@goondocks/myco 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-run-2NFYMQXW.js → agent-run-I4O2K2CK.js} +4 -4
- package/dist/{agent-tasks-MEIYLXGN.js → agent-tasks-UOW5BQIB.js} +4 -4
- package/dist/{chunk-JMOUFG6Y.js → chunk-44PZCAYS.js} +47 -5
- package/dist/chunk-44PZCAYS.js.map +1 -0
- package/dist/{chunk-JDI4DPWD.js → chunk-C3EGL5JX.js} +632 -145
- package/dist/chunk-C3EGL5JX.js.map +1 -0
- package/dist/{chunk-OW433Q4C.js → chunk-CURS2TNP.js} +44 -3
- package/dist/chunk-CURS2TNP.js.map +1 -0
- package/dist/{chunk-FABWUX5G.js → chunk-DPSLJ242.js} +16 -2
- package/dist/chunk-DPSLJ242.js.map +1 -0
- package/dist/{chunk-DLFDBKEV.js → chunk-LSP5HYOO.js} +17 -14
- package/dist/chunk-LSP5HYOO.js.map +1 -0
- package/dist/{chunk-VOCGURV7.js → chunk-N75GMQGA.js} +3 -3
- package/dist/{chunk-U7GJTVSX.js → chunk-RIDSOQDR.js} +20 -6
- package/dist/chunk-RIDSOQDR.js.map +1 -0
- package/dist/{chunk-KWTOCJLB.js → chunk-TCSVDQF5.js} +1128 -193
- package/dist/chunk-TCSVDQF5.js.map +1 -0
- package/dist/{chunk-55QEICRO.js → chunk-TLK46KKD.js} +2 -2
- package/dist/{chunk-NZI7WBZI.js → chunk-TOER6RNC.js} +21 -1
- package/dist/chunk-TOER6RNC.js.map +1 -0
- package/dist/{chunk-7OYXB2NM.js → chunk-TZAXQKO6.js} +5 -1
- package/dist/chunk-TZAXQKO6.js.map +1 -0
- package/dist/{chunk-EO2RQW4S.js → chunk-W7WENJ6F.js} +2 -2
- package/dist/{chunk-BUIR3JWM.js → chunk-XWOQL4XN.js} +2 -2
- package/dist/{chunk-PFWIPRF6.js → chunk-YZPI2Y3E.js} +2 -2
- package/dist/{cli-IIMBALPV.js → cli-D3TJYJ2U.js} +35 -35
- package/dist/{client-VZCUISHZ.js → client-4LLEXLVK.js} +3 -3
- package/dist/{detect-GEM3NVK6.js → detect-SZ2KDUF4.js} +2 -2
- package/dist/{doctor-QYD34X7Q.js → doctor-KCTXPX5D.js} +6 -6
- package/dist/{executor-NSPRTH4M.js → executor-UYIZC3L5.js} +83 -275
- package/dist/executor-UYIZC3L5.js.map +1 -0
- package/dist/{init-WYYL44KZ.js → init-QFNBKKDC.js} +7 -7
- package/dist/{llm-KEDHK3TQ.js → llm-SMA5ZEAW.js} +2 -2
- package/dist/{main-6PY3ITQ5.js → main-5THODR77.js} +427 -196
- package/dist/main-5THODR77.js.map +1 -0
- package/dist/{open-HRFMJDQX.js → open-7737CSPN.js} +4 -4
- package/dist/{post-compact-HT24YMAN.js → post-compact-2TJ5FPZH.js} +6 -6
- package/dist/{post-tool-use-DENRI5WB.js → post-tool-use-FRTSICC3.js} +5 -5
- package/dist/{post-tool-use-failure-A6SNJX42.js → post-tool-use-failure-KYO2NCNB.js} +6 -6
- package/dist/{pre-compact-3Q4BALCL.js → pre-compact-J6GCJEJR.js} +6 -6
- package/dist/{remove-YB5A6HY2.js → remove-3WZZC7AX.js} +5 -5
- package/dist/{restart-RGDVHELZ.js → restart-HUHEFOXU.js} +5 -5
- package/dist/{search-WOHT3G55.js → search-ZGN3LDXG.js} +5 -5
- package/dist/{server-6SUNYDV7.js → server-PTXLVVEE.js} +3 -3
- package/dist/{session-W3SKRFRV.js → session-7VV3IQMO.js} +5 -5
- package/dist/{session-end-OUTY7AFF.js → session-end-SMU55UCM.js} +5 -5
- package/dist/{session-start-5MB3LFOA.js → session-start-NIMWEOIZ.js} +16 -11
- package/dist/{session-start-5MB3LFOA.js.map → session-start-NIMWEOIZ.js.map} +1 -1
- package/dist/{setup-llm-ZMYGIQX5.js → setup-llm-7S3VPAPN.js} +4 -4
- package/dist/src/agent/definitions/tasks/extract-only.yaml +1 -1
- package/dist/src/agent/definitions/tasks/full-intelligence.yaml +10 -0
- package/dist/src/agent/definitions/tasks/skill-evolve.yaml +163 -49
- package/dist/src/agent/definitions/tasks/skill-generate.yaml +44 -27
- package/dist/src/agent/definitions/tasks/skill-survey.yaml +132 -138
- package/dist/src/agent/definitions/tasks/supersession-sweep.yaml +1 -1
- package/dist/src/cli.js +1 -1
- package/dist/src/daemon/main.js +1 -1
- package/dist/src/hooks/post-tool-use.js +1 -1
- package/dist/src/hooks/session-end.js +1 -1
- package/dist/src/hooks/session-start.js +1 -1
- package/dist/src/hooks/stop.js +1 -1
- package/dist/src/hooks/user-prompt-submit.js +1 -1
- package/dist/src/mcp/server.js +1 -1
- package/dist/src/symbionts/manifests/codex.yaml +45 -7
- package/dist/src/worker/src/index.ts +8 -2
- package/dist/src/worker/src/schema.ts +2 -0
- package/dist/{stats-DGI6B3HX.js → stats-GEOQ2DFF.js} +5 -5
- package/dist/{stop-YGHODSP7.js → stop-7AKYBJJ2.js} +5 -5
- package/dist/{stop-failure-7IJTPJ6W.js → stop-failure-NLE2EURG.js} +6 -6
- package/dist/{subagent-start-ZBQ5PJB5.js → subagent-start-LBNZF2TG.js} +6 -6
- package/dist/{subagent-stop-N2TDQU2D.js → subagent-stop-B2Z5GYAB.js} +6 -6
- package/dist/{task-completed-BDLMRSBB.js → task-completed-PO5TETJ7.js} +6 -6
- package/dist/{team-2ZFGTSIN.js → team-DPNP2RN7.js} +3 -3
- package/dist/ui/assets/{index-DtT9_nlT.js → index-CiI1fwas.js} +2 -2
- package/dist/ui/index.html +1 -1
- package/dist/{update-STLAN7LR.js → update-WBWB5URU.js} +5 -5
- package/dist/{user-prompt-submit-4IBFUYQ3.js → user-prompt-submit-IZJC3NV7.js} +11 -8
- package/dist/user-prompt-submit-IZJC3NV7.js.map +1 -0
- package/dist/{verify-EJYPO7QA.js → verify-FNSP62I3.js} +2 -2
- package/dist/{version-YPBIKH77.js → version-QEVU66NT.js} +2 -2
- package/package.json +7 -7
- package/dist/chunk-7OYXB2NM.js.map +0 -1
- package/dist/chunk-DLFDBKEV.js.map +0 -1
- package/dist/chunk-FABWUX5G.js.map +0 -1
- package/dist/chunk-JDI4DPWD.js.map +0 -1
- package/dist/chunk-JMOUFG6Y.js.map +0 -1
- package/dist/chunk-KWTOCJLB.js.map +0 -1
- package/dist/chunk-NZI7WBZI.js.map +0 -1
- package/dist/chunk-OW433Q4C.js.map +0 -1
- package/dist/chunk-U7GJTVSX.js.map +0 -1
- package/dist/executor-NSPRTH4M.js.map +0 -1
- package/dist/main-6PY3ITQ5.js.map +0 -1
- package/dist/user-prompt-submit-4IBFUYQ3.js.map +0 -1
- /package/dist/{agent-run-2NFYMQXW.js.map → agent-run-I4O2K2CK.js.map} +0 -0
- /package/dist/{agent-tasks-MEIYLXGN.js.map → agent-tasks-UOW5BQIB.js.map} +0 -0
- /package/dist/{chunk-VOCGURV7.js.map → chunk-N75GMQGA.js.map} +0 -0
- /package/dist/{chunk-55QEICRO.js.map → chunk-TLK46KKD.js.map} +0 -0
- /package/dist/{chunk-EO2RQW4S.js.map → chunk-W7WENJ6F.js.map} +0 -0
- /package/dist/{chunk-BUIR3JWM.js.map → chunk-XWOQL4XN.js.map} +0 -0
- /package/dist/{chunk-PFWIPRF6.js.map → chunk-YZPI2Y3E.js.map} +0 -0
- /package/dist/{cli-IIMBALPV.js.map → cli-D3TJYJ2U.js.map} +0 -0
- /package/dist/{client-VZCUISHZ.js.map → client-4LLEXLVK.js.map} +0 -0
- /package/dist/{detect-GEM3NVK6.js.map → detect-SZ2KDUF4.js.map} +0 -0
- /package/dist/{doctor-QYD34X7Q.js.map → doctor-KCTXPX5D.js.map} +0 -0
- /package/dist/{init-WYYL44KZ.js.map → init-QFNBKKDC.js.map} +0 -0
- /package/dist/{llm-KEDHK3TQ.js.map → llm-SMA5ZEAW.js.map} +0 -0
- /package/dist/{open-HRFMJDQX.js.map → open-7737CSPN.js.map} +0 -0
- /package/dist/{post-compact-HT24YMAN.js.map → post-compact-2TJ5FPZH.js.map} +0 -0
- /package/dist/{post-tool-use-DENRI5WB.js.map → post-tool-use-FRTSICC3.js.map} +0 -0
- /package/dist/{post-tool-use-failure-A6SNJX42.js.map → post-tool-use-failure-KYO2NCNB.js.map} +0 -0
- /package/dist/{pre-compact-3Q4BALCL.js.map → pre-compact-J6GCJEJR.js.map} +0 -0
- /package/dist/{remove-YB5A6HY2.js.map → remove-3WZZC7AX.js.map} +0 -0
- /package/dist/{restart-RGDVHELZ.js.map → restart-HUHEFOXU.js.map} +0 -0
- /package/dist/{search-WOHT3G55.js.map → search-ZGN3LDXG.js.map} +0 -0
- /package/dist/{server-6SUNYDV7.js.map → server-PTXLVVEE.js.map} +0 -0
- /package/dist/{session-W3SKRFRV.js.map → session-7VV3IQMO.js.map} +0 -0
- /package/dist/{session-end-OUTY7AFF.js.map → session-end-SMU55UCM.js.map} +0 -0
- /package/dist/{setup-llm-ZMYGIQX5.js.map → setup-llm-7S3VPAPN.js.map} +0 -0
- /package/dist/{stats-DGI6B3HX.js.map → stats-GEOQ2DFF.js.map} +0 -0
- /package/dist/{stop-YGHODSP7.js.map → stop-7AKYBJJ2.js.map} +0 -0
- /package/dist/{stop-failure-7IJTPJ6W.js.map → stop-failure-NLE2EURG.js.map} +0 -0
- /package/dist/{subagent-start-ZBQ5PJB5.js.map → subagent-start-LBNZF2TG.js.map} +0 -0
- /package/dist/{subagent-stop-N2TDQU2D.js.map → subagent-stop-B2Z5GYAB.js.map} +0 -0
- /package/dist/{task-completed-BDLMRSBB.js.map → task-completed-PO5TETJ7.js.map} +0 -0
- /package/dist/{team-2ZFGTSIN.js.map → team-DPNP2RN7.js.map} +0 -0
- /package/dist/{update-STLAN7LR.js.map → update-WBWB5URU.js.map} +0 -0
- /package/dist/{verify-EJYPO7QA.js.map → verify-FNSP62I3.js.map} +0 -0
- /package/dist/{version-YPBIKH77.js.map → version-QEVU66NT.js.map} +0 -0
|
@@ -471,7 +471,7 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
|
|
|
471
471
|
|
|
472
472
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
473
473
|
|
|
474
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},vF="DialogDescriptionWarning",pF=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${FD(vF).contentName}}.`;return j.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},mF=kD,gF=jD,yF=RD,UD=DD,qD=MD,VD=OD,HD=PD,xF=zD;const Ad=mF,bF=gF,wF=yF,$D=j.forwardRef(({className:e,...t},n)=>d.jsx(UD,{ref:n,className:ke("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));$D.displayName=UD.displayName;const pc=j.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(wF,{children:[d.jsx($D,{}),d.jsxs(qD,{ref:r,className:ke("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 [&>*]:min-w-0 border-0 bg-surface-container-highest p-6 shadow-ambient duration-200 sm:rounded-lg",e),...n,children:[t,d.jsxs(xF,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[d.jsx(is,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pc.displayName=qD.displayName;function Rd({className:e,...t}){return d.jsx("div",{className:ke("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}Rd.displayName="DialogHeader";function Xp({className:e,...t}){return d.jsx("div",{className:ke("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}Xp.displayName="DialogFooter";const mc=j.forwardRef(({className:e,...t},n)=>d.jsx(VD,{ref:n,className:ke("text-lg font-serif font-semibold leading-none tracking-tight",e),...t}));mc.displayName=VD.displayName;const Qp=j.forwardRef(({className:e,...t},n)=>d.jsx(HD,{ref:n,className:ke("text-sm text-on-surface-variant",e),...t}));Qp.displayName=HD.displayName;const fn=j.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:ke("flex h-9 w-full rounded-md bg-surface-container-lowest border border-[var(--ghost-border)] px-3 py-1 font-sans text-sm text-on-surface shadow-none transition-colors","file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-on-surface","placeholder:text-on-surface-variant/50","focus-visible:outline-none focus-visible:border-primary/40","disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));fn.displayName="Input";var GD="Toggle",KD=j.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:a,...i}=e,[l,o]=dp({prop:n,onChange:a,defaultProp:r??!1,caller:GD});return d.jsx(Zt.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:tn(e.onClick,()=>{e.disabled||o(!l)})})});KD.displayName=GD;var YD=KD;const SF=Hp("inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-surface-container-high/80 hover:text-on-surface-variant focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-primary data-[state=on]:text-on-primary",{variants:{variant:{default:"bg-surface-container-high text-on-surface-variant",outline:"border border-input bg-surface-container-high text-on-surface-variant shadow-sm hover:bg-surface-container-high/80 hover:text-on-surface-variant"},size:{default:"h-9 px-3",sm:"h-8 px-2",lg:"h-10 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Db=j.forwardRef(({className:e,variant:t,size:n,...r},a)=>d.jsx(YD,{ref:a,className:ke(SF({variant:t,size:n,className:e})),...r}));Db.displayName=YD.displayName;const EF=Hp("inline-flex items-center rounded-sm px-2 py-0.5 font-sans text-xs font-medium transition-colors",{variants:{variant:{default:"bg-primary/15 text-primary",secondary:"bg-surface-container-high text-on-surface-variant",destructive:"bg-tertiary/15 text-tertiary",warning:"bg-secondary/15 text-secondary",outline:"border border-[var(--ghost-border)] text-on-surface-variant"}},defaultVariants:{variant:"default"}});function wt({className:e,variant:t,...n}){return d.jsx("div",{className:ke(EF({variant:t}),e),...n})}const CF=120,NF={session:{label:"Sessions",icon:Up},spore:{label:"Spores",icon:z1},plan:{label:"Plans",icon:xz},prompt_batch:{label:"Prompt Batches",icon:Eb},activity:{label:"Activities",icon:Eb}};function XD(e){return NF[e]??{label:e,icon:Nz}}function kF(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function TF({score:e}){const t=Math.round(e*100);return d.jsxs(wt,{variant:"outline",className:"shrink-0 text-xs tabular-nums text-on-surface-variant",children:[t,"%"]})}function jF({result:e,onSelect:t,isHighlighted:n}){const{icon:r}=XD(e.type);return d.jsxs("button",{type:"button",onClick:()=>t(e),className:["w-full flex items-start gap-3 px-3 py-2 text-left rounded-md transition-colors",n?"bg-surface-container-high text-on-surface":"hover:bg-surface-container-high hover:text-on-surface"].join(" "),children:[d.jsx(r,{className:"h-4 w-4 mt-0.5 shrink-0 text-on-surface-variant"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("span",{className:"text-sm font-medium truncate",children:e.title})}),e.preview&&d.jsx("p",{className:"text-xs text-on-surface-variant mt-0.5 line-clamp-2",children:kF(e.preview,CF)})]}),d.jsx(TF,{score:e.score})]})}function AF({results:e,onSelect:t,highlightedIndex:n}){const r=e.reduce((i,l)=>{const o=l.type??"unknown";return(i[o]??(i[o]=[])).push(l),i},{});let a=0;return d.jsx("div",{className:"py-2 space-y-1",children:Object.entries(r).map(([i,l])=>{const{label:o}=XD(i),c=a;return a+=l.length,d.jsxs("div",{children:[d.jsx("div",{className:"px-3 py-1",children:d.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-on-surface-variant",children:o})}),l.map((f,h)=>d.jsx(jF,{result:f,onSelect:t,isHighlighted:n===c+h},f.id))]},i)})})}const RF=2,DF=3e4;function MF(e,t="semantic"){return Wt({queryKey:["search",e,t],queryFn:({signal:n})=>lt(`/search?q=${encodeURIComponent(e)}&mode=${t}`,{signal:n}),enabled:e.length>RF,staleTime:DF})}const _F=300,OF=20;function LF(e){switch(e.type){case"session":return`/sessions/${e.id}`;case"spore":return`/mycelium?tab=spores&spore=${encodeURIComponent(e.id)}`;case"plan":return e.session_id?`/sessions/${e.session_id}?tab=plans&plan=${encodeURIComponent(e.id)}`:"/sessions";case"prompt_batch":return e.session_id?`/sessions/${e.session_id}`:"/sessions";case"activity":return e.session_id?`/sessions/${e.session_id}`:"/sessions";default:return"/"}}function PF({open:e,onOpenChange:t}){const n=Qa(),[r,a]=j.useState(""),[i,l]=j.useState(""),[o,c]=j.useState("semantic"),[f,h]=j.useState(0),p=j.useRef(null);j.useEffect(()=>{const C=setTimeout(()=>{l(r.trim())},_F);return()=>clearTimeout(C)},[r]),j.useEffect(()=>{e&&(a(""),l(""),h(0),setTimeout(()=>{var C;return(C=p.current)==null?void 0:C.focus()},50))},[e]);const{data:m,isLoading:y}=MF(i,o),x=((m==null?void 0:m.results)??[]).slice(0,OF);j.useEffect(()=>{h(0)},[x.length,i]);const b=j.useCallback(C=>{const T=LF(C);t(!1),n(T)},[n,t]),w=j.useCallback(C=>{if(x.length!==0){if(C.key==="ArrowDown")C.preventDefault(),h(T=>Math.min(T+1,x.length-1));else if(C.key==="ArrowUp")C.preventDefault(),h(T=>Math.max(T-1,0));else if(C.key==="Enter"){C.preventDefault();const T=x[f];T&&b(T)}}},[x,f,b]),S=i.length>2&&!y&&x.length===0,N=i.length<=2&&!y;return d.jsx(Ad,{open:e,onOpenChange:t,children:d.jsxs(pc,{className:"max-w-2xl p-0 gap-0 overflow-hidden",onKeyDown:w,children:[d.jsx(mc,{className:"sr-only",children:"Search vault"}),d.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--ghost-border)] pl-4 pr-12 py-3",children:[d.jsx(dc,{className:"h-4 w-4 shrink-0 text-on-surface-variant"}),d.jsx(fn,{ref:p,value:r,onChange:C=>a(C.target.value),placeholder:"Search sessions, spores, plans…",className:"border-0 shadow-none focus-visible:ring-0 px-0 h-auto text-base bg-surface-bright font-mono"}),d.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[d.jsx(Db,{size:"sm",pressed:o==="semantic",onPressedChange:()=>c("semantic"),"aria-label":"Semantic search",title:"Semantic (embedded knowledge)",children:"Semantic"}),d.jsx(Db,{size:"sm",pressed:o==="fts",onPressedChange:()=>c("fts"),"aria-label":"Full-text search",title:"Full text (raw data)",children:"Full Text"})]})]}),d.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[y&&i.length>2&&d.jsx("div",{className:"px-4 py-8 text-center",children:d.jsxs("div",{className:"flex flex-col items-center gap-2 text-on-surface-variant",children:[d.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),d.jsx("div",{className:"h-3 w-24 rounded bg-muted animate-pulse"}),d.jsx("div",{className:"h-3 w-28 rounded bg-muted animate-pulse"})]})}),N&&d.jsx("div",{className:"px-4 py-8 text-center text-sm text-on-surface-variant",children:"Type to search your vault…"}),S&&d.jsxs("div",{className:"px-4 py-8 text-center text-sm text-on-surface-variant",children:["No results for ",d.jsxs("span",{className:"font-medium text-on-surface",children:['"',i,'"']})]}),x.length>0&&!y&&d.jsx(AF,{results:x,onSelect:b,highlightedIndex:f})]}),d.jsxs("div",{className:"border-t border-[var(--ghost-border)] px-4 py-2 flex items-center gap-4 text-xs text-on-surface-variant",children:[d.jsxs("span",{children:[d.jsx("kbd",{className:"font-mono",children:"↑↓"})," navigate"]}),d.jsxs("span",{children:[d.jsx("kbd",{className:"font-mono",children:"↵"})," open"]}),d.jsxs("span",{children:[d.jsx("kbd",{className:"font-mono",children:"Esc"})," close"]}),d.jsx("span",{className:"ml-auto",children:(m==null?void 0:m.mode)&&x.length>0&&`${x.length} result${x.length!==1?"s":""} · ${m.mode}`})]})]})})}const BF=Sr.STATS;function zF(){return Qr({queryKey:["notifications","unread-count"],queryFn:({signal:e})=>lt("/notifications/unread-count",{signal:e}),refetchInterval:BF,pollCategory:"standard"})}function Z1(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.domain&&t.set("domain",e.domain),e!=null&&e.mode&&t.set("mode",e.mode),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/notifications?${n}`:"/notifications";return Wt({queryKey:["notifications","list",e],queryFn:({signal:a})=>lt(r,{signal:a})})}function IF(){return Wt({queryKey:["notifications","registry"],queryFn:({signal:e})=>lt("/notifications/registry",{signal:e}),staleTime:6e4})}function QD(){const e=jn();return wr({mutationFn:({id:t,status:n})=>lt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify({status:n}),headers:{"Content-Type":"application/json"}}),onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}function FF(){const e=jn();return wr({mutationFn:t=>nn("/notifications/dismiss-all",t?{domain:t}:{}),onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}function UF(){const e=jn();return wr({mutationFn:t=>nn("/notifications/mark-all-read",t?{domain:t}:{}),onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}const qF=3,VF=8e3,HF={info:"bg-primary/10 border-primary/20 text-primary",success:"bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400",warning:"bg-secondary/10 border-secondary/20 text-secondary",error:"bg-tertiary/10 border-tertiary/20 text-tertiary"},$F={info:KR,success:Td,warning:WR,error:Dr};function GF(){const{data:e}=Z1({status:"unread",mode:"banner",limit:qF}),t=QD(),n=Qa(),[r,a]=j.useState(new Set),i=((e==null?void 0:e.items)??[]).filter(c=>!r.has(c.id));if(j.useEffect(()=>{const c=[];for(const f of i)f.level!=="error"&&c.push(setTimeout(()=>{a(h=>new Set(h).add(f.id)),t.mutate({id:f.id,status:"read"})},VF));return()=>c.forEach(clearTimeout)},[i.map(c=>c.id).join(",")]),i.length===0)return null;const l=c=>{t.mutate({id:c.id,status:"read"}),a(f=>new Set(f).add(c.id)),c.link&&n(c.link)},o=(c,f)=>{c.stopPropagation(),a(h=>new Set(h).add(f.id)),t.mutate({id:f.id,status:"read"})};return d.jsx("div",{className:"fixed top-3 right-3 z-50 flex flex-col gap-2 w-80",children:i.map(c=>{const f=$F[c.level];return d.jsxs("div",{onClick:()=>l(c),className:ke("flex items-start gap-2 rounded-md border px-3 py-2.5 text-sm shadow-lg cursor-pointer transition-all animate-in slide-in-from-right-5 fade-in duration-200",HF[c.level]),children:[d.jsx(f,{className:"h-4 w-4 mt-0.5 shrink-0"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"font-medium truncate",children:c.title}),c.message&&d.jsx("div",{className:"text-xs mt-0.5 opacity-80 line-clamp-2",children:c.message})]}),d.jsx("button",{onClick:h=>o(h,c),className:"shrink-0 rounded p-0.5 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:d.jsx(is,{className:"h-3.5 w-3.5"})})]},c.id)})})}function KF(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const YF=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XF=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QF={};function FN(e,t){return(QF.jsx?XF:YF).test(e)}const WF=/[ \t\n\f\r]/g;function ZF(e){return typeof e=="object"?e.type==="text"?UN(e.value):!1:UN(e)}function UN(e){return e.replace(WF,"")===""}class Dd{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Dd.prototype.normal={};Dd.prototype.property={};Dd.prototype.space=void 0;function WD(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Dd(n,r,t)}function Mb(e){return e.toLowerCase()}class Wr{constructor(t,n){this.attribute=n,this.property=t}}Wr.prototype.attribute="";Wr.prototype.booleanish=!1;Wr.prototype.boolean=!1;Wr.prototype.commaOrSpaceSeparated=!1;Wr.prototype.commaSeparated=!1;Wr.prototype.defined=!1;Wr.prototype.mustUseProperty=!1;Wr.prototype.number=!1;Wr.prototype.overloadedBoolean=!1;Wr.prototype.property="";Wr.prototype.spaceSeparated=!1;Wr.prototype.space=void 0;let JF=0;const yt=Oo(),On=Oo(),_b=Oo(),je=Oo(),en=Oo(),Fu=Oo(),sa=Oo();function Oo(){return 2**++JF}const Ob=Object.freeze(Object.defineProperty({__proto__:null,boolean:yt,booleanish:On,commaOrSpaceSeparated:sa,commaSeparated:Fu,number:je,overloadedBoolean:_b,spaceSeparated:en},Symbol.toStringTag,{value:"Module"})),ax=Object.keys(Ob);class J1 extends Wr{constructor(t,n,r,a){let i=-1;if(super(t,n),qN(this,"space",a),typeof r=="number")for(;++i<ax.length;){const l=ax[i];qN(this,ax[i],(r&Ob[l])===Ob[l])}}}J1.prototype.defined=!0;function qN(e,t,n){n&&(e[t]=n)}function gc(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new J1(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Mb(r)]=r,n[Mb(i.attribute)]=r}return new Dd(t,n,e.space)}const ZD=gc({properties:{ariaActiveDescendant:null,ariaAtomic:On,ariaAutoComplete:null,ariaBusy:On,ariaChecked:On,ariaColCount:je,ariaColIndex:je,ariaColSpan:je,ariaControls:en,ariaCurrent:null,ariaDescribedBy:en,ariaDetails:null,ariaDisabled:On,ariaDropEffect:en,ariaErrorMessage:null,ariaExpanded:On,ariaFlowTo:en,ariaGrabbed:On,ariaHasPopup:null,ariaHidden:On,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:en,ariaLevel:je,ariaLive:null,ariaModal:On,ariaMultiLine:On,ariaMultiSelectable:On,ariaOrientation:null,ariaOwns:en,ariaPlaceholder:null,ariaPosInSet:je,ariaPressed:On,ariaReadOnly:On,ariaRelevant:null,ariaRequired:On,ariaRoleDescription:en,ariaRowCount:je,ariaRowIndex:je,ariaRowSpan:je,ariaSelected:On,ariaSetSize:je,ariaSort:null,ariaValueMax:je,ariaValueMin:je,ariaValueNow:je,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function JD(e,t){return t in e?e[t]:t}function eM(e,t){return JD(e,t.toLowerCase())}const eU=gc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Fu,acceptCharset:en,accessKey:en,action:null,allow:null,allowFullScreen:yt,allowPaymentRequest:yt,allowUserMedia:yt,alt:null,as:null,async:yt,autoCapitalize:null,autoComplete:en,autoFocus:yt,autoPlay:yt,blocking:en,capture:null,charSet:null,checked:yt,cite:null,className:en,cols:je,colSpan:null,content:null,contentEditable:On,controls:yt,controlsList:en,coords:je|Fu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:yt,defer:yt,dir:null,dirName:null,disabled:yt,download:_b,draggable:On,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:yt,formTarget:null,headers:en,height:je,hidden:_b,high:je,href:null,hrefLang:null,htmlFor:en,httpEquiv:en,id:null,imageSizes:null,imageSrcSet:null,inert:yt,inputMode:null,integrity:null,is:null,isMap:yt,itemId:null,itemProp:en,itemRef:en,itemScope:yt,itemType:en,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:yt,low:je,manifest:null,max:null,maxLength:je,media:null,method:null,min:null,minLength:je,multiple:yt,muted:yt,name:null,nonce:null,noModule:yt,noValidate:yt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:yt,optimum:je,pattern:null,ping:en,placeholder:null,playsInline:yt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:yt,referrerPolicy:null,rel:en,required:yt,reversed:yt,rows:je,rowSpan:je,sandbox:en,scope:null,scoped:yt,seamless:yt,selected:yt,shadowRootClonable:yt,shadowRootDelegatesFocus:yt,shadowRootMode:null,shape:null,size:je,sizes:null,slot:null,span:je,spellCheck:On,src:null,srcDoc:null,srcLang:null,srcSet:null,start:je,step:null,style:null,tabIndex:je,target:null,title:null,translate:null,type:null,typeMustMatch:yt,useMap:null,value:On,width:je,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:en,axis:null,background:null,bgColor:null,border:je,borderColor:null,bottomMargin:je,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:yt,declare:yt,event:null,face:null,frame:null,frameBorder:null,hSpace:je,leftMargin:je,link:null,longDesc:null,lowSrc:null,marginHeight:je,marginWidth:je,noResize:yt,noHref:yt,noShade:yt,noWrap:yt,object:null,profile:null,prompt:null,rev:null,rightMargin:je,rules:null,scheme:null,scrolling:On,standby:null,summary:null,text:null,topMargin:je,valueType:null,version:null,vAlign:null,vLink:null,vSpace:je,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:yt,disableRemotePlayback:yt,prefix:null,property:null,results:je,security:null,unselectable:null},space:"html",transform:eM}),tU=gc({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:sa,accentHeight:je,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:je,amplitude:je,arabicForm:null,ascent:je,attributeName:null,attributeType:null,azimuth:je,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:je,by:null,calcMode:null,capHeight:je,className:en,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:je,diffuseConstant:je,direction:null,display:null,dur:null,divisor:je,dominantBaseline:null,download:yt,dx:null,dy:null,edgeMode:null,editable:null,elevation:je,enableBackground:null,end:null,event:null,exponent:je,externalResourcesRequired:null,fill:null,fillOpacity:je,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Fu,g2:Fu,glyphName:Fu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:je,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:je,horizOriginX:je,horizOriginY:je,id:null,ideographic:je,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:je,k:je,k1:je,k2:je,k3:je,k4:je,kernelMatrix:sa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:je,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:je,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:je,overlineThickness:je,paintOrder:null,panose1:null,path:null,pathLength:je,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:en,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:je,pointsAtY:je,pointsAtZ:je,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:sa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:sa,rev:sa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:sa,requiredFeatures:sa,requiredFonts:sa,requiredFormats:sa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:je,specularExponent:je,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:je,strikethroughThickness:je,string:null,stroke:null,strokeDashArray:sa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:je,strokeOpacity:je,strokeWidth:null,style:null,surfaceScale:je,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:sa,tabIndex:je,tableValues:null,target:null,targetX:je,targetY:je,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:sa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:je,underlineThickness:je,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:je,values:null,vAlphabetic:je,vMathematical:je,vectorEffect:null,vHanging:je,vIdeographic:je,version:null,vertAdvY:je,vertOriginX:je,vertOriginY:je,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:je,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:JD}),tM=gc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),nM=gc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:eM}),rM=gc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nU={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},rU=/[A-Z]/g,VN=/-[a-z]/g,aU=/^data[-\w.:]+$/i;function iU(e,t){const n=Mb(t);let r=t,a=Wr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&aU.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(VN,lU);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!VN.test(i)){let l=i.replace(rU,sU);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}a=J1}return new a(r,t)}function sU(e){return"-"+e.toLowerCase()}function lU(e){return e.charAt(1).toUpperCase()}const oU=WD([ZD,eU,tM,nM,rM],"html"),ew=WD([ZD,tU,tM,nM,rM],"svg");function uU(e){return e.join(" ").trim()}var wu={},ix,HN;function cU(){if(HN)return ix;HN=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,o=/^\s+|\s+$/g,c=`
|
|
474
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},vF="DialogDescriptionWarning",pF=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${FD(vF).contentName}}.`;return j.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},mF=kD,gF=jD,yF=RD,UD=DD,qD=MD,VD=OD,HD=PD,xF=zD;const Ad=mF,bF=gF,wF=yF,$D=j.forwardRef(({className:e,...t},n)=>d.jsx(UD,{ref:n,className:ke("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));$D.displayName=UD.displayName;const pc=j.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(wF,{children:[d.jsx($D,{}),d.jsxs(qD,{ref:r,className:ke("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 [&>*]:min-w-0 border-0 bg-surface-container-highest p-6 shadow-ambient duration-200 sm:rounded-lg",e),...n,children:[t,d.jsxs(xF,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[d.jsx(is,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pc.displayName=qD.displayName;function Rd({className:e,...t}){return d.jsx("div",{className:ke("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}Rd.displayName="DialogHeader";function Xp({className:e,...t}){return d.jsx("div",{className:ke("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}Xp.displayName="DialogFooter";const mc=j.forwardRef(({className:e,...t},n)=>d.jsx(VD,{ref:n,className:ke("text-lg font-serif font-semibold leading-none tracking-tight",e),...t}));mc.displayName=VD.displayName;const Qp=j.forwardRef(({className:e,...t},n)=>d.jsx(HD,{ref:n,className:ke("text-sm text-on-surface-variant",e),...t}));Qp.displayName=HD.displayName;const fn=j.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:ke("flex h-9 w-full rounded-md bg-surface-container-lowest border border-[var(--ghost-border)] px-3 py-1 font-sans text-sm text-on-surface shadow-none transition-colors","file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-on-surface","placeholder:text-on-surface-variant/50","focus-visible:outline-none focus-visible:border-primary/40","disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));fn.displayName="Input";var GD="Toggle",KD=j.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:a,...i}=e,[l,o]=dp({prop:n,onChange:a,defaultProp:r??!1,caller:GD});return d.jsx(Zt.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:tn(e.onClick,()=>{e.disabled||o(!l)})})});KD.displayName=GD;var YD=KD;const SF=Hp("inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-surface-container-high/80 hover:text-on-surface-variant focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-primary data-[state=on]:text-on-primary",{variants:{variant:{default:"bg-surface-container-high text-on-surface-variant",outline:"border border-input bg-surface-container-high text-on-surface-variant shadow-sm hover:bg-surface-container-high/80 hover:text-on-surface-variant"},size:{default:"h-9 px-3",sm:"h-8 px-2",lg:"h-10 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Db=j.forwardRef(({className:e,variant:t,size:n,...r},a)=>d.jsx(YD,{ref:a,className:ke(SF({variant:t,size:n,className:e})),...r}));Db.displayName=YD.displayName;const EF=Hp("inline-flex items-center rounded-sm px-2 py-0.5 font-sans text-xs font-medium transition-colors",{variants:{variant:{default:"bg-primary/15 text-primary",secondary:"bg-surface-container-high text-on-surface-variant",destructive:"bg-tertiary/15 text-tertiary",warning:"bg-secondary/15 text-secondary",outline:"border border-[var(--ghost-border)] text-on-surface-variant"}},defaultVariants:{variant:"default"}});function wt({className:e,variant:t,...n}){return d.jsx("div",{className:ke(EF({variant:t}),e),...n})}const CF=120,NF={session:{label:"Sessions",icon:Up},spore:{label:"Spores",icon:z1},plan:{label:"Plans",icon:xz},prompt_batch:{label:"Prompt Batches",icon:Eb},activity:{label:"Activities",icon:Eb}};function XD(e){return NF[e]??{label:e,icon:Nz}}function kF(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function TF({score:e}){const t=Math.round(e*100);return d.jsxs(wt,{variant:"outline",className:"shrink-0 text-xs tabular-nums text-on-surface-variant",children:[t,"%"]})}function jF({result:e,onSelect:t,isHighlighted:n}){const{icon:r}=XD(e.type);return d.jsxs("button",{type:"button",onClick:()=>t(e),className:["w-full flex items-start gap-3 px-3 py-2 text-left rounded-md transition-colors",n?"bg-surface-container-high text-on-surface":"hover:bg-surface-container-high hover:text-on-surface"].join(" "),children:[d.jsx(r,{className:"h-4 w-4 mt-0.5 shrink-0 text-on-surface-variant"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("span",{className:"text-sm font-medium truncate",children:e.title})}),e.preview&&d.jsx("p",{className:"text-xs text-on-surface-variant mt-0.5 line-clamp-2",children:kF(e.preview,CF)})]}),d.jsx(TF,{score:e.score})]})}function AF({results:e,onSelect:t,highlightedIndex:n}){const r=e.reduce((i,l)=>{const o=l.type??"unknown";return(i[o]??(i[o]=[])).push(l),i},{});let a=0;return d.jsx("div",{className:"py-2 space-y-1",children:Object.entries(r).map(([i,l])=>{const{label:o}=XD(i),c=a;return a+=l.length,d.jsxs("div",{children:[d.jsx("div",{className:"px-3 py-1",children:d.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-on-surface-variant",children:o})}),l.map((f,h)=>d.jsx(jF,{result:f,onSelect:t,isHighlighted:n===c+h},f.id))]},i)})})}const RF=2,DF=3e4;function MF(e,t="semantic"){return Wt({queryKey:["search",e,t],queryFn:({signal:n})=>lt(`/search?q=${encodeURIComponent(e)}&mode=${t}`,{signal:n}),enabled:e.length>RF,staleTime:DF})}const _F=300,OF=20;function LF(e){switch(e.type){case"session":return`/sessions/${e.id}`;case"spore":return`/mycelium?tab=spores&spore=${encodeURIComponent(e.id)}`;case"plan":return e.session_id?`/sessions/${e.session_id}?tab=plans&plan=${encodeURIComponent(e.id)}`:"/sessions";case"prompt_batch":return e.session_id?`/sessions/${e.session_id}`:"/sessions";case"activity":return e.session_id?`/sessions/${e.session_id}`:"/sessions";case"skill":return`/skills?skill=${encodeURIComponent(e.id)}`;default:return"/"}}function PF({open:e,onOpenChange:t}){const n=Qa(),[r,a]=j.useState(""),[i,l]=j.useState(""),[o,c]=j.useState("semantic"),[f,h]=j.useState(0),p=j.useRef(null);j.useEffect(()=>{const C=setTimeout(()=>{l(r.trim())},_F);return()=>clearTimeout(C)},[r]),j.useEffect(()=>{e&&(a(""),l(""),h(0),setTimeout(()=>{var C;return(C=p.current)==null?void 0:C.focus()},50))},[e]);const{data:m,isLoading:y}=MF(i,o),x=((m==null?void 0:m.results)??[]).slice(0,OF);j.useEffect(()=>{h(0)},[x.length,i]);const b=j.useCallback(C=>{const T=LF(C);t(!1),n(T)},[n,t]),w=j.useCallback(C=>{if(x.length!==0){if(C.key==="ArrowDown")C.preventDefault(),h(T=>Math.min(T+1,x.length-1));else if(C.key==="ArrowUp")C.preventDefault(),h(T=>Math.max(T-1,0));else if(C.key==="Enter"){C.preventDefault();const T=x[f];T&&b(T)}}},[x,f,b]),S=i.length>2&&!y&&x.length===0,N=i.length<=2&&!y;return d.jsx(Ad,{open:e,onOpenChange:t,children:d.jsxs(pc,{className:"max-w-2xl p-0 gap-0 overflow-hidden",onKeyDown:w,children:[d.jsx(mc,{className:"sr-only",children:"Search vault"}),d.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--ghost-border)] pl-4 pr-12 py-3",children:[d.jsx(dc,{className:"h-4 w-4 shrink-0 text-on-surface-variant"}),d.jsx(fn,{ref:p,value:r,onChange:C=>a(C.target.value),placeholder:"Search sessions, spores, plans…",className:"border-0 shadow-none focus-visible:ring-0 px-0 h-auto text-base bg-surface-bright font-mono"}),d.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[d.jsx(Db,{size:"sm",pressed:o==="semantic",onPressedChange:()=>c("semantic"),"aria-label":"Semantic search",title:"Semantic (embedded knowledge)",children:"Semantic"}),d.jsx(Db,{size:"sm",pressed:o==="fts",onPressedChange:()=>c("fts"),"aria-label":"Full-text search",title:"Full text (raw data)",children:"Full Text"})]})]}),d.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[y&&i.length>2&&d.jsx("div",{className:"px-4 py-8 text-center",children:d.jsxs("div",{className:"flex flex-col items-center gap-2 text-on-surface-variant",children:[d.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),d.jsx("div",{className:"h-3 w-24 rounded bg-muted animate-pulse"}),d.jsx("div",{className:"h-3 w-28 rounded bg-muted animate-pulse"})]})}),N&&d.jsx("div",{className:"px-4 py-8 text-center text-sm text-on-surface-variant",children:"Type to search your vault…"}),S&&d.jsxs("div",{className:"px-4 py-8 text-center text-sm text-on-surface-variant",children:["No results for ",d.jsxs("span",{className:"font-medium text-on-surface",children:['"',i,'"']})]}),x.length>0&&!y&&d.jsx(AF,{results:x,onSelect:b,highlightedIndex:f})]}),d.jsxs("div",{className:"border-t border-[var(--ghost-border)] px-4 py-2 flex items-center gap-4 text-xs text-on-surface-variant",children:[d.jsxs("span",{children:[d.jsx("kbd",{className:"font-mono",children:"↑↓"})," navigate"]}),d.jsxs("span",{children:[d.jsx("kbd",{className:"font-mono",children:"↵"})," open"]}),d.jsxs("span",{children:[d.jsx("kbd",{className:"font-mono",children:"Esc"})," close"]}),d.jsx("span",{className:"ml-auto",children:(m==null?void 0:m.mode)&&x.length>0&&`${x.length} result${x.length!==1?"s":""} · ${m.mode}`})]})]})})}const BF=Sr.STATS;function zF(){return Qr({queryKey:["notifications","unread-count"],queryFn:({signal:e})=>lt("/notifications/unread-count",{signal:e}),refetchInterval:BF,pollCategory:"standard"})}function Z1(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.domain&&t.set("domain",e.domain),e!=null&&e.mode&&t.set("mode",e.mode),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/notifications?${n}`:"/notifications";return Wt({queryKey:["notifications","list",e],queryFn:({signal:a})=>lt(r,{signal:a})})}function IF(){return Wt({queryKey:["notifications","registry"],queryFn:({signal:e})=>lt("/notifications/registry",{signal:e}),staleTime:6e4})}function QD(){const e=jn();return wr({mutationFn:({id:t,status:n})=>lt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify({status:n}),headers:{"Content-Type":"application/json"}}),onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}function FF(){const e=jn();return wr({mutationFn:t=>nn("/notifications/dismiss-all",t?{domain:t}:{}),onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}function UF(){const e=jn();return wr({mutationFn:t=>nn("/notifications/mark-all-read",t?{domain:t}:{}),onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}const qF=3,VF=8e3,HF={info:"bg-primary/10 border-primary/20 text-primary",success:"bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400",warning:"bg-secondary/10 border-secondary/20 text-secondary",error:"bg-tertiary/10 border-tertiary/20 text-tertiary"},$F={info:KR,success:Td,warning:WR,error:Dr};function GF(){const{data:e}=Z1({status:"unread",mode:"banner",limit:qF}),t=QD(),n=Qa(),[r,a]=j.useState(new Set),i=((e==null?void 0:e.items)??[]).filter(c=>!r.has(c.id));if(j.useEffect(()=>{const c=[];for(const f of i)f.level!=="error"&&c.push(setTimeout(()=>{a(h=>new Set(h).add(f.id)),t.mutate({id:f.id,status:"read"})},VF));return()=>c.forEach(clearTimeout)},[i.map(c=>c.id).join(",")]),i.length===0)return null;const l=c=>{t.mutate({id:c.id,status:"read"}),a(f=>new Set(f).add(c.id)),c.link&&n(c.link)},o=(c,f)=>{c.stopPropagation(),a(h=>new Set(h).add(f.id)),t.mutate({id:f.id,status:"read"})};return d.jsx("div",{className:"fixed top-3 right-3 z-50 flex flex-col gap-2 w-80",children:i.map(c=>{const f=$F[c.level];return d.jsxs("div",{onClick:()=>l(c),className:ke("flex items-start gap-2 rounded-md border px-3 py-2.5 text-sm shadow-lg cursor-pointer transition-all animate-in slide-in-from-right-5 fade-in duration-200",HF[c.level]),children:[d.jsx(f,{className:"h-4 w-4 mt-0.5 shrink-0"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"font-medium truncate",children:c.title}),c.message&&d.jsx("div",{className:"text-xs mt-0.5 opacity-80 line-clamp-2",children:c.message})]}),d.jsx("button",{onClick:h=>o(h,c),className:"shrink-0 rounded p-0.5 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:d.jsx(is,{className:"h-3.5 w-3.5"})})]},c.id)})})}function KF(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const YF=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XF=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QF={};function FN(e,t){return(QF.jsx?XF:YF).test(e)}const WF=/[ \t\n\f\r]/g;function ZF(e){return typeof e=="object"?e.type==="text"?UN(e.value):!1:UN(e)}function UN(e){return e.replace(WF,"")===""}class Dd{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Dd.prototype.normal={};Dd.prototype.property={};Dd.prototype.space=void 0;function WD(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Dd(n,r,t)}function Mb(e){return e.toLowerCase()}class Wr{constructor(t,n){this.attribute=n,this.property=t}}Wr.prototype.attribute="";Wr.prototype.booleanish=!1;Wr.prototype.boolean=!1;Wr.prototype.commaOrSpaceSeparated=!1;Wr.prototype.commaSeparated=!1;Wr.prototype.defined=!1;Wr.prototype.mustUseProperty=!1;Wr.prototype.number=!1;Wr.prototype.overloadedBoolean=!1;Wr.prototype.property="";Wr.prototype.spaceSeparated=!1;Wr.prototype.space=void 0;let JF=0;const yt=Oo(),On=Oo(),_b=Oo(),je=Oo(),en=Oo(),Fu=Oo(),sa=Oo();function Oo(){return 2**++JF}const Ob=Object.freeze(Object.defineProperty({__proto__:null,boolean:yt,booleanish:On,commaOrSpaceSeparated:sa,commaSeparated:Fu,number:je,overloadedBoolean:_b,spaceSeparated:en},Symbol.toStringTag,{value:"Module"})),ax=Object.keys(Ob);class J1 extends Wr{constructor(t,n,r,a){let i=-1;if(super(t,n),qN(this,"space",a),typeof r=="number")for(;++i<ax.length;){const l=ax[i];qN(this,ax[i],(r&Ob[l])===Ob[l])}}}J1.prototype.defined=!0;function qN(e,t,n){n&&(e[t]=n)}function gc(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new J1(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Mb(r)]=r,n[Mb(i.attribute)]=r}return new Dd(t,n,e.space)}const ZD=gc({properties:{ariaActiveDescendant:null,ariaAtomic:On,ariaAutoComplete:null,ariaBusy:On,ariaChecked:On,ariaColCount:je,ariaColIndex:je,ariaColSpan:je,ariaControls:en,ariaCurrent:null,ariaDescribedBy:en,ariaDetails:null,ariaDisabled:On,ariaDropEffect:en,ariaErrorMessage:null,ariaExpanded:On,ariaFlowTo:en,ariaGrabbed:On,ariaHasPopup:null,ariaHidden:On,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:en,ariaLevel:je,ariaLive:null,ariaModal:On,ariaMultiLine:On,ariaMultiSelectable:On,ariaOrientation:null,ariaOwns:en,ariaPlaceholder:null,ariaPosInSet:je,ariaPressed:On,ariaReadOnly:On,ariaRelevant:null,ariaRequired:On,ariaRoleDescription:en,ariaRowCount:je,ariaRowIndex:je,ariaRowSpan:je,ariaSelected:On,ariaSetSize:je,ariaSort:null,ariaValueMax:je,ariaValueMin:je,ariaValueNow:je,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function JD(e,t){return t in e?e[t]:t}function eM(e,t){return JD(e,t.toLowerCase())}const eU=gc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Fu,acceptCharset:en,accessKey:en,action:null,allow:null,allowFullScreen:yt,allowPaymentRequest:yt,allowUserMedia:yt,alt:null,as:null,async:yt,autoCapitalize:null,autoComplete:en,autoFocus:yt,autoPlay:yt,blocking:en,capture:null,charSet:null,checked:yt,cite:null,className:en,cols:je,colSpan:null,content:null,contentEditable:On,controls:yt,controlsList:en,coords:je|Fu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:yt,defer:yt,dir:null,dirName:null,disabled:yt,download:_b,draggable:On,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:yt,formTarget:null,headers:en,height:je,hidden:_b,high:je,href:null,hrefLang:null,htmlFor:en,httpEquiv:en,id:null,imageSizes:null,imageSrcSet:null,inert:yt,inputMode:null,integrity:null,is:null,isMap:yt,itemId:null,itemProp:en,itemRef:en,itemScope:yt,itemType:en,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:yt,low:je,manifest:null,max:null,maxLength:je,media:null,method:null,min:null,minLength:je,multiple:yt,muted:yt,name:null,nonce:null,noModule:yt,noValidate:yt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:yt,optimum:je,pattern:null,ping:en,placeholder:null,playsInline:yt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:yt,referrerPolicy:null,rel:en,required:yt,reversed:yt,rows:je,rowSpan:je,sandbox:en,scope:null,scoped:yt,seamless:yt,selected:yt,shadowRootClonable:yt,shadowRootDelegatesFocus:yt,shadowRootMode:null,shape:null,size:je,sizes:null,slot:null,span:je,spellCheck:On,src:null,srcDoc:null,srcLang:null,srcSet:null,start:je,step:null,style:null,tabIndex:je,target:null,title:null,translate:null,type:null,typeMustMatch:yt,useMap:null,value:On,width:je,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:en,axis:null,background:null,bgColor:null,border:je,borderColor:null,bottomMargin:je,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:yt,declare:yt,event:null,face:null,frame:null,frameBorder:null,hSpace:je,leftMargin:je,link:null,longDesc:null,lowSrc:null,marginHeight:je,marginWidth:je,noResize:yt,noHref:yt,noShade:yt,noWrap:yt,object:null,profile:null,prompt:null,rev:null,rightMargin:je,rules:null,scheme:null,scrolling:On,standby:null,summary:null,text:null,topMargin:je,valueType:null,version:null,vAlign:null,vLink:null,vSpace:je,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:yt,disableRemotePlayback:yt,prefix:null,property:null,results:je,security:null,unselectable:null},space:"html",transform:eM}),tU=gc({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:sa,accentHeight:je,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:je,amplitude:je,arabicForm:null,ascent:je,attributeName:null,attributeType:null,azimuth:je,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:je,by:null,calcMode:null,capHeight:je,className:en,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:je,diffuseConstant:je,direction:null,display:null,dur:null,divisor:je,dominantBaseline:null,download:yt,dx:null,dy:null,edgeMode:null,editable:null,elevation:je,enableBackground:null,end:null,event:null,exponent:je,externalResourcesRequired:null,fill:null,fillOpacity:je,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Fu,g2:Fu,glyphName:Fu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:je,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:je,horizOriginX:je,horizOriginY:je,id:null,ideographic:je,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:je,k:je,k1:je,k2:je,k3:je,k4:je,kernelMatrix:sa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:je,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:je,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:je,overlineThickness:je,paintOrder:null,panose1:null,path:null,pathLength:je,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:en,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:je,pointsAtY:je,pointsAtZ:je,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:sa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:sa,rev:sa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:sa,requiredFeatures:sa,requiredFonts:sa,requiredFormats:sa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:je,specularExponent:je,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:je,strikethroughThickness:je,string:null,stroke:null,strokeDashArray:sa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:je,strokeOpacity:je,strokeWidth:null,style:null,surfaceScale:je,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:sa,tabIndex:je,tableValues:null,target:null,targetX:je,targetY:je,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:sa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:je,underlineThickness:je,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:je,values:null,vAlphabetic:je,vMathematical:je,vectorEffect:null,vHanging:je,vIdeographic:je,version:null,vertAdvY:je,vertOriginX:je,vertOriginY:je,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:je,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:JD}),tM=gc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),nM=gc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:eM}),rM=gc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nU={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},rU=/[A-Z]/g,VN=/-[a-z]/g,aU=/^data[-\w.:]+$/i;function iU(e,t){const n=Mb(t);let r=t,a=Wr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&aU.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(VN,lU);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!VN.test(i)){let l=i.replace(rU,sU);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}a=J1}return new a(r,t)}function sU(e){return"-"+e.toLowerCase()}function lU(e){return e.charAt(1).toUpperCase()}const oU=WD([ZD,eU,tM,nM,rM],"html"),ew=WD([ZD,tU,tM,nM,rM],"svg");function uU(e){return e.join(" ").trim()}var wu={},ix,HN;function cU(){if(HN)return ix;HN=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,o=/^\s+|\s+$/g,c=`
|
|
475
475
|
`,f="/",h="*",p="",m="comment",y="declaration";function x(w,S){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];S=S||{};var N=1,C=1;function T($){var U=$.match(t);U&&(N+=U.length);var I=$.lastIndexOf(c);C=~I?$.length-I:C+$.length}function R(){var $={line:N,column:C};return function(U){return U.position=new A($),L(),U}}function A($){this.start=$,this.end={line:N,column:C},this.source=S.source}A.prototype.content=w;function D($){var U=new Error(S.source+":"+N+":"+C+": "+$);if(U.reason=$,U.filename=S.source,U.line=N,U.column=C,U.source=w,!S.silent)throw U}function O($){var U=$.exec(w);if(U){var I=U[0];return T(I),w=w.slice(I.length),U}}function L(){O(n)}function M($){var U;for($=$||[];U=P();)U!==!1&&$.push(U);return $}function P(){var $=R();if(!(f!=w.charAt(0)||h!=w.charAt(1))){for(var U=2;p!=w.charAt(U)&&(h!=w.charAt(U)||f!=w.charAt(U+1));)++U;if(U+=2,p===w.charAt(U-1))return D("End of comment missing");var I=w.slice(2,U-2);return C+=2,T(I),w=w.slice(U),C+=2,$({type:m,comment:I})}}function z(){var $=R(),U=O(r);if(U){if(P(),!O(a))return D("property missing ':'");var I=O(i),V=$({type:y,property:b(U[0].replace(e,p)),value:I?b(I[0].replace(e,p)):p});return O(l),V}}function H(){var $=[];M($);for(var U;U=z();)U!==!1&&($.push(U),M($));return $}return L(),H()}function b(w){return w?w.replace(o,p):p}return ix=x,ix}var $N;function fU(){if($N)return wu;$N=1;var e=wu&&wu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(wu,"__esModule",{value:!0}),wu.default=n;const t=e(cU());function n(r,a){let i=null;if(!r||typeof r!="string")return i;const l=(0,t.default)(r),o=typeof a=="function";return l.forEach(c=>{if(c.type!=="declaration")return;const{property:f,value:h}=c;o?a(f,h,c):h&&(i=i||{},i[f]=h)}),i}return wu}var Nf={},GN;function dU(){if(GN)return Nf;GN=1,Object.defineProperty(Nf,"__esModule",{value:!0}),Nf.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,i=function(f){return!f||n.test(f)||e.test(f)},l=function(f,h){return h.toUpperCase()},o=function(f,h){return"".concat(h,"-")},c=function(f,h){return h===void 0&&(h={}),i(f)?f:(f=f.toLowerCase(),h.reactCompat?f=f.replace(a,o):f=f.replace(r,o),f.replace(t,l))};return Nf.camelCase=c,Nf}var kf,KN;function hU(){if(KN)return kf;KN=1;var e=kf&&kf.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(fU()),n=dU();function r(a,i){var l={};return!a||typeof a!="string"||(0,t.default)(a,function(o,c){o&&c&&(l[(0,n.camelCase)(o,i)]=c)}),l}return r.default=r,kf=r,kf}var vU=hU();const pU=bd(vU),aM=iM("end"),tw=iM("start");function iM(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function mU(e){const t=tw(e),n=aM(e);if(t&&n)return{start:t,end:n}}function $f(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?YN(e.position):"start"in e||"end"in e?YN(e):"line"in e||"column"in e?Lb(e):""}function Lb(e){return XN(e&&e.line)+":"+XN(e&&e.column)}function YN(e){return Lb(e&&e.start)+"-"+Lb(e&&e.end)}function XN(e){return e&&typeof e=="number"?e:1}class Er extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",i={},l=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?a=t:!i.cause&&t&&(l=!0,a=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?i.ruleId=r:(i.source=r.slice(0,c),i.ruleId=r.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=o?o.line:void 0,this.name=$f(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=l&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Er.prototype.file="";Er.prototype.name="";Er.prototype.reason="";Er.prototype.message="";Er.prototype.stack="";Er.prototype.column=void 0;Er.prototype.line=void 0;Er.prototype.ancestors=void 0;Er.prototype.cause=void 0;Er.prototype.fatal=void 0;Er.prototype.place=void 0;Er.prototype.ruleId=void 0;Er.prototype.source=void 0;const nw={}.hasOwnProperty,gU=new Map,yU=/[A-Z]/g,xU=new Set(["table","tbody","thead","tfoot","tr"]),bU=new Set(["td","th"]),sM="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wU(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=AU(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=jU(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ew:oU,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=lM(a,e,void 0);return i&&typeof i!="string"?i:a.create(e,a.Fragment,{children:i||void 0},void 0)}function lM(e,t,n){if(t.type==="element")return SU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return EU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return NU(e,t,n);if(t.type==="mdxjsEsm")return CU(e,t);if(t.type==="root")return kU(e,t,n);if(t.type==="text")return TU(e,t)}function SU(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=ew,e.schema=a),e.ancestors.push(t);const i=uM(e,t.tagName,!1),l=RU(e,t);let o=aw(e,t);return xU.has(t.tagName)&&(o=o.filter(function(c){return typeof c=="string"?!ZF(c):!0})),oM(e,l,i,t),rw(l,o),e.ancestors.pop(),e.schema=r,e.create(t,i,l,n)}function EU(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}nd(e,t.position)}function CU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);nd(e,t.position)}function NU(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=ew,e.schema=a),e.ancestors.push(t);const i=t.name===null?e.Fragment:uM(e,t.name,!0),l=DU(e,t),o=aw(e,t);return oM(e,l,i,t),rw(l,o),e.ancestors.pop(),e.schema=r,e.create(t,i,l,n)}function kU(e,t,n){const r={};return rw(r,aw(e,t)),e.create(t,e.Fragment,r,n)}function TU(e,t){return t.value}function oM(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function rw(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function jU(e,t,n){return r;function r(a,i,l,o){const f=Array.isArray(l.children)?n:t;return o?f(i,l,o):f(i,l)}}function AU(e,t){return n;function n(r,a,i,l){const o=Array.isArray(i.children),c=tw(r);return t(a,i,l,o,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function RU(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&nw.call(t.properties,a)){const i=MU(e,a,t.properties[a]);if(i){const[l,o]=i;e.tableCellAlignToStyle&&l==="align"&&typeof o=="string"&&bU.has(t.tagName)?r=o:n[l]=o}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function DU(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const l=i.expression;l.type;const o=l.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else nd(e,t.position);else{const a=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,i=e.evaluater.evaluateExpression(o.expression)}else nd(e,t.position);else i=r.value===null?!0:r.value;n[a]=i}return n}function aw(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:gU;for(;++r<t.children.length;){const i=t.children[r];let l;if(e.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const f=a.get(c)||0;l=c+"-"+f,a.set(c,f+1)}}const o=lM(e,i,l);o!==void 0&&n.push(o)}return n}function MU(e,t,n){const r=iU(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?KF(n):uU(n)),r.property==="style"){let a=typeof n=="object"?n:_U(e,String(n));return e.stylePropertyNameCase==="css"&&(a=OU(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?nU[r.property]||r.property:r.attribute,n]}}function _U(e,t){try{return pU(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new Er("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=sM+"#cannot-parse-style-attribute",a}}function uM(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let i=-1,l;for(;++i<a.length;){const o=FN(a[i])?{type:"Identifier",name:a[i]}:{type:"Literal",value:a[i]};l=l?{type:"MemberExpression",object:l,property:o,computed:!!(i&&o.type==="Literal"),optional:!1}:o}r=l}else r=FN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return nw.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);nd(e)}function nd(e,t){const n=new Er("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=sM+"#cannot-handle-mdx-estrees-without-createevaluater",n}function OU(e){const t={};let n;for(n in e)nw.call(e,n)&&(t[LU(n)]=e[n]);return t}function LU(e){let t=e.replace(yU,PU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function PU(e){return"-"+e.toLowerCase()}const sx={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},BU={};function iw(e,t){const n=BU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return cM(e,r,a)}function cM(e,t,n){if(zU(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return QN(e.children,t,n)}return Array.isArray(e)?QN(e,t,n):""}function QN(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=cM(e[a],t,n);return r.join("")}function zU(e){return!!(e&&typeof e=="object")}const WN=document.createElement("i");function sw(e){const t="&"+e+";";WN.innerHTML=t;const n=WN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ua(e,t,n,r){const a=e.length;let i=0,l;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)l=Array.from(r),l.unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);i<r.length;)l=r.slice(i,i+1e4),l.unshift(t,0),e.splice(...l),i+=1e4,t+=1e4}function Ra(e,t){return e.length>0?(ua(e,e.length,0,t),e):t}const ZN={}.hasOwnProperty;function fM(e){const t={};let n=-1;for(;++n<e.length;)IU(t,e[n]);return t}function IU(e,t){let n;for(n in t){const a=(ZN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let l;if(i)for(l in i){ZN.call(a,l)||(a[l]=[]);const o=i[l];FU(a[l],Array.isArray(o)?o:o?[o]:[])}}}function FU(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ua(e,0,0,r)}function dM(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Va(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ar=kl(/[A-Za-z]/),gr=kl(/[\dA-Za-z]/),UU=kl(/[#-'*+\--9=?A-Z^-~]/);function vp(e){return e!==null&&(e<32||e===127)}const Pb=kl(/\d/),qU=kl(/[\dA-Fa-f]/),VU=kl(/[!-/:-@[-`{-~]/);function rt(e){return e!==null&&e<-2}function Qt(e){return e!==null&&(e<0||e===32)}function Nt(e){return e===-2||e===-1||e===32}const Wp=kl(new RegExp("\\p{P}|\\p{S}","u")),Co=kl(/\s/);function kl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function yc(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const i=e.charCodeAt(n);let l="";if(i===37&&gr(e.charCodeAt(n+1))&&gr(e.charCodeAt(n+2)))a=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(l=String.fromCharCode(i));else if(i>55295&&i<57344){const o=e.charCodeAt(n+1);i<56320&&o>56319&&o<57344?(l=String.fromCharCode(i,o),a=1):l="�"}else l=String.fromCharCode(i);l&&(t.push(e.slice(r,n),encodeURIComponent(l)),r=n+a+1,l=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Rt(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let i=0;return l;function l(c){return Nt(c)?(e.enter(n),o(c)):t(c)}function o(c){return Nt(c)&&i++<a?(e.consume(c),o):(e.exit(n),t(c))}}const HU={tokenize:$U};function $U(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Rt(e,t,"linePrefix")}function a(o){return e.enter("paragraph"),i(o)}function i(o){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,l(o)}function l(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return rt(o)?(e.consume(o),e.exit("chunkText"),i):(e.consume(o),l)}}const GU={tokenize:KU},JN={tokenize:YU};function KU(e){const t=this,n=[];let r=0,a,i,l;return o;function o(C){if(r<n.length){const T=n[r];return t.containerState=T[1],e.attempt(T[0].continuation,c,f)(C)}return f(C)}function c(C){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&N();const T=t.events.length;let R=T,A;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){A=t.events[R][1].end;break}S(r);let D=T;for(;D<t.events.length;)t.events[D][1].end={...A},D++;return ua(t.events,R+1,0,t.events.slice(T)),t.events.length=D,f(C)}return o(C)}function f(C){if(r===n.length){if(!a)return m(C);if(a.currentConstruct&&a.currentConstruct.concrete)return x(C);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(JN,h,p)(C)}function h(C){return a&&N(),S(r),m(C)}function p(C){return t.parser.lazy[t.now().line]=r!==n.length,l=t.now().offset,x(C)}function m(C){return t.containerState={},e.attempt(JN,y,x)(C)}function y(C){return r++,n.push([t.currentConstruct,t.containerState]),m(C)}function x(C){if(C===null){a&&N(),S(0),e.consume(C);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:i}),b(C)}function b(C){if(C===null){w(e.exit("chunkFlow"),!0),S(0),e.consume(C);return}return rt(C)?(e.consume(C),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(C),b)}function w(C,T){const R=t.sliceStream(C);if(T&&R.push(null),C.previous=i,i&&(i.next=C),i=C,a.defineSkip(C.start),a.write(R),t.parser.lazy[C.start.line]){let A=a.events.length;for(;A--;)if(a.events[A][1].start.offset<l&&(!a.events[A][1].end||a.events[A][1].end.offset>l))return;const D=t.events.length;let O=D,L,M;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){if(L){M=t.events[O][1].end;break}L=!0}for(S(r),A=D;A<t.events.length;)t.events[A][1].end={...M},A++;ua(t.events,O+1,0,t.events.slice(D)),t.events.length=A}}function S(C){let T=n.length;for(;T-- >C;){const R=n[T];t.containerState=R[1],R[0].exit.call(t,e)}n.length=C}function N(){a.write([null]),i=void 0,a=void 0,t.containerState._closeFlow=void 0}}function YU(e,t,n){return Rt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ac(e){if(e===null||Qt(e)||Co(e))return 1;if(Wp(e))return 2}function Zp(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const i=e[a].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const Bb={name:"attention",resolveAll:XU,tokenize:QU};function XU(e,t){let n=-1,r,a,i,l,o,c,f,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},m={...e[n][1].start};ek(p,-c),ek(m,c),l={type:c>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},i={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:c>1?"strong":"emphasis",start:{...l.start},end:{...o.end}},e[r][1].end={...l.start},e[n][1].start={...o.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=Ra(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=Ra(f,[["enter",a,t],["enter",l,t],["exit",l,t],["enter",i,t]]),f=Ra(f,Zp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=Ra(f,[["exit",i,t],["enter",o,t],["exit",o,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,f=Ra(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,ua(e,r-1,n-r+3,f),n=r+f.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function QU(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=ac(r);let i;return l;function l(c){return i=c,e.enter("attentionSequence"),o(c)}function o(c){if(c===i)return e.consume(c),o;const f=e.exit("attentionSequence"),h=ac(c),p=!h||h===2&&a||n.includes(c),m=!a||a===2&&h||n.includes(r);return f._open=!!(i===42?p:p&&(a||!m)),f._close=!!(i===42?m:m&&(h||!p)),t(c)}}function ek(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const WU={name:"autolink",tokenize:ZU};function ZU(e,t,n){let r=0;return a;function a(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(y){return Ar(y)?(e.consume(y),l):y===64?n(y):f(y)}function l(y){return y===43||y===45||y===46||gr(y)?(r=1,o(y)):f(y)}function o(y){return y===58?(e.consume(y),r=0,c):(y===43||y===45||y===46||gr(y))&&r++<32?(e.consume(y),o):(r=0,f(y))}function c(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||vp(y)?n(y):(e.consume(y),c)}function f(y){return y===64?(e.consume(y),h):UU(y)?(e.consume(y),f):n(y)}function h(y){return gr(y)?p(y):n(y)}function p(y){return y===46?(e.consume(y),r=0,h):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):m(y)}function m(y){if((y===45||gr(y))&&r++<63){const x=y===45?m:p;return e.consume(y),x}return n(y)}}const Md={partial:!0,tokenize:JU};function JU(e,t,n){return r;function r(i){return Nt(i)?Rt(e,a,"linePrefix")(i):a(i)}function a(i){return i===null||rt(i)?t(i):n(i)}}const hM={continuation:{tokenize:tq},exit:nq,name:"blockQuote",tokenize:eq};function eq(e,t,n){const r=this;return a;function a(l){if(l===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),i}return n(l)}function i(l){return Nt(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(l))}}function tq(e,t,n){const r=this;return a;function a(l){return Nt(l)?Rt(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):i(l)}function i(l){return e.attempt(hM,t,n)(l)}}function nq(e){e.exit("blockQuote")}const vM={name:"characterEscape",tokenize:rq};function rq(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),a}function a(i){return VU(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const pM={name:"characterReference",tokenize:aq};function aq(e,t,n){const r=this;let a=0,i,l;return o;function o(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),c}function c(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),i=31,l=gr,h(p))}function f(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,l=qU,h):(e.enter("characterReferenceValue"),i=7,l=Pb,h(p))}function h(p){if(p===59&&a){const m=e.exit("characterReferenceValue");return l===gr&&!sw(r.sliceSerialize(m))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return l(p)&&a++<i?(e.consume(p),h):n(p)}}const tk={partial:!0,tokenize:sq},nk={concrete:!0,name:"codeFenced",tokenize:iq};function iq(e,t,n){const r=this,a={partial:!0,tokenize:R};let i=0,l=0,o;return c;function c(A){return f(A)}function f(A){const D=r.events[r.events.length-1];return i=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,o=A,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(A)}function h(A){return A===o?(l++,e.consume(A),h):l<3?n(A):(e.exit("codeFencedFenceSequence"),Nt(A)?Rt(e,p,"whitespace")(A):p(A))}function p(A){return A===null||rt(A)?(e.exit("codeFencedFence"),r.interrupt?t(A):e.check(tk,b,T)(A)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(A))}function m(A){return A===null||rt(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(A)):Nt(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Rt(e,y,"whitespace")(A)):A===96&&A===o?n(A):(e.consume(A),m)}function y(A){return A===null||rt(A)?p(A):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),x(A))}function x(A){return A===null||rt(A)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(A)):A===96&&A===o?n(A):(e.consume(A),x)}function b(A){return e.attempt(a,T,w)(A)}function w(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),S}function S(A){return i>0&&Nt(A)?Rt(e,N,"linePrefix",i+1)(A):N(A)}function N(A){return A===null||rt(A)?e.check(tk,b,T)(A):(e.enter("codeFlowValue"),C(A))}function C(A){return A===null||rt(A)?(e.exit("codeFlowValue"),N(A)):(e.consume(A),C)}function T(A){return e.exit("codeFenced"),t(A)}function R(A,D,O){let L=0;return M;function M(U){return A.enter("lineEnding"),A.consume(U),A.exit("lineEnding"),P}function P(U){return A.enter("codeFencedFence"),Nt(U)?Rt(A,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):z(U)}function z(U){return U===o?(A.enter("codeFencedFenceSequence"),H(U)):O(U)}function H(U){return U===o?(L++,A.consume(U),H):L>=l?(A.exit("codeFencedFenceSequence"),Nt(U)?Rt(A,$,"whitespace")(U):$(U)):O(U)}function $(U){return U===null||rt(U)?(A.exit("codeFencedFence"),D(U)):O(U)}}}function sq(e,t,n){const r=this;return a;function a(l){return l===null?n(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),i)}function i(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}const lx={name:"codeIndented",tokenize:oq},lq={partial:!0,tokenize:uq};function oq(e,t,n){const r=this;return a;function a(f){return e.enter("codeIndented"),Rt(e,i,"linePrefix",5)(f)}function i(f){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?l(f):n(f)}function l(f){return f===null?c(f):rt(f)?e.attempt(lq,l,c)(f):(e.enter("codeFlowValue"),o(f))}function o(f){return f===null||rt(f)?(e.exit("codeFlowValue"),l(f)):(e.consume(f),o)}function c(f){return e.exit("codeIndented"),t(f)}}function uq(e,t,n){const r=this;return a;function a(l){return r.parser.lazy[r.now().line]?n(l):rt(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a):Rt(e,i,"linePrefix",5)(l)}function i(l){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(l):rt(l)?a(l):n(l)}}const cq={name:"codeText",previous:dq,resolve:fq,tokenize:hq};function fq(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function dq(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hq(e,t,n){let r=0,a,i;return l;function l(p){return e.enter("codeText"),e.enter("codeTextSequence"),o(p)}function o(p){return p===96?(e.consume(p),r++,o):(e.exit("codeTextSequence"),c(p))}function c(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),c):p===96?(i=e.enter("codeTextSequence"),a=0,h(p)):rt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("codeTextData"),f(p))}function f(p){return p===null||p===32||p===96||rt(p)?(e.exit("codeTextData"),c(p)):(e.consume(p),f)}function h(p){return p===96?(e.consume(p),a++,h):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(i.type="codeTextData",f(p))}}class vq{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&Tf(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Tf(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Tf(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Tf(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Tf(this.left,n.reverse())}}}function Tf(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function mM(e){const t={};let n=-1,r,a,i,l,o,c,f;const h=new vq(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,pq(h,n)),n=t[n],f=!0);else if(r[1]._container){for(i=n,a=void 0;i--;)if(l=h.get(i),l[1].type==="lineEnding"||l[1].type==="lineEndingBlank")l[0]==="enter"&&(a&&(h.get(a)[1].type="lineEndingBlank"),l[1].type="lineEnding",a=i);else if(!(l[1].type==="linePrefix"||l[1].type==="listItemIndent"))break;a&&(r[1].end={...h.get(a)[1].start},o=h.slice(a,n),o.unshift(r),h.splice(a,n-a+1,o))}}return ua(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!f}function pq(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const i=[];let l=n._tokenizer;l||(l=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));const o=l.events,c=[],f={};let h,p,m=-1,y=n,x=0,b=0;const w=[b];for(;y;){for(;e.get(++a)[1]!==y;);i.push(a),y._tokenizer||(h=r.sliceStream(y),y.next||h.push(null),p&&l.defineSkip(y.start),y._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(h),y._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),p=y,y=y.next}for(y=n;++m<o.length;)o[m][0]==="exit"&&o[m-1][0]==="enter"&&o[m][1].type===o[m-1][1].type&&o[m][1].start.line!==o[m][1].end.line&&(b=m+1,w.push(b),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(l.events=[],y?(y._tokenizer=void 0,y.previous=void 0):w.pop(),m=w.length;m--;){const S=o.slice(w[m],w[m+1]),N=i.pop();c.push([N,N+S.length-1]),e.splice(N,2,S)}for(c.reverse(),m=-1;++m<c.length;)f[x+c[m][0]]=x+c[m][1],x+=c[m][1]-c[m][0]-1;return f}const mq={resolve:yq,tokenize:xq},gq={partial:!0,tokenize:bq};function yq(e){return mM(e),e}function xq(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(o)}function a(o){return o===null?i(o):rt(o)?e.check(gq,l,i)(o):(e.consume(o),a)}function i(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function l(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function bq(e,t,n){const r=this;return a;function a(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Rt(e,i,"linePrefix")}function i(l){if(l===null||rt(l))return n(l);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}function gM(e,t,n,r,a,i,l,o,c){const f=c||Number.POSITIVE_INFINITY;let h=0;return p;function p(S){return S===60?(e.enter(r),e.enter(a),e.enter(i),e.consume(S),e.exit(i),m):S===null||S===32||S===41||vp(S)?n(S):(e.enter(r),e.enter(l),e.enter(o),e.enter("chunkString",{contentType:"string"}),b(S))}function m(S){return S===62?(e.enter(i),e.consume(S),e.exit(i),e.exit(a),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),y(S))}function y(S){return S===62?(e.exit("chunkString"),e.exit(o),m(S)):S===null||S===60||rt(S)?n(S):(e.consume(S),S===92?x:y)}function x(S){return S===60||S===62||S===92?(e.consume(S),y):y(S)}function b(S){return!h&&(S===null||S===41||Qt(S))?(e.exit("chunkString"),e.exit(o),e.exit(l),e.exit(r),t(S)):h<f&&S===40?(e.consume(S),h++,b):S===41?(e.consume(S),h--,b):S===null||S===32||S===40||vp(S)?n(S):(e.consume(S),S===92?w:b)}function w(S){return S===40||S===41||S===92?(e.consume(S),b):b(S)}}function yM(e,t,n,r,a,i){const l=this;let o=0,c;return f;function f(y){return e.enter(r),e.enter(a),e.consume(y),e.exit(a),e.enter(i),h}function h(y){return o>999||y===null||y===91||y===93&&!c||y===94&&!o&&"_hiddenFootnoteSupport"in l.parser.constructs?n(y):y===93?(e.exit(i),e.enter(a),e.consume(y),e.exit(a),e.exit(r),t):rt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===null||y===91||y===93||rt(y)||o++>999?(e.exit("chunkString"),h(y)):(e.consume(y),c||(c=!Nt(y)),y===92?m:p)}function m(y){return y===91||y===92||y===93?(e.consume(y),o++,p):p(y)}}function xM(e,t,n,r,a,i){let l;return o;function o(m){return m===34||m===39||m===40?(e.enter(r),e.enter(a),e.consume(m),e.exit(a),l=m===40?41:m,c):n(m)}function c(m){return m===l?(e.enter(a),e.consume(m),e.exit(a),e.exit(r),t):(e.enter(i),f(m))}function f(m){return m===l?(e.exit(i),c(l)):m===null?n(m):rt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Rt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(m))}function h(m){return m===l||m===null||rt(m)?(e.exit("chunkString"),f(m)):(e.consume(m),m===92?p:h)}function p(m){return m===l||m===92?(e.consume(m),h):h(m)}}function Gf(e,t){let n;return r;function r(a){return rt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Nt(a)?Rt(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const wq={name:"definition",tokenize:Eq},Sq={partial:!0,tokenize:Cq};function Eq(e,t,n){const r=this;let a;return i;function i(y){return e.enter("definition"),l(y)}function l(y){return yM.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function o(y){return a=Va(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),c):n(y)}function c(y){return Qt(y)?Gf(e,f)(y):f(y)}function f(y){return gM(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function h(y){return e.attempt(Sq,p,p)(y)}function p(y){return Nt(y)?Rt(e,m,"whitespace")(y):m(y)}function m(y){return y===null||rt(y)?(e.exit("definition"),r.parser.defined.push(a),t(y)):n(y)}}function Cq(e,t,n){return r;function r(o){return Qt(o)?Gf(e,a)(o):n(o)}function a(o){return xM(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function i(o){return Nt(o)?Rt(e,l,"whitespace")(o):l(o)}function l(o){return o===null||rt(o)?t(o):n(o)}}const Nq={name:"hardBreakEscape",tokenize:kq};function kq(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),a}function a(i){return rt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const Tq={name:"headingAtx",resolve:jq,tokenize:Aq};function jq(e,t){let n=e.length-2,r=3,a,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ua(e,r,n-r+1,[["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t]])),e}function Aq(e,t,n){let r=0;return a;function a(h){return e.enter("atxHeading"),i(h)}function i(h){return e.enter("atxHeadingSequence"),l(h)}function l(h){return h===35&&r++<6?(e.consume(h),l):h===null||Qt(h)?(e.exit("atxHeadingSequence"),o(h)):n(h)}function o(h){return h===35?(e.enter("atxHeadingSequence"),c(h)):h===null||rt(h)?(e.exit("atxHeading"),t(h)):Nt(h)?Rt(e,o,"whitespace")(h):(e.enter("atxHeadingText"),f(h))}function c(h){return h===35?(e.consume(h),c):(e.exit("atxHeadingSequence"),o(h))}function f(h){return h===null||h===35||Qt(h)?(e.exit("atxHeadingText"),o(h)):(e.consume(h),f)}}const Rq=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],rk=["pre","script","style","textarea"],Dq={concrete:!0,name:"htmlFlow",resolveTo:Oq,tokenize:Lq},Mq={partial:!0,tokenize:Bq},_q={partial:!0,tokenize:Pq};function Oq(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Lq(e,t,n){const r=this;let a,i,l,o,c;return f;function f(B){return h(B)}function h(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),p}function p(B){return B===33?(e.consume(B),m):B===47?(e.consume(B),i=!0,b):B===63?(e.consume(B),a=3,r.interrupt?t:F):Ar(B)?(e.consume(B),l=String.fromCharCode(B),w):n(B)}function m(B){return B===45?(e.consume(B),a=2,y):B===91?(e.consume(B),a=5,o=0,x):Ar(B)?(e.consume(B),a=4,r.interrupt?t:F):n(B)}function y(B){return B===45?(e.consume(B),r.interrupt?t:F):n(B)}function x(B){const W="CDATA[";return B===W.charCodeAt(o++)?(e.consume(B),o===W.length?r.interrupt?t:z:x):n(B)}function b(B){return Ar(B)?(e.consume(B),l=String.fromCharCode(B),w):n(B)}function w(B){if(B===null||B===47||B===62||Qt(B)){const W=B===47,re=l.toLowerCase();return!W&&!i&&rk.includes(re)?(a=1,r.interrupt?t(B):z(B)):Rq.includes(l.toLowerCase())?(a=6,W?(e.consume(B),S):r.interrupt?t(B):z(B)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):i?N(B):C(B))}return B===45||gr(B)?(e.consume(B),l+=String.fromCharCode(B),w):n(B)}function S(B){return B===62?(e.consume(B),r.interrupt?t:z):n(B)}function N(B){return Nt(B)?(e.consume(B),N):M(B)}function C(B){return B===47?(e.consume(B),M):B===58||B===95||Ar(B)?(e.consume(B),T):Nt(B)?(e.consume(B),C):M(B)}function T(B){return B===45||B===46||B===58||B===95||gr(B)?(e.consume(B),T):R(B)}function R(B){return B===61?(e.consume(B),A):Nt(B)?(e.consume(B),R):C(B)}function A(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),c=B,D):Nt(B)?(e.consume(B),A):O(B)}function D(B){return B===c?(e.consume(B),c=null,L):B===null||rt(B)?n(B):(e.consume(B),D)}function O(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Qt(B)?R(B):(e.consume(B),O)}function L(B){return B===47||B===62||Nt(B)?C(B):n(B)}function M(B){return B===62?(e.consume(B),P):n(B)}function P(B){return B===null||rt(B)?z(B):Nt(B)?(e.consume(B),P):n(B)}function z(B){return B===45&&a===2?(e.consume(B),I):B===60&&a===1?(e.consume(B),V):B===62&&a===4?(e.consume(B),q):B===63&&a===3?(e.consume(B),F):B===93&&a===5?(e.consume(B),Q):rt(B)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(Mq,X,H)(B)):B===null||rt(B)?(e.exit("htmlFlowData"),H(B)):(e.consume(B),z)}function H(B){return e.check(_q,$,X)(B)}function $(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),U}function U(B){return B===null||rt(B)?H(B):(e.enter("htmlFlowData"),z(B))}function I(B){return B===45?(e.consume(B),F):z(B)}function V(B){return B===47?(e.consume(B),l="",K):z(B)}function K(B){if(B===62){const W=l.toLowerCase();return rk.includes(W)?(e.consume(B),q):z(B)}return Ar(B)&&l.length<8?(e.consume(B),l+=String.fromCharCode(B),K):z(B)}function Q(B){return B===93?(e.consume(B),F):z(B)}function F(B){return B===62?(e.consume(B),q):B===45&&a===2?(e.consume(B),F):z(B)}function q(B){return B===null||rt(B)?(e.exit("htmlFlowData"),X(B)):(e.consume(B),q)}function X(B){return e.exit("htmlFlow"),t(B)}}function Pq(e,t,n){const r=this;return a;function a(l){return rt(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),i):n(l)}function i(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}function Bq(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Md,t,n)}}const zq={name:"htmlText",tokenize:Iq};function Iq(e,t,n){const r=this;let a,i,l;return o;function o(F){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(F),c}function c(F){return F===33?(e.consume(F),f):F===47?(e.consume(F),R):F===63?(e.consume(F),C):Ar(F)?(e.consume(F),O):n(F)}function f(F){return F===45?(e.consume(F),h):F===91?(e.consume(F),i=0,x):Ar(F)?(e.consume(F),N):n(F)}function h(F){return F===45?(e.consume(F),y):n(F)}function p(F){return F===null?n(F):F===45?(e.consume(F),m):rt(F)?(l=p,V(F)):(e.consume(F),p)}function m(F){return F===45?(e.consume(F),y):p(F)}function y(F){return F===62?I(F):F===45?m(F):p(F)}function x(F){const q="CDATA[";return F===q.charCodeAt(i++)?(e.consume(F),i===q.length?b:x):n(F)}function b(F){return F===null?n(F):F===93?(e.consume(F),w):rt(F)?(l=b,V(F)):(e.consume(F),b)}function w(F){return F===93?(e.consume(F),S):b(F)}function S(F){return F===62?I(F):F===93?(e.consume(F),S):b(F)}function N(F){return F===null||F===62?I(F):rt(F)?(l=N,V(F)):(e.consume(F),N)}function C(F){return F===null?n(F):F===63?(e.consume(F),T):rt(F)?(l=C,V(F)):(e.consume(F),C)}function T(F){return F===62?I(F):C(F)}function R(F){return Ar(F)?(e.consume(F),A):n(F)}function A(F){return F===45||gr(F)?(e.consume(F),A):D(F)}function D(F){return rt(F)?(l=D,V(F)):Nt(F)?(e.consume(F),D):I(F)}function O(F){return F===45||gr(F)?(e.consume(F),O):F===47||F===62||Qt(F)?L(F):n(F)}function L(F){return F===47?(e.consume(F),I):F===58||F===95||Ar(F)?(e.consume(F),M):rt(F)?(l=L,V(F)):Nt(F)?(e.consume(F),L):I(F)}function M(F){return F===45||F===46||F===58||F===95||gr(F)?(e.consume(F),M):P(F)}function P(F){return F===61?(e.consume(F),z):rt(F)?(l=P,V(F)):Nt(F)?(e.consume(F),P):L(F)}function z(F){return F===null||F===60||F===61||F===62||F===96?n(F):F===34||F===39?(e.consume(F),a=F,H):rt(F)?(l=z,V(F)):Nt(F)?(e.consume(F),z):(e.consume(F),$)}function H(F){return F===a?(e.consume(F),a=void 0,U):F===null?n(F):rt(F)?(l=H,V(F)):(e.consume(F),H)}function $(F){return F===null||F===34||F===39||F===60||F===61||F===96?n(F):F===47||F===62||Qt(F)?L(F):(e.consume(F),$)}function U(F){return F===47||F===62||Qt(F)?L(F):n(F)}function I(F){return F===62?(e.consume(F),e.exit("htmlTextData"),e.exit("htmlText"),t):n(F)}function V(F){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),K}function K(F){return Nt(F)?Rt(e,Q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):Q(F)}function Q(F){return e.enter("htmlTextData"),l(F)}}const lw={name:"labelEnd",resolveAll:Vq,resolveTo:Hq,tokenize:$q},Fq={tokenize:Gq},Uq={tokenize:Kq},qq={tokenize:Yq};function Vq(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&ua(e,0,e.length,n),e}function Hq(e,t){let n=e.length,r=0,a,i,l,o;for(;n--;)if(a=e[n][1],i){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(l){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(i=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(l=n);const c={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[i][1].start},end:{...e[l][1].end}},h={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[l-2][1].start}};return o=[["enter",c,t],["enter",f,t]],o=Ra(o,e.slice(i+1,i+r+3)),o=Ra(o,[["enter",h,t]]),o=Ra(o,Zp(t.parser.constructs.insideSpan.null,e.slice(i+r+4,l-3),t)),o=Ra(o,[["exit",h,t],e[l-2],e[l-1],["exit",f,t]]),o=Ra(o,e.slice(l+1)),o=Ra(o,[["exit",c,t]]),ua(e,i,e.length,o),e}function $q(e,t,n){const r=this;let a=r.events.length,i,l;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){i=r.events[a][1];break}return o;function o(m){return i?i._inactive?p(m):(l=r.parser.defined.includes(Va(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),c):n(m)}function c(m){return m===40?e.attempt(Fq,h,l?h:p)(m):m===91?e.attempt(Uq,h,l?f:p)(m):l?h(m):p(m)}function f(m){return e.attempt(qq,h,p)(m)}function h(m){return t(m)}function p(m){return i._balanced=!0,n(m)}}function Gq(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),a}function a(p){return Qt(p)?Gf(e,i)(p):i(p)}function i(p){return p===41?h(p):gM(e,l,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function l(p){return Qt(p)?Gf(e,c)(p):h(p)}function o(p){return n(p)}function c(p){return p===34||p===39||p===40?xM(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function f(p){return Qt(p)?Gf(e,h)(p):h(p)}function h(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function Kq(e,t,n){const r=this;return a;function a(o){return yM.call(r,e,i,l,"reference","referenceMarker","referenceString")(o)}function i(o){return r.parser.defined.includes(Va(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function l(o){return n(o)}}function Yq(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),a}function a(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const Xq={name:"labelStartImage",resolveAll:lw.resolveAll,tokenize:Qq};function Qq(e,t,n){const r=this;return a;function a(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),i}function i(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),l):n(o)}function l(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Wq={name:"labelStartLink",resolveAll:lw.resolveAll,tokenize:Zq};function Zq(e,t,n){const r=this;return a;function a(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),i}function i(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const ox={name:"lineEnding",tokenize:Jq};function Jq(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Rt(e,t,"linePrefix")}}const Xv={name:"thematicBreak",tokenize:eV};function eV(e,t,n){let r=0,a;return i;function i(f){return e.enter("thematicBreak"),l(f)}function l(f){return a=f,o(f)}function o(f){return f===a?(e.enter("thematicBreakSequence"),c(f)):r>=3&&(f===null||rt(f))?(e.exit("thematicBreak"),t(f)):n(f)}function c(f){return f===a?(e.consume(f),r++,c):(e.exit("thematicBreakSequence"),Nt(f)?Rt(e,o,"whitespace")(f):o(f))}}const Ur={continuation:{tokenize:aV},exit:sV,name:"list",tokenize:rV},tV={partial:!0,tokenize:lV},nV={partial:!0,tokenize:iV};function rV(e,t,n){const r=this,a=r.events[r.events.length-1];let i=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,l=0;return o;function o(y){const x=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:Pb(y)){if(r.containerState.type||(r.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Xv,n,f)(y):f(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(y)}return n(y)}function c(y){return Pb(y)&&++l<10?(e.consume(y),c):(!r.interrupt||l<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Md,r.interrupt?n:h,e.attempt(tV,m,p))}function h(y){return r.containerState.initialBlankLine=!0,i++,m(y)}function p(y){return Nt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),m):n(y)}function m(y){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function aV(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Md,a,i);function a(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Rt(e,t,"listItemIndent",r.containerState.size+1)(o)}function i(o){return r.containerState.furtherBlankLines||!Nt(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(nV,t,l)(o))}function l(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Rt(e,e.attempt(Ur,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function iV(e,t,n){const r=this;return Rt(e,a,"listItemIndent",r.containerState.size+1);function a(i){const l=r.events[r.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(i):n(i)}}function sV(e){e.exit(this.containerState.type)}function lV(e,t,n){const r=this;return Rt(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(i){const l=r.events[r.events.length-1];return!Nt(i)&&l&&l[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const ak={name:"setextUnderline",resolveTo:oV,tokenize:uV};function oV(e,t){let n=e.length,r,a,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const l={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",i?(e.splice(a,0,["enter",l,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=l,e.push(["exit",l,t]),e}function uV(e,t,n){const r=this;let a;return i;function i(f){let h=r.events.length,p;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){p=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),a=f,l(f)):n(f)}function l(f){return e.enter("setextHeadingLineSequence"),o(f)}function o(f){return f===a?(e.consume(f),o):(e.exit("setextHeadingLineSequence"),Nt(f)?Rt(e,c,"lineSuffix")(f):c(f))}function c(f){return f===null||rt(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const cV={tokenize:fV};function fV(e){const t=this,n=e.attempt(Md,r,e.attempt(this.parser.constructs.flowInitial,a,Rt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(mq,a)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const dV={resolveAll:wM()},hV=bM("string"),vV=bM("text");function bM(e){return{resolveAll:wM(e==="text"?pV:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],i=n.attempt(a,l,o);return l;function l(h){return f(h)?i(h):o(h)}function o(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),c}function c(h){return f(h)?(n.exit("data"),i(h)):(n.consume(h),c)}function f(h){if(h===null)return!0;const p=a[h];let m=-1;if(p)for(;++m<p.length;){const y=p[m];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function wM(e){return t;function t(n,r){let a=-1,i;for(;++a<=n.length;)i===void 0?n[a]&&n[a][1].type==="data"&&(i=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==i+2&&(n[i][1].end=n[a-1][1].end,n.splice(i+2,a-i-2),a=i+2),i=void 0);return e?e(n,r):n}}function pV(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let i=a.length,l=-1,o=0,c;for(;i--;){const f=a[i];if(typeof f=="string"){for(l=f.length;f.charCodeAt(l-1)===32;)o++,l--;if(l)break;l=-1}else if(f===-2)c=!0,o++;else if(f!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const f={type:n===e.length||c||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?l:r.start._bufferIndex+l,_index:r.start._index+i,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const mV={42:Ur,43:Ur,45:Ur,48:Ur,49:Ur,50:Ur,51:Ur,52:Ur,53:Ur,54:Ur,55:Ur,56:Ur,57:Ur,62:hM},gV={91:wq},yV={[-2]:lx,[-1]:lx,32:lx},xV={35:Tq,42:Xv,45:[ak,Xv],60:Dq,61:ak,95:Xv,96:nk,126:nk},bV={38:pM,92:vM},wV={[-5]:ox,[-4]:ox,[-3]:ox,33:Xq,38:pM,42:Bb,60:[WU,zq],91:Wq,92:[Nq,vM],93:lw,95:Bb,96:cq},SV={null:[Bb,dV]},EV={null:[42,95]},CV={null:[]},NV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:EV,contentInitial:gV,disable:CV,document:mV,flow:xV,flowInitial:yV,insideSpan:SV,string:bV,text:wV},Symbol.toStringTag,{value:"Module"}));function kV(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},i=[];let l=[],o=[];const c={attempt:D(R),check:D(A),consume:N,enter:C,exit:T,interrupt:D(A,{interrupt:!0})},f={code:null,containerState:{},defineSkip:b,events:[],now:x,parser:e,previous:null,sliceSerialize:m,sliceStream:y,write:p};let h=t.tokenize.call(f,c);return t.resolveAll&&i.push(t),f;function p(P){return l=Ra(l,P),w(),l[l.length-1]!==null?[]:(O(t,0),f.events=Zp(i,f.events,f),f.events)}function m(P,z){return jV(y(P),z)}function y(P){return TV(l,P)}function x(){const{_bufferIndex:P,_index:z,line:H,column:$,offset:U}=r;return{_bufferIndex:P,_index:z,line:H,column:$,offset:U}}function b(P){a[P.line]=P.column,M()}function w(){let P;for(;r._index<l.length;){const z=l[r._index];if(typeof z=="string")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<z.length;)S(z.charCodeAt(r._bufferIndex));else S(z)}}function S(P){h=h(P)}function N(P){rt(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,M()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===l[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=P}function C(P,z){const H=z||{};return H.type=P,H.start=x(),f.events.push(["enter",H,f]),o.push(H),H}function T(P){const z=o.pop();return z.end=x(),f.events.push(["exit",z,f]),z}function R(P,z){O(P,z.from)}function A(P,z){z.restore()}function D(P,z){return H;function H($,U,I){let V,K,Q,F;return Array.isArray($)?X($):"tokenize"in $?X([$]):q($);function q(ae){return ie;function ie(ye){const ue=ye!==null&&ae[ye],ee=ye!==null&&ae.null,ne=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(ee)?ee:ee?[ee]:[]];return X(ne)(ye)}}function X(ae){return V=ae,K=0,ae.length===0?I:B(ae[K])}function B(ae){return ie;function ie(ye){return F=L(),Q=ae,ae.partial||(f.currentConstruct=ae),ae.name&&f.parser.constructs.disable.null.includes(ae.name)?re():ae.tokenize.call(z?Object.assign(Object.create(f),z):f,c,W,re)(ye)}}function W(ae){return P(Q,F),U}function re(ae){return F.restore(),++K<V.length?B(V[K]):I}}}function O(P,z){P.resolveAll&&!i.includes(P)&&i.push(P),P.resolve&&ua(f.events,z,f.events.length-z,P.resolve(f.events.slice(z),f)),P.resolveTo&&(f.events=P.resolveTo(f.events,f))}function L(){const P=x(),z=f.previous,H=f.currentConstruct,$=f.events.length,U=Array.from(o);return{from:$,restore:I};function I(){r=P,f.previous=z,f.currentConstruct=H,f.events.length=$,o=U,M()}}function M(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function TV(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,i=t.end._bufferIndex;let l;if(n===a)l=[e[n].slice(r,i)];else{if(l=e.slice(n,a),r>-1){const o=l[0];typeof o=="string"?l[0]=o.slice(r):l.shift()}i>0&&l.push(e[a].slice(0,i))}return l}function jV(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const i=e[n];let l;if(typeof i=="string")l=i;else switch(i){case-5:{l="\r";break}case-4:{l=`
|
|
476
476
|
`;break}case-3:{l=`\r
|
|
477
477
|
`;break}case-2:{l=t?" ":" ";break}case-1:{if(!t&&a)continue;l=" ";break}default:l=String.fromCharCode(i)}a=i===-2,r.push(l)}return r.join("")}function AV(e){const r={constructs:fM([NV,...(e||{}).extensions||[]]),content:a(HU),defined:[],document:a(GU),flow:a(cV),lazy:{},string:a(hV),text:a(vV)};return r;function a(i){return l;function l(o){return kV(r,i,o)}}}function RV(e){for(;!mM(e););return e}const ik=/[\0\t\n\r]/g;function DV(){let e=1,t="",n=!0,r;return a;function a(i,l,o){const c=[];let f,h,p,m,y;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(l||void 0).decode(i)),p=0,t="",n&&(i.charCodeAt(0)===65279&&p++,n=void 0);p<i.length;){if(ik.lastIndex=p,f=ik.exec(i),m=f&&f.index!==void 0?f.index:i.length,y=i.charCodeAt(m),!f){t=i.slice(p);break}if(y===10&&p===m&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),p<m&&(c.push(i.slice(p,m)),e+=m-p),y){case 0:{c.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,c.push(-2);e++<h;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}p=m+1}return o&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const MV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function _V(e){return e.replace(MV,OV)}function OV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),i=a===120||a===88;return dM(n.slice(i?2:1),i?16:10)}return sw(n)||e}const SM={}.hasOwnProperty;function LV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),PV(n)(RV(AV(n).document().write(DV()(e,t,!0))))}function PV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ve),autolinkProtocol:L,autolinkEmail:L,atxHeading:i(Be),blockQuote:i(ee),characterEscape:L,characterReference:L,codeFenced:i(ne),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:i(ne,l),codeText:i(se,l),codeTextData:L,data:L,codeFlowValue:L,definition:i(ge),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:i(Te),hardBreakEscape:i(ot),hardBreakTrailing:i(ot),htmlFlow:i(Je,l),htmlFlowData:L,htmlText:i(Je,l),htmlTextData:L,image:i(We),label:l,link:i(Ve),listItem:i(Ye),listItemValue:m,listOrdered:i(De,p),listUnordered:i(De),paragraph:i(Qe),reference:B,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:i(Be),strong:i(st),thematicBreak:i(dt)},exit:{atxHeading:c(),atxHeadingSequence:R,autolink:c(),autolinkEmail:ue,autolinkProtocol:ye,blockQuote:c(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ae,characterReference:ie,codeFenced:c(w),codeFencedFence:b,codeFencedFenceInfo:y,codeFencedFenceMeta:x,codeFlowValue:M,codeIndented:c(S),codeText:c(U),codeTextData:M,data:M,definition:c(),definitionDestinationString:T,definitionLabelString:N,definitionTitleString:C,emphasis:c(),hardBreakEscape:c(z),hardBreakTrailing:c(z),htmlFlow:c(H),htmlFlowData:M,htmlText:c($),htmlTextData:M,image:c(V),label:Q,labelText:K,lineEnding:P,link:c(I),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:W,resourceDestinationString:F,resourceTitleString:q,resource:X,setextHeading:c(O),setextHeadingLineSequence:D,setextHeadingText:A,strong:c(),thematicBreak:c()}};EM(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(he){let Ce={type:"root",children:[]};const Me={stack:[Ce],tokenStack:[],config:t,enter:o,exit:f,buffer:l,resume:h,data:n},Fe=[];let _e=-1;for(;++_e<he.length;)if(he[_e][1].type==="listOrdered"||he[_e][1].type==="listUnordered")if(he[_e][0]==="enter")Fe.push(_e);else{const Oe=Fe.pop();_e=a(he,Oe,_e)}for(_e=-1;++_e<he.length;){const Oe=t[he[_e][0]];SM.call(Oe,he[_e][1].type)&&Oe[he[_e][1].type].call(Object.assign({sliceSerialize:he[_e][2].sliceSerialize},Me),he[_e][1])}if(Me.tokenStack.length>0){const Oe=Me.tokenStack[Me.tokenStack.length-1];(Oe[1]||sk).call(Me,void 0,Oe[0])}for(Ce.position={start:$s(he.length>0?he[0][1].start:{line:1,column:1,offset:0}),end:$s(he.length>0?he[he.length-2][1].end:{line:1,column:1,offset:0})},_e=-1;++_e<t.transforms.length;)Ce=t.transforms[_e](Ce)||Ce;return Ce}function a(he,Ce,Me){let Fe=Ce-1,_e=-1,Oe=!1,xe,Y,oe,pe;for(;++Fe<=Me;){const de=he[Fe];switch(de[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{de[0]==="enter"?_e++:_e--,pe=void 0;break}case"lineEndingBlank":{de[0]==="enter"&&(xe&&!pe&&!_e&&!oe&&(oe=Fe),pe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:pe=void 0}if(!_e&&de[0]==="enter"&&de[1].type==="listItemPrefix"||_e===-1&&de[0]==="exit"&&(de[1].type==="listUnordered"||de[1].type==="listOrdered")){if(xe){let be=Fe;for(Y=void 0;be--;){const Le=he[be];if(Le[1].type==="lineEnding"||Le[1].type==="lineEndingBlank"){if(Le[0]==="exit")continue;Y&&(he[Y][1].type="lineEndingBlank",Oe=!0),Le[1].type="lineEnding",Y=be}else if(!(Le[1].type==="linePrefix"||Le[1].type==="blockQuotePrefix"||Le[1].type==="blockQuotePrefixWhitespace"||Le[1].type==="blockQuoteMarker"||Le[1].type==="listItemIndent"))break}oe&&(!Y||oe<Y)&&(xe._spread=!0),xe.end=Object.assign({},Y?he[Y][1].start:de[1].end),he.splice(Y||Fe,0,["exit",xe,de[2]]),Fe++,Me++}if(de[1].type==="listItemPrefix"){const be={type:"listItem",_spread:!1,start:Object.assign({},de[1].start),end:void 0};xe=be,he.splice(Fe,0,["enter",be,de[2]]),Fe++,Me++,oe=void 0,pe=!0}}}return he[Ce][1]._spread=Oe,Me}function i(he,Ce){return Me;function Me(Fe){o.call(this,he(Fe),Fe),Ce&&Ce.call(this,Fe)}}function l(){this.stack.push({type:"fragment",children:[]})}function o(he,Ce,Me){this.stack[this.stack.length-1].children.push(he),this.stack.push(he),this.tokenStack.push([Ce,Me||void 0]),he.position={start:$s(Ce.start),end:void 0}}function c(he){return Ce;function Ce(Me){he&&he.call(this,Me),f.call(this,Me)}}function f(he,Ce){const Me=this.stack.pop(),Fe=this.tokenStack.pop();if(Fe)Fe[0].type!==he.type&&(Ce?Ce.call(this,he,Fe[0]):(Fe[1]||sk).call(this,he,Fe[0]));else throw new Error("Cannot close `"+he.type+"` ("+$f({start:he.start,end:he.end})+"): it’s not open");Me.position.end=$s(he.end)}function h(){return iw(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(he){if(this.data.expectingFirstListItemValue){const Ce=this.stack[this.stack.length-2];Ce.start=Number.parseInt(this.sliceSerialize(he),10),this.data.expectingFirstListItemValue=void 0}}function y(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.lang=he}function x(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.meta=he}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=he.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=he.replace(/(\r?\n|\r)$/g,"")}function N(he){const Ce=this.resume(),Me=this.stack[this.stack.length-1];Me.label=Ce,Me.identifier=Va(this.sliceSerialize(he)).toLowerCase()}function C(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.title=he}function T(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.url=he}function R(he){const Ce=this.stack[this.stack.length-1];if(!Ce.depth){const Me=this.sliceSerialize(he).length;Ce.depth=Me}}function A(){this.data.setextHeadingSlurpLineEnding=!0}function D(he){const Ce=this.stack[this.stack.length-1];Ce.depth=this.sliceSerialize(he).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function L(he){const Me=this.stack[this.stack.length-1].children;let Fe=Me[Me.length-1];(!Fe||Fe.type!=="text")&&(Fe=ze(),Fe.position={start:$s(he.start),end:void 0},Me.push(Fe)),this.stack.push(Fe)}function M(he){const Ce=this.stack.pop();Ce.value+=this.sliceSerialize(he),Ce.position.end=$s(he.end)}function P(he){const Ce=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Me=Ce.children[Ce.children.length-1];Me.position.end=$s(he.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ce.type)&&(L.call(this,he),M.call(this,he))}function z(){this.data.atHardBreak=!0}function H(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=he}function $(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=he}function U(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=he}function I(){const he=this.stack[this.stack.length-1];if(this.data.inReference){const Ce=this.data.referenceType||"shortcut";he.type+="Reference",he.referenceType=Ce,delete he.url,delete he.title}else delete he.identifier,delete he.label;this.data.referenceType=void 0}function V(){const he=this.stack[this.stack.length-1];if(this.data.inReference){const Ce=this.data.referenceType||"shortcut";he.type+="Reference",he.referenceType=Ce,delete he.url,delete he.title}else delete he.identifier,delete he.label;this.data.referenceType=void 0}function K(he){const Ce=this.sliceSerialize(he),Me=this.stack[this.stack.length-2];Me.label=_V(Ce),Me.identifier=Va(Ce).toLowerCase()}function Q(){const he=this.stack[this.stack.length-1],Ce=this.resume(),Me=this.stack[this.stack.length-1];if(this.data.inReference=!0,Me.type==="link"){const Fe=he.children;Me.children=Fe}else Me.alt=Ce}function F(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.url=he}function q(){const he=this.resume(),Ce=this.stack[this.stack.length-1];Ce.title=he}function X(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function W(he){const Ce=this.resume(),Me=this.stack[this.stack.length-1];Me.label=Ce,Me.identifier=Va(this.sliceSerialize(he)).toLowerCase(),this.data.referenceType="full"}function re(he){this.data.characterReferenceType=he.type}function ae(he){const Ce=this.sliceSerialize(he),Me=this.data.characterReferenceType;let Fe;Me?(Fe=dM(Ce,Me==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Fe=sw(Ce);const _e=this.stack[this.stack.length-1];_e.value+=Fe}function ie(he){const Ce=this.stack.pop();Ce.position.end=$s(he.end)}function ye(he){M.call(this,he);const Ce=this.stack[this.stack.length-1];Ce.url=this.sliceSerialize(he)}function ue(he){M.call(this,he);const Ce=this.stack[this.stack.length-1];Ce.url="mailto:"+this.sliceSerialize(he)}function ee(){return{type:"blockquote",children:[]}}function ne(){return{type:"code",lang:null,meta:null,value:""}}function se(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Te(){return{type:"emphasis",children:[]}}function Be(){return{type:"heading",depth:0,children:[]}}function ot(){return{type:"break"}}function Je(){return{type:"html",value:""}}function We(){return{type:"image",title:null,url:"",alt:null}}function Ve(){return{type:"link",title:null,url:"",children:[]}}function De(he){return{type:"list",ordered:he.type==="listOrdered",start:null,spread:he._spread,children:[]}}function Ye(he){return{type:"listItem",spread:he._spread,checked:null,children:[]}}function Qe(){return{type:"paragraph",children:[]}}function st(){return{type:"strong",children:[]}}function ze(){return{type:"text",value:""}}function dt(){return{type:"thematicBreak"}}}function $s(e){return{line:e.line,column:e.column,offset:e.offset}}function EM(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?EM(e,r):BV(e,r)}}function BV(e,t){let n;for(n in t)if(SM.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function sk(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+$f({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+$f({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+$f({start:t.start,end:t.end})+") is still open")}function zV(e){const t=this;t.parser=n;function n(r){return LV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function IV(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function FV(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -839,4 +839,4 @@ ${x}`,fullLabel:y.name,type:y.type,degree:c.get(y.id)??0,nodeSize:Nte(c.get(y.id
|
|
|
839
839
|
`,children:[d.jsx(w,{className:"h-4 w-4"}),d.jsx("span",{className:"font-sans text-xs font-medium",children:Bne[b.type]??b.type}),!l&&d.jsx(wt,{variant:b.available?"secondary":"destructive",className:"text-[10px] px-1.5 py-0",children:b.available?"online":"offline"})]},b.type)})}),m&&d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Base URL"}),d.jsx(fn,{value:n,onChange:b=>f(b.target.value),placeholder:(p==null?void 0:p.baseUrl)??""})]}),m&&d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Context Length"}),d.jsx(fn,{type:"number",value:r,onChange:b=>h(b.target.value),placeholder:"32768 (default)"}),d.jsx("p",{className:"font-sans text-[11px] text-on-surface-variant/70",children:"Leave blank to use the 32K default. Myco creates a Modelfile variant at this size so the model loads at the size you asked for, not its (much larger) native default."})]}),y&&d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),x.length>0?d.jsxs(hi,{value:t,onValueChange:c,children:[d.jsx(Ua,{children:d.jsx(vi,{placeholder:a??"Select a model"})}),d.jsx(qa,{children:x.map(b=>d.jsx(Gr,{value:b,children:d.jsx("span",{className:"font-mono text-sm",children:b})},b))})]}):d.jsx(fn,{value:t,onChange:b=>c(b.target.value),placeholder:(p==null?void 0:p.available)===!1?"Provider offline":"Enter model name",disabled:(p==null?void 0:p.available)===!1})]})]})}const i5=3e4;function Ine(e){return Wt({queryKey:["task-config",e],queryFn:({signal:t})=>lt(`/agent/tasks/${e}/config`,{signal:t}),enabled:e!==void 0,staleTime:i5})}function s5(){return Wt({queryKey:["providers"],queryFn:({signal:e})=>lt("/providers",{signal:e}),staleTime:i5})}function l5(){return wr({mutationFn:e=>nn("/providers/test",e)})}function Fne(){const e=jn();return wr({mutationFn:({taskId:t,config:n})=>hc(`/agent/tasks/${t}/config`,n),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["task-config",n.taskId]})}})}function Une({phase:e,override:t,taskModel:n,providers:r,isLoadingProviders:a,onChange:i}){var f,h,p,m;const[l,o]=j.useState(!1),c=t.provider!==void 0||t.model!==void 0||t.maxTurns!==void 0;return d.jsxs("div",{className:"border border-[var(--ghost-border)] rounded-md",children:[d.jsxs("button",{onClick:()=>o(!l),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-surface-container-low/50 transition-colors rounded-md",children:[l?d.jsx($a,{className:"h-3.5 w-3.5 text-on-surface-variant"}):d.jsx(da,{className:"h-3.5 w-3.5 text-on-surface-variant"}),d.jsx("span",{className:"font-sans text-sm text-on-surface",children:e.name}),d.jsxs("span",{className:"font-mono text-xs text-on-surface-variant",children:["max ",t.maxTurns??e.maxTurns," turns"]}),c&&d.jsx(wt,{variant:"secondary",className:"text-[10px] ml-auto",children:"override"})]}),l&&d.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-[var(--ghost-border)]",children:[d.jsx("div",{className:"pt-3",children:d.jsx(iS,{providerType:((f=t.provider)==null?void 0:f.type)??"anthropic",model:((h=t.provider)==null?void 0:h.model)??t.model??"",baseUrl:((p=t.provider)==null?void 0:p.base_url)??"",contextLength:((m=t.provider)==null?void 0:m.context_length)!=null?String(t.provider.context_length):"",modelPlaceholder:e.model??n,providers:r,isLoadingProviders:a,onProviderChange:y=>{var b;const x=(b=r.find(w=>w.type===y))==null?void 0:b.baseUrl;i({...t,provider:{type:y,base_url:x},model:void 0})},onModelChange:y=>i({...t,provider:t.provider?{...t.provider,model:y}:void 0,model:t.provider?void 0:y}),onBaseUrlChange:y=>i({...t,provider:t.provider?{...t.provider,base_url:y}:void 0}),onContextLengthChange:y=>i({...t,provider:t.provider?{...t.provider,context_length:y?Number(y):void 0}:void 0})})}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),d.jsx(fn,{type:"number",value:t.maxTurns??"",onChange:y=>i({...t,maxTurns:y.target.value?Number(y.target.value):void 0}),placeholder:String(e.maxTurns)})]}),c&&d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>i(null),className:"text-xs text-on-surface-variant",children:"Clear Phase Override"})]})]})}const qne=["active","idle","sleep"],Vne={active:"Active",idle:"Idle",sleep:"Sleep"};function Hne({taskId:e,phases:t,defaults:n,schedule:r,params:a}){const{data:i,isPending:l}=s5(),{data:o}=Ine(e),c=l5(),f=Fne(),h=o==null?void 0:o.config,[p,m]=j.useState("anthropic"),[y,x]=j.useState(""),[b,w]=j.useState(""),[S,N]=j.useState(""),[C,T]=j.useState(""),[R,A]=j.useState(""),[D,O]=j.useState({}),[L,M]=j.useState({}),[P,z]=j.useState({}),[H,$]=j.useState(!1);j.useEffect(()=>{var B,W,re,ae;h&&(m(((B=h.provider)==null?void 0:B.type)??"anthropic"),x(((W=h.provider)==null?void 0:W.model)??h.model??""),w(((re=h.provider)==null?void 0:re.base_url)??""),N(((ae=h.provider)==null?void 0:ae.context_length)!=null?String(h.provider.context_length):""),T(h.maxTurns!=null?String(h.maxTurns):""),A(h.timeoutSeconds!=null?String(h.timeoutSeconds):""),O(h.phases??{}),M(h.schedule??{}),z(h.params??{}),$(!1))},[h]);const U=L.enabled??(r==null?void 0:r.enabled)??!1,I=L.runIn??(r==null?void 0:r.runIn)??[],V=(i==null?void 0:i.providers)??[];function K(B){var re;const W=V.find(ae=>ae.type===B);m(B),x(((re=W==null?void 0:W.models)==null?void 0:re[0])??""),w((W==null?void 0:W.baseUrl)??""),N(""),$(!0),c.reset()}function Q(B,W){O(re=>{const ae={...re};return W===null?delete ae[B]:ae[B]=W,ae}),$(!0)}function F(){const B=p==="ollama"||p==="lmstudio",W={type:p,...y?{model:y}:{},...B&&b?{base_url:b}:{},...B&&S?{context_length:Number(S)}:{}},re=r?Object.keys(L).length>0?{schedule:L}:{schedule:null}:{},ae=a&&Object.keys(P).length>0?{params:P}:{};f.mutate({taskId:e,config:{provider:W,...C?{maxTurns:Number(C)}:{maxTurns:null},...R?{timeoutSeconds:Number(R)}:{timeoutSeconds:null},...Object.keys(D).length>0?{phases:D}:{phases:null},...re,...ae}},{onSuccess:()=>$(!1)})}function q(){f.mutate({taskId:e,config:{provider:null,model:null,maxTurns:null,timeoutSeconds:null,phases:null,schedule:null,params:null}},{onSuccess:()=>{m("anthropic"),x(""),w(""),N(""),T(""),A(""),O({}),M({}),z({}),$(!1)}})}function X(){const W={type:p,...(p==="ollama"||p==="lmstudio")&&b?{base_url:b}:{}};c.mutate(W)}return d.jsxs(Ge,{level:"low",className:"p-4 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Task Config"}),h&&d.jsx(Ae,{variant:"ghost",size:"sm",onClick:q,className:"text-xs text-on-surface-variant",children:"Clear All Overrides"})]}),d.jsx(iS,{providerType:p,model:y,baseUrl:b,contextLength:S,modelPlaceholder:n==null?void 0:n.model,providers:V,isLoadingProviders:l,onProviderChange:K,onModelChange:B=>{x(B),$(!0)},onBaseUrlChange:B=>{w(B),$(!0)},onContextLengthChange:B=>{N(B),$(!0)}}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),d.jsx(fn,{type:"number",value:C,onChange:B=>{T(B.target.value),$(!0)},placeholder:(n==null?void 0:n.maxTurns)!=null?String(n.maxTurns):"—"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Timeout (seconds)"}),d.jsx(fn,{type:"number",value:R,onChange:B=>{A(B.target.value),$(!0)},placeholder:(n==null?void 0:n.timeoutSeconds)!=null?String(n.timeoutSeconds):"—"})]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:X,disabled:c.isPending,className:"gap-1.5 text-on-surface-variant",children:[c.isPending?d.jsx(zn,{className:"h-3.5 w-3.5 animate-spin"}):d.jsx(Qz,{className:"h-3.5 w-3.5"}),"Test"]}),c.isSuccess&&d.jsx("span",{className:"flex items-center gap-1 text-xs",children:c.data.ok?d.jsxs(d.Fragment,{children:[d.jsx(Td,{className:"h-3.5 w-3.5 text-green-500"}),d.jsxs("span",{className:"text-green-500 font-mono",children:[c.data.latency_ms,"ms"]})]}):d.jsxs(d.Fragment,{children:[d.jsx(yo,{className:"h-3.5 w-3.5 text-red-400"}),d.jsx("span",{className:"text-red-400",children:c.data.error})]})}),d.jsx("div",{className:"flex-1"}),d.jsxs(Ae,{size:"sm",onClick:F,disabled:!H||f.isPending,className:"gap-1.5",children:[f.isPending&&d.jsx(zn,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]}),r&&d.jsxs("div",{className:"space-y-3 pt-2 border-t border-[var(--ghost-border)]",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(GR,{className:"h-3.5 w-3.5 text-on-surface-variant"}),d.jsx("h3",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:"Scheduling"}),d.jsx(wt,{variant:U?"secondary":"outline",className:"text-[10px] px-1.5 py-0",children:U?"active":"off"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface",children:"Auto-run"}),d.jsx("p",{className:"font-sans text-[11px] text-on-surface-variant",children:"Automatically run this task on a schedule"})]}),d.jsx(ml,{checked:U,onCheckedChange:B=>{M(W=>({...W,enabled:B})),$(!0)}})]}),U&&d.jsxs("div",{className:"space-y-3 pl-0.5",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Run every (seconds)"}),d.jsx(fn,{type:"number",min:10,value:L.intervalSeconds??"",onChange:B=>{const W=B.target.value;M(re=>({...re,intervalSeconds:W?Number(W):void 0})),$(!0)},placeholder:r.intervalSeconds!=null?String(r.intervalSeconds):"300"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Run in states"}),d.jsx("div",{className:"flex gap-2",children:qne.map(B=>{const W=I.includes(B);return d.jsx("button",{onClick:()=>{const re=W?I.filter(ae=>ae!==B):[...I,B];M(ae=>({...ae,runIn:re.length>0?re:void 0})),$(!0)},className:`
|
|
840
840
|
rounded-md border px-3 py-1.5 font-sans text-xs font-medium transition-colors
|
|
841
841
|
${W?"border-primary/40 bg-primary/5 text-on-surface":"border-[var(--ghost-border)] bg-surface-container-lowest text-on-surface-variant hover:border-primary/20"}
|
|
842
|
-
`,children:Vne[B]},B)})})]})]})]}),a&&Object.keys(a).length>0&&d.jsxs("div",{className:"space-y-3 pt-2 border-t border-[var(--ghost-border)]",children:[d.jsx("h3",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Parameters"}),Object.entries(a).map(([B,W])=>{const re=P[B],ae=re??W,ie=B.replace(/_/g," ").replace(/\b\w/g,ye=>ye.toUpperCase());return typeof W=="boolean"?d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("label",{className:"font-sans text-sm text-on-surface",children:ie}),d.jsx(ml,{checked:ae,onCheckedChange:ye=>{z(ue=>({...ue,[B]:ye})),$(!0)}})]},B):d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-sm text-on-surface",children:ie}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(fn,{type:typeof W=="number"?"number":"text",value:re!=null?String(re):"",placeholder:String(W),onChange:ye=>{const ue=typeof W=="number"?ye.target.value===""?void 0:Number(ye.target.value):ye.target.value;z(ue===void 0?ee=>{const ne={...ee};return delete ne[B],ne}:ee=>({...ee,[B]:ue})),$(!0)},className:"w-40 font-mono"}),d.jsxs("span",{className:"font-sans text-xs text-on-surface-variant",children:["default: ",String(W)]})]})]},B)})]}),t&&t.length>0&&d.jsxs("div",{className:"space-y-2 pt-2 border-t border-[var(--ghost-border)]",children:[d.jsx("h3",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:"Per-Phase Overrides"}),t.map(B=>d.jsx(Une,{phase:B,override:D[B.name]??{},taskModel:y||"claude-sonnet-4-6",providers:V,isLoadingProviders:l,onChange:W=>Q(B.name,W)},B.name))]})]})}const $ne=3;function Gne(e){var t,n,r;return{model:((t=e.execution)==null?void 0:t.model)??e.model,maxTurns:((n=e.execution)==null?void 0:n.maxTurns)??e.maxTurns,timeoutSeconds:((r=e.execution)==null?void 0:r.timeoutSeconds)??e.timeoutSeconds}}function Kne(){return d.jsxs("div",{className:"space-y-6",children:[d.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-surface-container-high"}),d.jsxs("div",{className:"rounded-md bg-surface-container-low p-4 space-y-3",children:[d.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-4 w-64 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-8 w-32 animate-pulse rounded bg-surface-container-high"})]}),d.jsx("div",{className:"rounded-md bg-surface-container-low p-4 space-y-2",children:Array.from({length:$ne}).map((e,t)=>d.jsx("div",{className:"h-5 animate-pulse rounded bg-surface-container-high"},t))})]})}function Yne({phase:e,index:t}){return d.jsxs(Ge,{level:"low",className:"p-4 space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-surface-container-high font-mono text-xs font-semibold text-on-surface-variant shrink-0",children:t+1}),d.jsx("span",{className:"font-sans text-sm font-medium text-on-surface",children:e.name}),!e.required&&d.jsx(wt,{variant:"secondary",children:"optional"})]}),d.jsxs("span",{className:"font-mono text-xs text-on-surface-variant shrink-0",children:["max ",e.maxTurns," turns"]})]}),e.tools.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(n=>d.jsx("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded-sm bg-surface-container-high text-on-surface-variant",children:n},n))}),d.jsx(Ge,{level:"lowest",className:"p-3 overflow-auto max-h-40",children:d.jsx(Xr,{content:e.prompt})})]})}function Xne({taskId:e,onBack:t,onNavigate:n,onRunTriggered:r}){const{data:a,isPending:i,isError:l}=x$(e);if(i)return d.jsx(Kne,{});if(l||!(a!=null&&a.task))return d.jsxs("div",{className:"space-y-4",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Tasks"]}),d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Task not found"})]})]});const o=a.task,c=o.phases??[],f=Gne(o);return d.jsxs("div",{className:"space-y-6",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Tasks"]}),d.jsxs(Ge,{level:"low",className:"p-4 space-y-4",children:[d.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[d.jsxs("div",{className:"flex-1 space-y-1 min-w-0",children:[d.jsx("h1",{className:"font-serif text-lg text-on-surface",children:o.displayName}),o.description&&d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:o.description})]}),d.jsx(wt,{variant:s_(o.source),className:"shrink-0",children:xw(o.source??"built-in")})]}),d.jsx(One,{task:o,onDeleted:t,onCustomized:h=>n==null?void 0:n(h),onRunTriggered:r})]}),d.jsx(Hne,{taskId:e,phases:c,defaults:{model:f.model,maxTurns:f.maxTurns,timeoutSeconds:f.timeoutSeconds},schedule:o.schedule,params:o.params}),(f.model!==void 0||f.maxTurns!==void 0||f.timeoutSeconds!==void 0)&&d.jsxs(Ge,{level:"low",className:"p-4 space-y-3",children:[d.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Execution Config"}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[f.model!==void 0&&d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),d.jsx("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:f.model})]}),f.maxTurns!==void 0&&d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),d.jsx("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:f.maxTurns})]}),f.timeoutSeconds!==void 0&&d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Timeout"}),d.jsxs("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:[f.timeoutSeconds,"s"]})]})]})]}),c.length>0?d.jsxs("div",{className:"space-y-3",children:[d.jsxs("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:["Phases",d.jsxs("span",{className:"ml-2 text-on-surface normal-case font-normal",children:[c.length," ",c.length===1?"phase":"phases"]})]}),c.map((h,p)=>d.jsx(Yne,{phase:h,index:p},h.name))]}):d.jsxs("div",{className:"space-y-3",children:[d.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Prompt"}),d.jsx(Ge,{level:"lowest",className:"p-4 overflow-auto max-h-96",children:d.jsx(Xr,{content:o.prompt??""})})]}),d.jsx(Pne,{taskId:e})]})}function o5(e,t){var n,r,a;return{summaryBatchInterval:String(((n=e.agent)==null?void 0:n.summary_batch_interval)??Tb),defaultTask:t??"",scheduledTasksEnabled:((r=e.agent)==null?void 0:r.scheduled_tasks_enabled)??!0,eventTasksEnabled:((a=e.agent)==null?void 0:a.event_tasks_enabled)??!0}}function Qne(e,t,n){const r=o5(t,n);return e.summaryBatchInterval!==r.summaryBatchInterval||e.defaultTask!==r.defaultTask||e.scheduledTasksEnabled!==r.scheduledTasksEnabled||e.eventTasksEnabled!==r.eventTasksEnabled}function BA({label:e,value:t,max:n,color:r}){const a=n>0?Math.round(t/n*100):0,i=2*Math.PI*36,l=i-a/100*i;return d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsxs("div",{className:"relative h-20 w-20",children:[d.jsxs("svg",{className:"h-20 w-20 -rotate-90",viewBox:"0 0 80 80",children:[d.jsx("circle",{cx:"40",cy:"40",r:"36",fill:"none",stroke:"currentColor",className:"text-surface-container/30",strokeWidth:"6"}),d.jsx("circle",{cx:"40",cy:"40",r:"36",fill:"none",stroke:r,strokeWidth:"6",strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:l,className:"transition-all duration-700"})]}),d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:d.jsxs("span",{className:"text-sm font-semibold font-mono text-on-surface",children:[a,"%"]})})]}),d.jsx("span",{className:"text-xs text-on-surface-variant text-center font-sans",children:e})]})}function Gi({label:e,value:t}){return d.jsxs("div",{className:"flex items-center justify-between py-1",children:[d.jsx("span",{className:"text-xs text-on-surface-variant font-sans",children:e}),d.jsx("span",{className:"text-xs font-mono text-on-surface",children:t})]})}function Wne({stats:e}){const t=e.embedding.total_embeddable>0?e.embedding.embedded_count:0,n=e.embedding.total_embeddable;return d.jsxs("div",{className:"space-y-4",children:[d.jsxs("h2",{className:"text-xs font-semibold text-on-surface-variant uppercase tracking-widest flex items-center gap-2 font-sans",children:[d.jsx(Eb,{className:"h-3.5 w-3.5"}),"System Health"]}),d.jsxs("div",{className:"flex justify-center gap-8 py-2",children:[d.jsx(BA,{label:"Embedding Coverage",value:t,max:n,color:"#abcfb8"}),d.jsx(BA,{label:"Queue Health",value:Math.max(0,n-e.embedding.queue_depth),max:n,color:"#edbf7f"})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-0",children:[d.jsx(Gi,{label:"Sessions",value:String(e.vault.session_count)}),d.jsx(Gi,{label:"Spores",value:String(e.vault.spore_count)}),d.jsx(Gi,{label:"Entities",value:String(e.vault.entity_count)}),d.jsx(Gi,{label:"Graph edges",value:String(e.vault.edge_count)}),d.jsx(Gi,{label:"Uptime",value:yw(e.daemon.uptime_seconds)}),d.jsx(Gi,{label:"Daemon",value:`v${e.daemon.version} :${e.daemon.port}`}),e.agent.last_run_at!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Gi,{label:"Last run",value:bi(e.agent.last_run_at)}),d.jsx(Gi,{label:"Total runs",value:String(e.agent.total_runs)})]}),e.digest.freshest_tier!==null&&d.jsx(Gi,{label:"Digest tier",value:`T${e.digest.freshest_tier}`})]})]})}function Zne(){var L,M;const{config:e,isLoading:t,saveConfig:n,isSaving:r}=Od(),{data:a,isLoading:i}=Vp(),{data:l,isLoading:o}=xc(),{restart:c}=V1(),[f,h]=j.useState(null),[p,m]=j.useState(null),[y,x]=j.useState("idle"),[b,w]=j.useState(""),S=(l==null?void 0:l.tasks)??[],N=((L=S.find(P=>P.isDefault))==null?void 0:L.name)??"",C=j.useRef(!1);e&&!o&&!C.current&&(C.current=!0,f===null&&h(o5(e,N)));const T=f&&e?Qne(f,e,N):!1,R=!!((M=e==null?void 0:e.agent)!=null&&M.provider),A=j.useCallback((P,z)=>{h(H=>H&&{...H,[P]:z}),m(null)},[]),D=async()=>{if(!(!f||!e)){m(null);try{const P={...e,agent:{...e.agent,summary_batch_interval:Hb(f.summaryBatchInterval,Tb),scheduled_tasks_enabled:f.scheduledTasksEnabled,event_tasks_enabled:f.eventTasksEnabled}};await n(P),m({type:"success",text:"Agent settings saved. Restarting daemon..."});try{await c()}catch{m({type:"success",text:"Settings saved. Daemon restart may require manual action."})}}catch{m({type:"error",text:"Failed to save settings."})}}},O=async()=>{if(e){x("testing"),w("");try{const P=new URLSearchParams({provider:e.embedding.provider,type:"embedding"});e.embedding.base_url&&P.set("base_url",e.embedding.base_url);const H=(await lt(`/models?${P.toString()}`)).models.length;x("success"),w(`Connected -- ${H} model${H!==1?"s":""} available.`)}catch(P){x("error"),w(P instanceof Error?P.message:"Connection failed.")}}};return t||!e||!f?d.jsx("div",{className:"space-y-4",children:[1,2,3].map(P=>d.jsx("div",{className:"h-32 rounded-md animate-pulse bg-surface-container-low"},P))}):d.jsxs("div",{className:"space-y-6",children:[d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(Fz,{className:"h-4 w-4 text-primary"}),"Agent Operations"]})}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Scheduled Tasks"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Intelligence, skill survey, and skill evolution run automatically on a schedule"})]}),d.jsx(ml,{checked:f.scheduledTasksEnabled,onCheckedChange:P=>A("scheduledTasksEnabled",P),disabled:!R})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Event-Driven Tasks"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Titles and summaries generated automatically after coding sessions"})]}),d.jsx(ml,{checked:f.eventTasksEnabled,onCheckedChange:P=>A("eventTasksEnabled",P),disabled:!R})]})]}),!R&&d.jsxs("p",{className:"font-sans text-xs text-on-surface-variant/70",children:["Configure an agent provider in"," ",d.jsx("a",{href:"/settings",className:"underline hover:text-on-surface transition-colors",children:"Settings"})," ","to enable agent tasks."]}),d.jsx("div",{className:"border-t border-outline-variant/20"}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Title & Summary Batch Interval"}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(fn,{type:"number",min:0,placeholder:String(Tb),value:f.summaryBatchInterval,onChange:P=>A("summaryBatchInterval",P.target.value),className:"w-32 font-mono"}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:"batches"})]}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Run the Title & Summary task every N batches to keep active sessions properly titled. Set to 0 to disable."})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Default Task"}),o?d.jsxs("div",{className:"flex h-9 items-center gap-2 text-on-surface-variant font-sans text-sm",children:[d.jsx(zn,{className:"h-4 w-4 animate-spin"}),"Loading tasks..."]}):d.jsxs(hi,{value:f.defaultTask,onValueChange:P=>A("defaultTask",P),children:[d.jsx(Ua,{children:d.jsx(vi,{placeholder:"Select default task"})}),d.jsx(qa,{children:S.map(P=>d.jsx(Gr,{value:P.name,children:P.displayName},P.name))})]}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"The task used when Run Now is clicked or no task is specified."})]}),d.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[d.jsxs(Ae,{onClick:D,disabled:!T||r,size:"sm",children:[r?d.jsx(zn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Save Changes"]}),p&&d.jsx("span",{className:p.type==="success"?"font-sans text-xs text-primary":"font-sans text-xs text-tertiary",children:p.text})]})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-4 border-t-2 border-t-ochre",children:[d.jsx(St,{children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(P1,{className:"h-4 w-4 text-secondary"}),"Embedding Configuration"]})}),d.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Provider"}),d.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5",children:e.embedding.provider})]}),d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),d.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5 truncate",title:e.embedding.model,children:e.embedding.model})]}),e.embedding.base_url&&d.jsxs("div",{className:"col-span-2",children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Base URL"}),d.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5 truncate",title:e.embedding.base_url,children:e.embedding.base_url})]})]}),d.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[d.jsxs(Ae,{type:"button",variant:"ghost",size:"sm",onClick:O,disabled:y==="testing",children:[y==="testing"?d.jsx(zn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Test Connection"]}),d.jsxs("a",{href:"/settings",className:"flex items-center gap-1 font-sans text-xs text-on-surface-variant hover:text-on-surface transition-colors",children:[d.jsx(jd,{className:"h-3 w-3"}),"Edit in Settings"]}),y==="success"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-xs text-primary",children:[d.jsx(kb,{className:"h-3.5 w-3.5"}),b]}),y==="error"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-xs text-tertiary",children:[d.jsx(yo,{className:"h-3.5 w-3.5"}),b]})]})]}),i?d.jsx(Ge,{level:"low",className:"p-6",children:d.jsx("div",{className:"h-32 animate-pulse rounded-md bg-surface-container"})}):a?d.jsx(Ge,{level:"low",className:"p-6",children:d.jsx(Wne,{stats:a})}):null]})}const u5="tab",c5="run",f5="task",Jne=new Set(["runs","tasks","config"]);function zA(){const e=new URLSearchParams(window.location.search),t=e.get(u5);return{tab:t&&Jne.has(t)?t:"runs",runId:e.get(c5)??void 0,taskId:e.get(f5)??void 0}}function ere(e,t,n){const r=new URLSearchParams;e!=="runs"&&r.set(u5,e),t&&r.set(c5,t),n&&r.set(f5,n);const a=r.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.pushState(null,"",i)}const tre=[{id:"runs",label:"Runs"},{id:"tasks",label:"Tasks"},{id:"config",label:"Config"}];function nre(){const e=zA(),[t,n]=j.useState(e.tab),[r,a]=j.useState(e.runId),[i,l]=j.useState(e.taskId),[o,c]=j.useState(!1),f=j.useRef(!1),h=j.useRef(!1);j.useEffect(()=>{if(!f.current){f.current=!0;return}if(h.current){h.current=!1;return}ere(t,r,i)},[t,r,i]),j.useEffect(()=>{function m(){h.current=!0;const y=zA();n(y.tab),a(y.runId),l(y.taskId)}return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]);const p=j.useCallback(m=>{const y=m;n(y),y!=="runs"&&a(void 0),y!=="tasks"&&l(void 0)},[]);return d.jsxs("div",{className:"p-6 space-y-4",children:[d.jsx(wi,{title:"Agent",subtitle:"Intelligence runs, task configuration, and operational settings",tabs:tre,activeTab:t,onTabChange:p,actions:t==="runs"?d.jsxs(Ae,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>c(!0),children:[d.jsx(rs,{className:"h-3.5 w-3.5"}),"Run Now"]}):void 0}),t==="runs"&&(r?d.jsx(Ene,{runId:r,onBack:()=>a(void 0)}):d.jsx(vne,{onSelectRun:a,onTriggerRun:()=>c(!0)})),t==="tasks"&&(i?d.jsx(Xne,{taskId:i,onBack:()=>l(void 0),onNavigate:l,onRunTriggered:m=>{l(void 0),n("runs"),m&&a(m)}}):d.jsx(Ane,{onSelect:l})),t==="config"&&d.jsx(Zne,{}),d.jsx(Nne,{open:o,onOpenChange:c,onTriggered:()=>a(void 0)})]})}function d5(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),(e==null?void 0:e.limit)!==void 0&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset));const n=t.toString(),r=n?`/skill-candidates?${n}`:"/skill-candidates";return Wt({queryKey:["skill-candidates",e],queryFn:({signal:a})=>lt(r,{signal:a})})}function rre(){const e=jn();return wr({mutationFn:({id:t,...n})=>hc(`/skill-candidates/${t}`,n),onSuccess:()=>{e.invalidateQueries({queryKey:["skill-candidates"]})}})}function h5(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),(e==null?void 0:e.limit)!==void 0&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset));const n=t.toString(),r=n?`/skill-records?${n}`:"/skill-records";return Wt({queryKey:["skill-records",e],queryFn:({signal:a})=>lt(r,{signal:a})})}function are(e){return Wt({queryKey:["skill-record",e],queryFn:({signal:t})=>lt(`/skill-records/${e}`,{signal:t}),enabled:!!e})}function ire(){const e=jn();return wr({mutationFn:t=>I1(`/skill-records/${encodeURIComponent(t)}`),onSuccess:()=>{e.invalidateQueries({queryKey:["skill-records"]}),e.invalidateQueries({queryKey:["skill-record"]})}})}const Bn={IDENTIFIED:"identified",APPROVED:"approved",GENERATED:"generated",DISMISSED:"dismissed"},sre=`${Bn.APPROVED},${Bn.GENERATED}`,lre=[{key:"status",label:"Status",options:[{value:er,label:"All statuses"},{value:Bn.IDENTIFIED,label:"Identified"},{value:sre,label:"Approved & generated"},{value:Bn.APPROVED,label:"Awaiting generation"},{value:Bn.GENERATED,label:"Generated"},{value:Bn.DISMISSED,label:"Dismissed"}]}];function ore(e){const t=`${(e*100).toFixed(0)}%`;return e>=.85?{text:t,variant:"default"}:e>=.7?{text:t,variant:"secondary"}:{text:t,variant:"outline"}}function IA(e){const t=Math.floor(Date.now()/1e3)-e;return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function ure(e){switch(e){case Bn.IDENTIFIED:return d.jsx(wt,{variant:"outline",children:"Identified"});case Bn.APPROVED:return d.jsx(wt,{variant:"secondary",children:"Awaiting generation"});case Bn.GENERATED:return d.jsx(wt,{variant:"default",children:"Generated"});case Bn.DISMISSED:return d.jsx(wt,{variant:"outline",className:"opacity-50",children:"Dismissed"});default:return d.jsx(wt,{variant:"outline",children:e})}}function cre({candidate:e,onApprove:t,onDismiss:n,isApproving:r,isDismissing:a}){const i=ore(e.confidence),l=e.status===Bn.IDENTIFIED||e.status===Bn.APPROVED;return d.jsxs(Ge,{level:"low",className:"p-5 space-y-3",children:[d.jsxs("div",{className:"flex items-start justify-between gap-4",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("h3",{className:"font-serif text-lg text-on-surface leading-tight",children:e.topic}),e.approved_at!==null&&d.jsxs("p",{className:"font-sans text-xs text-on-surface-variant mt-1",children:["Approved ",IA(e.approved_at),e.status===Bn.GENERATED&&" · generated"]})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[ure(e.status),d.jsx(wt,{variant:i.variant,children:i.text}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:IA(e.created_at)})]})]}),d.jsx(Xr,{content:e.rationale,className:"text-sm text-on-surface-variant"}),l&&d.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.status===Bn.IDENTIFIED&&d.jsxs(d.Fragment,{children:[d.jsxs(Ae,{size:"sm",variant:"default",onClick:t,disabled:r,children:[d.jsx(kd,{className:"h-3.5 w-3.5 mr-1.5"}),r?"Approving...":"Approve"]}),d.jsxs(Ae,{size:"sm",variant:"ghost",onClick:n,disabled:a,className:"text-on-surface-variant",children:[d.jsx(yo,{className:"h-3.5 w-3.5 mr-1.5"}),a?"Dismissing...":"Dismiss"]})]}),e.status===Bn.APPROVED&&d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:"Awaiting generation"})]})]})}function fre(){return d.jsxs(Ge,{level:"low",className:"p-5 space-y-3",children:[d.jsxs("div",{className:"flex items-start justify-between",children:[d.jsx("div",{className:"h-5 w-64 rounded bg-surface-container-high animate-pulse"}),d.jsx("div",{className:"h-5 w-20 rounded bg-surface-container-high animate-pulse"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("div",{className:"h-3 w-full rounded bg-surface-container-high animate-pulse"}),d.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-container-high animate-pulse"})]}),d.jsx("div",{className:"h-8 w-32 rounded bg-surface-container-high animate-pulse"})]})}function dre(){const e=rre(),{searchInput:t,debouncedSearch:n,filterValues:r,offset:a,setOffset:i,handleSearchChange:l,handleFilterChange:o,activeFilter:c}=Bd({initialFilters:{status:Bn.IDENTIFIED}}),f=c("status"),{data:h,isLoading:p,isError:m,error:y}=d5({status:f,limit:Kr,offset:a}),x=(h==null?void 0:h.candidates)??[],b=(h==null?void 0:h.total)??0,w=j.useMemo(()=>{if(!n)return x;const T=n.toLowerCase();return x.filter(R=>R.topic.toLowerCase().includes(T)||R.rationale.toLowerCase().includes(T))},[x,n]);function S(T){e.mutate({id:T.id,status:Bn.APPROVED})}function N(T){e.mutate({id:T.id,status:Bn.DISMISSED})}const C=d.jsx(Pd,{searchPlaceholder:"Search candidates...",searchValue:t,onSearchChange:l,filters:lre,filterValues:r,onFilterChange:o});return m?d.jsxs("div",{className:"space-y-3",children:[C,d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Failed to load candidates"}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:y instanceof Error?y.message:"Unknown error"})]})]}):p?d.jsxs("div",{className:"space-y-3",children:[C,Array.from({length:3}).map((T,R)=>d.jsx(fre,{},R))]}):d.jsxs("div",{className:"space-y-3",children:[C,w.length===0?d.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-3 text-on-surface-variant",children:[d.jsx(Mz,{className:"h-10 w-10 opacity-20"}),b===0&&!f&&!n?d.jsxs("div",{className:"text-center space-y-2 max-w-md",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"No skill candidates discovered yet"}),d.jsx("p",{className:"font-sans text-xs leading-relaxed",children:"Candidates are procedural patterns discovered from your vault knowledge. Review and approve them here, then Myco generates full skills from them."}),d.jsxs("div",{className:"font-sans text-xs space-y-1 pt-1",children:[d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Automatic:"})," ","The"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-survey",className:"text-primary hover:underline",children:"Skill Survey"})," ","task runs automatically during idle periods and discovers candidates from session history, decisions, and gotchas."]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Manual:"})," ","Run"," ",d.jsxs(Ma,{to:"/agent?tab=tasks&task=skill-survey",className:"inline-flex items-center gap-1 text-primary hover:underline",children:[d.jsx(jd,{className:"h-3 w-3"}),"Skill Survey"]})," ","from the Agent page to discover candidates on demand."]})]})]}):d.jsx("span",{className:"font-sans text-sm",children:"No matching candidates"})]}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:n?`${w.length} of ${b} candidate${b!==1?"s":""}`:`${b} candidate${b!==1?"s":""}`}),w.map(T=>{var R,A,D,O;return d.jsx(cre,{candidate:T,onApprove:()=>S(T),onDismiss:()=>N(T),isApproving:e.isPending&&((R=e.variables)==null?void 0:R.id)===T.id&&((A=e.variables)==null?void 0:A.status)===Bn.APPROVED,isDismissing:e.isPending&&((D=e.variables)==null?void 0:D.id)===T.id&&((O=e.variables)==null?void 0:O.status)===Bn.DISMISSED},T.id)})]}),d.jsx(Ec,{total:n?w.length:b,offset:a,limit:Kr,onPageChange:i})]})}const hre=5,vre=[{key:"status",label:"Status",options:[{value:er,label:"All statuses"},{value:"active",label:"Active"},{value:"stale",label:"Stale"},{value:"retired",label:"Retired"}]}];function pre(e){return e==="active"?"default":e==="stale"?"secondary":"outline"}function If({children:e,className:t}){return d.jsx("th",{className:ke("px-4 py-3 text-left font-sans text-[10px] font-medium uppercase tracking-widest text-on-surface-variant",t),children:e})}function mre(){return d.jsxs("tr",{className:"border-b border-[var(--ghost-border)]",children:[d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-40 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-12 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-16 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-10 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-20 rounded bg-surface-container-high animate-pulse"})})]})}function gre({record:e,onClick:t}){return d.jsxs("tr",{className:"border-b border-[var(--ghost-border)] last:border-0 hover:bg-surface-container/60 cursor-pointer transition-all duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40 hover:shadow-[inset_3px_0_0_var(--primary)]",onClick:t,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())},tabIndex:0,role:"row","aria-label":`Skill: ${e.display_name}`,children:[d.jsxs("td",{className:"px-4 py-3",children:[d.jsx("span",{className:"font-sans text-sm font-medium text-on-surface block",children:e.display_name}),d.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant block mt-0.5",children:e.name})]}),d.jsx("td",{className:"px-4 py-3",children:d.jsxs(wt,{variant:"outline",className:"font-mono text-[10px] px-1.5 py-0",children:["gen ",e.generation]})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx(wt,{variant:pre(e.status),children:e.status})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("span",{className:"font-mono text-xs text-on-surface-variant",children:e.usage_count})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("span",{className:"font-mono text-xs text-on-surface-variant",children:am(e.updated_at)})})]})}function yre({onSelectSkill:e}){const{searchInput:t,debouncedSearch:n,filterValues:r,offset:a,setOffset:i,handleSearchChange:l,handleFilterChange:o,activeFilter:c}=Bd({initialFilters:{status:er}}),f=c("status"),{data:h,isLoading:p,isError:m,error:y}=h5({status:f,limit:Kr,offset:a}),x=(h==null?void 0:h.records)??[],b=(h==null?void 0:h.total)??0,w=n?x.filter(C=>C.display_name.toLowerCase().includes(n.toLowerCase())||C.name.toLowerCase().includes(n.toLowerCase())||C.description.toLowerCase().includes(n.toLowerCase())):x,S=d.jsx(Pd,{searchPlaceholder:"Search skills...",searchValue:t,onSearchChange:l,filters:vre,filterValues:r,onFilterChange:o}),N=d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-[var(--ghost-border)] bg-surface-container/50",children:[d.jsx(If,{children:"Name"}),d.jsx(If,{children:"Generation"}),d.jsx(If,{children:"Status"}),d.jsx(If,{children:"Usage"}),d.jsx(If,{children:"Last Evolved"})]})});return m?d.jsxs("div",{children:[S,d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary mt-4",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Failed to load skills"}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:y instanceof Error?y.message:"Unknown error"})]})]}):d.jsxs("div",{children:[S,p?d.jsx(Ge,{level:"low",className:"rounded-md overflow-hidden mt-4",children:d.jsxs("table",{className:"w-full",children:[N,d.jsx("tbody",{children:Array.from({length:hre}).map((C,T)=>d.jsx(mre,{},T))})]})}):w.length===0?d.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-3 text-on-surface-variant mt-4",children:[d.jsx(mz,{className:"h-10 w-10 opacity-20"}),b===0&&!n&&!f?d.jsxs("div",{className:"text-center space-y-2 max-w-md",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"No skills generated yet"}),d.jsx("p",{className:"font-sans text-xs leading-relaxed",children:"Skills are project-specific procedural guides generated from your vault knowledge. They teach agents how to accomplish tasks in this codebase."}),d.jsxs("div",{className:"font-sans text-xs space-y-1 pt-1",children:[d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Automatic:"})," ","The"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-survey",className:"text-primary hover:underline",children:"Skill Survey"})," ","task runs automatically and discovers candidates from your vault. Approve candidates in the"," ",d.jsx(Ma,{to:"/skills?tab=candidates",className:"text-primary hover:underline",children:"Candidates tab"}),", then enable the"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","task to produce skills automatically."]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Manual:"})," ","Run"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","from the Agent page to generate a skill on demand."]})]})]}):d.jsx("span",{className:"font-sans text-sm",children:"No matching skills"})]}):d.jsx(Ge,{level:"low",className:"rounded-md overflow-hidden mt-4",children:d.jsxs("table",{className:"w-full","aria-label":"Skills",children:[N,d.jsx("tbody",{children:w.map(C=>d.jsx(gre,{record:C,onClick:()=>e(C.name)},C.id))})]})}),d.jsx(Ec,{total:b,offset:a,limit:Kr,onPageChange:i})]})}const xre={created:"default",updated:"secondary",split:"warning",retired:"outline"};function bre({entry:e}){const[t,n]=j.useState(!1);return d.jsxs("div",{className:"relative pl-6",children:[d.jsx("div",{className:"absolute left-0 top-2 h-2.5 w-2.5 rounded-full border-2 border-outline-variant bg-surface-container"}),d.jsxs("button",{type:"button",className:"w-full text-left group cursor-pointer",onClick:()=>n(r=>!r),"aria-expanded":t,children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsxs(wt,{variant:"outline",className:"font-mono text-[10px] px-1.5 py-0",children:["v",e.generation]}),d.jsx(wt,{variant:xre[e.action]??"outline",children:e.action}),d.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant ml-auto shrink-0",children:am(e.created_at)}),d.jsx(da,{className:ke("h-3.5 w-3.5 text-on-surface-variant transition-transform duration-150",t&&"rotate-90")})]}),e.rationale&&d.jsx("p",{className:"font-sans text-sm text-on-surface-variant mt-1 leading-relaxed",children:e.rationale})]}),t&&e.content_snapshot&&d.jsx(Ge,{level:"lowest",className:"mt-2 p-3 overflow-auto max-h-96",children:d.jsx("pre",{className:"font-mono text-xs text-on-surface whitespace-pre-wrap break-words",children:e.content_snapshot})})]})}function wre({entries:e}){return e.length===0?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant py-4",children:"No evolution history."}):d.jsxs("div",{className:"relative space-y-4",children:[d.jsx("div",{className:"absolute left-[4.5px] top-2 bottom-2 w-px bg-outline-variant/30"}),e.map(t=>d.jsx(bre,{entry:t},t.id))]})}function Sre(e){return e==="active"?"default":e==="stale"?"secondary":"outline"}function Ere(e){if(!e)return 0;try{const t=JSON.parse(e);return Array.isArray(t)?t.length:0}catch{return 0}}function Cre(){return d.jsxs("div",{className:"space-y-6",children:[d.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-surface-container-high"}),d.jsxs("div",{className:"rounded-md bg-surface-container-low p-4 space-y-3",children:[d.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-4 w-64 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-5 w-32 animate-pulse rounded bg-surface-container-high"})]}),d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:Array.from({length:3}).map((e,t)=>d.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-surface-container-high"},t))})]})}function Nre({skillName:e,onBack:t}){var m,y;const{data:n,isPending:r,isError:a}=are(e),i=ire(),[l,o]=j.useState(!1);if(r)return d.jsx(Cre,{});if(a||!n)return d.jsxs("div",{className:"space-y-4",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Skills"]}),d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Skill not found"})]})]});const c=Ere(n.source_ids),f=((y=(m=n.lineage)==null?void 0:m[0])==null?void 0:y.content_snapshot)??null,h=n.frontmatter??{},p=(f==null?void 0:f.replace(/^---\n[\s\S]*?\n---\n*/,""))??null;return d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Skills"]}),d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-2 text-tertiary hover:text-tertiary hover:bg-tertiary/10",onClick:()=>o(!0),children:[d.jsx(as,{className:"h-4 w-4"}),"Delete"]})]}),d.jsx(Ge,{level:"low",className:"p-4 space-y-3",children:d.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[d.jsxs("div",{className:"flex-1 space-y-1 min-w-0",children:[d.jsx("h1",{className:"font-serif text-lg text-on-surface",children:n.display_name}),n.description&&d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:n.description}),n.path&&d.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant mt-1",children:n.path}),Object.keys(h).length>0&&d.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[h["user-invocable"]==="true"&&d.jsx(wt,{variant:"secondary",children:"user-invocable"}),h["allowed-tools"]&&d.jsxs(wt,{variant:"outline",children:["tools: ",h["allowed-tools"]]})]})]}),d.jsx(wt,{variant:Sre(n.status),className:"shrink-0",children:n.status})]})}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[d.jsx(Kt,{label:"Generation",value:`v${n.generation}`,accent:"sage"}),d.jsx(Kt,{label:"Usage",value:`${n.usage_total??n.usage_count??0}`,sublabel:"sessions",accent:"ochre"}),d.jsx(Kt,{label:"Sources",value:`${c}`,accent:"outline"})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsx(St,{children:"Evolution History"}),d.jsx(wre,{entries:n.lineage??[]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsx(St,{children:"Current Content"}),p?d.jsx(Xr,{content:p}):d.jsx("p",{className:"font-sans text-sm text-on-surface-variant py-4",children:"No content snapshot available."})]}),d.jsx(im,{open:l,onOpenChange:o,title:"Delete Skill",description:"This will permanently delete the skill record, evolution history, and the SKILL.md file from disk.",icon:d.jsx(as,{className:"h-4 w-4 text-tertiary"}),meta:n?[{label:"Name",value:n.name},{label:"Title",value:n.display_name}]:[],confirmLabel:"Delete Skill",variant:"destructive",onConfirm:()=>{i.mutate(n.name,{onSuccess:()=>{o(!1),t()}})},isPending:i.isPending})]})}const v5="tab",p5="skill",kre=new Set(["candidates","skills"]);function Tre(){const e=new URLSearchParams(window.location.search),t=e.get(v5);return{tab:t&&kre.has(t)?t:"skills",skill:e.get(p5)??void 0}}function jre(e,t){const n=new URLSearchParams;e!=="skills"&&n.set(v5,e),t&&n.set(p5,t);const r=n.toString(),a=r?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState(null,"",a)}const Are=[{id:"skills",label:"Skills"},{id:"candidates",label:"Candidates"}];function Rre(){return d.jsxs(Ad,{children:[d.jsx(bF,{asChild:!0,children:d.jsx(Ae,{variant:"ghost",size:"sm",className:"text-on-surface-variant",children:d.jsx(yz,{className:"h-4 w-4"})})}),d.jsxs(pc,{className:"max-w-lg",children:[d.jsxs(Rd,{children:[d.jsx(mc,{children:"How Skills Work"}),d.jsx(Qp,{children:"Skills are project-specific procedural guides generated from your vault knowledge. They teach agents how to accomplish tasks in your codebase."})]}),d.jsxs("div",{className:"space-y-4 font-sans text-sm text-on-surface-variant",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"font-medium text-on-surface",children:"The Pipeline"}),d.jsxs("ol",{className:"list-decimal pl-5 space-y-1",children:[d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Survey"})," — discovers candidate skills from vault knowledge (sessions, decisions, gotchas)"]}),d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Approve"})," — you review candidates and approve the ones worth generating"]}),d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Generate"})," — produces a SKILL.md file from the approved candidate's source material"]}),d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Evolve"})," — updates existing skills when new knowledge makes them stale"]})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"font-medium text-on-surface",children:"Scheduling"}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Skill Survey"})," runs automatically during idle periods. Skill Generate and Skill Evolve are off by default — enable them in the"," ",d.jsxs(Ma,{to:"/agent?tab=tasks",className:"text-primary hover:underline inline-flex items-center gap-0.5",children:["Agent Tasks",d.jsx(jd,{className:"h-3 w-3"})]})," ","page for fully automatic operation, or trigger them manually with Run Now."]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"font-medium text-on-surface",children:"Quick Start"}),d.jsxs("ol",{className:"list-decimal pl-5 space-y-1",children:[d.jsx("li",{children:"Wait for the survey to discover candidates (or run it manually)"}),d.jsx("li",{children:"Review candidates in the Candidates tab and approve the best ones"}),d.jsxs("li",{children:["Run"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","to produce skills from approved candidates"]})]})]})]})]})]})}function Dre(){const e=Tre(),[t,n]=j.useState(e.tab),[r,a]=j.useState(e.skill),{data:i}=d5({status:"identified"}),{data:l}=h5({status:"active"}),o=(i==null?void 0:i.total)??0,c=(l==null?void 0:l.total)??0;j.useEffect(()=>{jre(t,r)},[t,r]);const f=j.useCallback(p=>{const m=p;n(m),m!=="skills"&&a(void 0)},[]),h=j.useCallback(p=>{n("skills"),a(p)},[]);return d.jsxs("div",{className:"p-6 space-y-4",children:[d.jsx(wi,{title:"Skills",subtitle:"Discovered skill candidates and promoted skill records",tabs:Are,activeTab:t,onTabChange:f,actions:d.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&d.jsxs(wt,{variant:"secondary",children:[o," pending"]}),c>0&&d.jsxs(wt,{variant:"default",children:[c," active"]}),d.jsx(Rre,{})]})}),t==="candidates"&&d.jsx(dre,{}),t==="skills"&&!r&&d.jsx(yre,{onSelectSkill:h}),t==="skills"&&r&&d.jsx(Nre,{skillName:r,onBack:()=>a(void 0)})]})}const Mre=new Set(["openai-compatible"]);function _re(e,t,n){const r=e?Mre.has(e):!1;return Wt({queryKey:["models",e,t,n],queryFn:({signal:i})=>{const l=new URLSearchParams({provider:e});return t&&l.set("base_url",t),l.set("type",n),lt(`/models?${l.toString()}`,{signal:i})},enabled:!!e&&(!r||!!t),staleTime:nI})}function Ore(){const[e,t]=j.useState({}),[n,r]=j.useState([]),[a,i]=j.useState([]),[l,o]=j.useState(""),[c,f]=j.useState(!1),[h,p]=j.useState(null),[m,y]=j.useState(!0);j.useEffect(()=>{lt("/config/plan-dirs").then(T=>{t(T.symbiont),r(T.custom),i(T.custom)}).catch(()=>{}).finally(()=>y(!1))},[]);const x=n.length!==a.length||n.some((T,R)=>T!==a[R]),b=j.useCallback(()=>{const T=l.trim();!T||n.includes(T)||(r(R=>[...R,T]),o(""),p(null))},[l,n]),w=j.useCallback(T=>{r(R=>R.filter(A=>A!==T)),p(null)},[]),S=j.useCallback(async()=>{f(!0),p(null);try{const T=await nn("/config/plan-dirs",{plan_dirs:n});i(T.custom),r(T.custom),p({type:"success",text:"Plan directories saved."})}catch{p({type:"error",text:"Failed to save plan directories."})}finally{f(!1)}},[n]),N=j.useCallback(T=>{T.key==="Enter"&&b()},[b]),C=Object.entries(e);return d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-amber-500",children:[d.jsx(St,{children:"Plan Capture"}),m?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:"Loading..."}):d.jsxs("div",{className:"space-y-5",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"Agent Directories"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Directories monitored by connected agents. Managed by symbiont manifests."}),C.length===0?d.jsx("p",{className:"font-sans text-xs text-on-surface-variant italic",children:"No agent directories configured."}):d.jsx("div",{className:"space-y-3",children:C.map(([T,R])=>d.jsxs("div",{className:"space-y-1",children:[d.jsx("p",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:T}),d.jsx("div",{className:"space-y-1",children:R.map(A=>d.jsx("div",{className:"rounded bg-surface-container px-3 py-1.5 font-mono text-xs text-on-surface-variant",children:A},A))})]},T))})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"Custom Directories"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Additional directories to watch for plan files."}),n.length>0&&d.jsx("div",{className:"space-y-1",children:n.map(T=>d.jsxs("div",{className:"flex items-center gap-2 rounded bg-surface-container px-3 py-1.5",children:[d.jsx("span",{className:"flex-1 font-mono text-xs text-on-surface",children:T}),d.jsx("button",{type:"button",onClick:()=>w(T),className:"font-sans text-xs text-on-surface-variant hover:text-tertiary transition-colors leading-none","aria-label":`Remove ${T}`,children:"x"})]},T))}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(fn,{placeholder:"/path/to/plans",value:l,onChange:T=>o(T.target.value),onKeyDown:N,className:"flex-1 font-mono text-xs"}),d.jsx(Ae,{type:"button",size:"sm",onClick:b,disabled:!l.trim(),children:"Add"})]})]}),x&&d.jsxs("div",{className:"flex items-center gap-4 pt-1",children:[d.jsx(Ae,{onClick:S,disabled:c,size:"sm",children:c?"Saving...":"Save"}),h&&d.jsx("span",{className:h.type==="success"?"font-sans text-sm text-primary":"font-sans text-sm text-tertiary",children:h.text})]}),!x&&(h==null?void 0:h.type)==="success"&&d.jsx("p",{className:"font-sans text-sm text-primary",children:h.text})]})]})}function zv({children:e,hint:t}){return d.jsxs("label",{className:"font-sans text-sm font-medium text-on-surface",children:[e,t&&d.jsxs("span",{className:"ml-1 font-sans text-xs text-on-surface-variant font-normal",children:["(",t,")"]})]})}function sb({children:e}){return d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:e})}function Lre(){var y,x,b,w;const{config:e,saveConfig:t,isSaving:n}=Od(),{data:r}=IF(),[a,i]=j.useState(null),[l,o]=j.useState(null);j.useEffect(()=>{var S,N,C,T;e&&!a&&i({enabled:((S=e.notifications)==null?void 0:S.enabled)??!0,system_notifications:((N=e.notifications)==null?void 0:N.system_notifications)??!1,default_mode:((C=e.notifications)==null?void 0:C.default_mode)??"banner",domains:((T=e.notifications)==null?void 0:T.domains)??{}})},[e,a]);const c=j.useCallback((S,N)=>{i(C=>C&&{...C,[S]:N}),o(null)},[]),f=j.useCallback((S,N)=>{i(C=>{if(!C)return C;const T=C.domains[S]??{enabled:!0};return{...C,domains:{...C.domains,[S]:{...T,...N}}}}),o(null)},[]),h=j.useCallback(async()=>{if(!(!a||!e)){o(null);try{await t({...e,notifications:a}),o({type:"success",text:"Notification settings saved."})}catch{o({type:"error",text:"Failed to save notification settings."})}}},[a,e,t]);if(!a||!e)return null;const p=(r==null?void 0:r.domains)??[],m=e?a.enabled!==(((y=e.notifications)==null?void 0:y.enabled)??!0)||a.system_notifications!==(((x=e.notifications)==null?void 0:x.system_notifications)??!1)||a.default_mode!==(((b=e.notifications)==null?void 0:b.default_mode)??"banner")||JSON.stringify(a.domains)!==JSON.stringify(((w=e.notifications)==null?void 0:w.domains)??{}):!1;return d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:"Notifications"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(zv,{children:"Enabled"}),d.jsx(sb,{children:"Master switch for all notification types."})]}),d.jsx(ml,{checked:a.enabled,onCheckedChange:S=>c("enabled",S)})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(zv,{children:"System Notifications"}),d.jsx(sb,{children:"Show browser notifications when the tab is not focused."})]}),d.jsx(ml,{checked:a.system_notifications,onCheckedChange:S=>c("system_notifications",S),disabled:!a.enabled})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(zv,{children:"Default Mode"}),d.jsxs(hi,{value:a.default_mode,onValueChange:S=>c("default_mode",S),disabled:!a.enabled,children:[d.jsx(Ua,{className:"w-40",children:d.jsx(vi,{})}),d.jsxs(qa,{children:[d.jsx(Gr,{value:"banner",children:"Banner"}),d.jsx(Gr,{value:"summary",children:"Summary"})]})]}),d.jsx(sb,{children:"Banner shows as a pop-up overlay. Summary shows only in the notification panel."})]}),p.length>0&&d.jsxs("div",{className:"space-y-3 pt-2",children:[d.jsx(zv,{children:"Domain Notifications"}),d.jsx("div",{className:"space-y-3",children:p.map(S=>{const N=a.domains[S.domain]??{enabled:!0},C=N.enabled;return d.jsxs("div",{className:"flex items-center justify-between gap-3 py-1",children:[d.jsxs("div",{className:"space-y-0.5 flex-1 min-w-0",children:[d.jsx("span",{className:"text-sm text-on-surface",children:S.label}),d.jsx("p",{className:"text-[11px] text-on-surface-variant",children:S.types.map(T=>T.label).join(", ")})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.jsxs(hi,{value:N.mode??"default",onValueChange:T=>f(S.domain,{mode:T==="default"?void 0:T}),disabled:!a.enabled||!C,children:[d.jsx(Ua,{className:"w-[110px] h-8 text-xs",children:d.jsx(vi,{})}),d.jsxs(qa,{children:[d.jsx(Gr,{value:"default",children:"Default"}),d.jsx(Gr,{value:"banner",children:"Banner"}),d.jsx(Gr,{value:"summary",children:"Summary"})]})]}),d.jsx(ml,{checked:C,onCheckedChange:T=>f(S.domain,{enabled:T}),disabled:!a.enabled})]})]},S.domain)})})]})]}),d.jsxs("div",{className:"flex items-center gap-4 pt-2",children:[d.jsxs(Ae,{onClick:h,disabled:!m||n,size:"sm",children:[n?d.jsx(zn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save Notifications"]}),l&&d.jsx("span",{className:l.type==="success"?"font-sans text-sm text-primary":"font-sans text-sm text-tertiary",children:l.text})]})]})}const Pre=["debug","info","warn","error"],Bre=[{value:"ollama",label:"Ollama"},{value:"openai-compatible",label:"OpenAI-compatible"}],zre=[{value:"1500",label:"1.5K — Executive briefing"},{value:"5000",label:"5K — Deep onboarding"},{value:"10000",label:"10K — Full institutional"}];function FA(e){var t,n,r,a,i,l,o,c,f,h,p,m,y;return{daemonPort:e.daemon.port!=null?String(e.daemon.port):"",logLevel:e.daemon.log_level,logRetentionDays:String(e.daemon.log_retention_days),embeddingProvider:e.embedding.provider,embeddingModel:e.embedding.model,embeddingBaseUrl:e.embedding.base_url??"",contextDigestTier:String(((t=e.context)==null?void 0:t.digest_tier)??eD),contextPromptSearch:((n=e.context)==null?void 0:n.prompt_search)??!0,contextMaxSpores:String(((r=e.context)==null?void 0:r.prompt_max_spores)??tD),agentProviderType:((i=(a=e.agent)==null?void 0:a.provider)==null?void 0:i.type)??"",agentModel:((o=(l=e.agent)==null?void 0:l.provider)==null?void 0:o.model)??((c=e.agent)==null?void 0:c.model)??"",agentBaseUrl:((h=(f=e.agent)==null?void 0:f.provider)==null?void 0:h.base_url)??"",agentContextLength:((y=(m=(p=e.agent)==null?void 0:p.provider)==null?void 0:m.context_length)==null?void 0:y.toString())??""}}function Ire(e,t){var o,c,f;const n=!!((o=t.agent)!=null&&o.provider),r=e.agentProviderType!=="",a=r?{type:e.agentProviderType,...e.agentModel?{model:e.agentModel}:{},...e.agentBaseUrl?{base_url:e.agentBaseUrl}:{},...e.agentContextLength?{context_length:Number(e.agentContextLength)}:{}}:void 0;let i=(c=t.agent)==null?void 0:c.scheduled_tasks_enabled,l=(f=t.agent)==null?void 0:f.event_tasks_enabled;return r&&!n?(i=!0,l=!0):!r&&n&&(i=!1,l=!1),{...t,agent:{...t.agent,provider:a,model:void 0,scheduled_tasks_enabled:i,event_tasks_enabled:l}}}function Fre(e,t,n){switch(e){case"agent":return Ire(t,n);case"embedding":return{...n,embedding:{...n.embedding,provider:t.embeddingProvider,model:t.embeddingModel,base_url:t.embeddingBaseUrl!==""?t.embeddingBaseUrl:void 0}};case"context":return{...n,context:{...n.context,digest_tier:Hb(t.contextDigestTier,eD),prompt_search:t.contextPromptSearch,prompt_max_spores:Hb(t.contextMaxSpores,tD)}};case"project":return{...n,daemon:{...n.daemon,port:t.daemonPort!==""?Number(t.daemonPort):null,log_level:t.logLevel,log_retention_days:Number(t.logRetentionDays)}}}}const Ure={agent:["agentProviderType","agentModel","agentBaseUrl","agentContextLength"],embedding:["embeddingProvider","embeddingModel","embeddingBaseUrl"],context:["contextDigestTier","contextPromptSearch","contextMaxSpores"],project:["daemonPort","logLevel","logRetentionDays"]};function Iv(e,t,n){return Ure[e].some(r=>t[r]!==n[r])}function ii({children:e,hint:t}){return d.jsxs("label",{className:"font-sans text-sm font-medium text-on-surface",children:[e,t&&d.jsxs("span",{className:"ml-1 font-sans text-xs text-on-surface-variant font-normal",children:["(",t,")"]})]})}function Fv({children:e}){return d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:e})}function Uv({dirty:e,isSaving:t,showMessage:n,message:r,onSave:a}){return d.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[d.jsxs(Ae,{onClick:a,disabled:!e||t,size:"sm",children:[t?d.jsx(zn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Save"]}),n&&r&&d.jsx("span",{className:r.type==="success"?"font-sans text-xs text-primary":"font-sans text-xs text-tertiary",children:r.text})]})}function qre(){const{config:e,isLoading:t,saveConfig:n,isSaving:r}=Od(),{data:a}=Vp(),{restart:i}=V1(),{data:l,isPending:o}=s5(),c=l5(),f=j.useRef(!1),[h,p]=j.useState(null);e&&!f.current&&(f.current=!0,h===null&&p(FA(e)));const[m,y]=j.useState(null),[x,b]=j.useState("idle"),[w,S]=j.useState(""),{data:N}=_re((h==null?void 0:h.embeddingProvider)??null,(h==null?void 0:h.embeddingBaseUrl)||void 0,"embedding"),C=(N==null?void 0:N.models)??[];j.useEffect(()=>{var I,V;if(!h||h.agentProviderType===""||h.agentModel!=="")return;const U=(V=(I=l==null?void 0:l.providers.find(K=>K.type===h.agentProviderType))==null?void 0:I.models)==null?void 0:V[0];U&&p(K=>K&&{...K,agentModel:U})},[h,l]);const T=j.useMemo(()=>e?FA(e):null,[e]),R=!!(h&&T&&Iv("agent",h,T)),A=!!(h&&T&&Iv("embedding",h,T)),D=!!(h&&T&&Iv("context",h,T)),O=!!(h&&T&&Iv("project",h,T)),L=j.useCallback((U,I)=>{p(V=>V&&{...V,[U]:I}),y(null)},[]),M=j.useCallback(async U=>{if(!(!h||!e)){y(null);try{await n(Fre(U,h,e)),y({section:U,type:"success",text:"Saved. Restarting daemon..."});try{await i()}catch{y({section:U,type:"success",text:"Saved. Daemon restart may require manual action."})}}catch{y({section:U,type:"error",text:"Failed to save."})}}},[h,e,n,i]),P=j.useCallback(async()=>{if(h){b("testing"),S("");try{const U=new URLSearchParams({provider:h.embeddingProvider,type:"embedding"});h.embeddingBaseUrl&&U.set("base_url",h.embeddingBaseUrl);const V=(await lt(`/models?${U.toString()}`)).models.length;b("success"),S(`Connected -- ${V} model${V!==1?"s":""} available.`)}catch(U){b("error"),S(U instanceof Error?U.message:"Connection failed.")}}},[h]),z=j.useCallback(()=>{!h||!h.agentProviderType||c.mutate({type:h.agentProviderType,...h.agentBaseUrl?{base_url:h.agentBaseUrl}:{}})},[h,c]);if(t||!h||!e)return d.jsxs("div",{className:"p-6",children:[d.jsx(wi,{title:"Settings"}),d.jsx("p",{className:"font-sans text-sm text-on-surface-variant mt-2",children:"Loading..."})]});const H=(a==null?void 0:a.vault.name)??e.embedding.provider,$=(l==null?void 0:l.providers)??[];return d.jsxs("div",{className:"p-6",children:[d.jsx(wi,{title:"Settings",subtitle:"Vault configuration and daemon settings"}),d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:"Myco Agent"}),h.agentProviderType===""?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:"No provider configured -- data collection is active. Configure a provider to enable the intelligence pipeline."}):null,d.jsx(iS,{providerType:h.agentProviderType,model:h.agentModel,baseUrl:h.agentBaseUrl,contextLength:h.agentContextLength,providers:$,isLoadingProviders:o,onProviderChange:U=>{var V;L("agentProviderType",U);const I=$.find(K=>K.type===U);L("agentModel",((V=I==null?void 0:I.models)==null?void 0:V[0])??""),L("agentBaseUrl",(I==null?void 0:I.baseUrl)??""),L("agentContextLength",""),c.reset()},onModelChange:U=>L("agentModel",U),onBaseUrlChange:U=>{L("agentBaseUrl",U),c.reset()},onContextLengthChange:U=>L("agentContextLength",U)}),h.agentProviderType!==""&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[d.jsxs(Ae,{type:"button",variant:"ghost",size:"sm",onClick:z,disabled:c.isPending,children:[c.isPending?d.jsx(zn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Test Connection"]}),c.isSuccess&&c.data.ok&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-primary",children:[d.jsx(kb,{className:"h-4 w-4"}),"Connected — ",c.data.latency_ms,"ms"]}),c.isSuccess&&!c.data.ok&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-tertiary",children:[d.jsx(yo,{className:"h-4 w-4"}),c.data.error??"Connection failed."]}),c.isError&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-tertiary",children:[d.jsx(yo,{className:"h-4 w-4"}),c.error.message]})]}),d.jsx(Ae,{type:"button",variant:"ghost",size:"sm",onClick:()=>{L("agentProviderType",""),L("agentModel",""),L("agentBaseUrl",""),L("agentContextLength",""),c.reset()},className:"text-xs text-on-surface-variant",children:"Clear provider"})]}),d.jsx(Uv,{dirty:R,isSaving:r,showMessage:(m==null?void 0:m.section)==="agent",message:m,onSave:()=>M("agent")})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-ochre",children:[d.jsx(St,{children:"Embedding"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Provider"}),d.jsxs(hi,{value:h.embeddingProvider,onValueChange:U=>{L("embeddingProvider",U),b("idle"),S("")},children:[d.jsx(Ua,{children:d.jsx(vi,{})}),d.jsx(qa,{children:Bre.map(U=>d.jsx(Gr,{value:U.value,children:U.label},U.value))})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Model"}),C.length>0?d.jsxs(hi,{value:h.embeddingModel,onValueChange:U=>L("embeddingModel",U),children:[d.jsx(Ua,{children:d.jsx(vi,{placeholder:"Select a model"})}),d.jsx(qa,{children:C.map(U=>d.jsx(Gr,{value:U,children:d.jsx("span",{className:"font-mono text-sm",children:U})},U))})]}):d.jsx(fn,{placeholder:"bge-m3",value:h.embeddingModel,onChange:U=>L("embeddingModel",U.target.value)})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{hint:"optional",children:"Base URL"}),d.jsx(fn,{type:"url",placeholder:"http://localhost:11434",value:h.embeddingBaseUrl,onChange:U=>{L("embeddingBaseUrl",U.target.value),b("idle"),S("")}})]}),d.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[d.jsxs(Ae,{type:"button",variant:"ghost",size:"sm",onClick:P,disabled:x==="testing",children:[x==="testing"?d.jsx(zn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Test Connection"]}),x==="success"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-primary",children:[d.jsx(kb,{className:"h-4 w-4"}),w]}),x==="error"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-tertiary",children:[d.jsx(yo,{className:"h-4 w-4"}),w]})]})]}),d.jsx(Uv,{dirty:A,isSaving:r,showMessage:(m==null?void 0:m.section)==="embedding",message:m,onSave:()=>M("embedding")})]})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-ochre",children:[d.jsx(St,{children:"Context Injection"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Digest Tier"}),d.jsxs(hi,{value:h.contextDigestTier,onValueChange:U=>L("contextDigestTier",U),children:[d.jsx(Ua,{children:d.jsx(vi,{})}),d.jsx(qa,{children:zre.map(U=>d.jsx(Gr,{value:U.value,children:U.label},U.value))})]}),d.jsx(Fv,{children:"Token budget for digest context injected at session start."})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(ii,{children:"Prompt Search"}),d.jsx(Fv,{children:"Search vault for relevant observations on each prompt."})]}),d.jsx(ml,{checked:h.contextPromptSearch,onCheckedChange:U=>L("contextPromptSearch",U)})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Max Spores per Prompt"}),d.jsx(fn,{type:"number",min:"0",max:"10",placeholder:"3",value:h.contextMaxSpores,onChange:U=>L("contextMaxSpores",U.target.value)}),d.jsx(Fv,{children:"Maximum observations injected per prompt. Lower = leaner context."})]})]}),d.jsx(Uv,{dirty:D,isSaving:r,showMessage:(m==null?void 0:m.section)==="context",message:m,onSave:()=>M("context")})]}),d.jsx(Lre,{}),d.jsx(Ore,{}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:"Project"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Vault Name"}),d.jsx(fn,{value:H,readOnly:!0,disabled:!0,className:"text-on-surface-variant bg-surface-container-lowest"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Daemon Port"}),d.jsx(fn,{type:"number",placeholder:"Auto",value:h.daemonPort,onChange:U=>L("daemonPort",U.target.value)}),d.jsx(Fv,{children:"Leave blank to use a random available port."})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Log Level"}),d.jsxs(hi,{value:h.logLevel,onValueChange:U=>L("logLevel",U),children:[d.jsx(Ua,{children:d.jsx(vi,{})}),d.jsx(qa,{children:Pre.map(U=>d.jsx(Gr,{value:U,children:U},U))})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Log Retention (days)"}),d.jsx(fn,{type:"number",min:1,max:365,className:"w-24",value:h.logRetentionDays,onChange:U=>L("logRetentionDays",U.target.value)})]})]}),d.jsx(Uv,{dirty:O,isSaving:r,showMessage:(m==null?void 0:m.section)==="project",message:m,onSave:()=>M("project")})]})]})]})}function Vre(){return Qr({queryKey:["embedding-details"],queryFn:({signal:e})=>lt("/embedding/details",{signal:e}),refetchInterval:Sr.STATS,pollCategory:"standard"})}function Hre(){return Qr({queryKey:["database-details"],queryFn:({signal:e})=>lt("/database/details",{signal:e}),refetchInterval:Sr.STATS,pollCategory:"standard"})}const $re=100,UA=2e3,Gre=40;function Kre(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=Gre}function m5(e){const[t,n]=j.useState([]),[r,a]=j.useState(void 0),[i,l]=j.useState(!0),[o,c]=j.useState(!1),f=j.useRef(null),h=j.useRef(i);h.current=i;const p=j.useRef(r);p.current=r;const{data:m}=Qr({queryKey:["logs",e],queryFn:({signal:w})=>{const S=new URLSearchParams({limit:String($re),category:e});return p.current&&S.set("since",p.current),lt(`/logs?${S.toString()}`,{signal:w})},refetchInterval:Sr.LOGS,pollCategory:"standard"});j.useEffect(()=>{m!=null&&m.entries.length&&(n(w=>{let S;if(m.cursor_reset){const N=new Set(w.map(T=>`${T.timestamp}|${T.message}`)),C=m.entries.filter(T=>!N.has(`${T.timestamp}|${T.message}`));S=C.length?[...w,...C]:w}else S=[...w,...m.entries];return S.length>UA?S.slice(-UA):S}),a(m.cursor),h.current||c(!0))},[m]),j.useEffect(()=>{!i||!f.current||(f.current.scrollTop=f.current.scrollHeight,c(!1))},[t,i]);const y=j.useCallback(()=>{const w=f.current;w&&(Kre(w)?(l(!0),c(!1)):l(!1))},[]),x=j.useCallback(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight,l(!0),c(!1))},[]);return{filteredEntries:j.useMemo(()=>{const w=fp.debug;return t.filter(S=>fp[S.level]>=w)},[t]),scrollRef:f,autoScroll:i,setAutoScroll:l,hasNewEntries:o,handleScroll:y,scrollToBottom:x}}function Yre(e){return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Xre(){const[e,t]=j.useState([]),[n,r]=j.useState(!1),[a,i]=j.useState(!1),[l,o]=j.useState(null),[c,f]=j.useState(null),[h,p]=j.useState(""),[m,y]=j.useState(!1);j.useEffect(()=>{lt("/backup/config").then(C=>{p(C.dir??"")}).catch(()=>{})},[]);const x=j.useCallback(async()=>{y(!0);try{await hc("/backup/config",{dir:h||null}),o({type:"success",text:h?"Backup directory updated. Restart daemon to apply.":"Backup directory reset to default. Restart daemon to apply."})}catch{o({type:"error",text:"Failed to save backup directory."})}finally{y(!1)}},[h]),b=j.useCallback(async()=>{try{const C=await lt("/backups");t(C.backups),r(!0)}catch(C){o({type:"error",text:`Failed to load backups: ${C.message}`})}},[]);!n&&!a&&(i(!0),b().finally(()=>i(!1)));async function w(){o(null),f(null);try{const C=await nn("/backup");o({type:"success",text:`Backup created: ${C.machine_id} (${xo(C.size_bytes)})`}),await b()}catch(C){o({type:"error",text:`Backup failed: ${C.message}`})}}async function S(C){o(null),f(null);try{const T=await nn("/restore/preview",{machine_id:C});f(T)}catch(T){o({type:"error",text:`Preview failed: ${T.message}`})}}async function N(C){o(null),f(null);try{const T=await nn("/restore",{machine_id:C});o({type:"success",text:`Restored ${T.total_restored} records, skipped ${T.total_skipped} duplicates`})}catch(T){o({type:"error",text:`Restore failed: ${T.message}`})}}return d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Az,{className:"h-4 w-4 text-primary"}),d.jsx(St,{children:"Backup & Restore"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:b,children:[d.jsx(gl,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]}),d.jsxs(Ae,{variant:"default",size:"sm",onClick:w,children:[d.jsx(Sz,{className:"mr-1.5 h-3.5 w-3.5"}),"Backup Now"]})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("label",{className:"font-sans text-xs text-on-surface-variant flex items-center gap-1.5",children:[d.jsx(jz,{className:"h-3.5 w-3.5"}),"Backup Directory"]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:h,onChange:C=>p(C.target.value),placeholder:".myco/backups",className:"flex-1 bg-surface-container text-on-surface font-mono text-sm rounded px-3 py-1.5 outline-none border border-outline-variant/15 focus:border-primary/40 placeholder:text-on-surface-variant/50"}),d.jsx(Ae,{variant:"ghost",size:"sm",onClick:x,disabled:m,children:m?"Saving...":"Save"})]}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Override where backups are stored. Leave empty for default (.myco/backups). Supports ~ for home directory. Useful for network shares or git-tracked directories."})]}),l&&d.jsx("p",{className:ke("font-sans text-sm",l.type==="success"?"text-primary":"text-tertiary"),children:l.text}),e.length>0?d.jsx("div",{className:"space-y-2",children:e.map(C=>d.jsxs("div",{className:ke("flex items-center justify-between rounded-md px-4 py-3","bg-surface-container-lowest transition-colors"),children:[d.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[d.jsx("span",{className:"font-mono text-sm text-on-surface truncate",children:C.machine_id}),d.jsx(wt,{variant:"secondary",children:xo(C.size_bytes)}),d.jsx("span",{className:"text-xs text-on-surface-variant",children:Yre(C.modified_at)})]}),d.jsxs("div",{className:"flex gap-2 flex-shrink-0 ml-3",children:[d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>S(C.machine_id),children:"Preview"}),d.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>N(C.machine_id),children:[d.jsx(Kz,{className:"mr-1.5 h-3.5 w-3.5"}),"Restore"]})]})]},C.machine_id))}):n?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:'No backups yet. Click "Backup Now" to create one.'}):null,c&&d.jsxs(Ge,{level:"lowest",className:"p-4 space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(St,{children:"Restore Preview"}),d.jsx(wt,{variant:"outline",children:c.machine_id})]}),d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Restore preview",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Table"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"New"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Existing"})]})}),d.jsx("tbody",{children:c.tables.map((C,T)=>d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",T%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-2 pr-4",children:C.table}),d.jsx("td",{className:"py-2 pr-4 text-right",children:C.new>0?d.jsx("span",{className:"text-primary",children:C.new}):0}),d.jsx("td",{className:"py-2 text-right text-on-surface-variant",children:C.existing})]},C.table))})]})}),d.jsxs("div",{className:"flex gap-4 font-sans text-sm text-on-surface-variant",children:[d.jsxs("span",{children:["New: ",d.jsx("strong",{className:"text-primary",children:c.total_new})]}),d.jsxs("span",{children:["Existing: ",d.jsx("strong",{children:c.total_existing})]})]})]})]})}const qv=500,qA=6e4;function Qre(e){return e?new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"}function Wre(){const{data:e}=rD(),t=sI(),n=lI(),r=oI(),[a,i]=j.useState("idle"),[l,o]=j.useState(null);j.useEffect(()=>{if(!(e!=null&&e.restarting)||a!=="idle")return;i("restarting");const b=Date.now()+qA;let w=!1;const S=async()=>{if(!(w||Date.now()>b)){try{if((await fetch("/health")).ok){window.location.reload();return}}catch{}w||setTimeout(S,qv)}},N=setTimeout(S,qv);return()=>{w=!0,clearTimeout(N)}},[e==null?void 0:e.restarting,a]);const c=j.useCallback(async()=>{i("applying"),o(null);try{await n.mutateAsync(),i("restarting");const b=Date.now()+qA;await new Promise((w,S)=>{const N=async()=>{if(Date.now()>b){S(new Error("timeout"));return}try{if((await fetch("/health")).ok){w();return}}catch{}setTimeout(N,qv)};setTimeout(N,qv)}),window.location.reload()}catch(b){i("error");const w=b.message==="timeout"?"Daemon did not restart within the expected time. Check the terminal.":b.message;o(w)}},[n]),f=j.useCallback(()=>{t.mutate()},[t]),h=j.useCallback(b=>{r.mutate(b)},[r]);if(!e)return null;const p=t.isPending,m=a==="applying"||a==="restarting",y=e.update_available===!0,x=e.channel??"stable";return e.exempt?d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(qz,{className:"h-4 w-4 text-primary"}),d.jsx(St,{children:"Updates"})]}),d.jsxs("p",{className:"font-sans text-sm text-on-surface-variant",children:["Updates are disabled in development mode."," ",d.jsx("span",{className:"font-mono text-xs text-outline",children:e.running_version})]})]}):d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Nb,{className:ke("h-4 w-4",y?"text-secondary":"text-primary")}),d.jsx(St,{children:"Updates"})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"font-mono text-xs text-outline",children:e.running_version}),y&&e.latest_version&&d.jsx(wt,{variant:"warning",children:e.latest_version})]})]}),d.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[y?d.jsx(Ae,{variant:"default",size:"sm",onClick:c,disabled:m,children:m?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),a==="restarting"?"Restarting…":"Updating…"]}):d.jsxs(d.Fragment,{children:[d.jsx(Nb,{className:"mr-1.5 h-3.5 w-3.5"}),"Update & Restart"]})}):d.jsxs("div",{className:"flex items-center gap-1.5 text-primary",children:[d.jsx(Td,{className:"h-4 w-4"}),d.jsx("span",{className:"font-sans text-sm",children:"Up to date"})]}),d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:f,disabled:p||m,children:[d.jsx(gl,{className:ke("mr-1.5 h-3.5 w-3.5",p&&"animate-spin")}),"Check Now"]})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"flex items-center gap-1",children:iI.map(b=>d.jsx(Ae,{variant:x===b?"default":"ghost",className:"text-xs capitalize h-6 px-2",onClick:()=>h(b),disabled:r.isPending||m,children:b},b))}),d.jsxs("span",{className:"font-sans text-xs text-on-surface-variant",children:["Checked: ",Qre(e.last_check)]})]}),(a==="error"||e.error)&&d.jsxs("div",{className:"flex items-start gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),d.jsx("span",{className:"font-sans text-sm",children:l??e.error})]})]})}function Zre(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0");return n+":"+r+":"+a}function g5({entry:e}){return d.jsxs("tr",{className:"hover:bg-surface-container-high/30 transition-colors",children:[d.jsx("td",{className:"whitespace-nowrap py-1.5 pl-4 pr-3 text-on-surface-variant/60 align-top w-[68px]",children:Zre(e.timestamp)}),d.jsx("td",{className:"whitespace-nowrap py-1.5 pr-3 align-top w-[20px]",children:d.jsx("div",{className:ke("h-2 w-2 rounded-full mt-1",U1(e.level))})}),d.jsx("td",{className:"whitespace-nowrap py-1.5 pr-3 align-top w-[54px]",children:d.jsx(wt,{variant:nD(e.level),className:"px-1.5 py-0 text-[10px] uppercase",children:e.level})}),d.jsx("td",{className:"py-1.5 pr-4 text-on-surface align-top break-words",children:e.message})]})}const Jre=["sessions","spores","plans","artifacts"],eae="embedding",tae="database",nae=15,rae="insufficient_disk_space",zp=20,aae=[{id:"embedding",label:"Embedding"},{id:"database",label:"Database"},{id:"system",label:"System"}],iae=new Set(["embedding","database","system"]),y5="tab";function sae(){const t=new URLSearchParams(window.location.search).get(y5);return t&&iae.has(t)?t:"embedding"}function lae(e){const t=new URLSearchParams;e!=="embedding"&&t.set(y5,e);const n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.replaceState(null,"",r)}function oae(e){return e.provider.available?Object.values(e.pending).some(n=>n>0)?"processing":"idle":"unavailable"}function uae(e){return e.provider.available?Object.values(e.pending).some(n=>n>0)?"bg-secondary":"bg-primary":"bg-tertiary"}function cae(e){if(e<=0)return"now";const t=Math.floor(e/1e3);if(t<60)return t+"s";const n=Math.floor(t/60);return n<60?n+"m":Math.floor(n/60)+"h"}function fae({data:e}){return d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Embedding namespace breakdown",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Namespace"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Embedded"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Pending"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Stale"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Total"})]})}),d.jsx("tbody",{children:Jre.map((t,n)=>{const r=e.by_namespace[t],a=(r==null?void 0:r.embedded)??0,i=(r==null?void 0:r.stale)??0,l=e.pending[t]??0,o=a+l;return d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",n%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-2.5 pr-4",children:t}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:a}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:l>0?d.jsx("span",{className:"text-secondary",children:l}):l}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:i>0?d.jsx("span",{className:"text-tertiary",children:i}):i}),d.jsx("td",{className:"py-2.5 text-right",children:o})]},t)})})]})})}function dae({tables:e}){const t=[...e].sort((n,r)=>r.rows-n.rows);return d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Database table breakdown",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Table"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Rows"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Indexes"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Type"})]})}),d.jsx("tbody",{children:t.map((n,r)=>d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",r%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-2.5 pr-4",children:n.name}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:n.rows.toLocaleString()}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:n.index_count}),d.jsx("td",{className:"py-2.5",children:n.is_fts?d.jsx(wt,{variant:"outline",className:"px-1.5 py-0 text-[10px] uppercase",children:"FTS5"}):d.jsx("span",{className:"text-on-surface-variant/60",children:"btree"})})]},n.name))})]})})}function hae({indexes:e}){const[t,n]=j.useState(!1),r=e.filter(i=>i.type==="btree").length,a=e.filter(i=>i.type==="auto").length;return d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Indexes"}),d.jsx("button",{type:"button",onClick:()=>n(i=>!i),className:"font-sans text-xs text-on-surface-variant hover:text-on-surface transition-colors",children:t?"Hide":"Show all "+e.length})]}),d.jsxs("p",{className:"font-sans text-sm text-on-surface-variant",children:[r," btree ",r===1?"index":"indexes",a>0&&d.jsxs(d.Fragment,{children:[" · ",a," auto-",a===1?"index":"indexes"]})]}),t&&d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-xs","aria-label":"All database indexes",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"Name"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"Table"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"Type"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"SQL"})]})}),d.jsx("tbody",{children:e.map((i,l)=>d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",l%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-1.5 pr-4",children:i.name}),d.jsx("td",{className:"py-1.5 pr-4 text-on-surface-variant",children:i.table}),d.jsx("td",{className:"py-1.5 pr-4 text-on-surface-variant uppercase",children:i.type}),d.jsx("td",{className:"py-1.5 text-on-surface-variant/70 truncate max-w-[300px]",title:i.sql??"",children:i.sql??"—"})]},i.name))})]})})]})}function vae({details:e,onActionResult:t}){const{config:n,saveConfig:r,isSaving:a}=Od(),i=jn(),[l,o]=j.useState(!1);if(!n)return null;const c=n.maintenance.auto_optimize,f=n.maintenance.auto_optimize_interval_hours,h=e.last_optimize_at?new Date(e.last_optimize_at).getTime():null,p=h!==null?h+f*so*1e3-Date.now():0;async function m(x){try{await r({...n,maintenance:{...n.maintenance,...x}})}catch(b){t({type:"error",text:"Config save failed: "+b.message})}}async function y(){o(!0);try{const x=await nn("/database/optimize"),b=x.actions_failed.length;t({type:b>0?"error":"success",text:"Optimize complete: "+x.actions_completed.length+" steps, "+b+" failed ("+x.duration_ms+"ms)"}),i.invalidateQueries({queryKey:["database-details"]})}catch(x){t({type:"error",text:"Error: "+x.message})}finally{o(!1)}}return d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsx(St,{children:"Scheduled Maintenance"}),d.jsxs("div",{className:"flex flex-wrap items-center gap-3 font-sans text-sm",children:[d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:c,disabled:a,onChange:x=>m({auto_optimize:x.target.checked}),className:"h-4 w-4 accent-primary"}),d.jsx("span",{className:"text-on-surface",children:"Auto-optimize"})]}),d.jsx("span",{className:"text-on-surface-variant",children:"every"}),d.jsxs("select",{value:f,disabled:!c||a,onChange:x=>m({auto_optimize_interval_hours:Number(x.target.value)}),className:"rounded-md border border-outline bg-surface-container px-2 py-1 text-on-surface text-sm",children:[d.jsx("option",{value:6,children:"6 hours"}),d.jsx("option",{value:12,children:"12 hours"}),d.jsx("option",{value:24,children:"24 hours"}),d.jsx("option",{value:72,children:"3 days"}),d.jsx("option",{value:168,children:"7 days"}),d.jsx("option",{value:720,children:"30 days"})]})]}),d.jsxs("p",{className:"font-sans text-sm text-on-surface-variant",children:["Last run: ",e.last_optimize_at?nm(e.last_optimize_at):"never",c&&h!==null&&d.jsxs(d.Fragment,{children:[" · Next: ",cae(p)]})]}),d.jsxs(Ae,{variant:"secondary",size:"sm",onClick:y,disabled:l,children:[d.jsx(rs,{className:"mr-2 h-4 w-4"}),l?"Running...":"Run now"]})]})}function pae({onActionResult:e}){const t=jn(),[n,r]=j.useState(!1);async function a(){r(!0);try{const o=await nn("/database/integrity-check");o.status==="ok"?e({type:"success",text:"Integrity check OK ("+o.duration_ms+"ms)"}):e({type:"error",text:"Integrity issues: "+o.issues.length+" problems, "+o.fk_violations+" FK violations"}),t.invalidateQueries({queryKey:["database-details"]})}catch(o){e({type:"error",text:"Error: "+o.message})}finally{r(!1)}}async function i(){if(confirm("VACUUM rebuilds the entire DB file and may take a while. Continue?")){r(!0);try{const o=await nn("/database/vacuum");e({type:"success",text:"Vacuum complete: freed "+xo(o.freed_bytes)+" in "+o.duration_ms+"ms"}),t.invalidateQueries({queryKey:["database-details"]})}catch(o){if(o instanceof JR){const c=o.body;if((c==null?void 0:c.error)===rae){e({type:"error",text:"Insufficient disk: need "+xo(c.required_bytes??0)+", have "+xo(c.free_bytes??0)});return}}e({type:"error",text:"Error: "+o.message})}finally{r(!1)}}}async function l(){if(confirm("REINDEX rebuilds all indexes. Continue?")){r(!0);try{const o=await nn("/database/reindex");e({type:"success",text:"Reindex complete ("+o.duration_ms+"ms)"}),t.invalidateQueries({queryKey:["database-details"]})}catch(o){e({type:"error",text:"Error: "+o.message})}finally{r(!1)}}}return d.jsxs(Ge,{level:"low",className:"p-6 space-y-3",children:[d.jsx(St,{children:"Actions"}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:a,disabled:n,children:[d.jsx(gl,{className:"mr-2 h-4 w-4"}),"Integrity check"]}),d.jsxs(Ae,{variant:"destructive",size:"sm",onClick:i,disabled:n,children:[d.jsx(as,{className:"mr-2 h-4 w-4"}),"Vacuum"]}),d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:l,disabled:n,children:[d.jsx(qp,{className:"mr-2 h-4 w-4"}),"Reindex"]})]})]})}function mae({data:e}){const t=jn(),[n,r]=j.useState(null),[a,i]=j.useState([]);j.useEffect(()=>{i(C=>{const T=[...C,e.total];return T.length>zp?T.slice(-zp):T})},[e]);const{filteredEntries:l,scrollRef:o,autoScroll:c,setAutoScroll:f,hasNewEntries:h,handleScroll:p,scrollToBottom:m}=m5(eae);async function y(){r(null);try{const C=await nn("/embedding/reembed-stale");r({type:"success",text:`Re-embedded ${C.reembedded} stale vectors`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}async function x(){if(confirm("This will re-embed all vectors. Continue?")){r(null);try{const C=await nn("/embedding/rebuild");r({type:"success",text:`Rebuild queued: ${C.queued} vectors to re-embed`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}}async function b(){r(null);try{const C=await nn("/embedding/clean-orphans");r({type:"success",text:`Cleaned ${C.orphans_cleaned} orphan vectors`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}async function w(){r(null);try{const C=await nn("/embedding/reconcile");r({type:"success",text:`Reconcile complete: ${C.embedded} embedded, ${C.orphans_cleaned} orphans cleaned (${C.duration_ms}ms)`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}const S=Object.values(e.pending).reduce((C,T)=>C+T,0),N=Object.values(e.by_namespace).reduce((C,T)=>C+T.stale,0);return d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-4 font-sans text-sm",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(P1,{className:"h-4 w-4 text-primary"}),d.jsx("span",{className:"text-on-surface-variant",children:"Provider"}),d.jsx("span",{className:"font-mono text-on-surface",children:e.provider.name})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-on-surface-variant",children:"Model"}),d.jsx("span",{className:"font-mono text-xs text-on-surface truncate max-w-[200px]",title:e.provider.model,children:e.provider.model})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:ke("h-2 w-2 rounded-full",uae(e))}),d.jsx("span",{className:"text-on-surface-variant capitalize",children:oae(e)})]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[d.jsx(Kt,{label:"Total Vectors",value:String(e.total),sparklineData:a,accent:"sage"}),d.jsx(Kt,{label:"Pending",value:String(S),accent:S>0?"ochre":"outline"}),d.jsx(Kt,{label:"Stale",value:String(N),accent:N>0?"terracotta":"outline"})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsx(St,{children:"Namespace Breakdown"}),d.jsx(fae,{data:e})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-3",children:[d.jsx(St,{children:"Actions"}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:y,children:[d.jsx(gl,{className:"mr-2 h-4 w-4"}),"Re-embed stale"]}),d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:b,children:[d.jsx(as,{className:"mr-2 h-4 w-4"}),"Clean orphans"]}),d.jsxs(Ae,{variant:"secondary",size:"sm",onClick:w,children:[d.jsx(rs,{className:"mr-2 h-4 w-4"}),"Force reconcile"]}),d.jsxs(Ae,{variant:"destructive",size:"sm",onClick:x,children:[d.jsx(qp,{className:"mr-2 h-4 w-4"}),"Rebuild all"]})]}),n&&d.jsx("p",{className:ke("font-sans text-sm",n.type==="success"?"text-primary":"text-tertiary"),children:n.text})]}),d.jsxs(Ge,{level:"low",className:"flex flex-col overflow-hidden",children:[d.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[d.jsx(St,{children:"Activity Log"}),d.jsxs(Ae,{size:"sm",variant:c?"default":"ghost",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>{c?f(!1):m()},title:c?"Pause auto-scroll":"Resume auto-scroll",children:[c?d.jsx(B1,{className:"h-3 w-3"}):d.jsx(rs,{className:"h-3 w-3"}),c?"Pause":"Resume"]})]}),d.jsxs("div",{className:"relative flex-1 p-0",children:[d.jsx("div",{ref:o,onScroll:p,className:"h-64 overflow-y-auto font-mono text-xs bg-surface-container-lowest",children:l.length===0?d.jsx("div",{className:"flex h-32 items-center justify-center font-sans text-on-surface-variant",children:"No embedding log entries"}):d.jsx("table",{className:"w-full border-collapse","aria-label":"Embedding activity log",children:d.jsx("tbody",{children:l.map((C,T)=>d.jsx(g5,{entry:C},`${C.timestamp}-${T}`))})})}),h&&!c&&d.jsxs("button",{type:"button",onClick:m,className:ke("absolute bottom-4 left-1/2 -translate-x-1/2","flex items-center gap-1.5 rounded-full","bg-surface-container-high px-3 py-1.5 text-xs font-medium shadow-ambient","text-on-surface-variant transition-colors hover:text-on-surface"),children:[d.jsx(HR,{className:"h-3 w-3"}),"New entries below"]})]})]})]})}function gae(){return d.jsxs("div",{className:"space-y-6",children:[d.jsx(Wre,{}),d.jsx(Xre,{})]})}function yae(){const{data:e,isLoading:t,isError:n,error:r}=Hre(),[a,i]=j.useState([]),[l,o]=j.useState(null);j.useEffect(()=>{e&&i(S=>{const N=[...S,e.file.size_bytes];return N.length>zp?N.slice(-zp):N})},[e]);const{filteredEntries:c,scrollRef:f,autoScroll:h,setAutoScroll:p,hasNewEntries:m,handleScroll:y,scrollToBottom:x}=m5(tae);if(t)return d.jsx("div",{className:"text-on-surface-variant",children:"Loading database details..."});if(n)return d.jsxs("div",{className:"text-tertiary",children:["Error: ",r.message]});if(!e)return null;const b=e.file.fragmentation_pct.toFixed(1)+"%",w=e.file.fragmentation_pct>nae?"ochre":"outline";return d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-4 font-sans text-sm",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(wz,{className:"h-4 w-4 text-primary"}),d.jsx("span",{className:"text-on-surface-variant",children:"Database"}),d.jsx("span",{className:"font-mono text-on-surface",children:"myco.db"})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-on-surface-variant",children:"Schema"}),d.jsxs("span",{className:"font-mono text-on-surface",children:["v",e.schema.version]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-on-surface-variant",children:"Journal"}),d.jsx("span",{className:"font-mono text-on-surface uppercase",children:e.schema.journal_mode})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"}),d.jsx("span",{className:"text-on-surface-variant",children:"healthy"})]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[d.jsx(Kt,{label:"Database Size",value:xo(e.file.size_bytes),sparklineData:a,accent:"sage"}),d.jsx(Kt,{label:"Fragmentation",value:b,accent:w}),d.jsx(Kt,{label:"WAL Size",value:xo(e.file.wal_size_bytes),accent:"outline"})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsx(St,{children:"Schema Breakdown"}),d.jsx(dae,{tables:e.tables})]}),d.jsx(hae,{indexes:e.indexes}),d.jsx(vae,{details:e,onActionResult:o}),d.jsx(pae,{onActionResult:o}),l&&d.jsx("p",{className:ke("font-sans text-sm",l.type==="success"?"text-primary":"text-tertiary"),children:l.text}),d.jsxs(Ge,{level:"low",className:"flex flex-col overflow-hidden",children:[d.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[d.jsx(St,{children:"Activity Log"}),d.jsxs(Ae,{size:"sm",variant:h?"default":"ghost",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>{h?p(!1):x()},title:h?"Pause auto-scroll":"Resume auto-scroll",children:[h?d.jsx(B1,{className:"h-3 w-3"}):d.jsx(rs,{className:"h-3 w-3"}),h?"Pause":"Resume"]})]}),d.jsxs("div",{className:"relative flex-1 p-0",children:[d.jsx("div",{ref:f,onScroll:y,className:"h-64 overflow-y-auto font-mono text-xs bg-surface-container-lowest",children:c.length===0?d.jsx("div",{className:"flex h-32 items-center justify-center font-sans text-on-surface-variant",children:"No database log entries"}):d.jsx("table",{className:"w-full border-collapse","aria-label":"Database activity log",children:d.jsx("tbody",{children:c.map((S,N)=>d.jsx(g5,{entry:S},S.timestamp+"-"+N))})})}),m&&!h&&d.jsxs("button",{type:"button",onClick:x,className:ke("absolute bottom-4 left-1/2 -translate-x-1/2","flex items-center gap-1.5 rounded-full","bg-surface-container-high px-3 py-1.5 text-xs font-medium shadow-ambient","text-on-surface-variant transition-colors hover:text-on-surface"),children:[d.jsx(HR,{className:"h-3 w-3"}),"New entries below"]})]})]})]})}const xae={embedding:"Embedding health, maintenance actions, and activity log",database:"Schema inspection, maintenance actions, and scheduled optimization",system:"Software updates and backup management"};function bae(){const{data:e,isLoading:t,isError:n,error:r}=Vre(),[a,i]=j.useState(sae),l=j.useCallback(o=>{const c=o;i(c),lae(c)},[]);return d.jsx(gw,{isLoading:t,error:n?r instanceof Error?r:new Error("Unable to reach daemon"):null,loadingText:"Loading operations...",children:e&&d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsx("div",{className:"px-6 pt-6",children:d.jsx(wi,{title:"Operations",subtitle:xae[a],tabs:aae,activeTab:a,onTabChange:l})}),d.jsx("div",{className:"flex-1 overflow-auto",children:d.jsxs("div",{className:"px-6 pb-6",children:[a==="embedding"&&d.jsx(mae,{data:e}),a==="database"&&d.jsx(yae,{}),a==="system"&&d.jsx(gae,{})]})})]})})}function wae(){return Qr({queryKey:["team-status"],queryFn:({signal:e})=>lt("/team/status",{signal:e}),refetchInterval:Sr.STATS,pollCategory:"standard"})}function Vv({label:e,value:t,mono:n=!0}){const[r,a]=j.useState(!1),i=j.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)})},[t]);return d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{className:"text-xs text-on-surface-variant",children:e}),d.jsxs("div",{className:"flex items-center gap-2 group",children:[d.jsx("span",{className:`text-sm text-on-surface break-all ${n?"font-mono":""}`,children:t}),d.jsx("button",{type:"button",onClick:i,className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy to clipboard",children:r?d.jsx(kd,{className:"h-3.5 w-3.5 text-primary"}):d.jsx(L1,{className:"h-3.5 w-3.5"})})]})]})}function VA({label:e,value:t}){const[n,r]=j.useState(!1),[a,i]=j.useState(!1),l=j.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)})},[t]),o=`${t.slice(0,8)}${"*".repeat(Math.max(0,t.length-12))}${t.slice(-4)}`;return d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{className:"text-xs text-on-surface-variant",children:e}),d.jsxs("div",{className:"flex items-center gap-2 group",children:[d.jsx("span",{className:"text-sm text-on-surface font-mono break-all",children:n?t:o}),d.jsx("button",{type:"button",onClick:()=>r(!n),className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface transition-opacity",title:n?"Hide":"Reveal",children:n?d.jsx(Ez,{className:"h-3.5 w-3.5"}):d.jsx(Cz,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button",onClick:l,className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy to clipboard",children:a?d.jsx(kd,{className:"h-3.5 w-3.5 text-primary"}):d.jsx(L1,{className:"h-3.5 w-3.5"})})]})]})}function Sae({onConnected:e}){const[t,n]=j.useState(""),[r,a]=j.useState(""),[i,l]=j.useState(null),[o,c]=j.useState(!1),f=async h=>{h.preventDefault(),l(null),c(!0);try{await nn("/team/connect",{url:t,api_key:r}),e()}catch(p){l(p instanceof Error?p.message:"Connection failed")}finally{c(!1)}};return d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-6",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[d.jsx(Xz,{className:"h-4 w-4 text-on-surface-variant"}),d.jsx(St,{children:"Connect to team"})]}),d.jsx("p",{className:"text-sm text-on-surface-variant mb-4",children:"Enter the URL and API key for your team's Cloudflare Worker to enable cross-machine knowledge sharing."}),d.jsxs("form",{onSubmit:f,className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-medium text-on-surface-variant mb-1",children:"Worker URL"}),d.jsx(fn,{type:"url",placeholder:"https://myco-team.your-account.workers.dev",value:t,onChange:h=>n(h.target.value),required:!0})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-medium text-on-surface-variant mb-1",children:"API Key"}),d.jsx(fn,{type:"password",placeholder:"your-api-key",value:r,onChange:h=>a(h.target.value),required:!0})]}),i&&d.jsx("p",{className:"text-sm text-tertiary",children:i}),d.jsx(Ae,{type:"submit",size:"sm",disabled:o||!t||!r,children:o?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Connecting..."]}):"Connect"})]})]})}function Eae({status:e}){const t=jn(),[n,r]=j.useState(!1),[a,i]=j.useState(!1),[l,o]=j.useState(null),[c,f]=j.useState(!1),[h,p]=j.useState(null),[m,y]=j.useState(!1),[x,b]=j.useState(null),[w,S]=j.useState(!1),[N,C]=j.useState(!1),[T,R]=j.useState(!1),A=async()=>{r(!0);try{await nn("/team/disconnect"),t.invalidateQueries({queryKey:["team-status"]})}finally{r(!1)}},D=j.useCallback(async()=>{i(!0),o(null);try{const M=await nn("/team/backfill");o(M.enqueued>0?`Enqueued ${M.enqueued} records for sync. They'll push on the next flush cycle.`:"All records are already synced or enqueued."),t.invalidateQueries({queryKey:["team-status"]})}catch{o("Backfill failed.")}finally{i(!1)}},[t]),O=j.useCallback(async()=>{f(!0),p(null);try{const M=await nn("/team/upgrade-worker");M.success?(p(`Worker updated to v${M.version}`),t.invalidateQueries({queryKey:["team-status"]})):p(M.error??"Upgrade failed")}catch(M){p(M instanceof Error?M.message:"Upgrade failed")}finally{f(!1)}},[t]),L=j.useCallback(async()=>{y(!0),b(null);try{const M=await nn("/team/retry-failed");b(M.retried>0?`Re-queued ${M.retried} record${M.retried>1?"s":""} for sync.`:"No failed records to retry."),t.invalidateQueries({queryKey:["team-status"]})}catch{b("Retry failed.")}finally{y(!1)}},[t]);return d.jsxs("div",{className:"space-y-4",children:[e.worker_update_available&&d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-4 border-l-2 border-l-ochre",children:[d.jsxs("div",{className:"flex items-center justify-between gap-4",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Nb,{className:"h-5 w-5 text-ochre flex-shrink-0"}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface",children:"Worker update available"}),d.jsxs("p",{className:"text-xs text-on-surface-variant",children:["Deployed: v",e.deployed_worker_version??"?"," — Local: v",e.package_version]})]})]}),d.jsx(Ae,{variant:"default",size:"sm",onClick:O,disabled:c,children:c?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Deploying..."]}):"Update Worker"})]}),h&&d.jsx("p",{className:"text-xs text-on-surface-variant mt-2",children:h})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[d.jsx(Kt,{label:"Status",value:e.healthy?"Connected":"Unhealthy",accent:e.healthy?"sage":"terracotta"}),d.jsx(Kt,{label:"Pending sync",value:String(e.pending_sync_count),accent:e.dead_letter_count>0?"terracotta":"outline",sublabel:e.dead_letter_count>0?`${e.dead_letter_count} failed`:void 0,href:"/logs?component=team-sync"}),d.jsx(Kt,{label:"Protocol",value:`v${e.sync_protocol_version}`,accent:"outline"}),d.jsx(Kt,{label:"Schema",value:`v${e.schema_version}`,accent:"outline"})]}),d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Team Credentials"}),d.jsx(wt,{variant:e.healthy?"default":"destructive",children:e.healthy?"healthy":"unhealthy"})]}),d.jsx("p",{className:"text-xs text-on-surface-variant",children:"Share these with teammates so they can connect from the Team page."}),d.jsxs("div",{className:"space-y-3",children:[e.worker_url&&d.jsx(Vv,{label:"Worker URL",value:e.worker_url}),e.api_key&&d.jsx(VA,{label:"API Key",value:e.api_key})]})]}),e.mcp_token&&e.mcp_endpoint&&d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Cloud MCP Endpoint"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>S(!w),className:"text-xs text-on-surface-variant hover:text-on-surface transition-colors",children:w?"Hide snippet":"Config snippet"}),d.jsx("button",{onClick:()=>C(!0),className:"text-xs text-on-surface-variant hover:text-terracotta-text transition-colors",children:"Rotate token"})]})]}),d.jsx("p",{className:"text-xs text-on-surface-variant",children:"Configure cloud agents with this endpoint to access project team intelligence."}),d.jsxs("div",{className:"space-y-3",children:[d.jsx(Vv,{label:"MCP URL",value:e.mcp_endpoint}),d.jsx(VA,{label:"MCP Access Token",value:e.mcp_token})]}),w&&(()=>{const M=JSON.stringify({mcp_servers:[{type:"url",url:e.mcp_endpoint,name:"myco",authorization_token:e.mcp_token}]},null,2);return d.jsxs("div",{className:"relative",children:[d.jsx("pre",{className:"text-xs bg-surface-container p-3 rounded-lg overflow-x-auto text-on-surface-variant",children:M}),d.jsx("button",{onClick:()=>navigator.clipboard.writeText(M),className:"absolute top-2 right-2 p-1 rounded hover:bg-surface-container-high transition-colors",children:d.jsx(L1,{className:"h-3.5 w-3.5 text-on-surface-variant"})})]})})()]}),d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[d.jsx(St,{children:"This Node"}),d.jsxs("div",{className:"grid gap-3",children:[d.jsx(Vv,{label:"Machine ID",value:e.machine_id}),d.jsx(Vv,{label:"Package Version",value:e.package_version})]}),e.health_error&&d.jsx("p",{className:"text-sm text-tertiary mt-2",children:e.health_error})]}),d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Sync"}),d.jsx(Ae,{variant:"default",size:"sm",onClick:D,disabled:a,children:a?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Syncing..."]}):"Sync All"})]}),d.jsx("p",{className:"text-xs text-on-surface-variant",children:"Push all unsynced local knowledge to the team store. Records sync automatically on new writes, but historical data needs a one-time backfill."}),l&&d.jsx("p",{className:"text-sm text-primary",children:l}),e.dead_letter_count>0&&d.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-outline-variant/10",children:[d.jsxs("p",{className:"text-xs text-on-surface-variant",children:[d.jsxs("span",{className:"text-tertiary font-medium",children:[e.dead_letter_count," failed"]})," record",e.dead_letter_count>1?"s":""," — exceeded max retries."," ",d.jsx("a",{href:"/logs?component=team-sync&level=error",className:"underline hover:text-on-surface",children:"View logs"})]}),d.jsx(Ae,{variant:"outline",size:"sm",onClick:L,disabled:m,children:m?"Retrying...":"Retry Failed"})]}),x&&d.jsx("p",{className:"text-xs text-primary",children:x})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(Ae,{variant:"outline",size:"sm",onClick:A,disabled:n,children:n?"Disconnecting...":"Disconnect"})}),d.jsx(im,{open:N,onOpenChange:C,title:"Rotate MCP Access Token",description:"This will invalidate the current MCP token. Any cloud agents using it will lose access until reconfigured with the new token.",confirmLabel:"Rotate Token",variant:"destructive",isPending:T,onConfirm:async()=>{R(!0);try{await nn("/team/rotate-mcp-token"),t.invalidateQueries({queryKey:["team-status"]}),C(!1)}catch{}finally{R(!1)}}})]})}function Cae(){const{data:e,isLoading:t}=wae(),n=jn();if(t)return d.jsx(gw,{isLoading:!0,error:null,children:d.jsx("span",{})});const r=(e==null?void 0:e.enabled)&&(e==null?void 0:e.worker_url);return d.jsxs("div",{className:"p-6 max-w-4xl",children:[d.jsx(wi,{title:"Team",subtitle:"Share knowledge across machines with team sync"}),r&&e?d.jsx(Eae,{status:e}):d.jsxs("div",{className:"space-y-4",children:[d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-6 space-y-4",children:[d.jsx(St,{children:"Getting Started"}),d.jsx("p",{className:"text-sm text-on-surface-variant",children:"Team sync lets multiple machines share captured knowledge through a Cloudflare Worker. One team member provisions the infrastructure, then shares the connection details."}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"1. Install Wrangler"}),d.jsx("code",{className:"block font-mono text-xs bg-surface-container rounded px-3 py-2 text-on-surface-variant",children:"npm install -g wrangler && wrangler login"})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"2. Provision the team"}),d.jsx("code",{className:"block font-mono text-xs bg-surface-container rounded px-3 py-2 text-on-surface-variant",children:"myco team init"}),d.jsx("p",{className:"text-xs text-on-surface-variant mt-1",children:"Creates a D1 database, Vectorize index, and deploys the sync worker. Outputs a Worker URL and API key to share with teammates."})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"3. Connect"}),d.jsxs("p",{className:"text-xs text-on-surface-variant",children:["Paste the Worker URL and API key below, or if you ran ",d.jsx("code",{className:"font-mono",children:"myco team init"}),", you're already connected."]})]})]})]}),d.jsx(Sae,{onConnected:()=>n.invalidateQueries({queryKey:["team-status"]})})]})]})}const Nae=[{value:"15m",label:"15m"},{value:"1h",label:"1h"},{value:"6h",label:"6h"},{value:"24h",label:"24h"},{value:"7d",label:"7d"},{value:"30d",label:"30d"}];function kae({mode:e,onModeChange:t,searchValue:n,onSearchChange:r,onSearchSubmit:a,activeLevel:i,onLevelChange:l,components:o,activeComponents:c,onComponentToggle:f,onComponentsClear:h,timeRange:p,onTimeRangeChange:m,totalResults:y,paused:x=!1,onPausedToggle:b}){return d.jsxs(Ge,{level:"default",className:"rounded-md p-3 space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"flex items-center rounded-md bg-surface-container-low",children:[d.jsxs(Ae,{size:"sm",variant:e==="live"?"default":"ghost",className:"h-7 gap-1.5 px-2.5 text-xs rounded-r-none",onClick:()=>t("live"),children:[d.jsx(XR,{className:"h-3 w-3"}),"Live"]}),d.jsxs(Ae,{size:"sm",variant:e==="search"?"default":"ghost",className:"h-7 gap-1.5 px-2.5 text-xs rounded-l-none",onClick:()=>t("search"),children:[d.jsx(dc,{className:"h-3 w-3"}),"Search"]})]}),e==="live"&&b&&d.jsxs(Ae,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 px-2.5 text-xs",onClick:b,"aria-label":x?"Resume log stream":"Pause log stream",title:x?"Resume":"Pause",children:[x?d.jsx(rs,{className:"h-3 w-3"}):d.jsx(B1,{className:"h-3 w-3"}),x?"Resume":"Pause"]}),e==="search"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"h-5 w-px bg-outline-variant/30"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(GR,{className:"h-3 w-3 text-on-surface-variant/50"}),Nae.map(w=>d.jsx(Ae,{size:"sm",variant:p===w.value?"default":"ghost",className:"h-6 px-1.5 text-[10px]",onClick:()=>m(w.value),children:w.label},w.value))]})]}),d.jsx("form",{className:"ml-auto flex items-center gap-1.5",onSubmit:w=>{w.preventDefault(),a()},children:d.jsx(fn,{className:"h-7 w-56 text-xs",placeholder:e==="search"?"Search logs...":"Filter messages...",value:n,onChange:w=>r(w.target.value),"aria-label":"Search log messages"})}),e==="search"&&y!==void 0&&d.jsxs("span",{className:"text-[10px] font-mono text-on-surface-variant/50 tabular-nums whitespace-nowrap",children:[y.toLocaleString()," results"]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"flex items-center gap-1",children:rI.map(w=>d.jsxs(Ae,{size:"sm",variant:i===w?"default":"ghost",className:"h-6 px-2 text-[10px] capitalize gap-1.5",onClick:()=>l(w),children:[d.jsx("div",{className:ke("h-1.5 w-1.5 rounded-full",U1(w))}),w]},w))}),o.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"h-4 w-px bg-outline-variant/20"}),d.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[o.map(w=>d.jsx(Ae,{size:"sm",variant:c.has(w)?"default":"ghost",className:"h-5 px-1.5 text-[10px]",onClick:()=>f(w),children:w},w)),c.size>0&&d.jsx(Ae,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-[10px] text-on-surface-variant",onClick:h,children:"clear"})]})]})]})]})}const Tae={debug:"border-l-outline/30",info:"border-l-primary/50",warn:"border-l-secondary/70",error:"border-l-tertiary/80"},jae={context:"text-primary/70",hooks:"text-on-surface-variant/70",agent:"text-secondary/80",daemon:"text-on-surface-variant/60",capture:"text-primary/60",processor:"text-on-surface-variant/70",lifecycle:"text-primary/50",embedding:"text-on-surface-variant/60",power:"text-on-surface-variant/50",server:"text-on-surface-variant/60"};function Aae(e,t){if(t)return nm(e);const n=new Date(e),r=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),i=String(n.getSeconds()).padStart(2,"0");return`${r}:${a}:${i}`}const Rae=40,Dae=60;function Xs(e){return typeof e=="string"&&e.length>0?e:null}const Mae=[{pick:e=>Xs(e.tool_name)},{pick:e=>Xs(e.type)},{pick:e=>Xs(e.agent_type)},{pick:e=>Xs(e.task_subject),format:e=>yp(e,Rae)},{pick:e=>Xs(e.filename)},{pick:e=>Xs(e.source_path)??Xs(e.path),format:q7},{pick:e=>Xs(e.error),format:e=>yp(e,Dae)},{pick:e=>typeof e.pid=="number"?`pid ${e.pid}`:null}];function _ae(e){if(!e)return"";for(const{pick:t,format:n}of Mae){const r=t(e);if(r)return n?n(r):r}return""}function Oae({entries:e,selectedId:t,onSelect:n,autoScroll:r=!1,relativeTime:a=!1,compact:i=!0}){const l=j.useRef(null);return j.useEffect(()=>{!r||!l.current||(l.current.scrollTop=l.current.scrollHeight)},[e,r]),d.jsx("div",{ref:l,className:"flex-1 overflow-y-auto bg-surface-container-lowest font-mono text-xs",children:e.length===0?d.jsx("div",{className:"flex h-full min-h-[200px] items-center justify-center text-on-surface-variant/50 font-sans text-sm",children:"No log entries"}):d.jsxs("table",{className:"w-full border-collapse","aria-label":"Log entries",children:[d.jsx("thead",{className:"sticky top-0 z-10 bg-surface-container-lowest/95 backdrop-blur supports-[backdrop-filter]:bg-surface-container-lowest/80",children:d.jsxs("tr",{className:"border-b border-outline-variant/10 text-[10px] uppercase tracking-[0.16em] text-on-surface-variant/50",children:[d.jsx("th",{className:"w-[68px] px-3 py-2 text-left font-medium",children:"Time"}),d.jsx("th",{className:"w-[12px] px-0 py-2","aria-hidden":"true"}),d.jsx("th",{className:"w-[48px] px-0 py-2 text-left font-medium",children:"Level"}),d.jsx("th",{className:"w-[90px] px-0 py-2 text-left font-medium",children:"Area"}),d.jsx("th",{className:"w-[72px] px-0 py-2 text-left font-medium",children:"Session"}),d.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Message"})]})}),d.jsx("tbody",{children:e.map(o=>d.jsx(Lae,{entry:o,selected:o.id===t,onSelect:n,relativeTime:a,compact:i},o.id))})]})})}const Lae=j.memo(function({entry:t,selected:n,onSelect:r,relativeTime:a,compact:i}){const l=i?"py-0.5":"py-1.5",o=hl(t.session_id),c=_ae(t.data);return d.jsxs("tr",{className:ke("cursor-pointer transition-colors border-l-2",Tae[t.level],n?"bg-primary/10":"hover:bg-surface-container-high/30"),onClick:()=>r(t),children:[d.jsx("td",{className:ke("whitespace-nowrap pl-3 pr-2 text-on-surface-variant/50 align-top w-[68px] tabular-nums",l),children:Aae(t.timestamp,a)}),d.jsx("td",{className:ke("whitespace-nowrap pr-1 align-top w-[12px]",l),children:d.jsx("div",{className:ke("h-1.5 w-1.5 rounded-full mt-1",U1(t.level))})}),d.jsx("td",{className:ke("whitespace-nowrap pr-2 align-top w-[48px]",l),children:d.jsx(wt,{variant:nD(t.level),className:"px-1 py-0 text-[9px] uppercase",children:t.level})}),d.jsx("td",{className:ke("whitespace-nowrap pr-2 align-top w-[90px] truncate max-w-[90px]",l,jae[t.component]??"text-on-surface-variant/60"),children:t.component}),d.jsx("td",{className:ke("whitespace-nowrap pr-2 align-top w-[72px] tabular-nums text-on-surface-variant/40",l),title:t.session_id??"",children:o}),d.jsxs("td",{className:ke("pr-3 text-on-surface align-top break-words",l),children:[d.jsx("span",{children:t.message}),c&&d.jsxs("span",{className:"ml-2 text-on-surface-variant/50",children:["· ",c]})]})]})});function Pae({value:e}){const t=String(e),n=t.slice(0,8);return d.jsxs(Ma,{to:`/sessions/${t}`,className:"font-mono text-primary hover:underline",children:[n,"..."]})}function Bae({value:e}){return Array.isArray(e)?d.jsx("span",{className:"flex flex-wrap gap-1",children:e.map((t,n)=>d.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:String(t)},n))}):d.jsx("span",{children:String(e)})}function zae({value:e}){return Array.isArray(e)?d.jsx("span",{className:"flex gap-1",children:e.map((t,n)=>d.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0 tabular-nums",children:String(t)},n))}):d.jsx("span",{children:String(e)})}function Iae({value:e}){return d.jsx("span",{className:"rounded bg-tertiary/10 px-2 py-0.5 text-tertiary font-mono text-[11px]",children:String(e)})}function HA({value:e}){return d.jsx("pre",{className:"max-h-32 overflow-auto rounded bg-surface-container-lowest px-2 py-1 text-[11px] font-mono text-on-surface-variant whitespace-pre-wrap",children:String(e)})}function Fae({value:e}){const t=new Date(String(e)),r=new Date().getTime()-t.getTime(),a=Math.floor(r/6e4),i=Math.floor(a/60),l=Math.floor(i/24);let o;return a<1?o="just now":a<60?o=`${a}m ago`:i<24?o=`${i}h ago`:o=`${l}d ago`,d.jsx("span",{className:"tabular-nums",title:t.toISOString(),children:o})}function Uae({value:e}){return typeof e=="object"&&e!==null?d.jsx("pre",{className:"text-[11px] font-mono text-on-surface-variant whitespace-pre-wrap",children:JSON.stringify(e,null,2)}):d.jsx("span",{children:String(e)})}const qae={session_id:Pae,spore_titles:Bae,scores:zae,error:Iae,preview:HA,generated_at:Fae,text:HA},Vae=new Set(["id","timestamp","level","kind","component","message"]);function $A(e,t){const n=qae[e]??Uae;return d.jsx(n,{value:t})}function Hae(e){return Vae.has(e)}function $ae(e){return e?Object.entries(e).filter(([t])=>!Hae(t)):[]}const Gae={debug:"text-on-surface-variant/60",info:"text-primary",warn:"text-secondary",error:"text-tertiary"};function Kae({entry:e,resolved:t,onClose:n}){const r=$ae(e.data);return d.jsxs("div",{className:"flex h-full flex-col bg-surface-container-low",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/10",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.kind}),d.jsx("span",{className:ke("text-xs font-medium",Gae[e.level]),children:e.level.toUpperCase()})]}),d.jsx(Ae,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:n,"aria-label":"Close detail panel",children:d.jsx(is,{className:"h-3.5 w-3.5"})})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-4",children:[d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Timestamp"}),d.jsx("div",{className:"font-mono text-xs tabular-nums",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Message"}),d.jsx("div",{className:"text-sm text-on-surface leading-relaxed",children:e.message})]}),e.session_id&&d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Session"}),d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[$A("session_id",e.session_id),!!(t!=null&&t.session_title)&&d.jsx("span",{className:"text-on-surface-variant/70",children:String(t.session_title)})]})]}),r.length>0&&d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-1.5",children:"Metadata"}),d.jsx("div",{className:"space-y-2",children:r.map(([a,i])=>d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] text-on-surface-variant/40 mb-0.5",children:a}),d.jsx("div",{className:"text-xs",children:$A(a,i)})]},a))})]})]}),d.jsx("div",{className:"px-4 py-2 border-t border-outline-variant/10",children:d.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant/40 tabular-nums",children:["id: ",e.id]})})]})}const GA=5e3;function Yae(e=!1){const[t,n]=j.useState([]),r=j.useRef(null),{data:a,refetch:i}=Wt({queryKey:["logs-stream"],queryFn:({signal:c})=>{const f=r.current===null?"/logs/stream":`/logs/stream?since=${r.current}`;return lt(f,{signal:c})},refetchInterval:e?!1:Sr.LOGS}),l=j.useRef(e);j.useEffect(()=>{l.current&&!e&&i(),l.current=e},[e,i]),j.useEffect(()=>{if(!(a!=null&&a.entries.length)){a&&r.current===null&&(r.current=a.cursor);return}r.current=a.cursor,n(c=>{const f=[...c,...a.entries];return f.length>GA?f.slice(-GA):f})},[a]);const o=j.useCallback(()=>{n([]),r.current=null},[]);return{entries:t,clear:o}}function Xae(e,t){const n=new URLSearchParams;return e.q&&n.set("q",e.q),e.level&&n.set("level",e.level),e.component&&n.set("component",e.component),e.kind&&n.set("kind",e.kind),e.session_id&&n.set("session_id",e.session_id),e.from&&n.set("from",e.from),e.to&&n.set("to",e.to),e.page&&n.set("page",String(e.page)),e.page_size&&n.set("page_size",String(e.page_size)),Wt({queryKey:["logs-search",Object.fromEntries(n)],queryFn:({signal:r})=>lt(`/logs/search?${n.toString()}`,{signal:r}),enabled:t})}function Qae(e){return Wt({queryKey:["log-detail",e],queryFn:({signal:t})=>lt(`/logs/${e}`,{signal:t}),enabled:e!==null})}function Wae(e){const t=Date.now(),n={"15m":15*6e4,"1h":60*6e4,"6h":360*6e4,"24h":1440*6e4,"7d":10080*6e4,"30d":720*60*6e4};return new Date(t-(n[e]??1440*6e4)).toISOString()}function Zae(){const e=j.useMemo(()=>{var B;const K=new URLSearchParams(window.location.search),Q=((B=K.get("component"))==null?void 0:B.split(",").filter(Boolean))??[],F=K.get("level"),q=K.get("q")??"",X=Q.length>0||!!F||!!q;return{components:Q,level:F,q,hasFilters:X}},[]),[t,n]=j.useState(e.hasFilters?"search":"live"),[r,a]=j.useState(e.q),[i,l]=j.useState(e.q),[o,c]=j.useState(e.level??"debug"),[f,h]=j.useState(new Set(e.components)),[p,m]=j.useState("24h"),[y,x]=j.useState(1),[b,w]=j.useState(null),[S,N]=j.useState(!1),{entries:C,clear:T}=Yae(S),R=j.useMemo(()=>({q:i||void 0,level:o!=="debug"?o:void 0,component:f.size>0?Array.from(f).join(","):void 0,from:Wae(p),page:y,page_size:Kr}),[i,o,f,p,y]),{data:A}=Xae(R,t==="search"),{data:D}=Qae((b==null?void 0:b.id)??null),[O,L]=j.useState(e.components);j.useEffect(()=>{const K=t==="live"?C:(A==null?void 0:A.entries)??[];L(Q=>{const F=new Set(Q);let q=!1;for(const X of K)F.has(X.component)||(F.add(X.component),q=!0);return q?Array.from(F).sort():Q})},[C,A,t]);const M=j.useMemo(()=>{const K=fp[o]??0,Q=r.trim().toLowerCase();return C.filter(F=>!((fp[F.level]??0)<K||f.size>0&&!f.has(F.component)||Q&&!F.message.toLowerCase().includes(Q)))},[C,o,f,r]),P=t==="live"?M:(A==null?void 0:A.entries)??[],z=j.useCallback(K=>{n(K),w(null),K==="live"&&(T(),N(!1))},[T]),H=j.useCallback(()=>{l(r),x(1)},[r]),$=j.useCallback(K=>{w(Q=>(Q==null?void 0:Q.id)===K.id?null:K)},[]),U=j.useCallback(K=>{h(Q=>{const F=new Set(Q);return F.has(K)?F.delete(K):F.add(K),F}),x(1)},[]),I=j.useCallback(K=>{c(K),x(1)},[]),V=b!==null;return d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsx("div",{className:"px-6 pt-6",children:d.jsx(wi,{title:"Logs",subtitle:"Daemon log explorer"})}),d.jsx("div",{className:"px-6 mb-3",children:d.jsx(kae,{mode:t,onModeChange:z,searchValue:r,onSearchChange:a,onSearchSubmit:H,activeLevel:o,onLevelChange:I,components:O,activeComponents:f,onComponentToggle:U,onComponentsClear:()=>{h(new Set),x(1)},timeRange:p,onTimeRangeChange:K=>{m(K),x(1)},totalResults:t==="search"?A==null?void 0:A.total:void 0,paused:S,onPausedToggle:()=>N(K=>!K)})}),d.jsxs("div",{className:"flex flex-1 overflow-hidden mx-6 mb-6 rounded-lg border border-outline-variant/10",children:[d.jsxs("div",{className:ke("flex flex-col",V?"w-3/5":"w-full"),children:[d.jsx(Oae,{entries:P,selectedId:(b==null?void 0:b.id)??null,onSelect:$,autoScroll:t==="live"&&!S,relativeTime:t==="live",compact:!0}),t==="search"&&A&&d.jsx("div",{className:"border-t border-outline-variant/10 px-3 py-2 bg-surface-container-low",children:d.jsx(Ec,{total:A.total,offset:(y-1)*Kr,limit:Kr,onPageChange:K=>x(Math.floor(K/Kr)+1)})})]}),V&&b&&d.jsx("div",{className:"w-2/5 border-l border-outline-variant/10",children:d.jsx(Kae,{entry:b,resolved:D==null?void 0:D.resolved,onClose:()=>w(null)})})]})]})}function Jae(){return d.jsx(xB,{children:d.jsxs(Na,{element:d.jsx(F7,{}),children:[d.jsx(Na,{path:"/",element:d.jsx(z$,{})}),d.jsx(Na,{path:"/sessions",element:d.jsx(Qk,{})}),d.jsx(Na,{path:"/sessions/:id",element:d.jsx(Qk,{})}),d.jsx(Na,{path:"/mycelium",element:d.jsx(une,{})}),d.jsx(Na,{path:"/agent",element:d.jsx(nre,{})}),d.jsx(Na,{path:"/skills",element:d.jsx(Dre,{})}),d.jsx(Na,{path:"/settings",element:d.jsx(qre,{})}),d.jsx(Na,{path:"/operations",element:d.jsx(bae,{})}),d.jsx(Na,{path:"/team",element:d.jsx(Cae,{})}),d.jsx(Na,{path:"/logs",element:d.jsx(Zae,{})})]})})}const eie=new sP({defaultOptions:{queries:{staleTime:tI}}});L4.createRoot(document.getElementById("root")).render(d.jsx(Yi.StrictMode,{children:d.jsx(tz,{children:d.jsx(lz,{children:d.jsx(fz,{children:d.jsx(lP,{client:eie,children:d.jsx(VB,{children:d.jsx(Jae,{})})})})})})}));
|
|
842
|
+
`,children:Vne[B]},B)})})]})]})]}),a&&Object.keys(a).length>0&&d.jsxs("div",{className:"space-y-3 pt-2 border-t border-[var(--ghost-border)]",children:[d.jsx("h3",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Parameters"}),Object.entries(a).map(([B,W])=>{const re=P[B],ae=re??W,ie=B.replace(/_/g," ").replace(/\b\w/g,ye=>ye.toUpperCase());return typeof W=="boolean"?d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("label",{className:"font-sans text-sm text-on-surface",children:ie}),d.jsx(ml,{checked:ae,onCheckedChange:ye=>{z(ue=>({...ue,[B]:ye})),$(!0)}})]},B):d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-sm text-on-surface",children:ie}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(fn,{type:typeof W=="number"?"number":"text",value:re!=null?String(re):"",placeholder:String(W),onChange:ye=>{const ue=typeof W=="number"?ye.target.value===""?void 0:Number(ye.target.value):ye.target.value;z(ue===void 0?ee=>{const ne={...ee};return delete ne[B],ne}:ee=>({...ee,[B]:ue})),$(!0)},className:"w-40 font-mono"}),d.jsxs("span",{className:"font-sans text-xs text-on-surface-variant",children:["default: ",String(W)]})]})]},B)})]}),t&&t.length>0&&d.jsxs("div",{className:"space-y-2 pt-2 border-t border-[var(--ghost-border)]",children:[d.jsx("h3",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:"Per-Phase Overrides"}),t.map(B=>d.jsx(Une,{phase:B,override:D[B.name]??{},taskModel:y||"claude-sonnet-4-6",providers:V,isLoadingProviders:l,onChange:W=>Q(B.name,W)},B.name))]})]})}const $ne=3;function Gne(e){var t,n,r;return{model:((t=e.execution)==null?void 0:t.model)??e.model,maxTurns:((n=e.execution)==null?void 0:n.maxTurns)??e.maxTurns,timeoutSeconds:((r=e.execution)==null?void 0:r.timeoutSeconds)??e.timeoutSeconds}}function Kne(){return d.jsxs("div",{className:"space-y-6",children:[d.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-surface-container-high"}),d.jsxs("div",{className:"rounded-md bg-surface-container-low p-4 space-y-3",children:[d.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-4 w-64 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-8 w-32 animate-pulse rounded bg-surface-container-high"})]}),d.jsx("div",{className:"rounded-md bg-surface-container-low p-4 space-y-2",children:Array.from({length:$ne}).map((e,t)=>d.jsx("div",{className:"h-5 animate-pulse rounded bg-surface-container-high"},t))})]})}function Yne({phase:e,index:t}){return d.jsxs(Ge,{level:"low",className:"p-4 space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-surface-container-high font-mono text-xs font-semibold text-on-surface-variant shrink-0",children:t+1}),d.jsx("span",{className:"font-sans text-sm font-medium text-on-surface",children:e.name}),!e.required&&d.jsx(wt,{variant:"secondary",children:"optional"})]}),d.jsxs("span",{className:"font-mono text-xs text-on-surface-variant shrink-0",children:["max ",e.maxTurns," turns"]})]}),e.tools.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(n=>d.jsx("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded-sm bg-surface-container-high text-on-surface-variant",children:n},n))}),d.jsx(Ge,{level:"lowest",className:"p-3 overflow-auto max-h-40",children:d.jsx(Xr,{content:e.prompt})})]})}function Xne({taskId:e,onBack:t,onNavigate:n,onRunTriggered:r}){const{data:a,isPending:i,isError:l}=x$(e);if(i)return d.jsx(Kne,{});if(l||!(a!=null&&a.task))return d.jsxs("div",{className:"space-y-4",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Tasks"]}),d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Task not found"})]})]});const o=a.task,c=o.phases??[],f=Gne(o);return d.jsxs("div",{className:"space-y-6",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Tasks"]}),d.jsxs(Ge,{level:"low",className:"p-4 space-y-4",children:[d.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[d.jsxs("div",{className:"flex-1 space-y-1 min-w-0",children:[d.jsx("h1",{className:"font-serif text-lg text-on-surface",children:o.displayName}),o.description&&d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:o.description})]}),d.jsx(wt,{variant:s_(o.source),className:"shrink-0",children:xw(o.source??"built-in")})]}),d.jsx(One,{task:o,onDeleted:t,onCustomized:h=>n==null?void 0:n(h),onRunTriggered:r})]}),d.jsx(Hne,{taskId:e,phases:c,defaults:{model:f.model,maxTurns:f.maxTurns,timeoutSeconds:f.timeoutSeconds},schedule:o.schedule,params:o.params}),(f.model!==void 0||f.maxTurns!==void 0||f.timeoutSeconds!==void 0)&&d.jsxs(Ge,{level:"low",className:"p-4 space-y-3",children:[d.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Execution Config"}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[f.model!==void 0&&d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),d.jsx("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:f.model})]}),f.maxTurns!==void 0&&d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),d.jsx("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:f.maxTurns})]}),f.timeoutSeconds!==void 0&&d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Timeout"}),d.jsxs("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:[f.timeoutSeconds,"s"]})]})]})]}),c.length>0?d.jsxs("div",{className:"space-y-3",children:[d.jsxs("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:["Phases",d.jsxs("span",{className:"ml-2 text-on-surface normal-case font-normal",children:[c.length," ",c.length===1?"phase":"phases"]})]}),c.map((h,p)=>d.jsx(Yne,{phase:h,index:p},h.name))]}):d.jsxs("div",{className:"space-y-3",children:[d.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Prompt"}),d.jsx(Ge,{level:"lowest",className:"p-4 overflow-auto max-h-96",children:d.jsx(Xr,{content:o.prompt??""})})]}),d.jsx(Pne,{taskId:e})]})}function o5(e,t){var n,r,a;return{summaryBatchInterval:String(((n=e.agent)==null?void 0:n.summary_batch_interval)??Tb),defaultTask:t??"",scheduledTasksEnabled:((r=e.agent)==null?void 0:r.scheduled_tasks_enabled)??!0,eventTasksEnabled:((a=e.agent)==null?void 0:a.event_tasks_enabled)??!0}}function Qne(e,t,n){const r=o5(t,n);return e.summaryBatchInterval!==r.summaryBatchInterval||e.defaultTask!==r.defaultTask||e.scheduledTasksEnabled!==r.scheduledTasksEnabled||e.eventTasksEnabled!==r.eventTasksEnabled}function BA({label:e,value:t,max:n,color:r}){const a=n>0?Math.round(t/n*100):0,i=2*Math.PI*36,l=i-a/100*i;return d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsxs("div",{className:"relative h-20 w-20",children:[d.jsxs("svg",{className:"h-20 w-20 -rotate-90",viewBox:"0 0 80 80",children:[d.jsx("circle",{cx:"40",cy:"40",r:"36",fill:"none",stroke:"currentColor",className:"text-surface-container/30",strokeWidth:"6"}),d.jsx("circle",{cx:"40",cy:"40",r:"36",fill:"none",stroke:r,strokeWidth:"6",strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:l,className:"transition-all duration-700"})]}),d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:d.jsxs("span",{className:"text-sm font-semibold font-mono text-on-surface",children:[a,"%"]})})]}),d.jsx("span",{className:"text-xs text-on-surface-variant text-center font-sans",children:e})]})}function Gi({label:e,value:t}){return d.jsxs("div",{className:"flex items-center justify-between py-1",children:[d.jsx("span",{className:"text-xs text-on-surface-variant font-sans",children:e}),d.jsx("span",{className:"text-xs font-mono text-on-surface",children:t})]})}function Wne({stats:e}){const t=e.embedding.total_embeddable>0?e.embedding.embedded_count:0,n=e.embedding.total_embeddable;return d.jsxs("div",{className:"space-y-4",children:[d.jsxs("h2",{className:"text-xs font-semibold text-on-surface-variant uppercase tracking-widest flex items-center gap-2 font-sans",children:[d.jsx(Eb,{className:"h-3.5 w-3.5"}),"System Health"]}),d.jsxs("div",{className:"flex justify-center gap-8 py-2",children:[d.jsx(BA,{label:"Embedding Coverage",value:t,max:n,color:"#abcfb8"}),d.jsx(BA,{label:"Queue Health",value:Math.max(0,n-e.embedding.queue_depth),max:n,color:"#edbf7f"})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-0",children:[d.jsx(Gi,{label:"Sessions",value:String(e.vault.session_count)}),d.jsx(Gi,{label:"Spores",value:String(e.vault.spore_count)}),d.jsx(Gi,{label:"Entities",value:String(e.vault.entity_count)}),d.jsx(Gi,{label:"Graph edges",value:String(e.vault.edge_count)}),d.jsx(Gi,{label:"Uptime",value:yw(e.daemon.uptime_seconds)}),d.jsx(Gi,{label:"Daemon",value:`v${e.daemon.version} :${e.daemon.port}`}),e.agent.last_run_at!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Gi,{label:"Last run",value:bi(e.agent.last_run_at)}),d.jsx(Gi,{label:"Total runs",value:String(e.agent.total_runs)})]}),e.digest.freshest_tier!==null&&d.jsx(Gi,{label:"Digest tier",value:`T${e.digest.freshest_tier}`})]})]})}function Zne(){var L,M;const{config:e,isLoading:t,saveConfig:n,isSaving:r}=Od(),{data:a,isLoading:i}=Vp(),{data:l,isLoading:o}=xc(),{restart:c}=V1(),[f,h]=j.useState(null),[p,m]=j.useState(null),[y,x]=j.useState("idle"),[b,w]=j.useState(""),S=(l==null?void 0:l.tasks)??[],N=((L=S.find(P=>P.isDefault))==null?void 0:L.name)??"",C=j.useRef(!1);e&&!o&&!C.current&&(C.current=!0,f===null&&h(o5(e,N)));const T=f&&e?Qne(f,e,N):!1,R=!!((M=e==null?void 0:e.agent)!=null&&M.provider),A=j.useCallback((P,z)=>{h(H=>H&&{...H,[P]:z}),m(null)},[]),D=async()=>{if(!(!f||!e)){m(null);try{const P={...e,agent:{...e.agent,summary_batch_interval:Hb(f.summaryBatchInterval,Tb),scheduled_tasks_enabled:f.scheduledTasksEnabled,event_tasks_enabled:f.eventTasksEnabled}};await n(P),m({type:"success",text:"Agent settings saved. Restarting daemon..."});try{await c()}catch{m({type:"success",text:"Settings saved. Daemon restart may require manual action."})}}catch{m({type:"error",text:"Failed to save settings."})}}},O=async()=>{if(e){x("testing"),w("");try{const P=new URLSearchParams({provider:e.embedding.provider,type:"embedding"});e.embedding.base_url&&P.set("base_url",e.embedding.base_url);const H=(await lt(`/models?${P.toString()}`)).models.length;x("success"),w(`Connected -- ${H} model${H!==1?"s":""} available.`)}catch(P){x("error"),w(P instanceof Error?P.message:"Connection failed.")}}};return t||!e||!f?d.jsx("div",{className:"space-y-4",children:[1,2,3].map(P=>d.jsx("div",{className:"h-32 rounded-md animate-pulse bg-surface-container-low"},P))}):d.jsxs("div",{className:"space-y-6",children:[d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(Fz,{className:"h-4 w-4 text-primary"}),"Agent Operations"]})}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Scheduled Tasks"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Intelligence, skill survey, and skill evolution run automatically on a schedule"})]}),d.jsx(ml,{checked:f.scheduledTasksEnabled,onCheckedChange:P=>A("scheduledTasksEnabled",P),disabled:!R})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Event-Driven Tasks"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Titles and summaries generated automatically after coding sessions"})]}),d.jsx(ml,{checked:f.eventTasksEnabled,onCheckedChange:P=>A("eventTasksEnabled",P),disabled:!R})]})]}),!R&&d.jsxs("p",{className:"font-sans text-xs text-on-surface-variant/70",children:["Configure an agent provider in"," ",d.jsx("a",{href:"/settings",className:"underline hover:text-on-surface transition-colors",children:"Settings"})," ","to enable agent tasks."]}),d.jsx("div",{className:"border-t border-outline-variant/20"}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Title & Summary Batch Interval"}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(fn,{type:"number",min:0,placeholder:String(Tb),value:f.summaryBatchInterval,onChange:P=>A("summaryBatchInterval",P.target.value),className:"w-32 font-mono"}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:"batches"})]}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Run the Title & Summary task every N batches to keep active sessions properly titled. Set to 0 to disable."})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Default Task"}),o?d.jsxs("div",{className:"flex h-9 items-center gap-2 text-on-surface-variant font-sans text-sm",children:[d.jsx(zn,{className:"h-4 w-4 animate-spin"}),"Loading tasks..."]}):d.jsxs(hi,{value:f.defaultTask,onValueChange:P=>A("defaultTask",P),children:[d.jsx(Ua,{children:d.jsx(vi,{placeholder:"Select default task"})}),d.jsx(qa,{children:S.map(P=>d.jsx(Gr,{value:P.name,children:P.displayName},P.name))})]}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"The task used when Run Now is clicked or no task is specified."})]}),d.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[d.jsxs(Ae,{onClick:D,disabled:!T||r,size:"sm",children:[r?d.jsx(zn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Save Changes"]}),p&&d.jsx("span",{className:p.type==="success"?"font-sans text-xs text-primary":"font-sans text-xs text-tertiary",children:p.text})]})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-4 border-t-2 border-t-ochre",children:[d.jsx(St,{children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(P1,{className:"h-4 w-4 text-secondary"}),"Embedding Configuration"]})}),d.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Provider"}),d.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5",children:e.embedding.provider})]}),d.jsxs("div",{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),d.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5 truncate",title:e.embedding.model,children:e.embedding.model})]}),e.embedding.base_url&&d.jsxs("div",{className:"col-span-2",children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Base URL"}),d.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5 truncate",title:e.embedding.base_url,children:e.embedding.base_url})]})]}),d.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[d.jsxs(Ae,{type:"button",variant:"ghost",size:"sm",onClick:O,disabled:y==="testing",children:[y==="testing"?d.jsx(zn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Test Connection"]}),d.jsxs("a",{href:"/settings",className:"flex items-center gap-1 font-sans text-xs text-on-surface-variant hover:text-on-surface transition-colors",children:[d.jsx(jd,{className:"h-3 w-3"}),"Edit in Settings"]}),y==="success"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-xs text-primary",children:[d.jsx(kb,{className:"h-3.5 w-3.5"}),b]}),y==="error"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-xs text-tertiary",children:[d.jsx(yo,{className:"h-3.5 w-3.5"}),b]})]})]}),i?d.jsx(Ge,{level:"low",className:"p-6",children:d.jsx("div",{className:"h-32 animate-pulse rounded-md bg-surface-container"})}):a?d.jsx(Ge,{level:"low",className:"p-6",children:d.jsx(Wne,{stats:a})}):null]})}const u5="tab",c5="run",f5="task",Jne=new Set(["runs","tasks","config"]);function zA(){const e=new URLSearchParams(window.location.search),t=e.get(u5);return{tab:t&&Jne.has(t)?t:"runs",runId:e.get(c5)??void 0,taskId:e.get(f5)??void 0}}function ere(e,t,n){const r=new URLSearchParams;e!=="runs"&&r.set(u5,e),t&&r.set(c5,t),n&&r.set(f5,n);const a=r.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.pushState(null,"",i)}const tre=[{id:"runs",label:"Runs"},{id:"tasks",label:"Tasks"},{id:"config",label:"Config"}];function nre(){const e=zA(),[t,n]=j.useState(e.tab),[r,a]=j.useState(e.runId),[i,l]=j.useState(e.taskId),[o,c]=j.useState(!1),f=j.useRef(!1),h=j.useRef(!1);j.useEffect(()=>{if(!f.current){f.current=!0;return}if(h.current){h.current=!1;return}ere(t,r,i)},[t,r,i]),j.useEffect(()=>{function m(){h.current=!0;const y=zA();n(y.tab),a(y.runId),l(y.taskId)}return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]);const p=j.useCallback(m=>{const y=m;n(y),y!=="runs"&&a(void 0),y!=="tasks"&&l(void 0)},[]);return d.jsxs("div",{className:"p-6 space-y-4",children:[d.jsx(wi,{title:"Agent",subtitle:"Intelligence runs, task configuration, and operational settings",tabs:tre,activeTab:t,onTabChange:p,actions:t==="runs"?d.jsxs(Ae,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>c(!0),children:[d.jsx(rs,{className:"h-3.5 w-3.5"}),"Run Now"]}):void 0}),t==="runs"&&(r?d.jsx(Ene,{runId:r,onBack:()=>a(void 0)}):d.jsx(vne,{onSelectRun:a,onTriggerRun:()=>c(!0)})),t==="tasks"&&(i?d.jsx(Xne,{taskId:i,onBack:()=>l(void 0),onNavigate:l,onRunTriggered:m=>{l(void 0),n("runs"),m&&a(m)}}):d.jsx(Ane,{onSelect:l})),t==="config"&&d.jsx(Zne,{}),d.jsx(Nne,{open:o,onOpenChange:c,onTriggered:()=>a(void 0)})]})}function d5(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),(e==null?void 0:e.limit)!==void 0&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset));const n=t.toString(),r=n?`/skill-candidates?${n}`:"/skill-candidates";return Wt({queryKey:["skill-candidates",e],queryFn:({signal:a})=>lt(r,{signal:a})})}function rre(){const e=jn();return wr({mutationFn:({id:t,...n})=>hc(`/skill-candidates/${t}`,n),onSuccess:()=>{e.invalidateQueries({queryKey:["skill-candidates"]})}})}function h5(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),(e==null?void 0:e.limit)!==void 0&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset));const n=t.toString(),r=n?`/skill-records?${n}`:"/skill-records";return Wt({queryKey:["skill-records",e],queryFn:({signal:a})=>lt(r,{signal:a})})}function are(e){return Wt({queryKey:["skill-record",e],queryFn:({signal:t})=>lt(`/skill-records/${e}`,{signal:t}),enabled:!!e})}function ire(){const e=jn();return wr({mutationFn:t=>I1(`/skill-records/${encodeURIComponent(t)}`),onSuccess:()=>{e.invalidateQueries({queryKey:["skill-records"]}),e.invalidateQueries({queryKey:["skill-record"]})}})}const Bn={IDENTIFIED:"identified",APPROVED:"approved",GENERATED:"generated",DISMISSED:"dismissed"},sre=`${Bn.APPROVED},${Bn.GENERATED}`,lre=[{key:"status",label:"Status",options:[{value:er,label:"All statuses"},{value:Bn.IDENTIFIED,label:"Identified"},{value:sre,label:"Approved & generated"},{value:Bn.APPROVED,label:"Awaiting generation"},{value:Bn.GENERATED,label:"Generated"},{value:Bn.DISMISSED,label:"Dismissed"}]}];function ore(e){const t=`${(e*100).toFixed(0)}%`;return e>=.85?{text:t,variant:"default"}:e>=.7?{text:t,variant:"secondary"}:{text:t,variant:"outline"}}function IA(e){const t=Math.floor(Date.now()/1e3)-e;return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function ure(e){switch(e){case Bn.IDENTIFIED:return d.jsx(wt,{variant:"outline",children:"Identified"});case Bn.APPROVED:return d.jsx(wt,{variant:"secondary",children:"Awaiting generation"});case Bn.GENERATED:return d.jsx(wt,{variant:"default",children:"Generated"});case Bn.DISMISSED:return d.jsx(wt,{variant:"outline",className:"opacity-50",children:"Dismissed"});default:return d.jsx(wt,{variant:"outline",children:e})}}function cre({candidate:e,onApprove:t,onDismiss:n,isApproving:r,isDismissing:a}){const i=ore(e.confidence),l=e.status===Bn.IDENTIFIED||e.status===Bn.APPROVED;return d.jsxs(Ge,{level:"low",className:"p-5 space-y-3",children:[d.jsxs("div",{className:"flex items-start justify-between gap-4",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("h3",{className:"font-serif text-lg text-on-surface leading-tight",children:e.topic}),e.approved_at!==null&&d.jsxs("p",{className:"font-sans text-xs text-on-surface-variant mt-1",children:["Approved ",IA(e.approved_at),e.status===Bn.GENERATED&&" · generated"]})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[ure(e.status),d.jsx(wt,{variant:i.variant,children:i.text}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:IA(e.created_at)})]})]}),d.jsx(Xr,{content:e.rationale,className:"text-sm text-on-surface-variant"}),l&&d.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.status===Bn.IDENTIFIED&&d.jsxs(d.Fragment,{children:[d.jsxs(Ae,{size:"sm",variant:"default",onClick:t,disabled:r,children:[d.jsx(kd,{className:"h-3.5 w-3.5 mr-1.5"}),r?"Approving...":"Approve"]}),d.jsxs(Ae,{size:"sm",variant:"ghost",onClick:n,disabled:a,className:"text-on-surface-variant",children:[d.jsx(yo,{className:"h-3.5 w-3.5 mr-1.5"}),a?"Dismissing...":"Dismiss"]})]}),e.status===Bn.APPROVED&&d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:"Awaiting generation"})]})]})}function fre(){return d.jsxs(Ge,{level:"low",className:"p-5 space-y-3",children:[d.jsxs("div",{className:"flex items-start justify-between",children:[d.jsx("div",{className:"h-5 w-64 rounded bg-surface-container-high animate-pulse"}),d.jsx("div",{className:"h-5 w-20 rounded bg-surface-container-high animate-pulse"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("div",{className:"h-3 w-full rounded bg-surface-container-high animate-pulse"}),d.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-container-high animate-pulse"})]}),d.jsx("div",{className:"h-8 w-32 rounded bg-surface-container-high animate-pulse"})]})}function dre(){const e=rre(),{searchInput:t,debouncedSearch:n,filterValues:r,offset:a,setOffset:i,handleSearchChange:l,handleFilterChange:o,activeFilter:c}=Bd({initialFilters:{status:Bn.IDENTIFIED}}),f=c("status"),{data:h,isLoading:p,isError:m,error:y}=d5({status:f,limit:Kr,offset:a}),x=(h==null?void 0:h.candidates)??[],b=(h==null?void 0:h.total)??0,w=j.useMemo(()=>{if(!n)return x;const T=n.toLowerCase();return x.filter(R=>R.topic.toLowerCase().includes(T)||R.rationale.toLowerCase().includes(T))},[x,n]);function S(T){e.mutate({id:T.id,status:Bn.APPROVED})}function N(T){e.mutate({id:T.id,status:Bn.DISMISSED})}const C=d.jsx(Pd,{searchPlaceholder:"Search candidates...",searchValue:t,onSearchChange:l,filters:lre,filterValues:r,onFilterChange:o});return m?d.jsxs("div",{className:"space-y-3",children:[C,d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Failed to load candidates"}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:y instanceof Error?y.message:"Unknown error"})]})]}):p?d.jsxs("div",{className:"space-y-3",children:[C,Array.from({length:3}).map((T,R)=>d.jsx(fre,{},R))]}):d.jsxs("div",{className:"space-y-3",children:[C,w.length===0?d.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-3 text-on-surface-variant",children:[d.jsx(Mz,{className:"h-10 w-10 opacity-20"}),b===0&&!f&&!n?d.jsxs("div",{className:"text-center space-y-2 max-w-md",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"No skill candidates discovered yet"}),d.jsx("p",{className:"font-sans text-xs leading-relaxed",children:"Candidates are procedural patterns discovered from your vault knowledge. Review and approve them here, then Myco generates full skills from them."}),d.jsxs("div",{className:"font-sans text-xs space-y-1 pt-1",children:[d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Automatic:"})," ","The"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-survey",className:"text-primary hover:underline",children:"Skill Survey"})," ","task runs automatically during idle periods and discovers candidates from session history, decisions, and gotchas."]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Manual:"})," ","Run"," ",d.jsxs(Ma,{to:"/agent?tab=tasks&task=skill-survey",className:"inline-flex items-center gap-1 text-primary hover:underline",children:[d.jsx(jd,{className:"h-3 w-3"}),"Skill Survey"]})," ","from the Agent page to discover candidates on demand."]})]})]}):d.jsx("span",{className:"font-sans text-sm",children:"No matching candidates"})]}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:n?`${w.length} of ${b} candidate${b!==1?"s":""}`:`${b} candidate${b!==1?"s":""}`}),w.map(T=>{var R,A,D,O;return d.jsx(cre,{candidate:T,onApprove:()=>S(T),onDismiss:()=>N(T),isApproving:e.isPending&&((R=e.variables)==null?void 0:R.id)===T.id&&((A=e.variables)==null?void 0:A.status)===Bn.APPROVED,isDismissing:e.isPending&&((D=e.variables)==null?void 0:D.id)===T.id&&((O=e.variables)==null?void 0:O.status)===Bn.DISMISSED},T.id)})]}),d.jsx(Ec,{total:n?w.length:b,offset:a,limit:Kr,onPageChange:i})]})}const hre=5,vre=[{key:"status",label:"Status",options:[{value:er,label:"All statuses"},{value:"active",label:"Active"},{value:"stale",label:"Stale"},{value:"retired",label:"Retired"}]}];function pre(e){return e==="active"?"default":e==="stale"?"secondary":"outline"}function If({children:e,className:t}){return d.jsx("th",{className:ke("px-4 py-3 text-left font-sans text-[10px] font-medium uppercase tracking-widest text-on-surface-variant",t),children:e})}function mre(){return d.jsxs("tr",{className:"border-b border-[var(--ghost-border)]",children:[d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-40 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-12 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-16 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-10 rounded bg-surface-container-high animate-pulse"})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("div",{className:"h-3 w-20 rounded bg-surface-container-high animate-pulse"})})]})}function gre({record:e,onClick:t}){return d.jsxs("tr",{className:"border-b border-[var(--ghost-border)] last:border-0 hover:bg-surface-container/60 cursor-pointer transition-all duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40 hover:shadow-[inset_3px_0_0_var(--primary)]",onClick:t,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())},tabIndex:0,role:"row","aria-label":`Skill: ${e.display_name}`,children:[d.jsxs("td",{className:"px-4 py-3",children:[d.jsx("span",{className:"font-sans text-sm font-medium text-on-surface block",children:e.display_name}),d.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant block mt-0.5",children:e.name})]}),d.jsx("td",{className:"px-4 py-3",children:d.jsxs(wt,{variant:"outline",className:"font-mono text-[10px] px-1.5 py-0",children:["gen ",e.generation]})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx(wt,{variant:pre(e.status),children:e.status})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("span",{className:"font-mono text-xs text-on-surface-variant",children:e.usage_count})}),d.jsx("td",{className:"px-4 py-3",children:d.jsx("span",{className:"font-mono text-xs text-on-surface-variant",children:am(e.updated_at)})})]})}function yre({onSelectSkill:e}){const{searchInput:t,debouncedSearch:n,filterValues:r,offset:a,setOffset:i,handleSearchChange:l,handleFilterChange:o,activeFilter:c}=Bd({initialFilters:{status:er}}),f=c("status"),{data:h,isLoading:p,isError:m,error:y}=h5({status:f,limit:Kr,offset:a}),x=(h==null?void 0:h.records)??[],b=(h==null?void 0:h.total)??0,w=n?x.filter(C=>C.display_name.toLowerCase().includes(n.toLowerCase())||C.name.toLowerCase().includes(n.toLowerCase())||C.description.toLowerCase().includes(n.toLowerCase())):x,S=d.jsx(Pd,{searchPlaceholder:"Search skills...",searchValue:t,onSearchChange:l,filters:vre,filterValues:r,onFilterChange:o}),N=d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-[var(--ghost-border)] bg-surface-container/50",children:[d.jsx(If,{children:"Name"}),d.jsx(If,{children:"Generation"}),d.jsx(If,{children:"Status"}),d.jsx(If,{children:"Usage"}),d.jsx(If,{children:"Last Evolved"})]})});return m?d.jsxs("div",{children:[S,d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary mt-4",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Failed to load skills"}),d.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:y instanceof Error?y.message:"Unknown error"})]})]}):d.jsxs("div",{children:[S,p?d.jsx(Ge,{level:"low",className:"rounded-md overflow-hidden mt-4",children:d.jsxs("table",{className:"w-full",children:[N,d.jsx("tbody",{children:Array.from({length:hre}).map((C,T)=>d.jsx(mre,{},T))})]})}):w.length===0?d.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-3 text-on-surface-variant mt-4",children:[d.jsx(mz,{className:"h-10 w-10 opacity-20"}),b===0&&!n&&!f?d.jsxs("div",{className:"text-center space-y-2 max-w-md",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"No skills generated yet"}),d.jsx("p",{className:"font-sans text-xs leading-relaxed",children:"Skills are project-specific procedural guides generated from your vault knowledge. They teach agents how to accomplish tasks in this codebase."}),d.jsxs("div",{className:"font-sans text-xs space-y-1 pt-1",children:[d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Automatic:"})," ","The"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-survey",className:"text-primary hover:underline",children:"Skill Survey"})," ","task runs automatically and discovers candidates from your vault. Approve candidates in the"," ",d.jsx(Ma,{to:"/skills?tab=candidates",className:"text-primary hover:underline",children:"Candidates tab"}),", then enable the"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","task to produce skills automatically."]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Manual:"})," ","Run"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","from the Agent page to generate a skill on demand."]})]})]}):d.jsx("span",{className:"font-sans text-sm",children:"No matching skills"})]}):d.jsx(Ge,{level:"low",className:"rounded-md overflow-hidden mt-4",children:d.jsxs("table",{className:"w-full","aria-label":"Skills",children:[N,d.jsx("tbody",{children:w.map(C=>d.jsx(gre,{record:C,onClick:()=>e(C.name)},C.id))})]})}),d.jsx(Ec,{total:b,offset:a,limit:Kr,onPageChange:i})]})}const xre={created:"default",updated:"secondary",split:"warning",retired:"outline"};function bre({entry:e}){const[t,n]=j.useState(!1);return d.jsxs("div",{className:"relative pl-6",children:[d.jsx("div",{className:"absolute left-0 top-2 h-2.5 w-2.5 rounded-full border-2 border-outline-variant bg-surface-container"}),d.jsxs("button",{type:"button",className:"w-full text-left group cursor-pointer",onClick:()=>n(r=>!r),"aria-expanded":t,children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsxs(wt,{variant:"outline",className:"font-mono text-[10px] px-1.5 py-0",children:["v",e.generation]}),d.jsx(wt,{variant:xre[e.action]??"outline",children:e.action}),d.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant ml-auto shrink-0",children:am(e.created_at)}),d.jsx(da,{className:ke("h-3.5 w-3.5 text-on-surface-variant transition-transform duration-150",t&&"rotate-90")})]}),e.rationale&&d.jsx("p",{className:"font-sans text-sm text-on-surface-variant mt-1 leading-relaxed",children:e.rationale})]}),t&&e.content_snapshot&&d.jsx(Ge,{level:"lowest",className:"mt-2 p-3 overflow-auto max-h-96",children:d.jsx("pre",{className:"font-mono text-xs text-on-surface whitespace-pre-wrap break-words",children:e.content_snapshot})})]})}function wre({entries:e}){return e.length===0?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant py-4",children:"No evolution history."}):d.jsxs("div",{className:"relative space-y-4",children:[d.jsx("div",{className:"absolute left-[4.5px] top-2 bottom-2 w-px bg-outline-variant/30"}),e.map(t=>d.jsx(bre,{entry:t},t.id))]})}function Sre(e){return e==="active"?"default":e==="stale"?"secondary":"outline"}function Ere(e){if(!e)return 0;try{const t=JSON.parse(e);return Array.isArray(t)?t.length:0}catch{return 0}}function Cre(){return d.jsxs("div",{className:"space-y-6",children:[d.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-surface-container-high"}),d.jsxs("div",{className:"rounded-md bg-surface-container-low p-4 space-y-3",children:[d.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-4 w-64 animate-pulse rounded bg-surface-container-high"}),d.jsx("div",{className:"h-5 w-32 animate-pulse rounded bg-surface-container-high"})]}),d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:Array.from({length:3}).map((e,t)=>d.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-surface-container-high"},t))})]})}function Nre({skillName:e,onBack:t}){var m,y;const{data:n,isPending:r,isError:a}=are(e),i=ire(),[l,o]=j.useState(!1);if(r)return d.jsx(Cre,{});if(a||!n)return d.jsxs("div",{className:"space-y-4",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Skills"]}),d.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-5 w-5"}),d.jsx("span",{className:"font-sans text-sm",children:"Skill not found"})]})]});const c=Ere(n.source_ids),f=((y=(m=n.lineage)==null?void 0:m[0])==null?void 0:y.content_snapshot)??null,h=n.frontmatter??{},p=(f==null?void 0:f.replace(/^---\n[\s\S]*?\n---\n*/,""))??null;return d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[d.jsx(gi,{className:"h-4 w-4"}),"Skills"]}),d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-2 text-tertiary hover:text-tertiary hover:bg-tertiary/10",onClick:()=>o(!0),children:[d.jsx(as,{className:"h-4 w-4"}),"Delete"]})]}),d.jsx(Ge,{level:"low",className:"p-4 space-y-3",children:d.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[d.jsxs("div",{className:"flex-1 space-y-1 min-w-0",children:[d.jsx("h1",{className:"font-serif text-lg text-on-surface",children:n.display_name}),n.description&&d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:n.description}),n.path&&d.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant mt-1",children:n.path}),Object.keys(h).length>0&&d.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[h["user-invocable"]==="true"&&d.jsx(wt,{variant:"secondary",children:"user-invocable"}),h["allowed-tools"]&&d.jsxs(wt,{variant:"outline",children:["tools: ",h["allowed-tools"]]})]})]}),d.jsx(wt,{variant:Sre(n.status),className:"shrink-0",children:n.status})]})}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[d.jsx(Kt,{label:"Generation",value:`v${n.generation}`,accent:"sage"}),d.jsx(Kt,{label:"Usage",value:`${n.usage_total??n.usage_count??0}`,sublabel:"sessions",accent:"ochre"}),d.jsx(Kt,{label:"Sources",value:`${c}`,accent:"outline"})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsx(St,{children:"Evolution History"}),d.jsx(wre,{entries:n.lineage??[]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsx(St,{children:"Current Content"}),p?d.jsx(Xr,{content:p}):d.jsx("p",{className:"font-sans text-sm text-on-surface-variant py-4",children:"No content snapshot available."})]}),d.jsx(im,{open:l,onOpenChange:o,title:"Delete Skill",description:"This will permanently delete the skill record, evolution history, and the SKILL.md file from disk.",icon:d.jsx(as,{className:"h-4 w-4 text-tertiary"}),meta:n?[{label:"Name",value:n.name},{label:"Title",value:n.display_name}]:[],confirmLabel:"Delete Skill",variant:"destructive",onConfirm:()=>{i.mutate(n.name,{onSuccess:()=>{o(!1),t()}})},isPending:i.isPending})]})}const v5="tab",p5="skill",kre=new Set(["candidates","skills"]);function Tre(){const e=new URLSearchParams(window.location.search),t=e.get(v5);return{tab:t&&kre.has(t)?t:"skills",skill:e.get(p5)??void 0}}function jre(e,t){const n=new URLSearchParams;e!=="skills"&&n.set(v5,e),t&&n.set(p5,t);const r=n.toString(),a=r?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState(null,"",a)}const Are=[{id:"skills",label:"Skills"},{id:"candidates",label:"Candidates"}];function Rre(){return d.jsxs(Ad,{children:[d.jsx(bF,{asChild:!0,children:d.jsx(Ae,{variant:"ghost",size:"sm",className:"text-on-surface-variant",children:d.jsx(yz,{className:"h-4 w-4"})})}),d.jsxs(pc,{className:"max-w-lg",children:[d.jsxs(Rd,{children:[d.jsx(mc,{children:"How Skills Work"}),d.jsx(Qp,{children:"Skills are project-specific procedural guides generated from your vault knowledge. They teach agents how to accomplish tasks in your codebase."})]}),d.jsxs("div",{className:"space-y-4 font-sans text-sm text-on-surface-variant",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"font-medium text-on-surface",children:"The Pipeline"}),d.jsxs("ol",{className:"list-decimal pl-5 space-y-1",children:[d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Survey"})," — discovers candidate skills from vault knowledge (sessions, decisions, gotchas)"]}),d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Approve"})," — you review candidates and approve the ones worth generating"]}),d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Generate"})," — produces a SKILL.md file from the approved candidate's source material"]}),d.jsxs("li",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Evolve"})," — updates existing skills when new knowledge makes them stale"]})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"font-medium text-on-surface",children:"Scheduling"}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium text-on-surface",children:"Skill Survey"})," runs automatically during idle periods. Skill Generate and Skill Evolve are off by default — enable them in the"," ",d.jsxs(Ma,{to:"/agent?tab=tasks",className:"text-primary hover:underline inline-flex items-center gap-0.5",children:["Agent Tasks",d.jsx(jd,{className:"h-3 w-3"})]})," ","page for fully automatic operation, or trigger them manually with Run Now."]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"font-medium text-on-surface",children:"Quick Start"}),d.jsxs("ol",{className:"list-decimal pl-5 space-y-1",children:[d.jsx("li",{children:"Wait for the survey to discover candidates (or run it manually)"}),d.jsx("li",{children:"Review candidates in the Candidates tab and approve the best ones"}),d.jsxs("li",{children:["Run"," ",d.jsx(Ma,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","to produce skills from approved candidates"]})]})]})]})]})]})}function Dre(){const e=Tre(),[t,n]=j.useState(e.tab),[r,a]=j.useState(e.skill),{data:i}=d5({status:"identified"}),{data:l}=h5({status:"active"}),o=(i==null?void 0:i.total)??0,c=(l==null?void 0:l.total)??0;j.useEffect(()=>{jre(t,r)},[t,r]);const f=j.useCallback(p=>{const m=p;n(m),m!=="skills"&&a(void 0)},[]),h=j.useCallback(p=>{n("skills"),a(p)},[]);return d.jsxs("div",{className:"p-6 space-y-4",children:[d.jsx(wi,{title:"Skills",subtitle:"Discovered skill candidates and promoted skill records",tabs:Are,activeTab:t,onTabChange:f,actions:d.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&d.jsxs(wt,{variant:"secondary",children:[o," pending"]}),c>0&&d.jsxs(wt,{variant:"default",children:[c," active"]}),d.jsx(Rre,{})]})}),t==="candidates"&&d.jsx(dre,{}),t==="skills"&&!r&&d.jsx(yre,{onSelectSkill:h}),t==="skills"&&r&&d.jsx(Nre,{skillName:r,onBack:()=>a(void 0)})]})}const Mre=new Set(["openai-compatible"]);function _re(e,t,n){const r=e?Mre.has(e):!1;return Wt({queryKey:["models",e,t,n],queryFn:({signal:i})=>{const l=new URLSearchParams({provider:e});return t&&l.set("base_url",t),l.set("type",n),lt(`/models?${l.toString()}`,{signal:i})},enabled:!!e&&(!r||!!t),staleTime:nI})}function Ore(){const[e,t]=j.useState({}),[n,r]=j.useState([]),[a,i]=j.useState([]),[l,o]=j.useState(""),[c,f]=j.useState(!1),[h,p]=j.useState(null),[m,y]=j.useState(!0);j.useEffect(()=>{lt("/config/plan-dirs").then(T=>{t(T.symbiont),r(T.custom),i(T.custom)}).catch(()=>{}).finally(()=>y(!1))},[]);const x=n.length!==a.length||n.some((T,R)=>T!==a[R]),b=j.useCallback(()=>{const T=l.trim();!T||n.includes(T)||(r(R=>[...R,T]),o(""),p(null))},[l,n]),w=j.useCallback(T=>{r(R=>R.filter(A=>A!==T)),p(null)},[]),S=j.useCallback(async()=>{f(!0),p(null);try{const T=await nn("/config/plan-dirs",{plan_dirs:n});i(T.custom),r(T.custom),p({type:"success",text:"Plan directories saved."})}catch{p({type:"error",text:"Failed to save plan directories."})}finally{f(!1)}},[n]),N=j.useCallback(T=>{T.key==="Enter"&&b()},[b]),C=Object.entries(e);return d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-amber-500",children:[d.jsx(St,{children:"Plan Capture"}),m?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:"Loading..."}):d.jsxs("div",{className:"space-y-5",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"Agent Directories"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Directories monitored by connected agents. Managed by symbiont manifests."}),C.length===0?d.jsx("p",{className:"font-sans text-xs text-on-surface-variant italic",children:"No agent directories configured."}):d.jsx("div",{className:"space-y-3",children:C.map(([T,R])=>d.jsxs("div",{className:"space-y-1",children:[d.jsx("p",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:T}),d.jsx("div",{className:"space-y-1",children:R.map(A=>d.jsx("div",{className:"rounded bg-surface-container px-3 py-1.5 font-mono text-xs text-on-surface-variant",children:A},A))})]},T))})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"Custom Directories"}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Additional directories to watch for plan files."}),n.length>0&&d.jsx("div",{className:"space-y-1",children:n.map(T=>d.jsxs("div",{className:"flex items-center gap-2 rounded bg-surface-container px-3 py-1.5",children:[d.jsx("span",{className:"flex-1 font-mono text-xs text-on-surface",children:T}),d.jsx("button",{type:"button",onClick:()=>w(T),className:"font-sans text-xs text-on-surface-variant hover:text-tertiary transition-colors leading-none","aria-label":`Remove ${T}`,children:"x"})]},T))}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(fn,{placeholder:"/path/to/plans",value:l,onChange:T=>o(T.target.value),onKeyDown:N,className:"flex-1 font-mono text-xs"}),d.jsx(Ae,{type:"button",size:"sm",onClick:b,disabled:!l.trim(),children:"Add"})]})]}),x&&d.jsxs("div",{className:"flex items-center gap-4 pt-1",children:[d.jsx(Ae,{onClick:S,disabled:c,size:"sm",children:c?"Saving...":"Save"}),h&&d.jsx("span",{className:h.type==="success"?"font-sans text-sm text-primary":"font-sans text-sm text-tertiary",children:h.text})]}),!x&&(h==null?void 0:h.type)==="success"&&d.jsx("p",{className:"font-sans text-sm text-primary",children:h.text})]})]})}function zv({children:e,hint:t}){return d.jsxs("label",{className:"font-sans text-sm font-medium text-on-surface",children:[e,t&&d.jsxs("span",{className:"ml-1 font-sans text-xs text-on-surface-variant font-normal",children:["(",t,")"]})]})}function sb({children:e}){return d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:e})}function Lre(){var y,x,b,w;const{config:e,saveConfig:t,isSaving:n}=Od(),{data:r}=IF(),[a,i]=j.useState(null),[l,o]=j.useState(null);j.useEffect(()=>{var S,N,C,T;e&&!a&&i({enabled:((S=e.notifications)==null?void 0:S.enabled)??!0,system_notifications:((N=e.notifications)==null?void 0:N.system_notifications)??!1,default_mode:((C=e.notifications)==null?void 0:C.default_mode)??"banner",domains:((T=e.notifications)==null?void 0:T.domains)??{}})},[e,a]);const c=j.useCallback((S,N)=>{i(C=>C&&{...C,[S]:N}),o(null)},[]),f=j.useCallback((S,N)=>{i(C=>{if(!C)return C;const T=C.domains[S]??{enabled:!0};return{...C,domains:{...C.domains,[S]:{...T,...N}}}}),o(null)},[]),h=j.useCallback(async()=>{if(!(!a||!e)){o(null);try{await t({...e,notifications:a}),o({type:"success",text:"Notification settings saved."})}catch{o({type:"error",text:"Failed to save notification settings."})}}},[a,e,t]);if(!a||!e)return null;const p=(r==null?void 0:r.domains)??[],m=e?a.enabled!==(((y=e.notifications)==null?void 0:y.enabled)??!0)||a.system_notifications!==(((x=e.notifications)==null?void 0:x.system_notifications)??!1)||a.default_mode!==(((b=e.notifications)==null?void 0:b.default_mode)??"banner")||JSON.stringify(a.domains)!==JSON.stringify(((w=e.notifications)==null?void 0:w.domains)??{}):!1;return d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:"Notifications"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(zv,{children:"Enabled"}),d.jsx(sb,{children:"Master switch for all notification types."})]}),d.jsx(ml,{checked:a.enabled,onCheckedChange:S=>c("enabled",S)})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(zv,{children:"System Notifications"}),d.jsx(sb,{children:"Show browser notifications when the tab is not focused."})]}),d.jsx(ml,{checked:a.system_notifications,onCheckedChange:S=>c("system_notifications",S),disabled:!a.enabled})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(zv,{children:"Default Mode"}),d.jsxs(hi,{value:a.default_mode,onValueChange:S=>c("default_mode",S),disabled:!a.enabled,children:[d.jsx(Ua,{className:"w-40",children:d.jsx(vi,{})}),d.jsxs(qa,{children:[d.jsx(Gr,{value:"banner",children:"Banner"}),d.jsx(Gr,{value:"summary",children:"Summary"})]})]}),d.jsx(sb,{children:"Banner shows as a pop-up overlay. Summary shows only in the notification panel."})]}),p.length>0&&d.jsxs("div",{className:"space-y-3 pt-2",children:[d.jsx(zv,{children:"Domain Notifications"}),d.jsx("div",{className:"space-y-3",children:p.map(S=>{const N=a.domains[S.domain]??{enabled:!0},C=N.enabled;return d.jsxs("div",{className:"flex items-center justify-between gap-3 py-1",children:[d.jsxs("div",{className:"space-y-0.5 flex-1 min-w-0",children:[d.jsx("span",{className:"text-sm text-on-surface",children:S.label}),d.jsx("p",{className:"text-[11px] text-on-surface-variant",children:S.types.map(T=>T.label).join(", ")})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.jsxs(hi,{value:N.mode??"default",onValueChange:T=>f(S.domain,{mode:T==="default"?void 0:T}),disabled:!a.enabled||!C,children:[d.jsx(Ua,{className:"w-[110px] h-8 text-xs",children:d.jsx(vi,{})}),d.jsxs(qa,{children:[d.jsx(Gr,{value:"default",children:"Default"}),d.jsx(Gr,{value:"banner",children:"Banner"}),d.jsx(Gr,{value:"summary",children:"Summary"})]})]}),d.jsx(ml,{checked:C,onCheckedChange:T=>f(S.domain,{enabled:T}),disabled:!a.enabled})]})]},S.domain)})})]})]}),d.jsxs("div",{className:"flex items-center gap-4 pt-2",children:[d.jsxs(Ae,{onClick:h,disabled:!m||n,size:"sm",children:[n?d.jsx(zn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save Notifications"]}),l&&d.jsx("span",{className:l.type==="success"?"font-sans text-sm text-primary":"font-sans text-sm text-tertiary",children:l.text})]})]})}const Pre=["debug","info","warn","error"],Bre=[{value:"ollama",label:"Ollama"},{value:"openai-compatible",label:"OpenAI-compatible"}],zre=[{value:"1500",label:"1.5K — Executive briefing"},{value:"5000",label:"5K — Deep onboarding"},{value:"10000",label:"10K — Full institutional"}];function FA(e){var t,n,r,a,i,l,o,c,f,h,p,m,y;return{daemonPort:e.daemon.port!=null?String(e.daemon.port):"",logLevel:e.daemon.log_level,logRetentionDays:String(e.daemon.log_retention_days),embeddingProvider:e.embedding.provider,embeddingModel:e.embedding.model,embeddingBaseUrl:e.embedding.base_url??"",contextDigestTier:String(((t=e.context)==null?void 0:t.digest_tier)??eD),contextPromptSearch:((n=e.context)==null?void 0:n.prompt_search)??!0,contextMaxSpores:String(((r=e.context)==null?void 0:r.prompt_max_spores)??tD),agentProviderType:((i=(a=e.agent)==null?void 0:a.provider)==null?void 0:i.type)??"",agentModel:((o=(l=e.agent)==null?void 0:l.provider)==null?void 0:o.model)??((c=e.agent)==null?void 0:c.model)??"",agentBaseUrl:((h=(f=e.agent)==null?void 0:f.provider)==null?void 0:h.base_url)??"",agentContextLength:((y=(m=(p=e.agent)==null?void 0:p.provider)==null?void 0:m.context_length)==null?void 0:y.toString())??""}}function Ire(e,t){var o,c,f;const n=!!((o=t.agent)!=null&&o.provider),r=e.agentProviderType!=="",a=r?{type:e.agentProviderType,...e.agentModel?{model:e.agentModel}:{},...e.agentBaseUrl?{base_url:e.agentBaseUrl}:{},...e.agentContextLength?{context_length:Number(e.agentContextLength)}:{}}:void 0;let i=(c=t.agent)==null?void 0:c.scheduled_tasks_enabled,l=(f=t.agent)==null?void 0:f.event_tasks_enabled;return r&&!n?(i=!0,l=!0):!r&&n&&(i=!1,l=!1),{...t,agent:{...t.agent,provider:a,model:void 0,scheduled_tasks_enabled:i,event_tasks_enabled:l}}}function Fre(e,t,n){switch(e){case"agent":return Ire(t,n);case"embedding":return{...n,embedding:{...n.embedding,provider:t.embeddingProvider,model:t.embeddingModel,base_url:t.embeddingBaseUrl!==""?t.embeddingBaseUrl:void 0}};case"context":return{...n,context:{...n.context,digest_tier:Hb(t.contextDigestTier,eD),prompt_search:t.contextPromptSearch,prompt_max_spores:Hb(t.contextMaxSpores,tD)}};case"project":return{...n,daemon:{...n.daemon,port:t.daemonPort!==""?Number(t.daemonPort):null,log_level:t.logLevel,log_retention_days:Number(t.logRetentionDays)}}}}const Ure={agent:["agentProviderType","agentModel","agentBaseUrl","agentContextLength"],embedding:["embeddingProvider","embeddingModel","embeddingBaseUrl"],context:["contextDigestTier","contextPromptSearch","contextMaxSpores"],project:["daemonPort","logLevel","logRetentionDays"]};function Iv(e,t,n){return Ure[e].some(r=>t[r]!==n[r])}function ii({children:e,hint:t}){return d.jsxs("label",{className:"font-sans text-sm font-medium text-on-surface",children:[e,t&&d.jsxs("span",{className:"ml-1 font-sans text-xs text-on-surface-variant font-normal",children:["(",t,")"]})]})}function Fv({children:e}){return d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:e})}function Uv({dirty:e,isSaving:t,showMessage:n,message:r,onSave:a}){return d.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[d.jsxs(Ae,{onClick:a,disabled:!e||t,size:"sm",children:[t?d.jsx(zn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Save"]}),n&&r&&d.jsx("span",{className:r.type==="success"?"font-sans text-xs text-primary":"font-sans text-xs text-tertiary",children:r.text})]})}function qre(){const{config:e,isLoading:t,saveConfig:n,isSaving:r}=Od(),{data:a}=Vp(),{restart:i}=V1(),{data:l,isPending:o}=s5(),c=l5(),f=j.useRef(!1),[h,p]=j.useState(null);e&&!f.current&&(f.current=!0,h===null&&p(FA(e)));const[m,y]=j.useState(null),[x,b]=j.useState("idle"),[w,S]=j.useState(""),{data:N}=_re((h==null?void 0:h.embeddingProvider)??null,(h==null?void 0:h.embeddingBaseUrl)||void 0,"embedding"),C=(N==null?void 0:N.models)??[];j.useEffect(()=>{var I,V;if(!h||h.agentProviderType===""||h.agentModel!=="")return;const U=(V=(I=l==null?void 0:l.providers.find(K=>K.type===h.agentProviderType))==null?void 0:I.models)==null?void 0:V[0];U&&p(K=>K&&{...K,agentModel:U})},[h,l]);const T=j.useMemo(()=>e?FA(e):null,[e]),R=!!(h&&T&&Iv("agent",h,T)),A=!!(h&&T&&Iv("embedding",h,T)),D=!!(h&&T&&Iv("context",h,T)),O=!!(h&&T&&Iv("project",h,T)),L=j.useCallback((U,I)=>{p(V=>V&&{...V,[U]:I}),y(null)},[]),M=j.useCallback(async U=>{if(!(!h||!e)){y(null);try{await n(Fre(U,h,e)),y({section:U,type:"success",text:"Saved. Restarting daemon..."});try{await i()}catch{y({section:U,type:"success",text:"Saved. Daemon restart may require manual action."})}}catch{y({section:U,type:"error",text:"Failed to save."})}}},[h,e,n,i]),P=j.useCallback(async()=>{if(h){b("testing"),S("");try{const U=new URLSearchParams({provider:h.embeddingProvider,type:"embedding"});h.embeddingBaseUrl&&U.set("base_url",h.embeddingBaseUrl);const V=(await lt(`/models?${U.toString()}`)).models.length;b("success"),S(`Connected -- ${V} model${V!==1?"s":""} available.`)}catch(U){b("error"),S(U instanceof Error?U.message:"Connection failed.")}}},[h]),z=j.useCallback(()=>{!h||!h.agentProviderType||c.mutate({type:h.agentProviderType,...h.agentBaseUrl?{base_url:h.agentBaseUrl}:{}})},[h,c]);if(t||!h||!e)return d.jsxs("div",{className:"p-6",children:[d.jsx(wi,{title:"Settings"}),d.jsx("p",{className:"font-sans text-sm text-on-surface-variant mt-2",children:"Loading..."})]});const H=(a==null?void 0:a.vault.name)??e.embedding.provider,$=(l==null?void 0:l.providers)??[];return d.jsxs("div",{className:"p-6",children:[d.jsx(wi,{title:"Settings",subtitle:"Vault configuration and daemon settings"}),d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:"Myco Agent"}),h.agentProviderType===""?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:"No provider configured -- data collection is active. Configure a provider to enable the intelligence pipeline."}):null,d.jsx(iS,{providerType:h.agentProviderType,model:h.agentModel,baseUrl:h.agentBaseUrl,contextLength:h.agentContextLength,providers:$,isLoadingProviders:o,onProviderChange:U=>{var V;L("agentProviderType",U);const I=$.find(K=>K.type===U);L("agentModel",((V=I==null?void 0:I.models)==null?void 0:V[0])??""),L("agentBaseUrl",(I==null?void 0:I.baseUrl)??""),L("agentContextLength",""),c.reset()},onModelChange:U=>L("agentModel",U),onBaseUrlChange:U=>{L("agentBaseUrl",U),c.reset()},onContextLengthChange:U=>L("agentContextLength",U)}),h.agentProviderType!==""&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[d.jsxs(Ae,{type:"button",variant:"ghost",size:"sm",onClick:z,disabled:c.isPending,children:[c.isPending?d.jsx(zn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Test Connection"]}),c.isSuccess&&c.data.ok&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-primary",children:[d.jsx(kb,{className:"h-4 w-4"}),"Connected — ",c.data.latency_ms,"ms"]}),c.isSuccess&&!c.data.ok&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-tertiary",children:[d.jsx(yo,{className:"h-4 w-4"}),c.data.error??"Connection failed."]}),c.isError&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-tertiary",children:[d.jsx(yo,{className:"h-4 w-4"}),c.error.message]})]}),d.jsx(Ae,{type:"button",variant:"ghost",size:"sm",onClick:()=>{L("agentProviderType",""),L("agentModel",""),L("agentBaseUrl",""),L("agentContextLength",""),c.reset()},className:"text-xs text-on-surface-variant",children:"Clear provider"})]}),d.jsx(Uv,{dirty:R,isSaving:r,showMessage:(m==null?void 0:m.section)==="agent",message:m,onSave:()=>M("agent")})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-ochre",children:[d.jsx(St,{children:"Embedding"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Provider"}),d.jsxs(hi,{value:h.embeddingProvider,onValueChange:U=>{L("embeddingProvider",U),b("idle"),S("")},children:[d.jsx(Ua,{children:d.jsx(vi,{})}),d.jsx(qa,{children:Bre.map(U=>d.jsx(Gr,{value:U.value,children:U.label},U.value))})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Model"}),C.length>0?d.jsxs(hi,{value:h.embeddingModel,onValueChange:U=>L("embeddingModel",U),children:[d.jsx(Ua,{children:d.jsx(vi,{placeholder:"Select a model"})}),d.jsx(qa,{children:C.map(U=>d.jsx(Gr,{value:U,children:d.jsx("span",{className:"font-mono text-sm",children:U})},U))})]}):d.jsx(fn,{placeholder:"bge-m3",value:h.embeddingModel,onChange:U=>L("embeddingModel",U.target.value)})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{hint:"optional",children:"Base URL"}),d.jsx(fn,{type:"url",placeholder:"http://localhost:11434",value:h.embeddingBaseUrl,onChange:U=>{L("embeddingBaseUrl",U.target.value),b("idle"),S("")}})]}),d.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[d.jsxs(Ae,{type:"button",variant:"ghost",size:"sm",onClick:P,disabled:x==="testing",children:[x==="testing"?d.jsx(zn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Test Connection"]}),x==="success"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-primary",children:[d.jsx(kb,{className:"h-4 w-4"}),w]}),x==="error"&&d.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-tertiary",children:[d.jsx(yo,{className:"h-4 w-4"}),w]})]})]}),d.jsx(Uv,{dirty:A,isSaving:r,showMessage:(m==null?void 0:m.section)==="embedding",message:m,onSave:()=>M("embedding")})]})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-ochre",children:[d.jsx(St,{children:"Context Injection"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Digest Tier"}),d.jsxs(hi,{value:h.contextDigestTier,onValueChange:U=>L("contextDigestTier",U),children:[d.jsx(Ua,{children:d.jsx(vi,{})}),d.jsx(qa,{children:zre.map(U=>d.jsx(Gr,{value:U.value,children:U.label},U.value))})]}),d.jsx(Fv,{children:"Token budget for digest context injected at session start."})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(ii,{children:"Prompt Search"}),d.jsx(Fv,{children:"Search vault for relevant observations on each prompt."})]}),d.jsx(ml,{checked:h.contextPromptSearch,onCheckedChange:U=>L("contextPromptSearch",U)})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Max Spores per Prompt"}),d.jsx(fn,{type:"number",min:"0",max:"10",placeholder:"3",value:h.contextMaxSpores,onChange:U=>L("contextMaxSpores",U.target.value)}),d.jsx(Fv,{children:"Maximum observations injected per prompt. Lower = leaner context."})]})]}),d.jsx(Uv,{dirty:D,isSaving:r,showMessage:(m==null?void 0:m.section)==="context",message:m,onSave:()=>M("context")})]}),d.jsx(Lre,{}),d.jsx(Ore,{}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[d.jsx(St,{children:"Project"}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Vault Name"}),d.jsx(fn,{value:H,readOnly:!0,disabled:!0,className:"text-on-surface-variant bg-surface-container-lowest"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Daemon Port"}),d.jsx(fn,{type:"number",placeholder:"Auto",value:h.daemonPort,onChange:U=>L("daemonPort",U.target.value)}),d.jsx(Fv,{children:"Leave blank to use a random available port."})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Log Level"}),d.jsxs(hi,{value:h.logLevel,onValueChange:U=>L("logLevel",U),children:[d.jsx(Ua,{children:d.jsx(vi,{})}),d.jsx(qa,{children:Pre.map(U=>d.jsx(Gr,{value:U,children:U},U))})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx(ii,{children:"Log Retention (days)"}),d.jsx(fn,{type:"number",min:1,max:365,className:"w-24",value:h.logRetentionDays,onChange:U=>L("logRetentionDays",U.target.value)})]})]}),d.jsx(Uv,{dirty:O,isSaving:r,showMessage:(m==null?void 0:m.section)==="project",message:m,onSave:()=>M("project")})]})]})]})}function Vre(){return Qr({queryKey:["embedding-details"],queryFn:({signal:e})=>lt("/embedding/details",{signal:e}),refetchInterval:Sr.STATS,pollCategory:"standard"})}function Hre(){return Qr({queryKey:["database-details"],queryFn:({signal:e})=>lt("/database/details",{signal:e}),refetchInterval:Sr.STATS,pollCategory:"standard"})}const $re=100,UA=2e3,Gre=40;function Kre(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=Gre}function m5(e){const[t,n]=j.useState([]),[r,a]=j.useState(void 0),[i,l]=j.useState(!0),[o,c]=j.useState(!1),f=j.useRef(null),h=j.useRef(i);h.current=i;const p=j.useRef(r);p.current=r;const{data:m}=Qr({queryKey:["logs",e],queryFn:({signal:w})=>{const S=new URLSearchParams({limit:String($re),category:e});return p.current&&S.set("since",p.current),lt(`/logs?${S.toString()}`,{signal:w})},refetchInterval:Sr.LOGS,pollCategory:"standard"});j.useEffect(()=>{m!=null&&m.entries.length&&(n(w=>{let S;if(m.cursor_reset){const N=new Set(w.map(T=>`${T.timestamp}|${T.message}`)),C=m.entries.filter(T=>!N.has(`${T.timestamp}|${T.message}`));S=C.length?[...w,...C]:w}else S=[...w,...m.entries];return S.length>UA?S.slice(-UA):S}),a(m.cursor),h.current||c(!0))},[m]),j.useEffect(()=>{!i||!f.current||(f.current.scrollTop=f.current.scrollHeight,c(!1))},[t,i]);const y=j.useCallback(()=>{const w=f.current;w&&(Kre(w)?(l(!0),c(!1)):l(!1))},[]),x=j.useCallback(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight,l(!0),c(!1))},[]);return{filteredEntries:j.useMemo(()=>{const w=fp.debug;return t.filter(S=>fp[S.level]>=w)},[t]),scrollRef:f,autoScroll:i,setAutoScroll:l,hasNewEntries:o,handleScroll:y,scrollToBottom:x}}function Yre(e){return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Xre(){const[e,t]=j.useState([]),[n,r]=j.useState(!1),[a,i]=j.useState(!1),[l,o]=j.useState(null),[c,f]=j.useState(null),[h,p]=j.useState(""),[m,y]=j.useState(!1);j.useEffect(()=>{lt("/backup/config").then(C=>{p(C.dir??"")}).catch(()=>{})},[]);const x=j.useCallback(async()=>{y(!0);try{await hc("/backup/config",{dir:h||null}),o({type:"success",text:h?"Backup directory updated. Restart daemon to apply.":"Backup directory reset to default. Restart daemon to apply."})}catch{o({type:"error",text:"Failed to save backup directory."})}finally{y(!1)}},[h]),b=j.useCallback(async()=>{try{const C=await lt("/backups");t(C.backups),r(!0)}catch(C){o({type:"error",text:`Failed to load backups: ${C.message}`})}},[]);!n&&!a&&(i(!0),b().finally(()=>i(!1)));async function w(){o(null),f(null);try{const C=await nn("/backup");o({type:"success",text:`Backup created: ${C.machine_id} (${xo(C.size_bytes)})`}),await b()}catch(C){o({type:"error",text:`Backup failed: ${C.message}`})}}async function S(C){o(null),f(null);try{const T=await nn("/restore/preview",{machine_id:C});f(T)}catch(T){o({type:"error",text:`Preview failed: ${T.message}`})}}async function N(C){o(null),f(null);try{const T=await nn("/restore",{machine_id:C});o({type:"success",text:`Restored ${T.total_restored} records, skipped ${T.total_skipped} duplicates`})}catch(T){o({type:"error",text:`Restore failed: ${T.message}`})}}return d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Az,{className:"h-4 w-4 text-primary"}),d.jsx(St,{children:"Backup & Restore"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:b,children:[d.jsx(gl,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]}),d.jsxs(Ae,{variant:"default",size:"sm",onClick:w,children:[d.jsx(Sz,{className:"mr-1.5 h-3.5 w-3.5"}),"Backup Now"]})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("label",{className:"font-sans text-xs text-on-surface-variant flex items-center gap-1.5",children:[d.jsx(jz,{className:"h-3.5 w-3.5"}),"Backup Directory"]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:h,onChange:C=>p(C.target.value),placeholder:".myco/backups",className:"flex-1 bg-surface-container text-on-surface font-mono text-sm rounded px-3 py-1.5 outline-none border border-outline-variant/15 focus:border-primary/40 placeholder:text-on-surface-variant/50"}),d.jsx(Ae,{variant:"ghost",size:"sm",onClick:x,disabled:m,children:m?"Saving...":"Save"})]}),d.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Override where backups are stored. Leave empty for default (.myco/backups). Supports ~ for home directory. Useful for network shares or git-tracked directories."})]}),l&&d.jsx("p",{className:ke("font-sans text-sm",l.type==="success"?"text-primary":"text-tertiary"),children:l.text}),e.length>0?d.jsx("div",{className:"space-y-2",children:e.map(C=>d.jsxs("div",{className:ke("flex items-center justify-between rounded-md px-4 py-3","bg-surface-container-lowest transition-colors"),children:[d.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[d.jsx("span",{className:"font-mono text-sm text-on-surface truncate",children:C.machine_id}),d.jsx(wt,{variant:"secondary",children:xo(C.size_bytes)}),d.jsx("span",{className:"text-xs text-on-surface-variant",children:Yre(C.modified_at)})]}),d.jsxs("div",{className:"flex gap-2 flex-shrink-0 ml-3",children:[d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>S(C.machine_id),children:"Preview"}),d.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>N(C.machine_id),children:[d.jsx(Kz,{className:"mr-1.5 h-3.5 w-3.5"}),"Restore"]})]})]},C.machine_id))}):n?d.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:'No backups yet. Click "Backup Now" to create one.'}):null,c&&d.jsxs(Ge,{level:"lowest",className:"p-4 space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(St,{children:"Restore Preview"}),d.jsx(wt,{variant:"outline",children:c.machine_id})]}),d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Restore preview",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Table"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"New"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Existing"})]})}),d.jsx("tbody",{children:c.tables.map((C,T)=>d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",T%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-2 pr-4",children:C.table}),d.jsx("td",{className:"py-2 pr-4 text-right",children:C.new>0?d.jsx("span",{className:"text-primary",children:C.new}):0}),d.jsx("td",{className:"py-2 text-right text-on-surface-variant",children:C.existing})]},C.table))})]})}),d.jsxs("div",{className:"flex gap-4 font-sans text-sm text-on-surface-variant",children:[d.jsxs("span",{children:["New: ",d.jsx("strong",{className:"text-primary",children:c.total_new})]}),d.jsxs("span",{children:["Existing: ",d.jsx("strong",{children:c.total_existing})]})]})]})]})}const qv=500,qA=6e4;function Qre(e){return e?new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"}function Wre(){const{data:e}=rD(),t=sI(),n=lI(),r=oI(),[a,i]=j.useState("idle"),[l,o]=j.useState(null);j.useEffect(()=>{if(!(e!=null&&e.restarting)||a!=="idle")return;i("restarting");const b=Date.now()+qA;let w=!1;const S=async()=>{if(!(w||Date.now()>b)){try{if((await fetch("/health")).ok){window.location.reload();return}}catch{}w||setTimeout(S,qv)}},N=setTimeout(S,qv);return()=>{w=!0,clearTimeout(N)}},[e==null?void 0:e.restarting,a]);const c=j.useCallback(async()=>{i("applying"),o(null);try{await n.mutateAsync(),i("restarting");const b=Date.now()+qA;await new Promise((w,S)=>{const N=async()=>{if(Date.now()>b){S(new Error("timeout"));return}try{if((await fetch("/health")).ok){w();return}}catch{}setTimeout(N,qv)};setTimeout(N,qv)}),window.location.reload()}catch(b){i("error");const w=b.message==="timeout"?"Daemon did not restart within the expected time. Check the terminal.":b.message;o(w)}},[n]),f=j.useCallback(()=>{t.mutate()},[t]),h=j.useCallback(b=>{r.mutate(b)},[r]);if(!e)return null;const p=t.isPending,m=a==="applying"||a==="restarting",y=e.update_available===!0,x=e.channel??"stable";return e.exempt?d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(qz,{className:"h-4 w-4 text-primary"}),d.jsx(St,{children:"Updates"})]}),d.jsxs("p",{className:"font-sans text-sm text-on-surface-variant",children:["Updates are disabled in development mode."," ",d.jsx("span",{className:"font-mono text-xs text-outline",children:e.running_version})]})]}):d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Nb,{className:ke("h-4 w-4",y?"text-secondary":"text-primary")}),d.jsx(St,{children:"Updates"})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"font-mono text-xs text-outline",children:e.running_version}),y&&e.latest_version&&d.jsx(wt,{variant:"warning",children:e.latest_version})]})]}),d.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[y?d.jsx(Ae,{variant:"default",size:"sm",onClick:c,disabled:m,children:m?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),a==="restarting"?"Restarting…":"Updating…"]}):d.jsxs(d.Fragment,{children:[d.jsx(Nb,{className:"mr-1.5 h-3.5 w-3.5"}),"Update & Restart"]})}):d.jsxs("div",{className:"flex items-center gap-1.5 text-primary",children:[d.jsx(Td,{className:"h-4 w-4"}),d.jsx("span",{className:"font-sans text-sm",children:"Up to date"})]}),d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:f,disabled:p||m,children:[d.jsx(gl,{className:ke("mr-1.5 h-3.5 w-3.5",p&&"animate-spin")}),"Check Now"]})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"flex items-center gap-1",children:iI.map(b=>d.jsx(Ae,{variant:x===b?"default":"ghost",className:"text-xs capitalize h-6 px-2",onClick:()=>h(b),disabled:r.isPending||m,children:b},b))}),d.jsxs("span",{className:"font-sans text-xs text-on-surface-variant",children:["Checked: ",Qre(e.last_check)]})]}),(a==="error"||e.error)&&d.jsxs("div",{className:"flex items-start gap-2 text-tertiary",children:[d.jsx(Dr,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),d.jsx("span",{className:"font-sans text-sm",children:l??e.error})]})]})}function Zre(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0");return n+":"+r+":"+a}function g5({entry:e}){return d.jsxs("tr",{className:"hover:bg-surface-container-high/30 transition-colors",children:[d.jsx("td",{className:"whitespace-nowrap py-1.5 pl-4 pr-3 text-on-surface-variant/60 align-top w-[68px]",children:Zre(e.timestamp)}),d.jsx("td",{className:"whitespace-nowrap py-1.5 pr-3 align-top w-[20px]",children:d.jsx("div",{className:ke("h-2 w-2 rounded-full mt-1",U1(e.level))})}),d.jsx("td",{className:"whitespace-nowrap py-1.5 pr-3 align-top w-[54px]",children:d.jsx(wt,{variant:nD(e.level),className:"px-1.5 py-0 text-[10px] uppercase",children:e.level})}),d.jsx("td",{className:"py-1.5 pr-4 text-on-surface align-top break-words",children:e.message})]})}const Jre=["sessions","spores","plans","artifacts","skill_records"],eae="embedding",tae="database",nae=15,rae="insufficient_disk_space",zp=20,aae=[{id:"embedding",label:"Embedding"},{id:"database",label:"Database"},{id:"system",label:"System"}],iae=new Set(["embedding","database","system"]),y5="tab";function sae(){const t=new URLSearchParams(window.location.search).get(y5);return t&&iae.has(t)?t:"embedding"}function lae(e){const t=new URLSearchParams;e!=="embedding"&&t.set(y5,e);const n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.replaceState(null,"",r)}function oae(e){return e.provider.available?Object.values(e.pending).some(n=>n>0)?"processing":"idle":"unavailable"}function uae(e){return e.provider.available?Object.values(e.pending).some(n=>n>0)?"bg-secondary":"bg-primary":"bg-tertiary"}function cae(e){if(e<=0)return"now";const t=Math.floor(e/1e3);if(t<60)return t+"s";const n=Math.floor(t/60);return n<60?n+"m":Math.floor(n/60)+"h"}function fae({data:e}){return d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Embedding namespace breakdown",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Namespace"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Embedded"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Pending"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Stale"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Total"})]})}),d.jsx("tbody",{children:Jre.map((t,n)=>{const r=e.by_namespace[t],a=(r==null?void 0:r.embedded)??0,i=(r==null?void 0:r.stale)??0,l=e.pending[t]??0,o=a+l;return d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",n%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-2.5 pr-4",children:t}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:a}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:l>0?d.jsx("span",{className:"text-secondary",children:l}):l}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:i>0?d.jsx("span",{className:"text-tertiary",children:i}):i}),d.jsx("td",{className:"py-2.5 text-right",children:o})]},t)})})]})})}function dae({tables:e}){const t=[...e].sort((n,r)=>r.rows-n.rows);return d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Database table breakdown",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Table"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Rows"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Indexes"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Type"})]})}),d.jsx("tbody",{children:t.map((n,r)=>d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",r%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-2.5 pr-4",children:n.name}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:n.rows.toLocaleString()}),d.jsx("td",{className:"py-2.5 pr-4 text-right",children:n.index_count}),d.jsx("td",{className:"py-2.5",children:n.is_fts?d.jsx(wt,{variant:"outline",className:"px-1.5 py-0 text-[10px] uppercase",children:"FTS5"}):d.jsx("span",{className:"text-on-surface-variant/60",children:"btree"})})]},n.name))})]})})}function hae({indexes:e}){const[t,n]=j.useState(!1),r=e.filter(i=>i.type==="btree").length,a=e.filter(i=>i.type==="auto").length;return d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Indexes"}),d.jsx("button",{type:"button",onClick:()=>n(i=>!i),className:"font-sans text-xs text-on-surface-variant hover:text-on-surface transition-colors",children:t?"Hide":"Show all "+e.length})]}),d.jsxs("p",{className:"font-sans text-sm text-on-surface-variant",children:[r," btree ",r===1?"index":"indexes",a>0&&d.jsxs(d.Fragment,{children:[" · ",a," auto-",a===1?"index":"indexes"]})]}),t&&d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"w-full font-mono text-xs","aria-label":"All database indexes",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"text-left text-on-surface-variant",children:[d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"Name"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"Table"}),d.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"Type"}),d.jsx("th",{className:"pb-2 font-sans font-medium text-[10px] uppercase tracking-widest",scope:"col",children:"SQL"})]})}),d.jsx("tbody",{children:e.map((i,l)=>d.jsxs("tr",{className:ke("transition-colors hover:bg-surface-container-high/50",l%2===1?"bg-surface-container-low/30":""),children:[d.jsx("td",{className:"py-1.5 pr-4",children:i.name}),d.jsx("td",{className:"py-1.5 pr-4 text-on-surface-variant",children:i.table}),d.jsx("td",{className:"py-1.5 pr-4 text-on-surface-variant uppercase",children:i.type}),d.jsx("td",{className:"py-1.5 text-on-surface-variant/70 truncate max-w-[300px]",title:i.sql??"",children:i.sql??"—"})]},i.name))})]})})]})}function vae({details:e,onActionResult:t}){const{config:n,saveConfig:r,isSaving:a}=Od(),i=jn(),[l,o]=j.useState(!1);if(!n)return null;const c=n.maintenance.auto_optimize,f=n.maintenance.auto_optimize_interval_hours,h=e.last_optimize_at?new Date(e.last_optimize_at).getTime():null,p=h!==null?h+f*so*1e3-Date.now():0;async function m(x){try{await r({...n,maintenance:{...n.maintenance,...x}})}catch(b){t({type:"error",text:"Config save failed: "+b.message})}}async function y(){o(!0);try{const x=await nn("/database/optimize"),b=x.actions_failed.length;t({type:b>0?"error":"success",text:"Optimize complete: "+x.actions_completed.length+" steps, "+b+" failed ("+x.duration_ms+"ms)"}),i.invalidateQueries({queryKey:["database-details"]})}catch(x){t({type:"error",text:"Error: "+x.message})}finally{o(!1)}}return d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsx(St,{children:"Scheduled Maintenance"}),d.jsxs("div",{className:"flex flex-wrap items-center gap-3 font-sans text-sm",children:[d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:c,disabled:a,onChange:x=>m({auto_optimize:x.target.checked}),className:"h-4 w-4 accent-primary"}),d.jsx("span",{className:"text-on-surface",children:"Auto-optimize"})]}),d.jsx("span",{className:"text-on-surface-variant",children:"every"}),d.jsxs("select",{value:f,disabled:!c||a,onChange:x=>m({auto_optimize_interval_hours:Number(x.target.value)}),className:"rounded-md border border-outline bg-surface-container px-2 py-1 text-on-surface text-sm",children:[d.jsx("option",{value:6,children:"6 hours"}),d.jsx("option",{value:12,children:"12 hours"}),d.jsx("option",{value:24,children:"24 hours"}),d.jsx("option",{value:72,children:"3 days"}),d.jsx("option",{value:168,children:"7 days"}),d.jsx("option",{value:720,children:"30 days"})]})]}),d.jsxs("p",{className:"font-sans text-sm text-on-surface-variant",children:["Last run: ",e.last_optimize_at?nm(e.last_optimize_at):"never",c&&h!==null&&d.jsxs(d.Fragment,{children:[" · Next: ",cae(p)]})]}),d.jsxs(Ae,{variant:"secondary",size:"sm",onClick:y,disabled:l,children:[d.jsx(rs,{className:"mr-2 h-4 w-4"}),l?"Running...":"Run now"]})]})}function pae({onActionResult:e}){const t=jn(),[n,r]=j.useState(!1);async function a(){r(!0);try{const o=await nn("/database/integrity-check");o.status==="ok"?e({type:"success",text:"Integrity check OK ("+o.duration_ms+"ms)"}):e({type:"error",text:"Integrity issues: "+o.issues.length+" problems, "+o.fk_violations+" FK violations"}),t.invalidateQueries({queryKey:["database-details"]})}catch(o){e({type:"error",text:"Error: "+o.message})}finally{r(!1)}}async function i(){if(confirm("VACUUM rebuilds the entire DB file and may take a while. Continue?")){r(!0);try{const o=await nn("/database/vacuum");e({type:"success",text:"Vacuum complete: freed "+xo(o.freed_bytes)+" in "+o.duration_ms+"ms"}),t.invalidateQueries({queryKey:["database-details"]})}catch(o){if(o instanceof JR){const c=o.body;if((c==null?void 0:c.error)===rae){e({type:"error",text:"Insufficient disk: need "+xo(c.required_bytes??0)+", have "+xo(c.free_bytes??0)});return}}e({type:"error",text:"Error: "+o.message})}finally{r(!1)}}}async function l(){if(confirm("REINDEX rebuilds all indexes. Continue?")){r(!0);try{const o=await nn("/database/reindex");e({type:"success",text:"Reindex complete ("+o.duration_ms+"ms)"}),t.invalidateQueries({queryKey:["database-details"]})}catch(o){e({type:"error",text:"Error: "+o.message})}finally{r(!1)}}}return d.jsxs(Ge,{level:"low",className:"p-6 space-y-3",children:[d.jsx(St,{children:"Actions"}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:a,disabled:n,children:[d.jsx(gl,{className:"mr-2 h-4 w-4"}),"Integrity check"]}),d.jsxs(Ae,{variant:"destructive",size:"sm",onClick:i,disabled:n,children:[d.jsx(as,{className:"mr-2 h-4 w-4"}),"Vacuum"]}),d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:l,disabled:n,children:[d.jsx(qp,{className:"mr-2 h-4 w-4"}),"Reindex"]})]})]})}function mae({data:e}){const t=jn(),[n,r]=j.useState(null),[a,i]=j.useState([]);j.useEffect(()=>{i(C=>{const T=[...C,e.total];return T.length>zp?T.slice(-zp):T})},[e]);const{filteredEntries:l,scrollRef:o,autoScroll:c,setAutoScroll:f,hasNewEntries:h,handleScroll:p,scrollToBottom:m}=m5(eae);async function y(){r(null);try{const C=await nn("/embedding/reembed-stale");r({type:"success",text:`Re-embedded ${C.reembedded} stale vectors`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}async function x(){if(confirm("This will re-embed all vectors. Continue?")){r(null);try{const C=await nn("/embedding/rebuild");r({type:"success",text:`Rebuild queued: ${C.queued} vectors to re-embed`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}}async function b(){r(null);try{const C=await nn("/embedding/clean-orphans");r({type:"success",text:`Cleaned ${C.orphans_cleaned} orphan vectors`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}async function w(){r(null);try{const C=await nn("/embedding/reconcile");r({type:"success",text:`Reconcile complete: ${C.embedded} embedded, ${C.orphans_cleaned} orphans cleaned (${C.duration_ms}ms)`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(C){r({type:"error",text:`Error: ${C.message}`})}}const S=Object.values(e.pending).reduce((C,T)=>C+T,0),N=Object.values(e.by_namespace).reduce((C,T)=>C+T.stale,0);return d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-4 font-sans text-sm",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(P1,{className:"h-4 w-4 text-primary"}),d.jsx("span",{className:"text-on-surface-variant",children:"Provider"}),d.jsx("span",{className:"font-mono text-on-surface",children:e.provider.name})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-on-surface-variant",children:"Model"}),d.jsx("span",{className:"font-mono text-xs text-on-surface truncate max-w-[200px]",title:e.provider.model,children:e.provider.model})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:ke("h-2 w-2 rounded-full",uae(e))}),d.jsx("span",{className:"text-on-surface-variant capitalize",children:oae(e)})]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[d.jsx(Kt,{label:"Total Vectors",value:String(e.total),sparklineData:a,accent:"sage"}),d.jsx(Kt,{label:"Pending",value:String(S),accent:S>0?"ochre":"outline"}),d.jsx(Kt,{label:"Stale",value:String(N),accent:N>0?"terracotta":"outline"})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsx(St,{children:"Namespace Breakdown"}),d.jsx(fae,{data:e})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-3",children:[d.jsx(St,{children:"Actions"}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:y,children:[d.jsx(gl,{className:"mr-2 h-4 w-4"}),"Re-embed stale"]}),d.jsxs(Ae,{variant:"ghost",size:"sm",onClick:b,children:[d.jsx(as,{className:"mr-2 h-4 w-4"}),"Clean orphans"]}),d.jsxs(Ae,{variant:"secondary",size:"sm",onClick:w,children:[d.jsx(rs,{className:"mr-2 h-4 w-4"}),"Force reconcile"]}),d.jsxs(Ae,{variant:"destructive",size:"sm",onClick:x,children:[d.jsx(qp,{className:"mr-2 h-4 w-4"}),"Rebuild all"]})]}),n&&d.jsx("p",{className:ke("font-sans text-sm",n.type==="success"?"text-primary":"text-tertiary"),children:n.text})]}),d.jsxs(Ge,{level:"low",className:"flex flex-col overflow-hidden",children:[d.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[d.jsx(St,{children:"Activity Log"}),d.jsxs(Ae,{size:"sm",variant:c?"default":"ghost",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>{c?f(!1):m()},title:c?"Pause auto-scroll":"Resume auto-scroll",children:[c?d.jsx(B1,{className:"h-3 w-3"}):d.jsx(rs,{className:"h-3 w-3"}),c?"Pause":"Resume"]})]}),d.jsxs("div",{className:"relative flex-1 p-0",children:[d.jsx("div",{ref:o,onScroll:p,className:"h-64 overflow-y-auto font-mono text-xs bg-surface-container-lowest",children:l.length===0?d.jsx("div",{className:"flex h-32 items-center justify-center font-sans text-on-surface-variant",children:"No embedding log entries"}):d.jsx("table",{className:"w-full border-collapse","aria-label":"Embedding activity log",children:d.jsx("tbody",{children:l.map((C,T)=>d.jsx(g5,{entry:C},`${C.timestamp}-${T}`))})})}),h&&!c&&d.jsxs("button",{type:"button",onClick:m,className:ke("absolute bottom-4 left-1/2 -translate-x-1/2","flex items-center gap-1.5 rounded-full","bg-surface-container-high px-3 py-1.5 text-xs font-medium shadow-ambient","text-on-surface-variant transition-colors hover:text-on-surface"),children:[d.jsx(HR,{className:"h-3 w-3"}),"New entries below"]})]})]})]})}function gae(){return d.jsxs("div",{className:"space-y-6",children:[d.jsx(Wre,{}),d.jsx(Xre,{})]})}function yae(){const{data:e,isLoading:t,isError:n,error:r}=Hre(),[a,i]=j.useState([]),[l,o]=j.useState(null);j.useEffect(()=>{e&&i(S=>{const N=[...S,e.file.size_bytes];return N.length>zp?N.slice(-zp):N})},[e]);const{filteredEntries:c,scrollRef:f,autoScroll:h,setAutoScroll:p,hasNewEntries:m,handleScroll:y,scrollToBottom:x}=m5(tae);if(t)return d.jsx("div",{className:"text-on-surface-variant",children:"Loading database details..."});if(n)return d.jsxs("div",{className:"text-tertiary",children:["Error: ",r.message]});if(!e)return null;const b=e.file.fragmentation_pct.toFixed(1)+"%",w=e.file.fragmentation_pct>nae?"ochre":"outline";return d.jsxs("div",{className:"space-y-6",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-4 font-sans text-sm",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(wz,{className:"h-4 w-4 text-primary"}),d.jsx("span",{className:"text-on-surface-variant",children:"Database"}),d.jsx("span",{className:"font-mono text-on-surface",children:"myco.db"})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-on-surface-variant",children:"Schema"}),d.jsxs("span",{className:"font-mono text-on-surface",children:["v",e.schema.version]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-on-surface-variant",children:"Journal"}),d.jsx("span",{className:"font-mono text-on-surface uppercase",children:e.schema.journal_mode})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"}),d.jsx("span",{className:"text-on-surface-variant",children:"healthy"})]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[d.jsx(Kt,{label:"Database Size",value:xo(e.file.size_bytes),sparklineData:a,accent:"sage"}),d.jsx(Kt,{label:"Fragmentation",value:b,accent:w}),d.jsx(Kt,{label:"WAL Size",value:xo(e.file.wal_size_bytes),accent:"outline"})]}),d.jsxs(Ge,{level:"low",className:"p-6 space-y-4",children:[d.jsx(St,{children:"Schema Breakdown"}),d.jsx(dae,{tables:e.tables})]}),d.jsx(hae,{indexes:e.indexes}),d.jsx(vae,{details:e,onActionResult:o}),d.jsx(pae,{onActionResult:o}),l&&d.jsx("p",{className:ke("font-sans text-sm",l.type==="success"?"text-primary":"text-tertiary"),children:l.text}),d.jsxs(Ge,{level:"low",className:"flex flex-col overflow-hidden",children:[d.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[d.jsx(St,{children:"Activity Log"}),d.jsxs(Ae,{size:"sm",variant:h?"default":"ghost",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>{h?p(!1):x()},title:h?"Pause auto-scroll":"Resume auto-scroll",children:[h?d.jsx(B1,{className:"h-3 w-3"}):d.jsx(rs,{className:"h-3 w-3"}),h?"Pause":"Resume"]})]}),d.jsxs("div",{className:"relative flex-1 p-0",children:[d.jsx("div",{ref:f,onScroll:y,className:"h-64 overflow-y-auto font-mono text-xs bg-surface-container-lowest",children:c.length===0?d.jsx("div",{className:"flex h-32 items-center justify-center font-sans text-on-surface-variant",children:"No database log entries"}):d.jsx("table",{className:"w-full border-collapse","aria-label":"Database activity log",children:d.jsx("tbody",{children:c.map((S,N)=>d.jsx(g5,{entry:S},S.timestamp+"-"+N))})})}),m&&!h&&d.jsxs("button",{type:"button",onClick:x,className:ke("absolute bottom-4 left-1/2 -translate-x-1/2","flex items-center gap-1.5 rounded-full","bg-surface-container-high px-3 py-1.5 text-xs font-medium shadow-ambient","text-on-surface-variant transition-colors hover:text-on-surface"),children:[d.jsx(HR,{className:"h-3 w-3"}),"New entries below"]})]})]})]})}const xae={embedding:"Embedding health, maintenance actions, and activity log",database:"Schema inspection, maintenance actions, and scheduled optimization",system:"Software updates and backup management"};function bae(){const{data:e,isLoading:t,isError:n,error:r}=Vre(),[a,i]=j.useState(sae),l=j.useCallback(o=>{const c=o;i(c),lae(c)},[]);return d.jsx(gw,{isLoading:t,error:n?r instanceof Error?r:new Error("Unable to reach daemon"):null,loadingText:"Loading operations...",children:e&&d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsx("div",{className:"px-6 pt-6",children:d.jsx(wi,{title:"Operations",subtitle:xae[a],tabs:aae,activeTab:a,onTabChange:l})}),d.jsx("div",{className:"flex-1 overflow-auto",children:d.jsxs("div",{className:"px-6 pb-6",children:[a==="embedding"&&d.jsx(mae,{data:e}),a==="database"&&d.jsx(yae,{}),a==="system"&&d.jsx(gae,{})]})})]})})}function wae(){return Qr({queryKey:["team-status"],queryFn:({signal:e})=>lt("/team/status",{signal:e}),refetchInterval:Sr.STATS,pollCategory:"standard"})}function Vv({label:e,value:t,mono:n=!0}){const[r,a]=j.useState(!1),i=j.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)})},[t]);return d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{className:"text-xs text-on-surface-variant",children:e}),d.jsxs("div",{className:"flex items-center gap-2 group",children:[d.jsx("span",{className:`text-sm text-on-surface break-all ${n?"font-mono":""}`,children:t}),d.jsx("button",{type:"button",onClick:i,className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy to clipboard",children:r?d.jsx(kd,{className:"h-3.5 w-3.5 text-primary"}):d.jsx(L1,{className:"h-3.5 w-3.5"})})]})]})}function VA({label:e,value:t}){const[n,r]=j.useState(!1),[a,i]=j.useState(!1),l=j.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)})},[t]),o=`${t.slice(0,8)}${"*".repeat(Math.max(0,t.length-12))}${t.slice(-4)}`;return d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{className:"text-xs text-on-surface-variant",children:e}),d.jsxs("div",{className:"flex items-center gap-2 group",children:[d.jsx("span",{className:"text-sm text-on-surface font-mono break-all",children:n?t:o}),d.jsx("button",{type:"button",onClick:()=>r(!n),className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface transition-opacity",title:n?"Hide":"Reveal",children:n?d.jsx(Ez,{className:"h-3.5 w-3.5"}):d.jsx(Cz,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button",onClick:l,className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy to clipboard",children:a?d.jsx(kd,{className:"h-3.5 w-3.5 text-primary"}):d.jsx(L1,{className:"h-3.5 w-3.5"})})]})]})}function Sae({onConnected:e}){const[t,n]=j.useState(""),[r,a]=j.useState(""),[i,l]=j.useState(null),[o,c]=j.useState(!1),f=async h=>{h.preventDefault(),l(null),c(!0);try{await nn("/team/connect",{url:t,api_key:r}),e()}catch(p){l(p instanceof Error?p.message:"Connection failed")}finally{c(!1)}};return d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-6",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[d.jsx(Xz,{className:"h-4 w-4 text-on-surface-variant"}),d.jsx(St,{children:"Connect to team"})]}),d.jsx("p",{className:"text-sm text-on-surface-variant mb-4",children:"Enter the URL and API key for your team's Cloudflare Worker to enable cross-machine knowledge sharing."}),d.jsxs("form",{onSubmit:f,className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-medium text-on-surface-variant mb-1",children:"Worker URL"}),d.jsx(fn,{type:"url",placeholder:"https://myco-team.your-account.workers.dev",value:t,onChange:h=>n(h.target.value),required:!0})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-xs font-medium text-on-surface-variant mb-1",children:"API Key"}),d.jsx(fn,{type:"password",placeholder:"your-api-key",value:r,onChange:h=>a(h.target.value),required:!0})]}),i&&d.jsx("p",{className:"text-sm text-tertiary",children:i}),d.jsx(Ae,{type:"submit",size:"sm",disabled:o||!t||!r,children:o?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Connecting..."]}):"Connect"})]})]})}function Eae({status:e}){const t=jn(),[n,r]=j.useState(!1),[a,i]=j.useState(!1),[l,o]=j.useState(null),[c,f]=j.useState(!1),[h,p]=j.useState(null),[m,y]=j.useState(!1),[x,b]=j.useState(null),[w,S]=j.useState(!1),[N,C]=j.useState(!1),[T,R]=j.useState(!1),A=async()=>{r(!0);try{await nn("/team/disconnect"),t.invalidateQueries({queryKey:["team-status"]})}finally{r(!1)}},D=j.useCallback(async()=>{i(!0),o(null);try{const M=await nn("/team/backfill");o(M.enqueued>0?`Enqueued ${M.enqueued} records for sync. They'll push on the next flush cycle.`:"All records are already synced or enqueued."),t.invalidateQueries({queryKey:["team-status"]})}catch{o("Backfill failed.")}finally{i(!1)}},[t]),O=j.useCallback(async()=>{f(!0),p(null);try{const M=await nn("/team/upgrade-worker");M.success?(p(`Worker updated to v${M.version}`),t.invalidateQueries({queryKey:["team-status"]})):p(M.error??"Upgrade failed")}catch(M){p(M instanceof Error?M.message:"Upgrade failed")}finally{f(!1)}},[t]),L=j.useCallback(async()=>{y(!0),b(null);try{const M=await nn("/team/retry-failed");b(M.retried>0?`Re-queued ${M.retried} record${M.retried>1?"s":""} for sync.`:"No failed records to retry."),t.invalidateQueries({queryKey:["team-status"]})}catch{b("Retry failed.")}finally{y(!1)}},[t]);return d.jsxs("div",{className:"space-y-4",children:[e.worker_update_available&&d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-4 border-l-2 border-l-ochre",children:[d.jsxs("div",{className:"flex items-center justify-between gap-4",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Nb,{className:"h-5 w-5 text-ochre flex-shrink-0"}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface",children:"Worker update available"}),d.jsxs("p",{className:"text-xs text-on-surface-variant",children:["Deployed: v",e.deployed_worker_version??"?"," — Local: v",e.package_version]})]})]}),d.jsx(Ae,{variant:"default",size:"sm",onClick:O,disabled:c,children:c?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Deploying..."]}):"Update Worker"})]}),h&&d.jsx("p",{className:"text-xs text-on-surface-variant mt-2",children:h})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[d.jsx(Kt,{label:"Status",value:e.healthy?"Connected":"Unhealthy",accent:e.healthy?"sage":"terracotta"}),d.jsx(Kt,{label:"Pending sync",value:String(e.pending_sync_count),accent:e.dead_letter_count>0?"terracotta":"outline",sublabel:e.dead_letter_count>0?`${e.dead_letter_count} failed`:void 0,href:"/logs?component=team-sync"}),d.jsx(Kt,{label:"Protocol",value:`v${e.sync_protocol_version}`,accent:"outline"}),d.jsx(Kt,{label:"Schema",value:`v${e.schema_version}`,accent:"outline"})]}),d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Team Credentials"}),d.jsx(wt,{variant:e.healthy?"default":"destructive",children:e.healthy?"healthy":"unhealthy"})]}),d.jsx("p",{className:"text-xs text-on-surface-variant",children:"Share these with teammates so they can connect from the Team page."}),d.jsxs("div",{className:"space-y-3",children:[e.worker_url&&d.jsx(Vv,{label:"Worker URL",value:e.worker_url}),e.api_key&&d.jsx(VA,{label:"API Key",value:e.api_key})]})]}),e.mcp_token&&e.mcp_endpoint&&d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Cloud MCP Endpoint"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>S(!w),className:"text-xs text-on-surface-variant hover:text-on-surface transition-colors",children:w?"Hide snippet":"Config snippet"}),d.jsx("button",{onClick:()=>C(!0),className:"text-xs text-on-surface-variant hover:text-terracotta-text transition-colors",children:"Rotate token"})]})]}),d.jsx("p",{className:"text-xs text-on-surface-variant",children:"Configure cloud agents with this endpoint to access project team intelligence."}),d.jsxs("div",{className:"space-y-3",children:[d.jsx(Vv,{label:"MCP URL",value:e.mcp_endpoint}),d.jsx(VA,{label:"MCP Access Token",value:e.mcp_token})]}),w&&(()=>{const M=JSON.stringify({mcp_servers:[{type:"url",url:e.mcp_endpoint,name:"myco",authorization_token:e.mcp_token}]},null,2);return d.jsxs("div",{className:"relative",children:[d.jsx("pre",{className:"text-xs bg-surface-container p-3 rounded-lg overflow-x-auto text-on-surface-variant",children:M}),d.jsx("button",{onClick:()=>navigator.clipboard.writeText(M),className:"absolute top-2 right-2 p-1 rounded hover:bg-surface-container-high transition-colors",children:d.jsx(L1,{className:"h-3.5 w-3.5 text-on-surface-variant"})})]})})()]}),d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[d.jsx(St,{children:"This Node"}),d.jsxs("div",{className:"grid gap-3",children:[d.jsx(Vv,{label:"Machine ID",value:e.machine_id}),d.jsx(Vv,{label:"Package Version",value:e.package_version})]}),e.health_error&&d.jsx("p",{className:"text-sm text-tertiary mt-2",children:e.health_error})]}),d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-5 space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(St,{children:"Sync"}),d.jsx(Ae,{variant:"default",size:"sm",onClick:D,disabled:a,children:a?d.jsxs(d.Fragment,{children:[d.jsx(gl,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Syncing..."]}):"Sync All"})]}),d.jsx("p",{className:"text-xs text-on-surface-variant",children:"Push all unsynced local knowledge to the team store. Records sync automatically on new writes, but historical data needs a one-time backfill."}),l&&d.jsx("p",{className:"text-sm text-primary",children:l}),e.dead_letter_count>0&&d.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-outline-variant/10",children:[d.jsxs("p",{className:"text-xs text-on-surface-variant",children:[d.jsxs("span",{className:"text-tertiary font-medium",children:[e.dead_letter_count," failed"]})," record",e.dead_letter_count>1?"s":""," — exceeded max retries."," ",d.jsx("a",{href:"/logs?component=team-sync&level=error",className:"underline hover:text-on-surface",children:"View logs"})]}),d.jsx(Ae,{variant:"outline",size:"sm",onClick:L,disabled:m,children:m?"Retrying...":"Retry Failed"})]}),x&&d.jsx("p",{className:"text-xs text-primary",children:x})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(Ae,{variant:"outline",size:"sm",onClick:A,disabled:n,children:n?"Disconnecting...":"Disconnect"})}),d.jsx(im,{open:N,onOpenChange:C,title:"Rotate MCP Access Token",description:"This will invalidate the current MCP token. Any cloud agents using it will lose access until reconfigured with the new token.",confirmLabel:"Rotate Token",variant:"destructive",isPending:T,onConfirm:async()=>{R(!0);try{await nn("/team/rotate-mcp-token"),t.invalidateQueries({queryKey:["team-status"]}),C(!1)}catch{}finally{R(!1)}}})]})}function Cae(){const{data:e,isLoading:t}=wae(),n=jn();if(t)return d.jsx(gw,{isLoading:!0,error:null,children:d.jsx("span",{})});const r=(e==null?void 0:e.enabled)&&(e==null?void 0:e.worker_url);return d.jsxs("div",{className:"p-6 max-w-4xl",children:[d.jsx(wi,{title:"Team",subtitle:"Share knowledge across machines with team sync"}),r&&e?d.jsx(Eae,{status:e}):d.jsxs("div",{className:"space-y-4",children:[d.jsxs(Ge,{level:"low",ghostBorder:!0,className:"p-6 space-y-4",children:[d.jsx(St,{children:"Getting Started"}),d.jsx("p",{className:"text-sm text-on-surface-variant",children:"Team sync lets multiple machines share captured knowledge through a Cloudflare Worker. One team member provisions the infrastructure, then shares the connection details."}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"1. Install Wrangler"}),d.jsx("code",{className:"block font-mono text-xs bg-surface-container rounded px-3 py-2 text-on-surface-variant",children:"npm install -g wrangler && wrangler login"})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"2. Provision the team"}),d.jsx("code",{className:"block font-mono text-xs bg-surface-container rounded px-3 py-2 text-on-surface-variant",children:"myco team init"}),d.jsx("p",{className:"text-xs text-on-surface-variant mt-1",children:"Creates a D1 database, Vectorize index, and deploys the sync worker. Outputs a Worker URL and API key to share with teammates."})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"3. Connect"}),d.jsxs("p",{className:"text-xs text-on-surface-variant",children:["Paste the Worker URL and API key below, or if you ran ",d.jsx("code",{className:"font-mono",children:"myco team init"}),", you're already connected."]})]})]})]}),d.jsx(Sae,{onConnected:()=>n.invalidateQueries({queryKey:["team-status"]})})]})]})}const Nae=[{value:"15m",label:"15m"},{value:"1h",label:"1h"},{value:"6h",label:"6h"},{value:"24h",label:"24h"},{value:"7d",label:"7d"},{value:"30d",label:"30d"}];function kae({mode:e,onModeChange:t,searchValue:n,onSearchChange:r,onSearchSubmit:a,activeLevel:i,onLevelChange:l,components:o,activeComponents:c,onComponentToggle:f,onComponentsClear:h,timeRange:p,onTimeRangeChange:m,totalResults:y,paused:x=!1,onPausedToggle:b}){return d.jsxs(Ge,{level:"default",className:"rounded-md p-3 space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"flex items-center rounded-md bg-surface-container-low",children:[d.jsxs(Ae,{size:"sm",variant:e==="live"?"default":"ghost",className:"h-7 gap-1.5 px-2.5 text-xs rounded-r-none",onClick:()=>t("live"),children:[d.jsx(XR,{className:"h-3 w-3"}),"Live"]}),d.jsxs(Ae,{size:"sm",variant:e==="search"?"default":"ghost",className:"h-7 gap-1.5 px-2.5 text-xs rounded-l-none",onClick:()=>t("search"),children:[d.jsx(dc,{className:"h-3 w-3"}),"Search"]})]}),e==="live"&&b&&d.jsxs(Ae,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 px-2.5 text-xs",onClick:b,"aria-label":x?"Resume log stream":"Pause log stream",title:x?"Resume":"Pause",children:[x?d.jsx(rs,{className:"h-3 w-3"}):d.jsx(B1,{className:"h-3 w-3"}),x?"Resume":"Pause"]}),e==="search"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"h-5 w-px bg-outline-variant/30"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(GR,{className:"h-3 w-3 text-on-surface-variant/50"}),Nae.map(w=>d.jsx(Ae,{size:"sm",variant:p===w.value?"default":"ghost",className:"h-6 px-1.5 text-[10px]",onClick:()=>m(w.value),children:w.label},w.value))]})]}),d.jsx("form",{className:"ml-auto flex items-center gap-1.5",onSubmit:w=>{w.preventDefault(),a()},children:d.jsx(fn,{className:"h-7 w-56 text-xs",placeholder:e==="search"?"Search logs...":"Filter messages...",value:n,onChange:w=>r(w.target.value),"aria-label":"Search log messages"})}),e==="search"&&y!==void 0&&d.jsxs("span",{className:"text-[10px] font-mono text-on-surface-variant/50 tabular-nums whitespace-nowrap",children:[y.toLocaleString()," results"]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"flex items-center gap-1",children:rI.map(w=>d.jsxs(Ae,{size:"sm",variant:i===w?"default":"ghost",className:"h-6 px-2 text-[10px] capitalize gap-1.5",onClick:()=>l(w),children:[d.jsx("div",{className:ke("h-1.5 w-1.5 rounded-full",U1(w))}),w]},w))}),o.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"h-4 w-px bg-outline-variant/20"}),d.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[o.map(w=>d.jsx(Ae,{size:"sm",variant:c.has(w)?"default":"ghost",className:"h-5 px-1.5 text-[10px]",onClick:()=>f(w),children:w},w)),c.size>0&&d.jsx(Ae,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-[10px] text-on-surface-variant",onClick:h,children:"clear"})]})]})]})]})}const Tae={debug:"border-l-outline/30",info:"border-l-primary/50",warn:"border-l-secondary/70",error:"border-l-tertiary/80"},jae={context:"text-primary/70",hooks:"text-on-surface-variant/70",agent:"text-secondary/80",daemon:"text-on-surface-variant/60",capture:"text-primary/60",processor:"text-on-surface-variant/70",lifecycle:"text-primary/50",embedding:"text-on-surface-variant/60",power:"text-on-surface-variant/50",server:"text-on-surface-variant/60"};function Aae(e,t){if(t)return nm(e);const n=new Date(e),r=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),i=String(n.getSeconds()).padStart(2,"0");return`${r}:${a}:${i}`}const Rae=40,Dae=60;function Xs(e){return typeof e=="string"&&e.length>0?e:null}const Mae=[{pick:e=>Xs(e.tool_name)},{pick:e=>Xs(e.type)},{pick:e=>Xs(e.agent_type)},{pick:e=>Xs(e.task_subject),format:e=>yp(e,Rae)},{pick:e=>Xs(e.filename)},{pick:e=>Xs(e.source_path)??Xs(e.path),format:q7},{pick:e=>Xs(e.error),format:e=>yp(e,Dae)},{pick:e=>typeof e.pid=="number"?`pid ${e.pid}`:null}];function _ae(e){if(!e)return"";for(const{pick:t,format:n}of Mae){const r=t(e);if(r)return n?n(r):r}return""}function Oae({entries:e,selectedId:t,onSelect:n,autoScroll:r=!1,relativeTime:a=!1,compact:i=!0}){const l=j.useRef(null);return j.useEffect(()=>{!r||!l.current||(l.current.scrollTop=l.current.scrollHeight)},[e,r]),d.jsx("div",{ref:l,className:"flex-1 overflow-y-auto bg-surface-container-lowest font-mono text-xs",children:e.length===0?d.jsx("div",{className:"flex h-full min-h-[200px] items-center justify-center text-on-surface-variant/50 font-sans text-sm",children:"No log entries"}):d.jsxs("table",{className:"w-full border-collapse","aria-label":"Log entries",children:[d.jsx("thead",{className:"sticky top-0 z-10 bg-surface-container-lowest/95 backdrop-blur supports-[backdrop-filter]:bg-surface-container-lowest/80",children:d.jsxs("tr",{className:"border-b border-outline-variant/10 text-[10px] uppercase tracking-[0.16em] text-on-surface-variant/50",children:[d.jsx("th",{className:"w-[68px] px-3 py-2 text-left font-medium",children:"Time"}),d.jsx("th",{className:"w-[12px] px-0 py-2","aria-hidden":"true"}),d.jsx("th",{className:"w-[48px] px-0 py-2 text-left font-medium",children:"Level"}),d.jsx("th",{className:"w-[90px] px-0 py-2 text-left font-medium",children:"Area"}),d.jsx("th",{className:"w-[72px] px-0 py-2 text-left font-medium",children:"Session"}),d.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Message"})]})}),d.jsx("tbody",{children:e.map(o=>d.jsx(Lae,{entry:o,selected:o.id===t,onSelect:n,relativeTime:a,compact:i},o.id))})]})})}const Lae=j.memo(function({entry:t,selected:n,onSelect:r,relativeTime:a,compact:i}){const l=i?"py-0.5":"py-1.5",o=hl(t.session_id),c=_ae(t.data);return d.jsxs("tr",{className:ke("cursor-pointer transition-colors border-l-2",Tae[t.level],n?"bg-primary/10":"hover:bg-surface-container-high/30"),onClick:()=>r(t),children:[d.jsx("td",{className:ke("whitespace-nowrap pl-3 pr-2 text-on-surface-variant/50 align-top w-[68px] tabular-nums",l),children:Aae(t.timestamp,a)}),d.jsx("td",{className:ke("whitespace-nowrap pr-1 align-top w-[12px]",l),children:d.jsx("div",{className:ke("h-1.5 w-1.5 rounded-full mt-1",U1(t.level))})}),d.jsx("td",{className:ke("whitespace-nowrap pr-2 align-top w-[48px]",l),children:d.jsx(wt,{variant:nD(t.level),className:"px-1 py-0 text-[9px] uppercase",children:t.level})}),d.jsx("td",{className:ke("whitespace-nowrap pr-2 align-top w-[90px] truncate max-w-[90px]",l,jae[t.component]??"text-on-surface-variant/60"),children:t.component}),d.jsx("td",{className:ke("whitespace-nowrap pr-2 align-top w-[72px] tabular-nums text-on-surface-variant/40",l),title:t.session_id??"",children:o}),d.jsxs("td",{className:ke("pr-3 text-on-surface align-top break-words",l),children:[d.jsx("span",{children:t.message}),c&&d.jsxs("span",{className:"ml-2 text-on-surface-variant/50",children:["· ",c]})]})]})});function Pae({value:e}){const t=String(e),n=t.slice(0,8);return d.jsxs(Ma,{to:`/sessions/${t}`,className:"font-mono text-primary hover:underline",children:[n,"..."]})}function Bae({value:e}){return Array.isArray(e)?d.jsx("span",{className:"flex flex-wrap gap-1",children:e.map((t,n)=>d.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:String(t)},n))}):d.jsx("span",{children:String(e)})}function zae({value:e}){return Array.isArray(e)?d.jsx("span",{className:"flex gap-1",children:e.map((t,n)=>d.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0 tabular-nums",children:String(t)},n))}):d.jsx("span",{children:String(e)})}function Iae({value:e}){return d.jsx("span",{className:"rounded bg-tertiary/10 px-2 py-0.5 text-tertiary font-mono text-[11px]",children:String(e)})}function HA({value:e}){return d.jsx("pre",{className:"max-h-32 overflow-auto rounded bg-surface-container-lowest px-2 py-1 text-[11px] font-mono text-on-surface-variant whitespace-pre-wrap",children:String(e)})}function Fae({value:e}){const t=new Date(String(e)),r=new Date().getTime()-t.getTime(),a=Math.floor(r/6e4),i=Math.floor(a/60),l=Math.floor(i/24);let o;return a<1?o="just now":a<60?o=`${a}m ago`:i<24?o=`${i}h ago`:o=`${l}d ago`,d.jsx("span",{className:"tabular-nums",title:t.toISOString(),children:o})}function Uae({value:e}){return typeof e=="object"&&e!==null?d.jsx("pre",{className:"text-[11px] font-mono text-on-surface-variant whitespace-pre-wrap",children:JSON.stringify(e,null,2)}):d.jsx("span",{children:String(e)})}const qae={session_id:Pae,spore_titles:Bae,scores:zae,error:Iae,preview:HA,generated_at:Fae,text:HA},Vae=new Set(["id","timestamp","level","kind","component","message"]);function $A(e,t){const n=qae[e]??Uae;return d.jsx(n,{value:t})}function Hae(e){return Vae.has(e)}function $ae(e){return e?Object.entries(e).filter(([t])=>!Hae(t)):[]}const Gae={debug:"text-on-surface-variant/60",info:"text-primary",warn:"text-secondary",error:"text-tertiary"};function Kae({entry:e,resolved:t,onClose:n}){const r=$ae(e.data);return d.jsxs("div",{className:"flex h-full flex-col bg-surface-container-low",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/10",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.kind}),d.jsx("span",{className:ke("text-xs font-medium",Gae[e.level]),children:e.level.toUpperCase()})]}),d.jsx(Ae,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:n,"aria-label":"Close detail panel",children:d.jsx(is,{className:"h-3.5 w-3.5"})})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-4",children:[d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Timestamp"}),d.jsx("div",{className:"font-mono text-xs tabular-nums",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Message"}),d.jsx("div",{className:"text-sm text-on-surface leading-relaxed",children:e.message})]}),e.session_id&&d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Session"}),d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[$A("session_id",e.session_id),!!(t!=null&&t.session_title)&&d.jsx("span",{className:"text-on-surface-variant/70",children:String(t.session_title)})]})]}),r.length>0&&d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-1.5",children:"Metadata"}),d.jsx("div",{className:"space-y-2",children:r.map(([a,i])=>d.jsxs("div",{children:[d.jsx("div",{className:"text-[10px] text-on-surface-variant/40 mb-0.5",children:a}),d.jsx("div",{className:"text-xs",children:$A(a,i)})]},a))})]})]}),d.jsx("div",{className:"px-4 py-2 border-t border-outline-variant/10",children:d.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant/40 tabular-nums",children:["id: ",e.id]})})]})}const GA=5e3;function Yae(e=!1){const[t,n]=j.useState([]),r=j.useRef(null),{data:a,refetch:i}=Wt({queryKey:["logs-stream"],queryFn:({signal:c})=>{const f=r.current===null?"/logs/stream":`/logs/stream?since=${r.current}`;return lt(f,{signal:c})},refetchInterval:e?!1:Sr.LOGS}),l=j.useRef(e);j.useEffect(()=>{l.current&&!e&&i(),l.current=e},[e,i]),j.useEffect(()=>{if(!(a!=null&&a.entries.length)){a&&r.current===null&&(r.current=a.cursor);return}r.current=a.cursor,n(c=>{const f=[...c,...a.entries];return f.length>GA?f.slice(-GA):f})},[a]);const o=j.useCallback(()=>{n([]),r.current=null},[]);return{entries:t,clear:o}}function Xae(e,t){const n=new URLSearchParams;return e.q&&n.set("q",e.q),e.level&&n.set("level",e.level),e.component&&n.set("component",e.component),e.kind&&n.set("kind",e.kind),e.session_id&&n.set("session_id",e.session_id),e.from&&n.set("from",e.from),e.to&&n.set("to",e.to),e.page&&n.set("page",String(e.page)),e.page_size&&n.set("page_size",String(e.page_size)),Wt({queryKey:["logs-search",Object.fromEntries(n)],queryFn:({signal:r})=>lt(`/logs/search?${n.toString()}`,{signal:r}),enabled:t})}function Qae(e){return Wt({queryKey:["log-detail",e],queryFn:({signal:t})=>lt(`/logs/${e}`,{signal:t}),enabled:e!==null})}function Wae(e){const t=Date.now(),n={"15m":15*6e4,"1h":60*6e4,"6h":360*6e4,"24h":1440*6e4,"7d":10080*6e4,"30d":720*60*6e4};return new Date(t-(n[e]??1440*6e4)).toISOString()}function Zae(){const e=j.useMemo(()=>{var B;const K=new URLSearchParams(window.location.search),Q=((B=K.get("component"))==null?void 0:B.split(",").filter(Boolean))??[],F=K.get("level"),q=K.get("q")??"",X=Q.length>0||!!F||!!q;return{components:Q,level:F,q,hasFilters:X}},[]),[t,n]=j.useState(e.hasFilters?"search":"live"),[r,a]=j.useState(e.q),[i,l]=j.useState(e.q),[o,c]=j.useState(e.level??"debug"),[f,h]=j.useState(new Set(e.components)),[p,m]=j.useState("24h"),[y,x]=j.useState(1),[b,w]=j.useState(null),[S,N]=j.useState(!1),{entries:C,clear:T}=Yae(S),R=j.useMemo(()=>({q:i||void 0,level:o!=="debug"?o:void 0,component:f.size>0?Array.from(f).join(","):void 0,from:Wae(p),page:y,page_size:Kr}),[i,o,f,p,y]),{data:A}=Xae(R,t==="search"),{data:D}=Qae((b==null?void 0:b.id)??null),[O,L]=j.useState(e.components);j.useEffect(()=>{const K=t==="live"?C:(A==null?void 0:A.entries)??[];L(Q=>{const F=new Set(Q);let q=!1;for(const X of K)F.has(X.component)||(F.add(X.component),q=!0);return q?Array.from(F).sort():Q})},[C,A,t]);const M=j.useMemo(()=>{const K=fp[o]??0,Q=r.trim().toLowerCase();return C.filter(F=>!((fp[F.level]??0)<K||f.size>0&&!f.has(F.component)||Q&&!F.message.toLowerCase().includes(Q)))},[C,o,f,r]),P=t==="live"?M:(A==null?void 0:A.entries)??[],z=j.useCallback(K=>{n(K),w(null),K==="live"&&(T(),N(!1))},[T]),H=j.useCallback(()=>{l(r),x(1)},[r]),$=j.useCallback(K=>{w(Q=>(Q==null?void 0:Q.id)===K.id?null:K)},[]),U=j.useCallback(K=>{h(Q=>{const F=new Set(Q);return F.has(K)?F.delete(K):F.add(K),F}),x(1)},[]),I=j.useCallback(K=>{c(K),x(1)},[]),V=b!==null;return d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsx("div",{className:"px-6 pt-6",children:d.jsx(wi,{title:"Logs",subtitle:"Daemon log explorer"})}),d.jsx("div",{className:"px-6 mb-3",children:d.jsx(kae,{mode:t,onModeChange:z,searchValue:r,onSearchChange:a,onSearchSubmit:H,activeLevel:o,onLevelChange:I,components:O,activeComponents:f,onComponentToggle:U,onComponentsClear:()=>{h(new Set),x(1)},timeRange:p,onTimeRangeChange:K=>{m(K),x(1)},totalResults:t==="search"?A==null?void 0:A.total:void 0,paused:S,onPausedToggle:()=>N(K=>!K)})}),d.jsxs("div",{className:"flex flex-1 overflow-hidden mx-6 mb-6 rounded-lg border border-outline-variant/10",children:[d.jsxs("div",{className:ke("flex flex-col",V?"w-3/5":"w-full"),children:[d.jsx(Oae,{entries:P,selectedId:(b==null?void 0:b.id)??null,onSelect:$,autoScroll:t==="live"&&!S,relativeTime:t==="live",compact:!0}),t==="search"&&A&&d.jsx("div",{className:"border-t border-outline-variant/10 px-3 py-2 bg-surface-container-low",children:d.jsx(Ec,{total:A.total,offset:(y-1)*Kr,limit:Kr,onPageChange:K=>x(Math.floor(K/Kr)+1)})})]}),V&&b&&d.jsx("div",{className:"w-2/5 border-l border-outline-variant/10",children:d.jsx(Kae,{entry:b,resolved:D==null?void 0:D.resolved,onClose:()=>w(null)})})]})]})}function Jae(){return d.jsx(xB,{children:d.jsxs(Na,{element:d.jsx(F7,{}),children:[d.jsx(Na,{path:"/",element:d.jsx(z$,{})}),d.jsx(Na,{path:"/sessions",element:d.jsx(Qk,{})}),d.jsx(Na,{path:"/sessions/:id",element:d.jsx(Qk,{})}),d.jsx(Na,{path:"/mycelium",element:d.jsx(une,{})}),d.jsx(Na,{path:"/agent",element:d.jsx(nre,{})}),d.jsx(Na,{path:"/skills",element:d.jsx(Dre,{})}),d.jsx(Na,{path:"/settings",element:d.jsx(qre,{})}),d.jsx(Na,{path:"/operations",element:d.jsx(bae,{})}),d.jsx(Na,{path:"/team",element:d.jsx(Cae,{})}),d.jsx(Na,{path:"/logs",element:d.jsx(Zae,{})})]})})}const eie=new sP({defaultOptions:{queries:{staleTime:tI}}});L4.createRoot(document.getElementById("root")).render(d.jsx(Yi.StrictMode,{children:d.jsx(tz,{children:d.jsx(lz,{children:d.jsx(fz,{children:d.jsx(lP,{client:eie,children:d.jsx(VB,{children:d.jsx(Jae,{})})})})})})}));
|