@qredence/fleet 0.5.10 → 0.5.11

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 (103) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/web/client/assets/agent-activity-CwMDU7aP.js +1 -0
  3. package/dist/web/client/assets/artifacts-panel-CQmFEF_H.js +1 -0
  4. package/dist/web/client/assets/{chat-command-palette-DfYSPPXI.js → chat-command-palette-CmHTS3rs.js} +1 -1
  5. package/dist/web/client/assets/{chat-C8XDWWXz.js → chat-yh02zgA7.js} +1 -1
  6. package/dist/web/client/assets/{citations-BQ_pr_9_.js → citations-C_tPOJE_.js} +1 -1
  7. package/dist/web/client/assets/{fleet-message-queue-zWM5-y18.js → fleet-message-queue-DUz6Hfrf.js} +1 -1
  8. package/dist/web/client/assets/{fleet-pi-tool-renderer-AJoMbXBa.js → fleet-pi-tool-renderer-BEDIO3al.js} +4 -4
  9. package/dist/web/client/assets/fleet-reasoning-panel-CbkO7u-v.js +1 -0
  10. package/dist/web/client/assets/{fleet-subagent-list-BnRnrWKS.js → fleet-subagent-list-iKUtLJKZ.js} +1 -1
  11. package/dist/web/client/assets/fleet-tool-timeline-C8heL7ae.js +1 -0
  12. package/dist/web/client/assets/{fork-picker-dialog-CkcSekBl.js → fork-picker-dialog-ByBOGVsa.js} +1 -1
  13. package/dist/web/client/assets/globals-B_I1Eq1u.css +2 -0
  14. package/dist/web/client/assets/horizontal-resize-qK6eRhIG.js +1 -0
  15. package/dist/web/client/assets/{index-DlnHLDpx.js → index-C1zOjrMK.js} +3 -3
  16. package/dist/web/client/assets/{ipython-tool-BrMePqD-.js → ipython-tool-ldJ9F1Cw.js} +1 -1
  17. package/dist/web/client/assets/model-selector-list-DsKTuAgS.js +1 -0
  18. package/dist/web/client/assets/{openui-renderer-DwYFJdbe.js → openui-renderer-J3dhPpL4.js} +5 -5
  19. package/dist/web/client/assets/prompt-input-qPIXZ-Rb.js +1 -0
  20. package/dist/web/client/assets/prompt-suggestions-Cc--lSNR.js +1 -0
  21. package/dist/web/client/assets/{provider-label-BCJh04J5.js → provider-label-Dpr7djG9.js} +1 -1
  22. package/dist/web/client/assets/repl-panel-DsPX04Xr.js +1 -0
  23. package/dist/web/client/assets/{resources-panel-Bo8dfUdm.js → resources-panel-D867-goy.js} +1 -1
  24. package/dist/web/client/assets/right-panel-registry-DewpBWHM.js +2 -0
  25. package/dist/web/client/assets/routes-vNkVToAF.js +16 -0
  26. package/dist/web/client/assets/safe-storage-s25GrfpH.js +1 -0
  27. package/dist/web/client/assets/session-insights-panel-YnaXvTpi.js +1 -0
  28. package/dist/web/client/assets/settings-dialog-B-v4me3Y.js +1 -0
  29. package/dist/web/client/assets/skeleton-loaders-C9vHwAYV.js +1 -0
  30. package/dist/web/client/assets/{subagent-chat-panel-DseoO31p.js → subagent-chat-panel-DkVUumrP.js} +1 -1
  31. package/dist/web/client/assets/subagent-transcript-D8wmQxXe.js +1 -0
  32. package/dist/web/client/assets/subagents-panel-BMp2Ego0.js +1 -0
  33. package/dist/web/client/assets/{surfaces-cW-gp56p.js → surfaces-DI-U-_2a.js} +1 -1
  34. package/dist/web/client/assets/tool-result-DfnPN0FQ.js +4 -0
  35. package/dist/web/client/assets/ui-preferences-CImQGZm_.js +1 -0
  36. package/dist/web/client/assets/virtualized-turn-list-DMJENRY0.js +6 -0
  37. package/dist/web/client/assets/{workspace-panel-DI1W3ce9.js → workspace-panel-G6yMpKJ8.js} +1 -1
  38. package/dist/web/client/bundle-budget.json +6 -6
  39. package/dist/web/server/{_tanstack-start-manifest_v-Cdx6hy2i-I7A5YJRU.js → _tanstack-start-manifest_v-po4woX6g-AUGCOEZ2.js} +14 -13
  40. package/dist/web/server/{agent-activity-B-JMvecd-SLE3GGY2.js → agent-activity-CS2rbF_C-A3R26CYH.js} +2 -2
  41. package/dist/web/server/{artifacts-panel-DLMK1O8P-42T45JMA.js → artifacts-panel-8GGUCtOd-X5TNKTY2.js} +12 -12
  42. package/dist/web/server/{chat-command-palette-CdYwoTMe-4LBAZF7K.js → chat-command-palette-Dgl5tqWn-72LLEWUD.js} +2 -2
  43. package/dist/web/server/{chunk-K5ESTT4A.js → chunk-7MDZVLIY.js} +11 -3
  44. package/dist/web/server/{chunk-EBCYJSBR.js → chunk-7SD2ZSEA.js} +3 -3
  45. package/dist/web/server/{chunk-M564UIEY.js → chunk-ABBWBBSS.js} +8 -8
  46. package/dist/web/server/{chunk-KNJUSMBT.js → chunk-BXWAUTTH.js} +2 -2
  47. package/dist/web/server/{chunk-54II5QXQ.js → chunk-ETTDO4UO.js} +6 -3
  48. package/dist/web/server/{chunk-EHNIN245.js → chunk-GETSIVNU.js} +5 -5
  49. package/dist/web/server/{chunk-NRDG2ISJ.js → chunk-GGT2ZKDB.js} +49 -49
  50. package/dist/web/server/{chunk-X2R5YPQZ.js → chunk-IJPCV6DH.js} +3 -2
  51. package/dist/web/server/{chunk-AJJ2S5FF.js → chunk-JQDLJ7KI.js} +20 -20
  52. package/dist/web/server/{chunk-VHBFU4TG.js → chunk-JUROEEWM.js} +43 -14
  53. package/dist/web/server/{chunk-TCH3U26B.js → chunk-MIW4LJTV.js} +2 -2
  54. package/dist/web/server/{chunk-2TRF62K5.js → chunk-N6NOTURM.js} +3 -3
  55. package/dist/web/server/{chunk-5XX7RKJ6.js → chunk-NXJ32VFR.js} +5 -5
  56. package/dist/web/server/{chunk-EOVMHQ2H.js → chunk-O4OTWWPF.js} +7 -7
  57. package/dist/web/server/{chunk-OB5OSYJK.js → chunk-RNOJACWQ.js} +53 -29
  58. package/dist/web/server/chunk-SZJUXVWG.js +40 -0
  59. package/dist/web/server/{chunk-6AW2XFTZ.js → chunk-WILCIZYU.js} +194 -10
  60. package/dist/web/server/{chunk-FED63ZHU.js → chunk-WKV2Z4KO.js} +10 -5
  61. package/dist/web/server/{chunk-ANL4B775.js → chunk-XLNCWZMZ.js} +2 -2
  62. package/dist/web/server/{chunk-GM32R7JW.js → chunk-YKVGQBZA.js} +10 -8
  63. package/dist/web/server/{chunk-3PIUR75R.js → chunk-YXXRP3NS.js} +9 -9
  64. package/dist/web/server/{fleet-message-queue-BxycG26e-2XLOTCLP.js → fleet-message-queue-j0DCU5Xy-5HKBHMPV.js} +2 -2
  65. package/dist/web/server/{fleet-pi-tool-renderer-RIeVlM9J-D6MISCQC.js → fleet-pi-tool-renderer-umKunT3K-O4GBH35V.js} +5 -5
  66. package/dist/web/server/{fleet-reasoning-panel-D_K48UOT-GN2PA6KT.js → fleet-reasoning-panel-BxC2COxi-GPLMQSTT.js} +9 -9
  67. package/dist/web/server/{fleet-subagent-list-5luKtpds-3OTVFHJQ.js → fleet-subagent-list-CpSYzCIq-JDH2LHSS.js} +1 -1
  68. package/dist/web/server/{fleet-tool-timeline-DwRqQgOj-HUFLGMDV.js → fleet-tool-timeline-IB36_PB2-XJENTO6I.js} +1 -1
  69. package/dist/web/server/{fork-picker-dialog-B9yGc8Au-IL63F2DN.js → fork-picker-dialog-DlINz9UQ-UWIXFDJX.js} +3 -3
  70. package/dist/web/server/{model-selector-list-cb2-ewoA-KIVU6LD3.js → model-selector-list-OYnzNbyu-HBGCNF2L.js} +5 -5
  71. package/dist/web/server/{openui-renderer-Czy5Vo2L-BLXPJD65.js → openui-renderer-Cj7kfqyL-EKJ6JTTQ.js} +4 -4
  72. package/dist/web/server/{prompt-suggestions-BOmHi4-J-C563CHFU.js → prompt-suggestions-D4AEEY7K-RZSP7PWV.js} +3 -3
  73. package/dist/web/server/{repl-panel-yyxhwe4c-7U6HXYPS.js → repl-panel-D5KsoJik-BQKO53JO.js} +9 -9
  74. package/dist/web/server/{resources-panel-j4fAIi9g-5C267IXV.js → resources-panel-CE5pD4vy-V5FXBTYC.js} +2 -2
  75. package/dist/web/server/{router-CgSWrAYc-5UBYSZTJ.js → router-Ci1wxI7I-E2AYMNON.js} +253 -76
  76. package/dist/web/server/{routes-CP_BBhD0-BAWQYGKY.js → routes-CRpm9-Sa-IYK6MUJO.js} +705 -537
  77. package/dist/web/server/server.js +2 -2
  78. package/dist/web/server/{session-insights-panel-BHZyKDTo-LRMAMA3O.js → session-insights-panel-CUhdgvRt-VB2HUCQP.js} +4 -4
  79. package/dist/web/server/{settings-dialog-CxHe8nym-KKXDPTIW.js → settings-dialog-BvkgNflv-GPJ6COQO.js} +14 -10
  80. package/dist/web/server/{subagent-chat-panel-DlSsM59d-DBW7DI3T.js → subagent-chat-panel-CMuvW9Sd-M5TEEGQW.js} +11 -11
  81. package/dist/web/server/{subagents-panel-Txzk8oDb-NRKLASYN.js → subagents-panel-DgfB6_Yy-4INEPE3Y.js} +13 -13
  82. package/dist/web/server/{workspace-panel-BOs-58Cv-SWQBMZSB.js → workspace-panel-bpwj-Veu-Q2CEJMN4.js} +4 -3
  83. package/package.json +1 -1
  84. package/dist/web/client/assets/agent-activity-CDcDNVC6.js +0 -1
  85. package/dist/web/client/assets/artifacts-panel-CObI-DMt.js +0 -1
  86. package/dist/web/client/assets/fleet-reasoning-panel-MtbSdoCv.js +0 -1
  87. package/dist/web/client/assets/fleet-tool-timeline-COzPrwr8.js +0 -1
  88. package/dist/web/client/assets/generative-text-renderer-CDKHv-v_.js +0 -6
  89. package/dist/web/client/assets/globals-DisQPFtV.css +0 -2
  90. package/dist/web/client/assets/horizontal-resize-Bl3AyBJg.js +0 -1
  91. package/dist/web/client/assets/model-selector-list-DQaPFUYt.js +0 -1
  92. package/dist/web/client/assets/prompt-input-DZ4cho_e.js +0 -1
  93. package/dist/web/client/assets/prompt-suggestions-CXM6knMK.js +0 -1
  94. package/dist/web/client/assets/repl-panel-BDQ5MEgV.js +0 -1
  95. package/dist/web/client/assets/right-panel-registry-VVRPktV3.js +0 -2
  96. package/dist/web/client/assets/routes-DAikUNzO.js +0 -16
  97. package/dist/web/client/assets/session-insights-panel-CQdT90Op.js +0 -1
  98. package/dist/web/client/assets/settings-dialog-DS64KmwC.js +0 -1
  99. package/dist/web/client/assets/skeleton-loaders-DjGv9LLA.js +0 -1
  100. package/dist/web/client/assets/subagent-transcript-cxVKYnh9.js +0 -1
  101. package/dist/web/client/assets/subagents-panel-CHC96I68.js +0 -1
  102. package/dist/web/client/assets/tool-result-Baj3CdL_.js +0 -4
  103. package/dist/web/client/assets/ui-preferences-DUEFuJFj.js +0 -1
