@bigduu/lotus-next 2026.11.12 → 2026.11.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/asset-manifest.json +135 -135
  2. package/dist/assets/{AgentService-BCwIYsdb.js → AgentService-BxkDZijx.js} +1 -1
  3. package/dist/assets/{BrowserPane-CeeIn9-7.js → BrowserPane-DQmb9MbF.js} +1 -1
  4. package/dist/assets/{CommandPalette-DFFjvT5e.js → CommandPalette-zFGAeao_.js} +1 -1
  5. package/dist/assets/{ConversationClearDialogContent-DOal0VIa.js → ConversationClearDialogContent-BjUzjlW5.js} +1 -1
  6. package/dist/assets/{ErrorBoundary-BYTlWx9S.js → ErrorBoundary-DZL5VW7G.js} +1 -1
  7. package/dist/assets/ErrorBoundary-RQjzfWIN.js +1 -0
  8. package/dist/assets/{ExternalLinkDialog-DAl1X_Rd.js → ExternalLinkDialog-BLhTAIN3.js} +1 -1
  9. package/dist/assets/{JianduProjectMemories-BVvR5A-E.js → JianduProjectMemories-bTTYZdJm.js} +1 -1
  10. package/dist/assets/{Markdown-BLVJ3McT.js → Markdown-DcU5BDYf.js} +2 -2
  11. package/dist/assets/MermaidChart-ByE31o0x.js +1 -0
  12. package/dist/assets/{NewChatWorktreeControl-C5hX_sFG.js → NewChatWorktreeControl-BfJn3yGb.js} +1 -1
  13. package/dist/assets/{ProjectWorkBoard-DQPTDlAR.js → ProjectWorkBoard-DO7KLYxo.js} +1 -1
  14. package/dist/assets/{RightWorkbench-CLQN7HAA.js → RightWorkbench-BYiu51Dg.js} +1 -1
  15. package/dist/assets/{RightWorkbenchSurface-DYtuKquV.js → RightWorkbenchSurface-CMHluk_b.js} +1 -1
  16. package/dist/assets/Root-kgWSyvAi.js +11 -0
  17. package/dist/assets/{RunDiagnosticsDialogContent-zW8wbgjy.js → RunDiagnosticsDialogContent-CYQ_gQRw.js} +1 -1
  18. package/dist/assets/Settings-DWx59xvd.js +9 -0
  19. package/dist/assets/{SidebarProjectDrag-Cz6LN4Ot.js → SidebarProjectDrag-CsY9x3a_.js} +1 -1
  20. package/dist/assets/{StreamdownMarkdown-DQeWAen9.js → StreamdownMarkdown-BesiJzz2.js} +2 -2
  21. package/dist/assets/StreamdownMermaid-ByE31o0x.js +1 -0
  22. package/dist/assets/{StreamdownMermaid-1DDiJEMk.js → StreamdownMermaid-z81R4U3T.js} +1 -1
  23. package/dist/assets/{SupervisorManagedSessions-BTyVyN25.js → SupervisorManagedSessions-ngi6oXHn.js} +1 -1
  24. package/dist/assets/{SupervisorProjectScopeDialog-DEUu6PVY.js → SupervisorProjectScopeDialog-CzP4lg8j.js} +1 -1
  25. package/dist/assets/{TicketWorkPanel-BLhcQK27.js → TicketWorkPanel-bkGJzvs_.js} +1 -1
  26. package/dist/assets/{WorkflowAuthoring-BRRm2f64.js → WorkflowAuthoring-B-wblAVn.js} +1 -1
  27. package/dist/assets/{WorkflowRunsContent-Cj54WCtx.js → WorkflowRunsContent-qjOAAv8j.js} +2 -2
  28. package/dist/assets/appStore-DhQwkuOp.js +14 -0
  29. package/dist/assets/{command-C6FS5UNj.js → command-CIuEm3dl.js} +3 -3
  30. package/dist/assets/{en-US-Ct0T2acE.js → en-US-DVa15VFu.js} +1 -1
  31. package/dist/assets/{index-BJqlTN_f.css → index-63AMwWQM.css} +1 -1
  32. package/dist/assets/{index-q4GvX8V2.js → index-D6ZjT3if.js} +3 -3
  33. package/dist/assets/{managedSessions-CKRnqnRV.js → managedSessions-BEiB7QR5.js} +1 -1
  34. package/dist/assets/{managedSessions-whVnY1Ku.js → managedSessions-dKLoLibq.js} +1 -1
  35. package/dist/assets/{renderPdf-ClWRaM4a.js → renderPdf-COTAxKjK.js} +1 -1
  36. package/dist/assets/{responsive-dialog-X2p7BxPz.js → responsive-dialog-D6zJ6jIQ.js} +1 -1
  37. package/dist/assets/{state-BvQWuk__.js → state-BEeCkuhw.js} +1 -1
  38. package/dist/assets/{ticketWorkLabels-E1FCpCgd.js → ticketWorkLabels-DuizmQP4.js} +1 -1
  39. package/dist/assets/{ui-MhL1JCuh.js → ui-DHEY0Lgx.js} +1 -1
  40. package/dist/assets/{useBrowserSession-BxoLALDt.js → useBrowserSession-jKAyolWq.js} +1 -1
  41. package/dist/assets/{useWorkflowCatalog-DyvbgSYT.js → useWorkflowCatalog-CLMiMU7o.js} +1 -1
  42. package/dist/assets/{workflowProposals-C5jo0VE3.js → workflowProposals-DfTwNhR0.js} +1 -1
  43. package/dist/assets/{zh-CN-BpuEfyrW.js → zh-CN-484J-zUA.js} +1 -1
  44. package/dist/bundle-ownership.json +53 -49
  45. package/dist/index.html +2 -2
  46. package/dist/lotus-next-manifest.json +100 -100
  47. package/package.json +1 -1
  48. package/dist/assets/ErrorBoundary-Dl4dCV3z.js +0 -1
  49. package/dist/assets/MermaidChart-CykxptKx.js +0 -1
  50. package/dist/assets/Root-BAszw18u.js +0 -11
  51. package/dist/assets/Settings-Xyy5DfPr.js +0 -9
  52. package/dist/assets/StreamdownMermaid-CykxptKx.js +0 -1
  53. package/dist/assets/appStore-B9lnBbyu.js +0 -14
@@ -0,0 +1,9 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./JianduProjectMemories-bTTYZdJm.js","./rolldown-runtime-QTnfLwEv.js","./vendor-react-CCIEwYL0.js","./ui-DHEY0Lgx.js","./preload-helper-DYl5dUZ5.js","./shim-B7rqb4U2.js","./select-CmSs2Iud.js","./createLucideIcon-5m7IB1Aa.js","./check-D8KAspD5.js","./chevron-down-x8rJ6PKU.js","./dist-F2p7j0vG.js","./button-Cfb4l-V4.js","./bundle-mjs-B_AA55HL.js","./utils-DqNhCx4L.js","./motion-A2StR0Mh.js","./dist-DCRuquMi.js","./dist-C7Y4oZCX.js","./floating-ui.dom-BRnbq1vk.js","./dist-fTqKuvxa.js","./appStore-DhQwkuOp.js","./clipboard-CyQ_pZV9.js","./react-BqtYw2Yd.js","./api-CPcpMjoM.js","./runtimeConfig-DNyol2mX.js","./AgentService-BxkDZijx.js","./project-Bes6r3Er.js","./responsive-dialog-D6zJ6jIQ.js","./x-CH9nNoJJ.js","./dist-DF6JjXE-.js","./input-BDZy7WK3.js","./textarea-BKzYyWL5.js","./jianduMemoryApi-Bg3hZQEs.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r}from"./runtimeConfig-DNyol2mX.js";import{t as i}from"./preload-helper-DYl5dUZ5.js";import{a,i as o,l as s,n as c,o as l,r as u,t as d,u as f}from"./ui-DHEY0Lgx.js";import{C as p,D as m,E as h,O as g,S as _,T as v,a as y,b,d as x,f as S,g as C,h as w,i as T,l as E,m as D,n as O,o as k,p as A,r as j,s as M,t as N,u as P,v as ee,w as F,x as te,y as ne}from"./command-CIuEm3dl.js";import{t as I}from"./createLucideIcon-5m7IB1Aa.js";import{a as L,n as re,r as R,t as z}from"./popover-Csd6fbme.js";import{t as ie}from"./loader-circle-B9fKDSy8.js";import{t as ae}from"./check-D8KAspD5.js";import{t as oe}from"./chevron-down-x8rJ6PKU.js";import{i as B}from"./dist-D8rsXFxT.js";import{a as V,i as se,n as ce,o as le,r as H,s as U,t as W}from"./select-CmSs2Iud.js";import{t as ue}from"./copy-DmHig_f7.js";import{t as de}from"./external-link-zzXjsZJY.js";import{t as fe}from"./plus-Do3us3O5.js";import{t as pe}from"./refresh-cw-DHR8UyeF.js";import{t as me}from"./search-DcePmjfr.js";import{t as he}from"./workflow-Ba3VCur3.js";import{t as ge}from"./x-CH9nNoJJ.js";import{t as _e}from"./clipboard-CyQ_pZV9.js";import{t as ve}from"./react-BqtYw2Yd.js";import{A as ye,I as be,M as xe,N as Se,P as Ce,d as we,f as Te,g as Ee,h as De,i as Oe,j as ke,k as G,l as Ae,p as je,u as Me,v as K}from"./appStore-DhQwkuOp.js";import{c as Ne,s as q,t as J}from"./api-CPcpMjoM.js";import{r as Pe}from"./AgentService-BxkDZijx.js";import{a as Fe}from"./dist-F2p7j0vG.js";import{t as Y}from"./button-Cfb4l-V4.js";import{t as X}from"./utils-DqNhCx4L.js";import{_ as Ie,f as Le,m as Re,t as ze,v as Be}from"./motion-A2StR0Mh.js";import{o as Ve}from"./dist-C7Y4oZCX.js";import{i as He,n as Ue,r as We,t as Ge}from"./responsive-dialog-D6zJ6jIQ.js";import{t as Z}from"./input-BDZy7WK3.js";import{a as Ke,i as qe,n as Je,o as Ye,t as Xe}from"./themeStore-iULXkh0N.js";import{t as Ze}from"./textarea-BKzYyWL5.js";import{t as Qe}from"./ownerAccessContext-DnfKhLRV.js";import{i as $e,n as et,r as tt,t as nt}from"./tabs-CZ73j2Ke.js";import{a as rt,i as it,r as at,s as ot,u as st}from"./jianduMemoryApi-Bg3hZQEs.js";var ct=I(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),lt=I(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),ut=I(`blocks`,[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]),dt=I(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),ft=I(`chart-no-axes-combined`,[[`path`,{d:`M12 16v5`,key:`zza2cw`}],[`path`,{d:`M16 14.639V21`,key:`1s85h0`}],[`path`,{d:`M20 10.656V21`,key:`q45596`}],[`path`,{d:`m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15`,key:`1fw8x9`}],[`path`,{d:`M4 18.463V21`,key:`1otddq`}],[`path`,{d:`M8 14.656V21`,key:`1t2idw`}]]),pt=I(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),mt=I(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ht=I(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),gt=I(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),_t=I(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),vt=I(`package-check`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16 17 2 2 4-4`,key:`uh5qu3`}],[`path`,{d:`M21 11.127V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.32-.753`,key:`kpkbpo`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),yt=I(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),bt=I(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),xt=I(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),St=I(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ct=I(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),wt=I(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Tt=I(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Et=I(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Q=e(t(),1),Dt=`lotus_experience_mode_v1`,Ot=new Set([`skills`,`env`,`masking`,`clusters`,`metrics`,`jiandu`]);function kt(){try{let e=localStorage.getItem(Dt);if(e===`simple`||e===`advanced`)return e}catch{}return`advanced`}var At=ve(e=>({mode:kt(),isAdvanced:kt()===`advanced`,setMode:t=>{try{localStorage.setItem(Dt,t)}catch{}e({mode:t,isAdvanced:t===`advanced`})},toggleMode:()=>e(e=>{let t=e.mode===`simple`?`advanced`:`simple`;try{localStorage.setItem(Dt,t)}catch{}return{mode:t,isAdvanced:t===`advanced`}})})),jt=e=>{let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{n===void 0||n===``||t.set(e,String(n))});let n=t.toString();return n?`?${n}`:``},Mt=new class{async getSummary(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate});return J.get(`metrics/summary${t}`)}async getByModel(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate});return J.get(`metrics/by-model${t}`)}async getSessions(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate,model:e.model,limit:e.limit});return J.get(`metrics/sessions${t}`)}async getSessionDetail(e){try{return await J.get(`metrics/sessions/${encodeURIComponent(e)}`)}catch(e){if(e instanceof Error&&e.message.includes(`not found`))return null;throw e}}async getUsageBreakdown(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate,model:e.model});return J.get(`metrics/usage-breakdown${t}`)}async getDaily(e={}){let t=jt({days:e.days,end_date:e.endDate,granularity:e.granularity});return J.get(`metrics/daily${t}`)}async getForwardSummary(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate,endpoint:e.endpoint,model:e.model,limit:e.limit});return J.get(`metrics/forward/summary${t}`)}async getForwardByEndpoint(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate,endpoint:e.endpoint,model:e.model,limit:e.limit});return J.get(`metrics/forward/by-endpoint${t}`)}async getForwardRequests(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate,endpoint:e.endpoint,model:e.model,limit:e.limit});return J.get(`metrics/forward/requests${t}`)}async getMemorySummary(e={}){let t=jt({scope:e.scope,project_key:e.projectKey});return J.get(`metrics/memory/summary${t}`)}async getMemoryTimeline(e={}){let t=jt({scope:e.scope,project_key:e.projectKey,days:e.days,end_date:e.endDate,granularity:e.granularity});return J.get(`metrics/memory/timeline${t}`)}async getUnifiedSummary(e={}){let t=jt({start_date:e.startDate,end_date:e.endDate});return J.get(`metrics/v2/summary${t}`)}async getUnifiedTimeline(e={}){let t=jt({days:e.days,end_date:e.endDate,granularity:e.granularity});return J.get(`metrics/v2/timeline${t}`)}},$=n(),Nt=`Switch`,[Pt,Ft]=Ie(Nt),[It,Lt]=Pt(Nt);function Rt(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Re({prop:n,defaultProp:i??!1,onChange:c,caller:Nt}),[m,h]=Q.useState(null),[g,_]=Q.useState(null),v={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:Q.useRef(!1),required:l,defaultChecked:i,isFormControl:m?!!o||!!m.closest(`form`):!0,bubbleInput:g,setBubbleInput:_};return(0,$.jsx)(It,{scope:t,...v,children:Kt(d)?d(v):r})}var zt=`SwitchTrigger`,Bt=Q.forwardRef(({__scopeSwitch:e,onClick:t,...n},r)=>{let{value:i,disabled:a,checked:o,required:s,setControl:c,setChecked:l,hasConsumerStoppedPropagationRef:u,isFormControl:d,bubbleInput:f}=Lt(zt,e),p=Fe(r,c);return(0,$.jsx)(Le.button,{type:`button`,role:`switch`,"aria-checked":o,"aria-required":s,"data-state":qt(o),"data-disabled":a?``:void 0,disabled:a,value:i,...n,ref:p,onClick:Be(t,e=>{l(e=>!e),f&&d&&(u.current=e.isPropagationStopped(),u.current||e.stopPropagation())})})});Bt.displayName=zt;var Vt=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,$.jsx)(Rt,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Bt,{...d,ref:t,__scopeSwitch:n}),e&&(0,$.jsx)(Gt,{__scopeSwitch:n})]})})});Vt.displayName=Nt;var Ht=`SwitchThumb`,Ut=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Lt(Ht,n);return(0,$.jsx)(Le.span,{"data-state":qt(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Ut.displayName=Ht;var Wt=`SwitchBubbleInput`,Gt=Q.forwardRef(({__scopeSwitch:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:c,name:l,value:u,form:d,bubbleInput:f,setBubbleInput:p}=Lt(Wt,e),m=Fe(n,p),h=le(a),g=Ve(r);Q.useEffect(()=>{let e=f;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(h!==a&&n){let t=new Event(`click`,{bubbles:r});n.call(e,a),e.dispatchEvent(t)}},[f,h,a,i]);let _=Q.useRef(a);return(0,$.jsx)(Le.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??_.current,required:s,disabled:c,name:l,value:u,form:d,...t,tabIndex:-1,ref:m,style:{...t.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});Gt.displayName=Wt;function Kt(e){return typeof e==`function`}function qt(e){return e?`checked`:`unchecked`}function Jt({className:e,...t}){return(0,$.jsx)(Vt,{"data-slot":`switch`,className:X(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs switch-feedback outline-none disabled:cursor-not-allowed disabled:opacity-50`,ze,e),...t,children:(0,$.jsx)(Ut,{"data-slot":`switch-thumb`,className:X(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`,ze)})})}var Yt=e=>typeof e==`string`&&e.trim().length>0&&[...e.trim()].every(e=>e===`*`||e===`.`),Xt=[{id:`deepseek`,label:`DeepSeek`,provider_type:`openai`,base_url:`https://api.deepseek.com/v1`,suggested_models:[`deepseek-chat`,`deepseek-reasoner`]},{id:`deepseek-anthropic`,get label(){return u(`deepseek_anthropic_protocol_62842c32`)},provider_type:`anthropic`,base_url:`https://api.deepseek.com/anthropic`,suggested_models:[`deepseek-chat`,`deepseek-reasoner`]},{id:`zhipu`,get label(){return u(`zhipu_glm_bigmodel_cn_a240ba1c`)},provider_type:`openai`,base_url:`https://open.bigmodel.cn/api/paas/v4`,suggested_models:[`glm-5.2`],get note(){return u(`coding_plan_subscriptions_must_use_https_open_bigmodel__3219dd7a`)}},{id:`zhipu-anthropic`,get label(){return u(`zhipu_glm_anthropic_protocol_3615b3ca`)},provider_type:`anthropic`,base_url:`https://open.bigmodel.cn/api/anthropic`,suggested_models:[`glm-5.2`]},{id:`zai`,get label(){return u(`z_ai_international_e13ea359`)},provider_type:`openai`,base_url:`https://api.z.ai/api/paas/v4`,suggested_models:[`glm-5.2`],get note(){return u(`coding_plan_subscriptions_must_use_https_api_z_ai_api_c_5de1ae0c`)}},{id:`minimax`,get label(){return u(`minimax_international_6474afda`)},provider_type:`openai`,base_url:`https://api.minimax.io/v1`,suggested_models:[`MiniMax-M3`]},{id:`minimax-cn`,get label(){return u(`minimax_china_10b93448`)},provider_type:`openai`,base_url:`https://api.minimaxi.com/v1`,suggested_models:[`MiniMax-M3`]},{id:`qwen`,get label(){return u(`qwen_dashscope_8aaf2acd`)},provider_type:`openai`,base_url:`https://dashscope.aliyuncs.com/compatible-mode/v1`,suggested_models:[`qwen-plus`],get note(){return u(`alibaba_cloud_recommends_migrating_to_a_business_space__9739bc3e`)}},{id:`kimi`,label:`Kimi (Moonshot)`,provider_type:`openai`,base_url:`https://api.moonshot.cn/v1`,suggested_models:[`kimi-k2.6`,`kimi-k2.7-code`]}];function Zt(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}function Qt(){o();let[e,t]=(0,Q.useState)(`unknown`),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(0),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),g=(0,Q.useCallback)(async()=>{r(!0);try{t((await be.getCopilotAuthStatus()).authenticated?`authenticated`:`not_authenticated`),h(null)}catch(e){t(`unknown`),h(q(e))}finally{r(!1)}},[]);(0,Q.useEffect)(()=>{g()},[g]),(0,Q.useEffect)(()=>{if(!i)return;c(i.expires_in);let e=setInterval(()=>c(e=>e>0?e-1:0),1e3);return()=>clearInterval(e)},[i]);let _=async()=>{d(!0),h(null);try{let e=await be.startCopilotAuth();a(e);try{window.open(e.verification_uri,`_blank`,`noopener`)}catch{}await be.completeCopilotAuth({device_code:e.device_code,interval:e.interval??5,expires_in:e.expires_in}),t(`authenticated`)}catch(e){h(q(e)),g()}finally{a(null),d(!1)}},v=async()=>{h(null);try{await be.logoutCopilot(),t(`not_authenticated`)}catch(e){h(q(e))}},y=async()=>{if(i)try{await navigator.clipboard.writeText(i.user_code),p(!0),setTimeout(()=>p(!1),2e3)}catch{h(u(`could_not_copy_select_and_copy_the_code_manually_7c49600d`))}};return(0,$.jsxs)(`div`,{className:`space-y-2 rounded-md border bg-muted/30 p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:u(`copilot_authorization_c3d9d8de`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e===`authenticated`?(0,$.jsx)(U,{className:`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400`,variant:`secondary`,children:u(`signed_in_0a01eee1`)}):e===`not_authenticated`?(0,$.jsx)(U,{variant:`secondary`,children:u(`signed_out_c1f65837`)}):(0,$.jsx)(U,{variant:`outline`,children:u(`unknown_4d8c1c5b`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":u(`refresh_status_802a407c`),className:`rounded p-1 text-muted-foreground hover:text-foreground`,disabled:n,children:(0,$.jsx)(pe,{className:n?`size-3.5 animate-spin`:`size-3.5`})})]})]}),i?(0,$.jsxs)(`div`,{className:`space-y-1.5 text-sm`,children:[(0,$.jsxs)(`p`,{children:[u(`open_c771248e`),` `,(0,$.jsx)(`a`,{href:i.verification_uri,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline`,children:i.verification_uri}),` `,u(`and_enter_the_code_7aa88967`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-base font-semibold tracking-wider`,children:i.user_code}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2`,onClick:()=>void y(),children:[f?(0,$.jsx)(ae,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(ue,{className:`size-3.5`}),u(f?`copied_8f6f8d97`:`copy_63d90d97`)]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s>0?u(`code_expires_in_e5dcbf33`,{v0:Zt(s)}):u(`code_expired_sign_in_again_bc54f564`),s>0?u(`this_completes_automatically_after_authorization_ec18f4d2`):``]})]}):e===`authenticated`?(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:u(`github_copilot_account_connected_b4129fa2`)}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>void v(),children:u(`sign_out_498e1d59`)})]}):(0,$.jsx)(Y,{size:`sm`,onClick:()=>void _(),disabled:l,children:u(l?`signing_in_3f06ed8f`:`sign_in_to_github_copilot_be6015e8`)}),m?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:m}):null]})}function $t({label:e,value:t,onChange:n,models:r=[],placeholder:i,disabled:a=!1,hideLabel:s=!1}){o();let c=(0,Q.useRef)(null),l=(0,Q.useId)(),d=(0,Q.useId)(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(-1),g=(0,Q.useMemo)(()=>{let e=new Map;for(let t of r){let n=t.reference.model.trim();n&&!e.has(n)&&e.set(n,t)}return[...e.values()]},[r]),_=(0,Q.useMemo)(()=>{let e=t.trim().toLocaleLowerCase();if(!e)return g;let n=g.filter(t=>{let n=t.reference.model.toLocaleLowerCase(),r=t.display_name.toLocaleLowerCase();return n.includes(e)||r.includes(e)});return n.length>0?n:g},[g,t]),v=f&&_.length>0;(0,Q.useEffect)(()=>{!v||m<0||document.getElementById(`${l}-option-${m}`)?.scrollIntoView?.({block:`nearest`})},[m,l,v]);let y=e=>{n(e),p(!1),h(-1),c.current?.focus()},b=e=>{_.length!==0&&(p(!0),h(t=>t<0?e===1?0:_.length-1:(t+e+_.length)%_.length))};return(0,$.jsxs)(`div`,{className:`relative`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(p(!1),h(-1))},children:[(0,$.jsx)(`span`,{id:d,className:X(s?`sr-only`:`mb-1 block text-xs text-muted-foreground`),children:e}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Z,{ref:c,role:`combobox`,"aria-labelledby":d,"aria-autocomplete":`list`,"aria-controls":l,"aria-expanded":v,"aria-activedescendant":v&&m>=0?`${l}-option-${m}`:void 0,autoComplete:`off`,value:t,placeholder:i,disabled:a,className:X(g.length>0&&`pr-9`),onFocus:()=>p(g.length>0),onChange:e=>{n(e.target.value),p(g.length>0),h(-1)},onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),b(1);else if(e.key===`ArrowUp`)e.preventDefault(),b(-1);else if(e.key===`Enter`&&v&&m>=0){e.preventDefault();let t=_[m];t&&y(t.reference.model)}else e.key===`Escape`&&f&&(e.preventDefault(),e.stopPropagation(),p(!1),h(-1))}}),g.length>0?(0,$.jsx)(`button`,{type:`button`,"aria-label":u(`expand_options_fe7f0967`,{v0:e}),tabIndex:-1,disabled:a,className:`absolute inset-y-0 right-0 flex w-9 items-center justify-center text-muted-foreground disabled:opacity-50`,onMouseDown:e=>e.preventDefault(),onClick:()=>{p(e=>!e),h(-1),c.current?.focus()},children:(0,$.jsx)(oe,{className:`size-4`})}):null]}),v?(0,$.jsx)(`div`,{id:l,role:`listbox`,"aria-labelledby":d,className:`absolute inset-x-0 top-full z-[140] mt-1 max-h-52 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,children:_.map((e,n)=>{let r=e.reference.model,i=r===t;return(0,$.jsxs)(`button`,{id:`${l}-option-${n}`,type:`button`,role:`option`,"aria-selected":i,className:X(`flex w-full items-start gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none`,n===m&&`bg-accent text-accent-foreground`),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>h(n),onClick:()=>y(r),children:[(0,$.jsx)(ae,{className:X(`mt-0.5 size-3.5 shrink-0`,i?`opacity-100`:`opacity-0`)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate`,children:r}),e.display_name&&e.display_name!==r?(0,$.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.display_name}):null]})]},r)})}):null]})}function en({value:e,onChange:t,candidates:n,modelCapabilities:r,onVisionChange:i,onFetchModels:a,fetchingModels:s=!1,fetchModelsNotice:c,fetchModelsHint:l}){o();let[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),h=(0,Q.useMemo)(()=>new Set(e),[e]),g=(0,Q.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n,n);for(let e of n){let n=e.reference.model.trim();n&&t.set(n,e.display_name||n)}let r=d.trim().toLocaleLowerCase();return[...t].filter(([e,t])=>!r||e.toLocaleLowerCase().includes(r)||t.toLocaleLowerCase().includes(r))},[e,n,d]),_=()=>{let n=p.trim();n&&(h.has(n)||t([...e,n]),m(``))};return(0,$.jsxs)(`fieldset`,{"data-testid":`runtime-models-editor`,className:`space-y-2 rounded-md border bg-background p-2.5`,children:[(0,$.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:u(`runtime_models`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`runtime_models_hint`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`model_vision_hint`)}),(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:u(`runtime_models_selected`,{count:e.length})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(Z,{type:`search`,className:`min-w-0 flex-1`,"aria-label":u(`runtime_models_search`),placeholder:u(`runtime_models_search`),value:d,onChange:e=>f(e.target.value)}),(0,$.jsxs)(Y,{type:`button`,size:`sm`,variant:`secondary`,className:`shrink-0`,"aria-label":u(`runtime_models_fetch`),"aria-busy":s,disabled:!a||s,onClick:a,children:[(0,$.jsx)(pe,{className:X(`size-3.5`,s&&`animate-spin`)}),u(s?`runtime_models_fetching`:`runtime_models_fetch`)]})]}),l?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}):null,c?(0,$.jsx)(`p`,{role:c.tone===`error`?`alert`:`status`,className:X(`text-xs`,c.tone===`success`&&`text-emerald-500`,c.tone===`loading`&&`text-muted-foreground`,c.tone===`warning`&&`text-amber-600 dark:text-amber-300`,c.tone===`error`&&`text-destructive`),children:c.text}):null,(0,$.jsxs)(`div`,{className:`max-h-52 space-y-1 overflow-y-auto`,children:[g.map(([n,a])=>(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-2 rounded px-1 py-1.5 text-xs hover:bg-muted sm:flex-row`,children:[(0,$.jsxs)(`label`,{className:`flex min-w-0 max-w-full flex-1 cursor-pointer items-start gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,"aria-label":n,checked:h.has(n),className:`mt-0.5 shrink-0`,onChange:r=>t(r.target.checked?[...e,n]:e.filter(e=>e!==n))}),(0,$.jsxs)(`span`,{className:`min-w-0 break-all`,children:[(0,$.jsx)(`span`,{className:`block font-mono`,children:n}),a===n?null:(0,$.jsx)(`span`,{className:`block text-muted-foreground`,children:a})]})]}),h.has(n)?(0,$.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{children:u(`model_vision_label`)}),(0,$.jsxs)(`select`,{"aria-label":u(`model_vision_for`,{model:n}),className:`max-w-full rounded border bg-background px-1 py-1 text-xs`,value:String(r[n]?.supports_vision!==!1),onChange:e=>i(n,e.target.value===`true`),children:[(0,$.jsx)(`option`,{value:`true`,children:u(`model_vision_yes`)}),(0,$.jsx)(`option`,{value:`false`,children:u(`model_vision_no`)})]})]}):null]},n)),g.length===0?(0,$.jsx)(`p`,{className:`py-1 text-xs text-muted-foreground`,children:u(`runtime_models_empty`)}):null]}),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:u(`runtime_models_custom_id`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{"aria-label":u(`runtime_models_custom_id`),value:p,placeholder:`vendor/custom-model`,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),_())}}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`secondary`,disabled:!p.trim(),onClick:_,children:u(`runtime_models_add`)})]})]})]})}var tn=[`anthropic`,`openai`,`gemini`,`copilot`,`bodhi`],nn=[{value:`none`,get label(){return u(`reasoning_none`)}},{value:`low`,get label(){return u(`low_aa9e366f`)}},{value:`medium`,get label(){return u(`medium_a567bdaa`)}},{value:`high`,get label(){return u(`high_b1c27820`)}},{value:`xhigh`,get label(){return u(`extra_high_392d0dce`)}},{value:`max`,get label(){return u(`max_9730c15f`)}}],rn=`__unset__`,an={anthropic:`sk-ant-…`,openai:`sk-…`,gemini:`AIza…`,copilot:``,bodhi:`bhi_sk_…`},on=e=>typeof e==`string`?e:e==null?``:String(e);function sn(e){let t=e?.config??{};return{type:e?.type??`anthropic`,label:e?.label??``,enabled:e?.enabled??!0,apiKey:Yt(t.api_key)?``:on(t.api_key),baseUrl:on(t.base_url),model:on(t.model),fastModel:typeof t.fast_model==`string`&&t.fast_model.trim()?t.fast_model:null,visionModel:typeof t.vision_model==`string`&&t.vision_model.trim()?t.vision_model:null,runtimeModels:e?Se(e):[],initialRuntimeModels:e?Se(e):[],modelCapabilities:structuredClone(e?.config.model_capabilities??{}),reasoningEffort:on(t.reasoning_effort),responsesOnlyModels:Array.isArray(t.responses_only_models)?t.responses_only_models.map(on).filter(Boolean).join(`
3
+ `):``,headlessAuth:t.headless_auth===!0,targetProvider:on(t.target_provider),requestOverridesJson:t.request_overrides==null?``:JSON.stringify(t.request_overrides,null,2)}}function cn(e,t,n){let r=e.type,i={},a={...e.modelCapabilities};for(let t of e.runtimeModels)!e.initialRuntimeModels.includes(t)&&a[t]?.supports_vision!==!1&&(a[t]={...a[t],supports_vision:!0});if(i.model_capabilities=a,i.runtime_models=[...new Set(e.runtimeModels.map(e=>e.trim()).filter(Boolean))],e.model.trim()&&!i.runtime_models.includes(e.model.trim()))return{error:u(`runtime_models_default_required`)};let o=(e,n,r)=>{r?i[e]=n:t&&(i[e]=null)};if(r!==`copilot`){let r=e.apiKey.trim();if(r&&Yt(r)){if(!(t&&n))return{error:u(`a_masked_api_key_cannot_be_used_2b50d591`)}}else if(r)i.api_key=r;else if(!(t&&n))return{error:u(`api_key_is_required_91482829`)};o(`base_url`,e.baseUrl.trim(),e.baseUrl.trim()!==``)}if(o(`model`,e.model.trim(),e.model.trim()!==``),e.fastModel!==null&&o(`fast_model`,e.fastModel.trim(),e.fastModel.trim()!==``),e.visionModel!==null&&o(`vision_model`,e.visionModel.trim(),e.visionModel.trim()!==``),o(`reasoning_effort`,e.reasoningEffort,e.reasoningEffort!==``),r===`openai`||r===`copilot`){let n=e.responsesOnlyModels.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean);(n.length>0||t)&&(i.responses_only_models=n)}r===`copilot`&&(i.headless_auth=e.headlessAuth),r===`bodhi`&&o(`target_provider`,e.targetProvider,e.targetProvider!==``);let s=e.requestOverridesJson.trim();if(s)try{i.request_overrides=JSON.parse(s)}catch(e){return{error:u(`could_not_parse_request_overrides_json_d2ce243c`,{v0:e.message})}}else t&&(i.request_overrides=null);return{payload:{type:r,label:e.label.trim()||ke[r]||r,enabled:e.enabled,config:i}}}var ln=(e,t)=>{let n=q(e);for(let e of t)typeof e!=`string`||e.trim()===``||(n=n.replaceAll(e,`[REDACTED]`));return n.replace(/[*.]{4,}/g,`[REDACTED]`)};function un({label:e,value:t,onChange:n,type:r=`text`,placeholder:i}){return o(),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:e}),(0,$.jsx)(Z,{type:r,value:t,placeholder:i,onChange:e=>n(e.target.value)})]})}function dn({instance:e,onSave:t,onCancel:n,modelOptions:r=[],initialRuntimeModels:i,defaults:a,onFetchModels:s,fetchingModels:c,fetchModelsNotice:l}){o();let d=e!=null,f=Yt((e?.config??{}).api_key),[p,m]=(0,Q.useState)(()=>({...sn(e),...i?{runtimeModels:[...i],initialRuntimeModels:[...i]}:{}})),[h,g]=(0,Q.useState)(()=>{let t=sn(e);return t.requestOverridesJson!==``||t.responsesOnlyModels!==``||t.fastModel!==null||t.visionModel!==null}),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(``),C=e=>m(t=>({...t,...e})),w=p.type,T=Xt.find(e=>e.id===x)??null,E=e!==null&&(p.baseUrl.trim()!==on(e.config.base_url).trim()||p.apiKey.trim()!==``&&p.apiKey.trim()!==on(e.config.api_key).trim()||p.targetProvider!==on(e.config.target_provider)),D=e=>{if(e===rn){S(``);return}let t=Xt.find(t=>t.id===e);t&&(S(e),m(e=>({...e,type:t.provider_type,baseUrl:t.base_url,label:e.label.trim()===``?t.label:e.label})))},O=async()=>{if(e){let t=Se({...e,config:{fast_model:p.fastModel,vision_model:p.visionModel}},a).find(e=>!p.runtimeModels.includes(e));if(t){b(u(`runtime_models_in_use`,{model:t}));return}}let n=cn(p,d,f);if(`error`in n){b(n.error);return}v(!0),b(null);try{await t(n.payload)}catch(t){let n=(e?.config??{}).api_key;b(ln(t,[p.apiKey.trim(),n])),v(!1)}};return(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border bg-muted/30 p-3`,children:[(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:u(`vendor_preset_optional_fills_the_form_without_being_sav_b2935f04`)}),(0,$.jsxs)(W,{value:x||rn,onValueChange:D,children:[(0,$.jsx)(se,{className:`w-full`,"aria-label":u(`vendor_preset_65edf224`),children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:rn,children:u(`no_preset_64c25942`)}),Xt.map(e=>(0,$.jsx)(H,{value:e.id,disabled:d&&e.provider_type!==w,children:e.label},e.id))]})]}),T?.note?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:T.note}):null]}),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsxs)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:[u(`type_ba40014f`),d?u(`cannot_be_changed_after_creation_0f2775dc`):``]}),(0,$.jsxs)(W,{value:w,onValueChange:e=>{S(``),C({type:e})},disabled:d,children:[(0,$.jsx)(se,{className:`w-full`,"aria-label":u(`provider_type_6c9c029c`),children:(0,$.jsx)(V,{})}),(0,$.jsx)(ce,{children:tn.map(e=>(0,$.jsx)(H,{value:e,children:ke[e]??e},e))})]})]}),(0,$.jsx)(un,{label:u(`name_d44e9b3d`),value:p.label,onChange:e=>C({label:e}),placeholder:u(`e_g_my_c85274e7`,{v0:ke[w]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border bg-background px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`text-sm`,children:u(`enable_this_instance_271435c3`)}),(0,$.jsx)(Jt,{checked:p.enabled,onCheckedChange:e=>C({enabled:e})})]}),w===`copilot`?(0,$.jsx)(Qt,{}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(un,{label:`API Key`,value:p.apiKey,onChange:e=>C({apiKey:e}),type:`password`,placeholder:f?u(`configured_leave_blank_to_keep_f3805ede`):an[w]}),(0,$.jsx)(un,{label:u(`base_url_optional_0ae73047`),value:p.baseUrl,onChange:e=>C({baseUrl:e}),placeholder:w===`anthropic`?`https://api.anthropic.com`:w===`openai`?`https://api.openai.com/v1`:w===`gemini`?`https://generativelanguage.googleapis.com/v1beta`:`http://localhost:8080`})]}),w===`bodhi`?(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:u(`upstream_target_optional_df6cf793`)}),(0,$.jsxs)(W,{value:p.targetProvider||rn,onValueChange:e=>C({targetProvider:e===rn?``:e}),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:rn,children:u(`not_set_2f5f1d6f`)}),(0,$.jsx)(H,{value:`openai`,children:`OpenAI`}),(0,$.jsx)(H,{value:`anthropic`,children:`Anthropic`}),(0,$.jsx)(H,{value:`gemini`,children:`Gemini`})]})]})]}):null,w===`copilot`?(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border bg-background px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`headless_authorization_b4707eb5`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`print_the_sign_in_url_in_the_console_without_opening_a__55e7a61e`)})]}),(0,$.jsx)(Jt,{checked:p.headlessAuth,onCheckedChange:e=>C({headlessAuth:e})})]}):null,(0,$.jsx)(en,{value:p.runtimeModels,onChange:e=>C({runtimeModels:e}),candidates:r,onFetchModels:e&&!E&&!_?s:void 0,fetchingModels:c,fetchModelsNotice:l,fetchModelsHint:e?E?u(`runtime_models_fetch_save_changes`):void 0:u(`runtime_models_fetch_save_first`),modelCapabilities:p.modelCapabilities,onVisionChange:(e,t)=>C({modelCapabilities:{...p.modelCapabilities,[e]:{...p.modelCapabilities[e],supports_vision:t}}})}),(0,$.jsx)($t,{label:u(`default_model_optional_d2c2a9cc`),value:p.model,onChange:e=>C({model:e}),models:p.runtimeModels.map(t=>r.find(e=>e.reference.model===t)??{reference:{provider:e?.id??``,model:t},display_name:t,provider_display_name:e?.label??``,capabilities:{supports_tools:!0,supports_vision:!1,supports_reasoning:!1},source:`manual`}),placeholder:T?T.suggested_models.join(`, `):`glm-5.2`}),(0,$.jsx)(`div`,{children:(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:u(`reasoning_level_optional_2191ceaa`)}),(0,$.jsxs)(W,{value:p.reasoningEffort||rn,onValueChange:e=>C({reasoningEffort:e===rn?``:e}),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:rn,children:u(`default_unspecified_1c38331c`)}),nn.map(e=>(0,$.jsx)(H,{value:e.value,children:e.label},e.value))]})]})]})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,children:[h?(0,$.jsx)(oe,{className:`size-3.5`}):(0,$.jsx)(B,{className:`size-3.5`}),u(`advanced_settings_44455611`)]}),h?(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[p.fastModel!==null||p.visionModel!==null?(0,$.jsxs)(`fieldset`,{className:`space-y-2 rounded-md border p-2.5`,children:[(0,$.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:u(`runtime_models_legacy_assignments`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`runtime_models_legacy_assignments_hint`)}),p.fastModel===null?null:(0,$.jsx)(un,{label:u(`runtime_models_legacy_fast_model`),value:p.fastModel,onChange:e=>C({fastModel:e})}),p.visionModel===null?null:(0,$.jsx)(un,{label:u(`runtime_models_legacy_vision_model`),value:p.visionModel,onChange:e=>C({visionModel:e})})]}):null,w===`openai`||w===`copilot`?(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:u(`responses_only_models_optional_separate_with_spaces_com_ff7e394c`)}),(0,$.jsx)(Ze,{className:`min-h-14 resize-y font-mono text-xs`,value:p.responsesOnlyModels,placeholder:`gpt-5.3-codex
4
+ gpt-5*`,onChange:e=>C({responsesOnlyModels:e.target.value})})]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:u(`request_overrides_optional_json_6388420b`)}),(0,$.jsx)(Ze,{className:`min-h-20 resize-y font-mono text-xs`,value:p.requestOverridesJson,placeholder:`{"common":{"headers":{"X-Custom":"value"}}}`,onChange:e=>C({requestOverridesJson:e.target.value})})]})]}):null,y?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:y}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:n,disabled:_,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>void O(),disabled:_,children:u(_?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}var fn=`__unset__`,pn=`__auto__`,mn=[{value:`none`,get label(){return u(`reasoning_none`)}},{value:`low`,get label(){return u(`low_aa9e366f`)}},{value:`medium`,get label(){return u(`medium_a567bdaa`)}},{value:`high`,get label(){return u(`high_b1c27820`)}},{value:`xhigh`,get label(){return u(`extra_high_392d0dce`)}},{value:`max`,get label(){return u(`max_9730c15f`)}}],hn=[{key:`chat`,get label(){return u(`chat_required_e8946535`)},get description(){return u(`used_for_main_chat_and_as_the_final_fallback_for_other__56810104`)},required:!0},{key:`fast`,get label(){return u(`fast_db945cfe`)},get description(){return u(`used_for_lightweight_tasks_such_as_title_generation_and_5614b007`)},required:!1},{key:`vision`,get label(){return u(`vision_209c47b5`)},get description(){return u(`used_for_image_understanding_and_vision_fallback_falls__5854c68e`)},required:!1},{key:`sub_agent`,get label(){return u(`sub_agent_acd37b4c`)},get description(){return u(`default_for_new_subagents_falls_back_to_fast_then_chat__41df0ee5`)},required:!1}],gn=[{key:`task_summary`,get label(){return u(`task_summary_6c36c26b`)},get description(){return u(`used_for_task_summaries_and_conversation_compression_fa_a7e90752`)},required:!1},{key:`memory_background`,get label(){return u(`memory_background_86e700b0`)},get description(){return u(`used_for_memory_reranking_background_recall_and_auto_dr_1069ef2e`)},required:!1},{key:`planning`,get label(){return u(`planning_29d38fc5`)},get description(){return u(`used_for_task_breakdown_architecture_and_coordination_f_e1bd2846`)},required:!1},{key:`search`,get label(){return u(`search_44ce7ae9`)},get description(){return u(`used_for_code_search_file_navigation_and_symbol_lookup__7ea18af5`)},required:!1},{key:`code_review`,get label(){return u(`code_review_1fa3244c`)},get description(){return u(`used_for_code_review_and_pr_analysis_falls_back_to_fast_5273eb65`)},required:!1},{key:`work_review`,get label(){return u(`work_review_model_purpose`)},get description(){return u(`work_review_model_description`)},required:!1}],_n=[...hn,...gn],vn=()=>({provider:``,model:``,reasoningEffort:``}),yn=e=>({provider:e?.provider??``,model:e?.model??``,reasoningEffort:e?.reasoning_effort??``}),bn=e=>({provider:e.provider,model:e.model.trim(),...e.reasoningEffort?{reasoning_effort:e.reasoningEffort}:{}});function xn(e){return{roles:Object.fromEntries(ye.map(t=>[t,yn(e?.[t])])),subagentModels:Object.fromEntries(Object.entries(e?.subagent_models??{}).map(([e,t])=>[e,yn(t)]))}}var Sn=e=>JSON.stringify(e),Cn=e=>e.some(e=>e.kind===`default_provider_instance`),wn=(e,t)=>e.some(e=>e.kind===`default_model_ref`&&e.role===t),Tn=(e,t)=>e.some(e=>e.kind===`subagent_model_ref`&&e.subagent===t);function En(){o();let e=G(e=>e.providerSnapshot),t=G(e=>e.providerRepairSnapshot),n=G(e=>e.providerRepairIssues),r=G(e=>e.providerStatus),i=G(e=>e.providerError),a=G(e=>e.loadProviderInstances),s=G(e=>e.getModelsForProvider),c=G(e=>e.catalog),l=e??t,d=l?.instances??[],f=l?.defaults,p=r===`ready`||r===`degraded`,m=xn(f),[h,g]=(0,Q.useState)(()=>m),[_,v]=(0,Q.useState)(()=>Sn(m)),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),T=(0,Q.useMemo)(()=>Sn(h)!==_,[h,_]),E=(f?.chat.provider??``)!==``&&f?.chat.provider!==(l?.default_provider_instance_id??``),D=(0,Q.useRef)(T),O=(0,Q.useRef)(!1);D.current=T,(0,Q.useEffect)(()=>{if(D.current||O.current)return;let e=xn(f);g(e),v(Sn(e))},[f]);let k=(e,t)=>g(n=>({...n,roles:{...n.roles,[e]:{...n.roles[e],...t}}})),A=(e,t)=>g(n=>({...n,subagentModels:{...n.subagentModels,[e]:{...n.subagentModels[e]??vn(),...t}}})),j=async()=>{let e=new Map(d.map(e=>[e.id,e]));for(let t of _n){let r=h.roles[t.key];if(!r.provider&&!r.model.trim()){if(t.required){S(u(`select_a_provider_and_model_for_the_chat_default_5d2bf930`));return}if(wn(n,t.key)){S(u(`explicitly_replace_the_broken_reference_with_an_existin_158974d9`,{v0:t.label}));return}continue}if(!r.provider||!r.model.trim()){S(u(`select_both_a_provider_and_model_for_ebb2b990`,{v0:t.label}));return}let i=e.get(r.provider);if(!i){S(u(`the_provider_referenced_by_is_invalid_select_an_existin_55330622`,{v0:t.label}));return}if(!i.enabled){S(u(`the_provider_referenced_by_is_disabled_enable_it_or_sel_e71c0c57`,{v0:t.label}));return}if(!Se(i,f).includes(r.model.trim())){S(u(`runtime_models_role_required`,{model:r.model.trim()}));return}}for(let[t,n]of Object.entries(h.subagentModels)){let r=e.get(n.provider);if(!n.provider||!n.model.trim()||!r){S(u(`explicitly_replace_the_broken_subagent_reference_with_a_523237bc`,{v0:t}));return}if(!r.enabled){S(u(`the_provider_for_subagent_is_disabled_enable_it_or_sele_ef0263ac`,{v0:t}));return}if(!Se(r,f).includes(n.model.trim())){S(u(`runtime_models_role_required`,{model:n.model.trim()}));return}}O.current=!0,b(!0),S(null),w(!1);try{let e={};for(let t of _n){let n=h.roles[t.key],r=n.provider!==``&&n.model.trim()!==``;e[t.key]=r?bn(n):null}e.subagent_models=Object.fromEntries(Object.entries(h.subagentModels).map(([e,t])=>[e,bn(t)]));let t=await J.get(`/bamboo/config`);await J.post(`/bamboo/config`,{defaults:e,default_provider_instance:h.roles.chat.provider,...t?.model_limits===void 0?{}:{model_limits:t.model_limits}});let n=await a(),r=xn(n.defaults);g(r),v(Sn(r)),D.current=!1;let i=xe(n);i.length>0?S(u(`preferences_saved_but_references_remain_invalid_repair__777c4ffa`,{v0:i.length})):(w(!0),setTimeout(()=>w(!1),2500))}catch(e){S(q(e))}finally{O.current=!1,b(!1)}},M=e=>{let t=d.some(t=>t.id===e);return(0,$.jsxs)($.Fragment,{children:[e&&!t?(0,$.jsxs)(H,{value:e,disabled:!0,children:[e,u(`invalid_replace_67f9041a`)]}):null,d.map(e=>(0,$.jsxs)(H,{value:e.id,disabled:!e.enabled,children:[e.label||e.type,e.enabled?``:u(`disabled_7f9b2a77`)]},e.id))]})},N=e=>{let t=h.roles[e.key],r=t.provider&&c?s(t.provider):[],i=wn(n,e.key);return(0,$.jsxs)(`div`,{className:X(`rounded-md border p-2.5`,i&&`border-amber-500/50 bg-amber-500/5`),children:[(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-muted-foreground`,children:e.description})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_9rem]`,children:[(0,$.jsxs)(W,{value:t.provider||fn,onValueChange:n=>{if(n===fn){k(e.key,vn());return}k(e.key,{provider:n,model:n===t.provider?t.model:``})},children:[(0,$.jsx)(se,{className:`w-full`,"aria-label":u(`provider_a386a8dd`,{v0:e.label}),children:(0,$.jsx)(V,{placeholder:u(`provider_9e218722`)})}),(0,$.jsxs)(ce,{children:[!e.required&&!i?(0,$.jsx)(H,{value:fn,children:u(`not_set_2f5f1d6f`)}):null,M(t.provider)]})]}),(0,$.jsx)($t,{label:u(`model_a40c0922`,{v0:e.label}),hideLabel:!0,value:t.model,models:r,placeholder:u(`model_id_8b84338d`),disabled:!t.provider,onChange:t=>k(e.key,{model:t})}),(0,$.jsxs)(W,{value:t.reasoningEffort||pn,disabled:!t.provider,onValueChange:t=>k(e.key,{reasoningEffort:t===pn?``:t}),children:[(0,$.jsx)(se,{className:`w-full`,"aria-label":u(`reasoning_level_fab1021c`,{v0:e.label}),children:(0,$.jsx)(V,{placeholder:u(`reasoning_level_c8c14507`)})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:pn,children:u(`auto_7eb336e4`)}),mn.map(e=>(0,$.jsx)(H,{value:e.value,children:e.label},e.value))]})]})]})]},e.key)},P=gn.filter(({key:e})=>{let t=h.roles[e];return t.provider!==``&&t.model.trim()!==``}).length,ee=gn.some(({key:e})=>wn(n,e));if(!p){let e=u(r===`incompatible`?`this_bamboo_provider_configuration_format_is_incompatib_8eefe79f`:r===`unavailable`?`provider_settings_are_currently_unavailable_b04506b2`:`loading_provider_settings_46da40c3`);return(0,$.jsx)(`section`,{className:`rounded-lg border p-3`,children:(0,$.jsxs)(`p`,{role:r===`unavailable`||r===`incompatible`?`alert`:void 0,className:`text-xs text-muted-foreground`,children:[e,i?` ${i}`:``]})})}return(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`default_model_preferences_acdce210`)}),(0,$.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:u(`four_common_purposes_appear_first_unset_specialist_mode_50869c72`)}),Cn(n)||E?(0,$.jsx)(`p`,{role:`alert`,className:`mb-2 rounded-md border border-amber-500/50 p-2 text-xs text-amber-700 dark:text-amber-300`,children:u(`provider_routing_is_not_synchronized_with_chat_preferen_23f833cd`)}):null,(0,$.jsx)(`div`,{role:`group`,"aria-label":u(`common_model_purposes_4ad51f49`),className:`space-y-2`,children:hn.map(N)}),(0,$.jsxs)(`details`,{className:`mt-3 rounded-md border`,open:ee||void 0,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-2.5 py-2 text-xs font-medium text-muted-foreground`,children:[u(`advanced_model_routing_62a178ed`),` `,(0,$.jsxs)(`span`,{className:`font-normal`,children:[u(`usually_unnecessary_f3a49923`),P>0?u(`configured_e17db314`,{v0:P}):``]})]}),(0,$.jsxs)(`div`,{className:`border-t p-2.5`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-[11px] leading-relaxed text-muted-foreground`,children:u(`override_common_models_only_for_the_corresponding_speci_e1d880b7`)}),(0,$.jsx)(`div`,{role:`group`,"aria-label":u(`advanced_model_purposes_c23c6a8e`),className:`space-y-2`,children:gn.map(N)})]})]}),Object.keys(h.subagentModels).length>0?(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`subagent_model_mapping_4238aed0`)}),Object.entries(h.subagentModels).map(([e,t])=>{let r=t.provider&&c?s(t.provider):[];return(0,$.jsxs)(`div`,{className:X(`rounded-md`,Tn(n,e)&&`border border-amber-500/50 bg-amber-500/5 p-1`),children:[(0,$.jsx)(`span`,{className:`mb-1 block truncate text-xs text-muted-foreground`,title:e,children:e}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_9rem]`,children:[(0,$.jsxs)(W,{value:t.provider,onValueChange:n=>A(e,{provider:n,model:n===t.provider?t.model:``}),children:[(0,$.jsx)(se,{className:`w-full`,"aria-label":u(`subagent_provider_7c3689a7`,{v0:e}),children:(0,$.jsx)(V,{placeholder:u(`provider_9e218722`)})}),(0,$.jsx)(ce,{children:M(t.provider)})]}),(0,$.jsx)($t,{label:u(`subagent_model_f8fb17fb`,{v0:e}),hideLabel:!0,value:t.model,models:r,placeholder:u(`model_id_8b84338d`),disabled:!t.provider,onChange:t=>A(e,{model:t})}),(0,$.jsxs)(W,{value:t.reasoningEffort||pn,disabled:!t.provider,onValueChange:t=>A(e,{reasoningEffort:t===pn?``:t}),children:[(0,$.jsx)(se,{className:`w-full`,"aria-label":u(`subagent_reasoning_level_f14c2262`,{v0:e}),children:(0,$.jsx)(V,{placeholder:u(`reasoning_level_c8c14507`)})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:pn,children:u(`auto_7eb336e4`)}),mn.map(e=>(0,$.jsx)(H,{value:e.value,children:e.label},e.value))]})]})]})]},e)})]}):null,x?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:x}):null,(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-end gap-2`,children:[C?(0,$.jsx)(`span`,{className:`text-xs text-emerald-500`,children:u(`saved_1bd91a7d`)}):null,(0,$.jsx)(Y,{size:`sm`,onClick:()=>void j(),disabled:y||!T&&!E,children:u(y?`saving_ff509c9b`:`save_preferences_f96c9903`)})]})]})}function Dn(){o();let e=G(e=>e.providerSnapshot),t=G(e=>e.providerRepairSnapshot),n=G(e=>e.providerRepairIssues),r=G(e=>e.providerStatus),i=G(e=>e.providerError),a=G(e=>e.loadProviderInstances),s=G(e=>e.createProviderInstance),c=G(e=>e.updateProviderInstance),l=G(e=>e.deleteProviderInstance),d=G(e=>e.loadCatalog),f=G(e=>e.fetchCatalogModels),p=G(e=>e.catalog),m=G(e=>e.discoveredModelsByProvider),h=e??t,g=h?.instances??[],_=h?.defaults?.chat.provider??null,v=h?.default_provider_instance_id??null,y=r===`ready`||r===`degraded`,[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),[P,ee]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(null),[L,re]=(0,Q.useState)(null),R=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{a().catch(()=>void 0)},[a]),(0,Q.useEffect)(()=>{!y||p!==null||R.current||(R.current=!0,d())},[y,p,d]);let z=async e=>{let t=await s({type:e.type,label:e.label,enabled:e.enabled,config:e.config});if(C(!1),!t.responseValid||!t.instance){re(null),I(t.authorityRefreshed?u(`the_instance_was_saved_and_the_list_reloaded_but_the_cr_6fe3f38e`):u(`the_instance_was_saved_but_neither_the_creation_respons_a47ff1ce`));return}let n=t.instance;t.instanceConfirmed?(x(n.id),re(null),I(null)):(re(n.id),I(t.authorityRefreshed?u(`was_saved_but_the_reloaded_list_has_not_confirmed_it_mo_ff5cbaca`,{v0:n.label}):u(`was_saved_but_the_instance_list_could_not_be_reloaded_m_673d8238`,{v0:n.label}))),N(n.id),ee(t.instanceConfirmed?{id:n.id,text:u(`instance_saved_discovering_models_83ad3667`),tone:`loading`}:null);try{await f(n.id);let e=G.getState().discoveredModelsByProvider[n.id]?.length??0,r=e>0?u(`runtime_models_saved_discovered`,{count:e}):u(`instance_saved_but_no_models_were_found_enter_a_custom__a6488023`);t.instanceConfirmed?ee({id:n.id,text:r,tone:e>0?`success`:`warning`}):I(u(`the_instance_list_could_not_be_reloaded_reload_before_c_b8ee7a2a`,{v0:r}))}catch{let e=u(`instance_saved_but_model_discovery_failed_enter_a_custo_e47612cc`);t.instanceConfirmed?ee({id:n.id,text:e,tone:`warning`}):I(u(`the_instance_list_could_not_be_reloaded_reload_before_c_b8ee7a2a`,{v0:e}))}finally{N(null)}},ie=e=>e===_?u(`switch_the_chat_model_preference_to_another_enabled_pro_9448959e`):e===v?u(`confirm_and_save_the_chat_provider_in_default_model_pre_0f535ee4`):null,ae=async(e,t)=>{if(!t.enabled){let t=ie(e);if(t)throw Error(t)}await c(e,{label:t.label,enabled:t.enabled,config:t.config}),await d(),await Oe.getState().fetchModels(),ee(t=>t?.id===e?null:t),x(null)},oe=async(e,t)=>{if(T(null),!t){let t=ie(e.id);if(t){T(t);return}}try{await c(e.id,{enabled:t})}catch(n){T(u(`failed_72c709b0`,{v0:e.label||e.type,v1:u(t?`enable_action`:`disable_4e6fd0e2`),v2:q(n)}))}},B=async e=>{x(e.id),N(e.id),ee({id:e.id,text:u(`runtime_models_fetching`),tone:`loading`});try{await f(e.id);let t=G.getState().discoveredModelsByProvider[e.id]?.length??0;ee({id:e.id,text:t>0?u(`runtime_models_discovered`,{count:t}):u(`no_models_found_you_can_enter_a_custom_model_id_in_the__f7b4e163`),tone:t>0?`success`:`warning`})}catch{ee({id:e.id,text:u(`model_discovery_failed_check_the_instance_settings_and__c3f830b9`),tone:`error`})}finally{N(null)}},V=async()=>{T(null);try{let e=await a(),t=L;t&&e.instances.some(e=>e.id===t)?(I(null),re(null),x(t)):I(u(t?`instance_saved_but_the_reloaded_list_has_not_confirmed__1d5018ee`:`the_list_was_reloaded_but_the_creation_response_has_no__08755e58`))}catch{T(u(`instance_saved_but_the_provider_list_still_cannot_be_re_6fdc1782`))}},se=e=>m[e]??p?.models.filter(t=>t.reference.provider===e)??[],ce=async()=>{if(E){k(!0),j(null);try{await l(E.id),D(null)}catch(e){j(q(e))}finally{k(!1)}}};return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`configure_llm_providers_api_keys_and_available_models_4caf6573`)}),!S&&y&&!F?(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:()=>{C(!0)},children:[(0,$.jsx)(fe,{className:`size-4`}),u(`add_0006d696`)]}):null]}),r===`idle`||r===`loading`?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_provider_settings_46da40c3`)}):null,r===`unavailable`?(0,$.jsxs)(`div`,{role:`alert`,className:`rounded-lg border border-destructive/40 p-3 text-xs text-destructive`,children:[u(`provider_settings_are_currently_unavailable_b04506b2`),i?` ${i}`:``]}):null,r===`incompatible`?(0,$.jsxs)(`div`,{role:`alert`,className:`rounded-lg border border-destructive/40 p-3 text-xs text-destructive`,children:[u(`this_bamboo_provider_configuration_format_is_incompatib_8eefe79f`),i?` ${i}`:``]}):null,r===`degraded`?(0,$.jsxs)(`div`,{role:`alert`,className:`rounded-lg border border-amber-500/50 bg-amber-500/5 p-3 text-xs text-amber-700 dark:text-amber-300`,children:[u(`provider_or_model_preferences_contain_broken_references_a5de7472`),n.length,` `,u(`valid_instances_can_still_be_managed_but_chat_and_runti_301d8be4`)]}):null,F?(0,$.jsxs)(`div`,{role:`status`,className:`flex items-start justify-between gap-3 rounded-lg border border-amber-500/50 bg-amber-500/5 p-3 text-xs text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(`span`,{children:F}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>void V(),children:u(`reload_7bdd5ce1`)})]}):null,w?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:w}):null,S&&y?(0,$.jsx)(dn,{instance:null,onCancel:()=>C(!1),onSave:z}):null,y?(0,$.jsx)(`ul`,{className:`space-y-2`,children:g.map(e=>(0,$.jsx)(`li`,{className:`rounded-lg border p-3`,children:b===e.id?(0,$.jsx)(dn,{instance:e,modelOptions:se(e.id),initialRuntimeModels:Se(e,h?.defaults),defaults:h?.defaults,onFetchModels:()=>void B(e),fetchingModels:M===e.id,fetchModelsNotice:P?.id===e.id?P:void 0,onCancel:()=>x(null),onSave:t=>ae(e.id,t)}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.label||e.type}),e.enabled?null:(0,$.jsx)(U,{variant:`secondary`,className:`shrink-0 px-1.5 text-[10px]`,children:u(`disabled_a8c3698b`)})]}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:ke[e.type]??e.type})]}),(0,$.jsx)(Jt,{checked:e.enabled,onCheckedChange:t=>void oe(e,t),"aria-label":e.enabled?u(`disable_4e6fd0e2`):u(`enable_action`),className:`shrink-0`}),(0,$.jsx)(`button`,{onClick:()=>void B(e),"aria-label":u(`discover_models_22572a98`),title:u(`discover_models_22572a98`),disabled:M===e.id,className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,$.jsx)(pe,{className:X(`size-3.5`,M===e.id&&`animate-spin`)})}),(0,$.jsx)(`button`,{onClick:()=>{x(e.id),F&&L===null&&I(null)},"aria-label":u(`edit_05183656`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(te,{className:`size-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>{j(null),D(e)},"aria-label":u(`delete_2f9daa82`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]})})},e.id))}):null,y&&g.length===0&&!S?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_provider_instances_yet_click_add_to_create_one_9f673789`)}):null,(0,$.jsx)(`div`,{hidden:!y,children:(0,$.jsx)(En,{})}),(0,$.jsx)(Ge,{open:E!=null,onOpenChange:e=>e?null:D(null),children:(0,$.jsxs)(Ue,{className:`gap-3 p-4`,children:[(0,$.jsx)(He,{children:u(`delete_provider_instance_c190bd28`)}),(0,$.jsxs)(We,{children:[u(`delete_72f49a52`),E?.label||E?.type,u(`default_model_preferences_that_reference_it_will_become_2c834ea2`)]}),A?(0,$.jsxs)(`p`,{className:`text-xs text-destructive`,children:[u(`deletion_failed_8b176752`),A]}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>D(null),disabled:O,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>void ce(),disabled:O,children:u(O?`deleting_5e8e7af5`:`delete_2f9daa82`)})]})]})})]})}var On=function(e){return e.Connecting=`connecting`,e.Ready=`ready`,e.Degraded=`degraded`,e.Stopped=`stopped`,e.Error=`error`,e}({}),kn=/^[a-zA-Z0-9_-]+$/,An=6e4,jn=3e4,Mn=2e4,Nn=1e4,Pn=e=>({id:e,enabled:!0,transport:{type:`stdio`,command:``,args:[],env:{},startup_timeout_ms:Mn},request_timeout_ms:An,healthcheck_interval_ms:jn,allowed_tools:[],denied_tools:[]}),Fn=()=>({status:`stopped`,tool_count:0,restart_count:0}),In=500,Ln=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Rn=(e,t)=>Object.hasOwn(e,t),zn=(e,t)=>Object.keys(e).every(e=>t.includes(e)),Bn=e=>typeof e==`string`,Vn=e=>typeof e==`boolean`,Hn=e=>Array.isArray(e)&&e.every(Bn),Un=e=>Ln(e)&&Object.values(e).every(Bn),Wn=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,Gn=(e,t,n,r=!1)=>!Rn(e,t)||r&&e[t]===null||n(e[t]),Kn=[`id`,`name`,`enabled`,`request_timeout_ms`,`healthcheck_interval_ms`,`reconnect`,`allowed_tools`,`denied_tools`],qn=[`command`,`args`,`cwd`,`env`,`env_encrypted`,`env_credential_refs`,`startup_timeout_ms`],Jn=[`url`,`headers`,`connect_timeout_ms`],Yn=[...Kn,...qn,...Jn,`disabled`,`transport_kind`,`headers_encrypted`,`header_credential_refs`];function Xn(e,t){return t&&(e===null||Un(e))?!0:Array.isArray(e)&&e.every(e=>Ln(e)&&zn(e,[`name`,`value`,`value_encrypted`,`credential_ref`])&&typeof e.name==`string`&&!!e.name.trim()&&Gn(e,`value`,Bn)&&Gn(e,`value_encrypted`,Bn,!0)&&Gn(e,`credential_ref`,Bn,!0))}function Zn(e,t){if(!Gn(e,`name`,Bn,!0)||!Gn(e,`enabled`,Vn,t)||!Gn(e,`allowed_tools`,Hn)||!Gn(e,`denied_tools`,Hn)||!Gn(e,`request_timeout_ms`,Wn,t)||!Gn(e,`healthcheck_interval_ms`,Wn,t))return!1;if(!Rn(e,`reconnect`)||t&&e.reconnect===null)return!0;let n=e.reconnect;return Ln(n)&&zn(n,[`enabled`,`initial_backoff_ms`,`max_backoff_ms`,`max_attempts`])&&Gn(n,`enabled`,Vn)&&Gn(n,`initial_backoff_ms`,Wn)&&Gn(n,`max_backoff_ms`,Wn)&&Gn(n,`max_attempts`,e=>Wn(e)&&e<=4294967295)}function Qn(e){let t=e=>({ok:!1,error:e});if(!e.trim())return t(u(`provide_a_complete_json_configuration_containing_a_mcps_2e2c18b7`));if(e.length>1048576||new TextEncoder().encode(e).length>1048576)return t(u(`json_configuration_must_be_at_most_1_mib_9939f15a`));let n;try{n=JSON.parse(e)}catch{return t(u(`invalid_json_check_quotes_commas_and_brackets_error_det_f1e650ac`))}if(!Ln(n)||!zn(n,[`mcpServers`])||!Ln(n.mcpServers))return t(u(`only_a_complete_mcpservers_server_id_object_is_supporte_afa6183d`));let r=Object.entries(n.mcpServers);if(!r.length)return t(u(`mcpservers_cannot_be_empty_import_cannot_clear_all_serv_570ab194`));if(r.length>In)return t(u(`import_at_most_500_servers_at_a_time_4dd89598`));if(Rn(n.mcpServers,`servers`))return t(u(`legacy_servers_lists_are_unsupported_servers_is_a_reser_47c104f7`));let i=[];for(let[e,[n,a]]of r.entries()){let r=n=>t(u(`entry_82cdfe37`,{v0:e+1,v1:n}));if(n!==n.trim()||!kn.test(n))return r(u(`server_ids_may_contain_only_letters_digits_and_without__ab6bab76`));if(!Ln(a))return r(u(`server_configuration_must_be_an_object_8ae12c4c`));let o=Rn(a,`transport`);if(o&&Rn(a,`disabled`))return r(u(`use_enabled_for_internal_transport_configuration_the_ba_83e877c7`));if(!zn(a,o?[...Kn,`transport`]:Yn))return r(u(`unsupported_or_mixed_fields_for_http_use_transport_kind_7577394c`));if(!Zn(a,!o)||!Gn(a,`disabled`,Vn))return r(u(`invalid_types_for_enabled_state_tool_list_or_timeout_se_c69275c8`));let s=o?a.transport:a;if(!Ln(s))return r(u(`transport_must_be_an_object_1b0b3231`));let c;if(o){if(s.type!==`stdio`&&s.type!==`streamable_http`)return r(u(`unsupported_transport_type_5751fa29`));if(c=s.type,!zn(s,[`type`,...c===`stdio`?qn:Jn]))return r(u(`transport_contains_unsupported_fields_379bbbcd`))}else{let e=a.command!==void 0&&a.command!==null;if(e===(a.url!==void 0&&a.url!==null))return r(u(`provide_either_command_or_url_not_both_c8e9f37c`));if(a.transport_kind!==void 0&&a.transport_kind!==null&&(e||a.transport_kind!==`streamable_http`))return r(u(`transport_kind_supports_only_remote_sse_or_streamable_h_647a07bf`));if(c=e?`stdio`:`streamable_http`,!zn(a,[...Kn,`disabled`,...c===`stdio`?qn:[...Jn,`transport_kind`,`headers_encrypted`,`header_credential_refs`]]))return r(u(`do_not_mix_fields_from_different_transport_types_0c9b1f51`))}if(c===`stdio`){if(typeof s.command!=`string`||!s.command.trim()||!Gn(s,`args`,Hn)||!Gn(s,`cwd`,Bn,!0)||!Gn(s,`startup_timeout_ms`,Wn,!o))return r(u(`invalid_stdio_command_arguments_working_directory_or_st_d88fa0a6`));for(let e of[`env`,`env_encrypted`,`env_credential_refs`])if(!Gn(s,e,Un))return r(u(`environment_variables_and_credential_references_must_be_aa85c455`))}else{try{if(typeof s.url!=`string`||![`http:`,`https:`].includes(new URL(s.url).protocol))return r(u(`remote_urls_must_use_http_or_https_290c9d54`))}catch{return r(u(`invalid_remote_url_format_161cb180`))}if(!Gn(s,`headers`,e=>Xn(e,!o))||!Gn(s,`connect_timeout_ms`,Wn,!o)||!Gn(a,`headers_encrypted`,Un)||!Gn(a,`header_credential_refs`,Un))return r(u(`invalid_headers_or_connection_timeout_header_values_mus_ac9684fd`))}i.push({id:n,transport:c,enabled:typeof a.enabled==`boolean`?a.enabled:o||!a.disabled})}return{ok:!0,value:{mcpServers:n.mcpServers,servers:i}}}var $n=e=>JSON.stringify([...e].sort());function er(e,t,n){let r=new Set(e),i=new Set(t);return{added:e.filter(e=>!i.has(e)),updated:e.filter(e=>i.has(e)),removed:n===`replace`?t.filter(e=>!r.has(e)).sort():[]}}var tr=e=>[...new Set(e)].sort(),nr=e=>Ln(e)?Object.keys(e):[],rr=e=>Array.isArray(e)?e.flatMap(e=>Ln(e)&&typeof e.name==`string`?[e.name]:[]):nr(e),ir=e=>{let t=Ln(e)?e:{};return{enabled:typeof t.enabled==`boolean`?t.enabled:!0,initial_backoff_ms:typeof t.initial_backoff_ms==`number`?t.initial_backoff_ms:1e3,max_backoff_ms:typeof t.max_backoff_ms==`number`?t.max_backoff_ms:3e4,max_attempts:typeof t.max_attempts==`number`?t.max_attempts:0}};function ar(e,t){let n=Ln(e.transport)?e.transport:e,r={name:typeof e.name==`string`?e.name:null,enabled:t.enabled,request_timeout_ms:typeof e.request_timeout_ms==`number`?e.request_timeout_ms:An,healthcheck_interval_ms:typeof e.healthcheck_interval_ms==`number`?e.healthcheck_interval_ms:jn,reconnect:ir(e.reconnect),allowed_tools:tr(Array.isArray(e.allowed_tools)?e.allowed_tools.filter(Bn):[]),denied_tools:tr(Array.isArray(e.denied_tools)?e.denied_tools.filter(Bn):[])};return t.transport===`stdio`?{...r,transport:{type:`stdio`,command:n.command,args:Array.isArray(n.args)?n.args:[],cwd:typeof n.cwd==`string`?n.cwd:null,env_names:tr([...nr(n.env),...nr(n.env_encrypted),...nr(n.env_credential_refs)]),startup_timeout_ms:typeof n.startup_timeout_ms==`number`?n.startup_timeout_ms:Mn}}:{...r,transport:{type:t.transport,url:n.url,header_names:tr([...rr(n.headers),...nr(e.headers_encrypted),...nr(e.header_credential_refs)]),connect_timeout_ms:typeof n.connect_timeout_ms==`number`?n.connect_timeout_ms:Nn}}}function or(e){let t=e.config,n={name:typeof t.name==`string`?t.name:null,enabled:t.enabled,request_timeout_ms:t.request_timeout_ms,healthcheck_interval_ms:t.healthcheck_interval_ms,reconnect:ir(t.reconnect),allowed_tools:tr(t.allowed_tools),denied_tools:tr(t.denied_tools)};return t.transport.type===`stdio`?{...n,transport:{type:`stdio`,command:t.transport.command,args:t.transport.args,cwd:t.transport.cwd??null,env_names:tr(Object.keys(t.transport.env)),startup_timeout_ms:t.transport.startup_timeout_ms??2e4}}:{...n,transport:{type:t.transport.type,url:t.transport.url,header_names:tr(t.transport.headers.map(e=>e.name)),connect_timeout_ms:t.transport.connect_timeout_ms??1e4}}}function sr(e,t){let n;try{n=Qn(JSON.stringify({mcpServers:e.mcpServers}))}catch{return!1}if(!n.ok)return!1;let r=n.value.servers.map(e=>e.id);if(e.mode===`replace`&&$n(t.map(e=>e.id))!==$n(r))return!1;let i=new Map(t.map(e=>[e.id,e]));return n.value.servers.every(t=>{let n=e.mcpServers[t.id],r=i.get(t.id);return Ln(n)&&r!==void 0&&JSON.stringify(ar(n,t))===JSON.stringify(or(r))})}var cr=class extends Error{kind;constructor(e){super({busy:u(`an_import_is_already_in_progress_wait_for_completion_th_fb46ceab`),rejected:u(`the_server_rejected_the_import_without_committing_confi_32d442f4`),uncertain:u(`the_import_result_cannot_be_confirmed_yet_further_opera_2d04c1a1`),not_applied:u(`the_actual_list_was_checked_automatically_this_configur_99fce191`),list_changed:u(`the_server_list_has_changed_review_the_preview_and_conf_2e03f9bc`),list_unavailable:u(`the_current_server_list_could_not_be_confirmed_refresh__986de92b`)}[e]),this.kind=e,this.name=`McpImportFailure`}};function lr(e,t){let n=Object.keys(t.mcpServers);if(!Ln(e)||e.mode!==t.mode||!Wn(e.added)||!Wn(e.updated)||!Wn(e.removed)||e.added+e.updated!==n.length||t.mode===`merge`&&e.removed!==0||!Hn(e.server_ids)||$n(e.server_ids)!==$n(n)||e.start_errors!==void 0&&(!Array.isArray(e.start_errors)||e.start_errors.length>0))throw new cr(`uncertain`);return{mode:t.mode,added:e.added,updated:e.updated,removed:e.removed,server_ids:n.sort()}}var ur=e=>{switch(typeof e==`string`?e.trim().toLowerCase():``){case On.Connecting:return On.Connecting;case On.Ready:return On.Ready;case On.Degraded:return On.Degraded;case On.Error:return On.Error;case On.Stopped:default:return On.Stopped}},dr=(e,t)=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`){let t=Number(e);if(Number.isFinite(t))return t}return t},fr=(e,t)=>{if(!e||typeof e!=`object`)return t;let n=e;if(n.type===`streamablehttp`||n.type===`streamable_http`){let e=Array.isArray(n.headers)?n.headers.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.name!=`string`||typeof t.value!=`string`?null:{name:t.name,value:t.value}}).filter(e=>!!e):[];return{type:`streamable_http`,url:typeof n.url==`string`?n.url:``,headers:e,connect_timeout_ms:dr(n.connect_timeout_ms,Nn)}}let r=Array.isArray(n.args)?n.args.filter(e=>typeof e==`string`):[],i=n.env&&typeof n.env==`object`?Object.entries(n.env):[];return{type:`stdio`,command:typeof n.command==`string`?n.command:``,args:r,cwd:typeof n.cwd==`string`?n.cwd:void 0,env:i.reduce((e,[t,n])=>(typeof n==`string`&&(e[t]=n),e),{}),startup_timeout_ms:dr(n.startup_timeout_ms,Mn)}},pr=(e,t)=>{let n=Pn(e.id),r=t??{};return{...n,...r,id:e.id,name:typeof r.name==`string`?r.name:typeof e.name==`string`?e.name:void 0,enabled:typeof e.enabled==`boolean`?e.enabled:typeof r.enabled==`boolean`?r.enabled:!0,request_timeout_ms:dr(r.request_timeout_ms,An),healthcheck_interval_ms:dr(r.healthcheck_interval_ms,jn),allowed_tools:Array.isArray(r.allowed_tools)?r.allowed_tools.filter(e=>typeof e==`string`):[],denied_tools:Array.isArray(r.denied_tools)?r.denied_tools.filter(e=>typeof e==`string`):[],reconnect:r.reconnect&&typeof r.reconnect==`object`?{enabled:typeof r.reconnect.enabled==`boolean`?r.reconnect.enabled:!0,initial_backoff_ms:dr(r.reconnect.initial_backoff_ms,1e3),max_backoff_ms:dr(r.reconnect.max_backoff_ms,3e4),max_attempts:dr(r.reconnect.max_attempts,0)}:void 0,transport:fr(r.transport,n.transport)}},mr=e=>{let t=Fn(),n=e.runtime??{};return{status:ur(n.status??e.status),last_error:typeof n.last_error==`string`?n.last_error:typeof e.last_error==`string`?e.last_error:void 0,connected_at:typeof n.connected_at==`string`?n.connected_at:void 0,disconnected_at:typeof n.disconnected_at==`string`?n.disconnected_at:void 0,tool_count:dr(n.tool_count??e.tool_count,t.tool_count),restart_count:dr(n.restart_count??e.restart_count,t.restart_count),last_ping_at:typeof n.last_ping_at==`string`?n.last_ping_at:void 0}},hr=e=>{let t=pr(e,e.config);return{id:e.id,name:typeof e.name==`string`?e.name:typeof t.name==`string`?t.name:e.id,enabled:typeof e.enabled==`boolean`?e.enabled:t.enabled,config:t,runtime:mr(e)}},gr=(e,t)=>`mcp__${e}__${t}`,_r=e=>{if(!e.startsWith(`mcp__`))return null;let t=e.slice(5),n=t.indexOf(`__`);if(n<=0)return null;let r=t.slice(0,n),i=t.slice(n+2);return!r||!i?null:{server_id:r,original_name:i}},vr=(e,t,n=0)=>{if(!e||typeof e!=`object`)return null;let r=e,i=typeof r.alias==`string`?r.alias:typeof r.name==`string`&&r.name.startsWith(`mcp__`)?r.name:void 0,a=i&&typeof i==`string`?_r(i):null,o=(typeof r.server_id==`string`?r.server_id:void 0)??(typeof r.serverId==`string`?r.serverId:void 0)??a?.server_id??t??``,s=(typeof r.original_name==`string`?r.original_name:void 0)??(typeof r.originalName==`string`?r.originalName:void 0)??a?.original_name??(typeof r.name==`string`?r.name:void 0)??``,c=i??(o&&s?gr(o,s):``),l=typeof r.description==`string`?r.description:``,u=r,d=`parameters`in u?u.parameters:`inputSchema`in u?u.inputSchema:`input_schema`in u?u.input_schema:void 0,f=c||s||`mcp_tool_${n}`;return{alias:f,server_id:o||`unknown`,original_name:s||f,description:l,parameters:d}},yr=new class{importInFlight=!1;async getServers(){let e=await J.get(`mcp/servers`),t=new Set;if(!Ln(e)||!Array.isArray(e.servers)||!e.servers.every(e=>{if(!Ln(e)||typeof e.id!=`string`||!e.id.trim()||t.has(e.id)||typeof e.enabled!=`boolean`||!Ln(e.config)||!Ln(e.config.transport))return!1;let n=e.config.transport;if(e.config.id!==void 0&&e.config.id!==e.id)return!1;if(n.type===`stdio`){if(typeof n.command!=`string`||n.args!==void 0&&(!Array.isArray(n.args)||!n.args.every(e=>typeof e==`string`))||n.env!==void 0&&(!Ln(n.env)||!Object.values(n.env).every(e=>typeof e==`string`)))return!1}else if([`streamablehttp`,`streamable_http`].includes(n.type)){if(typeof n.url!=`string`||n.headers!==void 0&&(!Array.isArray(n.headers)||!n.headers.every(e=>Ln(e)&&typeof e.name==`string`&&typeof e.value==`string`)))return!1}else return!1;return t.add(e.id),!0}))throw Error(`MCP server list could not be verified.`);return e.servers.map(hr)}async addServer(e){return J.post(`mcp/servers`,e)}async updateServer(e,t){let n={...t,id:e};return J.put(`mcp/servers/${e}`,n)}async deleteServer(e){return J.delete(`mcp/servers/${e}`)}async connectServer(e){return J.post(`mcp/servers/${e}/connect`)}async disconnectServer(e){return J.post(`mcp/servers/${e}/disconnect`)}async refreshTools(e){return J.post(`mcp/servers/${e}/refresh`)}async getTools(e){let t=e?`mcp/servers/${e}/tools`:`mcp/tools`,n=await J.get(t);return(Array.isArray(n.tools)?n.tools:[]).map((t,n)=>vr(t,e,n)).filter(e=>!!e)}async importServers(e){if(this.importInFlight)throw new cr(`busy`);this.importInFlight=!0;try{return lr(await J.post(`mcp/servers/import`,e),e)}catch(e){throw e instanceof cr?e:new cr(Ne(e)&&e.status>=400&&e.status<500?`rejected`:`uncertain`)}finally{this.importInFlight=!1}}};function br({label:e,children:t}){return o(),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:e}),t]})}function xr({title:e,addLabel:t,keyPlaceholder:n,valuePlaceholder:r,entries:i,onChange:a}){return o(),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,$.jsxs)(Y,{type:`button`,size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,onClick:()=>a([...i,{k:``,v:``}]),children:[(0,$.jsx)(fe,{className:`size-3.5`}),` `,t]})]}),i.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:u(`none_484d5561`)}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:i.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Z,{className:`h-8 flex-1 font-mono text-xs`,placeholder:n,value:e.k,onChange:e=>a(i.map((n,r)=>r===t?{...n,k:e.target.value}:n))}),(0,$.jsx)(Z,{className:`h-8 flex-1 font-mono text-xs`,placeholder:r,value:e.v,onChange:e=>a(i.map((n,r)=>r===t?{...n,v:e.target.value}:n))}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(i.filter((e,n)=>n!==t)),"aria-label":u(`remove_6135d415`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ge,{className:`size-3.5`})})]},t))})]})}function Sr({open:e,mode:t,initial:n,existingIds:r,onCancel:i,onSubmit:a}){o();let[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(`stdio`),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!e)return;let r=t===`edit`&&n?n:null;c(r?.id??``),d(r?.name??``),p(r?.enabled??!0);let i=r?.transport;h(i?.type??`stdio`),_(i?.type===`stdio`?i.command:``),y(i?.type===`stdio`?i.args.join(`
5
+ `):``),x(i?.type===`stdio`?i.cwd??``:``),C(i?.type===`stdio`?Object.entries(i.env??{}).map(([e,t])=>({k:e,v:t})):[]),T(i&&i.type!==`stdio`?i.url:``),D(i&&i.type!==`stdio`?i.headers.map(e=>({k:e.name,v:e.value})):[]),k(null),j(!1)},[e,t,n]);let M=()=>{if(t===`create`){if(!s.trim())return u(`server_id_is_required_ce4bc4a2`);if(!kn.test(s.trim()))return u(`server_ids_may_contain_only_letters_digits_and_15c859fe`);if(r.includes(s.trim()))return u(`this_server_id_already_exists_e06921d5`)}if(m===`stdio`){if(!g.trim())return u(`command_is_required_eddb4f63`)}else{if(!w.trim())return u(`url_is_required_b0a85a80`);try{new URL(w.trim())}catch{return u(`invalid_url_format_aed7aaa6`)}}return null},N=()=>{let e=t===`edit`&&n?n.id:s.trim(),r=t===`edit`&&n?n:Pn(e),i=m===`stdio`?{type:`stdio`,command:g.trim(),args:v.split(`
6
+ `).map(e=>e.trim()).filter(Boolean),cwd:b.trim()?b.trim():void 0,env:S.reduce((e,t)=>(t.k.trim()&&(e[t.k.trim()]=t.v),e),{}),startup_timeout_ms:n?.transport.type===`stdio`?n.transport.startup_timeout_ms??2e4:Mn}:{type:m,url:w.trim(),headers:E.filter(e=>e.k.trim()).map(e=>({name:e.k.trim(),value:e.v})),connect_timeout_ms:n&&n.transport.type!==`stdio`?n.transport.connect_timeout_ms??1e4:Nn};return{...r,id:e,name:l.trim()||void 0,enabled:f,transport:i}};return(0,$.jsx)(Ge,{open:e,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(Ue,{className:`sm:max-w-lg`,children:[(0,$.jsx)(`div`,{className:`border-b px-4 py-3.5`,children:(0,$.jsx)(He,{children:u(t===`edit`?`edit_mcp_server_d9bc88f2`:`add_mcp_server_f4b0e747`)})}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[(0,$.jsx)(br,{label:u(`server_id_2964b36b`),children:(0,$.jsx)(Z,{placeholder:`filesystem`,value:s,disabled:t===`edit`,autoComplete:`off`,onChange:e=>c(e.target.value)})}),(0,$.jsx)(br,{label:u(`display_name_optional_1e3a880a`),children:(0,$.jsx)(Z,{placeholder:`Filesystem MCP`,value:l,autoComplete:`off`,onChange:e=>d(e.target.value)})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border bg-muted/30 px-3 py-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`enabled_f4f0ead1`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`connect_to_this_server_after_saving_0e2112fa`)})]}),(0,$.jsx)(Jt,{checked:f,onCheckedChange:p})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`mb-1 text-xs text-muted-foreground`,children:u(`transport_84dada05`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`stdio`,`streamable_http`].map(e=>(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:m===e?`default`:`secondary`,"aria-pressed":m===e,className:`flex-1`,onClick:()=>h(e),children:u(e===`stdio`?`stdio_local_process_e3d7ac94`:`streamable_http_remote_7ac7cbb2`)},e))})]}),m===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(br,{label:u(`command_928f87d4`),children:(0,$.jsx)(Z,{placeholder:`npx`,value:g,autoComplete:`off`,onChange:e=>_(e.target.value)})}),(0,$.jsx)(br,{label:u(`arguments_one_per_line_243b43f4`),children:(0,$.jsx)(Ze,{className:`min-h-16 resize-y font-mono text-xs`,placeholder:`-y
7
+ @modelcontextprotocol/server-filesystem
8
+ /Users/me`,value:v,onChange:e=>y(e.target.value)})}),(0,$.jsx)(br,{label:u(`working_directory_cwd_optional_dd5ce4a1`),children:(0,$.jsx)(Z,{placeholder:`/Users/me/project`,value:b,autoComplete:`off`,onChange:e=>x(e.target.value)})}),(0,$.jsx)(xr,{title:u(`environment_variables_ae27b474`),addLabel:u(`add_7a8a11ea`),keyPlaceholder:`MCP_ROOT`,valuePlaceholder:`/Users/me/workspace`,entries:S,onChange:C})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(br,{label:`URL`,children:(0,$.jsx)(Z,{placeholder:`http://localhost:4000/mcp`,value:w,autoComplete:`off`,onChange:e=>T(e.target.value)})}),(0,$.jsx)(xr,{title:u(`request_headers_70378530`),addLabel:u(`add_7a8a11ea`),keyPlaceholder:`Authorization`,valuePlaceholder:`Bearer token`,entries:E,onChange:D})]})]}),(0,$.jsxs)(`div`,{className:`border-t p-3`,children:[O?(0,$.jsx)(`p`,{className:`mb-2 text-xs break-all text-destructive`,role:`alert`,children:O}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:i,disabled:A,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,onClick:async()=>{let e=M();if(e){k(e);return}j(!0),k(null);try{await a(N())}catch(e){k(q(e))}finally{j(!1)}},disabled:A,children:u(A?`saving_ff509c9b`:t===`edit`?`save_a3030bf8`:`add_7a8a11ea`)})]})]})]})})}function Cr({serverId:e,version:t}){o();let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let t=!1;return a(null),yr.getTools(e).then(e=>{t||r(e)}).catch(e=>{t||(r([]),a(q(e)))}),()=>{t=!0}},[e,t]),i?(0,$.jsxs)(`p`,{className:`text-xs break-all text-destructive`,role:`alert`,children:[u(`could_not_load_tools_7cf37d72`),i]}):n===null?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_tools_3ab9b8bc`)}):n.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`this_server_exposes_no_tools_ca0d2452`)}):(0,$.jsx)(`ul`,{className:`space-y-1.5`,children:n.map(e=>(0,$.jsxs)(`li`,{className:`rounded-md border bg-muted/30 p-2`,children:[(0,$.jsx)(`div`,{className:`font-mono text-xs font-medium break-all`,children:e.original_name}),e.description?(0,$.jsx)(`div`,{className:`mt-0.5 text-xs whitespace-pre-wrap text-muted-foreground`,children:e.description}):null,e.parameters==null?null:(0,$.jsxs)(`details`,{className:`mt-1`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground select-none`,children:u(`argument_schema_50a739a9`)}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto rounded bg-muted p-2 text-[11px] leading-relaxed`,children:JSON.stringify(e.parameters,null,2)})]})]},e.alias))})}function wr({existingIds:e,listConfirmed:t,listRevision:n,onClose:r,onReturnFocus:i,onImport:a,onReconcile:s,onReload:l}){o();let[d,f]=(0,Q.useState)({text:``,revision:0}),[p,m]=(0,Q.useState)(`merge`),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),k=(0,Q.useRef)(!0),A=(0,Q.useRef)(!1),j=(0,Q.useRef)(0),M=(0,Q.useRef)(null);(0,Q.useEffect)(()=>(k.current=!0,()=>{k.current=!1,j.current+=1}),[]);let N=(0,Q.useMemo)(()=>Qn(d.text),[d.text]),P=er(N.ok?N.value.servers.map(e=>e.id):[],e,p),ee=$n(e),F=JSON.stringify([d.revision,p,n,ee,$n(P.removed)]),te=h===F&&t,ne=C===`uncertain`,I=y!==null,L=N.ok&&t&&!I&&!_&&!ne&&!D&&(p===`merge`||te),re=e=>{A.current||(j.current+=1,v(!1),f(t=>({text:e,revision:t.revision+1})),g(null),S(null),w(null),E(null))},R=async e=>{if(!e||A.current)return;re(``);let t=j.current;if(e.size>1048576){S(u(`json_files_must_be_at_most_1_mib_f27d4474`));return}v(!0);try{let n=await e.text();if(!k.current||t!==j.current)return;re(n)}catch{k.current&&t===j.current&&S(u(`could_not_read_the_json_file_select_it_again_or_paste_t_00aff047`))}finally{k.current&&t===j.current&&v(!1)}},z=e=>{O(e),f(e=>({text:``,revision:e.revision+1})),g(null),S(null),w(null),E(null)},ie=(e,t)=>{let n=e instanceof cr?e:new cr(`uncertain`);S(n.message),w(n.kind),g(null),E(n.kind===`uncertain`?t??null:null)},ae=async e=>{try{let t=await s(e.request,e.existingIds);k.current&&z(t)}catch(t){k.current&&ie(t,e)}},oe=async()=>{if(A.current||!L||!N.ok)return;let t={request:{mcpServers:N.value.mcpServers,mode:p},existingIds:[...e]};A.current=!0,b(`importing`),S(null),w(null),E(null);try{let e=await a(t.request,t.existingIds);if(!k.current)return;z(e)}catch(e){if(!k.current)return;let n=e instanceof cr?e:new cr(`uncertain`);n.kind===`uncertain`?(b(`reconciling`),await ae(t)):ie(n)}finally{A.current=!1,k.current&&b(null)}},B=async()=>{if(!(A.current||!T)){A.current=!0,b(`reconciling`),S(null),w(null);try{await ae(T)}finally{A.current=!1,k.current&&b(null)}}},V=async()=>{if(!A.current){A.current=!0,b(`refreshing`),g(null),S(null),w(null);try{let e=await l();if(!k.current)return;D&&O({...D,refreshed:e}),e||(S(u(`could_not_refresh_the_actual_list_try_again_later_no_im_7b17ed25`)),w(`list_unavailable`))}catch{k.current&&(S(u(`could_not_refresh_the_actual_list_try_again_later_no_im_7b17ed25`)),w(`list_unavailable`))}finally{A.current=!1,k.current&&b(null)}}},se=()=>{A.current||(j.current+=1,r())};return(0,$.jsx)(Ge,{open:!0,onOpenChange:e=>{e||se()},children:(0,$.jsxs)(Ue,{className:`sm:max-w-2xl`,dismissable:!I,showCloseButton:!1,onCloseAutoFocus:e=>{e.preventDefault(),i()},onOpenAutoFocus:e=>{e.preventDefault(),M.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`border-b px-4 py-3.5`,children:[(0,$.jsx)(He,{children:u(`import_mcp_json_a41b0e8e`)}),(0,$.jsx)(We,{className:`mt-2 text-xs`,children:u(`only_mcpservers_is_imported_configuration_stays_in_this_c3c8c01c`)})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[D?(0,$.jsxs)(`section`,{role:`status`,"aria-label":u(`import_result_e4039a16`),className:`space-y-2 rounded-md border p-3 text-sm`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:D.reconciled?u(`import_confirmed_44067475`):u(`import_completed_72695f79`)}),(0,$.jsxs)(`p`,{children:[u(`add_0006d696`),` `,D.result.added,` `,u(`updated_b1b3836b`),` `,D.result.updated,` `,u(`deleted_7dad13b3`),` `,D.result.removed]}),(0,$.jsxs)(`p`,{className:`break-all text-xs`,children:[u(`server_ids_4ab9d03b`),c(D.result.server_ids)]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:D.reconciled?u(`the_actual_server_list_was_checked_automatically_import_c90ee703`):D.refreshed?u(`the_actual_server_list_and_runtime_state_were_refreshed_6aca294f`):u(`configuration_submitted_runtime_state_will_refresh_auto_66de7fc4`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-xs`,children:[(0,$.jsx)(`span`,{children:u(`mcp_json_configuration_fa76d7f0`)}),(0,$.jsx)(Ze,{value:d.text,onChange:e=>re(e.target.value),disabled:I,className:`min-h-44 resize-y font-mono text-xs`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,placeholder:`{"mcpServers":{"example":{"command":"mcp-server","disabled":true}}}`})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-xs`,children:[(0,$.jsx)(`span`,{children:u(`choose_json_file_405a583f`)}),(0,$.jsx)(`input`,{type:`file`,accept:`.json,application/json`,disabled:I,className:`block w-full min-w-0 text-xs`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,R(t)}})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`at_most_1_mib_and_500_servers_preview_shows_only_ids_tr_06a6a9d6`)}),_?(0,$.jsx)(`p`,{role:`status`,className:`text-xs`,children:u(`reading_json_file_eb7090c4`)}):null,d.revision>0&&!_&&!x&&!N.ok?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:N.error}):null,(0,$.jsxs)(`fieldset`,{disabled:I,className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-1 text-xs font-medium`,children:u(`import_mode_6ac2e247`)}),[`merge`,`replace`].map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`mcp-import-mode`,value:e,checked:p===e,onChange:()=>{A.current||(m(e),g(null),S(null),w(null),E(null))}}),u(e===`merge`?`merge_by_id_40ecfb02`:`replace_all_02ac1ef7`)]},e))]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(p===`merge`?`merge_replaces_the_entire_server_entry_for_each_matchin_ebcee6ab`:`replace_uses_the_imported_set_and_deletes_absent_ids_th_8eb5cdd1`)}),N.ok?(0,$.jsxs)(`section`,{"aria-label":u(`import_preview_7f1a08e3`),className:`space-y-2 rounded-md border p-3 text-xs`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:u(`import_preview_7f1a08e3`)}),(0,$.jsxs)(`p`,{children:[u(`expected_additions_9843ee0c`),` `,P.added.length,` `,u(`entire_entries_updated_5a95ad9f`),` `,P.updated.length,` `,u(`deleted_7dad13b3`),` `,P.removed.length]}),(0,$.jsx)(`ul`,{className:`max-h-36 space-y-1 overflow-y-auto`,children:N.value.servers.map(e=>(0,$.jsxs)(`li`,{className:`break-all`,children:[(0,$.jsx)(`code`,{children:e.id}),` · `,e.transport===`streamable_http`?`Streamable HTTP`:e.transport,` · `,e.enabled?u(`enabled_f4f0ead1`):u(`disable_4e6fd0e2`)]},e.id))}),(0,$.jsx)(`p`,{children:u(`server_ids_come_from_mcpservers_keys_internal_id_fields_9daa1d00`)}),p===`replace`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-destructive`,children:u(`existing_ids_to_delete_7831fba1`)}),P.removed.length?(0,$.jsx)(`ul`,{"aria-label":u(`servers_to_delete_c702db4b`),className:`max-h-28 overflow-y-auto`,children:P.removed.map(e=>(0,$.jsx)(`li`,{className:`break-all`,children:(0,$.jsx)(`code`,{children:e})},e))}):(0,$.jsx)(`p`,{children:u(`none_484d5561`)}),(0,$.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:te,disabled:I||_||!t,onChange:e=>g(e.target.checked?F:null)}),u(`i_confirm_replacement_with_this_configuration_and_delet_d9dd018a`)]})]}):null]}):null,t?null:(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:u(`the_current_server_list_is_unconfirmed_refresh_before_i_926117a1`)})]}),ne?(0,$.jsxs)(`section`,{role:`status`,className:`space-y-1 rounded-md border p-3 text-xs`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:u(`cannot_confirm_right_now_89a7e9d4`)}),(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[x,` `,u(`check_again_or_close_this_dialog_and_inspect_the_server_e32df514`)]})]}):x?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:x}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t p-3`,children:[ne&&T?(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:I,onClick:()=>void B(),children:u(`check_again_a925d402`)}):null,!D&&!ne&&(!t||C===`list_unavailable`)?(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:I,onClick:()=>void V(),children:u(`refresh_current_list_392bcf0e`)}):null,D&&!D.refreshed?(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:I,onClick:()=>void V(),children:u(`refresh_runtime_state_f55886a0`)}):null,(0,$.jsx)(Y,{ref:M,size:`sm`,variant:`secondary`,disabled:I,onClick:se,children:u(D?`done_c0b3fbff`:ne?`close_3fd47edc`:`cancel_2cd0f3be`)}),D?null:(0,$.jsx)(Y,{size:`sm`,disabled:!L,onClick:()=>void oe(),children:u(y===`importing`?`importing_2f58b6ed`:y===`reconciling`?`checking_0d32f419`:`import_576d81bb`)})]})]})})}var Tr=1e4;function Er(e){return e.type===`stdio`?`stdio · ${[e.command,...e.args].filter(Boolean).join(` `)}`:`Streamable HTTP · ${e.url}`}function Dr({server:e}){o();let t=e.runtime;switch(t?.status??On.Stopped){case On.Ready:return(0,$.jsxs)(U,{variant:`success`,children:[u(`connected_13bc0e73`),` `,u(`count_tools`,{count:t?.tool_count??0})]});case On.Connecting:return(0,$.jsx)(U,{variant:`warning`,children:u(`connecting_a898478b`)});case On.Degraded:return(0,$.jsxs)(U,{variant:`warning`,children:[u(`degraded_ab342d36`),` `,u(`count_tools`,{count:t?.tool_count??0})]});case On.Error:return(0,$.jsx)(U,{variant:`destructive`,children:u(`error_0bc1fb72`)});case On.Stopped:default:return(0,$.jsx)(U,{variant:`outline`,children:u(`stopped_f006455e`)})}}function Or(){o();let[e,t]=(0,Q.useState)({servers:[],confirmed:!1,revision:0}),{servers:n,confirmed:r,revision:i}=e,[a,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)({}),[x,S]=(0,Q.useState)({}),[C,w]=(0,Q.useState)({}),[T,E]=(0,Q.useState)(!1),D=(0,Q.useRef)(null),O=(0,Q.useRef)(!1),k=(0,Q.useRef)(0),A=(0,Q.useRef)(null),j=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(j.current=!0,()=>{j.current=!1,k.current+=1}),[]);let M=(0,Q.useCallback)(async(e=!1)=>{let n=++k.current;A.current=n;try{let e=await yr.getServers();return!j.current||n!==k.current?null:(t(t=>({servers:e,confirmed:!0,revision:t.revision+ +(!t.confirmed||$n(t.servers.map(e=>e.id))!==$n(e.map(e=>e.id)))})),l(null),e)}catch{return!j.current||n!==k.current?null:(t(e=>({...e,confirmed:!1,revision:e.revision+1})),e||l(u(`the_mcp_server_list_could_not_be_confirmed_refresh_and__b682cec6`)),null)}finally{A.current===n&&(A.current=null),j.current&&n===k.current&&s(!1)}},[]);(0,Q.useEffect)(()=>{M();let e=window.setInterval(()=>{!O.current&&A.current===null&&M(!0)},Tr);return()=>window.clearInterval(e)},[M]);let N=e=>{j.current&&w(t=>{let n={...t};for(let t of e)n[t]=(n[t]??0)+1;return n})},P=async(e,t)=>{if(O.current)throw new cr(`busy`);O.current=!0,k.current+=1;try{if(e.mode===`replace`){let e=await M(!0);if(!e)throw new cr(`list_unavailable`);if($n(e.map(e=>e.id))!==$n(t))throw new cr(`list_changed`)}if(!j.current)throw new cr(`list_unavailable`);let n=await yr.importServers(e),r=await M(!0);return N(n.server_ids),{result:n,refreshed:r!==null}}catch(e){throw e instanceof cr?e:new cr(`uncertain`)}finally{O.current=!1}},ee=async(e,t)=>{let n=await M(!0);if(!n)throw new cr(`uncertain`);if(!sr(e,n))throw new cr(`not_applied`);let r=Object.keys(e.mcpServers).sort(),i=er(r,t,e.mode);return N(r),{result:{mode:e.mode,added:i.added.length,updated:i.updated.length,removed:i.removed.length,server_ids:r},refreshed:!0,reconciled:!0}},F=(e,t)=>b(n=>({...n,[e]:t})),I=async(e,t)=>{F(e.id,!0);try{await(t?yr.connectServer(e.id):yr.disconnectServer(e.id)),l(null)}catch{l(u(`could_not_change_the_server_s_enabled_state_check_the_a_e8ee44ca`))}finally{F(e.id,!1),M(!0)}},L=async e=>{F(e.id,!0);try{await yr.refreshTools(e.id),w(t=>({...t,[e.id]:(t[e.id]??0)+1})),l(null)}catch{l(u(`could_not_refresh_server_tools_check_the_server_state_e_9f6d5c48`))}finally{F(e.id,!1),M(!0)}},re=async e=>{d?.mode===`edit`?await yr.updateServer(e.id,e):await yr.addServer(e),f(null),w(t=>({...t,[e.id]:(t[e.id]??0)+1})),await M(!0)},R=async()=>{if(p){g(!0),v(null);try{await yr.deleteServer(p.id),m(null),await M(!0)}catch{v(u(`the_delete_result_could_not_be_confirmed_refresh_the_ac_3af86680`))}finally{g(!1)}}};return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`connect_mcp_tool_servers_using_stdio_sse_or_streamable__1a4a9aec`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,"aria-label":u(`refresh_mcp_list_7e60055b`),onClick:()=>{O.current||M()},children:(0,$.jsx)(pe,{className:`size-4`})}),(0,$.jsxs)(Y,{ref:D,size:`sm`,variant:`secondary`,disabled:!r||a,onClick:()=>E(!0),children:[(0,$.jsx)(Et,{className:`size-4`}),u(`import_json_8f6e8682`)]}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:()=>f({mode:`create`,initial:null}),children:[(0,$.jsx)(fe,{className:`size-4`}),u(`add_0006d696`)]})]})]}),c?(0,$.jsx)(`div`,{className:`rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-xs break-all text-destructive`,role:`alert`,children:c}):null,a?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):n.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(r?`no_mcp_servers_yet_48ef8b92`:`server_list_unconfirmed_please_refresh_07249978`)}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:n.map(e=>{let t=!!y[e.id],n=!!x[e.id],r=e.runtime?.last_error&&(e.runtime?.status===On.Error||e.runtime?.status===On.Degraded);return(0,$.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>S(t=>({...t,[e.id]:!t[e.id]})),"aria-label":u(n?`collapse_tool_list_6bba8d4b`:`expand_tool_list_cc4cd445`),"aria-expanded":n,className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(B,{className:X(`size-4 transition-transform`,n&&`rotate-90`)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name||e.id}),(0,$.jsx)(Dr,{server:e})]}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:Er(e.config.transport),children:Er(e.config.transport)})]}),(0,$.jsx)(Jt,{checked:e.enabled,disabled:t,onCheckedChange:t=>void I(e,t),"aria-label":e.enabled?u(`disable_4e6fd0e2`):u(`enable_action`)}),(0,$.jsx)(`button`,{onClick:()=>void L(e),disabled:t||!e.enabled,"aria-label":u(`refresh_tools_6fd87b32`),title:e.enabled?u(`reload_tools_551274c1`):u(`enable_the_server_first_d7458d83`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground disabled:opacity-40`,children:(0,$.jsx)(pe,{className:X(`size-3.5`,t&&`animate-spin`)})}),(0,$.jsx)(`button`,{onClick:()=>f({mode:`edit`,initial:{...e.config,name:e.config.name??e.name,enabled:e.enabled}}),"aria-label":u(`edit_05183656`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(te,{className:`size-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>{v(null),m(e)},"aria-label":u(`delete_2f9daa82`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]}),r?(0,$.jsx)(`p`,{className:`mt-1.5 text-xs text-destructive`,children:u(`the_server_is_unhealthy_error_details_are_hidden_to_pro_efc23f19`)}):null,n?(0,$.jsx)(`div`,{className:`mt-2 border-t pt-2`,children:(0,$.jsx)(Cr,{serverId:e.id,version:C[e.id]??0})}):null]},e.id)})}),T?(0,$.jsx)(wr,{existingIds:n.map(e=>e.id),listConfirmed:r,listRevision:i,onClose:()=>E(!1),onReturnFocus:()=>D.current?.focus(),onImport:P,onReconcile:ee,onReload:async()=>await M()!==null}):null,(0,$.jsx)(Sr,{open:d!==null,mode:d?.mode??`create`,initial:d?.initial,existingIds:n.map(e=>e.id),onCancel:()=>f(null),onSubmit:re}),(0,$.jsx)(Ge,{open:p!==null,onOpenChange:e=>{e||m(null)},children:(0,$.jsxs)(Ue,{showCloseButton:!1,className:`p-5`,children:[(0,$.jsx)(He,{children:u(`delete_mcp_server_16db2934`)}),(0,$.jsxs)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:[u(`delete_72f49a52`),p?.name||p?.id,u(`connected_sessions_will_lose_access_to_its_tools_this_c_cab6e03c`)]}),_?(0,$.jsx)(`p`,{className:`mt-2 text-xs break-all text-destructive`,role:`alert`,children:_}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>m(null),disabled:h,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>void R(),disabled:h,children:u(h?`deleting_5e8e7af5`:`delete_2f9daa82`)})]})]})})]})}var kr=e=>e===`installing`?`installing`:`installed`,Ar=e=>{if(!Array.isArray(e))return;let t=e.filter(e=>typeof e==`string`);return t.length>0?t:void 0},jr=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={},r=Ar(t.mcp_server_ids),i=Ar(t.preset_ids),a=Ar(t.skill_dirs),o=Ar(t.workflow_filenames);return r&&(n.mcp_server_ids=r),i&&(n.preset_ids=i),a&&(n.skill_dirs=a),o&&(n.workflow_filenames=o),n},Mr=e=>{if(e&&typeof e==`object`){let t=e;if(t.type===`local_dir`&&typeof t.path==`string`)return{type:`local_dir`,path:t.path};if(t.type===`local_archive`&&typeof t.path==`string`)return{type:`local_archive`,path:t.path};if(t.type===`url`&&typeof t.url==`string`)return{type:`url`,url:t.url,sha256:typeof t.sha256==`string`?t.sha256:void 0}}return{type:`local_dir`,path:``}},Nr=e=>({id:typeof e.id==`string`?e.id:``,name:typeof e.name==`string`?e.name:void 0,version:typeof e.version==`string`?e.version:``,source:Mr(e.source),status:kr(e.status),registered:jr(e.registered)}),Pr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fr=e=>e===null||typeof e==`string`,Ir=e=>typeof e==`string`&&e.trim().length>0,Lr=(e,t)=>Ir(e)&&!e.includes(`\0`)&&!e.includes(`\r`)&&!e.includes(`
9
+ `)&&(t===`windows`?/^(?:[A-Za-z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+)/.test(e):e.startsWith(`/`)),Rr=e=>{let t=()=>{throw Error(`Jiandu setup could not be verified.`)};if(!Pr(e)||e.plugin_id!==`jiandu`)return t();let{host:n,release:r,trust:i,install:a,installed:o,external_client:s}=e;if(!Pr(n)||!Ir(n.os)||!Ir(n.arch)||!Fr(n.libc)||typeof n.supported!=`boolean`||!Fr(n.reason)||!Pr(i)||typeof i.trusted!=`boolean`||!Fr(i.reason)||!Pr(a)||typeof a.available!=`boolean`||!Fr(a.reason)||!Pr(o)||typeof o.state!=`string`||![`missing`,`installing`,`ready`,`unverified`].includes(o.state)||!Fr(o.version)||!Fr(o.reason)||r!==null&&(!Pr(r)||!Ir(r.version)||!Ir(r.manifest_url)||typeof r.sha256!=`string`||!/^[a-f\d]{64}$/i.test(r.sha256))||s!==null&&(!Pr(s)||!Lr(s.command,n.os)||!Array.isArray(s.args)||s.args.length!==2||s.args[0]!==`--data-dir`||!Lr(s.args[1],n.os)))return t();let c=e.trust_action;if(c!=null&&(!Pr(c)||typeof c.available!=`boolean`||!Fr(c.reason)||!Number.isSafeInteger(c.expected_revision)||c.expected_revision<1||!Pr(c.publisher)||!Ir(c.publisher.label)||c.publisher.algorithm!==`ed25519`||typeof c.publisher.public_key!=`string`||!/^[a-f\d]{64}$/i.test(c.publisher.public_key)||c.available&&(c.reason!==null||!n.supported||r===null||i.trusted||i.reason!==`publisher_not_trusted`||o.state===`installing`)))return t();let l=n.supported&&i.trusted&&r!==null;return a.available&&(!l||o.state!==`missing`)||o.state===`ready`!=(s!==null)||o.state===`ready`&&(!l||o.version!==r.version)?t():{...e,external_client:s===null?null:{command:s.command,args:s.args}}},zr=e=>{let t=()=>{throw Error(`Nova app setup could not be verified.`)};if(!Pr(e)||e.plugin_id!==`nova`)return t();let{host:n,connector:r,capability:i,app:a,install:o,artifact:s,desktop_server_id:c}=e;if(!Pr(n)||!Ir(n.os)||!Ir(n.arch)||typeof n.supported!=`boolean`||!Fr(n.reason)||!Pr(r)||typeof r.state!=`string`||![`missing`,`installing`,`unverified`,`verified`].includes(r.state)||!Fr(r.version)||!Fr(r.reason)||!Pr(i)||typeof i.supported!=`boolean`||!Fr(i.reason)||!Pr(o)||typeof o.available!=`boolean`||!Fr(o.reason)||!Ir(e.manual_guidance)||e.desktop_readiness!==`not_tested`||c!==null&&(typeof c!=`string`||!/^[a-zA-Z0-9_-]+$/.test(c)||r.state!==`verified`)||s!==null&&(!Pr(s)||!Ir(s.artifact_id)||!Ir(s.version)||!Ir(s.url)||typeof s.sha256!=`string`||!/^[a-f\d]{64}$/i.test(s.sha256)||s.signing!==`ad_hoc`||s.install_mode!==`local_ad_hoc`||s.development!==!0)||a!==null&&(!Pr(a)||typeof a.success!=`boolean`||typeof a.state!=`string`||![`missing`,`installed`,`already_installed`,`unsupported`,`error`].includes(a.state)||!Ir(a.message)||!Ir(a.next_action)||a.path!==void 0&&!Lr(a.path,n.os)||a.version!==void 0&&!Ir(a.version)||a.signing!==void 0&&(typeof a.signing!=`string`||![`ad_hoc`,`developer_id`,`other`].includes(a.signing))||a.development!==void 0&&typeof a.development!=`boolean`||a.connector_compatible!==void 0&&typeof a.connector_compatible!=`boolean`||a.success!==(a.state===`missing`||a.state===`installed`)||a.state===`installed`&&(a.path===void 0||a.version===void 0||a.signing===void 0||a.development===void 0||a.connector_compatible===void 0)||!n.supported||r.state!==`verified`)||i.supported!==(a!==null)||o.available&&(n.os!==`macos`||![`aarch64`,`x86_64`].includes(n.arch)||!n.supported||r.state!==`verified`||!i.supported||!Pr(a)||a.state!==`missing`||!a.success||!Pr(s)||r.version!==s.version||o.reason!==null))return t();if(e.start!==void 0||e.observation!==void 0){let{start:o,observation:s}=e;if(!Pr(o)||typeof o.available!=`boolean`||!Fr(o.reason)||!Pr(s)||s.schema_version!==1||!Ir(s.observed_at)||!Number.isFinite(Date.parse(s.observed_at))||s.app_runtime!==`not_verified`||s.permissions!==`not_verified`||!Pr(s.mcp))return t();let l=s.mcp;if(!Fr(l.server_id)||l.server_id!==null&&l.server_id!==c||typeof l.state!=`string`||![`not_observed`,`connecting`,`ready`,`degraded`,`stopped`,`error`].includes(l.state)||typeof l.tool_count!=`number`||!Number.isSafeInteger(l.tool_count)||l.tool_count<0||l.configuration_applied!==`not_verified`||l.server_id===null&&l.state!==`not_observed`||o.available&&(!n.supported||!i.supported||r.state!==`verified`||!Pr(a)||a.state!==`installed`||!a.success||a.connector_compatible!==!0||a.version!==r.version||o.reason!==null))return t()}return e},Br=e=>{if(!Ne(e)||typeof e.body!=`string`)return null;try{let t=JSON.parse(e.body).error?.reason;return typeof t==`string`&&/^[a-z0-9_]{1,64}$/.test(t)?t:null}catch{return null}},Vr=new class{async trustOfficialJiandu(e){let t=Rr(e).trust_action;if(!t?.available)throw Error(`Jiandu publisher trust could not be verified.`);await J.post(`plugins/official/jiandu/trust`,{expected_revision:t.expected_revision,expected_public_key:t.publisher.public_key})}async getNovaAppSetup(){return zr(await J.get(`plugins/nova/app`))}async startNovaApp(e){if(!e.start?.available||!e.observation||!e.app?.version)throw Error(`Nova app start could not be verified.`);let t=await J.post(`plugins/nova/app/start`,{observed_at:e.observation.observed_at,app_version:e.app.version});if(!Pr(t)||t.action!==`start_requested`)throw Error(`Nova app start could not be confirmed.`);zr(t.setup)}async installNovaApp(e){await J.post(`plugins/nova/app/install`,{artifact_id:e})}async getJianduSetup(){return Rr(await J.get(`plugins/jiandu/setup`))}async installOfficialJiandu(){await J.post(`plugins/official/jiandu/install`,{})}async listPlugins(){let e=await J.get(`plugins`),t=new Set;if(!Array.isArray(e?.plugins)||!e.plugins.every(e=>!e||typeof e.id!=`string`||!e.id.trim()||t.has(e.id)||e.status!==`installed`&&e.status!==`installing`?!1:(t.add(e.id),!0)))throw Error(`Plugin inventory could not be verified.`);return e.plugins.map(Nr)}async installPlugin(e){return Nr(await J.post(`plugins/install`,{source:e})??{})}async updatePlugin(e,t){return Nr(await J.post(`plugins/${encodeURIComponent(e)}/update`,{source:t})??{})}async removePlugin(e){await J.delete(`plugins/${encodeURIComponent(e)}`)}},Hr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ur=e=>Number.isSafeInteger(e)&&e>=0;function Wr(e){let t=()=>{throw Error(`Publisher policy could not be verified.`)};if(!Hr(e)||!Ur(e.expected_revision)||![`follow_defaults`,`explicit`].includes(e.publisher_mode)||![`strict`,`off`].includes(e.enforcement)||!Ur(e.custom_key_count)||!Array.isArray(e.publishers)||!e.publishers.length)return t();let n=new Set,r=e.publishers.map(e=>!Hr(e)||typeof e.id!=`string`||!/^[a-z0-9_-]{1,64}$/.test(e.id)||n.has(e.id)||typeof e.trusted!=`boolean`||typeof e.revoked!=`boolean`||e.trusted&&e.revoked||!Hr(e.key)||typeof e.key.label!=`string`||!e.key.label.trim()||e.key.algorithm!==`ed25519`||typeof e.key.public_key!=`string`||!/^[a-f\d]{64}$/i.test(e.key.public_key)?t():(n.add(e.id),{id:e.id,trusted:e.trusted,revoked:e.revoked,key:{label:e.key.label,algorithm:`ed25519`,public_key:e.key.public_key}}));return{expected_revision:e.expected_revision,publisher_mode:e.publisher_mode,enforcement:e.enforcement,custom_key_count:e.custom_key_count,publishers:r}}var Gr=e=>Object.fromEntries(e.publishers.map(({id:e,key:t})=>[e,`${t.algorithm}:${t.public_key.toLowerCase()}`]));function Kr(e,t,n){let r=Gr(e),i=Gr(n);if(n.expected_revision<=e.expected_revision||Object.keys(r).length!==Object.keys(i).length||Object.entries(r).some(([e,t])=>i[e]!==t))return!1;if(t.type===`set_mode`)return n.publisher_mode===t.publisher_mode;let a=n.publishers.find(({id:e})=>e===t.publisher_id);return!!(a&&(t.type===`revoke`?a.revoked&&!a.trusted:a.trusted&&!a.revoked))}var qr={async get(){return Wr(await J.get(`plugins/publishers`))},async change(e,t){let n=Wr(e);if(![`set_mode`,`revoke`,`trust`].includes(t.type)||t.type===`set_mode`&&![`follow_defaults`,`explicit`].includes(t.publisher_mode))throw Error(`Invalid publisher policy change.`);if(t.type!==`set_mode`&&!n.publishers.some(({id:e})=>e===t.publisher_id))throw Error(`Publisher is not in the reviewed catalog.`);let r=t.type===`set_mode`?{type:t.type,publisher_mode:t.publisher_mode}:{type:t.type,publisher_id:t.publisher_id};await J.post(`plugins/publishers`,{expected_revision:n.expected_revision,expected_publishers:Gr(n),change:r})}},Jr=[{value:`url`,label:`URL`},{value:`local_dir`,get label(){return u(`local_directory_aeb65d05`)}},{value:`local_archive`,get label(){return u(`local_archive_b6a1a973`)}}];function Yr({label:e,children:t}){return o(),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:e}),t]})}function Xr({open:e,mode:t,pluginId:n,pluginName:r,initialSource:i,onCancel:a,onSubmit:s}){o();let[c,l]=(0,Q.useState)(`url`),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!e)return;let t=i??null;l(t?.type??`url`),f(t?.type===`url`?t.url:``),m(t?.type===`url`?t.sha256??``:``),g(t&&(t.type===`local_dir`||t.type===`local_archive`)?t.path:``),v(null),b(!1)},[e,i]);let x=()=>{if(c===`url`){if(!d.trim())return u(`url_is_required_b0a85a80`);try{new URL(d.trim())}catch{return u(`invalid_url_format_aed7aaa6`)}}else if(!h.trim())return u(`path_is_required_72b2ecec`);return null},S=()=>c===`url`?{type:`url`,url:d.trim(),sha256:p.trim()?p.trim():void 0}:c===`local_archive`?{type:`local_archive`,path:h.trim()}:{type:`local_dir`,path:h.trim()},C=async()=>{let e=x();if(e){v(e);return}b(!0),v(null);try{await s(S())}catch(e){v(q(e))}finally{b(!1)}};return(0,$.jsx)(Ge,{open:e,onOpenChange:e=>{e||a()},children:(0,$.jsxs)(Ue,{className:`sm:max-w-lg`,children:[(0,$.jsx)(`div`,{className:`border-b px-4 py-3.5`,children:(0,$.jsx)(He,{children:t===`update`?u(`update_plugin_ccd7d265`,{v0:r||n}):u(`install_plugin_edc3f028`)})}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`mb-1 text-xs text-muted-foreground`,children:u(`source_type_38e1e77b`)}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:Jr.map(e=>(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:c===e.value?`default`:`secondary`,className:`flex-1`,onClick:()=>l(e.value),children:e.label},e.value))})]}),c===`url`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yr,{label:`URL`,children:(0,$.jsx)(Z,{placeholder:`https://example.com/plugin.zip`,value:d,autoComplete:`off`,onChange:e=>f(e.target.value)})}),(0,$.jsx)(Yr,{label:u(`sha256_checksum_optional_a604f8f4`),children:(0,$.jsx)(Z,{placeholder:u(`verify_downloaded_content_integrity_ac604aa0`),value:p,autoComplete:`off`,className:`font-mono text-xs`,onChange:e=>m(e.target.value)})})]}):(0,$.jsx)(Yr,{label:u(c===`local_dir`?`local_directory_path_80cfccba`:`local_archive_path_8a4bb71d`),children:(0,$.jsx)(Z,{placeholder:c===`local_dir`?`/Users/me/my-plugin`:`/Users/me/my-plugin.zip`,value:h,autoComplete:`off`,onChange:e=>g(e.target.value)})}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-700 dark:text-amber-400`,children:[(0,$.jsx)(ct,{className:`mt-0.5 size-3.5 shrink-0`}),(0,$.jsxs)(`span`,{children:[u(t===`update`?`update_3055a035`:`install_e8f88f51`),u(`plugins_may_register_mcp_servers_or_run_bundled_executa_0c705da8`)]})]})]}),(0,$.jsxs)(`div`,{className:`border-t p-3`,children:[_?(0,$.jsx)(`p`,{className:`mb-2 text-xs break-all text-destructive`,role:`alert`,children:_}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:a,disabled:y,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>void C(),disabled:y,children:u(y?t===`update`?`updating_a0bacec4`:`installing_19658d9f`:t===`update`?`update_3055a035`:`install_e8f88f51`)})]})]})]})})}var Zr={id:`nova`,version:`0.3.1`,releaseUrl:`https://github.com/bigduu/Nova/releases/tag/v0.3.1`,setupUrl:`https://github.com/bigduu/Nova/blob/v0.3.1/README.md`,source:{type:`url`,url:`https://github.com/bigduu/Nova/releases/download/v0.3.1/nova-plugin-v0.3.1.tar.gz`,sha256:`9eadc3ee0355f1aff047329f41e027405c68a519686efb9bc22ac91cf055b95a`}};function Qr({nova:e,installing:t,disabled:n,onInstallNova:r,onManageNova:i,novaSetup:a,jianduSetup:s}){return o(),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`article`,{"aria-label":`Nova`,className:`flex min-w-0 flex-col rounded-xl border bg-card p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(p,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Nova`}),(0,$.jsx)(U,{variant:`outline`,children:u(`plugin_official`)})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:u(`plugin_nova_subtitle`)})]})]}),(0,$.jsx)(`p`,{className:`my-4 text-sm leading-relaxed text-muted-foreground`,children:u(`plugin_nova_description`)}),(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:[(0,$.jsx)(U,{variant:`secondary`,children:`macOS`}),(0,$.jsx)(U,{variant:`secondary`,children:`Windows`}),(0,$.jsxs)(U,{variant:`outline`,children:[`v`,Zr.version]})]}),a,(0,$.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center justify-between gap-3 pt-3`,children:[(0,$.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,href:Zr.releaseUrl,target:`_blank`,rel:`noreferrer`,children:[u(`plugin_release_details`),(0,$.jsx)(de,{className:`size-3`})]}),(0,$.jsxs)(Y,{size:`sm`,onClick:e?i:r,disabled:n||e?.status===`installing`,children:[e?(0,$.jsx)(vt,{className:`size-4`}):(0,$.jsx)(h,{className:`size-4`}),t||e?.status===`installing`?u(`installing_19658d9f`):u(e?`plugin_manage_installed`:`plugin_install_nova`)]})]})]}),(0,$.jsxs)(`article`,{"aria-label":`Jiandu`,className:`flex min-w-0 flex-col rounded-xl border bg-card p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(mt,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Jiandu`}),(0,$.jsx)(U,{variant:`outline`,children:u(`plugin_official`)})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:u(`plugin_jiandu_subtitle`)})]})]}),(0,$.jsx)(`p`,{className:`my-4 text-sm leading-relaxed text-muted-foreground`,children:u(`plugin_jiandu_description`)}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-3 text-xs leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`font-medium text-primary`,children:u(`plugin_jiandu_builtin`)}),(0,$.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:u(`plugin_jiandu_builtin_detail`)})]}),(0,$.jsx)(`div`,{className:`mt-auto pt-3`,children:s})]})]})}var $r={app_not_required:`plugin_nova_app_not_required`,unsupported_host:`plugin_nova_app_unsupported`,connector_missing:`plugin_nova_app_connector_required`,incomplete_install:`plugin_nova_app_connector_unverified`,unverified_install:`plugin_nova_app_connector_unverified`,publisher_not_trusted:`plugin_nova_app_connector_unverified`,source_not_trusted:`plugin_nova_app_connector_unverified`,legacy_cli_unavailable:`plugin_nova_app_legacy_cli`,artifact_unavailable:`plugin_nova_app_artifact_unavailable`,connector_version_mismatch:`plugin_nova_app_version_mismatch`};function ei({report:e,error:t,disabled:n,installing:r,reconnecting:i,reconnectSent:a,starting:s,startSent:c,canReconnect:l,onInstall:d,onStart:f,onReconnect:p}){o();let m=e?.app,g=m?.success&&m.state===`installed`,_=e?.install.available||g&&m.signing===`ad_hoc`&&m.development===!0,v=e?.host.reason??e?.connector.reason??e?.capability.reason??e?.install.reason,y=t===`loading`?`loading_4927a53b`:t===`legacy`?`plugin_nova_app_legacy_backend`:t?`plugin_nova_app_unknown`:g?m.connector_compatible?`plugin_nova_app_installed`:`plugin_nova_app_version_mismatch`:e?.install.available?`plugin_nova_app_missing`:$r[v??``]??`plugin_nova_app_unknown`;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:u(`plugin_nova_setup_title`)}),(0,$.jsx)(`p`,{role:`status`,children:u(y)}),c?(0,$.jsx)(`p`,{role:`status`,children:u(`plugin_nova_app_start_sent`)}):null,e?.observation?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:u(`plugin_nova_app_runtime_unverified`)}),(0,$.jsx)(`p`,{children:u(`plugin_nova_app_mcp_observation`,{state:u({ready:`plugin_connected`,connecting:`connecting_a898478b`,error:`error_0bc1fb72`,degraded:`plugin_degraded`,stopped:`stopped_f006455e`,not_observed:`plugin_connection_unknown`}[e.observation.mcp.state]??`plugin_connection_unknown`)})})]}):null,a?(0,$.jsx)(`p`,{role:`status`,children:u(`plugin_nova_app_reconnect_sent`)}):null,e?(0,$.jsxs)(`p`,{children:[u(`plugin_jiandu_host`,{os:e.host.os,arch:e.host.arch}),e.connector.version?` · v${e.connector.version}`:null]}):null,g?(0,$.jsx)(`p`,{className:`break-all`,children:u(`plugin_nova_app_location`,{path:m.path??``,version:m.version??``})}):null,e?null:(0,$.jsx)(`p`,{children:u(`plugin_nova_setup_macos`)}),!e||e.host.os===`macos`?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsx)(`p`,{children:u(`plugin_nova_app_local_sign`)}):null,(0,$.jsx)(`p`,{children:u(`plugin_nova_setup_permissions`)}),g&&!l?(0,$.jsx)(`p`,{children:u(`plugin_nova_app_reconnect_unavailable`)}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[g&&e?.start?(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,disabled:n||t!==null||!e.start.available,onClick:f,children:[(0,$.jsx)(yt,{className:`size-4`}),u(s?`plugin_nova_app_starting`:`plugin_nova_app_start`)]}):null,g?(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,disabled:n||!l,onClick:p,children:[(0,$.jsx)(xt,{className:`size-4`}),u(i?`plugin_nova_app_reconnecting`:`plugin_nova_app_reconnect`)]}):(0,$.jsxs)(Y,{size:`sm`,disabled:n||t!==null||!e?.install.available,onClick:d,children:[(0,$.jsx)(h,{className:`size-4`}),u(r?`installing_19658d9f`:`plugin_nova_app_install`)]})]})]}):null,(0,$.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline`,href:Zr.setupUrl,target:`_blank`,rel:`noreferrer`,children:[u(`plugin_setup_guide`),(0,$.jsx)(de,{className:`size-3`})]})]})}function ti({ids:e,servers:t,confirmed:n,disabled:r,onToggle:i}){return o(),e.length?(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:u(`plugin_connections`)}),n?null:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`plugin_connections_unknown`)}),e.map(e=>{let a=n?t.find(t=>t.id===e):void 0,o=a?.runtime?.status,s=a?a.enabled?o===On.Ready?u(`plugin_connected`):o===On.Connecting?u(`connecting_a898478b`):o===On.Error?u(`error_0bc1fb72`):o===On.Degraded?u(`plugin_degraded`):u(`stopped_f006455e`):u(`disabled_bc5a87a7`):u(`plugin_connection_unknown`);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-all text-muted-foreground`,children:a?.name||e}),(0,$.jsx)(U,{variant:o===On.Error?`destructive`:`outline`,children:s}),a?(0,$.jsx)(Jt,{checked:a.enabled,disabled:r,"aria-label":u(`plugin_toggle_connection`,{name:a.name||e}),onCheckedChange:e=>i(a,e)}):null]},e)}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:u(`plugin_connection_scope`)})]}):null}var ni={unsupported_host:`plugin_jiandu_unsupported`,glibc_2_35_required:`plugin_jiandu_glibc`,publisher_not_trusted:`plugin_jiandu_untrusted`,source_not_trusted:`plugin_jiandu_source_untrusted`,artifact_unavailable:`plugin_jiandu_unavailable_detail`,incomplete_install:`plugin_jiandu_incomplete`,already_installed:`plugin_jiandu_unverified`,unverified_install:`plugin_jiandu_unverified`,memory_root_unavailable:`plugin_jiandu_root_unavailable`,memory_root_overlaps_plugin:`plugin_jiandu_root_overlap`,invalid_managed_files:`plugin_jiandu_unverified`};function ri({report:e,error:t,disabled:n,installing:r,copying:i,copiedConfiguration:a,copyError:s,onInstall:c,onCopy:l,onReviewTrust:d}){o();let f=e?.installed.state===`ready`,p=f&&e.external_client?JSON.stringify({mcpServers:{jiandu:e.external_client}},null,2):null,m=e?.trust.trusted||e?.trust_action?.reason===`publisher_already_trusted`?null:e?.trust_action?.reason,g=e?.host.reason??m??e?.trust.reason??e?.installed.reason??e?.install.reason,_=g===`memory_root_unavailable`||g===`memory_root_overlaps_plugin`?ni[g]:null;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,role:`status`,children:u(t===`loading`?`loading_4927a53b`:t===`legacy`?`plugin_jiandu_legacy`:t?`plugin_jiandu_unknown`:f?`plugin_jiandu_ready`:_??(e?.installed.state===`installing`?`plugin_jiandu_incomplete`:e?.installed.state===`unverified`?`plugin_jiandu_unverified`:e?.install.available?`plugin_jiandu_optional`:ni[g??``]??`plugin_jiandu_unknown`))}),e?(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[u(`plugin_jiandu_host`,{os:e.host.os,arch:e.host.arch}),e.release?` · v${e.release.version}`:null]}):null,e?.trust.reason===`publisher_not_trusted`&&!e.trust_action?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`plugin_jiandu_trust_unsupported`)}):null,f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:u(`plugin_jiandu_same_host`)}),(0,$.jsx)(`pre`,{"aria-label":u(`plugin_jiandu_config`),className:`whitespace-pre-wrap break-all rounded-lg border bg-muted/30 p-3 text-xs`,children:p})]}):null,s?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[e?.trust_action?.available?(0,$.jsxs)(Y,{size:`sm`,variant:`outline`,disabled:n||t!==null,onClick:d,children:[(0,$.jsx)(wt,{className:`size-4`}),u(`plugin_jiandu_review_trust`)]}):null,p&&a===p?(0,$.jsx)(`span`,{role:`status`,className:`text-xs text-primary`,children:u(`plugin_jiandu_copied`)}):null,(0,$.jsxs)(Y,{size:`sm`,variant:f?`secondary`:`default`,onClick:f?l:c,disabled:n||t!==null||!f&&!e?.install.available,children:[f?(0,$.jsx)(ue,{className:`size-4`}):(0,$.jsx)(h,{className:`size-4`}),u(r?`installing_19658d9f`:i?`plugin_jiandu_copying`:f?`plugin_jiandu_copy`:`plugin_jiandu_install`)]})]})]})}function ii({disabled:e,observedRevision:t,onBegin:n,onEnd:r}){o();let[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(!0),C=(0,Q.useRef)(0),w=(0,Q.useRef)(!1),T=(0,Q.useRef)(null),E=(0,Q.useCallback)(async()=>{let e=++C.current;p(!0);try{let t=await qr.get();if(!S.current||e!==C.current)return;a(t),_(!1),c(!1),T.current&&Kr(T.current.policy,T.current.change,t)&&(T.current=null,y(null))}catch(t){if(!S.current||e!==C.current)return;a(null),c(Ne(t)&&t.status===404),_(!0)}finally{S.current&&e===C.current&&p(!1)}},[]);(0,Q.useEffect)(()=>(S.current=!0,()=>{S.current=!1,C.current+=1}),[]),(0,Q.useEffect)(()=>{E()},[E,t]);let D=async()=>{let e=b;if(!e||w.current||!n())return;w.current=!0,h(!0),x(null),C.current+=1,T.current=e;let t=u(`plugin_publishers_unconfirmed`);try{await qr.change(e.policy,e.change)}catch(e){Ne(e)&&e.status===409&&(t=u(`plugin_publishers_changed`))}finally{S.current&&y(t),await E(),await r(),w.current=!1,S.current&&h(!1)}};if(s&&!i)return null;let O=e||m||f,k=i?.publisher_mode===`follow_defaults`?u(`plugin_publishers_follow`):u(`plugin_publishers_explicit`),A=e=>{i&&!O&&x({policy:i,change:e})},j=b?.change,M=j&&j.type!==`set_mode`?b?.policy.publishers.find(({id:e})=>e===j.publisher_id):void 0;return(0,$.jsxs)(`section`,{className:`rounded-lg border p-3 text-sm`,"aria-label":u(`plugin_publishers_title`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,"aria-expanded":l,onClick:()=>{d(!l),l||E()},disabled:m,children:u(`plugin_publishers_title`)}),i&&(0,$.jsx)(U,{variant:`secondary`,children:k})]}),l&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`plugin_publishers_description`)}),i?.enforcement===`off`&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:u(`plugin_publishers_off`)}),g&&(0,$.jsx)(`p`,{role:`alert`,children:u(`plugin_publishers_read_failed`)}),v&&(0,$.jsx)(`p`,{role:`alert`,children:v}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>void E(),disabled:O,children:u(`plugin_publishers_refresh`)}),i&&(0,$.jsx)(Y,{size:`sm`,variant:`outline`,disabled:O,onClick:()=>A({type:`set_mode`,publisher_mode:i.publisher_mode===`follow_defaults`?`explicit`:`follow_defaults`}),children:i.publisher_mode===`follow_defaults`?u(`plugin_publishers_use_explicit`):u(`plugin_publishers_use_defaults`)})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`plugin_publishers_custom_count`,{count:i.custom_key_count})}),(0,$.jsx)(`ul`,{className:`space-y-3`,children:i.publishers.map(e=>(0,$.jsxs)(`li`,{className:`space-y-1 rounded-md border p-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.key.label}),(0,$.jsx)(U,{variant:e.revoked?`warning`:`secondary`,children:e.revoked?u(`plugin_publishers_revoked`):e.trusted?u(`plugin_publishers_trusted`):u(`plugin_publishers_untrusted`)})]}),(0,$.jsx)(`p`,{className:`break-all font-mono text-xs text-muted-foreground`,children:e.key.public_key}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!e.revoked&&(0,$.jsx)(Y,{size:`sm`,variant:`outline`,disabled:O,onClick:()=>A({type:`revoke`,publisher_id:e.id}),"aria-label":u(`plugin_publishers_revoke_named`,{name:e.id}),children:u(`plugin_publishers_revoke`)}),!e.trusted&&(0,$.jsx)(Y,{size:`sm`,variant:`outline`,disabled:O,onClick:()=>A({type:`trust`,publisher_id:e.id}),"aria-label":u(`plugin_publishers_trust_named`,{name:e.id}),children:u(`plugin_publishers_trust`)})]})]},e.id))})]})]}),(0,$.jsx)(Ge,{open:b!==null,onOpenChange:e=>{e||x(null)},children:(0,$.jsxs)(Ue,{className:`gap-4 p-5 sm:max-w-xl`,children:[(0,$.jsx)(He,{children:u(`plugin_publishers_review`)}),(0,$.jsx)(We,{children:b?.change.type===`set_mode`?b.change.publisher_mode===`follow_defaults`?u(`plugin_publishers_review_defaults`):u(`plugin_publishers_review_explicit`):b?.change.type===`revoke`?u(`plugin_publishers_review_revoke`):u(`plugin_publishers_review_trust`)}),(0,$.jsx)(`ul`,{className:`max-h-64 space-y-2 overflow-y-auto text-xs`,children:(M?[M]:b?.policy.publishers??[]).map(({id:e,key:t})=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`p`,{children:t.label}),(0,$.jsx)(`p`,{className:`break-all font-mono`,children:t.public_key})]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>x(null),children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,disabled:O,onClick:()=>void D(),children:u(`plugin_publishers_confirm`)})]})]})})]})}function ai({status:e}){return o(),e===`installing`?(0,$.jsx)(U,{variant:`warning`,children:u(`installing_possibly_an_incomplete_installation_ce4290b2`)}):(0,$.jsx)(U,{variant:`secondary`,children:u(`installed_a8b6c39d`)})}function oi(e){switch(e.type){case`local_dir`:return u(`local_directory_9a7b72f1`,{v0:e.path});case`local_archive`:return u(`local_archive_7e17d5f1`,{v0:e.path});case`url`:return`URL · ${e.url}`;default:return``}}function si(e){let t=[];return e.mcp_server_ids?.length&&t.push({key:`mcp`,label:u(`mcp_servers_bf3157a8`,{v0:e.mcp_server_ids.length,count:e.mcp_server_ids.length})}),e.skill_dirs?.length&&t.push({key:`skills`,label:u(`skills_c576d453`,{v0:e.skill_dirs.length,count:e.skill_dirs.length})}),e.preset_ids?.length&&t.push({key:`prompts`,label:u(`prompts_b7b44efd`,{v0:e.preset_ids.length,count:e.preset_ids.length})}),e.workflow_filenames?.length&&t.push({key:`workflows`,label:u(`workflows_a9684d0d`,{v0:e.workflow_filenames.length,count:e.workflow_filenames.length})}),t}function ci(e){return e===`archive_checksum_mismatch`?u(`plugin_nova_app_install_checksum`):e?u(`plugin_nova_app_install_reason`,{reason:e}):u(`plugin_nova_app_install_unconfirmed`)}function li(){o();let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(`discover`),[i,a]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)([]),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(`loading`),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(`loading`),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!0),[M,N]=(0,Q.useState)(null),[P,ee]=(0,Q.useState)(null),[F,te]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[re,R]=(0,Q.useState)(null),[z,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(null),B=(0,Q.useRef)(!0),V=(0,Q.useRef)(!1),se=(0,Q.useRef)(0),ce=(0,Q.useRef)(!1),le=(0,Q.useRef)(null);(0,Q.useEffect)(()=>(B.current=!0,()=>{B.current=!1,se.current+=1}),[]);let H=(0,Q.useCallback)(async(e=!1)=>{let n=++se.current;ce.current=!0,e||j(!0);let[r,i,o,s]=await Promise.allSettled([Vr.listPlugins(),yr.getServers(),Vr.getJianduSetup(),Vr.getNovaAppSetup()]);if(!B.current||n!==se.current)return;r.status===`fulfilled`?(t(r.value),a(!0),N(null)):(a(!1),N(u(`plugin_inventory_unconfirmed`))),d(i.status===`fulfilled`),i.status===`fulfilled`&&c(i.value),p(o.status===`fulfilled`?o.value:null),h(o.status===`fulfilled`?null:Ne(o.reason)&&o.reason.status===404?`legacy`:`unknown`),y(s.status===`fulfilled`?s.value:null),x(s.status===`fulfilled`?null:Ne(s.reason)&&s.reason.status===404?`legacy`:`unknown`);let l=le.current;return(l?.type===`install`&&r.status===`fulfilled`&&r.value.some(e=>e.id===l.id&&e.status===`installed`)||l?.type===`jiandu-install`&&o.status===`fulfilled`&&o.value.installed.state===`ready`||l?.type===`jiandu-trust`&&o.status===`fulfilled`&&o.value.trust.trusted&&o.value.trust_action?.publisher.public_key.toLowerCase()===l.publicKey.toLowerCase()||l?.type===`nova-app-install`&&s.status===`fulfilled`&&s.value.artifact?.artifact_id===l.artifactId&&s.value.app?.success&&s.value.app.state===`installed`&&s.value.app.version===l.version&&s.value.app.connector_compatible===!0&&s.value.app.signing===`ad_hoc`&&s.value.app.development===!0||l?.type===`toggle`&&i.status===`fulfilled`&&i.value.some(e=>e.id===l.id&&e.enabled===l.enabled))&&(le.current=null,ee(null)),ce.current=!1,j(!1),r.status===`fulfilled`?r.value:null},[]);(0,Q.useEffect)(()=>{H();let e=window.setInterval(()=>{!V.current&&!ce.current&&H(!0)},1e4);return()=>window.clearInterval(e)},[H]),(0,Q.useEffect)(()=>{i&&re&&!e.some(e=>e.id===re.id)&&(R(null),oe(null))},[i,re,e]);let W=(e,t=!0)=>V.current||t&&!i?!1:(V.current=!0,se.current+=1,le.current=null,te(e),ee(null),C(!1),T(!1),k(null),D(null),!0),ue=async()=>{let e=await H(!0);return V.current=!1,B.current&&te(null),e},de=async()=>{if(W(`nova-install`)){le.current={type:`install`,id:Zr.id};try{await Vr.installPlugin(Zr.source)}catch{B.current&&ee(u(`plugin_install_failed`))}finally{let e=await ue();B.current&&e&&ee(e.some(e=>e.id===Zr.id&&e.status===`installed`)?null:u(`plugin_install_failed`))}}},me=async()=>{let e=g;if(!e?.trust_action?.available||!W(`jiandu-trust`,!1))return;_(null),le.current={type:`jiandu-trust`,publicKey:e.trust_action.publisher.public_key};let t=u(`plugin_jiandu_trust_unconfirmed`);try{await Vr.trustOfficialJiandu(e)}catch(e){Ne(e)&&e.status===409?t=u(`plugin_jiandu_trust_changed`):Ne(e)&&e.status===404&&(t=u(`plugin_jiandu_trust_unsupported`))}finally{B.current&&ee(t),await ue()}},he=async()=>{if(!(!f?.install.available||!W(`jiandu-install`,!1))){le.current={type:`jiandu-install`};try{await Vr.installOfficialJiandu()}catch{}finally{B.current&&ee(u(`plugin_jiandu_install_unconfirmed`)),await ue()}}},ge=async()=>{if(!v?.install.available||!v.artifact||!W(`nova-app-install`,!1))return;let{artifact_id:e,version:t}=v.artifact;le.current={type:`nova-app-install`,artifactId:e,version:t};let n=null;try{await Vr.installNovaApp(e)}catch(e){n=Br(e)}finally{B.current&&ee(ci(n)),await ue()}},ve=async()=>{let e=v?.app?.version;if(!(!v?.start?.available||!e||!W(`nova-app-start`,!1)))try{let t=await Vr.getNovaAppSetup();if(!B.current)return;if(y(t),x(null),!t.start?.available||!t.observation||t.app?.version!==e){ee(u(`plugin_nova_app_start_unconfirmed`));return}await Vr.startNovaApp(t),B.current&&T(!0)}catch{B.current&&ee(u(`plugin_nova_app_start_unconfirmed`))}finally{await ue()}},ye=async()=>{let e=v?.desktop_server_id;if(!(!e||!W(`nova-reconnect`,!1)))try{let[t,n]=await Promise.all([Vr.getNovaAppSetup(),yr.getServers()]);if(!B.current)return;if(y(t),x(null),c(n),d(!0),t.desktop_server_id!==e||!t.app?.success||t.app.state!==`installed`||t.app.connector_compatible!==!0||!n.some(t=>t.id===e&&t.enabled)){ee(u(`plugin_nova_app_reconnect_unconfirmed`));return}await yr.connectServer(e),B.current&&C(!0)}catch{B.current&&ee(u(`plugin_nova_app_reconnect_unconfirmed`))}finally{await ue()}},be=async()=>{if(!(f?.installed.state!==`ready`||!W(`jiandu-copy`,!1)))try{let e=await Vr.getJianduSetup();if(!B.current)return;if(p(e),h(null),e.installed.state!==`ready`||!e.external_client){k(u(`plugin_jiandu_copy_unconfirmed`));return}let t=JSON.stringify({mcpServers:{jiandu:e.external_client}},null,2);await _e(t),B.current&&D(t)}catch{B.current&&k(u(`plugin_jiandu_copy_failed`))}finally{await ue()}},xe=async(e,t)=>{if(!(!l||!W(`mcp:${e.id}`))){le.current={type:`toggle`,id:e.id,enabled:t};try{await(t?yr.connectServer(e.id):yr.disconnectServer(e.id))}catch{B.current&&ee(u(`plugin_toggle_failed`))}finally{await ue()}}},Se=async e=>{if(!W(`manual`))throw Error(u(`plugin_inventory_unconfirmed`));try{I?.mode===`update`&&I.pluginId?await Vr.updatePlugin(I.pluginId,e):await Vr.installPlugin(e),B.current&&(L(null),r(`installed`))}catch(e){throw I?.mode===`install`&&Ne(e)&&e.status===409?Error(u(`already_installed_use_update_a919ad86`,{v0:q(e)})):e}finally{await ue()}},Ce=async()=>{if(!re||!W(`delete`))return;let e=re.id;ie(!0),oe(null);try{await Vr.removePlugin(e)}catch(e){B.current&&oe(q(e))}finally{await ue(),B.current&&ie(!1)}},we=(0,$.jsx)(ri,{report:f,error:m,disabled:F!==null||A,installing:F===`jiandu-install`,copying:F===`jiandu-copy`,copiedConfiguration:E,copyError:O,onInstall:()=>void he(),onCopy:()=>void be(),onReviewTrust:()=>{!V.current&&f?.trust_action?.available&&_(f)}}),Te=(0,$.jsx)(ei,{report:v,error:b,disabled:F!==null||A,installing:F===`nova-app-install`,reconnecting:F===`nova-reconnect`,reconnectSent:S,starting:F===`nova-app-start`,startSent:w,canReconnect:!!(v?.app?.success&&v.app.state===`installed`&&v.app.connector_compatible&&v.desktop_server_id&&l&&s.some(e=>e.id===v.desktop_server_id&&e.enabled)),onInstall:()=>void ge(),onStart:()=>void ve(),onReconnect:()=>void ye()});return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(ii,{disabled:A||F!==null,observedRevision:f?.trust_action?.expected_revision,onBegin:()=>W(`publisher-policy`,!1),onEnd:ue}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:u(`plugin_center_description`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>void H(),disabled:A||F!==null,"aria-label":u(`plugin_refresh`),children:[(0,$.jsx)(pe,{className:X(`size-4`,A&&`animate-spin`)}),u(`refresh_aee88743`)]}),(0,$.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>L({mode:`install`}),disabled:!i||F!==null,children:[(0,$.jsx)(fe,{className:`size-4`}),u(`plugin_manual_install`)]})]})]}),M?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-xs break-all text-destructive`,role:`alert`,children:[(0,$.jsx)(`span`,{children:M}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`h-7 shrink-0 px-2`,onClick:()=>void H(),disabled:A||F!==null,children:u(`retry_b8784c8d`)})]}):null,P?(0,$.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-xs leading-relaxed text-destructive`,children:P}):null,(0,$.jsxs)(nt,{value:n,onValueChange:r,children:[(0,$.jsxs)(tt,{"aria-label":u(`plugin_center_views`),children:[(0,$.jsx)($e,{value:`discover`,children:u(`plugin_discover`)}),(0,$.jsxs)($e,{value:`installed`,children:[u(`plugin_installed_view`),i?(0,$.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:e.length}):null]})]}),(0,$.jsxs)(et,{value:`discover`,className:`pt-2`,children:[(0,$.jsx)(Qr,{nova:e.find(e=>e.id===Zr.id),installing:F===`nova-install`,disabled:!i||F!==null,onInstallNova:()=>void de(),onManageNova:()=>r(`installed`),novaSetup:Te,jianduSetup:we}),(0,$.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-muted-foreground`,children:u(`plugin_install_location`)})]}),(0,$.jsx)(et,{value:`installed`,className:`pt-2`,children:A&&e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):i&&e.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-dashed px-5 py-8 text-center`,children:[(0,$.jsx)(ut,{className:`mx-auto mb-3 size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:u(`no_plugins_yet_c3e55896`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:u(`plugin_empty_hint`)}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>r(`discover`),children:u(`plugin_discover`)})]}):!i&&e.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[u(`total_76e547a8`),` `,e.length,` `,u(`plugins_07219a59`)]}),(0,$.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let t=si(e.registered);return(0,$.jsxs)(`li`,{className:`rounded-xl border bg-card p-4`,"aria-label":e.name||e.id,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 break-words text-sm font-medium`,children:e.name||e.id}),(0,$.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[`v`,e.version]}),(0,$.jsx)(ai,{status:e.status})]}),e.name?(0,$.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:e.id}):null,(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground`,title:oi(e.source),children:oi(e.source)}),t.length>0?(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:t.map(e=>(0,$.jsx)(U,{variant:`outline`,className:`text-[10px] font-normal text-muted-foreground`,children:e.label},e.key))}):null,(0,$.jsx)(ti,{ids:e.registered.mcp_server_ids??[],servers:s,confirmed:l,disabled:!i||F!==null||e.status===`installing`,onToggle:(e,t)=>void xe(e,t)}),e.id===Zr.id?(0,$.jsx)(`div`,{className:`mt-3`,children:Te}):null,e.id===`jiandu`?(0,$.jsx)(`div`,{className:`mt-3`,children:we}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,disabled:!i||F!==null||e.status===`installing`,onClick:()=>L({mode:`update`,pluginId:e.id,pluginName:e.name,initialSource:e.source}),children:[(0,$.jsx)(xt,{className:`size-3.5`}),u(`update_3055a035`)]}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs text-destructive hover:text-destructive`,disabled:!i||F!==null,onClick:()=>{oe(null),R(e)},children:[(0,$.jsx)(ne,{className:`size-3.5`}),u(`delete_2f9daa82`)]})]})]},e.id)})})]})})]}),(0,$.jsx)(Ge,{open:g!==null,onOpenChange:e=>{e||_(null)},children:(0,$.jsxs)(Ue,{className:`gap-4 p-5 sm:max-w-lg`,children:[(0,$.jsx)(He,{children:u(`plugin_jiandu_review_trust`)}),(0,$.jsx)(We,{children:u(`plugin_jiandu_trust_description`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u(`plugin_jiandu_host`,{os:g?.host.os??``,arch:g?.host.arch??``})}),(0,$.jsxs)(`dl`,{className:`min-w-0 space-y-2 text-xs`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:u(`plugin_jiandu_trust_publisher`)}),(0,$.jsx)(`dd`,{children:g?.trust_action?.publisher.label}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:u(`plugin_jiandu_trust_key`)}),(0,$.jsx)(`dd`,{className:`break-all font-mono`,children:g?.trust_action?.publisher.public_key}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:u(`plugin_jiandu_trust_source`)}),(0,$.jsx)(`dd`,{className:`break-all`,children:g?.release?.manifest_url})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>_(null),children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,disabled:F!==null,onClick:()=>void me(),children:u(`plugin_jiandu_confirm_trust`)})]})]})}),(0,$.jsx)(Xr,{open:I!==null,mode:I?.mode??`install`,pluginId:I?.pluginId,pluginName:I?.pluginName,initialSource:I?.initialSource,onCancel:()=>{V.current||L(null)},onSubmit:Se}),(0,$.jsx)(Ge,{open:re!==null,onOpenChange:e=>{!e&&!V.current&&R(null)},children:(0,$.jsxs)(Ue,{showCloseButton:!1,className:`p-5`,children:[(0,$.jsx)(He,{children:u(`delete_plugin_a0c9ae7e`)}),(0,$.jsxs)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:[u(`delete_72f49a52`),re?.name||re?.id,u(`its_mcp_servers_skills_prompts_and_workflows_will_also__539475bd`)]}),ae?(0,$.jsx)(`p`,{className:`mt-2 text-xs break-all text-destructive`,role:`alert`,children:ae}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>R(null),disabled:z,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>void Ce(),disabled:z||!i,children:u(z?`deleting_5e8e7af5`:`delete_2f9daa82`)})]})]})})]})}function ui(){o();let e=Ee(e=>e.config),t=Ee(e=>e.loadConfig),n=Ee(e=>e.saveConfig),r=Oe(e=>e.loadSkills),[i,a]=(0,Q.useState)([]),[s,c]=(0,Q.useState)(!0),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),v=(0,Q.useMemo)(()=>new Set((e?.skills?.disabled??[]).map(e=>e.trim()).filter(Boolean)),[e]),y=(0,Q.useCallback)(async e=>{c(!0),d(null);try{let[n]=await Promise.all([De.listSkills({includeDisabled:!0},e),t({force:e})]);a(n.skills)}catch(e){d(e instanceof Error?e.message:u(`failed_to_load_skills_25d4f16d`))}finally{c(!1)}},[t]);(0,Q.useEffect)(()=>{y(!0)},[y]);let b=async(e,i)=>{p(e.id),h(null);try{let a=await t({force:!0}),o=a?.skills?.disabled??[],s=Array.from(new Set((i?o.filter(t=>t!==e.id):[...o,e.id]).map(e=>e.trim()).filter(Boolean))).sort();await n({skills:{...a?.skills??{},disabled:s},...a&&a.model_limits!==void 0?{model_limits:a.model_limits}:{}}),r()}catch(t){h({id:e.id,message:t instanceof Error?t.message:u(`failed_to_save_skill_state_369d373b`)})}finally{p(null)}},x=g.trim().toLowerCase(),S=x?i.filter(e=>[e.id,e.name,e.description,e.license??``,e.compatibility??``,...e.tool_refs??[]].join(` `).toLowerCase().includes(x)):i;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[u(`type_in_the_composer_dcfa53f6`),` `,(0,$.jsx)(`code`,{children:`/`}),u(`to_trigger_a_skill_disabled_skills_are_excluded_from_sy_fa49c48f`)]}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,className:`shrink-0`,onClick:()=>void y(!0),disabled:s,children:[(0,$.jsx)(pe,{className:X(`size-4`,s&&`animate-spin`)}),u(`refresh_aee88743`)]})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(me,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Z,{className:`pl-8`,placeholder:u(`search_skills_name_description_tools_7b0a1647`),value:g,onChange:e=>_(e.target.value)})]}),l?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:l}):null,s&&i.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):S.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(x?`no_skills_match_the_current_search_578e81dc`:`no_skills_yet_990d5ec7`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[u(`total_76e547a8`),` `,i.length,` `,u(`skills_ac2141d1`),` `,v.size>0?u(`disabled_7f49fd2e`,{v0:v.size}):``]}),(0,$.jsx)(`ul`,{className:`space-y-2`,children:S.map(e=>{let t=v.has(e.id);return(0,$.jsxs)(`li`,{className:X(`rounded-lg border p-3`,t&&`opacity-70`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),t?(0,$.jsx)(U,{variant:`outline`,className:`text-[10px]`,children:u(`disabled_bc5a87a7`)}):null,(0,$.jsx)(Jt,{checked:!t,disabled:f===e.id,onCheckedChange:t=>void b(e,t),"aria-label":u(t?`enable_57077dfa`:`disable_df52dc37`,{v0:e.name})})]}),e.description?(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:e.description}):null,e.license||e.compatibility||(e.tool_refs?.length??0)>0?(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[e.license?(0,$.jsxs)(U,{variant:`secondary`,className:`text-[10px]`,children:[`License: `,e.license]}):null,e.compatibility?(0,$.jsxs)(U,{variant:`secondary`,className:`text-[10px]`,children:[u(`compatible_0225420a`),` `,e.compatibility]}):null,(e.tool_refs??[]).map(e=>(0,$.jsx)(U,{variant:`outline`,className:`text-[10px] font-normal text-muted-foreground`,children:e},e))]}):null,m?.id===e.id?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:m.message}):null]},e.id)})})]})]})}var di=[{value:`default`,label:`Default`,get hint(){return u(`ask_before_dangerous_operations_1949266f`)}},{value:`bypass`,label:`Bypass`,get hint(){return u(`skip_ordinary_approvals_forced_confirmation_rules_still_d1272ac8`)},danger:!0},{value:`auto`,label:`Auto`,get hint(){return u(`no_approval_dialogs_hard_deny_policies_still_apply_73c31eb7`)},danger:!0}];function fi(){o();let[e,t]=(0,Q.useState)(`default`),[n,r]=(0,Q.useState)(void 0),[i,a]=(0,Q.useState)(),[s,c]=(0,Q.useState)(!0),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),m=(0,Q.useCallback)(async()=>{let e=await be.getDefaultSessionPermissionMode();t(e.mode),r(e.revision),a(e.supervisor_approval_handoff_enabled)},[]);(0,Q.useEffect)(()=>{m().catch(()=>p(u(`could_not_load_default_permission_mode_f3b27a89`))).finally(()=>c(!1))},[m]);let h=async i=>{if(i===e||l)return;let a=e;t(i),d(!0),p(null);try{r((await be.updateDefaultSessionPermissionMode(i,n)).revision)}catch{t(a),p(u(`could_not_save_please_try_again_f42a1238`))}finally{d(!1)}},g=async()=>{if(!(l||n===void 0||i===void 0)){d(!0),p(null);try{let e=await be.updateSupervisorApprovalHandoff(!i,n);a(e.supervisor_approval_handoff_enabled),r(e.revision)}catch(e){if(p(u(`could_not_save_please_try_again_f42a1238`)),Ne(e)&&e.status===409)try{await m(),p(u(`the_request_or_permissions_have_changed_confirm_again_u_a1ebae48`))}catch{}}finally{d(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`default_permissions_for_new_sessions_5ac6c44c`)}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:di.map(t=>(0,$.jsx)(Y,{variant:e===t.value?`default`:`secondary`,disabled:s||l,onClick:()=>void h(t.value),className:X(`flex-1`,e===t.value&&t.danger&&`border-amber-500/60 text-amber-600 dark:text-amber-400`),children:t.label},t.value))}),(0,$.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[s?u(`loading_4927a53b`):l?u(`saving_ff509c9b`):di.find(t=>t.value===e)?.hint,u(`only_affects_new_sessions_existing_sessions_keep_their__770c0ec9`)]})]}),i===void 0?null:(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`supervisor_approval_handoff_setting`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`supervisor_approval_handoff_description`)}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,"aria-pressed":i,disabled:l,onClick:()=>void g(),children:u(i?`supervisor_approval_handoff_on`:`supervisor_approval_handoff_off`)})]}),f?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:f}):null]})}function pi(){o();let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(!0),[i,a]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{be.getPermissionAskRules().then(t).catch(()=>{}).finally(()=>r(!1))},[]);let s=async e=>{t(e);try{t(await be.updatePermissionAskRules(e))}catch{}},c=()=>{let t=i.trim();!t||e.includes(t)||(s([...e,t]),a(``))};return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(fi,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,$.jsx)(g,{i18nKey:`ui.approval_rule_example`,components:{code:(0,$.jsx)(`code`,{})}})}),(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`add_rule_83009fcf`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{className:`flex-1`,placeholder:u(`tool_name_pattern_a8384820`),value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()}}),(0,$.jsxs)(Y,{size:`sm`,onClick:c,disabled:!i.trim(),children:[(0,$.jsx)(fe,{className:`size-4`}),u(`add_7a8a11ea`)]})]})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:[u(`approval_rules_f747dce1`),e.length,`)`]}),n?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`none_all_tools_execute_directly_6f32e54e`)}):(0,$.jsx)(`ul`,{className:`space-y-1.5`,children:e.map(t=>(0,$.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md bg-muted/40 px-2.5 py-1.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t}),(0,$.jsx)(`button`,{onClick:()=>void s(e.filter(e=>e!==t)),"aria-label":u(`delete_2f9daa82`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]},t))})]})]})}function mi(){o();let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=(0,Q.useCallback)(e=>{t(e.entries),r(e.revision)},[]),x=(0,Q.useCallback)(async()=>{try{return b(await be.getEnvVars()),y(null),!0}catch{return r(null),y(u(`the_environment_variable_list_could_not_be_confirmed_re_4b274f7c`)),!1}},[b]);(0,Q.useEffect)(()=>{x().finally(()=>a(!1))},[x]);let S=async()=>{if(!(!s.trim()||n===null||m)){h(!0),y(null);try{b(await be.upsertEnvVar({name:s.trim(),value:l,secret:f},n)),c(``),d(``),p(!1)}catch{y(await x()?u(`the_add_result_is_unconfirmed_the_actual_list_was_refre_0e0eb67c`):u(`adding_failed_and_the_actual_list_could_not_be_refreshe_55bc8eea`))}finally{h(!1)}}},C=async e=>{if(!(n===null||g!==null)){_(e),y(null);try{b(await be.deleteEnvVar(e,n))}catch{y(await x()?u(`the_delete_result_is_unconfirmed_the_actual_list_was_re_3ab20d2d`):u(`deleting_failed_and_the_actual_list_could_not_be_refres_92130a73`))}finally{_(null)}}};return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`environment_variables_passed_to_the_backend_and_tools_v_0163420e`)}),(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`add_variable_de177c5f`)}),(0,$.jsx)(Z,{placeholder:u(`name_e_g_openai_api_key_b963e5a6`),value:s,onChange:e=>c(e.target.value)}),(0,$.jsx)(Z,{placeholder:u(`value_cda1d55c`),type:f?`password`:`text`,value:l,onChange:e=>d(e.target.value)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(st,{className:`text-muted-foreground font-normal`,children:[(0,$.jsx)(Jt,{checked:f,onCheckedChange:p}),u(`secret_masked_bf94b704`)]}),(0,$.jsxs)(Y,{size:`sm`,onClick:S,disabled:!s.trim()||n===null||m,children:[(0,$.jsx)(fe,{className:`size-4`}),` `,u(m?`adding_f470193b`:`add_7a8a11ea`)]})]})]}),v?(0,$.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:v}):null,(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:[u(`configured_e7284971`),e.length,`)`]}),i?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`none_yet_b336a174`)}):(0,$.jsx)(`ul`,{className:`space-y-1.5`,children:e.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md bg-muted/40 px-2.5 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.name}),e.secret?(0,$.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:u(`secret_f67bca8f`)}):null]}),(0,$.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.has_value?e.secret?u(`set_value_hidden_4e58023d`):e.value:(0,$.jsx)(`span`,{className:`italic`,children:u(`not_set_2f5f1d6f`)})})]}),(0,$.jsx)(`button`,{onClick:()=>void C(e.name),disabled:g!==null||n===null,"aria-label":u(`delete_4124e386`,{v0:e.name}),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]},e.name))})]})]})}var hi=[{value:`mon`,get label(){return u(`mon_51a75f46`)}},{value:`tue`,get label(){return u(`tue_084b42f6`)}},{value:`wed`,get label(){return u(`wed_a4c3313d`)}},{value:`thu`,get label(){return u(`thu_754a9d58`)}},{value:`fri`,get label(){return u(`fri_c9b87f51`)}},{value:`sat`,get label(){return u(`sat_de07b538`)}},{value:`sun`,get label(){return u(`sun_85217f7a`)}}],gi=[{value:`interval`,get label(){return u(`interval_4f5df723`)}},{value:`daily`,get label(){return u(`daily_eea1694c`)}},{value:`weekly`,get label(){return u(`weekly_92845d3b`)}},{value:`monthly`,get label(){return u(`monthly_68b21af9`)}},{value:`cron`,label:`Cron`}],_i=[{value:`run_once`,get label(){return u(`catch_up_once_c2096e4c`)}},{value:`skip`,get label(){return u(`skip_fc50a99c`)}},{value:`catch_up_all`,get label(){return u(`catch_up_all_06529cda`)}},{value:`catch_up_window`,get label(){return u(`catch_up_within_window_28b614d7`)}}],vi=[{value:`queue_one`,get label(){return u(`queue_one_1d2609b4`)}},{value:`skip`,get label(){return u(`skip_fc50a99c`)}},{value:`allow`,get label(){return u(`allow_parallel_runs_33ce425a`)}}],yi={name:``,enabled:!1,trigger_type:`interval`,interval_value:`60`,interval_unit:`minutes`,hour:`9`,minute:`0`,weekly_weekdays:[`mon`],monthly_days:`1`,cron_expr:`0 9 * * *`,timezone:``,start_at:``,end_at:``,misfire_policy:`run_once`,catch_up_max_runs:`1`,catch_up_max_lateness_seconds:`60`,overlap_policy:`queue_one`,task_message:``,system_prompt:``,model:``,workspace_path:``,enhance_prompt:``,auto_execute:!0};function bi(e){return e.trim()||void 0}var xi={seconds:1,minutes:60,hours:3600};function Si(e){return e>0&&e%3600==0?{value:String(e/3600),unit:`hours`}:e>0&&e%60==0?{value:String(e/60),unit:`minutes`}:{value:String(e),unit:`seconds`}}function Ci(e){let t=e.trim();if(!t)return{days:[],invalid:!1};let n=t.split(/[\s,,]+/).filter(Boolean).map(e=>Number(e)),r=n.some(e=>!Number.isInteger(e)||e<1||e>31);return{days:Array.from(new Set(n.filter(e=>Number.isInteger(e)&&e>=1&&e<=31))).sort((e,t)=>e-t),invalid:r}}function wi(e){let t=Number(e.hour),n=Number(e.minute);return!Number.isInteger(t)||t<0||t>23||!Number.isInteger(n)||n<0||n>59?null:{hour:t,minute:n}}function Ti(e){switch(e.trigger_type){case`interval`:{let t=Number(e.interval_value);if(!Number.isFinite(t)||t<=0)return{error:u(`enter_an_interval_greater_than_0_da8d5def`)};let n=Math.round(t*xi[e.interval_unit]);return n<=0?{error:u(`enter_an_interval_greater_than_0_da8d5def`)}:{trigger:{type:`interval`,every_seconds:n}}}case`daily`:{let t=wi(e);return t?{trigger:{type:`daily`,...t,second:0}}:{error:u(`enter_a_valid_time_hour_0_23_minute_0_59_f44f4f37`)}}case`weekly`:{if(e.weekly_weekdays.length===0)return{error:u(`select_at_least_one_weekday_1084b61e`)};let t=wi(e);return t?{trigger:{type:`weekly`,weekdays:e.weekly_weekdays,...t,second:0}}:{error:u(`enter_a_valid_time_hour_0_23_minute_0_59_f44f4f37`)}}case`monthly`:{let{days:t,invalid:n}=Ci(e.monthly_days);if(n)return{error:u(`days_of_month_must_be_integers_from_1_to_31_separated_b_e907e493`)};if(t.length===0)return{error:u(`enter_days_of_month_e_g_1_15_7a903115`)};let r=wi(e);return r?{trigger:{type:`monthly`,days:t,...r,second:0}}:{error:u(`enter_a_valid_time_hour_0_23_minute_0_59_f44f4f37`)}}case`cron`:{let t=bi(e.cron_expr);return t?{trigger:{type:`cron`,expr:t}}:{error:u(`enter_a_cron_expression_443c70c5`)}}default:return{error:u(`select_a_trigger_type_7b90f017`)}}}function Ei(e){switch(e.misfire_policy){case`skip`:return{type:`skip`};case`catch_up_all`:return{type:`catch_up_all`};case`catch_up_window`:return{type:`catch_up_window`,max_catch_up_runs:Math.max(1,Number(e.catch_up_max_runs)||1),max_lateness_seconds:Math.max(1,Number(e.catch_up_max_lateness_seconds)||60)};default:return{type:`run_once`}}}function Di(e,t){return{...t??{},system_prompt:bi(e.system_prompt),task_message:bi(e.task_message),model:bi(e.model),workspace_path:bi(e.workspace_path),enhance_prompt:bi(e.enhance_prompt),auto_execute:e.auto_execute}}function Oi(e){let t={...yi,name:e.name,enabled:e.enabled,trigger_type:e.trigger.type,timezone:e.timezone??``,start_at:e.start_at??``,end_at:e.end_at??``,misfire_policy:e.misfire_policy?.type??`run_once`,overlap_policy:e.overlap_policy??`queue_one`,task_message:e.run_config?.task_message??``,system_prompt:e.run_config?.system_prompt??``,model:e.run_config?.model??``,workspace_path:e.run_config?.workspace_path??``,enhance_prompt:e.run_config?.enhance_prompt??``,auto_execute:!!e.run_config?.auto_execute};switch(e.misfire_policy?.type===`catch_up_window`&&(t.catch_up_max_runs=String(e.misfire_policy.max_catch_up_runs),t.catch_up_max_lateness_seconds=String(e.misfire_policy.max_lateness_seconds)),e.trigger.type){case`interval`:{let{value:n,unit:r}=Si(e.trigger.every_seconds);t.interval_value=n,t.interval_unit=r;break}case`daily`:t.hour=String(e.trigger.hour),t.minute=String(e.trigger.minute);break;case`weekly`:t.weekly_weekdays=e.trigger.weekdays,t.hour=String(e.trigger.hour),t.minute=String(e.trigger.minute);break;case`monthly`:t.monthly_days=e.trigger.days.join(`, `),t.hour=String(e.trigger.hour),t.minute=String(e.trigger.minute);break;case`cron`:t.cron_expr=e.trigger.expr;break}return t}function ki(e){return String(e).padStart(2,`0`)}function Ai(e){switch(e.type){case`interval`:{let t=e.every_seconds??0;return t>0&&t%3600==0?u(`every_hours_347737e7`,{v0:t/3600,count:t/3600}):t>0&&t%60==0?u(`every_minutes_895d33b7`,{v0:t/60,count:t/60}):u(`every_seconds_3b49d477`,{v0:t,count:t})}case`daily`:return u(`daily_at_0b14f6d6`,{v0:ki(e.hour),v1:ki(e.minute)});case`weekly`:return u(`weekly_on_at_73d5220a`,{v0:c(e.weekdays.map(e=>hi.find(t=>t.value===e)?.label??String(e))),v1:ki(e.hour),v2:ki(e.minute)});case`monthly`:return u(`monthly_on_day_at_42b0e4e2`,{v0:e.days.join(`, `),v1:ki(e.hour),v2:ki(e.minute)});case`cron`:return`cron: ${e.expr}`;default:return e.type}}function ji(e){switch(e?.type){case`skip`:return u(`skip_missed_runs_d8ac050b`);case`catch_up_all`:return u(`catch_up_all_missed_runs_1409bcf8`);case`catch_up_window`:return u(`catch_up_missed_runs_within_window_7559803d`);default:return u(`catch_up_one_missed_run_c6ba80f9`)}}function Mi(e){switch(e){case`allow`:return u(`allow_parallel_runs_33ce425a`);case`skip`:return u(`skip_overlapping_runs_15eb649d`);default:return u(`queue_one_overlapping_run_e88647a4`)}}function Ni(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(d(),{hour12:!1})}function Pi(e){return e instanceof Error?e.message:String(e)}function Fi({children:e}){return o(),(0,$.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:e})}function Ii({values:e,onChange:t}){return o(),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`hour_0_23_67d64c5b`)}),(0,$.jsx)(Z,{type:`number`,min:0,max:23,value:e.hour,onChange:e=>t({hour:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`minute_0_59_5162a1bb`)}),(0,$.jsx)(Z,{type:`number`,min:0,max:59,value:e.minute,onChange:e=>t({minute:e.target.value})})]})]})}function Li({values:e,onChange:t,error:n,saving:r,submitLabel:i,onSubmit:a,onCancel:s}){o();let[c,l]=(0,Q.useState)(!1),d=n=>{t({weekly_weekdays:e.weekly_weekdays.includes(n)?e.weekly_weekdays.filter(e=>e!==n):[...e.weekly_weekdays,n]})};return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(Fi,{children:u(`name_d44e9b3d`)}),(0,$.jsx)(Z,{placeholder:u(`scheduled_task_name_b1066de6`),value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`flex h-9 shrink-0 items-center gap-2 text-xs text-muted-foreground`,children:[u(`enabled_f4f0ead1`),` `,(0,$.jsx)(Jt,{checked:e.enabled,onCheckedChange:e=>t({enabled:e})})]})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border bg-background/50 p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`trigger_250bf9d5`)}),(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`trigger_type_97577ce7`)}),(0,$.jsxs)(W,{value:e.trigger_type,onValueChange:e=>t({trigger_type:e}),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsx)(ce,{children:gi.map(e=>(0,$.jsx)(H,{value:e.value,children:e.label},e.value))})]})]}),e.trigger_type===`interval`?(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`every_100107ff`)}),(0,$.jsx)(Z,{type:`number`,min:1,value:e.interval_value,onChange:e=>t({interval_value:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`w-28 shrink-0`,children:[(0,$.jsx)(Fi,{children:u(`unit_80b19d68`)}),(0,$.jsxs)(W,{value:e.interval_unit,onValueChange:e=>t({interval_unit:e}),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:`minutes`,children:u(`minute_bd957bc4`)}),(0,$.jsx)(H,{value:`hours`,children:u(`hour_3b6fefc5`)}),(0,$.jsx)(H,{value:`seconds`,children:u(`seconds_9dcdc2b2`)})]})]})]})]}):null,e.trigger_type===`daily`?(0,$.jsx)(Ii,{values:e,onChange:t}):null,e.trigger_type===`weekly`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`weekdays_c398134d`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:hi.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(t.value),className:X(`size-8 rounded-md border text-xs transition-colors`,e.weekly_weekdays.includes(t.value)?`border-primary bg-primary text-primary-foreground`:`bg-background text-muted-foreground hover:text-foreground`),children:t.label},t.value))})]}),(0,$.jsx)(Ii,{values:e,onChange:t})]}):null,e.trigger_type===`monthly`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`days_of_month_1_31_comma_separated_4ac9fe92`)}),(0,$.jsx)(Z,{placeholder:u(`e_g_1_15_81eec894`),value:e.monthly_days,onChange:e=>t({monthly_days:e.target.value})})]}),(0,$.jsx)(Ii,{values:e,onChange:t})]}):null,e.trigger_type===`cron`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`cron_expression_b505ad2e`)}),(0,$.jsx)(Z,{placeholder:u(`e_g_0_9_0ab6b096`),value:e.cron_expr,onChange:e=>t({cron_expr:e.target.value})})]}):null]})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border bg-background/50 p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`execution_content_7007f0b1`)}),(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`task_content_2b7e32bf`)}),(0,$.jsx)(Ze,{className:`min-h-16 resize-y`,placeholder:u(`task_content_required_for_automatic_execution_f5e84230`),value:e.task_message,onChange:e=>t({task_message:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`automatic_execution_run_the_task_when_triggered_b6df1e0d`)}),(0,$.jsx)(Jt,{checked:e.auto_execute,onCheckedChange:e=>t({auto_execute:e})})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`model_optional_5a32d134`)}),(0,$.jsx)(Z,{placeholder:u(`default_model_1e2933c6`),value:e.model,onChange:e=>t({model:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`working_directory_optional_3102ad46`)}),(0,$.jsx)(Z,{placeholder:u(`workspace_path_c311026e`),value:e.workspace_path,onChange:e=>t({workspace_path:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`system_prompt_optional_86495286`)}),(0,$.jsx)(Ze,{className:`min-h-12 resize-y`,placeholder:u(`override_the_default_system_prompt_f1aced6d`),value:e.system_prompt,onChange:e=>t({system_prompt:e.target.value})})]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline`,children:u(c?`collapse_advanced_options_29272cf0`:`advanced_options_policies_time_zone_effective_period_464f52f2`)}),c?(0,$.jsxs)(`section`,{className:`rounded-lg border bg-background/50 p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`advanced_d6e61888`)}),(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`misfire_policy_7c12f054`)}),(0,$.jsxs)(W,{value:e.misfire_policy,onValueChange:e=>t({misfire_policy:e}),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsx)(ce,{children:_i.map(e=>(0,$.jsx)(H,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`overlap_policy_5a3f749e`)}),(0,$.jsxs)(W,{value:e.overlap_policy,onValueChange:e=>t({overlap_policy:e}),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsx)(ce,{children:vi.map(e=>(0,$.jsx)(H,{value:e.value,children:e.label},e.value))})]})]})]}),e.misfire_policy===`catch_up_window`?(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`maximum_catch_up_runs_e6aa309b`)}),(0,$.jsx)(Z,{type:`number`,min:1,value:e.catch_up_max_runs,onChange:e=>t({catch_up_max_runs:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`maximum_delay_seconds_f2bdfce4`)}),(0,$.jsx)(Z,{type:`number`,min:1,value:e.catch_up_max_lateness_seconds,onChange:e=>t({catch_up_max_lateness_seconds:e.target.value})})]})]}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`time_zone_optional_7b17e06a`)}),(0,$.jsx)(Z,{placeholder:u(`e_g_asia_shanghai_790169bf`),value:e.timezone,onChange:e=>t({timezone:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`start_time_optional_d43c4ece`)}),(0,$.jsx)(Z,{placeholder:`2026-01-01T00:00:00Z`,value:e.start_at,onChange:e=>t({start_at:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Fi,{children:u(`end_time_optional_f5b079bd`)}),(0,$.jsx)(Z,{placeholder:`2026-12-31T00:00:00Z`,value:e.end_at,onChange:e=>t({end_at:e.target.value})})]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:u(`clearing_the_time_zone_start_or_end_fields_and_saving_d_60ffce38`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fi,{children:u(`enhancement_prompt_optional_439879c2`)}),(0,$.jsx)(Ze,{className:`min-h-12 resize-y`,placeholder:u(`enhancement_text_appended_to_the_task_c98fca6e`),value:e.enhance_prompt,onChange:e=>t({enhance_prompt:e.target.value})})]})]})]}):null,n?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:n}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:s,disabled:r,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,onClick:a,disabled:r||!e.name.trim(),children:r?u(`saving_ff509c9b`):i})]})]})}var Ri={get queued(){return u(`queued_d6f766f2`)},get running(){return u(`running_1f0eb99b`)},get success(){return u(`successful_053461ce`)},get failed(){return u(`failed_28384d7a`)},get skipped(){return u(`skipped_71e95b28`)},get missed(){return u(`missed_67330e9d`)},get cancelled(){return u(`cancelled_a37778f1`)}};function zi(e){switch(e){case`success`:return`success`;case`failed`:case`cancelled`:return`destructive`;case`running`:return`default`;case`queued`:return`warning`;default:return`secondary`}}function Bi(e){return e==null?null:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Vi({scheduleId:e}){o();let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)(!0),[a,s]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let t=!1;return i(!0),s(null),Pe.listScheduleRuns(e).then(e=>{t||n(e.runs??[])}).catch(e=>{t||s(u(`could_not_load_run_history_1bebf89d`,{v0:Pi(e)}))}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),r?(0,$.jsx)(`p`,{className:`px-1 py-2 text-xs text-muted-foreground`,children:u(`loading_run_history_0ea0960f`)}):a?(0,$.jsx)(`p`,{className:`px-1 py-2 text-xs text-destructive`,children:a}):t.length===0?(0,$.jsx)(`p`,{className:`px-1 py-2 text-xs text-muted-foreground`,children:u(`no_runs_yet_6c3df58b`)}):(0,$.jsx)(`ul`,{className:`divide-y`,children:t.map(e=>{let t=Bi(e.execution_duration_ms);return(0,$.jsxs)(`li`,{className:`space-y-1 px-1 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(U,{variant:zi(e.status),children:Ri[e.status]??e.status}),(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[u(`scheduled_0f6b1949`),` `,Ni(e.scheduled_for)]}),e.was_catch_up?(0,$.jsx)(U,{variant:`outline`,children:u(`catch_up_1ce0743a`)}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[u(`started_d2bb025a`),` `,Ni(e.started_at),` `,u(`ended_66d5238f`),` `,Ni(e.completed_at),t?u(`duration_dd4a49ef`,{v0:t}):``]}),e.session_id?(0,$.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[u(`session_a6328025`),` `,e.session_id]}):null,e.outcome_reason?(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[u(`reason_0a38db58`),e.outcome_reason]}):null]},e.run_id)})})}function Hi(e){return(e.state?.running_run_count??0)>0?{variant:`default`,label:u(`running_2fe78a4f`,{v0:e.state.running_run_count})}:(e.state?.queued_run_count??0)>0?{variant:`warning`,label:u(`queued_26a1886e`,{v0:e.state.queued_run_count})}:(e.state?.consecutive_failures??0)>0?{variant:`destructive`,label:u(`consecutive_failures_246d1740`,{v0:e.state.consecutive_failures})}:e.enabled?e.state?.last_success_at?{variant:`success`,label:u(`healthy_296de0e3`)}:{variant:`secondary`,label:u(`idle_dae661d1`)}:{variant:`secondary`,label:u(`disabled_a8c3698b`)}}function Ui(e){return Ni(e.state?.last_success_at??e.state?.last_finished_at)}function Wi(){o();let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(!0),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(yi),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),E=(0,Q.useCallback)(()=>{Pe.listSchedules().then(e=>{t(e.schedules??[]),a(null)}).catch(e=>a(u(`could_not_load_scheduled_tasks_563b447d`,{v0:Pi(e)}))).finally(()=>r(!1))},[]);(0,Q.useEffect)(E,[E]);let D=e=>p(t=>({...t,...e})),O=()=>{d(null),p(yi),h(null),c(!0)},k=e=>{c(!1),d(e.id),p(Oi(e)),h(null)},A=()=>{c(!1),d(null),p(yi),h(null)},j=async()=>{if(!f.name.trim()){h(u(`enter_a_name_fbc79033`));return}let{trigger:t,error:n}=Ti(f);if(!t){h(n??u(`complete_the_trigger_configuration_52bf2a1f`));return}let r=Di(f,l?e.find(e=>e.id===l)?.run_config:null);if(f.auto_execute&&!r.task_message){h(u(`task_content_is_required_for_automatic_execution_81c44cf1`));return}_(!0),h(null);try{l?await Pe.patchSchedule(l,{name:f.name.trim(),enabled:f.enabled,trigger:t,timezone:bi(f.timezone),start_at:bi(f.start_at),end_at:bi(f.end_at),misfire_policy:Ei(f),overlap_policy:f.overlap_policy,run_config:r}):await Pe.createSchedule({name:f.name.trim(),enabled:f.enabled,trigger:t,timezone:bi(f.timezone),start_at:bi(f.start_at),end_at:bi(f.end_at),misfire_policy:Ei(f),overlap_policy:f.overlap_policy,run_config:r}),A(),E()}catch(e){h(u(`could_not_save_c4b7c511`,{v0:Pi(e)}))}finally{_(!1)}},M=async(e,t)=>{y(null),x(null);try{await e(),t&&x(t),E()}catch(e){y(Pi(e))}};return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`tasks_triggered_automatically_on_a_schedule_3d3799a3`)}),!s&&!l?(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:O,children:[(0,$.jsx)(fe,{className:`size-4`}),u(`add_0006d696`)]}):null]}),s?(0,$.jsx)(Li,{values:f,onChange:D,error:m,saving:g,submitLabel:u(`add_7a8a11ea`),onSubmit:j,onCancel:A}):null,i?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:i}):null,v?(0,$.jsxs)(`p`,{className:`text-xs text-destructive`,children:[u(`operation_failed_db63436a`),v]}):null,b?(0,$.jsx)(`p`,{className:`text-xs text-primary`,children:b}):null,n?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):e.length===0?!s&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_scheduled_tasks_yet_d55f6399`)}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let t=Hi(e),n=l===e.id;return(0,$.jsxs)(`li`,{className:`rounded-lg border`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,$.jsx)(U,{variant:t.variant,children:t.label}),(0,$.jsx)(Jt,{checked:e.enabled,"aria-label":e.enabled?u(`disable_4e6fd0e2`):u(`enable_action`),onCheckedChange:t=>M(async()=>{await Pe.patchSchedule(e.id,{enabled:t})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:Ai(e.trigger)}),e.timezone?(0,$.jsxs)(`span`,{children:[`· `,e.timezone]}):null,(0,$.jsxs)(`span`,{children:[`· `,ji(e.misfire_policy)]}),(0,$.jsxs)(`span`,{children:[`· `,Mi(e.overlap_policy)]}),e.run_config?.auto_execute?(0,$.jsx)(`span`,{children:u(`automatic_execution_ad0af2bd`)}):null,e.run_config?.model?(0,$.jsxs)(`span`,{children:[`· `,e.run_config.model]}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[u(`next_6f7517d2`),` `,Ni(e.state?.next_fire_at),` `,u(`last_a3c43f9e`),` `,Ui(e)]}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[u(`successful_053461ce`),` `,e.state?.total_success_count??0,` `,u(`failed_89661a55`),` `,e.state?.total_failure_count??0,` `,u(`missed_e550d27f`),` `,e.state?.total_missed_count??0,` `,u(`total_c8b28178`),` `,u(`count_runs`,{count:e.state?.total_run_count??0})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 pt-1`,children:[(0,$.jsx)(`button`,{onClick:()=>M(async()=>{await Pe.runScheduleNow(e.id)},u(`was_queued_for_execution_dea579f0`,{v0:e.name})),"aria-label":u(`run_now_04eb5397`),title:u(`run_now_04eb5397`),className:`rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(yt,{className:`size-4`})}),(0,$.jsx)(`button`,{onClick:()=>C(t=>t===e.id?null:e.id),"aria-label":u(`runs_6e55e0f2`),title:u(`runs_6e55e0f2`),className:X(`rounded p-1 hover:text-foreground`,S===e.id?`text-primary`:`text-muted-foreground`),children:(0,$.jsx)(gt,{className:`size-4`})}),(0,$.jsx)(`button`,{onClick:()=>n?A():k(e),"aria-label":u(`edit_05183656`),title:u(`edit_05183656`),className:X(`rounded p-1 hover:text-foreground`,n?`text-primary`:`text-muted-foreground`),children:(0,$.jsx)(te,{className:`size-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>T(t=>t===e.id?null:e.id),"aria-label":u(`delete_2f9daa82`),title:u(`delete_2f9daa82`),className:`rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]}),w===e.id?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:u(`delete_schedule_confirmation`,{name:e.name})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1.5`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>T(null),children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>{T(null),M(async()=>{await Pe.deleteSchedule(e.id)},u(`deleted_2c8bfdf9`,{v0:e.name}))},children:u(`delete_2f9daa82`)})]})]}):null]}),n?(0,$.jsx)(`div`,{className:`border-t p-2`,children:(0,$.jsx)(Li,{values:f,onChange:D,error:m,saving:g,submitLabel:u(`save_a3030bf8`),onSubmit:j,onCancel:A})}):null,S===e.id?(0,$.jsx)(`div`,{className:`border-t px-2 py-1`,children:(0,$.jsx)(Vi,{scheduleId:e.id})}):null]},e.id)})})]})}var Gi=`notifications/preferences`;function Ki(e){return{enabled:e.enabled,onClarification:e.on_clarification,onToolApproval:e.on_tool_approval,onContextPressure:e.on_context_pressure,onSubAgentComplete:e.on_subagent_complete,onBackgroundTaskComplete:e.on_background_task_complete,onRunComplete:e.on_run_complete,onRunFailed:e.on_run_failed}}function qi(e){return{enabled:e.enabled,on_clarification:e.onClarification,on_tool_approval:e.onToolApproval,on_context_pressure:e.onContextPressure,on_subagent_complete:e.onSubAgentComplete,on_background_task_complete:e.onBackgroundTaskComplete,on_run_complete:e.onRunComplete,on_run_failed:e.onRunFailed}}async function Ji(){return Ki(await J.get(Gi))}async function Yi(e){return Ki(await J.put(Gi,qi(e)))}var Xi=`https://ntfy.sh`,Zi=`https://api.day.app`;function Qi(e){let t=e?.desktop?.enabled;return{desktopMode:t===!0?`on`:t===!1?`off`:`auto`,ntfyEnabled:e?.ntfy?.enabled??!1,ntfyBaseUrl:e?.ntfy?.base_url??Xi,ntfyTopic:e?.ntfy?.topic??``,ntfyToken:Yt(e?.ntfy?.token)?``:e?.ntfy?.token??``,barkEnabled:e?.bark?.enabled??!1,barkBaseUrl:e?.bark?.base_url??Zi,barkDeviceKey:Yt(e?.bark?.device_key)?``:e?.bark?.device_key??``}}function $i({label:e,value:t,onChange:n,type:r=`text`,placeholder:i}){return o(),(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-muted-foreground`,children:e}),(0,$.jsx)(Z,{type:r,value:t,placeholder:i,onChange:e=>n(e.target.value)})]})}function ea(){o();let[e,t]=(0,Q.useState)(void 0),[n,r]=(0,Q.useState)(()=>Qi(void 0)),[i,a]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(null),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S=async()=>{a(!0),c(null);try{let e=await J.get(`bamboo/config`);t(e.notifications),r(Qi(e.notifications))}catch(e){c(q(e))}finally{a(!1)}};(0,Q.useEffect)(()=>{S()},[]);let C=e=>r(t=>({...t,...e})),w=Yt(e?.ntfy?.token),T=Yt(e?.bark?.device_key),E=async()=>{d(!0),p(null),h(!1);try{let e=n.ntfyToken.trim(),i=n.barkDeviceKey.trim(),a={notifications:{desktop:{enabled:n.desktopMode===`auto`?null:n.desktopMode===`on`},ntfy:{enabled:n.ntfyEnabled,base_url:n.ntfyBaseUrl.trim()||Xi,topic:n.ntfyTopic.trim(),...e?{token:e}:{}},bark:{enabled:n.barkEnabled,base_url:n.barkBaseUrl.trim()||Zi,...i?{device_key:i}:{}}}},o=await J.post(`bamboo/config`,a);t(o.notifications),r(Qi(o.notifications)),h(!0),setTimeout(()=>h(!1),2500)}catch(e){p(q(e))}finally{d(!1)}},D=async()=>{_(!0),y(null),x(null);try{x((await J.post(`notifications/test`)).attempted)}catch(e){y(q(e))}finally{_(!1)}};return i?(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`notification_channels_b2354ceb`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)})]}):s?(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`notification_channels_b2354ceb`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:s}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`shrink-0`,onClick:()=>void S(),children:u(`retry_b8784c8d`)})]})]}):(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`notification_channels_b2354ceb`)}),(0,$.jsx)(`p`,{className:`mb-3 text-xs leading-relaxed text-muted-foreground`,children:u(`configure_backend_notification_delivery_desktop_ntfy_ba_d7494474`)}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:u(`desktop_notifications_717084d9`)}),(0,$.jsxs)(W,{value:n.desktopMode,onValueChange:e=>C({desktopMode:e}),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:`auto`,children:u(`auto_on_when_standalone_off_when_embedded_in_bodhi_abe65183`)}),(0,$.jsx)(H,{value:`on`,children:u(`on_8da97ddd`)}),(0,$.jsx)(H,{value:`off`,children:u(`notifications_off`)})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:`ntfy`}),(0,$.jsx)(Jt,{checked:n.ntfyEnabled,onCheckedChange:e=>C({ntfyEnabled:e}),"aria-label":u(`enable_ntfy_22f70ff4`)})]}),(0,$.jsx)($i,{label:`Base URL`,value:n.ntfyBaseUrl,onChange:e=>C({ntfyBaseUrl:e}),placeholder:Xi}),(0,$.jsx)($i,{label:`Topic`,value:n.ntfyTopic,onChange:e=>C({ntfyTopic:e}),placeholder:`my-bamboo-topic`}),(0,$.jsx)($i,{label:u(`token_optional_self_hosted_397fbbe8`),value:n.ntfyToken,onChange:e=>C({ntfyToken:e}),type:`password`,placeholder:u(w?`configured_leave_blank_to_keep_f3805ede`:`not_required_for_public_ntfy_sh_topics_fe732726`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:`Bark`}),(0,$.jsx)(Jt,{checked:n.barkEnabled,onCheckedChange:e=>C({barkEnabled:e}),"aria-label":u(`enable_bark_d60caf2b`)})]}),(0,$.jsx)($i,{label:`Base URL`,value:n.barkBaseUrl,onChange:e=>C({barkBaseUrl:e}),placeholder:Zi}),(0,$.jsx)($i,{label:`Device Key`,value:n.barkDeviceKey,onChange:e=>C({barkDeviceKey:e}),type:`password`,placeholder:u(T?`configured_leave_blank_to_keep_f3805ede`:`device_key_from_the_ios_bark_app_2d3b3e59`)})]}),f?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:f}):null,(0,$.jsxs)(`div`,{className:`flex items-end justify-between gap-2 border-t pt-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>void D(),disabled:g,children:u(g?`sending_364970d8`:`test_notification_channels_109fe0da`)}),b?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b.length>0?u(`attempted_0e32a3d3`,{v0:b.join(`, `)}):u(`no_channels_enabled_14d78be1`)}):null,v?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:v}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m?(0,$.jsx)(`span`,{className:`text-xs text-emerald-500`,children:u(`saved_1bd91a7d`)}):null,(0,$.jsx)(Y,{size:`sm`,onClick:()=>void E(),disabled:l,children:u(l?`saving_ff509c9b`:`save_channel_settings_e9951ba0`)})]})]})]})]})}var ta=[{key:`onClarification`,get label(){return u(`when_the_agent_needs_clarification_e088e7d7`)}},{key:`onToolApproval`,get label(){return u(`when_a_tool_needs_approval_97b94cf2`)}},{key:`onContextPressure`,get label(){return u(`when_context_approaches_its_limit_b54b0d2c`)}},{key:`onSubAgentComplete`,get label(){return u(`when_a_background_subtask_completes_92a62146`)}},{key:`onRunComplete`,get label(){return u(`when_a_task_run_completes_successfully_f1a64ada`)}},{key:`onRunFailed`,get label(){return u(`when_a_task_run_fails_55780996`)}}];function na(){o();let[e,t]=(0,Q.useState)(Ae()),[n,r]=(0,Q.useState)(we()),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!0),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),m=async()=>{c(!0),d(null);try{a(await Ji())}catch(e){d(e instanceof Error?e.message:u(`could_not_load_notification_preferences_c66b5a75`))}finally{c(!1)}};(0,Q.useEffect)(()=>{m()},[]);let h=(e,t)=>{if(!i)return;let n=i,r={...i,[e]:t};a(r),p(null),Yi(r).then(e=>a(e)).catch(e=>{a(n),p(e instanceof Error?e.message:u(`could_not_save_notification_preferences_951b0058`))})},g=async()=>{if(!e){let e=await Te();if(r(we()),!e)return}let n=!e;t(n),je(n)};return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`notification_preferences_server_fffc7e6d`)}),(0,$.jsx)(`p`,{className:`mb-3 text-xs leading-relaxed text-muted-foreground`,children:u(`the_backend_determines_notifications_centrally_includin_bb244be6`)}),s?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):l?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:l}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`shrink-0`,onClick:()=>void m(),children:u(`retry_b8784c8d`)})]}):i?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`enable_notifications_master_switch_fef57a27`)}),(0,$.jsx)(Jt,{checked:i.enabled,onCheckedChange:e=>h(`enabled`,e),"aria-label":u(`enable_notifications_73e369d5`)})]}),(0,$.jsxs)(`div`,{className:X(`space-y-2.5 border-t pt-2.5`,!i.enabled&&`pointer-events-none opacity-50`),children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`notify_me_in_these_situations_cbbff5c0`)}),ta.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm`,children:e.label}),(0,$.jsx)(Jt,{checked:i[e.key],disabled:!i.enabled,onCheckedChange:t=>h(e.key,t),"aria-label":e.label})]},e.key))]}),f?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:f}):null]}):null]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`browser_notifications_this_device_ff712968`)}),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:u(`task_completion_alerts_90a30333`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:u(`receive_a_browser_notification_when_an_agent_task_compl_c0524c35`)})]}),(0,$.jsx)(Jt,{checked:e,onCheckedChange:()=>void g(),"aria-label":u(`task_completion_alerts_90a30333`),className:`mt-0.5`})]}),n===`denied`?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:u(`notifications_are_blocked_allow_them_in_your_browser_s__83cdc1ce`)}):n===`unsupported`?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`notifications_are_not_supported_in_this_environment_37a9c6ef`)}):null,e&&n===`granted`?(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`mt-3`,onClick:()=>Me(u(`bodhi_test_notification_7de1d35e`),u(`notifications_are_working_3a772497`)),children:u(`send_test_notification_5e0022a1`)}):null]}),(0,$.jsx)(ea,{})]})}var ra=[`exact`,`regex`];function ia(){o();let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(!0),[i,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`exact`);(0,Q.useEffect)(()=>{K.getKeywordMaskingConfig().then(e=>t(e.entries)).catch(()=>{}).finally(()=>r(!1))},[]);let l=async e=>{t(e);try{t((await K.updateKeywordMaskingConfig(e)).entries)}catch{}},d=()=>{i.trim()&&(l([...e,{pattern:i.trim(),match_type:s,enabled:!0}]),a(``))},[f,p]=(0,Q.useState)(``),m=(0,Q.useMemo)(()=>{let t=f;for(let n of e)if(!(!n.enabled||!n.pattern))try{t=n.match_type===`regex`?t.replace(new RegExp(n.pattern,`g`),`***`):t.split(n.pattern).join(`***`)}catch{}return t},[f,e]);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:u(`matches_are_masked_before_being_sent_to_models_or_logs__c8a6d58b`)}),(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`add_rule_83009fcf`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{className:`flex-1`,placeholder:u(`content_pattern_to_mask_d870245d`),value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d()}}),(0,$.jsxs)(W,{value:s,onValueChange:c,children:[(0,$.jsx)(se,{className:`w-28 shrink-0`,children:(0,$.jsx)(V,{})}),(0,$.jsx)(ce,{children:ra.map(e=>(0,$.jsx)(H,{value:e,children:e},e))})]}),(0,$.jsx)(Y,{size:`sm`,onClick:d,disabled:!i.trim(),children:(0,$.jsx)(fe,{className:`size-4`})})]})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:[u(`masking_rules_5f1fa4a9`),e.length,`)`]}),n?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`none_yet_b336a174`)}):(0,$.jsx)(`ul`,{className:`space-y-1.5`,children:e.map((t,n)=>(0,$.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md bg-muted/40 px-2.5 py-1.5`,children:[(0,$.jsx)(Jt,{checked:t.enabled,onCheckedChange:()=>void l(e.map((e,t)=>t===n?{...e,enabled:!e.enabled}:e)),"aria-label":u(`enable_rule_d23ee517`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.pattern}),(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:t.match_type}),(0,$.jsx)(`button`,{onClick:()=>void l(e.filter((e,t)=>t!==n)),"aria-label":u(`delete_2f9daa82`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]},`${t.pattern}-${n}`))})]}),(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`preview_13d61fea`)}),(0,$.jsx)(Ze,{className:`min-h-16 resize-y rounded-md border px-2.5 py-1.5 text-sm`,placeholder:u(`enter_text_to_preview_masking_48b25eea`),value:f,onChange:e=>p(e.target.value)}),f?(0,$.jsx)(`div`,{className:`rounded-md bg-muted/40 p-2.5 text-sm [overflow-wrap:anywhere]`,children:m}):null]})]})}function aa({label:e,description:t,checked:n,onCheckedChange:r}){return o(),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:e}),t?(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-muted-foreground`,children:t}):null]}),(0,$.jsx)(Jt,{checked:n,onCheckedChange:r,"aria-label":e,className:`mt-0.5 shrink-0`})]})}function oa(){o();let e=Oe(e=>e.systemPrompts),t=Oe(e=>e.addSystemPrompt),n=Oe(e=>e.updateSystemPrompt),r=Oe(e=>e.deleteSystemPrompt),i=G(e=>{let t=e.providerSnapshot?.defaults?.chat.provider;return t?e.getProviderType(t)===`copilot`:!1}),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),C=e=>{l(e),f(e?.name??``),m(e?.content??``),v(null),s(!0)},T=()=>{s(!1),l(null),f(``),m(``),v(null)},O=async()=>{if(!(!d.trim()||!p.trim())){g(!0),v(null);try{c?await n({...c,name:d.trim(),content:p}):await t({name:d.trim(),content:p}),T()}catch(e){v(q(e))}finally{g(!1)}}},k=async e=>{b(null);try{await r(e.id)}catch(t){b(u(`could_not_delete_e74a58dc`,{v0:e.name,v1:q(t)}))}},[j,N]=(0,Q.useState)(()=>M()),[ee,F]=(0,Q.useState)(!1),I=()=>{E(j),F(!0),setTimeout(()=>F(!1),2e3)},[L,re]=(0,Q.useState)(()=>D()),[R,z]=(0,Q.useState)(()=>S()),[ie,ae]=(0,Q.useState)(()=>P());return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`system_prompt_presets_3aced1c3`)}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:()=>C(null),children:[(0,$.jsx)(fe,{className:`size-4`}),u(`add_0006d696`)]})]}),y?(0,$.jsx)(`p`,{className:`mb-2 text-xs text-destructive`,children:y}):null,e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_presets_yet_0c75be1d`)}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),e.isDefault?(0,$.jsx)(U,{variant:`secondary`,className:`shrink-0 text-[10px]`,children:u(`default_844b8cc8`)}):null]}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.description||e.content.slice(0,120)})]}),e.isDefault?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{onClick:()=>C(e),"aria-label":u(`edit_05183656`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(te,{className:`size-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>void k(e),"aria-label":u(`delete_2f9daa82`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]})]},e.id))})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`prompt_enhancement_e4500793`)}),(0,$.jsx)(`p`,{className:`mb-2 text-xs leading-relaxed text-muted-foreground`,children:u(`custom_content_appended_to_system_prompts_for_all_sessi_7e014a9a`)}),(0,$.jsx)(Ze,{className:`min-h-24 resize-y text-sm`,placeholder:u(`enter_enhancement_text_to_append_bb366915`),value:j,onChange:e=>N(e.target.value)}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-2`,children:[ee?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`saved_1bd91a7d`)}):null,(0,$.jsx)(Y,{size:`sm`,onClick:I,children:u(`save_a3030bf8`)})]})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:u(`enhancement_switches_e2a6a5a8`)}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(aa,{label:u(`mermaid_diagram_enhancement_267bc7a4`),description:u(`encourage_mermaid_diagrams_when_explaining_workflows_an_d05fbd2a`),checked:L,onCheckedChange:e=>{re(e),w(e)}}),(0,$.jsx)(aa,{label:u(`task_list_rules_ec44f37e`),description:u(`encourage_the_model_to_track_multi_step_tasks_with_the__97ac7808`),checked:R,onCheckedChange:e=>{z(e),A(e)}}),i?(0,$.jsx)(aa,{label:u(`copilot_completion_confirmation_735f51ca`),description:u(`require_copilot_to_call_conclusion_with_options_for_you_c22f3eda`),checked:ie,onCheckedChange:e=>{ae(e),x(e)}}):null]})]}),(0,$.jsx)(Ge,{open:a,onOpenChange:e=>{e||T()},children:(0,$.jsxs)(Ue,{className:`p-5 sm:max-w-lg`,children:[(0,$.jsx)(He,{children:u(c?`edit_preset_4e32d8db`:`add_preset_0a866812`)}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-2.5`,children:[(0,$.jsx)(Z,{placeholder:u(`name_d44e9b3d`),value:d,onChange:e=>f(e.target.value)}),(0,$.jsx)(Ze,{className:`min-h-40 resize-y text-sm`,placeholder:u(`prompt_content_cc1ab53a`),value:p,onChange:e=>m(e.target.value)}),_?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:_}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:T,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>void O(),disabled:h||!d.trim()||!p.trim(),children:u(h?`saving_ff509c9b`:`save_a3030bf8`)})]})]})]})})]})}function sa(e){if(!e||e.trim()!==e||e.length>255||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`))return!1;for(let t of e){let e=t.charCodeAt(0);if(e<32||e===127)return!1}return!0}function ca(){o();let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(!0),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(0),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),D=(0,Q.useCallback)(async()=>{r(!0),a(null);try{let e=((await N.listCommands()).commands??[]).filter(e=>e.type===`workflow`).sort((e,t)=>e.name.localeCompare(t.name));return t(e),e}catch(e){return a(u(`could_not_load_workflow_list_2b2396a1`,{v0:q(e)})),[]}finally{r(!1)}},[]);(0,Q.useEffect)(()=>{D()},[D]);let O=()=>{c(null),d(!1),p(``),h(``),S(!1),w(null)},k=()=>{O(),d(!0)},A=async e=>{d(!1),c(e),p(e),h(``),S(!1),w(null),_(!0);let t=++v.current;try{let n=await N.getWorkflowCommand(e);if(v.current!==t)return;h(n.content??``)}catch(e){if(v.current!==t)return;w(u(`could_not_load_content_1df3cf32`,{v0:q(e)}))}finally{v.current===t&&_(!1)}},j=async()=>{let t=f.trim();if(w(null),!sa(t)){w(u(`invalid_name_required_and_cannot_contain_or_42cdaab3`));return}if(l&&e.some(e=>e.name===t)){w(u(`a_workflow_named_already_exists_1194d8fa`,{v0:t}));return}b(!0);try{await K.saveWorkflow(t,m),S(!1),d(!1),c(t),E(!0),setTimeout(()=>E(!1),2e3),await D()}catch(e){w(u(`could_not_save_c4b7c511`,{v0:q(e)}))}finally{b(!1)}},M=async e=>{a(null);try{await K.deleteWorkflow(e),s===e&&O(),await D()}catch(t){a(u(`could_not_delete_e74a58dc`,{v0:e,v1:q(t)}))}},P=l||s!==null;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`markdown_workflows_can_be_invoked_in_chat_with_name_8bf54549`)}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1.5`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>void D(),"aria-label":u(`refresh_aee88743`),children:(0,$.jsx)(pe,{className:X(`size-4`,n&&`animate-spin`)})}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:k,children:[(0,$.jsx)(fe,{className:`size-4`}),u(`add_0006d696`)]})]})]}),i?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:i}):null,P?(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border bg-muted/30 p-3`,children:[(0,$.jsx)(Z,{placeholder:u(`name_without_md_extension_d694eedf`),value:f,disabled:!l,onChange:e=>{p(e.target.value),S(!0)}}),(0,$.jsx)(Ze,{className:`min-h-48 resize-y font-mono text-xs`,placeholder:u(g?`loading_4927a53b`:`markdown_content_eefe6dfc`),value:m,disabled:g,onChange:e=>{h(e.target.value),S(!0)}}),C?(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:C}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[T?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`saved_1bd91a7d`)}):null,(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:O,children:u(`close_3fd47edc`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>void j(),disabled:y||!x||!f.trim(),children:u(y?`saving_ff509c9b`:`save_a3030bf8`)})]})]}):null,n&&e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_workflows_yet_5c7b21e5`)}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let t=typeof e.metadata?.filename==`string`?e.metadata.filename:`${e.name}.md`;return(0,$.jsxs)(`li`,{className:X(`flex cursor-pointer items-center gap-2 rounded-lg border p-3`,s===e.name&&`border-primary/50 bg-muted/40`),onClick:()=>void A(e.name),children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[`/`,e.name]}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t})]}),(0,$.jsx)(`button`,{onClick:t=>{t.stopPropagation(),M(e.name)},"aria-label":u(`delete_2f9daa82`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]},e.id)})})]})}var la=`****...****`,ua=3e4,da={not_deployed:{get label(){return u(`not_deployed_d5c4befa`)},cls:`bg-muted text-muted-foreground`},deploying:{get label(){return u(`deploying_096fbd86`)},cls:`animate-pulse bg-blue-500/15 text-blue-600 dark:text-blue-400`},running:{get label(){return u(`running_1f0eb99b`)},cls:`bg-primary/15 text-primary`},unreachable:{get label(){return u(`unreachable_8d7c0301`)},cls:`bg-amber-500/15 text-amber-600 dark:text-amber-400`},stopped:{get label(){return u(`stopped_f006455e`)},cls:`bg-muted text-muted-foreground`},failed:{get label(){return u(`failed_28384d7a`)},cls:`bg-destructive/15 text-destructive`}},fa={get test(){return u(`test_6aa8f49c`)},get deploy(){return u(`deploy_3ca77185`)},get stop(){return u(`stop_ca4d973c`)}},pa={get test(){return u(`connected_successfully_4a19cb8a`)},get deploy(){return u(`deployment_triggered_7e32b41b`)},get stop(){return u(`stop_triggered_72121661`)}};function ma(e){if(!e)return``;let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return u(`seconds_ago_f58a9f01`,{v0:n,count:n});let r=Math.floor(n/60);if(r<60)return u(`minutes_ago_700ed992`,{v0:r,count:r});let i=Math.floor(r/60);return i<24?u(`hours_ago_c8f8001b`,{v0:i,count:i}):u(`days_ago_f0351b9d`,{v0:Math.floor(i/24),count:Math.floor(i/24)})}function ha(e,t){return e instanceof Error&&e.message?e.message:t}function ga(e){return e.placement.type===`ssh`?`${e.placement.username}@${e.placement.host}:${e.placement.port}`:u(`local_8a94c4a1`)}var _a={label:``,placementType:`ssh`,host:``,port:`22`,username:``,authMethod:`password`,password:``,privateKey:``,privateKeyPath:``,passphrase:``,trustLevel:`trusted`,artifactPath:``,remoteDir:``,defaultRole:``,model:``,workspace:``,autoRecover:!1,enabled:!0};function va(){o();let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(!0),[s,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),m=(0,Q.useRef)(null),h=(0,Q.useCallback)((e,t)=>{f({kind:e,text:t}),m.current&&window.clearTimeout(m.current),e===`ok`&&(m.current=window.setTimeout(()=>f(null),4e3))},[]);(0,Q.useEffect)(()=>()=>{m.current&&window.clearTimeout(m.current)},[]);let[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(_a),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[ee,F]=(0,Q.useState)(!1),[I,re]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(``),[oe,B]=(0,Q.useState)(``),[le,ue]=(0,Q.useState)([]),[de,me]=(0,Q.useState)(null),[he,_e]=(0,Q.useState)(!1),[ve,ye]=(0,Q.useState)(null),[xe,Se]=(0,Q.useState)(null),[Ce,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)(null),De=(0,Q.useRef)(0),Oe=(0,Q.useCallback)(async(e=!1)=>{let n=++De.current;e||a(!0);try{let e=await be.listNodes();if(n!==De.current)return;t(e.nodes??[]),r(e.clusters??[]),l(null)}catch(t){n===De.current&&!e&&l(ha(t,u(`could_not_load_cluster_settings_96bba618`)))}finally{e||a(!1)}},[]);(0,Q.useEffect)(()=>{Oe()},[Oe]);let ke=g||D||ee;(0,Q.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&!ke&&Oe(!0)},t=window.setInterval(e,ua);return document.addEventListener(`visibilitychange`,e),()=>{window.clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[Oe,ke]);let G=(0,Q.useMemo)(()=>{let e=new Map;for(let t of n)for(let n of t.node_ids)e.has(n)||e.set(n,t.name);return e},[n]),Ae=()=>{y(null),S({..._a}),w(null),_(!0)},je=e=>{let t=e.placement.type===`ssh`?e.placement:void 0,n=t?.auth;y(e.id),S({label:e.label,placementType:e.placement.type,host:t?.host??``,port:String(t?.port??22),username:t?.username??``,authMethod:n?.method??`password`,password:``,privateKey:``,privateKeyPath:n?.method===`private_key`?n.private_key_path??``:``,passphrase:``,trustLevel:e.trust_level??`trusted`,artifactPath:e.deploy?.artifact_path??``,remoteDir:e.deploy?.remote_dir??``,defaultRole:e.deploy?.default_role??``,model:e.deploy?.model??``,workspace:e.deploy?.workspace??``,autoRecover:e.deploy?.auto_recover??!1,enabled:e.enabled}),w(null),_(!0)},Me=()=>{_(!1),y(null),w(null)},K=(e,t)=>S(n=>({...n,[e]:t})),Ne=v?e.find(e=>e.id===v):void 0,q=Ne?.placement.type===`ssh`?Ne.placement.auth:void 0,J=e=>{if(!e.label.trim())return u(`name_is_required_e8365416`);if(e.placementType===`ssh`){if(!e.host.trim())return u(`host_is_required_0c6a959b`);if(!e.username.trim())return u(`username_is_required_390ccdec`);let t=Number(e.port);if(!Number.isInteger(t)||t<1||t>65535)return u(`port_must_be_between_1_and_65535_2cc08f2a`);if(e.authMethod===`password`){let t=q?.method===`password`&&!!q.password;if(!e.password&&!t)return u(`password_is_required_3aa7a9e0`)}if(e.authMethod===`private_key`){let t=!!(e.privateKey.trim()||e.privateKeyPath.trim()),n=q?.method===`private_key`&&!!(q.private_key||q.private_key_path);if(!t&&!n)return u(`provide_private_key_content_or_a_private_key_file_path_e183c9eb`)}}return null},Pe=e=>{if(e.placementType===`local`)return{type:`local`};let t=q,n=(e,t)=>!!e&&!t,r;if(e.authMethod===`system_ssh_config`)r={method:`system_ssh_config`};else if(e.authMethod===`private_key`){let i=t?.method===`private_key`?t.private_key:void 0,a=t?.method===`private_key`?t.passphrase:void 0;r={method:`private_key`,private_key:n(i,e.privateKey)?la:e.privateKey||void 0,private_key_path:e.privateKeyPath.trim()||void 0,passphrase:n(a,e.passphrase)?la:e.passphrase||void 0}}else r={method:`password`,password:n(t?.method===`password`?t.password:void 0,e.password)?la:e.password};return{type:`ssh`,host:e.host.trim(),port:Number(e.port)||22,username:e.username.trim(),auth:r}},Fe=async()=>{let e=J(x);if(e){w(e);return}let t={label:x.label.trim(),placement:Pe(x),trust_level:x.trustLevel,enabled:x.enabled,deploy:{artifact_path:x.artifactPath.trim()||void 0,artifact_sha256:Ne?.deploy?.artifact_sha256,remote_dir:x.remoteDir.trim()||void 0,default_role:x.defaultRole.trim()||void 0,model:x.model.trim()||void 0,workspace:x.workspace.trim()||void 0,auto_recover:x.autoRecover}};E(!0),w(null);try{v?await be.updateNode(v,t):await be.createNode(t),h(`ok`,u(v?`node_updated_726bbf53`:`node_created_a2d136da`)),Me(),Oe()}catch(e){w(ha(e,u(`could_not_save_node_aab1bd8b`)))}finally{E(!1)}},Ie=async e=>{Se(e.id);try{await be.updateNode(e.id,{label:e.label,placement:e.placement,trust_level:e.trust_level,deploy:e.deploy,enabled:!e.enabled}),Oe(!0)}catch(e){h(`err`,u(`could_not_change_enabled_state_733ce52b`,{v0:ha(e,u(`unknown_error`))}))}finally{Se(null)}},Le=async e=>{try{await be.deleteNode(e),h(`ok`,u(`node_deleted_ad977456`)),Oe(!0)}catch(e){h(`err`,u(`could_not_delete_node_182c9128`,{v0:ha(e,u(`unknown_error`))}))}finally{we(null)}},Re=async(e,t)=>{ye({id:e.id,action:t});try{let n=await be.nodeAction(e.id,t),r=t===`test`&&n&&typeof n==`object`&&`preflight`in n?String(n.preflight??``):``;h(`ok`,r?u(`connected_d82f3f8f`,{v0:r}):pa[t]),Oe(!0)}catch(e){h(`err`,u(`failed_aaf317fd`,{v0:fa[t],v1:ha(e,u(`unknown_error`))}))}finally{ye(null)}},ze=async e=>{A(e),O(!0),P(!0),M(``);try{M((await be.nodeLogs(e.id,200)).logs||u(`no_log_output_yet_fcfbdb9a`))}catch(e){M(ha(e,u(`could_not_read_logs_c9d4f6cd`)))}finally{P(!1)}},Be=()=>{re(null),z(``),B(``),ue([]),me(null),F(!0)},Ve=e=>{re(e.name),z(e.name),B(e.description??``),ue([...e.node_ids]),me(null),F(!0)},We=()=>{F(!1),re(null),me(null)},Ke=e=>ue(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),qe=async()=>{let e=R.trim();if(!e){me(u(`cluster_name_is_required_cbb7c731`));return}_e(!0),me(null);try{let t={name:e,description:oe.trim()||void 0,node_ids:le};I?await be.updateCluster(I,t):await be.createCluster(t),h(`ok`,u(`cluster_saved_84956917`)),We(),Oe()}catch(e){me(u(`could_not_save_cluster_membership_changes_did_not_take__22529f62`,{v0:ha(e,u(`unknown_error`))}))}finally{_e(!1)}},Je=async e=>{try{await be.deleteCluster(e),h(`ok`,u(`cluster_deleted_member_nodes_kept_58bda9cb`)),Oe(!0)}catch(e){h(`err`,u(`could_not_delete_cluster_f176a20e`,{v0:ha(e,u(`unknown_error`))}))}finally{Ee(null)}},Ye=x.placementType===`ssh`;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`register_local_or_remote_ssh_machines_to_deploy_worker__bf3f5b75`)}),d?(0,$.jsxs)(`div`,{className:X(`flex items-start gap-2 rounded-md border px-3 py-2 text-xs`,d.kind===`err`?`border-destructive/30 bg-destructive/10 text-destructive`:`border-primary/30 bg-primary/10 text-primary`),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:d.text}),(0,$.jsx)(`button`,{onClick:()=>f(null),"aria-label":u(`dismiss_notification_d301bc12`),className:`shrink-0 opacity-70 hover:opacity-100`,children:(0,$.jsx)(ge,{className:`size-3.5`})})]}):null,s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(L,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:s}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,onClick:()=>void Oe(),children:u(`retry_b8784c8d`)})]}):null,(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`nodes_2410d860`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,"aria-label":u(`refresh_aee88743`),onClick:()=>void Oe(),children:(0,$.jsx)(pe,{className:X(`size-3.5`,i&&`animate-spin`)})}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,onClick:Ae,children:[(0,$.jsx)(fe,{className:`size-3.5`}),u(`add_node_09da9abd`)]})]})]}),i&&e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_nodes_yet_281309d3`)}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let t=e.state?.status??`not_deployed`,n=da[t],r=e.state?.last_error,i=ma(e.state?.last_health),a=G.get(e.id),o=ve?.id===e.id;return(0,$.jsxs)(`li`,{className:`space-y-1.5 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.placement.type===`ssh`?(0,$.jsx)(b,{className:`size-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(p,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.label}),(0,$.jsx)(U,{variant:`outline`,className:X(`border-transparent`,n.cls),title:r&&(t===`unreachable`||t===`failed`)?r:void 0,children:n.label}),(0,$.jsx)(Jt,{checked:e.enabled,disabled:xe===e.id,onCheckedChange:()=>void Ie(e),"aria-label":e.enabled?u(`disable_node_8a809f1d`):u(`enable_node_b7e7cd5a`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:ga(e)}),a?(0,$.jsx)(U,{variant:`outline`,className:`h-4 px-1.5 text-[10px]`,children:a}):null,e.trust_level===`untrusted`?(0,$.jsx)(U,{variant:`warning`,className:`h-4 px-1.5 text-[10px]`,children:u(`untrusted_1ddc3b8a`)}):null,e.enabled?null:(0,$.jsx)(`span`,{children:u(`disabled_a8c3698b`)}),i?(0,$.jsxs)(`span`,{children:[u(`last_active_30f38ff1`),` `,i]}):null]}),r&&(t===`unreachable`||t===`failed`)?(0,$.jsx)(`p`,{className:`truncate text-xs text-destructive`,title:r,children:r}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-0.5`,children:[[`test`,`deploy`,`stop`].map(t=>(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,disabled:o,onClick:()=>void Re(e,t),children:[o&&ve?.action===t?(0,$.jsx)(ie,{className:`size-3 animate-spin`}):null,fa[t]]},t)),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,onClick:()=>void ze(e),children:u(`logs_7dbac1c2`)}),(0,$.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:Ce===e.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:u(`confirm_deletion_2d61cf17`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,className:`h-7 px-2 text-xs`,onClick:()=>void Le(e.id),children:u(`delete_2f9daa82`)}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,onClick:()=>we(null),children:u(`cancel_2cd0f3be`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{onClick:()=>je(e),"aria-label":u(`edit_node_eca9fae8`),className:`rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(te,{className:`size-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>we(e.id),"aria-label":u(`delete_node_685e2d0b`),className:`rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]})})]})]},e.id)})})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`clusters_5318ca46`)}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,className:`h-7 px-2 text-xs`,onClick:Be,children:[(0,$.jsx)(fe,{className:`size-3.5`}),u(`add_cluster_0a87eec0`)]})]}),n.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_clusters_yet_25b2d086`)}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:n.map(t=>{let n=c(t.node_ids.map(t=>e.find(e=>e.id===t)?.label??t));return(0,$.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:t.name}),(0,$.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[u(`count_nodes`,{count:t.node_ids.length}),` `,n?` · ${n}`:``,t.description?` · ${t.description}`:``]})]}),Te===t.name?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-destructive`,children:u(`confirm_deletion_2d61cf17`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>void Je(t.name),children:u(`delete_2f9daa82`)}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>Ee(null),children:u(`cancel_2cd0f3be`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{onClick:()=>Ve(t),"aria-label":u(`edit_cluster_28890c2b`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(te,{className:`size-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>Ee(t.name),"aria-label":u(`delete_cluster_7ab3ed6c`),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(ne,{className:`size-3.5`})})]})]},t.name)})})]}),(0,$.jsx)(Ge,{open:g,onOpenChange:e=>{e||Me()},children:(0,$.jsxs)(Ue,{className:`p-5 sm:max-w-lg`,children:[(0,$.jsx)(He,{children:u(v?`edit_node_eca9fae8`:`add_node_09da9abd`)}),(0,$.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-3 overflow-y-auto pr-1`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`name_d44e9b3d`)}),(0,$.jsx)(Z,{value:x.label,onChange:e=>K(`label`,e.target.value),placeholder:`gpu-1`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`deployment_location_9d554c49`)}),(0,$.jsxs)(W,{value:x.placementType,onValueChange:e=>K(`placementType`,e),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:`ssh`,children:u(`ssh_remote_563675ae`)}),(0,$.jsx)(H,{value:`local`,children:u(`local_8a94c4a1`)})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`trust_level_ca9df95a`)}),(0,$.jsxs)(W,{value:x.trustLevel,onValueChange:e=>K(`trustLevel`,e),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:`trusted`,children:u(`trusted_8627bad4`)}),(0,$.jsx)(H,{value:`untrusted`,children:u(`untrusted_1ddc3b8a`)})]})]})]})]}),Ye?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[1fr_6rem] gap-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`host_e87d9f23`)}),(0,$.jsx)(Z,{value:x.host,onChange:e=>K(`host`,e.target.value),placeholder:`10.0.0.5`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`port_e71ac32b`)}),(0,$.jsx)(Z,{inputMode:`numeric`,value:x.port,onChange:e=>K(`port`,e.target.value),placeholder:`22`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`username_1a3f0617`)}),(0,$.jsx)(Z,{value:x.username,onChange:e=>K(`username`,e.target.value),placeholder:`deploy`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`authentication_d1ff8f98`)}),(0,$.jsxs)(W,{value:x.authMethod,onValueChange:e=>K(`authMethod`,e),children:[(0,$.jsx)(se,{className:`w-full`,children:(0,$.jsx)(V,{})}),(0,$.jsxs)(ce,{children:[(0,$.jsx)(H,{value:`password`,children:u(`password_a621ab60`)}),(0,$.jsx)(H,{value:`private_key`,children:u(`private_key_3ffe935f`)}),(0,$.jsx)(H,{value:`system_ssh_config`,children:u(`use_local_ssh_configuration_0acb0e3d`)})]})]})]}),x.authMethod===`password`?(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`password_a621ab60`)}),(0,$.jsx)(Z,{type:`password`,value:x.password,onChange:e=>K(`password`,e.target.value),placeholder:q?.method===`password`?u(`leave_blank_to_keep_the_existing_password_66c2200e`):void 0})]}):null,x.authMethod===`private_key`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`private_key_file_path_local_4f44a132`)}),(0,$.jsx)(Z,{value:x.privateKeyPath,onChange:e=>K(`privateKeyPath`,e.target.value),placeholder:`~/.ssh/id_ed25519`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`or_paste_a_private_key_pem_5e7cf830`)}),(0,$.jsx)(Ze,{className:`min-h-16 resize-y font-mono text-xs`,value:x.privateKey,onChange:e=>K(`privateKey`,e.target.value),placeholder:q?.method===`private_key`?u(`leave_blank_to_keep_the_existing_private_key_7f685d0b`):`-----BEGIN OPENSSH PRIVATE KEY-----`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`private_key_passphrase_optional_8138fad9`)}),(0,$.jsx)(Z,{type:`password`,value:x.passphrase,onChange:e=>K(`passphrase`,e.target.value),placeholder:q?.method===`private_key`?u(`leave_blank_to_keep_the_existing_passphrase_a50f11c8`):void 0})]})]}):null]}):null,(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border bg-muted/30 p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`deployment_settings_ccbf90f5`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`artifact_path_bamboo_binary_to_upload_a8a61a77`)}),(0,$.jsx)(Z,{value:x.artifactPath,onChange:e=>K(`artifactPath`,e.target.value),placeholder:`/path/to/bamboo-linux-x64`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`remote_directory_1cfa6840`)}),(0,$.jsx)(Z,{value:x.remoteDir,onChange:e=>K(`remoteDir`,e.target.value),placeholder:`~/.bamboo-worker`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`default_role_8a2a6551`)}),(0,$.jsx)(Z,{value:x.defaultRole,onChange:e=>K(`defaultRole`,e.target.value),placeholder:`worker`})]})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`model_c98e118e`)}),(0,$.jsx)(Z,{value:x.model,onChange:e=>K(`model`,e.target.value),placeholder:u(`default_844b8cc8`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`working_directory_3db7b06b`)}),(0,$.jsx)(Z,{value:x.workspace,onChange:e=>K(`workspace`,e.target.value),placeholder:u(`default_844b8cc8`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium`,children:u(`automatic_recovery_d4670a4c`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`redeploy_automatically_when_health_checks_detect_a_disc_46daaed1`)})]}),(0,$.jsx)(Jt,{checked:x.autoRecover,onCheckedChange:e=>K(`autoRecover`,e),"aria-label":u(`automatic_recovery_d4670a4c`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium`,children:u(`enabled_f4f0ead1`)}),(0,$.jsx)(Jt,{checked:x.enabled,onCheckedChange:e=>K(`enabled`,e),"aria-label":u(`enable_node_b7e7cd5a`)})]})]}),C?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:C}):null,(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(Y,{variant:`secondary`,onClick:Me,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{onClick:()=>void Fe(),disabled:T,children:u(T?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}),(0,$.jsx)(Ge,{open:D,onOpenChange:e=>{e||O(!1)},children:(0,$.jsxs)(Ue,{className:`p-5 sm:max-w-2xl`,children:[(0,$.jsxs)(He,{children:[u(`logs_8a81380a`),` `,k?.label??``]}),(0,$.jsx)(`div`,{className:`mt-3 max-h-[50vh] min-h-24 flex-1 overflow-auto rounded-md border bg-muted/30 p-2`,children:N?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):(0,$.jsx)(`pre`,{className:`font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:j})}),(0,$.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,$.jsx)(Y,{variant:`secondary`,onClick:()=>O(!1),children:u(`close_3fd47edc`)}),(0,$.jsx)(Y,{disabled:N,onClick:()=>{k&&ze(k)},children:u(`refresh_aee88743`)})]})]})}),(0,$.jsx)(Ge,{open:ee,onOpenChange:e=>{e||We()},children:(0,$.jsxs)(Ue,{className:`p-5`,children:[(0,$.jsx)(He,{children:u(I?`edit_cluster_28890c2b`:`add_cluster_0a87eec0`)}),(0,$.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-3 overflow-y-auto pr-1`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`name_d44e9b3d`)}),(0,$.jsx)(Z,{value:R,disabled:!!I,onChange:e=>z(e.target.value),placeholder:`gpu-pool`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`description_optional_8b29dbed`)}),(0,$.jsx)(Z,{value:oe,onChange:e=>B(e.target.value),placeholder:u(`purpose_0bef9631`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{className:`text-xs`,children:u(`member_nodes_658ff86e`)}),e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_nodes_yet_add_a_node_first_d769d2c5`)}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>{let t=le.includes(e.id);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Ke(e.id),className:X(`flex w-full items-center gap-2 rounded-md border px-2.5 py-1.5 text-left text-sm transition-colors`,t?`border-primary/50 bg-primary/5`:`hover:bg-accent/50`),children:[(0,$.jsx)(`span`,{className:X(`flex size-4 shrink-0 items-center justify-center rounded border`,t?`border-primary bg-primary text-primary-foreground`:`border-muted-foreground/40`),children:t?(0,$.jsx)(ae,{className:`size-3`}):null}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:ga(e)})]},e.id)})})]})]}),de?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:de}):null,(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(Y,{variant:`secondary`,onClick:We,children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{onClick:()=>void qe(),disabled:he,children:u(he?`saving_ff509c9b`:`save_a3030bf8`)})]})]})})]})}function ya({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`skeleton`,className:X(`bg-accent animate-pulse rounded-md`,e),...t})}function ba(e){return e==null||Number.isNaN(e)?`0`:new Intl.NumberFormat(d(),{notation:`compact`,maximumFractionDigits:1}).format(e)}function xa(e){return e==null||Number.isNaN(e)?`0`:new Intl.NumberFormat(d()).format(e)}function Sa(e){return e==null||Number.isNaN(e)?`0%`:new Intl.NumberFormat(d(),{style:`percent`,minimumFractionDigits:1,maximumFractionDigits:1}).format(e/100)}function Ca(e){if(!e||e<=0)return`-`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return n>=60?`${Math.floor(n/60)}h ${n%60}m`:n>0?`${n}m ${r}s`:`${r}s`}function wa(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(d(),{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function Ta(e){let t=/^\d{4}-(\d{2}-\d{2})$/.exec(e);return t?t[1]:e}function Ea(e){return String(e).padStart(2,`0`)}function Da(e){return`${e.getFullYear()}-${Ea(e.getMonth()+1)}-${Ea(e.getDate())}`}function Oa(){return Da(new Date)}function ka(e,t){let[n,r,i]=e.split(`-`).map(Number),a=new Date(n,(r??1)-1,i??1);return a.setDate(a.getDate()+t),Da(a)}function Aa(e,t){let[n,r,i]=e.split(`-`).map(Number),[a,o,s]=t.split(`-`).map(Number),c=new Date(n,(r??1)-1,i??1),l=new Date(a,(o??1)-1,s??1),u=Math.round((l.getTime()-c.getTime())/864e5);return Math.max(1,u+1)}var ja={summary:null,timeline:[],models:[],usage:null,sessions:[],forwardEndpoints:[],forwardRequests:[],memoryTimeline:[]},Ma=3e4,Na=50,Pa=()=>[u(`overview_a33db573`),u(`trend_9b59e637`),u(`model_distribution_39f1a54a`),u(`usage_breakdown_38f4c70c`),u(`sessions_c980de33`),u(`forward_endpoints_3e1263a7`),u(`forward_requests_549199b5`),u(`memory_trend_73d9cf2f`)];function Fa(e){return e instanceof Error?e.message:String(e)}function Ia(e){o();let[t,n]=(0,Q.useState)(ja),[r,i]=(0,Q.useState)([]),[a,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(0),m=(0,Q.useRef)(!0),h=(0,Q.useRef)(0);(0,Q.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let g=(0,Q.useCallback)(async t=>{if(t?.skipIfBusy&&f.current)return;let r=++p.current;f.current=!0,l(!0);let a={startDate:e.startDate,endDate:e.endDate},o=await Promise.allSettled([Mt.getUnifiedSummary(a),Mt.getUnifiedTimeline({days:e.days,endDate:e.endDate}),Mt.getByModel(a),Mt.getUsageBreakdown(a),Mt.getSessions({...a,limit:20}),Mt.getForwardByEndpoint(a),Mt.getForwardRequests({...a,limit:Na}),Mt.getMemoryTimeline({days:e.days,endDate:e.endDate})]);if(r!==p.current||(f.current=!1,!m.current))return;let[c,u,g,_,v,y,b,x]=o;n(e=>({summary:c.status===`fulfilled`?c.value:e.summary,timeline:u.status===`fulfilled`?u.value:e.timeline,models:g.status===`fulfilled`?g.value:e.models,usage:_.status===`fulfilled`?_.value:e.usage,sessions:v.status===`fulfilled`?v.value:e.sessions,forwardEndpoints:y.status===`fulfilled`?y.value:e.forwardEndpoints,forwardRequests:b.status===`fulfilled`?b.value:e.forwardRequests,memoryTimeline:x.status===`fulfilled`?x.value:e.memoryTimeline})),i(o.flatMap((e,t)=>e.status===`rejected`?[`${Pa()[t]}: ${Fa(e.reason)}`]:[])),h.current=Date.now(),d(h.current),s(!1),l(!1)},[e.startDate,e.endDate,e.days]);return(0,Q.useEffect)(()=>{g();let e=setInterval(()=>{document.visibilityState===`visible`&&g({skipIfBusy:!0})},Ma),t=()=>{document.visibilityState===`visible`&&Date.now()-h.current>Ma&&g()};return document.addEventListener(`visibilitychange`,t),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,t)}},[g]),{data:t,errors:r,initialLoading:a,refreshing:c,lastUpdated:u,refresh:g}}var La=`var(--mx-chat)`,Ra=`var(--mx-fwd)`,za=140,Ba={top:8,right:12,bottom:20,left:40},Va=Ba.top+za+Ba.bottom;function Ha(){o();let e=(0,Q.useRef)(null),[t,n]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&n(t)});return r.observe(t),n(t.clientWidth),()=>r.disconnect()},[]),{ref:e,width:t}}function Ua(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e));for(let n of[1,2,5,10])if(e<=n*t)return n*t;return 10*t}function Wa(e,t){return e.map((e,n)=>`${n===0?`M`:`L`}${e.toFixed(1)} ${t[n].toFixed(1)}`).join(` `)}function Ga(e,t,n){if(e.length===0)return``;let r=Wa(e,t),i=e[e.length-1].toFixed(1),a=e[0].toFixed(1);return`${r} L${i} ${n.toFixed(1)} L${a} ${n.toFixed(1)} Z`}function Ka({points:e}){o();let{ref:t,width:n}=Ha(),[r,i]=(0,Q.useState)(`chart`),[a,s]=(0,Q.useState)(null),c=e.length,l=Math.max(0,n-Ba.left-Ba.right),d=Ba.top+za,f=(0,Q.useMemo)(()=>{if(c===0||l<=0)return null;let t=Ua(e.reduce((e,t)=>Math.max(e,t.chat_tokens,t.forward_tokens),0)),n=e=>Ba.left+(c===1?l/2:e/(c-1)*l),r=e=>Ba.top+za-e/t*za;return{yMax:t,xs:e.map((e,t)=>n(t)),chatYs:e.map(e=>r(e.chat_tokens)),forwardYs:e.map(e=>r(e.forward_tokens))}},[e,c,l]),p=(0,Q.useMemo)(()=>c===0?[]:c<=3?e.map((e,t)=>t):[...new Set([0,Math.floor((c-1)/2),c-1])],[c,e]),m=(e,t)=>{if(!f||c===0)return;let n=e-t.left,r=0,i=1/0;f.xs.forEach((e,t)=>{let a=Math.abs(e-n);a<i&&(i=a,r=t)}),s(r)};if(c===0)return(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_data_yet_497c8569`)});let h=a==null?null:e[a],g=a!=null&&f?f.xs[a]:null,_=g!=null&&n>0&&g>n*.55;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 rounded-full`,style:{background:La}}),u(`session_tokens_17dc5fdb`)]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 rounded-full`,style:{background:Ra}}),`Forward Tokens`]})]}),(0,$.jsx)(`div`,{className:`flex gap-1`,children:[[`chart`,u(`chart_8cb443ab`)],[`table`,u(`table_22d9e7c5`)]].map(([e,t])=>(0,$.jsx)(Y,{size:`sm`,variant:r===e?`secondary`:`ghost`,className:`h-6 px-2 text-xs`,onClick:()=>i(e),children:t},e))})]}),r===`table`?(0,$.jsx)(`div`,{className:`max-h-56 overflow-auto rounded-md border`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[420px] text-xs`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 bg-background text-muted-foreground`,children:(0,$.jsxs)(`tr`,{className:`[&>th]:px-2 [&>th]:py-1.5 [&>th]:font-medium`,children:[(0,$.jsx)(`th`,{className:`text-left`,children:u(`date_70d0c1b3`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`session_tokens_17dc5fdb`)}),(0,$.jsx)(`th`,{className:`text-right`,children:`Forward Tokens`}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`sessions_578c55a3`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`forward_requests_8afb028b`)})]})}),(0,$.jsx)(`tbody`,{children:e.map(e=>(0,$.jsxs)(`tr`,{className:`border-t [&>td]:px-2 [&>td]:py-1`,children:[(0,$.jsx)(`td`,{children:e.date}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.chat_tokens)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.forward_tokens)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.chat_sessions)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.forward_requests)})]},e.date))})]})}):(0,$.jsx)(`div`,{ref:t,className:`relative w-full`,children:n>0&&f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`svg`,{width:n,height:Va,role:`img`,"aria-label":u(`token_trend_chart_5ce8cd83`),tabIndex:0,className:`block outline-none focus-visible:ring-1 focus-visible:ring-ring`,onPointerMove:e=>m(e.clientX,e.currentTarget.getBoundingClientRect()),onPointerLeave:()=>s(null),onFocus:()=>s(e=>e??c-1),onBlur:()=>s(null),onKeyDown:e=>{if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=e.key===`ArrowLeft`?-1:1;s(e=>Math.min(c-1,Math.max(0,(e??c-1)+t)))}},children:[[0,.5,1].map(e=>{let t=Ba.top+za-e*za;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`line`,{x1:Ba.left,x2:n-Ba.right,y1:t,y2:t,stroke:`var(--border)`,strokeWidth:1}),(0,$.jsx)(`text`,{x:Ba.left-6,y:t+3,textAnchor:`end`,fontSize:10,className:`fill-muted-foreground tabular-nums`,children:ba(e*f.yMax)})]},e)}),(0,$.jsx)(`path`,{d:Ga(f.xs,f.chatYs,d),fill:La,fillOpacity:.1}),(0,$.jsx)(`path`,{d:Ga(f.xs,f.forwardYs,d),fill:Ra,fillOpacity:.1}),c>1?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`path`,{d:Wa(f.xs,f.chatYs),fill:`none`,stroke:La,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`}),(0,$.jsx)(`path`,{d:Wa(f.xs,f.forwardYs),fill:`none`,stroke:Ra,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`})]}):null,(0,$.jsx)(`circle`,{cx:f.xs[c-1],cy:f.chatYs[c-1],r:4,fill:La,stroke:`var(--background)`,strokeWidth:2}),(0,$.jsx)(`circle`,{cx:f.xs[c-1],cy:f.forwardYs[c-1],r:4,fill:Ra,stroke:`var(--background)`,strokeWidth:2}),g!=null&&a!=null?(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`line`,{x1:g,x2:g,y1:Ba.top,y2:d,stroke:`var(--border)`,strokeWidth:1}),(0,$.jsx)(`circle`,{cx:g,cy:f.chatYs[a],r:3.5,fill:La,stroke:`var(--background)`,strokeWidth:2}),(0,$.jsx)(`circle`,{cx:g,cy:f.forwardYs[a],r:3.5,fill:Ra,stroke:`var(--background)`,strokeWidth:2})]}):null,(0,$.jsx)(`line`,{x1:Ba.left,x2:n-Ba.right,y1:d,y2:d,stroke:`var(--border)`,strokeWidth:1}),p.map(t=>(0,$.jsx)(`text`,{x:f.xs[t],y:d+14,textAnchor:t===0?`start`:t===c-1?`end`:`middle`,fontSize:10,className:`fill-muted-foreground`,children:Ta(e[t].date)},t))]}),h&&g!=null?(0,$.jsxs)(`div`,{className:X(`pointer-events-none absolute top-1 z-10 rounded-md border bg-popover px-2.5 py-2 text-xs shadow-md`),style:_?{left:g-10,transform:`translateX(-100%)`}:{left:g+10},children:[(0,$.jsx)(`div`,{className:`mb-1 font-medium`,children:h.date}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 shrink-0 rounded-full`,style:{background:La}}),(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:xa(h.chat_tokens)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:u(`session_tokens_17dc5fdb`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 shrink-0 rounded-full`,style:{background:Ra}}),(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:xa(h.forward_tokens)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Forward Tokens`})]}),(0,$.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[xa(h.chat_sessions),` `,u(`sessions_d2a38975`),` `,xa(h.forward_requests),` `,u(`forward_requests_4ec8d920`)]})]}):null]}):(0,$.jsx)(`div`,{style:{height:Va}})})]})}function qa({items:e,color:t=`var(--mx-chat)`,emptyText:n=u(`no_data_yet_497c8569`),formatValue:r=ba}){if(o(),e.length===0)return(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n});let i=e.reduce((e,t)=>Math.max(e,t.value),0);return(0,$.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>(0,$.jsxs)(`li`,{title:`${e.label}: ${e.value.toLocaleString(d())}`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 truncate text-xs`,children:[e.label,e.meta?(0,$.jsx)(`span`,{className:`ml-1.5 text-muted-foreground`,children:e.meta}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums`,children:r(e.value)})]}),(0,$.jsx)(`div`,{className:`mt-1 h-1.5 w-full rounded-full`,style:{background:`color-mix(in srgb, ${t} 14%, transparent)`},children:(0,$.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${i>0?Math.max(e.value/i*100,e.value>0?1.5:0):0}%`,background:t}})})]},e.key))})}var Ja={running:{get label(){return u(`active_dc9591e5`)},dotClass:`bg-[#2a78d6] dark:bg-[#3987e5]`},awaiting_response:{get label(){return u(`awaiting_response_bf0b6179`)},dotClass:`bg-amber-500`},completed:{get label(){return u(`completed_f28461bb`)},dotClass:`bg-emerald-600 dark:bg-emerald-500`},error:{get label(){return u(`errors_01ad2bc5`)},dotClass:`bg-destructive`},cancelled:{get label(){return u(`cancelled_a37778f1`)},dotClass:`bg-muted-foreground`}};function Ya({status:e}){o();let t=Ja[e]??{label:e,dotClass:`bg-muted-foreground`};return(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[(0,$.jsx)(`span`,{className:X(`inline-block size-1.5 shrink-0 rounded-full`,t.dotClass)}),t.label]})}function Xa({sessions:e}){return o(),e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_session_records_yet_8fae1d55`)}):(0,$.jsx)(`div`,{className:`max-h-72 overflow-auto rounded-md border`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[620px] text-xs`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 z-10 bg-background text-muted-foreground`,children:(0,$.jsxs)(`tr`,{className:`[&>th]:px-2 [&>th]:py-1.5 [&>th]:font-medium`,children:[(0,$.jsx)(`th`,{className:`text-left`,children:u(`session_a6328025`)}),(0,$.jsx)(`th`,{className:`text-left`,children:u(`model_c98e118e`)}),(0,$.jsx)(`th`,{className:`text-left`,children:u(`status_6320b4a8`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`round_4890584b`)}),(0,$.jsx)(`th`,{className:`text-right`,children:`Tokens`}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`tool_5ca6730d`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`duration_04a95e06`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`started_6a9906c7`)})]})}),(0,$.jsx)(`tbody`,{children:e.map(e=>(0,$.jsxs)(`tr`,{className:`border-t [&>td]:px-2 [&>td]:py-1.5`,children:[(0,$.jsx)(`td`,{className:`font-mono`,title:e.session_id,children:e.session_id.slice(0,8)}),(0,$.jsx)(`td`,{className:`max-w-40 truncate`,title:e.model,children:e.model||`-`}),(0,$.jsx)(`td`,{children:(0,$.jsx)(Ya,{status:e.status})}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.total_rounds)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,title:xa(e.total_token_usage.total_tokens),children:ba(e.total_token_usage.total_tokens)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.tool_call_count)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:Ca(e.duration_ms)}),(0,$.jsx)(`td`,{className:`whitespace-nowrap text-right tabular-nums text-muted-foreground`,children:wa(e.started_at)})]},e.session_id))})]})})}var Za=5;function Qa({usage:e}){let t=a(),n=(0,Q.useMemo)(()=>{let n=e.top_core_tools.slice(0,Za).map(e=>({key:`core:${e.name}`,category:t(`core_tools_a833e5af`),label:e.name,count:e.count})),r=e.top_skills.slice(0,Za).map(e=>({key:`skill:${e.skill_id}`,category:t(`skills_99aea2f9`),label:e.skill_id,count:e.count})),i=e.top_mcp_tools.slice(0,Za).map(e=>({key:`mcp:${e.alias}`,category:`MCP`,label:e.tool_name,detail:e.server_id,count:e.count}));return[...n,...r,...i]},[e,t]),r=n.reduce((e,t)=>Math.max(e,t.count),0);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[{label:t(`total_tool_calls_422aab04`),value:e.total_tool_calls},{label:t(`core_tools_a833e5af`),value:e.core_tool_calls},{label:t(`skill_loads_a0e4cc4e`),value:e.skill_load_calls},{label:t(`mcp_calls_c237aee5`),value:e.mcp_calls}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border p-2 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold`,title:xa(e.value),children:ba(e.value)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label})]},e.label))}),n.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`no_tool_skill_or_mcp_usage_records_in_this_range_47e6bd78`)}):(0,$.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-md border`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[440px] text-xs`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 z-10 bg-background text-muted-foreground`,children:(0,$.jsxs)(`tr`,{className:`[&>th]:px-2 [&>th]:py-1.5 [&>th]:font-medium`,children:[(0,$.jsx)(`th`,{className:`text-left`,children:t(`category_0d12cbd6`)}),(0,$.jsx)(`th`,{className:`text-left`,children:t(`name_d44e9b3d`)}),(0,$.jsx)(`th`,{className:`w-24 text-right`,children:t(`count_05c518eb`)}),(0,$.jsx)(`th`,{className:`w-28 text-left`,children:t(`share_cc87b27b`)})]})}),(0,$.jsx)(`tbody`,{children:n.map(e=>(0,$.jsxs)(`tr`,{className:`border-t [&>td]:px-2 [&>td]:py-1.5`,children:[(0,$.jsx)(`td`,{children:(0,$.jsx)(U,{variant:`outline`,className:`px-1.5 py-0 text-[10px] font-normal`,children:e.category})}),(0,$.jsxs)(`td`,{className:`max-w-48 truncate`,title:e.detail?`${e.label} · ${e.detail}`:e.label,children:[e.label,e.detail?(0,$.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`(`,e.detail,`)`]}):null]}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.count)}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`div`,{className:`h-1.5 w-full rounded-full`,style:{background:`color-mix(in srgb, var(--mx-chat) 14%, transparent)`},children:(0,$.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${r>0?Math.max(e.count/r*100,1.5):0}%`,background:`var(--mx-chat)`}})})})]},e.key))})]})})]})}var $a=`var(--mx-ok)`,eo=`var(--destructive)`;function to(e){return e.split(`.`).pop()||e}function no({endpoints:e}){if(o(),e.length===0)return(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_forward_requests_in_this_range_78b60c7c`)});let t=[...e].sort((e,t)=>t.requests-e.requests),n=t.reduce((e,t)=>Math.max(e,t.requests),0);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 rounded-full`,style:{background:$a}}),u(`successful_053461ce`)]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 rounded-full`,style:{background:eo}}),u(`failed_28384d7a`)]})]}),(0,$.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>{let t=n>0?e.successful/n*100:0,r=n>0?e.failed/n*100:0;return(0,$.jsxs)(`li`,{title:u(`requests_successful_failed_3994db44`,{v0:e.endpoint,v1:xa(e.requests),v2:xa(e.successful),v3:xa(e.failed)}),children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 truncate text-xs`,children:[to(e.endpoint),(0,$.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[u(`successful_053461ce`),` `,ba(e.successful),` `,u(`failed_89661a55`),` `,ba(e.failed),e.avg_duration_ms!=null&&e.avg_duration_ms>0?u(`average_847b8976`,{v0:Ca(e.avg_duration_ms)}):``]})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums`,children:ba(e.requests)})]}),(0,$.jsxs)(`div`,{className:`mt-1 flex h-1.5 w-full overflow-hidden rounded-full`,style:{background:`color-mix(in srgb, ${$a} 14%, transparent)`},children:[(0,$.jsx)(`div`,{className:`h-full`,style:{width:`${Math.max(t,e.successful>0?1.5:0)}%`,background:$a}}),(0,$.jsx)(`div`,{className:`h-full`,style:{width:`${Math.max(r,e.failed>0?1.5:0)}%`,background:eo}})]})]},e.endpoint)})})]})}var ro={pending:{get label(){return u(`active_dc9591e5`)},dotClass:`bg-[var(--mx-chat)]`},success:{get label(){return u(`successful_053461ce`)},dotClass:`bg-[var(--mx-ok)]`},error:{get label(){return u(`failed_28384d7a`)},dotClass:`bg-destructive`}};function io({status:e,statusCode:t}){if(o(),!e)return(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`-`});let n=ro[e]??{label:e,dotClass:`bg-muted-foreground`};return(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[(0,$.jsx)(`span`,{className:X(`inline-block size-1.5 shrink-0 rounded-full`,n.dotClass)}),n.label,t==null?null:(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t,`)`]})]})}function ao(e){return e.split(`.`).pop()||e}function oo({requests:e}){return o(),e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_forward_request_records_in_this_range_0ddae944`)}):(0,$.jsx)(`div`,{className:`max-h-72 overflow-auto rounded-md border`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[720px] text-xs`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 z-10 bg-background text-muted-foreground`,children:(0,$.jsxs)(`tr`,{className:`[&>th]:px-2 [&>th]:py-1.5 [&>th]:font-medium`,children:[(0,$.jsx)(`th`,{className:`text-left`,children:u(`requests_393e1241`)}),(0,$.jsx)(`th`,{className:`text-left`,children:u(`endpoint_52fff168`)}),(0,$.jsx)(`th`,{className:`text-left`,children:u(`model_c98e118e`)}),(0,$.jsx)(`th`,{className:`text-left`,children:u(`type_ba40014f`)}),(0,$.jsx)(`th`,{className:`text-left`,children:u(`status_6320b4a8`)}),(0,$.jsx)(`th`,{className:`text-right`,children:`Tokens`}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`duration_e77e3d58`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`started_6a9906c7`)}),(0,$.jsx)(`th`,{className:`text-left`,children:u(`error_0bc1fb72`)})]})}),(0,$.jsx)(`tbody`,{children:e.map(e=>(0,$.jsxs)(`tr`,{className:`border-t [&>td]:px-2 [&>td]:py-1.5`,children:[(0,$.jsx)(`td`,{className:`font-mono`,title:e.forward_id,children:e.forward_id.slice(0,8)}),(0,$.jsx)(`td`,{title:e.endpoint,children:(0,$.jsx)(U,{variant:`outline`,className:`px-1.5 py-0 text-[10px] font-normal`,children:ao(e.endpoint)})}),(0,$.jsx)(`td`,{className:`max-w-40 truncate`,title:e.model,children:e.model||`-`}),(0,$.jsx)(`td`,{className:`whitespace-nowrap`,children:e.is_stream?u(`stream_62ebdef8`):u(`sync_dcfe516d`)}),(0,$.jsx)(`td`,{children:(0,$.jsx)(io,{status:e.status,statusCode:e.status_code})}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,title:e.token_usage?xa(e.token_usage.total_tokens):void 0,children:e.token_usage?ba(e.token_usage.total_tokens):`-`}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:Ca(e.duration_ms)}),(0,$.jsx)(`td`,{className:`whitespace-nowrap text-right tabular-nums text-muted-foreground`,children:wa(e.started_at)}),(0,$.jsx)(`td`,{className:`max-w-48 truncate text-destructive`,title:e.error??void 0,children:e.error||(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`-`})})]},e.forward_id))})]})})}var so={message_count_mismatch:`message_count_e78985bc`,last_message_id_mismatch:`last_message_208b7165`,pending_question_mismatch:`questions_awaiting_response_61c1d336`,message_count:`message_count_e78985bc`,last_message_id:`last_message_208b7165`,pending_question:`questions_awaiting_response_61c1d336`};function co(e,t){return so[e]?u(so[e],{lng:t}):e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function lo({breakdown:e}){let t=o();return(0,$.jsx)(qa,{items:(0,Q.useMemo)(()=>Object.entries(e??{}).map(([e,n])=>({key:e,label:co(e,t),value:n})).sort((e,t)=>t.value-e.value),[e,t]),color:`var(--destructive)`,emptyText:u(`no_sync_mismatch_records_in_this_range_c3dd8efd`)})}var uo=`var(--mx-chat)`,fo=[{key:`total_memories`,get label(){return u(`total_memories_cfd0f732`)},color:uo},{key:`created_memories`,get label(){return u(`created_memories_ec5500c1`)},color:`var(--mx-fwd)`},{key:`updated_memories`,get label(){return u(`updated_memories_2f282ad5`)},color:`var(--mx-mem)`}],po=140,mo={top:8,right:12,bottom:20,left:40},ho=mo.top+po+mo.bottom;function go(){o();let e=(0,Q.useRef)(null),[t,n]=(0,Q.useState)(0);return{ref:(0,Q.useCallback)(t=>{if(e.current?.disconnect(),e.current=null,!t)return;let r=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&n(t)});r.observe(t),e.current=r,n(t.clientWidth)},[]),width:t}}function _o(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e));for(let n of[1,2,5,10])if(e<=n*t)return n*t;return 10*t}function vo(e,t){return e.map((e,n)=>`${n===0?`M`:`L`}${e.toFixed(1)} ${t[n].toFixed(1)}`).join(` `)}function yo(e,t,n){if(e.length===0)return``;let r=vo(e,t),i=e[e.length-1].toFixed(1),a=e[0].toFixed(1);return`${r} L${i} ${n.toFixed(1)} L${a} ${n.toFixed(1)} Z`}function bo({points:e}){o();let{ref:t,width:n}=go(),[r,i]=(0,Q.useState)(`chart`),[a,s]=(0,Q.useState)(null),c=e.length,l=Math.max(0,n-mo.left-mo.right),d=mo.top+po,f=(0,Q.useMemo)(()=>{if(c===0||l<=0)return null;let t=_o(e.reduce((e,t)=>Math.max(e,t.total_memories,t.created_memories,t.updated_memories),0)),n=e=>mo.left+(c===1?l/2:e/(c-1)*l),r=e=>mo.top+po-e/t*po;return{yMax:t,xs:e.map((e,t)=>n(t)),ysBySeries:fo.map(t=>e.map(e=>r(e[t.key])))}},[e,c,l]),p=(0,Q.useMemo)(()=>c===0?[]:c<=3?e.map((e,t)=>t):[...new Set([0,Math.floor((c-1)/2),c-1])],[c,e]),m=(e,t)=>{if(!f||c===0)return;let n=e-t.left,r=0,i=1/0;f.xs.forEach((e,t)=>{let a=Math.abs(e-n);a<i&&(i=a,r=t)}),s(r)};if(c===0)return(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_memory_trend_available_bae93929`)});let h=a==null?null:e[a],g=a!=null&&f?f.xs[a]:null,_=g!=null&&n>0&&g>n*.55;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:fo.map(e=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 rounded-full`,style:{background:e.color}}),e.label]},e.key))}),(0,$.jsx)(`div`,{className:`flex gap-1`,children:[[`chart`,u(`chart_8cb443ab`)],[`table`,u(`table_22d9e7c5`)]].map(([e,t])=>(0,$.jsx)(Y,{size:`sm`,variant:r===e?`secondary`:`ghost`,className:`h-6 px-2 text-xs`,onClick:()=>i(e),children:t},e))})]}),r===`table`?(0,$.jsx)(`div`,{className:`max-h-56 overflow-auto rounded-md border`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[420px] text-xs`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 bg-background text-muted-foreground`,children:(0,$.jsxs)(`tr`,{className:`[&>th]:px-2 [&>th]:py-1.5 [&>th]:font-medium`,children:[(0,$.jsx)(`th`,{className:`text-left`,children:u(`date_70d0c1b3`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`total_memories_cfd0f732`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`created_memories_ec5500c1`)}),(0,$.jsx)(`th`,{className:`text-right`,children:u(`updated_memories_2f282ad5`)})]})}),(0,$.jsx)(`tbody`,{children:e.map(e=>(0,$.jsxs)(`tr`,{className:`border-t [&>td]:px-2 [&>td]:py-1`,children:[(0,$.jsx)(`td`,{children:e.label}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.total_memories)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.created_memories)}),(0,$.jsx)(`td`,{className:`text-right tabular-nums`,children:xa(e.updated_memories)})]},e.label))})]})}):(0,$.jsx)(`div`,{ref:t,className:`relative w-full`,children:n>0&&f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`svg`,{width:n,height:ho,role:`img`,"aria-label":u(`memory_trend_chart_f317b7a3`),tabIndex:0,className:`block outline-none focus-visible:ring-1 focus-visible:ring-ring`,onPointerMove:e=>m(e.clientX,e.currentTarget.getBoundingClientRect()),onPointerLeave:()=>s(null),onFocus:()=>s(e=>e??c-1),onBlur:()=>s(null),onKeyDown:e=>{if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=e.key===`ArrowLeft`?-1:1;s(e=>Math.min(c-1,Math.max(0,(e??c-1)+t)))}},children:[[0,.5,1].map(e=>{let t=mo.top+po-e*po;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`line`,{x1:mo.left,x2:n-mo.right,y1:t,y2:t,stroke:`var(--border)`,strokeWidth:1}),(0,$.jsx)(`text`,{x:mo.left-6,y:t+3,textAnchor:`end`,fontSize:10,className:`fill-muted-foreground tabular-nums`,children:ba(e*f.yMax)})]},e)}),(0,$.jsx)(`path`,{d:yo(f.xs,f.ysBySeries[0],d),fill:uo,fillOpacity:.1}),c>1?fo.map((e,t)=>(0,$.jsx)(`path`,{d:vo(f.xs,f.ysBySeries[t]),fill:`none`,stroke:e.color,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`},e.key)):null,fo.map((e,t)=>(0,$.jsx)(`circle`,{cx:f.xs[c-1],cy:f.ysBySeries[t][c-1],r:4,fill:e.color,stroke:`var(--background)`,strokeWidth:2},e.key)),g!=null&&a!=null?(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`line`,{x1:g,x2:g,y1:mo.top,y2:d,stroke:`var(--border)`,strokeWidth:1}),fo.map((e,t)=>(0,$.jsx)(`circle`,{cx:g,cy:f.ysBySeries[t][a],r:3.5,fill:e.color,stroke:`var(--background)`,strokeWidth:2},e.key))]}):null,(0,$.jsx)(`line`,{x1:mo.left,x2:n-mo.right,y1:d,y2:d,stroke:`var(--border)`,strokeWidth:1}),p.map(t=>(0,$.jsx)(`text`,{x:f.xs[t],y:d+14,textAnchor:t===0?`start`:t===c-1?`end`:`middle`,fontSize:10,className:`fill-muted-foreground`,children:Ta(e[t].label)},t))]}),h&&g!=null?(0,$.jsxs)(`div`,{className:X(`pointer-events-none absolute top-1 z-10 rounded-md border bg-popover px-2.5 py-2 text-xs shadow-md`),style:_?{left:g-10,transform:`translateX(-100%)`}:{left:g+10},children:[(0,$.jsx)(`div`,{className:`mb-1 font-medium`,children:h.label}),fo.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-3 shrink-0 rounded-full`,style:{background:e.color}}),(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:xa(h[e.key])}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.label})]},e.key))]}):null]}):(0,$.jsx)(`div`,{style:{height:ho}})})]})}var xo=[{id:`today`,get label(){return u(`today_d5f5a7a0`)},days:1},{id:`7d`,get label(){return u(`7_days_38eefacb`)},days:7},{id:`30d`,get label(){return u(`30_days_84ad2952`)},days:30}],So=`.lnx-metrics{--mx-chat:#2a78d6;--mx-fwd:#1baf7a;--mx-mem:#8a5cd8;--mx-ok:#059669}.dark .lnx-metrics{--mx-chat:#3987e5;--mx-fwd:#199e70;--mx-mem:#9a74e3;--mx-ok:#10b981}`;function Co({label:e,value:t,sub:n,title:r}){return o(),(0,$.jsxs)(`div`,{className:`rounded-lg border p-2.5`,title:r,children:[(0,$.jsx)(`div`,{className:`text-lg font-semibold leading-tight`,children:t}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),n?(0,$.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground/80`,children:n}):null]})}function wo(){let e=a(),[t,n]=(0,Q.useState)(`7d`),[r,i]=(0,Q.useState)(()=>ka(Oa(),-6)),[o,s]=(0,Q.useState)(()=>Oa()),c=(e,t)=>{let r=Oa();n(e),i(ka(r,-(t-1))),s(r)},l=(0,Q.useMemo)(()=>r&&o?Math.min(Aa(r,o),365):r?Math.min(Aa(r,Oa()),365):7,[r,o]),{data:u,errors:f,initialLoading:p,refreshing:m,lastUpdated:h,refresh:g}=Ia((0,Q.useMemo)(()=>({startDate:r||void 0,endDate:o||void 0,days:l}),[r,o,l])),_=u.summary,v=(0,Q.useMemo)(()=>{if(!_)return[];let{chat:t,forward:n,combined:r,memory:i}=_;return[{label:e(`total_requests_ddde16f8`),value:ba(r.total_requests),sub:e(`sessions_forward_292dc01e`,{v0:ba(t.total_sessions),v1:ba(n.total_requests)}),title:xa(r.total_requests)},{label:e(`total_tokens_660bf040`),value:ba(r.total_tokens),title:xa(r.total_tokens)},{label:e(`success_rate_47d2ca13`),value:Sa(r.success_rate),sub:e(`failed_canceled_e9608c9f`,{v0:ba(r.total_errors)})},{label:e(`active_sessions_1bd6d27c`),value:ba(t.active_sessions),sub:e(`completed_e0dae796`,{v0:ba(t.completed_sessions??0)}),title:xa(t.active_sessions)},{label:e(`tool_calls_a8ca3c13`),value:ba(t.total_tool_calls),title:xa(t.total_tool_calls)},{label:e(`tokens_saved_by_compression_78843369`),value:ba(t.total_tokens_saved??0),sub:e(`compression_events_400e2333`,{v0:ba(t.total_compression_events??0)}),title:xa(t.total_tokens_saved??0)},{label:e(`forward_requests_549199b5`),value:ba(n.total_requests),sub:e(`failed_233d8a20`,{v0:ba(n.failed_requests)}),title:xa(n.total_requests)},{label:e(`memory_entries_1c21bf72`),value:ba(i.total_memories),sub:e(`pending_cleanup_7af3da03`,{v0:ba(i.stale_candidate_count)}),title:xa(i.total_memories)}]},[_,e]),y=(0,Q.useMemo)(()=>{let t=[...u.models].sort((e,t)=>t.tokens.total_tokens-e.tokens.total_tokens),n=t.slice(0,8),r=t.slice(8),i=n.map(t=>({key:t.model,label:t.model,value:t.tokens.total_tokens,meta:e(`sessions_4e5cc041`,{v0:xa(t.sessions),count:t.sessions})}));return r.length>0&&i.push({key:`__other__`,label:e(`other_models_dfe4953e`,{v0:r.length,count:r.length}),value:r.reduce((e,t)=>e+t.tokens.total_tokens,0),meta:e(`sessions_4e5cc041`,{v0:xa(r.reduce((e,t)=>e+t.sessions,0)),count:r.reduce((e,t)=>e+t.sessions,0)})}),i},[u.models,e]);return(0,$.jsxs)(`div`,{className:`lnx-metrics space-y-4`,children:[(0,$.jsx)(`style`,{children:So}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[xo.map(e=>(0,$.jsx)(Y,{size:`sm`,variant:t===e.id?`default`:`secondary`,className:`h-7 px-2.5 text-xs`,onClick:()=>c(e.id,e.days),children:e.label},e.id)),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Z,{type:`date`,value:r,max:o||void 0,onChange:e=>{i(e.target.value),n(`custom`)},"aria-label":e(`start_date_76050649`),className:`h-7 w-[8.75rem] px-2 text-xs`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`to_65edbf9f`)}),(0,$.jsx)(Z,{type:`date`,value:o,min:r||void 0,onChange:e=>{s(e.target.value),n(`custom`)},"aria-label":e(`end_date_895cd52f`),className:`h-7 w-[8.75rem] px-2 text-xs`})]}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>void g(),disabled:m,"aria-label":e(`refresh_aee88743`),children:(0,$.jsx)(pe,{className:X(`size-3.5`,m&&`animate-spin`)})})]}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`refreshes_every_30_seconds_while_visible_e02cda1f`),` `,h?e(`last_updated_5d5c7605`,{v0:new Date(h).toLocaleTimeString(d(),{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}):``]})]}),f.length>0?(0,$.jsxs)(`div`,{className:`space-y-1 rounded-lg border border-destructive/50 bg-destructive/10 p-2.5 text-xs text-destructive`,children:[f.map(t=>(0,$.jsxs)(`div`,{children:[e(`could_not_load_ca2335da`),` `,t]},t)),(0,$.jsx)(`button`,{className:`underline underline-offset-2`,onClick:()=>void g(),children:e(`retry_b8784c8d`)})]}):null,(0,$.jsxs)(`div`,{className:X(`space-y-4 transition-opacity duration-300`,m&&!p&&`opacity-60`),children:[(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:e(`overview_a33db573`)}),p?(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:Array.from({length:8}).map((e,t)=>(0,$.jsx)(ya,{className:`h-16 rounded-lg`},t))}):_?(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:v.map(e=>(0,$.jsx)(Co,{...e},e.label))}):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`no_data_yet_497c8569`)})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:[e(`token_trend_last_1cbf2e73`),` `,l,` `,e(`days_6ef2fddf`)]}),p?(0,$.jsx)(ya,{className:`h-40 rounded-lg`}):(0,$.jsx)(Ka,{points:u.timeline})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:e(`model_distribution_by_tokens_f7a6674f`)}),p?(0,$.jsx)(ya,{className:`h-24 rounded-lg`}):(0,$.jsx)(qa,{items:y,emptyText:e(`no_model_usage_in_this_range_2b5f1863`)})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:e(`usage_breakdown_38f4c70c`)}),p?(0,$.jsx)(ya,{className:`h-32 rounded-lg`}):u.usage?(0,$.jsx)(Qa,{usage:u.usage}):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`no_data_yet_497c8569`)})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:e(`forward_endpoint_distribution_by_requests_afb001e2`)}),p?(0,$.jsx)(ya,{className:`h-24 rounded-lg`}):(0,$.jsx)(no,{endpoints:u.forwardEndpoints})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:e(`sync_mismatch_distribution_by_reason_4fc1c9b5`)}),p?(0,$.jsx)(ya,{className:`h-24 rounded-lg`}):(0,$.jsx)(lo,{breakdown:_?.chat.sync_mismatch_breakdown})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:[e(`memory_trend_last_26d2aa43`),` `,l,` `,e(`days_6ef2fddf`)]}),p?(0,$.jsx)(ya,{className:`h-40 rounded-lg`}):(0,$.jsx)(bo,{points:u.memoryTimeline})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:e(`recent_sessions_up_to_20_77b385e9`)}),p?(0,$.jsx)(ya,{className:`h-40 rounded-lg`}):(0,$.jsx)(Xa,{sessions:u.sessions})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:e(`recent_forward_requests_up_to_50_f23834e1`)}),p?(0,$.jsx)(ya,{className:`h-40 rounded-lg`}):(0,$.jsx)(oo,{requests:u.forwardRequests})]})]})]})}function To(){o();let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!0),[i,a]=(0,Q.useState)(null),s=(0,Q.useRef)(null),c=(0,Q.useCallback)(async()=>{r(!0),a(null);try{let e=await J.get(`bamboo/config`);s.current=Array.isArray(e.model_limits)?e.model_limits:[],t(e)}catch(e){a(q(e))}finally{r(!1)}},[]);return(0,Q.useEffect)(()=>{c()},[c]),{config:e,loading:n,loadError:i,reload:c,saveSection:(0,Q.useCallback)(async e=>{let n={...e};n.model_limits===void 0&&s.current!==null&&(n.model_limits=s.current);let r=await K.validateBambooConfigPatch(n);if(!r.valid){let e=Object.values(r.errors??{}).flat().filter(Boolean)[0];throw Error(e?.message||u(`configuration_validation_failed_ed3442af`))}let i=await K.setBambooConfig(n);return s.current=Array.isArray(i.model_limits)?i.model_limits:[],t(i),i},[])}}function Eo({msg:e}){return e?(0,$.jsx)(`p`,{className:X(`text-xs`,e.kind===`error`?`text-destructive`:`text-muted-foreground`),children:e.text}):null}function Do({config:e,saveSection:t}){o();let[n,r]=(0,Q.useState)(()=>e.http_proxy??``),[i,a]=(0,Q.useState)(()=>e.https_proxy??``),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null);return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`agent_5e84ea61`)}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`http_proxy_fe51a8c8`)}),(0,$.jsx)(Z,{placeholder:`http://proxy.example.com:8080`,value:n,onChange:e=>r(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`https_proxy_67047f31`)}),(0,$.jsx)(Z,{placeholder:`https://proxy.example.com:8080`,value:i,onChange:e=>a(e.target.value)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(Eo,{msg:l}),(0,$.jsx)(Y,{size:`sm`,className:`ml-auto`,onClick:async()=>{c(!0),d(null);try{await t({http_proxy:n.trim(),https_proxy:i.trim()}),d({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){d({kind:`error`,text:q(e)})}finally{c(!1)}},disabled:s,children:u(s?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}var Oo=e=>{let t=e.context_management?.strategy;return t===`summary`||t===`message_summary`||t===`retrieval_window`?t:null},ko=e=>Oo(e)??`summary`,Ao=[{value:`summary`,label:`context_full_summary_label`,description:`context_full_summary_description`,unconfirmed:`the_backend_has_not_confirmed_the_summary_policy_it_is__a1931a8d`},{value:`message_summary`,label:`context_message_summary_label`,description:`context_message_summary_description`,unconfirmed:`context_message_summary_unconfirmed`},{value:`retrieval_window`,label:`context_retrieval_window_label`,description:`context_retrieval_window_description`,unconfirmed:`the_backend_has_not_confirmed_the_retrieval_window_poli_f71a7519`}];function jo({config:e,saveSection:t}){o();let n=(0,Q.useId)(),[r,i]=(0,Q.useState)(()=>ko(e)),[a,s]=(0,Q.useState)(()=>ko(e)),[c,l]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),p=r!==a;return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`context_management_29dde6e6`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":u(`context_management_29dde6e6`),className:`space-y-2`,children:Ao.map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 ${r===e.value?`border-primary/40 bg-primary/5`:`border-border`}`,children:[(0,$.jsx)(`input`,{type:`radio`,name:n,value:e.value,checked:r===e.value,disabled:c,"aria-labelledby":`${n}-${e.value}-label`,"aria-describedby":`${n}-${e.value}-description`,className:`mt-0.5 size-4 shrink-0`,style:{accentColor:`var(--primary)`},onChange:()=>{i(e.value),f(null)}}),(0,$.jsxs)(`span`,{className:`min-w-0 space-y-1`,children:[(0,$.jsx)(`span`,{id:`${n}-${e.value}-label`,className:`block text-sm`,children:u(e.label)}),(0,$.jsx)(`span`,{id:`${n}-${e.value}-description`,className:`block text-xs leading-relaxed text-muted-foreground`,children:u(e.description)})]})]},e.value))}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:u(`no_restart_is_needed_changes_apply_to_the_next_run_acti_24de7c6e`)}),r===`retrieval_window`?(0,$.jsx)(`p`,{className:`rounded-md bg-muted px-2 py-1.5 text-xs leading-relaxed text-muted-foreground`,children:u(`sessions_with_existing_summaries_are_not_converted_auto_d1b0f8c0`)}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(Eo,{msg:d}),(0,$.jsx)(Y,{size:`sm`,className:`ml-auto`,onClick:async()=>{l(!0),f(null);try{let e=r,n=await t(e===`retrieval_window`?{context_management:{strategy:`retrieval_window`,retrieval_window:{history_tool_required:!0,fallback_strategy:`none`}}}:{context_management:{strategy:e}}),a=n.context_management?.strategy===void 0?`summary`:Oo(n);if(a!==e){let t=Ao.find(({value:t})=>t===e);throw Error(u(t.unconfirmed))}i(a),s(a),f({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){f({kind:`error`,text:q(e)})}finally{l(!1)}},disabled:c||!p,children:u(c?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}var Mo=1800;function No({config:e,saveSection:t}){o();let[n,r]=(0,Q.useState)(()=>e.memory?.auto_dream_enabled??!0),[i,a]=(0,Q.useState)(()=>String(e.memory?.auto_dream_interval_secs??Mo)),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null);return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`memory_7a6335b3`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`automatic_organization_auto_dream_1e2006e6`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`organize_session_memory_periodically_in_the_background_95c196c4`)})]}),(0,$.jsx)(Jt,{checked:n,onCheckedChange:r})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`organization_interval_seconds_0a821075`)}),(0,$.jsx)(Z,{className:`w-28 text-right`,inputMode:`numeric`,placeholder:String(Mo),value:i,onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(Eo,{msg:l}),(0,$.jsx)(Y,{size:`sm`,className:`ml-auto`,onClick:async()=>{let e=Number(i);if(!Number.isInteger(e)||e<60){d({kind:`error`,text:u(`interval_must_be_an_integer_of_at_least_60_seconds_2e4fa5c6`)});return}c(!0),d(null);try{await t({memory:{auto_dream_enabled:n,auto_dream_interval_secs:e}}),d({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){d({kind:`error`,text:q(e)})}finally{c(!1)}},disabled:s,children:u(s?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}function Po({config:e,saveSection:t}){o();let[n,r]=(0,Q.useState)(()=>{let t=e.subagents?.max_concurrent;return typeof t==`number`?String(t):``}),[i,a]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`sub_agent_acd37b4c`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`maximum_concurrency_dd9fd5ce`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`maximum_simultaneous_subagent_processes_leave_blank_for_c6efded8`)})]}),(0,$.jsx)(Z,{className:`w-24 text-right`,inputMode:`numeric`,placeholder:`8`,value:n,onChange:e=>r(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(Eo,{msg:s}),(0,$.jsx)(Y,{size:`sm`,className:`ml-auto`,onClick:async()=>{let e=n.trim(),r=null;if(e){let t=Number(e);if(!Number.isInteger(t)||t<1){c({kind:`error`,text:u(`concurrency_must_be_an_integer_of_at_least_1_9240ee0f`)});return}r=t}a(!0),c(null);try{await t({subagents:{max_concurrent:r}}),c({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){c({kind:`error`,text:q(e)})}finally{a(!1)}},disabled:i,children:u(i?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}var Fo=e=>[...new Set(e.map(e=>e.trim()).filter(Boolean))].sort();function Io({config:e,saveSection:t}){o();let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(()=>Fo((e.tools?.disabled??[]).filter(e=>typeof e==`string`))),[s,c]=(0,Q.useState)(i),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),g=()=>{h(null),J.get(`bamboo/tools`).then(e=>r(Fo(e.tools??[]))).catch(e=>h(q(e)))};(0,Q.useEffect)(g,[]);let _=(0,Q.useMemo)(()=>Fo([...n,...i]),[n,i]),v=(0,Q.useMemo)(()=>new Set(i),[i]),y=JSON.stringify(i)!==JSON.stringify(s),b=(e,t)=>{a(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),Fo([...r])})};return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`tool_5ca6730d`)}),(0,$.jsx)(`button`,{onClick:g,"aria-label":u(`reload_tool_list_979c8a01`),className:`rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(pe,{className:`size-3.5`})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`disabled_tools_are_removed_globally_from_models_availab_566d0b52`)}),m?(0,$.jsxs)(`p`,{className:`text-xs text-destructive`,children:[u(`could_not_load_tool_list_875327bd`),m]}):null,_.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_tools_yet_dae2b2c5`)}):(0,$.jsx)(`ul`,{className:`max-h-56 space-y-1.5 overflow-y-auto pr-1`,children:_.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`code`,{className:`truncate font-mono text-xs`,children:e}),(0,$.jsx)(Jt,{checked:!v.has(e),onCheckedChange:t=>b(e,t),"aria-label":e})]},e))}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(Eo,{msg:f}),(0,$.jsx)(Y,{size:`sm`,className:`ml-auto`,onClick:async()=>{d(!0),p(null);try{await t({tools:{disabled:i}}),c(i),p({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){p({kind:`error`,text:q(e)})}finally{d(!1)}},disabled:l||!y,children:u(l?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}function Lo({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=u(`confirm_36f33ada`),destructive:a=!0,busy:s=!1,error:c,onConfirm:l}){return o(),(0,$.jsx)(Ge,{open:e,onOpenChange:e=>s?void 0:t(e),children:(0,$.jsxs)(Ue,{className:`gap-0 p-4 sm:max-w-sm`,children:[(0,$.jsx)(He,{children:n}),(0,$.jsx)(We,{className:`mt-2 leading-relaxed`,children:r}),c?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:c}):null,(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,disabled:s,onClick:()=>t(!1),children:u(`cancel_2cd0f3be`)}),(0,$.jsx)(Y,{size:`sm`,variant:a?`destructive`:`default`,disabled:s,onClick:l,children:s?u(`processing_d3d21191`):i})]})]})})}function Ro({saveSection:e,configReady:t}){o();let[n,r]=(0,Q.useState)(!0),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),O=s&&!l,k=(0,Q.useCallback)(async()=>{r(!0),a(null);try{let e=await K.getAccessStatus();c(e.password_enabled),d(e.local_bypass)}catch(e){a(q(e))}finally{r(!1)}},[]);(0,Q.useEffect)(()=>{k()},[k]);let A=async()=>{let e=m.trim();if(e.length<4){x({kind:`error`,text:u(`new_password_must_be_at_least_4_characters_94479073`)});return}if(e!==g.trim()){x({kind:`error`,text:u(`the_passwords_do_not_match_58807745`)});return}if(O&&!f.trim()){x({kind:`error`,text:u(`please_enter_the_current_password_f1790d33`)});return}y(!0),x(null);try{await K.updateAccessPassword({current_password:f.trim()||void 0,new_password:e}),p(``),h(``),_(``),x({kind:`ok`,text:u(s?`password_updated_326400c7`:`password_enabled_750d3be9`)}),await k()}catch(e){x({kind:`error`,text:q(e)})}finally{y(!1)}},j=async()=>{T(!0),D(null);try{await e({access_control:{password_enabled:!1}}),C(!1),x({kind:`ok`,text:u(`access_password_disabled_44121148`)}),await k()}catch(e){D(q(e))}finally{T(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`access_password_f4f712d5`)}),n?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)}):i?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-destructive`,children:[u(`could_not_load_status_8e9b5bd3`),i]}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>void k(),children:u(`retry_b8784c8d`)})]}):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(s?l?`enabled_password_entry_is_not_required_for_local_or_lan_3daa946f`:`enabled_a_password_is_required_for_remote_access_65f39105`:`disabled_remote_access_does_not_require_a_password_sett_1458bac4`)}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[O?(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`current_password_a114cfb6`)}),(0,$.jsx)(Z,{type:`password`,autoComplete:`current-password`,value:f,onChange:e=>p(e.target.value)})]}):null,(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(s?`new_password_at_least_4_characters_d91d6a45`:`set_password_at_least_4_characters_51a6ae54`)}),(0,$.jsx)(Z,{type:`password`,autoComplete:`new-password`,value:m,onChange:e=>h(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`confirm_password_81b17bc0`)}),(0,$.jsx)(Z,{type:`password`,autoComplete:`new-password`,value:g,onChange:e=>_(e.target.value)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(Eo,{msg:b}),(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[s?(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,disabled:!t||v,onClick:()=>{D(null),C(!0)},children:u(`disable_password_a9e26288`)}):null,(0,$.jsx)(Y,{size:`sm`,onClick:A,disabled:v||!m.trim(),children:u(v?`saving_ff509c9b`:s?`update_password_82817084`:`enable_password_fe979237`)})]})]}),(0,$.jsx)(Lo,{open:S,onOpenChange:C,title:u(`disable_access_password_eaa845c9`),description:u(`remote_access_will_no_longer_require_password_verificat_036abd84`),confirmLabel:u(`disable_password_a9e26288`),busy:w,error:E,onConfirm:()=>void j()})]})}var zo=[{value:`placeholder`,get label(){return u(`replace_with_placeholder_text_a3640565`)}},{value:`error`,get label(){return u(`return_an_error_3d9f8301`)}},{value:`ocr`,get label(){return u(`extract_text_with_ocr_f28621fc`)}}];function Bo(e){let t=String(e??`placeholder`).trim().toLowerCase();return t===`error`||t===`ocr`?t:`placeholder`}function Vo({config:e,saveSection:t}){o();let[n,r]=(0,Q.useState)(()=>e.hooks?.image_fallback?.enabled===!0),[i,a]=(0,Q.useState)(()=>Bo(e.hooks?.image_fallback?.mode)),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),f=async(e,o)=>{let s={enabled:n,mode:i};r(e),a(o),c(!0),d(null);try{await t({hooks:{image_fallback:{enabled:e,mode:o}}}),d({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){r(s.enabled),a(s.mode),d({kind:`error`,text:q(e)})}finally{c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Hooks`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`image_preflight_fallback_db10bcdd`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`choose_how_to_handle_images_when_the_model_does_not_sup_91164dd4`)})]}),(0,$.jsx)(Jt,{checked:n,disabled:s,onCheckedChange:e=>void f(e,i)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`fallback_method_7d710102`)}),(0,$.jsxs)(W,{value:i,disabled:!n||s,onValueChange:e=>void f(n,e),children:[(0,$.jsx)(se,{className:`w-44`,size:`sm`,children:(0,$.jsx)(V,{})}),(0,$.jsx)(ce,{children:zo.map(e=>(0,$.jsx)(H,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsx)(Eo,{msg:l})]})}var Ho={get all(){return u(`delete_all_sessions_ddae77af`)},get empty(){return u(`delete_empty_sessions_1a185d3a`)},get children(){return u(`delete_child_sessions_a50c6edd`)}};function Uo({advanced:e=!0}){o();let t=Oe(e=>e.chats),n=Oe(e=>e.currentSessionId),r=Oe(e=>e.loadChats),[i,a]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(null),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),g=(0,Q.useMemo)(()=>n?t.find(e=>e.id===n)??null:null,[t,n]),_=e=>{switch(e.type){case`cleanup`:{let t=e.mode===`all`?u(`all_sessions_19c6c208`):e.mode===`empty`?u(`all_empty_sessions_5ed386ae`):u(`all_child_sessions_343eb995`);return{title:`${Ho[e.mode]}?`,description:u(`delete_this_cannot_be_undone_185d9a6f`,{v0:t,v1:u(i?`pinned_kept`:`pinned_included`)}),label:u(`delete_2f9daa82`)}}case`dev-reset`:return{title:u(`reset_session_storage_40780a5f`),description:u(`for_development_delete_all_backend_session_data_and_reb_86af26c4`),label:u(`reset_cb5d682b`)}}},v=async()=>{if(!(!s||s.type===`clear-current`)){d(!0),p(null);try{s.type===`cleanup`?(await Pe.cleanupSessions(s.mode,i),await r(),h({kind:`ok`,text:u(`cleanup_complete_6d256e25`)})):(await Pe.devResetSessions(),await r(),h({kind:`ok`,text:u(`session_storage_reset_30160c67`)})),c(null)}catch(e){p(q(e))}finally{d(!1)}}},y=e=>{p(null),h(null),c(e)},b=s&&s.type!==`clear-current`?_(s):null;return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`session_maintenance_6ce8056e`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`current_session_9800a458`)}),g?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm`,children:g.title||g.id}),(0,$.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[g.kind===`child`?u(`child_7f54b15e`):u(`root_session_label`),` · `,g.id]})]}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>y({type:`clear-current`,sessionId:g.id}),children:u(`conversation_clear_action`)})]}):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`no_active_session_d3a91aa2`)})]}),e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2 border-t pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`keep_pinned_sessions_during_bulk_cleanup_66ca3998`)}),(0,$.jsx)(Jt,{checked:i,onCheckedChange:a})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`all`,`empty`,`children`].map(e=>(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>y({type:`cleanup`,mode:e}),children:Ho[e]},e))})]}),(0,$.jsxs)(`div`,{className:`space-y-1 border-t pt-2`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`development_reset_delete_all_backend_session_data_and_r_0331fbb6`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>y({type:`dev-reset`}),children:u(`reset_session_storage_226dd63a`)})]})]}):null,(0,$.jsx)(Eo,{msg:m}),s?.type===`clear-current`?(0,$.jsx)(O,{sessionId:s.sessionId,title:t.find(e=>e.id===s.sessionId)?.title||s.sessionId,onClose:()=>c(null)}):null,s&&b?(0,$.jsx)(Lo,{open:!0,onOpenChange:e=>{e||c(null)},title:b.title,description:b.description,confirmLabel:b.label,busy:l,error:f,onConfirm:()=>void v()}):null]})}var{artifact:Wo,publicMetadata:Go}=r();function Ko(){o();let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),[l,d]=(0,Q.useState)(T());(0,Q.useEffect)(()=>y(()=>d(T())),[]);let f=e=>{d(e),k(e),window.dispatchEvent(new Event(j))},p=()=>{localStorage.clear(),t(null),c({kind:`ok`,text:u(`local_storage_cleared_reloading_ec1328a5`)}),window.setTimeout(()=>window.location.reload(),600)},m=async()=>{r(!0),a(null);try{await Pe.cleanupSessions(`all`,!1),await K.resetSetupStatus(),await K.resetBambooConfig(),localStorage.clear(),t(null),c({kind:`ok`,text:u(`reset_complete_reloading_12514457`)}),window.setTimeout(()=>window.location.reload(),1200)}catch(e){a(q(e)),r(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:u(`apply_63c73c47`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:u(`frontend_version_1986e080`)}),(0,$.jsxs)(`span`,{className:`font-mono text-xs`,children:[`v`,Wo.version,Go.development?` (dev)`:``]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t pt-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsx)(`div`,{className:`text-sm`,children:u(`graphics_compatibility_mode_49d20649`)}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:u(`disable_blur_and_glass_effects_for_virtual_desktops_vdi_26252605`)})]}),(0,$.jsx)(Jt,{checked:l,onCheckedChange:f})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t pt-2`,children:[(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u(`clear_browser_local_storage_and_reload_the_page_2a696421`)}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>t(`clear-storage`),children:u(`clear_local_storage_4ee71bf2`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-destructive`,children:[(0,$.jsx)(ct,{className:`size-3.5`}),u(`danger_zone_d0baa11d`)]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:u(`full_reset_delete_all_sessions_including_pinned_ones_re_d92ddf8e`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>t(`reset-app`),children:u(`reset_application_23f30713`)})]}),(0,$.jsx)(Eo,{msg:s}),(0,$.jsx)(Lo,{open:e===`clear-storage`,onOpenChange:e=>{e||t(null)},title:u(`clear_local_storage_1b86d7c0`),description:u(`this_clears_browser_localstorage_local_preferences_and__acf1cd5f`),confirmLabel:u(`clear_and_reload_f19b6e32`),onConfirm:p}),(0,$.jsx)(Lo,{open:e===`reset-app`,onOpenChange:e=>{!e&&!n&&t(null)},title:u(`reset_the_entire_app_60e36122`),description:u(`delete_all_sessions_including_pinned_ones_reset_backend_b03a8b2a`),confirmLabel:u(`confirm_reset_96f2cb4f`),busy:n,error:i,onConfirm:()=>void m()})]})}var qo=[{flag:`ticket_mutation`,label:`work_settings_mutation`,description:`work_settings_mutation_description`},{flag:`ticket_dispatch`,label:`work_settings_dispatch`,description:`work_settings_dispatch_description`}];function Jo({flags:e}){o();let t=(0,Q.useId)(),[n,r]=(0,Q.useState)(e),[i,a]=(0,Q.useState)(e),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),f={};for(let{flag:e}of qo)i[e]!==n[e]&&(f[e]=i[e]);let p=Object.keys(f).length>0;async function m(){c(!0),d(null);try{let e=(await K.setBambooConfig({features:f})).features;if(typeof e?.ticket_mutation!=`boolean`||typeof e.ticket_dispatch!=`boolean`||qo.some(({flag:t})=>f[t]!==void 0&&e[t]!==f[t]))throw Error(u(`work_settings_unconfirmed`));let t={ticket_mutation:e.ticket_mutation,ticket_dispatch:e.ticket_dispatch};r(t),a(t),d({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){d({kind:`error`,text:q(e)})}finally{c(!1)}}return(0,$.jsxs)(`section`,{"aria-labelledby":t,className:`space-y-3 rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{id:t,className:`text-xs font-medium text-muted-foreground`,children:u(`supervisor_work_tab`)}),qo.map(({flag:e,label:n,description:r})=>{let o=`${t}-${e}`;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:o,className:`block text-sm`,children:u(n)}),(0,$.jsx)(`p`,{id:`${o}-description`,className:`text-xs leading-relaxed text-muted-foreground`,children:u(r)})]}),(0,$.jsx)(Jt,{id:o,"aria-describedby":`${o}-description`,checked:i[e],disabled:s,onCheckedChange:t=>{a(n=>({...n,[e]:t})),d(null)}})]},e)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{"aria-live":`polite`,children:(0,$.jsx)(Eo,{msg:l})}),(0,$.jsx)(Y,{size:`sm`,className:`ml-auto`,onClick:m,disabled:s||!p,children:u(s?`saving_ff509c9b`:`save_a3030bf8`)})]})]})}function Yo(){o();let{config:e,loading:t,loadError:n,reload:r,saveSection:i}=To(),a=(0,Q.useContext)(Qe),s=At(e=>e.isAdvanced),c=e?.features?.ticket_mutation,l=e?.features?.ticket_dispatch;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[t?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(ya,{className:`h-24 w-full rounded-lg`}),(0,$.jsx)(ya,{className:`h-24 w-full rounded-lg`}),(0,$.jsx)(ya,{className:`h-24 w-full rounded-lg`})]}):n?(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-destructive`,children:[u(`could_not_load_configuration_395e6a71`),n]}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>void r(),children:u(`retry_b8784c8d`)})]}):e?(0,$.jsxs)($.Fragment,{children:[a&&typeof c==`boolean`&&typeof l==`boolean`?(0,$.jsx)(Jo,{flags:{ticket_mutation:c,ticket_dispatch:l}}):null,s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Do,{config:e,saveSection:i}),(0,$.jsx)(jo,{config:e,saveSection:i}),(0,$.jsx)(No,{config:e,saveSection:i}),(0,$.jsx)(Po,{config:e,saveSection:i}),(0,$.jsx)(Io,{config:e,saveSection:i})]}):null,s?(0,$.jsx)(Vo,{config:e,saveSection:i}):null]}):null,s?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Ro,{saveSection:i,configReady:!!e})}):null,(0,$.jsx)(Uo,{advanced:s}),(0,$.jsx)(Ko,{})]})}var Xo=(0,Q.lazy)(()=>i(()=>import(`./JianduProjectMemories-bTTYZdJm.js`).then(e=>({default:e.JianduProjectMemories})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]),import.meta.url));function Zo({api:e=ot}){let{t,i18n:n}=f(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)({status:`loading`});if((0,Q.useEffect)(()=>{if(r)return;let t=!1;return c({status:`loading`}),e.getOverview().then(e=>{t||c({status:`ready`,overview:e})}).catch(e=>{if(t)return;let n=e instanceof rt?e.code:null;c({status:`error`,error:n===`malformed_response`?`malformed`:n===`access_denied`?`denied`:`unavailable`})}),()=>{t=!0}},[e,r,a]),r)return(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,$.jsx)(Y,{variant:`outline`,onClick:()=>i(!1),children:t(`settings.jiandu.overview.back`)}),(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.list.loading`)}),children:(0,$.jsx)(Xo,{})})]});let l=s.status===`ready`?s.overview:null,u=e=>e?new Intl.DateTimeFormat(n.language,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):t(`settings.jiandu.overview.noTimestamp`);return(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,$.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(`settings.jiandu.overview.title`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings.jiandu.overview.description`)})]}),(0,$.jsx)(Y,{variant:`outline`,disabled:s.status===`loading`,onClick:()=>o(e=>e+1),children:t(`settings.jiandu.overview.refresh`)})]}),(0,$.jsx)(`section`,{"aria-label":t(`settings.jiandu.overview.scopes`),className:`flex flex-col gap-3 sm:flex-row`,children:[`global`,`session`,`project`].map(e=>(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 rounded-lg border p-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`settings.jiandu.overview.${e}Title`)}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t(`settings.jiandu.overview.${e}Description`)})]},e))}),s.status===`loading`?(0,$.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.overview.loading`)}):null,s.status===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/40 p-3 text-sm text-destructive`,children:t(`settings.jiandu.overview.errors.${s.error}`)}):null,l?(0,$.jsxs)(`section`,{"aria-label":t(`settings.jiandu.overview.inventory`),className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings.jiandu.overview.inventory`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`settings.jiandu.overview.inventoryDescription`)})]}),(0,$.jsx)(`dl`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[`total`,l.totalMemories],[`globalCount`,l.globalMemories],[`projectCount`,l.projectMemories],[`projects`,l.projectCount]].map(([e,r])=>(0,$.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.overview.${e}`)}),(0,$.jsx)(`dd`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:r.toLocaleString(n.language)})]},e))}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`byType`,it,l.byType,`types`],[`byStatus`,at,l.byStatus,`statuses`]].map(([e,r,i,a])=>(0,$.jsxs)(`section`,{"aria-label":t(`settings.jiandu.overview.${e}`),className:`rounded-lg border p-3`,children:[(0,$.jsx)(`h4`,{className:`mb-2 text-sm font-medium`,children:t(`settings.jiandu.overview.${e}`)}),(0,$.jsx)(`dl`,{className:`space-y-2 text-sm`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:t(`settings.jiandu.${a}.${e}`)}),(0,$.jsx)(`dd`,{className:`tabular-nums`,children:i[e].toLocaleString(n.language)})]},e))})]},e))}),(0,$.jsxs)(`dl`,{className:`grid gap-2 text-xs sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:t(`settings.jiandu.overview.lastReindex`)}),(0,$.jsx)(`dd`,{children:u(l.lastReindexAt)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:t(`settings.jiandu.overview.lastDream`)}),(0,$.jsx)(`dd`,{children:u(l.lastDreamAt)})]})]})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.overview.manageDescription`)}),(0,$.jsx)(Y,{variant:`outline`,onClick:()=>i(!0),children:t(`settings.jiandu.overview.manage`)})]})]})}var Qo={max_context_tokens:1e6,max_output_tokens:32e3,safety_margin:1e4},$o=0,es=()=>`model-limit-${$o++}`;function ts(e){let t=e.trim().replace(/[,_\s]/g,``),n=/^(\d+(?:\.\d+)?)([kKmM])?$/.exec(t);if(!n)return null;let r=Number(n[1])*(n[2]?.toLowerCase()===`m`?1e6:n[2]?.toLowerCase()===`k`?1e3:1);return Number.isSafeInteger(r)?r:null}function ns(e){return e>=1e6&&e%1e6==0?`${e/1e6}M`:e>=1e3&&e%1e3==0?`${e/1e3}K`:String(e)}var rs=(e,t)=>({id:es(),model_pattern:e.model_pattern,isCustom:!t.has(e.model_pattern.trim().toLocaleLowerCase()),customized:!0,max_context_tokens:ns(e.max_context_tokens),max_output_tokens:ns(e.max_output_tokens??Qo.max_output_tokens),safety_margin:e.safety_margin==null?``:ns(e.safety_margin)});function is(e,t,n){let r=new Set(n.map(e=>e.trim().toLocaleLowerCase()).filter(Boolean)),i=t.map(e=>rs(e,r)),a=new Set(t.map(e=>e.model_pattern.trim().toLocaleLowerCase()));for(let t of n){let n=t.trim(),r=n.toLocaleLowerCase();!n||a.has(r)||(a.add(r),i.push({id:es(),model_pattern:n,isCustom:!1,customized:!1,max_context_tokens:ns(e.max_context_tokens),max_output_tokens:ns(e.max_output_tokens),safety_margin:``}))}return i}function as(e){let t=new Set,n=[];for(let r of e){if(!r.customized)continue;let e=r.model_pattern.trim();if(!e)return{error:u(`model_pattern_is_required_327363dc`)};let i=e.toLocaleLowerCase();if(t.has(i))return{error:u(`duplicate_model_8846705b`,{v0:e})};t.add(i);let a=ts(r.max_context_tokens);if(a===null||a<1e3)return{error:u(`the_context_window_for_must_be_an_integer_of_at_least_1_3efecb54`,{v0:e})};let o=ts(r.max_output_tokens);if(o===null||o<1)return{error:u(`maximum_output_for_must_be_an_integer_of_at_least_1_f032d4bd`,{v0:e})};if(o>a)return{error:u(`maximum_output_for_cannot_exceed_its_context_window_e5cd692f`,{v0:e})};let s;if(r.safety_margin.trim()){let t=ts(r.safety_margin);if(t===null||t<0)return{error:u(`the_safety_margin_for_must_be_a_nonnegative_integer_e71fc7c5`,{v0:e})};if(t>=a)return{error:u(`the_safety_margin_for_must_be_smaller_than_its_context__94c4d58b`,{v0:e})};s=t}n.push({model_pattern:e,max_context_tokens:a,max_output_tokens:o,...s===void 0?{}:{safety_margin:s}})}return{overrides:n}}var os=[{value:`16K`,label:`16K`,description:`16,000 tokens`},{value:`32K`,label:`32K`,description:`32,000 tokens`},{value:`64K`,label:`64K`,description:`64,000 tokens`},{value:`128K`,label:`128K`,description:`128,000 tokens`},{value:`200K`,label:`200K`,description:`200,000 tokens`},{value:`256K`,label:`256K`,description:`256,000 tokens`},{value:`258K`,label:`258K`,description:`258,000 tokens`},{value:`400K`,label:`400K`,description:`400,000 tokens`},{value:`1M`,label:`1M`,description:`1,000,000 tokens`},{value:`2M`,label:`2M`,description:`2,000,000 tokens`}],ss=[{value:`4K`,label:`4K`,description:`4,000 tokens`},{value:`8K`,label:`8K`,description:`8,000 tokens`},{value:`16K`,label:`16K`,description:`16,000 tokens`},{value:`32K`,label:`32K`,description:`32,000 tokens`},{value:`64K`,label:`64K`,description:`64,000 tokens`},{value:`128K`,label:`128K`,description:`128,000 tokens`}];function cs(e){let t=e.model_limits?.[0],n=(e,t)=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0?e:t;return{max_context_tokens:n(t?.max_context_tokens,Qo.max_context_tokens),max_output_tokens:n(t?.max_output_tokens,Qo.max_output_tokens),safety_margin:((e,t)=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:t)(t?.safety_margin,Qo.safety_margin)}}function ls({ariaLabel:e,value:t,onChange:n,options:r,placeholder:i,disabled:a=!1,inputMode:s}){o();let c=(0,Q.useRef)(null),l=(0,Q.useId)(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(-1),[h,g]=(0,Q.useState)(!1),_=(0,Q.useMemo)(()=>{if(!h)return r;let e=t.trim().toLocaleLowerCase();if(!e)return r;let n=r.filter(t=>`${t.label} ${t.value} ${t.description??``}`.toLocaleLowerCase().includes(e));return n.length>0?n:r},[h,r,t]),v=d&&_.length>0&&!a,y=e=>{n(e),f(!1),m(-1),g(!1),c.current?.focus()},b=e=>{_.length!==0&&(f(!0),m(t=>t<0?e===1?0:_.length-1:(t+e+_.length)%_.length))};return(0,$.jsxs)(z,{open:v,onOpenChange:e=>{f(e),e||(m(-1),g(!1))},children:[(0,$.jsx)(re,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Z,{ref:c,role:`combobox`,"aria-label":e,"aria-autocomplete":`list`,"aria-controls":l,"aria-expanded":v,"aria-activedescendant":v&&p>=0?`${l}-${p}`:void 0,autoComplete:`off`,inputMode:s,value:t,placeholder:i,disabled:a,className:X(`h-8 text-xs`,r.length>0&&!a&&`pr-8`),onFocus:()=>{g(!1),f(r.length>0)},onChange:e=>{n(e.target.value),g(!0),f(r.length>0),m(-1)},onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),b(1);else if(e.key===`ArrowUp`)e.preventDefault(),b(-1);else if(e.key===`Enter`&&v&&p>=0){e.preventDefault();let t=_[p];t&&y(t.value)}else e.key===`Escape`&&d&&(e.preventDefault(),f(!1),m(-1),g(!1))}}),r.length>0&&!a?(0,$.jsx)(`button`,{type:`button`,"aria-label":u(`expand_options_fe7f0967`,{v0:e}),tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-8 items-center justify-center text-muted-foreground`,onMouseDown:e=>e.preventDefault(),onClick:()=>{g(!1),f(e=>!e),m(-1),c.current?.focus()},children:(0,$.jsx)(oe,{className:`size-3.5`})}):null]})}),v?(0,$.jsx)(R,{id:l,role:`listbox`,align:`start`,className:`z-[160] max-h-72 min-w-48 overflow-y-auto p-1`,style:{width:Math.max(c.current?.parentElement?.offsetWidth??0,192)},onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:_.map((e,n)=>{let r=e.value.toLocaleLowerCase()===t.trim().toLocaleLowerCase();return(0,$.jsxs)(`button`,{id:`${l}-${n}`,type:`button`,role:`option`,"aria-selected":r,className:X(`flex w-full items-start gap-2 rounded-sm px-2 py-1.5 text-left text-xs outline-none`,n===p&&`bg-accent text-accent-foreground`),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>m(n),onClick:()=>y(e.value),children:[(0,$.jsx)(ae,{className:X(`mt-0.5 size-3.5 shrink-0`,r?`opacity-100`:`opacity-0`)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:e.description}):null]})]},e.value)})}):null]})}function us({config:e,saveSection:t}){o();let n=Oe(e=>e.models),r=G(e=>e.providerSnapshot??e.providerRepairSnapshot),i=G(e=>e.catalog?.models),[a,s]=(0,Q.useState)(Qo),[c,l]=(0,Q.useState)(C),[d,f]=(0,Q.useState)(()=>is(Qo,e.model_limits??[],C())),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=!1;return K.getModelLimitDefaults().then(t=>{if(e)return;let n=cs(t);s(n),f(e=>e.map(e=>e.customized?e:{...e,max_context_tokens:ns(n.max_context_tokens),max_output_tokens:ns(n.max_output_tokens)}))}).catch(()=>{}),()=>{e=!0}},[]);let x=(0,Q.useMemo)(()=>{let e=[],t=new Set,a=n=>{if(typeof n!=`string`)return;let r=n.trim(),i=r.toLocaleLowerCase();!r||t.has(i)||(t.add(i),e.push(r))};c.forEach(a),d.forEach(e=>a(e.model_pattern)),n.forEach(a),i?.forEach(e=>a(e.reference.model));let o=r?.defaults;return a(o?.chat?.model),a(o?.fast?.model),a(o?.task_summary?.model),a(o?.vision?.model),a(o?.memory_background?.model),a(o?.planning?.model),a(o?.search?.model),a(o?.code_review?.model),a(o?.work_review?.model),a(o?.sub_agent?.model),Object.values(o?.subagent_models??{}).forEach(e=>a(e.model)),e.map(e=>({value:e,label:e}))},[n,i,r,d,c]),S=(e,t)=>{f(n=>n.map(n=>n.id===e?{...n,...t}:n)),g(null)},w=()=>{f(e=>[...e,{id:es(),model_pattern:``,isCustom:!0,customized:!0,max_context_tokens:ns(a.max_context_tokens),max_output_tokens:ns(a.max_output_tokens),safety_margin:``}]),g(null)},T=e=>{e.isCustom||l(ee(e.model_pattern)),f(t=>t.filter(t=>t.id!==e.id)),g(null)},E=e=>{f(t=>t.map(t=>t.id===e?{...t,customized:!1,max_context_tokens:ns(a.max_context_tokens),max_output_tokens:ns(a.max_output_tokens),safety_margin:``}:t)),g(null)},D=async()=>{let e=as(d);if(`error`in e){g({kind:`error`,text:e.error});return}m(!0),g(null);try{let n=await t({model_limits:e.overrides}),r=C();l(r),f(is(a,n.model_limits??[],r)),g({kind:`ok`,text:u(`saved_1bd91a7d`)})}catch(e){g({kind:`error`,text:q(e)})}finally{m(!1)}},O=async()=>{m(!0),b(null);try{let e=await t({model_limits:[]}),n=C();l(n),f(is(a,e.model_limits??[],n)),v(!1),g({kind:`ok`,text:u(`restored_global_defaults_4f47beee`)})}catch(e){b(q(e))}finally{m(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:u(`model_limits_05ff605e`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:u(`models_confirmed_through_sending_appear_automatically_u_1e3a1de2`)})]}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:w,children:[(0,$.jsx)(fe,{className:`size-4`}),u(`add_model_e552c2ac`)]})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:[u(`global_defaults_context_b7667fd0`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:ns(a.max_context_tokens)}),` · `,u(`max_output_d6601037`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:ns(a.max_output_tokens)}),` · `,u(`safety_margin_40253c60`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:ns(a.safety_margin)})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:u(`choose_or_type_a_model_pattern_context_and_output_limit_eb2906c4`)}),(0,$.jsxs)(`div`,{className:`overflow-x-auto rounded-lg border`,children:[(0,$.jsxs)(`table`,{className:`w-full min-w-[820px] text-xs`,children:[(0,$.jsx)(`thead`,{className:`bg-muted/40 text-muted-foreground`,children:(0,$.jsxs)(`tr`,{className:`[&>th]:px-2 [&>th]:py-2 [&>th]:font-medium`,children:[(0,$.jsx)(`th`,{className:`w-[220px] text-left`,children:u(`model_c98e118e`)}),(0,$.jsx)(`th`,{className:`w-[150px] text-left`,children:u(`context_window_bb074b86`)}),(0,$.jsx)(`th`,{className:`w-[130px] text-left`,children:u(`max_output_d6601037`)}),(0,$.jsx)(`th`,{className:`w-[130px] text-left`,children:u(`safety_margin_40253c60`)}),(0,$.jsx)(`th`,{className:`w-[90px] text-left`,children:u(`status_6320b4a8`)}),(0,$.jsx)(`th`,{className:`w-[150px] text-right`,children:u(`action_ed31fbb4`)})]})}),(0,$.jsx)(`tbody`,{children:d.map(e=>(0,$.jsxs)(`tr`,{className:`border-t align-top [&>td]:px-2 [&>td]:py-2`,children:[(0,$.jsx)(`td`,{children:e.isCustom?(0,$.jsx)(ls,{ariaLabel:u(`model_pattern_e5fe9bd4`),value:e.model_pattern,onChange:t=>S(e.id,{model_pattern:t}),options:x,placeholder:u(`e_g_gpt_5_or_glm_5_3_63bebb83`)}):(0,$.jsx)(`div`,{className:`flex h-8 items-center font-mono font-medium`,title:e.model_pattern,children:(0,$.jsx)(`span`,{className:`truncate`,children:e.model_pattern})})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(ls,{ariaLabel:u(`context_window_74c09029`,{v0:e.model_pattern||u(`new_model`)}),value:e.max_context_tokens,onChange:t=>S(e.id,{max_context_tokens:t}),options:os,placeholder:u(`e_g_258k_or_1m_0a242a0c`),disabled:!e.customized,inputMode:`decimal`})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(ls,{ariaLabel:u(`maximum_output_5e8920ca`,{v0:e.model_pattern||u(`new_model`)}),value:e.max_output_tokens,onChange:t=>S(e.id,{max_output_tokens:t}),options:ss,placeholder:u(`e_g_16k_or_32k_95dea87b`),disabled:!e.customized,inputMode:`decimal`})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(Z,{className:`h-8 text-xs`,"aria-label":u(`safety_margin_b3945952`,{v0:e.model_pattern||u(`new_model`)}),inputMode:`decimal`,placeholder:ns(a.safety_margin),value:e.safety_margin,disabled:!e.customized,onChange:t=>S(e.id,{safety_margin:t.target.value})})}),(0,$.jsx)(`td`,{className:`pt-3!`,children:(0,$.jsx)(U,{variant:e.customized?`success`:`secondary`,children:e.customized?u(`overridden_4ae1bfcb`):u(`follow_defaults_a44f9f9f`)})}),(0,$.jsx)(`td`,{children:(0,$.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[e.customized?e.isCustom?null:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>E(e.id),children:u(`reset_to_default_ba2e93e7`)}):(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>S(e.id,{customized:!0}),children:u(`customize_4eafa9e9`)}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-8 px-2 text-destructive hover:text-destructive`,onClick:()=>T(e),children:u(`remove_6135d415`)})]})})]},e.id))})]}),d.length===0?(0,$.jsx)(`div`,{className:`border-t px-3 py-8 text-center text-xs text-muted-foreground`,children:u(`models_you_have_used_appear_here_after_sending_you_can__d8f967ba`)}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(Eo,{msg:h}),(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,disabled:p,onClick:()=>{b(null),v(!0)},children:u(`reset_all_to_default_3b6c48ce`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>void D(),disabled:p,children:u(p?`saving_ff509c9b`:`save_a3030bf8`)})]})]}),(0,$.jsx)(Lo,{open:_,onOpenChange:v,title:u(`clear_all_model_limits_86ec2499`),description:u(`remove_all_per_model_overrides_used_models_stay_in_the__d570aece`),confirmLabel:u(`clear_bce23772`),busy:p,error:y,onConfirm:()=>void O()})]})}function ds(){o();let{config:e,loading:t,loadError:n,reload:r,saveSection:i}=To();return t?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(ya,{className:`h-24 w-full rounded-lg`}),(0,$.jsx)(ya,{className:`h-64 w-full rounded-lg`})]}):n?(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-destructive`,children:[u(`could_not_load_model_limits_f49c4361`),n]}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>void r(),children:u(`retry_b8784c8d`)})]}):e?(0,$.jsx)(us,{config:e,saveSection:i}):null}var fs=`core`,ps={max_attempts:{min:1,max:12},attempt_timeout_ms:{min:1e3,max:6e5},total_budget_ms:{min:1e3,max:36e5},base_delay_ms:{min:1,max:3e5},max_delay_ms:{min:1,max:3e5}},ms=[{key:`max_attempts`,labelKey:`retry_max_attempts`,hintKey:`retry_max_attempts_hint`},{key:`attempt_timeout_ms`,labelKey:`retry_attempt_timeout`,hintKey:`retry_attempt_timeout_hint`},{key:`total_budget_ms`,labelKey:`retry_total_budget`,hintKey:`retry_total_budget_hint`},{key:`base_delay_ms`,labelKey:`retry_base_delay`,hintKey:`retry_base_delay_hint`},{key:`max_delay_ms`,labelKey:`retry_max_delay`,hintKey:`retry_max_delay_hint`}];function hs(e){for(let[t,n]of Object.entries(ps)){let r=e[t];if(!Number.isSafeInteger(r)||r<n.min||r>n.max)return`${t}: ${n.min}–${n.max}`}return e.base_delay_ms>e.max_delay_ms?`base_delay_ms > max_delay_ms`:null}function gs(){o();let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(()=>new Set),g=(0,Q.useCallback)(e=>{t({...e.data.llm_retry??{}}),r(e.revision),h(new Set)},[]),_=(0,Q.useCallback)(async()=>{try{return g(await be.getTypedSection(fs)),d(null),!0}catch{return r(null),d(u(`retry_load_failed`)),!1}},[g]);(0,Q.useEffect)(()=>{_().finally(()=>a(!1))},[_]);let v=async()=>{if(!e||n===null||s)return;let t=hs(e);if(t){d(t);return}c(!0),d(null),p(!1);try{let t=await be.getTypedSection(fs),n={...t.data.llm_retry??{}};for(let t of m)n[t]=e[t];let r=hs(n);if(r){d(r);return}g(await be.putTypedSection(fs,{...t.data,llm_retry:n},t.revision)),p(!0)}catch{d(await _()?u(`retry_save_unconfirmed`):u(`retry_save_failed`))}finally{c(!1)}};return i?(0,$.jsx)(ya,{className:`h-64 w-full rounded-lg`}):e?(0,$.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:u(`retry_title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`retry_description`)})]}),(0,$.jsx)(`div`,{className:`space-y-3`,children:ms.map(({key:n,labelKey:r,hintKey:i})=>(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(st,{htmlFor:`llm-retry-${n}`,children:u(r)}),(0,$.jsx)(Z,{id:`llm-retry-${n}`,type:`number`,inputMode:`numeric`,min:ps[n].min,max:ps[n].max,value:Number.isFinite(e[n])?String(e[n]):``,disabled:s,onChange:r=>{let i=Number(r.target.value);p(!1),h(e=>new Set(e).add(n)),t({...e,[n]:Number.isFinite(i)?i:0})}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(i)})]},n))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{size:`sm`,disabled:s||n===null,onClick:()=>void v(),children:u(`save_a3030bf8`)}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,disabled:s,onClick:()=>void _(),children:u(`reload_state_df7392cc`)})]}),l?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:l}):null,f?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:u(`retry_saved`)}):null]}):(0,$.jsxs)(`section`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:l}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>void _(),children:u(`retry_b8784c8d`)})]})}var _s=()=>({providers:[],provider_base_urls:[],provider_api_keys:[],scenarios:[],subagent_models:[],env:Object.create(null)}),vs=()=>({providers:Object.create(null),scenarios:Object.create(null),subagent_models:Object.create(null),env:Object.create(null)}),ys=1048576,bs=1024,xs=ye.filter(e=>e!==`work_review`),Ss=class extends Error{kind;constructor(e){super(`Configuration sharing ${e}`),this.kind=e,this.name=`ConfigShareError`}},Cs=`/bamboo/config/share`,ws=e=>({cache:`no-store`,headers:{"Cache-Control":`no-store`},signal:e}),Ts=e=>new TextEncoder().encode(e).length,Es=e=>{if(e===void 0)return;let t=Ts(e);if(!e.trim()||t<12||t>1024)throw new Ss(`invalid`)},Ds=e=>{if(!e.share_string.trim().startsWith(`BAMBOO-SHARE:1:`)||Ts(e.share_string)>1048576)throw new Ss(`invalid`);Es(e.passphrase)},Os=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ks=e=>typeof e==`string`&&e.length>0&&e.length<=1024,As=e=>Number.isSafeInteger(e)&&e>=0,js=e=>Os(e)&&As(e.providers)&&As(e.env)&&As(e.credentials),Ms=e=>{if(!ks(e))return!1;try{let t=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&!t.username&&!t.password&&t.pathname===`/`&&!t.search&&!t.hash&&e===t.origin}catch{return!1}},Ns=e=>{if(!Os(e)||!ks(e.preview_token)||!js(e.expected_revisions)||!Os(e.preview)||typeof e.apply_blocked!=`boolean`||e.warnings!==void 0&&(!Array.isArray(e.warnings)||e.warnings.length>16||e.warnings.some(e=>!ks(e))))throw new Ss(`unavailable`);let t=e.preview,n=[t.providers,t.scenarios,t.subagent_models,t.env];if(n.some(e=>!Array.isArray(e)||e.length>256)||typeof t.contains_secrets!=`boolean`)throw new Ss(`unavailable`);for(let e of n.flat())if(!Os(e)||typeof e.conflict!=`boolean`)throw new Ss(`unavailable`);for(let e of t.providers)if(!ks(e.id)||!ks(e.provider_type)||e.label!==void 0&&!ks(e.label)||typeof e.has_api_key!=`boolean`||typeof e.has_base_url!=`boolean`||typeof e.replace_allowed!=`boolean`||!e.conflict&&!e.replace_allowed||typeof e.retains_existing_api_key!=`boolean`||typeof e.credential_origin_risk!=`boolean`||e.source_origin!==void 0&&!Ms(e.source_origin)||e.target_origin!==void 0&&!Ms(e.target_origin)||e.has_base_url!==(e.source_origin!==void 0)||e.retains_existing_api_key&&!e.conflict||e.credential_origin_risk!==(e.conflict&&e.has_base_url&&e.source_origin!==e.target_origin))throw new Ss(`unavailable`);for(let e of[...t.scenarios,...t.subagent_models])if(!ks(e.provider)||!ks(e.model))throw new Ss(`unavailable`);for(let e of t.scenarios)if(!xs.includes(e.scenario))throw new Ss(`unavailable`);for(let e of[...t.subagent_models,...t.env])if(!ks(e.name))throw new Ss(`unavailable`);for(let e of t.env)if(typeof e.has_value!=`boolean`||typeof e.secret!=`boolean`)throw new Ss(`unavailable`);let r=e;return{preview_token:r.preview_token,apply_blocked:r.apply_blocked,warnings:(r.warnings??[]).filter(e=>[`automatic_provider_authentication_blocked`,`credential_key_uninitialized`].includes(e)),expected_revisions:{providers:r.expected_revisions.providers,env:r.expected_revisions.env,credentials:r.expected_revisions.credentials},preview:{contains_secrets:r.preview.contains_secrets,providers:r.preview.providers.map(({id:e,provider_type:t,label:n,has_api_key:r,has_base_url:i,conflict:a,replace_allowed:o,source_origin:s,target_origin:c,retains_existing_api_key:l,credential_origin_risk:u})=>({id:e,provider_type:t,...n?{label:n}:{},has_api_key:r,has_base_url:i,conflict:a,replace_allowed:o,...s?{source_origin:s}:{},...c?{target_origin:c}:{},retains_existing_api_key:l,credential_origin_risk:u})),scenarios:r.preview.scenarios.map(({scenario:e,provider:t,model:n,conflict:r})=>({scenario:e,provider:t,model:n,conflict:r})),subagent_models:r.preview.subagent_models.map(({name:e,provider:t,model:n,conflict:r})=>({name:e,provider:t,model:n,conflict:r})),env:r.preview.env.map(({name:e,has_value:t,secret:n,conflict:r})=>({name:e,has_value:t,secret:n,conflict:r}))}}},Ps=e=>{if(!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(e))throw new Ss(`invalid`)},Fs=(e,t)=>{if(!Os(e)||e.operation_id!==t||![`committed`,`pending`,`rejected`,`not_found`].includes(e.state)||e.revisions!==void 0&&!js(e.revisions))throw new Ss(`unconfirmed`);let n=e.revisions;return{operation_id:t,state:e.state,...n?{revisions:{providers:n.providers,env:n.env,credentials:n.credentials}}:{}}},Is=(e,t)=>e instanceof Ss?e:Ne(e)&&e.status===409?new Ss(`stale`):Ne(e)&&[400,401,403,413,422,429].includes(e.status)?new Ss(`invalid`):new Ss(t),Ls=new class{async waitForProviderRefresh(e){if(!js(e))throw new Ss(`unavailable`);let t=AbortSignal.timeout(3e3);try{for(let n=0;n<15;n+=1){let r=await J.get(`/bamboo/config/live-health`,ws(t));if(Os(r)&&Os(r.providers)&&r.providers.status===`healthy`&&As(r.providers.revision)&&r.providers.revision>=e.providers&&Os(r.application)&&Os(r.application.sections)&&Array.isArray(r.application.consumers)){let t=r.application.sections,n=Object.entries(e).every(([e,n])=>Os(t[e])&&As(t[e].revision)&&t[e].revision>=n),i=r.application.consumers.find(e=>Os(e)&&e.id===`provider-runtime`);if(n&&Os(i)&&i.state===`in_sync`&&Os(i.applied_dependencies)&&As(i.applied_dependencies.providers)&&i.applied_dependencies.providers>=e.providers&&Os(i.credential_source)&&(i.applied_dependencies.credentials===void 0&&i.credential_source.status===`not_required`||As(i.applied_dependencies.credentials)&&i.applied_dependencies.credentials>=e.credentials&&i.credential_source.status===`observed_inputs`&&As(i.credential_source.revision)&&i.credential_source.revision>=e.credentials))return}if(n<14&&!t.aborted&&await new Promise(e=>{let n=()=>{clearTimeout(r),t.removeEventListener(`abort`,n),e()},r=setTimeout(n,200);t.addEventListener(`abort`,n,{once:!0}),t.aborted&&n()}),t.aborted)break}}catch{throw new Ss(`unavailable`)}throw new Ss(`unavailable`)}async inventory(){try{let[e,t]=await Promise.all([be.getProviderInstances(),be.getEnvVars()]),n=Ce(e),r=e=>{let t=e.trim();if(n.instances.some(e=>e.id===t))return t;let r=n.instances.find(e=>e.id===n.default_provider_instance_id);return r?.type===t?r.id:n.instances.filter(e=>e.enabled&&e.type===t).map(e=>e.id).sort()[0]??t};return{providers:n.instances.map(({id:e,label:t,type:n})=>({id:e,label:t,type:n})),scenarios:xs.flatMap(e=>{let t=n.defaults?.[e];return t?[{name:e,provider:r(t.provider),model:t.model}]:[]}),subagent_models:Object.entries(n.defaults?.subagent_models??{}).map(([e,t])=>({name:e,provider:r(t.provider),model:t.model})),env:t.entries.map(({name:e,secret:t,has_value:n})=>({name:e,secret:t,has_value:n}))}}catch{throw new Ss(`unavailable`)}}async export(e,t,n,r){if(Es(n),(e.provider_api_keys.length>0||Object.values(e.env).some(Boolean))&&(!t||!n))throw new Ss(`invalid`);try{let i=await J.postOnce(`${Cs}/export`,{selection:e,include_secrets:t,...n?{passphrase:n}:{}},ws(r));if(!i||typeof i.share_string!=`string`)throw new Ss(`unavailable`);return Ds({share_string:i.share_string}),i.share_string}catch(e){throw Is(e,`unavailable`)}}async preview(e,t){Ds(e);try{return Ns(await J.postOnce(`${Cs}/preview`,e,ws(t)))}catch(e){throw Is(e,`unavailable`)}}async apply(e){Ds(e),Ps(e.operation_id);try{return Fs(await J.postOnce(`${Cs}/apply`,e,ws()),e.operation_id)}catch(e){throw Is(e,`unconfirmed`)}}async operation(e){Ps(e);try{return Fs(await J.get(`${Cs}/operations/${e}`,ws()),e)}catch(e){throw Is(e,`unconfirmed`)}}},Rs=()=>({providers:[],scenarios:[],subagent_models:[],env:[]}),zs=({preview:e})=>[...e.providers.map(e=>({group:`providers`,id:e.id,label:e.label?`${e.label} (${e.id})`:e.id,conflict:e.conflict,secret:e.has_api_key,provider:e})),...e.scenarios.map(e=>({group:`scenarios`,id:e.scenario,label:`${e.scenario}: ${e.provider} / ${e.model}`,conflict:e.conflict,secret:!1})),...e.subagent_models.map(e=>({group:`subagent_models`,id:e.name,label:`${e.name}: ${e.provider} / ${e.model}`,conflict:e.conflict,secret:!1})),...e.env.map(e=>({group:`env`,id:e.name,label:e.name,conflict:e.conflict,secret:e.has_value}))],Bs=(e,t,n)=>n?[...new Set([...e,t])]:e.filter(e=>e!==t),Vs=e=>{let t=vs();for(let n of zs(e))n.conflict&&(t[n.group][n.id]={action:`skip`});return t},Hs=(e,t)=>Object.hasOwn(e[t.group],t.id)?e[t.group][t.id]:void 0,Us=e=>e.replace(/[A-Z]/g,e=>e.toLowerCase()),Ws=()=>{G.getState().invalidateProviderState(),Oe.getState().setSavedModelOptions([])},Gs=async e=>{Ws(),await Ls.waitForProviderRefresh(e);let t=await G.getState().loadProviderInstances(),n=G.getState();if(n.providerStatus!==`ready`||n.providerSnapshot!==t)throw new Ss(`unavailable`);Oe.getState().setSavedModelOptions(t.instances.filter(e=>e.enabled).flatMap(e=>Se(e,t.defaults)))};function Ks({label:e,checked:t,disabled:n,onChange:r}){return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:e=>r(e.target.checked)}),e]})}function qs(){o();let e=(0,Q.useId)(),[t,n]=(0,Q.useState)(Rs),[r,i]=(0,Q.useState)(!0),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(_s),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(vs),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[ee,F]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(null),I=(0,Q.useRef)(null),L=(0,Q.useRef)(0),re=(0,Q.useRef)(null),R=(0,Q.useRef)(null),z=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(z.current=!0,Ls.inventory().then(e=>{z.current&&(n(e),s(!0))}).catch(()=>{z.current&&P(u(`share_inventory_failed`))}).finally(()=>{z.current&&i(!1)}),()=>{z.current=!1,L.current+=1,re.current?.abort(),R.current=null}),[]);let ie=()=>{L.current+=1,S(null),w(vs()),E(!1),O(null),R.current=null,A(!1),F(null),P(j?u(`share_current_refresh_failed`):null)},ae=()=>{I.current===`apply`||I.current===`check`||I.current===`refresh`||R.current||(re.current?.abort(),re.current=null,I.current=null,ne(null),D?.state===`committed`&&k?(L.current+=1,S(null),w(vs()),E(!1),F(u(`share_saved`)),P(u(`share_saved_refresh_failed`))):ie(),v(``),b(``),m(``),g(``),f(!1),l(_s()))},oe=e=>I.current?!1:(I.current=e,ne(e),P(null),F(null),!0),B=e=>{z.current&&e===L.current&&(I.current=null,ne(null),re.current=null)},V=e=>{I.current||(l(e),g(``),F(null))},se=(e,n)=>V({...c,providers:Bs(c.providers,e,n),provider_base_urls:n?c.provider_base_urls:c.provider_base_urls.filter(t=>t!==e),provider_api_keys:n?c.provider_api_keys:c.provider_api_keys.filter(t=>t!==e),scenarios:n?c.scenarios:c.scenarios.filter(n=>t.scenarios.find(e=>e.name===n)?.provider!==e),subagent_models:n?c.subagent_models:c.subagent_models.filter(n=>t.subagent_models.find(e=>e.name===n)?.provider!==e)}),ce=c.provider_api_keys.length>0||Object.values(c.env).some(Boolean),le=c.providers.length+c.scenarios.length+c.subagent_models.length+Object.keys(c.env).length>0,H=!!te||!!R.current||k||!!j,U=new TextEncoder().encode(p).length,W=!ce&&!p||!!p.trim()&&U>=12&&U<=1024,ue=async()=>{if(!a||!le||!W||!oe(`export`))return;let e=L.current;re.current=new AbortController;try{let t=await Ls.export(c,d,p||void 0,re.current.signal);z.current&&e===L.current&&(g(t),m(``))}catch{z.current&&e===L.current&&P(u(`share_export_failed`))}finally{B(e)}},de=async()=>{if(!_.trim()||R.current||!oe(`preview`))return;let e=L.current;re.current=new AbortController,S(null),E(!1);try{let t=await Ls.preview({share_string:_,...y?{passphrase:y}:{}},re.current.signal);z.current&&e===L.current&&(S(t),w(Vs(t)))}catch{z.current&&e===L.current&&P(u(`share_preview_failed`))}finally{B(e)}},fe=async(e,t)=>{try{await Gs(e.revisions),z.current&&t===L.current&&(A(!1),P(null),F(u(`share_saved`)))}catch{z.current&&t===L.current&&(A(!0),F(u(`share_saved`)),P(u(`share_saved_refresh_failed`)))}},pe=async(e,t,n)=>{try{await Gs(e),z.current&&t===L.current&&(M(null),F(null),P(n))}catch{z.current&&t===L.current&&(M({revisions:e,error:n}),F(null),P(u(`share_current_refresh_failed`)))}},me=async(e,t,n)=>{z.current&&t===L.current&&(O(e),e.state===`committed`?(R.current=null,v(``),b(``),S(null),w(vs()),E(!1),F(u(`share_saved`)),A(!0)):e.state===`rejected`?(R.current=null,S(null),E(!1),P(u(`share_apply_rejected`))):P(u(`share_apply_unconfirmed`))),e.state===`committed`?await fe(e,t):e.state===`rejected`&&await pe(n,t,u(`share_apply_rejected`))},he=x&&zs(x).some(e=>{let t=Hs(C,e);return t?.action===`rename`&&(!t.target.trim()||(e.group===`env`?Us(t.target)===Us(e.id):t.target===e.id))}),ge=x&&zs(x).some(e=>e.provider?.replace_allowed===!1&&(Hs(C,e)??{action:`replace`}).action===`replace`),_e=async()=>{if(!x||x.apply_blocked||!T||he||ge||R.current||I.current)return;let e;try{e=crypto.randomUUID()}catch{P(u(`share_apply_rejected`));return}if(!oe(`apply`))return;let t=L.current,n={share_string:_,...y?{passphrase:y}:{},choices:C,expected_revisions:x.expected_revisions,preview_token:x.preview_token,operation_id:e};R.current=e,Ws(),v(``),b(``),m(``);try{await me(await Ls.apply(n),t,n.expected_revisions)}catch(e){if(e instanceof Ss&&[`stale`,`invalid`].includes(e.kind)){let r=u(e.kind===`stale`?`share_stale`:`share_apply_rejected`);z.current&&t===L.current&&(R.current=null,S(null),E(!1),P(r)),await pe(n.expected_revisions,t,r)}else z.current&&t===L.current&&P(u(`share_apply_unconfirmed`))}finally{B(t)}},ve=async()=>{let e=R.current;if(!e||!oe(`check`))return;let t=L.current,n=x?.expected_revisions;try{await me(await Ls.operation(e),t,n)}catch{z.current&&t===L.current&&P(u(`share_apply_unconfirmed`))}finally{B(t)}},ye=async()=>{if(!j&&(D?.state!==`committed`||!k)||!oe(`refresh`))return;let e=L.current;try{j?await pe(j.revisions,e,j.error):D&&await fe(D,e)}finally{B(e)}},be=async()=>{if(!h||!oe(`copy`))return;let e=L.current;try{await navigator.clipboard.writeText(h),z.current&&e===L.current&&F(u(`share_copied`))}catch{z.current&&e===L.current&&P(u(`share_copy_failed`))}finally{B(e)}};return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u(`share_description`)}),(0,$.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-3`,"aria-labelledby":`${e}-export`,children:[(0,$.jsx)(`h3`,{id:`${e}-export`,className:`font-medium`,children:u(`share_export_title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`share_selection_hint`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`share_contract_limits`)}),r?(0,$.jsx)(`p`,{children:u(`share_loading`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`fieldset`,{disabled:H||!a,className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:u(`share_providers`)}),t.providers.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2 rounded border p-2`,children:[(0,$.jsx)(Ks,{label:`${e.label} (${e.id})`,checked:c.providers.includes(e.id),onChange:t=>se(e.id,t)}),(0,$.jsxs)(`div`,{className:`ml-5 flex flex-wrap gap-4`,children:[(0,$.jsx)(Ks,{label:u(`share_include_base_url`),checked:c.provider_base_urls.includes(e.id),disabled:!c.providers.includes(e.id),onChange:t=>V({...c,provider_base_urls:Bs(c.provider_base_urls,e.id,t)})}),(0,$.jsx)(Ks,{label:u(`share_include_api_key`),checked:c.provider_api_keys.includes(e.id),disabled:!c.providers.includes(e.id)||!d||e.type===`copilot`,onChange:t=>V({...c,provider_api_keys:Bs(c.provider_api_keys,e.id,t)})})]})]},e.id))]}),(0,$.jsxs)(`fieldset`,{disabled:H||!a,className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:u(`share_scenarios`)}),t.scenarios.map(e=>(0,$.jsx)(Ks,{label:`${e.name}: ${e.provider} / ${e.model}`,checked:c.scenarios.includes(e.name),onChange:t=>V({...c,scenarios:Bs(c.scenarios,e.name,t),providers:t?Bs(c.providers,e.provider,!0):c.providers})},e.name)),t.subagent_models.map(e=>(0,$.jsx)(Ks,{label:`${u(`share_subagent`)}: ${e.name} / ${e.model}`,checked:c.subagent_models.includes(e.name),onChange:t=>V({...c,subagent_models:Bs(c.subagent_models,e.name,t),providers:t?Bs(c.providers,e.provider,!0):c.providers})},e.name))]}),(0,$.jsxs)(`fieldset`,{disabled:H||!a,className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:u(`share_env`)}),t.env.map(e=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 rounded border p-2`,children:[(0,$.jsx)(Ks,{label:e.name,checked:Object.hasOwn(c.env,e.name),onChange:t=>{let n=Object.assign(Object.create(null),c.env);t?n[e.name]=!1:delete n[e.name],V({...c,env:n})}}),(0,$.jsx)(Ks,{label:u(`share_include_value`),checked:!!c.env[e.name],disabled:!Object.hasOwn(c.env,e.name)||!e.has_value||!d,onChange:t=>V({...c,env:{...c.env,[e.name]:t}})})]},e.name))]})]}),(0,$.jsx)(Ks,{label:u(`share_sensitive_choice`),checked:d,disabled:H,onChange:e=>{f(e),g(``),e||(m(``),l({...c,provider_api_keys:[],env:Object.fromEntries(Object.keys(c.env).map(e=>[e,!1]))}))}}),d&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:u(`share_sensitive_warning`)}),(0,$.jsx)(`label`,{htmlFor:`${e}-export-password`,className:`block text-sm`,children:u(`share_export_passphrase`)}),(0,$.jsx)(Z,{id:`${e}-export-password`,type:`password`,autoComplete:`new-password`,maxLength:bs,value:p,disabled:H,onChange:e=>{m(e.target.value),g(``)}}),(0,$.jsx)(Y,{type:`button`,onClick:()=>void ue(),disabled:H||!a||!le||!W,children:u(te===`export`?`share_working`:`share_generate`)}),h&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:`${e}-output`,className:`block text-sm`,children:u(`share_output`)}),(0,$.jsx)(`textarea`,{id:`${e}-output`,className:`w-full rounded border bg-background p-2 font-mono text-xs`,readOnly:!0,value:h,rows:3,spellCheck:!1}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,disabled:!!te,onClick:()=>void be(),children:u(`share_copy`)})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-3`,"aria-labelledby":`${e}-import`,children:[(0,$.jsx)(`h3`,{id:`${e}-import`,className:`font-medium`,children:u(`share_import_title`)}),(0,$.jsx)(`label`,{htmlFor:`${e}-input`,className:`block text-sm`,children:u(`share_paste`)}),(0,$.jsx)(`textarea`,{id:`${e}-input`,className:`w-full rounded border bg-background p-2 font-mono text-xs`,rows:4,maxLength:ys,autoComplete:`off`,spellCheck:!1,value:_,disabled:H,onChange:e=>{!I.current&&!R.current&&(ie(),v(e.target.value))}}),(0,$.jsx)(`label`,{htmlFor:`${e}-import-password`,className:`block text-sm`,children:u(`share_import_passphrase`)}),(0,$.jsx)(Z,{id:`${e}-import-password`,type:`password`,autoComplete:`off`,maxLength:bs,value:y,disabled:H,onChange:e=>{!I.current&&!R.current&&(ie(),b(e.target.value))}}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,disabled:H||!_.trim(),onClick:()=>void de(),children:u(te===`preview`?`share_working`:`share_preview`)}),x&&(0,$.jsxs)(`div`,{className:`space-y-3`,role:`region`,"aria-label":u(`share_preview`),children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`share_redacted_hint`)}),x.apply_blocked&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:u(`share_boundary_blocked`)}),x.warnings?.includes(`automatic_provider_authentication_blocked`)&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:u(`share_provider_auth_blocked`)}),x.warnings?.includes(`credential_key_uninitialized`)&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:u(`share_key_uninitialized`)}),x.preview.contains_secrets&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:u(`share_contains_secrets`)}),zs(x).map(e=>{let t=Hs(C,e)??{action:`replace`},n=t=>{!I.current&&!R.current&&(E(!1),w({...C,[e.group]:{...C[e.group],[e.id]:t}}))};return(0,$.jsxs)(`div`,{className:`space-y-2 rounded border p-2`,children:[(0,$.jsxs)(`div`,{className:`text-sm break-words`,children:[e.label,e.conflict?` · ${u(`share_conflict`)}`:` · ${u(`share_addition`)}`,e.secret?` · ${u(`share_hidden_value`)}`:``]}),e.provider&&(0,$.jsxs)(`dl`,{className:`space-y-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`dt`,{className:`inline`,children:[u(`share_imported_provider_type`),`: `]}),(0,$.jsx)(`dd`,{className:`inline break-all font-mono`,children:e.provider.provider_type})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`dt`,{className:`inline`,children:[u(`share_imported_origin`),`: `]}),(0,$.jsx)(`dd`,{className:`inline break-all font-mono`,children:e.provider.source_origin??u(t.action===`rename`||!e.conflict?`share_origin_provider_default`:`share_origin_keep_current`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`dt`,{className:`inline`,children:[u(`share_current_origin`),`: `]}),(0,$.jsx)(`dd`,{className:`inline break-all font-mono`,children:e.provider.target_origin??u(`share_origin_unknown`)})]})]}),e.provider?.replace_allowed===!1&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`share_provider_type_mismatch`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[u(`share_action`),(0,$.jsxs)(`select`,{"aria-label":`${u(`share_action`)} ${e.group}:${e.id}`,className:`settings-select`,value:t.action,disabled:H,onChange:e=>n(e.target.value===`rename`?{action:`rename`,target:``}:{action:e.target.value}),children:[(0,$.jsx)(`option`,{value:`skip`,children:u(`share_skip`)}),(0,$.jsx)(`option`,{value:`replace`,disabled:e.provider?.replace_allowed===!1,children:e.conflict?u(`share_replace`):u(`share_import_item`)}),e.group!==`scenarios`&&(0,$.jsx)(`option`,{value:`rename`,children:u(`share_rename`)})]})]}),e.provider?.replace_allowed&&e.provider.credential_origin_risk&&t.action===`replace`&&(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:u(`share_retained_key_origin_warning`,{origin:e.provider.source_origin})}),t.action===`rename`&&(0,$.jsx)(Z,{"aria-label":`${u(`share_new_name`)} ${e.group}:${e.id}`,value:t.target,disabled:H,maxLength:128,onChange:e=>n({action:`rename`,target:e.target.value})})]},`${e.group}:${e.id}`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`share_reference_hint`)}),(0,$.jsx)(Ks,{label:u(`share_review_confirm`),checked:T,disabled:H,onChange:E}),(0,$.jsx)(Y,{type:`button`,disabled:H||x.apply_blocked||!T||!!he||!!ge,onClick:()=>void _e(),children:u(te===`apply`?`share_working`:`share_apply`)})]}),R.current&&(0,$.jsx)(Y,{type:`button`,variant:`outline`,disabled:!!te,onClick:()=>void ve(),children:u(`share_check_result`)}),R.current&&(0,$.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:u(`share_receipt`,{id:R.current})}),D?.state===`committed`&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`share_receipt`,{id:D.operation_id})}),D?.state===`committed`&&k&&(0,$.jsx)(Y,{type:`button`,variant:`outline`,disabled:!!te,onClick:()=>void ye(),children:u(`share_refresh_saved`)}),j&&(0,$.jsx)(Y,{type:`button`,variant:`outline`,disabled:!!te,onClick:()=>void ye(),children:u(`share_refresh_current`)})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,onClick:ae,disabled:te===`apply`||te===`check`||te===`refresh`||!!R.current,children:u(`share_cancel`)}),N&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:N}),ee&&(0,$.jsx)(`p`,{role:`status`,className:`text-sm`,children:ee})]})}function Js({label:e,value:t}){return o(),(0,$.jsxs)(`div`,{className:`settings-stat`,children:[(0,$.jsx)(`div`,{className:`settings-stat-value`,children:t??0}),(0,$.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e})]})}function Ys(){let e=o(),[t,n]=(0,Q.useState)(!1),r=Xe(e=>e.themePreference),i=Xe(e=>e.themeMode),a=Xe(e=>e.setThemePreference),c=Xe(e=>e.userMessageColorPreset),d=Xe(e=>e.customUserMessageColor),f=Xe(e=>e.setUserMessageColorPreset),m=Xe(e=>e.setCustomUserMessageColor),h=Xe(e=>e.globalAccentPreset),g=Xe(e=>e.customGlobalAccentColor),_=Xe(e=>e.setGlobalAccentPreset),v=Xe(e=>e.setCustomGlobalAccentColor),y=At(e=>e.mode),b=At(e=>e.setMode),[x,S]=(0,Q.useState)(null),C=(0,Q.useId)(),w=(0,Q.useId)(),T=(0,Q.useId)(),E=(0,Q.useId)(),D=(0,Q.useId)(),O=(0,Q.useId)(),k=(0,Q.useId)(),A=(0,Q.useId)(),j=(0,Q.useId)(),M=Ye(i,c,d),N=qe(i,h,g);return(0,Q.useEffect)(()=>{Mt.getSummary().then(S).catch(()=>S(null))},[]),(0,$.jsxs)(`div`,{className:`settings-general`,children:[(0,$.jsxs)(`div`,{className:`settings-preferences`,children:[(0,$.jsxs)(`section`,{className:`settings-row settings-row-responsive`,children:[(0,$.jsx)(`label`,{htmlFor:`app-language`,className:`text-sm font-medium`,children:u(`language_label`)}),(0,$.jsxs)(`div`,{className:`settings-language`,children:[(0,$.jsxs)(`select`,{id:`app-language`,value:e,className:`settings-select`,onChange:e=>{let t=e.target.value;s(t)&&(n(!1),l(t,{persist:!0}).catch(()=>n(!0)))},children:[(0,$.jsx)(`option`,{value:`en-US`,children:`English`}),(0,$.jsx)(`option`,{value:`zh-CN`,children:`简体中文`}),(0,$.jsx)(`option`,{value:`zh-TW`,children:`繁體中文`}),(0,$.jsx)(`option`,{value:`fr-FR`,children:`Français`}),(0,$.jsx)(`option`,{value:`ja-JP`,children:`日本語`}),(0,$.jsx)(`option`,{value:`hi-IN`,children:`हिन्दी`})]}),t&&(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-destructive`,children:u(`language_load_failed`)})]})]}),(0,$.jsxs)(`section`,{className:`settings-row settings-row-responsive`,children:[(0,$.jsx)(`h3`,{id:C,className:`text-sm font-medium`,children:u(`appearance_86a63f23`)}),(0,$.jsx)(`div`,{role:`group`,"aria-labelledby":C,className:`settings-choice-group`,children:[`light`,`dark`,`system`].map(e=>(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,"aria-pressed":r===e,className:`settings-choice`,onClick:()=>a(e),children:[(0,$.jsx)(e===`light`?Tt:e===`dark`?_t:p,{"aria-hidden":`true`,className:`size-4`}),u(e===`light`?`light_aa0819df`:e===`dark`?`dark_a6b75d06`:`system_217cfe7d`)]},e))})]}),(0,$.jsxs)(`section`,{className:`settings-row`,children:[(0,$.jsx)(`h3`,{id:w,className:`text-sm font-medium`,children:u(`accent_color`)}),(0,$.jsx)(`p`,{id:T,className:`settings-description`,children:u(`accent_color_hint`)}),(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":w,"aria-describedby":T,className:`settings-accent-options`,children:[Je.map(e=>(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,className:`settings-accent-option`,"aria-pressed":h===e.id,onClick:()=>_(e.id),children:[(0,$.jsx)(`span`,{className:`settings-color-swatch`,style:{backgroundColor:e[i].primary},"aria-hidden":`true`}),u(`accent_${e.id}`)]},e.id)),(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,className:`settings-accent-option`,"aria-pressed":h===`custom`,onClick:()=>_(`custom`),children:[(0,$.jsx)(`span`,{className:`settings-color-swatch`,style:{backgroundColor:g},"aria-hidden":`true`}),u(`accent_custom`)]})]}),(0,$.jsxs)(`div`,{className:`settings-accent-custom`,children:[(0,$.jsx)(`label`,{htmlFor:E,children:u(`accent_custom_color`)}),(0,$.jsx)(`input`,{id:E,type:`color`,value:g,onInput:e=>v(e.currentTarget.value),onChange:e=>v(e.target.value)}),(0,$.jsx)(`span`,{children:g.toUpperCase()})]}),(0,$.jsxs)(`div`,{className:`settings-accent-preview`,children:[(0,$.jsxs)(`div`,{className:`settings-accent-preview-sample`,children:[(0,$.jsx)(Y,{size:`sm`,style:{backgroundColor:N.primary,color:N.primaryForeground},children:u(`accent_preview`)}),(0,$.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold`,style:{backgroundColor:N.accent,color:N.accentForeground},children:`Active`}),(0,$.jsx)(`span`,{className:`inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium`,style:{borderColor:N.primary,color:N.primary},children:`Focus`})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:N.primary.toUpperCase()})]})]}),(0,$.jsxs)(`section`,{className:`settings-row`,children:[(0,$.jsx)(`h3`,{id:k,className:`text-sm font-medium`,children:u(`bubble_colors`)}),(0,$.jsx)(`p`,{id:A,className:`settings-description`,children:u(`bubble_colors_hint`)}),(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":k,"aria-describedby":A,className:`settings-bubble-options`,children:[Ke.map(e=>(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,className:`settings-bubble-option`,"aria-pressed":c===e.id,onClick:()=>f(e.id),children:[(0,$.jsx)(`span`,{className:`settings-color-swatch`,style:{backgroundColor:e[i]},"aria-hidden":`true`}),u(`bubble_${e.id}`)]},e.id)),(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,className:`settings-bubble-option`,"aria-pressed":c===`custom`,onClick:()=>f(`custom`),children:[(0,$.jsx)(`span`,{className:`settings-color-swatch`,style:{backgroundColor:d},"aria-hidden":`true`}),u(`bubble_custom`)]})]}),(0,$.jsxs)(`div`,{className:`settings-bubble-custom`,children:[(0,$.jsx)(`label`,{htmlFor:j,children:u(`bubble_custom_color`)}),(0,$.jsx)(`input`,{id:j,type:`color`,value:d,onInput:e=>m(e.currentTarget.value),onChange:e=>m(e.target.value)}),(0,$.jsx)(`span`,{children:d.toUpperCase()})]}),(0,$.jsx)(`div`,{className:`settings-bubble-preview`,children:(0,$.jsx)(`p`,{style:{backgroundColor:M.background,color:M.foreground},children:u(`bubble_preview`)})})]}),(0,$.jsxs)(`section`,{className:`settings-row settings-row-responsive`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{id:D,className:`text-sm font-medium`,children:u(`experience_mode_94057abe`)}),(0,$.jsx)(`p`,{id:O,className:`settings-description`,children:u(`simple_mode_hides_advanced_settings_such_as_skills_envi_23e359c3`)})]}),(0,$.jsx)(`div`,{role:`group`,"aria-labelledby":D,"aria-describedby":O,className:`settings-choice-group`,children:[`simple`,`advanced`].map(e=>(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,"aria-pressed":y===e,className:`settings-choice settings-choice-mode`,onClick:()=>b(e),children:u(e===`simple`?`simple_aa55960e`:`advanced_d6e61888`)},e))})]}),(0,$.jsxs)(`section`,{className:`settings-row`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:u(`default_model_1e2933c6`)}),(0,$.jsx)(`p`,{className:`settings-description settings-description-wide`,children:u(`configure_defaults_under_providers_default_model_prefer_c7136d2f`)})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-3 text-sm font-medium`,children:u(`usage_statistics_3ce933a3`)}),x?(0,$.jsxs)(`div`,{className:`settings-stat-grid`,children:[(0,$.jsx)(Js,{label:u(`total_sessions_ef3cbace`),value:x.total_sessions}),(0,$.jsx)(Js,{label:u(`active_dc9591e5`),value:x.active_sessions}),(0,$.jsx)(Js,{label:u(`completed_f28461bb`),value:x.completed_sessions}),(0,$.jsx)(Js,{label:u(`tool_calls_a8ca3c13`),value:x.total_tool_calls}),(0,$.jsx)(Js,{label:u(`errors_01ad2bc5`),value:x.error_sessions}),(0,$.jsx)(Js,{label:u(`tokens_saved_2bc165cb`),value:x.total_tokens_saved})]}):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`loading_4927a53b`)})]}),(0,$.jsxs)(`section`,{className:`settings-about`,children:[(0,$.jsx)(`h3`,{className:`text-muted-foreground`,children:u(`about_52d25a9e`)}),(0,$.jsx)(`p`,{className:`font-medium`,children:`Bodhi · lotus-next`})]})]})}var Xs=[{id:`general`,icon:St,get label(){return u(`general_835b700e`)},render:()=>(0,$.jsx)(Ys,{})},{id:`providers`,icon:pt,get label(){return u(`provider_9e218722`)},render:()=>(0,$.jsx)(Dn,{})},{id:`config-share`,icon:Ct,get label(){return u(`share_title`)},render:()=>(0,$.jsx)(qs,{})},{id:`model-limits`,icon:ht,get label(){return u(`model_limits_05ff605e`)},render:()=>(0,$.jsx)(ds,{})},{id:`retry`,icon:xt,get label(){return u(`retry_settings_1a7c4e91`)},render:()=>(0,$.jsx)(gs,{})},{id:`mcp`,icon:bt,label:`MCP`,render:()=>(0,$.jsx)(Or,{})},{id:`plugins`,icon:ut,get label(){return u(`plugins_e806fbbe`)},render:()=>(0,$.jsx)(li,{})},{id:`skills`,icon:m,get label(){return u(`skills_99aea2f9`)},render:()=>(0,$.jsx)(ui,{})},{id:`permissions`,icon:wt,get label(){return u(`permission_978cbca6`)},render:()=>(0,$.jsx)(pi,{})},{id:`env`,icon:F,get label(){return u(`environment_variables_ae27b474`)},render:()=>(0,$.jsx)(mi,{})},{id:`schedules`,icon:dt,get label(){return u(`scheduled_tasks_3c39e9bd`)},render:()=>(0,$.jsx)(Wi,{})},{id:`notifications`,icon:lt,get label(){return u(`notifications_4b6ded8a`)},render:()=>(0,$.jsx)(na,{})},{id:`masking`,icon:wt,get label(){return u(`keyword_masking_62e701d9`)},render:()=>(0,$.jsx)(ia,{})},{id:`prompts`,icon:v,get label(){return u(`prompts_4b47dbae`)},render:()=>(0,$.jsx)(oa,{})},{id:`workflows`,icon:he,get label(){return u(`workflow_c71d0bca`)},render:()=>(0,$.jsx)(ca,{})},{id:`clusters`,icon:_,get label(){return u(`clusters_5318ca46`)},render:()=>(0,$.jsx)(va,{})},{id:`metrics`,icon:ft,get label(){return u(`metrics_b87e67c7`)},render:()=>(0,$.jsx)(wo,{})},{id:`jiandu`,icon:mt,get label(){return u(`jiandu_memory_6567932c`)},render:()=>(0,$.jsx)(Zo,{})},{id:`system`,icon:p,get label(){return u(`system_5b50d7c4`)},render:()=>(0,$.jsx)(Yo,{})}],Zs=[{get label(){return u(`settings_group_appearance`)},tabs:[`general`,`notifications`]},{get label(){return u(`settings_group_connections`)},tabs:[`providers`,`config-share`,`model-limits`,`retry`,`mcp`,`clusters`]},{get label(){return u(`settings_group_capabilities`)},tabs:[`plugins`,`skills`,`prompts`,`workflows`,`schedules`,`jiandu`]},{get label(){return u(`settings_group_safety`)},tabs:[`permissions`,`masking`,`env`,`metrics`,`system`]}];function Qs({tab:e,onTabChange:t}){o();let n=(0,Q.useId)(),r=At(e=>e.isAdvanced)?Xs:Xs.filter(e=>!Ot.has(e.id)),i=r.find(t=>t.id===e)??Xs[0],a=Zs.map(e=>({label:e.label,tabs:e.tabs.map(e=>r.find(t=>t.id===e)).filter(e=>e!==void 0)})).filter(e=>e.tabs.length>0);return(0,$.jsxs)(`div`,{className:`settings-layout`,children:[(0,$.jsxs)(`div`,{className:`settings-mobile-nav`,children:[(0,$.jsx)(`label`,{htmlFor:`settings-category`,className:`sr-only`,children:u(`system_settings_68ea5dd4`)}),(0,$.jsx)(`select`,{id:`settings-category`,value:i.id,onChange:e=>{let n=r.find(t=>t.id===e.target.value);n&&t(n.id)},className:`settings-select`,children:a.map(e=>(0,$.jsx)(`optgroup`,{label:e.label,children:e.tabs.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))},e.label))})]}),(0,$.jsx)(`nav`,{"aria-label":u(`system_settings_68ea5dd4`),className:`settings-nav`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`settings-nav-group`,children:[(0,$.jsx)(`h3`,{className:`settings-nav-heading`,children:e.label}),(0,$.jsx)(`div`,{className:`settings-nav-links`,children:e.tabs.map(e=>{let n=e.icon;return(0,$.jsxs)(`button`,{type:`button`,"aria-current":i.id===e.id?`page`:void 0,onClick:()=>t(e.id),className:`settings-nav-item`,children:[(0,$.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0`}),e.label]},e.id)})})]},e.label))}),(0,$.jsx)(`div`,{className:`settings-scroll`,children:(0,$.jsxs)(`div`,{role:`region`,"aria-labelledby":n,className:X(`settings-panel motion-content-enter`,(i.id===`model-limits`||i.id===`metrics`)&&`settings-panel-wide`),children:[(0,$.jsxs)(`div`,{className:`settings-panel-heading`,children:[(0,$.jsx)(`h2`,{id:n,className:`settings-title`,children:i.label}),(0,$.jsx)(`p`,{className:`settings-panel-hint`,children:u(`settings_hint_${i.id}`)})]}),i.render()]},i.id)})]})}export{Qs as SettingsContent};