@cuongtran001/kanna 1.94.2 → 1.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{BoardsPage-CcEgSKEH.js → BoardsPage-J03IilS6.js} +1 -1
- package/dist/client/assets/{BoardsRoutePage-DYG2WpTB.js → BoardsRoutePage-C9ruZTAp.js} +1 -1
- package/dist/client/assets/ChatPage-Br846W9n.js +35 -0
- package/dist/client/assets/{CronJobsPage-LCRBV65t.js → CronJobsPage-VpFQ8to7.js} +1 -1
- package/dist/client/assets/{FilePreviewSheet-DK4JlQ4b.js → FilePreviewSheet-CfrHVm3Z.js} +2 -2
- package/dist/client/assets/{FlowSurface-B34Ui27C.js → FlowSurface-CwMymdE7.js} +1 -1
- package/dist/client/assets/{GenUIBlock-B90q9Hoz.js → GenUIBlock-BNjeGZYW.js} +2 -2
- package/dist/client/assets/{InboundHandlerFields-CrbQcRFr.js → InboundHandlerFields-CxNZ0mLE.js} +1 -1
- package/dist/client/assets/{InboxPage-CcU-wMdJ.js → InboxPage-dS7nGsdx.js} +1 -1
- package/dist/client/assets/{LocalProjectsPage-Csj-YWVf.js → LocalProjectsPage-CuTu5jpZ.js} +1 -1
- package/dist/client/assets/SettingsPage-BCV0w9Vi.js +17 -0
- package/dist/client/assets/{StackBoardsRoutePage-qh4CMVbO.js → StackBoardsRoutePage-7wFhv0_e.js} +1 -1
- package/dist/client/assets/{ToolCallMessage-36Dj7xkk.js → ToolCallMessage-BdnXHucS.js} +1 -1
- package/dist/client/assets/{VChartSurface-CcMrzPBy.js → VChartSurface-Cstkrqkr.js} +1 -1
- package/dist/client/assets/{WebhooksPage-5KNcw-Vz.js → WebhooksPage-vMuFDMp6.js} +1 -1
- package/dist/client/assets/{WorkflowsPage-DNYcsvtV.js → WorkflowsPage-CKSmQTVr.js} +1 -1
- package/dist/client/assets/{appSettingsStore-LgzUNvfd.js → appSettingsStore-fU_N20LE.js} +1 -1
- package/dist/client/assets/{arrow-left-BIWqzCsH.js → arrow-left-CMvFX3PN.js} +1 -1
- package/dist/client/assets/{beacon-alias-DxONetqC.js → beacon-alias-BLR2AbFH.js} +3 -3
- package/dist/client/assets/{chunk-OB3PAWPO-zund-gx-.js → chunk-6KYCQHYJ-C0N1h4Su.js} +1 -1
- package/dist/client/assets/{code-xml-BfYZcKk2.js → code-xml-Bz3Pw469.js} +1 -1
- package/dist/client/assets/{commandFeedback-yC5d0Ae6.js → commandFeedback-CJUPA0qJ.js} +1 -1
- package/dist/client/assets/{contextWindow-pvBJBrsH.js → contextWindow-DOCh4Cvd.js} +1 -1
- package/dist/client/assets/{copyFeedbackStore-BpFUDutm.js → copyFeedbackStore-CA3R4Lkw.js} +1 -1
- package/dist/client/assets/{createScopedStore-Ba9K_10X.js → createScopedStore-Bwg_GPUf.js} +1 -1
- package/dist/client/assets/{cronJobsStore-Dehc4edG.js → cronJobsStore-BLB0Vehu.js} +1 -1
- package/dist/client/assets/{file-plus-corner-DWHF_kbn.js → file-plus-corner-D_lIlmxu.js} +1 -1
- package/dist/client/assets/{github-dark-default-adAWTKmX.js → github-dark-default-CM8LCIj6.js} +1 -1
- package/dist/client/assets/highlights-BNrfEgy9.js +3 -0
- package/dist/client/assets/{inboxStore-BxT26bsM.js → inboxStore-YuvJrOoh.js} +1 -1
- package/dist/client/assets/index-DSzVkIcK.js +85 -0
- package/dist/client/assets/{index-JXlKTAWE.css → index-D_XO3fZ-.css} +1 -1
- package/dist/client/assets/{info-Ba70747-.js → info-QOQ2TnKq.js} +1 -1
- package/dist/client/assets/{input-BY7tE022.js → input-SQ_NQ4i3.js} +1 -1
- package/dist/client/assets/{loader-BxIVfMhW.js → loader-Dbltcnnq.js} +1 -1
- package/dist/client/assets/{log-DxnWb_y2.js → log-CSvFzOgk.js} +1 -1
- package/dist/client/assets/minus-4P2PfMQ9.js +1 -0
- package/dist/client/assets/{monitor-ByZxj7H9.js → monitor-Cq4Xva5_.js} +1 -1
- package/dist/client/assets/{pencil-41SXT97L.js → pencil-KyJnUAFc.js} +1 -1
- package/dist/client/assets/{pendingActionsStore-BEJnZIRD.js → pendingActionsStore-BAMMp6is.js} +1 -1
- package/dist/client/assets/{plus-CVyLwE7_.js → plus-CD0ryc0u.js} +1 -1
- package/dist/client/assets/{react-CZBv4gq-.js → react-B_ssCuNh.js} +4 -4
- package/dist/client/assets/{refresh-cw-CLCXCzaY.js → refresh-cw-BZhFl6k9.js} +1 -1
- package/dist/client/assets/runDetached-6EapWBGL.js +1 -0
- package/dist/client/assets/{search-BabRSZmb.js → search-C00xf7Dr.js} +1 -1
- package/dist/client/assets/{searchable-select-prsU5V9D.js → searchable-select-Bb-64ppm.js} +1 -1
- package/dist/client/assets/{segmented-control-BdqpOGH3.js → segmented-control-WauTv4kI.js} +1 -1
- package/dist/client/assets/{select-BuN3bPMQ.js → select-aSIMmCY4.js} +1 -1
- package/dist/client/assets/{settings-header-button-BkDztcVR.js → settings-header-button-HRGFRld7.js} +1 -1
- package/dist/client/assets/{shiki-CCur_AjT.js → shiki-Dr1ftTui.js} +1 -1
- package/dist/client/assets/{state-mark-BoV1BBc0.js → state-mark-D2ronAPV.js} +1 -1
- package/dist/client/assets/{stream-tokenizer-B5Lrlknv.js → stream-tokenizer-Dusn-8y-.js} +1 -1
- package/dist/client/assets/{terminal-uWEJ91yR.js → terminal-CE7sC7nZ.js} +1 -1
- package/dist/client/assets/{themes-B2qJmig7.js → themes-Bahc5xK2.js} +1 -1
- package/dist/client/assets/{timer.adapter-BX7ibpTi.js → timer.adapter-obf6icc9.js} +1 -1
- package/dist/client/assets/{tools-B59RcrVm.js → tools-DE7C49T-.js} +1 -1
- package/dist/client/assets/{triangle-alert-D3aY6mGU.js → triangle-alert-DgVGhRHG.js} +1 -1
- package/dist/client/assets/useAppGlobalState-DZp5teQX.js +1 -0
- package/dist/client/assets/{useProviderCatalog-BJE2nJJQ.js → useProviderCatalog-Bm7q2MH2.js} +1 -1
- package/dist/client/assets/{useTheme-CuVmsdqy.js → useTheme-BU3AlCLI.js} +1 -1
- package/dist/client/index.html +33 -33
- package/package.json +10 -10
- package/src/server/event-store-transcript-write.adapter.ts +3 -0
- package/src/server/event-store.test.ts +16 -0
- package/src/server/event-store.ts +1 -0
- package/src/server/inbound/deliver-inbound.test.ts +7 -0
- package/src/server/inbound/deliver-inbound.ts +2 -0
- package/src/server/inbox/inbox-boot.test.ts +1 -0
- package/src/server/inbox/inbox-registry.ts +2 -1
- package/src/server/mcp-sources/mcp-source-client.adapter.test.ts +134 -15
- package/src/server/mcp-sources/mcp-source-client.adapter.ts +57 -11
- package/src/server/mcp-sources/mcp-source-fetch.ts +78 -0
- package/src/server/mcp-sources/mcp-source-runner.test.ts +175 -6
- package/src/server/mcp-sources/mcp-source-runner.ts +90 -47
- package/src/server/mcp-sources-settings.test.ts +24 -0
- package/src/server/mcp-sources-settings.ts +20 -4
- package/src/server/uploads.test.ts +7 -3
- package/src/server/ws-router-abandoned-chat.test.ts +93 -0
- package/src/server/ws-router-broadcast.ts +45 -1
- package/src/server/ws-router.ts +6 -1
- package/src/shared/mcp-sources/presets.ts +16 -25
- package/src/shared/mcp-sources/types.schema.ts +20 -2
- package/src/shared/mcp-sources/types.ts +14 -1
- package/src/shared/mcp-sources/validate.test.ts +12 -17
- package/src/shared/mcp-sources/validate.ts +1 -1
- package/dist/client/assets/ChatPage-CUa9Mlv0.js +0 -35
- package/dist/client/assets/SettingsPage-BFnBY3op.js +0 -16
- package/dist/client/assets/highlights-CFT8RIMY.js +0 -3
- package/dist/client/assets/index-CRk0GD4y.js +0 -93
- package/dist/client/assets/minus-DpkN1lgU.js +0 -1
- package/dist/client/assets/runDetached-K6ggut3D.js +0 -1
- package/dist/client/assets/useAppGlobalState-vHoqoq7W.js +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{l as n,u as r}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{A as a,At as o,E as s,Mt as c,N as l,Nt as u,P as d,Pt as f,St as p,T as m,Tt as h,U as g,_,a as v,c as y,d as b,g as x,h as S,ht as ee,j as C,l as te,m as w,n as ne,o as re,s as ie,u as ae,wt as T}from"./useAppGlobalState-DZp5teQX.js";import{a as oe,d as E,f as D,h as O,i as se,l as k,m as A,n as j,o as ce,r as M,t as N,u as le}from"./pendingActionsStore-BAMMp6is.js";import{a as ue,l as de,n as fe,o as pe}from"./beacon-alias-BLR2AbFH.js";import{a as me,i as he,n as ge,o as _e,t as ve}from"./copyFeedbackStore-CA3R4Lkw.js";import{a as ye,i as P,n as be,o as xe,r as Se,t as Ce}from"./select-aSIMmCY4.js";import{t as we}from"./info-QOQ2TnKq.js";import{c as Te,r as Ee,s as De}from"./contextWindow-DOCh4Cvd.js";import{t as Oe}from"./monitor-Cq4Xva5_.js";import{t as ke}from"./pencil-KyJnUAFc.js";import{t as Ae}from"./plus-CD0ryc0u.js";import{t as je}from"./refresh-cw-BZhFl6k9.js";import{t as Me}from"./search-C00xf7Dr.js";import{A as Ne,B as Pe,C as Fe,D as Ie,E as Le,F as Re,L as ze,M as Be,N as Ve,O as He,P as Ue,R as We,T as Ge,U as Ke,V as qe,Z as Je,a as Ye,c as Xe,i as Ze,o as Qe,r as $e,s as et,t as tt,w as nt,z as rt}from"./useProviderCatalog-Bm7q2MH2.js";import{g as it,i as at,n as ot,o as st,r as ct,t as lt,u as ut}from"./timer.adapter-obf6icc9.js";import{a as dt,c as ft,o as pt,s as mt,t as F}from"./segmented-control-WauTv4kI.js";import{d as ht,f as I,i as gt,n as L,r as _t,s as vt}from"./log-CSvFzOgk.js";import{t as R}from"./input-SQ_NQ4i3.js";import{f as yt,i as bt,o as xt,u as St}from"./core-types-Ds7PFmZN.js";import{$ as Ct,A as wt,B as Tt,C as Et,D as Dt,E as Ot,G as kt,H as At,I as jt,J as Mt,K as Nt,M as Pt,O as Ft,Q as It,S as Lt,T as Rt,U as zt,V as Bt,W as Vt,X as Ht,Y as Ut,_ as z,a as Wt,c as Gt,d as Kt,f as qt,g as Jt,h as Yt,i as Xt,it as Zt,j as Qt,k as $t,l as en,lt as tn,m as nn,n as rn,nt as an,o as on,p as sn,q as cn,r as ln,rt as un,s as dn,st as fn,t as pn,tt as mn,u as hn,y as gn}from"./appSettingsStore-fU_N20LE.js";import{M as _n,N as vn,iu as yn,j as bn,r as xn,ru as Sn}from"./useTheme-BU3AlCLI.js";import{t as Cn}from"./runDetached-6EapWBGL.js";import{t as wn}from"./dom.adapter-C26vNdMA.js";import{_ as Tn,a as B,g as En,h as Dn,r as On,y as kn}from"./commandFeedback-CJUPA0qJ.js";import{a as An,n as jn}from"./state-mark-D2ronAPV.js";import{n as Mn,t as Nn}from"./formatDuration-BbWTR_M_.js";import{n as Pn}from"./cronJobsStore-BLB0Vehu.js";import{Jt as Fn,bt as In,ln as Ln,pn as Rn,vt as zn,yt as Bn}from"./index-DSzVkIcK.js";import{_ as Vn,c as Hn,d as Un,g as Wn,l as Gn,s as Kn,u as qn,v as Jn,x as Yn,y as Xn}from"./ChatPage-Br846W9n.js";import{a as Zn,c as Qn,d as $n,f as er,i as tr,l as nr,o as rr,p as ir,s as ar,t as or,u as sr}from"./searchable-select-Bb-64ppm.js";import{t as cr}from"./settings-header-button-HRGFRld7.js";import{t as lr}from"./InboundHandlerFields-CxNZ0mLE.js";var ur={name:`antenna`,size:24,node:[[`path`,{d:`M2 12 7 2`,key:`117k30`}],[`path`,{d:`m7 12 5-10`,key:`1tvx22`}],[`path`,{d:`m12 12 5-10`,key:`ev1o1a`}],[`path`,{d:`m17 12 5-10`,key:`1e4ti3`}],[`path`,{d:`M4.5 7h15`,key:`vlsxkz`}],[`path`,{d:`M12 16v6`,key:`c8a4gj`}]]};ur.node;var dr=O(ur),fr={name:`book-text`,size:24,node:[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]};fr.node;var pr=O(fr),mr={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};mr.node;var hr=O(mr),gr={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};gr.node;var _r=O(gr),vr={name:`command`,size:24,node:[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]};vr.node;var yr=O(vr),br={name:`cpu`,size:24,node:[[`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`}]]};br.node;var xr=O(br),Sr={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};Sr.node;var Cr=O(Sr),wr={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};wr.node;var Tr=O(wr),Er={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Er.node;var Dr=O(Er),Or={name:`moon`,size:24,node:[[`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`}]]};Or.node;var kr=O(Or),Ar={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};Ar.node;var jr=O(Ar),Mr={name:`plug`,size:24,node:[[`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`}]]};Mr.node;var Nr=O(Mr),Pr={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Pr.node;var Fr=O(Pr),Ir={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Ir.node;var Lr=O(Ir),Rr={name:`sun`,size:24,node:[[`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`}]]};Rr.node;var zr=O(Rr),Br={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};Br.node;var Vr=O(Br),Hr={name:`waypoints`,size:24,node:[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]};Hr.node;var Ur=O(Hr),Wr={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},V=e(t(),1),H=e(i(),1);function Gr(e){let t=e.trim();if(t.startsWith(`https://`))try{let e=new URL(t);if(e.protocol!==`https:`)return!1;let n=e.hostname.toLowerCase();return!(n===`localhost`||!n.includes(`.`)||n.startsWith(`.`)||n.endsWith(`.`))}catch{return!1}if(t.startsWith(`mailto:`)){let e=t.slice(7),n=/^[^\s@]+@([^\s@]+)$/.exec(e);if(!n)return!1;let r=n[1].toLowerCase();return!(r===`localhost`||!r.includes(`.`)||r.startsWith(`.`)||r.endsWith(`.`))}return!1}var Kr={maxFileSizeMb:2048},qr={path:`uploads.maxFileSizeMb`,min:1,max:51200,integer:!1},Jr=I()(e=>({authEnabled:!1,setAuthEnabled:t=>e({authEnabled:t})}));function U({title:e,description:t,children:n,bordered:r=!0,alignStart:i=!1}){return(0,H.jsx)(`div`,{className:r?`border-t border-border`:void 0,children:(0,H.jsxs)(`div`,{className:D(`flex flex-col gap-4 py-5 md:flex-row md:justify-between md:gap-8`,i?`md:items-start`:`md:items-center`),children:[(0,H.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),(0,H.jsx)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:t})]}),(0,H.jsx)(`div`,{className:`flex items-center justify-start md:shrink-0 md:justify-end`,children:n})]})})}function Yr({icon:e,message:t}){return(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md border border-dashed px-6 py-10 text-center`,children:[(0,H.jsx)(e,{className:`mb-3 h-8 w-8 text-muted-foreground`,"aria-hidden":!0}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function Xr({children:e}){return(0,H.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function Zr({label:e,onEdit:t,onDelete:n,deletePending:r=!1}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Edit ${e}`,children:(0,H.jsx)(ke,{className:`h-4 w-4`})}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:n,pending:r,"aria-label":`Delete ${e}`,children:(0,H.jsx)(Je,{className:`h-4 w-4`})})]})}var Qr=new Set([`checking`,`downloading`,`installing`,`restarting`]);function $r(e){return e!==null&&Qr.has(e.state)}function ei(e){switch(e.state){case`checking`:return`Checking ${e.version}…`;case`downloading`:return`Downloading ${e.version}…`;case`installing`:return`Installing ${e.version}…`;case`restarting`:return`Restarting…`;case`current`:return`Up to date`;case`failed`:return e.message===void 0?`Update failed`:`Update failed: ${e.message}`}}function ti(e){switch(e.state){case`failed`:return`destructive`;case`current`:return`muted`;case`checking`:case`downloading`:case`installing`:case`restarting`:return`active`}}var ni={},ri={},ii={},ai={};function oi(e,t){return`${e}:${t}`}function si(e,t,n){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e!==t));return Object.keys(r).length>0?r:n}var W=I()(e=>({pairing:null,expandedId:null,drafts:ni,updateErrors:ri,aliasErrors:ii,openExplanations:ai,setPairing:t=>e({pairing:t}),toggleExpanded:t=>e(e=>({expandedId:e.expandedId===t?null:t})),setDraft:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:n}})),clearDraft:t=>e(e=>({drafts:si(e.drafts,t,ni)})),setUpdateError:(t,n)=>e(e=>n===null?{updateErrors:si(e.updateErrors,t,ri)}:{updateErrors:{...e.updateErrors,[t]:n}}),beginAliasEdit:(t,n)=>e(e=>({drafts:{...e.drafts,[oi(t,`alias`)]:n}})),endAliasEdit:t=>e(e=>({drafts:si(e.drafts,oi(t,`alias`),ni),aliasErrors:si(e.aliasErrors,t,ii)})),setAliasError:(t,n)=>e(e=>n===null?{aliasErrors:si(e.aliasErrors,t,ii)}:{aliasErrors:{...e.aliasErrors,[t]:n}}),toggleExplanation:t=>e(e=>({openExplanations:t in e.openExplanations?si(e.openExplanations,t,ai):{...e.openExplanations,[t]:!0}}))})),ci=`kanna-beacon`,li=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`,ui=`https://github.com/cuongtranba/kanna/releases/latest`;RegExp(`^[${li}]{8}$`);function di(e){return`${ci}://pair?url=${encodeURIComponent(e.kannaUrl)}&code=${encodeURIComponent(e.code)}`}function fi(e){return`kanna-beacon pair ${e.kannaUrl} ${e.code}`}function pi(e){return e.replace(/^v/,``).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10))}function mi(e,t){if(e===t)return!1;let n=pi(e),r=pi(t),i=Math.max(n.length,r.length);for(let a=0;a<i;a+=1){let i=n[a]??0,o=r[a]??0;if(Number.isNaN(i)||Number.isNaN(o))return e<t;if(i!==o)return i<o}return!1}var hi={outdated:`border-warning/40 text-warning-text bg-warning/10`,partial:`border-warning/40 text-warning-text bg-warning/10`,unknown:`border-border text-muted-foreground bg-muted/40`};function gi({beaconId:e,alias:t,displayName:n}){let r=W(e=>e.beginAliasEdit),i=(0,V.useCallback)(()=>{r(e,t??``)},[t,e,r]);return(0,H.jsx)(En,{label:`Set a short name`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":`Set a short name for ${n}`,children:(0,H.jsx)(ke,{className:`h-3.5 w-3.5`})})})}function _i({beaconId:e,alias:t,displayName:n,onSetAlias:r}){let i=oi(e,`alias`),a=W(e=>e.drafts[i]),o=W(t=>t.aliasErrors[e]??null),s=W(e=>e.setDraft),c=W(e=>e.setAliasError),l=W(e=>e.endAliasEdit),u=N(`beacons.setAlias`,e),d=M(u),f=a??``,p=f.length===0?null:ue(f),m=f.length>0&&p===null&&f!==t,h=p??o,g=(0,V.useCallback)(t=>{s(i,t.target.value.toLowerCase()),c(e,null)},[e,i,c,s]),_=(0,V.useCallback)(t=>{j(u,async()=>{try{await r(e,t),l(e)}catch(t){c(e,L(t))}})},[e,l,r,u,c]),v=(0,V.useCallback)(()=>{_(f)},[_,f]),y=(0,V.useCallback)(()=>{_(null)},[_]),b=(0,V.useCallback)(()=>{l(e)},[e,l]);return a===void 0?null:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(R,{value:f,onChange:g,placeholder:`office-mac`,disabled:d,"aria-label":`Short name for ${n}`,"aria-invalid":h!==null||void 0,className:`w-48`}),(0,H.jsx)(k,{size:`sm`,onClick:v,pending:d,disabled:!m,children:`Save`}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:b,disabled:d,children:`Cancel`}),t!==null&&(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:y,disabled:d,children:`Clear alias`})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Type `,(0,H.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,f.length>0?f:`name`]}),` in a message to refer to this machine.`]}),h!==null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive-text`,children:h})]})}var vi=`Lets the agent run commands and scripts on this machine. Off means every command and script is refused, and the agent can only read and copy files inside the folders below. When on, each command still waits for your approval unless it is on the always-run list or you switch on running without asking.`,yi=`Skips the approval prompt. Reads and writes inside the folders below, and every command and script, run immediately. Leave it off to review each action before it runs on this machine.`,bi=`The agent can list, search, read and copy files off this machine only inside these folders and their subfolders. Anything outside is refused. With none listed it cannot read from this machine at all. Each read waits for your approval unless running without asking is on.`,xi=`The agent can copy files onto this machine only inside these folders and their subfolders. Leave empty and it cannot write to this machine at all. Each write waits for your approval unless running without asking is on.`,Si=`Command names, such as git, that run immediately once running commands is allowed. Matching uses the command name only, so git covers every git subcommand. Anything not listed asks you first.`;function Ci(e){return`beacon-explain-${e}`}function wi({explanationKey:e,subject:t}){let n=W(t=>e in t.openExplanations),r=W(e=>e.toggleExplanation),i=(0,V.useCallback)(()=>{r(e)},[e,r]);return(0,H.jsx)(En,{label:`What does this do?`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-expanded":n,"aria-controls":Ci(e),"aria-label":`What does "${t}" do?`,children:(0,H.jsx)(we,{className:`h-4 w-4`})})})}function Ti({explanationKey:e,text:t}){let n=W(t=>e in t.openExplanations);return(0,H.jsx)(`p`,{id:Ci(e),hidden:!n,className:`text-13 text-muted-foreground`,children:t})}function Ei({beaconId:e,scope:t,onSetScope:n}){let r=N(`beacons.setScope`,e),i=M(r),a=(0,V.useCallback)(t=>{j(r,()=>n(e,t))},[e,n,r]),o=(0,V.useCallback)(e=>{a({...t,exec:e.target.checked})},[a,t]),s=(0,V.useCallback)(e=>{a({...t,autoRunScripts:e.target.checked})},[a,t]),c=(0,V.useCallback)(e=>{a({...t,readRoots:e})},[a,t]),l=(0,V.useCallback)(e=>{a({...t,writeRoots:e})},[a,t]),u=(0,V.useCallback)(e=>{a({...t,execAllowlist:e})},[a,t]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border bg-muted/40 px-4 py-4`,"aria-busy":i||void 0,children:[(0,H.jsx)(Di,{explanationKey:oi(e,`exec`),checked:t.exec,disabled:i,onChange:o,title:`Allow running commands`,explanation:vi}),(0,H.jsx)(Di,{explanationKey:oi(e,`autoRunScripts`),checked:t.autoRunScripts,disabled:i,onChange:s,title:`Run commands and scripts from this chat without asking each time`,explanation:yi}),(0,H.jsx)(Oi,{label:`Folders the agent may read`,explanation:bi,placeholder:`/Users/me/projects`,draftKey:oi(e,`readRoots`),items:t.readRoots,disabled:i,onChange:c}),(0,H.jsx)(Oi,{label:`Folders the agent may write to`,explanation:xi,placeholder:`/Users/me/inbox`,draftKey:oi(e,`writeRoots`),items:t.writeRoots,disabled:i,onChange:l}),(0,H.jsx)(Oi,{label:`Commands that always run without asking`,explanation:Si,placeholder:`git`,draftKey:oi(e,`execAllowlist`),items:t.execAllowlist,disabled:i,onChange:u})]})}function Di({explanationKey:e,checked:t,disabled:n,onChange:r,title:i,explanation:a}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(`label`,{className:`flex min-w-0 cursor-pointer items-center gap-3`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:r}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:i})]}),(0,H.jsx)(wi,{explanationKey:e,subject:i})]}),(0,H.jsx)(`div`,{className:`pl-7`,children:(0,H.jsx)(Ti,{explanationKey:e,text:a})})]})}function Oi({label:e,explanation:t,placeholder:n,draftKey:r,items:i,disabled:a,onChange:o}){let s=W(e=>e.drafts[r]??``),c=W(e=>e.setDraft),l=W(e=>e.clearDraft),u=s.trim(),d=u.length>0&&!i.includes(u),f=(0,V.useCallback)(e=>{c(r,e.target.value)},[r,c]),p=(0,V.useCallback)(()=>{o([...i,u]),l(r)},[l,r,i,o,u]),m=(0,V.useCallback)(e=>{o(i.filter(t=>t!==e))},[i,o]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),(0,H.jsx)(wi,{explanationKey:r,subject:e})]}),(0,H.jsx)(Ti,{explanationKey:r,text:t}),i.length===0?(0,H.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`None`}):(0,H.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,H.jsx)(ki,{item:e,disabled:a,onRemove:m},e))}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{value:s,onChange:f,placeholder:n,disabled:a,"aria-label":e}),(0,H.jsx)(k,{variant:`secondary`,size:`sm`,onClick:p,disabled:a||!d,children:`Add`})]})]})}function ki({item:e,disabled:t,onRemove:n}){let r=(0,V.useCallback)(()=>{n(e)},[e,n]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-2 py-1 font-mono text-13`,children:e}),(0,H.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:r,disabled:t,"aria-label":`Remove ${e}`,children:(0,H.jsx)(it,{className:`h-4 w-4`})})]})}var Ai=N(`beacons.mintPairingCode`);function ji(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>{let t=n.get(e.id);return{id:e.id,label:e.label,alias:e.alias??null,os:e.os,enabled:e.enabled,online:t?.online??!1,lastSeenAt:t?.lastSeenAt??null,beaconVersion:t?.beaconVersion??null,canSelfUpdate:t?.canSelfUpdate??!1,update:t?.update??null}})}function Mi({rows:e,configs:t,handlers:n,serverVersion:r,dom:i=wn,clipboard:a=he,timer:o=lt}){let s=Pn(1e3),c=(0,V.useMemo)(()=>ji(e,t),[e,t]),l=(0,V.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsx)(Ni,{now:s,handlers:n,dom:i,clipboard:a,timer:o}),c.length===0?(0,H.jsx)(Yr,{icon:Jn,message:`No machines paired yet. Pair a machine to let the agent read files and run approved commands there.`}):(0,H.jsx)(Xr,{children:c.map(e=>(0,H.jsx)(zi,{row:e,scope:l.get(e.id)?.scope??null,now:s,serverVersion:r,handlers:n,dom:i},e.id))})]})}function Ni({now:e,handlers:t,dom:n,clipboard:r,timer:i}){let a=W(e=>e.pairing),o=W(e=>e.setPairing),s=M(Ai),c=(0,V.useCallback)(()=>{j(Ai,async()=>{o(await t.onMint())})},[t,o]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Beacons`}),(0,H.jsx)(`p`,{className:`mt-1 text-13 text-muted-foreground`,children:`A beacon is a small program on your own machine. Once paired, the agent can read files and run commands there, only within the scope you grant below.`})]}),(0,H.jsxs)(k,{size:`sm`,variant:a?.ok===!0?`secondary`:`default`,onClick:c,pending:s,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Pair a machine`]})]}),a?.ok===!1&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive-text`,children:a.error}),a?.ok===!0&&(0,H.jsx)(Pi,{code:a.code,expiresAt:a.expiresAt,now:e,dom:n,clipboard:r,timer:i})]})}function Pi({code:e,expiresAt:t,now:n,dom:r,clipboard:i,timer:a}){let o=t-n,s=r.getOrigin(),c=fi({kannaUrl:s,code:e}),l=di({kannaUrl:s,code:e}),u=N(`beacons.copyPairCommand`,e),d=M(u),f=ge(u),p=(0,V.useCallback)(()=>{j(u,()=>ve(u,()=>i.writeText(c),a))},[i,c,u,a]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,H.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums tracking-widest`,children:e}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:o>0?`Expires in ${Mn(o)}`:`Expired. Pair again for a new code.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,H.jsxs)(`a`,{href:l,className:le({size:`sm`}),children:[(0,H.jsx)(Ln,{className:`mr-1 h-4 w-4`}),`Open in Kanna Beacon`]}),(0,H.jsx)(`a`,{href:ui,target:`_blank`,rel:`noreferrer`,className:`text-13 text-muted-foreground underline underline-offset-2 hover:text-foreground`,children:`Download Kanna Beacon`})]}),(0,H.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Or run this on the machine you want to pair:`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-3 py-2 font-mono text-13`,children:c}),(0,H.jsx)(En,{label:f?`Copied`:`Copy command`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon`,onClick:p,pending:d,"aria-label":f?`Copied`:`Copy pairing command`,children:f?(0,H.jsx)(_e,{className:`h-4 w-4 text-success-text`}):(0,H.jsx)(me,{className:`h-4 w-4`})})})]})]})}function Fi(e,t){return e.lastSeenAt===null?`Never connected`:`Last seen ${Nn(t-e.lastSeenAt)} ago`}var Ii=`This beacon is too old to update itself. Reinstall it once from the download page; after that, updates are one click.`;function Li({canSelfUpdate:e}){let t=D(`rounded-full border px-2 py-0.5 text-xs`,hi.outdated);return e?(0,H.jsx)(`span`,{className:t,children:`Update available`}):(0,H.jsx)(En,{label:Ii,children:(0,H.jsx)(`a`,{href:ui,target:`_blank`,rel:`noreferrer`,className:t,children:`Update available`})})}function Ri({row:e,updateAvailable:t,handlers:n}){let r=N(`beacons.update`,e.id),i=M(r),a=W(t=>t.updateErrors[e.id]??null),o=W(e=>e.setUpdateError),s=t&&e.online&&e.canSelfUpdate&&!$r(e.update),c=(0,V.useCallback)(()=>{j(r,async()=>{let t=await n.onUpdate(e.id);o(e.id,t.ok?null:t.error)})},[n,e.id,o,r]);return(0,H.jsxs)(H.Fragment,{children:[e.update!==null&&(0,H.jsx)(jn,{tone:ti(e.update),label:ei(e.update)}),s&&(0,H.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:c,pending:i,"aria-label":`Update ${fe(e)} now`,children:[(0,H.jsx)(hr,{className:`mr-1 h-4 w-4`}),`Update now`]}),a!==null&&(0,H.jsx)(`span`,{role:`alert`,className:`text-destructive-text`,children:a})]})}function zi({row:e,scope:t,now:n,serverVersion:r,handlers:i,dom:a}){let o=W(t=>t.expandedId===e.id),s=W(e=>e.toggleExpanded),c=N(`beacons.setEnabled`,e.id),l=M(c),u=N(`beacons.delete`,e.id),d=M(u),f=fe(e),p=e.beaconVersion!==null&&r!==void 0&&mi(e.beaconVersion,r),m=(0,V.useCallback)(t=>{let n=t.target.checked;j(c,()=>i.onSetEnabled(e.id,n))},[c,i,e.id]),h=(0,V.useCallback)(()=>{a.confirmDialog(`Revoke "${f}"? The agent will lose access to this machine until you pair it again.`)&&j(u,()=>i.onDelete(e.id))},[u,f,a,i,e.id]),g=(0,V.useCallback)(()=>{s(e.id)},[e.id,s]);return(0,H.jsxs)(`li`,{className:`flex flex-col`,"aria-busy":d||void 0,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium`,children:f}),(0,H.jsx)(gi,{beaconId:e.id,alias:e.alias,displayName:f})]}),e.alias!==null&&(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`font-mono`,children:e.label}),(0,H.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,e.alias]})]}),(0,H.jsx)(_i,{beaconId:e.id,alias:e.alias,displayName:f,onSetAlias:i.onSetAlias}),(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(jn,{tone:e.online?`active`:`muted`,label:e.online?`Online`:`Offline`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:Fi(e,n)}),e.beaconVersion!==null&&(0,H.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`v`,e.beaconVersion]}),p&&(0,H.jsx)(Li,{canSelfUpdate:e.canSelfUpdate}),(0,H.jsx)(Ri,{row:e,updateAvailable:p,handlers:i}),(0,H.jsx)(`span`,{children:e.os})]})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[l?(0,H.jsx)(E,{}):null,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:l,"aria-busy":l||void 0,onChange:m,"aria-label":`Enable ${f}`}),(0,H.jsx)(`span`,{children:e.enabled?`Enabled`:`Disabled`})]}),t!==null&&(0,H.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:g,"aria-expanded":o,children:[`Scope`,(0,H.jsx)(Rn,{className:D(`ml-1 h-4 w-4 transition-transform`,o&&`rotate-180`)})]}),(0,H.jsx)(En,{label:`Revoke this machine`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon`,onClick:h,pending:d,"aria-label":`Revoke ${f}`,children:(0,H.jsx)(Je,{className:`h-4 w-4`})})})]})]}),o&&t!==null&&(0,H.jsx)(Ei,{beaconId:e.id,scope:t,onSetScope:i.onSetScope})]})}function Bi(e){let t=d(l),n=z(ln),{handleWriteAppSettings:r,handleMintBeaconPairingCode:i,handleUpdateBeacon:a}=e.state,o=(0,V.useMemo)(()=>({onMint:i,onSetEnabled:async(e,t)=>{await r({customBeacons:{setEnabled:{id:e,enabled:t}}})},onSetScope:async(e,t)=>{await r({customBeacons:{setScope:{id:e,scope:t}}})},onSetAlias:async(e,t)=>{await r({customBeacons:{update:{id:e,patch:{alias:t}}}})},onDelete:async e=>{await r({customBeacons:{delete:{id:e}}})},onUpdate:a}),[r,i,a]);return(0,H.jsx)(Mi,{rows:t,configs:n,handlers:o,serverVersion:vt})}var Vi=3e5,Hi=null;function Ui(e=Date.now){return Hi?e()>=Hi.expiresAt?(Hi=null,null):Hi.releases:null}function Wi(e,t=Date.now){Hi={releases:e,expiresAt:t()+Vi}}async function Gi(e,t){let n=t?.now??Date.now,r=t?.force?null:Ui(n);if(r)return r;let i=await e();return Wi(i,n),i}function Ki(e){return e.trim().replace(/^v/i,``)}function qi(e,t){let n=e=>Ki(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e)),r=n(e),i=n(t),a=Math.max(r.length,i.length);for(let e=0;e<a;e+=1){let t=r[e]??0,n=i[e]??0;if(t!==n)return t<n?-1:1}return 0}function Ji(e,t,n){return Ki(e)===Ki(n)?{actionLabel:`Update`,pendingLabel:`Updating…`}:qi(e,t)<0?{actionLabel:`Rollback`,pendingLabel:`Rolling back…`}:{actionLabel:`Install`,pendingLabel:`Installing…`}}function Yi(e){if(!e)return`Unpublished`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown date`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,year:`numeric`}).format(t)}function Xi({status:e,releases:t,error:n,onRetry:r,updateSnapshot:i,currentVersion:a,onInstallUpdate:o,onCheckForUpdates:s,onForceReload:c}){let l=M(`update.check`),u=oe(`update.install`),d=M(`update.redeploy`),f=se(e=>e.inFlight),p=u||d,m=i?.latestVersion??t[0]?.tag_name??`Unknown`,h=i?.currentVersion??a,g=i?.status===`checking`||l,_=i?.status===`updating`||i?.status===`restart_pending`,v=_||p,y=i?.updateAvailable===!0,b=Ki(m),x=Ki(h),S=(0,V.useCallback)(async e=>{await o(e)},[o]),ee=(0,V.useCallback)(async()=>{await c()},[c]),C=d||_;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[e===`loading`||e===`idle`?(0,H.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center rounded-2xl border border-border bg-card/40 px-6 py-8 text-sm text-muted-foreground`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,H.jsx)(`span`,{children:`Loading release notes…`})]})}):null,e===`error`?(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-6 py-5`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Could not load changelog`}),(0,H.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:n??`Unable to load changelog.`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted`,children:`Retry`})]})}):null,e===`success`&&t.length===0?(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 px-6 py-8`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No releases yet`}),(0,H.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`GitHub did not return any published releases for this repository.`})]}):null,e===`success`?(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(cr,{variant:`outline`,onClick:()=>j(`update.redeploy`,ee),disabled:v,children:C?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),`Re-deploying…`]}):`Re-deploy`}),(0,H.jsx)(cr,{variant:`outline`,onClick:()=>j(`update.check`,s),disabled:g||v,children:g?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),`Checking…`]}):`Check for updates`})]}):null,e===`success`&&t.length>0?t.map(e=>{let t=Ki(e.tag_name),n=t===b,r=t===x;return(0,H.jsxs)(`article`,{className:D(`rounded-xl border bg-card/30 pl-6 pr-4 py-4`,n?`border-border bg-muted`:`border-border`),children:[(0,H.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-3 `,children:[(0,H.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-2 `,children:[(0,H.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:e.name?.trim()||e.tag_name}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:Yi(e.published_at)}),e.prerelease?(0,H.jsx)(`span`,{className:`rounded-full border border-border px-2.5 py-1 tracking-wide`,children:`Prerelease`}):null]})]}),(0,H.jsxs)(`div`,{className:`flex flex-row items-center justify-end min-w-0 flex-1 gap-2 `,children:[(0,H.jsx)(`a`,{href:e.html_url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`View release on GitHub`,className:D(le({variant:`ghost`,size:`icon-sm`}),`h-11 w-11 md:h-8 md:w-8 shrink-0 rounded-md hover:!bg-transparent hover:border-border/0`),children:(0,H.jsx)(Zi,{className:`h-4 w-4`})}),r?(0,H.jsx)(`span`,{className:D(`bg-transparent border border-border text-secondary-foreground`,`h-9 rounded-full px-3 text-sm`,`h-auto gap-1.5 px-3 py-1.5`),children:`Current`}):null,n&&y||!n&&!r?(()=>{let t=f[N(`update.install`,e.tag_name)]===!0||_&&!p,{actionLabel:n,pendingLabel:r}=Ji(e.tag_name,h,m);return(0,H.jsx)(cr,{variant:`default`,className:``,onClick:()=>j(N(`update.install`,e.tag_name),()=>S(e.tag_name)),disabled:v,children:(0,H.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2`,children:[t?(0,H.jsx)(A,{className:`size-4 animate-spin`}):(0,H.jsx)(_r,{className:`size-4`}),t?r:n]})})})():null]})]}),e.body?.trim()?(0,H.jsx)(`div`,{className:`prose prose-sm mt-5 max-w-none text-foreground dark:prose-invert`,children:de(e.body)}):(0,H.jsx)(`div`,{className:`mt-5 text-sm text-muted-foreground`,children:`No release notes were provided.`})]},e.id)}):null]})}function Zi({className:e}){return(0,H.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,H.jsx)(`path`,{d:`M12 .5C5.649.5.5 5.649.5 12A11.5 11.5 0 0 0 8.36 22.04c.575.106.785-.25.785-.556 0-.274-.01-1-.015-1.962-3.181.691-3.853-1.532-3.853-1.532-.52-1.322-1.27-1.674-1.27-1.674-1.038-.71.08-.695.08-.695 1.148.08 1.752 1.178 1.752 1.178 1.02 1.748 2.676 1.243 3.328.95.103-.738.399-1.243.725-1.53-2.54-.289-5.211-1.27-5.211-5.65 0-1.248.446-2.27 1.177-3.07-.118-.288-.51-1.45.112-3.024 0 0 .96-.307 3.145 1.173A10.91 10.91 0 0 1 12 6.03c.973.004 1.954.132 2.87.387 2.182-1.48 3.14-1.173 3.14-1.173.625 1.573.233 2.736.115 3.024.734.8 1.175 1.822 1.175 3.07 0 4.39-2.676 5.358-5.224 5.642.41.353.776 1.05.776 2.117 0 1.528-.014 2.761-.014 3.136 0 .309.207.668.79.555A11.502 11.502 0 0 0 23.5 12C23.5 5.649 18.351.5 12 .5Z`})})}var Qi=[],$i=I()(e=>({status:`idle`,releases:Qi,error:null,loadStarted:()=>e({status:`loading`,error:null}),loaded:t=>e({releases:t,status:`success`}),loadFailed:t=>e({error:t,status:`error`})}));function ea(e){let t=$i(e=>e.status),n=$i(e=>e.releases),r=$i(e=>e.error),i=$i(e=>e.loadStarted),a=$i(e=>e.loaded),o=$i(e=>e.loadFailed),s=(0,V.useCallback)(async(t,n)=>{i();try{let r=await Gi(e,{force:t});n()||a(r)}catch(e){n()||o(L(e))}},[e,i,a,o]);return(0,V.useEffect)(()=>{let e=!1;return Cn(`changelog.load`,s(!1,()=>e)),()=>{e=!0}},[s]),{status:t,releases:n,error:r,retry:(0,V.useCallback)(()=>{Cn(`changelog.retry`,s(!0,()=>!1))},[s])}}function ta({state:e}){let{socket:t}=e,n=ea((0,V.useCallback)(()=>t.command({type:`settings.getChangelog`}),[t]));return(0,H.jsx)(Xi,{status:n.status,releases:n.releases,error:n.error,onRetry:n.retry,updateSnapshot:e.updateSnapshot,currentVersion:vt,onInstallUpdate:t=>e.handleInstallUpdate(t),onCheckForUpdates:()=>e.handleCheckForUpdates({force:!0}),onForceReload:()=>e.handleForceReload()})}var G=I()(e=>({drafts:{scrollback:``,minColumnWidth:``,tabMinWidth:``,uploadMaxFileSize:``,editorCommand:``,cloudflaredPath:``,shareDefaultTtl:``},appSettingsError:null,tunnelError:null,analyticsDialogOpen:!1,patchDrafts:t=>e(e=>({drafts:{...e.drafts,...t}})),setAppSettingsError:t=>e({appSettingsError:t}),setTunnelError:t=>e({tunnelError:t}),setAnalyticsDialogOpen:t=>e({analyticsDialogOpen:t})}));function na(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function ra(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}var ia=bt.map(e=>({value:e,label:ra(e)})),aa=I()(e=>({chatSoundPreference:Bt,chatSoundId:Tt,setChatSoundPreference:t=>e({chatSoundPreference:zt(t)}),setChatSoundId:t=>e({chatSoundId:At(t)})}));function oa(e){let t=G(e=>e.setAppSettingsError),{handleWriteAppSettings:n}=e,r=(0,V.useCallback)(e=>t(e.message),[t]);return{write:(0,V.useCallback)(e=>{n(e).catch(gt(r))},[n,r]),writeAsync:(0,V.useCallback)(e=>n(e).catch(gt(r)),[n,r])}}var sa=[{value:`light`,label:`Light`,icon:zr},{value:`dark`,label:`Dark`,icon:kr},{value:`system`,label:`System`,icon:Oe}],ca=[{value:`sm`,label:`Small`},{value:`md`,label:`Default`},{value:`lg`,label:`Large`},{value:`xl`,label:`Extra Large`},{value:`xxl`,label:`XX-Large`}],la=[{value:`never`,label:`Never`},{value:`unfocused`,label:`When Unfocused`},{value:`always`,label:`Always`}],ua=`settings.chatSoundPreference`,da=`settings.chatSoundId`;function fa(e,t){return e!==t}function pa(e){return e?.status===`checking`?`Checking for updates…`:e?.status===`updating`?`Installing update…`:e?.status===`restart_pending`?`Restarting Kanna…`:e?.status===`available`?`Update available${e.latestVersion?`: ${e.latestVersion}`:``}`:e?.status===`up_to_date`?`Up to date`:e?.status===`error`?`Update check failed`:`Not checked yet`}function ma({updateSnapshot:e}){return(0,H.jsx)(U,{title:`Application Update`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[pa(e),`.`]}),e?.lastCheckedAt?(0,H.jsxs)(`span`,{children:[` Last checked `,new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e.lastCheckedAt),`.`]}):null,e?.error?(0,H.jsxs)(`span`,{children:[` `,e.error]}):null]}),bordered:!1,children:(0,H.jsxs)(`div`,{className:`text-right text-sm text-foreground`,children:[(0,H.jsxs)(`div`,{children:[`Current: `,e?.currentVersion??vt]}),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Latest: `,e?.latestVersion??`Unknown`]})]})})}function ha({state:e}){let{writeAsync:t}=oa(e),n=z(rn),r=z(pn),i=aa(e=>e.setChatSoundPreference),a=aa(e=>e.setChatSoundId),o=M(ua),s=M(da);function c(e){fa(n,e)&&(i(e),j(ua,()=>t({chatSoundPreference:e})),Cn(`chat sound preview`,Fn(r,1)))}function l(e){fa(r,e)&&(a(e),j(da,()=>t({chatSoundId:e})),Cn(`chat sound preview`,Fn(e,1)))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Chat Sounds`,description:`Play a pop when a chat starts waiting on you or the unread chat count increases`,children:(0,H.jsxs)(Ce,{disabled:o,value:n,onValueChange:e=>{Ct(e)&&c(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:la.map(e=>(0,H.jsx)(P,{value:e.value,children:e.label},e.value))})})]})}),(0,H.jsx)(U,{title:`Chat Sound`,description:`The bundled sound used for chat notification playback and previews`,children:(0,H.jsxs)(Ce,{disabled:s,value:r,onValueChange:e=>{It(e)&&l(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:ia.map(e=>(0,H.jsx)(P,{value:e.value,children:e.label},e.value))})})]})})]})}function ga({state:e}){let{write:t}=oa(e),n=z(Gt),r=z(dn),i=C(e=>e.setEditorPreset),a=C(e=>e.setEditorCommandTemplate),o=G(e=>e.drafts.editorCommand),s=G(e=>e.patchDrafts);(0,V.useEffect)(()=>{s({editorCommand:r})},[r,s]);function c(){a(o),t({editor:{commandTemplate:o}})}function l(e){i(e);let n=e===`custom`?r:jt(e);t({editor:{preset:e,commandTemplate:n}})}let u=o.replaceAll(`{path}`,`/Users/jake/Projects/kanna/src/client/app/App.tsx`).replaceAll(`{line}`,`12`).replaceAll(`{column}`,`1`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Default Editor`,description:`Used when opening transcript links or files from the git diff menu`,alignStart:!0,children:(0,H.jsxs)(Ce,{value:n,onValueChange:e=>{mn(e)&&l(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:Kn.map(e=>(0,H.jsx)(P,{value:e.value,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Hn,{preset:e.value,className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:e.label})]})},e.value))})})]})}),n===`custom`?(0,H.jsx)(`div`,{className:`border-t border-border`,children:(0,H.jsxs)(`div`,{className:`flex justify-between gap-8 py-5 pl-6`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Command Template`}),(0,H.jsxs)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:[`Include `,`{path}`,` and optionally `,`{line}`,` and `,`{column}`,` in your command.`]})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 flex-col items-stretch gap-2`,children:[(0,H.jsx)(R,{type:`text`,value:o,onChange:e=>s({editorCommand:e.target.value}),onBlur:c,onKeyDown:e=>na(e,c),className:`font-mono`}),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Preview: `,(0,H.jsx)(`span`,{className:`font-mono`,children:u})]})]})]})}):null]})}function _a({state:e}){let{write:t}=oa(e),{theme:n,setTheme:r}=xn(),i=s(e=>e.typographyOverride),a=s(e=>e.clearTypographyOverride),o=z(e=>e.settings?.typography.scale),c=Zt(i,o);function l(e){r(e),t({theme:e})}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ma,{updateSnapshot:e.updateSnapshot}),(0,H.jsx)(U,{title:`Theme`,description:`Choose between light, dark, or system appearance`,children:(0,H.jsx)(F,{value:n,onValueChange:l,options:sa,size:`sm`})}),(0,H.jsx)(U,{title:`Typography Scale`,description:i?`This device uses its own text size instead of the account default.`:`Choose how large text and UI elements appear across the app.`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(Ce,{value:c,onValueChange:e=>{un(e)&&t({typography:{scale:e}})},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:ca.map(e=>(0,H.jsx)(P,{value:e.value,children:e.label},e.value))})})]}),i?(0,H.jsx)(k,{type:`button`,variant:`link`,size:`sm`,onClick:a,children:`Use account default`}):null]})}),(0,H.jsx)(ha,{state:e}),(0,H.jsx)(ga,{state:e})]})}var va=[`app_launch`,`project_opened`,`project_created`,`project_removed`,`project_deleted`,`chat_created`,`chat_deleted`,`message_sent`,`update_checked`,`update_installed`,`update_failed`,`analytics_enabled`,`analytics_disabled`],ya=[`current_version`,`environment`,`latest_version`,`custom_port_enabled`,`no_open_enabled`,`password_enabled`,`strict_port_enabled`,`remote_enabled`,`host_enabled`,`share_quick_enabled`,`share_token_enabled`],ba=I()(e=>({permissionState:`unsupported`,deviceId:null,error:null,contactSubjectDraft:``,detected:(t,n)=>e({permissionState:t,deviceId:n}),setPermissionState:t=>e({permissionState:t}),setDeviceId:t=>e({deviceId:t}),setError:t=>e({error:t}),setContactSubjectDraft:t=>e({contactSubjectDraft:t})})),xa=`inline-flex items-center justify-center rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground transition-colors hover:bg-muted`,Sa=`inline-flex items-center justify-center rounded-lg bg-foreground px-3 py-1.5 text-sm font-medium text-background transition-colors hover:bg-foreground/90`,Ca=`rounded bg-muted px-1 py-0.5 font-mono text-12 text-foreground`,wa=`text-xs font-medium tracking-wide text-muted-foreground`,Ta=`gap-1.5 disabled:cursor-default disabled:opacity-60`,Ea=`push.enable`,Da=`push.test`,Oa=`push.disable`,ka=`push.contactSubject`;async function Aa(e){try{await e(),ba.getState().setError(null)}catch(e){ba.getState().setError(L(e))}}function ja(e,t){j(e,()=>Aa(t))}function Ma(){let e=ba(e=>e.error);return e?(0,H.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive-text`,children:e}):null}function Na({pendingKey:e,onRun:t,className:n,label:r,children:i}){let a=M(e);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>ja(e,t),disabled:a,"aria-busy":a||void 0,"aria-label":r,className:D(n,Ta),children:[a?(0,H.jsx)(E,{}):null,i]})}function Pa({localPath:e,muted:t,onMuteToggle:n}){let r=N(`push.setProjectMute`,e),i=M(r);return(0,H.jsxs)(`label`,{"aria-busy":i||void 0,className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:!t,disabled:i,onChange:t=>ja(r,()=>n(e,!t.target.checked)),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),(0,H.jsx)(Tn,{inline:!0,className:`min-w-0 flex-1 font-mono text-12 text-foreground`,tooltip:e,children:e}),i?(0,H.jsx)(E,{className:`text-muted-foreground`}):null]})}function Fa(e){let{permissionState:t}=e,n=M(ka);if(t===`unsupported`)return(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Push notifications are not supported in this browser.`});if(t===`insecure-context`)return(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Push requires HTTPS. Run `,(0,H.jsx)(`code`,{className:Ca,children:`kanna --share`}),` or open Kanna over a tunnel, then enable on this device.`]});if(t===`denied`)return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You blocked notifications for this site. Re-enable them in your browser settings, then reload.`}),(0,H.jsx)(Ma,{})]});if(!(t===`granted`&&e.config.devices.some(t=>t.id===e.currentDeviceId)))return(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start gap-2 md:w-[440px]`,children:[(0,H.jsx)(Na,{pendingKey:Ea,onRun:e.onEnable,className:Sa,children:`Enable on this device`}),(0,H.jsx)(Ma,{})]});let r=new Set(e.config.preferences.mutedProjectPaths),i=e.contactSubjectDraft.trim(),a=Gr(i),o=i!==e.contactSubject,s=()=>{a&&o&&ja(ka,()=>e.onContactSubjectSave(i))};return(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-5 md:w-[440px]`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-border bg-card/40 px-3 py-1 text-xs font-medium text-foreground`,children:[(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`,"aria-hidden":!0}),`Enabled on this device`]}),(0,H.jsx)(Na,{pendingKey:Da,onRun:e.onTest,className:xa,children:`Send test`}),(0,H.jsx)(Na,{pendingKey:Oa,onRun:e.onDisable,className:xa,children:`Disable`})]}),(0,H.jsx)(Ma,{}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:D(wa,`flex items-center gap-1.5`),children:[`Contact for delivery`,n?(0,H.jsx)(E,{}):null]}),(0,H.jsx)(R,{type:`text`,inputMode:`email`,spellCheck:!1,autoCapitalize:`none`,value:e.contactSubjectDraft,readOnly:n,"aria-busy":n||void 0,onChange:t=>e.onContactSubjectDraftChange(t.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:`mailto:you@example.com`,"aria-label":`Push contact subject`,"aria-invalid":i!==``&&!a,className:D(`font-mono`,i!==``&&!a&&`border-destructive`)}),i!==``&&!a?(0,H.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Must be a `,(0,H.jsx)(`code`,{className:Ca,children:`mailto:`}),` address or`,` `,(0,H.jsx)(`code`,{className:Ca,children:`https:`}),` URL with a routable domain (not localhost).`]}):(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Push services require a contact `,(0,H.jsx)(`code`,{className:Ca,children:`mailto:`}),` or`,` `,(0,H.jsx)(`code`,{className:Ca,children:`https:`}),` URL to sign notifications. Set your own so delivery isn’t rejected.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`div`,{className:wa,children:`Devices`}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.config.devices.map(t=>(0,H.jsxs)(`li`,{className:`flex items-start justify-between gap-3 rounded-lg border border-border bg-card/40 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.label}),(0,H.jsx)(`span`,{className:`line-clamp-2 break-all text-xs leading-snug text-muted-foreground`,children:t.userAgent})]}),!t.isCurrentDevice&&(0,H.jsx)(Na,{pendingKey:N(`push.unsubscribe`,t.id),onRun:()=>e.onRemoveDevice(t.id),label:`Remove ${t.label}`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-background px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:`Remove`})]},t.id))})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`div`,{className:wa,children:`Per-project`}),(0,H.jsx)(`ul`,{className:`flex flex-col`,children:e.projects.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Pa,{localPath:t.localPath,muted:r.has(t.localPath),onMuteToggle:e.onMuteToggle})},t.localPath))})]}),(0,H.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`Phone setup: this page must be reachable over HTTPS. Run`,` `,(0,H.jsx)(`code`,{className:Ca,children:`kanna --share`}),` or open Kanna over your tunnel on the phone, then enable on that device.`]})]})}function Ia(e){return e.map(e=>({...e,disabled:!0}))}function La({pendingKey:e,value:t,onValueChange:n,options:r,size:i}){let a=M(e);return(0,H.jsxs)(`div`,{className:`inline-flex items-center gap-2`,"aria-busy":a||void 0,children:[a?(0,H.jsx)(E,{className:`text-muted-foreground`}):null,(0,H.jsx)(F,{value:t,onValueChange:t=>j(e,()=>n(t)),options:a?Ia(r):r,size:i})]})}function Ra(e){let{pushConfig:t,socket:n}=e,r=ba(e=>e.deviceId),i=ba(e=>e.setDeviceId),a=ba(e=>e.setPermissionState);return{handleEnablePush:(0,V.useCallback)(async()=>{if(t)try{let e=await te({vapidPublicKey:t.vapidPublicKey,sendToServer:async e=>{let t=await n.command({type:`push.subscribe`,subscription:e.subscription,label:e.label,userAgent:e.userAgent});return y(t.id),{id:t.id}}});i(e)}finally{a(re().state)}},[t,n,i,a]),handleDisablePush:(0,V.useCallback)(async()=>{r&&(await ae({pushDeviceId:r,sendToServer:async e=>{await n.command({type:`push.unsubscribe`,pushDeviceId:e})}}),v(),i(null))},[r,n,i])}}var za=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Ba=`~/.kanna/data/settings.json`;function Va({state:e,dom:t}){let n=z(e=>e.settings),r=ba(e=>e.permissionState),i=ba(e=>e.deviceId),a=ba(e=>e.contactSubjectDraft),o=ba(e=>e.setContactSubjectDraft),s=ba(e=>e.detected),c=ba(e=>e.setPermissionState),{handleEnablePush:l,handleDisablePush:u}=Ra(e),{pushConfig:d,socket:f}=e,p=n?.push.contactSubject;return(0,V.useLayoutEffect)(()=>{s(re().state,ie())},[s]),(0,V.useEffect)(()=>t.addWindowListener(`focus`,()=>c(re().state)),[t,c]),(0,V.useEffect)(()=>{p!==void 0&&o(p)},[p,o]),d?(0,H.jsx)(U,{title:`Push notifications`,description:`Get notified when a chat is waiting for you, finishes, or fails. Works on iPhone (after Add to Home Screen), Android, and desktop browsers.`,bordered:!1,alignStart:!0,children:(0,H.jsx)(Fa,{permissionState:r,config:d,projects:e.localProjects?.projects??[],currentDeviceId:i,contactSubject:p??``,contactSubjectDraft:a,onContactSubjectDraftChange:o,onContactSubjectSave:t=>e.handleWriteAppSettings({push:{contactSubject:t}}),onEnable:l,onDisable:u,onTest:async()=>{await f.command({type:`push.test`})},onMuteToggle:async(e,t)=>{await f.command({type:`push.setProjectMute`,localPath:e,muted:t})},onRemoveDevice:async e=>{await f.command({type:`push.unsubscribe`,pushDeviceId:e})}})}):null}function Ha({state:e}){let t=z(e=>e.settings),n=G(e=>e.setAppSettingsError),r=G(e=>e.setAnalyticsDialogOpen),i=t?.analyticsEnabled===!1?`disabled`:`enabled`,a=t?.telemetry?.enabled===!1?`disabled`:`enabled`;async function o(t){await B(n,()=>e.handleWriteAppSettings(t))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Anonymous Analytics`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Help improve Kanna with anonymous product analytics. Kanna sends tracked event names plus a small set of event properties like current version, environment, update version info, and launch flags. No message content, prompts, file paths, or provider credentials are sent.`}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,t?.filePathDisplay??Ba,`.`,` `,(0,H.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`underline underline-offset-2 text-foreground hover:text-foreground/80`,children:`View tracked events`})]}),t?.warning?(0,H.jsx)(`span`,{className:`mt-1 block`,children:t.warning}):null]}),children:(0,H.jsx)(La,{pendingKey:`settings.analytics`,value:i,onValueChange:e=>o({analyticsEnabled:e===`enabled`}),options:za,size:`sm`})}),(0,H.jsx)(U,{title:`Telemetry Tracing`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Export OpenTelemetry traces and metrics (turn timings, subagent runs, process memory) to Kanna's observability collector so each install can be monitored. This machine reports under its computer name. Turning it off stops the export immediately.`}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Collector: `,t?.telemetry?.endpoint??`not configured`,`. Stored in `,t?.filePathDisplay??Ba,`.`]})]}),children:(0,H.jsx)(La,{pendingKey:`settings.telemetry`,value:a,onValueChange:e=>o({telemetry:{enabled:e===`enabled`}}),options:za,size:`sm`})})]})}function Ua(){let e=G(e=>e.analyticsDialogOpen),t=G(e=>e.setAnalyticsDialogOpen);return(0,H.jsx)(ot,{open:e,onOpenChange:t,children:(0,H.jsxs)(at,{size:`lg`,children:[(0,H.jsxs)(ct,{className:`space-y-4`,children:[(0,H.jsx)(ut,{children:`Tracked Events`}),(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Kanna sends these event names plus the limited property keys below, depending on the event type.`}),(0,H.jsxs)(`div`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted/40 p-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Event Names`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:va.map(e=>(0,H.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))}),(0,H.jsx)(`div`,{className:`mt-6 text-xs font-medium tracking-wide text-muted-foreground`,children:`Property Keys`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:ya.map(e=>(0,H.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))})]})]}),(0,H.jsx)(st,{children:(0,H.jsx)(k,{variant:`secondary`,size:`sm`,onClick:()=>t(!1),children:`Close`})})]})})}function Wa({state:e,dom:t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Va,{state:e,dom:t}),(0,H.jsx)(Ha,{state:e}),(0,H.jsx)(Ua,{})]})}var Ga={path:`shareDefaultTtlHours`,min:1,max:1/0,integer:!0},Ka=6e5,qa={path:`subagentRuntime.runTimeoutMs`,min:3e4,max:864e5,integer:!0},Ja={path:`claudeDriver.lifecycle.idleTimeoutMs`,min:kt,max:Vt,integer:!1},Ya={path:`claudeDriver.lifecycle.maxConcurrent`,min:1,max:16,integer:!1};function Xa(e,t,n){let r=Number(e);if(!tn(n,r))return{kind:`invalid`};let i=Math.round(r);return i===t?{kind:`unchanged`}:{kind:`write`,value:i}}function Za({title:e,description:t,min:n,max:r,step:i,value:a,onValueChange:o,onCommit:s,hint:c,unit:l,ariaLabel:u,bordered:d}){let f=(0,H.jsx)(R,{type:`number`,min:n,max:r,step:i,value:a,onChange:e=>o(e.target.value),onBlur:s,onKeyDown:e=>na(e,s),className:D(`hide-number-steppers w-full text-left font-mono`,l?`tabular-nums md:w-24 md:text-right`:`md:w-28 md:text-right`),"aria-label":u});return(0,H.jsx)(U,{title:e,description:t,bordered:d,children:(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[l?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 md:justify-end`,children:[f,(0,H.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:l})]}):f,(0,H.jsx)(`div`,{className:D(`text-left text-xs text-muted-foreground md:text-right`,l&&`tabular-nums`),children:c})]})})}function Qa({state:e}){let{write:t}=oa(e),n=z(e=>e.settings?.shareDefaultTtlHours??24),r=G(e=>e.drafts.shareDefaultTtl),i=G(e=>e.patchDrafts),a=G(e=>e.setAppSettingsError);(0,V.useEffect)(()=>{i({shareDefaultTtl:String(n)})},[n,i]);function o(){let e=Xa(r,n,Ga);e.kind===`write`?t({shareDefaultTtlHours:e.value}):(i({shareDefaultTtl:String(n)}),e.kind===`invalid`&&a(`Default share link expiry must be a whole number of hours >= 1.`))}return(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(Za,{title:`Public share links`,description:`Default expiry for read-only chat share links. Owners can revoke any link manually at any time.`,min:Ga.min,step:1,value:r,onValueChange:e=>i({shareDefaultTtl:e}),onCommit:o,unit:`hours`,ariaLabel:`Default share link expiry in hours`,hint:`Minimum 1 hour · default 24`,bordered:!1})})}function $a({checked:e,onChange:t}){return(0,H.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked)}),`Enabled`]})}function eo(e,t){let n=G(t=>t.drafts[e]),r=G(e=>e.patchDrafts);return(0,V.useEffect)(()=>{r({[e]:String(t)})},[e,t,r]),{draft:n,setDraft:t=>r({[e]:t}),parsed:()=>{let e=Number(n);return Number.isFinite(e)?e:null},reset:()=>r({[e]:String(t)})}}function to({state:e}){let{write:t}=oa(e),n=z(nn),r=C(e=>e.setScrollbackLines),i=eo(`scrollback`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{scrollbackLines:e}}))}return(0,H.jsx)(Za,{title:`Terminal Scrollback`,description:`Lines retained for embedded terminal history`,min:500,max:gn,step:100,value:i.draft,onValueChange:i.setDraft,onCommit:a,hint:(0,H.jsxs)(H.Fragment,{children:[500,`-`,gn,` lines`,n===1e3?` (default)`:``]})})}function no({state:e}){let{write:t}=oa(e),n=z(Kt),r=C(e=>e.setMinColumnWidth),i=eo(`minColumnWidth`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{minColumnWidth:e}}))}return(0,H.jsx)(Za,{title:`Terminal Min Column Width`,description:`Minimum width for each terminal pane`,min:250,max:900,step:10,value:i.draft,onValueChange:i.setDraft,onCommit:a,hint:(0,H.jsxs)(H.Fragment,{children:[250,`-`,900,` px`,n===450?` (default)`:``]})})}function ro({state:e}){let{write:t}=oa(e),n=z(e=>e.settings?.panes.tabMinWidth??60),r=eo(`tabMinWidth`,n);function i(){let e=r.parsed();e===null?r.reset():t({panes:{tabMinWidth:Un(e)}})}return(0,H.jsx)(Za,{title:`Tab Minimum Width`,description:`How narrow a pane tab may get before the strip scrolls instead of shrinking`,min:60,max:200,step:10,value:r.draft,onValueChange:r.setDraft,onCommit:i,hint:(0,H.jsxs)(H.Fragment,{children:[60,`-`,200,` px`,n===60?` (default)`:``]})})}function io({state:e}){let{write:t}=oa(e),n=z(e=>e.settings?.uploads.maxFileSizeMb??Kr.maxFileSizeMb),r=G(e=>e.drafts.uploadMaxFileSize),i=G(e=>e.patchDrafts),a=G(e=>e.setAppSettingsError);(0,V.useEffect)(()=>{i({uploadMaxFileSize:String(n)})},[n,i]);function o(){let e=Xa(r,n,qr);e.kind===`write`?t({uploads:{maxFileSizeMb:e.value}}):(i({uploadMaxFileSize:String(n)}),e.kind===`invalid`&&a(`Max file size must be between ${qr.min} and ${qr.max} MB.`))}return(0,H.jsx)(Za,{title:`Max upload file size`,description:`Largest single file the chat upload endpoint accepts.`,min:qr.min,max:qr.max,step:1,value:r,onValueChange:e=>i({uploadMaxFileSize:e}),onCommit:o,unit:`MB`,ariaLabel:`Max upload file size in megabytes`,hint:`${qr.min}–${qr.max} MB · default ${Kr.maxFileSizeMb}`})}function ao({state:e}){let t=s(e=>e.autoResumeOnRateLimit),n=s(e=>e.setAutoResumeOnRateLimit);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(to,{state:e}),(0,H.jsx)(no,{state:e}),(0,H.jsx)(ro,{state:e}),(0,H.jsx)(io,{state:e}),(0,H.jsx)(U,{title:`Auto-resume on rate limit`,description:`When you hit a rate limit, automatically schedule "continue" at the reset time instead of asking. You can still cancel each one from the chat.`,children:(0,H.jsx)($a,{checked:t,onChange:n})})]})}var oo=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],so=[{value:`always-ask`,label:`Always ask`},{value:`auto-expose`,label:`Auto-expose`}],co=`appSettings.setCloudflareTunnel`,lo=N(co,`cloudflaredPath`);function uo({state:e}){let t=z(e=>e.settings),n=G(e=>e.tunnelError),r=G(e=>e.setTunnelError),i=G(e=>e.drafts.cloudflaredPath),a=G(e=>e.patchDrafts),o=M(lo),s=t?.cloudflareTunnel??Wr,c=s.enabled?`enabled`:`disabled`,l=t?.cloudflareTunnel.cloudflaredPath;(0,V.useEffect)(()=>{l!==void 0&&a({cloudflaredPath:l})},[l,a]);async function u(t){await B(r,()=>e.handleWriteCloudflareTunnel(t))}return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[n?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:n}):null,(0,H.jsx)(U,{title:`Cloudflare Tunnel`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[`When enabled, Claude can call the `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`expose_port`}),` tool to expose a local port via Cloudflare Tunnel. The mode below controls whether each call requires your approval or is exposed automatically. Requires`,` `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`cloudflared`}),` `,`to be installed.`]}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,t?.filePathDisplay??`~/.kanna/data/settings.json`,`.`]})]}),bordered:!1,children:(0,H.jsx)(La,{pendingKey:N(co,`enabled`),value:c,onValueChange:e=>u({enabled:e===`enabled`}),options:oo,size:`sm`})}),s.enabled&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Tool mode`,description:`Always ask: each expose_port call shows an accept card. Auto-expose: expose_port calls spawn cloudflared immediately without prompting.`,children:(0,H.jsx)(La,{pendingKey:N(co,`mode`),value:s.mode,onValueChange:e=>u({mode:e}),options:so,size:`sm`})}),(0,H.jsx)(U,{title:`cloudflared path`,description:`Path to the cloudflared binary. Defaults to the one found on $PATH.`,children:(0,H.jsx)(R,{value:i,onChange:e=>a({cloudflaredPath:e.target.value}),onBlur:()=>j(lo,()=>u({cloudflaredPath:i})),readOnly:o,"aria-busy":o||void 0,placeholder:`cloudflared`,className:`w-full font-mono md:w-64`})})]})]})}function fo({state:e,dom:t=wn}){let n=G(e=>e.appSettingsError);return(0,H.jsxs)(H.Fragment,{children:[n?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:n}):null,(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(_a,{state:e}),(0,H.jsx)(ao,{state:e}),(0,H.jsx)(Wa,{state:e,dom:t})]}),(0,H.jsx)(uo,{state:e}),(0,H.jsx)(Qa,{state:e})]})}var po=I()(e=>({draft:``,persistedAtMount:``,error:null,setDraft:t=>e({draft:t}),persistedChanged:t=>e({persistedAtMount:t,draft:t}),setError:t=>e({error:t})})),mo=`settings.globalInstructions`;function ho({state:e}){let t=z(e=>e.settings?.globalPromptAppend??``),n=po(e=>e.draft),r=po(e=>e.setDraft),i=po(e=>e.persistedAtMount),a=po(e=>e.persistedChanged),o=M(mo),s=po(e=>e.error),c=po(e=>e.setError);(0,V.useEffect)(()=>{t!==i&&a(t)},[t,i,a]);let l=n.replace(/\s+$/u,``),u=l.length>Mt,d=l!==t,f=o||u||!d,p=(0,V.useCallback)(async()=>{f||await B(c,()=>e.handleWriteAppSettings({globalPromptAppend:l}))},[f,e,l,c]),m;return m=o?`Saving…`:d?`Save`:`Saved`,(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(U,{title:`Global Instructions`,description:`Appended to every Claude and Codex turn — including subagent turns — as “Workspace instructions”. Kanna does not read CLAUDE.md or AGENTS.md from disk; paste your global instructions here. For rules that apply to one project only, use “Edit instructions” in that project's sidebar menu. Leave blank to disable.`,bordered:!1,alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,H.jsx)(`textarea`,{value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Always write tests before implementation. Prefer Tailwind classes over inline styles.`,rows:8,"aria-label":`Global instructions`,className:D(`min-h-[160px] w-full resize-y rounded-md border bg-background px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,u?`border-destructive`:`border-input`),disabled:o}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,H.jsxs)(`span`,{className:u?`text-destructive`:`text-muted-foreground`,children:[l.length,` / `,Mt,` characters`,u?` — over limit`:``]}),(0,H.jsx)(k,{type:`button`,size:`sm`,onClick:()=>j(mo,p),disabled:f,pending:o,children:m})]}),s?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:s}):null]})})})}function go(e){return{async onReload(t){await On(e,{type:`plugins.reload`,pluginId:t})}}}function _o({plugins:e,handlers:t}){return e.length===0?(0,H.jsx)(Yr,{icon:u,message:`No plugins installed yet.`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plugins`}),(0,H.jsx)(Xr,{children:e.map(e=>(0,H.jsx)(vo,{plugin:e,onReload:t.onReload},e.id))})]})}function vo({plugin:e,onReload:t}){let n=N(`plugins.reload`,e.id),r=M(n),i=(0,V.useCallback)(()=>{j(n,()=>t(e.id))},[t,e.id,n]);return(0,H.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.id}),(0,H.jsx)(jn,{tone:e.enabled?`active`:`muted`,label:e.enabled?`Enabled`:`Disabled`})]}),(0,H.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.sourceDir})]}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,"data-testid":`plugin-reload:${e.id}`,pending:r,onClick:i,children:`Reload`})]})}function yo(){let e=z(qt),t=z(en),n=kn(),r=(0,V.useMemo)(()=>go(n),[n]);return e?(0,H.jsx)(_o,{plugins:t,handlers:r}):null}var bo={},xo=I()(e=>({drafts:bo,error:null,setDrafts:t=>e({drafts:t}),setDraft:(t,n)=>e(e=>e.drafts[t]===n?e:{drafts:{...e.drafts,[t]:n}}),setError:t=>e({error:t})}));function So(e){let t={};for(let n of Ut)t[n]=h(e[n]??``);return{...cn,...t}}function Co(e){return N(`settings.writeKeybindings`,e)}function wo({action:e,currentValue:t,bordered:n,onDraftChange:r,onCommit:i,onRestoreDefault:a}){let o=Co(e),s=M(o),c=p(cn[e]),l=t!==c,u=()=>{j(o,i)};return(0,H.jsx)(U,{title:ee[e],description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Comma-separated shortcuts.`}),l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:` `}),(0,H.jsxs)(`button`,{type:`button`,disabled:s,"aria-busy":s||void 0,onClick:()=>{j(o,()=>a(e))},className:`inline rounded text-foreground hover:text-foreground/80 disabled:opacity-60`,children:[`Restore: `,c]})]}):null]}),bordered:n,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 items-center gap-2`,children:[(0,H.jsx)(R,{type:`text`,value:t,"aria-busy":s||void 0,onChange:t=>r(e,t.target.value),onBlur:u,onKeyDown:e=>na(e,u),className:`font-mono`}),s?(0,H.jsx)(E,{}):null]})})}function To({state:e}){let t=xo(e=>e.drafts),n=xo(e=>e.setDrafts),r=xo(e=>e.setDraft),i=xo(e=>e.error),a=xo(e=>e.setError),o=(0,V.useMemo)(()=>T(e.keybindings),[e.keybindings]);(0,V.useEffect)(()=>{n(Object.fromEntries(Ut.map(e=>[e,p(o.bindings[e])])))},[o,n]);async function s(t){await B(a,async()=>{await e.socket.command({type:`settings.writeKeybindings`,bindings:So(t)})})}async function c(){await s(t)}async function l(e){let r={...t,[e]:p(cn[e])};n(r),await s(r)}return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[i?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:i}):null,o.warning?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:o.warning}):null,Ut.map((e,n)=>(0,H.jsx)(wo,{action:e,currentValue:t[e]??``,bordered:n!==0,onDraftChange:r,onCommit:c,onRestoreDefault:l},e))]})}function Eo(e){return e===null?{name:``,transport:`stdio`,command:``,argsText:``,envText:``,cwd:``,url:``,headersText:``}:e.transport===`stdio`?{name:e.name,transport:`stdio`,command:e.command,argsText:e.args.join(`
|
|
2
|
+
`),envText:Object.entries(e.env).map(([e,t])=>`${e}=${t}`).join(`
|
|
3
|
+
`),cwd:e.cwd??``,url:``,headersText:``}:{name:e.name,transport:e.transport,command:``,argsText:``,envText:``,cwd:``,url:e.url,headersText:Object.entries(e.headers).map(([e,t])=>`${e}: ${t}`).join(`
|
|
4
|
+
`)}}function Do(e,t,n){let r={};for(let i of e.split(`
|
|
5
|
+
`)){let e=i.indexOf(t);if(e<=0)continue;let a=i.slice(e+1);r[i.slice(0,e).trim()]=n?a.trim():a}return r}function Oo(e){return e.transport===`stdio`?{name:e.name,transport:`stdio`,command:e.command,args:e.argsText.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),env:Do(e.envText,`=`,!1),cwd:e.cwd||void 0}:{name:e.name,transport:e.transport,url:e.url,headers:Do(e.headersText,`:`,!0)}}var ko={kind:`list`};function Ao(e){return{...Eo(e),error:null,oauthEnabled:e!==null&&e.transport!==`stdio`?e.oauth?.enabled??!1:!1,authFlowUrl:null,callbackInput:``,oauthError:null,authenticating:!1,completing:!1}}var jo=I()(e=>({editing:ko,editorForm:Ao(null),setEditing:t=>e({editing:t}),resetEditorForm:t=>e({editorForm:Ao(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))})),Mo={customMcpServers:e=>({customMcpServers:e}),mcpSources:e=>({mcpSources:e}),customModels:e=>({customModels:e}),customProviders:e=>({customProviders:e}),textSnippets:e=>({textSnippets:e})},No={customMcpServers:e=>({customMcpServers:{setEnabled:e}}),mcpSources:e=>({mcpSources:{setEnabled:e}})};function Po(e,t){return(0,V.useMemo)(()=>{let n=Mo[e];return{onCreate:async e=>{await t.handleWriteAppSettings(n({create:e}))},onUpdate:async(e,r)=>{await t.handleWriteAppSettings(n({update:{id:e,patch:r}}))},onDelete:async e=>{await t.handleWriteAppSettings(n({delete:{id:e}}))}}},[e,t])}function Fo(e,t){return(0,V.useCallback)(async(n,r)=>{await t.handleWriteAppSettings(No[e]({id:n,enabled:r}))},[e,t])}async function Io(e){e.patch({error:null});try{await e.save(),e.onDone()}catch(t){e.patch({error:L(t)})}}function Lo(e){return e.submitting?`Saving…`:e.isEdit?`Save changes`:e.addLabel}function Ro({server:e,handlers:t,onEdit:n,dom:r=wn}){let i=N(`mcpServers.delete`,e.id),a=M(i),o=N(`mcpServers.setEnabled`,e.id),s=M(o),c=N(`settings.testMcpServer`,e.id),l=M(c),u=(0,V.useCallback)(()=>{r.confirmDialog(`Delete MCP server "${e.name}"?`)&&j(i,()=>t.onDelete(e.id))},[i,r,t,e.id,e.name]),d=(0,V.useCallback)(n=>{let r=n.target.checked;j(o,()=>t.onSetEnabled(e.id,r))},[t,e.id,o]),f=(0,V.useCallback)(()=>{j(c,()=>t.onTest(e.id))},[t,e.id,c]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,H.jsx)(zo,{transport:e.transport}),(0,H.jsx)(`span`,{className:`ml-2`,children:e.transport===`stdio`?e.command:e.url})]})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(Bo,{result:e.lastTest,pending:l}),e.transport!==`stdio`&&(0,H.jsx)(Vo,{oauth:e.oauth}),(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[s?(0,H.jsx)(E,{}):null,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:s,"aria-busy":s||void 0,onChange:d,"aria-label":`Enabled`}),(0,H.jsx)(`span`,{children:`On`})]}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:f,disabled:l,"aria-busy":l||void 0,title:`Test connection`,children:(0,H.jsx)(je,{className:D(`h-4 w-4`,l&&`animate-spin`)})}),(0,H.jsx)(Zr,{label:e.name,onEdit:n,onDelete:u,deletePending:a})]})]})}function zo({transport:e}){return(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:e})}function Bo({result:e,pending:t}){if(t||e.status===`pending`)return(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Testing…`});switch(e.status){case`ok`:return(0,H.jsxs)(`span`,{className:`text-xs text-green-600`,children:[`OK · `,e.toolCount,` tools`]});case`error`:return(0,H.jsx)(En,{label:e.message,children:(0,H.jsx)(`span`,{className:`text-xs text-red-600`,children:`Failed`})});default:return(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Untested`})}}function Vo({oauth:e}){if(!e?.enabled)return null;switch(e.status){case`authenticated`:return(0,H.jsx)(`span`,{className:`text-xs text-green-600`,children:`OAuth ✓`});case`error`:return(0,H.jsx)(En,{label:e.errorMessage,children:(0,H.jsx)(`span`,{className:`text-xs text-red-600`,children:`OAuth error`})});default:return(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`OAuth: unauth`})}}var Ho=new Set([`stdio`,`http`,`sse`,`ws`]);function Uo(e){return Ho.has(e)}var Wo=`new`;function Go({pending:e,copied:t}){return e?(0,H.jsx)(E,{className:`size-3`}):t?(0,H.jsx)(_e,{className:`h-3 w-3 text-success-text`}):(0,H.jsx)(me,{className:`h-3 w-3`})}function Ko(e){return e.editing.kind===`list`?e.servers.length===0?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,H.jsx)(Nr,{className:`mb-4 h-10 w-10 text-muted-foreground`,"aria-hidden":!0}),(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:`No custom MCP servers`}),(0,H.jsx)(`p`,{className:`mt-2 max-w-md text-sm text-muted-foreground`,children:`Install MCP servers to extend the model's tool surface. Supports stdio, http, sse, and ws transports.`}),(0,H.jsxs)(k,{className:`mt-6`,onClick:e.onStartCreate,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add server`]})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Custom MCP servers`}),(0,H.jsxs)(k,{size:`sm`,onClick:e.onStartCreate,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add server`]})]}),(0,H.jsx)(Xr,{children:e.servers.map(t=>(0,H.jsx)(Ro,{server:t,handlers:e.handlers,onEdit:()=>e.onSelect(t.id),dom:e.dom},t.id))})]}):(0,H.jsx)(qo,{initial:e.editing.kind===`edit`?e.servers.find(t=>e.editing.kind===`edit`&&t.id===e.editing.id)??null:null,existingNames:e.servers.map(e=>({id:e.id,name:e.name})),onCancel:e.onCancelEditing,handlers:e.handlers})}function qo({initial:e,existingNames:t,onCancel:n,handlers:r,clipboard:i=he}){let a=jo(e=>e.editorForm),o=jo(e=>e.resetEditorForm),s=jo(e=>e.patchEditorForm),c=(0,V.useCallback)(e=>{Uo(e)&&s({transport:e})},[s]),{name:l,transport:u,command:d,argsText:f,envText:p,cwd:m,url:h,headersText:g,error:_,oauthEnabled:v,authFlowUrl:y,callbackInput:b,oauthError:x,authenticating:S,completing:ee}=a,C=(0,V.useRef)(e);(0,V.useEffect)(()=>{o(C.current)},[o]);let te=e!==null&&e.transport!==`stdio`?e.oauth:void 0,w=e?.id??Wo,ne=N(`mcpServers.save`,w),re=M(ne),ie=N(`mcpServers.toggleOAuth`,w),ae=M(ie),T=N(`mcpServers.copyAuthUrl`,w),oe=M(T),D=ge(T),O=(0,V.useCallback)(async t=>{s(t?{oauthEnabled:!0}:{oauthEnabled:!1,authFlowUrl:null,callbackInput:``,oauthError:null}),e&&await r.onUpdate(e.id,{oauth:{...te??{status:`unauthenticated`},enabled:t}})},[e,te,r,s]),se=(0,V.useCallback)(async()=>{if(e){s({authenticating:!0,oauthError:null});try{let t=await r.onStartMcpOAuth(e.id);t.ok?s({authFlowUrl:`authorizationUrl`in t?t.authorizationUrl:null}):s({oauthError:t.error})}finally{s({authenticating:!1})}}},[e,r,s]),A=(0,V.useCallback)(async()=>{if(e){s({completing:!0,oauthError:null});try{let t=await r.onCompleteMcpOAuth(e.id,b);t.ok?s({authFlowUrl:null,callbackInput:``}):s({oauthError:t.error})}finally{s({completing:!1})}}},[e,b,r,s]),ce=(0,V.useCallback)(e=>{let t=e.target.checked;j(ie,()=>O(t))},[O,ie]),le=(0,V.useCallback)(()=>{j(N(`settings.startMcpOAuth`,w),se)},[w,se]),ue=(0,V.useCallback)(()=>{j(N(`settings.completeMcpOAuth`,w),A)},[A,w]),de=(0,V.useCallback)(()=>{y&&j(T,()=>ve(T,()=>i.writeText(y)))},[y,i,T]),fe=(0,V.useMemo)(()=>{if(l.length===0)return null;let n=vn(l);return n===`INVALID_NAME`?`Name must start with a letter and contain only letters, digits, '_' or '-' (max 32 chars).`:n===`RESERVED_NAME`?`'${l}' is reserved.`:t.find(t=>t.name===l&&t.id!==e?.id)?`Name already taken.`:null},[l,t,e?.id]),pe=(0,V.useCallback)(async()=>{fe||await Io({patch:s,save:async()=>{let t=Oo({name:l,transport:u,command:d,argsText:f,envText:p,cwd:m,url:h,headersText:g});e?await r.onUpdate(e.id,t):await r.onCreate(t)},onDone:n})},[f,d,m,p,r,g,e,l,fe,n,u,h,s]),me=(0,V.useCallback)(()=>{j(ne,pe)},[ne,pe]),_e=Lo({submitting:re,isEdit:e!==null,addLabel:`Add server`});return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6 max-w-2xl`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:e?`Edit MCP server`:`Add MCP server`}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Name`}),(0,H.jsx)(R,{value:l,onChange:e=>s({name:e.target.value}),placeholder:`fs`}),fe&&(0,H.jsx)(`p`,{className:`text-xs text-red-600`,children:fe})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Transport`}),(0,H.jsxs)(Ce,{value:u,onValueChange:c,children:[(0,H.jsx)(ye,{children:(0,H.jsx)(xe,{})}),(0,H.jsxs)(be,{children:[(0,H.jsx)(P,{value:`stdio`,children:`stdio (spawn local command)`}),(0,H.jsx)(P,{value:`http`,children:`http (Streamable HTTP)`}),(0,H.jsx)(P,{value:`sse`,children:`sse (Server-Sent Events)`}),(0,H.jsx)(P,{value:`ws`,children:`ws (WebSocket)`})]})]})]}),u===`stdio`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Command`}),(0,H.jsx)(R,{value:d,onChange:e=>s({command:e.target.value}),placeholder:`/usr/local/bin/mcp-filesystem`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Args (one per line)`}),(0,H.jsx)(Dn,{value:f,onChange:e=>s({argsText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Env (KEY=value, one per line)`}),(0,H.jsx)(Dn,{value:p,onChange:e=>s({envText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`cwd (optional)`}),(0,H.jsx)(R,{value:m,onChange:e=>s({cwd:e.target.value}),placeholder:`/optional/working/dir`})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`URL`}),(0,H.jsx)(R,{value:h,onChange:e=>s({url:e.target.value}),placeholder:u===`ws`?`wss://example.com/mcp`:`https://example.com/mcp`})]}),u===`ws`?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Headers are not supported on the ws transport.`}):(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Headers (Key: value, one per line)`}),(0,H.jsx)(Dn,{value:g,onChange:e=>s({headersText:e.target.value}),rows:3,className:`font-mono text-sm`,disabled:v}),v&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Authorization header is managed by OAuth when enabled.`})]}),(u===`http`||u===`sse`)&&(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Xn,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`text-xs font-medium`,children:`OAuth 2.1`}),(0,H.jsxs)(`label`,{className:`ml-auto flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[ae?(0,H.jsx)(E,{}):null,(0,H.jsx)(`input`,{type:`checkbox`,checked:v,disabled:ae,"aria-busy":ae||void 0,onChange:ce,"aria-label":`Enable OAuth`}),(0,H.jsx)(`span`,{children:`Enable`})]})]}),v&&!e&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save the server first, then authenticate.`}),v&&e&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Vo,{oauth:te}),te?.status===`authenticated`&&(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:le,pending:S,children:`Re-authenticate`})]}),(te?.status!==`authenticated`||y)&&(y?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(`a`,{href:y,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-blue-600 underline`,children:[`Open authorization URL`,(0,H.jsx)(Ln,{className:`h-3 w-3`})]}),(0,H.jsx)(En,{label:D?`Copied`:`Copy URL`,children:(0,H.jsx)(`button`,{type:`button`,onClick:de,disabled:oe,"aria-busy":oe||void 0,className:`ml-1 text-muted-foreground hover:text-foreground`,"aria-label":D?`Copied`:`Copy authorization URL`,children:(0,H.jsx)(Go,{pending:oe,copied:D})})})]}),(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`After authorizing, paste the callback URL here:`}),(0,H.jsx)(R,{value:b,onChange:e=>s({callbackInput:e.target.value}),placeholder:`http://localhost:…/callback?code=…`,className:`font-mono text-xs`})]}),(0,H.jsx)(k,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:ue,pending:ee,disabled:b.length===0,children:ee?`Completing…`:`Complete`})]}):(0,H.jsx)(k,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:le,pending:S,children:S?`Starting…`:`Authenticate`})),x&&(0,H.jsx)(`p`,{className:`text-xs text-red-600`,children:x})]})]})]}),_&&(0,H.jsx)(`p`,{className:`text-xs text-red-600`,children:_}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,H.jsx)(k,{variant:`ghost`,onClick:n,disabled:re,children:`Cancel`}),(0,H.jsx)(k,{onClick:me,pending:re,disabled:!!fe||l.length===0,children:_e})]})]})}function Jo(e){let t=z(Xt),n=jo(e=>e.editing),r=jo(e=>e.setEditing),i=Po(`customMcpServers`,e.state),a=Fo(`customMcpServers`,e.state),o=(0,V.useMemo)(()=>({...i,onDelete:async e=>{await i.onDelete(e),r({kind:`list`})},onSetEnabled:a,onTest:async t=>{await e.state.handleTestMcpServer(t)},onStartMcpOAuth:async t=>e.state.handleStartMcpOAuth(t),onCompleteMcpOAuth:async(t,n)=>e.state.handleCompleteMcpOAuth(t,n)}),[i,a,e.state,r]);return(0,H.jsx)(Ko,{servers:t,editing:n,onSelect:e=>r({kind:`edit`,id:e}),onStartCreate:()=>r({kind:`create`}),onCancelEditing:()=>r({kind:`list`}),handlers:o})}var Yo=[`subscribe`,`poll`],Xo=5e3,Zo=36e5,Qo=yt(Yo),$o={disabled:`Disabled`,connecting:`Connecting`,listening:`Listening`,polling:`Polling`,backoff:`Retrying`,error:`Error`},es={disabled:`muted`,connecting:`attention`,listening:`muted`,polling:`muted`,backoff:`attention`,error:`destructive`},ts={subscribe:`Subscribe`,poll:`Poll`},ns={subscribe:`Kanna listens for change notifications on the resources you name, reads each one that changes and catches up after a reconnect. A resync interval re-reads them on a timer. Needs a server that supports resource subscriptions.`,poll:`Kanna calls a tool on an interval and remembers a cursor, so each message is delivered once.`};function rs(e){return $o[e]}function is(e){return es[e]}function as(e){return ts[e]}function os(e){return ns[e]}function ss(){return`Between ${Xo/1e3} and ${Zo/1e3}.`}var cs=[`zalo`],ls={zalo:{label:`Zalo`,mode:`subscribe`,resourceUris:[`zalo://inbox`],itemsPath:`messages`,itemKeyPath:`id`,resyncIntervalMs:3e5,threadKeyPath:`threadId`,senderPath:`senderName`,textPath:`text`,handler:{mode:`spawn`,template:`A new Zalo message arrived in a conversation. Read it, decide whether the user needs to act, and draft a reply in the same language the sender used.`,replyHint:`Send the reply with zalo_send_message using threadId {{threadId}} and threadType {{threadType}}: pass 0 when threadType is "dm" and 1 when it is "group".`,pushEnabled:!0}}};function us(e){return e.trim().length>0}function ds(e){return[...ir(e.handler),...er(e.handler.template,{required:!0}),...$n(e.handler.replyHint)]}function fs(e){if(e.mode===`subscribe`)return e.resourceUris.some(us)?[]:[`At least one resource URI is required`];let t=[],n=[[`Tool`,e.tool],[`Cursor argument`,e.cursorArg],[`Cursor path`,e.cursorPath],[`Items path`,e.itemsPath]];for(let[e,r]of n)us(r)||t.push(`${e} is required`);return Sn(e.args)||t.push(`Arguments must be a JSON object`),t}function ps(e){let t=[];return t.push(...nr(e.name)),us(e.serverId)||t.push(`An MCP server is required`),Qo(e.mode)?t.push(...fs(e)):t.push(`Mode must be subscribe or poll`),t.push(...sr([e.threadKeyPath,e.senderPath,e.textPath,e.itemsPath,e.itemKeyPath])),t.push(...ds(e)),t}function ms(e){let t=e.trim();if(t.length===0)return{args:{}};let n=yn(t);return n!==null&&Sn(n)?{args:n}:{error:`Arguments must be a JSON object`}}var hs=`A new message arrived. Read it, decide whether the user needs to act, and draft a reply if one is appropriate.`,gs=`30`;function _s(){return{name:``,serverId:``,mode:`subscribe`,resourceUris:``,subscribeItemsPath:``,subscribeItemKeyPath:``,resyncSeconds:``,tool:``,argsText:`{}`,cursorArg:``,cursorPath:``,itemsPath:``,itemKeyPath:``,intervalSeconds:gs,threadKeyPath:``,senderPath:``,textPath:``,handlerMode:`spawn`,chatId:``,projectId:``,modelValue:``,template:hs,replyHint:``,pushEnabled:!0}}function vs(e){return{handlerMode:e.mode,chatId:e.chatId??``,projectId:e.projectId??``,modelValue:e.provider&&e.model?ar(e.provider,e.model):``,template:e.template,replyHint:e.replyHint,pushEnabled:e.pushEnabled}}function ys(e){let t={..._s(),name:e.name,serverId:e.serverId,mode:e.mode,threadKeyPath:e.threadKeyPath,senderPath:e.senderPath,textPath:e.textPath,...vs(e.handler)};return e.mode===`subscribe`?{...t,resourceUris:e.resourceUris.join(`
|
|
7
|
+
`),subscribeItemsPath:e.itemsPath,subscribeItemKeyPath:e.itemKeyPath??``,resyncSeconds:bs(e.resyncIntervalMs)}:{...t,tool:e.tool,argsText:JSON.stringify(e.args,null,2),cursorArg:e.cursorArg,cursorPath:e.cursorPath,itemsPath:e.itemsPath,itemKeyPath:e.itemKeyPath??``,intervalSeconds:String(Math.round(e.intervalMs/1e3))}}function bs(e){return e===null?``:String(Math.round(e/1e3))}function xs(e,t){let n=ls[t],r={...e,name:e.name.trim().length>0?e.name:n.label,mode:n.mode,threadKeyPath:n.threadKeyPath,senderPath:n.senderPath,textPath:n.textPath??``,...vs({...n.handler,projectId:e.projectId||void 0})};return n.mode===`subscribe`?{...r,resourceUris:n.resourceUris.join(`
|
|
8
|
+
`),subscribeItemsPath:n.itemsPath??``,subscribeItemKeyPath:n.itemKeyPath??``,resyncSeconds:bs(n.resyncIntervalMs??null)}:{...r,tool:n.tool,argsText:JSON.stringify(n.args,null,2),cursorArg:n.cursorArg,cursorPath:n.cursorPath,itemsPath:n.itemsPath,itemKeyPath:n.itemKeyPath??``,intervalSeconds:String(Math.round(n.intervalMs/1e3))}}function Ss(e){let t=e.handlerMode===`notify`?null:rr(e.modelValue);return{mode:e.handlerMode,template:e.template,replyHint:e.replyHint,pushEnabled:e.pushEnabled,...Qn(e.handlerMode,e.chatId,e.projectId),...t?{provider:t.provider,model:t.model}:{}}}function Cs(e){let t={name:e.name.trim(),serverId:e.serverId,threadKeyPath:e.threadKeyPath.trim(),senderPath:e.senderPath.trim(),textPath:e.textPath.trim(),handler:Ss(e)};if(e.mode===`subscribe`){let n=e.resyncSeconds.trim(),r=Number(n),i=n.length===0||Number.isFinite(r)&&r>0,a={...t,mode:`subscribe`,resourceUris:e.resourceUris.split(`
|
|
9
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),itemsPath:e.subscribeItemsPath.trim(),itemKeyPath:e.subscribeItemKeyPath.trim()||null,resyncIntervalMs:n.length>0&&i?Math.round(r*1e3):null},o=[...i?[]:[`Resync interval must be a number of seconds`],...ps(a)];return o.length>0?{ok:!1,errors:o}:{ok:!0,input:a}}let n=ms(e.argsText),r=Number(e.intervalSeconds),i={...t,mode:`poll`,tool:e.tool.trim(),args:`args`in n?n.args:{},cursorArg:e.cursorArg.trim(),cursorPath:e.cursorPath.trim(),itemsPath:e.itemsPath.trim(),itemKeyPath:e.itemKeyPath.trim()||null,intervalMs:Number.isFinite(r)?Math.round(r*1e3):Xo},a=[...`error`in n?[n.error]:[],...Number.isFinite(r)&&r>0?[]:[`Interval must be a number of seconds`],...ps(i)];return a.length>0?{ok:!1,errors:a}:{ok:!0,input:i}}function ws(e){let{enabled:t,...n}=e;return n}var Ts=I()(e=>({editing:ko,draft:_s(),error:null,confirmingDeleteId:null,startCreate:()=>e({editing:{kind:`create`},draft:_s(),error:null}),startEdit:t=>e({editing:{kind:`edit`,id:t.id},draft:ys(t),error:null}),closeEditor:()=>e({editing:ko,error:null}),patchDraft:t=>e(e=>({draft:{...e.draft,...t}})),applyPreset:t=>e(e=>({draft:xs(e.draft,t)})),setError:t=>e({error:t}),askDelete:t=>e({confirmingDeleteId:t}),cancelDelete:()=>e({confirmingDeleteId:null})})),Es=[`subscribe`,`poll`].map(e=>({value:e,label:as(e)}));function K({id:e,label:t,hint:n,children:r}){return(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`label`,{htmlFor:e,className:`block text-sm font-medium text-foreground`,children:t}),r,n?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}):null]})}function Ds(e,t){let n=e.filter(e=>e.transport!==`ws`&&(e.enabled||e.id===t)),r=n.filter(e=>e.transport!==`stdio`),i=n.filter(e=>e.transport===`stdio`);return[...r,...i].map(e=>({value:e.id,label:e.name,hint:e.transport}))}function Os({draft:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(K,{id:`mcp-source-uris`,label:`Resource URIs`,hint:`One URI per line. Kanna subscribes to each and reads it whenever the server says it changed.`,children:(0,H.jsx)(Dn,{id:`mcp-source-uris`,rows:3,className:`font-mono`,value:e.resourceUris,onChange:e=>t({resourceUris:e.target.value})})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(K,{id:`mcp-source-sub-items-path`,label:`Items path`,hint:`Optional. Where the array of messages sits in the resource. Leave empty to deliver the whole resource as one message.`,children:(0,H.jsx)(R,{id:`mcp-source-sub-items-path`,className:`font-mono`,value:e.subscribeItemsPath,onChange:e=>t({subscribeItemsPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-sub-item-key`,label:`Item key path`,hint:`Optional. A field that is unique per message. Leave empty to hash the whole item.`,children:(0,H.jsx)(R,{id:`mcp-source-sub-item-key`,className:`font-mono`,value:e.subscribeItemKeyPath,onChange:e=>t({subscribeItemKeyPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-resync`,label:`Resync every (seconds)`,hint:`Optional. Re-reads the resources on a timer to catch missed notifications. ${ss()}`,children:(0,H.jsx)(R,{id:`mcp-source-resync`,inputMode:`numeric`,className:`tabular-nums`,value:e.resyncSeconds,onChange:e=>t({resyncSeconds:e.target.value})})})]})]})}function ks({draft:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(K,{id:`mcp-source-tool`,label:`List tool`,hint:`The tool Kanna calls on every poll.`,children:(0,H.jsx)(R,{id:`mcp-source-tool`,className:`font-mono`,value:e.tool,onChange:e=>t({tool:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-args`,label:`Arguments`,hint:`A JSON object sent with every call. The cursor is added under the cursor argument.`,children:(0,H.jsx)(Dn,{id:`mcp-source-args`,rows:3,className:`font-mono`,value:e.argsText,onChange:e=>t({argsText:e.target.value})})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(K,{id:`mcp-source-cursor-arg`,label:`Cursor argument`,children:(0,H.jsx)(R,{id:`mcp-source-cursor-arg`,className:`font-mono`,value:e.cursorArg,onChange:e=>t({cursorArg:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-cursor-path`,label:`Cursor path`,hint:`Where the next cursor sits in the result.`,children:(0,H.jsx)(R,{id:`mcp-source-cursor-path`,className:`font-mono`,value:e.cursorPath,onChange:e=>t({cursorPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-items-path`,label:`Items path`,hint:`Where the array of messages sits in the result.`,children:(0,H.jsx)(R,{id:`mcp-source-items-path`,className:`font-mono`,value:e.itemsPath,onChange:e=>t({itemsPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-item-key`,label:`Item key path`,hint:`A field that is unique per message. Leave empty to hash the whole item.`,children:(0,H.jsx)(R,{id:`mcp-source-item-key`,className:`font-mono`,value:e.itemKeyPath,onChange:e=>t({itemKeyPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-interval`,label:`Interval (seconds)`,hint:ss(),children:(0,H.jsx)(R,{id:`mcp-source-interval`,inputMode:`numeric`,className:`tabular-nums`,value:e.intervalSeconds,onChange:e=>t({intervalSeconds:e.target.value})})})]})]})}function As({presetId:e,onApply:t}){let n=(0,V.useCallback)(()=>t(e),[t,e]);return(0,H.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:n,children:[ls[e].label,` preset`]})}function js({editing:e,servers:t,sidebarData:n,handlers:r}){let i=tt(),a=Ts(e=>e.draft),o=Ts(e=>e.error),s=Ts(e=>e.patchDraft),c=Ts(e=>e.applyPreset),l=Ts(e=>e.closeEditor),u=Ts(e=>e.setError),d=N(`mcpSources.save`,e?.id??`new`),f=M(d),p=(0,V.useMemo)(()=>Zn(n),[n]),m=(0,V.useMemo)(()=>tr(i),[i]),h=(0,V.useMemo)(()=>Ds(t,a.serverId),[t,a.serverId]),g=(0,V.useMemo)(()=>Cs(a),[a]),_=a.handlerMode!==`notify`,v=(0,V.useCallback)(e=>s({name:e.target.value}),[s]),y=(0,V.useCallback)(()=>{g.ok&&j(d,()=>B(u,async()=>{e?await r.onUpdate(e.id,ws(g.input)):await r.onCreate(g.input),l()}))},[l,e,r,g,d,u]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:e?`Edit MCP source`:`Add MCP source`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:cs.map(e=>(0,H.jsx)(As,{presetId:e,onApply:c},e))})]}),(0,H.jsx)(K,{id:`mcp-source-name`,label:`Name`,children:(0,H.jsx)(R,{id:`mcp-source-name`,value:a.name,onChange:v,placeholder:`Zalo`,autoFocus:!0})}),(0,H.jsx)(K,{id:`mcp-source-server`,label:`MCP server`,hint:`A stdio server started here is a separate process from the one your chats use — prefer http or sse.`,children:(0,H.jsx)(or,{id:`mcp-source-server`,value:a.serverId,options:h,placeholder:`Choose an MCP server`,searchPlaceholder:`Search servers...`,emptyMessage:`Add an MCP server first`,onValueChange:e=>s({serverId:e})})}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`How messages arrive`}),(0,H.jsx)(F,{value:a.mode,onValueChange:e=>s({mode:e}),options:Es,size:`sm`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:os(a.mode)})]}),a.mode===`subscribe`?(0,H.jsx)(Os,{draft:a,onChange:s}):(0,H.jsx)(ks,{draft:a,onChange:s}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(K,{id:`mcp-source-thread-key`,label:`Thread key path`,hint:`Messages with the same value share one Inbox thread.`,children:(0,H.jsx)(R,{id:`mcp-source-thread-key`,className:`font-mono`,value:a.threadKeyPath,onChange:e=>s({threadKeyPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-sender`,label:`Sender path`,hint:`Shown as the sender of the thread.`,children:(0,H.jsx)(R,{id:`mcp-source-sender`,className:`font-mono`,value:a.senderPath,onChange:e=>s({senderPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-text`,label:`Text path`,hint:`Optional. The field holding the message text, shown as the Inbox preview. Leave empty to show the raw item.`,children:(0,H.jsx)(R,{id:`mcp-source-text`,className:`font-mono`,value:a.textPath,onChange:e=>s({textPath:e.target.value})})})]}),(0,H.jsx)(lr,{idPrefix:`mcp-source`,mode:a.handlerMode,chatId:a.chatId,projectId:a.projectId,modelValue:a.modelValue,targets:p,modelOptions:m,modelHint:`The model the turn started by each message runs with.`,showModeControl:!0,startsTurn:_,onModeChange:e=>s({handlerMode:e}),onChatChange:e=>s({chatId:e}),onProjectChange:e=>s({projectId:e}),onModelChange:e=>s({modelValue:e})}),(0,H.jsx)(K,{id:`mcp-source-template`,label:`Instruction template`,hint:(0,H.jsxs)(H.Fragment,{children:[`Insert fields from the message with `,(0,H.jsx)(`code`,{className:`font-mono`,children:`{{senderName}}`}),`. The message is appended as untrusted data.`]}),children:(0,H.jsx)(Dn,{id:`mcp-source-template`,rows:4,value:a.template,onChange:e=>s({template:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-reply-hint`,label:`Reply hint`,hint:`Tells the agent how to send a reply through the server's tools when you answer from the Inbox.`,children:(0,H.jsx)(Dn,{id:`mcp-source-reply-hint`,rows:3,value:a.replyHint,onChange:e=>s({replyHint:e.target.value})})}),(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:a.pushEnabled,onChange:e=>s({pushEnabled:e.target.checked}),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),`Send a push notification for new messages`]}),!g.ok&&a.name.length>0?(0,H.jsx)(`p`,{className:`text-xs text-destructive-text`,children:g.errors[0]}):null,o?(0,H.jsx)(`p`,{className:`text-xs text-destructive-text`,children:o}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:y,pending:f,disabled:!g.ok,children:e?`Save changes`:`Add source`}),(0,H.jsx)(k,{variant:`ghost`,onClick:l,disabled:f,children:`Cancel`})]})]})}function Ms({source:e,serverName:t,status:n,now:r,confirmingDelete:i,handlers:a}){let o=Ts(e=>e.startEdit),s=Ts(e=>e.askDelete),c=Ts(e=>e.cancelDelete),l=N(`mcpSources.setEnabled`,e.id),u=N(`mcpSources.delete`,e.id),d=M(l),f=M(u),p=n?.state??(e.enabled?`connecting`:`disabled`),m=An(n?.lastItemAt??void 0,r),h=(0,V.useCallback)(()=>{j(l,()=>a.onSetEnabled(e.id,!e.enabled))},[l,a,e.enabled,e.id]),g=(0,V.useCallback)(()=>o(e),[e,o]),_=(0,V.useCallback)(()=>s(e.id),[s,e.id]),v=(0,V.useCallback)(()=>{j(u,async()=>{await a.onDelete(e.id),c()})},[c,u,a,e.id]);return(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3`,"aria-busy":d||f||void 0,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,H.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[t,` · `,as(e.mode)]}),n?.lastError?(0,H.jsx)(`span`,{className:`text-xs text-destructive-text`,children:n.lastError}):null]}),(0,H.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-3 text-xs text-muted-foreground`,children:[(0,H.jsx)(jn,{tone:is(p),label:rs(p)}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:m?`last ${m}`:`no items yet`}),(0,H.jsxs)(`span`,{className:`tabular-nums`,children:[n?.itemCount??0,` items`]}),(0,H.jsx)(k,{variant:`secondary`,size:`sm`,onClick:h,pending:d,children:e.enabled?`Disable`:`Enable`}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:g,"aria-label":`Edit ${e.name}`,children:`Edit`}),i?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(k,{variant:`destructive`,size:`sm`,onClick:v,pending:f,children:[`Delete `,e.name,`?`]}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:c,disabled:f,children:`Keep`})]}):(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:_,"aria-label":`Delete ${e.name}`,children:`Delete`})]})]})}function Ns({sources:e,statuses:t,servers:n,sidebarData:r,handlers:i}){let a=Ts(e=>e.editing),o=Ts(e=>e.confirmingDeleteId),s=Ts(e=>e.startCreate),c=Pn(3e4);if(a.kind!==`list`){let t=a.kind===`edit`?e.find(e=>e.id===a.id)??null:null;return(0,H.jsx)(js,{editing:t,servers:n,sidebarData:r,handlers:i})}return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`MCP sources`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Let Kanna listen to an MCP server you already added, such as a Zalo or mail server, and put what arrives into the Inbox. Replies go back out through the same server.`})]}),(0,H.jsxs)(k,{size:`sm`,onClick:s,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add source`]})]}),e.length===0?(0,H.jsx)(Yr,{icon:dr,message:`No MCP sources yet. Add one to bring a server's messages into the Inbox.`}):(0,H.jsx)(Xr,{children:e.map(e=>(0,H.jsx)(Ms,{source:e,serverName:n.find(t=>t.id===e.serverId)?.name??`Missing server`,status:t.find(t=>t.id===e.id),now:c,confirmingDelete:o===e.id,handlers:i},e.id))})]})}function Ps({state:e}){let t=z(hn),n=z(Xt),r=_(e=>e.statuses),i=Po(`mcpSources`,e),a=Fo(`mcpSources`,e),o=(0,V.useMemo)(()=>({...i,onSetEnabled:a}),[i,a]);return(0,H.jsx)(Ns,{sources:t,statuses:r,servers:n,sidebarData:e.sidebarData,handlers:o})}var Fs={id:``,label:``,modelProvider:`claude`,supportedEfforts:[],offersOneMillionContext:!1};function Is(e){return{...e,error:null}}var Ls=I()(e=>({editing:ko,editorForm:Is(Fs),setEditing:t=>e({editing:t}),resetEditorForm:t=>e({editorForm:Is(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}})),toggleSupportedEffort:t=>e(e=>{let n=e.editorForm.supportedEfforts,r=n.includes(t)?n.filter(e=>e!==t):[...n,t];return{editorForm:{...e.editorForm,supportedEfforts:r}}}),toggleOneMillionContext:()=>e(e=>({editorForm:{...e.editorForm,offersOneMillionContext:!e.editorForm.offersOneMillionContext}}))}));function Rs({models:e,handlers:t,dom:n=wn}){let r=Ls(e=>e.editing),i=Ls(e=>e.setEditing),a=Ls(e=>e.resetEditorForm);function o(t){if(t.kind===`create`)a({id:``,label:``,modelProvider:t.provider,supportedEfforts:[],offersOneMillionContext:!1});else if(t.kind===`edit`){let n=e.find(e=>e.id===t.id)??null;n&&a({id:n.id,label:n.label,modelProvider:n.provider,supportedEfforts:n.supportedEfforts??[],offersOneMillionContext:Re(n.provider,n.id,n.contextWindowOptions).some(e=>e.id===`1m`)})}i(t)}if(r.kind!==`list`){let n=r.kind===`edit`?e.find(e=>e.id===r.id)??null:null;return(0,H.jsx)(Bs,{initial:n,existing:e.map(e=>({id:e.id,provider:e.provider})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,H.jsx)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:He.map(r=>{let i=e.filter(e=>e.provider===r);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`h2`,{className:`text-base font-medium`,children:[ze(r).label,` models`]}),(0,H.jsxs)(k,{size:`sm`,onClick:()=>o({kind:`create`,provider:r}),children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add model`]})]}),i.length===0?(0,H.jsx)(Yr,{icon:xr,message:`No ${ze(r).label} models configured.`}):(0,H.jsx)(Xr,{children:i.map(e=>(0,H.jsx)(zs,{model:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]},r)})})}function zs({model:e,onEdit:t,onDelete:n,dom:r}){let i=N(`models.delete`,e.provider,e.id),a=M(i),o=(0,V.useCallback)(()=>{r.confirmDialog(`Delete model "${e.label}"?`)&&j(i,()=>n(e.id))},[i,r,e.id,e.label,n]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(e.supportedEfforts?.length??0)>0&&(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`effort`}),e.supportedEfforts?.includes(`max`)&&(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`max`}),(0,H.jsx)(Zr,{label:e.label,onEdit:t,onDelete:o,deletePending:a})]})]})}function Bs({initial:e,existing:t,handlers:n,onDone:r}){let i=Ls(e=>e.editorForm),a=Ls(e=>e.patchEditorForm),o=Ls(e=>e.toggleSupportedEffort),s=Ls(e=>e.toggleOneMillionContext),c=(0,V.useCallback)(e=>{qe(e)&&a({modelProvider:e})},[a]),{id:l,label:u,modelProvider:d,supportedEfforts:f,offersOneMillionContext:p,error:m}=i,h=N(`models.save`,e?.id??`new`),g=M(h),_=p?Ge:Ge.filter(e=>e.id===`200k`),v=e!==null,y=(0,V.useMemo)(()=>!v&&t.some(e=>e.id===l.trim()&&e.provider===d),[t,l,v,d]),b=l.trim().length>0&&u.trim().length>0&&!y&&!g,x=()=>Io({patch:a,save:async()=>{v&&e?await n.onUpdate(e.id,{label:u.trim(),supportedEfforts:f.length>0?f:null,...d===`claude`?{contextWindowOptions:_}:{}}):await n.onCreate({id:l.trim(),label:u.trim(),provider:d,...f.length>0?{supportedEfforts:f}:{},...d===`claude`?{contextWindowOptions:_}:{}})},onDone:r}),S=Lo({submitting:g,isEdit:v,addLabel:`Add model`});return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:v?`Edit model`:`Add model`}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Provider`}),(0,H.jsxs)(Ce,{value:d,onValueChange:c,disabled:v,children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:He.map(e=>(0,H.jsx)(P,{value:e,children:ze(e).label},e))})]})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Model ID`}),(0,H.jsx)(R,{value:l,onChange:e=>a({id:e.target.value}),placeholder:`claude-opus-4-9`,disabled:v,className:`font-mono`}),y&&(0,H.jsx)(`span`,{className:`text-xs text-red-600`,children:`A model with this id already exists.`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Label`}),(0,H.jsx)(R,{value:u,onChange:e=>a({label:e.target.value}),placeholder:`Opus 4.9`})]}),d===`claude`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Supported effort levels`}),Le.map(e=>(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:f.includes(e.id),onChange:()=>o(e.id)}),(0,H.jsx)(`span`,{children:e.label})]},e.id))]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Context window`}),(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:p,onChange:s}),(0,H.jsx)(`span`,{children:`Offer the 1M context window`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Off means every turn on this model runs on the 200k window.`})]})]}),m&&(0,H.jsx)(`span`,{className:`text-xs text-red-600`,children:m}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:()=>{j(h,x)},pending:g,disabled:!b,children:S}),(0,H.jsx)(k,{variant:`ghost`,onClick:r,disabled:g,children:`Cancel`})]})]})}function Vs(e){let t=z(Wt),n=Po(`customModels`,e.state);return(0,H.jsx)(Rs,{models:t,handlers:n})}function Hs(e){if(!e)return`—`;let t=e.trim();if(!t)return`—`;let n=t.slice(-4);return`${t.startsWith(`sk-ant-`)?`sk-ant-`:``}…${n}`}var q=I()(e=>({addLabel:``,addToken:``,addBaseUrl:``,addSubmitting:!1,tokenRowStates:{},baseUrlDrafts:{},setAddLabel:t=>e({addLabel:t}),setAddToken:t=>e({addToken:t}),setAddBaseUrl:t=>e({addBaseUrl:t}),setAddSubmitting:t=>e({addSubmitting:t}),resetAddForm:()=>e({addLabel:``,addToken:``,addBaseUrl:``}),setTokenRowTesting:(t,n)=>e(e=>({tokenRowStates:{...e.tokenRowStates,[t]:{...e.tokenRowStates[t]??{testResult:null,testing:!1},testing:n}}})),setTokenRowTestResult:(t,n)=>e(e=>({tokenRowStates:{...e.tokenRowStates,[t]:{...e.tokenRowStates[t]??{testResult:null,testing:!1},testResult:n}}})),clearTokenRowState:t=>e(e=>({tokenRowStates:ce(e.tokenRowStates,t)})),setBaseUrlDraft:(t,n)=>e(e=>({baseUrlDrafts:{...e.baseUrlDrafts,[t]:n}})),clearBaseUrlDraft:t=>e(e=>({baseUrlDrafts:ce(e.baseUrlDrafts,t)}))}));function Us(e){if(e<=0)return`reset now`;let t=Math.ceil(e/1e3),n=Math.floor(t/60),r=t%60;return n<60?`reset in ${n}m ${r.toString().padStart(2,`0`)}s`:`reset in ${Math.floor(n/60)}h ${(n%60).toString().padStart(2,`00`)}m`}function Ws({entry:e,now:t}){if(e.status===`active`)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`,"aria-hidden":`true`}),`Active`]});if(e.status===`limited`){let n=e.limitedUntil===null?null:Us(e.limitedUntil-t);return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-hidden":`true`}),`Limited`,n!==null&&(0,H.jsxs)(H.Fragment,{children:[` `,`(`,(0,H.jsx)(`span`,{className:`tabular-nums`,children:n}),`)`]})]})}if(e.status===`disabled`)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground/60`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/30`,"aria-hidden":`true`}),`Disabled`]});let n=e.lastErrorMessage??`Unknown error`;return(0,H.jsx)(mt,{children:(0,H.jsxs)(dt,{children:[(0,H.jsx)(ft,{asChild:!0,children:(0,H.jsxs)(`span`,{className:`inline-flex cursor-default items-center gap-1.5 text-xs text-destructive`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive`,"aria-hidden":`true`}),`Error`,(0,H.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,H.jsx)(pt,{"aria-hidden":`true`,children:n})]})})}var Gs=3e3;function Ks(){return(0,H.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:et})}function qs({entry:e,now:t,isCurrent:n,concurrencyDefault:r,onRemove:i,onToggleDisabled:a,onTest:o,onChangeMaxConcurrent:s,onChangeBaseUrl:c,ports:l}){let u=l?.timer??lt,d=q(e=>e.tokenRowStates),f=q(e=>e.setTokenRowTesting),p=q(e=>e.setTokenRowTestResult),m=q(e=>e.baseUrlDrafts),h=q(e=>e.setBaseUrlDraft),g=d[e.id],_=g?.testResult??null,v=g?.testing??!1,y=m[e.id]??e.baseUrl??``,b=Xe(y,512).kind===`invalid`,x=N(`oauthPool.remove`,e.id),S=N(`oauthPool.toggle`,e.id),ee=N(`oauthPool.concurrency`,e.id),C=N(`oauthPool.baseUrl`,e.id),te=N(`oauthPool.test`,e.id),w=M(x),ne=M(S),re=M(ee),ie=M(C),ae=()=>j(C,()=>c(e.id,y)),T=e=>{e.key===`Enter`&&e.currentTarget.blur()},oe=async()=>{f(e.id,!0),p(e.id,null);try{let t=await o(e.token,e.baseUrl),n=t.ok?`OK`:t.error??`Error`;p(e.id,n)}catch{p(e.id,`Error`)}finally{f(e.id,!1),u.setTimeout(()=>p(e.id,null),Gs)}},D=e.status===`disabled`,O=D?Lr:Fr,se=e.maxConcurrent??r;return(0,H.jsxs)(`div`,{className:`border-t border-border py-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium ${D?`text-muted-foreground/60`:`text-foreground`}`,children:e.label}),(0,H.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground`,children:Hs(e.token)}),n&&(0,H.jsx)(`span`,{className:`inline-flex shrink-0 items-center whitespace-nowrap rounded-full border border-primary/40 bg-primary/10 px-1.5 py-0.5 text-xs font-medium tracking-wide text-primary`,children:`In use`})]}),(0,H.jsx)(`div`,{className:`mt-0.5`,children:(0,H.jsx)(Ws,{entry:e,now:t})})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,H.jsx)(En,{label:`Maximum concurrent chats sharing this OAuth token. Higher = risks Anthropic rate limits.`,children:(0,H.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:`Concurrent`}),re?(0,H.jsx)(E,{className:`size-3`}):null,(0,H.jsx)(R,{type:`number`,value:se,readOnly:re,"aria-busy":re||void 0,onChange:t=>j(ee,()=>s(e.id,Ht(Number(t.target.value)))),min:1,"aria-label":`Max concurrent chats`,className:`h-7 w-14 text-xs`,disabled:D})]})}),_!==null&&(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_}),(0,H.jsxs)(`button`,{type:`button`,"aria-label":`Test`,onClick:()=>j(te,oe),disabled:v||D,"aria-busy":v||void 0,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,children:[v?(0,H.jsx)(E,{className:`size-3`}):(0,H.jsx)(Cr,{className:`size-3`,"aria-hidden":`true`}),`Test`]}),(0,H.jsx)(mt,{children:(0,H.jsxs)(dt,{children:[(0,H.jsx)(ft,{asChild:!0,children:(0,H.jsxs)(`button`,{type:`button`,"aria-label":D?`Enable`:`Disable`,onClick:()=>j(S,a),disabled:ne,"aria-busy":ne||void 0,className:`rounded p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default`,children:[ne?(0,H.jsx)(E,{}):(0,H.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`}),(0,H.jsx)(`span`,{className:`sr-only`,children:D?`Enable`:`Disable`})]})}),(0,H.jsx)(pt,{children:D?`Enable`:`Disable`})]})}),(0,H.jsxs)(`button`,{type:`button`,"aria-label":`Remove`,onClick:()=>j(x,i),disabled:w,"aria-busy":w||void 0,className:`rounded p-1 text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default`,children:[w?(0,H.jsx)(E,{}):(0,H.jsx)(Je,{className:`size-3.5`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]})]}),(0,H.jsx)(En,{label:`Anthropic API endpoint this token authenticates against. Leave empty for the default api.anthropic.com; set it to route this credential through a proxy.`,children:(0,H.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`shrink-0`,children:`Base URL`}),ie?(0,H.jsx)(E,{className:`size-3`}):null,(0,H.jsx)(R,{value:y,readOnly:ie,"aria-busy":ie||void 0,onChange:t=>h(e.id,t.target.value),onBlur:ae,onKeyDown:T,placeholder:`(default)`,maxLength:512,"aria-label":`Anthropic base URL for ${e.label}`,className:`h-7 flex-1 text-xs font-mono`,disabled:D})]})}),b&&(0,H.jsx)(Ks,{})]})}function Js({tokens:e,onWrite:t}){let n=q(e=>e.addLabel),r=q(e=>e.addToken),i=q(e=>e.addBaseUrl),a=q(e=>e.addSubmitting),o=q(e=>e.setAddLabel),s=q(e=>e.setAddToken),c=q(e=>e.setAddBaseUrl),l=q(e=>e.setAddSubmitting),u=q(e=>e.resetAddForm),d=Xe(i,512),f=d.kind===`invalid`,p=n.trim().length>0&&r.trim().length>0&&!f&&!a,m=async()=>{if(p){l(!0);try{let i={id:crypto.randomUUID(),label:n.trim(),token:r.trim(),status:`active`,limitedUntil:null,lastUsedAt:null,lastErrorAt:null,lastErrorMessage:null,addedAt:Date.now(),...d.kind===`url`?{baseUrl:d.url}:{}};await t({tokens:[...e,i]}),u()}finally{l(!1)}}};return(0,H.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end sm:gap-3`,children:[(0,H.jsx)(`div`,{className:`flex-1`,children:(0,H.jsx)(R,{value:n,onChange:e=>o(e.target.value),placeholder:`e.g. personal`,maxLength:64,className:`text-sm`,"aria-label":`Token label`})}),(0,H.jsx)(`div`,{className:`flex-[2]`,children:(0,H.jsx)(R,{value:r,onChange:e=>s(e.target.value),type:`password`,placeholder:`sk-ant-...`,maxLength:1024,className:`text-sm font-mono`,"aria-label":`OAuth token`})}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>j(`oauthPool.add`,m),disabled:!p,"aria-busy":a||void 0,className:`inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,children:[a?(0,H.jsx)(E,{}):null,`Add token`]})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(R,{value:i,onChange:e=>c(e.target.value),placeholder:`Base URL — leave empty for api.anthropic.com`,maxLength:512,className:`text-sm font-mono`,"aria-label":`Anthropic base URL`}),f&&(0,H.jsx)(Ks,{})]})]})}function Ys({tokens:e,concurrencyDefault:t,onWrite:n,onTest:r,now:i,ports:a}){let o=i??Date.now(),s=q(e=>e.clearBaseUrlDraft),c=e.reduce((e,t)=>t.lastUsedAt!==null&&(e===null||t.lastUsedAt>(e.lastUsedAt??0))?t:e,null)?.id??null,l=t=>n({tokens:e.filter(e=>e.id!==t)}),u=t=>n({tokens:e.map(e=>e.id===t?{...e,status:e.status===`disabled`?`active`:`disabled`}:e)}),d=(t,r)=>n({tokens:e.map(e=>e.id===t?{...e,maxConcurrent:r}:e)}),f=async(t,r)=>{let i=e.find(e=>e.id===t);if(!i)return;let a=Xe(r,512);if(a.kind===`invalid`)return;let o=a.kind===`url`?a.url:null;s(t),o!==(i.baseUrl??null)&&await n({tokens:e.map(e=>{if(e.id!==t)return e;let{baseUrl:n,...r}=e;return o===null?r:{...e,baseUrl:o}})})},p=M(`oauthPool.concurrencyDefault`),m=e=>{j(`oauthPool.concurrencyDefault`,()=>n({concurrencyDefault:Ht(e)}))};return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-3`,children:[(0,H.jsx)(En,{label:`Default concurrent-chat cap applied to any OAuth token whose row does not override it. Sharing across N chats burns Anthropic quota and risks 429s.`,children:(0,H.jsxs)(`label`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:`Default concurrency per token`}),(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Cap for tokens without an explicit per-row override. Minimum `,1,`, no upper limit.`]})]})}),p?(0,H.jsx)(E,{className:`ml-auto text-muted-foreground`}):null,(0,H.jsx)(R,{type:`number`,value:t,readOnly:p,"aria-busy":p||void 0,onChange:e=>m(Number(e.target.value)),min:1,"aria-label":`Default concurrency per token`,className:`h-8 w-16 text-sm`})]}),e.map(e=>(0,H.jsx)(qs,{entry:e,now:o,isCurrent:e.id===c,concurrencyDefault:t,onRemove:()=>l(e.id),onToggleDisabled:()=>u(e.id),onTest:r,onChangeMaxConcurrent:d,onChangeBaseUrl:f,ports:a},e.id)),(0,H.jsx)(Js,{tokens:e,onWrite:n})]})}var J=I()(e=>({claudeIdleMinutesDraft:``,claudeMaxConcurrentDraft:``,llmProviderDraft:{provider:`openai`,apiKey:``,model:``,baseUrl:``},llmProviderError:null,llmValidationStatus:`idle`,llmValidationError:null,llmValidationDialogOpen:!1,setClaudeIdleMinutesDraft:t=>e({claudeIdleMinutesDraft:t}),setClaudeMaxConcurrentDraft:t=>e({claudeMaxConcurrentDraft:t}),setLlmProviderDraft:t=>e({llmProviderDraft:t}),setLlmProviderError:t=>e({llmProviderError:t}),llmDraftChanged:()=>e({llmValidationStatus:`idle`,llmValidationError:null}),llmValidated:(t,n)=>e({llmValidationStatus:t,llmValidationError:n}),setLlmValidationDialogOpen:t=>e({llmValidationDialogOpen:t})})),Xs=32,Zs=`-`;function Qs(){return{id:``,idTouched:!1,label:``,baseUrl:``,apiKey:``,models:[$s()],contextWindow:``,hint:null}}function $s(){return{id:``,label:``}}function ec(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,Xs).replace(/-+$/,``)}function tc(e,t){if(e.length===0||!t.includes(e))return e;for(let n=2;;n+=1){let r=`-${n}`,i=`${e.slice(0,Xs-r.length)}${r}`;if(!t.includes(i))return i}}function nc(e,t){return{id:tc(e.id,t),idTouched:!0,label:e.label,baseUrl:e.baseUrl,apiKey:e.defaultApiKey??``,models:e.models.length>0?e.models.map(e=>({...e})):[$s()],contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),hint:e.hint??null}}function rc(e){return{id:e.id,idTouched:!0,label:e.label,baseUrl:e.baseUrl,apiKey:``,models:e.models.map(e=>({...e})),contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),hint:null}}function ic(e,t){return tc(ec(e),t)}function ac(e){return e.map(e=>({id:e.id.trim(),label:e.label.trim()})).filter(e=>e.id.length>0||e.label.length>0)}function oc(e){let t=e.replace(/[\s,_]/g,``);return t.length===0?void 0:Number(t)}function sc(e){let t=oc(e.contextWindow);return{id:e.id.trim(),label:e.label.trim(),baseUrl:e.baseUrl.trim(),apiKey:e.apiKey.trim(),models:ac(e.models),...t===void 0?{}:{contextWindow:t}}}function cc(e){let t=e.apiKey.trim();return{label:e.label.trim(),baseUrl:e.baseUrl.trim(),models:ac(e.models),contextWindow:oc(e.contextWindow)??null,...t.length>0?{apiKey:t}:{}}}function lc(e,t,n){let r=sc(e),i=Ye({...r,apiKey:t===`edit`&&r.apiKey.length===0?Zs:r.apiKey},n);return i===null?null:i.code===`INVALID_ID`?`Id must be lowercase letters, digits or dashes, start with a letter, and be at most ${Xs} characters (${Ze}).`:i.message}function uc(e){return`${e<1e6&&e%1024==0?`${e/1024}k`:Ee(e)} context`}function dc(e){return e===null?`Key set`:`Key ••••${e}`}function fc(e,t){return e===`create`?`API key`:t===null?`Leave blank to keep the saved key`:`Leave blank to keep ••••${t}`}function pc(e){return{...e,error:null}}var Y=I()(e=>({editing:ko,menuOpen:!1,listError:null,editorForm:pc(Qs()),setMenuOpen:t=>e({menuOpen:t}),setListError:t=>e({listError:t}),startEditing:(t,n)=>e({editing:t,menuOpen:!1,listError:null,editorForm:pc(n)}),discardEditor:()=>e({editing:ko,menuOpen:!1,editorForm:pc(Qs())}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}})),setLabel:(t,n)=>e(e=>({editorForm:{...e.editorForm,label:t,id:e.editorForm.idTouched?e.editorForm.id:ic(t,n)}})),setId:t=>e(e=>({editorForm:{...e.editorForm,id:t.toLowerCase(),idTouched:!0}})),setModelField:(t,n,r)=>e(e=>({editorForm:{...e.editorForm,models:e.editorForm.models.map((e,i)=>i===t?{...e,[n]:r}:e)}})),addModelRow:()=>e(e=>({editorForm:{...e.editorForm,models:[...e.editorForm.models,{id:``,label:``}]}})),removeModelRow:t=>e(e=>({editorForm:{...e.editorForm,models:e.editorForm.models.filter((e,n)=>n!==t)}}))})),mc=[{id:`glm`,label:`GLM (Z.AI)`,baseUrl:`https://api.z.ai/api/anthropic`,models:[{id:`glm-5.3`,label:`GLM-5.3`},{id:`glm-5.3-flash`,label:`GLM-5.3 Flash`}]},{id:`qwen`,label:`Qwen (Alibaba Model Studio)`,baseUrl:`https://coding-intl.dashscope.aliyuncs.com/apps/anthropic`,models:[{id:`qwen3.7-plus`,label:`Qwen3.7 Plus`},{id:`qwen3.7-max`,label:`Qwen3.7 Max`}],hint:`Coding Plan endpoint. Pay-as-you-go uses https://{WorkspaceId}.<region>.maas.aliyuncs.com/apps/anthropic.`},{id:`kimi`,label:`Kimi (Moonshot)`,baseUrl:`https://api.moonshot.ai/anthropic`,models:[{id:`kimi-k3`,label:`Kimi K3`},{id:`kimi-k2.7-code`,label:`Kimi K2.7 Code`}]},{id:`deepseek`,label:`DeepSeek`,baseUrl:`https://api.deepseek.com/anthropic`,models:[{id:`deepseek-v4-pro`,label:`DeepSeek V4 Pro`},{id:`deepseek-flash`,label:`DeepSeek Flash`}]},{id:`minimax`,label:`MiniMax`,baseUrl:`https://api.minimax.io/anthropic`,models:[{id:`MiniMax-M3.1`,label:`MiniMax M3.1`}],hint:`Mainland China: https://api.minimaxi.com/anthropic`},{id:`ollama`,label:`Ollama (local)`,baseUrl:`http://localhost:11434`,models:[],contextWindow:65536,defaultApiKey:`ollama`,hint:"Runs on this machine. Ollama ignores the API key, so any value works. Add the exact model names from `ollama list`, and set Context window to your OLLAMA_CONTEXT_LENGTH."}],hc=`Anthropic-compatible endpoints such as GLM, Qwen, Kimi, DeepSeek or MiniMax. They run through the Claude agent, so tools, skills and MCP work as usual. Pick them in the chat composer under Custom endpoints.`;function gc(e){return`${e} ${e===1?`model`:`models`}`}function _c({providers:e,handlers:t,dom:n=wn}){let r=Y(e=>e.editing),i=Y(e=>e.discardEditor);return(0,V.useEffect)(()=>{i()},[i]),(0,H.jsxs)(`div`,{className:`border-t border-border pb-5`,children:[(0,H.jsx)(U,{title:`Custom endpoints`,description:hc,bordered:!1,alignStart:!0,children:r.kind===`list`?(0,H.jsx)(vc,{providers:e}):null}),r.kind===`list`?(0,H.jsx)(yc,{providers:e,onDelete:t.onDelete,dom:n}):(0,H.jsx)(xc,{providers:e,editingId:r.kind===`edit`?r.id:null,handlers:t})]})}function vc({providers:e}){let t=Y(e=>e.menuOpen),n=Y(e=>e.setMenuOpen),r=Y(e=>e.startEditing),i=(0,V.useMemo)(()=>e.map(e=>e.id),[e]),a=(0,V.useCallback)(e=>{r({kind:`create`},nc(e,i))},[r,i]),o=(0,V.useCallback)(()=>{r({kind:`create`},Qs())},[r]);return(0,H.jsxs)(zn,{open:t,onOpenChange:n,children:[(0,H.jsx)(In,{asChild:!0,children:(0,H.jsxs)(k,{size:`sm`,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add endpoint`]})}),(0,H.jsx)(Bn,{align:`end`,className:`w-64 p-1`,children:(0,H.jsxs)(`div`,{className:`space-y-1`,children:[mc.map(e=>(0,H.jsx)(qn,{onClick:()=>a(e),selected:!1,icon:(0,H.jsx)(Vn,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)),(0,H.jsx)(qn,{onClick:o,selected:!1,icon:(0,H.jsx)(Ae,{className:`h-4 w-4 text-muted-foreground`}),label:`Custom…`,description:`Any Anthropic-compatible URL`})]})})]})}function yc({providers:e,onDelete:t,dom:n}){let r=Y(e=>e.listError);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r?(0,H.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:r}):null,e.length===0?(0,H.jsx)(Yr,{icon:Vn,message:`No custom endpoints yet.`}):(0,H.jsx)(Xr,{children:e.map(e=>(0,H.jsx)(bc,{provider:e,onDelete:t,dom:n},e.id))})]})}function bc({provider:e,onDelete:t,dom:n}){let r=Y(e=>e.startEditing),i=Y(e=>e.setListError),a=N(`settings.customProviders.delete`,e.id),o=M(a),s=(0,V.useCallback)(()=>{r({kind:`edit`,id:e.id},rc(e))},[e,r]),c=(0,V.useCallback)(()=>{n.confirmDialog(`Delete endpoint "${e.label}"?`)&&j(a,async()=>{i(null);try{await t(e.id)}catch(e){i(L(e))}})},[a,n,t,e.id,e.label,i]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":o||void 0,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,H.jsx)(Tn,{tooltip:e.baseUrl,className:`font-mono text-xs text-muted-foreground`,children:e.baseUrl})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`tabular-nums`,children:gc(e.models.length)}),e.contextWindow===void 0?null:(0,H.jsx)(`span`,{className:`tabular-nums`,children:uc(e.contextWindow)}),(0,H.jsx)(`span`,{children:dc(e.apiKeyHint)})]}),(0,H.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,H.jsx)(Zr,{label:e.label,onEdit:s,onDelete:c,deletePending:o})})]})}function xc({providers:e,editingId:t,handlers:n}){let r=Y(e=>e.editorForm),i=Y(e=>e.patchEditorForm),a=Y(e=>e.setLabel),o=Y(e=>e.setId),s=Y(e=>e.setModelField),c=Y(e=>e.addModelRow),l=Y(e=>e.removeModelRow),u=Y(e=>e.discardEditor),d=t!==null,f=d?`edit`:`create`,p=(0,V.useMemo)(()=>e.find(e=>e.id===t)??null,[e,t]),m=(0,V.useMemo)(()=>e.filter(e=>e.id!==t).map(e=>e.id),[e,t]),h=N(`settings.customProviders`,t??`new`),g=M(h),_=(0,V.useCallback)(e=>{a(e,m)},[m,a]),v=(0,V.useCallback)(()=>{let e=lc(r,f,m);e===null?j(h,()=>Io({patch:i,save:async()=>{t===null?await n.onCreate(sc(r)):await n.onUpdate(t,cc(r))},onDone:u})):i({error:e})},[u,t,r,n,f,m,i,h]),y=g;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-md border border-border px-4 py-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium`,children:d?`Edit ${p?.label??t}`:`Add endpoint`}),r.hint?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.hint}):null,(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Label`}),(0,H.jsx)(R,{value:r.label,onChange:e=>_(e.target.value),maxLength:64,placeholder:`GLM (Z.AI)`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Id`}),(0,H.jsx)(R,{value:r.id,onChange:e=>o(e.target.value),disabled:d,placeholder:`glm`,className:`font-mono`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Part of every model id, so it cannot change after the endpoint is created.`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Base URL`}),(0,H.jsx)(R,{value:r.baseUrl,onChange:e=>i({baseUrl:e.target.value}),placeholder:`https://api.example.com/anthropic`,className:`font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`API key`}),(0,H.jsx)(R,{type:`password`,autoComplete:`off`,value:r.apiKey,onChange:e=>i({apiKey:e.target.value}),maxLength:$e,placeholder:fc(f,p?.apiKeyHint??null),className:`font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Context window (tokens)`}),(0,H.jsx)(R,{inputMode:`numeric`,value:r.contextWindow,onChange:e=>i({contextWindow:e.target.value}),placeholder:`200000`,className:`font-mono tabular-nums`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`The model's real context window. The agent compacts the conversation before reaching it. Leave empty to assume 200,000. For Ollama use your OLLAMA_CONTEXT_LENGTH.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Models`}),r.models.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{value:e.id,onChange:e=>s(t,`id`,e.target.value),maxLength:128,placeholder:`Model id`,"aria-label":`Model ${t+1} id`,className:`font-mono`}),(0,H.jsx)(R,{value:e.label,onChange:e=>s(t,`label`,e.target.value),maxLength:64,placeholder:`Label (optional)`,"aria-label":`Model ${t+1} label`}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>l(t),"aria-label":`Remove model ${t+1}`,children:(0,H.jsx)(it,{className:`h-4 w-4`})})]},t)),(0,H.jsx)(`div`,{children:(0,H.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:c,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add model`]})})]}),r.error?(0,H.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:r.error}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:v,pending:y,children:Lo({submitting:y,isEdit:d,addLabel:`Add endpoint`})}),(0,H.jsx)(k,{variant:`ghost`,onClick:u,disabled:y,children:`Cancel`})]})]})}function Sc(e){let t=z(on),n=Po(`customProviders`,e.state);return(0,H.jsx)(_c,{providers:t,handlers:n})}function Cc(e){return e===`openai`?xt:e===`openrouter`?Ve:``}function wc(e,t){return{...e,provider:t,model:Cc(t),baseUrl:t===`custom`?e.baseUrl:``}}var Tc=`settings.writeLlmProvider`,Ec=[{value:`openai`,label:`OpenAI`},{value:`openrouter`,label:`OpenRouter`},{value:`custom`,label:`Custom`}];function Dc({saving:e,busy:t}){let n=J(e=>e.llmValidationStatus),r=J(e=>e.llmValidationError),i=J(e=>e.setLlmValidationDialogOpen),a,o;return t?(a=`inline-flex items-center gap-1.5 text-muted-foreground`,o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(E,{}),e?`Saving…`:`Loading…`]})):n===`valid`?(a=`text-success-text`,o=`Credentials valid & saved`):n===`invalid`?(a=`text-destructive`,o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Credentials invalid.`}),r?(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`underline underline-offset-2`,children:`See error`})]}):null]})):(a=`hidden`,o=null),(0,H.jsx)(`span`,{className:D(`mt-2 block text-sm font-medium`,a),children:o})}function Oc(){let e=J(e=>e.llmValidationDialogOpen),t=J(e=>e.setLlmValidationDialogOpen),n=J(e=>e.llmValidationError),r=n?JSON.stringify(n,null,2):``;return(0,H.jsx)(ot,{open:e,onOpenChange:t,children:(0,H.jsxs)(at,{size:`lg`,children:[(0,H.jsxs)(ct,{className:`space-y-4`,children:[(0,H.jsx)(ut,{children:`Validation Error`}),(0,H.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-words`,children:r})]}),(0,H.jsx)(st,{children:(0,H.jsx)(k,{variant:`secondary`,size:`sm`,onClick:()=>t(!1),children:`Close`})})]})})}function kc({state:e}){let{llmProvider:t,handleReadLlmProvider:n,handleWriteLlmProvider:r,handleValidateLlmProvider:i}=e,a=J(e=>e.llmProviderDraft),o=J(e=>e.setLlmProviderDraft),s=J(e=>e.llmProviderError),c=J(e=>e.setLlmProviderError),l=J(e=>e.llmDraftChanged),u=J(e=>e.llmValidated),d=M(Tc),f=M(ne),p=d||f;(0,V.useEffect)(()=>{j(ne,n)},[n]),(0,V.useEffect)(()=>{t&&o({provider:t.provider,apiKey:t.apiKey,model:t.model,baseUrl:t.baseUrl})},[t,o]),(0,V.useEffect)(()=>{l()},[a.provider,a.apiKey,a.model,a.baseUrl,l]);let m=(0,V.useCallback)(async e=>{try{c(null),await r(e);let t=await i(e);u(t.ok?`valid`:`invalid`,t.error)}catch(e){let t=e instanceof Error?{name:e.name,message:e.message}:Te(e);u(`invalid`,t),c(L(e))}},[r,i,c,u]);function h(e=a){j(Tc,()=>m(e))}function g(e){let t=wc(a,e);o(t),h(t)}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Quick Response SDK`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[`Use an OpenAI-compatible API for title and commit message generation before Claude and Codex. Stored in `,t?.filePathDisplay??`the active llm-provider.json file`,`.`]}),(0,H.jsx)(Dc,{saving:d,busy:p})]}),alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex w-full max-w-[420px] flex-col gap-3`,children:[s?(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:s}):null,t?.warning?(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:t.warning}):null,(0,H.jsxs)(Ce,{value:a.provider,disabled:p,onValueChange:e=>{an(e)&&g(e)},children:[(0,H.jsx)(ye,{className:`w-full`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:Ec.map(e=>(0,H.jsx)(P,{value:e.value,children:e.label},e.value))})})]}),a.provider===`custom`?(0,H.jsx)(R,{value:a.baseUrl,onChange:e=>o({...a,baseUrl:e.target.value}),onBlur:()=>h(),onKeyDown:e=>na(e,h),readOnly:p,placeholder:`https://your-provider.example/v1`}):null,(0,H.jsx)(R,{type:`password`,value:a.apiKey,onChange:e=>o({...a,apiKey:e.target.value}),onBlur:()=>h(),onKeyDown:e=>na(e,h),readOnly:p,placeholder:`API key`}),(0,H.jsx)(R,{value:a.model,onChange:e=>o({...a,model:e.target.value}),onBlur:()=>h(),onKeyDown:e=>na(e,h),readOnly:p,placeholder:`Model id`})]})}),(0,H.jsx)(Oc,{})]})}var Ac=Math.round(Ja.min/6e4),jc=Math.round(Ja.max/6e4),Mc={min:Ac,max:jc},Nc=Math.round(Nt.idleTimeoutMs/6e4);function Pc({state:e}){let{write:t}=oa(e),n=z(e=>e.settings?.claudeDriver.lifecycle),r=G(e=>e.setAppSettingsError),i=Math.round((n?.idleTimeoutMs??Nt.idleTimeoutMs)/6e4),a=n?.maxConcurrent??Nt.maxConcurrent,o=J(e=>e.claudeIdleMinutesDraft),s=J(e=>e.setClaudeIdleMinutesDraft),c=J(e=>e.claudeMaxConcurrentDraft),l=J(e=>e.setClaudeMaxConcurrentDraft);(0,V.useEffect)(()=>{s(String(i))},[i,s]),(0,V.useEffect)(()=>{l(String(a))},[a,l]);function u(){let e=Xa(o,i,Mc);e.kind===`write`?t({claudeDriver:{lifecycle:{idleTimeoutMs:e.value*6e4}}}):(s(String(i)),e.kind===`invalid`&&r(`Idle timeout must be between ${Ac} and ${jc} minutes.`))}function d(){let e=Xa(c,a,Ya);e.kind===`write`?t({claudeDriver:{lifecycle:{maxConcurrent:e.value}}}):(l(String(a)),e.kind===`invalid`&&r(`Max concurrent sessions must be between ${Ya.min} and ${Ya.max}.`))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Za,{title:`Claude session idle timeout`,description:`Stop a Claude session after this many minutes without user activity. Lower values free memory sooner; higher values keep cold-start latency low.`,min:Ac,max:jc,step:1,value:o,onValueChange:s,onCommit:u,hint:`${Ac}–${jc} min · default ${Nc}`}),(0,H.jsx)(Za,{title:`Max concurrent Claude sessions`,description:`Hard cap on resident Claude processes. Excess sessions are evicted LRU; their next activation cold-starts.`,min:Ya.min,max:Ya.max,step:1,value:c,onValueChange:l,onCommit:d,hint:`${Ya.min}–${Ya.max} · default ${Nt.maxConcurrent}`})]})}function Fc({state:e}){let{write:t}=oa(e),n=tt(),r=a(e=>e.defaultProvider),i=a(e=>e.providerDefaults),o=a(e=>e.setDefaultProvider),s=a(e=>e.setProviderDefaultModel),c=a(e=>e.setProviderDefaultModelOptions),l=a(e=>e.setProviderDefaultPlanMode);function u(e){o(e),t({defaultProvider:e})}function d(e,n){s(e,n),t({providerDefaults:{[e]:{model:n}}})}function f(e,n){c(e,n),t({providerDefaults:{[e]:{modelOptions:n}}})}function p(e,n){l(e,n),t({providerDefaults:{[e]:{planMode:n}}})}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Default Provider`,description:`The default harness used for new chats before a provider is locked by an existing session.`,children:(0,H.jsxs)(Ce,{value:r,onValueChange:e=>{(e===`last_used`||St(e))&&u(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsxs)(Se,{children:[(0,H.jsx)(P,{value:`last_used`,children:`Last Used`}),n.map(e=>(0,H.jsx)(P,{value:e.id,children:e.label},e.id))]})})]})}),(0,H.jsx)(Sc,{state:e}),(0,H.jsx)(U,{title:`Claude Code Defaults`,description:`Saved defaults when using Claude Code.`,alignStart:!0,children:(0,H.jsx)(`div`,{className:`max-w-[420px]`,children:(0,H.jsx)(Gn,{availableProviders:n,selectedProvider:`claude`,showProviderPicker:!1,model:i.claude.model,modelOptions:i.claude.modelOptions,onModelChange:(e,t)=>{d(`claude`,t)},onModelOptionChange:e=>{e.type===`claudeReasoningEffort`?f(`claude`,{reasoningEffort:e.effort}):e.type===`contextWindow`&&f(`claude`,{contextWindow:e.contextWindow})},planMode:i.claude.planMode,onPlanModeChange:e=>p(`claude`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,H.jsx)(U,{title:`Codex Defaults`,description:`Saved defaults when using Codex.`,alignStart:!0,children:(0,H.jsx)(`div`,{className:`max-w-[420px]`,children:(0,H.jsx)(Gn,{availableProviders:n,selectedProvider:`codex`,showProviderPicker:!1,model:i.codex.model,modelOptions:i.codex.modelOptions,onModelChange:(e,t)=>{d(`codex`,t)},onModelOptionChange:e=>{e.type===`codexReasoningEffort`?f(`codex`,{reasoningEffort:e.effort}):e.type===`fastMode`&&f(`codex`,{fastMode:e.fastMode})},planMode:i.codex.planMode,onPlanModeChange:e=>p(`codex`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})})]})}function Ic({state:e}){let t=z(e=>e.settings?.claudeAuth);return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(U,{title:`Claude OAuth tokens`,description:`Manage multiple Claude OAuth tokens. Kanna switches automatically when one hits its rate limit.`,bordered:!1,alignStart:!0,children:(0,H.jsx)(`div`,{className:`w-full md:w-[420px]`,children:(0,H.jsx)(Ys,{tokens:t?.tokens??[],concurrencyDefault:t?.concurrencyDefault??1,onWrite:e.handleWriteClaudeAuth,onTest:e.handleTestOAuthToken})})}),(0,H.jsx)(Pc,{state:e}),(0,H.jsx)(Fc,{state:e}),(0,H.jsx)(kc,{state:e})]})}var Lc={disabled:`Disabled`,installing:`Installing`,starting:`Starting`,connecting:`Connecting`,connected:`Connected`,reconnecting:`Reconnecting`,restarting:`Restarting`,error:`Error`},Rc={disabled:`muted`,installing:`attention`,starting:`attention`,connecting:`attention`,connected:`muted`,reconnecting:`attention`,restarting:`attention`,error:`destructive`};function zc(e){return Lc[e]}function Bc(e){return Rc[e]}var X=I()(e=>({connection:null,stream:null,embedded:null,consumerEditor:null,resetConfirm:!1,error:null,editConnection:(t,n)=>e(e=>({connection:{...e.connection??t,...n}})),discardConnection:()=>e({connection:null}),editStream:(t,n)=>e(e=>({stream:{...e.stream??t,...n}})),discardStream:()=>e({stream:null}),editEmbedded:(t,n)=>e(e=>({embedded:{...e.embedded??t,...n}})),discardEmbedded:()=>e({embedded:null}),openConsumerEditor:(t,n)=>e({consumerEditor:{target:t,draft:n}}),editConsumer:t=>e(e=>e.consumerEditor===null?e:{consumerEditor:{...e.consumerEditor,draft:{...e.consumerEditor.draft,...t}}}),closeConsumerEditor:()=>e({consumerEditor:null}),askResetConfirm:()=>e({resetConfirm:!0}),cancelResetConfirm:()=>e({resetConfirm:!1}),setError:t=>e({error:t})})),Vc=`auto`;function Hc(e){return{name:e.name,subjectPrefix:e.subjectPrefix,extraSubjects:e.extraSubjects.join(`
|
|
10
|
+
`),retention:e.retention,storage:e.storage,maxAgeDays:String(e.maxAgeDays),maxBytesMb:String(e.maxBytesMb),maxMsgs:String(e.maxMsgs),discard:e.discard,duplicateWindowSec:String(e.duplicateWindowSec),replicas:String(e.replicas)}}function Uc(e){return e.trim()===``?NaN:Number(e)}function Wc(e){return{name:e.name.trim(),subjectPrefix:e.subjectPrefix.trim(),extraSubjects:e.extraSubjects.split(`
|
|
11
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),retention:e.retention,storage:e.storage,maxAgeDays:Uc(e.maxAgeDays),maxBytesMb:Uc(e.maxBytesMb),maxMsgs:Uc(e.maxMsgs),discard:e.discard,duplicateWindowSec:Uc(e.duplicateWindowSec),replicas:Uc(e.replicas)}}function Gc(e){return{durableName:e.durableName,filterSubject:e.filterSubject,ackPolicy:e.ackPolicy,deliverPolicy:e.deliverPolicy,maxAckPending:String(e.maxAckPending),ackWaitSec:String(e.ackWaitSec)}}function Kc(e){return{durableName:``,filterSubject:`${e}.>`,ackPolicy:Dt.ackPolicy,deliverPolicy:Dt.deliverPolicy,maxAckPending:String(Dt.maxAckPending),ackWaitSec:String(Dt.ackWaitSec)}}function qc(e){return{durableName:e.durableName.trim(),filterSubject:e.filterSubject.trim(),ackPolicy:e.ackPolicy,deliverPolicy:e.deliverPolicy,maxAckPending:Uc(e.maxAckPending),ackWaitSec:Uc(e.ackWaitSec)}}function Jc(e){return{maxMemoryStoreMb:String(e.maxMemoryStoreMb),maxFileStoreMb:String(e.maxFileStoreMb),port:String(e.port),logLevel:e.logLevel}}function Yc(e){let t=e.port.trim().toLowerCase()===`auto`?Vc:Uc(e.port);return{maxMemoryStoreMb:Uc(e.maxMemoryStoreMb),maxFileStoreMb:Uc(e.maxFileStoreMb),port:t,logLevel:e.logLevel}}function Xc(e,t){return Pt({...e,...t})}function Zc(e,t){let n=[];return e.retention!==t.retention&&n.push(`retention`),e.storage!==t.storage&&n.push(`storage`),e.replicas!==t.replicas&&n.push(`replicas`),n}function Qc(e,t){return t.maxAgeDays<e.maxAgeDays||t.maxBytesMb<e.maxBytesMb}function $c(e,t){return JSON.stringify(Hc(e))===JSON.stringify(t)}function Z({label:e,note:t,warn:n=!1,children:r}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsx)(`div`,{className:`text-13 font-medium text-foreground`,children:e}),r,t?(0,H.jsx)(`div`,{className:D(`text-xs`,n?`text-warning-text`:`text-muted-foreground`),children:t}):null]})}function el({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,H.jsx)(`dd`,{className:`font-mono text-13 tabular-nums text-foreground`,children:t})]})}function tl({problems:e}){return e.length===0?null:(0,H.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-destructive-text`,role:`alert`,children:e.map(e=>(0,H.jsx)(`li`,{children:e},e))})}var nl=N(`settings.serviceBus`,`consumers`),rl={explicit:`Explicit`,all:`All`,none:`None`},il=Lt.map(e=>({value:e,label:rl[e]})),al={all:`All`,new:`New`,last:`Last`},ol=Et.map(e=>({value:e,label:al[e]}));function sl({consumer:e,onEdit:t,onRemove:n}){let r=x(t=>t.status.consumers.find(t=>t.name===e.durableName)),i=M(N(`settings.serviceBus`,`consumer`,e.durableName));return(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 px-4 py-3 md:flex-row md:items-center md:justify-between`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.durableName}),(0,H.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,children:[e.filterSubject||`all subjects`,` · ack `,e.ackPolicy,` · deliver `,e.deliverPolicy]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:r?`${String(r.pending)} pending · ${String(r.ackPending)} ack pending`:`not reported yet`}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.durableName}`,onClick:t,children:(0,H.jsx)(ke,{className:`h-4 w-4`})}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.durableName}`,pending:i,onClick:n,children:(0,H.jsx)(Je,{className:`h-4 w-4`})})]})]})}function cl({state:e}){let t=z(Yt),n=X(e=>e.consumerEditor),r=X(e=>e.openConsumerEditor),i=X(e=>e.editConsumer),a=X(e=>e.closeConsumerEditor),o=X(e=>e.setError),s=M(nl),c=(0,V.useCallback)(t=>B(o,async()=>{await e.handleWriteAppSettings({serviceBus:{consumers:t}}),a()}),[e,a,o]),l=n?qc(n.draft):null,u=n?.target.kind===`edit`?n.target.durableName:null,d=t.consumers.filter(e=>e.durableName!==u),f=l?Xc(t,{consumers:[...d,l]}):[],p=(0,V.useCallback)(async()=>{if(l===null)return;let e=t.consumers.map(e=>e.durableName===u?l:e);await c(u===null?[...t.consumers,l]:e)},[l,u,t.consumers,c]);return(0,H.jsxs)(`details`,{className:`rounded-lg border border-border`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-foreground`,children:[`Consumers `,(0,H.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:t.consumers.length})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border py-3`,children:[(0,H.jsx)(`p`,{className:`px-4 text-13 text-muted-foreground`,children:`Durable pull consumers Kanna creates on the stream. Kanna removes only the ones it created, and never touches consumers you add elsewhere.`}),t.consumers.length===0?(0,H.jsx)(`div`,{className:`px-4 text-13 text-muted-foreground`,children:`No consumers configured`}):(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border border-y border-border`,children:t.consumers.map(e=>(0,H.jsx)(sl,{consumer:e,onEdit:()=>r({kind:`edit`,durableName:e.durableName},Gc(e)),onRemove:()=>j(N(`settings.serviceBus`,`consumer`,e.durableName),()=>c(t.consumers.filter(t=>t.durableName!==e.durableName)))},e.durableName))}),n?(0,H.jsxs)(`div`,{className:`mx-4 flex flex-col gap-4 rounded-lg border border-border p-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsx)(Z,{label:`Durable name`,children:(0,H.jsx)(R,{"aria-label":`Durable name`,value:n.draft.durableName,disabled:u!==null,onChange:e=>i({durableName:e.target.value}),spellCheck:!1})}),(0,H.jsx)(Z,{label:`Filter subject`,note:`Leave empty for every subject in the stream`,children:(0,H.jsx)(R,{"aria-label":`Filter subject`,value:n.draft.filterSubject,onChange:e=>i({filterSubject:e.target.value}),spellCheck:!1})})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsx)(Z,{label:`Acknowledgement`,note:u===null?void 0:`Cannot change on an existing consumer; remove and add it again`,children:(0,H.jsx)(F,{size:`sm`,value:n.draft.ackPolicy,onValueChange:e=>i({ackPolicy:e}),options:il})}),(0,H.jsx)(Z,{label:`Deliver`,children:(0,H.jsx)(F,{size:`sm`,value:n.draft.deliverPolicy,onValueChange:e=>i({deliverPolicy:e}),options:ol})}),(0,H.jsx)(Z,{label:`Max ack pending`,children:(0,H.jsx)(R,{"aria-label":`Max ack pending`,inputMode:`numeric`,className:`tabular-nums`,value:n.draft.maxAckPending,onChange:e=>i({maxAckPending:e.target.value})})}),(0,H.jsx)(Z,{label:`Ack wait (s)`,children:(0,H.jsx)(R,{"aria-label":`Ack wait in seconds`,inputMode:`numeric`,className:`tabular-nums`,value:n.draft.ackWaitSec,onChange:e=>i({ackWaitSec:e.target.value})})})]}),(0,H.jsx)(tl,{problems:f}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:s,onClick:a,children:`Cancel`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:f.length>0,pending:s,onClick:()=>j(nl,p),children:`Save consumer`})]})]}):(0,H.jsx)(`div`,{className:`px-4`,children:(0,H.jsxs)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r({kind:`new`},Kc(t.stream.subjectPrefix)),children:[(0,H.jsx)(Ae,{className:`mr-1.5 h-4 w-4`}),`Add consumer`]})})]})]})}var ll=N(`settings.serviceBus`,`embedded`),ul=N(`serviceBus.resetStore`),dl={info:`Info`,debug:`Debug`},fl=Rt.map(e=>({value:e,label:dl[e]}));function pl({state:e}){let t=kn(),n=z(Yt),r=Jc(n.embedded),i=X(e=>e.embedded)??r,a=X(e=>e.editEmbedded),o=X(e=>e.discardEmbedded),s=X(e=>e.resetConfirm),c=X(e=>e.askResetConfirm),l=X(e=>e.cancelResetConfirm),u=X(e=>e.setError),d=M(ll),f=M(ul),p=Xc(n,{embedded:Yc(i)}),m=JSON.stringify(r)!==JSON.stringify(i),h=e=>a(r,e),g=(0,V.useCallback)(()=>B(u,async()=>{await e.handleWriteAppSettings({serviceBus:{embedded:Yc(i)}}),o()}),[e,i,o,u]),_=(0,V.useCallback)(async()=>{await B(u,async()=>{await On(t,{type:`serviceBus.resetStore`})}),l()},[t,l,u]);return(0,H.jsxs)(`details`,{className:`rounded-lg border border-border`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-foreground`,children:`Embedded server`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border px-4 py-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`Memory store (MB)`,children:(0,H.jsx)(R,{"aria-label":`Memory store in megabytes`,inputMode:`numeric`,className:`tabular-nums`,value:i.maxMemoryStoreMb,onChange:e=>h({maxMemoryStoreMb:e.target.value})})}),(0,H.jsx)(Z,{label:`File store (MB)`,children:(0,H.jsx)(R,{"aria-label":`File store in megabytes`,inputMode:`numeric`,className:`tabular-nums`,value:i.maxFileStoreMb,onChange:e=>h({maxFileStoreMb:e.target.value})})}),(0,H.jsx)(Z,{label:`Port`,note:`auto picks a free loopback port`,children:(0,H.jsx)(R,{"aria-label":`Port`,inputMode:`numeric`,className:`tabular-nums`,value:i.port,onChange:e=>h({port:e.target.value})})})]}),(0,H.jsx)(Z,{label:`Server log level`,children:(0,H.jsx)(F,{size:`sm`,value:i.logLevel,onValueChange:e=>h({logLevel:e}),options:fl})}),(0,H.jsx)(tl,{problems:p}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:!m||d,onClick:o,children:`Revert`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!m||p.length>0,pending:d,onClick:()=>j(ll,g),children:`Save server`})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-4`,children:[(0,H.jsx)(`div`,{className:`text-13 font-medium text-foreground`,children:`Reset store`}),(0,H.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Stops the embedded server, deletes every message it holds and starts it again. Kanna's own history is not touched.`}),s?(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`destructive`,size:`sm`,pending:f,onClick:()=>j(ul,_),children:`Delete the store`}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:f,onClick:l,children:`Cancel`})]}):(0,H.jsx)(`div`,{children:(0,H.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:`Reset store`})})]})]})]})}var ml=N(`settings.serviceBus`,`stream`),hl=`Changing this requires recreating the stream`,gl=`Lowering this drops older messages`,_l={limits:`Limits`,interest:`Interest`,workqueue:`Work queue`},vl=wt.map(e=>({value:e,label:_l[e]})),yl={file:`File`,memory:`Memory`},bl=Qt.map(e=>({value:e,label:yl[e]})),xl={old:`Oldest`,new:`Newest`},Sl=$t.map(e=>({value:e,label:xl[e]}));function Cl({state:e}){let t=z(Yt),n=Hc(t.stream),r=X(e=>e.stream)??n,i=X(e=>e.editStream),a=X(e=>e.discardStream),o=X(e=>e.setError),s=M(ml),c=Wc(r),l=Xc(t,{stream:c}),u=!$c(t.stream,r),d=Zc(t.stream,c),f=Qc(t.stream,c),p=e=>i(n,e),m=(0,V.useCallback)(()=>B(o,async()=>{await e.handleWriteAppSettings({serviceBus:{stream:Wc(r)}}),a()}),[e,r,a,o]);return(0,H.jsxs)(`details`,{className:`rounded-lg border border-border`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-foreground`,children:`Stream`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border px-4 py-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsx)(Z,{label:`Stream name`,children:(0,H.jsx)(R,{"aria-label":`Stream name`,value:r.name,onChange:e=>p({name:e.target.value}),spellCheck:!1})}),(0,H.jsx)(Z,{label:`Subject prefix`,note:`Kanna publishes under ${r.subjectPrefix||`…`}.>`,children:(0,H.jsx)(R,{"aria-label":`Subject prefix`,value:r.subjectPrefix,onChange:e=>p({subjectPrefix:e.target.value}),spellCheck:!1})})]}),(0,H.jsx)(Z,{label:`Extra subjects`,note:`One per line; the stream also captures these`,children:(0,H.jsx)(Dn,{"aria-label":`Extra subjects`,rows:2,value:r.extraSubjects,onChange:e=>p({extraSubjects:e.target.value}),spellCheck:!1})}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`Retention`,note:hl,warn:d.includes(`retention`),children:(0,H.jsx)(F,{size:`sm`,value:r.retention,onValueChange:e=>p({retention:e}),options:vl})}),(0,H.jsx)(Z,{label:`Storage`,note:hl,warn:d.includes(`storage`),children:(0,H.jsx)(F,{size:`sm`,value:r.storage,onValueChange:e=>p({storage:e}),options:bl})}),(0,H.jsx)(Z,{label:`Replicas`,note:hl,warn:d.includes(`replicas`),children:(0,H.jsx)(R,{"aria-label":`Replicas`,inputMode:`numeric`,className:`tabular-nums`,value:r.replicas,onChange:e=>p({replicas:e.target.value})})})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`Max age (days)`,note:gl,warn:f,children:(0,H.jsx)(R,{"aria-label":`Max age in days`,inputMode:`numeric`,className:`tabular-nums`,value:r.maxAgeDays,onChange:e=>p({maxAgeDays:e.target.value})})}),(0,H.jsx)(Z,{label:`Max bytes (MB)`,note:gl,warn:f,children:(0,H.jsx)(R,{"aria-label":`Max bytes in megabytes`,inputMode:`numeric`,className:`tabular-nums`,value:r.maxBytesMb,onChange:e=>p({maxBytesMb:e.target.value})})}),(0,H.jsx)(Z,{label:`Max messages`,note:`-1 means unlimited`,children:(0,H.jsx)(R,{"aria-label":`Max messages`,inputMode:`numeric`,className:`tabular-nums`,value:r.maxMsgs,onChange:e=>p({maxMsgs:e.target.value})})})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`When full, discard`,children:(0,H.jsx)(F,{size:`sm`,value:r.discard,onValueChange:e=>p({discard:e}),options:Sl})}),(0,H.jsx)(Z,{label:`Duplicate window (s)`,note:`Messages with the same id inside this window are stored once`,children:(0,H.jsx)(R,{"aria-label":`Duplicate window in seconds`,inputMode:`numeric`,className:`tabular-nums`,value:r.duplicateWindowSec,onChange:e=>p({duplicateWindowSec:e.target.value})})})]}),(0,H.jsx)(tl,{problems:l}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:!u||s,onClick:a,children:`Revert`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!u||l.length>0,pending:s,onClick:()=>j(ml,m),children:`Save stream`})]})]})]})}var wl=N(`settings.serviceBus`,`enabled`),Tl=N(`settings.serviceBus`,`mode`),El=N(`settings.serviceBus`,`start`),Dl=N(`settings.serviceBus`,`connection`),Ol=N(`settings.serviceBus`,`token`),kl=[{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}],Al={embedded:`Embedded`,external:`External`},jl=Ft.map(e=>({value:e,label:Al[e]}));function Ml(){let e=x(S),t=e=>e.toLocaleString(`en-US`);return(0,H.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 md:grid-cols-4`,children:[e.stream?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(el,{label:`Messages`,value:t(e.stream.messages)}),(0,H.jsx)(el,{label:`Size`,value:pe(e.stream.bytes)}),(0,H.jsx)(el,{label:`First seq`,value:t(e.stream.firstSeq)}),(0,H.jsx)(el,{label:`Last seq`,value:t(e.stream.lastSeq)})]}):null,(0,H.jsx)(el,{label:`Published`,value:t(e.published)}),(0,H.jsx)(el,{label:`Dropped`,value:t(e.dropped)}),(0,H.jsx)(el,{label:`Queued`,value:t(e.queued)}),e.serverVersion?(0,H.jsx)(el,{label:`Server`,value:`v${e.serverVersion}${e.port?` · :${String(e.port)}`:``}`}):null]})}function Nl({state:e}){let t=z(Yt),n=X(e=>e.connection)??{url:t.url,token:``},r=X(e=>e.editConnection),i=X(e=>e.discardConnection),a=X(e=>e.setError),o=M(Dl),s=M(Ol),c=n.url.trim(),l=Xc({...t,mode:`external`},{url:c}),u=c!==t.url,d=(0,V.useCallback)(()=>B(a,async()=>{await e.handleWriteAppSettings({serviceBus:{url:c}}),i()}),[e,c,i,a]),f=(0,V.useCallback)(t=>B(a,async()=>{await e.handleWriteAppSettings({serviceBus:{token:t}}),i()}),[e,i,a]),p={url:t.url,token:``};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border py-5`,children:[(0,H.jsx)(Z,{label:`Server URL`,note:`Where your own nats-server listens, for example nats://nats.internal:4222`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{"aria-label":`Server URL`,value:n.url,onChange:e=>r(p,{url:e.target.value}),spellCheck:!1}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!u||l.length>0,pending:o,onClick:()=>j(Dl,d),children:`Save`})]})}),(0,H.jsx)(Z,{label:`Token`,note:t.tokenHint?`A token ending in ${t.tokenHint} is stored. Kanna never shows it again.`:`No token stored`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{"aria-label":`Token`,type:`password`,autoComplete:`off`,value:n.token,placeholder:t.tokenHint?`Enter a new token to replace it`:`Token`,onChange:e=>r(p,{token:e.target.value})}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:n.token.trim()===``,pending:s,onClick:()=>j(Ol,()=>f(n.token.trim())),children:`Replace token`}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:t.tokenHint===null,onClick:()=>j(Ol,()=>f(null)),children:`Clear`})]})}),(0,H.jsx)(tl,{problems:l})]})}function Pl({state:e}){let t=z(Yt),n=x(S),r=X(e=>e.error),i=X(e=>e.setError),a=M(El),o=(0,V.useCallback)(t=>B(i,()=>e.handleWriteAppSettings({serviceBus:t})),[e,i]),s=(0,V.useCallback)(e=>o({enabled:e===`enabled`}),[o]),c=(0,V.useCallback)(e=>o({mode:e}),[o]),l=(0,V.useCallback)(async()=>{t.enabled&&await o({enabled:!1}),await o({enabled:!0})},[t.enabled,o]),u=t.mode===`embedded`,d=u&&(!t.enabled||n.state===`error`);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 pb-2`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Service bus`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Mirror every durable event Kanna records into a NATS JetStream stream, so other programs can read them with the nats CLI or any NATS client. Kanna's own history is not affected, and a bus outage never blocks a chat.`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-13 text-muted-foreground`,children:`Embedded mode downloads nats-server v${Ot} from GitHub on first start and runs it on loopback with a private token.`})]}),(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(U,{title:`Mirror to NATS`,description:`When off, nothing is downloaded, started or published.`,children:(0,H.jsx)(La,{pendingKey:wl,value:t.enabled?`enabled`:`disabled`,onValueChange:s,options:kl,size:`sm`})}),(0,H.jsx)(U,{title:`Server`,description:`Embedded runs a nats-server that Kanna manages. External connects to one you run.`,children:(0,H.jsx)(La,{pendingKey:Tl,value:t.mode,onValueChange:c,options:jl,size:`sm`})}),(0,H.jsx)(U,{title:`Status`,description:n.lastError?(0,H.jsx)(`span`,{className:`text-destructive-text`,children:n.lastError}):`Live state of the mirror.`,alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(jn,{tone:Bc(n.state),label:zc(n.state)}),d?(0,H.jsx)(k,{type:`button`,size:`sm`,pending:a,onClick:()=>j(El,l),children:t.enabled?`Retry`:`Install & start`}):null]})})]}),r?(0,H.jsx)(`div`,{className:`text-xs text-destructive-text`,role:`alert`,children:r}):null,t.enabled||n.state!==`disabled`?(0,H.jsx)(`div`,{className:`py-3`,children:(0,H.jsx)(Ml,{})}):null,u?null:(0,H.jsx)(Nl,{state:e}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2`,children:[(0,H.jsx)(Cl,{state:e}),(0,H.jsx)(cl,{state:e}),u?(0,H.jsx)(pl,{state:e}):null]})]})}function Fl(e,t){if(!e.pinnedRef)return null;let n=t.latestVersion;return!n||n===e.pinnedRef?null:n}var Il={outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function Ll(e){if(!e)return null;let t=Fl(e,e.update);if(t)return`Re-pin to ${t}`;if(e.pinnedRef)return null;let n=e.update.availability;return n===`outdated`||n===`partial`?`Update`:null}function Rl({availability:e}){return e===void 0||e===`up_to_date`?null:(0,H.jsx)(`span`,{className:D(`rounded-full border px-2 py-0.5 text-xs font-medium`,hi[e]),children:Il[e]})}function zl({label:e,updating:t,onClick:n}){return(0,H.jsxs)(k,{type:`button`,size:`sm`,variant:`secondary`,disabled:t,"aria-busy":t||void 0,onClick:n,className:`h-6 rounded-full px-2 text-xs`,children:[t?(0,H.jsx)(A,{className:`mr-1 h-3 w-3 animate-spin`}):null,e]})}function Bl({skill:e,packageEntry:t,uninstalling:n,applying:r,onUninstall:i,onUpdate:a}){let o=e.source?`https://skills.sh/${e.source}/${e.name}`:null,s=t?.versionLabel??t?.revision?.slice(0,7)??t?.updatedAt??null,c=t?.pinnedRef??null,l=Ll(t);return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.source||`Unknown source`}),s?(0,H.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:s}):null,c?(0,H.jsxs)(`div`,{className:`truncate font-mono tabular-nums text-xs text-muted-foreground/70`,children:[`Pinned `,c]}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,H.jsx)(Rl,{availability:t?.update.availability}),l?(0,H.jsx)(zl,{label:l,updating:r,onClick:a}):null,o?(0,H.jsx)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} on skills.sh`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ln,{className:`h-4 w-4`})}):null,(0,H.jsx)(`button`,{type:`button`,"aria-label":`Uninstall ${e.name}`,disabled:n,onClick:i,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:pointer-events-none disabled:opacity-50`,children:n?(0,H.jsx)(A,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(Je,{className:`h-4 w-4`})})]})]})}var Vl=[],Hl=[],Ul={},Wl=`Installed globally`;function Gl(e){return new Set(e.map(e=>e.name))}function Kl(e,t){let{[t]:n,...r}=e;return r}var Q=I()(e=>({query:``,results:Vl,searchLoading:!1,searchError:null,installedSkills:Hl,installedSkillIds:new Set,installedLoading:!1,installedError:null,operationError:null,installMessages:Ul,setQuery:t=>e({query:t}),searchCleared:t=>e({results:Vl,searchError:t,searchLoading:!1}),searchStarted:()=>e({searchLoading:!0,searchError:null}),searchSucceeded:t=>e({results:t,searchLoading:!1}),searchFailed:t=>e({results:Vl,searchError:t,searchLoading:!1}),installedCleared:()=>e({installedSkills:Hl,installedSkillIds:new Set,installedError:null,installedLoading:!1}),installedLoadStarted:()=>e({installedLoading:!0,installedError:null}),installedLoaded:t=>e({installedSkills:t,installedSkillIds:Gl(t)}),installedLoadFailed:t=>e({installedSkills:Hl,installedSkillIds:new Set,installedError:t}),installedLoadFinished:()=>e({installedLoading:!1}),setOperationError:t=>e({operationError:t}),installStarted:t=>e(e=>({operationError:null,installMessages:Kl(e.installMessages,t)})),installSucceeded:t=>e(e=>({installedSkillIds:new Set([...e.installedSkillIds,t]),installMessages:{...e.installMessages,[t]:Wl}})),uninstallSucceeded:t=>e(e=>({installedSkills:e.installedSkills.filter(e=>e.name!==t),installedSkillIds:new Set([...e.installedSkillIds].filter(e=>e!==t)),installMessages:Kl(e.installMessages,t)}))}));function ql(e){return N(`skills.install`,e)}function Jl(e){return!e||e<=0?`0 installs`:e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M installs`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K installs`:`${e} install${e===1?``:`s`}`}var Yl=N(`packages.checkUpdates`),Xl=N(`packages.updateAll`,`skill`);function Zl(e){return`skill:${e}`}function Ql({skill:e,packageEntry:t,applying:n,onUninstall:r,onUpdate:i}){let a=Zl(e.name),o=M(N(`packages.update`,a)),s=M(N(`skills.uninstall`,e.name));return(0,H.jsx)(Bl,{skill:e,packageEntry:t,uninstalling:s,applying:n||o,onUninstall:()=>r(e),onUpdate:()=>i(a)})}function $l({message:e}){return(0,H.jsx)(`pre`,{className:`max-w-full overflow-x-auto whitespace-pre-wrap rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-xs text-destructive`,children:e})}function eu({skill:e,installing:t,installed:n,message:r,onInstall:i}){let a;return a=n?`Installed`:t?`Installing`:`Get`,(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,H.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.source,` · `,Jl(e.installs)]}),n&&r?(0,H.jsx)(`div`,{className:`mt-1 truncate text-xs text-emerald-500`,children:r}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,H.jsx)(`a`,{href:`https://skills.sh/${e.id}`,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} on skills.sh`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ln,{className:`h-4 w-4`})}),(0,H.jsxs)(k,{type:`button`,size:`sm`,variant:n?`secondary`:`default`,disabled:t||n,onClick:i,className:`h-6 rounded-full px-2 text-xs`,children:[t?(0,H.jsx)(A,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):null,a]})]})]})}function tu({state:e,ports:t}){let n=t?.timer??lt,r=e.socket,i=e.connectionStatus,a=Q(e=>e.query),o=Q(e=>e.setQuery),s=Q(e=>e.results),c=Q(e=>e.searchLoading),l=Q(e=>e.searchError),u=Q(e=>e.searchCleared),d=Q(e=>e.searchStarted),f=Q(e=>e.searchSucceeded),p=Q(e=>e.searchFailed),m=Q(e=>e.installedSkills),h=Q(e=>e.installedSkillIds),g=Q(e=>e.installedLoading),_=Q(e=>e.installedError),v=Q(e=>e.installedCleared),y=Q(e=>e.installedLoadStarted),b=Q(e=>e.installedLoaded),x=Q(e=>e.installedLoadFailed),S=Q(e=>e.installedLoadFinished),ee=Q(e=>e.operationError),C=Q(e=>e.setOperationError),te=se(e=>e.inFlight),ne=Q(e=>e.installMessages),re=Q(e=>e.installStarted),ie=Q(e=>e.installSucceeded),ae=Q(e=>e.uninstallSucceeded),T=w(e=>e.updateSnapshot),oe=T?.status===`checking`,E=T?.packages.filter(e=>e.kind===`skill`&&!e.pinnedRef).filter(e=>e.update.availability===`outdated`||e.update.availability===`partial`).map(e=>e.id)??[],D=E.length,O=T?.lastCheckedAt?new Date(T.lastCheckedAt).toLocaleTimeString():null,ce=M(Yl),le=M(Xl),ue=oe||ce;async function de(e){await B(C,()=>r.command(e))}function fe(){j(Yl,()=>de({type:`packages.checkUpdates`}))}function pe(e){j(N(`packages.update`,e),()=>de({type:`packages.update`,id:e}))}function me(){E.length!==0&&j(Xl,()=>de({type:`packages.updateAll`,ids:E}))}function he(e){j(ql(e.id),()=>ve(e))}function ge(e){j(N(`skills.uninstall`,e.name),()=>ye(e))}let _e=(0,V.useCallback)(async()=>{if(i!==`connected`)v();else try{y();let e=await r.command({type:`skills.listInstalled`});b(e.skills)}catch(e){x(L(e))}finally{S()}},[i,r,v,y,b,x,S]);(0,V.useEffect)(()=>{Cn(`skills.listInstalled`,_e())},[i,_e,r]),(0,V.useEffect)(()=>{let e=a.trim();if(e.length<2){u(null);return}if(i!==`connected`){u(`Backend connection required.`);return}let t=!1;d();let o=n.setTimeout(()=>{r.command({type:`skills.search`,query:e,limit:100}).then(e=>{t||f(e.skills)}).catch(e=>{t||p(L(e))})},250);return()=>{t=!0,n.clearTimeout(o)}},[i,a,r,u,d,f,p,n]);async function ve(e){if(i!==`connected`)C(`Backend connection required.`);else try{re(e.skillId),await r.command({type:`skills.install`,source:e.source,skillId:e.skillId}),ie(e.skillId),Cn(`skills.listInstalled`,_e())}catch(e){C(L(e))}}async function ye(e){i===`connected`?await B(C,async()=>{await r.command({type:`skills.uninstall`,skillId:e.name}),ae(e.name),Cn(`skills.listInstalled`,_e())}):C(`Backend connection required.`)}let P;return P=m.length>0?(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:m.map(e=>(0,H.jsx)(Ql,{skill:e,packageEntry:T?.packages.find(t=>t.kind===`skill`&&t.name===e.name)??null,applying:T?.applying.includes(Zl(e.name))??!1,onUninstall:ge,onUpdate:pe},`${e.source}/${e.name}`))}):g?null:(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No global skills installed.`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[ee?(0,H.jsx)($l,{message:ee}):null,(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Installed`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O?(0,H.jsxs)(`span`,{className:`tabular-nums text-xs text-muted-foreground`,children:[`Checked `,O]}):null,D>0?(0,H.jsxs)(k,{size:`sm`,variant:`secondary`,className:`h-6 rounded-full px-2 text-xs`,pending:le,onClick:me,children:[`Update all (`,D,`)`]}):null,(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,className:`h-6 rounded-full px-2 text-xs`,disabled:ue,"aria-busy":ue||void 0,onClick:fe,children:[ue?(0,H.jsx)(A,{className:`mr-1 h-3 w-3 animate-spin`}):null,`Check`]}),g?(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}):null]})]}),_?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:_}):null,P]}),(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Discover`}),(0,H.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-lg border border-border bg-card/30 px-3`,children:[(0,H.jsx)(Me,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`input`,{type:`text`,role:`searchbox`,value:a,onChange:e=>o(e.target.value),placeholder:`Search skills`,className:`min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground`}),a?(0,H.jsx)(`button`,{type:`button`,"aria-label":`Clear skills search`,onClick:()=>o(``),className:`touch-manipulation inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(it,{className:`h-3.5 w-3.5`})}):null,c?(0,H.jsx)(A,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):null]}),l?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:l}):null,(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:s.map(e=>(0,H.jsx)(eu,{skill:e,installing:te[ql(e.id)]===!0,installed:h.has(e.skillId),message:ne[e.skillId],onInstall:()=>{he(e)}},e.id))}),!c&&!l&&a.trim().length>=2&&s.length===0?(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No skills found.`}):null]})]})}var nu=`auto`;function ru(e){return e.triggerMode??`auto`}function iu(e,t,n){return t?.[e].model||n?.find(t=>t.id===e)?.defaultModel||ze(e).defaultModel}function au(e,t){return e===`claude`?{...t?.claude.modelOptions??Ne}:e===`codex`?{...t?.codex.modelOptions??Be}:{}}function ou(e,t,n){return{name:``,provider:e,model:iu(e,t,n),modelOptions:au(e,t),systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:nu}}function su(e){return{name:e.name,description:e.description,provider:e.provider,model:e.model,modelOptions:e.modelOptions,systemPrompt:e.systemPrompt,contextScope:e.contextScope,triggerMode:e.triggerMode,workingDir:e.workingDir,allowedPaths:e.allowedPaths,maxTurns:e.maxTurns,allowBeaconTools:e.allowBeaconTools}}function cu(e){return{...e,maxTurns:e.maxTurns??null}}function lu(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function uu(e,t){if(!_t(e)||!_t(t))return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!1;return!0}var du={name:(e,t)=>e.name===t.name,description:(e,t)=>(e.description??``)===(t.description??``),provider:(e,t)=>e.provider===t.provider,model:(e,t)=>e.model===t.model,modelOptions:(e,t)=>uu(e.modelOptions,t.modelOptions),systemPrompt:(e,t)=>e.systemPrompt===t.systemPrompt,contextScope:(e,t)=>e.contextScope===t.contextScope,triggerMode:(e,t)=>ru(e)===ru(t),workingDir:(e,t)=>(e.workingDir??``)===(t.workingDir??``),allowedPaths:(e,t)=>lu(e.allowedPaths,t.allowedPaths),maxTurns:(e,t)=>(e.maxTurns??null)===(t.maxTurns??null),allowBeaconTools:(e,t)=>(e.allowBeaconTools??!1)===(t.allowBeaconTools??!1)};function fu(e,t){return Object.values(du).some(n=>!n(e,t))}var pu=new Set([`EMPTY_NAME`,`INVALID_CHAR`,`RESERVED_NAME`,`DUPLICATE_NAME`,`TOO_LONG`]);function mu(e){return pu.has(e.code)?{field:`name`,message:e.message}:{field:`general`,message:e.message}}function hu(e){return e.toLowerCase().replace(_n,`-`).slice(0,64)}function gu(){return{draft:ou(`claude`,void 0),error:null,confirmDelete:!1}}var _u=I()(e=>({editing:ko,form:gu(),timeoutDraft:``,loopError:null,setEditing:t=>e({editing:t}),resetForm:t=>e({form:{draft:t,error:null,confirmDelete:!1}}),patchForm:t=>e(e=>({form:{...e.form,...t}})),patchFormDraft:t=>e(e=>({form:{...e.form,draft:{...e.form.draft,...t}}})),setTimeoutDraft:t=>e({timeoutDraft:t}),setLoopError:t=>e({loopError:t})}));function $(e){return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e.label}),e.children,e.hint?(0,H.jsx)(`span`,{className:D(`text-xs`,e.hintTone===`destructive`?`text-destructive`:`text-muted-foreground`),children:e.hint}):null]})}function vu(e){let{draft:t,patchDraft:n}=e;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{label:`Working directory`,hint:`Optional. Relative to the parent chat cwd. Restricts the subagent's filesystem access to this subtree.`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-working-dir`,value:t.workingDir??``,onChange:e=>{let t=e.target.value;n({workingDir:t.length>0?t:void 0})},placeholder:`docs`})}),(0,H.jsx)($,{label:`Allowed paths`,hint:`Optional. Newline-separated, relative to the parent chat cwd. When set, file tools can only read/write inside these roots.`,children:(0,H.jsx)(Dn,{"data-testid":`subagent-form-allowed-paths`,value:(t.allowedPaths??[]).join(`
|
|
12
|
+
`),onChange:e=>{let t=e.target.value.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);n({allowedPaths:t.length>0?t:void 0})},placeholder:`docs
|
|
13
|
+
wiki`,rows:3})}),(0,H.jsx)($,{label:`Beacon tools`,hint:`Off by default. When on, this subagent can run commands and read files on your paired machines. Each call still asks for your approval.`,children:(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-foreground`,children:[(0,H.jsx)(`input`,{type:`checkbox`,"data-testid":`subagent-form-allow-beacon-tools`,checked:t.allowBeaconTools===!0,onChange:e=>{n({allowBeaconTools:e.target.checked})}}),(0,H.jsx)(`span`,{children:`Allow this subagent to use beacon tools (run on your paired machines)`})]})})]})}function yu(e){return`contextWindow`in e}function bu(e){return`fastMode`in e}function xu(e){let t=e.editing,n=(0,V.useMemo)(()=>t.kind===`edit`?e.subagents.find(e=>e.id===t.id)??null:null,[t,e.subagents]),r=t.kind,i=r!==`list`,a=e.subagents.length===0;return a&&!i?(0,H.jsx)(Su,{onStartCreate:e.onStartCreate}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-6 md:flex-row md:items-start md:gap-8`,children:[a?null:(0,H.jsx)(wu,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?(0,H.jsx)(Au,{mode:r,subject:r===`edit`?n:null,providerDefaults:e.providerDefaults,availableProviders:e.availableProviders,handlers:e.handlers,onCancelEditing:e.onCancelEditing},r===`edit`?n?.id??`edit`:`create`):(0,H.jsx)(Cu,{})]})}function Su(e){return(0,H.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`subagent-empty`,children:[(0,H.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,H.jsx)(Yn,{className:`size-5`,"aria-hidden":!0})}),(0,H.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No subagents yet`}),(0,H.jsxs)(k,{variant:`default`,size:`sm`,onClick:e.onStartCreate,children:[(0,H.jsx)(Ae,{className:`mr-1.5 size-4`}),` Create subagent`]})]})}function Cu(){return(0,H.jsx)(`div`,{className:`hidden flex-1 items-center justify-center rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground md:flex`,children:`Select a subagent to edit, or create a new one.`})}function wu(e){let t=e.editing.kind===`edit`?e.editing.id:null;return(0,H.jsxs)(`aside`,{className:`flex w-full flex-col gap-2 md:w-64 md:flex-shrink-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.subagents.length,` `,e.subagents.length===1?`agent`:`agents`]}),(0,H.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:e.onStartCreate,"data-testid":`subagent-create`,children:[(0,H.jsx)(Ae,{className:`size-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Create subagent`})]})]}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.subagents.map(n=>{let r=n.description?.trim()||(n.contextScope===`previous-assistant-reply`?`Last reply`:`Full transcript`);return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`subagent-row:${n.id}`,onClick:()=>e.onSelect(n.id),className:D(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,t===n.id&&`bg-muted`),children:[(0,H.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:n.name}),(0,H.jsx)(Tu,{provider:n.provider})]}),(0,H.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:r})]})},n.id)})})]})}function Tu({provider:e}){let t=ze(e).label;return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground`,children:[(0,H.jsx)(Yn,{className:`size-3`}),` `,t]})}function Eu(e,t){return(e.some(e=>e.id===t)?e:[...e,ze(t)]).map(e=>({value:e.id,label:e.label}))}function Du(e,t){return t.length===0?e:e.map(e=>e.id===`openrouter`?{...e,models:t.map(e=>({id:e.id,label:e.label}))}:e)}var Ou=[{value:`previous-assistant-reply`,label:`Last reply`},{value:`full-transcript`,label:`Full transcript`}],ku=[{value:`auto`,label:`Auto`},{value:`manual`,label:`Manual`}];function Au(e){let t=(0,V.useMemo)(()=>e.mode===`edit`&&e.subject?su(e.subject):ou(`claude`,e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=_u(e=>e.resetForm),r=_u(e=>e.form),i=_u(e=>e.patchFormDraft),a=_u(e=>e.patchForm);(0,V.useEffect)(()=>{n(t)},[]);let{draft:o,error:s,confirmDelete:c}=r,l=N(`subagent.save`,e.subject?.id??`new`),u=N(`subagent.delete`,e.subject?.id??``),d=M(l),f=M(u),p=d||f,m=Eu(e.availableProviders,o.provider),h=s?.field===`name`?s.message:null,g=s?.field===`general`?s.message:null,_=fu(o,t),v=o.name.trim().length>0&&(e.mode===`create`||_);function y(e){i(e),s?.field===`name`&&`name`in e&&a({error:null})}function b(t){if(t===o.provider)return;let n=ou(t,e.providerDefaults,e.availableProviders);i({provider:t,model:n.model,modelOptions:n.modelOptions})}function x(e){if(o.provider!==`claude`)return;let t=yu(o.modelOptions)?o.modelOptions:Ne;i({modelOptions:{...Ne,...t,reasoningEffort:e}})}function S(e){if(o.provider!==`claude`)return;let t=yu(o.modelOptions)?o.modelOptions:Ne;i({modelOptions:{...Ne,...t,contextWindow:e}})}function ee(e){if(o.provider!==`codex`)return;let t=bu(o.modelOptions)?o.modelOptions:Be;i({modelOptions:{...Be,...t,reasoningEffort:e}})}async function C(){if(v&&!f){a({error:null,confirmDelete:!1});try{let t=e.mode===`create`?await e.handlers.onCreate(o):await e.handlers.onUpdate(e.subject.id,o);t.ok||a({error:mu(t.error)})}catch(e){a({error:{field:`general`,message:L(e)}})}}}async function te(){if(e.mode===`edit`&&e.subject){if(!c)a({confirmDelete:!0});else{a({error:null});try{await e.handlers.onDelete(e.subject.id)}catch(e){a({error:{field:`general`,message:L(e)}})}finally{a({confirmDelete:!1})}}}}let w=o.provider===`claude`?{...Ne,...yu(o.modelOptions)?o.modelOptions:{}}:null,ne=o.provider===`codex`?{...Be,...bu(o.modelOptions)?o.modelOptions:{}}:null,re=e.availableProviders.find(e=>e.id===o.provider)??ze(o.provider);return(0,H.jsxs)(`section`,{className:`flex w-full flex-1 flex-col gap-4`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h3`,{className:`text-base font-medium text-foreground`,children:e.mode===`create`?`New subagent`:o.name||`Subagent`}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Mention with `,(0,H.jsxs)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:[`@agent/`,o.name||`<name>`]}),` in chat.`]})]}),g?(0,H.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:g}):null,(0,H.jsx)($,{label:`Name`,hint:h,hintTone:h?`destructive`:`muted`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-name`,value:o.name,onChange:e=>y({name:hu(e.target.value)}),maxLength:64,placeholder:`reviewer`,className:`font-mono`})}),(0,H.jsx)($,{label:`Description`,hint:`Optional. Shown next to the name.`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-description`,value:o.description??``,onChange:e=>y({description:e.target.value}),placeholder:`Reviews diffs against the repo style`})}),(0,H.jsx)($,{label:`Provider`,children:(0,H.jsx)(F,{value:o.provider,onValueChange:e=>{St(e)&&b(e)},options:m,size:`sm`})}),(0,H.jsx)($,{label:`Model`,children:(0,H.jsxs)(Ce,{value:o.model,onValueChange:e=>y({model:e}),children:[(0,H.jsx)(ye,{"data-testid":`subagent-form-model`,className:`w-full md:w-72`,children:(0,H.jsx)(xe,{placeholder:`Select a model`})}),(0,H.jsx)(be,{children:re.models.map(e=>(0,H.jsx)(P,{value:e.id,children:e.label},e.id))})]})}),w?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{label:`Reasoning effort`,children:(0,H.jsx)(F,{value:w.reasoningEffort,onValueChange:e=>{rt(e)&&x(e)},options:Le.map(e=>({value:e.id,label:e.label})),size:`sm`})}),(0,H.jsx)($,{label:`Context window`,children:(0,H.jsx)(F,{value:w.contextWindow,onValueChange:e=>{We(e)&&S(e)},options:Ge.map(e=>({value:e.id,label:e.label})),size:`sm`})})]}):null,ne?(0,H.jsx)($,{label:`Reasoning effort`,children:(0,H.jsx)(F,{value:ne.reasoningEffort,onValueChange:e=>{Pe(e)&&ee(e)},options:Ie.map(e=>({value:e.id,label:e.label})),size:`sm`})}):null,(0,H.jsx)($,{label:`Context scope`,children:(0,H.jsx)(F,{value:o.contextScope,onValueChange:e=>{Fe(e)&&y({contextScope:e})},options:Ou,size:`sm`})}),(0,H.jsx)($,{label:`Trigger`,hint:`Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.`,children:(0,H.jsx)(F,{value:ru(o),onValueChange:e=>{nt(e)&&y({triggerMode:e})},options:ku,size:`sm`})}),(0,H.jsx)($,{label:`System prompt`,hint:`What this persona should focus on. Plain text.`,children:(0,H.jsx)(Dn,{"data-testid":`subagent-form-system-prompt`,value:o.systemPrompt,onChange:e=>y({systemPrompt:e.target.value}),placeholder:`You are a careful code reviewer...`,rows:6,className:`min-h-32`})}),(0,H.jsx)($,{label:`Max turns`,hint:`Optional. Caps the agentic turns per run (like Claude Code's per-agent maxTurns). Empty = unbounded. Claude SDK runs stop gracefully at the limit; Codex runs are aborted.`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-max-turns`,type:`number`,min:1,step:1,value:o.maxTurns?.toString()??``,onChange:e=>{let t=Number.parseInt(e.target.value,10);y({maxTurns:Number.isInteger(t)&&t>0?t:void 0})},placeholder:`unbounded`,className:`w-36`})}),o.provider===`claude`?(0,H.jsx)(vu,{draft:o,patchDraft:y}):null,(0,H.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-end gap-2 pt-2`,children:[(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:e.onCancelEditing,children:`Cancel`}),e.mode===`edit`?(0,H.jsx)(k,{variant:`destructive`,size:`sm`,"data-testid":`subagent-form-delete`,disabled:p,pending:f,onClick:()=>{j(u,te)},children:c?`Confirm delete`:`Delete`}):null,(0,H.jsx)(k,{variant:`default`,size:`sm`,"data-testid":`subagent-form-save`,disabled:!v||p,pending:d,onClick:()=>{j(l,C)},children:p?`Saving…`:`Save`})]})]})}var ju=[];function Mu(e){let t=z(e=>e.settings?.subagents??ju),n=z(e=>e.settings?.providerDefaults),r=z(Wt),i=z(on),a=m(De(e=>e.models)),o=(0,V.useMemo)(()=>Du(Qe(Ke([...Ue],r),i),a),[r,i,a]),s=_u(e=>e.editing),c=_u(e=>e.setEditing),l=(0,V.useMemo)(()=>({onCreate:async t=>{let n=await e.state.socket.command({type:`subagent.create`,input:t});return n.ok&&c({kind:`edit`,id:n.subagent.id}),n},onUpdate:async(t,n)=>await e.state.socket.command({type:`subagent.update`,id:t,patch:cu(n)}),onDelete:async t=>{await e.state.socket.command({type:`subagent.delete`,id:t}),c({kind:`list`})}}),[e.state.socket,c]),u=(0,V.useCallback)(e=>{c({kind:`edit`,id:e})},[c]),d=(0,V.useCallback)(()=>{c({kind:`create`})},[c]),f=(0,V.useCallback)(()=>{c({kind:`list`})},[c]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:[(0,H.jsx)(Ru,{subagents:t,handleWriteAppSettings:e.state.handleWriteAppSettings}),(0,H.jsx)(xu,{subagents:t,providerDefaults:n,availableProviders:o,editing:s,onSelect:u,onStartCreate:d,onCancelEditing:f,handlers:l})]})}var Nu=`__none__`,Pu=qa.min/1e3,Fu=qa.max/1e3,Iu={min:Pu,max:Fu,integer:!0},Lu=Ka/1e3;function Ru(e){let t=z(e=>e.settings?.subagentRuntime),n=t?Math.round(t.runTimeoutMs/1e3):Lu,r=t?.defaultLoopSubagentId??null,i=_u(e=>e.timeoutDraft),a=_u(e=>e.setTimeoutDraft),o=_u(e=>e.loopError),s=_u(e=>e.setLoopError);(0,V.useEffect)(()=>{a(String(n))},[n]);function c(){let t=Number(i);tn(Iu,t)?(s(null),t!==n&&e.handleWriteAppSettings({subagentRuntime:{runTimeoutMs:t*1e3}}).catch(gt(e=>s(e.message)))):(a(String(n)),s(`Timeout must be a whole number of seconds between ${Pu} and ${Fu}.`))}function l(t){s(null);let n=t===Nu?null:t;e.handleWriteAppSettings({subagentRuntime:{defaultLoopSubagentId:n}}).catch(gt(e=>s(e.message)))}return(0,H.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-lg border border-border/60 bg-card/40 p-4`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Loop & runtime`}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Applies to background subagent runs and the autonomous `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono`,children:`/loop`}),`.`]})]}),o?(0,H.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:o}):null,(0,H.jsx)($,{label:`Stall timeout (seconds)`,hint:`A subagent run is aborted only after this long with no streamed activity — not a total wall-clock cap. A steadily-working run is never killed.`,children:(0,H.jsx)(R,{type:`number`,inputMode:`numeric`,min:Pu,max:Fu,value:i,onChange:e=>a(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&(c(),e.currentTarget.blur())},className:`w-full md:w-48 tabular-nums`})}),(0,H.jsx)($,{label:`Default loop subagent`,hint:`The subagent setup_loop delegates each chunk to when no explicit id is given.`,children:(0,H.jsxs)(Ce,{value:r??Nu,onValueChange:l,children:[(0,H.jsx)(ye,{className:`w-full md:w-72`,children:(0,H.jsx)(xe,{placeholder:`None`})}),(0,H.jsxs)(be,{children:[(0,H.jsx)(P,{value:Nu,children:`None (require explicit id)`}),e.subagents.map(e=>(0,H.jsx)(P,{value:e.id,children:e.name},e.id))]})]})})]})}function zu(e,t){return{shortcut:e,expansion:t,error:null}}var Bu=I()(e=>({editing:ko,editorForm:zu(``,``),setEditing:t=>e({editing:t}),resetEditorForm:(t,n)=>e({editorForm:zu(t,n)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))}));function Vu({snippets:e,handlers:t,dom:n=wn}){let r=Bu(e=>e.editing),i=Bu(e=>e.setEditing),a=Bu(e=>e.resetEditorForm);function o(t){if(t.kind===`create`)a(``,``);else if(t.kind===`edit`){let n=e.find(e=>e.id===t.id)??null;n&&a(n.shortcut,n.expansion)}i(t)}if(r.kind!==`list`){let n=r.kind===`edit`?e.find(e=>e.id===r.id)??null:null;return(0,H.jsx)(Uu,{initial:n,existing:e.map(e=>({id:e.id,shortcut:e.shortcut})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Text snippets`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Type a shortcut in the chat composer and press Tab to expand it into the full text. Handy for prompts you send often.`})]}),(0,H.jsxs)(k,{size:`sm`,onClick:()=>o({kind:`create`}),children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add snippet`]})]}),e.length===0?(0,H.jsx)(Yr,{icon:Vr,message:`No snippets yet. Add one to expand a shortcut with Tab.`}):(0,H.jsx)(Xr,{children:e.map(e=>(0,H.jsx)(Hu,{snippet:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]})}function Hu({snippet:e,onEdit:t,onDelete:n,dom:r}){let i=N(`textSnippets.delete`,e.id),a=M(i),o=(0,V.useCallback)(()=>{r.confirmDialog(`Delete snippet "${e.shortcut}"?`)&&j(i,()=>n(e.id))},[i,r,n,e.id,e.shortcut]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`font-mono text-sm`,children:e.shortcut}),(0,H.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.expansion})]}),(0,H.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,H.jsx)(Zr,{label:e.shortcut,onEdit:t,onDelete:o,deletePending:a})})]})}function Uu({initial:e,existing:t,handlers:n,onDone:r}){let i=Bu(e=>e.editorForm),a=Bu(e=>e.patchEditorForm),{shortcut:o,expansion:s,error:c}=i,l=N(`textSnippets.save`,e?.id??`new`),u=M(l),d=e!==null,f=o.trim(),p=bn.test(f),m=(0,V.useMemo)(()=>t.some(t=>t.shortcut===f&&t.id!==e?.id),[t,f,e?.id]),h=p&&!m&&s.length>0&&!u,g=()=>Io({patch:a,save:async()=>{d&&e?await n.onUpdate(e.id,{shortcut:f,expansion:s}):await n.onCreate({shortcut:f,expansion:s})},onDone:r}),_=Lo({submitting:u,isEdit:d,addLabel:`Add snippet`});return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:d?`Edit snippet`:`Add snippet`}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Shortcut`}),(0,H.jsx)(R,{value:o,onChange:e=>a({shortcut:e.target.value}),placeholder:`pgm`,className:`font-mono`,autoFocus:!0}),o.length>0&&!p&&(0,H.jsx)(`span`,{className:`text-xs text-destructive`,children:`Shortcut must be 1-32 characters with no spaces.`}),m&&(0,H.jsx)(`span`,{className:`text-xs text-destructive`,children:`A snippet with this shortcut already exists.`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Expands to`}),(0,H.jsx)(Dn,{value:s,onChange:e=>a({expansion:e.target.value}),placeholder:`pull request green then merge`,rows:4})]}),c&&(0,H.jsx)(`span`,{className:`text-xs text-destructive`,children:c}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:()=>{j(l,g)},pending:u,disabled:!h,children:_}),(0,H.jsx)(k,{variant:`ghost`,onClick:r,disabled:u,children:`Cancel`})]})]})}function Wu(e){let t=z(Jt),n=Po(`textSnippets`,e.state);return(0,H.jsx)(Vu,{snippets:t,handlers:n})}var Gu=N(`packages.checkUpdates`);function Ku(e){return N(`packages.update`,e)}var qu=[],Ju=[],Yu=[],Xu=[];function Zu({pkg:e,packageEntry:t,applying:n,onUpdate:r}){let i=M(Ku(e.id)),a=n||i,o=e.versionLabel??e.version??e.revision?.slice(0,7)??null,s=Ll(t);return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),o?(0,H.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:o}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,H.jsx)(Rl,{availability:t?.update.availability}),s?(0,H.jsx)(zl,{label:s,updating:a,onClick:r}):null,e.sourceUrl?(0,H.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} source`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ln,{className:`h-4 w-4`})}):null]})]})}function Qu({source:e,packages:t,updateEntries:n,applying:r,isChecking:i,onCheckUpdates:a,onUpdate:o}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:e}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,className:`h-6 rounded-full px-2 text-xs`,disabled:i,"aria-busy":i||void 0,onClick:a,children:[i?(0,H.jsx)(A,{className:`mr-1 h-3 w-3 animate-spin`}):(0,H.jsx)(je,{className:`mr-1 h-3 w-3`}),`Refresh`]})]}),(0,H.jsx)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:t.map(e=>{let t=n.find(t=>t.id===e.id)??null;return(0,H.jsx)(Zu,{pkg:e,packageEntry:t,applying:r.includes(e.id),onUpdate:()=>o(e.id)},e.id)})})]})}function $u({label:e,kind:t,packages:n,errors:r,updateEntries:i,applying:a,isChecking:o,onCheckUpdates:s,onUpdate:c}){let l=r.find(e=>e.kind===t),u=n.filter(e=>e.kind===t),d=new Map;for(let e of u){let t=e.source||`Unknown`,n=d.get(t);n?n.push(e):d.set(t,[e])}let f=t===`claude-plugin`?`Claude Code CLI`:`Codex CLI`,p;return p=l?(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:[f,` not found — install it to manage `,e,` plugins.`]}):u.length===0?(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:[`No `,e,` plugins installed.`]}):(0,H.jsx)(`div`,{className:`flex flex-col gap-4`,children:[...d.entries()].map(([e,t])=>(0,H.jsx)(Qu,{source:e,packages:t,updateEntries:i,applying:a,isChecking:o,onCheckUpdates:s,onUpdate:c},e))}),(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),p]})}function ed({state:e}){let{socket:t,connectionStatus:n}=e,r=w(e=>e.inventory),i=w(e=>e.loading),a=w(e=>e.error),o=w(e=>e.inventoryCleared),s=w(e=>e.inventoryLoadStarted),c=w(e=>e.inventoryLoaded),l=w(e=>e.inventoryLoadFailed),u=w(e=>e.inventoryLoadFinished),d=w(e=>e.updateSnapshot),f=(0,V.useCallback)(async()=>{if(n!==`connected`)o();else try{s(),c(await t.command({type:`packages.listInstalled`}))}catch(e){l(L(e))}finally{u()}},[n,t,o,s,c,l,u]);(0,V.useEffect)(()=>{Cn(`packages.listInstalled`,f())},[f]);let p=(0,V.useCallback)(()=>{j(Gu,()=>On(t,{type:`packages.checkUpdates`}))},[t]),m=(0,V.useCallback)(e=>{j(Ku(e),()=>On(t,{type:`packages.update`,id:e}))},[t]),h=M(Gu),g=d?.status===`checking`||h,_=d?.applying??Xu,v=d?.packages.filter(e=>e.kind===`claude-plugin`||e.kind===`codex-plugin`)??Yu,y=r?.packages??qu,b=r?.errors??Ju;return a?(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:a}):i&&!r?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,H.jsx)($u,{label:`Claude Code`,kind:`claude-plugin`,packages:y,errors:b,updateEntries:v,applying:_,isChecking:g,onCheckUpdates:p,onUpdate:m}),(0,H.jsx)($u,{label:`Codex`,kind:`codex-plugin`,packages:y,errors:b,updateEntries:v,applying:_,isChecking:g,onCheckUpdates:p,onUpdate:m})]})}var td=I()(e=>({publicUrlDraft:null,error:null,setPublicUrlDraft:t=>e({publicUrlDraft:t}),setError:t=>e({error:t})})),nd=`<your Kanna password>`,rd=`Start Kanna with --password first; the remote MCP server is off without it. `,id=`The URL must be https and reachable from the internet (a Cloudflare tunnel or --share).`;function ad(e){return`${e}/mcp`}function od({publicOrigin:e,passwordConfigured:t}){let n=ad(e??`https://<your-public-kanna-url>`),r=t?``:rd;return[{id:`claude-code`,client:`claude-code`,title:`Claude Code`,instructions:`${r}Add the server with your Kanna password as a bearer header, or add it without one and sign in through OAuth.`,snippet:[`claude mcp add --transport http kanna ${n} --header "Authorization: Bearer ${nd}"`,``,`claude mcp add --transport http kanna ${n}`,`# then run /mcp inside Claude Code and choose Authenticate to sign in with OAuth`].join(`
|
|
14
|
+
`)},{id:`codex`,client:`codex`,title:`Codex`,instructions:`${r}Put the block in ~/.codex/config.toml and export your Kanna password as KANNA_PASSWORD, or sign in through OAuth instead.`,snippet:[`[mcp_servers.kanna]`,`url = "${n}"`,`bearer_token_env_var = "KANNA_PASSWORD"`,``,`# OAuth alternative: drop bearer_token_env_var and run`,`codex mcp login kanna`].join(`
|
|
15
|
+
`)},{id:`claude-desktop`,client:`claude-desktop`,title:`Claude Desktop and claude.ai`,instructions:`${r}Open Settings, Connectors, Add custom connector and enter the URL. Add the request header below, or leave it empty to sign in through OAuth. ${id}`,snippet:[`URL: ${n}`,`Header: Authorization: Bearer ${nd}`].join(`
|
|
16
|
+
`)},{id:`chatgpt`,client:`chatgpt`,title:`ChatGPT`,instructions:`${r}Open chatgpt.com/plugins, select the plus button, then Add custom MCP server; enter the URL and choose OAuth as the authentication. ${id}`,snippet:[`URL: ${n}`,`Authentication: OAuth`].join(`
|
|
17
|
+
`)}]}var sd=N(`settings.remoteMcp`,`enabled`),cd=N(`settings.remoteMcp`,`publicUrl`),ld=[{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}];function ud(e){try{return new URL(e).origin}catch{return``}}function dd({snippet:e}){let t=N(`remoteMcp.copySnippet`,e.id),n=ge(t),r=(0,V.useCallback)(()=>ve(t,()=>he.writeText(e.snippet)),[t,e.snippet]);return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-mobile`,"aria-label":n?`Copied ${e.title} setup`:`Copy ${e.title} setup`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>Cn(`copy remote MCP setup`,r()),children:n?(0,H.jsx)(_e,{className:`h-4 w-4 text-success-text`}):(0,H.jsx)(me,{className:`h-4 w-4`})})]}),(0,H.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:e.instructions}),(0,H.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md border border-border bg-muted p-2 font-mono text-xs text-foreground`,children:e.snippet})]})}function fd({state:e,dom:t=wn}){let n=z(sn),r=Jr(e=>e.authEnabled),i=td(e=>e.publicUrlDraft),a=td(e=>e.setPublicUrlDraft),o=td(e=>e.error),s=td(e=>e.setError),c=M(cd),l=i??n.publicUrl??``,u=l.trim(),d=u!==``&&fn(u)===null,f=u!==(n.publicUrl??``),p=n.publicUrl??fn(ud(t.getHref())),m=od({publicOrigin:p,passwordConfigured:r}),h=(0,V.useCallback)(t=>e.handleWriteAppSettings({remoteMcp:{enabled:t===`enabled`}}),[e]),g=(0,V.useCallback)(async()=>{s(null);try{await e.handleWriteAppSettings({remoteMcp:{publicUrl:u===``?null:u}}),a(null)}catch(e){s(L(e))}},[e,u,a,s]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 pb-2`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Remote MCP`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Let other agents and apps drive Kanna over the Model Context Protocol: Claude Code, Codex, Claude Desktop and ChatGPT can list projects, run chats, move board cards and more.`})]}),r?null:(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:`Set --password when starting Kanna to enable the remote MCP server`}),(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(U,{title:`Remote MCP server`,description:`Serves the /mcp endpoint and the OAuth sign-in pages. Turn it off to answer 404 on all of them.`,children:(0,H.jsx)(La,{pendingKey:sd,value:n.enabled?`enabled`:`disabled`,onValueChange:h,options:ld,size:`sm`})}),(0,H.jsx)(U,{title:`Public URL`,description:`https URL, or http on localhost; the OAuth issuer and resource are derived from it. Leave empty to use this machine's loopback address.`,alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,H.jsx)(R,{value:l,onChange:e=>a(e.target.value),placeholder:`https://kanna.example.com`,"aria-label":`Public URL`,"aria-invalid":d||void 0,spellCheck:!1}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,H.jsx)(`span`,{className:d?`text-destructive-text`:`text-muted-foreground`,children:d?`Enter an https URL, or an http URL on localhost`:`Path, query and trailing slash are dropped`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!f||d,onClick:()=>j(cd,g),pending:c,children:`Save`})]}),o?(0,H.jsx)(`div`,{className:`text-xs text-destructive-text`,children:o}):null]})}),(0,H.jsx)(U,{title:`Endpoint`,description:`Give this URL to your MCP client.`,bordered:!0,children:p?(0,H.jsxs)(`code`,{className:`break-all rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs`,children:[p,`/mcp`]}):(0,H.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`Set a public URL to see the endpoint`})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Connect a client`}),(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:m.map(e=>(0,H.jsx)(dd,{snippet:e},e.id))})]})]})}var pd=`auth.signOut`,md=[{id:`general`,label:`General`,icon:Wn,subtitle:`Manage appearance, editor behavior, and embedded terminal defaults.`},{id:`skills`,label:`Skills`,icon:pr,subtitle:`Manage globally installed agent skills from the active skill lock file.`},{id:`plugins`,label:`Plugins`,icon:Nr,subtitle:`View and update globally installed Claude Code and Codex plugins.`},{id:`kanna-plugins`,label:`Kanna plugins`,icon:u,subtitle:`Install local Kanna plugins that contribute UI surfaces and daemon behavior.`},{id:`providers`,label:`Providers`,icon:Dr,subtitle:`Manage the default chat provider and saved model defaults for Claude Code and Codex.`},{id:`models`,label:`Models`,icon:xr,subtitle:`Add, edit, and remove Claude and Codex models available in the model picker.`},{id:`subagents`,label:`Subagents`,icon:Yn,subtitle:`Define reusable agent personas. Mention them in chat with @agent/<name>.`},{id:`mcp-servers`,label:`MCP servers`,icon:Nr,subtitle:`Install custom MCP servers (stdio, http, sse, ws) and connect-test them.`},{id:`mcp-sources`,label:`MCP sources`,icon:dr,subtitle:`Bring messages from an MCP server, such as Zalo, into the Inbox by subscription or polling.`},{id:`remote-mcp`,label:`Remote MCP`,icon:jr,subtitle:`Let Claude, Codex and ChatGPT drive Kanna over MCP, with setup snippets for each client.`},{id:`service-bus`,label:`Service bus`,icon:Ur,subtitle:`Mirror Kanna's events into NATS JetStream, with an embedded or your own server.`},{id:`beacons`,label:`Beacons`,icon:Jn,subtitle:`Pair your own machines so the agent can read files and run approved commands there.`},{id:`snippets`,label:`Text snippets`,icon:Vr,subtitle:`Define shortcuts that expand to full text in the chat composer with Tab.`},{id:`instructions`,label:`Instructions`,icon:Dr,subtitle:`Global instructions appended to every Claude and Codex turn (main + subagents).`},{id:`keybindings`,label:`Keybindings`,icon:yr,subtitle:`Edit global app shortcuts stored in the active keybindings file.`},{id:`changelog`,label:`Changelog`,icon:pr,subtitle:`Release notes pulled from the public GitHub releases feed.`}],hd={general:fo,skills:tu,plugins:ed,"kanna-plugins":yo,providers:Ic,models:Vs,subagents:Mu,"mcp-servers":Jo,"mcp-sources":Ps,"remote-mcp":fd,"service-bus":Pl,beacons:Bi,snippets:Wu,instructions:ho,keybindings:To,changelog:ta};function gd(e){return e?md.find(t=>t.id===e)?.id??null:null}function _d(e){return e?md:md.filter(e=>e.id!==`kanna-plugins`)}function vd(e){return`Edit global app shortcuts stored in ${e}.`}function yd({sectionId:e}={}){let t=n(),i=r(),a=M(pd),s=Jr(e=>e.authEnabled),l=Jr(e=>e.setAuthEnabled),u=gd(e)??`general`,d=hd[u],p=z(e=>e.hydrationStatus===`loading`&&e.settings===null),m=i.connectionStatus===`connecting`||!i.localProjectsReady||p,h=M(`keybindings.openEditor`),_=i.localProjects?.machine.displayName??`Unavailable`,v=i.localProjects?.projects.length??0,y=vt,x=i.updateSnapshot,S=(0,V.useMemo)(()=>T(i.keybindings).filePathDisplay||ht(),[i.keybindings]);(0,V.useEffect)(()=>{e&&(gd(e)||t(`/settings/general`,{replace:!0}))},[t,e]),(0,V.useEffect)(()=>{let e=!1;return Cn(`read auth status`,b().then(t=>{e||l(t.kind===`ok`&&t.status.enabled===!0)})),()=>{e=!0}},[l]);let ee=md.find(e=>e.id===u)??md[0],C=z(qt),te=(0,V.useMemo)(()=>_d(C),[C]),w=u===`keybindings`?vd(S):ee.subtitle,ne=!m;return(0,H.jsxs)(`div`,{className:`relative flex h-full flex-1 min-w-0 bg-background`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1`,children:[(0,H.jsx)(`aside`,{className:`hidden w-[200px] shrink-0 md:block ${ne?`pb-[89px]`:``}`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-6`,children:[(0,H.jsx)(`div`,{className:`px-3 pb-5 text-22 font-extrabold tracking-[-0.5px] text-foreground`,children:`Settings`}),te.map(e=>{let n=e.id===`changelog`&&x?.updateAvailable===!0;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{t(`/settings/${e.id}`)},className:`relative cursor-pointer rounded-lg px-3 py-2 text-sm ${e.id===u?`font-medium text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[e.id===u?(0,H.jsx)(f.span,{layoutId:`settings-nav-indicator`,className:`absolute inset-0 rounded-lg bg-muted`,transition:{type:`spring`,...g.indicator}}):null,(0,H.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,H.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(hr,{className:`ml-auto size-3.5 shrink-0 text-warning-text`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Update available`})]}):null]})]},e.label)}),s?(0,H.jsx)(`button`,{type:`button`,onClick:()=>j(pd,i.handleSignOut),disabled:a,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[a?(0,H.jsx)(E,{className:`h-4 w-4`}):(0,H.jsx)(Tr,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:a?`Signing out...`:`Sign out`})]})}):null]})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto`,children:[(0,H.jsx)(`div`,{className:`sticky top-0 z-20 border-b border-border bg-background px-2 py-2 md:hidden`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(En,{label:`Open sidebar`,children:(0,H.jsx)(`button`,{type:`button`,onClick:i.openSidebar,className:`flex size-11 shrink-0 items-center justify-center rounded-md text-sm text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,"aria-label":`Open sidebar`,children:(0,H.jsx)(o,{className:`h-4 w-4 shrink-0`})})}),(0,H.jsxs)(Ce,{value:u,onValueChange:e=>{t(`/settings/${e}`)},children:[(0,H.jsx)(ye,{className:`h-11 min-w-0 flex-1`,"aria-label":`Settings section`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:te.map(e=>(0,H.jsx)(P,{value:e.id,children:e.label},e.id))})})]}),s?(0,H.jsxs)(`button`,{type:`button`,onClick:()=>j(pd,i.handleSignOut),disabled:a,className:`flex min-h-11 shrink-0 items-center gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:[a?(0,H.jsx)(E,{className:`h-4 w-4`}):(0,H.jsx)(Tr,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{className:`sr-only`,children:a?`Signing out...`:`Sign out`})]}):null]})}),(0,H.jsxs)(`div`,{className:`w-full px-4 pb-32 pt-8 md:px-6 md:pt-16`,children:[m?(0,H.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-2xl border border-border bg-card/40 px-4 py-6 text-sm text-muted-foreground`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,H.jsx)(`span`,{children:`Loading machine settings…`})]})}):(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl kanna-settings-section-in`,children:[(0,H.jsxs)(`div`,{className:`pb-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4 min-h-[34px]`,children:[(0,H.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:ee.label}),u===`general`?(0,H.jsx)(cr,{variant:`outline`,onClick:()=>{t(`/settings/changelog`)},children:`Check for updates`}):null,u===`keybindings`?(0,H.jsxs)(cr,{onClick:()=>j(`keybindings.openEditor`,()=>i.handleOpenExternalPath(`open_editor`,S)),disabled:h,"aria-busy":h||void 0,icon:h?(0,H.jsx)(E,{className:`h-4 w-4`}):(0,H.jsx)(c,{className:`h-4 w-4`}),children:[`Open in `,i.editorLabel]}):null]}),(0,H.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:w})]}),(0,H.jsx)(d,{state:i})]},u),i.commandError?(0,H.jsxs)(`div`,{className:`mx-auto mt-4 flex max-w-4xl items-start gap-3 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:[(0,H.jsx)(we,{className:`mt-0.5 h-4 w-4 flex-shrink-0`}),(0,H.jsx)(`span`,{children:i.commandError})]}):null]})]})]}),ne?(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 border-t border-border bg-background`,children:(0,H.jsx)(`div`,{className:`px-6 py-[14.25px]`,children:(0,H.jsxs)(`div`,{className:`grid gap-3 text-xs text-muted-foreground grid-cols-2 lg:grid-cols-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Machine`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:_})]}),(0,H.jsxs)(`div`,{className:`hidden md:block`,children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Connection`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:i.connectionStatus})]}),(0,H.jsxs)(`div`,{className:`hidden md:block`,children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Projects Indexed`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:v})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`App Version`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:y})]})]})})}):null]})}export{yd as SettingsPage};
|
package/dist/client/assets/{StackBoardsRoutePage-qh4CMVbO.js → StackBoardsRoutePage-7wFhv0_e.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{l as n,u as r}from"./chunk-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{l as n,u as r}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{t as a}from"./BoardsPage-J03IilS6.js";var o=e(t(),1),s=e(i(),1);function c({stackId:e}){let t=r(),i=n(),c=t.sidebarData.stacks.find(t=>t.id===e),l=c?c.title:`Stack`,u=(0,o.useCallback)(t=>{i(`/boards/stack/${e}/${t}`)},[i,e]);return(0,s.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,s.jsx)(a,{ownerKind:`stack`,ownerId:e,ownerName:l,socket:t.socket,onOpenBoard:u})})}export{c as StackBoardsRoutePage};
|