@@ -1,16 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/model-selector-list-DQaPFUYt.js","assets/rolldown-runtime-hePW80VL.js","assets/bundle-mjs-DKHVkVWu.js","assets/jsx-runtime-NZYk81nU.js","assets/ease-u56MhKYS.js","assets/layout-gyLzPvVv.js","assets/utils-Eg7xtNmV.js","assets/check-JjHKAZas.js","assets/createLucideIcon-DwxZHm0M.js","assets/gauge-DNpstbBn.js","assets/command-DPfiaYUL.js","assets/dialog-BEZuZhzk.js","assets/react-dom-Bwxum3ti.js","assets/button-BR2WWrFo.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-BFDsCVS9.js","assets/input-0wwjWjKq.js","assets/useControlled-CJJ9BOQB.js","assets/fleet-pi-tool-renderer-AJoMbXBa.js","assets/use-reduced-motion-eORd7fqW.js","assets/tool-result-Baj3CdL_.js","assets/chevron-down-BEVGmnSb.js","assets/loader-circle-DjfHXUPB.js","assets/circle-x-CkKCB__4.js","assets/action-swap-roll-BB8DFMuf.js","assets/rotate-ccw-WNFNkKQD.js","assets/square-terminal-BYTN_I86.js","assets/wrench-BJNNe07k.js","assets/preload-helper-Czpn1I53.js","assets/agent-disclosure-B8SnhQXL.js","assets/citations-BQ_pr_9_.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-BrMePqD-.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/workspace-path-nav-C0AQNZyy.js","assets/collapsible-BoXtZZWN.js","assets/surfaces-cW-gp56p.js","assets/range-BWOHiLNe.js","assets/agent-activity-CDcDNVC6.js","assets/image-BbPmlw-n.js","assets/message-square-hbDao-A1.js","assets/fleet-reasoning-panel-MtbSdoCv.js","assets/fleet-tool-timeline-COzPrwr8.js","assets/fleet-subagent-list-BnRnrWKS.js","assets/subagent-utils-DDH5qm9Z.js","assets/prompt-suggestions-CXM6knMK.js","assets/fleet-message-queue-zWM5-y18.js","assets/notify-DgMKgZZW.js","assets/toast-Bt9p2OL4.js","assets/triangle-alert-CU-gd7ui.js","assets/chat-command-palette-DfYSPPXI.js","assets/right-panel-registry-VVRPktV3.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-DS64KmwC.js","assets/provider-catalog-D8G66gwc.js","assets/provider-label-BCJh04J5.js","assets/plug-Dt6VN0zF.js","assets/hard-drive-CHqgr7VQ.js","assets/refresh-cw-IThTJ3j-.js","assets/ui-preferences-DUEFuJFj.js","assets/switch-9rTeg6J6.js","assets/fork-picker-dialog-CkcSekBl.js","assets/subagent-chat-panel-DseoO31p.js","assets/prompt-input-DZ4cho_e.js","assets/subagent-transcript-cxVKYnh9.js","assets/generative-text-renderer-CDKHv-v_.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{D as i,E as a,F as o,M as s,O as c,P as l,d as u,g as d,h as f,j as p,k as m,l as h,m as g,o as _,p as v,s as y,v as b,w as x,x as S}from"./analytics-stub-Cas1He0w.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 R,p as z,r as B,t as V,v as H,x as U,z as W}from"./button-BR2WWrFo.js";import{$ as G,C as ee,I as te,K as ne,L as re,M as ie,N as ae,P as oe,U as se,V as ce,W as le,X as ue,Y as de,Z as fe,at as pe,ct as me,et as he,h as ge,it as _e,j as ve,m as ye,nt as be,ot as xe,q as Se,rt as Ce,tt as we,y as Te,z as Ee}from"./layout-gyLzPvVv.js";import{d as K,h as De,l as Oe,m as ke,n as Ae,o as je,p as Me,r as Ne,t as Pe,u as Fe}from"./ease-u56MhKYS.js";import{a as Ie,c as Le,i as Re,n as ze,o as Be,r as Ve,s as He,t as Ue}from"./prompt-input-DZ4cho_e.js";import{n as We,t as Ge}from"./use-reduced-motion-eORd7fqW.js";import{C as Ke,K as qe,O as Je,b as Ye,c as Xe,d as Ze,et as Qe,f as $e,h as et,i as tt,j as nt,nt as rt,o as it,ot as at,rt as ot,s as st,st as ct,t as lt,v as ut,w as dt,x as ft}from"./createBaseUIEventDetails-DV0dQrBX.js";import{$ as pt,A as mt,B as ht,C as gt,D as _t,E as vt,F as yt,G as bt,H as xt,I as St,J as Ct,K as wt,L as Tt,M as Et,N as Dt,O as Ot,P as kt,Q as At,R as jt,S 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,w as Zt,x as Qt,y as $t}from"./dialog-BEZuZhzk.js";import{_ as en,b as tn,c as nn,f as rn,g as an,j as on,m as sn,s as cn,u as ln,v as un,x as dn,y as fn}from"./provider-catalog-D8G66gwc.js";import{t as pn}from"./useBaseUiId-CHqXB2UQ.js";import{A as mn,C as hn,D as gn,E as _n,O as vn,S as yn,T as bn,a as xn,c as Sn,d as Cn,f as wn,h as Tn,i as En,l as Dn,m as On,n as kn,o as An,p as jn,s as Mn,t as Nn,u as Pn,x as Fn,y as In}from"./provider-label-BCJh04J5.js";import{t as q}from"./utils-Eg7xtNmV.js";import{t as Ln}from"./createLucideIcon-DwxZHm0M.js";import{n as Rn,r as zn,t as Bn}from"./right-panel-registry-VVRPktV3.js";import{c as Vn,i as Hn,l as Un,n as Wn,o as Gn,s as Kn,t as qn,u as Jn}from"./citations-BQ_pr_9_.js";import{r as Yn}from"./resource-helpers-Q2T0YCMO.js";import{t as Xn}from"./bot-Bs7QWJ2q.js";import{t as Zn}from"./check-JjHKAZas.js";import{t as Qn}from"./chevron-down-BEVGmnSb.js";import{a as $n,c as er,d as tr,f as nr,i as rr,l as ir,n as ar,o as or,r as sr,s as cr,t as lr,u as ur}from"./generative-text-renderer-CDKHv-v_.js";import{t as dr}from"./chevron-right-DrJxToLs.js";import{t as fr}from"./chevron-up-CnSvySGH.js";import{t as pr}from"./circle-alert-CONlFReH.js";import{t as mr}from"./loader-circle-DjfHXUPB.js";import{n as hr,r as gr,t as _r}from"./action-swap-roll-BB8DFMuf.js";import{t as vr}from"./file-text-T-NcAlZs.js";import{a as yr,c as br,d as xr,f as Sr,h as Cr,i as wr,l as Tr,m as Er,n as Dr,r as Or,s as kr,t as Ar,u as jr,v as Mr,y as Nr}from"./horizontal-resize-Bl3AyBJg.js";import{t as Pr}from"./folder-BC5p7qK7.js";import{t as Fr}from"./gauge-DNpstbBn.js";import{t as Ir}from"./package-CdcJFPf2.js";import{t as Lr}from"./plus-DXN1Bg_z.js";import{t as Rr}from"./refresh-cw-IThTJ3j-.js";import{t as zr}from"./rotate-ccw-WNFNkKQD.js";import{t as Br}from"./subagent-utils-DDH5qm9Z.js";import{t as Vr}from"./search-eWVnAJsb.js";import{t as Hr}from"./sparkles-DuclzqlE.js";import{t as Ur}from"./triangle-alert-CU-gd7ui.js";import{t as Wr}from"./x-CsRC_tCI.js";import{t as Gr}from"./preload-helper-Czpn1I53.js";import"./cn-C8c0S2mI.js";import{t as Kr}from"./notify-DgMKgZZW.js";import{n as qr}from"./workspace-path-nav-C0AQNZyy.js";import{t as Jr}from"./useControlled-CJJ9BOQB.js";import{t as Yr}from"./agent-disclosure-B8SnhQXL.js";import{a as Xr,i as Zr,o as Qr,s as $r}from"./surfaces-cW-gp56p.js";import{t as ei}from"./prime-agent-artifacts-C-g1VPiW.js";import{A as ti,C as ni,D as ri,E as ii,F as ai,I as oi,J as si,L as ci,M as li,O as ui,P as J,R as di,S as fi,T as pi,V as Y,_ as mi,a as hi,c as gi,d as _i,f as vi,g as yi,h as bi,i as xi,j as Si,l as Ci,m as wi,n as Ti,o as Ei,p as Di,q as Oi,r as ki,s as Ai,t as ji,u as Mi,v as Ni,w as Pi,y as Fi,z as X}from"./chat-C8XDWWXz.js";import{i as Ii,n as Li,t as Ri}from"./right-panel-context-DHlNWJsF.js";import{t as zi}from"./input-0wwjWjKq.js";import{t as Bi}from"./artifacts-utils-N_kUFbz2.js";var Vi=class extends f{#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),Ui(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Wi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wi(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 i(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&&!c(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Gi(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||i(this.options.enabled,this.#t)!==i(t.enabled,this.#t)||i(this.options.staleTime,this.#t)!==i(t.staleTime,this.#t))&&this.#g();let a=this.#_();r&&(this.#t!==n||i(this.options.enabled,this.#t)!==i(t.enabled,this.#t)||a!==this.#f)&&this.#v(a)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return c(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(x)),t}#h(e){return!d()&&i(this.options.enabled,this.#t)!==!1&&S(e)}#g(){this.#b();let e=i(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=p(this.#r.dataUpdatedAt,e)+1;this.#u=s.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=s.setInterval(()=>{(this.options.refetchIntervalInBackground||g.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(s.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(s.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,o=this.#r,s=this.#i,c=this.#a,l=e===n?this.#n:e.state,{state:d}=e,f={...d},p=!1,m;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Ui(e,t),o=i&&Gi(e,n,t,r);(a||o)&&(f={...f,...u(d.data,e.options)}),t._optimisticResults===`isRestoring`&&(f.fetchStatus=`idle`)}let{error:h,errorUpdatedAt:g,status:_}=f;m=f.data;let v=!1;if(t.placeholderData!==void 0&&m===void 0&&_===`pending`){let e;o?.isPlaceholderData&&t.placeholderData===c?.placeholderData?(e=o.data,v=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(_=`success`,m=a(o?.data,e,t),p=!0)}if(t.select&&m!==void 0&&!v){if(o&&m===s?.data&&t.select===this.#s)m=this.#c;else try{this.#s=t.select,m=t.select(m),m=a(o?.data,m,t),this.#c=m,this.#o=null}catch(e){this.#o=e}}else m===void 0&&(this.#o=null);this.#o&&(h=this.#o,m=this.#c,g=Date.now(),_=`error`,p=!1);let y=f.fetchStatus===`fetching`,b=_===`pending`,x=_===`error`,S=b&&y,C=m!==void 0;return{status:_,fetchStatus:f.fetchStatus,isPending:b,isSuccess:_===`success`,isError:x,isInitialLoading:S,isLoading:S,data:m,dataUpdatedAt:f.dataUpdatedAt,error:h,errorUpdatedAt:g,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:f.dataUpdateCount>l.dataUpdateCount||f.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!b,isLoadingError:x&&!C,isPaused:f.fetchStatus===`paused`,isPlaceholderData:p,isRefetchError:x&&C,isStale:Ki(e,t),refetch:this.refetch,isEnabled:i(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),c(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)})})();v.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 Hi(e,t){return i(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||i(t.retryOnMount,e)!==!1)}function Ui(e,t){return Hi(e,t)||e.state.data!==void 0&&Wi(e,t,t.refetchOnMount)}function Wi(e,t,n){if(i(t.enabled,e)!==!1&&i(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ki(e,t)}return!1}function Gi(e,t,n,r){return(e!==t||i(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ki(e,n)}function Ki(e,t){return i(t.enabled,e)!==!1&&e.isStaleByTime(i(t.staleTime,e))}var qi=class extends f{#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),c(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&b(t.mutationKey)!==b(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??h();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){v.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)})})}},Z=e(t(),1),Ji=Z.createContext(!1),Yi=()=>Z.useContext(Ji);Ji.Provider;var Q=r();function Xi(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Zi=Z.createContext(Xi()),Qi=()=>Z.useContext(Zi),$i=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?m(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},ea=e=>{Z.useEffect(()=>{e.clearReset()},[e])},ta=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||m(n,[e.error,r])),na=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))}},ra=(e,t)=>e?.suspense&&t.isPending,ia=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function aa(e,t,n){let r=Yi(),i=Qi(),a=l(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,na(o),$i(o,i,s),ea(i);let[u]=Z.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(Z.useSyncExternalStore(Z.useCallback(e=>{let t=f?u.subscribe(v.batchCalls(e)):x;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Z.useEffect(()=>{u.setOptions(o)},[o,u]),ra(o,d))throw ia(o,u,i);if(ta({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return o.notifyOnChangeProps?d:u.trackResult(d)}function oa(e,t){return aa(e,Vi,t)}function sa(e,t){let n=l(t),[r]=Z.useState(()=>new qi(n,e));Z.useEffect(()=>{r.setOptions(e)},[r,e]);let i=Z.useSyncExternalStore(Z.useCallback(e=>r.subscribe(v.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=Z.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(x)},[r]);if(i.error&&m(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var ca=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function la(e,t){return he(e)?e[ca(0,e.length,t)]:e}var ua=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 da(this.animations,`duration`)}get iterationDuration(){return da(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 da(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 fa=class extends ua{then(e,t){return this.finished.finally(e).then(()=>{})}};function pa(e,t){return e in t}var ma=class extends ee{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(pa(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 ie()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}},ha=e=>!e.isLayoutDirty&&e.willUpdate(!1);function ga(){let e=new Set,t=new WeakMap,n=()=>e.forEach(ha);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 _a=(0,Z.createContext)(null);function va(){let e=(0,Z.useRef)(!1);return ke(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function ya(){let e=va(),[t,n]=(0,Z.useState)(0),r=(0,Z.useCallback)(()=>{e.current&&n(t+1)},[t]);return[(0,Z.useCallback)(()=>G.postRender(r),[r]),t]}var ba=e=>e===!0,xa=e=>ba(e===!0)||e===`id`,Sa=({children:e,id:t,inherit:n=!0})=>{let r=(0,Z.useContext)(me),i=(0,Z.useContext)(_a),[a,o]=ya(),s=(0,Z.useRef)(null),c=r.id||i;s.current===null&&(xa(n)&&c&&(t=t?c+`-`+t:c),s.current={id:t,group:ba(n)&&r.group||ga()});let l=(0,Z.useMemo)(()=>({...s.current,forceRender:a}),[o]);return(0,Q.jsx)(me.Provider,{value:l,children:e})};function Ca({children:e,...t}){let n=(0,Z.useContext)(Me);t={...n,...t},t.transition=ce(t.transition,n.transition),t.isStatic=De(()=>t.isStatic);let r=(0,Z.useMemo)(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion,t.skipAnimations,t.isValidProp]);return(0,Q.jsx)(Me.Provider,{value:r,children:e})}function wa(e){return typeof e==`object`&&!Array.isArray(e)}function Ta(e,t,n,r){return e==null?[]:typeof e==`string`&&wa(t)?te(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(e=>e!=null):[e]}function Ea(e,t,n){return e*(t+1)+n*t}function Da(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 Oa(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.at>t&&i.at<n&&(xe(e,i),r--)}}function ka(e,t,n,r,i,a){Oa(e,i,a);for(let o=0;o<t.length;o++)e.push({value:t[o],at:fe(i,a,r[o]),easing:la(n,o)})}function Aa(e,t,n=0){let r=t+1+t*n;for(let t=0;t<e.length;t++)e[t]=e[t]/r}function ja(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}var Ma=`easeInOut`,Na=20;function Pa(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,Da(d,o.at,u,l));continue}let[p,m,h={}]=o;h.at!==void 0&&(d=Da(d,h.at,u,l));let g=0,_=(e,n,r,o=0,s=0)=>{let c=La(e),{delay:l=0,times:u=ne(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=le(p)?p:i?.[p||`keyframes`];if(S<=2&&C){let e=100;if(S===2&&Ba(c)){let t=c[1]-c[0];e=Math.abs(t)}let n={...t,...v};b!==void 0&&(n.duration=be(b));let r=ue(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&&Se(u,T),c.length===1&&c.unshift(null),m&&pe(m<Na,`Sequence segments can't repeat ${m} times — ignoring repeat option. Use a value below ${Na} or apply repeat at the sequence level instead.`),m&&m<Na){let e=b>0?_/b:0;b=Ea(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`?we(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`:la(f,e-1))}Aa(u,m,e)}let E=w+b;ka(r,c,y,u,w,E),g=Math.max(x+b,g),f=Math.max(E,f)};if(Ee(p)){let e=Fa(p,s);_(m,h,Ia(`default`,e))}else{let e=Ta(p,m,r,c),t=e.length;for(let n=0;n<t;n++){m=m,h=h;let r=e[n],i=Fa(r,s);for(let e in m)_(m[e],Ra(h,e),Ia(e,i),n,t)}}u=d,d+=g}return s.forEach((e,r)=>{for(let i in e){let a=e[i];a.sort(ja);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(Ce(0,f,t)),l.push(r||`easeOut`)}c[0]!==0&&(c.unshift(0),s.unshift(s[0]),l.unshift(Ma)),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 Fa(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function Ia(e,t){return t[e]||(t[e]=[]),t[e]}function La(e){return Array.isArray(e)?e:[e]}function Ra(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}var za=e=>typeof e==`number`,Ba=e=>e.every(za);function Va(e){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=oe(e)&&!ae(e)?new ge(t):new Te(t);n.mount(e),ve.set(e,n)}function Ha(e){let t=new ma({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),ve.set(e,t)}function Ua(e,t){return Ee(e)||typeof e==`number`||typeof e==`string`&&!wa(t)}function Wa(e,t,n,r){let i=[];if(Ua(e,t))i.push(ye(e,wa(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return i;let a=Ta(e,t,r),o=a.length;_e(!!o,`No valid elements provided.`,`no-valid-elements`);for(let e=0;e<o;e++){let r=a[e],s=r instanceof Element?Va:Ha;ve.has(r)||s(r);let c=ve.get(r),l={...n};`delay`in l&&typeof l.delay==`function`&&(l.delay=l.delay(e,o)),i.push(...re(c,{...t,transition:l},{}))}}return i}function Ga(e,t,n){let r=[];return Pa(e.map(e=>{if(Array.isArray(e)&&typeof e[0]==`function`){let t=e[0],n=se(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:de}).forEach(({keyframes:e,transition:t},n)=>{r.push(...Wa(n,e,t))}),r}function Ka(e){return Array.isArray(e)&&e.some(Array.isArray)}function qa(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),Ka(e)){let{onComplete:n,...r}=i||{};typeof n==`function`&&(s=n),o=Ga(e,{...c,...r},t)}else{let{onComplete:n,...r}=a||{};typeof n==`function`&&(s=n),o=Wa(e,i,{...c,...r},t)}let l=new fa(o);return s&&l.finished.then(s),t&&(t.animations.push(l),l.finished.then(()=>{xe(t.animations,l)})),l}return i}var Ja=qa(),Ya=Ln(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Xa=Ln(`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`}]]),Za=Ln(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Qa=Ln(`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`}]]),$a=Ln(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),eo=Ln(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),to=Ln(`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`}]]),no=Ln(`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`}]]),ro=Ln(`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`}]]),io=Ln(`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`}]]),ao=Ln(`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`}]]),oo=Ln(`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`}]]),so=Ln(`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`}]]),co=Ln(`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`}]]),lo=Ln(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),uo=Ln(`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`}]]),fo=Ln(`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`}]]),po=Ln(`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`}]]),mo=Ln(`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`}]]),ho=Ln(`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`}]]),go=Ln(`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`}]]);function _o(e){return`agent-tab-${encodeURIComponent(e)}`}function vo(e){return`agent-tab-panel-${encodeURIComponent(e)}`}function yo(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 bo(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 xo({tabs:e,value:t,onValueChange:n,onClose:r,onNewSession:i}){let a=(0,Z.useRef)(new Map),o=(0,Z.useCallback)((e,t)=>{t?a.current.set(e,t):a.current.delete(e)},[]);(0,Z.useEffect)(()=>{for(let t of a.current.keys())e.some(e=>e.id===t)||a.current.delete(t)},[e]);let s=(0,Z.useCallback)(t=>{let r=e[t];r&&(a.current.get(r.id)?.focus(),n(r.id))},[n,e]),c=(0,Z.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,Q.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-1`,"data-testid":`agent-tab-bar`,children:[(0,Q.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=yo(e.status);return(0,Q.jsxs)(`div`,{className:`group/tab relative min-w-0 shrink-0 basis-[164px] sm:max-w-[164px]`,"data-tab-id":e.id,children:[(0,Q.jsxs)(V,{ref:t=>o(e.id,t),"aria-controls":vo(e.id),"aria-selected":i,"aria-label":`${e.label}, ${a}`,className:q(`h-7 w-full min-w-0 justify-start text-left gap-1.5 rounded-[7px] border border-transparent px-2 text-[12px] font-medium leading-none transition-colors motion-reduce:transition-none`,i?`bg-[#2c2c2c] 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:_o(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,Q.jsx)(Xn,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-1.5 shrink-0 rounded-full`,bo(e.status))}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]}),e.kind===`subagent`&&r?(0,Q.jsx)(V,{"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,Q.jsx)(Wr,{"aria-hidden":`true`,className:`size-3`})}):null]},e.id)})}),i?(0,Q.jsx)(V,{"aria-label":`New chat`,className:`size-7 shrink-0 rounded-[7px] text-foreground/50 hover:bg-foreground/7 hover:text-foreground/85`,"data-testid":`new-chat-tab`,onClick:i,size:`icon-sm`,title:`New chat`,type:`button`,variant:`ghost`,children:(0,Q.jsx)(Lr,{"aria-hidden":`true`,className:`size-3.5`})}):null]})}function So({children:e,dataTestid:t,headerLeading:n,loading:r,onClose:i,onRefresh:a,onResizeStart:o,open:s,headerActions:c,title:l,titleIcon:u,width:d}){let f=Ge(),p=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{s&&p.current?.focus({preventScroll:!0})},[s]),(0,Q.jsx)(y,{features:_,children:(0,Q.jsx)(We,{children:s&&(0,Q.jsxs)(K.aside,{ref:p,initial:!f&&{x:d,opacity:.8},animate:{x:0,opacity:1},exit:f?{opacity:0}:{x:d,opacity:.8},transition:f?{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:d},tabIndex:-1,role:`dialog`,"aria-label":l,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())},children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Resize ${l} 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,Q.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.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,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:n??(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px] font-medium text-foreground/80`,children:[(0,Q.jsx)(u,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:l})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[c,(0,Q.jsx)(V,{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 ${l}`,title:`Refresh ${l}`,children:(0,Q.jsx)(Rr,{"data-icon":`inline-start`,className:`size-3.5 ${r?`animate-spin`:``}`})}),(0,Q.jsx)(V,{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,Q.jsx)(Wr,{"data-icon":`inline-start`,className:`size-3.5`})})]})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:e})]})]})})})}var Co=Z.createContext(void 0);function wo(){let e=Z.useContext(Co);if(e===void 0)throw Error(rt(64));return e}var To={tabActivationDirection:e=>({"data-activation-direction":e})},Eo=Z.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=Z.useRef([]),[f,p]=Z.useState(()=>new Map),[m,h]=Jr({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=Z.useState(()=>new Map),y=Z.useRef(void 0),b=Z.useCallback(e=>Do(_,e),[_]),[x,S]=Z.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:C,tabActivationDirection:w}=x,T=w,E=!1;C!==m&&(T=Oo(C,m,a,_),E=C!=null&&m!=null&&b(m)==null);let D=E?C:m,O=C!==D||w!==T;ot(()=>{O&&S({previousValue:D,tabActivationDirection:T})},[D,O,T]);let k=Qe((e,t)=>{t.activationDirection=Oo(m,e,a,_),i?.(e,t),!t.isCanceled&&h(e)}),A=Qe((e,t)=>{i?.(e,lt(t,void 0,void 0,{activationDirection:`none`}))}),j=Qe((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=Z.useCallback(e=>f.get(e),[f]),N=Z.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),P=Z.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=Z.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),I=Z.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),L=Z.useRef(!u),R=Z.useRef(r),z=Z.useRef(u),B=Z.useRef(!1);ot(()=>{if(g)return;function e(e,t){h(e),S({previousValue:e,tabActivationDirection:`none`}),A(e,t),L.current=!1}if(_.size===0){B.current&&m!==null&&!y.current?.isConnected&&e(null,Ze);return}B.current=!0,y.current=_.keys().next().value;let t=F?.disabled,n=F==null&&m!==null;if(!t&&m===R.current&&(z.current=!1),z.current&&t&&m===R.current)return;let r=L.current;if(t||n){let n=I??null;if(m===n){L.current=!1;return}let i=Ze;r?i=Xe:t&&(i=tt),e(n,i);return}r&&F!=null&&(A(m,Xe),L.current=!1)},[I,g,A,F,h,_,m]);let V=Je(`div`,e,{state:{orientation:a,tabActivationDirection:T},ref:t,props:l,stateAttributesMapping:To});return(0,Q.jsx)(Co.Provider,{value:P,children:(0,Q.jsx)(en,{elementsRef:d,children:V})})});function Do(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function Oo(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=Do(r,e),c=Do(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 ko=`data-composite-item-active`;function Ao(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ft(),{ref:i,index:a}=an(e),o=n===a,s=Z.useRef(null),c=nt(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 jo=Z.createContext(void 0);function Mo(){let e=Z.useContext(jo);if(e===void 0)throw Error(rt(65));return e}var No=Z.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}=wo(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=Mo(),{highlightedIndex:v,onHighlightedIndexChange:y}=ft(),b=pn(o),{compositeProps:x,compositeRef:S,index:C}=Ao({metadata:Z.useMemo(()=>({disabled:r,id:b,value:a}),[r,b,a])}),T=a===u,E=Z.useRef(!1),D=Z.useRef(null),O=Qe(e=>{D.current?.(),D.current=e?g(e):null});ot(()=>{if(E.current){E.current=!1;return}if(!(T&&C>-1&&v!==C))return;let e=_;if(e!=null){let t=W(N(e));if(t&&w(e,t))return}r||y(C)},[T,C,v,y,r,_]);let{getButtonProps:k,buttonRef:A}=ut({disabled:r,native:s,focusableWhenDisabled:!0}),j=d(a),M=Z.useRef(!1),P=Z.useRef(!1);function F(e){f(a,lt($e,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 R(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 Je(`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:R,[ko]:T?``:void 0,onKeyDownCapture(){E.current=!0}},l,k],stateAttributesMapping:To})}),Po=[];function Fo(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=Po}=e,[p,m]=Z.useState(0),h=r!=null,g=Z.useRef(null),_=nt(g,c),v=Z.useRef([]),y=Z.useRef(!1),b=o??p,x=Qe((e,t=!1)=>{if((s??m)(e),t){let t=v.current[e];Ot(g.current,t,a,n)}}),S=Qe(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)}Ot(g.current,r,a,n)});ot(()=>{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=Qe((e,t,n)=>i?i(e,t,n,v):n),D=Qe(e=>{let o=e.key===`Home`||e.key===`End`;if(!Zt.has(e.key)||!l&&o||Io(e,f)||!g.current)return;let s=a===`rtl`,c=s?Qt:Mt,p=s?Mt:Qt,m=n===`vertical`?Bt:c,_=n===`vertical`?gt:p,y=A(e.nativeEvent);if(y!=null&&_t(y)&&!sn(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||!_t(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:b,onHighlightedIndexChange:x,elementsRef:v,onMapChange:S,relayKeyboardEvent:D}}function Io(e,t){for(let n of vt)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Lo(e){let{render:t,className:n,style:r,refs:i=at,props:a=at,state:o=ct,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}=Fo({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:dn(),disabledIndices:v,modifierKeys:y}),k=Je(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=Z.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,Q.jsx)(Ye.Provider,{value:A,children:(0,Q.jsx)(en,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var Ro=Z.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}=wo(),[d,f]=Z.useState(0),[p,m]=Z.useState(null),h=Z.useRef(new Set),g=Z.useRef(new Set),_=Z.useRef(null);ot(()=>{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=Qe(e=>(h.current.add(e),()=>{h.current.delete(e)})),y=Qe(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=Z.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:y,tabsListElement:p}),[n,v,y,p]);return(0,Q.jsx)(jo.Provider,{value:S,children:(0,Q.jsx)(Lo,{render:a,className:r,style:o,state:b,refs:[t,m],props:[x,s],stateAttributesMapping:To,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:at})})});function zo({className:e,orientation:t=`horizontal`,...n}){return(0,Q.jsx)(Eo,{"data-slot":`tabs`,"data-orientation":t,className:q(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Bo=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 Vo({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(Ro,{"data-slot":`tabs-list`,"data-variant":t,className:q(Bo({variant:t}),e),...n})}function Ho({className:e,...t}){return(0,Q.jsx)(No,{"data-slot":`tabs-trigger`,className:q(`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 Uo(e,t={}){let{axis:n=`y`}=t,r=(0,Z.useRef)(new Map),i=(0,Z.useRef)(new Map),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)([]),l=(0,Z.useRef)([]),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.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,Z.useCallback)(()=>{d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null,f()})},[f]),m=(0,Z.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,Z.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,Z.useCallback)(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),o(null)},[]);return(0,Z.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,Z.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 Wo={normal:`'wght' 400, 'opsz' 14`,medium:`'wght' 450, 'opsz' 15`,semibold:`'wght' 550, 'opsz' 20`,bold:`'wght' 700, 'opsz' 25`},Go={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}}},Ko=`bg-background shadow-sm`,qo=`rounded-full border border-border/70 bg-sidebar p-0.5 shadow-sm backdrop-blur`,Jo=`rounded-full`;function Yo(e,t){return t?e?`text-foreground/75`:`text-foreground`:e?`text-foreground/55`:`text-muted-foreground`}var Xo=(0,Z.createContext)(null);function Zo(){let e=(0,Z.useContext)(Xo);if(!e)throw Error(`useTabsSubtle must be used within a TabsSubtle`);return e}function Qo({selectedRect:e,hoverRect:t,focusRect:n,isHovering:r,isHoveringSelected:i}){let a=Ge()?{duration:0}:void 0;return(0,Q.jsxs)(y,{features:_,children:[e?(0,Q.jsx)(K.div,{className:q(`pointer-events-none absolute`,Ko,Jo),layout:!0,initial:!1,style:{left:e.left,top:e.top,width:e.width,height:e.height},animate:{opacity:r?.8:1},transition:a??{...Go.moderate.enter,opacity:{duration:.08}}}):null,(0,Q.jsx)(We,{children:t&&!i?(0,Q.jsx)(K.div,{className:q(`pointer-events-none absolute`,Ko,Jo),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??Go.fast.exit},transition:a??{...Go.fast.enter,opacity:{duration:.08}}}):null}),(0,Q.jsx)(We,{children:n?(0,Q.jsx)(K.div,{className:q(`pointer-events-none absolute z-20 border border-ring`,Jo),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??Go.fast.exit},transition:a??{...Go.fast.enter,opacity:{duration:.08}}}):null})]})}var $o=(0,Z.forwardRef)(({children:e,selectedIndex:t,onSelect:n,idPrefix:r,activeLabel:i=!1,variant:a=`default`,className:o,...s},c)=>{let l=(0,Z.useRef)(null),u=(0,Z.useRef)(!1),d=a===`pill`,{activeIndex:f,setActiveIndex:p,itemRects:m,onMouseMove:h,onMouseLeave:g,registerItem:_}=Uo(l,{axis:`x`}),v=(0,Z.useCallback)((e,t)=>{_(e,t)},[_]),y=(0,Z.useCallback)(e=>{u.current=!0,h(e)},[h]),b=(0,Z.useCallback)(()=>{u.current=!1,g()},[g]),[x,S]=(0,Z.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,Z.useMemo)(()=>({registerTab:v,hoveredIndex:f,selectedIndex:t,idPrefix:r,activeLabel:i,variant:a,onSelect:n}),[v,f,t,r,i,a,n]);return(0,Q.jsx)(Xo.Provider,{value:O,children:(0,Q.jsx)(zo,{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,Q.jsxs)(Vo,{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:q(`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?qo:`-mx-1 -my-1 px-1 py-1`,o),...s,children:[(0,Q.jsx)(Qo,{selectedRect:C,hoverRect:w,focusRect:T,isHovering:D,isHoveringSelected:E}),e]})})})});$o.displayName=`TabsSubtle`;var es=(0,Z.forwardRef)(({icon:e,label:t,index:n,badge:r,className:i,"aria-label":a,onClick:o,...s},c)=>{let l=(0,Z.useRef)(null),{registerTab:u,hoveredIndex:d,selectedIndex:f,idPrefix:p,activeLabel:m,variant:h,onSelect:g}=Zo();(0,Z.useEffect)(()=>(u(n,l.current),()=>u(n,null)),[n,u]);let v=f===n,b=d===n||v,x=m&&!!e,S=!x||v,C=h===`pill`,w=Yo(C,b),T=a??(x&&!S?t:void 0),E=(0,Q.jsxs)(`span`,{className:q(`inline-grid whitespace-nowrap`,C?`text-[12px] font-medium`:`text-[13px]`),children:[(0,Q.jsx)(`span`,{className:`invisible col-start-1 row-start-1 [text-box:trim-both_cap_alphabetic]`,style:{fontVariationSettings:Wo.semibold},"aria-hidden":`true`,children:t}),(0,Q.jsx)(`span`,{className:q(`col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]`,w),style:{fontVariationSettings:v?Wo.semibold:Wo.normal},children:t})]});return(0,Q.jsxs)(Ho,{ref:e=>{let t=e;l.current=t,typeof c==`function`?c(t):c&&(c.current=t)},value:n,"data-proximity-index":n,id:p?`${p}-tab-${n}`:void 0,"aria-controls":p?`${p}-panel-${n}`:void 0,"aria-label":T,className:q(`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`,Jo,i),...s,onClick:e=>{o?.(e),v&&g(n)},children:[e?(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(e,{"data-icon":`inline-start`,size:C?14:16,strokeWidth:b?2:1.5,className:q(`shrink-0 transition-[color,stroke-width] duration-80`,w)}),r===void 0?null:(0,Q.jsx)(`span`,{className:q(`text-[11px] tabular-nums transition-colors duration-80`,w),children:r})]}):null,x?null:E,(0,Q.jsx)(y,{features:_,children:(0,Q.jsx)(We,{initial:!1,children:x&&S?(0,Q.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:{...Go.fast.enter,opacity:{duration:.06}},children:E},`label`):null})})]})});es.displayName=`TabsSubtleItem`;var ts=(0,Z.forwardRef)(({index:e,selectedIndex:t,idPrefix:n,children:r,className:i,...a},o)=>{let s=t===e;return(0,Q.jsx)(`div`,{ref:o,id:`${n}-panel-${e}`,role:`tabpanel`,"aria-labelledby":`${n}-tab-${e}`,hidden:!s,tabIndex:-1,className:q(`outline-none`,i),...a,children:s?r:null})});ts.displayName=`TabsSubtlePanel`;function ns({active:e=!1,ariaLabel:t,className:n,title:r,...i}){return(0,Q.jsx)(V,{...i,type:`button`,variant:`ghost`,size:`sm`,className:q(On,e?jn:Tn,n),"aria-label":t,title:r??t})}var rs=`[&_[data-proximity-index]]:!h-7 [&_[data-proximity-index]]:!px-2 [&_[data-proximity-index]]:!text-[11px]`;function is({compact:e=!1}={}){let{reopenRightPanel:t,rightPanel:n}=Li();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`min-[960px]:hidden`,children:(0,Q.jsx)(as,{compact:e,idPrefix:`right-panel-mobile`})}),(0,Q.jsx)(`div`,{className:`hidden min-[960px]:block`,children:n===null?(0,Q.jsx)(os,{compact:e,onOpen:t}):null})]})}function as({compact:e=!1,idPrefix:t=`right-panel`}){let{artifactRuns:n,messages:r,rightPanel:i,setRightPanel:a,resources:o}=Li(),{workspaceTree:s}=Ii();return(0,Q.jsx)(ss,{activePanel:i,onPanelChange:a,resources:o,replRuns:n.flatMap(e=>e.artifacts).filter(e=>e.kind===`ipython`).length,sessionBlocks:Bi(r).length,openUIArtifacts:n.flatMap(e=>e.artifacts).filter(e=>e.kind===`openui-html`).length,workspace:s,idPrefix:t,compact:e})}function os({compact:e=!1,onOpen:t}){return(0,Q.jsx)(ns,{ariaLabel:`Open side panel`,className:e?`!size-7 !rounded-[7px] !px-0`:`size-9 justify-center px-0`,onClick:t,children:(0,Q.jsx)(lo,{className:`size-4`})})}function ss({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=Yn(n,o).reduce((e,t)=>e+t.items.length,0),u=(0,Z.useMemo)(()=>{let e=i+a;return e>0?e:void 0},[a,i]),d=(0,Z.useMemo)(()=>Bn.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,Z.useMemo)(()=>d.map(e=>({value:e.id,label:e.title,icon:e.icon})),[d]);return(0,Q.jsx)(cs,{"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 cs({activePanel:e,className:t,compact:n=!1,idPrefix:r,onSelect:i,options:a,panelOptions:o,selectedIndex:s,...c}){let l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),[d,f]=(0,Z.useState)(!1),p=(0,Z.useCallback)(()=>{let e=l.current,t=u.current;if(!e||!t)return;let n=e.parentElement?.clientWidth??e.clientWidth,r=t.getBoundingClientRect().width;f(r>n+1)},[]);(0,Z.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,Z.useCallback)(e=>{let t=o.findIndex(t=>t.id===e);t>=0&&i(t)},[i,o]);return(0,Q.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,Q.jsx)(cn,{"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,Q.jsx)($o,{activeLabel:!0,className:`w-fit max-w-full ${n?rs:``}`,idPrefix:r,selectedIndex:s,onSelect:i,children:o.map((e,t)=>(0,Q.jsx)(es,{index:t,icon:e.icon,label:e.title,badge:e.badge,"aria-label":e.ariaLabel},e.id))}),(0,Q.jsx)(`div`,{ref:u,"aria-hidden":`true`,className:`pointer-events-none invisible absolute top-0 left-0 -z-10 h-0 w-max max-w-none overflow-hidden`,"data-panel-launcher-measurement":!0,inert:!0,children:(0,Q.jsx)($o,{activeLabel:!0,className:`w-max max-w-none ${n?rs:``}`,idPrefix:`${r}-measurement`,selectedIndex:s,onSelect:()=>void 0,children:o.map((e,t)=>(0,Q.jsx)(es,{index:t,icon:e.icon,label:e.title,badge:e.badge,"aria-label":e.ariaLabel},e.id))})})]})}function ls({children:e,dataTestid:t,headerActions:n,icon:r,onClose:i,open:a,title:o}){let s=(0,Z.useRef)(null),c=(0,Z.useId)(),l=(0,Z.useRef)(!1),u=(0,Z.useEffectEvent)(e=>{s.current&&e.target===s.current&&i?.()});return(0,Z.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,Z.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,Q.jsx)(`dialog`,{ref:s,"data-testid":t,className:`fixed top-[var(--chat-chrome-top)] right-3 bottom-3 m-0 ${In} backdrop:bg-black/20 ${Er}`,"aria-labelledby":c,onClose:()=>{if(l.current){l.current=!1;return}i?.()},children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,Q.jsx)(`span`,{id:c,className:`sr-only`,children:o??`Panel`}),o&&(0,Q.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px] font-medium text-foreground/80`,children:[r&&(0,Q.jsx)(r,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:o})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,i&&(0,Q.jsx)(V,{type:`button`,onClick: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,Q.jsx)(Wr,{"data-icon":`inline-start`,className:`size-3.5`})})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-2`,children:e})]})}):null}function us({handleResourceCanvasResizeStart:e,onClose:t,resourceCanvasWidth:n}){let r=Li(),i=Ii(),{rightPanel:a}=r,o=a!==null,s=a?Rn(a):null,c=s?.component,l=s?.loadingSource===`resources`?r.resourcesLoading:s?.loadingSource===`workspace`&&i.workspaceLoading,u=s?.refreshSource===`resources`?r.refreshResources:s?.refreshSource===`workspace`?i.refreshWorkspace:void 0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ls,{dataTestid:s?.mobileDataTestid,icon:s?.icon,onClose:t,open:o,title:s?.title??``,children:c?(0,Q.jsx)(c,{}):null}),(0,Q.jsx)(So,{dataTestid:s?.dataTestid,headerLeading:(0,Q.jsx)(as,{idPrefix:`right-panel-desktop`}),loading:l,onClose:t,onRefresh:u,onResizeStart:e,open:o,title:s?.title??``,titleIcon:s?.icon??zn,width:n,children:c?(0,Q.jsx)(c,{}):null})]})}var ds={"--chat-chrome-top":`52px`,"--chat-header-height":`44px`,"--chat-header-top":`0px`};function fs({children:e,headerCenter:t,headerLeft:n,headerRight:r,panel:i}){return(0,Q.jsxs)(`div`,{className:`flex h-svh min-w-0 overflow-hidden`,"data-testid":`chat-shell`,style:ds,children:[(0,Q.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,"data-testid":`chat-column`,children:[(0,Q.jsxs)(`header`,{className:q(wn,`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-[#2e3033] px-2 py-2`),"data-testid":`chat-header`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 justify-self-start`,children:n}),(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center justify-start gap-1 overflow-hidden justify-self-stretch`,children:t}),(0,Q.jsx)(`div`,{className:`min-w-0 justify-self-end`,children:r})]}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:e})]}),i]})}var ps=e(n(),1),ms=`(max-width: 767px)`,hs=`b`,gs={duration:.36,ease:Pe},_s={type:`spring`,stiffness:380,damping:35,mass:.75},vs={duration:.18,ease:Ne},ys={closed:{opacity:0,clipPath:`inset(0 0 100% 0 round 8px)`,transition:{duration:.14,ease:Ne,staggerChildren:.025,staggerDirection:-1}},open:{opacity:1,clipPath:`inset(0 0 0% 0 round 8px)`,transition:{duration:.2,delayChildren:.035,ease:Ne,staggerChildren:.045}}},bs={closed:{opacity:0,y:-6,filter:`blur(3px)`},open:{opacity:1,y:0,filter:`blur(0px)`,transition:vs}},xs={duration:.16,ease:Ne},Ss=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex='-1'])`].join(`,`);function Cs(e){let t=window.matchMedia(ms);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function ws(){return window.matchMedia(ms).matches}function Ts(){return!1}function Es(){return(0,Z.useSyncExternalStore)(Cs,ws,Ts)}var Ds=(0,Z.createContext)(null),Os=(0,Z.createContext)(null);function ks(){let e=(0,Z.useContext)(Ds);if(!e)throw Error(`useAnimatedSidebar must be used inside AnimatedSidebarProvider.`);return e}function As(){let e=(0,Z.useContext)(Os);if(!e)throw Error(`Animated Sidebar parts must be used inside AnimatedSidebar.`);return e}function js({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,Z.useState)(n),[f,p]=(0,Z.useState)(a),m=Es(),h=Ge()??!1,g=(0,Z.useId)(),_=(0,Z.useRef)(null),v=t??u,y=i??f,b=(0,Z.useCallback)(e=>{t===void 0&&d(e),r?.(e)},[r,t]),x=(0,Z.useCallback)(e=>{i===void 0&&p(e),o?.(e)},[o,i]),S=(0,Z.useCallback)(()=>{m?x(!y):b(!v)},[v,m,y,b,x]),C=(0,Z.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,Z.useEffect)(()=>{let e=e=>{e.key.toLowerCase()===hs&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S]),(0,Q.jsx)(Ds.Provider,{value:C,children:(0,Q.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:q(`group/sidebar-wrapper flex min-h-svh w-full min-w-0`,s),children:e})})}function Ms({ariaLabel:e,children:t,className:n,side:r}){let i=ks(),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(!1),c=(0,Z.useMemo)(()=>({collapsed:!1,collapsible:`none`,side:r}),[r]);return(0,Z.useEffect)(()=>s(!0),[]),(0,Z.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(Ss)??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,ps.createPortal)((0,Q.jsxs)(`div`,{className:q(`pointer-events-none fixed inset-0 z-50 md:hidden`,i.openMobile?`visible`:`invisible`),children:[(0,Q.jsx)(K.button,{type:`button`,"aria-label":`Close sidebar`,tabIndex:i.openMobile?0:-1,initial:!1,animate:{opacity:+!!i.openMobile},transition:i.reduce?xs:gs,onClick:()=>i.setOpenMobile(!1),className:q(`absolute inset-0 bg-black/40`,i.openMobile?`pointer-events-auto`:`pointer-events-none`)}),(0,Q.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?xs:gs,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(Ss)):[];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:q(`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,Q.jsx)(Os.Provider,{value:c,children:t})})]}),document.body):null}var Ns=(0,Z.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=ks(),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,Z.useMemo)(()=>({collapsed:d,collapsible:n,side:e}),[d,n,e]);return u.isMobile?(0,Q.jsx)(Ms,{ariaLabel:r,className:a,side:e,children:i}):(0,Q.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}:_s,layout:`size`,style:{...s,width:m},className:q(`group/sidebar relative hidden h-auto shrink-0 md:block will-change-transform`,`peer`,e===`right`&&`order-last`,a),children:(0,Q.jsx)(K.div,{initial:!1,animate:{opacity:+!f,x:f?e===`left`?`-120%`:`120%`:`0%`},transition:u.reduce?xs:gs,className:q(`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,Q.jsx)(Os.Provider,{value:h,children:i})})})}),Ps=(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=ks(),o=a.isMobile?a.openMobile:a.open;return(0,Q.jsx)(V,{...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:q(`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,e)})});(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=ks();return(0,Q.jsx)(V,{...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:q(`focus-visible:ring-2 focus-visible:ring-ring`,e)})});var Fs=(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=ks(),o=As();return(0,Q.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:q(`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)})}),Is=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(K.main,{...t,ref:n,"data-slot":`sidebar-inset`,className:q(`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)})}),Ls=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-header`,className:q(`flex shrink-0 flex-col gap-2 p-3`,e)})}),Rs=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-content`,className:q(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-2`,e)})}),zs=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-footer`,className:q(`flex shrink-0 flex-col gap-2 border-border border-t p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,e)})}),Bs=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group`,className:q(`flex w-full min-w-0 flex-col px-1 py-1.5`,e)})}),Vs=(0,Z.forwardRef)(function({children:e,className:t,...n},r){let{collapsed:i}=As();return(0,Q.jsx)(`div`,{...n,ref:r,"aria-hidden":i,"data-slot":`sidebar-group-label`,className:q(`mb-1 h-7 overflow-hidden px-2 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-opacity`,i?`opacity-0`:`opacity-100`,t),children:e})}),Hs=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group-content`,className:q(`w-full min-w-0`,e)})});(0,Z.forwardRef)(function({children:e,className:t,...n},r){return(0,Q.jsx)(Sr,{...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:q(`flex w-full min-w-0 list-none flex-col gap-0.5`,t),children:e})}),(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(K.li,{...t,ref:n,layout:`position`,transition:je,"data-slot":`sidebar-menu-item`,className:q(`relative`,e)})}),(0,Z.forwardRef)(function({open:e,children:t,className:n,...r},i){let a=ks(),o=As();return(0,Q.jsx)(We,{initial:!1,mode:`popLayout`,children:e&&!o.collapsed?(0,Z.createElement)(K.ul,{...r,ref:i,key:`sidebar-submenu`,variants:a.reduce?void 0:ys,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:q(`relative mt-1 ml-5 flex min-w-0 flex-col gap-0.5 border-border border-l pl-3`,n)},t):null})}),(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(K.li,{...t,ref:n,variants:bs,"data-slot":`sidebar-menu-sub-item`,className:q(`relative min-w-0`,e)})});function Us({children:e,className:t,sidebarWidth:n=`17rem`,style:r,...i}){return(0,Q.jsx)(js,{...i,style:{...r,"--sidebar-width":n},className:q(`min-h-0 w-full overflow-hidden rounded-2xl border border-border bg-background`,t),children:e})}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 kr(e.title||e.firstMessage||e.sessionId.slice(0,8))}function tc(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 nc(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 rc(e){return e.hasChildren?`${e.name}/`:e.name}function ic(e,t){return e instanceof Error&&e.message.trim()?e.message:t}function ac(e){if(typeof window>`u`)return e?[Xs(e)]:[];let t=window.localStorage.getItem(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 oc(e,t){return t.type===`update`?t.update(e):{...e,[t.field.key]:t.field.value}}function sc(e){let[t,n]=(0,Z.useReducer)(oc,e,e=>({brandMenuOpen:!1,projectActionsOpen:!1,searchOpen:!1,query:``,expandedProjectIds:ac(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,Z.useCallback)(function(e,t){n({type:`set`,field:{key:e,value:t}})},[]),i=(0,Z.useCallback)(function(e,t){n({type:`update`,update:n=>({...n,[e]:t(n[e])})})},[]),a=(0,Z.useCallback)(e=>r(`brandMenuOpen`,e),[r]),o=(0,Z.useCallback)(e=>r(`projectActionsOpen`,e),[r]),s=(0,Z.useCallback)(e=>r(`searchOpen`,e),[r]),c=(0,Z.useCallback)(e=>r(`query`,e),[r]),l=(0,Z.useCallback)(e=>typeof e==`function`?i(`expandedProjectIds`,e):r(`expandedProjectIds`,e),[r,i]),u=(0,Z.useCallback)(e=>typeof e==`function`?i(`revealedProjectIds`,e):r(`revealedProjectIds`,e),[r,i]),d=(0,Z.useCallback)(e=>r(`renameTarget`,e),[r]),f=(0,Z.useCallback)(e=>r(`renameTitle`,e),[r]),p=(0,Z.useCallback)(e=>r(`renameProjectTarget`,e),[r]),m=(0,Z.useCallback)(e=>r(`renameProjectName`,e),[r]),h=(0,Z.useCallback)(e=>r(`deleteTarget`,e),[r]),g=(0,Z.useCallback)(e=>r(`unregisterTarget`,e),[r]),_=(0,Z.useCallback)(e=>r(`createOpen`,e),[r]),v=(0,Z.useCallback)(e=>r(`createPath`,e),[r]),y=(0,Z.useCallback)(e=>r(`createName`,e),[r]),b=(0,Z.useCallback)(e=>r(`directoryToken`,e),[r]),x=(0,Z.useCallback)(e=>r(`directoryBrowser`,e),[r]),S=(0,Z.useCallback)(e=>r(`directoryBrowseLoading`,e),[r]),C=(0,Z.useCallback)(e=>r(`directoryBrowseError`,e),[r]),w=(0,Z.useCallback)(e=>r(`createSubmitting`,e),[r]),T=(0,Z.useCallback)(e=>r(`createSubmitError`,e),[r]),E=(0,Z.useCallback)(e=>r(`forkTarget`,e),[r]),D=(0,Z.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}}function cc(e,t){return e.filter(e=>e.messageCount>0||e.sessionId===t)}function lc(e){return e.toSorted((e,t)=>Date.parse(t.updatedAt)-Date.parse(e.updatedAt))}function uc(e,t,n){let r=lc(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 dc(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})}var fc=[[`resources`,`Open Resources`,zn],[`workspace`,`Open Workspace`,Pr],[`artifacts`,`Open Artifacts`,Ir]];function pc({icon:e,label:t,destructive:n=!1,onClick:r}){return(0,Q.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,Q.jsx)(e,{className:`size-3.5`}),t]})}function mc({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:R}){let z=(0,Z.useRef)(!1),B=(0,Z.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(ic(e,`Could not browse this directory.`)),!1}finally{b(!1)}},[f,C,x,b,y,S]);(0,Z.useEffect)(()=>{let e=p&&!z.current;z.current=p,!(!e||!f)&&B({})},[p,B,f]);let V=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.projectId,e])),[t]),H=(0,Z.useMemo)(()=>dc(t,n),[n,t]);(0,Z.useEffect)(()=>{if(!r)return;let e=Xs(r);g(t=>t.includes(e)?t:[...t,e])},[r,g]),(0,Z.useEffect)(()=>{window.localStorage.setItem(Gs,JSON.stringify(m))},[m]);let U=(0,Z.useMemo)(()=>{let e=H.map(e=>{let t=cc(n.filter(t=>t.projectId===e.projectId),i),r=h.has(e.projectId),a=uc(t,i,r).map(e=>({id:Zs(e.sessionId),label:ec(e),kind:`file`,...e.isSubagent?{indent:1}:{}}));return t.length===0?a.push({id:Qs(e.projectId),label:`Start first chat`,kind:`action`}):t.length>5&&a.push({id:`toggle:${e.projectId}`,label:r?`Show less`:`Show more`,kind:`action`}),{id:Xs(e.projectId),label:e.name,kind:`project`,children:a}}),t=lc(cc(n.filter(e=>!e.projectId),i));if(t.length>0){let n=uc(t,i,h.has(`unassigned`)).map(e=>({id:Zs(e.sessionId),label:ec(e),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,H]),W=(0,Z.useCallback)(e=>{o?o(e):(s?.(e),a())},[a,o,s]);return{loadDirectories:B,projectById:V,sortedProjects:H,sidebarItems:U,resumeResource:(0,Z.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){W(r);return}let i=$s(e,Ys);if(!i)return;let a=n.find(e=>e.sessionId===i);a&&c(a)},[W,c,n,_]),toggleProjectResource:(0,Z.useCallback)(e=>{g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[g]),selectSearchResult:(0,Z.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,Z.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pc,{icon:hn,label:`Rename`,onClick:()=>{r.close(),w(e),T(ec(e))}}),u&&t.length>1?(0,Q.jsx)(pc,{icon:ao,label:`Fork into project`,onClick:()=>{r.close(),E(e),D(t.find(t=>t.projectId!==e.projectId)?.projectId)}}):null,d&&a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 border-t`}),fc.map(([e,t,n])=>(0,Q.jsx)(pc,{icon:n,label:t,onClick:()=>{r.close(),d({panel:e,projectId:a,focus:!0})}},e))]}):null,(0,Q.jsx)(pc,{icon:Fn,label:`Delete`,destructive:!0,onClick:()=>{r.close(),O(e)}})]})}if(a&&a!==`unassigned`){let e=V.get(a);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pc,{icon:hn,label:`Rename project`,onClick:()=>{r.close(),k(e),A(e.name)}}),(0,Q.jsx)(pc,{icon:go,label:`Unregister project`,destructive:!0,onClick:()=>{r.close(),j(e)}}),d?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 border-t`}),fc.map(([e,t,n])=>(0,Q.jsx)(pc,{icon:n,label:t,onClick:()=>{r.close(),d({panel:e,projectId:a,focus:!0})}},e))]}):null]}):null}return null},[u,d,V,n,t,O,D,E,A,k,w,T,j]),submitCreate:async()=>{let e=M.trim();if(!(!l||!e&&!N)){R(!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(ic(e,`Could not add this project.`))}finally{R(!1)}}}}}var hc=Z.createContext(void 0);function gc(e){let t=Z.useContext(hc);if(t===void 0&&!e)throw Error(rt(47));return t}var _c={...yt,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},vc=class extends R{constructor(e,t,n){let r=new St;super(yc(e,r,t,n),bc(r),_c)}setOpen=(e,t)=>{let n=t.reason===et,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=ht(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};xt(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),ps.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function yc(e,t,n,r=!1){let i={...Dt(),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=kt(t,n,r),i}function bc(e){return{popupRef:Z.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Z.createRef(),beforeContentFocusGuardRef:Z.createRef(),stickIfOpenTimeout:new D,triggerElements:e}}function xc({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=Cc(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}),Z.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),Z.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,lt(st))}),[m,u]);let h=d||f;return(0,Q.jsxs)(hc.Provider,{value:u,children:[s&&(0,Q.jsx)(jt,{handle:s,store:u}),h&&(0,Q.jsx)(wc,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function Sc(e){return gc(!0)?(0,Q.jsx)(xc,{props:e}):(0,Q.jsx)(pt,{children:(0,Q.jsx)(xc,{props:e})})}function Cc(e,t){let n=wt((e,n)=>new vc(t,e,n));return Z.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function wc({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 bt(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}function Tc(e,t){let n=Z.useRef(null);function r(t){ps.flushSync(()=>{e.setOpen(!1,lt(it,t.nativeEvent,t.currentTarget))}),U(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&O(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{ps.flushSync(()=>{e.setOpen(!1,lt(it,n.nativeEvent,n.currentTarget))});let i=j(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&w(r,i);){let e=i;if(i=H(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var Ec=Z.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=gc(!0),h=mn(s)??m;if(!h)throw Error(rt(74));let g=pn(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=Z.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Ct(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:_n(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=on(v,{stickIfOpen:T}),A=rn(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:N,buttonRef:P}=ut({disabled:a,native:o}),F={open(e){return e&&w===`trigger-press`?Gt.open(e):Et.open(e)}},{preFocusGuardRef:L,handlePreFocusGuardFocus:R,handleFocusTargetFocus:z}=Tc(h,x),B=Je(`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}),V=(0,Q.jsx)(Z.Fragment,{children:B},g);return C&&!D?(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(I,{ref:L,onFocus:R}),V,(0,Q.jsx)(I,{ref:h.context.triggerFocusTargetRef,onFocus:z})]}):V}),Dc=Z.createContext(void 0);function Oc(){let e=Z.useContext(Dc);if(e===void 0)throw Error(rt(45));return e}var kc=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return gc().useState(`mounted`)||n?(0,Q.jsx)(Dc.Provider,{value:n,children:(0,Q.jsx)(B,{ref:t,...r})}):null}),Ac=Z.createContext(void 0);function jc(){let e=Z.useContext(Ac);if(!e)throw Error(rt(46));return e}var Mc=Z.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=gc(),y=Oc(),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=Z.useRef(null),N=dt(O),F=tn({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`);ot(()=>{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`;ln(C&&L,D===`touch`,O,T);let R=v.useStateSetter(`positionerElement`),B={open:C,side:F.side,align:F.align,anchorHidden:F.anchorHidden,instant:k},V=un(e,B,{styles:F.positionerStyles,transitionStatus:A,props:_,refs:[t,R],hidden:!S,inert:!C});return(0,Q.jsxs)(Ac.Provider,{value:F,children:[S&&L&&(0,Q.jsx)($t,{inert:z(!C),cutout:T}),(0,Q.jsx)(At,{id:b,children:V})]})}),Nc=Z.createContext(void 0);function Pc(){let[e,t]=Z.useState(0),n=Qe(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Z.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Fc=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=gc(),l=jc(),u=nn(!0)!=null,{context:d,hasClosePart:f}=Pc(),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`);Ke({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),vn(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=Je(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Tt,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Zt.has(e.key)&&e.stopPropagation()}},fn(g),s],stateAttributesMapping:mt});return(0,Q.jsx)(Lt,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:qe(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Q.jsx)(Nc.Provider,{value:d,children:N})})}),Ic=2;function Lc({...e}){return(0,Q.jsx)(Sc,{"data-slot":`popover`,...e})}function Rc({...e}){return(0,Q.jsx)(Ec,{"data-slot":`popover-trigger`,...e})}function zc({className:e,children:t,align:n=`center`,alignOffset:r=0,side:i=`bottom`,sideOffset:a=4,...o}){let s=Ht(),c=Math.min(s+Ic,8);return(0,Q.jsx)(kc,{children:(0,Q.jsx)(Mc,{align:n,alignOffset:r,side:i,sideOffset:a,className:`isolate z-50`,children:(0,Q.jsx)(Fc,{"data-slot":`popover-content`,className:q(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg p-2.5 text-sm text-popover-foreground 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),e),...o,children:(0,Q.jsx)(Ut,{value:c,children:t})})})})}function Bc({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,Z.useId)(),f=n??d,[p,m]=(0,Z.useState)(i??!1),h=r??p;return(0,Q.jsxs)(Lc,{open:h,onOpenChange:e=>{r===void 0&&m(e),a?.(e)},children:[(0,Z.isValidElement)(e)?(0,Q.jsx)(Rc,{render:e,"aria-controls":f,className:`inline-flex`}):(0,Q.jsx)(Rc,{render:(0,Q.jsx)(V,{type:`button`,variant:`ghost`,children:e}),"aria-controls":f,className:`inline-flex`}),u&&h?(0,Q.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/20`,"aria-hidden":`true`}):null,(0,Q.jsx)(zc,{id:f,side:o,align:s,sideOffset:c,className:q(`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})]})}function Vc({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,Z.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,Q.jsxs)(`button`,{type:`button`,onClick:()=>{f(e.id),i?.(e.id)},className:q(`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,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.pinned&&(0,Q.jsx)(uo,{className:`text-foreground/30 size-2.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title})]}),(0,Q.jsx)(`span`,{className:`text-foreground/35 truncate text-xs`,children:e.preview})]},e.id);return(0,Q.jsxs)(`div`,{"data-slot":`thread-search`,className:q($r,`flex w-full max-w-sm flex-col gap-1.5 rounded-2xl p-3`,a),...o,children:[(0,Q.jsxs)(`div`,{className:q(Zr,`flex items-center gap-2 rounded-xl px-2.5 py-1.5`),children:[(0,Q.jsx)(Vr,{className:`text-foreground/30 size-3.5 shrink-0`}),(0,Q.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-[13px]`})]}),c.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:q(`font-mono text-[11px] tracking-tight`,`text-foreground/25 px-2 pb-1`),children:`pinned`}),c.map(h)]}),l.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:q(Qr,`text-foreground/25 px-2 pb-1`),children:e}),s.flatMap(t=>!t.pinned&&t.group===e?[h(t)]:[])]},e)),s.length===0&&(0,Q.jsxs)(`span`,{className:`text-foreground/30 px-2 py-4 text-center text-xs`,children:[`No thread matches “`,t,`”`]})]})}function Hc(){try{return`0.5.10`}catch{return`dev`}}function Uc(){let e=Hc();return(0,Q.jsxs)(Oi,{variant:`secondary`,title:`Fleet ${e}`,"aria-label":`Fleet version ${e}`,className:`shrink-0 font-mono text-[10px] font-normal text-muted-foreground`,children:[`v`,e]})}var Wc={duration:.16,ease:Ne},Gc=[],Kc=[];function qc(e){return e.kind===`folder`||e.kind===`project`}function Jc(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,...Jc(e.children,t,n+1,e.id)]})}function Yc(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?Yc(n.children,t):void 0;if(e)return e}}function Xc(e,t){return e.id===t||e.children?.some(e=>Xc(e,t))===!0}function Zc(e,t){let n,r=[];for(let i of e){if(i.id===t){n=i;continue}if(i.children?.length){let e=Zc(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 Qc(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:Qc(a.children,t,n,r)}):i.push(a)}return i}function $c(e,t){let n=Yc(e,t.itemId);if(!n||n.disabled||t.targetId&&Xc(n,t.targetId))return null;let r=t.targetId?Yc(e,t.targetId):void 0;if(t.position===`inside`&&(!r||r.disabled||!qc(r)))return null;let i=Zc(e,t.itemId);return i.removed?Qc(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 tl(e,t){if(e.kind===`action`)return null;let n=e.kind===`folder`||e.kind===`project`?t?Mr:Pr:e.kind===`bookmark`?Xa:vr;return(0,Q.jsx)(n,{className:`size-4`})}function nl({active:e,children:t}){let n=Ge()??!1,r=(0,Z.useRef)(null),i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(0);(0,Z.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,Q.jsx)(`span`,{ref:r,className:`block min-w-0 flex-1 overflow-hidden`,children:(0,Q.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}:Wc,children:[(0,Q.jsx)(`span`,{ref:i,children:t}),s?(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:t}):null]})})}function rl({label:e,onCommit:t,onCancel:n}){let[r,i]=(0,Z.useState)(e),a=(0,Z.useRef)(null),o=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{o.current=!1,i(e),requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()})},[e]),(0,Q.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 il({item:e,menuOpen:t,onMenuOpenChange:n,onRenameStart:r,renderMenu:i}){let a=i?.(e,{close:()=>n(!1),rename:()=>{n(!1),r()}})??(0,Q.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,Q.jsx)(hn,{"aria-hidden":`true`,className:`size-3.5`}),`Rename`]});return(0,Q.jsxs)(ze,{open:t,onOpenChange:n,children:[(0,Q.jsx)(Re,{children:(0,Q.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,Q.jsx)(no,{"aria-hidden":`true`,className:`size-4`})})}),(0,Q.jsx)(Ve,{side:`bottom`,align:`end`,sideOffset:8,radius:12,className:`w-40 p-1.5`,children:(0,Q.jsx)(`div`,{"data-sidebar-resource-menu":e.id,children:a})})]})}function al(e,t,n,r,i){return q(`group/resource relative flex min-h-8 min-w-0 cursor-pointer items-center gap-2 rounded-lg pr-2 text-[13px] 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 ol({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,Z.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 sl({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,Q.jsxs)(Q.Fragment,{children:[e!==null&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 shrink-0 place-items-center`,children:e}),(0,Q.jsx)(rl,{label:n,onCommit:r,onCancel:i})]}):(0,Q.jsxs)(Q.Fragment,{children:[e!==null&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 shrink-0 place-items-center`,children:e}),(0,Q.jsx)(nl,{active:a,children:n}),s,!o.disabled&&o.kind!==`action`&&(0,Q.jsx)(il,{item:o,menuOpen:c,onMenuOpenChange:l,onRenameStart:u,renderMenu:d})]})}function cl(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 ll(e){let t=Ge()??!1,[n,r]=(0,Z.useState)(!1),i=qc(e.row.item),a=e.renderIcon?.(e.row.item),o=a===void 0?tl(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=ol({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=cl(e.row,i,e.active,e.expanded,e.focused,e.allowMove,e.renaming,e.menuOpen,c,s);return(0,Q.jsx)(K.div,{ref:e.setRef,layout:`position`,transition:t?{duration:0}:je,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:al(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,Q.jsx)(sl,{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 ul({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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{role:`tree`,"aria-label":d,"aria-multiselectable":`false`,onDragOver:D,onDrop:O,className:q(`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,Q.jsx)(We,{initial:!1,children:e.map(e=>(0,Q.jsx)(ll,{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,Q.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-[10px] 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,Q.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})}function dl({expandedIds:e,flat:t,focusRow:n,onContainerSelect:r,performMove:i,select:a,setMenuOpenId:o,setRenamingId:s,toggle:c,updateExpandedIds:l}){return(0,Z.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&&qc(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`&&qc(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(),qc(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 fl({items:e,defaultItems:t=Gc,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=Kc,onExpandedIdsChange:m,renderIcon:h,renderSecondaryAction:g,renderMenu:_,ariaLabel:v=`Resources`,className:y}){let[b,x]=(0,Z.useState)(e??t),[S,C]=(0,Z.useState)(l),[w,T]=(0,Z.useState)(()=>new Set(p)),[E,D]=(0,Z.useState)(s??l),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(``),R=(0,Z.useRef)(new Map),z=(0,Z.useRef)(!1),B=b,V=s??S,H=(0,Z.useMemo)(()=>f===void 0?w:new Set(f),[f,w]);(0,Z.useEffect)(()=>{e&&x(e)},[e]),(0,Z.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 U=(0,Z.useMemo)(()=>Jc(B,H),[H,B]);(0,Z.useEffect)(()=>{E&&U.some(e=>e.item.id===E)||D(U[0]?.item.id??null)},[U,E]),(0,Z.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 W=(0,Z.useCallback)(e=>{x(e),n?.(e)},[n]),G=(0,Z.useCallback)(async e=>{if(z.current){L(`Wait for the current move to finish.`);return}let t=B,n=$c(t,e);if(!n||n===t)return;z.current=!0,W(n),j(null),k(null);let a=Yc(t,e.itemId),o=e.targetId?Yc(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){W(t),L(`Move failed. ${a?.label??`Item`} was restored.`),i?.(n,e)}finally{z.current=!1}},[r,i,B,W]),ee=(0,Z.useCallback)(e=>{D(e),requestAnimationFrame(()=>R.current.get(e)?.focus())},[]),te=(0,Z.useCallback)(e=>{s===void 0&&C(e),u?.(e)},[s,u]),ne=(0,Z.useCallback)(e=>{let t=e(new Set(H));f===void 0&&T(t),m?.([...t])},[f,H,m]),re=(0,Z.useCallback)(e=>{ne(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[ne]),ie=dl({expandedIds:H,flat:U,focusRow:ee,onContainerSelect:d,performMove:G,select:te,setMenuOpenId:N,setRenamingId:F,toggle:re,updateExpandedIds:ne});return(0,Q.jsx)(ul,{flat:U,selectedId:V,activeContainerId:c,expandedIds:H,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:te,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=B;W(el(r,e.item.id,n)),Promise.resolve(o?.(e.item,n)).catch(()=>{W(r),L(`Rename failed. ${e.item.label} was restored.`)})},onMenuOpenChange:(e,t)=>{N(t?e:null),t||ee(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=Yc(B,O);if(n&&Xc(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&&qc(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&&G({itemId:O,targetId:A.id,position:A.position})},setRef:(e,t)=>{t?R.current.set(e,t):R.current.delete(e)}})}var pl=5,ml=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function hl(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 gl({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,Q.jsxs)(`div`,{ref:c,role:`dialog`,"aria-modal":`true`,"aria-labelledby":n,"aria-hidden":i?void 0:`true`,className:q(`fixed inset-0 z-50 flex items-start justify-center overflow-y-auto sm:items-center`,a&&`pointer-events-none`),children:[(0,Q.jsx)(We,{initial:!1,children:i?(0,Q.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,Q.jsxs)(`div`,{className:`relative z-10 w-full max-w-5xl px-6 py-8`,children:[(0,Q.jsx)(We,{initial:!1,children:i?(0,Q.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,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{id:n,className:`text-xl font-medium text-foreground`,children:e}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),(0,Q.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,Q.jsx)(Wr,{className:`size-4`,"aria-hidden":`true`})})]},`project-files-header`):null}),(0,Q.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,Q.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 _l({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=Ge(),g=Gn(),_=(0,Z.useId)(),v=`${_}-title`,y=(0,Z.useRef)(!1),b=(0,Z.useRef)(!1),x=(0,Z.useRef)(!1),S=(0,Z.useRef)(null),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=Ie(),[E,D]=(0,Z.useState)(o),[O,k]=(0,Z.useState)(l),[A,j]=(0,Z.useState)(!1),M=a!==void 0,N=c!==void 0,P=c??O,F=(a??E)||P,I=n.slice(0,pl),L=h?{duration:0}:je,R=`${r} ${i}${r===1?``:`s`}`,z=(0,Z.useCallback)(e=>{f||(M||D(e),s?.(e))},[f,s,M]),B=(0,Z.useCallback)(e=>{f||I.length===0||(N||k(e),u?.(e))},[f,N,u,I.length]),V=(0,Z.useCallback)(()=>{j(!1),x.current=!0,requestAnimationFrame(()=>S.current?.focus())},[]),H=(0,Z.useCallback)(()=>{j(!0),z(!1),B(!1)},[B,z]),U=(0,Z.useEffectEvent)(H);(0,Z.useEffect)(()=>{h&&A&&V()},[V,A,h]),(0,Z.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(),U();return}if(e.key!==`Tab`||!w.current)return;let t=Array.from(w.current.querySelectorAll(ml)).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 W=()=>{j(!1),B(!0),z(!0),d?.()},G=(0,Q.jsx)(gl,{title:e,countText:R,dialogTitleId:v,previewItems:I,isExpanded:P,isClosing:A,reduce:h??!1,transition:L,dialogRef:w,closeButtonRef:C,closeOverlay:H});return(0,Q.jsxs)(Sa,{id:_,children:[(0,Q.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,z(!0))},onPointerLeave:()=>{g&&(y.current=!1,!P&&!A&&z(b.current))},onFocus:()=>{if(x.current){x.current=!1,b.current=!1;return}b.current=!0,z(!0)},onBlur:()=>{b.current=!1,!P&&!A&&z(y.current)},onClick:W,whileTap:h||f?void 0:{scale:.98},transition:h?{duration:0}:Oe,className:q(`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,Q.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,Q.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:(0,Q.jsx)(`span`,{className:`absolute left-1/2 top-0 block h-0 w-0`,children:(0,Q.jsx)(We,{initial:!1,children:P?null:I.map((e,t)=>{let n=hl(t,I.length);return(0,Q.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&&V()},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,Q.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,Q.jsx)(`span`,{className:`flex h-16 items-center px-4`,children:(0,Q.jsx)(`span`,{className:`line-clamp-2 text-xl font-medium leading-tight text-foreground`,children:e})}),(0,Q.jsxs)(`span`,{className:`flex h-12 items-center justify-between gap-3 border-t border-foreground/10 px-4`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/70`,children:R}),(0,Q.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,children:t})]})]})]}),T?(0,ps.createPortal)(G,document.body):null]})}function vl(e){return e?.status===`running`?(0,Q.jsx)(mr,{className:`size-3.5 animate-spin`}):e?.status===`failed`?(0,Q.jsx)(Ur,{className:`size-3.5 text-destructive`}):e?.status===`interrupted`?(0,Q.jsx)($a,{className:`size-3.5 text-muted-foreground`}):null}function yl({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,Q.jsx)(Rs,{className:`gap-0 px-2 pb-1 pt-2`,children:(0,Q.jsxs)(Bs,{className:`p-0`,children:[(0,Q.jsxs)(`div`,{className:`relative mb-1 h-8`,children:[(0,Q.jsx)(Vs,{className:`mb-0 h-8 pr-16 text-xs font-normal normal-case tracking-normal text-muted-foreground`,children:`Projects`}),(0,Q.jsxs)(`div`,{className:`absolute inset-y-0 right-1 flex items-center gap-0.5`,children:[(0,Q.jsxs)(Bc,{open:e,onOpenChange:t,side:`bottom`,align:`end`,className:`w-44 p-1`,trigger:(0,Q.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,Q.jsx)(no,{"aria-hidden":`true`,className:`size-3.5`})}),children:[m?(0,Q.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,Q.jsx)(io,{"aria-hidden":`true`,className:`size-3.5`}),`Add project`]}):null,(0,Q.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,Q.jsx)(Qn,{"aria-hidden":`true`,className:`size-3.5`}),`Collapse all`]})]}),m?(0,Q.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,Q.jsx)(Lr,{"aria-hidden":`true`,className:`size-3.5`})}):null]})]}),(0,Q.jsx)(Hs,{children:a.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-4`,children:(0,Q.jsx)(_l,{title:`Add a project`,description:`Choose a local directory for Fleet Prime.`,count:0,itemLabel:`session`,previews:[{id:`empty-project`,content:(0,Q.jsx)(io,{className:`size-5 text-muted-foreground`})}],onClick:()=>i(!0),ariaLabel:`Add a project`,className:`w-full`})}):(0,Q.jsx)(fl,{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,Q.jsx)(Pr,{className:`size-4`});if(e.kind===`action`)return null;let t=$s(e.id,Ys);return vl(o.find(e=>e.sessionId===t))},renderSecondaryAction:e=>{let t=$s(e.id,Js);return!t||t===`unassigned`?null:(0,Q.jsx)(V,{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,Q.jsx)(so,{"data-icon":`inline-start`,className:`size-3.5`})})},allowMove:!1,ariaLabel:`Projects and sessions`,className:`px-0`})})]})})}var bl=`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 xl({icon:e,label:t,onClick:n,href:r}){return r?(0,Q.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:bl,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:bl,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]})}function Sl({children:e}){return(0,Q.jsx)(`kbd`,{className:`rounded border border-border/60 bg-muted/60 px-1 font-mono text-[10px] leading-4 text-muted-foreground`,children:e})}function Cl({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,Z.useMemo)(()=>lc(f).map(e=>({id:e.sessionId,title:ec(e),preview:tc(e,h),group:nc(e.updatedAt),keywords:e.firstMessage?[kr(e.firstMessage)]:[]})),[h,f]),A=(0,Z.useMemo)(()=>{let e=i.trim().toLowerCase();return e?m.filter(t=>`${t.name} ${t.pathLabel}`.toLowerCase().includes(e)):m},[i,m]);return(0,Q.jsx)(Ns,{ariaLabel:`Fleet projects and sessions`,collapsible:`offcanvas`,variant:`floating`,className:`text-sidebar-foreground`,children:(0,Q.jsxs)(Ut,{value:2,children:[(0,Q.jsxs)(Ls,{className:`gap-2 border-0 px-2.5 pb-2 pt-2.5`,children:[(0,Q.jsxs)(`div`,{className:`relative flex h-9 min-w-0 items-center justify-between gap-1`,children:[(0,Q.jsxs)(Bc,{open:e,onOpenChange:t,side:`bottom`,align:`start`,trigger:(0,Q.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,Q.jsx)(`span`,{className:`truncate`,children:`Qredence Fleet`}),(0,Q.jsx)(Qn,{className:`size-3.5 text-muted-foreground`})]}),className:`w-52 p-1`,children:[S?(0,Q.jsx)(xl,{icon:io,label:`Add project`,onClick:()=>{t(!1),u(!0)}}):null,(0,Q.jsx)(xl,{icon:yn,label:`Settings`,onClick:()=>{t(!1),C?.()}}),(0,Q.jsx)(xl,{icon:Jn,label:`Documentation`,href:Ws})]}),(0,Q.jsx)(Bc,{open:n,onOpenChange:r,side:`bottom`,align:`end`,className:`w-64 p-0`,trigger:(0,Q.jsx)(V,{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,Q.jsx)(Vr,{"data-icon":`inline-start`,className:`size-4`})}),children:(0,Q.jsxs)(`div`,{className:`max-h-[min(32rem,calc(100vh-5rem))] overflow-y-auto`,children:[(0,Q.jsx)(Vc,{threads:k,query:i,activeId:_??``,onQueryChange:a,onSelect:e=>D(`search-session:${e}`),className:`max-w-none rounded-none border-0 bg-transparent p-2 shadow-none`}),(0,Q.jsxs)(`div`,{className:`border-t border-border/60 px-2 pb-2 pt-1.5`,children:[(0,Q.jsx)(`span`,{className:`px-2 pb-1 font-mono text-[10px] uppercase tracking-[0.14em] text-muted-foreground/60`,children:`Projects`}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5`,children:[A.map(e=>(0,Q.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,Q.jsx)(Pr,{className:`size-3.5 shrink-0 text-muted-foreground/60`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`max-w-24 truncate text-[10px] text-muted-foreground/55`,children:e.pathLabel})]},e.projectId)),A.length===0?(0,Q.jsxs)(`span`,{className:`px-2 py-2 text-center text-[11px] text-muted-foreground/60`,children:[`No project matches “`,i,`”`]}):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t border-border/60 px-3 py-2 text-[10px] text-muted-foreground/70`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Sl,{children:`↑`}),(0,Q.jsx)(Sl,{children:`↓`}),`navigate`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Sl,{children:`↵`}),`open`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Sl,{children:`esc`}),`close`]})]})]})})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:v,className:`flex h-8 w-full items-center justify-start gap-2 rounded-lg px-2 text-[13px] 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,Q.jsx)(po,{className:`size-4 shrink-0 text-muted-foreground`}),`New chat`]})]}),(0,Q.jsx)(yl,{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,Q.jsxs)(zs,{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,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:w??(0,Q.jsx)(`span`,{className:`flex h-8 items-center px-2 text-[13px]`,children:`Qredence`})}),(0,Q.jsx)(Uc,{}),(0,Q.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,Q.jsx)(Qa,{className:`size-4`})})]}),(0,Q.jsx)(Fs,{})]})})}var wl=(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},Tl=(0,Z.createContext)(null),El=(0,Z.createContext)(null);function Dl(e){let t=(0,Z.useContext)(Tl);if(!t)throw Error(`${e} must be used within <Combobox>`);return t}function Ol(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&typeof n==`object`&&(n.current=t)}}function kl({children:e,value:t,defaultValue:n,onValueChange:r,open:i,defaultOpen:a=!1,onOpenChange:o,query:s,defaultQuery:c=``,onQueryChange:l,filter:u=wl,disabled:d=!1,className:f}){let p=Ge()??!1,m=(0,Z.useId)(),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),[y,b]=(0,Z.useState)(n),[x,S]=(0,Z.useState)(a),[C,w]=(0,Z.useState)(c),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.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,Z.useCallback)(e=>{j||w(e),l?.(e)},[l,j]),I=(0,Z.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,Z.useEffectEvent)(I),R=(0,Z.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})},[]),z=(0,Z.useCallback)(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),B=(0,Z.useMemo)(()=>Array.from(D.values()).filter(e=>u(e.value,P,[e.label,...e.keywords])),[u,D,P]),V=(0,Z.useMemo)(()=>B.filter(e=>!e.disabled),[B]),H=(0,Z.useMemo)(()=>new Set(B.map(e=>e.value)),[B]),U=(0,Z.useMemo)(()=>new Set(B.map(e=>e.groupId)),[B]),W=(0,Z.useCallback)(e=>{D.get(e)?.disabled||(k||b(e),r?.(e),I(!1,!0))},[D,r,I,k]),G=(0,Z.useCallback)(e=>{if(!V.length){E(null);return}if(e===`first`){E(V[0].value);return}if(e===`last`){E(V.at(-1)?.value??null);return}let t=V.findIndex(e=>e.value===T),n=t<0?e===1?0:V.length-1:(t+e+V.length)%V.length;E(V[n].value)},[T,V]),ee=(0,Z.useCallback)(()=>{T&&W(T)},[T,W]);(0,Z.useEffect)(()=>{if(!N)return;let e=M&&H.has(M)?M:null,t=T&&H.has(T)?T:null;E(t??e??V[0]?.value??null)},[T,V,N,M,H]),(0,Z.useEffect)(()=>{N&&requestAnimationFrame(()=>v.current?.focus({preventScroll:!0}))},[N]),(0,Z.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,Z.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 te=T?D.get(T):void 0,ne=(0,Z.useMemo)(()=>({open:N,setOpen:I,value:M,select:W,query:P,setQuery:F,activeValue:T,setActiveValue:E,moveActive:G,selectActive:ee,registerItem:R,unregisterItem:z,labelFor:e=>e===void 0?void 0:D.get(e)?.label,isVisible:e=>!P.trim()||H.has(e),hasVisibleItems:e=>U.has(e),visibleCount:B.length,activeItemId:te?.id,triggerId:`${m}-trigger`,listId:`${m}-list`,inputId:`${m}-input`,disabled:d,reduce:p,triggerRef:g,contentRef:_,inputRef:v,activeLayoutId:`${m}-active`}),[te?.id,T,m,d,D,G,N,P,p,R,W,ee,z,I,F,M,B.length,U,H]);return(0,Q.jsx)(Tl.Provider,{value:ne,children:(0,Q.jsx)(`div`,{ref:h,className:q(`relative w-full`,f),children:e})})}var Al={type:`spring`,duration:.5,bounce:.22},jl=8;function Ml({children:e,side:t=`bottom`,align:n=`start`,sideOffset:r=6,avoidCollisions:i=!0,className:a}){let o=Dl(`ComboboxContent`),s=(0,Z.useRef)(null),c=Ie(),[l,u]=(0,Z.useState)(t),[d,f]=(0,Z.useState)(!1),p=Ht(),m=Math.min(p+2,8),h=Be(o.triggerRef,s,c);if((0,Z.useLayoutEffect)(()=>{if(!c)return;let e=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(e)},[c]),(0,Z.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(jl,window.innerWidth-v-jl),x=Math.min(Math.max(y,jl),b),S=h?.content.height??0;return(0,ps.createPortal)((0,Q.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}:Al,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:q(`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,Q.jsx)(Ut,{value:m,children:(0,Q.jsx)(K.div,{ref:s,initial:!1,animate:{opacity:+!!o.open},transition:o.reduce||!d?{duration:0}:Al,children:e})})}),document.body)}function Nl({children:e,ariaLabel:t=`Options`,className:n}){let r=Dl(`ComboboxList`);return(0,Q.jsx)(`div`,{id:r.listId,role:`listbox`,"aria-label":t,className:q(`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 Pl({children:e,className:t}){let n=Dl(`ComboboxGroup`),r=(0,Z.useId)();return(0,Q.jsx)(El.Provider,{value:r,children:(0,Q.jsx)(`fieldset`,{hidden:!n.hasVisibleItems(r),className:q(`m-0 min-w-0 border-0 p-0 py-0.5`,t),children:e})})}function Fl({children:e,className:t}){let n=(0,Z.useContext)(El),r=q(`w-full px-2 py-1.5 text-[0.68rem] font-medium uppercase tracking-[0.12em] text-muted-foreground`,t);return n?(0,Q.jsx)(`legend`,{className:r,children:e}):(0,Q.jsx)(`div`,{className:r,children:e})}function Il({value:e,children:t,textValue:n,keywords:r=[],disabled:i=!1,onSelect:a,className:o}){let s=Dl(`ComboboxItem`),c=(0,Z.useContext)(El),l=(0,Z.useId)(),u=(0,Z.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,Z.useMemo)(()=>h?h.split(`\0`):[],[h]),{registerItem:_,unregisterItem:v}=s;return(0,Z.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,Q.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:q(`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,Q.jsx)(K.span,{"aria-hidden":!0,layoutId:s.activeLayoutId,className:`absolute inset-0 -z-10 rounded-lg bg-muted`,transition:s.reduce?{duration:0}:je}):null,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),(0,Q.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:Ne},className:`grid size-5 shrink-0 place-items-center text-foreground`,children:(0,Q.jsx)(Zn,{className:`size-4`})})]}):null}function Ll({children:e=`No options found.`,className:t}){return Dl(`ComboboxEmpty`).visibleCount>0?null:(0,Q.jsx)(`div`,{role:`status`,className:q(`px-3 py-8 text-center text-sm text-muted-foreground`,t),children:e})}function Rl({children:e,className:t,showIndicator:n=!0}){let r=Dl(`ComboboxTrigger`);return(0,Q.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:q(`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,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:e}),n?(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-muted-foreground`,children:(0,Q.jsx)(Za,{className:`size-4`})}):null]})}function zl({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=Dl(`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,Q.jsxs)(`div`,{className:q(`flex min-w-0 flex-1 items-center gap-2`,n),children:[(0,Q.jsx)(Vr,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`input`,{...u,ref:Ol(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:q(`h-10 min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed`,t)})]})}function Bl({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,Z.useId)(),b=(0,Z.useId)(),x=(0,Z.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,Q.jsx)(Xt,{open:e,onOpenChange:e=>{e?t(!0):T()},children:(0,Q.jsxs)(Kt,{className:`sm:max-w-xl`,children:[(0,Q.jsxs)(zt,{children:[(0,Q.jsx)(qt,{children:`Add project`}),(0,Q.jsx)(Yt,{children:`Choose the local directory that owns this project's sessions. Browse the server filesystem or paste an absolute path.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium`,htmlFor:y,children:`Project name`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Optional`})]}),(0,Q.jsx)(zi,{id:y,value:u,onChange:e=>d(e.target.value),placeholder:`e.g. Fleet Prime`,"aria-label":`Project name`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium`,htmlFor:b,children:`Local directory`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Required`})]}),(0,Q.jsx)(zi,{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,Q.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,Q.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,Q.jsx)(Cn,{className:`size-4`}),`Loading directories…`]}):null,n?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl border bg-muted/20`,"data-testid":`project-directory-browser`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 p-3`,children:[(0,Q.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-primary/10 text-primary`,children:(0,Q.jsx)(Mr,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Selected directory`}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-foreground`,title:S,children:S})]}),(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary`,children:`Selected`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 border-t px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`Browse child directories`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open a folder to make it the selected directory.`})]}),n.parentToken?(0,Q.jsxs)(V,{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,Q.jsx)(Le,{className:`size-3.5`}),`Up`]}):null]}),i?(0,Q.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,Q.jsx)(Cn,{className:`size-4`}),`Loading directories…`]}):n.entries.length===0?(0,Q.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,Q.jsxs)(kl,{value:c,onValueChange:e=>{n.entries.find(t=>t.directoryToken===e)&&m({token:e})},children:[(0,Q.jsx)(Rl,{className:`h-10 bg-background`,children:(0,Q.jsx)(zl,{"aria-label":`Search child directories`,placeholder:`Choose a child directory…`,className:`text-xs`})}),(0,Q.jsx)(Ml,{className:`w-[min(32rem,calc(100vw-3rem))]`,children:(0,Q.jsxs)(Nl,{ariaLabel:`Child directories`,children:[(0,Q.jsxs)(Pl,{children:[(0,Q.jsx)(Fl,{children:`Child directories`}),n.entries.map(e=>(0,Q.jsx)(Il,{value:e.directoryToken,textValue:`${e.name} ${e.pathLabel}`,keywords:[e.pathLabel],children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(ao,{className:`mt-0.5 size-4 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:rc(e)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,title:e.pathLabel,children:e.pathLabel})]})]})},e.directoryToken))]}),(0,Q.jsx)(Ll,{children:`No matching directories.`})]})})]})]})]}):s?(0,Q.jsxs)(V,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void m({}),className:`w-full justify-start`,children:[(0,Q.jsx)(Mr,{className:`size-4`}),`Browse directories`]}):null,a?(0,Q.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,Q.jsx)(Ur,{className:`mt-0.5 size-4 shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{children:a}),(0,Q.jsx)(V,{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,Q.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:g}):null]}),(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(V,{type:`button`,variant:`outline`,disabled:h,onClick:T,children:`Cancel`}),(0,Q.jsx)(V,{type:`button`,disabled:!C||h,onClick:()=>void v(),children:h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Cn,{className:`size-3.5`}),`Adding project…`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(io,{className:`size-3.5`}),`Add project`]})})]})]})})}function Vl({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,Z.useMemo)(()=>e.flatMap(e=>e.projectId===v?.projectId?[]:[{value:e.projectId,label:`${e.name} — ${e.pathLabel}`,icon:Pr}]),[v?.projectId,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,Q.jsxs)(Mn,{children:[(0,Q.jsx)(Pn,{children:`Rename session`}),(0,Q.jsx)(Sn,{children:`Choose a local display title for this Fleet Prime session.`}),(0,Q.jsx)(zi,{value:c,onChange:e=>l(e.target.value),"aria-label":`Session title`,autoFocus:!0}),(0,Q.jsxs)(Dn,{children:[(0,Q.jsx)(An,{children:`Cancel`}),(0,Q.jsx)(xn,{disabled:!c.trim(),onClick:()=>{o&&c.trim()&&(t(o.sessionId,c.trim()),s(null))},children:`Rename`})]})]})}),(0,Q.jsx)(En,{open:u!==null,onOpenChange:e=>!e&&d(null),children:(0,Q.jsxs)(Mn,{children:[(0,Q.jsx)(Pn,{children:`Rename project`}),(0,Q.jsx)(Sn,{children:`This changes the display name only. The registered directory stays the same.`}),(0,Q.jsx)(zi,{value:f,onChange:e=>p(e.target.value),"aria-label":`Project name`,autoFocus:!0}),(0,Q.jsxs)(Dn,{children:[(0,Q.jsx)(An,{children:`Cancel`}),(0,Q.jsx)(xn,{disabled:!f.trim()||!r,onClick:()=>{u&&f.trim()&&(r?.(u.projectId,f.trim()),d(null))},children:`Rename`})]})]})}),(0,Q.jsx)(En,{open:m!==null,onOpenChange:e=>!e&&h(null),children:(0,Q.jsxs)(Mn,{children:[(0,Q.jsx)(Pn,{children:`Delete session?`}),(0,Q.jsx)(Sn,{children:`This removes the Fleet Prime session and its managed session artifacts. This cannot be undone.`}),(0,Q.jsxs)(Dn,{children:[(0,Q.jsx)(An,{children:`Cancel`}),(0,Q.jsx)(xn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{m&&n(m.sessionId),h(null)},children:`Delete`})]})]})}),(0,Q.jsx)(En,{open:g!==null,onOpenChange:e=>!e&&_(null),children:(0,Q.jsxs)(Mn,{children:[(0,Q.jsx)(Pn,{children:`Unregister project?`}),(0,Q.jsx)(Sn,{children:`The directory and its sessions remain intact. Existing sessions will move to Unassigned until the directory is registered again.`}),(0,Q.jsxs)(Dn,{children:[(0,Q.jsx)(An,{children:`Cancel`}),(0,Q.jsx)(xn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{g&&i?.(g.projectId),_(null)},children:`Unregister`})]})]})}),(0,Q.jsx)(Xt,{open:v!==null,onOpenChange:e=>!e&&y(null),children:(0,Q.jsxs)(Kt,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(zt,{children:[(0,Q.jsx)(qt,{children:`Fork session into project`}),(0,Q.jsx)(Yt,{children:`Create a new Fleet Prime session in another registered project.`})]}),(0,Q.jsx)(`div`,{className:`py-2`,children:(0,Q.jsx)(cn,{value:b??null,onValueChange:e=>x(e),options:S,placeholder:`Select a project…`,"aria-label":`Target project`})}),(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(V,{type:`button`,variant:`outline`,onClick:()=>y(null),children:`Cancel`}),(0,Q.jsx)(V,{type:`button`,disabled:!v||!b||!a,onClick:()=>{!v||!b||(a?.(v.sessionId,b),y(null))},children:`Fork session`})]})]})})]})}function Hl(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Bl,{...e}),(0,Q.jsx)(Vl,{...e})]})}function Ul({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=sc(c),{loadDirectories:T,projectById:E,sortedProjects:D,sidebarItems:O,resumeResource:k,toggleProjectResource:A,selectSearchResult:j,renderMenu:M,submitCreate:N}=mc({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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Cl,{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,Q.jsx)(Hl,{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})]})}var Wl=[];function Gl({label:e,active:t=!1,onClick:n,children:r}){let i=Ge()??!1;return(0,Q.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:Oe,className:q(`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 Kl({children:e,status:t=`streaming`,copyText:n,onCopy:r,onRetry:i,sources:a=Wl,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=Ge()??!1,y=(0,Z.useId)(),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(d),[w,T]=(0,Z.useState)(s),E=(0,Z.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,Z.useEffect)(()=>()=>{E.current&&window.clearTimeout(E.current)},[]);let I=(0,Z.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)},R=(0,Z.useCallback)(e=>{o===void 0&&T(e),c?.(e)},[c,o]);return(0,Q.jsxs)(`div`,{"data-state":t,"aria-busy":k,className:q(`w-full`,h),children:[(0,Q.jsx)(`div`,{"aria-live":p?`polite`:`off`,className:q(`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,Q.jsx)(We,{initial:!1,children:N?(0,Q.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:Ne},className:`mt-3`,children:[(0,Q.jsxs)(`div`,{className:q(`flex items-center gap-0.5`,_),children:[j?(0,Q.jsx)(Gl,{label:b?`Copied`:`Copy response`,onClick:I,children:b?(0,Q.jsx)(Zn,{className:`size-3.5`}):(0,Q.jsx)(gr,{className:`size-3.5`})}):null,i?(0,Q.jsx)(Gl,{label:`Retry response`,onClick:i,children:(0,Q.jsx)(zr,{className:`size-3.5`})}):null,A?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gl,{label:`Helpful`,active:D===`up`,onClick:()=>L(`up`),children:(0,Q.jsx)(ho,{className:`size-3.5`})}),(0,Q.jsx)(Gl,{label:`Not helpful`,active:D===`down`,onClick:()=>L(`down`),children:(0,Q.jsx)(mo,{className:`size-3.5`})})]}):null,M?(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":P,onClick:()=>R(!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,Q.jsx)(Wn,{citations:a}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[a.length,` `,a.length===1?`source`:`sources`]}),(0,Q.jsx)(K.span,{"aria-hidden":`true`,animate:{rotate:O?180:0},transition:v?{duration:0}:Fe,className:`text-muted-foreground/50 group-hover:text-muted-foreground`,children:(0,Q.jsx)(Qn,{className:`size-3`})})]}):null]}),M?(0,Q.jsx)(Yr,{id:P,open:O,children:(0,Q.jsx)(qn,{citations:a,idPrefix:F,className:`mt-2 rounded-xl bg-muted p-2`})}):null]}):null})]})}var ql=[{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 Jl(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 Yl({label:e=`Churning`,elapsedSeconds:t,initialSeconds:n=0,running:r=!0,className:i}){let a=Ge()??!1,[o,s]=(0,Z.useState)(n);(0,Z.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,Q.jsxs)(`span`,{role:`status`,"aria-label":`${e}, in progress`,className:q(`inline-flex items-center gap-3 font-mono text-sm text-muted-foreground`,i),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 grid-cols-3 gap-[2px]`,children:ql.map(({id:e,delay:t})=>(0,Q.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:Ae,repeat:1/0,delay:t}},e))}),(0,Q.jsx)(`span`,{className:`font-sans font-medium`,children:e}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`tabular-nums text-muted-foreground/70`,children:Jl(c)})]})}function Xl({label:e,className:t}){let n=Ge();if(!e?.trim())return null;let{kind:r,title:i,detail:a}=Zl(e),o=Ql(r),s=r===`queue`||r===`retry`||r===`compaction`;return(0,Q.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:q(`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,Q.jsx)(Yl,{label:i,running:!0,className:`min-w-0 text-xs`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(o,{className:q(`mt-0.5 size-3.5 shrink-0`,r===`recovery`&&`text-amber-600 dark:text-amber-400`)}),(0,Q.jsx)(`strong`,{className:`font-medium text-foreground/90`,children:i})]}),a?(0,Q.jsx)(`span`,{className:`min-w-0 leading-relaxed`,children:a}):null]})}function Zl(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 Ql(e){switch(e){case`queue`:return oo;case`retry`:return zr;case`compaction`:return Fr;case`recovery`:return pr;default:return eo}}function $l(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 eu(e){return e.length===1?`Completed 1 tracked action`:`Completed ${e.length} tracked actions`}var tu=[{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 nu({disabled:e,onSelect:t,composer:n}){return(0,Q.jsxs)(`section`,{"aria-labelledby":`fleet-welcome-title`,className:`flex w-full max-w-an flex-col items-center text-center`,children:[(0,Q.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,Q.jsx)(`div`,{className:`mt-6 w-full`,children:n}),(0,Q.jsx)(`div`,{"aria-label":`Suggested prompts`,className:`mt-4 flex w-full flex-wrap justify-center gap-2`,children:tu.map(n=>(0,Q.jsx)(V,{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))})]})}var ru=[`·`,`•`,`●`,`•`];function iu({label:e,isActive:t,className:n}){let[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(0);return(0,Z.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,Q.jsxs)(`div`,{className:q(`flex items-center gap-2 px-an-context-padding py-1 text-xs text-foreground/70`,n),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-an-primary-color`,children:ru[a%ru.length]}),(0,Q.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:e}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`truncate`,children:e}),(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:`tabular-nums text-foreground/50`,children:[r,`s`]})]})}var au=`M5 13l4 4L19 7`,ou=`M6 12h12`;function su({checked:e,onCheckedChange:t,disabled:n,indeterminate:r,label:i,className:a,id:o,"aria-label":s,"aria-describedby":c}){let l=(0,Z.useId)(),u=o??l,d=Ge(),f=e||r,p=r?ou:au;return(0,Q.jsxs)(`label`,{htmlFor:u,className:q(`inline-flex items-center gap-3`,n?`cursor-not-allowed`:`cursor-pointer`,a),children:[(0,Q.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:Oe,"data-state":e?`checked`:r?`indeterminate`:`unchecked`,className:q(`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,Q.jsx)(We,{initial:!1,children:f?(0,Q.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:Ne},"aria-hidden":!0,children:[(0,Q.jsx)(`title`,{children:r?`Partially selected`:`Selected`}),(0,Q.jsx)(K.path,{d:p,initial:d?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:d?{duration:0}:{duration:r?.2:.3,ease:Ne,delay:.04}})]},r?`indeterminate`:`checked`):null})}),i?(0,Q.jsx)(`span`,{className:q(`select-none text-sm text-foreground`,n&&`opacity-60`),children:i}):null]})}var cu=(0,Z.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,Z.useId)(),v=p??_,y=Ge(),b=t!==void 0,[x,S]=(0,Z.useState)(n??``),C=b?t??``:x,[w,T]=(0,Z.useState)(!1),E=(0,Z.useRef)(null),D=!!o,O=typeof o==`string`?o:null,k=s?null:l;(0,Z.useEffect)(()=>{!E.current||y||!D||Ja(E.current,{x:[0,-6,6,-4,4,-2,0]},{duration:.45})},[D,y]);let A=e=>{b||S(e),r?.(e)};return(0,Q.jsxs)(`div`,{className:q(`flex flex-col gap-1.5`,u,d?.root),children:[e?(0,Q.jsx)(`label`,{htmlFor:v,className:q(`px-1 text-sm font-medium text-foreground`,d?.label),children:e}):null,(0,Q.jsxs)(`div`,{ref:E,"data-state":D?`error`:s?`success`:w?`focused`:`idle`,className:q(`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,Q.jsx)(`span`,{className:q(`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,Q.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:q(`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,Q.jsx)(K.svg,{viewBox:`0 0 24 24`,fill:`none`,className:q(`absolute right-3.5 top-1/2 h-5 w-5 -translate-y-1/2 text-(--color-success)`,d?.successIcon),children:(0,Q.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,Q.jsx)(`span`,{className:q(`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,Q.jsx)(We,{initial:!1,children:O?(0,Q.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:q(`px-1 text-xs text-destructive`,d?.errorMessage),children:O}):null})]})}),lu=(0,Z.createContext)(null);function uu(){let e=(0,Z.useContext)(lu);if(!e)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);return e}function du({value:e,defaultValue:t=``,onValueChange:n,children:r,className:i,orientation:a=`vertical`}){let[o,s]=(0,Z.useState)(t),c=(0,Z.useId)(),l=Ge(),u=e!==void 0,d=u?e:o,f=(0,Z.useCallback)(e=>{u||s(e),n?.(e)},[u,n]),p=(0,Z.useMemo)(()=>({value:d,setValue:f,layoutId:c}),[d,c,f]);return(0,Q.jsx)(Ca,{transition:l?{duration:0}:je,children:(0,Q.jsx)(lu.Provider,{value:p,children:(0,Q.jsx)(`div`,{role:`radiogroup`,className:q(`flex gap-3`,a===`vertical`?`flex-col`:`flex-row flex-wrap`,i),children:r})})})}function fu({value:e,label:t,disabled:n,className:r,id:i}){let{value:a,setValue:o,layoutId:s}=uu(),c=(0,Z.useId)(),l=i??c,u=Ge(),d=a===e;return(0,Q.jsxs)(`label`,{htmlFor:l,className:q(`inline-flex items-center gap-3`,n?`cursor-not-allowed`:`cursor-pointer`,r),children:[(0,Q.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:Oe,"data-state":d?`checked`:`unchecked`,className:q(`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,Q.jsx)(K.span,{layoutId:s,className:`absolute inset-1 rounded-full bg-primary`,transition:u?{duration:0}:je}):null}),t?(0,Q.jsx)(`span`,{className:q(`select-none text-sm text-foreground`,n&&`opacity-60`),children:t}):null]})}var pu={selected:[],custom:``};function mu(e){return e===`submitting`?`Submitting`:e===`approved`?`Approved`:e===`rejected`?`Rejected`:e===`changes-requested`?`Changes requested`:e===`answered`?`Response submitted`:`Input required`}function hu(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 gu(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 _u(e){return e.selected.length>0||!!e.custom?.trim()}function vu({question:e,answer:t,disabled:n,onChange:r,onSingleSelect:i}){let a=t.custom??``,o=new Set(t.selected);return(0,Q.jsxs)(`div`,{className:`mt-3`,children:[e.options?.length?e.multiple?(0,Q.jsx)(`div`,{className:`grid gap-0.5`,children:e.options.map(e=>(0,Q.jsx)(su,{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,Q.jsx)(du,{value:t.selected[0]??``,onValueChange:e=>{r({selected:[e],custom:``}),i?.()},className:`gap-0.5`,children:e.options.map(e=>(0,Q.jsx)(fu,{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,Q.jsx)(cu,{value:a,disabled:n,placeholder:e.customPlaceholder??`Add another response…`,onChange:n=>r({selected:e.multiple?t.selected:[],custom:n}),className:q(`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 yu({current:e,ids:t}){return(0,Q.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`Question `,e+1,` of `,t.length]}),t.map((t,n)=>(0,Q.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:Fe,className:`size-1.5 rounded-full bg-foreground`},t))]})}function bu({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=Ge()??!1,[x,S]=(0,Z.useState)(o),[C,w]=(0,Z.useState)(l),T=(0,Z.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]??pu:pu,P=O?.title??e,F=O?.id??String(i),I=mu(i),L=(0,Z.useCallback)(()=>{T.current!==void 0&&(window.clearTimeout(T.current),T.current=void 0)},[]);(0,Z.useEffect)(()=>L,[L]);let R=(0,Z.useCallback)(e=>{a===void 0&&S(e),s?.(e)},[a,s]),z=e=>{L(),c===void 0&&w(e),u?.(e)};return(0,Q.jsx)(`div`,{"data-state":i,"aria-busy":j,className:q(`w-full overflow-hidden rounded-2xl bg-muted p-4 text-sm`,y),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:q(`grid size-5 shrink-0 place-items-center text-muted-foreground`,hu(i)),children:j?(0,Q.jsx)(mr,{className:q(`size-4`,!b&&`animate-spin`)}):M?k?(0,Q.jsx)(Qa,{className:`size-4`}):(0,Q.jsx)(co,{className:`size-4`}):i===`rejected`?(0,Q.jsx)(Wr,{className:`size-4`}):(0,Q.jsx)(Zn,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 flex-1 text-base font-medium leading-5 text-foreground`,children:(0,Q.jsx)(_r,{value:F,children:P})}),k&&M?(0,Q.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-muted-foreground/65`,children:[D+1,`/`,r.length]}):(0,Q.jsx)(`span`,{className:q(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors`,gu(i)),children:I}),h?(0,Q.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,Q.jsx)(Wr,{className:`size-4`})}):null]}),(0,Q.jsxs)(Yr,{open:M,children:[(0,Q.jsx)(We,{initial:!1,mode:`wait`,children:k&&O?(0,Q.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:Ne},children:[O.description?(0,Q.jsx)(`p`,{className:`mt-1 leading-5 text-muted-foreground`,children:O.description}):null,(0,Q.jsx)(vu,{question:O,answer:N,disabled:j,onChange:e=>{O&&R({...E,[O.id]:e})},onSingleSelect:()=>{!O||O.multiple||O.autoAdvance===!1||D>=r.length-1||j||(L(),T.current=window.setTimeout(()=>{z(D+1)},240))}})]},O.id):(0,Q.jsxs)(K.div,{initial:!1,children:[t?(0,Q.jsx)(`p`,{className:`mt-1 leading-5 text-muted-foreground`,children:t}):null,n?(0,Q.jsx)(`div`,{className:`mt-3`,children:n}):null]},`description`)}),k?(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,Q.jsx)(He,{variant:`ghost`,size:`icon`,"aria-label":`Previous question`,disabled:j||D===0,onClick:()=>z(D-1),className:`rounded-full`,children:(0,Q.jsx)(bn,{className:`size-4`})}),(0,Q.jsx)(yu,{current:D,ids:r.map(e=>e.id)}),(0,Q.jsx)(He,{size:D===r.length-1?`sm`:`icon`,"aria-label":D===r.length-1?`Submit response`:`Next question`,disabled:j||!_u(N),onClick:()=>{if(D<r.length-1){z(D+1);return}d?.(E)},className:`ml-auto rounded-full`,children:j?(0,Q.jsx)(mr,{className:q(`size-4`,!b&&`animate-spin`)}):D===r.length-1?(0,Q.jsxs)(Q.Fragment,{children:[_,(0,Q.jsx)(Ya,{className:`size-3.5`})]}):(0,Q.jsx)(Ya,{className:`size-4`})})]}):(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(He,{size:`sm`,disabled:j,onClick:f,className:`rounded-full`,children:g}),m?(0,Q.jsx)(He,{variant:`secondary`,size:`sm`,disabled:j,onClick:m,className:`rounded-full`,children:`Request changes`}):null,p?(0,Q.jsx)(He,{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,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:v??I})]})]})})}function xu({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,Q.jsxs)(`div`,{className:q(`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,Q.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,Q.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Kn,{className:`h-3.5 w-3.5`}),`Question`]}),s&&(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,Q.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,Q.jsx)(fr,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[a,` of `,i]}),(0,Q.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,Q.jsx)(Qn,{className:`h-3.5 w-3.5`})})]})]}),(0,Q.jsx)(bu,{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,Q.jsx)(`div`,{className:`border-t border-border bg-background px-3 py-2`,children:(0,Q.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 Su=(0,Z.memo)(function({modes:e,value:t,defaultValue:n,onChange:r,className:i}){let a=t!==void 0,[o,s]=(0,Z.useState)(n),c=a?t:o,l=e.find(e=>e.id===c)??e[0],[u,d]=(0,Z.useState)(!1),f=(0,Z.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,Q.jsxs)(`button`,{type:`button`,className:q(`relative inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full px-2 text-[12px] 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,Q.jsx)(p,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:l?.label}),m&&(0,Q.jsx)(Qn,{className:`size-3 text-foreground/40`})]});return m?(0,Q.jsx)(Bc,{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,Q.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),className:q(`flex w-full cursor-pointer items-start gap-2 rounded-[6px] px-2 py-2 text-left text-[12px] 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,Q.jsx)(n,{className:`mt-0.5 size-3.5 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium`,children:e.label}),e.description&&(0,Q.jsx)(`span`,{className:`block truncate text-foreground/40`,children:e.description})]}),t&&(0,Q.jsx)(Zn,{className:`mt-0.5 size-3.5 shrink-0 text-foreground/60`})]},e.id)})}):h});Array.from({length:14},(e,t)=>t);function Cu(e,t){return(0,Z.useMemo)(()=>{if(!t||!e.startsWith(`/`))return[];let n=e.slice(1).toLowerCase();return t.filter(e=>e.name.startsWith(n))},[t,e])}function wu(e,t){return(0,Z.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 Tu({open:e,align:t=`start`,className:n,...r}){return(0,Q.jsx)(`div`,{"data-slot":`composer-menu`,"data-open":e||void 0,className:q(Xr,`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 Eu({active:e=!1,className:t,...n}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`composer-menu-item`,"data-active":e||void 0,className:q(`flex w-full items-center gap-2.5 rounded-[10px] px-2.5 py-2 text-[13.5px] transition-colors`,e?Zr:`hover:bg-foreground/[0.04]`,t),...n})}function Du(e,t){return t.icon?t.icon:e===`mention`?t.metadata?.kind===`folder`?(0,Q.jsx)(Pr,{"aria-hidden":`true`,className:`size-4`}):(0,Q.jsx)(Nr,{"aria-hidden":`true`,className:`size-4`}):(0,Q.jsx)(to,{"aria-hidden":`true`,className:`size-4`})}function Ou(e,t){return e&&e.length>0?e.flatMap(e=>e.items):t?[...t]:[]}var ku=(0,Z.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,Z.useMemo)(()=>Ou(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,Q.jsxs)(Eu,{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:q(`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,Q.jsx)(`span`,{className:`mt-0.5 shrink-0 text-muted-foreground`,children:Du(t,e)}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-muted-foreground`,children:e.description}):null]}),r?(0,Q.jsx)(dr,{"aria-hidden":`true`,className:`mt-1 size-3.5 shrink-0 text-muted-foreground`}):null]},e.id)};return e?(0,Q.jsxs)(Tu,{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:q(`inset-x-0 z-50 mb-2 w-auto overflow-hidden rounded-xl border bg-popover text-popover-foreground shadow-xl`,u),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2 text-xs text-muted-foreground`,children:[l?(0,Q.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,Q.jsx)(nr,{"aria-hidden":`true`,className:`size-3.5`})}):null,(0,Q.jsx)(Hr,{"aria-hidden":`true`,className:`size-3.5`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:f??(t===`slash`?`Commands`:`Workspace`)}),n?(0,Q.jsx)(`span`,{className:`ml-auto max-w-[50%] truncate font-mono text-[11px]`,children:n}):null,c?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Close suggestions`,onClick:c,className:`sr-only`,children:`Close suggestions`}):null]}),(0,Q.jsxs)(`div`,{className:`max-h-[min(42vh,360px)] overflow-y-auto p-1.5`,children:[m.length===0?(0,Q.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,Q.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,Q.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),e.items.map((e,n)=>_(e,t+n))]},e.id)}):m.map(_)]})]}):null}),Au=(0,Z.lazy)(()=>Gr(async()=>{let{ModelSelectorList:e}=await import(`./model-selector-list-DQaPFUYt.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 ju(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`h-24 animate-pulse rounded-md bg-muted/40 p-1.5`,"aria-label":`Loading models`,role:`status`}),children:(0,Q.jsx)(Au,{...e})})}var Mu=(0,Z.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,Z.useState)(!1),p=(0,Z.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,Q.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-expanded":m,"aria-controls":p,"aria-haspopup":`dialog`,"aria-label":`Select model and reasoning effort`,className:q(`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,Q.jsx)(`span`,{className:`shrink-0`,children:g.icon}):null,(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:g?.name??s}),_&&g?.reasoning?(0,Q.jsxs)(`span`,{className:`hidden shrink-0 text-muted-foreground/70 xl:inline`,children:[`· `,_.name]}):null,(0,Q.jsx)(Qn,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]});return(0,Q.jsx)(Bc,{contentId:p,open:m,onOpenChange:h,side:`top`,align:`start`,className:q(`w-[min(24rem,calc(100vw-2rem))] max-h-[min(55vh,28rem)] overflow-hidden p-0`,u),trigger:v,children:m?(0,Q.jsx)(ju,{models:e,selectedModel:g,selectedEffort:_,effortLabel:c,onModelChange:a,onEffortChange:o}):null})});function Nu(e){let[t,n]=(0,Z.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,Z.useCallback)(()=>{if(d){if(e?.onPreviousQuestion){e.onPreviousQuestion();return}n(e=>Math.max(1,e-1))}},[d,e]),goToNextQuestion:(0,Z.useCallback)(()=>{if(f){if(e?.onNextQuestion){e.onNextQuestion();return}n(e=>Math.min(o,e+1))}},[f,e,o]),advanceQuestionIndex:(0,Z.useCallback)(()=>{n(e=>Math.min(o,e+1))},[o])}}var Pu=[];function Fu(e){return e?Array.isArray(e)?e:e.items:[]}function Iu(e){return(e.value??e.id).trim().replace(/^\/+/,``).split(/\s+/,1)[0]??e.id}function Lu(e){return(e.value?.trim()??``).match(/^\/\S+\s+(.+)$/)?.[1]}function Ru({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=Pu,workspaceSuggestions:p,onWorkspaceReferenceSelect:m,onRemoveWorkspaceReference:h,controlled:g,disabled:_,questionBar:v,attachments:y,slashCommands:b}){let[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(null),T=g?.value??x,E=g?.onChange??S,D=t===`streaming`||t===`submitted`,O=Nu(v),k=Fu(b),A=Fu(p),j=(0,Z.useMemo)(()=>k.map(e=>({name:Iu(e),description:[e.description,Lu(e)].filter(Boolean).join(` `),icon:Hr})),[k]),M=(0,Z.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`,R=Cu(T,j),z=wu(T,M),B=(0,Z.useMemo)(()=>{let e=new Set(R.map(e=>e.name));return k.filter(t=>e.has(Iu(t)))},[k,R]),V=(0,Z.useMemo)(()=>{let e=new Set(z.map(e=>e.id).filter(e=>!!e));return A.filter(t=>e.has(t.id))},[z,A]),H=L===`slash`?B:V,[U,W]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{W(0)},[L,F,I,H.length]);let G=(0,Z.useCallback)((e,t=!1)=>{if(s?.(e)===!0){E(``);return}a({role:`user`,content:e,altKey:t}),E(``)},[s,a,E]),ee=(0,Z.useCallback)(e=>{if(o?.(e)===!0){E(``);return}E(e.value??e.label)},[o,E]),te=(0,Z.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]),ne=(0,Z.useCallback)(e=>{m?.(e),E(te(P))},[m,te,E,P]),re=(0,Z.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(te(L===`slash`?N:P));return}if(t&&H.length>0){if(e.key===`ArrowDown`){e.preventDefault(),W(e=>(e+1)%H.length);return}if(e.key===`ArrowUp`){e.preventDefault(),W(e=>(e-1+H.length)%H.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=H[U];t&&(L===`slash`?ee(t):ne(t));return}}if(e.key===`Enter`&&e.altKey&&!e.shiftKey){e.preventDefault();let t=T.trim();t&&!_&&G(t,!0)}},[U,_,D,h,te,ee,ne,G,E,N,H,L,T,P,f]),ie=v&&v.id!==C,ae=y?.files??[],oe=y?.images??[],se=!!(L&&!D&&!_),ce=(0,Z.useMemo)(()=>{if(L!==`slash`)return[];let e=new Map;for(let t of B){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,Lu(e)].filter(Boolean).join(` · `)}))}))},[B,L]),le=(0,Z.useMemo)(()=>e.map(e=>({id:e.id,name:e.name,provider:e.provider,providerLabel:Nn(e.provider),modelId:e.modelId,icon:(0,Q.jsx)(kn,{provider:e.provider,className:`size-4`}),disabled:e.available===!1,reasoning:e.reasoning,keywords:[e.provider,e.modelId,e.id],efforts:wr(e).map(e=>({id:e,name:Tr(e)}))})),[e]);return{activeTriggerIndex:U,combinedPickerOpen:c===!0||u===!0,commandGroups:ce,files:ae,handleCombinedPickerOpenChange:(0,Z.useCallback)(e=>{l?.(e),d?.(e)},[d,l]),handlePromptKeyDown:re,handleSelectorModelChange:(0,Z.useCallback)(t=>{let a=e.find(e=>e.id===t);r(t),a&&i?.(yr(n,wr(a)))},[e,r,i,n]),images:oe,isStreaming:D,navigation:O,selectorModels:le,selectCommand:ee,selectWorkspaceReference:ne,removeTriggerToken:te,send:G,setActiveTriggerIndex:W,setDismissedQuestionId:w,setValue:E,showQuestion:ie,triggerItems:H,triggerKind:L,triggerOpen:se,slashMatch:N,slashQuery:F,workspaceMentionMatch:P,workspaceQuery:I,filteredCommands:B,filteredWorkspaceItems:V,value:T}}var zu=[{id:`agent`,label:`Agent`,icon:Xn,description:`Default coding agent`},{id:`plan`,label:`Plan`,icon:Un,description:`Plan before executing`},{id:`harness`,label:`Harness`,icon:fo,description:`Harness-aware turn`}],Bu=[],Vu=[...zu];function Hu(e){return(0,Q.jsx)(Uu,{...e})}function Uu({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:_=Bu,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:R,filteredWorkspaceItems:z,removeTriggerToken:B,selectCommand:H,selectWorkspaceReference:U,selectorModels:W,send:G,setActiveTriggerIndex:ee,setDismissedQuestionId:te,setValue:ne,showQuestion:re,slashMatch:ie,slashQuery:ae,triggerItems:oe,triggerKind:se,triggerOpen:ce,value:le,workspaceMentionMatch:ue,workspaceQuery:de}=Ru({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}),fe=(0,Z.useCallback)(e=>a?.(e),[a]),pe=(0,Z.useCallback)(e=>c?.(e),[c]);return(0,Q.jsx)(`div`,{className:q(`shrink-0 px-3 pb-3`,O),children:(0,Q.jsxs)(`div`,{className:`relative mx-auto w-full max-w-an`,children:[(0,Q.jsx)(iu,{label:r??void 0,isActive:L}),re?(0,Q.jsx)(xu,{questionBar:E,navigation:R,roundedTop:!0,onDismiss:te}):null,(0,Q.jsx)(ku,{open:ce,kind:se??`slash`,query:se===`slash`?ae:de,items:se===`mention`?z:void 0,groups:se===`slash`?j:void 0,activeIndex:k,onActiveIndexChange:ee,onSelect:e=>{se===`slash`?H(e):U(e)},onClose:()=>ne(B(se===`slash`?ie:ue)),title:se===`slash`?`Commands`:`Workspace references`,listId:`fleet-composer-trigger-list`}),I.length>0||M.length>0?(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2 rounded-xl border bg-muted/40 p-2`,children:[I.map(e=>(0,Q.jsxs)(`div`,{className:`group relative`,children:[(0,Q.jsx)(`img`,{src:e.url,alt:e.filename,width:64,height:64,loading:`lazy`,className:`size-16 rounded-lg border object-cover`}),(0,Q.jsx)(V,{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,Q.jsx)(Wr,{"data-icon":`inline-start`,className:`size-3`})})]},e.id)),M.map(e=>(0,Q.jsx)(or,{id:e.id,filename:e.filename,size:e.size,onRemove:T?.onRemoveFile?()=>T.onRemoveFile?.(e.id):void 0},e.id))]}):null,_.length>0?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5 rounded-xl border bg-muted/40 p-2`,children:_.map(e=>(0,Q.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,Q.jsx)(hr,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`max-w-[min(28rem,70vw)] truncate`,children:[`@`,e.relativePath]}),(0,Q.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,Q.jsx)(Wr,{className:`size-3`})})]},e.relativePath))}):null,(0,Q.jsx)(Ue,{id:`fleet-composer-prompt`,name:`prompt`,value:le,onValueChange:ne,onSubmit:e=>G(e),loading:L,submitWhileLoading:!0,onStop:l,disabled:S,autoFocus:C,placeholder:w??`Send a message…`,onPaste:T?.onPaste,"aria-controls":ce?`fleet-composer-trigger-list`:void 0,"aria-expanded":ce,"aria-haspopup":`listbox`,"aria-activedescendant":ce&&oe[k]?`fleet-composer-trigger-list-${oe[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,Q.jsx)(ro,{})}]:[],onAction:e=>{e===`attach`&&T?.onAttach?.()},onKeyDown:P,leadingAction:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Su,{modes:Vu,value:i,onChange:fe}),(0,Q.jsx)(Mu,{models:W,value:e,effort:s,onModelChange:F,onEffortChange:pe,open:A,onOpenChange:N,placeholder:`Model`,className:`rounded-full`})]})})]})})}var Wu=`Fleet Prime is not connected to the Prime Agent runtime. Start or reconnect the runtime, then try again.`;function Gu(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:Wu}:{title:`Request failed`,message:e.message.replace(/\s+(?:Socket|Daemon log):\s*[^\n]*(?:\s+(?:Socket|Daemon log):\s*[^\n]*)*/gi,``)}}var Ku=(0,Z.lazy)(()=>Gr(async()=>{let{FleetPiToolRenderer:e}=await import(`./fleet-pi-tool-renderer-AJoMbXBa.js`).then(e=>e.n);return{FleetPiToolRenderer:e}},__vite__mapDeps([22,1,2,3,4,5,23,6,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 qu(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`h-7 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading tool`}),children:(0,Q.jsx)(Ku,{...e})})}var Ju=(0,Z.lazy)(()=>Gr(async()=>{let{AgentActivity:e}=await import(`./agent-activity-CDcDNVC6.js`);return{AgentActivity:e}},__vite__mapDeps([54,1,2,3,4,5,23,6,8,7,25,35,44,55,56,17,45,30,31,33,37])).then(({AgentActivity:e})=>({default:e})));function Yu(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`mt-2 h-8 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading activity`}),children:(0,Q.jsx)(Ju,{...e})})}var Xu=(0,Z.lazy)(()=>Gr(async()=>{let{FleetReasoningPanel:e}=await import(`./fleet-reasoning-panel-MtbSdoCv.js`);return{FleetReasoningPanel:e}},__vite__mapDeps([57,1,2,3,6,25,8,51,14,12,15,21,52,53])).then(({FleetReasoningPanel:e})=>({default:e})));function Zu(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`mb-2 h-6 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading reasoning`}),children:(0,Q.jsx)(Xu,{...e})})}var Qu=(0,Z.lazy)(()=>Gr(async()=>{let{FleetToolTimeline:e}=await import(`./fleet-tool-timeline-COzPrwr8.js`).then(e=>e.n);return{FleetToolTimeline:e}},__vite__mapDeps([58,1,2,3,6,8,25,46,31])).then(({FleetToolTimeline:e})=>({default:e})));function $u(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`h-6 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading timeline`}),children:(0,Q.jsx)(Qu,{...e})})}var ed=(0,Z.lazy)(()=>Gr(async()=>{let{FleetSubagentList:e}=await import(`./fleet-subagent-list-BnRnrWKS.js`).then(e=>e.n);return{FleetSubagentList:e}},__vite__mapDeps([59,1,2,3,6,25,8,26,60,40,27])).then(({FleetSubagentList:e})=>({default:e})));function td(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`h-6 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading subagents`}),children:(0,Q.jsx)(ed,{...e})})}var nd=(0,Z.lazy)(()=>Gr(async()=>{let{PromptSuggestions:e}=await import(`./prompt-suggestions-CXM6knMK.js`);return{PromptSuggestions:e}},__vite__mapDeps([61,3,1,6,2,52])).then(({PromptSuggestions:e})=>({default:e})));function rd(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`h-8 animate-pulse rounded-full bg-muted/40`,"aria-label":`Loading suggestions`}),children:(0,Q.jsx)(nd,{...e})})}var id=(0,Z.lazy)(()=>Gr(async()=>{let{FleetMessageQueue:e}=await import(`./fleet-message-queue-zWM5-y18.js`);return{FleetMessageQueue:e}},__vite__mapDeps([62,3,1,6,2,16,8,63,64,12,13,14,26,65])).then(({FleetMessageQueue:e})=>({default:e})));function ad(e){return(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(id,{...e})})}function od(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(`
3
-
4
- `)}function sd(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function cd(e,...t){let n=sd(e);for(let e of t){let t=n?.[e];if(typeof t==`string`&&t.trim())return t}}function ld(e){for(let t of[...e].reverse())for(let e of[...t.parts??[]].reverse()){let t=sd(e);if(t?.type!==`tool-FleetReasoning`)continue;let n=sd(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 ud(e){return/^(.*)-a\d+$/.exec(e)?.[1]}function dd(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=sd(e);return typeof t?.toolCallId==`string`&&t.toolCallId?[t.toolCallId]:[]}))),i=new Set(t.flatMap(e=>{let t=ud(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 fd(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=sd(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=sd(s.input)??sd(s.args);if(l===`websearch`||l===`grep`||l===`glob`){i.set(u,{id:u,type:`search`,query:cd(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:cd(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 pd({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,Z.useMemo)(()=>e.flatMap((n,o)=>sr(rr((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:qu,TextRendererComponent:lr,toolRenderers:i,onOpenUIAction:a,onOpenUIArtifactReady:u,onOpenArtifact:l})),[t,d,e,l,a,u,r,i]),p=e.flatMap(e=>{let t=od(e);return t?[t]:[]}).join(`
5
-
6
- `),m=(0,Z.useMemo)(()=>fd(e,s,c,l),[c,e,l,s]),h=(0,Z.useMemo)(()=>ld(e),[e]),g=(0,Z.useMemo)(()=>t?dd(c,e):[],[c,t,e]),[_,v]=(0,Z.useState)(d),[y,b]=(0,Z.useState)(d);return y!==d&&(b(d),v(d)),(0,Q.jsx)(cr,{from:`assistant`,animateIn:!d,children:(0,Q.jsx)(er,{children:(0,Q.jsx)(ur,{variant:`ghost`,children:(0,Q.jsxs)(tr,{children:[h?(0,Q.jsx)(Zu,{presentation:h,className:`mb-2`}):null,t&&gd(o)?(0,Q.jsx)(Xl,{label:o,className:`mb-2`}):null,(0,Q.jsx)($u,{messages:e,artifacts:g,streaming:d}),(0,Q.jsx)(Kl,{status:d?`streaming`:`complete`,copyText:p||void 0,announce:!1,contentClassName:`flex flex-col gap-3`,children:f}),m.length>0?(0,Q.jsx)(Yu,{items:m,status:d?`working`:`complete`,open:_,onOpenChange:v,activeLabel:$l(m),summary:eu(m),collapseOnComplete:!0,maxHeight:208,className:`mt-2 max-w-none`}):null,t&&s?(0,Q.jsx)(td,{children:s.rlmChildren,tree:s.rlmTree}):null]})})})})}function md(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var hd=(0,Z.memo)(function({turn:e,state:t,rendering:n,activity:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 400px`},children:[e.user?(0,Q.jsx)(cr,{from:`user`,animateIn:!t.isStreaming,children:(0,Q.jsx)(er,{children:(0,Q.jsx)($n,{message:e.user})})}):null,e.assistants.length>0?(0,Q.jsx)(pd,{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&&md(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 gd(e){return e?/queued|steered|retry|compact|reset|recover|sign in/i.test(e):!1}function _d(e){return Array.isArray(e)?e:e?.items??[]}function vd({inputBar:e,status:t,suggestions:n,onSend:r,onStop:i,isEmpty:a,draftSetterRef:o}){let[s,c]=(0,Z.useState)(``);return(0,Z.useEffect)(()=>{o.current=c},[o]),(0,Q.jsx)(Hu,{...e,className:q(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 yd=(0,Z.memo)(vd);function bd({toolRenderers:e=Hn,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:_}){let v=(0,Z.useRef)(null),y=(0,Z.useCallback)(e=>v.current?.(e),[]),b=(0,Z.useMemo)(()=>ar(s),[s]),x=_d(t),S=(0,Z.useMemo)(()=>x.flatMap(e=>e.disabled?[]:[e.value??e.label]),[x]),C=S.join(`\0`),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(C);E!==C&&(D(C),T(null));let O=n===`streaming`||n===`submitted`,k=(0,Z.useMemo)(()=>({toolRenderers:e,onOpenUIAction:u,onOpenUIArtifactReady:h,onOpenArtifact:m}),[m,u,h,e]),A=(0,Z.useMemo)(()=>({isLast:!0,isStreaming:O,suppressQuestionTool:l}),[O,l]),j=(0,Z.useMemo)(()=>({isLast:!1,isStreaming:!1,suppressQuestionTool:l}),[l]),M=(0,Z.useMemo)(()=>({label:d,presentation:f,artifactRuns:p}),[d,p,f]),N=(0,Z.useMemo)(()=>({label:void 0,presentation:void 0,artifactRuns:void 0}),[]),P=b.length===0&&!c,F=c?Gu(c):null,I=(0,Q.jsx)(yd,{inputBar:a,status:n,suggestions:t,onSend:i,onStop:r,isEmpty:P,draftSetterRef:v});return(0,Q.jsxs)(`div`,{className:q(`fleet-pi-agent-chat flex h-full min-h-0 flex-col bg-background`,o),children:[(0,Q.jsxs)(ir,{className:`flex-1`,busy:O,followOutput:!0,smooth:!O,contentClassName:q(`mx-auto flex w-full max-w-an flex-col gap-5 px-4`,P?`min-h-full items-center justify-center py-8`:`py-6`),children:[P?(0,Q.jsx)(nu,{disabled:O,onSelect:e=>y(e.value??e.label),composer:I}):null,b.map((e,t)=>{let n=e.user?.id??`assistant-turn-${t}`,r=t===b.length-1;return(0,Q.jsx)(hd,{turn:e,state:r?A:j,rendering:k,activity:r?M:N},n)}),F?(0,Q.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,Q.jsx)(pr,{className:`mt-0.5 size-4 shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:F.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs opacity-90`,children:F.message})]})]}):null,b.length>0&&S.length>0&&!O&&!c?(0,Q.jsx)(rd,{suggestions:S,selectedSuggestion:w,cycle:b.length,onSuggestion:e=>{T(e),y(e)},className:`px-0`}):null]}),P?null:I,(0,Q.jsx)(ad,{queue:g??{steering:[],followUp:[]},onDelete:_})]})}function xd({messages:e,status:t,error:n,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,queue:s,onDeleteQueuedMessage:c,onOpenArtifact:l,onOpenUIArtifactReady:u,inputSuggestionItems:d,suppressQuestionTool:f,inputBar:p,onSend:m,onOpenUIAction:h,onStop:g,onQuestionAnswer:_}){let v=(0,Z.useCallback)(e=>{m(e.content,e.altKey)},[m]),y=(0,Z.useCallback)(e=>{h(e)},[h]),b=(0,Z.useCallback)(({toolCallId:e,answer:t})=>{_({toolCallId:e,answer:t})},[_]),x=(0,Z.useMemo)(()=>({submitLabel:`Continue`,allowSkip:!0,onAnswer:b}),[b]);return(0,Q.jsx)(`div`,{className:`contents`,"data-fleet-chat-focus":!0,children:(0,Q.jsx)(si,{children:(0,Q.jsx)(bd,{messages:e,status:t,onSend:v,onOpenUIAction:y,onStop:g,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,queue:s,onDeleteQueuedMessage:c,onOpenArtifact:l,onOpenUIArtifactReady:u,questionTool:x,suppressQuestionTool:f,error:n??void 0,emptyStatePosition:`default`,suggestions:d,inputBar:p})})})}var Sd=[`/api/health`,`/api/chat`,`/api/projects`,`/api/workspace`];function Cd(){return``}function wd(e){return Sd.some(t=>e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`))}function Td(e){let t=Cd();if(!t)return e;let[n]=e.split(`?`);return wd(n)?`${t}${e}`:e}function Ed(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:Td(`/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 Dd=(0,Z.lazy)(()=>Gr(async()=>{let{ChatCommandPalette:e}=await import(`./chat-command-palette-DfYSPPXI.js`);return{ChatCommandPalette:e}},__vite__mapDeps([66,1,2,3,8,67,68,69,70,30,32,71,72,6,73,74,75,10,11,12,13,14,15,16,7,17,18,19,20,21])).then(({ChatCommandPalette:e})=>({default:e}))),Od=(0,Z.lazy)(()=>Gr(async()=>{let{SettingsDialog:e}=await import(`./settings-dialog-DS64KmwC.js`);return{SettingsDialog:e}},__vite__mapDeps([76,1,2,3,13,12,14,6,64,8,26,65,16,11,15,77,7,25,21,20,78,68,36,79,45,38,43,80,73,56,74,81,29,17,82,63,71,72,83,19])).then(({SettingsDialog:e})=>({default:e}))),kd=(0,Z.lazy)(()=>Gr(async()=>{let{ForkPickerDialog:e}=await import(`./fork-picker-dialog-CkcSekBl.js`);return{ForkPickerDialog:e}},__vite__mapDeps([84,3,1,11,2,12,13,14,6,15,16,8])).then(({ForkPickerDialog:e})=>({default:e})));function Ad({chrome:e,conversation:t,dialogs:n,panels:r,session:i}){return(0,Q.jsx)(Q.Fragment,{children:n.commandPaletteOpen?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Dd,{open:!0,onOpenChange:n.setCommandPaletteOpen,onNewSession:()=>void 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 jd({dialogs:e}){let{forkFromEntry:t,forkPickerEntries:n,setForkPickerEntries:r,setSettingsDialogOpen:i,setSettingsInitialTab:a,settingsDialogOpen:o,settingsInitialTab:s}=e,c=(0,Z.useCallback)(e=>{i(e),e||a(void 0)},[i,a]);return(0,Q.jsxs)(Q.Fragment,{children:[o?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Od,{open:!0,onOpenChange:c,initialTab:s})}):null,n?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(kd,{entries:n,onOpenChange:e=>{e||r(null)},onPick:t})}):null]})}var Md=`fleet-prime:v1:panel-keybindings`,Nd={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 Pd(){try{let e=window.localStorage.getItem(Md);if(!e)return Nd;let t=JSON.parse(e);return{...Nd,...t}}catch{return Nd}}function Fd(e,t){return e.code===t.code&&(e.ctrlKey||e.metaKey)===!!t.ctrlOrMeta&&e.shiftKey===!!t.shift&&e.altKey===!!t.alt}function Id(){document.querySelector(`[data-fleet-chat-focus] textarea, [data-fleet-chat-focus] [contenteditable='true'], [data-fleet-chat-focus] input`)?.focus({preventScroll:!0})}function Ld({onCommandPaletteToggle:e,onClosePanel:t,rightPanel:n,setRightPanel:r}){(0,Z.useEffect)(()=>{let i=Pd(),a=a=>{let o=e=>Fd(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),Id()):n&&o(`focusPanel`)?document.querySelector(`[data-fleet-panel-focus]`)?.focus({preventScroll:!0}):o(`focusChat`)?Id():s=!1,s&&(a.preventDefault(),a.stopPropagation())};return document.addEventListener(`keydown`,a),()=>document.removeEventListener(`keydown`,a)},[e,t,n,r])}function Rd(){return null}function zd(){return null}async function Bd(){}var Vd=X({key:Y(),provider:Y(),id:Y(),name:Y(),version:Y().optional(),reasoning:ai(),input:J(li([`text`,`image`])),contextWindow:di().optional(),maxTokens:di().optional(),available:ai(),defaultThinkingLevel:wi.optional(),thinkingLevels:J(wi).optional()}).openapi({description:`Chat model info`}),Hd=X({models:J(Vd),selectedModelKey:Y().optional(),defaultProvider:Y().optional(),defaultModel:Y().optional(),defaultThinkingLevel:wi.optional(),diagnostics:J(Y())}).openapi({description:`Chat models response`}),Ud=X({providerId:Y().min(1).max(128)}).openapi({description:`Discover models for a provider`}),Wd=X({providerId:Y(),models:J(Vd)}).openapi({description:`Discovered models for a provider`}),Gd=X({activationStatus:li([`active`,`staged`,`reload-required`]).optional(),name:Y(),description:Y().optional(),installedInWorkspace:ai().optional(),path:Y().optional(),source:Y().optional(),workspacePath:Y().optional(),argumentHint:Y().optional()}).openapi({description:`Chat resource info`}),Kd=X({packages:J(Gd),skills:J(Gd),prompts:J(Gd),extensions:J(Gd),themes:J(Gd),agentsFiles:J(Gd),diagnostics:J(Y())}).openapi({description:`Chat resources response`}),qd=oi(()=>X({name:Y(),path:Y(),type:li([`directory`,`file`]),children:J(qd).optional()})),Jd=X({root:Y(),nodes:J(qd),diagnostics:J(Y())}).openapi({description:`Workspace tree response`}),Yd=X({path:Y(),name:Y(),content:Y(),mediaType:li([`text/markdown`,`text/plain`,`application/octet-stream`]),size:di().optional(),status:li([`ok`,`too-large`,`unsupported`]).optional()}).openapi({description:`Workspace file preview response`}),Xd=X({name:Y(),path:Y()}).openapi({description:`Directory entry in the project-folder picker`}),Zd=X({path:Y(),parent:Y().nullable(),entries:J(Xd)}).openapi({description:`Workspace directory browse response`}),Qd=X({id:Y(),name:Y(),isConfigured:ai(),envVarName:Y(),authType:li([`apiKey`,`oauth`]).optional(),supportsOAuth:ai().optional(),providerFamily:Y().optional(),displayName:Y().optional(),api:li([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),baseUrl:Y().optional(),modelIds:J(Y().max(4096)).max(64).optional(),discoverable:ai().optional()}).openapi({description:`Chat provider info`}),$d=X({providers:J(Qd)}).openapi({description:`Chat providers response`}),ef=X({providerId:Y(),apiKey:Y().max(4096),baseUrl:Y().max(4096).optional(),modelId:Y().max(4096).optional(),displayName:Y().max(256).optional(),createOccInstance:ai().optional(),api:li([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),models:J(Y().max(4096)).max(64).optional()}).openapi({description:`Chat provider update request`}),tf=X({success:ai(),providers:J(Qd),reloadRequired:ai().optional()}).openapi({description:`Chat provider update response`}),nf=X({providerId:Y()}).openapi({description:`Chat provider remove request`});tf.openapi({description:`Chat provider remove response`});var rf=li([`waiting`,`success`,`error`]).openapi({description:`OAuth login status`}),af=X({message:Y(),placeholder:Y().optional(),allowEmpty:ai().optional()}).openapi({description:`Interactive OAuth prompt`}),of=X({providerId:Y().min(1),loginId:Y().min(1).optional(),promptAnswer:Y().max(8192).optional(),cancel:ai().optional()}).openapi({description:`Chat provider OAuth login request`}),sf=X({status:rf,loginId:Y().optional(),authUrl:Y().optional(),userCode:Y().optional(),instructions:Y().optional(),prompt:af.optional(),error:Y().optional(),providers:J(Qd).optional()}).openapi({description:`Chat provider OAuth login response`}),cf=X({name:Y(),description:Y().optional(),argumentHint:Y().optional(),source:li([`builtin`,`extension`,`prompt`,`skill`]),passThrough:ai().optional()}).openapi({description:`Chat slash command info`}),lf=X({commands:J(cf),diagnostics:J(Y())}).openapi({description:`Chat slash commands response`});X({message:Y()}).openapi({description:`Error response`}),X({status:ci(`ok`)}).openapi({description:`Health check response`});var uf=X({compaction:X({enabled:ai(),reserveTokens:Ni,keepRecentTokens:Ni}),defaultModel:Y().optional(),defaultProvider:Y().optional(),defaultThinkingLevel:wi.optional(),enableSkillCommands:ai(),enabledModels:J(yi).optional(),extensions:J(yi),followUpMode:vi,packages:J(Di),prompts:J(yi),retry:X({enabled:ai(),maxRetries:mi,baseDelayMs:mi}),skills:J(yi),steeringMode:vi,themes:J(yi),transport:bi}).openapi({description:`Editable Pi settings`}),df=X({compaction:uf.shape.compaction.partial().optional(),defaultModel:Y().optional(),defaultProvider:Y().optional(),defaultThinkingLevel:wi.optional(),enableSkillCommands:ai().optional(),enabledModels:J(yi).nullable().optional(),extensions:J(yi).optional(),followUpMode:vi.optional(),packages:J(Di).optional(),prompts:J(yi).optional(),retry:uf.shape.retry.partial().optional(),skills:J(yi).optional(),steeringMode:vi.optional(),themes:J(yi).optional(),transport:bi.optional()}).strict().openapi({description:`Pi settings update`}),ff=X({settings:df}).openapi({description:`Pi settings update request`}),pf=X({diagnostics:J(Y()),effective:uf,project:df,projectPath:Y(),updateImpact:X({newSessionRecommended:ai(),resourceReloadRequired:ai()})}).openapi({description:`Pi settings response`});function mf(){return null}var hf=class extends Error{status;body;code;remediation;constructor(e,t){super(vf(e,t)),this.name=`ChatRequestError`,this.status=e,this.body=t;let n=_f(t);this.code=n?.code,this.remediation=n?.remediation}};function gf(e){return typeof e==`object`&&!!e&&typeof e.action==`string`&&typeof e.label==`string`}function _f(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:gf(e.remediation)?e.remediation:void 0}}catch{}return null}function vf(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 yf(e){return(e instanceof hf?e.body:e instanceof Error?e.message:String(e)).includes(`Session belongs to another user`)}function bf(e){return e instanceof hf&&e.status===404}function xf(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 Sf(e){let t=Error(e.message);return e.code&&(t.code=e.code),t}async function Cf(e){let t=new Headers(e?.headers),n=await mf();return n&&t.set(`Authorization`,`Bearer ${n}`),t}async function wf(e,t){let n=Td(e),r=async e=>{let i=await Cf(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 hf(a.status,e)}return await a.json()};return r(!0)}async function Tf(e,t,n){return Df(t,await wf(e,n),`Response from ${e}`)}async function Ef(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=Df(_i,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(`
7
- `);for(;o>=0;)s(i.slice(0,o)),i=i.slice(o+1),o=i.indexOf(`
8
- `)}i+=r.decode(),s(i)}function Df(e,t,n){let r=e.safeParse(t);if(r.success)return r.data;throw Error(`${n} did not match the expected contract`)}function Of(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 kf(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}}var Af=X({project:ui}),jf={async abortSession(e){await wf(`/api/chat/abort`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async answerQuestion(e){return Tf(`/api/chat/question`,hi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async deleteQueuedMessage(e){let t=Ei.parse(e);return Tf(`/api/chat/session`,Ai,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},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 Tf(`/api/workspace/browse${r?`?${r}`:``}`,Zd)},async createSession(e,t){return Tf(`/api/chat/new`,Ci,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({openUI:!0,...e?{projectId:e}:{}}),signal:t})},async listProjects(){return Tf(`/api/projects`,ii)},async createProject(e){let t=fi.parse(e);return(await Tf(`/api/projects`,Af,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).project},async renameProject(e,t){let n=ri.parse({name:t});return(await Tf(`/api/projects?projectId=${encodeURIComponent(e)}`,Af,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})).project},async unregisterProject(e){return(await Tf(`/api/projects?projectId=${encodeURIComponent(e)}`,Af,{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 Tf(`/api/projects/browse${n?`?${n}`:``}`,ni)},async forkSessionIntoProject(e,t){let n=Pi.parse({sessionId:e,targetProjectId:t});return Tf(`/api/projects/fork`,pi,{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 Tf(`/api/chat/models${n?`?${n}`:``}`,Hd)},async discoverModels(e){return Tf(`/api/chat/models/discover`,Wd,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Ud.parse(e))})},async getResources(e){return Tf(`/api/chat/resources${e?`?projectId=${encodeURIComponent(e)}`:``}`,Kd)},async getCommands(e){return Tf(`/api/chat/commands${e?`?projectId=${encodeURIComponent(e)}`:``}`,lf)},async getSettings(e){return Tf(`/api/chat/settings${e?`?projectId=${encodeURIComponent(e)}`:``}`,pf)},async getWorkspaceTree(e){return Tf(`/api/workspace/tree${e?`?projectId=${encodeURIComponent(e)}`:``}`,Jd)},async getWorkspaceFile(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`projectId`,t),Tf(`/api/workspace/file?${n}`,Yd)},async listSessions(e){return(await Tf(`/api/chat/sessions${e?`?projectId=${encodeURIComponent(e)}`:``}`,Mi)).sessions},async renameSession(e,t){await wf(`/api/chat/sessions`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e,title:t})})},async deleteSession(e){await wf(`/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(Td(`/api/chat/session`),{method:`POST`,body:n});if(!r.ok)throw new hf(r.status,await r.text());return X({attachments:J(ti)}).parse(await r.json()).attachments},async loadSession(e){return Tf(`/api/chat/session?${Of({...e,openUI:!0})}`,Ci)},async loadSubagentSession(e,t){return Tf(`/api/chat/session?${new URLSearchParams({parentSessionId:e,childId:t})}`,Ci)},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)),Td(`/api/chat/events?${r}`)},async upsertPlanPresentation(e){let t=xi.parse(e);return Tf(`/api/chat/session`,X({presentation:ki}),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.presentation)},async upsertOpenUIArtifact(e){let t=ji.parse(e);return Tf(`/api/chat/artifacts`,Ti,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async resumeSession(e){return Tf(`/api/chat/resume`,Ci,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,openUI:!0})})},async updateSettings(e,t){let n=ff.parse(e);return Tf(`/api/chat/settings${t?`?projectId=${encodeURIComponent(t)}`:``}`,pf,{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 zd();o&&a.set(`Authorization`,`Bearer ${o}`);let s=await fetch(Td(`/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 hf(s.status,e)}await Ef(s,t)};await r(!0)},async getProviders(){return Tf(`/api/chat/providers`,$d)},async oauthLoginProvider(e){let t=of.parse(e);return Tf(`/api/chat/providers/oauth`,sf,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async updateProvider(e){let t=ef.parse(e);return Tf(`/api/chat/providers`,tf,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async removeProvider(e){let t=nf.parse(e);return Tf(`/api/chat/providers`,tf,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}},Mf={models:e=>[`chat`,`models`,e??`default`],modelCatalog:e=>[`chat`,`models`,`catalog`,e??`default`],providers:[`chat`,`providers`],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`]};function Nf(e){return oa({queryKey:Mf.models(e),queryFn:()=>jf.getModels({projectId:e})})}function Pf(){return oa({queryKey:Mf.projects,queryFn:()=>jf.listProjects(),staleTime:5e3})}function Ff(e){return oa({queryKey:Mf.modelCatalog(e?.projectId),queryFn:()=>jf.getModels({scope:`all`,projectId:e?.projectId}),enabled:e?.enabled})}function If(){let e=l();return sa({mutationFn:e=>jf.discoverModels({providerId:e}),onSuccess:()=>{e.invalidateQueries({queryKey:[`chat`,`models`]})}})}function Lf(e){return oa({queryKey:Mf.resources(e),queryFn:()=>jf.getResources(e)})}function Rf(e){return oa({queryKey:Mf.commands(e),queryFn:()=>jf.getCommands(e)})}function zf(e){return oa({queryKey:Mf.settings(e),queryFn:()=>jf.getSettings(e)})}function Bf(){let e=l();return sa({mutationFn:e=>jf.updateSettings(e.request,e.projectId),onSuccess:(t,n)=>{e.setQueryData(Mf.settings(n.projectId),t),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`resources`]}),e.invalidateQueries({queryKey:[`chat`,`commands`]})}})}function Vf(e,t){return oa({queryKey:Mf.workspace(e),queryFn:()=>jf.getWorkspaceTree(e),enabled:t?.enabled})}function Hf(){return oa({queryKey:Mf.providers,queryFn:()=>jf.getProviders()})}function Uf(){let e=l();return sa({mutationFn:e=>jf.updateProvider(e),onSuccess:t=>{e.setQueryData(Mf.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function Wf(){let e=l();return sa({mutationFn:e=>jf.oauthLoginProvider(e),onSuccess:t=>{t.status!==`success`||!t.providers||(e.setQueryData(Mf.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]}))}})}function Gf(){let e=l();return sa({mutationFn:e=>jf.removeProvider(e),onSuccess:t=>{e.setQueryData(Mf.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function Kf(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 qf(e){return e?.role!==`assistant`||!Array.isArray(e.parts)?!1:e.parts.some(e=>Kf(e))}var Jf=[{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`}],Yf={clear:`new`,usage:`context`,thinking:`effort`,rename:`name`,side:`btw`};function Xf(e){let t=wi.safeParse(e.trim().toLowerCase());return t.success?t.data:void 0}function Zf(e){return Yf[e]??e}function Qf(e){let t=e.trim().match(/^\/(\S+)(?:\s+(.*))?$/);if(!t)return null;let[,n=``,r=``]=t;return{command:n,args:r.trim()}}function $f(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 ep(e,t=``){let n=Zf(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=Xf(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:$f(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?$f(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 tp(e){let t=e.trim().replace(/\s+/g,`-`);return/^[\w.-]+$/.test(t)?t:``}function np(e){return{id:e.name,label:`/${e.name}`,value:`/${e.name}${e.argumentHint?` ${e.argumentHint}`:``} `,description:e.description,category:e.category??`builtin`}}function rp(e,t,n){let r=new Map;for(let e of Jf)r.set(e.name,np(e));for(let e of n?.commands??[])r.has(e.name)||r.set(e.name,np({...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=tp(e.name);!n||r.has(n)||r.set(n,{id:n,label:`/${n}`,value:`/${n} `,description:e.description,category:t})}return Array.from(r.values())}var ip={dismissedChildIds:new Set,scopeKey:``,selectedTabId:`main`};function ap(e,t){return e.scopeKey===t?e:{dismissedChildIds:new Set,scopeKey:t,selectedTabId:`main`}}function op(e,t){return ap(e,t)}function sp(e,t){if(t.type===`scope`)return ap(e,t.scopeKey);let n=ap(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 cp(e,t,n=crypto.randomUUID()){return{id:n,role:e,createdAt:Date.now(),parts:[{type:`text`,text:t}]}}function lp(e){return{...cp(`user`,e),optimistic:!0}}function up(e,t){return e.filter(e=>e.id!==t||e.optimistic!==!0)}function dp(e,t){return e.map(e=>{if(e.id!==t||e.optimistic!==!0)return e;let n={...e};return delete n.optimistic,n})}function fp(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 pp(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 mp(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 hp({messageId:e,presentation:t}){return{type:`tool-FleetReasoning`,toolCallId:`${e}-reasoning`,state:t.streaming?`input-streaming`:`output-available`,input:t}}function gp(e,t,n){return e.map(e=>e.id===t?{...e,parts:fp(e.parts,n)}:e)}function _p(e,t,n){return e.map(e=>e.id===t?{...e,parts:pp(e.parts,n)}:e)}function vp(e,t,n){return e.map(e=>e.id===t?{...e,parts:mp(e.parts,n)}:e)}function yp(e,t,n){return _p(e,t,hp({messageId:t,presentation:n}))}function bp(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 xp(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``)}var Sp={steering:[],followUp:[]};function Cp(e){let t=e.sessionId?.trim()||void 0,n=e.projectId?.trim()||void 0;return t||n?{...t?{sessionId:t}:{},...n?{projectId:n}:{}}:{}}function wp(e,t){let n=t.sessionId?.trim()||e.sessionId,r=t.projectId?.trim()||e.projectId;return{...n?{sessionId:n}:{},...r?{projectId:r}:{}}}function Tp(e){return(e.parts??[]).some(e=>e.type!==`text`||typeof e.text==`string`&&e.text.trim().length>0)}function Ep(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,cp(`assistant`,``,t)]}}}function Dp(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):[...e,t]}function Op(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 kp(e,t,n){if(!Tp(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=>Tp(e));if(r)return Dp(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 Ap(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:Sp,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.filter(e=>e.id!==t.child.id),t.child];return{...e,snapshot:{...e.snapshot,presentation:{...n,rlmChildren:r,...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=Ep(e,t.message.id);return{assistantId:n.assistantId,snapshot:{...n.snapshot,messages:kp(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,cp(`assistant`,``,t.id)],sessionMetadata:wp(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`?Ep(e,t.messageId):e,{assistantId:r,snapshot:i}=n;if(t.type===`delta`&&r)return{assistantId:r,snapshot:{...i,messages:gp(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:yp(i.messages,r,t.presentation)}};if(t.type===`tool`&&r)return{assistantId:r,snapshot:{...i,messages:_p(i.messages,r,t.part)}};if(t.type===`payload`&&r)return{assistantId:r,snapshot:{...i,messages:vp(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:kf(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=bp(t.message),n=Op(i.messages,e,r),a=kp(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=>bp(e)),queue:Sp,presentation:o,sessionMetadata:wp(i.sessionMetadata,{sessionId:t.sessionId})}}}return n}function jp(e){return e===`running`||e===`recovering`?`streaming`:e===`error`||e===`failed`?`error`:`ready`}function Mp(){return{status:`ready`,loading:!1,messages:[]}}function Np(e){return{assistantId:null,snapshot:{messages:e.messages,presentation:e.presentation,queue:Sp,sessionMetadata:e.session}}}function Pp(e){return typeof e==`object`&&!!e&&e.type===`connected`&&typeof e.sessionId==`string`}function Fp(e){if(!(typeof window>`u`))try{let t=window.sessionStorage.getItem(e);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){window.sessionStorage.removeItem(e);return}return{generation:n.generation,lastEventId:n.lastEventId}}catch{window.sessionStorage.removeItem(e);return}}function Ip({client:e,enabled:t,child:n,loadSession:r,parentSessionId:i}){let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(Mp),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(0),p=(0,Z.useRef)(null),m=n?.id,h=n?.activeSessionId,g=n?.status,_=n?.error,v=(0,Z.useCallback)(()=>o(e=>e+1),[]),y=(0,Z.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=lp(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 Sf(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=Np(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:up(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,Z.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,Z.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(Mp());return}let s=!1,u=null,p=null,y=0,b=!1,x=0,S,C=!1,w=jp(g),T=`pi:sse:cursor:subagent:${`${i}:${m}:${h??``}`}`,E=Fp(T);E&&(S=E.generation,x=E.lastEventId);let D=()=>{if(!(typeof window>`u`))try{if(!S){window.sessionStorage.removeItem(T);return}window.sessionStorage.setItem(T,JSON.stringify({generation:S,lastEventId:x}))}catch{}},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(bf(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=Np(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(Pp(n)){n.streamGeneration&&S!==n.streamGeneration?(S=n.streamGeneration,O()):n.streamGeneration&&(S=n.streamGeneration),n.cursorReset&&O(),D();return}let r;try{r=Df(_i,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=Ap(i,r);if(r.type===`error`){C=!0,k(),u?.close(),u=null,A(a,`error`,Sf(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 Lp(e){return kr(e.sessionName?.trim()||e.label)||`Subagent`}function Rp({activeProjectId:e,loadSubagentSession:t,presentation:n,rootSessionId:r,client:i=jf}){let a=`${e??``}:${r??``}`,[o,s]=(0,Z.useReducer)(sp,ip);(0,Z.useEffect)(()=>{s({type:`scope`,scopeKey:a})},[a]);let{dismissedChildIds:c,selectedTabId:l}=op(o,a),u=(0,Z.useMemo)(()=>Br(n.rlmChildren,n.rlmTree),[n.rlmChildren,n.rlmTree]),d=(0,Z.useMemo)(()=>[{id:`main`,label:`Main agent`,kind:`main`},...u.filter(e=>!c.has(e.id)).map(e=>({id:e.id,label:Lp(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,Z.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,Z.useCallback)(e=>{e===`main`||!u.some(t=>t.id===e)||s({type:`dismiss`,scopeKey:a,tabId:e})},[u,a]),g=(0,Z.useCallback)(e=>m(e),[m]);return{activeTabId:f,closeTab:h,conversation:Ip({client:i,child:p,enabled:f!==`main`&&!!p,loadSession:t,parentSessionId:r}),openChildTab:g,selectedChild:p,selectTab:m,tabs:d}}var zp=`fleet-prime:v1:right-panel-width`,Bp=`fleet-prime:v1:theme-preference`,Vp=320;function Hp(){return typeof window>`u`?Vp:Up()}function Up(){return typeof window>`u`?Vp:Math.max(Vp,Math.floor(window.innerWidth*Cr))}function Wp(e){return Math.min(Up(),Math.max(Vp,Math.round(e)))}function Gp(){return Dr(zp,Hp(),Wp)}function Kp(e){Or(zp,Wp(e))}function qp(){if(typeof window>`u`)return`system`;let e=window.localStorage.getItem(Bp);return e===`light`||e===`dark`||e===`system`?e:`system`}function Jp(e){typeof window>`u`||window.localStorage.setItem(Bp,e)}function Yp(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 Xp(e,t){let{sessionMetadata:n,setSessionMetadata:r}=t,i=(0,Z.useMemo)(()=>e?.models.map(jr)??[],[e]),[a,o]=(0,Z.useState)(),[s,c]=(0,Z.useState)(),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(`workspace`),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(()=>qp()),[b,x]=(0,Z.useState)(()=>Gp());(0,Z.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,Z.useEffect)(()=>{let t=i.find(e=>e.id===a);if(!t)return;let n=wr(t);c(t=>yr(t??e?.defaultThinkingLevel,n))},[i,a,e?.defaultThinkingLevel]),(0,Z.useEffect)(()=>{if(Yp(v),v!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>Yp(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[v]);let S=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=S.current;if(S.current=l,!l||e!==null)return;let t=Hp();x(t),Kp(t)},[l]),(0,Z.useEffect)(()=>{l===null&&h(null)},[l]),(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{x(e=>{let t=Wp(e);return Kp(t),t})};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[l]);let C=(0,Z.useCallback)(e=>{y(e),Jp(e),Yp(e)},[]),w=(0,Z.useCallback)(e=>{Ar({event:e,startWidth:b,getNextWidth:(e,t,n)=>Wp(n-(e-t)),onWidthChange:e=>{x(e),Kp(e)}})},[b]),T=(0,Z.useCallback)(()=>{u(d.current)},[]),E=(0,Z.useCallback)(e=>{if(e!==null&&(d.current=e),u(e),e===null){p(null);return}h(t=>{if(!t)return t;let n=qr(t);return!n||n.panel===e?t:null})},[]),D=(0,Z.useCallback)((e,t=`artifacts`)=>{p(e),E(t)},[E]),O=(0,Z.useCallback)(e=>{let t=qr(e);t&&(E(t.panel),h(t.path))},[E]),k=(0,Z.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,Z.useCallback)(e=>{r(e)},[r]),j=i.find(e=>e.id===a),M=yr(s??e?.defaultThinkingLevel,wr(j)),N=(0,Z.useCallback)(e=>{let t=i.find(e=>e.id===a);c(yr(e,wr(t)))},[a,i]);return{commandPaletteOpen:g,handleResourceCanvasResizeStart:w,handleThemePreferenceChange:C,initialSessionMetadata:n,modelKey:a,modelSelection:(0,Z.useMemo)(()=>xr(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 Zp=`fleet-prime:v1:chat-session`;function Qp(){let[e,t]=(0,Z.useState)(()=>$p()),n=(0,Z.useCallback)(e=>{t(e)},[]);return(0,Z.useEffect)(()=>{rm(e)},[e]),{sessionMetadata:e,setSessionMetadata:n}}function $p(){if(typeof window>`u`||!window.localStorage)return{};try{let e=window.localStorage.getItem(Zp);return e?tm(JSON.parse(e)):em()}catch{return em()}}function em(){if(typeof window>`u`||!window.localStorage)return{};let e=window.localStorage.getItem(`fleet-prime:v1:chat-sessions`);if(!e)return{};try{return tm(JSON.parse(e)?.normal)}catch{return{}}}function tm(e){let t=gi.safeParse(e);return t.success?t.data:{}}function nm(){typeof window>`u`||!window.localStorage||(window.localStorage.removeItem(Zp),window.localStorage.removeItem(`fleet-prime:v1:chat-sessions`),window.localStorage.removeItem(`fleet-prime:v1:chat-mode`))}function rm(e){if(!(typeof window>`u`||!window.localStorage)){if(!e.sessionId&&!e.projectId){window.localStorage.removeItem(Zp),window.localStorage.removeItem(`fleet-prime:v1:chat-sessions`);return}window.localStorage.setItem(Zp,JSON.stringify(e))}}function im({messages:e,resources:t,workspaceTree:n}){return(0,Z.useMemo)(()=>am({messages:e,resources:t,workspaceTree:n}),[e,t,n])}function am({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=sm([...e].reverse().find(e=>e.role===`user`)).toLowerCase(),c=sm(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`)]:om(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 om(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 sm(e){return e?e.parts.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(` `):``}var cm=`https://docs.qredence.ai`;function lm({className:e}){return(0,Q.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,Q.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 um({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,Q.jsx)(`div`,{className:q(`flex min-w-0 items-center gap-2`,a),children:(0,Q.jsx)(Bc,{side:`bottom`,align:`start`,trigger:(0,Q.jsxs)(ns,{ariaLabel:`Open account menu`,className:q(`min-w-0 border-transparent shadow-none`,r?`size-8 justify-center px-2`:`w-full justify-start`),children:[(0,Q.jsx)(lm,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:r?`sr-only`:`text-[13px] font-medium tracking-[-0.01em] whitespace-nowrap`,children:i}),(0,Q.jsx)(Qn,{className:`size-3.5 shrink-0 text-foreground/35`})]}),children:e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-label leading-4 text-foreground/50`,children:e.name||e.email}),(0,Q.jsxs)(`button`,{type:`button`,className:o,children:[(0,Q.jsx)(lm,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Account`})]}),(0,Q.jsxs)(`a`,{href:cm,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Q.jsx)(Jn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Documentation`})]}),n&&(0,Q.jsxs)(`button`,{type:`button`,className:o,onClick:n,children:[(0,Q.jsx)(yn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Settings`})]}),(0,Q.jsxs)(`button`,{type:`button`,className:o,onClick:()=>void t(),children:[(0,Q.jsx)(Vn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Sign out`})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`a`,{href:cm,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Q.jsx)(Jn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Documentation`})]}),n&&(0,Q.jsxs)(`button`,{type:`button`,className:o,onClick:n,children:[(0,Q.jsx)(yn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Settings`})]})]})})})}function dm({activeTabId:e,tabs:t,onCloseTab:n,onNewSession:r,onSelectTab:i,onOpenSettings:a}){let s=o(),c=Rd();return{left:(0,Q.jsx)(Ps,{"aria-label":`Toggle conversations`,className:`!size-7 !rounded-[7px] border border-border/70 bg-background shadow-sm`,children:(0,Q.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,Q.jsx)(um,{className:`w-full`,label:`Qredence`,user:c,onSignOut:async()=>{nm(),await Bd(),s({to:`/`})},onOpenSettings:a}),center:(0,Q.jsx)(xo,{tabs:t,value:e,onValueChange:i,onClose:n,onNewSession:r}),right:(0,Q.jsx)(is,{compact:!0})}}var fm=`/api/chat/command`;function pm(e){return e.sessionId?.trim()||void 0}function mm({sessionId:e,name:t}){let n=e.trim()||`none`;return[t?`Session: ${t}`:`Session`,` id: ${n}`].join(`
9
- `)}function hm(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 gm(e){let{entry:t}=e;if(t.type===`message`&&t.message){let e=t.message.role??`message`,n=hm(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 _m(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} ${gm(a)}`),r(a.children,i+1)}};return r(e,0),n}function vm(e,t){let n=_m(e,t);return n.length>0?n.join(`
10
- `):`(empty session tree)`}function ym(e){let t=[],n=[],r=e=>{for(let i of e){if(i.entry.type===`message`){let e={id:i.entry.id,preview:gm(i)};t.push(e),i.entry.message?.role===`user`&&n.push(e)}r(i.children)}};return r(e),n.length>0?n:t}function bm(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.role!==`assistant`||n.source===`local`)continue;let r=xp(n).trim();if(r)return r}}function xm(e){return e.flatMap(e=>{if(e.source===`local`)return[];let t=xp(e).trim(),n=`**${e.role}**\n\n${t}`;return n.trim().length>0?[n]:[]}).join(`
11
-
12
- ---
13
-
14
- `)}function Sm({appendLocalMessage:e,getMessages:t,getSessionMetadata:n,modelKey:r,models:i,onForkPicker:a,openSettings:o,onOpenUIRequest:s,resumeSession:c,sessions:l,setEffortPickerOpen:u,setModelKey:d,setModelPickerOpen:f,setThinkingLevel:p,startNewSession:m}){let h=(0,Z.useCallback)(async(e,t=``)=>{let r=pm(n());if(!r)return{ok:!1,error:`No active session — start a new one first.`};try{let n=await fetch(fm,{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]),g=(0,Z.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(Kr.success(r(a)),a.newSessionId!==`?`){await c({sessionId:a.newSessionId});return}e(r(a))},[e,c]),_=(0,Z.useCallback)(c=>{switch(c.type){case`open-model-picker`:return c.modelKey&&i.some(e=>e.id===c.modelKey)?(d(c.modelKey),Kr.success(`Model set to ${c.modelKey}`),!0):(u(!1),f(!0),!0);case`open-effort-picker`:return c.unknownLevel&&Kr.error(`Unknown thinking level '${c.unknownLevel}'.`),f(!1),u(!0),!0;case`set-thinking-level`:{let e=i.find(e=>e.id===r),t=wr(e);return t.includes(c.level)?(p(c.level),Kr.success(`Effort set to ${Tr(c.level)}`),!0):(Kr.error(`Unknown thinking level '${c.level}'. Available: ${t.join(`, `)}`),f(!1),u(!0),!0)}case`open-settings`:return o(c.tab),!0;case`new-session`:return m(),!0;case`openui-request`:return c.request?(s(c.request),!0):(e(`Usage: /openui <request>`),!0);case`session-info`:return(async()=>{let t=pm(n()),r=await h(`session`);if(!r.ok||!t){e(mm({sessionId:t??`none`,name:null}));return}e(mm({sessionId:t,name:typeof r.payload.name==`string`?r.payload.name:null}))})(),!0;case`session-rename`:return c.name?((async()=>{let t=await h(`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 h(`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 h(`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 h(`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?(g(h(`fork`,c.args),`Fork`,e=>`Forked → session ${e.newSessionId}. Selected text: ${e.selectedText}`),!0):((async()=>{let t=await h(`tree`);if(!t.ok){e(`Fork picker failed: ${t.error}`);return}let n=t.payload.tree,r=Array.isArray(n?.tree)?ym(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 g(h(`clone`),`Clone`,e=>`Cloned → session ${e.newSessionId}.`),!0;case`session-tree`:return(async()=>{let t=await h(`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(vm(n.tree,n.leafId??null))})(),!0;case`session-share`:return(async()=>{let n=xm(t());if(!n.trim()){e(`Nothing to share yet.`);return}await navigator.clipboard.writeText(n),Kr.success(`Transcript copied`),e(`Copied the transcript to the clipboard. GitHub Gist upload is TUI-only in this port.`)})().catch(e=>{Kr.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 l.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${l.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`:return o(`chat`),c.args&&e(`MCP: ${c.args}. Manage MCP connections with Fleet Prime CLI configuration.`),!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 h(`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=bm(t());if(!e){Kr.error(`No assistant message to copy`);return}await navigator.clipboard.writeText(e),Kr.success(`Last assistant message copied`)})().catch(e=>{Kr.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,h,g,t,n,r,i,a,o,s,l,u,d,f,p,m]),v=(0,Z.useCallback)(e=>{if(e.id===`openui`)return!1;let t=ep(e.id);return t?_(t):!1},[_]),y=(0,Z.useCallback)(e=>{let t=Qf(e);if(!t)return!1;let n=ep(t.command,t.args);return n?_(n):!1},[_]);return{applyLocalSlashAction:_,forkFromEntry:(0,Z.useCallback)(e=>{g(h(`fork`,e),`Fork`,e=>`Forked → session ${e.newSessionId}. Selected text: ${e.selectedText}`)},[h,g]),handleLocalSlashSubmit:y,handleSlashCommandSelect:v}}function Cm({messages:e,answerQuestion:t}){let n=(0,Z.useRef)(new Map);return(0,Z.useMemo)(()=>{let r=wm(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)=>Tm(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,Em(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 wm(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`&&Kf(t))return{part:t}}}}function Tm(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 Em(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 Dm(e){xf(e)||Kr.error(e instanceof Error?e.message:String(e))}function Om(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 km(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=Om(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=Om(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=Om(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 Am=`plan-mode-decision`;function jm(){return{enabled:!1,executing:!1,todos:[],pendingDecision:!1,pendingDecisionToolCallId:void 0}}function Mm(e,t,n){let r=Bm(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 Nm(e,t){if(!e.enabled)return{state:e,changed:!1};let n=km(t);return n.length===0?{state:e,changed:!1}:{state:{...Bm(e),todos:n,executing:!1,pendingDecision:!0,pendingDecisionToolCallId:void 0},changed:!0}}function Pm(e,t){return{enabled:e.mode===`plan`,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:e.pendingDecision,pendingDecisionToolCallId:e.pendingDecision?`${Am}-${t}`:void 0}}function Fm(e,t){return Im(e,Pm(t,e))}function Im(e,t){if(t.todos.length===0)return;let n=zm(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:Vm(t),status:r,todos:n.todos}}}}function Lm(e){return!!e?.startsWith(Am)}function Rm(e,t){if(!e.pendingDecision)return e;let n=`${Am}-${t}`;return e.pendingDecisionToolCallId===n?e:{...Bm(e),pendingDecisionToolCallId:n}}function zm(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 Bm(e){return{enabled:e.enabled,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:!!e.pendingDecision,pendingDecisionToolCallId:e.pendingDecisionToolCallId}}function Vm(e){let t=zm(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 Hm(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?Fm(e.id,t.state):void 0;return r?{...e,parts:pp(e.parts,r)}:e})}function Um(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 Wm(e){e.setSessionMetadataSynced({}),e.setMessagesSynced([]),e.setQueueSynced(Sp),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 Gm(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`),Dm(t)}return!0}async function Km(e,t,n){return Gm(e,yf,t,n)}async function qm(e,t,n){return Gm(e,bf,t,n)}function Jm({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,Z.useEffect)(()=>{if(n.current)return;n.current=!0;let p=new AbortController,m=!1;f(`ready`),o(null),u(Sp),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(Hm(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 Km(e,r,t)||await qm(e,r,t)||p.signal.aborted)return;let n=e instanceof Error?e:Error(String(e));o(n),f(`error`),Dm(n)}).finally(()=>{m=!0}),()=>{p.abort(),m||(n.current=!1)}},[e,t,n,r,i,a,o,s,c,l,u,d,f])}function Ym({client:e,presentationRef:t,sessionId:n,sessionMetadataRef:r,setActivityLabelSynced:i,setAdapterCapabilities:a,setMessagesSynced:o,setPresentationSynced:s,setQueueSynced:c,setSessionMetadataSynced:l,statusRef:u}){(0,Z.useEffect)(()=>{if(!n||typeof window>`u`)return;let d=`pi:sse:last-event-id:${n}`,f={current:void 0},p=Number.parseInt(window.sessionStorage.getItem(d)??`0`,10);Number.isNaN(p)&&(p=0);let m=null,h=null,g=!1,_=d=>{let p;try{p=JSON.parse(d.data)}catch{return}if(p.type===`presentation`){p.presentation.revision>(t.current?.revision??-1)&&s(p.presentation);return}if(p.type===`rlm`){let e=t.current,n=e.rlmChildren.find(e=>e.id===p.child.id);if(n&&n.timestamp>p.child.timestamp)return;s({...e,rlmChildren:[...e.rlmChildren.filter(e=>e.id!==p.child.id),p.child],...p.tree?{rlmTree:p.tree}:{}});return}if(u.current===`streaming`||u.current===`submitted`)return;let m=p;if(m.type===`connected`){f.current=m.adapterCapabilities,a(m.adapterCapabilities);return}if(p.type===`reasoning`){let e=p.messageId;if(!f.current?.features.includes(`reasoning-summary-v1`)||!e)return;o(t=>yp(t,e,p.presentation));return}if(p.type===`tool`&&p.part?.type===`tool-Question`){o(e=>{let t=p.part.toolCallId??``;if(e.some(e=>e.parts.some(e=>e.type!==`text`&&e.type!==`error`&&`toolCallId`in e&&e.toolCallId===t)))return e;let n={...p.part,type:`tool-Question`};return[...e,{id:crypto.randomUUID(),role:`assistant`,parts:[n],createdAt:new Date().toISOString()}]});return}if(p.type===`state`){i(typeof p.state?.message==`string`?p.state.message:void 0),p.state?.name===`agent_settled`&&e.loadSession({sessionId:n}).then(e=>{g||r.current.sessionId!==n||(o(Hm(e.messages,e.planPresentations)),s(e.presentation),l(e.session),c(Sp))}).catch(()=>void 0);return}p.type===`queue`&&c({steering:p.steering,followUp:p.followUp})},v=()=>{let e=new URLSearchParams({sessionId:n});p>0&&e.set(`lastEventId`,String(p)),m?.close();let t=new EventSource(Td(`/api/chat/events?${e}`));m=t,t.onmessage=e=>{if(g||m!==t)return;let n=Number.parseInt(e.lastEventId??``,10);!Number.isNaN(n)&&n>0&&(p=n,window.sessionStorage.setItem(d,String(n))),_(e)},t.onerror=()=>{g||m!==t||(t.close(),h&&clearTimeout(h),h=setTimeout(v,2e3))}};return v(),()=>{g=!0,m?.close(),h&&clearTimeout(h)}},[e,t,n,r,i,a,o,s,c,l,u])}function Xm(){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 Zm=Promise.resolve();function Qm({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,Z.useRef)(null),C=(0,Z.useRef)(new Set),w=(0,Z.useRef)(Zm),T=(0,Z.useRef)(void 0),E=(0,Z.useCallback)(e=>{for(let t of C.current)if(t.sessionId===e)return t},[]),D=(0,Z.useCallback)(e=>{for(let t of[...C.current])t.sessionId===e&&(C.current.delete(t),t.reject(Error(`Chat stream stopped before admission`)))},[]),O=(0,Z.useCallback)(e=>{T.current=e},[]),k=(0,Z.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(Hm(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]),A=(0,Z.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(o,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,o,u,d,g,y]),j=(0,Z.useCallback)((i,a,o,l)=>{if(i.type===`error`)throw Sf(i);if(i.type===`done`&&i.sessionReset){o!==d.current.sessionId&&u();return}let f;if(i.type===`done`&&l===`plan`){let e=Nm(Mm(jm(),l),xp(i.message)),n=Rm(e.state,i.message.id);f=e.changed?Im(i.message.id,n):void 0,f&&t.upsertPlanPresentation({sessionId:o,presentation:{assistantMessageId:i.message.id,state:zm(n)}}).catch(()=>void 0)}if(i.type===`start`){let e=E(o);e&&(C.current.delete(e),e.resolve())}if(o!==d.current.sessionId){i.type===`done`&&u();return}let m=Ap({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=>_p(e,i.message.id,f)),i.type===`start`&&b(`streaming`),i.type===`done`&&(b(`ready`),u())},[e,t,E,n,r,s,c,u,d,p,h,g,_,v,y,b]),M=(0,Z.useCallback)(async(e,n=`steer`,r)=>{let a=d.current.sessionId??(await A()).sessionId;if(!a)throw Error(`Unable to queue a message without a session`);let o=lp(e);h(e=>[...e,o]),m(null);let s=w.current,c=Xm(),l=s.catch(()=>void 0).then(async()=>{try{await E(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=>dp(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 Sf(e)}),c.resolve()}catch(e){throw c.reject(e),h(e=>up(e,o.id)),e}try{await u()}catch{}});w.current=c.promise.catch(()=>void 0),await l},[t,A,E,i,u,d,p,m,h,v]);return{enqueueDuringStream:M,handleStreamEvent:j,resetStreamAdmission:D,sendMessage:(0,Z.useCallback)(async({text:e,attachments:r,openUI:o,openUIArtifact:s,planAction:c,mode:g,altKey:_})=>{let v=e.trim();if(!v)return;if(x===`submitted`||x===`streaming`||E(d.current.sessionId)!==void 0){try{await M(v,_?`followUp`:`steer`,{attachments:r,mode:g,openUI:o,openUIArtifact:s,planAction:c})}catch(e){let t=e instanceof Error?e:Error(String(e));m(t),Dm(t)}return}m(null),p(void 0),b(`submitted`),n.current.length===0&&(v.length,d.current.sessionId);let y=lp(v);h(e=>[...e,y]);let S={current:null},w=Xm();w.sessionId=d.current.sessionId,C.current.add(w);let T=new AbortController;a.current=T;let D,O=!1;try{let e=await A(T.signal);if(T.signal.aborted)return;let a=e.sessionId;if(!a)throw Error(`Unable to start a session stream`);D=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),j(e,S,a,g),e.type===`done`&&e.requestKind===`session-command`&&d.current.sessionId===a&&h(e=>dp(e,y.id))},T.signal);let l=!1;try{l=await k(a)}catch{}d.current.sessionId===a&&(O||!l)&&b(`ready`),n.current.length}catch(e){if(C.current.delete(w)&&w.reject(e),h(e=>up(e,y.id)),T.signal.aborted)return;if(D&&d.current.sessionId!==D){u();return}let t={setError:m,setStatus:b};if(await Km(e,l,t)||await qm(e,l,t))return;let n=e instanceof Error?e:Error(String(e));m(n),b(`error`),Dm(n)}finally{C.current.delete(w)&&w.reject(Error(`Chat stream ended before admission`)),T.signal.aborted&&h(e=>up(e,y.id)),a.current===T&&(a.current=null),D&&T&&f.current.get(D)===T&&f.current.delete(D)}},[t,A,M,E,j,k,n,i,a,u,l,d,p,m,h,b,f,x]),setAdapterCapabilities:O}}function $m(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 eh(e,t,n){if(!Lm(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:$m(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 th(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 nh(e,t){let{client:n=jf,initialSessionMetadata:r,persistSession:i,projectId:a}=t,[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(`ready`),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(()=>r),[m,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(Sp),[S,C]=(0,Z.useState)(()=>({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]})),w=(0,Z.useRef)(r),T=(0,Z.useRef)(o),E=(0,Z.useRef)(f),D=(0,Z.useRef)(g),O=(0,Z.useRef)(v),k=(0,Z.useRef)(b),A=(0,Z.useRef)(0),j=(0,Z.useRef)(Promise.resolve()),M=(0,Z.useRef)(S),N=(0,Z.useRef)(null),P=(0,Z.useRef)(new Map),F=(0,Z.useRef)(c),I=(0,Z.useRef)(!1),L=(0,Z.useRef)(()=>Promise.resolve()),R=(0,Z.useCallback)(e=>{let t=typeof e==`function`?e(T.current):e;T.current=t,s(t)},[]),z=(0,Z.useCallback)(e=>{R(t=>[...t,{id:crypto.randomUUID(),role:`assistant`,source:`local`,createdAt:Date.now(),parts:[{type:`text`,text:e}]}])},[R]),B=(0,Z.useCallback)(e=>{let t=E.current,n=Cp(e);(t.sessionId!==n.sessionId||t.projectId!==n.projectId)&&(A.current+=1,E.current=n,p(n),i(n))},[i]),V=(0,Z.useCallback)(e=>{D.current=e,_(e)},[]),H=(0,Z.useCallback)(e=>{O.current=e,y(e)},[]),U=(0,Z.useCallback)(e=>{A.current+=1,k.current=e,x(e)},[]),W=(0,Z.useCallback)(()=>{A.current+=1},[]),G=(0,Z.useCallback)(e=>{M.current=e,C(e)},[]),ee=(0,Z.useCallback)(async e=>{let t=E.current.sessionId;if(!t)return;let r=await n.upsertOpenUIArtifact({sessionId:t,...e});return E.current.sessionId===t&&G(r.presentation),r.artifact.id},[n,G]),te=(0,Z.useCallback)(async()=>{let e=await n.listSessions();return h(e),e},[n]),ne=(0,Z.useCallback)(e=>Wm({client:n,projectId:e??a,refreshSessions:te,setActivityLabelSynced:V,setError:d,setMessagesSynced:R,setPlanLabelSynced:H,setPresentationSynced:G,setQueueSynced:U,setSessionMetadataSynced:B,setStatus:l}),[n,a,te,V,R,H,G,U,B]),re=(0,Z.useCallback)(async({toolCallId:e,answer:t})=>{if(Lm(e)){let r=eh(T.current,e,t);R(r);let i=Um(r,e);i&&E.current.sessionId&&await n.upsertPlanPresentation({sessionId:E.current.sessionId,presentation:i}).catch(()=>void 0);let a=t.selectedIds?.[0];if(a===`execute`){await L.current({text:`Execute the approved plan.`,mode:`agent`,planAction:`execute`,openUI:!0});let t=Um(T.current,e);t&&E.current.sessionId&&await n.upsertPlanPresentation({sessionId:E.current.sessionId,presentation:{...t,state:{...t.state,executing:!1}}}).catch(()=>void 0),t&&R(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 L.current({text:t.text?.trim()||`Refine the plan.`,mode:`plan`,planAction:`refine`,openUI:!0});return{ok:!0}}let r=await n.answerQuestion({sessionId:E.current.sessionId,toolCallId:e,answer:t});return r.message&&await L.current({text:r.message,planAction:r.planAction}),r},[n,R]),ie=(0,Z.useCallback)(e=>th(e,re),[re]);(0,Z.useEffect)(()=>{E.current=f},[f]),(0,Z.useEffect)(()=>{F.current=c},[c]),(0,Z.useEffect)(()=>{w.current=r},[r]),(0,Z.useEffect)(()=>{let e=P.current;return()=>{N.current?.abort(),N.current=null;for(let t of e.values())t.abort();e.clear()}},[]),(0,Z.useEffect)(()=>{let e=!1;return te().catch(t=>{if(e)return;let n=t instanceof Error?t:Error(String(t));d(n),Dm(n)}),()=>{e=!0}},[te]),Jm({client:n,initialSessionMetadataRef:w,initializedRef:I,recoverFromForbiddenSession:ne,refreshSessions:te,setActivityLabelSynced:V,setError:d,setMessagesSynced:R,setPlanLabelSynced:H,setPresentationSynced:G,setQueueSynced:U,setSessionMetadataSynced:B,setStatus:l});let{resetStreamAdmission:ae,sendMessage:oe,setAdapterCapabilities:se}=Qm({activityLabelRef:D,client:n,messagesRef:T,presentationRef:M,model:e,pendingSendControllerRef:N,projectId:a,planLabelRef:O,queueRef:k,recoverFromForbiddenSession:ne,refreshSessions:te,sessionMetadataRef:E,setActivityLabelSynced:V,setError:d,setMessagesSynced:R,setPresentationSynced:G,setPlanLabelSynced:H,setQueueSynced:U,setSessionMetadataSynced:B,setStatus:l,streamControllersRef:P,status:c}),ce=(0,Z.useCallback)(()=>{let e=E.current;ae(e.sessionId),N.current?.abort(),N.current=null,e.sessionId&&n.abortSession(e).catch(()=>void 0),e.sessionId&&(P.current.get(e.sessionId)?.abort(),P.current.delete(e.sessionId)),W(),l(`ready`),U(Sp),V(void 0)},[n,W,ae,V,U]),le=(0,Z.useCallback)((e,t,r)=>{let i=E.current.sessionId,a=A.current,o=(e===`steering`?k.current.steering:k.current.followUp).filter(e=>e===r).length,s=j.current.catch(()=>void 0).then(async()=>{if(!i||E.current.sessionId!==i)return!1;let s=k.current,c=e===`steering`?s.steering:s.followUp,l;if(A.current===a)l=c[t]===r?t:void 0;else{if(o!==1)return!1;let e=c.reduce((e,t,n)=>(t===r&&e.push(n),e),[]);l=e.length===1?e[0]:void 0}if(l===void 0)return!1;let u={...s,[e]:c.filter((e,t)=>t!==l)};U(u);let d=A.current;try{let t=await n.deleteQueuedMessage({sessionId:i,lane:e,index:l,expectedText:r});return E.current.sessionId!==i||A.current!==d||U(t.queue),t.status===`applied`}catch(e){throw E.current.sessionId===i&&A.current===d&&k.current===u&&U(s),e}});return j.current=s.then(()=>void 0,()=>void 0),s},[n,U]),ue=(0,Z.useCallback)(async e=>{e?.preserveRunning===!1?ce():(W(),l(`ready`));let t=await n.createSession(e?.projectId??a);B(t.session),R([]),G(t.presentation),U(Sp),V(void 0),H(void 0),Kr.success(`New session started`),await te()},[n,te,V,R,G,H,U,B,W,ce,a]),de=(0,Z.useCallback)(async(e,t)=>{W();try{t?.preserveRunning===!1&&ce();let r=await n.resumeSession(e);return B(r.session),R(Hm(r.messages,r.planPresentations)),G(r.presentation),U(Sp),V(r.sessionReset?`Started a fresh Pi session`:void 0),H(void 0),l(P.current.has(r.session.sessionId??``)?`streaming`:`ready`),await te(),!0}catch(t){let n={setError:d,setStatus:l},r=()=>ne(e.projectId);if(await Km(t,r,n)||await qm(t,r,n))return!1;let i=t instanceof Error?t:Error(String(t));return d(i),l(`error`),Dm(i),!1}},[n,ne,te,V,R,G,H,U,B,W,ce]),fe=(0,Z.useCallback)(async(e,t)=>t?de({sessionId:t,projectId:e},{preserveRunning:!0}):(W(),B({projectId:e}),R([]),G({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]}),U(Sp),V(void 0),H(void 0),l(`ready`),!0),[de,V,R,H,G,U,B,W]);(0,Z.useEffect)(()=>{L.current=oe},[oe]),Ym({client:n,presentationRef:M,sessionId:f.sessionId,sessionMetadataRef:E,setActivityLabelSynced:V,setAdapterCapabilities:se,setMessagesSynced:R,setPresentationSynced:G,setQueueSynced:U,setSessionMetadataSynced:B,statusRef:F});let pe=(0,Z.useMemo)(()=>ie(o),[o,ie]),me=(0,Z.useCallback)(async(e,t)=>{await n.renameSession(e,t),await te()},[n,te]),he=(0,Z.useCallback)(async e=>{let t=E.current.sessionId===e;t&&ce(),await n.deleteSession(e),t&&(B({}),R([]),G({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]})),await te()},[n,te,R,G,B,ce]),ge=re,_e=(0,Z.useCallback)(()=>E.current,[]);return{activityLabel:g,answerQuestion:ge,appendLocalMessage:z,deleteQueuedMessage:le,deleteSession:he,error:u,getMessages:(0,Z.useCallback)(()=>T.current,[]),getSessionMetadata:_e,messages:pe,planLabel:v,presentation:S,persistOpenUIArtifact:ee,queue:b,renameSession:me,refreshSessions:te,resumeSession:de,sendMessage:oe,sessionMetadata:f,sessions:m,setError:d,startNewSession:ue,status:c,stop:ce,switchProject:fe}}function rh({activityLabel:e,artifactRuns:t,chatMode:n,handleThemePreferenceChange:r,isLoadingProviders:i,isUpdatingProvider:a,loadSession:o,loadSubagentSession:s,loadWorkspaceFile:c,messages:l,onOpenSubagentTab:u,modelKey:d,models:f,modelCatalog:p,onDiscoverModels:m,onOAuthLogin:h,onRemoveProvider:g,onUpdateProvider:_,openWorkspacePath:v,planLabel:y,presentation:b,providers:x,queue:S,refreshResources:C,refreshWorkspace:w,resources:T,resourcesError:E,resourcesLoading:D,rightPanel:O,reopenRightPanel:k,saveSettings:A,selectedArtifactId:j,sessionId:M,selectedWorkspacePath:N,setRightPanel:P,setSelectedWorkspacePath:F,settings:I,settingsError:L,settingsLoading:R,status:z,thinkingLevel:B,themePreference:V,workspaceError:H,workspaceLoading:U,workspaceTree:W}){let G=(0,Z.useMemo)(()=>({activityLabel:e,artifactRuns:t,chatMode:n,loadSession:o,loadSubagentSession:s,messages:l,onOpenSubagentTab:u,models:f,planLabel:y,presentation:b,queue:S,refreshResources:C,resources:T,resourcesError:E,resourcesLoading:D,reopenRightPanel:k,rightPanel:O,selectedModelKey:d,selectedArtifactId:j,sessionId:M,setRightPanel:P,status:z,thinkingLevel:B}),[e,t,n,o,s,l,u,f,y,b,S,C,T,E,D,k,O,d,j,M,P,z,B]),ee=(0,Z.useMemo)(()=>({loadWorkspaceFile:c,openWorkspacePath:v,refreshWorkspace:w,selectedWorkspacePath:N,setSelectedWorkspacePath:F,workspaceError:H,workspaceLoading:U,workspaceTree:W}),[c,v,w,N,F,H,U,W]);return{chatPanelData:G,settingsActions:(0,Z.useMemo)(()=>({isLoadingProviders:i,isUpdatingProvider:a,modelCatalog:p,onDiscoverModels:m,onOAuthLogin:h,onRemoveProvider:g,onThemePreferenceChange:r,onUpdateProvider:_,providers:x,saveSettings:A,settings:I,settingsError:L,settingsLoading:R,themePreference:V}),[r,i,a,p,m,h,g,_,x,A,I,L,R,V]),workspaceTreeContext:ee}}var ih=`workspace:`;function ah(e,t=[]){for(let n of e)t.push(n),n.children&&ah(n.children,t);return t}function oh(e){return e?ah(e.nodes).map(e=>({id:`${ih}${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 sh(e){if(!e.id.startsWith(ih))return null;let t=e.id.slice(10);if(!t)return null;let n=Si.safeParse(t);return n.success?n.data:null}async function ch(e,t){return jf.getWorkspaceFile(e,t)}function lh(e,t){return e.sessionId!==t.sessionId||e.projectId!==t.projectId}function uh(e,t){return!!e.sessionId||t!==void 0&&t!==e.projectId}function dh(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 fh(){let e=Rd(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(void 0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`agent`),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(null),_=Qp(),[v,y]=(0,Z.useState)(_.sessionMetadata.projectId??void 0);(0,Z.useEffect)(()=>{},[e]);let{data:b,isLoading:x}=Hf(),{data:S,refetch:C}=Pf(),{mutateAsync:w,isPending:T}=Uf(),{mutateAsync:E}=Wf(),{mutateAsync:D,isPending:O}=Gf(),{data:k}=Nf(v),{data:A}=Ff({enabled:t,projectId:v}),j=If(),{commandPaletteOpen:M,handleResourceCanvasResizeStart:N,handleThemePreferenceChange:P,initialSessionMetadata:F,modelKey:I,modelSelection:L,models:R,openArtifact:z,openWorkspacePath:B,openPanelAction:V,persistSession:H,reopenRightPanel:U,resourceCanvasWidth:W,rightPanel:G,selectedArtifactId:ee,selectedWorkspacePath:te,setCommandPaletteOpen:ne,setModelKey:re,setRightPanel:ie,setSelectedWorkspacePath:ae,setThinkingLevel:oe,themePreference:se,thinkingLevel:ce}=Xp(k,_);(0,Z.useEffect)(()=>{if(F.projectId&&F.projectId!==v){y(F.projectId);return}!v&&S?.projects[0]&&(y(S.projects[0].projectId),H({projectId:S.projects[0].projectId}))},[v,F.projectId,H,S?.projects]);let{data:le,isLoading:ue,error:de,refetch:fe}=Lf(v),{data:pe}=Rf(v),{data:me,isLoading:he,error:ge}=zf(v),_e=Bf(),{data:ve,isLoading:ye,error:be,refetch:xe}=Vf(v,{enabled:!0}),Se=le??null,Ce=ve??null,we=(0,Z.useCallback)(()=>{fe()},[fe]),Te=(0,Z.useCallback)(async e=>{let t=await _e.mutateAsync({request:{settings:e},projectId:v}),n=dh(R,t);return n&&re(n),t},[v,R,re,_e]),Ee=(0,Z.useCallback)(()=>{xe()},[xe]),{activityLabel:K,answerQuestion:De,appendLocalMessage:Oe,deleteQueuedMessage:ke,deleteSession:Ae,error:je,getMessages:Me,getSessionMetadata:Ne,messages:Pe,planLabel:Fe,persistOpenUIArtifact:Ie,presentation:Le,queue:Re,renameSession:ze,resumeSession:Be,sendMessage:Ve,sessionMetadata:He,sessions:Ue,startNewSession:We,switchProject:Ge,status:Ke,stop:qe}=nh(L,{initialSessionMetadata:F,projectId:v,persistSession:H}),Je=(0,Z.useMemo)(()=>ei(Pe,Le,Ke),[Pe,Le,Ke]),Ye=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{if(!Le.thinkingLevel)return;let e=`${He.sessionId}:${Le.thinkingLevel}`;Ye.current!==e&&(Ye.current=e,oe(Le.thinkingLevel))},[Le.thinkingLevel,He.sessionId,oe]);let Xe=(0,Z.useCallback)(()=>{f([]),m([])},[]),Ze=(0,Z.useCallback)(async e=>{let t=Ne(),n=e?.projectId??v,r=uh({...t,projectId:t.projectId??v},n);await We(e),r&&Xe()},[v,Xe,Ne,We]),Qe=(0,Z.useCallback)(async(e,t)=>{let n=e.projectId===void 0&&v?{...e,projectId:v}:e,r=lh(Ne(),n),i=await Be(n,t);return i&&r&&Xe(),i},[v,Xe,Ne,Be]),$e=(0,Z.useCallback)(async(e,t)=>{await Qe(e,t)},[Qe]),et=(0,Z.useCallback)(async e=>{let t=Ue.filter(t=>t.projectId===e).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))[0],n=lh(Ne(),{sessionId:t?.sessionId,projectId:e});y(e),ae(null),await Ge(e,t?.sessionId)&&n&&Xe(),await C()},[Xe,Ne,C,ae,Ue,Ge]),tt=(0,Z.useCallback)(async e=>{y(e),ae(null),await Ze({projectId:e}),await C()},[C,ae,Ze]),nt=(0,Z.useCallback)(async e=>{let t=Ne().sessionId===e;await Ae(e),t&&Xe()},[Xe,Ae,Ne]),rt=(0,Z.useCallback)(async e=>{let t=await jf.createProject(e);await C(),await et(t.projectId)},[C,et]),it=(0,Z.useCallback)(async(e,t)=>{await jf.renameProject(e,t),await C()},[C]),at=(0,Z.useCallback)(async e=>{await jf.unregisterProject(e);let t=await C();if(v===e){let n=t.data?.projects.find(t=>t.projectId!==e);n?await et(n.projectId):(y(void 0),ae(null),await Ge(``,void 0)&&Xe())}},[v,Xe,C,et,ae,Ge]),ot=(0,Z.useCallback)(e=>jf.browseProjectDirectories(e),[]),st=(0,Z.useCallback)(async(e,t)=>{await jf.forkSessionIntoProject(e,t),await C()},[C]);(0,Z.useEffect)(()=>{He.sessionId&&C()},[C,He.sessionId]),He.sessionId;let ct=br(Re)??K??Fe,lt=(0,Z.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;Ne().sessionId||await Ze();let n=Ne().sessionId;if(!n)throw Error(`Unable to create a session for attachments`);let r=await jf.uploadAttachments(n,t);f(e=>[...e,...r])})().catch(e=>{Dm(e)})},e.click()},[Ne,Ze]),ut=(0,Z.useCallback)(e=>{f(t=>t.filter(t=>t.attachmentId!==e))},[]),dt=(0,Z.useCallback)(()=>f([]),[]),ft=(0,Z.useCallback)(()=>m([]),[]),pt=(0,Z.useCallback)(e=>{let t=sh(e);t&&m(e=>e.some(e=>e.relativePath===t)?e:[...e,{kind:`workspace`,relativePath:t,name:t.split(`/`).pop()||t}])},[]),mt=(0,Z.useCallback)(e=>{m(t=>t.filter(t=>t.relativePath!==e))},[]),ht=(0,Z.useCallback)(({toolCallId:e,answer:t})=>{De({toolCallId:e,answer:t}).catch(e=>{Dm(e)})},[De]),gt=Cm({messages:Pe,answerQuestion:ht}),_t=im({messages:Pe,resources:Se,workspaceTree:Ce}),vt=(0,Z.useMemo)(()=>{if(Pe.length===0||Ke===`streaming`||Ke===`submitted`)return!1;let e=Pe[Pe.length-1];return e.role===`assistant`&&!qf(e)},[Pe,Ke]),yt=(0,Z.useMemo)(()=>vt?_t:[],[vt,_t]),bt=(0,Z.useMemo)(()=>rp(Se,me?.effective.enableSkillCommands??!1,pe),[pe,Se,me]),xt=(0,Z.useMemo)(()=>oh(Ce),[Ce]),St=(0,Z.useCallback)(e=>{if(e.projectId&&e.projectId!==v){Kr.error(`This panel action targets a different project.`);return}V(e)},[v,V]),Ct=(0,Z.useCallback)(e=>{if(!e.projectId||e.projectId===v){V(e);return}et(e.projectId).then(()=>V(e)).catch(e=>Dm(e))},[v,V,et]),wt=(0,Z.useCallback)(e=>{i(e),n(!0)},[]),{forkFromEntry:Tt,handleLocalSlashSubmit:Et,handleSlashCommandSelect:Dt}=Sm({appendLocalMessage:Oe,getMessages:Me,getSessionMetadata:Ne,modelKey:I,models:R,onForkPicker:g,onOpenUIRequest:(0,Z.useCallback)(e=>{let t=[...p,...d];return dt(),ft(),Ve({text:e,altKey:!1,mode:l,openUI:!0,openUIArtifact:!0,attachments:t})},[l,dt,ft,Ve,d,p]),openSettings:wt,resumeSession:$e,sessions:Ue,setEffortPickerOpen:c,setModelKey:re,setModelPickerOpen:o,setThinkingLevel:oe,startNewSession:Ze}),Ot=(0,Z.useMemo)(()=>A?.models.map(jr)??R,[A,R]),kt=(0,Z.useCallback)(e=>ch(e,v),[v]),At=(0,Z.useCallback)(e=>jf.loadSession(e),[]),jt=(0,Z.useCallback)((e,t)=>jf.loadSubagentSession(e,t),[]),Mt=Rp({activeProjectId:v,loadSubagentSession:jt,presentation:Le,rootSessionId:He.sessionId}),Nt=(0,Z.useCallback)(async e=>(await j.mutateAsync(e)).models.map(jr),[j]),{chatPanelData:Pt,settingsActions:Ft,workspaceTreeContext:It}=rh({activityLabel:K,artifactRuns:Je,chatMode:l,handleThemePreferenceChange:P,isLoadingProviders:x,isUpdatingProvider:T||O,loadSession:At,loadSubagentSession:jt,loadWorkspaceFile:kt,messages:Pe,onOpenSubagentTab:Mt.openChildTab,modelKey:I,models:R,modelCatalog:Ot,onDiscoverModels:Nt,onOAuthLogin:E,onRemoveProvider:D,onUpdateProvider:w,openWorkspacePath:B,planLabel:Fe,presentation:Le,providers:b?.providers??[],queue:Re,refreshResources:we,refreshWorkspace:Ee,resources:Se,resourcesError:de,resourcesLoading:ue,reopenRightPanel:U,rightPanel:G,saveSettings:Te,selectedArtifactId:ee,sessionId:He.sessionId,selectedWorkspacePath:te,setRightPanel:ie,setSelectedWorkspacePath:ae,settings:me??null,settingsError:ge,settingsLoading:he||_e.isPending,status:Ke,thinkingLevel:ce,themePreference:se,workspaceError:be,workspaceLoading:ye,workspaceTree:Ce}),Lt=dm({activeTabId:Mt.activeTabId,tabs:Mt.tabs,onCloseTab:Mt.closeTab,onNewSession:()=>void Ze(),onSelectTab:Mt.selectTab,onOpenSettings:()=>wt()});return{session:{activeSessionId:He.sessionId,activeProjectId:v,openPanelAction:Ct,projects:S?.projects??[],projectSessions:Ue,sessions:Ue,browseProjectDirectories:ot,createProject:rt,deleteSession:nt,forkSessionIntoProject:st,renameProject:it,renameSession:ze,resumeSession:$e,selectProject:et,startNewSession:Ze,startNewSessionInProject:tt,unregisterProject:at},conversation:{activityLabel:K,artifactRuns:Je,deleteQueuedMessage:ke,error:je,messages:Pe,openArtifact:z,openPanelAction:St,persistOpenUIArtifact:Ie,presentation:Le,queue:Re,sendMessage:Ve,status:Ke,stop:qe},agentTabs:Mt,composer:{answerQuestion:De,chatMode:l,clearUploadedAttachments:dt,clearWorkspaceAttachments:ft,effortPickerOpen:s,handleAttach:lt,handleLocalSlashSubmit:Et,handleQuestionAnswer:ht,handleSlashCommandSelect:Dt,infoDescription:ct,inputSuggestionItems:yt,workspaceReferenceSuggestions:xt,modelKey:I,modelPickerOpen:a,models:R,pendingQuestionBar:gt,removeUploadedAttachment:ut,removeWorkspaceAttachment:mt,addWorkspaceAttachment:pt,setChatMode:u,setEffortPickerOpen:c,setModelKey:re,setModelPickerOpen:o,setThinkingLevel:oe,slashCommands:bt,thinkingLevel:ce,uploadedAttachments:d,workspaceAttachments:p},panels:{chatPanelData:Pt,handleResourceCanvasResizeStart:N,resourceCanvasWidth:W,rightPanel:G,setRightPanel:ie,settingsActions:Ft,workspaceTreeContext:It},dialogs:{commandPaletteOpen:M,forkFromEntry:Tt,forkPickerEntries:h,setCommandPaletteOpen:ne,setForkPickerEntries:g,setSettingsDialogOpen:n,setSettingsInitialTab:i,settingsDialogOpen:t,settingsInitialTab:r},chrome:{handleThemePreferenceChange:P,header:Lt,themePreference:se}}}var ph=(0,Z.lazy)(()=>Gr(async()=>{let{SubagentChatPanel:e}=await import(`./subagent-chat-panel-DseoO31p.js`);return{SubagentChatPanel:e}},__vite__mapDeps([85,3,1,86,2,12,5,4,23,6,8,34,25,35,36,32,33,37,7,26,74,75,16,87,13,14,68,88,38,28,44,55,42,63,64,65,89,22,24,27,29,30,31,39,40,41,43,17,45,46,47,48,49,50,51,15,21,52,53,58,81,59,60,90])).then(({SubagentChatPanel:e})=>({default:e})));function mh(){let{session:e,conversation:t,composer:n,panels:r,dialogs:i,chrome:a,agentTabs:o}=fh(),s=(0,Z.useCallback)(()=>{i.setCommandPaletteOpen(e=>!e)},[i.setCommandPaletteOpen]),c=(0,Z.useCallback)(()=>{r.setRightPanel(null),window.requestAnimationFrame(()=>Id())},[r.setRightPanel]);Ld({onCommandPaletteToggle:s,onClosePanel:c,rightPanel:r.rightPanel,setRightPanel:r.setRightPanel});let l=e.projects.find(t=>t.projectId===e.activeProjectId)?.name,u=(0,Z.useCallback)((e,r)=>{let i=[...n.workspaceAttachments,...n.uploadedAttachments];n.clearUploadedAttachments(),n.clearWorkspaceAttachments(),(async()=>{await t.sendMessage({text:e,altKey:r,mode:n.chatMode,openUI:!0,attachments:i})})()},[n.chatMode,n.clearUploadedAttachments,n.clearWorkspaceAttachments,n.uploadedAttachments,n.workspaceAttachments,t.sendMessage]),d=(0,Z.useCallback)(e=>{let r=Fi(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,Z.useCallback)(async e=>{try{return await t.persistOpenUIArtifact(e)}catch(e){Kr.error(`Artifact persistence failed: ${e instanceof Error?e.message:String(e)}`);return}},[t.persistOpenUIArtifact]),p=o.activeTabId===`main`||!o.selectedChild?(0,Q.jsx)(xd,{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,onOpenArtifact:t.openArtifact,onOpenUIArtifactReady:f,inputSuggestionItems:n.inputSuggestionItems,suppressQuestionTool:!!n.pendingQuestionBar,inputBar:Ed(n,e.activeSessionId),onSend:u,onOpenUIAction:d,onStop:t.stop,onQuestionAnswer:n.handleQuestionAnswer}):(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex min-h-32 flex-1 items-center justify-center text-xs text-foreground/45`,children:`Loading subagent thread…`}),children:(0,Q.jsx)(ph,{child:o.selectedChild,parentSessionId:e.activeSessionId,state:o.conversation})});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ad,{chrome:a,conversation:t,dialogs:i,panels:r,session:e}),(0,Q.jsxs)(Ri,{chatPanelData:r.chatPanelData,onOpenUIAction:d,settingsActions:r.settingsActions,workspaceTree:r.workspaceTreeContext,children:[(0,Q.jsxs)(Us,{className:`h-svh min-h-0 rounded-none border-0`,sidebarWidth:`17.5rem`,children:[(0,Q.jsx)(Ul,{data:{sessions:e.sessions,projects:e.projects,projectSessions:e.projectSessions,activeProjectId:e.activeProjectId,activeSessionId:e.activeSessionId},sessionActions:{onNewSession:()=>void 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,Q.jsx)(Is,{className:`h-svh min-h-0 overflow-hidden`,children:(0,Q.jsx)(fs,{headerLeft:a.header.left,headerCenter:a.header.center,headerRight:a.header.right,panel:(0,Q.jsx)(si,{children:(0,Q.jsx)(us,{handleResourceCanvasResizeStart:r.handleResourceCanvasResizeStart,onClose:c,resourceCanvasWidth:r.resourceCanvasWidth})}),children:(0,Q.jsx)(`div`,{"aria-labelledby":_o(o.activeTabId),className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-testid":`agent-tab-panel`,id:vo(o.activeTabId),role:`tabpanel`,children:p})})})]}),(0,Q.jsx)(jd,{dialogs:i})]})]})}var hh=mh;export{hh as component};