@cuongtran001/kanna 1.94.2 → 1.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/client/assets/{BoardsPage-CcEgSKEH.js → BoardsPage-DYLH4CnT.js} +1 -1
  2. package/dist/client/assets/{BoardsRoutePage-DYG2WpTB.js → BoardsRoutePage-C-9i-aRF.js} +1 -1
  3. package/dist/client/assets/ChatPage-BRFYC5UH.js +35 -0
  4. package/dist/client/assets/{CronJobsPage-LCRBV65t.js → CronJobsPage-C-gjzAu1.js} +1 -1
  5. package/dist/client/assets/{FilePreviewSheet-DK4JlQ4b.js → FilePreviewSheet-NvVL2JG6.js} +2 -2
  6. package/dist/client/assets/{FlowSurface-B34Ui27C.js → FlowSurface-Bikh4YLq.js} +1 -1
  7. package/dist/client/assets/{GenUIBlock-B90q9Hoz.js → GenUIBlock-B3DisBjQ.js} +2 -2
  8. package/dist/client/assets/{InboundHandlerFields-CrbQcRFr.js → InboundHandlerFields-UbdPgHQ5.js} +1 -1
  9. package/dist/client/assets/{InboxPage-CcU-wMdJ.js → InboxPage-DvkzNCfr.js} +1 -1
  10. package/dist/client/assets/{LocalProjectsPage-Csj-YWVf.js → LocalProjectsPage-J0x7G0l4.js} +1 -1
  11. package/dist/client/assets/{SettingsPage-BFnBY3op.js → SettingsPage-B80IUZQz.js} +1 -1
  12. package/dist/client/assets/{StackBoardsRoutePage-qh4CMVbO.js → StackBoardsRoutePage-Dj1jG4vG.js} +1 -1
  13. package/dist/client/assets/{ToolCallMessage-36Dj7xkk.js → ToolCallMessage-DZTR1W1v.js} +1 -1
  14. package/dist/client/assets/{VChartSurface-CcMrzPBy.js → VChartSurface-BTKWM6nl.js} +1 -1
  15. package/dist/client/assets/{WebhooksPage-5KNcw-Vz.js → WebhooksPage-CvZbgQwk.js} +1 -1
  16. package/dist/client/assets/{WorkflowsPage-DNYcsvtV.js → WorkflowsPage-Dbt_ju8E.js} +1 -1
  17. package/dist/client/assets/{appSettingsStore-LgzUNvfd.js → appSettingsStore-BgLKcwVW.js} +1 -1
  18. package/dist/client/assets/{arrow-left-BIWqzCsH.js → arrow-left-B9MpdBtg.js} +1 -1
  19. package/dist/client/assets/{beacon-alias-DxONetqC.js → beacon-alias-k72gNh9f.js} +3 -3
  20. package/dist/client/assets/{chunk-OB3PAWPO-zund-gx-.js → chunk-6KYCQHYJ-C0N1h4Su.js} +1 -1
  21. package/dist/client/assets/{code-xml-BfYZcKk2.js → code-xml-0ltzEz2X.js} +1 -1
  22. package/dist/client/assets/{commandFeedback-yC5d0Ae6.js → commandFeedback-CxHXOC78.js} +1 -1
  23. package/dist/client/assets/{contextWindow-pvBJBrsH.js → contextWindow-C-20_tVh.js} +1 -1
  24. package/dist/client/assets/{copyFeedbackStore-BpFUDutm.js → copyFeedbackStore-Bw_-4aam.js} +1 -1
  25. package/dist/client/assets/{createScopedStore-Ba9K_10X.js → createScopedStore-L_qmwTAu.js} +1 -1
  26. package/dist/client/assets/{cronJobsStore-Dehc4edG.js → cronJobsStore-CHZ3jprN.js} +1 -1
  27. package/dist/client/assets/{file-plus-corner-DWHF_kbn.js → file-plus-corner-DMWk1Kix.js} +1 -1
  28. package/dist/client/assets/{github-dark-default-adAWTKmX.js → github-dark-default-CM8LCIj6.js} +1 -1
  29. package/dist/client/assets/highlights-BNrfEgy9.js +3 -0
  30. package/dist/client/assets/{inboxStore-BxT26bsM.js → inboxStore-BQwc6qjp.js} +1 -1
  31. package/dist/client/assets/index-BLMXLYEb.js +85 -0
  32. package/dist/client/assets/{index-JXlKTAWE.css → index-D_XO3fZ-.css} +1 -1
  33. package/dist/client/assets/{info-Ba70747-.js → info-DC1K4zUR.js} +1 -1
  34. package/dist/client/assets/{input-BY7tE022.js → input-_et6sDdl.js} +1 -1
  35. package/dist/client/assets/{loader-BxIVfMhW.js → loader-Dbltcnnq.js} +1 -1
  36. package/dist/client/assets/{log-DxnWb_y2.js → log-CJGZbJ9_.js} +1 -1
  37. package/dist/client/assets/minus-BzIzkqpx.js +1 -0
  38. package/dist/client/assets/{monitor-ByZxj7H9.js → monitor-BnslMj28.js} +1 -1
  39. package/dist/client/assets/{pencil-41SXT97L.js → pencil-CT-2s_oA.js} +1 -1
  40. package/dist/client/assets/{pendingActionsStore-BEJnZIRD.js → pendingActionsStore-CwUFtQGR.js} +1 -1
  41. package/dist/client/assets/{plus-CVyLwE7_.js → plus-BEiLnjKx.js} +1 -1
  42. package/dist/client/assets/{react-CZBv4gq-.js → react-B_ssCuNh.js} +4 -4
  43. package/dist/client/assets/{refresh-cw-CLCXCzaY.js → refresh-cw-Z4F-mVpF.js} +1 -1
  44. package/dist/client/assets/runDetached-eg1AfjiJ.js +1 -0
  45. package/dist/client/assets/{search-BabRSZmb.js → search-D-PyMvIQ.js} +1 -1
  46. package/dist/client/assets/{searchable-select-prsU5V9D.js → searchable-select-CBdJ9FND.js} +1 -1
  47. package/dist/client/assets/{segmented-control-BdqpOGH3.js → segmented-control-BSVd0-R_.js} +1 -1
  48. package/dist/client/assets/{select-BuN3bPMQ.js → select-DoKKeQr6.js} +1 -1
  49. package/dist/client/assets/{settings-header-button-BkDztcVR.js → settings-header-button-DuU-Cs7B.js} +1 -1
  50. package/dist/client/assets/{shiki-CCur_AjT.js → shiki-Dr1ftTui.js} +1 -1
  51. package/dist/client/assets/{state-mark-BoV1BBc0.js → state-mark-vOaDe8bG.js} +1 -1
  52. package/dist/client/assets/{stream-tokenizer-B5Lrlknv.js → stream-tokenizer-Dusn-8y-.js} +1 -1
  53. package/dist/client/assets/{terminal-uWEJ91yR.js → terminal-CCsdLV7K.js} +1 -1
  54. package/dist/client/assets/{themes-B2qJmig7.js → themes-Bahc5xK2.js} +1 -1
  55. package/dist/client/assets/{timer.adapter-BX7ibpTi.js → timer.adapter-DpluAhJm.js} +1 -1
  56. package/dist/client/assets/{tools-B59RcrVm.js → tools-Bp5T17Iw.js} +1 -1
  57. package/dist/client/assets/{triangle-alert-D3aY6mGU.js → triangle-alert-DQWxYfS8.js} +1 -1
  58. package/dist/client/assets/useAppGlobalState-B6yOUSp4.js +1 -0
  59. package/dist/client/assets/{useProviderCatalog-BJE2nJJQ.js → useProviderCatalog-BL2w91DB.js} +1 -1
  60. package/dist/client/assets/{useTheme-CuVmsdqy.js → useTheme-BH9ZneWq.js} +1 -1
  61. package/dist/client/index.html +33 -33
  62. package/package.json +10 -10
  63. package/src/server/event-store-transcript-write.adapter.ts +3 -0
  64. package/src/server/event-store.test.ts +16 -0
  65. package/src/server/event-store.ts +1 -0
  66. package/src/server/uploads.test.ts +7 -3
  67. package/src/server/ws-router-abandoned-chat.test.ts +93 -0
  68. package/src/server/ws-router-broadcast.ts +45 -1
  69. package/src/server/ws-router.ts +6 -1
  70. package/dist/client/assets/ChatPage-CUa9Mlv0.js +0 -35
  71. package/dist/client/assets/highlights-CFT8RIMY.js +0 -3
  72. package/dist/client/assets/index-CRk0GD4y.js +0 -93
  73. package/dist/client/assets/minus-DpkN1lgU.js +0 -1
  74. package/dist/client/assets/runDetached-K6ggut3D.js +0 -1
  75. package/dist/client/assets/useAppGlobalState-vHoqoq7W.js +0 -1
