@qredence/fleet 0.5.11 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/web/client/assets/action-swap-roll-COzQ86wm.js +1 -0
  3. package/dist/web/client/assets/agent-activity-svETLf_5.js +1 -0
  4. package/dist/web/client/assets/agent-disclosure-DAMuuGcM.js +1 -0
  5. package/dist/web/client/assets/analytics-stub-B6zGMuSV.js +1 -0
  6. package/dist/web/client/assets/{artifacts-panel-CQmFEF_H.js → artifacts-panel-HVjqBMyx.js} +1 -1
  7. package/dist/web/client/assets/button-C5wFDY5_.js +1 -0
  8. package/dist/web/client/assets/card-DA3Vnqay.js +1 -0
  9. package/dist/web/client/assets/{chat-yh02zgA7.js → chat-BhYseKd6.js} +7 -7
  10. package/dist/web/client/assets/{chat-command-palette-CmHTS3rs.js → chat-command-palette-LILDO_vG.js} +1 -1
  11. package/dist/web/client/assets/{citations-C_tPOJE_.js → citations-BPv8HIpf.js} +2 -2
  12. package/dist/web/client/assets/command-PhicLCoO.js +1 -0
  13. package/dist/web/client/assets/dialog-pBGUjAQ7.js +1 -0
  14. package/dist/web/client/assets/fleet-message-queue-fbYYwMj0.js +1 -0
  15. package/dist/web/client/assets/{fleet-pi-tool-renderer-BEDIO3al.js → fleet-pi-tool-renderer-BRgNnmaJ.js} +28 -28
  16. package/dist/web/client/assets/fleet-reasoning-panel-CjA2dwUJ.js +1 -0
  17. package/dist/web/client/assets/{fork-picker-dialog-ByBOGVsa.js → fork-picker-dialog-B7NNpVmW.js} +1 -1
  18. package/dist/web/client/assets/globals-CuIiqOTg.css +2 -0
  19. package/dist/web/client/assets/horizontal-resize-Cp3iHMH7.js +1 -0
  20. package/dist/web/client/assets/index-CSGplyr_.js +12 -0
  21. package/dist/web/client/assets/{input-0wwjWjKq.js → input-PcdubeKn.js} +1 -1
  22. package/dist/web/client/assets/input-group-C2HJEZvl.js +1 -0
  23. package/dist/web/client/assets/ipython-tool-CyuMOxz1.js +3 -0
  24. package/dist/web/client/assets/{markdown-code-CuQcR3UO.js → markdown-code-xNyjdZ4g.js} +1 -1
  25. package/dist/web/client/assets/{markdown-DInPmRUG.js → markdown-lvexwooo.js} +2 -2
  26. package/dist/web/client/assets/{model-selector-list-DsKTuAgS.js → model-selector-list-CoXX358G.js} +1 -1
  27. package/dist/web/client/assets/{notify-DgMKgZZW.js → notify-DxL0VD7Z.js} +1 -1
  28. package/dist/web/client/assets/openui-renderer-TLNe5e_Q.js +378 -0
  29. package/dist/web/client/assets/pencil-DcUwsKLn.js +1 -0
  30. package/dist/web/client/assets/prompt-input-fwP8TsgQ.js +1 -0
  31. package/dist/web/client/assets/{prompt-suggestions-Cc--lSNR.js → prompt-suggestions-BlGXmWS7.js} +1 -1
  32. package/dist/web/client/assets/provider-catalog-DYMFdbKc.js +1 -0
  33. package/dist/web/client/assets/provider-label-B4q5mI65.js +1 -0
  34. package/dist/web/client/assets/{repl-panel-DsPX04Xr.js → repl-panel-C5om8MGU.js} +1 -1
  35. package/dist/web/client/assets/{right-panel-registry-DewpBWHM.js → right-panel-registry-BBlxLxnx.js} +2 -2
  36. package/dist/web/client/assets/routes-XGsAIqBJ.js +16 -0
  37. package/dist/web/client/assets/settings-dialog-BSBasR3o.js +2 -0
  38. package/dist/web/client/assets/{subagent-chat-panel-DkVUumrP.js → subagent-chat-panel-oeLDPDAK.js} +1 -1
  39. package/dist/web/client/assets/{subagent-transcript-D8wmQxXe.js → subagent-transcript-DaVHjNUH.js} +1 -1
  40. package/dist/web/client/assets/{subagents-panel-BMp2Ego0.js → subagents-panel-D_aVgSCi.js} +1 -1
  41. package/dist/web/client/assets/surfaces-BhAXz9So.js +1 -0
  42. package/dist/web/client/assets/{switch-9rTeg6J6.js → switch-WhXeJNNY.js} +1 -1
  43. package/dist/web/client/assets/{toast-Bt9p2OL4.js → toast-D3c9XeGe.js} +1 -1
  44. package/dist/web/client/assets/{tool-result-DfnPN0FQ.js → tool-result-Cki8WUNc.js} +3 -3
  45. package/dist/web/client/assets/virtualized-turn-list-CdMa-ydT.js +6 -0
  46. package/dist/web/client/assets/workspace-panel-77bDbprs.js +1 -0
  47. package/dist/web/client/bundle-budget.json +6 -6
  48. package/dist/web/launcher.mjs +10 -1
  49. package/dist/web/server/{_tanstack-start-manifest_v-po4woX6g-AUGCOEZ2.js → _tanstack-start-manifest_v-0L7fqnH4-KMVGUFE4.js} +25 -24
  50. package/dist/web/server/{agent-activity-CS2rbF_C-A3R26CYH.js → agent-activity-BuEE6iVw-CDZLK4D2.js} +4 -4
  51. package/dist/web/server/{artifacts-panel-8GGUCtOd-X5TNKTY2.js → artifacts-panel-D3ySO--V-XSL53CXL.js} +18 -18
  52. package/dist/web/server/{chat-command-palette-Dgl5tqWn-72LLEWUD.js → chat-command-palette-kAbXhWVg-TJWXH2WW.js} +9 -9
  53. package/dist/web/server/{chunk-O4OTWWPF.js → chunk-2DDWXTVG.js} +5 -5
  54. package/dist/web/server/{chunk-MIW4LJTV.js → chunk-2JHTYWD5.js} +15 -23
  55. package/dist/web/server/{chunk-7MDZVLIY.js → chunk-3TIMGWWI.js} +1 -2
  56. package/dist/web/server/{chunk-AGFRJQZ7.js → chunk-4WBFCB4O.js} +257 -257
  57. package/dist/web/server/{chunk-P6UMR32I.js → chunk-5UCAJBAH.js} +4 -4
  58. package/dist/web/server/{chunk-BXWAUTTH.js → chunk-D27LRYVT.js} +42 -42
  59. package/dist/web/server/{chunk-YXXRP3NS.js → chunk-DLUZFOG3.js} +5 -5
  60. package/dist/web/server/{chunk-K3BXQG3N.js → chunk-EBG3XFGQ.js} +60 -60
  61. package/dist/web/server/{chunk-2ATMSG7U.js → chunk-EJEPDVK6.js} +3 -3
  62. package/dist/web/server/{chunk-IJPCV6DH.js → chunk-FYDQK6UX.js} +1 -1
  63. package/dist/web/server/{chunk-WKV2Z4KO.js → chunk-HF7DG7PC.js} +74 -74
  64. package/dist/web/server/{chunk-WYL2DW5R.js → chunk-JTCCQZLN.js} +2 -2
  65. package/dist/web/server/{chunk-UAPNEWCA.js → chunk-KP2PNDGL.js} +6 -6
  66. package/dist/web/server/chunk-M5RSPNYN.js +22 -0
  67. package/dist/web/server/{chunk-7SR6WDM2.js → chunk-MNBGB2SP.js} +2 -2
  68. package/dist/web/server/{chunk-HSJMLO36.js → chunk-MNPHMZU7.js} +3 -3
  69. package/dist/web/server/{chunk-JQDLJ7KI.js → chunk-NGCQJ33Y.js} +1134 -1134
  70. package/dist/web/server/{chunk-7SD2ZSEA.js → chunk-NIDBN7BQ.js} +1 -1
  71. package/dist/web/server/{chunk-ZJFA4F5X.js → chunk-NIZBFVJF.js} +2 -2
  72. package/dist/web/server/{chunk-P7H2OPKF.js → chunk-NJ4QEZHK.js} +11 -4
  73. package/dist/web/server/{chunk-WM4PUT6M.js → chunk-NNKJTKOQ.js} +234 -234
  74. package/dist/web/server/{chunk-N6NOTURM.js → chunk-NWDI3OWB.js} +4 -4
  75. package/dist/web/server/{chunk-ABBWBBSS.js → chunk-O3HDELZ2.js} +74826 -74825
  76. package/dist/web/server/{chunk-GGT2ZKDB.js → chunk-PLYZ7P2Y.js} +11 -155
  77. package/dist/web/server/chunk-PTCKOR23.js +39 -0
  78. package/dist/web/server/{chunk-RNOJACWQ.js → chunk-QFRCJWQQ.js} +7 -7
  79. package/dist/web/server/{chunk-NXJ32VFR.js → chunk-QIULBRTU.js} +13 -13
  80. package/dist/web/server/{chunk-XKKXXG6N.js → chunk-RIP3PBWT.js} +3 -3
  81. package/dist/web/server/{chunk-YKVGQBZA.js → chunk-S5LFXXDY.js} +625 -622
  82. package/dist/web/server/{chunk-XLNCWZMZ.js → chunk-UCUFC553.js} +3 -1
  83. package/dist/web/server/{chunk-KOUEJ3NU.js → chunk-UL2725KQ.js} +3 -3
  84. package/dist/web/server/{chunk-HFQTI7AX.js → chunk-VPKX7QRU.js} +3 -3
  85. package/dist/web/server/{chunk-LZ4Q5KUJ.js → chunk-WNCAL4HN.js} +133 -133
  86. package/dist/web/server/{chunk-C5X6G26O.js → chunk-XIB6XNUX.js} +436 -436
  87. package/dist/web/server/{chunk-JUROEEWM.js → chunk-YGYOBX7G.js} +82 -4
  88. package/dist/web/server/{chunk-WILCIZYU.js → chunk-ZIFSJ3HQ.js} +626 -626
  89. package/dist/web/server/fleet-message-queue-D_w8lSeY-T3HB7HVQ.js +152 -0
  90. package/dist/web/server/{fleet-pi-tool-renderer-umKunT3K-O4GBH35V.js → fleet-pi-tool-renderer-qwc-qZFq-4U556N5Q.js} +12 -12
  91. package/dist/web/server/{fleet-reasoning-panel-BxC2COxi-GPLMQSTT.js → fleet-reasoning-panel-DG_vuvv0-NCZWEEIT.js} +26 -26
  92. package/dist/web/server/{fleet-subagent-list-CpSYzCIq-JDH2LHSS.js → fleet-subagent-list-BGb0PjhF-2X67FMUV.js} +1 -1
  93. package/dist/web/server/{fleet-tool-timeline-IB36_PB2-XJENTO6I.js → fleet-tool-timeline-D6yM4ZMz-ZSFVRRRI.js} +1 -1
  94. package/dist/web/server/{fork-picker-dialog-DlINz9UQ-UWIXFDJX.js → fork-picker-dialog-Ds6Tgtu3-DIBWN7MV.js} +5 -5
  95. package/dist/web/server/{model-selector-list-OYnzNbyu-HBGCNF2L.js → model-selector-list-DxeGZoD2-P6S6FSJH.js} +9 -9
  96. package/dist/web/server/{openui-renderer-Cj7kfqyL-EKJ6JTTQ.js → openui-renderer-MKFv6LlH-MDRSVFEY.js} +11 -11
  97. package/dist/web/server/{prompt-suggestions-D4AEEY7K-RZSP7PWV.js → prompt-suggestions-BOItmGnD-YQA7RHLG.js} +2 -2
  98. package/dist/web/server/{repl-panel-D5KsoJik-BQKO53JO.js → repl-panel-CuyF8wt5-CHDT2Q3N.js} +2 -2
  99. package/dist/web/server/{router-Ci1wxI7I-E2AYMNON.js → router-Dg72SESP-PCWKLFRG.js} +1239 -470
  100. package/dist/web/server/{routes-CRpm9-Sa-IYK6MUJO.js → routes-BGrVtPYF-SURPAJN6.js} +5781 -5588
  101. package/dist/web/server/server.js +2 -2
  102. package/dist/web/server/{settings-dialog-BvkgNflv-GPJ6COQO.js → settings-dialog-CK0FJlTg-HZRBAXDZ.js} +1577 -1264
  103. package/dist/web/server/{subagent-chat-panel-CMuvW9Sd-M5TEEGQW.js → subagent-chat-panel-gzamnTgK-PQ2TLLJF.js} +21 -21
  104. package/dist/web/server/{subagents-panel-DgfB6_Yy-4INEPE3Y.js → subagents-panel-Berjd7HJ-EI5ZKC6V.js} +20 -20
  105. package/dist/web/server/{workspace-panel-bpwj-Veu-Q2CEJMN4.js → workspace-panel-CBBa_3UO-B4PPFPMA.js} +46 -21
  106. package/package.json +1 -1
  107. package/dist/web/client/assets/action-swap-roll-BB8DFMuf.js +0 -1
  108. package/dist/web/client/assets/agent-activity-CwMDU7aP.js +0 -1
  109. package/dist/web/client/assets/agent-disclosure-B8SnhQXL.js +0 -1
  110. package/dist/web/client/assets/analytics-stub-Cas1He0w.js +0 -1
  111. package/dist/web/client/assets/button-BR2WWrFo.js +0 -1
  112. package/dist/web/client/assets/card-BKl76a3R.js +0 -1
  113. package/dist/web/client/assets/command-DPfiaYUL.js +0 -1
  114. package/dist/web/client/assets/dialog-BEZuZhzk.js +0 -1
  115. package/dist/web/client/assets/fleet-message-queue-DUz6Hfrf.js +0 -1
  116. package/dist/web/client/assets/fleet-reasoning-panel-CbkO7u-v.js +0 -1
  117. package/dist/web/client/assets/globals-B_I1Eq1u.css +0 -2
  118. package/dist/web/client/assets/horizontal-resize-qK6eRhIG.js +0 -1
  119. package/dist/web/client/assets/index-C1zOjrMK.js +0 -12
  120. package/dist/web/client/assets/input-group-BFDsCVS9.js +0 -1
  121. package/dist/web/client/assets/ipython-tool-ldJ9F1Cw.js +0 -3
  122. package/dist/web/client/assets/openui-renderer-J3dhPpL4.js +0 -378
  123. package/dist/web/client/assets/prompt-input-qPIXZ-Rb.js +0 -1
  124. package/dist/web/client/assets/provider-catalog-D8G66gwc.js +0 -1
  125. package/dist/web/client/assets/provider-label-Dpr7djG9.js +0 -1
  126. package/dist/web/client/assets/routes-vNkVToAF.js +0 -16
  127. package/dist/web/client/assets/settings-dialog-B-v4me3Y.js +0 -1
  128. package/dist/web/client/assets/surfaces-DI-U-_2a.js +0 -1
  129. package/dist/web/client/assets/virtualized-turn-list-DMJENRY0.js +0 -6
  130. package/dist/web/client/assets/workspace-panel-G6yMpKJ8.js +0 -1
  131. package/dist/web/server/chunk-QK4CHLVV.js +0 -17
  132. package/dist/web/server/fleet-message-queue-j0DCU5Xy-5HKBHMPV.js +0 -75
@@ -0,0 +1,16 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/model-selector-list-CoXX358G.js","assets/rolldown-runtime-hePW80VL.js","assets/bundle-mjs-DKHVkVWu.js","assets/jsx-runtime-NZYk81nU.js","assets/utils-Eg7xtNmV.js","assets/ease-u56MhKYS.js","assets/layout-gyLzPvVv.js","assets/check-JjHKAZas.js","assets/createLucideIcon-DwxZHm0M.js","assets/gauge-DNpstbBn.js","assets/command-PhicLCoO.js","assets/dialog-pBGUjAQ7.js","assets/react-dom-Bwxum3ti.js","assets/button-C5wFDY5_.js","assets/createBaseUIEventDetails-DV0dQrBX.js","assets/useBaseUiId-CHqXB2UQ.js","assets/x-CsRC_tCI.js","assets/search-eWVnAJsb.js","assets/dist-BPaFisIZ.js","assets/input-group-C2HJEZvl.js","assets/input-PcdubeKn.js","assets/useControlled-CJJ9BOQB.js","assets/fleet-pi-tool-renderer-BRgNnmaJ.js","assets/use-reduced-motion-eORd7fqW.js","assets/tool-result-Cki8WUNc.js","assets/chevron-down-BEVGmnSb.js","assets/loader-circle-DjfHXUPB.js","assets/circle-x-CkKCB__4.js","assets/action-swap-roll-COzQ86wm.js","assets/rotate-ccw-WNFNkKQD.js","assets/square-terminal-BYTN_I86.js","assets/wrench-BJNNe07k.js","assets/preload-helper-Czpn1I53.js","assets/agent-disclosure-DAMuuGcM.js","assets/citations-BPv8HIpf.js","assets/earth-DGZXAN5r.js","assets/shield-check-CkA2viVW.js","assets/safe-external-url-D3PJJIcM.js","assets/chevron-right-DrJxToLs.js","assets/chevron-up-CnSvySGH.js","assets/circle-alert-CONlFReH.js","assets/ipython-tool-CyuMOxz1.js","assets/cn-C8c0S2mI.js","assets/eye-B0DFz5hL.js","assets/file-text-T-NcAlZs.js","assets/sparkles-DuclzqlE.js","assets/terminal-DOS1s1gm.js","assets/dist-CZDnnosQ.js","assets/lib-ChrQ49PO.js","assets/character-entities-legacy-Wut6vMuj.js","assets/surfaces-BhAXz9So.js","assets/collapsible-BoXtZZWN.js","assets/workspace-path-nav-C0AQNZyy.js","assets/range-BWOHiLNe.js","assets/agent-activity-svETLf_5.js","assets/image-BbPmlw-n.js","assets/message-square-hbDao-A1.js","assets/fleet-reasoning-panel-CjA2dwUJ.js","assets/fleet-tool-timeline-C8heL7ae.js","assets/fleet-subagent-list-iKUtLJKZ.js","assets/subagent-utils-DDH5qm9Z.js","assets/prompt-suggestions-BlGXmWS7.js","assets/fleet-message-queue-fbYYwMj0.js","assets/pencil-DcUwsKLn.js","assets/notify-DxL0VD7Z.js","assets/toast-D3c9XeGe.js","assets/triangle-alert-CU-gd7ui.js","assets/chat-command-palette-LILDO_vG.js","assets/right-panel-registry-BBlxLxnx.js","assets/bot-Bs7QWJ2q.js","assets/folder-BC5p7qK7.js","assets/package-CdcJFPf2.js","assets/right-panel-context-DHlNWJsF.js","assets/skeleton-CkR2VmWc.js","assets/sun-BWiZFty0.js","assets/plus-DXN1Bg_z.js","assets/square-Bhn8gjr0.js","assets/settings-dialog-BSBasR3o.js","assets/provider-catalog-DYMFdbKc.js","assets/provider-label-B4q5mI65.js","assets/plug-Dt6VN0zF.js","assets/hard-drive-CHqgr7VQ.js","assets/refresh-cw-IThTJ3j-.js","assets/safe-storage-s25GrfpH.js","assets/ui-preferences-CImQGZm_.js","assets/switch-WhXeJNNY.js","assets/fork-picker-dialog-B7NNpVmW.js","assets/subagent-chat-panel-oeLDPDAK.js","assets/prompt-input-fwP8TsgQ.js","assets/subagent-transcript-DaVHjNUH.js","assets/virtualized-turn-list-CdMa-ydT.js","assets/openui-utils-DawGoQNp.js","assets/prime-agent-artifacts-C-g1VPiW.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./bundle-mjs-DKHVkVWu.js";import{t as n}from"./react-dom-Bwxum3ti.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{A as i,D as a,E as o,F as s,M as c,N as l,P as u,S as d,T as f,d as p,f as m,g as h,k as g,l as _,m as v,p as y,s as b,w as x,y as S}from"./analytics-stub-B6zGMuSV.js";import{A as C,B as w,D as T,E,Q as D,S as O,T as k,V as A,b as j,c as M,et as N,f as P,k as F,m as I,n as L,nt as ee,p as te,r as R,t as z,v as B,x as V,z as H}from"./button-C5wFDY5_.js";import{t as U}from"./utils-Eg7xtNmV.js";import{$ as W,C as ne,I as G,K as re,L as ie,M as ae,N as oe,P as se,U as ce,V as le,W as ue,X as de,Y as fe,Z as pe,at as me,ct as he,et as ge,h as _e,it as ve,j as ye,m as be,nt as xe,ot as Se,q as Ce,rt as we,tt as Te,y as Ee,z as De}from"./layout-gyLzPvVv.js";import{d as K,h as Oe,l as ke,m as Ae,n as je,o as Me,p as Ne,r as Pe,t as Fe,u as Ie}from"./ease-u56MhKYS.js";import{a as Le,c as Re,i as ze,n as Be,o as Ve,r as He,s as Ue,t as We}from"./prompt-input-fwP8TsgQ.js";import{n as Ge,t as Ke}from"./use-reduced-motion-eORd7fqW.js";import{C as qe,K as Je,O as Ye,b as Xe,c as Ze,d as Qe,et as $e,f as et,h as tt,i as nt,j as rt,nt as it,o as at,ot,rt as st,s as ct,st as lt,t as ut,v as dt,w as ft,x as pt}from"./createBaseUIEventDetails-DV0dQrBX.js";import{$ as mt,A as ht,B as gt,E as _t,F as vt,G as yt,H as bt,I as xt,J as St,K as Ct,L as wt,M as Tt,N as Et,O as Dt,P as Ot,Q as kt,R as At,S as jt,T as Mt,U as Nt,V as Pt,W as Ft,X as It,Z as Lt,_ as Rt,a as zt,b as Bt,et as Vt,g as Ht,h as Ut,i as Wt,j as Gt,n as Kt,o as qt,q as Jt,r as Yt,t as Xt,v as Zt,w as Qt,x as $t,y as en}from"./dialog-pBGUjAQ7.js";import{_ as tn,b as nn,c as rn,f as an,h as on,j as sn,p as cn,s as ln,u as un,v as dn,x as fn,y as pn}from"./provider-catalog-DYMFdbKc.js";import{t as mn}from"./useBaseUiId-CHqXB2UQ.js";import{D as hn,E as gn,S as _n,T as vn,a as yn,c as bn,d as xn,f as Sn,h as Cn,i as wn,k as Tn,l as En,m as Dn,n as On,o as kn,p as An,s as jn,t as Mn,u as Nn,v as Pn,w as Fn,x as In,y as Ln}from"./provider-label-B4q5mI65.js";import{t as Rn}from"./createLucideIcon-DwxZHm0M.js";import{n as zn,r as Bn,t as Vn}from"./right-panel-registry-BBlxLxnx.js";import{c as Hn,i as Un,l as Wn,n as Gn,o as Kn,s as qn,t as Jn,u as Yn}from"./citations-BPv8HIpf.js";import{r as Xn}from"./resource-helpers-Q2T0YCMO.js";import{t as Zn}from"./bot-Bs7QWJ2q.js";import{t as Qn}from"./check-JjHKAZas.js";import{t as $n}from"./chevron-down-BEVGmnSb.js";import{a as er,c as tr,d as nr,f as rr,i as ir,l as ar,n as or,o as sr,p as cr,r as lr,s as ur,t as dr,u as fr}from"./virtualized-turn-list-CdMa-ydT.js";import{t as pr}from"./chevron-right-DrJxToLs.js";import{t as mr}from"./chevron-up-CnSvySGH.js";import{t as hr}from"./circle-alert-CONlFReH.js";import{t as gr}from"./loader-circle-DjfHXUPB.js";import{n as _r,r as vr,t as yr}from"./action-swap-roll-COzQ86wm.js";import{t as br}from"./file-text-T-NcAlZs.js";import{S as xr,_ as Sr,a as Cr,c as wr,d as Tr,f as Er,h as Dr,i as Or,l as kr,m as Ar,n as jr,o as Mr,p as Nr,r as Pr,t as Fr,u as Ir,v as Lr,x as Rr}from"./horizontal-resize-Cp3iHMH7.js";import{t as zr}from"./folder-BC5p7qK7.js";import{t as Br}from"./gauge-DNpstbBn.js";import{t as Vr}from"./package-CdcJFPf2.js";import{t as Hr}from"./pencil-DcUwsKLn.js";import{t as Ur}from"./plus-DXN1Bg_z.js";import{t as Wr}from"./refresh-cw-IThTJ3j-.js";import{t as Gr}from"./rotate-ccw-WNFNkKQD.js";import{t as Kr}from"./subagent-utils-DDH5qm9Z.js";import{t as qr}from"./search-eWVnAJsb.js";import{t as Jr}from"./sparkles-DuclzqlE.js";import{t as Yr}from"./triangle-alert-CU-gd7ui.js";import{t as Xr}from"./x-CsRC_tCI.js";import{n as Zr,r as Qr,t as $r}from"./safe-storage-s25GrfpH.js";import{t as ei}from"./preload-helper-Czpn1I53.js";import{a as ti,c as ni,i as ri,o as ii,s as ai}from"./surfaces-BhAXz9So.js";import"./cn-C8c0S2mI.js";import{t as oi}from"./notify-DxL0VD7Z.js";import{t as si}from"./useControlled-CJJ9BOQB.js";import{n as ci}from"./workspace-path-nav-C0AQNZyy.js";import{t as li}from"./agent-disclosure-DAMuuGcM.js";import{t as ui}from"./prime-agent-artifacts-C-g1VPiW.js";import{B as di,C as fi,D as pi,E as mi,F as q,I as hi,L as gi,M as _i,N as vi,O as yi,R as bi,T as xi,U as J,V as Y,W as Si,_ as Ci,a as wi,b as Ti,c as Ei,d as Di,f as Oi,g as ki,h as Ai,i as ji,j as Mi,k as Ni,l as Pi,m as Fi,n as Ii,o as Li,p as Ri,r as zi,s as Bi,t as Vi,u as Hi,v as Ui,w as Wi,y as Gi,z as Ki}from"./chat-BhYseKd6.js";import{i as qi,n as Ji,t as Yi}from"./right-panel-context-DHlNWJsF.js";import{t as Xi}from"./input-PcdubeKn.js";import{t as Zi}from"./artifacts-utils-N_kUFbz2.js";var Qi=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function $i(e,t){return ge(e)?e[Qi(0,e.length,t)]:e}var ea=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get state(){return this.getAll(`state`)}get startTime(){return this.getAll(`startTime`)}get duration(){return ta(this.animations,`duration`)}get iterationDuration(){return ta(this.animations,`iterationDuration`)}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}};function ta(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r][t];i!==null&&i>n&&(n=i)}return n}var na=class extends ea{then(e,t){return this.finished.finally(e).then(()=>{})}};function ra(e,t){return e in t}var ia=class extends ne{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(ra(t,e)){let n=e[t];if(typeof n==`string`||typeof n==`number`)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return ae()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}},aa=e=>!e.isLayoutDirty&&e.willUpdate(!1);function oa(){let e=new Set,t=new WeakMap,n=()=>e.forEach(aa);return{add:r=>{e.add(r),t.set(r,r.addEventListener(`willUpdate`,n))},remove:r=>{e.delete(r);let i=t.get(r);i&&(i(),t.delete(r)),n()},dirty:n}}var X=e(t(),1),sa=(0,X.createContext)(null);function ca(){let e=(0,X.useRef)(!1);return Ae(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function la(){let e=ca(),[t,n]=(0,X.useState)(0),r=(0,X.useCallback)(()=>{e.current&&n(t+1)},[t]);return[(0,X.useCallback)(()=>W.postRender(r),[r]),t]}var Z=r(),ua=e=>e===!0,da=e=>ua(e===!0)||e===`id`,fa=({children:e,id:t,inherit:n=!0})=>{let r=(0,X.useContext)(he),i=(0,X.useContext)(sa),[a,o]=la(),s=(0,X.useRef)(null),c=r.id||i;s.current===null&&(da(n)&&c&&(t=t?c+`-`+t:c),s.current={id:t,group:ua(n)&&r.group||oa()});let l=(0,X.useMemo)(()=>({...s.current,forceRender:a}),[o]);return(0,Z.jsx)(he.Provider,{value:l,children:e})};function pa({children:e,...t}){let n=(0,X.useContext)(Ne);t={...n,...t},t.transition=le(t.transition,n.transition),t.isStatic=Oe(()=>t.isStatic);let r=(0,X.useMemo)(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion,t.skipAnimations,t.isValidProp]);return(0,Z.jsx)(Ne.Provider,{value:r,children:e})}function ma(e){return typeof e==`object`&&!Array.isArray(e)}function ha(e,t,n,r){return e==null?[]:typeof e==`string`&&ma(t)?G(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(e=>e!=null):[e]}function ga(e,t,n){return e*(t+1)+n*t}function _a(e,t,n,r){return typeof t==`number`?t:t.startsWith(`-`)||t.startsWith(`+`)?Math.max(0,e+parseFloat(t)):t===`<`?n:t.startsWith(`<`)?Math.max(0,n+parseFloat(t.slice(1))):r.get(t)??e}function va(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.at>t&&i.at<n&&(Se(e,i),r--)}}function ya(e,t,n,r,i,a){va(e,i,a);for(let o=0;o<t.length;o++)e.push({value:t[o],at:pe(i,a,r[o]),easing:$i(n,o)})}function ba(e,t,n=0){let r=t+1+t*n;for(let t=0;t<e.length;t++)e[t]=e[t]/r}function xa(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}var Sa=`easeInOut`,Ca=20;function wa(e,{defaultTransition:t={},...n}={},r,i){let a=t.duration||.3,o=new Map,s=new Map,c={},l=new Map,u=0,d=0,f=0;for(let n=0;n<e.length;n++){let o=e[n];if(typeof o==`string`){l.set(o,d);continue}if(!Array.isArray(o)){l.set(o.name,_a(d,o.at,u,l));continue}let[p,m,h={}]=o;h.at!==void 0&&(d=_a(d,h.at,u,l));let g=0,_=(e,n,r,o=0,s=0)=>{let c=Da(e),{delay:l=0,times:u=re(c),type:p=t.type||`keyframes`,repeat:m,repeatType:h,repeatDelay:_=0,...v}=n,{ease:y=t.ease||`easeOut`,duration:b}=n,x=typeof l==`function`?l(o,s):l,S=c.length,C=ue(p)?p:i?.[p||`keyframes`];if(S<=2&&C){let e=100;if(S===2&&Aa(c)){let t=c[1]-c[0];e=Math.abs(t)}let n={...t,...v};b!==void 0&&(n.duration=xe(b));let r=de(n,e,C);y=r.ease,b=r.duration}b??=a;let w=d+x;u.length===1&&u[0]===0&&(u[1]=1);let T=u.length-c.length;if(T>0&&Ce(u,T),c.length===1&&c.unshift(null),m&&me(m<Ca,`Sequence segments can't repeat ${m} times — ignoring repeat option. Use a value below ${Ca} or apply repeat at the sequence level instead.`),m&&m<Ca){let e=b>0?_/b:0;b=ga(b,m,_);let t=[...c],n=[...u];y=Array.isArray(y)?[...y]:[y];let r=[...y],i=h===`reverse`||h===`mirror`,a=t,o=r;i&&(a=[...t].reverse(),h===`reverse`&&(o=[...r].reverse().map(e=>typeof e==`function`?Te(e):e)));for(let s=0;s<m;s++){let l=i&&s%2==0,d=l?a:t,f=l?o:r,p=(s+1)*(1+e);e>0&&(c.push(c[c.length-1]),u.push(p),y.push(`linear`)),c.push(...d);for(let e=0;e<d.length;e++)u.push(n[e]+p),y.push(e===0?`linear`:$i(f,e-1))}ba(u,m,e)}let E=w+b;ya(r,c,y,u,w,E),g=Math.max(x+b,g),f=Math.max(E,f)};if(De(p)){let e=Ta(p,s);_(m,h,Ea(`default`,e))}else{let e=ha(p,m,r,c),t=e.length;for(let n=0;n<t;n++){m=m,h=h;let r=e[n],i=Ta(r,s);for(let e in m)_(m[e],Oa(h,e),Ea(e,i),n,t)}}u=d,d+=g}return s.forEach((e,r)=>{for(let i in e){let a=e[i];a.sort(xa);let s=[],c=[],l=[];for(let e=0;e<a.length;e++){let{at:t,value:n,easing:r}=a[e];s.push(n),c.push(we(0,f,t)),l.push(r||`easeOut`)}c[0]!==0&&(c.unshift(0),s.unshift(s[0]),l.unshift(Sa)),c[c.length-1]!==1&&(c.push(1),s.push(null)),o.has(r)||o.set(r,{keyframes:{},transition:{}});let u=o.get(r);u.keyframes[i]=s;let{type:d,...p}=t;u.transition[i]={...p,duration:f,ease:l,times:c,...n}}}),o}function Ta(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function Ea(e,t){return t[e]||(t[e]=[]),t[e]}function Da(e){return Array.isArray(e)?e:[e]}function Oa(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}var ka=e=>typeof e==`number`,Aa=e=>e.every(ka);function ja(e){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=se(e)&&!oe(e)?new _e(t):new Ee(t);n.mount(e),ye.set(e,n)}function Ma(e){let t=new ia({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),ye.set(e,t)}function Na(e,t){return De(e)||typeof e==`number`||typeof e==`string`&&!ma(t)}function Pa(e,t,n,r){let i=[];if(Na(e,t))i.push(be(e,ma(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return i;let a=ha(e,t,r),o=a.length;ve(!!o,`No valid elements provided.`,`no-valid-elements`);for(let e=0;e<o;e++){let r=a[e],s=r instanceof Element?ja:Ma;ye.has(r)||s(r);let c=ye.get(r),l={...n};`delay`in l&&typeof l.delay==`function`&&(l.delay=l.delay(e,o)),i.push(...ie(c,{...t,transition:l},{}))}}return i}function Fa(e,t,n){let r=[];return wa(e.map(e=>{if(Array.isArray(e)&&typeof e[0]==`function`){let t=e[0],n=ce(0);return n.on(`change`,t),e.length===1?[n,[0,1]]:e.length===2?[n,[0,1],e[1]]:[n,e[1],e[2]]}return e}),t,n,{spring:fe}).forEach(({keyframes:e,transition:t},n)=>{r.push(...Pa(n,e,t))}),r}function Ia(e){return Array.isArray(e)&&e.some(Array.isArray)}function La(e={}){let{scope:t,reduceMotion:n,skipAnimations:r}=e;function i(e,i,a){let o=[],s,c={};if(n!==void 0&&(c.reduceMotion=n),r!==void 0&&(c.skipAnimations=r),Ia(e)){let{onComplete:n,...r}=i||{};typeof n==`function`&&(s=n),o=Fa(e,{...c,...r},t)}else{let{onComplete:n,...r}=a||{};typeof n==`function`&&(s=n),o=Pa(e,i,{...c,...r},t)}let l=new na(o);return s&&l.finished.then(s),t&&(t.animations.push(l),l.finished.then(()=>{Se(t.animations,l)})),l}return i}var Ra=La(),za=Rn(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Ba=Rn(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),Va=Rn(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Ha=Rn(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`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`}]]),Ua=Rn(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Wa=Rn(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Ga=Rn(`command`,[[`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`}]]),Ka=Rn(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),qa=Rn(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Ja=Rn(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Ya=Rn(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),Xa=Rn(`list-restart`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M7 12H3`,key:`13ou7f`}],[`path`,{d:`M7 19H3`,key:`wbqt3n`}],[`path`,{d:`M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14`,key:`qth677`}],[`path`,{d:`M11 10v4h4`,key:`172dkj`}]]),Za=Rn(`message-square-plus`,[[`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:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Qa=Rn(`message-square-text`,[[`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:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),$a=Rn(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),eo=Rn(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),to=Rn(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),no=Rn(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),ro=Rn(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),io=Rn(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),ao=Rn(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),oo=class extends y{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),co(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return lo(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return lo(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof f(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!o(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&uo(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||f(this.options.enabled,this.#t)!==f(t.enabled,this.#t)||f(this.options.staleTime,this.#t)!==f(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||f(this.options.enabled,this.#t)!==f(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return o(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(d)),t}#h(e){return!v()&&f(this.options.enabled,this.#t)!==!1&&S(e)}#g(){this.#b();let e=f(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=g(this.#r.dataUpdatedAt,e)+1;this.#u=i.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,!(this.#f===0||!this.#h(this.#f))&&(this.#d=i.setInterval(()=>{(this.options.refetchIntervalInBackground||m.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(i.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(i.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&co(e,t),o=i&&uo(e,n,t,r);(a||o)&&(l={...l,..._(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:p,errorUpdatedAt:m,status:h}=l;d=l.data;let g=!1;if(t.placeholderData!==void 0&&d===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(h=`success`,d=x(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!g){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=x(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(p=this.#o,d=this.#c,m=Date.now(),h=`error`,u=!1);let v=l.fetchStatus===`fetching`,y=h===`pending`,b=h===`error`,S=y&&v,C=d!==void 0;return{status:h,fetchStatus:l.fetchStatus,isPending:y,isSuccess:h===`success`,isError:b,isInitialLoading:S,isLoading:S,data:d,dataUpdatedAt:l.dataUpdatedAt,error:p,errorUpdatedAt:m,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:v,isRefetching:v&&!y,isLoadingError:b&&!C,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:b&&C,isStale:fo(e,t),refetch:this.refetch,isEnabled:f(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),o(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();p.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function so(e,t){return f(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||f(t.retryOnMount,e)!==!1)}function co(e,t){return so(e,t)||e.state.data!==void 0&&lo(e,t,t.refetchOnMount)}function lo(e,t,n){if(f(t.enabled,e)!==!1&&f(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&fo(e,t)}return!1}function uo(e,t,n,r){return(e!==t||f(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&fo(e,n)}function fo(e,t){return f(t.enabled,e)!==!1&&e.isStaleByTime(f(t.staleTime,e))}var po=class extends y{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),o(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&h(t.mutationKey)!==h(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??b();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){p.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},mo=X.createContext(!1),ho=()=>X.useContext(mo);mo.Provider;function go(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var _o=X.createContext(go()),vo=()=>X.useContext(_o),yo=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?a(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},bo=e=>{X.useEffect(()=>{e.clearReset()},[e])},xo=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||a(n,[e.error,r])),So=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Co=(e,t)=>e?.suspense&&t.isPending,wo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function To(e,t,n){let r=ho(),i=vo(),a=c(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:l?`optimistic`:void 0,So(o),yo(o,i,s),bo(i);let[u]=X.useState(()=>new t(a,o)),f=u.getOptimisticResult(o),m=!r&&l;if(X.useSyncExternalStore(X.useCallback(e=>{let t=m?u.subscribe(p.batchCalls(e)):d;return u.updateResult(),t},[u,m]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),X.useEffect(()=>{u.setOptions(o)},[o,u]),Co(o,f))throw wo(o,u,i);if(xo({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw f.error;return o.notifyOnChangeProps?f:u.trackResult(f)}function Eo(e,t){return To(e,oo,t)}function Do(e,t){let n=c(t),[r]=X.useState(()=>new po(n,e));X.useEffect(()=>{r.setOptions(e)},[r,e]);let i=X.useSyncExternalStore(X.useCallback(e=>r.subscribe(p.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=X.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(d)},[r]);if(i.error&&a(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function Oo(e){return`agent-tab-${encodeURIComponent(e)}`}function ko(e){return`agent-tab-panel-${encodeURIComponent(e)}`}var Ao={"--chat-chrome-top":`52px`,"--chat-header-height":`44px`,"--chat-header-top":`0px`};function jo({children:e,headerCenter:t,headerLeft:n,headerRight:r,panel:i}){return(0,Z.jsxs)(`div`,{className:`flex h-svh min-w-0 overflow-hidden`,"data-testid":`chat-shell`,style:Ao,children:[(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,"data-testid":`chat-column`,children:[(0,Z.jsxs)(`header`,{className:U(Sn,`grid h-[var(--chat-header-height)] min-h-[var(--chat-header-height)] shrink-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1 border-b border-border/70 px-2 py-2`),"data-testid":`chat-header`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 justify-self-start`,children:n}),(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center justify-start gap-1 overflow-visible justify-self-stretch`,children:t}),(0,Z.jsx)(`div`,{className:`min-w-0 justify-self-end`,children:r})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:e})]}),i]})}function Mo({children:e,dataTestid:t,headerLeading:n,loading:r,onClose:i,onRefresh:a,onResizeStart:o,open:s,headerActions:c,title:d,titleIcon:f,width:p}){let m=Ke(),h=(0,X.useRef)(null);return(0,X.useEffect)(()=>{s&&h.current?.focus({preventScroll:!0})},[s]),(0,Z.jsx)(u,{features:l,children:(0,Z.jsx)(Ge,{children:s&&(0,Z.jsxs)(K.aside,{ref:h,initial:!m&&{x:p,opacity:.8},animate:{x:0,opacity:1},exit:m?{opacity:0}:{x:p,opacity:.8},transition:m?{duration:0}:{duration:.2,ease:`easeInOut`},className:`relative h-full shrink-0 border-l border-border/70 bg-background/95 outline-none hidden min-[960px]:flex`,"data-fleet-panel-focus":!0,"data-testid":t,style:{width:p},tabIndex:-1,role:`dialog`,"aria-label":d,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Resize ${d} panel`,className:`absolute top-0 bottom-0 left-0 z-10 w-2 -translate-x-1 cursor-col-resize touch-none bg-transparent transition-colors outline-none hover:bg-foreground/10 focus-visible:bg-foreground/10`,"data-testid":`pi-resources-resize-handle`,onPointerDown:o}),(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex h-[var(--chat-header-height,44px)] min-h-[var(--chat-header-height,44px)] min-w-0 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n??(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[0.8125rem] font-medium text-foreground/80`,children:[(0,Z.jsx)(f,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:d})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[c,(0,Z.jsx)(z,{type:`button`,onClick:a,disabled:!a,variant:`ghost`,size:`icon-sm`,className:`relative after:absolute after:inset-x-0 after:-top-1.5 after:-bottom-1.5 text-foreground/40 hover:text-foreground/70 disabled:cursor-not-allowed disabled:opacity-35`,"aria-label":`Refresh ${d}`,title:`Refresh ${d}`,children:(0,Z.jsx)(Wr,{"data-icon":`inline-start`,className:`size-3.5 ${r?`animate-spin`:``}`})}),(0,Z.jsx)(z,{type:`button`,onClick:i,variant:`ghost`,size:`icon-sm`,className:`relative after:absolute after:inset-x-0 after:-top-1.5 after:-bottom-1.5 text-foreground/40 hover:text-foreground/70`,"aria-label":`Close panel`,title:`Close panel`,children:(0,Z.jsx)(Xr,{"data-icon":`inline-start`,className:`size-3.5`})})]})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:e})]})]})})})}var No=X.createContext(void 0);function Po(){let e=X.useContext(No);if(e===void 0)throw Error(it(64));return e}var Fo={tabActivationDirection:e=>({"data-activation-direction":e})},Io=X.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=X.useRef([]),[f,p]=X.useState(()=>new Map),[m,h]=si({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=X.useState(()=>new Map),y=X.useRef(void 0),b=X.useCallback(e=>Lo(_,e),[_]),[x,S]=X.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:C,tabActivationDirection:w}=x,T=w,E=!1;C!==m&&(T=Ro(C,m,a,_),E=C!=null&&m!=null&&b(m)==null);let D=E?C:m,O=C!==D||w!==T;st(()=>{O&&S({previousValue:D,tabActivationDirection:T})},[D,O,T]);let k=$e((e,t)=>{t.activationDirection=Ro(m,e,a,_),i?.(e,t),!t.isCanceled&&h(e)}),A=$e((e,t)=>{i?.(e,ut(t,void 0,void 0,{activationDirection:`none`}))}),j=$e((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),M=X.useCallback(e=>f.get(e),[f]),N=X.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),P=X.useMemo(()=>({getTabElementBySelectedValue:b,getTabIdByPanelValue:N,getTabPanelIdByValue:M,onValueChange:k,orientation:a,registerMountedTabPanel:j,setTabMap:v,tabActivationDirection:T,value:m}),[b,N,M,k,a,j,v,T,m]),F=X.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),I=X.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),L=X.useRef(!u),ee=X.useRef(r),te=X.useRef(u),R=X.useRef(!1);st(()=>{if(g)return;function e(e,t){h(e),S({previousValue:e,tabActivationDirection:`none`}),A(e,t),L.current=!1}if(_.size===0){R.current&&m!==null&&!y.current?.isConnected&&e(null,Qe);return}R.current=!0,y.current=_.keys().next().value;let t=F?.disabled,n=F==null&&m!==null;if(!t&&m===ee.current&&(te.current=!1),te.current&&t&&m===ee.current)return;let r=L.current;if(t||n){let n=I??null;if(m===n){L.current=!1;return}let i=Qe;r?i=Ze:t&&(i=nt),e(n,i);return}r&&F!=null&&(A(m,Ze),L.current=!1)},[I,g,A,F,h,_,m]);let z=Ye(`div`,e,{state:{orientation:a,tabActivationDirection:T},ref:t,props:l,stateAttributesMapping:Fo});return(0,Z.jsx)(No.Provider,{value:P,children:(0,Z.jsx)(cn,{elementsRef:d,children:z})})});function Lo(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function Ro(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=Lo(r,e),c=Lo(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var zo=`data-composite-item-active`;function Bo(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=pt(),{ref:i,index:a}=rn(e),o=n===a,s=X.useRef(null),c=rt(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}var Vo=X.createContext(void 0);function Ho(){let e=X.useContext(Vo);if(e===void 0)throw Error(it(65));return e}var Uo=X.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=Po(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=Ho(),{highlightedIndex:v,onHighlightedIndexChange:y}=pt(),b=mn(o),{compositeProps:x,compositeRef:S,index:C}=Bo({metadata:X.useMemo(()=>({disabled:r,id:b,value:a}),[r,b,a])}),T=a===u,E=X.useRef(!1),D=X.useRef(null),O=$e(e=>{D.current?.(),D.current=e?g(e):null});st(()=>{if(E.current){E.current=!1;return}if(!(T&&C>-1&&v!==C))return;let e=_;if(e!=null){let t=H(N(e));if(t&&w(e,t))return}r||y(C)},[T,C,v,y,r,_]);let{getButtonProps:k,buttonRef:A}=dt({disabled:r,native:s,focusableWhenDisabled:!0}),j=d(a),M=X.useRef(!1),P=X.useRef(!1);function F(e){f(a,ut(et,e.nativeEvent,void 0,{activationDirection:`none`}))}function I(e){T||r||F(e)}function L(e){T||r||h&&(!M.current||P.current)&&F(e)}function ee(e){if(T||r)return;M.current=!0,P.current=e.button===0;let t=N(e.currentTarget);function n(){M.current=!1,P.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return Ye(`button`,e,{state:{disabled:r,active:T,orientation:p,tabActivationDirection:m},ref:[t,A,S,O],props:[x,{role:`tab`,"aria-controls":j,"aria-selected":T,id:b,onClick:I,onFocus:L,onPointerDown:ee,[zo]:T?``:void 0,onKeyDownCapture(){E.current=!0}},l,k],stateAttributesMapping:Fo})}),Wo=[];function Go(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=Wo}=e,[p,m]=X.useState(0),h=r!=null,g=X.useRef(null),_=rt(g,c),v=X.useRef([]),y=X.useRef(!1),b=o??p,x=$e((e,t=!1)=>{if((s??m)(e),t){let t=v.current[e];_t(g.current,t,a,n)}}),S=$e(e=>{if(e.size===0||y.current)return;y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)x(i);else if(C(t,b,d)){let e=k(t,{disabledIndices:d});F(t,e)||x(e)}_t(g.current,r,a,n)});st(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(C(e,b,d)){let t=k(e,{disabledIndices:d});F(e,t)||x(t)}},[d,o,b,v,x]);let w=$e((e,t,n)=>i?i(e,t,n,v):n),D=$e(e=>{let o=e.key===`Home`||e.key===`End`;if(!jt.has(e.key)||!l&&o||Ko(e,f)||!g.current)return;let s=a===`rtl`,c=s?en:Bt,p=s?Bt:en,m=n===`vertical`?Zt:c,_=n===`vertical`?$t:p,y=A(e.nativeEvent);if(y!=null&&Mt(y)&&!tn(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let S=b,C=T(v,d),D=E(v,d);r!=null&&(S=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:b,loopFocus:t,maxIndex:D,minIndex:C,onLoop:w,orientation:n,rtl:s}));let O=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,j=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?S=C:e.key===`End`&&(S=D)),S===b&&(O||j)&&(t&&S===D&&O?(S=C,i&&(S=i(e,b,S,v))):t&&S===C&&j?(S=D,i&&(S=i(e,b,S,v))):S=k(v.current,{startingIndex:S,decrement:j,disabledIndices:d})),S!==b&&!F(v.current,S)&&(u&&e.stopPropagation(),(h||o||O||j)&&e.preventDefault(),x(S,!0),queueMicrotask(()=>{v.current[S]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=A(e.nativeEvent);!t||n==null||!Mt(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:b,onHighlightedIndexChange:x,elementsRef:v,onMapChange:S,relayKeyboardEvent:D}}function Ko(e,t){for(let n of Qt)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function qo(e){let{render:t,className:n,style:r,refs:i=ot,props:a=ot,state:o=lt,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=Go({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:fn(),disabledIndices:v,modifierKeys:y}),k=Ye(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=X.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,Z.jsx)(Xe.Provider,{value:A,children:(0,Z.jsx)(cn,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var Jo=X.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=Po(),[d,f]=X.useState(0),[p,m]=X.useState(null),h=X.useRef(new Set),g=X.useRef(new Set),_=X.useRef(null);st(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return _.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),_.current=null}},[p]);let v=$e(e=>(h.current.add(e),()=>{h.current.delete(e)})),y=$e(e=>(g.current.add(e),_.current?.observe(e),()=>{g.current.delete(e),_.current?.unobserve(e)})),b={orientation:c,tabActivationDirection:u},x={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},S=X.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:y,tabsListElement:p}),[n,v,y,p]);return(0,Z.jsx)(Vo.Provider,{value:S,children:(0,Z.jsx)(qo,{render:a,className:r,style:o,state:b,refs:[t,m],props:[x,s],stateAttributesMapping:Fo,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:ot})})});function Yo({className:e,orientation:t=`horizontal`,...n}){return(0,Z.jsx)(Io,{"data-slot":`tabs`,"data-orientation":t,className:U(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Xo=L(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Zo({className:e,variant:t=`default`,...n}){return(0,Z.jsx)(Jo,{"data-slot":`tabs-list`,"data-variant":t,className:U(Xo({variant:t}),e),...n})}function Qo({className:e,...t}){return(0,Z.jsx)(Uo,{"data-slot":`tabs-trigger`,className:U(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function $o(e,t={}){let{axis:n=`y`}=t,r=(0,X.useRef)(new Map),i=(0,X.useRef)(new Map),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)([]),l=(0,X.useRef)([]),u=(0,X.useRef)(null),d=(0,X.useRef)(null),f=(0,X.useCallback)(()=>{if(!e.current)return;let t=[];r.current.forEach((e,n)=>{t[n]={top:e.offsetTop,height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth}});let n=l.current,i=n.length!==t.length;for(let e=0;!i&&e<t.length;e++){let r=n[e],a=t[e];r!==a&&(i=!r||!a||r.top!==a.top||r.left!==a.left||r.width!==a.width||r.height!==a.height)}i&&(l.current=t,c(t))},[e]),p=(0,X.useCallback)(()=>{d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null,f()})},[f]),m=(0,X.useCallback)((e,t)=>{let n=i.current.get(e);if(n&&(n.disconnect(),i.current.delete(e)),t){if(r.current.set(e,t),typeof ResizeObserver<`u`){let n=new ResizeObserver(()=>p());n.observe(t),i.current.set(e,n)}}else r.current.delete(e);p()},[p]),h=(0,X.useCallback)(t=>{let r=t.clientX,i=t.clientY;u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null;let t=e.current;if(!t)return;let a=t.getBoundingClientRect(),s=n===`x`?r:i,c=null,d=1/0,f=null,p=l.current,m=n===`x`?t.scrollLeft:t.scrollTop,h=n===`x`?t.clientLeft:t.clientTop,g=n===`x`?a.left:a.top,_=n===`x`?t.offsetWidth:t.offsetHeight,v=n===`x`?a.width:a.height,y=_>0?v/_:1;for(let e=0;e<p.length;e++){let t=p[e];if(!t)continue;let r=g+(h+(n===`x`?t.left:t.top)-m)*y,i=(n===`x`?t.width:t.height)*y,a=r+i;s>=r&&s<=a&&(f=e);let o=r+i/2,l=Math.abs(s-o);l<d&&(d=l,c=e)}o(f??c)})},[n,e]),g=(0,X.useCallback)(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),o(null)},[]);return(0,X.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>p());return n.observe(t),()=>n.disconnect()},[e,p]),(0,X.useEffect)(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),d.current!==null&&cancelAnimationFrame(d.current),i.current.forEach(e=>{e.disconnect()}),i.current.clear()},[]),{activeIndex:a,setActiveIndex:o,itemRects:s,onMouseMove:h,onMouseLeave:g,registerItem:m,measureItems:f}}var es={normal:`'wght' 400, 'opsz' 14`,medium:`'wght' 450, 'opsz' 15`,semibold:`'wght' 550, 'opsz' 20`,bold:`'wght' 700, 'opsz' 25`},ts={fast:{enter:{type:`spring`,duration:.08,bounce:0},exit:{duration:.06}},moderate:{enter:{type:`spring`,duration:.16,bounce:0},exit:{duration:.12}},slow:{enter:{type:`spring`,duration:.24,bounce:.12},exit:{duration:.16}}},ns=`bg-background shadow-sm`,rs=`rounded-full border border-border/70 bg-sidebar p-0.5 shadow-sm backdrop-blur`,is=`rounded-full`;function as(e,t){return t?e?`text-foreground/75`:`text-foreground`:e?`text-foreground/55`:`text-muted-foreground`}var os=(0,X.createContext)(null);function ss(){let e=(0,X.useContext)(os);if(!e)throw Error(`useTabsSubtle must be used within a TabsSubtle`);return e}function cs({selectedRect:e,hoverRect:t,focusRect:n,isHovering:r,isHoveringSelected:i}){let a=Ke()?{duration:0}:void 0;return(0,Z.jsxs)(u,{features:l,children:[e?(0,Z.jsx)(K.div,{className:U(`pointer-events-none absolute`,ns,is),layout:!0,initial:!1,style:{left:e.left,top:e.top,width:e.width,height:e.height},animate:{opacity:r?.8:1},transition:a??{...ts.moderate.enter,opacity:{duration:.08}}}):null,(0,Z.jsx)(Ge,{children:t&&!i?(0,Z.jsx)(K.div,{className:U(`pointer-events-none absolute`,ns,is),layout:!0,style:{left:t.left,top:t.top,width:t.width,height:t.height},initial:{opacity:0},animate:{opacity:.4},exit:{opacity:0,transition:a??ts.fast.exit},transition:a??{...ts.fast.enter,opacity:{duration:.08}}}):null}),(0,Z.jsx)(Ge,{children:n?(0,Z.jsx)(K.div,{className:U(`pointer-events-none absolute z-20 border border-ring`,is),layout:!0,initial:!1,style:{left:n.left-2,top:n.top-2,width:n.width+4,height:n.height+4},exit:{opacity:0,transition:a??ts.fast.exit},transition:a??{...ts.fast.enter,opacity:{duration:.08}}}):null})]})}var ls=(0,X.forwardRef)(({children:e,selectedIndex:t,onSelect:n,idPrefix:r,activeLabel:i=!1,variant:a=`default`,className:o,...s},c)=>{let l=(0,X.useRef)(null),u=(0,X.useRef)(!1),d=a===`pill`,{activeIndex:f,setActiveIndex:p,itemRects:m,onMouseMove:h,onMouseLeave:g,registerItem:_}=$o(l,{axis:`x`}),v=(0,X.useCallback)((e,t)=>{_(e,t)},[_]),y=(0,X.useCallback)(e=>{u.current=!0,h(e)},[h]),b=(0,X.useCallback)(()=>{u.current=!1,g()},[g]),[x,S]=(0,X.useState)(null),C=t>=0?m[t]:void 0,w=f===null?null:m[f],T=x===null?null:m[x],E=f===t,D=f!==null&&!E,O=(0,X.useMemo)(()=>({registerTab:v,hoveredIndex:f,selectedIndex:t,idPrefix:r,activeLabel:i,variant:a,onSelect:n}),[v,f,t,r,i,a,n]);return(0,Z.jsx)(os.Provider,{value:O,children:(0,Z.jsx)(Yo,{className:`data-horizontal:!flex-row !gap-0.5`,value:t>=0?t:null,onValueChange:e=>{let t=typeof e==`number`?e:Number(e);Number.isInteger(t)&&n(t)},render:(0,Z.jsxs)(Zo,{activateOnFocus:!1,variant:`line`,ref:e=>{l.current=e,typeof c==`function`?c(e):c&&(c.current=e)},onMouseMove:y,onMouseLeave:b,onFocus:e=>{let t=e.target.closest(`[data-proximity-index]`)?.getAttribute(`data-proximity-index`);if(t!=null){let n=Number(t);p(n),S(e.target.matches(`:focus-visible`)?n:null)}},onBlur:e=>{l.current?.contains(e.relatedTarget)||(S(null),!u.current&&p(null))},className:U(`relative flex max-w-full [scrollbar-width:none] items-center gap-0.5 overflow-x-auto select-none [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,d?rs:`-mx-1 -my-1 px-1 py-1`,o),...s,children:[(0,Z.jsx)(cs,{selectedRect:C,hoverRect:w,focusRect:T,isHovering:D,isHoveringSelected:E}),e]})})})});ls.displayName=`TabsSubtle`;var us=(0,X.forwardRef)(({icon:e,label:t,index:n,badge:r,className:i,"aria-label":a,onClick:o,...s},c)=>{let d=(0,X.useRef)(null),{registerTab:f,hoveredIndex:p,selectedIndex:m,idPrefix:h,activeLabel:g,variant:_,onSelect:v}=ss();(0,X.useEffect)(()=>(f(n,d.current),()=>f(n,null)),[n,f]);let y=m===n,b=p===n||y,x=g&&!!e,S=!x||y,C=_===`pill`,w=as(C,b),T=a??(x&&!S?t:void 0),E=(0,Z.jsxs)(`span`,{className:U(`inline-grid whitespace-nowrap`,C?`text-[0.75rem] font-medium`:`text-[0.8125rem]`),children:[(0,Z.jsx)(`span`,{className:`invisible col-start-1 row-start-1 [text-box:trim-both_cap_alphabetic]`,style:{fontVariationSettings:es.semibold},"aria-hidden":`true`,children:t}),(0,Z.jsx)(`span`,{className:U(`col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]`,w),style:{fontVariationSettings:y?es.semibold:es.normal},children:t})]});return(0,Z.jsxs)(Qo,{ref:e=>{let t=e;d.current=t,typeof c==`function`?c(t):c&&(c.current=t)},value:n,"data-proximity-index":n,id:h?`${h}-tab-${n}`:void 0,"aria-controls":h?`${h}-panel-${n}`:void 0,"aria-label":T,className:U(`relative z-10 flex flex-none cursor-pointer items-center border-none !bg-transparent !shadow-none outline-none after:hidden`,C?`h-8 px-2.5`:x?`h-8 px-3`:`h-9 gap-2 px-3`,is,i),...s,onClick:e=>{o?.(e),y&&v(n)},children:[e?(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(e,{"data-icon":`inline-start`,size:C?14:16,strokeWidth:b?2:1.5,className:U(`shrink-0 transition-[color,stroke-width] duration-80`,w)}),r===void 0?null:(0,Z.jsx)(`span`,{className:U(`text-[0.6875rem] tabular-nums transition-colors duration-80`,w),children:r})]}):null,x?null:E,(0,Z.jsx)(u,{features:l,children:(0,Z.jsx)(Ge,{initial:!1,children:x&&S?(0,Z.jsx)(K.span,{className:`ml-2 overflow-hidden`,initial:{clipPath:`inset(0 100% 0 0)`,opacity:0},animate:{clipPath:`inset(0 0% 0 0)`,opacity:1},exit:{clipPath:`inset(0 100% 0 0)`,opacity:0},transition:{...ts.fast.enter,opacity:{duration:.06}},children:E},`label`):null})})]})});us.displayName=`TabsSubtleItem`;var ds=(0,X.forwardRef)(({index:e,selectedIndex:t,idPrefix:n,children:r,className:i,...a},o)=>{let s=t===e;return(0,Z.jsx)(`div`,{ref:o,id:`${n}-panel-${e}`,role:`tabpanel`,"aria-labelledby":`${n}-tab-${e}`,hidden:!s,tabIndex:-1,className:U(`outline-none`,i),...a,children:s?r:null})});ds.displayName=`TabsSubtlePanel`;function fs({active:e=!1,ariaLabel:t,className:n,title:r,...i}){return(0,Z.jsx)(z,{...i,type:`button`,variant:`ghost`,size:`sm`,className:U(Dn,e?An:Cn,n),"aria-label":t,title:r??t})}var ps=`[&_[data-proximity-index]]:!h-7 [&_[data-proximity-index]]:!px-2 [&_[data-proximity-index]]:!text-[0.6875rem]`;function ms({compact:e=!1}={}){let{reopenRightPanel:t,rightPanel:n}=Ji();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`min-[960px]:hidden`,children:(0,Z.jsx)(hs,{compact:e,idPrefix:`right-panel-mobile`})}),(0,Z.jsx)(`div`,{className:`hidden min-[960px]:block`,children:n===null?(0,Z.jsx)(gs,{compact:e,onOpen:t}):null})]})}function hs({compact:e=!1,idPrefix:t=`right-panel`}){let{artifactRuns:n,messages:r,rightPanel:i,setRightPanel:a,resources:o}=Ji(),{workspaceTree:s}=qi();return(0,Z.jsx)(_s,{activePanel:i,onPanelChange:a,resources:o,replRuns:n.flatMap(e=>e.artifacts).filter(e=>e.kind===`ipython`).length,sessionBlocks:Zi(r).length,openUIArtifacts:n.flatMap(e=>e.artifacts).filter(e=>e.kind===`openui-html`).length,workspace:s,idPrefix:t,compact:e})}function gs({compact:e=!1,onOpen:t}){return(0,Z.jsx)(fs,{ariaLabel:`Open side panel`,className:e?`!size-7 !rounded-[7px] !px-0`:`size-9 justify-center px-0`,onClick:t,children:(0,Z.jsx)($a,{className:`size-4`})})}function _s({activePanel:e,onPanelChange:t,resources:n,replRuns:r=0,sessionBlocks:i=0,openUIArtifacts:a=0,workspace:o,idPrefix:s=`right-panel`,compact:c=!1}){let l=Xn(n,o).reduce((e,t)=>e+t.items.length,0),u=(0,X.useMemo)(()=>{let e=i+a;return e>0?e:void 0},[a,i]),d=(0,X.useMemo)(()=>Vn.map(e=>({...e,badge:e.badgeSource===`resources`?l||void 0:e.badgeSource===`artifacts`?u:e.badgeSource===`repl`&&r||void 0})),[r,u,l]),f=d.findIndex(t=>t.id===e),p=(0,X.useMemo)(()=>d.map(e=>({value:e.id,label:e.title,icon:e.icon})),[d]);return(0,Z.jsx)(vs,{"data-testid":`right-panel-inline-launcher`,"data-active-panel":e??`closed`,activePanel:e,options:p,panelOptions:d,idPrefix:s,selectedIndex:f,onSelect:n=>{let r=d.at(n)?.id;r&&t(r===e?null:r)},compact:c})}function vs({activePanel:e,className:t,compact:n=!1,idPrefix:r,onSelect:i,options:a,panelOptions:o,selectedIndex:s,...c}){let l=(0,X.useRef)(null),u=(0,X.useRef)(null),[d,f]=(0,X.useState)(!1),p=(0,X.useCallback)(()=>{let e=l.current,t=u.current;if(!e||!t)return;let n=e.parentElement?.clientWidth??0,r=n>0?n:e.clientWidth;if(r<=0)return;let i=t.firstElementChild,a=Math.max(t.scrollWidth,i instanceof HTMLElement?i.scrollWidth:0,t.getBoundingClientRect().width,i instanceof HTMLElement?i.getBoundingClientRect().width:0);a<=0||f(a>r+1)},[]);(0,X.useLayoutEffect)(()=>{p();let e=l.current,t=u.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(p);return e.parentElement&&n.observe(e.parentElement),n.observe(e),n.observe(t),()=>n.disconnect()},[p,o,s]);let m=(0,X.useCallback)(e=>{let t=o.findIndex(t=>t.id===e);t>=0&&i(t)},[i,o]);return(0,Z.jsxs)(`div`,{ref:l,className:`relative ${d?`w-full`:`w-fit`} min-w-0 max-w-full overflow-hidden ${t??``}`,"data-panel-launcher-mode":d?`dropdown`:`tabs`,...c,children:[d?(0,Z.jsx)(ln,{"aria-label":`Select panel`,className:`w-full min-w-0 max-w-full rounded-full border-border/70 bg-sidebar ${n?`h-7`:``}`,onValueChange:m,options:a,placeholder:`Open panel`,value:e}):(0,Z.jsx)(ls,{activeLabel:!0,className:`w-fit max-w-full ${n?ps:``}`,idPrefix:r,selectedIndex:s,onSelect:i,children:o.map((e,t)=>(0,Z.jsx)(us,{index:t,icon:e.icon,label:e.title,badge:e.badge,"aria-label":e.ariaLabel},e.id))}),(0,Z.jsx)(`div`,{ref:u,"aria-hidden":`true`,className:`pointer-events-none invisible absolute top-0 left-0 -z-10 w-max max-w-none`,"data-panel-launcher-measurement":!0,inert:!0,children:(0,Z.jsx)(ls,{activeLabel:!0,className:`w-max max-w-none ${n?ps:``}`,idPrefix:`${r}-measurement`,selectedIndex:s,onSelect:()=>void 0,children:o.map((e,t)=>(0,Z.jsx)(us,{index:t,icon:e.icon,label:e.title,badge:e.badge,"aria-label":e.ariaLabel},e.id))})})]})}function ys({children:e,dataTestid:t,headerActions:n,icon:r,onClose:i,open:a,title:o}){let s=(0,X.useRef)(null),c=(0,X.useId)(),l=(0,X.useRef)(!1),u=(0,X.useEffectEvent)(e=>{s.current&&e.target===s.current&&s.current.close()});return(0,X.useEffect)(()=>{if(!a)return;let e=s.current;if(!e)return;let t=e=>u(e);return e.addEventListener(`click`,t),()=>e.removeEventListener(`click`,t)},[a]),(0,X.useEffect)(()=>{let e=s.current;if(!e)return;if(!a){e.open&&(l.current=!0,e.close(),l.current=!1);return}let t=window.matchMedia(`(min-width: 960px)`),n=()=>{if(t.matches){e.open&&(l.current=!0,e.close());return}e.open||(e.showModal(),e.focus())};return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[a]),a?(0,Z.jsx)(`dialog`,{ref:s,"data-testid":t,className:`fixed top-[var(--chat-chrome-top)] right-3 bottom-3 m-0 ${Ln} backdrop:bg-black/20 ${Sr}`,"aria-labelledby":c,onClose:()=>{if(l.current){l.current=!1;return}i?.()},children:(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,Z.jsx)(`span`,{id:c,className:`sr-only`,children:o??`Panel`}),o&&(0,Z.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[0.8125rem] font-medium text-foreground/80`,children:[r&&(0,Z.jsx)(r,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:o})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,i&&(0,Z.jsx)(z,{type:`button`,onClick:()=>{let e=s.current;e&&e.open?e.close():i?.()},variant:`ghost`,size:`icon-sm`,className:`relative after:absolute after:top-1/2 after:left-1/2 after:size-10 after:-translate-x-1/2 after:-translate-y-1/2 text-foreground/40 hover:text-foreground/70`,"aria-label":`Close panel`,title:`Close panel`,children:(0,Z.jsx)(Xr,{"data-icon":`inline-start`,className:`size-3.5`})})]})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-2`,children:e})]})}):null}var bs=`(min-width: 960px)`;function xs(e){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>void 0;let t=window.matchMedia(bs);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Ss(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(bs).matches}function Cs(){return!1}function ws(){return(0,X.useSyncExternalStore)(xs,Ss,Cs)}function Ts({handleResourceCanvasResizeStart:e,onClose:t,resourceCanvasWidth:n}){let r=Ji(),i=qi(),{rightPanel:a}=r,o=a!==null,s=ws(),c=a?zn(a):null,l=c?.component,u=c?.loadingSource===`resources`?r.resourcesLoading:c?.loadingSource===`workspace`&&i.workspaceLoading,d=c?.refreshSource===`resources`?r.refreshResources:c?.refreshSource===`workspace`?i.refreshWorkspace:void 0;return(0,Z.jsx)(Z.Fragment,{children:s?(0,Z.jsx)(Mo,{dataTestid:c?.dataTestid,headerLeading:(0,Z.jsx)(hs,{compact:!0,idPrefix:`right-panel-desktop`}),loading:u,onClose:t,onRefresh:d,onResizeStart:e,open:o,title:c?.title??``,titleIcon:c?.icon??Bn,width:n,children:l?(0,Z.jsx)(l,{}):null}):(0,Z.jsx)(ys,{dataTestid:c?.mobileDataTestid,icon:c?.icon,onClose:t,open:o,title:c?.title??``,children:l?(0,Z.jsx)(l,{}):null})})}function Es({projects:e,onRenameSession:t,onDeleteSession:n,onRenameProject:r,onUnregisterProject:i,onForkSessionIntoProject:a,renameTarget:o,setRenameTarget:s,renameTitle:c,setRenameTitle:l,renameProjectTarget:u,setRenameProjectTarget:d,renameProjectName:f,setRenameProjectName:p,deleteTarget:m,setDeleteTarget:h,unregisterTarget:g,setUnregisterTarget:_,forkTarget:v,setForkTarget:y,forkProjectId:b,setForkProjectId:x}){let S=(0,X.useMemo)(()=>e.flatMap(e=>e.projectId===v?.projectId?[]:[{value:e.projectId,label:`${e.name} — ${e.pathLabel}`,icon:zr}]),[v?.projectId,e]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yn,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,Z.jsxs)(bn,{children:[(0,Z.jsx)(xn,{children:`Rename session`}),(0,Z.jsx)(En,{children:`Choose a local display title for this Fleet Prime session.`}),(0,Z.jsx)(Xi,{value:c,onChange:e=>l(e.target.value),"aria-label":`Session title`,autoFocus:!0}),(0,Z.jsxs)(Nn,{children:[(0,Z.jsx)(jn,{children:`Cancel`}),(0,Z.jsx)(kn,{disabled:!c.trim(),onClick:()=>{o&&c.trim()&&(t(o.sessionId,c.trim()),s(null))},children:`Rename`})]})]})}),(0,Z.jsx)(yn,{open:u!==null,onOpenChange:e=>!e&&d(null),children:(0,Z.jsxs)(bn,{children:[(0,Z.jsx)(xn,{children:`Rename project`}),(0,Z.jsx)(En,{children:`This changes the display name only. The registered directory stays the same.`}),(0,Z.jsx)(Xi,{value:f,onChange:e=>p(e.target.value),"aria-label":`Project name`,autoFocus:!0}),(0,Z.jsxs)(Nn,{children:[(0,Z.jsx)(jn,{children:`Cancel`}),(0,Z.jsx)(kn,{disabled:!f.trim()||!r,onClick:()=>{u&&f.trim()&&(r?.(u.projectId,f.trim()),d(null))},children:`Rename`})]})]})}),(0,Z.jsx)(yn,{open:m!==null,onOpenChange:e=>!e&&h(null),children:(0,Z.jsxs)(bn,{children:[(0,Z.jsx)(xn,{children:`Delete session?`}),(0,Z.jsx)(En,{children:`This removes the Fleet Prime session and its managed session artifacts. This cannot be undone.`}),(0,Z.jsxs)(Nn,{children:[(0,Z.jsx)(jn,{children:`Cancel`}),(0,Z.jsx)(kn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{m&&n(m.sessionId),h(null)},children:`Delete`})]})]})}),(0,Z.jsx)(yn,{open:g!==null,onOpenChange:e=>!e&&_(null),children:(0,Z.jsxs)(bn,{children:[(0,Z.jsx)(xn,{children:`Unregister project?`}),(0,Z.jsx)(En,{children:`The directory and its sessions remain intact. Existing sessions will move to Unassigned until the directory is registered again.`}),(0,Z.jsxs)(Nn,{children:[(0,Z.jsx)(jn,{children:`Cancel`}),(0,Z.jsx)(kn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{g&&i?.(g.projectId),_(null)},children:`Unregister`})]})]})}),(0,Z.jsx)(Xt,{open:v!==null,onOpenChange:e=>!e&&y(null),children:(0,Z.jsxs)(Kt,{className:`sm:max-w-md`,children:[(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(qt,{children:`Fork session into project`}),(0,Z.jsx)(Yt,{children:`Create a new Fleet Prime session in another registered project.`})]}),(0,Z.jsx)(`div`,{className:`py-2`,children:(0,Z.jsx)(ln,{value:b??null,onValueChange:e=>x(e),options:S,placeholder:`Select a project…`,"aria-label":`Target project`})}),(0,Z.jsxs)(Wt,{children:[(0,Z.jsx)(z,{type:`button`,variant:`outline`,onClick:()=>y(null),children:`Cancel`}),(0,Z.jsx)(z,{type:`button`,disabled:!v||!b||!a,onClick:()=>{!v||!b||(a?.(v.sessionId,b),y(null))},children:`Fork session`})]})]})})]})}var Ds=e(n(),1),Os=(e,t,n)=>{let r=t.trim().toLocaleLowerCase();if(!r)return!0;let i=[e,...n].join(` `).toLocaleLowerCase(),a=0;for(let e of i)if(e===r[a]&&(a+=1),a===r.length)return!0;return!1},ks=(0,X.createContext)(null),As=(0,X.createContext)(null);function js(e){let t=(0,X.useContext)(ks);if(!t)throw Error(`${e} must be used within <Combobox>`);return t}function Ms(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&typeof n==`object`&&(n.current=t)}}function Ns({children:e,value:t,defaultValue:n,onValueChange:r,open:i,defaultOpen:a=!1,onOpenChange:o,query:s,defaultQuery:c=``,onQueryChange:l,filter:u=Os,disabled:d=!1,className:f}){let p=Ke()??!1,m=(0,X.useId)(),h=(0,X.useRef)(null),g=(0,X.useRef)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(null),[y,b]=(0,X.useState)(n),[x,S]=(0,X.useState)(a),[C,w]=(0,X.useState)(c),[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(new Map),k=t!==void 0,A=i!==void 0,j=s!==void 0,M=k?t:y,N=A?i:x,P=j?s:C,F=(0,X.useCallback)(e=>{j||w(e),l?.(e)},[l,j]),I=(0,X.useCallback)((e,t=!1)=>{d&&e||(A||S(e),o?.(e),e||F(``),t&&requestAnimationFrame(()=>v.current?.focus({preventScroll:!0})))},[d,o,A,F]),L=(0,X.useEffectEvent)(I),ee=(0,X.useCallback)(e=>{O(t=>{let n=t.get(e.value);if(n?.label===e.label&&n.disabled===e.disabled&&n.id===e.id&&n.ref===e.ref&&n.groupId===e.groupId&&n.keywords.join(`\0`)===e.keywords.join(`\0`))return t;let r=new Map(t);return r.set(e.value,e),r})},[]),te=(0,X.useCallback)(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),R=(0,X.useMemo)(()=>Array.from(D.values()).filter(e=>u(e.value,P,[e.label,...e.keywords])),[u,D,P]),z=(0,X.useMemo)(()=>R.filter(e=>!e.disabled),[R]),B=(0,X.useMemo)(()=>new Set(R.map(e=>e.value)),[R]),V=(0,X.useMemo)(()=>new Set(R.map(e=>e.groupId)),[R]),H=(0,X.useCallback)(e=>{D.get(e)?.disabled||(k||b(e),r?.(e),I(!1,!0))},[D,r,I,k]),W=(0,X.useCallback)(e=>{if(!z.length){E(null);return}if(e===`first`){E(z[0].value);return}if(e===`last`){E(z.at(-1)?.value??null);return}let t=z.findIndex(e=>e.value===T),n=t<0?e===1?0:z.length-1:(t+e+z.length)%z.length;E(z[n].value)},[T,z]),ne=(0,X.useCallback)(()=>{T&&H(T)},[T,H]);(0,X.useEffect)(()=>{if(!N)return;let e=M&&B.has(M)?M:null,t=T&&B.has(T)?T:null;E(t??e??z[0]?.value??null)},[T,z,N,M,B]),(0,X.useEffect)(()=>{N&&requestAnimationFrame(()=>v.current?.focus({preventScroll:!0}))},[N]),(0,X.useEffect)(()=>{if(!T||!N)return;let e=D.get(T)?.ref.current,t=e?.closest(`[role='listbox']`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();n.top<r.top?t.scrollTop-=r.top-n.top:n.bottom>r.bottom&&(t.scrollTop+=n.bottom-r.bottom)},[T,D,N]),(0,X.useEffect)(()=>{if(!N)return;let e=e=>h.current?.contains(e)||_.current?.contains(e),t=t=>{e(t.target)||L(!1)},n=t=>{e(t.target)||L(!1)},r=e=>{e.key===`Escape`&&(e.preventDefault(),L(!1,!0))};return window.addEventListener(`pointerdown`,t),window.addEventListener(`focusin`,n),window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`pointerdown`,t),window.removeEventListener(`focusin`,n),window.removeEventListener(`keydown`,r)}},[N]);let G=T?D.get(T):void 0,re=(0,X.useMemo)(()=>({open:N,setOpen:I,value:M,select:H,query:P,setQuery:F,activeValue:T,setActiveValue:E,moveActive:W,selectActive:ne,registerItem:ee,unregisterItem:te,labelFor:e=>e===void 0?void 0:D.get(e)?.label,isVisible:e=>!P.trim()||B.has(e),hasVisibleItems:e=>V.has(e),visibleCount:R.length,activeItemId:G?.id,triggerId:`${m}-trigger`,listId:`${m}-list`,inputId:`${m}-input`,disabled:d,reduce:p,triggerRef:g,contentRef:_,inputRef:v,activeLayoutId:`${m}-active`}),[G?.id,T,m,d,D,W,N,P,p,ee,H,ne,te,I,F,M,R.length,V,B]);return(0,Z.jsx)(ks.Provider,{value:re,children:(0,Z.jsx)(`div`,{ref:h,className:U(`relative w-full`,f),children:e})})}var Ps={type:`spring`,duration:.5,bounce:.22},Fs=8;function Is({children:e,side:t=`bottom`,align:n=`start`,sideOffset:r=6,avoidCollisions:i=!0,className:a}){let o=js(`ComboboxContent`),s=(0,X.useRef)(null),c=Le(),[l,u]=(0,X.useState)(t),[d,f]=(0,X.useState)(!1),p=Ht(),m=Math.min(p+2,8),h=Ve(o.triggerRef,s,c);if((0,X.useLayoutEffect)(()=>{if(!c)return;let e=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(e)},[c]),(0,X.useLayoutEffect)(()=>{if(!o.open||!h)return;if(!i){u(t);return}let e=window.innerHeight-(h.trigger.top+h.trigger.height),n=h.trigger.top;t===`bottom`&&e<h.content.height+r&&n>e?u(`top`):t===`top`&&n<h.content.height+r&&e>n?u(`bottom`):u(t)},[i,o.open,h,t,r]),!c)return null;let g=h?.trigger.left??0,_=h?.trigger.width??0,v=h?.content.width??_,y=n===`end`?g+_-v:n===`center`?g+(_-v)/2:g,b=Math.max(Fs,window.innerWidth-v-Fs),x=Math.min(Math.max(y,Fs),b),S=h?.content.height??0;return(0,Ds.createPortal)((0,Z.jsx)(K.div,{ref:o.contentRef,"data-combobox-content":``,"data-side":l,"aria-hidden":!o.open,inert:!o.open,initial:!1,animate:{opacity:+!!o.open,y:o.open?l===`bottom`?r:-r:0},transition:o.reduce||!d?{duration:0}:Ps,layout:`size`,style:{height:o.open?S:0,left:x,top:l===`bottom`&&h?h.trigger.top+h.trigger.height:void 0,bottom:l===`top`&&h?window.innerHeight-h.trigger.top:void 0,minWidth:_,pointerEvents:o.open?`auto`:`none`,transformOrigin:l===`bottom`?`top`:`bottom`,visibility:h?`visible`:`hidden`,"--combobox-trigger-width":`${_}px`},className:U(`fixed z-[9999] w-(--combobox-trigger-width) overflow-hidden rounded-xl text-popover-foreground outline-none will-change-[height,transform]`,Rt(m,3),a),children:(0,Z.jsx)(Ut,{value:m,children:(0,Z.jsx)(K.div,{ref:s,initial:!1,animate:{opacity:+!!o.open},transition:o.reduce||!d?{duration:0}:Ps,children:e})})}),document.body)}function Ls({children:e,ariaLabel:t=`Options`,className:n}){let r=js(`ComboboxList`);return(0,Z.jsx)(`div`,{id:r.listId,role:`listbox`,"aria-label":t,className:U(`relative isolate max-h-64 overflow-y-auto overscroll-contain p-1.5 [-ms-overflow-style:none] scrollbar-none [&::-webkit-scrollbar]:hidden`,n),children:e})}function Rs({children:e,className:t}){let n=js(`ComboboxGroup`),r=(0,X.useId)();return(0,Z.jsx)(As.Provider,{value:r,children:(0,Z.jsx)(`fieldset`,{hidden:!n.hasVisibleItems(r),className:U(`m-0 min-w-0 border-0 p-0 py-0.5`,t),children:e})})}function zs({children:e,className:t}){let n=(0,X.useContext)(As),r=U(`w-full px-2 py-1.5 text-[0.68rem] font-medium uppercase tracking-[0.12em] text-muted-foreground`,t);return n?(0,Z.jsx)(`legend`,{className:r,children:e}):(0,Z.jsx)(`div`,{className:r,children:e})}function Bs({value:e,children:t,textValue:n,keywords:r=[],disabled:i=!1,onSelect:a,className:o}){let s=js(`ComboboxItem`),c=(0,X.useContext)(As),l=(0,X.useId)(),u=(0,X.useRef)(null),d=n??(typeof t==`string`?t:e),f=s.isVisible(e),p=s.activeValue===e,m=s.value===e,h=r.join(`\0`),g=(0,X.useMemo)(()=>h?h.split(`\0`):[],[h]),{registerItem:_,unregisterItem:v}=s;return(0,X.useLayoutEffect)(()=>(_({value:e,label:d,keywords:g,disabled:i,groupId:c,id:l,ref:u}),()=>v(e)),[i,c,l,d,g,_,v,e]),f?(0,Z.jsxs)(`button`,{ref:u,id:l,type:`button`,role:`option`,"aria-selected":m,disabled:i,tabIndex:-1,"data-combobox-item":``,"data-active":p||void 0,"data-selected":m||void 0,onPointerMove:()=>{i||s.setActiveValue(e)},onPointerDown:e=>e.preventDefault(),onClick:()=>{i||(a?.(e),s.select(e))},className:U(`relative flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm outline-none transition-colors duration-150`,p?`text-foreground`:`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-45`,o),children:[p?(0,Z.jsx)(K.span,{"aria-hidden":!0,layoutId:s.activeLayoutId,className:`absolute inset-0 -z-10 rounded-lg bg-muted`,transition:s.reduce?{duration:0}:Me}):null,(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),(0,Z.jsx)(K.span,{"aria-hidden":!0,initial:!1,animate:{opacity:+!!m,transform:m?`scale(1)`:`scale(0.82)`},transition:s.reduce?{duration:0}:{duration:.14,ease:Pe},className:`grid size-5 shrink-0 place-items-center text-foreground`,children:(0,Z.jsx)(Qn,{className:`size-4`})})]}):null}function Vs({children:e=`No options found.`,className:t}){return js(`ComboboxEmpty`).visibleCount>0?null:(0,Z.jsx)(`div`,{role:`status`,className:U(`px-3 py-8 text-center text-sm text-muted-foreground`,t),children:e})}function Hs({children:e,className:t,showIndicator:n=!0}){let r=js(`ComboboxTrigger`);return(0,Z.jsxs)(`div`,{ref:r.triggerRef,id:r.triggerId,"data-state":r.open?`open`:`closed`,onPointerDown:e=>{r.disabled||e.target===r.inputRef.current||(e.preventDefault(),r.inputRef.current?.focus({preventScroll:!0}),r.setOpen(!0))},className:U(`relative z-20 flex h-10 w-full min-w-52 cursor-text items-center justify-between gap-3 rounded-xl border border-border bg-transparent px-3 text-sm text-foreground transition-[border-color] hover:border-(--color-border-strong)`,`focus-within:ring-2 focus-within:ring-foreground/20`,r.disabled&&`pointer-events-none opacity-50`,t),children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:e}),n?(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-muted-foreground`,children:(0,Z.jsx)(Va,{className:`size-4`})}):null]})}function Us({ref:e,className:t,wrapperClassName:n,"aria-label":r=`Search options`,onChange:i,onClick:a,onFocus:o,onKeyDown:s,onPointerDown:c,placeholder:l=`Search…`,...u}){let d=js(`ComboboxInput`),f=d.labelFor(d.value),p=e=>{s?.(e),!e.defaultPrevented&&(e.key===`ArrowDown`?(e.preventDefault(),d.setOpen(!0),d.moveActive(1)):e.key===`ArrowUp`?(e.preventDefault(),d.setOpen(!0),d.moveActive(-1)):e.key===`Home`&&d.open?(e.preventDefault(),d.moveActive(`first`)):e.key===`End`&&d.open?(e.preventDefault(),d.moveActive(`last`)):e.key===`Enter`?(e.preventDefault(),d.open?d.selectActive():d.setOpen(!0)):e.key===`Escape`&&d.open&&(e.preventDefault(),d.setOpen(!1,!0)))};return(0,Z.jsxs)(`div`,{className:U(`flex min-w-0 flex-1 items-center gap-2`,n),children:[(0,Z.jsx)(qr,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`input`,{...u,ref:Ms(e,d.inputRef),id:d.inputId,role:`combobox`,"aria-label":r,"aria-autocomplete":`list`,"aria-expanded":d.open,"aria-controls":d.listId,"aria-activedescendant":d.open?d.activeItemId:void 0,autoComplete:`off`,disabled:d.disabled,value:d.open?d.query:f??``,placeholder:l,onPointerDown:e=>{c?.(e),!(e.defaultPrevented||d.open)&&(e.preventDefault(),d.inputRef.current?.focus({preventScroll:!0}),d.setOpen(!0))},onFocus:e=>{d.setOpen(!0),o?.(e)},onClick:e=>{d.setOpen(!0),a?.(e)},onChange:e=>{d.setOpen(!0),d.setQuery(e.target.value),i?.(e)},onKeyDown:p,className:U(`h-10 min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed`,t)})]})}var Ws=`https://docs.qredence.ai`,Gs=`fleet-prime:v1:sidebar-expanded-projects`,Ks=[],qs=`new-session:`,Js=`project:`,Ys=`session:`;function Xs(e){return`${Js}${e}`}function Zs(e){return`${Ys}${e}`}function Qs(e){return`${qs}${e}`}function $s(e,t){return e.startsWith(t)?e.slice(t.length):null}function ec(e){return wr(Dr({sessionId:e.sessionId,title:e.title,firstMessage:e.firstMessage}))||Ar(e.sessionId)}function tc(e,t){let n=ec(e);if(!t)return n;let r=0;for(let e of t)ec(e)===n&&(r+=1);return Nr(n,e.sessionId,r)}function nc(e,t){return`${e.projectId?t.get(e.projectId)?.name??`Unassigned`:`Unassigned`} · ${e.status===`idle`?`Ready`:e.status} · ${`${String(e.messageCount)} ${e.messageCount===1?`message`:`messages`}`}`}function rc(e){let t=Date.parse(e);if(!Number.isFinite(t))return`Earlier`;let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=Math.floor((r-new Date(t).setHours(0,0,0,0))/864e5);return i<=0?`Today`:i===1?`Yesterday`:`Earlier`}function ic(e){return e.hasChildren?`${e.name}/`:e.name}function ac(e,t){return e instanceof Error&&e.message.trim()?e.message:t}function oc(e){let t=$r(Gs);if(!t)return e?[Xs(e)]:[];try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return e?[Xs(e)]:[]}}function sc({createOpen:e,setCreateOpen:t,directoryBrowser:n,setDirectoryBrowser:r,directoryBrowseLoading:i,directoryBrowseError:a,setDirectoryBrowseError:o,onBrowseDirectories:s,directoryToken:c,setDirectoryToken:l,createName:u,setCreateName:d,createPath:f,setCreatePath:p,loadDirectories:m,createSubmitting:h,createSubmitError:g,setCreateSubmitError:_,submitCreate:v}){let y=(0,X.useId)(),b=(0,X.useId)(),x=(0,X.useId)(),S=n?.pathLabel??f,C=!!(c||f.trim().startsWith(`/`)),w=()=>{r(null),l(void 0),p(``),o(null)},T=()=>{h||(w(),d(``),_(null),t(!1))};return(0,Z.jsx)(Xt,{open:e,onOpenChange:e=>{e?t(!0):T()},children:(0,Z.jsxs)(Kt,{className:`sm:max-w-xl`,children:[(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(qt,{children:`Add project`}),(0,Z.jsx)(Yt,{children:`Choose the local directory that owns this project's sessions. Browse the server filesystem or paste an absolute path.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-sm font-medium`,htmlFor:y,children:`Project name`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Optional`})]}),(0,Z.jsx)(Xi,{id:y,value:u,onChange:e=>d(e.target.value),placeholder:`e.g. Fleet Prime`,"aria-label":`Project name`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-sm font-medium`,htmlFor:b,children:`Local directory`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Required`})]}),(0,Z.jsx)(Xi,{id:b,value:f,onChange:e=>{p(e.target.value),l(void 0),r(null),o(null),_(null)},placeholder:`/absolute/path/to/project`,"aria-label":`Project directory`,"aria-describedby":x,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`h-10 font-mono text-xs`}),(0,Z.jsx)(`p`,{id:x,className:`text-xs text-muted-foreground`,children:`Browse to select a directory, or paste an absolute path. The server validates the final choice before registering it.`})]}),i&&!n?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-dashed px-3 py-4 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(wn,{className:`size-4`}),`Loading directories…`]}):null,n?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border bg-muted/20`,"data-testid":`project-directory-browser`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-primary/10 text-primary`,children:(0,Z.jsx)(Rr,{className:`size-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Selected directory`}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-foreground`,title:S,children:S})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-2 py-1 text-[0.6875rem] font-medium text-primary`,children:`Selected`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 border-t p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:`Browse child directories`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open a folder to make it the selected directory.`})]}),n.parentToken?(0,Z.jsxs)(z,{type:`button`,size:`sm`,variant:`outline`,disabled:i,onClick:()=>void m({token:n.parentToken??void 0}),"aria-label":`Go up one directory`,title:`Go up one directory`,children:[(0,Z.jsx)(Re,{className:`size-3.5`}),`Up`]}):null]}),i?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-dashed px-3 py-4 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(wn,{className:`size-4`}),`Loading directories…`]}):n.entries.length===0?(0,Z.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-4 text-center text-sm text-muted-foreground`,children:`No child directories here.`}):(0,Z.jsxs)(Ns,{value:c,onValueChange:e=>{n.entries.find(t=>t.directoryToken===e)&&m({token:e})},children:[(0,Z.jsx)(Hs,{className:`h-10 bg-background`,children:(0,Z.jsx)(Us,{"aria-label":`Search child directories`,placeholder:`Choose a child directory…`,className:`text-xs`})}),(0,Z.jsx)(Is,{className:`w-[min(32rem,calc(100vw-3rem))]`,children:(0,Z.jsxs)(Ls,{ariaLabel:`Child directories`,children:[(0,Z.jsxs)(Rs,{children:[(0,Z.jsx)(zs,{children:`Child directories`}),n.entries.map(e=>(0,Z.jsx)(Bs,{value:e.directoryToken,textValue:`${e.name} ${e.pathLabel}`,keywords:[e.pathLabel],children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.jsx)(Ya,{className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:ic(e)}),(0,Z.jsx)(`span`,{className:`block truncate text-[0.6875rem] text-muted-foreground`,title:e.pathLabel,children:e.pathLabel})]})]})},e.directoryToken))]}),(0,Z.jsx)(Vs,{children:`No matching directories.`})]})})]})]})]}):s?(0,Z.jsxs)(z,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void m({}),className:`w-full justify-start`,children:[(0,Z.jsx)(Rr,{className:`size-4`}),`Browse directories`]}):null,a?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive`,role:`alert`,children:[(0,Z.jsx)(Yr,{className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{children:a}),(0,Z.jsx)(z,{type:`button`,variant:`link`,size:`xs`,className:`mt-1 h-auto p-0 text-destructive`,onClick:()=>void m(n?{token:n.directoryToken}:{}),children:`Try again`})]})]}):null,g?(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:g}):null]}),(0,Z.jsxs)(Wt,{children:[(0,Z.jsx)(z,{type:`button`,variant:`outline`,disabled:h,onClick:T,children:`Cancel`}),(0,Z.jsx)(z,{type:`button`,disabled:!C||h,onClick:()=>void v(),children:h?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wn,{className:`size-3.5`}),`Adding project…`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ja,{className:`size-3.5`}),`Add project`]})})]})]})})}function cc({threads:e,query:t,activeId:n,onQueryChange:r,onSelect:i,className:a,...o}){let s=e.filter(e=>`${e.title} ${e.preview} ${(e.keywords??[]).join(` `)}`.toLowerCase().includes(t.toLowerCase())),c=s.filter(e=>e.pinned),l=[...new Set(s.flatMap(e=>e.pinned?[]:[e.group]))],u=[...c,...l.flatMap(e=>s.filter(t=>!t.pinned&&t.group===e))],[d,f]=(0,X.useState)(null),p=e=>{if(u.length===0)return;let t=u.findIndex(e=>e.id===d),n=u[((t===-1?e>0?-1:0:t)+e+u.length)%u.length];f(n?n.id:null)},m=e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),p(1)):e.key===`ArrowUp`?(e.preventDefault(),p(-1)):e.key===`Enter`&&d&&(e.preventDefault(),i?.(d)))},h=e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{f(e.id),i?.(e.id)},className:U(`flex flex-col gap-0.5 rounded-xl px-2 py-1 text-start transition-colors`,e.id===d?`bg-foreground/[0.05]`:e.id===n?`bg-foreground/[0.02] hover:bg-foreground/[0.03]`:`hover:bg-foreground/[0.03]`),children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.pinned&&(0,Z.jsx)(eo,{className:`text-foreground/30 size-2.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem]`,children:e.title})]}),(0,Z.jsx)(`span`,{className:`text-foreground/35 truncate text-xs`,children:e.preview})]},e.id);return(0,Z.jsxs)(`div`,{"data-slot":`thread-search`,className:U(ni,`flex w-full max-w-sm flex-col gap-1.5 rounded-2xl p-3`,a),...o,children:[(0,Z.jsxs)(`div`,{className:U(ti,`flex items-center gap-2 rounded-xl px-2.5 py-1.5`),children:[(0,Z.jsx)(qr,{className:`text-foreground/30 size-3.5 shrink-0`}),(0,Z.jsx)(`input`,{value:t,onChange:e=>{f(null),r?.(e.target.value)},onKeyDown:m,placeholder:`Search threads`,"aria-label":`Search threads`,className:`text-foreground/85 placeholder:text-foreground/30 min-w-0 flex-1 bg-transparent text-base outline-none md:text-[0.8125rem]`})]}),c.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:U(`font-mono text-[0.6875rem] tracking-tight`,`text-foreground/25 px-2 pb-1`),children:`pinned`}),c.map(h)]}),l.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:U(ai,`text-foreground/25 px-2 pb-1`),children:e}),s.flatMap(t=>!t.pinned&&t.group===e?[h(t)]:[])]},e)),s.length===0&&(0,Z.jsxs)(`span`,{className:`text-foreground/30 px-2 py-4 text-center text-xs`,children:[`No thread matches “`,t,`”`]})]})}var lc=X.createContext(void 0);function uc(e){let t=X.useContext(lc);if(t===void 0&&!e)throw Error(it(47));return t}var dc={...vt,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},fc=class extends ee{constructor(e,t,n){let r=new xt;super(pc(e,r,t,n),mc(r),dc)}setOpen=(e,t)=>{let n=t.reason===tt,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=gt(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};bt(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Ds.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function pc(e,t,n,r=!1){let i={...Et(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=Ot(t,n,r),i}function mc(e){return{popupRef:X.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:X.createRef(),beforeContentFocusGuardRef:X.createRef(),stickIfOpenTimeout:new D,triggerElements:e}}function hc({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=_c(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Jt(u,d),Nt(u);let{forceUnmount:m}=Ft(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),X.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),X.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,ut(ct))}),[m,u]);let h=d||f;return(0,Z.jsxs)(lc.Provider,{value:u,children:[s&&(0,Z.jsx)(At,{handle:s,store:u}),h&&(0,Z.jsx)(vc,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function gc(e){return uc(!0)?(0,Z.jsx)(hc,{props:e}):(0,Z.jsx)(mt,{children:(0,Z.jsx)(hc,{props:e})})}function _c(e,t){let n=Ct((e,n)=>new fc(t,e,n));return X.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function vc({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=It(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return yt(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}function yc(e,t){let n=X.useRef(null);function r(t){Ds.flushSync(()=>{e.setOpen(!1,ut(at,t.nativeEvent,t.currentTarget))}),V(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&O(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{Ds.flushSync(()=>{e.setOpen(!1,ut(at,n.nativeEvent,n.currentTarget))});let i=j(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&w(r,i);){let e=i;if(i=B(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var bc=X.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=uc(!0),h=Tn(s)??m;if(!h)throw Error(it(74));let g=mn(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=X.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=St(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=gn(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:vn(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=sn(v,{stickIfOpen:T}),A=on(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:N,buttonRef:P}=dt({disabled:a,native:o}),F={open(e){return e&&w===`trigger-press`?Gt.open(e):Tt.open(e)}},{preFocusGuardRef:L,handlePreFocusGuardFocus:ee,handleFocusTargetFocus:te}=yc(h,x),R=Ye(`button`,e,{state:{disabled:a,open:y},ref:[P,t,S,x],props:[k.reference,O,j,A,{[M]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,N],stateAttributesMapping:F}),z=(0,Z.jsx)(X.Fragment,{children:R},g);return C&&!D?(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsx)(I,{ref:L,onFocus:ee}),z,(0,Z.jsx)(I,{ref:h.context.triggerFocusTargetRef,onFocus:te})]}):z}),xc=X.createContext(void 0);function Sc(){let e=X.useContext(xc);if(e===void 0)throw Error(it(45));return e}var Cc=X.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return uc().useState(`mounted`)||n?(0,Z.jsx)(xc.Provider,{value:n,children:(0,Z.jsx)(R,{ref:t,...r})}):null}),wc=X.createContext(void 0);function Tc(){let e=X.useContext(wc);if(!e)throw Error(it(46));return e}var Ec=X.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=P,..._}=e,v=uc(),y=Sc(),b=Vt(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=X.useRef(null),N=ft(O),F=nn({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),I=x.useState(`domReferenceElement`);st(()=>{let e=I,t=M.current;if(e&&(M.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return N(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,N,v]);let L=E===!0&&w!==`trigger-hover`;an(C&&L,D===`touch`,O,T);let ee=v.useStateSetter(`positionerElement`),R={open:C,side:F.side,align:F.align,anchorHidden:F.anchorHidden,instant:k},z=dn(e,R,{styles:F.positionerStyles,transitionStatus:A,props:_,refs:[t,ee],hidden:!S,inert:!C});return(0,Z.jsxs)(wc.Provider,{value:F,children:[S&&L&&(0,Z.jsx)(Dt,{inert:te(!C),cutout:T}),(0,Z.jsx)(kt,{id:b,children:z})]})}),Dc=X.createContext(void 0);function Oc(){let[e,t]=X.useState(0),n=$e(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:X.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var kc=X.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=uc(),l=Tc(),u=un(!0)!=null,{context:d,hasClosePart:f}=Oc(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);qe({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),hn(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Pt(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M={open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},N=Ye(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...wt,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&jt.has(e.key)&&e.stopPropagation()}},pn(g),s],stateAttributesMapping:ht});return(0,Z.jsx)(Lt,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:Je(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(Dc.Provider,{value:d,children:N})})}),Ac=2;function jc({...e}){return(0,Z.jsx)(gc,{"data-slot":`popover`,...e})}function Mc({...e}){return(0,Z.jsx)(bc,{"data-slot":`popover-trigger`,...e})}function Nc({className:e,children:t,align:n=`center`,alignOffset:r=0,side:i=`bottom`,sideOffset:a=4,...o}){let s=Ht(),c=Math.min(s+Ac,8);return(0,Z.jsx)(Cc,{children:(0,Z.jsx)(Ec,{align:n,alignOffset:r,side:i,sideOffset:a,className:`isolate z-50`,children:(0,Z.jsx)(kc,{"data-slot":`popover-content`,className:U(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg p-2.5 text-sm outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,Rt(c,3),ri,e),...o,children:(0,Z.jsx)(Ut,{value:c,children:t})})})})}function Pc({trigger:e,children:t,contentId:n,open:r,defaultOpen:i,onOpenChange:a,side:o=`top`,align:s=`start`,sideOffset:c=6,className:l,overlay:u=!1}){let d=(0,X.useId)(),f=n??d,[p,m]=(0,X.useState)(i??!1),h=r??p;return(0,Z.jsxs)(jc,{open:h,onOpenChange:e=>{r===void 0&&m(e),a?.(e)},children:[(0,X.isValidElement)(e)?(0,Z.jsx)(Mc,{render:e,"aria-controls":f,className:`inline-flex`}):(0,Z.jsx)(Mc,{render:(0,Z.jsx)(z,{type:`button`,variant:`ghost`,children:e}),"aria-controls":f,className:`inline-flex`}),u&&h?(0,Z.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/20`,"aria-hidden":`true`}):null,(0,Z.jsx)(Nc,{id:f,side:o,align:s,sideOffset:c,className:U(`max-h-[min(320px,var(--available-height,320px))] max-w-[calc(100vw-16px)] min-w-[180px] overflow-y-auto overscroll-contain p-1`,l),children:t})]})}var Fc=`(max-width: 767px)`,Ic=`b`,Lc={duration:.36,ease:Fe},Rc={type:`spring`,stiffness:380,damping:35,mass:.75},zc={duration:.18,ease:Pe},Bc={closed:{opacity:0,clipPath:`inset(0 0 100% 0 round 8px)`,transition:{duration:.14,ease:Pe,staggerChildren:.025,staggerDirection:-1}},open:{opacity:1,clipPath:`inset(0 0 0% 0 round 8px)`,transition:{duration:.2,delayChildren:.035,ease:Pe,staggerChildren:.045}}},Vc={closed:{opacity:0,y:-6,filter:`blur(3px)`},open:{opacity:1,y:0,filter:`blur(0px)`,transition:zc}},Hc={duration:.16,ease:Pe},Uc=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex='-1'])`].join(`,`);function Wc(e){let t=window.matchMedia(Fc);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Gc(){return window.matchMedia(Fc).matches}function Kc(){return!1}function qc(){return(0,X.useSyncExternalStore)(Wc,Gc,Kc)}var Jc=(0,X.createContext)(null),Yc=(0,X.createContext)(null);function Xc(){let e=(0,X.useContext)(Jc);if(!e)throw Error(`useAnimatedSidebar must be used inside AnimatedSidebarProvider.`);return e}function Zc(){let e=(0,X.useContext)(Yc);if(!e)throw Error(`Animated Sidebar parts must be used inside AnimatedSidebar.`);return e}function Qc({children:e,open:t,defaultOpen:n=!0,onOpenChange:r,openMobile:i,defaultOpenMobile:a=!1,onOpenMobileChange:o,className:s,style:c,...l}){let[u,d]=(0,X.useState)(n),[f,p]=(0,X.useState)(a),m=qc(),h=Ke()??!1,g=(0,X.useId)(),_=(0,X.useRef)(null),v=t??u,y=i??f,b=(0,X.useCallback)(e=>{t===void 0&&d(e),r?.(e)},[r,t]),x=(0,X.useCallback)(e=>{i===void 0&&p(e),o?.(e)},[o,i]),S=(0,X.useCallback)(()=>{m?x(!y):b(!v)},[v,m,y,b,x]),C=(0,X.useMemo)(()=>({isMobile:m,layoutId:`${g}-active`,open:v,openMobile:y,reduce:h,setOpen:b,setOpenMobile:x,state:v?`expanded`:`collapsed`,toggleSidebar:S,triggerRef:_}),[v,g,m,y,h,b,x,S]);return(0,X.useEffect)(()=>{let e=e=>{e.key.toLowerCase()===Ic&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S]),(0,Z.jsx)(Jc.Provider,{value:C,children:(0,Z.jsx)(`div`,{...l,"data-slot":`sidebar-wrapper`,"data-state":v?`expanded`:`collapsed`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`4.25rem`,"--sidebar-width-mobile":`18rem`,...c},className:U(`group/sidebar-wrapper flex min-h-svh w-full min-w-0`,s),children:e})})}function $c({ariaLabel:e,children:t,className:n,side:r}){let i=Xc(),a=(0,X.useRef)(null),[o,s]=(0,X.useState)(!1),c=(0,X.useMemo)(()=>({collapsed:!1,collapsible:`none`,side:r}),[r]);return(0,X.useEffect)(()=>s(!0),[]),(0,X.useEffect)(()=>{if(!i.openMobile)return;let e=a.current;if(!e)return;let t=i.triggerRef.current,n=document.body,r=window.scrollY,o={left:n.style.left,overflow:n.style.overflow,position:n.style.position,right:n.style.right,top:n.style.top};n.style.position=`fixed`,n.style.top=`-${r}px`,n.style.left=`0`,n.style.right=`0`,n.style.overflow=`hidden`;let s=requestAnimationFrame(()=>{(e.querySelector(Uc)??e).focus({preventScroll:!0})});return()=>{cancelAnimationFrame(s),n.style.position=o.position,n.style.top=o.top,n.style.left=o.left,n.style.right=o.right,n.style.overflow=o.overflow,window.scrollTo(0,r),t?.focus({preventScroll:!0})}},[i.openMobile,i.triggerRef,o]),o?(0,Ds.createPortal)((0,Z.jsxs)(`div`,{className:U(`pointer-events-none fixed inset-0 z-50 md:hidden`,i.openMobile?`visible`:`invisible`),children:[(0,Z.jsx)(K.button,{type:`button`,"aria-label":`Close sidebar`,tabIndex:i.openMobile?0:-1,initial:!1,animate:{opacity:+!!i.openMobile},transition:i.reduce?Hc:Lc,onClick:()=>i.setOpenMobile(!1),className:U(`absolute inset-0 bg-black/40`,i.openMobile?`pointer-events-auto`:`pointer-events-none`)}),(0,Z.jsx)(K.div,{ref:a,role:`dialog`,"aria-modal":`true`,"aria-label":e,"aria-hidden":!i.openMobile,inert:!i.openMobile,tabIndex:-1,"data-mobile":`true`,"data-state":i.openMobile?`expanded`:`collapsed`,"data-side":r,initial:!1,animate:{opacity:i.reduce?+!!i.openMobile:1,x:i.reduce?0:i.openMobile?`0%`:r===`left`?`-100%`:`100%`},transition:i.reduce?Hc:Lc,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),i.setOpenMobile(!1);return}if(e.key!==`Tab`)return;let t=a.current?Array.from(a.current.querySelectorAll(Uc)):[];if(t.length===0){e.preventDefault(),a.current?.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())},className:U(`pointer-events-auto absolute inset-y-0 flex h-dvh w-(--sidebar-width-mobile) max-w-[88vw] flex-col overflow-hidden`,`border-border bg-background shadow-2xl will-change-transform`,r===`left`?`left-0 border-r`:`right-0 border-l`,!i.openMobile&&`pointer-events-none`,n),children:(0,Z.jsx)(Yc.Provider,{value:c,children:t})})]}),document.body):null}var el=(0,X.forwardRef)(function({side:e=`left`,variant:t=`sidebar`,collapsible:n=`icon`,ariaLabel:r=`Sidebar`,children:i,className:a,panelClassName:o,style:s,...c},l){let u=Xc(),d=n!==`none`&&!u.open,f=d&&n===`offcanvas`,p=t===`floating`||t===`inset`,m=f?`0px`:d?p?`calc(var(--sidebar-width-icon) + 1rem)`:`var(--sidebar-width-icon)`:p?`calc(var(--sidebar-width) + 1rem)`:`var(--sidebar-width)`,h=(0,X.useMemo)(()=>({collapsed:d,collapsible:n,side:e}),[d,n,e]);return u.isMobile?(0,Z.jsx)($c,{ariaLabel:r,className:a,side:e,children:i}):(0,Z.jsx)(K.aside,{...c,ref:l,initial:!1,"aria-label":r,"data-slot":`sidebar`,"data-state":d?`collapsed`:`expanded`,"data-collapsible":n,"data-variant":t,"data-side":e,transition:u.reduce?{duration:0}:Rc,layout:`size`,style:{...s,width:m},className:U(`group/sidebar relative hidden h-auto shrink-0 md:block will-change-transform`,`peer`,e===`right`&&`order-last`,a),children:(0,Z.jsx)(K.div,{initial:!1,animate:{opacity:+!f,x:f?e===`left`?`-120%`:`120%`:`0%`},transition:u.reduce?Hc:Lc,className:U(`sticky top-0 flex h-svh w-full flex-col overflow-hidden`,p&&(d?`w-[var(--sidebar-width-icon)]`:`w-[var(--sidebar-width)]`),n===`offcanvas`&&`w-[var(--sidebar-width)]`,t===`sidebar`&&(e===`left`?`border-border border-r bg-background`:`border-border border-l bg-background`),t===`floating`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl bg-sidebar shadow-surface-3`,t===`inset`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl bg-background`,o),children:(0,Z.jsx)(Yc.Provider,{value:h,children:i})})})}),tl=(0,X.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=Xc(),o=a.isMobile?a.openMobile:a.open;return(0,Z.jsx)(z,{...r,ref:e=>{a.triggerRef.current=e,typeof i==`function`?i(e):i&&(i.current=e)},type:n,variant:`ghost`,size:`icon-lg`,"aria-label":r[`aria-label`]??`Toggle sidebar`,"aria-expanded":o,"data-slot":`sidebar-trigger`,"data-state":o?`expanded`:`collapsed`,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:U(`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,e)})});(0,X.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=Xc();return(0,Z.jsx)(z,{...r,ref:i,type:n,variant:`ghost`,size:`icon-lg`,"aria-label":r[`aria-label`]??`Close sidebar`,onClick:e=>{t?.(e),!e.defaultPrevented&&(a.isMobile?a.setOpenMobile(!1):a.setOpen(!1))},className:U(`focus-visible:ring-2 focus-visible:ring-ring`,e)})});var nl=(0,X.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=Xc(),o=Zc();return(0,Z.jsx)(`button`,{...r,ref:i,type:n,"data-side":o.side,"aria-label":r[`aria-label`]??`Toggle sidebar`,title:`Toggle sidebar`,tabIndex:-1,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:U(`absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 outline-none md:block`,`after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent after:transition-colors hover:after:bg-border`,`data-[side=right]:right-0 data-[side=right]:translate-x-1/2 data-[side=left]:left-full`,e)})}),rl=(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(K.main,{...t,ref:n,"data-slot":`sidebar-inset`,className:U(`relative flex min-h-svh min-w-0 flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl md:peer-data-[variant=inset]:shadow-sm`,e)})}),il=(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-header`,className:U(`flex shrink-0 flex-col gap-2 p-3`,e)})}),al=(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-content`,className:U(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-2`,e)})}),ol=(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-footer`,className:U(`flex shrink-0 flex-col gap-2 border-border border-t p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,e)})}),sl=(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group`,className:U(`flex w-full min-w-0 flex-col px-1 py-1.5`,e)})}),cl=(0,X.forwardRef)(function({children:e,className:t,...n},r){let{collapsed:i}=Zc();return(0,Z.jsx)(`div`,{...n,ref:r,"aria-hidden":i,"data-slot":`sidebar-group-label`,className:U(`mb-1 h-7 overflow-hidden px-2 text-[0.625rem] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-opacity`,i?`opacity-0`:`opacity-100`,t),children:e})}),ll=(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group-content`,className:U(`w-full min-w-0`,e)})});(0,X.forwardRef)(function({children:e,className:t,...n},r){return(0,Z.jsx)(Or,{...n,ref:r,as:`ul`,inset:0,pillClassName:`rounded-xl bg-muted/70`,pillContainerClassName:`inset-y-auto top-0 h-9`,"data-slot":`sidebar-menu`,className:U(`flex w-full min-w-0 list-none flex-col gap-0.5`,t),children:e})}),(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(K.li,{...t,ref:n,layout:`position`,transition:Me,"data-slot":`sidebar-menu-item`,className:U(`relative`,e)})}),(0,X.forwardRef)(function({open:e,children:t,className:n,...r},i){let a=Xc(),o=Zc();return(0,Z.jsx)(Ge,{initial:!1,mode:`popLayout`,children:e&&!o.collapsed?(0,X.createElement)(K.ul,{...r,ref:i,key:`sidebar-submenu`,variants:a.reduce?void 0:Bc,initial:!a.reduce&&`closed`,animate:a.reduce?{opacity:1}:`open`,exit:a.reduce?{opacity:0}:`closed`,transition:a.reduce?{duration:.12}:void 0,"data-slot":`sidebar-menu-sub`,className:U(`relative mt-1 ml-5 flex min-w-0 flex-col gap-0.5 border-border border-l pl-3`,n)},t):null})}),(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(K.li,{...t,ref:n,variants:Vc,"data-slot":`sidebar-menu-sub-item`,className:U(`relative min-w-0`,e)})});function ul(e,t){return e.filter(e=>e.messageCount>0||e.sessionId===t)}function dl(e){return e.toSorted((e,t)=>Date.parse(t.updatedAt)-Date.parse(e.updatedAt))}function fl(e,t,n){let r=dl(e);if(n||r.length<=5)return r;let i=r.slice(0,5),a=r.find(e=>e.sessionId===t);return a&&!i.some(e=>e.sessionId===a.sessionId)&&(i[4]=a),i}function pl(e,t){let n=new Map(e.map((e,t)=>[e.projectId,t])),r=new Map;for(let e of t){if(!e.projectId)continue;let t=Date.parse(e.updatedAt);r.set(e.projectId,Math.max(r.get(e.projectId)??0,t))}return e.toSorted((e,t)=>{let i=r.get(e.projectId)??0,a=r.get(t.projectId)??0;return i===a?(n.get(e.projectId)??0)-(n.get(t.projectId)??0):a-i})}function ml(){try{return`0.6.1`}catch{return`dev`}}function hl(){let e=ml();return(0,Z.jsxs)(Gi,{variant:`secondary`,title:`Fleet ${e}`,"aria-label":`Fleet version ${e}`,className:`shrink-0 font-mono text-[0.625rem] font-normal text-muted-foreground`,children:[`v`,e]})}var gl={duration:.16,ease:Pe},_l=[],vl=[];function yl(e){return e.kind===`folder`||e.kind===`project`}function bl(e,t,n=0,r=null){return e.flatMap(e=>{let i={item:e,depth:n,parentId:r};return!e.children?.length||!t.has(e.id)?[i]:[i,...bl(e.children,t,n+1,e.id)]})}function xl(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?xl(n.children,t):void 0;if(e)return e}}function Sl(e,t){return e.id===t||e.children?.some(e=>Sl(e,t))===!0}function Cl(e,t){let n,r=[];for(let i of e){if(i.id===t){n=i;continue}if(i.children?.length){let e=Cl(i.children,t);if(e.removed){n=e.removed,r.push({...i,children:e.items});continue}}r.push(i)}return{items:r,removed:n}}function wl(e,t,n,r){if(n===null)return[...e,t];let i=[];for(let a of e){if(a.id===n){r===`before`?i.push(t,a):r===`after`?i.push(a,t):i.push({...a,children:[...a.children??[],t]});continue}a.children?.length?i.push({...a,children:wl(a.children,t,n,r)}):i.push(a)}return i}function Tl(e,t){let n=xl(e,t.itemId);if(!n||n.disabled||t.targetId&&Sl(n,t.targetId))return null;let r=t.targetId?xl(e,t.targetId):void 0;if(t.position===`inside`&&(!r||r.disabled||!yl(r)))return null;let i=Cl(e,t.itemId);return i.removed?wl(i.items,i.removed,t.targetId,t.position):null}function El(e,t,n){return e.map(e=>({...e,label:e.id===t?n:e.label,children:e.children?El(e.children,t,n):void 0}))}function Dl(e,t){if(e.kind===`action`)return null;let n=e.kind===`folder`||e.kind===`project`?t?Rr:zr:e.kind===`bookmark`?Ba:br;return(0,Z.jsx)(n,{className:`size-4`})}function Ol({active:e,children:t}){let n=Ke()??!1,r=(0,X.useRef)(null),i=(0,X.useRef)(null),[a,o]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=()=>{let e=r.current,t=i.current;!e||!t||o(t.scrollWidth>e.clientWidth?t.scrollWidth+24:0)};e();let t=new ResizeObserver(e);return r.current&&t.observe(r.current),i.current&&t.observe(i.current),()=>t.disconnect()},[]);let s=e&&a>0&&!n;return(0,Z.jsx)(`span`,{ref:r,className:`block min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsxs)(K.span,{className:`flex w-max items-center gap-6 whitespace-nowrap`,animate:{x:s?[0,-a]:0},transition:s?{duration:Math.max(2.4,a/34),ease:`linear`,repeat:1/0,repeatDelay:2}:gl,children:[(0,Z.jsx)(`span`,{ref:i,children:t}),s?(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:t}):null]})})}function kl({label:e,onCommit:t,onCancel:n}){let[r,i]=(0,X.useState)(e),a=(0,X.useRef)(null),o=(0,X.useRef)(!1);return(0,X.useEffect)(()=>{o.current=!1,i(e),requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()})},[e]),(0,Z.jsx)(`input`,{ref:a,value:r,"aria-label":`Rename ${e}`,onChange:e=>i(e.target.value),draggable:!1,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onBlur:()=>{o.current||t(r)},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&(o.current=!0,t(r)),e.key===`Escape`&&(o.current=!0,n())},className:`mx-1 h-7 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-base text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring md:text-sm`})}function Al({item:e,menuOpen:t,onMenuOpenChange:n,onRenameStart:r,renderMenu:i}){let a=i?.(e,{close:()=>n(!1),rename:()=>{n(!1),r()}})??(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{n(!1),r()},className:`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsx)(Hr,{"aria-hidden":`true`,className:`size-3.5`}),`Rename`]});return(0,Z.jsxs)(Be,{open:t,onOpenChange:n,children:[(0,Z.jsx)(ze,{children:(0,Z.jsx)(`button`,{type:`button`,draggable:!1,tabIndex:-1,"aria-label":`Actions for ${e.label}`,onClick:e=>e.stopPropagation(),className:`grid size-7 shrink-0 place-items-center rounded-lg opacity-0 outline-none transition-opacity hover:bg-foreground/5 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring group-hover/resource:opacity-100 group-data-[menu-open=true]/resource:opacity-100`,children:(0,Z.jsx)(Ka,{"aria-hidden":`true`,className:`size-4`})})}),(0,Z.jsx)(He,{side:`bottom`,align:`end`,sideOffset:8,radius:12,className:`w-40 p-1.5`,children:(0,Z.jsx)(`div`,{"data-sidebar-resource-menu":e.id,children:a})})]})}function jl(e,t,n,r,i){return U(`group/resource relative flex min-h-8 min-w-0 cursor-pointer items-center gap-2 rounded-lg pr-2 text-[0.8125rem] outline-none`,`text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,`focus-visible:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,`data-[menu-open=true]:bg-muted data-[menu-open=true]:text-foreground`,`data-[dragging=true]:opacity-40`,`data-[drop=inside]:bg-primary/10 data-[drop=inside]:ring-1 data-[drop=inside]:ring-primary/45`,`data-[drop=before]:before:absolute data-[drop=before]:before:-top-0.5 data-[drop=before]:before:right-2 data-[drop=before]:before:left-2 data-[drop=before]:before:h-0.5 data-[drop=before]:before:rounded-full data-[drop=before]:before:bg-primary`,`data-[drop=after]:after:absolute data-[drop=after]:after:-bottom-0.5 data-[drop=after]:after:right-2 data-[drop=after]:after:left-2 data-[drop=after]:after:h-0.5 data-[drop=after]:after:rounded-full data-[drop=after]:after:bg-primary`,!e&&t&&`bg-muted text-foreground`,e&&n&&`bg-muted/55 text-foreground ring-1 ring-border/70`,r===`action`&&`text-xs text-muted-foreground`,i&&`cursor-not-allowed opacity-45`)}function Ml({acceptsChildren:e,allowMove:t,disabled:n,kind:r,onContainerSelect:i,onDragEnd:a,onDragOver:o,onDragStart:s,onDrop:c,onRenameStart:l,onSelect:u,renaming:d,row:f}){let p=(0,X.useRef)(!1);return{handleClick:t=>{t.defaultPrevented||p.current||d||n||(e?i():u())},handleDoubleClick:t=>{e||r===`action`||n||(t.preventDefault(),l())},handleDragStartCapture:e=>{t&&(p.current=!0,s(e,f.item.id))},handleDragEndCapture:()=>{a(),requestAnimationFrame(()=>{p.current=!1})},handleDragOver:e=>{t&&o(e,f)},handleDrop:e=>{t&&c(e)}}}function Nl({icon:e,renaming:t,label:n,onCommit:r,onCancel:i,activeLabel:a,item:o,secondaryAction:s,menuOpen:c,onMenuOpenChange:l,onRenameStart:u,renderMenu:d}){return t?(0,Z.jsxs)(Z.Fragment,{children:[e!==null&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 shrink-0 place-items-center`,children:e}),(0,Z.jsx)(kl,{label:n,onCommit:r,onCancel:i})]}):(0,Z.jsxs)(Z.Fragment,{children:[e!==null&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 shrink-0 place-items-center`,children:e}),(0,Z.jsx)(Ol,{active:a,children:n}),s,!o.disabled&&o.kind!==`action`&&(0,Z.jsx)(Al,{item:o,menuOpen:c,onMenuOpenChange:l,onRenameStart:u,renderMenu:d})]})}function Pl(e,t,n,r,i,a,o,s,c,l){return{"aria-level":e.depth+1,"aria-selected":t?void 0:n,"aria-expanded":t?r:void 0,"aria-disabled":e.item.disabled||void 0,tabIndex:i?0:-1,draggable:a&&!e.item.disabled&&!o,"data-menu-open":s||void 0,"data-kind":e.item.kind,"data-drop":c??void 0,"data-dragging":l||void 0}}function Fl(e){let t=Ke()??!1,[n,r]=(0,X.useState)(!1),i=yl(e.row.item),a=e.renderIcon?.(e.row.item),o=a===void 0?Dl(e.row.item,e.expanded):a,s=e.draggingId===e.row.item.id,c=e.dropTarget?.id===e.row.item.id?e.dropTarget.position:null,l=Ml({acceptsChildren:i,allowMove:e.allowMove,disabled:e.row.item.disabled,kind:e.row.item.kind,onContainerSelect:e.onContainerSelect,onDragEnd:e.onDragEnd,onDragOver:e.onDragOver,onDragStart:e.onDragStart,onDrop:e.onDrop,onRenameStart:e.onRenameStart,onSelect:e.onSelect,renaming:e.renaming,row:e.row}),u=Pl(e.row,i,e.active,e.expanded,e.focused,e.allowMove,e.renaming,e.menuOpen,c,s);return(0,Z.jsx)(K.div,{ref:e.setRef,layout:`position`,transition:t?{duration:0}:Me,role:`treeitem`,...u,onFocus:e.onFocus,onKeyDown:e.onKeyDown,onClick:l.handleClick,onDoubleClick:l.handleDoubleClick,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onDragStartCapture:l.handleDragStartCapture,onDragEndCapture:l.handleDragEndCapture,onDragOver:l.handleDragOver,onDrop:l.handleDrop,className:jl(i,e.active,e.containerActive,e.row.item.kind,e.row.item.disabled),style:{paddingLeft:`${8+(e.row.depth+(e.row.item.indent??0))*14}px`},children:(0,Z.jsx)(Nl,{icon:o,renaming:e.renaming,label:e.row.item.label,onCommit:e.onRenameCommit,onCancel:e.onRenameCancel,activeLabel:n||e.menuOpen,item:e.row.item,secondaryAction:e.renaming?null:e.renderSecondaryAction?.(e.row.item),menuOpen:e.menuOpen,onMenuOpenChange:e.onMenuOpenChange,onRenameStart:e.onRenameStart,renderMenu:e.renderMenu})})}function Il({flat:e,selectedId:t,activeContainerId:n,expandedIds:r,focusedId:i,draggingId:a,dropTarget:o,menuOpenId:s,renamingId:c,allowMove:l,announcement:u,ariaLabel:d,className:f,renderIcon:p,renderSecondaryAction:m,renderMenu:h,onFocus:g,onSelect:_,onContainerSelect:v,onKeyDown:y,onRenameStart:b,onRenameCancel:x,onRenameCommit:S,onMenuOpenChange:C,onDragStart:w,onDragEnd:T,onDragOver:E,onRootDragOver:D,onDrop:O,setRef:k}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{role:`tree`,"aria-label":d,"aria-multiselectable":`false`,onDragOver:D,onDrop:O,className:U(`relative flex min-w-0 flex-col gap-0.5 [overflow-anchor:none] group-data-[state=collapsed]/sidebar:hidden`,a&&`select-none pb-9`,f),children:[(0,Z.jsx)(Ge,{initial:!1,children:e.map(e=>(0,Z.jsx)(Fl,{row:e,active:t===e.item.id,containerActive:n===e.item.id,expanded:r.has(e.item.id),focused:i===e.item.id,draggingId:a,dropTarget:o,menuOpen:s===e.item.id,renaming:c===e.item.id,onFocus:()=>g(e.item.id),onSelect:()=>_(e.item.id),onContainerSelect:()=>v(e.item.id),allowMove:l,onKeyDown:t=>y(t,e),onRenameStart:()=>b(e.item.id),onRenameCancel:x,onRenameCommit:t=>S(e,t),onMenuOpenChange:t=>C(e.item.id,t),onDragStart:w,onDragEnd:T,onDragOver:(e,t)=>E(e,t),onDrop:O,renderIcon:p,renderSecondaryAction:m,renderMenu:h,setRef:t=>k(e.item.id,t)},e.item.id))}),a?(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-active":o?.id===null||void 0,className:`absolute inset-x-1 bottom-0 flex h-8 items-center justify-center rounded-lg border border-dashed border-border text-[0.625rem] text-muted-foreground data-[active=true]:border-primary/50 data-[active=true]:bg-primary/10 data-[active=true]:text-foreground`,children:`Move to top level`}):null]}),(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})}function Ll({expandedIds:e,flat:t,focusRow:n,onContainerSelect:r,performMove:i,select:a,setMenuOpenId:o,setRenamingId:s,toggle:c,updateExpandedIds:l}){return(0,X.useCallback)((u,d)=>{let f=t.findIndex(({item:e})=>e.id===d.item.id),p=t[f-1],m=t[f+1],h=u.altKey&&u.shiftKey;if(u.key===`ArrowDown`&&!h&&m){u.preventDefault(),n(m.item.id);return}if(u.key===`ArrowUp`&&!h&&p){u.preventDefault(),n(p.item.id);return}if(u.key===`Home`&&t[0]){u.preventDefault(),n(t[0].item.id);return}if(u.key===`End`&&t.at(-1)){u.preventDefault(),n(t.at(-1)?.item.id??d.item.id);return}if(d.item.disabled){u.key===`ArrowLeft`&&d.parentId?(u.preventDefault(),n(d.parentId)):(h||[`ArrowRight`,`Enter`,` `,`F2`,`ContextMenu`].includes(u.key)||u.shiftKey&&u.key===`F10`)&&u.preventDefault();return}if(h&&u.key===`ArrowUp`&&p){u.preventDefault(),i({itemId:d.item.id,targetId:p.item.id,position:`before`});return}if(h&&u.key===`ArrowDown`&&m){u.preventDefault(),i({itemId:d.item.id,targetId:m.item.id,position:`after`});return}if(h&&u.key===`ArrowRight`&&p&&yl(p.item)){u.preventDefault(),l(e=>new Set(e).add(p.item.id)),i({itemId:d.item.id,targetId:p.item.id,position:`inside`});return}if(h&&u.key===`ArrowLeft`&&d.parentId){u.preventDefault(),i({itemId:d.item.id,targetId:d.parentId,position:`after`});return}u.key===`ArrowRight`&&yl(d.item)?(u.preventDefault(),e.has(d.item.id)?m?.parentId===d.item.id&&n(m.item.id):c(d.item.id)):u.key===`ArrowLeft`?(u.preventDefault(),e.has(d.item.id)?c(d.item.id):d.parentId&&n(d.parentId)):u.key===`Enter`||u.key===` `?(u.preventDefault(),yl(d.item)?r?r(d.item.id):c(d.item.id):a(d.item.id)):u.key===`F2`&&d.item.kind!==`action`?(u.preventDefault(),s(d.item.id)):(u.key===`ContextMenu`||u.shiftKey&&u.key===`F10`)&&(u.preventDefault(),o(d.item.id))},[e,t,n,r,i,a,o,s,c,l])}function Rl({items:e,defaultItems:t=_l,onItemsChange:n,onMove:r,onMoveError:i,allowMove:a=!0,onRename:o,activeId:s,activeContainerId:c,defaultActiveId:l=null,onActiveChange:u,onContainerSelect:d,expandedIds:f,defaultExpandedIds:p=vl,onExpandedIdsChange:m,renderIcon:h,renderSecondaryAction:g,renderMenu:_,ariaLabel:v=`Resources`,className:y}){let[b,x]=(0,X.useState)(e??t),[S,C]=(0,X.useState)(l),[w,T]=(0,X.useState)(()=>new Set(p)),[E,D]=(0,X.useState)(s??l),[O,k]=(0,X.useState)(null),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(null),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(``),ee=(0,X.useRef)(new Map),te=(0,X.useRef)(!1),R=b,z=s??S,B=(0,X.useMemo)(()=>f===void 0?w:new Set(f),[f,w]);(0,X.useEffect)(()=>{e&&x(e)},[e]),(0,X.useEffect)(()=>{f===void 0&&p.length!==0&&T(e=>{let t=new Set(e),n=!1;for(let e of p)t.has(e)||(t.add(e),n=!0);return n?t:e})},[f,p]);let V=(0,X.useMemo)(()=>bl(R,B),[B,R]);(0,X.useEffect)(()=>{E&&V.some(e=>e.item.id===E)||D(V[0]?.item.id??null)},[V,E]),(0,X.useEffect)(()=>{if(!M)return;let e=requestAnimationFrame(()=>{Array.from(document.querySelectorAll(`[data-sidebar-resource-menu]`)).find(e=>e.dataset.sidebarResourceMenu===M)?.querySelector(`button, a[href]`)?.focus()});return()=>cancelAnimationFrame(e)},[M]);let H=(0,X.useCallback)(e=>{x(e),n?.(e)},[n]),U=(0,X.useCallback)(async e=>{if(te.current){L(`Wait for the current move to finish.`);return}let t=R,n=Tl(t,e);if(!n||n===t)return;te.current=!0,H(n),j(null),k(null);let a=xl(t,e.itemId),o=e.targetId?xl(t,e.targetId):null;L(o?`Moved ${a?.label??`item`} ${e.position} ${o.label}.`:`Moved ${a?.label??`item`} to the top level.`);try{await r?.(e)}catch(n){H(t),L(`Move failed. ${a?.label??`Item`} was restored.`),i?.(n,e)}finally{te.current=!1}},[r,i,R,H]),W=(0,X.useCallback)(e=>{D(e),requestAnimationFrame(()=>ee.current.get(e)?.focus())},[]),ne=(0,X.useCallback)(e=>{s===void 0&&C(e),u?.(e)},[s,u]),G=(0,X.useCallback)(e=>{let t=e(new Set(B));f===void 0&&T(t),m?.([...t])},[f,B,m]),re=(0,X.useCallback)(e=>{G(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[G]),ie=Ll({expandedIds:B,flat:V,focusRow:W,onContainerSelect:d,performMove:U,select:ne,setMenuOpenId:N,setRenamingId:F,toggle:re,updateExpandedIds:G});return(0,Z.jsx)(Il,{flat:V,selectedId:z,activeContainerId:c,expandedIds:B,focusedId:E,draggingId:O,dropTarget:A,menuOpenId:M,renamingId:P,allowMove:a,announcement:I,ariaLabel:v,className:y,renderIcon:h,renderSecondaryAction:g,renderMenu:_,onFocus:D,onSelect:ne,onContainerSelect:e=>{d?d(e):re(e)},onKeyDown:ie,onRenameStart:F,onRenameCancel:()=>F(null),onRenameCommit:(e,t)=>{let n=t.trim();if(F(null),!n||n===e.item.label)return;let r=R;H(El(r,e.item.id,n)),Promise.resolve(o?.(e.item,n)).catch(()=>{H(r),L(`Rename failed. ${e.item.label} was restored.`)})},onMenuOpenChange:(e,t)=>{N(t?e:null),t||W(e)},onDragStart:(e,t)=>{k(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},onDragEnd:()=>{k(null),j(null)},onDragOver:(e,t)=>{if(!O||O===t.item.id)return;let n=xl(R,O);if(n&&Sl(n,t.item.id))return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget.getBoundingClientRect(),i=(e.clientY-r.top)/r.height,a=!t.item.disabled&&yl(t.item)&&i>=.25&&i<=.75?`inside`:i<.5?`before`:`after`;j({id:t.item.id,position:a})},onRootDragOver:e=>{!O||e.target!==e.currentTarget||(e.preventDefault(),j({id:null,position:`after`}))},onDrop:e=>{e.preventDefault(),e.stopPropagation(),O&&A&&U({itemId:O,targetId:A.id,position:A.position})},setRef:(e,t)=>{t?ee.current.set(e,t):ee.current.delete(e)}})}var zl=5,Bl=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function Vl(e,t){let n=e-(t-1)/2,r=Math.abs(n),i=Math.max(0,2-r)*8;return{x:n*44,y:8-i,rotate:n*6,scale:r===0?1.04:r===1?.95:.88,opacity:r===0?1:r===1?.78:.58,zIndex:10-r}}function Hl({title:e,countText:t,dialogTitleId:n,previewItems:r,isExpanded:i,isClosing:a,reduce:o,transition:s,dialogRef:c,closeButtonRef:l,closeOverlay:u}){return!i&&!a?null:(0,Z.jsxs)(`div`,{ref:c,role:`dialog`,"aria-modal":`true`,"aria-labelledby":n,"aria-hidden":i?void 0:`true`,className:U(`fixed inset-0 z-50 flex items-start justify-center overflow-y-auto sm:items-center`,a&&`pointer-events-none`),children:[(0,Z.jsx)(Ge,{initial:!1,children:i?(0,Z.jsx)(K.button,{type:`button`,tabIndex:-1,"aria-label":`Close file overlay`,onClick:u,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:o?{duration:0}:{duration:.18},className:`absolute inset-0 cursor-default bg-background/80 backdrop-blur-xl`},`project-files-backdrop`):null}),(0,Z.jsxs)(`div`,{className:`relative z-10 w-full max-w-5xl px-6 py-8`,children:[(0,Z.jsx)(Ge,{initial:!1,children:i?(0,Z.jsxs)(K.div,{initial:{opacity:0,y:o?0:8},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:-8},transition:o?{duration:0}:{duration:.18},className:`mb-6 flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{id:n,className:`text-xl font-medium text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),(0,Z.jsx)(`button`,{ref:l,type:`button`,onClick:u,"aria-label":`Close ${e}`,className:`flex size-10 items-center justify-center rounded-full border border-foreground/10 bg-background/50 text-muted-foreground backdrop-blur-xl transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Z.jsx)(Xr,{className:`size-4`,"aria-hidden":`true`})})]},`project-files-header`):null}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 place-items-center gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:i?r.map(e=>(0,Z.jsx)(K.div,{layoutId:`file-${e.id}`,transition:s,className:`aspect-[3/4] w-full max-w-40 overflow-hidden rounded-xl border border-foreground/10 bg-background/50 backdrop-blur-xl`,children:e.content},e.id)):null})]})]})}function Ul({title:e,description:t=`Updated recently`,previews:n=[],count:r=n.length,itemLabel:i=`file`,open:a,defaultOpen:o=!1,onOpenChange:s,expanded:c,defaultExpanded:l=!1,onExpandedChange:u,onClick:d,disabled:f=!1,ariaLabel:p,className:m}){let h=Ke(),g=Kn(),_=(0,X.useId)(),v=`${_}-title`,y=(0,X.useRef)(!1),b=(0,X.useRef)(!1),x=(0,X.useRef)(!1),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=Le(),[E,D]=(0,X.useState)(o),[O,k]=(0,X.useState)(l),[A,j]=(0,X.useState)(!1),M=a!==void 0,N=c!==void 0,P=c??O,F=(a??E)||P,I=n.slice(0,zl),L=h?{duration:0}:Me,ee=`${r} ${i}${r===1?``:`s`}`,te=(0,X.useCallback)(e=>{f||(M||D(e),s?.(e))},[f,s,M]),R=(0,X.useCallback)(e=>{f||I.length===0||(N||k(e),u?.(e))},[f,N,u,I.length]),z=(0,X.useCallback)(()=>{j(!1),x.current=!0,requestAnimationFrame(()=>S.current?.focus())},[]),B=(0,X.useCallback)(()=>{j(!0),te(!1),R(!1)},[R,te]),V=(0,X.useEffectEvent)(B);(0,X.useEffect)(()=>{h&&A&&z()},[z,A,h]),(0,X.useEffect)(()=>{if(!P)return;let e=document.body.style.overflow,t=requestAnimationFrame(()=>C.current?.focus());document.body.style.overflow=`hidden`;let n=e=>{if(e.key===`Escape`){e.preventDefault(),V();return}if(e.key!==`Tab`||!w.current)return;let t=Array.from(w.current.querySelectorAll(Bl)).filter(e=>e.tabIndex>=0),n=t[0],r=t.at(-1);!n||!r||(e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()))};return document.addEventListener(`keydown`,n),()=>{cancelAnimationFrame(t),document.body.style.overflow=e,document.removeEventListener(`keydown`,n)}},[P]);let H=()=>{j(!1),R(!0),te(!0),d?.()},W=(0,Z.jsx)(Hl,{title:e,countText:ee,dialogTitleId:v,previewItems:I,isExpanded:P,isClosing:A,reduce:h??!1,transition:L,dialogRef:w,closeButtonRef:C,closeOverlay:B});return(0,Z.jsxs)(fa,{id:_,children:[(0,Z.jsxs)(K.button,{ref:S,type:`button`,disabled:f,"aria-label":p,"aria-haspopup":`dialog`,"aria-expanded":P,"data-open":F?`true`:`false`,"data-expanded":P?`true`:`false`,tabIndex:P?-1:void 0,onPointerEnter:()=>{g&&(y.current=!0,te(!0))},onPointerLeave:()=>{g&&(y.current=!1,!P&&!A&&te(b.current))},onFocus:()=>{if(x.current){x.current=!1,b.current=!1;return}b.current=!0,te(!0)},onBlur:()=>{b.current=!1,!P&&!A&&te(y.current)},onClick:H,whileTap:h||f?void 0:{scale:.98},transition:h?{duration:0}:ke,className:U(`relative block h-56 w-72 select-none rounded-2xl text-left outline-none [perspective:1200px] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50`,m),children:[(0,Z.jsx)(K.span,{"aria-hidden":`true`,animate:{rotateX:F&&!h?15:0},transition:L,className:`absolute inset-0 rounded-2xl border border-foreground/10 bg-background/25 backdrop-blur-xl [transform-origin:center_bottom]`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:(0,Z.jsx)(`span`,{className:`absolute left-1/2 top-0 block size-0`,children:(0,Z.jsx)(Ge,{initial:!1,children:P?null:I.map((e,t)=>{let n=Vl(t,I.length);return(0,Z.jsx)(K.span,{layoutId:`file-${e.id}`,initial:!1,animate:F&&!h?{x:n.x*1.4,y:n.y-8,rotate:n.rotate*1.3,scale:n.scale*1.02,opacity:Math.min(1,n.opacity+.18)}:{x:n.x,y:n.y,rotate:n.rotate,scale:n.scale,opacity:n.opacity},transition:L,onLayoutAnimationComplete:()=>{A&&t===0&&z()},className:`absolute left-0 top-0 -ml-12 block h-40 w-24 overflow-hidden rounded-lg border border-foreground/10 bg-background/45 backdrop-blur-lg`,style:{zIndex:n.zIndex},children:e.content},e.id)})})})}),(0,Z.jsxs)(K.span,{initial:!1,animate:{rotateX:F&&!h?-25:0},transition:L,className:`absolute inset-x-0 bottom-0 z-20 overflow-hidden rounded-2xl border border-foreground/10 bg-background/60 backdrop-blur-2xl [backface-visibility:hidden] [transform-origin:center_bottom]`,children:[(0,Z.jsx)(`span`,{className:`flex h-16 items-center px-4`,children:(0,Z.jsx)(`span`,{className:`line-clamp-2 text-xl font-medium leading-tight text-foreground`,children:e})}),(0,Z.jsxs)(`span`,{className:`flex h-12 items-center justify-between gap-3 border-t border-foreground/10 px-4`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/70`,children:ee}),(0,Z.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,children:t})]})]})]}),T?(0,Ds.createPortal)(W,document.body):null]})}function Wl(e){return e?.status===`running`?(0,Z.jsx)(gr,{className:`size-3.5 animate-spin`}):e?.status===`failed`?(0,Z.jsx)(Yr,{className:`size-3.5 text-destructive`}):e?.status===`interrupted`?(0,Z.jsx)(Ua,{className:`size-3.5 text-muted-foreground`}):null}function Gl({projectActionsOpen:e,setProjectActionsOpen:t,expandedProjectIds:n,setExpandedProjectIds:r,setCreateOpen:i,projects:a,projectSessions:o,sidebarItems:s,activeProjectId:c,activeSessionId:l,onNewSession:u,onNewSessionInProject:d,onProjectSelect:f,onRenameSession:p,onCreateProject:m,resumeResource:h,toggleProjectResource:g,renderMenu:_}){return(0,Z.jsx)(al,{className:`gap-0 px-2 pb-1 pt-2`,children:(0,Z.jsxs)(sl,{className:`p-0`,children:[(0,Z.jsxs)(`div`,{className:`relative mb-1 h-8`,children:[(0,Z.jsx)(cl,{className:`mb-0 h-8 pr-16 text-xs font-normal normal-case tracking-normal text-muted-foreground`,children:`Projects`}),(0,Z.jsxs)(`div`,{className:`absolute inset-y-0 right-1 flex items-center gap-0.5`,children:[(0,Z.jsxs)(Pc,{open:e,onOpenChange:t,side:`bottom`,align:`end`,className:`w-44 p-1`,trigger:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Project actions`,title:`Project actions`,className:`grid size-6 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,Z.jsx)(Ka,{"aria-hidden":`true`,className:`size-3.5`})}),children:[m?(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{t(!1),i(!0)},className:`flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs outline-none hover:bg-muted focus-visible:bg-muted`,children:[(0,Z.jsx)(Ja,{"aria-hidden":`true`,className:`size-3.5`}),`Add project`]}):null,(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{t(!1),r([])},className:`flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs outline-none hover:bg-muted focus-visible:bg-muted`,children:[(0,Z.jsx)($n,{"aria-hidden":`true`,className:`size-3.5`}),`Collapse all`]})]}),m?(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Add project`,title:`Add project`,onClick:()=>i(!0),className:`grid size-6 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,Z.jsx)(Ur,{"aria-hidden":`true`,className:`size-3.5`})}):null]})]}),(0,Z.jsx)(ll,{children:a.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-4`,children:(0,Z.jsx)(Ul,{title:`Add a project`,description:`Choose a local directory for Fleet Prime.`,count:0,itemLabel:`session`,previews:[{id:`empty-project`,content:(0,Z.jsx)(Ja,{className:`size-5 text-muted-foreground`})}],onClick:()=>i(!0),ariaLabel:`Add a project`,className:`w-full`})}):(0,Z.jsx)(Rl,{items:s,activeId:l?Zs(l):null,activeContainerId:c?Xs(c):null,expandedIds:n,onExpandedIdsChange:r,onActiveChange:h,onContainerSelect:g,onRename:(e,t)=>{let n=$s(e.id,Ys);n&&p(n,t)},renderMenu:_,renderIcon:e=>{if($s(e.id,`project:`))return(0,Z.jsx)(zr,{className:`size-4`});if(e.kind===`action`)return null;let t=$s(e.id,Ys);return Wl(o.find(e=>e.sessionId===t))},renderSecondaryAction:e=>{let t=$s(e.id,Js);return!t||t===`unassigned`?null:(0,Z.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`New chat in ${e.label}`,title:`New chat in ${e.label}`,onClick:e=>{e.stopPropagation(),d?d(t):(f?.(t),u())},className:`size-7 shrink-0 opacity-0 group-hover/resource:opacity-100 group-focus-within/resource:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,children:(0,Z.jsx)(Za,{"data-icon":`inline-start`,className:`size-3.5`})})},allowMove:!1,ariaLabel:`Projects and sessions`,className:`px-0`})})]})})}var Kl=`flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs outline-none transition-colors hover:bg-muted focus-visible:bg-muted`;function ql({icon:e,label:t,onClick:n,href:r}){return r?(0,Z.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:Kl,children:[(0,Z.jsx)(e,{className:`size-3.5`}),t]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:n,className:Kl,children:[(0,Z.jsx)(e,{className:`size-3.5`}),t]})}function Jl({children:e}){return(0,Z.jsx)(`kbd`,{className:`rounded border border-border/60 bg-muted/60 px-1 font-mono text-[0.625rem] leading-4 text-muted-foreground`,children:e})}function Yl({brandMenuOpen:e,setBrandMenuOpen:t,searchOpen:n,setSearchOpen:r,query:i,setQuery:a,projectActionsOpen:o,setProjectActionsOpen:s,expandedProjectIds:c,setExpandedProjectIds:l,setCreateOpen:u,projects:d,projectSessions:f,sidebarItems:p,sortedProjects:m,projectById:h,activeProjectId:g,activeSessionId:_,onNewSession:v,onNewSessionInProject:y,onProjectSelect:b,onRenameSession:x,onCreateProject:S,onOpenSettings:C,accountMenu:w,resumeResource:T,toggleProjectResource:E,selectSearchResult:D,renderMenu:O}){let k=(0,X.useMemo)(()=>dl(f).map(e=>({id:e.sessionId,title:tc(e,f),preview:nc(e,h),group:rc(e.updatedAt),keywords:e.firstMessage?[wr(e.firstMessage)]:[]})),[h,f]),A=(0,X.useMemo)(()=>{let e=i.trim().toLowerCase();return e?m.filter(t=>`${t.name} ${t.pathLabel}`.toLowerCase().includes(e)):m},[i,m]);return(0,Z.jsx)(el,{ariaLabel:`Fleet projects and sessions`,collapsible:`offcanvas`,variant:`floating`,className:`text-sidebar-foreground`,children:(0,Z.jsxs)(Ut,{value:2,children:[(0,Z.jsxs)(il,{className:`gap-2 border-0 px-2.5 pb-2 pt-2.5`,children:[(0,Z.jsxs)(`div`,{className:`relative flex h-9 min-w-0 items-center justify-between gap-1`,children:[(0,Z.jsxs)(Pc,{open:e,onOpenChange:t,side:`bottom`,align:`start`,trigger:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-8 w-fit shrink-0 items-center gap-1 rounded-lg px-2 text-left text-sm font-medium outline-none transition-colors hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:`Qredence Fleet`}),(0,Z.jsx)($n,{className:`size-3.5 text-muted-foreground`})]}),className:`w-52 p-1`,children:[S?(0,Z.jsx)(ql,{icon:Ja,label:`Add project`,onClick:()=>{t(!1),u(!0)}}):null,(0,Z.jsx)(ql,{icon:_n,label:`Settings`,onClick:()=>{t(!1),C?.()}}),(0,Z.jsx)(ql,{icon:Yn,label:`Documentation`,href:Ws})]}),(0,Z.jsx)(Pc,{open:n,onOpenChange:r,side:`bottom`,align:`end`,className:`w-64 p-0`,trigger:(0,Z.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Search projects and sessions`,title:`Search projects and sessions`,className:`shrink-0 text-muted-foreground hover:bg-sidebar-accent`,children:(0,Z.jsx)(qr,{"data-icon":`inline-start`,className:`size-4`})}),children:(0,Z.jsxs)(`div`,{className:`max-h-[min(32rem,calc(100vh-5rem))] overflow-y-auto`,children:[(0,Z.jsx)(cc,{threads:k,query:i,activeId:_??``,onQueryChange:a,onSelect:e=>D(`search-session:${e}`),className:`max-w-none rounded-none border-0 p-2 shadow-none`}),(0,Z.jsxs)(`div`,{className:`border-t border-border/60 px-2 pb-2 pt-1.5`,children:[(0,Z.jsx)(`span`,{className:`px-2 pb-1 font-mono text-[0.625rem] uppercase tracking-[0.14em] text-muted-foreground/60`,children:`Projects`}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5`,children:[A.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>D(`search-project:${e.projectId}`),className:`flex w-full min-w-0 items-center gap-2 rounded-xl px-2 py-1.5 text-left text-xs outline-none transition-colors hover:bg-foreground/[0.03] focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsx)(zr,{className:`size-3.5 shrink-0 text-muted-foreground/60`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,Z.jsx)(`span`,{className:`max-w-24 truncate text-[0.625rem] text-muted-foreground/55`,children:e.pathLabel})]},e.projectId)),A.length===0?(0,Z.jsxs)(`span`,{className:`p-2 text-center text-[0.6875rem] text-muted-foreground/60`,children:[`No project matches “`,i,`”`]}):null]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t border-border/60 px-3 py-2 text-[0.625rem] text-muted-foreground/70`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Jl,{children:`↑`}),(0,Z.jsx)(Jl,{children:`↓`}),`navigate`]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Jl,{children:`↵`}),`open`]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Jl,{children:`esc`}),`close`]})]})]})})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,className:`flex h-8 w-full items-center justify-start gap-2 rounded-lg px-2 text-[0.8125rem] font-normal text-sidebar-foreground outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:[(0,Z.jsx)(no,{className:`size-4 shrink-0 text-muted-foreground`}),`New chat`]})]}),(0,Z.jsx)(Gl,{projectActionsOpen:o,setProjectActionsOpen:s,expandedProjectIds:c,setExpandedProjectIds:l,setCreateOpen:u,projects:d,projectSessions:f,sidebarItems:p,activeProjectId:g,activeSessionId:_,onNewSession:v,onNewSessionInProject:y,onProjectSelect:b,onRenameSession:x,onCreateProject:S,resumeResource:T,toggleProjectResource:E,renderMenu:O}),(0,Z.jsxs)(ol,{className:`flex-row items-center gap-1 border-sidebar-border px-2.5 py-2 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:w??(0,Z.jsx)(`span`,{className:`flex h-8 items-center px-2 text-[0.8125rem]`,children:`Qredence`})}),(0,Z.jsx)(hl,{}),(0,Z.jsx)(`a`,{href:Ws,target:`_blank`,rel:`noreferrer`,"aria-label":`Open Qredence documentation`,title:`Help`,className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,Z.jsx)(Ha,{className:`size-4`})})]}),(0,Z.jsx)(nl,{})]})})}function Xl(e,t){return t.type===`update`?t.update(e):{...e,[t.field.key]:t.field.value}}function Zl(e){let[t,n]=(0,X.useReducer)(Xl,e,e=>({brandMenuOpen:!1,projectActionsOpen:!1,searchOpen:!1,query:``,expandedProjectIds:oc(e),revealedProjectIds:new Set,renameTarget:null,renameTitle:``,renameProjectTarget:null,renameProjectName:``,deleteTarget:null,unregisterTarget:null,createOpen:!1,createPath:``,createName:``,directoryToken:void 0,directoryBrowser:null,directoryBrowseLoading:!1,directoryBrowseError:null,createSubmitting:!1,createSubmitError:null,forkTarget:null,forkProjectId:void 0})),r=(0,X.useCallback)(function(e,t){n({type:`set`,field:{key:e,value:t}})},[]),i=(0,X.useCallback)(function(e,t){n({type:`update`,update:n=>({...n,[e]:t(n[e])})})},[]),a=(0,X.useCallback)(e=>r(`brandMenuOpen`,e),[r]),o=(0,X.useCallback)(e=>r(`projectActionsOpen`,e),[r]),s=(0,X.useCallback)(e=>r(`searchOpen`,e),[r]),c=(0,X.useCallback)(e=>r(`query`,e),[r]),l=(0,X.useCallback)(e=>typeof e==`function`?i(`expandedProjectIds`,e):r(`expandedProjectIds`,e),[r,i]),u=(0,X.useCallback)(e=>typeof e==`function`?i(`revealedProjectIds`,e):r(`revealedProjectIds`,e),[r,i]),d=(0,X.useCallback)(e=>r(`renameTarget`,e),[r]),f=(0,X.useCallback)(e=>r(`renameTitle`,e),[r]),p=(0,X.useCallback)(e=>r(`renameProjectTarget`,e),[r]),m=(0,X.useCallback)(e=>r(`renameProjectName`,e),[r]),h=(0,X.useCallback)(e=>r(`deleteTarget`,e),[r]),g=(0,X.useCallback)(e=>r(`unregisterTarget`,e),[r]),_=(0,X.useCallback)(e=>r(`createOpen`,e),[r]),v=(0,X.useCallback)(e=>r(`createPath`,e),[r]),y=(0,X.useCallback)(e=>r(`createName`,e),[r]),b=(0,X.useCallback)(e=>r(`directoryToken`,e),[r]),x=(0,X.useCallback)(e=>r(`directoryBrowser`,e),[r]),S=(0,X.useCallback)(e=>r(`directoryBrowseLoading`,e),[r]),C=(0,X.useCallback)(e=>r(`directoryBrowseError`,e),[r]),w=(0,X.useCallback)(e=>r(`createSubmitting`,e),[r]),T=(0,X.useCallback)(e=>r(`createSubmitError`,e),[r]),E=(0,X.useCallback)(e=>r(`forkTarget`,e),[r]),D=(0,X.useCallback)(e=>r(`forkProjectId`,e),[r]);return{...t,setBrandMenuOpen:a,setProjectActionsOpen:o,setSearchOpen:s,setQuery:c,setExpandedProjectIds:l,setRevealedProjectIds:u,setRenameTarget:d,setRenameTitle:f,setRenameProjectTarget:p,setRenameProjectName:m,setDeleteTarget:h,setUnregisterTarget:g,setCreateOpen:_,setCreatePath:v,setCreateName:y,setDirectoryToken:b,setDirectoryBrowser:x,setDirectoryBrowseLoading:S,setDirectoryBrowseError:C,setCreateSubmitting:w,setCreateSubmitError:T,setForkTarget:E,setForkProjectId:D}}var Ql=[[`resources`,`Open Resources`,Bn],[`workspace`,`Open Workspace`,zr],[`artifacts`,`Open Artifacts`,Vr]];function $l({icon:e,label:t,destructive:n=!1,onClick:r}){return(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:n?`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-destructive hover:bg-destructive/10`:`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs hover:bg-muted`,children:[(0,Z.jsx)(e,{className:`size-3.5`}),t]})}function eu({sessions:e,projects:t=Ks,projectSessions:n=e,activeProjectId:r,activeSessionId:i,onNewSession:a,onNewSessionInProject:o,onProjectSelect:s,onResumeSession:c,onCreateProject:l,onForkSessionIntoProject:u,onOpenPanelAction:d,onBrowseDirectories:f,createOpen:p,expandedProjectIds:m,revealedProjectIds:h,setExpandedProjectIds:g,setRevealedProjectIds:_,setSearchOpen:v,setDirectoryBrowser:y,setDirectoryBrowseLoading:b,setDirectoryBrowseError:x,setDirectoryToken:S,setCreatePath:C,setRenameTarget:w,setRenameTitle:T,setForkTarget:E,setForkProjectId:D,setDeleteTarget:O,setRenameProjectTarget:k,setRenameProjectName:A,setUnregisterTarget:j,createPath:M,directoryToken:N,createName:P,setCreateName:F,setCreateOpen:I,setCreateSubmitError:L,setCreateSubmitting:ee}){let te=(0,X.useRef)(!1),R=(0,X.useCallback)(async e=>{if(!f)return!1;b(!0),x(null);try{let t=await f(e);return y(t),S(t.directoryToken),C(t.pathLabel),!0}catch(e){return x(ac(e,`Could not browse this directory.`)),!1}finally{b(!1)}},[f,C,x,b,y,S]);(0,X.useEffect)(()=>{let e=p&&!te.current;te.current=p,!(!e||!f)&&R({})},[p,R,f]);let z=(0,X.useMemo)(()=>new Map(t.map(e=>[e.projectId,e])),[t]),B=(0,X.useMemo)(()=>pl(t,n),[n,t]);(0,X.useEffect)(()=>{if(!r)return;let e=Xs(r);g(t=>t.includes(e)?t:[...t,e])},[r,g]),(0,X.useEffect)(()=>{Qr(Gs,JSON.stringify(m))},[m]);let V=(0,X.useMemo)(()=>{let e=B.map(e=>{let t=ul(n.filter(t=>t.projectId===e.projectId),i),r=h.has(e.projectId),a=fl(t,i,r),o=a.map(e=>({id:Zs(e.sessionId),label:tc(e,a),kind:`file`,...e.isSubagent?{indent:1}:{}}));return t.length===0?o.push({id:Qs(e.projectId),label:`Start first chat`,kind:`action`}):t.length>5&&o.push({id:`toggle:${e.projectId}`,label:r?`Show less`:`Show more`,kind:`action`}),{id:Xs(e.projectId),label:e.name,kind:`project`,children:o}}),t=dl(ul(n.filter(e=>!e.projectId),i));if(t.length>0){let n=fl(t,i,h.has(`unassigned`)).map(e=>({id:Zs(e.sessionId),label:tc(e,t),kind:`file`,...e.isSubagent?{indent:1}:{}}));t.length>5&&n.push({id:`toggle:unassigned`,label:h.has(`unassigned`)?`Show less`:`Show more`,kind:`action`}),e.push({id:`project:unassigned`,label:`Unassigned`,kind:`folder`,children:n})}return e},[i,n,h,B]),H=(0,X.useCallback)(e=>{o?o(e):(s?.(e),a())},[a,o,s]);return{loadDirectories:R,projectById:z,sortedProjects:B,sidebarItems:V,resumeResource:(0,X.useCallback)(e=>{let t=$s(e,`toggle:`);if(t){_(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});return}let r=$s(e,qs);if(r){H(r);return}let i=$s(e,Ys);if(!i)return;let a=n.find(e=>e.sessionId===i);a&&c(a)},[H,c,n,_]),toggleProjectResource:(0,X.useCallback)(e=>{g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[g]),selectSearchResult:(0,X.useCallback)(e=>{let t=$s(e,`search-project:`);if(t){let e=Xs(t);g(t=>t.includes(e)?t:[...t,e]),s?.(t),v(!1);return}let r=$s(e,`search-session:`),i=r?n.find(e=>e.sessionId===r):void 0;if(i){if(i.projectId){let e=Xs(i.projectId);g(t=>t.includes(e)?t:[...t,e])}c(i),v(!1)}},[s,c,n,g,v]),renderMenu:(0,X.useCallback)((e,r)=>{let i=$s(e.id,Ys),a=$s(e.id,`project:`);if(i){let e=n.find(e=>e.sessionId===i);if(!e)return null;let a=e.projectId??void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($l,{icon:Hr,label:`Rename`,onClick:()=>{r.close(),w(e),T(tc(e))}}),u&&t.length>1?(0,Z.jsx)($l,{icon:Ya,label:`Fork into project`,onClick:()=>{r.close(),E(e),D(t.find(t=>t.projectId!==e.projectId)?.projectId)}}):null,d&&a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t`}),Ql.map(([e,t,n])=>(0,Z.jsx)($l,{icon:n,label:t,onClick:()=>{r.close(),d({panel:e,projectId:a,focus:!0})}},e))]}):null,(0,Z.jsx)($l,{icon:In,label:`Delete`,destructive:!0,onClick:()=>{r.close(),O(e)}})]})}if(a&&a!==`unassigned`){let e=z.get(a);return e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($l,{icon:Hr,label:`Rename project`,onClick:()=>{r.close(),k(e),A(e.name)}}),(0,Z.jsx)($l,{icon:ao,label:`Unregister project`,destructive:!0,onClick:()=>{r.close(),j(e)}}),d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t`}),Ql.map(([e,t,n])=>(0,Z.jsx)($l,{icon:n,label:t,onClick:()=>{r.close(),d({panel:e,projectId:a,focus:!0})}},e))]}):null]}):null}return null},[u,d,z,n,t,O,D,E,A,k,w,T,j]),submitCreate:async()=>{let e=M.trim();if(!(!l||!e&&!N)){ee(!0),L(null);try{await l({path:N?void 0:e,directoryToken:N,name:P.trim()||void 0}),I(!1),C(``),F(``),S(void 0),y(null),x(null)}catch(e){L(ac(e,`Could not add this project.`))}finally{ee(!1)}}}}}function tu(e){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(sc,{...e}),(0,Z.jsx)(Es,{...e})]})}function nu({data:e,sessionActions:t,projectActions:n={},navigationActions:r={},slots:i={}}){let{sessions:a,projects:o=Ks,projectSessions:s=a,activeProjectId:c,activeSessionId:l}=e,{onNewSession:u,onNewSessionInProject:d,onResumeSession:f,onRenameSession:p,onDeleteSession:m}=t,{onProjectSelect:h,onCreateProject:g,onRenameProject:_,onUnregisterProject:v,onForkSessionIntoProject:y}=n,{onOpenPanelAction:b,onBrowseDirectories:x,onOpenSettings:S}=r,{accountMenu:C}=i,w=Zl(c),{loadDirectories:T,projectById:E,sortedProjects:D,sidebarItems:O,resumeResource:k,toggleProjectResource:A,selectSearchResult:j,renderMenu:M,submitCreate:N}=eu({sessions:a,projects:o,projectSessions:s,activeProjectId:c,activeSessionId:l,onNewSession:u,onNewSessionInProject:d,onProjectSelect:h,onResumeSession:f,onCreateProject:g,onForkSessionIntoProject:y,onOpenPanelAction:b,onBrowseDirectories:x,createOpen:w.createOpen,expandedProjectIds:w.expandedProjectIds,revealedProjectIds:w.revealedProjectIds,setExpandedProjectIds:w.setExpandedProjectIds,setRevealedProjectIds:w.setRevealedProjectIds,setSearchOpen:w.setSearchOpen,setDirectoryBrowser:w.setDirectoryBrowser,setDirectoryBrowseLoading:w.setDirectoryBrowseLoading,setDirectoryBrowseError:w.setDirectoryBrowseError,setDirectoryToken:w.setDirectoryToken,setCreatePath:w.setCreatePath,setRenameTarget:w.setRenameTarget,setRenameTitle:w.setRenameTitle,setForkTarget:w.setForkTarget,setForkProjectId:w.setForkProjectId,setDeleteTarget:w.setDeleteTarget,setRenameProjectTarget:w.setRenameProjectTarget,setRenameProjectName:w.setRenameProjectName,setUnregisterTarget:w.setUnregisterTarget,createPath:w.createPath,directoryToken:w.directoryToken,createName:w.createName,setCreateName:w.setCreateName,setCreateOpen:w.setCreateOpen,setCreateSubmitError:w.setCreateSubmitError,setCreateSubmitting:w.setCreateSubmitting});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Yl,{brandMenuOpen:w.brandMenuOpen,setBrandMenuOpen:w.setBrandMenuOpen,searchOpen:w.searchOpen,setSearchOpen:w.setSearchOpen,query:w.query,setQuery:w.setQuery,projectActionsOpen:w.projectActionsOpen,setProjectActionsOpen:w.setProjectActionsOpen,expandedProjectIds:w.expandedProjectIds,setExpandedProjectIds:w.setExpandedProjectIds,setCreateOpen:w.setCreateOpen,projects:o,projectSessions:s,sidebarItems:O,sortedProjects:D,projectById:E,activeProjectId:c,activeSessionId:l,onNewSession:u,onNewSessionInProject:d,onProjectSelect:h,onRenameSession:p,onCreateProject:g,onOpenSettings:S,accountMenu:C,resumeResource:k,toggleProjectResource:A,selectSearchResult:j,renderMenu:M}),(0,Z.jsx)(tu,{projects:o,onRenameSession:p,onDeleteSession:m,onRenameProject:_,onUnregisterProject:v,onForkSessionIntoProject:y,onBrowseDirectories:x,createOpen:w.createOpen,setCreateOpen:w.setCreateOpen,directoryBrowser:w.directoryBrowser,setDirectoryBrowser:w.setDirectoryBrowser,directoryBrowseLoading:w.directoryBrowseLoading,directoryBrowseError:w.directoryBrowseError,setDirectoryBrowseError:w.setDirectoryBrowseError,directoryToken:w.directoryToken,setDirectoryToken:w.setDirectoryToken,createName:w.createName,setCreateName:w.setCreateName,createPath:w.createPath,setCreatePath:w.setCreatePath,renameTarget:w.renameTarget,setRenameTarget:w.setRenameTarget,renameTitle:w.renameTitle,setRenameTitle:w.setRenameTitle,renameProjectTarget:w.renameProjectTarget,setRenameProjectTarget:w.setRenameProjectTarget,renameProjectName:w.renameProjectName,setRenameProjectName:w.setRenameProjectName,deleteTarget:w.deleteTarget,setDeleteTarget:w.setDeleteTarget,unregisterTarget:w.unregisterTarget,setUnregisterTarget:w.setUnregisterTarget,forkTarget:w.forkTarget,setForkTarget:w.setForkTarget,forkProjectId:w.forkProjectId,setForkProjectId:w.setForkProjectId,createSubmitting:w.createSubmitting,createSubmitError:w.createSubmitError,setCreateSubmitError:w.setCreateSubmitError,loadDirectories:T,submitCreate:N})]})}function ru({children:e,className:t,sidebarWidth:n=`17rem`,style:r,...i}){return(0,Z.jsx)(Qc,{...i,style:{...r,"--sidebar-width":n},className:U(`min-h-0 w-full overflow-hidden rounded-2xl border border-border bg-background`,t),children:e})}var iu=Y({key:J(),provider:J(),id:J(),name:J(),version:J().optional(),reasoning:hi(),input:q(vi([`text`,`image`])),contextWindow:di().optional(),maxTokens:di().optional(),available:hi(),defaultThinkingLevel:Ri.optional(),thinkingLevels:q(Ri).optional()}).openapi({description:`Chat model info`}),au=Y({models:q(iu),selectedModelKey:J().optional(),defaultProvider:J().optional(),defaultModel:J().optional(),defaultThinkingLevel:Ri.optional(),diagnostics:q(J())}).openapi({description:`Chat models response`}),ou=Y({providerId:J().min(1).max(128)}).openapi({description:`Discover models for a provider`}),su=Y({providerId:J(),models:q(iu)}).openapi({description:`Discovered models for a provider`}),cu=Y({activationStatus:vi([`active`,`staged`,`reload-required`]).optional(),name:J(),description:J().optional(),installedInWorkspace:hi().optional(),path:J().optional(),source:J().optional(),workspacePath:J().optional(),argumentHint:J().optional()}).openapi({description:`Chat resource info`}),lu=Y({packages:q(cu),skills:q(cu),prompts:q(cu),extensions:q(cu),themes:q(cu),agentsFiles:q(cu),diagnostics:q(J())}).openapi({description:`Chat resources response`}),uu=bi(()=>Y({name:J(),path:J(),type:vi([`directory`,`file`]),children:q(uu).optional()})),du=Y({root:J(),nodes:q(uu),diagnostics:q(J())}).openapi({description:`Workspace tree response`}),fu=Y({path:J(),name:J(),content:J(),mediaType:vi([`text/markdown`,`text/plain`,`application/octet-stream`]),size:di().optional(),status:vi([`ok`,`too-large`,`unsupported`]).optional()}).openapi({description:`Workspace file preview response`}),pu=Y({name:J(),path:J()}).openapi({description:`Directory entry in the project-folder picker`}),mu=Y({path:J(),parent:J().nullable(),entries:q(pu)}).openapi({description:`Workspace directory browse response`}),hu=Y({id:J(),name:J(),isConfigured:hi(),envVarName:J(),authType:vi([`apiKey`,`oauth`]).optional(),supportsOAuth:hi().optional(),providerFamily:J().optional(),displayName:J().optional(),api:vi([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),baseUrl:J().optional(),modelIds:q(J().max(4096)).max(64).optional(),discoverable:hi().optional()}).openapi({description:`Chat provider info`}),gu=Y({providers:q(hu)}).openapi({description:`Chat providers response`}),_u=Y({providerId:J(),apiKey:J().max(4096),baseUrl:J().max(4096).optional(),modelId:J().max(4096).optional(),displayName:J().max(256).optional(),createOccInstance:hi().optional(),api:vi([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),models:q(J().max(4096)).max(64).optional()}).openapi({description:`Chat provider update request`}),vu=Y({success:hi(),providers:q(hu),reloadRequired:hi().optional()}).openapi({description:`Chat provider update response`}),yu=Y({providerId:J()}).openapi({description:`Chat provider remove request`});vu.openapi({description:`Chat provider remove response`});var bu=vi([`waiting`,`success`,`error`]).openapi({description:`OAuth login status`}),xu=Y({message:J(),placeholder:J().optional(),allowEmpty:hi().optional()}).openapi({description:`Interactive OAuth prompt`}),Su=Y({providerId:J().min(1),loginId:J().min(1).optional(),promptAnswer:J().max(8192).optional(),cancel:hi().optional()}).openapi({description:`Chat provider OAuth login request`}),Cu=Y({status:bu,loginId:J().optional(),authUrl:J().optional(),userCode:J().optional(),instructions:J().optional(),prompt:xu.optional(),error:J().optional(),providers:q(hu).optional()}).openapi({description:`Chat provider OAuth login response`}),wu=Y({name:J(),description:J().optional(),argumentHint:J().optional(),source:vi([`builtin`,`extension`,`prompt`,`skill`]),passThrough:hi().optional()}).openapi({description:`Chat slash command info`}),Tu=Y({commands:q(wu),diagnostics:q(J())}).openapi({description:`Chat slash commands response`}),Eu=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,Du=/^[A-Za-z_][A-Za-z0-9_]*$/,Ou=J().regex(Eu,`MCP server names must be 1-64 letters, numbers, underscores, or hyphens and start with a letter or number.`),ku=J().regex(Du,`Environment variable names must be letters, digits, or underscores.`),Au=vi([`builtin`,`user`]),ju=vi([`http`,`stdio`]),Mu=vi([`connected`,`needs_auth`,`disabled`,`anonymous`]),Nu=Y({child:ku,source:ku}).openapi({description:`Stdio env mapping as CHILD=SOURCE variable names only`}),Pu=Y({name:Ou,label:Ai,source:Au,transport:ju,url:J().optional(),commandPreview:J().optional(),cwdPreview:J().optional(),usesOAuth:hi(),enabled:hi(),status:Mu,bearerTokenEnvVar:J().optional(),envBindings:q(Nu).optional(),error:J().optional()}).openapi({description:`Browser-safe MCP connection row; never includes tokens or env values`}),Fu=Y({connections:q(Pu)}).openapi({description:`MCP connection list`}),Iu=Y({name:Ou,transport:Ki(`http`),url:Ai,oauth:hi().optional(),bearerTokenEnvVar:ku.optional(),force:hi().optional()}),Lu=Y({name:Ou,transport:Ki(`stdio`),command:Ai,args:q(J().min(1).max(1024)).max(32).optional(),cwd:J().min(1).max(1024).optional(),env:q(Nu).max(32).optional(),force:hi().optional()}),Ru=gi(`transport`,[Iu,Lu]).openapi({description:`Add or replace a user MCP server`}),zu=Y({name:Ou}).openapi({description:`Remove a user MCP server`}),Bu=vi([`login`,`logout`,`reconnect`]),Vu=Y({name:Ou,action:Bu.optional(),loginId:J().min(1).optional(),promptAnswer:J().max(8192).optional(),cancel:hi().optional()}).openapi({description:`MCP OAuth login, logout, or reconnect`}),Hu=Y({status:bu,loginId:J().optional(),authUrl:J().optional(),userCode:J().optional(),instructions:J().optional(),prompt:xu.optional(),error:J().optional(),connections:q(Pu).optional()}).openapi({description:`MCP OAuth login snapshot`});Y({message:J()}).openapi({description:`Error response`}),Y({status:Ki(`ok`)}).openapi({description:`Health check response`});var Uu=Ai.max(1024),Wu=q(Uu),Gu=Wu.max(100),Ku=Y({source:Ai,extensions:q(Ai).optional(),skills:q(Ai).optional(),prompts:q(Ai).optional(),themes:q(Ai).optional()}),qu=Si([Ai,Ku]),Ju=q(qu),Yu=Ju.max(100),Xu=Y({compaction:Y({enabled:hi(),reserveTokens:Ci,keepRecentTokens:Ci}),defaultModel:J().optional(),defaultProvider:J().optional(),defaultThinkingLevel:Ri.optional(),enableSkillCommands:hi(),enabledModels:q(Ai).optional(),extensions:Wu,followUpMode:Oi,packages:Ju,prompts:Wu,retry:Y({enabled:hi(),maxRetries:ki,baseDelayMs:ki}),skills:Wu,steeringMode:Oi,themes:Wu,transport:Fi}).openapi({description:`Editable Pi settings`}),Zu=Y({compaction:Xu.shape.compaction.partial().optional(),defaultModel:J().optional(),defaultProvider:J().optional(),defaultThinkingLevel:Ri.optional(),enableSkillCommands:hi().optional(),enabledModels:q(Ai).nullable().optional(),extensions:Gu.optional(),followUpMode:Oi.optional(),packages:Yu.optional(),prompts:Gu.optional(),retry:Xu.shape.retry.partial().optional(),skills:Gu.optional(),steeringMode:Oi.optional(),themes:Gu.optional(),transport:Fi.optional()}).strict().openapi({description:`Pi settings update`}),Qu=Y({compaction:Xu.shape.compaction.partial().optional(),defaultModel:J().optional(),defaultProvider:J().optional(),defaultThinkingLevel:Ri.optional(),enableSkillCommands:hi().optional(),enabledModels:q(Ai).nullable().optional(),extensions:Wu.optional(),followUpMode:Oi.optional(),packages:Ju.optional(),prompts:Wu.optional(),retry:Xu.shape.retry.partial().optional(),skills:Wu.optional(),steeringMode:Oi.optional(),themes:Wu.optional(),transport:Fi.optional()}).strict(),$u=Y({settings:Zu}).openapi({description:`Pi settings update request`}),ed=Y({diagnostics:q(J()),effective:Xu,project:Qu,projectPath:J(),updateImpact:Y({newSessionRecommended:hi(),resourceReloadRequired:hi()})}).openapi({description:`Pi settings response`}),td=[`/api/health`,`/api/chat`,`/api/projects`,`/api/workspace`];function nd(){return``}function rd(e){return td.some(t=>e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`))}function id(e){let t=nd();if(!t)return e;let[n]=e.split(`?`);return rd(n)?`${t}${e}`:e}function ad(){return null}var od=class extends Error{status;body;code;remediation;constructor(e,t){super(ld(e,t)),this.name=`ChatRequestError`,this.status=e,this.body=t;let n=cd(t);this.code=n?.code,this.remediation=n?.remediation}};function sd(e){return typeof e==`object`&&!!e&&typeof e.action==`string`&&typeof e.label==`string`}function cd(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(typeof e.code==`string`)return{code:e.code,remediation:sd(e.remediation)?e.remediation:void 0}}catch{}return null}function ld(e,t){let n=t.trim();if(!n)return`Request failed (${e})`;try{let e=JSON.parse(n);if(typeof e.message==`string`&&e.message.length>0)return e.message}catch{}return n}function ud(e){return(e instanceof od?e.body:e instanceof Error?e.message:String(e)).includes(`Session belongs to another user`)}function dd(e){return e instanceof od&&e.status===404}function fd(e){return e instanceof Error?e.code===`NETWORK_DISCONNECTED`||/daemon is not connected/i.test(e.message)||/cannot send daemon command/i.test(e.message):!1}function pd(e){let t=Error(e.message);return e.code&&(t.code=e.code),t}async function md(e){let t=new Headers(e?.headers),n=await ad();return n&&t.set(`Authorization`,`Bearer ${n}`),t}async function hd(e,t){let n=id(e),r=async e=>{let i=await md(t),a=await fetch(n,{...t,headers:i});if(a.status===401&&e)return r(!1);if(!a.ok){let e=await a.text();throw new od(a.status,e)}return await a.json()};return r(!0)}async function Q(e,t,n){return _d(t,await hd(e,n),`Response from ${e}`)}async function gd(e,t){let n=e.body?.getReader();if(!n)throw Error(`Chat response did not include a stream`);let r=new TextDecoder,i=``,a=new Map;function o(e,t,n){let r=a.get(`${e}:${t}`)??0;n>r+1&&console.warn(`[chat-sequence] Gap detected in ${t} sequence for session ${e}: expected ${r+1}, got ${n}`),a.set(`${e}:${t}`,n)}let s=e=>{let n=e.trim();if(!n)return;let r=JSON.parse(n),i=typeof r==`object`&&r?`type`in r&&r.type:void 0,a=typeof r==`object`&&r&&`sessionId`in r?String(r.sessionId):void 0,s=typeof r==`object`&&r&&`sequenceNumber`in r?Number(r.sequenceNumber):void 0;if(i===`start`||i===`done`||i===`error`||i===`plan`||i===`state`||i===`tool`||i===`queue`||i===`reasoning`||i===`compaction`||i===`retry`||i===`payload`||i===`session_snapshot`){let e=_d(Di,r,`Chat stream event`);a&&s!==void 0&&o(a,String(e.type),s),t(e)}else t(r)};for(;;){let{value:e,done:t}=await n.read();if(t)break;let a=r.decode(e,{stream:!0});i+=a;let o=i.indexOf(`
3
+ `);for(;o>=0;)s(i.slice(0,o)),i=i.slice(o+1),o=i.indexOf(`
4
+ `)}i+=r.decode(),s(i)}function _d(e,t,n){let r=e.safeParse(t);if(r.success)return r.data;throw Error(`${n} did not match the expected contract`)}function vd(e){let t=new URLSearchParams;return e.sessionId&&t.set(`sessionId`,e.sessionId),e.projectId&&t.set(`projectId`,e.projectId),e.openUI&&t.set(`openUI`,`true`),t.toString()}function yd(e){switch(e){case`agent_start`:return`Working`;case`turn_start`:return`Waiting`;case`message_start`:return`Thinking`;case`message_end`:return`Writing`;case`tool_start`:case`tool_execution_start`:case`tool_execution`:return`Executing`;case`tool_end`:case`tool_execution_end`:return`Writing`;case`turn_end`:return`Turn finished`;case`agent_end`:return;default:return}}function bd(e){fd(e)||oi.error(e instanceof Error?e.message:String(e))}function xd(e){Promise.resolve().then(e).catch(bd)}function Sd(e,t){return{modelKey:e.modelKey,models:e.models,infoDescription:e.infoDescription,slashCommands:e.slashCommands,questionBar:e.pendingQuestionBar,chatMode:e.chatMode,onChatModeChange:e.setChatMode,onModelChange:e.setModelKey,thinkingLevel:e.thinkingLevel,onThinkingLevelChange:e.setThinkingLevel,attachments:{onAttach:e.handleAttach,images:e.uploadedAttachments.flatMap(e=>e.mimeType.startsWith(`image/`)?[{id:e.attachmentId,filename:e.name,size:e.size,url:id(`/api/chat/session?sessionId=${encodeURIComponent(t??``)}&attachmentId=${encodeURIComponent(e.attachmentId)}`)}]:[]),files:e.uploadedAttachments.flatMap(e=>e.mimeType.startsWith(`image/`)?[]:[{id:e.attachmentId,filename:e.name,size:e.size}]),onRemoveImage:e.removeUploadedAttachment,onRemoveFile:e.removeUploadedAttachment},workspaceReferences:e.workspaceAttachments,workspaceSuggestions:e.workspaceReferenceSuggestions,onWorkspaceReferenceSelect:e.addWorkspaceAttachment,onRemoveWorkspaceReference:e.removeWorkspaceAttachment,onSlashCommandSelect:e.handleSlashCommandSelect,onLocalSlashSubmit:e.handleLocalSlashSubmit,modelPickerOpen:e.modelPickerOpen,onModelPickerOpenChange:e.setModelPickerOpen,effortPickerOpen:e.effortPickerOpen,onEffortPickerOpenChange:e.setEffortPickerOpen}}var Cd=[];function wd({label:e,active:t=!1,onClick:n,children:r}){let i=Ke()??!1;return(0,Z.jsx)(K.button,{type:`button`,"aria-label":e,title:e,"aria-pressed":e===`Helpful`||e===`Not helpful`?t:void 0,onClick:n,whileTap:i?void 0:{scale:.9},transition:ke,className:U(`grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,t&&`bg-muted text-foreground`),children:r})}function Td({children:e,status:t=`streaming`,copyText:n,onCopy:r,onRetry:i,sources:a=Cd,sourcesOpen:o,defaultSourcesOpen:s=!1,onSourcesOpenChange:c,sourceIdPrefix:l,feedback:u,defaultFeedback:d=null,onFeedbackChange:f,announce:p=!0,showActions:m=!0,className:h,contentClassName:g,actionsClassName:_}){let v=Ke()??!1,y=(0,X.useId)(),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(d),[w,T]=(0,X.useState)(s),E=(0,X.useRef)(void 0),D=u??S,O=o??w,k=t===`streaming`,A=t===`complete`,j=!!(n||r),M=a.length>0,N=m&&!k&&(j||i||A||M),P=`${y}-sources`,F=l??`response-source-${y.replace(/:/g,``)}`;(0,X.useEffect)(()=>()=>{E.current&&window.clearTimeout(E.current)},[]);let I=(0,X.useCallback)(async()=>{r?await r():n&&await navigator.clipboard?.writeText(n),x(!0),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>x(!1),1600)},[n,r]),L=e=>{let t=D===e?null:e;u===void 0&&C(t),f?.(t)},ee=(0,X.useCallback)(e=>{o===void 0&&T(e),c?.(e)},[c,o]);return(0,Z.jsxs)(`div`,{"data-state":t,"aria-busy":k,className:U(`w-full`,h),children:[(0,Z.jsx)(`div`,{"aria-live":p?`polite`:`off`,className:U(`text-sm leading-6 text-foreground/90 [&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:space-y-1 [&_ol]:pl-5 [&_p+p]:mt-3 [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:border [&_pre]:border-border [&_pre]:bg-muted/45 [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_ul]:my-3 [&_ul]:list-disc [&_ul]:space-y-1 [&_ul]:pl-5`,g),children:e}),(0,Z.jsx)(Ge,{initial:!1,children:N?(0,Z.jsxs)(K.div,{initial:v?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:v?.12:.22,ease:Pe},className:`mt-3`,children:[(0,Z.jsxs)(`div`,{className:U(`flex items-center gap-0.5`,_),children:[j?(0,Z.jsx)(wd,{label:b?`Copied`:`Copy response`,onClick:I,children:b?(0,Z.jsx)(Qn,{className:`size-3.5`}):(0,Z.jsx)(vr,{className:`size-3.5`})}):null,i?(0,Z.jsx)(wd,{label:`Retry response`,onClick:i,children:(0,Z.jsx)(Gr,{className:`size-3.5`})}):null,A?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wd,{label:`Helpful`,active:D===`up`,onClick:()=>L(`up`),children:(0,Z.jsx)(io,{className:`size-3.5`})}),(0,Z.jsx)(wd,{label:`Not helpful`,active:D===`down`,onClick:()=>L(`down`),children:(0,Z.jsx)(ro,{className:`size-3.5`})})]}):null,M?(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":P,onClick:()=>ee(!O),className:`group ml-1 inline-flex min-h-7 items-center gap-2 rounded-md px-1.5 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsx)(Gn,{citations:a}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[a.length,` `,a.length===1?`source`:`sources`]}),(0,Z.jsx)(K.span,{"aria-hidden":`true`,animate:{rotate:O?180:0},transition:v?{duration:0}:Ie,className:`text-muted-foreground/50 group-hover:text-muted-foreground`,children:(0,Z.jsx)($n,{className:`size-3`})})]}):null]}),M?(0,Z.jsx)(li,{id:P,open:O,children:(0,Z.jsx)(Jn,{citations:a,idPrefix:F,className:`mt-2 rounded-xl bg-muted p-2`})}):null]}):null})]})}function Ed(e){if(e.length===1){let t=e[0];if(t?.type===`search`)return`Checking a source…`;if(t?.type===`tool`)return`Working with ${t.action}…`}return e.length>1?`Coordinating ${e.length} active actions…`:`Working through the run…`}function Dd(e){return e.length===1?`Completed 1 tracked action`:`Completed ${e.length} tracked actions`}var Od=`Fleet Prime is not connected to the Prime Agent runtime. Start or reconnect the runtime, then try again.`;function kd(e){return e.code===`NETWORK_DISCONNECTED`||/Cannot send daemon command/i.test(e.message)||/Prime Agent daemon is not connected/i.test(e.message)||/not connected to the Prime Agent runtime/i.test(e.message)?{title:`Agent unavailable`,message:Od}:{title:`Request failed`,message:e.message.replace(/\s+(?:Socket|Daemon log):\s*[^\n]*(?:\s+(?:Socket|Daemon log):\s*[^\n]*)*/gi,``)}}var Ad=[{id:`welcome-explore-codebase`,label:`Explore codebase`,value:`Explore this codebase and explain its architecture, important modules, and main entry points.`},{id:`welcome-review-changes`,label:`Review changes`,value:`Review my current changes for bugs, regressions, architecture issues, and code quality problems.`},{id:`welcome-fix-issue`,label:`Fix an issue`,value:`Help me investigate and fix an issue in this project.`},{id:`welcome-plan-feature`,label:`Plan a feature`,value:`Explore the relevant code and create an implementation plan for a new feature before making changes.`}];function jd({disabled:e,onSelect:t,composer:n}){return(0,Z.jsxs)(`section`,{"aria-labelledby":`fleet-welcome-title`,className:`flex w-full max-w-an flex-col items-center text-center`,children:[(0,Z.jsx)(`h1`,{id:`fleet-welcome-title`,className:`text-2xl font-normal tracking-tight text-foreground sm:text-3xl`,children:`What should Fleet Prime Agent work on?`}),(0,Z.jsx)(`div`,{className:`mt-6 w-full`,children:n}),(0,Z.jsx)(`div`,{"aria-label":`Suggested prompts`,className:`mt-4 flex w-full flex-wrap justify-center gap-2`,children:Ad.map(n=>(0,Z.jsx)(z,{type:`button`,variant:`outline`,size:`sm`,disabled:e||n.disabled,onClick:()=>t(n),className:`min-h-8 rounded-full border-border/70 bg-background/70 px-4 py-1.5 text-center text-sm font-normal text-foreground/80 shadow-sm hover:border-primary/40 hover:bg-primary/5 hover:text-foreground motion-reduce:transition-none`,children:n.label},n.id))})]})}Array.from({length:14},(e,t)=>t);function Md(e,t){return(0,X.useMemo)(()=>{if(!t||!e.startsWith(`/`))return[];let n=e.slice(1).toLowerCase();return t.filter(e=>e.name.startsWith(n))},[t,e])}function Nd(e,t){return(0,X.useMemo)(()=>{if(!t)return[];let n=/(?:^|\s)@([^\s@]*)$/.exec(e);if(!n)return[];let r=n[1]?.toLowerCase()??``;return t.filter(e=>[e.name,e.id,e.path,e.description].filter(Boolean).join(` `).toLowerCase().includes(r))},[t,e])}function Pd({open:e,align:t=`start`,className:n,...r}){return(0,Z.jsx)(`div`,{"data-slot":`composer-menu`,"data-open":e||void 0,className:U(ii,`absolute bottom-full z-10 mb-2 flex w-72 flex-col gap-0.5 rounded-2xl p-1.5`,t===`start`?`start-0 origin-bottom-left`:`end-0 origin-bottom-right`,`transition-[opacity,scale] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none`,e?`scale-100 opacity-100`:`pointer-events-none scale-[0.97] opacity-0`,n),...r})}function Fd({active:e=!1,className:t,...n}){return(0,Z.jsx)(`button`,{type:`button`,"data-slot":`composer-menu-item`,"data-active":e||void 0,className:U(`flex w-full items-center gap-2.5 rounded-[10px] px-2.5 py-2 text-[0.84375rem] transition-colors`,e?ti:`hover:bg-foreground/[0.04]`,t),...n})}function Id(e,t){return t.icon?t.icon:e===`mention`?t.metadata?.kind===`folder`?(0,Z.jsx)(zr,{"aria-hidden":`true`,className:`size-4`}):(0,Z.jsx)(xr,{"aria-hidden":`true`,className:`size-4`}):(0,Z.jsx)(Ga,{"aria-hidden":`true`,className:`size-4`})}function Ld(e,t){return e&&e.length>0?e.flatMap(e=>e.items):t?[...t]:[]}var Rd=(0,X.memo)(function({open:e,kind:t,query:n,items:r,groups:i,activeIndex:a=0,onActiveIndexChange:o,onSelect:s,onClose:c,onBack:l,className:u,emptyLabel:d=`No matching items`,title:f,listId:p=`fleet-composer-trigger-list`}){let m=(0,X.useMemo)(()=>Ld(i,r),[i,r]);if(!e)return null;let h=!!(i&&i.length>0),g=m[a],_=(e,n)=>{let r=n===a,i=`${p}-${e.id.replace(/[^a-zA-Z0-9_-]/g,`-`)}`;return(0,Z.jsxs)(Fd,{id:i,disabled:e.disabled,role:`option`,"aria-selected":r,"data-active":r?`true`:void 0,active:r,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>o?.(n),onClick:()=>{e.disabled||s(e)},className:U(`flex min-h-10 cursor-pointer items-start gap-2 rounded-lg px-3 py-2 text-left`,r&&`bg-accent text-accent-foreground`),children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-muted-foreground`,children:Id(t,e)}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.label}),e.description?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-muted-foreground`,children:e.description}):null]}),r?(0,Z.jsx)(pr,{"aria-hidden":`true`,className:`mt-1 size-3.5 shrink-0 text-muted-foreground`}):null]},e.id)};return e?(0,Z.jsxs)(Pd,{open:!0,id:p,role:`listbox`,"aria-label":f??`Suggestions`,"aria-activedescendant":g?`${p}-${g.id.replace(/[^a-zA-Z0-9_-]/g,`-`)}`:void 0,"data-slot":`composer-trigger-popover`,"data-kind":t,"data-state":`open`,className:U(`inset-x-0 z-50 mb-2 w-auto overflow-hidden rounded-xl border bg-popover text-popover-foreground shadow-xl`,u),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2 text-xs text-muted-foreground`,children:[l?(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Back`,onClick:l,className:`grid size-6 place-items-center rounded-md hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Z.jsx)(cr,{"aria-hidden":`true`,className:`size-3.5`})}):null,(0,Z.jsx)(Jr,{"aria-hidden":`true`,className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:f??(t===`slash`?`Commands`:`Workspace`)}),n?(0,Z.jsx)(`span`,{className:`ml-auto max-w-[50%] truncate font-mono text-[0.6875rem]`,children:n}):null,c?(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close suggestions`,onClick:c,className:`sr-only`,children:`Close suggestions`}):null]}),(0,Z.jsxs)(`div`,{className:`max-h-[min(42vh,360px)] overflow-y-auto p-1.5`,children:[m.length===0?(0,Z.jsx)(`div`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:d}):null,h?i?.map(e=>{let t=0;for(let n of i){if(n.id===e.id)break;t+=n.items.length}return(0,Z.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,Z.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[0.625rem] font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),e.items.map((e,n)=>_(e,t+n))]},e.id)}):m.map(_)]})]}):null}),zd=(0,X.lazy)(()=>ei(async()=>{let{ModelSelectorList:e}=await import(`./model-selector-list-CoXX358G.js`);return{ModelSelectorList:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({ModelSelectorList:e})=>({default:e})));function Bd(e){return(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`h-24 animate-pulse rounded-md bg-muted/40 p-1.5`,"aria-label":`Loading models`,role:`status`}),children:(0,Z.jsx)(zd,{...e})})}var Vd=(0,X.memo)(function({models:e,value:t,effort:n,open:r,onOpenChange:i,onModelChange:a,onEffortChange:o,placeholder:s=`Model`,effortLabel:c=`Reasoning effort`,className:l,contentClassName:u}){let[d,f]=(0,X.useState)(!1),p=(0,X.useId)(),m=r??d,h=e=>{r===void 0&&f(e),i?.(e)},g=e.find(e=>e.id===t)??e[0],_=g?.efforts?.find(e=>e.id===n)??g?.efforts?.[0],v=(0,Z.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-expanded":m,"aria-controls":p,"aria-haspopup":`dialog`,"aria-label":`Select model and reasoning effort`,className:U(`relative inline-flex h-8 max-w-[18rem] min-w-0 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,l),children:[g?.icon?(0,Z.jsx)(`span`,{className:`shrink-0`,children:g.icon}):null,(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:g?.name??s}),_&&g?.reasoning?(0,Z.jsxs)(`span`,{className:`hidden shrink-0 text-muted-foreground/70 xl:inline`,children:[`· `,_.name]}):null,(0,Z.jsx)($n,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]});return(0,Z.jsx)(Pc,{contentId:p,open:m,onOpenChange:h,side:`top`,align:`start`,className:U(`w-[min(24rem,calc(100vw-2rem))] max-h-[min(55vh,28rem)] overflow-hidden p-0`,u),trigger:v,children:m?(0,Z.jsx)(Bd,{models:e,selectedModel:g,selectedEffort:_,effortLabel:c,onModelChange:a,onEffortChange:o}):null})}),Hd=[`·`,`•`,`●`,`•`];function Ud({label:e,isActive:t,className:n}){let[r,i]=(0,X.useState)(0),[a,o]=(0,X.useState)(0);return(0,X.useEffect)(()=>{if(!t){i(0),o(0);return}let e=Date.now(),n=window.setInterval(()=>{i(Math.max(0,Math.floor((Date.now()-e)/1e3))),o(e=>e+1)},500);return()=>window.clearInterval(n)},[t]),!t||!e?null:(0,Z.jsxs)(`div`,{className:U(`flex items-center gap-2 px-an-context-padding py-1 text-xs text-foreground/70`,n),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-an-primary-color`,children:Hd[a%Hd.length]}),(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:e}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`truncate`,children:e}),(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`tabular-nums text-foreground/50`,children:[r,`s`]})]})}var Wd=(0,X.memo)(function({modes:e,value:t,defaultValue:n,onChange:r,className:i}){let a=t!==void 0,[o,s]=(0,X.useState)(n),c=a?t:o,l=e.find(e=>e.id===c)??e[0],[u,d]=(0,X.useState)(!1),f=(0,X.useCallback)(e=>{a||s(e),r?.(e),d(!1)},[a,r]);if(e.length===0)return null;let p=l?.icon,m=e.length>1,h=(0,Z.jsxs)(`button`,{type:`button`,className:U(`relative inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full px-2 text-[0.75rem] leading-4 text-foreground/40 transition-[background-color,transform] duration-150 after:absolute after:inset-x-0 after:-top-1.5 after:-bottom-1.5 hover:bg-foreground/6 active:scale-[0.96]`,!m&&`pointer-events-none`,i),"aria-label":`Select mode`,children:[p&&(0,Z.jsx)(p,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:l?.label}),m&&(0,Z.jsx)($n,{className:`size-3 text-foreground/40`})]});return m?(0,Z.jsx)(Pc,{open:u,onOpenChange:d,side:`top`,align:`start`,trigger:h,children:e.map(e=>{let t=e.id===l?.id,n=e.icon;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),className:U(`flex w-full cursor-pointer items-start gap-2 rounded-[6px] px-2 py-2 text-left text-[0.75rem] leading-4 text-foreground transition-[background-color,transform] duration-150 hover:bg-foreground/6 active:scale-[0.96]`,t&&`bg-foreground/6`),children:[n&&(0,Z.jsx)(n,{className:`mt-0.5 size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium`,children:e.label}),e.description&&(0,Z.jsx)(`span`,{className:`block truncate text-foreground/40`,children:e.description})]}),t&&(0,Z.jsx)(Qn,{className:`mt-0.5 size-3.5 shrink-0 text-foreground/60`})]},e.id)})}):h}),Gd=`M5 13l4 4L19 7`,Kd=`M6 12h12`;function qd({checked:e,onCheckedChange:t,disabled:n,indeterminate:r,label:i,className:a,id:o,"aria-label":s,"aria-describedby":c}){let l=(0,X.useId)(),u=o??l,d=Ke(),f=e||r,p=r?Kd:Gd;return(0,Z.jsxs)(`label`,{htmlFor:u,className:U(`inline-flex items-center gap-3`,n?`cursor-not-allowed`:`cursor-pointer`,a),children:[(0,Z.jsx)(K.button,{id:u,type:`button`,role:`checkbox`,"aria-checked":r?`mixed`:e,"aria-label":s,"aria-describedby":c,disabled:n,onClick:()=>!n&&t(!e),whileTap:d||n?void 0:{scale:.92},transition:ke,"data-state":e?`checked`:r?`indeterminate`:`unchecked`,className:U(`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md border-2 outline-none transition-colors duration-200`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-60`,f?`border-primary bg-primary text-primary-foreground`:`border-muted-foreground/50 bg-background hover:border-muted-foreground`),children:(0,Z.jsx)(Ge,{initial:!1,children:f?(0,Z.jsxs)(K.svg,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:3,strokeLinecap:`round`,strokeLinejoin:`round`,initial:d?{opacity:1}:{opacity:0,scale:.5},animate:d?{opacity:1}:{opacity:1,scale:1},exit:d?{opacity:0}:{opacity:0,scale:.5,filter:`blur(4px)`},transition:d?{duration:0}:{duration:.16,ease:Pe},"aria-hidden":!0,children:[(0,Z.jsx)(`title`,{children:r?`Partially selected`:`Selected`}),(0,Z.jsx)(K.path,{d:p,initial:d?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:d?{duration:0}:{duration:r?.2:.3,ease:Pe,delay:.04}})]},r?`indeterminate`:`checked`):null})}),i?(0,Z.jsx)(`span`,{className:U(`select-none text-sm text-foreground`,n&&`opacity-60`),children:i}):null]})}var Jd=(0,X.createContext)(null);function Yd(){let e=(0,X.useContext)(Jd);if(!e)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);return e}function Xd({value:e,defaultValue:t=``,onValueChange:n,children:r,className:i,orientation:a=`vertical`}){let[o,s]=(0,X.useState)(t),c=(0,X.useId)(),l=Ke(),u=e!==void 0,d=u?e:o,f=(0,X.useCallback)(e=>{u||s(e),n?.(e)},[u,n]),p=(0,X.useMemo)(()=>({value:d,setValue:f,layoutId:c}),[d,c,f]);return(0,Z.jsx)(pa,{transition:l?{duration:0}:Me,children:(0,Z.jsx)(Jd.Provider,{value:p,children:(0,Z.jsx)(`div`,{role:`radiogroup`,className:U(`flex gap-3`,a===`vertical`?`flex-col`:`flex-row flex-wrap`,i),children:r})})})}function Zd({value:e,label:t,disabled:n,className:r,id:i}){let{value:a,setValue:o,layoutId:s}=Yd(),c=(0,X.useId)(),l=i??c,u=Ke(),d=a===e;return(0,Z.jsxs)(`label`,{htmlFor:l,className:U(`inline-flex items-center gap-3`,n?`cursor-not-allowed`:`cursor-pointer`,r),children:[(0,Z.jsx)(K.button,{id:l,type:`button`,role:`radio`,"aria-checked":d,disabled:n,onClick:()=>!n&&o(e),whileTap:u||n?void 0:{scale:.92},transition:ke,"data-state":d?`checked`:`unchecked`,className:U(`relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-60`,d?`border-primary`:`border-muted-foreground/50 hover:border-muted-foreground`),children:d?(0,Z.jsx)(K.span,{layoutId:s,className:`absolute inset-1 rounded-full bg-primary`,transition:u?{duration:0}:Me}):null}),t?(0,Z.jsx)(`span`,{className:U(`select-none text-sm text-foreground`,n&&`opacity-60`),children:t}):null]})}var Qd=(0,X.forwardRef)(function({label:e,value:t,defaultValue:n,onChange:r,onFocus:i,onBlur:a,error:o,success:s,leftIcon:c,rightIcon:l,className:u,classNames:d,disabled:f,id:p,type:m,...h},g){let _=(0,X.useId)(),v=p??_,y=Ke(),b=t!==void 0,[x,S]=(0,X.useState)(n??``),C=b?t??``:x,[w,T]=(0,X.useState)(!1),E=(0,X.useRef)(null),D=!!o,O=typeof o==`string`?o:null,k=s?null:l;(0,X.useEffect)(()=>{!E.current||y||!D||Ra(E.current,{x:[0,-6,6,-4,4,-2,0]},{duration:.45})},[D,y]);let A=e=>{b||S(e),r?.(e)};return(0,Z.jsxs)(`div`,{className:U(`flex flex-col gap-1.5`,u,d?.root),children:[e?(0,Z.jsx)(`label`,{htmlFor:v,className:U(`px-1 text-sm font-medium text-foreground`,d?.label),children:e}):null,(0,Z.jsxs)(`div`,{ref:E,"data-state":D?`error`:s?`success`:w?`focused`:`idle`,className:U(`relative h-11 overflow-hidden rounded-full border transition-colors duration-200`,`border-border`,w&&!D&&`border-foreground/40 ring-2 ring-ring/40`,D&&`border-destructive ring-2 ring-destructive/25`,f&&`opacity-60`,d?.field),children:[c?(0,Z.jsx)(`span`,{className:U(`pointer-events-none absolute left-3 top-1/2 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:h-4 [&_svg]:w-4`,d?.leftIcon),children:c}):null,(0,Z.jsx)(`input`,{ref:g,id:v,type:m,value:C,disabled:f,"aria-invalid":D||void 0,"aria-describedby":O?`${v}-error`:void 0,...h,onChange:e=>A(e.target.value),onFocus:e=>{T(!0),i?.(e)},onBlur:e=>{T(!1),a?.(e)},className:U(`peer h-full w-full bg-transparent text-base leading-6 text-foreground caret-foreground outline-none`,`placeholder:text-muted-foreground/60`,c?`pl-10`:`pl-3.5`,k||s?`pr-10`:`pr-3.5`,f&&`cursor-not-allowed`,d?.input)}),s?(0,Z.jsx)(K.svg,{viewBox:`0 0 24 24`,fill:`none`,className:U(`absolute right-3.5 top-1/2 h-5 w-5 -translate-y-1/2 text-(--color-success)`,d?.successIcon),children:(0,Z.jsx)(K.path,{d:`M5 12.5l4.5 4.5L19 7.5`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:y?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:{duration:.35,ease:`easeOut`}})}):k?(0,Z.jsx)(`span`,{className:U(`absolute right-0 top-0 flex h-full items-center text-muted-foreground [&_button]:grid [&_button]:size-11 [&_button]:place-items-center [&_svg]:h-4 [&_svg]:w-4`,d?.rightIcon),children:k}):null]}),(0,Z.jsx)(Ge,{initial:!1,children:O?(0,Z.jsx)(K.p,{id:`${v}-error`,role:`alert`,initial:y?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},animate:{opacity:1,y:0,filter:`blur(0px)`},exit:y?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},transition:{duration:.2},className:U(`px-1 text-xs text-destructive`,d?.errorMessage),children:O}):null})]})}),$d={selected:[],custom:``};function ef(e){return e===`submitting`?`Submitting`:e===`approved`?`Approved`:e===`rejected`?`Rejected`:e===`changes-requested`?`Changes requested`:e===`answered`?`Response submitted`:`Input required`}function tf(e){return e===`approved`||e===`answered`?`text-emerald-600 dark:text-emerald-400`:e===`rejected`?`text-rose-600 dark:text-rose-400`:e===`changes-requested`?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function nf(e){return e===`pending`||e===`changes-requested`?`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`:e===`submitting`?`border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400`:e===`approved`||e===`answered`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`border-rose-500/30 bg-rose-500/10 text-rose-600 dark:text-rose-400`}function rf(e){return e.selected.length>0||!!e.custom?.trim()}function af({question:e,answer:t,disabled:n,onChange:r,onSingleSelect:i}){let a=t.custom??``,o=new Set(t.selected);return(0,Z.jsxs)(`div`,{className:`mt-3`,children:[e.options?.length?e.multiple?(0,Z.jsx)(`div`,{className:`grid gap-0.5`,children:e.options.map(e=>(0,Z.jsx)(qd,{checked:o.has(e.value),disabled:n||e.disabled,label:e.label,onCheckedChange:n=>r({...t,selected:n?[...t.selected,e.value]:t.selected.filter(t=>t!==e.value)}),className:`min-h-9 rounded-lg px-1.5 py-1`},e.value))}):(0,Z.jsx)(Xd,{value:t.selected[0]??``,onValueChange:e=>{r({selected:[e],custom:``}),i?.()},className:`gap-0.5`,children:e.options.map(e=>(0,Z.jsx)(Zd,{value:e.value,label:e.label,disabled:n||e.disabled,className:`min-h-9 rounded-lg px-1.5 py-1`},e.value))}):null,e.allowCustom?(0,Z.jsx)(Qd,{value:a,disabled:n,placeholder:e.customPlaceholder??`Add another response…`,onChange:n=>r({selected:e.multiple?t.selected:[],custom:n}),className:U(`p-0.5`,e.options?.length&&`mt-1.5`),classNames:{field:`h-10 rounded-xl border-0 bg-background/70 focus-within:bg-background`,input:`px-3 text-sm`}}):null]})}function of({current:e,ids:t}){return(0,Z.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`Question `,e+1,` of `,t.length]}),t.map((t,n)=>(0,Z.jsx)(K.span,{"aria-hidden":`true`,initial:{scale:n===e?1:.75,opacity:n<=e?1:.35},animate:{scale:n===e?1:.75,opacity:n<=e?1:.35},transition:Ie,className:`size-1.5 rounded-full bg-foreground`},t))]})}function sf({title:e=`Approval required`,description:t,children:n,questions:r=[],status:i=`pending`,answers:a,defaultAnswers:o={},onAnswersChange:s,step:c,defaultStep:l=0,onStepChange:u,onSubmit:d,onApprove:f,onReject:p,onRequestChanges:m,onDismiss:h,approveLabel:g=`Approve`,submitLabel:_=`Submit response`,result:v,className:y}){let b=Ke()??!1,[x,S]=(0,X.useState)(o),[C,w]=(0,X.useState)(l),T=(0,X.useRef)(void 0),E=a??x,D=Math.min(Math.max(0,c??C),Math.max(0,r.length-1)),O=r[D],k=r.length>0,A=i===`pending`,j=i===`submitting`,M=A||j,N=O?E[O.id]??$d:$d,P=O?.title??e,F=O?.id??String(i),I=ef(i),L=(0,X.useCallback)(()=>{T.current!==void 0&&(window.clearTimeout(T.current),T.current=void 0)},[]);(0,X.useEffect)(()=>L,[L]);let ee=(0,X.useCallback)(e=>{a===void 0&&S(e),s?.(e)},[a,s]),te=e=>{L(),c===void 0&&w(e),u?.(e)};return(0,Z.jsx)(`div`,{"data-state":i,"aria-busy":j,className:U(`w-full overflow-hidden rounded-2xl bg-muted p-4 text-sm`,y),children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:U(`grid size-5 shrink-0 place-items-center text-muted-foreground`,tf(i)),children:j?(0,Z.jsx)(gr,{className:U(`size-4`,!b&&`animate-spin`)}):M?k?(0,Z.jsx)(Ha,{className:`size-4`}):(0,Z.jsx)(Qa,{className:`size-4`}):i===`rejected`?(0,Z.jsx)(Xr,{className:`size-4`}):(0,Z.jsx)(Qn,{className:`size-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(`h3`,{className:`min-w-0 flex-1 text-base font-medium leading-5 text-foreground`,children:(0,Z.jsx)(yr,{value:F,children:P})}),k&&M?(0,Z.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-muted-foreground/65`,children:[D+1,`/`,r.length]}):(0,Z.jsx)(`span`,{className:U(`shrink-0 rounded-full border px-2 py-0.5 text-[0.6875rem] font-medium transition-colors`,nf(i)),children:I}),h?(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:h,className:`grid size-5 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Z.jsx)(Xr,{className:`size-4`})}):null]}),(0,Z.jsxs)(li,{open:M,children:[(0,Z.jsx)(Ge,{initial:!1,mode:`wait`,children:k&&O?(0,Z.jsxs)(K.div,{initial:b?{opacity:1}:{opacity:0,x:8},animate:{opacity:1,x:0},exit:b?{opacity:0}:{opacity:0,x:-6},transition:{duration:b?0:.2,ease:Pe},children:[O.description?(0,Z.jsx)(`p`,{className:`mt-1 leading-5 text-muted-foreground`,children:O.description}):null,(0,Z.jsx)(af,{question:O,answer:N,disabled:j,onChange:e=>{O&&ee({...E,[O.id]:e})},onSingleSelect:()=>{!O||O.multiple||O.autoAdvance===!1||D>=r.length-1||j||(L(),T.current=window.setTimeout(()=>{te(D+1)},240))}})]},O.id):(0,Z.jsxs)(K.div,{initial:!1,children:[t?(0,Z.jsx)(`p`,{className:`mt-1 leading-5 text-muted-foreground`,children:t}):null,n?(0,Z.jsx)(`div`,{className:`mt-3`,children:n}):null]},`description`)}),k?(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,Z.jsx)(Ue,{variant:`ghost`,size:`icon`,"aria-label":`Previous question`,disabled:j||D===0,onClick:()=>te(D-1),className:`rounded-full`,children:(0,Z.jsx)(Fn,{className:`size-4`})}),(0,Z.jsx)(of,{current:D,ids:r.map(e=>e.id)}),(0,Z.jsx)(Ue,{size:D===r.length-1?`sm`:`icon`,"aria-label":D===r.length-1?`Submit response`:`Next question`,disabled:j||!rf(N),onClick:()=>{if(D<r.length-1){te(D+1);return}d?.(E)},className:`ml-auto rounded-full`,children:j?(0,Z.jsx)(gr,{className:U(`size-4`,!b&&`animate-spin`)}):D===r.length-1?(0,Z.jsxs)(Z.Fragment,{children:[_,(0,Z.jsx)(za,{className:`size-3.5`})]}):(0,Z.jsx)(za,{className:`size-4`})})]}):(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Ue,{size:`sm`,disabled:j,onClick:f,className:`rounded-full`,children:g}),m?(0,Z.jsx)(Ue,{variant:`secondary`,size:`sm`,disabled:j,onClick:m,className:`rounded-full`,children:`Request changes`}):null,p?(0,Z.jsx)(Ue,{variant:`ghost`,size:`sm`,disabled:j,onClick:p,className:`rounded-full text-muted-foreground hover:text-rose-600 dark:hover:text-rose-400`,children:`Reject`}):null]})]}),M?null:(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:v??I})]})]})})}function cf({questionBar:e,navigation:t,roundedTop:n,onDismiss:r}){let{totalQuestions:i,clampedQuestionIndex:a,activeQuestion:o,showQuestionNavigation:s,canGoPrev:c,canGoNext:l,goToPreviousQuestion:u,goToNextQuestion:d,advanceQuestionIndex:f}=t;if(!o)return null;let p={id:o.id??`question-${a}`,title:o.title,description:o.description,multiple:o.kind===`multi`,allowCustom:o.kind===`text`||o.allowCustom,customPlaceholder:o.customPlaceholder??o.placeholder,options:o.options?.map(e=>({value:e.id??e.value??e.label,label:e.label}))};return(0,Z.jsxs)(`div`,{className:U(`mx-auto w-full max-w-[calc(100%-24px)] border-x border-t border-border`,n?`rounded-t-an-input-border-radius`:null),children:[(0,Z.jsxs)(`div`,{className:`flex h-7 items-center justify-between border-b border-border px-3 text-xs text-an-tool-color-muted`,children:[(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(qn,{className:`size-3.5`}),`Question`]}),s&&(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:u,disabled:!c,className:`relative inline-flex size-5 items-center justify-center rounded-[4px] transition-[background-color,transform] duration-150 after:absolute after:inset-x-0 after:-top-2.5 after:-bottom-2.5 hover:bg-an-background-secondary active:scale-[0.96] disabled:opacity-40 disabled:active:scale-100`,"aria-label":`Previous question`,children:(0,Z.jsx)(mr,{className:`size-3.5`})}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[a,` of `,i]}),(0,Z.jsx)(`button`,{type:`button`,onClick:d,disabled:!l,className:`relative inline-flex size-5 items-center justify-center rounded-[4px] transition-[background-color,transform] duration-150 after:absolute after:inset-x-0 after:-top-2.5 after:-bottom-2.5 hover:bg-an-background-secondary active:scale-[0.96] disabled:opacity-40 disabled:active:scale-100`,"aria-label":`Next question`,children:(0,Z.jsx)($n,{className:`size-3.5`})})]})]}),(0,Z.jsx)(sf,{title:`Fleet Prime question`,questions:[p],submitLabel:e.submitLabel??`Continue`,status:`pending`,onSubmit:t=>{let n=t[p.id];if(!n)return;let s=n.custom?.trim()||void 0,c=n.selected.filter(e=>e!==`__custom__`),l=o.kind===`text`?{kind:`text`,questionId:o.id,text:s}:{kind:o.kind,questionId:o.id,selectedIds:c,text:s};e.onSubmit(l),a>=i?r(e.id):f()},className:`rounded-none bg-background p-0`},`${a}-${o.title}`),e.allowSkip?(0,Z.jsx)(`div`,{className:`border-t border-border bg-background px-3 py-2`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{e.onSkip?.(),e.onSubmit({kind:`skip`,questionId:o.id}),r(e.id)},className:`text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:e.skipLabel??`Skip`})}):null]})}var lf=[{id:`agent`,label:`Agent`,icon:Zn,description:`Default coding agent`},{id:`plan`,label:`Plan`,icon:Wn,description:`Plan before executing`},{id:`harness`,label:`Harness`,icon:to,description:`Harness-aware turn`}];function uf(e){let[t,n]=(0,X.useState)(1),r=e?.questions??[],i=r.length>0,a=i?r.length:1,o=e?.totalQuestions??a,s=e?.onPreviousQuestion||e?.onNextQuestion?e?.questionIndex??1:t,c=Math.max(1,Math.min(s,o)),l=i?r[c-1]:void 0,u=o>1,d=c>1,f=c<o;return{questionSet:r,totalQuestions:o,clampedQuestionIndex:c,activeQuestion:l,showQuestionNavigation:u,canGoPrev:d,canGoNext:f,goToPreviousQuestion:(0,X.useCallback)(()=>{if(d){if(e?.onPreviousQuestion){e.onPreviousQuestion();return}n(e=>Math.max(1,e-1))}},[d,e]),goToNextQuestion:(0,X.useCallback)(()=>{if(f){if(e?.onNextQuestion){e.onNextQuestion();return}n(e=>Math.min(o,e+1))}},[f,e,o]),advanceQuestionIndex:(0,X.useCallback)(()=>{n(e=>Math.min(o,e+1))},[o])}}var df=[];function ff(e){return e?Array.isArray(e)?e:e.items:[]}function pf(e){return(e.value??e.id).trim().replace(/^\/+/,``).split(/\s+/,1)[0]??e.id}function mf(e){return e.metadata?.argumentHint?.trim()||(e.value?.trim()??``).match(/^\/\S+\s+(.+)$/)?.[1]}function hf({models:e,status:t,thinkingLevel:n,onModelChange:r,onThinkingLevelChange:i,onSend:a,onSlashCommandSelect:o,onLocalSlashSubmit:s,modelPickerOpen:c,onModelPickerOpenChange:l,effortPickerOpen:u,onEffortPickerOpenChange:d,workspaceReferences:f=df,workspaceSuggestions:p,onWorkspaceReferenceSelect:m,onRemoveWorkspaceReference:h,controlled:g,disabled:_,questionBar:v,attachments:y,slashCommands:b}){let[x,S]=(0,X.useState)(``),[C,w]=(0,X.useState)(null),T=g?.value??x,E=g?.onChange??S,D=t===`streaming`||t===`submitted`,O=uf(v),k=ff(b),A=ff(p),j=(0,X.useMemo)(()=>k.map(e=>({name:pf(e),description:[e.description,mf(e)].filter(Boolean).join(` `),icon:Jr})),[k]),M=(0,X.useMemo)(()=>A.map(e=>({id:e.id,name:e.label,path:e.value??e.label,kind:e.metadata?.kind===`folder`?`folder`:`file`,description:e.description,role:`human`})),[A]),N=T.match(/^\/([^\s/]*)$/),P=T.match(/(?:^|\s)@([^\s@]*)$/),F=N?.[1]?.toLowerCase(),I=P?.[1]?.toLowerCase(),L=F===void 0?I===void 0?void 0:`mention`:`slash`,ee=Md(T,j),te=Nd(T,M),R=(0,X.useMemo)(()=>{let e=new Set(ee.map(e=>e.name));return k.filter(t=>e.has(pf(t)))},[k,ee]),z=(0,X.useMemo)(()=>{let e=new Set(te.map(e=>e.id).filter(e=>!!e));return A.filter(t=>e.has(t.id))},[te,A]),B=L===`slash`?R:z,[V,H]=(0,X.useState)(0);(0,X.useEffect)(()=>{H(0)},[L,F,I,B.length]);let U=(0,X.useCallback)((e,t=!1)=>{if(s?.(e)===!0){E(``);return}a({role:`user`,content:e,altKey:t}),E(``)},[s,a,E]),W=(0,X.useCallback)(e=>{if(o?.(e)===!0){E(``);return}E(e.value??e.label)},[o,E]),ne=(0,X.useCallback)(e=>{if(!e)return T;let t=e[0].length-e[0].trimStart().length,n=T.length-e[0].length+t;return T.slice(0,n)},[T]),G=(0,X.useCallback)(e=>{m?.(e),E(ne(P))},[m,ne,E,P]),re=(0,X.useCallback)(e=>{let t=!D&&!_&&L!==void 0;if(e.key===`Backspace`&&T.length===0&&f.length>0){let t=f[f.length-1];if(t){e.preventDefault(),h?.(t.relativePath);return}}if(t&&e.key===`Escape`){e.preventDefault(),E(ne(L===`slash`?N:P));return}if(t&&B.length>0){if(e.key===`ArrowDown`){e.preventDefault(),H(e=>(e+1)%B.length);return}if(e.key===`ArrowUp`){e.preventDefault(),H(e=>(e-1+B.length)%B.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=B[V];t&&(L===`slash`?W(t):G(t));return}}if(e.key===`Enter`&&e.altKey&&!e.shiftKey){e.preventDefault();let t=T.trim();t&&!_&&U(t,!0)}},[V,_,D,h,ne,W,G,U,E,N,B,L,T,P,f]),ie=v&&v.id!==C,ae=y?.files??[],oe=y?.images??[],se=!!(L&&!D&&!_),ce=(0,X.useMemo)(()=>{if(L!==`slash`)return[];let e=new Map;for(let t of R){let n=t.category??`builtin`,r=e.get(n)??[];r.push(t),e.set(n,r)}let t={builtin:`Built-in`,extension:`Extensions`,prompt:`Prompts`,skill:`Skills`};return[...e.entries()].map(([e,n])=>({id:e,label:t[e]??e,items:n.map(e=>({...e,description:[e.description,mf(e)].filter(Boolean).join(` · `)}))}))},[R,L]),le=(0,X.useMemo)(()=>e.map(e=>({id:e.id,name:e.name,provider:e.provider,providerLabel:Mn(e.provider),modelId:e.modelId,icon:(0,Z.jsx)(On,{provider:e.provider,className:`size-4`}),disabled:e.available===!1,reasoning:e.reasoning,keywords:[e.provider,e.modelId,e.id],efforts:Cr(e).map(e=>({id:e,name:Ir(e)}))})),[e]);return{activeTriggerIndex:V,combinedPickerOpen:c===!0||u===!0,commandGroups:ce,files:ae,handleCombinedPickerOpenChange:(0,X.useCallback)(e=>{l?.(e),d?.(e)},[d,l]),handlePromptKeyDown:re,handleSelectorModelChange:(0,X.useCallback)(t=>{let a=e.find(e=>e.id===t);r(t),a&&i?.(Mr(n,Cr(a)))},[e,r,i,n]),images:oe,isStreaming:D,navigation:O,selectorModels:le,selectCommand:W,selectWorkspaceReference:G,removeTriggerToken:ne,send:U,setActiveTriggerIndex:H,setDismissedQuestionId:w,setValue:E,showQuestion:ie,triggerItems:B,triggerKind:L,triggerOpen:se,slashMatch:N,slashQuery:F,workspaceMentionMatch:P,workspaceQuery:I,filteredCommands:R,filteredWorkspaceItems:z,value:T}}var gf=[],_f=[...lf];function vf(e){return(0,Z.jsx)(yf,{...e})}function yf({modelKey:e,models:t,status:n,infoDescription:r,chatMode:i=`agent`,onChatModeChange:a,onModelChange:o,thinkingLevel:s,onThinkingLevelChange:c,onStop:l,onSend:u,onSlashCommandSelect:d,onLocalSlashSubmit:f,modelPickerOpen:p,onModelPickerOpenChange:m,effortPickerOpen:h,onEffortPickerOpenChange:g,workspaceReferences:_=gf,workspaceSuggestions:v,onWorkspaceReferenceSelect:y,onRemoveWorkspaceReference:b,controlled:x,disabled:S,autoFocus:C,placeholder:w,attachments:T,questionBar:E,slashCommands:D,className:O}){let{activeTriggerIndex:k,combinedPickerOpen:A,commandGroups:j,files:M,handleCombinedPickerOpenChange:N,handlePromptKeyDown:P,handleSelectorModelChange:F,images:I,isStreaming:L,navigation:ee,filteredWorkspaceItems:te,removeTriggerToken:R,selectCommand:B,selectWorkspaceReference:V,selectorModels:H,send:W,setActiveTriggerIndex:ne,setDismissedQuestionId:G,setValue:re,showQuestion:ie,slashMatch:ae,slashQuery:oe,triggerItems:se,triggerKind:ce,triggerOpen:le,value:ue,workspaceMentionMatch:de,workspaceQuery:fe}=hf({models:t,status:n,thinkingLevel:s,onModelChange:o,onThinkingLevelChange:c,onSend:u,onSlashCommandSelect:d,onLocalSlashSubmit:f,modelPickerOpen:p,onModelPickerOpenChange:m,effortPickerOpen:h,onEffortPickerOpenChange:g,workspaceReferences:_,workspaceSuggestions:v,onWorkspaceReferenceSelect:y,onRemoveWorkspaceReference:b,controlled:x,disabled:S,questionBar:E,attachments:T,slashCommands:D}),pe=(0,X.useCallback)(e=>a?.(e),[a]),me=(0,X.useCallback)(e=>c?.(e),[c]);return(0,Z.jsx)(`div`,{className:U(`shrink-0 px-3 pb-3`,O),children:(0,Z.jsxs)(`div`,{className:`relative mx-auto w-full max-w-an`,children:[(0,Z.jsx)(Ud,{label:r??void 0,isActive:L}),ie?(0,Z.jsx)(cf,{questionBar:E,navigation:ee,roundedTop:!0,onDismiss:G}):null,(0,Z.jsx)(Rd,{open:le,kind:ce??`slash`,query:ce===`slash`?oe:fe,items:ce===`mention`?te:void 0,groups:ce===`slash`?j:void 0,activeIndex:k,onActiveIndexChange:ne,onSelect:e=>{ce===`slash`?B(e):V(e)},onClose:()=>re(R(ce===`slash`?ae:de)),title:ce===`slash`?`Commands`:`Workspace references`,listId:`fleet-composer-trigger-list`}),I.length>0||M.length>0?(0,Z.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2 rounded-xl border bg-muted/40 p-2`,children:[I.map(e=>(0,Z.jsxs)(`div`,{className:`group relative`,children:[(0,Z.jsx)(`img`,{src:e.url,alt:e.filename,width:64,height:64,loading:`lazy`,className:`size-16 rounded-lg border object-cover`}),(0,Z.jsx)(z,{type:`button`,variant:`outline`,size:`icon-xs`,"aria-label":`Remove ${e.filename}`,onClick:()=>T?.onRemoveImage?.(e.id),className:`absolute -right-1 -top-1 size-5 rounded-full bg-background opacity-0 shadow-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,children:(0,Z.jsx)(Xr,{"data-icon":`inline-start`,className:`size-3`})})]},e.id)),M.map(e=>(0,Z.jsx)(ir,{id:e.id,filename:e.filename,size:e.size,onRemove:T?.onRemoveFile?()=>T.onRemoveFile?.(e.id):void 0},e.id))]}):null,_.length>0?(0,Z.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5 rounded-xl border bg-muted/40 p-2`,children:_.map(e=>(0,Z.jsxs)(`div`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-lg border bg-background px-2 py-1 text-xs text-foreground/75`,children:[(0,Z.jsx)(_r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`max-w-[min(28rem,70vw)] truncate`,children:[`@`,e.relativePath]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Remove workspace reference ${e.relativePath}`,onClick:()=>b?.(e.relativePath),className:`grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Z.jsx)(Xr,{className:`size-3`})})]},e.relativePath))}):null,(0,Z.jsx)(We,{id:`fleet-composer-prompt`,name:`prompt`,value:ue,onValueChange:re,onSubmit:e=>W(e),loading:L,submitWhileLoading:!0,onStop:l,disabled:S,autoFocus:C,placeholder:w??`Send a message…`,onPaste:T?.onPaste,"aria-controls":le?`fleet-composer-trigger-list`:void 0,"aria-expanded":le,"aria-haspopup":`listbox`,"aria-activedescendant":le&&se[k]?`fleet-composer-trigger-list-${se[k].id.replace(/[^a-zA-Z0-9_-]/g,`-`)}`:void 0,actions:T?.onAttach?[{value:`attach`,label:`Attach file`,description:`Add a file or image to this turn`,icon:(0,Z.jsx)(qa,{})}]:[],onAction:e=>{e===`attach`&&T?.onAttach?.()},onKeyDown:P,leadingAction:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wd,{modes:_f,value:i,onChange:pe}),(0,Z.jsx)(Vd,{models:H,value:e,effort:s,onModelChange:F,onEffortChange:me,open:A,onOpenChange:N,placeholder:`Model`,className:`rounded-full`})]})})]})})}var bf=[{id:`top-left`,delay:0},{id:`top-center`,delay:.14},{id:`top-right`,delay:.28},{id:`middle-left`,delay:.42},{id:`middle-center`,delay:.56},{id:`middle-right`,delay:.7},{id:`bottom-left`,delay:.84},{id:`bottom-center`,delay:.98},{id:`bottom-right`,delay:1.12}];function xf(e){let t=Math.max(0,e),n=Math.floor(t/60),r=(t%60).toFixed(1);return n>0?`${n}m ${r}s`:`${r}s`}function Sf({label:e=`Churning`,elapsedSeconds:t,initialSeconds:n=0,running:r=!0,className:i}){let a=Ke()??!1,[o,s]=(0,X.useState)(n);(0,X.useEffect)(()=>{if(t!==void 0||!r)return;let e=performance.now()-n*1e3,i=window.setInterval(()=>{s((performance.now()-e)/1e3)},100);return()=>window.clearInterval(i)},[t,n,r]);let c=t??o;return(0,Z.jsxs)(`span`,{role:`status`,"aria-label":`${e}, in progress`,className:U(`inline-flex items-center gap-3 font-mono text-sm text-muted-foreground`,i),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 grid-cols-3 gap-[2px]`,children:bf.map(({id:e,delay:t})=>(0,Z.jsx)(K.span,{className:`rounded-[1px] bg-current`,animate:a?{opacity:[.35,.8,.35]}:{opacity:[.28,1,.28],scale:[.72,1,.72]},transition:{duration:1.55,ease:je,repeat:1/0,delay:t}},e))}),(0,Z.jsx)(`span`,{className:`font-sans font-medium`,children:e}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`tabular-nums text-muted-foreground/70`,children:xf(c)})]})}function Cf({label:e,className:t}){let n=Ke();if(!e?.trim())return null;let{kind:r,title:i,detail:a}=wf(e),o=Tf(r),s=r===`queue`||r===`retry`||r===`compaction`;return(0,Z.jsxs)(K.div,{initial:!n&&{opacity:0,y:-4},animate:{opacity:1,y:0},exit:n?void 0:{opacity:0,y:-4},transition:{duration:n?0:.16},role:r===`recovery`?`status`:void 0,"aria-live":r===`recovery`?`polite`:`off`,className:U(`flex items-start gap-2 rounded-lg border border-border/60 bg-muted/45 px-3 py-2 text-xs text-muted-foreground`,t),children:[s?(0,Z.jsx)(Sf,{label:i,running:!0,className:`min-w-0 text-xs`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{className:U(`mt-0.5 size-3.5 shrink-0`,r===`recovery`&&`text-amber-600 dark:text-amber-400`)}),(0,Z.jsx)(`strong`,{className:`font-medium text-foreground/90`,children:i})]}),a?(0,Z.jsx)(`span`,{className:`min-w-0 leading-relaxed`,children:a}):null]})}function wf(e){let t=e.trim(),n=t.toLowerCase();return n.includes(`queued`)||n.includes(`steered`)?{kind:`queue`,title:`Queued work`,detail:t}:n.includes(`retry`)?{kind:`retry`,title:`Retrying safely`,detail:t}:n.includes(`compact`)?{kind:`compaction`,title:`Managing context`,detail:t}:n.includes(`reset`)||n.includes(`recover`)||n.includes(`sign in`)?{kind:`recovery`,title:`Run needs attention`,detail:t}:{kind:`notice`,title:`Run update`,detail:t}}function Tf(e){switch(e){case`queue`:return Xa;case`retry`:return Gr;case`compaction`:return Br;case`recovery`:return hr;default:return Wa}}var Ef=(0,X.lazy)(()=>ei(async()=>{let{FleetPiToolRenderer:e}=await import(`./fleet-pi-tool-renderer-BRgNnmaJ.js`).then(e=>e.n);return{FleetPiToolRenderer:e}},__vite__mapDeps([22,1,2,3,4,5,6,23,8,24,7,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,17,45,46,16,47,48,49,50,51,14,12,15,21,52,53])).then(({FleetPiToolRenderer:e})=>({default:e})));function Df(e){return(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`h-7 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading tool`}),children:(0,Z.jsx)(Ef,{...e})})}var Of=(0,X.lazy)(()=>ei(async()=>{let{AgentActivity:e}=await import(`./agent-activity-svETLf_5.js`);return{AgentActivity:e}},__vite__mapDeps([54,1,2,3,4,5,6,23,8,7,25,35,44,55,56,17,45,30,31,33,37])).then(({AgentActivity:e})=>({default:e})));function kf(e){return(0,Z.jsx)(`div`,{className:`mt-2 min-h-8`,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`h-8 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading activity`}),children:(0,Z.jsx)(Of,{...e})})})}var Af=(0,X.lazy)(()=>ei(async()=>{let{FleetReasoningPanel:e}=await import(`./fleet-reasoning-panel-CjA2dwUJ.js`);return{FleetReasoningPanel:e}},__vite__mapDeps([57,1,2,3,4,25,8,50,51,14,12,15,21,53])).then(({FleetReasoningPanel:e})=>({default:e})));function jf(e){return(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`mb-2 h-6 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading reasoning`}),children:(0,Z.jsx)(Af,{...e})})}var Mf=(0,X.lazy)(()=>ei(async()=>{let{FleetToolTimeline:e}=await import(`./fleet-tool-timeline-C8heL7ae.js`).then(e=>e.n);return{FleetToolTimeline:e}},__vite__mapDeps([58,1,2,3,4,8,25,46,31])).then(({FleetToolTimeline:e})=>({default:e})));function Nf(e){return(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`h-6 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading timeline`}),children:(0,Z.jsx)(Mf,{...e})})}var Pf=(0,X.lazy)(()=>ei(async()=>{let{FleetSubagentList:e}=await import(`./fleet-subagent-list-iKUtLJKZ.js`).then(e=>e.n);return{FleetSubagentList:e}},__vite__mapDeps([59,1,2,3,4,25,8,26,60,40,27])).then(({FleetSubagentList:e})=>({default:e})));function Ff(e){return(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`h-6 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading subagents`}),children:(0,Z.jsx)(Pf,{...e})})}var If=(0,X.lazy)(()=>ei(async()=>{let{PromptSuggestions:e}=await import(`./prompt-suggestions-BlGXmWS7.js`);return{PromptSuggestions:e}},__vite__mapDeps([61,3,1,4,2,50])).then(({PromptSuggestions:e})=>({default:e})));function Lf(e){return(0,Z.jsx)(`div`,{className:`min-h-8`,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`h-8 animate-pulse rounded-full bg-muted/40`,"aria-label":`Loading suggestions`}),children:(0,Z.jsx)(If,{...e})})})}var Rf=(0,X.lazy)(()=>ei(async()=>{let{FleetMessageQueue:e}=await import(`./fleet-message-queue-fbYYwMj0.js`);return{FleetMessageQueue:e}},__vite__mapDeps([62,1,2,3,4,63,8,16,64,65,12,13,14,26,66])).then(({FleetMessageQueue:e})=>({default:e})));function zf(e){return(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Rf,{...e})})}function Bf(e){return(e.parts??[]).flatMap(e=>typeof e==`object`&&e&&`type`in e&&e.type===`text`&&`text`in e&&typeof e.text==`string`?[e.text]:[]).join(`
5
+
6
+ `)}function Vf(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Hf(e,...t){let n=Vf(e);for(let e of t){let t=n?.[e];if(typeof t==`string`&&t.trim())return t}}function Uf(e){for(let t of[...e].reverse())for(let e of[...t.parts??[]].reverse()){let t=Vf(e);if(t?.type!==`tool-FleetReasoning`)continue;let n=Vf(t.input);if(!(typeof n?.runId!=`string`||typeof n.phase!=`string`||!Array.isArray(n.steps)||typeof n.visibleSteps!=`number`||typeof n.streaming!=`boolean`||typeof n.startedAt!=`number`||typeof n.restingLabel!=`string`))return n}}function Wf(e){return/^(.*)-a\d+$/.exec(e)?.[1]}function Gf(e,t){if(!e||t.length===0)return[];let n=new Set(t.map(e=>e.id)),r=new Set(t.flatMap(e=>(e.parts??[]).flatMap(e=>{let t=Vf(e);return typeof t?.toolCallId==`string`&&t.toolCallId?[t.toolCallId]:[]}))),i=new Set(t.flatMap(e=>{let t=Wf(e.id);return t?[e.id,t]:[e.id]}));return e.flatMap(e=>e.artifacts).filter(e=>e.sourceMessageId?n.has(e.sourceMessageId):e.sourceToolCallId&&r.has(e.sourceToolCallId)||i.has(e.runId))}function Kf(e,t,n=[],r){let i=new Map,a=n.flatMap(e=>e.artifacts),o=e=>{let t=a.findIndex(t=>t.sourceToolCallId===e),n=t>=0?a[t]:void 0,i=n?.kind===`ipython`?`repl`:n?`artifacts`:void 0;if(!(!n||!i||!r))return{label:i===`repl`?`Open in REPL`:`Open in Artifacts`,ariaLabel:`Open ${n.title||`tool result`} artifact ${t+1}`,onClick:()=>r(n.id,i)}};for(let t of e)for(let[e,n]of(t.parts??[]).entries()){let r=Vf(n),a=r?.type;if(typeof a!=`string`||!a.startsWith(`tool-`))continue;let s=r??{},c=a.slice(5),l=c.toLowerCase();if(l===`fleetreasoning`||l===`thinking`||l===`taskoutput`)continue;let u=String(s.toolCallId??s.id??`${t.id}-${l}-${e}`),d=Vf(s.input)??Vf(s.args);if(l===`websearch`||l===`grep`||l===`glob`){i.set(u,{id:u,type:`search`,query:Hf(d,`query`,`pattern`,`path`)??c});continue}let f=l.includes(`edit`)||l.includes(`write`)?`edit`:l.includes(`read`)?`read`:`run`;i.set(u,{id:u,type:`tool`,action:f,target:Hf(d,`path`,`filePath`,`command`,`cmd`,`code`)??c,openAction:o(u)})}let s=[];for(let e of t?.userBash??[])e.status===`running`&&s.push({id:e.id,type:`trace`,kind:`run`,label:`Bash`,detail:e.command||`User command`,action:o(e.runId)});for(let e of t?.rlmChildren??[])(e.status===`queued`||e.status===`running`)&&s.push({id:`rlm-${e.id}`,type:`trace`,kind:`run`,label:`RLM · ${e.label}`,detail:e.answerPreview||e.status,action:o(e.id)});return t?.goal?.active&&t.goal.status===`active`&&t.goal.objective&&s.push({id:`goal-${t.goal.goalId??`current`}`,type:`step`,label:t.goal.objective,status:t.goal.status===`active`?`active`:`complete`,meta:t.goal.status}),[...s,...Array.from(i.values())]}function qf({messages:e,isLast:t,isStreaming:n,suppressQuestionTool:r,toolRenderers:i,onOpenUIAction:a,activityLabel:o,presentation:s,artifactRuns:c,onOpenArtifact:l,onOpenUIArtifactReady:u}){let d=t&&n,f=(0,X.useMemo)(()=>e.flatMap((n,o)=>er(sr((n.parts??[]).filter(e=>e.type!==`tool-FleetReasoning`&&e.type!==`tool-Thinking`)),{messageId:n.id,isLast:t&&o===e.length-1,isStreaming:d,suppressQuestionTool:r,suppressTextWhenPlanWrite:!0,ToolRendererComponent:Df,TextRendererComponent:or,toolRenderers:i,onOpenUIAction:a,onOpenUIArtifactReady:u,onOpenArtifact:l})),[t,d,e,l,a,u,r,i]),p=e.flatMap(e=>{let t=Bf(e);return t?[t]:[]}).join(`
7
+
8
+ `),m=(0,X.useMemo)(()=>Kf(e,s,c,l),[c,e,l,s]),h=(0,X.useMemo)(()=>Uf(e),[e]),g=(0,X.useMemo)(()=>t?Gf(c,e):[],[c,t,e]),[_,v]=(0,X.useState)(d),[y,b]=(0,X.useState)(d);return y!==d&&(b(d),v(d)),(0,Z.jsx)(ur,{from:`assistant`,animateIn:!d,children:(0,Z.jsx)(tr,{children:(0,Z.jsx)(fr,{variant:`ghost`,children:(0,Z.jsxs)(nr,{children:[h?(0,Z.jsx)(jf,{presentation:h,className:`mb-2`}):null,t&&Xf(o)?(0,Z.jsx)(Cf,{label:o,className:`mb-2`}):null,(0,Z.jsx)(Nf,{messages:e,artifacts:g,streaming:d}),(0,Z.jsx)(Td,{status:d?`streaming`:`complete`,copyText:p||void 0,announce:!1,contentClassName:`flex flex-col gap-3`,children:f}),m.length>0?(0,Z.jsx)(kf,{items:m,status:d?`working`:`complete`,open:_,onOpenChange:v,activeLabel:Ed(m),summary:Dd(m),collapseOnComplete:!0,maxHeight:208,className:`mt-2 max-w-none`}):null,t&&s?(0,Z.jsx)(Ff,{tree:s.rlmTree,children:s.rlmChildren}):null]})})})})}function Jf(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var Yf=(0,X.memo)(function({turn:e,state:t,rendering:n,activity:r}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 400px`},children:[e.user?(0,Z.jsx)(ur,{from:`user`,animateIn:!t.isStreaming,children:(0,Z.jsx)(tr,{children:(0,Z.jsx)(lr,{message:e.user})})}):null,e.assistants.length>0?(0,Z.jsx)(qf,{messages:e.assistants,isLast:t.isLast,isStreaming:t.isStreaming,suppressQuestionTool:t.suppressQuestionTool,toolRenderers:n.toolRenderers,onOpenUIAction:n.onOpenUIAction,onOpenUIArtifactReady:n.onOpenUIArtifactReady,onOpenArtifact:n.onOpenArtifact,activityLabel:r.label,presentation:r.presentation,artifactRuns:r.artifactRuns}):null]})},(e,t)=>e.turn.user===t.turn.user&&Jf(e.turn.assistants,t.turn.assistants)&&e.state.isLast===t.state.isLast&&e.state.isStreaming===t.state.isStreaming&&e.state.suppressQuestionTool===t.state.suppressQuestionTool&&e.rendering.toolRenderers===t.rendering.toolRenderers&&e.rendering.onOpenUIAction===t.rendering.onOpenUIAction&&e.rendering.onOpenUIArtifactReady===t.rendering.onOpenUIArtifactReady&&e.rendering.onOpenArtifact===t.rendering.onOpenArtifact&&e.activity.label===t.activity.label&&e.activity.presentation===t.activity.presentation&&e.activity.artifactRuns===t.activity.artifactRuns);function Xf(e){return e?/queued|steered|retry|compact|reset|recover|sign in/i.test(e):!1}function Zf(e){return Array.isArray(e)?e:e?.items??[]}function Qf({inputBar:e,status:t,suggestions:n,onSend:r,onStop:i,isEmpty:a,draftSetterRef:o}){let[s,c]=(0,X.useState)(``);return(0,X.useEffect)(()=>{o.current=c},[o]),(0,Z.jsx)(vf,{...e,className:U(e.className,a&&`px-0 pb-0`),placeholder:a?`Ask Prime to build, investigate, or change something…`:e.placeholder,controlled:{value:s,onChange:c},status:t,suggestions:n,onSend:r,onStop:i})}var $f=(0,X.memo)(Qf);function ep(e,t){return e.user?.id??e.assistants[0]?.id??`assistant-turn-${t}`}function tp({toolRenderers:e=Un,suggestions:t,status:n,onStop:r,onSend:i,inputBar:a,className:o,messages:s,error:c,suppressQuestionTool:l=!1,onOpenUIAction:u,activityLabel:d,presentation:f,artifactRuns:p,onOpenArtifact:m,onOpenUIArtifactReady:h,queue:g,onDeleteQueuedMessage:_,onEditQueuedMessage:v}){let y=(0,X.useRef)(null),b=(0,X.useRef)(null),x=(0,X.useCallback)(e=>y.current?.(e),[]),S=(0,X.useMemo)(()=>rr(s),[s]),C=Zf(t),w=(0,X.useMemo)(()=>C.flatMap(e=>e.disabled?[]:[e.value??e.label]),[C]),T=w.join(`\0`),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(T);O!==T&&(k(T),D(null));let A=n===`streaming`||n===`submitted`,j=(0,X.useMemo)(()=>({toolRenderers:e,onOpenUIAction:u,onOpenUIArtifactReady:h,onOpenArtifact:m}),[m,u,h,e]),M=(0,X.useMemo)(()=>({isLast:!0,isStreaming:A,suppressQuestionTool:l}),[A,l]),N=(0,X.useMemo)(()=>({isLast:!1,isStreaming:!1,suppressQuestionTool:l}),[l]),P=(0,X.useMemo)(()=>({label:d,presentation:f,artifactRuns:p}),[d,p,f]),F=(0,X.useMemo)(()=>({label:void 0,presentation:void 0,artifactRuns:void 0}),[]),I=(0,X.useCallback)((e,t)=>{let n=t===S.length-1;return(0,Z.jsx)(Yf,{turn:e,state:n?M:N,rendering:j,activity:n?P:F})},[P,F,j,M,N,S.length]),L=S.length===0&&!c,ee=c?kd(c):null,te=(0,Z.jsx)($f,{inputBar:a,status:n,suggestions:t,onSend:i,onStop:r,isEmpty:L,draftSetterRef:y});return(0,Z.jsxs)(`div`,{className:U(`fleet-pi-agent-chat flex h-full min-h-0 flex-col bg-background`,o),children:[(0,Z.jsxs)(ar,{className:`flex-1`,busy:A,followOutput:!0,viewportRef:b,smooth:!A,contentClassName:U(`mx-auto flex w-full max-w-an flex-col gap-5 px-4`,L?`min-h-full items-center justify-center py-8`:`py-6`),children:[L?(0,Z.jsx)(jd,{disabled:A,onSelect:e=>x(e.value??e.label),composer:te}):null,(0,Z.jsx)(dr,{estimateSize:400,getItemKey:ep,itemGap:20,items:S,renderItem:I,viewportRef:b}),ee?(0,Z.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Z.jsx)(hr,{className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:ee.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs opacity-90`,children:ee.message})]})]}):null,S.length>0&&w.length>0&&!A&&!c?(0,Z.jsx)(Lf,{suggestions:w,selectedSuggestion:E,cycle:S.length,onSuggestion:e=>{D(e),x(e)},className:`px-0`}):null]}),L?null:te,(0,Z.jsx)(zf,{queue:g??{steering:[],followUp:[]},onDelete:_,onEdit:v})]})}function np({messages:e,status:t,error:n,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,queue:s,onDeleteQueuedMessage:c,onEditQueuedMessage:l,onOpenArtifact:u,onOpenUIArtifactReady:d,inputSuggestionItems:f,suppressQuestionTool:p,inputBar:m,onSend:h,onOpenUIAction:g,onStop:_,onQuestionAnswer:v}){let y=(0,X.useCallback)(e=>{h(e.content,e.altKey)},[h]),b=(0,X.useCallback)(e=>{g(e)},[g]),x=(0,X.useCallback)(({toolCallId:e,answer:t})=>{v({toolCallId:e,answer:t})},[v]),S=(0,X.useMemo)(()=>({submitLabel:`Continue`,allowSkip:!0,onAnswer:x}),[x]);return(0,Z.jsx)(`div`,{className:`contents`,"data-fleet-chat-focus":!0,children:(0,Z.jsx)(Ui,{children:(0,Z.jsx)(tp,{messages:e,status:t,onSend:y,onOpenUIAction:b,onStop:_,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,queue:s,onDeleteQueuedMessage:c,onEditQueuedMessage:l,onOpenArtifact:u,onOpenUIArtifactReady:d,questionTool:S,suppressQuestionTool:p,error:n??void 0,emptyStatePosition:`default`,suggestions:f,inputBar:m})})})}var rp=(0,X.lazy)(()=>ei(async()=>{let{ChatCommandPalette:e}=await import(`./chat-command-palette-LILDO_vG.js`);return{ChatCommandPalette:e}},__vite__mapDeps([67,1,2,3,8,68,69,70,71,30,32,72,73,4,74,75,76,10,11,12,13,14,15,16,7,17,18,19,20,21])).then(({ChatCommandPalette:e})=>({default:e}))),ip=(0,X.lazy)(()=>ei(async()=>{let{SettingsDialog:e}=await import(`./settings-dialog-BSBasR3o.js`);return{SettingsDialog:e}},__vite__mapDeps([77,1,2,3,13,12,4,14,65,8,26,66,16,11,15,78,7,25,21,20,79,69,36,80,45,38,43,81,74,56,63,75,82,29,17,83,84,64,72,73,85,19])).then(({SettingsDialog:e})=>({default:e}))),ap=(0,X.lazy)(()=>ei(async()=>{let{ForkPickerDialog:e}=await import(`./fork-picker-dialog-B7NNpVmW.js`);return{ForkPickerDialog:e}},__vite__mapDeps([86,3,1,11,2,12,13,4,14,15,16,8])).then(({ForkPickerDialog:e})=>({default:e})));function op({chrome:e,conversation:t,dialogs:n,panels:r,session:i}){return(0,Z.jsx)(Z.Fragment,{children:n.commandPaletteOpen?(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(rp,{open:!0,onOpenChange:n.setCommandPaletteOpen,onNewSession:()=>xd(()=>i.startNewSession()),onStop:t.stop,onResumeSession:e=>void i.resumeSession({sessionId:e.sessionId}),onSetRightPanel:r.setRightPanel,onThemeChange:e.handleThemePreferenceChange,sessions:i.sessions,isStreaming:t.status===`streaming`,themePreference:e.themePreference})}):null})}function sp({dialogs:e}){let{forkFromEntry:t,forkPickerEntries:n,setForkPickerEntries:r,setSettingsDialogOpen:i,setSettingsInitialTab:a,settingsDialogOpen:o,settingsInitialTab:s}=e,[c,l]=(0,X.useState)(o),[u,d]=(0,X.useState)(n!==null);(0,X.useEffect)(()=>{o&&l(!0)},[o]),(0,X.useEffect)(()=>{n!==null&&d(!0)},[n]);let f=(0,X.useCallback)(e=>{i(e),e||a(void 0)},[i,a]);return(0,Z.jsxs)(Z.Fragment,{children:[c?(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(ip,{open:o,onOpenChange:f,initialTab:s})}):null,u?(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(ap,{entries:n,onOpenChange:e=>{e||r(null)},onPick:t})}):null]})}var cp=`fleet-prime:v1:panel-keybindings`,lp={toggleResources:{code:`Digit1`,ctrlOrMeta:!0,shift:!0},toggleWorkspace:{code:`Digit2`,ctrlOrMeta:!0,shift:!0},toggleArtifacts:{code:`Digit3`,ctrlOrMeta:!0,shift:!0},toggleRepl:{code:`Digit4`,ctrlOrMeta:!0,shift:!0},toggleSubagents:{code:`Digit5`,ctrlOrMeta:!0,shift:!0},toggleCommandPalette:{code:`KeyK`,ctrlOrMeta:!0},closePanel:{code:`Escape`},focusPanel:{code:`KeyP`,ctrlOrMeta:!0,shift:!0},focusChat:{code:`KeyC`,ctrlOrMeta:!0,shift:!0}};function up(){try{let e=$r(cp);if(!e)return lp;let t=JSON.parse(e);return{...lp,...t}}catch{return lp}}function dp(e,t){return e.code===t.code&&(e.ctrlKey||e.metaKey)===!!t.ctrlOrMeta&&e.shiftKey===!!t.shift&&e.altKey===!!t.alt}function fp(){document.querySelector(`[data-fleet-chat-focus] textarea, [data-fleet-chat-focus] [contenteditable='true'], [data-fleet-chat-focus] input`)?.focus({preventScroll:!0})}function pp({onCommandPaletteToggle:e,onClosePanel:t,rightPanel:n,setRightPanel:r}){(0,X.useEffect)(()=>{let i=up(),a=a=>{let o=e=>dp(a,i[e]),s=!0;o(`toggleResources`)?r(n===`resources`?null:`resources`):o(`toggleWorkspace`)?r(n===`workspace`?null:`workspace`):o(`toggleArtifacts`)?r(n===`artifacts`?null:`artifacts`):o(`toggleRepl`)?r(n===`repl`?null:`repl`):o(`toggleSubagents`)?r(n===`subagents`?null:`subagents`):e&&o(`toggleCommandPalette`)?e():n&&o(`closePanel`)?t?t():(r(null),fp()):n&&o(`focusPanel`)?document.querySelector(`[data-fleet-panel-focus]`)?.focus({preventScroll:!0}):o(`focusChat`)?fp():s=!1,s&&(a.preventDefault(),a.stopPropagation())};return document.addEventListener(`keydown`,a),()=>document.removeEventListener(`keydown`,a)},[e,t,n,r])}function mp(){return null}function hp(){return null}async function gp(){}var _p=Y({project:Ni}),vp={async abortSession(e){await hd(`/api/chat/abort`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async answerQuestion(e){return Q(`/api/chat/question`,wi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async mutateQueuedMessage(e){let t=Li.parse(e);return Q(`/api/chat/session`,Bi,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async deleteQueuedMessage(e){return this.mutateQueuedMessage({...e,mutation:e.mutation??{type:`delete`}})},async browseWorkspace(e,t){let n=new URLSearchParams;t&&n.set(`projectId`,t),e&&e.trim().length>0&&n.set(`path`,e);let r=n.toString();return Q(`/api/workspace/browse${r?`?${r}`:``}`,mu)},async createSession(e,t){return Q(`/api/chat/new`,Pi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({openUI:!0,...e?{projectId:e}:{}}),signal:t})},async listProjects(){return Q(`/api/projects`,pi)},async createProject(e){let t=fi.parse(e);return(await Q(`/api/projects`,_p,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).project},async renameProject(e,t){let n=yi.parse({name:t});return(await Q(`/api/projects?projectId=${encodeURIComponent(e)}`,_p,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})).project},async unregisterProject(e){return(await Q(`/api/projects?projectId=${encodeURIComponent(e)}`,_p,{method:`DELETE`})).project},async browseProjectDirectories(e){let t=new URLSearchParams;e?.path&&t.set(`path`,e.path),e?.token&&t.set(`token`,e.token);let n=t.toString();return Q(`/api/projects/browse${n?`?${n}`:``}`,Wi)},async forkSessionIntoProject(e,t){let n=xi.parse({sessionId:e,targetProjectId:t});return Q(`/api/projects/fork`,mi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})},async getModels(e){let t=new URLSearchParams;e?.scope===`all`&&t.set(`scope`,`all`),e?.projectId&&t.set(`projectId`,e.projectId);let n=t.toString();return Q(`/api/chat/models${n?`?${n}`:``}`,au)},async discoverModels(e){return Q(`/api/chat/models/discover`,su,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(ou.parse(e))})},async getResources(e){return Q(`/api/chat/resources${e?`?projectId=${encodeURIComponent(e)}`:``}`,lu)},async getCommands(e){return Q(`/api/chat/commands${e?`?projectId=${encodeURIComponent(e)}`:``}`,Tu)},async getSettings(e){return Q(`/api/chat/settings${e?`?projectId=${encodeURIComponent(e)}`:``}`,ed)},async getWorkspaceTree(e){return Q(`/api/workspace/tree${e?`?projectId=${encodeURIComponent(e)}`:``}`,du)},async getWorkspaceFile(e,t,n){let r=new URLSearchParams({path:e});return t&&r.set(`projectId`,t),Q(`/api/workspace/file?${r}`,fu,n?{signal:n}:void 0)},async listSessions(e){return(await Q(`/api/chat/sessions${e?`?projectId=${encodeURIComponent(e)}`:``}`,Hi)).sessions},async renameSession(e,t){await hd(`/api/chat/sessions`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e,title:t})})},async deleteSession(e){await hd(`/api/chat/sessions`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})})},async uploadAttachments(e,t){let n=new FormData;n.set(`sessionId`,e);for(let e of t)n.append(`files`,e);let r=await fetch(id(`/api/chat/session`),{method:`POST`,body:n});if(!r.ok)throw new od(r.status,await r.text());return Y({attachments:q(Mi)}).parse(await r.json()).attachments},async loadSession(e){return Q(`/api/chat/session?${vd({...e,openUI:!0})}`,Pi)},async loadSubagentSession(e,t){return Q(`/api/chat/session?${new URLSearchParams({parentSessionId:e,childId:t})}`,Pi)},openSubagentEvents(e,t,n){let r=new URLSearchParams({parentSessionId:e,childId:t});return n?.streamGeneration&&r.set(`streamGeneration`,n.streamGeneration),n?.lastEventId&&n.lastEventId>0&&r.set(`lastEventId`,String(n.lastEventId)),id(`/api/chat/events?${r}`)},async upsertPlanPresentation(e){let t=ji.parse(e);return Q(`/api/chat/session`,Y({presentation:zi}),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.presentation)},async upsertOpenUIArtifact(e){let t=Vi.parse(e);return Q(`/api/chat/artifacts`,Ii,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async resumeSession(e){return Q(`/api/chat/resume`,Pi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,openUI:!0})})},async updateSettings(e,t){let n=$u.parse(e);return Q(`/api/chat/settings${t?`?projectId=${encodeURIComponent(t)}`:``}`,ed,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})},async streamMessage(e,t,n){let r=async i=>{let a=new Headers({"Content-Type":`application/json`}),o=await hp();o&&a.set(`Authorization`,`Bearer ${o}`);let s=await fetch(id(`/api/chat`),{method:`POST`,headers:a,body:JSON.stringify(e),signal:n});if(s.status===401&&i)return r(!1);if(!s.ok){let e=await s.text();throw new od(s.status,e)}await gd(s,t)};await r(!0)},async getMcpConnections(){return Q(`/api/chat/mcp`,Fu)},async upsertMcpConnection(e){let t=Ru.parse(e);return Q(`/api/chat/mcp`,Fu,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async removeMcpConnection(e){let t=zu.parse(e);return Q(`/api/chat/mcp`,Fu,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async mcpOAuth(e){let t=Vu.parse(e);return Q(`/api/chat/mcp/oauth`,Hu,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async getProviders(){return Q(`/api/chat/providers`,gu)},async oauthLoginProvider(e){let t=Su.parse(e);return Q(`/api/chat/providers/oauth`,Cu,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async updateProvider(e){let t=_u.parse(e);return Q(`/api/chat/providers`,vu,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async removeProvider(e){let t=yu.parse(e);return Q(`/api/chat/providers`,vu,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}},yp={models:e=>[`chat`,`models`,e??`default`],modelCatalog:e=>[`chat`,`models`,`catalog`,e??`default`],providers:[`chat`,`providers`],mcp:[`chat`,`mcp`],resources:e=>[`chat`,`resources`,e??`default`],commands:e=>[`chat`,`commands`,e??`default`],settings:e=>[`chat`,`settings`,e??`default`],workspace:e=>[`workspace`,`tree`,e??`default`],projects:[`projects`]},bp=yp;function xp(e){return Eo({queryKey:bp.models(e),queryFn:()=>vp.getModels({projectId:e}),enabled:!!e})}function Sp(){return Eo({queryKey:bp.projects,queryFn:()=>vp.listProjects(),staleTime:5e3})}function Cp(e){return Eo({queryKey:bp.modelCatalog(e?.projectId),queryFn:()=>vp.getModels({scope:`all`,projectId:e?.projectId}),enabled:!!e?.projectId&&e?.enabled!==!1})}function wp(){let e=c();return Do({mutationFn:e=>vp.discoverModels({providerId:e}),onSuccess:()=>{e.invalidateQueries({queryKey:[`chat`,`models`]})}})}function Tp(e){return Eo({queryKey:bp.resources(e),queryFn:()=>vp.getResources(e),enabled:!!e})}function Ep(e){return Eo({queryKey:bp.commands(e),queryFn:()=>vp.getCommands(e),enabled:!!e})}function Dp(e){return Eo({queryKey:bp.settings(e),queryFn:()=>vp.getSettings(e),enabled:!!e})}function Op(){let e=c();return Do({mutationFn:e=>vp.updateSettings(e.request,e.projectId),onSuccess:(t,n)=>{e.setQueryData(bp.settings(n.projectId),t),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`resources`]}),e.invalidateQueries({queryKey:[`chat`,`commands`]})}})}function kp(e,t){return Eo({queryKey:bp.workspace(e),queryFn:()=>vp.getWorkspaceTree(e),enabled:!!e&&t?.enabled!==!1})}function Ap(){return Eo({queryKey:bp.mcp,queryFn:()=>vp.getMcpConnections()})}function jp(){let e=c();return Do({mutationFn:e=>vp.upsertMcpConnection(e),onSuccess:t=>{e.setQueryData(bp.mcp,t),e.invalidateQueries({queryKey:[`chat`,`resources`]})}})}function Mp(){let e=c();return Do({mutationFn:e=>vp.removeMcpConnection(e),onSuccess:t=>{e.setQueryData(bp.mcp,t),e.invalidateQueries({queryKey:[`chat`,`resources`]})}})}function Np(){let e=c();return Do({mutationFn:e=>vp.mcpOAuth(e),onSuccess:t=>{t.status!==`success`||!t.connections||(e.setQueryData(bp.mcp,{connections:t.connections}),e.invalidateQueries({queryKey:[`chat`,`resources`]}))}})}function Pp(){return Eo({queryKey:bp.providers,queryFn:()=>vp.getProviders()})}function Fp(){let e=c();return Do({mutationFn:e=>vp.updateProvider(e),onSuccess:t=>{e.setQueryData(bp.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function Ip(){let e=c();return Do({mutationFn:e=>vp.oauthLoginProvider(e),onSuccess:t=>{t.status!==`success`||!t.providers||(e.setQueryData(bp.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]}))}})}function Lp(){let e=c();return Do({mutationFn:e=>vp.removeProvider(e),onSuccess:t=>{e.setQueryData(bp.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function Rp(e){if(e.type!==`tool-Question`||e.state===`output-available`||e.state===`output-error`)return!1;let t=e.output;return!t||!(t.answer!==void 0&&t.answer!==null||Array.isArray(t.answers)&&t.answers.length>0||typeof t.content==`string`&&t.content.length>0)}function zp(e){return e?.role!==`assistant`||!Array.isArray(e.parts)?!1:e.parts.some(e=>Rp(e))}var Bp=[{name:`settings`,description:`Open Settings`,source:`builtin`},{name:`model`,description:`Open the model picker`,argumentHint:`[provider/id]`,source:`builtin`},{name:`effort`,description:`Select reasoning/thinking level`,argumentHint:`[level]`,source:`builtin`},{name:`fast`,description:`Toggle OpenAI Fast mode`,source:`builtin`},{name:`scoped-models`,description:`Enable/disable models for cycling`,source:`builtin`},{name:`export`,description:`Export session (HTML default, or .html/.jsonl path)`,argumentHint:`[path]`,source:`builtin`},{name:`import`,description:`Import and resume a session from a JSONL file`,argumentHint:`<path.jsonl>`,source:`builtin`},{name:`share`,description:`Copy the transcript (Gist upload is TUI-only)`,source:`builtin`},{name:`copy`,description:`Copy last agent message to clipboard`,source:`builtin`},{name:`btw`,description:`Ask a side question without adding it to the session`,argumentHint:`<question>`,source:`builtin`},{name:`name`,description:`Set or show the session display name`,argumentHint:`[name]`,source:`builtin`},{name:`session`,description:`Show current session metadata`,source:`builtin`},{name:`system-prompt`,description:`Show the exact system prompt sent to the model`,source:`builtin`},{name:`logs`,description:`Show where daemon and client logs are saved`,source:`builtin`},{name:`traces`,description:`Preview, upload, or configure Fleet Prime traces`,argumentHint:`[status|on|off|preview|upload]`,source:`builtin`},{name:`context`,description:`Show token and context usage`,source:`builtin`},{name:`changelog`,description:`Show changelog entries`,source:`builtin`},{name:`hotkeys`,description:`Show keyboard shortcuts`,source:`builtin`},{name:`fork`,description:`Create a new fork from a previous user message`,argumentHint:`[message-entry-id]`,source:`builtin`},{name:`clone`,description:`Duplicate the current session at the current position`,source:`builtin`},{name:`tree`,description:`Show the session tree (switch branches)`,source:`builtin`},{name:`agents`,description:`List saved sessions (web stand-in for the TUI agent tray)`,source:`builtin`},{name:`login`,description:`Configure provider authentication`,source:`builtin`},{name:`logout`,description:`Remove provider authentication`,source:`builtin`},{name:`mcp`,description:`Open MCP connections in Settings`,argumentHint:`[list|login <name>|logout <name>]`,source:`builtin`},{name:`new`,description:`Start a new chat session`,source:`builtin`},{name:`compact`,description:`Compact the session context`,argumentHint:`[instructions]`,source:`builtin`},{name:`refine`,description:`Refine continual harness prompt notes, skills, and memory`,source:`builtin`},{name:`openui`,description:`Generate a durable OpenUI HTML artifact`,argumentHint:`<request>`,source:`builtin`},{name:`goal`,description:`Set or view a persistent goal`,argumentHint:`[objective]`,source:`builtin`},{name:`autonomous`,description:`Set or view autonomous mode`,argumentHint:`[status|on|off]`,source:`builtin`},{name:`rlm-max-depth`,description:`Set or view per-chat RLM max depth`,argumentHint:`[<int> [--global]]`,source:`builtin`},{name:`heartbeat`,description:`Set or view a persistent heartbeat`,argumentHint:`[status|pause|resume|stop]`,source:`builtin`},{name:`heartbeats`,description:`View user and agent heartbeats`,source:`builtin`},{name:`reload`,description:`Reload keybindings, extensions, skills, prompts, and themes`,source:`builtin`},{name:`update`,description:`Update Fleet Prime (TUI-only)`,source:`builtin`},{name:`fullscreen`,description:`Toggle fullscreen (TUI-only)`,source:`builtin`},{name:`quit`,description:`Quit (TUI-only; close this tab instead)`,source:`builtin`}],Vp={clear:`new`,usage:`context`,thinking:`effort`,rename:`name`,side:`btw`};function Hp(e){let t=Ri.safeParse(e.trim().toLowerCase());return t.success?t.data:void 0}function Up(e){return Vp[e]??e}function Wp(e){let t=e.trim().match(/^\/(\S+)(?:\s+(.*))?$/);if(!t)return null;let[,n=``,r=``]=t;return{command:n,args:r.trim()}}function Gp(e){let t=e.trim();if(!t)return;let n=t[0];if(n!==`"`&&n!==`'`)return t;let r=t.indexOf(n,1);return r<0?void 0:t.slice(1,r)}function Kp(e,t=``){let n=Up(e),r=t.trim();switch(n){case`model`:return{type:`open-model-picker`,modelKey:r?r.replace(/:[\w.-]+$/,``):void 0};case`effort`:{if(!r)return{type:`open-effort-picker`};let e=Hp(r);return e?{type:`set-thinking-level`,level:e}:{type:`open-effort-picker`,unknownLevel:r}}case`models`:case`scoped-models`:return{type:`open-model-picker`};case`settings`:return{type:`open-settings`,tab:`appearance`};case`config`:return{type:`open-settings`,tab:`chat`};case`new`:return{type:`new-session`};case`openui`:return{type:`openui-request`,request:r};case`login`:return{type:`open-providers`};case`logout`:return{type:`open-logout`};case`session`:return{type:`session-info`};case`name`:return{type:`session-rename`,name:r||void 0};case`context`:return{type:`session-context`};case`system-prompt`:return{type:`session-system-prompt`};case`logs`:return{type:`session-logs`};case`export`:return{type:`session-export`,outputPath:Gp(r)};case`fork`:return{type:`session-fork`,args:r};case`clone`:return{type:`session-clone`};case`tree`:return{type:`session-tree`,args:r};case`share`:return{type:`session-share`};case`import`:return{type:`session-import`,path:r?Gp(r)??r:``};case`btw`:return{type:`session-btw`,question:r};case`fast`:return{type:`fast-toggle`};case`reload`:return{type:`reload-resources`};case`mcp`:return{type:`open-mcp`,args:r};case`rlm-max-depth`:return{type:`rlm-max-depth`,args:r};case`heartbeat`:return{type:`heartbeat-manage`,args:r};case`heartbeats`:return{type:`heartbeat-list`};case`traces`:return{type:`session-traces`};case`agents`:return{type:`session-agents`};case`changelog`:return{type:`show-changelog`};case`hotkeys`:return{type:`show-hotkeys`};case`copy`:return{type:`copy-last-reply`};case`update`:return{type:`update-check`,args:r};case`fullscreen`:return{type:`toggle-fullscreen`};case`quit`:return{type:`quit-app`};default:return null}}function qp(e){let t=e.trim().replace(/\s+/g,`-`);return/^[\w.-]+$/.test(t)?t:``}function Jp(e){return`/${e} `}function Yp(e){let t=e.argumentHint?.trim();return{id:e.name,label:`/${e.name}`,value:Jp(e.name),description:e.description,category:e.category??`builtin`,...t?{metadata:{argumentHint:t}}:{}}}function Xp(e){return e.metadata?.argumentHint?.trim()?!0:!!Bp.find(t=>t.name===e.id)?.argumentHint?.trim()}function Zp(e,t,n){let r=new Map;for(let e of Bp)r.set(e.name,Yp(e));for(let e of n?.commands??[])r.has(e.name)||r.set(e.name,Yp({...e,category:`extension`}));if(!t||!e)return Array.from(r.values());for(let[t,n]of[[`skill`,e.skills],[`prompt`,e.prompts]])for(let e of n){if(e.activationStatus&&e.activationStatus!==`active`)continue;let n=qp(e.name);if(!n||r.has(n))continue;let i=e.argumentHint?.trim();r.set(n,{id:n,label:`/${n}`,value:Jp(n),description:e.description,category:t,...i?{metadata:{argumentHint:i}}:{}})}return Array.from(r.values())}var Qp={dismissedChildIds:new Set,scopeKey:``,selectedTabId:`main`};function $p(e,t){return e.scopeKey===t?e:{dismissedChildIds:new Set,scopeKey:t,selectedTabId:`main`}}function em(e,t){return $p(e,t)}function tm(e,t){if(t.type===`scope`)return $p(e,t.scopeKey);let n=$p(e,t.scopeKey);if(t.type===`select`)return{...n,selectedTabId:t.tabId};if(t.type===`dismiss`)return{...n,dismissedChildIds:new Set(n.dismissedChildIds).add(t.tabId),selectedTabId:n.selectedTabId===t.tabId?`main`:n.selectedTabId};let r=new Set(n.dismissedChildIds);return r.delete(t.tabId),{...n,dismissedChildIds:r}}function nm(e,t,n=crypto.randomUUID()){return{id:n,role:e,createdAt:Date.now(),parts:[{type:`text`,text:t}]}}function rm(e){return{...nm(`user`,e),optimistic:!0}}function im(e,t){return e.filter(e=>e.id!==t||e.optimistic!==!0)}function am(e,t){return e.map(e=>{if(e.id!==t||e.optimistic!==!0)return e;let n={...e};return delete n.optimistic,n})}function om(e,t){let n=e.findIndex(e=>e.type===`text`);if(n===-1)return[...e,{type:`text`,text:t}];let r=[...e],i=r[n];return r[n]=i.type===`text`?{...i,text:`${i.text}${t}`}:i,r}function sm(e,t){let n=e.findIndex(e=>e.type===t.type&&`toolCallId`in e&&e.toolCallId===t.toolCallId);if(n===-1){let n=e.findIndex(e=>e.type===`text`);return n===-1?[...e,t]:[...e.slice(0,n),t,...e.slice(n)]}let r=[...e];return r[n]={...r[n],...t},r}function cm(e,t){let n=e.findIndex(e=>e.type===`payload`&&(e.id&&t.id?e.id===t.id:e.kind===t.kind&&e.title===t.title));if(n===-1)return[...e,t];let r=[...e];return r[n]={...r[n],...t},r}function lm({messageId:e,presentation:t}){return{type:`tool-FleetReasoning`,toolCallId:`${e}-reasoning`,state:t.streaming?`input-streaming`:`output-available`,input:t}}function um(e,t,n){return e.map(e=>e.id===t?{...e,parts:om(e.parts,n)}:e)}function dm(e,t,n){return e.map(e=>e.id===t?{...e,parts:sm(e.parts,n)}:e)}function fm(e,t,n){return e.map(e=>e.id===t?{...e,parts:cm(e.parts,n)}:e)}function pm(e,t,n){return dm(e,t,lm({messageId:t,presentation:n}))}function mm(e){if(e.role!==`assistant`)return e;let t=e.parts.filter(e=>e.type!==`tool-Thinking`);return t.length===e.parts.length?e:{...e,parts:t}}function hm(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``)}var gm={steering:[],followUp:[]};function _m(e){let t=e.sessionId?.trim()||void 0,n=e.projectId?.trim()||void 0;return t||n?{...t?{sessionId:t}:{},...n?{projectId:n}:{}}:{}}function vm(e,t){let n=t.sessionId?.trim()||e.sessionId,r=t.projectId?.trim()||e.projectId;return{...n?{sessionId:n}:{},...r?{projectId:r}:{}}}function ym(e){return(e.parts??[]).some(e=>e.type!==`text`||typeof e.text==`string`&&e.text.trim().length>0)}function bm(e,t){if(!t)return e;let{assistantId:n,snapshot:r}=e;if(n===t)return e;if(n){let e=r.messages.map(e=>e.id===n&&e.role===`assistant`?{...e,id:t}:e);return{assistantId:t,snapshot:{...r,messages:e}}}return{assistantId:t,snapshot:{...r,messages:[...r.messages,nm(`assistant`,``,t)]}}}function xm(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):[...e,t]}function Sm(e,t,n){let r=[n?e.find(e=>e.id===n&&e.role===`assistant`):void 0,e.find(e=>e.id===t.id&&e.role===`assistant`)].filter(Boolean).flatMap(e=>e.parts.filter(e=>e.type===`tool-FleetReasoning`||e.type===`payload`));return r.length===0||t.parts.some(e=>e.type===`tool-FleetReasoning`||e.type===`payload`)?t:{...t,parts:[...r,...t.parts]}}function Cm(e,t,n){if(!ym(t)){let r=[n?e.find(e=>e.id===n&&e.role===`assistant`):void 0,e.find(e=>e.id===t.id&&e.role===`assistant`)].filter(Boolean).find(e=>ym(e));if(r)return xm(e,{...t,parts:r.parts,createdAt:t.createdAt??r.createdAt})}return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):n&&n!==t.id&&e.some(e=>e.id===n&&e.role===`assistant`)?e.map(e=>e.id===n&&e.role===`assistant`?t:e):[...e,t]}function wm(e,t){if(t.type===`session_snapshot`)return{assistantId:null,snapshot:{...e.snapshot,activityLabel:void 0,messages:t.messages,planLabel:void 0,presentation:t.presentation,queue:gm,sessionMetadata:t.session}};if(t.type===`done`&&t.sessionReset)return e;if(t.type===`presentation`){let n=e.snapshot.presentation?.revision??-1;return t.presentation.revision<=n?e:{...e,snapshot:{...e.snapshot,presentation:t.presentation}}}if(t.type===`rlm`){let n=e.snapshot.presentation;if(!n)return e;let r=n.rlmChildren.find(e=>e.id===t.child.id);if(r&&r.timestamp>t.child.timestamp)return e;let i=[...n.rlmChildren.filter(e=>e.id!==t.child.id),t.child];return{...e,snapshot:{...e.snapshot,presentation:{...n,rlmChildren:i,...t.tree?{rlmTree:t.tree}:{}}}}}if(t.type===`message`){if(t.message.role===`user`){let n=e.snapshot.messages.findIndex(e=>e.id===t.message.id),r=n>=0?n:e.snapshot.messages.findIndex(e=>e.role===`user`&&e.optimistic===!0),i=r>=0?{...t.message,id:e.snapshot.messages[r].id}:t.message;return{...e,snapshot:{...e.snapshot,messages:r>=0?e.snapshot.messages.map((e,t)=>t===r?i:e):[...e.snapshot.messages,i]}}}let n=bm(e,t.message.id);return{assistantId:n.assistantId,snapshot:{...n.snapshot,messages:Cm(n.snapshot.messages,t.message,n.assistantId)}}}if(t.type===`start`){let n=e.snapshot.messages.some(e=>e.id===t.id&&e.role===`assistant`);return{assistantId:t.id,snapshot:{...e.snapshot,adapterCapabilities:t.adapterCapabilities,activityLabel:t.sessionReset?`Started a fresh Pi session`:t.diagnostics?.[0],messages:n?e.snapshot.messages:[...e.snapshot.messages,nm(`assistant`,``,t.id)],sessionMetadata:vm(e.snapshot.sessionMetadata,{sessionId:t.sessionId})}}}if(t.type===`thinking`)return e;let n=t.type===`delta`||t.type===`reasoning`||t.type===`tool`||t.type===`payload`?bm(e,t.messageId):e,{assistantId:r,snapshot:i}=n;if(t.type===`delta`&&r)return{assistantId:r,snapshot:{...i,messages:um(i.messages,r,t.text)}};if(t.type===`error`)return n;if(t.type===`reasoning`&&r&&i.adapterCapabilities?.features.includes(`reasoning-summary-v1`))return{assistantId:r,snapshot:{...i,messages:pm(i.messages,r,t.presentation)}};if(t.type===`tool`&&r)return{assistantId:r,snapshot:{...i,messages:dm(i.messages,r,t.part)}};if(t.type===`payload`&&r)return{assistantId:r,snapshot:{...i,messages:fm(i.messages,r,t.part)}};if(t.type===`queue`)return{assistantId:r,snapshot:{...i,queue:{steering:t.steering,followUp:t.followUp}}};if(t.type===`plan`)return{assistantId:r,snapshot:{...i,planLabel:t.message}};if(t.type===`state`)return{assistantId:r,snapshot:{...i,activityLabel:yd(t.state.name)}};if(t.type===`compaction`)return{assistantId:r,snapshot:{...i,activityLabel:t.phase===`start`?`Compacting session`:`Compaction finished`}};if(t.type===`retry`)return{assistantId:r,snapshot:{...i,activityLabel:t.phase===`start`?`Retrying request ${t.attempt}/${t.maxAttempts}`:t.success?`Retry succeeded`:`Retry failed`}};if(t.type===`done`){let e=mm(t.message),n=Sm(i.messages,e,r),a=Cm(i.messages,n,r),o=t.presentation&&t.presentation.revision>(i.presentation?.revision??-1)?t.presentation:i.presentation;return{assistantId:null,snapshot:{...i,activityLabel:void 0,messages:a.map(e=>mm(e)),queue:gm,presentation:o,sessionMetadata:vm(i.sessionMetadata,{sessionId:t.sessionId})}}}return n}function Tm(e){return e===`running`||e===`recovering`?`streaming`:e===`error`||e===`failed`?`error`:`ready`}function Em(){return{status:`ready`,loading:!1,messages:[]}}function Dm(e){return{assistantId:null,snapshot:{messages:e.messages,presentation:e.presentation,queue:gm,sessionMetadata:e.session}}}function Om(e){return typeof e==`object`&&!!e&&e.type===`connected`&&typeof e.sessionId==`string`}function km(e){try{let t=$r(e,`session`);if(!t)return;let n=JSON.parse(t);if(typeof n.generation!=`string`||n.generation.length===0||typeof n.lastEventId!=`number`||!Number.isInteger(n.lastEventId)||n.lastEventId<0){Zr(e,`session`);return}return{generation:n.generation,lastEventId:n.lastEventId}}catch{Zr(e,`session`);return}}function Am({client:e,enabled:t,child:n,loadSession:r,parentSessionId:i}){let[a,o]=(0,X.useState)(0),[s,c]=(0,X.useState)(Em),[l,u]=(0,X.useState)(!1),d=(0,X.useRef)(null),f=(0,X.useRef)(0),p=(0,X.useRef)(null),m=n?.id,h=n?.activeSessionId,g=n?.status,_=n?.error,v=(0,X.useCallback)(()=>o(e=>e+1),[]),y=(0,X.useCallback)(async t=>{let n=t.trim();if(!n||!i||!m||p.current)return;let a=new AbortController;p.current={controller:a,parentSessionId:i,childId:m},u(!0);let o=rm(n);c(e=>({...e,status:`streaming`,loading:!1,error:void 0,messages:[...e.messages,o]}));try{if(await e.streamMessage({sessionId:i,childId:m,message:n,streamingBehavior:`steer`},e=>{if(!a.signal.aborted){if(e.type===`error`)throw pd(e);e.type===`start`&&c(e=>({...e,status:`streaming`}))}},a.signal),a.signal.aborted)return;try{let e=await r(i,m);if(a.signal.aborted)return;let t=Dm(e);d.current=t,c({status:`ready`,loading:!1,messages:e.messages,presentation:e.presentation})}catch{c(e=>({...e,status:`ready`,loading:!1}))}}catch(e){if(a.signal.aborted)return;c(t=>({...t,status:`error`,loading:!1,messages:im(t.messages,o.id),error:e instanceof Error?e:Error(String(e))}))}finally{p.current?.controller===a&&(p.current=null,u(!1))}},[m,e,r,i]),b=(0,X.useCallback)(()=>{let t=p.current;t?.controller.abort(),p.current=null;let n=t?.parentSessionId??i,r=t?.childId??m;n&&r&&e.abortSession({sessionId:n,childId:r}).catch(()=>void 0),u(!1),v()},[m,e,i,v]);return(0,X.useEffect)(()=>{let n=f.current+1;f.current=n;let o=()=>f.current===n;if(a>0&&(d.current=null),!t||!i||!m||!g){d.current=null,c(Em());return}let s=!1,u=null,p=null,y=0,b=!1,x=0,S,C=!1,w=Tm(g),T=`pi:sse:cursor:subagent:${`${i}:${m}:${h??``}`}`,E=km(T);E&&(S=E.generation,x=E.lastEventId);let D=()=>{if(!S){Zr(T,`session`);return}Qr(T,JSON.stringify({generation:S,lastEventId:x}),`session`)},O=()=>{x=0,D()},k=()=>{p&&=(clearTimeout(p),null)},A=(e,t,n)=>{s||!o()||(w=t,d.current=e,c({status:t,loading:!1,messages:e.snapshot.messages,presentation:e.snapshot.presentation,...n?{error:n}:{}}))},j=()=>void 0,M=()=>{s||!o()||C||(y+=1,k(),p=setTimeout(j,Math.min(2e3,250*2**Math.min(y,3))))},N=async()=>{if(!(s||!o()||C||b)){b=!0;try{await r(i,m),!s&&o()&&M()}catch(e){if(s||!o())return;if(dd(e)){C=!0,k();let t=e instanceof Error?e:Error(String(e));c(e=>({...e,status:`error`,loading:!1,error:t}));return}M()}finally{b=!1}}};return(async()=>{c(e=>({...e,loading:!0,error:void 0}));try{let t=await r(i,m);if(s||!o())return;let n=Dm(t);if(d.current=n,c({status:w,loading:!1,messages:t.messages,presentation:t.presentation}),g!==`running`&&g!==`recovering`&&!l||typeof window>`u`||typeof EventSource>`u`)return;j=()=>{if(s||!o()||C)return;let t=e.openSubagentEvents(i,m,{...S?{streamGeneration:S}:{},...x>0?{lastEventId:x}:{}});u?.close();try{u=new EventSource(t)}catch{N();return}u.onopen=()=>{y=0},u.onmessage=e=>{if(s||!o()||C)return;let t=Number.parseInt(e.lastEventId??``,10);Number.isFinite(t)&&t>0&&(x=t,D());let n;try{n=JSON.parse(e.data)}catch{return}if(Om(n)){n.streamGeneration&&S!==n.streamGeneration?(S=n.streamGeneration,O()):n.streamGeneration&&(S=n.streamGeneration),n.cursorReset&&O(),D();return}let r;try{r=_d(Di,n,`Subagent chat stream event`)}catch{return}if(r.type===`state`&&r.state.message===`resync-required`){O(),u?.close(),u=null,v();return}let i=d.current;if(!i)return;let a=wm(i,r);if(r.type===`error`){C=!0,k(),u?.close(),u=null,A(a,`error`,pd(r));return}if(r.type===`done`){A(a,`ready`);return}if(r.type===`session_snapshot`){let e=r.status===`error`?Error(_??`The subagent thread ended with an error.`):void 0;r.terminal&&(C=!0,k(),u?.close(),u=null),A(a,r.status,e);return}if(r.type===`state`){let e=r.state.name===`agent_start`||r.state.name===`turn_start`?`streaming`:r.state.name===`agent_end`||r.state.name===`turn_end`?`ready`:w;A(a,e);return}A(a,w)},u.onerror=()=>{u?.close(),u=null,N()}},j()}catch(e){if(s||!o())return;c(t=>({...t,status:`error`,loading:!1,error:e instanceof Error?e:Error(String(e))}))}})(),()=>{s=!0,C=!0,u?.close(),k()}},[h,m,_,g,e,t,r,i,v,a,l]),{...s,refresh:v,sendMessage:y,sending:l,stop:b}}function jm(e){return wr(e.sessionName?.trim()||e.label)||`Subagent`}function Mm({activeProjectId:e,loadSubagentSession:t,presentation:n,rootSessionId:r,client:i=vp}){let a=`${e??``}:${r??``}`,[o,s]=(0,X.useReducer)(tm,Qp);(0,X.useEffect)(()=>{s({type:`scope`,scopeKey:a})},[a]);let{dismissedChildIds:c,selectedTabId:l}=em(o,a),u=(0,X.useMemo)(()=>Kr(n.rlmChildren,n.rlmTree),[n.rlmChildren,n.rlmTree]),d=(0,X.useMemo)(()=>[{id:`main`,label:`Main agent`,kind:`main`},...u.filter(e=>!c.has(e.id)).map(e=>({id:e.id,label:jm(e),kind:`subagent`,status:e.status}))],[c,u]),f=d.some(e=>e.id===l)?l:`main`,p=u.find(e=>e.id===f),m=(0,X.useCallback)(e=>{e!==`main`&&!u.some(t=>t.id===e)||(e!==`main`&&s({type:`restore`,scopeKey:a,tabId:e}),s({type:`select`,scopeKey:a,tabId:e}))},[u,a]),h=(0,X.useCallback)(e=>{e===`main`||!u.some(t=>t.id===e)||s({type:`dismiss`,scopeKey:a,tabId:e})},[u,a]),g=(0,X.useCallback)(e=>m(e),[m]);return{activeTabId:f,closeTab:h,conversation:Am({client:i,child:p,enabled:f!==`main`&&!!p,loadSession:t,parentSessionId:r}),openChildTab:g,selectedChild:p,selectTab:m,tabs:d}}var Nm=`fleet-prime:v1:right-panel-width`,Pm=`fleet-prime:v1:theme-preference`,Fm=320;function Im(){return typeof window>`u`?Fm:Lm()}function Lm(){return typeof window>`u`?Fm:Math.max(Fm,Math.floor(window.innerWidth*Lr))}function Rm(e){return Math.min(Lm(),Math.max(Fm,Math.round(e)))}function zm(){return jr(Nm,Im(),Rm)}function Bm(e){Pr(Nm,Rm(e))}function Vm(){if(typeof window>`u`)return`system`;let e=$r(Pm);return e===`light`||e===`dark`||e===`system`?e:`system`}function Hm(e){Qr(Pm,e)}function Um(e){if(typeof window>`u`)return;let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches,n=e===`dark`||e===`system`&&t;document.documentElement.classList.toggle(`dark`,n),document.documentElement.dataset.theme=n?`dark`:`light`}function Wm(e,t){let{sessionMetadata:n,setSessionMetadata:r}=t,i=(0,X.useMemo)(()=>e?.models.map(Tr)??[],[e]),[a,o]=(0,X.useState)(),[s,c]=(0,X.useState)(),[l,u]=(0,X.useState)(null),d=(0,X.useRef)(`workspace`),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(()=>Vm()),[b,x]=(0,X.useState)(()=>zm());(0,X.useEffect)(()=>{if(i.length===0)return;let t=e?.selectedModelKey??i[0].id;if(!a){o(t);return}let n=i.find(e=>e.id===a);(!n||n.available===!1)&&o(t)},[i,a,e]),(0,X.useEffect)(()=>{let t=i.find(e=>e.id===a);if(!t)return;let n=Cr(t);c(t=>Mr(t??e?.defaultThinkingLevel,n))},[i,a,e?.defaultThinkingLevel]),(0,X.useEffect)(()=>{if(Um(v),v!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>Um(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[v]);let S=(0,X.useRef)(null);(0,X.useEffect)(()=>{let e=S.current;if(S.current=l,!l||e!==null)return;let t=Im();x(t),Bm(t)},[l]),(0,X.useEffect)(()=>{l===null&&h(null)},[l]),(0,X.useEffect)(()=>{if(!l)return;let e=()=>{x(e=>{let t=Rm(e);return Bm(t),t})};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[l]);let C=(0,X.useCallback)(e=>{y(e),Hm(e),Um(e)},[]),w=(0,X.useCallback)(e=>{Fr({event:e,startWidth:b,getNextWidth:(e,t,n)=>Rm(n-(e-t)),onWidthChange:e=>{x(e),Bm(e)}})},[b]),T=(0,X.useCallback)(()=>{u(d.current)},[]),E=(0,X.useCallback)(e=>{if(e!==null&&(d.current=e),u(e),e===null){p(null);return}h(t=>{if(!t)return t;let n=ci(t);return!n||n.panel===e?t:null})},[]),D=(0,X.useCallback)((e,t=`artifacts`)=>{p(e),E(t)},[E]),O=(0,X.useCallback)(e=>{let t=ci(e);t&&(E(t.panel),h(t.path))},[E]),k=(0,X.useCallback)(e=>{let t=e.panel===`artifacts`&&e.relativePath?`workspace`:e.panel,n=t===`workspace`||t===`artifacts`;E(t),h(n?e.relativePath??null:null),e.focus&&window.requestAnimationFrame(()=>{document.querySelector(`[data-fleet-panel-focus]`)?.focus({preventScroll:!0})})},[E]),A=(0,X.useCallback)(e=>{r(e)},[r]),j=i.find(e=>e.id===a),M=Mr(s??e?.defaultThinkingLevel,Cr(j)),N=(0,X.useCallback)(e=>{let t=i.find(e=>e.id===a);c(Mr(e,Cr(t)))},[a,i]);return{commandPaletteOpen:g,handleResourceCanvasResizeStart:w,handleThemePreferenceChange:C,initialSessionMetadata:n,modelKey:a,modelSelection:(0,X.useMemo)(()=>Er(j,M),[M,j]),models:i,openWorkspacePath:O,openPanelAction:k,persistSession:A,reopenRightPanel:T,resourceCanvasWidth:b,rightPanel:l,selectedArtifactId:f,selectedWorkspacePath:m,setCommandPaletteOpen:_,setModelKey:o,setRightPanel:E,openArtifact:D,setSelectedWorkspacePath:h,setThinkingLevel:N,themePreference:v,thinkingLevel:M}}var Gm=`fleet-prime:v1:chat-session`;function Km(){let[e,t]=(0,X.useState)(()=>qm()),n=(0,X.useCallback)(e=>{t(e)},[]);return(0,X.useEffect)(()=>{Zm(e)},[e]),{sessionMetadata:e,setSessionMetadata:n}}function qm(){let e=$r(Gm);if(!e)return Jm();try{return Ym(JSON.parse(e))}catch{return Jm()}}function Jm(){let e=$r(`fleet-prime:v1:chat-sessions`);if(!e)return{};try{return Ym(JSON.parse(e)?.normal)}catch{return{}}}function Ym(e){let t=Ei.safeParse(e);return t.success?t.data:{}}function Xm(){Zr(Gm),Zr(`fleet-prime:v1:chat-sessions`),Zr(`fleet-prime:v1:chat-mode`)}function Zm(e){if(!e.sessionId&&!e.projectId){Zr(Gm),Zr(`fleet-prime:v1:chat-sessions`);return}Qr(Gm,JSON.stringify(e))}function Qm({messages:e,resources:t,workspaceTree:n}){return(0,X.useMemo)(()=>$m({messages:e,resources:t,workspaceTree:n}),[e,t,n])}function $m({messages:e,resources:t,workspaceTree:n}){let r=!!t?.agentsFiles.some(e=>e.name===`AGENTS.md`),i=e=>e.toLowerCase().includes(`frontend`),a=!!(t?.skills.some(e=>i(`${e.name} ${e.description??``}`))||n?.nodes.some(e=>i(JSON.stringify(e))));if(e.length===0)return[$(`overview`,`Summarize this project`),$(`frontend`,a?`Find a skill "frontend"`:`Explore available skills`),$(`docs`,r?`Read AGENTS.md`:`Tell me about this project`)];let o=[...e].reverse().find(e=>e.role===`assistant`),s=th([...e].reverse().find(e=>e.role===`user`)).toLowerCase(),c=th(o).toLowerCase(),l=new Set,u=[];if(o){for(let e of o.parts)if(e.type.startsWith(`tool-`)){l.add(e.type);let t=e.input,n=typeof t?.file_path==`string`?t.file_path:typeof t?.path==`string`?t.path:void 0;n&&u.push(n)}}if(l.has(`tool-Write`)||l.has(`tool-Edit`)){let e=u[u.length-1]??`the changed file`;return[$(`review-changes`,`Review the changes to ${e.split(`/`).pop()??e}`),$(`run-tests`,`Run the tests`),$(`explain-changes`,`Explain what was changed and why`)]}if(l.has(`tool-Read`)&&!l.has(`tool-Write`)){let e=u[u.length-1]??`the file`;return[$(`summarize-file`,`Summarize ${e.split(`/`).pop()??e}`),$(`suggest-improvements`,`Suggest improvements`),$(`find-related`,`Find related files`)]}return l.has(`tool-Bash`)?[$(`explain-output`,`Explain the output`),$(`fix-issues`,`Fix any issues found`),$(`run-again`,`Run it again with different options`)]:l.has(`tool-PlanWrite`)?[$(`execute-plan`,`Execute this plan`),$(`refine-plan`,`Refine the plan`),$(`explain-plan`,`Explain the plan in detail`)]:l.has(`tool-resource_install`)?[$(`use-resource`,`Use the installed resource`),$(`list-resources`,`List all available resources`),$(`workspace`,`Show workspace files`)]:eh(o)?[$(`fix-error`,`Fix the error`),$(`explain-error`,`Explain what went wrong`),$(`suggest-alternative`,`Suggest an alternative approach`)]:s.includes(`what can you do`)||s.includes(`help`)?[$(`frontend`,`Find a skill "frontend"`),$(`agents`,r?`Read AGENTS.md`:`Read the repo docs`),$(`workspace`,`Show workspace files`)]:s.includes(`skill`)?[$(`frontend-skill`,`Find a skill "frontend"`),$(`memory-skill`,`Find a skill "memory"`),$(`skill-docs`,r?`Read AGENTS.md`:`Show workspace files`)]:c?[$(`go-deeper`,`Go deeper on this`),$(`next-steps`,`What should I do next?`),$(`workspace`,`Show workspace files`)]:[$(`overview`,`Summarize this project`),$(`workspace`,`Show workspace files`),$(`docs`,r?`Read AGENTS.md`:`Tell me about this project`)]}function eh(e){return e?e.parts.some(e=>{if(e.type===`error`)return!0;if(!e.type.startsWith(`tool-`)||typeof e!=`object`||!e)return!1;let t=e;if(t.state===`output-error`||t.state===`error`||t.state===`failed`)return!0;let n=typeof t.output==`object`&&t.output!==null?t.output:void 0;return!!(t.error||n?.error)}):!1}function $(e,t){return{id:e,label:t,value:t}}function th(e){return e?e.parts.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(` `):``}function nh(e){switch(e){case`queued`:return`queued`;case`running`:case`recovering`:return`streaming`;case`error`:case`failed`:return`error`;case`cancelled`:return`cancelled`;case`done`:return`complete`;default:return`ready`}}function rh(e){switch(e){case`running`:case`recovering`:return`bg-emerald-400 motion-safe:animate-pulse`;case`error`:case`failed`:return`bg-destructive`;case`queued`:return`bg-amber-300`;case`cancelled`:return`bg-foreground/35`;default:return`bg-foreground/35`}}function ih({tabs:e,value:t,onValueChange:n,onClose:r,onNewSession:i}){let a=(0,X.useRef)(new Map),o=(0,X.useCallback)((e,t)=>{t?a.current.set(e,t):a.current.delete(e)},[]);(0,X.useEffect)(()=>{for(let t of a.current.keys())e.some(e=>e.id===t)||a.current.delete(t)},[e]);let s=(0,X.useCallback)(t=>{let r=e[t];r&&(a.current.get(r.id)?.focus(),n(r.id))},[n,e]),c=(0,X.useCallback)((t,n)=>{let r=e.findIndex(e=>e.id===n);if(r<0)return;let i;t.key===`ArrowRight`&&(i=(r+1)%e.length),t.key===`ArrowLeft`&&(i=(r-1+e.length)%e.length),t.key===`Home`&&(i=0),t.key===`End`&&(i=e.length-1),i!==void 0&&(t.preventDefault(),s(i))},[s,e]);return(0,Z.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-1`,"data-testid":`agent-tab-bar`,children:[(0,Z.jsx)(`div`,{"aria-label":`Agent conversations`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,role:`tablist`,children:e.map(e=>{let i=e.id===t,a=nh(e.status);return(0,Z.jsxs)(`div`,{className:`group/tab relative min-w-0 shrink-0 basis-[164px] sm:max-w-[164px]`,"data-tab-id":e.id,children:[(0,Z.jsxs)(z,{ref:t=>o(e.id,t),"aria-controls":ko(e.id),"aria-selected":i,"aria-label":`${e.label}, ${a}`,className:U(`h-7 w-full min-w-0 justify-start text-left gap-1.5 rounded-[7px] border border-transparent px-2 text-[0.75rem] font-medium leading-none transition-colors motion-reduce:transition-none`,i?`bg-surface-4 text-foreground shadow-none`:`bg-transparent text-foreground/45 hover:bg-foreground/5 hover:text-foreground/75`,e.kind===`subagent`&&r&&`pr-7`),"data-state":i?`active`:`inactive`,id:Oo(e.id),onClick:()=>n(e.id),onKeyDown:t=>c(t,e.id),role:`tab`,size:`sm`,tabIndex:i?0:-1,type:`button`,variant:`ghost`,children:[e.kind===`main`?(0,Z.jsx)(Zn,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}):(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:U(`size-1.5 shrink-0 rounded-full`,rh(e.status))}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]}),e.kind===`subagent`&&r?(0,Z.jsx)(z,{"aria-label":`Close ${e.label} tab`,className:`absolute top-1/2 right-1 size-5 -translate-y-1/2 rounded-[5px] p-0 text-foreground/35 opacity-0 transition-opacity motion-reduce:transition-none hover:bg-foreground/10 hover:text-foreground/75 focus-visible:opacity-100 group-hover/tab:opacity-100`,onClick:t=>{t.stopPropagation(),r(e.id)},size:`icon-xs`,title:`Close ${e.label} tab`,type:`button`,variant:`ghost`,children:(0,Z.jsx)(Xr,{"aria-hidden":`true`,className:`size-3`})}):null]},e.id)})}),i?(0,Z.jsx)(z,{"aria-label":`New chat`,className:U(Pn,`relative z-10 size-7 shrink-0 rounded-[7px] text-foreground/50 hover:bg-foreground/7 hover:text-foreground/85`),"data-testid":`new-chat-tab`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},size:`icon-sm`,title:`New chat`,type:`button`,variant:`ghost`,children:(0,Z.jsx)(Ur,{"aria-hidden":`true`,className:`size-3.5`})}):null]})}var ah=`https://docs.qredence.ai`;function oh({className:e}){return(0,Z.jsx)(`svg`,{width:`97`,height:`93`,viewBox:`0 0 97 93`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:e,"aria-hidden":`true`,children:(0,Z.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M53.72 0.17C53.27 0.24 52.22 0.43 51.40 0.60C50.58 0.78 49.27 1.11 48.49 1.36C47.71 1.61 46.34 2.17 45.43 2.60C44.52 3.03 43.18 3.79 42.44 4.29C41.71 4.78 40.62 5.62 40.06 6.14C39.47 6.65 38.58 7.54 38.06 8.12C37.53 8.69 36.68 9.81 36.16 10.59C35.65 11.36 34.92 12.65 34.56 13.42C34.20 14.20 33.73 15.38 33.50 16.04C33.29 16.69 32.98 17.83 32.83 18.57C32.67 19.31 32.46 20.65 32.35 21.56C32.26 22.49 32.22 24.04 32.26 25.14C32.31 26.22 32.52 28.03 32.73 29.17C32.93 30.32 33.31 31.97 33.55 32.83C33.79 33.70 34.29 35.24 34.68 36.27C35.07 37.30 35.77 38.97 36.26 40.00C36.76 41.03 37.64 42.67 38.22 43.66C38.80 44.64 39.73 46.12 40.28 46.94C40.83 47.76 41.76 49.05 42.31 49.79C42.88 50.55 44.06 51.99 44.92 53.00C45.79 54.02 46.95 55.36 47.52 55.97C48.07 56.59 50.28 58.93 52.43 61.18C54.58 63.42 58.20 67.08 60.48 69.32C64.30 73.02 64.62 73.38 64.36 73.56C64.21 73.68 63.57 74.02 62.94 74.35C62.30 74.67 61.26 75.14 60.63 75.40C59.99 75.65 58.90 76.04 58.20 76.28C57.49 76.50 56.28 76.83 55.51 77.00C54.73 77.16 53.39 77.41 52.52 77.53C51.57 77.68 49.92 77.77 48.31 77.77C46.65 77.77 45.03 77.68 43.98 77.53C43.06 77.40 41.41 77.07 40.35 76.80C39.29 76.53 37.74 76.07 36.92 75.76C36.10 75.44 34.70 74.83 33.79 74.37C32.87 73.92 31.58 73.20 30.87 72.77C30.17 72.34 28.96 71.49 28.19 70.89C27.41 70.28 26.07 69.08 25.20 68.22C24.33 67.35 23.05 65.87 22.35 64.93C21.65 63.99 20.77 62.71 20.39 62.10C20.02 61.48 19.48 60.51 19.18 59.93C18.90 59.35 18.41 58.27 18.11 57.54C17.80 56.81 17.35 55.53 17.11 54.70C16.85 53.88 16.50 52.48 16.30 51.57C16.11 50.66 15.87 48.88 15.77 47.61C15.63 45.87 15.63 44.73 15.75 42.98C15.85 41.72 16.06 39.97 16.24 39.10C16.42 38.24 16.74 36.92 16.94 36.19C17.15 35.46 17.59 34.18 17.91 33.36C18.24 32.53 18.89 31.13 19.35 30.22C19.81 29.31 20.57 28.01 21.04 27.31C21.48 26.61 22.29 25.50 22.81 24.85C23.33 24.19 24.48 22.92 25.36 22.01C26.31 21.02 27.11 20.05 27.34 19.57C27.56 19.16 27.84 18.38 27.96 17.87C28.08 17.35 28.19 16.56 28.19 16.11C28.19 15.66 28.08 14.86 27.95 14.31C27.83 13.78 27.53 12.98 27.28 12.53C27.04 12.08 26.53 11.38 26.14 10.98C25.74 10.57 25.10 10.02 24.68 9.75C24.27 9.48 23.53 9.11 23.04 8.94C22.54 8.77 21.66 8.59 21.09 8.54C20.40 8.49 19.72 8.55 19.05 8.71C18.48 8.84 17.65 9.12 17.18 9.35C16.59 9.63 15.79 10.26 14.63 11.41C13.69 12.30 12.38 13.71 11.72 14.53C11.05 15.33 10.05 16.60 9.51 17.37C8.97 18.11 8.17 19.29 7.73 19.99C7.30 20.69 6.48 22.13 5.93 23.20C5.37 24.28 4.64 25.80 4.31 26.61C3.97 27.40 3.43 28.85 3.09 29.80C2.76 30.77 2.30 32.34 2.06 33.28C1.82 34.22 1.45 35.94 1.25 37.09C1.04 38.24 0.81 39.95 0.72 40.89C0.64 41.84 0.57 43.75 0.57 45.15C0.57 46.55 0.64 48.46 0.72 49.40C0.81 50.35 1.00 51.96 1.18 52.99C1.34 54.02 1.75 55.87 2.06 57.09C2.37 58.33 2.94 60.21 3.33 61.27C3.72 62.33 4.42 64.05 4.88 65.08C5.34 66.11 6.14 67.65 6.61 68.52C7.09 69.38 8.02 70.86 8.64 71.80C9.29 72.74 10.36 74.22 11.06 75.08C11.75 75.95 12.85 77.22 13.50 77.91C14.14 78.59 15.38 79.80 16.24 80.58C17.11 81.35 18.45 82.49 19.23 83.07C20.01 83.67 21.45 84.68 22.44 85.33C23.42 85.97 25.17 86.98 26.32 87.58C27.47 88.16 29.32 89.01 30.43 89.46C31.53 89.91 33.11 90.48 33.93 90.73C34.76 90.98 36.10 91.36 36.92 91.57C37.74 91.76 39.19 92.07 40.13 92.24C41.07 92.40 42.92 92.64 44.24 92.78C45.55 92.90 47.40 93 48.34 93C49.28 93 51.10 92.90 52.37 92.78C53.64 92.66 55.49 92.42 56.48 92.24C57.46 92.07 58.94 91.76 59.76 91.55C60.58 91.36 61.90 90.98 62.67 90.73C63.45 90.48 64.93 89.94 65.96 89.54C66.99 89.13 68.71 88.36 69.77 87.82L69.80 87.80L69.80 87.80C70.85 87.27 71.95 86.71 72.23 86.54C72.51 86.37 73.47 85.77 74.36 85.21L75.96 84.19C78.34 86.36 80.13 88.00 81.49 89.25C83.14 90.76 84.26 91.67 84.92 92.01C85.46 92.30 86.32 92.64 86.86 92.76C87.40 92.90 88.13 93 88.50 93C88.88 93 89.58 92.90 90.07 92.78C90.56 92.64 91.37 92.34 91.86 92.10C92.36 91.87 93.03 91.45 93.34 91.18C93.67 90.91 94.24 90.28 94.59 89.79C94.95 89.30 95.37 88.54 95.54 88.12C95.68 87.69 95.88 86.88 95.97 86.33C96.06 85.67 96.06 84.95 95.97 84.31C95.88 83.74 95.61 82.85 95.36 82.30C95.10 81.73 94.71 81.04 94.49 80.76C94.25 80.47 92.44 78.74 90.46 76.92C88.49 75.08 86.86 73.56 86.86 73.52C86.86 73.47 87.47 72.52 88.22 71.40C88.97 70.26 90.12 68.26 90.77 66.95C91.44 65.63 92.31 63.74 92.70 62.74C93.10 61.72 93.67 60.11 93.95 59.15C94.25 58.18 94.65 56.69 94.85 55.82C95.04 54.96 95.31 53.64 95.43 52.91C95.57 52.18 95.76 50.49 95.89 49.18C96.01 47.87 96.12 46.12 96.12 45.30C96.12 44.48 96.01 42.70 95.89 41.34C95.77 39.98 95.54 38.10 95.36 37.16C95.19 36.22 94.89 34.77 94.68 33.95C94.48 33.13 94.07 31.73 93.77 30.82C93.49 29.91 93.00 28.53 92.68 27.76C92.37 26.98 91.83 25.73 91.50 24.99C91.16 24.26 90.43 22.84 89.88 21.86C89.34 20.87 88.32 19.23 87.62 18.20C86.94 17.17 85.73 15.53 84.95 14.54C84.16 13.56 82.53 11.77 81.34 10.57C80.14 9.38 78.47 7.84 77.60 7.15C76.74 6.47 75.23 5.38 74.25 4.72C73.26 4.08 71.72 3.18 70.81 2.75C69.90 2.30 68.56 1.73 67.83 1.48C67.09 1.21 65.94 0.88 65.29 0.72C64.63 0.57 63.36 0.35 62.45 0.21C61.35 0.06 59.78 -0.01 57.67 0.00C55.94 0.02 54.16 0.09 53.72 0.17ZM54.24 15.47C54.82 15.33 55.45 15.20 55.66 15.17C55.87 15.13 56.81 15.10 57.75 15.08C58.69 15.08 60.08 15.16 60.81 15.28C61.54 15.38 62.56 15.63 63.05 15.83C63.54 16.04 64.38 16.44 64.91 16.74C65.45 17.04 66.57 17.78 67.41 18.41C68.26 19.04 69.63 20.23 70.48 21.07C71.32 21.92 72.47 23.17 73.04 23.87C73.60 24.58 74.54 25.88 75.14 26.79C75.75 27.70 76.60 29.13 77.07 30.00C77.51 30.86 78.19 32.30 78.55 33.21C78.90 34.12 79.43 35.58 79.68 36.49C79.93 37.40 80.29 38.86 80.46 39.77C80.68 40.89 80.80 42.31 80.84 44.25C80.90 45.97 80.86 47.67 80.75 48.58C80.67 49.40 80.41 50.88 80.22 51.87C80.01 52.85 79.53 54.57 79.16 55.68C78.78 56.78 78.08 58.50 77.60 59.48C77.13 60.47 76.47 61.66 75.59 63.02L73.35 60.81C72.11 59.59 69.30 56.78 67.09 54.56C64.88 52.35 62.12 49.51 60.97 48.29C59.81 47.05 58.17 45.24 57.30 44.25C56.43 43.27 55.28 41.90 54.75 41.19C54.19 40.49 53.28 39.22 52.72 38.36C52.15 37.49 51.39 36.28 51.03 35.67C50.67 35.06 50.09 33.94 49.75 33.21C49.40 32.47 48.88 31.16 48.58 30.29C48.28 29.43 47.89 28.07 47.74 27.26C47.55 26.34 47.45 25.22 47.45 24.13C47.45 23.17 47.55 22.05 47.67 21.52C47.79 21.01 48.10 20.17 48.36 19.65C48.63 19.13 49.24 18.32 49.75 17.80C50.43 17.11 50.98 16.74 51.93 16.29C52.63 15.96 53.66 15.59 54.24 15.47Z`,fill:`currentColor`})})}function sh({user:e,onSignOut:t,onOpenSettings:n,compact:r=!1,label:i=`Fleet Prime Agent`,className:a}){let o=`flex w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-label leading-4 text-foreground transition-colors hover:bg-foreground/6`;return(0,Z.jsx)(`div`,{className:U(`flex min-w-0 items-center gap-2`,a),children:(0,Z.jsx)(Pc,{side:`bottom`,align:`start`,trigger:(0,Z.jsxs)(fs,{ariaLabel:`Open account menu`,className:U(`min-w-0 border-transparent shadow-none`,r?`size-8 justify-center px-2`:`w-full justify-start`),children:[(0,Z.jsx)(oh,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:r?`sr-only`:`text-[0.8125rem] font-medium tracking-[-0.01em] whitespace-nowrap`,children:i}),(0,Z.jsx)($n,{className:`size-3.5 shrink-0 text-foreground/35`})]}),children:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`px-2 py-1.5 text-label leading-4 text-foreground/50`,children:e.name||e.email}),(0,Z.jsxs)(`button`,{type:`button`,className:o,children:[(0,Z.jsx)(oh,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Account`})]}),(0,Z.jsxs)(`a`,{href:ah,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Z.jsx)(Yn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Documentation`})]}),n&&(0,Z.jsxs)(`button`,{type:`button`,className:o,onClick:n,children:[(0,Z.jsx)(_n,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Settings`})]}),(0,Z.jsxs)(`button`,{type:`button`,className:o,onClick:()=>void t(),children:[(0,Z.jsx)(Hn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Sign out`})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`a`,{href:ah,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Z.jsx)(Yn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Documentation`})]}),n&&(0,Z.jsxs)(`button`,{type:`button`,className:o,onClick:n,children:[(0,Z.jsx)(_n,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Settings`})]})]})})})}function ch({activeTabId:e,tabs:t,onCloseTab:n,onNewSession:r,onSelectTab:i,onOpenSettings:a}){let o=s(),c=mp();return{left:(0,Z.jsx)(tl,{"aria-label":`Toggle conversations`,className:`!size-7 !rounded-[7px] border border-border/70 bg-background shadow-sm`,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-icon":`inline-start`,className:`block h-3.5 w-4 rounded-[3px] border border-current before:block before:h-full before:w-1 before:border-r before:border-current`})}),accountMenu:(0,Z.jsx)(sh,{className:`w-full`,label:`Qredence`,user:c,onSignOut:async()=>{Xm(),await gp(),o({to:`/`})},onOpenSettings:a}),center:(0,Z.jsx)(ih,{tabs:t,value:e,onValueChange:i,onClose:n,onNewSession:r}),right:(0,Z.jsx)(ms,{compact:!0})}}var lh=`/api/chat/command`,uh=`MCP usage: /mcp, /mcp list, /mcp login <name>, /mcp logout <name>.`;function dh(e){return e.sessionId?.trim()||void 0}function fh({sessionId:e,name:t}){let n=e.trim()||`none`;return[t?`Session: ${t}`:`Session`,` id: ${n}`].join(`
9
+ `)}function ph(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(` `):``}function mh(e){let{entry:t}=e;if(t.type===`message`&&t.message){let e=t.message.role??`message`,n=ph(t.message.content).replace(/\s+/g,` `).trim();return`${e}: ${n.length>72?`${n.slice(0,72)}…`:n}`}return t.label??e.label??t.type}function hh(e,t){let n=[],r=(e,i)=>{for(let a of e){let e=a.entry.id===t?`*`:` `,o=` `.repeat(i);n.push(`${o}${e} ${a.entry.id} ${mh(a)}`),r(a.children,i+1)}};return r(e,0),n}function gh(e,t){let n=hh(e,t);return n.length>0?n.join(`
10
+ `):`(empty session tree)`}function _h(e){let t=[],n=[],r=e=>{for(let i of e){if(i.entry.type===`message`){let e={id:i.entry.id,preview:mh(i)};t.push(e),i.entry.message?.role===`user`&&n.push(e)}r(i.children)}};return r(e),n.length>0?n:t}function vh(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.role!==`assistant`||n.source===`local`)continue;let r=hm(n).trim();if(r)return r}}function yh(e){return e.flatMap(e=>{if(e.source===`local`)return[];let t=hm(e).trim(),n=`**${e.role}**\n\n${t}`;return n.trim().length>0?[n]:[]}).join(`
11
+
12
+ ---
13
+
14
+ `)}function bh({appendLocalMessage:e,getMessages:t,getSessionMetadata:n,modelKey:r,models:i,onForkPicker:a,openSettings:o,onOpenUIRequest:s,resumeSession:l,sessions:u,setEffortPickerOpen:d,setModelKey:f,setModelPickerOpen:p,setThinkingLevel:m,startNewSession:h}){let g=c(),_=(0,X.useCallback)(async(e,t=``)=>{let r=dh(n());if(!r)return{ok:!1,error:`No active session — start a new one first.`};try{let n=await fetch(lh,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:r,command:e,args:t})});if(!n.ok){let e=`HTTP ${n.status}`;try{let t=await n.json();typeof t.message==`string`&&(e=t.message)}catch{}return{ok:!1,error:e}}return{ok:!0,payload:await n.json()}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},[n]),v=(0,X.useCallback)(async(t,n,r)=>{let i=await t;if(!i.ok){e(`${n} failed: ${i.error}`);return}let a={newSessionId:typeof i.payload.newSessionId==`string`?i.payload.newSessionId:`?`,selectedText:typeof i.payload.selectedText==`string`?i.payload.selectedText:`(none)`};if(oi.success(r(a)),a.newSessionId!==`?`){await l({sessionId:a.newSessionId});return}e(r(a))},[e,l]),y=(0,X.useCallback)(c=>{switch(c.type){case`open-model-picker`:return c.modelKey&&i.some(e=>e.id===c.modelKey)?(f(c.modelKey),oi.success(`Model set to ${c.modelKey}`),!0):(d(!1),p(!0),!0);case`open-effort-picker`:return c.unknownLevel&&oi.error(`Unknown thinking level '${c.unknownLevel}'.`),p(!1),d(!0),!0;case`set-thinking-level`:{let e=i.find(e=>e.id===r),t=Cr(e);return t.includes(c.level)?(m(c.level),oi.success(`Effort set to ${Ir(c.level)}`),!0):(oi.error(`Unknown thinking level '${c.level}'. Available: ${t.join(`, `)}`),p(!1),d(!0),!0)}case`open-settings`:return o(c.tab),!0;case`new-session`:return xd(async()=>h()),!0;case`openui-request`:return c.request?(s(c.request),!0):(e(`Usage: /openui <request>`),!0);case`session-info`:return(async()=>{let t=dh(n()),r=await _(`session`);if(!r.ok||!t){e(fh({sessionId:t??`none`,name:null}));return}e(fh({sessionId:t,name:typeof r.payload.name==`string`?r.payload.name:null}))})(),!0;case`session-rename`:return c.name?((async()=>{let t=await _(`name`,c.name??``);e(t.ok?`Session renamed to "${c.name}".`:`Couldn't rename session: ${t.error}`)})(),!0):(e(`Usage: /name <display name>`),!0);case`session-context`:return(async()=>{let t=await _(`context`);if(!t.ok){e(`Couldn't load context: ${t.error}`);return}let n=t.payload.usage;if(!n){e(`Context usage isn't available yet — no model response on this branch.`);return}let{tokens:r,contextWindow:i,percent:a}=n;e(`Context usage: ~${r??`?`}/${i??`?`} tokens${typeof a==`number`?` (${a.toFixed(1)}%)`:``}`)})(),!0;case`session-system-prompt`:return(async()=>{let t=await _(`system-prompt`);if(!t.ok){e(`Couldn't load system prompt: ${t.error}`);return}e(typeof t.payload.systemPrompt==`string`?t.payload.systemPrompt:`(empty)`)})(),!0;case`session-logs`:return e("Daemon and client logs live at `~/.prime/agent/log/`. Use your OS's log viewer or `tail -f` there (TUI parity with /logs)."),!0;case`session-export`:return(async()=>{let t=await _(`export`,c.outputPath??``);if(!t.ok){e(`Export failed: ${t.error}`);return}e(`Session exported to ${typeof t.payload.path==`string`?t.payload.path:`(unknown path)`} (${typeof t.payload.format==`string`?t.payload.format:`html`})`)})(),!0;case`session-fork`:return c.args?(v(_(`fork`,c.args),`Fork`,e=>`Forked → session ${e.newSessionId}. Selected text: ${e.selectedText}`),!0):((async()=>{let t=await _(`tree`);if(!t.ok){e(`Fork picker failed: ${t.error}`);return}let n=t.payload.tree,r=Array.isArray(n?.tree)?_h(n.tree):[];if(r.length===0){e(`No fork points yet — send a user message first, then run /fork.`);return}a(r)})(),!0);case`session-clone`:return v(_(`clone`),`Clone`,e=>`Cloned → session ${e.newSessionId}.`),!0;case`session-tree`:return(async()=>{let t=await _(`tree`,c.args??``);if(!t.ok){e(`Tree failed: ${t.error}`);return}let n=t.payload.tree;if(!n||!Array.isArray(n.tree)){e(`(no session tree available)`);return}e(gh(n.tree,n.leafId??null))})(),!0;case`session-share`:return(async()=>{let n=yh(t());if(!n.trim()){e(`Nothing to share yet.`);return}await navigator.clipboard.writeText(n),oi.success(`Transcript copied`),e(`Copied the transcript to the clipboard. GitHub Gist upload is TUI-only in this port.`)})().catch(e=>{oi.error(`Share failed: ${e instanceof Error?e.message:String(e)}`)}),!0;case`session-import`:return e(c.path?`/import ${c.path} is not wired in the web port. Resume a saved conversation from the session picker instead.`:`Usage: /import <path.jsonl> — JSONL import is not wired in the web port. Use the session picker to resume.`),!0;case`session-btw`:return e(c.question?`/btw is not wired in the web port. Side question was not sent:\n${c.question}`:`Usage: /btw <question> — side questions are not wired in the web port.`),!0;case`session-traces`:return e(`Fleet Prime traces (preview / upload / login) are TUI-only. The web port does not upload traces.`),!0;case`session-agents`:return u.length===0?(e(`No saved sessions. The web port has no daemon agent tray — use the conversation picker in the header.`),!0):(e(`Saved sessions (web stand-in for /agents):\n${u.map(e=>`${e.sessionId} ${e.title}`).join(`
15
+ `)}`),!0);case`open-providers`:return o(`providers`),!0;case`open-logout`:return e(`Provider sign-out is managed by Fleet Prime CLI commands.`),!0;case`open-mcp`:{o(`mcp`);let t=c.args.trim().split(/\s+/).filter(Boolean),n=t[0],r=t.slice(1).join(` `);return!n||n===`list`||(n===`login`||n===`reconnect`)&&!r?!0:(n===`login`||n===`reconnect`)&&r?(e(`Open Settings → MCP and sign in to "${r}".`),!0):n===`logout`&&r?((async()=>{try{let t=await vp.mcpOAuth({name:r,action:`logout`});t.connections&&g.setQueryData(yp.mcp,{connections:t.connections}),g.invalidateQueries({queryKey:[`chat`,`resources`]}),e(`Signed out of MCP connection "${r}".`)}catch(t){e(t instanceof Error?t.message:`Could not sign out of "${r}".`)}})(),!0):(e(uh),!0)}case`fast-toggle`:return(async()=>{e("/fast toggles OpenAI Fast mode. The web port reads this from ~/.prime/agent/settings.json — flip `fastMode` there or in Settings.")})(),!0;case`reload-resources`:return(async()=>{let t=await _(`reload`);e(t.ok?`Reloaded keybindings, extensions, skills, prompts, and themes.`:`Reload failed: ${t.error}`)})(),!0;case`show-changelog`:return e(`Changelog lives at https://github.com/Qredence/fleet-prime-agent/blob/main/CHANGELOG.md`),!0;case`show-hotkeys`:return e(`Web port hotkeys: Enter=send, Alt+Enter=follow-up while streaming, / = slash menu, ⌘K=command palette.`),!0;case`copy-last-reply`:return(async()=>{let e=vh(t());if(!e){oi.error(`No assistant message to copy`);return}await navigator.clipboard.writeText(e),oi.success(`Last assistant message copied`)})().catch(e=>{oi.error(`Copy failed: ${e instanceof Error?e.message:String(e)}`)}),!0;case`update-check`:return e(`/update is TUI-only (pulls the latest Fleet Prime release). Use npm/pnpm in your shell to upgrade.`),!0;case`toggle-fullscreen`:return e(`/fullscreen is TUI-only (alternate screen rendering). In the browser, use your OS/browser fullscreen.`),!0;case`quit-app`:return e(`/quit is TUI-only (exits the agent loop). Close this browser tab instead.`),!0;case`rlm-max-depth`:return e(`/rlm-max-depth is not yet wired in the web port.`),!0;case`heartbeat-manage`:case`heartbeat-list`:return e(`/heartbeat(s) are not wired in the web port. Persistent heartbeats remain TUI/session-cron.`),!0;default:return!1}},[e,_,v,t,n,r,i,a,o,s,g,u,d,f,p,m,h]),b=(0,X.useCallback)(e=>{if(Xp(e))return!1;let t=Kp(e.id);return t?y(t):!1},[y]),x=(0,X.useCallback)(e=>{let t=Wp(e);if(!t)return!1;let n=Kp(t.command,t.args);return n?y(n):!1},[y]);return{applyLocalSlashAction:y,forkFromEntry:(0,X.useCallback)(e=>{v(_(`fork`,e),`Fork`,e=>`Forked → session ${e.newSessionId}. Selected text: ${e.selectedText}`)},[_,v]),handleLocalSlashSubmit:x,handleSlashCommandSelect:b}}function xh({messages:e,answerQuestion:t}){let n=(0,X.useRef)(new Map);return(0,X.useMemo)(()=>{let r=Sh(e);if(!r){n.current.clear();return}let{part:i}=r,a=i.input?.questions??[];if(a.length===0){n.current.clear();return}let o=a.map((e,t)=>Ch(e,t)),s=i.toolCallId,c=s??`pending-question`;for(let e of Array.from(n.current.keys()))e!==c&&n.current.delete(e);let l=o.map((e,t)=>e.id??`question-${t+1}`);return{id:c,questions:o,submitLabel:`Continue`,allowSkip:!0,onSubmit:e=>{if(e.kind===`skip`){n.current.delete(c),t({toolCallId:s,answer:{kind:`skip`,...e.questionId?{questionId:e.questionId}:{}}});return}let r=n.current.get(c),i=r??new Map;r||n.current.set(c,i);let a=typeof e.questionId==`string`&&e.questionId?e.questionId:l.find(e=>!i.has(e));if(!a){t({toolCallId:s,answer:e});return}if(i.set(a,wh(e)),!l.every(e=>i.has(e)))return;let o={};for(let e of l){let t=i.get(e);t!==void 0&&(o[e]=t)}n.current.delete(c),t({toolCallId:s,answer:{kind:`questions`,answers:o}})}}},[e,t])}function Sh(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.role!==`assistant`||!Array.isArray(n.parts)))for(let e=n.parts.length-1;e>=0;e--){let t=n.parts[e];if(t?.type===`tool-Question`&&Rp(t))return{part:t}}}}function Ch(e,t){let n=(e.options??[]).map(e=>{let t=e.value??e.label;if(typeof t==`string`)return{id:t,value:t,label:e.label??t,description:e.description}}).filter(e=>e!==void 0),r=e.kind??(n.length>0?`single`:`text`);return{id:typeof e.id==`string`&&e.id.trim()?e.id:`question-${t+1}`,kind:r,title:e.question??e.prompt??e.title??``,options:n.length>0?n:void 0,allowCustom:e.allowOther??e.allowCustom}}function wh(e){if(e.kind===`multi`){let t=Array.isArray(e.selectedIds)?[...e.selectedIds]:[];return typeof e.text==`string`&&e.text.trim()&&t.push(e.text.trim()),t}return e.kind===`text`?typeof e.text==`string`?e.text:``:e.selectedIds?.[0]??e.text??``}function Th(e){let t=e.replace(/\*{1,2}([^*]+)\*{1,2}/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/^(Use|Run|Execute|Create|Write|Read|Check|Verify|Update|Modify|Add|Remove|Delete|Install)\s+(the\s+)?/i,``).replace(/\s+/g,` `).trim();return t.length>0&&(t=`${t.charAt(0).toUpperCase()}${t.slice(1)}`),t}function Eh(e){let t=[],n=e.match(/\*{0,2}Plan:\*{0,2}\s*\n/i),r=n?e.slice(e.indexOf(n[0])+n[0].length):e;for(let e of r.matchAll(/^\s*(\d+)[.)]\s+\*{0,2}([^*\n]+)/gm)){let n=e[2].trim().replace(/\*{1,2}$/,``).trim();if(n.length>5&&!n.startsWith("`")&&!n.startsWith(`/`)&&!n.startsWith(`-`)){let e=Th(n);e.length>3&&t.push({step:t.length+1,text:e,completed:!1})}}if(!n&&t.length<2){let t=0,n=Array.from(e.matchAll(/^\s*([A-Z][^:\n]{4,72}):\s+[^\n]+/gm)).flatMap(e=>{let n=Th(e[1]??``);return n.length<=3?[]:(t+=1,[{step:t,text:n,completed:!1}])});if(n.length>=2)return n;let r=[...new Set(e.split(/\n+/).flatMap(e=>{let t=e.trim();if(t.length<=5||[`#`,`>`,`*`,`-`].includes(t.charAt(0)))return[];let n=Th(t);return n.length>3?[n]:[]}))].slice(0,12).map((e,t)=>({step:t+1,text:e,completed:!1}));return r.length>=2?r:[]}return t}var Dh=`plan-mode-decision`;function Oh(){return{enabled:!1,executing:!1,todos:[],pendingDecision:!1,pendingDecisionToolCallId:void 0}}function kh(e,t,n){let r=Lh(e);return n===`execute`?(r.enabled=!1,r.executing=r.todos.some(e=>!e.completed),r.pendingDecision=!1,r.pendingDecisionToolCallId=void 0,r):n===`refine`||t===`plan`?(r.enabled=!0,r.executing=!1,r.pendingDecisionToolCallId=void 0,r):(r.enabled=!1,r.executing=!1,r.pendingDecision=!1,r.pendingDecisionToolCallId=void 0,r)}function Ah(e,t){if(!e.enabled)return{state:e,changed:!1};let n=Eh(t);return n.length===0?{state:e,changed:!1}:{state:{...Lh(e),todos:n,executing:!1,pendingDecision:!0,pendingDecisionToolCallId:void 0},changed:!0}}function jh(e,t){return{enabled:e.mode===`plan`,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:e.pendingDecision,pendingDecisionToolCallId:e.pendingDecision?`${Dh}-${t}`:void 0}}function Mh(e,t){return Nh(e,jh(t,e))}function Nh(e,t){if(t.todos.length===0)return;let n=Ih(t),r=t.pendingDecision?`awaiting_approval`:n.total>0&&n.completed===n.total?`completed`:`approved`;return{type:`tool-PlanWrite`,toolCallId:t.pendingDecisionToolCallId??`plan-mode-decision-${e}`,state:`output-available`,input:{action:t.pendingDecision?`create`:`update`,pendingDecision:t.pendingDecision,executing:t.executing,completed:n.completed,total:n.total,presentation:n,plan:{id:e,title:n.executing?`Executing plan`:`Execution plan`,summary:Rh(t),status:r,todos:n.todos}}}}function Ph(e){return!!e?.startsWith(Dh)}function Fh(e,t){if(!e.pendingDecision)return e;let n=`${Dh}-${t}`;return e.pendingDecisionToolCallId===n?e:{...Lh(e),pendingDecisionToolCallId:n}}function Ih(e){let t=e.todos.filter(e=>e.completed).length,n=e.todos.length,r=e.enabled?`plan`:`agent`,i=e.executing?n>0?`Plan progress ${t}/${n}`:`Executing plan`:e.pendingDecision?`Plan ready for review`:e.enabled?`Plan mode`:void 0;return{mode:r,executing:e.executing,pendingDecision:!!e.pendingDecision,completed:t,total:n,todos:e.todos.map(e=>({...e})),message:i}}function Lh(e){return{enabled:e.enabled,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:!!e.pendingDecision,pendingDecisionToolCallId:e.pendingDecisionToolCallId}}function Rh(e){let t=Ih(e),n=t.todos.map(e=>`${e.completed?`- [x]`:`- [ ]`} ${e.step}. ${e.text}`);return e.pendingDecision?n.push(``,`Review the steps, then execute, stay in plan mode, or refine.`):t.executing?n.push(``,`Progress: ${t.completed}/${t.total} completed.`):t.total>0&&t.completed===t.total&&n.push(``,`All plan steps are complete.`),n.join(`
16
+ `)}function zh(e,t){let n=new Map(t.map(e=>[e.assistantMessageId,e]));return e.map(e=>{if(e.role!==`assistant`)return e;let t=n.get(e.id),r=t?Mh(e.id,t.state):void 0;return r?{...e,parts:sm(e.parts,r)}:e})}function Bh(e,t){for(let n of e)for(let e of n.parts){if(e.type!==`tool-PlanWrite`||e.toolCallId!==t||!e.input||typeof e.input!=`object`)continue;let r=e.input.presentation;if(!r||typeof r!=`object`)continue;let i=r;if(!(!Array.isArray(i.todos)||i.mode!==`agent`&&i.mode!==`plan`&&i.mode!==`harness`))return{assistantMessageId:n.id,state:{...i,todos:i.todos.map(e=>({...e}))}}}}async function Vh(e){e.setSessionMetadataSynced({}),e.setMessagesSynced([]),e.setQueueSynced(gm),e.setActivityLabelSynced(void 0),e.setPlanLabelSynced(void 0),e.setPresentationSynced({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]}),e.setError(null),e.setStatus(`ready`);let t=await e.client.createSession(e.projectId);e.setSessionMetadataSynced(t.session),e.setMessagesSynced(t.messages),e.setPresentationSynced(t.presentation),e.setActivityLabelSynced(t.sessionReset?`Started a fresh Pi session`:void 0),await e.refreshSessions()}async function Hh(e,t,n,r){if(!t(e))return!1;try{await n()}catch(e){let t=e instanceof Error?e:Error(String(e));r.setError(t),r.setStatus(`error`),bd(t)}return!0}async function Uh(e,t,n){return Hh(e,ud,t,n)}async function Wh(e,t,n){return Hh(e,dd,t,n)}function Gh({client:e,initialSessionMetadataRef:t,initializedRef:n,recoverFromForbiddenSession:r,refreshSessions:i,setActivityLabelSynced:a,setError:o,setMessagesSynced:s,setPlanLabelSynced:c,setPresentationSynced:l,setQueueSynced:u,setSessionMetadataSynced:d,setStatus:f}){(0,X.useEffect)(()=>{if(n.current)return;n.current=!0;let p=new AbortController,m=!1;f(`ready`),o(null),u(gm),a(void 0),c(void 0),s([]);let h=t.current;return i().then(t=>{if(p.signal.aborted)return;let n=h.sessionId?t.find(e=>e.sessionId===h.sessionId):void 0,r=n??(h.projectId?t.find(e=>e.projectId===h.projectId):t[0]);if(!r){d(h.projectId?{projectId:h.projectId}:{});return}let i=n?h:{sessionId:r.sessionId,projectId:r.projectId};return e.loadSession(i)}).then(e=>{!e||p.signal.aborted||(d(e.session),s(zh(e.messages,e.planPresentations)),l(e.presentation),a(e.sessionReset?`Started a fresh Pi session`:void 0))}).catch(async e=>{if(p.signal.aborted)return;let t={setError:o,setStatus:f};if(await Uh(e,r,t)||await Wh(e,r,t)||p.signal.aborted)return;let n=e instanceof Error?e:Error(String(e));o(n),f(`error`),bd(n)}).finally(()=>{m=!0}),()=>{p.abort(),m||(n.current=!1)}},[e,t,n,r,i,a,o,s,c,l,u,d,f])}function Kh({client:e,presentationRef:t,sessionId:n,sessionMetadataRef:r,setActivityLabelSynced:i,setAdapterCapabilities:a,setMessagesSynced:o,setPresentationSynced:s,setQueueSynced:c,setSessionMetadataSynced:l,statusRef:u}){(0,X.useEffect)(()=>{if(!n||typeof window>`u`)return;let d=`pi:sse:last-event-id:${n}`,f={current:void 0},p=Number.parseInt($r(d,`session`)??`0`,10);Number.isNaN(p)&&(p=0);let m=null,h=null,g=0,_=!1,v=0,y=!1,b,x=(d,p)=>{let m;try{m=JSON.parse(d.data)}catch{return}m.type===`start`&&(b=m.id),m.type===`done`&&(b=void 0);let h=u.current;if(m.type===`presentation`){m.presentation.revision>(t.current?.revision??-1)&&s(m.presentation);return}if(m.type===`rlm`){if(!Number.isNaN(p)&&p>0){if(p<=v)return;v=p}let e=t.current,n=e.rlmChildren.find(e=>e.id===m.child.id);if(n&&n.timestamp>m.child.timestamp)return;s({...e,rlmChildren:[...e.rlmChildren.filter(e=>e.id!==m.child.id),m.child],...m.tree?{rlmTree:m.tree}:{}});return}if(m.type===`tool`&&m.part?.type===`tool-Question`){o(e=>{let t=m.part.toolCallId??``;if(!t)return e;let n=e=>e.parts.some(e=>e.type!==`text`&&e.type!==`error`&&`toolCallId`in e&&e.toolCallId===t),r=m.messageId?e.findIndex(e=>e.id===m.messageId&&e.role===`assistant`):-1;if(r<0&&b&&(r=e.findIndex(e=>e.id===b&&e.role===`assistant`)),r<0){let t=-1,i=-1;for(let r=e.length-1;r>=0;--r){let a=e[r];a.role===`assistant`&&(n(a)&&i<0?i=r:t<0&&(t=r))}r=m.part.state===`input-streaming`?t>=0?t:i:i>=0?i:t}let i={...m.part,type:`tool-Question`};return r<0?[...e,{id:m.messageId??crypto.randomUUID(),role:`assistant`,parts:[i],createdAt:new Date().toISOString()}]:e.flatMap((e,a)=>{if(a===r)return[{...e,parts:sm(e.parts,i)}];if(!n(e))return[e];let o=e.parts.filter(e=>!(e.type!==`text`&&e.type!==`error`&&`toolCallId`in e&&e.toolCallId===t));return o.length>0?[{...e,parts:o}]:[]})});return}if(u.current===`streaming`||u.current===`submitted`)return;let g=m;if(g.type===`connected`){f.current=g.adapterCapabilities,a(g.adapterCapabilities),g.cursorReset&&(v=0);return}if(m.type===`reasoning`){let e=m.messageId;if(!f.current?.features.includes(`reasoning-summary-v1`)||!e)return;o(t=>pm(t,e,m.presentation));return}if(m.type===`state`){if(i(typeof m.state?.message==`string`?m.state.message:void 0),m.state?.name===`agent_settled`){if(h===`streaming`||h===`submitted`)return;let t=r.current.sessionId;e.loadSession({sessionId:n}).then(e=>{y||r.current.sessionId!==n||r.current.sessionId===t&&u.current!==`streaming`&&u.current!==`submitted`&&(o(zh(e.messages,e.planPresentations)),s(e.presentation),l(e.session),c(gm))}).catch(()=>void 0)}return}m.type===`queue`&&c({steering:m.steering,followUp:m.followUp})},S=()=>{let e=new URLSearchParams({sessionId:n});p>0&&e.set(`lastEventId`,String(p)),m?.close();let t=new EventSource(id(`/api/chat/events?${e}`));m=t,t.onmessage=e=>{if(y||m!==t)return;let n=Number.parseInt(e.lastEventId??``,10);!Number.isNaN(n)&&n>0&&(p=n,Qr(d,String(n),`session`)),g>0&&(g=0,_&&(_=!1,u.current!==`streaming`&&u.current!==`submitted`&&i(void 0))),x(e,n)},t.onerror=()=>{y||m!==t||(t.close(),g+=1,g>1&&u.current!==`streaming`&&u.current!==`submitted`&&(_=!0,i(g>2?`Reconnecting… (attempt ${g})`:`Reconnecting…`)),h&&clearTimeout(h),h=setTimeout(S,Math.min(2e3,250*2**Math.min(g,3))))}};return S(),()=>{y=!0,m?.close(),h&&clearTimeout(h)}},[e,t,n,r,i,a,o,s,c,l,u])}function qh(){let e,t,n=!1,r=new Promise((n,r)=>{e=n,t=r});return r.catch(()=>void 0),{promise:r,resolve:()=>{n||(n=!0,e())},reject:e=>{n||(n=!0,t(e))}}}var Jh=Promise.resolve();function Yh({activityLabelRef:e,client:t,messagesRef:n,presentationRef:r,model:i,pendingSendControllerRef:a,projectId:o,planLabelRef:s,queueRef:c,recoverFromForbiddenSession:l,refreshSessions:u,sessionMetadataRef:d,streamControllersRef:f,setActivityLabelSynced:p,setError:m,setMessagesSynced:h,setPresentationSynced:g,setPlanLabelSynced:_,setQueueSynced:v,setSessionMetadataSynced:y,setStatus:b,status:x}){let S=(0,X.useRef)(null),C=(0,X.useRef)(new Set),w=(0,X.useRef)(Jh),T=(0,X.useRef)(void 0),E=(0,X.useRef)(o);(0,X.useEffect)(()=>{E.current=o},[o]);let D=(0,X.useCallback)(e=>{for(let t of C.current)if(t.sessionId===e)return t},[]),O=(0,X.useCallback)(e=>{for(let t of[...C.current])t.sessionId===e&&(C.current.delete(t),t.reject(Error(`Chat stream stopped before admission`)))},[]),k=(0,X.useCallback)(e=>{T.current=e},[]),A=(0,X.useCallback)(async e=>{let[n,r]=await Promise.all([t.loadSession({sessionId:e}),u()]);if(d.current.sessionId!==e)return!1;n.messages.length>0&&h(zh(n.messages,n.planPresentations)),g(n.presentation),y(n.session),v({steering:[],followUp:[]}),_(void 0);let i=r.find(t=>t.sessionId===e)?.status===`running`;return i||p(n.sessionReset?`Started a fresh Pi session`:void 0),i},[t,u,d,p,h,_,g,v,y]),j=(0,X.useCallback)(async e=>{if(e?.aborted)throw Error(`Session creation was aborted`);let n=d.current;if(n.sessionId)return n;let r=S.current;if(r)return r;let i=t.createSession(E.current,e).then(t=>{if(e?.aborted)throw Error(`Session creation was aborted`);return y(t.session),g(t.presentation),d.current=t.session,u(),t.session}).finally(()=>{S.current===i&&(S.current=null)});return S.current=i,i},[t,u,d,g,y]),M=(0,X.useCallback)((i,a,o,l)=>{if(i.type===`error`)throw pd(i);if(i.type===`done`&&i.sessionReset){o!==d.current.sessionId&&u();return}let f;if(i.type===`done`&&l===`plan`){let e=Ah(kh(Oh(),l),hm(i.message)),n=Fh(e.state,i.message.id);f=e.changed?Nh(i.message.id,n):void 0,f&&t.upsertPlanPresentation({sessionId:o,presentation:{assistantMessageId:i.message.id,state:Ih(n)}}).catch(()=>void 0)}if(i.type===`start`){let e=D(o);e&&(C.current.delete(e),e.resolve())}if(o!==d.current.sessionId){i.type===`done`&&u();return}let m=wm({assistantId:a.current,snapshot:{adapterCapabilities:T.current,activityLabel:e.current,messages:n.current,presentation:r.current,planLabel:s.current,queue:c.current,sessionMetadata:d.current}},i);a.current=m.assistantId,T.current=m.snapshot.adapterCapabilities,h(m.snapshot.messages),m.snapshot.presentation&&g(m.snapshot.presentation),y(m.snapshot.sessionMetadata),v(m.snapshot.queue),p(m.snapshot.activityLabel),_(m.snapshot.planLabel),f&&i.type===`done`&&h(e=>dm(e,i.message.id,f)),i.type===`start`&&b(`streaming`),i.type===`done`&&(b(`ready`),u())},[e,t,D,n,r,s,c,u,d,p,h,g,_,v,y,b]),N=(0,X.useCallback)(async(e,n=`steer`,r)=>{let a=d.current.sessionId??(await j()).sessionId;if(!a)throw Error(`Unable to queue a message without a session`);let o=rm(e);h(e=>[...e,o]),m(null);let s=w.current,c=qh(),l=s.catch(()=>void 0).then(async()=>{try{await D(a)?.promise,await t.streamMessage({message:e,attachments:r?.attachments,openUI:r?.openUI,openUIArtifact:r?.openUIArtifact,model:i,planAction:r?.planAction,mode:r?.mode,sessionId:a,streamingBehavior:n},e=>{if(e.type===`start`&&e.requestKind===`session-command`&&c.resolve(),e.type===`done`&&e.requestKind===`session-command`){if(d.current.sessionId!==a)return;h(t=>am(t.some(t=>t.id===e.message.id)?t:[...t,e.message],o.id));return}if(e.type===`queue`&&(c.resolve(),v({steering:e.steering,followUp:e.followUp}),p(n===`steer`?`Steered`:`Follow-up queued`)),e.type===`error`)throw pd(e)}),c.resolve()}catch(e){throw c.reject(e),h(e=>im(e,o.id)),e}try{await u()}catch{}});w.current=c.promise.catch(()=>void 0),await l},[t,j,D,i,u,d,p,m,h,v]);return{enqueueDuringStream:N,handleStreamEvent:M,resetStreamAdmission:O,sendMessage:(0,X.useCallback)(async({text:e,attachments:r,openUI:o,openUIArtifact:s,planAction:c,mode:g,altKey:_})=>{let v=e.trim();if(!v)return!1;if(x===`submitted`||x===`streaming`||D(d.current.sessionId)!==void 0)try{return await N(v,_?`followUp`:`steer`,{attachments:r,mode:g,openUI:o,openUIArtifact:s,planAction:c}),!0}catch(e){let t=e instanceof Error?e:Error(String(e));return m(t),bd(t),!1}m(null),p(void 0),b(`submitted`),n.current.length===0&&(v.length,d.current.sessionId);let y=rm(v);h(e=>[...e,y]);let S={current:null},w=qh();w.sessionId=d.current.sessionId,C.current.add(w);let T=new AbortController;a.current=T;let E,O=!1;try{let e=await j(T.signal);if(T.signal.aborted)return!1;let a=e.sessionId;if(!a)throw Error(`Unable to start a session stream`);E=a,w.sessionId=a,f.current.set(a,T),await t.streamMessage({message:v,attachments:r,openUI:o,openUIArtifact:s,model:i,planAction:c,mode:g,sessionId:a,streamingBehavior:_?`followUp`:`steer`},e=>{e.type===`done`&&!e.sessionReset&&(O=!0),M(e,S,a,g),e.type===`done`&&e.requestKind===`session-command`&&d.current.sessionId===a&&h(e=>am(e,y.id))},T.signal);let l=!1;try{l=await A(a)}catch{}return d.current.sessionId===a&&(O||!l)&&b(`ready`),n.current.length,!0}catch(e){if(C.current.delete(w)&&w.reject(e),h(e=>im(e,y.id)),T.signal.aborted)return!1;if(E&&d.current.sessionId!==E)return u(),!1;let t={setError:m,setStatus:b};if(await Uh(e,l,t)||await Wh(e,l,t))return!1;let n=e instanceof Error?e:Error(String(e));return m(n),b(`error`),bd(n),!1}finally{C.current.delete(w)&&w.reject(Error(`Chat stream ended before admission`)),T.signal.aborted&&h(e=>im(e,y.id)),a.current===T&&(a.current=null),E&&T&&f.current.get(E)===T&&f.current.delete(E)}},[t,j,N,D,M,A,n,i,a,u,l,d,p,m,h,b,f,x]),setAdapterCapabilities:k}}function Xh(e,t){if(!e||typeof e!=`object`)return;let n=e.presentation;if(!n||typeof n!=`object`)return n;let r=t.selectedIds?.[0],i=n,a=(Array.isArray(i.todos)?i.todos:[]).some(e=>!!(e&&typeof e==`object`&&!e.completed));return{...i,pendingDecision:!1,mode:r===`execute`?`agent`:`plan`,executing:r===`execute`&&a}}function Zh(e,t,n){if(!Ph(t))return e;let r=e.map(e=>{let r=e.parts.map(e=>e.type!==`tool-PlanWrite`||e.toolCallId!==t||!e.input||typeof e.input!=`object`?e:{...e,input:{...e.input,approved:n.selectedIds?.[0]===`execute`||n.selectedIds?.[0]===`stay`,pendingDecision:!1,executing:n.selectedIds?.[0]===`execute`,presentation:Xh(e.input,n)}});return r.some((t,n)=>t!==e.parts[n])?{...e,parts:r}:e});return r.some((t,n)=>t!==e[n])?r:e}function Qh(e,t){let n=e.map(e=>{let n=e.parts.map(e=>{if(e.type!==`tool-PlanWrite`||typeof e.toolCallId!=`string`||!e.input||typeof e.input!=`object`)return e;let n=e.input;return n.pendingDecision!==!0||typeof n.onExecute==`function`&&typeof n.onStay==`function`&&typeof n.onRefine==`function`?e:{...e,input:{...n,onExecute:()=>t({toolCallId:e.toolCallId,answer:{kind:`single`,selectedIds:[`execute`]}}),onStay:()=>t({toolCallId:e.toolCallId,answer:{kind:`single`,selectedIds:[`stay`]}}),onRefine:n=>t({toolCallId:e.toolCallId,answer:n&&n.trim().length>0?{kind:`text`,text:n.trim()}:{kind:`single`,selectedIds:[`refine`]}})}}});return n.some((t,n)=>t!==e.parts[n])?{...e,parts:n}:e});return n.some((t,n)=>t!==e[n])?n:e}function $h(e,t){let{client:n=vp,initialSessionMetadata:r,persistSession:i,projectId:a}=t,[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(`ready`),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(()=>r),[m,h]=(0,X.useState)([]),[g,_]=(0,X.useState)(),[v,y]=(0,X.useState)(),[b,x]=(0,X.useState)(gm),[S,C]=(0,X.useState)(()=>({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]})),w=(0,X.useRef)(r),T=(0,X.useRef)(a),E=(0,X.useRef)(o),D=(0,X.useRef)(f),O=(0,X.useRef)(g),k=(0,X.useRef)(v),A=(0,X.useRef)(b),j=(0,X.useRef)(0),M=(0,X.useRef)(null),N=(0,X.useRef)(S),P=(0,X.useRef)(null),F=(0,X.useRef)(new Map),I=(0,X.useRef)(null),L=(0,X.useRef)(0),ee=(0,X.useRef)(c),te=(0,X.useRef)(!1),R=(0,X.useRef)(()=>Promise.resolve(!1)),z=(0,X.useCallback)(e=>{let t=typeof e==`function`?e(E.current):e;E.current=t,s(t)},[]),B=(0,X.useCallback)(e=>{z(t=>[...t,{id:crypto.randomUUID(),role:`assistant`,source:`local`,createdAt:Date.now(),parts:[{type:`text`,text:e}]}])},[z]),V=(0,X.useCallback)(e=>{let t=D.current,n=_m(e);(t.sessionId!==n.sessionId||t.projectId!==n.projectId)&&(j.current+=1,D.current=n,p(n),i(n))},[i]),H=(0,X.useCallback)(e=>{O.current=e,_(e)},[]),U=(0,X.useCallback)(e=>{k.current=e,y(e)},[]),W=(0,X.useCallback)(e=>{j.current+=1,A.current=e,x(e)},[]),ne=(0,X.useCallback)(()=>{j.current+=1},[]),G=(0,X.useCallback)(e=>{N.current=e,C(e)},[]),re=(0,X.useCallback)(async e=>{let t=D.current.sessionId;if(!t)return;let r=await n.upsertOpenUIArtifact({sessionId:t,...e});return D.current.sessionId===t&&G(r.presentation),r.artifact.id},[n,G]);(0,X.useEffect)(()=>{T.current=a},[a]);let ie=(0,X.useCallback)(async()=>{let e=I.current;if(e)return e;let t=n.listSessions().then(e=>(h(e),e));I.current=t;try{return await t}finally{I.current===t&&(I.current=null)}},[n]),ae=(0,X.useCallback)(e=>Vh({client:n,projectId:e??T.current,refreshSessions:ie,setActivityLabelSynced:H,setError:d,setMessagesSynced:z,setPlanLabelSynced:U,setPresentationSynced:G,setQueueSynced:W,setSessionMetadataSynced:V,setStatus:l}),[n,ie,H,z,U,G,W,V]),oe=(0,X.useCallback)(async({toolCallId:e,answer:t})=>{if(Ph(e)){let r=Zh(E.current,e,t);z(r);let i=Bh(r,e);i&&D.current.sessionId&&await n.upsertPlanPresentation({sessionId:D.current.sessionId,presentation:i}).catch(()=>void 0);let a=t.selectedIds?.[0];if(a===`execute`){await R.current({text:`Execute the approved plan.`,mode:`agent`,planAction:`execute`,openUI:!0});let t=Bh(E.current,e);t&&D.current.sessionId&&await n.upsertPlanPresentation({sessionId:D.current.sessionId,presentation:{...t,state:{...t.state,executing:!1}}}).catch(()=>void 0),t&&z(t=>t.map(t=>t.role===`assistant`?{...t,parts:t.parts.map(t=>{if(t.type!==`tool-PlanWrite`||t.toolCallId!==e||!t.input||typeof t.input!=`object`)return t;let n=t.input,r=n.presentation;return!r||typeof r!=`object`?t:{...t,input:{...n,executing:!1,presentation:{...r,executing:!1}}}})}:t))}else(a===`refine`||t.text?.trim())&&await R.current({text:t.text?.trim()||`Refine the plan.`,mode:`plan`,planAction:`refine`,openUI:!0});return{ok:!0}}let r=await n.answerQuestion({sessionId:D.current.sessionId,toolCallId:e,answer:t});return r.message&&await R.current({text:r.message,planAction:r.planAction}),r},[n,z]),se=(0,X.useCallback)(e=>Qh(e,oe),[oe]);(0,X.useEffect)(()=>{D.current=f},[f]),(0,X.useEffect)(()=>{ee.current=c},[c]),(0,X.useEffect)(()=>{w.current=r},[r]),(0,X.useEffect)(()=>{let e=F.current;return()=>{P.current?.abort(),P.current=null;for(let t of e.values())t.abort();e.clear()}},[]),Gh({client:n,initialSessionMetadataRef:w,initializedRef:te,recoverFromForbiddenSession:ae,refreshSessions:ie,setActivityLabelSynced:H,setError:d,setMessagesSynced:z,setPlanLabelSynced:U,setPresentationSynced:G,setQueueSynced:W,setSessionMetadataSynced:V,setStatus:l});let{resetStreamAdmission:ce,sendMessage:le,setAdapterCapabilities:ue}=Yh({activityLabelRef:O,client:n,messagesRef:E,presentationRef:N,model:e,pendingSendControllerRef:P,projectId:a,planLabelRef:k,queueRef:A,recoverFromForbiddenSession:ae,refreshSessions:ie,sessionMetadataRef:D,setActivityLabelSynced:H,setError:d,setMessagesSynced:z,setPresentationSynced:G,setPlanLabelSynced:U,setQueueSynced:W,setSessionMetadataSynced:V,setStatus:l,streamControllersRef:F,status:c}),de=(0,X.useCallback)(()=>{let e=D.current;ce(e.sessionId),P.current?.abort(),P.current=null,e.sessionId&&n.abortSession(e).catch(()=>void 0),e.sessionId&&(F.current.get(e.sessionId)?.abort(),F.current.delete(e.sessionId)),ne(),l(`ready`),W(gm),H(void 0)},[n,ne,ce,H,W]),fe=(0,X.useCallback)((e,t,r,i,a)=>{let o=D.current.sessionId,s=j.current,c=(e===`steering`?A.current.steering:A.current.followUp).filter(e=>e===r).length,l=(M.current??Promise.resolve()).catch(()=>void 0).then(async()=>{if(!o||D.current.sessionId!==o)return!1;let l=e=>(!e&&a?.staleMessage&&bd(Error(a.staleMessage)),!1),u=A.current,d=e===`steering`?u.steering:u.followUp,f;if(j.current===s)f=d[t]===r?t:void 0;else{if(c!==1)return l(!0);let e=d.reduce((e,t,n)=>(t===r&&e.push(n),e),[]);f=e.length===1?e[0]:void 0}if(f===void 0)return l(j.current!==s);let p=i.type===`delete`?{...u,[e]:d.filter((e,t)=>t!==f)}:{...u,[e]:d.map((e,t)=>t===f?i.text:e)};W(p);let m=j.current;try{let t=await n.mutateQueuedMessage({sessionId:o,lane:e,index:f,expectedText:r,mutation:i});return D.current.sessionId!==o||j.current!==m||W(t.queue),t.status===`applied`}catch(e){throw D.current.sessionId===o&&j.current===m&&A.current===p&&W(u),e}});return M.current=l.then(()=>void 0,()=>void 0),l},[n,W]),pe=(0,X.useCallback)((e,t,n)=>fe(e,t,n,{type:`delete`},{staleMessage:`The queued message changed before it could be deleted.`}),[fe]),me=(0,X.useCallback)((e,t,n,r)=>fe(e,t,n,{type:`replace`,text:r,lane:e},{staleMessage:`The queued message changed before it could be updated.`}),[fe]),he=(0,X.useCallback)(async e=>{e?.preserveRunning===!1?de():(ne(),l(`ready`));let t=await n.createSession(e?.projectId??T.current??a);V(t.session),z([]),G(t.presentation),W(gm),H(void 0),U(void 0),oi.success(`New session started`),await ie()},[n,ie,H,z,G,U,W,V,ne,de,a]),ge=(0,X.useCallback)(async(e,t)=>{let r=L.current+1;L.current=r;let i=()=>L.current===r;ne();try{t?.preserveRunning===!1&&de();let r=await n.resumeSession(e);return!(!i()||(V(r.session),z(zh(r.messages,r.planPresentations)),G(r.presentation),W(gm),H(r.sessionReset?`Started a fresh Pi session`:void 0),U(void 0),l(F.current.has(r.session.sessionId??``)?`streaming`:`ready`),await ie(),!i()))}catch(t){if(!i())return!1;let n={setError:d,setStatus:l},r=()=>ae(e.projectId),a=await Uh(t,r,n)||await Wh(t,r,n);if(!i()||a)return!1;let o=t instanceof Error?t:Error(String(t));return d(o),l(`error`),bd(o),!1}},[n,ae,ie,H,z,G,U,W,V,ne,de]),_e=(0,X.useCallback)(async(e,t)=>t?ge({sessionId:t,projectId:e},{preserveRunning:!0}):(ne(),V({projectId:e}),z([]),G({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]}),W(gm),H(void 0),U(void 0),l(`ready`),!0),[ge,H,z,U,G,W,V,ne]);(0,X.useEffect)(()=>{R.current=le},[le]),Kh({client:n,presentationRef:N,sessionId:f.sessionId,sessionMetadataRef:D,setActivityLabelSynced:H,setAdapterCapabilities:ue,setMessagesSynced:z,setPresentationSynced:G,setQueueSynced:W,setSessionMetadataSynced:V,statusRef:ee});let ve=(0,X.useMemo)(()=>se(o),[o,se]),ye=(0,X.useCallback)(async(e,t)=>{try{return await n.renameSession(e,t),await ie(),!0}catch(e){return bd(e),!1}},[n,ie]),be=(0,X.useCallback)(async e=>{let t=D.current.sessionId===e;t&&de();try{await n.deleteSession(e)}catch(e){return bd(e),!1}return t&&(V({}),z([]),G({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]})),await ie(),!0},[n,ie,z,G,V,de]),xe=oe,Se=(0,X.useCallback)(()=>D.current,[]);return{activityLabel:g,answerQuestion:xe,appendLocalMessage:B,deleteQueuedMessage:pe,editQueuedMessage:me,deleteSession:be,error:u,getMessages:(0,X.useCallback)(()=>E.current,[]),getSessionMetadata:Se,messages:ve,planLabel:v,presentation:S,persistOpenUIArtifact:re,queue:b,renameSession:ye,refreshSessions:ie,resumeSession:ge,sendMessage:le,sessionMetadata:f,sessions:m,setError:d,startNewSession:he,status:c,stop:de,switchProject:_e}}function eg({activityLabel:e,artifactRuns:t,chatMode:n,handleThemePreferenceChange:r,isLoadingMcp:i,isLoadingProviders:a,isUpdatingMcp:o,isUpdatingProvider:s,loadSession:c,loadSubagentSession:l,loadWorkspaceFile:u,messages:d,onOpenSubagentTab:f,modelKey:p,models:m,modelCatalog:h,onDiscoverModels:g,onMcpOAuth:_,onOAuthLogin:v,onRemoveMcp:y,onRemoveProvider:b,onUpdateMcp:x,onUpdateProvider:S,openWorkspacePath:C,planLabel:w,presentation:T,mcpConnections:E,providers:D,queue:O,refreshResources:k,refreshWorkspace:A,resources:j,resourcesError:M,resourcesLoading:N,rightPanel:P,reopenRightPanel:F,saveSettings:I,selectedArtifactId:L,sessionId:ee,selectedWorkspacePath:te,setRightPanel:R,setSelectedWorkspacePath:z,settings:B,settingsError:V,settingsLoading:H,status:U,thinkingLevel:W,themePreference:ne,workspaceError:G,workspaceLoading:re,workspaceTree:ie}){let ae=(0,X.useMemo)(()=>({activityLabel:e,artifactRuns:t,chatMode:n,loadSession:c,loadSubagentSession:l,messages:d,onOpenSubagentTab:f,models:m,planLabel:w,presentation:T,queue:O,refreshResources:k,resources:j,resourcesError:M,resourcesLoading:N,reopenRightPanel:F,rightPanel:P,selectedModelKey:p,selectedArtifactId:L,sessionId:ee,setRightPanel:R,status:U,thinkingLevel:W}),[e,t,n,c,l,d,f,m,w,T,O,k,j,M,N,F,P,p,L,ee,R,U,W]),oe=(0,X.useMemo)(()=>({loadWorkspaceFile:u,openWorkspacePath:C,refreshWorkspace:A,selectedWorkspacePath:te,setSelectedWorkspacePath:z,workspaceError:G,workspaceLoading:re,workspaceTree:ie}),[u,C,A,te,z,G,re,ie]);return{chatPanelData:ae,settingsActions:(0,X.useMemo)(()=>({isLoadingMcp:i,isLoadingProviders:a,isUpdatingMcp:o,isUpdatingProvider:s,mcpConnections:E,modelCatalog:h,onDiscoverModels:g,onMcpOAuth:_,onOAuthLogin:v,onRemoveMcp:y,onRemoveProvider:b,onThemePreferenceChange:r,onUpdateMcp:x,onUpdateProvider:S,providers:D,saveSettings:I,settings:B,settingsError:V,settingsLoading:H,themePreference:ne}),[r,i,a,o,s,E,h,g,_,v,y,b,x,S,D,I,B,V,H,ne]),workspaceTreeContext:oe}}var tg=`workspace:`;function ng(e,t=[]){for(let n of e)t.push(n),n.children&&ng(n.children,t);return t}function rg(e){return e?ng(e.nodes).map(e=>({id:`${tg}${e.path}`,label:e.path,description:e.type===`directory`?`Folder`:`Workspace file`,keywords:[e.name,e.path],metadata:{kind:e.type===`directory`?`folder`:`file`}})):[]}function ig(e){if(!e.id.startsWith(tg))return null;let t=e.id.slice(10);if(!t)return null;let n=_i.safeParse(t);return n.success?n.data:null}var ag=15e3;async function og(e,t,n){let r=typeof AbortSignal.timeout==`function`?AbortSignal.timeout(ag):void 0,i=n&&r&&typeof AbortSignal.any==`function`?AbortSignal.any([n,r]):n??r;return vp.getWorkspaceFile(e,t,i)}function sg(e,t){return e.sessionId!==t.sessionId||e.projectId!==t.projectId}function cg(e,t){return!!e.sessionId||t!==void 0&&t!==e.projectId}function lg(e,t){let{defaultProvider:n,defaultModel:r}=t.effective;return e.find(e=>e.provider===n&&e.modelId===r)?.id??(n&&r?`${n}/${r}`:void 0)}function ug(){let e=mp(),[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(void 0),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(`agent`),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)([]),[h,g]=(0,X.useState)(null),_=Km(),[v,y]=(0,X.useState)(_.sessionMetadata.projectId??void 0);(0,X.useEffect)(()=>{},[e]);let{data:b,isLoading:x}=Pp(),{data:S,isLoading:C}=Ap(),{data:w,refetch:T}=Sp(),{mutateAsync:E,isPending:D}=Fp(),{mutateAsync:O}=Ip(),{mutateAsync:k,isPending:A}=Lp(),{mutateAsync:j,isPending:M}=jp(),{mutateAsync:N,isPending:P}=Mp(),{mutateAsync:F}=Np(),{data:I}=xp(v),{data:L}=Cp({enabled:t,projectId:v}),ee=wp(),{commandPaletteOpen:te,handleResourceCanvasResizeStart:R,handleThemePreferenceChange:z,initialSessionMetadata:B,modelKey:V,modelSelection:H,models:U,openArtifact:W,openWorkspacePath:ne,openPanelAction:G,persistSession:re,reopenRightPanel:ie,resourceCanvasWidth:ae,rightPanel:oe,selectedArtifactId:se,selectedWorkspacePath:ce,setCommandPaletteOpen:le,setModelKey:ue,setRightPanel:de,setSelectedWorkspacePath:fe,setThinkingLevel:pe,themePreference:me,thinkingLevel:he}=Wm(I,_);(0,X.useEffect)(()=>{if(B.projectId&&B.projectId!==v){y(B.projectId);return}!v&&w?.projects[0]&&(y(w.projects[0].projectId),re({projectId:w.projects[0].projectId}))},[v,B.projectId,re,w?.projects]);let{data:ge,isLoading:_e,error:ve,refetch:ye}=Tp(v),{data:be}=Ep(v),{data:xe,isLoading:Se,error:Ce}=Dp(v),we=Op(),{data:Te,isLoading:Ee,error:De,refetch:K}=kp(v,{enabled:oe===`workspace`||oe===`resources`}),Oe=ge??null,ke=Te??null,Ae=(0,X.useCallback)(()=>{ye()},[ye]),je=(0,X.useCallback)(async e=>{let t=await we.mutateAsync({request:{settings:e},projectId:v}),n=lg(U,t);return n&&ue(n),t},[v,U,ue,we]),Me=(0,X.useCallback)(()=>{K()},[K]),{activityLabel:Ne,answerQuestion:Pe,appendLocalMessage:Fe,deleteQueuedMessage:Ie,editQueuedMessage:Le,deleteSession:Re,error:ze,getMessages:Be,getSessionMetadata:Ve,messages:He,planLabel:Ue,persistOpenUIArtifact:We,presentation:Ge,queue:Ke,renameSession:qe,resumeSession:Je,sendMessage:Ye,sessionMetadata:Xe,sessions:Ze,startNewSession:Qe,switchProject:$e,status:et,stop:tt}=$h(H,{initialSessionMetadata:B,projectId:v,persistSession:re}),nt=(0,X.useMemo)(()=>ui(He,Ge,et),[He,Ge,et]),rt=(0,X.useRef)(void 0);(0,X.useEffect)(()=>{if(!Ge.thinkingLevel)return;let e=`${Xe.sessionId}:${Ge.thinkingLevel}`;rt.current!==e&&(rt.current=e,pe(Ge.thinkingLevel))},[Ge.thinkingLevel,Xe.sessionId,pe]);let it=(0,X.useCallback)(()=>{f([]),m([])},[]),at=(0,X.useRef)(null),ot=(0,X.useCallback)(async e=>{let t=`${e?.projectId??``}::${e?.preserveRunning??``}`,n=at.current;if(n&&n.key===t)return n.promise;let r=(async()=>{let t=Ve(),n=e?.projectId??v,r=cg({...t,projectId:t.projectId??v},n);return await Qe(e),r&&it(),Ve()})().finally(()=>{at.current?.promise===r&&(at.current=null)});return at.current={key:t,promise:r},r},[v,it,Ve,Qe]),st=(0,X.useCallback)(async(e,t)=>{let n=e.projectId===void 0&&v?{...e,projectId:v}:e,r=sg(Ve(),n),i=await Je(n,t);return i&&r&&it(),i},[v,it,Ve,Je]),ct=(0,X.useCallback)(async(e,t)=>{await st(e,t)},[st]),lt=(0,X.useCallback)(async e=>{let t=Ze.filter(t=>t.projectId===e).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))[0],n=sg(Ve(),{sessionId:t?.sessionId,projectId:e});y(e),fe(null),await $e(e,t?.sessionId)&&n&&it(),await T()},[it,Ve,T,fe,Ze,$e]),ut=(0,X.useCallback)(async e=>{y(e),fe(null),await ot({projectId:e}),await T()},[T,fe,ot]),dt=(0,X.useCallback)(async e=>{let t=Ve().sessionId===e;await Re(e)&&t&&it()},[it,Re,Ve]),ft=(0,X.useCallback)(async e=>{let t=await vp.createProject(e);await T(),await lt(t.projectId)},[T,lt]),pt=(0,X.useCallback)(async(e,t)=>{await vp.renameProject(e,t),await T()},[T]),mt=(0,X.useCallback)(async e=>{await vp.unregisterProject(e);let t=await T();if(v===e){let n=t.data?.projects.find(t=>t.projectId!==e);n?await lt(n.projectId):(y(void 0),fe(null),await $e(``,void 0)&&it())}},[v,it,T,lt,fe,$e]),ht=(0,X.useCallback)(e=>vp.browseProjectDirectories(e),[]),gt=(0,X.useCallback)(async(e,t)=>{await vp.forkSessionIntoProject(e,t),await T()},[T]);(0,X.useEffect)(()=>{Xe.sessionId&&T()},[T,Xe.sessionId]),Xe.sessionId;let _t=kr(Ke)??Ne??Ue,vt=(0,X.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`image/*,text/*,application/json,application/pdf`,e.onchange=()=>{(async()=>{let t=Array.from(e.files??[]);if(t.length===0)return;let n=Ve().sessionId??(await ot()).sessionId;if(!n)throw Error(`Unable to create a session for attachments`);let r=await vp.uploadAttachments(n,t);f(e=>[...e,...r])})().catch(e=>{bd(e)})},e.click()},[Ve,ot]),yt=(0,X.useCallback)(e=>{f(t=>t.filter(t=>t.attachmentId!==e))},[]),bt=(0,X.useCallback)(()=>f([]),[]),xt=(0,X.useCallback)(()=>m([]),[]),St=(0,X.useCallback)((e,t)=>{e.length>0&&f(t=>[...e,...t]),t.length>0&&m(e=>[...t,...e])},[]),Ct=(0,X.useCallback)(e=>{let t=ig(e);t&&m(e=>e.some(e=>e.relativePath===t)?e:[...e,{kind:`workspace`,relativePath:t,name:t.split(`/`).pop()||t}])},[]),wt=(0,X.useCallback)(e=>{m(t=>t.filter(t=>t.relativePath!==e))},[]),Tt=(0,X.useCallback)(({toolCallId:e,answer:t})=>{Pe({toolCallId:e,answer:t}).catch(e=>{bd(e)})},[Pe]),Et=xh({messages:He,answerQuestion:Tt}),Dt=Qm({messages:He,resources:Oe,workspaceTree:ke}),Ot=(0,X.useMemo)(()=>{if(He.length===0||et===`streaming`||et===`submitted`)return!1;let e=He[He.length-1];return e.role===`assistant`&&!zp(e)},[He,et]),kt=(0,X.useMemo)(()=>Ot?Dt:[],[Ot,Dt]),At=(0,X.useMemo)(()=>Zp(Oe,xe?.effective.enableSkillCommands??!1,be),[be,Oe,xe]),jt=(0,X.useMemo)(()=>rg(ke),[ke]),Mt=(0,X.useCallback)(e=>{if(e.projectId&&e.projectId!==v){oi.error(`This panel action targets a different project.`);return}G(e)},[v,G]),Nt=(0,X.useCallback)(e=>{if(!e.projectId||e.projectId===v){G(e);return}lt(e.projectId).then(()=>G(e)).catch(e=>bd(e))},[v,G,lt]),Pt=(0,X.useCallback)(e=>{i(e),n(!0)},[]),{forkFromEntry:Ft,handleLocalSlashSubmit:It,handleSlashCommandSelect:Lt}=bh({appendLocalMessage:Fe,getMessages:Be,getSessionMetadata:Ve,modelKey:V,models:U,onForkPicker:g,onOpenUIRequest:(0,X.useCallback)(async e=>{let t=[...p,...d];bt(),xt(),await Ye({text:e,altKey:!1,mode:l,openUI:!0,openUIArtifact:!0,attachments:t})||St(d,p)},[l,bt,xt,St,Ye,d,p]),openSettings:Pt,resumeSession:ct,sessions:Ze,setEffortPickerOpen:c,setModelKey:ue,setModelPickerOpen:o,setThinkingLevel:pe,startNewSession:ot}),Rt=(0,X.useMemo)(()=>L?.models.map(Tr)??U,[L,U]),zt=(0,X.useCallback)((e,t)=>og(e,v,t),[v]),Bt=(0,X.useCallback)(e=>vp.loadSession(e),[]),Vt=(0,X.useCallback)((e,t)=>vp.loadSubagentSession(e,t),[]),Ht=Mm({activeProjectId:v,loadSubagentSession:Vt,presentation:Ge,rootSessionId:Xe.sessionId}),Ut=(0,X.useCallback)(async e=>(await ee.mutateAsync(e)).models.map(Tr),[ee]),{chatPanelData:Wt,settingsActions:Gt,workspaceTreeContext:Kt}=eg({activityLabel:Ne,artifactRuns:nt,chatMode:l,handleThemePreferenceChange:z,isLoadingMcp:C,isLoadingProviders:x,isUpdatingMcp:M||P,isUpdatingProvider:D||A,loadSession:Bt,loadSubagentSession:Vt,loadWorkspaceFile:zt,messages:He,onOpenSubagentTab:Ht.openChildTab,modelKey:V,models:U,modelCatalog:Rt,onDiscoverModels:Ut,onMcpOAuth:F,onOAuthLogin:O,onRemoveMcp:N,onRemoveProvider:k,onUpdateMcp:j,onUpdateProvider:E,openWorkspacePath:ne,planLabel:Ue,presentation:Ge,mcpConnections:S?.connections??[],providers:b?.providers??[],queue:Ke,refreshResources:Ae,refreshWorkspace:Me,resources:Oe,resourcesError:ve,resourcesLoading:_e,reopenRightPanel:ie,rightPanel:oe,saveSettings:je,selectedArtifactId:se,sessionId:Xe.sessionId,selectedWorkspacePath:ce,setRightPanel:de,setSelectedWorkspacePath:fe,settings:xe??null,settingsError:Ce,settingsLoading:Se||we.isPending,status:et,thinkingLevel:he,themePreference:me,workspaceError:De,workspaceLoading:Ee,workspaceTree:ke}),qt=ch({activeTabId:Ht.activeTabId,tabs:Ht.tabs,onCloseTab:Ht.closeTab,onNewSession:()=>xd(()=>ot()),onSelectTab:Ht.selectTab,onOpenSettings:()=>Pt()});return{session:{activeSessionId:Xe.sessionId,activeProjectId:v,openPanelAction:Nt,projects:w?.projects??[],projectSessions:Ze,sessions:Ze,browseProjectDirectories:ht,createProject:ft,deleteSession:dt,forkSessionIntoProject:gt,renameProject:pt,renameSession:qe,resumeSession:ct,selectProject:lt,startNewSession:ot,startNewSessionInProject:ut,unregisterProject:mt},conversation:{activityLabel:Ne,artifactRuns:nt,deleteQueuedMessage:Ie,editQueuedMessage:Le,error:ze,messages:He,openArtifact:W,openPanelAction:Mt,persistOpenUIArtifact:We,presentation:Ge,queue:Ke,sendMessage:Ye,status:et,stop:tt},agentTabs:Ht,composer:{answerQuestion:Pe,chatMode:l,clearUploadedAttachments:bt,clearWorkspaceAttachments:xt,effortPickerOpen:s,handleAttach:vt,handleLocalSlashSubmit:It,handleQuestionAnswer:Tt,handleSlashCommandSelect:Lt,infoDescription:_t,inputSuggestionItems:kt,workspaceReferenceSuggestions:jt,modelKey:V,modelPickerOpen:a,models:U,pendingQuestionBar:Et,removeUploadedAttachment:yt,removeWorkspaceAttachment:wt,addWorkspaceAttachment:Ct,restoreAttachments:St,setChatMode:u,setEffortPickerOpen:c,setModelKey:ue,setModelPickerOpen:o,setThinkingLevel:pe,slashCommands:At,thinkingLevel:he,uploadedAttachments:d,workspaceAttachments:p},panels:{chatPanelData:Wt,handleResourceCanvasResizeStart:R,resourceCanvasWidth:ae,rightPanel:oe,setRightPanel:de,settingsActions:Gt,workspaceTreeContext:Kt},dialogs:{commandPaletteOpen:te,forkFromEntry:Ft,forkPickerEntries:h,setCommandPaletteOpen:le,setForkPickerEntries:g,setSettingsDialogOpen:n,setSettingsInitialTab:i,settingsDialogOpen:t,settingsInitialTab:r},chrome:{handleThemePreferenceChange:z,header:qt,themePreference:me}}}var dg=(0,X.lazy)(()=>ei(async()=>{let{SubagentChatPanel:e}=await import(`./subagent-chat-panel-oeLDPDAK.js`);return{SubagentChatPanel:e}},__vite__mapDeps([87,3,1,88,2,12,4,6,5,23,8,34,25,35,36,32,33,37,7,26,75,76,16,50,89,13,14,69,90,38,28,44,55,42,64,65,66,91,22,24,27,29,30,31,39,40,41,43,17,45,46,47,48,49,51,15,21,52,53,58,82,59,60,92])).then(({SubagentChatPanel:e})=>({default:e})));function fg(){let{session:e,conversation:t,composer:n,panels:r,dialogs:i,chrome:a,agentTabs:o}=ug(),s=(0,X.useCallback)(()=>{i.setCommandPaletteOpen(e=>!e)},[i.setCommandPaletteOpen]),c=(0,X.useCallback)(()=>{r.setRightPanel(null),window.requestAnimationFrame(()=>fp())},[r.setRightPanel]);pp({onCommandPaletteToggle:s,onClosePanel:c,rightPanel:r.rightPanel,setRightPanel:r.setRightPanel});let l=e.projects.find(t=>t.projectId===e.activeProjectId)?.name,u=(0,X.useCallback)((e,r)=>{let i=[...n.uploadedAttachments],a=[...n.workspaceAttachments],o=[...a,...i];n.clearUploadedAttachments(),n.clearWorkspaceAttachments(),(async()=>{try{await t.sendMessage({text:e,altKey:r,mode:n.chatMode,openUI:!0,attachments:o})||n.restoreAttachments(i,a)}catch(e){n.restoreAttachments(i,a),bd(e)}})()},[n.chatMode,n.clearUploadedAttachments,n.clearWorkspaceAttachments,n.restoreAttachments,n.uploadedAttachments,n.workspaceAttachments,t.sendMessage]),d=(0,X.useCallback)(e=>{let r=Ti(e);if(r){t.openPanelAction(r);return}t.sendMessage({text:e,altKey:!1,mode:n.chatMode,openUI:!0})},[n.chatMode,t.openPanelAction,t.sendMessage]),f=(0,X.useCallback)(async e=>{try{return await t.persistOpenUIArtifact(e)}catch(e){oi.error(`Artifact persistence failed: ${e instanceof Error?e.message:String(e)}`);return}},[t.persistOpenUIArtifact]),p=o.activeTabId===`main`||!o.selectedChild?(0,Z.jsx)(np,{messages:t.messages,status:t.status,error:t.error??void 0,workspaceName:l,activityLabel:t.activityLabel,presentation:t.presentation,artifactRuns:t.artifactRuns,queue:t.queue,onDeleteQueuedMessage:t.deleteQueuedMessage,onEditQueuedMessage:t.editQueuedMessage,onOpenArtifact:t.openArtifact,onOpenUIArtifactReady:f,inputSuggestionItems:n.inputSuggestionItems,suppressQuestionTool:!!n.pendingQuestionBar,inputBar:Sd(n,e.activeSessionId),onSend:u,onOpenUIAction:d,onStop:t.stop,onQuestionAnswer:n.handleQuestionAnswer}):(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`flex min-h-32 flex-1 items-center justify-center text-xs text-foreground/45`,children:`Loading subagent thread…`}),children:(0,Z.jsx)(dg,{child:o.selectedChild,parentSessionId:e.activeSessionId,state:o.conversation})});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(op,{chrome:a,conversation:t,dialogs:i,panels:r,session:e}),(0,Z.jsxs)(Yi,{chatPanelData:r.chatPanelData,onOpenUIAction:d,settingsActions:r.settingsActions,workspaceTree:r.workspaceTreeContext,children:[(0,Z.jsxs)(ru,{className:`h-svh min-h-0 rounded-none border-0`,sidebarWidth:`17.5rem`,children:[(0,Z.jsx)(nu,{data:{sessions:e.sessions,projects:e.projects,projectSessions:e.projectSessions,activeProjectId:e.activeProjectId,activeSessionId:e.activeSessionId},sessionActions:{onNewSession:()=>xd(()=>e.startNewSession()),onNewSessionInProject:e.startNewSessionInProject,onResumeSession:t=>void e.resumeSession({sessionId:t.sessionId}),onRenameSession:(t,n)=>void e.renameSession(t,n),onDeleteSession:t=>void e.deleteSession(t)},projectActions:{onProjectSelect:e.selectProject,onCreateProject:e.createProject,onRenameProject:e.renameProject,onUnregisterProject:e.unregisterProject,onForkSessionIntoProject:e.forkSessionIntoProject},navigationActions:{onOpenPanelAction:e.openPanelAction,onBrowseDirectories:e.browseProjectDirectories,onOpenSettings:()=>i.setSettingsDialogOpen(!0)},slots:{accountMenu:a.header.accountMenu}}),(0,Z.jsx)(rl,{className:`h-svh min-h-0 overflow-hidden`,children:(0,Z.jsx)(jo,{headerLeft:a.header.left,headerCenter:a.header.center,headerRight:a.header.right,panel:(0,Z.jsx)(Ui,{children:(0,Z.jsx)(Ts,{handleResourceCanvasResizeStart:r.handleResourceCanvasResizeStart,onClose:c,resourceCanvasWidth:r.resourceCanvasWidth})}),children:(0,Z.jsx)(`div`,{"aria-labelledby":Oo(o.activeTabId),className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-testid":`agent-tab-panel`,id:ko(o.activeTabId),role:`tabpanel`,children:p})})})]}),(0,Z.jsx)(sp,{dialogs:i})]})]})}var pg=fg;export{pg as component};