dorkos 0.122.0 → 0.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/dist/bin/cli.js +914 -333
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-ClN3P9B8.js → AboutPage-BH8Ndn3e.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-B2lq1pyE.js → ActivityErrorState-K5Mew9EX.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-htTkSy18.js → ActivityPage-BB20L5HU.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-BqV0B1T0.js → ActivityRow-C5O7rnmS.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-DlkN0YJo.js → AdapterIcon-Bmybvrzb.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-RyNPjSmU.js → AdapterSetupWizard-CkdV7Hhh.js} +2 -2
  10. package/dist/client/assets/{AgentOptionRow-DSievGfL.js → AgentOptionRow-BA2cDa7r.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-BCtWrhsA.js → AgentPicker-CsIIPGZJ.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-BHIHWNRz.js → AgentRequestCard-0fOxvaoe.js} +3 -3
  13. package/dist/client/assets/{AppearancePage-B2eduuT0.js → AppearancePage-XOjkkoli.js} +1 -1
  14. package/dist/client/assets/{ApplyToOverridesDialog-C7G2t3X2.js → ApplyToOverridesDialog-CoO6V1G4.js} +1 -1
  15. package/dist/client/assets/{AttentionSignalRow-_8thTHYX.js → AttentionSignalRow-CjjZobp7.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-WpZU5xiO.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-9TVHyRPJ.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-BAwbHFq3.js → BindingDialog-DLoAQauL.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-BEtRmEbL.js → BlintzCanvas-CYHsXAcY.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent--6i2ETyZ.js → CanvasCsvContent--Gr7Fe_U.js} +1 -1
  20. package/dist/client/assets/{CanvasFileContent-C86nyLbI.js → CanvasFileContent-estXyAbr.js} +2 -2
  21. package/dist/client/assets/{CanvasModel3dContent-wYHHAovt.js → CanvasModel3dContent-CkOo930M.js} +2 -2
  22. package/dist/client/assets/{ChatAppsOff-2Wvch1rr.js → ChatAppsOff-D4L1zJVN.js} +1 -1
  23. package/dist/client/assets/{CodeMirrorDiff-s1TWguZ8.js → CodeMirrorDiff-DY_6ju-z.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-1ndoTbcZ.js → CodeMirrorEditor-BUoDBsBv.js} +1 -1
  25. package/dist/client/assets/{CommitmentList-BK97ndab.js → CommitmentList-wDkcVP9c.js} +1 -1
  26. package/dist/client/assets/{CommitmentsPage-_nd37gVX.js → CommitmentsPage-CzSM6b8R.js} +1 -1
  27. package/dist/client/assets/{ComputerResourceView-C2Broer4.js → ComputerResourceView-cERD9H2L.js} +1 -1
  28. package/dist/client/assets/{ComputerViewer-DgG7t2KZ.js → ComputerViewer-rMcfbk2_.js} +1 -1
  29. package/dist/client/assets/{ConnectionAccessLists-Pbo2lft8.js → ConnectionAccessLists-f7QeQbQo.js} +1 -1
  30. package/dist/client/assets/{ConnectionsPage-Dm2d9owX.js → ConnectionsPage-BmjtA6pw.js} +2 -2
  31. package/dist/client/assets/{ConventionPage-BUltejHJ.js → ConventionPage-CH-ah6nI.js} +1 -1
  32. package/dist/client/assets/{ExtensionPageRoute-DAomCiMw.js → ExtensionPageRoute-CJIxa6ST.js} +2 -2
  33. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-5fT29ZEV.js → FloatingTanStackRouterDevtools-CqogiFob-BP7EJ2JL.js} +1 -1
  34. package/dist/client/assets/HandlePage-Cg8H3mQS.js +1 -0
  35. package/dist/client/assets/{HeartbeatPage-BW0X4YAL.js → HeartbeatPage-BUsf-qrU.js} +1 -1
  36. package/dist/client/assets/{KeyEntry-ClqAj0dS.js → KeyEntry-C2kWdN8q.js} +1 -1
  37. package/dist/client/assets/{LexicalField-CbswpPQ7.js → LexicalField-CR8ulsI_.js} +1 -1
  38. package/dist/client/assets/{ManagesPage-Daqs8hys.js → ManagesPage-DTtsIOGi.js} +1 -1
  39. package/dist/client/assets/{Marketplace-BNMIm8g_.js → Marketplace-iaV5XAzv.js} +2 -2
  40. package/dist/client/assets/{MarketplaceSourcesView-B4WpzVpr.js → MarketplaceSourcesView-6tgzUfFj.js} +1 -1
  41. package/dist/client/assets/{McpAppFrame-Dbg_Ni39.js → McpAppFrame-C7eYYdI9.js} +1 -1
  42. package/dist/client/assets/McpSigninBody-BDyGbJ7I.js +1 -0
  43. package/dist/client/assets/{Model3dViewer-DT8x0h7T.js → Model3dViewer-BujDNuVS.js} +1 -1
  44. package/dist/client/assets/NamePage-Bx8T98OF.js +1 -0
  45. package/dist/client/assets/{NewDirectMessageMenu-BbehZd6I.js → NewDirectMessageMenu-D4e-z2Jt.js} +1 -1
  46. package/dist/client/assets/{NotificationsPage-B9zEN26O.js → NotificationsPage-CkDeTaJp.js} +1 -1
  47. package/dist/client/assets/{OpenMeshSwitch-D-AYDXjH.js → OpenMeshSwitch-CtbOt3r5.js} +2 -2
  48. package/dist/client/assets/OperatorIdentityForm-Vr4qZnmM.js +1 -0
  49. package/dist/client/assets/PermissionHistory-DzU1rf2B.js +1 -0
  50. package/dist/client/assets/{PermissionsPage-CKfDf5Pj.js → PermissionsPage-f4QaX8oM.js} +1 -1
  51. package/dist/client/assets/{PersonalityPopover-CHPTuHIH.js → PersonalityPopover-BkZruwF-.js} +1 -1
  52. package/dist/client/assets/PhotoPage-CmrOIRjf.js +1 -0
  53. package/dist/client/assets/{PreviewRefusedNotice-BuVUhjq3.js → PreviewRefusedNotice-BXC2K0tx.js} +1 -1
  54. package/dist/client/assets/{ProfileFields-DimHNpR4.js → ProfileFields-BebX5oiv.js} +1 -1
  55. package/dist/client/assets/{ProfilePanelContainer-FRZ5Px2L.js → ProfilePanelContainer-DZoL65zQ.js} +1 -1
  56. package/dist/client/assets/{ProfileRolePicker-UWhM5yuR.js → ProfileRolePicker-D9H7wsuT.js} +1 -1
  57. package/dist/client/assets/{PromptSuggestionChips-DQaDSd7Y.js → PromptSuggestionChips-B5fDmc-g.js} +1 -1
  58. package/dist/client/assets/{ReportsToPopover-BOuCM8il.js → ReportsToPopover-uVYhSqj7.js} +1 -1
  59. package/dist/client/assets/{RoomSurface-Dhv-LkWz.js → RoomSurface-Bg5WV4Ep.js} +7 -7
  60. package/dist/client/assets/{RoomsPage-glKYJBpq.js → RoomsPage-yflYFulU.js} +1 -1
  61. package/dist/client/assets/{RunsOnPopover-BvxoHUeo.js → RunsOnPopover-DtGrX1Vq.js} +1 -1
  62. package/dist/client/assets/{RuntimeConnectFlow-CgB_X5wo.js → RuntimeConnectFlow-DjReuQ-T.js} +1 -1
  63. package/dist/client/assets/{RuntimeSetupDialog-r1Ss_YQW.js → RuntimeSetupDialog-Cr4GRi8c.js} +1 -1
  64. package/dist/client/assets/SeenDevices-SPWkdzoK.js +19 -0
  65. package/dist/client/assets/{SessionsPage-CFLDx-aF.js → SessionsPage-BWu-en78.js} +1 -1
  66. package/dist/client/assets/SettingsDialog-_dEXUhHe.js +12 -0
  67. package/dist/client/assets/{SkillsPage-CUQZ4I_r.js → SkillsPage-BdUb9SZy.js} +1 -1
  68. package/dist/client/assets/TaskDialogWrapper-qYJPEoSR.js +1 -0
  69. package/dist/client/assets/{TasksEmptyState-B4TjUm8G.js → TasksEmptyState-Bgcg9vxF.js} +2 -2
  70. package/dist/client/assets/{TasksPage-D_vFBDA1.js → TasksPage-Ch5W2WQS.js} +1 -1
  71. package/dist/client/assets/{TeamComputerEntry-EQ1fjMRb.js → TeamComputerEntry-CPwSIMRw.js} +1 -1
  72. package/dist/client/assets/ToolsPage-Idimrn3o.js +2 -0
  73. package/dist/client/assets/{TopologyGraph-DsPEpDjt.js → TopologyGraph-I4_mkMHM.js} +14 -14
  74. package/dist/client/assets/{TourHost-D1z2mH5S.js → TourHost-BPaSwh9I.js} +1 -1
  75. package/dist/client/assets/{UnlinkDialog-q-6B4Ftt.js → UnlinkDialog-BUWZUu5P.js} +1 -1
  76. package/dist/client/assets/{WidgetErrorCard-BYMiUiAf.js → WidgetErrorCard-cS8yMCxU.js} +3 -3
  77. package/dist/client/assets/_shell-ClVN2pUj.js +80 -0
  78. package/dist/client/assets/{_shell._home-D-8JcUYq.js → _shell._home-DCA5k-jb.js} +1 -1
  79. package/dist/client/assets/{_shell._home.activity-xJKxWbtL.js → _shell._home.activity-BX4nFLna.js} +1 -1
  80. package/dist/client/assets/{_shell._home.index-C74gh1aE.js → _shell._home.index-C8t8cw72.js} +1 -1
  81. package/dist/client/assets/{_shell._home.tasks-Bh8jwRYJ.js → _shell._home.tasks-BgUeEvhK.js} +1 -1
  82. package/dist/client/assets/{_shell._home.workspaces-BKkUl6wW.js → _shell._home.workspaces-BPBdnkRt.js} +1 -1
  83. package/dist/client/assets/_shell.channels-CX4kki7G.js +10 -0
  84. package/dist/client/assets/_shell.connections-0vP7g7E4.js +1 -0
  85. package/dist/client/assets/{_shell.feedback-requests-Cdbl3oKj.js → _shell.feedback-requests-TsuaO4eR.js} +2 -2
  86. package/dist/client/assets/_shell.marketplace-CiL6YRbl.js +1 -0
  87. package/dist/client/assets/_shell.marketplace_.sources-C0sI8e21.js +1 -0
  88. package/dist/client/assets/_shell.session-_hhBvFc6.js +63 -0
  89. package/dist/client/assets/{_shell.team-Consxq97.js → _shell.team-Bm6cOBhR.js} +4 -4
  90. package/dist/client/assets/_shell.x._extensionId-BWy5v1YE.js +1 -0
  91. package/dist/client/assets/_shell.x._extensionId_._-BWy5v1YE.js +1 -0
  92. package/dist/client/assets/{abnfDiagram-WEYOIA3C-DXTlLd8s.js → abnfDiagram-WEYOIA3C-CrvoN15x.js} +1 -1
  93. package/dist/client/assets/{access-copy-B1SlOYEi.js → access-copy-B3yNZ7Gz.js} +1 -1
  94. package/dist/client/assets/{arc-B3IW5TXq.js → arc-CuT6QA_y.js} +1 -1
  95. package/dist/client/assets/{architectureDiagram-ZHVYKT53-Bx-4szWe.js → architectureDiagram-ZHVYKT53-CPXCZ9H4.js} +1 -1
  96. package/dist/client/assets/{banner-RKoWGrEp.js → banner-DRumuw3F.js} +1 -1
  97. package/dist/client/assets/{blockDiagram-RJAE7QA3-D_B3EDQ1.js → blockDiagram-RJAE7QA3-CM0rka9p.js} +1 -1
  98. package/dist/client/assets/{c4Diagram-XDPPPE54-CSBl4ROD.js → c4Diagram-XDPPPE54-D4j2cXRy.js} +1 -1
  99. package/dist/client/assets/{card-DTMhLU7B.js → card-B3CtfC3R.js} +1 -1
  100. package/dist/client/assets/channel-DjBlTcCV.js +1 -0
  101. package/dist/client/assets/{chunk-2E7WHVMD-QSgLcVHQ.js → chunk-2E7WHVMD-KGyqhVpO.js} +1 -1
  102. package/dist/client/assets/{chunk-2Q5K7J3B-CAEYyBSj.js → chunk-2Q5K7J3B-Dl0BHoqK.js} +1 -1
  103. package/dist/client/assets/{chunk-4EMNKR2T-CQ_90aiz.js → chunk-4EMNKR2T-Da7vH6Kv.js} +1 -1
  104. package/dist/client/assets/{chunk-55XCU76K-jsUyUA3N.js → chunk-55XCU76K-DgBUEROO.js} +1 -1
  105. package/dist/client/assets/{chunk-5VM5RSS4-JHkf15PA.js → chunk-5VM5RSS4-BQ4mn-_I.js} +1 -1
  106. package/dist/client/assets/{chunk-JWPE2WC7-BT-3krv8.js → chunk-JWPE2WC7-8LPR3mXf.js} +1 -1
  107. package/dist/client/assets/{chunk-VQ5W62QI-CJP11I5o.js → chunk-VQ5W62QI-BkIVXi4W.js} +1 -1
  108. package/dist/client/assets/{chunk-XXDRQBXY-BpqBecnj.js → chunk-XXDRQBXY-DQXJx06h.js} +1 -1
  109. package/dist/client/assets/{chunk-ZCHMQSOR-BLb4KcT4.js → chunk-ZCHMQSOR-DzCE7qlD.js} +2 -2
  110. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-DwLyYGkw.js → classDiagram-v2-4MYWR3UA-C_cZra7c.js} +1 -1
  111. package/dist/client/assets/{command-DDSiiJlP.js → command-CDKbyppr.js} +1 -1
  112. package/dist/client/assets/{cose-bilkent-JH36ORCC-CxYTET88.js → cose-bilkent-JH36ORCC-DlXHdGwT.js} +1 -1
  113. package/dist/client/assets/{cpu--56q_Ey0.js → cpu-B7xLO7jn.js} +1 -1
  114. package/dist/client/assets/{cynefin-EF2NZ3EQ-9fHLZRHz.js → cynefin-EF2NZ3EQ-HhP4ArLc.js} +1 -1
  115. package/dist/client/assets/{cynefinDiagram-WF24UDRP-DpfQecff.js → cynefinDiagram-WF24UDRP-D4GgWnZV.js} +1 -1
  116. package/dist/client/assets/{dagre-NK4GIZVX-DuV6buEQ.js → dagre-NK4GIZVX-SZ_OI2Zi.js} +1 -1
  117. package/dist/client/assets/{diagram-CBK3MWTC-B-A9Sx5n.js → diagram-CBK3MWTC-BN-_Ja5m.js} +1 -1
  118. package/dist/client/assets/{diagram-I5XIIV2D-Ds5Hq9aV.js → diagram-I5XIIV2D-t7AK6xnL.js} +1 -1
  119. package/dist/client/assets/{diagram-ODIL2UCW-UUfSjM-R.js → diagram-ODIL2UCW-C1V7szSc.js} +1 -1
  120. package/dist/client/assets/{diagram-PFBEJUXE-CUzSSYf9.js → diagram-PFBEJUXE-DPtraQ2g.js} +1 -1
  121. package/dist/client/assets/{diagram-RJA3I4VV-Cgp6U3q1.js → diagram-RJA3I4VV-D2XNRB2b.js} +1 -1
  122. package/dist/client/assets/{diagram-TYUNFSNR-BxVgzMNE.js → diagram-TYUNFSNR-BieaRy38.js} +1 -1
  123. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-BgDiHzoi.js → ebnfDiagram-V4P3TTPT-Bwki86UY.js} +1 -1
  124. package/dist/client/assets/{elk-QONTBCTQ-BCCN6mFs.js → elk-QONTBCTQ-WEXSAyHB.js} +1 -1
  125. package/dist/client/assets/{empty-state-BsA3jcrO.js → empty-state-J-UJ0BUU.js} +1 -1
  126. package/dist/client/assets/{erDiagram-KYQIGQAA-5RkmUbLz.js → erDiagram-KYQIGQAA-DIKASnoc.js} +1 -1
  127. package/dist/client/assets/{execution-config-CRkSeCj7.js → execution-config-ILQiJAmy.js} +1 -1
  128. package/dist/client/assets/{file-Bg_qGvWR.js → file-D40js1Zx.js} +1 -1
  129. package/dist/client/assets/{file-exclamation-point-BWsLZQVN.js → file-exclamation-point-Dg3ZpiAe.js} +1 -1
  130. package/dist/client/assets/{file-text-DQThCdY3.js → file-text-DgdvRfMk.js} +1 -1
  131. package/dist/client/assets/{find-latest-widget-fence-DFpYPIlS.js → find-latest-widget-fence-D4kBWC_1.js} +1 -1
  132. package/dist/client/assets/{flowDiagram-IUGLLWBU-C2FFT_4u.js → flowDiagram-IUGLLWBU-CoavNw0M.js} +1 -1
  133. package/dist/client/assets/{form-DjMe15QR.js → form-DlPwEgQH.js} +1 -1
  134. package/dist/client/assets/{format-cron-Bo3D4N9C.js → format-cron-BrK8RzgT.js} +1 -1
  135. package/dist/client/assets/{ganttDiagram-R7GPNTJY-BHG-HNDj.js → ganttDiagram-R7GPNTJY-DccKAz7f.js} +1 -1
  136. package/dist/client/assets/{git-branch-CJ1NlVLY.js → git-branch-BpxhecMq.js} +1 -1
  137. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-D4bvs6_J.js → gitGraphDiagram-PDYL7XHY-DEbo_dgQ.js} +1 -1
  138. package/dist/client/assets/{graph-D8MBmHRU.js → graph-DROgI3M3.js} +1 -1
  139. package/dist/client/assets/{heart-Beze5rli.js → heart-c7u4Ezxt.js} +1 -1
  140. package/dist/client/assets/{highlighted-body-KPVGNVTW-B-za1R0D.js → highlighted-body-KPVGNVTW-CrATNdTR.js} +1 -1
  141. package/dist/client/assets/image-lightbox-DE_fHkw-.js +1 -0
  142. package/dist/client/assets/{image-off-dQCXn9D_.js → image-off-BExgZjfM.js} +2 -2
  143. package/dist/client/assets/{index-Dbt6ttQb.js → index-2wezsLA_.js} +1 -1
  144. package/dist/client/assets/index-7jby-RRg.js +1 -0
  145. package/dist/client/assets/{index-CocSe_I3.js → index-AzyLwYS_.js} +3 -3
  146. package/dist/client/assets/{index-dnaC3n0i.js → index-B3eeEDWj.js} +4 -4
  147. package/dist/client/assets/{index-C38pc-JE.js → index-BEkYBuOq.js} +1 -1
  148. package/dist/client/assets/index-BGqvci3k.js +1 -0
  149. package/dist/client/assets/{index-BJv8b9cZ.js → index-BVqSmajJ.js} +1 -1
  150. package/dist/client/assets/{index-Bk6YahnN.js → index-Be0OJLWK.js} +1 -1
  151. package/dist/client/assets/{index-BTfwunle.js → index-BizvylBV.js} +1 -1
  152. package/dist/client/assets/{index-CPxcbKL6.js → index-BkoMsjtM.js} +2 -2
  153. package/dist/client/assets/{index-CxWJDJW7.js → index-BlyoyIck.js} +1 -1
  154. package/dist/client/assets/{index-hKY0860x.js → index-BqIHtiaE.js} +1 -1
  155. package/dist/client/assets/{index-DfSOcv9s.js → index-C5or4L_3.js} +1 -1
  156. package/dist/client/assets/{index-CDm1XkU1.js → index-C7B3eSOP.js} +1 -1
  157. package/dist/client/assets/{index-vNaWkS8Y.js → index-CD8aw6Jb.js} +1 -1
  158. package/dist/client/assets/{index-D4mYlxG0.js → index-CT_pFeX_.js} +1 -1
  159. package/dist/client/assets/{index-BPa0ZczY.js → index-CYy1cjtq.js} +1 -1
  160. package/dist/client/assets/{index-DFN-GU8r.js → index-CZmqtJWZ.js} +1 -1
  161. package/dist/client/assets/{index-BMhblg3s.js → index-CbHCZsbE.js} +1 -1
  162. package/dist/client/assets/{index-Ds-LCBb6.js → index-Ccf1XBTs.js} +1 -1
  163. package/dist/client/assets/index-Cga0qx1T.js +1033 -0
  164. package/dist/client/assets/{index-CU-gekzq.js → index-CqPRAM_6.js} +1 -1
  165. package/dist/client/assets/index-Ct4At33X.js +1 -0
  166. package/dist/client/assets/{index-CMlVfxJv.js → index-D0eJtRlK.js} +1 -1
  167. package/dist/client/assets/{index-D_KBdkA4.js → index-D150FXCC.js} +22 -20
  168. package/dist/client/assets/{index-BqwfU5a7.js → index-D3YeRrne.js} +1 -1
  169. package/dist/client/assets/index-DCJQGDZk.js +1 -0
  170. package/dist/client/assets/{index-C9qjJR0B.js → index-DDgOoXP1.js} +1 -1
  171. package/dist/client/assets/{index-DpX_xwGs.js → index-DINk1YfD.js} +1 -1
  172. package/dist/client/assets/{index-CAGOE4EU.js → index-DITPwUa9.js} +3 -3
  173. package/dist/client/assets/{index-DnfhvN3q.js → index-DNGNMW3c.js} +1 -1
  174. package/dist/client/assets/{index-DNlhbCX_.js → index-DT7pv2iW.js} +1 -1
  175. package/dist/client/assets/{index-CrflCTqO.css → index-DUZrTFYD.css} +1 -1
  176. package/dist/client/assets/{index-B3VKw60l.js → index-DaZ1I8s-.js} +1 -1
  177. package/dist/client/assets/{index-yDf4EVDy.js → index-DeRDq7bD.js} +1 -1
  178. package/dist/client/assets/{index-BTVsyrd0.js → index-DhHobJd3.js} +1 -1
  179. package/dist/client/assets/{index-CodC2rG4.js → index-DksjixUS.js} +1 -1
  180. package/dist/client/assets/{index-CGVRWEpN.js → index-DswGXheF.js} +1 -1
  181. package/dist/client/assets/{index-BaocSCDH.js → index-DxiRRZRo.js} +1 -1
  182. package/dist/client/assets/index-F-vqXYqa.js +1 -0
  183. package/dist/client/assets/{index-B3ybVnXe.js → index-InEBtYxw.js} +7 -7
  184. package/dist/client/assets/{index-DqD-Sg0W.js → index-J3Hh1MnL.js} +1 -1
  185. package/dist/client/assets/{index-BMktWriw.js → index-dyAahqKe.js} +1 -1
  186. package/dist/client/assets/{index-Ckv0K82u.js → index-mwf7ZNk2.js} +1 -1
  187. package/dist/client/assets/{index.esm-Ruqz-OsH.js → index.esm-BFJ9SG0n.js} +1 -1
  188. package/dist/client/assets/{infoDiagram-MVDRKAX5-CmDlX3lx.js → infoDiagram-MVDRKAX5-VL8q5pKx.js} +1 -1
  189. package/dist/client/assets/{inline-code-plzdKGm9.js → inline-code-BE9ckzPs.js} +1 -1
  190. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-DZFRAvrx.js → ishikawaDiagram-HPEHV2GE-BLKkPYF-.js} +1 -1
  191. package/dist/client/assets/{journeyDiagram-BOSHW7O7-B140KXYu.js → journeyDiagram-BOSHW7O7-CSYpRobu.js} +1 -1
  192. package/dist/client/assets/{kanban-definition-FNSA4HC5-QCZgRJic.js → kanban-definition-FNSA4HC5-HilAqtZo.js} +1 -1
  193. package/dist/client/assets/{layers-Br3LALac.js → layers-Cm7coqdo.js} +1 -1
  194. package/dist/client/assets/{lightbulb-CeJgUDoT.js → lightbulb-DqdWS75d.js} +1 -1
  195. package/dist/client/assets/{link-2-BXcZwTAC.js → link-2-CDJapTSa.js} +1 -1
  196. package/dist/client/assets/{list-runtime-types-CqKIrt9D.js → list-runtime-types-CP82p1u4.js} +1 -1
  197. package/dist/client/assets/{markdown-content-BKbjOTI2.js → markdown-content-m_qereFc.js} +1 -1
  198. package/dist/client/assets/{mention-pill-B-FgNE6o.js → mention-pill-DV5HIG5Q.js} +1 -1
  199. package/dist/client/assets/{mermaid.core-Br9hJ7FR.js → mermaid.core-zxW6MBr-.js} +4 -4
  200. package/dist/client/assets/{message-square-off-Co0W--np.js → message-square-off-YVtpbaJ0.js} +1 -1
  201. package/dist/client/assets/{mindmap-definition-6OY57UG3-BxjSZAec.js → mindmap-definition-6OY57UG3-IAYemvOg.js} +1 -1
  202. package/dist/client/assets/{more-details-BsdCkGTg.js → more-details-ReA2ZFBn.js} +1 -1
  203. package/dist/client/assets/{owner-notice-BxltHzJH.js → owner-notice-M4hn_1ep.js} +1 -1
  204. package/dist/client/assets/{package-DPgmy9lP.js → package-CUuTl39E.js} +1 -1
  205. package/dist/client/assets/{page-container-HokGbFg_.js → page-container-BnmNikNZ.js} +1 -1
  206. package/dist/client/assets/{paperclip-BDnApT-_.js → paperclip-C6fYq5Zf.js} +1 -1
  207. package/dist/client/assets/{path-input-C22n3ghr.js → path-input-DHn9-XaE.js} +1 -1
  208. package/dist/client/assets/{pegDiagram-ECIUJNBX-utA2pUiu.js → pegDiagram-ECIUJNBX-CojaUwe7.js} +1 -1
  209. package/dist/client/assets/{pieDiagram-GNMPY74T-DjEry_VP.js → pieDiagram-GNMPY74T-CjP3pw6V.js} +1 -1
  210. package/dist/client/assets/{plug-tLTAmXis.js → plug-DHQcxt7N.js} +1 -1
  211. package/dist/client/assets/primer-trigger-BmV5wjek.js +3 -0
  212. package/dist/client/assets/{profile-errors-Dvm4O6MR.js → profile-errors-BSCuj3rT.js} +1 -1
  213. package/dist/client/assets/{progress-BduTwXMX.js → progress-4FQQfnS6.js} +1 -1
  214. package/dist/client/assets/{quadrantDiagram-D57K4MC3-DO9NgnEq.js → quadrantDiagram-D57K4MC3-OP0Z8zcR.js} +1 -1
  215. package/dist/client/assets/{query-error-state-puwJHnzi.js → query-error-state-BkUdxenP.js} +1 -1
  216. package/dist/client/assets/{radio-DR4E05zZ.js → radio-ta5Bw763.js} +1 -1
  217. package/dist/client/assets/{railroadDiagram-Y72NRBL7-BTilAS9p.js → railroadDiagram-Y72NRBL7-CT3NCb9b.js} +1 -1
  218. package/dist/client/assets/registry-Dc102rws.js +1 -0
  219. package/dist/client/assets/{relay-trace-schemas-DwqIIDB9.js → relay-trace-schemas-DwUuyxao.js} +2 -2
  220. package/dist/client/assets/{requirementDiagram-EQYSW5RA-C6rzY7GK.js → requirementDiagram-EQYSW5RA-tde4lYGp.js} +1 -1
  221. package/dist/client/assets/{room-files-source-Duo4oiqX.js → room-files-source-CZWhaaOy.js} +2 -2
  222. package/dist/client/assets/{rotate-ccw-clock-RJuoRE3k.js → rotate-ccw-clock-RfbbgUa4.js} +1 -1
  223. package/dist/client/assets/{rotate-cw-C0EpbK5k.js → rotate-cw-B3rB_YSw.js} +1 -1
  224. package/dist/client/assets/{sankeyDiagram-SY24JHO5-BqpJRY1t.js → sankeyDiagram-SY24JHO5-sdCzIA7-.js} +1 -1
  225. package/dist/client/assets/{scroll-area-07T90PR6.js → scroll-area-B4WB7Q40.js} +1 -1
  226. package/dist/client/assets/{search-x-DQabogEL.js → search-x-DCUmWW2_.js} +1 -1
  227. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-BHfzZpFt.js → sequenceDiagram-BLEHNHQU-DvzTJcKu.js} +1 -1
  228. package/dist/client/assets/{shield-x-Cuo1GTv4.js → shield-x-CANziVLc.js} +1 -1
  229. package/dist/client/assets/signed-in-DctJ2IWe.js +1 -0
  230. package/dist/client/assets/{sizeCapture-INFHLROL-U0MO-4ua.js → sizeCapture-INFHLROL-DuDA7TKE.js} +1 -1
  231. package/dist/client/assets/{soul-file-wKTqbR0Y.js → soul-file-Co_8f1qw.js} +1 -1
  232. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-fzo1sDsX.js → stateDiagram-v2-A6IESKWZ-BJPX5JTC.js} +1 -1
  233. package/dist/client/assets/{swimlanes-B3ENRKFQ-B7QcCUBU.js → swimlanes-B3ENRKFQ-CiLSffGv.js} +1 -1
  234. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-Dv1-QS9J.js +8 -0
  235. package/dist/client/assets/{table-BjHA85BX.js → table-BSAvOYPp.js} +1 -1
  236. package/dist/client/assets/{terminal-qfxxVZaa.js → terminal-6CdY-T1V.js} +1 -1
  237. package/dist/client/assets/{timeline-definition-JXYKGLGB-okVlmef4.js → timeline-definition-JXYKGLGB-5oq8sl82.js} +1 -1
  238. package/dist/client/assets/{trust-posture-BmW0KVP6.js → trust-posture-D-Yjm6ot.js} +1 -1
  239. package/dist/client/assets/{unplug-BYKBdSMl.js → unplug-Bq_1WdV7.js} +1 -1
  240. package/dist/client/assets/{unverified-catalog-notice-CQHA4Cst.js → unverified-catalog-notice-CEzu54YH.js} +1 -1
  241. package/dist/client/assets/{use-adapter-catalog-rB4qQQ5D.js → use-adapter-catalog-Tn3ZbPAj.js} +1 -1
  242. package/dist/client/assets/{use-bindings-DiFC7kWg.js → use-bindings-Bz9YRgO7.js} +1 -1
  243. package/dist/client/assets/{use-composer-prefs-DHY5vJ0l.js → use-composer-prefs-D9oKJSQN.js} +1 -1
  244. package/dist/client/assets/{use-connector-management-CoinXIID.js → use-connector-management-CLYFraXN.js} +1 -1
  245. package/dist/client/assets/{use-deep-link-scroll-Cm8BRFAE.js → use-deep-link-scroll-DkS713kG.js} +1 -1
  246. package/dist/client/assets/{use-delete-binding-FtM6qPfF.js → use-delete-binding-CukKpHBK.js} +1 -1
  247. package/dist/client/assets/{use-dev-links-TQFCV3vk.js → use-dev-links-DQ32IcGe.js} +1 -1
  248. package/dist/client/assets/{use-external-adapter-catalog-Lx8LZDAa.js → use-external-adapter-catalog-D-FO_XW6.js} +1 -1
  249. package/dist/client/assets/{use-full-activity-feed-CmcBAvUM.js → use-full-activity-feed-BNxcyb1j.js} +1 -1
  250. package/dist/client/assets/use-is-below-desktop-gTvJDvw4.js +1 -0
  251. package/dist/client/assets/use-is-hub-B1vPpkYU.js +1 -0
  252. package/dist/client/assets/{use-jump-back-in-V8G_6fYj.js → use-jump-back-in-Bibj5tVk.js} +3 -3
  253. package/dist/client/assets/{use-local-browser-CbS4typW.js → use-local-browser-xg7WXAVK.js} +1 -1
  254. package/dist/client/assets/{use-mesh-topology-DZ1qMT3J.js → use-mesh-topology-BgCSFw8s.js} +1 -1
  255. package/dist/client/assets/{use-mounted-ref-DUbNzP-m.js → use-mounted-ref-qRbdZfOU.js} +1 -1
  256. package/dist/client/assets/{use-notification-prefs-BAsICJ96.js → use-notification-prefs-B-4kZR7I.js} +1 -1
  257. package/dist/client/assets/{use-panel-tab-placements-ymrpuL_s.js → use-panel-tab-placements-CCq-mZlY.js} +1 -1
  258. package/dist/client/assets/use-pending-read-C8L_v4Zw.js +1 -0
  259. package/dist/client/assets/{use-personality-commit-rJOmDgC2.js → use-personality-commit-DwSisUfF.js} +1 -1
  260. package/dist/client/assets/{use-promo-activation-BKeBloMI.js → use-promo-activation-Botoso6l.js} +3 -3
  261. package/dist/client/assets/{use-promo-dismissals-Cio8QMjL.js → use-promo-dismissals-RJXp-r_J.js} +1 -1
  262. package/dist/client/assets/{use-pulse-freshness-DZkMVbSM.js → use-pulse-freshness-B3390hGg.js} +1 -1
  263. package/dist/client/assets/{use-relay-config-CbZQKFhZ.js → use-relay-config-BV0xcLwS.js} +1 -1
  264. package/dist/client/assets/{use-room-follow-claim-DbJIsuWz.js → use-room-follow-claim-Du4hKHIJ.js} +1 -1
  265. package/dist/client/assets/{use-roving-tab-list-B4nZ7trj.js → use-roving-tab-list-g2hO6Ruz.js} +1 -1
  266. package/dist/client/assets/{use-session-canvas-sAwc2L1A.js → use-session-canvas-i30oMO_Q.js} +3 -3
  267. package/dist/client/assets/{use-session-diagnostics-0gcI762B.js → use-session-diagnostics-a4b83F5J.js} +2 -2
  268. package/dist/client/assets/{use-unclaimed-chats-BWIqOrvs.js → use-unclaimed-chats-B92om889.js} +1 -1
  269. package/dist/client/assets/use-update-config-Tbn3SodN.js +1 -0
  270. package/dist/client/assets/{useMutationState-C9Q5lRej.js → useMutationState-DdOGdpjP.js} +1 -1
  271. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-CMjVaeX9.js → usecaseDiagram-WPOLBNNX-Di5pJvcw.js} +1 -1
  272. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-BajZBf0H.js → vennDiagram-Q3Y3IDCW-K7KAf26T.js} +1 -1
  273. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-BN4xF6JT.js → wardleyDiagram-IVAIDKWA-DVTaxQt9.js} +1 -1
  274. package/dist/client/assets/{xychartDiagram-4URNHDU4-Cy0Z9a28.js → xychartDiagram-4URNHDU4-x-lSJm_B.js} +1 -1
  275. package/dist/client/index.html +2 -2
  276. package/dist/drizzle/20261018123612_session_route.sql +1 -0
  277. package/dist/drizzle/20261018210140_remote_command_agent_computer_kind.sql +21 -0
  278. package/dist/drizzle/20261019142317_turn_marks.sql +3 -0
  279. package/dist/drizzle/meta/20261018123612_snapshot.json +14027 -0
  280. package/dist/drizzle/meta/20261018210140_snapshot.json +14027 -0
  281. package/dist/drizzle/meta/20261019142317_snapshot.json +14048 -0
  282. package/dist/drizzle/meta/_journal.json +21 -0
  283. package/dist/server/index.js +25295 -21133
  284. package/dist/server/index.js.map +2 -2
  285. package/package.json +5 -5
  286. package/dist/client/assets/HandlePage-BoBFGnUB.js +0 -1
  287. package/dist/client/assets/McpSigninBody-ZmmY1BZ4.js +0 -1
  288. package/dist/client/assets/NamePage-bC_9FOtD.js +0 -1
  289. package/dist/client/assets/OperatorIdentityForm-BdAqzVEG.js +0 -1
  290. package/dist/client/assets/PermissionHistory-IOgLQ7qN.js +0 -1
  291. package/dist/client/assets/PhotoPage-BOe3xwyN.js +0 -1
  292. package/dist/client/assets/PresetPicker-BcKF2ds8.js +0 -19
  293. package/dist/client/assets/SettingsDialog-BT5rYJUm.js +0 -12
  294. package/dist/client/assets/TaskDialogWrapper-DWpxyxBb.js +0 -1
  295. package/dist/client/assets/ToolsPage-CyNXCe2l.js +0 -2
  296. package/dist/client/assets/_shell-scIpUrVY.js +0 -80
  297. package/dist/client/assets/_shell.channels-B2A1G9n8.js +0 -10
  298. package/dist/client/assets/_shell.connections-eDlPXmuG.js +0 -1
  299. package/dist/client/assets/_shell.marketplace-FHQpZxgB.js +0 -1
  300. package/dist/client/assets/_shell.marketplace_.sources-DXv90Z-v.js +0 -1
  301. package/dist/client/assets/_shell.session-BNeYm91q.js +0 -63
  302. package/dist/client/assets/_shell.x._extensionId-DirEl_qN.js +0 -1
  303. package/dist/client/assets/_shell.x._extensionId_._-DirEl_qN.js +0 -1
  304. package/dist/client/assets/channel-BlEJg4XA.js +0 -1
  305. package/dist/client/assets/image-lightbox-a4gqhNXS.js +0 -1
  306. package/dist/client/assets/index--vwACals.js +0 -1
  307. package/dist/client/assets/index-BydIKjk5.js +0 -1
  308. package/dist/client/assets/index-D18FqQKB.js +0 -1
  309. package/dist/client/assets/index-DBdO-_iL.js +0 -1023
  310. package/dist/client/assets/index-DLdpa3d4.js +0 -1
  311. package/dist/client/assets/index-vieeLeZH.js +0 -1
  312. package/dist/client/assets/primer-trigger-CfVHNFbe.js +0 -3
  313. package/dist/client/assets/registry-B3Ss4ItQ.js +0 -1
  314. package/dist/client/assets/shield-check-DbbCy17l.js +0 -6
  315. package/dist/client/assets/signed-in-CFtA8gTK.js +0 -1
  316. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-CgZZnzbW.js +0 -8
  317. package/dist/client/assets/use-is-below-desktop-BB9kHnYm.js +0 -1
  318. package/dist/client/assets/use-is-hub-ab4UGRdN.js +0 -1
  319. package/dist/client/assets/use-pending-read-BkCvAuX4.js +0 -1
  320. package/dist/client/assets/use-update-config-DTL7WyZV.js +0 -1
@@ -1,63 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DfSOcv9s.js","assets/index-DBdO-_iL.js","assets/index-CrflCTqO.css","assets/index-CodC2rG4.js"])))=>i.map(i=>d[i]);
2
- var mi=Object.defineProperty;var pi=(e,t,n)=>t in e?mi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var et=(e,t,n)=>pi(e,typeof t!="symbol"?t+"":t,n);import{fz as hi,hV as no,pF as gi,r as c,fw as xi,W as ut,dy as Ae,j as r,ar as V,bx as de,hK as ts,a1 as Se,l4 as so,q as it,jW as bi,pG as yi,pH as ro,pI as vi,pJ as ki,g8 as Ci,B as le,a7 as Te,pK as oo,pL as dt,pM as Qe,G as W,J as lt,X as Ue,pN as gt,gX as Si,pO as ji,I as _i,pP as wi,pQ as mn,pR as Ni,pS as Ei,fp as Di,b7 as vt,pT as ao,aW as ue,pU as Ti,pV as Ln,hI as Ai,as as io,d5 as Fi,ap as Ri,n2 as Mi,pW as Ms,dS as Os,a8 as ct,oD as Oi,pX as Ii,oJ as St,pY as Yt,a2 as Je,oF as ns,a4 as jt,hb as Nt,dR as ss,c6 as Et,cw as $i,cx as Pi,cz as Li,cA as zi,cB as Bi,dw as qi,e as Is,jw as Ui,dc as Hi,x as Le,jx as Wi,oB as rs,dN as Gi,pZ as Vi,p_ as Ki,jo as os,p$ as lo,q0 as co,q1 as Qi,q2 as Yi,iB as as,a3 as is,cr as Dt,dQ as ls,du as cs,dP as Xi,q3 as Ji,jf as uo,q4 as Zi,oG as el,hq as tl,dZ as nl,aR as Ye,ai as Tt,a9 as us,q5 as sl,n3 as rl,q6 as ol,ba as al,T as At,hy as He,hz as We,aj as fo,q7 as en,dx as Ft,jP as il,c4 as ft,s as Rt,gQ as ll,gk as $s,hE as mo,gU as cl,C as ds,d8 as ul,d9 as dl,q8 as fl,l as ml,mU as po,aT as pl,q9 as hl,qa as gl,qb as xl,qc as bl,qd as yl,qe as Pe,mB as we,mL as vl,mC as tn,aN as kl,hj as Cl,cc as Sl,bK as jl,iR as _l,a0 as fs,dz as Ps,d7 as ho,f as go,qf as wl,em as Nl,aX as El,f6 as xo,hN as bo,hu as _t,jg as yo,dA as Dl,qg as Tl,qh as Al,o as vo,y as nn,aS as ko,qi as Co,qj as Fl,lV as pn,i$ as Rl,kJ as Ml,bc as So,eK as Ol,eL as Ls,qk as zn,ql as jo,qm as Il,qn as $l,qo as _o,er as Pl,lc as Ll,g9 as zl,ga as Bl,gb as ql,gc as Ul,gd as Hl,ge as Wl,gf as Gl,gg as Vl,qp as ms,qq as Kl,qr as Ql,qs as Yl,iW as Xl,iX as Jl,iY as Zl,iZ as hn,qt as ec,i_ as zs,jO as tc,bP as nc,jQ as sc,bR as rc,qu as Bs,cf as oc,f$ as wo,ck as No,ca as ac,cj as ic,cq as Eo,co as lc,lG as ps,qv as cc,aw as uc,qw as dc,lh as ie,qx as fc,qy as mc,_ as pc,fW as qs,iy as Ke,qz as gn,me as kt,qA as Us,qB as Hs,qC as Ws,c5 as xn,qD as rt,eh as Ct,qE as hc,qF as Do,qG as To,qH as gc,qI as xc,qJ as Ao,lI as bc,qK as Fo,qL as tt,l0 as Ro,qM as yc,bO as vc,lH as kc,qN as Cc,fq as Mo,qO as Sc,bW as Gs,np as Oo,qP as jc,iq as _c,nr as wc,ns as Nc,ak as sn,qQ as Ec,qR as Dc,gx as Io,gu as hs,ke as Tc,qS as Ac,qT as Fc,qU as xt,qV as Rc,qW as Mc,cs as Oc,eG as Ic,lM as $c,fm as Pc,l7 as Lc,dI as zc}from"./index-DBdO-_iL.js";import{P as Bc}from"./PromptSuggestionChips-DQaDSd7Y.js";import{u as qc,a as Uc,L as Hc,f as Wc,b as Gc,c as Vc,B as Kc,d as Qc}from"./primer-trigger-CfVHNFbe.js";import{E as Yc,F as Xc,e as Jc,h as Zc,f as eu,P as tu,g as nu,d as su,q as ru,j as ou,b as au,G as iu,B as lu,H as $o,z as cu,u as uu,D as du,v as fu,t as mu,p as pu,w as hu,y as gu,o as xu,n as bu,k as yu,s as vu,M as ku,i as Cu,S as Su,U as ju,A as _u,I as wu,J as Nu,K as Vs,x as Eu,R as Du}from"./use-session-diagnostics-0gcI762B.js";import{C as Tu}from"./card-DTMhLU7B.js";import{a as Au,u as Fu,i as Ru}from"./use-notification-prefs-BAsICJ96.js";import{B as Mu}from"./banner-RKoWGrEp.js";import{t as $t,b as Bn,l as Ou,k as Iu,N as Po,n as $u,g as Pu,C as wt,M as nt,f as Lu,D as zu,U as Bu,F as qu}from"./index-B3ybVnXe.js";import{a as Uu,b as Hu}from"./markdown-content-BKbjOTI2.js";import{u as Wu,b as Gu}from"./WidgetErrorCard-BYMiUiAf.js";import{P as Vu,W as Ku,a as Qu,C as Yu,b as Xu}from"./find-latest-widget-fence-DFpYPIlS.js";import{a as Lo,b as Ju,R as Zu,K as ed,c as td,g as nd}from"./RuntimeConnectFlow-CgB_X5wo.js";import{a as zo,u as sd,I as rd}from"./image-off-dQCXn9D_.js";import{S as od}from"./shield-check-DbbCy17l.js";import{a as ad,c as id}from"./composer-insert-BpyATrmR.js";import{u as ld}from"./use-composer-prefs-DHY5vJ0l.js";import{A as qn,M as cd}from"./McpAppFrame-Dbg_Ni39.js";import{F as Bo}from"./file-Bg_qGvWR.js";import{S as ud}from"./shield-x-Cuo1GTv4.js";import{u as dd,M as fd}from"./McpSigninBody-ZmmY1BZ4.js";import{f as md}from"./format-duration-BCr6uzby.js";import{l as pd}from"./use-connector-management-CoinXIID.js";import{A as hd}from"./AgentRequestCard-BHIHWNRz.js";import{F as gd,i as xd}from"./use-session-canvas-sAwc2L1A.js";import{F as bd}from"./file-text-DQThCdY3.js";import"./use-is-below-desktop-BB9kHnYm.js";import"./git-branch-CJ1NlVLY.js";import"./use-update-config-DTL7WyZV.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./RuntimeSetupDialog-r1Ss_YQW.js";import"./inline-code-plzdKGm9.js";import"./list-runtime-types-CqKIrt9D.js";import"./unverified-catalog-notice-CQHA4Cst.js";import"./layers-Br3LALac.js";import"./cpu--56q_Ey0.js";import"./file-drag-GDx2qhdk.js";import"./paperclip-BDnApT-_.js";import"./index-BMktWriw.js";import"./index-vieeLeZH.js";import"./progress-BduTwXMX.js";import"./table-BjHA85BX.js";import"./terminal-qfxxVZaa.js";import"./package-DPgmy9lP.js";import"./heart-Beze5rli.js";import"./useMutationState-C9Q5lRej.js";import"./runtime-connect-Dn0T5YWv.js";import"./more-details-BsdCkGTg.js";import"./access-copy-B1SlOYEi.js";import"./query-error-state-puwJHnzi.js";import"./empty-state-BsA3jcrO.js";import"./use-bindings-DiFC7kWg.js";import"./connection-copy--MA7AN04.js";import"./KeyEntry-ClqAj0dS.js";import"./rotate-cw-C0EpbK5k.js";import"./query-keys-DeYqUDia.js";import"./index.esm-Ruqz-OsH.js";function yd(e,t,n={}){const s=e.get();let o=null,a=s,i;const l=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,u=()=>{o&&(o.stop(),o=null),e.animation=void 0},d=()=>{const h=Ks(e.get()),m=Ks(a);if(h===m){u();return}const x=o?o.getGeneratorVelocity():e.getVelocity();u(),o=new gi({keyframes:[h,m],velocity:x,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:i})},f=()=>{var h;d(),e.animation=o??void 0,(h=e.events.animationStart)==null||h.notify(),o==null||o.then(()=>{var m;e.animation=void 0,(m=e.events.animationComplete)==null||m.notify()})};if(e.attach((h,m)=>{a=h,i=x=>m(bn(x,l)),hi.postRender(f)},u),no(t)){let h=n.skipInitialAnimation===!0;const m=t.on("change",g=>{h?(h=!1,e.jump(bn(g,l),!1)):e.set(bn(g,l))}),x=e.on("destroy",m);return()=>{m(),x()}}return u}function bn(e,t){return t?e+t:e}function Ks(e){return typeof e=="number"?e:parseFloat(e)}function vd(e,t={}){const{isStatic:n}=c.useContext(xi),s=()=>no(e)?e.get():e;if(n)return zo(s);const o=sd(s());return c.useInsertionEffect(()=>yd(o,e,t),[o,JSON.stringify(t)]),o}function kd(e,t={}){return vd(e,{type:"spring",...t})}function Cd(e){const t=Math.floor(e/1e3);if(t<3600){const o=Math.floor(t/60),a=t%60;return`${o}m ${String(a).padStart(2,"0")}s`}const n=Math.floor(t/3600),s=Math.floor(t%3600/60);return`${n}h ${String(s).padStart(2,"0")}m`}function qo(e){const[t,n]=c.useState(()=>Date.now()),s=c.useRef(null);if(c.useEffect(()=>{if(e===null){s.current&&(clearInterval(s.current),s.current=null);return}return n(Date.now()),s.current=setInterval(()=>n(Date.now()),1e3),()=>{s.current&&(clearInterval(s.current),s.current=null)}},[e]),e===null)return{formatted:"0m 00s",ms:0};const o=Math.max(0,t-e);return{formatted:Cd(o),ms:o}}function Sd(e={}){const{timeoutMs:t=3e4,onIdle:n,onReturn:s}=e,o=c.useRef(!1),a=c.useRef(null),i=c.useCallback(()=>{o.current||(o.current=!0,n==null||n())},[n]),l=c.useCallback(()=>{o.current&&(o.current=!1,s==null||s())},[s]),u=c.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(i,t),l()},[t,i,l]);return c.useEffect(()=>{a.current=setTimeout(i,t);const d=["mousemove","keydown","scroll","touchstart"];d.forEach(h=>document.addEventListener(h,u,{passive:!0}));const f=()=>{document.hidden?i():u()};return document.addEventListener("visibilitychange",f),()=>{a.current&&clearTimeout(a.current),d.forEach(h=>document.removeEventListener(h,u)),document.removeEventListener("visibilitychange",f)}},[t,i,u]),{isIdle:o.current}}function jd({activeInteraction:e,onApprove:t,onAlwaysAllow:n,onDeny:s,onToggleOption:o,onNavigateOption:a,onNavigateQuestion:i,onSubmit:l,optionCount:u=0,focusedIndex:d=0}){const f=c.useRef(!1);c.useEffect(()=>{f.current=!1},[e==null?void 0:e.toolCallId]),c.useEffect(()=>{if(!e)return;function h(m){const x=m.target,g=(x.tagName==="TEXTAREA"||x.tagName==="INPUT")&&!x.disabled;if(!f.current&&!(m.metaKey||m.ctrlKey||m.altKey)){if(e.type==="approval"){if(m.key==="Enter"&&g&&x.closest("[data-approval-field]")!==null)return;m.key==="Enter"&&m.shiftKey?(m.preventDefault(),f.current=!0,n==null||n()):m.key==="Enter"?(m.preventDefault(),f.current=!0,t==null||t()):m.key==="Escape"&&(m.preventDefault(),f.current=!0,s==null||s());return}if(e.type==="question"){if(g){if(m.key==="Enter"&&!m.shiftKey){m.preventDefault(),l==null||l();return}if(m.key==="ArrowUp"){m.preventDefault(),a==null||a("up");return}if(m.key==="ArrowDown"){m.preventDefault(),a==null||a("down");return}return}const C=parseInt(m.key,10);if(C>=1&&C<=9){m.preventDefault(),C-1<u&&(o==null||o(C-1));return}switch(m.key){case"ArrowUp":m.preventDefault(),a==null||a("up");break;case"ArrowDown":m.preventDefault(),a==null||a("down");break;case" ":m.preventDefault(),o==null||o(d);break;case"ArrowLeft":case"[":m.preventDefault(),i==null||i("prev");break;case"ArrowRight":case"]":m.preventDefault(),i==null||i("next");break;case"Enter":m.preventDefault(),l==null||l();break}}}}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t,n,s,o,a,i,l,u,d])}function Uo(){const[e,t]=c.useState(()=>!document.hidden);return c.useEffect(()=>{const n=()=>t(!document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),e}/**
3
- * @license lucide-react v1.48.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */const Ho={name:"brain",size:24,node:[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]};Ho.node;const _d=ut(Ho);/**
8
- * @license lucide-react v1.48.0 - ISC
9
- *
10
- * This source code is licensed under the ISC license.
11
- * See the LICENSE file in the root directory of this source tree.
12
- */const Wo={name:"corner-up-left",size:24,node:[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]};Wo.node;const wd=ut(Wo);/**
13
- * @license lucide-react v1.48.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */const Go={name:"file-image",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]};Go.node;const Nd=ut(Go);/**
18
- * @license lucide-react v1.48.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */const Vo={name:"file-spreadsheet",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]};Vo.node;const Ed=ut(Vo);/**
23
- * @license lucide-react v1.48.0 - ISC
24
- *
25
- * This source code is licensed under the ISC license.
26
- * See the LICENSE file in the root directory of this source tree.
27
- */const Ko={name:"git-branch-plus",size:24,node:[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]};Ko.node;const Dd=ut(Ko);/**
28
- * @license lucide-react v1.48.0 - ISC
29
- *
30
- * This source code is licensed under the ISC license.
31
- * See the LICENSE file in the root directory of this source tree.
32
- */const Qo={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]};Qo.node;const Td=ut(Qo);function Ad({color:e,isTextStreaming:t,fadeEdges:n=!0,edge:s="bottom"}){const o=Ae()===!0,a=t?1.8:2.5,i=n?"linear-gradient(to right, transparent, black 15%, black 85%, transparent)":void 0,l=s==="top"?"pointer-events-none absolute right-0 top-0 left-0":"pointer-events-none absolute right-0 bottom-0 left-0",u="[--scan-highlight:hsl(var(--background))] dark:[--scan-highlight:hsl(var(--foreground))]",d=s==="top"?"top":"bottom";return r.jsxs(V.div,{"aria-hidden":!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:`${l} ${u}`,style:{height:n?10:0,overflow:n?"hidden":"visible",maskImage:i,WebkitMaskImage:i},children:[r.jsx("div",{className:"absolute right-0 left-0",style:{[d]:0,height:6,backgroundColor:e,opacity:.6,filter:"blur(3px)"}}),!o&&r.jsx(V.div,{initial:{x:"-100%"},animate:{x:"433%"},transition:{x:{duration:a,repeat:1/0,ease:"linear"}},className:"absolute",style:{[d]:0,width:"30%",height:2,background:`linear-gradient(to right, transparent, ${e}, var(--scan-highlight), transparent)`,willChange:"transform"}}),r.jsx(de,{children:t&&!o&&r.jsx(V.div,{initial:{opacity:0,x:"-100%"},animate:{opacity:.9,x:"1525%"},exit:{opacity:0},transition:{x:{duration:1.1,repeat:1/0,ease:"linear"},opacity:{duration:.2}},className:"absolute",style:{[d]:0,width:"8%",height:1,background:"linear-gradient(to right, transparent, var(--scan-highlight) 40%, var(--scan-highlight) 60%, transparent)",willChange:"transform"}})})]})}const yn={"word-boundary":3,substring:2,subsequence:1},Fd=new Set(["/",":","-","_","."," "]);function Rd(e,t){if(t===0)return!0;const n=e[t-1];if(Fd.has(n))return!0;const s=e[t];return n===n.toLowerCase()&&s!==s.toLowerCase()&&s===s.toUpperCase()}function Pt(e,t){return Array.from({length:t},(n,s)=>e+s)}function Lt(e,t,n){const s=1/(1+t),o=n/e.length;return(s*.6+o*.4)*.999}function Md(e,t){let n=0,s=0,o=0;const a=[];for(let i=0;i<t.length&&n<e.length;i++)t[i]===e[n]?(n++,s++,s>o&&(o=s),a.push(i)):s=0;return n===e.length?{indices:a,maxRun:o}:null}function Od(e,t){const n=t.indices[t.indices.length-1]-t.indices[0]+1,s=t.maxRun/t.indices.length,o=t.indices.length/n,a=t.indices.length/e.length;return(s*.4+o*.3+a*.3)*.999}function Vt(e,t){if(!e)return{match:!0,tier:null,score:0,indices:[]};const n=e.toLowerCase(),s=t.toLowerCase();if(s===n)return{match:!0,tier:"exact",score:5+Lt(t,0,n.length),indices:Pt(0,n.length)};if(s.startsWith(n))return{match:!0,tier:"prefix",score:4+Lt(t,0,n.length),indices:Pt(0,n.length)};for(let i=1;i<=s.length-n.length;i++)if(Rd(t,i)&&s.startsWith(n,i))return{match:!0,tier:"word-boundary",score:yn["word-boundary"]+Lt(t,i,n.length),indices:Pt(i,n.length)};const o=s.indexOf(n);if(o>=0)return{match:!0,tier:"substring",score:yn.substring+Lt(t,o,n.length),indices:Pt(o,n.length)};const a=Md(n,s);return a?{match:!0,tier:"subsequence",score:yn.subsequence+Od(t,a),indices:a.indices}:{match:!1,tier:null,score:0,indices:[]}}function Yo(e){return e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function Id(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function $d(e){return/^[/~.]/.test(e)||/\.(ts|tsx|js|jsx|json|md|py|rs|go|sh|yml|yaml|toml)$/.test(e)}function Un(e,t){if(e===null)return r.jsx("span",{className:"text-muted-foreground italic",children:"null"});if(typeof e=="boolean")return r.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:String(e)});if(typeof e=="number")return r.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:e});if(typeof e=="string"){const n=Id(e,t);return $d(e)?r.jsx("code",{className:"bg-muted rounded px-1 py-0.5 text-xs break-all",children:n}):r.jsx("span",{className:"break-words",children:n})}if(Array.isArray(e)){const n=e.slice(0,5),s=e.length-5;return r.jsxs("div",{className:"space-y-0.5",children:[n.map((o,a)=>r.jsx("div",{className:"border-border/40 border-l pl-2",children:Un(o,80)},a)),s>0&&r.jsxs("span",{className:"text-muted-foreground text-xs italic",children:["… and ",s," more"]})]})}if(typeof e=="object"){const n=Object.entries(e);return r.jsx("div",{className:"space-y-0.5",children:n.map(([s,o])=>r.jsxs("div",{className:"border-border/40 border-l pl-2",children:[r.jsxs("span",{className:"text-muted-foreground text-xs",children:[Yo(s),": "]}),typeof o=="object"&&o!==null?r.jsx("span",{className:"text-muted-foreground italic",children:"{…}"}):Un(o,80)]},s))})}return r.jsx("span",{children:String(e)})}function Xo({toolName:e,input:t,isStreaming:n=!1}){if(!t)return null;if(n){const a=t.length>5120?t.slice(0,5120)+"…":t;return r.jsxs("pre",{className:"text-muted-foreground overflow-x-auto text-xs whitespace-pre-wrap",children:[a,r.jsx("span",{className:"animate-breath ml-0.5 inline-block size-1.5 rounded-full bg-current"})]})}let s;try{s=JSON.parse(t)}catch{const a=t.length>5120?t.slice(0,5120)+"…":t;return r.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:a})}if(typeof s!="object"||s===null||Array.isArray(s)){const a=t.length>5120?t.slice(0,5120)+"…":t;return r.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:a})}const o=Object.entries(s);return o.length===0?null:r.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:o.map(([a,i])=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"text-muted-foreground py-0.5 font-medium whitespace-nowrap",children:Yo(a)}),r.jsx("dd",{className:"min-w-0 py-0.5",children:Un(i,120)})]},a))})}class Pd{constructor(t){et(this,"config");et(this,"recentCompletions",[]);et(this,"queue",[]);et(this,"isIdle",!1);et(this,"debounceTimer",null);this.config=t}onTaskCompleted(t,n){if(!this.config.enabled)return;const s=Date.now();this.recentCompletions.push(s),this.recentCompletions=this.recentCompletions.filter(l=>s-l<this.config.debounceWindowMs);const o=n.length,a=n.filter(l=>l.status==="completed").length;if(o>=this.config.minTasksForMajor&&a===o){this.cancelDebounce();const l={level:"major",taskId:t,timestamp:s};this.emitOrQueue(l);return}if(this.recentCompletions.length>=this.config.debounceThreshold){this.cancelDebounce(),this.debounceTimer=setTimeout(()=>{const l={level:"mini",taskId:t,timestamp:Date.now()};this.emitOrQueue(l),this.recentCompletions=[]},this.config.debounceWindowMs);return}if(Math.random()<this.config.miniProbability){const l={level:"mini",taskId:t,timestamp:s};this.emitOrQueue(l)}}setIdle(t){this.isIdle=t}onUserReturn(){if(this.queue.length>0){const n=this.queue.some(s=>s.level==="major")?this.queue.find(s=>s.level==="major"):this.queue[this.queue.length-1];this.config.onCelebrate(n),this.queue=[]}}destroy(){this.cancelDebounce(),this.queue=[],this.recentCompletions=[]}emitOrQueue(t){this.isIdle?this.queue.push(t):this.config.onCelebrate(t)}cancelDebounce(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}const Ld={background:"radial-gradient(circle, rgba(255,215,0,0.15) 0%, transparent 70%)"},zd={mode:"blur-in",duration:150,easing:"ease-out",sep:"word"},Bd={none:void 0,fade:"fadeIn","blur-in":"blurIn","slide-up":"slideUp"};function qd(e){const t=Bd[e.mode];return t?{animation:t,duration:e.duration??150,easing:e.easing??"ease-out",sep:e.sep??"word"}:!1}function Ud(e,t=40){if(e.length<=t)return e;const n=e.split("/").pop()??e,s=n.length+2,o=Math.max(6,t-s);return`${e.slice(0,o)}…/${n}`}function Hd({onlyFirst:e=!1}={}){const o="(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(o,e?void 0:"g")}const Wd=Hd({onlyFirst:!0});function Gd(e){if(Wd.test(e))return"ansi";const t=e.trimStart();if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}return"plain"}function rn(e){var n;const{sessions:t}=ts();if(e)return(n=t.find(s=>s.id===e))==null?void 0:n.runtime}const Vd=typeof window<"u"&&window.location.pathname===yi;let vn=null,Qs=!Vd;function Kd(e){return Qs?vn===e?!0:(vn=null,!1):(Qs=!0,vn=e,!0)}function Qd(e){var s;const t=Se(),n=((s=so(e))==null?void 0:s.draft)===!0;c.useEffect(()=>{if(!e||n)return;let o=!1;const a=()=>{o||document.visibilityState!=="visible"||(o=!0,document.removeEventListener("visibilitychange",a),Kd(e)||it.getState().recordOpened("session",e),t.markSessionOpened(e).catch(i=>{bi(t,i)}))};if(a(),!o)return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[e,n,t])}function Jo(){const e=ro(),t=so(e.session);return{cwd:(t==null?void 0:t.cwd)??e.dir??null}}function Zo({agentId:e,agentName:t,onResumed:n}){const s=vi(),{data:o,dataUpdatedAt:a,refetch:i}=ki(),[l]=c.useState(()=>Date.now());c.useEffect(()=>{i()},[e,i]);const u=t??"This agent";return o!=null&&a>=l&&!o.pauses.some(f=>f.agentId===e)?null:r.jsxs("div",{"data-testid":"agent-paused-notice",role:"status",className:"border-border bg-muted/50 my-2 flex items-center gap-3 rounded-lg border px-4 py-3",children:[r.jsx(Ci,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("p",{className:"text-sm font-medium",children:[u," is paused"]}),r.jsx("p",{className:"text-muted-foreground text-xs",children:"Resume it, then send your message again."})]}),r.jsx(le,{size:"sm",variant:"outline",disabled:s.isPending,onClick:()=>s.mutate(e,{onSuccess:()=>{Te(`${u} resumed`),n==null||n()}}),children:"Resume"})]})}const Yd={session:"this chat",project:"this project",user:"all your Claude chats"};function Xd(e){return e===void 0?void 0:Yd[e]}const Jd={duration:.12,ease:"easeOut"},Zd={duration:0},Ys=new Set(["Bash","Write","Edit","NotebookEdit"]),Xs=new Set(["WebFetch","WebSearch"]);function ef(e){const t=e.includes("__")?e.split("__").pop():e;return Ys.has(t)||Ys.has(e)?"high":Xs.has(t)||Xs.has(e)||e.startsWith("mcp__")?"medium":"low"}function tf(e){const t=Math.floor(e/60),n=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}`:`${n}s`}function ea({sessionId:e,toolCallId:t,toolName:n,input:s,isActive:o=!1,onDecided:a,ref:i,timeoutMs:l,approvalStartedAt:u,approvalRemainingMs:d,approvalParked:f,approvalTitle:h,approvalDisplayName:m,approvalDescription:x,approvalBlockedPath:g,approvalDecisionReason:C,approvalHasSuggestions:b,approvalAlwaysAllowScope:v,allowsDenyReason:k=!0}){const y=Se(),p=Ae(),j=c.useMemo(()=>ef(n),[n]),_=oo(n),D=dt(n,s),A=m||D,N=Xd(v),[T,S]=c.useState(!1),[E,w]=c.useState(null),[M,R]=c.useState(null),[F,I]=c.useState(!1),[z,B]=c.useState(""),J=c.useRef(""),[Y,G]=c.useState(!1),$=o&&!Y,[P,O]=c.useState(()=>Date.now()),Q=c.useRef(!1);c.useLayoutEffect(()=>{if(!Q.current){Q.current=!0;return}O(Date.now())},[l,u,d]);const[ce,H]=c.useState(null),U=c.useMemo(()=>{if(!l||f===!0)return null;const L=d!==void 0?P+d:u?u+l:P+l,ve=Math.min(l,Math.max(0,l-(L-P)));return{expiresAt:L,elapsedMs:ve}},[P,l,u,d,f]),X=E||!l||!U?null:ce!==null&&ce.expiresAt===U.expiresAt?ce.seconds:Math.max(0,Math.ceil((U.expiresAt-P)/1e3));c.useEffect(()=>{if(E||!l||!U)return;const{expiresAt:L}=U,ve=setInterval(()=>{const je=Math.max(0,Math.ceil((L-Date.now())/1e3));H({expiresAt:L,seconds:je}),je<=0&&clearInterval(ve)},1e3);return()=>clearInterval(ve)},[l,U,E]);const ne=f===!0||X===0,oe=E||X===null?"":X<=0?"Nobody answered. The agent is waiting for you.":X<=Ni?"One minute left to answer.":X<=Ei?"Two minutes left to answer.":"",K=c.useCallback(async()=>{if(!(T||E)){S(!0),R(null);try{await y.approveTool(e,t),w("approved"),a==null||a()}catch(L){L.code==="INTERACTION_ALREADY_RESOLVED"?(w("approved"),a==null||a()):(console.error("Approval failed:",L),R("Couldn’t send your answer. Try again."))}finally{S(!1)}}},[T,E,y,e,t,a]),ae=c.useCallback(async()=>{if(!(T||E)){S(!0),R(null);try{await y.approveTool(e,t,!0),w("approved"),a==null||a()}catch(L){L.code==="INTERACTION_ALREADY_RESOLVED"?(w("approved"),a==null||a()):(console.error("Always Allow failed:",L),R("Couldn’t send your answer. Try again."))}finally{S(!1)}}},[T,E,y,e,t,a]),ge=c.useCallback(async()=>{if(!(T||E)){S(!0),R(null);try{await y.denyTool(e,t,J.current.trim()||void 0),w("denied"),a==null||a()}catch(L){L.code==="INTERACTION_ALREADY_RESOLVED"?(w("denied"),a==null||a()):(console.error("Deny failed:",L),R("Couldn’t send your answer. Try again."))}finally{S(!1)}}},[T,E,y,e,t,a]);c.useImperativeHandle(i,()=>({approve(){K()},alwaysAllow(){ae()},deny(){ge()}}),[K,ae,ge]);const fe=r.jsx("span",{role:"status","aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:oe});if(E){const L=E==="approved";return r.jsxs(r.Fragment,{children:[r.jsx(V.div,{initial:p?!1:{opacity:0,scaleY:.9},animate:{opacity:1,scaleY:1},transition:p?Zd:Jd,style:{originY:0},children:r.jsx(Qe,{"data-testid":"tool-approval-decided","data-decision":E,icon:L?r.jsx(lt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}):r.jsx(Ue,{className:"text-status-error size-(--size-icon-sm) shrink-0"}),label:r.jsx("span",{className:"text-3xs font-mono",children:A}),trailing:r.jsx("span",{className:W("text-2xs rounded-full px-1.5 py-0.5 font-medium",L?"bg-status-success-bg text-status-success-fg":"bg-status-error-bg text-status-error-fg"),children:L?"Allowed":"Not allowed"})})}),fe]})}return r.jsxs(r.Fragment,{children:[r.jsxs(gt.Root,{isActive:o,isResolved:!!E,onAllow:K,onDeny:ge,className:"my-1","data-testid":"tool-approval",children:[r.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[r.jsx(Si,{className:W("size-(--size-icon-md)",j==="high"&&"text-status-error",j==="medium"&&"text-status-warning",j==="low"&&"text-muted-foreground")}),r.jsx(gt.Headline,{className:"font-semibold",children:h||"Your agent wants to use a tool"})]}),(x||C||g)&&r.jsxs(gt.Detail,{className:"mb-2",children:[x&&r.jsx("p",{children:x}),C&&!x&&r.jsx("p",{children:C}),g&&r.jsxs("p",{className:"font-mono",children:["Path: ",g]})]}),(l||ne)&&!E&&r.jsx("div",{className:"mb-2",children:r.jsx(gt.Countdown,{secondsLeft:ne?null:X,...ne?{}:{timeoutMs:l},elapsedMs:(U==null?void 0:U.elapsedMs)??0,label:ne?ji:X===null?"":`${tf(X)} remaining`})}),r.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[_&&r.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:_}),r.jsx("span",{className:"font-mono text-xs",children:A})]}),s&&r.jsx("div",{className:"bg-muted mb-3 rounded p-2",children:r.jsx(Xo,{toolName:n,input:s})}),M&&r.jsx("p",{className:"text-status-error text-2xs mb-2",children:M}),k&&F&&r.jsx("div",{className:"mb-2",children:r.jsx(_i,{autoFocus:!0,"data-approval-field":"",value:z,maxLength:wi,disabled:T,onFocus:()=>G(!0),onBlur:()=>G(!1),onChange:L=>{B(L.target.value),J.current=L.target.value},onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),ge())},placeholder:"Why not? The agent sees this.","aria-label":"Reason for not allowing",className:"text-xs"})}),r.jsxs(gt.Actions,{children:[r.jsxs(le,{size:"sm",onClick:K,disabled:T,className:"transition-opacity duration-150",children:[r.jsx(lt,{className:"size-(--size-icon-xs)"})," Allow",$&&r.jsx(mn,{className:"ml-1.5",children:"Enter"})]}),b&&r.jsxs(le,{size:"sm",variant:"outline",onClick:ae,disabled:T,"aria-label":N===void 0?"Always allow":`Always allow, ${N}`,className:"transition-opacity duration-150",children:[r.jsx(od,{className:"size-(--size-icon-xs)"})," Always allow",N!==void 0&&r.jsx("span",{className:"text-2xs opacity-70",children:`· ${N}`}),$&&r.jsx(mn,{className:"ml-1.5",children:"Shift+Enter"})]}),r.jsxs(le,{size:"sm",variant:"outline",onClick:ge,disabled:T,className:"transition-opacity duration-150",children:[r.jsx(Ue,{className:"size-(--size-icon-xs)"})," Don’t allow",o&&r.jsx(mn,{className:"ml-1.5",children:"Esc"})]}),k&&!F&&r.jsx("button",{type:"button",onClick:()=>I(!0),disabled:T,className:W("text-muted-foreground hover:text-foreground text-2xs rounded underline","focus-visible:ring-ring underline-offset-2 focus-visible:ring-2","focus-visible:outline-none disabled:opacity-50"),children:"Add a reason"})]})]}),fe]})}function nf(e){if(!e)return[];const t=e.properties??{};return Object.entries(t).map(([n,s])=>({key:n,label:s.description??n,type:s.type??"string",options:s.enum,defaultValue:s.default}))}function sf({sessionId:e,interactionId:t,serverName:n,message:s,mode:o="form",url:a,requestedSchema:i,status:l,action:u}){const d=Se(),[f,h]=c.useState(!1),[m,x]=c.useState(null),[g,C]=c.useState(null),[b,v]=c.useState({}),[k,y]=c.useState(!1),p=c.useMemo(()=>nf(i),[i]),j=l!=="pending",_=c.useCallback(async(E,w)=>{if(!(f||j)){h(!0),x(null),C(null);try{await d.submitElicitation(e,t,E,w)}catch(M){if(M.code!=="INTERACTION_ALREADY_RESOLVED"){x("Couldn’t send your answer. Try again."),C(M instanceof Error?M.message:null),h(!1);return}}h(!1)}},[d,e,t,f,j]),D=c.useCallback(()=>{const E={};for(const w of p)E[w.key]=b[w.key]??w.defaultValue??"";_("accept",E)},[p,b,_]),A=c.useCallback(()=>{_("accept")},[_]),N=c.useCallback(()=>{_("decline")},[_]),T=c.useCallback((E,w)=>{v(M=>({...M,[E]:w}))},[]),S=c.useCallback(()=>{if(a){if(!Di(a)){x(`Couldn’t open ${a}. Nothing has been authorized.`),C(null);return}x(null),C(null),y(!0)}},[a]);return j?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[r.jsx("span",{className:"font-mono",children:n}),r.jsx("span",{children:"·"}),r.jsx("span",{children:u==="accept"?"Authorized":u==="decline"?"Declined":"Cancelled"})]}):r.jsxs(V.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:W("border-border bg-card my-2 rounded-xl border p-4","shadow-soft"),children:[r.jsxs("div",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-xs",children:[r.jsx("span",{className:"bg-muted text-3xs inline-flex items-center rounded-md px-2 py-0.5 font-mono",children:n}),r.jsx("span",{children:"needs something from you"})]}),r.jsx("p",{className:"mb-3 text-sm",children:s}),m&&r.jsxs("div",{className:"mb-2",children:[r.jsx("p",{className:"text-destructive text-xs break-words",children:m}),g&&r.jsx("p",{className:"text-muted-foreground/70 mt-1 text-xs break-words",children:g})]}),o==="url"&&a&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",variant:"outline",onClick:S,disabled:f,children:"Open authorization page"}),k&&r.jsx(le,{size:"sm",onClick:A,disabled:f,children:f?"Sending…":"Done"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:N,disabled:f,children:"Decline"})]}),o==="form"&&r.jsxs(r.Fragment,{children:[p.length>0?r.jsx("div",{className:"mb-3 space-y-2",children:p.map(E=>r.jsxs("div",{children:[r.jsx("label",{htmlFor:`elicitation-${t}-${E.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:E.label}),E.options?r.jsxs("select",{id:`elicitation-${t}-${E.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:b[E.key]??String(E.defaultValue??""),onChange:w=>T(E.key,w.target.value),disabled:f,children:[r.jsx("option",{value:"",children:"Select…"}),E.options.map(w=>r.jsx("option",{value:w,children:w},w))]}):r.jsx("input",{id:`elicitation-${t}-${E.key}`,type:E.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(E.defaultValue??""),value:b[E.key]??"",onChange:w=>T(E.key,w.target.value),disabled:f})]},E.key))}):r.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",onClick:D,disabled:f,children:f?"Sending…":"Accept"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:N,disabled:f,children:"Decline"})]})]})]})}const rf=8,of={duration:.3,ease:[.16,1,.3,1]},af={duration:0};function lf(e){const t=Math.round(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}:${String(s).padStart(2,"0")}`:`${s}s`}function cf(e){return new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function uf(e){return`${e} action${e===1?"":"s"}`}function df({outcome:e,items:t,resolvedAt:n,startedAt:s,reasonGiven:o,className:a}){var C;const i=Ae(),[l,u]=c.useState(!1),d=t.length,f=d>1,h=f?uf(d):(C=t[0])==null?void 0:C.label,m=n!==void 0&&s!==void 0?Math.max(0,n-s):null,x=e==="allowed"?lt:e==="denied"?Ue:vt,g=e==="allowed"?"text-status-success":e==="denied"?"text-status-error":"text-muted-foreground";return r.jsxs(V.div,{"data-testid":"approval-receipt","data-outcome":e,"data-count":d,initial:i?!1:{opacity:0,y:rf},animate:{opacity:1,y:0},transition:i?af:of,className:W("text-muted-foreground my-1 text-xs",a),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(x,{className:W("size-(--size-icon-xs) shrink-0",g),"aria-hidden":"true"}),r.jsx("span",{className:"min-w-0 truncate",children:e==="expired"?r.jsxs(r.Fragment,{children:["Expired · ",f?`${h} `:"","denied",m!==null&&` after ${lf(m)}`]}):r.jsxs(r.Fragment,{children:["You ",e==="allowed"?"allowed":"denied"," ",f?h:r.jsx("span",{className:"font-mono",children:h}),e==="denied"&&o===!0&&r.jsx(r.Fragment,{children:" · agent was told why"})]})}),n!==void 0&&r.jsx("time",{dateTime:new Date(n).toISOString(),className:"ml-auto shrink-0 tabular-nums opacity-70",children:cf(n)}),f&&r.jsx("button",{type:"button",onClick:()=>u(b=>!b),"aria-expanded":l,className:W("hover:text-foreground focus-visible:ring-ring shrink-0 rounded underline","underline-offset-2 focus-visible:ring-2 focus-visible:outline-none"),children:l?"Hide":"Show"})]}),f&&l&&r.jsx("ul",{"data-testid":"approval-receipt-items",className:"mt-1 ml-6 space-y-0.5",children:t.map(b=>r.jsx("li",{className:"truncate font-mono",children:b.label},b.toolCallId))})]})}function ff({outcome:e,reasonGiven:t,members:n,lead:s,children:o}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(df,{outcome:e,items:n.map(a=>({toolCallId:a.toolCallId,label:a.approvalDisplayName||dt(a.toolName,a.input??"")})),resolvedAt:s.approvalResolvedAt,startedAt:s.approvalStartedAt,reasonGiven:t}),e!=="allowed"&&s.result&&r.jsx(ao,{"data-testid":"approval-receipt-result",content:s.result,className:"text-muted-foreground mt-0.5 ml-6"}),e==="allowed"&&o]})}function ta(e){return e.endsWith("connectors.request_connection")||e.endsWith("connectors_request_connection")}function na(e){if(e)try{return JSON.parse(e)}catch{return}}function Kt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function mf(e){const t=na(e);if(!Kt(t))return;const{serviceSlug:n,reason:s}=t;if(!(typeof n!="string"||typeof s!="string"))return{serviceSlug:n,reason:s}}function sa(e){const t=na(e);if(Kt(t)&&typeof t.requestId=="string")return t.requestId;if(Kt(t)&&Array.isArray(t.content)){const n=t.content.map(s=>Kt(s)&&typeof s.text=="string"?s.text:"").join("");return sa(n)}}function pf(e,t){const n=sa(t.result);if(n)return e.find(o=>o.requestId===n);const s=mf(t.input);if(s)return e.filter(o=>o.serviceSlug===s.serviceSlug).sort((o,a)=>a.createdAt.localeCompare(o.createdAt))[0]}function hf({sessionId:e,input:t,result:n,fallback:s}){const o=pd(e),a=o.data?pf(o.data,{input:t,result:n}):void 0;return a?r.jsx("div",{className:"my-3","data-testid":"chat-agent-request",children:r.jsx(hd,{request:a})}):r.jsx(r.Fragment,{children:s})}const kn={name:{exact:0,prefix:1,"word-boundary":2,substring:6,subsequence:8},alias:{exact:3,prefix:4,"word-boundary":5,substring:7,subsequence:9},description:{exact:10,prefix:11,"word-boundary":12,substring:13,subsequence:14}},gf={match:!1,bucket:Number.POSITIVE_INFINITY,score:0};function Js(e){return e.startsWith("/")?e.slice(1):e}function Zs(e,t){return e.bucket<t.bucket||e.bucket===t.bucket&&e.score>t.score}function xf(e,t){let n=gf;const s=Vt(e,Js(t.fullCommand));s.match&&s.tier&&(n={match:!0,bucket:kn.name[s.tier],score:s.score});for(const o of t.aliases??[]){const a=Vt(e,Js(o));if(!a.match||!a.tier)continue;const i={bucket:kn.alias[a.tier],score:a.score};Zs(i,n)&&(n={match:!0,...i,matchedAlias:o})}if(t.description){const o=Vt(e,t.description);if(o.match&&o.tier){const a={bucket:kn.description[o.tier],score:o.score};Zs(a,n)&&(n={match:!0,...a})}}return n}const ra="dorkos:mcp-app-consent:";function oa(e){return`${ra}${e}`}function bf(e){try{return localStorage.getItem(oa(e))==="granted"}catch{return!1}}function yf(e){try{localStorage.setItem(oa(e),"granted")}catch{}vf()}const Hn=new Set;function vf(){for(const e of Hn)e()}function kf(e){Hn.add(e);const t=n=>{var s;(s=n.key)!=null&&s.startsWith(ra)&&e()};return window.addEventListener("storage",t),()=>{Hn.delete(e),window.removeEventListener("storage",t)}}function Cf(e){const t=c.useSyncExternalStore(kf,()=>bf(e),()=>!1),n=c.useCallback(()=>yf(e),[e]);return{consented:t,grant:n}}const Sf="h-80";function jf({sessionId:e,serverName:t,uri:n,title:s}){const{consented:o,grant:a}=Cf(t),i=ue(d=>d.openPip),l=()=>{const d=ue.getState(),f={type:"mcp_app",serverName:t,uri:n,title:s};d.openCanvasDocument(f),Ln(d,"user",f)},u=()=>{i({kind:"mcp_app",sessionId:e,serverName:t,uri:n,title:s??`App · ${t}`})};return o?r.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[r.jsxs("div",{className:"bg-muted/40 flex items-center justify-between border-b px-3 py-1.5",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[r.jsx(qn,{className:"text-muted-foreground size-3.5 shrink-0"}),r.jsx("span",{className:"truncate",children:s??`App · ${t}`})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:u,"aria-label":"Pop out into a floating window",title:"Pop out",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:r.jsx(Vu,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:l,title:"Open in canvas",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:r.jsx(Ti,{className:"size-3.5"})})]})]}),r.jsx(cd,{sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:l,onRequestPip:u,className:Sf})]}):r.jsxs("div",{className:"bg-muted/40 flex flex-col gap-3 rounded-lg border p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r.jsx(qn,{className:"text-muted-foreground size-4 shrink-0"}),r.jsxs("span",{children:["Interactive app from ",t]})]}),r.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[r.jsxs("p",{children:["It runs code from ",t," in a sealed-off frame."]}),r.jsx("p",{children:"It can’t see your chat, files or credentials."})]}),r.jsx("div",{children:r.jsx("button",{type:"button",onClick:a,className:"bg-foreground text-background hover:bg-foreground/90 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",children:"Show app"})})]})}function _f(e){return e.replace(/[-_]+/g," ").trim()}function wf({action:e}){const t=Wu(),n=_f(e.actionId),s=`Widget interaction${e.title?`, ${e.title}`:""}: ${n}`;return r.jsxs(V.span,{"data-testid":"ui-action-chip",title:e.payload?JSON.stringify(e.payload):void 0,className:W("ml-auto inline-flex w-fit items-center gap-2 rounded-full border py-1 pr-3 pl-1.5","bg-muted/40 shadow-soft text-xs"),initial:t?{opacity:0,y:4,scale:.9}:!1,animate:t?{opacity:1,y:0,scale:1}:!1,transition:t?Gu:void 0,children:[r.jsx("span",{className:"sr-only",children:s}),r.jsx("span",{"aria-hidden":!0,className:"bg-primary/10 text-primary flex size-5 shrink-0 items-center justify-center rounded-full",children:r.jsx(Td,{className:"size-3"})}),r.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground truncate",children:[e.title&&r.jsx("span",{className:"text-foreground font-medium",children:e.title}),e.title&&r.jsx("span",{className:"px-1 opacity-50",children:"·"}),r.jsx("span",{className:"text-foreground font-medium",children:n})]})]})}const Nf=/<ui_action>([\s\S]*?)<\/ui_action>/;function er(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:null}catch{return null}}function Ef(e){const t=e.match(Nf);if(!t)return null;const n=t[1].split(`
33
- `);let s=null,o=null,a=null,i=null;for(let l=0;l<n.length;l++){const u=n[l],d=u.match(/^\s*Widget:\s*(.*)$/);if(d){const x=d[1].trim();s=x&&x!=="(untitled)"?x:null;continue}const f=u.match(/^\s*Action:\s*(.*)$/);if(f){o=f[1].trim();continue}const h=u.match(/^\s*Widget ID:\s*(.*)$/);if(h){a=h[1].trim()||null;continue}const m=u.match(/^\s*Payload:\s*(.*)$/);if(m){const x=m[1].trim();if(x&&x!=="(none)")i=er(x);else if(!x){let g="";for(let C=l+1;C<n.length;C++){g+=(g?`
34
- `:"")+n[C];const b=er(g.trim());if(b){i=b;break}}}break}}return o?{title:s,actionId:o,widgetId:a,payload:i}:null}function Df({onAllow:e,onNotNow:t}){return r.jsxs(Tu,{"data-slot":"notification-permission-primer",gap:"none",className:"flex-row flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2",children:[r.jsx(Ai,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsx("p",{className:"text-muted-foreground min-w-0 flex-1 text-xs",children:"Get notified when this needs you, even in another tab."}),r.jsxs("div",{className:"flex w-full shrink-0 flex-wrap items-center justify-end gap-1.5 sm:w-auto",children:[r.jsx(le,{variant:"ghost",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:t,children:"Not now"}),r.jsx(le,{variant:"outline",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:e,children:"Turn on notifications"})]})]})}function Tf(e){const t=qc(),{permission:n,request:s}=Au(),{prefs:o,setPrefs:a}=Fu(),{data:i}=io(),l=i!==void 0,[u,d]=c.useState(!1),f=Fi()||n==="unsupported";c.useEffect(()=>{if(f||!e)return;const g=setTimeout(Uc,Hc);return()=>clearTimeout(g)},[f,e]);const h=c.useCallback(()=>{d(!0),s().then(()=>{a({browserPermissionPrimerDismissed:!0})})},[s,a]),m=c.useCallback(()=>{d(!0),a({browserPermissionPrimerDismissed:!0})},[a]);return{eligible:!f&&l&&t&&!u&&n==="default"&&!o.browserPermissionPrimerDismissed,allow:h,notNow:m}}const Af="dorkos:chat:last-seen:";function Ff(){try{const e=[];for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n!=null&&n.startsWith(Af)&&e.push(n)}for(const t of e)window.localStorage.removeItem(t)}catch{}}function Rf(e){let t=0;for(const n of e)n._streaming!==!0&&t++;return t}function Mf(e){if(typeof e!="object"||e===null)return!1;const{userId:t,threadKind:n,threadId:s,lastReadSeq:o}=e;return typeof t=="string"&&typeof n=="string"&&typeof s=="string"&&typeof o=="number"&&Number.isInteger(o)}function Of(e,t,n=0){const s=Se(),[o,a]=c.useState(()=>({sessionId:e,lastReadSeq:null,hydrated:!1}));o.sessionId!==e&&a({sessionId:e,lastReadSeq:null,hydrated:!1});const i=c.useRef(0),l=c.useRef(null),u=c.useRef(!1),d=c.useRef(!1),f=c.useRef(e),h=c.useRef(null),m=n+Rf(t);c.useEffect(()=>{Ff();let k=!1;return f.current=e,i.current=0,l.current=null,u.current=!1,d.current=!1,(async()=>{let y=null;try{y=await s.getReadCursor("session",e)}catch{}k||(y&&(i.current=y.lastReadSeq,h.current=y.userId),a({sessionId:e,lastReadSeq:(y==null?void 0:y.lastReadSeq)??null,hydrated:!0}))})(),()=>{k=!0}},[s,e]);const x=c.useCallback(async()=>{if(!u.current){u.current=!0;try{for(;;){const k=l.current;if(k===null)break;if(l.current=null,k.sessionId!==f.current)continue;if(d.current)break;const y=i.current;i.current=Math.max(y,k.seq);try{const p=await s.setReadCursor("session",k.sessionId,k.seq);h.current=p.userId??h.current}catch{i.current=y,k.sessionId===f.current&&(d.current=!0);break}}}finally{u.current=!1}}},[s]),g=c.useCallback(()=>{!o.hydrated||d.current||m<=i.current||(l.current={sessionId:e,seq:m},x())},[o.hydrated,e,m,x]);Ri("read_cursor",k=>{if(!Mf(k)||k.threadKind!=="session"||k.threadId!==e)return;const y=h.current;y!==null&&k.userId!==y||k.lastReadSeq<=i.current||(i.current=k.lastReadSeq,a({sessionId:e,lastReadSeq:k.lastReadSeq,hydrated:!0}))});const C=c.useMemo(()=>t.filter(k=>k._streaming!==!0).map((k,y)=>({id:k.id,seq:n+y+1})),[t,n]),b=o.lastReadSeq,v=Mi(C,b===null?null:Math.min(b,m));return{lastSeenMessageId:v.lastSeenId,unreadFromStart:v.fromStart,markSeen:g,isHydrated:o.hydrated}}function Xe(e){return e.notAllowed!==!0&&e.usage.state!=="limited"}function If(e,t){if(e.id===ct||!e.eligible)return e.reason;const n=Oi(e.usage,"seven_day");if(!n||n.usedPct===null)return"usage unknown";const s=Math.min(100,Math.max(0,Math.round(100-n.usedPct))),o=Ii(n.resetsAt,t);return o?`${s}% left · resets ${o}`:`${s}% left`}function on(e,t){return e.runtime!==void 0&&e.runtime!==t}function $f(e,t){const n=[],s=[];for(const o of e)(on(o,t)?s:n).push(o);return{same:n,other:s}}function Xt(e,t){return`${e.runtime??t}:${e.id}`}function Pf(e,t,n){if(on(e,t)){const s=e.runtime;return!e.label&&e.id===St?`${Yt({runtime:s,accountLabel:null,identityGate:!1})} (this computer's sign-in)`:Yt({runtime:s,accountLabel:e.label,identityGate:!0})}return e.label?e.label:e.id===St&&e.usage.label?e.usage.label:e.usage.path?n(e.usage.path):e.id}function Lf(e,t){const n=e.accounts.find(o=>o.id===e.recommendedId);if(n&&Xe(n))return Xt(n,t);const s=e.accounts.find(Xe);return s?Xt(s,t):null}function zf(e){return e.length===0?null:e.length===1?`${e[0]} is kept out, so it isn’t listed.`:`${`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`} are kept out, so they aren’t listed.`}function Bf(e,t){if(e&&t)return{subtitle:"Picks up in the same folder and branch, from the last checkpoint.",carries:"Carries over: files, branch, checkpoint, task",doesnt:"Doesn’t: the chat itself"};const n="Starts a new chat in the same folder, with a summary of this one.";return{subtitle:e?n:`${n} Sorted by most usage left.`,carries:"Carries over: the folder and a summary of this chat",doesnt:"Doesn’t: the chat itself"}}function qf(e){return e.carryOver===!1}function Uf(e,t,n){return e?!0:(t==null?void 0:t.accounts.some(s=>on(s,n)))??!1}function Hf(e){return{id:ct,runtime:e,label:Os,color:Ms,eligible:!0,reason:"paid from your DorkOS account",usage:{runtime:"claude-code",accountId:ct,path:"",label:Os,color:Ms,subscriptionType:null,plan:null,credits:null,spend:null,windows:[],state:"unknown",limit:null,updatedAt:null}}}function aa(e,t){const n=Se();return Je({queryKey:ns.continueOptions(e),queryFn:()=>n.getContinueOptions(e),enabled:t,staleTime:0,retry:!1})}function Wf(e){const t=Se();return jt({mutationFn:n=>t.continueSession(e,n),retry:!1})}function Gf(e){const t=Se();return jt({mutationFn:()=>t.cancelAutoContinue(e),retry:!1})}const tr="claude-code",Vf="No other account can take this work right now.";function Kf(e){return e instanceof Error&&e.message?e.message:"Couldn’t continue on that account. Try again."}function Qf({row:e,value:t,name:n,status:s,selected:o}){const a=Xe(e);return r.jsxs("label",{"data-slot":"continue-account-row","data-eligible":e.eligible,className:W("flex min-h-11 min-w-0 items-center gap-1.5 rounded-lg border px-2.5 py-2 text-sm transition-colors duration-150","has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-[3px]",o?"border-foreground ring-foreground ring-1 ring-inset":"border-border",a?"hover:bg-muted/50 cursor-pointer":"cursor-not-allowed",!e.eligible&&"opacity-60"),children:[r.jsx(Wi,{value:t,disabled:!a,className:"sr-only"}),r.jsx("span",{"aria-hidden":!0,className:"inline-flex",children:r.jsx(rs,{color:e.color,name:n})}),r.jsx("span",{className:"max-w-[55%] shrink-0 truncate font-medium",children:n}),e.badge==="recommended"&&r.jsx("span",{className:W(Gi.success,"border-status-success-border text-2xs shrink-0 rounded-full border px-1.5"),children:"recommended"}),r.jsx("span",{className:"text-muted-foreground ml-auto min-w-0 pl-1 text-right text-xs",children:s})]})}function ia({open:e,onOpenChange:t,sessionId:n,account:s,cancelAutoFirst:o=!1,now:a,onCloseAutoFocus:i}){var ce;const l=Nt(),u=a??new Date(l),d=c.useId(),f=s.runtime??tr,{accounts:h,nameFor:m}=ss(),[,x]=Et(),g=Gf(n),C=c.useRef(!1),{mutate:b,reset:v}=g;c.useEffect(()=>{if(!e){C.current=!1,v();return}!o||C.current||(C.current=!0,b())},[e,o,b,v]);const k=e&&(!o||g.isSuccess),y=aa(n,k),p=Wf(n),[j,_]=c.useState(null),D=()=>{p.isPending||(_(null),p.reset(),t(!1))},A=H=>H?t(!0):D(),N=k?y.data:void 0,T=N==null?void 0:N.ranking,S=N&&!qf(N.plan)?[...N.ranking.accounts,...N.credits?[Hf(f)]:[]]:[],E=S.some(Xe),w=j??(T?Lf(T,f):null),M=S.find(H=>Xt(H,f)===w)??null,R=M!==null&&Xe(M),F=H=>Pf(H,f,m),{same:I,other:z}=$f(S,f),B=Bf((N==null?void 0:N.advised)===!0,s.trackerItems.some(H=>H.via==="this-chat")),J=s.accountId??((ce=s.limit)==null?void 0:ce.accountId)??null,Y=(N==null?void 0:N.advised)===!0&&f===tr&&J!==null?zf(h.filter(H=>H.id&&H.id!==J&&!I.some(U=>U.id===H.id)).map(H=>m(H.path))):null,G=()=>{!M||!Xe(M)||p.mutate(on(M,f)?{account:M.id,runtime:M.runtime}:{account:M.id},{onSuccess:H=>{D(),H.sessionId&&x(H.sessionId)}})},$=H=>{const U=Xt(H,f);return r.jsx(Qf,{row:H,value:U,name:F(H),status:If(H,u),selected:U===w},U)},P=g.isError?g.error:y.isError&&k?y.error:p.isError?p.error:null,O=e&&!P&&(!k||y.isPending),Q=!O&&N!==void 0;return r.jsx($i,{open:e,onOpenChange:A,children:r.jsxs(Pi,{className:"max-h-[85vh] !min-h-0",desktopProps:{className:"sm:max-w-[380px]"},onCloseAutoFocus:i,"aria-labelledby":d,children:[r.jsxs(Li,{className:"shrink-0 text-left",children:[r.jsx(zi,{id:d,className:"text-left",children:"Continue on another account"}),r.jsx(Bi,{className:"text-left",children:B.subtitle})]}),r.jsxs(qi,{className:"flex flex-col gap-3",children:[O&&r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx(Is,{className:"h-11 rounded-lg"}),r.jsx(Is,{className:"h-11 rounded-lg"})]}),Q&&(E?r.jsxs(Ui,{"aria-labelledby":d,value:w??"",onValueChange:_,className:"min-w-0 grid-cols-1 gap-1.5",children:[I.map($),z.length>0&&r.jsx("div",{className:"text-muted-foreground mt-2 text-xs font-semibold tracking-wide uppercase",children:"Other runtimes"}),z.map($)]}):r.jsx("p",{className:"text-muted-foreground text-sm",children:Vf})),Q&&Y&&r.jsx("p",{className:"text-muted-foreground text-xs",children:Y}),Q&&r.jsxs("ul",{className:"text-muted-foreground list-disc pl-4 text-xs",children:[r.jsx("li",{children:B.carries}),r.jsx("li",{children:B.doesnt})]}),P!==null&&r.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Kf(P)})]}),r.jsxs(Hi,{className:"shrink-0",children:[r.jsx(le,{variant:"outline",onClick:D,disabled:p.isPending,children:"Cancel"}),r.jsxs(le,{onClick:G,disabled:!Q||!E||!R||p.isPending,"aria-busy":p.isPending||void 0,children:[p.isPending&&r.jsx(Le,{}),M&&Q&&E?`Continue on ${F(M)}`:"Continue"]})]})]})})}const Yf=1440*60*1e3,Xf="Paused until you continue or the account resets",Jf="Paused until the task moves or the account resets",Zf=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited"]);function em(e){return Zf.has(e)?"critical":"neutral"}function la(e){return e.carryOver===!1}function ot(e,t){return e!==null&&Date.parse(e)<=t.getTime()}function gs(e){return`${e} should have reset by now.`}function tm(e,t,n,s){if(ot(n,s))return gs(e);const o=Vi(t,n,s);return o==="out"?`${e} is out of usage.`:o.startsWith("back in ")?`${e} is out of usage · ${o}.`:`${e} is out of usage ${o.slice(4)}.`}function ca(e){return e.plan.mode==="waiting"&&e.plan.resumeAt?e.plan.resumeAt:e.resetsAt}function nr(e,t,n){if(t===null)return`Waiting for ${e}`;if(ot(t,n))return gs(e);const s=Date.parse(t)-n.getTime();return s<Yf?`Waiting for ${e} · back in ${Ki(s)}`:`Waiting for ${e} · back ${os(t,n)}`}function nm(e,t){return Math.max(0,Math.ceil((Date.parse(e)-t.getTime())/1e3))}const sm=new Set(["continue-on","move-now","keep-going","resume","open-moved"]);function rm(e,t){return(()=>{switch(e){case"limited":return[t.canPick&&"continue-on","wait"];case"handing-off":return["move-now",t.canPick&&"choose","wait"];case"model-limited":return[t.hasFallback&&"keep-going",t.canPick&&"continue-on","wait"];case"wait-only":case"all-accounts-out":return["wait"];case"reset-ready":return["resume"];case"moved":return["open-moved",!t.continuedHere&&"continue-here"];default:return[]}})().filter(s=>s!==!1)}const om=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited","waiting-reset"]),Cn={canSubmit:!0,placeholder:null};function am(e,t,n){if(!e)return Cn;const s=lo(e);if(s==="moved")return{canSubmit:t,placeholder:null};if(!om.has(s))return Cn;const o=i=>i!==null&&!ot(i,n);return o(ca(e))||e.plan.mode==="auto"&&o(e.plan.fireAt)?{canSubmit:!1,placeholder:s==="handing-off"?Jf:Xf}:Cn}const im=300*1e3;function ua(e,t){const n=Date.parse(e)-Date.parse(t);return Number.isFinite(n)&&n>=0&&n<=im}function lm(e,t){let n=null;for(const s of e)ua(s.since,t)&&(n===null||Date.parse(s.since)<Date.parse(n.since))&&(n=s);return n}function Wn(e,t){var n;return e?((n=t.find(s=>s.value===e))==null?void 0:n.displayName)??e:null}function cm(e,t){return{from:Wn(e.modelFrom,t)??(e.scope==="model"?co(e.window,t):null),to:Wn(e.modelTo,t)}}function da(){const{accounts:e,nameFor:t,colorFor:n}=ss(),s=Qi("claude-code",{accountId:St,path:null});return o=>{const a=Yi({accountId:o,path:null,accounts:e,usage:o===St?s:null,nameFor:t,colorFor:n});return{name:a.name??o,color:a.color}}}const sr=as(e=>({episodes:new Set,choose:t=>e(n=>n.episodes.has(t)?n:{episodes:new Set([...n.episodes,t])})}));function um(e,t){return`${e}\0${t}`}function fa(e,t){const n=t===null?null:um(e,t),s=sr(a=>n!==null&&a.episodes.has(n)),o=sr(a=>a.choose);return{continuedHere:s,continueHere:()=>{n!==null&&o(n)}}}const rr="claude-code",dm=new Set(["limited","handing-off","model-limited"]),fm=new Set(["limited","model-limited","all-accounts-out"]);function mm(e){return(e==null?void 0:e.runsOn)==="own-sign-in"&&e.chosenBy==="user"}function pm(e){return e instanceof Error&&e.message?e.message:"Couldn’t do that. Try again."}function hm(e,t){var J,Y,G;const n=Se(),s=is(),[,o]=Et(),a=Dt(e,{fetchUsage:!1}),i=t??a,l=i.limit,u=l?lo(l):null,d=i.runtime??rr,f=i.visible,h=da(),m=d===rr&&(l!=null&&l.accountId)?h(l.accountId).name:i.name,x=Yt({runtime:d,accountLabel:m,identityGate:f}),g=ls({sessionId:e||void 0,runtime:d}).data??[],C=l?la(l.plan):!0,b=u!==null&&dm.has(u)&&!C,{isLoaded:v}=ss(),{data:k}=cs(),y=v&&k!==void 0,p=u==="model-limited",j=aa(e,b&&y&&(p?f:!f)),_=b&&(p?f&&(((J=j.data)==null?void 0:J.ranking.accounts.some(Xe))??!1):Uf(f,(Y=j.data)==null?void 0:Y.ranking,d)),{continuedHere:D,continueHere:A}=fa(e,(l==null?void 0:l.since)??null),{data:N}=Xi(),T=u!==null&&fm.has(u)&&!C&&(l==null?void 0:l.accountId)!==ct&&Ji(N,d)&&!mm((G=N==null?void 0:N.defaults)==null?void 0:G[d]),S=(l==null?void 0:l.since)??null,E=`${S}:${u}`,[w,M]=c.useState(null),R=$=>M($===null?null:{key:E,message:$}),F=$=>R(pm($)),I=jt({mutationFn:$=>n.waitForReset(e,$),retry:!1,onError:F}),z=jt({mutationFn:$=>n.continueSession(e,$),retry:!1,onError:F,onSuccess:$=>{$.sessionId&&$.sessionId!==e&&o($.sessionId)}}),B=c.useRef(S);return c.useEffect(()=>{B.current!==null&&S===null&&s.invalidateQueries({queryKey:ns.limitHistory(e)}),B.current=S},[S,e,s]),{account:i,limit:l,state:u,runtime:d,subject:x,identityGate:f,canPick:_,creditsOffered:T,nameOf:h,models:g,continuedHere:D,continueHere:A,wait:$=>{R(null),I.mutate($===void 0?{}:{autoResume:$})},continueOn:$=>{R(null),z.mutate($)},openSession:$=>o($),pending:I.isPending||z.isPending,failure:(w==null?void 0:w.key)===E?w.message:null}}function Sn({visible:e,spoken:t,spokenKey:n}){const[s,o]=c.useState({key:n,text:t});return s.key!==n&&o({key:n,text:t}),r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:e}),r.jsx("span",{className:"sr-only",children:s.key===n?s.text:t})]})}function jn({account:e,showDot:t}){return r.jsxs(r.Fragment,{children:[t&&e.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-1 inline-flex align-middle",children:r.jsx(rs,{color:e.color,name:e.name,tooltip:!1})}),e.name]})}function gm(e,t){switch(e){case"continue-on":return"Continue on another account…";case"move-now":return"Move now";case"choose":return"Choose account…";case"keep-going":return`Keep going on ${t}, same account`;case"resume":return"Continue";case"open-moved":return"Open it →";case"continue-here":return"Continue here anyway";case"wait":return"Wait for reset"}}function xm({sessionId:e,onSend:t,account:n,now:s}){const o=hm(e,n),a=uo(),{limit:i,state:l,subject:u,identityGate:d}=o,f=Nt(l==="handing-off"?1e3:6e4),h=s??new Date(f),m=i?i.since:null,[x,g]=c.useState(null),C=o.canPick&&m!==null&&x===m,b=E=>g(E?m:null),v=c.useId();if(!i||!l)return null;const k=o.creditsOffered&&a!==null,y=i.plan,p=Wn(i.modelFallback,o.models),j=rm(l,{canPick:o.canPick,hasFallback:p!==null,continuedHere:o.continuedHere}),_=`${l}:${i.since}:${u}`;let D,A=null,N=!1;switch(l){case"all-accounts-out":{D="All accounts are out.";const E=i.allOut;if(E!=null&&E.resetsAt){const w=o.nameOf(E.accountId);A=ot(E.resetsAt,h)?gs(w.name):r.jsxs(r.Fragment,{children:["Soonest back: ",r.jsx(jn,{account:w,showDot:d}),","," ",os(E.resetsAt,h)]})}break}case"model-limited":D=`${co(i.window,o.models)} is out on ${u} for this week.`;break;case"waiting-reset":{const E=ca(i);D=r.jsx(Sn,{visible:nr(u,E,h),spoken:nr(u,E,h),spokenKey:`${_}:${ot(E,h)}`});break}case"reset-ready":D=y.mode==="waiting"&&y.unconfirmed?`${u} should have reset by now.`:`${u} has reset.`;break;case"moved":{if(y.mode!=="continued")return null;const E=o.nameOf(y.accountId);D=r.jsxs(r.Fragment,{children:["This task continued on ",r.jsx(jn,{account:E,showDot:d}),"."]});break}default:{const E=tm(u,i.window,i.resetsAt,h);if(D=r.jsx(Sn,{visible:E,spoken:E,spokenKey:`${_}:${ot(i.resetsAt,h)}`}),l==="handing-off"&&y.mode==="auto"){const w=o.nameOf(y.target),M=nm(y.fireAt,h);N=M===0,A=r.jsx(Sn,{visible:r.jsxs(r.Fragment,{children:["Moving this task to ",r.jsx(jn,{account:w,showDot:d}),N?"…":` in ${M}s…`]}),spoken:N?`Moving this task to ${w.name}.`:`Moving this task to ${w.name} in ${M} seconds.`,spokenKey:`${_}:${y.fireAt}:${w.name}:${N}`})}}}const T=E=>{switch(E){case"continue-on":case"choose":b(!0);return;case"move-now":y.mode==="auto"&&o.continueOn({account:y.target});return;case"keep-going":i.modelFallback&&o.continueOn({model:i.modelFallback});return;case"resume":t(Zi);return;case"open-moved":y.mode==="continued"&&o.openSession(y.sessionId);return;case"continue-here":o.continueHere();return;case"wait":o.wait();return}},S=l==="waiting-reset"&&y.mode==="waiting"&&!la(y);return r.jsxs(r.Fragment,{children:[r.jsxs(Mu,{variant:em(l),role:"status",icon:null,"data-slot":"account-limit-banner","data-state":l,className:"mx-4 mb-2 rounded-lg border px-3 py-2",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"font-semibold",children:D}),A&&r.jsxs(r.Fragment,{children:[" ",A]})]}),S&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[r.jsx("input",{id:v,type:"checkbox",className:"size-3.5",checked:y.autoResume,disabled:o.pending,onChange:E=>o.wait(E.target.checked)}),r.jsx("label",{htmlFor:v,children:"Continue automatically when it resets"})]}),k&&a&&r.jsx("div",{className:"mt-1.5",children:a({runtime:o.runtime,origin:`limit:${e}`,intent:"keep-going",confirmAfterLink:{prompt:"Linked. Continue on DorkOS credits?",action:"Continue"},onChoose:()=>o.continueOn({account:ct})})}),j.length>0&&r.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:j.map(E=>r.jsx(le,{size:"sm",variant:sm.has(E)&&!k?"default":E==="continue-here"?"ghost":"outline",className:"h-auto min-h-11 max-w-full py-1 whitespace-normal md:min-h-8",disabled:o.pending||E==="move-now"&&N,onClick:()=>T(E),children:gm(E,p)},E))}),o.failure&&r.jsx("p",{role:"alert",className:"text-destructive mt-1.5",children:o.failure})]}),o.canPick&&r.jsx(ia,{open:C,onOpenChange:b,sessionId:e,account:{runtime:o.runtime,accountId:o.account.accountId,limit:i,trackerItems:o.account.trackerItems},cancelAutoFirst:l==="handing-off",now:s})]})}function bm(e){const t=Se();return Je({queryKey:ns.limitHistory(e),queryFn:()=>t.getLimitHistory(e),enabled:e!=="",retry:!1})}const ym={moved:tl,"resumed-reset":vt,"resumed-model":vt,"resumed-early":vt};function vm({entry:e,now:t}){const n=Nt(),s=t??new Date(n),o=da(),a=el(e.runtime),i=ls({runtime:e.runtime}).data??[],[,l]=Et(),u=e.runtime==="claude-code"&&e.accountId?o(e.accountId).name:null,d=Yt({runtime:e.runtime,accountLabel:u,identityGate:a}),f=`at ${os(e.resolvedAt,s)}`,h=ym[e.resolution];let m;switch(e.resolution){case"moved":{const x=e.toAccountId?o(e.toAccountId):null,g=x?r.jsxs(r.Fragment,{children:[a&&x.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-0.5 inline-flex align-middle",children:r.jsx(rs,{color:x.color,name:x.name,tooltip:!1})}),x.name]}):null;m=r.jsxs(r.Fragment,{children:[d," ran out · moved",g&&r.jsxs(r.Fragment,{children:[" to ",e.toSessionId?r.jsx("button",{type:"button",className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 outline-none focus-visible:ring-2",onClick:()=>l(e.toSessionId),children:g}):g]})," ",f]});break}case"resumed-reset":m=`Resumed after reset ${f}`;break;case"resumed-model":{const{from:x,to:g}=cm(e,i);m=g?`${x??d} ran out · continued on ${g} ${f}`:`${d} ran out · continued here ${f}`;break}case"resumed-early":m=`${d} ran out · continued here ${f}`;break}return r.jsxs("p",{"data-slot":"account-limit-marker","data-resolution":e.resolution,className:"text-muted-foreground text-2xs my-2 flex items-center gap-1.5",children:[r.jsx(h,{"aria-hidden":!0,className:"size-3 shrink-0"}),r.jsx("span",{className:"min-w-0",children:m})]})}function km({sessionId:e,at:t,fallback:n,now:s}){const{limit:o}=Dt(e,{fetchUsage:!1}),a=bm(e),[i,l]=c.useState(null),u=o!==null&&(t===""||ua(o.since,t));if(u&&((i==null?void 0:i.data)!==a.dataUpdatedAt||i.error!==a.errorUpdatedAt)&&l({data:a.dataUpdatedAt,error:a.errorUpdatedAt}),u||a.isPending)return null;const d=a.data&&t?lm(a.data.entries,t):null;return d?r.jsx(vm,{entry:d,now:s}):o===null&&i!==null&&a.dataUpdatedAt===i.data&&a.errorUpdatedAt===i.error?null:r.jsx(r.Fragment,{children:n})}function Cm(e){const{limit:t}=Dt(e,{fetchUsage:!1}),{continuedHere:n}=fa(e,(t==null?void 0:t.since)??null),s=Nt();return am(t,n,new Date(s))}function Sm(e){return Dt(e,{fetchUsage:!1}).limit!==null}function jm({text:e,indices:t,startOffset:n=0}){const s=new Set(t.map(o=>o-n));return r.jsx(r.Fragment,{children:e.split("").map((o,a)=>s.has(a)?r.jsx("span",{className:"text-foreground font-semibold",children:o},a):r.jsx("span",{children:o},a))})}function _m({filteredFiles:e,selectedIndex:t,onSelect:n}){return c.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),r.jsx(V.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:s=>s.preventDefault(),children:r.jsx("div",{id:"file-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No files found."}):e.map((s,o)=>{const a=o===t,i=s.isDirectory?nl:Bo;return r.jsxs("div",{id:`file-item-${o}`,role:"option","aria-selected":a,"data-selected":a,tabIndex:a?0:-1,onClick:()=>n(s),onKeyDown:l=>{l.key==="Enter"&&n(s)},className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[r.jsx(i,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:r.jsx(jm,{text:s.filename,indices:s.indices,startOffset:s.directory.length})}),s.directory&&r.jsx("p",{className:"text-muted-foreground/70 truncate text-xs leading-normal",children:s.directory})]})]},s.path)})})})}function wm(e){const t=Se();return Je({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:Ye.FILES_STALE_TIME_MS,gcTime:Ye.FILES_GC_TIME_MS})}const Nm="You",Em="human",Dm="system",Tm="System",Am="agent",Fm="Agent",Rm="chat-sender:",or="room-author:",Mm="Room member",Om="runtime:";function Im(e){return e.messageType==="local_command_output"||e.messageType==="compaction"}function $m(e,t){var a,i,l,u,d,f;if(Im(e)||e._chatStop)return{kind:"system",id:Dm,displayName:Tm};const n=e.role==="user"?(i=(a=e.chatMessages)==null?void 0:a[0])==null?void 0:i.from:void 0;if(n){const h=n.agentId??n.chatId,m=((l=t.senderAgent)==null?void 0:l.call(t,n))??Tt({id:h});return{kind:"agent",id:`${Rm}${h}`,displayName:n.agentName,emoji:m.emoji,color:m.color}}const s=e.role==="user"?e.roomMessage:void 0;if(s&&!((u=s.author)!=null&&u.you))return Pm(s,t);if(e.role==="user")return{kind:"human",id:Em,displayName:((d=t.humanName)==null?void 0:d.trim())||Nm};if(t.agent){const{id:h,displayName:m,emoji:x,color:g,imageUrl:C}=t.agent;return{kind:"agent",id:h,displayName:m,emoji:x,color:g,imageUrl:C}}const o=(f=t.runtime)==null?void 0:f.trim();return o?{kind:"agent",id:`${Om}${o}`,displayName:us(o),runtime:o}:{kind:"agent",id:Am,displayName:Fm}}function Pm(e,t){var o;const{author:n}=e;if(!n)return{kind:"human",id:`${or}entry:${e.entryId}`,displayName:Mm};const s=`${or}${n.id}`;if(n.kind==="agent"){const a=n.agentId??n.id,i=((o=t.senderAgent)==null?void 0:o.call(t,{agentId:a,chatId:a}))??Tt({id:a,...n.emoji?{icon:n.emoji}:{},...n.color?{color:n.color}:{}});return{kind:"agent",id:s,displayName:n.displayName,...i}}return{kind:n.kind,id:s,displayName:n.displayName}}function ma(e){return`msg-${e}`}function Lm(){return{last:null}}function zm(e,t){const{resolveAuthor:n,now:s,cache:o}=t,a=t.lastSeenMessageId??null,i=t.unreadFromStart??!1,l=o==null?void 0:o.last,u=l&&l.resolveAuthor===n&&l.now===s&&l.lastSeenMessageId===a&&l.unreadFromStart===i?l:null;let d=0;if(u){const b=Math.min(e.length,u.messages.length);for(;d<b&&e[d]===u.messages[d];)d++}const f=u?u.authors.slice(0,d):[],h=u?u.items.slice(0,d):[];for(let b=f.length;b<e.length;b++){const v=e[b],k=n(v,b);f.push(k),h.push({id:v.id,authorId:k.id,timestamp:v.timestamp})}const m={now:s,lastSeenId:a,unreadFromStart:i},{rows:x,kept:g}=u?sl(h,m,u.timeline,d):{rows:rl(h,m),kept:0},C=u?u.rows.slice(0,g):[];for(let b=g;b<x.length;b++){const v=x[b];C.push(v.kind!=="item"?v:{kind:"message",key:ma(e[v.index].id),messageIndex:v.index,message:e[v.index],grouping:v.grouping,author:f[v.index]})}return o&&(o.last={messages:e,authors:f,items:h,resolveAuthor:n,now:s,lastSeenMessageId:a,unreadFromStart:i,timeline:x,rows:C}),C}function Bm(e){const t=[],n=new Set;for(const s of e){const o=s.lastIndexOf("/"),a=o>=0?s.slice(0,o+1):"",i=o>=0?s.slice(o+1):s;t.push({path:s,filename:i,directory:a,isDirectory:!1});const l=s.split("/");for(let u=1;u<l.length;u++){const d=l.slice(0,u).join("/")+"/";n.has(d)||(n.add(d),t.push({path:d,filename:l[u-1]+"/",directory:u>1?l.slice(0,u-1).join("/")+"/":"",isDirectory:!0}))}}return t}function qm(e,t){const n=[...e].reverse().find(s=>s.role==="user");if(n!=null&&n.content)return n.content;if((t==null?void 0:t.kind)==="first-message"&&t.kickoffMessage)return t.kickoffMessage}const pa=Symbol("no-error-part");function Um(e){for(let t=e.length-1;t>=0;t--){const n=e[t].parts;for(let s=n.length-1;s>=0;s--){const o=n[s];if(o.type==="error")return o.category}}return pa}function Hm(e){const{messages:t,status:n,lastErrorCategory:s,queuedCount:o,draft:a}=e;if(a.trim().length>0||n==="streaming"||o>0)return null;let i=-1;for(let d=t.length-1;d>=0;d--)if(t[d].role==="user"){i=d;break}const l=i===-1?"":t[i].content.trim();if(!l)return null;const u=Um(t.slice(i+1));return u!==pa?u==="auth_error"?l:null:n==="error"&&s==="auth_error"?l:null}const Wm="dorkos:signin-resume",Gm=1e4;function Vm(){const e=c.useRef(new Map),t=c.useRef(null);return c.useEffect(()=>{const n=ol(Wm);t.current=n;const s=e.current,o=n.onMessage(a=>{s.set(a.sessionId,Date.now())});return()=>{o(),n.close(),t.current=null}},[]),c.useMemo(()=>({claimedElsewhere:n=>{const s=e.current.get(n);return s!==void 0&&Date.now()-s<Gm},claim:n=>{var s;return(s=t.current)==null?void 0:s.postMessage({sessionId:n})}}),[])}function ha(e){switch(e){case"pending":case"running":return r.jsx(Le,{size:"xs",className:$t({status:e})});case"complete":return r.jsx(lt,{className:W("size-(--size-icon-xs)",$t({status:e}))});case"error":return r.jsx(Ue,{className:W("size-(--size-icon-xs)",$t({status:e}))});case"neutral":return r.jsx(al,{className:W("size-(--size-icon-xs)",$t({status:e}))})}}function ar({type:e,toolName:t,toolInput:n,...s}){const o=e==="approval"?"Waiting for approval":"Answering questions",a=t?dt(t,n??""):null,i=a?`${o} · ${a}`:`${o}…`;return r.jsx("div",{className:"bg-muted/50 rounded-msg-tool text-muted-foreground shadow-msg-tool border px-3 py-1 text-sm transition-colors duration-150",...s,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Le,{className:"shrink-0"}),r.jsx("span",{className:"truncate text-xs",children:i})]})})}function Mt({expanded:e,onToggle:t,header:n,children:s,variant:o="default",dimmed:a=!1,disabled:i=!1,hideChevron:l=!1,extraContent:u,ariaLabel:d,className:f,...h}){const m=l?void 0:e;return r.jsxs("div",{className:W("bg-muted/40 mt-px rounded-md border-l-2 text-sm transition-[opacity,background-color,border-color,box-shadow] duration-200 first:mt-1","hover:bg-muted/60 hover:border-l-muted-foreground/60 hover:shadow-soft",o==="default"&&"border-l-muted-foreground/30",o==="thinking"&&"border-l-muted-foreground/20",o==="memory"&&"border-l-muted-foreground/20",a&&!e&&"opacity-50 hover:opacity-100",f),...h,children:[r.jsxs("button",{onClick:()=>!i&&t(),disabled:i,className:W("focus-ring flex w-full items-center gap-2 rounded-md px-3 py-1",i&&"cursor-default"),"aria-expanded":m,"aria-label":d,children:[n,!l&&!i&&r.jsx(V.div,{animate:{rotate:e?180:0},transition:{type:"spring",stiffness:400,damping:30},className:"ml-auto",children:r.jsx(At,{className:"text-muted-foreground size-(--size-icon-xs)"})})]}),u,r.jsx(de,{initial:!1,children:e&&r.jsx(V.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:"overflow-hidden",children:r.jsx("div",{className:"border-border/50 border-t px-3 pt-1 pb-3",children:s})})})]})}const Km=[0,.2,.4];function ga({className:e}){return r.jsx("div",{className:W("flex gap-1",e),"data-testid":"typing-dots","aria-hidden":"true",children:Km.map(t=>r.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:`${t}s`}},t))})}function Qm({record:e}){const t=Ae(),{color:n,emoji:s}=Tt({id:e.agentId,icon:e.icon,color:e.color}),o=e.displayName.trim()||"Your agent";return r.jsxs("div",{className:"flex flex-col items-center gap-5 text-center","data-testid":"first-light",children:[r.jsx(V.div,{animate:t?void 0:{scale:[1,1.05,1],opacity:[.9,1,.9]},transition:t?void 0:{duration:3,repeat:1/0,ease:"easeInOut"},children:r.jsx(fo,{color:n,emoji:s,size:"lg"})}),r.jsxs("div",{className:"flex flex-col items-center gap-3",children:[r.jsxs("p",{className:"text-muted-foreground text-base","aria-live":"polite",children:[o," is waking up…"]}),r.jsx(ga,{})]})]})}function Ym({birthRecord:e,firstLightRecord:t}){return(e==null?void 0:e.greetingFailed)===!0?r.jsxs("div",{className:"text-center","data-testid":"greeting-failed-empty",children:[r.jsxs("p",{className:"text-muted-foreground text-base",children:[e.displayName," couldn’t say hello just now"]}),r.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Send a message to get started."})]}):t?r.jsx(Qm,{record:t}):r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-muted-foreground text-base",children:"Start a chat"}),r.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Type a message below to begin."})]})}function Xm(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function Jm({sessionId:e}){const t=en(e),n=Ae();if(!t||t.kind==="first-message")return null;const s=Xm(t.bornAt),o=Ft(t.runtime).label;return r.jsxs(V.div,{initial:n?!1:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.3},"data-testid":"birth-certificate",className:"text-muted-foreground flex items-center justify-center gap-1.5 px-4 pt-3 pb-1 text-xs",children:[r.jsx(il,{className:"text-primary size-3.5 shrink-0 fill-current","aria-hidden":"true"}),r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"text-foreground font-medium",children:t.displayName}),s&&r.jsxs(r.Fragment,{children:[r.jsx(_n,{}),r.jsxs("span",{children:["born ",s]})]}),r.jsx(_n,{}),r.jsxs("span",{className:"min-w-0 truncate",children:["lives in ",r.jsx("code",{className:"text-2xs",children:t.path})]}),r.jsx(_n,{}),r.jsxs("span",{className:"shrink-0",children:["runs on ",o]})]})]})}function _n(){return r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 shrink-0",children:"·"})}const Zm="another chat";function ep(e,t){const n=t==null?void 0:t.find(s=>s.id===e);return n?ll(n)?$s("autonomy"):n.label:mo(e)?$s("autonomy"):cl(e)}function tp({startedBy:e,modes:t}){var a;const n=ft();if(!e)return null;const s=((a=e.reason)==null?void 0:a.trim())||null,o=e.kind==="chat"?e.permission:null;return r.jsxs(r.Fragment,{children:[r.jsx(np,{startedBy:e,reason:s,navigate:n}),o&&r.jsxs("p",{"data-testid":"started-level-line",className:"text-muted-foreground mx-auto max-w-prose px-4 pb-1 text-center text-xs",children:["Started at ",ep(o.mode,t),","," ",o.sameAsStarter?"same as":"lower than"," the chat that started it."]})]})}function np({startedBy:e,reason:t,navigate:n}){return r.jsxs("p",{"data-testid":"started-by-line",className:"text-muted-foreground mx-auto max-w-prose px-4 pt-3 pb-1 text-center text-xs",children:[e.kind==="extension"?r.jsxs(r.Fragment,{children:["Started by the"," ",r.jsx("span",{className:"text-foreground font-medium",children:e.extensionName})," extension"]}):r.jsxs(r.Fragment,{children:["Started from"," ",r.jsx("button",{type:"button",onClick:()=>void n(Rt({session:e.sessionId})),className:"text-foreground focus-visible:ring-ring rounded-sm font-medium underline-offset-2 hover:underline focus-visible:ring-2 focus-visible:outline-none",children:e.title??Zm})]}),t&&r.jsxs(r.Fragment,{children:[": ",t]})]})}function sp({content:e}){const[t,n]=c.useState(!1);return r.jsxs("div",{"data-testid":"started-prompt",className:"px-4 py-1",children:[r.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring mx-auto flex items-center gap-1 rounded-sm text-xs focus-visible:ring-2 focus-visible:outline-none",children:["What it was asked",r.jsx(ds,{"aria-hidden":"true",className:W("size-3 transition-transform duration-200",t&&"rotate-90")})]}),t&&r.jsx("div",{className:"bg-muted/40 text-foreground mx-auto mt-2 max-w-prose rounded-md px-3 py-2 text-sm break-words whitespace-pre-wrap",children:e})]})}const rp={a:dl,img:Hu},xa=c.createContext({isStreaming:!1});function op(e){const t=c.useContext(xa);return r.jsx(Qu,{...e,...t})}const ap={renderers:[{language:Ku,component:op}]};function xs({content:e,isStreaming:t=!1,textEffect:n=zd,sessionId:s,isLatestWidgetMessage:o}){const a=qd(n),i=c.useMemo(()=>({sessionId:s,isLatestMessage:o,isStreaming:t}),[s,o,t]);return r.jsx(xa.Provider,{value:i,children:r.jsx("div",{className:W("relative",t&&"streaming-cursor"),children:r.jsx(Uu,{resetKey:e,fallback:r.jsx("div",{className:"text-sm break-words whitespace-pre-wrap",children:e}),children:r.jsx(ul,{shikiTheme:["github-light","github-dark"],components:rp,animated:a,isAnimating:t,plugins:ap,children:e})})})})}function Gn(e){if(e)try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}function he(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.length>0?n:void 0}function ip(e){const t=Gn(e);if(t){if(Array.isArray(t.content))for(const n of t.content){const s=typeof(n==null?void 0:n.text)=="string"?Gn(n.text):void 0;if(s)return s}return t}}function ba(e){const t=fl(e.toolName);if(t!=="chat_send"&&t!=="session_start"&&t!=="chat_stop")return null;const n=Gn(e.input),s=ip(e.result),o=lp(e,s),a=o===void 0&&(s==null?void 0:s.status)==="approval_required",i=he(n,"delivery");return{tool:t,...he(n,t==="chat_stop"?"chat":"to")!==void 0?{to:he(n,t==="chat_stop"?"chat":"to")}:{},...he(n,t==="session_start"?"prompt":"message")!==void 0?{message:he(n,t==="session_start"?"prompt":"message")}:{},...he(n,"summary")!==void 0?{summary:he(n,"summary")}:{},...i==="queue"||i==="steer"||i==="interrupt"?{delivery:i}:{},...he(n,"reason")!==void 0?{reason:he(n,"reason")}:{},...he(s,"messageId")!==void 0?{messageId:he(s,"messageId")}:{},...(he(s,"chatId")??he(s,"sessionId"))!==void 0?{chatId:he(s,"chatId")??he(s,"sessionId")}:{},...o!==void 0?{error:o}:{},...a?{waiting:a}:{},...t==="chat_stop"&&o===void 0&&(s==null?void 0:s.stopped)===!1?{notRunning:!0}:{},...he(s,"note")!==void 0?{note:he(s,"note")}:{}}}const zt="It could not be sent.";function lp(e,t){var n;if((t==null?void 0:t.status)==="denied")return he(t,"message")??zt;if((t==null?void 0:t.ok)===!1||typeof(t==null?void 0:t.error)=="string")return he(t,"error")??he(t,"message")??zt;if(e.status==="error")return t?he(t,"error")??he(t,"message")??zt:((n=e.result)==null?void 0:n.trim())||zt}function cp(e,t=60){const n=e.trim().split(new RegExp("(?<=[.!?])\\s"))[0]??"";if(n.length<=t)return n;const s=n.slice(0,t),o=s.lastIndexOf(" ");return`${(o>t/2?s.slice(0,o):s).replace(/[\s,;:.]+$/,"")}…`}function up(e,t){if(e){for(let n=t.length-1;n>=0;n--)if(t[n].to.chatId===e)return t[n].to}}function dp(e,t){if(e.messageId)return t.find(n=>n.id===e.messageId);if(e.tool==="session_start"&&e.chatId)return t.find(n=>n.kind==="start"&&n.to.chatId===e.chatId)}function fp(e,t){if(e&&e.trim())return e.trim();const s=((t??"").split(`
35
- `).find(o=>o.trim()!=="")??"").replace(/^#+\s*/,"").trim();return s.length>72?`${s.slice(0,71)}…`:s}function mp(e,t){if(t.error)return{label:"Failed",tone:"error"};if(t.waiting)return{label:"Waiting for approval",tone:"muted"};if(!e)return{label:t.pending?"Sending":"Sent",tone:"muted"};switch(e.status){case"queued":return{label:e.position?`Queued · #${e.position}`:"Queued",tone:"muted"};case"steered":return{label:"Steered in",tone:"done"};case"working":return{label:e.delivery==="interrupt"?"Interrupted, working":"Working",tone:"active"};case"delivered":return{label:e.delivery==="interrupt"?"Interrupted, then delivered":"Delivered",tone:"done"};case"replied":return{label:"Replied",tone:"done"};case"failed":return{label:"Failed",tone:"error"};default:return{label:"Sent",tone:"muted"}}}function pp(e){const t=[];return e.kind==="report"&&t.push("Report"),e.kind==="start"&&t.push("Started this chat"),e.delivery==="steer"&&t.push("Steered in"),e.delivery==="interrupt"&&t.push("Interrupted"),t}function ya(e,t){var n,s;for(const o of e){if((n=o.chatMessages)!=null&&n.some(i=>i.id===t))return o.id;const a=[...o.toolCalls??[],...(o.parts??[]).filter(i=>i.type==="tool_call")];for(const i of a)if(((s=ba(i))==null?void 0:s.messageId)===t)return o.id}}const ir=new WeakMap;function hp(e,t){if(t.length===0)return e;const n=[];let s=0;const o=a=>{let i=ir.get(a);return i||(i={id:`chat-stop-${a.id}`,role:"user",content:"",parts:[],timestamp:a.at,_chatStop:a},ir.set(a,i)),i};for(const a of e){const i=a.timestamp==="",l=i?Number.NaN:Date.parse(a.timestamp),u=d=>i||!Number.isNaN(l)&&Date.parse(d.at)<l;for(;s<t.length&&u(t[s]);)n.push(o(t[s])),s+=1;n.push(a)}for(;s<t.length;)n.push(o(t[s])),s+=1;return n}function gp({stamp:e}){const t=pp(e);return t.length===0?null:r.jsx(r.Fragment,{children:t.map(n=>r.jsx("span",{"data-testid":"chat-message-tag",className:"bg-muted text-muted-foreground text-2xs rounded px-1.5 py-px leading-4 font-medium",children:n},n))})}function va({stamp:e}){const t=ft(),n=e.from.chatTitle??"another chat";return r.jsxs("span",{"data-testid":"chat-from-mark",className:"inline-flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[r.jsxs("span",{className:"text-muted-foreground inline-flex min-w-0 items-center gap-1",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"from"}),r.jsx("button",{type:"button",onClick:()=>void t(Rt({session:e.from.chatId,message:e.id})),className:"focus-ring text-foreground/80 hover:text-foreground max-w-48 truncate underline-offset-4 hover:underline",children:n})]}),r.jsx(gp,{stamp:e})]})}function xp({sessionId:e,messageId:t}){const n=ft();return r.jsxs("button",{type:"button","data-testid":"chat-reply-to",onClick:()=>void n(Rt({session:e,message:t})),className:"focus-ring text-muted-foreground hover:text-foreground focus-visible:text-foreground mb-1 inline-flex items-center gap-1 text-xs underline-offset-4 hover:underline",children:[r.jsx(wd,{"aria-hidden":!0,className:"size-3"}),"Reply to your message"]})}function bp({stamps:e,sessionId:t}){return r.jsx("div",{className:"space-y-2","data-testid":"received-chat-messages",children:e.map((n,s)=>r.jsxs("div",{"data-testid":"received-chat-message","data-kind":n.kind,className:"border-status-info-border bg-status-info-bg rounded-r-md border-l-2 py-1.5 pr-2 pl-3",children:[n.replyToId&&t&&r.jsx(xp,{sessionId:t,messageId:n.replyToId}),s>0&&r.jsxs("div",{className:"text-muted-foreground mb-1 flex flex-wrap items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"text-foreground/80 font-medium",children:n.from.agentName}),r.jsx(va,{stamp:n})]}),r.jsx("div",{className:"msg-prose",children:r.jsx(xs,{content:n.text,isStreaming:!1,...t?{sessionId:t}:{}})})]},n.id))})}function yp({stamp:e}){const t=ft(),n=e.roomLabel??"a room";return r.jsxs("span",{"data-testid":"room-post-mark",className:"text-muted-foreground inline-flex min-w-0 items-center gap-1 text-xs",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"in"}),r.jsx("button",{type:"button","aria-label":`Open ${n}`,onClick:()=>void t({...ml.channels(),search:{id:e.roomId}}),className:"focus-ring text-foreground/80 hover:text-foreground max-w-48 truncate underline-offset-4 hover:underline",children:n})]})}const vp={muted:"text-muted-foreground",active:"text-foreground",done:"text-muted-foreground",error:"text-destructive"};function kp(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Cp(e,t,n){if(e.error)return e.error;if(e.waiting)return"Waiting for a person to approve it.";if(e.tool==="chat_stop")return e.note??(e.notRunning?"Nothing was running there.":"Asked it to stop.");if(!t)return e.note??"Sent.";const s=kp(n);switch(t.status){case"queued":return t.position?`Waiting for ${n} to finish its turn. Number ${t.position} in line.`:`Waiting for ${n} to finish its turn.`;case"steered":return`Joined ${n}’s running turn.`;case"working":return t.delivery==="interrupt"?`Stopped ${n}’s turn. ${s} is on this now.`:`${s} is working on it.`;case"delivered":return`${s} read it and finished its turn.`;case"replied":return`${s} replied.`;case"failed":return t.failureReason??"It was not delivered.";default:return"Sent."}}function Sp(e,t){return e.error?{label:"Failed",tone:"error"}:e.waiting?{label:"Waiting for approval",tone:"muted"}:t?{label:"Stopping",tone:"muted"}:e.notRunning?{label:"Not running",tone:"muted"}:{label:"Stopped",tone:"done"}}function jp({part:e,sent:t,at:n,sessionId:s}){const[o,a]=c.useState(!1),i=c.useId(),l=ft(),u=ba(e);if(!u)return null;const d=e.status==="pending"||e.status==="running",f=dp(u,t),h=(f==null?void 0:f.to.chatId)??u.chatId??(u.tool==="chat_stop"?u.to:void 0),m=(f==null?void 0:f.to)??up(h,t),x=(m==null?void 0:m.agentName)??"the agent",g=m==null?void 0:m.chatTitle,C=Tt({id:(m==null?void 0:m.agentId)??u.to??h??"chat"}),b=u.tool==="chat_stop"?Sp(u,d):mp(f,{...u,pending:d}),v=fp((f==null?void 0:f.summary)??u.summary,(f==null?void 0:f.text)??u.message),k=n?Bn(n):f?Bn(f.sentAt):"",y=u.error??((f==null?void 0:f.status)==="failed"?f.failureReason:void 0),p=y?cp(y):u.tool==="chat_stop"?u.reason:v!==g?v:"",j=u.tool==="session_start"?Dd:u.tool==="chat_stop"?po:pl,_=u.tool==="session_start"?"Started spin-off chat":u.tool==="chat_stop"?u.error||u.notRunning?"Tried to stop":"Stopped":"To",D=u.tool==="session_start"?g??(v||"a new chat"):u.tool==="chat_stop"?g??"a chat":(m==null?void 0:m.agentName)??g??"a chat",A=()=>{h&&l(Rt({session:h,...f?{message:f.id}:{}}))};return r.jsxs("div",{"data-testid":"sent-chat-card","data-tool":u.tool,"data-state":b.label,className:"border-border/70 bg-background my-1.5 rounded-lg border text-sm",children:[r.jsxs("button",{type:"button",onClick:()=>a(N=>!N),"aria-expanded":o,...o?{"aria-controls":i}:{},className:"focus-ring hover:bg-muted/40 flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors duration-150",children:[r.jsx(fo,{size:"xs",emoji:C.emoji,color:C.color}),r.jsx(j,{"aria-hidden":!0,className:"text-muted-foreground hidden size-3.5 shrink-0 sm:block"}),r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.jsxs("span",{className:"text-muted-foreground",children:[_," "]}),r.jsx("span",{className:"font-medium",children:D}),u.tool==="chat_send"&&g&&(m==null?void 0:m.agentName)&&r.jsxs("span",{className:"text-muted-foreground",children:[" · ",g]}),p&&(u.tool!=="session_start"||y)&&r.jsxs("span",{"data-testid":"sent-chat-aside",className:W("text-muted-foreground",!y&&"hidden sm:inline"),children:[" ","· ",p]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("span",{className:W("text-xs",vp[b.tone]),"data-testid":"sent-chat-state",children:b.label}),k&&r.jsx("time",{className:"text-muted-foreground hidden text-xs tabular-nums sm:inline",children:k}),r.jsx(At,{"aria-hidden":!0,className:W("text-muted-foreground size-3.5 transition-transform duration-200",o&&"rotate-180")})]})]}),o&&r.jsxs("div",{id:i,className:"border-border/60 space-y-2 border-t px-3 py-2",children:[((f==null?void 0:f.text)??u.message??u.reason)&&r.jsx("div",{className:"msg-prose",children:r.jsx(xs,{content:(f==null?void 0:f.text)??u.message??u.reason??"",isStreaming:!1,...s?{sessionId:s}:{}})}),r.jsxs("p",{className:"text-muted-foreground text-xs",children:[Cp(u,f,x),u.note&&u.tool!=="chat_stop"&&f?` ${u.note}`:""]}),h&&!u.error&&!u.waiting&&r.jsx("button",{type:"button",onClick:A,className:"focus-ring text-foreground text-xs font-medium underline-offset-4 hover:underline",children:"Open chat →"})]})]})}function _p({notice:e}){const t=ft();return r.jsxs("div",{"data-testid":"chat-stop-line",className:"text-muted-foreground flex flex-wrap items-center gap-1.5 text-xs",children:[r.jsx(po,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),r.jsxs("span",{children:["Stopped by ",r.jsx("span",{className:"text-foreground/80 font-medium",children:e.by.agentName})," · ",r.jsx("button",{type:"button",onClick:()=>void t(Rt({session:e.by.chatId})),className:"focus-ring hover:text-foreground underline-offset-4 hover:underline",children:e.by.chatTitle??"another chat"}),e.reason?`: ${e.reason}`:""]})]})}const wp={sent:[],stops:[]},Np=new bl;function ka(e){const t=hl(),n=c.useContext(gl),s=xl(e??""),{data:o}=Je({queryKey:["chat-activity",e,s],queryFn:()=>t.getChatActivity(e),enabled:!!e&&t!==null&&n!==void 0,placeholderData:(a,i)=>(i==null?void 0:i.queryKey[1])===e?a:void 0,staleTime:3e4},n??Np);return o??wp}function bs(e){const t=[],n=[];for(const s of e)s.type==="text"?t.push(s.text):s.type==="tool_call"&&n.push({toolCallId:s.toolCallId,toolName:s.toolName,input:s.input||"",result:s.result,progressOutput:s.progressOutput,status:s.status,interactiveType:s.interactiveType,questions:s.questions,answers:s.answers,timeoutMs:s.timeoutMs,hooks:s.hooks,startedAt:s.startedAt,completedAt:s.completedAt,approvalStartedAt:s.approvalStartedAt,approvalRemainingMs:s.approvalRemainingMs,approvalParked:s.approvalParked,approvalTitle:s.approvalTitle,approvalDisplayName:s.approvalDisplayName,approvalDescription:s.approvalDescription,approvalBlockedPath:s.approvalBlockedPath,approvalDecisionReason:s.approvalDecisionReason,approvalHasSuggestions:s.approvalHasSuggestions,approvalAlwaysAllowScope:s.approvalAlwaysAllowScope});return{content:t.join(`
36
- `),toolCalls:n}}const lr=new WeakMap;function Ep(e){let t=lr.get(e);return t||(t=e.map(at),lr.set(e,t)),t}function at(e){const t=e.parts?[...e.parts]:[];if(t.length===0&&(e.content&&t.push({type:"text",text:e.content}),e.toolCalls))for(const s of e.toolCalls)t.push({type:"tool_call",toolCallId:s.toolCallId,toolName:s.toolName,input:s.input,result:s.result,status:s.status,...s.questions||s.questionOutcome?{interactiveType:"question",questions:s.questions,answers:s.answers,questionOutcome:s.questionOutcome}:{},...s.approvalOutcome?{interactiveType:"approval",approvalOutcome:s.approvalOutcome,approvalResolvedAt:s.approvalResolvedAt,approvalStartedAt:s.approvalStartedAt,approvalReasonGiven:s.approvalReasonGiven}:{}});const n=bs(t);return{id:e.id,role:e.role,content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:void 0,parts:t,timestamp:e.timestamp||"",messageType:e.messageType,compactMetadata:e.compactMetadata,commandName:e.commandName,commandArgs:e.commandArgs,...e.chatMessages&&e.chatMessages.length>0?{chatMessages:e.chatMessages}:{},...e.roomMessage?{roomMessage:e.roomMessage}:{}}}function Dp(e,t,n){const s=new Set(e.map(d=>d.id)),o=e.filter(d=>d._streaming),a=o.find(d=>d.role==="user"),i=o.find(d=>d.role==="assistant"),l=[];let u=-1;for(let d=0;d<t.length;d++){const f=t[d];if(!s.has(f.id)){if(a&&f.role==="user"&&f.content===a.content){u=d,n(h=>h.map(m=>m.id===a.id?{...at(f),_streaming:!1}:m));continue}if(i&&u>=0&&d===u+1&&f.role==="assistant"){const h=at(f),m=new Set(h.parts.filter(C=>C.type==="background_task").map(C=>C.taskId)),x=i.parts.filter(C=>C.type==="background_task"&&!m.has(C.taskId)),g=x.length>0?[...h.parts,...x]:h.parts;n(C=>C.map(b=>b.id===i.id?{...h,parts:g,_streaming:!1}:b));continue}l.push(f)}}l.length>0&&n(d=>[...d,...l.map(at)])}const Tp=20;function Ap(e,t){var v;const n=Se(),s=yl(e),o=Pe(k=>k.seeks[e]),[a,i]=c.useState(null),l=c.useRef(null),u=a===e,d=c.useRef({key:"",count:0}),f=s.windowStartId!==null&&((v=t[0])==null?void 0:v.id)===s.windowStartId,h=c.useMemo(()=>f?s.earlier.map(at):[],[f,s.earlier]),m=c.useMemo(()=>h.length>0?[...h,...t]:t,[h,t]),x=f&&s.remaining>0,g=f?s.remaining:0,C=c.useCallback(()=>{var p;if(l.current===e||!x)return;const{generation:k}=s,y=((p=s.earlier[0])==null?void 0:p.id)??s.windowStartId;y&&(l.current=e,i(e),n.getMessages(e,void 0,{before:y}).then(j=>{Pe.getState().prependPage(e,k,j.messages,j.earlierMessages??0)}).catch(j=>{console.warn("[chat] could not read earlier messages",j),Pe.getState().endSeek(e)}).finally(()=>{l.current===e&&(l.current=null,i(null))}))},[x,e,n,s]),b=o!==void 0&&(m.some(k=>k.id===o)||ya([...s.earlier,...we.getState().getSession(e).messages],o)!==void 0);return c.useEffect(()=>{if(o===void 0){d.current={key:"",count:0};return}const k=`${e}:${o}`;if(d.current.key!==k&&(d.current={key:k,count:0}),!(s.generation===0||u)){if(b||!x||d.current.count>=Tp){Pe.getState().endSeek(e);return}d.current.count+=1,C()}},[o,b,x,u,C,e,s.generation]),{messages:m,earlierCount:h.length,messagesBefore:g,canLoadEarlier:x,isLoadingEarlier:u,isSeeking:o!==void 0,loadEarlier:C}}function Fp({celebration:e,onComplete:t}){const n=c.useRef(null),s=(e==null?void 0:e.level)==="major",o=c.useCallback(()=>{t()},[t]);return c.useEffect(()=>{if(!s)return;let a=!1;vl({kind:"burst"}).then(l=>{if(a){l();return}n.current=l});const i=setTimeout(()=>{o()},tn.CELEBRATION_DISPLAY_MS);return()=>{var l;a=!0,(l=n.current)==null||l.call(n),n.current=null,clearTimeout(i)}},[s,o]),r.jsx(de,{children:s&&r.jsx(V.div,{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-50",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.1},transition:{duration:.6,ease:"easeOut"},style:Ld})})}const ys=c.createContext(null);function Rp({children:e,value:t}){const n=c.useMemo(()=>t,[t.sessionId,t.isStreaming,t.isLatestWidgetMessage,t.isFinalMessage,t.activeToolCallId,t.onToolRef,t.focusedOptionIndex,t.onToolDecided,t.onRetry,t.onSigninComplete,t.onChooseModel,t.inputZoneToolCallId,t.textEffect,t.runtimeLabel,t.allowsDenyReason]);return r.jsx(ys,{value:n,children:e})}function Mp(){const e=c.useContext(ys);if(!e)throw new Error("useMessageContext must be used within MessageProvider");return e}function Op(){return c.useContext(ys)}function Ip(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function $p({text:e,isStreaming:t,elapsedMs:n}){const[s,o]=c.useState(t),a=c.useRef(t),i=c.useRef(null);c.useEffect(()=>{a.current&&!t&&o(!1),a.current=t},[t]),c.useEffect(()=>{t&&s&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t,s]);const l=n?`Thought for ${Ip(n)}`:"Thinking…";return r.jsx(Mt,{expanded:s,onToggle:()=>o(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:l,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(_d,{className:W("text-muted-foreground size-(--size-icon-xs)",t&&"animate-breath")}),r.jsx("span",{className:W("text-3xs text-muted-foreground font-mono",t&&"animate-breath"),children:l})]}),children:r.jsx("div",{ref:i,className:"max-h-32 overflow-y-auto",children:r.jsx("pre",{className:"text-muted-foreground text-xs break-words whitespace-pre-wrap",children:e})})})}function Pp({mode:e,memories:t,isStreaming:n}){const[s,o]=c.useState(n),a=c.useRef(n);if(c.useEffect(()=>{a.current&&!n&&o(!1),a.current=n},[n]),t.length===0)return null;const i=t.length,l=n?i<=1?"Consulting memory…":`Consulting ${i} memories…`:i===1?"Recalled 1 memory":`Recalled ${i} memories`,u=e==="synthesize"?kl:Cl,d=e==="synthesize"?"sparkles":"bookopen";return r.jsx(Mt,{expanded:s,onToggle:()=>o(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:l,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(u,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":d,className:W("text-muted-foreground size-(--size-icon-xs)",n&&"animate-breath")}),r.jsx("span",{className:W("text-3xs text-muted-foreground font-mono",n&&"animate-breath"),children:l})]}),children:r.jsx(Lp,{memories:t})})}function Lp({memories:e}){return r.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>r.jsx(zp,{memory:t},t.path))})}function zp({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?Sl:jl,s=e.scope==="team"?"team":"personal",{copy:o}=_l({toastOnSettle:!0}),a=()=>{const i=t&&e.content?e.content:e.path;o(i)};if(t&&e.content){const i=e.path.replace(/^<synthesis:/,"synthesis:").replace(/>$/,"");return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:a,"aria-label":`Copy synthesized ${s} memory content`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full flex-col items-start gap-1 rounded-md px-2 py-1 text-left transition-colors duration-150",children:[r.jsx("span",{className:"text-sm",children:e.content}),r.jsxs("span",{className:"text-3xs text-muted-foreground flex items-center gap-1 font-mono",children:[r.jsx(n,{"aria-hidden":"true",className:"size-(--size-icon-xs)"}),i]})]})})}return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:a,"aria-label":`Copy ${s} memory path ${e.path}`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full items-center gap-2 rounded-md px-2 py-1 text-left transition-colors duration-150",children:[r.jsx("span",{className:"flex-1 truncate font-mono text-sm",children:Ud(e.path,40)}),r.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Qt(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ca(e){return e===void 0?"Summarized (asked by the agent)":`Summarized at ${e}% (asked by the agent)`}function Bp(e){if((e==null?void 0:e.requestedBy)==="agent")return Ca(e.contextPercent);const t=["Context compacted"];return(e==null?void 0:e.preTokens)!==void 0&&t.push(`${Qt(e.preTokens)} tokens`),e!=null&&e.trigger&&t.push(e.trigger),t.join(" · ")}function qp(e,t){return e===void 0?"Compacted context":t===void 0?`Compacted context · ${Qt(e)} tokens summarized`:`Compacted context · ${Qt(e)} → ${Qt(t)} tokens`}function Up({trigger:e,preTokens:t,postTokens:n,failed:s,error:o,requestedBy:a,contextPercent:i}){return s?r.jsx(Qe,{"data-testid":"compact-boundary-row","data-failed":"true",icon:r.jsx(fs,{"aria-hidden":"true",className:"text-status-warning-dot size-3 shrink-0"}),label:r.jsx("span",{className:"text-status-warning-fg",children:a==="agent"?"Couldn’t compact (asked by the agent)":"Couldn’t compact"}),children:o?r.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:o}):null}):a==="agent"?r.jsx(Qe,{"data-testid":"compact-boundary-row","data-requested-by":"agent",icon:r.jsx(Ps,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:Ca(i)})}):r.jsx(Qe,{"data-testid":"compact-boundary-row",icon:r.jsx(Ps,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:qp(t,n)}),trailing:e?r.jsx("span",{"data-testid":"compact-boundary-trigger",className:"text-3xs text-muted-foreground/70 ml-auto font-mono uppercase",children:e}):void 0})}function Hp({part:e}){const[t,n]=c.useState(!1);return t?r.jsxs("div",{"data-testid":"message-image-missing",className:W("my-3 flex items-center gap-2 rounded-md border px-3 py-2","text-muted-foreground border-border/60 bg-muted/30 text-sm"),children:[r.jsx(rd,{"aria-hidden":"true",className:"size-4 shrink-0"}),r.jsx("span",{children:e.alt?`${e.alt}, not available`:"This image is not available."})]}):r.jsx("figure",{className:"my-3","data-testid":"message-image",children:r.jsx(ho,{image:{src:e.url,alt:e.alt??"Image produced by the agent"},className:"block",children:r.jsx("img",{src:e.url,alt:e.alt??"Image produced by the agent",loading:"lazy",decoding:"async",onError:()=>n(!0),className:"border-border/60 bg-muted/20 max-h-[32rem] max-w-full rounded-md border object-contain"})})})}function Wp({content:e}){return r.jsx(Qe,{"data-testid":"staged-context-note",icon:r.jsx(go,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:"Added context for the next reply"}),children:r.jsx("p",{className:"text-muted-foreground/80 mt-1 text-xs whitespace-pre-wrap",children:e})})}function Gp(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Vp(e){return e==="untracked"?"neutral":e==="stopped"?"complete":e}function Kp(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Gp(e.durationMs)),t.length>0?t.join(" · "):null}function Qp({part:e}){const[t,n]=c.useState(!1),s=c.useRef(null),o=Kp(e),a=e.subagentText,i=e.status==="untracked",l=!!(o||e.summary||e.lastToolName||a||i);return c.useEffect(()=>{const u=s.current;u&&(u.scrollTop=u.scrollHeight)},[a]),r.jsx(Mt,{expanded:t,onToggle:()=>l&&n(!t),hideChevron:!l,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[ha(Vp(e.status)),r.jsx("span",{className:"text-3xs truncate font-mono",children:e.description}),o&&r.jsx("span",{className:"text-3xs text-muted-foreground ml-1 shrink-0",children:o})]}),children:r.jsxs("div",{className:"space-y-1.5",children:[a&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-3xs text-muted-foreground/70 tracking-wide uppercase",children:"Helper output"}),r.jsx("pre",{ref:s,className:"text-foreground/90 bg-muted/50 max-h-64 overflow-y-auto rounded-md p-2 text-xs break-words whitespace-pre-wrap","data-testid":"subagent-text",children:a})]}),e.lastToolName&&e.status==="running"&&r.jsxs("p",{className:"text-3xs text-muted-foreground",children:["Last tool: ",r.jsx("span",{className:"font-mono",children:e.lastToolName})]}),e.summary&&r.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:e.summary}),i&&r.jsx("p",{className:"text-3xs text-muted-foreground","data-testid":"subagent-untracked",children:"No longer tracked. It may still be running."})]})})}const Yp=e=>typeof e=="boolean"||e instanceof Boolean,Xp=e=>typeof e=="number"||e instanceof Number,Jp=e=>typeof e=="bigint"||e instanceof BigInt,Sa=e=>!!e&&e instanceof Date,Zp=e=>typeof e=="string"||e instanceof String,eh=e=>Array.isArray(e),ja=e=>typeof e=="object"&&e!==null,_a=e=>!!e&&e instanceof Object&&typeof e=="function";function Jt(e,t){return t===void 0&&(t=!1),!e||t?`"${e}"`:e}function th(e,t,n){return n?JSON.stringify(e):t?`"${e}"`:e}function wa(e){let{field:t,value:n,data:s,lastElement:o,openBracket:a,closeBracket:i,level:l,style:u,shouldExpandNode:d,clickToExpandNode:f,outerRef:h,beforeExpandChange:m}=e;const x=c.useRef(!1),[g,C]=c.useState(()=>d(l,n,t)),b=c.useRef(null);c.useEffect(()=>{x.current?C(d(l,n,t)):x.current=!0},[d]);const v=c.useId();if(s.length===0)return nh({field:t,openBracket:a,closeBracket:i,lastElement:o,style:u});const k=g?u.collapseIcon:u.expandIcon,y=g?u.ariaLables.collapseJson:u.ariaLables.expandJson,p=l+1,j=s.length-1,_=N=>{g!==N&&(!m||m({level:l,value:n,field:t,newExpandValue:N}))&&C(N)},D=N=>{if(N.key==="ArrowRight"||N.key==="ArrowLeft")N.preventDefault(),_(N.key==="ArrowRight");else if(N.key==="ArrowUp"||N.key==="ArrowDown"){N.preventDefault();const T=N.key==="ArrowUp"?-1:1;if(!h.current)return;const S=h.current.querySelectorAll("[role=button]");let E=-1;for(let M=0;M<S.length;M++)if(S[M].tabIndex===0){E=M;break}if(E<0)return;const w=(E+T+S.length)%S.length;S[E].tabIndex=-1,S[w].tabIndex=0,S[w].focus()}},A=()=>{var N;_(!g);const T=b.current;if(!T)return;const S=(N=h.current)===null||N===void 0?void 0:N.querySelector('[role=button][tabindex="0"]');S&&(S.tabIndex=-1),T.tabIndex=0,T.focus()};return c.createElement("div",{className:u.basicChildStyle,role:"treeitem","aria-expanded":g,"aria-selected":void 0},c.createElement("span",{className:k,onClick:A,onKeyDown:D,role:"button","aria-label":y,"aria-expanded":g,"aria-controls":g?v:void 0,ref:b,tabIndex:l===0?0:-1}),(t||t==="")&&(f?c.createElement("span",{className:u.clickableLabel,onClick:A,onKeyDown:D},Jt(t,u.quotesForFieldNames),":"):c.createElement("span",{className:u.label},Jt(t,u.quotesForFieldNames),":")),c.createElement("span",{className:u.punctuation},a),g?c.createElement("ul",{id:v,role:"group",className:u.childFieldsContainer},s.map((N,T)=>c.createElement(Vn,{key:N[0]||T,field:N[0],value:N[1],style:u,lastElement:T===j,level:p,shouldExpandNode:d,clickToExpandNode:f,beforeExpandChange:m,outerRef:h}))):c.createElement("span",{className:u.collapsedContent,onClick:A,onKeyDown:D}),c.createElement("span",{className:u.punctuation},i),!o&&c.createElement("span",{className:u.punctuation},","))}function nh(e){let{field:t,openBracket:n,closeBracket:s,lastElement:o,style:a}=e;return c.createElement("div",{className:a.basicChildStyle,role:"treeitem","aria-selected":void 0},(t||t==="")&&c.createElement("span",{className:a.label},Jt(t,a.quotesForFieldNames),":"),c.createElement("span",{className:a.punctuation},n),c.createElement("span",{className:a.punctuation},s),!o&&c.createElement("span",{className:a.punctuation},","))}function sh(e){let{field:t,value:n,style:s,lastElement:o,shouldExpandNode:a,clickToExpandNode:i,level:l,outerRef:u,beforeExpandChange:d}=e;return wa({field:t,value:n,lastElement:o||!1,level:l,openBracket:"{",closeBracket:"}",style:s,shouldExpandNode:a,clickToExpandNode:i,data:Object.keys(n).map(f=>[f,n[f]]),outerRef:u,beforeExpandChange:d})}function rh(e){let{field:t,value:n,style:s,lastElement:o,level:a,shouldExpandNode:i,clickToExpandNode:l,outerRef:u,beforeExpandChange:d}=e;return wa({field:t,value:n,lastElement:o||!1,level:a,openBracket:"[",closeBracket:"]",style:s,shouldExpandNode:i,clickToExpandNode:l,data:n.map(f=>[void 0,f]),outerRef:u,beforeExpandChange:d})}function oh(e){let{field:t,value:n,style:s,lastElement:o}=e,a,i=s.otherValue;return n===null?(a="null",i=s.nullValue):n===void 0?(a="undefined",i=s.undefinedValue):Zp(n)?(a=th(n,!s.noQuotesForStringValues,s.stringifyStringValues),i=s.stringValue):Yp(n)?(a=n?"true":"false",i=s.booleanValue):Xp(n)?(a=n.toString(),i=s.numberValue):Jp(n)?(a=`${n.toString()}n`,i=s.numberValue):Sa(n)?a=n.toISOString():_a(n)?a="function() { }":a=n.toString(),c.createElement("div",{className:s.basicChildStyle,role:"treeitem","aria-selected":void 0},(t||t==="")&&c.createElement("span",{className:s.label},Jt(t,s.quotesForFieldNames),":"),c.createElement("span",{className:i},a),!o&&c.createElement("span",{className:s.punctuation},","))}function Vn(e){const t=e.value;return eh(t)?c.createElement(rh,Object.assign({},e)):ja(t)&&!Sa(t)&&!_a(t)?c.createElement(sh,Object.assign({},e)):c.createElement(oh,Object.assign({},e))}var te={"container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","child-fields-container":"_1BXBN","label-light":"_1MGIk","clickable-label-light":"_2YKJg _1MGIk _1MFti","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","clickable-label-dark":"_1RQEj _2bSDX _1MFti","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const Na={collapseJson:"collapse JSON",expandJson:"expand JSON"},wn={container:te["container-light"],basicChildStyle:te["basic-element-style"],childFieldsContainer:te["child-fields-container"],label:te["label-light"],clickableLabel:te["clickable-label-light"],nullValue:te["value-null-light"],undefinedValue:te["value-undefined-light"],stringValue:te["value-string-light"],booleanValue:te["value-boolean-light"],numberValue:te["value-number-light"],otherValue:te["value-other-light"],punctuation:te["punctuation-light"],collapseIcon:te["collapse-icon-light"],expandIcon:te["expand-icon-light"],collapsedContent:te["collapsed-content-light"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:Na,stringifyStringValues:!1},ah={container:te["container-dark"],basicChildStyle:te["basic-element-style"],childFieldsContainer:te["child-fields-container"],label:te["label-dark"],clickableLabel:te["clickable-label-dark"],nullValue:te["value-null-dark"],undefinedValue:te["value-undefined-dark"],stringValue:te["value-string-dark"],booleanValue:te["value-boolean-dark"],numberValue:te["value-number-dark"],otherValue:te["value-other-dark"],punctuation:te["punctuation-dark"],collapseIcon:te["collapse-icon-dark"],expandIcon:te["expand-icon-dark"],collapsedContent:te["collapsed-content-dark"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:Na,stringifyStringValues:!1},ih=()=>!0,lh=e=>e<1,ch=e=>{let{data:t,style:n=wn,shouldExpandNode:s=ih,clickToExpandNode:o=!1,beforeExpandChange:a,compactTopLevel:i,...l}=e;const u=c.useRef(null);return c.createElement("div",Object.assign({"aria-label":"JSON view"},l,{className:n.container,ref:u,role:"tree"}),i&&ja(t)?Object.entries(t).map(d=>{let[f,h]=d;return c.createElement(Vn,{key:f,field:f,value:h,style:{...wn,...n},lastElement:!0,level:1,shouldExpandNode:s,clickToExpandNode:o,beforeExpandChange:a,outerRef:u})}):c.createElement(Vn,{value:t,style:{...wn,...n},lastElement:!0,level:0,shouldExpandNode:s,clickToExpandNode:o,outerRef:u,beforeExpandChange:a}))};var De={},Nn,cr;function uh(){if(cr)return Nn;cr=1;const e=[[{color:"0, 0, 0",class:"ansi-black"},{color:"187, 0, 0",class:"ansi-red"},{color:"0, 187, 0",class:"ansi-green"},{color:"187, 187, 0",class:"ansi-yellow"},{color:"0, 0, 187",class:"ansi-blue"},{color:"187, 0, 187",class:"ansi-magenta"},{color:"0, 187, 187",class:"ansi-cyan"},{color:"255,255,255",class:"ansi-white"}],[{color:"85, 85, 85",class:"ansi-bright-black"},{color:"255, 85, 85",class:"ansi-bright-red"},{color:"0, 255, 0",class:"ansi-bright-green"},{color:"255, 255, 85",class:"ansi-bright-yellow"},{color:"85, 85, 255",class:"ansi-bright-blue"},{color:"255, 85, 255",class:"ansi-bright-magenta"},{color:"85, 255, 255",class:"ansi-bright-cyan"},{color:"255, 255, 255",class:"ansi-bright-white"}]],t=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;class n{static escapeForHtml(o){return new n().escapeForHtml(o)}static linkify(o){return new n().linkify(o)}static ansiToHtml(o,a){return new n().ansiToHtml(o,a)}static ansiToJson(o,a){return new n().ansiToJson(o,a)}static ansiToText(o){return new n().ansiToText(o)}constructor(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0,this.decorations=[]}setupPalette(){this.PALETTE_COLORS=[];for(let l=0;l<2;++l)for(let u=0;u<8;++u)this.PALETTE_COLORS.push(e[l][u].color);let o=[0,95,135,175,215,255],a=(l,u,d)=>o[l]+", "+o[u]+", "+o[d];for(let l=0;l<6;++l)for(let u=0;u<6;++u)for(let d=0;d<6;++d)this.PALETTE_COLORS.push(a(l,u,d));let i=8;for(let l=0;l<24;++l,i+=10)this.PALETTE_COLORS.push(i+", "+i+", "+i)}escapeForHtml(o){return o.replace(/[&<>\"]/gm,a=>a=="&"?"&amp;":a=='"'?"&quot;":a=="<"?"&lt;":a==">"?"&gt;":"")}linkify(o){return o.replace(t,a=>`<a href="${a}">${a}</a>`)}ansiToHtml(o,a){return this.process(o,a,!0)}ansiToJson(o,a){return a=a||{},a.json=!0,a.clearLine=!1,this.process(o,a,!0)}ansiToText(o){return this.process(o,{},!1)}process(o,a,i){let l=this,u=o.split(/\033\[/),d=u.shift();a==null&&(a={}),a.clearLine=/\r/.test(o);let f=u.map(h=>this.processChunk(h,a,i));if(a&&a.json){let h=l.processChunkJson("");return h.content=d,h.clearLine=a.clearLine,f.unshift(h),a.remove_empty&&(f=f.filter(m=>!m.isEmpty())),f}else f.unshift(d);return f.join("")}processChunkJson(o,a,i){a=typeof a>"u"?{}:a;let l=a.use_classes=typeof a.use_classes<"u"&&a.use_classes,u=a.key=l?"class":"color",d={content:o,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:a.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!d.content},f=o.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!f)return d;d.content=f[4];let h=f[2].split(";");if(f[1]!==""||f[3]!=="m"||!i)return d;let m=this;for(;h.length>0;){let x=h.shift(),g=parseInt(x);if(isNaN(g)||g===0)m.fg=m.bg=null,m.decorations=[];else if(g===1)m.decorations.push("bold");else if(g===2)m.decorations.push("dim");else if(g===3)m.decorations.push("italic");else if(g===4)m.decorations.push("underline");else if(g===5)m.decorations.push("blink");else if(g===7)m.decorations.push("reverse");else if(g===8)m.decorations.push("hidden");else if(g===9)m.decorations.push("strikethrough");else if(g===21)m.removeDecoration("bold");else if(g===22)m.removeDecoration("bold"),m.removeDecoration("dim");else if(g===23)m.removeDecoration("italic");else if(g===24)m.removeDecoration("underline");else if(g===25)m.removeDecoration("blink");else if(g===27)m.removeDecoration("reverse");else if(g===28)m.removeDecoration("hidden");else if(g===29)m.removeDecoration("strikethrough");else if(g===39)m.fg=null;else if(g===49)m.bg=null;else if(g>=30&&g<38)m.fg=e[0][g%10][u];else if(g>=90&&g<98)m.fg=e[1][g%10][u];else if(g>=40&&g<48)m.bg=e[0][g%10][u];else if(g>=100&&g<108)m.bg=e[1][g%10][u];else if(g===38||g===48){let C=g===38;if(h.length>=1){let b=h.shift();if(b==="5"&&h.length>=1){let v=parseInt(h.shift());if(v>=0&&v<=255)if(!l)this.PALETTE_COLORS||m.setupPalette(),C?m.fg=this.PALETTE_COLORS[v]:m.bg=this.PALETTE_COLORS[v];else{let k=v>=16?"ansi-palette-"+v:e[v>7?1:0][v%8].class;C?m.fg=k:m.bg=k}}else if(b==="2"&&h.length>=3){let v=parseInt(h.shift()),k=parseInt(h.shift()),y=parseInt(h.shift());if(v>=0&&v<=255&&k>=0&&k<=255&&y>=0&&y<=255){let p=v+", "+k+", "+y;l?C?(m.fg="ansi-truecolor",m.fg_truecolor=p):(m.bg="ansi-truecolor",m.bg_truecolor=p):C?m.fg=p:m.bg=p}}}}}return m.fg===null&&m.bg===null&&m.decorations.length===0||(d.fg=m.fg,d.bg=m.bg,d.fg_truecolor=m.fg_truecolor,d.bg_truecolor=m.bg_truecolor,d.decorations=m.decorations,d.decoration=m.decorations.slice(-1).pop()||null,d.was_processed=!0),d}processChunk(o,a,i){a=a||{};let l=this.processChunkJson(o,a,i),u=a.use_classes;if(l.decorations=l.decorations.filter(g=>{if(g==="reverse"){l.fg||(l.fg=e[0][7][u?"class":"color"]),l.bg||(l.bg=e[0][0][u?"class":"color"]);let C=l.fg;l.fg=l.bg,l.bg=C;let b=l.fg_truecolor;return l.fg_truecolor=l.bg_truecolor,l.bg_truecolor=b,l.isInverted=!0,!1}return!0}),a.json)return l;if(l.isEmpty())return"";if(!l.was_processed)return l.content;let d=[],f=[],h=[],m={},x=g=>{let C=[],b;for(b in g)g.hasOwnProperty(b)&&C.push("data-"+b+'="'+this.escapeForHtml(g[b])+'"');return C.length>0?" "+C.join(" "):""};return l.isInverted&&(m["ansi-is-inverted"]="true"),l.fg&&(u?(d.push(l.fg+"-fg"),l.fg_truecolor!==null&&(m["ansi-truecolor-fg"]=l.fg_truecolor,l.fg_truecolor=null)):d.push("color:rgb("+l.fg+")")),l.bg&&(u?(d.push(l.bg+"-bg"),l.bg_truecolor!==null&&(m["ansi-truecolor-bg"]=l.bg_truecolor,l.bg_truecolor=null)):d.push("background-color:rgb("+l.bg+")")),l.decorations.forEach(g=>{if(u){f.push("ansi-"+g);return}g==="bold"?f.push("font-weight:bold"):g==="dim"?f.push("opacity:0.5"):g==="italic"?f.push("font-style:italic"):g==="hidden"?f.push("visibility:hidden"):g==="strikethrough"?h.push("line-through"):h.push(g)}),h.length&&f.push("text-decoration:"+h.join(" ")),u?'<span class="'+d.concat(f).join(" ")+'"'+x(m)+">"+l.content+"</span>":'<span style="'+d.concat(f).join(";")+'"'+x(m)+">"+l.content+"</span>"}removeDecoration(o){const a=this.decorations.indexOf(o);a>=0&&this.decorations.splice(a,1)}}return Nn=n,Nn}var bt={exports:{}},ur;function dh(){if(ur)return bt.exports;ur=1;function e(o){if(!o)return"";if(!/\r/.test(o))return o;for(o=o.replace(/\r+\n/gm,`
37
- `);/\r./.test(o);)o=o.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm,function(a,i,l){return l+i.slice(l.length)});return o}function t(o){for(var a=0,i=0;i<o.length;i++)o[a].length<=o[i].length&&(a=i);return a}function n(o){if(!/\r/.test(o))return o;for(var a=o.split("\r"),i=[];a.length>0;){var l=t(a);i.push(a[l]),a=a.slice(l+1)}return i.join("\r")}function s(o){if(!o)return"";if(!/\r/.test(o))return o;if(!/\n/.test(o))return n(o);o=o.replace(/\r+\n/gm,`
38
- `);var a=o.lastIndexOf(`
39
- `);return e(o.slice(0,a))+`
40
- `+n(o.slice(a+1))}return bt.exports=e,bt.exports.escapeCarriageReturn=e,bt.exports.escapeCarriageReturnSafe=s,bt.exports}var qe={},dr;function fh(){if(dr)return qe;dr=1;var e=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,t=/[\0-\x1F\x7F-\x9F]/,n=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,s=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,o=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,a=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;return qe.Any=e,qe.Cc=t,qe.Cf=n,qe.P=s,qe.S=o,qe.Z=a,qe}var En,fr;function mh(){if(fr)return En;fr=1;var e=fh();function t(y){const p={};y=y||{},p.src_Any=e.Any.source,p.src_Cc=e.Cc.source,p.src_Z=e.Z.source,p.src_P=e.P.source,p.src_ZPCc=[p.src_Z,p.src_P,p.src_Cc].join("|"),p.src_ZCc=[p.src_Z,p.src_Cc].join("|");const j="[><|]";return p.src_pseudo_letter=`(?:(?!${j}|${p.src_ZPCc})${p.src_Any})`,p.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",p.src_auth=`(?:(?:(?!${p.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`,p.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",p.src_host_terminator=`(?=$|${j}|${p.src_ZPCc})(?!${y["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${p.src_ZPCc}))`,p.src_path=`(?:[/?#](?:(?!${p.src_ZCc}|${j}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${p.src_ZCc}|\\]).)*\\]|\\((?:(?!${p.src_ZCc}|[)]).)*\\)|\\{(?:(?!${p.src_ZCc}|[}]).)*\\}|\\"(?:(?!${p.src_ZCc}|["]).)+\\"|\\'(?:(?!${p.src_ZCc}|[']).)+\\'|\\'(?=${p.src_pseudo_letter}|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!${p.src_ZCc}|[.]|$)|`+(y["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+`,(?!${p.src_ZCc}|$)|;(?!${p.src_ZCc}|$)|\\!+(?!${p.src_ZCc}|[!]|$)|\\?(?!${p.src_ZCc}|[?]|$))+|\\/)?`,p.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}',p.src_xn="xn--[a-z0-9\\-]{1,59}",p.src_domain_root="(?:"+p.src_xn+`|${p.src_pseudo_letter}{1,63})`,p.src_domain="(?:"+p.src_xn+`|(?:${p.src_pseudo_letter})|(?:${p.src_pseudo_letter}(?:-|${p.src_pseudo_letter}){0,61}${p.src_pseudo_letter}))`,p.src_host=`(?:(?:(?:(?:${p.src_domain})\\.)*${p.src_domain}))`,p.tpl_host_fuzzy="(?:"+p.src_ip4+`|(?:(?:(?:${p.src_domain})\\.)+(?:%TLDS%)))`,p.tpl_host_no_ip_fuzzy=`(?:(?:(?:${p.src_domain})\\.)+(?:%TLDS%))`,p.src_host_strict=p.src_host+p.src_host_terminator,p.tpl_host_fuzzy_strict=p.tpl_host_fuzzy+p.src_host_terminator,p.src_host_port_strict=p.src_host+p.src_port+p.src_host_terminator,p.tpl_host_port_fuzzy_strict=p.tpl_host_fuzzy+p.src_port+p.src_host_terminator,p.tpl_host_port_no_ip_fuzzy_strict=p.tpl_host_no_ip_fuzzy+p.src_port+p.src_host_terminator,p.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${p.src_ZPCc}|>|$))`,p.tpl_email_fuzzy=`(^|${j}|"|\\(|${p.src_ZCc})(${p.src_email_name}@${p.tpl_host_fuzzy_strict})`,p.tpl_link_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${p.src_ZPCc}))((?![$+<=>^\`||])${p.tpl_host_port_fuzzy_strict}${p.src_path})`,p.tpl_link_no_ip_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${p.src_ZPCc}))((?![$+<=>^\`||])${p.tpl_host_port_no_ip_fuzzy_strict}${p.src_path})`,p}function n(y){return Array.prototype.slice.call(arguments,1).forEach(function(j){j&&Object.keys(j).forEach(function(_){y[_]=j[_]})}),y}function s(y){return Object.prototype.toString.call(y)}function o(y){return s(y)==="[object String]"}function a(y){return s(y)==="[object Object]"}function i(y){return s(y)==="[object RegExp]"}function l(y){return s(y)==="[object Function]"}function u(y){return y.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const d={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function f(y){return Object.keys(y||{}).reduce(function(p,j){return p||d.hasOwnProperty(j)},!1)}const h={"http:":{validate:function(y,p,j){const _=y.slice(p);return j.re.http||(j.re.http=new RegExp(`^\\/\\/${j.re.src_auth}${j.re.src_host_port_strict}${j.re.src_path}`,"i")),j.re.http.test(_)?_.match(j.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(y,p,j){const _=y.slice(p);return j.re.no_http||(j.re.no_http=new RegExp("^"+j.re.src_auth+`(?:localhost|(?:(?:${j.re.src_domain})\\.)+${j.re.src_domain_root})`+j.re.src_port+j.re.src_host_terminator+j.re.src_path,"i")),j.re.no_http.test(_)?p>=3&&y[p-3]===":"||p>=3&&y[p-3]==="/"?0:_.match(j.re.no_http)[0].length:0}},"mailto:":{validate:function(y,p,j){const _=y.slice(p);return j.re.mailto||(j.re.mailto=new RegExp(`^${j.re.src_email_name}@${j.re.src_host_strict}`,"i")),j.re.mailto.test(_)?_.match(j.re.mailto)[0].length:0}}},m="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",x="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function g(y){return function(p,j){const _=p.slice(j);return y.test(_)?_.match(y)[0].length:0}}function C(){return function(y,p){p.normalize(y)}}function b(y){const p=y.re=t(y.__opts__),j=y.__tlds__.slice();y.onCompile(),y.__tlds_replaced__||j.push(m),j.push(p.src_xn),p.src_tlds=j.join("|");function _(T){return T.replace("%TLDS%",p.src_tlds)}p.email_fuzzy=RegExp(_(p.tpl_email_fuzzy),"i"),p.email_fuzzy_global=RegExp(_(p.tpl_email_fuzzy),"ig"),p.link_fuzzy=RegExp(_(p.tpl_link_fuzzy),"i"),p.link_fuzzy_global=RegExp(_(p.tpl_link_fuzzy),"ig"),p.link_no_ip_fuzzy=RegExp(_(p.tpl_link_no_ip_fuzzy),"i"),p.link_no_ip_fuzzy_global=RegExp(_(p.tpl_link_no_ip_fuzzy),"ig"),p.host_fuzzy_test=RegExp(_(p.tpl_host_fuzzy_test),"i");const D=[];y.__compiled__={};function A(T,S){throw new Error(`(LinkifyIt) Invalid schema "${T}": ${S}`)}Object.keys(y.__schemas__).forEach(function(T){const S=y.__schemas__[T];if(S===null)return;const E={validate:null,link:null};if(y.__compiled__[T]=E,a(S)){i(S.validate)?E.validate=g(S.validate):l(S.validate)?E.validate=S.validate:A(T,S),l(S.normalize)?E.normalize=S.normalize:S.normalize?A(T,S):E.normalize=C();return}if(o(S)){D.push(T);return}A(T,S)}),D.forEach(function(T){y.__compiled__[y.__schemas__[T]]&&(y.__compiled__[T].validate=y.__compiled__[y.__schemas__[T]].validate,y.__compiled__[T].normalize=y.__compiled__[y.__schemas__[T]].normalize)}),y.__compiled__[""]={validate:null,normalize:C()};const N=Object.keys(y.__compiled__).filter(function(T){return T.length>0&&y.__compiled__[T]}).map(u).join("|");y.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${N})`,"i"),y.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${N})`,"ig"),y.re.schema_at_start=RegExp(`^${y.re.schema_search.source}`,"i"),y.re.pretest=RegExp(`(${y.re.schema_test.source})|(${y.re.host_fuzzy_test.source})|@`,"i")}function v(y,p,j,_){const D=y.slice(j,_);this.schema=p.toLowerCase(),this.index=j,this.lastIndex=_,this.raw=D,this.text=D,this.url=D}function k(y,p){if(!(this instanceof k))return new k(y,p);p||f(y)&&(p=y,y={}),this.__opts__=n({},d,p),this.__schemas__=n({},h,y),this.__compiled__={},this.__tlds__=x,this.__tlds_replaced__=!1,this.re={},b(this)}return k.prototype.add=function(p,j){return this.__schemas__[p]=j,b(this),this},k.prototype.set=function(p){return this.__opts__=n(this.__opts__,p),this},k.prototype.test=function(p){if(!p.length)return!1;let j,_;if(this.re.schema_test.test(p)){for(_=this.re.schema_search,_.lastIndex=0;(j=_.exec(p))!==null;)if(this.testSchemaAt(p,j[2],_.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&p.search(this.re.host_fuzzy_test)>=0&&p.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&p.indexOf("@")>=0&&p.match(this.re.email_fuzzy)!==null)},k.prototype.pretest=function(p){return this.re.pretest.test(p)},k.prototype.testSchemaAt=function(p,j,_){return this.__compiled__[j.toLowerCase()]?this.__compiled__[j.toLowerCase()].validate(p,_,this):0},k.prototype.match=function(p){const j=[],_=[],D=[],A=[];let N,T,S;function E(R,F){return R?F?R.index!==F.index?R.index<F.index?R:F:R.lastIndex>=F.lastIndex?R:F:R:F}if(!p.length)return null;if(this.re.schema_test.test(p))for(S=this.re.schema_search,S.lastIndex=0;(N=S.exec(p))!==null;)T=this.testSchemaAt(p,N[2],S.lastIndex),T&&_.push({schema:N[2],index:N.index+N[1].length,lastIndex:N.index+N[0].length+T});if(this.__opts__.fuzzyLink&&this.__compiled__["http:"])for(S=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,S.lastIndex=0;(N=S.exec(p))!==null;)D.push({schema:"",index:N.index+N[1].length,lastIndex:N.index+N[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"])for(S=this.re.email_fuzzy_global,S.lastIndex=0;(N=S.exec(p))!==null;)A.push({schema:"mailto:",index:N.index+N[1].length,lastIndex:N.index+N[0].length});const w=[0,0,0];let M=0;for(;;){const R=[_[w[0]],A[w[1]],D[w[2]]],F=E(E(R[0],R[1]),R[2]);if(!F)break;if(F===R[0]?w[0]++:F===R[1]?w[1]++:w[2]++,F.index<M)continue;const I=new v(p,F.schema,F.index,F.lastIndex);this.__compiled__[I.schema].normalize(I,this),j.push(I),M=F.lastIndex}return j.length?j:null},k.prototype.matchAtStart=function(p){if(!p.length)return null;const j=this.re.schema_at_start.exec(p);if(!j)return null;const _=this.testSchemaAt(p,j[2],j[0].length);if(!_)return null;const D=new v(p,j[2],j.index+j[1].length,j.index+j[0].length+_);return this.__compiled__[D.schema].normalize(D,this),D},k.prototype.tlds=function(p,j){return p=Array.isArray(p)?p:[p],j?(this.__tlds__=this.__tlds__.concat(p).sort().filter(function(_,D,A){return _!==A[D-1]}).reverse(),b(this),this):(this.__tlds__=p.slice(),this.__tlds_replaced__=!0,b(this),this)},k.prototype.normalize=function(p){p.schema||(p.url=`http://${p.url}`),p.schema==="mailto:"&&!/^mailto:/i.test(p.url)&&(p.url=`mailto:${p.url}`)},k.prototype.onCompile=function(){},En=k,En}var mr;function ph(){if(mr)return De;mr=1;var e=De&&De.__createBinding||(Object.create?(function(b,v,k,y){y===void 0&&(y=k);var p=Object.getOwnPropertyDescriptor(v,k);(!p||("get"in p?!v.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return v[k]}}),Object.defineProperty(b,y,p)}):(function(b,v,k,y){y===void 0&&(y=k),b[y]=v[k]})),t=De&&De.__setModuleDefault||(Object.create?(function(b,v){Object.defineProperty(b,"default",{enumerable:!0,value:v})}):function(b,v){b.default=v}),n=De&&De.__importStar||(function(){var b=function(v){return b=Object.getOwnPropertyNames||function(k){var y=[];for(var p in k)Object.prototype.hasOwnProperty.call(k,p)&&(y[y.length]=p);return y},b(v)};return function(v){if(v&&v.__esModule)return v;var k={};if(v!=null)for(var y=b(v),p=0;p<y.length;p++)y[p]!=="default"&&e(k,v,y[p]);return t(k,v),k}})(),s=De&&De.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(De,"__esModule",{value:!0}),De.default=g;const o=s(uh()),a=dh(),i=s(mh()),l=n(wl());function u(b,v=!1){return b=(0,a.escapeCarriageReturn)(C(b)),o.default.ansiToJson(b,{json:!0,remove_empty:!0,use_classes:v})}function d(b){let v="";return b.bg&&(v+=`${b.bg}-bg `),b.fg&&(v+=`${b.fg}-fg `),b.decoration&&(v+=`ansi-${b.decoration} `),v===""?null:(v=v.substring(0,v.length-1),v)}function f(b){const v={};switch(b.bg&&(v.backgroundColor=`rgb(${b.bg})`),b.fg&&(v.color=`rgb(${b.fg})`),b.decoration){case"bold":v.fontWeight="bold";break;case"dim":v.opacity="0.5";break;case"italic":v.fontStyle="italic";break;case"hidden":v.visibility="hidden";break;case"strikethrough":v.textDecoration="line-through";break;case"underline":v.textDecoration="underline";break;case"blink":v.textDecoration="blink";break}return v}function h(b,v,k,y){const p=v?null:f(k),j=v?d(k):null;return b?b==="fuzzy"?x(k,y,p,j):m(k,y,p,j):l.createElement("span",{style:p,key:y,className:j},k.content)}function m(b,v,k,y){const p=[],j=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let _=0,D;for(;(D=j.exec(b.content))!==null;){const[,A,N]=D,T=D.index+A.length;T>_&&p.push(b.content.substring(_,T));const S=N.startsWith("www.")?`http://${N}`:N;p.push(l.createElement("a",{key:_,href:S,target:"_blank"},`${N}`)),_=j.lastIndex}return _<b.content.length&&p.push(b.content.substring(_)),l.createElement("span",{style:k,key:v,className:y},p)}function x(b,v,k,y){var p;const j=(0,i.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!j.pretest(b.content))return l.createElement("span",{style:k,key:v,className:y},b.content);const _=j.match(b.content);if(!_)return l.createElement("span",{style:k,key:v,className:y},b.content);const D=[b.content.substring(0,(p=_[0])===null||p===void 0?void 0:p.index)];return _.forEach((A,N)=>{var T;D.push(l.createElement("a",{href:A.url,target:"_blank",key:N},b.content.substring(A.index,A.lastIndex))),_[N+1]&&D.push(b.content.substring(_[N].lastIndex,(T=_[N+1])===null||T===void 0?void 0:T.index))}),_[_.length-1].lastIndex!==b.content.length&&D.push(b.content.substring(_[_.length-1].lastIndex,b.content.length)),l.createElement("span",{style:k,key:v,className:y},D)}function g(b){const{className:v,useClasses:k,children:y,linkify:p}=b;return l.createElement("code",{className:v},u(y??"",k??!1).map(h.bind(null,p??!1,k??!1)))}function C(b){let v=b;do b=v,v=b.replace(/[^\n]\x08/gm,"");while(v.length<b.length);return b}return De}var hh=ph();const gh=Nl(hh),xh=c.lazy(()=>El(()=>import("./index-DfSOcv9s.js"),__vite__mapDeps([0,1,2,3]))),bh={...ah,container:"bg-transparent text-xs font-mono leading-relaxed",label:"text-muted-foreground font-medium mr-1",clickableLabel:"text-muted-foreground font-medium mr-1 cursor-pointer",nullValue:"text-muted-foreground italic",undefinedValue:"text-muted-foreground italic",stringValue:"text-foreground",booleanValue:"text-amber-400",numberValue:"text-blue-400",otherValue:"text-muted-foreground",punctuation:"text-muted-foreground",collapseIcon:'text-muted-foreground mr-1 cursor-pointer text-[1.2em] select-none after:content-["▾"]',expandIcon:'text-muted-foreground mr-1 cursor-pointer text-[1.2em] select-none after:content-["▸"]',collapsedContent:'text-muted-foreground mr-1 cursor-pointer after:text-[0.8em] after:content-["…"]'},pr=5120;function yh(e){try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&("old_string"in t||"new_string"in t)?t:null}catch{return null}}function Dn({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:o}){const[a,i]=c.useState(!1),l=t.length>pr,u=l&&!a?t.slice(0,pr):t;return r.jsxs("div",{className:"space-y-1",children:[n&&r.jsx("div",{className:"flex justify-end",children:r.jsx("button",{onClick:o,className:"text-muted-foreground hover:text-foreground text-xs underline",children:s?"Formatted":"Raw"})}),s?r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:u}),l&&!a&&r.jsxs("button",{onClick:()=>i(!0),className:"text-muted-foreground hover:text-foreground text-xs underline",children:["Show full output (",(t.length/1024).toFixed(1),"KB)"]})]}):e]})}function vh({oldValue:e,newValue:t,rawContent:n}){return r.jsx(c.Suspense,{fallback:r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:n}),children:r.jsx(xh,{oldValue:e,newValue:t,splitView:!1,useDarkTheme:!0,hideLineNumbers:!0,showDiffOnly:!0,extraLinesSurroundingDiff:2,styles:{variables:{dark:{diffViewerBackground:"transparent",addedBackground:"rgba(34, 197, 94, 0.1)",addedColor:"rgb(134, 239, 172)",addedGutterBackground:"rgba(34, 197, 94, 0.08)",wordAddedBackground:"rgba(34, 197, 94, 0.2)",removedBackground:"rgba(239, 68, 68, 0.1)",removedColor:"rgb(252, 165, 165)",removedGutterBackground:"rgba(239, 68, 68, 0.08)",wordRemovedBackground:"rgba(239, 68, 68, 0.2)",gutterBackground:"hsl(0 0% 9%)",gutterBackgroundDark:"hsl(0 0% 7%)",gutterColor:"hsl(0 0% 40%)"}}}})})}function Ea({content:e,toolName:t,input:n}){const[s,o]=c.useState(!1);if(t==="Edit"&&n){const i=yh(n);if(i)return r.jsx(vh,{oldValue:i.old_string??"",newValue:i.new_string??"",rawContent:e})}const a=Gd(e);if(a==="json"){let i;try{i=JSON.parse(e)}catch{i={}}return r.jsx(Dn,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>o(l=>!l),children:r.jsx(ch,{data:i,style:bh,shouldExpandNode:lh})})}return a==="ansi"?r.jsx(Dn,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>o(i=>!i),children:r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:r.jsx(gh,{children:e})})}):r.jsx(Dn,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}function kh(e){try{const t=JSON.parse(e);if(!t||typeof t!="object")return e;const n=t;if(n.error&&typeof n.error=="object"){const s=n.error;if(typeof s.message=="string")return s.message}return typeof n.message=="string"?n.message:e}catch{return e}}function Ch(e){const t=kh(e),n=t.match(/The ['"`]([^'"`]+)['"`] model requires a newer version of Codex\b/i);if(n)return{message:`The Codex version DorkOS is using is too old for ${n[1]}. Update DorkOS (or your custom Codex installation), then try again. You can also choose another model.`,category:"runtime_update_required",details:e};const s=t.match(/The ['"`]([^'"`]+)['"`] model is not supported when using Codex with a ChatGPT account\b/i);return s?{message:`${s[1]} isn’t available with a ChatGPT account. Choose another model from the model menu.`,category:"model_unavailable",details:e}:null}const Da="runtimes";function Sh({label:e}){const{open:t}=xo();return r.jsx("button",{type:"button",onClick:()=>t(Da),className:"text-muted-foreground hover:text-foreground mt-2 block text-xs underline decoration-dotted underline-offset-2 transition-colors",children:e})}function jh({runtime:e,sessionId:t,onRetry:n,onSigninComplete:s}){const[o,a]=c.useState(!1),i=td(e,{sessionId:t,onCompleted:()=>a((s==null?void 0:s())??!1)}),l=nd(e);return i.isSuccess?r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin-success",children:[r.jsxs("p",{className:"text-status-success-fg flex items-center gap-2 text-sm",role:"status",children:[r.jsx(lt,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),o?"Signed in. Sending your message again…":"Signed in."]}),!o&&n&&r.jsxs(le,{size:"sm",onClick:n,className:"mt-2 gap-1.5",children:[r.jsx(_t,{className:"size-3"}),"Retry"]})]}):r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin",children:[r.jsx("p",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-sm",role:"status",children:i.isPending&&r.jsxs(r.Fragment,{children:[r.jsx(Le,{size:"xs",className:"shrink-0"}),l.signInPending]})}),i.isError&&r.jsx("p",{className:"text-destructive mb-2 text-sm",role:"alert",children:i.errorMessage}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(le,{size:"sm",onClick:i.login,disabled:i.isPending,className:"gap-1.5","data-testid":"auth-error-signin-button",children:[r.jsx(bo,{className:"size-3"}),i.isError?"Try again":l.signInLabel]}),n&&r.jsxs(le,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[r.jsx(_t,{className:"size-3"}),"Retry"]})]}),r.jsx(Sh,{label:"Use an API key instead"})]})}function hr({onRetry:e}){return r.jsx("div",{className:"mt-3","data-testid":"auth-error-remote-guidance",children:r.jsx(Zu,{...e?{onRetry:e}:{}})})}function Ta({onRetry:e}){const{open:t}=xo();return r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(le,{size:"sm",onClick:()=>t(Da),className:"gap-1.5",children:[r.jsx(bo,{className:"size-3"}),"Fix sign-in"]}),e&&r.jsxs(le,{variant:"outline",size:"sm",onClick:e,className:"gap-1.5",children:[r.jsx(_t,{className:"size-3"}),"Retry"]})]})}function _h({runtime:e,sessionId:t,onRetry:n,renderOffer:s,lead:o,children:a}){const i=!Lo(),l=yo(),u=ue(m=>m.setRetryAccount),d=Ft(e).label,f=s({runtime:e,origin:`auth-error:${t}`,note:`This makes new ${d} work on this computer run on your DorkOS credits.`,chosen:n?`New ${d} work on this computer now runs on your DorkOS credits. Sending your message again…`:`New ${d} work on this computer now runs on your DorkOS credits.`,...n?{confirmAfterLink:{prompt:"Linked. Send again on DorkOS credits?",action:"Send again"}}:{},onChoose:async()=>{await l.mutateAsync({runtime:e,useCredits:!0}),n&&(u({id:ct,sessionId:t}),n())}}),h=m=>r.jsxs("section",{"aria-label":"Other ways",children:[r.jsx("p",{className:"text-muted-foreground text-2xs font-medium tracking-wide uppercase",children:"Other ways"}),m]});return o?r.jsxs("div",{className:"mt-3 space-y-3","data-testid":"auth-error-credits-first",children:[f,h(a),r.jsx(ed,{ollama:Dl(e)==="provider-picker",remote:i})]}):r.jsxs("div",{"data-testid":"auth-error-credits-other-way",children:[a,r.jsx("div",{className:"mt-3",children:h(f)})]})}function wh({sessionId:e,onRetry:t,onSigninComplete:n}){var h;const{sessions:s,isLoading:o}=ts(),a=Lo(),i=(h=s.find(m=>m.id===e))==null?void 0:h.runtime,l=Ju(i),u=uo(),d=i!==void 0&&u!==null&&(l==="lead"||l==="other-way");if(!a&&!d)return r.jsx(hr,{onRetry:t});if(o)return null;const f=a?!i||!Tl(i)?r.jsx(Ta,{onRetry:t}):r.jsx(jh,{runtime:i,sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(hr,{onRetry:t});return d&&i&&u?r.jsx(_h,{runtime:i,sessionId:e,onRetry:t,renderOffer:u,lead:l==="lead",children:f}):f}function Nh({sessionId:e,onRetry:t,onSigninComplete:n}){return e?r.jsx(wh,{sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(Ta,{onRetry:t})}const Eh="credits_unavailable",Dh="folder-sign-in";function Th({onRetry:e,sessionId:t,runtimeLabel:n,reason:s}){const o=ue(g=>g.setRetryAccount),a=Al(),i=yo(),l=vo(),u=rn(t),d=nn(u??null);if(!e)return null;const f=Ah(d),h=n?`your ${n}`:"your own",m=()=>{if(d!==void 0){if(f==="pick-for-send"){t&&o({id:St,sessionId:t}),e();return}i.mutate({runtime:d.type,useCredits:!1},{onSuccess:()=>f==="new-conversation"?l(void 0,{runtime:d.type}):e()})}},x=()=>{t&&a.mutate(t,{onSuccess:({launch:g})=>{g!=null&&g.ok&&o({id:g.accountId,sessionId:t}),e()}})};return r.jsxs("div",{className:"mt-2 flex flex-col gap-2","data-testid":"credits-error-actions",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(le,{size:"sm",variant:"outline",onClick:e,className:"gap-1.5",children:[r.jsx(_t,{className:"size-3"}),"Retry"]}),t&&r.jsx(le,{size:"sm",variant:"outline",onClick:m,disabled:d===void 0||i.isPending,children:f==="new-conversation"?`Start a new chat on ${h} sign-in`:`Use ${h} sign-in`}),t&&s===Dh&&r.jsx(le,{size:"sm",variant:"outline",onClick:x,disabled:a.isPending,children:"Don’t use credits in this project"})]}),t&&f==="whole-runtime"&&r.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"credits-own-sign-in-reach",children:["This moves all ",n??"its"," chats to ",h," sign-in, not just this one."]}),a.error&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:a.error.message}),i.isError&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:"Couldn’t switch to your own sign-in. Try again in a moment."})]})}function Ah(e){var t;return e===void 0||e.supportsAccounts?"pick-for-send":((t=e.credits)==null?void 0:t.scope)==="conversation"?"new-conversation":"whole-runtime"}function Fh({category:e,onChooseModel:t}){return t?r.jsxs(le,{size:"sm",onClick:t,className:"mt-3 gap-1.5",children:[r.jsx(ko,{className:"size-3"}),e==="runtime_update_required"?"Choose another model":"Choose model"]}):null}const Rh="your agent",Mh="agent",gr={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"Something went wrong before it finished.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This chat hit its spending limit.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn’t produce the required output format.",retryable:!1},auth_error:{heading:"Sign in again",subtext:"Your login stopped working. Sign in again to continue.",retryable:!0},model_unavailable:{heading:"Model unavailable",subtext:"Choose another model from the model menu.",retryable:!1},runtime_update_required:{heading:"Codex update required",subtext:"Update DorkOS or your Codex install, then try again. Or choose another model.",retryable:!1}},Oh=new Set(["max_turns","budget_exceeded","output_format_error","auth_error"]);function Ih(e){return`Sign in to ${e??Rh} again`}function $h(e){return`Your ${e??Mh} login stopped working. Sign in again to continue.`}const Ph="rate_limit";function an(e){const{code:t,at:n,sessionId:s,reason:o}=e;return t===Co&&o?r.jsx(Zo,{agentId:o}):t===Ph&&s?r.jsx(km,{sessionId:s,at:n??"",fallback:r.jsx(xr,{...e})}):r.jsx(xr,{...e})}function xr({message:e,category:t,details:n,onRetry:s,heading:o,subtext:a,runtimeLabel:i,sessionId:l,onSigninComplete:u,onChooseModel:d,code:f,reason:h}){const[m,x]=c.useState(!1),g=f===Eh,C=c.useMemo(()=>Ch(e),[e]),b=(C==null?void 0:C.category)??t,v=(C==null?void 0:C.message)??e,k=C?n!=null&&n.includes(C.details??"")?n:[n,C.details].filter(Boolean).join(`
41
- `):n,y=b==="auth_error",p=b?gr[b]??gr.execution_error:null,j=y?Ih(i):b==="runtime_update_required"&&i?`${i} update required`:p==null?void 0:p.heading,_=y?$h(i):p==null?void 0:p.subtext,D=g?"Couldn’t reach DorkOS credits":C?j??"Error":o??j??"Error",A=v.trim(),N=b!==void 0&&Oh.has(b),T=g?A:(C&&(a==null?void 0:a.trim())===e.trim()?void 0:a)??(N?_:A||_)??A,S=T.trim(),E=c.useMemo(()=>Fl(A),[A]),w=!A||A===S||A===D,M=!w&&(!N||E)?A:null,R=w||M!==null||k!=null&&k.includes(A)?k:[k,A].filter(Boolean).join(`
42
- `),F=(p==null?void 0:p.retryable)??!!s;return r.jsx("div",{"data-testid":"error-message-block",className:W("my-2 rounded-lg border px-4 py-3","border-destructive/30 bg-destructive/5 text-foreground"),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(fs,{className:"text-destructive mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium",children:D}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(pn,{text:T})}),M&&r.jsx("p",{className:"text-muted-foreground mt-1 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(pn,{text:M})}),R&&r.jsxs("button",{type:"button",onClick:()=>x(!m),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":m,children:[r.jsx(V.div,{animate:{rotate:m?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:r.jsx(At,{className:"size-3"})}),"Details"]}),r.jsx(de,{initial:!1,children:m&&R&&r.jsx(V.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:"overflow-hidden",children:r.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:r.jsx(pn,{text:R})})})}),g&&r.jsx(Th,{onRetry:s,sessionId:l,runtimeLabel:i,reason:h}),y&&r.jsx(Nh,{sessionId:l,onRetry:s,onSigninComplete:u}),(b==="model_unavailable"||b==="runtime_update_required")&&r.jsx(Fh,{category:b,onChooseModel:d})]}),!y&&!g&&F&&s&&r.jsxs(le,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[r.jsx(_t,{className:"size-3"}),"Retry"]})]})})}const Lh=8;function zh({toolName:e,reasonType:t,reason:n,message:s,agentId:o}){const a=n||s,i=t==="classifier",l=t==="asyncAgent",u=o!==void 0?`Helper ${o.slice(0,Lh)}`:l?"A background helper":null,f=u!==null?`${u} was blocked from using ${e}${i?" by auto mode":""}: ${a}`:i?`Blocked by auto mode: ${a}`:`Blocked: ${a}`;return r.jsxs("div",{"data-testid":"permission-denied-chip","data-reason-type":t,"data-agent-id":o,className:W("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-amber-500/30 bg-amber-500/5"),children:[r.jsx(ud,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-500"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm",children:f}),l?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Background helpers can’t ask for approval, so this was blocked."}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Do it yourself, or ask the agent to run it in the foreground."})]}):null,r.jsx("p",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:e})]})]})}const Bh=50;function qh(e){return e.type==="tool_call"&&e.interactiveType==="approval"&&e.approvalOutcome!==void 0}function Uh(e,t){return e.approvalOutcome!==t.approvalOutcome||(e.approvalReasonGiven??!1)!==(t.approvalReasonGiven??!1)||e.approvalResolvedAt===void 0||t.approvalResolvedAt===void 0?!1:Math.abs(e.approvalResolvedAt-t.approvalResolvedAt)<=Bh}function Hh(e){const t=new Map;let n=null;for(let s=0;s<e.length;s++){const o=e[s];if(!qh(o)){n=null;continue}if(n&&Uh(n.part,o)){n.group.indices.push(s),t.set(s,n.group);continue}const a={leadIndex:s,indices:[s],outcome:o.approvalOutcome,reasonGiven:o.approvalReasonGiven??!1};t.set(s,a),n={group:a,part:o}}return t}function Wh(e){return e.questionOutcome!==void 0?e.questionOutcome==="answered":e.status!=="pending"}function Gh(e){return e.status==="pending"?void 0:e.questionOutcome}function Vh({message:e}){return r.jsx(Qe,{"data-testid":"unreadable-entry-note",icon:r.jsx(Rl,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:e})})}function Kh({title:e}){return r.jsxs("div",{"data-testid":"capability-approval-timed-out",className:W("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-border bg-muted/40"),children:[r.jsx(vt,{"aria-hidden":"true",className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm",children:"The agent stopped waiting for your answer."}),r.jsxs("p",{className:"text-muted-foreground mt-0.5 text-xs",children:["“",e,"” is still in Approvals. Answer it, then ask the agent to retry."]})]})]})}function Kn({testId:e,icon:t,children:n}){return r.jsxs("div",{"data-testid":e,className:W("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-border bg-muted/40"),children:[t,r.jsx("div",{className:"min-w-0 flex-1",children:n})]})}function Qh({part:e}){return e.outcome==="failed"?r.jsx(Kn,{testId:"mcp-signin-failed",icon:r.jsx(fs,{"aria-hidden":"true",className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Sign-in to “",e.serverName,"” didn’t finish. Ask your agent to retry."]})}):r.jsx(Kn,{testId:"mcp-signin-receipt",icon:r.jsx(So,{"aria-hidden":"true",className:"text-status-success mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Connected to ",e.serverName,e.toolCount===void 0?"":` · ${e.toolCount} tool${e.toolCount===1?"":"s"}`,"."]})})}function Yh({part:e}){const t=dd(e.agentId,e.serverName),{adopt:n}=t,s=e.outcome!==void 0;return c.useEffect(()=>{s||n({flowId:e.flowId,authorizeUrl:e.authorizeUrl,disclosure:e.disclosure})},[s,n,e.flowId,e.authorizeUrl,e.disclosure]),e.outcome!==void 0?r.jsx(Qh,{part:e}):r.jsxs(Kn,{testId:"mcp-signin-card",icon:r.jsx(Ml,{"aria-hidden":"true",className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),children:[r.jsxs("p",{className:"text-sm",children:["Sign in to ",e.serverName]}),r.jsx(fd,{flow:t,serverName:e.serverName,failedActions:r.jsx(le,{variant:"secondary",size:"sm",onClick:()=>t.start(),className:"focus-visible:ring-2",children:"Try again"})})]})}function Xh({fromName:e,toName:t}){return r.jsx(Qe,{"data-testid":"model-substituted-row",icon:r.jsx(ko,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsxs("span",{className:"text-muted-foreground",children:["DorkOS credits don’t cover ",e,", so this ran on ",t,". Switch in the model menu."]})})}const Jh={running:r.jsx(Le,{size:"xs",className:"text-muted-foreground"}),success:r.jsx(lt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:r.jsx(Ue,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:r.jsx(Ue,{className:"text-muted-foreground size-(--size-icon-xs)"})};function Zh({hook:e}){const t=!!(e.stdout||e.stderr),[n,s]=c.useState(e.status==="error"),o=e.stderr||e.stdout;return r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>t&&s(a=>!a),className:W("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[Jh[e.status],r.jsx("span",{className:W("text-3xs font-mono",e.status==="error"?"text-destructive":"text-muted-foreground"),children:e.hookName}),e.status==="error"&&r.jsx("span",{className:"text-3xs text-destructive",children:"Error"}),e.exitCode!==void 0&&r.jsxs("span",{className:"text-3xs text-muted-foreground ml-auto",children:["exit ",e.exitCode]})]}),r.jsx(de,{initial:!1,children:n&&t&&o&&r.jsx(V.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:"overflow-hidden",children:r.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:o})})})]})}function eg({toolCall:e,defaultExpanded:t=!1}){const[n,s]=c.useState(t),o=!!e.progressOutput;c.useEffect(()=>{o&&!n&&s(!0)},[o]);const a=e.hooks&&e.hooks.length>0?r.jsx("div",{className:"border-border/50 space-y-0.5 border-t px-3 py-1",children:e.hooks.map(u=>r.jsx(Zh,{hook:u},u.hookId))}):void 0,i=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=oo(e.toolName);return r.jsxs(Mt,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:a,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[ha(e.status),l&&r.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:l}),r.jsx("span",{className:"text-3xs flex-1 text-left font-mono",children:dt(e.toolName,e.input)}),i!==void 0&&r.jsx("span",{className:"text-muted-foreground text-3xs tabular-nums",children:md(i)})]}),children:[e.status==="running"&&!e.input?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[r.jsx(Le,{size:"xs"}),r.jsx("span",{children:"Preparing…"})]}):e.input!==void 0&&e.input!==""?r.jsx(Xo,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&r.jsx(ao,{content:e.progressOutput,className:"mt-2 border-t pt-2"}),e.result&&r.jsx("div",{className:"mt-2 border-t pt-2",children:r.jsx(Ea,{content:e.result,toolName:e.toolName,input:e.input})})]})}function tg(e){if(e.startsWith("mcp__"))return e.split("__")[1]||void 0}function Aa(e,t,n){const s=c.useRef(e),[o,a]=c.useState(!(t&&s.current==="complete"));return c.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const i=setTimeout(()=>a(!1),tn.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(i)}},[e,t,n]),!t||n?!0:o}function ng({part:e,autoHide:t,expandToolCalls:n}){var a;const s=((a=e.hooks)==null?void 0:a.some(i=>i.status==="error"))??!1,o=Aa(e.status,t,s);return r.jsx(de,{children:o&&r.jsx(V.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(eg,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function Tn({part:e,sessionId:t,autoHide:n,expandToolCalls:s}){const o=e.ui?tg(e.toolName):void 0,a=r.jsx(ng,{part:e,autoHide:n,expandToolCalls:s});return!e.ui||e.status!=="complete"||!o?a:r.jsxs("div",{className:"flex flex-col gap-2",children:[a,r.jsx(jf,{sessionId:t,serverName:o,uri:e.ui.resourceUri})]})}function sg({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",o=Aa(s,t,!1);return r.jsx(de,{children:o&&r.jsx(V.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx($p,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const rg=4,br=2;function og({children:e}){const[t,n]=c.useState(!1);if(e.length<=rg||t)return r.jsx(r.Fragment,{children:e});const s=e.length-br;return r.jsxs(r.Fragment,{children:[e.slice(0,br),r.jsx(Mt,{expanded:!1,onToggle:()=>n(!0),ariaLabel:`Show ${s} more steps`,className:"border-l-muted-foreground/15",header:r.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]}),children:r.jsx(r.Fragment,{})})]})}const ag=/\|\||&&|;|\|/,ig=/<<|>/,yr=60;function lg(e){if(!e)return null;try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Ie(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function cg(e,t){const n=e.split(`
43
- `),s=t.split(`
44
- `);let o=0;for(;o<n.length&&o<s.length&&n[o]===s[o];)o++;let a=0;for(;a<n.length-o&&a<s.length-o&&n[n.length-1-a]===s[s.length-1-a];)a++;const i=o+a;return{additions:Math.max(0,s.length-i),deletions:Math.max(0,n.length-i)}}function Qn(e){const t=e.old_string,n=e.new_string;if(!(typeof t!="string"&&typeof n!="string"))return cg(typeof t=="string"?t:"",typeof n=="string"?n:"")}function ug(e){const t=e.edits;if(!Array.isArray(t))return Qn(e);let n=0,s=0,o=!1;for(const a of t){if(typeof a!="object"||a===null)continue;const i=Qn(a);i&&(n+=i.additions,s+=i.deletions,o=!0)}return o?{additions:n,deletions:s}:void 0}function dg(e){return e?` +${e.additions} −${e.deletions}`:""}function fg(e){return e.length===0?0:e.replace(/\n$/,"").split(`
45
- `).length}function Fa(e){const t=e.replace(/\/+$/,"");if(t.length===0)return e;const n=t.startsWith("/"),s=[];for(const a of t.split("/"))if(!(a===""||a===".")){if(a===".."){const i=s[s.length-1];i!==void 0&&i!==".."?s.pop():n||s.push("..");continue}s.push(a)}const o=s.join("/");return o.length===0?n?"/":e:n?`/${o}`:o}function mg(e,t){if(e===t)return!0;const n=e.startsWith("/")?e:t,s=e.startsWith("/")?t:e;return!n.startsWith("/")||s.startsWith("/")?!1:n.endsWith(`/${s}`)}function Ra(e){const t=Fa(e).split("/");return t[t.length-1]||e}function pg(e){try{const t=new URL(e);return t.hash="",t.toString()}catch{return e}}function hg(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function gg(e){if(!e)return;const t=e.trim();if(t.length===0)return;if(/^no (matches|files)/i.test(t))return 0;const n=/^(\d+)$/.exec(t);if(n)return Number(n[1]);const s=/(\d+)\s+(?:matches?|lines?)/i.exec(t);if(s)return Number(s[1]);if(!/\d+\s+files?/i.test(t))return t.split(`
46
- `).filter(o=>o.trim().length>0).length}function xg(e){var s;const n=((s=e.split(`
47
- `).find(o=>o.trim().length>0))==null?void 0:s.trim())??e.trim();return n.length<=yr?n:`${n.slice(0,yr-1).trimEnd()}…`}function bg(e){const t=[];let n="",s=null,o=!1;for(const a of e){if(s){a===s?s=null:n+=a;continue}if(a==='"'||a==="'"){s=a,o=!0;continue}if(/\s/.test(a)){o&&t.push(n),n="",o=!1;continue}n+=a,o=!0}return o&&t.push(n),t}function yg(e){const t=[];for(const n of e.split(`
48
- `)){for(const s of n.split(ag)){const o=bg(s.trim());if(o.length===0)continue;let a;if(o[0]==="git"&&o[1]==="rm")a=2;else if(o[0]==="rm")a=1;else continue;for(const i of o.slice(a)){if(i.includes(">")||i.includes("<"))break;i==="--"||i.startsWith("-")||i.length===0||t.push(i)}}if(ig.test(n))break}return t}const vr={delete:3,create:2,edit:1,read:0,search:0,fetch:0,run:0},vg=new Set(["Task","Agent","TodoWrite"]);function vs(e){return e===1?"1 hit":`${e} hits`}const kg=/[*?[\]~$]/;function yt(e,t,n,s,o){const a=Fa(e);return{key:`file:${a}`,kind:"file",label:o===!0?a:Ra(a),fullTarget:a,verb:t,entry:n,additions:s==null?void 0:s.additions,deletions:s==null?void 0:s.deletions,pattern:o===!0?!0:void 0}}function Cg(e){const{toolName:t}=e;if(vg.has(t)||t.startsWith("mcp__"))return[];const n=lg(e.input);if(!n)return[];switch(t){case"Read":{const s=Ie(n,"file_path");return s?[yt(s,"read","read")]:[]}case"Glob":{const s=Ie(n,"pattern");return s?[{key:`file:${s}`,kind:"file",label:s,fullTarget:s,verb:"read",entry:"globbed",pattern:!0}]:[]}case"Grep":{const s=Ie(n,"pattern");if(!s)return[];const o=e.status==="error"?void 0:gg(e.result);return[{key:`grep:${s}`,kind:"command",label:`"${s}"`,fullTarget:s,verb:"search",entry:o===void 0?"searched":`searched (${vs(o)})`,hits:o}]}case"Edit":case"MultiEdit":case"NotebookEdit":{const s=Ie(n,"file_path")??Ie(n,"notebook_path");if(!s)return[];const o=t==="MultiEdit"?ug(n):Qn(n);return[yt(s,"edit",`edited${dg(o)}`,o)]}case"Write":{const s=Ie(n,"file_path");if(!s)return[];if(!/created/i.test(e.result??""))return[yt(s,"edit","wrote")];const a=Ie(n,"content"),i=a===void 0?void 0:{additions:fg(a)};return[yt(s,"create",`created${i?` +${i.additions}`:""}`,i)]}case"Bash":{const s=Ie(n,"command");if(!s)return[];const o=[{key:`run:${s}`,kind:"command",label:xg(s),fullTarget:s,verb:"run",entry:"ran"}];for(const a of yg(s))o.push(yt(a,"delete","deleted",void 0,kg.test(a)));return o}case"WebFetch":{const s=Ie(n,"url");return s?[{key:`url:${pg(s)}`,kind:"url",label:hg(s),fullTarget:s,verb:"fetch",entry:"fetched"}]:[]}case"WebSearch":{const s=Ie(n,"query");return s?[{key:`websearch:${s}`,kind:"command",label:s,fullTarget:s,verb:"search",entry:"searched the web"}]:[]}default:return[]}}function Sg(e,t){if(t.kind!=="file"||t.pattern===!0||e.has(t.key))return t.key;for(const n of e.values())if(!(n.kind!=="file"||n.pattern===!0)&&mg(n.fullTarget,t.fullTarget))return n.key;return t.key}function jg(e,t,n,s,o){const a=Sg(e,t),i=e.get(a);if(!i){e.set(a,{key:a,kind:t.kind,label:t.label,fullTarget:t.fullTarget,verb:t.verb,live:s,error:o,touches:1,additions:t.additions,deletions:t.deletions,hits:t.hits,pattern:t.pattern,firstSeq:n,lastSeq:n,history:[t.entry]});return}i.touches+=1,i.lastSeq=n,i.live=i.live||s,i.error=i.error||o,i.history.push(t.entry),t.additions!==void 0&&(i.additions=(i.additions??0)+t.additions),t.deletions!==void 0&&(i.deletions=(i.deletions??0)+t.deletions),t.hits!==void 0&&(i.hits=(i.hits??0)+t.hits),t.pattern||(i.pattern=void 0),i.kind==="file"&&i.pattern!==!0&&t.fullTarget.startsWith("/")&&!i.fullTarget.startsWith("/")&&(i.fullTarget=t.fullTarget,i.label=Ra(t.fullTarget)),i.verb==="read"&&t.verb==="edit"&&(i.upgraded=!0),vr[t.verb]>vr[i.verb]&&(i.verb=t.verb)}const kr=new WeakMap;function _g(e){const t=kr.get(e);if(t&&t.input===e.input&&t.result===e.result&&t.status===e.status)return t.touches;const n=Cg(e);return kr.set(e,{input:e.input,result:e.result,status:e.status,touches:n}),n}function wg(e){const t=new Map;return e.forEach((n,s)=>{if(n.type!=="tool_call")return;const o=n.status==="pending"||n.status==="running",a=n.status==="error";for(const i of _g(n))jg(t,i,s,o,a)}),[...t.values()]}const Ma={expanded:!1,verbFilter:null,order:"grouped"},An=as(e=>({views:{},update:(t,n)=>e(s=>({views:{...s.views,[t]:{...s.views[t]??Ma,...n}}}))}));function Ng(e,t){const n=t.find(s=>s.type==="tool_call");return`${e}:${(n==null?void 0:n.toolCallId)??""}`}function Eg(e){const t=An(l=>l.views[e]),n=An(l=>l.update),s=t??Ma,o=c.useCallback(()=>{var l;return n(e,{expanded:!((l=An.getState().views[e])!=null&&l.expanded)})},[e,n]),a=c.useCallback(l=>n(e,{verbFilter:l}),[e,n]),i=c.useCallback(l=>n(e,{order:l}),[e,n]);return c.useMemo(()=>({...s,toggleExpanded:o,setVerbFilter:a,setOrder:i}),[s,o,a,i])}const Cr=4,mt=[.4,0,.2,1],Dg={type:"spring",stiffness:320,damping:28},Tg={duration:.25,ease:mt},Ag={x:-16,scale:.45,opacity:0},Zt={duration:.15,ease:mt},Sr={duration:.3,ease:mt},jr={duration:.15,ease:mt},Fg={duration:.3,ease:mt},Rg={stiffness:220,damping:30},Mg={rotate:[0,-4,3,0],scale:[1,1.08,1,1]},Og={duration:.3,ease:mt};function Ig(e,t){return e?t?{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:Zt},transition:Zt}:{initial:{opacity:0,y:7},animate:{opacity:1,y:0},exit:{...Ag,transition:Tg},transition:Dg}:{}}const ln={read:"📖",search:"🔍",edit:"✏️",create:"✚",delete:"🗑",fetch:"🌐",run:"▮"},cn={read:"Read",search:"Searched",edit:"Edited",create:"Created",delete:"Deleted",fetch:"Fetched",run:"Ran"},Oa=["read","search","edit","create","delete","fetch","run"];function Ia(e){return Oa.map(t=>{const n=e.filter(o=>o.verb===t),s={verb:t,chips:n};for(const o of n)o.additions!==void 0&&(s.additions=(s.additions??0)+o.additions),o.deletions!==void 0&&(s.deletions=(s.deletions??0)+o.deletions);return s}).filter(t=>t.chips.length>0)}const $g=["z-30","-ml-2 z-20 opacity-70","-ml-2 z-10 opacity-45"];function Pg({chips:e,expanded:t,controls:n,onExpand:s}){const o=Ae()??!1,a=e.slice(-3).reverse();return r.jsxs("button",{type:"button","data-testid":"chip-pile","aria-expanded":t,"aria-controls":n,"aria-label":`Show everything this turn touched (${e.length} more)`,onClick:s,className:W("flex shrink-0 items-center gap-1.5 rounded-full py-0.5 pr-1.5 pl-0.5","hover:bg-accent focus-visible:ring-ring outline-none focus-visible:ring-2"),children:[r.jsx(V.span,{animate:o?{rotate:0,scale:1}:Mg,transition:Og,className:"flex origin-bottom items-center",children:a.map((i,l)=>r.jsx("span",{"aria-hidden":"true",className:W("bg-card border-border text-3xs flex size-5 items-center justify-center rounded-full border leading-none",$g[l]),children:ln[i.verb]},i.key))},e.length),r.jsx("span",{"data-testid":"chip-pile-count",className:"bg-primary text-primary-foreground text-3xs rounded-full px-1.5 tabular-nums",children:e.length})]})}function _r({value:e,live:t}){const n=Ae()??!1,s=kd(e,Rg),o=zo(s,a=>Math.round(a));return c.useEffect(()=>{s.set(e)},[s,e]),!t||n?r.jsx(r.Fragment,{children:e}):r.jsx(V.span,{children:o})}function Lg(e){return e.kind!=="command"&&e.pattern!==!0}function zg(e){return[e.fullTarget,e.history.join(", "),e.pattern===!0?"A pattern, not one file. There is nothing to open.":""].filter(Boolean).join(`
49
- `)}function Bg(e){const t=e.pattern===!0&&e.verb==="read"?"Globbed":cn[e.verb],n=e.verb==="run"?e.label:e.fullTarget,s=[`${t} ${n}`];return e.touches>1&&s.push(`${e.touches} times`),e.hits!==void 0&&s.push(vs(e.hits)),e.additions!==void 0&&s.push(`${e.additions} added`),e.deletions!==void 0&&s.push(`${e.deletions} removed`),e.error&&s.push("didn’t work"),s.join(", ")}const wr="bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-3xs leading-[1.4] tabular-nums";function $a({chip:e,onOpen:t,animated:n=!1,pulseUpgrade:s=!1,onUpgradeSeen:o}){const a=Ae()??!1,i=s&&!a,l=Lg(e),u=e.verb==="delete",d=e.additions!==void 0||e.deletions!==void 0,f=n&&(e.verb==="create"||e.verb==="delete");return r.jsxs(V.button,{...Ig(n,a),type:"button","data-testid":"touch-chip","data-verb":e.verb,"data-live":e.live,"data-arriving":f?"true":void 0,title:zg(e),"aria-label":Bg(e),onClick:()=>t(e),className:W("touch-chip relative inline-flex max-w-56 items-center gap-1.5 rounded-full border","px-2 py-0.5 text-xs","bg-card text-foreground border-border","focus-visible:ring-ring outline-none focus-visible:ring-2",l?"hover:bg-accent hover:text-accent-foreground":"cursor-default",u&&"text-muted-foreground line-through opacity-60",e.error&&"border-destructive/40 bg-destructive/10 text-destructive"),children:[r.jsx("span",{"aria-hidden":"true",className:"chip-sweep"}),r.jsxs("span",{className:"chip-icon relative inline-flex w-4 shrink-0 items-center justify-center leading-none",children:[r.jsx("span",{className:"chip-glyph inline-flex items-center justify-center [perspective:400px]",children:r.jsx(de,{initial:!1,mode:"wait",children:r.jsx(V.span,{"aria-hidden":"true",initial:a?{opacity:0}:{opacity:0,rotateX:-90},animate:a?{opacity:1}:{opacity:1,rotateX:0},exit:a?{opacity:0}:{opacity:0,rotateX:90},transition:jr,children:ln[e.verb]},e.verb)})}),i&&r.jsx(V.span,{"aria-hidden":"true","data-testid":"chip-upgrade-pulse",className:"border-primary pointer-events-none absolute -inset-1 rounded-full border",initial:{scale:.6,opacity:.8},animate:{scale:1.8,opacity:0},transition:Fg,onAnimationComplete:()=>o==null?void 0:o(e.key)})]}),r.jsx("span",{className:"chip-label truncate",children:e.label}),e.verb==="edit"&&e.live&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-caret",className:"chip-caret"}),e.verb==="run"&&e.live&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-cursor",className:"chip-cursor"}),e.verb==="fetch"&&e.live&&r.jsxs("span",{"aria-hidden":"true","data-testid":"chip-dots",className:"chip-dots",children:[r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{})]}),e.verb==="create"&&f&&r.jsxs(r.Fragment,{children:[r.jsx("svg",{"aria-hidden":"true","data-testid":"chip-pen",className:"chip-pen",children:r.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",rx:"11",ry:"11",pathLength:"100"})}),r.jsx("span",{"aria-hidden":"true",className:"chip-spark"})]}),e.verb==="delete"&&f&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-puff",className:"chip-puff"}),e.touches>1&&r.jsxs("span",{className:wr,children:["×",e.touches]}),e.hits!==void 0&&r.jsx("span",{className:wr,children:vs(e.hits)}),d&&r.jsxs(V.span,{className:"shrink-0 tabular-nums",initial:i?{opacity:0,x:-4}:!1,animate:{opacity:1,x:0},transition:jr,children:[e.additions!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",r.jsx(_r,{value:e.additions,live:e.live})]}),e.additions!==void 0&&e.deletions!==void 0&&" ",e.deletions!==void 0&&r.jsxs("span",{className:"text-destructive",children:["−",r.jsx(_r,{value:e.deletions,live:e.live})]})]})]})}const Nr=new Map(Oa.map((e,t)=>[e,t]));function qg(e,t){const n=[...e];return t==="chronological"?n.sort((s,o)=>s.lastSeq-o.lastSeq):n.sort((s,o)=>(Nr.get(s.verb)??0)-(Nr.get(o.verb)??0)||s.firstSeq-o.firstSeq)}function Ug({id:e,chips:t,onOpen:n,verbFilter:s,onVerbFilterChange:o,order:a,onOrderChange:i}){const l=c.useMemo(()=>Ia(t),[t]),u=c.useMemo(()=>{const d=s?t.filter(f=>f.verb===s):t;return qg(d,a)},[t,s,a]);return r.jsxs("div",{id:e,role:"region","aria-label":"Touched files and links","data-testid":"chip-tray",className:"border-border bg-card/50 flex flex-col gap-2 rounded-md border p-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsx("div",{role:"group","aria-label":"Filter by what happened",className:"flex flex-wrap gap-1",children:l.map(d=>{const f=s===d.verb;return r.jsxs(le,{variant:"outline",size:"xs","aria-pressed":f,"data-testid":`chip-filter-${d.verb}`,onClick:()=>o(f?null:d.verb),className:W("rounded-full",f?"border-primary dark:border-primary text-foreground":"text-muted-foreground"),children:[r.jsx("span",{"aria-hidden":"true",children:ln[d.verb]}),r.jsx("span",{className:"sr-only",children:cn[d.verb]}),r.jsx("span",{className:"tabular-nums",children:d.chips.length})]},d.verb)})}),r.jsxs(Ol,{value:a,onValueChange:d=>i(d),"aria-label":"Order the roster",className:"w-auto",children:[r.jsx(Ls,{value:"grouped",children:"Grouped"}),r.jsx(Ls,{value:"chronological",children:"Chronological"})]})]}),r.jsx("div",{"data-testid":"chip-tray-roster",className:"flex max-h-60 flex-wrap items-start gap-1.5 overflow-y-auto overscroll-contain",children:u.map(d=>r.jsx($a,{chip:d,onOpen:n},d.key))})]})}const Hg=new Set;function Wg(){const[e,t]=c.useState(Hg),n=c.useCallback((o,a)=>a===!0&&!e.has(o),[e]),s=c.useCallback(o=>{t(a=>a.has(o)?a:new Set(a).add(o))},[]);return{shouldPulse:n,acknowledge:s}}function Gg(e){const t=[...e].sort((n,s)=>n.lastSeq-s.lastSeq);return{visible:t.slice(-Cr),absorbed:t.slice(0,Math.max(0,t.length-Cr))}}function Vg(e){return e.map(t=>{const n=[`${t.chips.length} ${cn[t.verb].toLowerCase()}`];return t.additions!==void 0&&n.push(`${t.additions} added`),t.deletions!==void 0&&n.push(`${t.deletions} removed`),n.join(", ")}).join("; ")}function Kg({verb:e,count:t,additions:n,deletions:s}){return r.jsxs("span",{"data-testid":`chip-summary-${e}`,className:"inline-flex items-center gap-1",children:[r.jsx("span",{"aria-hidden":"true",children:ln[e]}),r.jsx("span",{className:"sr-only",children:cn[e]}),r.jsx("span",{className:"tabular-nums",children:t}),(n!==void 0||s!==void 0)&&r.jsxs("span",{className:"tabular-nums",children:[n!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",n]}),n!==void 0&&s!==void 0&&" ",s!==void 0&&r.jsxs("span",{className:"text-destructive",children:["−",s]})]})]})}function Qg({parts:e,sessionId:t,turnActive:n=!1}){const s=Ae()??!1,o=c.useMemo(()=>wg(e),[e]),a=Wg(),i=c.useId(),l=Eg(c.useMemo(()=>Ng(t,e),[t,e])),u=c.useCallback(x=>{if(x.pattern===!0)return;const g=ue.getState();if(x.kind==="url"){const C={type:"url",url:x.fullTarget};g.openCanvasDocument(C),Ln(g,"user",C);return}if(x.kind==="file"){const C={type:"file",sourcePath:x.fullTarget};g.openCanvasDocument(C),Ln(g,"user",C)}},[]),d=c.useMemo(()=>Ia(o),[o]),f=n||o.some(x=>x.live),{visible:h,absorbed:m}=c.useMemo(()=>Gg(o),[o]);return o.length===0?null:r.jsxs("div",{"data-testid":"touch-chip-strip",className:"mt-2 flex flex-col gap-2",children:[r.jsx(de,{initial:!1,mode:"wait",children:f?r.jsxs(V.div,{"data-testid":"chip-live-row",role:"group","aria-label":"Latest activity",exit:s?{opacity:0}:{opacity:0,height:0},transition:s?Zt:Sr,className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:[m.length>0&&r.jsx(Pg,{chips:m,expanded:l.expanded,controls:i,onExpand:l.toggleExpanded}),r.jsx(de,{initial:!1,children:h.map(x=>r.jsx($a,{chip:x,onOpen:u,animated:!0,pulseUpgrade:a.shouldPulse(x.key,x.upgraded),onUpgradeSeen:a.acknowledge},x.key))})]},"live"):r.jsxs(V.div,{"data-testid":"chip-summary-line",role:"group","aria-label":Vg(d),initial:{opacity:0},animate:{opacity:1},transition:s?Zt:Sr,className:"text-muted-foreground flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs",children:[d.map((x,g)=>r.jsxs(c.Fragment,{children:[g>0&&r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx(Kg,{verb:x.verb,count:x.chips.length,additions:x.additions,deletions:x.deletions})]},x.verb)),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("button",{type:"button","aria-expanded":l.expanded,"aria-controls":i,onClick:l.toggleExpanded,className:W("hover:text-foreground rounded-sm underline underline-offset-2","focus-visible:ring-ring outline-none focus-visible:ring-2"),children:l.expanded?"hide":"show all"})]},"settled")}),l.expanded&&r.jsx(Ug,{id:i,chips:o,onOpen:u,verbFilter:l.verbFilter,onVerbFilterChange:l.setVerbFilter,order:l.order,onOrderChange:l.setOrder})]})}function Er(e){return e.type==="thinking"?!0:e.type==="tool_call"&&!e.interactiveType&&!ta(e.toolName)&&!zn(e.toolName)}function Yg({message:e}){const{sessionId:t,isStreaming:n,isLatestWidgetMessage:s,isFinalMessage:o,activeToolCallId:a,onToolRef:i,focusedOptionIndex:l,onToolDecided:u,onRetry:d,onSigninComplete:f,onChooseModel:h,inputZoneToolCallId:m,textEffect:x,runtimeLabel:g,allowsDenyReason:C}=Mp(),b=ue(S=>S.expandToolCalls),v=ue(S=>S.autoHideToolCalls),k=e.parts??[],{sent:y}=ka(t),p=c.useCallback(S=>{i==null||i(S)},[i]),j=c.useCallback(S=>{i==null||i(S)},[i]),_=Hh(k.map(S=>S.type==="tool_call"&&zn(S.toolName)?{...S,interactiveType:void 0}:S));let D=-1;for(let S=k.length-1;S>=0;S--)if(k[S].type==="text"){D=S;break}function A(S,E){if(S.type==="text")return r.jsx("div",{className:"msg-prose",children:r.jsx(xs,{content:S.text,isStreaming:n&&E===D,textEffect:x,sessionId:t,isLatestWidgetMessage:s})},`text-${E}`);if(S.type==="background_task")return r.jsx(Qp,{part:S},S.taskId);if(S.type==="error"&&S.code===jo)return r.jsx(Vh,{message:S.message},`unreadable-${E}`);if(S.type==="error")return r.jsx(an,{message:S.message,category:S.category,details:S.details,code:S.code,reason:S.reason,at:e.timestamp,onRetry:o&&S.category!==void 0?d:void 0,onSigninComplete:f,onChooseModel:h,runtimeLabel:g,sessionId:t},`error-${E}`);if(S.type==="thinking")return r.jsx(sg,{part:S,autoHide:v,index:E},`thinking-${E}`);if(S.type==="elicitation")return r.jsx(sf,{sessionId:t,interactionId:S.interactionId,serverName:S.serverName,message:S.message,mode:S.mode,url:S.url,requestedSchema:S.requestedSchema,status:S.status,action:S.action},`elicitation-${S.interactionId}`);if(S.type==="memory_recall")return r.jsx(Pp,{mode:S.mode,memories:S.memories,isStreaming:S.isStreaming??!1},`memory-recall-${E}`);if(S.type==="permission_denied")return r.jsx(zh,{toolName:S.toolName,reasonType:S.reasonType,reason:S.reason,message:S.message,agentId:S.agentId},`permission-denied-${S.toolCallId}-${E}`);if(S.type==="model_substituted")return r.jsx(Xh,{fromName:S.fromName,toName:S.toName},`model-substituted-${E}`);if(S.type==="compact_boundary")return r.jsx(Up,{trigger:S.trigger,preTokens:S.preTokens,postTokens:S.postTokens,failed:S.failed,error:S.error,requestedBy:S.requestedBy,contextPercent:S.contextPercent},`compact-boundary-${E}`);if(S.type==="capability_approval")return S.outcome==="timeout"?r.jsx(Kh,{title:Il(S.approval)},`capability-approval-${S.approval.approvalId}`):r.jsx($l,{approval:S.approval},`capability-approval-${S.approval.approvalId}`);if(S.type==="mcp_signin")return r.jsx(Yh,{part:S},`mcp-signin-${S.agentId}-${S.flowId}`);if(S.type==="image")return r.jsx(Hp,{part:S},`image-${S.attachmentId}-${E}`);if(S.type!=="tool_call")return null;const w=S;if(w.interactiveType==="approval"&&w.status==="pending"){if(w.toolCallId===m)return r.jsx(ar,{type:"approval",toolName:w.toolName,toolInput:w.input},w.toolCallId);const R=w.toolCallId===a;return r.jsx(ea,{ref:R?p:void 0,sessionId:t,toolCallId:w.toolCallId,toolName:w.toolName,input:w.input||"",timeoutMs:w.timeoutMs,approvalStartedAt:w.approvalStartedAt,approvalRemainingMs:w.approvalRemainingMs,approvalParked:w.approvalParked,approvalTitle:w.approvalTitle,approvalDisplayName:w.approvalDisplayName,approvalDescription:w.approvalDescription,approvalBlockedPath:w.approvalBlockedPath,approvalDecisionReason:w.approvalDecisionReason,approvalHasSuggestions:w.approvalHasSuggestions,approvalAlwaysAllowScope:w.approvalAlwaysAllowScope,isActive:R,onDecided:u?()=>u(w.toolCallId):void 0,allowsDenyReason:C},w.toolCallId)}const M=_.get(E);if(M){if(M.leadIndex!==E)return null;const R=M.indices.map(F=>k[F]).filter(F=>F.type==="tool_call");return r.jsx(ff,{outcome:M.outcome,reasonGiven:M.reasonGiven,members:R,lead:w,children:R.map(F=>r.jsx(Tn,{part:F,sessionId:t,autoHide:v,expandToolCalls:b},F.toolCallId))},`approval-receipt-${w.toolCallId}`)}if(w.interactiveType==="question"){if(w.toolCallId===m)return r.jsx(ar,{type:"question",toolName:w.toolName,toolInput:w.input},w.toolCallId);const R=w.toolCallId===a;return r.jsx(_o,{ref:R?j:void 0,sessionId:t,toolCallId:w.toolCallId,questions:w.questions??[],answers:w.answers??(Wh(w)?{}:void 0),outcome:Gh(w),result:w.result,isActive:R,focusedOptionIndex:R?l:-1,onDecided:u?F=>u(w.toolCallId,F):void 0},w.toolCallId)}return zn(w.toolName)?r.jsx(jp,{part:w,sent:y,...e.timestamp?{at:e.timestamp}:{},...t?{sessionId:t}:{}},w.toolCallId):ta(w.toolName)?r.jsx(hf,{sessionId:t,input:w.input,result:w.result,fallback:r.jsx(Tn,{part:w,sessionId:t,autoHide:v,expandToolCalls:b})},w.toolCallId):r.jsx(Tn,{part:w,sessionId:t,autoHide:v,expandToolCalls:b},w.toolCallId)}const N=[];let T=[];for(let S=0;S<k.length;S++){const E=k[S];Er(E)?T.push(S):(T.length>0&&(N.push(T.length===1?{type:"single",index:T[0]}:{type:"run",indices:[...T]}),T=[]),N.push({type:"single",index:S}))}return T.length>0&&N.push(T.length===1?{type:"single",index:T[0]}:{type:"run",indices:[...T]}),r.jsxs(r.Fragment,{children:[N.map(S=>{if(S.type==="single"){const w=k[S.index];return Er(w)?r.jsx("div",{className:"my-3",children:A(w,S.index)},`spacer-${S.index}`):A(w,S.index)}const E=S.indices.map(w=>A(k[w],w));return r.jsx("div",{className:"my-3",children:r.jsx(og,{children:E})},`run-${S.indices[0]}`)}),r.jsx(Qg,{parts:k,sessionId:t,turnActive:e._streaming===!0})]})}const Xg=/^Please read the following uploaded file\(s\):\n((?:- .+\n)+)\n?/,Jg=/^[a-f0-9]{8}-/,Zg=new Set(["png","jpg","jpeg","gif","webp","svg"]);function ex(e){const t=e.match(Xg);if(!t)return{files:[],textContent:e};const s=t[1].split(`
50
- `).filter(a=>a.startsWith("- ")).map(a=>{var f;const i=a.slice(2).trim(),u=(i.split("/").pop()??i).replace(Jg,""),d=((f=u.split(".").pop())==null?void 0:f.toLowerCase())??"";return{path:i,displayName:u,isImage:Zg.has(d)}}),o=e.slice(t[0].length).trim();return{files:s,textContent:o}}function tx(e){var n;switch(((n=e.split(".").pop())==null?void 0:n.toLowerCase())??""){case"txt":case"md":case"log":return bd;case"ts":case"tsx":case"js":case"jsx":case"json":case"py":case"rs":case"go":return gd;case"csv":case"xls":case"xlsx":return Ed;case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":return Nd;default:return Bo}}function nx({files:e}){const t=ue(n=>n.selectedCwd);return e.length===0?null:r.jsx("div",{className:"flex flex-wrap gap-1.5 pb-1.5",children:e.map(n=>{const s=n.path.split("/").pop()??n.path;if(n.isImage){const a=`/api/uploads/${encodeURIComponent(s)}?cwd=${encodeURIComponent(t??"")}`;return r.jsx(V.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},children:r.jsx(ho,{image:{src:a,alt:n.displayName,downloadName:n.displayName},className:"block rounded-lg",children:r.jsx("img",{src:a,alt:n.displayName,loading:"lazy",className:"border-border/50 max-h-[120px] max-w-[200px] rounded-lg border object-contain"})})},n.path)}const o=tx(n.displayName);return r.jsxs(V.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[r.jsx(o,{className:"text-muted-foreground size-3 shrink-0"}),r.jsx("span",{className:"max-w-40 truncate",children:n.displayName})]},n.path)})})}function sx({message:e}){var i;const t=(i=Op())==null?void 0:i.sessionId,[n,s]=c.useState(!1),o=c.useMemo(()=>ex(e.content),[e.content]),a=c.useMemo(()=>Ef(e.content),[e.content]);if(a)return r.jsx(wf,{action:a});if(e.chatMessages&&e.chatMessages.length>0)return r.jsx(bp,{stamps:e.chatMessages,...t?{sessionId:t}:{}});if(e.messageType==="command")return r.jsx("div",{className:"text-msg-command-fg font-mono text-sm break-words",children:e.content});if(e.messageType==="local_command_output")return r.jsx(Ea,{content:e.content,toolName:""});if(e.messageType==="compaction"){const l=Bp(e.compactMetadata),u=e.content.trim(),d=r.jsx("div",{className:"bg-border/40 h-px flex-1"});return u.length===0?r.jsxs("div",{"data-testid":"compaction-row",className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[d,r.jsx("span",{children:l}),d]}):r.jsxs("div",{className:"w-full","data-testid":"compaction-row",children:[r.jsxs("button",{onClick:()=>s(!n),className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[d,r.jsx(ds,{className:W("size-3 transition-transform duration-200",n&&"rotate-90")}),r.jsx("span",{children:l}),d]}),n&&r.jsx("div",{className:"text-msg-compaction-fg mt-2 text-xs whitespace-pre-wrap",children:e.content})]})}return r.jsxs("div",{children:[o.files.length>0&&r.jsx(nx,{files:o.files}),o.textContent&&r.jsx("div",{className:"break-words whitespace-pre-wrap",children:o.textContent})]})}function rx({tasks:e,isCollapsed:t,onToggleCollapse:n}){const s=e.length,o=e.filter(l=>l.status==="completed").length,a=o===s&&s>0,i=s>0?o/s*100:0;return r.jsxs("button",{onClick:n,className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-2 text-xs",children:[t?r.jsx(ds,{className:"size-(--size-icon-xs) shrink-0"}):r.jsx(At,{className:"size-(--size-icon-xs) shrink-0"}),r.jsx("div",{className:"bg-muted h-0.5 flex-1 overflow-hidden rounded-full",children:r.jsx("div",{"data-slot":"progress-fill",className:`h-full rounded-full transition-[width,background-color] duration-300 ease-out ${a?"bg-green-500":"bg-blue-500"}`,style:{width:`${i}%`}})}),r.jsxs("span",{className:"shrink-0 tabular-nums",children:[o,"/",s," ",s===1?"task":"tasks"]})]})}function ox({activeForm:e,isCollapsed:t}){return r.jsx(de,{children:e&&!t&&r.jsxs(V.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:"mb-1 flex items-center gap-2 text-xs text-blue-400",children:[r.jsx(Le,{size:"xs",className:"shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})})}const ax={in_progress:"",pending:"waiting ",completed:"done "};function Dr({tasks:e,onScrollToTask:t}){return r.jsx(r.Fragment,{children:e.map((n,s)=>r.jsxs("span",{children:[r.jsx("button",{onClick:o=>{o.stopPropagation(),t(n.id)},className:"hover:text-foreground underline decoration-dotted",children:n.subject}),s<e.length-1&&", "]},n.id))})}function ix({task:e,taskMap:t,statusSince:n,onScrollToTask:s}){var d,f;const o=qo(n),a=ax[e.status]??"",i=((d=e.blockedBy)==null?void 0:d.map(h=>t.get(h)).filter(h=>h!=null))??[],l=((f=e.blocks)==null?void 0:f.map(h=>t.get(h)).filter(h=>h!=null))??[],u=[];return n!==null&&u.push(r.jsxs("span",{children:[a,o.formatted]},"time")),e.owner&&u.push(r.jsx("span",{children:e.owner},"owner")),i.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["← ",r.jsx(Dr,{tasks:i,onScrollToTask:s})]},"blocked-by")),l.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["→ ",r.jsx(Dr,{tasks:l,onScrollToTask:s})]},"blocks")),r.jsxs(V.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:"mt-0.5 ml-6 space-y-1",children:[e.description&&r.jsx("p",{className:"text-muted-foreground text-xs whitespace-pre-wrap",children:e.description}),u.length>0&&r.jsx("div",{className:"text-muted-foreground text-2xs flex flex-wrap items-center gap-1",children:u.map((h,m)=>r.jsxs("span",{className:"flex items-center gap-1",children:[m>0&&r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h]},m))})]})}const Tr={in_progress:r.jsx(Le,{size:"xs",className:"text-status-info shrink-0"}),pending:r.jsx(Pl,{className:"text-muted-foreground size-(--size-icon-xs) shrink-0"}),completed:r.jsx(So,{className:"text-status-success size-(--size-icon-xs) shrink-0"})};function lx({task:e,isBlocked:t,isExpanded:n,onToggleExpand:s,onHover:o,isHighlightedAsDep:a,isHighlightedAsDependent:i,taskMap:l,statusSince:u,isCelebrating:d,onCelebrationComplete:f,onScrollToTask:h}){const m=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),s())};return r.jsxs(V.li,{"data-task-id":e.id,children:[r.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,"data-task-id":e.id,onClick:s,onKeyDown:m,onMouseEnter:()=>o(e.id),onMouseLeave:()=>o(null),className:W("hover:bg-muted/40 focus-visible:bg-muted/40 relative flex items-center gap-2 rounded py-0.5 text-xs transition-colors",e.status==="completed"&&"text-muted-foreground/50 line-through",e.status==="in_progress"&&"text-foreground font-medium",e.status==="pending"&&!t&&"text-muted-foreground",e.status==="pending"&&t&&"text-muted-foreground/50",a&&"border-l-2 border-blue-400 pl-1.5",i&&"border-l-2 border-amber-400 pl-1.5",!a&&!i&&"border-l-2 border-transparent pl-1.5"),children:[d&&r.jsx(V.div,{"aria-hidden":"true",className:"absolute inset-0 rounded",initial:{backgroundPosition:"-200% 0"},animate:{backgroundPosition:"200% 0"},transition:{duration:.4,ease:"easeOut"},style:{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,215,0,0.2) 50%, transparent 100%)",backgroundSize:"200% 100%"}}),d?r.jsx(V.span,{initial:{scale:1},animate:{scale:[1,1.4,1]},transition:{type:"spring",stiffness:400,damping:10},onAnimationComplete:()=>f==null?void 0:f(),children:Tr[e.status]}):Tr[e.status],r.jsx("span",{className:"truncate",children:e.subject})]}),r.jsx(de,{children:n&&r.jsx(ix,{task:e,taskMap:l,statusSince:u,onScrollToTask:h})})]})}function cx(e,t){var n;return(n=e.blockedBy)!=null&&n.length?e.blockedBy.some(s=>{const o=t.get(s);return o&&o.status!=="completed"}):!1}const ux=10,dx="max-h-[30svh] sm:max-h-[40svh]";function fx({tasks:e,taskMap:t,activeForm:n,isCollapsed:s,onToggleCollapse:o,celebratingTaskId:a,onCelebrationComplete:i,statusTimestamps:l}){const[u,d]=c.useState(null),[f,h]=c.useState(null),m=c.useCallback(b=>{d(v=>v===b?null:b)},[]),x=c.useCallback(b=>{const v=document.querySelector(`[data-task-id="${b}"]`);v&&(v.scrollIntoView({behavior:"smooth",block:"nearest"}),v.classList.add("bg-blue-500/10"),setTimeout(()=>v.classList.remove("bg-blue-500/10"),1e3))},[]);if(e.length===0)return null;const g=e.slice(0,ux),C=f?t.get(f):null;return r.jsxs("div",{className:"border-t px-4 py-2",children:[r.jsx(ox,{activeForm:n,isCollapsed:s}),r.jsx(rx,{tasks:e,isCollapsed:s,onToggleCollapse:o}),r.jsx(de,{children:!s&&r.jsx(V.ul,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:W("mt-1 space-y-0.5 overflow-y-auto",dx),children:g.map(b=>{var _,D;const v=b.id===a&&b.status==="completed",k=cx(b,t),y=l.get(b.id),p=((_=C==null?void 0:C.blockedBy)==null?void 0:_.includes(b.id))??!1,j=((D=C==null?void 0:C.blocks)==null?void 0:D.includes(b.id))??!1;return r.jsx(lx,{task:b,isBlocked:k,isExpanded:u===b.id,onToggleExpand:()=>m(b.id),onHover:h,isHighlightedAsDep:p,isHighlightedAsDependent:j,taskMap:t,statusSince:(y==null?void 0:y.since)??null,isCelebrating:v,onCelebrationComplete:i,onScrollToTask:x},b.id)})})})]})}function mx({color:e}){const t=[{bx:"-8px",by:"-10px",delay:"0s"},{bx:"8px",by:"-8px",delay:"0.03s"},{bx:"-6px",by:"6px",delay:"0.06s"},{bx:"10px",by:"4px",delay:"0.09s"},{bx:"0px",by:"-12px",delay:"0.04s"},{bx:"-10px",by:"0px",delay:"0.07s"},{bx:"6px",by:"10px",delay:"0.05s"},{bx:"-4px",by:"-6px",delay:"0.08s"}];return r.jsx("div",{className:"pointer-events-none absolute inset-0",children:t.map((n,s)=>r.jsx("span",{className:"absolute top-1/2 left-1/2 size-[3px] rounded-full",style:{backgroundColor:e,"--bx":n.bx,"--by":n.by,animation:`burst-particle 0.5s ease-out ${n.delay} forwards`}},s))})}const px=350;function hx({status:e,color:t}){return r.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24","data-status":e,children:[r.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:t,strokeWidth:"1.5",opacity:"0.3"}),e==="error"&&r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"8",y1:"9",x2:"14",y2:"15",stroke:t,strokeWidth:"2",strokeLinecap:"round"}),r.jsx("line",{x1:"14",y1:"9",x2:"8",y2:"15",stroke:t,strokeWidth:"2",strokeLinecap:"round"})]}),e==="untracked"&&r.jsx("line",{x1:"8",y1:"12",x2:"14",y2:"12",stroke:t,strokeWidth:"2",strokeLinecap:"round",opacity:"0.5"}),e!=="error"&&e!=="untracked"&&r.jsx("polyline",{points:"7,12 10,15 15,9",fill:"none",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function gx({agent:e,index:t}){const n=c.useMemo(()=>({animationDelay:`${t*.09}s`}),[t]),[s,o]=c.useState(e.status==="running"?"running":"done"),a=c.useRef(e.status),i=c.useRef(null);return c.useEffect(()=>{const l=a.current;if(a.current=e.status,l==="running"&&e.status!=="running"){o("celebrating"),i.current=setTimeout(()=>o("done"),px);return}l!=="running"&&e.status==="running"&&(i.current&&clearTimeout(i.current),i.current=null,o("running"))},[e.status]),c.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),s==="done"?r.jsx("div",{className:"relative inline-flex",children:r.jsx(hx,{status:e.status,color:e.color})}):r.jsxs("div",{className:"group relative inline-flex",children:[r.jsx("svg",{className:"h-6 w-[22px] shrink-0",style:{"--c":e.color},viewBox:"0 0 22 24","aria-label":e.description,children:r.jsxs("g",{className:"r-all",style:n,children:[r.jsx("circle",{cx:"11",cy:"4.5",r:"2.8",fill:"var(--c)"}),r.jsx("circle",{cx:"12.3",cy:"3.7",r:"0.6",fill:"hsl(0 0% 100% / 0.7)"}),r.jsx("ellipse",{cx:"11",cy:"10.5",rx:"2.5",ry:"3.5",fill:"var(--c)"}),r.jsxs("g",{className:"r-rua",style:n,children:[r.jsx("line",{x1:"12",y1:"9",x2:"14",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-rfa",style:n,children:r.jsx("line",{x1:"14",y1:"11",x2:"14.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-lua",style:n,children:[r.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-lfa",style:n,children:r.jsx("line",{x1:"8",y1:"11",x2:"7.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-rt",style:n,children:[r.jsx("line",{x1:"11",y1:"14",x2:"13",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-rs",style:n,children:r.jsx("line",{x1:"13",y1:"17",x2:"13.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-lt",style:n,children:[r.jsx("line",{x1:"11",y1:"14",x2:"9",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-ls",style:n,children:r.jsx("line",{x1:"9",y1:"17",x2:"8.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]})]})}),s==="celebrating"&&r.jsx(mx,{color:e.color}),s==="running"&&r.jsxs("div",{"data-testid":"agent-runner-tooltip",className:W("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2 hidden","-translate-x-1/2 translate-y-1 opacity-0 transition-[opacity,translate] duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-2xs shadow-lg md:block"),children:[r.jsxs("div",{className:"mb-0.5 flex items-center gap-1.5 font-semibold",children:[r.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.description]}),r.jsxs("div",{className:"text-muted-foreground text-3xs font-mono",children:[e.toolUses??0," tool calls · ",Math.round((e.durationMs??0)/1e3),"s"]}),e.lastToolName&&r.jsxs("div",{className:"text-muted-foreground/60 text-3xs mt-0.5 font-mono",children:["Last: ",e.lastToolName]}),r.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}function xx({bashTasks:e}){const t=Ae(),n=e.filter(o=>o.taskType==="bash"),s=n.length;return s===0?null:r.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[r.jsx(de,{mode:"popLayout",children:n.map(o=>r.jsxs(V.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[o.status==="running"&&!t&&r.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:o.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),r.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:o.color}})]},o.taskId))}),r.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const bx=3e3;function yx({taskType:e,onConfirm:t}){const[n,s]=c.useState(!1),o=c.useRef(null);c.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),c.useEffect(()=>{if(n)return o.current=setTimeout(()=>{s(!1)},bx),()=>{o.current&&clearTimeout(o.current)}},[n]);const a=c.useCallback(()=>{if(e==="bash"){t();return}n?(o.current&&clearTimeout(o.current),s(!1),t()):s(!0)},[e,n,t]),i=c.useCallback(l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a())},[a]);return r.jsx("button",{onClick:a,onKeyDown:i,className:W("flex shrink-0 items-center justify-center rounded transition-colors duration-150","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1",n?"bg-destructive/5 text-destructive hover:bg-destructive/10 text-3xs px-1.5 py-0.5 font-medium":"text-muted-foreground/40 hover:text-destructive size-4"),"aria-label":n?"Press again to stop task":"Stop task",tabIndex:0,children:n?"Stop?":r.jsx(Ue,{className:"size-3"})})}function Ar({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,o=e.status==="running";return r.jsxs("div",{className:W("flex items-center gap-2 rounded-md px-2 py-1 text-xs",o?"bg-muted":"bg-muted/50 opacity-60"),children:[r.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),r.jsx("span",{className:"text-muted-foreground/60 text-3xs shrink-0 tracking-wider uppercase",children:e.taskType}),r.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate",children:n}),e.taskType==="agent"&&e.toolUses!==void 0&&e.toolUses>0&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs shrink-0 font-mono",children:[e.toolUses," tools"]}),e.taskType==="agent"&&e.lastToolName&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs hidden max-w-24 shrink-0 truncate font-mono md:inline",children:["Last: ",e.lastToolName]}),s>0&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs shrink-0 font-mono",children:[s,"s"]}),o&&r.jsx(yx,{taskType:e.taskType,onConfirm:t})]})}function vx({tasks:e,ambientTasks:t=[],onStopTask:n}){return r.jsx(V.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:"border-border overflow-hidden border-t px-2 py-1.5",children:r.jsxs("div",{className:"flex flex-col gap-1",children:[e.map(s=>r.jsx(Ar,{task:s,onStop:()=>n(s.taskId)},s.taskId)),t.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-muted-foreground/60 text-3xs mt-1 px-2",children:[t.length," housekeeping task",t.length!==1?"s":""," the agent runs for itself"]}),t.map(s=>r.jsx(Ar,{task:s,onStop:()=>n(s.taskId)},s.taskId))]})]})})}const Yn=4;function kx(e){return e==="stopped"?"complete":e}const Cx="relative after:absolute after:-inset-x-1 after:-inset-y-2.5 md:after:hidden",Pa=[.16,1,.3,1],Sx={width:{duration:.4,ease:Pa},opacity:{duration:.25}};function jx({tasks:e,onStopTask:t}){const[n,s]=c.useState(!1),o=Ae(),{shown:a,ambient:i}=Yc(e),l=a.filter(b=>b.taskType==="agent"),u=a.filter(b=>b.taskType==="bash"),d=a.length,f=l.slice(0,Yn),h=l.length-Yn,m=l.reduce((b,v)=>b+(v.toolUses??0),0),x=Math.max(0,...a.map(b=>Math.round((b.durationMs??0)/1e3))),g=o?{duration:0}:{duration:.35,ease:Pa},C=d>0;return r.jsx(de,{children:(d>0||i.length>0)&&r.jsxs(V.div,{...C?{role:"status","aria-live":"polite","aria-label":`${d} background task${d!==1?"s":""} running`}:{role:"group","aria-label":"Background tasks"},initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:g,className:"border-border bg-card overflow-hidden rounded-lg border",children:[r.jsxs("div",{className:"flex min-h-9 items-center gap-2 px-2 py-1.5",children:[l.length>0&&r.jsx(_x,{visibleAgents:f,overflowAgentCount:h,allAgentTasks:l}),l.length>0&&u.length>0&&r.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),u.length>0&&r.jsx(xx,{bashTasks:u}),d>0&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[r.jsx("strong",{className:"text-foreground font-semibold",children:d})," task",d!==1?"s":""," running"]}),r.jsxs("span",{className:"text-muted-foreground/60 text-2xs ml-auto font-mono whitespace-nowrap",children:[m>0&&r.jsxs(r.Fragment,{children:[m," tools · "]}),x,"s"]})]}),r.jsxs("button",{type:"button",onClick:()=>s(b=>!b),className:W("text-muted-foreground hover:text-foreground flex shrink-0 items-center gap-1 transition-colors duration-150",d>0?"ml-1":"ml-auto",Cx),"aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[d>0&&r.jsx("span",{className:"text-3xs tabular-nums",children:d}),r.jsx(At,{className:W("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),r.jsx(de,{children:n&&r.jsx(vx,{tasks:a,ambientTasks:i,onStopTask:t})})]},"background-task-bar")})}function _x({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(de,{mode:"popLayout",children:e.map((s,o)=>r.jsx(V.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:Sx,className:"shrink-0",children:r.jsx(gx,{agent:{taskId:s.taskId,description:s.description??"",status:kx(s.status),color:s.color,toolUses:s.toolUses,lastToolName:s.lastToolName,durationMs:s.durationMs,summary:s.summary},index:o})},s.taskId))}),t>0&&r.jsx(wx,{count:t,overflowTasks:n.slice(Yn)})]})}function wx({count:e,overflowTasks:t}){return r.jsxs("div",{className:"group relative",children:[r.jsxs("div",{className:"text-muted-foreground bg-muted text-3xs flex size-6 shrink-0 items-center justify-center rounded-full font-semibold","aria-label":`${e} more helper${e===1?"":"s"} running`,children:["+",e]}),r.jsxs("div",{"data-testid":"overflow-badge-tooltip",className:W("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2 hidden","-translate-x-1/2 translate-y-1 opacity-0 transition-[opacity,translate] duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-2xs shadow-lg md:block"),children:[t.map(n=>r.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[r.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:n.color}}),r.jsx("span",{className:"text-3xs",children:n.description})]},n.taskId)),r.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}const Fn="after:absolute after:-inset-1 md:after:hidden";function Nx({queue:e,editingId:t,onEdit:n,onRemove:s,onSend:o,onMoveUp:a,statusNote:i,onSwitchNow:l}){return e.length===0?null:r.jsxs(V.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:He,className:"mb-1.5 overflow-hidden",children:[r.jsxs("div",{className:"text-muted-foreground mb-1 flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:"font-medium",children:["Queued (",e.length,")"]}),r.jsxs("span",{className:"truncate",children:["· ",i]})]}),r.jsx("div",{className:"space-y-0.5",children:r.jsx(de,{mode:"popLayout",children:e.map((u,d)=>r.jsx(V.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,scale:.95,transition:{duration:.15}},layout:!0,children:r.jsxs("div",{className:W("group flex w-full items-center gap-2 rounded-md border-l-2 border-l-transparent pr-2 transition-colors md:gap-1",t===u.id?"border-l-primary bg-muted":"hover:bg-muted/50"),children:[r.jsxs("button",{type:"button",onClick:()=>n(u.id),"aria-current":t===u.id?!0:void 0,className:"focus-ring flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-3 text-left",children:[r.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs font-medium",children:[d+1,"."]}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"text-muted-foreground line-clamp-1 text-sm",children:u.content}),u.notice!==null&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.notice}),u.waiting!==void 0&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.waiting.line})]}),!u.mine&&r.jsxs("span",{className:"text-muted-foreground/60 flex shrink-0 items-center",title:"Queued from another window",children:[r.jsx(qn,{className:"size-3","aria-hidden":"true"}),r.jsx("span",{className:"sr-only",children:"Queued from another window"})]})]}),u.waiting!==void 0&&l!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:l,title:u.waiting.switchHint,"aria-describedby":`switch-now-${u.id}`,className:"focus-ring text-muted-foreground hover:text-foreground shrink-0 rounded-sm px-1.5 py-1 text-xs font-medium transition-colors",children:"Switch now"}),r.jsx("span",{id:`switch-now-${u.id}`,className:"sr-only",children:u.waiting.switchHint})]}),d>0&&r.jsx("button",{type:"button",onClick:()=>a(u.id),className:W("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100",Fn),"aria-label":`Move queued message ${d+1} earlier`,children:r.jsx(Ll,{className:"size-3"})}),d>0&&r.jsx("button",{type:"button",onClick:()=>o(u.id),"aria-label":`Send queued message ${d+1} next`,className:W("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm transition-colors",Fn),children:r.jsx(Yu,{className:"size-3"})}),r.jsx("button",{type:"button",onClick:()=>s(u.id),className:W("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100",Fn),"aria-label":`Remove queued message ${d+1}`,children:r.jsx(Ue,{className:"size-3"})})]})},u.id))})})]})}function Ex({open:e,onOpenChange:t,queuedCount:n,onConfirm:s}){const o=n===1?"message":"messages";return r.jsx(zl,{open:e,onOpenChange:t,children:r.jsxs(Bl,{children:[r.jsxs(ql,{children:[r.jsxs(Ul,{children:["Stop, and put ",n," queued ",o," back?"]}),r.jsxs(Hl,{children:["The agent stops. Your ",o," ",n===1?"goes":"go"," back to the composer."]})]}),r.jsxs(Wl,{children:[r.jsx(Gl,{children:"Keep going"}),r.jsx(Vl,{onClick:s,children:"Stop"})]})]})})}const Dx={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},Tx={duration:.3,ease:"easeInOut"};function Ax({text:e,animationKey:t}){return r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-start overflow-hidden py-0.5",children:r.jsx(de,{mode:"wait",children:r.jsx(V.span,{variants:Dx,initial:"initial",animate:"animate",exit:"exit",transition:Tx,className:"text-muted-foreground truncate text-sm",children:e},t)})})}function Fx(e){const t=Se();return Je({queryKey:["workspace-for-session",e??null],queryFn:()=>t.resolveWorkspace(e),enabled:!!e}).data??null}async function La(e,t,n){try{return await e.runCommandIntent(t,"compact",n),!0}catch(s){const o=s.code==="SESSION_LOCKED";return Te.error(o?"Your agent is busy. Try again in a moment.":"Couldn’t compact the chat."),!1}}const Xn=as(e=>({open:!1,setOpen:t=>e({open:t}),reveal:()=>e({open:!0})})),Rx=200,Jn=[{name:"rename",description:"Rename the current chat",argHint:"<new title>",run:(e,t)=>{const n=e.replace(/\s+/g," ").trim().slice(0,Rx).trim();return n?t.sessionId?(t.renameSession(n),!0):(t.notify("No open chat to rename","error"),!1):(t.notify("Usage: /rename <new title>","error"),!1)}},{name:"clear",description:"Start a new chat here",run:(e,t)=>(t.startFreshSession(t.sessionId),!0)},{name:"context",description:"Show context usage and cost",run:(e,t)=>(t.focusUsageSurface(),!0)}],Mx=/^\/(\S+)(?:\s+([\s\S]*))?$/;function za(e){const t=Mx.exec(e);if(!t)return null;const n=t[1],s=(t[2]??"").trim(),o=ms(n);if(o&&o.fulfillment==="client-native"){const i=Jn.find(l=>l.name===o.id);if(i)return{command:i,args:s}}const a=Jn.find(i=>i.name===n.toLowerCase());return a?{command:a,args:s}:null}const Fr=Jn.map(e=>({command:e.name,fullCommand:`/${e.name}`,description:e.description,argumentHint:e.argHint}));function Ba(e){const t=/^\/(\S+)([\s\S]*)$/.exec(e.trim());return t?{token:t[1],rest:t[2].trim()}:null}function Ox(e){const t=Ba(e);return t?ms(t.token)?!0:za(e.trim())!==null:!1}function Ix(e,t,n={}){const{mutateAsync:s}=Kl(e),o=Se(),{startFreshSession:a,compact:i}=n,[l,u]=c.useState(0),d=c.useCallback(h=>{u(x=>x+1);const m=()=>u(x=>Math.max(0,x-1));h.then(m,m)},[]);return{tryRun:c.useCallback(h=>{const m=Ba(h),x=m?ms(m.token):null;if(m&&(x==null?void 0:x.fulfillment)==="runtime"&&i){if(!i.supported)return Te.error(`Compact isn’t available on ${i.runtimeLabel||"this agent"}`),{handled:!0,ran:!1};if(!t)return Te.error("No open chat to compact"),{handled:!0,ran:!1};const v=La(o,t,m.rest||void 0);return d(v),{handled:!0,ran:!0,confirmed:v}}const g=za(h);if(!g)return{handled:!1};let C;return{handled:!0,ran:g.command.run(g.args,{sessionId:t,renameSession:v=>{t&&(C=s({sessionId:t,title:v}).then(()=>(Te.success(`Renamed chat to “${v}”`),!0),()=>!1),d(C))},notify:(v,k)=>k==="error"?Te.error(v):Te.success(v),startFreshSession:v=>a==null?void 0:a(v),focusUsageSurface:()=>Xn.getState().reveal()}),...C?{confirmed:C}:{}}},[s,o,t,a,i,d]),commandPending:l>0}}function qa(e,t){return{supported:(e==null?void 0:e.compact.supported)!==!1,runtimeLabel:t}}function Rr(e){const t=e.trim().toLowerCase();return t.startsWith("/")?t:`/${t}`}function $x(e){return Yl.map(t=>{var s,o;const n=t.fulfillment==="runtime"&&((o=(s=e==null?void 0:e.commandIntents)==null?void 0:s[t.id])==null?void 0:o.supported)===!1;return{command:t.id,fullCommand:t.canonical,description:t.description,argumentHint:t.argumentHint,aliases:[...t.aliases],...n?{disabled:!0,disabledReason:`Not available on ${e.runtimeLabel}`}:{}}})}function Px(e,t){const n=Ql(),s=$x(t),o=Fr.filter(l=>!(l.command!==void 0&&n.has(`/${l.command}`))),a=new Set(Fr.map(l=>l.command)),i=e.filter(l=>{if(l.command!==void 0&&a.has(l.command))return!1;const u=[l.fullCommand,...l.aliases??[]].map(Rr);return l.command!==void 0&&u.push(Rr(l.command)),!u.some(d=>n.has(d))});return[...s,...o,...i]}const Lx=3e4;function zx({percent:e,compactSupported:t,isStreaming:n}){return!(e===null||e<Xc||!t||n)}function Bx({sessionId:e,percent:t,compactSupported:n,isStreaming:s}){const o=Se(),[a,i]=c.useState(!1),l=c.useRef(!1),u=c.useRef(null),d=c.useCallback(()=>{l.current=!1,i(!1),u.current!==null&&(clearTimeout(u.current),u.current=null)},[]);c.useEffect(()=>{s&&l.current&&d()},[s,d]),c.useEffect(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);const f=c.useCallback(()=>{l.current||!e||(l.current=!0,i(!0),u.current=setTimeout(()=>{u.current=null,l.current=!1,i(!1)},Lx),La(o,e).then(h=>{h||d()}))},[e,o,d]);return{visible:zx({percent:t,compactSupported:n,isStreaming:s}),percent:t??0,pending:a,onCompact:f}}function qx({children:e,onSwitchAgent:t,onViewProfile:n,onNewSession:s}){return r.jsxs(Xl,{children:[r.jsx(Jl,{className:"min-w-0",children:e}),r.jsxs(Zl,{className:"w-48",children:[r.jsxs(hn,{onClick:t,children:[r.jsx(ec,{className:"mr-2 size-4"}),"Switch agent"]}),r.jsx(zs,{}),r.jsxs(hn,{onClick:n,children:[r.jsx(tc,{className:"mr-2 size-4"}),"View profile"]}),r.jsx(zs,{}),r.jsxs(hn,{onClick:s,children:[r.jsx(go,{className:"mr-2 size-4"}),"New chat"]})]})]})}function Ux({agentName:e,agentColor:t,agentEmoji:n,agentPath:s,nameHidden:o}){const a=nc(s),{open:i}=sc(),l=c.useCallback(()=>{s&&rc.getState().openProfileDocked(s)},[s]),u=c.useCallback(()=>{if(a===void 0)return l();i(a)},[a,i,l]),d=c.useCallback(()=>{ue.getState().openGlobalPaletteWithSearch("@")},[]),f=vo(),h=c.useCallback(()=>{f(s??void 0)},[f,s]);return!e||!t||!n?null:r.jsx("span",{className:"inline-flex min-w-0 items-center",children:s?r.jsx(qx,{onSwitchAgent:d,onViewProfile:u,onNewSession:h,children:r.jsx(Bs,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,onClick:u,className:"max-w-full"})}):r.jsx(Bs,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,className:"max-w-full"})})}function Hx({sessionId:e,account:t}){const[n,s]=c.useState(!1),[o,a]=c.useState(!1),i=c.useRef(null);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:i,className:"contents",children:r.jsx(oc,{sessionId:e,account:t,open:n,onOpenChange:s,onContinue:()=>{s(!1),a(!0)}})}),r.jsx(ia,{open:o,onOpenChange:a,sessionId:e,account:t,onCloseAutoFocus:l=>{var d;const u=(d=i.current)==null?void 0:d.querySelector("button");u&&(l.preventDefault(),u.focus())}})]})}function Wx({ctx:e,items:t}){return r.jsx("span",{className:"inline-flex min-w-0 items-center gap-2",children:t.map((n,s)=>{const o=n.component;return r.jsxs(c.Fragment,{children:[s>0&&r.jsx("span",{className:"text-muted-foreground/30 shrink-0","aria-hidden":"true",children:"·"}),r.jsx("span",{role:"group","aria-label":n.label,"data-testid":`extension-status-item-${n.id}`,className:"inline-flex min-w-0 items-center",children:r.jsx(wo,{fallback:null,onError:a=>Ua(n,a),children:r.jsx(o,{...e})})})]},n.id)})})}function Ua(e,t){console.warn(`[extensions] ${e.extensionId}'s status-bar item "${e.id}" failed to draw and is hidden.`,t)}function Gx({ctx:e,items:t}){return r.jsx(r.Fragment,{children:t.map(n=>{const s=n.component;return r.jsxs("div",{role:"group","aria-label":n.label,"data-testid":`session-row-extension-${n.id}`,className:"flex items-center gap-2 px-1 py-1 text-sm",children:[r.jsx("span",{className:"shrink-0",children:n.label}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("span",{className:"text-muted-foreground inline-flex min-w-0 items-center text-xs",children:r.jsx(wo,{fallback:null,onError:o=>Ua(n,o),children:r.jsx(s,{...e})})})]},n.id)})})}function Vx(e){const{costUsd:t,costBasis:n,...s}=e;return s}function Kx(e){var f;const{sessionId:t,agent:n,status:s,runtimeChip:o,onUpdateSession:a}=e,i={},l=e.density!=="full";n.name&&n.color&&n.emoji&&(i.agent=r.jsx(Ux,{agentName:n.name,agentColor:n.color,agentEmoji:n.emoji,agentPath:n.path,nameHidden:e.density==="avatar"})),s.cwd&&(i.cwd=r.jsx(Jc,{cwd:s.cwd})),e.gitStatus&&(i.git=r.jsx(iu,{data:e.gitStatus,workspace:e.workspace,compact:l})),o.runtime!==null&&(i.runtime=r.jsx(Zc,{runtime:o.runtime,model:o.model,onChangeRuntime:o.onChangeRuntime,canSelect:o.canSelect,account:o.account,compact:!0}));const u=No(e.account);u!==null&&(i.account=r.jsx(Hx,{sessionId:t,account:e.account})),e.extensions.items.length>0&&(i.extensions=r.jsx(Wx,{ctx:e.extensions.ctx,items:e.extensions.items})),i.model=r.jsx(eu,{model:s.model,onChangeModel:h=>a({model:h}),effort:s.effort,onChangeEffort:h=>a({effort:h??void 0}),fastMode:s.fastMode,onChangeFastMode:h=>a({fastMode:h}),disabled:!t,sessionId:t||void 0,runtime:o.runtime,onCredits:e.account.onCredits,compact:l}),(f=e.plan)!=null&&f.active||(i.permission=r.jsx(tu,{mode:s.permissionMode,onChangeMode:e.onChangeMode,disabled:!t,pending:!s.permissionModeKnown,runtime:o.runtime,modelSupportsAutoMode:e.modelSupportsAutoMode,compact:l,makeDefault:e.makeDefault,onOpenChange:e.onPermissionPickerOpenChange})),e.plan&&(i.plan=r.jsx(nu,{descriptor:e.plan.descriptor,active:e.plan.active,onToggle:e.plan.onToggle,disabled:!t})),e.contextPercent!==null&&(i.context=r.jsx(su,{percent:e.contextPercent,contextUsage:e.contextUsage,compact:e.compact,reading:e.contextReading}));const d=e.usage&&e.usageSource==="account"&&!e.supportsCostTracking?Vx(e.usage):e.usage;return d&&ac(d)&&(e.supportsCostTracking||e.usageSource==="account")&&!ru({account:u})&&(i.usage=r.jsx(ic,{usage:d,observedAt:e.usageObservedAt,now:e.now})),e.liveSubagentCount>0&&(i.subagents=r.jsx(ou,{count:e.liveSubagentCount,running:e.runningSubagents,waiting:e.waitingOnSubagents})),i.connection=r.jsx(au,{connectionState:e.connectionState,compact:l}),i}const Qx=[],Yx="(max-width: 639px)";function Xx({sessionId:e,sessionStatus:t,isStreaming:n,syncConnectionState:s,agentName:o,agentColor:a,agentEmoji:i,agentPath:l}){var Fe,ze;const{ref:u,budget:d}=lu(),f=Eo(e),h=$o(e,t,n,f.runtime),m=Dt(e||null),{pins:x}=cu(),g=uu(e),C=du(e,m,g.usage),b=C.usage,v=Nt(),k=new Date(v),y=lc(b,C.observedAt,k),p=g.contextUsage,j=((Fe=ps(e))==null?void 0:Fe.contextUsage)??null,_=Xn(re=>re.open),D=Xn(re=>re.setOpen),{data:A}=fu(h.cwd),N=Fx(h.cwd),{project:T}=cc(h.cwd),S=uc(Yx),E=c.useMemo(()=>({sessionId:e,cwd:h.cwd,project:T,trackerItems:m.trackerItems,compact:S}),[e,h.cwd,T,m.trackerItems,S]),w=mu(E),{data:M}=cs(),R=pu(g.activeSubagents).running,F=g.runningSubagentCount??R.length,{data:I}=ls({sessionId:e||void 0,runtime:f.runtime??void 0}),z=((ze=I==null?void 0:I.find(re=>re.value===h.model))==null?void 0:ze.supportsAutoMode)??!1,B=nn(f.runtime),J=(B==null?void 0:B.permissionModes.values)??Qx,Y=B==null?void 0:B.permissionModes.default,G=dc(e),$=ie(re=>re.recordAutoConfirmed),[P,O]=c.useState(!1),Q=hu({sessionId:e,runtime:f.runtime,declaredModes:J,runtimeDefaultMode:Y}),[ce,H]=c.useState(!1),U=c.useCallback(re=>h.updateSession({permissionMode:re}),[h]),X=c.useCallback(re=>{if(re==="auto"&&!G){O(!0);return}U(re).then(Ne=>{Ne&&Q.offerFor(re)})},[G,U,Q,O]),ne=c.useCallback(()=>{$(e),U("auto"),O(!1)},[$,e,U,O]),oe=fc(J),K=oe!==void 0&&h.permissionMode===oe.id,ae=mc(e),ge=ie(re=>re.recordModeBeforePlan),fe=c.useCallback(re=>{if(!oe)return;if(re){ge(e,h.permissionMode),U(oe.id);return}const Ne=ae,Be=Ne!==void 0&&J.some(Ge=>Ge.id===Ne)&&(Ne!=="auto"||z)?Ne:Y;Be&&U(Be)},[oe,ge,e,h,U,ae,J,z,Y]),L=f.runtime?Ft(f.runtime).label:"",ve=qa(B==null?void 0:B.commandIntents,L),je=g.contextPercent,me=Bx({sessionId:e,percent:je,compactSupported:ve.supported,isStreaming:n}),[_e,ee]=c.useState(!1);gu(()=>ee(re=>!re));const Z={cwd:h.cwd,git:xu(A)?bu(A.branch,A.clean,A.detached):null,contextPercent:je,connectionState:s,permissionMode:h.permissionMode,permissionDescriptor:(B==null?void 0:B.permissionModes.values.find(re=>re.id===h.permissionMode))??null,permissionPickerOpen:ce,plan:oe?{active:K}:null,runtime:f.runtime===null||M===void 0?null:{type:f.runtime,isDefault:f.runtime===M.defaultRuntime,canSelect:f.canSelect},account:No(m),usage:b,usageStale:y,subagentsInFlight:F,extensionItems:w.promotion},se=me.visible&&d.density==="full",pe=me.visible&&!se,xe=Kx({sessionId:e,agent:{name:o,color:a,emoji:i,path:l},status:h,onUpdateSession:h.updateSession,onChangeMode:X,makeDefault:ce?Q.line:null,onPermissionPickerOpenChange:H,modelSupportsAutoMode:z,plan:oe?{descriptor:oe,active:K,onToggle:fe}:null,gitStatus:A,workspace:N,runtimeChip:f,account:m,contextPercent:je,contextUsage:p,contextReading:j,compact:se?{pending:me.pending,onCompact:me.onCompact}:null,usage:b,usageSource:C.source,usageObservedAt:C.observedAt,now:k,supportsCostTracking:(B==null?void 0:B.supportsCostTracking)??!0,runningSubagents:R,liveSubagentCount:F,waitingOnSubagents:g.lifecycle==="idle",connectionState:s,density:d.density,extensions:{ctx:E,items:w.visible}}),{items:ke,overflow:be}=yu(vu({ctx:Z,pins:x,nodes:xe}),d);return r.jsxs("div",{ref:u,className:"relative pt-2",children:[!ce&&Q.line&&r.jsx(ku,{...Q.line,placement:"overlay"}),r.jsx(Cu,{items:ke,trailing:r.jsx(Su,{open:_e,onOpenChange:ee,diagnostics:g,controls:{plan:oe?{active:K,onToggle:fe}:null},promotionContext:Z,overflowCount:be,addOns:w.visible.length>0?r.jsx(Gx,{ctx:E,items:w.visible}):void 0,urgentAction:pe?{label:`Compact chat · ${me.percent}% full`,onAction:me.onCompact,pending:me.pending}:null})}),r.jsx(ju,{usage:b??null,accountUsage:C.accountUsage,observedAt:C.observedAt,open:_,onOpenChange:D}),r.jsx(_u,{open:P,onOpenChange:O,onConfirm:ne})]})}const Jx=Object.freeze({completed:"Completed",aborted_tools:"Tool stopped",aborted_streaming:"Reply stopped",max_turns:"Turn limit reached",blocking_limit:"Blocking limit",rapid_refill_breaker:"Rate limit",prompt_too_long:"Prompt too long",image_error:"Image error",model_error:"Model error",stop_hook_prevented:"Stopped by hook",hook_stopped:"Hook stopped",tool_deferred:"Tool deferred"});function Zx(e){return e!==void 0&&e!=="completed"}function e0(e){const t=Jx[e];return t!==void 0?t:t0(e)}function t0(e){if(e.length===0)return"Ended";const t=e.replace(/[_-]+/g," ").trim().split(/\s+/);if(t.length===0)return"Ended";const[n,...s]=t;return[n.charAt(0).toUpperCase()+n.slice(1).toLowerCase(),...s.map(a=>a.toLowerCase())].join(" ")}function n0({terminalReason:e}){const t=Zx(e),n=t?e0(e):"";return r.jsx(de,{children:t&&r.jsx(V.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,ease:"easeOut"},className:"flex px-4 py-1","data-testid":"terminal-reason-chip",children:r.jsx(pc,{variant:"secondary","aria-label":`Chat ended: ${n}`,children:n})},e)})}const s0="The turn ended before completing.";function r0({sessionId:e,onRetry:t,onSigninComplete:n,onChooseModel:s}){var m;const o=rn(e),a=((m=ps(e))==null?void 0:m.lastError)??null,i=(a==null?void 0:a.category)==="auth_error"||(a==null?void 0:a.category)==="model_unavailable"||(a==null?void 0:a.category)==="runtime_update_required",l=!i&&o?`${Ft(o).label} stopped unexpectedly`:void 0,u=(a==null?void 0:a.message)??s0,d=i?void 0:u,f=o?us(o):void 0,h=a?[a.code,a.details].filter(Boolean).join(`
51
- `):void 0;return r.jsx(V.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:.3,duration:.2,ease:"easeOut"},className:"mx-4 mb-2","data-testid":"turn-failed-notice",children:r.jsx(an,{category:(a==null?void 0:a.category)??"execution_error",heading:l,message:u,subtext:d,details:h||void 0,onRetry:t,onSigninComplete:n,onChooseModel:s,runtimeLabel:f,sessionId:e,...a!=null&&a.code?{code:a.code}:{},...a!=null&&a.reason?{reason:a.reason}:{}})})}const o0=["Type @ to mention a file","Type / to browse commands","End a line with \\ to keep typing","Drop or paste files to attach"];function a0(e,t,n){const s=c.useCallback(g=>{var k;if(!e||!t.current)return;const C=ie.getState(),b=(k=n.current)==null?void 0:k.get(e);if(b!==void 0&&C.getSession(e).mountGeneration!==b)return;const v=typeof g=="function"?g(C.getSession(e).messages):g;C.updateSession(e,{messages:v})},[e,t,n]),o=c.useCallback(g=>{e&&ie.getState().updateSession(e,{input:g})},[e]),a=c.useCallback(g=>{e&&ie.getState().updateSession(e,{status:g})},[e]),i=c.useCallback(g=>{e&&ie.getState().updateSession(e,{error:g})},[e]),l=c.useCallback(g=>{e&&ie.getState().updateSession(e,{sessionStatus:g})},[e]),u=c.useCallback(g=>{e&&ie.getState().updateSession(e,{estimatedTokens:g})},[e]),d=c.useCallback(g=>{e&&ie.getState().updateSession(e,{streamStartTime:g})},[e]),f=c.useCallback(g=>{e&&ie.getState().updateSession(e,{isTextStreaming:g})},[e]),h=c.useCallback(g=>{e&&ie.getState().updateSession(e,{systemStatus:g})},[e]),m=c.useCallback(g=>{e&&ie.getState().updateSession(e,{operationProgress:g})},[e]),x=c.useCallback(g=>{e&&ie.getState().updateSession(e,{promptSuggestions:g})},[e]);return{setMessages:s,setInput:o,setStatus:a,setError:i,setSessionStatus:l,setEstimatedTokens:u,setStreamStartTime:d,setIsTextStreaming:f,setSystemStatus:h,setOperationProgress:m,setPromptSuggestions:x}}function i0({sessionId:e,sid:t,transport:n,sessionCwd:s,enableMessagePolling:o,isStreaming:a,streamHydrated:i,setMessages:l}){const u=Uo(),d=s.cwd,f=c.useRef(d);c.useEffect(()=>{f.current=d},[d]);const h=c.useRef(i);c.useEffect(()=>{h.current=i},[i]);const m=Je({queryKey:["messages",e,d],queryFn:()=>n.getMessages(e,d??void 0,{newest:!0}),staleTime:Ye.MESSAGE_STALE_TIME_MS,refetchOnWindowFocus:!1,enabled:e!==null&&!i,refetchInterval:()=>a||!o?!1:u?Ye.ACTIVE_TAB_REFETCH_MS:Ye.BACKGROUND_TAB_REFETCH_MS});return c.useEffect(()=>{const x=ie.getState();t&&x.updateSession(t,{historySeeded:!1}),x.getSession(e??"").status!=="streaming"&&l([])},[e,d,t,l]),c.useEffect(()=>{if(!m.data)return;const x=m.data.messages,g=ie.getState().getSession(t).historySeeded;if(!g&&x.length>0){if(a)return;if(t&&ie.getState().updateSession(t,{historySeeded:!0}),e&&!h.current){const C=m.data.earlierMessages??0;Pe.getState().noteSnapshot(e,x[0].id,C)}l(x.map(at));return}g&&!a&&Dp(ie.getState().getSession(t).messages,x,l)},[m.data,a,e,t,l]),{historyQuery:m}}function Ha(e,t){if(e===t)return;const{opened:n,counts:s,mergeUsage:o}=it.getState(),a=qs("session",e),i=Date.parse(n[a]??"");Number.isNaN(i)||o([{key:qs("session",t),lastUsedAt:i,useCount:s[a]??1}])}function Zn(e,t,n){e&&n.then(s=>{if(!s)return;const o=ie.getState();o.getSession(e).input.trim()===t.trim()&&o.updateSession(e,{input:""})},()=>{})}const Bt=new Map;function l0(e,t){const s=(Bt.get(e)??Promise.resolve()).then(t),o=s.then(()=>{},()=>{});return Bt.set(e,o),o.then(()=>{Bt.get(e)===o&&Bt.delete(e)}),s}const st=new Set;function Mr(e){var o;const t=e,n=typeof(t==null?void 0:t.code)=="string"?t.code:void 0,s=(o=t==null?void 0:t.body)==null?void 0:o.agentId;return{...n?{code:n}:{},...typeof s=="string"?{agentId:s}:{}}}function c0({sessionId:e,input:t,status:n,transport:s,queryClient:o,selectedCwd:a,onSessionIdChangeReplace:i,transformContent:l,launchRuntime:u,agentPath:d,agentLookupPending:f,agentLookupFailed:h,launchAccount:m,takeSeedContext:x,setInput:g,setError:C,tryNativeCommand:b}){const v=c.useRef(a);c.useEffect(()=>{v.current=a},[a]);const k=c.useRef(u);c.useEffect(()=>{k.current=u},[u]);const y=c.useRef(m);c.useEffect(()=>{y.current=m},[m]);const{data:p}=cs(),j=c.useRef(p==null?void 0:p.defaultRuntime);c.useEffect(()=>{j.current=p==null?void 0:p.defaultRuntime},[p==null?void 0:p.defaultRuntime]);const _=wu(e,u),D=c.useRef(_.mode);c.useEffect(()=>{D.current=_.mode},[_.mode]);const A=c.useRef(l);c.useEffect(()=>{A.current=l});const N=c.useRef(x);c.useEffect(()=>{N.current=x});const T=c.useRef(i);c.useEffect(()=>{T.current=i});const S=c.useCallback(async(G,$,P={})=>{var ae,ge,fe;if(!P.kickoff){const L=b(G);if(L.handled){$&&L.ran&&(L.confirmed?Zn(e,G,L.confirmed):g(""));return}}const O=e,Q=P.cwd??v.current;C(null);const ce=o.getQueryData(Ke.list(Q))??[],H=gn(O),U=(H==null?void 0:H.draft)??!ce.some(L=>L.id===O),X=(H==null?void 0:H.draft)===!1?!1:U||st.has(O);if(X&&(f||h))return;X&&st.add(O),P.kickoff||(it.getState().recordOpened("session",O),Q&&it.getState().recordOpened("agent",Q)),kt.attachSession(O,Q);let ne;try{ne=!P.kickoff&&A.current?await A.current(G):G}catch(L){if(P.kickoff)throw L;C({heading:"Couldn’t send message",message:L.message||"The attachment didn’t upload. Try again.",retryable:!1});return}const oe=we.getState();if(U){const L=new Date().toISOString();Us(o,Q,{id:O,title:`Chat ${O.slice(0,8)}`,createdAt:L,updatedAt:L,permissionMode:((ae=o.getQueryData(Ke.detail(O,Q)))==null?void 0:ae.permissionMode)??D.current??"default",runtime:k.current??j.current??"claude-code"})}const K=crypto.randomUUID();P.kickoff||oe.setOptimisticUserMessage(O,{id:K,content:G}),oe.setTriggerPending(O,!0),$&&g("");try{const L=Hs(ue.getState(),Q??null),{uiState:ve,commit:je}=Ws(O,L),_e={clientMessageId:K,context:ve?{uiState:ve}:void 0};X&&(_e.create=!0),X&&k.current&&(_e.runtime=k.current),X&&d&&(_e.agentPath=d),X&&y.current&&(_e.account=y.current);const ee=ue.getState().retryAccount;(ee==null?void 0:ee.sessionId)===O&&(_e.account=ee.id,ue.getState().setRetryAccount(null));const Z=(ge=N.current)==null?void 0:ge.call(N);Z&&(_e.seedContext=Z);const{sessionId:se}=await s.postMessage(O,ne,Q??void 0,_e);if(st.delete(O),H){const xe={...H,draft:!1};xn(O,xe),xn(se,xe)}if(je(se),se!==O){we.getState().migrateSessionContinuity(O,se),ue.getState().carryCanvasWritesAcross(O,se),kt.attachSession(se,Q),Ha(O,se),rt.getState().migrate(O,se);const xe=o.getQueryData(Ke.list(Q))??[],ke=xe.find(be=>be.id===O);ke&&!xe.some(be=>be.id===se)&&Us(o,Q,{...ke,id:se}),o.setQueryData(Ke.list(Q),be=>be==null?void 0:be.filter(Fe=>Fe.id!==O))}(fe=T.current)==null||fe.call(T,se);const pe=se;setTimeout(()=>{var be;const xe=Ct.getState().rekeys[pe]??pe,ke=we.getState().getSession(xe);ke.triggerPending&&((be=ke.status)==null?void 0:be.lifecycle)!=="streaming"&&we.getState().setTriggerPending(xe,!1)},tn.TRIGGER_PENDING_TIMEOUT_MS)}catch(L){if(we.getState().setOptimisticUserMessage(O,null),we.getState().setTriggerPending(O,!1),P.kickoff)throw L;C({heading:"Couldn’t send message",message:L.message||"Couldn’t reach DorkOS. Try again.",retryable:!0,...Mr(L)})}},[e,s,o,g,C,b,d,f,h]),E=c.useCallback(async(G,$)=>{!G.trim()||n==="streaming"||await S(G.trim(),($==null?void 0:$.clearInput)===!0,{...$!=null&&$.cwd?{cwd:$.cwd}:{}})},[n,S]),w=c.useCallback(()=>E(t,{clearInput:!0}),[t,E]),M=c.useCallback(async(G,$,P)=>{if(!e)return!1;const O=e,Q=v.current;C(null);const ce=(o.getQueryData(Ke.list(Q))??[]).some(U=>U.id===O),H=gn(O);return((H==null?void 0:H.draft)??!ce)&&st.add(O),l0(O,async()=>{var X;let U;try{U=A.current?await A.current(G):G}catch(ne){return C({heading:P,message:ne.message||"The attachment didn’t upload. Try again.",retryable:!1}),!1}try{const ne=Hs(ue.getState(),Q??null),{uiState:oe,commit:K}=Ws(O,ne),ae={...oe?{uiState:oe}:{},...$==="queue"?{queued:!0}:{}},ge=Object.keys(ae).length>0?ae:void 0,fe=((X=gn(O))==null?void 0:X.draft)===!1?!1:st.has(O);if(fe&&(f||h))return!1;const{sessionId:L}=await s.postMessage(O,U,Q??void 0,{context:ge,disposition:$,...fe?{create:!0,...k.current&&{runtime:k.current},...y.current&&{account:y.current},...d&&{agentPath:d}}:{}});return fe&&st.delete(O),H&&xn(L,{...H,draft:!1}),K(L),!0}catch(ne){return C({heading:P,message:ne.message||"Couldn’t reach DorkOS. Try again.",retryable:!1,...Mr(ne)}),!1}})},[e,s,o,C,d,f,h]),R=c.useCallback(G=>M(G,"queue","Couldn’t queue message"),[M]),F=c.useCallback(G=>M(G,"steer","Couldn’t steer the agent"),[M]),I=c.useCallback(G=>M(G,"stage","Couldn’t add context"),[M]),z=c.useCallback(async()=>{if(!e)return{receipt:{outcome:"not-running",reason:"no-open-turn",runtime:"unknown"},cancelled:[]};try{const{receipt:G,cancelledQueued:$}=await s.interruptSession(e);return{receipt:G,cancelled:$??[]}}catch{return{receipt:{outcome:"failed",reason:"delivery-failed",runtime:"unknown"},cancelled:[]}}},[e,s]),B=c.useCallback(async G=>{C(null),await S(G,!1)},[S,C]),J=c.useCallback(async(G,$)=>{await S(G,!1,{kickoff:!0,...$?{cwd:$}:{}})},[S]),Y=c.useCallback((G,$)=>{},[]);return{handleSubmit:w,submitContent:E,enqueueContent:R,steerContent:F,addContextContent:I,stop:z,retryMessage:B,submitKickoff:J,markToolCallResponded:Y}}const qt=new Set,Or=new Set,Ut=new Set;function u0(e){var t;return e.role==="user"||e.content.trim().length>0||(((t=e.toolCalls)==null?void 0:t.length)??0)>0?!0:e.parts.some(n=>n.type==="tool_call")}function d0({sessionId:e,cwd:t,status:n,messages:s,hydrated:o,canStart:a=!0,submitKickoff:i,submitContent:l}){const u=en(e),d=s.length,f=s.some(u0);c.useEffect(()=>{if(!e)return;if(!u){t&&d===0&&n==="idle"&&rt.getState().claimByPath(t,e);return}if(u.fired||qt.has(e)||!a||d>0||n!=="idle")return;qt.add(e),rt.getState().markFired(e);const h=u.kind==="first-message";(h?l:i)(u.kickoffMessage,u.path||void 0).catch(x=>{console.warn("[chat] first-turn trigger failed for newborn session",e,x),Or.has(e)?h||rt.getState().markGreetingFailed(e):(Or.add(e),qt.delete(e),rt.getState().resetFired(e))})},[e,t,u,n,d,a,i,l]),c.useEffect(()=>{if(!(!e||!u)&&u.kind!=="first-message"&&!(!u.fired&&!qt.has(e))&&!u.greetingFailed){if(f){Ut.delete(e);return}if(n==="streaming"){Ut.add(e);return}o&&Ut.has(e)&&(Ut.delete(e),rt.getState().markGreetingFailed(e))}},[e,u,n,f,o])}function f0(e,t){return c.useEffect(()=>{hc(),kt.connectList(),e&&kt.attachSession(e,t)},[e,t]),c.useEffect(()=>()=>kt.releaseSession(),[]),Do(e??"")}function m0(e,t){const n=To(e),s=c.useRef(t);c.useEffect(()=>{s.current=t}),c.useEffect(()=>{var o;!n||!e||(Ha(e,n),(o=s.current)==null||o.call(s,n))},[n,e])}const p0=500;function h0(e,t,n){const s=c.useRef(new Map),[o,a]=c.useState(null),i=t.length>0?t[0].seq:-1;c.useEffect(()=>{const h=s.current;if(!e||!n){e&&h.delete(e),a(null);return}let m=h.get(e);(!m||m.turnSeq!==i)&&(m={turnSeq:i,anchor:Date.now()},h.set(e,m)),a(m.anchor)},[e,n,i]);const l=c.useMemo(()=>{let h=0;for(const m of t)m.type==="text_delta"&&(h+=m.text.length);return h/4},[t]),[u,d]=c.useState(!1),f=c.useRef({sid:null,tokens:0});return c.useEffect(()=>{const h=f.current,m=e===h.sid&&l>h.tokens;if(f.current={sid:e,tokens:l},m&&!u&&d(!0),!m&&!u)return;const x=setTimeout(()=>d(!1),p0);return()=>clearTimeout(x)},[e,l,u]),{streamStartTime:o,estimatedTokens:l,isTextStreaming:u}}function g0(e,t,n,s){const o=c.useRef(new Map),a=c.useRef(s);c.useEffect(()=>{a.current=s}),c.useEffect(()=>{var d;if(!e)return;const i=o.current,l=n??0;let u=i.get(e);(!u||u.floor!==l)&&(u={floor:l,seen:l},i.set(e,u));for(const f of t)f.seq<=u.seen||(f.type==="todo_update"&&((d=a.current)==null||d.call(a,{action:f.action,task:f.task,tasks:f.tasks,previousId:f.previousId})),u.seen=f.seq)},[e,t,n])}function x0(e){let t=null,n=null;for(const s of e){if(s.type==="operation_progress"){t=s.state==="started"?{operation:s.operation,determinate:s.determinate,...s.percent!==void 0?{percent:s.percent}:{},...s.message!==void 0?{message:s.message}:{}}:null;continue}if(s.type==="system_status"){s.status||(n={message:s.message});continue}n=null}return{operationProgress:t,systemStatus:n}}function b0(e,t){return e===null||t===null?e===t:e.operation===t.operation&&e.determinate===t.determinate&&e.percent===t.percent&&e.message===t.message}function y0(e,t){return((e==null?void 0:e.message)??null)===((t==null?void 0:t.message)??null)}function v0(e,t,n,s){const o=c.useRef(new Map),a=c.useRef(new Map),i=c.useRef(n),l=c.useRef(s);c.useEffect(()=>{i.current=n,l.current=s}),c.useEffect(()=>{if(!e)return;const{operationProgress:u,systemStatus:d}=x0(t),f=o.current.get(e)??null;b0(f,u)||(i.current(u),o.current.set(e,u));const h=a.current.get(e)??null;y0(h,d)||(l.current(d),a.current.set(e,d))},[e,t])}function k0(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="capability_approval"&&s.approval.approvalId===t)return s}}function C0(e,t){const n=k0(e,t.approval.approvalId);n?n.approval=t.approval:e.push({type:"capability_approval",approval:t.approval})}function S0(e,t){const n=e.findIndex(o=>o.type==="capability_approval"&&o.approval.approvalId===t.approvalId);if(n===-1)return;if(t.outcome!=="timeout"){e.splice(n,1);return}const s=e[n];s.outcome="timeout"}function j0(e,t,n){return e.findIndex(s=>s.type==="mcp_signin"&&s.agentId===t&&s.serverName===n&&s.outcome===void 0)}function _0(e,t){const n={type:"mcp_signin",serverName:t.serverName,agentId:t.agentId,flowId:t.flowId,authorizeUrl:t.authorizeUrl,disclosure:t.disclosure},s=j0(e,t.agentId,t.serverName);s===-1?e.push(n):e[s]=n}function w0(e,t){const n=e.findIndex(o=>o.type==="mcp_signin"&&o.flowId===t.flowId);if(n===-1)return;const s=e[n];s.outcome=t.outcome,t.toolCount!==void 0&&(s.toolCount=t.toolCount)}function N0(e){return e.type==="interaction_resolved"||e.type==="capability_approval_resolved"||e.type==="mcp_signin_resolved"}function E0(e){const t=new Set;for(const n of e)n.type==="interaction_resolved"&&t.add(n.id);return t}const Ir="__in_progress_turn__",D0="__optimistic_user__";function T0(e){return{id:D0,role:"user",content:e,parts:[{type:"text",text:e}],timestamp:"",_streaming:!0}}function A0(e){return{id:`steer-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,...e.chatMessages&&e.chatMessages.length>0?{chatMessages:e.chatMessages}:{}}}function F0(e){return{id:`staged-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,_stagedContext:!0}}function $e(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="tool_call"&&s.toolCallId===t)return s}}function un(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="elicitation"&&s.interactionId===t)return s}}function R0(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="background_task"&&s.taskId===t)return s}}function M0(e,t){Wa(e);const n=e[e.length-1];n&&n.type==="text"?n.text+=t.text:e.push({type:"text",text:t.text})}function O0(e,t){const n=e[e.length-1];n&&n.type==="thinking"&&n.isStreaming?n.text+=t.text:e.push({type:"thinking",text:t.text,isStreaming:!0})}function Wa(e){for(const t of e)t.type==="thinking"&&t.isStreaming&&(t.isStreaming=!1)}function I0(e,t,n){const s=$e(e,t.toolCallId);if(s){t.input!==void 0&&(s.input=(s.input??"")+t.input);return}const o=n.get(t.toolCallId);n.delete(t.toolCallId),e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",status:t.status,...o&&o.length>0?{hooks:o}:{}})}function $0(e,t){const n=$e(e,t.toolCallId);n?(n.result=t.result,n.status=t.status,t.ui!==void 0&&(n.ui=t.ui),t.result!==void 0&&(n.progressOutput=void 0)):e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",result:t.result,status:t.status,...t.ui!==void 0?{ui:t.ui}:{}})}function P0(e,t){const n=$e(e,t.toolCallId);n&&(n.progressOutput=(n.progressOutput??"")+t.content)}function Ga(e,t){const n={interactiveType:"approval",input:t.input,status:"pending",timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs,approvalTitle:t.title,approvalDisplayName:t.displayName,approvalDescription:t.description,approvalBlockedPath:t.blockedPath,approvalDecisionReason:t.decisionReason,approvalHasSuggestions:t.hasSuggestions,approvalAlwaysAllowScope:t.alwaysAllowScope},s=$e(e,t.id);s?Object.assign(s,n):e.push({type:"tool_call",toolCallId:t.id,toolName:t.toolName,...n})}function Va(e,t){const n=$e(e,t.id),s={timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs};n?(n.interactiveType="question",n.questions=t.questions,n.status="pending",Object.assign(n,s)):e.push({type:"tool_call",toolCallId:t.id,toolName:"AskUserQuestion",input:"",status:"pending",interactiveType:"question",questions:t.questions,...s})}function Ka(e,t){const n={serverName:t.serverName,message:t.message,mode:t.mode,url:t.url,elicitationId:t.elicitationId,requestedSchema:t.requestedSchema,status:"pending",startedAt:t.startedAt,remainingMs:t.remainingMs,timeoutMs:t.timeoutMs},s=un(e,t.id);s?Object.assign(s,n):e.push({type:"elicitation",interactionId:t.id,...n})}function L0(e){return e==="denied"||e==="expired"||e==="cancelled"?"error":e==="answered"?"complete":"running"}function z0(e,t){const n=$e(e,t.id);if(n){n.status==="pending"&&(n.status=L0(t.resolution),n.approvalRemainingMs=void 0);const o=gc(t);o&&(n.interactiveType="approval",n.approvalOutcome=o,n.approvalResolvedAt=t.at,t.reasonGiven===!0&&(n.approvalReasonGiven=!0),n.approvalStartedAt=t.startedAt??n.approvalStartedAt);const a=xc(t);a&&(n.questionOutcome=a)}const s=un(e,t.id);s&&s.status==="pending"&&(s.status="submitted",s.remainingMs=void 0)}function B0(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="tool_call"&&s.hooks){const o=s.hooks.find(a=>a.hookId===t);if(o)return o}}}function q0(e,t){for(const n of e.values()){const s=n.find(o=>o.hookId===t);if(s)return s}}function U0(e,t,n){const s=B0(e,t.hookId)??q0(n,t.hookId);if(s){s.status=t.status,t.hookName!==void 0&&(s.hookName=t.hookName),t.stdout!==void 0&&(s.stdout=t.stdout),t.stderr!==void 0&&(s.stderr=t.stderr),t.exitCode!==void 0&&(s.exitCode=t.exitCode);return}if(!t.toolCallId)return;const o={hookId:t.hookId,hookName:t.hookName??"",hookEvent:t.hookEvent??"",status:t.status,stdout:t.stdout??"",stderr:t.stderr??"",...t.exitCode!==void 0?{exitCode:t.exitCode}:{}},a=$e(e,t.toolCallId);a?a.hooks=[...a.hooks??[],o]:n.set(t.toolCallId,[...n.get(t.toolCallId)??[],o])}function H0(e,t){const n=e[0];if(n&&n.type==="memory_recall"){const a=new Set(n.memories.map(l=>l.path)),i=t.memories.filter(l=>!a.has(l.path));i.length>0&&(n.memories=[...n.memories,...i]);return}const s=new Set,o=t.memories.filter(a=>s.has(a.path)?!1:(s.add(a.path),!0));e.unshift({type:"memory_recall",mode:t.mode,memories:o,isStreaming:!0})}function W0(e,t){e.push({type:"image",attachmentId:t.attachmentId,url:t.url,mediaType:t.mediaType,size:t.size,...t.alt!==void 0?{alt:t.alt}:{}})}function G0(e,t){e.push({type:"compact_boundary",...t.trigger!==void 0?{trigger:t.trigger}:{},...t.preTokens!==void 0?{preTokens:t.preTokens}:{},...t.postTokens!==void 0?{postTokens:t.postTokens}:{},...t.durationMs!==void 0?{durationMs:t.durationMs}:{},...t.requestedBy!==void 0?{requestedBy:t.requestedBy}:{},...t.contextPercent!==void 0?{contextPercent:t.contextPercent}:{}})}function V0(e,t){e.push({type:"permission_denied",toolCallId:t.toolCallId,toolName:t.toolName,message:t.message,...t.reasonType!==void 0?{reasonType:t.reasonType}:{},...t.reason!==void 0?{reason:t.reason}:{},...t.agentId!==void 0?{agentId:t.agentId}:{}})}function K0(e,t){t.operation!=="compaction"||t.state!=="failed"||e.push({type:"compact_boundary",failed:!0,...t.error!==void 0?{error:t.error}:{},...t.requestedBy!==void 0?{requestedBy:t.requestedBy}:{}})}function Q0(e,t){Wa(e);const n=t.code!==void 0?t.details!==void 0?`[${t.code}] ${t.details}`:`[${t.code}]`:t.details;e.push({type:"error",message:t.message,...t.category!==void 0?{category:t.category}:{},...n!==void 0?{details:n}:{},...t.code!==void 0?{code:t.code}:{},...t.reason!==void 0?{reason:t.reason}:{}})}function Y0(e,t){const n=R0(e,t.taskId);n?(n.status=t.status,t.description!==void 0&&(n.description=t.description),t.toolUses!==void 0&&(n.toolUses=t.toolUses),t.lastToolName!==void 0&&(n.lastToolName=t.lastToolName),t.summary!==void 0&&(n.summary=t.summary),t.ambient!==void 0&&(n.ambient=t.ambient)):e.push({type:"background_task",taskId:t.taskId,taskType:"agent",status:t.status,startedAt:0,description:t.description,toolUses:t.toolUses,lastToolName:t.lastToolName,summary:t.summary,ambient:t.ambient})}const X0={approval:"approval_required",question:"question_prompt",elicitation:"elicitation_prompt"};function J0(e){const{type:t,...n}=e;return{...n,seq:0,type:X0[t]}}function Z0(e,t){const n=$e(e,t);return(n==null?void 0:n.interactiveType)!==void 0?!0:un(e,t)!==void 0}function eb(e,t){switch(t.type){case"approval_required":Ga(e,t);break;case"question_prompt":Va(e,t);break;case"elicitation_prompt":Ka(e,t);break}}function tb(e,t,n){const s=$e(e,t.id);if(s){!n&&s.result===void 0&&(s.status="pending"),s.approvalStartedAt=t.startedAt,s.approvalRemainingMs=t.remainingMs,t.timeoutMs!==void 0&&(s.timeoutMs=t.timeoutMs),s.approvalParked=t.parked===!0?!0:void 0;return}const o=un(e,t.id);o&&(o.startedAt=t.startedAt,o.remainingMs=t.remainingMs,t.timeoutMs!==void 0&&(o.timeoutMs=t.timeoutMs))}function nb(e,t,n){for(const s of t){if(Z0(e,s.id)){tb(e,s,n.has(s.id));continue}eb(e,J0(s)),sb(e,s)}}function sb(e,t){if(t.parked!==!0)return;const n=$e(e,t.id);n&&(n.approvalParked=!0)}function es(e){const t=[],n=new Map;for(const s of e)switch(s.type){case"text_delta":M0(t,s);break;case"thinking_delta":O0(t,s);break;case"tool_call":I0(t,s,n);break;case"tool_result":$0(t,s);break;case"tool_progress":P0(t,s);break;case"approval_required":Ga(t,s);break;case"question_prompt":Va(t,s);break;case"elicitation_prompt":Ka(t,s);break;case"capability_approval_required":C0(t,s);break;case"capability_approval_resolved":S0(t,s);break;case"mcp_signin_required":_0(t,s);break;case"mcp_signin_resolved":w0(t,s);break;case"interaction_resolved":z0(t,s);break;case"subagent_update":Y0(t,s);break;case"hook_update":U0(t,s,n);break;case"memory_recall":H0(t,s);break;case"image_attachment":W0(t,s);break;case"compact_boundary":G0(t,s);break;case"permission_denied":V0(t,s);break;case"model_substituted":t.push({type:"model_substituted",from:s.from,fromName:s.fromName,to:s.to,toName:s.toName,reason:s.reason});break;case"operation_progress":K0(t,s);break;case"error":Q0(t,s);break}return t}function $r(e,t){if(e.length===0)return null;const n=bs(e);return{id:t,role:"assistant",content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:[],parts:e,timestamp:"",_streaming:!0}}function rb(e,t){const n=[];let s=[],o=0;for(const[l,u]of e.entries()){if(u.type!=="turn_input"&&u.type!=="context_staged"){s.push(u);continue}const d=es([...s,...e.slice(l+1).filter(N0)]),f=$r(d,`${Ir}-${o}`);f&&n.push(f),o+=1,n.push(u.type==="turn_input"?A0(u):F0(u)),s=[]}const a=es(s);nb(a,t,E0(e));const i=$r(a,Ir);return i&&n.push(i),n}function ob(e){const t=new Set;for(const n of e)for(const s of n.parts)s.type==="tool_call"&&t.add(s.toolCallId);return t}function ab(e){return e.type==="tool_call"&&e.result===void 0&&e.answers===void 0&&e.approvalOutcome===void 0&&(e.questionOutcome===void 0||e.questionOutcome==="unresolved")}function ib(e,t){const n=e.parts.filter(o=>o.type!=="tool_call"||!t.has(o.toolCallId)||!ab(o));if(n.length===e.parts.length)return e;if(n.length===0)return null;const s=bs(n);return{...e,parts:n,content:s.content,toolCalls:s.toolCalls.length>0?s.toolCalls:void 0}}function lb(e){let t=e.length;for(;t>0&&e[t-1].role==="assistant";)t-=1;return t}function cb(e,t,n=[],s=null){const o=rb(t,n),a=ob(o),i=Ep(e),l=a.size===0?i.length:lb(i),u=[];for(const[d,f]of i.entries()){const h=d<l?f:ib(f,a);h&&u.push(h)}return s&&u.push(T0(s.content)),u.push(...o),u}function Pr(e){const t=new Map;for(const n of e)n.type!=="tool_call"||n.approvalOutcome===void 0||t.set(n.toolCallId,{outcome:n.approvalOutcome,resolvedAt:n.approvalResolvedAt,startedAt:n.approvalStartedAt,displayName:n.approvalDisplayName,reasonGiven:n.approvalReasonGiven});return t}function ub(e,t){return e.interactiveType==="approval"&&e.approvalOutcome===t.outcome&&e.approvalResolvedAt===t.resolvedAt&&e.approvalStartedAt===t.startedAt&&e.approvalReasonGiven===t.reasonGiven}function db(e,t){return t.size===0?e:e.map(n=>{if(!n.parts)return n;let s=!1;const o=n.parts.map(a=>{if(a.type!=="tool_call")return a;const i=t.get(a.toolCallId);return!i||ub(a,i)?a:(s=!0,{...a,interactiveType:"approval",approvalOutcome:i.outcome,approvalResolvedAt:i.resolvedAt,approvalStartedAt:i.startedAt,approvalReasonGiven:i.reasonGiven,...i.displayName!==void 0?{approvalDisplayName:i.displayName}:{}})});return s?{...n,parts:o}:n})}function fb(e,t){var o;if(!t.tail)return t.messages;const n=(o=t.messages[0])==null?void 0:o.id,s=n===void 0?-1:e.findIndex(a=>a.id===n);return s===-1?null:[...e.slice(0,s),...t.messages]}async function mb(e,t,n,s){const o=pb(s());if(o!==void 0){const a=await e.getMessages(t,n,{since:o}),i=fb(s(),a);if(i)return i}return(await e.getMessages(t,n)).messages}function pb(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="user")return e[t].id}function hb({sessionId:e,transport:t,sessionCwd:n,streamState:s,queryClient:o,onStreamingDone:a}){var k;const i=n.cwd,l=c.useRef(e),u=c.useRef(i),d=c.useRef(a);c.useEffect(()=>{l.current=e,u.current=i,d.current=a});const f=c.useRef(new Map),h=c.useRef(new Map),m=c.useRef(new Map),x=c.useRef(new Map),g=c.useRef(new Map),C=((k=s.status)==null?void 0:k.lifecycle)??null,b=s.hydrationGeneration,v=s.userTurnCount;c.useEffect(()=>{var T,S,E;if(!e)return;const y=g.current.get(e);g.current.set(e,v),y!==void 0&&v!==y&&x.current.set(e,!1);const p=h.current.get(e);if(h.current.set(e,b),p!==b){f.current.set(e,C),C==="streaming"&&m.current.set(e,((T=we.getState().getSession(e).optimisticUserMessage)==null?void 0:T.id)??null);return}const j=f.current.get(e)??null;if(f.current.set(e,C),C==="streaming"&&j!=="streaming"&&m.current.set(e,((S=we.getState().getSession(e).optimisticUserMessage)==null?void 0:S.id)??null),!(j==="streaming"&&C!=="streaming"&&C!==null))return;const D=e,A=m.current.get(D)??null,N=Pr(es(we.getState().getSession(D).inProgressTurn));mb(t,D,u.current??void 0,()=>we.getState().getSession(D).messages).then(w=>{var B;const M=we.getState(),R=M.getSession(D),F=((B=R.status)==null?void 0:B.lifecycle)==="streaming",I=new Map([...Pr(R.messages.flatMap(J=>J.parts??[])),...N]);M.setHistoryMessages(D,db(w,I),{preserveInProgressTurn:F});const z=R.optimisticUserMessage;(z===null||z.id===A)&&M.setOptimisticUserMessage(D,null)}).catch(w=>{console.warn("[turn-end-reconcile] history reload failed",{sessionId:D,error:w instanceof Error?w.message:String(w)})}),o.invalidateQueries({queryKey:["tasks",D]}),x.current.get(D)!==!0&&(x.current.set(D,!0),(E=d.current)==null||E.call(d))},[e,C,b,v,t,o])}function gb(e){return e.streamReadyCursor!==null||e.messages.length>0||e.inProgressTurn.length>0||e.optimisticUserMessage!==null}function Qa(e,t){const n=gb(e),s=n?e.messages:t,o=Lr.get(s);if(o&&o.hydrated===n&&o.inProgressTurn===e.inProgressTurn&&o.pendingInteractions===e.pendingInteractions&&o.optimisticUserMessage===e.optimisticUserMessage&&o.legacyMessages===t)return o.result;const a=n?cb(e.messages,e.inProgressTurn,e.pendingInteractions,e.optimisticUserMessage):t,i=Wc(a);return Lr.set(s,{hydrated:n,inProgressTurn:e.inProgressTurn,pendingInteractions:e.pendingInteractions,optimisticUserMessage:e.optimisticUserMessage,legacyMessages:t,result:i}),i}const Lr=new WeakMap;function xb(e,t={}){const n=Se(),s=is(),o=ue(K=>K.selectedCwd),a=ue(K=>K.enableMessagePolling),i=ue(K=>K.pendingAccount),l=Jo(),u=e??"",{messages:d,input:f,status:h,error:m,sessionStatus:x,systemStatus:g,operationProgress:C,promptSuggestions:b}=Ao(u),v=f0(e,l.cwd);m0(e,t.onSessionIdChangeReplace);const k=bc(u),y=c.useMemo(()=>Qa(v,d),[v,d]),p=Nu(v,h),{streamStartTime:j,estimatedTokens:_,isTextStreaming:D}=h0(e,v.inProgressTurn,p==="streaming");g0(e,v.inProgressTurn,v.streamReadyCursor,t.onTaskEvent);const A=c.useRef(!0);c.useEffect(()=>(A.current=!0,()=>{A.current=!1}),[]);const N=c.useRef(new Map);c.useLayoutEffect(()=>{u&&(N.current.has(u)||N.current.set(u,ie.getState().getSession(u).mountGeneration))},[u]);const{setMessages:T,setInput:S,setError:E,setSystemStatus:w,setOperationProgress:M}=a0(u,A,N);v0(e,v.inProgressTurn,M,w),u&&ie.getState().initSession(u),c.useEffect(()=>{e&&(ie.getState().initSession(e),ie.getState().touchSession(e),N.current.set(e,ie.getState().getSession(e).mountGeneration))},[e]),c.useEffect(()=>{if(e)return Ct.getState().clearUnseen(e),Ct.subscribe(K=>{K.unseen[e]!==void 0&&Ct.getState().clearUnseen(e)})},[e]);const{historyQuery:R}=i0({sessionId:e,sid:u,transport:n,sessionCwd:l,enableMessagePolling:a,isStreaming:p==="streaming",streamHydrated:v.streamReadyCursor!==null,setMessages:T}),F=Ix(o,e,{startFreshSession:t.startFreshSession,compact:t.compactIntent}),{handleSubmit:I,submitContent:z,enqueueContent:B,steerContent:J,addContextContent:Y,stop:G,retryMessage:$,submitKickoff:P,markToolCallResponded:O}=c0({sessionId:e,input:f,status:p,transport:n,queryClient:s,selectedCwd:o,onSessionIdChangeReplace:t.onSessionIdChangeReplace,transformContent:t.transformContent,launchRuntime:t.launchRuntime,agentPath:t.agentPath,agentLookupPending:t.agentLookupPending,agentLookupFailed:t.agentLookupFailed,launchAccount:(i==null?void 0:i.sessionId)===u?i.id:null,takeSeedContext:t.takeSeedContext,setInput:S,setError:E,tryNativeCommand:F.tryRun}),Q=v.streamReadyCursor!==null,ce=c.useCallback((K,ae)=>z(K,ae?{cwd:ae}:void 0),[z]);d0({sessionId:e,cwd:o,status:p,messages:y,hydrated:Q,canStart:!t.agentLookupPending&&!t.agentLookupFailed,submitKickoff:P,submitContent:ce}),hb({sessionId:e,transport:n,sessionCwd:l,streamState:v,queryClient:s,onStreamingDone:t.onStreamingDone});const H=R.isLoading&&y.length===0,U=c.useMemo(()=>y.flatMap(K=>K.toolCalls||[]).filter(K=>K.interactiveType&&K.status==="pending"),[y]),X=U[0]||null,ne=X!==null,oe=(X==null?void 0:X.interactiveType)||null;return{messages:y,input:f,setInput:S,handleSubmit:I,submitContent:z,enqueueContent:B,steerContent:J,addContextContent:Y,status:p,error:m,stop:G,retryMessage:$,isLoadingHistory:H,hydrated:Q,sessionStatus:x,streamStartTime:j,estimatedTokens:_,isTextStreaming:D,isWaitingForUser:ne,waitingType:oe,activeInteraction:X,pendingInteractions:U,markToolCallResponded:O,systemStatus:g,operationProgress:C,promptSuggestions:b,syncConnectionState:k,tryNativeCommand:F.tryRun,commandPending:F.commandPending}}function bb(e){switch(e.outcome){case"acked":return{message:"You stopped this reply.",isFailure:!1};case"closed":return{message:"Stopped. Your agent didn’t answer, so DorkOS ended it.",isFailure:!1};case"not-running":return{message:null,isFailure:!1};case"unconfirmed":return{message:`Stop requested. ${vb(e.runtime)} didn’t confirm, so it may still be working.`,isFailure:!1};case"failed":return{message:"Couldn’t stop it. Try again.",isFailure:!0}}}function yb(e,t){return!Fo(e)||e.outcome==="not-running"&&t}function vb(e){switch(e){case"claude-code":return"Claude Code";case"codex":return"Codex";case"opencode":return"OpenCode";case"doe":return"DorkOS";default:return"Your agent"}}function kb(){const e=ue(d=>d.showTaskCelebrations),[t,n]=c.useState(null),[s,o]=c.useState(null),a=c.useRef(null),i=c.useRef(!1);c.useEffect(()=>{const d=window.matchMedia("(prefers-reduced-motion: reduce)");i.current=d.matches;const f=h=>{i.current=h.matches};return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[]),Sd({timeoutMs:tt.IDLE_TIMEOUT_MS,onIdle:c.useCallback(()=>{var d;(d=a.current)==null||d.setIdle(!0)},[]),onReturn:c.useCallback(()=>{var d,f;(d=a.current)==null||d.setIdle(!1),(f=a.current)==null||f.onUserReturn()},[])}),c.useEffect(()=>{const d=new Pd({enabled:e,miniProbability:tt.MINI_PROBABILITY,debounceWindowMs:tt.DEBOUNCE_WINDOW_MS,debounceThreshold:tt.DEBOUNCE_THRESHOLD,minTasksForMajor:tt.MIN_TASKS_FOR_MAJOR,idleTimeoutMs:tt.IDLE_TIMEOUT_MS,onCelebrate:f=>{i.current&&f.level==="major"?n({...f,level:"mini"}):n(f),f.level==="mini"&&o(f.taskId)}});return a.current=d,()=>d.destroy()},[e]);const l=c.useCallback((d,f)=>{var h;d.action==="update"&&d.task.status==="completed"&&d.task.id&&((h=a.current)==null||h.onTaskCompleted(d.task.id,f))},[]),u=c.useCallback(()=>{n(null),o(null)},[]);return{handleTaskEvent:l,activeCelebration:t,celebratingTaskId:s,clearCelebration:u}}function Rn(){return{tasks:new Map,statusTimestamps:new Map,legacyCreateCount:0}}function Cb(e){const t={};for(const[n,s]of Object.entries(e))s!==void 0&&s!==""&&(t[n]=s);return t}function Mn(e,t,n){switch(t.action){case"snapshot":{e.tasks.clear(),e.statusTimestamps.clear();const s=t.tasks??[t.task];for(const o of s)e.tasks.set(o.id,o),e.statusTimestamps.set(o.id,{status:o.status,since:n});return}case"create":{const s=t.task.id||`legacy:${e.legacyCreateCount++}`,o=s===t.task.id?t.task:{...t.task,id:s};e.tasks.set(s,o),e.statusTimestamps.set(s,{status:o.status,since:n});return}case"id_assigned":{const s=t.previousId;if(!s)return;const o=e.tasks.get(s);if(!o)return;const a=t.task.id;e.tasks.delete(s),e.tasks.set(a,{...o,id:a});const i=e.statusTimestamps.get(s);e.statusTimestamps.delete(s),e.statusTimestamps.set(a,i??{status:o.status,since:n});return}case"remove":{e.tasks.delete(t.task.id),e.statusTimestamps.delete(t.task.id);return}case"update":{if(!t.task.id)return;const s=e.tasks.get(t.task.id);if(!s)return;e.tasks.set(t.task.id,{...s,...Cb(t.task)}),t.task.status&&t.task.status!==s.status&&e.statusTimestamps.set(t.task.id,{status:t.task.status,since:n});return}}}function zr(e,t){var n;return(n=e.blockedBy)!=null&&n.length?e.blockedBy.some(s=>{const o=t.get(s);return o&&o.status!=="completed"}):!1}function Sb(e,t){return[...e].sort((n,s)=>{const o=n.status==="in_progress"?0:n.status==="pending"&&!zr(n,t)?1:n.status==="pending"?2:3,a=s.status==="in_progress"?0:s.status==="pending"&&!zr(s,t)?1:s.status==="pending"?2:3;return o-a})}const jb=10;let Br=0;function Ht(e){return e==="streaming"||e==="blocked"}function _b(e,t=!1){const n=Se(),o=Jo().cwd,a=ue(N=>N.enableMessagePolling),i=Uo(),[l,u]=c.useState(Rn()),d=Ro(e??""),[f,h]=c.useState(()=>!Ht(d)),m=c.useRef([]),x=c.useRef(0),{data:g}=Je({queryKey:["tasks",e,o],queryFn:async()=>{const N=++Br;return{...await n.getTasks(e,o??void 0),fetchOrder:N}},staleTime:3e4,refetchOnWindowFocus:!1,enabled:e!==null,refetchInterval:()=>!a||t?!1:i?Ye.ACTIVE_TAB_REFETCH_MS:Ye.BACKGROUND_TAB_REFETCH_MS}),C=c.useRef(null);c.useEffect(()=>{const N=`${e??""}::${o??""}`,T=C.current!==N;if(C.current=N,T&&(m.current=[],x.current=0,u(Rn())),!g||g.fetchOrder<=x.current)return;x.current=g.fetchOrder;const S=Rn();g.tasks.length>0&&Mn(S,{action:"snapshot",task:g.tasks[0],tasks:g.tasks},Date.now()),m.current=m.current.filter(({order:E})=>E>g.fetchOrder);for(const{event:E,receivedAt:w}of m.current)Mn(S,E,w);u(S)},[g,e,o]);const b=c.useCallback(N=>{const T=Date.now();N.action==="snapshot"&&(m.current=[]),m.current.push({order:++Br,event:N,receivedAt:T}),u(S=>{const E={tasks:new Map(S.tasks),statusTimestamps:new Map(S.statusTimestamps),legacyCreateCount:S.legacyCreateCount};return Mn(E,N,T),E})},[]),v=c.useRef(!1),k=c.useCallback(()=>{h(N=>(v.current=!N,!N))},[]),y=c.useRef(Ht(d));c.useEffect(()=>{const N=Ht(d);N!==y.current&&(y.current=N,N?v.current||h(!1):h(!0))},[d]);const p=c.useRef(null);c.useEffect(()=>{const N=`${e??""}::${o??""}`;if(p.current===N)return;p.current=N;const T=Ht(d);y.current=T,v.current=!1,h(!T)},[e,o,d]);const j=Array.from(l.tasks.values()),_=Sb(j,l.tasks),D=j.find(N=>N.status==="in_progress"),A=(D==null?void 0:D.activeForm)??null;return{tasks:_.slice(0,jb),taskMap:l.tasks,activeForm:A,isCollapsed:f,toggleCollapse:k,handleTaskEvent:b,statusTimestamps:l.statusTimestamps}}function wb(e){const t=c.useRef(null),[n,s]=c.useState(0),[o,a]=c.useState(!1),[i,l]=c.useState(0),u=c.useCallback(v=>{t.current=v,l(v&&"getOptionCount"in v?v.getOptionCount():0)},[]);c.useEffect(()=>{s(0),l(0),a(!1)},[e==null?void 0:e.toolCallId]);const d=c.useMemo(()=>e!=null&&e.interactiveType?{type:e.interactiveType,toolCallId:e.toolCallId}:null,[e]),f=c.useCallback(()=>{const v=t.current;v&&"approve"in v&&v.approve()},[]),h=c.useCallback(()=>{const v=t.current;v&&"alwaysAllow"in v&&v.alwaysAllow()},[]),m=c.useCallback(()=>{const v=t.current;v&&"deny"in v&&v.deny()},[]),x=c.useCallback(v=>{const k=t.current;k&&"toggleOption"in k&&(k.toggleOption(v),s(v),a(!0))},[]),g=c.useCallback(v=>{if(!o){a(!0);return}s(k=>{const y=t.current,p=y&&"getOptionCount"in y?y.getOptionCount():0;return p===0?k:v==="up"?k<=0?p-1:k-1:k>=p-1?0:k+1})},[o]),C=c.useCallback(v=>{const k=t.current;k&&"navigateQuestion"in k&&(k.navigateQuestion(v),s(0),a(!0),l(k.getOptionCount()))},[]),b=c.useCallback(()=>{const v=t.current;v&&"submit"in v&&v.submit()},[]);return jd({activeInteraction:d,onApprove:f,onAlwaysAllow:h,onDeny:m,onToggleOption:x,onNavigateOption:g,onNavigateQuestion:C,onSubmit:b,optionCount:i,focusedIndex:n}),{handleToolRef:u,focusedOptionIndex:o?n:-1}}function Wt(e,t,n){var a;const s=e.length;if(s===0)return 0;let o=(t%s+s)%s;for(let i=0;i<s;i++){if(!((a=e[o])!=null&&a.disabled))return o;o=(o+n+s)%s}return t}function Nb({commands:e,input:t,cursorPos:n}){const[s,o]=c.useState(!1),[a,i]=c.useState(""),[l,u]=c.useState(-1),d=c.useMemo(()=>a?e.map(j=>({cmd:j,rank:xf(a,j)})).filter(j=>j.rank.match).sort((j,_)=>j.rank.bucket-_.rank.bucket||_.rank.score-j.rank.score).map(({cmd:j,rank:_})=>({...j,matchedAlias:_.matchedAlias})):e,[e,a]),[f,h]=c.useState(null),m=f!==null&&f.query===a&&f.open===s?f.index:Wt(d,0,1),x=d[m],g=d.length===0||x!==void 0&&!x.disabled?m:Wt(d,0,1),C=c.useCallback((j,_)=>{const A=j.slice(0,_).match(/(^|\s)\/([\w:-]*)$/);return A?(o(!0),i(A[2]),u((A.index??0)+A[1].length),!0):(o(!1),!1)},[]),b=c.useCallback(j=>{const _=t.slice(0,l),D=t.slice(l+1+a.length);return o(!1),_+j.fullCommand+(D.startsWith(" ")?"":" ")+D},[t,a,l]),v=c.useCallback(()=>{h({query:a,open:s,index:Wt(d,g+1,1)})},[d,g,a,s]),k=c.useCallback(()=>{h({query:a,open:s,index:Wt(d,g-1,-1)})},[d,g,a,s]),y=c.useCallback(()=>{const j=d[g];return j&&!j.disabled?b(j):(j||o(!1),null)},[d,g,b]),p=c.useCallback(()=>{o(!1),i("")},[]);return{showCommands:s,setShowCommands:o,commandQuery:a,selectedIndex:g,filteredCommands:d,slashTriggerPos:l,detectCommandTrigger:C,handleCommandSelect:b,handleArrowUp:k,handleArrowDown:v,handleKeyboardSelect:y,resetCommand:p}}function Eb({fileEntries:e,input:t,cursorPos:n}){const[s,o]=c.useState(!1),[a,i]=c.useState(""),[l,u]=c.useState(0),[d,f]=c.useState(-1),h=c.useMemo(()=>s?a?e.map(k=>({...k,...Vt(a,k.path)})).filter(k=>k.match).sort((k,y)=>y.score-k.score).slice(0,50):e.slice(0,50).map(k=>({...k,indices:[]})):[],[e,a,s]);c.useEffect(()=>{u(0)},[a,s]),c.useEffect(()=>{h.length>0&&l>=h.length&&u(h.length-1)},[h.length,l]);const m=c.useCallback((k,y)=>{const j=k.slice(0,y).match(/(^|\s)@([\w./:-]*)$/);return j?(o(!0),i(j[2]),f((j.index??0)+j[1].length),!0):(o(!1),!1)},[]),x=c.useCallback(k=>{const y=t.slice(0,d),p=t.slice(d+1+a.length);if(k.isDirectory){const _=y+"@"+k.path+p,D=y.length+1+k.path.length;return i(k.path),u(0),{newValue:_,newCursorPos:D,keepOpen:!0}}const j=y+"@"+k.path+" "+p;return o(!1),{newValue:j,keepOpen:!1}},[t,d,a]),g=c.useCallback(()=>{u(k=>h.length===0?0:(k+1)%h.length)},[h.length]),C=c.useCallback(()=>{u(k=>h.length===0?0:(k-1+h.length)%h.length)},[h.length]),b=c.useCallback(()=>h.length>0&&l<h.length?x(h[l]):(o(!1),null),[h,l,x]),v=c.useCallback(()=>{o(!1),i("")},[]);return{showFiles:s,setShowFiles:o,fileQuery:a,fileSelectedIndex:l,filteredFiles:h,fileTriggerPos:d,detectFileTrigger:m,handleFileSelect:x,handleArrowUp:C,handleArrowDown:g,handleKeyboardSelect:b,resetFiles:v}}function Db({input:e,setInput:t,commands:n,fileEntries:s}){const[o,a]=c.useState(0),i=Nb({commands:n,input:e,cursorPos:o}),l=Eb({fileEntries:s,input:e,cursorPos:o}),u=c.useCallback((_,D)=>{if(l.detectFileTrigger(_,D)){i.setShowCommands(!1);return}if(i.detectCommandTrigger(_,D)){l.setShowFiles(!1);return}l.setShowFiles(!1),i.setShowCommands(!1)},[l,i]),d=c.useRef({value:e,cursor:0});c.useEffect(()=>{d.current.value=e},[e]);const f=c.useCallback(_=>{t(_),d.current={value:_,cursor:d.current.cursor||_.length},u(_,d.current.cursor)},[t,u]),h=c.useCallback(_=>{a(_),d.current={value:d.current.value,cursor:_},u(d.current.value,_)},[u]),m=c.useCallback(_=>{const D=i.handleCommandSelect(_);t(D)},[i,t]),x=c.useCallback(_=>{const D=l.handleFileSelect(_);t(D.newValue),D.newCursorPos!==void 0&&a(D.newCursorPos)},[l,t]),g=c.useCallback(()=>{l.showFiles?l.handleArrowDown():i.handleArrowDown()},[l,i]),C=c.useCallback(()=>{l.showFiles?l.handleArrowUp():i.handleArrowUp()},[l,i]),b=c.useCallback(()=>{if(l.showFiles){const _=l.handleKeyboardSelect();_&&(t(_.newValue),_.newCursorPos!==void 0&&a(_.newCursorPos))}else if(i.showCommands){const _=i.handleKeyboardSelect();_&&t(_)}},[l,i,t]),v=c.useCallback(()=>{i.setShowCommands(!1),l.setShowFiles(!1)},[i,l]),k=i.showCommands||l.showFiles,y=l.showFiles&&l.filteredFiles.length>0||i.showCommands&&i.filteredCommands.length>0,p=l.showFiles?"file-palette-listbox":i.showCommands?"command-palette-listbox":void 0,j=l.showFiles&&l.filteredFiles.length>0?`file-item-${l.fileSelectedIndex}`:i.showCommands&&i.filteredCommands.length>0?`command-item-${i.selectedIndex}`:void 0;return{commands:{show:i.showCommands,filtered:i.filteredCommands,selectedIndex:i.selectedIndex},files:{show:l.showFiles,filtered:l.filteredFiles,selectedIndex:l.fileSelectedIndex},isPaletteOpen:k,paletteHasResults:y,activeDescendantId:j,paletteListboxId:p,handleInputChange:f,handleCursorChange:h,handleArrowUp:C,handleArrowDown:g,handleKeyboardSelect:b,handleCommandSelect:m,handleFileSelect:x,dismissPalettes:v}}function Tb(e,t,n){const s=ue(i=>i.setIsStreaming),o=ue(i=>i.setIsWaitingForUser),a=ue(i=>i.setIsTextStreaming);c.useEffect(()=>(s(e==="streaming"),()=>s(!1)),[e,s]),c.useEffect(()=>(o(t),()=>o(!1)),[t,o]),c.useEffect(()=>(a(n),()=>a(!1)),[n,a])}function Ab(){const e=Se(),t=ue(m=>m.selectedCwd),[n,s]=c.useState([]),o=c.useCallback(m=>{const x=m.map(g=>({id:crypto.randomUUID(),file:g,status:"pending",progress:0}));s(g=>[...g,...x])},[]),a=c.useCallback(m=>{s(x=>x.filter(g=>g.id!==m))},[]),i=c.useCallback(()=>{s([])},[]),l=c.useCallback(m=>{s(x=>x.map(g=>g.id===m&&g.status==="error"?{...g,status:"pending",progress:0,error:void 0}:g))},[]),u=c.useRef(null),d=jt({meta:{suppressErrorToast:!0},mutationFn:async m=>{if(!t)throw new Error("No working directory selected");s(b=>b.map(v=>m.some(k=>k.id===v.id)?{...v,status:"uploading"}:v));const x=b=>{s(v=>v.map(k=>k.status==="uploading"?{...k,progress:b.percentage}:k))},g=new AbortController;u.current=g;const C=m.map(b=>b.file);return e.uploadFiles(C,t,x,g.signal)},onSettled:()=>{u.current=null},onSuccess:(m,x)=>{s(g=>g.map(C=>{const b=x.findIndex(v=>v.id===C.id);return b===-1?C:{...C,status:"uploaded",progress:100,result:m[b]}}))},onError:m=>{s(x=>x.map(g=>g.status==="uploading"?{...g,status:"error",error:m.message}:g))}}),f=c.useCallback(()=>{var m;(m=u.current)==null||m.abort()},[]),h=c.useCallback(async()=>{const m=n.filter(b=>b.status==="error");if(m.length>0)throw new Error(m.length===1?`${m[0].file.name} did not upload. Retry it or remove it, then send again.`:`${m.length} attachments did not upload. Retry them or remove them, then send again.`);const x=n.filter(b=>b.status==="uploaded"&&b.result).map(b=>b.result.savedPath),g=n.filter(b=>b.status==="pending");if(g.length===0)return x;const C=await d.mutateAsync(g);return[...x,...C.map(b=>b.savedPath)]},[n,d]);return{pendingFiles:n,addFiles:o,removeFile:a,retryFile:l,clearFiles:i,cancelUpload:f,uploadAndGetPaths:h,hasPendingFiles:n.length>0,hasFailedUpload:n.some(m=>m.status==="error"),isUploading:d.isPending}}const On=new Set,In=new Set;function Fb(e,t){return`${e}\0${t}`}function Rb({sessionId:e,prompt:t,autoSend:n,input:s,setInput:o,messageCount:a,hydrated:i,status:l,submitBlocked:u=!1,submit:d,onSeeded:f,onConsumed:h}){const m=t!=null&&t.trim()?t:void 0,x=e&&m?Fb(e,m):null;c.useEffect(()=>{if(!(!x||!m)&&!On.has(x)&&i){if(On.add(x),s.length>0||a>0){In.add(x),h==null||h();return}o(m),f==null||f(),n||h==null||h()}},[x,m,n,s,i,a,o,f,h]),c.useEffect(()=>{!x||!m||!n||In.has(x)||On.has(x)&&s===m&&(!i||a>0||l==="streaming"||u||(In.add(x),h==null||h(),d()))},[x,m,n,s,i,a,l,u,d,h])}const qr=yc-256,Ur=`
52
- …(context truncated)`,Hr={"/":"the home team room","/activity":"the activity feed","/team":"the team page","/session":"a chat session","/tasks":"the scheduled-work page","/channels":"a channel","/workspaces":"the workspaces page","/connections":"the connections page","/marketplace":"the marketplace","/feedback-requests":"the feedback requests page"};function Mb(e){const t=`/${e.split("/").filter(Boolean)[0]??""}`;return Hr[e]??Hr[t]??`the ${e} page`}function Ob(e){const t=['The person opened this conversation by pressing "Ask DorkBot" in the DorkOS sidebar, so they are asking for help with DorkOS itself. Greet them with what you can see below and offer the next step; do not repeat this back to them.'];e.originPath!==null&&t.push(`They were on ${Mb(e.originPath)} (${e.originPath}).`),t.push(e.agentNames.length===1?"They have 1 agent registered.":`They have ${e.agentNames.length} agents registered.`),e.agentNames.length>0&&t.push(`Their agents: ${e.agentNames.join(", ")}.`),e.version!==null&&t.push(e.updateReady?`They are running DorkOS v${e.version}, and a newer version is ready to install.`:`They are running DorkOS v${e.version}.`),e.erroredSessionIds.length>0&&t.push(`These conversations ended in an error and may be what they want help with: ${e.erroredSessionIds.join(", ")}.`);const n=t.join(`
53
- `);return n.length<=qr?n:n.slice(0,qr-Ur.length)+Ur}const Ib="dorkbot-help",Gt=new Set;function $b({sessionId:e,seed:t,messageCount:n,hydrated:s,onConsumed:o}){const a=t===Ib&&e!==null,{data:i}=vc({enabled:a}),{data:l}=io(),u=Ct(kc(m=>Object.entries(m.statuses).filter(([,x])=>x.lifecycle==="error").map(([x])=>x))),d=c.useRef({agentNames:[],version:null,updateReady:!1,erroredSessionIds:[]}),f=c.useRef({armed:a,sessionId:e,messageCount:n}),h=c.useRef(o);return c.useEffect(()=>{const m=(l==null?void 0:l.latestVersion)??null,x=(l==null?void 0:l.version)??null;d.current={agentNames:((i==null?void 0:i.agents)??[]).map(g=>g.displayName??g.name),version:x,updateReady:m!==null&&x!==null&&Ru(m,x),erroredSessionIds:u}},[i,l,u]),c.useEffect(()=>{f.current={armed:a,sessionId:e,messageCount:n},h.current=o},[a,e,n,o]),c.useEffect(()=>{!a||e===null||!s||n===0||Gt.has(e)||(Gt.add(e),o==null||o())},[a,e,s,n,o]),c.useCallback(()=>{var x;const m=f.current;if(!(!m.armed||m.sessionId===null)&&!(m.messageCount>0)&&!Gt.has(m.sessionId))return Gt.add(m.sessionId),(x=h.current)==null||x.call(h),Ob({...d.current,originPath:Cc()})},[])}function Pb(e,t,n,s=!1){if(e!=="error"||t||s)return!1;let o=-1;for(let i=n.length-1;i>=0;i--)if(n[i].role==="user"){o=i;break}return!n.slice(o+1).some(i=>i.parts.some(l=>l.type==="error"&&l.code!==jo))}const Lb=4e3;function zb(e){const t=e.approvalDisplayName||dt(e.toolName,e.input??"");return e.approvalOutcome==="allowed"?`Allowed ${t}. Recorded in the chat.`:e.approvalOutcome==="denied"?`Didn’t allow ${t}. Recorded in the chat.`:`${t} wasn’t answered in time, so it didn’t run. Recorded in the chat.`}function Bb(e,t){const n=c.useRef(null),s=c.useRef(null),[o,a]=c.useState({text:"",nonce:0});return c.useEffect(()=>{s.current!==t&&(s.current=t,n.current=null);const i=e.filter(d=>d.type==="tool_call"&&d.approvalOutcome!==void 0);if(n.current===null){n.current=new Set(i.map(d=>d.toolCallId));return}const l=i.filter(d=>!n.current.has(d.toolCallId));if(l.length===0)return;for(const d of l)n.current.add(d.toolCallId);const u=l.length===1?zb(l[0]):`Answered ${l.length} permission requests. Recorded in the chat.`;a(d=>({text:u,nonce:d.nonce+1}))},[e,t]),c.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(l=>({text:"",nonce:l.nonce})),Lb);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}​`}const Wr=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"],Gr=5e3,qb=1e3,Ub=1500,Hb=new Set;function Wb(e){const t=c.useRef(new Map),n=Mo({byTask:new Map,assigned:0}),[s,o]=c.useState(Hb),[,a]=c.useState(0),i=c.useMemo(()=>{const u=new Map;for(const d of e)for(const f of d.parts)f.type==="background_task"&&u.set(f.taskId,f);return u},[e]);c.useEffect(()=>{if(!Array.from(i.values()).some(f=>f.taskType==="bash"&&f.status==="running"&&Date.now()-f.startedAt<Gr))return;const d=setInterval(()=>{a(f=>f+1)},qb);return()=>clearInterval(d)},[i]);const l=c.useRef(new Set);return c.useLayoutEffect(()=>{for(const[u,d]of i)t.current.get(u)==="running"&&d.status!=="running"&&!Vs(d)&&o(h=>h.has(u)?h:new Set(h).add(u)),t.current.set(u,d.status)},[i]),c.useEffect(()=>{for(const u of s)l.current.has(u)||(l.current.add(u),setTimeout(()=>{l.current.delete(u),o(d=>{if(!d.has(u))return d;const f=new Set(d);return f.delete(u),f})},Ub))},[s]),c.useMemo(()=>{const u=Date.now(),d=[],f=n.read();let h=f.assigned;for(const[m,x]of i){const g=x.status==="running",C=s.has(m);if(!g&&!C||x.taskType==="bash"&&g&&u-x.startedAt<Gr)continue;let b=f.byTask.get(m);b===void 0&&(b=Wr[h%Wr.length],h+=1,f.byTask.set(m,b),n.write({byTask:f.byTask,assigned:h})),d.push({taskId:x.taskId,taskType:x.taskType,status:x.status,color:b,startedAt:x.startedAt,description:x.description,toolUses:x.toolUses,lastToolName:x.lastToolName,durationMs:x.durationMs,summary:x.summary,command:x.command,ambient:Vs(x)})}return d},[i,s,n])}const Gb=new Set(["streaming","blocked"]);function Vb(e,t){return e.length===0||e[0].waitingOn!==void 0||t&&Gb.has(t)?e:e.slice(1)}function $n(e,t,n){return`${e} ${e===1?t:n}`}const Vr={"delivery-owed":"a helper’s report","waiting-on-person":"your answer","timer-pending":"a reminder the agent set"},Kb={"timer-pending":"Switching now cancels the reminder."};function Qb(e){const{agents:t,shells:n,other:s}=e.holding,o=[t>0?$n(t,"helper","helpers"):void 0,n>0?$n(n,"command","commands"):void 0,s>0?$n(s,"background job","background jobs"):void 0].filter(d=>d!==void 0),a=o.length===0?void 0:o.length===1?o[0]:`${o.slice(0,-1).join(", ")} and ${o.at(-1)}`,i=e.pins,l=i.includes("cwd")&&e.targetFolderName?`moves to ${e.targetFolderName}`:i.includes("agentIdentity")?"switches agents":i.includes("systemPromptAppend")?"loads new instructions":"applies new settings";return{line:`${a!==void 0?`Held for ${a}.`:e.because!==void 0&&Vr[e.because]!==void 0?`Held for ${Vr[e.because]}.`:"Held until the agent is free."} Sending it ${l}.`,switchHint:a!==void 0?`Switching now stops ${a}.`:(e.because!==void 0?Kb[e.because]:void 0)??"Switching now stops what the agent is doing."}}const Yb={"session-idle":null,unsupported:"Queued. This agent can’t take a message mid-task.","not-steerable":"Couldn’t cut in. It’s waiting in line.","not-stageable":null,"turn-owned-elsewhere":"Couldn’t cut in: something else is running it. It’s waiting in line.","pending-interaction":"Queued. The agent needs your answer first."};function Xb(e){return e!=null&&e.degradedBecause?Yb[e.degradedBecause]:null}function Kr(e){return(e==null?void 0:e.code)==="QUEUED_MESSAGE_NOT_FOUND"}function Jb({sessionId:e,waiting:t,onEnqueue:n}){const s=Se(),o=Sc(e??""),[a,i]=c.useState(null),l=c.useMemo(()=>t.map(p=>({id:p.id,content:p.content,mine:s.clientId===void 0||p.enqueuedBy===s.clientId,notice:Xb(o[p.id]),...p.waitingOn?{waiting:Qb(p.waitingOn)}:{}})),[t,o,s.clientId]),u=c.useMemo(()=>{if(a===null)return null;const p=l.findIndex(j=>j.id===a);return p===-1?null:p},[a,l]),d=c.useCallback(()=>{var p;if(e)return(p=we.getState().getSession(e).queuedMessages[0])==null?void 0:p.id},[e]),f=c.useCallback((p,j)=>{p().catch(_=>{Kr(_)||Te.error(j)})},[]),h=c.useCallback(async p=>{const j=p.trim();return!j||!e?!1:n(j)},[e,n]),m=c.useCallback((p,j)=>{e&&f(()=>s.updateQueuedMessage(e,p,{content:j}),"Couldn’t save that change")},[e,s,f]),x=c.useCallback(p=>{i(j=>j===p?null:j),e&&f(()=>s.removeQueuedMessage(e,p),"Couldn’t take that message off the queue")},[e,s,f]),g=c.useCallback((p,j)=>{if(!e)return;const _=D=>s.updateQueuedMessage(e,p,{move:{before:D}});f(async()=>{try{await _(j)}catch(D){if(!Kr(D))throw D;const A=d();if(A===void 0||A===p)return;await _(A)}},"Couldn’t move that message")},[e,s,f,d]),C=c.useCallback(p=>l.findIndex(_=>_.id===p)<=0?!1:(i(_=>_===p?null:_),g(p,l[0].id),!0),[l,g]),b=c.useCallback(p=>{const j=l.findIndex(_=>_.id===p);j<=0||g(p,l[j-1].id)},[l,g]),v=c.useCallback(p=>{const j=l.find(_=>_.id===p);return j?(i(p),j.content):null},[l]),k=c.useCallback(()=>{i(null)},[]),y=c.useCallback(p=>{a!==null&&(m(a,p),i(null))},[a,m]);return{queue:l,editingId:a,editingIndex:u,addToQueue:h,removeFromQueue:x,sendNow:C,moveUp:b,startEditing:v,cancelEditing:k,saveEditing:y,updateQueued:m}}function Ya(e,t){return e===null?null:`${e} ${t??""}`}function Zb({input:e,setInput:t,sessionId:n,selectedCwd:s,waiting:o,onEnqueue:a,onSteer:i,onStage:l,tryNativeCommand:u,chatInputRef:d}){const f=c.useRef(""),h=c.useRef(null),m=Ya(n,s);c.useEffect(()=>{f.current="",h.current=null},[m]);const x=Jb({sessionId:n,waiting:o,onEnqueue:a}),g=x.cancelEditing;c.useEffect(()=>{g()},[m,g]);const C=c.useCallback(()=>{const F=x.editingId;if(F===null)return;const I=e.trim();I&&(x.updateQueued(F,I),Ox(I)&&Te.warning("Saved as a command. It runs instead of sending."))},[e,x]),b=Gs(x.editingId),v=Gs(x.updateQueued);c.useEffect(()=>{const F=n;return()=>{const I=b.read();if(I===null||!F)return;const z=ie.getState(),B=z.getSession(F).input.trim();B&&v.read()(I,B),z.updateSession(F,{input:f.current})}},[m]);const k=c.useCallback(F=>{const I=e.trim();if(!I)return;const z=u(I);if(z.handled){if(!z.ran)return;z.confirmed?Zn(n,I,z.confirmed):t("");return}if(h.current===I)return;h.current=I,it.getState().recordOpened("session",n),s&&it.getState().recordOpened("agent",s);const B=F(I);B.finally(()=>{h.current===I&&(h.current=null)}),Zn(n,I,B)},[e,s,n,t,u]),y=c.useCallback(()=>k(F=>x.addToQueue(F)),[k,x]),p=c.useCallback(()=>{i&&k(i)},[k,i]),j=c.useCallback(()=>{l&&k(l)},[k,l]),_=c.useCallback(F=>{var B,J;if(x.editingId===F){(B=d.current)==null||B.focus();return}const I=x.editingId!==null;I&&C();const z=x.startEditing(F);z!==null&&(I||(f.current=e),t(z),(J=d.current)==null||J.focus())},[e,x,C,t,d]),D=c.useCallback(()=>{if(x.editingId===null)return;const F=e.trim();if(!F)return;const I=u(F);if(I.handled){I.ran&&(x.cancelEditing(),t(f.current));return}x.saveEditing(F),t(f.current)},[e,x,t,u]),A=c.useCallback(()=>{x.cancelEditing(),t(f.current)},[x,t]),N=c.useCallback(F=>{x.editingId===F&&t(f.current),x.removeFromQueue(F)},[x,t]),T=c.useCallback(F=>{const I=x.editingId===F;I&&C(),x.sendNow(F)&&I&&t(f.current)},[x,C,t]),S=c.useCallback(F=>{x.moveUp(F)},[x]),E=c.useCallback(F=>{var B;const I=(B=x.queue[F])==null?void 0:B.id;if(I!==void 0&&I===x.editingId)return;C();const z=I===void 0?null:x.startEditing(I);if(z===null){x.cancelEditing(),t(f.current);return}t(z)},[x,C,t]),w=c.useCallback(()=>{C(),x.cancelEditing(),t(f.current)},[C,x,t]),M=c.useCallback(()=>{const{editingIndex:F,queue:I}=x;if(F===null){if(I.length===0)return;f.current=e,E(I.length-1)}else F>0?E(F-1):w()},[E,e,w,x]),R=c.useCallback(()=>{const{editingIndex:F,queue:I}=x;F!==null&&(F<I.length-1?E(F+1):w())},[E,w,x]);return{queue:x.queue,editingId:x.editingId,editingIndex:x.editingIndex,handleQueue:y,handleSteer:p,handleStage:j,handleQueueEdit:_,handleQueueSaveEdit:D,handleQueueCancelEdit:A,handleQueueRemove:N,handleQueueSend:T,handleQueueMoveUp:S,handleQueueNavigateUp:M,handleQueueNavigateDown:R,leaveQueueForStop:w}}const ey=5e3,Qr=3;function Xa(){try{const e=Number(localStorage.getItem(Oo.PLACEHOLDER_HINT_CYCLES));return Number.isFinite(e)&&e>0?e:0}catch{return 0}}function ty(){const e=Xa()+1;try{localStorage.setItem(Oo.PLACEHOLDER_HINT_CYCLES,String(e))}catch{}return e}function ny(e){const t=[...e];for(let n=t.length-1;n>0;n--){const s=Math.floor(Math.random()*(n+1));[t[n],t[s]]=[t[s],t[n]]}return t}function sy({defaultText:e,hints:t,enabled:n,intervalMs:s=ey}){const[o]=c.useState(()=>t.length>0?ny(t):[]),[a,i]=c.useState(()=>Xa()>=Qr),[l,u]=c.useState({key:0,hintIndex:-1}),d=c.useRef(0),f=c.useRef(0),h=c.useRef(!1);return c.useEffect(()=>{if(a||!n||t.length===0){h.current&&(h.current=!1,d.current+=1,u({key:d.current,hintIndex:-1}));return}const x=setInterval(()=>{if(d.current+=1,h.current=!h.current,!h.current){u({key:d.current,hintIndex:-1});return}const g=f.current%t.length;f.current+=1,f.current%t.length===0&&ty()>=Qr&&i(!0),u({key:d.current,hintIndex:g})},s);return()=>clearInterval(x)},[n,t.length,s,a]),{text:l.hintIndex>=0?o[l.hintIndex]??e:e,key:l.key}}const Pn=/[.!?…:](?=\s|$)|\n/g;function Yr(e,t,n){const s=e.startsWith(t)?t.length:0,o=e.slice(0,s),a=e.slice(s);if(a.trim()==="")return{chunk:"",announced:o};if(n)return{chunk:a.trim(),announced:e};Pn.lastIndex=0;let i=-1;for(let l=Pn.exec(a);l!==null;l=Pn.exec(a))i=l.index+l[0].length;return i===-1?{chunk:"",announced:o}:{chunk:a.slice(0,i).trim(),announced:e.slice(0,s+i)}}const ry=1500,oy=4e3,ay=400;function iy({messageId:e,text:t,isStreaming:n}){const s=c.useRef(new Map),[o,a]=c.useState({text:"",nonce:0});return c.useEffect(()=>{if(e===void 0)return;if(s.current.get(e)===void 0){if(!n)return;s.current.clear(),s.current.set(e,{announced:t.length<=ay?"":t})}const l=s.current.get(e),{chunk:u,announced:d}=Yr(t,l.announced,!1);l.announced=d,u!==""&&a(h=>({text:u,nonce:h.nonce+1}));const f=setTimeout(()=>{const h=Yr(t,l.announced,!0);l.announced=h.announced,h.chunk!==""&&a(m=>({text:h.chunk,nonce:m.nonce+1}))},ry);return()=>clearTimeout(f)},[e,t,n]),c.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(l=>({text:"",nonce:l.nonce})),oy);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}​`}const Ja={reactions:!1,threads:!1,runWith:!0,attachments:!0,mentions:!1,streamHealth:!1,presence:!1,turnStatus:!0,asks:!0};function ly(e){var t;(t=e==null?void 0:e.querySelector('[data-testid="model-config-trigger"]'))==null||t.click()}const Xr=new WeakMap;function cy(e,t,n,s,o=!0){const a=new Set(t),i=new Set(n.flatMap(f=>f.roomMessage?[f.roomMessage.entryId]:[]));let l;const u=o?null:my(n),d=[];for(const f of e){if(f.kind!=="post"||f.threadRootEntryId||f.sessionId!==null&&a.has(f.sessionId)&&(l??(l=dy(n)),l.has(f.body.text)||!o&&(u===null||Date.parse(f.createdAt)<u))||i.has(f.id))continue;let h=Xr.get(f);if(!h){const m=f.body.text;h={id:`direct-note-${f.id}`,role:s.has(f.authorId)?"assistant":"user",content:m,parts:[{type:"text",text:m}],timestamp:f.createdAt,_directNote:{roomId:f.roomId,entryId:f.id,seq:f.seq}},Xr.set(f,h)}d.push(h)}return d}const uy=/(?:^|[_.])(?:post_to_room|relay_notify_user)$/;function dy(e){const t=new Set;for(const n of e){if(n.role!=="assistant")continue;const s=[];for(const o of n.parts??[])if(o.type==="text")t.add(o.text),t.add(o.text.trim()),s.push(o.text.trim());else if(o.type==="tool_call"&&o.input&&uy.test(o.toolName))for(const a of fy(o.input))t.add(a);s.length>1&&t.add(s.filter(Boolean).join(`
54
-
55
- `).trim())}return t}function fy(e){try{const t=JSON.parse(e);return t===null||typeof t!="object"?[]:Object.values(t).filter(n=>typeof n=="string")}catch{return[]}}function my(e){let t=null;for(const n of e){const s=Date.parse(n.timestamp);!Number.isNaN(s)&&(t===null||s<t)&&(t=s)}return t}function py(e,t){if(t.length===0)return e;const n=[];let s=0;for(const o of e){const a=o.timestamp==="",i=Date.parse(o.timestamp);for(;s<t.length&&(a||!Number.isNaN(i)&&Date.parse(t[s].timestamp)<i);)n.push(t[s]),s+=1;n.push(o)}for(;s<t.length;)n.push(t[s++]);return n}function hy(e,t,n=!0){if(!t||t.entries.length===0)return{messages:e,lastSeenBeforeUnread:null,unreadFromStart:!1};const s=cy(t.entries,t.sessionIds,e,t.agentAuthorIds,n),o=py(e,s),{readSeq:a}=t,i=a===null?-1:o.findIndex(l=>l._directNote!==void 0&&l.role==="assistant"&&l._directNote.seq>a);return{messages:o,lastSeenBeforeUnread:i>0?o[i-1].id:null,unreadFromStart:i===0}}function gy(e){var f,h,m;const t=jc(e),n=((f=t.data)==null?void 0:f.roomId)??null,s=_c(n),o=wc(n),a=s.data,i=o.data;Ou(n,i!==void 0),Nc(a,i??Jr);const l=((h=a==null?void 0:a.members.find(x=>x.author.id===a.viewerAuthorId))==null?void 0:h.lastReadSeq)??null,u=by(n,l),d=((m=t.data)==null?void 0:m.sessionIds)??xy;return c.useMemo(()=>{const x=s.isError||o.isError,g=n===null||x||i!==void 0&&u!==null;return{roomId:n,entries:i??Jr,sessionIds:d,agentAuthorIds:new Set(((a==null?void 0:a.members)??[]).filter(C=>C.author.kind==="agent").map(C=>C.author.id)),readSeq:u,ready:e===null||t.isError||t.isFetched&&g}},[e,t.isError,t.isFetched,n,a,i,d,u,s.isError,o.isError])}const xy=[],Jr=[];function by(e,t){const[n,s]=c.useState({key:null,value:null});return n.key===e&&n.value!==null?n.value:e===null||t===null?null:(s({key:e,value:t}),t)}function Zr(e){return e>=1e3?`~${(e/1e3).toFixed(1)}k tokens`:`~${Math.round(e)} tokens`}function yy(e){const{formatted:t}=qo(e.status==="streaming"?e.streamStartTime:null),n=mo(e.permissionMode),s=c.useRef(e.status),o=c.useRef(t),a=c.useRef(e.estimatedTokens),[i,l]=c.useState(!1);return c.useEffect(()=>{e.status==="streaming"&&(o.current=t,a.current=e.estimatedTokens,s.current!=="streaming"&&l(!1))},[e.status,t,e.estimatedTokens]),c.useEffect(()=>{s.current==="streaming"&&e.status==="idle"&&a.current>0&&l(!0),s.current=e.status},[e.status]),c.useEffect(()=>{if(!i)return;const u=setTimeout(()=>l(!1),tn.TURN_COMPLETE_DISMISS_MS);return()=>clearTimeout(u)},[i]),Iu({capabilities:Ja,asks:e.asks??Po,stalled:!1,presence:$u,turn:{status:e.status,isWaitingForUser:e.isWaitingForUser,waitingType:e.waitingType,operationProgress:e.operationProgress==null?null:{message:e.operationProgress.message??null,determinate:e.operationProgress.determinate,percent:e.operationProgress.percent??null},systemStatus:e.systemStatus??null,elapsed:t,activity:e.activity,tokens:Zr(e.estimatedTokens),isBypass:n,showComplete:i,lastElapsed:o.current,lastTokens:Zr(a.current)}})}function vy(e){const{sessionId:t,placeholder:n,files:s}=e,o=c.useRef(e);c.useEffect(()=>{o.current=e});const a=c.useCallback(C=>o.current.files.addFiles(C),[]),i=c.useCallback(C=>o.current.files.removeFile(C),[]),l=c.useCallback(C=>o.current.files.retryFile(C),[]),u=c.useCallback(()=>o.current.files.cancelUpload(),[]),{pendingFiles:d,hasFailedUpload:f,isUploading:h}=s,m=c.useMemo(()=>({staged:d,add:a,remove:i,retry:l,cancel:u,hasFailed:f,isUploading:h,holdsSendWhileUploading:!0}),[d,f,h,a,i,l,u]),x=c.useCallback(async C=>{await o.current.submit(C.text)},[]),g=c.useCallback(async C=>{if(!await o.current.enqueue(C.text))throw new Error("Couldn’t queue that message. Try again.")},[]);return c.useMemo(()=>({kind:"session",id:t,placeholder:n,canSend:t!=="",...t===""?{canSendReason:"Pick a chat, or start a new one."}:{},send:x,queue:g,attachments:m}),[t,n,m,x,g])}function ky({error:e,composerAgent:t,onRetry:n}){return e.code===Co&&e.agentId?r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(Zo,{agentId:e.agentId,...(t==null?void 0:t.id)===e.agentId?{agentName:sn(t,"This agent")}:{}})}):r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(an,{message:e.message,heading:e.heading,subtext:e.message,onRetry:e.retryable?n:void 0})})}const Cy={duration:.16,delay:.08,ease:[.16,1,.3,1]},Sy={duration:0};function jy({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:o,onToolDecided:a,queueDepth:i=0,allowsDenyReason:l=!0}){const u=g=>a(t.toolCallId,g),d=Ae(),{answerAll:f,isAnswering:h,error:m}=Ec(),x=c.useMemo(()=>n.map(g=>({sessionId:e,cwd:"",interaction:{type:"approval",id:g.toolCallId,startedAt:g.approvalStartedAt??0,remainingMs:g.timeoutMs??0,toolName:g.toolName,input:g.input??"",hasSuggestions:g.approvalHasSuggestions??!1}})),[n,e]);return r.jsxs(r.Fragment,{children:[n.length>=2&&r.jsx(Dc,{className:"mb-1.5",headline:`${n.length} tools are waiting on you`,items:n.map(g=>({id:g.toolCallId,line:dt(g.toolName,g.input??"")})),onAllowAll:()=>void f(x,"allow"),onDenyAll:()=>void f(x,"deny"),isAnswering:h,error:m}),r.jsx(de,{mode:"wait",initial:!1,children:r.jsx(V.div,{initial:d?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:d?Sy:Cy,children:t.interactiveType==="approval"?r.jsx(ea,{ref:o,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:u,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalRemainingMs:t.approvalRemainingMs,approvalParked:t.approvalParked,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions,approvalAlwaysAllowScope:t.approvalAlwaysAllowScope,allowsDenyReason:l}):t.interactiveType==="question"&&t.questions?r.jsx(_o,{ref:o,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:u}):null},t.toolCallId)}),i>0&&r.jsx("p",{className:"text-muted-foreground px-1 pt-2 text-xs",children:i===1?"1 message sends once you answer.":`${i} messages send once you answer.`})]})}function _y({filteredCommands:e,selectedIndex:t,onSelect:n}){const s=c.useMemo(()=>{const o=[],a=new Map;let i=0;for(const l of e){const u=l.namespace??"built-in";a.has(u)||a.set(u,[]),a.get(u).push({cmd:l,index:i++})}for(const[l,u]of a)o.push({namespace:l,items:u});return o},[e]);return c.useEffect(()=>{const o=document.getElementById(`command-item-${t}`);o&&o.scrollIntoView({block:"nearest"})},[t]),r.jsx(V.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:o=>o.preventDefault(),children:r.jsx("div",{id:"command-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No commands found."}):s.map(({namespace:o,items:a},i)=>r.jsxs("div",{children:[i>0&&r.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),r.jsx("div",{className:"text-muted-foreground/70 text-2xs px-2 pt-1.5 pb-1 font-medium tracking-wide uppercase",children:o}),a.map(({cmd:l,index:u})=>{const d=u===t,f=l.disabled===!0;return r.jsxs("div",{id:`command-item-${u}`,role:"option","aria-selected":d,"aria-disabled":f,"data-selected":d,"data-disabled":f,tabIndex:d?0:-1,onClick:()=>{f||n(l)},onKeyDown:h=>{h.key==="Enter"&&!f&&n(l)},className:f?"cursor-not-allowed rounded-md px-2 py-1.5 opacity-45":"data-[selected=true]:bg-accent hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 transition-colors duration-100",children:[r.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[r.jsx("span",{className:"text-foreground text-control shrink-0 font-mono font-medium",children:l.fullCommand}),l.argumentHint&&r.jsx("span",{className:"text-muted-foreground/50 shrink-0 font-mono text-xs",children:l.argumentHint}),f&&l.disabledReason?r.jsx("span",{className:"text-muted-foreground/70 text-2xs ml-auto shrink-0",children:l.disabledReason}):l.matchedAlias&&r.jsxs("span",{className:"text-muted-foreground/60 text-2xs ml-auto shrink-0 font-mono italic",children:["matched /",l.matchedAlias.replace(/^\//,"")]})]}),l.description&&r.jsx("p",{className:"text-muted-foreground mt-0.5 truncate text-xs leading-normal",children:l.description})]},l.fullCommand)})]},o))})})}function wy(e,t,n,s){return e!==null?`Edit queued message ${e+1} of ${n}. Press Enter to save`:t&&n>0?`Compose another (${n} queued)`:t?"Compose next. It sends when ready":s}function Ny({chatInputRef:e,input:t,autocomplete:n,steerContent:s,addContextContent:o,tryNativeCommand:a,commandPending:i,agentLookupPending:l=!1,agentLookupError:u=!1,status:d,stop:f,setInput:h,sessionId:m,sessionStatus:x,waiting:g,interaction:C,sync:b}){var Be,Ge;const{active:v,pendingApprovals:k,focusedOptionIndex:y,onToolRef:p,onToolDecided:j}=C,_=d==="streaming",D=ue(Ce=>Ce.isTextStreaming),[A]=Io(),N=Se(),{data:T}=hs(A),S=Tc(T??null,A??""),E=T?sn(T):void 0,{target:w}=Pu(),M=(w==null?void 0:w.placeholder)??"Send a message…",R=Ac(m),F=Cm(m),I=rn(m),z=nn(I),B=Fc(m),J=((z==null?void 0:z.supportsSteer)??!1)&&(B??!0),Y=(z==null?void 0:z.supportsContextStaging)??!1,G=((Be=z==null?void 0:z.permissionModes)==null?void 0:Be.denyReason)??!0,$=c.useCallback(async Ce=>{if((w==null?void 0:w.queue)===void 0)return!1;try{return await w.queue({text:Ce}),!0}catch{return!1}},[w]),P=Zb({input:t,setInput:h,sessionId:m,selectedCwd:A,waiting:g,onEnqueue:$,onSteer:s,onStage:o,tryNativeCommand:a,chatInputRef:e}),[O,Q]=c.useState(null),ce=c.useRef(null),H=c.useCallback(Ce=>{const ye=ce.current;if(ce.current=null,Ce.length===0)return;const Me=Ce.map(Ve=>ye&&Ve.id===ye.id?ye.content:Ve.content).join(`
56
-
57
- `),Oe=ie.getState().getSession(m).input.trim();h(Oe?`${Oe}
58
-
59
- ${Me}`:Me)},[m,h]),[U,X]=c.useState(null),ne=U===m&&_,oe=c.useRef(null),K=c.useCallback(()=>{oe.current=null,X(null)},[]);c.useEffect(()=>{_||K()},[_,m,K]);const ae=c.useRef(_);c.useEffect(()=>{ae.current=_},[_]);const ge=P.leaveQueueForStop,fe=c.useRef(P.editingId);c.useEffect(()=>{fe.current=P.editingId},[P.editingId]);const L=c.useCallback(()=>{const Ce=fe.current;if(Ce!==null){const ye=ie.getState().getSession(m).input.trim();ye&&(ce.current={id:Ce,content:ye}),ge()}oe.current=m,X(m),f().then(ye=>{H(ye.cancelled),yb(ye.receipt,ae.current)&&K();const Me=bb(ye.receipt);Me.message!==null&&!Fo(ye.receipt)&&(Me.isFailure?Te.error(Me.message):Te.warning(Me.message))}).catch(()=>{K()})},[m,f,H,K,ge]),ve=c.useCallback(()=>{if(!(oe.current===m||ne)){if(g.length===0){L();return}Q({sessionId:m,queuedCount:g.length})}},[m,ne,g.length,L]),je=c.useCallback(()=>{oe.current===m||ne||(Q(null),L())},[m,ne,L]);c.useEffect(()=>{(O==null?void 0:O.sessionId)===m&&g.length===0&&Q(null)},[O,m,g.length]);const{messages:me}=Ao(m),_e=Do(m),ee=c.useMemo(()=>Qa(_e,me),[_e,me]),Z=Wb(ee),se=c.useCallback(async Ce=>{if(m)try{await N.stopTask(m,Ce)}catch(ye){console.error("[chat] Failed to stop task:",ye)}},[m,N]),pe=c.useCallback(()=>{m&&N.switchSessionProcess(m).catch(()=>{Te.error("Couldn’t switch. Try again.")})},[m,N]),xe=c.useRef(t);c.useEffect(()=>{xe.current=t});const ke=c.useCallback(Ce=>{var Ve;const ye=xe.current,Me=ye.length>0&&!/\s$/.test(ye)?" ":"",Oe=`${ye}${Me}${Ce}`;h(Oe),(Ve=e.current)==null||Ve.focusAt(Oe.length)},[h,e]);c.useEffect(()=>ad(ke),[ke]);const be=!_&&P.editingIndex===null,Fe=sy({defaultText:M,hints:o0,enabled:be&&t===""}),ze=ld(),re=c.useCallback(()=>{n.dismissPalettes(),!(w===null||!w.canSend)&&w.send({text:t})},[n,w,t]),Ne=c.useCallback(()=>{n.dismissPalettes(),P.handleQueue()},[n,P]),Re=c.useCallback(()=>{n.dismissPalettes(),P.handleSteer()},[n,P]),pt=c.useCallback(()=>{n.dismissPalettes(),P.handleStage()},[n,P]);return r.jsx(wt.Composer,{className:"chat-input-container",onPathDropped:Ce=>ke(id(Ce)),inputRef:e,value:t,onChange:n.handleInputChange,onSubmit:re,head:r.jsx(de,{children:_&&r.jsx(Ad,{color:S.color,isTextStreaming:D,edge:"top"})}),asks:v?r.jsx(jy,{sessionId:m,activeInteraction:v,pendingApprovals:k,focusedOptionIndex:y,onToolRef:p,onToolDecided:j,queueDepth:P.queue.length,allowsDenyReason:G}):null,overlays:r.jsx(r.Fragment,{children:r.jsxs(de,{children:[n.commands.show&&r.jsx(_y,{filteredCommands:n.commands.filtered,selectedIndex:n.commands.selectedIndex,onSelect:n.handleCommandSelect}),n.files.show&&r.jsx(_m,{filteredFiles:n.files.filtered,selectedIndex:n.files.selectedIndex,onSelect:n.handleFileSelect})]})}),queue:r.jsx(de,{children:P.queue.length>0&&r.jsx(Nx,{queue:P.queue,editingId:P.editingId,onEdit:P.handleQueueEdit,onRemove:P.handleQueueRemove,onSend:P.handleQueueSend,onMoveUp:P.handleQueueMoveUp,onSwitchNow:pe,statusNote:R?"Waiting for your answer above":((Ge=P.queue[0])==null?void 0:Ge.waiting)!==void 0?"Sending when the agent is free":"Sending one at a time as the agent finishes"})}),aboveInput:r.jsx(jx,{tasks:Z,onStopTask:se}),footer:r.jsx(wt.Footer,{asChild:!0,children:r.jsx(Xx,{sessionId:m,sessionStatus:x,isStreaming:_,syncConnectionState:b.connectionState,agentName:E,agentColor:S.color,agentEmoji:S.emoji,agentPath:A??void 0})}),input:{isStreaming:_,commandPending:i,...l||u?{canSubmit:!1,canSubmitReason:u?"Check this folder again before you start.":"Checking this folder…"}:{},...F.canSubmit?{}:{canSubmit:!1},onStop:ve,stopPending:ne,onEscape:n.dismissPalettes,onClear:()=>{h(""),n.dismissPalettes()},isPaletteOpen:n.isPaletteOpen,paletteHasResults:n.paletteHasResults,onArrowUp:n.handleArrowUp,onArrowDown:n.handleArrowDown,onCommandSelect:n.handleKeyboardSelect,activeDescendantId:n.activeDescendantId,paletteListboxId:n.paletteListboxId,onCursorChange:n.handleCursorChange,richText:ze,editingQueueItem:P.editingIndex!==null,...P.editingIndex===null?{}:{editingPosition:P.editingIndex+1},queueDepth:P.queue.length,onQueue:Ne,...J?{onSteer:Re}:{},...Y?{onStage:pt}:{},onSaveEdit:P.handleQueueSaveEdit,onCancelEdit:P.handleQueueCancelEdit,onQueueNavigateUp:P.handleQueueNavigateUp,onQueueNavigateDown:P.handleQueueNavigateDown,queueHasItems:P.queue.length>0,contextKey:Ya(m,A)??void 0,placeholder:F.placeholder??wy(P.editingIndex,_,P.queue.length,M),placeholderOverlay:be&&F.canSubmit?r.jsx(Ax,{text:Fe.text,animationKey:Fe.key}):null},children:r.jsx(Ex,{open:(O==null?void 0:O.sessionId)===m,onOpenChange:Ce=>{Ce||Q(null)},queuedCount:(O==null?void 0:O.queuedCount)??0,onConfirm:je})})}const Ey=e=>{const t=e;return t.role==="user"?r.jsx(sx,{message:t}):r.jsx(Yg,{message:t})};function Dy(e,t){for(const n of Object.keys({...e,...t}))if(!(n==="grouping"||n==="author"||n==="feedPosition")&&!Object.is(e[n],t[n]))return!1;return e.grouping.position===t.grouping.position&&eo(e.author,t.author)&&eo(e.feedPosition,t.feedPosition)}function eo(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(s=>Object.is(e[s],t[s]))}const Ty=c.memo(Ay,Dy);function Ay({message:e,grouping:t,author:n,sessionId:s,isNew:o=!1,isStreaming:a=!1,isLatestWidgetMessage:i=!0,isFinalMessage:l=!0,activeToolCallId:u=null,onToolRef:d,focusedOptionIndex:f=-1,onToolDecided:h,onRetry:m,onSigninComplete:x,onChooseModel:g,inputZoneToolCallId:C=null,textEffect:b,runtimeLabel:v,allowsDenyReason:k,directRoomId:y,feedPosition:p}){var B,J;const j=c.useId(),_=`${j}-author`,D=`${j}-content`,A=c.useRef(null),N=t.position==="first"||t.position==="only",T=e.role==="user",S=T&&e.messageType!=="local_command_output",E=T?(B=e.chatMessages)==null?void 0:B[0]:void 0,w=T&&E===void 0?e.roomMessage:void 0,M=S&&E===void 0&&(w===void 0||((J=w.author)==null?void 0:J.you)===!0)&&e.messageType!=="command"&&e.messageType!=="compaction"&&e.content.trim().length>0,R=e.timestamp?Bn(e.timestamp):"",F=R.length>0,I=F?e.timestamp:void 0,z=c.useCallback(()=>{var Y;return(Y=A.current)==null?void 0:Y.focus()},[]);return r.jsx(Rp,{value:{sessionId:s,isStreaming:a,isLatestWidgetMessage:i,isFinalMessage:l,activeToolCallId:u,onToolRef:d,focusedOptionIndex:f,onToolDecided:h,onRetry:m,onSigninComplete:x,onChooseModel:g,inputZoneToolCallId:C,textEffect:b,runtimeLabel:v,allowsDenyReason:k},children:r.jsxs(nt.Root,{ref:A,role:S?"user":"assistant",position:t.position,isNew:o,"data-testid":"message-item","data-role":e.role,...N?{"aria-labelledby":_}:{"aria-label":F?`${n.displayName}, ${R}`:n.displayName},"aria-describedby":D,...Lu(p),children:[r.jsx(nt.Gutter,{author:n,at:I}),r.jsxs(nt.Body,{children:[r.jsx(nt.Author,{id:_,author:n,at:I,...E?{mark:r.jsx(va,{stamp:E}),className:"flex-wrap gap-y-0.5"}:w&&w.roomId!==y?{mark:r.jsx(yp,{stamp:w}),className:"flex-wrap gap-y-0.5"}:{}}),r.jsx(nt.Content,{id:D,children:Ey(e,{rowId:e.id})}),M&&r.jsx(nt.Actions,{runWith:{prompt:e.content,sessionId:s},onExit:z})]})]})})}function Fy({loading:e,onLoad:t}){return r.jsx("div",{className:"flex justify-center px-4 py-3",children:r.jsxs(le,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:e,"data-testid":"session-load-earlier",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&r.jsx(Le,{size:"xs"}),e?"Loading earlier messages…":"Earlier messages"]})})}const to="Conversation",Ry={kind:"notice",id:"session-load-earlier",at:"",body:null},My=[];function Oy(e){for(let t=e.length-1;t>=0;t--)if(e[t].content.includes(Xu))return t;return-1}function Iy({messages:e,sessionId:t,isLoadingHistory:n=!1,hydrated:s=!1,isTextStreaming:o=!1,activeToolCallId:a=null,onToolRef:i,focusedOptionIndex:l=-1,onToolDecided:u,onRetry:d,onSigninComplete:f,onChooseModel:h,inputZoneToolCallId:m=null,textEffect:x,runtimeLabel:g,allowsDenyReason:C,landOnRow:b,foldFirstPrompt:v=!1,directLog:k}){const y=xt(i),p=xt(u),j=xt(d),_=xt(f),D=xt(h),A=Ap(t,e),N=A.messages,{stops:T}=ka(t),S=!A.canLoadEarlier,E=c.useMemo(()=>hy(N,k,S),[N,k,S]),w=c.useMemo(()=>hp(E.messages,T),[E.messages,T]),M=c.useMemo(()=>{let ee=0;return w.map(Z=>Z._chatStop||Z._directNote?-1:ee++)},[w]),R=Mo(null);R.read()===null&&N.length>0&&R.write(A.messagesBefore+N.length);const F=c.useMemo(()=>Oy(w),[w]),I=c.useMemo(()=>v&&!A.canLoadEarlier?w.findIndex(ee=>ee.role==="user"&&ee.messageType===void 0&&!ee._stagedContext&&!ee._chatStop&&!ee._directNote):-1,[v,A.canLoadEarlier,w]),z=en(t),B=ue(ee=>ee.selectedCwd),J=rn(t),{data:Y}=hs(B),G=c.useMemo(()=>({agent:Y?{id:Y.id,displayName:sn(Y),...Tt(Y)}:null,runtime:J}),[Y,J]),$=N[N.length-1],P=($==null?void 0:$.role)==="assistant"?$:void 0,O=iy({messageId:P==null?void 0:P.id,text:(P==null?void 0:P.content)??"",isStreaming:P!==void 0&&o}),Q=Bb(($==null?void 0:$.parts)??My,t),{lastSeenMessageId:ce,unreadFromStart:H,markSeen:U,isHydrated:X}=Of(t,N,A.messagesBefore),[ne,oe]=c.useState(()=>Date.now()),K=c.useRef(null);c.useLayoutEffect(()=>{const ee=Date.now(),Z=new Date(ee).toDateString();if(K.current===null){K.current=Z;return}K.current!==Z&&(K.current=Z,oe(ee))},[w]);const ae=c.useCallback(ee=>$m(ee,G),[G]),[ge]=c.useState(Lm),fe=c.useMemo(()=>zm(w,{resolveAuthor:ae,now:ne,lastSeenMessageId:E.lastSeenBeforeUnread??ce,unreadFromStart:E.unreadFromStart||H,cache:ge}),[w,ae,ne,ce,H,E,ge]),[L]=c.useState(()=>new WeakMap),ve=c.useMemo(()=>{const ee=fe.map(Z=>{const se=L.get(Z);if(se)return se;const pe=Z.kind==="day-divider"?{kind:"day-divider",id:Z.key,label:Z.label}:Z.kind==="unread-divider"?{kind:"unread-divider",id:Z.key}:{kind:"message",id:Z.key,payload:Z.message,grouping:Z.grouping,author:Z.author,at:Z.message.timestamp};return L.set(Z,pe),pe});return A.canLoadEarlier?[Ry,...ee]:ee},[fe,L,A.canLoadEarlier]),je=A.canLoadEarlier?1:0,me=c.useCallback((ee,Z)=>{var Ne,Re;if(je===1&&Z.index===0)return r.jsx(Fy,{loading:A.isLoadingEarlier,onLoad:A.loadEarlier});const se=fe[Z.index-je];if(se.kind==="day-divider")return r.jsx(zu,{label:se.label});if(se.kind==="unread-divider")return r.jsx(Bu,{});const{message:pe,messageIndex:xe}=se;if(pe._stagedContext)return r.jsx(Wp,{content:pe.content});if(pe._chatStop)return r.jsx("div",{className:"px-4 py-1",children:r.jsx(_p,{notice:pe._chatStop})});if(xe===I)return r.jsx(sp,{content:((Re=(Ne=pe.chatMessages)==null?void 0:Ne[0])==null?void 0:Re.text)??pe.content});const ke=M[xe]??xe,be=ke>=0&&ke===N.length-1,Fe=be&&pe.role==="assistant",ze=F===-1||xe>=F,re=R.read();return r.jsx(Ty,{message:pe,grouping:se.grouping,author:se.author,sessionId:t,directRoomId:k==null?void 0:k.roomId,isNew:re!==null&&A.messagesBefore+ke>=re,isStreaming:Fe&&o,isLatestWidgetMessage:ze,isFinalMessage:be,activeToolCallId:a,onToolRef:y,focusedOptionIndex:l,onToolDecided:p,onRetry:j,onSigninComplete:_,onChooseModel:D,inputZoneToolCallId:m,textEffect:x,runtimeLabel:g,allowsDenyReason:C,feedPosition:{index:ke+1,total:N.length}})},[fe,je,A.isLoadingEarlier,A.loadEarlier,A.messagesBefore,N.length,M,F,I,t,k==null?void 0:k.roomId,R,o,a,y,l,p,j,_,D,m,x,g,C]),_e=z&&z.kind!=="first-message"&&z.fired&&!z.greetingFailed&&s?z:null;return r.jsx(wt.Timeline,{conversationId:t,label:to,rows:ve,renderRow:me,landOn:"unread",landingReady:X&&!A.isSeeking&&((k==null?void 0:k.ready)??!0),...b===void 0?{}:{landOnRow:b},onReachedBottom:U,transcriptAnnouncement:O,approvalAnnouncement:Q,className:"pt-12 [--conversation-thumb-top:3rem]",loading:n?r.jsx(qu,{label:to,busy:!0,className:"flex h-full items-center justify-center","data-testid":"transcript-feed-loading",children:r.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[r.jsx(ga,{}),"Loading chat…"]})}):void 0,empty:r.jsx("div",{className:"flex h-full items-center justify-center",children:r.jsx(Ym,{birthRecord:z,firstLightRecord:_e})}),"data-testid":"message-list",feedTestId:"transcript-feed"})}function $y({sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s=!1,launchSeed:o,onLaunchConsumed:a,landOnRow:i}){var Ts,As,Fs;const[,l]=Et(),u=is(),d=c.useRef(null),f=c.useRef(null),h=c.useCallback(()=>ly(f.current),[]),m=gy(e),x=_b(e),g=Rc(e??""),C=kb(),{play:b}=Gc(),[v]=Io(),{data:k,isPending:y,isError:p,refetch:j}=hs(v),{sessions:_}=ts(),D=e!==null&&!_.some(q=>q.id===e),A=Mc(e),N=Ab(),T=c.useCallback(async q=>{let Ee=q;if(N.hasPendingFiles){const Ze=await N.uploadAndGetPaths(),Rs=v?Ze.map(It=>It.startsWith(v)?It.slice(v.length).replace(/^\//,""):It):Ze;Rs.length>0&&(Ee=`Please read the following uploaded file(s):
60
- ${Rs.map(fi=>`- ${fi}`).join(`
61
- `)}
62
-
63
- ${Ee}`),N.clearFiles()}return Ee},[N,v]),S=c.useCallback(q=>{x.handleTaskEvent(q);const Ee=x.tasks.map(Ze=>Ze.id===q.task.id?{...Ze,...q.task}:Ze);C.handleTaskEvent(q,Ee)},[x,C]);c.useCallback(q=>{l(q),u.invalidateQueries({queryKey:Ke.bySession(q)})},[l,u]);const E=c.useCallback(q=>{l(q,{replace:!0}),u.invalidateQueries({queryKey:Ke.bySession(q)})},[l,u]),w=c.useCallback(q=>{l(crypto.randomUUID(),{continuedFrom:q??void 0,draft:!0})},[l]),M=Eo(e??""),R=nn(M.runtime),F=M.runtime?Ft(M.runtime).label:"",I=((Ts=R==null?void 0:R.permissionModes)==null?void 0:Ts.denyReason)??!0,z=c.useMemo(()=>qa(R==null?void 0:R.commandIntents,F),[R,F]),B=c.useRef(null),J=c.useCallback(()=>{var q;return(q=B.current)==null?void 0:q.call(B)},[]),{messages:Y,input:G,setInput:$,handleSubmit:P,submitContent:O,enqueueContent:Q,steerContent:ce,addContextContent:H,status:U,error:X,stop:ne,isLoadingHistory:oe,hydrated:K,sessionStatus:ae,streamStartTime:ge,estimatedTokens:fe,isTextStreaming:L,isWaitingForUser:ve,waitingType:je,activeInteraction:me,pendingInteractions:_e,markToolCallResponded:ee,systemStatus:Z,operationProgress:se,promptSuggestions:pe,syncConnectionState:xe,retryMessage:ke,tryNativeCommand:be,commandPending:Fe}=xb(e,{transformContent:T,onTaskEvent:S,onSessionIdChangeReplace:E,startFreshSession:w,compactIntent:z,launchRuntime:t,...k&&v?{agentPath:v}:{},agentLookupPending:v!==null&&y,agentLookupFailed:v!==null&&p,takeSeedContext:J,onStreamingDone:c.useCallback(()=>{b("turn-end"),u.invalidateQueries({queryKey:["commands"]})},[b,u])}),ze=c.useCallback(q=>O(q,{clearInput:!0}),[O]),{permissionMode:re,permissionModeKnown:Ne}=$o(e,ae,U==="streaming"),Re=Eu(e,M.runtime,Ne?re:void 0),pt=Oc(q=>q.setOpen);c.useEffect(()=>{pt(!1)},[e,pt]);const{handleToolRef:Be,focusedOptionIndex:Ge}=wb(me);Tb(U,ve,L),c.useEffect(()=>{var q;(q=d.current)==null||q.focusUnlessTouch()},[e]);const Ce=c.useCallback(()=>{var q;(q=d.current)==null||q.focusUnlessTouch()},[]);Rb({sessionId:e,prompt:n,autoSend:s,input:G,setInput:$,messageCount:Y.length,hydrated:K,status:U,submitBlocked:D&&v!==null&&(y||p),submit:P,onSeeded:Ce,onConsumed:a});const ye=$b({sessionId:e,seed:o,messageCount:Y.length,hydrated:K,onConsumed:a});c.useEffect(()=>{B.current=ye},[ye]);const Me=M.runtime?us(M.runtime):void 0,{data:Oe}=Vc(v,e??void 0,M.runtime??void 0),Ve=c.useMemo(()=>Px((Oe==null?void 0:Oe.commands)??[],{commandIntents:R==null?void 0:R.commandIntents,runtimeLabel:F}),[Oe,R,F]),{data:ht}=wm(v),Za=c.useMemo(()=>ht!=null&&ht.files?Bm(ht.files):[],[ht]),ei=Db({input:G,setInput:$,commands:Ve,fileEntries:Za}),ks=c.useCallback(()=>{const q=[...Y].reverse().find(Ee=>Ee.role==="user");q!=null&&q.content&&O(q.content)},[Y,O]),Cs=en(e??""),ti=c.useCallback(()=>{const q=qm(Y,Cs);q&&ke(q)},[Y,Cs,ke]),Ss=U==="idle"&&pe.length>0&&G.length===0,ni=Ic("chat.suggestion-chips"),si=Sm(e??""),ri=Pb(U,X,Y,si),oi=c.useMemo(()=>Y.some(q=>q.role==="user"),[Y]),js=c.useCallback(q=>{var Ee;$(q),(Ee=d.current)==null||Ee.focus()},[$]),ai=Po,Ot=$c(e??""),dn=Ro(e??""),ii=c.useMemo(()=>Vb(Ot,dn),[Ot,dn]),_s=(Fs=(As=ps(e??""))==null?void 0:As.lastError)==null?void 0:Fs.category,fn=Vm(),ws=c.useCallback(()=>{const q=e??"";if(fn.claimedElsewhere(q))return!1;const Ee=Hm({messages:Y,status:U,lastErrorCategory:_s,queuedCount:Ot.length,draft:ie.getState().getSession(q).input});return Ee===null?!1:(fn.claim(q),O(Ee),!0)},[Y,U,_s,Ot.length,e,O,fn]),li=k?`Message ${sn(k)}…`:"Send a message…",ci=vy({sessionId:e??"",placeholder:li,submit:ze,enqueue:Q,files:N}),{eligible:Ns,allow:Es,notNow:Ds}=Tf(U==="streaming"),ui=c.useMemo(()=>[{id:"prompt-suggestions",show:Ss,render:()=>r.jsx(Bc,{suggestions:pe,onChipClick:js})},{id:"permission-primer",show:Ns,render:()=>r.jsx(Df,{onAllow:Es,onNotNow:Ds})},{id:"read-only-mode",show:Re.eligible,render:()=>r.jsx(Du,{runtimeLabel:Re.runtimeLabel,onShown:Re.markShown,onDismiss:Re.dismiss})}],[Ss,pe,js,Ns,Es,Ds,Re]),di=yy({asks:ai,status:U,streamStartTime:ge,estimatedTokens:fe,permissionMode:re,isWaitingForUser:ve??!1,waitingType:je??"approval",operationProgress:se,systemStatus:Z,activity:g});return r.jsx(wt.Root,{surface:"session",capabilities:Ja,target:ci,children:r.jsxs("div",{ref:f,"data-testid":"chat-panel","data-turn-status":U,"data-turn-lifecycle":dn??void 0,className:"flex h-full w-full flex-col",children:[r.jsx(Jm,{sessionId:e}),r.jsx(tp,{startedBy:A,modes:R==null?void 0:R.permissionModes.values}),r.jsx(Iy,{messages:Y,sessionId:e,isLoadingHistory:oe,hydrated:K,isTextStreaming:L,activeToolCallId:(me==null?void 0:me.toolCallId)??null,onToolRef:Be,focusedOptionIndex:Ge,onToolDecided:ee,onRetry:ks,onSigninComplete:ws,onChooseModel:h,inputZoneToolCallId:(me==null?void 0:me.toolCallId)??null,runtimeLabel:Me,allowsDenyReason:I,...i===void 0?{}:{landOnRow:i},foldFirstPrompt:A!==null,directLog:m}),r.jsx(n0,{terminalReason:ae==null?void 0:ae.terminalReason}),r.jsx(wt.LiveLane,{state:di,scope:"session"}),r.jsx(Kc,{candidates:ui,ready:K,name:"session-bottom-slot",className:"px-4 pb-2"}),U==="idle"&&ni.map(q=>r.jsx(q.component,{},q.id)),r.jsx(Fp,{celebration:C.activeCelebration,onComplete:C.clearCelebration}),r.jsx(fx,{tasks:x.tasks,taskMap:x.taskMap,activeForm:x.activeForm,isCollapsed:x.isCollapsed,onToggleCollapse:x.toggleCollapse,celebratingTaskId:C.celebratingTaskId,onCelebrationComplete:C.clearCelebration,statusTimestamps:x.statusTimestamps}),ri&&r.jsx(r0,{sessionId:e,onRetry:oi?ks:void 0,onSigninComplete:ws,onChooseModel:h}),X&&r.jsx(ky,{error:X,composerAgent:k,onRetry:ti}),D&&p&&r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(an,{heading:"Couldn’t check this folder",message:"DorkOS couldn’t tell if an agent owns this folder. Try again.",onRetry:()=>void j()})}),e&&r.jsx(xm,{sessionId:e,onSend:q=>void O(q)}),r.jsx(Ny,{chatInputRef:d,input:G,autocomplete:ei,steerContent:ce,addContextContent:H,tryNativeCommand:be,commandPending:Fe,agentLookupPending:D&&v!==null&&y,agentLookupError:D&&v!==null&&p,status:U,stop:ne,setInput:$,sessionId:e??"",sessionStatus:ae,waiting:ii,interaction:{active:me,pendingApprovals:_e.filter(q=>q.interactiveType==="approval"),focusedOptionIndex:Ge,onToolRef:Be,onToolDecided:ee},sync:{connectionState:xe}})]})})}function Py(e,t){const n=e===null||t===void 0?null:`${e}:${t}`,s=c.useRef(null);c.useEffect(()=>{if(!(e===null||t===void 0))return s.current=`${e}:${t}`,Pe.getState().seek(e,t),()=>{const i=Pe.getState();i.seeks[e]===t&&i.endSeek(e)}},[e,t]);const o=c.useRef(null),a=c.useCallback(()=>{var d;if(n===null||o.current===n||t===void 0||e===null)return;const i=Pe.getState().seeks[e]===t;if(s.current!==n||i)return;o.current=n;const l=((d=Pe.getState().sessions[e])==null?void 0:d.earlier)??[],u=we.getState().getSession(e).messages;return ma(ya([...l,...u],t)??t)},[n,t,e]);return n===null?void 0:a}function Ly(){const[e]=Et();Qd(e);const{runtime:t,prompt:n,send:s,seed:o,message:a}=ro(),i=Pc(),l=Py(e,a),{data:u}=Lc(e,{enabled:!1,select:h=>h.title}),d=To(e);xd(e,{canonical:d===null}),Qc();const f=c.useCallback(()=>{i==null||i({search:h=>({...h,prompt:void 0,send:void 0,seed:void 0}),replace:!0})},[i]);return r.jsxs(r.Fragment,{children:[r.jsx(zc,{children:u!=null&&u.trim()?u:"Chat"}),r.jsx($y,{sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s==="1",launchSeed:o,onLaunchConsumed:f,...l===void 0?{}:{landOnRow:l}})]})}const Uv=Ly;export{Uv as component};