yepanywhere 0.9.0 → 0.9.2

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 (502) hide show
  1. package/bundled/@yep-anywhere/shared/dist/__tests__/long-context-effort-warning.test.js +19 -0
  2. package/bundled/@yep-anywhere/shared/dist/__tests__/long-context-effort-warning.test.js.map +1 -1
  3. package/bundled/@yep-anywhere/shared/dist/__tests__/model-prices.test.js +12 -0
  4. package/bundled/@yep-anywhere/shared/dist/__tests__/model-prices.test.js.map +1 -1
  5. package/bundled/@yep-anywhere/shared/dist/app-types.d.ts +2 -2
  6. package/bundled/@yep-anywhere/shared/dist/app-types.d.ts.map +1 -1
  7. package/bundled/@yep-anywhere/shared/dist/app-types.js +5 -5
  8. package/bundled/@yep-anywhere/shared/dist/app-types.js.map +1 -1
  9. package/bundled/@yep-anywhere/shared/dist/artifact-viewer.d.ts +21 -0
  10. package/bundled/@yep-anywhere/shared/dist/artifact-viewer.d.ts.map +1 -1
  11. package/bundled/@yep-anywhere/shared/dist/artifact-viewer.js +22 -1
  12. package/bundled/@yep-anywhere/shared/dist/artifact-viewer.js.map +1 -1
  13. package/bundled/@yep-anywhere/shared/dist/capability-ids.d.ts +6 -0
  14. package/bundled/@yep-anywhere/shared/dist/capability-ids.d.ts.map +1 -1
  15. package/bundled/@yep-anywhere/shared/dist/capability-ids.js +6 -0
  16. package/bundled/@yep-anywhere/shared/dist/capability-ids.js.map +1 -1
  17. package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.d.ts +2 -2
  18. package/bundled/@yep-anywhere/shared/dist/find/documentFind.d.ts +41 -0
  19. package/bundled/@yep-anywhere/shared/dist/find/documentFind.d.ts.map +1 -0
  20. package/bundled/@yep-anywhere/shared/dist/find/documentFind.js +280 -0
  21. package/bundled/@yep-anywhere/shared/dist/find/documentFind.js.map +1 -0
  22. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.d.ts +2 -0
  23. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.d.ts.map +1 -0
  24. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.d.ts +2 -0
  25. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.d.ts.map +1 -0
  26. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.js +5 -0
  27. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.js.map +1 -0
  28. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.js +59 -0
  29. package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.js.map +1 -0
  30. package/bundled/@yep-anywhere/shared/dist/find/protocol.d.ts +46 -0
  31. package/bundled/@yep-anywhere/shared/dist/find/protocol.d.ts.map +1 -0
  32. package/bundled/@yep-anywhere/shared/dist/find/protocol.js +45 -0
  33. package/bundled/@yep-anywhere/shared/dist/find/protocol.js.map +1 -0
  34. package/bundled/@yep-anywhere/shared/dist/index.d.ts +4 -2
  35. package/bundled/@yep-anywhere/shared/dist/index.d.ts.map +1 -1
  36. package/bundled/@yep-anywhere/shared/dist/index.js +3 -1
  37. package/bundled/@yep-anywhere/shared/dist/index.js.map +1 -1
  38. package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.d.ts +11 -11
  39. package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.d.ts.map +1 -1
  40. package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.js +26 -9
  41. package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.js.map +1 -1
  42. package/bundled/@yep-anywhere/shared/dist/model-prices.d.ts.map +1 -1
  43. package/bundled/@yep-anywhere/shared/dist/model-prices.js +9 -2
  44. package/bundled/@yep-anywhere/shared/dist/model-prices.js.map +1 -1
  45. package/bundled/@yep-anywhere/shared/dist/pdfjs.d.ts +7 -0
  46. package/bundled/@yep-anywhere/shared/dist/pdfjs.d.ts.map +1 -0
  47. package/bundled/@yep-anywhere/shared/dist/pdfjs.js +7 -0
  48. package/bundled/@yep-anywhere/shared/dist/pdfjs.js.map +1 -0
  49. package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts +20 -0
  50. package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts.map +1 -1
  51. package/bundled/@yep-anywhere/shared/dist/server-capabilities.js +22 -0
  52. package/bundled/@yep-anywhere/shared/dist/server-capabilities.js.map +1 -1
  53. package/bundled/@yep-anywhere/shared/dist/skill-invocations.d.ts.map +1 -1
  54. package/bundled/@yep-anywhere/shared/dist/skill-invocations.js +7 -10
  55. package/bundled/@yep-anywhere/shared/dist/skill-invocations.js.map +1 -1
  56. package/bundled/@yep-anywhere/shared/dist/types.d.ts +7 -0
  57. package/bundled/@yep-anywhere/shared/dist/types.d.ts.map +1 -1
  58. package/bundled/@yep-anywhere/shared/dist/types.js.map +1 -1
  59. package/bundled/@yep-anywhere/shared/package.json +1 -1
  60. package/client-dist/assets/AboutSettings-CCzudbSj.js +1 -0
  61. package/client-dist/assets/{ActivityPage-FgSG_9Sl.js → ActivityPage-Bn0LbMgE.js} +1 -1
  62. package/client-dist/assets/{AgentContextSettings-BfTCI7qG.js → AgentContextSettings-DI8jQVIx.js} +3 -3
  63. package/client-dist/assets/AgentsPage-Ci_iJt8T.js +2 -0
  64. package/client-dist/assets/App-rFnK5pnF.js +2 -0
  65. package/client-dist/assets/AppearanceSettings-DTYVt0W5.js +2 -0
  66. package/client-dist/assets/AppsSettings-hbh_sguk.js +1 -0
  67. package/client-dist/assets/AttachmentChip-BFve3lTD.js +1 -0
  68. package/client-dist/assets/{AuthContext-CVsoMulX.js → AuthContext-DmXjW0be.js} +1 -1
  69. package/client-dist/assets/{BangCommandDisplayObject-B8KrHDzH.js → BangCommandDisplayObject-BH2KRGnc.js} +1 -1
  70. package/client-dist/assets/BangCommandsPage-MfkuL8yS.js +1 -0
  71. package/client-dist/assets/BrowserDebugToolbarButton-BPghQu17.js +1 -0
  72. package/client-dist/assets/{CacheMissBillingSettings-Bfqlk9rA.js → CacheMissBillingSettings-rUgC-_DD.js} +2 -2
  73. package/client-dist/assets/{CodexUpdatePrompt-ChHtbla-.js → CodexUpdatePrompt-mT9K-f1e.js} +1 -1
  74. package/client-dist/assets/{CommittedRangeInput-C3Z7YUlS.js → CommittedRangeInput-BwuV6Q6c.js} +1 -1
  75. package/client-dist/assets/{CommittedRangeNumberInput-D497_5ff.js → CommittedRangeNumberInput-C5YSVltB.js} +1 -1
  76. package/client-dist/assets/ComputerControlSettings-MWIdP7SS.js +1 -0
  77. package/client-dist/assets/{ConversationPreviewPage-CTWx9N3v.js → ConversationPreviewPage-B47r7mUF.js} +2 -2
  78. package/client-dist/assets/DevelopmentSettings-BEAy_xq-.js +1 -0
  79. package/client-dist/assets/DevicesSettings-DKQOZkRN.js +1 -0
  80. package/client-dist/assets/EmulatorPage-DlsPq3nR.js +1 -0
  81. package/client-dist/assets/EmulatorSettings-C6Ye1k_Y.js +1 -0
  82. package/client-dist/assets/EnvironmentSettings-ou8UNqTa.js +1 -0
  83. package/client-dist/assets/FilePage-Cw2PaO5H.js +1 -0
  84. package/client-dist/assets/FilterDropdown-CACc6ysA.js +1 -0
  85. package/client-dist/assets/FilterDropdown-D11gXriH.css +1 -0
  86. package/client-dist/assets/FloatingActionButton-Bl1Eumxh.js +1 -0
  87. package/client-dist/assets/{GitStatusPage-879aktqc.js → GitStatusPage-CLTkgnDI.js} +3 -3
  88. package/client-dist/assets/GlobalSessionsPage-Bvzs4zmW.js +2 -0
  89. package/client-dist/assets/GlobalSessionsPage-dlTB6crv.css +1 -0
  90. package/client-dist/assets/{HeartbeatTextArea-CKxL-bdJ.js → HeartbeatTextArea-CtP5kx9R.js} +1 -1
  91. package/client-dist/assets/HostIdentityContext-DA7dMF-y.js +1 -0
  92. package/client-dist/assets/HostsPage-CBOYGC2-.js +1 -0
  93. package/client-dist/assets/{InboxContext-opkOiXDB.js → InboxContext-8PXoTbK1.js} +1 -1
  94. package/client-dist/assets/InboxPage-DWl7uzdw.js +1 -0
  95. package/client-dist/assets/IssueSettings-BVljRpuD.js +1 -0
  96. package/client-dist/assets/IssuesPage-BFxgsMkf.js +1 -0
  97. package/client-dist/assets/LifecycleWebhooksSettings-Qw_dN3F3.js +1 -0
  98. package/client-dist/assets/{LocalAccessSettings-BpmNC9pI.js → LocalAccessSettings-SWirs75o.js} +3 -3
  99. package/client-dist/assets/LocalMediaModal-B3KXtyEB.css +1 -0
  100. package/client-dist/assets/LocalMediaModal-B9eHVx6y.js +14 -0
  101. package/client-dist/assets/{LoginPage-Cu7cX9wS.js → LoginPage-CYWqVJ95.js} +1 -1
  102. package/client-dist/assets/{MessageAge-Cd1C0-Kr.js → MessageAge-CaPpa1nH.js} +1 -1
  103. package/client-dist/assets/{MessageDeliverySettings-B_9VqCMP.js → MessageDeliverySettings-BUSuGKlc.js} +2 -2
  104. package/client-dist/assets/MessageInput-a13ZPAHv.js +3 -0
  105. package/client-dist/assets/MessageInputToolbar-BIL_6i7G.css +1 -0
  106. package/client-dist/assets/MessageInputToolbar-CQGTnVea.js +58 -0
  107. package/client-dist/assets/MessageList-C7kAuWKg.js +4 -0
  108. package/client-dist/assets/MessageList-rD5OPsAJ.css +1 -0
  109. package/client-dist/assets/Modal-ClSjJagX.js +15 -0
  110. package/client-dist/assets/ModelSettings-Dnd4yzmI.js +1 -0
  111. package/client-dist/assets/NavigationLayout-BTFsWVtE.js +2 -0
  112. package/client-dist/assets/NewSessionPage-BfiAS-Mo.js +1 -0
  113. package/client-dist/assets/NotificationsSettings-B1ugQIp-.js +1 -0
  114. package/client-dist/assets/PageHeader-BjwH2pWD.js +1 -0
  115. package/client-dist/assets/PerformanceSettings-jJYF9SPY.js +1 -0
  116. package/client-dist/assets/{ProjectSessionDefaultsModal-Dq2_xDka.js → ProjectSessionDefaultsModal-G_0uxJEv.js} +1 -1
  117. package/client-dist/assets/ProjectTemplatesSettings-BQTCV3-3.js +1 -0
  118. package/client-dist/assets/ProjectsPage-suTd8s9l.js +1 -0
  119. package/client-dist/assets/ProviderBadge-P0VTI71n.js +1 -0
  120. package/client-dist/assets/{ProviderChildSessionDetail-tWrpaB_X.js → ProviderChildSessionDetail-D0472EW8.js} +35 -35
  121. package/client-dist/assets/ProviderChildSessionPage-9__sgY14.js +1 -0
  122. package/client-dist/assets/ProvidersSettings-Bwzy73Rk.js +1 -0
  123. package/client-dist/assets/{RecapAfterSecondsControl-qU0RMrUX.js → RecapAfterSecondsControl-CxuXyFSr.js} +1 -1
  124. package/client-dist/assets/{RelayProtocol-DjpPJk64.js → RelayProtocol-BpdH0COG.js} +1 -1
  125. package/client-dist/assets/RemoteAccessSettings-Dn7KB5nK.js +1 -0
  126. package/client-dist/assets/RemoteExecutorsSettings-Cjl4Y2rB.js +1 -0
  127. package/client-dist/assets/SchemaValidationContext-57RCj4c4.js +1 -0
  128. package/client-dist/assets/{SearchPreview-B25ksFLA.js → SearchPreview-OzVFWPJZ.js} +1 -1
  129. package/client-dist/assets/{SessionHeader.module-Co9s-JR3.js → SessionHeader.module-BpaFAQ-S.js} +1 -1
  130. package/client-dist/assets/SessionPage-BYthaEfZ.js +50 -0
  131. package/client-dist/assets/SessionPage-CXXEAwu2.css +1 -0
  132. package/client-dist/assets/{SettingsItem-B_rM9Vhi.js → SettingsItem-C9Vh5p7F.js} +1 -1
  133. package/client-dist/assets/{SettingsSection-DOwc_RwX.js → SettingsSection-BaPzETK6.js} +1 -1
  134. package/client-dist/assets/SourceControlSettings-DnqLg0db.js +1 -0
  135. package/client-dist/assets/{SourceFileHeaderActions-3_76js_o.js → SourceFileHeaderActions-PjhUGnn6.js} +1 -1
  136. package/client-dist/assets/SpeechControlMenu-BYVdEa3C.js +2 -0
  137. package/client-dist/assets/{SpeechSettings-BT4TnSgr.js → SpeechSettings-B6LkqfSK.js} +2 -2
  138. package/client-dist/assets/{SpeechSmartTurnControls-vIZ8a7Lb.js → SpeechSmartTurnControls-LPq9wBaM.js} +1 -1
  139. package/client-dist/assets/StorageSettings-DtsJnYaz.js +1 -0
  140. package/client-dist/assets/{ThinkingControls-CbZcYobp.js → ThinkingControls-DXbxdJRi.js} +1 -1
  141. package/client-dist/assets/ToolbarSettings-Nb2BKpnk.js +1 -0
  142. package/client-dist/assets/UsersSettings-BdvqmyqK.js +1 -0
  143. package/client-dist/assets/ViewerModePage-CfJJA5GL.css +1 -0
  144. package/client-dist/assets/ViewerModePage-DzRIpuYF.js +1 -0
  145. package/client-dist/assets/{VoiceInputButton-japn0Kx_.js → VoiceInputButton-CCgovfyf.js} +1 -1
  146. package/client-dist/assets/WorkstreamsPage-dlEUllSL.js +1 -0
  147. package/client-dist/assets/{YaServerProvider-OSxrnpr9.js → YaServerProvider-CN3tC5UL.js} +1 -1
  148. package/client-dist/assets/{YepAnywhereLogo-OH70DoR4.js → YepAnywhereLogo-5zFKWjQq.js} +1 -1
  149. package/client-dist/assets/{abnfDiagram-VCTEODGH-BK2byNq2.js → abnfDiagram-VCTEODGH-BWHUBcV3.js} +1 -1
  150. package/client-dist/assets/{arc-BZ7613Gf.js → arc-DKsIJWGD.js} +1 -1
  151. package/client-dist/assets/{architectureDiagram-5GKGNRK7-WEjy-r-z.js → architectureDiagram-5GKGNRK7-BuLImqW3.js} +1 -1
  152. package/client-dist/assets/{attachmentFileNames-BfFUuufi.js → attachmentFileNames-CBV_5g65.js} +1 -1
  153. package/client-dist/assets/{blockDiagram-I7D4REHJ-BOsYYXyW.js → blockDiagram-I7D4REHJ-CJ4Gh6sL.js} +1 -1
  154. package/client-dist/assets/{c4Diagram-7LVT6UL2-BRrAUZLE.js → c4Diagram-7LVT6UL2-WR43XvCI.js} +1 -1
  155. package/client-dist/assets/channel-PV8AAsuo.js +1 -0
  156. package/client-dist/assets/{chunk-2Q5K7J3B-ikUS9MZO.js → chunk-2Q5K7J3B-CiP4m_EA.js} +1 -1
  157. package/client-dist/assets/{chunk-5VM5RSS4-DqxRtuTQ.js → chunk-5VM5RSS4-BUAhj1h9.js} +1 -1
  158. package/client-dist/assets/{chunk-F27PBJKO-DQAhMVEw.js → chunk-F27PBJKO-BUZNwiGx.js} +1 -1
  159. package/client-dist/assets/{chunk-IMKFNOWR-B2QXI9W-.js → chunk-IMKFNOWR-CX1a0BCE.js} +1 -1
  160. package/client-dist/assets/{chunk-JWPE2WC7-Px4jgxzE.js → chunk-JWPE2WC7-C6tL-mLF.js} +1 -1
  161. package/client-dist/assets/{chunk-POPQ4Y6H-BTrXHY42.js → chunk-POPQ4Y6H-BzijGGWv.js} +1 -1
  162. package/client-dist/assets/{chunk-SVP7TREG-DufcbLSM.js → chunk-SVP7TREG-CsZImJKI.js} +1 -1
  163. package/client-dist/assets/{chunk-TICWLB2K-C6xArrXi.js → chunk-TICWLB2K-TwCtuDc1.js} +1 -1
  164. package/client-dist/assets/{chunk-XXDRQBXY-CtTuQMK6.js → chunk-XXDRQBXY-C-2EoNns.js} +1 -1
  165. package/client-dist/assets/classDiagram-ZZMXUADV-DvtSxfma.js +1 -0
  166. package/client-dist/assets/classDiagram-v2-VYDZK3BY-DvtSxfma.js +1 -0
  167. package/client-dist/assets/{client-sN_tbfxh.js → client-Ci_HPGfl.js} +2 -2
  168. package/client-dist/assets/{compactSettingsControls-BjKplkgf.js → compactSettingsControls-C9mLZh5H.js} +1 -1
  169. package/client-dist/assets/{cose-bilkent-JH36ORCC-Cn15YJGj.js → cose-bilkent-JH36ORCC-CmbEx2jT.js} +1 -1
  170. package/client-dist/assets/{cynefin-OW5HDTMX-CJkFJ0DX.js → cynefin-OW5HDTMX-BSQHHXFU.js} +1 -1
  171. package/client-dist/assets/{cynefinDiagram-5FMLGOSQ-CVX2L_eF.js → cynefinDiagram-5FMLGOSQ-C-62JZJD.js} +1 -1
  172. package/client-dist/assets/{dagre-GXQ25YYZ-BMbYVbaU.js → dagre-GXQ25YYZ-BBERQe_A.js} +1 -1
  173. package/client-dist/assets/de-Cgdxe5vX.js +6 -0
  174. package/client-dist/assets/{diagram-S7CK7UJ4-DTZ_P_Fh.js → diagram-S7CK7UJ4-muw11lmG.js} +1 -1
  175. package/client-dist/assets/{diagram-UQ7AKVKN-C6cgxro0.js → diagram-UQ7AKVKN-DpePWzAe.js} +1 -1
  176. package/client-dist/assets/{diagram-VSXAHHWV-MzNPAr2n.js → diagram-VSXAHHWV-DHX6AHUY.js} +1 -1
  177. package/client-dist/assets/{diagram-VX7I27RA-BZN6iloV.js → diagram-VX7I27RA-DYmR6NH_.js} +1 -1
  178. package/client-dist/assets/{diagram-Z3DM3KII-CtTiorxp.js → diagram-Z3DM3KII-BC1SenHB.js} +1 -1
  179. package/client-dist/assets/{ebnfDiagram-PWID7BFC-B28XYdqt.js → ebnfDiagram-PWID7BFC-EVpri6Ma.js} +1 -1
  180. package/client-dist/assets/{erDiagram-RLTQ6QDP-DlMmHWyy.js → erDiagram-RLTQ6QDP-DthztUaa.js} +1 -1
  181. package/client-dist/assets/es-gyRk85dY.js +6 -0
  182. package/client-dist/assets/{flowDiagram-HODETNUW-C5mVciwL.js → flowDiagram-HODETNUW-DEpC5nMx.js} +1 -1
  183. package/client-dist/assets/fr-Dx9lA8u-.js +6 -0
  184. package/client-dist/assets/{frontendReload-DT6MOpjg.js → frontendReload-CBdyvvdy.js} +1 -1
  185. package/client-dist/assets/{ganttDiagram-EL5Y4UJY-BTl7ZRTR.js → ganttDiagram-EL5Y4UJY-Csqji8t1.js} +1 -1
  186. package/client-dist/assets/{gitGraphDiagram-WWUBYQGX-BsG6KEKe.js → gitGraphDiagram-WWUBYQGX-DVX1SDIE.js} +1 -1
  187. package/client-dist/assets/{hostStorage-BoEdRarg.js → hostStorage-D1KAm3U1.js} +1 -1
  188. package/client-dist/assets/{index-D7q51uJV.js → index-BESqiBDI.js} +1 -1
  189. package/client-dist/assets/index-BkOdUxq4.js +2 -0
  190. package/client-dist/assets/index-CPb-36gi.css +1 -0
  191. package/client-dist/assets/index-CoR-vzsb.js +2 -0
  192. package/client-dist/assets/index-Cv3tQXyE.js +1 -0
  193. package/client-dist/assets/{index-CkZXrIi5.js → index-DSFMItgO.js} +1 -1
  194. package/client-dist/assets/index-umZg0LZ6.js +81 -0
  195. package/client-dist/assets/{infoDiagram-27XIBGKW-CkZcthz-.js → infoDiagram-27XIBGKW-CHm3qsd2.js} +1 -1
  196. package/client-dist/assets/{ishikawaDiagram-5VMMS53U-Cvqitz5U.js → ishikawaDiagram-5VMMS53U-tBRZwz-_.js} +1 -1
  197. package/client-dist/assets/ja-BOj7smkY.js +6 -0
  198. package/client-dist/assets/{journeyDiagram-3NMN7TZE-vCw00Cqy.js → journeyDiagram-3NMN7TZE-EJic7nqD.js} +1 -1
  199. package/client-dist/assets/{kanban-definition-UXKFOSKX-BZGCo-wX.js → kanban-definition-UXKFOSKX-DtzL6eeO.js} +1 -1
  200. package/client-dist/assets/{layout-D7JRfual.js → layout-gb-Axsoq.js} +1 -1
  201. package/client-dist/assets/{linear-O9cHRsA5.js → linear-CAe4xGbR.js} +1 -1
  202. package/client-dist/assets/long-context-effort-warning-C6XHizE1.js +1 -0
  203. package/client-dist/assets/{mermaid.core-CdC8AeOx.js → mermaid.core-BCu1nv8H.js} +5 -5
  204. package/client-dist/assets/{mindmap-definition-YA3MSWOX-CczC57z0.js → mindmap-definition-YA3MSWOX-C7-KSPtJ.js} +1 -1
  205. package/client-dist/assets/newSessionPrefill-DKcy0abh.js +1 -0
  206. package/client-dist/assets/{pegDiagram-XKGWAZYB-jTm4iBWK.js → pegDiagram-XKGWAZYB-iWVH9rbY.js} +1 -1
  207. package/client-dist/assets/{pieDiagram-E7YTZNPT-DfkDPuJg.js → pieDiagram-E7YTZNPT-VKD6PLHa.js} +1 -1
  208. package/client-dist/assets/providerChildSessions-Cd7oK6KQ.css +1 -0
  209. package/client-dist/assets/providerChildSessions-DbLFSybt.js +77 -0
  210. package/client-dist/assets/{quadrantDiagram-AXDQQJYC--bBZSIt1.js → quadrantDiagram-AXDQQJYC-AXFugcFl.js} +1 -1
  211. package/client-dist/assets/{railroadDiagram-O6MQD6OU-gbkMdGN6.js → railroadDiagram-O6MQD6OU-D6oZy6Al.js} +1 -1
  212. package/client-dist/assets/{recentProjectPathLinks-Ba20jx5b.js → recentProjectPathLinks-D0Dx6YXT.js} +2 -2
  213. package/client-dist/assets/{registerServiceWorker-CGxgV4Yi.js → registerServiceWorker-B8K2KVOY.js} +1 -1
  214. package/client-dist/assets/{relayEndpoints-0oIbn4eU.js → relayEndpoints-BTq9xppf.js} +1 -1
  215. package/client-dist/assets/{remoteRoutePaths-CiDZeM2I.js → remoteRoutePaths-D8htA0xa.js} +1 -1
  216. package/client-dist/assets/{requirementDiagram-BXWQKSXE-WfLCTewk.js → requirementDiagram-BXWQKSXE-Eqtb74It.js} +1 -1
  217. package/client-dist/assets/{sankeyDiagram-P5KCCOFB-BhJkx_M1.js → sankeyDiagram-P5KCCOFB-CxvDiZ1R.js} +1 -1
  218. package/client-dist/assets/{sequenceDiagram-WJ2MYXX4-_S-ZN-hK.js → sequenceDiagram-WJ2MYXX4-BbpkgW2L.js} +1 -1
  219. package/client-dist/assets/sessionHistorySearch.worker-DCkPlfGO.js +61 -0
  220. package/client-dist/assets/{sessionNavigationState-DKXD1sTS.js → sessionNavigationState-BXejf2ZW.js} +1 -1
  221. package/client-dist/assets/sessionRouteLayer-D9T2QT8G.js +1 -0
  222. package/client-dist/assets/{sizeCapture-INFHLROL-YfaR_7-Y.js → sizeCapture-INFHLROL-DcuwWD5r.js} +1 -1
  223. package/client-dist/assets/{sourceControlNavigationState-lyZ29oaF.js → sourceControlNavigationState-BJbTzWTE.js} +1 -1
  224. package/client-dist/assets/{speechDraftTransaction-zyWVCYTF.js → speechDraftTransaction-WhqFE1h9.js} +1 -1
  225. package/client-dist/assets/{stateDiagram-D77RDMKH-_N9FdD6m.js → stateDiagram-D77RDMKH-Cidpq73w.js} +1 -1
  226. package/client-dist/assets/stateDiagram-v2-MP3YSRHH-DFqKXxjz.js +1 -0
  227. package/client-dist/assets/{swimlanes-42K2YHIH-DUl5jFZz.js → swimlanes-42K2YHIH-Ba8C7MwG.js} +1 -1
  228. package/client-dist/assets/swimlanesDiagram-VR7AAH4N-3pW2TcAt.js +8 -0
  229. package/client-dist/assets/{timeline-definition-24CTP7MA-DtYzRl63.js → timeline-definition-24CTP7MA-CKefGvUK.js} +1 -1
  230. package/client-dist/assets/useAcliCommentarySetting-CBKAl7qr.js +9 -0
  231. package/client-dist/assets/useActivityBusState-C0dor9p7.js +1 -0
  232. package/client-dist/assets/{useBackgroundRevalidation-CULom4_W.js → useBackgroundRevalidation-C79HAUP3.js} +1 -1
  233. package/client-dist/assets/{useCodexUpdateStatus-BIDehnvt.js → useCodexUpdateStatus-CEZO_f2Y.js} +1 -1
  234. package/client-dist/assets/{useConnectedDevices-kBo43kbz.js → useConnectedDevices-Ds-DuUDc.js} +1 -1
  235. package/client-dist/assets/{useDocumentTitle-C06qawRj.js → useDocumentTitle-Xz5t-nlB.js} +1 -1
  236. package/client-dist/assets/{useEmulators-Bz8194e3.js → useEmulators-qS_cCZ3I.js} +1 -1
  237. package/client-dist/assets/{useFileActivity-CwkGwsQt.js → useFileActivity-BoW4X3DY.js} +1 -1
  238. package/client-dist/assets/{useFloatingActionButtonEnabled-C31rfHtR.js → useFloatingActionButtonEnabled-2_hw7nSa.js} +1 -1
  239. package/client-dist/assets/{useForkSummaryAutoOpen-D_SvtmbE.js → useForkSummaryAutoOpen-CS33Irpf.js} +1 -1
  240. package/client-dist/assets/{useGeneratedTitleLength-Cu-SoQ6T.js → useGeneratedTitleLength-D856ktVg.js} +1 -1
  241. package/client-dist/assets/{useKeepMobileKeyboardOpenAfterDelivery-C-cYLaEU.js → useKeepMobileKeyboardOpenAfterDelivery-Ba77SbWF.js} +1 -1
  242. package/client-dist/assets/useModelSettings-BdlYk1DT.js +1 -0
  243. package/client-dist/assets/{useNotifyInApp-BcLZ8ie_.js → useNotifyInApp-DcWe3dh4.js} +1 -1
  244. package/client-dist/assets/{useOnboarding-CYgE-Xsg.js → useOnboarding-CoE3WF8a.js} +1 -1
  245. package/client-dist/assets/{useProviders-C6kBPWYX.js → useProviders-CeN1PclA.js} +1 -1
  246. package/client-dist/assets/{useQuestionAsideSetting-6Excl6Pm.js → useQuestionAsideSetting-CPFw1u0y.js} +1 -1
  247. package/client-dist/assets/{useRecentSessions-CsmsGemq.js → useRecentSessions-ieTzzJu4.js} +2 -2
  248. package/client-dist/assets/{useRelativeNow-BdLaPgKO.js → useRelativeNow-Ca6QGcPa.js} +1 -1
  249. package/client-dist/assets/{useReloadNotifications-B0egr2ys.js → useReloadNotifications-Dm1jmdIb.js} +1 -1
  250. package/client-dist/assets/{useRemoteExecutors-Bgjgzif1.js → useRemoteExecutors-zBAQnQXH.js} +1 -1
  251. package/client-dist/assets/{useSidebarWidth-ut6NNk5Y.js → useSidebarWidth-CBCcbSLg.js} +1 -1
  252. package/client-dist/assets/{useSourceControlCleanLanding-DxrwogwF.js → useSourceControlCleanLanding-VDlft5tr.js} +1 -1
  253. package/client-dist/assets/{useStableToolPreviewRendering-CcrkchTG.js → useStableToolPreviewRendering-hbVp38Jd.js} +1 -1
  254. package/client-dist/assets/{useStreamingEnabled-EdvW04Vz.js → useStreamingEnabled-hU1g8i7_.js} +1 -1
  255. package/client-dist/assets/{useTabTitleActivityPreference-B0suFUHK.js → useTabTitleActivityPreference-DhREY7m2.js} +1 -1
  256. package/client-dist/assets/{useVhostAccess-2ZKr0Lcl.js → useVhostAccess-DUtn_sH1.js} +1 -1
  257. package/client-dist/assets/{useWorkflowTags-_4F_41YI.js → useWorkflowTags-DxbEBqtf.js} +1 -1
  258. package/client-dist/assets/{vennDiagram-4TSXK5OY-26XZDUe6.js → vennDiagram-4TSXK5OY-CSGBq-Ur.js} +1 -1
  259. package/client-dist/assets/{wardleyDiagram-VM6X3IG4-YvZ37BJ7.js → wardleyDiagram-VM6X3IG4-DIMvcaMb.js} +1 -1
  260. package/client-dist/assets/{xychartDiagram-S5SC5T6Z-BMT0MEGz.js → xychartDiagram-S5SC5T6Z-TYXSqT3w.js} +1 -1
  261. package/client-dist/assets/zh-CN-DadySLj9.js +7 -0
  262. package/client-dist/index.html +3 -3
  263. package/dist/app.d.ts.map +1 -1
  264. package/dist/app.js +29 -10
  265. package/dist/app.js.map +1 -1
  266. package/dist/artifacts/ArtifactServer.d.ts +2 -0
  267. package/dist/artifacts/ArtifactServer.d.ts.map +1 -1
  268. package/dist/artifacts/ArtifactServer.js +79 -1
  269. package/dist/artifacts/ArtifactServer.js.map +1 -1
  270. package/dist/auth/limitedUserPolicy.d.ts +9 -5
  271. package/dist/auth/limitedUserPolicy.d.ts.map +1 -1
  272. package/dist/auth/limitedUserPolicy.js +64 -35
  273. package/dist/auth/limitedUserPolicy.js.map +1 -1
  274. package/dist/auth/principal.d.ts +6 -0
  275. package/dist/auth/principal.d.ts.map +1 -1
  276. package/dist/auth/principal.js +6 -0
  277. package/dist/auth/principal.js.map +1 -1
  278. package/dist/frontend/static.d.ts.map +1 -1
  279. package/dist/frontend/static.js +2 -1
  280. package/dist/frontend/static.js.map +1 -1
  281. package/dist/middleware/authenticated-transport.d.ts +13 -0
  282. package/dist/middleware/authenticated-transport.d.ts.map +1 -1
  283. package/dist/middleware/authenticated-transport.js +12 -0
  284. package/dist/middleware/authenticated-transport.js.map +1 -1
  285. package/dist/middleware/limited-users.d.ts +9 -5
  286. package/dist/middleware/limited-users.d.ts.map +1 -1
  287. package/dist/middleware/limited-users.js +37 -23
  288. package/dist/middleware/limited-users.js.map +1 -1
  289. package/dist/routes/file-edit.d.ts +18 -0
  290. package/dist/routes/file-edit.d.ts.map +1 -0
  291. package/dist/routes/file-edit.js +244 -0
  292. package/dist/routes/file-edit.js.map +1 -0
  293. package/dist/routes/files.d.ts.map +1 -1
  294. package/dist/routes/files.js +34 -9
  295. package/dist/routes/files.js.map +1 -1
  296. package/dist/routes/pdfjs.d.ts +9 -0
  297. package/dist/routes/pdfjs.d.ts.map +1 -0
  298. package/dist/routes/pdfjs.js +34 -0
  299. package/dist/routes/pdfjs.js.map +1 -0
  300. package/dist/routes/public-file-shares.d.ts +6 -0
  301. package/dist/routes/public-file-shares.d.ts.map +1 -1
  302. package/dist/routes/public-file-shares.js +22 -10
  303. package/dist/routes/public-file-shares.js.map +1 -1
  304. package/dist/routes/public-shares.d.ts.map +1 -1
  305. package/dist/routes/public-shares.js +18 -1
  306. package/dist/routes/public-shares.js.map +1 -1
  307. package/dist/routes/recents.d.ts +4 -1
  308. package/dist/routes/recents.d.ts.map +1 -1
  309. package/dist/routes/recents.js +7 -0
  310. package/dist/routes/recents.js.map +1 -1
  311. package/dist/routes/sessions.d.ts.map +1 -1
  312. package/dist/routes/sessions.js +4 -0
  313. package/dist/routes/sessions.js.map +1 -1
  314. package/dist/routes/settings.d.ts +7 -2
  315. package/dist/routes/settings.d.ts.map +1 -1
  316. package/dist/routes/settings.js +43 -1
  317. package/dist/routes/settings.js.map +1 -1
  318. package/dist/routes/version.d.ts.map +1 -1
  319. package/dist/routes/version.js +1 -0
  320. package/dist/routes/version.js.map +1 -1
  321. package/dist/routes/ws-relay-handlers.d.ts +12 -0
  322. package/dist/routes/ws-relay-handlers.d.ts.map +1 -1
  323. package/dist/routes/ws-relay-handlers.js +25 -4
  324. package/dist/routes/ws-relay-handlers.js.map +1 -1
  325. package/dist/routes/ws-relay.d.ts.map +1 -1
  326. package/dist/routes/ws-relay.js +8 -0
  327. package/dist/routes/ws-relay.js.map +1 -1
  328. package/dist/sdk/providers/agent-self.js +1 -1
  329. package/dist/sdk/providers/agent-self.js.map +1 -1
  330. package/dist/sdk/providers/claude.d.ts +1 -0
  331. package/dist/sdk/providers/claude.d.ts.map +1 -1
  332. package/dist/sdk/providers/claude.js +7 -0
  333. package/dist/sdk/providers/claude.js.map +1 -1
  334. package/dist/sdk/providers/codex-model-catalog.d.ts.map +1 -1
  335. package/dist/sdk/providers/codex-model-catalog.js +5 -3
  336. package/dist/sdk/providers/codex-model-catalog.js.map +1 -1
  337. package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts +4 -1
  338. package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts.map +1 -1
  339. package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts +4 -1
  340. package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts.map +1 -1
  341. package/dist/sdk/providers/codex-protocol/generated/Personality.d.ts +3 -0
  342. package/dist/sdk/providers/codex-protocol/generated/Personality.d.ts.map +1 -1
  343. package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.d.ts +2 -0
  344. package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.d.ts.map +1 -0
  345. package/dist/sdk/providers/codex-protocol/generated/v2/{ThreadRollbackParams.js → McpAppDisplayMode.js} +1 -1
  346. package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.js.map +1 -0
  347. package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.d.ts +9 -0
  348. package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.d.ts.map +1 -0
  349. package/dist/sdk/providers/codex-protocol/generated/v2/{ThreadRollbackResponse.js → McpAppUi.js} +1 -1
  350. package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.js.map +1 -0
  351. package/dist/sdk/providers/codex-protocol/generated/v2/Thread.d.ts +1 -1
  352. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkResponse.d.ts +4 -0
  353. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkResponse.d.ts.map +1 -1
  354. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts +6 -1
  355. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts.map +1 -1
  356. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeParams.d.ts +4 -0
  357. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeParams.d.ts.map +1 -1
  358. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts +9 -0
  359. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts.map +1 -1
  360. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts +9 -0
  361. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts.map +1 -1
  362. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartResponse.d.ts +4 -0
  363. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartResponse.d.ts.map +1 -1
  364. package/dist/sdk/providers/codex-protocol/generated/v2/TurnStartParams.d.ts +7 -1
  365. package/dist/sdk/providers/codex-protocol/generated/v2/TurnStartParams.d.ts.map +1 -1
  366. package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts +3 -0
  367. package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts.map +1 -1
  368. package/dist/sdk/providers/codex-protocol/index.d.ts +0 -2
  369. package/dist/sdk/providers/codex-protocol/index.d.ts.map +1 -1
  370. package/dist/sdk/providers/codex.d.ts +23 -2
  371. package/dist/sdk/providers/codex.d.ts.map +1 -1
  372. package/dist/sdk/providers/codex.js +55 -22
  373. package/dist/sdk/providers/codex.js.map +1 -1
  374. package/dist/sdk/providers/index.d.ts.map +1 -1
  375. package/dist/sdk/providers/index.js +4 -1
  376. package/dist/sdk/providers/index.js.map +1 -1
  377. package/dist/sdk/providers/opencode.d.ts +9 -0
  378. package/dist/sdk/providers/opencode.d.ts.map +1 -1
  379. package/dist/sdk/providers/opencode.js +129 -76
  380. package/dist/sdk/providers/opencode.js.map +1 -1
  381. package/dist/sdk/providers/provider-session-owner.d.ts +9 -0
  382. package/dist/sdk/providers/provider-session-owner.d.ts.map +1 -1
  383. package/dist/sdk/providers/provider-session-owner.js +39 -3
  384. package/dist/sdk/providers/provider-session-owner.js.map +1 -1
  385. package/dist/sdk/providers/types.d.ts +13 -0
  386. package/dist/sdk/providers/types.d.ts.map +1 -1
  387. package/dist/sdk/providers/types.js.map +1 -1
  388. package/dist/services/ArtifactRebuildService.d.ts +67 -0
  389. package/dist/services/ArtifactRebuildService.d.ts.map +1 -0
  390. package/dist/services/ArtifactRebuildService.js +229 -0
  391. package/dist/services/ArtifactRebuildService.js.map +1 -0
  392. package/dist/services/DirtyFileEditorService.d.ts +2 -0
  393. package/dist/services/DirtyFileEditorService.d.ts.map +1 -1
  394. package/dist/services/DirtyFileEditorService.js +20 -1
  395. package/dist/services/DirtyFileEditorService.js.map +1 -1
  396. package/dist/services/PdfjsAssetCache.d.ts +20 -0
  397. package/dist/services/PdfjsAssetCache.d.ts.map +1 -0
  398. package/dist/services/PdfjsAssetCache.js +131 -0
  399. package/dist/services/PdfjsAssetCache.js.map +1 -0
  400. package/dist/services/SessionCatalogService.d.ts +27 -0
  401. package/dist/services/SessionCatalogService.d.ts.map +1 -1
  402. package/dist/services/SessionCatalogService.js +129 -34
  403. package/dist/services/SessionCatalogService.js.map +1 -1
  404. package/dist/sessions/opencode-reader.d.ts +2 -1
  405. package/dist/sessions/opencode-reader.d.ts.map +1 -1
  406. package/dist/sessions/opencode-reader.js +30 -1
  407. package/dist/sessions/opencode-reader.js.map +1 -1
  408. package/dist/sessions/types.d.ts +6 -0
  409. package/dist/sessions/types.d.ts.map +1 -1
  410. package/dist/supervisor/Process.d.ts +7 -0
  411. package/dist/supervisor/Process.d.ts.map +1 -1
  412. package/dist/supervisor/Process.js +48 -3
  413. package/dist/supervisor/Process.js.map +1 -1
  414. package/dist/supervisor/Supervisor.d.ts.map +1 -1
  415. package/dist/supervisor/Supervisor.js +11 -0
  416. package/dist/supervisor/Supervisor.js.map +1 -1
  417. package/dist/supervisor/types.d.ts +3 -1
  418. package/dist/supervisor/types.d.ts.map +1 -1
  419. package/dist/supervisor/types.js.map +1 -1
  420. package/package.json +3 -3
  421. package/client-dist/assets/AboutSettings-BlEONE7w.js +0 -1
  422. package/client-dist/assets/AgentsPage-CBku9RWz.js +0 -2
  423. package/client-dist/assets/App-DWHvFKob.js +0 -2
  424. package/client-dist/assets/AppearanceSettings-BSEBjSjr.js +0 -2
  425. package/client-dist/assets/AppsSettings-iDL6Xuaa.js +0 -1
  426. package/client-dist/assets/AttachmentChip-DHKr4EfG.js +0 -1
  427. package/client-dist/assets/BangCommandsPage-yX8grXp9.js +0 -1
  428. package/client-dist/assets/BrowserDebugToolbarButton-B-b7N4cr.js +0 -1
  429. package/client-dist/assets/ComputerControlSettings-DzRDwfJ1.js +0 -1
  430. package/client-dist/assets/DevelopmentSettings-Bf9gyeU0.js +0 -1
  431. package/client-dist/assets/DevicesSettings-dbZHFEEc.js +0 -1
  432. package/client-dist/assets/EmulatorPage-CKJwVTFq.js +0 -1
  433. package/client-dist/assets/EmulatorSettings-BV9Bg3Xk.js +0 -1
  434. package/client-dist/assets/EnvironmentSettings-DmOTuSwm.js +0 -1
  435. package/client-dist/assets/FilePage-DnPW5Pbc.js +0 -1
  436. package/client-dist/assets/FilterDropdown-CB_tRt6g.css +0 -1
  437. package/client-dist/assets/FilterDropdown-DpS1eMEf.js +0 -1
  438. package/client-dist/assets/FloatingActionButton-DBIoFwff.js +0 -1
  439. package/client-dist/assets/GlobalSessionsPage-Dbnuis89.css +0 -1
  440. package/client-dist/assets/GlobalSessionsPage-DcmQcX7q.js +0 -2
  441. package/client-dist/assets/HostIdentityContext-D5aBdejC.js +0 -1
  442. package/client-dist/assets/HostsPage-C1ZTrhJv.js +0 -1
  443. package/client-dist/assets/InboxPage-Cepu8VGM.js +0 -1
  444. package/client-dist/assets/IssueSettings-xRU8E-xR.js +0 -1
  445. package/client-dist/assets/IssuesPage-c6PUStFT.js +0 -1
  446. package/client-dist/assets/LifecycleWebhooksSettings-CZcZATjJ.js +0 -1
  447. package/client-dist/assets/MessageInput-B0t6b_Hd.js +0 -3
  448. package/client-dist/assets/MessageInputToolbar-DdP4tB2S.css +0 -1
  449. package/client-dist/assets/MessageInputToolbar-rhYW1xGJ.js +0 -58
  450. package/client-dist/assets/MessageList-Dcvfxbeq.css +0 -1
  451. package/client-dist/assets/MessageList-dH63bflu.js +0 -4
  452. package/client-dist/assets/Modal-QUinFhBP.js +0 -16
  453. package/client-dist/assets/ModelSettings-CcWkVSEK.js +0 -1
  454. package/client-dist/assets/NavigationLayout-BkOsag-J.js +0 -2
  455. package/client-dist/assets/NewSessionPage-DcZ9YjmC.js +0 -1
  456. package/client-dist/assets/NotificationsSettings-DoVzfeME.js +0 -1
  457. package/client-dist/assets/PageHeader-BaYMLVHI.js +0 -1
  458. package/client-dist/assets/PerformanceSettings-dwoVtUlX.js +0 -1
  459. package/client-dist/assets/ProjectTemplatesSettings-BlMWq1wb.js +0 -1
  460. package/client-dist/assets/ProjectsPage-B5VBairc.js +0 -1
  461. package/client-dist/assets/ProviderChildSessionPage-B3eTTTjF.js +0 -1
  462. package/client-dist/assets/ProvidersSettings-OUKp5-Hb.js +0 -1
  463. package/client-dist/assets/RemoteAccessSettings-Bn0ng7s4.js +0 -1
  464. package/client-dist/assets/RemoteExecutorsSettings-2Qh-9Qv_.js +0 -1
  465. package/client-dist/assets/SchemaValidationContext-CIAd7icg.js +0 -1
  466. package/client-dist/assets/SessionPage-B1g1UFEV.js +0 -49
  467. package/client-dist/assets/SessionPage-BiV0X3n1.css +0 -1
  468. package/client-dist/assets/SourceControlSettings-BQfC1KbV.js +0 -1
  469. package/client-dist/assets/SpeechControlMenu-BIv0O1la.js +0 -2
  470. package/client-dist/assets/StorageSettings-DQcG9Mbq.js +0 -1
  471. package/client-dist/assets/ToolbarSettings-CmHVAejU.js +0 -1
  472. package/client-dist/assets/UsersSettings-COgiiV9D.js +0 -1
  473. package/client-dist/assets/WorkstreamsPage-DKLRDEAp.js +0 -1
  474. package/client-dist/assets/channel-C-7AVqtf.js +0 -1
  475. package/client-dist/assets/classDiagram-ZZMXUADV-DkRr8VcO.js +0 -1
  476. package/client-dist/assets/classDiagram-v2-VYDZK3BY-DkRr8VcO.js +0 -1
  477. package/client-dist/assets/de-DKHK9Tu3.js +0 -6
  478. package/client-dist/assets/es-XSkBrKBg.js +0 -6
  479. package/client-dist/assets/fr-DKUJaPhN.js +0 -6
  480. package/client-dist/assets/index-BBpZzMBa.js +0 -2
  481. package/client-dist/assets/index-BUrcmRdN.js +0 -76
  482. package/client-dist/assets/index-CA-BRFYh.js +0 -1
  483. package/client-dist/assets/index-wA2zlxt-.css +0 -1
  484. package/client-dist/assets/ja-BDnQUlyD.js +0 -6
  485. package/client-dist/assets/long-context-effort-warning-BGls6uvf.js +0 -1
  486. package/client-dist/assets/newSessionPrefill-DkkSfnYR.js +0 -1
  487. package/client-dist/assets/providerChildSessions-ClrSXOQr.js +0 -80
  488. package/client-dist/assets/providerChildSessions-D2O1SLei.css +0 -1
  489. package/client-dist/assets/sessionHistorySearch.worker-BGlVvPYq.js +0 -60
  490. package/client-dist/assets/stateDiagram-v2-MP3YSRHH-CBvcZngO.js +0 -1
  491. package/client-dist/assets/swimlanesDiagram-VR7AAH4N-DKVyQBDp.js +0 -8
  492. package/client-dist/assets/useAcliCommentarySetting-DxndlmkH.js +0 -9
  493. package/client-dist/assets/useActivityBusState-CINl9yjP.js +0 -1
  494. package/client-dist/assets/useModelSettings-DoDJRymT.js +0 -1
  495. package/client-dist/assets/zh-CN-FVXKSeP_.js +0 -7
  496. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts +0 -14
  497. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts.map +0 -1
  498. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.js.map +0 -1
  499. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.d.ts +0 -12
  500. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.d.ts.map +0 -1
  501. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.js.map +0 -1
  502. /package/client-dist/assets/{Modal-EC-u4IZ7.css → index-EC-u4IZ7.css} +0 -0
@@ -1,25 +1,25 @@
1
- var Pc=Object.defineProperty;var Ec=(e,t,n)=>t in e?Pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var be=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);import{u as Z,r as m,bp as yn,j as s,ax as br,bt as pa,ct as Ic,cu as Mc,cv as vo,cz as $c,cA as Lc,cE as Ac,cx as wo,cF as Fc,cG as Bc,cH as _o,cy as Dc,ck as I,cl as Ke,cn as ce,cm as ke,cI as te,cJ as Xe,cK as J,cL as Oc,cM as qn,cN as Uc,cO as Hc,cP as Wc,cQ as Js,cR as Vc,cS as Gc,cT as zc,cU as qc,cV as Kc,cW as Xc,cX as Yc,cY as Jc,cZ as Qc,c_ as Zc,c$ as ed,d0 as td,d1 as nd,d2 as sd,d3 as rd,L as vr,d4 as us,bV as ms,s as ga,d5 as xa,ca as Lt,d6 as od,d7 as id,bu as Ss,d8 as No,d9 as ko}from"./index-BUrcmRdN.js";import{F as Kn,V as nn,Z as ya,a as on,X as fs,aA as ad,aB as ld,Y as cd}from"./client-sN_tbfxh.js";import{b7 as dd,b8 as ud,b9 as md,ba as fd,bb as wr,bc as _r,bd as ja,be as Nr,b0 as ba,k as va,bf as hd,l as tt,bg as hs,e as kr,X as qt,A as ps,I as pd,E as gd,Y as Sr,r as wa,bh as _a,K as Cr,z as ge,bi as Tr,bj as Rr,bk as Na,bl as xd,bm as yd,bn as jd,bo as bd,V as ka,bp as vd,bq as Sa,br as Ca,bs as wd,Z as oe,bt as Pr,bu as _d,bv as Nd,L as rt,bw as kd,bx as Sd,by as Ye,$ as Cd,a$ as Td,bz as Rd,bA as mn,bB as Pd,bC as gs,bD as Ta,bE as Ed,ab as Id,bF as Md,bG as So,bH as $d,bI as Ld,bJ as Er,bK as Ra,bL as Ad,bM as Fd,M as Pa,bN as Ea,y as Bd,bO as Dd,bP as Od,bQ as Co,_ as Ud,bR as Hd,bS as Wd,bT as Vd,m as Ia,b3 as Gd}from"./providerChildSessions-ClrSXOQr.js";import{l as zd,L as St,T as Ir,u as qd,a as Kd}from"./useAcliCommentarySetting-DxndlmkH.js";import{i as Xd}from"./postCompactReplay-D6HuoQK2.js";import{a as xs,b as Yd}from"./recentProjectPathLinks-Ba20jx5b.js";import{b as Kt,F as Jd,C as Ma,M as $a,u as Mr,h as La}from"./Modal-QUinFhBP.js";import{M as Qd}from"./MessageAge-Cd1C0-Kr.js";import{B as Zd}from"./BangCommandDisplayObject-B8KrHDzH.js";import{u as Aa,A as eu}from"./AttachmentChip-DHKr4EfG.js";import{a as Cs,r as Cn}from"./browserDebugPerformance-ZT9tAT-A.js";import{u as tu}from"./useStableToolPreviewRendering-CcrkchTG.js";import{a as ve}from"./SchemaValidationContext-CIAd7icg.js";import{S as nu}from"./SourceFileHeaderActions-3_76js_o.js";function mt(e,t){const n=e.slice(0,4097),r=n.indexOf(`
2
- `),o=r<0?n:n.slice(0,r);return(r>=0||t)&&o.length<=4096?dd(o):null}class Fa{constructor(t="stdout"){be(this,"source","");be(this,"framer",null);be(this,"format","raw");be(this,"previous",null);be(this,"textBlock",[]);be(this,"afterCommentary",!1);be(this,"nextId",0);this.channel=t}appendSnapshot(t,n,r){let o=this.source.length;if(!this.framer){const a=t.indexOf(`
3
- `);if(a<0&&!n)return[];const l=mt(t,n);this.format=l==="lines"?"lines":r?"json":"raw",this.framer=new ud(this.format==="json"?"json":"lines"),l&&(o=a<0?t.length:a+1)}const i=this.framer.append(t.slice(o));return this.source=t,n&&i.push(...this.framer.finish()),i.map(a=>{const l=this.format==="json"?md(a):this.format==="lines"?fd(a):{source:a,data:a,commentary:[],removed:[],metadataOnly:!1};let c=null;if(this.channel==="stdout"||this.channel==="unknown"&&this.format==="json"){const d=this.previous,u=this.textBlock;this.format==="lines"&&u.length?c=()=>u.join(""):d&&(c=()=>d.data)}return l.metadataOnly?this.afterCommentary=!0:(this.format==="lines"&&(this.afterCommentary&&(this.textBlock=[]),this.textBlock.push(l.data)),this.afterCommentary=!1,a.trim()&&(this.previous=l)),{id:this.nextId++,record:l,getPreviousContext:c}})}}function Qs(e,t){return[...t.metadataOnly?[]:[{id:e,text:t.data,kind:"data",opaque:t.json}],...t.commentary.map(n=>({id:`${e}:${n.id}`,text:n.text,kind:"commentary"}))]}const su=/<ide_(opened_file|selection)>[\s\S]*?<\/ide_\1>/g,ru=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g;function ou(e){return e.replace(su,"").trim()}function iu(e){const t=e.match(/(?:user opened the file|opened the file)\s+(.+?)\s+in the IDE/i);return(t==null?void 0:t[1])??null}function au(e){const t=[];for(const n of e.matchAll(ru)){const r=n[1];if(r){const o=iu(r);o&&t.push(o)}}return t}function lu(e){const t=e.split(/[\\/]/);return t[t.length-1]||e}function Zs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ba(e){try{return JSON.parse(e)}catch{return}}const cu=new Set(["chunk_id","wall_time_seconds","exit_code","output","session_id","original_token_count"]),du=new Set(["i","status","value"]);function uu(e){let t=Ba(e);if(Zs(t)){if(t.status==="fulfilled"){if(!Object.keys(t).every(n=>du.has(n))||t.i!==void 0&&(!Number.isInteger(t.i)||Number(t.i)<0))return;t=t.value}if(!(!Zs(t)||!Object.keys(t).every(n=>cu.has(n))||typeof t.chunk_id!="string"||!t.chunk_id||typeof t.output!="string"||typeof t.wall_time_seconds!="number"||!Number.isFinite(t.wall_time_seconds)||t.wall_time_seconds<0)&&!(t.exit_code!==void 0&&(typeof t.exit_code!="number"||!Number.isInteger(t.exit_code)))&&!(t.session_id!==void 0&&!(typeof t.session_id=="string"&&t.session_id.length>0)&&!(typeof t.session_id=="number"&&Number.isInteger(t.session_id)&&t.session_id>=0))&&!(t.exit_code===void 0&&t.session_id===void 0)&&!(t.original_token_count!==void 0&&!(typeof t.original_token_count=="number"&&Number.isInteger(t.original_token_count)&&t.original_token_count>=0)))return{kind:"command-output",text:t.output,durationSeconds:t.wall_time_seconds,...typeof t.exit_code=="number"?{exitCode:t.exit_code}:{},...typeof t.session_id=="string"||typeof t.session_id=="number"?{sessionId:t.session_id}:{}}}}function ht(e,t={}){const n=typeof e=="string"?Ba(e):e;if(!Array.isArray(n)||n.length===0)return;const r=[];for(const o of n){if(!Zs(o)||typeof o.type!="string"||!["input_text","output_text","text"].includes(o.type)||typeof o.text!="string")return;const i=o.text;r.length===0&&/^Script (?:completed|running with cell ID \w+)\r?\nWall time[^\n]*\r?\nOutput:\r?\n$/.test(i)?r.push({kind:"script-status",text:i.replace(/\r?\nOutput:\r?\n$/,"")}):r.push((t.commandResults!=="preserve"?uu(i):void 0)??{kind:"text",text:i})}return{parts:r}}const Tn=["black","red","green","yellow","blue","magenta","cyan","white"];function Da(){return{fg:null,bg:null,bold:!1,italic:!1,underline:!1,inverse:!1,strikethrough:!1}}function mu(e){const t=[],n=e.inverse?e.bg:e.fg,r=e.inverse?e.fg:e.bg;return n&&t.push(`ansi-fg-${n}`),r&&t.push(`ansi-bg-${r}`),e.inverse&&!n&&!r&&t.push("ansi-inverse"),e.bold&&t.push("ansi-bold"),e.italic&&t.push("ansi-italic"),e.underline&&t.push("ansi-underline"),e.strikethrough&&t.push("ansi-strikethrough"),t}function fu(e,t){let n=0;for(;n<t.length;){const r=t[n]??0;if(r===0)Object.assign(e,Da());else if(r===1)e.bold=!0;else if(r===3)e.italic=!0;else if(r===4)e.underline=!0;else if(r===7)e.inverse=!0;else if(r===9)e.strikethrough=!0;else if(r===22)e.bold=!1;else if(r===23)e.italic=!1;else if(r===24)e.underline=!1;else if(r===27)e.inverse=!1;else if(r===29)e.strikethrough=!1;else if(r>=30&&r<=37)e.fg=Tn[r-30]??null;else if(r===38){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.fg=null}else if(r===39)e.fg=null;else if(r>=40&&r<=47)e.bg=Tn[r-40]??null;else if(r===48){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.bg=null}else r===49?e.bg=null:r>=90&&r<=97?e.fg=`bright-${Tn[r-90]}`:r>=100&&r<=107&&(e.bg=`bright-${Tn[r-100]}`);n++}}function To(e){return zd(e,{},hu)}function hu(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const pu=/[\d;:?\s]/;function gu(e){return e.indexOf("\x1B[")!==-1}function xu(e){const t=Da();let n="",r="",o=0;const i=()=>{if(r.length===0)return;const a=mu(t);a.length>0?n+=`<span class="${a.join(" ")}">${To(r)}</span>`:n+=To(r),r=""};for(;o<e.length;){const a=e[o];if(a==="\x1B"&&e[o+1]==="["){i();let l=o+2,c="";for(;l<e.length&&pu.test(e[l]??"");)c+=e[l],l++;const d=e[l]??"";if(d==="m"){const u=c.length>0?c.split(";").map(f=>parseInt(f,10)||0):[0];fu(t,u)}o=l+(d?1:0)}else if(a==="\x1B"&&e[o+1]==="]"){i();let l=o+2;for(;l<e.length;){const c=e[l];if(c==="\x07"){l++;break}if(c==="\x1B"&&e[l+1]==="\\"){l+=2;break}l++}o=l}else a==="\x1B"?(i(),o+=e[o+1]!==void 0?2:1):(r+=a,o++)}return i(),n}const yu="<synthetic>",ju="Continue from where you left off.",bu="No response requested.";function Oa(e){const t=e.message&&typeof e.message=="object"?e.message:void 0,n=(t==null?void 0:t.content)??e.content;return typeof n=="string"?n.trim():Array.isArray(n)&&n.filter(o=>!!o&&typeof o=="object"&&o.type==="text"&&typeof o.text=="string").map(o=>o.text).join("").trim()||void 0}function vu(e){var n;if(!e||typeof e!="object")return!1;const t=(n=e.message)==null?void 0:n.role;return e.type!=="user"&&t!=="user"||e.isMeta!==!0?!1:Oa(e)===ju}function wu(e){if(!e||typeof e!="object")return!1;const t=e.message&&typeof e.message=="object"?e.message:void 0;return e.type!=="assistant"&&(t==null?void 0:t.role)!=="assistant"||(t==null?void 0:t.model)!==yu?!1:Oa(e)===bu}function st(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ut(e){return st(e)?e:null}const _u="_notice_ztq97_1",Nu="_label_ztq97_16",ku="_objective_ztq97_21",Su="_flag_ztq97_27",Dn={notice:_u,label:Nu,objective:ku,flag:Su};function Cu({objective:e,status:t}){const{t:n}=Z();return s.jsxs("div",{className:Dn.notice,title:t,children:[s.jsx("strong",{className:Dn.label,children:n("goalNoticeLabel")}),s.jsx("span",{className:Dn.objective,children:s.jsx(St,{text:e})})]})}function W_({objective:e,status:t,onToggle:n,onEdit:r}){const{t:o}=Z(),[i,a]=m.useState(!1),l=t==="active"?"pause":t==="paused"||t==="blocked"||t==="usageLimited"?"resume":void 0,c={active:o("goalStatusActive"),paused:o("goalStatusPaused"),blocked:o("goalStatusBlocked"),usageLimited:o("goalStatusUsageLimited"),budgetLimited:o("goalStatusBudgetLimited"),complete:o("goalStatusComplete")},d=t?c[t]??t:void 0,u=yn([d&&o("goalFlagStatus",{status:d}),e,i?o("goalFlagUpdating"):n&&l?o(l==="pause"?"goalFlagPauseHint":"goalFlagResumeHint"):void 0].filter(Boolean).join(`
1
+ var Pc=Object.defineProperty;var Ec=(e,t,n)=>t in e?Pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var be=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);import{u as Z,r as m,bp as yn,j as s,ax as br,bt as pa,cv as Ic,cw as Mc,cx as vo,cB as $c,cC as Lc,cE as Ac,cz as wo,cF as Fc,cG as Bc,cH as _o,cA as Dc,cm as I,cn as Ke,cp as ce,co as ke,cI as te,cJ as Xe,cK as J,cL as Oc,cM as qn,cN as Uc,cO as Hc,cP as Wc,cQ as Js,cR as Vc,cS as Gc,cT as zc,cU as qc,cV as Kc,cW as Xc,cX as Yc,cY as Jc,cZ as Qc,c_ as Zc,c$ as ed,d0 as td,d1 as nd,d2 as sd,d3 as rd,L as vr,d4 as us,bV as ms,s as ga,d5 as xa,cc as Lt,d6 as od,d7 as id,bu as Ss,d8 as No,d9 as ko}from"./index-umZg0LZ6.js";import{H as Kn,V as nn,Z as ya,a as on,X as fs,aA as ad,aB as ld,Y as cd}from"./client-Ci_HPGfl.js";import{ao as at,a4 as dd,g as tt,a7 as hs,b as wr,p as qt,f as ps,h as ud,q as _r,k as Nr,e as ge,ap as kr,a0 as ja,a2 as md,L as ba,aq as fd,r as oe,$ as hd,v as pd,S as gd,ar as gs,X as Sr,as as va,d as xd,at as Ut,au as yd,O as jd}from"./LocalMediaModal-B9eHVx6y.js";import{l as bd,L as St,T as Cr,u as vd,a as wd}from"./useAcliCommentarySetting-CBKAl7qr.js";import{i as _d}from"./postCompactReplay-D6HuoQK2.js";import{aA as Nd,aB as kd,aC as Sd,aD as Cd,aE as Tr,aF as Rr,aG as wa,aH as Pr,ax as _a,i as Na,o as Td,r as ka,aI as Sa,aJ as Er,aK as Rd,aL as Pd,aM as Ed,R as Ca,aN as Id,aO as Ta,aP as Ir,aQ as Md,q as st,aR as $d,aS as Ld,aT as Ye,aU as Ad,aV as mn,aW as Fd,aX as Ra,aY as Bd,O as Dd,aZ as Od,a_ as So,a$ as Ud,b0 as Hd,b1 as Wd,b2 as Vd,M as Pa,b3 as Ea,b4 as Gd,b5 as zd,b6 as Co,w as qd,b7 as Kd,b8 as Xd,j as Ia}from"./providerChildSessions-DbLFSybt.js";import{a as xs,b as Yd}from"./recentProjectPathLinks-D0Dx6YXT.js";import{C as Ma}from"./index-CoR-vzsb.js";import{M as Jd}from"./MessageAge-CaPpa1nH.js";import{B as Qd}from"./BangCommandDisplayObject-BH2KRGnc.js";import{u as $a,A as Zd}from"./AttachmentChip-BFve3lTD.js";import{a as Cs,r as Cn}from"./browserDebugPerformance-ZT9tAT-A.js";import{b as Kt,x as eu,M as La,u as Mr,g as Aa}from"./Modal-ClSjJagX.js";import{u as tu}from"./useStableToolPreviewRendering-hbVp38Jd.js";import{a as ve}from"./SchemaValidationContext-57RCj4c4.js";import{S as nu}from"./SourceFileHeaderActions-PjhUGnn6.js";function mt(e,t){const n=e.slice(0,4097),r=n.indexOf(`
2
+ `),o=r<0?n:n.slice(0,r);return(r>=0||t)&&o.length<=4096?Nd(o):null}class Fa{constructor(t="stdout"){be(this,"source","");be(this,"framer",null);be(this,"format","raw");be(this,"previous",null);be(this,"textBlock",[]);be(this,"afterCommentary",!1);be(this,"nextId",0);this.channel=t}appendSnapshot(t,n,r){let o=this.source.length;if(!this.framer){const a=t.indexOf(`
3
+ `);if(a<0&&!n)return[];const l=mt(t,n);this.format=l==="lines"?"lines":r?"json":"raw",this.framer=new kd(this.format==="json"?"json":"lines"),l&&(o=a<0?t.length:a+1)}const i=this.framer.append(t.slice(o));return this.source=t,n&&i.push(...this.framer.finish()),i.map(a=>{const l=this.format==="json"?Sd(a):this.format==="lines"?Cd(a):{source:a,data:a,commentary:[],removed:[],metadataOnly:!1};let c=null;if(this.channel==="stdout"||this.channel==="unknown"&&this.format==="json"){const d=this.previous,u=this.textBlock;this.format==="lines"&&u.length?c=()=>u.join(""):d&&(c=()=>d.data)}return l.metadataOnly?this.afterCommentary=!0:(this.format==="lines"&&(this.afterCommentary&&(this.textBlock=[]),this.textBlock.push(l.data)),this.afterCommentary=!1,a.trim()&&(this.previous=l)),{id:this.nextId++,record:l,getPreviousContext:c}})}}function Qs(e,t){return[...t.metadataOnly?[]:[{id:e,text:t.data,kind:"data",opaque:t.json}],...t.commentary.map(n=>({id:`${e}:${n.id}`,text:n.text,kind:"commentary"}))]}const su=/<ide_(opened_file|selection)>[\s\S]*?<\/ide_\1>/g,ru=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g;function ou(e){return e.replace(su,"").trim()}function iu(e){const t=e.match(/(?:user opened the file|opened the file)\s+(.+?)\s+in the IDE/i);return(t==null?void 0:t[1])??null}function au(e){const t=[];for(const n of e.matchAll(ru)){const r=n[1];if(r){const o=iu(r);o&&t.push(o)}}return t}function lu(e){const t=e.split(/[\\/]/);return t[t.length-1]||e}function Zs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ba(e){try{return JSON.parse(e)}catch{return}}const cu=new Set(["chunk_id","wall_time_seconds","exit_code","output","session_id","original_token_count"]),du=new Set(["i","status","value"]);function uu(e){let t=Ba(e);if(Zs(t)){if(t.status==="fulfilled"){if(!Object.keys(t).every(n=>du.has(n))||t.i!==void 0&&(!Number.isInteger(t.i)||Number(t.i)<0))return;t=t.value}if(!(!Zs(t)||!Object.keys(t).every(n=>cu.has(n))||typeof t.chunk_id!="string"||!t.chunk_id||typeof t.output!="string"||typeof t.wall_time_seconds!="number"||!Number.isFinite(t.wall_time_seconds)||t.wall_time_seconds<0)&&!(t.exit_code!==void 0&&(typeof t.exit_code!="number"||!Number.isInteger(t.exit_code)))&&!(t.session_id!==void 0&&!(typeof t.session_id=="string"&&t.session_id.length>0)&&!(typeof t.session_id=="number"&&Number.isInteger(t.session_id)&&t.session_id>=0))&&!(t.exit_code===void 0&&t.session_id===void 0)&&!(t.original_token_count!==void 0&&!(typeof t.original_token_count=="number"&&Number.isInteger(t.original_token_count)&&t.original_token_count>=0)))return{kind:"command-output",text:t.output,durationSeconds:t.wall_time_seconds,...typeof t.exit_code=="number"?{exitCode:t.exit_code}:{},...typeof t.session_id=="string"||typeof t.session_id=="number"?{sessionId:t.session_id}:{}}}}function ht(e,t={}){const n=typeof e=="string"?Ba(e):e;if(!Array.isArray(n)||n.length===0)return;const r=[];for(const o of n){if(!Zs(o)||typeof o.type!="string"||!["input_text","output_text","text"].includes(o.type)||typeof o.text!="string")return;const i=o.text;r.length===0&&/^Script (?:completed|running with cell ID \w+)\r?\nWall time[^\n]*\r?\nOutput:\r?\n$/.test(i)?r.push({kind:"script-status",text:i.replace(/\r?\nOutput:\r?\n$/,"")}):r.push((t.commandResults!=="preserve"?uu(i):void 0)??{kind:"text",text:i})}return{parts:r}}const Tn=["black","red","green","yellow","blue","magenta","cyan","white"];function Da(){return{fg:null,bg:null,bold:!1,italic:!1,underline:!1,inverse:!1,strikethrough:!1}}function mu(e){const t=[],n=e.inverse?e.bg:e.fg,r=e.inverse?e.fg:e.bg;return n&&t.push(`ansi-fg-${n}`),r&&t.push(`ansi-bg-${r}`),e.inverse&&!n&&!r&&t.push("ansi-inverse"),e.bold&&t.push("ansi-bold"),e.italic&&t.push("ansi-italic"),e.underline&&t.push("ansi-underline"),e.strikethrough&&t.push("ansi-strikethrough"),t}function fu(e,t){let n=0;for(;n<t.length;){const r=t[n]??0;if(r===0)Object.assign(e,Da());else if(r===1)e.bold=!0;else if(r===3)e.italic=!0;else if(r===4)e.underline=!0;else if(r===7)e.inverse=!0;else if(r===9)e.strikethrough=!0;else if(r===22)e.bold=!1;else if(r===23)e.italic=!1;else if(r===24)e.underline=!1;else if(r===27)e.inverse=!1;else if(r===29)e.strikethrough=!1;else if(r>=30&&r<=37)e.fg=Tn[r-30]??null;else if(r===38){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.fg=null}else if(r===39)e.fg=null;else if(r>=40&&r<=47)e.bg=Tn[r-40]??null;else if(r===48){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.bg=null}else r===49?e.bg=null:r>=90&&r<=97?e.fg=`bright-${Tn[r-90]}`:r>=100&&r<=107&&(e.bg=`bright-${Tn[r-100]}`);n++}}function To(e){return bd(e,{external:!0},hu)}function hu(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const pu=/[\d;:?\s]/;function gu(e){return e.indexOf("\x1B[")!==-1}function xu(e){const t=Da();let n="",r="",o=0;const i=()=>{if(r.length===0)return;const a=mu(t);a.length>0?n+=`<span class="${a.join(" ")}">${To(r)}</span>`:n+=To(r),r=""};for(;o<e.length;){const a=e[o];if(a==="\x1B"&&e[o+1]==="["){i();let l=o+2,c="";for(;l<e.length&&pu.test(e[l]??"");)c+=e[l],l++;const d=e[l]??"";if(d==="m"){const u=c.length>0?c.split(";").map(f=>parseInt(f,10)||0):[0];fu(t,u)}o=l+(d?1:0)}else if(a==="\x1B"&&e[o+1]==="]"){i();let l=o+2;for(;l<e.length;){const c=e[l];if(c==="\x07"){l++;break}if(c==="\x1B"&&e[l+1]==="\\"){l+=2;break}l++}o=l}else a==="\x1B"?(i(),o+=e[o+1]!==void 0?2:1):(r+=a,o++)}return i(),n}const yu="<synthetic>",ju="Continue from where you left off.",bu="No response requested.";function Oa(e){const t=e.message&&typeof e.message=="object"?e.message:void 0,n=(t==null?void 0:t.content)??e.content;return typeof n=="string"?n.trim():Array.isArray(n)&&n.filter(o=>!!o&&typeof o=="object"&&o.type==="text"&&typeof o.text=="string").map(o=>o.text).join("").trim()||void 0}function vu(e){var n;if(!e||typeof e!="object")return!1;const t=(n=e.message)==null?void 0:n.role;return e.type!=="user"&&t!=="user"||e.isMeta!==!0?!1:Oa(e)===ju}function wu(e){if(!e||typeof e!="object")return!1;const t=e.message&&typeof e.message=="object"?e.message:void 0;return e.type!=="assistant"&&(t==null?void 0:t.role)!=="assistant"||(t==null?void 0:t.model)!==yu?!1:Oa(e)===bu}const _u="_notice_ztq97_1",Nu="_label_ztq97_16",ku="_objective_ztq97_21",Su="_flag_ztq97_27",Dn={notice:_u,label:Nu,objective:ku,flag:Su};function Cu({objective:e,status:t}){const{t:n}=Z();return s.jsxs("div",{className:Dn.notice,title:t,children:[s.jsx("strong",{className:Dn.label,children:n("goalNoticeLabel")}),s.jsx("span",{className:Dn.objective,children:s.jsx(St,{text:e})})]})}function G_({objective:e,status:t,onToggle:n,onEdit:r}){const{t:o}=Z(),[i,a]=m.useState(!1),l=t==="active"?"pause":t==="paused"||t==="blocked"||t==="usageLimited"?"resume":void 0,c={active:o("goalStatusActive"),paused:o("goalStatusPaused"),blocked:o("goalStatusBlocked"),usageLimited:o("goalStatusUsageLimited"),budgetLimited:o("goalStatusBudgetLimited"),complete:o("goalStatusComplete")},d=t?c[t]??t:void 0,u=yn([d&&o("goalFlagStatus",{status:d}),e,i?o("goalFlagUpdating"):n&&l?o(l==="pause"?"goalFlagPauseHint":"goalFlagResumeHint"):void 0].filter(Boolean).join(`
4
4
 
5
5
  `));return s.jsx("button",{type:"button",className:Dn.flag,...u,"aria-label":o("goalFlagLabel",{objective:e}),"data-goal-status":t??void 0,"aria-busy":i,"aria-disabled":i,onClick:async()=>{if(!(i||!l||!n)){a(!0);try{await n(l)}finally{a(!1)}}},onMouseDown:f=>{f.button===2&&f.preventDefault()},onContextMenu:r,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75","aria-hidden":"true",children:s.jsx("path",{d:"M5 21V4m0 0c5-5 9 5 14 0v10c-5 5-9-5-14 0"})})})}const Tu={activeToolApproval:!0,markdown:!0,workflowTags:!0,workflowSchemaFiles:!0},Ru=Object.keys(Tu),Ro=new WeakMap,Pu=3;function Eu(e,t,n){const r=t==null?void 0:t.markdown,o=t==null?void 0:t.activeToolApproval,i=Ro.get(e),a=i==null?void 0:i.find(d=>d.compiler===n&&Ru.every(u=>d[u]===(t==null?void 0:t[u])));if(a)return a.items;const l=n(e,t),c=i??[];return c.push({workflowSchemaFiles:t==null?void 0:t.workflowSchemaFiles,workflowTags:t==null?void 0:t.workflowTags,activeToolApproval:o,compiler:n,items:l,markdown:r}),c.length>Pu&&c.shift(),Ro.set(e,c),l}function Po(e){return e.type==="system"&&e.subtype==="compact_boundary"}function Iu(e){return e.sourceMessages.some(t=>t.type==="system"&&t.subtype==="compact_boundary")}function Mu(e){const t=[],n=[];for(const r of e)typeof r=="string"&&r.startsWith("compactMetadata:")?t.push(r):n.push(r);return[...n,...t]}function $u(e){const t=e[0];if(!t)throw new Error("Cannot merge an empty compact boundary run");const n=e.find(Iu)??t,r=e.flatMap(i=>i.sourceMessages),o=Mu(e.flatMap(i=>i.details??[]));return{type:"system",id:n.id,subtype:"compact_boundary",content:n.content,status:n.status,configChanged:n.configChanged,isSubagent:n.isSubagent,sourceMessages:r,details:o.length>0?o:void 0}}function Lu(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!r||!Po(r)){r&&t.push(r),n+=1;continue}const o=[r];let i=n+1;for(;i<e.length;){const a=e[i];if(!a||!Po(a))break;o.push(a),i+=1}t.push($u(o)),n=i}return t}const Au="<task-notification>",Fu="</task-notification>";function Bu(e){var n;const t=((n=e.message)==null?void 0:n.content)??e.content;return typeof t=="string"?t:void 0}function Du(e){const t=e.trim();return t.startsWith(Au)&&t.endsWith(Fu)}function Ua(e){const t=e.origin;if((t==null?void 0:t.kind)==="task-notification")return!0;const n=Bu(e);return n!==void 0&&Du(n)}function At(e,t){var o;const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e),r=(o=n==null?void 0:n[1])==null?void 0:o.trim();return r||void 0}function Ou(e){return{taskId:At(e,"task-id"),toolUseId:At(e,"tool-use-id"),outputFile:At(e,"output-file"),status:At(e,"status"),summary:At(e,"summary"),event:At(e,"event")}}function Uu(e){const t=e.match(/(?:^|\n)\s*(?:Error:\s*)?(?:Process exited with code|Exit code:?)\s*(-?\d+)\b/i);if(t!=null&&t[1])return Number.parseInt(t[1],10)}function Hu(e){const t=e.match(/(?:^|\n)\s*Wall time:?\s+([^\n]+)\s*(?:\n|$)/i);if(t!=null&&t[1])return t[1].trim()}const Wu=/(?:^|\n)\s*Script\s+running\s+with\s+cell\s+ID\s+(\w+)\b/i;function Xn(e){var t;return(t=Wu.exec(e))==null?void 0:t[1]}function Me(e,t={}){const n=e.match(/(?:^|\n)\s*Output:\s*\n([\s\S]*)$/i),r=t.bareExitCodeIsEnvelope?e.match(/^\s*(?:Error:\s*)?(?:Process exited with code|Exit code:?)\s*(-?\d+)\b[^\n]*(?:\n|$)/i):null,o=!!n||!!r,i=((n==null?void 0:n[1])??(r?e.slice(r[0].length):e)).trimEnd(),a=n?Uu(e):r!=null&&r[1]?Number.parseInt(r[1],10):void 0;return{output:i,exitCode:a,wallTime:Hu(e),hasEnvelope:o}}function Eo(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Ct(e){if(!e||typeof e!="object")return{};const t=e,n=Eo(t.exitCode??t.exit_code),r=Eo(t.durationSeconds??t.wall_time_seconds);return{...n!==void 0?{exitCode:n}:{},...r!==void 0?{durationSeconds:r}:{}}}function et(e){if(!Number.isFinite(e)||e<0)return"";if(e<60)return`${Math.round(e*10)/10}s`;if(e<3600){const r=Math.floor(e/60),o=Math.round(e-r*60);return o>=60?`${r+1}m`:o>0?`${r}m${o}s`:`${r}m`}const t=Math.floor(e/3600),n=Math.round((e-t*60*60)/60);return n>=60?`${t+1}h`:n>0?`${t}h${n}m`:`${t}h`}function Vu(e){const t=[];if(typeof e.content=="string")t.push(e.content);else if(Array.isArray(e.content))for(const l of e.content)l.type==="text"&&l.text&&t.push(l.text);const n=t.join(`
6
6
  `);if(!n)return;const r=Gu(e),o=n.match(/^agentId:\s*(\S+)/m);if(!o)return;const i={agentId:o[1],status:"completed"};r&&r.length>0&&(i.content=r);const a=n.match(/<usage>([\s\S]*?)<\/usage>/);if(a!=null&&a[1]){const l=a[1],c=l.match(/total_tokens:\s*(\d+)/),d=l.match(/tool_uses:\s*(\d+)/),u=l.match(/duration_ms:\s*(\d+)/);c!=null&&c[1]&&(i.totalTokens=Number(c[1])),d!=null&&d[1]&&(i.totalToolUseCount=Number(d[1])),u!=null&&u[1]&&(i.totalDurationMs=Number(u[1]))}return i}function Io(e){return e.replace(/^agentId:\s*\S+.*$/gm,"").replace(/<usage>[\s\S]*?<\/usage>/g,"").trim()}function Gu(e){if(typeof e.content=="string"){const n=Io(e.content);return n?[{type:"text",text:n}]:void 0}if(!Array.isArray(e.content))return;const t=[];for(const n of e.content)if(!(!n||typeof n!="object")){if(n.type==="text"&&typeof n.text=="string"){const r=Io(n.text);if(!r)continue;t.push({...n,text:r});continue}t.push(n)}return t.length>0?t:void 0}function ys(e){return typeof e=="string"?e:e.map(t=>t.type==="text"&&typeof t.text=="string"?t.text:"").filter(Boolean).join(`
7
- `)}function zu(e){return e.type==="system"&&e.subtype==="local_command"}function qu(e){return e.type!=="user_prompt"||!e.sourceMessages.some(t=>t.isMeta===!0)?!1:ys(e.content).trimStart().startsWith("Base directory for this skill:")}function Mo(e){const t=e.promptId;return typeof t=="string"&&t?t:null}function Ku(e,t){const n=new Set(e.sourceMessages.map(Kn).filter(Boolean)),r=t.sourceMessages.map(a=>typeof a.parentUuid=="string"?a.parentUuid:null).filter(a=>a!==null);if(r.length>0&&n.size>0)return r.some(a=>n.has(a));const o=new Set(e.sourceMessages.map(Mo).filter(a=>a!==null)),i=t.sourceMessages.map(Mo).filter(a=>a!==null);return i.length>0&&o.size>0?i.some(a=>o.has(a)):!0}function Xu(e,t){return{...e,sourceMessages:[...e.sourceMessages,...t.sourceMessages],details:[...e.details??[],t.content]}}function Yu(e){const t=[];let n=0;for(;n<e.length;){const r=e[n],o=e[n+1];if(r&&o&&zu(r)&&qu(o)&&Ku(r,o)){t.push(Xu(r,o)),n+=2;continue}r&&t.push(r),n+=1}return t}const Ju=/\s*\(disable recaps in \/config\)\s*$/u;function Qu(e){return e.replace(Ju,"")}function Zu(e,t,n){const r=[],o=new Map,i=new Map,a={lastSignature:null},l=em(e,(t==null?void 0:t.activeToolApproval)===!0);for(const c of e)um(c,r,o,i,l,a,t,n);return r}function em(e,t){const n=new Set,r=t?tm(e):e.length;for(let o=0;o<e.length;o++){const i=e[o];if(i!=null&&i.orphanedToolUseIds&&!(t&&o>=r))for(const a of i.orphanedToolUseIds)n.add(a)}return n}function tm(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&cm(n))return t}return 0}const nm="Reasoning [internal]";function js(e){var t;return((t=e.message)==null?void 0:t.content)??e.content}const sm="This session is being continued from a previous conversation that ran out of context";function Ha(e){var o;const t=js(e);if(t===void 0)return!1;const n=typeof t=="string"?t:ys(t);if(!Xd(n))return!1;const r=((o=e.message)==null?void 0:o.role)??e.role;return e.type==="user"||r==="user"}function er(e){var i;if(e.isCompactSummary===!0)return!0;const t=js(e);if(t===void 0||!(typeof t=="string"?t:ys(t)).trimStart().startsWith(sm))return!1;const o=((i=e.message)==null?void 0:i.role)??e.role;return e.type==="user"||o==="user"}function Wa(e){const t=e.trim().replace(/^\/+/,"").toLowerCase();return t==="compact"||t==="compress"}function rm(e){if(typeof e!="string"||wr(e))return null;const t=_r(e);if(t)return Wa(t.command)?null:ja(t);const n=Nr(e);if(n!==null)return n?ba(n)?null:n:null;const r=e.trim();return r||null}function om(e){const t=e.details;if(!Array.isArray(t))return;const n=t.filter(r=>typeof r=="string"&&!!r.trim());return n.length>0?n:void 0}function im(e){const t=e.compactMetadata;return ym(t)?`compactMetadata:
8
- ${JSON.stringify(t,null,2)}`:null}function am(e){const t=[],n=e.compactSummaryText;typeof n=="string"&&n.trim()&&t.push(n.trim());const r=im(e);return r&&t.push(r),t}function $o(e){return e===void 0?[]:[e]}function lm(e){const t=js(e);return e.isMeta===!0&&t!==void 0&&ys(t).trimStart().startsWith("Base directory for this skill:")}function cm(e){var o;const t=js(e),n=((o=e.message)==null?void 0:o.role)??e.role;return!(e.type==="user"||n==="user")||Ua(e)||er(e)||Ha(e)||lm(e)?!1:Array.isArray(t)?!t.every(i=>i.type==="tool_result"):typeof t!="string"||e.isMeta===!0&&wr(t)||Nr(t)!==null?!1:!_r(t)}function dm(e){const t=e==null?void 0:e.trim();return!!t&&t!==nm}function Lo(e){var t;for(let n=e.length-1;n>=0;n--){const r=e[n];if((r==null?void 0:r.type)==="text"&&((t=r.text)!=null&&t.trim()))return n}return-1}function um(e,t,n,r,o,i,a,l){var y,x,b,_,N,v,j,C;const c=Kn(e);if(vu(e)||Ha(e))return;if(wu(e)){t.push({type:"system",id:c,subtype:"no_model_turn",content:"Session continued without running a turn",sourceMessages:[e],isSubagent:e.isSubagent});return}if(e.type==="error"){const w=typeof e.error=="string"&&e.error||typeof e.content=="string"&&e.content||"Agent error",k={type:"system",id:c||`error-${e.timestamp??Date.now()}`,subtype:e.codexWillRetry===!0?"warning":"error",content:w,sourceMessages:[e]};t.push(k);return}if(e.type==="system"){const w=e.subtype??"unknown";if(w==="informational"){typeof e.content=="string"&&e.content.trim()&&t.push({type:"system",id:c,subtype:e.level==="warning"?"warning":"informational",content:e.content,sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="local_command"){const k=rm(e.content);k!==null&&t.push({type:"system",id:c,subtype:w,content:k,details:om(e),sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="rewound_group"){t.push({type:"system",id:c,subtype:w,content:typeof e.content=="string"?e.content:"",sourceMessages:[e]});return}if(w==="tool_output"){const k=typeof e.codexToolName=="string"?e.codexToolName:"",$=[typeof e.codexToolNamespace=="string"?e.codexToolNamespace:"",k].filter(Boolean).join("."),T=typeof e.content=="string"?e.content:"";t.push({type:"system",id:c,subtype:w,content:$,details:T?[T]:[],sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="compact_boundary"||w==="turn_aborted"||w==="config_ack"||w==="away_summary"||w==="subagent_activity"){const k=w==="config_ack"?mm(e):null,S=typeof e.content=="string"?e.content:w==="turn_aborted"?"Turn aborted":w==="config_ack"?"Configuration updated":w==="away_summary"?"Recap unavailable":w==="subagent_activity"?"Subagent updated":"Context compacted",$={type:"system",id:c,subtype:w,content:w==="away_summary"?Qu(S):S,sourceMessages:[e],...w==="compact_boundary"?{details:am(e)}:{},...w==="config_ack"?{configChanged:e.configMismatch===!0&&k!==null&&k!==i.lastSignature}:{}};t.push($),w==="config_ack"&&k!==null&&(i.lastSignature=k)}return}e.type==="assistant"&&((y=l==null?void 0:l.onAssistantMessage)==null||y.call(l,{msgId:c,uuid:e.uuid,id:e.id,_isStreaming:e._isStreaming}));const d=((x=e.message)==null?void 0:x.content)??e.content,u=((b=e.message)==null?void 0:b.role)??e.role,f=e.type==="user"||u==="user";if(typeof d=="string"){if(f){if(er(e)){t.push({type:"system",id:c,subtype:"compact_boundary",content:"Context compacted",details:$o(d),sourceMessages:[e],isSubagent:e.isSubagent});return}if(e.isMeta===!0&&wr(d))return;const w=_r(d);if(w){if(Wa(w.command))return;t.push({type:"system",id:c,subtype:"local_command",content:ja(w),sourceMessages:[e],isSubagent:e.isSubagent});return}const k=Nr(d);if(k!==null){if(!k||ba(k))return;t.push({type:"system",id:c,subtype:"local_command",content:k,sourceMessages:[e],isSubagent:e.isSubagent});return}if(Ua(e)){const S=Ou(d);t.push({type:"task_notification",id:c,raw:d,sourceMessages:[e],isSubagent:e.isSubagent,...S});return}t.push({type:"user_prompt",id:c,content:d,projectPathLinks:xs(e._projectPathLinks),sourceMessages:[e],isSubagent:e.isSubagent});return}if(d.trim()){const w=e._html;t.push({type:"text",id:c,text:d,sourceBlockIndex:0,sourceMessages:[e],isSubagent:e.isSubagent,augmentHtml:w??((N=(_=a==null?void 0:a.markdown)==null?void 0:_[c])==null?void 0:N.html)})}return}if(!Array.isArray(d))return;if(f&&d.every(w=>w.type==="tool_result")){for(const w of d)w.type==="tool_result"&&w.tool_use_id&&hm(w,e,t,r,l);return}if(f){if(er(e)){t.push({type:"system",id:c,subtype:"compact_boundary",content:"Context compacted",details:$o(d),sourceMessages:[e],isSubagent:e.isSubagent});return}t.push({type:"user_prompt",id:c,content:d,sourceMessages:[e],isSubagent:e.isSubagent});return}const g=e._isStreaming?Lo(d):-1,p=e.isAbortedMidStream===!0&&!e._isStreaming?Lo(d):-1;for(let w=0;w<d.length;w++){const k=d[w];if(!k)continue;const S=`${c}-${w}`;if(k.type==="text"){if((v=k.text)!=null&&v.trim()){const $=k._html;t.push({type:"text",id:S,text:k.text,sourceBlockIndex:w,sourceMessages:[e],isSubagent:e.isSubagent,isStreaming:e._isStreaming&&w===g,augmentHtml:$??((C=(j=a==null?void 0:a.markdown)==null?void 0:j[c])==null?void 0:C.html),...w===p?{abortedMidStream:!0}:{}})}}else if(k.type==="thinking"){const $=k.thinking;dm($)&&t.push({type:"thinking",id:S,thinking:$,sourceBlockIndex:w,signature:void 0,status:e._isStreaming?"streaming":"complete",sourceMessages:[e],isSubagent:e.isSubagent})}else if(k.type==="tool_use"&&k.id&&k.name){const $=n.get(k.id);if($!==void 0){const D=t[$];(D==null?void 0:D.type)==="tool_call"&&(t[$]=fm(D,e,k.input,k._displayActions),D.status==="pending"&&r.set(k.id,$));continue}const T=o.has(k.id),E={type:"tool_call",id:k.id,toolName:k.name,toolInput:k.input,...k._displayActions?{displayActions:k._displayActions}:{},toolResult:void 0,status:T?"incomplete":"pending",sourceMessages:[e],isSubagent:e.isSubagent},R=t.length;n.set(k.id,R),r.set(k.id,R),t.push(E)}}}function mm(e){const t=typeof e.configModel=="string"?e.configModel.trim():"",n=typeof e.configThinking=="string"?e.configThinking.trim():"";return t||n?`${t}::${n}`:typeof e.content=="string"?e.content.trim():null}function Va(e,t){const n=Kn(t);return e.sourceMessages.some(r=>Kn(r)===n)?e:{...e,sourceMessages:[...e.sourceMessages,t]}}function fm(e,t,n,r){return{...Va(e,t),toolInput:n,displayActions:r}}function hm(e,t,n,r,o){var y;const i=e.tool_use_id;if(!i)return;const a=r.get(i);if(a===void 0){o!=null&&o.onUnmatchedToolResult?o.onUnmatchedToolResult({toolUseId:i,message:t}):console.warn(`Tool result for unknown tool_use: ${i}`);return}const l=n[a];if((l==null?void 0:l.type)!=="tool_call")return;let c=t.toolUseResult??t.tool_use_result;!c&&(l.toolName==="Agent"||l.toolName==="Task")&&(c=Vu(e)),c=pm(l,e,c);const d=xs(e._projectPathLinks),u={content:typeof e.content=="string"?e.content:"",isError:e.is_error||!1,structured:c,...d?{projectPathLinks:d}:{},...(y=t.toolResultMedia)!=null&&y.some(x=>x.toolCallId===e.tool_use_id)?{media:t.toolResultMedia.filter(x=>x.toolCallId===e.tool_use_id)}:{}},f=gm(e,l.toolName),h=xm(e,u,l.toolName);let g="complete";h||l.status==="aborted"?g="aborted":f?g=l.status==="incomplete"?"incomplete":"pending":e.is_error&&(g="error");const p={type:"tool_call",id:l.id,toolName:l.toolName,toolInput:l.toolInput,...l.displayActions?{displayActions:l.displayActions}:{},toolResult:u,status:g,sourceMessages:Va(l,t).sourceMessages,isSubagent:l.isSubagent};n[a]=p,!f&&!h&&r.delete(i)}function pm(e,t,n){if(e.toolName!=="Bash"||t.is_error!==!0)return n;const r=typeof n=="string"?n:typeof t.content=="string"?t.content:"",o=Me(r,{bareExitCodeIsEnvelope:!0});return!o.hasEnvelope||o.exitCode===void 0?n:{stdout:o.output,stderr:"",interrupted:!1,isImage:!1,exitCode:o.exitCode}}function gm(e,t){if(t!=="Bash")return!1;const n=typeof e.content=="string"?e.content:"";return n?/(?:^|\n)\s*(?:Process\s+running\s+with\s+session\s+ID|session(?:\s+id)?)\s*:?\s*\d+\b/i.test(n)&&!/(?:^|\n)\s*(?:Exit code:|Process exited with code)\s*-?\d+\b/i.test(n):!1}function xm(e,t,n){if(n!=="Bash")return!1;if(t.structured&&typeof t.structured=="object"&&t.structured.interrupted===!0)return!0;const r=typeof e.content=="string"?e.content:"";return/(?:^|\n)\s*(?:aborted by user|interrupted by user)(?:\s|$)/i.test(r)}function ym(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const jm=[/^<recommended_plugins>[\s\S]*?<\/recommended_plugins>/iu,/^# AGENTS\.md instructions[^\r\n]*(?:\r?\n)+\s*<INSTRUCTIONS>[\s\S]*?<\/INSTRUCTIONS>/iu,/^<environment_context>[\s\S]*?<\/environment_context>/iu];function bm(e){return e.some(t=>typeof t.codexUserTurnProvenance=="string")}function vm(e){return e.some(t=>t._source==="sdk")}function wm(e){let t=e.trim(),n=!1;for(;t;){const r=jm.map(o=>o.exec(t)).find(o=>(o==null?void 0:o.index)===0);if(!(r!=null&&r[0]))return!1;n=!0,t=t.slice(r[0].length).trimStart()}return n}function Ga(e,t=[]){return bm(t)||vm(t)?!1:wm(e)}function _m(e,t=[]){return Ga(e,t)?e.trimStart().startsWith("<environment_context>"):!1}const Nm=5e3;function za(e){return typeof e=="string"?e:e.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
9
- `)}function tr(e){const t=za(e.content).trimStart();return Ga(t,e.sourceMessages)}function km(e){return _m(za(e.content),e.sourceMessages)}function Ao(e){const t=e.sourceMessages.map(n=>typeof n.timestamp=="string"?Date.parse(n.timestamp):NaN).find(Number.isFinite);return t===void 0?null:t}function Sm(e,t){if(!km(e)||(t==null?void 0:t.type)!=="user_prompt"||tr(t))return!1;const n=Ao(e),r=Ao(t);if(n===null||r===null)return!1;const o=r-n;return o>=0&&o<=Nm}function Cm(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if((r==null?void 0:r.type)!=="user_prompt"||!tr(r)){t.push(r),n+=1;continue}const o=[];let i=n;for(;i<e.length;){const c=e[i];if((c==null?void 0:c.type)!=="user_prompt"||!tr(c))break;o.push(c),i+=1}const a=o.length===1?o[0]:void 0;if(a!==void 0&&Sm(a,e[i])){n=i;continue}if(o.length>1||n===0){const c=o[0];if(!c){n=i;continue}const d={type:"session_setup",id:`session-setup-${c.id}`,title:"Session setup",prompts:o.map(u=>u.content),sourceMessages:o.flatMap(u=>u.sourceMessages)};t.push(d)}else{const c=o[0];c&&t.push(c)}n=i}return t}function nt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Tm(e){if(nt(e)){if(typeof e.command=="string"&&e.command.trim().length>0)return e.command;if(typeof e.cmd=="string"&&e.cmd.trim().length>0)return e.cmd}}function wt(e){if(typeof e=="number"&&Number.isFinite(e))return String(Math.trunc(e));if(typeof e=="string"&&e.trim().length>0)return e.trim()}function qa(e){if(nt(e))return wt(e.session_id??e.sessionId)}function Fo(e){var i,a;const t=(i=e.toolResult)==null?void 0:i.structured;if(nt(t)){const l=wt(t.session_id??t.sessionId);if(l)return l}const n=((a=e.toolResult)==null?void 0:a.content)??"",o=(typeof n=="string"?n:"").match(/(?:^|\n)\s*(?:Process\s+running\s+with\s+session\s+ID|session[_\s]?id|session)\s*[:=]?\s*(\d+)\b/i);if(o!=null&&o[1])return o[1]}function $r(e){if(nt(e))return wt(e.cell_id??e.cellId)}function Yn(e){var n;const t=((n=e.toolResult)==null?void 0:n.content)??"";return Xn(typeof t=="string"?t:"")}function Rm(e,t){return!nt(e)||typeof e.linked_command=="string"&&e.linked_command.trim()?e:{...e,linked_command:t}}function Pm(e,t){return!nt(e)||typeof e.linked_file_path=="string"&&e.linked_file_path.trim()?e:{...e,linked_file_path:t}}function Em(e,t){return!nt(e)||typeof e.linked_tool_name=="string"&&e.linked_tool_name.trim()?e:{...e,linked_tool_name:t}}function nr(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function Bo(e){const t=e.toLowerCase();return t==="read"||t==="write"||t==="edit"}function Im(e){if(!nt(e)||typeof e.file_path!="string")return;const t=e.file_path.trim();return t.length>0?t:void 0}const Mm=/(?:Command|Process)\s+running\s+(?:in\s+background\s+with\s+ID|with\s+session\s+ID)\s*:?\s*([\w-]+)/i,$m=/(?:^|\n)\s*Process exited with code \d+/i,Lm=/^(completed|failed|killed|stopped|success|error|done)/i;function $e(e,t){return nt(e)?e[t]:void 0}function Am(e){return e==="taskoutput"||e==="task_output"||e==="get_command_or_subagent_output"}function Fm(e){return e==="killshell"||e==="kill_shell"||e==="kill_command_or_subagent"}function Bm(e){return e==="completed"||e==="failed"||e==="cancelled"}function Do(e){var n;const t=(n=e.toolResult)==null?void 0:n.content;return typeof t=="string"?t:""}function Dm(e){var r;const t=new Set,n=(...o)=>{for(const i of o)i&&t.add(i)};for(const o of e){if(o.type==="task_notification"){o.status&&Lm.test(o.status)&&n(o.taskId,o.toolUseId&&`tool:${o.toolUseId}`);continue}if(o.type!=="tool_call")continue;const i=o.toolName.toLowerCase(),a=o.toolInput,l=(r=o.toolResult)==null?void 0:r.structured;if(i==="bashoutput"||i==="bash_output"){const c=wt($e(l,"shellId")??$e(a,"bash_id")),d=$e(l,"status"),u=typeof $e(l,"exitCode")=="number";c&&(u||d==="completed"||d==="failed")&&n(c)}else if(Am(i)){const c=$e(l,"tasks"),d=Array.isArray(c)?c:[$e(l,"task")];for(const u of d)Bm($e(u,"status"))&&n(wt($e(u,"task_id")??$e(a,"task_id")))}else if(Fm(i))n(wt($e(l,"shell_id")??$e(l,"task_id")??$e(a,"shell_id")??$e(a,"task_id")));else if((i==="writestdin"||i==="write_stdin"||i==="wait")&&(typeof $e(l,"exit_code")=="number"||$m.test(Do(o)))){const d=qa(a),u=$r(a);n(d&&`session:${d}`,u&&`cell:${u}`)}}return e.map(o=>{var g;if(o.type!=="tool_call"||o.status!=="complete"||!nr(o.toolName))return o;const i=Do(o),a=[`tool:${o.id}`];let l=$e(o.toolInput,"run_in_background")===!0;const c=wt($e((g=o.toolResult)==null?void 0:g.structured,"backgroundTaskId"));c&&(l=!0,a.push(c,`session:${c}`));const d=i.match(Mm);d!=null&&d[1]&&(l=!0,a.push(d[1]),/session\s+ID/i.test(d[0])&&a.push(`session:${d[1]}`));const u=Xn(i);if(u&&(l=!0,a.push(`cell:${u}`)),!l)return o;const f=a.some(p=>t.has(p)),h=nt(o.toolInput)?o.toolInput:{};return{...o,toolInput:{...h,_backgroundTaskStatus:f?"completed":"running"}}})}function Om(e){const t=new Map,n=new Map;return e.map(r=>{if(r.type!=="tool_call")return r;if(nr(r.toolName)||Bo(r.toolName)){const f=Fo(r),h=Yn(r);if(!f&&!h)return r;const g=nr(r.toolName)?Tm(r.toolInput):void 0,p=Bo(r.toolName)?Im(r.toolInput):void 0;for(const[y,x]of[[f,t],[h,n]]){if(!y)continue;const b=x.get(y)??{};x.set(y,{command:g??b.command,filePath:p??b.filePath,toolName:r.toolName??b.toolName})}return r}const o=r.toolName.toLowerCase();if(o!=="writestdin"&&o!=="write_stdin"&&o!=="wait")return r;const i=qa(r.toolInput),a=$r(r.toolInput),l=(i?t.get(i):void 0)??(a?n.get(a):void 0),c=Yn(r);if(c&&l){const f=n.get(c)??{};n.set(c,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}const d=Fo(r);if(d&&l){const f=t.get(d)??{};t.set(d,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}if(!l)return r;let u=r.toolInput;return l.command&&(u=Rm(u,l.command)),l.filePath&&(u=Pm(u,l.filePath)),l.toolName&&(u=Em(u,l.toolName)),u===r.toolInput?r:{...r,toolInput:u}})}function Oo(e){const t=e.toLowerCase();return t==="writestdin"||t==="write_stdin"||t==="wait"}function Um(e){const t=new Map;for(let i=0;i<e.length;i++){const a=e[i];if((a==null?void 0:a.type)!=="tool_call"||!Oo(a.toolName))continue;const l=$r(a.toolInput);if(!l)continue;const c=t.get(l);c?c.push(i):t.set(l,[i])}if(t.size===0)return e;const n=new Set,r=(i,a)=>{const l=t.get(i);if(!l)return-1;for(const c of l)if(c>a&&!n.has(c))return c;return-1},o=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let a=e[i];if(a!==void 0){if(a.type==="tool_call"&&Oo(a.toolName)){let l=Yn(a),c=i;for(;l;){const d=r(l,c);if(d<0)break;const u=e[d];if((u==null?void 0:u.type)!=="tool_call")break;n.add(d),c=d,a={...a,status:u.status,toolResult:u.toolResult},l=u.toolResult!==void 0?Yn(u):void 0}}o.push(a)}}return o}function Hm(e){return e.filter(t=>{var d,u,f;if(t.type!=="tool_call"||t.status!=="complete")return!0;const n=t.toolName.toLowerCase();if(n!=="writestdin"&&n!=="write_stdin"&&n!=="wait"||(d=t.toolResult)!=null&&d.isError)return!0;const r=nt(t.toolInput)?t.toolInput:{};if((typeof r.chars=="string"?r.chars:"").length>0||[r.linked_command,r.linked_file_path,r.linked_tool_name].some(h=>typeof h=="string"&&h.trim().length>0))return!0;const a=((u=t.toolResult)==null?void 0:u.content)??"",l=Me(a),c=Ct((f=t.toolResult)==null?void 0:f.structured).exitCode??l.exitCode;return l.output.trim().length>0||c!==void 0})}const Uo="@@visualization-schema/1 ",Ka={containsTags:!1,closed:!1},Wm={containsTags:!0,view:"spans"},Xa={collect:!1,order:0};function sr(e){return typeof e=="string"&&e.length>0&&!/[[\]\r\n]/.test(e)}function Ya(e){var t;return(t=/^(?:\[[^[\]\r\n]+\])+/.exec(e))==null?void 0:t[0]}function rr(e){try{return JSON.parse(e)}catch{return}}function Ho(e,t){if(e===void 0)return t;if(!(!st(e)||e.containsTags!==void 0&&typeof e.containsTags!="boolean"||e.closed!==void 0&&typeof e.closed!="boolean")&&!(e.view!==void 0&&e.view!=="spans"&&e.view!=="matching-lines")&&!(e.whitelist!==void 0&&(!Array.isArray(e.whitelist)||!e.whitelist.every(n=>typeof n=="string"&&Ya(n)===n))))return{containsTags:e.containsTags??!1,closed:e.closed??!1,view:e.view,whitelist:e.whitelist}}function Wo(e){if(e===void 0)return Xa;if(!(!st(e)||e.collect!==void 0&&typeof e.collect!="boolean"||e.order!==void 0&&(typeof e.order!="number"||!Number.isFinite(e.order))))return{collect:e.collect??!1,order:e.order??0}}function Vo(e){if(!st(e)||e.type!=="tagged-stages/1"||typeof e.id!="string"||!e.id||/\s/.test(e.id)||!sr(e.key)||e.key==="workflow"||typeof e.title!="string"||!Array.isArray(e.stages))return;const t=Ho(e.toolOutput,Ka),n=Wo(e.presentation);if(!t||!n)return;const r=new Map,o=`[${e.key}]`;r.set(o,{title:e.title,policy:t,presentation:n});function i(a,l,c,d){if(d>32||r.size+a.length>512)return!1;for(const u of a){if(!st(u)||!sr(u.key)||u.title!==void 0&&typeof u.title!="string"||u.children!==void 0&&!Array.isArray(u.children))return!1;const f=`${l}[${u.key}]`,h=Ho(u.toolOutput,c.policy),g=Wo(u.presentation);if(r.has(f)||r.size>=512||!h||!g)return!1;const p={title:`${c.title} › ${u.title??u.key}`,policy:h,presentation:g};if(r.set(f,p),Array.isArray(u.children)&&!i(u.children,f,p,d+1))return!1}return!0}if(i(e.stages,o,r.get(o),1))return{id:e.id,title:e.title,root:o,stages:r}}function Vm(e){const t=rr(e);if(!Array.isArray(t))return;const n=[];for(const r of t){const o=typeof r=="string"?[r]:r;if(!Array.isArray(o)||!o.length||!o.every(sr))return;n.push(o.map(i=>`[${i}]`).join(""))}return{id:"",title:"",root:"",stages:new Map,inline:new Set(n)}}function Lr(e){if(!/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/.test(e))return;const t=e.indexOf("#");return{path:t<0?e:e.slice(0,t),id:t<0?void 0:e.slice(t+1)}}function Go(e,t){const n=Lr(t);if(!n)return;const{id:r}=n,o=rr(e);if(st(o)){const a=Vo(o);return a&&(r===void 0||a.id===r)?a:void 0}const i=[];for(const a of e.matchAll(/^```json\s*\r?\n([\s\S]*?)^```\s*$/gm)){const l=rr(a[1]??"");if(!st(l)||(r===void 0?!l.type:l.id!==r))continue;const c=Vo(l);if(!c)return;i.push(c)}return i.length===1?i[0]:void 0}function Ot(e){return e.schema.stages.get(e.path)??{title:e.path.replace(/\]\[/g," › ").replace(/^\[|\]$/g,""),policy:e.schema.inline?Wm:Ka,presentation:Xa}}function zo(e,t){var o;let n="",r="";for(const i of t.slice(1,-1).split("]["))n+=`[${i}]`,r=((o=e.stages.get(n))==null?void 0:o.title)??`${r?`${r} › `:""}${i}`;return r}function Gm(e,t){var r;if(t.schema.inline)return t.schema.inline.has(e);const n=Ot(t).policy;return n.containsTags&&(!n.closed||t.schema.stages.has(`${t.path}${e}`)||((r=n.whitelist)==null?void 0:r.includes(e))===!0)}function zm(e){var r,o,i,a,l,c;const t=(r=e.toolResult)==null?void 0:r.structured;if(e.toolName==="Exec"){const d=ht(t??((o=e.toolResult)==null?void 0:o.content));if(d){const u=d.parts.filter(f=>f.kind!=="script-status").map(f=>f.text);return u.length?u:[""]}}if(e.toolName==="Read"&&st(t)&&t.type==="text"&&st(t.file)&&typeof t.file.content=="string")return[t.file.content];const n=["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase());if(st(t)&&(typeof t.stdout=="string"||typeof t.stderr=="string"))return[typeof t.stdout=="string"?t.stdout:n?"":((i=e.toolResult)==null?void 0:i.content)??"",typeof t.stderr=="string"?t.stderr:""];if(n){const d=((a=e.toolResult)==null?void 0:a.content)??"",u=Me(d,{bareExitCodeIsEnvelope:(l=e.toolResult)==null?void 0:l.isError});return[u.hasEnvelope?u.output:d]}return[((c=e.toolResult)==null?void 0:c.content)??""]}function or(e,t,n,r,o,i,a,l){var _,N;const c={markers:[]};let d=t;const u=t==null?void 0:t.path;t&&u&&(c.parent={path:u,title:Ot(t).title}),n&&t&&Ot(t).policy.containsTags&&(c.view=Ot(t).policy.view??"spans");const f=[];function h(v,j){const C=f.at(-1);C&&C.end>=v?C.end=j:f.push({start:v,end:j})}let g,p="data";const y=new Map;let x=0,b=0;for(const v of e.split(`
7
+ `)}function zu(e){return e.type==="system"&&e.subtype==="local_command"}function qu(e){return e.type!=="user_prompt"||!e.sourceMessages.some(t=>t.isMeta===!0)?!1:ys(e.content).trimStart().startsWith("Base directory for this skill:")}function Mo(e){const t=e.promptId;return typeof t=="string"&&t?t:null}function Ku(e,t){const n=new Set(e.sourceMessages.map(Kn).filter(Boolean)),r=t.sourceMessages.map(a=>typeof a.parentUuid=="string"?a.parentUuid:null).filter(a=>a!==null);if(r.length>0&&n.size>0)return r.some(a=>n.has(a));const o=new Set(e.sourceMessages.map(Mo).filter(a=>a!==null)),i=t.sourceMessages.map(Mo).filter(a=>a!==null);return i.length>0&&o.size>0?i.some(a=>o.has(a)):!0}function Xu(e,t){return{...e,sourceMessages:[...e.sourceMessages,...t.sourceMessages],details:[...e.details??[],t.content]}}function Yu(e){const t=[];let n=0;for(;n<e.length;){const r=e[n],o=e[n+1];if(r&&o&&zu(r)&&qu(o)&&Ku(r,o)){t.push(Xu(r,o)),n+=2;continue}r&&t.push(r),n+=1}return t}const Ju=/\s*\(disable recaps in \/config\)\s*$/u;function Qu(e){return e.replace(Ju,"")}function Zu(e,t,n){const r=[],o=new Map,i=new Map,a={lastSignature:null},l=em(e,(t==null?void 0:t.activeToolApproval)===!0);for(const c of e)um(c,r,o,i,l,a,t,n);return r}function em(e,t){const n=new Set,r=t?tm(e):e.length;for(let o=0;o<e.length;o++){const i=e[o];if(i!=null&&i.orphanedToolUseIds&&!(t&&o>=r))for(const a of i.orphanedToolUseIds)n.add(a)}return n}function tm(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&cm(n))return t}return 0}const nm="Reasoning [internal]";function js(e){var t;return((t=e.message)==null?void 0:t.content)??e.content}const sm="This session is being continued from a previous conversation that ran out of context";function Ha(e){var o;const t=js(e);if(t===void 0)return!1;const n=typeof t=="string"?t:ys(t);if(!_d(n))return!1;const r=((o=e.message)==null?void 0:o.role)??e.role;return e.type==="user"||r==="user"}function er(e){var i;if(e.isCompactSummary===!0)return!0;const t=js(e);if(t===void 0||!(typeof t=="string"?t:ys(t)).trimStart().startsWith(sm))return!1;const o=((i=e.message)==null?void 0:i.role)??e.role;return e.type==="user"||o==="user"}function Wa(e){const t=e.trim().replace(/^\/+/,"").toLowerCase();return t==="compact"||t==="compress"}function rm(e){if(typeof e!="string"||Tr(e))return null;const t=Rr(e);if(t)return Wa(t.command)?null:wa(t);const n=Pr(e);if(n!==null)return n?_a(n)?null:n:null;const r=e.trim();return r||null}function om(e){const t=e.details;if(!Array.isArray(t))return;const n=t.filter(r=>typeof r=="string"&&!!r.trim());return n.length>0?n:void 0}function im(e){const t=e.compactMetadata;return ym(t)?`compactMetadata:
8
+ ${JSON.stringify(t,null,2)}`:null}function am(e){const t=[],n=e.compactSummaryText;typeof n=="string"&&n.trim()&&t.push(n.trim());const r=im(e);return r&&t.push(r),t}function $o(e){return e===void 0?[]:[e]}function lm(e){const t=js(e);return e.isMeta===!0&&t!==void 0&&ys(t).trimStart().startsWith("Base directory for this skill:")}function cm(e){var o;const t=js(e),n=((o=e.message)==null?void 0:o.role)??e.role;return!(e.type==="user"||n==="user")||Ua(e)||er(e)||Ha(e)||lm(e)?!1:Array.isArray(t)?!t.every(i=>i.type==="tool_result"):typeof t!="string"||e.isMeta===!0&&Tr(t)||Pr(t)!==null?!1:!Rr(t)}function dm(e){const t=e==null?void 0:e.trim();return!!t&&t!==nm}function Lo(e){var t;for(let n=e.length-1;n>=0;n--){const r=e[n];if((r==null?void 0:r.type)==="text"&&((t=r.text)!=null&&t.trim()))return n}return-1}function um(e,t,n,r,o,i,a,l){var y,x,b,_,N,v,j,C;const c=Kn(e);if(vu(e)||Ha(e))return;if(wu(e)){t.push({type:"system",id:c,subtype:"no_model_turn",content:"Session continued without running a turn",sourceMessages:[e],isSubagent:e.isSubagent});return}if(e.type==="error"){const w=typeof e.error=="string"&&e.error||typeof e.content=="string"&&e.content||"Agent error",k={type:"system",id:c||`error-${e.timestamp??Date.now()}`,subtype:e.codexWillRetry===!0?"warning":"error",content:w,sourceMessages:[e]};t.push(k);return}if(e.type==="system"){const w=e.subtype??"unknown";if(w==="informational"){typeof e.content=="string"&&e.content.trim()&&t.push({type:"system",id:c,subtype:e.level==="warning"?"warning":"informational",content:e.content,sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="local_command"){const k=rm(e.content);k!==null&&t.push({type:"system",id:c,subtype:w,content:k,details:om(e),sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="rewound_group"){t.push({type:"system",id:c,subtype:w,content:typeof e.content=="string"?e.content:"",sourceMessages:[e]});return}if(w==="tool_output"){const k=typeof e.codexToolName=="string"?e.codexToolName:"",$=[typeof e.codexToolNamespace=="string"?e.codexToolNamespace:"",k].filter(Boolean).join("."),T=typeof e.content=="string"?e.content:"";t.push({type:"system",id:c,subtype:w,content:$,details:T?[T]:[],sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="compact_boundary"||w==="turn_aborted"||w==="config_ack"||w==="away_summary"||w==="subagent_activity"){const k=w==="config_ack"?mm(e):null,S=typeof e.content=="string"?e.content:w==="turn_aborted"?"Turn aborted":w==="config_ack"?"Configuration updated":w==="away_summary"?"Recap unavailable":w==="subagent_activity"?"Subagent updated":"Context compacted",$={type:"system",id:c,subtype:w,content:w==="away_summary"?Qu(S):S,sourceMessages:[e],...w==="compact_boundary"?{details:am(e)}:{},...w==="config_ack"?{configChanged:e.configMismatch===!0&&k!==null&&k!==i.lastSignature}:{}};t.push($),w==="config_ack"&&k!==null&&(i.lastSignature=k)}return}e.type==="assistant"&&((y=l==null?void 0:l.onAssistantMessage)==null||y.call(l,{msgId:c,uuid:e.uuid,id:e.id,_isStreaming:e._isStreaming}));const d=((x=e.message)==null?void 0:x.content)??e.content,u=((b=e.message)==null?void 0:b.role)??e.role,f=e.type==="user"||u==="user";if(typeof d=="string"){if(f){if(er(e)){t.push({type:"system",id:c,subtype:"compact_boundary",content:"Context compacted",details:$o(d),sourceMessages:[e],isSubagent:e.isSubagent});return}if(e.isMeta===!0&&Tr(d))return;const w=Rr(d);if(w){if(Wa(w.command))return;t.push({type:"system",id:c,subtype:"local_command",content:wa(w),sourceMessages:[e],isSubagent:e.isSubagent});return}const k=Pr(d);if(k!==null){if(!k||_a(k))return;t.push({type:"system",id:c,subtype:"local_command",content:k,sourceMessages:[e],isSubagent:e.isSubagent});return}if(Ua(e)){const S=Ou(d);t.push({type:"task_notification",id:c,raw:d,sourceMessages:[e],isSubagent:e.isSubagent,...S});return}t.push({type:"user_prompt",id:c,content:d,projectPathLinks:xs(e._projectPathLinks),sourceMessages:[e],isSubagent:e.isSubagent});return}if(d.trim()){const w=e._html;t.push({type:"text",id:c,text:d,sourceBlockIndex:0,sourceMessages:[e],isSubagent:e.isSubagent,augmentHtml:w??((N=(_=a==null?void 0:a.markdown)==null?void 0:_[c])==null?void 0:N.html)})}return}if(!Array.isArray(d))return;if(f&&d.every(w=>w.type==="tool_result")){for(const w of d)w.type==="tool_result"&&w.tool_use_id&&hm(w,e,t,r,l);return}if(f){if(er(e)){t.push({type:"system",id:c,subtype:"compact_boundary",content:"Context compacted",details:$o(d),sourceMessages:[e],isSubagent:e.isSubagent});return}t.push({type:"user_prompt",id:c,content:d,sourceMessages:[e],isSubagent:e.isSubagent});return}const g=e._isStreaming?Lo(d):-1,p=e.isAbortedMidStream===!0&&!e._isStreaming?Lo(d):-1;for(let w=0;w<d.length;w++){const k=d[w];if(!k)continue;const S=`${c}-${w}`;if(k.type==="text"){if((v=k.text)!=null&&v.trim()){const $=k._html;t.push({type:"text",id:S,text:k.text,sourceBlockIndex:w,sourceMessages:[e],isSubagent:e.isSubagent,isStreaming:e._isStreaming&&w===g,augmentHtml:$??((C=(j=a==null?void 0:a.markdown)==null?void 0:j[c])==null?void 0:C.html),...w===p?{abortedMidStream:!0}:{}})}}else if(k.type==="thinking"){const $=k.thinking;dm($)&&t.push({type:"thinking",id:S,thinking:$,sourceBlockIndex:w,signature:void 0,status:e._isStreaming?"streaming":"complete",sourceMessages:[e],isSubagent:e.isSubagent})}else if(k.type==="tool_use"&&k.id&&k.name){const $=n.get(k.id);if($!==void 0){const D=t[$];(D==null?void 0:D.type)==="tool_call"&&(t[$]=fm(D,e,k.input,k._displayActions),D.status==="pending"&&r.set(k.id,$));continue}const T=o.has(k.id),E={type:"tool_call",id:k.id,toolName:k.name,toolInput:k.input,...k._displayActions?{displayActions:k._displayActions}:{},toolResult:void 0,status:T?"incomplete":"pending",sourceMessages:[e],isSubagent:e.isSubagent},R=t.length;n.set(k.id,R),r.set(k.id,R),t.push(E)}}}function mm(e){const t=typeof e.configModel=="string"?e.configModel.trim():"",n=typeof e.configThinking=="string"?e.configThinking.trim():"";return t||n?`${t}::${n}`:typeof e.content=="string"?e.content.trim():null}function Va(e,t){const n=Kn(t);return e.sourceMessages.some(r=>Kn(r)===n)?e:{...e,sourceMessages:[...e.sourceMessages,t]}}function fm(e,t,n,r){return{...Va(e,t),toolInput:n,displayActions:r}}function hm(e,t,n,r,o){var y;const i=e.tool_use_id;if(!i)return;const a=r.get(i);if(a===void 0){o!=null&&o.onUnmatchedToolResult?o.onUnmatchedToolResult({toolUseId:i,message:t}):console.warn(`Tool result for unknown tool_use: ${i}`);return}const l=n[a];if((l==null?void 0:l.type)!=="tool_call")return;let c=t.toolUseResult??t.tool_use_result;!c&&(l.toolName==="Agent"||l.toolName==="Task")&&(c=Vu(e)),c=pm(l,e,c);const d=xs(e._projectPathLinks),u={content:typeof e.content=="string"?e.content:"",isError:e.is_error||!1,structured:c,...d?{projectPathLinks:d}:{},...(y=t.toolResultMedia)!=null&&y.some(x=>x.toolCallId===e.tool_use_id)?{media:t.toolResultMedia.filter(x=>x.toolCallId===e.tool_use_id)}:{}},f=gm(e,l.toolName),h=xm(e,u,l.toolName);let g="complete";h||l.status==="aborted"?g="aborted":f?g=l.status==="incomplete"?"incomplete":"pending":e.is_error&&(g="error");const p={type:"tool_call",id:l.id,toolName:l.toolName,toolInput:l.toolInput,...l.displayActions?{displayActions:l.displayActions}:{},toolResult:u,status:g,sourceMessages:Va(l,t).sourceMessages,isSubagent:l.isSubagent};n[a]=p,!f&&!h&&r.delete(i)}function pm(e,t,n){if(e.toolName!=="Bash"||t.is_error!==!0)return n;const r=typeof n=="string"?n:typeof t.content=="string"?t.content:"",o=Me(r,{bareExitCodeIsEnvelope:!0});return!o.hasEnvelope||o.exitCode===void 0?n:{stdout:o.output,stderr:"",interrupted:!1,isImage:!1,exitCode:o.exitCode}}function gm(e,t){if(t!=="Bash")return!1;const n=typeof e.content=="string"?e.content:"";return n?/(?:^|\n)\s*(?:Process\s+running\s+with\s+session\s+ID|session(?:\s+id)?)\s*:?\s*\d+\b/i.test(n)&&!/(?:^|\n)\s*(?:Exit code:|Process exited with code)\s*-?\d+\b/i.test(n):!1}function xm(e,t,n){if(n!=="Bash")return!1;if(t.structured&&typeof t.structured=="object"&&t.structured.interrupted===!0)return!0;const r=typeof e.content=="string"?e.content:"";return/(?:^|\n)\s*(?:aborted by user|interrupted by user)(?:\s|$)/i.test(r)}function ym(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const jm=[/^<recommended_plugins>[\s\S]*?<\/recommended_plugins>/iu,/^# AGENTS\.md instructions[^\r\n]*(?:\r?\n)+\s*<INSTRUCTIONS>[\s\S]*?<\/INSTRUCTIONS>/iu,/^<environment_context>[\s\S]*?<\/environment_context>/iu];function bm(e){return e.some(t=>typeof t.codexUserTurnProvenance=="string")}function vm(e){return e.some(t=>t._source==="sdk")}function wm(e){let t=e.trim(),n=!1;for(;t;){const r=jm.map(o=>o.exec(t)).find(o=>(o==null?void 0:o.index)===0);if(!(r!=null&&r[0]))return!1;n=!0,t=t.slice(r[0].length).trimStart()}return n}function Ga(e,t=[]){return bm(t)||vm(t)?!1:wm(e)}function _m(e,t=[]){return Ga(e,t)?e.trimStart().startsWith("<environment_context>"):!1}const Nm=5e3;function za(e){return typeof e=="string"?e:e.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
9
+ `)}function tr(e){const t=za(e.content).trimStart();return Ga(t,e.sourceMessages)}function km(e){return _m(za(e.content),e.sourceMessages)}function Ao(e){const t=e.sourceMessages.map(n=>typeof n.timestamp=="string"?Date.parse(n.timestamp):NaN).find(Number.isFinite);return t===void 0?null:t}function Sm(e,t){if(!km(e)||(t==null?void 0:t.type)!=="user_prompt"||tr(t))return!1;const n=Ao(e),r=Ao(t);if(n===null||r===null)return!1;const o=r-n;return o>=0&&o<=Nm}function Cm(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if((r==null?void 0:r.type)!=="user_prompt"||!tr(r)){t.push(r),n+=1;continue}const o=[];let i=n;for(;i<e.length;){const c=e[i];if((c==null?void 0:c.type)!=="user_prompt"||!tr(c))break;o.push(c),i+=1}const a=o.length===1?o[0]:void 0;if(a!==void 0&&Sm(a,e[i])){n=i;continue}if(o.length>1||n===0){const c=o[0];if(!c){n=i;continue}const d={type:"session_setup",id:`session-setup-${c.id}`,title:"Session setup",prompts:o.map(u=>u.content),sourceMessages:o.flatMap(u=>u.sourceMessages)};t.push(d)}else{const c=o[0];c&&t.push(c)}n=i}return t}function nt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Tm(e){if(nt(e)){if(typeof e.command=="string"&&e.command.trim().length>0)return e.command;if(typeof e.cmd=="string"&&e.cmd.trim().length>0)return e.cmd}}function wt(e){if(typeof e=="number"&&Number.isFinite(e))return String(Math.trunc(e));if(typeof e=="string"&&e.trim().length>0)return e.trim()}function qa(e){if(nt(e))return wt(e.session_id??e.sessionId)}function Fo(e){var i,a;const t=(i=e.toolResult)==null?void 0:i.structured;if(nt(t)){const l=wt(t.session_id??t.sessionId);if(l)return l}const n=((a=e.toolResult)==null?void 0:a.content)??"",o=(typeof n=="string"?n:"").match(/(?:^|\n)\s*(?:Process\s+running\s+with\s+session\s+ID|session[_\s]?id|session)\s*[:=]?\s*(\d+)\b/i);if(o!=null&&o[1])return o[1]}function $r(e){if(nt(e))return wt(e.cell_id??e.cellId)}function Yn(e){var n;const t=((n=e.toolResult)==null?void 0:n.content)??"";return Xn(typeof t=="string"?t:"")}function Rm(e,t){return!nt(e)||typeof e.linked_command=="string"&&e.linked_command.trim()?e:{...e,linked_command:t}}function Pm(e,t){return!nt(e)||typeof e.linked_file_path=="string"&&e.linked_file_path.trim()?e:{...e,linked_file_path:t}}function Em(e,t){return!nt(e)||typeof e.linked_tool_name=="string"&&e.linked_tool_name.trim()?e:{...e,linked_tool_name:t}}function nr(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function Bo(e){const t=e.toLowerCase();return t==="read"||t==="write"||t==="edit"}function Im(e){if(!nt(e)||typeof e.file_path!="string")return;const t=e.file_path.trim();return t.length>0?t:void 0}const Mm=/(?:Command|Process)\s+running\s+(?:in\s+background\s+with\s+ID|with\s+session\s+ID)\s*:?\s*([\w-]+)/i,$m=/(?:^|\n)\s*Process exited with code \d+/i,Lm=/^(completed|failed|killed|stopped|success|error|done)/i;function $e(e,t){return nt(e)?e[t]:void 0}function Am(e){return e==="taskoutput"||e==="task_output"||e==="get_command_or_subagent_output"}function Fm(e){return e==="killshell"||e==="kill_shell"||e==="kill_command_or_subagent"}function Bm(e){return e==="completed"||e==="failed"||e==="cancelled"}function Do(e){var n;const t=(n=e.toolResult)==null?void 0:n.content;return typeof t=="string"?t:""}function Dm(e){var r;const t=new Set,n=(...o)=>{for(const i of o)i&&t.add(i)};for(const o of e){if(o.type==="task_notification"){o.status&&Lm.test(o.status)&&n(o.taskId,o.toolUseId&&`tool:${o.toolUseId}`);continue}if(o.type!=="tool_call")continue;const i=o.toolName.toLowerCase(),a=o.toolInput,l=(r=o.toolResult)==null?void 0:r.structured;if(i==="bashoutput"||i==="bash_output"){const c=wt($e(l,"shellId")??$e(a,"bash_id")),d=$e(l,"status"),u=typeof $e(l,"exitCode")=="number";c&&(u||d==="completed"||d==="failed")&&n(c)}else if(Am(i)){const c=$e(l,"tasks"),d=Array.isArray(c)?c:[$e(l,"task")];for(const u of d)Bm($e(u,"status"))&&n(wt($e(u,"task_id")??$e(a,"task_id")))}else if(Fm(i))n(wt($e(l,"shell_id")??$e(l,"task_id")??$e(a,"shell_id")??$e(a,"task_id")));else if((i==="writestdin"||i==="write_stdin"||i==="wait")&&(typeof $e(l,"exit_code")=="number"||$m.test(Do(o)))){const d=qa(a),u=$r(a);n(d&&`session:${d}`,u&&`cell:${u}`)}}return e.map(o=>{var g;if(o.type!=="tool_call"||o.status!=="complete"||!nr(o.toolName))return o;const i=Do(o),a=[`tool:${o.id}`];let l=$e(o.toolInput,"run_in_background")===!0;const c=wt($e((g=o.toolResult)==null?void 0:g.structured,"backgroundTaskId"));c&&(l=!0,a.push(c,`session:${c}`));const d=i.match(Mm);d!=null&&d[1]&&(l=!0,a.push(d[1]),/session\s+ID/i.test(d[0])&&a.push(`session:${d[1]}`));const u=Xn(i);if(u&&(l=!0,a.push(`cell:${u}`)),!l)return o;const f=a.some(p=>t.has(p)),h=nt(o.toolInput)?o.toolInput:{};return{...o,toolInput:{...h,_backgroundTaskStatus:f?"completed":"running"}}})}function Om(e){const t=new Map,n=new Map;return e.map(r=>{if(r.type!=="tool_call")return r;if(nr(r.toolName)||Bo(r.toolName)){const f=Fo(r),h=Yn(r);if(!f&&!h)return r;const g=nr(r.toolName)?Tm(r.toolInput):void 0,p=Bo(r.toolName)?Im(r.toolInput):void 0;for(const[y,x]of[[f,t],[h,n]]){if(!y)continue;const b=x.get(y)??{};x.set(y,{command:g??b.command,filePath:p??b.filePath,toolName:r.toolName??b.toolName})}return r}const o=r.toolName.toLowerCase();if(o!=="writestdin"&&o!=="write_stdin"&&o!=="wait")return r;const i=qa(r.toolInput),a=$r(r.toolInput),l=(i?t.get(i):void 0)??(a?n.get(a):void 0),c=Yn(r);if(c&&l){const f=n.get(c)??{};n.set(c,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}const d=Fo(r);if(d&&l){const f=t.get(d)??{};t.set(d,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}if(!l)return r;let u=r.toolInput;return l.command&&(u=Rm(u,l.command)),l.filePath&&(u=Pm(u,l.filePath)),l.toolName&&(u=Em(u,l.toolName)),u===r.toolInput?r:{...r,toolInput:u}})}function Oo(e){const t=e.toLowerCase();return t==="writestdin"||t==="write_stdin"||t==="wait"}function Um(e){const t=new Map;for(let i=0;i<e.length;i++){const a=e[i];if((a==null?void 0:a.type)!=="tool_call"||!Oo(a.toolName))continue;const l=$r(a.toolInput);if(!l)continue;const c=t.get(l);c?c.push(i):t.set(l,[i])}if(t.size===0)return e;const n=new Set,r=(i,a)=>{const l=t.get(i);if(!l)return-1;for(const c of l)if(c>a&&!n.has(c))return c;return-1},o=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let a=e[i];if(a!==void 0){if(a.type==="tool_call"&&Oo(a.toolName)){let l=Yn(a),c=i;for(;l;){const d=r(l,c);if(d<0)break;const u=e[d];if((u==null?void 0:u.type)!=="tool_call")break;n.add(d),c=d,a={...a,status:u.status,toolResult:u.toolResult},l=u.toolResult!==void 0?Yn(u):void 0}}o.push(a)}}return o}function Hm(e){return e.filter(t=>{var d,u,f;if(t.type!=="tool_call"||t.status!=="complete")return!0;const n=t.toolName.toLowerCase();if(n!=="writestdin"&&n!=="write_stdin"&&n!=="wait"||(d=t.toolResult)!=null&&d.isError)return!0;const r=nt(t.toolInput)?t.toolInput:{};if((typeof r.chars=="string"?r.chars:"").length>0||[r.linked_command,r.linked_file_path,r.linked_tool_name].some(h=>typeof h=="string"&&h.trim().length>0))return!0;const a=((u=t.toolResult)==null?void 0:u.content)??"",l=Me(a),c=Ct((f=t.toolResult)==null?void 0:f.structured).exitCode??l.exitCode;return l.output.trim().length>0||c!==void 0})}const Uo="@@visualization-schema/1 ",Ka={containsTags:!1,closed:!1},Wm={containsTags:!0,view:"spans"},Xa={collect:!1,order:0};function sr(e){return typeof e=="string"&&e.length>0&&!/[[\]\r\n]/.test(e)}function Ya(e){var t;return(t=/^(?:\[[^[\]\r\n]+\])+/.exec(e))==null?void 0:t[0]}function rr(e){try{return JSON.parse(e)}catch{return}}function Ho(e,t){if(e===void 0)return t;if(!(!at(e)||e.containsTags!==void 0&&typeof e.containsTags!="boolean"||e.closed!==void 0&&typeof e.closed!="boolean")&&!(e.view!==void 0&&e.view!=="spans"&&e.view!=="matching-lines")&&!(e.whitelist!==void 0&&(!Array.isArray(e.whitelist)||!e.whitelist.every(n=>typeof n=="string"&&Ya(n)===n))))return{containsTags:e.containsTags??!1,closed:e.closed??!1,view:e.view,whitelist:e.whitelist}}function Wo(e){if(e===void 0)return Xa;if(!(!at(e)||e.collect!==void 0&&typeof e.collect!="boolean"||e.order!==void 0&&(typeof e.order!="number"||!Number.isFinite(e.order))))return{collect:e.collect??!1,order:e.order??0}}function Vo(e){if(!at(e)||e.type!=="tagged-stages/1"||typeof e.id!="string"||!e.id||/\s/.test(e.id)||!sr(e.key)||e.key==="workflow"||typeof e.title!="string"||!Array.isArray(e.stages))return;const t=Ho(e.toolOutput,Ka),n=Wo(e.presentation);if(!t||!n)return;const r=new Map,o=`[${e.key}]`;r.set(o,{title:e.title,policy:t,presentation:n});function i(a,l,c,d){if(d>32||r.size+a.length>512)return!1;for(const u of a){if(!at(u)||!sr(u.key)||u.title!==void 0&&typeof u.title!="string"||u.children!==void 0&&!Array.isArray(u.children))return!1;const f=`${l}[${u.key}]`,h=Ho(u.toolOutput,c.policy),g=Wo(u.presentation);if(r.has(f)||r.size>=512||!h||!g)return!1;const p={title:`${c.title} › ${u.title??u.key}`,policy:h,presentation:g};if(r.set(f,p),Array.isArray(u.children)&&!i(u.children,f,p,d+1))return!1}return!0}if(i(e.stages,o,r.get(o),1))return{id:e.id,title:e.title,root:o,stages:r}}function Vm(e){const t=rr(e);if(!Array.isArray(t))return;const n=[];for(const r of t){const o=typeof r=="string"?[r]:r;if(!Array.isArray(o)||!o.length||!o.every(sr))return;n.push(o.map(i=>`[${i}]`).join(""))}return{id:"",title:"",root:"",stages:new Map,inline:new Set(n)}}function Lr(e){if(!/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/.test(e))return;const t=e.indexOf("#");return{path:t<0?e:e.slice(0,t),id:t<0?void 0:e.slice(t+1)}}function Go(e,t){const n=Lr(t);if(!n)return;const{id:r}=n,o=rr(e);if(at(o)){const a=Vo(o);return a&&(r===void 0||a.id===r)?a:void 0}const i=[];for(const a of e.matchAll(/^```json\s*\r?\n([\s\S]*?)^```\s*$/gm)){const l=rr(a[1]??"");if(!at(l)||(r===void 0?!l.type:l.id!==r))continue;const c=Vo(l);if(!c)return;i.push(c)}return i.length===1?i[0]:void 0}function Ot(e){return e.schema.stages.get(e.path)??{title:e.path.replace(/\]\[/g," › ").replace(/^\[|\]$/g,""),policy:e.schema.inline?Wm:Ka,presentation:Xa}}function zo(e,t){var o;let n="",r="";for(const i of t.slice(1,-1).split("]["))n+=`[${i}]`,r=((o=e.stages.get(n))==null?void 0:o.title)??`${r?`${r} › `:""}${i}`;return r}function Gm(e,t){var r;if(t.schema.inline)return t.schema.inline.has(e);const n=Ot(t).policy;return n.containsTags&&(!n.closed||t.schema.stages.has(`${t.path}${e}`)||((r=n.whitelist)==null?void 0:r.includes(e))===!0)}function zm(e){var r,o,i,a,l,c;const t=(r=e.toolResult)==null?void 0:r.structured;if(e.toolName==="Exec"){const d=ht(t??((o=e.toolResult)==null?void 0:o.content));if(d){const u=d.parts.filter(f=>f.kind!=="script-status").map(f=>f.text);return u.length?u:[""]}}if(e.toolName==="Read"&&at(t)&&t.type==="text"&&at(t.file)&&typeof t.file.content=="string")return[t.file.content];const n=["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase());if(at(t)&&(typeof t.stdout=="string"||typeof t.stderr=="string"))return[typeof t.stdout=="string"?t.stdout:n?"":((i=e.toolResult)==null?void 0:i.content)??"",typeof t.stderr=="string"?t.stderr:""];if(n){const d=((a=e.toolResult)==null?void 0:a.content)??"",u=Me(d,{bareExitCodeIsEnvelope:(l=e.toolResult)==null?void 0:l.isError});return[u.hasEnvelope?u.output:d]}return[((c=e.toolResult)==null?void 0:c.content)??""]}function or(e,t,n,r,o,i,a,l){var _,N;const c={markers:[]};let d=t;const u=t==null?void 0:t.path;t&&u&&(c.parent={path:u,title:Ot(t).title}),n&&t&&Ot(t).policy.containsTags&&(c.view=Ot(t).policy.view??"spans");const f=[];function h(v,j){const C=f.at(-1);C&&C.end>=v?C.end=j:f.push({start:v,end:j})}let g,p="data";const y=new Map;let x=0,b=0;for(const v of e.split(`
10
10
  `)){const j=v.replace(/\r$/,""),C=x,w=a==null?void 0:a.get(C);w!==void 0&&w!==p&&(y.set(p,g),p=w,g=y.get(p)),x+=v.length+1;const k=Math.min(x,e.length);if(n&&c.view!=="matching-lines"&&h(C,k),r&&x>e.length)break;for(;l!=null&&l[b]&&l[b].end<=C;)b++;if(l!=null&&l[b]&&l[b].start<=C)continue;const S=(_=/^ {0,3}(`{3,}|~{3,})/.exec(j))==null?void 0:_[1],$=g!==void 0;S&&(g?S[0]===g[0]&&S.length>=g.length&&/^ {0,3}(?:`+|~+)\s*$/.test(j)&&(g=void 0):g=S);const T=(R,D,K,V)=>{n&&h(C,k),c.markers.push({start:C,end:C+D.length,prefix:D,title:K,kind:R,...V?{path:V}:{}})};if(!$&&!S&&j.startsWith(Uo)){const R=j.slice(Uo.length).trim(),D=Lr(R),K=i==null?void 0:i[R],V=D&&n?Go(e,R):void 0,G=R.startsWith("[")?Vm(R):D?V??Go(K??"",R):void 0,W=G&&!G.inline?JSON.stringify([...G.stages]):void 0,ie=G&&o.declarations.get(G.id);if(!G||ie!==void 0&&ie!==W){T("unresolved",j,R),D&&(c.markers.at(-1).schemaRef=R);continue}W&&o.declarations.set(G.id,W),d=G.inline?{schema:G,path:""}:void 0,(!n||!t)&&(o.activated=G,o.cursor=d),n&&G.inline&&(c.view="spans"),T("activation",j,G.title),D&&!V&&(c.markers.at(-1).schemaRef=R);continue}if(!n&&($||S))continue;const E=Ya(j);if(E){if(!n&&!(d!=null&&d.schema.inline)&&E==="[workflow][start]"){const R=/^\[workflow\]\[start\] id=(\S+) schema=(\S+)\s*$/.exec(j);R&&o.activated&&!o.activated.inline&&o.activated.id===R[2]&&!o.cursor&&(o.cursor={schema:o.activated,path:o.activated.root,instance:R[1]},d=o.cursor,T("start",E,o.activated.title))}else if(!n&&!(d!=null&&d.schema.inline)&&E==="[workflow][end]"){const R=/^\[workflow\]\[end\] id=(\S+) status=(completed|blocked|failed)(?:\s|$)/.exec(j);R&&o.cursor&&o.cursor.instance===R[1]&&(T("end",E,`${o.cursor.schema.title} · ${R[2]}`),o.cursor=void 0,d=void 0)}else if(d){if(!(n?Gm(E,d):((N=d.schema.inline)==null?void 0:N.has(E))??d.schema.stages.has(E)))continue;const D=n?`${u??""}${E}`:E,K=n&&t&&t.schema!==d.schema&&u?`${Ot(t).title} › ${zo(d.schema,E)}`:zo(d.schema,D);T("stage",E,K,D),n||(o.cursor={...d,path:E},d=o.cursor)}}}return n&&c.view&&(c.visibleRanges=f),c}function qm(e,t,n){return{initial:e?{...e,schema:{...e.schema,stages:[...e.schema.stages],inline:e.schema.inline?[...e.schema.inline]:void 0}}:void 0,schemaFiles:n,declarations:[...t.declarations]}}function ir(e,t,n){const r=e.outputText??"",o=r&&n?`
11
11
  `:"",i=r.length+o.length;e.outputText=r+o+n,e.outputBoundaries??(e.outputBoundaries=[]),e.outputBoundaries.push(...(t.outputBoundaries??[0]).map(a=>a+i)),e.parent??(e.parent=t.parent),e.view??(e.view=t.view),e.markers.push(...t.markers.map(a=>({...a,start:a.start+i,end:a.end+i}))),e.visibleRanges??(e.visibleRanges=[]),e.visibleRanges.push(...(t.visibleRanges??[{start:0,end:n.length}]).map(a=>({start:a.start+i,end:a.end+i})))}function Km(e){const t={markers:[],outputText:""};for(const n of e)ir(t,n,n.outputText??"");return t}function Jn(e,t,n={declarations:new Map(t.declarations)}){const r=t.initial?{...t.initial,schema:{...t.initial.schema,stages:new Map(t.initial.schema.stages),inline:t.initial.schema.inline?new Set(t.initial.schema.inline):void 0}}:void 0,o={markers:[],outputText:""},i={markers:[],outputText:""},a={};for(const l of e){let c="",d;const u=new Map,f=l.map(N=>{c&&!c.endsWith(`
12
12
  `)&&(N.kind==="commentary"||d==="commentary")&&(c+=`
13
13
  `);const v=c.length;return u.set(v,N.kind==="data"?"data":N.id),c+=N.text,d=N.kind,{fragment:N,start:v,end:c.length}}),h=or(c,r,!0,!1,n,t.schemaFiles,u,f.filter(N=>N.fragment.opaque));ir(i,h,c);const g={markers:[],outputText:"",parent:h.parent,view:h.view,visibleRanges:[]};let p,y,x=0,b=0;const _=h.visibleRanges??[{start:0,end:c.length}];for(const{fragment:N,start:v,end:j}of f){const C=[];for(;h.markers[x]&&h.markers[x].start<j;){const S=h.markers[x++];S.start>=v&&C.push(S)}const w=[];for(;_[b]&&_[b].end<=v;)b++;for(let S=b;_[S]&&_[S].start<j;S++){const $=_[S],T=Math.max(v,$.start),E=Math.min(j,$.end);T<E&&w.push({start:T-v,end:E-v})}const k={markers:C.map(S=>({...S,start:S.start-v,end:S.end-v})),parent:p!=null&&p.path?{path:p.path,title:p.title}:h.parent,view:h.view,visibleRanges:w};if(N.kind==="commentary")a[N.id]=k;else{const S=g.outputText.length;h.view==="spans"&&p&&p!==y&&!C.some($=>$.start===v)&&g.markers.push({...p,prefix:"",start:S,end:S}),g.markers.push(...k.markers.map($=>({...$,start:$.start+S,end:$.end+S}))),g.visibleRanges.push(...k.visibleRanges.map($=>({start:$.start+S,end:$.end+S}))),g.outputText+=N.text}for(const S of C)S.kind==="stage"?p=S:S.kind==="activation"&&(p=void 0);N.kind==="data"&&(y=p)}ir(o,g,g.outputText)}return{data:o,combined:i,commentary:a}}function Ja(e,t){const n=[];for(const r of t.visibleRanges??[{start:0,end:e.length}]){let o=r.start,i;for(const a of t.markers)a.start<r.start||a.start>=r.end||((o<a.start||i)&&n.push({text:e.slice(o,a.start),marker:i}),i=a,o=a.end);(o<r.end||i)&&n.push({text:e.slice(o,r.end),marker:i})}return n}function Xm(e,t,n){const r=new Map,o=new Map,i=new Map;let a=0;const l={declarations:new Map};for(const c of t){if(c.isSubagent)continue;const d=c.sourceMessages[0];if(d){const u=r.get(d)??[];u.push({item:c,result:!1}),r.set(d,u)}if(c.type==="tool_call"&&c.toolResult){const u=[...c.sourceMessages].reverse().find(f=>{var g;const h=((g=f.message)==null?void 0:g.content)??f.content;return Array.isArray(h)&&h.some(p=>p.type==="tool_result"&&p.tool_use_id===c.id)});if(u){const f=r.get(u)??[];f.push({item:c,result:!0}),r.set(u,f)}}}for(const c of e)for(const d of r.get(c)??[]){const{item:u,result:f}=d;if(u.type==="user_prompt"||u.type==="system"&&u.subtype==="compact_boundary")a++,l.cursor=void 0,l.activated=void 0,l.declarations=new Map;else if(u.type==="text")o.set(u,or(u.text,l.cursor,!1,u.isStreaming===!0,l,n));else if(u.type==="tool_call")if(f){const h=i.get(u);if((h==null?void 0:h.turn)===a&&u.toolResult){const g=zm(u),p=u.status!=="pending";if(g.some(N=>mt(N,p))){const N=qm(h.cursor,l,n),v=u.toolName!=="Exec"&&g.some(w=>mt(w,p)==="json"),j=g.map((w,k)=>new Fa("unknown").appendSnapshot(w,p,u.toolName==="Exec"?mt(w,p)==="json":k===0&&v).flatMap(({id:S,record:$})=>Qs(`${k}:${S}`,$))),C=Jn(j,N,l);o.set(u,{...C.combined,toolContext:N});continue}const y=g.join(`
14
- `),x={markers:[],outputBoundaries:[]},b=[];let _=0;for(const N of g){x.outputBoundaries.push(_);const v=or(N,h.cursor,!0,u.status==="pending",l,n);x.parent=v.parent,v.view&&(x.view=v.view),x.markers.push(...v.markers.map(j=>({...j,start:j.start+_,end:j.end+_})));for(const j of v.visibleRanges??[{start:0,end:N.length}])b.push({start:j.start+_,end:j.end+_});_+N.length<y.length&&b.push({start:_+N.length,end:_+N.length+1}),_+=N.length+1}x.view&&(x.visibleRanges=b),x.view&&y!==u.toolResult.content&&(x.outputText=y),o.set(u,x)}}else{const h=l.cursor;i.set(u,{cursor:h,turn:a}),h!=null&&h.path&&o.set(u,{markers:[],parent:{path:h.path,title:Ot(h).title}})}}return t.map(c=>{const d=o.get(c);return d&&(d.markers.length||d.parent||d.view||d.toolContext)?{...c,workflow:d}:c})}function Ym(e,t,n){const r=Zu(e,t,n),o=t!=null&&t.workflowTags?Xm(e,r,t.workflowSchemaFiles):r,i=Lu(o),a=Yu(i),l=Om(a),c=Um(l),d=Dm(c),u=Hm(d);return Cm(u)}const Jm={onAssistantMessage(e){console.log("[preprocessMessages] Processing assistant message:",e)}};function Ar(e,t){const n=typeof window<"u"&&window.__STREAMING_DEBUG__?Jm:void 0;return Ym(e,t,n)}function Qa(e,t){return Yd(Ar(e,t))}function V_(e,t,n=!1){return n?Qa(e,t):Ar(e,t)}function Fr(e,t,n=!1){return Eu(e,t,n?Qa:Ar)}function G_(e){var n;const t=Fr(e);for(let r=t.length-1;r>=0;r-=1){const o=((n=t[r])==null?void 0:n.sourceMessages)??[];for(let i=o.length-1;i>=0;i-=1){const a=o[i],l=(a==null?void 0:a.uuid)??(a==null?void 0:a.id);if(l)return l}}return""}function Qm(e,t,n=!1){if(t.length===0)return e;const r=t.flatMap((i,a)=>{var c;if(i.placementAfterMessageId==="")return[{itemIndex:-1,object:i,order:a}];let l=Number.NEGATIVE_INFINITY;for(let d=0;d<e.length;d+=1){const u=e[d];u!=null&&u.sourceMessages.some(f=>(f.uuid??f.id)===i.placementAfterMessageId)&&(l=d)}if(l===Number.NEGATIVE_INFINITY&&n&&i.kind==="bang-command"){const d=nn(i.createdAt);if(d!==null)for(let u=0;u<e.length;u+=1){const f=ya(((c=e[u])==null?void 0:c.sourceMessages)??[]);f!==null&&f<=d&&(l=u)}}return l===Number.NEGATIVE_INFINITY?[]:[{itemIndex:l,object:i,order:a}]});if(r.sort((i,a)=>a.itemIndex-i.itemIndex||a.order-i.order),r.length===0)return e;const o=[...e];for(const i of r)o.splice(i.itemIndex+1,0,{type:"transcript_display_object",id:i.object.id,object:i.object,sourceMessages:[]});return o}const Za=m.createContext(null);function z_({children:e}){const t=m.useRef(null),n=m.useRef(null),r=m.useCallback(u=>(typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] Handler registered","color: #2196F3",{hadPreviousHandler:!!t.current}),t.current=u,()=>{t.current===u&&(typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] Handler unregistered","color: #FF5722"),t.current=null)}),[]),o=m.useCallback(u=>{n.current=u},[]),i=m.useCallback(u=>{var f;typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] dispatchAugment called","color: #4CAF50",{hasHandler:!!t.current,augment:{blockIndex:u.blockIndex,type:u.type}}),(f=t.current)==null||f.onAugment(u)},[]),a=m.useCallback(u=>{var f;typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] dispatchPending called","color: #FF9800",{hasHandler:!!t.current,htmlLength:u.html.length}),(f=t.current)==null||f.onPending(u)},[]),l=m.useCallback(()=>{var u;(u=t.current)==null||u.onStreamEnd(),n.current=null},[]),c=m.useCallback(()=>{var u,f;return((f=(u=t.current)==null?void 0:u.captureHtml)==null?void 0:f.call(u))??null},[]),d=m.useMemo(()=>({registerStreamingHandler:r,setCurrentMessageId:o,dispatchAugment:i,dispatchPending:a,dispatchStreamEnd:l,captureStreamingHtml:c}),[r,o,i,a,l,c]);return s.jsx(Za.Provider,{value:d,children:e})}function Zm(){return m.useContext(Za)}const Ts=100,ef=750,qo=16,tf=20;function Rn(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Re(e,t,n){if(typeof window<"u"&&window.__STREAMING_DEBUG__){const r={augment:"[AUGMENT]",pending:"[PENDING]",event:"[EVENT]",dom:"[DOM]"}[e],o=n?` ${JSON.stringify(n)}`:"";console.log(`%c${r} ${t}${o}`,nf(e))}}function nf(e){return{augment:"color: #4caf50; font-weight: bold",pending:"color: #ff9800; font-weight: bold",event:"color: #2196f3; font-weight: bold",dom:"color: #9c27b0; font-weight: bold"}[e]||""}function sf(e={}){const t=m.useRef(null),n=m.useRef(null),[r,o]=m.useState(!1),i=m.useRef(e.transformHtml);i.current=e.transformHtml;const a=m.useRef(new Map),l=m.useRef(new Map),c=m.useRef(""),d=m.useRef(-1),u=m.useRef(new Map),f=m.useRef(null),h=m.useRef(null),g=m.useRef(Number.NEGATIVE_INFINITY),p=m.useRef(Ts),y=m.useRef(0),x=m.useCallback(()=>{o(T=>T||!0)},[]),b=m.useCallback(T=>{var G;const E=t.current;if(Re("augment","Received augment",{blockIndex:T.blockIndex,type:T.type,htmlLength:T.html.length,htmlPreview:T.html.substring(0,100)}),!E){Re("augment","ERROR: containerRef.current is null - refs not attached!");return}x();const{blockIndex:R,html:D}=T;l.current.set(R,T);const K=((G=i.current)==null?void 0:G.call(i,D))??D;if(a.current.has(R)){const W=a.current.get(R);W&&(Re("dom","Updating existing block",{blockIndex:R}),W.innerHTML=K);return}const V=document.createElement("div");if(V.className="streaming-block",V.dataset.blockIndex=String(R),V.innerHTML=K,Re("dom","Created new block element",{blockIndex:R,className:V.className}),R>d.current)E.appendChild(V),d.current=R,Re("dom","Appended block to end",{blockIndex:R,maxBlockIndex:d.current});else{let W=!1;const ie=E.children;for(let ae=0;ae<ie.length;ae++){const Pe=ie[ae],se=Number.parseInt(Pe.dataset.blockIndex??"-1",10);if(se>R){E.insertBefore(V,Pe),W=!0,Re("dom","Inserted block before",{blockIndex:R,beforeIndex:se});break}}W||(E.appendChild(V),Re("dom","Appended out-of-order block to end",{blockIndex:R}))}a.current.set(R,V),Re("dom","Block tracking updated",{totalBlocks:a.current.size})},[x]),_=m.useCallback(T=>{var R;const E=n.current;if(Re("pending","Received pending update",{htmlLength:T.html.length,htmlPreview:T.html.substring(0,80)}),!E){Re("pending","ERROR: pendingRef.current is null - refs not attached!");return}x(),c.current=T.html,E.innerHTML=((R=i.current)==null?void 0:R.call(i,T.html))??T.html,Re("pending","Updated pending element innerHTML")},[x]),N=m.useCallback(()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},[]),v=m.useCallback(()=>{N();const T=u.current,E=f.current;if(T.size===0&&E===null){y.current=0;return}const R=[...T.values()].sort((G,W)=>G.blockIndex-W.blockIndex),D=y.current;T.clear(),f.current=null,y.current=0;const K=Rn();for(const G of R)b(G);E!==null&&_({html:E});const V=Rn()-K;Cs()&&(Cn("streaming-markdown.flush",{durationMs:V}),Cn("streaming-markdown.flushed-event",{count:D,category:R.length>0&&E!==null?"augment-and-pending":R.length>0?"augment":"pending"})),V>qo||D>tf?p.current=Math.min(ef,Math.max(200,Math.ceil(p.current*1.5))):V<qo/2&&D<=6&&(p.current=Math.max(Ts,Math.floor(p.current*.8))),g.current=Rn()},[b,_,N]),j=m.useCallback(()=>{if(h.current!==null)return;const E=Rn()-g.current,R=p.current;if(E>=R){v();return}h.current=setTimeout(v,R-E)},[v]),C=m.useCallback(T=>{Cs()&&Cn("streaming-markdown.event",{category:"augment",chars:T.html.length}),u.current.set(T.blockIndex,T),y.current+=1,j()},[j]),w=m.useCallback(T=>{Cs()&&Cn("streaming-markdown.event",{category:"pending",chars:T.html.length}),f.current=T.html,y.current+=1,j()},[j]),k=m.useCallback(()=>{Re("event","Stream ended"),v();const T=n.current;c.current="",T&&(T.innerHTML="",Re("event","Cleared pending element")),o(!1),Re("event","Set isStreaming to false")},[v]),S=m.useCallback(()=>{Re("event","Reset called"),N(),u.current.clear(),f.current=null,l.current.clear(),c.current="",y.current=0,p.current=Ts;const T=t.current,E=n.current;T&&(T.innerHTML="",Re("event","Cleared container")),E&&(E.innerHTML="",Re("event","Cleared pending element"));const R=a.current.size;a.current.clear(),d.current=-1,o(!1),Re("event","Reset complete",{previousBlockCount:R,maxBlockIndexReset:!0})},[N]),$=m.useCallback(()=>{if(v(),!t.current)return null;const T=document.createElement("div");for(const R of[...l.current.values()].sort((D,K)=>D.blockIndex-K.blockIndex)){const D=document.createElement("div");D.className="streaming-block",D.dataset.blockIndex=String(R.blockIndex),D.innerHTML=R.html,T.append(D)}const E=T.innerHTML;return Re("event","Captured HTML",{length:E.length}),E||null},[v]);return m.useEffect(()=>{var E,R;for(const[D,K]of a.current){const V=l.current.get(D);V&&(K.innerHTML=((E=e.transformHtml)==null?void 0:E.call(e,V.html))??V.html)}const T=n.current;T&&c.current&&(T.innerHTML=((R=e.transformHtml)==null?void 0:R.call(e,c.current))??c.current)},[e.transformHtml]),m.useEffect(()=>()=>{N()},[N]),{containerRef:t,pendingRef:n,isStreaming:r,onAugment:C,onPending:w,onStreamEnd:k,reset:S,captureHtml:$}}function Ko(e,t,n,r){if(r){const o=hd(r,{filePath:n});if(!o)return!1;e.setAttribute("href",o),e.dataset.publicShareFileLink="true"}else{const o=new URLSearchParams({path:n});e.setAttribute("href",`/projects/${encodeURIComponent(t)}/file?${o}`),e.dataset.yaPrivateProjectFileLink="true"}return e.dataset.yaResource="project-file",e.dataset.yaProjectId=t,e.dataset.yaPath=n,e.title=`${n}
15
- Click to view, or use a browser link gesture to open this file`,!0}function el(e,t,n,r){var u,f;if(!e||!(t!=null&&t.length)||!n||typeof document>"u")return{changed:!1,html:e};const o=new Map(t.map(h=>[h.text,h.filePath])),i=document.createElement("template");i.innerHTML=e;let a=!1;for(const h of i.content.querySelectorAll('a[data-ya-resource="project-file"]')){const g=o.get(((u=h.textContent)==null?void 0:u.trim())??"");g&&Ko(h,n,g,r)&&(a=!0)}const l=document.createTreeWalker(i.content,NodeFilter.SHOW_TEXT),c=[];let d=l.nextNode();for(;d;)d instanceof Text&&!((f=d.parentElement)!=null&&f.closest("a,button,script,style,textarea"))&&c.push(d),d=l.nextNode();for(const h of c){const g=va(h.data).filter(p=>o.has(p.text));for(let p=g.length-1;p>=0;p-=1){const y=g[p];if(!y)continue;const x=document.createElement("a");if(!Ko(x,n,o.get(y.text),r))continue;h.splitText(y.end);const b=h.splitText(y.start);b.replaceWith(x),x.append(b),a=!0}}return{changed:a,html:a?i.innerHTML:e}}const ar='a.local-media-link[data-media-type="image"], a.local-media-link[data-ya-media-type="image"]';function tl(e,t){return`${e}:inline-image:${t}`}function Br(e){return Array.from(e.querySelectorAll(ar))}function rf(e){var n,r;const t=e.getAttribute("data-ya-path")??((r=(n=e.closest(".local-media-link-group"))==null?void 0:n.querySelector("[data-media-path]"))==null?void 0:r.getAttribute("data-media-path"));if(t)return t;try{return new URL(e.href,window.location.href).searchParams.get("path")}catch{return null}}function of(e,t){var r,o;const n=e.cloneNode(!0);return(r=n.querySelector(".local-media-type"))==null||r.remove(),((o=n.textContent)==null?void 0:o.trim())||tt(t)}function af(e,t){if(!e.augmentHtml||typeof document>"u")return[];const n=document.createElement("template");n.innerHTML=e.augmentHtml;const r=[];for(const[o,i]of Br(n.content).entries()){const a=rf(i);a&&r.push({basename:tt(a),id:tl(e.id,o),label:of(i,a),originalIndex:t+r.length,path:a,sourceIndex:o,sourceItemId:e.id})}return r}function lf(e){const t=[];for(const n of e)n.type==="text"&&t.push(...af(n,t.length));return t}function Xo(e,t,n){var a;if(!(n instanceof Element))return null;const r=n.closest(`${ar}, button.local-media-inline-toggle[data-media-type="image"]`);if(!r||!e.contains(r))return null;const o=r instanceof HTMLAnchorElement?r:(a=r.closest(".local-media-link-group"))==null?void 0:a.querySelector(ar);if(!o)return null;const i=Br(e).indexOf(o);return i>=0?{id:tl(t,i),kind:r instanceof HTMLAnchorElement?"link":"toggle"}:null}function nl(e,t){return Br(e)[t]??null}function cf(e){return!e||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0?null:e}function df(e){return e?Math.max(.2,Math.min(5,e.width/e.height)):4/3}function uf(e,t,n,r,o){const i=Array.from({length:t},()=>({aspectSum:0,images:[]}));for(const c of e){let d=i[0];if(d){for(const u of i.slice(1))u.aspectSum<d.aspectSum&&(d=u);d.images.push(c),d.aspectSum+=c.aspect}}const l=Math.max(1,r-o*(t-1))/t;return i.filter(c=>c.images.length>0).map(c=>{const d=Math.max(1,n-o*(c.images.length-1)),u=Math.max(1,Math.min(l,d/c.aspectSum)),f=c.images.map(h=>{const g=h.naturalHeight===null?u:Math.min(u,h.naturalHeight);return{height:g,id:h.id,naturalHeight:h.naturalHeight,naturalWidth:h.naturalWidth,width:h.aspect*g}});return{height:Math.max(...f.map(h=>h.height)),items:f}})}function mf(e,t,n,r,o=8){if(e.length===0||n<=0||r<=0)return[];const i=e.map(d=>{const u=cf(t.get(d.id));return{...d,aspect:df(u),naturalHeight:(u==null?void 0:u.height)??null,naturalWidth:(u==null?void 0:u.width)??null}}).sort((d,u)=>u.aspect-d.aspect||d.originalIndex-u.originalIndex);let a=[],l=0;const c=Math.min(3,e.length);for(let d=1;d<=c;d+=1){const u=uf(i,d,n,r,o),f=Math.min(...u.flatMap(h=>h.items.map(g=>g.height)));f>l&&(a=u,l=f)}return a}function ff({alt:e,ariaLabel:t,buttonClassName:n,fileName:r,filePath:o,loadBlob:i,onImageLoad:a,onOpen:l,placeholderClassName:c,title:d}){const{t:u}=Z(),{url:f,error:h}=Aa(o,!0,i),g=hs({fileName:r,filePath:o,loadBlob:i,onOpen:l});return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:n,"aria-label":t,title:d,onClick:l,onContextMenu:g.handleContextMenu,children:f?s.jsx("img",{src:f,alt:e,draggable:!1,onLoad:a}):s.jsx("span",{className:c,children:u(h?"inlineImageUnavailable":"inlineImageLoading")})}),g.contextMenuElement]})}const hf="_gallery_1ydih_1",pf="_rows_1ydih_9",gf="_row_1ydih_9",xf="_item_1ydih_24",yf="_featured_1ydih_38",jf="_thumbnail_1ydih_43",bf="_placeholder_1ydih_63",vf="_footer_1ydih_74",wf="_caption_1ydih_82",_f="_count_1ydih_112",Nf="_dismiss_1ydih_118",Ze={gallery:hf,rows:pf,row:gf,item:xf,featured:yf,thumbnail:jf,placeholder:bf,footer:vf,caption:wf,count:_f,dismiss:Nf},sl=m.createContext(null);function kf(){return m.useContext(sl)}function Sf(){const e=ps();return m.useMemo(()=>{if(e)return{buildApiPath:t=>gd(e,t),fetchBlob:async(t,n)=>await pd({path:n,relayUrl:e.relayUrl,relayUsername:e.relayUsername})}},[e])}function Cf({candidate:e,featured:t,mediaSource:n,onDimensions:r,onFeature:o,onOpen:i,registerElement:a,style:l}){const{t:c}=Z(),d=Kt().transport,u=m.useCallback(()=>Sr(e.path,n,"inline",d),[e.path,n,d]);return s.jsx("div",{ref:f=>a(e.id,f),className:`${Ze.item}${t?` ${Ze.featured}`:""}`,"data-gallery-image-id":e.id,role:"group","aria-label":e.label,style:l,tabIndex:-1,onFocus:()=>o(e.id),onPointerEnter:()=>o(e.id),children:s.jsx(ff,{alt:e.label,ariaLabel:c("turnImageGalleryOpen",{label:e.label}),buttonClassName:Ze.thumbnail,fileName:e.basename,filePath:e.path,loadBlob:u,onImageLoad:f=>{const{naturalHeight:h,naturalWidth:g}=f.currentTarget;r(e.id,{height:h,width:g})},onOpen:()=>i(e),placeholderClassName:Ze.placeholder})})}function q_({children:e,items:t}){var xe;const{t:n}=Z(),{compactMultiImageGalleries:r,inlineMediaExpandedByDefault:o}=kr(),i=m.useMemo(()=>lf(t),[t]),a=i.map(L=>L.id).join("\0"),l=m.useMemo(()=>new Set(i.map(L=>L.id)),[i]),c=m.useMemo(()=>new Map(i.map(L=>[L.id,L])),[i]),d=m.useMemo(()=>new Map(i.map(L=>[L.id,L.label])),[i]),u=r&&i.length>=2,[f,h]=m.useState(!1),[g,p]=m.useState(!1),[y,x]=m.useState(((xe=i[0])==null?void 0:xe.id)??""),[b,_]=m.useState(null),[N,v]=m.useState(()=>new Map),[j,C]=m.useState({height:240,width:720}),w=m.useRef(null),k=m.useRef(null),S=m.useRef(new Map),$=m.useRef(null),T=m.useRef(null),E=m.useRef(null),R=m.useRef(null),D=m.useRef(null),K=m.useRef(null),V=m.useRef(y);V.current=y;const G=Sf(),W=u&&!f&&(o||g);m.useEffect(()=>{var L;l.has(y)||x(((L=i[0])==null?void 0:L.id)??"")},[l,i,y]),m.useLayoutEffect(()=>{const L=k.current;if(!L||!W)return;const B=()=>{const pe=window.innerHeight;C({height:Math.max(120,Math.min(320,pe/3-48)),width:Math.max(1,L.clientWidth)})};B();const Q=new ResizeObserver(B);return Q.observe(L),window.addEventListener("resize",B),()=>{Q.disconnect(),window.removeEventListener("resize",B)}},[W]);const ie=m.useCallback(L=>{x(L);const B=S.current.get(L);if(!B){$.current=L;return}B.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),B.focus({preventScroll:!0}),$.current=null},[]),ae=m.useCallback(L=>{l.has(L)&&($.current=L,x(L),p(!0),h(!1),W&&ie(L))},[l,ie,W]),Pe=m.useCallback(()=>{h(!0),p(!1)},[]),se=m.useCallback(()=>{var B;if(!u)return;const L=l.has(V.current)?V.current:(B=i[0])==null?void 0:B.id;L&&($.current=L,x(L)),p(!0),h(!1)},[l,i,u]);m.useLayoutEffect(()=>{W&&$.current&&ie($.current)},[ie,W]);const Se=m.useCallback(L=>{const B=w.current;if(!B)return null;const Q=Array.from(B.querySelectorAll("[data-turn-image-source-id]")).find(ye=>ye.dataset.turnImageSourceId===L.sourceItemId);return Q?nl(Q,L.sourceIndex):null},[]),F=m.useCallback(L=>{const B=Se(L);B&&(B.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),B.focus({preventScroll:!0}))},[Se]),O=m.useCallback((L,B)=>{D.current=B,K.current=B==="source"?L.id:null,x(L.id),_(L)},[]),Ce=m.useCallback(L=>{const B=c.get(L);B&&O(B,"source")},[c,O]),je=m.useCallback(L=>{if(!b||i.length<2)return;const B=i.findIndex(ye=>ye.id===b.id);if(B<0)return;const Q=(B+L+i.length)%i.length,pe=i[Q];pe&&(x(pe.id),_(pe))},[i,b]),He=m.useCallback(()=>{const L=(b==null?void 0:b.id)??null,B=D.current,Q=K.current;D.current=null,K.current=null,_(null),requestAnimationFrame(()=>{var pe;if(B==="gallery"&&L&&W){ie(L);return}if(Q){const ye=c.get(Q);ye&&((pe=Se(ye))==null||pe.focus({preventScroll:!0}))}})},[c,ie,Se,W,b]),ue=b?i.findIndex(L=>L.id===b.id):-1,Fe=ue>=0&&i.length>1?{count:i.length,current:ue+1,onNext:()=>je(1),onPrevious:()=>je(-1)}:void 0,Oe=m.useMemo(()=>mf(i,N,j.width,j.height),[i,N,j]),We=m.useMemo(()=>new Map(Oe.flatMap(L=>L.items.map(B=>[B.id,{"--turn-gallery-item-height":`${B.height}px`,"--turn-gallery-item-width":`${B.width}px`,...B.naturalHeight===null?{}:{"--turn-gallery-natural-height":`${B.naturalHeight}px`},...B.naturalWidth===null?{}:{"--turn-gallery-natural-width":`${B.naturalWidth}px`}}]))),[Oe]),re=i.find(L=>L.id===y)??i[0],Te=u?i[i.length-1]??null:null,A=m.useMemo(()=>({actionTarget:Te,active:W,activate:ae,available:u,candidateLabels:d,candidateIds:l,collapse:Pe,openImage:Ce,show:se}),[Te,ae,d,l,Pe,u,W,Ce,se]),U=m.useCallback(()=>{T.current=null;const L=k.current;if(!L)return;const B=L.getBoundingClientRect().left+L.clientWidth/2;let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.abs(me.left+me.width/2-B);(!Q||Be<Q.distance)&&(Q={distance:Be,id:pe})}Q&&x(Q.id)},[]),z=m.useCallback((L,B)=>{let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.max(me.left-L,0,L-me.right),ot=Math.max(me.top-B,0,B-me.bottom),Je=Be*Be+ot*ot,gt=me.left+me.width/2,$t=me.top+me.height/2,qe=(gt-L)**2+($t-B)**2;(!Q||Je<Q.edgeDistance||Je===Q.edgeDistance&&qe<Q.centerDistance)&&(Q={centerDistance:qe,edgeDistance:Je,id:pe})}Q&&x(Q.id)},[]),X=m.useCallback((L,B)=>{R.current={clientX:L,clientY:B},E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null;const Q=R.current;Q&&z(Q.clientX,Q.clientY)}))},[z]);return m.useEffect(()=>{if(!W||b)return;const L=B=>{B.pointerType!=="touch"&&X(B.clientX,B.clientY)};return window.addEventListener("pointermove",L,{passive:!0}),()=>window.removeEventListener("pointermove",L)},[W,X,b]),m.useEffect(()=>()=>{T.current!==null&&cancelAnimationFrame(T.current),E.current!==null&&cancelAnimationFrame(E.current)},[]),s.jsx(sl.Provider,{value:A,children:s.jsxs("div",{ref:w,className:`assistant-turn${W?" has-turn-image-gallery":""}`,children:[e,W?s.jsxs("section",{className:Ze.gallery,"aria-label":n("turnImageGalleryLabel"),onKeyDown:L=>{L.key==="Escape"&&(L.preventDefault(),Pe())},children:[s.jsx("div",{ref:k,className:Ze.rows,style:{"--turn-gallery-max-height":`${j.height}px`},onScroll:()=>{T.current===null&&(T.current=requestAnimationFrame(U))},children:Oe.map((L,B)=>s.jsx("div",{className:Ze.row,style:{height:L.height},children:L.items.map(Q=>{const pe=i.find(ye=>ye.id===Q.id);return pe?s.jsx(Cf,{candidate:pe,featured:pe.id===(re==null?void 0:re.id),mediaSource:G,onDimensions:(ye,me)=>{v(Be=>{const ot=Be.get(ye);if((ot==null?void 0:ot.width)===me.width&&ot.height===me.height)return Be;const Je=new Map(Be);return Je.set(ye,me),Je})},onFeature:x,onOpen:ye=>O(ye,"gallery"),registerElement:(ye,me)=>{me?S.current.set(ye,me):S.current.delete(ye)},style:We.get(pe.id)??{}},pe.id):null})},`${a}:row:${B}`))}),s.jsxs("div",{className:Ze.footer,children:[re?s.jsxs("button",{type:"button",className:Ze.caption,onClick:()=>F(re),children:[s.jsx("span",{children:re.label}),re.basename!==re.label?s.jsx("small",{children:re.basename}):null]}):null,s.jsx("span",{className:Ze.count,children:n("turnImageGalleryCount",{count:i.length,current:Math.max(1,i.findIndex(L=>L.id===(re==null?void 0:re.id))+1)})}),s.jsx("button",{type:"button",className:Ze.dismiss,"aria-keyshortcuts":"Escape",onClick:Pe,children:n("turnImageGalleryCollapse")})]})]}):null,b?s.jsx(qt,{path:b.path,mediaType:"image",mediaSource:G,imageNavigation:Fe,onClose:He}):null]})})}const Tf="_root_13m0q_1",Rf="_source_13m0q_11",Pf="_timelineAction_13m0q_46",Ef="_abortedMidStream_13m0q_57",Pn={root:Tf,source:Rf,timelineAction:Pf,abortedMidStream:Ef},If={html:"",changed:!1};function Mf(e){if(typeof document>"u")return e;const t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}const Yo=m.memo(function({artifact:t,className:n,html:r,projectId:o,projectPathLinks:i,publicShare:a}){const l=Cr(),c=m.useMemo(()=>{const d=el(r,i,o,a).html,u=Tr(d,t).html;return Rr(u,l)},[t,r,o,i,a,l]);return s.jsx("div",{className:n,dangerouslySetInnerHTML:{__html:c}})}),Qn=m.memo(function({text:t,isStreaming:n=!1,abortedMidStream:r=!1,augmentHtml:o,projectPathLinks:i,onQuoteBlock:a,alwaysShowQuoteCircle:l=!1,paragraphQuoteCirclesEnabled:c=!0,renderItemId:d,timelineAction:u}){var A;const{t:f}=Z(),[h,g]=m.useState(!1),[p,y]=m.useState(null),x=m.useRef(null),b=m.useRef(null),_=m.useMemo(()=>n?If:wa(t),[n,t]),N=_a(),v=N.state==="ready"&&((A=N.result)==null?void 0:A.status)==="ready"?N.result.artifact:void 0,j=ps(),C=Cr(),w=ge(),k=(w==null?void 0:w.projectId)??(j==null?void 0:j.projectId)??void 0,S=m.useCallback(U=>{const z=el(U,i,k,j).html,X=Tr(z,v).html;return Rr(X,C)},[v,k,i,j,C]),$=m.useMemo(()=>o?Mf(o).trim()!==t.trim():!1,[o,t]),T=sf({transformHtml:S}),E=Zm(),[R,D]=m.useState(!1);m.useEffect(()=>{if(!n||!E){n||(D(!1),T.reset());return}return E.registerStreamingHandler({onAugment:z=>{D(X=>X||!0),T.onAugment(z)},onPending:T.onPending,onStreamEnd:T.onStreamEnd,captureHtml:T.captureHtml})},[n,E,T.captureHtml,T.onAugment,T.onPending,T.onStreamEnd,T.reset]);const K=m.useCallback(async()=>{try{await navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),3e3)}catch(U){console.error("Failed to copy text:",U)}},[t]);m.useEffect(()=>{const U=x.current;if(U)return Jd(U,t)},[t]);const{modal:V,localFileModal:G,projectFileModal:W,handleClick:ie,handleContextMenu:ae,closeModal:Pe,closeLocalFileModal:se,closeProjectFileModal:Se,contextMenuElement:F}=Na(),O=kf();xd(x,void 0,void 0,{suppressAutomaticImages:(O==null?void 0:O.available)===!0}),yd(x);const Ce=m.useCallback(U=>{const z=x.current,X=z&&d&&(O!=null&&O.available)?Xo(z,d,U.target):null;if(X&&(O!=null&&O.candidateIds.has(X.id))){U.preventDefault(),U.stopPropagation(),X.kind==="link"?O.openImage(X.id):O.active?O.collapse():O.activate(X.id);return}ie(U)},[ie,d,O]),je=n&&R,He=$||_.changed,{showRendered:ue,toggleLocalMode:Fe}=jd(He,{participateInGlobalMode:!1,resetDependencies:[n,n?"":t,o??""]}),Oe=n,We=[ue,t,o??""].join("\0"),re=(O==null?void 0:O.actionTarget)??null,Te=(O==null?void 0:O.active)===!0;return m.useEffect(()=>{const U=x.current;if(!U||!ue||je||!d||!(O!=null&&O.available))return;const z=U.querySelectorAll("button.local-media-inline-toggle[data-media-type='image']");for(const X of z){const xe=Xo(U,d,X);if(!xe||!O.candidateIds.has(xe.id))continue;const L=O.candidateLabels.get(xe.id)??"",B=Te?f("turnImageGalleryCollapse"):f("turnImageGalleryExpandAt",{label:L});X.dataset.expanded=String(Te),X.setAttribute("aria-expanded",String(Te)),X.setAttribute("aria-label",B),X.title=B,X.textContent=Te?"−":"+"}},[Te,d,ue,je,f,O]),m.useLayoutEffect(()=>{const U=x.current;let z=null;if(U&&ue&&!je&&d&&(re==null?void 0:re.sourceItemId)===d){const X=nl(U,re.sourceIndex),xe=X==null?void 0:X.closest(".local-media-link-group");xe&&(z=document.createElement("span"),z.className="turn-image-gallery-inline-action-host",xe.append(z))}return y(z),()=>z==null?void 0:z.remove()},[re,d,ue,je]),s.jsxs("div",{ref:b,className:`${Pn.root} text-block text-block-assistant timeline-item${n?" streaming":""}`,"data-turn-image-source-id":d,children:[u?s.jsx("span",{className:Pn.timelineAction,children:u}):null,a?s.jsx(bd,{alwaysShowQuoteCircle:l,contentRef:x,layoutKey:We,onQuoteBlock:a,paragraphQuoteCirclesEnabled:c&&!je,sourceRef:x,surfaceRef:b}):null,s.jsxs("div",{className:"text-block-actions",children:[He&&s.jsx("button",{type:"button",className:`text-block-toggle ${ue?"is-rendered":""}`,onClick:Fe,title:ue?"Show source":"Show rendered","aria-label":ue?"Show source":"Show rendered","aria-pressed":ue,children:s.jsx(ka,{})}),s.jsx("button",{type:"button",className:`text-block-copy ${h?"copied":""}`,onClick:K,title:h?"Copied!":"Copy markdown","aria-label":h?"Copied!":"Copy markdown",children:h?s.jsx(Lf,{}):s.jsx($f,{})})]}),s.jsxs("div",{ref:x,className:`text-block-content ${vd}`,onClick:Ce,onContextMenu:ae,children:[Oe&&s.jsxs("div",{style:je&&ue?void 0:{display:"none"},children:[s.jsx("div",{ref:T.containerRef,className:"streaming-blocks"}),s.jsx("span",{ref:T.pendingRef,className:"streaming-pending"})]}),!je&&(ue&&o?s.jsx(Yo,{artifact:v,html:o,projectId:k,projectPathLinks:i,publicShare:j}):ue&&_.changed?s.jsx(Yo,{artifact:v,className:"text-block-local-rendered",html:_.html,projectId:k,projectPathLinks:i,publicShare:j}):s.jsx("pre",{className:`${Pn.source} text-block-source`,children:s.jsx("code",{children:t})})),r&&s.jsxs("span",{className:`${Pn.abortedMidStream} text-block-aborted-mid-stream`,title:f("textBlockAbortedMidStreamTitle"),children:[s.jsx("span",{"aria-hidden":"true",children:"⨯"}),f("textBlockAbortedMidStream")]})]}),p?br.createPortal(s.jsxs("button",{type:"button",className:"turn-image-gallery-inline-action","aria-expanded":Te,"aria-label":f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),title:f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),onClick:U=>{U.preventDefault(),U.stopPropagation(),Te?O==null||O.collapse():O==null||O.show()},children:[s.jsx("span",{"aria-hidden":"true",children:Te?"−":"+"}),f("turnImageGalleryShow")]}),p):null,V&&s.jsx(qt,{path:V.path,mediaType:V.mediaType,onClose:Pe}),G&&s.jsx(Sa,{resource:G.resource,initialPresentation:G.initialPresentation,onClose:se}),W&&s.jsx(Ca,{projectId:W.projectId,filePath:W.filePath,lineNumber:W.lineNumber,lineEnd:W.lineEnd,initialPresentation:W.initialPresentation,onClose:Se}),F]})});function $f(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"9",height:"9",rx:"1.5"}),s.jsx("path",{d:"M11 5V3.5A1.5 1.5 0 0 0 9.5 2H3.5A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5"})]})}function Lf(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5L6.5 12L13 4"})})}const Af=/^(?:-{2,}\s*)?\((?:\d+\w* (?:ago|later)(?:, had seen: "[^"\n]*")?|had seen: "[^"\n]*")\)\s*/,Ff=/^\[sent [^\]\n]+\]\s*/,Bf=/\s*\[sent [^\]\n]+\]\s*$/;function Df(e){return e.replace(Af,"").replace(Ff,"").replace(Bf,"")}function Jo(e){var i;const t=e.trim(),n=t.match(/^(\d+(?:\.\d+)?)\s*([KMGT]?B)$/i);if(!n)return t;const r=Number(n[1]);if(!Number.isFinite(r))return t;const o=(n[2]??"").toUpperCase();return o==="B"?`${Math.round(r)} b`:o==="KB"?`${Math.round(r)} kb`:`${Math.round(r*10)/10} ${((i=o[0])==null?void 0:i.toLowerCase())??""}b`}const Dr=lu;function Of(e){const t=[],n=[`
14
+ `),x={markers:[],outputBoundaries:[]},b=[];let _=0;for(const N of g){x.outputBoundaries.push(_);const v=or(N,h.cursor,!0,u.status==="pending",l,n);x.parent=v.parent,v.view&&(x.view=v.view),x.markers.push(...v.markers.map(j=>({...j,start:j.start+_,end:j.end+_})));for(const j of v.visibleRanges??[{start:0,end:N.length}])b.push({start:j.start+_,end:j.end+_});_+N.length<y.length&&b.push({start:_+N.length,end:_+N.length+1}),_+=N.length+1}x.view&&(x.visibleRanges=b),x.view&&y!==u.toolResult.content&&(x.outputText=y),o.set(u,x)}}else{const h=l.cursor;i.set(u,{cursor:h,turn:a}),h!=null&&h.path&&o.set(u,{markers:[],parent:{path:h.path,title:Ot(h).title}})}}return t.map(c=>{const d=o.get(c);return d&&(d.markers.length||d.parent||d.view||d.toolContext)?{...c,workflow:d}:c})}function Ym(e,t,n){const r=Zu(e,t,n),o=t!=null&&t.workflowTags?Xm(e,r,t.workflowSchemaFiles):r,i=Lu(o),a=Yu(i),l=Om(a),c=Um(l),d=Dm(c),u=Hm(d);return Cm(u)}const Jm={onAssistantMessage(e){console.log("[preprocessMessages] Processing assistant message:",e)}};function Ar(e,t){const n=typeof window<"u"&&window.__STREAMING_DEBUG__?Jm:void 0;return Ym(e,t,n)}function Qa(e,t){return Yd(Ar(e,t))}function z_(e,t,n=!1){return n?Qa(e,t):Ar(e,t)}function Fr(e,t,n=!1){return Eu(e,t,n?Qa:Ar)}function q_(e){var n;const t=Fr(e);for(let r=t.length-1;r>=0;r-=1){const o=((n=t[r])==null?void 0:n.sourceMessages)??[];for(let i=o.length-1;i>=0;i-=1){const a=o[i],l=(a==null?void 0:a.uuid)??(a==null?void 0:a.id);if(l)return l}}return""}function Qm(e,t,n=!1){if(t.length===0)return e;const r=t.flatMap((i,a)=>{var c;if(i.placementAfterMessageId==="")return[{itemIndex:-1,object:i,order:a}];let l=Number.NEGATIVE_INFINITY;for(let d=0;d<e.length;d+=1){const u=e[d];u!=null&&u.sourceMessages.some(f=>(f.uuid??f.id)===i.placementAfterMessageId)&&(l=d)}if(l===Number.NEGATIVE_INFINITY&&n&&i.kind==="bang-command"){const d=nn(i.createdAt);if(d!==null)for(let u=0;u<e.length;u+=1){const f=ya(((c=e[u])==null?void 0:c.sourceMessages)??[]);f!==null&&f<=d&&(l=u)}}return l===Number.NEGATIVE_INFINITY?[]:[{itemIndex:l,object:i,order:a}]});if(r.sort((i,a)=>a.itemIndex-i.itemIndex||a.order-i.order),r.length===0)return e;const o=[...e];for(const i of r)o.splice(i.itemIndex+1,0,{type:"transcript_display_object",id:i.object.id,object:i.object,sourceMessages:[]});return o}const Za=m.createContext(null);function K_({children:e}){const t=m.useRef(null),n=m.useRef(null),r=m.useCallback(u=>(typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] Handler registered","color: #2196F3",{hadPreviousHandler:!!t.current}),t.current=u,()=>{t.current===u&&(typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] Handler unregistered","color: #FF5722"),t.current=null)}),[]),o=m.useCallback(u=>{n.current=u},[]),i=m.useCallback(u=>{var f;typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] dispatchAugment called","color: #4CAF50",{hasHandler:!!t.current,augment:{blockIndex:u.blockIndex,type:u.type}}),(f=t.current)==null||f.onAugment(u)},[]),a=m.useCallback(u=>{var f;typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] dispatchPending called","color: #FF9800",{hasHandler:!!t.current,htmlLength:u.html.length}),(f=t.current)==null||f.onPending(u)},[]),l=m.useCallback(()=>{var u;(u=t.current)==null||u.onStreamEnd(),n.current=null},[]),c=m.useCallback(()=>{var u,f;return((f=(u=t.current)==null?void 0:u.captureHtml)==null?void 0:f.call(u))??null},[]),d=m.useMemo(()=>({registerStreamingHandler:r,setCurrentMessageId:o,dispatchAugment:i,dispatchPending:a,dispatchStreamEnd:l,captureStreamingHtml:c}),[r,o,i,a,l,c]);return s.jsx(Za.Provider,{value:d,children:e})}function Zm(){return m.useContext(Za)}const Ts=100,ef=750,qo=16,tf=20;function Rn(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Re(e,t,n){if(typeof window<"u"&&window.__STREAMING_DEBUG__){const r={augment:"[AUGMENT]",pending:"[PENDING]",event:"[EVENT]",dom:"[DOM]"}[e],o=n?` ${JSON.stringify(n)}`:"";console.log(`%c${r} ${t}${o}`,nf(e))}}function nf(e){return{augment:"color: #4caf50; font-weight: bold",pending:"color: #ff9800; font-weight: bold",event:"color: #2196f3; font-weight: bold",dom:"color: #9c27b0; font-weight: bold"}[e]||""}function sf(e={}){const t=m.useRef(null),n=m.useRef(null),[r,o]=m.useState(!1),i=m.useRef(e.transformHtml);i.current=e.transformHtml;const a=m.useRef(new Map),l=m.useRef(new Map),c=m.useRef(""),d=m.useRef(-1),u=m.useRef(new Map),f=m.useRef(null),h=m.useRef(null),g=m.useRef(Number.NEGATIVE_INFINITY),p=m.useRef(Ts),y=m.useRef(0),x=m.useCallback(()=>{o(T=>T||!0)},[]),b=m.useCallback(T=>{var G;const E=t.current;if(Re("augment","Received augment",{blockIndex:T.blockIndex,type:T.type,htmlLength:T.html.length,htmlPreview:T.html.substring(0,100)}),!E){Re("augment","ERROR: containerRef.current is null - refs not attached!");return}x();const{blockIndex:R,html:D}=T;l.current.set(R,T);const K=((G=i.current)==null?void 0:G.call(i,D))??D;if(a.current.has(R)){const W=a.current.get(R);W&&(Re("dom","Updating existing block",{blockIndex:R}),W.innerHTML=K);return}const V=document.createElement("div");if(V.className="streaming-block",V.dataset.blockIndex=String(R),V.innerHTML=K,Re("dom","Created new block element",{blockIndex:R,className:V.className}),R>d.current)E.appendChild(V),d.current=R,Re("dom","Appended block to end",{blockIndex:R,maxBlockIndex:d.current});else{let W=!1;const ie=E.children;for(let ae=0;ae<ie.length;ae++){const Pe=ie[ae],se=Number.parseInt(Pe.dataset.blockIndex??"-1",10);if(se>R){E.insertBefore(V,Pe),W=!0,Re("dom","Inserted block before",{blockIndex:R,beforeIndex:se});break}}W||(E.appendChild(V),Re("dom","Appended out-of-order block to end",{blockIndex:R}))}a.current.set(R,V),Re("dom","Block tracking updated",{totalBlocks:a.current.size})},[x]),_=m.useCallback(T=>{var R;const E=n.current;if(Re("pending","Received pending update",{htmlLength:T.html.length,htmlPreview:T.html.substring(0,80)}),!E){Re("pending","ERROR: pendingRef.current is null - refs not attached!");return}x(),c.current=T.html,E.innerHTML=((R=i.current)==null?void 0:R.call(i,T.html))??T.html,Re("pending","Updated pending element innerHTML")},[x]),N=m.useCallback(()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},[]),v=m.useCallback(()=>{N();const T=u.current,E=f.current;if(T.size===0&&E===null){y.current=0;return}const R=[...T.values()].sort((G,W)=>G.blockIndex-W.blockIndex),D=y.current;T.clear(),f.current=null,y.current=0;const K=Rn();for(const G of R)b(G);E!==null&&_({html:E});const V=Rn()-K;Cs()&&(Cn("streaming-markdown.flush",{durationMs:V}),Cn("streaming-markdown.flushed-event",{count:D,category:R.length>0&&E!==null?"augment-and-pending":R.length>0?"augment":"pending"})),V>qo||D>tf?p.current=Math.min(ef,Math.max(200,Math.ceil(p.current*1.5))):V<qo/2&&D<=6&&(p.current=Math.max(Ts,Math.floor(p.current*.8))),g.current=Rn()},[b,_,N]),j=m.useCallback(()=>{if(h.current!==null)return;const E=Rn()-g.current,R=p.current;if(E>=R){v();return}h.current=setTimeout(v,R-E)},[v]),C=m.useCallback(T=>{Cs()&&Cn("streaming-markdown.event",{category:"augment",chars:T.html.length}),u.current.set(T.blockIndex,T),y.current+=1,j()},[j]),w=m.useCallback(T=>{Cs()&&Cn("streaming-markdown.event",{category:"pending",chars:T.html.length}),f.current=T.html,y.current+=1,j()},[j]),k=m.useCallback(()=>{Re("event","Stream ended"),v();const T=n.current;c.current="",T&&(T.innerHTML="",Re("event","Cleared pending element")),o(!1),Re("event","Set isStreaming to false")},[v]),S=m.useCallback(()=>{Re("event","Reset called"),N(),u.current.clear(),f.current=null,l.current.clear(),c.current="",y.current=0,p.current=Ts;const T=t.current,E=n.current;T&&(T.innerHTML="",Re("event","Cleared container")),E&&(E.innerHTML="",Re("event","Cleared pending element"));const R=a.current.size;a.current.clear(),d.current=-1,o(!1),Re("event","Reset complete",{previousBlockCount:R,maxBlockIndexReset:!0})},[N]),$=m.useCallback(()=>{if(v(),!t.current)return null;const T=document.createElement("div");for(const R of[...l.current.values()].sort((D,K)=>D.blockIndex-K.blockIndex)){const D=document.createElement("div");D.className="streaming-block",D.dataset.blockIndex=String(R.blockIndex),D.innerHTML=R.html,T.append(D)}const E=T.innerHTML;return Re("event","Captured HTML",{length:E.length}),E||null},[v]);return m.useEffect(()=>{var E,R;for(const[D,K]of a.current){const V=l.current.get(D);V&&(K.innerHTML=((E=e.transformHtml)==null?void 0:E.call(e,V.html))??V.html)}const T=n.current;T&&c.current&&(T.innerHTML=((R=e.transformHtml)==null?void 0:R.call(e,c.current))??c.current)},[e.transformHtml]),m.useEffect(()=>()=>{N()},[N]),{containerRef:t,pendingRef:n,isStreaming:r,onAugment:C,onPending:w,onStreamEnd:k,reset:S,captureHtml:$}}function Ko(e,t,n,r){if(r){const o=dd(r,{filePath:n});if(!o)return!1;e.setAttribute("href",o),e.dataset.publicShareFileLink="true"}else{const o=new URLSearchParams({path:n});e.setAttribute("href",`/projects/${encodeURIComponent(t)}/file?${o}`),e.dataset.yaPrivateProjectFileLink="true"}return e.dataset.yaResource="project-file",e.dataset.yaProjectId=t,e.dataset.yaPath=n,e.title=`${n}
15
+ Click to view, or use a browser link gesture to open this file`,!0}function el(e,t,n,r){var u,f;if(!e||!(t!=null&&t.length)||!n||typeof document>"u")return{changed:!1,html:e};const o=new Map(t.map(h=>[h.text,h.filePath])),i=document.createElement("template");i.innerHTML=e;let a=!1;for(const h of i.content.querySelectorAll('a[data-ya-resource="project-file"]')){const g=o.get(((u=h.textContent)==null?void 0:u.trim())??"");g&&Ko(h,n,g,r)&&(a=!0)}const l=document.createTreeWalker(i.content,NodeFilter.SHOW_TEXT),c=[];let d=l.nextNode();for(;d;)d instanceof Text&&!((f=d.parentElement)!=null&&f.closest("a,button,script,style,textarea"))&&c.push(d),d=l.nextNode();for(const h of c){const g=Na(h.data).filter(p=>o.has(p.text));for(let p=g.length-1;p>=0;p-=1){const y=g[p];if(!y)continue;const x=document.createElement("a");if(!Ko(x,n,o.get(y.text),r))continue;h.splitText(y.end);const b=h.splitText(y.start);b.replaceWith(x),x.append(b),a=!0}}return{changed:a,html:a?i.innerHTML:e}}const ar='a.local-media-link[data-media-type="image"], a.local-media-link[data-ya-media-type="image"]';function tl(e,t){return`${e}:inline-image:${t}`}function Br(e){return Array.from(e.querySelectorAll(ar))}function rf(e){var n,r;const t=e.getAttribute("data-ya-path")??((r=(n=e.closest(".local-media-link-group"))==null?void 0:n.querySelector("[data-media-path]"))==null?void 0:r.getAttribute("data-media-path"));if(t)return t;try{return new URL(e.href,window.location.href).searchParams.get("path")}catch{return null}}function of(e,t){var r,o;const n=e.cloneNode(!0);return(r=n.querySelector(".local-media-type"))==null||r.remove(),((o=n.textContent)==null?void 0:o.trim())||tt(t)}function af(e,t){if(!e.augmentHtml||typeof document>"u")return[];const n=document.createElement("template");n.innerHTML=e.augmentHtml;const r=[];for(const[o,i]of Br(n.content).entries()){const a=rf(i);a&&r.push({basename:tt(a),id:tl(e.id,o),label:of(i,a),originalIndex:t+r.length,path:a,sourceIndex:o,sourceItemId:e.id})}return r}function lf(e){const t=[];for(const n of e)n.type==="text"&&t.push(...af(n,t.length));return t}function Xo(e,t,n){var a;if(!(n instanceof Element))return null;const r=n.closest(`${ar}, button.local-media-inline-toggle[data-media-type="image"]`);if(!r||!e.contains(r))return null;const o=r instanceof HTMLAnchorElement?r:(a=r.closest(".local-media-link-group"))==null?void 0:a.querySelector(ar);if(!o)return null;const i=Br(e).indexOf(o);return i>=0?{id:tl(t,i),kind:r instanceof HTMLAnchorElement?"link":"toggle"}:null}function nl(e,t){return Br(e)[t]??null}function cf(e){return!e||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0?null:e}function df(e){return e?Math.max(.2,Math.min(5,e.width/e.height)):4/3}function uf(e,t,n,r,o){const i=Array.from({length:t},()=>({aspectSum:0,images:[]}));for(const c of e){let d=i[0];if(d){for(const u of i.slice(1))u.aspectSum<d.aspectSum&&(d=u);d.images.push(c),d.aspectSum+=c.aspect}}const l=Math.max(1,r-o*(t-1))/t;return i.filter(c=>c.images.length>0).map(c=>{const d=Math.max(1,n-o*(c.images.length-1)),u=Math.max(1,Math.min(l,d/c.aspectSum)),f=c.images.map(h=>{const g=h.naturalHeight===null?u:Math.min(u,h.naturalHeight);return{height:g,id:h.id,naturalHeight:h.naturalHeight,naturalWidth:h.naturalWidth,width:h.aspect*g}});return{height:Math.max(...f.map(h=>h.height)),items:f}})}function mf(e,t,n,r,o=8){if(e.length===0||n<=0||r<=0)return[];const i=e.map(d=>{const u=cf(t.get(d.id));return{...d,aspect:df(u),naturalHeight:(u==null?void 0:u.height)??null,naturalWidth:(u==null?void 0:u.width)??null}}).sort((d,u)=>u.aspect-d.aspect||d.originalIndex-u.originalIndex);let a=[],l=0;const c=Math.min(3,e.length);for(let d=1;d<=c;d+=1){const u=uf(i,d,n,r,o),f=Math.min(...u.flatMap(h=>h.items.map(g=>g.height)));f>l&&(a=u,l=f)}return a}function ff({alt:e,ariaLabel:t,buttonClassName:n,fileName:r,filePath:o,loadBlob:i,onImageLoad:a,onOpen:l,placeholderClassName:c,title:d}){const{t:u}=Z(),{url:f,error:h}=$a(o,!0,i),g=hs({fileName:r,filePath:o,loadBlob:i,onOpen:l});return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:n,"aria-label":t,title:d,onClick:l,onContextMenu:g.handleContextMenu,children:f?s.jsx("img",{src:f,alt:e,draggable:!1,onLoad:a}):s.jsx("span",{className:c,children:u(h?"inlineImageUnavailable":"inlineImageLoading")})}),g.contextMenuElement]})}const hf="_gallery_1ydih_1",pf="_rows_1ydih_9",gf="_row_1ydih_9",xf="_item_1ydih_24",yf="_featured_1ydih_38",jf="_thumbnail_1ydih_43",bf="_placeholder_1ydih_63",vf="_footer_1ydih_74",wf="_caption_1ydih_82",_f="_count_1ydih_112",Nf="_dismiss_1ydih_118",Ze={gallery:hf,rows:pf,row:gf,item:xf,featured:yf,thumbnail:jf,placeholder:bf,footer:vf,caption:wf,count:_f,dismiss:Nf},sl=m.createContext(null);function kf(){return m.useContext(sl)}function Sf(){const e=ps();return m.useMemo(()=>{if(e)return{buildApiPath:t=>ud(e,t),fetchBlob:async(t,n)=>await Td({path:n,relayUrl:e.relayUrl,relayUsername:e.relayUsername})}},[e])}function Cf({candidate:e,featured:t,mediaSource:n,onDimensions:r,onFeature:o,onOpen:i,registerElement:a,style:l}){const{t:c}=Z(),d=Kt().transport,u=m.useCallback(()=>_r(e.path,n,"inline",d),[e.path,n,d]);return s.jsx("div",{ref:f=>a(e.id,f),className:`${Ze.item}${t?` ${Ze.featured}`:""}`,"data-gallery-image-id":e.id,role:"group","aria-label":e.label,style:l,tabIndex:-1,onFocus:()=>o(e.id),onPointerEnter:()=>o(e.id),children:s.jsx(ff,{alt:e.label,ariaLabel:c("turnImageGalleryOpen",{label:e.label}),buttonClassName:Ze.thumbnail,fileName:e.basename,filePath:e.path,loadBlob:u,onImageLoad:f=>{const{naturalHeight:h,naturalWidth:g}=f.currentTarget;r(e.id,{height:h,width:g})},onOpen:()=>i(e),placeholderClassName:Ze.placeholder})})}function X_({children:e,items:t}){var xe;const{t:n}=Z(),{compactMultiImageGalleries:r,inlineMediaExpandedByDefault:o}=wr(),i=m.useMemo(()=>lf(t),[t]),a=i.map(L=>L.id).join("\0"),l=m.useMemo(()=>new Set(i.map(L=>L.id)),[i]),c=m.useMemo(()=>new Map(i.map(L=>[L.id,L])),[i]),d=m.useMemo(()=>new Map(i.map(L=>[L.id,L.label])),[i]),u=r&&i.length>=2,[f,h]=m.useState(!1),[g,p]=m.useState(!1),[y,x]=m.useState(((xe=i[0])==null?void 0:xe.id)??""),[b,_]=m.useState(null),[N,v]=m.useState(()=>new Map),[j,C]=m.useState({height:240,width:720}),w=m.useRef(null),k=m.useRef(null),S=m.useRef(new Map),$=m.useRef(null),T=m.useRef(null),E=m.useRef(null),R=m.useRef(null),D=m.useRef(null),K=m.useRef(null),V=m.useRef(y);V.current=y;const G=Sf(),W=u&&!f&&(o||g);m.useEffect(()=>{var L;l.has(y)||x(((L=i[0])==null?void 0:L.id)??"")},[l,i,y]),m.useLayoutEffect(()=>{const L=k.current;if(!L||!W)return;const B=()=>{const pe=window.innerHeight;C({height:Math.max(120,Math.min(320,pe/3-48)),width:Math.max(1,L.clientWidth)})};B();const Q=new ResizeObserver(B);return Q.observe(L),window.addEventListener("resize",B),()=>{Q.disconnect(),window.removeEventListener("resize",B)}},[W]);const ie=m.useCallback(L=>{x(L);const B=S.current.get(L);if(!B){$.current=L;return}B.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),B.focus({preventScroll:!0}),$.current=null},[]),ae=m.useCallback(L=>{l.has(L)&&($.current=L,x(L),p(!0),h(!1),W&&ie(L))},[l,ie,W]),Pe=m.useCallback(()=>{h(!0),p(!1)},[]),se=m.useCallback(()=>{var B;if(!u)return;const L=l.has(V.current)?V.current:(B=i[0])==null?void 0:B.id;L&&($.current=L,x(L)),p(!0),h(!1)},[l,i,u]);m.useLayoutEffect(()=>{W&&$.current&&ie($.current)},[ie,W]);const Se=m.useCallback(L=>{const B=w.current;if(!B)return null;const Q=Array.from(B.querySelectorAll("[data-turn-image-source-id]")).find(ye=>ye.dataset.turnImageSourceId===L.sourceItemId);return Q?nl(Q,L.sourceIndex):null},[]),F=m.useCallback(L=>{const B=Se(L);B&&(B.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),B.focus({preventScroll:!0}))},[Se]),O=m.useCallback((L,B)=>{D.current=B,K.current=B==="source"?L.id:null,x(L.id),_(L)},[]),Ce=m.useCallback(L=>{const B=c.get(L);B&&O(B,"source")},[c,O]),je=m.useCallback(L=>{if(!b||i.length<2)return;const B=i.findIndex(ye=>ye.id===b.id);if(B<0)return;const Q=(B+L+i.length)%i.length,pe=i[Q];pe&&(x(pe.id),_(pe))},[i,b]),He=m.useCallback(()=>{const L=(b==null?void 0:b.id)??null,B=D.current,Q=K.current;D.current=null,K.current=null,_(null),requestAnimationFrame(()=>{var pe;if(B==="gallery"&&L&&W){ie(L);return}if(Q){const ye=c.get(Q);ye&&((pe=Se(ye))==null||pe.focus({preventScroll:!0}))}})},[c,ie,Se,W,b]),ue=b?i.findIndex(L=>L.id===b.id):-1,Fe=ue>=0&&i.length>1?{count:i.length,current:ue+1,onNext:()=>je(1),onPrevious:()=>je(-1)}:void 0,Oe=m.useMemo(()=>mf(i,N,j.width,j.height),[i,N,j]),We=m.useMemo(()=>new Map(Oe.flatMap(L=>L.items.map(B=>[B.id,{"--turn-gallery-item-height":`${B.height}px`,"--turn-gallery-item-width":`${B.width}px`,...B.naturalHeight===null?{}:{"--turn-gallery-natural-height":`${B.naturalHeight}px`},...B.naturalWidth===null?{}:{"--turn-gallery-natural-width":`${B.naturalWidth}px`}}]))),[Oe]),re=i.find(L=>L.id===y)??i[0],Te=u?i[i.length-1]??null:null,A=m.useMemo(()=>({actionTarget:Te,active:W,activate:ae,available:u,candidateLabels:d,candidateIds:l,collapse:Pe,openImage:Ce,show:se}),[Te,ae,d,l,Pe,u,W,Ce,se]),U=m.useCallback(()=>{T.current=null;const L=k.current;if(!L)return;const B=L.getBoundingClientRect().left+L.clientWidth/2;let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.abs(me.left+me.width/2-B);(!Q||Be<Q.distance)&&(Q={distance:Be,id:pe})}Q&&x(Q.id)},[]),z=m.useCallback((L,B)=>{let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.max(me.left-L,0,L-me.right),rt=Math.max(me.top-B,0,B-me.bottom),Je=Be*Be+rt*rt,gt=me.left+me.width/2,$t=me.top+me.height/2,qe=(gt-L)**2+($t-B)**2;(!Q||Je<Q.edgeDistance||Je===Q.edgeDistance&&qe<Q.centerDistance)&&(Q={centerDistance:qe,edgeDistance:Je,id:pe})}Q&&x(Q.id)},[]),X=m.useCallback((L,B)=>{R.current={clientX:L,clientY:B},E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null;const Q=R.current;Q&&z(Q.clientX,Q.clientY)}))},[z]);return m.useEffect(()=>{if(!W||b)return;const L=B=>{B.pointerType!=="touch"&&X(B.clientX,B.clientY)};return window.addEventListener("pointermove",L,{passive:!0}),()=>window.removeEventListener("pointermove",L)},[W,X,b]),m.useEffect(()=>()=>{T.current!==null&&cancelAnimationFrame(T.current),E.current!==null&&cancelAnimationFrame(E.current)},[]),s.jsx(sl.Provider,{value:A,children:s.jsxs("div",{ref:w,className:`assistant-turn${W?" has-turn-image-gallery":""}`,children:[e,W?s.jsxs("section",{className:Ze.gallery,"aria-label":n("turnImageGalleryLabel"),onKeyDown:L=>{L.key==="Escape"&&(L.preventDefault(),Pe())},children:[s.jsx("div",{ref:k,className:Ze.rows,style:{"--turn-gallery-max-height":`${j.height}px`},onScroll:()=>{T.current===null&&(T.current=requestAnimationFrame(U))},children:Oe.map((L,B)=>s.jsx("div",{className:Ze.row,style:{height:L.height},children:L.items.map(Q=>{const pe=i.find(ye=>ye.id===Q.id);return pe?s.jsx(Cf,{candidate:pe,featured:pe.id===(re==null?void 0:re.id),mediaSource:G,onDimensions:(ye,me)=>{v(Be=>{const rt=Be.get(ye);if((rt==null?void 0:rt.width)===me.width&&rt.height===me.height)return Be;const Je=new Map(Be);return Je.set(ye,me),Je})},onFeature:x,onOpen:ye=>O(ye,"gallery"),registerElement:(ye,me)=>{me?S.current.set(ye,me):S.current.delete(ye)},style:We.get(pe.id)??{}},pe.id):null})},`${a}:row:${B}`))}),s.jsxs("div",{className:Ze.footer,children:[re?s.jsxs("button",{type:"button",className:Ze.caption,onClick:()=>F(re),children:[s.jsx("span",{children:re.label}),re.basename!==re.label?s.jsx("small",{children:re.basename}):null]}):null,s.jsx("span",{className:Ze.count,children:n("turnImageGalleryCount",{count:i.length,current:Math.max(1,i.findIndex(L=>L.id===(re==null?void 0:re.id))+1)})}),s.jsx("button",{type:"button",className:Ze.dismiss,"aria-keyshortcuts":"Escape",onClick:Pe,children:n("turnImageGalleryCollapse")})]})]}):null,b?s.jsx(qt,{path:b.path,mediaType:"image",mediaSource:G,imageNavigation:Fe,onClose:He}):null]})})}const Tf="_root_13m0q_1",Rf="_source_13m0q_11",Pf="_timelineAction_13m0q_46",Ef="_abortedMidStream_13m0q_57",Pn={root:Tf,source:Rf,timelineAction:Pf,abortedMidStream:Ef},If={html:"",changed:!1};function Mf(e){if(typeof document>"u")return e;const t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}const Yo=m.memo(function({artifact:t,className:n,html:r,projectId:o,projectPathLinks:i,publicShare:a}){const l=Nr(),c=m.useMemo(()=>{const d=el(r,i,o,a).html,u=Er(d,t).html;return kr(u,l)},[t,r,o,i,a,l]);return s.jsx("div",{className:n,dangerouslySetInnerHTML:{__html:c}})}),Qn=m.memo(function({text:t,isStreaming:n=!1,abortedMidStream:r=!1,augmentHtml:o,projectPathLinks:i,onQuoteBlock:a,alwaysShowQuoteCircle:l=!1,paragraphQuoteCirclesEnabled:c=!0,renderItemId:d,timelineAction:u}){var A;const{t:f}=Z(),[h,g]=m.useState(!1),[p,y]=m.useState(null),x=m.useRef(null),b=m.useRef(null),_=m.useMemo(()=>n?If:ka(t),[n,t]),N=Sa(),v=N.state==="ready"&&((A=N.result)==null?void 0:A.status)==="ready"?N.result.artifact:void 0,j=ps(),C=Nr(),w=ge(),k=(w==null?void 0:w.projectId)??(j==null?void 0:j.projectId)??void 0,S=m.useCallback(U=>{const z=el(U,i,k,j).html,X=Er(z,v).html;return kr(X,C)},[v,k,i,j,C]),$=m.useMemo(()=>o?Mf(o).trim()!==t.trim():!1,[o,t]),T=sf({transformHtml:S}),E=Zm(),[R,D]=m.useState(!1);m.useEffect(()=>{if(!n||!E){n||(D(!1),T.reset());return}return E.registerStreamingHandler({onAugment:z=>{D(X=>X||!0),T.onAugment(z)},onPending:T.onPending,onStreamEnd:T.onStreamEnd,captureHtml:T.captureHtml})},[n,E,T.captureHtml,T.onAugment,T.onPending,T.onStreamEnd,T.reset]);const K=m.useCallback(async()=>{try{await navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),3e3)}catch(U){console.error("Failed to copy text:",U)}},[t]);m.useEffect(()=>{const U=x.current;if(U)return eu(U,t)},[t]);const{modal:V,localFileModal:G,projectFileModal:W,handleClick:ie,handleContextMenu:ae,closeModal:Pe,closeLocalFileModal:se,closeProjectFileModal:Se,contextMenuElement:F}=ja(),O=kf();md(x,void 0,void 0,{suppressAutomaticImages:(O==null?void 0:O.available)===!0}),Rd(x);const Ce=m.useCallback(U=>{const z=x.current,X=z&&d&&(O!=null&&O.available)?Xo(z,d,U.target):null;if(X&&(O!=null&&O.candidateIds.has(X.id))){U.preventDefault(),U.stopPropagation(),X.kind==="link"?O.openImage(X.id):O.active?O.collapse():O.activate(X.id);return}ie(U)},[ie,d,O]),je=n&&R,He=$||_.changed,{showRendered:ue,toggleLocalMode:Fe}=Pd(He,{participateInGlobalMode:!1,resetDependencies:[n,n?"":t,o??""]}),Oe=n,We=[ue,t,o??""].join("\0"),re=(O==null?void 0:O.actionTarget)??null,Te=(O==null?void 0:O.active)===!0;return m.useEffect(()=>{const U=x.current;if(!U||!ue||je||!d||!(O!=null&&O.available))return;const z=U.querySelectorAll("button.local-media-inline-toggle[data-media-type='image']");for(const X of z){const xe=Xo(U,d,X);if(!xe||!O.candidateIds.has(xe.id))continue;const L=O.candidateLabels.get(xe.id)??"",B=Te?f("turnImageGalleryCollapse"):f("turnImageGalleryExpandAt",{label:L});X.dataset.expanded=String(Te),X.setAttribute("aria-expanded",String(Te)),X.setAttribute("aria-label",B),X.title=B,X.textContent=Te?"−":"+"}},[Te,d,ue,je,f,O]),m.useLayoutEffect(()=>{const U=x.current;let z=null;if(U&&ue&&!je&&d&&(re==null?void 0:re.sourceItemId)===d){const X=nl(U,re.sourceIndex),xe=X==null?void 0:X.closest(".local-media-link-group");xe&&(z=document.createElement("span"),z.className="turn-image-gallery-inline-action-host",xe.append(z))}return y(z),()=>z==null?void 0:z.remove()},[re,d,ue,je]),s.jsxs("div",{ref:b,className:`${Pn.root} text-block text-block-assistant timeline-item${n?" streaming":""}`,"data-turn-image-source-id":d,children:[u?s.jsx("span",{className:Pn.timelineAction,children:u}):null,a?s.jsx(Ed,{alwaysShowQuoteCircle:l,contentRef:x,layoutKey:We,onQuoteBlock:a,paragraphQuoteCirclesEnabled:c&&!je,sourceRef:x,surfaceRef:b}):null,s.jsxs("div",{className:"text-block-actions",children:[He&&s.jsx("button",{type:"button",className:`text-block-toggle ${ue?"is-rendered":""}`,onClick:Fe,title:ue?"Show source":"Show rendered","aria-label":ue?"Show source":"Show rendered","aria-pressed":ue,children:s.jsx(Ca,{})}),s.jsx("button",{type:"button",className:`text-block-copy ${h?"copied":""}`,onClick:K,title:h?"Copied!":"Copy markdown","aria-label":h?"Copied!":"Copy markdown",children:h?s.jsx(Lf,{}):s.jsx($f,{})})]}),s.jsxs("div",{ref:x,className:`text-block-content ${Id}`,onClick:Ce,onContextMenu:ae,children:[Oe&&s.jsxs("div",{style:je&&ue?void 0:{display:"none"},children:[s.jsx("div",{ref:T.containerRef,className:"streaming-blocks"}),s.jsx("span",{ref:T.pendingRef,className:"streaming-pending"})]}),!je&&(ue&&o?s.jsx(Yo,{artifact:v,html:o,projectId:k,projectPathLinks:i,publicShare:j}):ue&&_.changed?s.jsx(Yo,{artifact:v,className:"text-block-local-rendered",html:_.html,projectId:k,projectPathLinks:i,publicShare:j}):s.jsx("pre",{className:`${Pn.source} text-block-source`,children:s.jsx("code",{children:t})})),r&&s.jsxs("span",{className:`${Pn.abortedMidStream} text-block-aborted-mid-stream`,title:f("textBlockAbortedMidStreamTitle"),children:[s.jsx("span",{"aria-hidden":"true",children:"⨯"}),f("textBlockAbortedMidStream")]})]}),p?br.createPortal(s.jsxs("button",{type:"button",className:"turn-image-gallery-inline-action","aria-expanded":Te,"aria-label":f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),title:f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),onClick:U=>{U.preventDefault(),U.stopPropagation(),Te?O==null||O.collapse():O==null||O.show()},children:[s.jsx("span",{"aria-hidden":"true",children:Te?"−":"+"}),f("turnImageGalleryShow")]}),p):null,V&&s.jsx(qt,{path:V.path,mediaType:V.mediaType,onClose:Pe}),G&&s.jsx(ba,{resource:G.resource,initialPresentation:G.initialPresentation,onClose:se}),W&&s.jsx(Ta,{projectId:W.projectId,filePath:W.filePath,lineNumber:W.lineNumber,lineEnd:W.lineEnd,initialPresentation:W.initialPresentation,onClose:Se}),F]})});function $f(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"9",height:"9",rx:"1.5"}),s.jsx("path",{d:"M11 5V3.5A1.5 1.5 0 0 0 9.5 2H3.5A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5"})]})}function Lf(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5L6.5 12L13 4"})})}const Af=/^(?:-{2,}\s*)?\((?:\d+\w* (?:ago|later)(?:, had seen: "[^"\n]*")?|had seen: "[^"\n]*")\)\s*/,Ff=/^\[sent [^\]\n]+\]\s*/,Bf=/\s*\[sent [^\]\n]+\]\s*$/;function Df(e){return e.replace(Af,"").replace(Ff,"").replace(Bf,"")}function Jo(e){var i;const t=e.trim(),n=t.match(/^(\d+(?:\.\d+)?)\s*([KMGT]?B)$/i);if(!n)return t;const r=Number(n[1]);if(!Number.isFinite(r))return t;const o=(n[2]??"").toUpperCase();return o==="B"?`${Math.round(r)} b`:o==="KB"?`${Math.round(r)} kb`:`${Math.round(r*10)/10} ${((i=o[0])==null?void 0:i.toLowerCase())??""}b`}const Dr=lu;function Of(e){const t=[],n=[`
16
16
 
17
17
  User uploaded files in .attachments:
18
18
  `,`
19
19
 
20
20
  User uploaded files:
21
21
  `],r=n.map(d=>e.indexOf(d)).filter(d=>d!==-1).sort((d,u)=>d-u)[0];if(r===void 0)return{textWithoutUploads:e,uploadedFiles:[]};const o=n.find(d=>e.startsWith(d,r));if(!o)return{textWithoutUploads:e,uploadedFiles:[]};const i=e.slice(0,r),a=e.slice(r+o.length),l=/^- \[(.+?)\]\((?:<(.+?)>|(.+?))\) \(([^,]+), ([^,()]+?)(?:, (\d+)x(\d+))?\)$/,c=/^- (.+?) \(([^,]+), ([^)]+)\): (.+)$/;for(const d of a.split(`
22
- `)){const u=d.match(l);if(u){t.push({originalName:u[1]??"",path:u[2]??u[3]??"",size:Jo(u[4]??""),mimeType:u[5]??"",width:u[6]?Number(u[6]):void 0,height:u[7]?Number(u[7]):void 0});continue}const f=d.match(c);f&&t.push({originalName:f[1]??"",size:Jo(f[2]??""),mimeType:f[3]??"",path:f[4]??""})}return{textWithoutUploads:i,uploadedFiles:t}}function Qo(e){const t=Df(e),{textWithoutUploads:n,uploadedFiles:r}=Of(t);return{text:ou(n),openedFiles:au(n),uploadedFiles:r}}const Uf=new Map,Hf=new Set,rl=m.createContext({turnIndexById:Uf,expandedRewoundGroups:Hf,toggleRewoundGroup:()=>{}}),K_=rl.Provider;function ol(){return m.useContext(rl)}const Wf="_wrapper_q492x_1",Vf="_menu_q492x_5",Gf="_secondary_q492x_42",zf="_rewind_q492x_48",en={wrapper:Wf,menu:Vf,secondary:Gf,rewind:zf},qf=40;function Kf({messageId:e,onForkBefore:t,onForkAfter:n,onForkAfterSummary:r,afterDisabled:o=!1,unavailableMessage:i}){const{t:a}=Z(),l=ol(),[c,d]=m.useState(!1),[u,f]=m.useState({top:0,right:8}),h=m.useRef(null),g=m.useRef(null),p=e?l.turnIndexById.get(e):void 0,y=e&&l.onClearAfter&&!i?()=>{var j;return(j=l.onClearAfter)==null?void 0:j.call(l,e)}:void 0,x=e&&l.onClearReplacing&&!i?()=>{var j;return(j=l.onClearReplacing)==null?void 0:j.call(l,e)}:void 0;m.useEffect(()=>{if(!c)return;const j=w=>{var S,$;const k=w.target;!((S=h.current)!=null&&S.contains(k))&&!(($=g.current)!=null&&$.contains(k))&&d(!1)},C=w=>{var k;w.key==="Escape"&&(d(!1),(k=h.current)==null||k.focus())};return document.addEventListener("mousedown",j),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",C)}},[c]);const b=()=>{var C;const j=(C=h.current)==null?void 0:C.getBoundingClientRect();if(j){const w=+!!t+ +!!n+ +!!r+ +!!y+ +!!x,k=Math.max(1,w)*qf+12,S=j.bottom+8+k<=window.innerHeight?j.bottom+8:Math.max(8,j.top-k-8);f({top:S,right:Math.max(8,window.innerWidth-j.right)})}d(!0)},_=j=>{d(!1),j()},N=p!==void 0?a("forkTurnMenuLabelIndexed",{index:String(p)}):a("forkTurnMenuLabel"),v=s.jsxs("div",{ref:g,className:en.menu,role:"menu",style:{"--fork-turn-menu-top":`${u.top}px`,"--fork-turn-menu-right":`${u.right}px`},"aria-label":N,children:[i?s.jsx("button",{type:"button",role:"menuitem",disabled:!0,children:i}):null,!i&&t&&s.jsx("button",{type:"button",role:"menuitem",onClick:()=>_(t),children:a("forkTurnBefore")}),!i&&n&&s.jsx("button",{type:"button",role:"menuitem",disabled:o,title:o?a("forkTurnAfterDisabled"):void 0,onClick:()=>_(n),children:a("forkTurnAfter")}),!i&&r&&s.jsx("button",{type:"button",role:"menuitem",className:en.secondary,disabled:o,title:o?a("forkTurnAfterDisabled"):void 0,onClick:()=>_(r),children:a("forkTurnAfterSummary")}),y&&s.jsx("button",{type:"button",role:"menuitem",className:en.rewind,disabled:o,title:o?a("forkTurnAfterDisabled"):a("rewindClearAfterTurnTooltip",{index:String(p??"")}),onClick:()=>_(y),children:a("rewindClearAfterTurn")}),x&&s.jsx("button",{type:"button",role:"menuitem",className:en.rewind,disabled:o,title:a(o?"forkTurnAfterDisabled":"rewindClearReplacingTurnTooltip"),onClick:()=>_(x),children:a("rewindClearReplacingTurn")})]});return s.jsxs("div",{className:en.wrapper,children:[s.jsx("button",{ref:h,type:"button",className:"user-prompt-action",onClick:()=>c?d(!1):b(),"aria-label":N,title:i??N,"aria-haspopup":"menu","aria-expanded":c,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"18",r:"3"}),s.jsx("circle",{cx:"18",cy:"12",r:"3"}),s.jsx("path",{d:"M6 9v6"}),s.jsx("path",{d:"M8.5 7.5 15 11"})]})}),c&&br.createPortal(v,document.body)]})}const Zo=.5;function Xf({actionCount:e,actionGap:t,actionSize:n,availableInlineSize:r,inlineEndInset:o,measurePromptBlockSize:i}){var g;if(e<=1)return{columns:1,rows:Math.max(1,e)};const l=[...new Set([1,Math.min(2,e),e])].map(p=>{const y=Math.ceil(e/p),x=p*n+Math.max(0,p-1)*t,b=Math.max(1,r-x-t-o),_=i(b),N=y*n+Math.max(0,y-1)*t;return{columns:p,rows:y,actionBlockSize:N,promptBlockSize:_,totalBlockSize:Math.max(N,_)}}),c=l.find(p=>p.actionBlockSize<=p.promptBlockSize+Zo);if(c)return{columns:c.columns,rows:c.rows};const d=((g=l[0])==null?void 0:g.promptBlockSize)??0,u=l.filter(p=>p.promptBlockSize<=d+Zo),h=(u.length>1?u:l).reduce((p,y)=>y.totalBlockSize!==p.totalBlockSize?y.totalBlockSize<p.totalBlockSize?y:p:y.promptBlockSize!==p.promptBlockSize?y.promptBlockSize<p.promptBlockSize?y:p:y.columns<p.columns?y:p);return{columns:h.columns,rows:h.rows}}function Yf(e,t){const n=Number.parseFloat(e);return Number.isFinite(n)?n:t}function ei(e){return{columns:1,rows:Math.max(1,e)}}function Jf(e,t){const n=m.useRef(null),r=m.useRef(null),o=m.useRef(null),[i,a]=m.useState(()=>ei(e)),l=m.useCallback(()=>{const c=n.current,d=r.current,u=o.current,f=u==null?void 0:u.querySelector(".user-prompt-action");if(!c||!d||!u||!f)return;const h=c.getBoundingClientRect(),g=f.getBoundingClientRect(),p=u.getBoundingClientRect();if(h.width<=0||g.width<=0)return;const y=getComputedStyle(u),x=getComputedStyle(c),b=Yf(y.columnGap,4),_=Math.max(g.width,g.height),N=Math.max(0,x.direction==="rtl"?p.left-h.left:h.right-p.right),v=document.createElement("div"),j=d.cloneNode(!0);v.setAttribute("aria-hidden","true");for(const C of j.querySelectorAll("[id]"))C.removeAttribute("id");Object.assign(v.style,{boxSizing:"border-box",contain:"layout style paint",direction:x.direction,inset:"0 auto auto 0",margin:"0",pointerEvents:"none",position:"fixed",visibility:"hidden",width:`${h.width}px`,zIndex:"-1"}),Object.assign(j.style,{margin:"0",maxHeight:"none",minWidth:"0"}),v.append(j),c.append(v);try{const C=Xf({actionCount:e,actionGap:b,actionSize:_,availableInlineSize:h.width,inlineEndInset:N,measurePromptBlockSize:w=>(v.style.paddingInlineEnd=`${h.width-w}px`,j.getBoundingClientRect().height)});a(w=>w.columns===C.columns&&w.rows===C.rows?w:C)}finally{v.remove()}},[e]);return m.useLayoutEffect(()=>{if(a(f=>{const h=ei(e);return f.columns<=e&&f.rows===Math.ceil(e/f.columns)?f:h}),l(),typeof ResizeObserver>"u")return;let c=0;const d=()=>{cancelAnimationFrame(c),c=requestAnimationFrame(l)},u=new ResizeObserver(d);return n.current&&u.observe(n.current),r.current&&u.observe(r.current),o.current&&u.observe(o.current),()=>{cancelAnimationFrame(c),u.disconnect()}},[e,l,t]),{actionsRef:o,bubbleRef:r,containerRef:n,layout:i,style:{"--user-prompt-action-columns":i.columns,"--user-prompt-action-count":e,"--user-prompt-action-rows":i.rows}}}function Or({displayPath:e}){const{dir:t,name:n}=wd(e);return s.jsxs("span",{className:"file-path-display",title:e,children:[t&&s.jsx("span",{className:"file-path-display-dir",children:t}),s.jsx("span",{className:"file-path-display-name",children:n})]})}function Ue({displayPath:e,filePath:t,lineEnd:n,lineNumber:r,showLineSuffix:o,viewMode:i,showCopyButton:a=!0,showVersionControlLinks:l=!0}){const c=ge(),d=e??oe(t,c==null?void 0:c.projectPath);return c!=null&&c.projectId?s.jsx(Pr,{projectId:c.projectId,filePath:t,displayText:d,lineEnd:n,lineNumber:r,showLineSuffix:o,viewMode:i,showCopyButton:a,showVersionControlLinks:l}):s.jsxs(s.Fragment,{children:[s.jsx(Or,{displayPath:d}),a&&s.jsx(_d,{filePath:Nd(t,c==null?void 0:c.projectPath)??t})]})}function Wt({links:e,renderText:t,text:n}){const r=m.useMemo(()=>{if(!(e!=null&&e.length))return null;const o=new Map(e.map(c=>[c.text,c.filePath])),i=va(n).filter(c=>o.has(c.text));if(i.length===0)return null;const a=[];let l=0;for(const[c,d]of i.entries()){if(d.start>l){const u=n.slice(l,d.start);a.push(s.jsx(m.Fragment,{children:t?t(u):u},`text-${l}`))}a.push(s.jsx(Ue,{displayPath:d.text,filePath:o.get(d.text),showCopyButton:!1,showLineSuffix:!1,showVersionControlLinks:!1},`${d.start}-${c}`)),l=d.end}if(l<n.length){const c=n.slice(l);a.push(s.jsx(m.Fragment,{children:t?t(c):c},`text-${l}`))}return a},[e,t,n]);return r||(t?t(n):n)}function Qf(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Zf({artifact:e,text:t}){const n=m.useMemo(()=>Tr(Qf(t),e),[e,t]);return n.changed?s.jsx("span",{dangerouslySetInnerHTML:{__html:n.html}}):t}function eh({artifact:e,projectPathLinks:t,suppressTrailingUrl:n,text:r}){const o=m.useCallback(a=>s.jsx(Zf,{artifact:e,text:a}),[e]),i=m.useCallback(a=>s.jsx(St,{text:a,suppressTrailingUrl:n,renderText:o}),[o,n]);return s.jsx(Wt,{links:t,text:r,renderText:i})}function lr({projectPathLinks:e,suppressTrailingUrl:t,text:n}){var i;const r=_a(),o=r.state==="ready"&&((i=r.result)==null?void 0:i.status)==="ready"?r.result.artifact:void 0;return s.jsx(eh,{artifact:o,projectPathLinks:e,suppressTrailingUrl:t,text:n})}const cr=12,Rs=cr*100,ti=`Correction to previous message:
22
+ `)){const u=d.match(l);if(u){t.push({originalName:u[1]??"",path:u[2]??u[3]??"",size:Jo(u[4]??""),mimeType:u[5]??"",width:u[6]?Number(u[6]):void 0,height:u[7]?Number(u[7]):void 0});continue}const f=d.match(c);f&&t.push({originalName:f[1]??"",size:Jo(f[2]??""),mimeType:f[3]??"",path:f[4]??""})}return{textWithoutUploads:i,uploadedFiles:t}}function Qo(e){const t=Df(e),{textWithoutUploads:n,uploadedFiles:r}=Of(t);return{text:ou(n),openedFiles:au(n),uploadedFiles:r}}const Uf=new Map,Hf=new Set,rl=m.createContext({turnIndexById:Uf,expandedRewoundGroups:Hf,toggleRewoundGroup:()=>{}}),Y_=rl.Provider;function ol(){return m.useContext(rl)}const Wf="_wrapper_q492x_1",Vf="_menu_q492x_5",Gf="_secondary_q492x_42",zf="_rewind_q492x_48",en={wrapper:Wf,menu:Vf,secondary:Gf,rewind:zf},qf=40;function Kf({messageId:e,onForkBefore:t,onForkAfter:n,onForkAfterSummary:r,afterDisabled:o=!1,unavailableMessage:i}){const{t:a}=Z(),l=ol(),[c,d]=m.useState(!1),[u,f]=m.useState({top:0,right:8}),h=m.useRef(null),g=m.useRef(null),p=e?l.turnIndexById.get(e):void 0,y=e&&l.onClearAfter&&!i?()=>{var j;return(j=l.onClearAfter)==null?void 0:j.call(l,e)}:void 0,x=e&&l.onClearReplacing&&!i?()=>{var j;return(j=l.onClearReplacing)==null?void 0:j.call(l,e)}:void 0;m.useEffect(()=>{if(!c)return;const j=w=>{var S,$;const k=w.target;!((S=h.current)!=null&&S.contains(k))&&!(($=g.current)!=null&&$.contains(k))&&d(!1)},C=w=>{var k;w.key==="Escape"&&(d(!1),(k=h.current)==null||k.focus())};return document.addEventListener("mousedown",j),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",C)}},[c]);const b=()=>{var C;const j=(C=h.current)==null?void 0:C.getBoundingClientRect();if(j){const w=+!!t+ +!!n+ +!!r+ +!!y+ +!!x,k=Math.max(1,w)*qf+12,S=j.bottom+8+k<=window.innerHeight?j.bottom+8:Math.max(8,j.top-k-8);f({top:S,right:Math.max(8,window.innerWidth-j.right)})}d(!0)},_=j=>{d(!1),j()},N=p!==void 0?a("forkTurnMenuLabelIndexed",{index:String(p)}):a("forkTurnMenuLabel"),v=s.jsxs("div",{ref:g,className:en.menu,role:"menu",style:{"--fork-turn-menu-top":`${u.top}px`,"--fork-turn-menu-right":`${u.right}px`},"aria-label":N,children:[i?s.jsx("button",{type:"button",role:"menuitem",disabled:!0,children:i}):null,!i&&t&&s.jsx("button",{type:"button",role:"menuitem",onClick:()=>_(t),children:a("forkTurnBefore")}),!i&&n&&s.jsx("button",{type:"button",role:"menuitem",disabled:o,title:o?a("forkTurnAfterDisabled"):void 0,onClick:()=>_(n),children:a("forkTurnAfter")}),!i&&r&&s.jsx("button",{type:"button",role:"menuitem",className:en.secondary,disabled:o,title:o?a("forkTurnAfterDisabled"):void 0,onClick:()=>_(r),children:a("forkTurnAfterSummary")}),y&&s.jsx("button",{type:"button",role:"menuitem",className:en.rewind,disabled:o,title:o?a("forkTurnAfterDisabled"):a("rewindClearAfterTurnTooltip",{index:String(p??"")}),onClick:()=>_(y),children:a("rewindClearAfterTurn")}),x&&s.jsx("button",{type:"button",role:"menuitem",className:en.rewind,disabled:o,title:a(o?"forkTurnAfterDisabled":"rewindClearReplacingTurnTooltip"),onClick:()=>_(x),children:a("rewindClearReplacingTurn")})]});return s.jsxs("div",{className:en.wrapper,children:[s.jsx("button",{ref:h,type:"button",className:"user-prompt-action",onClick:()=>c?d(!1):b(),"aria-label":N,title:i??N,"aria-haspopup":"menu","aria-expanded":c,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"18",r:"3"}),s.jsx("circle",{cx:"18",cy:"12",r:"3"}),s.jsx("path",{d:"M6 9v6"}),s.jsx("path",{d:"M8.5 7.5 15 11"})]})}),c&&br.createPortal(v,document.body)]})}const Zo=.5;function Xf({actionCount:e,actionGap:t,actionSize:n,availableInlineSize:r,inlineEndInset:o,measurePromptBlockSize:i}){var g;if(e<=1)return{columns:1,rows:Math.max(1,e)};const l=[...new Set([1,Math.min(2,e),e])].map(p=>{const y=Math.ceil(e/p),x=p*n+Math.max(0,p-1)*t,b=Math.max(1,r-x-t-o),_=i(b),N=y*n+Math.max(0,y-1)*t;return{columns:p,rows:y,actionBlockSize:N,promptBlockSize:_,totalBlockSize:Math.max(N,_)}}),c=l.find(p=>p.actionBlockSize<=p.promptBlockSize+Zo);if(c)return{columns:c.columns,rows:c.rows};const d=((g=l[0])==null?void 0:g.promptBlockSize)??0,u=l.filter(p=>p.promptBlockSize<=d+Zo),h=(u.length>1?u:l).reduce((p,y)=>y.totalBlockSize!==p.totalBlockSize?y.totalBlockSize<p.totalBlockSize?y:p:y.promptBlockSize!==p.promptBlockSize?y.promptBlockSize<p.promptBlockSize?y:p:y.columns<p.columns?y:p);return{columns:h.columns,rows:h.rows}}function Yf(e,t){const n=Number.parseFloat(e);return Number.isFinite(n)?n:t}function ei(e){return{columns:1,rows:Math.max(1,e)}}function Jf(e,t){const n=m.useRef(null),r=m.useRef(null),o=m.useRef(null),[i,a]=m.useState(()=>ei(e)),l=m.useCallback(()=>{const c=n.current,d=r.current,u=o.current,f=u==null?void 0:u.querySelector(".user-prompt-action");if(!c||!d||!u||!f)return;const h=c.getBoundingClientRect(),g=f.getBoundingClientRect(),p=u.getBoundingClientRect();if(h.width<=0||g.width<=0)return;const y=getComputedStyle(u),x=getComputedStyle(c),b=Yf(y.columnGap,4),_=Math.max(g.width,g.height),N=Math.max(0,x.direction==="rtl"?p.left-h.left:h.right-p.right),v=document.createElement("div"),j=d.cloneNode(!0);v.setAttribute("aria-hidden","true");for(const C of j.querySelectorAll("[id]"))C.removeAttribute("id");Object.assign(v.style,{boxSizing:"border-box",contain:"layout style paint",direction:x.direction,inset:"0 auto auto 0",margin:"0",pointerEvents:"none",position:"fixed",visibility:"hidden",width:`${h.width}px`,zIndex:"-1"}),Object.assign(j.style,{margin:"0",maxHeight:"none",minWidth:"0"}),v.append(j),c.append(v);try{const C=Xf({actionCount:e,actionGap:b,actionSize:_,availableInlineSize:h.width,inlineEndInset:N,measurePromptBlockSize:w=>(v.style.paddingInlineEnd=`${h.width-w}px`,j.getBoundingClientRect().height)});a(w=>w.columns===C.columns&&w.rows===C.rows?w:C)}finally{v.remove()}},[e]);return m.useLayoutEffect(()=>{if(a(f=>{const h=ei(e);return f.columns<=e&&f.rows===Math.ceil(e/f.columns)?f:h}),l(),typeof ResizeObserver>"u")return;let c=0;const d=()=>{cancelAnimationFrame(c),c=requestAnimationFrame(l)},u=new ResizeObserver(d);return n.current&&u.observe(n.current),r.current&&u.observe(r.current),o.current&&u.observe(o.current),()=>{cancelAnimationFrame(c),u.disconnect()}},[e,l,t]),{actionsRef:o,bubbleRef:r,containerRef:n,layout:i,style:{"--user-prompt-action-columns":i.columns,"--user-prompt-action-count":e,"--user-prompt-action-rows":i.rows}}}function Or({displayPath:e}){const{dir:t,name:n}=fd(e);return s.jsxs("span",{className:"file-path-display",title:e,children:[t&&s.jsx("span",{className:"file-path-display-dir",children:t}),s.jsx("span",{className:"file-path-display-name",children:n})]})}function Ue({displayPath:e,filePath:t,lineEnd:n,lineNumber:r,showLineSuffix:o,viewMode:i,showCopyButton:a=!0,showVersionControlLinks:l=!0}){const c=ge(),d=e??oe(t,c==null?void 0:c.projectPath);return c!=null&&c.projectId?s.jsx(Ir,{projectId:c.projectId,filePath:t,displayText:d,lineEnd:n,lineNumber:r,showLineSuffix:o,viewMode:i,showCopyButton:a,showVersionControlLinks:l}):s.jsxs(s.Fragment,{children:[s.jsx(Or,{displayPath:d}),a&&s.jsx(Md,{filePath:hd(t,c==null?void 0:c.projectPath)??t})]})}function Wt({links:e,renderText:t,text:n}){const r=m.useMemo(()=>{if(!(e!=null&&e.length))return null;const o=new Map(e.map(c=>[c.text,c.filePath])),i=Na(n).filter(c=>o.has(c.text));if(i.length===0)return null;const a=[];let l=0;for(const[c,d]of i.entries()){if(d.start>l){const u=n.slice(l,d.start);a.push(s.jsx(m.Fragment,{children:t?t(u):u},`text-${l}`))}a.push(s.jsx(Ue,{displayPath:d.text,filePath:o.get(d.text),showCopyButton:!1,showLineSuffix:!1,showVersionControlLinks:!1},`${d.start}-${c}`)),l=d.end}if(l<n.length){const c=n.slice(l);a.push(s.jsx(m.Fragment,{children:t?t(c):c},`text-${l}`))}return a},[e,t,n]);return r||(t?t(n):n)}function Qf(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Zf({artifact:e,text:t}){const n=m.useMemo(()=>Er(Qf(t),e),[e,t]);return n.changed?s.jsx("span",{dangerouslySetInnerHTML:{__html:n.html}}):t}function eh({artifact:e,projectPathLinks:t,suppressTrailingUrl:n,text:r}){const o=m.useCallback(a=>s.jsx(Zf,{artifact:e,text:a}),[e]),i=m.useCallback(a=>s.jsx(St,{text:a,suppressTrailingUrl:n,renderText:o}),[o,n]);return s.jsx(Wt,{links:t,text:r,renderText:i})}function lr({projectPathLinks:e,suppressTrailingUrl:t,text:n}){var i;const r=Sa(),o=r.state==="ready"&&((i=r.result)==null?void 0:i.status)==="ready"?r.result.artifact:void 0;return s.jsx(eh,{artifact:o,projectPathLinks:e,suppressTrailingUrl:t,text:n})}const cr=12,Rs=cr*100,ti=`Correction to previous message:
23
23
  `,ni=`
24
24
 
25
25
  Change: `;function il(e){if(!e.startsWith(ti))return null;const t=e.slice(ti.length),n=t.indexOf(ni),r=n===-1?t:t.slice(0,n),o=n===-1?void 0:t.slice(n+ni.length).trim();return r.trim()?{correctedText:r,...o?{change:o}:{}}:null}function si(e){const t=il(e);return t?t.change?`${t.correctedText}
@@ -28,11 +28,11 @@ Change: ${t.change}`:t.correctedText:e}function En({files:e}){return e.length===
28
28
  `).filter(t=>t.trim()!=="<image>").join(`
29
29
  `).replace(/\n{3,}/g,`
30
30
 
31
- `).trim()}function sh(e){var d;const t=/^data:([^;,]+)?(;base64)?,(.*)$/i.exec(e);if(!t)return{};const r=((d=t[1])==null?void 0:d.trim())||void 0,o=!!t[2],i=(t[3]??"").trim();if(!i)return{mimeType:r};if(!o){const u=decodeURIComponent(i);return{mimeType:r,bytes:u.length}}const a=i.replace(/\s+/g,""),l=a.endsWith("==")?2:a.endsWith("=")?1:0,c=Math.max(0,Math.floor(a.length*3/4)-l);return{mimeType:r,bytes:c}}function rh(e){return!e||e<0?"unknown size":e<1024?`${e} b`:e<1024*1024?`${Math.round(e/1024)} kb`:`${Math.round(e/(1024*1024)*10)/10} mb`}function ri(e){const t=e.toLowerCase();if(t.endsWith(".png"))return"image/png";if(t.endsWith(".jpg")||t.endsWith(".jpeg"))return"image/jpeg";if(t.endsWith(".gif"))return"image/gif";if(t.endsWith(".webp"))return"image/webp";if(t.endsWith(".bmp"))return"image/bmp";if(t.endsWith(".svg"))return"image/svg+xml"}function oh(e){const t=e.toLowerCase();if(t==="image/jpeg")return"jpg";if(t==="image/svg+xml")return"svg";const n=t.indexOf("/");return n===-1?"png":t.slice(n+1)||"png"}function ih(e){if(e.startsWith("data:"))return null;try{const r=(new URL(e,"https://codex.local").pathname||"").split("/").filter(Boolean).pop();return r?decodeURIComponent(r):null}catch{return null}}function ah(e){const t=[];let n=0;for(const r of e){if(!th(r))continue;n+=1;const o=typeof r.file_path=="string"?r.file_path.trim():"",i=typeof r.image_url=="string"?r.image_url.trim():"",a=i?sh(i):{},l=typeof r.mime_type=="string"&&r.mime_type.trim()||a.mimeType||(o?ri(o):void 0)||(i?ri(i):void 0)||"image/*",c=o&&Dr(o)||i&&ih(i)||`pasted-image-${n}.${oh(l)}`,d=o||(i&&!i.startsWith("data:")?i:"")||`codex-inline://image/${n}`;t.push({originalName:c,size:rh(a.bytes),mimeType:l,path:d,previewUrl:i||void 0})}return t}function lh(e,t){const n=new Set,r=[];for(const o of[...e,...t])n.has(o.path)||(n.add(o.path),r.push(o));return r}function In({files:e}){return e.length===0?null:s.jsx("div",{className:"user-prompt-metadata",children:e.map(t=>s.jsx(eu,{originalName:t.originalName,path:t.path,mimeType:t.mimeType,sizeLabel:t.size,imageWidth:t.width,imageHeight:t.height,previewUrl:t.previewUrl},t.path))})}function oi({projectPathLinks:e,text:t}){const[n,r]=m.useState(!1),o=t.split(`
32
- `),i=o.length>cr,a=t.length>Rs,l=i||a,c=rt(t);let d=i?o.slice(0,cr).join(`
33
- `):t;d.length>Rs&&(d=d.slice(0,Rs));const u=rt(d);return!l||n?s.jsxs("div",{className:"text-block",children:[s.jsx("div",{ref:c,children:s.jsx(lr,{text:t,projectPathLinks:e})}),n&&l&&s.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!1),children:"Show less"})]}):s.jsxs("div",{className:"text-block collapsible-text",children:[s.jsxs("div",{ref:u,className:"truncated-content",children:[s.jsx(lr,{text:d,projectPathLinks:e,suppressTrailingUrl:!0}),s.jsx("div",{className:"fade-overlay"})]}),s.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!0),children:"Show more"})]})}function ii({actionsRef:e,messageId:t,onCorrect:n,onCancelUnconfirmed:r,onTrimBefore:o,onForkBefore:i,onForkAfter:a,onForkAfterSummary:l,forkAfterDisabled:c,forkUnavailableMessage:d,copyText:u,extraActions:f}){const{t:h}=Z();return!n&&!r&&!o&&!a&&!d&&!u&&!f?null:s.jsxs("div",{ref:e,className:"user-prompt-actions",children:[u&&s.jsx(Ma,{text:u,label:h("userPromptCopyAction"),className:"user-prompt-action user-prompt-action-copy"}),n&&s.jsxs("button",{type:"button",className:"user-prompt-action user-prompt-action-edit",onClick:n,"aria-label":h("userPromptEditAction"),title:h("userPromptEditAction"),children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),s.jsx("span",{className:"user-prompt-correct-label",children:"Edit"})]}),r&&s.jsx("button",{type:"button",className:"user-prompt-action user-prompt-action-cancel-sent",onClick:r,"aria-label":h("userPromptCancelUnconfirmedAction"),title:h("userPromptCancelUnconfirmedAction"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M18 6 6 18"}),s.jsx("path",{d:"m6 6 12 12"})]})}),(a&&l||d)&&s.jsx(Kf,{messageId:t,onForkBefore:i,onForkAfter:a,onForkAfterSummary:l,afterDisabled:c,unavailableMessage:d}),o&&s.jsx("button",{type:"button",className:"user-prompt-action user-prompt-action-show-starting",onClick:o,"aria-label":h("userPromptShowStartingHere"),title:h("userPromptShowStartingHere"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M4 7h16"}),s.jsx("path",{d:"M4 12h10"}),s.jsx("path",{d:"M4 17h6"}),s.jsx("path",{d:"m15 16 3 3 3-3"}),s.jsx("path",{d:"M18 5v14"})]})}),f]})}function ai({deliveryState:e}){const{t}=Z(),[n,r]=m.useState(!1);return e!=="sent"?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"user-prompt-delivery-marker",title:t("userPromptDeliverySent"),"aria-label":t("userPromptDeliverySent"),"aria-expanded":n,onClick:()=>r(o=>!o),onBlur:()=>r(!1),onKeyDown:o=>{o.key==="Escape"&&r(!1)},children:t("userPromptDeliverySentLabel")}),n&&s.jsx("span",{className:"user-prompt-delivery-popover",role:"status",children:t("userPromptDeliverySentDetail")})]})}function li({projectPathLinks:e,text:t}){const n=il(t);return n?s.jsxs("div",{className:"user-prompt-correction",children:[s.jsx("div",{className:"user-prompt-correction-label",children:"Correction"}),s.jsx(oi,{text:n.correctedText,projectPathLinks:e}),n.change&&s.jsxs("div",{className:"user-prompt-correction-change",children:["Change:"," ",s.jsx(lr,{text:n.change,projectPathLinks:e})]})]}):s.jsx(oi,{text:t,projectPathLinks:e})}const al=m.memo(function({content:t,messageId:n,projectPathLinks:r,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,extraActions:h,deliveryState:g}){const p=g==="sent"?" user-prompt-unconfirmed":"",y=+!!t+ +!!o+ +!!i+ +!!(c&&d||f)+ +!!a+m.Children.count(h),x=typeof t=="string"?t:t.map(S=>S.type==="text"&&typeof S.text=="string"?S.text:S.type).join("\0"),b=Jf(y,x);if(typeof t=="string"){const{text:S,openedFiles:$,uploadedFiles:T}=Qo(t);return S?s.jsxs("div",{ref:b.containerRef,className:"user-prompt-container",style:b.style,children:[s.jsx("div",{ref:b.bubbleRef,className:`message message-user-prompt ${o?"user-prompt-correctable":""}${p}`,children:s.jsxs("div",{className:"message-content",children:[s.jsx(li,{text:S,projectPathLinks:r}),s.jsx(ai,{deliveryState:g}),s.jsx(In,{files:T})]})}),s.jsx(ii,{actionsRef:b.actionsRef,messageId:n,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,copyText:si(S),extraActions:h}),s.jsx(En,{files:$})]}):$.length>0||T.length>0?s.jsxs(s.Fragment,{children:[s.jsx(In,{files:T}),s.jsx(En,{files:$})]}):null}const _=t.filter(S=>S.type==="text"&&S.text).map(S=>S.text).join(`
34
- `),N=ah(t),v=N.length>0?nh(_):_,{text:j,openedFiles:C,uploadedFiles:w}=Qo(v),k=lh(w,N);return j?s.jsxs("div",{ref:b.containerRef,className:"user-prompt-container",style:b.style,children:[s.jsx("div",{ref:b.bubbleRef,className:`message message-user-prompt ${o?"user-prompt-correctable":""}${p}`,children:s.jsxs("div",{className:"message-content",children:[s.jsx(li,{text:j,projectPathLinks:r}),s.jsx(ai,{deliveryState:g}),s.jsx(In,{files:k})]})}),s.jsx(ii,{actionsRef:b.actionsRef,messageId:n,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,copyText:si(j),extraActions:h}),s.jsx(En,{files:C})]}):C.length>0||k.length>0?s.jsxs(s.Fragment,{children:[s.jsx(In,{files:k}),s.jsx(En,{files:C})]}):s.jsx("div",{className:"message message-user-prompt",children:s.jsx("div",{className:"message-content",children:s.jsx("div",{className:"text-block",children:"[Complex content]"})})})});function ch({open:e,onOpenChange:t,delayMultiplier:n=1}){const r=pa(),o=m.useRef(Symbol("rich-tooltip-intent")),i=m.useRef(null),a=m.useRef(null),l=m.useRef(null),c=m.useRef(null),d=m.useRef(!1),u=m.useRef(e);u.current=e;const f=m.useCallback(()=>{Ic(o.current)},[]),h=m.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=m.useCallback(()=>{const w=a.current;w&&(a.current=null,Mc(w))},[]),p=m.useCallback(()=>{f(),h(),g(),t(!1)},[h,f,t,g]),y=m.useCallback(()=>{if(vo()){p();return}const w=l.current;!d.current&&(!w||!$c(w))||(!a.current&&r==="themed"&&(a.current=Lc(p)),t(!0))},[p,t,r]),x=m.useCallback(()=>{if(f(),vo()||u.current)return;const w=r==="native"?0:Ac(n);w===0?wo(o.current,0,y):wo(o.current,w,y)},[f,n,y,r]),b=m.useCallback(()=>{if(i.current)return;const w=r==="native"?0:Fc()*Bc;if(w===0){p();return}i.current=setTimeout(()=>{i.current=null,p()},w)},[p,r]),_=m.useCallback(w=>{w.pointerType!=="touch"&&(l.current=w.currentTarget,c.current={x:w.clientX,y:w.clientY},h(),x())},[h,x]),N=m.useCallback(w=>{w.pointerType!=="touch"&&(l.current=w.currentTarget,c.current={x:w.clientX,y:w.clientY},h(),u.current||x())},[h,x]),v=m.useCallback(w=>{if(w.relatedTarget instanceof Node&&w.currentTarget.contains(w.relatedTarget))return;const k=c.current;u.current&&!_o(k,w.clientX,w.clientY)||(u.current?b():p())},[p,b]),j=m.useCallback(w=>{w.currentTarget.matches(":focus-visible")&&(d.current=!0,h(),x())},[h,x]),C=m.useCallback(w=>{w.relatedTarget instanceof Node&&w.currentTarget.contains(w.relatedTarget)||(d.current=!1,p())},[p]);return m.useEffect(()=>{e||g()},[e,g]),m.useEffect(()=>Dc(p),[p]),m.useEffect(()=>{if(!e||r!=="themed")return;const w=k=>{if(d.current)return;const S=l.current;S&&k.target instanceof Node&&S.contains(k.target)||_o(c.current,k.clientX,k.clientY)&&b()};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)},[e,b,r]),m.useEffect(()=>()=>{f(),h(),g()},[h,f,g]),{onPointerEnter:_,onPointerMove:N,onPointerLeave:v,onFocus:j,onBlur:C,cancelPending:f,close:p}}const ci={shell_command:"Bash",exec_command:"Bash",write_stdin:"WriteStdin",wait:"WriteStdin",update_plan:"UpdatePlan",apply_patch:"Edit",web_search_call:"WebSearch",search_query:"WebSearch",Agent:"Task",view_image:"ViewImage",imageView:"ViewImage"};function ll(e){return ci[e]??ci[e.toLowerCase()]??e}const dh={read:"read",grep:"search",search:"search",grepsearch:"search",grep_search:"search",glob:"list",ls:"list",list:"list",listdir:"list",list_dir:"list","list-dir":"list"};function X_(e){return dh[ll(e).toLowerCase()]??null}const uh="_partial_1py7t_1",mh={partial:uh},fn=m.memo(function({text:t,className:n,as:r="code"}){const o=Cr();if(!gu(t)){const a=s.jsx(St,{text:t});return r==="span"?s.jsx("span",{className:n,children:a}):s.jsx("code",{className:n,children:a})}const i=Rr(kd("ansi-render",()=>({chars:t.length,lines:t.length===0?0:t.split(`
35
- `).length}),()=>xu(t)),o);return r==="span"?s.jsx("span",{className:n,dangerouslySetInnerHTML:{__html:i}}):s.jsx("code",{className:n,dangerouslySetInnerHTML:{__html:i}})}),fh="_json_14506_1",hh="_metadata_14506_6",di={json:fh,metadata:hh};function pt({text:e,compact:t=!1}){return m.useMemo(()=>Sd(e),[e]).map((r,o)=>s.jsx("span",{"data-tool-output-kind":r.kind,className:r.kind==="metadata"?di.metadata:r.kind==="json"?di.json:void 0,children:s.jsx(fn,{as:"span",text:t?r.source:r.text})},o))}const ph="_row_1bm9g_1",gh="_header_1bm9g_11",xh="_details_1bm9g_17",yh="_output_1bm9g_22",jh="_status_1bm9g_30",bt={row:ph,header:gh,details:xh,output:yh,status:jh};function ui(e){return typeof e=="string"?e:JSON.stringify(e,null,2)??""}function Ur({toolName:e,toolInput:t,toolResult:n,status:r,error:o}){const{t:i}=Z();return s.jsxs("div",{className:bt.row,"data-tool-display":"raw",children:[s.jsxs("div",{className:bt.header,children:[s.jsx("strong",{children:e}),s.jsx("span",{className:bt.status,"data-status":r,children:i(`toolDisplay.status.${r}`)})]}),o&&s.jsx("pre",{className:bt.output,children:o.message}),s.jsxs("details",{className:bt.details,children:[s.jsx("summary",{children:i("toolDisplay.rawNotice")}),n!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:i("toolDisplay.output")}),s.jsx("pre",{className:bt.output,children:ui(n)})]}),s.jsx("strong",{children:i("toolDisplay.input")}),s.jsx("pre",{className:bt.output,children:ui(t)})]})]})}class cl extends m.Component{constructor(){super(...arguments);be(this,"state",{error:null,record:this.props})}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,r){const o=r.record;return o.id!==n.id||o.toolName!==n.toolName||o.toolInput!==n.toolInput||o.toolResult!==n.toolResult||o.status!==n.status?{error:null,record:n}:null}componentDidCatch(){}render(){return this.state.error?s.jsx(Ur,{...this.props,error:this.state.error}):this.props.children}}function Mn(e,t,n,r=n?"error":t===void 0?"pending":"complete"){return{input:e,result:t,isError:n,status:r}}function dl(e){return e.isError??e.status==="error"}function Hr(e){var t;return dl({status:e.status,isError:(t=e.toolResult)==null?void 0:t.isError})}function bh(e,t){var d;const n=dl(t),r=e.input.safeParse(t.input),o=n?e.failure:t.input===void 0?e.standaloneResultSchema??e.result:e.result,i=t.result===void 0||o==null?void 0:o.safeParse(t.result),a=!n&&i&&!i.success?(d=e.partialResult)==null?void 0:d.safeParse(t.result):void 0,l=r.success||t.input===void 0&&e.standaloneResult&&((i==null?void 0:i.success)||(a==null?void 0:a.success)),c=l?n&&!e.failure||i&&!i.success&&!(a!=null&&a.success)?"result":void 0:"input";return{kind:c?"raw":a!=null&&a.success?"partial":"rich",reason:c,status:t.status,isError:n,input:r,result:i,partialResult:a,inputEligible:l}}const vh=Symbol("checked tool definition");function de(e,t){const{renderFailure:n,getFailureSummary:r}=t,o=["renderToolUse","renderToolResult","getUseSummary","getResultSummary","renderCollapsedPreview","renderInteractiveSummary","renderInline","displayNameForCall"].filter(i=>typeof Reflect.get(t,i)=="function");return Object.freeze({[vh]:!0,tool:t.tool,displayName:t.displayName,pendingDisplayName:t.pendingDisplayName,variants:e.variants,standaloneResult:e.standaloneResult,operations:o,prepare(i){const{isError:a,input:l,result:c,partialResult:d,inputEligible:u,reason:f,kind:h}=bh(e,i),g=n&&a&&e.failure&&(c!=null&&c.success)?{data:c.data,render:n}:void 0,p=g||!(c!=null&&c.success)?void 0:{data:c.data},y=(v=i.status)=>(v==="pending"?t.pendingDisplayName:void 0)??t.displayName??t.tool,x=v=>s.jsx(Ur,{id:v.toolUseId??t.tool,toolName:i.toolName??t.tool,toolInput:i.input,toolResult:i.result,status:i.status}),b=()=>d!=null&&d.success?s.jsx("pre",{className:mh.partial,"data-tool-display":"partial",children:s.jsx(pt,{text:d.data})}):null,_=v=>{try{return v()}catch{return}},N=(v,j)=>{if(h==="raw")return x(v);try{const{toolUseResult:C,getToolUse:w,...k}=v,S=j(k);return S==null||S===!1?S:s.jsx(cl,{id:v.toolUseId??t.tool,toolName:i.toolName??t.tool,toolInput:i.input,toolResult:i.result,status:i.status,children:S})}catch{return x(v)}};return{kind:h,reason:f,status:i.status,isError:a,getDisplayName:(v=i.status)=>(l.success?_(()=>{var j;return(j=t.displayNameForCall)==null?void 0:j.call(t,l.data,v)}):void 0)??y(v),getUseSummary:v=>l.success?_(()=>{var j;return(j=t.getUseSummary)==null?void 0:j.call(t,l.data,v)}):void 0,getResultSummary:v=>u?g?_(()=>r==null?void 0:r(g.data,l.success?l.data:void 0)):p?_(()=>{var j;return(j=t.getResultSummary)==null?void 0:j.call(t,p.data,a,l.success?l.data:void 0,v)}):void 0:void 0,renderToolUse:v=>N(v,j=>l.success?t.renderToolUse(l.data,j):x(j)),renderToolResult:v=>N(v,j=>d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?t.renderToolUse(l.data,j):null,b()]}):g?g.render(g.data,j,l.success?l.data:void 0):p?t.renderToolResult(p.data,a,j,l.success?l.data:void 0):x(j)),renderCollapsedPreview:v=>N(v,j=>{var C,w;return d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?(C=t.renderCollapsedPreview)==null?void 0:C.call(t,l.data,void 0,a,j):null,b()]}):l.success?((w=t.renderCollapsedPreview)==null?void 0:w.call(t,l.data,p==null?void 0:p.data,a,j))??null:x(j)}),renderInteractiveSummary:v=>N(v,j=>{var C;return l.success?((C=t.renderInteractiveSummary)==null?void 0:C.call(t,l.data,p==null?void 0:p.data,a,j))??null:x(j)}),renderInline:v=>N(v,j=>{var C,w;return d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?(C=t.renderInline)==null?void 0:C.call(t,l.data,void 0,a,i.status,j):null,b()]}):l.success?((w=t.renderInline)==null?void 0:w.call(t,l.data,p==null?void 0:p.data,a,i.status,j))??null:x(j)})}}})}const bs=I({stdout:ce().optional(),stderr:ce().optional(),interrupted:ke().default(!1),isImage:ke().default(!1),backgroundTaskId:ce().optional(),exitCode:Ke().optional(),durationSeconds:Ke().optional()}).refine(e=>e.stdout!==void 0||e.stderr!==void 0||e.backgroundTaskId!==void 0).transform(e=>({...e,stdout:e.stdout??"",stderr:e.stderr??""}));function Xt(e,t){if(!e)return{stdout:"",stderr:"",interrupted:!1,isImage:!1};if(typeof e=="string"){const r=Me(e,{bareExitCodeIsEnvelope:t}),o=r.hasEnvelope?r.output:e;return{stdout:!t||r.hasEnvelope?o:"",stderr:t&&!r.hasEnvelope?o:"",interrupted:!1,isImage:!1,...r.exitCode!==void 0?{exitCode:r.exitCode}:{}}}const n=bs.safeParse(e);return n.success?n.data:{stdout:"",stderr:"",interrupted:!1,isImage:!1}}const wh=I({file_path:ce(),offset:Ke().optional(),limit:Ke().optional()}),_h=I({file_path:ce(),content:ce(),_highlightedContentHtml:ce().optional(),_highlightedLanguage:ce().optional(),_highlightedTruncated:ke().optional(),_renderedMarkdownHtml:ce().optional()}),ul=I({filePath:ce(),content:ce(),numLines:Ke(),startLine:Ke(),totalLines:Ke()}),Wr=I({oldStart:Ke(),oldLines:Ke(),newStart:Ke(),newLines:Ke(),lines:J(ce())}),ml=I({id:ce().optional(),question:ce(),header:ce(),options:J(I({label:ce(),description:ce(),preview:ce().optional()})),multiSelect:ke(),isOther:ke().optional(),isSecret:ke().optional()}),Nh=I({questions:J(ml)}),kh=te([I({file:ul,content:ce().optional()}),ce().transform(e=>({content:e,file:void 0})),I({content:ce(),file:Js()})]),De=te([ce(),I({tool_use_id:ce(),content:ce()}).transform(e=>e.content)]),M=ce(),he=Ke(),P=M.optional(),ne=he.optional(),Vr=J(I({type:Xe(["input_text","output_text","text"]),text:M})).min(1),Sh=Vr.transform(e=>e.map(t=>t.text).join(`
31
+ `).trim()}function sh(e){var d;const t=/^data:([^;,]+)?(;base64)?,(.*)$/i.exec(e);if(!t)return{};const r=((d=t[1])==null?void 0:d.trim())||void 0,o=!!t[2],i=(t[3]??"").trim();if(!i)return{mimeType:r};if(!o){const u=decodeURIComponent(i);return{mimeType:r,bytes:u.length}}const a=i.replace(/\s+/g,""),l=a.endsWith("==")?2:a.endsWith("=")?1:0,c=Math.max(0,Math.floor(a.length*3/4)-l);return{mimeType:r,bytes:c}}function rh(e){return!e||e<0?"unknown size":e<1024?`${e} b`:e<1024*1024?`${Math.round(e/1024)} kb`:`${Math.round(e/(1024*1024)*10)/10} mb`}function ri(e){const t=e.toLowerCase();if(t.endsWith(".png"))return"image/png";if(t.endsWith(".jpg")||t.endsWith(".jpeg"))return"image/jpeg";if(t.endsWith(".gif"))return"image/gif";if(t.endsWith(".webp"))return"image/webp";if(t.endsWith(".bmp"))return"image/bmp";if(t.endsWith(".svg"))return"image/svg+xml"}function oh(e){const t=e.toLowerCase();if(t==="image/jpeg")return"jpg";if(t==="image/svg+xml")return"svg";const n=t.indexOf("/");return n===-1?"png":t.slice(n+1)||"png"}function ih(e){if(e.startsWith("data:"))return null;try{const r=(new URL(e,"https://codex.local").pathname||"").split("/").filter(Boolean).pop();return r?decodeURIComponent(r):null}catch{return null}}function ah(e){const t=[];let n=0;for(const r of e){if(!th(r))continue;n+=1;const o=typeof r.file_path=="string"?r.file_path.trim():"",i=typeof r.image_url=="string"?r.image_url.trim():"",a=i?sh(i):{},l=typeof r.mime_type=="string"&&r.mime_type.trim()||a.mimeType||(o?ri(o):void 0)||(i?ri(i):void 0)||"image/*",c=o&&Dr(o)||i&&ih(i)||`pasted-image-${n}.${oh(l)}`,d=o||(i&&!i.startsWith("data:")?i:"")||`codex-inline://image/${n}`;t.push({originalName:c,size:rh(a.bytes),mimeType:l,path:d,previewUrl:i||void 0})}return t}function lh(e,t){const n=new Set,r=[];for(const o of[...e,...t])n.has(o.path)||(n.add(o.path),r.push(o));return r}function In({files:e}){return e.length===0?null:s.jsx("div",{className:"user-prompt-metadata",children:e.map(t=>s.jsx(Zd,{originalName:t.originalName,path:t.path,mimeType:t.mimeType,sizeLabel:t.size,imageWidth:t.width,imageHeight:t.height,previewUrl:t.previewUrl},t.path))})}function oi({projectPathLinks:e,text:t}){const[n,r]=m.useState(!1),o=t.split(`
32
+ `),i=o.length>cr,a=t.length>Rs,l=i||a,c=st(t);let d=i?o.slice(0,cr).join(`
33
+ `):t;d.length>Rs&&(d=d.slice(0,Rs));const u=st(d);return!l||n?s.jsxs("div",{className:"text-block",children:[s.jsx("div",{ref:c,children:s.jsx(lr,{text:t,projectPathLinks:e})}),n&&l&&s.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!1),children:"Show less"})]}):s.jsxs("div",{className:"text-block collapsible-text",children:[s.jsxs("div",{ref:u,className:"truncated-content",children:[s.jsx(lr,{text:d,projectPathLinks:e,suppressTrailingUrl:!0}),s.jsx("div",{className:"fade-overlay"})]}),s.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!0),children:"Show more"})]})}function ii({actionsRef:e,messageId:t,onCorrect:n,onCancelUnconfirmed:r,onTrimBefore:o,onForkBefore:i,onForkAfter:a,onForkAfterSummary:l,forkAfterDisabled:c,forkUnavailableMessage:d,copyText:u,extraActions:f}){const{t:h}=Z();return!n&&!r&&!o&&!a&&!d&&!u&&!f?null:s.jsxs("div",{ref:e,className:"user-prompt-actions",children:[u&&s.jsx(Ma,{text:u,label:h("userPromptCopyAction"),className:"user-prompt-action user-prompt-action-copy"}),n&&s.jsxs("button",{type:"button",className:"user-prompt-action user-prompt-action-edit",onClick:n,"aria-label":h("userPromptEditAction"),title:h("userPromptEditAction"),children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),s.jsx("span",{className:"user-prompt-correct-label",children:"Edit"})]}),r&&s.jsx("button",{type:"button",className:"user-prompt-action user-prompt-action-cancel-sent",onClick:r,"aria-label":h("userPromptCancelUnconfirmedAction"),title:h("userPromptCancelUnconfirmedAction"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M18 6 6 18"}),s.jsx("path",{d:"m6 6 12 12"})]})}),(a&&l||d)&&s.jsx(Kf,{messageId:t,onForkBefore:i,onForkAfter:a,onForkAfterSummary:l,afterDisabled:c,unavailableMessage:d}),o&&s.jsx("button",{type:"button",className:"user-prompt-action user-prompt-action-show-starting",onClick:o,"aria-label":h("userPromptShowStartingHere"),title:h("userPromptShowStartingHere"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M4 7h16"}),s.jsx("path",{d:"M4 12h10"}),s.jsx("path",{d:"M4 17h6"}),s.jsx("path",{d:"m15 16 3 3 3-3"}),s.jsx("path",{d:"M18 5v14"})]})}),f]})}function ai({deliveryState:e}){const{t}=Z(),[n,r]=m.useState(!1);return e!=="sent"?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"user-prompt-delivery-marker",title:t("userPromptDeliverySent"),"aria-label":t("userPromptDeliverySent"),"aria-expanded":n,onClick:()=>r(o=>!o),onBlur:()=>r(!1),onKeyDown:o=>{o.key==="Escape"&&r(!1)},children:t("userPromptDeliverySentLabel")}),n&&s.jsx("span",{className:"user-prompt-delivery-popover",role:"status",children:t("userPromptDeliverySentDetail")})]})}function li({projectPathLinks:e,text:t}){const n=il(t);return n?s.jsxs("div",{className:"user-prompt-correction",children:[s.jsx("div",{className:"user-prompt-correction-label",children:"Correction"}),s.jsx(oi,{text:n.correctedText,projectPathLinks:e}),n.change&&s.jsxs("div",{className:"user-prompt-correction-change",children:["Change:"," ",s.jsx(lr,{text:n.change,projectPathLinks:e})]})]}):s.jsx(oi,{text:t,projectPathLinks:e})}const al=m.memo(function({content:t,messageId:n,projectPathLinks:r,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,extraActions:h,deliveryState:g}){const p=g==="sent"?" user-prompt-unconfirmed":"",y=+!!t+ +!!o+ +!!i+ +!!(c&&d||f)+ +!!a+m.Children.count(h),x=typeof t=="string"?t:t.map(S=>S.type==="text"&&typeof S.text=="string"?S.text:S.type).join("\0"),b=Jf(y,x);if(typeof t=="string"){const{text:S,openedFiles:$,uploadedFiles:T}=Qo(t);return S?s.jsxs("div",{ref:b.containerRef,className:"user-prompt-container",style:b.style,children:[s.jsx("div",{ref:b.bubbleRef,className:`message message-user-prompt ${o?"user-prompt-correctable":""}${p}`,children:s.jsxs("div",{className:"message-content",children:[s.jsx(li,{text:S,projectPathLinks:r}),s.jsx(ai,{deliveryState:g}),s.jsx(In,{files:T})]})}),s.jsx(ii,{actionsRef:b.actionsRef,messageId:n,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,copyText:si(S),extraActions:h}),s.jsx(En,{files:$})]}):$.length>0||T.length>0?s.jsxs(s.Fragment,{children:[s.jsx(In,{files:T}),s.jsx(En,{files:$})]}):null}const _=t.filter(S=>S.type==="text"&&S.text).map(S=>S.text).join(`
34
+ `),N=ah(t),v=N.length>0?nh(_):_,{text:j,openedFiles:C,uploadedFiles:w}=Qo(v),k=lh(w,N);return j?s.jsxs("div",{ref:b.containerRef,className:"user-prompt-container",style:b.style,children:[s.jsx("div",{ref:b.bubbleRef,className:`message message-user-prompt ${o?"user-prompt-correctable":""}${p}`,children:s.jsxs("div",{className:"message-content",children:[s.jsx(li,{text:j,projectPathLinks:r}),s.jsx(ai,{deliveryState:g}),s.jsx(In,{files:k})]})}),s.jsx(ii,{actionsRef:b.actionsRef,messageId:n,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,copyText:si(j),extraActions:h}),s.jsx(En,{files:C})]}):C.length>0||k.length>0?s.jsxs(s.Fragment,{children:[s.jsx(In,{files:k}),s.jsx(En,{files:C})]}):s.jsx("div",{className:"message message-user-prompt",children:s.jsx("div",{className:"message-content",children:s.jsx("div",{className:"text-block",children:"[Complex content]"})})})});function ch({open:e,onOpenChange:t,delayMultiplier:n=1}){const r=pa(),o=m.useRef(Symbol("rich-tooltip-intent")),i=m.useRef(null),a=m.useRef(null),l=m.useRef(null),c=m.useRef(null),d=m.useRef(!1),u=m.useRef(e);u.current=e;const f=m.useCallback(()=>{Ic(o.current)},[]),h=m.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=m.useCallback(()=>{const w=a.current;w&&(a.current=null,Mc(w))},[]),p=m.useCallback(()=>{f(),h(),g(),t(!1)},[h,f,t,g]),y=m.useCallback(()=>{if(vo()){p();return}const w=l.current;!d.current&&(!w||!$c(w))||(!a.current&&r==="themed"&&(a.current=Lc(p)),t(!0))},[p,t,r]),x=m.useCallback(()=>{if(f(),vo()||u.current)return;const w=r==="native"?0:Ac(n);w===0?wo(o.current,0,y):wo(o.current,w,y)},[f,n,y,r]),b=m.useCallback(()=>{if(i.current)return;const w=r==="native"?0:Fc()*Bc;if(w===0){p();return}i.current=setTimeout(()=>{i.current=null,p()},w)},[p,r]),_=m.useCallback(w=>{w.pointerType!=="touch"&&(l.current=w.currentTarget,c.current={x:w.clientX,y:w.clientY},h(),x())},[h,x]),N=m.useCallback(w=>{w.pointerType!=="touch"&&(l.current=w.currentTarget,c.current={x:w.clientX,y:w.clientY},h(),u.current||x())},[h,x]),v=m.useCallback(w=>{if(w.relatedTarget instanceof Node&&w.currentTarget.contains(w.relatedTarget))return;const k=c.current;u.current&&!_o(k,w.clientX,w.clientY)||(u.current?b():p())},[p,b]),j=m.useCallback(w=>{w.currentTarget.matches(":focus-visible")&&(d.current=!0,h(),x())},[h,x]),C=m.useCallback(w=>{w.relatedTarget instanceof Node&&w.currentTarget.contains(w.relatedTarget)||(d.current=!1,p())},[p]);return m.useEffect(()=>{e||g()},[e,g]),m.useEffect(()=>Dc(p),[p]),m.useEffect(()=>{if(!e||r!=="themed")return;const w=k=>{if(d.current)return;const S=l.current;S&&k.target instanceof Node&&S.contains(k.target)||_o(c.current,k.clientX,k.clientY)&&b()};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)},[e,b,r]),m.useEffect(()=>()=>{f(),h(),g()},[h,f,g]),{onPointerEnter:_,onPointerMove:N,onPointerLeave:v,onFocus:j,onBlur:C,cancelPending:f,close:p}}const ci={shell_command:"Bash",exec_command:"Bash",write_stdin:"WriteStdin",wait:"WriteStdin",update_plan:"UpdatePlan",apply_patch:"Edit",web_search_call:"WebSearch",search_query:"WebSearch",Agent:"Task",view_image:"ViewImage",imageView:"ViewImage"};function ll(e){return ci[e]??ci[e.toLowerCase()]??e}const dh={read:"read",grep:"search",search:"search",grepsearch:"search",grep_search:"search",glob:"list",ls:"list",list:"list",listdir:"list",list_dir:"list","list-dir":"list"};function J_(e){return dh[ll(e).toLowerCase()]??null}const uh="_partial_1py7t_1",mh={partial:uh},fn=m.memo(function({text:t,className:n,as:r="code"}){const o=Nr();if(!gu(t)){const a=s.jsx(St,{text:t});return r==="span"?s.jsx("span",{className:n,children:a}):s.jsx("code",{className:n,children:a})}const i=kr($d("ansi-render",()=>({chars:t.length,lines:t.length===0?0:t.split(`
35
+ `).length}),()=>xu(t)),o);return r==="span"?s.jsx("span",{className:n,dangerouslySetInnerHTML:{__html:i}}):s.jsx("code",{className:n,dangerouslySetInnerHTML:{__html:i}})}),fh="_json_14506_1",hh="_metadata_14506_6",di={json:fh,metadata:hh};function pt({text:e,compact:t=!1}){return m.useMemo(()=>Ld(e),[e]).map((r,o)=>s.jsx("span",{"data-tool-output-kind":r.kind,className:r.kind==="metadata"?di.metadata:r.kind==="json"?di.json:void 0,children:s.jsx(fn,{as:"span",text:t?r.source:r.text})},o))}const ph="_row_1bm9g_1",gh="_header_1bm9g_11",xh="_details_1bm9g_17",yh="_output_1bm9g_22",jh="_status_1bm9g_30",bt={row:ph,header:gh,details:xh,output:yh,status:jh};function ui(e){return typeof e=="string"?e:JSON.stringify(e,null,2)??""}function Ur({toolName:e,toolInput:t,toolResult:n,status:r,error:o}){const{t:i}=Z();return s.jsxs("div",{className:bt.row,"data-tool-display":"raw",children:[s.jsxs("div",{className:bt.header,children:[s.jsx("strong",{children:e}),s.jsx("span",{className:bt.status,"data-status":r,children:i(`toolDisplay.status.${r}`)})]}),o&&s.jsx("pre",{className:bt.output,children:o.message}),s.jsxs("details",{className:bt.details,children:[s.jsx("summary",{children:i("toolDisplay.rawNotice")}),n!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:i("toolDisplay.output")}),s.jsx("pre",{className:bt.output,children:ui(n)})]}),s.jsx("strong",{children:i("toolDisplay.input")}),s.jsx("pre",{className:bt.output,children:ui(t)})]})]})}class cl extends m.Component{constructor(){super(...arguments);be(this,"state",{error:null,record:this.props})}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,r){const o=r.record;return o.id!==n.id||o.toolName!==n.toolName||o.toolInput!==n.toolInput||o.toolResult!==n.toolResult||o.status!==n.status?{error:null,record:n}:null}componentDidCatch(){}render(){return this.state.error?s.jsx(Ur,{...this.props,error:this.state.error}):this.props.children}}function Mn(e,t,n,r=n?"error":t===void 0?"pending":"complete"){return{input:e,result:t,isError:n,status:r}}function dl(e){return e.isError??e.status==="error"}function Hr(e){var t;return dl({status:e.status,isError:(t=e.toolResult)==null?void 0:t.isError})}function bh(e,t){var d;const n=dl(t),r=e.input.safeParse(t.input),o=n?e.failure:t.input===void 0?e.standaloneResultSchema??e.result:e.result,i=t.result===void 0||o==null?void 0:o.safeParse(t.result),a=!n&&i&&!i.success?(d=e.partialResult)==null?void 0:d.safeParse(t.result):void 0,l=r.success||t.input===void 0&&e.standaloneResult&&((i==null?void 0:i.success)||(a==null?void 0:a.success)),c=l?n&&!e.failure||i&&!i.success&&!(a!=null&&a.success)?"result":void 0:"input";return{kind:c?"raw":a!=null&&a.success?"partial":"rich",reason:c,status:t.status,isError:n,input:r,result:i,partialResult:a,inputEligible:l}}const vh=Symbol("checked tool definition");function de(e,t){const{renderFailure:n,getFailureSummary:r}=t,o=["renderToolUse","renderToolResult","getUseSummary","getResultSummary","renderCollapsedPreview","renderInteractiveSummary","renderInline","displayNameForCall"].filter(i=>typeof Reflect.get(t,i)=="function");return Object.freeze({[vh]:!0,tool:t.tool,displayName:t.displayName,pendingDisplayName:t.pendingDisplayName,variants:e.variants,standaloneResult:e.standaloneResult,operations:o,prepare(i){const{isError:a,input:l,result:c,partialResult:d,inputEligible:u,reason:f,kind:h}=bh(e,i),g=n&&a&&e.failure&&(c!=null&&c.success)?{data:c.data,render:n}:void 0,p=g||!(c!=null&&c.success)?void 0:{data:c.data},y=(v=i.status)=>(v==="pending"?t.pendingDisplayName:void 0)??t.displayName??t.tool,x=v=>s.jsx(Ur,{id:v.toolUseId??t.tool,toolName:i.toolName??t.tool,toolInput:i.input,toolResult:i.result,status:i.status}),b=()=>d!=null&&d.success?s.jsx("pre",{className:mh.partial,"data-tool-display":"partial",children:s.jsx(pt,{text:d.data})}):null,_=v=>{try{return v()}catch{return}},N=(v,j)=>{if(h==="raw")return x(v);try{const{toolUseResult:C,getToolUse:w,...k}=v,S=j(k);return S==null||S===!1?S:s.jsx(cl,{id:v.toolUseId??t.tool,toolName:i.toolName??t.tool,toolInput:i.input,toolResult:i.result,status:i.status,children:S})}catch{return x(v)}};return{kind:h,reason:f,status:i.status,isError:a,getDisplayName:(v=i.status)=>(l.success?_(()=>{var j;return(j=t.displayNameForCall)==null?void 0:j.call(t,l.data,v)}):void 0)??y(v),getUseSummary:v=>l.success?_(()=>{var j;return(j=t.getUseSummary)==null?void 0:j.call(t,l.data,v)}):void 0,getResultSummary:v=>u?g?_(()=>r==null?void 0:r(g.data,l.success?l.data:void 0)):p?_(()=>{var j;return(j=t.getResultSummary)==null?void 0:j.call(t,p.data,a,l.success?l.data:void 0,v)}):void 0:void 0,renderToolUse:v=>N(v,j=>l.success?t.renderToolUse(l.data,j):x(j)),renderToolResult:v=>N(v,j=>d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?t.renderToolUse(l.data,j):null,b()]}):g?g.render(g.data,j,l.success?l.data:void 0):p?t.renderToolResult(p.data,a,j,l.success?l.data:void 0):x(j)),renderCollapsedPreview:v=>N(v,j=>{var C,w;return d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?(C=t.renderCollapsedPreview)==null?void 0:C.call(t,l.data,void 0,a,j):null,b()]}):l.success?((w=t.renderCollapsedPreview)==null?void 0:w.call(t,l.data,p==null?void 0:p.data,a,j))??null:x(j)}),renderInteractiveSummary:v=>N(v,j=>{var C;return l.success?((C=t.renderInteractiveSummary)==null?void 0:C.call(t,l.data,p==null?void 0:p.data,a,j))??null:x(j)}),renderInline:v=>N(v,j=>{var C,w;return d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?(C=t.renderInline)==null?void 0:C.call(t,l.data,void 0,a,i.status,j):null,b()]}):l.success?((w=t.renderInline)==null?void 0:w.call(t,l.data,p==null?void 0:p.data,a,i.status,j))??null:x(j)})}}})}const bs=I({stdout:ce().optional(),stderr:ce().optional(),interrupted:ke().default(!1),isImage:ke().default(!1),backgroundTaskId:ce().optional(),exitCode:Ke().optional(),durationSeconds:Ke().optional()}).refine(e=>e.stdout!==void 0||e.stderr!==void 0||e.backgroundTaskId!==void 0).transform(e=>({...e,stdout:e.stdout??"",stderr:e.stderr??""}));function Xt(e,t){if(!e)return{stdout:"",stderr:"",interrupted:!1,isImage:!1};if(typeof e=="string"){const r=Me(e,{bareExitCodeIsEnvelope:t}),o=r.hasEnvelope?r.output:e;return{stdout:!t||r.hasEnvelope?o:"",stderr:t&&!r.hasEnvelope?o:"",interrupted:!1,isImage:!1,...r.exitCode!==void 0?{exitCode:r.exitCode}:{}}}const n=bs.safeParse(e);return n.success?n.data:{stdout:"",stderr:"",interrupted:!1,isImage:!1}}const wh=I({file_path:ce(),offset:Ke().optional(),limit:Ke().optional()}),_h=I({file_path:ce(),content:ce(),_highlightedContentHtml:ce().optional(),_highlightedLanguage:ce().optional(),_highlightedTruncated:ke().optional(),_renderedMarkdownHtml:ce().optional()}),ul=I({filePath:ce(),content:ce(),numLines:Ke(),startLine:Ke(),totalLines:Ke()}),Wr=I({oldStart:Ke(),oldLines:Ke(),newStart:Ke(),newLines:Ke(),lines:J(ce())}),ml=I({id:ce().optional(),question:ce(),header:ce(),options:J(I({label:ce(),description:ce(),preview:ce().optional()})),multiSelect:ke(),isOther:ke().optional(),isSecret:ke().optional()}),Nh=I({questions:J(ml)}),kh=te([I({file:ul,content:ce().optional()}),ce().transform(e=>({content:e,file:void 0})),I({content:ce(),file:Js()})]),De=te([ce(),I({tool_use_id:ce(),content:ce()}).transform(e=>e.content)]),M=ce(),he=Ke(),P=M.optional(),ne=he.optional(),Vr=J(I({type:Xe(["input_text","output_text","text"]),text:M})).min(1),Sh=Vr.transform(e=>e.map(t=>t.text).join(`
36
36
  `)),Ve=te([M.transform(e=>({content:e})),I({content:M})]),Ps={_highlightedContentHtml:P,_highlightedLanguage:P,_highlightedTruncated:ke().optional(),_renderedMarkdownHtml:P},fl=I({base64:P,filePath:P,type:M,originalSize:ne,dimensions:I({originalWidth:ne,originalHeight:ne,displayWidth:ne,displayHeight:ne}).optional()}),Ch=fl.extend({type:M.default("application/pdf")}),Th=te([I({type:Xe(["text","file_unchanged"]).optional(),file:te([ul,I({filePath:M,content:Js().optional(),numLines:Js().optional()})]),...Ps}),I({type:qn("image"),file:fl,...Ps}),I({type:qn("pdf"),file:Ch,...Ps})]),lt={file_path:P,old_string:P,new_string:P,replace_all:ke().optional(),_structuredPatch:J(Wr).optional(),_diffHtml:P,_rawPatch:P,changes:J(I({path:M})).optional()},Rh=te([I({...lt,changes:J(I({path:M})).min(1)}).transform(e=>({...e,displayVariant:"changes"})),I({...lt,file_path:M,old_string:M,new_string:M}).transform(e=>({...e,displayVariant:"replacement"})),I({...lt,_rawPatch:M}).transform(e=>({...e,displayVariant:"patch"})),I({...lt,rawPatch:M}).transform(({rawPatch:e,...t})=>({...t,_rawPatch:e,displayVariant:"patch"})),I({...lt,patch:M}).transform(({patch:e,...t})=>({...t,_rawPatch:e,displayVariant:"patch"})),M.transform(e=>({...I(lt).parse({}),_rawPatch:e,displayVariant:"patch"})),I({...lt,_structuredPatch:J(Wr)}).transform(e=>({...e,displayVariant:"augmented"})),I({...lt,file_path:M}).transform(e=>({...e,displayVariant:"target"}))]),mi=I({filePath:P,oldString:P,newString:P,originalFile:M.nullable().optional(),replaceAll:ke().optional(),userModified:ke().optional(),structuredPatch:J(Wr).optional(),content:P}),fi=te([mi,Sh.transform(e=>mi.parse({content:e}))]),Ph=I({command:P,cmd:te([M,J(M)]).optional(),description:P,timeout:ne,run_in_background:ke().optional(),_backgroundTaskStatus:P,_projectPathLinks:J(I({text:M,filePath:M})).optional(),_previewResult:te([M,bs]).optional()}).refine(e=>e.command!==void 0||e.cmd!==void 0),Eh=te([bs,De.transform(e=>Xt(e,!1))]),Ih=te([bs,ce().transform(e=>Xt(e,!0))]),Mh=I({pattern:M,path:P}),$h=I({filenames:J(M),durationMs:he,numFiles:he,truncated:ke()}),Lh=I({pattern:M,path:P,glob:P,output_mode:Xe(["files_with_matches","content","count"]).optional()}),Ah=I({mode:Xe(["files_with_matches","content","count"]),filenames:J(M),numFiles:he,content:P,numLines:ne,appliedLimit:ne,matches:J(I({filePath:M,lineNumber:he,text:M,columnNumber:ne,ranges:J(I({start:he,end:he})).optional()})).optional()}),dr=I({content:M,status:Xe(["pending","in_progress","completed"]),activeForm:M}),Fh=I({todos:J(dr)}),Bh=I({oldTodos:J(dr),newTodos:J(dr)}),Dh=I({prompt:M,description:P,subagent_type:P,model:P}),hl=I({status:Xe(["completed","failed","timeout","async_launched"]),prompt:P,agentId:P,content:J(I({type:M,id:P,text:P,_renderedHtml:P,summary:J(te([M,I({type:P,text:P})])).optional(),thinking:P,signature:P,name:P,input:Wc().optional(),tool_use_id:P,content:P,is_error:ke().optional()}).superRefine((e,t)=>{const n=e.type==="tool_use"?["name","id"]:e.type==="text"?["text"]:e.type==="tool_result"?["tool_use_id"]:[];for(const r of n)typeof Reflect.get(e,r)!="string"&&t.addIssue({code:"custom",path:[r],message:`Missing ${e.type} ${r}`})})).default([]),totalDurationMs:he.default(0),totalTokens:he.default(0),totalToolUseCount:he.default(0),isAsync:ke().optional(),outputFile:P}),Oh=te([hl,te([M,I({content:M})]).transform(e=>({status:"failed",content:[{type:"text",text:typeof e=="string"?e:e.content}],totalDurationMs:0,totalTokens:0,totalToolUseCount:0}))]),Uh=I({query:M}),Hh=I({query:M,results:J(te([M,I({content:J(I({title:M,url:M}))})])),durationSeconds:ne}),Wh=I({url:M,prompt:M}),Vh=I({bytes:he,code:he,codeText:M,result:M,durationMs:he,url:M}),Gh=I({questions:J(ml.extend({multiSelect:ke().optional()})).optional(),answers:Hc(M,te([M,J(M)])).optional()}),zh=I({plan:P,_renderedHtml:P}),hi=I({message:P,plan:P,isAgent:ke().optional(),filePath:P,_renderedHtml:P}),qh=te([M.transform(e=>({message:e})),I({message:M})]),Kh=I({explanation:P,plan:J(I({step:M,status:M})).optional()}),Es=te([M,Vr,I({message:P})]),Xh=I({session_id:te([M,he]).optional(),cell_id:te([M,he]).optional(),cellId:te([M,he]).optional(),command:P,cmd:P,chars:P,linked_command:P,linked_file_path:P,linked_tool_name:P}),pi=te([M,Vr,I({content:P,stdout:P,output:P,exitCode:ne,exit_code:ne,durationSeconds:ne,wall_time_seconds:ne})]),Yh=I({bash_id:M,block:ke().optional(),wait_up_to:ne}),Jh=I({shellId:M,command:M,status:Xe(["running","completed","failed"]),exitCode:he.nullable(),stdout:M,stderr:M,stdoutLines:he,stderrLines:he,timestamp:M}),Qh=I({task_id:M,block:ke().optional(),timeout:ne}),Zh=I({retrieval_status:Xe(["completed","timeout","running","success","not_ready"]),task:I({task_id:P,task_type:Xe(["local_bash","local_agent","agent"]).optional(),status:Xe(["running","completed","failed"]).optional(),description:P,output:P,exitCode:he.nullable().optional()}).optional()}),ep=I({shell_id:M}),tp=I({message:M,shell_id:M}),np=I({skill:M,args:P}),sp=I({success:ke(),commandName:P}),rp=I({path:M}),op=te([M,J(te([I({type:Xe(["input_text","output_text","text"]),text:M}),I({type:qn("input_image"),image_url:M,detail:P})])).min(1),I({}),Uc()]),ip=I({description:P,prompt:P,message:P,task:P,objective:P,role:P,agent_role:P,agent_type:P,subagent_type:P,model:P}),gi=I({agent_id:P,agentId:P,nickname:P}).transform(e=>({...e,agentId:e.agent_id??e.agentId})),xi=te([gi,M.transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:"custom",message:"Invalid agent result JSON"}),Oc}}).pipe(gi),M]),pl=I({version:qn(1),tasks:J(I({id:M,subject:M,status:M,description:P,activeForm:P,missingCreate:ke().optional()})),currentTaskId:P,sourceToolUseId:P,unresolvedTaskIds:J(M).optional()}),yi=I({subject:P,taskId:P,task_id:P,id:P,status:P,_taskSnapshot:pl.optional()}),ji=te([M,I({content:P,_taskSnapshot:pl.optional()})]),Is=I({objective:P,token_budget:ne,tokenBudget:ne,status:P}),bi=I({objective:P,status:P,token_budget:ne,tokenBudget:ne,tokens_used:ne,tokensUsed:ne,time_used_seconds:ne,timeUsedSeconds:ne}),Ft=te([M,bi.extend({goal:bi.nullable().optional(),message:P,content:P,error:te([M,I({message:P,detail:P})]).optional(),remainingTokens:he.nullable().optional(),remaining_tokens:he.nullable().optional()})]),vi=I({q:P,recency:ne,domains:J(M).optional()}),Ms=I({ref_id:P,lineno:he.nullable().optional(),pattern:P,id:ne}),ap=I({search_query:J(vi).optional(),image_query:J(vi).optional(),open:J(Ms).optional(),click:J(Ms).optional(),find:J(Ms).optional(),response_length:P}),lp=te([M,I({pages:J(I({ref:P,title:M,url:P,wordLimit:ne,totalLines:ne,contentType:P,published:P,redirectedUrl:P,crawled:P,source:P,text:P,lines:J(I({n:he,text:M})).optional()})),durationSeconds:ne,text:P})]),cp=I({calls:J(I({toolName:M,input:I({cmd:P}).optional()})),source:M}),dp=te([M,J(I({type:Xe(["input_text","text"]),text:M}))]),fe={TodoWrite:{partialResult:De,input:Fh,result:Bh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},TaskOutput:{partialResult:De,input:Qh,result:Zh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},AskUserQuestion:{partialResult:De,input:Nh,result:Gh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},Glob:{partialResult:De,input:Mh,result:$h,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},WebFetch:{partialResult:De,input:Wh,result:Vh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},ExitPlanMode:{partialResult:De,input:zh,result:hi,failure:qh,standaloneResultSchema:hi.refine(e=>!!(e.plan||e._renderedHtml||e.message)),variants:["standard","plain-text"],standaloneResult:!0},Exec:{input:cp,result:dp,variants:["standard"],standaloneResult:!0},Web:{input:ap,result:lp,variants:["standard"],standaloneResult:!0},UpdatePlan:{input:Kh,result:Es,failure:Es,standaloneResultSchema:Es.refine(e=>{var t;return typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.some(n=>n.text.trim().length>0):!!((t=e.message)!=null&&t.trim())}),variants:["standard"],standaloneResult:!0},Read:{partialResult:De,input:wh,result:Th,failure:Ve,variants:["text","dedup","image","pdf","plain-text"],standaloneResult:!0},ViewImage:{input:rp,result:op,variants:["standard"],standaloneResult:!1},Task:{partialResult:De,input:Dh,result:hl,failure:Oh,variants:["standard","asynchronous","plain-text"],standaloneResult:!1},Grep:{partialResult:De,input:Lh,result:Ah,failure:Ve,variants:["files","content","count","plain-text"],standaloneResult:!0},Bash:{input:Ph,result:Eh,failure:Ih,variants:["standard"],standaloneResult:!0},WebSearch:{partialResult:De,input:Uh,result:Hh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},spawn_agent:{input:ip,result:xi,failure:xi,variants:["standard"],standaloneResult:!1},Write:{input:_h,result:kh,failure:Ve,variants:["file","acknowledgement"],standaloneResult:!0},TaskCreate:{input:yi,result:ji,variants:["event","snapshot"],standaloneResult:!0},TaskUpdate:{input:yi,result:ji,variants:["event","snapshot"],standaloneResult:!0},WriteStdin:{input:Xh,result:pi,failure:pi,variants:["standard"],standaloneResult:!0},BashOutput:{partialResult:De,input:Yh,result:Jh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},KillShell:{partialResult:De,input:ep,result:tp,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},Skill:{partialResult:De,input:np,result:sp,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},Edit:{partialResult:De,input:Rh,result:fi,failure:Ve,standaloneResultSchema:fi.refine(e=>e.filePath!==void 0||e.structuredPatch!==void 0||e.content!==void 0),variants:["replacement","patch","augmented","changes","target","plain-text"],standaloneResult:!0},create_goal:{input:Is,result:Ft,failure:Ft,variants:["standard"],standaloneResult:!0},get_goal:{input:Is,result:Ft,failure:Ft,variants:["standard"],standaloneResult:!0},update_goal:{input:Is,result:Ft,failure:Ft,variants:["standard"],standaloneResult:!0}},gl={Task:sd,Bash:nd,Read:td,Edit:ed,Write:Zc,Glob:Qc,Grep:Jc,TodoWrite:Yc,WebSearch:Xc,WebFetch:Kc,AskUserQuestion:qc,BashOutput:zc,TaskOutput:Gc,KillShell:Vc};Object.freeze(Object.keys(gl));function we(e,t){const n=gl[e];if(!n)return{valid:!0,toolName:e};const r=n.safeParse(t);return r.success?{valid:!0,toolName:e}:{valid:!1,errors:r.error,toolName:e}}function up(e){const t=e.issues,n=[],r=[];for(const o of t){const i=o.path.join(".")||"(root)";o.code==="invalid_type"&&o.message.toLowerCase().includes("required")?n.push(i):r.push({path:i,message:o.message})}return{missing:n,invalid:r}}const mp="https://github.com/kzahel/yepanywhere/issues/new";function fp(e,t,n){const r=`Schema validation error: ${e}`,o=[`## Tool
37
37
 
38
38
  \`${e}\``];t.length>0&&o.push(`## Missing fields
@@ -45,7 +45,7 @@ ${n.map(({path:l,message:c})=>`- \`${l}\`: ${c}`).join(`
45
45
 
46
46
  <!-- Please add any additional context here, such as what you were doing when this occurred -->`);const i=o.join(`
47
47
 
48
- `),a=new URLSearchParams({title:r,body:i,labels:"bug,schema"});return`${mp}?${a.toString()}`}function q({toolName:e,errors:t}){const{t:n}=Z(),[r,o]=m.useState(!1),{missing:i,invalid:a}=up(t),l=fp(e,i,a),c=m.useCallback(f=>{f.stopPropagation(),o(!0)},[]),d=m.useCallback(f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.stopPropagation(),o(!0))},[]),u=m.useCallback(()=>{o(!1)},[]);return s.jsxs(s.Fragment,{children:[s.jsx("span",{role:"button",tabIndex:0,className:"schema-warning",onClick:c,onKeyDown:d,title:n("schemaWarningTooltip",{tool:e}),children:s.jsx("span",{className:"schema-warning-icon","aria-hidden":"true",children:"!"})}),r&&s.jsx($a,{title:s.jsxs("span",{className:"schema-warning-modal-title",children:["Schema validation failed: ",e,n("schemaWarningTitle",{tool:e})]}),onClose:u,children:s.jsxs("div",{className:"schema-warning-modal-content",children:[i.length>0&&s.jsxs("div",{className:"schema-warning-section",children:[s.jsx("div",{className:"schema-warning-section-title",children:n("schemaWarningMissing")}),s.jsx("ul",{className:"schema-warning-list",children:i.map(f=>s.jsx("li",{className:"schema-warning-item",children:s.jsx("code",{children:f})},f))})]}),a.length>0&&s.jsxs("div",{className:"schema-warning-section",children:[s.jsx("div",{className:"schema-warning-section-title",children:n("schemaWarningInvalid")}),s.jsx("ul",{className:"schema-warning-list",children:a.map(({path:f,message:h})=>s.jsxs("li",{className:"schema-warning-item",children:[s.jsx("code",{children:f}),s.jsx("span",{className:"schema-warning-message",children:h})]},f))})]}),s.jsx("div",{className:"schema-warning-footer",children:s.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"schema-warning-report-link",onClick:f=>f.stopPropagation(),children:n("schemaWarningReport")})})]})})]})}const hp="_toolUse_1l8md_1",pp="_result_1l8md_2",gp="_item_1l8md_8",xp="_header_1l8md_14",yp="_text_1l8md_21",jp="_options_1l8md_25",bp="_option_1l8md_25",vp="_optionSelected_1l8md_48",wp="_optionIndicator_1l8md_53",_p="_optionContent_1l8md_63",Np="_optionLabel_1l8md_69",kp="_optionDesc_1l8md_74",Sp="_error_1l8md_79",Cp="_empty_1l8md_86",_e={toolUse:hp,result:pp,item:gp,header:xp,text:yp,options:jp,option:bp,optionSelected:vp,optionIndicator:wp,optionContent:_p,optionLabel:Np,optionDesc:kp,error:Sp,empty:Cp};function xl({question:e,selectedAnswer:t}){const n=Array.isArray(t)?t:t?[t]:[],r=new Set(e.options.map(i=>i.label)),o=n.filter(i=>!r.has(i));return s.jsxs("div",{className:_e.item,children:[s.jsxs("div",{className:_e.header,children:[s.jsx("span",{className:"badge",children:e.header}),s.jsx("span",{className:_e.text,children:e.question})]}),s.jsxs("ul",{className:_e.options,children:[e.options.map(i=>{const a=n.includes(i.label);return s.jsxs("li",{className:`${_e.option} ${a?_e.optionSelected:""}`,children:[s.jsx("span",{className:_e.optionIndicator,children:e.multiSelect?a?"☑":"☐":a?"●":"○"}),s.jsxs("div",{className:_e.optionContent,children:[s.jsx("span",{className:_e.optionLabel,children:i.label}),i.description&&s.jsx("span",{className:_e.optionDesc,children:i.description})]})]},i.label)}),o.map(i=>s.jsxs("li",{className:`${_e.option} ${_e.optionSelected}`,children:[s.jsx("span",{className:_e.optionIndicator,children:e.multiSelect?"☑":"●"}),s.jsxs("div",{className:_e.optionContent,children:[s.jsx("span",{className:_e.optionLabel,children:"Other"}),s.jsx("span",{className:_e.optionDesc,children:i})]})]},`other-${i}`))]})]})}function Tp({input:e}){return s.jsx("div",{className:_e.toolUse,children:e.questions.map((t,n)=>s.jsx(xl,{question:t},`${t.header}-${n}`))})}function Rp({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("AskUserQuestion",e);!l.valid&&l.errors?(i(l.errors),n("AskUserQuestion",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("AskUserQuestion");return e!=null&&e.questions?s.jsxs("div",{className:_e.result,children:[a&&o&&s.jsx(q,{toolName:"AskUserQuestion",errors:o}),e.questions.map((l,c)=>{var u;const d=(u=e.answers)==null?void 0:u[l.question];return s.jsx(xl,{question:l,selectedAnswer:d},`${l.header}-${c}`)})]}):s.jsxs("div",{className:_e.empty,children:[a&&o&&s.jsx(q,{toolName:"AskUserQuestion",errors:o}),"No questions"]})}const Pp=de(fe.AskUserQuestion,{tool:"AskUserQuestion",displayName:"Asked",pendingDisplayName:"Asking",renderToolUse(e,t){return s.jsx(Tp,{input:e})},renderToolResult(e,t,n){return s.jsx(Rp,{result:e})},renderFailure(e){return s.jsx("div",{className:_e.error,children:e.content||"Question failed"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=e.questions;return`${(t==null?void 0:t.length)||0} question${(t==null?void 0:t.length)===1?"":"s"}`},getResultSummary(e){var r;const t=Object.keys((e==null?void 0:e.answers)||{}).length,n=((r=e==null?void 0:e.questions)==null?void 0:r.length)||0;return t===0&&n>0?`${n} question${n===1?"":"s"}`:`${t} answered`}}),wi=20;function Ep(e){try{const t=new Date(e),r=new Date().getTime()-t.getTime(),o=Math.floor(r/1e3);return o<60?`${o}s ago`:o<3600?`${Math.floor(o/60)}m ago`:t.toLocaleTimeString()}catch{return e}}function Ip({status:e}){const n={running:{icon:"⟳",className:"status-running"},completed:{icon:"✓",className:"status-completed"},failed:{icon:"✗",className:"status-failed"}}[e]||{icon:"?",className:""};return s.jsxs("span",{className:`bashoutput-status ${n.className}`,children:[n.icon," ",e]})}function _i(e,t="code-block"){return s.jsx("div",{className:`${t} fixed-font-rendered-panel`,children:s.jsx("div",{className:"fixed-font-rendered__content",dangerouslySetInnerHTML:{__html:e}})})}function Mp({input:e}){return s.jsxs("div",{className:"bashoutput-tool-use",children:[s.jsx("span",{className:"bashoutput-label",children:"Polling background shell"}),s.jsx("code",{className:"bashoutput-id",children:e.bash_id}),e.block!==void 0&&s.jsx("span",{className:"badge",children:e.block?"blocking":"non-blocking"})]})}function $p({result:e}){var p,y;const[t,n]=m.useState(!1),{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&e){const x=we("BashOutput",e);!x.valid&&x.errors?(l(x.errors),o("BashOutput",x.errors)):l(null)}},[r,e,o]);const c=r&&a&&!i("BashOutput");if(!e)return s.jsx("div",{className:"bashoutput-empty",children:"No output"});const d=((p=e.stdout)==null?void 0:p.split(`
48
+ `),a=new URLSearchParams({title:r,body:i,labels:"bug,schema"});return`${mp}?${a.toString()}`}function q({toolName:e,errors:t}){const{t:n}=Z(),[r,o]=m.useState(!1),{missing:i,invalid:a}=up(t),l=fp(e,i,a),c=m.useCallback(f=>{f.stopPropagation(),o(!0)},[]),d=m.useCallback(f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.stopPropagation(),o(!0))},[]),u=m.useCallback(()=>{o(!1)},[]);return s.jsxs(s.Fragment,{children:[s.jsx("span",{role:"button",tabIndex:0,className:"schema-warning",onClick:c,onKeyDown:d,title:n("schemaWarningTooltip",{tool:e}),children:s.jsx("span",{className:"schema-warning-icon","aria-hidden":"true",children:"!"})}),r&&s.jsx(La,{title:s.jsxs("span",{className:"schema-warning-modal-title",children:["Schema validation failed: ",e,n("schemaWarningTitle",{tool:e})]}),onClose:u,children:s.jsxs("div",{className:"schema-warning-modal-content",children:[i.length>0&&s.jsxs("div",{className:"schema-warning-section",children:[s.jsx("div",{className:"schema-warning-section-title",children:n("schemaWarningMissing")}),s.jsx("ul",{className:"schema-warning-list",children:i.map(f=>s.jsx("li",{className:"schema-warning-item",children:s.jsx("code",{children:f})},f))})]}),a.length>0&&s.jsxs("div",{className:"schema-warning-section",children:[s.jsx("div",{className:"schema-warning-section-title",children:n("schemaWarningInvalid")}),s.jsx("ul",{className:"schema-warning-list",children:a.map(({path:f,message:h})=>s.jsxs("li",{className:"schema-warning-item",children:[s.jsx("code",{children:f}),s.jsx("span",{className:"schema-warning-message",children:h})]},f))})]}),s.jsx("div",{className:"schema-warning-footer",children:s.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"schema-warning-report-link",onClick:f=>f.stopPropagation(),children:n("schemaWarningReport")})})]})})]})}const hp="_toolUse_1l8md_1",pp="_result_1l8md_2",gp="_item_1l8md_8",xp="_header_1l8md_14",yp="_text_1l8md_21",jp="_options_1l8md_25",bp="_option_1l8md_25",vp="_optionSelected_1l8md_48",wp="_optionIndicator_1l8md_53",_p="_optionContent_1l8md_63",Np="_optionLabel_1l8md_69",kp="_optionDesc_1l8md_74",Sp="_error_1l8md_79",Cp="_empty_1l8md_86",_e={toolUse:hp,result:pp,item:gp,header:xp,text:yp,options:jp,option:bp,optionSelected:vp,optionIndicator:wp,optionContent:_p,optionLabel:Np,optionDesc:kp,error:Sp,empty:Cp};function xl({question:e,selectedAnswer:t}){const n=Array.isArray(t)?t:t?[t]:[],r=new Set(e.options.map(i=>i.label)),o=n.filter(i=>!r.has(i));return s.jsxs("div",{className:_e.item,children:[s.jsxs("div",{className:_e.header,children:[s.jsx("span",{className:"badge",children:e.header}),s.jsx("span",{className:_e.text,children:e.question})]}),s.jsxs("ul",{className:_e.options,children:[e.options.map(i=>{const a=n.includes(i.label);return s.jsxs("li",{className:`${_e.option} ${a?_e.optionSelected:""}`,children:[s.jsx("span",{className:_e.optionIndicator,children:e.multiSelect?a?"☑":"☐":a?"●":"○"}),s.jsxs("div",{className:_e.optionContent,children:[s.jsx("span",{className:_e.optionLabel,children:i.label}),i.description&&s.jsx("span",{className:_e.optionDesc,children:i.description})]})]},i.label)}),o.map(i=>s.jsxs("li",{className:`${_e.option} ${_e.optionSelected}`,children:[s.jsx("span",{className:_e.optionIndicator,children:e.multiSelect?"☑":"●"}),s.jsxs("div",{className:_e.optionContent,children:[s.jsx("span",{className:_e.optionLabel,children:"Other"}),s.jsx("span",{className:_e.optionDesc,children:i})]})]},`other-${i}`))]})]})}function Tp({input:e}){return s.jsx("div",{className:_e.toolUse,children:e.questions.map((t,n)=>s.jsx(xl,{question:t},`${t.header}-${n}`))})}function Rp({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("AskUserQuestion",e);!l.valid&&l.errors?(i(l.errors),n("AskUserQuestion",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("AskUserQuestion");return e!=null&&e.questions?s.jsxs("div",{className:_e.result,children:[a&&o&&s.jsx(q,{toolName:"AskUserQuestion",errors:o}),e.questions.map((l,c)=>{var u;const d=(u=e.answers)==null?void 0:u[l.question];return s.jsx(xl,{question:l,selectedAnswer:d},`${l.header}-${c}`)})]}):s.jsxs("div",{className:_e.empty,children:[a&&o&&s.jsx(q,{toolName:"AskUserQuestion",errors:o}),"No questions"]})}const Pp=de(fe.AskUserQuestion,{tool:"AskUserQuestion",displayName:"Asked",pendingDisplayName:"Asking",renderToolUse(e,t){return s.jsx(Tp,{input:e})},renderToolResult(e,t,n){return s.jsx(Rp,{result:e})},renderFailure(e){return s.jsx("div",{className:_e.error,children:e.content||"Question failed"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=e.questions;return`${(t==null?void 0:t.length)||0} question${(t==null?void 0:t.length)===1?"":"s"}`},getResultSummary(e){var r;const t=Object.keys((e==null?void 0:e.answers)||{}).length,n=((r=e==null?void 0:e.questions)==null?void 0:r.length)||0;return t===0&&n>0?`${n} question${n===1?"":"s"}`:`${t} answered`}}),wi=20;function Ep(e){try{const t=new Date(e),r=new Date().getTime()-t.getTime(),o=Math.floor(r/1e3);return o<60?`${o}s ago`:o<3600?`${Math.floor(o/60)}m ago`:t.toLocaleTimeString()}catch{return e}}function Ip({status:e}){const n={running:{icon:"⟳",className:"status-running"},completed:{icon:"✓",className:"status-completed"},failed:{icon:"✗",className:"status-failed"}}[e]||{icon:"?",className:""};return s.jsxs("span",{className:`bashoutput-status ${n.className}`,children:[n.icon," ",e]})}function _i(e,t="code-block"){return s.jsx("div",{className:`${t} fixed-font-rendered-panel`,children:s.jsx("div",{className:"fixed-font-rendered__content",dangerouslySetInnerHTML:{__html:e}})})}function Mp({input:e}){return s.jsxs("div",{className:"bashoutput-tool-use",children:[s.jsx("span",{className:"bashoutput-label",children:"Polling background shell"}),s.jsx("code",{className:"bashoutput-id",children:e.bash_id}),e.block!==void 0&&s.jsx("span",{className:"badge",children:e.block?"blocking":"non-blocking"})]})}function $p({result:e}){var p,y;const[t,n]=m.useState(!1),{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&e){const x=we("BashOutput",e);!x.valid&&x.errors?(l(x.errors),o("BashOutput",x.errors)):l(null)}},[r,e,o]);const c=r&&a&&!i("BashOutput");if(!e)return s.jsx("div",{className:"bashoutput-empty",children:"No output"});const d=((p=e.stdout)==null?void 0:p.split(`
49
49
  `))||[],u=((y=e.stderr)==null?void 0:y.split(`
50
50
  `))||[],f=d.length+u.length,h=f>wi,g=h&&!t?d.slice(0,wi):d;return s.jsxs("div",{className:"bashoutput-result",children:[s.jsxs("div",{className:"bashoutput-header",children:[s.jsx(Ip,{status:e.status}),e.command&&s.jsx("code",{className:"bashoutput-command",children:e.command}),e.exitCode!==null&&s.jsxs("span",{className:`badge ${e.exitCode===0?"badge-success":"badge-error"}`,children:["exit ",e.exitCode]}),e.timestamp&&s.jsx("span",{className:"bashoutput-timestamp",children:Ep(e.timestamp)}),c&&a&&s.jsx(q,{toolName:"BashOutput",errors:a})]}),(e.stdout||e.stderr)&&s.jsxs(s.Fragment,{children:[e.stdout&&s.jsx(Ye,{sourceText:g.join(`
51
51
  `),sourceView:s.jsx("pre",{className:"bash-stdout code-block",children:s.jsx(fn,{text:g.join(`
@@ -55,18 +55,18 @@ ${n.map(({path:l,message:c})=>`- \`${l}\`: ${c}`).join(`
55
55
  ${o.slice(-i).join(`
56
56
  `)}`}function bl(e,t){const n=e.split(`
57
57
  `);let r="",o=0,i=0;for(const a of n){if(i>=t.maxLines||o>=t.maxChars)return{text:r.trimEnd(),truncated:!0};const l=t.maxChars-o;if(a.length>l)return r+=`${a.slice(0,l)}...`,{text:r.trimEnd(),truncated:!0};r+=`${a}
58
- `,o+=a.length+1,i++}return{text:r.trimEnd(),truncated:!1}}function Gp(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5"}),s.jsx("path",{d:"M3 10.5H2.5A1.5 1.5 0 0 1 1 9V2.5A1.5 1.5 0 0 1 2.5 1H9a1.5 1.5 0 0 1 1.5 1.5V3"})]})}function zp(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5 6.5 12 13 4"})})}function ft({text:e,label:t}){const[n,r]=m.useState(!1),o=m.useCallback(async i=>{i.preventDefault(),i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),window.setTimeout(()=>r(!1),3e3)}catch(a){console.error("Failed to copy output section:",a)}},[e]);return s.jsx("button",{type:"button",className:`bash-section-copy ${n?"copied":""}`,onClick:o,disabled:!e,"aria-label":n?"Copied":t,title:n?"Copied":t,children:n?s.jsx(zp,{}):s.jsx(Gp,{})})}function qp(e,t){const n=r=>r.replace(/\/+$/,"");return n(e)===n(t)}function Kp(e,t){const n=rd(e),r=n==null?void 0:n.sessionId;if(!r||r===t.sessionId||n!=null&&n.workingDirectory&&!(t.projectPath&&qp(n.workingDirectory,t.projectPath)))return;const o=t.basePath.replace(/\/$/,"");return{sessionId:r,href:`${o}/projects/${t.projectId}/sessions/${r}`}}const Xp="_link_1xa01_1",Yp="_id_1xa01_20",Si={link:Xp,id:Yp};function zr({command:e}){const{t}=Z(),n=Mr(),r=ge(),o=m.useMemo(()=>r?Kp(e,{basePath:n,projectId:r.projectId,projectPath:r.projectPath,sessionId:r.sessionId}):void 0,[e,n,r]);return o?s.jsxs(vr,{className:Si.link,to:o.href,title:t("nestedHarnessLaunchTitle"),children:[s.jsx("span",{children:t("nestedHarnessLaunchLabel")}),s.jsx("span",{className:Si.id,children:o.sessionId.slice(0,8)})]}):null}const Jp="_fixedWidthOutput_o17ci_1",vl={fixedWidthOutput:Jp};function Zn(e,t="code-block"){return s.jsx("div",{className:`${t} fixed-font-rendered-panel`,children:s.jsx("div",{className:`fixed-font-rendered__content ${vl.fixedWidthOutput}`,dangerouslySetInnerHTML:{__html:e}})})}function $s({label:e,copyText:t,copyLabel:n}){return s.jsxs("div",{className:"bash-section-header",children:[s.jsx("div",{className:"bash-modal-label",children:e}),s.jsx(ft,{text:t,label:n})]})}function wl({input:e,result:t,isError:n,projectPathLinks:r}){const o=typeof t=="string"?Xt(t,n):t,i=jn(e),a=(o==null?void 0:o.stdout)||"",l=(o==null?void 0:o.stderr)||"";return s.jsxs("div",{className:"bash-modal-sections",children:[s.jsxs("div",{className:"bash-modal-section",children:[s.jsx($s,{label:"Command",copyText:i,copyLabel:"Copy command"}),s.jsx("div",{className:"bash-modal-code",children:s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:s.jsx(Wt,{text:i,links:e._projectPathLinks})})})}),s.jsx(zr,{command:i})]}),a&&s.jsxs("div",{className:"bash-modal-section",children:[s.jsx($s,{label:"Output",copyText:a,copyLabel:"Copy output"}),s.jsx("div",{className:"bash-modal-code",children:s.jsx(Ye,{sourceText:a,projectPathLinks:r,sourceView:s.jsx("pre",{className:"code-block",children:s.jsx(pt,{text:a})}),renderRenderedView:c=>Zn(c)})})]}),l&&s.jsxs("div",{className:"bash-modal-section",children:[s.jsx($s,{label:s.jsx("span",{className:"bash-modal-label-error",children:n?"Error":"Stderr"}),copyText:l,copyLabel:n?"Copy error output":"Copy stderr"}),s.jsx("div",{className:"bash-modal-code bash-modal-code-error",children:s.jsx(Ye,{sourceText:l,projectPathLinks:r,sourceView:s.jsx("pre",{className:"code-block code-block-error",children:s.jsx(pt,{text:l})}),renderRenderedView:c=>Zn(c,"code-block code-block-error")})})]}),!a&&!l&&o&&!o.interrupted&&s.jsxs("div",{className:"bash-modal-section",children:[s.jsx("div",{className:"bash-modal-label",children:"Output"}),s.jsx("div",{className:"bash-modal-empty",children:"No output"})]}),(o==null?void 0:o.interrupted)&&s.jsx("div",{className:"bash-modal-section",children:s.jsx("span",{className:"badge badge-warning",children:"Interrupted"})}),(o==null?void 0:o.backgroundTaskId)&&s.jsx("div",{className:"bash-modal-section",children:s.jsxs("span",{className:"badge badge-info",children:["Background: ",o.backgroundTaskId]})}),s.jsx(_l,{result:o})]})}function _l({result:e}){const t=(e==null?void 0:e.exitCode)!==void 0&&e.exitCode!==0,n=(e==null?void 0:e.durationSeconds)!==void 0;return!t&&!n?null:s.jsxs("div",{className:"bash-result-meta-badges",children:[t&&s.jsxs("span",{className:"badge badge-error",children:["rc=",e==null?void 0:e.exitCode]}),n&&(e==null?void 0:e.durationSeconds)!==void 0&&s.jsx("span",{className:"badge badge-info",children:et(e.durationSeconds)})]})}function Nl(e){const t=e.ownerDocument.getSelection();if(!t||t.isCollapsed||t.rangeCount===0)return!1;for(let n=0;n<t.rangeCount;n+=1)if(t.getRangeAt(n).intersectsNode(e))return!0;return!1}function Mt({title:e,actions:t,label:n,briefLabel:r,children:o,onClose:i}){const a=Cd(),l=m.useRef(null),c=s.jsxs(s.Fragment,{children:[t,s.jsx(Rd,{className:"source-detail-action source-detail-icon-action",contentRef:l})]}),d=m.useRef(null);if(a&&(!d.current||d.current.sessionId!==a)&&(d.current={sessionId:a,title:e,actions:c,label:n,briefLabel:r,children:o}),!a)return s.jsx($a,{title:e,actions:c,contentRef:l,onClose:i,children:o});const u=d.current;return u?s.jsx(Td,{sessionId:u.sessionId,title:u.title,actions:u.actions,contentRef:l,label:u.label,briefLabel:u.briefLabel,onClose:i,children:u.children}):null}function Tt({count:e,className:t,tooltip:n}){const r=t?`hidden-content-badge ${t}`:"hidden-content-badge",o=yn(n);return s.jsxs("span",{className:r,...o,children:["+",e]})}const Ci=20,Ti=12,Qp=20,Zp=4e3,kl={html:"",changed:!1},eg=[/^npm warn (?:unknown env config|config)\s+["']recursive["']/i,/^this will stop working in the next major version of npm\.?$/i];function qr(e){return jn(e)}function tg(e,t){const n=e.replace(/\r\n/g,`
58
+ `,o+=a.length+1,i++}return{text:r.trimEnd(),truncated:!1}}function Gp(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5"}),s.jsx("path",{d:"M3 10.5H2.5A1.5 1.5 0 0 1 1 9V2.5A1.5 1.5 0 0 1 2.5 1H9a1.5 1.5 0 0 1 1.5 1.5V3"})]})}function zp(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5 6.5 12 13 4"})})}function ft({text:e,label:t}){const[n,r]=m.useState(!1),o=m.useCallback(async i=>{i.preventDefault(),i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),window.setTimeout(()=>r(!1),3e3)}catch(a){console.error("Failed to copy output section:",a)}},[e]);return s.jsx("button",{type:"button",className:`bash-section-copy ${n?"copied":""}`,onClick:o,disabled:!e,"aria-label":n?"Copied":t,title:n?"Copied":t,children:n?s.jsx(zp,{}):s.jsx(Gp,{})})}function qp(e,t){const n=r=>r.replace(/\/+$/,"");return n(e)===n(t)}function Kp(e,t){const n=rd(e),r=n==null?void 0:n.sessionId;if(!r||r===t.sessionId||n!=null&&n.workingDirectory&&!(t.projectPath&&qp(n.workingDirectory,t.projectPath)))return;const o=t.basePath.replace(/\/$/,"");return{sessionId:r,href:`${o}/projects/${t.projectId}/sessions/${r}`}}const Xp="_link_1xa01_1",Yp="_id_1xa01_20",Si={link:Xp,id:Yp};function zr({command:e}){const{t}=Z(),n=Mr(),r=ge(),o=m.useMemo(()=>r?Kp(e,{basePath:n,projectId:r.projectId,projectPath:r.projectPath,sessionId:r.sessionId}):void 0,[e,n,r]);return o?s.jsxs(vr,{className:Si.link,to:o.href,title:t("nestedHarnessLaunchTitle"),children:[s.jsx("span",{children:t("nestedHarnessLaunchLabel")}),s.jsx("span",{className:Si.id,children:o.sessionId.slice(0,8)})]}):null}const Jp="_fixedWidthOutput_o17ci_1",vl={fixedWidthOutput:Jp};function Zn(e,t="code-block"){return s.jsx("div",{className:`${t} fixed-font-rendered-panel`,children:s.jsx("div",{className:`fixed-font-rendered__content ${vl.fixedWidthOutput}`,dangerouslySetInnerHTML:{__html:e}})})}function $s({label:e,copyText:t,copyLabel:n}){return s.jsxs("div",{className:"bash-section-header",children:[s.jsx("div",{className:"bash-modal-label",children:e}),s.jsx(ft,{text:t,label:n})]})}function wl({input:e,result:t,isError:n,projectPathLinks:r}){const o=typeof t=="string"?Xt(t,n):t,i=jn(e),a=(o==null?void 0:o.stdout)||"",l=(o==null?void 0:o.stderr)||"";return s.jsxs("div",{className:"bash-modal-sections",children:[s.jsxs("div",{className:"bash-modal-section",children:[s.jsx($s,{label:"Command",copyText:i,copyLabel:"Copy command"}),s.jsx("div",{className:"bash-modal-code",children:s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:s.jsx(Wt,{text:i,links:e._projectPathLinks})})})}),s.jsx(zr,{command:i})]}),a&&s.jsxs("div",{className:"bash-modal-section",children:[s.jsx($s,{label:"Output",copyText:a,copyLabel:"Copy output"}),s.jsx("div",{className:"bash-modal-code",children:s.jsx(Ye,{sourceText:a,projectPathLinks:r,sourceView:s.jsx("pre",{className:"code-block",children:s.jsx(pt,{text:a})}),renderRenderedView:c=>Zn(c)})})]}),l&&s.jsxs("div",{className:"bash-modal-section",children:[s.jsx($s,{label:s.jsx("span",{className:"bash-modal-label-error",children:n?"Error":"Stderr"}),copyText:l,copyLabel:n?"Copy error output":"Copy stderr"}),s.jsx("div",{className:"bash-modal-code bash-modal-code-error",children:s.jsx(Ye,{sourceText:l,projectPathLinks:r,sourceView:s.jsx("pre",{className:"code-block code-block-error",children:s.jsx(pt,{text:l})}),renderRenderedView:c=>Zn(c,"code-block code-block-error")})})]}),!a&&!l&&o&&!o.interrupted&&s.jsxs("div",{className:"bash-modal-section",children:[s.jsx("div",{className:"bash-modal-label",children:"Output"}),s.jsx("div",{className:"bash-modal-empty",children:"No output"})]}),(o==null?void 0:o.interrupted)&&s.jsx("div",{className:"bash-modal-section",children:s.jsx("span",{className:"badge badge-warning",children:"Interrupted"})}),(o==null?void 0:o.backgroundTaskId)&&s.jsx("div",{className:"bash-modal-section",children:s.jsxs("span",{className:"badge badge-info",children:["Background: ",o.backgroundTaskId]})}),s.jsx(_l,{result:o})]})}function _l({result:e}){const t=(e==null?void 0:e.exitCode)!==void 0&&e.exitCode!==0,n=(e==null?void 0:e.durationSeconds)!==void 0;return!t&&!n?null:s.jsxs("div",{className:"bash-result-meta-badges",children:[t&&s.jsxs("span",{className:"badge badge-error",children:["rc=",e==null?void 0:e.exitCode]}),n&&(e==null?void 0:e.durationSeconds)!==void 0&&s.jsx("span",{className:"badge badge-info",children:et(e.durationSeconds)})]})}function Nl(e){const t=e.ownerDocument.getSelection();if(!t||t.isCollapsed||t.rangeCount===0)return!1;for(let n=0;n<t.rangeCount;n+=1)if(t.getRangeAt(n).intersectsNode(e))return!0;return!1}function Mt({title:e,actions:t,label:n,briefLabel:r,children:o,onClose:i}){const a=pd(),l=m.useRef(null),c=s.jsxs(s.Fragment,{children:[t,s.jsx(Ad,{className:"source-detail-action source-detail-icon-action",contentRef:l})]}),d=m.useRef(null);if(a&&(!d.current||d.current.sessionId!==a)&&(d.current={sessionId:a,title:e,actions:c,label:n,briefLabel:r,children:o}),!a)return s.jsx(La,{title:e,actions:c,contentRef:l,onClose:i,children:o});const u=d.current;return u?s.jsx(gd,{sessionId:u.sessionId,title:u.title,actions:u.actions,contentRef:l,label:u.label,briefLabel:u.briefLabel,onClose:i,children:u.children}):null}function Tt({count:e,className:t,tooltip:n}){const r=t?`hidden-content-badge ${t}`:"hidden-content-badge",o=yn(n);return s.jsxs("span",{className:r,...o,children:["+",e]})}const Ci=20,Ti=12,Qp=20,Zp=4e3,kl={html:"",changed:!1},eg=[/^npm warn (?:unknown env config|config)\s+["']recursive["']/i,/^this will stop working in the next major version of npm\.?$/i];function qr(e){return jn(e)}function tg(e,t){const n=e.replace(/\r\n/g,`
59
59
  `);if(!Wp(t))return n;const o=n.split(`
60
60
  `).filter(i=>{const a=i.trim();return a?!eg.some(l=>l.test(a)):!1});return o.length===0?n:o.join(`
61
61
  `)}function ng({input:e}){const t=qr(e),[n,r]=m.useState(!1),o=t.split(`
62
62
  `),i=o.length>Ti,a=i&&!n?`${o.slice(0,Ti).join(`
63
63
  `)}
64
- ...`:t,l=rt(a);return s.jsxs("div",{className:"bash-tool-use",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:"Command"}),s.jsx(ft,{text:t,label:"Copy command"})]}),s.jsx("pre",{ref:l,className:"code-block",children:s.jsx("code",{children:s.jsx(Wt,{text:a,links:e._projectPathLinks})})}),s.jsx(zr,{command:t}),i&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!n),children:n?"Show less":`Show all ${o.length} lines`})]})}function sg({result:e,isError:t,input:n,projectPathLinks:r}){const[o,i]=m.useState(!1),{enabled:a,reportValidationError:l,isToolIgnored:c}=ve(),[d,u]=m.useState(null),f=typeof e=="string"?Xt(e,t):e;m.useEffect(()=>{if(a&&e&&typeof e=="object"){const k=we("Bash",e);!k.valid&&k.errors?(u(k.errors),l("Bash",k.errors)):u(null)}},[a,e,l]);const h=a&&d&&!c("Bash"),g=f.stdout||"",p=f.stderr||"",y=n?qr(n):"",x=rt(y),b=ge(),_=g.split(`
64
+ ...`:t,l=st(a);return s.jsxs("div",{className:"bash-tool-use",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:"Command"}),s.jsx(ft,{text:t,label:"Copy command"})]}),s.jsx("pre",{ref:l,className:"code-block",children:s.jsx("code",{children:s.jsx(Wt,{text:a,links:e._projectPathLinks})})}),s.jsx(zr,{command:t}),i&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!n),children:n?"Show less":`Show all ${o.length} lines`})]})}function sg({result:e,isError:t,input:n,projectPathLinks:r}){const[o,i]=m.useState(!1),{enabled:a,reportValidationError:l,isToolIgnored:c}=ve(),[d,u]=m.useState(null),f=typeof e=="string"?Xt(e,t):e;m.useEffect(()=>{if(a&&e&&typeof e=="object"){const k=we("Bash",e);!k.valid&&k.errors?(u(k.errors),l("Bash",k.errors)):u(null)}},[a,e,l]);const h=a&&d&&!c("Bash"),g=f.stdout||"",p=f.stderr||"",y=n?qr(n):"",x=st(y),b=ge(),_=g.split(`
65
65
  `),N=m.useMemo(()=>mn(g,{projectId:b==null?void 0:b.projectId,projectPath:(b==null?void 0:b.projectPath)??void 0,projectPathLinks:r}),[g,b==null?void 0:b.projectId,b==null?void 0:b.projectPath,r]),v=m.useMemo(()=>mn(p,{projectId:b==null?void 0:b.projectId,projectPath:(b==null?void 0:b.projectPath)??void 0,projectPathLinks:r}),[p,b==null?void 0:b.projectId,b==null?void 0:b.projectPath,r]),j=_.length>Ci,C=j&&!o?`${_.slice(0,Ci).join(`
66
66
  `)}
67
67
  ...`:g,w=N.changed?g:C;return s.jsxs("div",{className:`bash-result ${t?"bash-result-error":""}`,children:[h&&d&&s.jsx(q,{toolName:"Bash",errors:d}),y&&s.jsxs("div",{className:"bash-expanded-section bash-expanded-command-section",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:"Command"}),s.jsx(ft,{text:y,label:"Copy command"})]}),s.jsx("pre",{ref:x,className:"code-block",children:s.jsx("code",{children:s.jsx(Wt,{text:y,links:n==null?void 0:n._projectPathLinks})})}),s.jsx(zr,{command:y})]}),(f==null?void 0:f.interrupted)&&s.jsx("span",{className:"badge badge-warning",children:"Interrupted"}),(f==null?void 0:f.backgroundTaskId)&&s.jsxs("span",{className:"badge badge-info",children:["Background: ",f.backgroundTaskId]}),s.jsx(_l,{result:f}),g&&s.jsxs("div",{className:"bash-stdout bash-expanded-section",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:"Output"}),s.jsx(ft,{text:g,label:"Copy output"})]}),s.jsx(Ye,{sourceText:w,projectPathLinks:r,precomputedRendered:w===g?N:kl,sourceView:s.jsx("pre",{className:"code-block",children:s.jsx(pt,{text:C})}),renderRenderedView:k=>Zn(k)}),j&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>i(!o),children:o?"Show less":`Show all ${_.length} lines`})]}),p&&s.jsxs("div",{className:"bash-stderr bash-expanded-section",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:t?"Error":"Stderr"}),s.jsx(ft,{text:p,label:t?"Copy error output":"Copy stderr"})]}),s.jsx(Ye,{sourceText:p,projectPathLinks:r,precomputedRendered:v,sourceView:s.jsx("pre",{className:"code-block code-block-error",children:s.jsx(pt,{text:p})}),renderRenderedView:k=>Zn(k,"code-block code-block-error")})]}),!g&&!p&&!(f!=null&&f.interrupted)&&s.jsx("div",{className:"bash-empty",children:"No output"})]})}function rg(e){return e._previewResult}function og({input:e,result:t,isError:n,provider:r,projectPathLinks:o}){const[i,a]=m.useState(!1),l=us(),{enabled:c,reportValidationError:d,isToolIgnored:u}=ve(),[f,h]=m.useState(null),g=t??rg(e),p=typeof g=="string"?Xt(g,n):g;m.useEffect(()=>{if(c&&t&&typeof t=="object"){const R=we("Bash",t);!R.valid&&R.errors?(h(R.errors),d("Bash",R.errors)):h(null)}},[c,t,d]);const y=c&&f&&!u("Bash"),x=ge(),b=!!(p!=null&&p.stderr),_=tg((b?p==null?void 0:p.stderr:p==null?void 0:p.stdout)||"",r),N=m.useMemo(()=>mn(_,{projectId:x==null?void 0:x.projectId,projectPath:(x==null?void 0:x.projectPath)??void 0,projectPathLinks:o}),[_,x==null?void 0:x.projectId,x==null?void 0:x.projectPath,o]),{text:v,truncated:j}=bl(_,N.changed?{maxLines:Qp,maxChars:Zp}:yl(l)),C=jl(_,l),w=Yt(_,l),k=m.useMemo(()=>v===_?N:N.changed?mn(v,{projectId:x==null?void 0:x.projectId,projectPath:(x==null?void 0:x.projectPath)??void 0,projectPathLinks:o}):kl,[v,_,N,x==null?void 0:x.projectId,x==null?void 0:x.projectPath,o]),S=v.length>0,$=m.useCallback(R=>{var K;const D=R.target;(K=D==null?void 0:D.closest)!=null&&K.call(D,"button,a")||Nl(R.currentTarget)||a(!0)},[]),T=m.useCallback(R=>{R.target===R.currentTarget&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),a(!0))},[]),E=m.useCallback(()=>{a(!1)},[]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{role:"button",tabIndex:0,"aria-label":"View bash command output",className:"bash-collapsed-preview",onClick:$,onKeyDown:T,children:[y&&f&&s.jsx("div",{className:"bash-preview-row bash-preview-warning-row",children:s.jsx(q,{toolName:"Bash",errors:f})}),S&&s.jsxs("div",{className:"bash-preview-row bash-preview-output-row",children:[s.jsxs("div",{className:`bash-preview-output ${j?"bash-preview-truncated":""} ${b?"bash-preview-error":""}`,style:{"--bash-preview-line-count":String(l)},children:[s.jsx(Ye,{sourceText:v,projectPathLinks:o,precomputedRendered:k,sourceView:s.jsx("pre",{children:s.jsx(pt,{text:v,compact:!0})}),renderRenderedView:R=>s.jsx("pre",{children:s.jsx("div",{className:`fixed-font-rendered__content ${vl.fixedWidthOutput}`,dangerouslySetInnerHTML:{__html:R}})})}),j&&s.jsx("div",{className:"bash-preview-fade"})]}),s.jsx(ft,{text:_,label:b?"Copy stderr":"Copy output"}),C>0&&s.jsx(Tt,{className:"bash-preview-more",count:C,tooltip:w??_})]}),!S&&p&&!p.interrupted&&s.jsx("div",{className:"bash-preview-row",children:s.jsx("span",{className:"bash-preview-empty",children:"No output"})}),(p==null?void 0:p.interrupted)&&s.jsx("div",{className:"bash-preview-row",children:s.jsx("span",{className:"bash-preview-interrupted",children:"Interrupted"})})]}),i&&s.jsx(Mt,{title:e.description||"Bash Command",label:e.description||"Bash Command",onClose:E,children:s.jsx(wl,{input:e,result:p,isError:n,projectPathLinks:o})})]})}const ig=de(fe.Bash,{tool:"Bash",displayName:"Ran",pendingDisplayName:"Run",displayNameForCall(e,t){return t!=="complete"?void 0:e._backgroundTaskStatus==="running"?"Running":void 0},renderToolUse(e,t){return s.jsx(ng,{input:e})},renderToolResult(e,t,n,r){return s.jsx(sg,{result:e,isError:t,input:r,projectPathLinks:n.projectPathLinks})},getUseSummary(e){const t=e,n=qr(t);if(t.description)return t.description;if(!n)return"Bash command";const r=n.split(`
68
68
  `)[0]??n;return r.length>200?`${r.slice(0,200)}...`:n.includes(`
69
- `)?`${r}...`:n},getResultSummary(e,t){const n=e;return n!=null&&n.interrupted?"Interrupted":t||n!=null&&n.stderr?"Error":""},renderCollapsedPreview(e,t,n,r){return s.jsx(og,{input:e,result:t,isError:n,provider:r.provider,projectPathLinks:r.projectPathLinks})}}),ag="_output_1nrzt_1",lg="_text_1nrzt_7",cg="_error_1nrzt_21",dg="_metadata_1nrzt_25",ug="_document_1nrzt_32",mg="_summary_1nrzt_38",fg="_description_1nrzt_44",Ee={output:ag,text:lg,error:cg,metadata:dg,document:ug,summary:mg,description:fg};function hn(e){return e!==void 0}function Sl(e){if(e.toolName==="exec_command"&&e.input&&typeof e.input=="object"){const t=e.input.cmd;if(typeof t=="string"&&t.trim())return t.trim()}return e.toolName}function Ri(e){if(!hn(e)||e.calls.length===0)return"done";const t=e.calls.every(o=>o.toolName==="exec_command")?"command":"tool call",n=[...new Set(e.calls.flatMap(o=>{const i=Kr(o);return i?[`${i.name}/SKILL.md`]:[]}))],r=`${e.calls.length} ${t}${e.calls.length===1?"":"s"}`;return n.length?`${n.join(", ")} · ${r}`:r}function Kr(e){if(e.toolName!=="exec_command")return;const t=/^cat\s+(?:'([^']+)'|"([^"$`]+)"|([^\s;|&<>"'$`]+))(?=\s|;|$)([\s\S]*)$/.exec(Sl(e));if(!t)return;const r=(t[1]??t[2]??t[3]??"").split(/[\\/]/),o=r.at(-2);if(!(!o||r.at(-1)!=="SKILL.md"))return{name:o,onlyRead:/^\s*;?\s*$/.test(t[4]??"")}}function hg(e){var o,i;const t=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(e);if(!t)return;const n=(o=/^name:\s*([\w.-]+)\s*$/m.exec(t[1]??""))==null?void 0:o[1];if(!n)return;const r=(i=/^description:[ \t]*(.+)$/m.exec(t[1]??""))==null?void 0:i[1];return{name:n,description:r}}function Xr({result:e,isError:t,input:n,shellMetadata:r=!1}){const{t:o}=Z(),i=typeof e=="string"?e:JSON.stringify(e,null,2),a=ht(e),l=hn(n)&&n.calls.some(c=>Kr(c));return a?s.jsxs("div",{className:`${Ee.output} ${t?Ee.error:""}`,children:[a.parts.map((c,d)=>{var y;const u=c.kind==="command-output"?c:void 0,{text:f}=c,h=l?hg(f):void 0,g=h?o("codeModeExecSkill",{name:h.name}):Pd(f.split(`
69
+ `)?`${r}...`:n},getResultSummary(e,t){const n=e;return n!=null&&n.interrupted?"Interrupted":t||n!=null&&n.stderr?"Error":""},renderCollapsedPreview(e,t,n,r){return s.jsx(og,{input:e,result:t,isError:n,provider:r.provider,projectPathLinks:r.projectPathLinks})}}),ag="_output_1nrzt_1",lg="_text_1nrzt_7",cg="_error_1nrzt_21",dg="_metadata_1nrzt_25",ug="_document_1nrzt_32",mg="_summary_1nrzt_38",fg="_description_1nrzt_44",Ee={output:ag,text:lg,error:cg,metadata:dg,document:ug,summary:mg,description:fg};function hn(e){return e!==void 0}function Sl(e){if(e.toolName==="exec_command"&&e.input&&typeof e.input=="object"){const t=e.input.cmd;if(typeof t=="string"&&t.trim())return t.trim()}return e.toolName}function Ri(e){if(!hn(e)||e.calls.length===0)return"done";const t=e.calls.every(o=>o.toolName==="exec_command")?"command":"tool call",n=[...new Set(e.calls.flatMap(o=>{const i=Kr(o);return i?[`${i.name}/SKILL.md`]:[]}))],r=`${e.calls.length} ${t}${e.calls.length===1?"":"s"}`;return n.length?`${n.join(", ")} · ${r}`:r}function Kr(e){if(e.toolName!=="exec_command")return;const t=/^cat\s+(?:'([^']+)'|"([^"$`]+)"|([^\s;|&<>"'$`]+))(?=\s|;|$)([\s\S]*)$/.exec(Sl(e));if(!t)return;const r=(t[1]??t[2]??t[3]??"").split(/[\\/]/),o=r.at(-2);if(!(!o||r.at(-1)!=="SKILL.md"))return{name:o,onlyRead:/^\s*;?\s*$/.test(t[4]??"")}}function hg(e){var o,i;const t=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(e);if(!t)return;const n=(o=/^name:\s*([\w.-]+)\s*$/m.exec(t[1]??""))==null?void 0:o[1];if(!n)return;const r=(i=/^description:[ \t]*(.+)$/m.exec(t[1]??""))==null?void 0:i[1];return{name:n,description:r}}function Xr({result:e,isError:t,input:n,shellMetadata:r=!1}){const{t:o}=Z(),i=typeof e=="string"?e:JSON.stringify(e,null,2),a=ht(e),l=hn(n)&&n.calls.some(c=>Kr(c));return a?s.jsxs("div",{className:`${Ee.output} ${t?Ee.error:""}`,children:[a.parts.map((c,d)=>{var y;const u=c.kind==="command-output"?c:void 0,{text:f}=c,h=l?hg(f):void 0,g=h?o("codeModeExecSkill",{name:h.name}):Fd(f.split(`
70
70
  `,1)[0]??"")||(y=/^# ([^\r\n]+)\r?\n/.exec(f))==null?void 0:y[1];if(c.kind==="script-status")return s.jsx("p",{className:Ee.metadata,children:f},d);const p=[(u==null?void 0:u.exitCode)!==void 0&&(!r||u.exitCode!==0)?r?`rc=${u.exitCode}`:o("codeModeExecExitCode",{code:u.exitCode}):"",(u==null?void 0:u.durationSeconds)!==void 0?et(u.durationSeconds):""].filter(Boolean).join(" · ");return s.jsxs("div",{className:u!=null&&u.exitCode?Ee.error:void 0,children:[p&&s.jsx("p",{className:Ee.metadata,children:p}),g?s.jsxs("details",{className:Ee.document,children:[s.jsx("summary",{className:Ee.summary,children:g}),(h==null?void 0:h.description)&&s.jsx("p",{className:Ee.description,children:h.description}),s.jsx("pre",{className:Ee.text,children:f})]}):s.jsx("pre",{className:Ee.text,children:s.jsx(pt,{text:f})})]},d)}),s.jsxs("details",{className:Ee.document,children:[s.jsx("summary",{className:Ee.summary,children:o("codeModeExecRaw")}),hn(n)&&s.jsx("pre",{className:Ee.text,children:n.source}),s.jsx("pre",{className:Ee.text,children:i})]})]}):s.jsx("pre",{className:`${Ee.text} ${t?Ee.error:""}`,children:i})}const pg=de(fe.Exec,{tool:"Exec",displayName:"Exec",displayNameForCall(e,t){if(hn(e)&&e.calls.length>0&&e.calls.every(n=>{var r;return(r=Kr(n))==null?void 0:r.onlyRead}))return t==="pending"?"Loading skill":"Skill load"},renderToolUse(e){return hn(e)?s.jsx("pre",{className:Ee.text,children:s.jsx("code",{children:e.calls.map(Sl).join(`
71
71
  `)})}):null},renderToolResult(e,t,n,r){return s.jsx(Xr,{result:e,isError:t,input:r})},getUseSummary(e){return Ri(e)},getResultSummary(e,t,n){return t?"failed":Ri(n)}});function es(e){return e.split(`
72
72
  `)}function Ls(e){return e.replace(/\s/g,"")}function gg(e,t){if(t.length===0)return[];const n=[];let r=0;for(;r<=e.length-t.length;){const o=e.indexOf(t,r);if(o===-1)break;n.push({start:o,end:o+t.length}),r=o+1}return n}function xg(e,t){const n=es(e),r=es(t);if(r.length===0||n.length<r.length)return[];if(!r.some(c=>Ls(c).length>0))return[];const o=n.map(Ls),i=r.map(Ls),a=[],l=o.length-i.length;for(let c=0;c<=l;c+=1){let d=!0;for(let u=0;u<i.length;u+=1)if(o[c+u]!==i[u]){d=!1;break}d&&a.push({start:c,end:c+i.length})}return a}function yg(e,t){const n=xg(e,t);return n.length===1?n[0]??null:null}function jg(e,t,n){return e.slice(0,t.start)+n+e.slice(t.end)}function bg(e,t,n){const r=es(e);return[...r.slice(0,t.start),...n===""?[]:es(n),...r.slice(t.end)].join(`
@@ -77,44 +77,44 @@ ${o.slice(-i).join(`
77
77
  `;return n&&r&&t.end<e.length&&e[t.end]===`
78
78
  `?{start:t.start,end:t.end+1}:t}function As(e,t,n){if(t.kind==="exact"){const r=n===""?wg(e,t.span):t.span;return jg(e,r,n)}return bg(e,t.block,n)}function _g(e){const t=Cl(e.oldString,e.newString,e.structuredPatch);if(!t)return null;const n=Pi(e.currentFile,t.newString);if((n==null?void 0:n.kind)==="ambiguous")return null;if(n)return{originalFile:As(e.currentFile,n,t.oldString),editedFile:e.currentFile};const r=Pi(e.currentFile,t.oldString);return(r==null?void 0:r.kind)==="ambiguous"?null:r?{originalFile:As(e.currentFile,r,t.oldString),editedFile:As(e.currentFile,r,t.newString)}:null}function Ng(e){const{projectId:t}=gs(),[n,r]=m.useState(!1),[o,i]=m.useState(null),[a,l]=m.useState(null),c=m.useCallback(async()=>{r(!0),i(null);const d=typeof e.originalFile=="string"&&e.originalFile.length>0?e.originalFile:null;let u=null;const f=Cl(e.oldString,e.newString,e.structuredPatch)??{oldString:e.oldString,newString:e.newString};try{let h;if(d!==null)h=await on.expandDiffContext(t,e.filePath,f.oldString,f.newString,d);else{u=(await on.getFile(t,e.filePath)).content??"";const p=_g({currentFile:u,oldString:f.oldString,newString:f.newString,structuredPatch:e.structuredPatch});if(p===null){l({kind:"file",content:u});return}h=await on.expandDiffContext(t,e.filePath,p.originalFile,p.editedFile,p.originalFile)}l({kind:"diff",structuredPatch:h.structuredPatch,diffHtml:h.diffHtml})}catch(h){if(u!==null){l({kind:"file",content:u});return}i(h instanceof Error?h.message:"Failed to expand context")}finally{r(!1)}},[e.filePath,e.newString,e.oldString,e.originalFile,e.structuredPatch,t]);return{loading:n,error:o,result:a,fetchExpandedDiff:c}}const kg=[{pattern:/^User denied permission\.?$/i,classification:"user_rejection",label:"Declined"},{pattern:/^User did not (approve|allow|permit)/i,classification:"user_rejection",label:"Declined"},{pattern:/^Permission denied by user/i,classification:"user_rejection",label:"Declined"},{pattern:/^Rejected by user/i,classification:"user_rejection",label:"Declined"},{pattern:/^The user doesn't want to proceed/i,classification:"user_rejection",label:"Declined"},{pattern:/^The user doesn't want to take this action/i,classification:"user_rejection",label:"Declined"},{pattern:/^\[Request interrupted by user/i,classification:"user_rejection",label:"Interrupted"},{pattern:/^User cancelled/i,classification:"user_rejection",label:"Cancelled"},{pattern:/^Plan mode - tools not executed/i,classification:"user_rejection",label:"Plan mode"},{pattern:/^Exit code [1-9]\d*/,classification:"command_failure",label:"Exit code"},{pattern:/ELIFECYCLE.*Command failed/,classification:"command_failure",label:"Command failed"},{pattern:/command not found/i,classification:"command_failure",label:"Not found"},{pattern:/Shell \d+ is not running/i,classification:"command_failure",label:"Shell stopped"},{pattern:/<tool_use_error>.*No shell found/i,classification:"command_failure",label:"Shell not found"},{pattern:/<tool_use_error>.*No task found/i,classification:"command_failure",label:"Task not found"},{pattern:/<tool_use_error>.*File has been modified since read/i,classification:"file_error",label:"File changed"},{pattern:/^File has been unexpectedly modified/i,classification:"file_error",label:"File changed"},{pattern:/<tool_use_error>.*File has not been read yet/i,classification:"file_error",label:"Not read yet"},{pattern:/<tool_use_error>.*File does not exist/i,classification:"file_error",label:"Not found"},{pattern:/<tool_use_error>.*No such file or directory/i,classification:"file_error",label:"Not found"},{pattern:/<tool_use_error>.*Permission denied/i,classification:"file_error",label:"Permission denied"},{pattern:/ENOENT/,classification:"file_error",label:"Not found"},{pattern:/EACCES/,classification:"file_error",label:"Permission denied"},{pattern:/No plan file found/i,classification:"file_error",label:"Plan not found"},{pattern:/<tool_use_error>.*Path does not exist/i,classification:"file_error",label:"Path not found"},{pattern:/<tool_use_error>.*old_string.*not found/i,classification:"validation_error",label:"Not found"},{pattern:/<tool_use_error>.*not unique/i,classification:"validation_error",label:"Not unique"},{pattern:/<tool_use_error>.*Found \d+ matches.*replace_all is false/i,classification:"validation_error",label:"Multiple matches"},{pattern:/<tool_use_error>.*InputValidationError/i,classification:"validation_error",label:"Invalid input"},{pattern:/Invalid (input|parameter|argument)/i,classification:"validation_error",label:"Invalid input"},{pattern:/<tool_use_error>.*No changes to make.*old_string and new_string are exactly the same/i,classification:"validation_error",label:"No changes"},{pattern:/<tool_use_error>.*String to replace not found/i,classification:"validation_error",label:"Not found"},{pattern:/File content.*exceeds maximum/i,classification:"validation_error",label:"Too large"},{pattern:/<tool_use_error>.*exceeds maximum allowed/i,classification:"validation_error",label:"Too large"},{pattern:/Agent type .* not found/i,classification:"validation_error",label:"Unknown agent"},{pattern:/^Request failed with status code/i,classification:"network_error",label:"Request failed"},{pattern:/ECONNREFUSED/,classification:"network_error",label:"Connection refused"},{pattern:/ENOTFOUND/,classification:"network_error",label:"Not found"},{pattern:/fetch failed/i,classification:"network_error",label:"Fetch failed"},{pattern:/Tool permission request failed/i,classification:"network_error",label:"Connection lost"},{pattern:/timed? ?out/i,classification:"timeout",label:"Timeout"},{pattern:/ETIMEDOUT/,classification:"timeout",label:"Timeout"}];function On(e){let t=e;return t=t.replace(/^Error:\s*/i,""),t=t.replace(/<\/?tool_use_error>/gi,""),t=t.trim(),t}function Sg(e){const t=e.match(/provided the following reason[^:]*:\s*(.+)/is);if(t!=null&&t[1])return t[1].trim()}function Cg(e){const t=On(e);return t.length>200||/exit code|ENOENT|EACCES|<tool_use_error>|command failed|permission denied|not found|does not exist/i.test(t)?!1:/^[a-zA-Z]/.test(t)&&t.includes(" ")&&!/^[A-Z_]+:/.test(t)&&!/\n.*\n/.test(t)}function vs(e){for(const{pattern:t,classification:n,label:r}of kg)if(t.test(e)){const o=On(e);if(n==="user_rejection"){const i=Sg(e);if(i)return{classification:"user_rejection_with_reason",cleanedMessage:o,userReason:i,label:r}}return{classification:n,cleanedMessage:o,label:r}}if(Cg(e)){const t=On(e);return{classification:"user_rejection_with_reason",cleanedMessage:t,userReason:t,label:"Declined"}}return{classification:"unknown",cleanedMessage:On(e),label:"Error"}}function Tl(e){switch(e){case"user_rejection":case"user_rejection_with_reason":return"muted";default:return"warning"}}function Rl(e){return e==="user_rejection"||e==="user_rejection_with_reason"}function Tg(e,t){if(e.slice(t.start,t.end)===t.text)return{start:t.start,end:t.end};let n=-1,r=Number.POSITIVE_INFINITY,o=e.indexOf(t.text);for(;o>=0;){const i=Math.abs(o-t.start);i<r&&(r=i,n=o),o=e.indexOf(t.text,o+1)}return n>=0?{start:n,end:n+t.text.length}:null}function Ei(e,t){var i,a;const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o=null;for(let l=n.nextNode();l;l=n.nextNode()){o=l;const c=((i=l.textContent)==null?void 0:i.length)??0;if(t<=r+c)return{node:l,offset:t-r};r+=c}return o?{node:o,offset:((a=o.textContent)==null?void 0:a.length)??0}:null}function Rg(e){var c;const t=e.querySelector(".fixed-font-render-toggle"),n=t==null?void 0:t.dataset.renderMode,r=e.ownerDocument.getSelection();if(!t||n!=="rendered"&&n!=="source"||!r||r.isCollapsed||r.rangeCount===0)return null;const o=r.getRangeAt(0);if(!t.contains(o.startContainer)||!t.contains(o.endContainer))return null;const i=t.ownerDocument.createRange();i.selectNodeContents(t),i.setEnd(o.startContainer,o.startOffset);const a=((c=i.cloneContents().textContent)==null?void 0:c.length)??0,l=o.cloneContents().textContent??"";return l?{start:a,end:a+l.length,renderMode:n,text:l}:null}function Pg(e,t){const n=e.querySelector(".fixed-font-render-toggle");if(!n)return!1;const r=Tg(n.textContent??"",t);if(!r)return!1;const o=Ei(n,r.start),i=Ei(n,r.end);if(!o||!i)return!1;const a=n.ownerDocument.createRange();a.setStart(o.node,o.offset),a.setEnd(i.node,i.offset);const l=n.ownerDocument.getSelection();return l?(l.removeAllRanges(),l.addRange(a),!0):!1}const Ae=12;function ts(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Eg(e){if(typeof e=="string")return e;if(!ts(e))return;const t=e._rawPatch;return typeof t=="string"?t:void 0}function Yr(e){if(typeof e!="string"||e.trim().length===0)return[];const t=[],n=new Set,r=e.replace(/\r\n/g,`
79
79
  `).split(`
80
- `);for(const o of r){const i=o.match(/^\*\*\*\s+(?:Update File|Add File|Delete File|Move to):\s+(.+?)\s*$/);if(i!=null&&i[1]){const a=i[1].trim();a&&!n.has(a)&&(n.add(a),t.push(a))}}return t}function Ig(e){if(!ts(e)||!Array.isArray(e.changes))return[];const t=[],n=new Set;for(const r of e.changes){if(!ts(r)||typeof r.path!="string")continue;const o=r.path.trim();o&&!n.has(o)&&(n.add(o),t.push(o))}return t}function Rt(e,t){const n=[],r=new Set,o=i=>{if(typeof i!="string")return;const a=i.trim();!a||r.has(a)||(r.add(a),n.push(a))};o(t==null?void 0:t.filePath),ts(e)&&o(e.file_path);for(const i of Yr(Eg(e)))o(i);for(const i of Ig(e))o(i);return n}function Vt(e,t){return Rt(e,t)[0]??""}function Pt(e){return e.length>0&&e.every(Er)?"rich":"math"}function Ii({filePath:e}){const t=ge();return!(t!=null&&t.projectId)||!e?null:s.jsx(Ta,{projectId:t.projectId,filePath:e})}function _t(e){if(typeof e!="string")return"Patch";const t=e.trim();return t?tt(t):"Patch"}function ur(e,t){const n=Rt(e,t),r=n[0];if(!r)return"Patch";const o=_t(r);return n.length<=1?o:`${o} +${n.length-1} files`}function Mg(e,t,n){const r=Pl(e,t,n);return r.length>0?r.join(`
80
+ `);for(const o of r){const i=o.match(/^\*\*\*\s+(?:Update File|Add File|Delete File|Move to):\s+(.+?)\s*$/);if(i!=null&&i[1]){const a=i[1].trim();a&&!n.has(a)&&(n.add(a),t.push(a))}}return t}function Ig(e){if(!ts(e)||!Array.isArray(e.changes))return[];const t=[],n=new Set;for(const r of e.changes){if(!ts(r)||typeof r.path!="string")continue;const o=r.path.trim();o&&!n.has(o)&&(n.add(o),t.push(o))}return t}function Rt(e,t){const n=[],r=new Set,o=i=>{if(typeof i!="string")return;const a=i.trim();!a||r.has(a)||(r.add(a),n.push(a))};o(t==null?void 0:t.filePath),ts(e)&&o(e.file_path);for(const i of Yr(Eg(e)))o(i);for(const i of Ig(e))o(i);return n}function Vt(e,t){return Rt(e,t)[0]??""}function Pt(e){return e.length>0&&e.every(Sr)?"rich":"math"}function Ii({filePath:e}){const t=ge();return!(t!=null&&t.projectId)||!e?null:s.jsx(Ra,{projectId:t.projectId,filePath:e})}function _t(e){if(typeof e!="string")return"Patch";const t=e.trim();return t?tt(t):"Patch"}function ur(e,t){const n=Rt(e,t),r=n[0];if(!r)return"Patch";const o=_t(r);return n.length<=1?o:`${o} +${n.length-1} files`}function Mg(e,t,n){const r=Pl(e,t,n);return r.length>0?r.join(`
81
81
  `):void 0}function Pl(e,t,n){return Rt(e,t).map(r=>oe(r,n))}function $g(e){return e.includes(".claude/plans/")}function El(e){if(!e||e.length===0)return null;const t=e.flatMap(r=>r.lines).filter(r=>r.startsWith("+")).length,n=e.flatMap(r=>r.lines).filter(r=>r.startsWith("-")).length;return t>0&&n>0?`Modified ${t+n} lines`:t>0?`Added ${t} line${t!==1?"s":""}`:n>0?`Removed ${n} line${n!==1?"s":""}`:null}function pn(e){if(!e||e.length===0)return;let t=null,n=null;for(const r of e){const o=Math.max(1,r.newStart||1),i=o+Math.max(1,r.newLines||1)-1;t=t===null?o:Math.min(t,o),n=n===null?i:Math.max(n,i)}if(!(t===null||n===null))return{lineNumber:t,lineEnd:n>t?n:void 0}}function Lg(e){const t=e.split(`
82
82
  `),n=[];for(const r of t){const o=r[0];if(o!=="-"){if(o==="+"||o===" "){n.push(r.slice(1));continue}r.trim().length>0&&!r.startsWith("@@")&&n.push(r)}}return n.join(`
83
83
  `)}function Ag(e,t){const n=e.split(`
84
84
  `);return n.length<=t?{hiddenLineCount:0,text:e,truncated:!1}:{hiddenLineCount:n.length-t,text:n.slice(0,t).join(`
85
85
  `),truncated:!0}}function Jr(e,t){return s.jsx("div",{className:`${t} fixed-font-rendered-panel`,children:s.jsx("div",{className:"fixed-font-rendered__content",dangerouslySetInnerHTML:{__html:e}})})}function Mi({text:e}){const[t,n]=m.useState(!1),r=m.useCallback(async o=>{o.preventDefault(),o.stopPropagation(),await navigator.clipboard.writeText(e),n(!0),window.setTimeout(()=>n(!1),2e3)},[e]);return s.jsx("button",{type:"button",className:`diff-copy-button ${t?"copied":""}`,onMouseDown:o=>o.stopPropagation(),onClick:r,"aria-label":"Copy post-change text",title:"Copy post-change text",children:t?s.jsx(Bg,{}):s.jsx(Fg,{})})}function Fg(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"9",height:"9",rx:"1.5"}),s.jsx("path",{d:"M11 5V3.5A1.5 1.5 0 0 0 9.5 2H3.5A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5"})]})}function Bg(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5 6.5 12 13 4"})})}function Et({sourceText:e,sourceView:t,truncated:n=!1,diffAware:r=!0,baseFilePath:o,renderMode:i,initialMode:a,copyText:l,hiddenLineCount:c=0}){const d=l??(r?Lg(e):e),u=i??Pt(o?[o]:[]),f=n?Yt(e,Ae):null,h=ms(e,f);return s.jsx(Ye,{sourceText:e,diffAware:r,baseFilePath:o,renderMode:u,initialMode:a,sourceView:s.jsxs("div",{className:`diff-view-container diff-gutter-aligned ${n?"truncated":""}`,...h,children:[s.jsx("div",{className:"diff-view",children:t}),d&&s.jsx(Mi,{text:d}),n&&s.jsx("div",{className:"diff-fade-overlay"}),c>0&&s.jsx(Tt,{className:"edit-preview-more",count:c,tooltip:f??e})]}),renderRenderedView:g=>s.jsxs("div",{className:`diff-view-container diff-gutter-aligned ${n?"truncated":""}`,...h,children:[s.jsx("div",{className:"diff-view",children:Jr(g,"diff-content")}),d&&s.jsx(Mi,{text:d}),n&&s.jsx("div",{className:"diff-fade-overlay"}),c>0&&s.jsx(Tt,{className:"edit-preview-more",count:c,tooltip:f??e})]})})}function Il(e,t){m.useEffect(()=>{if(!t)return;const n=window.requestAnimationFrame(()=>{e.current&&Pg(e.current,t)});return()=>window.cancelAnimationFrame(n)},[e,t])}function an({label:e,onOpen:t,children:n}){const r=o=>{const i=o.ownerDocument.getSelection();if(!i||i.isCollapsed)return!1;for(let a=0;a<i.rangeCount;a+=1){const l=i.getRangeAt(a);if(l.startContainer===o||o.contains(l.startContainer)||l.endContainer===o||o.contains(l.endContainer))return!0}return!1};return s.jsx("div",{role:"button",tabIndex:0,"aria-label":e,className:"diff-tap-target",onClick:o=>{var a;if(r(o.currentTarget)){o.stopPropagation();const l=Rg(o.currentTarget);l&&t(l);return}const i=o.target;(a=i==null?void 0:i.closest)!=null&&a.call(i,"button,a")||(o.stopPropagation(),t())},onKeyDown:o=>{o.target===o.currentTarget&&(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),t())},children:n})}const ns=m.memo(function({lines:t}){return s.jsx("div",{className:"diff-hunk",children:s.jsx("pre",{className:"diff-content",children:t.map((n,r)=>{const o=n[0],i=o==="-"?"diff-removed":o==="+"?"diff-added":"diff-context",a=`${r}-${n.slice(0,50)}`;return s.jsxs("div",{className:i,children:[s.jsx("span",{className:"diff-prefix",children:o}),n.slice(1)]},a)})})})}),ss=m.memo(function({diffHtml:t,truncateLines:n}){const r=m.useMemo(()=>{if(!n)return t;const o=/<span class="line[^"]*">/g,i=[...t.matchAll(o)];if(i.length<=n)return t;const a=i[n-1];if(!a)return t;const l=(a.index??0)+a[0].length,c=t.indexOf("</span>",l);return c===-1?t:`${t.slice(0,c+7)}</code></pre>`},[t,n]);return s.jsx("div",{className:"highlighted-diff",dangerouslySetInnerHTML:{__html:r}})}),Dg=m.memo(function({hunk:t}){return s.jsx("div",{className:"diff-hunk",children:s.jsx("pre",{className:"diff-content",children:t.lines.map((n,r)=>{const o=n[0],i=o==="-"?"diff-removed":o==="+"?"diff-added":"diff-context";return s.jsxs("div",{className:i,children:[s.jsx("span",{className:"diff-prefix",children:o}),n.slice(1)]},`${t.oldStart}-${r}`)})})})});function Ml({rawPatch:e,truncateLines:t,baseFilePath:n}){const r=Yr(e),o=n??r[0],i=Pt(r.length>0?r:o?[o]:[]),a=m.useMemo(()=>t?Ag(e,t):{hiddenLineCount:0,text:e,truncated:!1},[e,t]),l=t?Yt(e,t):null,c=ms(e,l);return s.jsx(Ye,{sourceText:a.text,diffAware:!0,baseFilePath:o,renderMode:i,sourceView:s.jsxs("div",{className:`diff-view-container ${a.truncated?"truncated":""}`,...c,children:[s.jsx("div",{className:"diff-view",children:s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:a.text})})}),a.truncated&&s.jsx("div",{className:"diff-fade-overlay"}),a.hiddenLineCount>0&&s.jsx(Tt,{className:"edit-preview-more",count:a.hiddenLineCount,tooltip:l??e})]}),renderRenderedView:d=>s.jsxs("div",{className:`diff-view-container ${a.truncated?"truncated":""}`,...c,children:[s.jsx("div",{className:"diff-view",children:Jr(d,"code-block")}),a.truncated&&s.jsx("div",{className:"diff-fade-overlay"}),a.hiddenLineCount>0&&s.jsx(Tt,{className:"edit-preview-more",count:a.hiddenLineCount,tooltip:l??e})]})})}function Og({rawPatch:e,baseFilePath:t,selection:n}){const r=m.useRef(null);Il(r,n);const o=Yr(e),i=t??o[0],a=Pt(o.length>0?o:i?[i]:[]);return s.jsx("div",{className:"diff-modal-content",ref:r,children:s.jsx(Ye,{sourceText:e,initialMode:n==null?void 0:n.renderMode,diffAware:!0,baseFilePath:i,renderMode:a,sourceView:s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:e})}),renderRenderedView:l=>Jr(l,"code-block")})})}function Ug({input:e}){if(!e._structuredPatch||e._structuredPatch.length===0)return e._rawPatch?s.jsx("div",{className:"edit-result",children:s.jsx(Ml,{rawPatch:e._rawPatch,baseFilePath:Vt(e)})}):s.jsx("div",{className:"edit-result",children:s.jsx("div",{className:"edit-loading",children:"Computing diff..."})});const t=e._structuredPatch.flatMap(a=>a.lines),n=Vt(e),r=Pt(Rt(e)),o=El(e._structuredPatch),i=t.length>Ae;return s.jsxs("div",{className:"edit-result",children:[o&&s.jsx("div",{className:"edit-change-summary",children:o}),s.jsx(Et,{sourceText:t.join(`
86
- `),baseFilePath:n,renderMode:r,truncated:i,hiddenLineCount:Math.max(0,t.length-Ae),sourceView:e._diffHtml?s.jsx(ss,{diffHtml:e._diffHtml,truncateLines:i?Ae:void 0}):s.jsx(ns,{lines:t})})]})}function gn({diffHtml:e,structuredPatch:t,filePath:n,oldString:r,newString:o,originalFile:i,selection:a}){const l=ge(),c=(l==null?void 0:l.projectPath)??null,[d,u]=m.useState(!1),f=m.useRef(null),h=m.useRef(null);Il(f,a);const g=!!(n&&(i||l!=null&&l.projectId)),{loading:p,error:y,result:x,fetchExpandedDiff:b}=Ng({filePath:n,oldString:r,newString:o,originalFile:i??"",structuredPatch:t}),_=m.useCallback(async()=>{if(!g)return;!d&&!x&&await b();const S=f.current,$=(S==null?void 0:S.closest(".modal-content"))??S;h.current=Md($,(S==null?void 0:S.querySelector(So))??null),u(!d)},[g,d,x,b]),N=d&&(x==null?void 0:x.kind)==="diff"?x:null,v=d&&(x==null?void 0:x.kind)==="file"?x:null;m.useLayoutEffect(()=>{var $;const S=h.current;S&&(h.current=null,$d(S,(($=f.current)==null?void 0:$.querySelector(So))??null))},[N,d]);const j=(N==null?void 0:N.diffHtml)??e,C=(N==null?void 0:N.structuredPatch)??t,w=v?void 0:pn(C),k=oe(n,c);return s.jsxs("div",{className:"diff-modal-content",ref:f,children:[s.jsxs("div",{className:"diff-context-controls",children:[l!=null&&l.projectId?s.jsx(Pr,{projectId:l.projectId,filePath:n,displayText:k,lineNumber:w==null?void 0:w.lineNumber,lineEnd:w==null?void 0:w.lineEnd,showCopyButton:!1,showVersionControlLinks:!1}):s.jsx("span",{className:"diff-context-path",children:k}),g&&s.jsx("button",{type:"button",className:"diff-context-toggle",onClick:_,disabled:p,children:p?"Loading...":d?"Show diff only":"Show full context"}),y&&s.jsx("span",{className:"diff-context-error",children:y})]}),v?s.jsx(Et,{sourceText:v.content,diffAware:!1,baseFilePath:k,initialMode:a==null?void 0:a.renderMode,sourceView:s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:v.content})})}):s.jsx(Et,{sourceText:C.flatMap(S=>S.lines).join(`
87
- `),baseFilePath:k,initialMode:a==null?void 0:a.renderMode,sourceView:s.jsx(Ld,{diffHtml:j??"",structuredPatch:C})})]})}function Hg({filePath:e,displayText:t,lineRange:n}){const r=ge(),o=t??_t(e);return r!=null&&r.projectId&&e?s.jsx(Pr,{projectId:r.projectId,filePath:e,displayText:o,lineNumber:n==null?void 0:n.lineNumber,lineEnd:n==null?void 0:n.lineEnd,showCopyButton:!1,showVersionControlLinks:!1}):s.jsx("span",{className:"file-path",title:e,children:o})}function Nt({filePath:e,displayText:t,lineRange:n,label:r,children:o,onClose:i}){const a=ge(),{t:l}=Z(),c=a==null?void 0:a.projectId,d=c&&e?Ed(c,e):e,u=c&&e?s.jsxs(s.Fragment,{children:[s.jsx(Id,{projectId:c,path:d,dirtyLabel:l("fileRevisionDirty"),uncommittedLabel:l("fileRevisionUncommitted")}),s.jsx(Ta,{projectId:c,filePath:e}),s.jsx(nu,{path:d,t:l})]}):void 0;return s.jsx(Mt,{title:s.jsx(Hg,{filePath:e,displayText:t,lineRange:n}),actions:u,label:r,onClose:i,children:o})}function Wg({input:e,result:t,isError:n}){var T;const[r,o]=m.useState(!1),[i,a]=m.useState(null),{enabled:l,reportValidationError:c,isToolIgnored:d}=ve(),[u,f]=m.useState(null);m.useEffect(()=>{if(l&&t){const E=we("Edit",t);!E.valid&&E.errors?(f(E.errors),c("Edit",E.errors)):f(null)}},[l,t,c]);const h=l&&u&&!d("Edit"),g=m.useCallback(()=>{o(!1),a(null)},[]),p=m.useCallback(E=>{a(E??null),o(!0)},[]),y=Vt(e,t),x=Pt(Rt(e,t)),b=_t(y),_=(t==null?void 0:t.oldString)??e.old_string,N=(t==null?void 0:t.newString)??e.new_string,v=t==null?void 0:t.originalFile,j=(t==null?void 0:t.structuredPatch)??e._structuredPatch??[],C=pn(j),w=e._diffHtml,k=e._rawPatch;if(n){const E=(t==null?void 0:t.content)??null,R=E?vs(E):{classification:"unknown",label:"Error",cleanedMessage:""},D=Tl(R.classification),K=Rl(R.classification),V=K&&e._structuredPatch&&e._structuredPatch.length>0,G=V?((T=e._structuredPatch)==null?void 0:T.flatMap(ie=>ie.lines))??[]:[],W=G.length>Ae;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`edit-collapsed-preview edit-collapsed-${D}`,children:[h&&u&&s.jsx(q,{toolName:"Edit",errors:u}),s.jsx("span",{className:`badge badge-${D}`,children:K?R.label:`Edit ${R.label.toLowerCase()}`}),R.userReason?s.jsx("span",{className:"edit-error-message",children:R.userReason}):R.cleanedMessage&&!K?s.jsx("span",{className:"edit-error-message",children:R.cleanedMessage}):null,V&&s.jsx(an,{label:"Show full diff",onOpen:p,children:s.jsx(Et,{sourceText:G.join(`
86
+ `),baseFilePath:n,renderMode:r,truncated:i,hiddenLineCount:Math.max(0,t.length-Ae),sourceView:e._diffHtml?s.jsx(ss,{diffHtml:e._diffHtml,truncateLines:i?Ae:void 0}):s.jsx(ns,{lines:t})})]})}function gn({diffHtml:e,structuredPatch:t,filePath:n,oldString:r,newString:o,originalFile:i,selection:a}){const l=ge(),c=(l==null?void 0:l.projectPath)??null,[d,u]=m.useState(!1),f=m.useRef(null),h=m.useRef(null);Il(f,a);const g=!!(n&&(i||l!=null&&l.projectId)),{loading:p,error:y,result:x,fetchExpandedDiff:b}=Ng({filePath:n,oldString:r,newString:o,originalFile:i??"",structuredPatch:t}),_=m.useCallback(async()=>{if(!g)return;!d&&!x&&await b();const S=f.current,$=(S==null?void 0:S.closest(".modal-content"))??S;h.current=Od($,(S==null?void 0:S.querySelector(So))??null),u(!d)},[g,d,x,b]),N=d&&(x==null?void 0:x.kind)==="diff"?x:null,v=d&&(x==null?void 0:x.kind)==="file"?x:null;m.useLayoutEffect(()=>{var $;const S=h.current;S&&(h.current=null,Ud(S,(($=f.current)==null?void 0:$.querySelector(So))??null))},[N,d]);const j=(N==null?void 0:N.diffHtml)??e,C=(N==null?void 0:N.structuredPatch)??t,w=v?void 0:pn(C),k=oe(n,c);return s.jsxs("div",{className:"diff-modal-content",ref:f,children:[s.jsxs("div",{className:"diff-context-controls",children:[l!=null&&l.projectId?s.jsx(Ir,{projectId:l.projectId,filePath:n,displayText:k,lineNumber:w==null?void 0:w.lineNumber,lineEnd:w==null?void 0:w.lineEnd,showCopyButton:!1,showVersionControlLinks:!1}):s.jsx("span",{className:"diff-context-path",children:k}),g&&s.jsx("button",{type:"button",className:"diff-context-toggle",onClick:_,disabled:p,children:p?"Loading...":d?"Show diff only":"Show full context"}),y&&s.jsx("span",{className:"diff-context-error",children:y})]}),v?s.jsx(Et,{sourceText:v.content,diffAware:!1,baseFilePath:k,initialMode:a==null?void 0:a.renderMode,sourceView:s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:v.content})})}):s.jsx(Et,{sourceText:C.flatMap(S=>S.lines).join(`
87
+ `),baseFilePath:k,initialMode:a==null?void 0:a.renderMode,sourceView:s.jsx(Hd,{diffHtml:j??"",structuredPatch:C})})]})}function Hg({filePath:e,displayText:t,lineRange:n}){const r=ge(),o=t??_t(e);return r!=null&&r.projectId&&e?s.jsx(Ir,{projectId:r.projectId,filePath:e,displayText:o,lineNumber:n==null?void 0:n.lineNumber,lineEnd:n==null?void 0:n.lineEnd,showCopyButton:!1,showVersionControlLinks:!1}):s.jsx("span",{className:"file-path",title:e,children:o})}function Nt({filePath:e,displayText:t,lineRange:n,label:r,children:o,onClose:i}){const a=ge(),{t:l}=Z(),c=a==null?void 0:a.projectId,d=c&&e?Bd(c,e):e,u=c&&e?s.jsxs(s.Fragment,{children:[s.jsx(Dd,{projectId:c,path:d,dirtyLabel:l("fileRevisionDirty"),uncommittedLabel:l("fileRevisionUncommitted")}),s.jsx(Ra,{projectId:c,filePath:e}),s.jsx(nu,{path:d,t:l})]}):void 0;return s.jsx(Mt,{title:s.jsx(Hg,{filePath:e,displayText:t,lineRange:n}),actions:u,label:r,onClose:i,children:o})}function Wg({input:e,result:t,isError:n}){var T;const[r,o]=m.useState(!1),[i,a]=m.useState(null),{enabled:l,reportValidationError:c,isToolIgnored:d}=ve(),[u,f]=m.useState(null);m.useEffect(()=>{if(l&&t){const E=we("Edit",t);!E.valid&&E.errors?(f(E.errors),c("Edit",E.errors)):f(null)}},[l,t,c]);const h=l&&u&&!d("Edit"),g=m.useCallback(()=>{o(!1),a(null)},[]),p=m.useCallback(E=>{a(E??null),o(!0)},[]),y=Vt(e,t),x=Pt(Rt(e,t)),b=_t(y),_=(t==null?void 0:t.oldString)??e.old_string,N=(t==null?void 0:t.newString)??e.new_string,v=t==null?void 0:t.originalFile,j=(t==null?void 0:t.structuredPatch)??e._structuredPatch??[],C=pn(j),w=e._diffHtml,k=e._rawPatch;if(n){const E=(t==null?void 0:t.content)??null,R=E?vs(E):{classification:"unknown",label:"Error",cleanedMessage:""},D=Tl(R.classification),K=Rl(R.classification),V=K&&e._structuredPatch&&e._structuredPatch.length>0,G=V?((T=e._structuredPatch)==null?void 0:T.flatMap(ie=>ie.lines))??[]:[],W=G.length>Ae;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`edit-collapsed-preview edit-collapsed-${D}`,children:[h&&u&&s.jsx(q,{toolName:"Edit",errors:u}),s.jsx("span",{className:`badge badge-${D}`,children:K?R.label:`Edit ${R.label.toLowerCase()}`}),R.userReason?s.jsx("span",{className:"edit-error-message",children:R.userReason}):R.cleanedMessage&&!K?s.jsx("span",{className:"edit-error-message",children:R.cleanedMessage}):null,V&&s.jsx(an,{label:"Show full diff",onOpen:p,children:s.jsx(Et,{sourceText:G.join(`
88
88
  `),baseFilePath:y,renderMode:x,truncated:W,hiddenLineCount:Math.max(0,G.length-Ae),sourceView:e._diffHtml?s.jsx(ss,{diffHtml:e._diffHtml,truncateLines:W?Ae:void 0}):s.jsx(ns,{lines:G})})})]}),r&&V&&s.jsx(Nt,{filePath:y,displayText:b,lineRange:C,label:b,onClose:g,children:s.jsx(gn,{diffHtml:w,structuredPatch:j,filePath:y,oldString:_??"",newString:N??"",selection:i})})]})}if(j.length===0)return t===void 0?s.jsx("div",{className:"edit-collapsed-preview",children:s.jsx("div",{className:"edit-loading",children:"Computing diff..."})}):k?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"edit-collapsed-preview",children:[h&&u&&s.jsx(q,{toolName:"Edit",errors:u}),s.jsx(an,{label:"Show full patch",onOpen:p,children:s.jsx(Ml,{rawPatch:k,truncateLines:Ae,baseFilePath:y})})]}),r&&s.jsx(Nt,{filePath:y,displayText:b,label:b,onClose:g,children:s.jsx(Og,{rawPatch:k,baseFilePath:y,selection:i})})]}):s.jsx("div",{className:"edit-collapsed-preview",children:s.jsx("span",{children:"Patch preview unavailable"})});const S=j.flatMap(E=>E.lines),$=S.length>Ae;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"edit-collapsed-preview",children:[(t==null?void 0:t.userModified)&&s.jsx("span",{className:"badge badge-info",children:"User modified"}),h&&u&&s.jsx(q,{toolName:"Edit",errors:u}),s.jsx(an,{label:"Show full diff",onOpen:p,children:s.jsx(Et,{sourceText:S.join(`
89
89
  `),baseFilePath:y,renderMode:x,truncated:$,hiddenLineCount:Math.max(0,S.length-Ae),sourceView:w?s.jsx(ss,{diffHtml:w,truncateLines:$?Ae:void 0}):s.jsx(ns,{lines:S})})})]}),r&&s.jsx(Nt,{filePath:y,displayText:b,lineRange:C,label:b,onClose:g,children:s.jsx(gn,{diffHtml:w,structuredPatch:j,filePath:y,oldString:_??"",newString:N??"",originalFile:v,selection:i})})]})}function Vg({input:e,result:t,isError:n}){var w;const[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&t){const k=we("Edit",t);!k.valid&&k.errors?(d(k.errors),a("Edit",k.errors)):d(null)}},[i,t,a]);const u=i&&c&&!l("Edit"),f=((w=ge())==null?void 0:w.projectPath)??null,h=Vt(e,t),g=ur(e,t),p=Mg(e,t,f),y=Pl(e,t,f),x=(t==null?void 0:t.oldString)??e.old_string,b=(t==null?void 0:t.newString)??e.new_string,_=t==null?void 0:t.originalFile,N=(t==null?void 0:t.structuredPatch)??e._structuredPatch??[],v=e._diffHtml,j=El(N),C=pn(N);return n?s.jsxs("span",{title:p,children:[g,u&&c&&s.jsx(q,{toolName:"Edit",errors:c})]}):N.length===0?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"source-review-edit-summary",children:[s.jsxs("button",{type:"button",className:"file-link-inline",title:p,onClick:k=>{k.stopPropagation(),o(!0)},children:[g,u&&c&&s.jsx(q,{toolName:"Edit",errors:c})]}),s.jsx(Ii,{filePath:h})]}),r&&s.jsx(Nt,{filePath:h,displayText:g,label:g,onClose:()=>o(!1),children:s.jsxs("div",{className:"diff-modal-content",children:[s.jsx("div",{className:"diff-context-controls",children:s.jsx("span",{className:"diff-context-path",title:p,children:y.length>0?y[0]:g})}),s.jsx("div",{className:"edit-target-paths",children:y.length>0?y.map(k=>s.jsx("div",{className:"edit-target-path",children:s.jsx(Or,{displayPath:k})},k)):s.jsx("div",{className:"edit-target-path",children:"Patch target unavailable"})})]})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"source-review-edit-summary",children:[s.jsxs("button",{type:"button",className:"file-link-inline",title:p,onClick:k=>{k.stopPropagation(),o(!0)},children:[g,j&&s.jsx("span",{className:"file-line-count-inline",children:j}),u&&c&&s.jsx(q,{toolName:"Edit",errors:c})]}),s.jsx(Ii,{filePath:h})]}),r&&s.jsx(Nt,{filePath:h,displayText:g,lineRange:C,label:g,onClose:()=>o(!1),children:s.jsx(gn,{diffHtml:v,structuredPatch:N,filePath:h,oldString:x??"",newString:b??"",originalFile:_})})]})}function Gg({result:e,input:t,isError:n}){var _,N;const[r,o]=m.useState(!1),[i,a]=m.useState(null),{enabled:l,reportValidationError:c,isToolIgnored:d}=ve(),[u,f]=m.useState(null),h=m.useCallback(v=>{a(v??null),o(!0)},[]),g=m.useCallback(()=>{o(!1),a(null)},[]);m.useEffect(()=>{if(l&&e){const v=we("Edit",e);!v.valid&&v.errors?(f(v.errors),c("Edit",v.errors)):f(null)}},[l,e,c]);const p=l&&u&&!d("Edit"),y=m.useMemo(()=>e!=null&&e.structuredPatch?e.structuredPatch.reduce((v,j)=>v+j.lines.length,0):0,[e==null?void 0:e.structuredPatch]),x=y>Ae,b=m.useMemo(()=>{if(!(e!=null&&e.structuredPatch))return null;const v=e.structuredPatch.flatMap(C=>C.lines).filter(C=>C.startsWith("+")).length,j=e.structuredPatch.flatMap(C=>C.lines).filter(C=>C.startsWith("-")).length;return v>0&&j>0?`Modified ${v+j} lines`:v>0?`Added ${v} line${v!==1?"s":""}`:j>0?`Removed ${j} line${j!==1?"s":""}`:null},[e==null?void 0:e.structuredPatch]);if(n){const v=(e==null?void 0:e.content)??null,j=v?vs(v):{classification:"unknown",label:"Error",cleanedMessage:""},C=Tl(j.classification),w=Rl(j.classification),k=t,S=w&&(k==null?void 0:k._structuredPatch)&&k._structuredPatch.length>0,$=S?((_=k._structuredPatch)==null?void 0:_.flatMap(V=>V.lines))??[]:[],T=$.length>Ae,E=Vt(k),R=Pt(Rt(k)),D=_t(E),K=pn(k==null?void 0:k._structuredPatch);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`edit-result edit-result-${C}`,children:[p&&u&&s.jsx(q,{toolName:"Edit",errors:u}),s.jsx("span",{className:`badge badge-${C}`,children:w?j.label:`Edit ${j.label.toLowerCase()}`}),j.userReason?s.jsx("div",{className:"edit-error-message",children:j.userReason}):j.cleanedMessage&&!w?s.jsx("div",{className:"edit-error-message",children:j.cleanedMessage}):null,S&&s.jsx(an,{label:"Show full diff",onOpen:h,children:s.jsx(Et,{sourceText:$.join(`
90
90
  `),baseFilePath:E,renderMode:R,truncated:T,hiddenLineCount:Math.max(0,$.length-Ae),sourceView:k!=null&&k._diffHtml?s.jsx(ss,{diffHtml:k._diffHtml,truncateLines:T?Ae:void 0}):s.jsx(ns,{lines:$})})})]}),r&&S&&k&&s.jsx(Nt,{filePath:E,displayText:D,lineRange:K,label:D,onClose:g,children:s.jsx(gn,{diffHtml:k._diffHtml,structuredPatch:k._structuredPatch??[],filePath:E,oldString:k.old_string??"",newString:k.new_string??"",selection:i})})]})}if(e.content&&!((N=e.structuredPatch)!=null&&N.length)&&e.oldString===void 0&&e.newString===void 0&&(t==null?void 0:t.old_string)===void 0&&(t==null?void 0:t.new_string)===void 0)return s.jsx("div",{className:"edit-result",children:e.content});if(!(e!=null&&e.structuredPatch)||e.structuredPatch.length===0){const v=Vt(t,e),j=(e==null?void 0:e.oldString)||(t==null?void 0:t.old_string)||"",C=(e==null?void 0:e.newString)||(t==null?void 0:t.new_string)||"",w=v?$g(v):!1;return s.jsxs("div",{className:"edit-result",children:[s.jsxs("div",{className:"edit-header",children:[s.jsx("span",{className:"file-path",children:v?_t(v):"File"}),w&&s.jsx("span",{className:"badge badge-muted",children:"Plan"}),(e==null?void 0:e.userModified)&&s.jsx("span",{className:"badge badge-info",children:"User modified"}),p&&u&&s.jsx(q,{toolName:"Edit",errors:u})]}),s.jsxs("div",{className:"edit-simple",children:[s.jsxs("div",{className:"edit-old",children:[s.jsx("div",{className:"edit-label",children:"Removed:"}),s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:j||"(empty)"})})]}),s.jsxs("div",{className:"edit-new",children:[s.jsx("div",{className:"edit-label",children:"Added:"}),s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:C||"(empty)"})})]})]})]})}return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"edit-result",children:[p&&u&&s.jsx(q,{toolName:"Edit",errors:u}),b&&s.jsx("div",{className:"edit-change-summary",children:b}),e.userModified&&s.jsx("span",{className:"badge badge-info",children:"User modified"}),s.jsx(an,{label:"Show full diff",onOpen:h,children:s.jsx(Et,{sourceText:e.structuredPatch.flatMap(v=>v.lines).join(`
91
- `),baseFilePath:e.filePath,renderMode:Pt(Rt(t,e)),truncated:x,hiddenLineCount:Math.max(0,y-Ae),sourceView:e.structuredPatch.map((v,j)=>s.jsx(Dg,{hunk:v},`hunk-${v.oldStart}-${j}`))})})]}),r&&s.jsx(Nt,{filePath:e.filePath??"",displayText:_t(e.filePath),lineRange:pn(e.structuredPatch),label:_t(e.filePath),onClose:g,children:s.jsx(gn,{structuredPatch:e.structuredPatch,filePath:e.filePath??"",oldString:e.oldString??(t==null?void 0:t.old_string)??"",newString:e.newString??(t==null?void 0:t.new_string)??"",originalFile:e.originalFile,selection:i})})]})}const zg=de(fe.Edit,{tool:"Edit",displayName:"Edit",renderToolUse(e){return s.jsx(Ug,{input:e})},renderToolResult(e,t,n,r){return s.jsx(Gg,{result:e,input:r,isError:t})},getUseSummary(e){return ur(e)},getResultSummary(e,t,n){if(t){const o=e==null?void 0:e.content;return o?vs(o).label:"Error"}return ur(n,e)},renderCollapsedPreview(e,t,n){return s.jsx(Wg,{input:e,result:t,isError:n})},renderInteractiveSummary(e,t,n,r){return s.jsx(Vg,{input:e,result:t,isError:n})}}),qg="_pending_1d2ql_1",Kg="_root_1d2ql_8",Xg="_inline_1d2ql_17",Yg="_error_1d2ql_102",tn={pending:qg,root:Kg,inline:Xg,error:Yg};function $i({plan:e,renderedHtml:t}){const n=Ra(t??"");return t?s.jsx("div",{dangerouslySetInnerHTML:{__html:n}}):s.jsx("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"inherit"},children:e})}const Jg=de(fe.ExitPlanMode,{tool:"ExitPlanMode",renderToolUse(){return null},renderToolResult(e,t){return t?s.jsx("div",{className:tn.error,children:e.message}):s.jsx($i,{plan:e.plan??e.message,renderedHtml:e._renderedHtml})},renderInline(e,t,n,r){const o=e,i=t,a=(o==null?void 0:o.plan)||(i==null?void 0:i.plan),l=(o==null?void 0:o._renderedHtml)||(i==null?void 0:i._renderedHtml);if(n){let c="Exit plan mode failed";if(typeof t=="string")c=t;else if(typeof t=="object"&&t!==null){const d="message"in t?t:void 0;d!=null&&d.message&&(c=String(d.message))}return s.jsx("div",{className:tn.error,children:c})}return!a&&!l?r==="pending"?s.jsx("div",{className:tn.pending,children:"Planning..."}):null:s.jsxs("details",{className:`${tn.root} collapsible`,open:!0,children:[s.jsxs("summary",{className:"collapsible__summary",children:[s.jsx("span",{children:r==="pending"?"Planning...":"Plan"}),s.jsx("span",{className:"collapsible__icon",children:"▸"})]}),s.jsx("div",{className:"collapsible__content",children:s.jsx("div",{className:`${tn.inline} ${r==="pending"?"pending":""}`,children:s.jsx($i,{plan:a,renderedHtml:l})})})]})},getUseSummary(e){return"Exit plan mode"},getResultSummary(e,t){return t?"Error":"Plan"}}),Qg="_toolUse_w9zbq_1",Zg="_pattern_w9zbq_8",ex="_path_w9zbq_14",tx="_result_w9zbq_19",nx="_header_w9zbq_25",sx="_count_w9zbq_31",rx="_error_w9zbq_36",ox="_empty_w9zbq_43",dt={toolUse:Qg,pattern:Zg,path:ex,result:tx,header:nx,count:sx,error:rx,empty:ox},Fs=20;function ix(e){return tt(e)}function ax({input:e,projectPath:t}){return s.jsxs("div",{className:dt.toolUse,children:[s.jsx("span",{className:dt.pattern,children:e.pattern}),e.path&&s.jsxs("span",{className:dt.path,children:["in ",oe(e.path,t)]})]})}function lx({result:e,projectPath:t}){const[n,r]=m.useState(!1),{enabled:o,reportValidationError:i,isToolIgnored:a}=ve(),[l,c]=m.useState(null);m.useEffect(()=>{if(o&&e){const y=we("Glob",e);!y.valid&&y.errors?(c(y.errors),i("Glob",y.errors)):c(null)}},[o,e,i]);const d=o&&l&&!a("Glob");if(!(e!=null&&e.filenames)||e.filenames.length===0)return s.jsxs("div",{className:dt.empty,children:[d&&l&&s.jsx(q,{toolName:"Glob",errors:l}),"No files found"]});const{filenames:u,numFiles:f,truncated:h}=e,g=u.length>Fs,p=g&&!n?u.slice(0,Fs):u;return s.jsxs("div",{className:dt.result,children:[s.jsxs("div",{className:dt.header,children:[s.jsxs("span",{className:dt.count,children:[f," files"]}),h&&s.jsx("span",{className:"badge badge-warning",children:"truncated"}),d&&l&&s.jsx(q,{toolName:"Glob",errors:l})]}),s.jsxs("div",{className:"file-list",children:[p.map(y=>s.jsxs("div",{className:"file-list-item",children:[s.jsx("span",{className:"file-path",children:ix(oe(y,t))}),s.jsx("span",{className:"file-dir",children:oe(y,t)})]},y)),g&&!n&&s.jsxs("div",{className:"file-list-more",children:["... and ",u.length-Fs," more"]})]}),g&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!n),children:n?"Show less":`Show all ${u.length} files`})]})}const cx=de(fe.Glob,{tool:"Glob",displayName:"List",renderToolUse(e,t){return s.jsx(ax,{input:e,projectPath:t.projectPath})},renderToolResult(e,t,n){return s.jsx(lx,{result:e,projectPath:n.projectPath})},renderFailure(e){return s.jsx("div",{className:dt.error,children:e.content||"Glob search failed"})},getFailureSummary(){return"Error"},getUseSummary(e,t){const n=e,r=`pattern: "${n.pattern}"`;return n.path?`${r} in ${oe(n.path,t==null?void 0:t.projectPath)}`:r},getResultSummary(e){const t=e;return(t==null?void 0:t.numFiles)===void 0?"Searching...":t.numFiles===0?"No files found":`Found ${t.numFiles} files`}}),dx="_card_e2590_1",ux="_empty_e2590_2",mx="_statusActive_e2590_25",fx="_statusPaused_e2590_29",hx="_statusLimited_e2590_30",px="_statusBlocked_e2590_34",gx="_error_e2590_35",xx="_statusComplete_e2590_39",yx="_statusUnknown_e2590_43",jx="_topline_e2590_47",bx="_objectiveLabel_e2590_55",vx="_statusBadge_e2590_65",wx="_objective_e2590_55",_x="_metrics_e2590_111",Nx="_metric_e2590_111",kx="_metricSecondary_e2590_129",Sx="_progress_e2590_133",Cx="_errorMessage_e2590_166",Ne={card:dx,empty:ux,statusActive:mx,statusPaused:fx,statusLimited:hx,statusBlocked:px,error:gx,statusComplete:xx,statusUnknown:yx,topline:jx,objectiveLabel:bx,statusBadge:vx,objective:wx,metrics:_x,metric:Nx,metricSecondary:kx,progress:Sx,errorMessage:Cx};function Gt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function bn(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function zt(e,...t){for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function ln(e,...t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}}function $l(e){if(!e)return"active";switch(e.trim().toLowerCase().replace(/[\s_-]+/g,"")){case"active":return"active";case"paused":return"paused";case"blocked":return"blocked";case"usagelimited":return"usageLimited";case"budgetlimited":return"budgetLimited";case"complete":case"completed":return"complete";default:return e}}function Tx(e){const t=bn(e);if(!Gt(t))return;const n=zt(t,"objective");if(n)return{objective:n,status:$l(zt(t,"status")),tokenBudget:ln(t,"tokenBudget","token_budget"),tokensUsed:ln(t,"tokensUsed","tokens_used"),timeUsedSeconds:ln(t,"timeUsedSeconds","time_used_seconds")}}function Ll(e){const t=bn(e);if(!Gt(t))return{};const r=Object.hasOwn(t,"goal")?t.goal:t;return{goal:r===null?null:Tx(r),remainingTokens:ln(t,"remainingTokens","remaining_tokens")}}function Al(e){const t=bn(e);if(!Gt(t))return;const n=zt(t,"objective");if(n)return{objective:n,status:"active",tokenBudget:ln(t,"tokenBudget","token_budget"),tokensUsed:0,timeUsedSeconds:0}}function Qr(e){const t=bn(e);if(!Gt(t))return;const n=$l(zt(t,"status"));return n==="complete"||n==="blocked"?n:void 0}function Li(e){return e.replace(/\s+/g," ").trim()}function Ai(e,t,n){var o;const r=Ll(n);if((o=r.goal)!=null&&o.objective)return Li(r.goal.objective);if(r.goal===null)return"No goal set";if(e==="create"){const i=Al(t);if(i)return Li(i.objective)}return e==="update"?Qr(t)??"current goal":"current goal"}function Rx(e,t,n){if(e==="create")return n==="pending"?"Creating goal":n==="complete"?"Created goal":"Create goal";if(e==="get")return n==="pending"?"Checking goal":n==="complete"?"Checked goal":"Check goal";const r=Qr(t);if(n!=="pending"&&n!=="complete")return r==="complete"?"Complete goal":r==="blocked"?"Block goal":"Update goal";if(r==="complete"){if(n==="pending")return"Completing goal";if(n==="complete")return"Goal complete"}if(r==="blocked"){if(n==="pending")return"Blocking goal";if(n==="complete")return"Goal blocked"}return n==="pending"?"Updating goal":"Updated goal"}function Px(e){const t=bn(e);if(typeof t=="string")return t.trim()||void 0;if(!Gt(t))return;const n=zt(t,"message","error","content");return n||(Gt(t.error)?zt(t.error,"message","detail"):void 0)}function Ex(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;const r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function Ix(e){switch(e){case"active":return Ne.statusActive;case"paused":return Ne.statusPaused;case"blocked":return Ne.statusBlocked;case"usageLimited":case"budgetLimited":return Ne.statusLimited;case"complete":return Ne.statusComplete;default:return Ne.statusUnknown}}function Bs({operation:e,input:t,result:n,isError:r,context:o}){const{locale:i,t:a}=Z(),l=Ll(n),c=l.goal??(e==="create"?Al(t):void 0),d=new Intl.NumberFormat(i),u=x=>{switch(x){case"active":return a("goalRendererStatusActive");case"paused":return a("goalRendererStatusPaused");case"blocked":return a("goalRendererStatusBlocked");case"usageLimited":return a("goalRendererStatusUsageLimited");case"budgetLimited":return a("goalRendererStatusBudgetLimited");case"complete":return a("goalRendererStatusComplete");default:return x.replace(/([a-z])([A-Z])/g,"$1 $2")}};if(r)return s.jsxs("div",{className:`${Ne.card} ${Ne.error}`,"data-goal-card":"error",children:[s.jsx("strong",{children:a("goalRendererFailed")}),s.jsx("span",{className:Ne.errorMessage,children:Px(n)??a("goalRendererFailedFallback")})]});if(!c){const x=Qr(t),b=o.isStreaming?a(e==="get"?"goalRendererChecking":x==="complete"?"goalRendererCompleting":x==="blocked"?"goalRendererBlocking":"goalRendererUpdating"):l.goal===null?a("goalRendererNone"):a("goalRendererDetailsUnavailable");return s.jsx("div",{className:Ne.empty,"data-goal-card":"empty",children:b})}const f=c.tokensUsed,h=c.tokenBudget,g=l.remainingTokens??(h!==void 0&&f!==void 0?Math.max(0,h-f):void 0),p=h!==void 0&&h>0,y=p?Math.min(h,Math.max(0,f??0)):void 0;return s.jsxs("section",{className:`${Ne.card} ${Ix(c.status)}`,"aria-label":a("goalRendererCardLabel"),"data-goal-card":"goal","data-goal-status":c.status,children:[s.jsxs("div",{className:Ne.topline,children:[s.jsx("span",{className:Ne.objectiveLabel,children:a("goalRendererObjectiveLabel")}),s.jsx("span",{className:Ne.statusBadge,children:u(c.status)})]}),s.jsx("p",{className:Ne.objective,children:c.objective}),(f!==void 0||(c.timeUsedSeconds??0)>0)&&s.jsxs("div",{className:Ne.metrics,children:[f!==void 0&&s.jsx("span",{className:Ne.metric,children:p?a("goalRendererTokenBudget",{used:d.format(f),budget:d.format(h)}):a("goalRendererTokensUsed",{count:d.format(f)})}),g!==void 0&&s.jsx("span",{className:Ne.metricSecondary,children:a("goalRendererTokensRemaining",{count:d.format(g)})}),(c.timeUsedSeconds??0)>0&&s.jsx("span",{className:Ne.metricSecondary,children:a("goalRendererElapsed",{duration:Ex(c.timeUsedSeconds??0)})})]}),p&&y!==void 0&&s.jsx("progress",{className:Ne.progress,value:y,max:h,"aria-label":a("goalRendererTokenProgressLabel",{used:d.format(f??0),budget:d.format(h)})})]})}function Zr(e,t){return de(fe[e],{tool:e,displayName:"Goal",displayNameForCall(n,r){return Rx(t,n,r)},renderToolUse(n,r){return s.jsx(Bs,{operation:t,input:n,isError:!1,context:r})},renderToolResult(n,r,o,i){return s.jsx(Bs,{operation:t,input:i,result:n,isError:r,context:o})},renderCollapsedPreview(n,r,o,i){return s.jsx(Bs,{operation:t,input:n,result:r,isError:o,context:i})},getUseSummary(n){return Ai(t,n)},getResultSummary(n,r,o){return r?"failed":Ai(t,o,n)}})}const Mx=Zr("create_goal","create"),$x=Zr("get_goal","get"),Lx=Zr("update_goal","update"),Ax="_toolUse_142hc_1",Fx="_pattern_142hc_8",Bx="_glob_142hc_14",Dx="_path_142hc_19",Ox="_result_142hc_24",Ux="_header_142hc_30",Hx="_count_142hc_36",Wx="_inlineSummary_142hc_41",Vx="_summaryPattern_142hc_54",Gx="_summaryPatternRow_142hc_62",zx="_summaryPatternClip_142hc_70",qx="_summaryPatternAction_142hc_79",Kx="_summaryPatternFull_142hc_99",Xx="_summaryPatternMeasure_142hc_106",Yx="_summaryScope_142hc_115",Jx="_summaryScopePrefix_142hc_132",Qx="_summaryScopeText_142hc_136",Zx="_summaryArrow_142hc_140",ey="_matchCountButton_142hc_144",ty="_matchModal_142hc_160",ny="_matchTable_142hc_165",sy="_matchFile_142hc_179",ry="_matchLine_142hc_185",oy="_matchText_142hc_192",iy="_matchHighlight_142hc_198",ay="_collapsedPreview_142hc_208",ly="_previewMatch_142hc_221",cy="_previewFile_142hc_229",dy="_previewLine_142hc_241",uy="_previewText_142hc_246",my="_previewMore_142hc_253",fy="_countSummary_142hc_260",hy="_content_142hc_269",py="_error_142hc_273",gy="_empty_142hc_280",Y={toolUse:Ax,pattern:Fx,glob:Bx,path:Dx,result:Ox,header:Ux,count:Hx,inlineSummary:Wx,summaryPattern:Vx,summaryPatternRow:Gx,summaryPatternClip:zx,summaryPatternAction:qx,summaryPatternFull:Kx,summaryPatternMeasure:Xx,summaryScope:Yx,summaryScopePrefix:Jx,summaryScopeText:Qx,summaryArrow:Zx,matchCountButton:ey,matchModal:ty,matchTable:ny,matchFile:sy,matchLine:ry,matchText:oy,matchHighlight:iy,collapsedPreview:ay,previewMatch:ly,previewFile:cy,previewLine:dy,previewText:uy,previewMore:my,countSummary:fy,content:hy,error:py,empty:gy},Ds=20,Fi=30,Os="...",xy=12;function Fl(e){return e?e.split(`
91
+ `),baseFilePath:e.filePath,renderMode:Pt(Rt(t,e)),truncated:x,hiddenLineCount:Math.max(0,y-Ae),sourceView:e.structuredPatch.map((v,j)=>s.jsx(Dg,{hunk:v},`hunk-${v.oldStart}-${j}`))})})]}),r&&s.jsx(Nt,{filePath:e.filePath??"",displayText:_t(e.filePath),lineRange:pn(e.structuredPatch),label:_t(e.filePath),onClose:g,children:s.jsx(gn,{structuredPatch:e.structuredPatch,filePath:e.filePath??"",oldString:e.oldString??(t==null?void 0:t.old_string)??"",newString:e.newString??(t==null?void 0:t.new_string)??"",originalFile:e.originalFile,selection:i})})]})}const zg=de(fe.Edit,{tool:"Edit",displayName:"Edit",renderToolUse(e){return s.jsx(Ug,{input:e})},renderToolResult(e,t,n,r){return s.jsx(Gg,{result:e,input:r,isError:t})},getUseSummary(e){return ur(e)},getResultSummary(e,t,n){if(t){const o=e==null?void 0:e.content;return o?vs(o).label:"Error"}return ur(n,e)},renderCollapsedPreview(e,t,n){return s.jsx(Wg,{input:e,result:t,isError:n})},renderInteractiveSummary(e,t,n,r){return s.jsx(Vg,{input:e,result:t,isError:n})}}),qg="_pending_1d2ql_1",Kg="_root_1d2ql_8",Xg="_inline_1d2ql_17",Yg="_error_1d2ql_102",tn={pending:qg,root:Kg,inline:Xg,error:Yg};function $i({plan:e,renderedHtml:t}){const n=va(t??"");return t?s.jsx("div",{dangerouslySetInnerHTML:{__html:n}}):s.jsx("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"inherit"},children:e})}const Jg=de(fe.ExitPlanMode,{tool:"ExitPlanMode",renderToolUse(){return null},renderToolResult(e,t){return t?s.jsx("div",{className:tn.error,children:e.message}):s.jsx($i,{plan:e.plan??e.message,renderedHtml:e._renderedHtml})},renderInline(e,t,n,r){const o=e,i=t,a=(o==null?void 0:o.plan)||(i==null?void 0:i.plan),l=(o==null?void 0:o._renderedHtml)||(i==null?void 0:i._renderedHtml);if(n){let c="Exit plan mode failed";if(typeof t=="string")c=t;else if(typeof t=="object"&&t!==null){const d="message"in t?t:void 0;d!=null&&d.message&&(c=String(d.message))}return s.jsx("div",{className:tn.error,children:c})}return!a&&!l?r==="pending"?s.jsx("div",{className:tn.pending,children:"Planning..."}):null:s.jsxs("details",{className:`${tn.root} collapsible`,open:!0,children:[s.jsxs("summary",{className:"collapsible__summary",children:[s.jsx("span",{children:r==="pending"?"Planning...":"Plan"}),s.jsx("span",{className:"collapsible__icon",children:"▸"})]}),s.jsx("div",{className:"collapsible__content",children:s.jsx("div",{className:`${tn.inline} ${r==="pending"?"pending":""}`,children:s.jsx($i,{plan:a,renderedHtml:l})})})]})},getUseSummary(e){return"Exit plan mode"},getResultSummary(e,t){return t?"Error":"Plan"}}),Qg="_toolUse_w9zbq_1",Zg="_pattern_w9zbq_8",ex="_path_w9zbq_14",tx="_result_w9zbq_19",nx="_header_w9zbq_25",sx="_count_w9zbq_31",rx="_error_w9zbq_36",ox="_empty_w9zbq_43",dt={toolUse:Qg,pattern:Zg,path:ex,result:tx,header:nx,count:sx,error:rx,empty:ox},Fs=20;function ix(e){return tt(e)}function ax({input:e,projectPath:t}){return s.jsxs("div",{className:dt.toolUse,children:[s.jsx("span",{className:dt.pattern,children:e.pattern}),e.path&&s.jsxs("span",{className:dt.path,children:["in ",oe(e.path,t)]})]})}function lx({result:e,projectPath:t}){const[n,r]=m.useState(!1),{enabled:o,reportValidationError:i,isToolIgnored:a}=ve(),[l,c]=m.useState(null);m.useEffect(()=>{if(o&&e){const y=we("Glob",e);!y.valid&&y.errors?(c(y.errors),i("Glob",y.errors)):c(null)}},[o,e,i]);const d=o&&l&&!a("Glob");if(!(e!=null&&e.filenames)||e.filenames.length===0)return s.jsxs("div",{className:dt.empty,children:[d&&l&&s.jsx(q,{toolName:"Glob",errors:l}),"No files found"]});const{filenames:u,numFiles:f,truncated:h}=e,g=u.length>Fs,p=g&&!n?u.slice(0,Fs):u;return s.jsxs("div",{className:dt.result,children:[s.jsxs("div",{className:dt.header,children:[s.jsxs("span",{className:dt.count,children:[f," files"]}),h&&s.jsx("span",{className:"badge badge-warning",children:"truncated"}),d&&l&&s.jsx(q,{toolName:"Glob",errors:l})]}),s.jsxs("div",{className:"file-list",children:[p.map(y=>s.jsxs("div",{className:"file-list-item",children:[s.jsx("span",{className:"file-path",children:ix(oe(y,t))}),s.jsx("span",{className:"file-dir",children:oe(y,t)})]},y)),g&&!n&&s.jsxs("div",{className:"file-list-more",children:["... and ",u.length-Fs," more"]})]}),g&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!n),children:n?"Show less":`Show all ${u.length} files`})]})}const cx=de(fe.Glob,{tool:"Glob",displayName:"List",renderToolUse(e,t){return s.jsx(ax,{input:e,projectPath:t.projectPath})},renderToolResult(e,t,n){return s.jsx(lx,{result:e,projectPath:n.projectPath})},renderFailure(e){return s.jsx("div",{className:dt.error,children:e.content||"Glob search failed"})},getFailureSummary(){return"Error"},getUseSummary(e,t){const n=e,r=`pattern: "${n.pattern}"`;return n.path?`${r} in ${oe(n.path,t==null?void 0:t.projectPath)}`:r},getResultSummary(e){const t=e;return(t==null?void 0:t.numFiles)===void 0?"Searching...":t.numFiles===0?"No files found":`Found ${t.numFiles} files`}}),dx="_card_e2590_1",ux="_empty_e2590_2",mx="_statusActive_e2590_25",fx="_statusPaused_e2590_29",hx="_statusLimited_e2590_30",px="_statusBlocked_e2590_34",gx="_error_e2590_35",xx="_statusComplete_e2590_39",yx="_statusUnknown_e2590_43",jx="_topline_e2590_47",bx="_objectiveLabel_e2590_55",vx="_statusBadge_e2590_65",wx="_objective_e2590_55",_x="_metrics_e2590_111",Nx="_metric_e2590_111",kx="_metricSecondary_e2590_129",Sx="_progress_e2590_133",Cx="_errorMessage_e2590_166",Ne={card:dx,empty:ux,statusActive:mx,statusPaused:fx,statusLimited:hx,statusBlocked:px,error:gx,statusComplete:xx,statusUnknown:yx,topline:jx,objectiveLabel:bx,statusBadge:vx,objective:wx,metrics:_x,metric:Nx,metricSecondary:kx,progress:Sx,errorMessage:Cx};function Gt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function bn(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function zt(e,...t){for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function ln(e,...t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}}function $l(e){if(!e)return"active";switch(e.trim().toLowerCase().replace(/[\s_-]+/g,"")){case"active":return"active";case"paused":return"paused";case"blocked":return"blocked";case"usagelimited":return"usageLimited";case"budgetlimited":return"budgetLimited";case"complete":case"completed":return"complete";default:return e}}function Tx(e){const t=bn(e);if(!Gt(t))return;const n=zt(t,"objective");if(n)return{objective:n,status:$l(zt(t,"status")),tokenBudget:ln(t,"tokenBudget","token_budget"),tokensUsed:ln(t,"tokensUsed","tokens_used"),timeUsedSeconds:ln(t,"timeUsedSeconds","time_used_seconds")}}function Ll(e){const t=bn(e);if(!Gt(t))return{};const r=Object.hasOwn(t,"goal")?t.goal:t;return{goal:r===null?null:Tx(r),remainingTokens:ln(t,"remainingTokens","remaining_tokens")}}function Al(e){const t=bn(e);if(!Gt(t))return;const n=zt(t,"objective");if(n)return{objective:n,status:"active",tokenBudget:ln(t,"tokenBudget","token_budget"),tokensUsed:0,timeUsedSeconds:0}}function Qr(e){const t=bn(e);if(!Gt(t))return;const n=$l(zt(t,"status"));return n==="complete"||n==="blocked"?n:void 0}function Li(e){return e.replace(/\s+/g," ").trim()}function Ai(e,t,n){var o;const r=Ll(n);if((o=r.goal)!=null&&o.objective)return Li(r.goal.objective);if(r.goal===null)return"No goal set";if(e==="create"){const i=Al(t);if(i)return Li(i.objective)}return e==="update"?Qr(t)??"current goal":"current goal"}function Rx(e,t,n){if(e==="create")return n==="pending"?"Creating goal":n==="complete"?"Created goal":"Create goal";if(e==="get")return n==="pending"?"Checking goal":n==="complete"?"Checked goal":"Check goal";const r=Qr(t);if(n!=="pending"&&n!=="complete")return r==="complete"?"Complete goal":r==="blocked"?"Block goal":"Update goal";if(r==="complete"){if(n==="pending")return"Completing goal";if(n==="complete")return"Goal complete"}if(r==="blocked"){if(n==="pending")return"Blocking goal";if(n==="complete")return"Goal blocked"}return n==="pending"?"Updating goal":"Updated goal"}function Px(e){const t=bn(e);if(typeof t=="string")return t.trim()||void 0;if(!Gt(t))return;const n=zt(t,"message","error","content");return n||(Gt(t.error)?zt(t.error,"message","detail"):void 0)}function Ex(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;const r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function Ix(e){switch(e){case"active":return Ne.statusActive;case"paused":return Ne.statusPaused;case"blocked":return Ne.statusBlocked;case"usageLimited":case"budgetLimited":return Ne.statusLimited;case"complete":return Ne.statusComplete;default:return Ne.statusUnknown}}function Bs({operation:e,input:t,result:n,isError:r,context:o}){const{locale:i,t:a}=Z(),l=Ll(n),c=l.goal??(e==="create"?Al(t):void 0),d=new Intl.NumberFormat(i),u=x=>{switch(x){case"active":return a("goalRendererStatusActive");case"paused":return a("goalRendererStatusPaused");case"blocked":return a("goalRendererStatusBlocked");case"usageLimited":return a("goalRendererStatusUsageLimited");case"budgetLimited":return a("goalRendererStatusBudgetLimited");case"complete":return a("goalRendererStatusComplete");default:return x.replace(/([a-z])([A-Z])/g,"$1 $2")}};if(r)return s.jsxs("div",{className:`${Ne.card} ${Ne.error}`,"data-goal-card":"error",children:[s.jsx("strong",{children:a("goalRendererFailed")}),s.jsx("span",{className:Ne.errorMessage,children:Px(n)??a("goalRendererFailedFallback")})]});if(!c){const x=Qr(t),b=o.isStreaming?a(e==="get"?"goalRendererChecking":x==="complete"?"goalRendererCompleting":x==="blocked"?"goalRendererBlocking":"goalRendererUpdating"):l.goal===null?a("goalRendererNone"):a("goalRendererDetailsUnavailable");return s.jsx("div",{className:Ne.empty,"data-goal-card":"empty",children:b})}const f=c.tokensUsed,h=c.tokenBudget,g=l.remainingTokens??(h!==void 0&&f!==void 0?Math.max(0,h-f):void 0),p=h!==void 0&&h>0,y=p?Math.min(h,Math.max(0,f??0)):void 0;return s.jsxs("section",{className:`${Ne.card} ${Ix(c.status)}`,"aria-label":a("goalRendererCardLabel"),"data-goal-card":"goal","data-goal-status":c.status,children:[s.jsxs("div",{className:Ne.topline,children:[s.jsx("span",{className:Ne.objectiveLabel,children:a("goalRendererObjectiveLabel")}),s.jsx("span",{className:Ne.statusBadge,children:u(c.status)})]}),s.jsx("p",{className:Ne.objective,children:c.objective}),(f!==void 0||(c.timeUsedSeconds??0)>0)&&s.jsxs("div",{className:Ne.metrics,children:[f!==void 0&&s.jsx("span",{className:Ne.metric,children:p?a("goalRendererTokenBudget",{used:d.format(f),budget:d.format(h)}):a("goalRendererTokensUsed",{count:d.format(f)})}),g!==void 0&&s.jsx("span",{className:Ne.metricSecondary,children:a("goalRendererTokensRemaining",{count:d.format(g)})}),(c.timeUsedSeconds??0)>0&&s.jsx("span",{className:Ne.metricSecondary,children:a("goalRendererElapsed",{duration:Ex(c.timeUsedSeconds??0)})})]}),p&&y!==void 0&&s.jsx("progress",{className:Ne.progress,value:y,max:h,"aria-label":a("goalRendererTokenProgressLabel",{used:d.format(f??0),budget:d.format(h)})})]})}function Zr(e,t){return de(fe[e],{tool:e,displayName:"Goal",displayNameForCall(n,r){return Rx(t,n,r)},renderToolUse(n,r){return s.jsx(Bs,{operation:t,input:n,isError:!1,context:r})},renderToolResult(n,r,o,i){return s.jsx(Bs,{operation:t,input:i,result:n,isError:r,context:o})},renderCollapsedPreview(n,r,o,i){return s.jsx(Bs,{operation:t,input:n,result:r,isError:o,context:i})},getUseSummary(n){return Ai(t,n)},getResultSummary(n,r,o){return r?"failed":Ai(t,o,n)}})}const Mx=Zr("create_goal","create"),$x=Zr("get_goal","get"),Lx=Zr("update_goal","update"),Ax="_toolUse_142hc_1",Fx="_pattern_142hc_8",Bx="_glob_142hc_14",Dx="_path_142hc_19",Ox="_result_142hc_24",Ux="_header_142hc_30",Hx="_count_142hc_36",Wx="_inlineSummary_142hc_41",Vx="_summaryPattern_142hc_54",Gx="_summaryPatternRow_142hc_62",zx="_summaryPatternClip_142hc_70",qx="_summaryPatternAction_142hc_79",Kx="_summaryPatternFull_142hc_99",Xx="_summaryPatternMeasure_142hc_106",Yx="_summaryScope_142hc_115",Jx="_summaryScopePrefix_142hc_132",Qx="_summaryScopeText_142hc_136",Zx="_summaryArrow_142hc_140",ey="_matchCountButton_142hc_144",ty="_matchModal_142hc_160",ny="_matchTable_142hc_165",sy="_matchFile_142hc_179",ry="_matchLine_142hc_185",oy="_matchText_142hc_192",iy="_matchHighlight_142hc_198",ay="_collapsedPreview_142hc_208",ly="_previewMatch_142hc_221",cy="_previewFile_142hc_229",dy="_previewLine_142hc_241",uy="_previewText_142hc_246",my="_previewMore_142hc_253",fy="_countSummary_142hc_260",hy="_content_142hc_269",py="_error_142hc_273",gy="_empty_142hc_280",Y={toolUse:Ax,pattern:Fx,glob:Bx,path:Dx,result:Ox,header:Ux,count:Hx,inlineSummary:Wx,summaryPattern:Vx,summaryPatternRow:Gx,summaryPatternClip:zx,summaryPatternAction:qx,summaryPatternFull:Kx,summaryPatternMeasure:Xx,summaryScope:Yx,summaryScopePrefix:Jx,summaryScopeText:Qx,summaryArrow:Zx,matchCountButton:ey,matchModal:ty,matchTable:ny,matchFile:sy,matchLine:ry,matchText:oy,matchHighlight:iy,collapsedPreview:ay,previewMatch:ly,previewFile:cy,previewLine:dy,previewText:uy,previewMore:my,countSummary:fy,content:hy,error:py,empty:gy},Ds=20,Fi=30,Os="...",xy=12;function Fl(e){return e?e.split(`
92
92
  `).filter(t=>/(^|:)\d+:/.test(t)).length:0}function yy(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jy(e){if(!e)return null;try{const t=new RegExp(e,"g");return t.source==="(?:)"?null:t}catch{const t=yy(e);return t?new RegExp(t,"gi"):null}}function by(e,t){if(!t||t.length===0)return null;const n=[];let r=0;for(const[o,i]of t.entries()){const a=Math.max(0,Math.min(e.length,i.start)),l=Math.max(a,Math.min(e.length,i.end));if(a>r&&n.push(e.slice(r,a)),l>a&&n.push(s.jsx("mark",{className:Y.matchHighlight,children:e.slice(a,l)},`match-${o}`)),r=l,o>=50)break}return r<e.length&&n.push(e.slice(r)),n.length>0?n:null}function Bl(e,t,n){const r=by(e,t);if(r)return r;const o=jy(n);if(!o)return e;const i=[];let a=0,l=0;for(const c of e.matchAll(o)){const d=c[0],u=c.index??0;if(!d||(u>a&&i.push(e.slice(a,u)),i.push(s.jsx("mark",{className:Y.matchHighlight,children:d},`match-${l}`)),l+=1,a=u+d.length,l>=50))break}return i.length===0?e:(a<e.length&&i.push(e.slice(a)),i)}function Dl({label:e,matches:t,pattern:n,projectPath:r}){const[o,i]=m.useState(!1),a=Ol(t);return t.length===0?s.jsx("span",{className:Y.count,children:e}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:Y.matchCountButton,onClick:l=>{l.preventDefault(),l.stopPropagation(),i(!0)},children:e}),o&&s.jsx(Mt,{title:e,label:e,onClose:()=>i(!1),children:s.jsx("div",{className:Y.matchModal,children:s.jsxs("table",{className:Y.matchTable,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[a&&s.jsx("th",{children:"File"}),s.jsx("th",{children:"Line"}),s.jsx("th",{children:"Text"})]})}),s.jsx("tbody",{children:t.map((l,c)=>s.jsxs("tr",{children:[a&&s.jsx("td",{className:Y.matchFile,children:oe(l.filePath,r)}),s.jsx("td",{className:Y.matchLine,children:l.columnNumber?`${l.lineNumber}:${l.columnNumber}`:l.lineNumber}),s.jsx("td",{className:Y.matchText,children:Bl(l.text,l.ranges,n)})]},`${l.filePath}:${l.lineNumber}:${l.columnNumber??""}:${c}`))})]})})})]})}function eo(e){return tt(e)}function Ol(e){return new Set(e.map(n=>n.filePath)).size>1}function vy({input:e,projectPath:t}){return s.jsxs("div",{className:Y.toolUse,children:[s.jsx("span",{className:Y.pattern,children:e.pattern}),e.glob&&s.jsxs("span",{className:Y.glob,children:["(",e.glob,")"]}),e.path&&s.jsxs("span",{className:Y.path,children:["in ",oe(e.path,t)]})]})}function wy({filenames:e,isExpanded:t,projectPath:n,setIsExpanded:r}){const o=e.length>Ds,i=o&&!t?e.slice(0,Ds):e;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"file-list",children:[i.map(a=>s.jsxs("div",{className:"file-list-item",children:[s.jsx("span",{className:"file-path",children:eo(oe(a,n))}),s.jsx("span",{className:"file-dir",children:oe(a,n)})]},a)),o&&!t&&s.jsxs("div",{className:"file-list-more",children:["... and ",e.length-Ds," more"]})]}),o&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!t),children:t?"Show less":`Show all ${e.length} files`})]})}function _y({content:e,isExpanded:t,setIsExpanded:n}){const r=e.split(`
93
93
  `),o=r.length>Fi,a=(o&&!t?r.slice(0,Fi):r).join(`
94
- `),l=rt(a);return s.jsxs(s.Fragment,{children:[s.jsx("pre",{ref:l,className:`${Y.content} code-block`,children:s.jsx("code",{children:a})}),o&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${r.length} lines`})]})}function Ny({input:e,result:t,isError:n,projectPath:r}){const o=us(),i=m.useMemo(()=>n||(t==null?void 0:t.mode)!=="content"?[]:t.matches??[],[n,t]),a=Math.max(0,o-1),l=i.slice(0,a);if(l.length===0)return null;const c=Ol(i),d=Math.max(0,i.length-l.length);return s.jsxs("div",{className:Y.collapsedPreview,children:[l.map((u,f)=>s.jsxs("div",{className:Y.previewMatch,children:[c&&s.jsx("span",{className:Y.previewFile,title:oe(u.filePath,r),children:eo(oe(u.filePath,r))}),s.jsx("span",{className:Y.previewLine,children:u.columnNumber?`${u.lineNumber}:${u.columnNumber}`:u.lineNumber}),s.jsx(ky,{match:u,pattern:e==null?void 0:e.pattern})]},`${u.filePath}:${u.lineNumber}:${u.columnNumber??""}:${f}`)),d>0&&s.jsxs("div",{className:Y.previewMore,children:["+",d," ",d===1?"match":"matches"]})]})}function ky({match:e,pattern:t}){const n=rt(e.text);return s.jsx("span",{ref:n,className:Y.previewText,children:Bl(e.text,e.ranges,t)})}function Sy({input:e,result:t,projectPath:n}){const[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&t){const x=we("Grep",t);!x.valid&&x.errors?(d(x.errors),a("Grep",x.errors)):d(null)}},[i,t,a]);const u=i&&c&&!l("Grep");if(!t)return s.jsx("div",{className:Y.empty,children:"No results"});const{mode:f,filenames:h,numFiles:g,content:p,appliedLimit:y}=t;if(f==="count")return s.jsxs("div",{className:Y.result,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),s.jsxs("div",{className:Y.countSummary,children:[g," ",g===1?"file":"files"," matched"]})]});if(f==="content"&&p){const x=t.matches??[],b=x.length||Fl(p),_=`${b} ${b===1?"match":"matches"}`;return s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsx(Dl,{label:_,matches:x,pattern:e==null?void 0:e.pattern,projectPath:n}),y&&s.jsxs("span",{className:"badge badge-info",children:["limit: ",y]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(_y,{content:p,isExpanded:r,setIsExpanded:o})]})}return!h||h.length===0?s.jsxs("div",{className:Y.empty,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),"No matches found"]}):s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsxs("span",{className:Y.count,children:[g," files"]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(wy,{filenames:h,isExpanded:r,projectPath:n,setIsExpanded:o})]})}function Ul(e,t){if(e.path){const n=oe(e.path,t);return{kind:"path",value:e.path,label:eo(n)}}return e.glob?{kind:"glob",value:e.glob,label:e.glob}:null}function Hl(e,t){const n=Ul(e,t);if(!n)return e.pattern;const r=n.kind==="path"?oe(n.value,t):n.value;return`${e.pattern} in ${r}`}function Cy(e,t,n){if(t<=0)return"";if(n(e)<=t)return e;if(n(Os)>t)return"";let r=0,o=e.length;for(;r<o;){const i=Math.ceil((r+o)/2),a=`${e.slice(0,i)}${Os}`;n(a)<=t?r=i:o=i-1}return`${e.slice(0,r)}${Os}`}function Ty({expanded:e,input:t,onToggle:n,projectPath:r}){const o=Hl(t,r),i=Ul(t,r),a=(i==null?void 0:i.value)??"",l=m.useRef(null),c=m.useRef(null),d=m.useRef(null),[u,f]=m.useState(t.pattern);m.useLayoutEffect(()=>{const p=()=>{var C;if(e){f(t.pattern);return}const x=l.current,b=d.current;if(!x||!b){f(t.pattern);return}const _=x.getBoundingClientRect().width;if(_<=0){f(t.pattern);return}const N=((C=c.current)==null?void 0:C.getBoundingClientRect().width)??0,v=Math.max(0,_-N-(N>0?xy:0)),j=w=>(b.textContent=w,b.getBoundingClientRect().width);f(Cy(t.pattern,v,j))};if(p(),typeof ResizeObserver>"u")return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const y=new ResizeObserver(p);return l.current&&y.observe(l.current),c.current&&y.observe(c.current),()=>y.disconnect()},[e,t.pattern,a]);const h=`${Y.summaryPatternClip}${n?` ${Y.summaryPatternAction}`:""}`,g=n?s.jsx("button",{type:"button",className:h,title:o,"aria-label":e?"Collapse grep pattern":"Show full grep pattern","aria-expanded":e,onClick:p=>{p.preventDefault(),p.stopPropagation(),n()},children:u}):s.jsx("span",{className:h,title:o,children:u});return s.jsxs("span",{className:`${Y.summaryPattern}${e?" is-expanded":""}`,children:[s.jsxs("span",{className:Y.summaryPatternRow,ref:l,children:[g,i&&s.jsxs("span",{className:Y.summaryScope,ref:c,children:[s.jsx("span",{className:Y.summaryScopePrefix,children:"in"}),i.kind==="path"?s.jsx(Ue,{displayPath:i.label,filePath:i.value,showLineSuffix:!1}):s.jsx("span",{className:Y.summaryScopeText,title:i.value,children:i.label})]})]}),s.jsx("span",{className:Y.summaryPatternMeasure,ref:d}),e&&s.jsx("span",{className:Y.summaryPatternFull,children:o})]})}function Wl(e){if(e.mode==="content"){const t=e.matches??[],n=t.length||Fl(e.content);return{matches:t,text:`${n} ${n===1?"match":"matches"}`}}return e.numFiles===0?{matches:[],text:"0 matches"}:{matches:[],text:e.numFiles!==void 0?`${e.numFiles} ${e.numFiles===1?"file":"files"}`:"Results"}}function Ry({input:e,result:t,isError:n,projectPath:r,summaryExpanded:o,toggleSummaryExpanded:i}){if(n||!t)return null;const a=Wl(t);return s.jsxs("span",{className:Y.inlineSummary,children:[s.jsx(Ty,{expanded:o??!1,input:e,onToggle:i,projectPath:r}),s.jsx("span",{className:Y.summaryArrow,"aria-hidden":"true",children:"→"}),s.jsx(Dl,{label:a.text,matches:a.matches,pattern:e.pattern,projectPath:r})]})}const Py=de(fe.Grep,{tool:"Grep",displayName:"Grep",renderToolUse(e,t){return s.jsx(vy,{input:e,projectPath:t.projectPath})},renderToolResult(e,t,n,r){return s.jsx(Sy,{input:r,result:e,projectPath:n.projectPath})},renderFailure(e){return s.jsx("div",{className:Y.error,children:e.content||"Search failed"})},getFailureSummary(){return"Error"},getUseSummary(e,t){return Hl(e,t==null?void 0:t.projectPath)},getResultSummary(e){const t=e;return t?Wl(t).text:"Results"},renderInteractiveSummary(e,t,n,r){return s.jsx(Ry,{input:e,result:t,isError:n,projectPath:r.projectPath,summaryExpanded:r.summaryExpanded,toggleSummaryExpanded:r.toggleSummaryExpanded})},renderCollapsedPreview(e,t,n,r){return s.jsx(Ny,{input:e,result:t,isError:n,projectPath:r.projectPath})}}),Ey="_toolUse_1vtak_1",Iy="_label_1vtak_7",My="_shellId_1vtak_11",$y="_result_1vtak_20",Ly="_message_1vtak_26",Ay="_error_1vtak_30",Fy="_empty_1vtak_37",ut={toolUse:Ey,label:Iy,shellId:My,result:$y,message:Ly,error:Ay,empty:Fy};function By({input:e}){return s.jsxs("div",{className:ut.toolUse,children:[s.jsx("span",{className:ut.label,children:"Killing shell"}),s.jsx("code",{className:ut.shellId,children:e.shell_id})]})}function Dy({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("KillShell",e);!l.valid&&l.errors?(i(l.errors),n("KillShell",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("KillShell");return e?s.jsxs("div",{className:ut.result,children:[a&&o&&s.jsx(q,{toolName:"KillShell",errors:o}),s.jsx("span",{className:ut.message,children:e.message}),e.shell_id&&s.jsx("code",{className:ut.shellId,children:e.shell_id})]}):s.jsx("div",{className:ut.empty,children:"No result"})}const Oy=de(fe.KillShell,{tool:"KillShell",renderToolUse(e,t){return s.jsx(By,{input:e})},renderToolResult(e,t,n){return s.jsx(Dy,{result:e})},renderFailure(e){return s.jsx("div",{className:ut.error,children:e.content||"Failed to kill shell"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.shell_id},getResultSummary(e){const t=e;return(t==null?void 0:t.message)||"Killed"}}),Uy="_container_blm34_7",Hy={container:Uy};function ws({html:e,className:t}){return s.jsx("div",{className:`shiki-container ${Hy.container}${t?` ${t}`:""}`,dangerouslySetInnerHTML:{__html:Ad(e)??""}})}const Wy="_imagePreviewButton_1dcmz_1",Vy={imagePreviewButton:Wy};function cn(e){return tt(e)}function to(e){return"content"in e&&typeof e.content=="string"}function Gy(e){return"filePath"in e?e.filePath??"":""}function zy({filePath:e}){const t=ge(),n=oe(e,t==null?void 0:t.projectPath);return s.jsx("div",{className:"read-text-result read-text-inline",children:s.jsx(vt,{displayPath:n,filePath:e,children:s.jsx("span",{className:"file-line-count-inline",children:"unchanged"})})})}function mr(e){if(e.numLines<=0)return{};if(!(e.startLine>1||e.numLines<e.totalLines))return{};const n=e.startLine+Math.max(1,e.numLines)-1;return{lineEnd:n>e.startLine?n:void 0,lineNumber:e.startLine}}function qy(e){if(e.offset===void 0)return{};const t=e.limit!==void 0?e.offset+Math.max(1,e.limit)-1:void 0;return{lineEnd:t!==void 0&&t>e.offset?t:void 0,lineNumber:e.offset}}function Bi(e){return s.jsx("div",{className:"file-viewer-code fixed-font-rendered-panel",children:s.jsx("div",{className:"fixed-font-rendered__content",dangerouslySetInnerHTML:{__html:e}})})}function vt({children:e,displayPath:t,filePath:n,lineEnd:r,lineNumber:o}){return s.jsxs("span",{className:"file-link-inline",children:[s.jsx(Ue,{displayPath:t,filePath:n,lineEnd:r,lineNumber:o}),e&&s.jsxs(s.Fragment,{children:[" ",e]})]})}function Vl({filePath:e,lineEnd:t,lineNumber:n,text:r}){return s.jsx(Ue,{displayPath:r,filePath:e,lineEnd:t,lineNumber:n,showLineSuffix:!1,viewMode:"range",showCopyButton:!1})}function Ky({input:e}){const t=ge(),n=oe(e.file_path,t==null?void 0:t.projectPath),r=qy(e);return s.jsxs("div",{className:"read-tool-use",children:[s.jsx("span",{className:"file-path",children:s.jsx(Ue,{displayPath:n,filePath:e.file_path,lineEnd:r.lineEnd,lineNumber:r.lineNumber})}),(e.offset!==void 0||e.limit!==void 0)&&s.jsxs("span",{className:"read-range",title:`offset ${e.offset??0}, limit ${e.limit??"∞"}`,children:[e.offset!==void 0&&` from line ${e.offset}`,e.limit!==void 0&&` (${e.limit} lines)`]})]})}function Xy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=Er(e.filePath),i=m.useMemo(()=>{if(!o||r)return null;const C=mn(e.content,{baseFilePath:e.filePath});return C.changed?C.html:null},[e.content,e.filePath,o,r]),a=o?r??i:null,l=!!a,[c,d]=m.useState(!1),u=rt(t||c&&a?e.content:null),f=m.useMemo(()=>t?wa(e.content):null,[t,e.content]),h=!!(f!=null&&f.changed),[g,p]=m.useState(!1),{btnRef:y,handleClick:x}=Fd(g,()=>p(C=>!C)),b=e.content.length>0?e.content.split(`
95
- `):[],_=e.content.length===0?s.jsx("div",{className:"file-viewer-empty-content",children:"No content read"}):t?s.jsxs("div",{className:"file-viewer-code file-viewer-code-highlighted",children:[s.jsx(ws,{html:t}),n&&s.jsx("div",{className:"file-viewer-truncated",children:"Content truncated for highlighting (showing first 2000 lines)"})]}):s.jsxs("div",{className:"file-content-with-lines",children:[s.jsx("div",{className:"line-numbers",children:b.map((C,w)=>s.jsx("div",{children:e.startLine+w},`ln-${w+1}`))}),s.jsx("pre",{className:"line-content",children:s.jsx("code",{children:e.content})})]}),N=c&&a?s.jsx(Pa,{html:a,sourcePath:e.filePath,density:Ea}):t?g&&f?Bi(f.html):_:s.jsx(Ye,{sourceText:e.content,renderMode:o?"rich":"math",sourceView:_,renderRenderedView:C=>Bi(C)}),v=l&&s.jsxs("div",{className:"markdown-view-toggle",children:[s.jsx("button",{type:"button",className:`toggle-btn ${c?"":"active"}`,onClick:()=>d(!1),children:"Source"}),s.jsx("button",{type:"button",className:`toggle-btn ${c?"active":""}`,onClick:()=>d(!0),children:"Preview"})]}),j=!l&&h;return s.jsxs("div",{className:"file-content-modal",ref:u,children:[v,j?s.jsxs("div",{className:"fixed-font-render-toggle",children:[N,s.jsx("button",{ref:y,type:"button",className:`fixed-font-render-toggle__button ${g?"is-rendered":""}`,onClick:x,"aria-label":g?"Show source":"Render math (LaTeX)",title:g?"Show source":"Render math (LaTeX)","aria-pressed":g,children:s.jsx(ka,{})})]}):N]})}function Yy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=ge(),i=oe(e.filePath,o==null?void 0:o.projectPath),a=e.numLines>0,l=a&&(e.startLine>1||e.numLines<e.totalLines),c=mr(e);return s.jsxs("div",{className:"read-text-result read-text-inline",children:[s.jsx("div",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:i,filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber})}),l&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx(Vl,{filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber,text:`lines ${e.startLine}–${e.startLine+e.numLines-1}`})," ","of ",e.totalLines]}),!a&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),e.totalLines>0&&s.jsxs(s.Fragment,{children:[" of ",e.totalLines]})]}),s.jsx(Xy,{file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r})]})}function Jy(e,t){const n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)r[o]=n.charCodeAt(o);return new Blob([r],{type:t})}function Qy({file:e,filePath:t}){const{t:n}=Z(),r=e.originalSize?Math.round(e.originalSize/1024):0,{dimensions:o}=e,i=ge(),a=t?oe(t,i==null?void 0:i.projectPath):null,l=(o==null?void 0:o.originalWidth)!=null&&(o==null?void 0:o.originalHeight)!=null,{inlineMediaExpandedByDefault:c}=kr(),[d,u]=m.useState(null),f=d??c,[h,g]=m.useState(!1),p=Kt().transport,y=e.base64,x=m.useCallback(async()=>{if(y)return Jy(y,e.type);if(t)return Sr(t,void 0,"inline",p);throw new Error("Read image result carries neither bytes nor a file path")},[e.type,t,y,p]),b=m.useMemo(()=>y?{buildApiPath:()=>"inline-read-image",fetchBlob:x}:void 0,[y,x]),_=y?`data:${e.type};base64,${y}`:null,{url:N,error:v}=Aa(t??null,f&&!y,x),j=_??N,C=m.useCallback(()=>g(!0),[]),w=t?cn(t):"image",k=hs({fileName:w,filePath:t,loadBlob:x,onOpen:C});return s.jsxs("div",{className:"read-image-result",children:[s.jsxs("div",{className:"local-media-link-group",children:[s.jsx("button",{type:"button",className:"local-media-inline-toggle","aria-expanded":f,"aria-label":f?"Collapse image":"Expand image",title:f?"Collapse inline preview":"Expand inline preview",onClick:()=>u(!f),children:f?"-":"+"}),t&&a?s.jsx("span",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:a,filePath:t})}):s.jsx("span",{className:"local-media-type",children:"image"})]}),(l||r>0)&&s.jsxs("div",{className:"image-info",children:[l&&s.jsxs(s.Fragment,{children:[o.originalWidth,"x",o.originalHeight]}),l&&r>0&&" ",r>0&&s.jsxs(s.Fragment,{children:["(",r," ","kb)"]})]}),f&&(j?s.jsx("button",{type:"button",className:Vy.imagePreviewButton,"aria-label":`Open ${w}`,onClick:C,onContextMenu:k.handleContextMenu,children:s.jsx("img",{className:"read-image",src:j,alt:"File content",width:o==null?void 0:o.displayWidth,height:o==null?void 0:o.displayHeight})}):s.jsx("span",{className:"file-line-count-inline",children:n(v?"inlineImageUnavailable":"inlineImageLoading")})),h?s.jsx(qt,{path:y?w:t??w,filePath:t??null,mediaType:"image",mediaSource:b,onClose:()=>g(!1)}):null,k.contextMenuElement]})}function Zy(e){const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);const r=new Blob([n],{type:"application/pdf"}),o=URL.createObjectURL(r);window.open(o,"_blank")}function ej({file:e,filePath:t}){const n=e.originalSize?Math.round(e.originalSize/1024):0,r=t?cn(t):"document.pdf",o=ge(),i=t?oe(t,o==null?void 0:o.projectPath):null;if(t&&i)return s.jsx("div",{className:"read-pdf-result",children:s.jsxs(vt,{displayPath:i,filePath:t,children:[n>0&&s.jsxs("span",{className:"file-line-count-inline",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count-inline",children:"PDF"})]})});const a=e.base64;return a?s.jsx("div",{className:"read-pdf-result",children:s.jsxs("button",{type:"button",className:"file-link-button",onClick:()=>Zy(a),children:[r,n>0&&s.jsxs("span",{className:"file-line-count",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count",children:"Open PDF"})]})}):s.jsx("div",{className:"read-pdf-result",children:s.jsx("span",{className:"file-line-count-inline",children:"PDF"})})}function tj({input:e,result:t}){const{enabled:n,reportValidationError:r,isToolIgnored:o}=ve(),[i,a]=m.useState(null);m.useEffect(()=>{if(n&&t){const c=we("Read",t);!c.valid&&c.errors?(a(c.errors),r("Read",c.errors)):a(null)}},[n,t,r]);const l=n&&i&&!o("Read");return t!=null&&t.file?t.type==="pdf"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(ej,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):t.type==="image"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Qy,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):to(t.file)?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Yy,{file:t.file,highlightedHtml:t._highlightedContentHtml,highlightedTruncated:t._highlightedTruncated,renderedMarkdownHtml:t._renderedMarkdownHtml})]}):s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(zy,{filePath:Gy(t.file)||((e==null?void 0:e.file_path)??"")})]}):s.jsxs("div",{className:"read-error",children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),"Failed to read file"]})}function nj({input:e,result:t,isError:n}){const{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&t){const h=we("Read",t);!h.valid&&h.errors?(l(h.errors),o("Read",h.errors)):l(null)}},[r,t,o]);const c=r&&a&&!i("Read"),d=ge(),u=oe(e.file_path,d==null?void 0:d.projectPath);if(n)return s.jsxs("span",{children:[s.jsx(Ue,{displayPath:u,filePath:e.file_path}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!(t!=null&&t.file))return s.jsx("span",{children:s.jsx(Ue,{displayPath:u,filePath:e.file_path})});if(t.type==="pdf")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(PDF)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(t.type==="image")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(image)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!to(t.file))return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"unchanged"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});const f=t.file;return f.numLines<=0?s.jsxs(vt,{displayPath:u,filePath:f.filePath,children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]}):s.jsxs(vt,{displayPath:u,filePath:f.filePath,...mr(f),children:[s.jsx("span",{className:"file-line-count-inline",children:s.jsx(Vl,{filePath:f.filePath,text:`${f.numLines} lines`,...mr(f)})}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]})}const sj=de(fe.Read,{tool:"Read",renderToolUse(e,t){return s.jsx(Ky,{input:e})},renderToolResult(e,t,n,r){return s.jsx(tj,{input:r,result:e})},renderFailure(e){return s.jsx("div",{className:"read-error",children:e.content||"Failed to read file"})},getFailureSummary(e,t){return t?cn(t.file_path):"Error"},getUseSummary(e){return cn(e.file_path)},getResultSummary(e){const t=e;return t!=null&&t.file?t.type==="pdf"?"PDF":t.type==="image"?"Image":to(t.file)?t.file.numLines<=0?"0 lines":cn(t.file.filePath):"unchanged":"Reading..."},renderInteractiveSummary(e,t,n,r){return s.jsx(nj,{input:e,result:t,isError:n})}}),rj="_toolUse_yz7zv_1",oj="_name_yz7zv_8",ij="_args_yz7zv_17",aj="_result_yz7zv_22",lj="_label_yz7zv_29",cj="_error_yz7zv_33",it={toolUse:rj,name:oj,args:ij,result:aj,label:lj,error:cj};function no(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim();if(t)return t.length>120?`${t.slice(0,117)}...`:t}function Gl(e,t){return(e==null?void 0:e.commandName)??(t==null?void 0:t.skill)??"skill"}function dj({input:e}){const t=no(e.args);return s.jsxs("div",{className:it.toolUse,children:[s.jsx("code",{className:it.name,children:e.skill}),t?s.jsx("span",{className:it.args,children:t}):null]})}function uj({result:e,input:t}){const n=Gl(e,t);if(!e.success)return s.jsxs("div",{className:it.error,children:[n," did not load"]});const r=no(t==null?void 0:t.args);return s.jsxs("div",{className:it.result,children:[s.jsx("span",{className:it.label,children:"Loaded"}),s.jsx("code",{className:it.name,children:n}),r?s.jsx("span",{className:it.args,children:r}):null]})}const mj=de(fe.Skill,{tool:"Skill",displayName:"Skill",pendingDisplayName:"Loading skill",renderToolUse(e,t){return s.jsx(dj,{input:e})},renderToolResult(e,t,n,r){return s.jsx(uj,{result:e,input:r})},renderFailure(e){return s.jsx("div",{className:it.error,children:e.content||"Skill failed"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=no(e.args);return t?`${e.skill} ${t}`:e.skill},getResultSummary(e,t,n){return t?"Error":e.success?Gl(e,n):"Not loaded"}}),so=m.createContext(null);function Y_({children:e,agentContent:t,mergeLoadedAgentContent:n,toolUseToAgent:r,projectId:o}){const[i,a]=m.useState(new Set),l=m.useRef(new Set),c=m.useCallback(async(f,h,g)=>{if(l.current.has(g))return t[g]??{messages:[],status:"pending"};if(i.has(g))return new Promise(p=>{const y=setInterval(()=>{l.current.has(g)&&(clearInterval(y),p(t[g]??{messages:[],status:"pending"}))},100);setTimeout(()=>{clearInterval(y),p({messages:[],status:"pending"})},3e4)});a(p=>new Set(p).add(g));try{const p=await on.getAgentSession(f,h,g);return l.current.add(g),n(g,p),{messages:p.messages,status:p.status}}catch(p){return console.error(`Failed to load agent content for ${g}:`,p),{messages:[],status:"failed"}}finally{a(p=>{const y=new Set(p);return y.delete(g),y})}},[t,i,n]),d=m.useCallback(f=>i.has(f),[i]),u=m.useMemo(()=>({agentContent:t,toolUseToAgent:r,loadAgentContent:c,isLoading:d,projectId:o}),[t,r,c,d,o]);return s.jsx(so.Provider,{value:u,children:e})}function Di(e){return`${e.type}:${e.id}`}function zl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function fj(e,t){return zl(e.sourceMessages,t.sourceMessages)}function Un(e,t,n){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((r,o)=>{const i=t[o];return i!==void 0&&n(r,i)})}function hj(e,t){return e.id===t.id&&e.kind===t.kind&&e.slot===t.slot&&e.thinking===t.thinking&&e.status===t.status&&e.endedAtMs===t.endedAtMs}function Oi(e,t){return e.label===t.label&&e.detail===t.detail&&e.preview===t.preview}function $n(e,t){return Un(e,t,(n,r)=>n.text===r.text&&n.filePath===r.filePath)}function Ui(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return xs(e._projectPathLinks)}function pj(e,t){var n,r;if(e.type!==t.type||e.id!==t.id||e.isSubagent!==t.isSubagent||JSON.stringify(e.workflow)!==JSON.stringify(t.workflow)||!fj(e,t))return!1;switch(e.type){case"text":return t.type==="text"&&e.text===t.text&&e.isStreaming===t.isStreaming&&e.augmentHtml===t.augmentHtml&&$n(e.projectPathLinks,t.projectPathLinks);case"thinking":return t.type==="thinking"&&e.thinking===t.thinking&&e.signature===t.signature&&e.status===t.status;case"tool_call":return t.type==="tool_call"&&e.toolName===t.toolName&&e.status===t.status&&$n(Ui(e.toolInput),Ui(t.toolInput))&&$n((n=e.toolResult)==null?void 0:n.projectPathLinks,(r=t.toolResult)==null?void 0:r.projectPathLinks);case"user_prompt":return t.type==="user_prompt"&&e.content===t.content&&$n(e.projectPathLinks,t.projectPathLinks);case"session_setup":return t.type==="session_setup"&&e.title===t.title&&zl(e.prompts,t.prompts);case"transcript_display_object":return t.type==="transcript_display_object"&&e.object===t.object;case"system":return t.type==="system"&&e.subtype===t.subtype&&e.content===t.content&&e.status===t.status&&e.configChanged===t.configChanged;case"task_notification":return t.type==="task_notification"&&e.raw===t.raw;case"conversation_activity":return t.type==="conversation_activity"&&e.activityCount===t.activityCount&&e.active===t.active&&e.expanded===t.expanded&&e.hasFollowingConversationText===t.hasFollowingConversationText&&Un(e.thinkingPreviews,t.thinkingPreviews,hj)&&Un(e.recentActivities,t.recentActivities,Oi)&&Un(e.tooltipActivities,t.tooltipActivities,Oi)&&e.startedAtMs===t.startedAtMs&&e.endedAtMs===t.endedAtMs}}function gj(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;for(const r of e){const o=Di(r),i=n.get(o);i?i.push(r):n.set(o,[r])}return t.map(r=>{const o=n.get(Di(r));if(!o)return r;const i=o.findIndex(l=>pj(l,r));if(i===-1)return r;const[a]=o.splice(i,1);return a??r})}function J_({messages:e,provider:t,markdownAugments:n,activeToolApproval:r,transcriptDisplayObjects:o=[],recoverUnanchoredBangCommands:i=!1,previousRenderItems:a=[],recentProjectPathLinksEnabled:l=!1,workflowTagsEnabled:c=!1,workflowSchemaFiles:d}){const u=Fr(e,{markdown:n,activeToolApproval:r,workflowTags:c,workflowSchemaFiles:d},l),f=t==="claude-gateway"?u.filter(g=>g.type!=="thinking"||g.thinking!=="Thinking..."):u,h=Qm(f,o,i);return gj(a,h)}function Q_(e){const t=[];let n=[];for(const r of e)r.type==="transcript_display_object"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!1,isStandalone:!0,items:[r]})):r.type==="user_prompt"||r.type==="session_setup"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!0,items:[r]})):n.push(r);return n.length>0&&t.push({isUserPrompt:!1,items:n}),t}function xj(e,t){return e.isUserPrompt!==t.isUserPrompt||e.isStandalone!==t.isStandalone||e.items.length!==t.items.length?!1:e.items.every((n,r)=>n===t.items[r])}function Hi(e,t){const n=e.items[0];return n?`${e.isUserPrompt?"user":"assistant"}:${n.type}:${n.id}`:`empty:${t}`}function Z_(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;return e.forEach((r,o)=>{const i=Hi(r,o),a=n.get(i);a?a.push(r):n.set(i,[r])}),t.map((r,o)=>{const i=n.get(Hi(r,o));if(!i)return r;const a=i.findIndex(c=>xj(c,r));if(a===-1)return r;const[l]=i.splice(a,1);return l??r})}function eN(e){let t=null;for(const n of e){const r=fs(n.sourceMessages);r!==null&&(t=t===null?r:Math.max(t,r))}return t}function tN(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&fs(n.sourceMessages)!==null)return n}return null}function nN(e,t){return e.isStandalone||!e.isUserPrompt?!0:!t||t.isUserPrompt||t.isStandalone===!0}function sN({asides:e=[],deferredMessages:t=[],displayRenderItems:n,pendingMessages:r=[],projectQueueMessages:o=[]}){let i=null;const a=l=>{l!==null&&(i=i===null?l:Math.max(i,l))};for(const l of n)a(fs(l.sourceMessages));for(const l of r)a(nn(l.timestamp));for(const l of t)a(nn(l.timestamp));for(const l of o)a(nn(l.timestamp));for(const l of e)a(nn(l.historyAt??l.updatedAt));return i}function xn(e){for(const t of e.sourceMessages){const n=t.rewoundGroupId;if(typeof n=="string"&&n)return n}}function rN(e,t){const n=t.expandedRewoundGroups,r=new Map;for(const a of e){const l=xn(a);if(!(!l||r.has(l)))for(const c of a.sourceMessages){const d=c.rewoundParentGroupId;if(typeof d=="string"&&d){r.set(l,d);break}}}const o=a=>{const l=new Set;let c=a;for(;c&&!l.has(c);){if(!(n!=null&&n.has(c)))return!1;l.add(c),c=r.get(c)}return!0},i=a=>{if(!t.thinkingItemsVisible&&a.type==="thinking")return!1;const l=xn(a);return l?a.type==="system"&&a.subtype==="rewound_group"?o(r.get(l)):o(l):!0};return e.every(i)?e:e.filter(i)}const yj=32;function jj(e,t=yj){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function bj(e,t,n={}){const{enabled:r=!0,identity:o}=n,i=m.useRef(!0),a=m.useRef(o),l=m.useCallback(()=>{const c=e.current;c&&(i.current=jj(c))},[e]);return m.useLayoutEffect(()=>{if(Object.is(a.current,o)||(a.current=o,i.current=!0),!r)return;const c=e.current;!c||!i.current||(c.scrollTop=c.scrollHeight)},[e,t,r,o]),{onScroll:l}}const ql=3e4;function vj(e,t,n,r=ql){return!e||t>=e.heightPx?{heightPx:t,shrankAtMs:null}:e.shrankAtMs===null?{heightPx:e.heightPx,shrankAtMs:n}:n-e.shrankAtMs>=r?{heightPx:t,shrankAtMs:null}:e}function wj(e,t,n=ql){return e.shrankAtMs===null?null:Math.max(0,e.shrankAtMs+n-t)}const _j=48,Nj=256,kj=544,Sj=288;function Wi(e,t,n){const r=Math.max(Nj,Math.min(kj,Math.ceil(n)+_j));return(e==null?void 0:e.id)===t&&e.targetWidthPx>=r?e:{id:t,targetWidthPx:r}}const Cj=5e3,Vi=1500;function Gi({active:e,hasFollowingConversationText:t,endedAtMs:n,shownSinceMs:r=null,nowMs:o,hideAfterMs:i=Cj}){if(e||!t)return null;const a=n===null?r:r===null?n:Math.max(n,r);if(a===null)return 0;const l=i-(o-a);return l>0?l:0}const Tj=2,Rj=1.5;function Pj({viewportHeightPx:e,trailingContentPx:t,contextReservePx:n,previousTopPx:r,previousChromePx:o,minContentHeightPx:i}){const a=Kl(e,t+n)-r-o;return a>=(i??n)?a:null}function Kl(e,t){return Math.max(0,e-t)}const Ej=2,Ij=1,Mj=4;function $j(e,t,n=Ej){return e===null||t>e?t:e-t<=n?e:t}function Lj(e,t,n=Ij,r=Mj){return e<=n?!0:e>r?!1:t}function Aj(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}`:`${r}s`}function Fj({object:e,targetHref:t,onCancel:n,onToggleAutoOpen:r,onFollow:o}){const{t:i}=Z(),[a,l]=m.useState(()=>Date.now());if(m.useEffect(()=>{if(e.status!=="generating")return;const u=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(u)},[e.status]),e.status==="generating")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-generating",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-spinner","aria-hidden":"true"}),s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryProgress")}),s.jsx("span",{className:"fork-summary-display-object-elapsed",children:Aj(a-Date.parse(e.createdAt))}),s.jsxs("label",{className:"fork-summary-display-object-autoopen",children:[s.jsx("input",{type:"checkbox",checked:e.autoOpenWhenReady??!1,onChange:u=>r(u.target.checked)}),i("forkSummaryAutoOpenToggle")]}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryCancelInFlight")})]});if(e.status==="error")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-error",role:"alert",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:e.error?`${i("forkSummaryFailed")}: ${e.error}`:i("forkSummaryFailed")}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryDismiss")})]});const c=e.title??i("forkSummaryReadyFallbackTitle"),d=e.clickedAt?i("forkSummaryClicked"):e.openedAt?i("forkSummaryOpenedMarker"):void 0;return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-ready",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryReadyPrefix")}),s.jsxs("a",{className:"fork-summary-display-object-link",href:t??"#",target:"_blank",rel:"noopener noreferrer",onClick:o,title:c,children:[c," ↗"]}),d&&s.jsx("span",{className:"fork-summary-display-object-state",children:d})]})}function Bj(e){if(typeof e=="string")return`s:${e.length}:${e.slice(0,80)}`;const t=e.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
96
- `);return`a:${e.length}:${t.length}:${t.slice(0,80)}`}const Dj=m.memo(function({title:t,prompts:n}){const r=new Map;return s.jsxs("details",{className:"session-setup-block collapsible",children:[s.jsxs("summary",{className:"collapsible__summary",children:[s.jsx("span",{className:"collapsible__icon",children:"▸"}),s.jsx("span",{children:t})]}),s.jsx("div",{className:"collapsible__content",children:n.map(o=>{const i=Bj(o),a=(r.get(i)??0)+1;return r.set(i,a),s.jsx("div",{className:"session-setup-entry",children:s.jsx(al,{content:o})},`${i}:${a}`)})})]})});function Oj(e){switch(e){case"completed":return{variant:"task-notification-completed",icon:"✓"};case"failed":case"error":return{variant:"task-notification-failed",icon:"!"};case"cancelled":case"canceled":return{variant:"task-notification-cancelled",icon:"⊘"};default:return{variant:"task-notification-progress",icon:"⟳"}}}const Uj=m.memo(function({item:t}){const{variant:n,icon:r}=Oj(t.status),o=t.summary??t.raw.trim();return s.jsxs("div",{className:`task-notification ${n}`.trim(),children:[s.jsxs("div",{className:"task-notification-head",children:[s.jsx("span",{className:"task-notification-icon","aria-hidden":"true",children:r}),s.jsx("span",{className:"task-notification-summary",children:o}),t.outputFile&&s.jsx("span",{className:"task-notification-output",title:t.outputFile,children:Dr(t.outputFile)})]}),t.event&&s.jsx("pre",{className:"task-notification-event",children:t.event.trim()})]})});function Hj(e){const t=Math.max(0,e)/1e3;if(t<10)return`${t.toFixed(1)} sec`;if(t<60)return`${Math.round(t)} sec`;const n=t/60;return n<10?`${n.toFixed(1)} min`:`${Math.round(n)} min`}const Wj=m.memo(function({thinking:t,status:n,isExpanded:r,onToggle:o,durationMs:i}){const a=n==="streaming",l=i!==void 0&&i>=100?Hj(i):null,c=["thinking-block","collapsible","timeline-item",a&&!r?"thinking-streaming-collapsed":""].filter(Boolean).join(" ");return s.jsxs("details",{className:c,open:r,onToggle:d=>{d.currentTarget.open!==r&&o()},children:[s.jsxs("summary",{className:"collapsible__summary","aria-label":r?"Collapse thinking":"Expand thinking",title:r?"Collapse thinking":"Expand thinking",children:[s.jsx("span",{className:"timeline-dot-btn","aria-hidden":!0}),s.jsxs("span",{children:[a?"Thinking...":"Thinking",l&&s.jsxs("span",{className:"thinking-duration",children:["for ",l]})]}),s.jsx("span",{className:"collapsible__icon",children:"▸"})]}),s.jsx("div",{className:"collapsible__content",children:s.jsx(Ir,{text:t,isStreaming:a})})]})}),Xl="\0";function zi(e,t){return[e,t].join(Xl)}function Vj(e){const t=e.indexOf(Xl);return t===-1?e:e.slice(0,t)}function oN(){const e=new Map;return{get size(){return e.size},read(t,n,r){const o=e.get(zi(t,n));return o===void 0?{expanded:r,overridden:!1}:{expanded:o,overridden:!0}},write(t,n,r,o){const i=zi(t,n);o===r?e.delete(i):e.set(i,o)},pruneOwners(t){for(const n of e.keys())t.has(Vj(n))||e.delete(n)}}}const Yl=m.createContext(null);function iN({children:e,registry:t}){return s.jsx(Yl.Provider,{value:t,children:e})}function Dt(e,t,n){const r=m.useContext(Yl),[o]=m.useState(()=>(r==null?void 0:r.read(e,t,n))??{expanded:n,overridden:!1}),[i,a]=m.useState(o.expanded),l=m.useCallback(c=>{a(d=>{const u=typeof c=="function"?c(d):c;return r==null||r.write(e,t,n,u),u})},[t,n,e,r]);return[i,l,o.overridden]}const Gj="_toggle_ipqut_1",zj="_inline_ipqut_23",qi={toggle:Gj,inline:zj};function ro({expanded:e,label:t,onClick:n,controls:r,status:o,inline:i=!1}){return s.jsx("button",{type:"button",className:`${qi.toggle} ${i?qi.inline:""}`,onClick:n,"aria-label":t,"aria-expanded":e,"aria-controls":r,title:t,"data-status":o,children:s.jsx("span",{"aria-hidden":"true",children:e?"−":"+"})})}const qj="_root_7iwcz_3",Kj="_rowHeader_7iwcz_8",Xj="_filename_7iwcz_17",Yj="_suffix_7iwcz_39",Jj="_dimensions_7iwcz_40",Qj="_row_7iwcz_8",Zj="_rejected_7iwcz_49",eb="_preview_7iwcz_53",tb="_loading_7iwcz_67",nb="_error_7iwcz_68",sb="_imageButton_7iwcz_76",Le={root:qj,rowHeader:Kj,filename:Xj,suffix:Yj,dimensions:Jj,row:Qj,rejected:Zj,preview:eb,loading:tb,error:nb,imageButton:sb},rb={"invalid-image-data":"toolResultMediaInvalidImageData","source-unavailable":"toolResultMediaSourceUnavailable","storage-unavailable":"toolResultMediaStorageUnavailable","too-large":"toolResultMediaTooLarge","unsupported-media":"toolResultMediaUnsupportedMedia"};function ob({displayName:e,media:t,sourcePath:n,status:r}){return s.jsx("div",{className:Le.root,children:t.map((o,i)=>s.jsx(ib,{displayName:e,index:i,media:o,sourcePath:n,status:r},o.state==="stored"?o.id:`${o.reason}-${i}`))})}function ib({displayName:e,index:t,media:n,sourcePath:r,status:o}){const{inlineMediaExpandedByDefault:i}=kr(),{t:a}=Z(),l=n.filename||a("toolResultMediaUnnamed",{number:t+1});return n.state==="rejected"?s.jsx("div",{className:`tool-row timeline-item status-${o} ${Le.row} ${Le.rejected}`,children:s.jsxs("div",{className:Le.rowHeader,title:a(rb[n.reason]),children:[s.jsx("span",{className:"tool-name",children:e}),s.jsx("span",{className:Le.filename,children:l}),s.jsxs("span",{className:Le.suffix,children:["(",a("toolResultMediaUnavailable"),")"]})]})}):s.jsx(ab,{displayName:e,filename:l,initialExpanded:i,media:n,sourcePath:r,status:o})}function ab({displayName:e,filename:t,initialExpanded:n,media:r,sourcePath:o,status:i}){const{projectId:a,sessionId:l}=gs(),c=Kt().transport,{t:d}=Z(),[u,f]=Dt(r.toolCallId,`media-preview:${r.id}`,n),[h,g]=m.useState({state:"idle"}),[p,y]=m.useState(!1),x=`/api/projects/${encodeURIComponent(a)}/sessions/${encodeURIComponent(l)}/media/${encodeURIComponent(r.id)}`,b=m.useMemo(()=>({buildApiPath:()=>x}),[x]),_=m.useCallback(()=>c.fetchBlob(Bd(x)),[x,c]),N=m.useCallback(()=>y(!0),[]),v=hs({fileName:t,filePath:o,loadBlob:_,onOpen:N});m.useEffect(()=>{if(!u){g({state:"idle"});return}let S=!1,$=null;return g({state:"loading"}),_().then(T=>{if($=URL.createObjectURL(T),S){URL.revokeObjectURL($);return}g({state:"loaded",objectUrl:$})}).catch(()=>{S||g({state:"error"})}),()=>{S=!0,$&&URL.revokeObjectURL($)}},[u,_]);const j=r.mimeType.startsWith("video/"),C=r.width&&r.height?`${r.width}×${r.height}`:null,w={"--tool-result-media-aspect-ratio":r.width&&r.height?`${r.width} / ${r.height}`:"16 / 9","--tool-result-media-max-width":r.width?`${Math.min(r.width,720)}px`:"720px"},k=d(u?"toolResultMediaCollapse":"toolResultMediaExpand");return s.jsxs("div",{className:`tool-row timeline-item status-${i} ${Le.row}`,children:[s.jsx(ro,{expanded:u,label:k,status:i,onClick:()=>f(S=>!S)}),s.jsxs("div",{className:Le.rowHeader,children:[s.jsx("span",{className:"tool-name",children:e}),s.jsx("button",{type:"button",className:Le.filename,onClick:N,onContextMenu:v.handleContextMenu,children:t}),s.jsxs("span",{className:Le.suffix,children:["(",d(j?"toolResultMediaVideo":"toolResultMediaImage"),")"]}),C&&s.jsx("span",{className:Le.dimensions,children:C})]}),u&&s.jsxs("div",{className:Le.preview,style:w,children:[h.state==="loading"&&s.jsx("span",{className:Le.loading,children:d("toolResultMediaLoading")}),h.state==="error"&&s.jsx("span",{className:Le.error,children:d("toolResultMediaLoadFailed")}),h.state==="loaded"&&(j?s.jsx("video",{className:Le.imageButton,src:h.objectUrl,controls:!0,playsInline:!0,preload:"metadata","aria-label":d("toolResultMediaAlt",{filename:t})}):s.jsx("button",{type:"button",className:Le.imageButton,onClick:N,onContextMenu:v.handleContextMenu,"aria-label":d("toolResultMediaOpen",{filename:t}),children:s.jsx("img",{src:h.objectUrl,alt:d("toolResultMediaAlt",{filename:t}),width:r.width,height:r.height})}))]}),p&&s.jsx(qt,{path:t,filePath:o??null,mediaType:j?"video":"image",mediaSource:b,onClose:()=>y(!1)}),v.contextMenuElement]})}function lb(e,t,n){if(n!==1||!t||typeof t!="object")return;const r=e.toLowerCase().replaceAll("_","");if(r!=="viewimage"&&r!=="imageview"&&r!=="read")return;const o=t,i=[o.path,o.file_path,o.filePath].filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean);return new Set(i).size===1?i[0]:void 0}const cb=500,db=/^timeout waiting for ([^\r\n]+) to reach not-running; current status=running$/;function ub(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Hn(e){const t=ht(e);if(t)return t.parts.filter(n=>n.kind!=="script-status").map(n=>n.text).join(`
94
+ `),l=st(a);return s.jsxs(s.Fragment,{children:[s.jsx("pre",{ref:l,className:`${Y.content} code-block`,children:s.jsx("code",{children:a})}),o&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${r.length} lines`})]})}function Ny({input:e,result:t,isError:n,projectPath:r}){const o=us(),i=m.useMemo(()=>n||(t==null?void 0:t.mode)!=="content"?[]:t.matches??[],[n,t]),a=Math.max(0,o-1),l=i.slice(0,a);if(l.length===0)return null;const c=Ol(i),d=Math.max(0,i.length-l.length);return s.jsxs("div",{className:Y.collapsedPreview,children:[l.map((u,f)=>s.jsxs("div",{className:Y.previewMatch,children:[c&&s.jsx("span",{className:Y.previewFile,title:oe(u.filePath,r),children:eo(oe(u.filePath,r))}),s.jsx("span",{className:Y.previewLine,children:u.columnNumber?`${u.lineNumber}:${u.columnNumber}`:u.lineNumber}),s.jsx(ky,{match:u,pattern:e==null?void 0:e.pattern})]},`${u.filePath}:${u.lineNumber}:${u.columnNumber??""}:${f}`)),d>0&&s.jsxs("div",{className:Y.previewMore,children:["+",d," ",d===1?"match":"matches"]})]})}function ky({match:e,pattern:t}){const n=st(e.text);return s.jsx("span",{ref:n,className:Y.previewText,children:Bl(e.text,e.ranges,t)})}function Sy({input:e,result:t,projectPath:n}){const[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&t){const x=we("Grep",t);!x.valid&&x.errors?(d(x.errors),a("Grep",x.errors)):d(null)}},[i,t,a]);const u=i&&c&&!l("Grep");if(!t)return s.jsx("div",{className:Y.empty,children:"No results"});const{mode:f,filenames:h,numFiles:g,content:p,appliedLimit:y}=t;if(f==="count")return s.jsxs("div",{className:Y.result,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),s.jsxs("div",{className:Y.countSummary,children:[g," ",g===1?"file":"files"," matched"]})]});if(f==="content"&&p){const x=t.matches??[],b=x.length||Fl(p),_=`${b} ${b===1?"match":"matches"}`;return s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsx(Dl,{label:_,matches:x,pattern:e==null?void 0:e.pattern,projectPath:n}),y&&s.jsxs("span",{className:"badge badge-info",children:["limit: ",y]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(_y,{content:p,isExpanded:r,setIsExpanded:o})]})}return!h||h.length===0?s.jsxs("div",{className:Y.empty,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),"No matches found"]}):s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsxs("span",{className:Y.count,children:[g," files"]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(wy,{filenames:h,isExpanded:r,projectPath:n,setIsExpanded:o})]})}function Ul(e,t){if(e.path){const n=oe(e.path,t);return{kind:"path",value:e.path,label:eo(n)}}return e.glob?{kind:"glob",value:e.glob,label:e.glob}:null}function Hl(e,t){const n=Ul(e,t);if(!n)return e.pattern;const r=n.kind==="path"?oe(n.value,t):n.value;return`${e.pattern} in ${r}`}function Cy(e,t,n){if(t<=0)return"";if(n(e)<=t)return e;if(n(Os)>t)return"";let r=0,o=e.length;for(;r<o;){const i=Math.ceil((r+o)/2),a=`${e.slice(0,i)}${Os}`;n(a)<=t?r=i:o=i-1}return`${e.slice(0,r)}${Os}`}function Ty({expanded:e,input:t,onToggle:n,projectPath:r}){const o=Hl(t,r),i=Ul(t,r),a=(i==null?void 0:i.value)??"",l=m.useRef(null),c=m.useRef(null),d=m.useRef(null),[u,f]=m.useState(t.pattern);m.useLayoutEffect(()=>{const p=()=>{var C;if(e){f(t.pattern);return}const x=l.current,b=d.current;if(!x||!b){f(t.pattern);return}const _=x.getBoundingClientRect().width;if(_<=0){f(t.pattern);return}const N=((C=c.current)==null?void 0:C.getBoundingClientRect().width)??0,v=Math.max(0,_-N-(N>0?xy:0)),j=w=>(b.textContent=w,b.getBoundingClientRect().width);f(Cy(t.pattern,v,j))};if(p(),typeof ResizeObserver>"u")return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const y=new ResizeObserver(p);return l.current&&y.observe(l.current),c.current&&y.observe(c.current),()=>y.disconnect()},[e,t.pattern,a]);const h=`${Y.summaryPatternClip}${n?` ${Y.summaryPatternAction}`:""}`,g=n?s.jsx("button",{type:"button",className:h,title:o,"aria-label":e?"Collapse grep pattern":"Show full grep pattern","aria-expanded":e,onClick:p=>{p.preventDefault(),p.stopPropagation(),n()},children:u}):s.jsx("span",{className:h,title:o,children:u});return s.jsxs("span",{className:`${Y.summaryPattern}${e?" is-expanded":""}`,children:[s.jsxs("span",{className:Y.summaryPatternRow,ref:l,children:[g,i&&s.jsxs("span",{className:Y.summaryScope,ref:c,children:[s.jsx("span",{className:Y.summaryScopePrefix,children:"in"}),i.kind==="path"?s.jsx(Ue,{displayPath:i.label,filePath:i.value,showLineSuffix:!1}):s.jsx("span",{className:Y.summaryScopeText,title:i.value,children:i.label})]})]}),s.jsx("span",{className:Y.summaryPatternMeasure,ref:d}),e&&s.jsx("span",{className:Y.summaryPatternFull,children:o})]})}function Wl(e){if(e.mode==="content"){const t=e.matches??[],n=t.length||Fl(e.content);return{matches:t,text:`${n} ${n===1?"match":"matches"}`}}return e.numFiles===0?{matches:[],text:"0 matches"}:{matches:[],text:e.numFiles!==void 0?`${e.numFiles} ${e.numFiles===1?"file":"files"}`:"Results"}}function Ry({input:e,result:t,isError:n,projectPath:r,summaryExpanded:o,toggleSummaryExpanded:i}){if(n||!t)return null;const a=Wl(t);return s.jsxs("span",{className:Y.inlineSummary,children:[s.jsx(Ty,{expanded:o??!1,input:e,onToggle:i,projectPath:r}),s.jsx("span",{className:Y.summaryArrow,"aria-hidden":"true",children:"→"}),s.jsx(Dl,{label:a.text,matches:a.matches,pattern:e.pattern,projectPath:r})]})}const Py=de(fe.Grep,{tool:"Grep",displayName:"Grep",renderToolUse(e,t){return s.jsx(vy,{input:e,projectPath:t.projectPath})},renderToolResult(e,t,n,r){return s.jsx(Sy,{input:r,result:e,projectPath:n.projectPath})},renderFailure(e){return s.jsx("div",{className:Y.error,children:e.content||"Search failed"})},getFailureSummary(){return"Error"},getUseSummary(e,t){return Hl(e,t==null?void 0:t.projectPath)},getResultSummary(e){const t=e;return t?Wl(t).text:"Results"},renderInteractiveSummary(e,t,n,r){return s.jsx(Ry,{input:e,result:t,isError:n,projectPath:r.projectPath,summaryExpanded:r.summaryExpanded,toggleSummaryExpanded:r.toggleSummaryExpanded})},renderCollapsedPreview(e,t,n,r){return s.jsx(Ny,{input:e,result:t,isError:n,projectPath:r.projectPath})}}),Ey="_toolUse_1vtak_1",Iy="_label_1vtak_7",My="_shellId_1vtak_11",$y="_result_1vtak_20",Ly="_message_1vtak_26",Ay="_error_1vtak_30",Fy="_empty_1vtak_37",ut={toolUse:Ey,label:Iy,shellId:My,result:$y,message:Ly,error:Ay,empty:Fy};function By({input:e}){return s.jsxs("div",{className:ut.toolUse,children:[s.jsx("span",{className:ut.label,children:"Killing shell"}),s.jsx("code",{className:ut.shellId,children:e.shell_id})]})}function Dy({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("KillShell",e);!l.valid&&l.errors?(i(l.errors),n("KillShell",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("KillShell");return e?s.jsxs("div",{className:ut.result,children:[a&&o&&s.jsx(q,{toolName:"KillShell",errors:o}),s.jsx("span",{className:ut.message,children:e.message}),e.shell_id&&s.jsx("code",{className:ut.shellId,children:e.shell_id})]}):s.jsx("div",{className:ut.empty,children:"No result"})}const Oy=de(fe.KillShell,{tool:"KillShell",renderToolUse(e,t){return s.jsx(By,{input:e})},renderToolResult(e,t,n){return s.jsx(Dy,{result:e})},renderFailure(e){return s.jsx("div",{className:ut.error,children:e.content||"Failed to kill shell"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.shell_id},getResultSummary(e){const t=e;return(t==null?void 0:t.message)||"Killed"}}),Uy="_container_blm34_7",Hy={container:Uy};function ws({html:e,className:t}){return s.jsx("div",{className:`shiki-container ${Hy.container}${t?` ${t}`:""}`,dangerouslySetInnerHTML:{__html:Wd(e)??""}})}const Wy="_imagePreviewButton_1dcmz_1",Vy={imagePreviewButton:Wy};function cn(e){return tt(e)}function to(e){return"content"in e&&typeof e.content=="string"}function Gy(e){return"filePath"in e?e.filePath??"":""}function zy({filePath:e}){const t=ge(),n=oe(e,t==null?void 0:t.projectPath);return s.jsx("div",{className:"read-text-result read-text-inline",children:s.jsx(vt,{displayPath:n,filePath:e,children:s.jsx("span",{className:"file-line-count-inline",children:"unchanged"})})})}function mr(e){if(e.numLines<=0)return{};if(!(e.startLine>1||e.numLines<e.totalLines))return{};const n=e.startLine+Math.max(1,e.numLines)-1;return{lineEnd:n>e.startLine?n:void 0,lineNumber:e.startLine}}function qy(e){if(e.offset===void 0)return{};const t=e.limit!==void 0?e.offset+Math.max(1,e.limit)-1:void 0;return{lineEnd:t!==void 0&&t>e.offset?t:void 0,lineNumber:e.offset}}function Bi(e){return s.jsx("div",{className:"file-viewer-code fixed-font-rendered-panel",children:s.jsx("div",{className:"fixed-font-rendered__content",dangerouslySetInnerHTML:{__html:e}})})}function vt({children:e,displayPath:t,filePath:n,lineEnd:r,lineNumber:o}){return s.jsxs("span",{className:"file-link-inline",children:[s.jsx(Ue,{displayPath:t,filePath:n,lineEnd:r,lineNumber:o}),e&&s.jsxs(s.Fragment,{children:[" ",e]})]})}function Vl({filePath:e,lineEnd:t,lineNumber:n,text:r}){return s.jsx(Ue,{displayPath:r,filePath:e,lineEnd:t,lineNumber:n,showLineSuffix:!1,viewMode:"range",showCopyButton:!1})}function Ky({input:e}){const t=ge(),n=oe(e.file_path,t==null?void 0:t.projectPath),r=qy(e);return s.jsxs("div",{className:"read-tool-use",children:[s.jsx("span",{className:"file-path",children:s.jsx(Ue,{displayPath:n,filePath:e.file_path,lineEnd:r.lineEnd,lineNumber:r.lineNumber})}),(e.offset!==void 0||e.limit!==void 0)&&s.jsxs("span",{className:"read-range",title:`offset ${e.offset??0}, limit ${e.limit??"∞"}`,children:[e.offset!==void 0&&` from line ${e.offset}`,e.limit!==void 0&&` (${e.limit} lines)`]})]})}function Xy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=Sr(e.filePath),i=m.useMemo(()=>{if(!o||r)return null;const C=mn(e.content,{baseFilePath:e.filePath});return C.changed?C.html:null},[e.content,e.filePath,o,r]),a=o?r??i:null,l=!!a,[c,d]=m.useState(!1),u=st(t||c&&a?e.content:null),f=m.useMemo(()=>t?ka(e.content):null,[t,e.content]),h=!!(f!=null&&f.changed),[g,p]=m.useState(!1),{btnRef:y,handleClick:x}=Vd(g,()=>p(C=>!C)),b=e.content.length>0?e.content.split(`
95
+ `):[],_=e.content.length===0?s.jsx("div",{className:"file-viewer-empty-content",children:"No content read"}):t?s.jsxs("div",{className:"file-viewer-code file-viewer-code-highlighted",children:[s.jsx(ws,{html:t}),n&&s.jsx("div",{className:"file-viewer-truncated",children:"Content truncated for highlighting (showing first 2000 lines)"})]}):s.jsxs("div",{className:"file-content-with-lines",children:[s.jsx("div",{className:"line-numbers",children:b.map((C,w)=>s.jsx("div",{children:e.startLine+w},`ln-${w+1}`))}),s.jsx("pre",{className:"line-content",children:s.jsx("code",{children:e.content})})]}),N=c&&a?s.jsx(Pa,{html:a,sourcePath:e.filePath,density:Ea}):t?g&&f?Bi(f.html):_:s.jsx(Ye,{sourceText:e.content,renderMode:o?"rich":"math",sourceView:_,renderRenderedView:C=>Bi(C)}),v=l&&s.jsxs("div",{className:"markdown-view-toggle",children:[s.jsx("button",{type:"button",className:`toggle-btn ${c?"":"active"}`,onClick:()=>d(!1),children:"Source"}),s.jsx("button",{type:"button",className:`toggle-btn ${c?"active":""}`,onClick:()=>d(!0),children:"Preview"})]}),j=!l&&h;return s.jsxs("div",{className:"file-content-modal",ref:u,children:[v,j?s.jsxs("div",{className:"fixed-font-render-toggle",children:[N,s.jsx("button",{ref:y,type:"button",className:`fixed-font-render-toggle__button ${g?"is-rendered":""}`,onClick:x,"aria-label":g?"Show source":"Render math (LaTeX)",title:g?"Show source":"Render math (LaTeX)","aria-pressed":g,children:s.jsx(Ca,{})})]}):N]})}function Yy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=ge(),i=oe(e.filePath,o==null?void 0:o.projectPath),a=e.numLines>0,l=a&&(e.startLine>1||e.numLines<e.totalLines),c=mr(e);return s.jsxs("div",{className:"read-text-result read-text-inline",children:[s.jsx("div",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:i,filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber})}),l&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx(Vl,{filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber,text:`lines ${e.startLine}–${e.startLine+e.numLines-1}`})," ","of ",e.totalLines]}),!a&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),e.totalLines>0&&s.jsxs(s.Fragment,{children:[" of ",e.totalLines]})]}),s.jsx(Xy,{file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r})]})}function Jy(e,t){const n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)r[o]=n.charCodeAt(o);return new Blob([r],{type:t})}function Qy({file:e,filePath:t}){const{t:n}=Z(),r=e.originalSize?Math.round(e.originalSize/1024):0,{dimensions:o}=e,i=ge(),a=t?oe(t,i==null?void 0:i.projectPath):null,l=(o==null?void 0:o.originalWidth)!=null&&(o==null?void 0:o.originalHeight)!=null,{inlineMediaExpandedByDefault:c}=wr(),[d,u]=m.useState(null),f=d??c,[h,g]=m.useState(!1),p=Kt().transport,y=e.base64,x=m.useCallback(async()=>{if(y)return Jy(y,e.type);if(t)return _r(t,void 0,"inline",p);throw new Error("Read image result carries neither bytes nor a file path")},[e.type,t,y,p]),b=m.useMemo(()=>y?{buildApiPath:()=>"inline-read-image",fetchBlob:x}:void 0,[y,x]),_=y?`data:${e.type};base64,${y}`:null,{url:N,error:v}=$a(t??null,f&&!y,x),j=_??N,C=m.useCallback(()=>g(!0),[]),w=t?cn(t):"image",k=hs({fileName:w,filePath:t,loadBlob:x,onOpen:C});return s.jsxs("div",{className:"read-image-result",children:[s.jsxs("div",{className:"local-media-link-group",children:[s.jsx("button",{type:"button",className:"local-media-inline-toggle","aria-expanded":f,"aria-label":f?"Collapse image":"Expand image",title:f?"Collapse inline preview":"Expand inline preview",onClick:()=>u(!f),children:f?"-":"+"}),t&&a?s.jsx("span",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:a,filePath:t})}):s.jsx("span",{className:"local-media-type",children:"image"})]}),(l||r>0)&&s.jsxs("div",{className:"image-info",children:[l&&s.jsxs(s.Fragment,{children:[o.originalWidth,"x",o.originalHeight]}),l&&r>0&&" ",r>0&&s.jsxs(s.Fragment,{children:["(",r," ","kb)"]})]}),f&&(j?s.jsx("button",{type:"button",className:Vy.imagePreviewButton,"aria-label":`Open ${w}`,onClick:C,onContextMenu:k.handleContextMenu,children:s.jsx("img",{className:"read-image",src:j,alt:"File content",width:o==null?void 0:o.displayWidth,height:o==null?void 0:o.displayHeight})}):s.jsx("span",{className:"file-line-count-inline",children:n(v?"inlineImageUnavailable":"inlineImageLoading")})),h?s.jsx(qt,{path:y?w:t??w,filePath:t??null,mediaType:"image",mediaSource:b,onClose:()=>g(!1)}):null,k.contextMenuElement]})}function Zy(e){const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);const r=new Blob([n],{type:"application/pdf"}),o=URL.createObjectURL(r);window.open(o,"_blank")}function ej({file:e,filePath:t}){const n=e.originalSize?Math.round(e.originalSize/1024):0,r=t?cn(t):"document.pdf",o=ge(),i=t?oe(t,o==null?void 0:o.projectPath):null;if(t&&i)return s.jsx("div",{className:"read-pdf-result",children:s.jsxs(vt,{displayPath:i,filePath:t,children:[n>0&&s.jsxs("span",{className:"file-line-count-inline",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count-inline",children:"PDF"})]})});const a=e.base64;return a?s.jsx("div",{className:"read-pdf-result",children:s.jsxs("button",{type:"button",className:"file-link-button",onClick:()=>Zy(a),children:[r,n>0&&s.jsxs("span",{className:"file-line-count",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count",children:"Open PDF"})]})}):s.jsx("div",{className:"read-pdf-result",children:s.jsx("span",{className:"file-line-count-inline",children:"PDF"})})}function tj({input:e,result:t}){const{enabled:n,reportValidationError:r,isToolIgnored:o}=ve(),[i,a]=m.useState(null);m.useEffect(()=>{if(n&&t){const c=we("Read",t);!c.valid&&c.errors?(a(c.errors),r("Read",c.errors)):a(null)}},[n,t,r]);const l=n&&i&&!o("Read");return t!=null&&t.file?t.type==="pdf"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(ej,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):t.type==="image"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Qy,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):to(t.file)?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Yy,{file:t.file,highlightedHtml:t._highlightedContentHtml,highlightedTruncated:t._highlightedTruncated,renderedMarkdownHtml:t._renderedMarkdownHtml})]}):s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(zy,{filePath:Gy(t.file)||((e==null?void 0:e.file_path)??"")})]}):s.jsxs("div",{className:"read-error",children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),"Failed to read file"]})}function nj({input:e,result:t,isError:n}){const{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&t){const h=we("Read",t);!h.valid&&h.errors?(l(h.errors),o("Read",h.errors)):l(null)}},[r,t,o]);const c=r&&a&&!i("Read"),d=ge(),u=oe(e.file_path,d==null?void 0:d.projectPath);if(n)return s.jsxs("span",{children:[s.jsx(Ue,{displayPath:u,filePath:e.file_path}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!(t!=null&&t.file))return s.jsx("span",{children:s.jsx(Ue,{displayPath:u,filePath:e.file_path})});if(t.type==="pdf")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(PDF)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(t.type==="image")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(image)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!to(t.file))return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"unchanged"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});const f=t.file;return f.numLines<=0?s.jsxs(vt,{displayPath:u,filePath:f.filePath,children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]}):s.jsxs(vt,{displayPath:u,filePath:f.filePath,...mr(f),children:[s.jsx("span",{className:"file-line-count-inline",children:s.jsx(Vl,{filePath:f.filePath,text:`${f.numLines} lines`,...mr(f)})}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]})}const sj=de(fe.Read,{tool:"Read",renderToolUse(e,t){return s.jsx(Ky,{input:e})},renderToolResult(e,t,n,r){return s.jsx(tj,{input:r,result:e})},renderFailure(e){return s.jsx("div",{className:"read-error",children:e.content||"Failed to read file"})},getFailureSummary(e,t){return t?cn(t.file_path):"Error"},getUseSummary(e){return cn(e.file_path)},getResultSummary(e){const t=e;return t!=null&&t.file?t.type==="pdf"?"PDF":t.type==="image"?"Image":to(t.file)?t.file.numLines<=0?"0 lines":cn(t.file.filePath):"unchanged":"Reading..."},renderInteractiveSummary(e,t,n,r){return s.jsx(nj,{input:e,result:t,isError:n})}}),rj="_toolUse_yz7zv_1",oj="_name_yz7zv_8",ij="_args_yz7zv_17",aj="_result_yz7zv_22",lj="_label_yz7zv_29",cj="_error_yz7zv_33",ot={toolUse:rj,name:oj,args:ij,result:aj,label:lj,error:cj};function no(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim();if(t)return t.length>120?`${t.slice(0,117)}...`:t}function Gl(e,t){return(e==null?void 0:e.commandName)??(t==null?void 0:t.skill)??"skill"}function dj({input:e}){const t=no(e.args);return s.jsxs("div",{className:ot.toolUse,children:[s.jsx("code",{className:ot.name,children:e.skill}),t?s.jsx("span",{className:ot.args,children:t}):null]})}function uj({result:e,input:t}){const n=Gl(e,t);if(!e.success)return s.jsxs("div",{className:ot.error,children:[n," did not load"]});const r=no(t==null?void 0:t.args);return s.jsxs("div",{className:ot.result,children:[s.jsx("span",{className:ot.label,children:"Loaded"}),s.jsx("code",{className:ot.name,children:n}),r?s.jsx("span",{className:ot.args,children:r}):null]})}const mj=de(fe.Skill,{tool:"Skill",displayName:"Skill",pendingDisplayName:"Loading skill",renderToolUse(e,t){return s.jsx(dj,{input:e})},renderToolResult(e,t,n,r){return s.jsx(uj,{result:e,input:r})},renderFailure(e){return s.jsx("div",{className:ot.error,children:e.content||"Skill failed"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=no(e.args);return t?`${e.skill} ${t}`:e.skill},getResultSummary(e,t,n){return t?"Error":e.success?Gl(e,n):"Not loaded"}}),so=m.createContext(null);function Q_({children:e,agentContent:t,mergeLoadedAgentContent:n,toolUseToAgent:r,projectId:o}){const[i,a]=m.useState(new Set),l=m.useRef(new Set),c=m.useCallback(async(f,h,g)=>{if(l.current.has(g))return t[g]??{messages:[],status:"pending"};if(i.has(g))return new Promise(p=>{const y=setInterval(()=>{l.current.has(g)&&(clearInterval(y),p(t[g]??{messages:[],status:"pending"}))},100);setTimeout(()=>{clearInterval(y),p({messages:[],status:"pending"})},3e4)});a(p=>new Set(p).add(g));try{const p=await on.getAgentSession(f,h,g);return l.current.add(g),n(g,p),{messages:p.messages,status:p.status}}catch(p){return console.error(`Failed to load agent content for ${g}:`,p),{messages:[],status:"failed"}}finally{a(p=>{const y=new Set(p);return y.delete(g),y})}},[t,i,n]),d=m.useCallback(f=>i.has(f),[i]),u=m.useMemo(()=>({agentContent:t,toolUseToAgent:r,loadAgentContent:c,isLoading:d,projectId:o}),[t,r,c,d,o]);return s.jsx(so.Provider,{value:u,children:e})}function Di(e){return`${e.type}:${e.id}`}function zl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function fj(e,t){return zl(e.sourceMessages,t.sourceMessages)}function Un(e,t,n){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((r,o)=>{const i=t[o];return i!==void 0&&n(r,i)})}function hj(e,t){return e.id===t.id&&e.kind===t.kind&&e.slot===t.slot&&e.thinking===t.thinking&&e.status===t.status&&e.endedAtMs===t.endedAtMs}function Oi(e,t){return e.label===t.label&&e.detail===t.detail&&e.preview===t.preview}function $n(e,t){return Un(e,t,(n,r)=>n.text===r.text&&n.filePath===r.filePath)}function Ui(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return xs(e._projectPathLinks)}function pj(e,t){var n,r;if(e.type!==t.type||e.id!==t.id||e.isSubagent!==t.isSubagent||JSON.stringify(e.workflow)!==JSON.stringify(t.workflow)||!fj(e,t))return!1;switch(e.type){case"text":return t.type==="text"&&e.text===t.text&&e.isStreaming===t.isStreaming&&e.augmentHtml===t.augmentHtml&&$n(e.projectPathLinks,t.projectPathLinks);case"thinking":return t.type==="thinking"&&e.thinking===t.thinking&&e.signature===t.signature&&e.status===t.status;case"tool_call":return t.type==="tool_call"&&e.toolName===t.toolName&&e.status===t.status&&$n(Ui(e.toolInput),Ui(t.toolInput))&&$n((n=e.toolResult)==null?void 0:n.projectPathLinks,(r=t.toolResult)==null?void 0:r.projectPathLinks);case"user_prompt":return t.type==="user_prompt"&&e.content===t.content&&$n(e.projectPathLinks,t.projectPathLinks);case"session_setup":return t.type==="session_setup"&&e.title===t.title&&zl(e.prompts,t.prompts);case"transcript_display_object":return t.type==="transcript_display_object"&&e.object===t.object;case"system":return t.type==="system"&&e.subtype===t.subtype&&e.content===t.content&&e.status===t.status&&e.configChanged===t.configChanged;case"task_notification":return t.type==="task_notification"&&e.raw===t.raw;case"conversation_activity":return t.type==="conversation_activity"&&e.activityCount===t.activityCount&&e.active===t.active&&e.expanded===t.expanded&&e.hasFollowingConversationText===t.hasFollowingConversationText&&Un(e.thinkingPreviews,t.thinkingPreviews,hj)&&Un(e.recentActivities,t.recentActivities,Oi)&&Un(e.tooltipActivities,t.tooltipActivities,Oi)&&e.startedAtMs===t.startedAtMs&&e.endedAtMs===t.endedAtMs}}function gj(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;for(const r of e){const o=Di(r),i=n.get(o);i?i.push(r):n.set(o,[r])}return t.map(r=>{const o=n.get(Di(r));if(!o)return r;const i=o.findIndex(l=>pj(l,r));if(i===-1)return r;const[a]=o.splice(i,1);return a??r})}function Z_({messages:e,provider:t,markdownAugments:n,activeToolApproval:r,transcriptDisplayObjects:o=[],recoverUnanchoredBangCommands:i=!1,previousRenderItems:a=[],recentProjectPathLinksEnabled:l=!1,workflowTagsEnabled:c=!1,workflowSchemaFiles:d}){const u=Fr(e,{markdown:n,activeToolApproval:r,workflowTags:c,workflowSchemaFiles:d},l),f=t==="claude-gateway"?u.filter(g=>g.type!=="thinking"||g.thinking!=="Thinking..."):u,h=Qm(f,o,i);return gj(a,h)}function eN(e){const t=[];let n=[];for(const r of e)r.type==="transcript_display_object"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!1,isStandalone:!0,items:[r]})):r.type==="user_prompt"||r.type==="session_setup"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!0,items:[r]})):n.push(r);return n.length>0&&t.push({isUserPrompt:!1,items:n}),t}function xj(e,t){return e.isUserPrompt!==t.isUserPrompt||e.isStandalone!==t.isStandalone||e.items.length!==t.items.length?!1:e.items.every((n,r)=>n===t.items[r])}function Hi(e,t){const n=e.items[0];return n?`${e.isUserPrompt?"user":"assistant"}:${n.type}:${n.id}`:`empty:${t}`}function tN(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;return e.forEach((r,o)=>{const i=Hi(r,o),a=n.get(i);a?a.push(r):n.set(i,[r])}),t.map((r,o)=>{const i=n.get(Hi(r,o));if(!i)return r;const a=i.findIndex(c=>xj(c,r));if(a===-1)return r;const[l]=i.splice(a,1);return l??r})}function nN(e){let t=null;for(const n of e){const r=fs(n.sourceMessages);r!==null&&(t=t===null?r:Math.max(t,r))}return t}function sN(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&fs(n.sourceMessages)!==null)return n}return null}function rN(e,t){return e.isStandalone||!e.isUserPrompt?!0:!t||t.isUserPrompt||t.isStandalone===!0}function oN({asides:e=[],deferredMessages:t=[],displayRenderItems:n,pendingMessages:r=[],projectQueueMessages:o=[]}){let i=null;const a=l=>{l!==null&&(i=i===null?l:Math.max(i,l))};for(const l of n)a(fs(l.sourceMessages));for(const l of r)a(nn(l.timestamp));for(const l of t)a(nn(l.timestamp));for(const l of o)a(nn(l.timestamp));for(const l of e)a(nn(l.historyAt??l.updatedAt));return i}function xn(e){for(const t of e.sourceMessages){const n=t.rewoundGroupId;if(typeof n=="string"&&n)return n}}function iN(e,t){const n=t.expandedRewoundGroups,r=new Map;for(const a of e){const l=xn(a);if(!(!l||r.has(l)))for(const c of a.sourceMessages){const d=c.rewoundParentGroupId;if(typeof d=="string"&&d){r.set(l,d);break}}}const o=a=>{const l=new Set;let c=a;for(;c&&!l.has(c);){if(!(n!=null&&n.has(c)))return!1;l.add(c),c=r.get(c)}return!0},i=a=>{if(!t.thinkingItemsVisible&&a.type==="thinking")return!1;const l=xn(a);return l?a.type==="system"&&a.subtype==="rewound_group"?o(r.get(l)):o(l):!0};return e.every(i)?e:e.filter(i)}const yj=32;function jj(e,t=yj){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function bj(e,t,n={}){const{enabled:r=!0,identity:o}=n,i=m.useRef(!0),a=m.useRef(o),l=m.useCallback(()=>{const c=e.current;c&&(i.current=jj(c))},[e]);return m.useLayoutEffect(()=>{if(Object.is(a.current,o)||(a.current=o,i.current=!0),!r)return;const c=e.current;!c||!i.current||(c.scrollTop=c.scrollHeight)},[e,t,r,o]),{onScroll:l}}const ql=3e4;function vj(e,t,n,r=ql){return!e||t>=e.heightPx?{heightPx:t,shrankAtMs:null}:e.shrankAtMs===null?{heightPx:e.heightPx,shrankAtMs:n}:n-e.shrankAtMs>=r?{heightPx:t,shrankAtMs:null}:e}function wj(e,t,n=ql){return e.shrankAtMs===null?null:Math.max(0,e.shrankAtMs+n-t)}const _j=48,Nj=256,kj=544,Sj=288;function Wi(e,t,n){const r=Math.max(Nj,Math.min(kj,Math.ceil(n)+_j));return(e==null?void 0:e.id)===t&&e.targetWidthPx>=r?e:{id:t,targetWidthPx:r}}const Cj=5e3,Vi=1500;function Gi({active:e,hasFollowingConversationText:t,endedAtMs:n,shownSinceMs:r=null,nowMs:o,hideAfterMs:i=Cj}){if(e||!t)return null;const a=n===null?r:r===null?n:Math.max(n,r);if(a===null)return 0;const l=i-(o-a);return l>0?l:0}const Tj=2,Rj=1.5;function Pj({viewportHeightPx:e,trailingContentPx:t,contextReservePx:n,previousTopPx:r,previousChromePx:o,minContentHeightPx:i}){const a=Kl(e,t+n)-r-o;return a>=(i??n)?a:null}function Kl(e,t){return Math.max(0,e-t)}const Ej=2,Ij=1,Mj=4;function $j(e,t,n=Ej){return e===null||t>e?t:e-t<=n?e:t}function Lj(e,t,n=Ij,r=Mj){return e<=n?!0:e>r?!1:t}function Aj(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}`:`${r}s`}function Fj({object:e,targetHref:t,onCancel:n,onToggleAutoOpen:r,onFollow:o}){const{t:i}=Z(),[a,l]=m.useState(()=>Date.now());if(m.useEffect(()=>{if(e.status!=="generating")return;const u=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(u)},[e.status]),e.status==="generating")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-generating",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-spinner","aria-hidden":"true"}),s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryProgress")}),s.jsx("span",{className:"fork-summary-display-object-elapsed",children:Aj(a-Date.parse(e.createdAt))}),s.jsxs("label",{className:"fork-summary-display-object-autoopen",children:[s.jsx("input",{type:"checkbox",checked:e.autoOpenWhenReady??!1,onChange:u=>r(u.target.checked)}),i("forkSummaryAutoOpenToggle")]}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryCancelInFlight")})]});if(e.status==="error")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-error",role:"alert",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:e.error?`${i("forkSummaryFailed")}: ${e.error}`:i("forkSummaryFailed")}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryDismiss")})]});const c=e.title??i("forkSummaryReadyFallbackTitle"),d=e.clickedAt?i("forkSummaryClicked"):e.openedAt?i("forkSummaryOpenedMarker"):void 0;return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-ready",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryReadyPrefix")}),s.jsxs("a",{className:"fork-summary-display-object-link",href:t??"#",target:"_blank",rel:"noopener noreferrer",onClick:o,title:c,children:[c," ↗"]}),d&&s.jsx("span",{className:"fork-summary-display-object-state",children:d})]})}function Bj(e){if(typeof e=="string")return`s:${e.length}:${e.slice(0,80)}`;const t=e.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
96
+ `);return`a:${e.length}:${t.length}:${t.slice(0,80)}`}const Dj=m.memo(function({title:t,prompts:n}){const r=new Map;return s.jsxs("details",{className:"session-setup-block collapsible",children:[s.jsxs("summary",{className:"collapsible__summary",children:[s.jsx("span",{className:"collapsible__icon",children:"▸"}),s.jsx("span",{children:t})]}),s.jsx("div",{className:"collapsible__content",children:n.map(o=>{const i=Bj(o),a=(r.get(i)??0)+1;return r.set(i,a),s.jsx("div",{className:"session-setup-entry",children:s.jsx(al,{content:o})},`${i}:${a}`)})})]})});function Oj(e){switch(e){case"completed":return{variant:"task-notification-completed",icon:"✓"};case"failed":case"error":return{variant:"task-notification-failed",icon:"!"};case"cancelled":case"canceled":return{variant:"task-notification-cancelled",icon:"⊘"};default:return{variant:"task-notification-progress",icon:"⟳"}}}const Uj=m.memo(function({item:t}){const{variant:n,icon:r}=Oj(t.status),o=t.summary??t.raw.trim();return s.jsxs("div",{className:`task-notification ${n}`.trim(),children:[s.jsxs("div",{className:"task-notification-head",children:[s.jsx("span",{className:"task-notification-icon","aria-hidden":"true",children:r}),s.jsx("span",{className:"task-notification-summary",children:o}),t.outputFile&&s.jsx("span",{className:"task-notification-output",title:t.outputFile,children:Dr(t.outputFile)})]}),t.event&&s.jsx("pre",{className:"task-notification-event",children:t.event.trim()})]})});function Hj(e){const t=Math.max(0,e)/1e3;if(t<10)return`${t.toFixed(1)} sec`;if(t<60)return`${Math.round(t)} sec`;const n=t/60;return n<10?`${n.toFixed(1)} min`:`${Math.round(n)} min`}const Wj=m.memo(function({thinking:t,status:n,isExpanded:r,onToggle:o,durationMs:i}){const a=n==="streaming",l=i!==void 0&&i>=100?Hj(i):null,c=["thinking-block","collapsible","timeline-item",a&&!r?"thinking-streaming-collapsed":""].filter(Boolean).join(" ");return s.jsxs("details",{className:c,open:r,onToggle:d=>{d.currentTarget.open!==r&&o()},children:[s.jsxs("summary",{className:"collapsible__summary","aria-label":r?"Collapse thinking":"Expand thinking",title:r?"Collapse thinking":"Expand thinking",children:[s.jsx("span",{className:"timeline-dot-btn","aria-hidden":!0}),s.jsxs("span",{children:[a?"Thinking...":"Thinking",l&&s.jsxs("span",{className:"thinking-duration",children:["for ",l]})]}),s.jsx("span",{className:"collapsible__icon",children:"▸"})]}),s.jsx("div",{className:"collapsible__content",children:s.jsx(Cr,{text:t,isStreaming:a})})]})}),Xl="\0";function zi(e,t){return[e,t].join(Xl)}function Vj(e){const t=e.indexOf(Xl);return t===-1?e:e.slice(0,t)}function aN(){const e=new Map;return{get size(){return e.size},read(t,n,r){const o=e.get(zi(t,n));return o===void 0?{expanded:r,overridden:!1}:{expanded:o,overridden:!0}},write(t,n,r,o){const i=zi(t,n);o===r?e.delete(i):e.set(i,o)},pruneOwners(t){for(const n of e.keys())t.has(Vj(n))||e.delete(n)}}}const Yl=m.createContext(null);function lN({children:e,registry:t}){return s.jsx(Yl.Provider,{value:t,children:e})}function Dt(e,t,n){const r=m.useContext(Yl),[o]=m.useState(()=>(r==null?void 0:r.read(e,t,n))??{expanded:n,overridden:!1}),[i,a]=m.useState(o.expanded),l=m.useCallback(c=>{a(d=>{const u=typeof c=="function"?c(d):c;return r==null||r.write(e,t,n,u),u})},[t,n,e,r]);return[i,l,o.overridden]}const Gj="_toggle_ipqut_1",zj="_inline_ipqut_23",qi={toggle:Gj,inline:zj};function ro({expanded:e,label:t,onClick:n,controls:r,status:o,inline:i=!1}){return s.jsx("button",{type:"button",className:`${qi.toggle} ${i?qi.inline:""}`,onClick:n,"aria-label":t,"aria-expanded":e,"aria-controls":r,title:t,"data-status":o,children:s.jsx("span",{"aria-hidden":"true",children:e?"−":"+"})})}const qj="_root_7iwcz_3",Kj="_rowHeader_7iwcz_8",Xj="_filename_7iwcz_17",Yj="_suffix_7iwcz_39",Jj="_dimensions_7iwcz_40",Qj="_row_7iwcz_8",Zj="_rejected_7iwcz_49",eb="_preview_7iwcz_53",tb="_loading_7iwcz_67",nb="_error_7iwcz_68",sb="_imageButton_7iwcz_76",Le={root:qj,rowHeader:Kj,filename:Xj,suffix:Yj,dimensions:Jj,row:Qj,rejected:Zj,preview:eb,loading:tb,error:nb,imageButton:sb},rb={"invalid-image-data":"toolResultMediaInvalidImageData","source-unavailable":"toolResultMediaSourceUnavailable","storage-unavailable":"toolResultMediaStorageUnavailable","too-large":"toolResultMediaTooLarge","unsupported-media":"toolResultMediaUnsupportedMedia"};function ob({displayName:e,media:t,sourcePath:n,status:r}){return s.jsx("div",{className:Le.root,children:t.map((o,i)=>s.jsx(ib,{displayName:e,index:i,media:o,sourcePath:n,status:r},o.state==="stored"?o.id:`${o.reason}-${i}`))})}function ib({displayName:e,index:t,media:n,sourcePath:r,status:o}){const{inlineMediaExpandedByDefault:i}=wr(),{t:a}=Z(),l=n.filename||a("toolResultMediaUnnamed",{number:t+1});return n.state==="rejected"?s.jsx("div",{className:`tool-row timeline-item status-${o} ${Le.row} ${Le.rejected}`,children:s.jsxs("div",{className:Le.rowHeader,title:a(rb[n.reason]),children:[s.jsx("span",{className:"tool-name",children:e}),s.jsx("span",{className:Le.filename,children:l}),s.jsxs("span",{className:Le.suffix,children:["(",a("toolResultMediaUnavailable"),")"]})]})}):s.jsx(ab,{displayName:e,filename:l,initialExpanded:i,media:n,sourcePath:r,status:o})}function ab({displayName:e,filename:t,initialExpanded:n,media:r,sourcePath:o,status:i}){const{projectId:a,sessionId:l}=gs(),c=Kt().transport,{t:d}=Z(),[u,f]=Dt(r.toolCallId,`media-preview:${r.id}`,n),[h,g]=m.useState({state:"idle"}),[p,y]=m.useState(!1),x=`/api/projects/${encodeURIComponent(a)}/sessions/${encodeURIComponent(l)}/media/${encodeURIComponent(r.id)}`,b=m.useMemo(()=>({buildApiPath:()=>x}),[x]),_=m.useCallback(()=>c.fetchBlob(xd(x)),[x,c]),N=m.useCallback(()=>y(!0),[]),v=hs({fileName:t,filePath:o,loadBlob:_,onOpen:N});m.useEffect(()=>{if(!u){g({state:"idle"});return}let S=!1,$=null;return g({state:"loading"}),_().then(T=>{if($=URL.createObjectURL(T),S){URL.revokeObjectURL($);return}g({state:"loaded",objectUrl:$})}).catch(()=>{S||g({state:"error"})}),()=>{S=!0,$&&URL.revokeObjectURL($)}},[u,_]);const j=r.mimeType.startsWith("video/"),C=r.width&&r.height?`${r.width}×${r.height}`:null,w={"--tool-result-media-aspect-ratio":r.width&&r.height?`${r.width} / ${r.height}`:"16 / 9","--tool-result-media-max-width":r.width?`${Math.min(r.width,720)}px`:"720px"},k=d(u?"toolResultMediaCollapse":"toolResultMediaExpand");return s.jsxs("div",{className:`tool-row timeline-item status-${i} ${Le.row}`,children:[s.jsx(ro,{expanded:u,label:k,status:i,onClick:()=>f(S=>!S)}),s.jsxs("div",{className:Le.rowHeader,children:[s.jsx("span",{className:"tool-name",children:e}),s.jsx("button",{type:"button",className:Le.filename,onClick:N,onContextMenu:v.handleContextMenu,children:t}),s.jsxs("span",{className:Le.suffix,children:["(",d(j?"toolResultMediaVideo":"toolResultMediaImage"),")"]}),C&&s.jsx("span",{className:Le.dimensions,children:C})]}),u&&s.jsxs("div",{className:Le.preview,style:w,children:[h.state==="loading"&&s.jsx("span",{className:Le.loading,children:d("toolResultMediaLoading")}),h.state==="error"&&s.jsx("span",{className:Le.error,children:d("toolResultMediaLoadFailed")}),h.state==="loaded"&&(j?s.jsx("video",{className:Le.imageButton,src:h.objectUrl,controls:!0,playsInline:!0,preload:"metadata","aria-label":d("toolResultMediaAlt",{filename:t})}):s.jsx("button",{type:"button",className:Le.imageButton,onClick:N,onContextMenu:v.handleContextMenu,"aria-label":d("toolResultMediaOpen",{filename:t}),children:s.jsx("img",{src:h.objectUrl,alt:d("toolResultMediaAlt",{filename:t}),width:r.width,height:r.height})}))]}),p&&s.jsx(qt,{path:t,filePath:o??null,mediaType:j?"video":"image",mediaSource:b,onClose:()=>y(!1)}),v.contextMenuElement]})}function lb(e,t,n){if(n!==1||!t||typeof t!="object")return;const r=e.toLowerCase().replaceAll("_","");if(r!=="viewimage"&&r!=="imageview"&&r!=="read")return;const o=t,i=[o.path,o.file_path,o.filePath].filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean);return new Set(i).size===1?i[0]:void 0}const cb=500,db=/^timeout waiting for ([^\r\n]+) to reach not-running; current status=running$/;function ub(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Hn(e){const t=ht(e);if(t)return t.parts.filter(n=>n.kind!=="script-status").map(n=>n.text).join(`
97
97
  `);if(typeof e=="string")return e;if(ub(e)){if(typeof e.content=="string")return e.content;const n=typeof e.stdout=="string"?e.stdout:"",r=typeof e.stderr=="string"?e.stderr:"";if(n||r)return[n,r].filter(Boolean).join(`
98
98
  `);if(typeof e.output=="string")return e.output}return e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e,null,2)}function Jl(e,t,n){var u;const r=ht(e),o=r==null?void 0:r.parts.filter(f=>f.kind!=="script-status");if(o&&o.length!==1)return null;const i=o==null?void 0:o[0],a=Me((i==null?void 0:i.text)??Hn(e),{bareExitCodeIsEnvelope:t}),l=a.output.trim();if(l.length===0||l.length>cb||/[\r\n]/.test(l))return null;const c=Ct(e).exitCode??((i==null?void 0:i.kind)==="command-output"?i.exitCode:void 0)??a.exitCode??(n?Me(n,{bareExitCodeIsEnvelope:t}).exitCode:void 0),d=c===1?(u=db.exec(l))==null?void 0:u[1]:void 0;return d?{kind:"waiting",target:d,output:l,exitCode:c}:{kind:"compact",output:l,exitCode:c}}function mb(e,t,n,r,o,i){const a=i??ze.prepare(e,{input:t,result:(n==null?void 0:n.structured)??(n==null?void 0:n.content),isError:n==null?void 0:n.isError,status:r}),l=ze.metadata(e).tool;if(r==="pending"||r==="aborted"||r==="incomplete"){if(a.getUseSummary){const u=a.getUseSummary(o);if(u!==void 0)return u}return Us(l,t)}let c;a.getUseSummary?c=a.getUseSummary(o)??Us(l,t):c=Us(l,t);let d;return a.getResultSummary?d=a.getResultSummary(o)??Ki(l,n,r):d=Ki(l,n,r),n?l==="Glob"||l==="Grep"?`${c} → ${d}`:l==="Bash"?c:l==="WriteStdin"&&c&&c!=="waiting for output"?`${c} → ${d}`:d:c}function Us(e,t){if(!t||typeof t!="object")return"...";const n=t;switch(e){case"Read":case"Write":case"Edit":if(typeof n.file_path=="string")return hb(n.file_path);break;case"Bash":{const r=jn(n);if(r)return r}break;case"Glob":if(typeof n.pattern=="string")return n.pattern;break;case"Grep":if(typeof n.pattern=="string")return`"${n.pattern}"`;break;case"Task":case"Agent":if(typeof n.description=="string")return Wn(n.description,30);break;case"WebSearch":if(typeof n.query=="string")return Wn(n.query,30);break;case"WebFetch":if(typeof n.url=="string")return Wn(n.url,40);break}return fb(n)}function fb(e){for(const t of Object.values(e))if(typeof t=="string"&&t.length>0&&t.length<100)return Wn(t,40);return"..."}function Ki(e,t,n){if(n==="error")return"failed";if(!t)return"done";const o=(typeof t.content=="string"?t.content:"").split(`
99
- `).filter(Boolean).length;switch(e){case"Read":return`${o} lines`;case"Bash":return`${o} lines`;case"Glob":return`${o} files`;case"Grep":return`${o} matches`;default:return"done"}}function Wn(e,t){return e.length<=t?e:`${e.slice(0,t-3)}...`}function hb(e){return tt(e)}const pb="_root_1ht2d_1",gb="_content_1ht2d_6",xb="_boundary_1ht2d_14",yb="_tag_1ht2d_31",jb="_title_1ht2d_42",bb="_context_1ht2d_47",vb="_original_1ht2d_54",at={root:pb,content:gb,boundary:xb,tag:yb,title:jb,context:bb,original:vb};function Ql({marker:e}){const{t}=Z(),n=e.kind==="unresolved"?t("workflowSchemaUnresolved"):t("workflowSchemaActivated",{title:e.title}),r=e.schemaRef?Lr(e.schemaRef):void 0;return r?s.jsx(Ue,{displayPath:n,filePath:r.path,showCopyButton:!1,showVersionControlLinks:!1}):n}function oo({marker:e}){return s.jsxs("span",{className:at.boundary,"data-workflow-boundary":e.kind,"data-workflow-path":e.path,children:[e.kind!=="activation"&&e.kind!=="unresolved"&&s.jsx("mark",{className:at.tag,children:e.prefix}),e.kind!=="activation"||e.title?s.jsx("span",{className:at.title,children:e.kind==="unresolved"||e.kind==="activation"?s.jsx(Ql,{marker:e}):e.title}):null]})}function Zl({workflow:e}){return s.jsxs(s.Fragment,{children:[e.parent?s.jsx("div",{className:at.context,"data-workflow-parent":e.parent.path,children:e.parent.title}):null,e.markers.filter(t=>!e.view&&(t.kind==="activation"||t.kind==="unresolved")).map(t=>s.jsx("div",{className:at.context,title:t.prefix,"data-workflow-schema":t.kind,children:s.jsx(Ql,{marker:t})},t.start))]})}function ec({text:e,workflow:t,original:n,preview:r}){const{t:o}=Z(),[i,a]=m.useState(!1),l=m.useId(),c=[],d=(f,h)=>{const g=[f,...(t.outputBoundaries??[]).filter(p=>p>f&&p<h),h];return g.slice(0,-1).map((p,y)=>s.jsx(pt,{text:e.slice(p,g[y+1])},p))};let u=0;for(const f of t.visibleRanges??[{start:0,end:e.length}]){let h=f.start;for(;u<t.markers.length;){const g=t.markers[u];if(g.start>=f.end)break;u++,!(g.start<f.start)&&(c.push(s.jsxs(m.Fragment,{children:[d(h,g.start),s.jsx(oo,{marker:g})]},g.start)),h=g.end)}c.push(s.jsx(m.Fragment,{children:d(h,f.end)},`tail-${f.start}`))}return s.jsxs("div",{className:`${at.root} timeline-item`,"data-workflow-output":"true",children:[s.jsx(ro,{expanded:i,label:o(i?"workflowHideOriginal":"workflowShowOriginal"),controls:l,onClick:()=>a(f=>!f)}),r??s.jsx("pre",{className:at.content,children:c}),i&&s.jsx("div",{className:at.original,id:l,"data-workflow-original":"true",children:n??s.jsx("pre",{className:at.content,children:e})})]})}class Xi{constructor(t,n=!0){be(this,"decoder");be(this,"data",[]);be(this,"fragments",[]);this.channel=t,this.decoder=new Fa(n?t:"unknown")}}class wb{constructor(t,n,r,o=!0,i){be(this,"stdout");be(this,"stderr",new Xi("stderr"));be(this,"finished",!1);be(this,"records",[]);be(this,"active",!1);be(this,"stopped",!1);be(this,"projection",{stdout:"",stderr:"",commentary:[],failed:!1,complete:!1,fragments:{stdout:[],stderr:[]}});this.render=t,this.publish=n,this.workflowContext=i,this.stdout=new Xi("stdout",o),r&&(this.stdout.decoder.source=r.source,this.stderr.decoder.source=r.stderr,this.finished=!0,this.projection=r.projection)}appendSnapshot(t,n,r=""){if(this.stopped)return!1;for(const[i,a]of[[this.stdout,t],[this.stderr,r]])if(!a.startsWith(i.decoder.source)||this.finished&&a!==i.decoder.source)return!1;if(this.finished)return!0;const o=[t,r].some(i=>mt(i,n)==="json");return this.appendStream(this.stdout,t,n,o),this.appendStream(this.stderr,r,n,!1),this.finished=n,this.finished&&!this.active&&this.records.length===0&&!this.projection.complete&&(this.projection={...this.projection,complete:!0},this.publish(this.projection)),this.drain(),!0}appendStream(t,n,r,o){for(const i of t.decoder.appendSnapshot(n,r,o))this.records.push({...i,id:`${t.channel}:${i.id}`,stream:t})}stop(){this.stopped=!0,this.records=[]}async drain(){if(!(this.active||this.stopped||this.records.length===0)){this.active=!0;try{for(;!this.stopped&&this.records.length>0;){const t=this.records.splice(0),n=this.workflowContext?Jn([this.stdout,this.stderr].map(c=>[...c.fragments,...t.filter(d=>d.stream===c).flatMap(({id:d,record:u})=>Qs(d,u))]),this.workflowContext):void 0,r=new Map(t.flatMap(({id:c,record:d})=>d.commentary.map(u=>{const f=`${c}:${u.id}`,h=n==null?void 0:n.commentary[f];return[f,h?Ja(u.text,h):[{text:u.text}]]}))),o=[...r.values()].flatMap(c=>c.filter(d=>d.text.trim()).map(d=>d.text));let i;try{if(i=o.length?await this.render(o):[],i.length!==o.length)throw new Error("Incomplete commentary rendering")}catch{i=null}if(this.stopped)return;let a=0;const l=[...this.projection.commentary];for(const{id:c,record:d,stream:u,getPreviousContext:f}of t){if(!i){u.data.push(d.source),u.fragments.push({id:c,text:d.source,kind:"data",opaque:d.json});continue}u.fragments.push(...Qs(c,d)),d.metadataOnly||u.data.push(d.data);for(const h of d.commentary){const g=`${c}:${h.id}`,p=r.get(g).map(y=>({...y,html:y.text.trim()?i[a++]:""}));l.push({id:g,text:h.text,html:p.map(y=>y.html).join(""),...n?{workflow:n.commentary[g],segments:p}:{},getContext:h.context?()=>Dd(d,h):d.metadataOnly?f:null})}}this.projection={stdout:this.stdout.data.join(""),stderr:this.stderr.data.join(""),commentary:l,failed:this.projection.failed||i===null,complete:this.finished&&this.records.length===0,fragments:{stdout:[...this.stdout.fragments],stderr:[...this.stderr.fragments]},workflow:i?n==null?void 0:n.data:this.workflowContext?Jn([this.stdout.fragments,this.stderr.fragments],this.workflowContext).data:void 0},this.publish(this.projection)}}finally{this.active=!1}}}}async function tc(e,t,n,r){const o=[];for(let i=0;i<n.length;){let a=Math.min(Od,n.length-i),l=JSON.stringify({texts:n.slice(i,i+a)});for(;new TextEncoder().encode(l).length>Co&&a>1;)a=Math.floor(a/2),l=JSON.stringify({texts:n.slice(i,i+a)});if(new TextEncoder().encode(l).length>Co)throw new Error("Commentary exceeds rendering limit");const c=await e.transport.fetch(`/projects/${t}/tool-commentary/render`,{method:"POST",body:l,signal:r});if(!Array.isArray(c.html)||c.html.length!==a||c.html.some(d=>typeof d!="string"))throw new Error("Invalid commentary response");o.push(...c.html),i+=a}return o}function nc(e){var r,o,i,a,l;const t=((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content)??((i=Ut(e.toolInput))==null?void 0:i._previewResult);if(["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase())){const c=Xt(t,Hr(e));return{stdout:c.stdout??"",stderr:c.stderr??"",shell:c,stdoutSequenced:typeof((a=Ut(t))==null?void 0:a.stdout)=="string"}}const n=Ut(t);return{stdout:typeof(n==null?void 0:n.stdout)=="string"?n.stdout:((l=e.toolResult)==null?void 0:l.content)??"",stderr:typeof(n==null?void 0:n.stderr)=="string"?n.stderr:"",stdoutSequenced:typeof(n==null?void 0:n.stdout)=="string",shell:null}}const Yi=new WeakMap;function aN(e){const t=Yi.get(e);if(t!==void 0)return t;const n=_b(e);return e.status!=="pending"&&Yi.set(e,n),n}function _b(e){var r,o;const t=e.status!=="pending";if(e.toolName==="Exec"){const i=ht(((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content));return(i==null?void 0:i.parts.some(a=>mt(a.text,t)!==null))??!1}const n=nc(e);return[n.stdout,n.stderr].some(i=>mt(i,t)!==null)}const Nb="_bullet_15up9_1",kb="_context_15up9_32",Sb="_close_15up9_55",Hs={bullet:Nb,context:kb,close:Sb},Cb=m.memo(function({items:t,command:n,onOpenOutput:r}){return t.map(o=>{var i,a;return o.segments?s.jsxs(m.Fragment,{children:[o.segments.length&&!((i=o.segments[0])!=null&&i.marker)?s.jsx(Zl,{workflow:{markers:[],parent:(a=o.workflow)==null?void 0:a.parent}}):null,o.segments.map((l,c)=>s.jsxs(m.Fragment,{children:[l.marker?s.jsx(oo,{marker:l.marker}):null,l.text.trim()||l.marker?s.jsx(Qn,{text:l.text,augmentHtml:l.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})}):null]},c))]},o.id):s.jsx(Qn,{text:o.text,augmentHtml:o.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})},o.id)})});function Ji({item:e,command:t,onOpenOutput:n}){const{t:r}=Z(),o=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[d,u]=m.useState(!1),[f,h]=m.useState(""),[g,p]=m.useState({left:8,top:8,maxHeight:320}),y=m.useCallback(_=>{var N;if(!(!e.getContext||d&&!_)){if(_){h(e.getContext());const v=(N=i.current)==null?void 0:N.getBoundingClientRect();if(v){const j=Math.min(480,window.innerWidth-16),C=Math.max(8,Math.min(v.bottom+6,window.innerHeight*.55));p({left:Math.max(8,Math.min(v.left,window.innerWidth-j-8)),top:C,maxHeight:window.innerHeight-C-8})}}c(_)}},[e,d]),x=ch({open:l,onOpenChange:y}),b=m.useCallback(()=>{u(!1),c(!1)},[]);return m.useEffect(()=>{if(!l)return;const _=v=>{var j,C;v.target instanceof Node&&((j=a.current)!=null&&j.contains(v.target)||(C=i.current)!=null&&C.contains(v.target))||b()},N=v=>{var j;v.key==="Escape"&&(v.stopPropagation(),b(),(j=i.current)==null||j.focus())};return document.addEventListener("pointerdown",_),document.addEventListener("scroll",_,!0),document.addEventListener("keydown",N),window.addEventListener("resize",b),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("scroll",_,!0),document.removeEventListener("keydown",N),window.removeEventListener("resize",b)}},[l,b]),s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:i,type:"button",className:Hs.bullet,"aria-label":r(e.getContext?"acliCommentaryContext":"acliCommentaryOutput"),"aria-expanded":e.getContext?l:void 0,"aria-controls":l?o:void 0,title:e.getContext?void 0:t,onPointerEnter:x.onPointerEnter,onPointerMove:x.onPointerMove,onPointerLeave:x.onPointerLeave,onFocus:x.onFocus,onBlur:x.onBlur,onClick:()=>{if(!e.getContext){n();return}d?b():(y(!0),u(!0))}}),l?br.createPortal(s.jsxs("div",{ref:a,id:o,className:Hs.context,style:g,role:"dialog","aria-label":r("acliCommentaryContext"),children:[s.jsx("button",{type:"button",className:Hs.close,onClick:b,"aria-label":r("acliCommentaryCloseContext"),children:"×"}),s.jsx("pre",{children:f})]}),document.body):null]})}const Qi=new WeakMap;function sc(e,t){return mt(e,!t)!==null}function Tb(e){var h,g,p,y,x;const t=((h=e.toolResult)==null?void 0:h.structured)??((g=e.toolResult)==null?void 0:g.content),n=Hr(e),r=m.useMemo(()=>{const b=e.toolResult?Qi.get(e.toolResult):void 0;if((b==null?void 0:b.source)===t&&e.status!=="pending")return b;const _=ht(t);if(!_)return null;const N=_.parts.flatMap((k,S)=>sc(k.text,e.status==="pending")?[{part:k,index:S}]:[]);if(!N.length)return null;const v=typeof t=="string"?JSON.parse(t):t,j=N.map(({part:k,index:S})=>{const $=v[S],T=k.kind==="command-output"?JSON.parse($.text):null;return{index:S,result:{...e.toolResult,content:k.text,structured:void 0,isError:n},replaceText:E=>({...$,text:T?JSON.stringify(T.status==="fulfilled"?{...T,value:{...T.value,output:E}}:{...T,output:E}):k.kind==="script-status"?$.text:E})}}),C=_.parts.flatMap((k,S)=>k.kind==="script-status"?[]:[{index:S,text:k.text}]),w={source:t,blocks:v,parts:j,textParts:C};return e.toolResult&&e.status!=="pending"&&Qi.set(e.toolResult,w),w},[t,e.toolResult,e.status,n]),[o,i]=m.useState(()=>new Map),a=m.useCallback((b,_,N)=>{i(v=>{var j,C;return v.has(b)&&((j=v.get(b))==null?void 0:j.result)===_&&((C=v.get(b))==null?void 0:C.workflow)===N?v:new Map(v).set(b,{result:_,workflow:N})})},[]),l=Ut(e.toolInput),c=m.useMemo(()=>({cmd:l==null?void 0:l.source}),[l==null?void 0:l.source]);if(!r||e.supported===!1)return e.children(e.toolInput,e.toolResult,e.workflow);const d=[...r.blocks];for(const b of r.parts)d[b.index]=b.replaceText(((y=(p=o.get(b.index))==null?void 0:p.result)==null?void 0:y.content)??"");const u=(x=e.workflow)==null?void 0:x.toolContext,f=u?Km(r.textParts.map(b=>{var _;return r.parts.some(N=>N.index===b.index)?((_=o.get(b.index))==null?void 0:_.workflow)??{markers:[],outputText:""}:Jn([[{id:String(b.index),kind:"data",text:b.text}]],u).data})):e.workflow;return s.jsxs(s.Fragment,{children:[e.children(e.toolInput,{...e.toolResult,content:JSON.stringify(d),structured:d,isError:n},f),r.parts.map(b=>m.createElement(rc,{...e,key:b.index,id:`${e.id}:${b.index}`,toolName:"Exec output",toolInput:c,toolResult:b.result},(_,N,v)=>s.jsx(Rb,{index:b.index,result:N,workflow:v,project:a})))]})}function Rb({index:e,result:t,workflow:n,project:r}){return m.useLayoutEffect(()=>r(e,t,n),[e,t,n,r]),null}function Pb(e){var l;const{acliCommentaryEnabled:t}=qd(),n=ge(),r=ps(),o=Kt(),i=La(o.sourceKey);if(!t||!n||r)return e.children(e.toolInput,e.toolResult,e.workflow);const a=e.toolName==="Exec"?Tb:rc;return s.jsx(a,{...e,projectId:n.projectId,runtime:o,supported:i?ga(i,xa):null},`${o.sourceKey}:${n.projectId}:${n.sessionId}:${e.id}:${JSON.stringify((l=e.workflow)==null?void 0:l.toolContext)}`)}function rc(e){const t=m.useMemo(()=>nc({toolName:e.toolName,toolInput:e.toolInput,toolResult:e.toolResult,status:e.status}),[e.toolResult,e.toolInput,e.toolName,e.status]),[n,r]=m.useState(null),o=[t.stdout,t.stderr].some(a=>sc(a,e.status==="pending"));if(n===null&&(e.supported===!1?r("raw"):o&&e.supported?r("commentary"):!o&&(e.status!=="pending"||t.stdout.includes(`
99
+ `).filter(Boolean).length;switch(e){case"Read":return`${o} lines`;case"Bash":return`${o} lines`;case"Glob":return`${o} files`;case"Grep":return`${o} matches`;default:return"done"}}function Wn(e,t){return e.length<=t?e:`${e.slice(0,t-3)}...`}function hb(e){return tt(e)}const pb="_root_1ht2d_1",gb="_content_1ht2d_6",xb="_boundary_1ht2d_14",yb="_tag_1ht2d_31",jb="_title_1ht2d_42",bb="_context_1ht2d_47",vb="_original_1ht2d_54",it={root:pb,content:gb,boundary:xb,tag:yb,title:jb,context:bb,original:vb};function Ql({marker:e}){const{t}=Z(),n=e.kind==="unresolved"?t("workflowSchemaUnresolved"):t("workflowSchemaActivated",{title:e.title}),r=e.schemaRef?Lr(e.schemaRef):void 0;return r?s.jsx(Ue,{displayPath:n,filePath:r.path,showCopyButton:!1,showVersionControlLinks:!1}):n}function oo({marker:e}){return s.jsxs("span",{className:it.boundary,"data-workflow-boundary":e.kind,"data-workflow-path":e.path,children:[e.kind!=="activation"&&e.kind!=="unresolved"&&s.jsx("mark",{className:it.tag,children:e.prefix}),e.kind!=="activation"||e.title?s.jsx("span",{className:it.title,children:e.kind==="unresolved"||e.kind==="activation"?s.jsx(Ql,{marker:e}):e.title}):null]})}function Zl({workflow:e}){return s.jsxs(s.Fragment,{children:[e.parent?s.jsx("div",{className:it.context,"data-workflow-parent":e.parent.path,children:e.parent.title}):null,e.markers.filter(t=>!e.view&&(t.kind==="activation"||t.kind==="unresolved")).map(t=>s.jsx("div",{className:it.context,title:t.prefix,"data-workflow-schema":t.kind,children:s.jsx(Ql,{marker:t})},t.start))]})}function ec({text:e,workflow:t,original:n,preview:r}){const{t:o}=Z(),[i,a]=m.useState(!1),l=m.useId(),c=[],d=(f,h)=>{const g=[f,...(t.outputBoundaries??[]).filter(p=>p>f&&p<h),h];return g.slice(0,-1).map((p,y)=>s.jsx(pt,{text:e.slice(p,g[y+1])},p))};let u=0;for(const f of t.visibleRanges??[{start:0,end:e.length}]){let h=f.start;for(;u<t.markers.length;){const g=t.markers[u];if(g.start>=f.end)break;u++,!(g.start<f.start)&&(c.push(s.jsxs(m.Fragment,{children:[d(h,g.start),s.jsx(oo,{marker:g})]},g.start)),h=g.end)}c.push(s.jsx(m.Fragment,{children:d(h,f.end)},`tail-${f.start}`))}return s.jsxs("div",{className:`${it.root} timeline-item`,"data-workflow-output":"true",children:[s.jsx(ro,{expanded:i,label:o(i?"workflowHideOriginal":"workflowShowOriginal"),controls:l,onClick:()=>a(f=>!f)}),r??s.jsx("pre",{className:it.content,children:c}),i&&s.jsx("div",{className:it.original,id:l,"data-workflow-original":"true",children:n??s.jsx("pre",{className:it.content,children:e})})]})}class Xi{constructor(t,n=!0){be(this,"decoder");be(this,"data",[]);be(this,"fragments",[]);this.channel=t,this.decoder=new Fa(n?t:"unknown")}}class wb{constructor(t,n,r,o=!0,i){be(this,"stdout");be(this,"stderr",new Xi("stderr"));be(this,"finished",!1);be(this,"records",[]);be(this,"active",!1);be(this,"stopped",!1);be(this,"projection",{stdout:"",stderr:"",commentary:[],failed:!1,complete:!1,fragments:{stdout:[],stderr:[]}});this.render=t,this.publish=n,this.workflowContext=i,this.stdout=new Xi("stdout",o),r&&(this.stdout.decoder.source=r.source,this.stderr.decoder.source=r.stderr,this.finished=!0,this.projection=r.projection)}appendSnapshot(t,n,r=""){if(this.stopped)return!1;for(const[i,a]of[[this.stdout,t],[this.stderr,r]])if(!a.startsWith(i.decoder.source)||this.finished&&a!==i.decoder.source)return!1;if(this.finished)return!0;const o=[t,r].some(i=>mt(i,n)==="json");return this.appendStream(this.stdout,t,n,o),this.appendStream(this.stderr,r,n,!1),this.finished=n,this.finished&&!this.active&&this.records.length===0&&!this.projection.complete&&(this.projection={...this.projection,complete:!0},this.publish(this.projection)),this.drain(),!0}appendStream(t,n,r,o){for(const i of t.decoder.appendSnapshot(n,r,o))this.records.push({...i,id:`${t.channel}:${i.id}`,stream:t})}stop(){this.stopped=!0,this.records=[]}async drain(){if(!(this.active||this.stopped||this.records.length===0)){this.active=!0;try{for(;!this.stopped&&this.records.length>0;){const t=this.records.splice(0),n=this.workflowContext?Jn([this.stdout,this.stderr].map(c=>[...c.fragments,...t.filter(d=>d.stream===c).flatMap(({id:d,record:u})=>Qs(d,u))]),this.workflowContext):void 0,r=new Map(t.flatMap(({id:c,record:d})=>d.commentary.map(u=>{const f=`${c}:${u.id}`,h=n==null?void 0:n.commentary[f];return[f,h?Ja(u.text,h):[{text:u.text}]]}))),o=[...r.values()].flatMap(c=>c.filter(d=>d.text.trim()).map(d=>d.text));let i;try{if(i=o.length?await this.render(o):[],i.length!==o.length)throw new Error("Incomplete commentary rendering")}catch{i=null}if(this.stopped)return;let a=0;const l=[...this.projection.commentary];for(const{id:c,record:d,stream:u,getPreviousContext:f}of t){if(!i){u.data.push(d.source),u.fragments.push({id:c,text:d.source,kind:"data",opaque:d.json});continue}u.fragments.push(...Qs(c,d)),d.metadataOnly||u.data.push(d.data);for(const h of d.commentary){const g=`${c}:${h.id}`,p=r.get(g).map(y=>({...y,html:y.text.trim()?i[a++]:""}));l.push({id:g,text:h.text,html:p.map(y=>y.html).join(""),...n?{workflow:n.commentary[g],segments:p}:{},getContext:h.context?()=>Gd(d,h):d.metadataOnly?f:null})}}this.projection={stdout:this.stdout.data.join(""),stderr:this.stderr.data.join(""),commentary:l,failed:this.projection.failed||i===null,complete:this.finished&&this.records.length===0,fragments:{stdout:[...this.stdout.fragments],stderr:[...this.stderr.fragments]},workflow:i?n==null?void 0:n.data:this.workflowContext?Jn([this.stdout.fragments,this.stderr.fragments],this.workflowContext).data:void 0},this.publish(this.projection)}}finally{this.active=!1}}}}async function tc(e,t,n,r){const o=[];for(let i=0;i<n.length;){let a=Math.min(zd,n.length-i),l=JSON.stringify({texts:n.slice(i,i+a)});for(;new TextEncoder().encode(l).length>Co&&a>1;)a=Math.floor(a/2),l=JSON.stringify({texts:n.slice(i,i+a)});if(new TextEncoder().encode(l).length>Co)throw new Error("Commentary exceeds rendering limit");const c=await e.transport.fetch(`/projects/${t}/tool-commentary/render`,{method:"POST",body:l,signal:r});if(!Array.isArray(c.html)||c.html.length!==a||c.html.some(d=>typeof d!="string"))throw new Error("Invalid commentary response");o.push(...c.html),i+=a}return o}function nc(e){var r,o,i,a,l;const t=((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content)??((i=Ut(e.toolInput))==null?void 0:i._previewResult);if(["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase())){const c=Xt(t,Hr(e));return{stdout:c.stdout??"",stderr:c.stderr??"",shell:c,stdoutSequenced:typeof((a=Ut(t))==null?void 0:a.stdout)=="string"}}const n=Ut(t);return{stdout:typeof(n==null?void 0:n.stdout)=="string"?n.stdout:((l=e.toolResult)==null?void 0:l.content)??"",stderr:typeof(n==null?void 0:n.stderr)=="string"?n.stderr:"",stdoutSequenced:typeof(n==null?void 0:n.stdout)=="string",shell:null}}const Yi=new WeakMap;function cN(e){const t=Yi.get(e);if(t!==void 0)return t;const n=_b(e);return e.status!=="pending"&&Yi.set(e,n),n}function _b(e){var r,o;const t=e.status!=="pending";if(e.toolName==="Exec"){const i=ht(((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content));return(i==null?void 0:i.parts.some(a=>mt(a.text,t)!==null))??!1}const n=nc(e);return[n.stdout,n.stderr].some(i=>mt(i,t)!==null)}const Nb="_bullet_15up9_1",kb="_context_15up9_32",Sb="_close_15up9_55",Hs={bullet:Nb,context:kb,close:Sb},Cb=m.memo(function({items:t,command:n,onOpenOutput:r}){return t.map(o=>{var i,a;return o.segments?s.jsxs(m.Fragment,{children:[o.segments.length&&!((i=o.segments[0])!=null&&i.marker)?s.jsx(Zl,{workflow:{markers:[],parent:(a=o.workflow)==null?void 0:a.parent}}):null,o.segments.map((l,c)=>s.jsxs(m.Fragment,{children:[l.marker?s.jsx(oo,{marker:l.marker}):null,l.text.trim()||l.marker?s.jsx(Qn,{text:l.text,augmentHtml:l.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})}):null]},c))]},o.id):s.jsx(Qn,{text:o.text,augmentHtml:o.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})},o.id)})});function Ji({item:e,command:t,onOpenOutput:n}){const{t:r}=Z(),o=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[d,u]=m.useState(!1),[f,h]=m.useState(""),[g,p]=m.useState({left:8,top:8,maxHeight:320}),y=m.useCallback(_=>{var N;if(!(!e.getContext||d&&!_)){if(_){h(e.getContext());const v=(N=i.current)==null?void 0:N.getBoundingClientRect();if(v){const j=Math.min(480,window.innerWidth-16),C=Math.max(8,Math.min(v.bottom+6,window.innerHeight*.55));p({left:Math.max(8,Math.min(v.left,window.innerWidth-j-8)),top:C,maxHeight:window.innerHeight-C-8})}}c(_)}},[e,d]),x=ch({open:l,onOpenChange:y}),b=m.useCallback(()=>{u(!1),c(!1)},[]);return m.useEffect(()=>{if(!l)return;const _=v=>{var j,C;v.target instanceof Node&&((j=a.current)!=null&&j.contains(v.target)||(C=i.current)!=null&&C.contains(v.target))||b()},N=v=>{var j;v.key==="Escape"&&(v.stopPropagation(),b(),(j=i.current)==null||j.focus())};return document.addEventListener("pointerdown",_),document.addEventListener("scroll",_,!0),document.addEventListener("keydown",N),window.addEventListener("resize",b),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("scroll",_,!0),document.removeEventListener("keydown",N),window.removeEventListener("resize",b)}},[l,b]),s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:i,type:"button",className:Hs.bullet,"aria-label":r(e.getContext?"acliCommentaryContext":"acliCommentaryOutput"),"aria-expanded":e.getContext?l:void 0,"aria-controls":l?o:void 0,title:e.getContext?void 0:t,onPointerEnter:x.onPointerEnter,onPointerMove:x.onPointerMove,onPointerLeave:x.onPointerLeave,onFocus:x.onFocus,onBlur:x.onBlur,onClick:()=>{if(!e.getContext){n();return}d?b():(y(!0),u(!0))}}),l?br.createPortal(s.jsxs("div",{ref:a,id:o,className:Hs.context,style:g,role:"dialog","aria-label":r("acliCommentaryContext"),children:[s.jsx("button",{type:"button",className:Hs.close,onClick:b,"aria-label":r("acliCommentaryCloseContext"),children:"×"}),s.jsx("pre",{children:f})]}),document.body):null]})}const Qi=new WeakMap;function sc(e,t){return mt(e,!t)!==null}function Tb(e){var h,g,p,y,x;const t=((h=e.toolResult)==null?void 0:h.structured)??((g=e.toolResult)==null?void 0:g.content),n=Hr(e),r=m.useMemo(()=>{const b=e.toolResult?Qi.get(e.toolResult):void 0;if((b==null?void 0:b.source)===t&&e.status!=="pending")return b;const _=ht(t);if(!_)return null;const N=_.parts.flatMap((k,S)=>sc(k.text,e.status==="pending")?[{part:k,index:S}]:[]);if(!N.length)return null;const v=typeof t=="string"?JSON.parse(t):t,j=N.map(({part:k,index:S})=>{const $=v[S],T=k.kind==="command-output"?JSON.parse($.text):null;return{index:S,result:{...e.toolResult,content:k.text,structured:void 0,isError:n},replaceText:E=>({...$,text:T?JSON.stringify(T.status==="fulfilled"?{...T,value:{...T.value,output:E}}:{...T,output:E}):k.kind==="script-status"?$.text:E})}}),C=_.parts.flatMap((k,S)=>k.kind==="script-status"?[]:[{index:S,text:k.text}]),w={source:t,blocks:v,parts:j,textParts:C};return e.toolResult&&e.status!=="pending"&&Qi.set(e.toolResult,w),w},[t,e.toolResult,e.status,n]),[o,i]=m.useState(()=>new Map),a=m.useCallback((b,_,N)=>{i(v=>{var j,C;return v.has(b)&&((j=v.get(b))==null?void 0:j.result)===_&&((C=v.get(b))==null?void 0:C.workflow)===N?v:new Map(v).set(b,{result:_,workflow:N})})},[]),l=Ut(e.toolInput),c=m.useMemo(()=>({cmd:l==null?void 0:l.source}),[l==null?void 0:l.source]);if(!r||e.supported===!1)return e.children(e.toolInput,e.toolResult,e.workflow);const d=[...r.blocks];for(const b of r.parts)d[b.index]=b.replaceText(((y=(p=o.get(b.index))==null?void 0:p.result)==null?void 0:y.content)??"");const u=(x=e.workflow)==null?void 0:x.toolContext,f=u?Km(r.textParts.map(b=>{var _;return r.parts.some(N=>N.index===b.index)?((_=o.get(b.index))==null?void 0:_.workflow)??{markers:[],outputText:""}:Jn([[{id:String(b.index),kind:"data",text:b.text}]],u).data})):e.workflow;return s.jsxs(s.Fragment,{children:[e.children(e.toolInput,{...e.toolResult,content:JSON.stringify(d),structured:d,isError:n},f),r.parts.map(b=>m.createElement(rc,{...e,key:b.index,id:`${e.id}:${b.index}`,toolName:"Exec output",toolInput:c,toolResult:b.result},(_,N,v)=>s.jsx(Rb,{index:b.index,result:N,workflow:v,project:a})))]})}function Rb({index:e,result:t,workflow:n,project:r}){return m.useLayoutEffect(()=>r(e,t,n),[e,t,n,r]),null}function Pb(e){var l;const{acliCommentaryEnabled:t}=vd(),n=ge(),r=ps(),o=Kt(),i=Aa(o.sourceKey);if(!t||!n||r)return e.children(e.toolInput,e.toolResult,e.workflow);const a=e.toolName==="Exec"?Tb:rc;return s.jsx(a,{...e,projectId:n.projectId,runtime:o,supported:i?ga(i,xa):null},`${o.sourceKey}:${n.projectId}:${n.sessionId}:${e.id}:${JSON.stringify((l=e.workflow)==null?void 0:l.toolContext)}`)}function rc(e){const t=m.useMemo(()=>nc({toolName:e.toolName,toolInput:e.toolInput,toolResult:e.toolResult,status:e.status}),[e.toolResult,e.toolInput,e.toolName,e.status]),[n,r]=m.useState(null),o=[t.stdout,t.stderr].some(a=>sc(a,e.status==="pending"));if(n===null&&(e.supported===!1?r("raw"):o&&e.supported?r("commentary"):!o&&(e.status!=="pending"||t.stdout.includes(`
100
100
  `))&&r("raw")),n==="commentary")return s.jsx(Eb,{...e,output:t});if(n==="raw")return e.children(e.toolInput,e.toolResult,e.workflow);const i=Ut(e.toolInput);return e.children(i?{...i,_previewResult:void 0}:e.toolInput,void 0,void 0)}const Zi=new WeakMap;function Eb(e){var b,_;const{t}=Z(),n=Hr(e),[r]=m.useState((b=e.workflow)==null?void 0:b.toolContext),[o]=m.useState(()=>{var v;const N=e.toolResult?Zi.get(e.toolResult):void 0;return(N==null?void 0:N.sourceKey)===e.runtime.sourceKey&&N.workflowKey===JSON.stringify((v=e.workflow)==null?void 0:v.toolContext)&&N.source===e.output.stdout&&N.stderr===e.output.stderr&&e.status!=="pending"?N:null}),[i,a]=m.useState((o==null?void 0:o.projection)??null),[l,c]=m.useState(!1),d=m.useRef(null),u=m.useRef(null),f=m.useRef(e);f.current=e;const h=jn(e.toolInput)||e.toolName;m.useEffect(()=>{let N=new AbortController;const v=C=>new wb(w=>tc(e.runtime,e.projectId,w,N.signal),w=>{var S;a(w);const k=f.current;w.complete&&k.toolResult&&k.status!=="pending"&&Zi.set(k.toolResult,{sourceKey:k.runtime.sourceKey,source:k.output.stdout,stderr:k.output.stderr,projection:w,workflowKey:JSON.stringify((S=k.workflow)==null?void 0:S.toolContext)})},C,e.output.stdoutSequenced,r);u.current=()=>{var w;N.abort(),(w=d.current)==null||w.stop(),N=new AbortController,d.current=v();const C=f.current;d.current.appendSnapshot(C.output.stdout,C.status!=="pending",C.output.stderr)},d.current=v(o??void 0);const j=f.current;return d.current.appendSnapshot(j.output.stdout,j.status!=="pending",j.output.stderr),()=>{var C;N.abort(),(C=d.current)==null||C.stop(),d.current=null,u.current=null}},[e.projectId,e.runtime,e.output.stdoutSequenced,o,r]),m.useEffect(()=>{var N;d.current&&(d.current.appendSnapshot(e.output.stdout,e.status!=="pending",e.output.stderr)||(N=u.current)==null||N.call(u))},[e.output.stdout,e.output.stderr,e.status]);const g=m.useCallback(()=>c(!1),[]),p=m.useCallback(()=>c(!0),[]),y=m.useMemo(()=>{if(!i)return;const N=i.stderr;return{...e.toolResult,content:i.stdout,isError:n,structured:e.output.shell?{...e.output.shell,stdout:i.stdout,stderr:N}:e.output.stderr?{stdout:i.stdout,stderr:N}:void 0}},[e.toolResult,e.output,i,n]),x=m.useMemo(()=>{const N=Ut(e.toolInput);return N?{...N,_previewResult:y==null?void 0:y.structured}:e.toolInput},[e.toolInput,y]);return s.jsxs(s.Fragment,{children:[e.children(x,y,i==null?void 0:i.workflow),i?s.jsx(Cb,{items:i.commentary,command:h,onOpenOutput:p}):null,i!=null&&i.failed?s.jsx("span",{role:"status",children:t("acliCommentaryUnavailable")}):null,l?s.jsxs(Mt,{title:h,label:h,onClose:g,children:[e.output.shell?s.jsx(wl,{input:e.toolInput,result:y==null?void 0:y.structured,isError:n,projectPathLinks:(_=e.toolResult)==null?void 0:_.projectPathLinks}):s.jsx("pre",{children:i==null?void 0:i.stdout}),s.jsxs("details",{children:[s.jsx("summary",{children:t("workflowOriginalOutput")}),s.jsxs("pre",{children:[e.output.stdout,e.output.stderr?`
101
101
  ${e.output.stderr}`:""]})]})]}):null]})}const Ib="_expandedCommand_1gp9x_1",Mb="_disclosureAnchor_1gp9x_8",$b="_waitingRow_1gp9x_16",Lb="_waitingSummary_1gp9x_20",Ab="_waitingHeader_1gp9x_28",dn={expandedCommand:Ib,disclosureAnchor:Mb,waitingRow:$b,waitingSummary:Lb,waitingHeader:Ab},Ge={outputRowChromePx:12,previewBorderPx:2,emptyOutputRowPx:28,minOutputRowPx:35,outputLineHeightPx:18,minPx:28,maxPx:94,defaultContentWidthPx:720,minCharsPerLine:24,maxCharsPerLine:160,averageCharWidthPx:7.5},Ht={averageCharWidthPx:Ge.averageCharWidthPx,outputLineHeightPx:Ge.outputLineHeightPx,outputRowChromePx:Ge.outputRowChromePx},Ws=220;function kt(e,t,n){return Math.min(n,Math.max(t,e))}function Vn(e){const{toolInput:t,structuredResult:n,status:r,startTimestampMs:o,resultTimestampMs:i,nowMs:a}=e,l=t&&typeof t=="object"?t._backgroundTaskStatus:void 0;if(r==="pending"||l==="running")return typeof o=="number"?{seconds:(a-o)/1e3,kind:"running"}:null;const c=Ct(n);return c.durationSeconds!==void 0?{seconds:c.durationSeconds,kind:"reported"}:l!==void 0?null:typeof o=="number"&&typeof i=="number"&&i>=o?{seconds:(i-o)/1e3,kind:"approximate"}:null}function Fb(e){const t=Vn(e);if(!t)return null;const n=et(t.seconds);switch(t.kind){case"running":return`running for ${n}`;case"reported":return`took ${n}`;case"approximate":return`took ~${n}`}}function io(e){return{averageCharWidthPx:kt((e==null?void 0:e.averageCharWidthPx)??Ht.averageCharWidthPx,4,18),outputLineHeightPx:kt((e==null?void 0:e.outputLineHeightPx)??Ht.outputLineHeightPx,12,42),outputRowChromePx:kt((e==null?void 0:e.outputRowChromePx)??Ht.outputRowChromePx,4,32)}}function oc(e,t){const n=typeof e=="number"&&e>0?Math.max(120,e-112):Ge.defaultContentWidthPx,r=io(t);return kt(Math.floor(n/r.averageCharWidthPx),Ge.minCharsPerLine,Ge.maxCharsPerLine)}function ic(e,t){const n=e.replace(/\r\n/g,`
102
102
  `).split(`
103
103
  `);let r=0;for(const o of n)r+=Math.max(1,Math.ceil(o.length/t));return r}function Bb({hiddenChars:e,hiddenLines:t}){return t||e||null}function Db(e,t){const n=kt(Math.round(t),1,8),r=e.replace(/\r\n/g,`
104
104
  `).split(`
105
105
  `),o=r.slice(0,n);let i=0;const a=o.map(c=>c.length<=Ws?c:(i+=c.length-Ws,`${c.slice(0,Ws)}...`)).join(`
106
- `),l=Math.max(0,r.length-o.length);return{text:a,hiddenCount:Bb({hiddenChars:i,hiddenLines:l})}}function Ob(e){if(!sn(e.status)||!ao(e.toolName))return null;const t=lo(e.result,e.status==="error").trimEnd();if(e.result===void 0&&!t)return null;const n=io(e.typography),r=oc(e.rowWidthPx,n),i=kt(Math.round(e.previewLineCount??4),1,8)*n.outputLineHeightPx,a=t?Math.max(Ge.minOutputRowPx,Math.min(i,ic(t,r)*n.outputLineHeightPx)+n.outputRowChromePx):e.result?Ge.emptyOutputRowPx:0;return kt(a+Ge.previewBorderPx,Ge.minPx,Math.max(Ge.maxPx,i+n.outputRowChromePx+Ge.previewBorderPx))}function ea(){if(typeof document>"u")return Ht;const e=document.createElement("span");e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.fontFamily="var(--output-prose-font-family)",e.style.fontSize="var(--output-prose-font-size)",e.style.lineHeight="var(--output-prose-line-height)",e.textContent="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",document.body.appendChild(e);const t=window.getComputedStyle(e),n=e.getBoundingClientRect(),r=Number.parseFloat(t.fontSize),o=Number.parseFloat(t.lineHeight);e.remove();const i=Number.isFinite(r)?r:Ht.outputLineHeightPx/1.5,a=n.width>0&&e.textContent?n.width/e.textContent.length:i*.5,l=Number.isFinite(o)?o:i*1.5,c=Ge.outputRowChromePx+(l-Ht.outputLineHeightPx)*.5;return io({averageCharWidthPx:a,outputLineHeightPx:l,outputRowChromePx:c})}function Ub(){const[e,t]=m.useState(ea);return m.useEffect(()=>{const n=()=>t(ea());return n(),window.addEventListener(No,n),()=>window.removeEventListener(No,n)},[]),e}function ao(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function sn(e,t=!0){return t&&(e==="complete"||e==="error")}function Hb(e){let t=e.parentElement;for(;t;){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t;t=t.parentElement}return null}function Wb(e){if(!e)return;const t=Hb(e);if(!t)return;const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(0,t.scrollTop+r.top-n.top-12);t.scrollTop=o,t.dispatchEvent(new Event("scroll"))}function Vb(e){const t=()=>Wb(e.current);t(),typeof window.requestAnimationFrame=="function"&&window.requestAnimationFrame(t),window.setTimeout(t,80)}function Gb(e,t){const n=m.useRef(null),[r,o]=m.useState(null),[i,a]=m.useState(()=>!sn(e,t)||typeof window>"u"||typeof IntersectionObserver>"u");return m.useEffect(()=>{if(!sn(e,t)){a(!0);return}if(typeof IntersectionObserver>"u"){a(!0);return}a(!1)},[e,t]),m.useLayoutEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l)return;const c=Math.round(l.getBoundingClientRect().width);c>0&&o(d=>d===c?d:c)},[i,e,t]),m.useEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l){a(!0);return}const c=new IntersectionObserver(d=>{d.some(u=>u.isIntersecting)&&(a(!0),c.disconnect())},{root:null,rootMargin:Hd});return c.observe(l),()=>c.disconnect()},[i,e,t]),{rowRef:n,shouldHydrate:i,hydrateNow:()=>a(!0),rowWidthPx:r}}const zb=m.memo(function(t){var r,o;const n=((r=t.toolResult)==null?void 0:r.structured)??((o=t.toolResult)==null?void 0:o.content);return s.jsx(cl,{...t,toolResult:n,children:s.jsx(Pb,{...t,children:(i,a,l)=>s.jsx(qb,{...t,toolInput:i,toolResult:a,workflow:l,originalOutput:n})})})});function qb(e){var c,d,u,f,h,g;const{t}=Z(),n=((c=e.toolResult)==null?void 0:c.structured)??((d=e.toolResult)==null?void 0:d.content),r=m.useMemo(()=>{var p;return ze.prepare(e.toolName,{input:e.toolInput,result:n,status:e.status,isError:(p=e.toolResult)==null?void 0:p.isError})},[e.toolName,e.toolInput,n,e.status,(u=e.toolResult)==null?void 0:u.isError]),o=ze.metadata(e.toolName),{enabled:i,reportValidationError:a}=ve();if(m.useEffect(()=>{var y;if(r.kind!=="raw"||!i||!((y=e.toolResult)!=null&&y.structured))return;const p=we(o.tool,e.toolResult.structured);!p.valid&&p.errors&&a(o.tool,p.errors)},[r.kind,i,(f=e.toolResult)==null?void 0:f.structured,o.tool,a]),(g=(h=e.toolResult)==null?void 0:h.media)!=null&&g.length)return s.jsx(ob,{displayName:r.getDisplayName(),media:e.toolResult.media,sourcePath:lb(e.toolName,e.toolInput,e.toolResult.media.length),status:e.status});if(r.kind==="raw"&&o.registered)return s.jsx(Ur,{...e,toolResult:n});const l=Kb(o.tool,e,n);return l?s.jsx("div",{className:`tool-row timeline-item ${dn.waitingRow}`,children:s.jsxs("div",{className:`tool-row-header ${dn.waitingHeader}`,children:[s.jsx("span",{className:"tool-name",children:t("toolShellPollWaitingLabel")}),s.jsx("span",{className:dn.waitingSummary,children:t("toolShellPollWaitingSummary",{target:l})})]})}):s.jsx(Xb,{...e,prepared:r})}function Kb(e,t,n){var o;if(e!=="Bash"&&e!=="WriteStdin"||t.status!=="complete"&&t.status!=="error"||t.workflow||It(t.toolInput)&&(t.toolInput.chars||t.toolInput.linked_file_path))return;const r=Jl(n,t.status==="error",(o=t.toolResult)==null?void 0:o.content);return(r==null?void 0:r.kind)==="waiting"?r.target:void 0}const Xb=m.memo(function({id:t,toolName:n,toolInput:r,toolResult:o,workflow:i,status:a,sessionProvider:l,startTimestampMs:c,resultTimestampMs:d,originalOutput:u,prepared:f}){const[h,g]=Dt(t,"interactive-summary",!1),[p,y]=Dt(t,"bash-command",!1),{enabled:x,reportValidationError:b}=ve(),_=ge(),N=us(),v=Ub(),j=pa(),C=m.useCallback(()=>{g(H=>!H)},[g]),w=m.useMemo(()=>({isStreaming:a==="pending",theme:"dark",toolUseId:t,provider:l,projectPath:(_==null?void 0:_.projectPath)??null,projectPathLinks:o==null?void 0:o.projectPathLinks}),[a,t,l,_==null?void 0:_.projectPath,o==null?void 0:o.projectPathLinks]),k=m.useMemo(()=>({...w,summaryExpanded:h,toggleSummaryExpanded:C}),[w,h,C]),S=(o==null?void 0:o.structured)??(o==null?void 0:o.content),{stableToolPreviewRendering:$}=tu(),{rowRef:T,shouldHydrate:E,hydrateNow:R,rowWidthPx:D}=Gb(a,!$);m.useEffect(()=>{if(!(a!=="pending"||!T.current))return Ud(T.current)},[T,a]);const K=ze.hasInlineRenderer(n),V=Jb(n,S,o==null?void 0:o.content,a),G=Yb(n,r,S,a,V!==null),W=ze.metadata(n).tool;m.useEffect(()=>{if(!x||E||!S||W==="Bash"&&typeof S!="object")return;const H=we(W,S);!H.valid&&H.errors&&b(W,H.errors)},[W,b,x,E,S]);const ie=(f.kind==="partial"||ze.hasCollapsedPreview(n))&&!G,ae=W==="Edit",Pe=W==="Read",se=W==="Bash",Se=se?fr(S,o==null?void 0:o.content,a==="error"):void 0,F=Se!==void 0&&Se!==0,O=W==="Grep",Ce=m.useCallback(H=>{se&&Lt(H.currentTarget,Fb({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),j)},[se,r,S,a,c,d,j]),je=a==="complete"||a==="error"&&W==="WriteStdin"||a==="pending"&&ae,He=je&&ze.hasInteractiveSummary(n),ue=m.useMemo(()=>Ob({toolName:n,result:S,status:a,rowWidthPx:D,typography:v,previewLineCount:N}),[n,r,S,a,D,v,N]),Fe=m.useMemo(()=>!je||!ze.hasInteractiveSummary(n)||!E?null:f.renderInteractiveSummary(k),[n,k,f,E,je]),Oe=Fe!=null&&Fe!==!1,We=m.useMemo(()=>G||f.kind!=="partial"&&!ze.hasCollapsedPreview(n)&&!(i!=null&&i.view)||!E?null:i!=null&&i.view&&o&&(i.markers.length>0||i.view==="matching-lines")?s.jsx(ec,{text:i.outputText??o.content,workflow:i,original:s.jsx("pre",{children:typeof u=="string"?u:JSON.stringify(u,null,2)})}):f.renderCollapsedPreview(w),[n,G,i,u,o,w,f,E]),re=We!=null&&We!==!1,U=se&&re||ae&&re&&o!==void 0,z=!E&&ie&&ue!==null,X=!E&&(ie||He),[xe,L]=Dt(t,"rich-preview",!0),B=Oe||re||X,Q=W==="WriteStdin",pe=m.useMemo(()=>{if(!Q||a!=="complete"||o!=null&&o.isError)return!1;const H=Me(typeof(o==null?void 0:o.content)=="string"?o.content:"").output.trim();if(H.length===0)return!1;const ee=oc(D,v);return ic(H,ee)<=N},[Q,a,o,N,D,v]),ye=!B&&(n==="Edit"||n==="TodoWrite"||pe),[me,Be,ot]=Dt(t,"tool-result",ye),Je=m.useRef(ot);m.useEffect(()=>{pe&&!Je.current&&Be(!0)},[Be,pe]);const[gt,$t]=Dt(t,"inline-tool-result",!1),qe=m.useRef(!1),wn=B&&Oe&&E&&Pe,Qt=O&&He,vc=!B||wn||U||Qt,_n=wn,Nn=U&&E,wc=H=>{H.stopPropagation(),R(),U?L(ee=>(ee||(qe.current=!0),!ee)):Qt?g(ee=>!ee):B?wn&&$t(ee=>(ee||(qe.current=!0),!ee)):(Je.current=!0,Be(ee=>(ee||(qe.current=!0),!ee)))},_c=m.useMemo(()=>mb(n,r,o,a,{projectPath:(_==null?void 0:_.projectPath)??null},f),[n,r,o,a,_==null?void 0:_.projectPath,f]),le=se?jn(r):"",po=xs(It(r)?r._projectPathLinks:void 0),ks=se&&It(r)&&typeof r.description=="string"&&r.description.trim().length>0,Zt=se&&!ks&&le.length>0,xt=m.useMemo(()=>Db(le,N),[le,N]),kn=!p&&xt.hiddenCount!==null&&xt.hiddenCount>0,go=rt(Zt?!V&&p?le:xt.text:""),xo=m.useRef(le);m.useEffect(()=>{xo.current!==le&&(xo.current=le,y(!1))},[le,y]);const yo=m.useCallback(H=>{const ee=H.currentTarget.querySelector(".tool-summary-command-text")??H.currentTarget,yt=kn||!od(ee);if(!le||!yt){Lt(H.currentTarget,null,j);return}const jt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,jt?`[${et(jt.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,kn,j]),Nc=m.useCallback(H=>{if(!le){Lt(H.currentTarget,null,j);return}const ee=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,ee?`[${et(ee.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,j]),kc=m.useCallback(H=>{if(!se)return;const ee=lo(S,a==="error").trimEnd(),yt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),jt=yt?`[${et(yt.seconds)}] `:"",Tc=Yt(ee,N,jt),Sn=H.currentTarget.querySelector(".bash-preview-output"),Rc=(Sn==null?void 0:Sn.querySelector("pre, .fixed-font-rendered__content"))??Sn??H.currentTarget;Lt(H.currentTarget,id(Rc,`${jt}${ee}`,Tc),j)},[se,S,N,r,a,c,d,j]),jo=()=>{R(),B||(Je.current=!0,Be(H=>(H||(qe.current=!0),!H)))},bo=()=>{L(H=>(H||(qe.current=!0),!H))},Sc=B?U?xe?"Collapse preview":"Expand preview":Qt?h?"Collapse summary":"Expand summary":gt?"Collapse inline view":"Expand inline view":me?"Collapse":"Expand",Cc=B?U?xe:Qt?h:gt:me;return m.useLayoutEffect(()=>{!qe.current||!me&&!gt&&!xe||(qe.current=!1,Vb(T))},[xe,me,gt,T]),K?s.jsx("div",{className:"tool-inline timeline-item",children:f.renderInline(w)}):s.jsxs("div",{ref:T,onPointerEnter:R,onFocus:R,className:`tool-row timeline-item ${me?"expanded":"collapsed"} status-${a} ${B?"interactive":""} ${E?"":"rich-deferred"} ${se?"ran-tool-row":""}`,children:[s.jsxs("div",{className:["tool-row-header",B?"non-expandable":"",Zt?"has-command-preview":"",V||F?"has-result-suffix":""].filter(Boolean).join(" "),onClick:X?R:Nn?bo:_n?()=>$t(H=>(H||(qe.current=!0),!H)):B?void 0:jo,onKeyDown:X?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),R())}:Nn?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),bo())}:_n?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),$t(ee=>(ee||(qe.current=!0),!ee)))}:B?void 0:H=>H.key==="Enter"&&jo(),role:X||Nn||_n||!B?"button":"presentation",tabIndex:X||Nn||_n||!B?0:void 0,children:[a==="pending"&&s.jsx("span",{className:"tool-spinner",role:"status","aria-label":"Running",children:s.jsx(nv,{})}),a==="aborted"&&s.jsx("span",{className:"tool-aborted-icon",role:"img","aria-label":"Interrupted",children:"⨯"}),a==="incomplete"&&s.jsx("span",{className:"tool-incomplete-icon",role:"img","aria-label":"Result unavailable",children:"?"}),s.jsxs("span",{className:"tool-name",onPointerEnter:Ce,children:[s.jsx("span",{className:dn.disclosureAnchor,children:vc&&s.jsx(ro,{inline:!0,onClick:wc,label:Sc,expanded:Cc,status:a})}),f.getDisplayName()]}),Oe&&je?s.jsx("span",{className:`tool-summary interactive-summary${Qt?" outline-summary":""}`,children:Fe}):Zt&&V?s.jsx("span",{className:"tool-summary tool-summary-command",...Ss(kn?le:null,j),onPointerEnter:yo,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:xt.text,links:po})})}):Zt?s.jsx("span",{className:["tool-summary","tool-summary-command",p?dn.expandedCommand:""].filter(Boolean).join(" "),...Ss(kn?le:null,j),onPointerEnter:yo,"aria-label":p?"Collapse command":"Show full command","aria-expanded":p,onClick:H=>{var ee,yt;(yt=(ee=H.target)==null?void 0:ee.closest)!=null&&yt.call(ee,"a,button")||(H.preventDefault(),H.stopPropagation(),y(jt=>!jt))},onKeyDown:H=>{H.target===H.currentTarget&&(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),H.stopPropagation(),y(ee=>!ee))},role:"button",tabIndex:0,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:p?le:xt.text,links:po})})}):s.jsxs("span",{className:"tool-summary",...ks&&le?Ss(le,j):{},onPointerEnter:ks&&le?Nc:void 0,children:[_c,a==="aborted"&&s.jsx("span",{className:"tool-aborted-label",children:" (interrupted)"}),a==="incomplete"&&s.jsxs("span",{className:"tool-incomplete-label",children:[" ","(result unavailable)"]})]}),V&&s.jsx("span",{className:"tool-result-suffix",children:"(no output)"}),F&&s.jsxs("span",{className:"tool-result-suffix tool-result-suffix-rc",children:["rc=",Se]}),le&&s.jsx(ov,{text:le,label:"Copy command"}),Zt&&!p&&xt.hiddenCount&&s.jsx(Tt,{className:"tool-summary-command-more",count:xt.hiddenCount,tooltip:le})]}),re&&xe&&s.jsxs("div",{className:"tool-row-collapsed-preview",onPointerEnter:kc,children:[U&&s.jsx(Vs,{onCollapse:()=>L(!1),ariaLabel:"Collapse preview from left gutter"}),We]}),z&&s.jsx("div",{className:"tool-row-collapsed-preview tool-row-deferred-preview",style:{"--tool-row-deferred-preview-height":`${ue}px`},"aria-hidden":"true",children:s.jsx("div",{className:"tool-row-deferred-preview-box"})}),gt&&wn&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>$t(!1)}),s.jsx(ta,{prepared:f,toolResult:o,context:w})]}),me&&!B&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>{Je.current=!0,Be(!1)}}),V&&se?s.jsx(ev,{command:le}):a==="pending"||a==="aborted"||a==="incomplete"?s.jsx(tv,{prepared:f,context:w}):s.jsx(ta,{prepared:f,toolResult:o,context:w})]})]})});function Vs({onCollapse:e,ariaLabel:t="Collapse expanded tool row"}){return s.jsx("button",{type:"button",className:"tool-row-collapse-strip",onClick:n=>{n.stopPropagation(),e()},"aria-label":t,title:t})}function Yb(e,t,n,r,o=!1){return ao(e)?r==="pending"?!Zb(t):n===void 0||o:!1}function Jb(e,t,n,r){if(!ao(e)||r!=="complete"&&r!=="error"||t===void 0)return null;const o=r==="error";return lo(t,o).trim().length>0?null:It(t)?t.interrupted===!0||t.backgroundTaskId!==void 0?null:{exitCode:fr(t,n,o)}:{exitCode:fr(t,n,o)}}function fr(e,t,n=!1){if(typeof e=="string")return Me(e,{bareExitCodeIsEnvelope:n}).exitCode;if(It(e)){const r=Qb(e,["exitCode","exit_code","returnCode","return_code","rc"]);if(r!==void 0)return r;if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:n}).exitCode;if(o!==void 0)return o}}return t?Me(t,{bareExitCodeIsEnvelope:n}).exitCode:void 0}function Qb(e,t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"&&/^-?\d+$/.test(r.trim()))return Number.parseInt(r,10)}}function It(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Zb(e){return It(e)&&e._previewResult!==void 0}function lo(e,t=!1){if(typeof e=="string"){const o=Me(e,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e}if(!It(e))return"";const n=typeof e.stdout=="string"?e.stdout:"",r=typeof e.stderr=="string"?e.stderr:"";if(n||r)return[n,r].filter(Boolean).join(`
107
- `);if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e.content}return""}function ev({command:e}){const t=rt(e);return e.trim()?s.jsx("pre",{ref:t,className:"code-block bash-no-output-command",children:s.jsx("code",{children:e})}):null}function tv({prepared:e,context:t}){return s.jsx("div",{className:"tool-use-expanded",children:e.renderToolUse(t)})}function ta({prepared:e,toolResult:t,context:n}){return t?s.jsx("div",{className:"tool-result-expanded",children:e.renderToolResult(n)}):s.jsx("div",{className:"tool-no-result",children:"No result data"})}function nv(){return s.jsx("svg",{className:"spinner",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:s.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"24",strokeDashoffset:"8"})})}function sv(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5"}),s.jsx("path",{d:"M3 10.5H2.5A1.5 1.5 0 0 1 1 9V2.5A1.5 1.5 0 0 1 2.5 1H9a1.5 1.5 0 0 1 1.5 1.5V3"})]})}function rv(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5 6.5 12 13 4"})})}function ov({text:e,label:t}){const[n,r]=m.useState(!1);return s.jsx("button",{type:"button",className:`tool-header-copy ${n?"copied":""}`,onClick:o=>{o.preventDefault(),o.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{r(!0),window.setTimeout(()=>r(!1),3e3)}).catch(i=>{console.error("Failed to copy tool header text:",i)})},"aria-label":n?"Copied":t,title:n?"Copied":t,children:n?s.jsx(rv,{}):s.jsx(sv,{})})}const iv="_thinkingPreviewLabel_yqj8y_20",av="_thinkingPreviewAge_yqj8y_33",lv="_activityChevron_yqj8y_40",cv="_activityChevronExpanded_yqj8y_51",dv="_activityPulse_yqj8y_55",uv="_activityLabel_yqj8y_66",mv="_activityHeightReserve_yqj8y_83",fv="_thinkingRollingUp_yqj8y_94",hv="_thinkingAutoHiding_yqj8y_114",pv="_compactBoundaryOutline_yqj8y_163",gv="_toolOutputDetails_yqj8y_173",xv="_rewoundGroupHeader_yqj8y_182",yv="_rewoundGroupToggleButton_yqj8y_189",jv="_rewoundItem_yqj8y_209",bv="_rewoundGroupToggle_yqj8y_189",vv="_rewoundGroupCopy_yqj8y_231",Ie={thinkingPreviewLabel:iv,thinkingPreviewAge:av,activityChevron:lv,activityChevronExpanded:cv,activityPulse:dv,activityLabel:uv,activityHeightReserve:mv,thinkingRollingUp:fv,thinkingAutoHiding:hv,compactBoundaryOutline:pv,toolOutputDetails:gv,rewoundGroupHeader:xv,rewoundGroupToggleButton:yv,rewoundItem:jv,rewoundGroupToggle:bv,rewoundGroupCopy:vv};function wv({text:e,workflow:t,isStreaming:n,original:r,renderText:o}){const i=Kt(),a=ge(),l=ps(),c=La(i.sourceKey),d=a==null?void 0:a.projectId,u=!l&&!!d&&!!c&&ga(c,xa),f=Ja(e,t),h=JSON.stringify(f.map(_=>_.text).filter(_=>_.trim())),g=m.useMemo(()=>JSON.parse(h),[h]),p=JSON.stringify([i.sourceKey,d,a==null?void 0:a.sessionId,h]),[y,x]=m.useState(null);if(m.useEffect(()=>{if(!u||!d||n)return;const _=new AbortController;return tc(i,d,g,_.signal).then(N=>{_.signal.aborted||x({key:p,html:N})},()=>{_.signal.aborted||x(null)}),()=>_.abort()},[i,d,u,n,g,p]),!u||n||(y==null?void 0:y.key)!==p)return r;let b=0;return s.jsx(ec,{text:e,workflow:t,original:r,preview:f.map((_,N)=>s.jsxs(m.Fragment,{children:[_.marker?s.jsx(oo,{marker:_.marker}):null,_.text.trim()?o(_.text,y.html[b++]):null]},N))})}function _v(e){return typeof e.uuid=="string"&&e.uuid.length>0?e.uuid:typeof e.id=="string"&&e.id.length>0?e.id:"<missing>"}function Nv(e){const t={sdk:0,jsonl:0,unknown:0},n={},r=[];let o=0,i=0;for(const a of e){const l=a._source==="sdk"||a._source==="jsonl"?a._source:"unknown";t[l]=(t[l]??0)+1;const c=typeof a.type=="string"?a.type:"unknown";n[c]=(n[c]??0)+1,c==="stream_event"&&o++,a._isStreaming&&i++,r.push(_v(a))}return{total:e.length,bySource:t,byType:n,streamEventCount:o,streamingPlaceholderCount:i,ids:r}}function kv(e,t){var r;const n=Nv(e.sourceMessages);return{render:{id:e.id,type:e.type,isSubagent:e.isSubagent??!1},uiContext:{sessionProvider:t.sessionProvider??"unknown",sessionIsStreaming:t.isStreaming,thinkingExpanded:t.thinkingExpanded},itemContext:e.type==="tool_call"?{toolName:e.toolName,status:e.status,hasToolResult:!!e.toolResult,hasStructuredResult:((r=e.toolResult)==null?void 0:r.structured)!==void 0,toolUseId:e.id}:e.type==="text"?{isStreamingTextBlock:e.isStreaming??!1,hasAugmentHtml:!!e.augmentHtml}:e.type==="thinking"?{status:e.status,thinkingLength:e.thinking.length}:e.type==="system"?{subtype:e.subtype,status:e.status??null}:e.type==="session_setup"?{promptCount:e.prompts.length}:null,sourceSummary:n,sourceMessages:e.sourceMessages,renderItem:e}}function ac(e){return typeof e=="string"?e:e.map(t=>t.type==="text"&&typeof t.text=="string"?t.text:t.type==="tool_result"&&typeof t.content=="string"?t.content:"").filter(Boolean).join(`
106
+ `),l=Math.max(0,r.length-o.length);return{text:a,hiddenCount:Bb({hiddenChars:i,hiddenLines:l})}}function Ob(e){if(!sn(e.status)||!ao(e.toolName))return null;const t=lo(e.result,e.status==="error").trimEnd();if(e.result===void 0&&!t)return null;const n=io(e.typography),r=oc(e.rowWidthPx,n),i=kt(Math.round(e.previewLineCount??4),1,8)*n.outputLineHeightPx,a=t?Math.max(Ge.minOutputRowPx,Math.min(i,ic(t,r)*n.outputLineHeightPx)+n.outputRowChromePx):e.result?Ge.emptyOutputRowPx:0;return kt(a+Ge.previewBorderPx,Ge.minPx,Math.max(Ge.maxPx,i+n.outputRowChromePx+Ge.previewBorderPx))}function ea(){if(typeof document>"u")return Ht;const e=document.createElement("span");e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.fontFamily="var(--output-prose-font-family)",e.style.fontSize="var(--output-prose-font-size)",e.style.lineHeight="var(--output-prose-line-height)",e.textContent="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",document.body.appendChild(e);const t=window.getComputedStyle(e),n=e.getBoundingClientRect(),r=Number.parseFloat(t.fontSize),o=Number.parseFloat(t.lineHeight);e.remove();const i=Number.isFinite(r)?r:Ht.outputLineHeightPx/1.5,a=n.width>0&&e.textContent?n.width/e.textContent.length:i*.5,l=Number.isFinite(o)?o:i*1.5,c=Ge.outputRowChromePx+(l-Ht.outputLineHeightPx)*.5;return io({averageCharWidthPx:a,outputLineHeightPx:l,outputRowChromePx:c})}function Ub(){const[e,t]=m.useState(ea);return m.useEffect(()=>{const n=()=>t(ea());return n(),window.addEventListener(No,n),()=>window.removeEventListener(No,n)},[]),e}function ao(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function sn(e,t=!0){return t&&(e==="complete"||e==="error")}function Hb(e){let t=e.parentElement;for(;t;){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t;t=t.parentElement}return null}function Wb(e){if(!e)return;const t=Hb(e);if(!t)return;const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(0,t.scrollTop+r.top-n.top-12);t.scrollTop=o,t.dispatchEvent(new Event("scroll"))}function Vb(e){const t=()=>Wb(e.current);t(),typeof window.requestAnimationFrame=="function"&&window.requestAnimationFrame(t),window.setTimeout(t,80)}function Gb(e,t){const n=m.useRef(null),[r,o]=m.useState(null),[i,a]=m.useState(()=>!sn(e,t)||typeof window>"u"||typeof IntersectionObserver>"u");return m.useEffect(()=>{if(!sn(e,t)){a(!0);return}if(typeof IntersectionObserver>"u"){a(!0);return}a(!1)},[e,t]),m.useLayoutEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l)return;const c=Math.round(l.getBoundingClientRect().width);c>0&&o(d=>d===c?d:c)},[i,e,t]),m.useEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l){a(!0);return}const c=new IntersectionObserver(d=>{d.some(u=>u.isIntersecting)&&(a(!0),c.disconnect())},{root:null,rootMargin:Kd});return c.observe(l),()=>c.disconnect()},[i,e,t]),{rowRef:n,shouldHydrate:i,hydrateNow:()=>a(!0),rowWidthPx:r}}const zb=m.memo(function(t){var r,o;const n=((r=t.toolResult)==null?void 0:r.structured)??((o=t.toolResult)==null?void 0:o.content);return s.jsx(cl,{...t,toolResult:n,children:s.jsx(Pb,{...t,children:(i,a,l)=>s.jsx(qb,{...t,toolInput:i,toolResult:a,workflow:l,originalOutput:n})})})});function qb(e){var c,d,u,f,h,g;const{t}=Z(),n=((c=e.toolResult)==null?void 0:c.structured)??((d=e.toolResult)==null?void 0:d.content),r=m.useMemo(()=>{var p;return ze.prepare(e.toolName,{input:e.toolInput,result:n,status:e.status,isError:(p=e.toolResult)==null?void 0:p.isError})},[e.toolName,e.toolInput,n,e.status,(u=e.toolResult)==null?void 0:u.isError]),o=ze.metadata(e.toolName),{enabled:i,reportValidationError:a}=ve();if(m.useEffect(()=>{var y;if(r.kind!=="raw"||!i||!((y=e.toolResult)!=null&&y.structured))return;const p=we(o.tool,e.toolResult.structured);!p.valid&&p.errors&&a(o.tool,p.errors)},[r.kind,i,(f=e.toolResult)==null?void 0:f.structured,o.tool,a]),(g=(h=e.toolResult)==null?void 0:h.media)!=null&&g.length)return s.jsx(ob,{displayName:r.getDisplayName(),media:e.toolResult.media,sourcePath:lb(e.toolName,e.toolInput,e.toolResult.media.length),status:e.status});if(r.kind==="raw"&&o.registered)return s.jsx(Ur,{...e,toolResult:n});const l=Kb(o.tool,e,n);return l?s.jsx("div",{className:`tool-row timeline-item ${dn.waitingRow}`,children:s.jsxs("div",{className:`tool-row-header ${dn.waitingHeader}`,children:[s.jsx("span",{className:"tool-name",children:t("toolShellPollWaitingLabel")}),s.jsx("span",{className:dn.waitingSummary,children:t("toolShellPollWaitingSummary",{target:l})})]})}):s.jsx(Xb,{...e,prepared:r})}function Kb(e,t,n){var o;if(e!=="Bash"&&e!=="WriteStdin"||t.status!=="complete"&&t.status!=="error"||t.workflow||It(t.toolInput)&&(t.toolInput.chars||t.toolInput.linked_file_path))return;const r=Jl(n,t.status==="error",(o=t.toolResult)==null?void 0:o.content);return(r==null?void 0:r.kind)==="waiting"?r.target:void 0}const Xb=m.memo(function({id:t,toolName:n,toolInput:r,toolResult:o,workflow:i,status:a,sessionProvider:l,startTimestampMs:c,resultTimestampMs:d,originalOutput:u,prepared:f}){const[h,g]=Dt(t,"interactive-summary",!1),[p,y]=Dt(t,"bash-command",!1),{enabled:x,reportValidationError:b}=ve(),_=ge(),N=us(),v=Ub(),j=pa(),C=m.useCallback(()=>{g(H=>!H)},[g]),w=m.useMemo(()=>({isStreaming:a==="pending",theme:"dark",toolUseId:t,provider:l,projectPath:(_==null?void 0:_.projectPath)??null,projectPathLinks:o==null?void 0:o.projectPathLinks}),[a,t,l,_==null?void 0:_.projectPath,o==null?void 0:o.projectPathLinks]),k=m.useMemo(()=>({...w,summaryExpanded:h,toggleSummaryExpanded:C}),[w,h,C]),S=(o==null?void 0:o.structured)??(o==null?void 0:o.content),{stableToolPreviewRendering:$}=tu(),{rowRef:T,shouldHydrate:E,hydrateNow:R,rowWidthPx:D}=Gb(a,!$);m.useEffect(()=>{if(!(a!=="pending"||!T.current))return qd(T.current)},[T,a]);const K=ze.hasInlineRenderer(n),V=Jb(n,S,o==null?void 0:o.content,a),G=Yb(n,r,S,a,V!==null),W=ze.metadata(n).tool;m.useEffect(()=>{if(!x||E||!S||W==="Bash"&&typeof S!="object")return;const H=we(W,S);!H.valid&&H.errors&&b(W,H.errors)},[W,b,x,E,S]);const ie=(f.kind==="partial"||ze.hasCollapsedPreview(n))&&!G,ae=W==="Edit",Pe=W==="Read",se=W==="Bash",Se=se?fr(S,o==null?void 0:o.content,a==="error"):void 0,F=Se!==void 0&&Se!==0,O=W==="Grep",Ce=m.useCallback(H=>{se&&Lt(H.currentTarget,Fb({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),j)},[se,r,S,a,c,d,j]),je=a==="complete"||a==="error"&&W==="WriteStdin"||a==="pending"&&ae,He=je&&ze.hasInteractiveSummary(n),ue=m.useMemo(()=>Ob({toolName:n,result:S,status:a,rowWidthPx:D,typography:v,previewLineCount:N}),[n,r,S,a,D,v,N]),Fe=m.useMemo(()=>!je||!ze.hasInteractiveSummary(n)||!E?null:f.renderInteractiveSummary(k),[n,k,f,E,je]),Oe=Fe!=null&&Fe!==!1,We=m.useMemo(()=>G||f.kind!=="partial"&&!ze.hasCollapsedPreview(n)&&!(i!=null&&i.view)||!E?null:i!=null&&i.view&&o&&(i.markers.length>0||i.view==="matching-lines")?s.jsx(ec,{text:i.outputText??o.content,workflow:i,original:s.jsx("pre",{children:typeof u=="string"?u:JSON.stringify(u,null,2)})}):f.renderCollapsedPreview(w),[n,G,i,u,o,w,f,E]),re=We!=null&&We!==!1,U=se&&re||ae&&re&&o!==void 0,z=!E&&ie&&ue!==null,X=!E&&(ie||He),[xe,L]=Dt(t,"rich-preview",!0),B=Oe||re||X,Q=W==="WriteStdin",pe=m.useMemo(()=>{if(!Q||a!=="complete"||o!=null&&o.isError)return!1;const H=Me(typeof(o==null?void 0:o.content)=="string"?o.content:"").output.trim();if(H.length===0)return!1;const ee=oc(D,v);return ic(H,ee)<=N},[Q,a,o,N,D,v]),ye=!B&&(n==="Edit"||n==="TodoWrite"||pe),[me,Be,rt]=Dt(t,"tool-result",ye),Je=m.useRef(rt);m.useEffect(()=>{pe&&!Je.current&&Be(!0)},[Be,pe]);const[gt,$t]=Dt(t,"inline-tool-result",!1),qe=m.useRef(!1),wn=B&&Oe&&E&&Pe,Qt=O&&He,vc=!B||wn||U||Qt,_n=wn,Nn=U&&E,wc=H=>{H.stopPropagation(),R(),U?L(ee=>(ee||(qe.current=!0),!ee)):Qt?g(ee=>!ee):B?wn&&$t(ee=>(ee||(qe.current=!0),!ee)):(Je.current=!0,Be(ee=>(ee||(qe.current=!0),!ee)))},_c=m.useMemo(()=>mb(n,r,o,a,{projectPath:(_==null?void 0:_.projectPath)??null},f),[n,r,o,a,_==null?void 0:_.projectPath,f]),le=se?jn(r):"",po=xs(It(r)?r._projectPathLinks:void 0),ks=se&&It(r)&&typeof r.description=="string"&&r.description.trim().length>0,Zt=se&&!ks&&le.length>0,xt=m.useMemo(()=>Db(le,N),[le,N]),kn=!p&&xt.hiddenCount!==null&&xt.hiddenCount>0,go=st(Zt?!V&&p?le:xt.text:""),xo=m.useRef(le);m.useEffect(()=>{xo.current!==le&&(xo.current=le,y(!1))},[le,y]);const yo=m.useCallback(H=>{const ee=H.currentTarget.querySelector(".tool-summary-command-text")??H.currentTarget,yt=kn||!od(ee);if(!le||!yt){Lt(H.currentTarget,null,j);return}const jt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,jt?`[${et(jt.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,kn,j]),Nc=m.useCallback(H=>{if(!le){Lt(H.currentTarget,null,j);return}const ee=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,ee?`[${et(ee.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,j]),kc=m.useCallback(H=>{if(!se)return;const ee=lo(S,a==="error").trimEnd(),yt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),jt=yt?`[${et(yt.seconds)}] `:"",Tc=Yt(ee,N,jt),Sn=H.currentTarget.querySelector(".bash-preview-output"),Rc=(Sn==null?void 0:Sn.querySelector("pre, .fixed-font-rendered__content"))??Sn??H.currentTarget;Lt(H.currentTarget,id(Rc,`${jt}${ee}`,Tc),j)},[se,S,N,r,a,c,d,j]),jo=()=>{R(),B||(Je.current=!0,Be(H=>(H||(qe.current=!0),!H)))},bo=()=>{L(H=>(H||(qe.current=!0),!H))},Sc=B?U?xe?"Collapse preview":"Expand preview":Qt?h?"Collapse summary":"Expand summary":gt?"Collapse inline view":"Expand inline view":me?"Collapse":"Expand",Cc=B?U?xe:Qt?h:gt:me;return m.useLayoutEffect(()=>{!qe.current||!me&&!gt&&!xe||(qe.current=!1,Vb(T))},[xe,me,gt,T]),K?s.jsx("div",{className:"tool-inline timeline-item",children:f.renderInline(w)}):s.jsxs("div",{ref:T,onPointerEnter:R,onFocus:R,className:`tool-row timeline-item ${me?"expanded":"collapsed"} status-${a} ${B?"interactive":""} ${E?"":"rich-deferred"} ${se?"ran-tool-row":""}`,children:[s.jsxs("div",{className:["tool-row-header",B?"non-expandable":"",Zt?"has-command-preview":"",V||F?"has-result-suffix":""].filter(Boolean).join(" "),onClick:X?R:Nn?bo:_n?()=>$t(H=>(H||(qe.current=!0),!H)):B?void 0:jo,onKeyDown:X?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),R())}:Nn?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),bo())}:_n?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),$t(ee=>(ee||(qe.current=!0),!ee)))}:B?void 0:H=>H.key==="Enter"&&jo(),role:X||Nn||_n||!B?"button":"presentation",tabIndex:X||Nn||_n||!B?0:void 0,children:[a==="pending"&&s.jsx("span",{className:"tool-spinner",role:"status","aria-label":"Running",children:s.jsx(nv,{})}),a==="aborted"&&s.jsx("span",{className:"tool-aborted-icon",role:"img","aria-label":"Interrupted",children:"⨯"}),a==="incomplete"&&s.jsx("span",{className:"tool-incomplete-icon",role:"img","aria-label":"Result unavailable",children:"?"}),s.jsxs("span",{className:"tool-name",onPointerEnter:Ce,children:[s.jsx("span",{className:dn.disclosureAnchor,children:vc&&s.jsx(ro,{inline:!0,onClick:wc,label:Sc,expanded:Cc,status:a})}),f.getDisplayName()]}),Oe&&je?s.jsx("span",{className:`tool-summary interactive-summary${Qt?" outline-summary":""}`,children:Fe}):Zt&&V?s.jsx("span",{className:"tool-summary tool-summary-command",...Ss(kn?le:null,j),onPointerEnter:yo,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:xt.text,links:po})})}):Zt?s.jsx("span",{className:["tool-summary","tool-summary-command",p?dn.expandedCommand:""].filter(Boolean).join(" "),...Ss(kn?le:null,j),onPointerEnter:yo,"aria-label":p?"Collapse command":"Show full command","aria-expanded":p,onClick:H=>{var ee,yt;(yt=(ee=H.target)==null?void 0:ee.closest)!=null&&yt.call(ee,"a,button")||(H.preventDefault(),H.stopPropagation(),y(jt=>!jt))},onKeyDown:H=>{H.target===H.currentTarget&&(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),H.stopPropagation(),y(ee=>!ee))},role:"button",tabIndex:0,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:p?le:xt.text,links:po})})}):s.jsxs("span",{className:"tool-summary",...ks&&le?Ss(le,j):{},onPointerEnter:ks&&le?Nc:void 0,children:[_c,a==="aborted"&&s.jsx("span",{className:"tool-aborted-label",children:" (interrupted)"}),a==="incomplete"&&s.jsxs("span",{className:"tool-incomplete-label",children:[" ","(result unavailable)"]})]}),V&&s.jsx("span",{className:"tool-result-suffix",children:"(no output)"}),F&&s.jsxs("span",{className:"tool-result-suffix tool-result-suffix-rc",children:["rc=",Se]}),le&&s.jsx(ov,{text:le,label:"Copy command"}),Zt&&!p&&xt.hiddenCount&&s.jsx(Tt,{className:"tool-summary-command-more",count:xt.hiddenCount,tooltip:le})]}),re&&xe&&s.jsxs("div",{className:"tool-row-collapsed-preview",onPointerEnter:kc,children:[U&&s.jsx(Vs,{onCollapse:()=>L(!1),ariaLabel:"Collapse preview from left gutter"}),We]}),z&&s.jsx("div",{className:"tool-row-collapsed-preview tool-row-deferred-preview",style:{"--tool-row-deferred-preview-height":`${ue}px`},"aria-hidden":"true",children:s.jsx("div",{className:"tool-row-deferred-preview-box"})}),gt&&wn&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>$t(!1)}),s.jsx(ta,{prepared:f,toolResult:o,context:w})]}),me&&!B&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>{Je.current=!0,Be(!1)}}),V&&se?s.jsx(ev,{command:le}):a==="pending"||a==="aborted"||a==="incomplete"?s.jsx(tv,{prepared:f,context:w}):s.jsx(ta,{prepared:f,toolResult:o,context:w})]})]})});function Vs({onCollapse:e,ariaLabel:t="Collapse expanded tool row"}){return s.jsx("button",{type:"button",className:"tool-row-collapse-strip",onClick:n=>{n.stopPropagation(),e()},"aria-label":t,title:t})}function Yb(e,t,n,r,o=!1){return ao(e)?r==="pending"?!Zb(t):n===void 0||o:!1}function Jb(e,t,n,r){if(!ao(e)||r!=="complete"&&r!=="error"||t===void 0)return null;const o=r==="error";return lo(t,o).trim().length>0?null:It(t)?t.interrupted===!0||t.backgroundTaskId!==void 0?null:{exitCode:fr(t,n,o)}:{exitCode:fr(t,n,o)}}function fr(e,t,n=!1){if(typeof e=="string")return Me(e,{bareExitCodeIsEnvelope:n}).exitCode;if(It(e)){const r=Qb(e,["exitCode","exit_code","returnCode","return_code","rc"]);if(r!==void 0)return r;if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:n}).exitCode;if(o!==void 0)return o}}return t?Me(t,{bareExitCodeIsEnvelope:n}).exitCode:void 0}function Qb(e,t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"&&/^-?\d+$/.test(r.trim()))return Number.parseInt(r,10)}}function It(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Zb(e){return It(e)&&e._previewResult!==void 0}function lo(e,t=!1){if(typeof e=="string"){const o=Me(e,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e}if(!It(e))return"";const n=typeof e.stdout=="string"?e.stdout:"",r=typeof e.stderr=="string"?e.stderr:"";if(n||r)return[n,r].filter(Boolean).join(`
107
+ `);if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e.content}return""}function ev({command:e}){const t=st(e);return e.trim()?s.jsx("pre",{ref:t,className:"code-block bash-no-output-command",children:s.jsx("code",{children:e})}):null}function tv({prepared:e,context:t}){return s.jsx("div",{className:"tool-use-expanded",children:e.renderToolUse(t)})}function ta({prepared:e,toolResult:t,context:n}){return t?s.jsx("div",{className:"tool-result-expanded",children:e.renderToolResult(n)}):s.jsx("div",{className:"tool-no-result",children:"No result data"})}function nv(){return s.jsx("svg",{className:"spinner",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:s.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"24",strokeDashoffset:"8"})})}function sv(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5"}),s.jsx("path",{d:"M3 10.5H2.5A1.5 1.5 0 0 1 1 9V2.5A1.5 1.5 0 0 1 2.5 1H9a1.5 1.5 0 0 1 1.5 1.5V3"})]})}function rv(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5 6.5 12 13 4"})})}function ov({text:e,label:t}){const[n,r]=m.useState(!1);return s.jsx("button",{type:"button",className:`tool-header-copy ${n?"copied":""}`,onClick:o=>{o.preventDefault(),o.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{r(!0),window.setTimeout(()=>r(!1),3e3)}).catch(i=>{console.error("Failed to copy tool header text:",i)})},"aria-label":n?"Copied":t,title:n?"Copied":t,children:n?s.jsx(rv,{}):s.jsx(sv,{})})}const iv="_thinkingPreviewLabel_yqj8y_20",av="_thinkingPreviewAge_yqj8y_33",lv="_activityChevron_yqj8y_40",cv="_activityChevronExpanded_yqj8y_51",dv="_activityPulse_yqj8y_55",uv="_activityLabel_yqj8y_66",mv="_activityHeightReserve_yqj8y_83",fv="_thinkingRollingUp_yqj8y_94",hv="_thinkingAutoHiding_yqj8y_114",pv="_compactBoundaryOutline_yqj8y_163",gv="_toolOutputDetails_yqj8y_173",xv="_rewoundGroupHeader_yqj8y_182",yv="_rewoundGroupToggleButton_yqj8y_189",jv="_rewoundItem_yqj8y_209",bv="_rewoundGroupToggle_yqj8y_189",vv="_rewoundGroupCopy_yqj8y_231",Ie={thinkingPreviewLabel:iv,thinkingPreviewAge:av,activityChevron:lv,activityChevronExpanded:cv,activityPulse:dv,activityLabel:uv,activityHeightReserve:mv,thinkingRollingUp:fv,thinkingAutoHiding:hv,compactBoundaryOutline:pv,toolOutputDetails:gv,rewoundGroupHeader:xv,rewoundGroupToggleButton:yv,rewoundItem:jv,rewoundGroupToggle:bv,rewoundGroupCopy:vv};function wv({text:e,workflow:t,isStreaming:n,original:r,renderText:o}){const i=Kt(),a=ge(),l=ps(),c=Aa(i.sourceKey),d=a==null?void 0:a.projectId,u=!l&&!!d&&!!c&&ga(c,xa),f=Ja(e,t),h=JSON.stringify(f.map(_=>_.text).filter(_=>_.trim())),g=m.useMemo(()=>JSON.parse(h),[h]),p=JSON.stringify([i.sourceKey,d,a==null?void 0:a.sessionId,h]),[y,x]=m.useState(null);if(m.useEffect(()=>{if(!u||!d||n)return;const _=new AbortController;return tc(i,d,g,_.signal).then(N=>{_.signal.aborted||x({key:p,html:N})},()=>{_.signal.aborted||x(null)}),()=>_.abort()},[i,d,u,n,g,p]),!u||n||(y==null?void 0:y.key)!==p)return r;let b=0;return s.jsx(ec,{text:e,workflow:t,original:r,preview:f.map((_,N)=>s.jsxs(m.Fragment,{children:[_.marker?s.jsx(oo,{marker:_.marker}):null,_.text.trim()?o(_.text,y.html[b++]):null]},N))})}function _v(e){return typeof e.uuid=="string"&&e.uuid.length>0?e.uuid:typeof e.id=="string"&&e.id.length>0?e.id:"<missing>"}function Nv(e){const t={sdk:0,jsonl:0,unknown:0},n={},r=[];let o=0,i=0;for(const a of e){const l=a._source==="sdk"||a._source==="jsonl"?a._source:"unknown";t[l]=(t[l]??0)+1;const c=typeof a.type=="string"?a.type:"unknown";n[c]=(n[c]??0)+1,c==="stream_event"&&o++,a._isStreaming&&i++,r.push(_v(a))}return{total:e.length,bySource:t,byType:n,streamEventCount:o,streamingPlaceholderCount:i,ids:r}}function kv(e,t){var r;const n=Nv(e.sourceMessages);return{render:{id:e.id,type:e.type,isSubagent:e.isSubagent??!1},uiContext:{sessionProvider:t.sessionProvider??"unknown",sessionIsStreaming:t.isStreaming,thinkingExpanded:t.thinkingExpanded},itemContext:e.type==="tool_call"?{toolName:e.toolName,status:e.status,hasToolResult:!!e.toolResult,hasStructuredResult:((r=e.toolResult)==null?void 0:r.structured)!==void 0,toolUseId:e.id}:e.type==="text"?{isStreamingTextBlock:e.isStreaming??!1,hasAugmentHtml:!!e.augmentHtml}:e.type==="thinking"?{status:e.status,thinkingLength:e.thinking.length}:e.type==="system"?{subtype:e.subtype,status:e.status??null}:e.type==="session_setup"?{promptCount:e.prompts.length}:null,sourceSummary:n,sourceMessages:e.sourceMessages,renderItem:e}}function ac(e){return typeof e=="string"?e:e.map(t=>t.type==="text"&&typeof t.text=="string"?t.text:t.type==="tool_result"&&typeof t.content=="string"?t.content:"").filter(Boolean).join(`
108
108
  `)}const Sv="No provider summary was retained for this compaction.";function hr(e,t){return e==="/"&&t.trimStart().startsWith("/")?"":e}function Cv({item:e}){const{t}=Z(),n=ol(),r=xn(e),o=e.sourceMessages[0],i=(o==null?void 0:o.rewoundGroup)??{},a=r?n.expandedRewoundGroups.has(r):!1,l=String(i.droppedTurnCount??i.rowCount??0),c=String(i.cutTurnIndex??0),d=i.clearloopIteration!==void 0?t("rewoundGroupClearloopLabel",{iteration:String(i.clearloopIteration),total:String(i.clearloopTotal??"?"),prompt:i.clearloopPrompt??"",index:c}):t("rewoundGroupLabel",{index:c}),u=t("rewoundGroupTooltip",{count:l}),f=i.clearloopIteration!==void 0&&i.clearloopTotal!==void 0&&i.clearloopPrompt?`/clearloop ${c} ${Math.max(0,i.clearloopTotal-i.clearloopIteration)}: ${i.clearloopPrompt}`:null;return s.jsxs("div",{className:`system-message system-message-local-command ${Ie.rewoundGroupHeader}`,children:[s.jsxs("button",{type:"button",className:Ie.rewoundGroupToggleButton,"aria-expanded":a,title:`${u} — ${t(a?"rewoundGroupCollapse":"rewoundGroupExpand")}`,onClick:()=>r&&n.toggleRewoundGroup(r),children:[s.jsx("span",{className:Ie.rewoundGroupToggle,"aria-hidden":"true",children:a?"−":"+"}),s.jsx("span",{className:"system-message-icon",children:"↶"}),s.jsx("span",{className:"system-message-text",children:d})]}),f&&s.jsx(Ma,{text:f,label:t("rewoundGroupCopyRelaunch"),className:`user-prompt-action user-prompt-action-copy ${Ie.rewoundGroupCopy}`})]})}function Tv({item:e,icon:t,label:n}){const r=(e.details??[]).map(ac).map(f=>f.trim()).filter(Boolean),o=e.subtype==="compact_boundary",i=e.subtype==="tool_output",a=o?"system-message-compact-boundary":"system-message-local-command",l=o?"system-message-summary system-message-compact-summary":"system-message-summary system-message-local-command-summary",c=n??e.content,d=hr(t,c);if(!o&&r.length===0)return s.jsxs("div",{className:`system-message ${a}`,children:[d&&s.jsx("span",{className:"system-message-icon",children:d}),s.jsx("span",{className:"system-message-text",children:s.jsx(St,{text:c})})]});const u=r.length>0?r:[Sv];return s.jsxs("details",{className:`system-message ${a} ${a}--details system-message--details${o?` ${Ie.compactBoundaryOutline}`:""}`,children:[s.jsxs("summary",{className:l,children:[s.jsx("span",{className:"collapsible__icon","aria-hidden":"true",children:"▸"}),d&&s.jsx("span",{className:"system-message-icon",children:d}),s.jsx("span",{className:"system-message-text",children:s.jsx(St,{text:c})})]}),s.jsx("div",{className:`system-message-details${i?` ${Ie.toolOutputDetails}`:""}`,children:u.map((f,h)=>s.jsx("pre",{className:"system-message-detail",children:f},`${e.id}-system-detail-${h}`))})]})}const lc='.conversation-thinking-preview[data-preview-slot="latest"]',Rv='.conversation-thinking-preview[data-preview-slot="previous"]',co=".conversation-thinking-preview-content",pr="--conversation-previous-thinking-budget",Gn="previousThinking",Ln="--conversation-thinking-height";function Pv(e){for(let t=e.parentElement;t;t=t.parentElement){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t}return null}function Ev(e,t){var l;const n=e.querySelector(`${co} .thinking-text`),r=n?Number.parseFloat(window.getComputedStyle(n).lineHeight):Number.NaN,o=Number.isFinite(r)&&r>0?r:Rj*(Number.parseFloat(window.getComputedStyle(e).fontSize)||0),i=(l=e.previousElementSibling)==null?void 0:l.getBoundingClientRect().bottom,a=i===void 0?0:Math.max(0,t.top-i);return Tj*o+a}function Iv(e,t){if(!t)return 0;const n=t.scrollTop+e.bottom-t.getBoundingClientRect().top;return Math.max(0,t.scrollHeight-n)}function Gs(e){delete e.dataset[Gn],e.style.removeProperty(pr)}function Mv(e,t){const n=(t==null?void 0:t.clientHeight)||window.innerHeight;if(!(n>0))return Gs(e),null;const r=e.getBoundingClientRect(),o=Ev(e,r),i=Iv(r,t),a=Kl(n,i+o),l=e.querySelector(lc),c=e.querySelector(Rv);if(!l||!c)return Gs(e),a;const d=l.getBoundingClientRect(),u=c.getBoundingClientRect();if(Lj(u.top-d.top,e.dataset[Gn]===void 0))return Gs(e),a;const f=l.querySelector(co),h=Pj({viewportHeightPx:n,trailingContentPx:i,contextReservePx:o,previousTopPx:u.top-r.top,previousChromePx:d.height-((f==null?void 0:f.getBoundingClientRect().height)??0)+(Number.parseFloat(window.getComputedStyle(l).marginBottom)||0)});return h===null?(e.dataset[Gn]="dropped",e.style.removeProperty(pr)):(e.dataset[Gn]="stacked",e.style.setProperty(pr,`${Math.round(h)}px`)),a}function cc(e,t,n=null){const r=e.getBoundingClientRect().top;let o=0;for(const c of Array.from(e.children))o=Math.max(o,c.getBoundingClientRect().bottom-r);const i=Date.now(),a=vj(t.reserve,o,i);t.reserve=a,e.style.setProperty("--conversation-activity-reserved-height",`${n===null?a.heightPx:Math.min(a.heightPx,n)}px`),t.timer!==null&&(window.clearTimeout(t.timer),t.timer=null);const l=wj(a,i);l!==null&&(t.timer=window.setTimeout(()=>{t.timer=null,cc(e,t)},l))}function dc(e){return e>=10&&e<60?`${Math.round(e)}s`:et(e)}function $v({item:e,onToggle:t,collapsedThinkingPreviewSlots:n,onToggleThinkingPreview:r,onDismissThinkingPreview:o,widerActivityPreviews:i}){var Ce,je,He,ue,Fe,Oe,We,re,Te;const{t:a}=Z(),l=m.useRef(null),c=m.useRef(null),d=m.useRef(!1),u=m.useRef(null),[f,h]=m.useState(()=>Gi({active:e.active,hasFollowingConversationText:!!e.hasFollowingConversationText,endedAtMs:e.endedAtMs,nowMs:Date.now()})===0?"hidden":"visible"),g=m.useRef(((Ce=e.thinkingPreviews)==null?void 0:Ce.length)??0),[p,y]=m.useState(null),x=m.useCallback(()=>{d.current=!1,u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]);m.useEffect(()=>x,[x]);const b=A=>{if(x(),A.pointerType!=="touch")return;const U=A.currentTarget.getBoundingClientRect();d.current=A.clientX<U.left||A.clientX>=U.right||A.clientY<U.top||A.clientY>=U.bottom},_=()=>{d.current&&(u.current=window.setTimeout(x,0))},N=()=>{if(d.current){x();return}t==null||t(e.id)},v=m.useCallback(()=>{const A=c.current;A&&A.classList.toggle("is-clipped",A.scrollHeight-A.clientHeight>1)},[]),j=(je=e.thinkingPreviews)==null?void 0:je.map(A=>`${A.slot}:${n.has(A.slot)?"c":"o"}`).join("|");m.useLayoutEffect(()=>{const A=l.current;if(!A)return;const U=A.querySelector(lc);if(!U){A.style.removeProperty(Ln);return}const z=U.querySelector(co);if(!z){A.style.setProperty(Ln,"0px");return}let X=null;const xe=()=>{const B=$j(X,z.offsetHeight);X=B;const Q=`${B}px`;A.style.getPropertyValue(Ln)!==Q&&A.style.setProperty(Ln,Q),v()};xe();const L=new ResizeObserver(xe);return L.observe(z),()=>L.disconnect()},[j,v]);const C=m.useRef({reserve:null,timer:null}),w=m.useRef(null),k=m.useCallback(()=>{const A=l.current;if(!A)return;const U=Mv(A,w.current);cc(A,C.current,U)},[]),S=(((He=e.thinkingPreviews)==null?void 0:He.length)??0)>0;m.useLayoutEffect(()=>{const A=l.current;if(!A)return;const U=S?Pv(A):null;w.current=U,k();const z=new ResizeObserver(k);z.observe(A);for(const xe of Array.from(A.children))z.observe(xe);U&&z.observe(U);const X=C.current;return()=>{z.disconnect(),w.current=null,X.timer!==null&&(window.clearTimeout(X.timer),X.timer=null)}},[S,j,k]);const $=((ue=e.thinkingPreviews)==null?void 0:ue.length)??0,T=(e.thinkingPreviews??[]).filter(A=>n.has(A.slot)).map(A=>A.slot).join("|"),E=m.useRef(T),R=m.useRef($);m.useLayoutEffect(()=>{const A=new Set(E.current.split("|").filter(Boolean)),U=T.split("|").filter(Boolean).some(X=>!A.has(X)),z=$===0&&R.current>0;E.current=T,R.current=$,(U||z)&&(C.current.reserve=null,k())},[T,$,k]),m.useLayoutEffect(()=>{v()},[v,e.recentActivities]),m.useEffect(()=>{var z;const A=((z=e.thinkingPreviews)==null?void 0:z.length)??0,U=g.current;if(g.current=A,A===0){y(null);return}U===0&&(y(Date.now()),h("visible"))},[(Fe=e.thinkingPreviews)==null?void 0:Fe.length]),m.useEffect(()=>{const A=Gi({active:e.active,hasFollowingConversationText:!!e.hasFollowingConversationText,endedAtMs:e.endedAtMs,shownSinceMs:p,nowMs:Date.now()});if(A===null){h("visible");return}if(A===0){h(z=>z==="visible"?"hidden":z);return}h("visible");const U=window.setTimeout(()=>{h("fading")},A);return()=>window.clearTimeout(U)},[e.active,e.endedAtMs,e.hasFollowingConversationText,p]),m.useEffect(()=>{if(f!=="fading")return;const A=window.setTimeout(()=>{h("hidden")},Vi);return()=>window.clearTimeout(A)},[f]),m.useLayoutEffect(()=>{const A=l.current;if(f==="fading"&&A){const U=A.querySelector(".conversation-activity-summary"),z=A.offsetHeight;let X=z;if(U){const L=window.getComputedStyle(U);X=Math.ceil((Number.parseFloat(L.marginTop)||0)+U.offsetHeight+(Number.parseFloat(L.marginBottom)||0))}A.style.height=`${z}px`,C.current.reserve=null,A.style.removeProperty("--conversation-activity-reserved-height");const xe=window.requestAnimationFrame(()=>{A.style.height=`${Math.min(z,X)}px`});return()=>window.cancelAnimationFrame(xe)}A&&A.style.removeProperty("height"),f!=="visible"&&(C.current.reserve=null,k())},[f,k]);const D=e.startedAtMs!==null&&e.endedAtMs!==null&&e.endedAtMs>=e.startedAtMs?(e.endedAtMs-e.startedAtMs)/1e3:null,K=D===null?"":dc(D),V=a(e.activityCount===1?"conversationActivitySingular":"conversationActivityPlural"),G=e.expanded?"conversationActivityExpanded":"conversationActivityComplete",W=e.expanded?"conversationActivityExpandedWithoutTime":"conversationActivityCompleteWithoutTime",ie=K?a(e.active?"conversationActivityActive":G,{duration:K,count:e.activityCount,activity:V}):a(e.active?"conversationActivityActiveWithoutTime":W,{count:e.activityCount,activity:V}),ae=a(e.expanded?"conversationActivityCollapseTitle":"conversationActivityExpandTitle"),Pe=(Oe=e.tooltipActivities)==null?void 0:Oe.map(A=>A.detail).join(`
109
109
  `),se=yn(ae,Pe?{headline:ie,detail:`${Pe}${e.activityCount>(((We=e.tooltipActivities)==null?void 0:We.length)??0)?`
110
110
  …`:""}`}:void 0),Se=f!=="hidden",F=f==="fading",O=Se&&((re=e.thinkingPreviews)==null?void 0:re.some(A=>!n.has(A.slot)));return s.jsxs("div",{className:`conversation-activity-row ${Ie.activityHeightReserve}${i?" is-wide-activity-previews":""}${F?` ${Ie.thinkingRollingUp}`:""}`,ref:l,style:F?{"--conversation-thinking-rollup-ms":`${Vi}ms`}:void 0,children:[s.jsxs("div",{className:"conversation-activity-column",children:[s.jsxs("button",{type:"button",className:`conversation-activity-summary${e.active?" is-active":""}${e.expanded?" is-expanded":""}`,onClick:N,onPointerCancel:x,onPointerDown:b,onPointerUp:_,"aria-expanded":e.expanded,...se,children:[s.jsx("span",{className:`${Ie.activityChevron}${e.expanded?` ${Ie.activityChevronExpanded}`:""}`,"aria-hidden":"true",children:e.expanded?"▾":"▸"}),e.active?s.jsx("span",{className:Ie.activityPulse,"aria-hidden":"true"}):null,s.jsx("span",{className:Ie.activityLabel,children:ie})]}),O&&e.recentActivities?s.jsx("ul",{ref:c,className:`conversation-recent-activities${F?` ${Ie.thinkingAutoHiding}`:""}`,"aria-label":a("conversationRecentActivities"),children:e.recentActivities.map((A,U)=>s.jsx(Lv,{activity:A},`${A.label}-${U}`))}):null]}),Se?(Te=e.thinkingPreviews)==null?void 0:Te.map(A=>s.jsx(Fv,{autoHiding:F,collapsed:n.has(A.slot),turnEndedAtMs:e.endedAtMs,onDismiss:o,onToggle:r,preview:A},A.slot)):null]})}function Lv({activity:e}){const t=yn(e.detail);return s.jsxs("li",{...t,children:[s.jsx("span",{className:"conversation-recent-activity-name",children:e.label}),e.preview?s.jsx("span",{className:"conversation-recent-activity-preview",children:e.preview}):null]})}function na(e){let t=0;for(const n of e.replace(/\r\n?/g,`
111
111
  `).split(`
112
- `))t=Math.max(t,n.length);return t*8}function Av(e,t){if(e.status==="streaming"||e.endedAtMs===null||t===null)return"";const n=(t-e.endedAtMs)/1e3;return!Number.isFinite(n)||n<1?"":dc(n)}function Fv({preview:e,collapsed:t,autoHiding:n,onToggle:r,onDismiss:o,turnEndedAtMs:i}){const{t:a}=Z(),l=m.useRef(null),[c,d]=m.useState(null),u=a(e.kind==="current"?"conversationThinkingPreviewCurrent":e.kind==="latest"?"conversationThinkingPreviewLatest":"conversationThinkingPreviewPrevious"),f=a(t?"conversationThinkingPreviewExpand":"conversationThinkingPreviewCollapse"),h=a("conversationThinkingPreviewDismiss",{label:u}),g=Av(e,i),p=(c==null?void 0:c.id)===e.id?c.targetWidthPx:Sj;m.useLayoutEffect(()=>{var C;if(t)return;const x=(C=l.current)==null?void 0:C.querySelector(".thinking-text");if(!x)return;const b=x.style.display,_=x.style.width,N=x.style.maxWidth;x.style.display=x.classList.contains("thinking-outline")?"inline-grid":"inline-block",x.style.width="max-content",x.style.maxWidth="none";const v=x.getBoundingClientRect().width;x.style.display=b,x.style.width=_,x.style.maxWidth=N;const j=v>0?v:na(e.thinking);d(w=>Wi(w,e.id,j))},[t,e.id]),m.useLayoutEffect(()=>{t||d(x=>Wi(x,e.id,na(e.thinking)))},[t,e.id,e.thinking]);const{onScroll:y}=bj(l,e.thinking,{enabled:e.status==="streaming",identity:e.id});return s.jsxs("div",{className:`conversation-thinking-preview${e.status==="streaming"?" is-streaming":""}${t?" is-collapsed":""}${n?` ${Ie.thinkingAutoHiding}`:""}`,"data-preview-slot":e.slot,style:{"--conversation-thinking-preview-target-width":`${p}px`},children:[s.jsxs("div",{className:"conversation-thinking-preview-header",children:[s.jsxs("button",{type:"button",className:"conversation-thinking-preview-toggle","aria-expanded":!t,"aria-label":f,title:f,onClick:()=>r==null?void 0:r(e.slot),children:[s.jsx("span",{className:"conversation-thinking-preview-dot","aria-hidden":!0}),s.jsx("span",{className:Ie.thinkingPreviewLabel,children:u}),g?s.jsx("span",{className:Ie.thinkingPreviewAge,title:a("conversationThinkingPreviewAgeTitle",{duration:g}),children:a("conversationThinkingPreviewAge",{duration:g})}):null,s.jsx("span",{className:"conversation-thinking-preview-chevron","aria-hidden":!0,children:t?"▸":"▾"})]}),s.jsx("button",{type:"button",className:"conversation-thinking-preview-dismiss","aria-label":h,title:h,onClick:()=>o==null?void 0:o(e.slot),children:"×"})]}),t?null:s.jsx("div",{ref:l,className:"conversation-thinking-preview-content",onScroll:y,children:s.jsx(Ir,{text:e.thinking,isStreaming:e.status==="streaming"})})]})}const Bv=m.memo(function({item:t,isStreaming:n,thinkingExpanded:r,toggleThinkingExpanded:o,sessionProvider:i,onCorrectUserPrompt:a,onCancelUnconfirmedUserPrompt:l,onTrimBeforeUserPrompt:c,onForkBeforeUserPrompt:d,onForkAfterUserPrompt:u,onForkAfterSummaryUserPrompt:f,forkAfterUserPromptDisabled:h,forkUnavailableMessage:g,onQuoteTextBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x,staleNowMs:b,thinkingDurationMs:_,getForkSummaryTargetHref:N,onCancelForkSummary:v,onToggleForkSummaryAutoOpen:j,onFollowForkSummary:C,bangCommandHandlers:w,onToggleConversationActivity:k,widerConversationActivityPreviews:S=!1,collapsedConversationThinkingPreviewSlots:$=new Set,onToggleConversationThinkingPreview:T,onDismissConversationThinkingPreview:E}){var Se;const{t:R}=Z(),D=m.useRef(Date.now()),K=fs(t.sourceMessages),V=t.type!=="conversation_activity"&&K!==null,G=V&&b!==void 0,W=G?b??Date.now():D.current,ie=G&&W!==null&&W-K>=cd,ae=rt(t.type==="system"&&t.subtype==="away_summary"?t.content:""),Pe=m.useCallback(F=>{const O=window.getSelection();O&&O.toString().length>0||F.shiftKey&&!F.ctrlKey&&!F.metaKey&&(F.preventDefault(),F.stopPropagation(),console.log("[DEBUG] Render snapshot",kv(t,{isStreaming:n,thinkingExpanded:r,sessionProvider:i})))},[t,n,r,i]),se=()=>{switch(t.type){case"text":return s.jsx(Vd,{renderId:t.id,fallback:s.jsx(Qn,{text:t.text,isStreaming:t.isStreaming,abortedMidStream:t.abortedMidStream,augmentHtml:t.augmentHtml,projectPathLinks:t.projectPathLinks,renderItemId:t.id,onQuoteBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x})});case"thinking":return s.jsx(Wj,{thinking:t.thinking,status:t.status,isExpanded:r,onToggle:o,durationMs:_});case"tool_call":return s.jsx(zb,{id:t.id,toolName:t.toolName,toolInput:t.toolInput,toolResult:t.toolResult,workflow:t.workflow,status:t.status,sessionProvider:i,startTimestampMs:ya(t.sourceMessages),resultTimestampMs:t.sourceMessages.length>1?K:null});case"user_prompt":{const F=ad(t.sourceMessages),O=ld(t.sourceMessages);return s.jsx(al,{content:t.content,messageId:t.id,projectPathLinks:t.projectPathLinks,onCorrect:a,onCancelUnconfirmed:O&&l?()=>l(O):void 0,onTrimBefore:c,onForkBefore:d,onForkAfter:u,onForkAfterSummary:f,forkAfterDisabled:h,forkUnavailableMessage:g,deliveryState:F})}case"session_setup":return s.jsx(Dj,{title:t.title,prompts:t.prompts});case"transcript_display_object":{const F=t.object;return F.kind==="bang-command"?s.jsx(Zd,{object:F,handlers:w}):s.jsx(Fj,{object:F,targetHref:F.targetSessionId?N==null?void 0:N(F.targetSessionId):void 0,onCancel:()=>v==null?void 0:v(F.id),onToggleAutoOpen:O=>j==null?void 0:j(F.id,O),onFollow:()=>C==null?void 0:C(F.id)})}case"task_notification":return s.jsx(Uj,{item:t});case"conversation_activity":return s.jsx($v,{item:t,onToggle:k,collapsedThinkingPreviewSlots:$,onToggleThinkingPreview:T,onDismissThinkingPreview:E,widerActivityPreviews:S});case"system":{if(t.subtype==="rewound_group")return s.jsx(Cv,{item:t});if(t.subtype==="local_command"&&t.content==="/goal"){const[U="",...z]=(t.details??[]).map(ac);return s.jsx(Cu,{objective:U,status:z.join(`
113
- `)})}if(t.subtype==="away_summary")return s.jsxs("div",{className:"system-message-recap",children:[s.jsx("span",{className:"system-message-recap-mark",children:"※"}),s.jsx("span",{ref:ae,className:"system-message-recap-body",children:s.jsx(St,{text:t.content})})]});const F=t.subtype==="status"&&t.status==="compacting",O=t.subtype==="error",Ce=t.subtype==="warning",je=t.subtype==="informational",He=t.subtype==="config_ack",ue=t.subtype==="local_command",Fe=t.subtype==="tool_output",Oe=t.subtype==="subagent_activity",We=t.subtype==="no_model_turn",re=t.subtype==="history_search_gap",Te=He&&t.configChanged!==!1,A=O||Ce?"!":je?"i":He?"✓":ue?"/":Fe?"<":Oe?"↳":We?"∅":re?"⋯":"⟳";return t.subtype==="compact_boundary"||ue||Fe?s.jsx(Tv,{item:t,icon:A,label:Fe?t.content?R("toolOutputFrom",{tool:t.content}):R("toolOutput"):void 0}):s.jsxs("div",{className:`system-message ${F?"system-message-compacting":""} ${O?"system-message-error":""} ${Ce?"system-message-warning":""} ${Te?"system-message-config-ack":""} ${ue?"system-message-local-command":""}`,children:[hr(A,t.content)&&s.jsx("span",{className:`system-message-icon ${F?"spinning":""}`,children:hr(A,t.content)}),s.jsx("span",{className:"system-message-text",children:s.jsx(St,{text:t.content})})]})}default:return null}};return s.jsxs("div",{className:["message-render-row",V?"has-message-age":"",ie?"is-message-age-visible":"",t.isSubagent?"subagent-item":"",xn(t)&&!(t.type==="system"&&t.subtype==="rewound_group")?`subagent-item ${Ie.rewoundItem}`:""].filter(Boolean).join(" "),"data-render-type":t.type,"data-render-id":t.id,"data-rewound-group":t.type==="system"&&t.subtype==="rewound_group"?void 0:xn(t),onClick:Pe,children:[s.jsxs("div",{className:"message-render-content",children:[t.type==="tool_call"&&t.workflow?s.jsx(Zl,{workflow:t.workflow}):null,t.type==="text"&&((Se=t.workflow)!=null&&Se.markers.length)?s.jsx(wv,{text:t.text,workflow:t.workflow,isStreaming:t.isStreaming,original:se(),renderText:(F,O)=>s.jsx(Qn,{text:F,augmentHtml:O,projectPathLinks:t.projectPathLinks,renderItemId:t.id,onQuoteBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x})}):se(),(t.type==="tool_call"||t.type==="conversation_activity")&&s.jsx(Wd,{messages:t.sourceMessages})]}),s.jsx(Qd,{timestampMs:K,nowMs:W??Date.now()})]})});function uo({messages:e,isStreaming:t}){const{recentProjectPathLinksEnabled:n}=Kd(),[r,o]=m.useState(!1),i=m.useCallback(()=>{o(l=>!l)},[]),a=m.useMemo(()=>Fr(e,void 0,n),[e,n]);return s.jsx("div",{className:"task-nested-content",children:a.map(l=>s.jsx(Bv,{item:l,isStreaming:t,thinkingExpanded:r,toggleThinkingExpanded:i},l.id))})}function rs(){return s.jsx("svg",{className:"spinner",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:s.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"24",strokeDashoffset:"8"})})}const Dv="_headerRow_3ven4_1",Ov="_expandButton_3ven4_7",Uv="_openPage_3ven4_12",Hv="_rejection_3ven4_29",ct={headerRow:Dv,expandButton:Ov,openPage:Uv,rejection:Hv};function gr(e){return typeof e=="object"?e:null}function Wv(e,t){const n=e==null?void 0:e.replace(/\s+/g," ").trim();return n?n.length>140?`${n.slice(0,137)}...`:n:t}function xr(e,t){return Wv((t==null?void 0:t.nickname)??e.description??e.task??e.objective??e.message??e.prompt,"Codex subagent")}function sa(e){return e.agent_type??e.subagent_type??e.agent_role??e.role??"agent"}function Vv({isError:e,status:t,childStatus:n,hasAgentId:r}){return e||t!=="pending"&&!r?{className:"badge-error",text:"failed",isRunning:!1}:t==="aborted"?{className:"badge-warning",text:"interrupted",isRunning:!1}:t==="incomplete"?{className:"badge-warning",text:"result unavailable",isRunning:!1}:n==="failed"?{className:"badge-error",text:"failed",isRunning:!1}:n==="running"||!r&&t==="pending"?{className:"badge-running",text:"running",isRunning:!0}:n==="completed"?{className:"badge-success",text:"completed",isRunning:!1}:r?{className:"badge-success",text:"spawned",isRunning:!1}:{className:"badge-pending",text:"pending",isRunning:!1}}function yr(e){if(typeof e=="string")return e;if(e===void 0)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Gv({input:e,result:t,isError:n,status:r,toolUseId:o}){const{t:i}=Z(),a=Mr(),{projectId:l,sessionId:c}=gs(),d=m.useContext(so),u=gr(t),f=(u==null?void 0:u.agentId)??(o?d==null?void 0:d.toolUseToAgent.get(o):void 0),h=f?d==null?void 0:d.agentContent[f]:void 0,[g,p]=m.useState(!1),[y,x]=m.useState(!1),b=Vv({isError:n,status:r,childStatus:h==null?void 0:h.status,hasAgentId:!!f}),_=async()=>{const j=(h==null?void 0:h.messages)&&h.messages.length>0;if(!g&&f&&d&&!j){p(!0),x(!0);try{await d.loadAgentContent(l,c,f)}finally{x(!1)}return}p(C=>!C)},N=xr(e,u),v=r!=="pending"&&!f;return s.jsxs("div",{className:`task-inline ${g?"expanded":"collapsed"} status-${b.text}`,children:[s.jsxs("div",{className:ct.headerRow,children:[v?s.jsxs("div",{className:`task-inline-header noninteractive ${ct.expandButton}`,children:[s.jsx("span",{className:"task-expand-icon"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:sa(e)}),s.jsx("span",{className:"task-inline-title",children:N}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),s.jsx("span",{className:`badge ${b.className}`,children:b.text})]}):s.jsxs("button",{type:"button",className:`task-inline-header ${ct.expandButton}`,onClick:_,children:[s.jsx("span",{className:"task-expand-icon",children:g?"▼":"▶"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:sa(e)}),s.jsx("span",{className:"task-inline-title",children:N}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),b.isRunning?s.jsx("span",{className:"task-spinner",role:"status","aria-label":"Running",children:s.jsx(rs,{})}):s.jsx("span",{className:`badge ${b.className}`,children:b.text})]}),f&&s.jsx(vr,{className:ct.openPage,to:Ia(a,l,c,f),children:i("providerChildOpen")})]}),v&&yr(t)&&s.jsx("pre",{className:`tool-fallback tool-fallback-error ${ct.rejection}`,children:s.jsx("code",{children:yr(t)})}),y&&s.jsxs("div",{className:"task-loading",children:[s.jsx(rs,{})," Loading agent content..."]}),g&&s.jsx("div",{className:"task-inline-content",children:h!=null&&h.messages.length?s.jsx(uo,{messages:h.messages,isStreaming:h.status==="running"}):f?s.jsx("div",{className:"task-empty",children:"No content"}):s.jsx("div",{className:"task-empty",children:"No agent session found"})})]})}const zv=de(fe.spawn_agent,{tool:"spawn_agent",displayName:"Spawn agent",pendingDisplayName:"Spawning agent",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:xr(e,null)})},renderToolResult(e,t){const n=gr(e);return s.jsx("div",{className:t||!(n!=null&&n.agentId)?"todo-error":"todo-summary",children:n!=null&&n.agentId?`Agent ${n.agentId}`:yr(e)||"Failed to spawn agent"})},getUseSummary(e){return xr(e,null)},getResultSummary(e,t){if(t)return"Error";const n=gr(e);return n!=null&&n.agentId?`Agent ${n.agentId}`:"Failed"},renderInline(e,t,n,r,o){return s.jsx(Gv,{input:e,result:t,isError:n,status:r,toolUseId:o.toolUseId})}}),ra=20;function oa({status:e}){const n={running:{icon:"⟳",className:"status-running"},completed:{icon:"✓",className:"status-completed"},failed:{icon:"✗",className:"status-failed"},timeout:{icon:"⏱",className:"status-timeout"}}[e]||{icon:"?",className:""};return s.jsxs("span",{className:`taskoutput-status ${n.className}`,children:[n.icon," ",e]})}function qv({input:e}){return s.jsxs("div",{className:"taskoutput-tool-use",children:[s.jsx("span",{className:"taskoutput-label",children:"Polling task"}),s.jsx("code",{className:"taskoutput-id",children:e.task_id}),e.block!==void 0&&s.jsx("span",{className:"badge",children:e.block?"blocking":"non-blocking"}),e.timeout!==void 0&&s.jsxs("span",{className:"badge",children:["timeout: ",e.timeout,"ms"]})]})}function Kv({result:e}){var g;const[t,n]=m.useState(!1),{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&e){const p=we("TaskOutput",e);!p.valid&&p.errors?(l(p.errors),o("TaskOutput",p.errors)):l(null)}},[r,e,o]);const c=r&&a&&!i("TaskOutput");if(!e)return s.jsx("div",{className:"taskoutput-empty",children:"No output"});const d=e.task,u=((g=d==null?void 0:d.output)==null?void 0:g.split(`
112
+ `))t=Math.max(t,n.length);return t*8}function Av(e,t){if(e.status==="streaming"||e.endedAtMs===null||t===null)return"";const n=(t-e.endedAtMs)/1e3;return!Number.isFinite(n)||n<1?"":dc(n)}function Fv({preview:e,collapsed:t,autoHiding:n,onToggle:r,onDismiss:o,turnEndedAtMs:i}){const{t:a}=Z(),l=m.useRef(null),[c,d]=m.useState(null),u=a(e.kind==="current"?"conversationThinkingPreviewCurrent":e.kind==="latest"?"conversationThinkingPreviewLatest":"conversationThinkingPreviewPrevious"),f=a(t?"conversationThinkingPreviewExpand":"conversationThinkingPreviewCollapse"),h=a("conversationThinkingPreviewDismiss",{label:u}),g=Av(e,i),p=(c==null?void 0:c.id)===e.id?c.targetWidthPx:Sj;m.useLayoutEffect(()=>{var C;if(t)return;const x=(C=l.current)==null?void 0:C.querySelector(".thinking-text");if(!x)return;const b=x.style.display,_=x.style.width,N=x.style.maxWidth;x.style.display=x.classList.contains("thinking-outline")?"inline-grid":"inline-block",x.style.width="max-content",x.style.maxWidth="none";const v=x.getBoundingClientRect().width;x.style.display=b,x.style.width=_,x.style.maxWidth=N;const j=v>0?v:na(e.thinking);d(w=>Wi(w,e.id,j))},[t,e.id]),m.useLayoutEffect(()=>{t||d(x=>Wi(x,e.id,na(e.thinking)))},[t,e.id,e.thinking]);const{onScroll:y}=bj(l,e.thinking,{enabled:e.status==="streaming",identity:e.id});return s.jsxs("div",{className:`conversation-thinking-preview${e.status==="streaming"?" is-streaming":""}${t?" is-collapsed":""}${n?` ${Ie.thinkingAutoHiding}`:""}`,"data-preview-slot":e.slot,style:{"--conversation-thinking-preview-target-width":`${p}px`},children:[s.jsxs("div",{className:"conversation-thinking-preview-header",children:[s.jsxs("button",{type:"button",className:"conversation-thinking-preview-toggle","aria-expanded":!t,"aria-label":f,title:f,onClick:()=>r==null?void 0:r(e.slot),children:[s.jsx("span",{className:"conversation-thinking-preview-dot","aria-hidden":!0}),s.jsx("span",{className:Ie.thinkingPreviewLabel,children:u}),g?s.jsx("span",{className:Ie.thinkingPreviewAge,title:a("conversationThinkingPreviewAgeTitle",{duration:g}),children:a("conversationThinkingPreviewAge",{duration:g})}):null,s.jsx("span",{className:"conversation-thinking-preview-chevron","aria-hidden":!0,children:t?"▸":"▾"})]}),s.jsx("button",{type:"button",className:"conversation-thinking-preview-dismiss","aria-label":h,title:h,onClick:()=>o==null?void 0:o(e.slot),children:"×"})]}),t?null:s.jsx("div",{ref:l,className:"conversation-thinking-preview-content",onScroll:y,children:s.jsx(Cr,{text:e.thinking,isStreaming:e.status==="streaming"})})]})}const Bv=m.memo(function({item:t,isStreaming:n,thinkingExpanded:r,toggleThinkingExpanded:o,sessionProvider:i,onCorrectUserPrompt:a,onCancelUnconfirmedUserPrompt:l,onTrimBeforeUserPrompt:c,onForkBeforeUserPrompt:d,onForkAfterUserPrompt:u,onForkAfterSummaryUserPrompt:f,forkAfterUserPromptDisabled:h,forkUnavailableMessage:g,onQuoteTextBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x,staleNowMs:b,thinkingDurationMs:_,getForkSummaryTargetHref:N,onCancelForkSummary:v,onToggleForkSummaryAutoOpen:j,onFollowForkSummary:C,bangCommandHandlers:w,onToggleConversationActivity:k,widerConversationActivityPreviews:S=!1,collapsedConversationThinkingPreviewSlots:$=new Set,onToggleConversationThinkingPreview:T,onDismissConversationThinkingPreview:E}){var Se;const{t:R}=Z(),D=m.useRef(Date.now()),K=fs(t.sourceMessages),V=t.type!=="conversation_activity"&&K!==null,G=V&&b!==void 0,W=G?b??Date.now():D.current,ie=G&&W!==null&&W-K>=cd,ae=st(t.type==="system"&&t.subtype==="away_summary"?t.content:""),Pe=m.useCallback(F=>{const O=window.getSelection();O&&O.toString().length>0||F.shiftKey&&!F.ctrlKey&&!F.metaKey&&(F.preventDefault(),F.stopPropagation(),console.log("[DEBUG] Render snapshot",kv(t,{isStreaming:n,thinkingExpanded:r,sessionProvider:i})))},[t,n,r,i]),se=()=>{switch(t.type){case"text":return s.jsx(Xd,{renderId:t.id,fallback:s.jsx(Qn,{text:t.text,isStreaming:t.isStreaming,abortedMidStream:t.abortedMidStream,augmentHtml:t.augmentHtml,projectPathLinks:t.projectPathLinks,renderItemId:t.id,onQuoteBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x})});case"thinking":return s.jsx(Wj,{thinking:t.thinking,status:t.status,isExpanded:r,onToggle:o,durationMs:_});case"tool_call":return s.jsx(zb,{id:t.id,toolName:t.toolName,toolInput:t.toolInput,toolResult:t.toolResult,workflow:t.workflow,status:t.status,sessionProvider:i,startTimestampMs:ya(t.sourceMessages),resultTimestampMs:t.sourceMessages.length>1?K:null});case"user_prompt":{const F=ad(t.sourceMessages),O=ld(t.sourceMessages);return s.jsx(al,{content:t.content,messageId:t.id,projectPathLinks:t.projectPathLinks,onCorrect:a,onCancelUnconfirmed:O&&l?()=>l(O):void 0,onTrimBefore:c,onForkBefore:d,onForkAfter:u,onForkAfterSummary:f,forkAfterDisabled:h,forkUnavailableMessage:g,deliveryState:F})}case"session_setup":return s.jsx(Dj,{title:t.title,prompts:t.prompts});case"transcript_display_object":{const F=t.object;return F.kind==="bang-command"?s.jsx(Qd,{object:F,handlers:w}):s.jsx(Fj,{object:F,targetHref:F.targetSessionId?N==null?void 0:N(F.targetSessionId):void 0,onCancel:()=>v==null?void 0:v(F.id),onToggleAutoOpen:O=>j==null?void 0:j(F.id,O),onFollow:()=>C==null?void 0:C(F.id)})}case"task_notification":return s.jsx(Uj,{item:t});case"conversation_activity":return s.jsx($v,{item:t,onToggle:k,collapsedThinkingPreviewSlots:$,onToggleThinkingPreview:T,onDismissThinkingPreview:E,widerActivityPreviews:S});case"system":{if(t.subtype==="rewound_group")return s.jsx(Cv,{item:t});if(t.subtype==="local_command"&&t.content==="/goal"){const[U="",...z]=(t.details??[]).map(ac);return s.jsx(Cu,{objective:U,status:z.join(`
113
+ `)})}if(t.subtype==="away_summary")return s.jsxs("div",{className:"system-message-recap",children:[s.jsx("span",{className:"system-message-recap-mark",children:"※"}),s.jsx("span",{ref:ae,className:"system-message-recap-body",children:s.jsx(St,{text:t.content})})]});const F=t.subtype==="status"&&t.status==="compacting",O=t.subtype==="error",Ce=t.subtype==="warning",je=t.subtype==="informational",He=t.subtype==="config_ack",ue=t.subtype==="local_command",Fe=t.subtype==="tool_output",Oe=t.subtype==="subagent_activity",We=t.subtype==="no_model_turn",re=t.subtype==="history_search_gap",Te=He&&t.configChanged!==!1,A=O||Ce?"!":je?"i":He?"✓":ue?"/":Fe?"<":Oe?"↳":We?"∅":re?"⋯":"⟳";return t.subtype==="compact_boundary"||ue||Fe?s.jsx(Tv,{item:t,icon:A,label:Fe?t.content?R("toolOutputFrom",{tool:t.content}):R("toolOutput"):void 0}):s.jsxs("div",{className:`system-message ${F?"system-message-compacting":""} ${O?"system-message-error":""} ${Ce?"system-message-warning":""} ${Te?"system-message-config-ack":""} ${ue?"system-message-local-command":""}`,children:[hr(A,t.content)&&s.jsx("span",{className:`system-message-icon ${F?"spinning":""}`,children:hr(A,t.content)}),s.jsx("span",{className:"system-message-text",children:s.jsx(St,{text:t.content})})]})}default:return null}};return s.jsxs("div",{className:["message-render-row",V?"has-message-age":"",ie?"is-message-age-visible":"",t.isSubagent?"subagent-item":"",xn(t)&&!(t.type==="system"&&t.subtype==="rewound_group")?`subagent-item ${Ie.rewoundItem}`:""].filter(Boolean).join(" "),"data-render-type":t.type,"data-render-id":t.id,"data-rewound-group":t.type==="system"&&t.subtype==="rewound_group"?void 0:xn(t),onClick:Pe,children:[s.jsxs("div",{className:"message-render-content",children:[t.type==="tool_call"&&t.workflow?s.jsx(Zl,{workflow:t.workflow}):null,t.type==="text"&&((Se=t.workflow)!=null&&Se.markers.length)?s.jsx(wv,{text:t.text,workflow:t.workflow,isStreaming:t.isStreaming,original:se(),renderText:(F,O)=>s.jsx(Qn,{text:F,augmentHtml:O,projectPathLinks:t.projectPathLinks,renderItemId:t.id,onQuoteBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x})}):se(),(t.type==="tool_call"||t.type==="conversation_activity")&&s.jsx(yd,{messages:t.sourceMessages})]}),s.jsx(Jd,{timestampMs:K,nowMs:W??Date.now()})]})});function uo({messages:e,isStreaming:t}){const{recentProjectPathLinksEnabled:n}=wd(),[r,o]=m.useState(!1),i=m.useCallback(()=>{o(l=>!l)},[]),a=m.useMemo(()=>Fr(e,void 0,n),[e,n]);return s.jsx("div",{className:"task-nested-content",children:a.map(l=>s.jsx(Bv,{item:l,isStreaming:t,thinkingExpanded:r,toggleThinkingExpanded:i},l.id))})}function rs(){return s.jsx("svg",{className:"spinner",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:s.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"24",strokeDashoffset:"8"})})}const Dv="_headerRow_3ven4_1",Ov="_expandButton_3ven4_7",Uv="_openPage_3ven4_12",Hv="_rejection_3ven4_29",ct={headerRow:Dv,expandButton:Ov,openPage:Uv,rejection:Hv};function gr(e){return typeof e=="object"?e:null}function Wv(e,t){const n=e==null?void 0:e.replace(/\s+/g," ").trim();return n?n.length>140?`${n.slice(0,137)}...`:n:t}function xr(e,t){return Wv((t==null?void 0:t.nickname)??e.description??e.task??e.objective??e.message??e.prompt,"Codex subagent")}function sa(e){return e.agent_type??e.subagent_type??e.agent_role??e.role??"agent"}function Vv({isError:e,status:t,childStatus:n,hasAgentId:r}){return e||t!=="pending"&&!r?{className:"badge-error",text:"failed",isRunning:!1}:t==="aborted"?{className:"badge-warning",text:"interrupted",isRunning:!1}:t==="incomplete"?{className:"badge-warning",text:"result unavailable",isRunning:!1}:n==="failed"?{className:"badge-error",text:"failed",isRunning:!1}:n==="running"||!r&&t==="pending"?{className:"badge-running",text:"running",isRunning:!0}:n==="completed"?{className:"badge-success",text:"completed",isRunning:!1}:r?{className:"badge-success",text:"spawned",isRunning:!1}:{className:"badge-pending",text:"pending",isRunning:!1}}function yr(e){if(typeof e=="string")return e;if(e===void 0)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Gv({input:e,result:t,isError:n,status:r,toolUseId:o}){const{t:i}=Z(),a=Mr(),{projectId:l,sessionId:c}=gs(),d=m.useContext(so),u=gr(t),f=(u==null?void 0:u.agentId)??(o?d==null?void 0:d.toolUseToAgent.get(o):void 0),h=f?d==null?void 0:d.agentContent[f]:void 0,[g,p]=m.useState(!1),[y,x]=m.useState(!1),b=Vv({isError:n,status:r,childStatus:h==null?void 0:h.status,hasAgentId:!!f}),_=async()=>{const j=(h==null?void 0:h.messages)&&h.messages.length>0;if(!g&&f&&d&&!j){p(!0),x(!0);try{await d.loadAgentContent(l,c,f)}finally{x(!1)}return}p(C=>!C)},N=xr(e,u),v=r!=="pending"&&!f;return s.jsxs("div",{className:`task-inline ${g?"expanded":"collapsed"} status-${b.text}`,children:[s.jsxs("div",{className:ct.headerRow,children:[v?s.jsxs("div",{className:`task-inline-header noninteractive ${ct.expandButton}`,children:[s.jsx("span",{className:"task-expand-icon"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:sa(e)}),s.jsx("span",{className:"task-inline-title",children:N}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),s.jsx("span",{className:`badge ${b.className}`,children:b.text})]}):s.jsxs("button",{type:"button",className:`task-inline-header ${ct.expandButton}`,onClick:_,children:[s.jsx("span",{className:"task-expand-icon",children:g?"▼":"▶"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:sa(e)}),s.jsx("span",{className:"task-inline-title",children:N}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),b.isRunning?s.jsx("span",{className:"task-spinner",role:"status","aria-label":"Running",children:s.jsx(rs,{})}):s.jsx("span",{className:`badge ${b.className}`,children:b.text})]}),f&&s.jsx(vr,{className:ct.openPage,to:Ia(a,l,c,f),children:i("providerChildOpen")})]}),v&&yr(t)&&s.jsx("pre",{className:`tool-fallback tool-fallback-error ${ct.rejection}`,children:s.jsx("code",{children:yr(t)})}),y&&s.jsxs("div",{className:"task-loading",children:[s.jsx(rs,{})," Loading agent content..."]}),g&&s.jsx("div",{className:"task-inline-content",children:h!=null&&h.messages.length?s.jsx(uo,{messages:h.messages,isStreaming:h.status==="running"}):f?s.jsx("div",{className:"task-empty",children:"No content"}):s.jsx("div",{className:"task-empty",children:"No agent session found"})})]})}const zv=de(fe.spawn_agent,{tool:"spawn_agent",displayName:"Spawn agent",pendingDisplayName:"Spawning agent",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:xr(e,null)})},renderToolResult(e,t){const n=gr(e);return s.jsx("div",{className:t||!(n!=null&&n.agentId)?"todo-error":"todo-summary",children:n!=null&&n.agentId?`Agent ${n.agentId}`:yr(e)||"Failed to spawn agent"})},getUseSummary(e){return xr(e,null)},getResultSummary(e,t){if(t)return"Error";const n=gr(e);return n!=null&&n.agentId?`Agent ${n.agentId}`:"Failed"},renderInline(e,t,n,r,o){return s.jsx(Gv,{input:e,result:t,isError:n,status:r,toolUseId:o.toolUseId})}}),ra=20;function oa({status:e}){const n={running:{icon:"⟳",className:"status-running"},completed:{icon:"✓",className:"status-completed"},failed:{icon:"✗",className:"status-failed"},timeout:{icon:"⏱",className:"status-timeout"}}[e]||{icon:"?",className:""};return s.jsxs("span",{className:`taskoutput-status ${n.className}`,children:[n.icon," ",e]})}function qv({input:e}){return s.jsxs("div",{className:"taskoutput-tool-use",children:[s.jsx("span",{className:"taskoutput-label",children:"Polling task"}),s.jsx("code",{className:"taskoutput-id",children:e.task_id}),e.block!==void 0&&s.jsx("span",{className:"badge",children:e.block?"blocking":"non-blocking"}),e.timeout!==void 0&&s.jsxs("span",{className:"badge",children:["timeout: ",e.timeout,"ms"]})]})}function Kv({result:e}){var g;const[t,n]=m.useState(!1),{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&e){const p=we("TaskOutput",e);!p.valid&&p.errors?(l(p.errors),o("TaskOutput",p.errors)):l(null)}},[r,e,o]);const c=r&&a&&!i("TaskOutput");if(!e)return s.jsx("div",{className:"taskoutput-empty",children:"No output"});const d=e.task,u=((g=d==null?void 0:d.output)==null?void 0:g.split(`
114
114
  `))||[],f=u.length>ra,h=f&&!t?u.slice(0,ra):u;return s.jsxs("div",{className:"taskoutput-result",children:[s.jsxs("div",{className:"taskoutput-header",children:[s.jsx(oa,{status:e.retrieval_status}),(d==null?void 0:d.task_type)&&s.jsx("span",{className:"badge badge-info",children:d.task_type}),(d==null?void 0:d.description)&&s.jsx("span",{className:"taskoutput-desc",children:d.description}),c&&a&&s.jsx(q,{toolName:"TaskOutput",errors:a})]}),d&&s.jsxs("div",{className:"taskoutput-task",children:[s.jsxs("div",{className:"taskoutput-task-status",children:[d.status&&s.jsx(oa,{status:d.status}),d.exitCode!=null&&s.jsxs("span",{className:`badge ${d.exitCode===0?"badge-success":"badge-error"}`,children:["exit ",d.exitCode]})]}),d.output&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"taskoutput-content code-block",children:s.jsx("code",{children:h.join(`
115
- `)})}),f&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${u.length} lines`})]})]})]})}const Xv=de(fe.TaskOutput,{tool:"TaskOutput",renderToolUse(e,t){return s.jsx(qv,{input:e})},renderToolResult(e,t,n){return s.jsx(Kv,{result:e})},renderFailure(e){return s.jsx("div",{className:"taskoutput-error",children:e.content||"Failed to get task output"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.task_id},getResultSummary(e){const t=e;return t?t.retrieval_status:"Pending"}});function uc(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function un(e,t){if(!uc(e))return;const n=e[t];return typeof n=="string"&&n.trim()?n.trim():void 0}function os(e){return typeof e=="object"&&e!==null?e._taskSnapshot:void 0}function Yv(e){return un(e,"taskId")??un(e,"task_id")??un(e,"id")}function mo(e){if(typeof e!="string")return"unknown";const t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");return t==="completed"||t==="complete"?"completed":t==="in_progress"||t==="running"?"in_progress":t==="pending"||t==="todo"?"pending":t==="failed"||t==="error"?"failed":t==="cancelled"||t==="canceled"?"cancelled":"unknown"}function Jv(e){switch(e){case"completed":return"✓";case"in_progress":return"◐";case"failed":return"!";case"cancelled":return"×";default:return"○"}}function Qv(e){return e==="in_progress"?"todo-status-in-progress":`todo-status-${e}`}function Zv(e){var t;return(t=e.subject)!=null&&t.trim()?e.subject.trim():e.id?`Task #${e.id}`:"Task"}function mc(e){return e.filter(t=>mo(t.status)==="completed").length}function ew({snapshot:e}){const t=e.tasks,n=mc(t);return s.jsxs("div",{className:"todo-result",children:[s.jsxs("div",{className:"todo-summary",children:[n," out of ",t.length," tasks completed"]}),s.jsx("div",{className:"todo-list",children:t.map(r=>{const o=mo(r.status),i=o==="completed",a=Zv(r);return s.jsxs("div",{className:`todo-item ${Qv(o)}`,children:[s.jsx("span",{className:"todo-checkbox",children:Jv(o)}),s.jsx("span",{className:`todo-content ${i?"todo-completed":""}`,children:a})]},r.id||a)})})]})}function _s(e,t){if(e==="TaskCreate")return un(t,"subject")??"Task created";const n=Yv(t),r=mo(un(t,"status")),o=r==="unknown"?"updated":r.replace("_"," ");return n?`Task #${n} ${o}`:`Task ${o}`}function tw(e){if(typeof e=="string")return e.trim()||void 0;if(!uc(e))return;const t=e.content;return typeof t=="string"&&t.trim()?t.trim():void 0}function is(e,t,n,r){const o=os(n)??os(t);return!r&&o&&o.tasks.length>0?s.jsx(ew,{snapshot:o}):r?s.jsx("div",{className:"todo-error",children:tw(n)??"Task update failed"}):s.jsx("div",{className:"todo-summary",children:_s(e,t)})}function as(e,t,n){const r=os(n)??os(t);return r!=null&&r.tasks.length?`${mc(r.tasks)}/${r.tasks.length} complete`:_s(e,t)}const nw=de(fe.TaskCreate,{tool:"TaskCreate",displayName:"Create task",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:_s("TaskCreate",e)})},renderToolResult(e,t,n,r){return is("TaskCreate",r,e,t)},renderInline(e,t,n){return is("TaskCreate",e,t,n)},getUseSummary(e){return as("TaskCreate",e)},getResultSummary(e,t,n){return t?"Error":as("TaskCreate",n,e)}}),sw=de(fe.TaskUpdate,{tool:"TaskUpdate",displayName:"Update task",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:_s("TaskUpdate",e)})},renderToolResult(e,t,n,r){return is("TaskUpdate",r,e,t)},renderInline(e,t,n){return is("TaskUpdate",e,t,n)},getUseSummary(e){return as("TaskUpdate",e)},getResultSummary(e,t,n){return t?"Error":as("TaskUpdate",n,e)}});function rw({block:e}){return s.jsxs("div",{className:"fallback-block",children:[s.jsx("div",{className:"fallback-type",children:e.type}),s.jsx("pre",{className:"fallback-content",children:s.jsx("code",{children:JSON.stringify(e,null,2)})})]})}const ow={type:[],render(e,t){return s.jsx(rw,{block:e,context:t})}};function iw({block:e}){const t=Ra(e._renderedHtml??""),{modal:n,localFileModal:r,projectFileModal:o,handleClick:i,handleContextMenu:a,closeModal:l,closeLocalFileModal:c,closeProjectFileModal:d,contextMenuElement:u}=Na();return e._renderedHtml?s.jsxs("div",{className:"text-block",onClick:i,onContextMenu:a,children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:t}}),n&&s.jsx(qt,{path:n.path,mediaType:n.mediaType,onClose:l}),r&&s.jsx(Sa,{resource:r.resource,initialPresentation:r.initialPresentation,onClose:c}),o&&s.jsx(Ca,{projectId:o.projectId,filePath:o.filePath,lineNumber:o.lineNumber,lineEnd:o.lineEnd,initialPresentation:o.initialPresentation,onClose:d}),u]}):s.jsx("div",{className:"text-block",children:s.jsx("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"inherit"},children:e.text})})}const aw={type:"text",render(e,t){return s.jsx(iw,{block:e})},getSummary(e){const t=e.text;return t.length>100?`${t.slice(0,97)}...`:t}};function fc(e){var n;if(typeof e.thinking=="string")return e.thinking;const t=(n=e.summary)==null?void 0:n.map(r=>typeof r=="string"?r:r.text).filter(r=>typeof r=="string").join(`
116
- `).trim();return t||(typeof e.text=="string"?e.text:"")}function lw({block:e,context:t}){const[n,r]=m.useState(!1),o=fc(e),i=t.thinkingExpanded??n,a=t.toggleThinkingExpanded??(()=>r(c=>!c));if(i)return s.jsxs("div",{className:"thinking-block thinking-block-expanded",children:[s.jsxs("button",{type:"button",className:"thinking-toggle-expanded",onClick:a,"aria-expanded":!0,children:[s.jsx("span",{className:"thinking-label",children:"Thinking"}),s.jsx("span",{className:"thinking-icon",children:"▲"})]}),s.jsx("div",{className:"thinking-content",children:s.jsx(Ir,{text:o,isStreaming:t.isStreaming})})]});const l=t.isStreaming?"thinking-block thinking-streaming-collapsed":"thinking-block";return s.jsx("div",{className:l,children:s.jsxs("button",{type:"button",className:"thinking-toggle-collapsed",onClick:a,"aria-expanded":!1,children:[s.jsx("span",{className:"thinking-label",children:t.isStreaming?"Thinking...":"Thinking"}),s.jsx("span",{className:"thinking-icon",children:"▼"})]})})}const cw={type:["thinking","reasoning","reasoning_text","summary_text"],render(e,t){return s.jsx(lw,{block:e,context:t})},getSummary(e){const n=fc(e).split(`
117
- `)[0]||"";return n.length>80?`${n.slice(0,77)}...`:n}};function dw({block:e,context:t}){var a;const n=(a=t.getToolUse)==null?void 0:a.call(t,e.tool_use_id),r=(n==null?void 0:n.name)||"Unknown",o=e.is_error===!0;let i=t.toolUseResult;if(!i&&e.content)try{i=JSON.parse(e.content)}catch{i={content:e.content}}return s.jsxs("div",{className:`tool-block tool-result ${o?"tool-error":""}`,children:[s.jsxs("div",{className:"tool-header",children:[s.jsx("span",{className:"tool-icon",children:"<"}),s.jsx("span",{className:"tool-name",children:r}),o&&s.jsx("span",{className:"badge badge-error",children:"Error"})]}),s.jsx("div",{className:"tool-content",children:ze.renderToolResult(r,i,o,t,n==null?void 0:n.input)})]})}const uw={type:"tool_result",render(e,t){return s.jsx(dw,{block:e,context:t})},getSummary(e){return e.is_error?"Error":"Result"}};function mw({block:e,context:t}){return s.jsxs("div",{className:"tool-block tool-use",children:[s.jsxs("div",{className:"tool-header",children:[s.jsx("span",{className:"tool-icon",children:">"}),s.jsx("span",{className:"tool-name",children:e.name})]}),s.jsx("div",{className:"tool-content",children:ze.renderToolUse(e.name,e.input,t)})]})}const fw={type:"tool_use",render(e,t){return s.jsx(mw,{block:e,context:t})},getSummary(e){const t=e;return ze.prepare(t.name,{input:t.input,status:"pending"}).getUseSummary()||t.name}};class hw{constructor(t){be(this,"renderers",new Map);be(this,"fallback");this.fallback=t}register(t){const n=Array.isArray(t.type)?t.type:[t.type];for(const r of n)this.renderers.set(r,t)}getRenderer(t){return this.renderers.get(t.type)||this.fallback}render(t,n){return this.getRenderer(t).render(t,n)}}const vn=new hw(ow);vn.register(aw);vn.register(cw);vn.register(fw);vn.register(uw);const hc=m.memo(function({block:t,context:n}){return s.jsx(s.Fragment,{children:vn.render(t,n)})}),ia=200,aa=80;function pc(e){var o,i;const t=((i=(o=e==null?void 0:e.content)==null?void 0:o.find(a=>a.type==="text"&&a.text))==null?void 0:i.text)??"";if(!t)return null;const n=vs(t),r=n.cleanedMessage.length>aa?`${n.cleanedMessage.slice(0,aa)}...`:n.cleanedMessage;return{raw:t,summary:r,label:n.label}}function gc(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function pw({input:e}){const[t,n]=m.useState(!1),r=e.prompt.length>ia?`${e.prompt.slice(0,ia)}...`:e.prompt;return s.jsxs("div",{className:"task-tool-use",children:[s.jsxs("div",{className:"task-header",children:[s.jsx("span",{className:"task-description",children:e.description}),s.jsx("span",{className:"badge badge-info",children:e.subagent_type}),e.model&&s.jsx("span",{className:"badge",children:e.model})]}),e.prompt&&s.jsxs("div",{className:"task-prompt",children:[s.jsx("button",{type:"button",className:"task-prompt-toggle",onClick:()=>n(!t),children:t?"Hide prompt":"Show prompt"}),t&&s.jsx("pre",{className:"task-prompt-content",children:s.jsx("code",{children:t?e.prompt:r})})]})]})}function gw({input:e,result:t,isError:n,status:r,toolUseId:o}){var Se;const{t:i}=Z(),a=Mr(),{projectId:l,projectPath:c,sessionId:d}=gs(),u=m.useContext(so),{reportValidationError:f,enabled:h,isToolIgnored:g}=ve(),p=(t==null?void 0:t.agentId)??(o?u==null?void 0:u.toolUseToAgent.get(o):void 0),y=p?u==null?void 0:u.agentContent[p]:void 0,b=!((t==null?void 0:t.status)==="completed"||(t==null?void 0:t.status)==="failed")&&r==="pending"&&((y==null?void 0:y.status)==="running"||!(y!=null&&y.status)),[_,N]=m.useState(!1),[v,j]=m.useState(!1),[C,w]=m.useState(!1),k=m.useCallback(()=>{w(F=>!F)},[]),S=m.useRef(null),$=m.useRef(!0),T=m.useRef(!1),E=m.useRef(0),R=m.useCallback(F=>{T.current=!0,F.scrollTop=F.scrollHeight-F.clientHeight,E.current=F.scrollHeight,requestAnimationFrame(()=>{T.current=!1})},[]),D=m.useCallback(()=>{if(T.current)return;const F=S.current;if(!F)return;const O=100,Ce=F.scrollHeight-F.scrollTop-F.clientHeight;$.current=Ce<O},[]);m.useEffect(()=>{const F=S.current;if(!(!F||!_))return F.addEventListener("scroll",D),()=>{F.removeEventListener("scroll",D)}},[D,_]),m.useEffect(()=>{const F=S.current;if(!F||!_||!b)return;E.current=F.scrollHeight;const O=new ResizeObserver(()=>{const Ce=F.scrollHeight;Ce>E.current&&$.current?R(F):E.current=Ce});for(const Ce of F.children)O.observe(Ce);return O.observe(F),()=>{O.disconnect()}},[_,b,R]),m.useEffect(()=>{if(_&&b){$.current=!0;const F=S.current;F&&requestAnimationFrame(()=>{R(F)})}},[_,b,R]);const K=m.useRef(!1);m.useEffect(()=>{if(!_||!p||!u||K.current)return;K.current=!0,(async()=>{j(!0);try{await u.loadAgentContent(l,d,p)}finally{j(!1)}})()},[_,p,u,l,d]);const[V,G]=m.useState(null);m.useEffect(()=>{if(!t||!h){G(null);return}const F=we("Task",t);!F.valid&&F.errors?(G(F.errors),f("Task",F.errors)):G(null)},[t,h,f]);const W=h&&V!==null&&!g("Task"),ie=async()=>{const F=(y==null?void 0:y.messages)&&y.messages.length>0;if(!_&&p&&u&&!F){N(!0),j(!0);try{await u.loadAgentContent(l,d,p)}finally{j(!1)}}else N(!_)},ae=n?pc(t):null,se=n?{class:"badge-error",text:(ae==null?void 0:ae.label)??"failed"}:r==="aborted"?{class:"badge-warning",text:"interrupted"}:r==="incomplete"?{class:"badge-warning",text:"result unavailable"}:b?{class:"badge-running",text:"running"}:(t==null?void 0:t.status)==="completed"?{class:"badge-success",text:"completed"}:(t==null?void 0:t.status)==="failed"?{class:"badge-error",text:"failed"}:{class:"badge-pending",text:"pending"};return s.jsxs("div",{className:`task-inline ${_?"expanded":"collapsed"} status-${se.text}`,children:[s.jsxs("div",{className:ct.headerRow,children:[s.jsxs("button",{type:"button",className:`task-inline-header ${ct.expandButton}`,onClick:ie,children:[s.jsx("span",{className:"task-expand-icon",children:_?"▼":"▶"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:e.subagent_type}),s.jsx("span",{className:"task-inline-title",children:e.description}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),b&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"task-spinner",role:"status","aria-label":"Running",children:s.jsx(rs,{})}),(y==null?void 0:y.contextUsage)&&s.jsxs("span",{className:"task-context-usage",children:[y.contextUsage.percentage.toFixed(0),"% context"]})]}),!b&&s.jsx("span",{className:`badge ${se.class}`,children:se.text}),!_&&ae&&s.jsx("span",{className:"task-error-summary",title:ae.raw,children:ae.summary}),t&&!n&&s.jsxs("span",{className:"task-stats",children:[gc(t.totalDurationMs??0)," ·"," ",(t.totalTokens??0).toLocaleString()," tokens"]}),W&&V&&s.jsx(q,{toolName:"Task",errors:V})]}),p&&s.jsx(vr,{className:ct.openPage,to:Ia(a,l,d,p),children:i("providerChildOpen")})]}),v&&s.jsxs("div",{className:"task-loading",children:[s.jsx(rs,{})," Loading agent content..."]}),_&&s.jsxs("div",{className:"task-inline-content",ref:S,children:[ae&&s.jsx("div",{className:"task-error-details",children:s.jsx("pre",{className:"task-error-message",children:ae.raw})}),!ae&&(y!=null&&y.messages.length)?s.jsx(uo,{messages:y.messages,isStreaming:b}):!ae&&((Se=t==null?void 0:t.content)!=null&&Se.length)?s.jsx("div",{className:"task-content",children:t.content.map(F=>{var O;return s.jsx(hc,{block:F,context:{isStreaming:!1,theme:"dark",projectPath:c,thinkingExpanded:C,toggleThinkingExpanded:k}},F.id??`${p}-${F.type}-${((O=F.text)==null?void 0:O.slice(0,20))??""}`)})}):ae?null:s.jsx("div",{className:"task-empty",children:b?"Waiting for agent activity...":"No content"})]})]})}function xw({result:e,isError:t}){var d,u;const n=((d=ge())==null?void 0:d.projectPath)??null,[r,o]=m.useState(!0),[i,a]=m.useState(!1),l=m.useCallback(()=>{a(f=>!f)},[]);if(t)return s.jsx("div",{className:"task-error",children:((u=pc(e))==null?void 0:u.raw)||"Task failed"});if(!e)return s.jsx("div",{className:"task-empty",children:"No result"});const c=e.status==="completed"?"badge-success":e.status==="failed"?"badge-error":"badge-warning";return s.jsxs("div",{className:"task-result",children:[s.jsxs("div",{className:"task-result-header",children:[s.jsx("span",{className:`badge ${c}`,children:e.status}),s.jsxs("span",{className:"task-stats",children:[gc(e.totalDurationMs??0)," ·"," ",(e.totalTokens??0).toLocaleString()," tokens ·"," ",e.totalToolUseCount??0," tools"]}),s.jsx("button",{type:"button",className:"expand-button",onClick:()=>o(!r),children:r?"Collapse":"Expand"})]}),r&&e.content&&e.content.length>0&&s.jsx("div",{className:"task-content",children:e.content.map((f,h)=>s.jsx(hc,{block:f,context:{isStreaming:!1,theme:"dark",projectPath:n,thinkingExpanded:i,toggleThinkingExpanded:l}},`${e.agentId}-${h}`))})]})}const yw=de(fe.Task,{tool:"Task",renderToolUse(e,t){return s.jsx(pw,{input:e})},renderToolResult(e,t,n){return s.jsx(xw,{result:e,isError:t})},getUseSummary(e){return e.description??"Agent"},getResultSummary(e,t){if(t)return"Error";const n=e;return n!=null&&n.status?`${n.status} (${n.totalToolUseCount} tools)`:"Complete"},renderInline(e,t,n,r,o){return s.jsx(gw,{input:e,result:t,isError:n,status:r,toolUseId:o.toolUseId})}});function jw(e){switch(e){case"pending":return"□";case"in_progress":return"❋";case"completed":return"✓";default:return"□"}}function bw({todo:e}){const t=`todo-status-${e.status}`,n=e.status==="completed";return s.jsxs("div",{className:`todo-item ${t}`,children:[s.jsx("span",{className:"todo-checkbox",children:jw(e.status)}),s.jsx("span",{className:`todo-content ${n?"todo-completed":""}`,children:e.content})]})}function vw({input:e}){if(!(e!=null&&e.todos)||e.todos.length===0)return s.jsx("div",{className:"todo-empty",children:"No todos specified"});const t=e.todos.filter(o=>o.status==="in_progress"),n=e.todos.filter(o=>o.status==="pending"),r=e.todos.filter(o=>o.status==="completed");return s.jsx("div",{className:"todo-tool-use",children:s.jsxs("span",{className:"todo-summary",children:[t.length>0&&`${t.length} in progress`,t.length>0&&(n.length>0||r.length>0)&&", ",n.length>0&&`${n.length} pending`,n.length>0&&r.length>0&&", ",r.length>0&&`${r.length} completed`]})})}function ww({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("TodoWrite",e);!l.valid&&l.errors?(i(l.errors),n("TodoWrite",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("TodoWrite");return!(e!=null&&e.newTodos)||e.newTodos.length===0?s.jsxs("div",{className:"todo-empty",children:[a&&o&&s.jsx(q,{toolName:"TodoWrite",errors:o}),"No todos"]}):s.jsxs("div",{className:"todo-result",children:[a&&o&&s.jsx(q,{toolName:"TodoWrite",errors:o}),s.jsx("div",{className:"todo-list",children:e.newTodos.map((l,c)=>s.jsx(bw,{todo:l},`${l.content}-${c}`))})]})}const _w=de(fe.TodoWrite,{tool:"TodoWrite",displayName:"Update Todos",renderToolUse(e,t){return s.jsx(vw,{input:e})},renderToolResult(e,t,n){return s.jsx(ww,{result:e})},renderFailure(e){return s.jsx("div",{className:"todo-error",children:e.content||"Failed to update todos"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=e.todos;return t?`${t.length} items`:"Todos"},getResultSummary(e){const t=e;return t!=null&&t.newTodos?`${t.newTodos.length} items`:"Todos"}}),Nw="_output_khonw_1",kw={output:Nw};function ls(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Sw(e){if(typeof e!="string")return"pending";const t=e.trim().toLowerCase();return t==="completed"||t==="complete"||t==="done"?"completed":t==="in_progress"||t==="in-progress"||t==="active"||t==="running"?"in_progress":"pending"}function Cw(e){switch(e){case"completed":return"✓";case"in_progress":return"◐";default:return"○"}}function Tw(e){return e==="in_progress"?"todo-status-in-progress":`todo-status-${e}`}function la(e){return!ls(e)||!Array.isArray(e.plan)?[]:e.plan.filter(t=>ls(t)&&typeof t.step=="string").map(t=>({step:t.step,status:Sw(t.status)}))}function Rw(e){if(!ls(e)||typeof e.explanation!="string")return;const t=e.explanation.trim();return t.length>0?t:void 0}function zs(e){if(typeof e=="string"){const t=e.trim();return t.length>0?t:void 0}if(ls(e)&&typeof e.message=="string"){const t=e.message.trim();return t.length>0?t:void 0}}function An({result:e,isError:t}){const{t:n}=Z();return s.jsxs("details",{className:kw.output,children:[s.jsx("summary",{children:n("toolDisplay.output")}),s.jsx(Xr,{result:e,isError:t})]})}const Pw=de(fe.UpdatePlan,{tool:"UpdatePlan",displayName:"Update plan",renderToolUse(){return null},renderToolResult(e,t){return s.jsxs("div",{className:t?"todo-error":"todo-summary",children:[zs(e),Array.isArray(e)&&s.jsx(An,{result:e,isError:t})]})},renderInline(e,t,n,r){const o=la(e),i=Rw(e),a=zs(t);if(n)return s.jsxs("div",{className:"todo-error",children:[a||"Failed to update plan",Array.isArray(t)&&s.jsx(An,{result:t,isError:n})]});if(o.length===0)return r==="pending"?s.jsx("div",{className:"todo-summary",children:"Updating plan..."}):s.jsxs("div",{className:"todo-summary",children:[a||"Plan updated",Array.isArray(t)&&s.jsx(An,{result:t,isError:n})]});const l=o.filter(c=>c.status==="completed").length;return s.jsxs("div",{className:"todo-result",children:[s.jsxs("div",{className:"todo-summary",children:[l," out of ",o.length," tasks completed"]}),i&&s.jsx("div",{className:"todo-summary",children:i}),s.jsx("div",{className:"todo-list",children:o.map((c,d)=>s.jsxs("div",{className:`todo-item ${Tw(c.status)}`,children:[s.jsx("span",{className:"todo-checkbox",children:Cw(c.status)}),s.jsxs("span",{className:`todo-content ${c.status==="completed"?"todo-completed":""}`,children:[d+1,". ",c.step]})]},`${c.step}-${d}`))}),Array.isArray(t)&&s.jsx(An,{result:t,isError:n}),r!=="pending"&&a&&a.toLowerCase()!=="plan updated"&&s.jsx("div",{className:"todo-summary",children:a})]})},getUseSummary(e){const t=la(e);return t.length===0?"Update plan":`${t.filter(r=>r.status==="completed").length}/${t.length} complete`},getResultSummary(e,t){return t?"Error":zs(e)||"Plan updated"}});function fo(e){return tt(e)}function Ew({path:e,className:t,onClick:n,onContextMenu:r,projectPath:o}){const i=oe(e,o);return s.jsxs("button",{type:"button",className:t,onClick:n,onContextMenu:r,children:[fo(i),s.jsx("span",{className:"file-line-count-inline",children:"(image)"})]})}function qs({path:e,buttonClass:t,stopPropagation:n,projectPath:r}){const[o,i]=m.useState(!1),a=Kt().transport,l=m.useCallback(()=>Sr(e,void 0,"modal",a),[e,a]),c=m.useCallback(()=>i(!0),[]),d=hs({fileName:fo(e),filePath:e,loadBlob:l,onOpen:c,projectPath:r});return s.jsxs(s.Fragment,{children:[s.jsx(Ew,{path:e,className:t,onContextMenu:d.handleContextMenu,projectPath:r,onClick:u=>{n&&u.stopPropagation(),c()}}),o&&s.jsx(qt,{path:e,mediaType:"image",onClose:()=>i(!1)}),d.contextMenuElement]})}const Iw=de(fe.ViewImage,{tool:"ViewImage",displayName:"View Image",renderToolUse(e,t){const{path:n}=e;return s.jsx("div",{className:"read-image-result",children:s.jsx(qs,{path:n,buttonClass:"file-link-button",projectPath:t.projectPath})})},renderToolResult(e,t,n,r){if(!r)return null;const{path:o}=r;return s.jsx("div",{className:"read-image-result",children:s.jsx(qs,{path:o,buttonClass:"file-link-button",projectPath:n.projectPath})})},getUseSummary(e,t){const n=(e==null?void 0:e.path)??"";return fo(oe(n,t==null?void 0:t.projectPath))},getResultSummary(e,t){return t?"Error":"Image loaded"},renderInteractiveSummary(e,t,n,r){const{path:o}=e;return s.jsx(qs,{path:o,buttonClass:"file-link-inline",projectPath:r.projectPath,stopPropagation:!0})}}),ca=30;function Mw(e){return e<1024?`${e} b`:e<1024*1024?`${Math.round(e/1024)} kb`:`${Math.round(e/(1024*1024)*10)/10} mb`}function $w({input:e}){return s.jsxs("div",{className:"webfetch-tool-use",children:[s.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"webfetch-url",children:e.url}),e.prompt&&s.jsx("div",{className:"webfetch-prompt",children:e.prompt})]})}function Lw({result:e}){var g;const[t,n]=m.useState(!1),{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&e){const p=we("WebFetch",e);!p.valid&&p.errors?(l(p.errors),o("WebFetch",p.errors)):l(null)}},[r,e,o]);const c=r&&a&&!i("WebFetch");if(!e)return s.jsx("div",{className:"webfetch-empty",children:"No content"});const d=((g=e.result)==null?void 0:g.split(`
115
+ `)})}),f&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${u.length} lines`})]})]})]})}const Xv=de(fe.TaskOutput,{tool:"TaskOutput",renderToolUse(e,t){return s.jsx(qv,{input:e})},renderToolResult(e,t,n){return s.jsx(Kv,{result:e})},renderFailure(e){return s.jsx("div",{className:"taskoutput-error",children:e.content||"Failed to get task output"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.task_id},getResultSummary(e){const t=e;return t?t.retrieval_status:"Pending"}});function uc(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function un(e,t){if(!uc(e))return;const n=e[t];return typeof n=="string"&&n.trim()?n.trim():void 0}function os(e){return typeof e=="object"&&e!==null?e._taskSnapshot:void 0}function Yv(e){return un(e,"taskId")??un(e,"task_id")??un(e,"id")}function mo(e){if(typeof e!="string")return"unknown";const t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");return t==="completed"||t==="complete"?"completed":t==="in_progress"||t==="running"?"in_progress":t==="pending"||t==="todo"?"pending":t==="failed"||t==="error"?"failed":t==="cancelled"||t==="canceled"?"cancelled":"unknown"}function Jv(e){switch(e){case"completed":return"✓";case"in_progress":return"◐";case"failed":return"!";case"cancelled":return"×";default:return"○"}}function Qv(e){return e==="in_progress"?"todo-status-in-progress":`todo-status-${e}`}function Zv(e){var t;return(t=e.subject)!=null&&t.trim()?e.subject.trim():e.id?`Task #${e.id}`:"Task"}function mc(e){return e.filter(t=>mo(t.status)==="completed").length}function ew({snapshot:e}){const t=e.tasks,n=mc(t);return s.jsxs("div",{className:"todo-result",children:[s.jsxs("div",{className:"todo-summary",children:[n," out of ",t.length," tasks completed"]}),s.jsx("div",{className:"todo-list",children:t.map(r=>{const o=mo(r.status),i=o==="completed",a=Zv(r);return s.jsxs("div",{className:`todo-item ${Qv(o)}`,children:[s.jsx("span",{className:"todo-checkbox",children:Jv(o)}),s.jsx("span",{className:`todo-content ${i?"todo-completed":""}`,children:a})]},r.id||a)})})]})}function _s(e,t){if(e==="TaskCreate")return un(t,"subject")??"Task created";const n=Yv(t),r=mo(un(t,"status")),o=r==="unknown"?"updated":r.replace("_"," ");return n?`Task #${n} ${o}`:`Task ${o}`}function tw(e){if(typeof e=="string")return e.trim()||void 0;if(!uc(e))return;const t=e.content;return typeof t=="string"&&t.trim()?t.trim():void 0}function is(e,t,n,r){const o=os(n)??os(t);return!r&&o&&o.tasks.length>0?s.jsx(ew,{snapshot:o}):r?s.jsx("div",{className:"todo-error",children:tw(n)??"Task update failed"}):s.jsx("div",{className:"todo-summary",children:_s(e,t)})}function as(e,t,n){const r=os(n)??os(t);return r!=null&&r.tasks.length?`${mc(r.tasks)}/${r.tasks.length} complete`:_s(e,t)}const nw=de(fe.TaskCreate,{tool:"TaskCreate",displayName:"Create task",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:_s("TaskCreate",e)})},renderToolResult(e,t,n,r){return is("TaskCreate",r,e,t)},renderInline(e,t,n){return is("TaskCreate",e,t,n)},getUseSummary(e){return as("TaskCreate",e)},getResultSummary(e,t,n){return t?"Error":as("TaskCreate",n,e)}}),sw=de(fe.TaskUpdate,{tool:"TaskUpdate",displayName:"Update task",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:_s("TaskUpdate",e)})},renderToolResult(e,t,n,r){return is("TaskUpdate",r,e,t)},renderInline(e,t,n){return is("TaskUpdate",e,t,n)},getUseSummary(e){return as("TaskUpdate",e)},getResultSummary(e,t,n){return t?"Error":as("TaskUpdate",n,e)}});function rw({block:e}){return s.jsxs("div",{className:"fallback-block",children:[s.jsx("div",{className:"fallback-type",children:e.type}),s.jsx("pre",{className:"fallback-content",children:s.jsx("code",{children:JSON.stringify(e,null,2)})})]})}const ow={type:[],render(e,t){return s.jsx(rw,{block:e,context:t})}};function iw({block:e}){const t=va(e._renderedHtml??""),{modal:n,localFileModal:r,projectFileModal:o,handleClick:i,handleContextMenu:a,closeModal:l,closeLocalFileModal:c,closeProjectFileModal:d,contextMenuElement:u}=ja();return e._renderedHtml?s.jsxs("div",{className:"text-block",onClick:i,onContextMenu:a,children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:t}}),n&&s.jsx(qt,{path:n.path,mediaType:n.mediaType,onClose:l}),r&&s.jsx(ba,{resource:r.resource,initialPresentation:r.initialPresentation,onClose:c}),o&&s.jsx(Ta,{projectId:o.projectId,filePath:o.filePath,lineNumber:o.lineNumber,lineEnd:o.lineEnd,initialPresentation:o.initialPresentation,onClose:d}),u]}):s.jsx("div",{className:"text-block",children:s.jsx("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"inherit"},children:e.text})})}const aw={type:"text",render(e,t){return s.jsx(iw,{block:e})},getSummary(e){const t=e.text;return t.length>100?`${t.slice(0,97)}...`:t}};function fc(e){var n;if(typeof e.thinking=="string")return e.thinking;const t=(n=e.summary)==null?void 0:n.map(r=>typeof r=="string"?r:r.text).filter(r=>typeof r=="string").join(`
116
+ `).trim();return t||(typeof e.text=="string"?e.text:"")}function lw({block:e,context:t}){const[n,r]=m.useState(!1),o=fc(e),i=t.thinkingExpanded??n,a=t.toggleThinkingExpanded??(()=>r(c=>!c));if(i)return s.jsxs("div",{className:"thinking-block thinking-block-expanded",children:[s.jsxs("button",{type:"button",className:"thinking-toggle-expanded",onClick:a,"aria-expanded":!0,children:[s.jsx("span",{className:"thinking-label",children:"Thinking"}),s.jsx("span",{className:"thinking-icon",children:"▲"})]}),s.jsx("div",{className:"thinking-content",children:s.jsx(Cr,{text:o,isStreaming:t.isStreaming})})]});const l=t.isStreaming?"thinking-block thinking-streaming-collapsed":"thinking-block";return s.jsx("div",{className:l,children:s.jsxs("button",{type:"button",className:"thinking-toggle-collapsed",onClick:a,"aria-expanded":!1,children:[s.jsx("span",{className:"thinking-label",children:t.isStreaming?"Thinking...":"Thinking"}),s.jsx("span",{className:"thinking-icon",children:"▼"})]})})}const cw={type:["thinking","reasoning","reasoning_text","summary_text"],render(e,t){return s.jsx(lw,{block:e,context:t})},getSummary(e){const n=fc(e).split(`
117
+ `)[0]||"";return n.length>80?`${n.slice(0,77)}...`:n}};function dw({block:e,context:t}){var a;const n=(a=t.getToolUse)==null?void 0:a.call(t,e.tool_use_id),r=(n==null?void 0:n.name)||"Unknown",o=e.is_error===!0;let i=t.toolUseResult;if(!i&&e.content)try{i=JSON.parse(e.content)}catch{i={content:e.content}}return s.jsxs("div",{className:`tool-block tool-result ${o?"tool-error":""}`,children:[s.jsxs("div",{className:"tool-header",children:[s.jsx("span",{className:"tool-icon",children:"<"}),s.jsx("span",{className:"tool-name",children:r}),o&&s.jsx("span",{className:"badge badge-error",children:"Error"})]}),s.jsx("div",{className:"tool-content",children:ze.renderToolResult(r,i,o,t,n==null?void 0:n.input)})]})}const uw={type:"tool_result",render(e,t){return s.jsx(dw,{block:e,context:t})},getSummary(e){return e.is_error?"Error":"Result"}};function mw({block:e,context:t}){return s.jsxs("div",{className:"tool-block tool-use",children:[s.jsxs("div",{className:"tool-header",children:[s.jsx("span",{className:"tool-icon",children:">"}),s.jsx("span",{className:"tool-name",children:e.name})]}),s.jsx("div",{className:"tool-content",children:ze.renderToolUse(e.name,e.input,t)})]})}const fw={type:"tool_use",render(e,t){return s.jsx(mw,{block:e,context:t})},getSummary(e){const t=e;return ze.prepare(t.name,{input:t.input,status:"pending"}).getUseSummary()||t.name}};class hw{constructor(t){be(this,"renderers",new Map);be(this,"fallback");this.fallback=t}register(t){const n=Array.isArray(t.type)?t.type:[t.type];for(const r of n)this.renderers.set(r,t)}getRenderer(t){return this.renderers.get(t.type)||this.fallback}render(t,n){return this.getRenderer(t).render(t,n)}}const vn=new hw(ow);vn.register(aw);vn.register(cw);vn.register(fw);vn.register(uw);const hc=m.memo(function({block:t,context:n}){return s.jsx(s.Fragment,{children:vn.render(t,n)})}),ia=200,aa=80;function pc(e){var o,i;const t=((i=(o=e==null?void 0:e.content)==null?void 0:o.find(a=>a.type==="text"&&a.text))==null?void 0:i.text)??"";if(!t)return null;const n=vs(t),r=n.cleanedMessage.length>aa?`${n.cleanedMessage.slice(0,aa)}...`:n.cleanedMessage;return{raw:t,summary:r,label:n.label}}function gc(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function pw({input:e}){const[t,n]=m.useState(!1),r=e.prompt.length>ia?`${e.prompt.slice(0,ia)}...`:e.prompt;return s.jsxs("div",{className:"task-tool-use",children:[s.jsxs("div",{className:"task-header",children:[s.jsx("span",{className:"task-description",children:e.description}),s.jsx("span",{className:"badge badge-info",children:e.subagent_type}),e.model&&s.jsx("span",{className:"badge",children:e.model})]}),e.prompt&&s.jsxs("div",{className:"task-prompt",children:[s.jsx("button",{type:"button",className:"task-prompt-toggle",onClick:()=>n(!t),children:t?"Hide prompt":"Show prompt"}),t&&s.jsx("pre",{className:"task-prompt-content",children:s.jsx("code",{children:t?e.prompt:r})})]})]})}function gw({input:e,result:t,isError:n,status:r,toolUseId:o}){var Se;const{t:i}=Z(),a=Mr(),{projectId:l,projectPath:c,sessionId:d}=gs(),u=m.useContext(so),{reportValidationError:f,enabled:h,isToolIgnored:g}=ve(),p=(t==null?void 0:t.agentId)??(o?u==null?void 0:u.toolUseToAgent.get(o):void 0),y=p?u==null?void 0:u.agentContent[p]:void 0,b=!((t==null?void 0:t.status)==="completed"||(t==null?void 0:t.status)==="failed")&&r==="pending"&&((y==null?void 0:y.status)==="running"||!(y!=null&&y.status)),[_,N]=m.useState(!1),[v,j]=m.useState(!1),[C,w]=m.useState(!1),k=m.useCallback(()=>{w(F=>!F)},[]),S=m.useRef(null),$=m.useRef(!0),T=m.useRef(!1),E=m.useRef(0),R=m.useCallback(F=>{T.current=!0,F.scrollTop=F.scrollHeight-F.clientHeight,E.current=F.scrollHeight,requestAnimationFrame(()=>{T.current=!1})},[]),D=m.useCallback(()=>{if(T.current)return;const F=S.current;if(!F)return;const O=100,Ce=F.scrollHeight-F.scrollTop-F.clientHeight;$.current=Ce<O},[]);m.useEffect(()=>{const F=S.current;if(!(!F||!_))return F.addEventListener("scroll",D),()=>{F.removeEventListener("scroll",D)}},[D,_]),m.useEffect(()=>{const F=S.current;if(!F||!_||!b)return;E.current=F.scrollHeight;const O=new ResizeObserver(()=>{const Ce=F.scrollHeight;Ce>E.current&&$.current?R(F):E.current=Ce});for(const Ce of F.children)O.observe(Ce);return O.observe(F),()=>{O.disconnect()}},[_,b,R]),m.useEffect(()=>{if(_&&b){$.current=!0;const F=S.current;F&&requestAnimationFrame(()=>{R(F)})}},[_,b,R]);const K=m.useRef(!1);m.useEffect(()=>{if(!_||!p||!u||K.current)return;K.current=!0,(async()=>{j(!0);try{await u.loadAgentContent(l,d,p)}finally{j(!1)}})()},[_,p,u,l,d]);const[V,G]=m.useState(null);m.useEffect(()=>{if(!t||!h){G(null);return}const F=we("Task",t);!F.valid&&F.errors?(G(F.errors),f("Task",F.errors)):G(null)},[t,h,f]);const W=h&&V!==null&&!g("Task"),ie=async()=>{const F=(y==null?void 0:y.messages)&&y.messages.length>0;if(!_&&p&&u&&!F){N(!0),j(!0);try{await u.loadAgentContent(l,d,p)}finally{j(!1)}}else N(!_)},ae=n?pc(t):null,se=n?{class:"badge-error",text:(ae==null?void 0:ae.label)??"failed"}:r==="aborted"?{class:"badge-warning",text:"interrupted"}:r==="incomplete"?{class:"badge-warning",text:"result unavailable"}:b?{class:"badge-running",text:"running"}:(t==null?void 0:t.status)==="completed"?{class:"badge-success",text:"completed"}:(t==null?void 0:t.status)==="failed"?{class:"badge-error",text:"failed"}:{class:"badge-pending",text:"pending"};return s.jsxs("div",{className:`task-inline ${_?"expanded":"collapsed"} status-${se.text}`,children:[s.jsxs("div",{className:ct.headerRow,children:[s.jsxs("button",{type:"button",className:`task-inline-header ${ct.expandButton}`,onClick:ie,children:[s.jsx("span",{className:"task-expand-icon",children:_?"▼":"▶"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:e.subagent_type}),s.jsx("span",{className:"task-inline-title",children:e.description}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),b&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"task-spinner",role:"status","aria-label":"Running",children:s.jsx(rs,{})}),(y==null?void 0:y.contextUsage)&&s.jsxs("span",{className:"task-context-usage",children:[y.contextUsage.percentage.toFixed(0),"% context"]})]}),!b&&s.jsx("span",{className:`badge ${se.class}`,children:se.text}),!_&&ae&&s.jsx("span",{className:"task-error-summary",title:ae.raw,children:ae.summary}),t&&!n&&s.jsxs("span",{className:"task-stats",children:[gc(t.totalDurationMs??0)," ·"," ",(t.totalTokens??0).toLocaleString()," tokens"]}),W&&V&&s.jsx(q,{toolName:"Task",errors:V})]}),p&&s.jsx(vr,{className:ct.openPage,to:Ia(a,l,d,p),children:i("providerChildOpen")})]}),v&&s.jsxs("div",{className:"task-loading",children:[s.jsx(rs,{})," Loading agent content..."]}),_&&s.jsxs("div",{className:"task-inline-content",ref:S,children:[ae&&s.jsx("div",{className:"task-error-details",children:s.jsx("pre",{className:"task-error-message",children:ae.raw})}),!ae&&(y!=null&&y.messages.length)?s.jsx(uo,{messages:y.messages,isStreaming:b}):!ae&&((Se=t==null?void 0:t.content)!=null&&Se.length)?s.jsx("div",{className:"task-content",children:t.content.map(F=>{var O;return s.jsx(hc,{block:F,context:{isStreaming:!1,theme:"dark",projectPath:c,thinkingExpanded:C,toggleThinkingExpanded:k}},F.id??`${p}-${F.type}-${((O=F.text)==null?void 0:O.slice(0,20))??""}`)})}):ae?null:s.jsx("div",{className:"task-empty",children:b?"Waiting for agent activity...":"No content"})]})]})}function xw({result:e,isError:t}){var d,u;const n=((d=ge())==null?void 0:d.projectPath)??null,[r,o]=m.useState(!0),[i,a]=m.useState(!1),l=m.useCallback(()=>{a(f=>!f)},[]);if(t)return s.jsx("div",{className:"task-error",children:((u=pc(e))==null?void 0:u.raw)||"Task failed"});if(!e)return s.jsx("div",{className:"task-empty",children:"No result"});const c=e.status==="completed"?"badge-success":e.status==="failed"?"badge-error":"badge-warning";return s.jsxs("div",{className:"task-result",children:[s.jsxs("div",{className:"task-result-header",children:[s.jsx("span",{className:`badge ${c}`,children:e.status}),s.jsxs("span",{className:"task-stats",children:[gc(e.totalDurationMs??0)," ·"," ",(e.totalTokens??0).toLocaleString()," tokens ·"," ",e.totalToolUseCount??0," tools"]}),s.jsx("button",{type:"button",className:"expand-button",onClick:()=>o(!r),children:r?"Collapse":"Expand"})]}),r&&e.content&&e.content.length>0&&s.jsx("div",{className:"task-content",children:e.content.map((f,h)=>s.jsx(hc,{block:f,context:{isStreaming:!1,theme:"dark",projectPath:n,thinkingExpanded:i,toggleThinkingExpanded:l}},`${e.agentId}-${h}`))})]})}const yw=de(fe.Task,{tool:"Task",renderToolUse(e,t){return s.jsx(pw,{input:e})},renderToolResult(e,t,n){return s.jsx(xw,{result:e,isError:t})},getUseSummary(e){return e.description??"Agent"},getResultSummary(e,t){if(t)return"Error";const n=e;return n!=null&&n.status?`${n.status} (${n.totalToolUseCount} tools)`:"Complete"},renderInline(e,t,n,r,o){return s.jsx(gw,{input:e,result:t,isError:n,status:r,toolUseId:o.toolUseId})}});function jw(e){switch(e){case"pending":return"□";case"in_progress":return"❋";case"completed":return"✓";default:return"□"}}function bw({todo:e}){const t=`todo-status-${e.status}`,n=e.status==="completed";return s.jsxs("div",{className:`todo-item ${t}`,children:[s.jsx("span",{className:"todo-checkbox",children:jw(e.status)}),s.jsx("span",{className:`todo-content ${n?"todo-completed":""}`,children:e.content})]})}function vw({input:e}){if(!(e!=null&&e.todos)||e.todos.length===0)return s.jsx("div",{className:"todo-empty",children:"No todos specified"});const t=e.todos.filter(o=>o.status==="in_progress"),n=e.todos.filter(o=>o.status==="pending"),r=e.todos.filter(o=>o.status==="completed");return s.jsx("div",{className:"todo-tool-use",children:s.jsxs("span",{className:"todo-summary",children:[t.length>0&&`${t.length} in progress`,t.length>0&&(n.length>0||r.length>0)&&", ",n.length>0&&`${n.length} pending`,n.length>0&&r.length>0&&", ",r.length>0&&`${r.length} completed`]})})}function ww({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("TodoWrite",e);!l.valid&&l.errors?(i(l.errors),n("TodoWrite",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("TodoWrite");return!(e!=null&&e.newTodos)||e.newTodos.length===0?s.jsxs("div",{className:"todo-empty",children:[a&&o&&s.jsx(q,{toolName:"TodoWrite",errors:o}),"No todos"]}):s.jsxs("div",{className:"todo-result",children:[a&&o&&s.jsx(q,{toolName:"TodoWrite",errors:o}),s.jsx("div",{className:"todo-list",children:e.newTodos.map((l,c)=>s.jsx(bw,{todo:l},`${l.content}-${c}`))})]})}const _w=de(fe.TodoWrite,{tool:"TodoWrite",displayName:"Update Todos",renderToolUse(e,t){return s.jsx(vw,{input:e})},renderToolResult(e,t,n){return s.jsx(ww,{result:e})},renderFailure(e){return s.jsx("div",{className:"todo-error",children:e.content||"Failed to update todos"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=e.todos;return t?`${t.length} items`:"Todos"},getResultSummary(e){const t=e;return t!=null&&t.newTodos?`${t.newTodos.length} items`:"Todos"}}),Nw="_output_khonw_1",kw={output:Nw};function ls(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Sw(e){if(typeof e!="string")return"pending";const t=e.trim().toLowerCase();return t==="completed"||t==="complete"||t==="done"?"completed":t==="in_progress"||t==="in-progress"||t==="active"||t==="running"?"in_progress":"pending"}function Cw(e){switch(e){case"completed":return"✓";case"in_progress":return"◐";default:return"○"}}function Tw(e){return e==="in_progress"?"todo-status-in-progress":`todo-status-${e}`}function la(e){return!ls(e)||!Array.isArray(e.plan)?[]:e.plan.filter(t=>ls(t)&&typeof t.step=="string").map(t=>({step:t.step,status:Sw(t.status)}))}function Rw(e){if(!ls(e)||typeof e.explanation!="string")return;const t=e.explanation.trim();return t.length>0?t:void 0}function zs(e){if(typeof e=="string"){const t=e.trim();return t.length>0?t:void 0}if(ls(e)&&typeof e.message=="string"){const t=e.message.trim();return t.length>0?t:void 0}}function An({result:e,isError:t}){const{t:n}=Z();return s.jsxs("details",{className:kw.output,children:[s.jsx("summary",{children:n("toolDisplay.output")}),s.jsx(Xr,{result:e,isError:t})]})}const Pw=de(fe.UpdatePlan,{tool:"UpdatePlan",displayName:"Update plan",renderToolUse(){return null},renderToolResult(e,t){return s.jsxs("div",{className:t?"todo-error":"todo-summary",children:[zs(e),Array.isArray(e)&&s.jsx(An,{result:e,isError:t})]})},renderInline(e,t,n,r){const o=la(e),i=Rw(e),a=zs(t);if(n)return s.jsxs("div",{className:"todo-error",children:[a||"Failed to update plan",Array.isArray(t)&&s.jsx(An,{result:t,isError:n})]});if(o.length===0)return r==="pending"?s.jsx("div",{className:"todo-summary",children:"Updating plan..."}):s.jsxs("div",{className:"todo-summary",children:[a||"Plan updated",Array.isArray(t)&&s.jsx(An,{result:t,isError:n})]});const l=o.filter(c=>c.status==="completed").length;return s.jsxs("div",{className:"todo-result",children:[s.jsxs("div",{className:"todo-summary",children:[l," out of ",o.length," tasks completed"]}),i&&s.jsx("div",{className:"todo-summary",children:i}),s.jsx("div",{className:"todo-list",children:o.map((c,d)=>s.jsxs("div",{className:`todo-item ${Tw(c.status)}`,children:[s.jsx("span",{className:"todo-checkbox",children:Cw(c.status)}),s.jsxs("span",{className:`todo-content ${c.status==="completed"?"todo-completed":""}`,children:[d+1,". ",c.step]})]},`${c.step}-${d}`))}),Array.isArray(t)&&s.jsx(An,{result:t,isError:n}),r!=="pending"&&a&&a.toLowerCase()!=="plan updated"&&s.jsx("div",{className:"todo-summary",children:a})]})},getUseSummary(e){const t=la(e);return t.length===0?"Update plan":`${t.filter(r=>r.status==="completed").length}/${t.length} complete`},getResultSummary(e,t){return t?"Error":zs(e)||"Plan updated"}});function fo(e){return tt(e)}function Ew({path:e,className:t,onClick:n,onContextMenu:r,projectPath:o}){const i=oe(e,o);return s.jsxs("button",{type:"button",className:t,onClick:n,onContextMenu:r,children:[fo(i),s.jsx("span",{className:"file-line-count-inline",children:"(image)"})]})}function qs({path:e,buttonClass:t,stopPropagation:n,projectPath:r}){const[o,i]=m.useState(!1),a=Kt().transport,l=m.useCallback(()=>_r(e,void 0,"modal",a),[e,a]),c=m.useCallback(()=>i(!0),[]),d=hs({fileName:fo(e),filePath:e,loadBlob:l,onOpen:c,projectPath:r});return s.jsxs(s.Fragment,{children:[s.jsx(Ew,{path:e,className:t,onContextMenu:d.handleContextMenu,projectPath:r,onClick:u=>{n&&u.stopPropagation(),c()}}),o&&s.jsx(qt,{path:e,mediaType:"image",onClose:()=>i(!1)}),d.contextMenuElement]})}const Iw=de(fe.ViewImage,{tool:"ViewImage",displayName:"View Image",renderToolUse(e,t){const{path:n}=e;return s.jsx("div",{className:"read-image-result",children:s.jsx(qs,{path:n,buttonClass:"file-link-button",projectPath:t.projectPath})})},renderToolResult(e,t,n,r){if(!r)return null;const{path:o}=r;return s.jsx("div",{className:"read-image-result",children:s.jsx(qs,{path:o,buttonClass:"file-link-button",projectPath:n.projectPath})})},getUseSummary(e,t){const n=(e==null?void 0:e.path)??"";return fo(oe(n,t==null?void 0:t.projectPath))},getResultSummary(e,t){return t?"Error":"Image loaded"},renderInteractiveSummary(e,t,n,r){const{path:o}=e;return s.jsx(qs,{path:o,buttonClass:"file-link-inline",projectPath:r.projectPath,stopPropagation:!0})}}),ca=30;function Mw(e){return e<1024?`${e} b`:e<1024*1024?`${Math.round(e/1024)} kb`:`${Math.round(e/(1024*1024)*10)/10} mb`}function $w({input:e}){return s.jsxs("div",{className:"webfetch-tool-use",children:[s.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"webfetch-url",children:e.url}),e.prompt&&s.jsx("div",{className:"webfetch-prompt",children:e.prompt})]})}function Lw({result:e}){var g;const[t,n]=m.useState(!1),{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&e){const p=we("WebFetch",e);!p.valid&&p.errors?(l(p.errors),o("WebFetch",p.errors)):l(null)}},[r,e,o]);const c=r&&a&&!i("WebFetch");if(!e)return s.jsx("div",{className:"webfetch-empty",children:"No content"});const d=((g=e.result)==null?void 0:g.split(`
118
118
  `))||[],u=d.length>ca,f=u&&!t?d.slice(0,ca):d,h=e.code>=200&&e.code<300?"badge-success":e.code>=400?"badge-error":"badge-warning";return s.jsxs("div",{className:"webfetch-result",children:[s.jsxs("div",{className:"webfetch-header",children:[s.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"webfetch-url",children:e.url}),s.jsxs("span",{className:`badge ${h}`,children:[e.code," ",e.codeText]}),s.jsxs("span",{className:"webfetch-meta",children:[Mw(e.bytes)," · ",e.durationMs,"ms"]}),c&&a&&s.jsx(q,{toolName:"WebFetch",errors:a})]}),e.result&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"webfetch-content code-block",children:s.jsx("code",{children:f.join(`
119
119
  `)})}),u&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${d.length} lines`})]})]})}const Aw=de(fe.WebFetch,{tool:"WebFetch",renderToolUse(e,t){return s.jsx($w,{input:e})},renderToolResult(e,t,n){return s.jsx(Lw,{result:e})},renderFailure(e){return s.jsx("div",{className:"webfetch-error",children:e.content||"Fetch failed"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=e.url;try{return new URL(t).hostname}catch{return t}},getResultSummary(e){const t=e;return t!=null&&t.code?`${t.code} ${t.codeText}`:"Fetched"}}),da=24,ua=3,Fw=20;function jr(e){return typeof e=="object"&&e!==null}function Ns(e){if(e)try{return new URL(e).hostname.replace(/^www\./,"")}catch{return}}function Bw(e){if(e!==void 0)return`${e.toFixed(1)}s`}function Ks(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function cs(e){var r,o,i,a,l,c;if(!e||typeof e!="object")return"";const t=[],n=[...e.search_query??[],...e.image_query??[]];if(n.length>0&&((r=n[0])!=null&&r.q)){const d=n.length>1?` (+${n.length-1} more)`:"";t.push(`search "${Ks(n[0].q,40)}"${d}`)}if((o=e.open)!=null&&o.length){const d=(i=e.open[0])==null?void 0:i.ref_id;t.push(e.open.length===1&&d?`open ${Ks(d,40)}`:`open ×${e.open.length}`)}if((a=e.find)!=null&&a.length){const d=(l=e.find[0])==null?void 0:l.pattern;t.push(d?`find "${Ks(d,30)}"`:"find")}return(c=e.click)!=null&&c.length&&t.push(`click ${e.click.map(d=>`#${d.id??"?"}`).join(" ")}`),t.join(" · ")}function ds(e){return e.title||Ns(e.url)||e.ref||"(untitled)"}function ho(e){return e.lines&&e.lines.length>0?e.lines.map(t=>t.text).join(`
120
120
  `).replace(/\n{3,}/g,`
@@ -130,7 +130,7 @@ ${r}`:n}).join(`
130
130
  `):e.text??"";return s.jsxs("div",{className:"webrun-page",children:[s.jsxs("div",{className:"webrun-page-header",children:[s.jsx(Hw,{page:e}),Uw(e).map(c=>s.jsx("span",{className:"badge",children:c},c)),s.jsx(ft,{text:ho(e),label:"Copy page text"})]}),e.redirectedUrl&&s.jsxs("div",{className:"webrun-redirect",children:["→ ",e.redirectedUrl]}),l&&s.jsx("div",{className:"webrun-text",children:l}),i&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!n),children:n?"Show less":`Show all ${o.length} lines`})]})}function Ww({result:e}){return e.pages.length===0?s.jsx("div",{className:"webrun-text",children:e.text||"No content"}):s.jsx("div",{className:"webrun-result",children:e.pages.map((t,n)=>s.jsx(xc,{page:t,collapsible:!1},`${t.ref??t.url??n}`))})}function Vw({page:e}){var r,o;const t=e.url?Ns(e.url)??e.url:e.ref,n=!e.url&&((o=(r=e.lines)==null?void 0:r[0])!=null&&o.text)?`${e.title} — ${e.lines[0].text}`:e.title!==t?e.title:"";return s.jsxs("div",{className:"webrun-preview-row",children:[e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"webrun-link",children:t}):s.jsx("span",{className:"webrun-link",children:t}),n&&s.jsx("span",{className:"webrun-preview-title",children:n})]})}function Gw({input:e,result:t}){const n=us(),[r,o]=m.useState(!1),i=m.useMemo(()=>Dw(t),[t]),a=m.useMemo(()=>Ow(t),[t]),{text:l,truncated:c}=bl(i,yl(n)),d=jl(i,n),u=Yt(i,n),f=ms(i,u,".webrun-preview-output-text"),h=t.pages.slice(0,ua),g=t.pages.slice(ua),p=g.slice(0,Fw).map(_=>{const N=_.url?Ns(_.url)??_.url:_.ref,v=ds(_);return v&&v!==N?`${N} — ${v}`:`${N}`}).join(`
131
131
  `),y=yn(p),x=m.useCallback(_=>{var v;const N=_.target;(v=N==null?void 0:N.closest)!=null&&v.call(N,"button,a")||Nl(_.currentTarget)||o(!0)},[]),b=m.useCallback(_=>{_.target===_.currentTarget&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),o(!0))},[]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{role:"button",tabIndex:0,"aria-label":"View web page content",className:"webrun-collapsed-preview",onClick:x,onKeyDown:b,children:[h.map((_,N)=>s.jsx(Vw,{page:_},`${_.ref??_.url??N}`)),g.length>0&&s.jsxs("div",{className:"webrun-preview-row webrun-preview-more",...y,children:["+",g.length," more"]}),l&&s.jsxs("div",{className:"webrun-preview-row webrun-preview-output-row",children:[s.jsxs("div",{className:"webrun-preview-output",...f,children:[s.jsx("div",{className:"webrun-preview-output-text",style:{"--webrun-preview-line-count":String(n)},children:l}),c&&s.jsx("div",{className:"webrun-preview-fade"})]}),s.jsx(ft,{text:a,label:"Copy page text"}),d>0&&s.jsx(Tt,{className:"webrun-preview-more-badge",count:d,tooltip:u??i})]})]}),r&&s.jsx(Mt,{title:cs(e)||"Web",label:cs(e)||"Web",onClose:()=>o(!1),children:s.jsx(Ww,{result:t})})]})}function zw({result:e,isError:t}){return t?s.jsx("div",{className:"webrun-error",children:typeof e=="string"?e:"Web browse failed"}):jr(e)?e.pages.length===0?s.jsx("div",{className:"webrun-text",children:e.text||"No content"}):s.jsx("div",{className:"webrun-result",children:e.pages.map((n,r)=>s.jsx(xc,{page:n},`${n.ref??n.url??r}`))}):typeof e=="string"&&e?s.jsx("div",{className:"webrun-text",children:e}):s.jsx("div",{className:"webrun-text",children:"No content"})}const qw=de(fe.Web,{tool:"Web",displayName:"Web",pendingDisplayName:"Browsing",renderToolUse(e,t){const n=cs(e);return s.jsx("div",{className:"webrun-tool-use",children:n||"web.run"})},renderToolResult(e,t,n){return s.jsx(zw,{result:e,isError:t})},renderCollapsedPreview(e,t,n,r){return n||!jr(t)||t.pages.length===0?null:s.jsx(Gw,{input:e,result:t})},getUseSummary(e){return cs(e)||"web.run"},getResultSummary(e,t,n){var l;if(t)return"failed";if(!jr(e))return"done";const r=Bw(e.durationSeconds),o=e.pages;if(o.length===0)return r??"done";if(o.length===1&&o[0]){const c=o[0];return[r,c.wordLimit!==void 0?`wordlim ${c.wordLimit}`:void 0,c.totalLines!==void 0?`${c.totalLines} lines`:void 0,Ns(c.url)].filter(Boolean).join(" · ")}const a=o.every(c=>!c.lines)&&(((l=n==null?void 0:n.search_query)==null?void 0:l.length)??0)>0?"results":"pages";return[r,`${o.length} ${a}`].filter(Boolean).join(" · ")}});function Kw({input:e}){return s.jsx("div",{className:"websearch-tool-use",children:s.jsx("span",{className:"websearch-query",children:e.query})})}function Xw({result:e}){var c;const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const d=we("WebSearch",e);!d.valid&&d.errors?(i(d.errors),n("WebSearch",d.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("WebSearch");if(!e)return s.jsx("div",{className:"websearch-empty",children:"No results"});const l=((c=e.results)==null?void 0:c.flatMap(d=>typeof d=="string"?[]:d.content).filter(Boolean))||[];return s.jsxs("div",{className:"websearch-result",children:[s.jsxs("div",{className:"websearch-header",children:[s.jsxs("span",{className:"websearch-query-display",children:['"',e.query,'"']}),e.durationSeconds!==void 0&&s.jsxs("span",{className:"badge",children:[e.durationSeconds.toFixed(2),"s"]}),a&&o&&s.jsx(q,{toolName:"WebSearch",errors:o})]}),l.length>0?s.jsx("ul",{className:"websearch-links",children:l.map((d,u)=>s.jsxs("li",{className:"websearch-link-item",children:[s.jsx("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",className:"websearch-link",children:d.title}),s.jsx("span",{className:"websearch-url",children:d.url})]},`${d.url}-${u}`))}):s.jsx("div",{className:"websearch-empty",children:"No results found"})]})}const Yw=de(fe.WebSearch,{tool:"WebSearch",renderToolUse(e,t){return s.jsx(Kw,{input:e})},renderToolResult(e,t,n){return s.jsx(Xw,{result:e})},renderFailure(e){return s.jsx("div",{className:"websearch-error",children:e.content||"Search failed"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.query},getResultSummary(e){var r;const t=e;return`${((r=t==null?void 0:t.results)==null?void 0:r.flatMap(o=>typeof o=="string"?[]:o.content).length)||0} results`}}),ma=30,Fn=3;function Xs(e){return tt(e)}function Jw(e,t){const n=e.split('<span class="line">');return n.length<=t+1?e:`${n.slice(0,t+1).join('<span class="line">')}</code></pre>`}function Qw({input:e}){const t=ge(),n=oe(e.file_path,t==null?void 0:t.projectPath),r=e.content.split(`
132
132
  `).length;return s.jsxs("div",{className:"write-tool-use",children:[s.jsx("span",{className:"file-path",children:s.jsx(Ue,{displayPath:n,filePath:e.file_path})}),s.jsxs("span",{className:"write-info",children:[r," lines"]})]})}function Zw({file:e,input:t}){const[n,r]=m.useState(!1),o=e.content.split(`
133
- `),l=Er(e.filePath)&&!!(t!=null&&t._renderedMarkdownHtml)&&s.jsxs("div",{className:"markdown-view-toggle",children:[s.jsx("button",{type:"button",className:`toggle-btn ${n?"":"active"}`,onClick:()=>r(!1),children:"Source"}),s.jsx("button",{type:"button",className:`toggle-btn ${n?"active":""}`,onClick:()=>r(!0),children:"Preview"})]});return n&&(t!=null&&t._renderedMarkdownHtml)?s.jsxs("div",{className:"file-content-modal",children:[l,s.jsx(Pa,{html:t._renderedMarkdownHtml,sourcePath:e.filePath,density:Ea})]}):t!=null&&t._highlightedContentHtml?s.jsxs("div",{className:"file-content-modal",children:[l,s.jsxs("div",{className:"file-viewer-code file-viewer-code-highlighted",children:[s.jsx(ws,{html:t._highlightedContentHtml}),t._highlightedTruncated&&s.jsx("div",{className:"file-viewer-truncated",children:"Content truncated for highlighting (showing first 2000 lines)"})]})]}):s.jsxs("div",{className:"file-content-modal",children:[l,s.jsxs("div",{className:"file-content-with-lines",children:[s.jsx("div",{className:"line-numbers",children:o.map((c,d)=>s.jsx("div",{children:e.startLine+d},`ln-${d+1}`))}),s.jsx("pre",{className:"line-content",children:s.jsx("code",{children:e.content})})]})]})}function e_({result:e,input:t}){const n=ge(),[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&e){const x=we("Write",e);!x.valid&&x.errors?(d(x.errors),a("Write",x.errors)):d(null)}},[i,e,a]);const u=i&&c&&!l("Write");if(!(e!=null&&e.file))return s.jsxs("div",{className:"write-error",children:[u&&c&&s.jsx(q,{toolName:"Write",errors:c}),(e==null?void 0:e.content)||"Failed to write file"]});const{file:f}=e,h=f.content.split(`
133
+ `),l=Sr(e.filePath)&&!!(t!=null&&t._renderedMarkdownHtml)&&s.jsxs("div",{className:"markdown-view-toggle",children:[s.jsx("button",{type:"button",className:`toggle-btn ${n?"":"active"}`,onClick:()=>r(!1),children:"Source"}),s.jsx("button",{type:"button",className:`toggle-btn ${n?"active":""}`,onClick:()=>r(!0),children:"Preview"})]});return n&&(t!=null&&t._renderedMarkdownHtml)?s.jsxs("div",{className:"file-content-modal",children:[l,s.jsx(Pa,{html:t._renderedMarkdownHtml,sourcePath:e.filePath,density:Ea})]}):t!=null&&t._highlightedContentHtml?s.jsxs("div",{className:"file-content-modal",children:[l,s.jsxs("div",{className:"file-viewer-code file-viewer-code-highlighted",children:[s.jsx(ws,{html:t._highlightedContentHtml}),t._highlightedTruncated&&s.jsx("div",{className:"file-viewer-truncated",children:"Content truncated for highlighting (showing first 2000 lines)"})]})]}):s.jsxs("div",{className:"file-content-modal",children:[l,s.jsxs("div",{className:"file-content-with-lines",children:[s.jsx("div",{className:"line-numbers",children:o.map((c,d)=>s.jsx("div",{children:e.startLine+d},`ln-${d+1}`))}),s.jsx("pre",{className:"line-content",children:s.jsx("code",{children:e.content})})]})]})}function e_({result:e,input:t}){const n=ge(),[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&e){const x=we("Write",e);!x.valid&&x.errors?(d(x.errors),a("Write",x.errors)):d(null)}},[i,e,a]);const u=i&&c&&!l("Write");if(!(e!=null&&e.file))return s.jsxs("div",{className:"write-error",children:[u&&c&&s.jsx(q,{toolName:"Write",errors:c}),(e==null?void 0:e.content)||"Failed to write file"]});const{file:f}=e,h=f.content.split(`
134
134
  `),g=h.length>ma,p=oe(f.filePath,n==null?void 0:n.projectPath);if(t!=null&&t._highlightedContentHtml)return s.jsxs("div",{className:"write-result",children:[s.jsxs("div",{className:"file-header",children:[s.jsx("span",{className:"file-path",children:s.jsx(Ue,{displayPath:p,filePath:f.filePath,lineNumber:f.startLine})}),s.jsxs("span",{className:"file-range",children:[f.numLines," lines written"]}),u&&c&&s.jsx(q,{toolName:"Write",errors:c})]}),s.jsxs("div",{className:"file-viewer-code file-viewer-code-highlighted",children:[s.jsx(ws,{html:t._highlightedContentHtml}),t._highlightedTruncated&&s.jsx("div",{className:"file-viewer-truncated",children:"Content truncated for highlighting (showing first 2000 lines)"})]})]});const y=g&&!r?h.slice(0,ma):h;return s.jsxs("div",{className:"write-result",children:[s.jsxs("div",{className:"file-header",children:[s.jsx("span",{className:"file-path",children:s.jsx(Ue,{displayPath:p,filePath:f.filePath,lineNumber:f.startLine})}),s.jsxs("span",{className:"file-range",children:[f.numLines," lines written"]}),u&&c&&s.jsx(q,{toolName:"Write",errors:c})]}),s.jsxs("div",{className:"file-content-with-lines",children:[s.jsxs("div",{className:"line-numbers",children:[y.map((x,b)=>{const _=f.startLine+b;return s.jsx("div",{children:_},`line-${_}`)}),g&&!r&&s.jsx("div",{children:"..."})]}),s.jsx("pre",{className:"line-content",children:s.jsx("code",{children:y.join(`
135
135
  `)})})]}),g&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>o(!r),children:r?"Show less":`Show all ${h.length} lines`})]})}function t_({input:e,result:t,isError:n}){var C,w,k;const[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&t){const S=we("Write",t);!S.valid&&S.errors?(d(S.errors),a("Write",S.errors)):d(null)}},[i,t,a]);const u=i&&c&&!l("Write"),f=m.useCallback(S=>{S.stopPropagation(),n||o(!0)},[n]),h=m.useCallback(()=>{o(!1)},[]),g=ge(),p=((C=t==null?void 0:t.file)==null?void 0:C.content)??e.content,y=((w=t==null?void 0:t.file)==null?void 0:w.filePath)??e.file_path,x=oe(y,g==null?void 0:g.projectPath),b=p.split(`
136
136
  `),_=((k=t==null?void 0:t.file)==null?void 0:k.numLines)??b.length,N=b.length>Fn,v=ms(p,N?Yt(p,Fn):null),j=m.useMemo(()=>e._highlightedContentHtml?Jw(e._highlightedContentHtml,Fn):null,[e._highlightedContentHtml]);return n?s.jsxs("div",{className:"write-collapsed-preview write-collapsed-error",children:[u&&c&&s.jsx(q,{toolName:"Write",errors:c}),s.jsx("span",{className:"write-preview-error",children:(t==null?void 0:t.content)||"Failed to write file"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"write-collapsed-preview",onClick:f,children:[s.jsxs("div",{className:"write-preview-lines",children:[s.jsx(Or,{displayPath:x})," · ",_," lines",u&&c&&s.jsx(q,{toolName:"Write",errors:c})]}),s.jsxs("div",{className:`write-preview-content ${N?"write-preview-truncated":""}`,...v,children:[j?s.jsx(ws,{html:j}):s.jsx("pre",{children:s.jsx("code",{children:b.slice(0,Fn).join(`
@@ -141,4 +141,4 @@ ${r}`:n}).join(`
141
141
  `:"",u=o?`command: ${o}
142
142
  `:"";return s.jsx("div",{className:"bash-tool-use",children:s.jsx("pre",{className:"code-block",children:s.jsx("code",{children:`${c}${d}${u}${a_(e)}
143
143
  ${l}`})})})},renderToolResult(e,t,n,r){if(ht(e)&&!(zn(r)==="Read"&&rn(r)))return s.jsx(Xr,{result:e,isError:t,shellMetadata:!0});const o=Hn(e),i=Me(o),a=zn(r),l=rn(r),c=u_(e,o),d=c?s.jsx("div",{className:"command-result-meta",children:c}):null;if(!i.output.trim()){const u=Ct(e).exitCode??i.exitCode;if(u!==void 0&&u!==0)return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"bash-empty",children:`Command exited with code ${u}`}),d]});const f=Xn(o);return f?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"bash-empty",children:`Still running — output continues as script cell ${f}`}),d]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"bash-empty",children:"No output"}),d]})}return a==="Read"&&l?s.jsx(ha,{filePath:l,output:i.output}):s.jsxs("div",{className:`bash-result ${t?"bash-result-error":""}`,children:[s.jsx(Ye,{sourceText:i.output,sourceView:s.jsx("pre",{className:`code-block ${t?"code-block-error":""}`,children:s.jsx(fn,{text:i.output})}),renderRenderedView:u=>f_(u,`code-block ${t?"code-block-error":""}`.trim())}),d]})},getUseSummary(e,t){const n=yc(e),r=Ys(e),o=fa(e,t);return r===void 0||r.length===0?o||"waiting for output":o?`${o} (input)`:`sent input (${n})`},getResultSummary(e,t){var h;const n=ht(e),r=n==null?void 0:n.parts.flatMap(g=>g.kind==="command-output"&&g.exitCode?[`rc=${g.exitCode}`]:[]);if(r!=null&&r.length)return r.join(" · ");if(n!=null&&n.parts.every(g=>g.kind==="script-status"))return(h=n.parts[0])!=null&&h.text.startsWith("Script running")?"still running":"No output";const o=Hn(e),i=Me(o,{bareExitCodeIsEnvelope:t}),a=Ct(e),l=a.exitCode??i.exitCode,c=a.durationSeconds!==void 0?et(a.durationSeconds):i.wallTime;if(l!==void 0&&l!==0)return c?`rc=${l} in ${c}`:`rc=${l}`;if(t)return"Error";const d=d_(e,o),u=g=>d?`${g} · ${d}`:g;if(!i.output.trim())return u(Xn(o)?"still running":"No output");const f=i.output.split(`
144
- `).filter(Boolean).length;return u(`${f} lines`)},renderInteractiveSummary(e,t,n,r){const o=zn(e),i=rn(e),a=Me(Hn(t),{bareExitCodeIsEnvelope:n}),l=!Ys(e)&&!i&&(!o||o==="Bash")?Jl(t,n):null;if(l){const{output:c,exitCode:d}=l;return s.jsxs("span",{className:Bn.summary,children:[s.jsx("span",{className:Bn.output,children:s.jsx(fn,{text:c})}),d!==void 0&&d!==0?s.jsxs("span",{className:Bn.failure,children:["rc=",d]}):n?s.jsx("span",{className:Bn.failure,children:"Error"}):null]})}return n||o!=="Read"||!i||!a.output.trim()?null:s.jsx(ha,{filePath:i,output:a.output,inline:!0})}}),p_={Bash:ig,Read:sj,Edit:zg,Write:n_,Glob:cx,Grep:Py,TodoWrite:_w,TaskCreate:nw,TaskUpdate:sw,Task:yw,WebSearch:Yw,WebFetch:Aw,Web:qw,AskUserQuestion:Pp,ExitPlanMode:Jg,UpdatePlan:Pw,WriteStdin:h_,create_goal:Mx,get_goal:$x,update_goal:Lx,ViewImage:Iw,spawn_agent:zv,Exec:pg,BashOutput:Lp,TaskOutput:Xv,KillShell:Oy,Skill:mj},g_=Object.values(p_),x_=new Map(g_.map(e=>[e.tool,e])),y_=de({input:ko(),result:ko(),variants:["unknown"],standaloneResult:!1},{tool:"__fallback__",renderToolUse:()=>null,renderToolResult:()=>null});function Bt(e){return x_.get(ll(e))}const ze={metadata(e){const t=Bt(e);return{registered:!!t,tool:(t==null?void 0:t.tool)??e,operations:(t==null?void 0:t.operations)??[]}},prepare(e,t){const n=Bt(e),r=(n??y_).prepare({...t,toolName:e});return n?r:{...r,getDisplayName:()=>e}},hasInteractiveSummary(e){var t;return((t=Bt(e))==null?void 0:t.operations.includes("renderInteractiveSummary"))??!1},hasCollapsedPreview(e){var t;return((t=Bt(e))==null?void 0:t.operations.includes("renderCollapsedPreview"))??!1},hasInlineRenderer(e){var t;return((t=Bt(e))==null?void 0:t.operations.includes("renderInline"))??!1},getDisplayName(e,t="complete",n){var r;return((r=Bt(e))==null?void 0:r.prepare({input:n,status:t}).getDisplayName())??e},renderToolUse(e,t,n){return this.prepare(e,{input:t,status:"pending"}).renderToolUse(n)},renderToolResult(e,t,n,r,o){return this.prepare(e,Mn(o,t,n,n?"error":"complete")).renderToolResult(r)},renderCollapsedPreview(e,t,n,r,o){return this.prepare(e,Mn(t,n,r)).renderCollapsedPreview(o)},renderInteractiveSummary(e,t,n,r,o){return this.prepare(e,Mn(t,n,r)).renderInteractiveSummary(o)},renderInline(e,t,n,r,o,i){return this.prepare(e,Mn(t,n,r,o)).renderInline(i)}},j_="_root_1ic9y_1",b_="_header_1ic9y_10",v_="_identity_1ic9y_19",w_="_title_1ic9y_26",__="_meta_1ic9y_34",N_="_readonly_1ic9y_42",k_="_status_1ic9y_43",S_="_actions_1ic9y_49",C_="_content_1ic9y_56",Qe={root:j_,header:b_,identity:v_,title:w_,meta:__,readonly:N_,status:k_,actions:S_,content:C_};function lN({projectId:e,sessionId:t,agentId:n,fallbackTitle:r,actions:o,headingLevel:i=2}){const{t:a}=Z(),[l,c]=m.useState(null),[d,u]=m.useState(null),[f,h]=m.useState(!0);m.useEffect(()=>{let y=!1;return h(!0),u(null),c(null),on.getAgentSession(e,t,n).then(x=>{y||c(x)}).catch(x=>{y||u(x instanceof Error?x.message:a("providerChildPageNotFound"))}).finally(()=>{y||h(!1)}),()=>{y=!0}},[n,e,t,a]);const g=(l==null?void 0:l.description)||(l==null?void 0:l.agentType)||r||a("providerChildFallback"),p=i===1?"h1":"h2";return s.jsxs("section",{className:Qe.root,children:[s.jsxs("header",{className:Qe.header,children:[s.jsxs("div",{className:Qe.identity,children:[s.jsx(p,{className:Qe.title,children:g}),s.jsxs("div",{className:Qe.meta,children:[(l==null?void 0:l.agentType)&&l.agentType!==g&&s.jsx("span",{children:l.agentType}),(l==null?void 0:l.status)&&s.jsx("span",{children:a(l.status==="running"?"providerChildStatusRunning":l.status==="completed"?"providerChildStatusCompleted":l.status==="failed"?"providerChildStatusFailed":"providerChildStatusPending")}),(l==null?void 0:l.spawnDepth)!==void 0&&s.jsx("span",{children:a("providerChildSpawnDepth",{count:l.spawnDepth})})]})]}),s.jsx("p",{className:Qe.readonly,children:a("providerChildPageReadOnly")}),o&&s.jsx("div",{className:Qe.actions,children:o})]}),s.jsxs("div",{className:Qe.content,children:[f&&s.jsx("p",{className:Qe.status,children:a("providerChildPageLoading")}),!f&&d&&s.jsx("p",{className:Qe.status,children:d}),!f&&!d&&l&&s.jsx(Gd,{projectId:e,projectPath:null,sessionId:t,sessionTitle:g,children:l.messages.length>0?s.jsx(uo,{messages:l.messages,isStreaming:l.status==="running"}):s.jsx("p",{className:Qe.status,children:a("providerChildPageEmpty")})})]})]})}export{q_ as A,Df as B,aN as C,jn as D,Qo as E,Ga as F,Ua as G,z_ as H,Zm as I,Fr as J,G_ as K,ff as L,W_ as M,Y_ as N,lN as P,iN as R,Ue as S,zb as T,al as U,Q_ as a,ll as b,V_ as c,tN as d,X_ as e,Hr as f,eN as g,mb as h,Qm as i,oN as j,J_ as k,ol as l,rN as m,Z_ as n,sN as o,K_ as p,Bv as q,Go as r,gj as s,ze as t,Dt as u,Nl as v,Lr as w,nN as x,Qn as y,ch as z};
144
+ `).filter(Boolean).length;return u(`${f} lines`)},renderInteractiveSummary(e,t,n,r){const o=zn(e),i=rn(e),a=Me(Hn(t),{bareExitCodeIsEnvelope:n}),l=!Ys(e)&&!i&&(!o||o==="Bash")?Jl(t,n):null;if(l){const{output:c,exitCode:d}=l;return s.jsxs("span",{className:Bn.summary,children:[s.jsx("span",{className:Bn.output,children:s.jsx(fn,{text:c})}),d!==void 0&&d!==0?s.jsxs("span",{className:Bn.failure,children:["rc=",d]}):n?s.jsx("span",{className:Bn.failure,children:"Error"}):null]})}return n||o!=="Read"||!i||!a.output.trim()?null:s.jsx(ha,{filePath:i,output:a.output,inline:!0})}}),p_={Bash:ig,Read:sj,Edit:zg,Write:n_,Glob:cx,Grep:Py,TodoWrite:_w,TaskCreate:nw,TaskUpdate:sw,Task:yw,WebSearch:Yw,WebFetch:Aw,Web:qw,AskUserQuestion:Pp,ExitPlanMode:Jg,UpdatePlan:Pw,WriteStdin:h_,create_goal:Mx,get_goal:$x,update_goal:Lx,ViewImage:Iw,spawn_agent:zv,Exec:pg,BashOutput:Lp,TaskOutput:Xv,KillShell:Oy,Skill:mj},g_=Object.values(p_),x_=new Map(g_.map(e=>[e.tool,e])),y_=de({input:ko(),result:ko(),variants:["unknown"],standaloneResult:!1},{tool:"__fallback__",renderToolUse:()=>null,renderToolResult:()=>null});function Bt(e){return x_.get(ll(e))}const ze={metadata(e){const t=Bt(e);return{registered:!!t,tool:(t==null?void 0:t.tool)??e,operations:(t==null?void 0:t.operations)??[]}},prepare(e,t){const n=Bt(e),r=(n??y_).prepare({...t,toolName:e});return n?r:{...r,getDisplayName:()=>e}},hasInteractiveSummary(e){var t;return((t=Bt(e))==null?void 0:t.operations.includes("renderInteractiveSummary"))??!1},hasCollapsedPreview(e){var t;return((t=Bt(e))==null?void 0:t.operations.includes("renderCollapsedPreview"))??!1},hasInlineRenderer(e){var t;return((t=Bt(e))==null?void 0:t.operations.includes("renderInline"))??!1},getDisplayName(e,t="complete",n){var r;return((r=Bt(e))==null?void 0:r.prepare({input:n,status:t}).getDisplayName())??e},renderToolUse(e,t,n){return this.prepare(e,{input:t,status:"pending"}).renderToolUse(n)},renderToolResult(e,t,n,r,o){return this.prepare(e,Mn(o,t,n,n?"error":"complete")).renderToolResult(r)},renderCollapsedPreview(e,t,n,r,o){return this.prepare(e,Mn(t,n,r)).renderCollapsedPreview(o)},renderInteractiveSummary(e,t,n,r,o){return this.prepare(e,Mn(t,n,r)).renderInteractiveSummary(o)},renderInline(e,t,n,r,o,i){return this.prepare(e,Mn(t,n,r,o)).renderInline(i)}},j_="_root_1ic9y_1",b_="_header_1ic9y_10",v_="_identity_1ic9y_19",w_="_title_1ic9y_26",__="_meta_1ic9y_34",N_="_readonly_1ic9y_42",k_="_status_1ic9y_43",S_="_actions_1ic9y_49",C_="_content_1ic9y_56",Qe={root:j_,header:b_,identity:v_,title:w_,meta:__,readonly:N_,status:k_,actions:S_,content:C_};function dN({projectId:e,sessionId:t,agentId:n,fallbackTitle:r,actions:o,headingLevel:i=2}){const{t:a}=Z(),[l,c]=m.useState(null),[d,u]=m.useState(null),[f,h]=m.useState(!0);m.useEffect(()=>{let y=!1;return h(!0),u(null),c(null),on.getAgentSession(e,t,n).then(x=>{y||c(x)}).catch(x=>{y||u(x instanceof Error?x.message:a("providerChildPageNotFound"))}).finally(()=>{y||h(!1)}),()=>{y=!0}},[n,e,t,a]);const g=(l==null?void 0:l.description)||(l==null?void 0:l.agentType)||r||a("providerChildFallback"),p=i===1?"h1":"h2";return s.jsxs("section",{className:Qe.root,children:[s.jsxs("header",{className:Qe.header,children:[s.jsxs("div",{className:Qe.identity,children:[s.jsx(p,{className:Qe.title,children:g}),s.jsxs("div",{className:Qe.meta,children:[(l==null?void 0:l.agentType)&&l.agentType!==g&&s.jsx("span",{children:l.agentType}),(l==null?void 0:l.status)&&s.jsx("span",{children:a(l.status==="running"?"providerChildStatusRunning":l.status==="completed"?"providerChildStatusCompleted":l.status==="failed"?"providerChildStatusFailed":"providerChildStatusPending")}),(l==null?void 0:l.spawnDepth)!==void 0&&s.jsx("span",{children:a("providerChildSpawnDepth",{count:l.spawnDepth})})]})]}),s.jsx("p",{className:Qe.readonly,children:a("providerChildPageReadOnly")}),o&&s.jsx("div",{className:Qe.actions,children:o})]}),s.jsxs("div",{className:Qe.content,children:[f&&s.jsx("p",{className:Qe.status,children:a("providerChildPageLoading")}),!f&&d&&s.jsx("p",{className:Qe.status,children:d}),!f&&!d&&l&&s.jsx(jd,{projectId:e,projectPath:null,sessionId:t,sessionTitle:g,children:l.messages.length>0?s.jsx(uo,{messages:l.messages,isStreaming:l.status==="running"}):s.jsx("p",{className:Qe.status,children:a("providerChildPageEmpty")})})]})]})}export{X_ as A,Df as B,cN as C,jn as D,Qo as E,Ga as F,Ua as G,K_ as H,Zm as I,Fr as J,q_ as K,ff as L,G_ as M,Q_ as N,dN as P,lN as R,Ue as S,zb as T,al as U,eN as a,ll as b,z_ as c,sN as d,J_ as e,Hr as f,nN as g,mb as h,Qm as i,aN as j,Z_ as k,ol as l,iN as m,tN as n,oN as o,Y_ as p,Bv as q,Go as r,gj as s,ze as t,Dt as u,Nl as v,Lr as w,rN as x,Qn as y,ch as z};