@@ -1,4 +1,4 @@
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-OB3PAWPO-zund-gx-.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 ee,h as x,ht as te,j as S,l as ne,m as C,n as w,o as re,s as ie,u as ae,wt as T}from"./useAppGlobalState-vHoqoq7W.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-BEJnZIRD.js";import{a as ue,l as de,n as fe,o as pe}from"./beacon-alias-DxONetqC.js";import{a as me,i as he,n as ge,o as _e,t as ve}from"./copyFeedbackStore-BpFUDutm.js";import{a as ye,i as P,n as be,o as xe,r as Se,t as Ce}from"./select-BuN3bPMQ.js";import{t as we}from"./info-Ba70747-.js";import{c as Te,r as Ee,s as De}from"./contextWindow-pvBJBrsH.js";import{t as Oe}from"./monitor-ByZxj7H9.js";import{t as ke}from"./pencil-41SXT97L.js";import{t as Ae}from"./plus-CVyLwE7_.js";import{t as je}from"./refresh-cw-CLCXCzaY.js";import{t as Me}from"./search-BabRSZmb.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-BJE2nJJQ.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-BX7ibpTi.js";import{a as dt,c as ft,o as pt,s as mt,t as F}from"./segmented-control-BdqpOGH3.js";import{d as ht,f as I,i as gt,n as L,r as _t,s as vt}from"./log-DxnWb_y2.js";import{t as R}from"./input-BY7tE022.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-LgzUNvfd.js";import{M as _n,N as vn,iu as yn,j as bn,r as xn,ru as Sn}from"./useTheme-CuVmsdqy.js";import{t as Cn}from"./runDetached-K6ggut3D.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-yC5d0Ae6.js";import{a as An,n as jn}from"./state-mark-BoV1BBc0.js";import{n as Mn,t as Nn}from"./formatDuration-BbWTR_M_.js";import{n as Pn}from"./cronJobsStore-Dehc4edG.js";import{Jt as Fn,bt as In,ln as Ln,pn as Rn,vt as zn,yt as Bn}from"./index-CRk0GD4y.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-CUa9Mlv0.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-prsU5V9D.js";import{t as cr}from"./settings-header-button-BkDztcVR.js";import{t as lr}from"./InboundHandlerFields-CrbQcRFr.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),ee=Ki(h),x=(0,V.useCallback)(async e=>{await o(e)},[o]),te=(0,V.useCallback)(async()=>{await c()},[c]),S=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`,te),disabled:v,children:S?(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===ee;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),()=>x(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=S(e=>e.setEditorPreset),a=S(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 ne({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=S(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=S(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:te[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(`
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 ee,h as x,ht as te,j as S,l as ne,m as C,n as w,o as re,s as ie,u as ae,wt as T}from"./useAppGlobalState-B6yOUSp4.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-CwUFtQGR.js";import{a as ue,l as de,n as fe,o as pe}from"./beacon-alias-k72gNh9f.js";import{a as me,i as he,n as ge,o as _e,t as ve}from"./copyFeedbackStore-Bw_-4aam.js";import{a as ye,i as P,n as be,o as xe,r as Se,t as Ce}from"./select-DoKKeQr6.js";import{t as we}from"./info-DC1K4zUR.js";import{c as Te,r as Ee,s as De}from"./contextWindow-C-20_tVh.js";import{t as Oe}from"./monitor-BnslMj28.js";import{t as ke}from"./pencil-CT-2s_oA.js";import{t as Ae}from"./plus-BEiLnjKx.js";import{t as je}from"./refresh-cw-Z4F-mVpF.js";import{t as Me}from"./search-D-PyMvIQ.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-BL2w91DB.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-DpluAhJm.js";import{a as dt,c as ft,o as pt,s as mt,t as F}from"./segmented-control-BSVd0-R_.js";import{d as ht,f as I,i as gt,n as L,r as _t,s as vt}from"./log-CJGZbJ9_.js";import{t as R}from"./input-_et6sDdl.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-BgLKcwVW.js";import{M as _n,N as vn,iu as yn,j as bn,r as xn,ru as Sn}from"./useTheme-BH9ZneWq.js";import{t as Cn}from"./runDetached-eg1AfjiJ.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-CxHXOC78.js";import{a as An,n as jn}from"./state-mark-vOaDe8bG.js";import{n as Mn,t as Nn}from"./formatDuration-BbWTR_M_.js";import{n as Pn}from"./cronJobsStore-CHZ3jprN.js";import{Jt as Fn,bt as In,ln as Ln,pn as Rn,vt as zn,yt as Bn}from"./index-BLMXLYEb.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-BRFYC5UH.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-CBdJ9FND.js";import{t as cr}from"./settings-header-button-DuU-Cs7B.js";import{t as lr}from"./InboundHandlerFields-UbdPgHQ5.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),ee=Ki(h),x=(0,V.useCallback)(async e=>{await o(e)},[o]),te=(0,V.useCallback)(async()=>{await c()},[c]),S=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`,te),disabled:v,children:S?(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===ee;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),()=>x(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=S(e=>e.setEditorPreset),a=S(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 ne({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=S(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=S(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:te[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
2
  `),envText:Object.entries(e.env).map(([e,t])=>`${e}=${t}`).join(`
3
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
4
  `)}}function Do(e,t,n){let r={};for(let i of e.split(`
