pisper 0.5.21-linux-x64.0 → 0.5.21

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 (290) hide show
  1. package/README.en.md +53 -0
  2. package/README.md +46 -46
  3. package/bin/pisper.mjs +48 -0
  4. package/lib/install.mjs +392 -0
  5. package/lib/npm-platform.mjs +41 -0
  6. package/lib/npm-update.mjs +165 -0
  7. package/lib/platform.mjs +43 -0
  8. package/lib/postinstall.mjs +3 -0
  9. package/package.json +36 -14
  10. package/updater.pubkey +1 -0
  11. package/web/.vite/manifest.json +2249 -0
  12. package/web/assets/AnimatedContent-BiVNqD3m.js +1 -0
  13. package/web/assets/AnimatedList-CJTx-B8I.js +1 -0
  14. package/web/assets/AppOverlays-C_v-1VL6.js +1 -0
  15. package/web/assets/AppSelect-g6etLk2g.js +1 -0
  16. package/web/assets/AssetsPage-Dt5ST6Ej.js +1 -0
  17. package/web/assets/ChannelsPage-C9dO2yLN.js +1 -0
  18. package/web/assets/ChatHistoryPage-ZvSTAtXB.js +1 -0
  19. package/web/assets/ChatPage-BD3WkozH.js +9 -0
  20. package/web/assets/ClickSpark-BhxL8WOQ.js +1 -0
  21. package/web/assets/ConfigPage-ifZdPO01.js +1 -0
  22. package/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  23. package/web/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  24. package/web/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  25. package/web/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  26. package/web/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  27. package/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  28. package/web/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  29. package/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  30. package/web/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  31. package/web/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  32. package/web/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  33. package/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  34. package/web/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  35. package/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  36. package/web/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  37. package/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  38. package/web/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  39. package/web/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  40. package/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  41. package/web/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  42. package/web/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  43. package/web/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  44. package/web/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  45. package/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  46. package/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  47. package/web/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  48. package/web/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  49. package/web/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  50. package/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  51. package/web/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  52. package/web/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  53. package/web/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  54. package/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  55. package/web/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  56. package/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  57. package/web/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  58. package/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  59. package/web/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  60. package/web/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  61. package/web/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  62. package/web/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  63. package/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  64. package/web/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  65. package/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  66. package/web/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  67. package/web/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  68. package/web/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  69. package/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  70. package/web/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  71. package/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  72. package/web/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  73. package/web/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  74. package/web/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  75. package/web/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  76. package/web/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  77. package/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  78. package/web/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  79. package/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  80. package/web/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  81. package/web/assets/MarkdownMessage-CMr3WuAI.js +1 -0
  82. package/web/assets/MemoryPage-D5Hjoc5p.js +1 -0
  83. package/web/assets/PageHeader-BKfO_vPe.js +1 -0
  84. package/web/assets/PluginsPage-DhkVJf05.js +1 -0
  85. package/web/assets/PreviewPages-mRjRmA0i.js +1 -0
  86. package/web/assets/SchedulesPage-DNe-Y6o5.js +1 -0
  87. package/web/assets/ShinyText-fuaKxKqJ.js +1 -0
  88. package/web/assets/SkillsPage-PguSYt8I.js +1 -0
  89. package/web/assets/StarOrbit-BlI6MhVr.js +1 -0
  90. package/web/assets/TerminalPanel-BrP-ENHg.css +1 -0
  91. package/web/assets/TerminalPanel-DrnfpA8m.js +18 -0
  92. package/web/assets/Threads-DskDSsK6.js +1 -0
  93. package/web/assets/WelcomeEffects-Bf8Z6qHU.js +1 -0
  94. package/web/assets/WorkflowsPage-C6sGl2oG.js +1 -0
  95. package/web/assets/WorkspacePicker-Cu2Z5jid.js +1 -0
  96. package/web/assets/alert-B7D8joCd.js +1 -0
  97. package/web/assets/alert-dialog-D5F_JQyX.js +1 -0
  98. package/web/assets/andromeeda-vGVdxbeo.js +1 -0
  99. package/web/assets/angular-html-17rlCfBS.js +1 -0
  100. package/web/assets/angular-ts-it3MaXWH.js +1 -0
  101. package/web/assets/astro-BEVDzCov.js +1 -0
  102. package/web/assets/aurora-x-CDeNXAV0.js +1 -0
  103. package/web/assets/ayu-dark-DluEY0Gj.js +1 -0
  104. package/web/assets/ayu-light-C3h-C4tm.js +1 -0
  105. package/web/assets/ayu-mirage-Bqwy1Gya.js +1 -0
  106. package/web/assets/blade-B3yUZIOx.js +1 -0
  107. package/web/assets/brand-CFOXmGdd.js +1 -0
  108. package/web/assets/button-DzlQCSNK.js +1 -0
  109. package/web/assets/c-aGSZMVdM.js +1 -0
  110. package/web/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
  111. package/web/assets/catppuccin-latte-CtsyrtPq.js +1 -0
  112. package/web/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
  113. package/web/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
  114. package/web/assets/chevron-down-DXmj1gMQ.js +1 -0
  115. package/web/assets/circle-dot-CbGG7s_7.js +1 -0
  116. package/web/assets/coffee-ouOQ86EC.js +1 -0
  117. package/web/assets/copy-DO0sQBgx.js +1 -0
  118. package/web/assets/cpp-Bm3vm43L.js +1 -0
  119. package/web/assets/css-CWcS1xXm.js +1 -0
  120. package/web/assets/csv-Dx-8-gkx.js +1 -0
  121. package/web/assets/dark-plus-Cs2F2srj.js +1 -0
  122. package/web/assets/dist-BaCXUSxG.js +1 -0
  123. package/web/assets/dist-Bv5OI2pf.js +1 -0
  124. package/web/assets/dracula-BHWKrbxM.js +1 -0
  125. package/web/assets/dracula-soft-5eyTD99u.js +1 -0
  126. package/web/assets/earth-D-KiHvdO.js +1 -0
  127. package/web/assets/es2015-CfKlxLgF.js +41 -0
  128. package/web/assets/everforest-dark-sB-x3p7T.js +1 -0
  129. package/web/assets/everforest-light-Df2xbC6M.js +1 -0
  130. package/web/assets/field-CCo2X7MX.js +1 -0
  131. package/web/assets/file-B6GksU4A.js +1 -0
  132. package/web/assets/file-code-corner-3gopYCm4.js +1 -0
  133. package/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  134. package/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  135. package/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  136. package/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  137. package/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  138. package/web/assets/github-dark-C-LZuMrd.js +1 -0
  139. package/web/assets/github-dark-default-DXG-b-1a.js +1 -0
  140. package/web/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
  141. package/web/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
  142. package/web/assets/github-light-EUqPIrTm.js +1 -0
  143. package/web/assets/github-light-default-BXViO-2h.js +1 -0
  144. package/web/assets/github-light-high-contrast-B68TUdTA.js +1 -0
  145. package/web/assets/glsl-TOBAB6bO.js +1 -0
  146. package/web/assets/graphql-BEmIBNve.js +1 -0
  147. package/web/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
  148. package/web/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
  149. package/web/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
  150. package/web/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
  151. package/web/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
  152. package/web/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
  153. package/web/assets/haml-CDWtFtU9.js +1 -0
  154. package/web/assets/handlebars-BNtjo3pL.js +1 -0
  155. package/web/assets/horizon-CE9ld1lL.js +1 -0
  156. package/web/assets/horizon-bright-DSNQnXHK.js +1 -0
  157. package/web/assets/houston-CsvMBhTu.js +1 -0
  158. package/web/assets/html-BVyvp26C.js +1 -0
  159. package/web/assets/html-derivative-BseLpURQ.js +1 -0
  160. package/web/assets/http-CkCfSMV9.js +1 -0
  161. package/web/assets/hurl-syYMt6Rn.js +1 -0
  162. package/web/assets/image-Bu_a9jz0.js +1 -0
  163. package/web/assets/imba-DsUTQ-LC.js +1 -0
  164. package/web/assets/index-BIQcwjFR.js +41 -0
  165. package/web/assets/index-Btu6aNk7.css +2 -0
  166. package/web/assets/java-duG_UTKe.js +1 -0
  167. package/web/assets/javascript-DWVbOe4X.js +1 -0
  168. package/web/assets/jinja-Boj4niAz.js +1 -0
  169. package/web/assets/jison-CHwnC1Pv.js +1 -0
  170. package/web/assets/json-qhed-kSA.js +1 -0
  171. package/web/assets/json5-BR5RXkoi.js +1 -0
  172. package/web/assets/jsonc-CYpm1nAK.js +1 -0
  173. package/web/assets/jsonl-CmCQp5Yx.js +1 -0
  174. package/web/assets/jsx-fcCEM_-L.js +1 -0
  175. package/web/assets/julia-VoF7UKfw.js +1 -0
  176. package/web/assets/kanagawa-dragon-Bozd7klA.js +1 -0
  177. package/web/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
  178. package/web/assets/kanagawa-wave-BML5mF2J.js +1 -0
  179. package/web/assets/laserwave-C_8bwKvT.js +1 -0
  180. package/web/assets/less-DVTAwKKz.js +1 -0
  181. package/web/assets/light-plus-DVQuIRkW.js +1 -0
  182. package/web/assets/link-2-SOWAopyR.js +1 -0
  183. package/web/assets/loader-circle-i0WYlBWu.js +1 -0
  184. package/web/assets/markdown-BYOwaDjH.js +1 -0
  185. package/web/assets/marko-Cupn1xhw.js +1 -0
  186. package/web/assets/material-theme-Bm3Qr25_.js +1 -0
  187. package/web/assets/material-theme-darker-2IIEA8gg.js +1 -0
  188. package/web/assets/material-theme-lighter-uhdI0v04.js +1 -0
  189. package/web/assets/material-theme-ocean-CHQ94UKr.js +1 -0
  190. package/web/assets/material-theme-palenight-B5W6OYN7.js +1 -0
  191. package/web/assets/mdc-4FfK5iWR.js +1 -0
  192. package/web/assets/mdx-DQZ5AkYe.js +1 -0
  193. package/web/assets/message-circle-C3tSGsW0.js +1 -0
  194. package/web/assets/min-dark-BSWPekZh.js +1 -0
  195. package/web/assets/min-light-DDpmG2fV.js +1 -0
  196. package/web/assets/monokai-B_bV9PQ9.js +1 -0
  197. package/web/assets/network-zt1ahOiz.js +1 -0
  198. package/web/assets/night-owl-DhmEMT88.js +1 -0
  199. package/web/assets/night-owl-light-eJ-hLW7d.js +1 -0
  200. package/web/assets/nord-Cb4Vim4T.js +1 -0
  201. package/web/assets/one-dark-pro-CLwyXe_n.js +1 -0
  202. package/web/assets/one-light-D7Lr4KcI.js +1 -0
  203. package/web/assets/panel-top-DYcS-wiY.js +1 -0
  204. package/web/assets/paperclip-t0nP1kBQ.js +1 -0
  205. package/web/assets/pencil-BOb7CieI.js +1 -0
  206. package/web/assets/php-CUREQQ7f.js +1 -0
  207. package/web/assets/pick-system-directory-BnIFt85A.js +1 -0
  208. package/web/assets/plastic-DQwYfKfQ.js +1 -0
  209. package/web/assets/play-V5zloi0R.js +1 -0
  210. package/web/assets/poimandres-DRFjx7u4.js +1 -0
  211. package/web/assets/postcss-BXeXVLqQ.js +1 -0
  212. package/web/assets/progress-DWkHIRCG.js +6 -0
  213. package/web/assets/pug-CQyGKZpv.js +1 -0
  214. package/web/assets/python-gzcpVVnB.js +1 -0
  215. package/web/assets/r-C5FwQflr.js +1 -0
  216. package/web/assets/react-bits-DQli9s7O.css +1 -0
  217. package/web/assets/red-DX1BQOs8.js +1 -0
  218. package/web/assets/regexp--aR2_iz7.js +1 -0
  219. package/web/assets/rolldown-runtime-B0Z9INg1.js +1 -0
  220. package/web/assets/rose-pine-aMsaMD1D.js +1 -0
  221. package/web/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
  222. package/web/assets/rose-pine-moon-DO-qXg-I.js +1 -0
  223. package/web/assets/sass-DXrisJhu.js +1 -0
  224. package/web/assets/save-CTsP04bb.js +1 -0
  225. package/web/assets/scss-Davl4E3T.js +1 -0
  226. package/web/assets/search-Chj7BjSz.js +1 -0
  227. package/web/assets/shellscript-CLZ0U2zV.js +1 -0
  228. package/web/assets/shield-check-By9gGYwr.js +1 -0
  229. package/web/assets/slack-dark-DnToyrRv.js +1 -0
  230. package/web/assets/slack-ochin-B2OO5cIa.js +1 -0
  231. package/web/assets/smithy-Dgaz7aur.js +1 -0
  232. package/web/assets/snazzy-light-4G7pJPwS.js +1 -0
  233. package/web/assets/solarized-dark-UdsmMDCL.js +1 -0
  234. package/web/assets/solarized-light-C1IUL_tW.js +1 -0
  235. package/web/assets/sql-b92rrcVl.js +1 -0
  236. package/web/assets/square-DQQwOv3-.js +1 -0
  237. package/web/assets/square-terminal-ByK0g_OZ.js +1 -0
  238. package/web/assets/stylus-B6D30XZt.js +1 -0
  239. package/web/assets/sun-CiCuEpCg.js +1 -0
  240. package/web/assets/svelte-BfstjgUc.js +1 -0
  241. package/web/assets/synthwave-84-nFMaYfgc.js +1 -0
  242. package/web/assets/tag-B0fT5ThM.js +1 -0
  243. package/web/assets/tokyo-night-oM2G3aXe.js +1 -0
  244. package/web/assets/trash-2-2GzVxk5J.js +1 -0
  245. package/web/assets/ts-tags-Cckpt1jI.js +1 -0
  246. package/web/assets/tsx-JMDX3aQ7.js +1 -0
  247. package/web/assets/typescript-BAz-bF8J.js +1 -0
  248. package/web/assets/use-i18n-DmLwOjO5.js +1 -0
  249. package/web/assets/usePagePrimaryAction-Bw0OFTDZ.js +1 -0
  250. package/web/assets/utils-C8uzG5AZ.js +1 -0
  251. package/web/assets/vendor-dockview-D5adAaCg.css +1 -0
  252. package/web/assets/vendor-dockview-yY5mBM3U.js +1 -0
  253. package/web/assets/vendor-markdown-CWK5AVhB.js +130 -0
  254. package/web/assets/vendor-markdown-plugins-DCl4I7Pz.js +263 -0
  255. package/web/assets/vendor-motion-XxgxfZSY.js +9 -0
  256. package/web/assets/vendor-react-CHuvPdJE.js +9 -0
  257. package/web/assets/vendor-router-Bw2aAdMs.js +4 -0
  258. package/web/assets/vendor-shiki-runtime-CxE5QolQ.js +153 -0
  259. package/web/assets/vendor-state-DE1O_s6m.js +1 -0
  260. package/web/assets/vendor-ui-DvrYggeS.js +1 -0
  261. package/web/assets/vendor-xyflow-CnjXtcyK.js +7 -0
  262. package/web/assets/vendor-xyflow-DLioOiRN.css +1 -0
  263. package/web/assets/vesper-DdrHHSXu.js +1 -0
  264. package/web/assets/vitesse-black-fwtXNY1n.js +1 -0
  265. package/web/assets/vitesse-dark-BZCL-v6S.js +1 -0
  266. package/web/assets/vitesse-light-VbXTXTou.js +1 -0
  267. package/web/assets/vue-3H7P6ncC.js +1 -0
  268. package/web/assets/vue-html-DZGW9MGR.js +1 -0
  269. package/web/assets/vue-vine-BECt67gq.js +1 -0
  270. package/web/assets/wasm-BnjxR4X6.js +1 -0
  271. package/web/assets/wasm-ByWQv1Qj.js +1 -0
  272. package/web/assets/wgsl-BsKzXJz4.js +1 -0
  273. package/web/assets/wit-DdvCle-K.js +1 -0
  274. package/web/assets/wrench-DkHcVlxK.js +1 -0
  275. package/web/assets/xml-CNfvW5JP.js +1 -0
  276. package/web/assets/yaml-rwi0_p6S.js +1 -0
  277. package/web/assets/zap-CRNpJWAy.js +1 -0
  278. package/web/favicon.svg +25 -0
  279. package/web/icons.svg +24 -0
  280. package/web/index.html +72 -0
  281. package/web/memory-galaxy-background.webp +0 -0
  282. package/web/mobile-startup.html +316 -0
  283. package/web/notification-sw.js +13 -0
  284. package/web/tauri-pet.css +117 -0
  285. package/web/tauri-pet.html +16 -0
  286. package/web/tauri-pet.js +117 -0
  287. package/components/runtime/Pisper_Runtime_Node_0.5.20_linux_x86_64.tar.gz +0 -0
  288. package/components/runtime/Pisper_Runtime_Node_0.5.20_linux_x86_64.tar.gz.sig +0 -1
  289. package/components/tui/Pisper_TUI_Component_0.5.12_linux_x86_64.tar.gz +0 -0
  290. package/components/tui/Pisper_TUI_Component_0.5.12_linux_x86_64.tar.gz.sig +0 -1
@@ -0,0 +1,9 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnimatedContent-BiVNqD3m.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-CHuvPdJE.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/vendor-motion-XxgxfZSY.js","assets/AnimatedList-CJTx-B8I.js","assets/react-bits-DQli9s7O.css","assets/ShinyText-fuaKxKqJ.js","assets/WelcomeEffects-Bf8Z6qHU.js","assets/ClickSpark-BhxL8WOQ.js","assets/Threads-DskDSsK6.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n,t as r}from"./vendor-react-CHuvPdJE.js";import{f as i}from"./vendor-router-Bw2aAdMs.js";import{a,n as o,r as s,s as c,t as l}from"./button-DzlQCSNK.js";import{d as u,h as d,m as f,o as p,p as m,s as h,t as g,u as _}from"./use-i18n-DmLwOjO5.js";import{a as v,i as y,r as b,t as x}from"./dist-BaCXUSxG.js";import{a as S,i as C,n as w,r as T,s as E,t as D,u as O}from"./es2015-CfKlxLgF.js";import{n as k}from"./dist-Bv5OI2pf.js";import{_ as A,a as j,c as M,f as N,g as P,i as F,l as I,n as L,o as R,p as ee,r as z,s as te,t as ne}from"./alert-dialog-D5F_JQyX.js";import{n as B,t as re}from"./AppSelect-g6etLk2g.js";import{i as ie,n as ae,r as oe,t as se}from"./progress-DWkHIRCG.js";import{i as ce,n as le,r as ue,t as de}from"./WorkspacePicker-Cu2Z5jid.js";import{t as V}from"./utils-C8uzG5AZ.js";import{i as H,n as fe,r as pe,t as me}from"./MarkdownMessage-CMr3WuAI.js";import{t as he}from"./chevron-down-DXmj1gMQ.js";import{t as ge}from"./circle-dot-CbGG7s_7.js";import{n as _e}from"./copy-DO0sQBgx.js";import{t as ve}from"./earth-D-KiHvdO.js";import{t as ye}from"./file-B6GksU4A.js";import{t as be}from"./loader-circle-i0WYlBWu.js";import{n as xe,r as Se,t as Ce}from"./panel-top-DYcS-wiY.js";import{t as U}from"./paperclip-t0nP1kBQ.js";import{t as we}from"./pencil-BOb7CieI.js";import{t as Te}from"./search-Chj7BjSz.js";import{t as Ee}from"./shield-check-By9gGYwr.js";import{t as De}from"./square-DQQwOv3-.js";import{t as Oe}from"./tag-B0fT5ThM.js";import{t as ke}from"./trash-2-2GzVxk5J.js";import{t as Ae}from"./wrench-DkHcVlxK.js";import{$ as je,A as Me,B as W,Bt as Ne,Dt as G,F as K,Ft as Pe,G as Fe,Gt as Ie,H as q,Ht as Le,I as Re,It as ze,K as Be,Kt as Ve,L as He,M as Ue,N as We,Nt as Ge,O as J,P as Ke,Pt as qe,Q as Je,Rt as Ye,St as Xe,Ut as Ze,V as Qe,W as $e,Wt as et,X as tt,Z as nt,at as rt,bt as it,ct as at,d as ot,dt as st,et as ct,f as Y,ft as lt,ht as ut,it as dt,j as ft,jt as pt,kt as mt,lt as ht,m as gt,mt as _t,n as vt,nt as yt,ot as bt,pt as xt,q as St,r as Ct,rt as wt,s as Tt,st as Et,t as Dt,tt as Ot,u as kt,ut as At,wt as jt,xt as Mt,yt as Nt,zt as Pt}from"./index-BIQcwjFR.js";import{t as Ft}from"./vendor-motion-XxgxfZSY.js";import{t as It}from"./usePagePrimaryAction-Bw0OFTDZ.js";import{n as Lt}from"./brand-CFOXmGdd.js";import{t as Rt}from"./vendor-dockview-yY5mBM3U.js";import{n as zt,t as Bt}from"./alert-B7D8joCd.js";import{n as Vt,t as Ht}from"./pick-system-directory-BnIFt85A.js";var X=e(t(),1),Z=r(),Ut=Object.defineProperty,Wt=(e,t)=>Ut(e,`name`,{value:t,configurable:!0}),Gt=`Collapsible`,[Kt,qt]=f(Gt),[Jt,Yt]=Kt(Gt),Xt=X.forwardRef(Wt(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=u({prop:r,defaultProp:i??!1,onChange:o,caller:Gt});return(0,Z.jsx)(Jt,{scope:n,disabled:a,contentId:k(),open:c,onOpenToggle:X.useCallback(()=>l(e=>!e),[l]),children:(0,Z.jsx)(d.div,{"data-state":Zt(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`));function Zt(e){return e?`open`:`closed`}Wt(Zt,`getState`);var Qt=Xt,$t=Object.defineProperty,en=(e,t)=>$t(e,`name`,{value:t,configurable:!0}),tn=`Checkbox`,[nn,rn]=f(tn),[an,on]=nn(tn);function sn(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:d=`on`,internal_do_not_use_render:f}=e,[p,m]=u({prop:n,defaultProp:i??!1,onChange:c,caller:tn}),[h,g]=X.useState(null),[_,v]=X.useState(null),y=X.useRef(!1),[b,x]=X.useReducer(e=>e+1,0),S=!h||!!o||!!h.closest(`form`),C={checked:p,disabled:a,setChecked:m,control:h,setControl:g,name:s,form:o,value:d,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:!gn(i)&&i,isFormControl:S,bubbleInput:_,setBubbleInput:v};return(0,Z.jsx)(an,{scope:t,...C,children:hn(f)?f(C):r})}en(sn,`CheckboxProvider`);var cn=`CheckboxTrigger`,ln=X.forwardRef(en(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:l,required:u,setControl:f,setChecked:p,hasConsumerStoppedPropagationRef:h,onUserInteraction:g,isFormControl:_,bubbleInput:v}=on(cn,e),y=c(i,f),b=X.useRef(l);return X.useEffect(()=>{let e=a?.form;if(e){let t=en(()=>p(b.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,p]),(0,Z.jsx)(d.button,{type:`button`,role:`checkbox`,"aria-checked":gn(l)?`mixed`:l,"aria-required":u,"data-state":_n(l),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:y,onKeyDown:m(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:m(n,e=>{g(),p(e=>gn(e)?!0:!e),v&&_&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})})},`CheckboxTrigger`)),un=X.forwardRef(en(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Z.jsx)(sn,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ln,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Z.jsx)(mn,{__scopeCheckbox:n})]})})},`Checkbox`)),dn=`CheckboxIndicator`,fn=X.forwardRef(en(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=on(dn,n);return(0,Z.jsx)(O,{present:r||gn(a.checked)||a.checked===!0,children:(0,Z.jsx)(d.span,{"data-state":_n(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),pn=`CheckboxBubbleInput`,mn=X.forwardRef(en(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:l,required:u,disabled:f,name:p,value:h,form:g,bubbleInput:v,setBubbleInput:y}=on(pn,e),b=c(r,y),x=_(i),S=X.useRef(!1),C=X.useRef(s),w=X.useRef(o);X.useEffect(()=>{let e=v;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==w.current;w.current=o;let i=C.current!==s;C.current=s;let c=!(r&&a.current);if(i&&n){S.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=gn(s),n.call(e,!gn(s)&&s),e.dispatchEvent(t),S.current=!1}},[v,s,a,o]);let T=X.useRef(!gn(s)&&s);return(0,Z.jsx)(d.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:l??T.current,required:u,disabled:f,name:p,value:h,form:g,...n,tabIndex:-1,ref:b,onClick:m(t,e=>{S.current&&e.stopPropagation()}),style:{...n.style,...x,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function hn(e){return typeof e==`function`}en(hn,`isFunction`);function gn(e){return e===`indeterminate`}en(gn,`isIndeterminate`);function _n(e){return gn(e)?`indeterminate`:e?`checked`:`unchecked`}en(_n,`getState`);var vn=Object.defineProperty,yn=(e,t)=>vn(e,`name`,{value:t,configurable:!0}),bn=`Popover`,[xn,Sn]=f(bn,[v]),Cn=v(),[wn,Tn]=xn(bn),En=yn(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Cn(t),c=X.useRef(null),[l,d]=X.useState(!1),[f,p]=u({prop:r,defaultProp:i??!1,onChange:a,caller:bn});return(0,Z.jsx)(y,{...s,children:(0,Z.jsx)(wn,{scope:t,contentId:k(),triggerRef:c,open:f,onOpenChange:p,onOpenToggle:X.useCallback(()=>p(e=>!e),[p]),hasCustomAnchor:l,onCustomAnchorAdd:X.useCallback(()=>d(!0),[]),onCustomAnchorRemove:X.useCallback(()=>d(!1),[]),modal:o,children:n})})},`Popover`),Dn=`PopoverTrigger`,On=X.forwardRef(yn(function(e,t){let{__scopePopover:n,...r}=e,i=Tn(Dn,n),a=Cn(n),o=c(t,i.triggerRef),s=(0,Z.jsx)(d.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":zn(i.open),...r,ref:o,onClick:m(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Z.jsx)(x,{asChild:!0,...a,children:s})},`PopoverTrigger`)),kn=`PopoverPortal`,[An,jn]=xn(kn,{forceMount:void 0}),Mn=yn(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Tn(kn,t);return(0,Z.jsx)(An,{scope:t,forceMount:n,children:(0,Z.jsx)(O,{present:n||a.open,children:(0,Z.jsx)(C,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),Nn=`PopoverContent`,Pn=X.forwardRef(yn(function(e,t){let n=jn(Nn,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Tn(Nn,e.__scopePopover);return(0,Z.jsx)(O,{present:r||a.open,children:a.modal?(0,Z.jsx)(In,{...i,ref:t}):(0,Z.jsx)(Ln,{...i,ref:t})})},`PopoverContent`)),Fn=a(`PopoverContent.RemoveScroll`),In=X.forwardRef(yn(function(e,t){let n=Tn(Nn,e.__scopePopover),r=X.useRef(null),i=c(t,r),a=X.useRef(!1);return X.useEffect(()=>{let e=r.current;if(e)return D(e)},[]),(0,Z.jsx)(w,{as:Fn,allowPinchZoom:!0,children:(0,Z.jsx)(Rn,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:m(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:m(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:m(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),Ln=X.forwardRef(yn(function(e,t){let n=Tn(Nn,e.__scopePopover),r=X.useRef(!1),i=X.useRef(!1);return(0,Z.jsx)(Rn,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),Rn=X.forwardRef(yn(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Tn(Nn,n),p=Cn(n);return T(),(0,Z.jsx)(S,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(E,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,Z.jsx)(b,{"data-state":zn(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function zn(e){return e?`open`:`closed`}yn(zn,`getState`);var Bn=En,Vn=On,Hn=Mn,Un=Pn,Wn=o(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Gn=o(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Kn=o(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),qn=o(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Jn=o(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Yn=o(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),Xn=o(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),Zn=o(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Qn=o(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),$n=o(`file-check-corner`,[[`path`,{d:`M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6`,key:`g5mvt7`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14 20 2 2 4-4`,key:`15kota`}]]),er=o(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),tr=o(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),nr=o(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),rr=o(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),ir=o(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),ar=o(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),or=o(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),sr=o(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),cr=o(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),lr=o(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),ur=o(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),dr=o(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),fr=o(`search-check`,[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),pr=o(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),mr=o(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),hr=o(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),gr=o(`tree-pine`,[[`path`,{d:`m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z`,key:`cpyugq`}],[`path`,{d:`M12 22v-3`,key:`kmzjlo`}]]),_r=o(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),vr=o(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),yr=o(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),br=o(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]);function xr(e){if(!(!e||typeof e!=`object`)){if(Object.hasOwn(e,`plan`))return e.plan??null;if(Object.hasOwn(e,`taskList`))return e.taskList??null}}function Sr(e,t){let n=xr(e);return n===void 0?t:n}function Cr(e){return e===`plan_update`||e===`task_list_update`}function wr(e){return e===`get_plan`||e===`get_task_list`}function Tr(e){return e===`update_plan`||e===`update_task_list`}function Er(e){return wr(e)||Tr(e)}function Dr(e){return xr(e)}var Or=Object.freeze({messages:[],tools:[],approvals:[],agents:[],currentActivity:null,activityFeed:[],lifecycle:null,sessionTreeRevision:0,thinkingText:``,queuedInputs:[],hadQueuedInput:!1,plan:null,executionMode:null,contextUsage:null,sessionUsage:null,promptCache:null,compaction:null,streaming:!1,error:``,loaded:!1,messageStart:null,hasOlder:!1,olderCursor:null});function kr(e,t){if(e===t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!0;return!1}function Ar(e,t){let n=e||Or,r=typeof t==`function`?t(n):{...n,...t};return kr(n,r)?r:n}function jr(e,t){return t===void 0?e||[]:Array.isArray(t)?t:[]}function Mr(e=[],t){let n=Array.isArray(e)?e:[],r=-1;for(let e=n.length-1;e>=0;--e)if(n[e]?.role===`agent`){r=e;break}return r<0?[...n,t]:[...n.slice(0,r),t,...n.slice(r)]}function Nr(e){return!!(e?.streaming||e?.recovering||e?.agents?.some(e=>[`queued`,`starting`,`running`].includes(e.status)))}function Pr(e){return!!(e&&(e.streaming||String(e.thinkingText||``).trim()||e.tools?.length||e.currentActivity?.type===`agent`||e.activityFeed?.some(e=>e.type===`agent`)))}function Fr(e,t,n){return t&&Pr(n)?n:Pr(e.runActivity)?e.runActivity:null}function Ir(e,t){if(e&&(e.loaded||e.streaming||xr(e)!==void 0))return Sr(e,null);let n=xr(t);return n===void 0?Sr(e,null):n}function Lr(e,t={}){return!!e?.items?.length}function Rr({...e}){return(0,Z.jsx)(Qt,{"data-slot":`collapsible`,...e})}var zr=({className:e,defaultOpen:t=!0,...n})=>(0,Z.jsx)(Rr,{className:V(e),defaultOpen:t,...n}),Br=10485760,Vr=20971520,Hr=new Set([`txt`,`md`,`json`,`js`,`jsx`,`ts`,`tsx`,`css`,`html`,`xml`,`yaml`,`yml`,`csv`,`log`,`py`,`java`,`go`,`rs`,`sh`,`ps1`,`toml`,`sql`]),Ur=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),Wr=new Set([`pdf`,`docx`,`pptx`,`xlsx`,`odt`,`odp`,`ods`,`rtf`,`epub`]),Gr=[`image/*`,`text/*`,`application/json`,...[...Ur,...Hr,...Wr].map(e=>`.${e}`)].join(`,`);function Kr(e){let t=[...e?.files||[]];return t.length?t:[...e?.items||[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile?.()).filter(e=>!!e)}function qr(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(String(i.result).split(`,`)[1]||``),i.onerror=()=>r(i.error||Error(t(`chat:attachments.couldNotReadFile`))),i.readAsDataURL(e)})}function Jr(e){return e.toLowerCase().split(`.`).at(-1)||``}async function Yr(e,t){let n=[...e].slice(0,8),r=[];for(let e of n){if(e.size>Br)throw Error(t(`chat:attachments.nameExceedsThe10MBLimit`,{name:e.name}));let n=Jr(e.name),i={id:`${e.name}-${e.lastModified}-${e.size}`,name:e.name,mimeType:e.type||`application/octet-stream`,size:e.size};if(e.type.startsWith(`image/`)||Ur.has(n))r.push({...i,kind:`image`,data:await qr(e,t)});else if(e.type.startsWith(`text/`)||e.type===`application/json`||Hr.has(n))r.push({...i,kind:`text`,text:await e.text()});else if(Wr.has(n))r.push({...i,kind:`document`,extension:n,data:await qr(e,t)});else throw Error(t(`chat:attachments.nameIsNotSupportedChooseAnImageOrTextCodeFile`,{name:e.name}))}return r}function Xr(e){return e.split(/[\\/]/).filter(Boolean).at(-1)||e}function Zr(e){return[...e].map(e=>String(e||``).trim()).filter(Boolean).slice(0,8).map(e=>({id:`path:${e}`,kind:`path`,name:Xr(e),path:e}))}function Qr(e=[],t){let n=(0,X.useCallback)((e,t)=>h(e,p(),t),[]),[r,i]=(0,X.useState)(()=>[...e]),[a,o]=(0,X.useState)(``),s=(0,X.useRef)([...e]),c=(0,X.useCallback)(e=>{s.current=e,i(e),t?.(e)},[t]),l=(0,X.useCallback)(async e=>{try{o(``);let t=await Yr(e||[],n),r=[...s.current,...t].slice(0,8);if(r.filter(e=>e.kind!==`path`).reduce((e,t)=>e+(t.size||0),0)>Vr)throw Error(n(`chat:attachments.totalAttachmentSizeCannotExceed20MB`));return c(r),!0}catch(e){return o(e instanceof Error?e.message:String(e)),!1}},[c,n]);return{attachments:r,attachmentError:a,addFiles:l,pasteFiles:(0,X.useCallback)(e=>{let t=Kr(e.clipboardData);t.length&&(e.preventDefault(),l(t))},[l]),removeAttachment:(0,X.useCallback)(e=>{c(s.current.filter(t=>t.id!==e))},[c]),clearAttachments:(0,X.useCallback)(()=>c([]),[c]),addAttachments:(0,X.useCallback)(e=>{o(``);let t=[...s.current];for(let n of e)t.some(e=>e.id===n.id)||t.push(n);c(t.slice(0,8))},[c]),replaceAttachments:c,setError:(0,X.useCallback)(e=>{o(e instanceof Error?e.message:String(e||``))},[])}}function $r({className:e,...t}){return(0,Z.jsx)(un,{"data-slot":`checkbox`,className:V(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,e),...t,children:(0,Z.jsx)(fn,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Z.jsx)(B,{})})})}function ei({open:e,initialPath:t,onOpenChange:n,onSelect:r}){let{t:i}=g(),[a,o]=(0,X.useState)(t||``),[s,c]=(0,X.useState)(null),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),_=(0,X.useRef)(0),v=(0,X.useCallback)(async e=>{let t=++_.current;p(!0),h(``);try{let n=await Fe(`/api/workspace-entries?path=${encodeURIComponent(e.trim())}`);if(t!==_.current)return;o(n.path),c(n),d([])}catch(e){if(t!==_.current)return;h(e instanceof Error?e.message:String(e))}finally{t===_.current&&p(!1)}},[]);(0,X.useEffect)(()=>{if(!e){_.current+=1;return}o(t||``),c(null),d([]),v(t||``)},[v,t,e]);let y=e=>{e.preventDefault(),v(a)},b=(e,t)=>{d(n=>t?[...n.filter(t=>t!==e),e].slice(-8):n.filter(t=>t!==e))};return(0,Z.jsx)(Me,{open:e,onOpenChange:n,children:(0,Z.jsxs)(ft,{className:`max-w-[calc(100vw-24px)]! gap-0 overflow-hidden p-0 sm:max-w-[680px]!`,children:[(0,Z.jsxs)(Ke,{className:`border-b px-4 py-3 pr-12`,children:[(0,Z.jsx)(K,{children:i(`chat:pathAttachmentPicker.title`)}),(0,Z.jsx)(Ue,{children:i(`chat:pathAttachmentPicker.description`)})]}),(0,Z.jsxs)(`form`,{className:`flex min-w-0 items-center gap-2 px-4 py-3`,onSubmit:y,children:[(0,Z.jsx)(l,{type:`button`,variant:`outline`,size:`icon`,title:i(`common:workspacePicker.parentFolder`),"aria-label":i(`common:workspacePicker.parentFolder`),disabled:f||!s?.parent,onClick:()=>s?.parent&&void v(s.parent),children:(0,Z.jsx)(ce,{})}),(0,Z.jsx)(W,{className:`min-w-0 flex-1 font-mono text-[12px]`,value:a,"aria-label":i(`chat:pathAttachmentPicker.directoryPath`),onChange:e=>o(e.target.value)}),(0,Z.jsxs)(l,{type:`submit`,variant:`secondary`,disabled:f||!a.trim(),children:[f?(0,Z.jsx)(be,{className:`animate-spin`}):(0,Z.jsx)(Ye,{}),i(`common:workspacePicker.go`)]})]}),(0,Z.jsx)(le,{className:`h-[min(400px,50dvh)] border-y bg-muted/20`,children:(0,Z.jsxs)(`div`,{className:`p-2`,children:[s?.directories.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`grid h-9 w-full grid-cols-[24px_minmax(0,1fr)_20px] items-center rounded-md px-2 text-left text-[13px] hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,title:e.path,disabled:f,onClick:()=>void v(e.path),children:[(0,Z.jsx)(ue,{className:`size-4 text-content-muted`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Z.jsx)(Ye,{className:`size-4 text-content-muted`})]},e.path)),s?.files.map(e=>{let t=u.includes(e.path);return(0,Z.jsxs)(`label`,{className:`grid h-9 cursor-pointer grid-cols-[24px_minmax(0,1fr)_24px] items-center rounded-md px-2 text-[13px] hover:bg-muted`,title:e.path,children:[(0,Z.jsx)(ye,{className:`size-4 text-content-muted`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Z.jsx)($r,{checked:t,"aria-label":i(`chat:pathAttachmentPicker.selectName`,{name:e.name}),onCheckedChange:t=>b(e.path,t===!0)})]},e.path)}),f&&(0,Z.jsxs)(`div`,{className:`flex h-32 items-center justify-center gap-2 text-content-muted`,children:[(0,Z.jsx)(be,{className:`size-4 animate-spin`}),(0,Z.jsx)(`span`,{children:i(`common:workspacePicker.readingFolder`)})]}),!f&&s&&!s.directories.length&&!s.files.length&&(0,Z.jsx)(`div`,{className:`flex h-32 items-center justify-center text-content-muted`,children:i(`chat:pathAttachmentPicker.empty`)})]})}),m&&(0,Z.jsxs)(Bt,{variant:`destructive`,className:`mx-4 mt-3 w-auto`,children:[(0,Z.jsx)(Xe,{}),(0,Z.jsx)(zt,{children:m})]}),(0,Z.jsxs)(We,{className:`m-0 border-t-0 bg-transparent px-4 py-3`,children:[(0,Z.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:i(`common:ui.cancel`)}),(0,Z.jsx)(l,{type:`button`,variant:`secondary`,disabled:!u.length,onClick:()=>{u.length&&(r(u),n(!1))},children:i(`chat:pathAttachmentPicker.attachCount`,{count:u.length})})]})]})})}function ti({cwd:e,selection:t}){let{t:n}=g(),r=He(),[i,a]=(0,X.useState)(!1),o=(0,X.useRef)(null),s=async()=>{if(r){o.current?.click();return}if(window.pisperDesktop?.pickFiles){try{let n=await window.pisperDesktop.pickFiles(e);t.addAttachments(Zr(n||[]))}catch(e){t.setError(e)}return}a(!0)};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`input`,{ref:o,type:`file`,className:`hidden`,accept:Gr,multiple:!0,"aria-label":n(`chat:focusSession.addAttachment`),onChange:e=>{let n=[...e.currentTarget.files||[]];e.currentTarget.value=``,n.length&&t.addFiles(n)}}),(0,Z.jsxs)(`button`,{type:`button`,className:`attach-trigger [.focus-composer_&]:h-[38px] [.focus-composer_&]:border-0 [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-composer_&]:bg-[var(--surface-subtle)] [.focus-composer_&]:text-[12px] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] relative grid place-items-center border-0 rounded-[var(--r-xs)] bg-transparent text-[var(--text-muted)] cursor-pointer hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)] [&_i]:absolute [&_i]:top-[-4px] [&_i]:right-[-4px] [&_i]:grid [&_i]:min-w-[14px] [&_i]:h-[14px] [&_i]:place-items-center [&_i]:[border:2px_solid_var(--solid)] [&_i]:rounded-[var(--r-pill)] [&_i]:bg-[var(--blue)] [&_i]:text-[var(--on-accent)] [&_i]:p-[0_3px] [&_i]:text-[13px] [&_i]:[font-style:normal]`,title:n(`chat:focusSession.addAttachment`),"aria-label":n(`chat:focusSession.addAttachment`),onClick:()=>void s(),children:[(0,Z.jsx)(U,{size:17}),t.attachments.length>0&&(0,Z.jsx)(`i`,{children:t.attachments.length})]}),(0,Z.jsx)(ei,{open:i,initialPath:e,onOpenChange:a,onSelect:e=>t.addAttachments(Zr(e))})]})}function ni({open:e,sessionId:t,onClose:n,onSelect:r,onCommandSelect:i}){let{t:a}=g(),o=Re(e=>e.capabilities),s=Nt(o,`workflows`),[c,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(`all`),[p,m]=(0,X.useState)(``),[h,_]=(0,X.useState)(null),[v,y]=(0,X.useState)({}),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(``);(0,X.useEffect)(()=>{if(!e)return;let n=!0;return f(`all`),m(``),_(null),y({}),x(!0),C(``),Promise.all([J.getSessionCommands(t),s?Fe(`/api/workflows`):Promise.resolve({workflows:[]}),Fe(`/api/plugins?sessionId=${encodeURIComponent(t)}`)]).then(([e,t,r])=>{if(!n)return;let i=new Set(r.callableToolNames||[]);u([...(e.commands||[]).map(e=>({kind:e.source,id:e.name,name:e.name,description:e.description||``,inputs:[],argumentHint:e.argumentHint,invocation:e.invocation})),...(t.workflows||[]).filter(e=>e.status===`published`).map(e=>({kind:`workflow`,id:e.id,name:e.name,description:e.description||``,inputs:e.inputs||[]})),...(r.plugins||[]).flatMap(e=>(e.capabilities||[]).filter(e=>i.has(e.name)).map(t=>({kind:`tool`,id:t.name,name:t.id?ee(t,a):String(t.label||t.name),description:t.id?N(t,a):t.description,inputs:[],sourceName:e.name})))])}).catch(e=>{n&&(u([]),C(e instanceof Error?e.message:String(e)))}).finally(()=>n&&x(!1)),()=>{n=!1}},[e,t,a,s]);let w=(0,X.useMemo)(()=>({all:c.length,prompt:c.filter(e=>e.kind===`prompt`).length,skill:c.filter(e=>e.kind===`skill`).length,tool:c.filter(e=>e.kind===`tool`).length,workflow:c.filter(e=>e.kind===`workflow`).length}),[c]),T=(0,X.useMemo)(()=>{let e=p.trim().toLowerCase();return c.filter(t=>(d===`all`||t.kind===d)&&(!e||`${t.name} ${t.id} ${t.description} ${t.kind===`tool`?t.sourceName:``}`.toLowerCase().includes(e)))},[d,p,c]),E=e=>{let t=e;f(t),h&&t!==`all`&&h.kind!==t&&_(null)},D=e=>{_(e),y(Object.fromEntries(e.inputs.map(e=>[e.name,e.defaultValue??``])))};return(0,Z.jsx)(Me,{open:e,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(ft,{className:`chat-resource-dialog w-[min(820px,calc(100vw_-_32px))] h-[min(600px,calc(100dvh_-_32px))] max-w-[820px] sm:max-w-[820px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden max-[650px]:w-[calc(100vw_-_16px)] max-[650px]:h-[calc(100dvh_-_16px)] z-[220] gap-0 p-0 ring-0`,overlayClassName:`z-[220]`,showCloseButton:!1,children:[(0,Z.jsxs)(`div`,{className:`chat-resource-head [&_[data-slot='dialog-title']]:text-[16px] [&_[data-slot='dialog-description']]:mt-[3px] [&_[data-slot='dialog-description']]:text-[12px] max-[650px]:p-[14px] flex items-start justify-between gap-[16px] [border-bottom:1px_solid_var(--stroke-soft)] [padding:17px_18px_14px]`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{children:a(`chat:resourcePicker.title`)}),(0,Z.jsx)(Ue,{children:a(`chat:resourcePicker.description`)})]}),(0,Z.jsx)(l,{size:`icon-sm`,variant:`ghost`,"aria-label":a(`chat:resourcePicker.close`),onClick:n,children:(0,Z.jsx)(it,{})})]}),(0,Z.jsxs)(`div`,{className:`chat-resource-body grid min-h-0 grid-cols-[minmax(0,1.1fr)_minmax(260px,.9fr)] overflow-hidden max-[650px]:grid-cols-[1fr] max-[650px]:grid-rows-[minmax(0,1fr)_minmax(190px,auto)] max-[650px]:overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`chat-resource-browser flex min-w-0 min-h-0 flex-col [border-right:1px_solid_var(--stroke-soft)] p-[12px] max-[650px]:min-h-0 max-[650px]:[border-right:0] max-[650px]:[border-bottom:1px_solid_var(--stroke-soft)]`,children:[(0,Z.jsx)(kt,{value:d,onValueChange:E,className:`chat-resource-tabs [&_[data-slot='tabs-list']]:grid [&_[data-slot='tabs-list']]:w-full [&_[data-slot='tabs-list']]:h-[36px] [&_[data-slot='tabs-list']]:[border:1px_solid_var(--stroke-soft)] [&_[data-slot='tabs-list']]:rounded-[var(--r-sm)] [&_[data-slot='tabs-list']]:bg-[var(--surface-muted)] [&_[data-slot='tabs-trigger']]:min-w-0 [&_[data-slot='tabs-trigger']]:gap-[5px] [&_[data-slot='tabs-trigger']]:rounded-[var(--r-xs)] [&_[data-slot='tabs-trigger']]:[padding-inline:6px] [&_[data-slot='tabs-trigger']]:text-[11px] [&_[data-slot='tabs-trigger'][data-state='active']]:bg-[var(--solid)] [&_[data-slot='tabs-trigger'][data-state='active']]:text-[var(--text)] [&_[data-slot='tabs-trigger']_small]:text-[var(--text-muted)] [&_[data-slot='tabs-trigger']_small]:text-[10px] [&_[data-slot='tabs-trigger']_small]:font-[500] w-full ${s?`[&_[data-slot='tabs-list']]:grid-cols-[repeat(5,minmax(0,1fr))]`:`[&_[data-slot='tabs-list']]:grid-cols-[repeat(4,minmax(0,1fr))]`}`,children:(0,Z.jsxs)(ot,{"aria-label":a(`chat:resourcePicker.categories`),children:[(0,Z.jsxs)(Y,{value:`all`,children:[a(`chat:resourcePicker.all`),(0,Z.jsx)(`small`,{children:w.all})]}),(0,Z.jsxs)(Y,{value:`prompt`,children:[a(`chat:resourcePicker.prompt`),(0,Z.jsx)(`small`,{children:w.prompt})]}),(0,Z.jsxs)(Y,{value:`skill`,children:[a(`chat:resourcePicker.skill`),(0,Z.jsx)(`small`,{children:w.skill})]}),(0,Z.jsxs)(Y,{value:`tool`,children:[a(`chat:resourcePicker.tool`),(0,Z.jsx)(`small`,{children:w.tool})]}),s&&(0,Z.jsxs)(Y,{value:`workflow`,children:[a(`chat:resourcePicker.workflow`),(0,Z.jsx)(`small`,{children:w.workflow})]})]})}),(0,Z.jsxs)(`label`,{className:`chat-resource-search [&:focus-within]:border-[var(--focus)] [&:focus-within]:shadow-[0_0_0_2px_var(--focus-ring)] [&_input]:w-full [&_input]:h-[36px] [&_input]:border-0 [&_input]:[outline:0]! [&_input]:bg-transparent [&_input]:text-[var(--text)] [&_input]:text-[13px] flex items-center gap-[7px] [margin-top:8px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] [padding:0_10px] text-[var(--text-muted)]`,children:[(0,Z.jsx)(Te,{size:15}),(0,Z.jsx)(`input`,{autoFocus:!0,value:p,onChange:e=>m(e.target.value),placeholder:a(`chat:resourcePicker.search`)})]}),(0,Z.jsxs)(`div`,{className:`chat-resource-list [&_>_button]:grid [&_>_button]:w-full [&_>_button]:grid-cols-[30px_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:[border:1px_solid_transparent] [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:p-[8px] [&_>_button]:text-[var(--text)] [&_>_button]:text-left [&_>_button]:cursor-pointer [&_>_button:hover]:bg-[var(--surface-hover)] [&_>_button.active]:border-[var(--focus)] [&_>_button.active]:bg-[var(--blue-soft)] [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_em]:text-[var(--text-muted)] [&_em]:text-[10px] [&_em]:[font-style:normal] [&_>_p]:m-[auto] [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[12px] flex min-h-0 [flex:1_1_0] flex-col gap-[3px] overflow-y-auto [overscroll-behavior:contain] [scrollbar-gutter:stable] [touch-action:pan-y] [margin-top:9px]`,children:[T.map(e=>{let t=e.kind===`prompt`?tr:e.kind===`skill`?ie:e.kind===`tool`?Ae:Mt;return(0,Z.jsxs)(`button`,{type:`button`,className:h?.kind===e.kind&&h.id===e.id?`active`:``,onClick:()=>D(e),children:[(0,Z.jsx)(`span`,{className:`list-icon [.chat-resource-list_&]:grid [.chat-resource-list_&]:w-[28px] [.chat-resource-list_&]:h-[28px] [.chat-resource-list_&]:place-items-center [.chat-resource-list_&]:rounded-[var(--r-sm)] [.chat-resource-list_&]:bg-[var(--surface-subtle)] [.chat-resource-list_&]:text-[var(--star-strong)] [.session-workflow-summary_&]:grid [.session-workflow-summary_&]:w-[28px] [.session-workflow-summary_&]:h-[28px] [.session-workflow-summary_&]:place-items-center [.session-workflow-summary_&]:rounded-[var(--r-sm)] [.session-workflow-summary_&]:bg-[var(--surface-subtle)] [.session-workflow-summary_&]:text-[var(--star-strong)] grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)] [.workflow-template-gallery_&]:grid [.workflow-template-gallery_&]:w-[32px] [.workflow-template-gallery_&]:h-[32px] [.workflow-template-gallery_&]:place-items-center [.workflow-template-gallery_&]:rounded-[var(--r-sm)] [.workflow-template-gallery_&]:bg-[var(--surface-subtle)] [.workflow-template-gallery_&]:text-[var(--star-strong)]`,children:(0,Z.jsx)(t,{size:15})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:e.name}),(0,Z.jsx)(`small`,{children:e.description})]}),(0,Z.jsx)(`em`,{children:e.kind===`prompt`?a(`chat:resourcePicker.prompt`):e.kind===`skill`?`Skill`:e.kind===`tool`?a(`chat:resourcePicker.tool`):a(`chat:resourcePicker.workflow`)})]},`${e.kind}:${e.id}`)}),!T.length&&(0,Z.jsx)(`p`,{children:b?a(`chat:resourcePicker.loading`):S||a(`chat:resourcePicker.empty`)})]})]}),(0,Z.jsx)(`div`,{className:`chat-resource-config [&_>_p]:m-[auto] [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[12px] [&_>_div:first-child]:flex [&_>_div:first-child]:flex-col [&_>_div:first-child]:gap-[4px] [&_strong]:text-[14px] [&_p]:text-[var(--text-muted)] [&_p]:text-[12px] max-[650px]:min-h-0 max-[650px]:max-h-[230px] flex min-w-0 min-h-0 flex-col gap-[16px] overflow-y-auto [overscroll-behavior:contain] [padding:18px]`,children:h?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`strong`,{children:h.name}),(0,Z.jsx)(`p`,{children:h.description||a(`chat:resourcePicker.noDescription`)})]}),h.kind===`workflow`&&h.inputs.length>0&&(0,Z.jsx)(`div`,{className:`chat-resource-inputs [&_label]:grid [&_label]:gap-[5px] [&_label]:text-[12px] [&_label]:font-[600] [&_input[type='checkbox']]:w-[16px] [&_input[type='checkbox']]:h-[16px] [&_input[type='checkbox']]:[accent-color:var(--blue)] flex flex-col gap-[11px]`,children:h.inputs.map(e=>(0,Z.jsxs)(`label`,{children:[(0,Z.jsxs)(`span`,{children:[e.label,e.required?` *`:``]}),e.type===`boolean`?(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!v[e.name],onChange:t=>y(n=>({...n,[e.name]:t.target.checked}))}):(0,Z.jsx)(W,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(v[e.name]??``),onChange:t=>y(n=>({...n,[e.name]:t.target.value}))})]},e.id))}),h.kind===`prompt`&&h.argumentHint&&(0,Z.jsx)(`code`,{className:`w-fit max-w-[100%] [overflow-wrap:anywhere] rounded-[var(--r-xs)] bg-[var(--surface-muted)] text-[var(--text-secondary)] [padding:5px_7px] text-[11px]`,children:h.argumentHint}),(0,Z.jsx)(l,{className:`chat-resource-confirm hover:bg-[var(--star-hover)] hover:text-[var(--on-accent)] min-w-[112px] min-h-[36px] self-start bg-[var(--star)] text-[var(--on-accent)] font-[650]`,onClick:()=>{if(h){if(h.kind===`prompt`){i(h.invocation||`/${h.name}`),n();return}r({kind:h.kind,resourceId:h.id,resourceName:h.name,arguments:h.kind===`workflow`?v:void 0,behavior:h.kind===`workflow`?`background`:`foreground`}),n()}},children:h.kind===`prompt`?a(`chat:resourcePicker.insertPrompt`):a(`chat:resourcePicker.useResource`)})]}):(0,Z.jsx)(`p`,{children:a(`chat:resourcePicker.chooseResource`)})})]})]})})}function ri(e,t){let n=t.match(/^\/[^\s]*(?:\s+([\s\S]*))?$/),r=(n?n[1]||``:t).trim();return`${e}${r?` ${r}`:` `}`}function ii({sessionId:e,value:t,onChange:n,inputRef:r}){let{t:i,language:a}=g(),o=(0,X.useId)(),s=t.match(/^\/([^\s]*)$/),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(!1),[_,v]=(0,X.useState)(0),y=!!(s&&c!==t),b=s?.[1]||``;(0,X.useEffect)(()=>{l(``),d(null),h(!1)},[e]),(0,X.useEffect)(()=>{if(!y||u)return;let t=!0;return p(!0),h(!1),J.getSessionCommands(e).then(e=>{t&&d(e.commands||[])}).catch(()=>{t&&(d([]),h(!0))}).finally(()=>t&&p(!1)),()=>{t=!1}},[u,y,e]);let x=(0,X.useMemo)(()=>{let e=b.toLocaleLowerCase(a);return e?(u||[]).filter(t=>`${t.invocation} ${t.name} ${t.description}`.toLocaleLowerCase(a).includes(e)):u||[]},[u,a,b]);(0,X.useEffect)(()=>{v(0)},[b,u]);let S=()=>{l(t)},C=e=>{let i=ri(e.invocation,t);n(i),l(i),requestAnimationFrame(()=>{let e=r.current;e&&(e.focus(),e.setSelectionRange(i.length,i.length),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})};(0,X.useEffect)(()=>{if(!y)return;let e=e=>{if(document.activeElement===r.current){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),S();return}x.length&&(e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),v(e=>(e+1)%x.length)):e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),v(e=>(e-1+x.length)%x.length)):(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),C(x[Math.min(_,x.length-1)])))}};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)});let w={user:i(`chat:commands.scope.user`),project:i(`chat:commands.scope.project`),package:i(`chat:commands.scope.package`),custom:i(`chat:commands.scope.custom`)};return(0,Z.jsx)(Z.Fragment,{children:y&&(0,Z.jsx)(`div`,{className:`permission-mode-menu [&_>_button]:grid [&_>_button]:w-full [&_>_button]:min-h-[48px] [&_>_button]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text)] [&_>_button]:p-[6px_7px] [&_>_button]:text-left [&_>_button:hover]:bg-[var(--accent-soft)] [&_>_button.active]:bg-[var(--accent-soft)] [&_>_button_>_span:nth-child(2)]:flex [&_>_button_>_span:nth-child(2)]:min-w-0 [&_>_button_>_span:nth-child(2)]:flex-col [&_>_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:leading-[1.4] [&_>_button_>_svg]:text-[var(--star-strong)] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(250px,calc(100vw_-_76px))] absolute z-[35] right-0 [bottom:calc(100%_+_8px)] w-[250px] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)] composer-command-menu`,id:o,role:`listbox`,"aria-label":i(`chat:commands.open`),style:{right:8,left:8,width:`auto`,maxHeight:`min(330px, 48dvh)`,overflowY:`auto`,padding:6},children:(0,Z.jsxs)(`div`,{className:`chat-resource-list [&_>_button]:grid [&_>_button]:w-full [&_>_button]:grid-cols-[30px_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:[border:1px_solid_transparent] [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:p-[8px] [&_>_button]:text-[var(--text)] [&_>_button]:text-left [&_>_button]:cursor-pointer [&_>_button:hover]:bg-[var(--surface-hover)] [&_>_button.active]:border-[var(--focus)] [&_>_button.active]:bg-[var(--blue-soft)] [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_em]:text-[var(--text-muted)] [&_em]:text-[10px] [&_em]:[font-style:normal] [&_>_p]:m-[auto] [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[12px] flex min-h-0 [flex:1_1_0] flex-col gap-[3px] overflow-y-auto [overscroll-behavior:contain] [scrollbar-gutter:stable] [touch-action:pan-y] [margin-top:9px] composer-command-list`,style:{marginTop:0},children:[x.map((e,t)=>{let n=e.source===`prompt`?tr:ie;return(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===_,className:t===_?`active`:``,onMouseEnter:()=>v(t),onMouseDown:e=>e.preventDefault(),onClick:()=>C(e),children:[(0,Z.jsx)(`span`,{className:`list-icon [.chat-resource-list_&]:grid [.chat-resource-list_&]:w-[28px] [.chat-resource-list_&]:h-[28px] [.chat-resource-list_&]:place-items-center [.chat-resource-list_&]:rounded-[var(--r-sm)] [.chat-resource-list_&]:bg-[var(--surface-subtle)] [.chat-resource-list_&]:text-[var(--star-strong)] [.session-workflow-summary_&]:grid [.session-workflow-summary_&]:w-[28px] [.session-workflow-summary_&]:h-[28px] [.session-workflow-summary_&]:place-items-center [.session-workflow-summary_&]:rounded-[var(--r-sm)] [.session-workflow-summary_&]:bg-[var(--surface-subtle)] [.session-workflow-summary_&]:text-[var(--star-strong)] grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)] [.workflow-template-gallery_&]:grid [.workflow-template-gallery_&]:w-[32px] [.workflow-template-gallery_&]:h-[32px] [.workflow-template-gallery_&]:place-items-center [.workflow-template-gallery_&]:rounded-[var(--r-sm)] [.workflow-template-gallery_&]:bg-[var(--surface-subtle)] [.workflow-template-gallery_&]:text-[var(--star-strong)]`,children:(0,Z.jsx)(n,{size:15})}),(0,Z.jsxs)(`span`,{className:`composer-command-copy`,children:[(0,Z.jsxs)(`strong`,{children:[e.invocation,e.argumentHint&&(0,Z.jsxs)(`small`,{children:[` `,e.argumentHint]})]}),(0,Z.jsx)(`small`,{children:e.description||i(`chat:commands.noDescription`)})]}),(0,Z.jsxs)(`em`,{children:[e.source===`prompt`?i(`chat:commands.prompt`):i(`chat:commands.skill`),` · `,w[e.scope]]})]},e.invocation)}),!x.length&&(0,Z.jsx)(`p`,{children:i(f?`chat:commands.loading`:m?`chat:commands.loadError`:`chat:commands.empty`)})]})})})}var ai=64,oi=new Map;function si(e){return{text:e?.text||``,attachments:[...e?.attachments||[]]}}function ci(e){return si(oi.get(e))}function li(e,t){if(!e)return;let n={...ci(e),...t};if(n.attachments=[...n.attachments],oi.delete(e),!(!n.text&&!n.attachments.length))for(oi.set(e,n);oi.size>ai;){let e=oi.keys().next().value;if(typeof e!=`string`)break;oi.delete(e)}}function ui(e){oi.delete(e)}function di(e){let t=(0,X.useRef)(ci(e)),[n,r]=(0,X.useState)(t.current.text),i=(0,X.useCallback)(t=>li(e,{attachments:t}),[e]),a=Qr(t.current.attachments,i),o=a.replaceAttachments,s=a.clearAttachments;return(0,X.useEffect)(()=>{let t=ci(e);r(t.text),o(t.attachments)},[o,e]),{value:n,updateValue:(0,X.useCallback)(t=>{r(t),li(e,{text:t})},[e]),selection:a,clearDraft:(0,X.useCallback)(()=>{r(``),s(),ui(e)},[s,e])}}var fi=(0,X.lazy)(()=>i(()=>import(`./AnimatedContent-BiVNqD3m.js`).then(e=>({default:e.AnimatedContent})),__vite__mapDeps([0,1,2,3,4,5])));function pi({open:e,children:t,label:n,trayId:r,mobile:i=!1}){let a=e?(0,Z.jsx)(`div`,{id:r,className:`composer-tool-tray @max-[700px]:gap-[3px] @max-[470px]:gap-[2px] flex min-w-0 items-center gap-[5px] [padding-left:1px] ${i?`min-w-0 flex-1 basis-0 overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:!size-9 [&>*]:!min-w-9 [&>*]:!flex-none [&>*>button]:!size-full`:``}`,"aria-label":n,children:t}):null;return i?a:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(fi,{show:e,direction:`horizontal`,reverse:!0,distance:18,duration:.24,initialOpacity:0,scale:.96,className:`min-w-0 max-w-[calc(100%_-_40px)] flex-1 [transform-origin:left_center]`,children:a})})}var mi=e(n(),1);function hi({...e}){return(0,Z.jsx)(Bn,{"data-slot":`popover`,...e})}function gi({...e}){return(0,Z.jsx)(Vn,{"data-slot":`popover-trigger`,...e})}function _i({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,Z.jsx)(Hn,{children:(0,Z.jsx)(Un,{"data-slot":`popover-content`,align:t,sideOffset:n,className:V(`z-[200] flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function vi({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`popover-title`,className:V(`font-medium`,e),...t})}var yi={completed:`completed`,in_progress:`running`,blocked:`blocked`,pending:`pending`};function bi(e){let t=new Map(e.map(e=>[String(e.id||``),e])),n=e=>e?.status===`completed`;return e.map(e=>{let r=String(e.id||``),i=(Array.isArray(e.dependsOn)?e.dependsOn:[]).map(e=>t.get(String(e))).filter(e=>!!e&&!n(e)),a=e.status!==`completed`&&(e.status===`blocked`||i.length>0);return{...e,id:r,blocked:a,blockedBy:i}})}function xi(e){return e===`completed`?B:e===`in_progress`?ge:e===`blocked`?lr:ge}function Si({status:e,t}){let n=xi(e),r=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,Z.jsxs)(`span`,{className:`plan-board-status [&.completed]:text-[var(--success)] [&.running]:text-[var(--star-strong)] inline-flex items-center gap-[4px] flex-none text-[11px] text-[var(--text-muted)] ${yi[String(e)]||`pending`}`,children:[(0,Z.jsx)(n,{size:12}),r]})}function Ci({item:e,current:t,t:n}){return(0,Z.jsxs)(`li`,{className:`plan-board-row flex flex-col gap-[2px] [padding:5px_6px] rounded-[var(--r-sm)] ${e.blocked?`blocked [.plan-board-summary_&]:text-[var(--star-strong)] [.plan-board-row&]:opacity-[.72] [.plan-board-status&]:text-[var(--danger)]`:``}`,"aria-current":t?`step`:void 0,"data-pisper-plan-current":t?`true`:void 0,"data-pisper-plan-id":e.id,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-[8px] min-w-0`,children:[(0,Z.jsx)(Si,{status:e.blocked?`blocked`:e.status,t:n}),(0,Z.jsx)(`span`,{className:`flex-1 min-w-0 overflow-hidden text-[var(--text)] text-[13px] text-ellipsis whitespace-nowrap`,title:e.title,children:e.title}),e.assignee?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-[4px] flex-none [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-pill)] bg-[var(--stroke-soft)] [padding:1px_8px] text-[var(--text-secondary)] text-[11px] whitespace-nowrap`,title:n(`chat:planBoard.assignedTo`,{name:e.assignee}),children:[(0,Z.jsx)(yr,{size:11}),e.assignee]}):e.status!==`completed`&&(0,Z.jsx)(`span`,{className:`flex-none text-[var(--text-muted)] text-[11px] [font-style:italic]`,children:n(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-[5px] [padding-left:2px] text-[var(--text-muted)] text-[11px]`,children:[(0,Z.jsx)(lr,{size:11}),n(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})]})]})}function wi({plan:e,header:t,collapsible:n=!1}){let{t:r}=g(),i=(0,X.useRef)(null),[a,o]=(0,X.useState)(!0),s=e?.items||[],c=bi(s),l=c.filter(e=>e.status===`completed`).length,u=c.filter(e=>e.status===`in_progress`&&!e.blocked).length,d=c.filter(e=>e.blocked).length,f=c.find(e=>e.status===`in_progress`&&!e.blocked)?.id??c.find(e=>e.blocked)?.id??c.find(e=>e.status===`pending`)?.id??c.at(-1)?.id;if((0,X.useLayoutEffect)(()=>{if(n&&!a)return;let e=i.current,t=e?.querySelector(`[data-pisper-plan-current="true"]`);if(!e||!t)return;let r=e.getBoundingClientRect(),o=t.getBoundingClientRect();o.top<r.top?e.scrollTop-=r.top-o.top:o.bottom>r.bottom&&(e.scrollTop+=o.bottom-r.bottom)},[n,f,a,c.length]),!s.length)return null;let p=c.find(e=>e.id===f),m=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(sr,{className:`flex-none text-[var(--star-strong)]`,size:15}),(0,Z.jsx)(`strong`,{children:r(`chat:planBoard.progress`,{completed:l,total:s.length})}),p?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-[var(--text-secondary)] text-ellipsis whitespace-nowrap`,title:p.title,children:p.title}):null,(0,Z.jsxs)(`span`,{className:`plan-board-counts @max-[470px]:hidden inline-flex flex-none items-center gap-[8px]`,children:[u>0&&(0,Z.jsx)(`span`,{children:r(`chat:planBoard.countInProgress`,{count:u})}),d>0&&(0,Z.jsx)(`span`,{className:`blocked [.plan-board-summary_&]:text-[var(--star-strong)] [.plan-board-row&]:opacity-[.72] [.plan-board-status&]:text-[var(--danger)]`,children:r(`chat:planBoard.countBlocked`,{count:d})})]}),t,n?(0,Z.jsx)(he,{className:`plan-board-chevron [.plan-board-collapsible[open]_&]:[transform:rotate(180deg)] flex-none [transition:transform_var(--d1)_var(--ease-out)]`,size:15}):null]}),h=(0,Z.jsx)(`ul`,{ref:i,className:`plan-board-list [.plan-board-collapsible_>_&]:[border-top:1px_solid_var(--stroke-soft)] [.plan-board-collapsible_>_&]:p-[8px_10px_10px] flex flex-col gap-[2px] m-0 [padding:8px_0_0] [list-style:none]${c.length>4?` is-scrollable [.session-plan-popover_.plan-board-list&]:[block-size:min(250px,38dvh)] [.plan-board-list&]:[block-size:min(220px,34dvh)] [.plan-board-list&]:overflow-y-auto [.plan-board-list&]:[overscroll-behavior:contain] [.plan-board-list&]:pr-[4px] [.plan-board-list&]:[scrollbar-gutter:stable] [.plan-board-list&:focus-visible]:[outline:2px_solid_var(--accent-border)] [.plan-board-list&:focus-visible]:[outline-offset:2px]`:``}`,tabIndex:c.length>4?0:void 0,children:c.map(e=>(0,Z.jsx)(Ci,{item:e,current:e.id===f,t:r},e.id))});return n?(0,Z.jsxs)(`details`,{className:`plan-board flex flex-col w-[min(900px,100%)] m-[0_auto] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--main-surface-bg)] p-[10px_14px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0 plan-board-collapsible !p-0`,open:a,onToggle:e=>o(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{className:`plan-board-summary [&_strong]:flex-none [&_strong]:text-[var(--text)] [&_strong]:font-[600] [.plan-board-collapsible_>_&]:min-h-[38px] [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[7px_10px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:[list-style:none] [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-[var(--surface-hover)] [.plan-board-collapsible_>_&:focus-visible]:[outline:2px_solid_var(--accent-border)] [.plan-board-collapsible_>_&:focus-visible]:[outline-offset:-2px] @max-[470px]:[.plan-board-collapsible_>_&]:[padding-inline:8px] flex min-w-0 items-center gap-[8px] [padding-bottom:8px] [border-bottom:1px_solid_var(--stroke-soft)] text-[12px] text-[var(--text-secondary)]`,"aria-label":r(`chat:planBoard.toggleAriaLabel`),children:m}),h]}):(0,Z.jsxs)(`section`,{className:`plan-board flex flex-col w-[min(900px,100%)] m-[0_auto] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--main-surface-bg)] p-[10px_14px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0`,"aria-label":r(`chat:planBoard.ariaLabel`),children:[(0,Z.jsx)(`div`,{className:`plan-board-summary [&_strong]:flex-none [&_strong]:text-[var(--text)] [&_strong]:font-[600] [.plan-board-collapsible_>_&]:min-h-[38px] [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[7px_10px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:[list-style:none] [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-[var(--surface-hover)] [.plan-board-collapsible_>_&:focus-visible]:[outline:2px_solid_var(--accent-border)] [.plan-board-collapsible_>_&:focus-visible]:[outline-offset:-2px] @max-[470px]:[.plan-board-collapsible_>_&]:[padding-inline:8px] flex min-w-0 items-center gap-[8px] [padding-bottom:8px] [border-bottom:1px_solid_var(--stroke-soft)] text-[12px] text-[var(--text-secondary)]`,children:m}),h]})}var Ti=(0,X.memo)(wi);function Ei({usage:e,plan:t}){let{t:n}=g(),r=Math.max(0,Number(e?.processedTokens)||0),i=Array.isArray(t?.items)?t.items:[],a=i.filter(e=>e?.status===`completed`).length,o=i.length?n(`chat:planBoard.progress`,{completed:a,total:i.length}):``,s=Number(e?.cacheHitRate),c=e?.cacheHitRate!=null&&Number.isFinite(s)?`${Math.round(Math.max(0,s))}%`:`—`,l=[n(`chat:focusSession.sessionUsageDetail`,{processed:q(r),input:q(e?.input),output:q(e?.output),cacheRead:q(e?.cacheRead),cacheWrite:q(e?.cacheWrite),reasoning:q(e?.reasoning),requests:Math.max(0,Number(e?.requests)||0)}),o].filter(Boolean).join(`
3
+ `);return(0,Z.jsxs)(`div`,{className:`session-usage-metrics [&_>_span]:inline-flex [&_>_span]:min-w-0 [&_>_span]:items-center [&_>_span]:gap-[4px] [&_>_span]:whitespace-nowrap [&_small]:text-inherit [&_small]:text-[inherit] [&_strong]:text-[var(--text-secondary)] [&_strong]:text-[11px] [&_strong]:[font-variant-numeric:tabular-nums] [&_strong]:font-[600] [&_svg]:text-[var(--text-tertiary)] [&_svg]:opacity-[.9] [&_>_i]:w-[1px] [&_>_i]:h-[10px] [&_>_i]:bg-[var(--border-subtle,var(--stroke-soft,#ddd))] @max-[470px]:[&_small]:hidden flex min-w-0 min-h-[26px] items-center justify-start gap-[10px] m-0 text-inherit text-[10px]`,title:l,"aria-label":l,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(Zn,{size:12}),(0,Z.jsx)(`small`,{children:n(`chat:focusSession.cacheHitRate`)}),(0,Z.jsx)(`strong`,{children:c})]}),(0,Z.jsx)(`i`,{"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(mr,{size:12}),(0,Z.jsx)(`small`,{children:n(`chat:focusSession.processedTokens`)}),(0,Z.jsx)(`strong`,{children:q(r)})]}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`i`,{"aria-hidden":`true`}),(0,Z.jsxs)(hi,{children:[(0,Z.jsx)(gi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`session-plan-progress inline-flex min-w-0 items-center gap-[4px] whitespace-nowrap hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)] data-[state=open]:bg-[var(--surface-hover)] data-[state=open]:text-[var(--star-strong)] focus-visible:[outline:2px_solid_var(--accent-border)] focus-visible:[outline-offset:1px] min-h-[24px] border-0 rounded-[var(--r-xs)] bg-transparent [padding:2px_5px] text-inherit cursor-pointer`,title:n(`chat:planBoard.openCurrentPlan`,{progress:o}),"aria-label":n(`chat:planBoard.openCurrentPlan`,{progress:o}),children:[(0,Z.jsx)(cr,{size:12}),(0,Z.jsx)(`strong`,{children:o})]})}),(0,Z.jsx)(_i,{className:`session-plan-popover w-[min(440px,calc(100vw_-_24px))] max-h-[min(360px,55dvh)] overflow-auto [padding:6px]`,align:`start`,side:`top`,sideOffset:7,children:(0,Z.jsx)(Ti,{plan:t??null})})]})]})]})}function Di({usage:e,onThresholdChange:t}){let{t:n}=g(),r=Number(e?.contextWindow)||0,i=e?.compactAtPercent==null?80:Number(e.compactAtPercent),a=Number.isFinite(i)?Math.round(i):80,[o,s]=(0,X.useState)(a),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(``),f=(0,X.useRef)(a),p=(0,X.useRef)(void 0);if((0,X.useEffect)(()=>{window.clearTimeout(p.current),s(a),f.current=a},[a]),(0,X.useEffect)(()=>()=>window.clearTimeout(p.current),[]),!r)return null;let m=e?.percent!=null&&Number.isFinite(Number(e.percent)),h=m?Math.max(0,Number(e.percent)):null,_=h==null?null:Math.round(h),v=Math.max(50,a-15),y=h==null?`unknown`:h>=a?`danger`:h>=v?`warning`:`normal`,b=m?e.estimated?n(`chat:focusSession.estimatedContextUsageTokensLimitTokensPercent`,{tokens:q(e.tokens),limit:q(r),percent:_}):n(`chat:focusSession.contextUsageTokensLimitTokensPercent`,{tokens:q(e.tokens),limit:q(r),percent:_}):n(`chat:focusSession.contextUsageWillUpdateAfterTheNextModelResponseLimitLimitTokens`,{limit:q(r)}),x=e?.autoCompactEnabled?n(`chat:focusSession.autoCompactionThresholdAboutPercent`,{percent:a}):n(`chat:focusSession.automaticContextCompactionIsDisabled`),S=e?.autoCompactEnabled&&e.compactionCapacityPercent!=null?n(`chat:focusSession.contextUsageToCompactionTokensPercent`,{percent:Math.round(Number(e.compactionCapacityPercent)),tokens:q(e.remainingBeforeCompaction)}):``,C=`${b} · ${x}${S?` · ${S}`:``}`,w=`${e?.tokens==null?`—`:q(e.tokens)} / ${q(r)}`,T=async e=>{let n=Math.min(95,Math.max(50,Math.round(e)));if(s(n),!(!t||n===f.current)){l(!0),d(``);try{await t(n),f.current=n}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}}},E=e=>{window.clearTimeout(p.current),s(e),p.current=window.setTimeout(()=>void T(e),250)},D=e=>{window.clearTimeout(p.current),T(e)};return(0,Z.jsxs)(hi,{children:[(0,Z.jsx)(gi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`context-usage-chip hover:opacity-100 [&_>_svg]:opacity-[.72] [&_>_span]:inline-flex [&_>_span]:[align-items:baseline] [&_>_span]:gap-[4px] [&_>_span]:whitespace-nowrap [&_>_span_strong]:text-inherit [&_>_span_strong]:text-[11px] [&_>_span_strong]:font-[500] [&_>_span_small]:text-inherit [&_>_span_small]:text-[10px] [&_>_span_small]:font-[600] [&_>_i]:block [&_>_i]:w-[24px] [&_>_i]:h-[2px] [&_>_i]:overflow-hidden [&_>_i]:rounded-[var(--r-pill)] [&_>_i]:bg-[var(--stroke-soft)] [&_>_i_>_b]:block [&_>_i_>_b]:h-full [&_>_i_>_b]:rounded-[inherit] [&_>_i_>_b]:bg-[var(--text-muted)] [&_>_i_>_b]:[transition:width_var(--d2)_var(--ease-out)] [&.warning_>_span_small]:text-[var(--warning-strong)] [&.warning_>_i_>_b]:bg-[var(--warning-strong)] [&.danger_>_span_small]:text-[var(--danger)] [&.danger_>_i_>_b]:bg-[var(--danger)] [&.unknown_>_i_>_b]:!w-[0] @max-[470px]:grid-cols-[auto_auto] @max-[470px]:[&_>_i]:hidden grid h-[24px] flex-none grid-cols-[auto_auto_24px] items-center gap-[4px] border-0 bg-transparent [padding:0_2px] text-[var(--text-tertiary)] text-[10px] opacity-[.78] cursor-pointer [transition:opacity_var(--d1)_var(--ease-out)] ${y}`,"aria-label":C,title:C,children:[(0,Z.jsx)(rr,{size:12}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:w}),(0,Z.jsx)(`small`,{children:_==null?`—`:`${_}%`})]}),(0,Z.jsx)(`i`,{"aria-hidden":`true`,children:(0,Z.jsx)(`b`,{style:{width:`${Math.min(100,h||0)}%`}})})]})}),(0,Z.jsxs)(_i,{className:`context-usage-popover [&_input[type='range']]:w-full [&_input[type='range']]:h-[20px] [&_input[type='range']]:m-0 [&_input[type='range']]:[accent-color:var(--brand-blue-strong)] [&_input[type='range']]:cursor-pointer [&_>_small]:min-h-[16px] [&_>_small]:text-[var(--text-muted)] [&_>_small]:text-[10px] [&_>_small]:leading-[1.4] [&_>_small.error]:text-[var(--danger)] w-[248px] gap-[8px] [padding:12px]`,align:`end`,sideOffset:8,children:[S&&(0,Z.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:S}),(0,Z.jsxs)(`div`,{className:`context-threshold-heading flex items-center justify-between [&_output]:text-[var(--brand-blue-strong)] [&_output]:[font-variant-numeric:tabular-nums] text-[var(--text)] text-[12px] font-[600]`,children:[(0,Z.jsx)(`span`,{children:n(`chat:focusSession.autoCompactionThreshold`)}),(0,Z.jsxs)(`output`,{children:[o,`%`]})]}),(0,Z.jsx)(`input`,{type:`range`,min:`50`,max:`95`,step:`1`,value:o,"aria-label":n(`chat:focusSession.autoCompactionThreshold`),disabled:c,onChange:e=>E(Number(e.currentTarget.value)),onBlur:e=>D(Number(e.currentTarget.value)),onPointerUp:e=>D(Number(e.currentTarget.value)),onKeyUp:e=>{[`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`].includes(e.key)&&D(Number(e.currentTarget.value))}}),(0,Z.jsxs)(`div`,{className:`context-threshold-scale flex items-center justify-between text-[var(--text-tertiary)] text-[10px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{children:`50%`}),(0,Z.jsx)(`span`,{children:`95%`})]}),(0,Z.jsx)(`small`,{className:u?`error`:``,children:u||(c?n(`chat:focusSession.savingCompactionThreshold`):`\xA0`)})]})]})}function Oi({value:e,models:t,onChange:n,disabled:r,compact:i=!1}){let{t:a}=g(),o=t.find(t=>t.key===e),s=o?`${o.providerName} · ${o.label}`:e.split(`/`).at(-1);return(0,Z.jsxs)(`div`,{className:`session-model-select [&.compact]:max-w-[118px] [&.compact]:h-[32px] [&.compact]:rounded-[var(--r-xs)] [&_[data-slot='select-trigger']]:w-full [&_[data-slot='select-trigger']]:h-full [&_[data-slot='select-trigger']]:min-h-0 [&_[data-slot='select-trigger']]:overflow-hidden [&_[data-slot='select-trigger']]:border-0 [&_[data-slot='select-trigger']]:[outline:0] [&_[data-slot='select-trigger']]:bg-transparent [&_[data-slot='select-trigger']]:p-[0_22px_0_8px] [&_[data-slot='select-trigger']]:text-inherit [&_[data-slot='select-trigger']]:text-[13px] [&_[data-slot='select-trigger']]:font-[600] [&_[data-slot='select-trigger']]:text-ellipsis [&_[data-slot='select-trigger']]:whitespace-nowrap [&.compact_[data-slot='select-trigger']]:text-[12px] [&_>_svg]:absolute [&_>_svg]:right-[6px] [&_>_svg]:flex-none [&_>_svg]:pointer-events-none [&:has([data-slot='select-trigger']:disabled)]:[cursor:not-allowed] [&:has([data-slot='select-trigger']:disabled)]:opacity-[.55] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-composer_&]:h-[38px] [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] dark:bg-[var(--accent-soft)] @max-[700px]:[.focus-composer-footer.tools-open_&]:hidden relative flex max-w-[170px] h-[30px] items-center rounded-[var(--r-xs)] bg-[var(--accent-soft)] text-[var(--star-strong)] icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] ${i?`compact`:``}`,title:a(r?`chat:focusSession.currentModelModelCannotSwitchWhileRunning`:`chat:focusSession.currentModelModelClickToSwitch`,{model:s}),children:[(0,Z.jsx)(Ne,{size:i?11:14}),(0,Z.jsxs)(re,{value:e,onChange:e=>n(e.target.value),disabled:r||t.length===0,"aria-label":a(`chat:focusSession.currentChatModel`),children:[!o&&(0,Z.jsx)(`option`,{value:e,children:e.split(`/`).at(-1)}),t.map(e=>(0,Z.jsxs)(`option`,{value:e.key,children:[e.providerName,` · `,e.label]},e.key))]})]})}function ki({value:e,levels:t,status:n=`supported`,message:r=``,onChange:i,disabled:a,compact:o=!1}){let{t:s}=g(),c=e||t[0]||`off`,l=!n&&t.length===0,u=n!==`unsupported`&&t.length>0,d=u&&t.length<=1&&t.includes(c),f=l?s(`chat:focusSession.loadingThinkingLevels`):u?s(d?`chat:focusSession.thinkingLevelFixed`:a?`chat:focusSession.currentThinkingLevelLevelCannotSwitchWhileRunning`:`chat:focusSession.currentThinkingLevelLevelClickToSwitch`,{level:c}):r||s(`chat:focusSession.thinkingLevelUnsupported`);return(0,Z.jsxs)(`div`,{className:`session-model-select [&.compact]:max-w-[118px] [&.compact]:h-[32px] [&.compact]:rounded-[var(--r-xs)] [&_[data-slot='select-trigger']]:w-full [&_[data-slot='select-trigger']]:h-full [&_[data-slot='select-trigger']]:min-h-0 [&_[data-slot='select-trigger']]:overflow-hidden [&_[data-slot='select-trigger']]:border-0 [&_[data-slot='select-trigger']]:[outline:0] [&_[data-slot='select-trigger']]:bg-transparent [&_[data-slot='select-trigger']]:p-[0_22px_0_8px] [&_[data-slot='select-trigger']]:text-inherit [&_[data-slot='select-trigger']]:text-[13px] [&_[data-slot='select-trigger']]:font-[600] [&_[data-slot='select-trigger']]:text-ellipsis [&_[data-slot='select-trigger']]:whitespace-nowrap [&.compact_[data-slot='select-trigger']]:text-[12px] [&_>_svg]:absolute [&_>_svg]:right-[6px] [&_>_svg]:flex-none [&_>_svg]:pointer-events-none [&:has([data-slot='select-trigger']:disabled)]:[cursor:not-allowed] [&:has([data-slot='select-trigger']:disabled)]:opacity-[.55] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-composer_&]:h-[38px] [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] dark:bg-[var(--accent-soft)] @max-[700px]:[.focus-composer-footer.tools-open_&]:hidden relative flex max-w-[170px] h-[30px] items-center rounded-[var(--r-xs)] bg-[var(--accent-soft)] text-[var(--star-strong)] session-thinking-select [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none [.focus-composer_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] ${o?`compact`:``}`,title:f,children:[(0,Z.jsx)(Pt,{size:o?11:14}),(0,Z.jsxs)(re,{value:c,onChange:e=>i(e.target.value),disabled:a||l||!u||d,"aria-label":s(`chat:focusSession.currentThinkingLevel`),children:[!t.includes(c)&&(0,Z.jsx)(`option`,{value:c,children:c}),t.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})}function Ai(e){return[[`read-only`,e(`chat:focusSession.readOnly`),e(`chat:focusSession.onlyInspectAndAnalyzeContent`),A],[`approval-required`,e(`chat:focusSession.approvalRequired`),e(`chat:focusSession.approvalRequiredShowsADiffBeforeWriting`),$n],[`workspace-write`,e(`chat:focusSession.workspaceWrite`),e(`chat:focusSession.workspaceWriteRunsCommandsWithAutomaticApproval`),Gn],[`full-access`,e(`chat:focusSession.fullAccess`),e(`chat:focusSession.fullAccessRunsShellWithoutPerCommandApproval`),pr]]}function ji({value:e,onChange:t,disabled:n,compact:r=!1}){let{t:i}=g(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)({left:0,top:0,width:270}),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=Ai(i),f=d.find(t=>t[0]===e)||d[1],p=f[3],m=(0,X.useCallback)(()=>{let e=l.current?.querySelector(`button`);if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(270,window.innerWidth-16),r=u.current?.offsetHeight||190,i=Math.max(8,Math.min(t.right-n,window.innerWidth-n-8)),a=t.top>=r+8+8?t.top-r-8:Math.min(t.bottom+8,window.innerHeight-r-8);c({left:i,top:Math.max(8,a),width:n})},[]);(0,X.useLayoutEffect)(()=>{if(a)return m(),window.addEventListener(`resize`,m),window.addEventListener(`scroll`,m,!0),()=>{window.removeEventListener(`resize`,m),window.removeEventListener(`scroll`,m,!0)}},[a,m]),(0,X.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.target instanceof Node?e.target:null;!l.current?.contains(t)&&!u.current?.contains(t)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let h=a&&(0,mi.createPortal)((0,Z.jsxs)(`div`,{ref:u,className:`permission-mode-menu [&_>_button]:grid [&_>_button]:w-full [&_>_button]:min-h-[48px] [&_>_button]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text)] [&_>_button]:p-[6px_7px] [&_>_button]:text-left [&_>_button:hover]:bg-[var(--accent-soft)] [&_>_button.active]:bg-[var(--accent-soft)] [&_>_button_>_span:nth-child(2)]:flex [&_>_button_>_span:nth-child(2)]:min-w-0 [&_>_button_>_span:nth-child(2)]:flex-col [&_>_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:leading-[1.4] [&_>_button_>_svg]:text-[var(--star-strong)] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(250px,calc(100vw_-_76px))] absolute z-[35] right-0 [bottom:calc(100%_+_8px)] w-[250px] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)] execution-mode-menu !fixed !right-auto !bottom-auto z-[80]`,style:s,role:`menu`,children:[(0,Z.jsx)(`div`,{className:`[padding:6px_8px_4px] text-[var(--text-muted)] text-[11px] font-[700] tracking-[.04em] [text-transform:uppercase]`,children:i(`chat:focusSession.executionMode`)}),d.map(([e,n,r,i])=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===f[0],className:e===f[0]?`active`:``,onClick:()=>{t(e),o(!1)},children:[(0,Z.jsx)(`span`,{className:`permission-level [&.level-auto]:bg-[var(--accent-soft)] [&.level-auto]:text-[var(--star-strong)] [&.level-ignore]:bg-[var(--danger-soft)] [&.level-ignore]:text-[var(--danger)] [&.level-full-access]:bg-[var(--danger-soft)] [&.level-full-access]:text-[var(--danger)] grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-muted)] level-${e}`,children:(0,Z.jsx)(i,{size:13})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n}),(0,Z.jsx)(`small`,{children:r})]}),e===f[0]&&(0,Z.jsx)(B,{size:13})]},e))]}),document.body);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:l,className:`permission-mode-select [&.compact]:min-w-[68px] [&.compact]:h-[32px] [.focus-composer_&]:h-[38px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] @max-[700px]:[.focus-composer_&]:min-w-0 max-[650px]:[.focus-composer_&]:min-w-0 relative min-w-[78px] h-[32px] text-[var(--text-tertiary)] execution-mode-select icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] ${r?`compact`:``} ${a?`open`:``}`,children:(0,Z.jsx)(`button`,{type:`button`,className:`permission-mode-trigger hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] [.permission-mode-select.open_&]:border-[var(--accent-border)] [.permission-mode-select.open_&]:bg-[var(--accent-soft)] [.permission-mode-select.open_&]:text-[var(--star-strong)] disabled:[cursor:not-allowed] disabled:opacity-[.55] [.permission-mode-select.compact_&]:gap-[3px] [.permission-mode-select.compact_&]:rounded-[var(--r-xs)] [.permission-mode-select.compact_&]:p-[0_4px] [.permission-mode-select.compact_&]:text-[13px] [.focus-composer_&]:rounded-[var(--r-sm)] dark:hover:bg-[var(--accent-soft)] grid w-full h-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[5px] [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-inherit [padding:0_7px] text-[12px] font-[700] icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] mode-${f[0]}`,title:i(`chat:focusSession.executionModeModeDescription`,{mode:f[1],description:f[2]}),disabled:n,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":i(`chat:focusSession.executionModeMode`,{mode:f[1]}),onClick:()=>o(e=>!e),children:(0,Z.jsx)(p,{size:r?11:14})})}),h]})}function Mi(e,{threshold:t=64}={}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(null),a=(0,X.useCallback)(e=>{n.current=e,i(e)},[]),o=(0,X.useRef)(0),s=(0,X.useRef)(!1),c=(0,X.useRef)(0),l=(0,X.useRef)(!0),[u,d]=(0,X.useState)(!0),[f,p]=(0,X.useState)(!1),m=(0,X.useCallback)((e=`auto`)=>{let t=n.current;t&&(s.current=!0,cancelAnimationFrame(c.current),t.scrollTo({top:t.scrollHeight,behavior:e}),l.current=!0,d(!0),p(!1),c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>{s.current=!1})}))},[]),h=(0,X.useCallback)(()=>{cancelAnimationFrame(c.current),s.current=!1},[]),g=(0,X.useCallback)(e=>{let n=e.currentTarget;if(s.current)return;let r=n.scrollHeight-n.scrollTop-n.clientHeight<=t;l.current=r,d(r),r&&p(!1)},[t]);(0,X.useEffect)(()=>{if(n.current){if(!u){p(!0);return}return cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>m()),()=>cancelAnimationFrame(o.current)}},[e,u,m]);let _=(0,X.useCallback)(()=>{l.current&&m()},[m]);return(0,X.useEffect)(()=>()=>cancelAnimationFrame(c.current),[]),{scrollRef:n,scrollElement:r,setScrollRef:a,onScroll:g,hasUnread:f,scrollToBottom:m,maintainBottom:_,cancelProgrammaticScroll:h}}function Ni(e){return e===`queued`?{titleKey:`{name} 等待调度`,tone:`waiting`}:e===`starting`?{titleKey:`{name} 正在启动`,tone:`running`}:e===`running`?{titleKey:`{name} 正在运行`,tone:`running`}:e===`completed`?{titleKey:`{name} 已完成`,tone:`completed`}:e===`interrupted`?{titleKey:`{name} 已中断`,tone:`stopped`}:e===`failed`?{titleKey:`{name} 执行失败`,tone:`failed`}:{titleKey:`{name} 状态已更新`,tone:`waiting`}}function Pi(e){let t=typeof e==`string`||typeof e==`number`||e instanceof Date?e:0,n=new Date(t).getTime();return Number.isFinite(n)?n:0}function Fi({currentActivity:e,compaction:t,text:n,thinkingText:r,lastActivityAt:i}={}){return t?.active?{type:`compaction`,compaction:t,updatedAt:t.startedAt||i}:e&&[`model`,`compaction`,`retry`].includes(e.type)?e:{type:`model`,stage:e?.type===`tool`?e.status===`running`?`working`:`processing_result`:String(r||``).trim()?`thinking`:String(n||``).trim()?`responding`:`thinking`,updatedAt:e?.updatedAt||i}}function Ii(e=[]){return e.map(e=>`${e.type}:${e.id||e.agent?.id||``}:${e.status||e.stage||e.agent?.status||``}`).join(`|`)}function Li(e,t=0){return e.type===`tool`?`tool:${e.id||e.name||t}`:e.type===`agent`?`agent:${e.agent?.id||e.agent?.canonicalName||t}:${e.agent?.status||e.status||``}`:e.type===`plan`?`plan:${e.id||Dr(e)?.updatedAt||e.updatedAt||t}`:`${e.type||`activity`}:${e.id||e.startedAt||e.createdAt||t}`}function Ri(e){return e?.type?e.type===`tool`?`tool:${e.id||e.name||``}`:e.type===`agent`?`agent:${e.agent?.id||e.agent?.canonicalName||``}`:e.type===`plan`?`plan:${e.updatedAt||Dr(e)?.updatedAt||``}`:e.type===`model`?`model:${e.stage||``}`:e.type===`compaction`?`compaction:${e.compaction?.status||e.compaction?.active||``}`:`${e.type}:${e.id||e.updatedAt||``}`:``}function zi(e,t){let n=new Map((e?.items||[]).map(e=>[String(e.id||``),e])),r=new Map((t?.items||[]).map(e=>[String(e.id||``),e])),i=[];for(let e of r.values()){let t=n.get(String(e.id||``));t?(t.status!==e.status||t.title!==e.title||t.note!==e.note)&&i.push({id:e.id,title:e.title,status:e.status,previousStatus:t.status,kind:`updated`}):i.push({id:e.id,title:e.title,status:e.status,kind:`added`})}for(let e of n.values())r.has(String(e.id||``))||i.push({id:e.id,title:e.title,status:e.status,kind:`removed`});return i}function Bi(e=[],t,n=6){let r=Array.isArray(e)?e:[];if(![`tool`,`plan`,`agent`].includes(t?.type))return r;let i=[...r];t.type===`plan`&&(i=i.filter(e=>e?.type!==`tool`||!Er(e.name))),t.type===`agent`&&(i=i.filter(e=>e?.type!==`tool`||![`spawn_agent`,`list_agents`,`send_message`,`followup_task`,`wait_agent`,`interrupt_agent`].includes(e.name)));let a=Ri(t),o=i.findIndex(e=>Ri(e)===a);return o>=0?i[o]={...i[o],...t}:i.push(t),i.slice(-Math.max(1,Number(n)||6))}function Vi(e=[],{finishedAt:t=new Date().toISOString(),error:n=``}={}){return e.map(e=>e?.status===`running`?{...e,status:n?`error`:`done`,message:n||e.message||``,updatedAt:t,finishedAt:t}:e)}function Hi(e,t,n=Date.now()){let r=Pi(e);if(!r)return 0;let i=Pi(t)||n;return Math.max(0,i-r)}function Ui(e,t,n=Date.now()){let r=e?.type===`agent`&&e.agent||{},i=e?.startedAt||r.startedAt||e?.updatedAt||t,a=e?.finishedAt||r.completedAt||``;return!a&&e?.type===`tool`&&e.status&&e.status!==`running`&&(a=e.updatedAt),!a&&e?.type===`agent`&&![`queued`,`starting`,`running`].includes(r.status)&&(a=r.lastActivityAt||e.updatedAt),!a&&e?.type===`plan`&&(a=e.updatedAt),Hi(i,a,n)}function Wi(e,t=`zh-CN`){let n=Math.max(0,Math.round(Number(e)||0));if(n<1e3)return t===`en-US`?`${n}ms`:`${n} 毫秒`;let r=Math.floor(n/1e3);if(r<60)return t===`en-US`?`${r}s`:`${r} 秒`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}:${String(a).padStart(2,`0`)}`:`${Math.floor(i/60)}:${String(i%60).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}function Gi(e,t){return e.scrollTop+t-e.scrollHeight}function Ki(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function qi(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function Ji(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Yi=(e,t)=>Math.abs(e-t)<1.01,Xi=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Zi,Qi=()=>{if(Zi!==void 0)return Zi;if(typeof navigator>`u`)return Zi=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Zi=!0;let e=navigator.maxTouchPoints;return Zi=navigator.platform===`MacIntel`&&e!==void 0&&e>0},$i=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ea=e=>e,ta=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},na=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i($i(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i($i(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},ra={passive:!0},ia=typeof window>`u`||`onscrollend`in window,aa=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&ia,o=0,s=a?null:Xi(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,ra),a&&r.addEventListener(`scrollend`,u,ra),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},oa=(e,t)=>aa(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),sa=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},ca=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},la=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ea,rangeExtractor:ta,onChange:()=>{},measureElement:sa,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=Math.max(0,e.start+t);n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=qi(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Qi()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,ra),e.addEventListener(`touchend`,n,ra),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(Qi()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=qi(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.getMeasurements=qi(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=Ki(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=qi(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=fa(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=qi(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f)}},this.getVirtualItems=qi(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return Ji(t[ua(0,t.length-1,r?e=>n[e*2]:e=>Ji(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){return e===0?!1:Qi()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=e,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Yi(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},ua=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function da(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function fa(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=da(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=ua(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var pa=typeof document<`u`?X.useLayoutEffect:X.useEffect;function ma({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=X.useReducer(e=>e+1,0)[1],a=X.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},s=e=>{let t=a.current;if(!t.enabled||!t.container)return;o(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let o=a.start-s,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==o&&(t.lastPositions.set(c,o),r?c.style.transform=n?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:c.style[i]=`${o}px`)}},c={...r,onChange:(t,n)=>{var o;let c=a.current,l=!0;if(c.enabled){s(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,mi.flushSync)(i):i()),(o=r.onChange)==null||o.call(r,t,n)}},[l]=X.useState(()=>{let e=new la(c);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return l.setOptions(c),pa(()=>l._didMount(),[]),pa(()=>(o(l),l._willUpdate())),pa(()=>{s(l)}),l}function ha(e){return ma({observeElementRect:na,observeElementOffset:oa,scrollToFn:ca,...e})}var ga=new Map,_a=e=>{let t=ga.get(e);return t||(t=Ft.create(e),ga.set(e,t)),t};(0,X.memo)(({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2})=>{let a=_a(t),o=(0,X.useMemo)(()=>(e?.length??0)*i,[e,i]);return(0,Z.jsx)(a,{animate:{backgroundPosition:`0% center`},className:V(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,n),initial:{backgroundPosition:`100% center`},style:{"--spread":`${o}px`,backgroundImage:`var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))`},transition:{duration:r,ease:`linear`,repeat:1/0},children:e})});var va=(0,X.createContext)(null),ya=({className:e,isStreaming:t=!1,children:n,...r})=>{let i=(0,X.useMemo)(()=>({isStreaming:t}),[t]);return(0,Z.jsx)(va.Provider,{value:i,children:(0,Z.jsx)(Rr,{asChild:!0,"data-slot":`plan`,...r,children:(0,Z.jsx)(gt,{className:V(`shadow-none`,e),children:n})})})},ba=({defaultOpen:e=!0,className:t,...n})=>(0,Z.jsx)(Rr,{className:V(t),defaultOpen:e,...n}),xa=4e3,Sa=`… earlier output omitted …`;function Ca(e){let t=String(e||``),n=``;for(let e=0;e<t.length;e+=1){let r=t.charCodeAt(e);if(r===27){let n=t.charCodeAt(e+1);if(n===91)for(e+=2;e<t.length&&t.charCodeAt(e)<64;)e+=1;else if(n===93)for(e+=2;e<t.length;){let n=t.charCodeAt(e);if(n===7)break;if(n===27&&t.charCodeAt(e+1)===92){e+=1;break}e+=1}else e+=1;continue}(r===9||r===10||r===13||r>=32&&r!==127)&&(n+=t[e])}return n}function wa(e,t=xa){let n=String(e||``),r=Math.max(1,Math.floor(Number(t)||4e3));if(n.length<=r)return{text:Ca(n),truncated:!1};let i=n.slice(-r),a=i.indexOf(`
4
+ `);return a>=0&&a<Math.floor(r/3)&&(i=i.slice(a+1)),{text:Ca(`${Sa}\n${i}`),truncated:!0}}var Ta=[],Ea=(0,X.lazy)(()=>i(()=>import(`./AnimatedList-CJTx-B8I.js`).then(e=>({default:e.AnimatedList})),__vite__mapDeps([6,1,2,3,4,5,7]))),Da=(0,X.lazy)(()=>i(()=>import(`./ShinyText-fuaKxKqJ.js`).then(e=>({default:e.ShinyText})),__vite__mapDeps([8,2,1,3,4,7])));function Oa(e,t){return e===`read`?t(`chat:agentRunActivity.readingFiles`):e===`grep`?t(`chat:agentRunActivity.searchingContent`):e===`find`?t(`chat:agentRunActivity.findingFiles`):e===`ls`?t(`chat:agentRunActivity.browsingDirectories`):e===`edit`?t(`chat:agentRunActivity.editingFiles`):e===`write`?t(`chat:agentRunActivity.writingFiles`):e===`bash`?t(`chat:agentRunActivity.runningCommands`):e===`memory_search`?t(`chat:agentRunActivity.searchingMemory`):e===`memory_remember`?t(`chat:agentRunActivity.savingMemory`):e===`spawn_agent`?t(`chat:agentRunActivity.startingSubagent`):e===`list_agents`?t(`chat:agentRunActivity.checkingSubagents`):e===`send_message`?t(`chat:agentRunActivity.messagingSubagent`):e===`followup_task`?t(`chat:agentRunActivity.addingSubagentTask`):e===`wait_agent`?t(`chat:agentRunActivity.waitingForSubagent`):e===`interrupt_agent`?t(`chat:agentRunActivity.interruptingSubagent`):wr(e)?t(`chat:agentRunActivity.readingPlan`):Tr(e)?t(`chat:agentRunActivity.updatingPlan`):e===`browser_automation`?t(`chat:agentRunActivity.controllingBrowser`):e===`generate_visual`?t(`chat:agentRunActivity.generatingVisualContent`):e===`discover_tools`?t(`chat:agentRunActivity.discoveringTools`):t(`chat:agentRunActivity.usingTool`,{tool:String(e||t(`chat:agentRunActivity.tools`))})}function ka(e,t){return e===`read`?t(`chat:agentRunActivity.filesRead`):e===`grep`?t(`chat:agentRunActivity.searchCompleted`):e===`find`?t(`chat:agentRunActivity.findCompleted`):e===`ls`?t(`chat:agentRunActivity.directoriesBrowsed`):e===`edit`?t(`chat:agentRunActivity.filesEdited`):e===`write`?t(`chat:agentRunActivity.filesWritten`):e===`bash`?t(`chat:agentRunActivity.commandCompleted`):e===`spawn_agent`?t(`chat:agentRunActivity.subagentStarted`):e===`wait_agent`?t(`chat:agentRunActivity.subagentStatusUpdated`):Tr(e)?t(`chat:agentRunActivity.planUpdated`):t(e===`discover_tools`?`chat:agentRunActivity.toolsDiscovered`:`chat:agentRunActivity.currentOperationCompleted`)}function Aa(e,t,n){return n(e===`queued`?`chat:agentRunActivity.agentQueued`:e===`starting`?`chat:agentRunActivity.agentStarting`:e===`running`?`chat:agentRunActivity.agentRunning`:e===`completed`?`chat:agentRunActivity.agentCompleted`:e===`interrupted`?`chat:agentRunActivity.agentInterrupted`:e===`failed`?`chat:agentRunActivity.agentFailed`:`chat:agentRunActivity.agentStatusUpdated`,{name:t})}function ja(e){let[t,n]=(0,X.useState)(()=>Date.now());return(0,X.useEffect)(()=>{if(n(Date.now()),!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function Q(e){return String(e||``).replace(/\s+/g,` `).trim()}function Ma(e){let t=e?.args||{};return e?.name===`bash`?{text:String(t.command||``).trim(),command:!0}:[`read`,`edit`,`write`,`ls`].includes(e?.name)?{text:Q(t.path)}:e?.name===`grep`?{text:[t.pattern?`“${Q(t.pattern)}”`:``,Q(t.path)].filter(Boolean).join(` · `)}:e?.name===`find`?{text:[Q(t.pattern),Q(t.path)].filter(Boolean).join(` · `)}:e?.name===`browser_automation`?{text:[Q(t.action),Q(t.url||t.selector)].filter(Boolean).join(` · `)}:e?.name===`spawn_agent`?{text:Q(t.taskName)}:[`send_message`,`followup_task`,`wait_agent`,`interrupt_agent`].includes(e?.name)?{text:Q(t.target)}:e?.name===`generate_visual`?{text:Q(t.outputName||t.kind)}:e?.name===`discover_tools`?{text:Q(t.query)}:{text:``}}function Na(e,t){let n=e?.items||[],r=e?.counts?.completed??n.filter(e=>e.status===`completed`).length,i=e?.counts?.inProgress??n.filter(e=>e.status===`in_progress`).length;return[n.length?t(`chat:agentRunActivity.completedTotalCompleted`,{completed:r,total:n.length}):``,i?t(`chat:agentRunActivity.countInProgress`,{count:i}):``].filter(Boolean).join(` · `)||t(`chat:agentRunActivity.planCleared`)}function Pa(e,t){return e.kind===`removed`?t(`chat:agentRunActivity.removedTitle`,{title:e.title}):e.status===`completed`?t(`chat:agentRunActivity.completedTitle`,{title:e.title}):e.status===`in_progress`?t(`chat:agentRunActivity.inProgressTitle`,{title:e.title}):e.status===`blocked`?t(`chat:agentRunActivity.blockedTitle`,{title:e.title}):e.kind===`added`?t(`chat:agentRunActivity.addedTitle`,{title:e.title}):t(`chat:agentRunActivity.pendingTitle`,{title:e.title})}function Fa(e,t){return e?.active?e.reason===`overflow`?t(`chat:agentRunActivity.contextIsFullTheRequestWillRetryAfterCompaction`):e.reason===`manual`?t(`chat:agentRunActivity.summarizingOlderMessagesAsRequested`):t(`chat:agentRunActivity.contextIsNearingItsLimitSummarizingOlderMessages`):e?.tokensBefore!=null&&e?.estimatedTokensAfter!=null?t(`chat:agentRunActivity.contextCompactedBeforeAfterTokens`,{before:q(e.tokensBefore),after:q(e.estimatedTokensAfter)}):t(`chat:agentRunActivity.summarizingOlderMessages`)}function Ia(e,{t,streaming:n,text:r,thinkingText:i,compaction:a,error:o,stopped:s,notice:c,lastActivityAt:l,now:u}){let d=`running`,f=t(`chat:agentRunActivity.understandingTheTask`),p=c||``,m=``,h=!1,g=e.startedAt,_=Ta;if(e.type===`tool`){let n=e.status===`error`,r=e.status===`done`;d=n?`failed`:r?`completed`:`running`,f=n?t(`chat:agentRunActivity.toolFailed`,{tool:Oa(e.name,t)}):r?ka(e.name,t):Oa(e.name,t);let i=Ma(e);p=i.text,h=!!i.command,m=Q(e.message)}else if(e.type===`plan`){d=`plan`;let n=Dr(e);f=n?.items?.length?t(`chat:agentRunActivity.planUpdated`):t(`chat:agentRunActivity.planCleared`),_=e.changes||Ta,p=_.length?t(`chat:agentRunActivity.countPlanChanges`,{count:_.length}):Na(n,t)}else if(e.type===`agent`){let n=e.agent||{},r=n.canonicalName||n.taskName||t(`chat:agentRunActivity.subagent`),i=Ni(n.status);f=Aa(n.status,r,t),d=i.tone,p=(n.currentActivity?.type===`tool`?Ma(n.currentActivity).text||n.currentActivity.name:``)||Q(n.error||n.message),m=n.status===`running`?Q(n.output):``,g=n.startedAt||g}else if(e.type===`compaction`)d=`compacting`,f=t(`chat:agentRunActivity.compactingContext`),p=Fa(e.compaction||a,t);else if(e.type===`retry`)d=`waiting`,f=t(`chat:agentRunActivity.retryingRequest`),p=e.message||c||``;else{let a=Math.max(0,u-new Date(l||u).getTime());o?(d=`failed`,f=t(`chat:agentRunActivity.thisRunFailed`),p=o):s?(d=`stopped`,f=t(`chat:agentRunActivity.runStopped`)):n?a>=1e4?(d=`waiting`,f=t(`chat:agentRunActivity.waitingForTheModel`),p=t(`chat:agentRunActivity.noNewProgressForCountS`,{count:Math.floor(a/1e3)})):f=e.stage===`starting`?t(`chat:agentRunActivity.startingTheModel`):e.stage===`responding`?t(`chat:agentRunActivity.preparingTheResponse`):e.stage===`processing_result`?t(`chat:agentRunActivity.processingToolResult`):e.stage===`waiting_retry`?t(`chat:agentRunActivity.waitingToRetry`):e.stage===`finalizing`?t(`chat:agentRunActivity.finalizingTheRun`):e.stage===`working`?t(`chat:agentRunActivity.advancingTheTask`):String(i||``).trim()?t(`chat:agentRunActivity.reasoningAboutTheNextStep`):String(r||``).trim()?t(`chat:agentRunActivity.preparingTheResponse`):t(`chat:agentRunActivity.understandingTheTask`):(d=`completed`,f=t(`chat:agentRunActivity.reasoningCompleted`),p=Q(i)),String(i||``).trim()&&(p=Q(i))}return{tone:d,title:f,detail:p,output:m,command:h,startedAt:g,changes:_}}function La({tone:e}){return e===`failed`?(0,Z.jsx)(Xe,{size:14}):e===`stopped`?(0,Z.jsx)(De,{size:12}):[`completed`,`plan`].includes(e)?(0,Z.jsx)(B,{size:14}):(0,Z.jsx)(G,{className:`animate-spin`,size:14})}function Ra({activity:e,className:t,children:n}){return e.type===`tool`?(0,Z.jsx)(`div`,{className:t,"data-pisper-activity-type":`tool`,children:n}):e.type===`plan`?(0,Z.jsx)(ya,{className:`${t} !gap-0 !rounded-none !border-0 !bg-transparent !p-0 !shadow-none`,"data-pisper-activity-type":`plan`,children:n}):e.type===`agent`?(0,Z.jsx)(ba,{className:t,"data-pisper-activity-type":`agent`,children:n}):(0,Z.jsx)(`div`,{className:t,"data-pisper-activity-type":e.type,children:n})}function za({output:e,streaming:t,t:n}){let r=wa(e),i=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(!t)return;let e=window.requestAnimationFrame(()=>{let e=i.current;e&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[r.text,t]),r.text.trim()?(0,Z.jsxs)(`details`,{className:`agent-run-command-output [.agent-run-feed:has(&[open])]:max-h-[320px] [&_>_summary]:grid [&_>_summary]:min-h-[30px] [&_>_summary]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_summary]:items-center [&_>_summary]:gap-[7px] [&_>_summary]:[list-style:none] [&_>_summary]:p-[5px_8px] [&_>_summary]:text-[var(--text-muted)] [&_>_summary]:text-[11px] [&_>_summary]:font-[600] [&_>_summary]:cursor-pointer [&_>_summary::-webkit-details-marker]:hidden [&_>_summary:hover]:bg-[var(--surface-hover)] [&_>_summary:hover]:text-[var(--text-secondary)] [&_>_summary:focus-visible]:[outline:2px_solid_var(--accent-border)] [&_>_summary:focus-visible]:[outline-offset:-2px] [&_>_summary_>_svg:first-child]:text-[var(--brand-blue-strong)] [&_>_pre]:max-h-[112px] [&_>_pre]:overflow-auto [&_>_pre]:m-0 [&_>_pre]:[border-top:1px_solid_var(--stroke-soft)] [&_>_pre]:bg-[var(--surface-subtle)] [&_>_pre]:p-[9px_10px] [&_>_pre]:text-[var(--text-secondary)] [&_>_pre]:font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] [&_>_pre]:text-[11px] [&_>_pre]:leading-[1.55] [&_>_pre]:whitespace-pre-wrap [&_>_pre]:[overflow-wrap:anywhere] [.agent-run-activity.compact_&]:[grid-column:1/-1] min-w-0 [grid-column:2/-1] overflow-hidden [margin:2px_0_1px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--solid)]`,"data-truncated":r.truncated||void 0,open:t||void 0,children:[(0,Z.jsxs)(`summary`,{children:[(0,Z.jsx)(_e,{size:13}),(0,Z.jsx)(`span`,{children:n(t?`chat:agentRunActivity.liveCommandOutput`:`chat:agentRunActivity.commandOutput`)}),(0,Z.jsx)(Ye,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:13})]}),(0,Z.jsx)(`pre`,{ref:i,children:r.text})]}):null}function Ba(e){if(e.type===`plan`)return!e.updatedAt;if(e.type===`tool`)return!e.status||e.status===`running`||!e.finishedAt&&!e.updatedAt;if(e.type===`agent`){let t=e.agent||{};return!t.status||[`queued`,`starting`,`running`].includes(t.status)||!t.completedAt&&!t.lastActivityAt&&!e.updatedAt}return!0}function Va(e,t){return e.activity!==t.activity||e.latest!==t.latest||e.t!==t.t||e.language!==t.language||e.runStartedAt!==t.runStartedAt||e.streaming!==t.streaming||e.now!==t.now&&Ba(t.activity)?!1:[`tool`,`plan`,`agent`].includes(t.activity.type)?!0:e.text===t.text&&e.thinkingText===t.thinkingText&&e.compaction===t.compaction&&e.error===t.error&&e.stopped===t.stopped&&e.notice===t.notice&&e.lastActivityAt===t.lastActivityAt}var Ha=(0,X.memo)(function({activity:e,latest:t,t:n,language:r,now:i,runStartedAt:a,streaming:o,text:s,thinkingText:c,compaction:l,error:u,stopped:d,notice:f,lastActivityAt:p}){let m=Ia(e,{t:n,streaming:o,text:s,thinkingText:c,compaction:l,error:u,stopped:d,notice:f,lastActivityAt:p,now:i}),h=Wi(Ui(e,a,i),r),g=e.name===`bash`&&t&&!!e.output;return(0,Z.jsxs)(Ra,{activity:e,className:`agent-run-summary grid w-full min-h-[42px] grid-cols-[28px_minmax(0,1fr)_auto] [align-items:start] gap-[9px] p-[6px_8px] hover:bg-[var(--surface-hover)] hover:opacity-100 [.agent-run-activity.compact_&]:min-h-[34px] [.agent-run-activity.compact_&]:grid-cols-[24px_minmax(0,1fr)_auto] [.agent-run-activity.compact_&]:gap-[7px] [.agent-run-activity.compact_&]:p-[4px_5px] @max-[700px]:grid-cols-[28px_minmax(0,1fr)_auto] @max-[700px]:[&_>_svg]:hidden flex-none [border:1px_solid_transparent] rounded-[var(--r-sm)] opacity-[.82] [transition:border-color_var(--d1)_var(--ease-out),_background_var(--d1)_var(--ease-out),_opacity_var(--d1)_var(--ease-out),_transform_var(--d1)_var(--ease-out)] ${m.tone} ${t?`current [.agent-run-summary&]:border-[var(--stroke-soft)] [.agent-run-summary&]:bg-[var(--surface-subtle)] [.agent-run-summary&]:opacity-100`:``}`,children:[(0,Z.jsx)(`span`,{className:`agent-run-status-icon [.agent-thinking-window.running_&]:text-[var(--brand-blue-strong)] [.agent-run-summary.completed_&]:bg-[var(--success-soft)] [.agent-run-summary.completed_&]:text-[var(--success)] [.agent-run-summary.plan_&]:bg-[var(--success-soft)] [.agent-run-summary.plan_&]:text-[var(--success)] [.agent-run-overview.completed_&]:bg-[var(--success-soft)] [.agent-run-overview.completed_&]:text-[var(--success)] [.agent-run-overview.plan_&]:bg-[var(--success-soft)] [.agent-run-overview.plan_&]:text-[var(--success)] [.agent-run-summary.compacting_&]:bg-[var(--warning-soft)] [.agent-run-summary.compacting_&]:text-[var(--star-strong)] [.agent-run-overview.compacting_&]:bg-[var(--warning-soft)] [.agent-run-overview.compacting_&]:text-[var(--star-strong)] [.agent-run-summary.failed_&]:bg-[var(--danger-soft)] [.agent-run-summary.failed_&]:text-[var(--danger)] [.agent-run-overview.failed_&]:bg-[var(--danger-soft)] [.agent-run-overview.failed_&]:text-[var(--danger)] [.agent-run-summary.stopped_&]:text-[var(--text-muted)] [.agent-run-overview.stopped_&]:text-[var(--text-muted)] [.agent-run-activity.compact_&]:w-[24px] [.agent-run-activity.compact_&]:h-[24px] grid w-[28px] h-[28px] place-items-center rounded-[var(--r-xs)] bg-[var(--blue-soft)] text-[var(--brand-blue-strong)]`,children:(0,Z.jsx)(La,{tone:m.tone})}),(0,Z.jsxs)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:[(0,Z.jsx)(`strong`,{children:m.title}),m.detail&&(m.command?(0,Z.jsxs)(`code`,{className:`agent-run-command overflow-hidden text-[var(--text-muted)] text-[12px] leading-[1.45] text-ellipsis whitespace-nowrap block max-h-[2.9em] p-[3px_7px] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] text-[var(--text-secondary)] font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] whitespace-pre-wrap [overflow-wrap:anywhere] [.agent-run-activity.compact_&]:text-[11px]`,title:m.detail,children:[`$ `,m.detail]}):(0,Z.jsx)(`small`,{title:m.detail,children:m.detail})),m.changes.length>0&&(0,Z.jsxs)(`span`,{className:`agent-run-plan-changes [&_small]:text-[var(--text-secondary)] flex min-w-0 flex-col gap-[1px] [padding:1px_0_0_7px] [border-left:1px_solid_var(--stroke-soft)]`,children:[m.changes.slice(0,4).map(e=>(0,Z.jsx)(`small`,{children:Pa(e,n)},`${e.id}-${e.kind}-${e.status}`)),m.changes.length>4&&(0,Z.jsx)(`small`,{children:n(`chat:agentRunActivity.countMoreChanges`,{count:m.changes.length-4})})]}),!g&&m.output&&m.output!==m.detail&&(0,Z.jsx)(`small`,{className:`text-[var(--text-tertiary)]`,title:m.output,children:m.output})]}),(0,Z.jsxs)(`span`,{className:`agent-run-duration inline-flex items-center gap-[4px] pt-[3px] text-[var(--text-muted)] font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] text-[11px] whitespace-nowrap [.agent-run-activity.compact_&]:text-[10px]`,children:[(0,Z.jsx)(pe,{size:12}),h]}),g&&(0,Z.jsx)(za,{output:e.output,streaming:!!(o&&e.status===`running`),t:n})]})},Va);function Ua({streaming:e,text:t,thinkingText:n,currentActivity:r,activityFeed:i=Ta,tools:a=Ta,compaction:o,error:s,stopped:c,notice:l,startedAt:u,lastActivityAt:d,finishedAt:f,compact:p=!1}){let{t:m,language:h}=g(),_=ja(e),v=String(n||``).trim(),y=(0,X.useRef)(null),b=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!v)return;let e=window.requestAnimationFrame(()=>{let e=y.current;e&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[v]);let x=i.length?i:a,S=Ii(x);if((0,X.useEffect)(()=>{if(!e||!x.length)return;let t=window.requestAnimationFrame(()=>{let e=b.current;e&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(t)},[S,x.length,e]),!e&&!v&&!x.length)return null;let C=Ia(Fi({currentActivity:r,compaction:o,text:t,thinkingText:n,lastActivityAt:d}),{t:m,streaming:e,text:t,thinkingText:v?``:n,compaction:o,error:s,stopped:c,notice:l,lastActivityAt:d,now:_});!e&&x.length&&(C.title=m(`chat:agentRunActivity.currentOperationCompleted`),C.detail=``);let w=e?0:x.length,T=!!(e||o?.active||s||c),E=Wi(Hi(u,f,_),h),D=C.command&&x.length?m(`chat:agentRunActivity.countLiveOperations`,{count:x.length}):C.detail,O=r=>r.map((i,a)=>(0,Z.jsx)(Ha,{activity:i,compaction:o,error:s,language:h,lastActivityAt:d,latest:a===r.length-1,notice:l,now:_,runStartedAt:u,stopped:c,streaming:e,t:m,text:t,thinkingText:v?``:n},Li(i,a))),k=O(x),A=O(x.slice(-1));return(0,Z.jsxs)(`section`,{className:`agent-run-activity [&.compact]:m-[4px_0_0_40px] w-full overflow-hidden [margin:1px_0_9px] text-[var(--text)] ${p?`compact`:``}`,"aria-live":`polite`,children:[v&&(0,Z.jsxs)(`details`,{className:`agent-thinking-window [&[open]]:border-[var(--stroke-soft)] [&.completed]:border-[transparent] [&.completed[open]]:border-[var(--stroke-soft)] overflow-hidden [margin:1px_0_8px] [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-transparent [transition:border-color_var(--d1)_var(--ease-out)] ${e?`running`:`completed`}`,"data-pisper-activity-type":`reasoning`,children:[(0,Z.jsxs)(`summary`,{className:`agent-thinking-head [summary&]:[list-style:none] [summary&]:cursor-pointer [summary&::-webkit-details-marker]:hidden [summary&:hover]:bg-[var(--surface-hover)] [summary&:focus-visible]:[outline:2px_solid_var(--accent-border)] [summary&:focus-visible]:[outline-offset:-2px] grid min-h-[40px] grid-cols-[28px_minmax(0,1fr)_auto] items-center gap-[9px] [padding:6px_8px]`,"aria-label":m(`chat:agentRunActivity.toggleReasoning`),children:[(0,Z.jsx)(`span`,{className:`agent-run-status-icon [.agent-thinking-window.running_&]:text-[var(--brand-blue-strong)] [.agent-run-summary.completed_&]:bg-[var(--success-soft)] [.agent-run-summary.completed_&]:text-[var(--success)] [.agent-run-summary.plan_&]:bg-[var(--success-soft)] [.agent-run-summary.plan_&]:text-[var(--success)] [.agent-run-overview.completed_&]:bg-[var(--success-soft)] [.agent-run-overview.completed_&]:text-[var(--success)] [.agent-run-overview.plan_&]:bg-[var(--success-soft)] [.agent-run-overview.plan_&]:text-[var(--success)] [.agent-run-summary.compacting_&]:bg-[var(--warning-soft)] [.agent-run-summary.compacting_&]:text-[var(--star-strong)] [.agent-run-overview.compacting_&]:bg-[var(--warning-soft)] [.agent-run-overview.compacting_&]:text-[var(--star-strong)] [.agent-run-summary.failed_&]:bg-[var(--danger-soft)] [.agent-run-summary.failed_&]:text-[var(--danger)] [.agent-run-overview.failed_&]:bg-[var(--danger-soft)] [.agent-run-overview.failed_&]:text-[var(--danger)] [.agent-run-summary.stopped_&]:text-[var(--text-muted)] [.agent-run-overview.stopped_&]:text-[var(--text-muted)] [.agent-run-activity.compact_&]:w-[24px] [.agent-run-activity.compact_&]:h-[24px] grid w-[28px] h-[28px] place-items-center rounded-[var(--r-xs)] bg-[var(--blue-soft)] text-[var(--brand-blue-strong)]`,children:(0,Z.jsx)(Ye,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:14})}),(0,Z.jsx)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:(0,Z.jsxs)(`strong`,{children:[m(e?`chat:agentRunActivity.reasoningInProgress`:`chat:agentRunActivity.reasoningCompleted`),e?(0,Z.jsxs)(`span`,{className:`agent-thinking-dots [&_i]:w-[3px] [&_i]:h-[3px] [&_i]:rounded-[50%] [&_i]:bg-[currentColor] [&_i]:[animation:agent-thinking-dot_1.15s_ease-in-out_infinite] [&_i:nth-child(2)]:[animation-delay:.14s] [&_i:nth-child(3)]:[animation-delay:.28s] inline-flex items-end gap-[2px] [margin-left:5px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{})]}):null]})}),(0,Z.jsxs)(`span`,{className:`agent-run-duration inline-flex items-center gap-[4px] pt-[3px] text-[var(--text-muted)] font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] text-[11px] whitespace-nowrap [.agent-run-activity.compact_&]:text-[10px]`,children:[(0,Z.jsx)(pe,{size:12}),E]})]}),(0,Z.jsx)(`div`,{ref:y,className:`agent-thinking-scroll max-h-[190px] overflow-auto [border-top:1px_solid_var(--stroke-soft)] [padding:9px_12px] [scroll-behavior:smooth]`,children:(0,Z.jsx)(me,{streaming:e,children:v})})]}),T&&(0,Z.jsxs)(`div`,{className:`agent-run-overview grid w-full min-h-[42px] grid-cols-[28px_minmax(0,1fr)_auto] [align-items:start] gap-[9px] p-[6px_8px] [.agent-run-activity.compact_&]:min-h-[34px] [.agent-run-activity.compact_&]:grid-cols-[24px_minmax(0,1fr)_auto] [.agent-run-activity.compact_&]:gap-[7px] [.agent-run-activity.compact_&]:p-[4px_5px] ${C.tone}`,"data-pisper-activity-type":`status`,children:[(0,Z.jsx)(`span`,{className:`agent-run-status-icon [.agent-thinking-window.running_&]:text-[var(--brand-blue-strong)] [.agent-run-summary.completed_&]:bg-[var(--success-soft)] [.agent-run-summary.completed_&]:text-[var(--success)] [.agent-run-summary.plan_&]:bg-[var(--success-soft)] [.agent-run-summary.plan_&]:text-[var(--success)] [.agent-run-overview.completed_&]:bg-[var(--success-soft)] [.agent-run-overview.completed_&]:text-[var(--success)] [.agent-run-overview.plan_&]:bg-[var(--success-soft)] [.agent-run-overview.plan_&]:text-[var(--success)] [.agent-run-summary.compacting_&]:bg-[var(--warning-soft)] [.agent-run-summary.compacting_&]:text-[var(--star-strong)] [.agent-run-overview.compacting_&]:bg-[var(--warning-soft)] [.agent-run-overview.compacting_&]:text-[var(--star-strong)] [.agent-run-summary.failed_&]:bg-[var(--danger-soft)] [.agent-run-summary.failed_&]:text-[var(--danger)] [.agent-run-overview.failed_&]:bg-[var(--danger-soft)] [.agent-run-overview.failed_&]:text-[var(--danger)] [.agent-run-summary.stopped_&]:text-[var(--text-muted)] [.agent-run-overview.stopped_&]:text-[var(--text-muted)] [.agent-run-activity.compact_&]:w-[24px] [.agent-run-activity.compact_&]:h-[24px] grid w-[28px] h-[28px] place-items-center rounded-[var(--r-xs)] bg-[var(--blue-soft)] text-[var(--brand-blue-strong)]`,children:(0,Z.jsx)(La,{tone:C.tone})}),(0,Z.jsxs)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:[(0,Z.jsx)(`strong`,{children:e&&[`running`,`waiting`,`compacting`].includes(C.tone)?(0,Z.jsx)(X.Suspense,{fallback:C.title,children:(0,Z.jsx)(Da,{children:C.title})}):C.title}),D&&(0,Z.jsx)(`small`,{title:D,children:D})]}),(0,Z.jsxs)(`span`,{className:`agent-run-duration inline-flex items-center gap-[4px] pt-[3px] text-[var(--text-muted)] font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] text-[11px] whitespace-nowrap [.agent-run-activity.compact_&]:text-[10px]`,children:[(0,Z.jsx)(pe,{size:12}),E]})]}),e&&x.length>0&&(0,Z.jsx)(`div`,{ref:b,className:`agent-run-feed focus-visible:[outline:2px_solid_var(--accent-border)] focus-visible:[outline-offset:2px] [.agent-run-history_&.completed]:mt-[3px] flex max-h-[184px] flex-col gap-[4px] overflow-y-auto [overscroll-behavior:contain] [margin:5px_0_2px] [padding:2px_4px_2px_0] [scrollbar-gutter:stable] live`,"aria-label":m(`chat:agentRunActivity.toolActivityAriaLabel`),children:(0,Z.jsx)(X.Suspense,{fallback:A,children:(0,Z.jsx)(Ea,{children:A})})}),w>0&&(0,Z.jsxs)(`details`,{className:`agent-run-history [&_>_summary]:grid [&_>_summary]:min-h-[38px] [&_>_summary]:grid-cols-[28px_minmax(0,1fr)_auto] [&_>_summary]:items-center [&_>_summary]:gap-[9px] [&_>_summary]:[list-style:none] [&_>_summary]:rounded-[var(--r-sm)] [&_>_summary]:p-[5px_8px] [&_>_summary]:text-[var(--text-muted)] [&_>_summary]:cursor-pointer [&_>_summary::-webkit-details-marker]:hidden [&_>_summary:hover]:bg-[var(--surface-hover)] [&_>_summary:hover]:text-[var(--text)] [&_>_summary:focus-visible]:[outline:2px_solid_var(--accent-border)] [&_>_summary:focus-visible]:[outline-offset:-2px] w-full`,children:[(0,Z.jsxs)(`summary`,{children:[(0,Z.jsx)(`span`,{className:`agent-run-status-icon [.agent-thinking-window.running_&]:text-[var(--brand-blue-strong)] [.agent-run-summary.completed_&]:bg-[var(--success-soft)] [.agent-run-summary.completed_&]:text-[var(--success)] [.agent-run-summary.plan_&]:bg-[var(--success-soft)] [.agent-run-summary.plan_&]:text-[var(--success)] [.agent-run-overview.completed_&]:bg-[var(--success-soft)] [.agent-run-overview.completed_&]:text-[var(--success)] [.agent-run-overview.plan_&]:bg-[var(--success-soft)] [.agent-run-overview.plan_&]:text-[var(--success)] [.agent-run-summary.compacting_&]:bg-[var(--warning-soft)] [.agent-run-summary.compacting_&]:text-[var(--star-strong)] [.agent-run-overview.compacting_&]:bg-[var(--warning-soft)] [.agent-run-overview.compacting_&]:text-[var(--star-strong)] [.agent-run-summary.failed_&]:bg-[var(--danger-soft)] [.agent-run-summary.failed_&]:text-[var(--danger)] [.agent-run-overview.failed_&]:bg-[var(--danger-soft)] [.agent-run-overview.failed_&]:text-[var(--danger)] [.agent-run-summary.stopped_&]:text-[var(--text-muted)] [.agent-run-overview.stopped_&]:text-[var(--text-muted)] [.agent-run-activity.compact_&]:w-[24px] [.agent-run-activity.compact_&]:h-[24px] grid w-[28px] h-[28px] place-items-center rounded-[var(--r-xs)] bg-[var(--blue-soft)] text-[var(--brand-blue-strong)]`,children:(0,Z.jsx)(Ye,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:14})}),(0,Z.jsx)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:(0,Z.jsx)(`strong`,{children:m(`chat:agentRunActivity.countCompletedOperations`,{count:w})})}),(0,Z.jsxs)(`span`,{className:`agent-run-duration inline-flex items-center gap-[4px] pt-[3px] text-[var(--text-muted)] font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] text-[11px] whitespace-nowrap [.agent-run-activity.compact_&]:text-[10px]`,children:[(0,Z.jsx)(pe,{size:12}),E]})]}),(0,Z.jsx)(`div`,{className:`agent-run-feed focus-visible:[outline:2px_solid_var(--accent-border)] focus-visible:[outline-offset:2px] [.agent-run-history_&.completed]:mt-[3px] flex max-h-[184px] flex-col gap-[4px] overflow-y-auto [overscroll-behavior:contain] [margin:5px_0_2px] [padding:2px_4px_2px_0] [scrollbar-gutter:stable] completed`,"aria-label":m(`chat:agentRunActivity.toolActivityAriaLabel`),tabIndex:x.length>3?0:void 0,children:(0,Z.jsx)(X.Suspense,{fallback:k,children:k})})]})]})}function Wa(e,t){return e.streaming===t.streaming&&e.text===t.text&&e.thinkingText===t.thinkingText&&e.currentActivity===t.currentActivity&&e.activityFeed===t.activityFeed&&e.compaction===t.compaction&&e.error===t.error&&e.stopped===t.stopped&&e.notice===t.notice&&e.startedAt===t.startedAt&&e.lastActivityAt===t.lastActivityAt&&e.finishedAt===t.finishedAt&&e.compact===t.compact&&e.tools===t.tools}var Ga=(0,X.memo)(Ua,Wa);function $(e){return e instanceof Error?e.message:String(e)}function Ka(e){return/(?:当前会话已经结束运行|session .*?(?:ended|finished|no longer running))/i.test($(e))}function qa({className:e,from:t,...n}){return(0,Z.jsx)(`div`,{"data-ai-element":`message`,"data-role":t,className:V(`group flex w-full max-w-[95%] flex-col gap-2`,t===`user`?`is-user ml-auto justify-end`:`is-assistant`,e),...n})}function Ja({attachment:e,source:t,onClose:n}){let{t:r}=g();return(0,X.useEffect)(()=>{let e=document.body.style.overflow,t=e=>{e.key===`Escape`&&n()};return document.body.style.overflow=`hidden`,window.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,t)}},[n]),(0,Z.jsxs)(`div`,{className:`image-lightbox [&_>_img]:w-full [&_>_img]:h-full [&_>_img]:min-h-0 [&_>_img]:object-contain fixed z-[100] inset-0 grid grid-rows-[auto_minmax(0,1fr)] gap-[12px] bg-[var(--lightbox-bg)] [padding:18px_24px_24px] [backdrop-filter:blur(8px)]`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`chat:chatMessage.fullScreenImagePreview`),onMouseDown:e=>e.target===e.currentTarget&&n(),children:[(0,Z.jsxs)(`div`,{className:`image-lightbox-toolbar [&_>_span]:overflow-hidden [&_>_span]:text-[13px] [&_>_span]:font-[700] [&_>_span]:text-ellipsis [&_>_span]:whitespace-nowrap [&_>_div]:flex [&_>_div]:flex-none [&_>_div]:items-center [&_>_div]:gap-[8px] flex min-w-0 items-center justify-between gap-[16px] text-[var(--on-ink)]`,children:[(0,Z.jsx)(`span`,{title:e.name,children:e.name||r(`chat:chatMessage.generatedImage`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{asChild:!0,size:`lg`,className:`border border-[var(--lightbox-action-border)] bg-[var(--lightbox-action-bg)] text-[var(--lightbox-action-text)] shadow-[0_8px_24px_var(--lightbox-action-shadow)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)]`,children:(0,Z.jsxs)(`a`,{href:e.downloadUrl||t,download:e.name||`generated-image`,children:[(0,Z.jsx)(ze,{size:14}),r(`chat:chatMessage.downloadOriginal`)]})}),(0,Z.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`bg-[var(--lightbox-control-bg)] text-[var(--on-ink)] hover:bg-[var(--lightbox-control-bg)] hover:text-[var(--on-ink)]`,"aria-label":r(`chat:chatMessage.closePreview`),onClick:n,children:(0,Z.jsx)(it,{size:18})})]})]}),(0,Z.jsx)(`img`,{alt:e.name||r(`chat:chatMessage.generatedImage`),decoding:`async`,src:t})]})}function Ya({attachments:e,compact:t=!1}){let{t:n}=g(),[r,i]=(0,X.useState)(null);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`message-attachments flex flex-wrap gap-[6px] [margin-top:6px] ${t?`compact`:``}`,children:e.map((e,t)=>{let r=e.id||t,a=e.url||(e.data?`data:${e.mimeType};base64,${e.data}`:``);return e.kind===`image`&&a?(0,Z.jsxs)(`button`,{type:`button`,className:`generated-media [.message-attachments_&]:flex [.message-attachments_&]:w-[min(360px,100%)] [.message-attachments_&]:flex-col [.message-attachments_&]:gap-[5px] [.message-attachments_&]:text-[var(--text-muted)] [.message-attachments_&]:no-underline [.message-attachments_button&]:border-0 [.message-attachments_button&]:bg-transparent [.message-attachments_button&]:p-0 [.message-attachments_button&]:text-left [.message-attachments_button&]:[cursor:zoom-in] [.message-attachments_&_img]:w-full [.message-attachments_&_img]:max-h-[320px] [.message-attachments_&_img]:[border:1px_solid_var(--stroke)] [.message-attachments_&_img]:rounded-[var(--r-sm)] [.message-attachments_&_img]:object-contain [.message-attachments_&_img]:bg-[var(--media-bg)] [.message-attachments_&_video]:w-full [.message-attachments_&_video]:max-h-[320px] [.message-attachments_&_video]:[border:1px_solid_var(--stroke)] [.message-attachments_&_video]:rounded-[var(--r-sm)] [.message-attachments_&_video]:object-contain [.message-attachments_&_video]:bg-[var(--media-bg)] [.message-attachments_&_small]:overflow-hidden [.message-attachments_&_small]:text-[13px] [.message-attachments_&_small]:text-ellipsis [.message-attachments_&_small]:whitespace-nowrap [.message-attachments.compact_&]:w-[min(190px,100%)] [.message-attachments.compact_&_img]:max-h-[130px] [.message-attachments.compact_&_video]:max-h-[130px]`,onClick:()=>i({attachment:e,source:a}),title:n(`chat:chatMessage.openFullScreenPreview`),children:[(0,Z.jsx)(`img`,{alt:e.name||n(`chat:chatMessage.imageAttachment`),decoding:`async`,loading:`lazy`,src:a}),(0,Z.jsx)(`small`,{children:e.name||n(`chat:chatMessage.generatedImage`)})]},r):e.kind===`video`&&a?(0,Z.jsxs)(`div`,{className:`generated-media [.message-attachments_&]:flex [.message-attachments_&]:w-[min(360px,100%)] [.message-attachments_&]:flex-col [.message-attachments_&]:gap-[5px] [.message-attachments_&]:text-[var(--text-muted)] [.message-attachments_&]:no-underline [.message-attachments_button&]:border-0 [.message-attachments_button&]:bg-transparent [.message-attachments_button&]:p-0 [.message-attachments_button&]:text-left [.message-attachments_button&]:[cursor:zoom-in] [.message-attachments_&_img]:w-full [.message-attachments_&_img]:max-h-[320px] [.message-attachments_&_img]:[border:1px_solid_var(--stroke)] [.message-attachments_&_img]:rounded-[var(--r-sm)] [.message-attachments_&_img]:object-contain [.message-attachments_&_img]:bg-[var(--media-bg)] [.message-attachments_&_video]:w-full [.message-attachments_&_video]:max-h-[320px] [.message-attachments_&_video]:[border:1px_solid_var(--stroke)] [.message-attachments_&_video]:rounded-[var(--r-sm)] [.message-attachments_&_video]:object-contain [.message-attachments_&_video]:bg-[var(--media-bg)] [.message-attachments_&_small]:overflow-hidden [.message-attachments_&_small]:text-[13px] [.message-attachments_&_small]:text-ellipsis [.message-attachments_&_small]:whitespace-nowrap [.message-attachments.compact_&]:w-[min(190px,100%)] [.message-attachments.compact_&_img]:max-h-[130px] [.message-attachments.compact_&_video]:max-h-[130px] video`,children:[(0,Z.jsx)(`video`,{controls:!0,preload:`metadata`,src:a}),(0,Z.jsx)(`small`,{children:e.name||n(`chat:chatMessage.generatedVideo`)})]},r):(0,Z.jsxs)(`a`,{className:`message-file-attachment [.message-attachments_&]:inline-flex [.message-attachments_&]:items-center [.message-attachments_&]:gap-[5px] [.message-attachments_&]:[border:1px_solid_var(--stroke)] [.message-attachments_&]:rounded-[var(--r-xs)] [.message-attachments_&]:bg-[var(--solid)] [.message-attachments_&]:p-[5px_7px] [.message-attachments_&]:text-[var(--text-tertiary)] [.message-attachments_&]:text-[13px] [.message-attachments_&]:no-underline`,href:e.downloadUrl||void 0,children:[(0,Z.jsx)(ye,{size:12}),e.name||n(`chat:chatMessage.fileAttachment`)]},r)})}),r&&(0,mi.createPortal)((0,Z.jsx)(Ja,{attachment:r.attachment,source:r.source,onClose:()=>i(null)}),document.body)]})}function Xa({sessionId:e,entryId:t}){let{t:n}=g(),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(``),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``);(0,X.useEffect)(()=>{if(!r)return;let n=!0;return d(!0),h(``),J.getSessionTree(e).then(e=>{if(!n)return;let r=e.nodes.find(e=>e.id===t)?.label||``;o(r),c(r)}).catch(e=>n&&h($(e))).finally(()=>n&&d(!1)),()=>{n=!1}},[t,r,e]);let _=async()=>{if(!(f||u)){p(!0),h(``);try{let n=(await J.setSessionTreeLabel(e,t,a)).nodes.find(e=>e.id===t)?.label||``;o(n),c(n),i(!1)}catch(e){h($(e))}finally{p(!1)}}},v=async()=>{if(!(f||u)){p(!0),h(``);try{let n=(await J.setSessionTreeLabel(e,t,``)).nodes.find(e=>e.id===t)?.label||``;o(n),c(n),i(!1)}catch(e){h($(e))}finally{p(!1)}}};return(0,Z.jsxs)(hi,{open:r,onOpenChange:i,children:[(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(Ve,{asChild:!0,children:(0,Z.jsx)(gi,{asChild:!0,children:(0,Z.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,className:s?`bg-surface-hover text-brand`:void 0,"aria-label":n(`chat:chatMessage.labelThisTurn`),"data-pisper-label-entry":t,children:(0,Z.jsx)(Oe,{size:14})})})}),(0,Z.jsx)(et,{side:`top`,sideOffset:6,children:n(`chat:chatMessage.labelThisTurn`)})]}),(0,Z.jsx)(_i,{className:`message-label-popover [&_form]:grid [&_form]:gap-[10px] [&_[data-slot='popover-title']]:text-[12px]`,align:`end`,sideOffset:6,children:(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_()},children:[(0,Z.jsx)(vi,{children:n(`chat:sessionTree.nodeLabel`)}),(0,Z.jsx)(W,{autoFocus:!0,value:a,maxLength:80,disabled:u||f,placeholder:n(`chat:sessionTree.labelPlaceholder`),onChange:e=>o(e.target.value)}),m&&(0,Z.jsx)(`small`,{className:`danger-text`,children:m}),(0,Z.jsxs)(`div`,{className:`message-label-actions flex items-center justify-between gap-[8px]`,children:[(0,Z.jsx)(l,{type:`button`,size:`icon-sm`,variant:`ghost`,title:n(`chat:sessionTree.removeLabel`),"aria-label":n(`chat:sessionTree.removeLabel`),disabled:u||f,onClick:()=>void v(),children:(0,Z.jsx)(ke,{})}),(0,Z.jsxs)(l,{className:`message-label-save [.message-label-actions_&]:min-w-[104px] [.message-label-actions_&]:text-[var(--primary-foreground)]`,type:`submit`,disabled:u||f,children:[f?(0,Z.jsx)(be,{className:`animate-spin`}):(0,Z.jsx)(B,{}),n(f?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]})]})]})})]})}function Za(e,t){return e.sessionId===t.sessionId&&e.message===t.message&&e.agentState===t.agentState&&e.showRunActivity===t.showRunActivity&&e.runProps===t.runProps&&e.sessionStreaming===t.sessionStreaming&&e.onBranchFromHere===t.onBranchFromHere&&e.onCreateChildSession===t.onCreateChildSession}var Qa=(0,X.memo)(function({sessionId:e,message:t,agentState:n,showRunActivity:r,runProps:i,sessionStreaming:a,onBranchFromHere:o,onCreateChildSession:s}){let{t:c}=g(),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),m=!!t.streaming,h=t.text||(r?``:String(t.error||``));return(0,Z.jsxs)(qa,{from:t.role===`agent`?`assistant`:`user`,className:`message [&.user]:items-end [&.user_>_span]:hidden [&.agent]:grid [&.agent]:grid-cols-[24px_minmax(0,1fr)] [&.agent]:[align-items:start] [&.agent]:gap-x-[12px] [&_>_span]:flex [&_>_span]:items-center [&_>_span]:gap-[5px] [&_>_span]:p-0 [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[12px] [&_>_span]:font-[600] [&.agent_>_span]:[grid-column:1] [&.agent_>_span]:[grid-row:1] [&.agent_>_span]:justify-center [&.agent_>_span]:pt-[4px] @max-[470px]:[&.agent]:grid-cols-[22px_minmax(0,1fr)] @max-[470px]:[&.agent]:gap-x-[9px] flex w-[min(900px,100%)] flex-col items-start gap-[6px] [margin:0_auto_30px] ${t.role} ${t.error?`has-error`:``}`,"data-pisper-message-id":t.id,"data-pisper-role":t.role,"data-pisper-streaming":m||void 0,"data-pisper-error":t.error?`true`:void 0,children:[(0,Z.jsx)(`span`,{children:t.role===`agent`?(0,Z.jsx)(`span`,{className:`agent-message-mark [&[data-state='thinking']]:opacity-100 [&[data-state='thinking']]:[animation:agent-message-pulse_1.8s_ease-in-out_infinite] [&[data-state='waiting']]:opacity-[.9] grid w-[22px] h-[22px] place-items-center rounded-[var(--r-xs)] text-[var(--text-muted)] opacity-[.72] [transition:opacity_var(--d1)_var(--ease-out),_transform_var(--d1)_var(--ease-out)]`,"data-state":n,"aria-label":`Pisper`,children:(0,Z.jsx)(ut,{size:20})}):`You`}),(0,Z.jsxs)(`div`,{className:`message-content [.message.agent_&]:w-full [.message.agent_&]:[grid-column:2] [.message.agent_&]:[grid-row:1] [.message.user_&]:w-[fit-content] [.message.user_&]:max-w-[76%] @max-[700px]:[.message.user_&]:max-w-[86%] @max-[470px]:[.message.user_&]:max-w-[92%] max-[650px]:[.message.user_&]:max-w-[86%] relative min-w-0`,children:[r&&i&&(0,Z.jsx)(Ga,{...i}),h&&(0,Z.jsx)(me,{streaming:m,children:h}),t.attachments&&t.attachments.length>0&&(0,Z.jsx)(Ya,{attachments:t.attachments})]}),t.role===`agent`&&t.turnBoundaryEntryId&&!m&&(0,Z.jsxs)(`div`,{className:`chat-history-actions [&_button]:grid [&_button]:w-[30px] [&_button]:h-[30px] [&_button]:min-h-[30px] [&_button]:place-items-center [&_button]:border-0 [&_button]:rounded-[var(--r-xs)] [&_button]:bg-transparent [&_button]:text-[var(--text-muted)] [&_button:hover]:bg-[var(--solid)] [&_button:hover]:text-[var(--text)] [&_button.active]:bg-[var(--star-soft)] [&_button.active]:text-[var(--star-strong)] [&_button.danger:hover]:bg-[var(--danger-soft)] [&_button.danger:hover]:text-[var(--danger)] max-[650px]:pr-[4px] flex items-center gap-[2px] [padding-right:8px] message-actions`,style:{gridColumn:2,gridRow:2,paddingRight:0},children:[(0,Z.jsx)(Xa,{sessionId:e,entryId:t.turnBoundaryEntryId}),(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(Ve,{asChild:!0,children:(0,Z.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":c(`chat:chatMessage.deriveFromHere`),"data-pisper-derive-entry":t.turnBoundaryEntryId,disabled:u||f||a,onClick:async()=>{let e=t.turnBoundaryEntryId;if(e){d(!0);try{await o(e)}finally{d(!1)}}},children:u?(0,Z.jsx)(be,{className:`animate-spin`,size:14}):(0,Z.jsx)(ar,{size:14})})}),(0,Z.jsx)(et,{side:`top`,sideOffset:6,children:c(`chat:chatMessage.deriveFromHere`)})]}),(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(Ve,{asChild:!0,children:(0,Z.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":c(`chat:chatMessage.createChildChat`),"data-pisper-child-entry":t.turnBoundaryEntryId,disabled:u||f,onClick:async()=>{let e=t.turnBoundaryEntryId;if(e){p(!0);try{await s(e)}finally{p(!1)}}},children:f?(0,Z.jsx)(be,{className:`animate-spin`,size:14}):(0,Z.jsx)(ur,{size:14})})}),(0,Z.jsx)(et,{side:`top`,sideOffset:6,children:c(`chat:chatMessage.createChildChat`)})]})]})]})},Za);function $a(e,t){return e.message===t.message}(0,X.memo)(function({message:e}){return(0,Z.jsxs)(qa,{from:e.role===`agent`?`assistant`:`user`,className:`mini-message [&_>_span]:pt-[5px] [&_>_span]:text-[var(--text-muted)] [&_>_span]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_>_span]:text-[13px] [&_>_span]:font-[600] [&_>_span]:[text-transform:uppercase] [&.agent_>_span::before]:[content:'✦'] [&.agent_>_span::before]:mr-[4px] [&.agent_>_span::before]:text-[var(--star)] grid grid-cols-[34px_minmax(0,1fr)] gap-[6px] [margin-bottom:6px] [align-items:start] ${e.role}`,"data-pisper-message-id":e.id,"data-pisper-role":e.role,"data-pisper-streaming":e.streaming||void 0,children:[(0,Z.jsx)(`span`,{children:e.role===`agent`?`Pisper`:`You`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(e.text||!e.streaming)&&(0,Z.jsx)(me,{streaming:e.streaming,children:e.text}),e.attachments&&e.attachments.length>0&&(0,Z.jsx)(Ya,{attachments:e.attachments,compact:!0})]})]})},$a);function eo(e,t){let n=t?.borderBoxSize?.[0];return Math.ceil(n?.blockSize??e.getBoundingClientRect().height)}function to(e,t,n){let[r,i]=(0,X.useState)(0);return(0,X.useLayoutEffect)(()=>{let r=n.current;if(!e||!r)return;let a=()=>{let t=Math.max(0,r.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop);i(e=>Math.abs(e-t)<1?e:t)};a();let o=typeof ResizeObserver>`u`?null:new ResizeObserver(a);return o?.observe(e),t.current&&o?.observe(t.current),window.addEventListener(`resize`,a),()=>{o?.disconnect(),window.removeEventListener(`resize`,a)}},[n,t,e]),r}var no=(0,X.memo)(function({sessionId:e,messages:t,streaming:n,latestRunProps:r,measurementVersion:i,scrollElement:a,prefixRef:o,targetEntryId:s,onContentSizeChange:c,onTargetLocated:l,onBranchFromHere:u,onCreateChildSession:d}){let f=(0,X.useRef)(null),[p,m]=(0,X.useState)(``),h=(0,X.useRef)(t);h.current=t;let g=to(a,o,f),_=(0,X.useCallback)(e=>h.current[e]?.id??`transcript-message-${e}`,[]),v=ha({count:t.length,getScrollElement:()=>a,getItemKey:_,estimateSize:()=>164,measureElement:eo,overscan:6,scrollMargin:g,useAnimationFrameWithResizeObserver:!0}),y=v.getVirtualItems(),b=v.getTotalSize(),x=t[t.length-1];return(0,X.useLayoutEffect)(()=>{c()},[c,b]),(0,X.useLayoutEffect)(()=>{if(!x)return;let e=v.elementsCache.get(x.id);e&&v.measureElement(e)},[x,i,v]),(0,X.useEffect)(()=>{if(!s)return;let e=t.findIndex(e=>e.turnBoundaryEntryId===s);if(e<0)return;v.scrollToIndex(e,{align:`center`}),m(s);let n=window.requestAnimationFrame(()=>{v.scrollToIndex(e,{align:`center`}),l(s)});return()=>window.cancelAnimationFrame(n)},[t,l,s,v]),(0,X.useEffect)(()=>{if(!p)return;let e=window.setTimeout(()=>m(``),2200);return()=>window.clearTimeout(e)},[p]),(0,Z.jsx)(`div`,{className:`relative w-full`,"data-pisper-transcript-size":t.length,"data-pisper-rendered-count":y.length,ref:f,style:{height:`${b}px`},children:y.map(i=>{let a=t[i.index];if(!a)return null;let o=a.role===`agent`&&i.index===t.length-1,s=a.streaming||o&&n?`thinking`:o&&!a.error?`waiting`:`idle`,c=Fr(a,o,r);return(0,Z.jsx)(`div`,{className:`virtual-transcript-item absolute left-0 [display:flow-root] w-full rounded-[var(--r-sm)] ${a.turnBoundaryEntryId===p?`targeted [.virtual-transcript-item&]:bg-[var(--star-soft)] [.virtual-transcript-item&]:shadow-[inset_3px_0_0_var(--star-strong)]`:``}`,"data-index":i.index,"data-pisper-target-entry":a.turnBoundaryEntryId===p?a.turnBoundaryEntryId:void 0,"data-pisper-virtual-item":a.id,ref:v.measureElement,style:{top:`${i.start-g}px`},children:(0,Z.jsx)(Qa,{sessionId:e,message:a,agentState:s,showRunActivity:!!c,runProps:c,sessionStreaming:n,onBranchFromHere:u,onCreateChildSession:d})},i.key)})})});function ro(){let e=(0,X.useId)();return(0,Z.jsxs)(`div`,{className:`relative grid h-[124px] w-[124px] place-items-center`,"aria-hidden":`true`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-[4px] rounded-full bg-[radial-gradient(circle,rgba(168,85,247,.17),transparent_68%)] [animation:agent-aura-think_3.6s_ease-in-out_infinite]`}),(0,Z.jsxs)(`svg`,{className:`absolute inset-0 h-full w-full [animation:galaxy-orbit-drift_22s_linear_infinite]`,viewBox:`0 0 124 124`,fill:`none`,children:[(0,Z.jsx)(`defs`,{children:(0,Z.jsxs)(`linearGradient`,{id:e,x1:`0`,y1:`0`,x2:`124`,y2:`124`,gradientUnits:`userSpaceOnUse`,children:[(0,Z.jsx)(`stop`,{offset:`0`,stopColor:`#8B5CF6`}),(0,Z.jsx)(`stop`,{offset:`0.55`,stopColor:`#A855F7`}),(0,Z.jsx)(`stop`,{offset:`1`,stopColor:`#EC4899`})]})}),(0,Z.jsx)(`circle`,{cx:`62`,cy:`62`,r:`52`,stroke:`url(#${e})`,strokeWidth:`1.2`,strokeDasharray:`2.5 7`,opacity:`0.7`}),(0,Z.jsx)(`circle`,{cx:`62`,cy:`10`,r:`3.2`,fill:`#A855F7`}),(0,Z.jsx)(`circle`,{cx:`107`,cy:`88`,r:`2.6`,fill:`#EC4899`}),(0,Z.jsx)(`circle`,{cx:`17`,cy:`88`,r:`2.2`,fill:`#1783ff`})]}),(0,Z.jsx)(`div`,{className:`grid h-[68px] w-[68px] place-items-center rounded-[22px] border border-[color-mix(in_srgb,#A855F7_24%,var(--stroke))] bg-[var(--solid)] shadow-[0_18px_44px_-24px_rgba(168,85,247,.45)]`,children:(0,Z.jsx)(ut,{size:40})})]})}var io=(0,X.lazy)(()=>i(()=>import(`./WelcomeEffects-Bf8Z6qHU.js`),__vite__mapDeps([9,1,2,3,4,7])));function ao({children:e,title:t}){return(0,Z.jsxs)(`div`,{className:`agent-welcome-content grid w-full max-w-[680px] place-items-center [padding:12px_20px_30px]`,children:[(0,Z.jsx)(`div`,{className:`[animation:transcript-stage-enter_.5s_var(--ease-out)_both]`,children:(0,Z.jsx)(ro,{})}),(0,Z.jsx)(`h2`,{className:`text-[var(--accent-strong)]`,children:t}),e]})}function oo({label:e}){return(0,Z.jsxs)(`div`,{className:`session-history-loading grid min-h-[100%] place-content-center justify-items-center gap-[24px] text-[var(--text-muted)] [animation:transcript-stage-enter_.18s_var(--ease-out)_both]`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-[10px]`,children:[(0,Z.jsx)(`span`,{className:`grid h-[34px] w-[34px] place-items-center rounded-[11px] border border-[color-mix(in_srgb,#A855F7_24%,var(--stroke))] bg-[var(--solid)] shadow-[var(--sh-1)]`,children:(0,Z.jsx)(ut,{size:19})}),(0,Z.jsx)(`strong`,{className:`text-[13px] font-[650] text-[var(--text-soft)]`,children:e}),(0,Z.jsxs)(`span`,{className:`flex items-end gap-[3px] pb-[3px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_infinite]`}),(0,Z.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_.16s_infinite]`}),(0,Z.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_.32s_infinite]`})]})]}),(0,Z.jsxs)(`div`,{className:`grid w-[min(560px,78vw)] gap-[12px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`div`,{className:`h-[52px] w-[68%] rounded-[16px_16px_16px_5px] border border-[var(--stroke-soft)] bg-[var(--surface-muted)] [animation:agent-message-pulse_1.9s_ease-in-out_infinite]`}),(0,Z.jsx)(`div`,{className:`h-[40px] w-[46%] justify-self-end rounded-[16px_16px_5px_16px] bg-[var(--user-bubble-bg)] opacity-[.14] [animation:agent-message-pulse_1.9s_ease-in-out_.25s_infinite]`}),(0,Z.jsx)(`div`,{className:`h-[46px] w-[58%] rounded-[16px_16px_16px_5px] border border-[var(--stroke-soft)] bg-[var(--surface-muted)] [animation:agent-message-pulse_1.9s_ease-in-out_.5s_infinite]`})]})]})}function so(e,t){return[{icon:_e,label:e(`chat:focusSession.explainCode`),prompt:e(`chat:focusSession.explainHowThisCodeWorks`)},{icon:nr,label:e(`chat:focusSession.writeTests`),prompt:e(`chat:focusSession.writeUnitTestsForTheFollowingCode`)},{icon:br,label:e(`chat:focusSession.refactor`),prompt:e(`chat:focusSession.refactorThisCodeAndExplainTheImprovements`)},{icon:qn,label:e(`chat:focusSession.findABug`),prompt:e(`chat:focusSession.helpMeLocateAndFixThisBug`)},{icon:tr,label:e(`chat:focusSession.summarize`),prompt:e(`chat:focusSession.summarizeContentAndExtractKeyPoints`)},...t?[{icon:sr,label:e(`chat:focusSession.makeAPlan`),prompt:e(`chat:focusSession.makeAClearActionablePlanForThisGoal`)}]:[],{icon:or,label:e(`chat:focusSession.organizeInformation`),prompt:e(`chat:focusSession.organizeThisInformationIntoAClearStructure`)},{icon:fr,label:e(`chat:focusSession.findIssues`),prompt:e(`chat:focusSession.reviewThisContentAndSuggestImprovements`)}]}function co({sessionId:e,messages:t,transcriptLoadState:n=`ready`,messageStart:r,hasOlder:i,loadingOlder:a,olderError:o,currentActivity:s,activityFeed:c,tools:u,thinkingText:d,compaction:f,streaming:p,runStartedAt:m,lastActivityAt:h,runFinishedAt:_,runStopped:v,runNotice:y,error:b,scrollRequest:x,cwd:S,lineage:C,switchingCwd:w,onLoadOlder:T,onBranchFromHere:E,onCreateChildSession:D,onPromptSelect:O,onWorkspace:k}){let{t:A,language:j}=g(),M=Re(e=>e.capabilities),N=Nt(M,`plans`),P=(0,X.useRef)(null),F=(0,X.useRef)(null),[I,L]=(0,X.useState)(()=>wt(e)),R=t[t.length-1],ee=Math.floor((R?.text?.length||0)/64),z=Ii(c),te=Math.floor(String(d||``).length/128),ne=`${e}:${R?.id||``}:${ee}:${te}:${R?.attachments?.length||0}:${z}:${f?.status||``}:${f?.finishedAt||``}:${b||``}:${p?`1`:`0`}`,{scrollRef:B,scrollElement:re,setScrollRef:ie,onScroll:ae,hasUnread:oe,scrollToBottom:se,maintainBottom:ce,cancelProgrammaticScroll:le}=Mi(ne),ue=(0,X.useMemo)(()=>({streaming:p,text:R?.role===`agent`?R.text:``,currentActivity:s,activityFeed:c,tools:u,thinkingText:d,compaction:f,error:b||(R?.role===`agent`?R.error:``),stopped:v,notice:y,startedAt:m,lastActivityAt:h,finishedAt:_}),[p,R,s,c,u,d,f,b,v,y,m,h,_]),de=(0,X.useCallback)(async()=>{let e=B.current;!e||!i||a||P.current||(P.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop},await T?.()||(P.current=null))},[i,a,T,B]),V=(0,X.useCallback)(e=>{ae(e),e.currentTarget.scrollTop<=96&&de()},[de,ae]);(0,X.useLayoutEffect)(()=>{let e=P.current,t=B.current;!e||!t||(t.scrollTop=Gi(e,t.scrollHeight),P.current=null)},[r,B]),(0,X.useEffect)(()=>{L(wt(e));let t=t=>{let n=t.detail;n?.sessionId===e&&n.targetEntryId&&L(n.targetEntryId)};return window.addEventListener(nt,t),()=>window.removeEventListener(nt,t)},[e]),(0,X.useEffect)(()=>{if(!(!I||r==null)&&!t.some(e=>e.turnBoundaryEntryId===I)&&!a){if(i){de();return}ct(e,I),L(``)}},[i,de,a,r,t,e,I]),(0,X.useEffect)(()=>{x&&se(`smooth`)},[x,se]);let H=(0,X.useMemo)(()=>{let e=new Date().getHours();return[A(e>=23||e<5?`chat:focusSession.timeLateNight`:e<11?`chat:focusSession.timeMorning`:e<14?`chat:focusSession.timeLunch`:e<18?`chat:focusSession.timeAfternoon`:`chat:focusSession.timeEvening`),...[...Nt(M,`plugins`)?[A(`chat:focusSession.feelLikeBuildingAPlugin`),A(`chat:focusSession.letAgentWriteItsOwnTool`)]:[],...Nt(M,`mcp`)?[A(`chat:focusSession.wireUpAnMcpServer`)]:[],...Nt(M,`schedules`)?[A(`chat:focusSession.scheduleTheRepetitiveWork`)]:[],...Nt(M,`workflows`)?[A(`chat:focusSession.turnRepeatedWorkIntoAWorkflow`)]:[],...Nt(M,`multiAgent`)?[A(`chat:focusSession.branchOutAndRunInParallel`)]:[],...Nt(M,`memory`)?[A(`chat:focusSession.letMemoryRememberYou`)]:[]].sort(()=>Math.random()-.5).slice(0,3)]},[M,A]),fe=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:A(`chat:focusSession.readyToWorkWithTheCurrentDirectoryAndHelpCompleteTheTask`)}),(0,Z.jsxs)(`button`,{type:`button`,className:`welcome-workspace [&_>_svg]:flex-none [&_>_span]:flex-none [&_>_strong]:min-w-0 [&_>_strong]:overflow-hidden [&_>_strong]:text-[var(--text-soft)] [&_>_strong]:text-[12.5px] [&_>_strong]:text-ellipsis [&_>_small]:flex-none [&_>_small]:ml-[3px] [&_>_small]:text-[var(--accent-strong)] [&_>_small]:text-[12px] [&_>_small]:font-[700] hover:border-[var(--stroke-hover)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)] [&:hover_>_strong]:text-[var(--text)] focus-visible:[outline:2px_solid_var(--brand-blue)] focus-visible:[outline-offset:1px] disabled:[cursor:wait] disabled:opacity-[.62] @max-[470px]:max-w-[100%] @max-[470px]:[&_>_span]:hidden flex max-w-[min(460px,100%)] min-h-[36px] items-center gap-[7px] overflow-hidden [margin-top:18px] border border-[var(--stroke)] rounded-[var(--r-pill)] bg-[var(--solid)] [padding:6px_14px] text-[var(--text-muted)] text-[12.5px] whitespace-nowrap shadow-[var(--sh-1)] [transition:background_var(--d1)_var(--ease-out),_color_var(--d1)_var(--ease-out),_border-color_var(--d1)_var(--ease-out)] [animation:transcript-stage-enter_.55s_var(--ease-out)_both] [animation-delay:240ms]`,"data-target-cursor":!0,title:S,"aria-label":A(`chat:focusSession.changeWorkingDirectoryWorkspace`,{workspace:S||$e(S,j)}),onClick:k,disabled:w,children:[w?(0,Z.jsx)(G,{className:`animate-spin`,size:14}):(0,Z.jsx)(qe,{size:14}),(0,Z.jsx)(`span`,{children:A(`chat:focusSession.workingDirectory`)}),(0,Z.jsx)(`strong`,{children:$e(S,j)}),(0,Z.jsx)(`small`,{children:A(`chat:focusSession.changeDirectory`)})]}),(0,Z.jsx)(`div`,{className:`welcome-chips flex max-w-[560px] flex-wrap justify-center gap-[9px] [margin-top:24px]`,children:so(A,N).map((e,t)=>(0,Z.jsxs)(`button`,{type:`button`,"data-target-cursor":!0,onClick:()=>O(e.prompt),className:`group inline-flex min-h-[38px] items-center gap-[7px] rounded-[var(--r-pill)] border border-[var(--stroke)] bg-[var(--solid)] px-[16px] text-[13px] font-[620] text-[var(--text-soft)] shadow-[var(--sh-1)] [transition:all_var(--d1)_var(--ease-out)] hover:-translate-y-[1px] hover:border-[color-mix(in_srgb,#A855F7_45%,var(--stroke))] hover:text-[var(--text)] hover:shadow-[0_10px_24px_-16px_rgba(168,85,247,.5)] [animation:transcript-stage-enter_.55s_var(--ease-out)_both]`,style:{animationDelay:`${300+t*45}ms`},children:[(0,Z.jsx)(e.icon,{size:14,className:`text-[var(--text-muted)] [transition:color_var(--d1)_var(--ease-out)] group-hover:text-[#A855F7]`}),e.label]},e.label))})]});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`transcript [.focus-session.has-conversation_&]:p-[30px_max(24px,calc((100%_-_900px)/2))] [.focus-session.has-conversation_&]:[scroll-padding-bottom:32px] @max-[700px]:p-[20px_14px] @max-[700px]:[.focus-session.has-conversation_&]:p-[24px_16px] @max-[470px]:[padding-inline:10px] max-[650px]:p-[20px_14px] min-h-0 flex-1 overflow-auto m-0 border-0 [padding:26px_max(24px,calc((100%_-_960px)/2))] [scroll-padding-bottom:28px]`,"data-pisper-transcript-state":n,"aria-busy":n===`loading`,ref:ie,onPointerDown:le,onScroll:V,onTouchStart:le,onWheel:le,children:[(0,Z.jsxs)(`div`,{className:`[display:flow-root] w-full`,ref:F,children:[C?.parentSessionId&&(0,Z.jsxs)(`div`,{className:`history-page-loader flex w-[min(960px,100%)] min-h-[42px] items-center justify-center gap-[7px] [margin:0_auto_18px] text-[var(--text-muted)] text-[12px] session-lineage`,"data-pisper-parent-session":C.parentSessionId,children:[(0,Z.jsx)(ar,{size:13}),(0,Z.jsx)(`span`,{children:A(`chat:focusSession.derivedFromSession`,{name:C.sourceSessionName||A(`chat:focusSession.unknownSourceSession`)})})]}),(i||a||o)&&(0,Z.jsx)(`div`,{className:`history-page-loader flex w-[min(960px,100%)] min-h-[42px] items-center justify-center gap-[7px] [margin:0_auto_18px] text-[var(--text-muted)] text-[12px]`,children:o?(0,Z.jsxs)(l,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:de,children:[(0,Z.jsx)(G,{size:13}),A(`chat:focusSession.retryOlderMessages`)]}):a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{className:`animate-spin`,size:14}),A(`chat:focusSession.loadingOlderMessages`)]}):(0,Z.jsxs)(l,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:de,children:[(0,Z.jsx)(Wn,{className:`history-up-arrow [.history-page-loader_&]:[transform:rotate(180deg)]`,size:14}),A(`chat:focusSession.loadOlderMessages`)]})})]}),n===`loading`&&(0,Z.jsx)(oo,{label:A(`chat:focusSession.loadingConversationHistory`)}),n===`ready`&&!t.length&&(0,Z.jsx)(`div`,{className:`agent-welcome [&_h2]:mt-[18px] [&_h2]:text-[clamp(28px,_3vw,_38px)] [&_h2]:font-[800] [&_h2]:leading-[1.2] [&_h2]:tracking-[-.02em] [&_p]:max-w-[600px] [&_p]:mt-[14px] [&_p]:text-[15px] [&_p]:leading-[1.75] relative grid min-h-[100%] place-content-center justify-items-center overflow-hidden text-[var(--text-muted)] text-center`,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(ao,{title:H[0],children:fe}),children:(0,Z.jsx)(io,{titles:H,children:fe})})}),n===`ready`&&t.length>0&&(0,Z.jsx)(`div`,{className:`[animation:transcript-reveal-enter_.22s_var(--ease-out)_both]`,children:(0,Z.jsx)(no,{sessionId:e,messages:t,streaming:p,latestRunProps:ue,measurementVersion:ne,scrollElement:re,prefixRef:F,targetEntryId:I,onContentSizeChange:ce,onTargetLocated:t=>{ct(e,t),L(``)},onBranchFromHere:E,onCreateChildSession:D},e)}),b&&(0,Z.jsxs)(`div`,{className:`flex w-[min(960px,100%)] items-center gap-[7px] [margin:8px_auto] rounded-[var(--r-sm)] bg-[var(--danger-soft)] text-[var(--danger)] [padding:9px_11px] text-[13px]`,children:[(0,Z.jsx)(Xe,{size:14}),b]})]}),oe&&(0,Z.jsxs)(l,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle self-center flex-none min-h-[32px] [margin:-2px_auto_6px] [border-color:var(--accent-border)] text-[var(--star-strong)] shadow-[0_8px_18px_-14px_var(--shadow)]`,onClick:()=>se(`smooth`),children:[(0,Z.jsx)(Wn,{size:14}),A(`chat:focusSession.newContent`)]})]})}function lo(e){let t=String(e||``).trim().split(` `)[0];if(t.startsWith(`"`)&&t.endsWith(`"`))try{t=JSON.parse(t)}catch{}return t===`/dev/null`?``:t.replace(/^[ab]\//,``)}function uo(e){let t=e.match(/^diff --git "a\/(.+)" "b\/(.+)"$/);if(t)return lo(`b/${t[2]}`);let n=e.match(/^diff --git a\/(.+) b\/(.+)$/);return n?lo(`b/${n[2]}`):``}function fo(){return{lineNumber:null,text:``,tone:`empty`}}function po(e){let t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return{oldLine:Number(t?.[1])||0,newLine:Number(t?.[2])||0}}function mo(e){let t=String(e||``).replace(/\r\n/g,`
5
+ `).split(`
6
+ `),n=[],r=null,i=null,a=0,o=0,s=[],c=[],l=()=>{if(!i||!s.length&&!c.length)return;let e=Math.max(s.length,c.length);for(let t=0;t<e;t+=1){let e=s[t],n=c[t];i.rows.push({kind:`pair`,old:e?{lineNumber:e.lineNumber,text:e.text,tone:`deleted`}:fo(),next:n?{lineNumber:n.lineNumber,text:n.text,tone:`added`}:fo()})}s=[],c=[]},u=()=>{l(),i=null},d=()=>{u(),r&&=(r.path=r.newPath||r.oldPath||r.path,n.push(r),null)};for(let e of t){if(e.startsWith(`diff --git `)){d(),r={oldPath:``,newPath:``,path:uo(e),metadata:[],hunks:[]};continue}if(r){if(e.startsWith(`@@ `)){u();let t=po(e);a=t.oldLine,o=t.newLine,i={header:e,rows:[]},r.hunks.push(i);continue}if(i){if(e.startsWith(`-`))s.push({lineNumber:a,text:e.slice(1)}),a+=1;else if(e.startsWith(`+`))c.push({lineNumber:o,text:e.slice(1)}),o+=1;else if(l(),e.startsWith(` `)){let t=e.slice(1);i.rows.push({kind:`pair`,old:{lineNumber:a,text:t,tone:`context`},next:{lineNumber:o,text:t,tone:`context`}}),a+=1,o+=1}else e.startsWith(`\\ `)&&i.rows.push({kind:`meta`,text:e.slice(2)});continue}e.startsWith(`--- `)?r.oldPath=lo(e.slice(4)):e.startsWith(`+++ `)?r.newPath=lo(e.slice(4)):e.trim()&&r.metadata.push(e)}}return d(),n}function ho({side:e,cell:t}){let n=t.tone===`deleted`?`−`:t.tone===`added`?`+`:` `;return(0,Z.jsxs)(`div`,{className:`git-diff-cell grid min-w-0 min-h-[24px] grid-cols-[44px_20px_minmax(0,1fr)] [border-bottom:1px_solid_var(--stroke-soft)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[11px] leading-[1.55] [&.next]:[border-left:1px_solid_var(--stroke)] [&.deleted]:bg-[var(--danger-soft)] [&.added]:bg-[var(--success-soft)] [&.empty]:bg-[var(--surface-muted)] [&.context]:bg-[var(--solid)] [&_code]:block [&_code]:min-w-0 [&_code]:p-[3px_8px_3px_2px] [&_code]:text-[var(--text)] [&_code]:font-[inherit] [&_code]:whitespace-pre-wrap [&_code]:[overflow-wrap:anywhere] ${e} ${t.tone}`,children:[(0,Z.jsx)(`span`,{className:`block [padding:3px_7px_3px_4px] [border-right:1px_solid_var(--stroke-soft)] text-[var(--text-muted)] text-right select-none`,children:t.lineNumber??``}),(0,Z.jsx)(`span`,{className:`git-diff-line-marker [.git-diff-cell.deleted_&]:text-[var(--danger)] [.git-diff-cell.added_&]:text-[var(--success)] block [padding:3px_4px] text-[var(--text-muted)] text-center select-none`,"aria-hidden":`true`,children:t.tone===`empty`?``:n}),(0,Z.jsx)(`code`,{children:t.text||`\xA0`})]})}function go({file:e,scrollElement:t}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(0),a=(0,X.useMemo)(()=>e.hunks.flatMap((e,t)=>[{kind:`header`,hunkIndex:t,header:e.header},...e.rows.map((e,n)=>({kind:`row`,hunkIndex:t,rowIndex:n,row:e}))]),[e.hunks]);(0,X.useLayoutEffect)(()=>{let e=n.current;if(!t||!e)return;let r=()=>{let n=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);i(e=>Math.abs(e-n)<1?e:n)};r();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return a?.observe(t),a?.observe(e),()=>a?.disconnect()},[t]);let o=ha({count:a.length,getScrollElement:()=>t,estimateSize:()=>25,getItemKey:e=>{let t=a[e];return t.kind===`header`?`hunk-${t.hunkIndex}`:`row-${t.hunkIndex}-${t.rowIndex}`},measureElement:e=>Math.ceil(e.getBoundingClientRect().height),overscan:12,scrollMargin:r}),s=o.getVirtualItems();return(0,Z.jsx)(`div`,{className:`relative min-w-[880px] w-full`,"data-pisper-diff-row-count":a.length,"data-pisper-rendered-count":s.length,ref:n,style:{height:`${o.getTotalSize()}px`},children:s.map(e=>{let t=a[e.index];return(0,Z.jsx)(`div`,{className:`absolute left-0 w-full`,"data-index":e.index,ref:o.measureElement,style:{top:`${e.start-r}px`},children:t.kind===`header`?(0,Z.jsx)(`div`,{className:`git-diff-hunk-header [border-bottom:1px_solid_var(--stroke-soft)] bg-[var(--blue-soft)] p-[4px_10px] text-[var(--brand-blue-strong)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[10px] [white-space:pre]`,children:t.header}):t.row.kind===`meta`?(0,Z.jsx)(`div`,{className:`git-diff-row-meta [border-bottom:1px_solid_var(--stroke-soft)] bg-[var(--blue-soft)] p-[4px_10px] text-[var(--brand-blue-strong)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[10px] [white-space:pre] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:t.row.text}):(0,Z.jsxs)(`div`,{className:`grid min-w-[880px] grid-cols-[minmax(440px,1fr)_minmax(440px,1fr)]`,children:[(0,Z.jsx)(ho,{side:`old`,cell:t.row.old}),(0,Z.jsx)(ho,{side:`next`,cell:t.row.next})]})},e.key)})})}function _o(e){let t=e.path.replace(/\\/g,`/`),n=t.split(`/`),r=n.pop()||t,i=0,a=0;for(let t of e.hunks)for(let e of t.rows)e.kind===`pair`&&(e.next.tone===`added`&&(i+=1),e.old.tone===`deleted`&&(a+=1));let o=e.metadata.join(`
7
+ `),s=/(?:^|\n)new file mode /.test(o)||!e.oldPath&&e.newPath?`added`:/(?:^|\n)deleted file mode /.test(o)||!e.newPath&&e.oldPath?`deleted`:/(?:^|\n)rename (?:from|to) /.test(o)||e.oldPath&&e.newPath&&e.oldPath!==e.newPath?`renamed`:`modified`;return{file:e,name:r,directory:n.join(`/`),added:i,deleted:a,status:s}}function vo(e){return e===`added`?`A`:e===`deleted`?`D`:e===`renamed`?`R`:`M`}function yo({diff:e,truncated:t,onClose:n}){let{t:r}=g(),i=(0,X.useMemo)(()=>mo(e),[e]),a=(0,X.useMemo)(()=>i.map(_o),[i]),[o,s]=(0,X.useState)(0),[c,u]=(0,X.useState)(null),d=Math.min(o,Math.max(a.length-1,0)),f=a[d];(0,X.useEffect)(()=>{let e=document.body.style.overflow,t=e=>{e.key===`Escape`&&n()};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t)}},[n]);let p=e=>{s(e),c?.scrollTo({top:0,left:0})};return(0,mi.createPortal)((0,Z.jsx)(`div`,{className:`git-diff-dialog-backdrop max-[760px]:p-[10px] fixed z-[120] inset-0 grid place-items-center bg-[rgb(0_0_0/.48)] [padding:24px] [backdrop-filter:blur(3px)]`,role:`presentation`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,Z.jsxs)(`section`,{className:`git-diff-dialog max-[760px]:w-[calc(100vw_-_20px)] max-[760px]:h-[calc(100vh_-_20px)] flex w-[min(1180px,calc(100vw_-_48px))] h-[min(820px,calc(100vh_-_48px))] min-w-0 min-h-0 flex-col overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-lg)] bg-[var(--solid)] shadow-[0_28px_90px_-24px_rgb(0_0_0/.65)]`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`chat:focusSession.gitViewDiff`),children:[(0,Z.jsxs)(`header`,{className:`git-diff-dialog-head [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] grid min-h-[54px] flex-none grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[10px] [border-bottom:1px_solid_var(--stroke)] [padding:8px_12px]`,children:[(0,Z.jsx)(`span`,{className:`grid w-[34px] h-[34px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,Z.jsx)(er,{size:17})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:r(`chat:focusSession.gitViewDiff`)}),(0,Z.jsx)(`small`,{children:r(`chat:focusSession.gitDiffFileCount`,{count:i.length})})]}),(0,Z.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,title:r(`chat:focusSession.gitCloseDiff`),"aria-label":r(`chat:focusSession.gitCloseDiff`),onClick:n,children:(0,Z.jsx)(it,{size:17})})]}),a.length?(0,Z.jsxs)(`div`,{className:`git-diff-layout max-[760px]:grid-rows-[minmax(112px,26vh)_minmax(0,1fr)] max-[760px]:grid-cols-[minmax(0,1fr)] grid min-w-0 min-h-0 flex-1 grid-cols-[252px_minmax(0,1fr)] overflow-hidden`,children:[(0,Z.jsxs)(`nav`,{className:`git-diff-file-nav max-[760px]:[border-right:0] max-[760px]:[border-bottom:1px_solid_var(--stroke)] flex min-w-0 min-h-0 flex-col overflow-hidden [border-right:1px_solid_var(--stroke)] bg-[var(--surface-muted)]`,"aria-label":r(`chat:focusSession.gitDiffChangedFiles`),children:[(0,Z.jsx)(`strong`,{className:`git-diff-file-nav-title max-[760px]:[padding-block:7px_5px] flex-none [padding:10px_12px_8px] text-[var(--text-muted)] text-[10px] font-[700] tracking-[.055em] [text-transform:uppercase]`,children:r(`chat:focusSession.gitDiffChangedFiles`)}),(0,Z.jsx)(`div`,{className:`git-diff-file-nav-list max-[760px]:pb-[6px] min-h-0 flex-1 overflow-x-hidden overflow-y-auto [padding:0_6px_8px]`,children:a.map((e,t)=>{let n=t===d;return(0,Z.jsxs)(`button`,{type:`button`,className:`git-diff-file-nav-item hover:bg-[var(--surface-hover)] hover:text-[var(--text)] [&.selected]:bg-[var(--accent-soft)] [&.selected]:text-[var(--text)] [&.selected]:shadow-[inset_2px_0_var(--star-strong)] grid w-full min-h-[42px] grid-cols-[20px_minmax(0,1fr)_auto] items-center gap-[7px] border-0 rounded-[var(--r-sm)] bg-transparent [padding:5px_7px] text-[var(--text-secondary)] text-left cursor-pointer ${e.status} ${n?`selected`:``}`,title:e.file.path,"aria-current":n?`true`:void 0,onClick:()=>p(t),children:[(0,Z.jsx)(`span`,{className:`git-diff-file-status font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[11px] font-[750] text-center [.git-diff-file-nav-item.added_&]:text-[var(--success)] [.git-diff-file-nav-item.deleted_&]:text-[var(--danger)] [.git-diff-file-nav-item.renamed_&]:text-[var(--warning-strong)] [.git-diff-file-nav-item.modified_&]:text-[var(--star-strong)]`,"aria-hidden":`true`,children:vo(e.status)}),(0,Z.jsxs)(`span`,{className:`git-diff-file-name [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[11px] [&_strong]:font-[650] [&_small]:text-[var(--text-muted)] [&_small]:text-[9px] flex min-w-0 flex-col gap-[1px]`,children:[(0,Z.jsx)(`strong`,{children:e.name}),e.directory&&(0,Z.jsx)(`small`,{children:e.directory})]}),(0,Z.jsxs)(`span`,{className:`git-diff-file-stats inline-flex items-center gap-[4px] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[9px] [&_em]:[font-style:normal]`,"aria-hidden":`true`,children:[e.added>0&&(0,Z.jsxs)(`em`,{className:`added [.git-diff-file-stats_&]:text-[var(--success)]`,children:[`+`,e.added]}),e.deleted>0&&(0,Z.jsxs)(`em`,{className:`deleted [.git-diff-file-stats_&]:text-[var(--danger)]`,children:[`−`,e.deleted]})]})]},`${e.file.path}-${t}`)})})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 min-h-0 overflow-auto bg-[var(--surface-subtle)] [padding:12px]`,ref:u,children:[t&&(0,Z.jsx)(`div`,{className:`[margin:0_0_12px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--warning-soft)] [padding:8px_10px] text-[var(--warning-strong)] text-[11px]`,children:r(`chat:focusSession.gitDiffTruncated`)}),f&&(0,Z.jsxs)(`section`,{className:`min-w-[880px] [overflow:clip] [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)]`,children:[(0,Z.jsxs)(`header`,{className:`git-diff-file-head [&_>_svg]:text-[var(--star-strong)] [&_strong]:overflow-hidden [&_strong]:font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] [&_strong]:text-[12px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:max-w-[300px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap sticky z-[3] top-0 grid min-h-[38px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] [border-bottom:1px_solid_var(--stroke)] bg-[var(--solid)] [padding:7px_10px]`,children:[(0,Z.jsx)(er,{size:14}),(0,Z.jsx)(`strong`,{title:f.file.path,children:f.file.path}),f.file.oldPath&&f.file.newPath&&f.file.oldPath!==f.file.newPath&&(0,Z.jsx)(`small`,{title:f.file.oldPath,children:f.file.oldPath})]}),f.file.metadata.length>0&&(0,Z.jsx)(`div`,{className:`git-diff-file-meta [border-bottom:1px_solid_var(--stroke-soft)] bg-[var(--surface-muted)] p-[5px_10px] text-[var(--text-muted)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[10px]`,children:f.file.metadata.join(` · `)}),f.file.hunks.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`git-diff-column-head [&_span]:p-[5px_10px] [&_span_+_span]:[border-left:1px_solid_var(--stroke)] sticky z-[2] [top:38px] grid grid-cols-[1fr_1fr] [border-bottom:1px_solid_var(--stroke)] bg-[var(--surface-muted)] text-[var(--text-muted)] text-[10px] font-[650] [text-transform:uppercase]`,children:[(0,Z.jsx)(`span`,{children:r(`chat:focusSession.gitDiffOriginal`)}),(0,Z.jsx)(`span`,{children:r(`chat:focusSession.gitDiffModified`)})]}),(0,Z.jsx)(go,{file:f.file,scrollElement:c})]}):(0,Z.jsx)(`div`,{className:`[padding:28px_16px] text-[var(--text-muted)] text-[12px] text-center`,children:r(`chat:focusSession.gitDiffNoTextChanges`)})]},f.file.path)]})]}):(0,Z.jsx)(`div`,{className:`min-w-0 min-h-0 flex-1 bg-[var(--surface-subtle)] overflow-auto [padding:12px]`,children:(0,Z.jsx)(`div`,{className:`[border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:20px] text-[var(--text-muted)] whitespace-pre-wrap`,children:e||r(`chat:focusSession.gitDiffUnavailable`)})})]})}),document.body)}var bo=8;function xo(e,t){(0,X.useLayoutEffect)(()=>{if(!e)return;let n=()=>{let e=t.current;if(!e)return;e.style.setProperty(`--menu-x-offset`,`0px`);let n=e.getBoundingClientRect(),r=n.right>window.innerWidth-bo?window.innerWidth-bo-n.right:n.left<bo?bo-n.left:0;e.style.setProperty(`--menu-x-offset`,`${r}px`)};return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[t,e])}var So=`Agent changes`;function Co(e){return e instanceof Error?e.message:String(e)}function wo({sessionId:e,streaming:t}){let{t:n,language:r}=g(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(!1),[h,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(``),w=(0,X.useRef)(null),T=(0,X.useRef)(null);xo(i,T);let E=(0,X.useCallback)(async()=>{if(e){u(!0),x(``);try{let t=await J.getVcsChanges(e);y(t)}catch(e){x(Co(e))}finally{u(!1)}}},[e]);(0,X.useEffect)(()=>{if(!i)return;E();let e=e=>{let t=e.target instanceof Node?e.target:null;w.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i,E]),(0,X.useEffect)(()=>{t||E().catch(()=>{})},[t,E]);let D=async t=>{if(!(!e||d)){if(t===`revert`&&!p){m(!0);return}f(t),x(``),C(``);try{let r;t===`commit`?(r=await J.commitVcsChanges(e,h.trim()||So),_(``),C(n(`chat:focusSession.gitCommitted`))):t===`push`?(r=await J.pushVcsChanges(e),C(n(`chat:focusSession.gitPushed`))):(r=await J.revertVcsChanges(e),m(!1),C(n(`chat:focusSession.gitReverted`))),y(r)}catch(e){x(Co(e))}finally{f(null)}}},O=(v?.vcs||(v?.isRepo?`git`:``))===`svn`,k=v?.isRepo?v.files.length:0,A=k>0,j=!!(!O&&v?.isRepo&&(v.ahead??0)>0),M=!!d,N=O?n(`chat:focusSession.vcsSvnWorkspace`):v?.branch||n(`chat:focusSession.gitDetachedHead`),P=v?.isRepo?`${n(`chat:focusSession.gitChanges`)}${v.branch?` · ${v.branch}`:``}${O?` · ${n(`chat:focusSession.vcsSvnWorkspace`)}`:``}${A?` · ${n(`chat:focusSession.gitFilesChanged`,{count:k})}`:``}`:n(`chat:focusSession.gitChanges`);return(0,Z.jsxs)(`div`,{ref:w,className:`git-changes-select [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] relative flex-none w-[38px] h-[38px] text-[var(--text-tertiary)] ${i?`open`:``} ${A?`active`:``}`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`git-changes-trigger hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] [.git-changes-select.open_&]:border-[var(--accent-border)] [.git-changes-select.open_&]:bg-[var(--accent-soft)] [.git-changes-select.open_&]:text-[var(--star-strong)] [.git-changes-select.active_&]:text-[var(--star-strong)] [&_>_i]:absolute [&_>_i]:top-[-4px] [&_>_i]:right-[-6px] [&_>_i]:min-w-[15px] [&_>_i]:rounded-[var(--r-pill)] [&_>_i]:bg-[var(--star-strong)] [&_>_i]:p-[1px_4px] [&_>_i]:text-[var(--on-accent)] [&_>_i]:text-[9px] [&_>_i]:[font-style:normal] [&_>_i]:font-[700] [&_>_i]:leading-[1.3] [&_>_i]:text-center @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] relative grid w-full h-full place-items-center [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-inherit cursor-pointer`,title:P,"aria-label":P,"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!e,onClick:()=>a(e=>!e),children:[(0,Z.jsx)(ae,{size:14}),A&&(0,Z.jsx)(`i`,{children:k>99?`99+`:k})]}),i&&(0,Z.jsxs)(`div`,{ref:T,className:`git-changes-menu [translate:var(--menu-x-offset,_0px)_0] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(340px,calc(100vw_-_76px))] absolute z-[35] [bottom:calc(100%_+_8px)] left-0 w-[min(340px,calc(100vw_-_28px))] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)]`,role:`dialog`,"aria-label":n(`chat:focusSession.gitChanges`),children:[(0,Z.jsxs)(`div`,{className:`git-changes-menu-head hover:bg-[var(--accent-soft)] [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[12px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap grid min-h-[44px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] rounded-[var(--r-sm)] [padding:6px_7px]`,children:[(0,Z.jsx)(`span`,{className:`git-changes-menu-icon [.git-changes-select.active_&]:bg-[var(--star-soft)] [.git-changes-select.active_&]:text-[var(--star-strong)] grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Z.jsx)(ae,{size:15})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n(`chat:focusSession.gitChanges`)}),(0,Z.jsx)(`small`,{title:v?.cwd||``,children:v?.isRepo?N:c?n(`chat:focusSession.gitLoading`):b&&!v?n(`chat:focusSession.gitLoadFailed`):v?.gitAvailable===!1&&v?.svnAvailable===!1?n(`chat:focusSession.gitUnavailable`):`${n(`chat:focusSession.gitNotARepository`)}${v?.cwd?` · ${$e(v.cwd,r)}`:``}`})]}),(0,Z.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,title:n(`chat:focusSession.gitRefresh`),"aria-label":n(`chat:focusSession.gitRefresh`),disabled:c||M,onClick:()=>void E(),children:(0,Z.jsx)(G,{className:c?`animate-spin`:``,size:13})})]}),b&&(0,Z.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--danger,_#d64545)] text-[11px]`,children:b}),!b&&v?.error&&(0,Z.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--danger,_#d64545)] text-[11px]`,children:v.error}),S&&!b&&(0,Z.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--success,_#2e9e63)] text-[11px]`,children:S}),v?.isRepo&&(0,Z.jsxs)(Z.Fragment,{children:[A?(0,Z.jsxs)(`div`,{className:`git-changes-file-list [&_>_small]:p-[3px_5px] [&_>_small]:text-[var(--text-muted)] flex max-h-[168px] flex-col gap-[1px] [margin:2px_4px] overflow-y-auto`,children:[v.files.slice(0,60).map(e=>(0,Z.jsxs)(`div`,{className:`git-changes-file hover:bg-[var(--accent-soft)] [&_>_span]:overflow-hidden [&_>_span]:text-[var(--text-secondary)] [&_>_span]:text-ellipsis [&_>_span]:whitespace-nowrap grid grid-cols-[26px_minmax(0,1fr)] items-center gap-[6px] rounded-[var(--r-sm)] [padding:3px_5px] text-[11px]`,children:[(0,Z.jsx)(`code`,{className:`text-[var(--star-strong)] text-[10px] font-[700]`,children:e.status}),(0,Z.jsx)(`span`,{title:e.path,children:e.path})]},`${e.status}-${e.path}`)),v.files.length>60&&(0,Z.jsx)(`small`,{children:n(`chat:focusSession.gitMoreFiles`,{count:v.files.length-60})})]}):(0,Z.jsx)(`p`,{className:`[margin:4px_7px] text-[var(--text-muted)] text-[11px]`,children:n(`chat:focusSession.gitNoChanges`)}),A&&(0,Z.jsxs)(`div`,{className:`git-changes-commit-row [&_input]:w-full [&_input]:min-w-0 [&_input]:[border:1px_solid_var(--stroke)] [&_input]:rounded-[var(--r-sm)] [&_input]:bg-[var(--surface-muted)] [&_input]:p-[5px_7px] [&_input]:text-inherit [&_input]:text-[12px] [&_input:focus]:border-[var(--focus)] [&_input:focus]:[outline:none] grid grid-cols-[minmax(0,1fr)_auto] gap-[6px] [margin:4px_7px]`,children:[(0,Z.jsx)(`input`,{value:h,placeholder:n(`chat:focusSession.gitCommitMessagePlaceholder`),onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),D(`commit`))}}),(0,Z.jsxs)(l,{type:`button`,disabled:M||t,title:n(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.gitCommit`),onClick:()=>void D(`commit`),children:[d===`commit`?(0,Z.jsx)(G,{className:`animate-spin`,size:12}):(0,Z.jsx)(ir,{size:12}),n(`chat:focusSession.gitCommit`)]})]}),A&&(0,Z.jsxs)(`button`,{type:`button`,className:`git-changes-view-diff hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] flex w-[calc(100%_-_14px)] min-h-[30px] items-center gap-[7px] [margin:4px_7px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] bg-[var(--surface-muted)] [padding:5px_8px] text-[var(--text-secondary)] text-[11px] font-[600] cursor-pointer`,onClick:()=>{s(!0),a(!1)},children:[(0,Z.jsx)(er,{size:13}),n(`chat:focusSession.gitViewDiff`)]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-[6px] [margin:5px_7px_6px]`,children:[!O&&(0,Z.jsxs)(l,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:M||!j&&!A,title:j?n(`chat:focusSession.gitPushAhead`,{count:v?.ahead||0}):n(`chat:focusSession.gitPush`),onClick:()=>void D(`push`),children:[d===`push`?(0,Z.jsx)(G,{className:`animate-spin`,size:12}):(0,Z.jsx)(vr,{size:12}),n(`chat:focusSession.gitPush`),j?` ↑${v?.ahead}`:``]}),p?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(l,{type:`button`,variant:`destructive`,disabled:M||t,title:n(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.gitConfirmRevert`),onClick:()=>void D(`revert`),children:[d===`revert`?(0,Z.jsx)(G,{className:`animate-spin`,size:12}):(0,Z.jsx)(B,{size:12}),n(`chat:focusSession.gitConfirmRevert`)]}),(0,Z.jsxs)(l,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:M,onClick:()=>m(!1),children:[(0,Z.jsx)(it,{size:12}),n(`chat:focusSession.gitCancel`)]})]}):(0,Z.jsxs)(l,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:M||t||!A,title:n(O?`chat:focusSession.vcsRevertDescription`:`chat:focusSession.gitRevertDescription`),onClick:()=>void D(`revert`),children:[(0,Z.jsx)(_r,{size:12}),n(`chat:focusSession.gitRevert`)]})]})]})]}),o&&v&&(0,Z.jsx)(yo,{diff:v.diff||``,truncated:v.diffTruncated,onClose:()=>s(!1)})]})}var To=1e3;function Eo({goal:e,armed:t,tokenBudget:n,onTokenBudgetChange:r,onSaveTokenBudget:i,onChange:a}){let{t:o}=g(),[s,c]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),f=(0,X.useRef)(null),p=(0,X.useRef)(null),m=e?.status===`active`,h=m||t,_=!!e?.id,v=n!==(Number(e?.tokenBudget)||3e4),y=m?o(`chat:focusSession.runningAutonomously`):t?e?.status===`paused`?o(`chat:focusSession.theNextMessageWillResumeTheGoal`):o(`chat:focusSession.theNextMessageWillStartAGoal`):e?.status===`complete`?o(`chat:focusSession.goalComplete`):e?.status===`budget_limited`?o(`chat:focusSession.goalReachedItsBudget`):e?.status===`paused`?o(`chat:focusSession.goalPaused`):o(`chat:focusSession.enableForTheNextMessageOnly`),b=String(e?.objective||``).replace(/\s+/g,` `).trim(),x=t?y:b||y,S=_?o(`chat:focusSession.usedBudgetTokensUsed`,{used:e?.tokensUsed||0,budget:e?.tokenBudget||0}):``,C=[o(`chat:focusSession.goalMode`),x,S].filter(Boolean).join(` · `);(0,X.useEffect)(()=>{if(!s)return;let e=e=>{let t=e.target instanceof Node?e.target:null;f.current?.contains(t)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[s]),xo(s,p);let w=async()=>{if(!(u||!v)&&_&&i){d(!0);try{await i(n)}finally{d(!1)}}};return(0,Z.jsxs)(`div`,{ref:f,className:`goal-mode-select [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] relative w-[38px] h-[38px] text-[var(--text-tertiary)] ${s?`open`:``} ${m||t?`active`:``}`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`goal-mode-trigger hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] [.goal-mode-select.open_&]:border-[var(--accent-border)] [.goal-mode-select.open_&]:bg-[var(--accent-soft)] [.goal-mode-select.open_&]:text-[var(--star-strong)] [.goal-mode-select.active_&]:text-[var(--star-strong)] @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] grid w-full h-full place-items-center [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-inherit cursor-pointer`,title:C,"aria-label":C,"aria-haspopup":`dialog`,"aria-expanded":s,onClick:()=>c(e=>!e),children:(0,Z.jsx)(hr,{size:14})}),s&&(0,Z.jsxs)(`div`,{ref:p,className:`goal-mode-menu [translate:var(--menu-x-offset,_0px)_0] [&_strong]:text-[12px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_p]:m-[1px_7px_4px_47px] [&_p]:text-[var(--text-muted)] [&_p]:text-[11px] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(250px,calc(100vw_-_76px))] absolute z-[35] [bottom:calc(100%_+_8px)] left-0 w-[min(250px,calc(100vw_-_28px))] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)]`,role:`dialog`,"aria-label":o(`chat:focusSession.goalMode`),children:[(0,Z.jsxs)(`div`,{className:`goal-mode-menu-row hover:bg-[var(--accent-soft)] [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] grid min-h-[48px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] rounded-[var(--r-sm)] [padding:6px_7px]`,children:[(0,Z.jsx)(`span`,{className:`goal-mode-menu-icon [.goal-mode-select.active_&]:bg-[var(--star-soft)] [.goal-mode-select.active_&]:text-[var(--star-strong)] grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Z.jsx)(hr,{size:15})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:o(`chat:focusSession.goalMode`)}),(0,Z.jsx)(`small`,{title:x,children:x})]}),(0,Z.jsx)(Tt,{value:h,onChange:e=>{a(e),c(!1)},ariaLabel:C,title:C})]}),S&&(0,Z.jsx)(`p`,{children:S}),(0,Z.jsxs)(`div`,{className:`goal-mode-budget-row [&_label]:text-[var(--text-secondary)] [&_label]:text-[11px] [&_label]:font-[600] [&_input]:w-full [&_input]:min-w-0 [&_input]:[border:1px_solid_var(--stroke)] [&_input]:rounded-[var(--r-sm)] [&_input]:bg-[var(--surface-muted)] [&_input]:p-[5px_7px] [&_input]:text-inherit [&_input]:text-[12px] [&_input:focus]:border-[var(--focus)] [&_input:focus]:[outline:none] grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[6px] [margin:2px_7px_2px]`,children:[(0,Z.jsx)(`label`,{htmlFor:`goal-token-budget-input`,children:o(`chat:focusSession.goalTokenBudget`)}),(0,Z.jsx)(`input`,{id:`goal-token-budget-input`,type:`number`,min:To,step:1e3,value:n,disabled:u,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&r(Math.max(To,Math.round(t)))}}),_&&v&&(0,Z.jsxs)(l,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:u,onClick:()=>void w(),children:[u?(0,Z.jsx)(G,{className:`animate-spin`,size:12}):(0,Z.jsx)(B,{size:12}),o(`chat:focusSession.goalBudgetSave`)]})]}),(0,Z.jsx)(`small`,{className:`block [margin:0_7px_5px] text-[var(--text-muted)] text-[10px]`,children:_?o(`chat:focusSession.goalTokenBudgetUpdateHint`):o(`chat:focusSession.goalTokenBudgetHint`,{min:q(To)})})]})]})}function Do({session:e,canSplit:t,streaming:n,switchingCwd:r,onSplitLeft:i,onSplitRight:a,onSplitTop:o,onSplitBottom:s,onClosePanel:c,onWorkspace:u,onRename:d,onSessionTree:f}){let{t:p,language:m}=g(),[h,_]=(0,X.useState)(!1),v=(0,X.useRef)(null),y=(0,X.useRef)(null);xo(h,y),(0,X.useEffect)(()=>{if(!h)return;let e=e=>{let t=e.target instanceof Node?e.target:null;v.current?.contains(t)||_(!1)},t=e=>{e.key===`Escape`&&_(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[h]);let b=e=>{_(!1),e?.()},x=[[pt,p(`chat:focusSession.splitToLeft`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheLeft`),i],[xe,p(`chat:focusSession.splitToRight`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheRight`),a],[Ce,p(`chat:focusSession.splitToTop`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheTop`),o],[Se,p(`chat:focusSession.splitToBottom`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheBottom`),s]];return(0,Z.jsxs)(`div`,{ref:v,className:`relative flex-none`,children:[(0,Z.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,title:p(`chat:focusSession.chatActions`),"aria-label":p(`chat:focusSession.openChatActionsMenu`),"aria-haspopup":`menu`,"aria-expanded":h,disabled:!e,onClick:()=>_(e=>!e),children:(0,Z.jsx)(Qn,{size:17})}),h&&(0,Z.jsxs)(`div`,{ref:y,className:`permission-mode-menu [&_>_button]:grid [&_>_button]:w-full [&_>_button]:min-h-[48px] [&_>_button]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text)] [&_>_button]:p-[6px_7px] [&_>_button]:text-left [&_>_button:hover]:bg-[var(--accent-soft)] [&_>_button.active]:bg-[var(--accent-soft)] [&_>_button_>_span:nth-child(2)]:flex [&_>_button_>_span:nth-child(2)]:min-w-0 [&_>_button_>_span:nth-child(2)]:flex-col [&_>_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:leading-[1.4] [&_>_button_>_svg]:text-[var(--star-strong)] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(250px,calc(100vw_-_76px))] absolute z-[35] right-0 [bottom:calc(100%_+_8px)] w-[250px] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)] session-actions-menu [.permission-mode-menu&]:top-[calc(100%_+_8px)] [.permission-mode-menu&]:bottom-[auto] [.permission-mode-menu&]:w-[250px] [&_>_button:disabled]:[cursor:not-allowed] [&_>_button:disabled]:opacity-[.5] [translate:var(--menu-x-offset,_0px)_0] [.composer-tool-tray_.focus-composer-session-actions_.permission-mode-menu&]:top-[auto] [.composer-tool-tray_.focus-composer-session-actions_.permission-mode-menu&]:bottom-[calc(100%_+_8px)]`,role:`menu`,children:[x.map(([e,n,r,i])=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:!t,onClick:()=>b(i),children:[(0,Z.jsx)(e,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n}),(0,Z.jsx)(`small`,{children:t?r:p(`chat:focusSession.thisGroupHasOnlyOneChat`)})]})]},n)),(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:n||r,onClick:()=>b(u),children:[(0,Z.jsx)(qe,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:focusSession.setWorkingDirectory`)}),(0,Z.jsx)(`small`,{children:n?p(`chat:focusSession.cannotSwitchWhileTheAgentIsRunning`):$e(e?.cwd,m)})]})]}),(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:n,onClick:()=>b(f),children:[(0,Z.jsx)(gr,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:sessionTree.menu`)}),(0,Z.jsx)(`small`,{children:p(n?`chat:sessionTree.waitForRun`:`chat:sessionTree.menuDescription`)})]})]}),(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>b(d),children:[(0,Z.jsx)(we,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:focusSession.renameChat`)}),(0,Z.jsx)(`small`,{children:e?.name||p(`chat:focusSession.newChat`)})]})]}),(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>b(c),children:[(0,Z.jsx)(it,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:focusSession.closeTab`)}),(0,Z.jsx)(`small`,{children:p(`chat:focusSession.keepTheHistoryAndCloseOnlyThisView`)})]})]})]})]})}var Oo=new Set([`user`,`assistant`,`summary`,`compaction`,`position`]),ko=new Set([`tool`,`tool-call`]),Ao=56,jo=12,Mo=120,No=26;function Po(e){let t=[],n=new Map;for(let r of e){let e=r.parentId?n.get(r.parentId):void 0,i={...r,children:[]};n.set(r.id,i),e?e.children.push(i):t.push(i)}return t}function Fo(e){let t=[],n=[...e].reverse();for(;n.length>0;){let e=n.pop();if(e){t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}}return t}function Io(e,t){let n=[],r=new Map;for(let i of Fo(e)){let e=i.parentId&&r.get(i.parentId)||null;if(!t(i)){r.set(i.id,e);continue}let a={...i,children:[]};r.set(i.id,a),e?e.children.push(a):n.push(a)}return n}function Lo(e){let t=[e],n=e;for(;n.children.length===1;)n=n.children[0],t.push(n);let r={id:e.id,nodes:t,children:[],active:t.some(e=>e.active)},i=[{segment:r,children:n.children}];for(;i.length>0;){let e=i.pop();if(e)for(let t of e.children){let n=[t],r=t;for(;r.children.length===1;)r=r.children[0],n.push(r);let a={id:t.id,nodes:n,children:[],active:n.some(e=>e.active)};e.segment.children.push(a),i.push({segment:a,children:r.children})}}return r}function Ro(e){return e.kind===`user`?yr:e.kind===`assistant`?Ne:e.kind===`tool`||e.kind===`tool-call`?Ae:e.kind===`settings`?jt:e.kind===`label`?Oe:e.kind===`summary`||e.kind===`compaction`?tr:e.kind===`position`?ae:e.label?Kn:Ge}function zo({segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let{nodes:o,children:s}=e,c=o.length>Mo,l=ha({count:o.length,getScrollElement:()=>t.current,estimateSize:()=>Ao,getItemKey:e=>o[e]?.id??`tree-node-${e}`,overscan:jo,scrollMargin:No,enabled:c,useAnimationFrameWithResizeObserver:!0}),u=e=>{let t=Ro(e);return(0,Z.jsxs)(`button`,{type:`button`,className:`session-tree-node hover:border-[var(--stroke-hover)] hover:bg-[var(--solid)] [&.selected]:border-[var(--focus)] [&.selected]:bg-[var(--solid)] [&.selected]:shadow-[0_0_0_2px_var(--focus-ring),0_8px_20px_-18px_var(--shadow)] relative z-[1] grid w-[220px] min-h-[48px] grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[color-mix(in_srgb,var(--solid)_94%,transparent)] text-[var(--text)] [padding:6px_8px_6px_2px] text-left shadow-[0_4px_14px_-13px_var(--shadow)] cursor-pointer ${e.id===n?` selected`:``}${e.active?` active`:``}${e.leaf?` leaf`:``}`,"data-kind":e.kind,"data-pisper-tree-entry":e.id,onClick:()=>a(e.id),children:[(0,Z.jsx)(`span`,{className:`session-tree-marker [.session-tree-node[data-kind='user']_&]:bg-[var(--star-soft)] [.session-tree-node[data-kind='user']_&]:text-[var(--star-strong)] [.session-tree-node[data-kind='assistant']_&]:bg-[var(--brand-blue-soft)] [.session-tree-node[data-kind='assistant']_&]:text-[var(--brand-blue-strong)] [.session-tree-node[data-kind='tool']_&]:bg-[var(--warning-soft)] [.session-tree-node[data-kind='tool']_&]:text-[var(--warning-strong)] [.session-tree-node[data-kind='summary']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='summary']_&]:text-[var(--violet-strong)] [.session-tree-node[data-kind='compaction']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='compaction']_&]:text-[var(--violet-strong)] [.session-tree-node.active_&]:border-[var(--brand-blue-border)] [.session-tree-node.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] [.session-tree-node.leaf_&]:bg-[var(--star)] [.session-tree-node.leaf_&]:text-[var(--on-accent)] [.session-tree-mark.active_&]:border-[var(--brand-blue-border)] [.session-tree-mark.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] relative z-[2] grid w-[26px] h-[26px] place-items-center [justify-self:center] [border:2px_solid_var(--surface-subtle)] rounded-[50%] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Z.jsx)(t,{size:14})}),(0,Z.jsxs)(`span`,{className:`session-tree-node-copy [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_strong]:font-[650] [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] flex min-w-0 flex-col gap-[2px]`,children:[(0,Z.jsx)(`strong`,{children:e.label||e.text||r(e)}),(0,Z.jsx)(`small`,{children:e.label&&e.text?e.text:r(e)})]}),(0,Z.jsxs)(`span`,{className:`session-tree-node-state [.session-tree-node.active_&]:text-[var(--brand-blue-strong)] [.session-tree-node.leaf_&]:text-[var(--brand-blue-strong)] inline-flex min-w-0 items-center gap-[4px] text-[var(--text-muted)] text-[9px] [text-transform:uppercase]`,children:[e.label&&(0,Z.jsx)(Kn,{size:12}),i(e)]})]},e.id)};return(0,X.useEffect)(()=>{if(!c||!n)return;let e=o.findIndex(e=>e.id===n);e<0||l.scrollToIndex(e,{align:`center`})},[n,o,c,l]),(0,Z.jsxs)(`div`,{className:`session-tree-segment relative flex min-w-[220px] flex-col items-center ${e.active?` active`:``}`,children:[(0,Z.jsx)(`div`,{className:`session-tree-track before:absolute before:z-[0] before:top-[22px] before:bottom-[22px] before:left-[50%] before:w-[2px] before:rounded-[var(--r-pill)] before:bg-[var(--stroke)] before:[content:''] before:[transform:translateX(-1px)] [.session-tree-segment.active_>_&::before]:bg-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] relative z-[1] grid w-[220px] gap-[8px]`,children:c?(0,Z.jsx)(`div`,{className:`relative w-[220px]`,style:{height:`${l.getTotalSize()}px`},children:l.getVirtualItems().map(e=>(0,Z.jsx)(`div`,{className:`absolute top-0 left-0 w-[220px]`,style:{top:`${e.start-No}px`},children:u(o[e.index])},e.key))}):o.map(u)}),s.length>0&&(0,Z.jsx)(`div`,{className:`session-tree-children before:absolute before:top-0 before:left-[50%] before:w-[2px] before:h-[14px] before:rounded-[var(--r-pill)] before:bg-[var(--stroke)] before:[content:''] before:[transform:translateX(-1px)] [.session-tree-segment.active_>_&::before]:bg-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] relative flex items-start justify-center [margin-top:0] [padding-top:28px]`,children:s.map(e=>(0,Z.jsx)(`div`,{className:`session-tree-child before:absolute before:top-0 before:w-[50%] before:h-[14px] before:[border-top:2px_solid_var(--stroke)] before:[content:''] after:absolute after:top-0 after:w-[50%] after:h-[14px] after:[border-top:2px_solid_var(--stroke)] after:[content:''] before:right-[50%] after:left-[50%] after:[border-left:2px_solid_var(--stroke)] [&:first-child::before]:[border-top-color:transparent] [&:last-child::after]:[border-top-color:transparent] [&.active::before]:border-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] [&.active::after]:border-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] [&.active:first-child::before]:[border-top-color:transparent] [&.active:last-child::after]:[border-top-color:transparent] relative flex [padding:14px_12px_0]${e.active?` active`:``}`,children:(0,Z.jsx)(zo,{segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a})},e.id))})]})}function Bo({open:e,sessionId:t,streaming:n,onClose:r,onNavigated:i,onCreateChildSession:a}){let{t:o,language:s}=g(),[c,u]=(0,X.useState)(null),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)(`conversation`),[h,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)([]),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(null),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(!1),[R,ee]=(0,X.useState)(!1),[z,te]=(0,X.useState)(``),[ne,B]=(0,X.useState)(``),re=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!e||!t)return;let n=!1;return m(`conversation`),_(``),N(!0),B(``),Promise.all([J.getSessionTree(t),J.listSessions()]).then(([e,t])=>{n||(u(e),f(t.sessions||[]),y(e.leafId||e.nodes[0]?.id||``))}).catch(e=>{n||B($(e))}).finally(()=>{n||N(!1)}),()=>{n=!0}},[e,t]),(0,X.useEffect)(()=>{e||(u(null),f([]),y(``),x(``),k(null),j(!1),B(``))},[e]),(0,X.useEffect)(()=>{if(!e||p!==`marks`||w)return;let t=!0;return D(!0),B(``),J.listSessionTreeLabels(500).then(e=>{t&&(C(e.labels||[]),T(!0))}).catch(e=>t&&B($(e))).finally(()=>t&&D(!1)),()=>{t=!1}},[e,p,w]);let ie=(0,X.useMemo)(()=>{let e=h.trim().toLocaleLowerCase(s);return e?S.filter(t=>`${t.label} ${t.sessionName}`.toLocaleLowerCase(s).includes(e)):S},[S,s,h]),oe=async e=>{if(!O){k(e),B(``);try{e.active||await J.navigateSessionTreeTarget(e.sessionId,e.entryId),rt(e.sessionId,`open`,e.entryId),r()}catch(e){B($(e)),k(null)}}},se=e=>{let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(s,{dateStyle:`medium`,timeStyle:`short`}).format(t):o(`navigation:appOverlays.unknownTime`)},ce=(0,X.useMemo)(()=>Po(c?.nodes||[]),[c]),le=(0,X.useCallback)(e=>({user:o(`chat:sessionTree.userMessage`),assistant:o(`chat:sessionTree.agentMessage`),tool:o(`chat:sessionTree.toolResult`),"tool-call":o(`chat:sessionTree.toolCall`),summary:o(`chat:sessionTree.branchSummary`),compaction:o(`chat:sessionTree.compactionSummary`),settings:o(`chat:sessionTree.settingsChange`),label:o(`chat:sessionTree.labelChange`),position:o(`chat:sessionTree.branchPosition`),extension:o(`chat:sessionTree.extensionEntry`),metadata:o(`chat:sessionTree.metadataEntry`),message:o(`chat:sessionTree.message`)})[e.kind]||e.type,[o]),ue=(0,X.useMemo)(()=>{let e=h.trim().toLocaleLowerCase(s);return Io(ce,t=>(p===`conversation`?Oo.has(t.kind):p!==`labeled`||t.label)?!e||`${t.label} ${t.text} ${le(t)}`.toLocaleLowerCase(s).includes(e):!1)},[ce,s,h,le,p]),de=(0,X.useMemo)(()=>ue.map(Lo),[ue]),V=(0,X.useMemo)(()=>Fo(ue),[ue]),H=(0,X.useMemo)(()=>Fo(ce),[ce]).find(e=>e.id===v)||null,fe=c?.lineage?.parentSessionId?d.find(e=>e.id===c.lineage?.parentSessionId):null,pe=(c?.lineage?.childSessionIds||[]).map(e=>d.find(t=>t.id===e)).filter(e=>!!e),me=H?.kind===`assistant`&&H.status===`completed`,he=me,ge=H?!ko.has(H.kind):!1;(0,X.useEffect)(()=>{x(H?.label||``),j(!1)},[H?.id,H?.label]),(0,X.useEffect)(()=>{if(v&&V.some(e=>e.id===v))return;let e=[...V].reverse().find(e=>e.active);y(e?.id||V[0]?.id||``)},[v,V]),(0,X.useEffect)(()=>{if(!e||!v)return;let t=requestAnimationFrame(()=>{document.querySelector(`[data-testid="session-tree-list"] .session-tree-node.selected`)?.scrollIntoView({block:`center`})});return()=>cancelAnimationFrame(t)},[e,h,v,p,V.length]);let _e=async()=>{N(!0),B(``);try{let e=await J.getSessionTree(t);u(e),y(e.leafId||e.nodes[0]?.id||``)}catch(e){B($(e))}finally{N(!1)}},ve=async()=>{if(!(!H||P)){F(!0),B(``);try{u(await J.setSessionTreeLabel(t,H.id,b))}catch(e){B($(e))}finally{F(!1)}}},ye=async()=>{if(!(!H||P)){F(!0),B(``);try{u(await J.setSessionTreeLabel(t,H.id,``))}catch(e){B($(e))}finally{F(!1)}}},xe=async()=>{if(!(!H||!he||R)){ee(!0),B(``);try{await a(H.id),r()}catch(e){B($(e))}finally{ee(!1)}}},Se=async(e,t=``)=>{if(!(!e.id||z)){te(e.id),B(``);try{t&&await J.navigateSessionTreeTarget(e.id,t),rt(e.id,`open`,t),r()}catch(e){B($(e))}finally{te(``)}}},Ce=async()=>{if(!(!H||I||H.leaf||n||c?.streaming)){L(!0),B(``);try{let e=await J.navigateSessionTree(t,H.id,A);u(e),e.cancelled||(await i(e.editorText),r())}catch(e){B($(e))}finally{L(!1)}}},U=e=>e.leaf?o(`chat:sessionTree.current`):e.branchPoint?o(`chat:sessionTree.fork`):e.active?o(`chat:sessionTree.active`):``;return(0,Z.jsx)(Me,{open:e,onOpenChange:e=>!e&&r(),children:(0,Z.jsxs)(ft,{className:`chat-resource-dialog w-[min(820px,calc(100vw_-_32px))] h-[min(600px,calc(100dvh_-_32px))] max-w-[820px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden max-[650px]:w-[calc(100vw_-_16px)] max-[650px]:h-[calc(100dvh_-_16px)] session-tree-dialog !w-[min(1120px,calc(100vw_-_32px))] !h-[min(760px,calc(100dvh_-_32px))] !max-w-[1120px]`,showCloseButton:!0,children:[(0,Z.jsx)(`div`,{className:`chat-resource-head [&_[data-slot='dialog-title']]:text-[16px] [&_[data-slot='dialog-description']]:mt-[3px] [&_[data-slot='dialog-description']]:text-[12px] max-[650px]:p-[14px] flex items-start justify-between gap-[16px] [border-bottom:1px_solid_var(--stroke-soft)] [padding:17px_18px_14px] session-tree-head max-[650px]:items-start`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`session-tree-title [&_>_span]:grid [&_>_span]:w-[30px] [&_>_span]:h-[30px] [&_>_span]:place-items-center [&_>_span]:rounded-[var(--r-sm)] [&_>_span]:bg-[var(--success-soft)] [&_>_span]:text-[var(--success)] flex items-center gap-[9px]`,children:[(0,Z.jsx)(`span`,{children:(0,Z.jsx)(gr,{size:17})}),(0,Z.jsx)(K,{children:o(`chat:sessionTree.title`)})]}),(0,Z.jsx)(Ue,{children:o(`chat:sessionTree.description`,{nodes:c?.nodeCount||0,branches:c?.branchCount||0})})]})}),(0,Z.jsxs)(`div`,{className:`chat-resource-body grid min-h-0 grid-cols-[minmax(0,1.1fr)_minmax(260px,.9fr)] overflow-hidden max-[650px]:grid-cols-[1fr] max-[650px]:grid-rows-[minmax(0,1fr)_minmax(190px,auto)] max-[650px]:overflow-hidden session-tree-layout !grid-cols-[minmax(0,1fr)_292px] bg-[var(--surface-subtle)] max-[650px]:grid-rows-[minmax(0,1fr)_minmax(210px,auto)]`,children:[(0,Z.jsxs)(`div`,{className:`chat-resource-browser flex min-w-0 min-h-0 flex-col [border-right:1px_solid_var(--stroke-soft)] p-[12px] max-[650px]:min-h-0 max-[650px]:[border-right:0] max-[650px]:[border-bottom:1px_solid_var(--stroke-soft)] session-tree-browser ![border-right:0] !p-0 bg-transparent`,children:[(0,Z.jsx)(kt,{className:`chat-resource-tabs [&_[data-slot='tabs-list']]:grid [&_[data-slot='tabs-list']]:w-full [&_[data-slot='tabs-list']]:h-[36px] [&_[data-slot='tabs-list']]:grid-cols-[repeat(5,minmax(0,1fr))] [&_[data-slot='tabs-list']]:[border:1px_solid_var(--stroke-soft)] [&_[data-slot='tabs-list']]:rounded-[var(--r-sm)] [&_[data-slot='tabs-list']]:bg-[var(--surface-muted)] [&_[data-slot='tabs-trigger']]:min-w-0 [&_[data-slot='tabs-trigger']]:gap-[5px] [&_[data-slot='tabs-trigger']]:rounded-[var(--r-xs)] [&_[data-slot='tabs-trigger']]:[padding-inline:6px] [&_[data-slot='tabs-trigger']]:text-[11px] [&_[data-slot='tabs-trigger'][data-state='active']]:bg-[var(--solid)] [&_[data-slot='tabs-trigger'][data-state='active']]:text-[var(--text)] [&_[data-slot='tabs-trigger']_small]:text-[var(--text-muted)] [&_[data-slot='tabs-trigger']_small]:text-[10px] [&_[data-slot='tabs-trigger']_small]:font-[500] w-full session-tree-tabs [padding:12px_12px_0]`,value:p,onValueChange:e=>m(e),children:(0,Z.jsxs)(ot,{children:[(0,Z.jsx)(Y,{value:`conversation`,children:o(`chat:sessionTree.conversation`)}),(0,Z.jsx)(Y,{value:`labeled`,children:o(`chat:sessionTree.labeled`)}),(0,Z.jsx)(Y,{value:`all`,children:o(`chat:sessionTree.all`)}),(0,Z.jsx)(Y,{value:`marks`,children:o(`chat:sessionTree.allMarks`)})]})}),(0,Z.jsxs)(`label`,{className:`chat-resource-search [&:focus-within]:border-[var(--focus)] [&:focus-within]:shadow-[0_0_0_2px_var(--focus-ring)] [&_input]:w-full [&_input]:h-[36px] [&_input]:border-0 [&_input]:[outline:0]! [&_input]:bg-transparent [&_input]:text-[var(--text)] [&_input]:text-[13px] flex items-center gap-[7px] [margin-top:8px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] [padding:0_10px] text-[var(--text-muted)] flex-none [margin:8px_12px_0] bg-[var(--solid)]`,children:[(0,Z.jsx)(Te,{size:15}),(0,Z.jsx)(`input`,{value:h,disabled:!!O,onChange:e=>_(e.target.value),placeholder:o(`chat:sessionTree.searchPlaceholder`)})]}),p===`marks`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 min-h-0 [flex:1_1_0] flex-col gap-[8px] overflow-auto [overscroll-behavior:contain] [padding:12px_14px]`,"data-testid":`session-tree-marks-list`,children:[ne&&(0,Z.jsx)(`p`,{className:`danger-text [margin:0_2px]`,children:ne}),E?(0,Z.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:o(`chat:sessionTree.loadingMarks`)}):ie.length?ie.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`session-tree-mark hover:border-[var(--stroke-hover)] hover:bg-[var(--solid)] [&.active]:border-[var(--brand-blue-border)] [&_>_em]:rounded-[var(--r-xs)] [&_>_em]:bg-[var(--brand-blue-soft)] [&_>_em]:text-[var(--brand-blue-strong)] [&_>_em]:p-[2px_6px] [&_>_em]:text-[10px] [&_>_em]:[font-style:normal] grid grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[color-mix(in_srgb,var(--solid)_94%,transparent)] text-[var(--text)] [padding:8px_10px_8px_4px] text-left cursor-pointer ${e.active?` active`:``}`,disabled:!!O,"aria-busy":O===e,onClick:()=>void oe(e),children:[(0,Z.jsx)(`span`,{className:`session-tree-marker [.session-tree-node[data-kind='user']_&]:bg-[var(--star-soft)] [.session-tree-node[data-kind='user']_&]:text-[var(--star-strong)] [.session-tree-node[data-kind='assistant']_&]:bg-[var(--brand-blue-soft)] [.session-tree-node[data-kind='assistant']_&]:text-[var(--brand-blue-strong)] [.session-tree-node[data-kind='tool']_&]:bg-[var(--warning-soft)] [.session-tree-node[data-kind='tool']_&]:text-[var(--warning-strong)] [.session-tree-node[data-kind='summary']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='summary']_&]:text-[var(--violet-strong)] [.session-tree-node[data-kind='compaction']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='compaction']_&]:text-[var(--violet-strong)] [.session-tree-node.active_&]:border-[var(--brand-blue-border)] [.session-tree-node.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] [.session-tree-node.leaf_&]:bg-[var(--star)] [.session-tree-node.leaf_&]:text-[var(--on-accent)] [.session-tree-mark.active_&]:border-[var(--brand-blue-border)] [.session-tree-mark.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] relative z-[2] grid w-[26px] h-[26px] place-items-center [justify-self:center] [border:2px_solid_var(--surface-subtle)] rounded-[50%] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:O===e?(0,Z.jsx)(be,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,Z.jsx)(Oe,{size:14})}),(0,Z.jsxs)(`span`,{className:`session-tree-node-copy [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_strong]:font-[650] [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] flex min-w-0 flex-col gap-[2px]`,children:[(0,Z.jsx)(`strong`,{children:e.label}),(0,Z.jsx)(`small`,{children:e.sessionName||o(`navigation:appOverlays.untitledChat`)}),(0,Z.jsx)(`small`,{children:o(`chat:sessionTree.markTimes`,{sessionTime:se(e.sessionModified),nodeTime:se(e.nodeTimestamp)})})]}),O===e?(0,Z.jsx)(`em`,{children:o(`chat:sessionTree.navigating`)}):e.active&&(0,Z.jsx)(`em`,{children:o(`chat:sessionTree.markActive`)})]},`${e.sessionId}:${e.entryId}`)):(0,Z.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:o(`chat:sessionTree.noMarksYet`)})]}):(0,Z.jsx)(`div`,{className:`min-w-0 min-h-0 [flex:1_1_0] overflow-auto [overscroll-behavior:contain] [scrollbar-gutter:stable]`,"data-testid":`session-tree-list`,ref:re,children:de.length>0?(0,Z.jsx)(`div`,{className:`session-tree-canvas max-[650px]:min-w-[460px] max-[650px]:[padding-inline:12px] flex w-[max-content] min-w-[100%] items-start justify-center gap-[36px] [padding:26px_28px_48px]`,children:de.map(e=>(0,Z.jsx)(zo,{segment:e,viewportRef:re,selectedId:v,typeLabel:le,stateLabel:U,onSelect:y},e.id))}):(0,Z.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:M?o(`chat:sessionTree.loading`):ne||o(`chat:sessionTree.empty`)})})]}),p!==`marks`&&(0,Z.jsxs)(`div`,{className:`chat-resource-config [&_>_p]:m-[auto] [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[12px] [&_>_div:first-child]:flex [&_>_div:first-child]:flex-col [&_>_div:first-child]:gap-[4px] [&_strong]:text-[14px] [&_p]:text-[var(--text-muted)] [&_p]:text-[12px] max-[650px]:min-h-0 max-[650px]:max-h-[230px] flex min-w-0 min-h-0 flex-col gap-[16px] overflow-y-auto [overscroll-behavior:contain] [padding:18px] session-tree-inspector max-[650px]:max-h-[250px] [margin:12px_12px_12px_0] [border-left:0] rounded-[var(--r-md)] bg-[color-mix(in_srgb,var(--solid)_88%,var(--surface-subtle))] shadow-[0_10px_28px_-26px_var(--shadow)]`,children:[H?(0,Z.jsxs)(Z.Fragment,{children:[(fe||pe.length>0)&&(0,Z.jsxs)(`div`,{className:`session-tree-lineage [&_>_strong]:text-[12px] [&_>_strong]:font-[650] [&_button]:justify-start [&_button]:text-left [&_button]:text-[11px] flex flex-col gap-[6px] [border-bottom:1px_solid_var(--stroke-soft)] [padding-bottom:12px]`,children:[(0,Z.jsx)(`strong`,{children:o(`chat:sessionTree.conversationLineage`)}),fe&&(0,Z.jsxs)(l,{variant:`outline`,disabled:!!z,onClick:()=>void Se(fe,c?.lineage?.sourceEntryId||``),children:[(0,Z.jsx)(Ge,{size:13}),o(`chat:sessionTree.returnToOriginalChat`,{name:fe.name||o(`chat:chatPage.newChat`)})]}),pe.map(e=>(0,Z.jsxs)(l,{variant:`outline`,disabled:!!z,onClick:()=>void Se(e),children:[(0,Z.jsx)(Ge,{size:13}),o(`chat:sessionTree.openSeparateChat`,{name:e.name||o(`chat:chatPage.newChat`)})]},e.id))]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`session-tree-selection-kind [&_em]:rounded-[var(--r-xs)] [&_em]:bg-[var(--brand-blue-soft)] [&_em]:text-[var(--brand-blue-strong)] [&_em]:p-[2px_5px] [&_em]:[font-style:normal] flex items-center justify-between gap-[8px] text-[var(--text-muted)] text-[10px] [text-transform:uppercase]`,children:[le(H),U(H)&&(0,Z.jsx)(`em`,{children:U(H)})]}),(0,Z.jsx)(`strong`,{children:H.label||le(H)}),(0,Z.jsx)(`p`,{children:H.text||o(`chat:sessionTree.noPreview`)})]}),(0,Z.jsxs)(`div`,{className:`chat-resource-inputs [&_label]:grid [&_label]:gap-[5px] [&_label]:text-[12px] [&_label]:font-[600] [&_input[type='checkbox']]:w-[16px] [&_input[type='checkbox']]:h-[16px] [&_input[type='checkbox']]:[accent-color:var(--blue)] flex flex-col gap-[11px]`,children:[me&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{children:[(0,Z.jsx)(`span`,{children:o(`chat:sessionTree.nodeLabel`)}),(0,Z.jsx)(W,{value:b,maxLength:80,placeholder:o(`chat:sessionTree.labelPlaceholder`),onChange:e=>x(e.target.value)})]}),(0,Z.jsxs)(l,{variant:`outline`,disabled:P||n||!!c?.streaming,onClick:()=>void ve(),children:[(0,Z.jsx)(Oe,{size:14}),o(P?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]}),!!H.label&&(0,Z.jsxs)(l,{variant:`outline`,disabled:P||n||!!c?.streaming,onClick:()=>void ye(),children:[(0,Z.jsx)(ke,{size:14}),o(`chat:sessionTree.removeLabel`)]})]}),he&&(0,Z.jsxs)(l,{variant:`outline`,disabled:R||n||!!c?.streaming,onClick:()=>void xe(),children:[(0,Z.jsx)(ur,{size:14}),o(R?`chat:sessionTree.creatingChildChat`:`chat:sessionTree.createChildChat`)]}),ge&&(0,Z.jsxs)(`label`,{className:`session-tree-summary-option [&_small]:[grid-column:1/-1] [&_small]:text-[var(--text-muted)] [&_small]:font-[400] [&_small]:leading-[1.45] grid-cols-[minmax(0,1fr)_auto] items-center`,children:[(0,Z.jsx)(`span`,{children:o(`chat:sessionTree.abandonedBranchSummary`)}),(0,Z.jsx)(`input`,{type:`checkbox`,checked:A,disabled:H.leaf||n||!!c?.streaming,onChange:e=>j(e.target.checked)}),(0,Z.jsx)(`small`,{children:o(`chat:sessionTree.abandonedBranchSummaryHint`)})]})]}),ge&&(0,Z.jsx)(`p`,{children:o(`chat:sessionTree.sideEffectsRemain`)}),H.timestamp&&(0,Z.jsx)(`p`,{children:new Intl.DateTimeFormat(s,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(H.timestamp))}),ne&&(0,Z.jsx)(`p`,{className:`danger-text`,children:ne}),ge&&(0,Z.jsxs)(l,{className:`chat-resource-confirm hover:bg-[var(--star-hover)] hover:text-[var(--on-accent)] min-w-[112px] min-h-[36px] self-start bg-[var(--star)] text-[var(--on-accent)] font-[650]`,disabled:I||H.leaf||n||!!c?.streaming,onClick:()=>void Ce(),children:[(0,Z.jsx)(ae,{size:15}),I?o(`chat:sessionTree.navigating`):H.leaf?o(`chat:sessionTree.currentPosition`):o(`chat:sessionTree.continueFromNode`)]})]}):(0,Z.jsx)(`p`,{children:M?o(`chat:sessionTree.loading`):ne||o(`chat:sessionTree.chooseNode`)}),ne&&!H&&(0,Z.jsx)(l,{variant:`outline`,onClick:()=>void _e(),children:o(`chat:sessionTree.retry`)})]})]})]})})}function Vo({visible:e,open:t,sessionId:n,streaming:r,revision:i,pulseToken:a,onOpenChange:o,onNavigated:s,onCreateChildSession:c}){let{t:u}=g(),[d,f]=(0,X.useState)(0),[p,m]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(!a)return;m(!0);let e=window.setTimeout(()=>m(!1),1800);return()=>window.clearTimeout(e)},[a]),(0,X.useEffect)(()=>{if(!e||r)return;let t=!0;return J.getSessionTree(n).then(e=>t&&f(e.branchCount||0)).catch(()=>{}),()=>{t=!1}},[i,n,r,e]),e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(l,{type:`button`,variant:`ghost`,size:`icon`,className:`focus-session-tree-entry hover:border-[var(--brand-blue-border)] hover:bg-[var(--solid)] hover:text-[var(--brand-blue-strong)] [&_>_span]:text-[11px] [&_>_span]:font-[650] [&_>_span]:whitespace-nowrap [&_i]:grid [&_i]:min-w-[17px] [&_i]:h-[17px] [&_i]:place-items-center [&_i]:rounded-[var(--r-pill)] [&_i]:bg-[var(--brand-blue-soft)] [&_i]:text-[var(--brand-blue-strong)] [&_i]:p-[0_4px] [&_i]:text-[9px] [&_i]:[font-style:normal] [&_i]:[font-variant-numeric:tabular-nums] absolute z-[6] [top:12px] [right:18px] inline-flex w-auto min-w-[32px] h-[32px] items-center gap-[6px] [border:1px_solid_var(--stroke)] rounded-[var(--r-pill)] bg-[color-mix(in_srgb,var(--solid)_90%,transparent)] text-[var(--text-muted)] [padding:0_10px_0_8px] shadow-[var(--sh-1)] [backdrop-filter:blur(10px)] motion-reduce:[animation:none] ${p?`[animation:session-tree-new-node-pulse_1.8s_var(--ease-out)]`:``}`,title:u(`chat:sessionTree.menuDescription`),"data-pisper-recall-pulse":p||void 0,"aria-label":u(`chat:sessionTree.menu`),onClick:()=>o(!0),children:[(0,Z.jsx)(gr,{size:16}),(0,Z.jsx)(`span`,{children:u(`chat:sessionTree.menu`)}),d>0&&(0,Z.jsx)(`i`,{children:d})]}),(0,Z.jsx)(Bo,{open:t,sessionId:n,streaming:r,onClose:()=>o(!1),onNavigated:s,onCreateChildSession:c})]}):null}function Ho(e){return[`running`,`waiting_approval`].includes(String(e.status||``))}function Uo(e,t){return t(e===`running`?`chat:workflowRun.running`:e===`waiting_approval`?`chat:workflowRun.waitingApproval`:e===`completed`?`chat:workflowRun.completed`:e===`failed`?`chat:workflowRun.failed`:e===`cancelled`?`chat:workflowRun.stopped`:`chat:workflowRun.interrupted`)}function Wo({sessionId:e}){let{t}=g(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(``),o=(0,X.useCallback)(async()=>{try{let t=await J.getSessionWorkflowRuns(e);r(t.runs||[])}catch{}},[e]);return(0,X.useEffect)(()=>{o();let e=window.setInterval(o,1500);return()=>window.clearInterval(e)},[o]),n.length?(0,Z.jsx)(`div`,{className:`flex max-h-[210px] flex-col gap-[5px] overflow-auto`,children:[...n].sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt)).slice(0,5).map(e=>{let n=i===e.id,r=Math.round((Number(e.completedNodes)||0)/Math.max(1,Number(e.totalNodes)||1)*100);return(0,Z.jsxs)(`div`,{className:`session-workflow-run [&.failed]:border-[color-mix(in_srgb,var(--danger)_40%,var(--stroke-soft))] [&.waiting_approval]:border-[color-mix(in_srgb,var(--warning)_45%,var(--stroke-soft))] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--solid)] ${e.status}`,children:[(0,Z.jsxs)(`button`,{className:`session-workflow-summary [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[1px] [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_[data-slot='progress']]:h-[4px] max-[650px]:grid-cols-[28px_minmax(0,1fr)_16px] max-[650px]:[&_[data-slot='progress']]:[grid-column:2/4] grid w-full grid-cols-[28px_minmax(120px,1fr)_minmax(80px,160px)_16px] items-center gap-[9px] border-0 bg-transparent [padding:7px_9px] text-[var(--text)] text-left cursor-pointer`,onClick:()=>a(n?``:e.id),children:[(0,Z.jsx)(`span`,{className:`list-icon [.chat-resource-list_&]:grid [.chat-resource-list_&]:w-[28px] [.chat-resource-list_&]:h-[28px] [.chat-resource-list_&]:place-items-center [.chat-resource-list_&]:rounded-[var(--r-sm)] [.chat-resource-list_&]:bg-[var(--surface-subtle)] [.chat-resource-list_&]:text-[var(--star-strong)] [.session-workflow-summary_&]:grid [.session-workflow-summary_&]:w-[28px] [.session-workflow-summary_&]:h-[28px] [.session-workflow-summary_&]:place-items-center [.session-workflow-summary_&]:rounded-[var(--r-sm)] [.session-workflow-summary_&]:bg-[var(--surface-subtle)] [.session-workflow-summary_&]:text-[var(--star-strong)] grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)] [.workflow-template-gallery_&]:grid [.workflow-template-gallery_&]:w-[32px] [.workflow-template-gallery_&]:h-[32px] [.workflow-template-gallery_&]:place-items-center [.workflow-template-gallery_&]:rounded-[var(--r-sm)] [.workflow-template-gallery_&]:bg-[var(--surface-subtle)] [.workflow-template-gallery_&]:text-[var(--star-strong)]`,children:(0,Z.jsx)(Mt,{size:14})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:e.workflowName}),(0,Z.jsxs)(`small`,{children:[Uo(e.status,t),` · v`,e.workflowRevision||1]})]}),(0,Z.jsx)(se,{value:e.status===`completed`?100:r}),n?(0,Z.jsx)(he,{size:14}):(0,Z.jsx)(Ye,{size:14})]}),n&&(0,Z.jsxs)(`div`,{className:`session-workflow-detail [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[11px] max-[650px]:pl-[12px] flex flex-col gap-[5px] [border-top:1px_solid_var(--stroke-soft)] [padding:7px_9px_9px_46px]`,children:[e.sourceMessage&&(0,Z.jsxs)(`div`,{className:`session-workflow-context [&_strong]:text-[var(--text-muted)] [&_strong]:text-[10px] [&_strong]:[text-transform:uppercase] [&_p]:max-h-[84px] [&_p]:overflow-auto [&_p]:m-0 [&_p]:text-[var(--text-secondary)] [&_p]:text-[11px] [&_p]:leading-[1.45] [&_p]:whitespace-pre-wrap [&_p]:[overflow-wrap:anywhere] [&_pre]:max-h-[84px] [&_pre]:overflow-auto [&_pre]:m-0 [&_pre]:text-[var(--text-secondary)] [&_pre]:text-[11px] [&_pre]:leading-[1.45] [&_pre]:whitespace-pre-wrap [&_pre]:[overflow-wrap:anywhere] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--surface-subtle)] [&_pre]:p-[5px_6px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] grid min-w-0 gap-[3px] [border-bottom:1px_solid_var(--stroke-soft)] [padding-bottom:6px]`,children:[(0,Z.jsx)(`strong`,{children:t(`chat:workflowRun.request`)}),(0,Z.jsx)(`p`,{children:e.sourceMessage})]}),e.inputs&&Object.keys(e.inputs).length>0&&(0,Z.jsxs)(`div`,{className:`session-workflow-context [&_strong]:text-[var(--text-muted)] [&_strong]:text-[10px] [&_strong]:[text-transform:uppercase] [&_p]:max-h-[84px] [&_p]:overflow-auto [&_p]:m-0 [&_p]:text-[var(--text-secondary)] [&_p]:text-[11px] [&_p]:leading-[1.45] [&_p]:whitespace-pre-wrap [&_p]:[overflow-wrap:anywhere] [&_pre]:max-h-[84px] [&_pre]:overflow-auto [&_pre]:m-0 [&_pre]:text-[var(--text-secondary)] [&_pre]:text-[11px] [&_pre]:leading-[1.45] [&_pre]:whitespace-pre-wrap [&_pre]:[overflow-wrap:anywhere] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--surface-subtle)] [&_pre]:p-[5px_6px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] grid min-w-0 gap-[3px] [border-bottom:1px_solid_var(--stroke-soft)] [padding-bottom:6px]`,children:[(0,Z.jsx)(`strong`,{children:t(`chat:workflowRun.inputs`)}),(0,Z.jsx)(`pre`,{children:JSON.stringify(e.inputs,null,2)})]}),(e.nodes||[]).map(n=>(0,Z.jsxs)(`div`,{className:`session-workflow-node [&.completed]:text-[var(--success)] [&.failed]:text-[var(--danger)] [&_>_span]:flex [&_>_span]:min-w-0 [&_>_span]:flex-col [&_strong]:text-[var(--text)] [&_strong]:text-[11px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_>_div]:flex [&_>_div]:gap-[4px] grid grid-cols-[15px_minmax(0,1fr)_auto] items-center gap-[6px] min-h-[24px] text-[var(--text-muted)] ${n.status}`,children:[n.status===`completed`?(0,Z.jsx)(B,{size:13}):n.status===`failed`?(0,Z.jsx)(oe,{size:13}):n.status===`running`?(0,Z.jsx)(G,{className:`animate-spin`,size:13}):(0,Z.jsx)(De,{size:11}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n.label}),(n.error||n.summary)&&(0,Z.jsx)(`small`,{children:n.error||n.summary})]}),n.status===`waiting_approval`&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(l,{size:`xs`,onClick:async()=>{await J.resolveWorkflowApproval(e.id,n.id,!0),await o()},children:t(`chat:workflowRun.approve`)}),(0,Z.jsx)(l,{size:`xs`,variant:`destructive`,onClick:async()=>{await J.resolveWorkflowApproval(e.id,n.id,!1),await o()},children:t(`chat:workflowRun.reject`)})]})]},n.id)),(e.error||e.summary)&&(0,Z.jsx)(`p`,{children:e.error||e.summary}),Ho(e)&&(0,Z.jsxs)(l,{size:`xs`,variant:`destructive`,onClick:async()=>{await J.stopWorkflowRun(e.id),await o()},children:[(0,Z.jsx)(De,{"data-icon":`inline-start`}),t(`chat:workflowRun.stop`)]})]})]},e.id)})}):null}(0,X.lazy)(()=>i(()=>import(`./ClickSpark-BhxL8WOQ.js`).then(e=>({default:e.ClickSpark})),__vite__mapDeps([10,1,2,3,4,7])));var Go=(0,X.createContext)(null),Ko=({className:e,approval:t,state:n,...r})=>{let i=(0,X.useMemo)(()=>({approval:t,state:n}),[t,n]);return!t||n===`input-streaming`||n===`input-available`?null:(0,Z.jsx)(Go.Provider,{value:i,children:(0,Z.jsx)(Bt,{className:V(`flex flex-col gap-2`,e),...r})})};function qo({approvals:e,onResolve:t,compact:n=!1}){let{t:r}=g(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(!1),u=e[0];if((0,X.useEffect)(()=>s(!1),[u?.id]),!u)return null;let d=u.fileChange,f=typeof d?.diff==`string`?d.diff:``,p=async e=>{if(!c.current){c.current=!0,a(!0);try{await t(u.id,e)}finally{c.current=!1,a(!1)}}};return(0,Z.jsxs)(Ko,{approval:{id:u.id},state:`approval-requested`,className:`tool-approval [&_>_div:first-child]:flex [&_>_div:first-child]:min-w-0 [&_>_div:first-child]:items-center [&_>_div:first-child]:gap-[8px] [&_>_div:first-child_>_span]:flex [&_>_div:first-child_>_span]:min-w-0 [&_>_div:first-child_>_span]:flex-col [&_>_div:first-child_>_span]:gap-[2px] [&_strong]:text-[13px] [&_small]:overflow-hidden [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_details]:min-w-0 [&_details]:text-[13px] [&_summary]:cursor-pointer [&_pre]:max-h-[130px] [&_pre]:overflow-auto [&_pre]:mt-[6px] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--warning-code-bg)] [&_pre]:text-[var(--warning-soft)] [&_pre]:p-[8px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_pre]:text-[13px] [&_pre]:whitespace-pre-wrap [&.compact]:grid-cols-[minmax(0,1fr)_auto] [&.compact]:p-[6px_7px] [&.compact_strong]:text-[13px] [&.compact_small]:text-[13px] grid grid-cols-[minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--warning-soft)] text-[var(--warning-strong)] [padding:9px_10px] ${n?`compact`:``}`,"data-pisper-approval-id":u.id,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(Ee,{size:n?12:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:r(`chat:focusSession.toolRequestsApproval`,{tool:u.toolName})}),(0,Z.jsxs)(`small`,{children:[u.reason,e.length>1?` · ${r(`chat:focusSession.countMoreWaiting`,{count:e.length-1})}`:``]})]})]}),!n&&(0,Z.jsxs)(`div`,{className:`flex [grid-column:1/-1] items-center gap-[10px]`,children:[f&&(0,Z.jsxs)(`button`,{type:`button`,className:`tool-approval-view-diff hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] inline-flex min-h-[28px] flex-none items-center gap-[6px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--surface-muted)] [padding:4px_7px] text-[var(--text-secondary)] text-[12px] font-[600] cursor-pointer`,onClick:()=>s(!0),children:[(0,Z.jsx)(er,{size:13}),r(`chat:focusSession.gitViewDiff`)]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{children:r(`chat:focusSession.viewCallArguments`)}),(0,Z.jsx)(`pre`,{children:JSON.stringify(u.args,null,2)})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-[5px]`,children:[(0,Z.jsx)(l,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:i,onClick:()=>p(!1),children:r(`chat:focusSession.deny`)}),(0,Z.jsxs)(l,{type:`button`,size:`lg`,disabled:i,onClick:()=>p(!0),children:[i?(0,Z.jsx)(G,{className:`animate-spin`,size:12}):(0,Z.jsx)(B,{size:12}),r(`chat:focusSession.allow`)]})]}),o&&(0,Z.jsx)(yo,{diff:f,truncated:!!d?.truncated,onClose:()=>s(!1)})]})}function Jo({sessionId:e,cwd:t,streaming:n=!1}){let{t:r}=g(),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(``),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(0),m=(0,X.useCallback)(async()=>{let t=++p.current;s(``);try{let n=await J.getWorkspaceTrust(e);t===p.current&&a(n)}catch(e){t===p.current&&s($(e))}},[e]);(0,X.useEffect)(()=>(a(null),m(),()=>{p.current+=1}),[t,m]);let h=async t=>{if(!(c||n)){u(!0),s(``);try{a(await J.setWorkspaceTrust(e,t))}catch(e){s($(e))}finally{u(!1)}}};return i?!i.resources.length||i.trusted?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`tool-approval [&_>_div:first-child]:flex [&_>_div:first-child]:min-w-0 [&_>_div:first-child]:items-center [&_>_div:first-child]:gap-[8px] [&_>_div:first-child_>_span]:flex [&_>_div:first-child_>_span]:min-w-0 [&_>_div:first-child_>_span]:flex-col [&_>_div:first-child_>_span]:gap-[2px] [&_strong]:text-[13px] [&_small]:overflow-hidden [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_details]:min-w-0 [&_details]:text-[13px] [&_summary]:cursor-pointer [&_pre]:max-h-[130px] [&_pre]:overflow-auto [&_pre]:mt-[6px] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--warning-code-bg)] [&_pre]:text-[var(--warning-soft)] [&_pre]:p-[8px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_pre]:text-[13px] [&_pre]:whitespace-pre-wrap [&.compact]:grid-cols-[minmax(0,1fr)_auto] [&.compact]:p-[6px_7px] [&.compact_strong]:text-[13px] [&.compact_small]:text-[13px] grid grid-cols-[minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--warning-soft)] text-[var(--warning-strong)] [padding:9px_10px] compact workspace-trust-notice`,role:i.requiresDecision?`alert`:`status`,"data-pisper-workspace-trust":i.decision===!1?`restricted`:`pending`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(P,{size:17}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:i.requiresDecision?r(`chat:focusSession.workspaceTrustRequired`):r(`chat:focusSession.workspaceResourcesRestricted`)}),(0,Z.jsx)(`small`,{children:i.requiresDecision?r(`chat:focusSession.workspaceTrustRequiredDescription`):r(`chat:focusSession.workspaceResourcesRestrictedDescription`)}),o&&(0,Z.jsx)(`small`,{children:o})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-[5px]`,children:[i.requiresDecision&&(0,Z.jsx)(l,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:c||n,onClick:()=>void h(!1),children:r(`chat:focusSession.keepWorkspaceRestricted`)}),(0,Z.jsxs)(l,{type:`button`,disabled:c||n,onClick:()=>f(!0),children:[c?(0,Z.jsx)(G,{className:`animate-spin`,size:12}):(0,Z.jsx)(B,{size:12}),r(`chat:focusSession.trustWorkspace`)]})]})]}),(0,Z.jsx)(ne,{open:d,onOpenChange:f,children:(0,Z.jsxs)(F,{children:[(0,Z.jsxs)(te,{children:[(0,Z.jsx)(M,{children:(0,Z.jsx)(P,{})}),(0,Z.jsx)(I,{children:r(`chat:focusSession.trustWorkspaceTitle`)}),(0,Z.jsx)(j,{children:r(`chat:focusSession.trustWorkspaceDescription`)})]}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{children:r(`chat:focusSession.gitCancel`)}),(0,Z.jsx)(L,{className:`text-[var(--primary-foreground)]`,onClick:()=>void h(!0),children:r(`chat:focusSession.trustWorkspace`)})]})]})})]}):o?(0,Z.jsxs)(`div`,{className:`tool-approval [&_>_div:first-child]:flex [&_>_div:first-child]:min-w-0 [&_>_div:first-child]:items-center [&_>_div:first-child]:gap-[8px] [&_>_div:first-child_>_span]:flex [&_>_div:first-child_>_span]:min-w-0 [&_>_div:first-child_>_span]:flex-col [&_>_div:first-child_>_span]:gap-[2px] [&_strong]:text-[13px] [&_small]:overflow-hidden [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_details]:min-w-0 [&_details]:text-[13px] [&_summary]:cursor-pointer [&_pre]:max-h-[130px] [&_pre]:overflow-auto [&_pre]:mt-[6px] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--warning-code-bg)] [&_pre]:text-[var(--warning-soft)] [&_pre]:p-[8px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_pre]:text-[13px] [&_pre]:whitespace-pre-wrap [&.compact]:grid-cols-[minmax(0,1fr)_auto] [&.compact]:p-[6px_7px] [&.compact_strong]:text-[13px] [&.compact_small]:text-[13px] grid grid-cols-[minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--warning-soft)] text-[var(--warning-strong)] [padding:9px_10px] compact workspace-trust-notice`,role:`alert`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(P,{size:16}),(0,Z.jsx)(`span`,{children:r(`chat:focusSession.workspaceTrustLoadFailed`)})]}),(0,Z.jsx)(`div`,{className:`flex gap-[5px]`,children:(0,Z.jsxs)(l,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:()=>void m(),children:[(0,Z.jsx)(G,{size:12}),r(`chat:focusSession.retryWorkspaceTrust`)]})})]}):null}var Yo=3e4,Xo=/Mac|iPhone|iPad/.test(globalThis.navigator?.platform||``)?`⌘ K`:`Ctrl K`;function Zo({session:e,messages:t,transcriptLoadState:n=`ready`,messageStart:r,hasOlder:i,loadingOlder:a,olderError:o,model:s,thinkingLevel:c,availableThinkingLevels:l,thinkingStatus:u,thinkingMessage:d,executionMode:f,goal:p,plan:m,currentActivity:h,activityFeed:_,tools:v,thinkingText:y,queuedInputs:b,compaction:x,contextUsage:S,sessionUsage:C,sessionTreeRevision:w,sessionTreePulse:T,cwd:E,availableModels:D,switchingModel:O,switchingThinking:k,switchingCwd:A,switchingPermission:j,streaming:M,runStartedAt:N,lastActivityAt:P,runFinishedAt:F,runStopped:I,runNotice:L,approvals:R,error:ee,pendingAsset:z,canSplit:te,onAssetConsumed:ne,onLoadOlder:B,onModelChange:re,onThinkingLevelChange:ae,onExecutionModeChange:oe,onCompact:se,onCompactionThresholdChange:ce,onGoalPause:le,onGoalBudgetChange:ue,onApproval:de,onWorkspace:V,onRename:H,onBranchFromHere:pe,onCreateChildSession:me,onTreeNavigated:he,onSplitLeft:ge,onSplitRight:_e,onSplitTop:ve,onSplitBottom:ye,onClosePanel:be,onSend:xe,onQueue:Se,onAbort:Ce}){let{t:U,language:we}=g(),Te=He(),Ee=Re(e=>e.capabilities),Oe=Nt(Ee,`goals`),ke=Nt(Ee,`plans`),je=Nt(Ee,`vcs`),Me=Nt(Ee,`workflows`),{value:W,updateValue:Ne,selection:K,clearDraft:Pe}=di(e.id),[Fe,Ie]=(0,X.useState)(!1),[q,Le]=(0,X.useState)(Yo),[ze,Be]=(0,X.useState)(!1),[Ve,Ue]=(0,X.useState)(!1),[We,Ge]=(0,X.useState)(0),[J,Ke]=(0,X.useState)(!1),[Je,Ye]=(0,X.useState)(!1),[Xe,Ze]=(0,X.useState)(!1),[Qe,et]=(0,X.useState)(null),tt=K.addAttachments,nt=(0,X.useRef)(null),rt=n!==`ready`||t.length>0,at=`composer-tool-tray-${e.id}`,ot=U(Xe?`chat:focusSession.collapseQuickActions`:`chat:focusSession.expandQuickActions`),st=U(Te?M?`chat:focusSession.addGuidanceForTheRunningAgent`:`chat:focusSession.writeWhatYouWantToAccomplish`:M?`chat:focusSession.addGuidanceForTheRunningAgentShiftEnterForANewLine`:`chat:focusSession.writeWhatYouWantToAccomplishShiftEnterForANewLine`);(0,X.useEffect)(()=>{Ie(!1),Be(!1),Ue(!1),et(null),Ke(!1),Ye(!1),Ze(!1)},[e.id]),(0,X.useEffect)(()=>{Oe||Ie(!1),!Me&&Qe?.kind===`workflow`&&et(null)},[Oe,Qe?.kind,Me]),(0,X.useEffect)(()=>{z&&(tt([z]),ne?.())},[z,ne,tt]),(0,X.useEffect)(()=>{if(!Xe)return;let e=e=>{e.key===`Escape`&&Ze(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Xe]);let ct=e=>{Ne(e),requestAnimationFrame(()=>{let e=nt.current;e&&(e.focus(),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})},Y=()=>{Ge(e=>e+1)},lt=async()=>{if(!(!se||M||Ve||x?.active)){Ue(!0);try{await se()}finally{Ue(!1)}}},ut=async e=>{if(e.preventDefault(),!(!W.trim()&&!K.attachments.length&&!Qe)){if(M){if(!W.trim()&&!K.attachments.length||ze)return;Be(!0);let e=await Se?.(W,K.attachments,`steer`);if(Be(!1),!e)return;Pe(),Ie(!1),Y(),nt.current&&(nt.current.style.height=`auto`);return}xe(W,K.attachments,Fe,Fe?q:null,Qe),Y(),Pe(),Ie(!1),et(null),nt.current&&(nt.current.style.height=`auto`)}},ft=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ii,{sessionId:e.id,value:W,onChange:Ne,inputRef:nt}),(0,Z.jsx)(`button`,{type:`button`,className:`resource-picker-trigger [.focus-composer_&]:h-[38px] [.focus-composer_&]:border-0 [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-composer_&]:bg-[var(--surface-subtle)] [.focus-composer_&]:text-[12px] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] relative grid place-items-center border-0 rounded-[var(--r-xs)] bg-transparent text-[var(--text-muted)] cursor-pointer hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)]`,title:U(`chat:resourcePicker.open`),"aria-label":U(`chat:resourcePicker.open`),onClick:()=>Ke(!0),children:(0,Z.jsx)(ie,{size:16})}),(0,Z.jsx)(ti,{cwd:E,selection:K})]});return(0,Z.jsxs)(Dt,{className:`focus-session [.session-dock-panel_&]:overflow-hidden [.session-dock-panel_&]:min-h-0 [.session-dock-panel_&]:border-0 [.session-dock-panel_&]:rounded-[0] [.session-dock-panel_&]:bg-[var(--panel)] [.session-dock-panel_&]:p-0 [.session-dock-panel_&]:shadow-[none] [[data-theme='dark']_.session-dock-panel_&]:bg-[var(--main-surface-bg)] min-[651px]:[[data-density='compact']_.app-card:not(&)]:p-[10px] max-[650px]:min-h-[460px] max-[650px]:[.session-dock-panel_&]:min-h-0 relative flex h-full min-h-[500px] flex-col ${rt?`has-conversation`:`is-empty`}`,children:[!rt&&(0,Z.jsx)(vt,{className:`relative z-4 min-h-12 flex-none items-center border-b border-[var(--stroke-soft)] bg-[var(--panel)] px-3 py-[7px]`,children:(0,Z.jsx)(`div`,{className:`flex [margin-left:auto] items-center gap-[6px]`,children:(0,Z.jsx)(Do,{session:e,canSplit:te,streaming:M,switchingCwd:A,onSplitLeft:ge,onSplitRight:_e,onSplitTop:ve,onSplitBottom:ye,onClosePanel:be,onWorkspace:V,onRename:H,onSessionTree:()=>Ye(!0)})})}),(0,Z.jsx)(Vo,{visible:t.length>0,open:Je,sessionId:e.id,streaming:!!M,revision:w,pulseToken:T,onOpenChange:Ye,onNavigated:async e=>{e!==null&&ct(e),await he?.(),Y()},onCreateChildSession:e=>me(e)}),(0,Z.jsx)(co,{sessionId:e.id,messages:t,transcriptLoadState:n,messageStart:r,hasOlder:i,loadingOlder:a,olderError:o,currentActivity:h,activityFeed:_,tools:v,thinkingText:y,compaction:x,streaming:M,runStartedAt:N,lastActivityAt:P,runFinishedAt:F,runStopped:I,runNotice:L,error:ee,scrollRequest:We,cwd:E,lineage:e.lineage,switchingCwd:A,onLoadOlder:B,onBranchFromHere:pe,onCreateChildSession:me,onPromptSelect:ct,onWorkspace:V}),(0,Z.jsxs)(`form`,{className:`focus-composer-shell [.focus-session.has-conversation_&]:w-[min(900px,calc(100%_-_48px))] [.focus-session.has-conversation_&]:pt-[8px] @max-[700px]:w-[calc(100%_-_20px)] @max-[700px]:pb-[10px] @max-[700px]:[.focus-session.has-conversation_&]:w-[calc(100%_-_20px)] max-[650px]:w-[calc(100%_-_20px)] max-[650px]:pb-[10px] flex w-[min(960px,calc(100%_-_48px))] flex-none flex-col gap-[7px] [margin:0_auto] [padding:10px_0_0]`,onSubmit:ut,children:[(0,Z.jsx)(Jo,{sessionId:e.id,cwd:E,streaming:M}),(0,Z.jsx)(qo,{approvals:R,onResolve:de}),M&&b.length>0&&(0,Z.jsx)(zr,{asChild:!0,defaultOpen:!0,children:(0,Z.jsxs)(`div`,{className:`queued-input-tray [&_>_span]:flex-none [&_>_span]:text-[var(--star-strong)] [&_>_span]:font-[600] [&_>_small]:max-w-[240px] [&_>_small]:overflow-hidden [&_>_small]:rounded-[var(--r-pill)] [&_>_small]:bg-[var(--surface-muted)] [&_>_small]:p-[4px_8px] [&_>_small]:text-[var(--text-secondary)] [&_>_small]:text-ellipsis [&_>_small]:whitespace-nowrap [&_>_em]:flex-none [&_>_em]:[font-style:normal] flex min-w-0 items-center gap-[6px] overflow-hidden text-[var(--text-muted)] text-[11px]`,"data-pisper-queue-size":b.length,children:[(0,Z.jsx)(`span`,{children:U(`chat:focusSession.sentToTheRunningAgent`)}),b.slice(-3).map((e,t)=>(0,Z.jsx)(`small`,{title:e.text,children:e.text},e.id||`${e.behavior}-${t}`)),b.length>3&&(0,Z.jsx)(`em`,{children:U(`chat:focusSession.countMore`,{count:b.length-3})})]})}),Me&&(0,Z.jsx)(Wo,{sessionId:e.id}),Qe&&(0,Z.jsxs)(`div`,{className:`composer-resource-chip [&.workflow]:border-[var(--success)] [&.workflow]:bg-[var(--success-soft)] [&_button]:grid [&_button]:w-[20px] [&_button]:h-[20px] [&_button]:place-items-center [&_button]:border-0 [&_button]:rounded-[var(--r-xs)] [&_button]:bg-transparent [&_button]:text-[var(--text-muted)] [&_button]:cursor-pointer [&_button:hover]:bg-[var(--surface-hover)] [&_button:hover]:text-[var(--text)] inline-flex min-h-[28px] self-start items-center gap-[6px] [border:1px_solid_var(--blue)] rounded-[var(--r-sm)] bg-[var(--blue-soft)] text-[var(--text)] [padding:4px_6px_4px_8px] text-[12px] font-[600] ${Qe.kind}`,children:[Qe.kind===`tool`?(0,Z.jsx)(Ae,{size:13}):(0,Z.jsx)(ie,{size:13}),(0,Z.jsxs)(`span`,{children:[Qe.kind===`skill`?`Skill`:Qe.kind===`tool`?U(`chat:resourcePicker.tool`):U(`chat:resourcePicker.workflow`),` `,`· `,Qe.resourceName]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":U(`chat:resourcePicker.remove`),onClick:()=>et(null),children:(0,Z.jsx)(it,{size:13})})]}),(0,Z.jsx)(Qo,{attachments:K.attachments,onRemove:K.removeAttachment}),K.attachmentError&&(0,Z.jsx)(`span`,{className:`text-[var(--danger)] text-[13px]`,children:K.attachmentError}),(0,Z.jsxs)(`div`,{className:`focus-composer-status [.focus-session.has-conversation_&.idle]:hidden [&_>_i]:w-[7px] [&_>_i]:h-[7px] [&_>_i]:flex-none [&_>_i]:rounded-[50%] [&_>_i]:bg-[var(--text-muted)] [&.running]:text-[var(--success-strong)] [&.running_>_i]:bg-[var(--success)] [&.running_>_i]:shadow-[0_0_0_3px_var(--success-soft)] [&.running_>_i]:[animation:star-twinkle_1.1s_ease-in-out_infinite] inline-flex min-h-[22px] self-start items-center gap-[7px] [margin:0_0_-2px_5px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-pill)] bg-[var(--solid)] [padding:3px_9px_3px_7px] text-[var(--text-muted)] text-[11px] font-[600] shadow-[0_8px_18px_-16px_var(--shadow-strong)] ${x?.active?`compacting [.focus-composer-status&]:text-[var(--warning-strong)] [.focus-composer-status&_>_i]:bg-[var(--warning-strong)] [.focus-composer-status&_>_i]:shadow-[0_0_0_3px_var(--warning-soft)] [.focus-composer-status&_>_i]:[animation:star-twinkle_1.1s_ease-in-out_infinite]`:M?`running`:`idle`}`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(`i`,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:x?.active?U(`chat:focusSession.compactingContext`):U(M?`chat:focusSession.running`:`chat:focusSession.waitingForInput`)})]}),(0,Z.jsxs)(`div`,{className:`focus-composer [&:focus-within]:border-[var(--focus)] [&:focus-within]:shadow-[0_0_0_3px_var(--focus-ring)] [&_textarea]:w-full [&_textarea]:min-w-0 [&_textarea]:min-h-[48px] [&_textarea]:max-h-[220px] [&_textarea]:[align-self:start] [&_textarea]:resize-none [&_textarea]:overflow-y-auto [&_textarea]:border-0 [&_textarea]:[outline:0]! [&_textarea]:bg-transparent [&_textarea]:p-[5px_6px_8px] [&_textarea]:text-[var(--text)] [&_textarea]:text-[14px] [&_textarea]:leading-[1.5] [.focus-session.has-conversation_&]:shadow-[0_10px_28px_-24px_var(--shadow-strong)] [.focus-session.has-conversation_&_textarea]:min-h-[50px] [.focus-session.has-conversation_&_textarea]:p-[6px_7px_8px] dark:bg-[var(--solid)] dark:text-[var(--text)] @max-[700px]:grid-cols-[70px_36px_36px_auto_minmax(0,1fr)_36px] @max-[700px]:grid-rows-[minmax(48px,1fr)_36px] relative flex min-w-0 flex-col items-stretch gap-[4px] [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:8px] shadow-[0_14px_34px_-24px_var(--shadow-strong)] [transition:border-color_var(--d1)_var(--ease-out),_box-shadow_var(--d2)_var(--ease-out)]`,children:[(0,Z.jsx)(`textarea`,{ref:nt,rows:1,value:W,onChange:e=>{Ne(e.target.value),e.currentTarget.style.height=`auto`,e.currentTarget.style.height=`${Math.min(e.currentTarget.scrollHeight,220)}px`},onPaste:K.pasteFiles,onKeyDown:e=>{!Te&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},enterKeyHint:Te?`enter`:`send`,placeholder:st}),(0,Z.jsxs)(`div`,{className:`focus-composer-footer @max-[470px]:[.focus-session.has-conversation_&]:flex-nowrap flex min-w-0 items-center gap-[4px] [&[data-mobile-app].tools-open]:flex-wrap ${Xe?`tools-open`:``}`,"data-mobile-app":Te||void 0,children:[!Te&&(0,Z.jsx)(`div`,{className:`focus-composer-leading flex min-w-0 items-center gap-[4px] @max-[700px]:[.focus-composer-footer.tools-open_&]:hidden`,children:ft}),(0,Z.jsxs)(`div`,{className:`focus-composer-runtime flex min-w-0 items-center gap-[4px]`,children:[(0,Z.jsx)(Oi,{value:s,models:D,onChange:re,disabled:M||O}),(0,Z.jsx)(ji,{value:f,onChange:oe,disabled:j})]}),(0,Z.jsxs)(`div`,{className:`focus-composer-quick-actions [.focus-composer-footer.tools-open_&]:flex-1 [.focus-composer-footer[data-mobile-app].tools-open_&]:order-2 [.focus-composer-footer[data-mobile-app].tools-open_&]:basis-full flex min-w-0 items-center gap-[4px]`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`composer-tools-trigger [.focus-composer_&]:h-[38px] [.focus-composer_&]:border-0 [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-composer_&]:bg-[var(--surface-subtle)] [.focus-composer_&]:text-[12px] [.focus-composer_&]:grid [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-composer_&]:place-items-center [.focus-composer_&]:text-[var(--text-muted)] [.focus-composer_&]:cursor-pointer [.focus-composer_&:hover]:bg-[var(--accent-soft)] [.focus-composer_&:hover]:text-[var(--star-strong)] [.focus-composer_&.active]:bg-[var(--accent-soft)] [.focus-composer_&.active]:text-[var(--star-strong)] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] ${Xe?`active`:``}`,title:ot,"aria-label":ot,"aria-expanded":Xe,"aria-controls":at,onClick:()=>Ze(e=>!e),children:Xe?(0,Z.jsx)(Jn,{size:17}):(0,Z.jsx)(Yn,{size:17})}),(0,Z.jsxs)(pi,{open:Xe,label:U(`chat:focusSession.quickActions`),trayId:at,mobile:Te,children:[Te&&ft,(0,Z.jsxs)(`button`,{type:`button`,className:`command-palette-trigger [.focus-composer_&]:h-[38px] [.focus-composer_&]:border-0 [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-composer_&]:bg-[var(--surface-subtle)] [.focus-composer_&]:text-[12px] [.composer-tool-tray_&]:relative [.composer-tool-tray_&]:grid [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:place-items-center [.composer-tool-tray_&]:p-0 [.composer-tool-tray_&]:text-[var(--text-muted)] [.composer-tool-tray_&]:cursor-pointer [.composer-tool-tray_&:hover]:bg-[var(--surface-hover)] [.composer-tool-tray_&:hover]:text-[var(--star-strong)] [.composer-tool-tray_&_kbd]:absolute [.composer-tool-tray_&_kbd]:w-[1px] [.composer-tool-tray_&_kbd]:h-[1px] [.composer-tool-tray_&_kbd]:overflow-hidden [.composer-tool-tray_&_kbd]:[clip:rect(0_0_0_0)] [.composer-tool-tray_&_kbd]:[clip-path:inset(50%)] [.composer-tool-tray_&_kbd]:whitespace-nowrap @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px]`,title:U(`chat:focusSession.openCommandPaletteShortcut`,{shortcut:Xo}),"aria-label":U(`chat:focusSession.openCommandPaletteShortcut`,{shortcut:Xo}),onClick:dt,children:[(0,Z.jsx)(Xn,{size:16}),(0,Z.jsx)(`kbd`,{children:Xo})]}),(0,Z.jsx)(ki,{value:c||`medium`,levels:l||[],status:u,message:d,onChange:ae,disabled:M||k||O}),Oe&&(0,Z.jsx)(Eo,{goal:p,armed:Fe,tokenBudget:q,onTokenBudgetChange:Le,onSaveTokenBudget:e=>ue?.(e),onChange:e=>{!e&&p?.status===`active`?le?.():Ie(e)}}),je&&(0,Z.jsx)(wo,{sessionId:e.id,streaming:M}),(0,Z.jsx)(`button`,{type:`button`,className:`compact-context-trigger [&:hover:not(:disabled)]:border-[var(--accent-border)] [&:hover:not(:disabled)]:bg-[var(--accent-soft)] [&:hover:not(:disabled)]:text-[var(--star-strong)] disabled:[cursor:not-allowed] disabled:opacity-[.5] [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] grid w-[38px] h-[38px] flex-none place-items-center [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-tertiary)] cursor-pointer`,title:M?U(`chat:focusSession.manualCompactionWaitForRun`):Ve||x?.active?U(`chat:focusSession.compactingContext`):U(`chat:focusSession.compactContextNow`),"aria-label":U(`chat:focusSession.compactContextNow`),disabled:!se||M||Ve||!!x?.active||t.length===0,onClick:()=>void lt(),children:Ve||x?.active?(0,Z.jsx)(G,{className:`animate-spin`,size:14}):(0,Z.jsx)(dr,{size:14})}),rt&&(0,Z.jsx)(`div`,{className:`focus-composer-session-actions [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px]`,children:(0,Z.jsx)(Do,{session:e,canSplit:te,streaming:M,switchingCwd:A,onSplitLeft:ge,onSplitRight:_e,onSplitTop:ve,onSplitBottom:ye,onClosePanel:be,onWorkspace:V,onRename:H,onSessionTree:()=>Ye(!0)})})]})]}),(0,Z.jsx)(`div`,{className:`focus-composer-secondary [.focus-session.has-conversation_&]:h-[36px] @max-[700px]:h-[36px] @max-[700px]:gap-[5px] @max-[470px]:[.focus-session.has-conversation_&]:hidden max-[650px]:h-[36px] max-[650px]:gap-[5px] flex min-w-0 h-[38px] flex-1 items-center justify-end gap-[7px]`,children:(0,Z.jsx)(Di,{usage:S,onThresholdChange:ce})}),(0,Z.jsx)(`button`,{type:M?`button`:`submit`,className:`send-button disabled:cursor-not-allowed disabled:opacity-100 [.focus-composer_&]:h-[38px] [.focus-composer_&]:border-0 [.focus-composer_&:disabled]:border-[1px] [.focus-composer_&:disabled]:border-[var(--stroke)] [.focus-composer_&:disabled]:bg-[var(--surface-muted)] [.focus-composer_&:disabled]:text-[var(--text-muted)] [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-composer_&]:text-[12px] [.focus-composer_&]:grid [.focus-composer_&]:w-[42px] [.focus-composer_&]:flex-none [.focus-composer_&]:place-items-center [.focus-composer_&]:bg-[var(--star)] [.focus-composer_&]:text-[var(--on-accent)] [.focus-composer_&]:[transition:var(--d1)_var(--ease-out)] [.focus-composer_&:hover:not(:disabled)]:bg-[var(--star-hover)] [.focus-composer_&:hover:not(:disabled)]:shadow-[var(--sh-star)] [.focus-composer_&:active:not(:disabled)]:[transform:scale(.96)] [.focus-session.has-conversation_.focus-composer_&]:w-[38px] [.focus-session.has-conversation_.focus-composer_&]:h-[38px] dark:text-[var(--on-accent)] @max-[700px]:[.focus-composer_&]:h-[36px] @max-[700px]:[.focus-composer_&]:[align-self:center] @max-[470px]:[.focus-composer_&]:ml-[auto] max-[650px]:[.focus-composer_&]:h-[36px] max-[650px]:[.focus-composer_&]:[align-self:center]${M?` stop [.focus-composer_.send-button&]:bg-[var(--danger)] [.focus-composer_.send-button&]:shadow-[0_7px_16px_-10px_var(--danger)] [.focus-composer_.send-button&:hover:not(:disabled)]:bg-[var(--danger)] [.focus-composer_.send-button&:hover:not(:disabled)]:shadow-[0_0_0_3px_var(--danger-soft)]`:``}`,title:U(M?`chat:focusSession.stop`:`chat:focusSession.sendMessage`),"aria-label":U(M?`chat:focusSession.stop`:`chat:focusSession.sendMessage`),onClick:M?Ce:void 0,disabled:!M&&(ze||!W.trim()&&!K.attachments.length&&!Qe),children:M?(0,Z.jsx)(De,{size:16,fill:`currentColor`}):ze?(0,Z.jsx)(G,{className:`animate-spin`,size:17}):(0,Z.jsx)(fe,{size:18})})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 min-h-[26px] items-center gap-[6px] [margin:0_8px_5px] text-[var(--text-tertiary)]`,children:[rt&&(0,Z.jsxs)(`button`,{type:`button`,className:`composer-workspace-status [&_span]:min-w-0 [&_span]:overflow-hidden [&_span]:text-ellipsis [&_span]:whitespace-nowrap [&:hover:not(:disabled)]:text-[var(--star-strong)] disabled:opacity-[.55] disabled:[cursor:not-allowed] @max-[470px]:w-[24px] @max-[470px]:p-0 @max-[470px]:justify-center @max-[470px]:[&_span]:hidden inline-flex max-w-[180px] min-w-0 h-[24px] flex-none items-center gap-[4px] overflow-hidden border-0 rounded-[0] bg-transparent [padding:2px_0] text-inherit text-[10px] cursor-pointer`,title:E,"aria-label":U(`chat:focusSession.changeWorkingDirectoryWorkspace`,{workspace:$e(E,we)}),onClick:V,disabled:M||A,children:[(0,Z.jsx)(qe,{size:12}),(0,Z.jsx)(`span`,{children:$e(E,we)})]}),(0,Z.jsx)(Ei,{usage:C,plan:ke?m:null})]})]}),(0,Z.jsx)(ni,{open:J,sessionId:e.id,onClose:()=>Ke(!1),onSelect:et,onCommandSelect:e=>ct(ri(e,W))})]})}function Qo({attachments:e,onRemove:t,compact:n=!1}){let{t:r}=g();return e.length?(0,Z.jsx)(`div`,{className:`attachment-tray [&.compact]:max-h-[58px] flex max-h-[116px] flex-wrap gap-[6px] overflow-auto ${n?`compact`:``}`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:`attachment-chip [&_>_img]:w-[30px] [&_>_img]:h-[30px] [&_>_img]:rounded-[var(--r-xs)] [&_>_img]:object-cover [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_>_button]:grid [&_>_button]:w-[32px] [&_>_button]:h-[32px] [&_>_button]:place-items-center [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-xs)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text-muted)] [&_>_button:hover]:bg-[var(--danger-soft)] [&_>_button:hover]:text-[var(--danger)] dark:bg-[var(--surface-subtle)] grid min-w-[150px] max-w-[250px] grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-[7px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:5px]`,children:[e.kind===`image`?(0,Z.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``}):(0,Z.jsx)(`span`,{className:`grid w-[30px] h-[30px] place-items-center rounded-[var(--r-xs)] bg-[var(--violet-soft)] text-[var(--violet-strong)]`,children:(0,Z.jsx)(ye,{size:13})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:e.name}),(0,Z.jsxs)(`small`,{children:[e.kind===`path`?r(`chat:focusSession.localPath`):e.kind===`image`?r(`chat:focusSession.image`):e.kind===`document`?r(`chat:focusSession.document`):r(`chat:focusSession.text`),e.kind===`path`?``:` · ${Qe(e.size)}`,e.truncated?` · ${r(`chat:focusSession.truncated`)}`:``]})]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":r(`chat:focusSession.removeName`,{name:e.name}),onClick:()=>t(String(e.id||``)),children:(0,Z.jsx)(it,{size:12})})]},e.id))}):null}var $o=(0,X.createContext)(null),es=40;function ts({params:e,api:t}){let n=(0,X.useContext)($o),r=e?.sessionId||st(t?.id),[i,a]=(0,X.useState)(()=>t.isVisible),o=n?.sessions.find(e=>e.id===r),s=n?.sessionStates[r],c=s||Or,l=!!(c.streaming||o?.streaming),u=Ir(s,o),d=Lr(u,{streaming:l})?u:null,f=n?.sessionTreePulseSessionId===r?n.sessionTreePulseToken:0,p=n?.loadSessionMessages,m=n?.loadSessionThinkingLevel,h=(0,X.useRef)(``);if((0,X.useEffect)(()=>{a(t.isVisible);let e=t.onDidVisibilityChange(({isVisible:e})=>a(e));return()=>e.dispose()},[t]),(0,X.useEffect)(()=>{i&&r&&p?.(r,{limit:es})},[p,r,i]),(0,X.useEffect)(()=>{!i||!r||!o||!m||l||c.thinkingStatus||(c.availableThinkingLevels||[]).length||h.current!==r&&(h.current=r,m(r))},[m,o,r,c.availableThinkingLevels,c.thinkingStatus,l,i]),!i)return null;if(!n||!o)return(0,Z.jsxs)(`div`,{className:`session-dock-missing flex h-full min-h-[180px] items-center justify-center gap-[8px] text-[var(--text-muted)] text-[12px]`,children:[(0,Z.jsx)(Xe,{size:16}),n?`Session unavailable`:`Loading session`]});let g=n.pendingAsset?.asset&&(!n.pendingAsset.targetSessionId||n.pendingAsset.targetSessionId===r)?n.pendingAsset.asset:null;return(0,Z.jsx)(`div`,{className:`session-dock-panel w-full h-full min-w-0 min-h-0 overflow-hidden [container-type:inline-size] bg-[var(--panel)]`,onFocusCapture:()=>t.setActive(),children:(0,Z.jsx)(Zo,{session:o,messages:c.messages||[],transcriptLoadState:c.loaded?`ready`:c.loading||!c.error?`loading`:`error`,messageStart:c.messageStart,hasOlder:c.hasOlder,loadingOlder:c.loadingOlder,olderError:c.olderError,model:c.model||o.model||n.defaultModel,thinkingLevel:c.thinkingLevel||o.thinkingLevel||`medium`,availableThinkingLevels:c.availableThinkingLevels||[],thinkingStatus:c.thinkingStatus||``,thinkingMessage:c.thinkingMessage||``,executionMode:c.executionMode||o.executionMode||`approval-required`,goal:c.goal??o.goal??null,plan:d,currentActivity:c.currentActivity,activityFeed:c.activityFeed||[],tools:c.tools||[],thinkingText:c.thinkingText||``,queuedInputs:c.queuedInputs||[],compaction:c.compaction,contextUsage:c.contextUsage,sessionUsage:c.sessionUsage,sessionTreeRevision:c.sessionTreeRevision,sessionTreePulse:f,cwd:c.cwd||o.cwd,availableModels:n.availableModels,switchingModel:c.switchingModel,switchingThinking:c.switchingThinking,switchingCwd:c.switchingCwd,switchingPermission:c.switchingPermission,streaming:l,runStartedAt:c.runStartedAt,lastActivityAt:c.lastActivityAt,runFinishedAt:c.runFinishedAt,runStopped:c.runStopped,runNotice:c.runNotice,approvals:c.approvals||[],error:c.error||(n.activeId===r?n.globalError:``),pendingAsset:g,onAssetConsumed:n.onAssetConsumed,onLoadOlder:()=>n.loadOlderMessages(r),onModelChange:e=>n.switchSessionModel(r,e),onThinkingLevelChange:e=>n.switchSessionThinkingLevel(r,e),onExecutionModeChange:e=>n.switchSessionExecutionMode(r,e),onGoalPause:()=>n.pauseGoal(r),onGoalBudgetChange:e=>n.setGoalBudget(r,e),onCompact:()=>n.compactSession(r),onCompactionThresholdChange:n.setCompactionThreshold,onApproval:(e,t)=>n.resolveToolApproval(r,e,t),onWorkspace:()=>void n.selectSessionWorkspace(o),onRename:()=>n.renameSession(o),onBranchFromHere:e=>n.branchFromEntry(o,e),onCreateChildSession:e=>n.createChildSession(o,e),onTreeNavigated:()=>n.reloadSessionBranch(r),onSplitLeft:()=>n.splitDockPanel(t.id,`left`),onSplitRight:()=>n.splitDockPanel(t.id,`right`),onSplitTop:()=>n.splitDockPanel(t.id,`above`),onSplitBottom:()=>n.splitDockPanel(t.id,`below`),onClosePanel:()=>n.closeDockPanel(t.id),canSplit:!n.compactDock&&t.group.size>1,onSend:(e,t,i,a,o)=>n.sendPrompt(e,r,t,i,a,o),onQueue:(e,t,i)=>n.queuePrompt(e,r,t,i),onAbort:()=>n.abort(r)})})}function ns(){let{t:e}=g();return(0,Z.jsxs)(`div`,{className:`chat-dock-watermark flex h-full min-h-[180px] items-center justify-center gap-[8px] text-[var(--text-muted)] text-[12px] [&_strong]:text-[var(--text)] [&_strong]:text-[14px] [&_span]:max-w-[320px] [&_span]:leading-[1.55] flex-col text-center`,children:[(0,Z.jsx)(Ge,{size:34}),(0,Z.jsx)(`strong`,{children:e(`chat:chatDock.openAChatToBegin`)}),(0,Z.jsx)(`span`,{children:e(`chat:chatDock.openAChatFromTheSessionListOrSplitItInAnyDirection`)})]})}var rs=(0,X.createContext)(null),is=()=>{let e=(0,X.useContext)(rs);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},as=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,X.useState)(n),[s,c]=(0,X.useState)(!1),l=(0,X.useCallback)(e=>{o(e),r?.(e)},[r]),u=(0,X.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:l,url:a}),[s,l,a]);return(0,Z.jsx)(rs.Provider,{value:u,children:(0,Z.jsx)(`div`,{className:V(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},os=({className:e,children:t,...n})=>(0,Z.jsx)(`div`,{className:V(`flex shrink-0 items-center gap-1 border-b p-2`,e),...n,children:t}),ss=({onClick:e,disabled:t,tooltip:n,children:r,...i})=>(0,Z.jsx)(Ie,{children:(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(Ve,{asChild:!0,children:(0,Z.jsx)(l,{className:`size-8 p-0 hover:text-foreground`,disabled:t,onClick:e,size:`sm`,variant:`ghost`,...i,children:r})}),(0,Z.jsx)(et,{children:(0,Z.jsx)(`p`,{children:n})})]})}),cs=({value:e,onChange:t,onKeyDown:n,...r})=>{let{url:i,setUrl:a}=is(),[o,s]=(0,X.useState)(i),[c,l]=(0,X.useState)(i);i!==o&&(s(i),l(i));let u=e=>{l(e.target.value),t?.(e)},d=(0,X.useCallback)(e=>{e.key===`Enter`&&a(e.target.value),n?.(e)},[n,a]);return(0,Z.jsx)(W,{className:`h-8 flex-1 text-sm`,onChange:t??u,onKeyDown:d,placeholder:`Enter URL...`,value:e??c,...r})},ls=({className:e,loading:t,src:n,...r})=>{let{url:i}=is();return(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,Z.jsx)(`iframe`,{className:V(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})},us=`web-preview`;function ds(e,t=`Web preview`){try{return new URL(e).hostname.replace(/^www\./i,``)||t}catch{return t}}var fs=(0,X.lazy)(()=>i(()=>import(`./Threads-DskDSsK6.js`).then(e=>({default:e.Threads})),__vite__mapDeps([11,2,1,3,4,7])));function ps(e){return e?{entries:[e],index:0}:{entries:[],index:-1}}function ms({params:e,api:t}){let{t:n}=g(),r=_t(e?.url||``,window.location.href)||``,[i,a]=(0,X.useState)(()=>t.isVisible),[o,s]=(0,X.useState)(()=>ps(r)),[c,l]=(0,X.useState)(0),[u,d]=(0,X.useState)(!!r),f=o.index>=0&&o.entries[o.index]||``;(0,X.useEffect)(()=>{a(t.isVisible);let e=t.onDidVisibilityChange(({isVisible:e})=>a(e));return()=>e.dispose()},[t]),(0,X.useEffect)(()=>{!r||r===f||(s(ps(r)),l(0),d(!0))},[f,r]),(0,X.useEffect)(()=>{t.setTitle(ds(f,n(`common:webPreview.title`)))},[t,f,n]);let p=(0,X.useCallback)(e=>{let n=_t(e,f||window.location.href);!n||n===f||(s(e=>({entries:[...e.entries.slice(0,e.index+1),n],index:e.index+1})),t.updateParameters({url:n}),l(0),d(!0))},[t,f]),m=(0,X.useCallback)(e=>{let n=o.index+e;if(n<0||n>=o.entries.length)return;let r=o.entries[n];s(e=>({...e,index:n})),t.updateParameters({url:r}),d(!0)},[t,o]),h=(0,X.useCallback)(()=>{l(e=>e+1),d(!0)},[]),_=(0,X.useCallback)(()=>{f&&window.open(f,`_blank`,`noopener,noreferrer`)},[f]);return i?f?(0,Z.jsx)(`div`,{className:`web-preview-panel [&_>_div]:rounded-[0] w-full h-full min-w-0 min-h-0 overflow-hidden bg-[var(--panel)]`,onFocusCapture:()=>t.setActive(),children:(0,Z.jsxs)(as,{className:`rounded-none border-0`,defaultUrl:f,onUrlChange:p,children:[(0,Z.jsxs)(os,{children:[(0,Z.jsx)(ss,{"aria-label":n(`common:webPreview.back`),disabled:o.index<=0,onClick:()=>m(-1),tooltip:n(`common:webPreview.back`),children:(0,Z.jsx)(Le,{})}),(0,Z.jsx)(ss,{"aria-label":n(`common:webPreview.forward`),disabled:o.index>=o.entries.length-1,onClick:()=>m(1),tooltip:n(`common:webPreview.forward`),children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(ss,{"aria-label":n(`common:webPreview.reload`),onClick:h,tooltip:n(`common:webPreview.reload`),children:(0,Z.jsx)(G,{})}),(0,Z.jsxs)(`div`,{className:`web-preview-address [&_>_svg]:w-[14px] [&_>_svg]:h-[14px] [&_>_svg]:flex-none [&_>_svg]:text-[var(--text-muted)] flex min-w-0 flex-1 items-center gap-[7px] [margin:0_3px]`,children:[(0,Z.jsx)(ve,{"aria-hidden":`true`}),(0,Z.jsx)(cs,{"aria-label":n(`common:webPreview.url`),placeholder:n(`common:webPreview.urlPlaceholder`)})]}),(0,Z.jsx)(ss,{"aria-label":n(`common:webPreview.openExternal`),onClick:_,tooltip:n(`common:webPreview.openExternal`),children:(0,Z.jsx)(Pe,{})})]}),(0,Z.jsx)(ls,{onLoad:()=>d(!1),src:f,title:n(`common:webPreview.title`),loading:u?(0,Z.jsxs)(`div`,{className:`absolute inset-0 grid place-items-center overflow-hidden bg-[color-mix(in_srgb,var(--panel)_86%,transparent)] text-[var(--text-muted)] text-[12px] [backdrop-filter:blur(3px)]`,children:[(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(fs,{})}),(0,Z.jsxs)(`span`,{className:`relative z-[1] flex items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-pill)] bg-[color-mix(in_srgb,var(--panel)_82%,transparent)] [padding:7px_11px] shadow-[var(--sh-1)]`,children:[(0,Z.jsx)(be,{className:`animate-spin`,size:18}),(0,Z.jsx)(`span`,{children:n(`common:webPreview.loading`)})]})]}):null},`${f}:${c}`),(0,Z.jsx)(`div`,{className:`flex-none [border-top:1px_solid_var(--stroke-soft)] bg-[var(--surface-subtle)] [padding:5px_10px] text-[var(--text-muted)] text-[10px] leading-[1.4]`,children:n(`common:webPreview.embedNotice`)})]},`${o.index}:${f}`)}):(0,Z.jsxs)(`div`,{className:`web-preview-panel [&_>_div]:rounded-[0] w-full h-full min-w-0 min-h-0 overflow-hidden bg-[var(--panel)] web-preview-empty [&_strong]:text-[var(--text)] [&_strong]:text-[13px] flex flex-col items-center justify-center gap-[8px] text-[var(--text-muted)]`,onFocusCapture:()=>t.setActive(),children:[(0,Z.jsx)(ve,{size:24}),(0,Z.jsx)(`strong`,{children:n(`common:webPreview.title`)})]}):null}function hs(e,t){let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return[...t,...r]}function gs(e){for(let t of e){let e=typeof t.cwd==`string`?t.cwd.trim():``;if(e)return e}return``}function _s({notify:e}){let{t}=g(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(()=>localStorage.getItem(s.activeSession)||``),[o,c]=(0,X.useState)({}),[l,u]=(0,X.useState)(!0),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(()=>t(`chat:chatPage.waitingForConfiguration`)),[h,_]=(0,X.useState)([]),v=(0,X.useRef)(n),y=(0,X.useRef)(o),b=(0,X.useRef)(null),x=(0,X.useCallback)(e=>{let t=v.current,n=typeof e==`function`?e(t):e;return v.current=n,r(n),n},[]),S=(0,X.useCallback)(e=>{y.current=e,c(e)},[]),C=(0,X.useCallback)((e,t)=>{if(!e)return;let n=y.current,r=n[e]||Or,i=Ar(r,t);i!==r&&S({...n,[e]:i})},[S]),w=(0,X.useCallback)((e,{panelOpen:t=!1,localStreamOwned:n=!1}={})=>{if(!e||t||n)return!1;let r=y.current,i=r[e];if(!i||Nr(i))return!1;let a={...r};return delete a[e],S(a),!0},[S]),T=(0,X.useCallback)(async e=>{let t=await J.listSessions();return x(t.sessions),a(e||(e=>t.sessions.some(t=>t.id===e)?e:t.sessions[0]?.id||``)),je(),t.sessions},[x]),E=(0,X.useCallback)((n=``)=>{if(b.current)return b.current;let r=(async()=>{try{f(``);let r=await J.createSession(t(`chat:chatPage.newChat`),n||gs(v.current));a(r.id),x(e=>hs(e,[r])),C(r.id,{messages:[],tools:[],approvals:[],queuedInputs:[],permissionMode:r.permissionMode||`ask`,executionMode:r.executionMode||`approval-required`,goal:r.goal||null,plan:Sr(r,null),contextUsage:r.contextUsage||null,sessionUsage:r.sessionUsage||null,compaction:null,streaming:!1,error:``,loaded:!0,pageSize:40,messageStart:0,hasOlder:!1,olderCursor:null,runStartedAt:null,lastActivityAt:null,runFinishedAt:null,runStopped:!1,runNotice:``});try{await T(r.id)}catch(e){f(t(`chat:chatPage.theChatWasCreatedButTheListCouldNotBeRefreshedError`,{error:$(e)}))}return e(t(`chat:chatPage.newChatCreated`)),r.id}catch(e){return f($(e)),``}})();return b.current=r,r.finally(()=>{b.current===r&&(b.current=null)}),r},[e,T,t,C,x]);(0,X.useEffect)(()=>{let e=!0;return Promise.all([J.listSessions(),J.getConfig()]).then(async([n,r])=>{if(!e)return;m(r.model?`${r.provider}/${r.model}`:t(`chat:chatPage.noModelConfigured`)),_(r.providers.flatMap(e=>e.configured&&e.enabled?e.models.filter(e=>e.kind===`chat`).map(t=>({key:`${e.id}/${t.id}`,provider:e.id,modelId:t.id,label:t.name||t.id,providerName:e.name||e.id})):[]));let i=n.sessions;if(!i.length&&(b.current||Object.keys(y.current).length)){if(await b.current,!e)return;i=(await J.listSessions()).sessions}if(i.length||(i=[await J.createSession(t(`chat:chatPage.newChat`))]),!e)return;x(e=>hs(e,i)),je();for(let e of i)C(e.id,{agents:e.agents||[],plan:Sr(e,null),...e.streaming?{streaming:!0,recovering:!0,loaded:!1,error:``}:{}});let o=localStorage.getItem(s.activeSession),c=new Set([...i.map(e=>e.id),...Object.keys(y.current)]);a(e=>c.has(e)?e:o&&c.has(o)?o:i[0]?.id||``)}).catch(t=>e&&f($(t))).finally(()=>e&&u(!1)),()=>{e=!1}},[t,C,x]),(0,X.useEffect)(()=>{i&&localStorage.setItem(s.activeSession,i)},[i]);let D=n.find(e=>e.id===i),O=(o[i]||Or).model||D?.model||``;return(0,X.useEffect)(()=>{Je(i,O)},[i,O]),(0,X.useEffect)(()=>(document.title=D?.name?`${D.name} · ${Lt}`:Lt,()=>{document.title=Lt}),[D?.name]),{sessions:n,sessionsRef:v,activeId:i,setActiveId:a,sessionStates:o,sessionStatesRef:y,loading:l,globalError:d,setGlobalError:f,defaultModel:p,availableModels:h,updateSessions:x,replaceSessionStates:S,updateSessionState:C,releaseSessionState:w,refreshSessions:T,createSessionRecord:E}}function vs({sessions:e,sessionsRef:t,sessionStates:n,activeId:r,setActiveId:i,loading:a,localStreamSessionsRef:o,loadSessionMessages:c,releaseSessionState:l,notify:u}){let{t:d}=g(),[f,p]=(0,X.useState)(0),[m,h]=(0,X.useState)(()=>window.matchMedia(`(max-width: 900px)`).matches),_=(0,X.useRef)(null),v=(0,X.useRef)(!1),y=(0,X.useRef)([]),b=(0,X.useRef)(void 0),x=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(m),T=(0,X.useRef)(null),E=(0,X.useRef)(!1),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=!0;return Fe(`/api/settings/chat-dock-layout`).then(t=>{e&&(O(At(t)),A(!0))}).catch(()=>{e&&A(!0)}),()=>{e=!1}},[]),(0,X.useEffect)(()=>{let e=window.matchMedia(`(max-width: 900px)`),t=()=>{w.current=e.matches,h(e.matches)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let j=(0,X.useCallback)(()=>{E.current||(E.current=!0,(async()=>{do{for(;T.current;){let e=T.current;T.current=null;try{await Fe(`/api/settings/chat-dock-layout`,{method:`PUT`,body:e})}catch{}}E.current=!1,T.current&&(E.current=!0)}while(E.current)})())},[]),M=(0,X.useCallback)(e=>{T.current=e,j()},[j]),N=(0,X.useCallback)((e=_.current)=>{if(!v.current)return!1;window.clearTimeout(b.current),b.current=void 0;let t=x.current;if(e)try{let n=bt(e.toJSON(),e.activePanel?.id||``);t=JSON.stringify(n)}catch{}return t?(M(t),x.current=null,!0):!1},[M]),P=(0,X.useCallback)((e=_.current)=>{if(!e||!v.current)return;let t;try{t=JSON.stringify(bt(e.toJSON(),e.activePanel?.id||``))}catch{return}x.current=t,window.clearTimeout(b.current),b.current=window.setTimeout(()=>{b.current=void 0,!(!v.current||_.current!==e)&&(M(t),x.current===t&&(x.current=null))},180)},[M]),F=(0,X.useCallback)((e,n=`open`)=>{let r=t.current.find(t=>t.id===e),a=_.current;if(!r||!a||!v.current)return S.current={sessionId:e,disposition:n},!1;let o=w.current?`open`:n,s=ht(e),l=a.getPanel(s),u=a.activePanel;if(l)return o!==`open`&&(u&&l.id!==u.id?l.api.moveTo({group:u.group,position:Et(o)}):l.group.size>1&&l.api.moveTo({group:l.group,position:Et(o)})),l.api.setActive(),i(e),!0;let f=o===`open`?a.activeGroup?{referenceGroup:a.activeGroup}:void 0:u?{referencePanel:u,direction:o}:{direction:o};return a.addPanel({id:s,component:`session`,title:r.name||d(`chat:chatPage.untitledChat`),params:{sessionId:e},renderer:`always`,minimumWidth:300,minimumHeight:240,...f?{position:f}:{}}),i(e),c(e,{limit:40}),!0},[c,t,i,d]),I=(0,X.useCallback)(e=>{let t=_.current;if(!t||!v.current)return C.current=e,!1;let n=t.getPanel(us),r=ds(e.url,d(`common:webPreview.title`));if(n)return n.api.updateParameters({url:e.url}),n.api.setTitle(r),n.api.setActive(),!0;let i=t.activePanel,a=w.current?t.activeGroup?{referenceGroup:t.activeGroup}:void 0:i?{referencePanel:i,direction:`right`}:{direction:`right`};return t.addPanel({id:us,component:`webPreview`,title:r,params:{url:e.url},renderer:`always`,minimumWidth:360,...a?{position:a}:{}}),!0},[d]),L=(0,X.useCallback)((e,t)=>{let n=_.current?.getPanel(e);if(n){if(w.current){u(d(`chat:chatPage.onNarrowScreensChatsStayInASingleTabGroup`),`info`);return}if(n.group.size<=1){u(d(`chat:chatPage.thisGroupHasOnlyOneChatChooseAnotherChatFromTheSessionListToCreateASplit`),`info`);return}n.api.moveTo({group:n.group,position:Et(t)}),n.api.setActive()}},[u,d]),R=(0,X.useCallback)(e=>{_.current?.getPanel(e)?.api.close()},[]),ee=(0,X.useCallback)((e,t)=>{if(!t)return;let n=_.current?.getPanel(ht(e));n&&n.group!==t&&n.api.moveTo({group:t})},[]),z=(0,X.useCallback)(e=>l(e,{panelOpen:!!_.current?.getPanel(ht(e)),localStreamOwned:o.current.has(e)}),[o,l]),te=(0,X.useCallback)(({api:e})=>{_.current&&_.current!==e&&(v.current=!1);for(let e of y.current)e.dispose();y.current=[],_.current=e,y.current.push(e.onDidActivePanelChange(({panel:t})=>{let n=st(t);n&&i(n),P(e)}),e.onDidLayoutChange(()=>P(e)),e.onDidAddPanel(e=>{let t=st(e);t&&c(t,{limit:40})}),e.onDidRemovePanel(e=>{let t=st(e);t&&queueMicrotask(()=>z(t))})),p(e=>e+1)},[c,z,P,i]);return(0,X.useEffect)(()=>{if(v.current)for(let e of Object.keys(n))z(e)},[z,n]),(0,X.useEffect)(()=>{let e=e=>{let t=e.detail,n=t?.sessionId||t?.id;n&&(localStorage.removeItem(s.sessionOpenRequest),F(n,t?.disposition||`open`),t?.targetEntryId&&c(n,{force:!0,limit:40}))};return window.addEventListener(nt,e),()=>window.removeEventListener(nt,e)},[c,F]),(0,X.useEffect)(()=>{let e=e=>{let t=e.detail;t?.url&&(localStorage.removeItem(s.webPreviewRequest),I(t))};return window.addEventListener(lt,e),()=>window.removeEventListener(lt,e)},[I]),(0,X.useEffect)(()=>{let e=()=>{document.visibilityState===`hidden`&&N()},t=()=>N();return document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t)}},[N]),(0,X.useEffect)(()=>()=>{let e=_.current;N(e),v.current=!1,window.clearTimeout(b.current),b.current=void 0;for(let e of y.current)e.dispose();y.current=[],_.current=null},[N]),(0,X.useEffect)(()=>{if(!f||!k||a||v.current||!_.current)return;let t=_.current,n=new Set(e.map(e=>e.id)),i=D;if(i)try{t.fromJSON(i.layout);for(let e of[...t.panels]){if(e.api.component!==`session`)continue;let r=st(e);n.has(r)||t.removePanel(e)}}catch{t.clear()}if(!t.panels.length){let n=at({activeSessionId:r,validSessionIds:e.map(e=>e.id)}),i;for(let r of n){let n=e.find(e=>e.id===r);if(!n)continue;let a=t.addPanel({id:ht(r),component:`session`,title:n.name||d(`chat:chatPage.untitledChat`),params:{sessionId:r},renderer:`always`,minimumWidth:300,...i?{position:{referenceGroup:i}}:{},inactive:!!i});i||=a.group}}for(let n of t.panels){let t=e.find(e=>e.id===st(n));t&&n.api.setTitle(t.name||d(`chat:chatPage.untitledChat`))}v.current=!0,localStorage.removeItem(s.chatMode);let o=S.current||yt();S.current=null,o?(F(o.sessionId,o.disposition),o.targetEntryId&&c(o.sessionId,{force:!0,limit:40})):(t.getPanel(i?.activePanelId||ht(r))||t.panels[0])?.api.setActive();let l=C.current||xt();C.current=null,l&&I(l),P(t)},[r,k,f,c,a,F,I,P,e,D,d]),(0,X.useEffect)(()=>{if(!(!v.current||!_.current))for(let t of e)_.current.getPanel(ht(t.id))?.api.setTitle(t.name||d(`chat:chatPage.untitledChat`))},[e,d]),{compactDock:m,openSessionInDock:F,splitDockPanel:L,closeDockPanel:R,moveSessionToGroup:ee,onDockReady:te,getTabContextMenuItems:(0,X.useCallback)(({panel:e})=>{let t={label:d(`chat:focusSession.closeTab`),action:()=>R(e.id)};return m||e.group.size<=1?[t]:[{label:d(`chat:chatPage.splitToLeft`),action:()=>L(e.id,`left`)},{label:d(`chat:chatPage.splitToRight`),action:()=>L(e.id,`right`)},{label:d(`chat:chatPage.splitToTop`),action:()=>L(e.id,`above`)},{label:d(`chat:chatPage.splitToBottom`),action:()=>L(e.id,`below`)},`separator`,t]},[R,m,L,d])}}function ys(e){return!!e?.agents?.some(e=>[`queued`,`starting`,`running`].includes(String(e.status)))}function bs(e,{localStreamOwned:t=!1}={}){return!e||t?!1:!!(e.recovering||e.streaming||e.approvals?.length||ys(e))}function xs(e,t){let n=Number(t.pageInfo?.start)||0,r=Number.isInteger(e.messageStart)?e.messageStart:null,i=r!=null&&r<=n,a=i?Math.max(0,n-r):0,o=i?r:n,s=i?[...e.messages.slice(0,a),...t.messages]:t.messages,c=Math.max(0,s.length-200);return c&&(s=s.slice(c),o+=c),{messages:s,messageStart:o,hasOlder:o>0,olderCursor:o>0?String(o):null}}function Ss(e,t,n=new Date().toISOString()){let r=t.finishedAt||e.runFinishedAt||n;return{...e,...xs(e,t),tools:t.streaming?t.tools||[]:Vi(t.tools||[],{finishedAt:r,error:t.error||``}),streaming:t.streaming,recovering:t.streaming,runStartedAt:t.startedAt||e.runStartedAt||null,lastActivityAt:t.lastActivityAt||e.lastActivityAt||t.startedAt||null,runFinishedAt:t.streaming?null:r,runNotice:t.streaming&&e.runNotice||``,loaded:!0,loading:!1,error:t.error||``,model:t.model||e.model,cwd:t.cwd||e.cwd,permissionMode:t.permissionMode||e.permissionMode,executionMode:t.executionMode||e.executionMode,goal:t.goal??e.goal??null,plan:Sr(t,e.plan??null),contextUsage:t.contextUsage??e.contextUsage??null,sessionUsage:t.sessionUsage??e.sessionUsage??null,compaction:t.compaction??e.compaction??null,approvals:t.approvals||[],agents:t.agents||[],currentActivity:t.streaming?t.currentActivity||e.currentActivity||null:t.currentActivity?.type===`agent`?t.currentActivity:null,lifecycle:t.lifecycle??e.lifecycle??null,sessionTreeRevision:Number(t.sessionTreeRevision??e.sessionTreeRevision??0),activityFeed:t.streaming?t.activityFeed||e.activityFeed||[]:(t.activityFeed||[]).filter(e=>e.type===`agent`),thinkingText:t.streaming?t.thinkingText??e.thinkingText??``:``,queuedInputs:jr(e.queuedInputs,t.queuedInputs),hadQueuedInput:t.streaming?!!(e.hadQueuedInput||t.queuedInputs?.length):!1}}function Cs({sessionStates:e,sessionStatesRef:t,localStreamSessionsRef:n,updateSessionState:r,updateSessions:i}){let a=(0,X.useRef)(new Set),o=(0,X.useRef)({timer:null,activeSessions:new Set}),s=(0,X.useCallback)(async e=>{if(!(!e||n.current.has(e)||a.current.has(e))){a.current.add(e);try{let t=await J.getLiveSession(e);if(n.current.has(e))return;r(e,e=>Ss(e,t)),i(n=>n.map(n=>n.id===e?{...n,streaming:t.streaming,model:t.model||n.model,cwd:t.cwd||n.cwd,permissionMode:t.permissionMode||n.permissionMode,executionMode:t.executionMode||n.executionMode,goal:t.goal??n.goal??null,plan:Sr(t,n.plan??null)}:n))}catch(t){n.current.has(e)||r(e,{recovering:!1,loading:!1,error:$(t)})}finally{a.current.delete(e)}}},[n,r,i]),c=(0,X.useCallback)(async(e,{force:n=!1,limit:a=40}={})=>{if(!e)return;let o=t.current[e];if(o?.recovering){await s(e);return}if(!(!n&&(o?.loading||o?.streaming||o?.loaded&&(o.pageSize||0)>=a))){r(e,{loading:!0});try{let n=await J.getMessages(e,{limit:a});r(e,e=>e.streaming?{...e,loaded:!0,loading:!1,pageSize:Math.max(e.pageSize||0,a)}:{...e,...xs(e,n),model:e.model||n.model||void 0,contextUsage:n.contextUsage??e.contextUsage??null,sessionUsage:n.sessionUsage??e.sessionUsage??null,loaded:!0,loading:!1,pageSize:Math.max(e.pageSize||0,a),error:``,olderError:``});let o=t.current[e]?.model||(typeof n.model==`string`?n.model:``);o&&i(t=>t.map(t=>t.id===e&&t.model!==o?{...t,model:o}:t))}catch(t){r(e,{loading:!1,error:$(t)})}}},[t,s,r,i]),l=(0,X.useCallback)(async e=>{let n=t.current[e];if(!e||!n?.hasOlder||!n.olderCursor||n.loadingOlder)return!1;r(e,{loadingOlder:!0,olderError:``});try{let t=await J.getMessages(e,{limit:40,before:n.olderCursor});return r(e,e=>{let n=new Set(e.messages.map(e=>e.id)),r=[...t.messages.filter(e=>!n.has(e.id)),...e.messages],i=Math.max(0,r.length-200);return{...e,messages:i?r.slice(i):r,messageStart:t.pageInfo.start+i,hasOlder:t.pageInfo.hasMore,olderCursor:t.pageInfo.nextCursor,loadingOlder:!1,olderError:``}}),t.messages.length>0}catch(t){return r(e,{loadingOlder:!1,olderError:$(t)}),!1}},[t,r]),u=(0,X.useCallback)(()=>{o.current.timer&&window.clearInterval(o.current.timer),o.current.timer=null,o.current.activeSessions.clear()},[]),d=(0,X.useCallback)(()=>{o.current.timer||!o.current.activeSessions.size||(o.current.timer=window.setInterval(()=>{let e=Array.from(o.current.activeSessions).map(async e=>{let r=t.current[e];if(!bs(r,{localStreamOwned:n.current.has(e)})){o.current.activeSessions.delete(e);return}await s(e)});Promise.allSettled(e).then(()=>{o.current.activeSessions.size||u()})},2e3))},[n,t,u,s]);return(0,X.useEffect)(()=>{let t=new Set(Object.keys(e));for(let e of o.current.activeSessions)t.has(e)||o.current.activeSessions.delete(e);for(let[t,r]of Object.entries(e))bs(r,{localStreamOwned:n.current.has(t)})?o.current.activeSessions.add(t):o.current.activeSessions.delete(t);o.current.activeSessions.size?d():u()},[d,n,e,u]),(0,X.useEffect)(()=>u,[u]),{syncLiveSession:s,loadSessionMessages:c,loadOlderMessages:l,liveSyncInFlightRef:a}}function ws(e,t){let n=null,r=!1,i=typeof document<`u`,a=()=>!i||document.visibilityState===`visible`,o=()=>{r&&=(document.removeEventListener(`visibilitychange`,c),!1)},s=()=>{n=setTimeout(()=>{n=null,e()},t)},c=()=>{!a()||n!=null||(o(),s())},l=()=>{!i||r||(document.addEventListener(`visibilitychange`,c),r=!0)};return{schedule(){n!=null||r||(a()?s():l())},flushNow(){n!=null&&(clearTimeout(n),n=null),o(),e()},cancel(){n!=null&&clearTimeout(n),n=null,o()},get active(){return n!=null||r}}}function Ts(e,{intervalMs:t=48}={}){let n=null,r=null,i=ws(()=>{if(n==null)return;let t=n,i=r;n=null,r=null,e(t,i)},t);return{push(e,t=new Date().toISOString()){n=e,r=t,i.schedule()},flush(){i.flushNow()},cancel(){i.cancel(),n=null,r=null}}}function Es(e,{intervalMs:t=80}={}){let n=new Map,r=null,i=ws(()=>{if(!n.size)return;let t=n,i=r;n=new Map,r=null,e(t,i)},t);return{push(e,t,a=new Date().toISOString()){e&&(n.set(e,{...n.get(e)||{},...t}),r=a,i.schedule())},flush(){i.flushNow()},cancel(){i.cancel(),n=new Map,r=null}}}function Ds(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r+=1;return r}function Os(e,{minCharsPerSecond:t=36,maxCharsPerSecond:n=1200,catchUpRemaining:r=160,snapRemaining:i=480,requestFrame:a,cancelFrame:o,now:s=()=>typeof performance<`u`&&performance.now?performance.now():Date.now()}={}){let c=a||(e=>setTimeout(()=>e(s()),16)),l=o||clearTimeout,u=typeof document<`u`,d=()=>!u||document.visibilityState===`visible`,f=``,p=``,m=null,h=0,g=0,_=!1,v=()=>e(p,m),y=(e,a)=>{if(e<=0)return 0;if(e>=i)return e;if(e>=r)return Math.min(e,Math.max(12,Math.ceil(e*Math.min(1,a*10))));let o=Math.min(n,t+e*4);return Math.min(e,Math.max(1,Math.ceil(o*a)))},b=e=>{if(h=0,_)return;let t=g?Math.min(.08,Math.max(.012,(e-g)/1e3)):.032;g=e;let n=p;if(f!==p){if(!f.startsWith(p)){let e=Ds(p,f);p=f.slice(0,e)}if(f.length<p.length)p=f;else{let e=f.length-p.length;e>0&&(p=f.slice(0,p.length+y(e,t)))}p!==n&&v(),!_&&p!==f&&(h=c(b))}},x=()=>{_||h||!d()||(g=0,h=c(b))},S=()=>{d()?x():h&&(l(h),h=0,g=0)};return u&&document.addEventListener(`visibilitychange`,S),{setTarget(e,t=new Date().toISOString()){_||(f=String(e||``),m=t,x())},flush(){h&&l(h),h=0,g=0,p=f,v()},cancel(){_=!0,h&&l(h),u&&document.removeEventListener(`visibilitychange`,S),h=0,g=0},getShown:()=>p,getTarget:()=>f}}var ks=new Set([`contacts.search`,`camera.capture`,`location.current`,`apps.open_url`,`apps.open_map`,`apps.open_system_settings`,`apps.open_dialer`,`apps.compose_sms`,`apps.open_app`]),As=new Map,js=[];function Ms(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}async function Ns(e,t){let n=String(t.id||``),r=String(t.operation||``);if(!n||!ks.has(r))return;let i=Date.parse(String(t.expiresAt||``));if(Number.isFinite(i)&&i<=Date.now()){await J.resolveMobileOperation(e,n,{ok:!1,error:`移动设备操作请求已过期。`});return}try{let i=await Ms(`mobile_execute_device_operation`,{request:{id:n,operation:r,parameters:t.parameters&&typeof t.parameters==`object`?t.parameters:void 0}});await J.resolveMobileOperation(e,n,{ok:!0,result:i})}catch(t){await J.resolveMobileOperation(e,n,{ok:!1,error:t instanceof Error?t.message:String(t)})}finally{js.push(n),js.length>128&&js.splice(0,js.length-128)}}function Ps(e){let t=String(e.id||``);!t||js.includes(t)||(js.push(t),js.length>128&&js.splice(0,js.length-128))}function Fs(e,t){let n=String(t.id||``);if(!n||js.includes(n)||As.has(n))return;let r=Ns(e,t).catch(()=>{}).finally(()=>As.delete(n));As.set(n,r)}function Is(e,{agentId:t,responseText:n,data:r,finishedAt:i,error:a}){let o=!!a,s=r.lifecycle||e.lifecycle||{};return{...e,streaming:!1,runFinishedAt:i,lastActivityAt:i,...o?{}:{runNotice:``},currentActivity:r.currentActivity?.type===`agent`?r.currentActivity:null,lifecycle:{...s,phase:o?`failed`:`completed`,event:o?`runtime_error`:`runtime_done`,updatedAt:i},sessionTreeRevision:Number(r.sessionTreeRevision??e.sessionTreeRevision??0),activityFeed:(r.activityFeed||[]).filter(e=>e.type===`agent`),goal:o?e.goal:r.goal??e.goal??null,plan:o?e.plan:Sr(r,e.plan),agents:r.agents||e.agents||[],contextUsage:r.contextUsage??e.contextUsage??null,sessionUsage:r.sessionUsage??e.sessionUsage??null,compaction:r.compaction??e.compaction??null,approvals:o?[]:r.approvals||[],tools:Vi(r.tools||e.tools,{finishedAt:i,...a?{error:a}:{}}),messages:e.messages.map(e=>e.id===t?{...e,text:typeof r.text==`string`?r.text:n||e.text,streaming:!1,...o?{}:r.assets?.length?{attachments:r.assets}:{}}:e)}}function Ls({sessionId:e,agentId:t,sessionStatesRef:n,updateSessionState:r,updateSessions:i,typewriter:a,thinkingScheduler:o,toolScheduler:s,t:c}){let l={responseText:``,responseRenderingStreaming:!0,thinkingText:``,thinkingPrefix:``,queuedDuringRun:!1},u=t=>{i(n=>n.map(n=>n.id===e?t(n):n))};return{dispatch:(i,d)=>{let f=new Date().toISOString();if(i===`meta`)r(e,e=>({...e,model:d.model||e.model,thinkingLevel:d.thinkingLevel||e.thinkingLevel,cwd:d.cwd,permissionMode:d.permissionMode,executionMode:d.executionMode,goal:d.goal??null,plan:Sr(d,e.plan),agents:d.agents||e.agents||[],currentActivity:d.currentActivity||e.currentActivity||null,activityFeed:d.activityFeed||e.activityFeed||[],lifecycle:d.lifecycle??e.lifecycle??null,sessionTreeRevision:Number(d.sessionTreeRevision??e.sessionTreeRevision??0),thinkingText:d.thinkingText??e.thinkingText??``,queuedInputs:jr(e.queuedInputs,d.queuedInputs),hadQueuedInput:!!(e.hadQueuedInput||d.queuedInputs?.length),contextUsage:d.contextUsage??e.contextUsage??null,sessionUsage:d.sessionUsage??e.sessionUsage??null,runStartedAt:d.startedAt||e.runStartedAt,lastActivityAt:d.lastActivityAt||f})),(d.model||d.thinkingLevel||d.cwd||d.permissionMode||d.executionMode||d.goal!==void 0||xr(d)!==void 0)&&u(e=>({...e,model:d.model||e.model,thinkingLevel:d.thinkingLevel||e.thinkingLevel,cwd:d.cwd||e.cwd,permissionMode:d.permissionMode||e.permissionMode,executionMode:d.executionMode||e.executionMode,goal:d.goal??e.goal??null,plan:Sr(d,e.plan??null)}));else if(i===`queue_update`)d.queuedInputs?.length&&(l.queuedDuringRun=!0),r(e,e=>({...e,queuedInputs:d.queuedInputs||[],hadQueuedInput:!!(e.hadQueuedInput||d.queuedInputs?.length)}));else if(i===`agent_update`)r(e,e=>{let t=d.currentActivity||(d.agent?{type:`agent`,agent:d.agent,updatedAt:d.agent.lastActivityAt||f}:null);return{...e,agents:d.agents||[],currentActivity:e.currentActivity?.type===`tool`?e.currentActivity:t||e.currentActivity,activityFeed:t?Bi(e.activityFeed,t):e.activityFeed,lastActivityAt:d.agent?.lastActivityAt||f}});else if(i===`agent_lifecycle`)r(e,e=>{let t=d.lifecycle||e.lifecycle,n=t?.event===`auto_retry_end`,r=t?.event===`turn_start`&&(e.lifecycle?.phase===`retrying`||e.currentActivity?.type===`retry`);return{...e,lifecycle:t,currentActivity:d.currentActivity||e.currentActivity,lastActivityAt:t?.updatedAt||f,runNotice:n&&t?.retry?.success?``:n&&t?.retry?.message?t.retry.message:r?``:e.runNotice}});else if(i===`session_tree_changed`)r(e,{sessionTreeRevision:Number(d.revision||0),lastActivityAt:f});else if(i===`thinking_level_changed`)r(e,{thinkingLevel:d.level,lastActivityAt:f}),u(e=>({...e,thinkingLevel:d.level}));else if(i===`context_usage`)r(e,{contextUsage:d});else if(i===`session_usage`)r(e,{sessionUsage:d});else if(i===`compaction_start`)a.flush(),s.flush(),r(e,e=>{let t={type:`compaction`,compaction:d,updatedAt:d.startedAt||f};return{...e,compaction:d,currentActivity:t,activityFeed:Bi(e.activityFeed,t),lastActivityAt:d.startedAt||f}});else if(i===`compaction_end`)r(e,e=>{let t={type:`model`,stage:`processing_result`,updatedAt:d.finishedAt||f};return{...e,compaction:d,currentActivity:t,activityFeed:Bi(e.activityFeed,t),lastActivityAt:d.finishedAt||f}});else if(i===`text_patch`)l.responseRenderingStreaming=!0,l.responseText=Be(l.responseText,d),a.setTarget(l.responseText,f);else if(i===`text_delta`)l.responseRenderingStreaming=!0,l.responseText+=d.delta||``,a.setTarget(l.responseText,f);else if(i===`text_end`)typeof d.text==`string`&&(l.responseText=d.text),l.responseRenderingStreaming=!1,a.setTarget(l.responseText,d.updatedAt||f),a.flush();else if(i===`thinking_reset`)l.thinkingText=``,l.thinkingPrefix=String(d.thinkingText||``).slice(-6e3),o.cancel(),r(e,{thinkingText:l.thinkingPrefix,currentActivity:{type:`model`,stage:`thinking`,updatedAt:d.updatedAt||f},lastActivityAt:d.updatedAt||f});else if(i===`thinking_patch`){l.thinkingText=Be(l.thinkingText,d).slice(-6e3);let e=[l.thinkingPrefix,l.thinkingText].filter(Boolean).join(`
8
+
9
+ `);o.push(e.slice(-6e3),f)}else if(i===`tool_start`)o.flush(),a.flush(),s.flush(),r(e,e=>{let n={type:`tool`,id:d.id,name:d.name,args:d.args,status:`running`,startedAt:d.startedAt||f,updatedAt:f,...d.output===void 0?{}:{output:d.output}};return{...e,lastActivityAt:f,runNotice:``,tools:Bi(e.tools,n),currentActivity:n,activityFeed:Bi(e.activityFeed,n),messages:e.messages.map(e=>e.id===t?{...e,text:l.responseText||e.text}:e)}});else if(i===`tool_update`)s.push(d.id,{message:d.message||``,updatedAt:d.updatedAt||f,...d.output===void 0?{}:{output:d.output},...d.agent?{agent:d.agent}:{}},d.updatedAt||f);else if(i===`tool_end`)s.flush(),r(e,e=>{let t=e.tools.find(e=>e.id===d.id),n=d.finishedAt||f,r=String(t?.name||``),i=(Tr(r)||[`spawn_agent`,`list_agents`,`send_message`,`followup_task`,`wait_agent`,`interrupt_agent`].includes(r))&&[`plan`,`agent`].includes(e.currentActivity?.type),a={...t||{},type:`tool`,status:d.error?`error`:`done`,message:d.message||t?.message||``,updatedAt:n,finishedAt:n,...d.output===void 0?{}:{output:d.output}},o=d.agent?{type:`agent`,agent:d.agent,updatedAt:d.agent.lastActivityAt||n}:null,s=e.activityFeed||[];return(d.error||!i&&!o)&&(s=Bi(s,a)),o&&(s=Bi(s,o)),{...e,lastActivityAt:n,tools:e.tools.map(e=>e.id===d.id?{...e,status:d.error?`error`:`done`,message:d.message||``,updatedAt:n,finishedAt:n,...d.output===void 0?{}:{output:d.output}}:e),currentActivity:d.error?a:o||(i?e.currentActivity:a),activityFeed:s}});else if(i===`mobile_operation_request`)Fs(e,d);else if(i===`mobile_operation_cancel`)Ps(d);else if(i===`permission_request`)a.flush(),s.flush(),r(e,e=>({...e,lastActivityAt:f,approvals:[...(e.approvals||[]).filter(e=>e.id!==d.id),d]}));else if(i===`permission_resolved`)r(e,e=>({...e,lastActivityAt:f,approvals:(e.approvals||[]).filter(e=>e.id!==d.id)}));else if(i===`generated_asset`)r(e,e=>({...e,lastActivityAt:f,messages:e.messages.map(e=>e.id===t?{...e,attachments:[...(e.attachments||[]).filter(e=>e.id!==d.id),d]}:e)}));else if(i===`goal_update`)r(e,{goal:d.goal??null}),u(e=>({...e,goal:d.goal??null}));else if(Cr(i))a.flush(),s.flush(),r(e,e=>{let t=Sr(d,e.plan),n=d.currentActivity||{type:`plan`,plan:t,changes:zi(e.plan,t),updatedAt:t?.updatedAt||f};return{...e,lastActivityAt:f,plan:t,currentActivity:n,activityFeed:Bi(e.activityFeed,n)}}),u(e=>({...e,plan:Sr(d,e.plan??null)}));else if(i===`session_title`)u(e=>({...e,name:d.name}));else if(i===`retry`){let t=c(`chat:chatPage.retryingAttemptMaxAttemptsMessage`,{attempt:d.attempt,maxAttempts:d.maxAttempts,message:d.message});r(e,e=>{let n={type:`retry`,message:t,updatedAt:f};return{...e,runNotice:t,currentActivity:n,activityFeed:Bi(e.activityFeed,n),lastActivityAt:f}})}else if(i===`done`||i===`error`){l.queuedDuringRun||=!!(n.current[e]?.hadQueuedInput||n.current[e]?.queuedInputs?.length);let c=d.finishedAt||f;if(typeof d.text==`string`&&(l.responseText=d.text),l.responseRenderingStreaming=!1,a.setTarget(l.responseText,c),a.flush(),o.flush(),s.cancel(),r(e,e=>Is(e,{agentId:t,responseText:l.responseText,data:d,finishedAt:c,...i===`error`?{error:d.message}:{}})),i===`done`)return u(e=>({...e,streaming:!1,goal:d.goal??e.goal??null,plan:Sr(d,e.plan??null)})),!1;throw Error(d.message)}},state:l}}var Rs=`pisper:usage-updated`;function zs({browserNotify:e,notify:t,defaultModel:n,localStreamSessionsRef:r,sessionStatesRef:i,setActiveId:a,setGlobalError:o,updateSessionState:s,updateSessions:c,createSession:l,loadSessionMessages:u,refreshSessions:d,syncLiveSession:f}){let{t:p}=g(),m=(0,X.useRef)(new Map),h=(0,X.useCallback)(async(t,h,g=[],_=!1,v=null,y=null)=>{let b=t.trim()||(g.length?p(`chat:chatPage.pleaseAnalyzeTheseAttachments`):``)||(y?y.resourceName:``);if(!b&&!y)return;let x=h;if(x||=await l(),!x||i.current[x]?.streaming)return;let S=()=>{},C=new Promise(e=>{S=e});m.current.set(x,{promise:C,resolve:S}),a(x),o(``);let w={id:`user-${Date.now()}`,role:`user`,text:b,invocation:y,attachments:g.map(({id:e,kind:t,name:n,mimeType:r,size:i,data:a})=>({id:e,kind:t,name:n,mimeType:r,size:i,data:t===`image`?a:void 0}))},T=`agent-${Date.now()}`,E=new Date().toISOString(),D={responseText:``,responseRenderingStreaming:!0,thinkingText:``,thinkingPrefix:``,queuedDuringRun:!1},O=Ts((e,t)=>{s(x,n=>({...n,thinkingText:e,lastActivityAt:t||n.lastActivityAt,currentActivity:{type:`model`,stage:`thinking`,updatedAt:t||n.lastActivityAt}}))},{intervalMs:80}),k=Os((e,t)=>{s(x,n=>{let r={type:`model`,stage:`responding`,updatedAt:t||n.lastActivityAt};return{...n,lastActivityAt:t||n.lastActivityAt,runNotice:``,currentActivity:r,activityFeed:Bi(n.activityFeed,r),messages:n.messages.map(t=>t.id===T?{...t,text:e,streaming:D.responseRenderingStreaming}:t)}})}),A=Es((e,t)=>{s(x,n=>{let r=n.activityFeed||[];for(let[n,i]of e){let e=r.find(e=>e.type===`tool`&&e.id===n);e&&(r=Bi(r,{...e,...i,updatedAt:t||e.updatedAt}))}let i=n.currentActivity?.type===`tool`&&e.has(n.currentActivity.id)?{...n.currentActivity,...e.get(n.currentActivity.id),updatedAt:t||n.currentActivity.updatedAt}:n.currentActivity;return{...n,lastActivityAt:t||n.lastActivityAt,tools:n.tools.map(t=>{let n=e.get(String(t.id||``));return n?{...t,...n}:t}),currentActivity:i,activityFeed:r}})}),j=Ls({sessionId:x,agentId:T,sessionStatesRef:i,updateSessionState:s,updateSessions:c,typewriter:k,thinkingScheduler:O,toolScheduler:A,t:p});D=j.state,s(x,e=>{let t=_||e.goal?.status===`active`;return{...e,messages:[...e.messages,w,{id:T,role:`agent`,text:``,streaming:!0}],tools:[],approvals:[],error:``,streaming:!0,loaded:!0,runStartedAt:E,lastActivityAt:E,runFinishedAt:null,runStopped:!1,runNotice:``,currentActivity:{type:`model`,stage:`thinking`,updatedAt:E},activityFeed:[],lifecycle:{phase:`starting`,event:`prompt_submitted`,turn:0,updatedAt:E},thinkingText:``,hadQueuedInput:!1,compaction:null,plan:t?e.plan:null}}),_||c(e=>e.map(e=>e.id!==x||e.goal?.status===`active`?e:{...e,plan:null})),r.current.add(x);try{await J.openStream({sessionId:x,message:b,attachments:g,goalMode:_,goalTokenBudget:v,invocation:y},j.dispatch),k.setTarget(D.responseText),k.flush(),O.flush(),A.flush();let t=new Date().toISOString();i.current[x]?.streaming&&s(x,e=>{let n=e.runFinishedAt||t;return{...e,streaming:!1,runFinishedAt:n,lastActivityAt:n,runNotice:``,currentActivity:null,activityFeed:[],approvals:[],tools:Vi(e.tools,{finishedAt:n}),messages:e.messages.map(e=>e.id===T?{...e,streaming:!1,text:D.responseText||e.text}:e)}}),await u(x,{force:!0}),(_||D.queuedDuringRun||i.current[x]?.hadQueuedInput||i.current[x]?.goal||i.current[x]?.queuedInputs?.length)&&s(x,{queuedInputs:[],hadQueuedInput:!1});let r;try{r=(await d()).find(e=>e.id===x)}catch{f(x)}e?.(`chat.completed`,{chat:{title:r?.name||p(`chat:chatPage.appChat`,{app:`Pisper`}),summary:D.responseText.trim().slice(0,260)||p(`chat:chatPage.theAgentHasFinishedResponding`),model:i.current[x]?.model||n}})}catch(e){k.cancel(),O.flush(),A.cancel();let t=new Date().toISOString(),n=$(e);if(s(x,e=>({...e,streaming:!1,error:n,runFinishedAt:t,lastActivityAt:t,runNotice:``,currentActivity:null,activityFeed:[],approvals:[],tools:Vi(e.tools,{finishedAt:t,error:n}),messages:e.messages.map(e=>e.id===T?{...e,streaming:!1,error:n,text:e.text||D.responseText||n}:e)})),D.queuedDuringRun||i.current[x]?.hadQueuedInput||i.current[x]?.queuedInputs?.length){try{await u(x,{force:!0})}catch{}s(x,{queuedInputs:[],hadQueuedInput:!1})}c(e=>e.map(e=>e.id===x?{...e,streaming:!1}:e))}finally{r.current.delete(x),k.cancel(),O.cancel(),A.cancel(),s(x,{streaming:!1,hadQueuedInput:!1});let e=m.current.get(x);m.current.delete(x),e?.resolve(),window.dispatchEvent(new Event(Rs))}},[e,l,n,u,r,d,i,a,o,f,p,s,c]);return{sendPrompt:h,queuePrompt:(0,X.useCallback)(async(e,n,r=[],i=`steer`)=>{let a=String(e||``).trim()||(r.length?p(`chat:chatPage.pleaseAnalyzeTheseAttachments`):``);if(!n||!a)return!1;try{let e=await J.queueInput(n,a,r,i),t=new Date().toISOString(),o={id:`interactive-user-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,role:`user`,text:a,queuedAt:t,streamingBehavior:e.behavior||i,attachments:r.map(({id:e,kind:t,name:n,mimeType:r,size:i,data:a})=>({id:e,kind:t,name:n,mimeType:r,size:i,data:t===`image`?a:void 0}))};return s(n,n=>({...n,messages:Mr(n.messages,o),queuedInputs:jr(n.queuedInputs,e.queuedInputs),hadQueuedInput:!0,lastActivityAt:t})),!0}catch(e){if(Ka(e)){let e=m.current.get(n);return e?await e.promise:await f(n),s(n,{streaming:!1,recovering:!1,queuedInputs:[],hadQueuedInput:!1}),await u(n,{force:!0}),h(a,n,r),!0}return t($(e),`error`),!1}},[u,t,h,f,p,s]),abort:(0,X.useCallback)(async e=>{if(!e)return;let n=await J.abort(e),r=new Date().toISOString();s(e,e=>({...e,streaming:!1,queuedInputs:[],hadQueuedInput:!1,goal:n.goal??null,compaction:e.compaction?.active?{...e.compaction,active:!1,status:`aborted`,aborted:!0,finishedAt:r}:e.compaction,runFinishedAt:r,lastActivityAt:r,runStopped:!0,runNotice:``,approvals:[],tools:Vi(e.tools,{finishedAt:r,error:p(`chat:chatPage.stopped`)}),messages:e.messages.map(e=>e.streaming?{...e,streaming:!1}:e)})),c(t=>t.map(t=>t.id===e?{...t,streaming:!1,goal:n.goal??t.goal??null}:t)),t(p(`chat:chatPage.currentRunStopped`),`info`)},[t,p,s,c])}}function Bs({notify:e,requestText:t,requestConfirm:n,availableModels:r,sessionStatesRef:i,updateSessionState:a,updateSessions:o,replaceSessionStates:s,setGlobalError:c,syncLiveSession:l}){let{t:u,language:d}=g(),[f,p]=(0,X.useState)(null),m=(0,X.useCallback)((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[o]),h=(0,X.useCallback)(async t=>{if(t)try{let n=await J.pauseGoal(t);a(t,{goal:n.goal||null}),m(t,e=>({...e,goal:n.goal||null})),e(u(`chat:chatPage.goalPaused`),`info`)}catch(e){a(t,{error:$(e)})}},[e,u,a,m]),_=(0,X.useCallback)(async(t,n)=>{if(t)try{let r=await J.setGoalBudget(t,n);a(t,{goal:r.goal||null}),m(t,e=>({...e,goal:r.goal||null})),e(u(`chat:chatPage.goalTokenBudgetUpdated`),`info`)}catch(e){a(t,{error:$(e)})}},[e,u,a,m]),v=(0,X.useCallback)(async t=>{let n=i.current[t];if(!(!t||n?.streaming||n?.compaction?.active)){a(t,{compaction:{...n?.compaction||{},active:!0,status:`running`,reason:`manual`},error:``});try{let n=await J.compactSession(t);a(t,{compaction:n.compaction||null,contextUsage:n.contextUsage||null}),e(u(`chat:chatPage.contextCompacted`))}catch(e){await l(t).catch(()=>{}),a(t,{error:$(e)})}}},[e,i,l,u,a]),y=(0,X.useCallback)(async e=>{let t=await J.updateCompactionPreference(e);s(Object.fromEntries(Object.entries(i.current).map(([e,n])=>{let r=Number(n.contextUsage?.contextWindow)||0;return r?[e,{...n,contextUsage:{...n.contextUsage,compactAtPercent:t.thresholdPercent,compactAtTokens:Math.floor(r*t.thresholdPercent/100)}}]:[e,n]})))},[s,i]),b=(0,X.useCallback)((e,t={})=>{let n=String(t.model||``),r=String(i.current[e]?.model||``);if(n&&r&&n!==r)return;let o=Array.isArray(t.availableThinkingLevels)?t.availableThinkingLevels.map(e=>String(e)):Array.isArray(t.availableLevels)?t.availableLevels.map(e=>String(e)):[],s=String(t.thinkingLevel||``);a(e,{thinkingLevel:s||void 0,availableThinkingLevels:o,thinkingStatus:String(t.thinkingStatus||t.status||``),thinkingMessage:String(t.thinkingMessage||t.message||``),switchingThinking:!1}),s&&m(e,e=>({...e,thinkingLevel:s}))},[i,a,m]),x=(0,X.useCallback)(async e=>{if(!(!e||i.current[e]?.streaming))try{let t=await J.getThinkingLevel(e);b(e,t)}catch{a(e,{thinkingStatus:`error`,thinkingMessage:u(`chat:focusSession.thinkingLevelsLoadFailed`)})}},[b,i,u,a]),S=(0,X.useCallback)(async(t,o)=>{let s=r.find(e=>e.key===o);if(!t||!s||i.current[t]?.streaming)return;let c=i.current[t],l=c?.model||``,d=!!c?.messages?.length&&!c?.compaction?.active;a(t,{switchingModel:!0,model:s.key,error:``}),m(t,e=>({...e,model:s.key}));try{let r=await J.updateModel(t,s.provider,s.modelId);a(t,{model:r.model||s.key,contextUsage:r.contextUsage??null,switchingModel:!1}),m(t,e=>({...e,model:r.model||s.key})),b(t,r),e(u(`chat:chatPage.switchedToModel`,{model:s.label})),d&&await n({title:u(`chat:chatPage.compactAfterModelSwitch`),message:u(`chat:chatPage.compactAfterModelSwitchDescription`),confirmLabel:u(`chat:chatPage.compactNow`),tone:`primary`})&&await v(t)}catch(e){a(t,{switchingModel:!1,model:l||void 0,error:$(e)}),l&&m(t,e=>({...e,model:l}))}},[b,r,v,e,n,i,u,a,m]),C=(0,X.useCallback)(async(t,n)=>{let r=String(n||``).trim();if(!t||!r||i.current[t]?.streaming)return;let o=i.current[t]||{},s=String(o.thinkingLevel||``);a(t,{switchingThinking:!0,thinkingLevel:r,error:``}),m(t,e=>({...e,thinkingLevel:r}));try{let n=await J.setThinkingLevel(t,r);b(t,n),e(u(`chat:chatPage.switchedToThinkingLevel`,{level:String(n.thinkingLevel||r)}))}catch(e){a(t,{switchingThinking:!1,thinkingLevel:s||void 0,error:$(e)}),s&&m(t,e=>({...e,thinkingLevel:s}))}},[b,e,i,u,a,m]),w=(0,X.useCallback)(async(t,r)=>{if(!t)return!1;a(t,{switchingPermission:!0,error:``});try{if(r===`full-access`&&!await n({title:u(`chat:chatPage.enableFullAccess`),message:u(`chat:chatPage.fullAccessAllowsTheAgentToUseFilesAndNetworkServicesOutsideTheWorkspaceAndShellCommandsWillNoLon`),confirmLabel:u(`chat:chatPage.enableFullAccess`)}))return a(t,{switchingPermission:!1}),!1;let i=await J.updateExecutionMode(t,r);return a(t,{executionMode:i.executionMode,permissionMode:i.permissionMode,switchingPermission:!1}),m(t,e=>({...e,executionMode:i.executionMode,permissionMode:i.permissionMode})),e(u(`chat:chatPage.executionModeChangedToMode`,{mode:i.executionMode===`read-only`?u(`chat:chatPage.readOnly`):i.executionMode===`approval-required`?u(`chat:chatPage.approvalRequired`):i.executionMode===`workspace-write`?u(`chat:focusSession.workspaceWrite`):u(`chat:chatPage.fullAccess`)})),!0}catch(e){return a(t,{switchingPermission:!1,error:$(e)}),!1}},[e,n,u,a,m]),T=(0,X.useCallback)(async(t,n,r)=>{a(t,e=>({...e,approvals:(e.approvals||[]).filter(e=>e.id!==n),error:``}));try{(await J.resolveApproval(t,n,r)).alreadyResolved&&l(t)}catch(n){if(await l(t),n instanceof St&&n.status===404){e(u(`chat:chatPage.approvalStatusUpdated`),`info`);return}throw a(t,{error:$(n)}),n}},[e,l,u,a]),E=(0,X.useCallback)(async(t,n)=>{if(!(!t?.id||i.current[t.id]?.streaming)){a(t.id,{switchingCwd:!0,error:``});try{let r=await J.updateCwd(t.id,n);a(t.id,{cwd:r.cwd,switchingCwd:!1}),m(t.id,e=>({...e,cwd:r.cwd})),p(null),e(u(`chat:chatPage.workingDirectoryChangedToWorkspace`,{workspace:$e(r.cwd,d)}))}catch(e){throw a(t.id,{switchingCwd:!1,error:$(e)}),e}}},[d,e,i,u,a,m]);return{workspaceSession:f,setWorkspaceSession:p,switchSessionCwd:E,selectSessionWorkspace:(0,X.useCallback)(async t=>{if(t?.id){if(i.current[t.id]?.streaming){e(u(`chat:chatPage.stopTheActiveRunBeforeChangingTheWorkspace`),`info`);return}if(!Ht()){p(t);return}try{let e=await Vt(t.cwd);e&&await E(t,e)}catch(e){a(t.id,{switchingCwd:!1,error:$(e)})}}},[e,i,E,u,a]),renameSession:(0,X.useCallback)(async n=>{if(!n?.id)return;if(i.current[n.id]?.streaming){e(u(`chat:chatPage.stopTheActiveRunBeforeRenamingTheChat`),`info`);return}let r=await t({title:u(`chat:chatPage.renameChat`),inputLabel:u(`chat:chatPage.chatTitle`),value:n.name,confirmLabel:u(`chat:chatPage.save`)});if(r!==null&&r!==n.name)try{let t=await J.renameSession(n.id,r);m(n.id,e=>({...e,name:t.name})),je(),e(u(`chat:chatPage.chatTitleUpdated`))}catch(e){c($(e))}},[e,t,i,c,u,m]),pauseGoal:h,setGoalBudget:_,compactSession:v,setCompactionThreshold:y,loadSessionThinkingLevel:x,switchSessionModel:S,switchSessionThinkingLevel:C,switchSessionExecutionMode:w,resolveToolApproval:T}}function Vs({notify:e,browserNotify:t,registerPrimaryAction:n,pendingAsset:r,onAssetConsumed:i,requestText:a,requestConfirm:o}){let{t:s}=g(),c=(0,X.useRef)(new Set),l=_s({notify:e}),u=Cs({sessionStates:l.sessionStates,sessionStatesRef:l.sessionStatesRef,localStreamSessionsRef:c,updateSessionState:l.updateSessionState,updateSessions:l.updateSessions}),d=vs({sessions:l.sessions,sessionsRef:l.sessionsRef,sessionStates:l.sessionStates,activeId:l.activeId,setActiveId:l.setActiveId,loading:l.loading,localStreamSessionsRef:c,loadSessionMessages:u.loadSessionMessages,releaseSessionState:l.releaseSessionState,notify:e}),f=l.createSessionRecord,p=u.loadSessionMessages,m=l.refreshSessions,h=l.setGlobalError,_=d.openSessionInDock,v=d.moveSessionToGroup,[y,b]=(0,X.useState)({sessionId:``,token:0}),x=(0,X.useCallback)(async(e,t=``)=>{let n=await f(t);return n?(_(n)&&v(n,e),n):``},[f,v,_]);It(n,x),(0,X.useEffect)(()=>{let e=()=>{let e=Ot();e&&x(void 0,e.cwd)};return window.addEventListener(tt,e),e(),()=>window.removeEventListener(tt,e)},[x]);let S=zs({browserNotify:t,notify:e,defaultModel:l.defaultModel,localStreamSessionsRef:c,sessionStatesRef:l.sessionStatesRef,setActiveId:l.setActiveId,setGlobalError:l.setGlobalError,updateSessionState:l.updateSessionState,updateSessions:l.updateSessions,createSession:x,loadSessionMessages:u.loadSessionMessages,refreshSessions:l.refreshSessions,syncLiveSession:u.syncLiveSession}),C=Bs({notify:e,requestText:a,requestConfirm:o,availableModels:l.availableModels,sessionStatesRef:l.sessionStatesRef,updateSessionState:l.updateSessionState,updateSessions:l.updateSessions,replaceSessionStates:l.replaceSessionStates,setGlobalError:l.setGlobalError,syncLiveSession:u.syncLiveSession}),w=(0,X.useCallback)(async e=>{await p(e,{force:!0}),await m(e)},[p,m]),T=(0,X.useCallback)(async(t,n)=>{if(!(!t?.id||!n))try{if(h(``),(await J.navigateSessionTree(t.id,n,!1)).cancelled)return;await w(t.id),b(e=>({sessionId:t.id,token:e.token+1})),e(s(`chat:chatPage.branchedFromNode`))}catch(e){h(e instanceof Error?e.message:String(e))}},[e,w,h,s]),E=(0,X.useCallback)(async(t,n)=>{if(!t?.id||!n)return;let r=await a({title:s(`chat:chatPage.createChildChat`),inputLabel:s(`chat:chatPage.chatTitle`),value:`${s(`chat:chatPage.separateChatSuffix`)} · ${t.name||s(`chat:chatPage.newChat`)}`,confirmLabel:s(`chat:chatPage.create`)});if(r!==null)try{h(``);let i=await J.deriveSession(t.id,n,r);await m(i.id),b(e=>({sessionId:t.id,token:e.token+1})),await new Promise(e=>window.setTimeout(e,550)),_(i.id),e(s(`chat:chatPage.childChatCreated`))}catch(e){h(e instanceof Error?e.message:String(e))}},[e,_,m,a,h,s]),D=(0,X.useMemo)(()=>function({group:e}){let t=s(`navigation:pageHeader.newChat`);return(0,Z.jsx)(`button`,{type:`button`,className:`dock-new-session hover:bg-[var(--surface-hover)] hover:text-[var(--text)] focus-visible:relative focus-visible:z-[1] focus-visible:[outline:2px_solid_var(--focus)] focus-visible:[outline-offset:-2px] grid w-[36px] h-[35px] flex-none place-items-center border-0 [border-left:1px_solid_var(--stroke-soft)] bg-transparent text-[var(--text-muted)] cursor-pointer`,title:t,"aria-label":t,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),x(e)},children:(0,Z.jsx)(mt,{size:15})})},[x,s]),O=(0,X.useMemo)(()=>({session:ts,webPreview:ms}),[]),k={sessions:l.sessions,sessionStates:l.sessionStates,defaultModel:l.defaultModel,availableModels:l.availableModels,globalError:l.globalError,activeId:l.activeId,compactDock:d.compactDock,sessionTreePulseSessionId:y.sessionId,sessionTreePulseToken:y.token,pendingAsset:r,onAssetConsumed:i,loadSessionMessages:u.loadSessionMessages,loadOlderMessages:u.loadOlderMessages,sendPrompt:S.sendPrompt,queuePrompt:S.queuePrompt,abort:S.abort,pauseGoal:C.pauseGoal,setGoalBudget:C.setGoalBudget,compactSession:C.compactSession,setCompactionThreshold:C.setCompactionThreshold,switchSessionModel:C.switchSessionModel,loadSessionThinkingLevel:C.loadSessionThinkingLevel,switchSessionThinkingLevel:C.switchSessionThinkingLevel,switchSessionExecutionMode:C.switchSessionExecutionMode,resolveToolApproval:C.resolveToolApproval,selectSessionWorkspace:C.selectSessionWorkspace,renameSession:C.renameSession,branchFromEntry:T,createChildSession:E,reloadSessionBranch:w,splitDockPanel:d.splitDockPanel,closeDockPanel:d.closeDockPanel};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`chat-layout max-[900px]:grid-cols-[minmax(0,1fr)] max-[650px]:flex max-[650px]:flex-col max-[650px]:min-h-0 relative grid w-full min-w-0 min-h-0 flex-1 grid-cols-[minmax(0,1fr)] gap-[0] dock-layout`,children:l.loading?(0,Z.jsxs)(Ct,{children:[(0,Z.jsx)(G,{className:`animate-spin`,size:24}),(0,Z.jsx)(`h2`,{children:s(`chat:chatPage.wakingTheAgent`)}),(0,Z.jsx)(`p`,{children:s(`chat:chatPage.modelsSessionsAndContextAreSettlingIntoPlace`)})]}):(0,Z.jsx)(`div`,{className:`chat-dock-workspace max-[650px]:[flex:1_1_0] max-[650px]:min-h-0 relative min-w-0 min-h-0 [isolation:isolate] overflow-hidden [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-md)] bg-[var(--panel)]`,children:(0,Z.jsx)($o.Provider,{value:k,children:(0,Z.jsx)(Rt,{className:`dockview-theme-light dockview-theme-pisper`,components:O,watermarkComponent:ns,leftHeaderActionsComponent:D,onReady:d.onDockReady,getTabContextMenuItems:d.getTabContextMenuItems,disableFloatingGroups:!0,disableDnd:d.compactDock,noPanelsOverlay:`watermark`})})})}),C.workspaceSession&&(0,Z.jsx)(de,{open:!0,initialPath:C.workspaceSession.cwd,description:s(`common:workspacePicker.selectWorkspaceForChat`,{name:C.workspaceSession.name}),onOpenChange:e=>!e&&C.setWorkspaceSession(null),onSelect:e=>C.switchSessionCwd(C.workspaceSession,e)})]})}export{Vs as ChatPage,ro as t};