@@ -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-OB3PAWPO-zund-gx-.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{t as a}from"./BoardsPage-CcEgSKEH.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};
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-DYLH4CnT.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};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{n}from"./chunk-OB3PAWPO-zund-gx-.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{f as i,h as a,l as o,m as s}from"./pendingActionsStore-BEJnZIRD.js";import{o as c}from"./beacon-alias-DxONetqC.js";import{n as l}from"./code-xml-BfYZcKk2.js";import{A as u,B as d,E as f,F as p,N as m,P as h,S as g,_,b as v,g as y,i as b,j as x,k as S,m as ee,t as C,w as te,x as ne,y as re}from"./FilePreviewSheet-DK4JlQ4b.js";import{n as ie,t as ae}from"./file-plus-corner-DWHF_kbn.js";import{c as oe,l as se,r as ce,s as le}from"./contextWindow-pvBJBrsH.js";import{t as ue}from"./pencil-41SXT97L.js";import{t as w}from"./search-BabRSZmb.js";import{t as de}from"./terminal-uWEJ91yR.js";import{g as fe}from"./timer.adapter-BX7ibpTi.js";import{f as pe,i as T,m as me,n as he,p as E,r as ge,t as _e}from"./log-DxnWb_y2.js";import{n as ve,t as ye}from"./createScopedStore-Ba9K_10X.js";import{ru as be}from"./useTheme-CuVmsdqy.js";import{c as xe,n as Se,s as D}from"./pathUtils-DTWwEzHK.js";import{_ as Ce,c as we,h as Te,i as Ee,m as De,n as Oe,s as ke}from"./state-mark-BoV1BBc0.js";import{t as Ae}from"./formatDuration-BbWTR_M_.js";import{c as je,s as Me,u as Ne}from"./tools-B59RcrVm.js";var Pe={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Pe.node;var Fe=a(Pe),Ie={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Ie.node;var Le=a(Ie),Re={name:`check-line`,size:24,node:[[`path`,{d:`M20 4L9 15`,key:`1qkx8z`}],[`path`,{d:`M21 19L3 19`,key:`100sma`}],[`path`,{d:`M9 15L4 10`,key:`9zxff7`}]]};Re.node;var O=a(Re),ze={name:`file-x`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]};ze.node;var Be=a(ze),Ve={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};Ve.node;var k=a(Ve),He={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};He.node;var Ue=a(He),We={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};We.node;var Ge=a(We),Ke={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};Ke.node;var A=a(Ke),j={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};j.node;var qe=a(j),M={name:`square-x`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-square`]};M.node;var N=a(M),Je={name:`toy-brick`,size:24,node:[[`rect`,{width:`18`,height:`12`,x:`3`,y:`8`,rx:`1`,key:`158fvp`}],[`path`,{d:`M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3`,key:`s0042v`}],[`path`,{d:`M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3`,key:`9wmeh2`}]]};Je.node;var Ye=a(Je),Xe={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Xe.node;var P=a(Xe),Ze={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Ze.node;var Qe=a(Ze);function $e(e){return e.kind===`tool`}function F(e){return new Date(e).toISOString()}function et(e){let{_id:t,createdAt:n,...r}=e;return{...r,id:t,timestamp:F(n)}}function tt(e){let{_id:t,createdAt:n,debugRaw:r,...i}=e;return{...i,id:t,timestamp:F(n)}}function nt(e){return{...rt(e),kind:`unknown`,json:JSON.stringify(e,null,2)}}function rt(e){return{id:e._id,messageId:e.messageId,timestamp:F(e.createdAt),hidden:e.hidden}}var it=`/.claude/plans/`;function at(e){return e.includes(it)&&e.endsWith(`.md`)}function ot(e,t){if(e.toolKind!==`exit_plan_mode`)return e.toolKind===`write_file`&&at(e.input.filePath)?e.input.content:t}function st(e,t){return e.toolKind===`exit_plan_mode`&&!e.input.plan&&t?{...e.input,plan:t}:e.input}function ct(e,t){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:`tool`,toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:st(e.tool,t),timestamp:F(e.createdAt)}}function lt(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).tool_use_result??void 0}catch{return}if(t!==void 0&&typeof t!=`number`&&typeof t!=`boolean`)return t}function I(e){return typeof e==`number`?e:void 0}function L(e){return typeof e==`string`?e:void 0}function ut(e){if(e===void 0||!be(e))return;let t=e,n={readCount:I(t.readCount),searchCount:I(t.searchCount),bashCount:I(t.bashCount),editFileCount:I(t.editFileCount),linesAdded:I(t.linesAdded),linesRemoved:I(t.linesRemoved),otherToolCount:I(t.otherToolCount)};return Object.values(n).some(e=>e!==void 0)?n:void 0}function dt(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).toolUseResult}catch{return}if(t===void 0||!be(t))return;let n=t,r={agentId:L(n.agentId),agentType:L(n.agentType),status:L(n.status),totalTokens:I(n.totalTokens),totalDurationMs:I(n.totalDurationMs),totalToolUseCount:I(n.totalToolUseCount),toolStats:ut(n.toolStats),content:L(n.content)};return r.agentId!==void 0||r.agentType!==void 0||r.totalTokens!==void 0||r.totalDurationMs!==void 0||r.status!==void 0?r:void 0}function ft(e){let t=new Map,n=[],r;for(let i of e)switch(i.kind){case`user_prompt`:case`account_info`:case`assistant_text`:case`assistant_thinking`:case`api_error`:case`policy_refusal`:case`status`:case`context_window_updated`:case`compact_boundary`:case`compact_summary`:case`context_cleared`:case`interrupted`:case`memory_loaded`:case`auto_continue_prompt`:case`pending_tool_request`:case`cron_armed`:case`cron_command_error`:case`cron_run`:case`cron_run_skipped`:case`cron_list`:case`cron_job_change`:case`webhook_delivery`:case`inbound_delivery`:case`loop_disarmed`:n.push(tt(i));break;case`system_init`:n.push(et(i));break;case`tool_call`:{let e=ct(i,r);r=ot(i.tool,r),t.set(i.tool.toolId,{hydrated:e,normalized:i.tool}),$e(e)&&n.push(e);break}case`tool_result`:{let e=t.get(i.toolId);if(e){let t=Me.has(e.normalized.toolKind)?lt(i)??i.content:i.content;e.normalized.toolKind===`subagent_task`?e.hydrated.result=dt(i):e.hydrated.result=je(e.normalized,oe(t)),e.hydrated.rawResult=t,e.hydrated.isError=i.isError,i.persisted&&(e.hydrated.persisted=i.persisted)}break}case`result`:n.push({...rt(i),kind:`result`,success:!i.isError,cancelled:i.subtype===`cancelled`,result:i.result,durationMs:i.durationMs,costUsd:i.costUsd,codexErrorInfo:i.codexErrorInfo});break;case`tool_request_resolved`:break;default:n.push(nt(i))}return n}var R={key:`other`,singular:`tool call`,plural:`tool calls`},z={key:`task`,singular:`task update`,plural:`task updates`},pt={read_file:{key:`read`,singular:`read`,plural:`reads`},edit_file:{key:`edit`,singular:`edit`,plural:`edits`},write_file:{key:`write`,singular:`write`,plural:`writes`},delete_file:{key:`delete`,singular:`delete`,plural:`deletes`},bash:{key:`bash`,singular:`command`,plural:`commands`},grep:{key:`grep`,singular:`search`,plural:`searches`},glob:{key:`glob`,singular:`glob`,plural:`globs`},subagent_task:{key:`task`,singular:`agent`,plural:`agents`},web_search:{key:`websearch`,singular:`web search`,plural:`web searches`},skill:{key:`skill`,singular:`skill`,plural:`skills`},todo_write:{key:`todo`,singular:`todo update`,plural:`todo updates`},task_create:z,task_update:z,task_get:z,task_list:z,ask_user_question:R,exit_plan_mode:R,mcp_generic:R,beacon:R,offer_download:R,preview_file:R,image_generation:R,image_view:R,workflow:R,unknown_tool:R};function mt(e){return pt[e]}var B=Ye,ht={read_file:d,edit_file:ie,write_file:ae,delete_file:Be,bash:de,grep:w,glob:w,web_search:w,subagent_task:P,skill:qe,todo_write:O,task_create:O,task_update:O,task_get:O,task_list:O,ask_user_question:A,exit_plan_mode:Ge,image_view:Ue,workflow:k,mcp_generic:B,beacon:B,offer_download:B,preview_file:B,image_generation:B,unknown_tool:B},gt={Task:se,TaskOutput:se,Delete:Be,NotebookEdit:ue,WebFetch:Fe,KillShell:N,TaskStop:N,EnterPlanMode:Ge};function _t(e){return e.toolKind===`unknown_tool`?gt[e.toolName]??B:ht[e.toolKind]}function vt(e){return _t(Ne({toolName:e,toolId:``,input:{}}))}function yt(e,t){switch(e.toolKind){case`skill`:return e.input.skill;case`glob`:return`Search files ${e.input.pattern===`**/*`?`in all directories`:`matching ${e.input.pattern}`}`;case`grep`:return e.input.outputMode===`count`?`Count \`${e.input.pattern}\` occurrences`:e.input.outputMode===`content`?`Find \`${e.input.pattern}\` in text`:`Find \`${e.input.pattern}\` in files`;case`bash`:return e.input.description||(e.input.command?Ee(e.input.command):`Bash`);case`web_search`:return e.input.query||`Web Search`;case`read_file`:return`Read ${D(e.input.filePath,t)}`;case`image_view`:return`View ${D(e.input.path,t)||e.input.path}`;case`write_file`:return`Write ${D(e.input.filePath,t)}`;case`edit_file`:return`Edit ${D(e.input.filePath,t)}`;case`delete_file`:return`Delete ${D(e.input.filePath,t)}`;case`mcp_generic`:return`${ke(e.input.tool)} from ${ke(e.input.server)}`;case`beacon`:return e.input.beaconId?`Beacon ${e.input.beaconId}: ${e.input.summary}`:e.input.summary;case`subagent_task`:return e.input.subagentType||e.toolName;case`workflow`:return e.input.name??`Workflow`;case`ask_user_question`:case`exit_plan_mode`:case`todo_write`:case`task_create`:case`task_update`:case`task_get`:case`task_list`:case`offer_download`:case`preview_file`:case`image_generation`:case`unknown_tool`:return e.toolName}}var bt=40;function V(e){return we(e,bt)}function H(e,t,n,r){let i=D(n,r);return i?`${e} ${V(i)}`:t}function xt(e,t){switch(e.toolKind){case`bash`:{let t=e.input.description||(e.input.command?Ee(e.input.command):``);return t?`$ ${V(t)}`:`running bash...`}case`read_file`:return H(`reading`,`reading file...`,e.input.filePath,t);case`write_file`:return H(`writing`,`writing file...`,e.input.filePath,t);case`edit_file`:return H(`editing`,`editing file...`,e.input.filePath,t);case`delete_file`:return H(`deleting`,`deleting file...`,e.input.filePath,t);case`glob`:return e.input.pattern?`globbing ${V(e.input.pattern)}`:`globbing...`;case`grep`:return e.input.pattern?`grepping ${V(e.input.pattern)}`:`grepping...`;case`web_search`:return e.input.query?`searching: ${V(e.input.query)}`:`searching web...`;case`skill`:return e.input.skill?`skill ${V(e.input.skill)}`:`running skill...`;case`todo_write`:return`updating todos...`;case`task_create`:return`creating task...`;case`task_update`:return`updating task...`;case`task_get`:case`task_list`:return`reading tasks...`;case`subagent_task`:return e.input.subagentType?`delegating ${V(e.input.subagentType)}`:`delegating...`;case`ask_user_question`:return`asking...`;case`exit_plan_mode`:return`presenting plan...`;case`offer_download`:return`preparing download...`;case`image_generation`:return`generating image...`;case`image_view`:return`viewing image...`;case`mcp_generic`:return V(`${e.input.server}.${e.input.tool}`);case`unknown_tool`:return`running ${V(e.toolName)}`;case`preview_file`:case`beacon`:case`workflow`:return`running...`}}var U=e(t(),1),W=e(r(),1),St=(0,U.memo)(({message:e})=>(0,W.jsx)(`div`,{className:`text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4`,children:b(e.text)})),Ct=(0,U.memo)(({message:e})=>(0,W.jsx)(`div`,{className:`px-0.5 w-full max-w-[70ch]`,children:(0,W.jsx)(y,{content:e.text})})),wt=({children:e,className:t,animate:n=!0,...r})=>(0,W.jsx)(`span`,{className:i(`mx-auto max-w-md text-foreground/60`,n&&`animate-shiny-pulse`,t),...r,children:e});function Tt(e){let t=e.split(`
1
+ import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{n}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{f as i,h as a,l as o,m as s}from"./pendingActionsStore-CwUFtQGR.js";import{o as c}from"./beacon-alias-k72gNh9f.js";import{n as l}from"./code-xml-0ltzEz2X.js";import{A as u,B as d,E as f,F as p,N as m,P as h,S as g,_,b as v,g as y,i as b,j as x,k as S,m as ee,t as C,w as te,x as ne,y as re}from"./FilePreviewSheet-NvVL2JG6.js";import{n as ie,t as ae}from"./file-plus-corner-DMWk1Kix.js";import{c as oe,l as se,r as ce,s as le}from"./contextWindow-C-20_tVh.js";import{t as ue}from"./pencil-CT-2s_oA.js";import{t as w}from"./search-D-PyMvIQ.js";import{t as de}from"./terminal-CCsdLV7K.js";import{g as fe}from"./timer.adapter-DpluAhJm.js";import{f as pe,i as T,m as me,n as he,p as E,r as ge,t as _e}from"./log-CJGZbJ9_.js";import{n as ve,t as ye}from"./createScopedStore-L_qmwTAu.js";import{ru as be}from"./useTheme-BH9ZneWq.js";import{c as xe,n as Se,s as D}from"./pathUtils-DTWwEzHK.js";import{_ as Ce,c as we,h as Te,i as Ee,m as De,n as Oe,s as ke}from"./state-mark-vOaDe8bG.js";import{t as Ae}from"./formatDuration-BbWTR_M_.js";import{c as je,s as Me,u as Ne}from"./tools-Bp5T17Iw.js";var Pe={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Pe.node;var Fe=a(Pe),Ie={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Ie.node;var Le=a(Ie),Re={name:`check-line`,size:24,node:[[`path`,{d:`M20 4L9 15`,key:`1qkx8z`}],[`path`,{d:`M21 19L3 19`,key:`100sma`}],[`path`,{d:`M9 15L4 10`,key:`9zxff7`}]]};Re.node;var O=a(Re),ze={name:`file-x`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]};ze.node;var Be=a(ze),Ve={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};Ve.node;var k=a(Ve),He={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};He.node;var Ue=a(He),We={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};We.node;var Ge=a(We),Ke={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};Ke.node;var A=a(Ke),j={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};j.node;var qe=a(j),M={name:`square-x`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-square`]};M.node;var N=a(M),Je={name:`toy-brick`,size:24,node:[[`rect`,{width:`18`,height:`12`,x:`3`,y:`8`,rx:`1`,key:`158fvp`}],[`path`,{d:`M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3`,key:`s0042v`}],[`path`,{d:`M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3`,key:`9wmeh2`}]]};Je.node;var Ye=a(Je),Xe={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Xe.node;var P=a(Xe),Ze={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Ze.node;var Qe=a(Ze);function $e(e){return e.kind===`tool`}function F(e){return new Date(e).toISOString()}function et(e){let{_id:t,createdAt:n,...r}=e;return{...r,id:t,timestamp:F(n)}}function tt(e){let{_id:t,createdAt:n,debugRaw:r,...i}=e;return{...i,id:t,timestamp:F(n)}}function nt(e){return{...rt(e),kind:`unknown`,json:JSON.stringify(e,null,2)}}function rt(e){return{id:e._id,messageId:e.messageId,timestamp:F(e.createdAt),hidden:e.hidden}}var it=`/.claude/plans/`;function at(e){return e.includes(it)&&e.endsWith(`.md`)}function ot(e,t){if(e.toolKind!==`exit_plan_mode`)return e.toolKind===`write_file`&&at(e.input.filePath)?e.input.content:t}function st(e,t){return e.toolKind===`exit_plan_mode`&&!e.input.plan&&t?{...e.input,plan:t}:e.input}function ct(e,t){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:`tool`,toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:st(e.tool,t),timestamp:F(e.createdAt)}}function lt(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).tool_use_result??void 0}catch{return}if(t!==void 0&&typeof t!=`number`&&typeof t!=`boolean`)return t}function I(e){return typeof e==`number`?e:void 0}function L(e){return typeof e==`string`?e:void 0}function ut(e){if(e===void 0||!be(e))return;let t=e,n={readCount:I(t.readCount),searchCount:I(t.searchCount),bashCount:I(t.bashCount),editFileCount:I(t.editFileCount),linesAdded:I(t.linesAdded),linesRemoved:I(t.linesRemoved),otherToolCount:I(t.otherToolCount)};return Object.values(n).some(e=>e!==void 0)?n:void 0}function dt(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).toolUseResult}catch{return}if(t===void 0||!be(t))return;let n=t,r={agentId:L(n.agentId),agentType:L(n.agentType),status:L(n.status),totalTokens:I(n.totalTokens),totalDurationMs:I(n.totalDurationMs),totalToolUseCount:I(n.totalToolUseCount),toolStats:ut(n.toolStats),content:L(n.content)};return r.agentId!==void 0||r.agentType!==void 0||r.totalTokens!==void 0||r.totalDurationMs!==void 0||r.status!==void 0?r:void 0}function ft(e){let t=new Map,n=[],r;for(let i of e)switch(i.kind){case`user_prompt`:case`account_info`:case`assistant_text`:case`assistant_thinking`:case`api_error`:case`policy_refusal`:case`status`:case`context_window_updated`:case`compact_boundary`:case`compact_summary`:case`context_cleared`:case`interrupted`:case`memory_loaded`:case`auto_continue_prompt`:case`pending_tool_request`:case`cron_armed`:case`cron_command_error`:case`cron_run`:case`cron_run_skipped`:case`cron_list`:case`cron_job_change`:case`webhook_delivery`:case`inbound_delivery`:case`loop_disarmed`:n.push(tt(i));break;case`system_init`:n.push(et(i));break;case`tool_call`:{let e=ct(i,r);r=ot(i.tool,r),t.set(i.tool.toolId,{hydrated:e,normalized:i.tool}),$e(e)&&n.push(e);break}case`tool_result`:{let e=t.get(i.toolId);if(e){let t=Me.has(e.normalized.toolKind)?lt(i)??i.content:i.content;e.normalized.toolKind===`subagent_task`?e.hydrated.result=dt(i):e.hydrated.result=je(e.normalized,oe(t)),e.hydrated.rawResult=t,e.hydrated.isError=i.isError,i.persisted&&(e.hydrated.persisted=i.persisted)}break}case`result`:n.push({...rt(i),kind:`result`,success:!i.isError,cancelled:i.subtype===`cancelled`,result:i.result,durationMs:i.durationMs,costUsd:i.costUsd,codexErrorInfo:i.codexErrorInfo});break;case`tool_request_resolved`:break;default:n.push(nt(i))}return n}var R={key:`other`,singular:`tool call`,plural:`tool calls`},z={key:`task`,singular:`task update`,plural:`task updates`},pt={read_file:{key:`read`,singular:`read`,plural:`reads`},edit_file:{key:`edit`,singular:`edit`,plural:`edits`},write_file:{key:`write`,singular:`write`,plural:`writes`},delete_file:{key:`delete`,singular:`delete`,plural:`deletes`},bash:{key:`bash`,singular:`command`,plural:`commands`},grep:{key:`grep`,singular:`search`,plural:`searches`},glob:{key:`glob`,singular:`glob`,plural:`globs`},subagent_task:{key:`task`,singular:`agent`,plural:`agents`},web_search:{key:`websearch`,singular:`web search`,plural:`web searches`},skill:{key:`skill`,singular:`skill`,plural:`skills`},todo_write:{key:`todo`,singular:`todo update`,plural:`todo updates`},task_create:z,task_update:z,task_get:z,task_list:z,ask_user_question:R,exit_plan_mode:R,mcp_generic:R,beacon:R,offer_download:R,preview_file:R,image_generation:R,image_view:R,workflow:R,unknown_tool:R};function mt(e){return pt[e]}var B=Ye,ht={read_file:d,edit_file:ie,write_file:ae,delete_file:Be,bash:de,grep:w,glob:w,web_search:w,subagent_task:P,skill:qe,todo_write:O,task_create:O,task_update:O,task_get:O,task_list:O,ask_user_question:A,exit_plan_mode:Ge,image_view:Ue,workflow:k,mcp_generic:B,beacon:B,offer_download:B,preview_file:B,image_generation:B,unknown_tool:B},gt={Task:se,TaskOutput:se,Delete:Be,NotebookEdit:ue,WebFetch:Fe,KillShell:N,TaskStop:N,EnterPlanMode:Ge};function _t(e){return e.toolKind===`unknown_tool`?gt[e.toolName]??B:ht[e.toolKind]}function vt(e){return _t(Ne({toolName:e,toolId:``,input:{}}))}function yt(e,t){switch(e.toolKind){case`skill`:return e.input.skill;case`glob`:return`Search files ${e.input.pattern===`**/*`?`in all directories`:`matching ${e.input.pattern}`}`;case`grep`:return e.input.outputMode===`count`?`Count \`${e.input.pattern}\` occurrences`:e.input.outputMode===`content`?`Find \`${e.input.pattern}\` in text`:`Find \`${e.input.pattern}\` in files`;case`bash`:return e.input.description||(e.input.command?Ee(e.input.command):`Bash`);case`web_search`:return e.input.query||`Web Search`;case`read_file`:return`Read ${D(e.input.filePath,t)}`;case`image_view`:return`View ${D(e.input.path,t)||e.input.path}`;case`write_file`:return`Write ${D(e.input.filePath,t)}`;case`edit_file`:return`Edit ${D(e.input.filePath,t)}`;case`delete_file`:return`Delete ${D(e.input.filePath,t)}`;case`mcp_generic`:return`${ke(e.input.tool)} from ${ke(e.input.server)}`;case`beacon`:return e.input.beaconId?`Beacon ${e.input.beaconId}: ${e.input.summary}`:e.input.summary;case`subagent_task`:return e.input.subagentType||e.toolName;case`workflow`:return e.input.name??`Workflow`;case`ask_user_question`:case`exit_plan_mode`:case`todo_write`:case`task_create`:case`task_update`:case`task_get`:case`task_list`:case`offer_download`:case`preview_file`:case`image_generation`:case`unknown_tool`:return e.toolName}}var bt=40;function V(e){return we(e,bt)}function H(e,t,n,r){let i=D(n,r);return i?`${e} ${V(i)}`:t}function xt(e,t){switch(e.toolKind){case`bash`:{let t=e.input.description||(e.input.command?Ee(e.input.command):``);return t?`$ ${V(t)}`:`running bash...`}case`read_file`:return H(`reading`,`reading file...`,e.input.filePath,t);case`write_file`:return H(`writing`,`writing file...`,e.input.filePath,t);case`edit_file`:return H(`editing`,`editing file...`,e.input.filePath,t);case`delete_file`:return H(`deleting`,`deleting file...`,e.input.filePath,t);case`glob`:return e.input.pattern?`globbing ${V(e.input.pattern)}`:`globbing...`;case`grep`:return e.input.pattern?`grepping ${V(e.input.pattern)}`:`grepping...`;case`web_search`:return e.input.query?`searching: ${V(e.input.query)}`:`searching web...`;case`skill`:return e.input.skill?`skill ${V(e.input.skill)}`:`running skill...`;case`todo_write`:return`updating todos...`;case`task_create`:return`creating task...`;case`task_update`:return`updating task...`;case`task_get`:case`task_list`:return`reading tasks...`;case`subagent_task`:return e.input.subagentType?`delegating ${V(e.input.subagentType)}`:`delegating...`;case`ask_user_question`:return`asking...`;case`exit_plan_mode`:return`presenting plan...`;case`offer_download`:return`preparing download...`;case`image_generation`:return`generating image...`;case`image_view`:return`viewing image...`;case`mcp_generic`:return V(`${e.input.server}.${e.input.tool}`);case`unknown_tool`:return`running ${V(e.toolName)}`;case`preview_file`:case`beacon`:case`workflow`:return`running...`}}var U=e(t(),1),W=e(r(),1),St=(0,U.memo)(({message:e})=>(0,W.jsx)(`div`,{className:`text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4`,children:b(e.text)})),Ct=(0,U.memo)(({message:e})=>(0,W.jsx)(`div`,{className:`px-0.5 w-full max-w-[70ch]`,children:(0,W.jsx)(y,{content:e.text})})),wt=({children:e,className:t,animate:n=!0,...r})=>(0,W.jsx)(`span`,{className:i(`mx-auto max-w-md text-foreground/60`,n&&`animate-shiny-pulse`,t),...r,children:e});function Tt(e){let t=e.split(`
2
2
  `),n=/^\s*(\d+)→(.*)$/;return t.map(e=>{let t=e.match(n);return t?{lineNumber:parseInt(t[1],10),content:t[2]}:{lineNumber:null,content:e}})}function Et(e){return e.replace(/<[^>]+>/g,``)}function Dt(e,t){let n=e.split(`
3
3
  `),r=t.split(`
4
4
  `);return At(kt(n,r,Ot(n,r)))}function Ot(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)i[a][n]=e[a-1]===t[n-1]?i[a-1][n-1]+1:Math.max(i[a-1][n],i[a][n-1]);return i}function kt(e,t,n){let r=[],i=e.length,a=t.length;for(;i>0||a>0;)i>0&&a>0&&e[i-1]===t[a-1]?(r.push({type:`context`,text:e[i-1],oldIdx:i,newIdx:a}),i--,a--):a>0&&(i===0||n[i][a-1]>=n[i-1][a])?(r.push({type:`added`,text:t[a-1],oldIdx:i,newIdx:a}),a--):(r.push({type:`removed`,text:e[i-1],oldIdx:i,newIdx:a}),i--);return r.reverse()}function At(e){return e.map(e=>{let t;return t=e.type===`removed`?`-`:e.type===`added`?`+`:` `,{type:e.type,content:`${t}${e.text}`}})}function G({content:e,isDiff:t=!1,oldString:n,newString:r}){let i=(0,U.useMemo)(()=>t&&n!==void 0&&r!==void 0?Dt(n,r):[],[t,n,r]),a=(0,U.useMemo)(()=>t?[]:Tt(e),[e,t]),o=(0,U.useMemo)(()=>a.some(e=>e.lineNumber!==null),[a]);return t&&i.length>0?(0,W.jsx)(`div`,{className:`my-1 rounded-lg border border-border overflow-hidden`,children:(0,W.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,W.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,W.jsx)(`tbody`,{children:i.map((e,t)=>{let n;n=e.type===`removed`?`bg-destructive/10 dark:bg-destructive/15`:e.type===`added`?`bg-success/10 dark:bg-success/15`:``;let r;r=e.type===`removed`?`text-destructive`:e.type===`added`?`text-success`:`text-foreground`;let i;i=e.type===`removed`?`text-destructive/50`:e.type===`added`?`text-success/50`:`text-muted-foreground/50`;let a;return a=e.type===`removed`?`-`:e.type===`added`?`+`:` `,(0,W.jsxs)(`tr`,{className:n,children:[(0,W.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${i}`,children:a}),(0,W.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all ${r}`,children:e.content.slice(1)})]},t)})})})})}):(0,W.jsx)(`div`,{className:`my-1 rounded-lg border border-border overflow-hidden`,children:(0,W.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,W.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,W.jsx)(`tbody`,{children:a.map((e,t)=>(0,W.jsxs)(`tr`,{children:[o&&(0,W.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right`,children:e.lineNumber===null?``:e.lineNumber}),(0,W.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all text-foreground`,children:Et(e.content)})]},t))})})})})}var jt=new Map;function K(e,t){if(!t)return;let n=jt.get(e);return n===void 0?void 0:t(n)}function Mt(e){return{state:e===void 0?`idle`:`ready`,data:e===void 0?null:e,error:null}}function Nt(e){let{cacheKey:t,enabled:n,ref:r,fetcher:i,rootMargin:a,fromCache:o}=e,s=K(t,o),c=(0,U.useMemo)(()=>me(()=>Mt(K(t,o))),[t,o]),l=E(c,e=>e.state),u=E(c,e=>e.data),d=E(c,e=>e.error),f=(0,U.useRef)(t),p=(0,U.useRef)(null),m=(0,U.useRef)(t);return(0,U.useEffect)(()=>{m.current=t},[t]),(0,U.useEffect)(()=>{f.current!==t&&(f.current=t,c.setState(Mt(K(t,o))))},[t,o,c]),(0,U.useEffect)(()=>{if(!n||s!==void 0)return;let e=r.current;if(!e||typeof IntersectionObserver>`u`)return;let o=!1,l=t,u=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;if(u.disconnect(),o)return;let e=new AbortController;p.current=e,c.setState({state:`loading`}),i(e.signal).then(e=>{o||m.current!==l||(jt.set(l,e),c.setState({data:e,state:`ready`}))}).catch(T(t=>{o||e.signal.aborted||m.current!==l||c.setState({error:t,state:`error`})}));break}},{rootMargin:a??`200px`});return u.observe(e),()=>{o=!0,u.disconnect(),p.current?.abort(),p.current=null}},[s,t,n,r,i,a,c]),(0,U.useMemo)(()=>({state:l,data:u,error:d}),[l,u,d])}function Pt(e){return typeof e==`string`?e:void 0}function Ft({source:e,onOpen:t,variant:n}){let r=m(e),{iconKind:i,friendlyType:a,sizeLabel:o}=r;return i===`image`?(0,W.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`touch-manipulation overflow-hidden rounded-xl border border-border bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:(0,W.jsx)(`img`,{src:e.contentUrl,alt:e.altText??e.displayName,loading:`lazy`,className:`max-h-64 w-auto max-w-full object-contain`})}):n===`expanded`&&(i===`text`||i===`code`||i===`markdown`||i===`json`||i===`table`)?(0,W.jsx)(It,{source:e,onOpen:t,friendlyType:a,sizeLabel:o}):(0,W.jsx)(_,{attachment:ee(e),onClick:t,meta:(0,W.jsx)(re,{description:r}),ariaLabel:p(`Preview`,e.displayName,r)})}var It=function({source:e,onOpen:t,friendlyType:n,sizeLabel:r}){let i=(0,U.useRef)(null),a=e.contentUrl,o=(0,U.useCallback)(async e=>{let t=await h(a,4096);if(e.aborted)throw Error(`aborted`);return t.content.slice(0,200)},[a]),s=Nt({ref:i,enabled:!0,cacheKey:`snippet:${e.id}|${e.contentUrl}|${e.size??0}`,fetcher:o,fromCache:Pt}),c=s.state===`ready`&&typeof s.data==`string`?s.data:``;return(0,W.jsxs)(`button`,{ref:i,type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`flex w-full max-w-md flex-col items-start gap-1 rounded-xl border border-border bg-background p-3 text-left hover:bg-accent/40`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.displayName}),(0,W.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n,r?` · ${r}`:``]}),c?(0,W.jsx)(`pre`,{className:`line-clamp-3 max-h-16 w-full whitespace-pre-wrap break-words text-xs text-muted-foreground`,children:c}):null]})},q=x(`ImageViewMessage`);function Lt({toolId:e,path:t,contentUrl:n,mimeType:r}){let i=q.useScopedStore(e=>e.value),a=q.useScopedStore(e=>e.set),o=Se(t);if(!n)return(0,W.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/20 px-3 py-2 text-sm text-muted-foreground`,children:t});let s={id:`image-view-${e}`,contentUrl:n,displayName:o,fileName:o,relativePath:t,mimeType:r,origin:`image_view`};return(0,W.jsxs)(`figure`,{className:`flex flex-col gap-2`,"data-testid":`image-view`,children:[(0,W.jsx)(Ft,{source:s,onOpen:()=>a(!0),variant:`expanded`}),(0,W.jsx)(C,{source:i?s:null,open:i,onOpenChange:a})]})}function Rt(e){return(0,W.jsx)(q.Provider,{init:!1,children:(0,W.jsx)(Lt,{...e})})}function zt({status:e}){return(0,W.jsx)(Oe,{tone:Te(e),label:De(e)})}function Bt(){return(0,W.jsx)(`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:`started…`})}function Vt({name:e,description:t,run:n}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,W.jsx)(k,{className:`size-4 text-muted-icon shrink-0`}),(0,W.jsxs)(`div`,{className:`flex flex-1 items-center gap-2 min-w-0 overflow-hidden`,children:[(0,W.jsx)(`span`,{className:`font-medium text-foreground/80 text-sm truncate`,children:e??`Workflow`}),t&&(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:t}),n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(zt,{status:n.status}),n.agentCount!=null&&n.agentCount>0&&(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[n.agentCount,` agents`]})]}):(0,W.jsx)(Bt,{})]})]})}var J={serverOverloaded:{failureClass:`transient`,shape:`string`,describe:e=>`${e} is temporarily at capacity. Retry, or switch to another model.`},internalServerError:{failureClass:`transient`,shape:`string`,describe:e=>`${e} hit a server-side error. Retrying usually clears it.`},httpConnectionFailed:{failureClass:`transient`,shape:`object`,describe:()=>`Could not reach the model provider. Check your connection, then retry.`},responseStreamConnectionFailed:{failureClass:`transient`,shape:`object`,describe:()=>`The response stream failed to connect. Retry to start a new stream.`},responseStreamDisconnected:{failureClass:`transient`,shape:`object`,describe:()=>`The response stream disconnected mid-turn. Retry to pick up from where it stopped.`},responseTooManyFailedAttempts:{failureClass:`transient`,shape:`object`,describe:e=>`${e} failed repeatedly while streaming. Retry, or switch to another model.`},usageLimitExceeded:{failureClass:`quota`,shape:`string`,describe:()=>`You have reached your Codex usage limit. Access returns when the limit window resets.`},sessionBudgetExceeded:{failureClass:`quota`,shape:`string`,describe:()=>`This session reached its configured token budget.`},unauthorized:{failureClass:`auth`,shape:`string`,describe:()=>"Codex rejected the credentials for this request. Re-authenticate with `codex login`."},contextWindowExceeded:{failureClass:`fatal`,shape:`string`,describe:e=>`The conversation no longer fits in ${e}'s context window. Start a new chat or compact this one.`},badRequest:{failureClass:`fatal`,shape:`string`,describe:()=>`Codex rejected the request as malformed.`},cyberPolicy:{failureClass:`fatal`,shape:`string`,describe:()=>`Codex declined this request under its usage policy.`},sandboxError:{failureClass:`fatal`,shape:`string`,describe:()=>`The Codex sandbox failed to run the requested command.`},threadRollbackFailed:{failureClass:`fatal`,shape:`string`,describe:()=>`Codex could not roll the conversation back to the requested point.`},activeTurnNotSteerable:{failureClass:`fatal`,shape:`object`,describe:()=>`The running turn cannot accept new input. Wait for it to finish, or stop it.`},other:{failureClass:`unknown`,shape:`string`,describe:null}};function Y(e){return Object.hasOwn(J,e)}function Ht(e,t){return J[e].shape===t}function Ut(e){if(e==null)return null;if(typeof e==`string`)return Y(e)&&Ht(e,`string`)?e:null;if(typeof e!=`object`)return null;let t=Object.keys(e);if(t.length!==1)return null;let[n]=t;return Y(n)&&Ht(n,`object`)?n:null}function Wt(e){return typeof e==`string`?Y(e)?e:null:Ut(e)}function Gt(e){let t=Wt(e);return t===null?`unknown`:J[t].failureClass}function Kt(e){return Gt(e)===`transient`}var qt=`The selected model`;function Jt(e,t){let n=Wt(e);if(n===null)return null;let r=J[n].describe;return r===null?null:r(t??qt)}var X=ye(`TranscriptActionCard`,()=>e=>({busyId:null,actionError:null,setBusyId:t=>e({busyId:t}),setActionError:t=>e({actionError:t})})),Yt={neutral:`border-border bg-card`,muted:`border-border/50 bg-card/50 opacity-75`,success:`border-emerald-500/30 bg-emerald-500/5`,error:`border-destructive/40 bg-destructive/5`},Xt={primary:`default`,secondary:`secondary`,ghost:`ghost`,destructive:`destructive`};function Zt(e){return(0,W.jsx)(X.Provider,{init:void 0,children:(0,W.jsx)(Qt,{...e})})}function Qt({title:e,description:t,body:n,errorMessage:r,tone:a=`neutral`,actions:s=[]}){let c=X.useScopedStore(e=>e.busyId),l=X.useScopedStore(e=>e.actionError),u=X.useScopedStoreApi(),d=(0,U.useCallback)(e=>{let t=u.getState();if(t.busyId)return;t.setActionError(null);let n;try{n=e.onClick()}catch(e){_e.error(`[transcript-action-card] sync click threw`,String(e)),u.getState().setActionError(he(e));return}n instanceof Promise&&(t.setBusyId(e.id),n.then(()=>u.getState().setBusyId(null),T(e=>{_e.error(`[transcript-action-card] async click rejected`,e.message),u.getState().setActionError(e.message),u.getState().setBusyId(null)})))},[u]),f=c!==null;return(0,W.jsxs)(`div`,{"data-focus-fallback-ignore":!0,className:i(`rounded-lg border px-4 py-3 text-sm space-y-2 transition-colors`,Yt[a]),children:[(0,W.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,W.jsxs)(`div`,{className:`space-y-1 min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`font-medium leading-tight`,children:e}),t?(0,W.jsx)(`div`,{className:`text-muted-foreground text-xs leading-snug`,children:t}):null]})}),n?(0,W.jsx)(`div`,{className:`text-xs leading-snug`,children:n}):null,r?(0,W.jsx)(`div`,{className:`text-destructive text-xs leading-snug`,children:r}):null,l?(0,W.jsx)(`div`,{className:`text-destructive text-xs leading-snug`,role:`alert`,children:l}):null,s.length>0?(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-1`,children:s.map(e=>{let t=c===e.id;return(0,W.jsxs)(o,{type:`button`,size:`sm`,variant:Xt[e.variant??`ghost`],disabled:e.disabled||f&&!t,pending:t||e.pending===!0,onClick:()=>d(e),className:`gap-1.5`,children:[e.icon,e.label]},e.id)})}):null]})}function $t(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h${r>0?` ${r}m`:``}`:r>0?`${r}m${i>0?` ${i}s`:``}`:`${i}s`}function en({durationMs:e,prefix:t=`Worked for`}){return e<=0?null:(0,W.jsxs)(S,{children:[t,` `,$t(e)]})}var Z=/\[([^\]]+)\]\(\/chat\/([0-9a-fA-F][0-9a-fA-F-]{7,})\)/g;function tn(e,t){let r=[],i=0,a=0;Z.lastIndex=0;for(let o=Z.exec(e);o!==null;o=Z.exec(e))o.index>i&&r.push(e.slice(i,o.index)),r.push((0,W.jsx)(n,{to:Ce(o[2]),className:t??`underline decoration-destructive/40 hover:decoration-destructive`,children:o[1]},`chat-link-${a++}`)),i=o.index+o[0].length;return i<e.length&&r.push(e.slice(i)),r.length===0?e:r}function nn({resultMessageId:e,body:t,onRetry:n}){let r=[{id:`retry`,label:`Retry`,variant:`primary`,onClick:(0,U.useCallback)(()=>n(e),[n,e])}];return(0,W.jsx)(`div`,{className:`mx-2 my-1`,children:(0,W.jsx)(Zt,{title:`Turn failed`,tone:`error`,body:t,actions:r})})}function rn({message:e,onRetry:t}){if(!e.success){let n=e.codexErrorInfo,r=(n?Jt(n,null):null)??e.result??``,i=r.trim().length>0,a=n!==void 0&&Kt(n),o=null;return a&&t?o=(0,W.jsx)(nn,{resultMessageId:e.id,body:r,onRetry:t}):i&&(o=(0,W.jsx)(`div`,{className:`px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm whitespace-pre-wrap`,children:tn(r)})),(0,W.jsxs)(W.Fragment,{children:[o,e.durationMs>0?(0,W.jsx)(en,{durationMs:e.durationMs,prefix:`Failed after`}):null]})}return(0,W.jsx)(en,{durationMs:e.durationMs})}var an=`<persisted-output>`,on=`</persisted-output>`,sn=RegExp(`${an}\\n?`,`g`),cn=RegExp(`\\n?${on}`,`g`);function ln(e){return e.replace(sn,``).replace(cn,``)}function un(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function dn({message:e,localPath:t,isRunning:n=!1}){if(e.kind===`tool`&&e.persisted){let t=ln(un(e.rawResult??``));return(0,W.jsxs)(`div`,{className:`animate-in fade-in-0 duration-200 rounded-md border border-border bg-muted/30 p-2 space-y-1 text-xs`,children:[(0,W.jsxs)(`div`,{className:`font-medium`,children:[e.toolName,`: output too large (`,c(e.persisted.originalSize),`) — saved to disk`]}),(0,W.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap overflow-hidden max-h-48`,children:t}),(0,W.jsxs)(`a`,{href:xe(e.persisted.filePath),className:`text-blue-500 hover:underline break-all`,target:`_blank`,rel:`noreferrer`,children:[`View full output (`,e.persisted.filePath,`)`]})]})}let r;switch(e.kind){case`assistant_text`:r=(0,W.jsx)(St,{message:e});break;case`assistant_thinking`:r=(0,W.jsx)(Ct,{message:e});break;case`tool`:r=(0,W.jsx)($,{message:e,isLoading:n,localPath:t});break;case`result`:r=(0,W.jsx)(rn,{message:e});break;default:return null}return(0,W.jsx)(`div`,{className:`animate-in fade-in-0 duration-200`,children:r})}var fn=(0,U.createContext)(null);function pn({children:e,value:t}){return(0,W.jsx)(fn.Provider,{value:t,children:e})}function mn(){return(0,U.useContext)(fn)}var hn=[],Q=ye(`SubagentTaskMessage`,()=>e=>({expanded:!1,loading:!1,loaded:!1,children:hn,error:null,setExpanded:t=>e({expanded:t}),setLoading:t=>e({loading:t}),setLoaded:t=>e({loaded:t}),setChildren:t=>e({children:t}),setError:t=>e({error:t})}));function gn(e,t){return t||e===`failed`||e===`error`?`destructive`:e===`in_progress`||e===`running`?`active`:`muted`}function _n(e){if(!e)return``;let t=[],n=(e,n,r)=>{e&&e>0&&t.push(`${e} ${e===1?n:r}`)};return n(e.readCount,`read`,`reads`),n(e.editFileCount,`edit`,`edits`),n(e.bashCount,`cmd`,`cmds`),n(e.searchCount,`search`,`searches`),n(e.otherToolCount,`tool`,`tools`),t.join(` · `)}function vn({subagentType:e,result:t,isError:n,localPath:r}){let a=e||`Agent`,o=gn(t?.status,n),c=_n(t?.toolStats),u=mn(),d=t?.agentId,f=!!(u&&d),p=Q.useScopedStore(e=>e.expanded),m=Q.useScopedStore(e=>e.loading),h=Q.useScopedStore(e=>e.loaded),g=Q.useScopedStore(e=>e.children),_=Q.useScopedStore(e=>e.error),v=Q.useScopedStore(e=>e.setExpanded),y=Q.useScopedStore(e=>e.setLoading),b=Q.useScopedStore(e=>e.setLoaded),x=Q.useScopedStore(e=>e.setChildren),S=Q.useScopedStore(e=>e.setError),ee=(0,U.useCallback)(()=>{if(!u||!d)return;let e=!p;v(e),e&&!h&&!m&&(y(!0),S(null),u(d).then(e=>{x(ft(e)),b(!0)}).catch(T(e=>S(e.message))).finally(()=>y(!1)))},[u,d,p,h,m,v,y,S,x,b]),C=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[f?(0,W.jsx)(l,{className:i(`size-4 text-muted-icon shrink-0 transition-transform`,p&&`rotate-90`),"aria-hidden":!0}):(0,W.jsx)(P,{className:`size-4 text-muted-icon shrink-0`}),(0,W.jsxs)(`div`,{className:`flex flex-1 items-center gap-2 min-w-0 overflow-hidden`,children:[(0,W.jsx)(`span`,{className:`font-medium text-foreground/80 text-sm truncate`,children:a}),t?.status&&(0,W.jsx)(Oe,{tone:o,label:t.status}),t?.totalTokens!=null&&t.totalTokens>0&&(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums`,children:[(0,W.jsx)(Le,{className:`size-3`,"aria-hidden":!0}),ce(t.totalTokens),` tokens`]}),t?.totalDurationMs!=null&&t.totalDurationMs>0&&(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:Ae(t.totalDurationMs)}),c&&(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums truncate`,children:c}),m&&(0,W.jsx)(s,{className:`size-3 animate-spin text-muted-foreground`,"aria-label":`Loading`})]})]});return f?(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:ee,"aria-expanded":p,className:`w-full text-left cursor-pointer`,children:C}),p&&(0,W.jsxs)(`div`,{className:`mt-2 ml-2 border-l-2 border-muted-foreground/20 pl-3 space-y-2`,children:[_&&(0,W.jsx)(`div`,{className:`text-xs text-destructive`,children:_}),!_&&h&&g.length===0&&(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No subagent activity recorded.`}),g.map(e=>(0,W.jsx)(dn,{message:e,localPath:r??``},e.id))]})]}):C}var yn=ve(Q,vn),bn=[],xn=pe()(e=>({byChat:{},setRuns:(t,n)=>e(e=>({byChat:{...e.byChat,[t]:n}}))}));function Sn(e){return t=>t.byChat[e]??bn}function Cn({images:e}){return(0,W.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,t)=>{let n=e.mimeType||`image/png`;return(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted/20`,children:(0,W.jsx)(`img`,{src:`data:${n};base64,${e.data}`,alt:`Read result ${t+1}`,className:`max-h-[50vh] w-full object-contain bg-background`})},`${n}:${t}`)})})}function wn(e){return e.type===`image`}function Tn({result:e,resultText:t}){let n=typeof e==`object`?(e.blocks??[]).filter(wn):[];return n.length===0?(0,W.jsx)(G,{content:t}):(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Image`}),(0,W.jsx)(`div`,{className:`mt-1`,children:(0,W.jsx)(Cn,{images:n})})]})}function En(e){return(0,W.jsxs)(`span`,{className:`flex items-center gap-2 w-full`,children:[(0,W.jsx)(`span`,{children:`Command`}),!!e.timeoutMs&&(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`timeout: `,String(e.timeoutMs),`ms`]}),!!e.runInBackground&&(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`background`})]})}function Dn(e){switch(e.toolKind){case`edit_file`:return(0,W.jsx)(G,{content:``,isDiff:!0,oldString:e.input.oldString,newString:e.input.newString});case`delete_file`:return(0,W.jsx)(G,{content:e.input.content});case`read_file`:case`write_file`:case`image_view`:return null;case`bash`:return(0,W.jsx)(g,{label:En(e.input),copyText:e.input.command,children:e.input.command});default:{let t=JSON.stringify(e.input,null,2);return(0,W.jsx)(g,{label:`Input`,copyText:t,children:t})}}}function On(e,t){let n=e.result!==void 0,r=!e.isError,i=n?(0,W.jsx)(g,{label:r?`Result`:`Error`,copyText:t,children:t}):null;switch(e.toolKind){case`read_file`:return n&&r?(0,W.jsx)(Tn,{result:e.result,resultText:t}):null;case`image_view`:return r?(0,W.jsx)(Rt,{toolId:e.toolId,path:e.input.path,contentUrl:e.input.contentUrl,mimeType:e.input.mimeType}):i;case`write_file`:return r?(0,W.jsx)(G,{content:e.input.content}):i;case`edit_file`:case`delete_file`:return r?null:i;default:return i}}function $({message:e,isLoading:t=!1,localPath:n,chatId:r=``}){let i=e.result===void 0&&t,a=xn(le(Sn(r))),o=(0,U.useMemo)(()=>yt(e,n),[e,n]),s=(0,U.useMemo)(()=>{if(typeof e.result==`string`)return e.result;if(!e.result)return``;if(ge(e.result)){let t=e.result.content;if(typeof t==`string`)return t}return JSON.stringify(e.result,null,2)},[e.result]),c;if(e.toolKind===`workflow`&&!e.isError){let t=e.result?.taskId,n=t?a.find(e=>e.taskId===t):void 0;c=(0,W.jsx)(Vt,{name:e.input.name,description:e.input.description,run:n})}else c=e.toolKind===`subagent_task`&&e.result?(0,W.jsx)(yn,{subagentType:e.input.subagentType,result:e.result,isError:e.isError,localPath:n}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:e.isError?(0,W.jsx)(fe,{className:`size-4 text-destructive`}):(0,W.jsx)(ne,{icon:_t(e),className:`size-4 text-muted-icon`})}),(0,W.jsx)(te,{className:`text-left transition-opacity duration-200 truncate`,children:(0,W.jsx)(wt,{animate:i,children:o})})]});return(0,W.jsx)(f,{className:`w-full`,children:(0,W.jsx)(v,{expandedContent:(0,W.jsx)(u,{className:`my-4 text-sm`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Dn(e),On(e,s)]})}),children:c})})}export{Le as S,ft as _,dn as a,A as b,Zt as c,wt as d,Ct as f,vt as g,mt as h,pn as i,zt as l,xt as m,Sn as n,rn as o,St as p,xn as r,tn as s,$ as t,Ft as u,Qe as v,k as x,P as y};