pisper 0.5.39-linux-x64.0 → 0.5.39

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 (318) hide show
  1. package/README.en.md +67 -0
  2. package/README.md +53 -53
  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 +2606 -0
  12. package/web/assets/AnimatedList-_pbK4tS3.js +1 -0
  13. package/web/assets/AppOverlays-DK_RBSUi.js +1 -0
  14. package/web/assets/AppSelect-v2NUOzRf.js +1 -0
  15. package/web/assets/AppShortcuts-D66c2bOM.js +1 -0
  16. package/web/assets/AssetsPage-DFD-JHLO.js +1 -0
  17. package/web/assets/ChannelsPage-S1iZpd8M.js +1 -0
  18. package/web/assets/ChatDockView-wwQKATRH.js +2 -0
  19. package/web/assets/ChatHistoryPage-BNckgbvE.js +1 -0
  20. package/web/assets/ChatPage-COE_4ulo.js +4 -0
  21. package/web/assets/ClickSpark-BhxL8WOQ.js +1 -0
  22. package/web/assets/ConfigPage-BsLy5y6L.js +1 -0
  23. package/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  24. package/web/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  25. package/web/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  26. package/web/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  27. package/web/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  28. package/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  29. package/web/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  30. package/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  31. package/web/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  32. package/web/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  33. package/web/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  34. package/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  35. package/web/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  36. package/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  37. package/web/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  38. package/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  39. package/web/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  40. package/web/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  41. package/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  42. package/web/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  43. package/web/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  44. package/web/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  45. package/web/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  46. package/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  47. package/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  48. package/web/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  49. package/web/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  50. package/web/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  51. package/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  52. package/web/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  53. package/web/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  54. package/web/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  55. package/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  56. package/web/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  57. package/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  58. package/web/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  59. package/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  60. package/web/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  61. package/web/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  62. package/web/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  63. package/web/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  64. package/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  65. package/web/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  66. package/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  67. package/web/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  68. package/web/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  69. package/web/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  70. package/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  71. package/web/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  72. package/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  73. package/web/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  74. package/web/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  75. package/web/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  76. package/web/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  77. package/web/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  78. package/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  79. package/web/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  80. package/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  81. package/web/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  82. package/web/assets/MarkdownMessage-ickiT81L.js +2 -0
  83. package/web/assets/MemoryPage-BryPFpf3.js +1 -0
  84. package/web/assets/MobileViewportStabilizer-CYh5obIv.js +1 -0
  85. package/web/assets/PageHeader-D7ZcsXHZ.js +1 -0
  86. package/web/assets/PluginsPage-By294e2k.js +1 -0
  87. package/web/assets/PreviewPages-gdxrspfV.js +1 -0
  88. package/web/assets/SchedulesPage-S6X-heBQ.js +1 -0
  89. package/web/assets/ShinyText-fuaKxKqJ.js +1 -0
  90. package/web/assets/SkillsPage-nP6Ilb53.js +1 -0
  91. package/web/assets/StarOrbit-BlI6MhVr.js +1 -0
  92. package/web/assets/TerminalPanel-Bb_Kf0kq.js +18 -0
  93. package/web/assets/TerminalPanel-BrP-ENHg.css +1 -0
  94. package/web/assets/Threads-DPFx-jxG.js +1 -0
  95. package/web/assets/WelcomeEffects-C9iQOeK6.js +1 -0
  96. package/web/assets/WorkflowsPage-DlZwTBcP.js +1 -0
  97. package/web/assets/WorkspacePicker-D766UTlt.js +1 -0
  98. package/web/assets/abort-signal-D0GPd1Mw.js +1 -0
  99. package/web/assets/alert-B7D8joCd.js +1 -0
  100. package/web/assets/andromeeda-vGVdxbeo.js +1 -0
  101. package/web/assets/angular-html-17rlCfBS.js +1 -0
  102. package/web/assets/angular-ts-it3MaXWH.js +1 -0
  103. package/web/assets/api-CmPTEiOc.js +3 -0
  104. package/web/assets/arrow-right-KWvgbo3p.js +1 -0
  105. package/web/assets/astro-BEVDzCov.js +1 -0
  106. package/web/assets/aurora-x-CDeNXAV0.js +1 -0
  107. package/web/assets/ayu-dark-DluEY0Gj.js +1 -0
  108. package/web/assets/ayu-light-C3h-C4tm.js +1 -0
  109. package/web/assets/ayu-mirage-Bqwy1Gya.js +1 -0
  110. package/web/assets/blade-B3yUZIOx.js +1 -0
  111. package/web/assets/brand-DIEc3fK8.js +1 -0
  112. package/web/assets/button-XhIEgIsg.js +1 -0
  113. package/web/assets/c-aGSZMVdM.js +1 -0
  114. package/web/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
  115. package/web/assets/catppuccin-latte-CtsyrtPq.js +1 -0
  116. package/web/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
  117. package/web/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
  118. package/web/assets/chat-api-B4XafR63.js +1 -0
  119. package/web/assets/check-jIXqkGKr.js +1 -0
  120. package/web/assets/chevron-down-DT6AXwTP.js +1 -0
  121. package/web/assets/circle-dot-rl11gaty.js +1 -0
  122. package/web/assets/client-store-TRnjrXTz.js +1 -0
  123. package/web/assets/code-xml-Z4K2ea1N.js +1 -0
  124. package/web/assets/coffee-ouOQ86EC.js +1 -0
  125. package/web/assets/collapsible-DjbBeRo0.js +1 -0
  126. package/web/assets/config-search-DdUjL2D7.js +1 -0
  127. package/web/assets/copy-DS-8Hh_R.js +1 -0
  128. package/web/assets/cpp-Bm3vm43L.js +1 -0
  129. package/web/assets/css-CWcS1xXm.js +1 -0
  130. package/web/assets/csv-Dx-8-gkx.js +1 -0
  131. package/web/assets/dark-plus-Cs2F2srj.js +1 -0
  132. package/web/assets/dist-CISIC3_f.js +1 -0
  133. package/web/assets/dist-DOR8kAEV.js +1 -0
  134. package/web/assets/dracula-BHWKrbxM.js +1 -0
  135. package/web/assets/dracula-soft-5eyTD99u.js +1 -0
  136. package/web/assets/earth-DR_clkZ9.js +1 -0
  137. package/web/assets/embedded-D2rqyswH.js +269 -0
  138. package/web/assets/es2015-0VLo_afz.js +41 -0
  139. package/web/assets/everforest-dark-sB-x3p7T.js +1 -0
  140. package/web/assets/everforest-light-Df2xbC6M.js +1 -0
  141. package/web/assets/field-C8yUX8Pf.js +1 -0
  142. package/web/assets/file-C8GNXmhJ.js +1 -0
  143. package/web/assets/file-code-corner-BKkXAMHR.js +1 -0
  144. package/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  145. package/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  146. package/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  147. package/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  148. package/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  149. package/web/assets/github-dark-C-LZuMrd.js +1 -0
  150. package/web/assets/github-dark-default-DXG-b-1a.js +1 -0
  151. package/web/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
  152. package/web/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
  153. package/web/assets/github-light-EUqPIrTm.js +1 -0
  154. package/web/assets/github-light-default-BXViO-2h.js +1 -0
  155. package/web/assets/github-light-high-contrast-B68TUdTA.js +1 -0
  156. package/web/assets/glsl-TOBAB6bO.js +1 -0
  157. package/web/assets/graphql-BEmIBNve.js +1 -0
  158. package/web/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
  159. package/web/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
  160. package/web/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
  161. package/web/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
  162. package/web/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
  163. package/web/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
  164. package/web/assets/haml-CDWtFtU9.js +1 -0
  165. package/web/assets/handlebars-BNtjo3pL.js +1 -0
  166. package/web/assets/horizon-CE9ld1lL.js +1 -0
  167. package/web/assets/horizon-bright-DSNQnXHK.js +1 -0
  168. package/web/assets/houston-CsvMBhTu.js +1 -0
  169. package/web/assets/html-BVyvp26C.js +1 -0
  170. package/web/assets/html-derivative-BseLpURQ.js +1 -0
  171. package/web/assets/http-CkCfSMV9.js +1 -0
  172. package/web/assets/hurl-syYMt6Rn.js +1 -0
  173. package/web/assets/image-Dh7-wI1d.js +1 -0
  174. package/web/assets/imba-DsUTQ-LC.js +1 -0
  175. package/web/assets/index-BvVJkBr0.js +40 -0
  176. package/web/assets/index-DTit-2OA.css +2 -0
  177. package/web/assets/input-D1QFzNMx.js +1 -0
  178. package/web/assets/java-duG_UTKe.js +1 -0
  179. package/web/assets/javascript-DWVbOe4X.js +1 -0
  180. package/web/assets/jinja-Boj4niAz.js +1 -0
  181. package/web/assets/jison-CHwnC1Pv.js +1 -0
  182. package/web/assets/json-qhed-kSA.js +1 -0
  183. package/web/assets/json5-BR5RXkoi.js +1 -0
  184. package/web/assets/jsonc-CYpm1nAK.js +1 -0
  185. package/web/assets/jsonl-CmCQp5Yx.js +1 -0
  186. package/web/assets/jsx-fcCEM_-L.js +1 -0
  187. package/web/assets/julia-VoF7UKfw.js +1 -0
  188. package/web/assets/kanagawa-dragon-Bozd7klA.js +1 -0
  189. package/web/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
  190. package/web/assets/kanagawa-wave-BML5mF2J.js +1 -0
  191. package/web/assets/laserwave-C_8bwKvT.js +1 -0
  192. package/web/assets/less-DVTAwKKz.js +1 -0
  193. package/web/assets/light-plus-DVQuIRkW.js +1 -0
  194. package/web/assets/link-2-CaZP6GWi.js +1 -0
  195. package/web/assets/loader-circle-72TYCcVQ.js +1 -0
  196. package/web/assets/markdown-BYOwaDjH.js +1 -0
  197. package/web/assets/marko-Cupn1xhw.js +1 -0
  198. package/web/assets/material-theme-Bm3Qr25_.js +1 -0
  199. package/web/assets/material-theme-darker-2IIEA8gg.js +1 -0
  200. package/web/assets/material-theme-lighter-uhdI0v04.js +1 -0
  201. package/web/assets/material-theme-ocean-CHQ94UKr.js +1 -0
  202. package/web/assets/material-theme-palenight-B5W6OYN7.js +1 -0
  203. package/web/assets/mdc-4FfK5iWR.js +1 -0
  204. package/web/assets/mdx-DQZ5AkYe.js +1 -0
  205. package/web/assets/message-circle-Bc_EzZop.js +1 -0
  206. package/web/assets/min-dark-BSWPekZh.js +1 -0
  207. package/web/assets/min-light-DDpmG2fV.js +1 -0
  208. package/web/assets/mobile-remote-fallback-JvG4VcPg.js +1 -0
  209. package/web/assets/mobile-runtime-recovery-DBq1Dp1R.js +1 -0
  210. package/web/assets/monokai-B_bV9PQ9.js +1 -0
  211. package/web/assets/night-owl-DhmEMT88.js +1 -0
  212. package/web/assets/night-owl-light-eJ-hLW7d.js +1 -0
  213. package/web/assets/nord-Cb4Vim4T.js +1 -0
  214. package/web/assets/one-dark-pro-CLwyXe_n.js +1 -0
  215. package/web/assets/one-light-D7Lr4KcI.js +1 -0
  216. package/web/assets/panel-left-CVuoi3zo.js +1 -0
  217. package/web/assets/panel-top-CA2GX1Rj.js +1 -0
  218. package/web/assets/paperclip-BMRj9kRG.js +1 -0
  219. package/web/assets/pencil-CxA1IK0x.js +1 -0
  220. package/web/assets/php-CUREQQ7f.js +1 -0
  221. package/web/assets/pick-system-directory-BnIFt85A.js +1 -0
  222. package/web/assets/plastic-DQwYfKfQ.js +1 -0
  223. package/web/assets/play-N6mg4pFl.js +1 -0
  224. package/web/assets/poimandres-DRFjx7u4.js +1 -0
  225. package/web/assets/postcss-BXeXVLqQ.js +1 -0
  226. package/web/assets/progress-493FBtJ4.js +6 -0
  227. package/web/assets/pug-CQyGKZpv.js +1 -0
  228. package/web/assets/python-gzcpVVnB.js +1 -0
  229. package/web/assets/r-C5FwQflr.js +1 -0
  230. package/web/assets/react-bits-DQli9s7O.css +1 -0
  231. package/web/assets/red-DX1BQOs8.js +1 -0
  232. package/web/assets/regexp--aR2_iz7.js +1 -0
  233. package/web/assets/rolldown-runtime-B0Z9INg1.js +1 -0
  234. package/web/assets/rose-pine-aMsaMD1D.js +1 -0
  235. package/web/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
  236. package/web/assets/rose-pine-moon-DO-qXg-I.js +1 -0
  237. package/web/assets/sass-DXrisJhu.js +1 -0
  238. package/web/assets/save-CVL5N6eP.js +1 -0
  239. package/web/assets/scroll-area-CrWpxKGa.js +1 -0
  240. package/web/assets/scss-Davl4E3T.js +1 -0
  241. package/web/assets/send-DcLH_sg0.js +1 -0
  242. package/web/assets/separator-COSHUqEJ.js +1 -0
  243. package/web/assets/shellscript-CLZ0U2zV.js +1 -0
  244. package/web/assets/shield-check-BQHFfxVy.js +1 -0
  245. package/web/assets/shortcuts-BIzphxhz.js +1 -0
  246. package/web/assets/slack-dark-DnToyrRv.js +1 -0
  247. package/web/assets/slack-ochin-B2OO5cIa.js +1 -0
  248. package/web/assets/smithy-Dgaz7aur.js +1 -0
  249. package/web/assets/snazzy-light-4G7pJPwS.js +1 -0
  250. package/web/assets/solarized-dark-UdsmMDCL.js +1 -0
  251. package/web/assets/solarized-light-C1IUL_tW.js +1 -0
  252. package/web/assets/speech-session-UGYrCHlP.js +3 -0
  253. package/web/assets/speech-stream-text-Cwsgaoku.js +2 -0
  254. package/web/assets/speech-text-Js_tr4qo.js +1 -0
  255. package/web/assets/sql-b92rrcVl.js +1 -0
  256. package/web/assets/square-BZ3Bi3O-.js +1 -0
  257. package/web/assets/square-terminal-DpCa0gzM.js +1 -0
  258. package/web/assets/storage-BE5DCCG3.js +1 -0
  259. package/web/assets/stylus-B6D30XZt.js +1 -0
  260. package/web/assets/svelte-BfstjgUc.js +1 -0
  261. package/web/assets/synthwave-84-nFMaYfgc.js +1 -0
  262. package/web/assets/tag-Csd134FL.js +1 -0
  263. package/web/assets/tokyo-night-oM2G3aXe.js +1 -0
  264. package/web/assets/tool-labels-BJhLig5u.js +1 -0
  265. package/web/assets/tooltip-BIOYQmnq.js +1 -0
  266. package/web/assets/trash-2-mhzzyC6i.js +1 -0
  267. package/web/assets/ts-tags-Cckpt1jI.js +1 -0
  268. package/web/assets/tsx-JMDX3aQ7.js +1 -0
  269. package/web/assets/typescript-BAz-bF8J.js +1 -0
  270. package/web/assets/use-animation-visibility-C-GENY2Z.js +1 -0
  271. package/web/assets/use-i18n-B2uTAjsJ.js +1 -0
  272. package/web/assets/use-mobile-DikQ1IYz.js +1 -0
  273. package/web/assets/usePagePrimaryAction-Bw0OFTDZ.js +1 -0
  274. package/web/assets/utils-C8uzG5AZ.js +1 -0
  275. package/web/assets/vendor-dockview-D5adAaCg.css +1 -0
  276. package/web/assets/vendor-dockview-yY5mBM3U.js +1 -0
  277. package/web/assets/vendor-markdown-K9KdiImV.js +130 -0
  278. package/web/assets/vendor-markdown-plugins-DEcVZfaU.css +1 -0
  279. package/web/assets/vendor-markdown-plugins-Wv1dLaAO.js +263 -0
  280. package/web/assets/vendor-motion-XxgxfZSY.js +9 -0
  281. package/web/assets/vendor-react-CHuvPdJE.js +9 -0
  282. package/web/assets/vendor-router-Bw2aAdMs.js +4 -0
  283. package/web/assets/vendor-shiki-runtime-CxE5QolQ.js +153 -0
  284. package/web/assets/vendor-state-DE1O_s6m.js +1 -0
  285. package/web/assets/vendor-ui-DvrYggeS.js +1 -0
  286. package/web/assets/vendor-xyflow-CnjXtcyK.js +7 -0
  287. package/web/assets/vendor-xyflow-DLioOiRN.css +1 -0
  288. package/web/assets/vesper-DdrHHSXu.js +1 -0
  289. package/web/assets/vitesse-black-fwtXNY1n.js +1 -0
  290. package/web/assets/vitesse-dark-BZCL-v6S.js +1 -0
  291. package/web/assets/vitesse-light-VbXTXTou.js +1 -0
  292. package/web/assets/vue-3H7P6ncC.js +1 -0
  293. package/web/assets/vue-html-DZGW9MGR.js +1 -0
  294. package/web/assets/vue-vine-BECt67gq.js +1 -0
  295. package/web/assets/wasm-BnjxR4X6.js +1 -0
  296. package/web/assets/wasm-ByWQv1Qj.js +1 -0
  297. package/web/assets/web-preview-panel-Dp5aIwsV.js +556 -0
  298. package/web/assets/welcome-brand-W7Ox3fri.js +1 -0
  299. package/web/assets/wgsl-BsKzXJz4.js +1 -0
  300. package/web/assets/wit-DdvCle-K.js +1 -0
  301. package/web/assets/wrench-BqeVhocX.js +1 -0
  302. package/web/assets/x-bw26XDZM.js +1 -0
  303. package/web/assets/xml-CNfvW5JP.js +1 -0
  304. package/web/assets/yaml-rwi0_p6S.js +1 -0
  305. package/web/assets/zap-CFsp4Y1u.js +1 -0
  306. package/web/favicon.svg +25 -0
  307. package/web/icons.svg +24 -0
  308. package/web/index.html +82 -0
  309. package/web/memory-galaxy-background.webp +0 -0
  310. package/web/mobile-startup.html +322 -0
  311. package/web/notification-sw.js +13 -0
  312. package/web/tauri-pet.css +117 -0
  313. package/web/tauri-pet.html +16 -0
  314. package/web/tauri-pet.js +149 -0
  315. package/components/runtime/Pisper_Runtime_Node_0.5.37_linux_x86_64.tar.gz +0 -0
  316. package/components/runtime/Pisper_Runtime_Node_0.5.37_linux_x86_64.tar.gz.sig +0 -1
  317. package/components/tui/Pisper_TUI_Component_0.5.23_linux_x86_64.tar.gz +0 -0
  318. package/components/tui/Pisper_TUI_Component_0.5.23_linux_x86_64.tar.gz.sig +0 -1
@@ -0,0 +1,556 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnimatedList-_pbK4tS3.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/react-bits-DQli9s7O.css","assets/ShinyText-fuaKxKqJ.js","assets/WelcomeEffects-C9iQOeK6.js","assets/welcome-brand-W7Ox3fri.js","assets/index-BvVJkBr0.js","assets/vendor-router-Bw2aAdMs.js","assets/chat-api-B4XafR63.js","assets/api-CmPTEiOc.js","assets/button-XhIEgIsg.js","assets/use-i18n-B2uTAjsJ.js","assets/vendor-state-DE1O_s6m.js","assets/storage-BE5DCCG3.js","assets/use-mobile-DikQ1IYz.js","assets/dist-CISIC3_f.js","assets/es2015-0VLo_afz.js","assets/dist-DOR8kAEV.js","assets/separator-COSHUqEJ.js","assets/tooltip-BIOYQmnq.js","assets/panel-left-CVuoi3zo.js","assets/client-store-TRnjrXTz.js","assets/x-bw26XDZM.js","assets/input-D1QFzNMx.js","assets/index-DTit-2OA.css","assets/ClickSpark-BhxL8WOQ.js","assets/speech-text-Js_tr4qo.js","assets/vendor-markdown-K9KdiImV.js","assets/vendor-markdown-plugins-Wv1dLaAO.js","assets/vendor-shiki-runtime-CxE5QolQ.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/speech-stream-text-Cwsgaoku.js","assets/abort-signal-D0GPd1Mw.js","assets/speech-session-UGYrCHlP.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{t as a}from"./chat-api-B4XafR63.js";import{s as o,t as s}from"./api-CmPTEiOc.js";import{i as c,n as l,o as u,t as d}from"./button-XhIEgIsg.js";import{d as f,h as p,m,o as h,p as g,s as _,t as v,u as y}from"./use-i18n-B2uTAjsJ.js";import{c as b,i as x,o as S,r as C,s as w}from"./use-mobile-DikQ1IYz.js";import{a as T,i as E,n as D,r as O,s as k,t as A,u as j}from"./es2015-0VLo_afz.js";import{n as M}from"./dist-CISIC3_f.js";import{a as N,c as P,i as F,o as I,s as L,t as R}from"./collapsible-DjbBeRo0.js";import{t as z}from"./AppSelect-v2NUOzRf.js";import{i as B,n as ee,r as te,t as V}from"./progress-493FBtJ4.js";import{n as ne,r as re,t as ie}from"./scroll-area-CrWpxKGa.js";import{i as H,n as ae,t as U}from"./tooltip-BIOYQmnq.js";import{t as W}from"./utils-C8uzG5AZ.js";import{a as oe,i as se}from"./vendor-state-DE1O_s6m.js";import{t as ce}from"./storage-BE5DCCG3.js";import{t as G}from"./check-jIXqkGKr.js";import{t as le}from"./chevron-down-DT6AXwTP.js";import{t as ue}from"./circle-dot-rl11gaty.js";import{t as de}from"./code-xml-Z4K2ea1N.js";import{t as fe}from"./file-C8GNXmhJ.js";import{t as K}from"./loader-circle-72TYCcVQ.js";import{n as pe,r as me,t as he}from"./panel-top-CA2GX1Rj.js";import{t as ge}from"./panel-left-CVuoi3zo.js";import{t as _e}from"./paperclip-BMRj9kRG.js";import{t as ve}from"./pencil-CxA1IK0x.js";import{t as ye}from"./play-N6mg4pFl.js";import{t as be}from"./send-DcLH_sg0.js";import{a as xe,n as Se,o as Ce}from"./client-store-TRnjrXTz.js";import{t as we}from"./shield-check-BQHFfxVy.js";import{t as Te}from"./square-BZ3Bi3O-.js";import{t as Ee}from"./tag-Csd134FL.js";import{t as q}from"./trash-2-mhzzyC6i.js";import{t as De}from"./wrench-BqeVhocX.js";import{t as Oe}from"./x-bw26XDZM.js";import{t as ke}from"./input-D1QFzNMx.js";import{$ as Ae,A as je,At as Me,Et as Ne,F as Pe,G as Fe,I as Ie,J as Le,M as Re,Mt as ze,N as Be,Ot as Ve,P as He,Q as Ue,R as We,V as Ge,Z as Ke,bt as J,d as qe,et as Je,f as Ye,ht as Xe,j as Ze,jt as Qe,k as $e,kt as et,m as tt,mt as nt,n as rt,ot as it,t as at,u as ot,ut as st,vt as ct,wt as lt,xt as ut,z as Y}from"./index-BvVJkBr0.js";import{i as dt,o as ft,r as pt,s as mt,t as ht}from"./shortcuts-BIzphxhz.js";import{t as gt}from"./vendor-motion-XxgxfZSY.js";import{t as _t}from"./MarkdownMessage-ickiT81L.js";import{n as vt,t as yt}from"./alert-B7D8joCd.js";import{i as bt,r as xt}from"./tool-labels-BJhLig5u.js";import{t as St}from"./welcome-brand-W7Ox3fri.js";import{n as Ct,r as X,t as wt}from"./abort-signal-D0GPd1Mw.js";import{a as Tt,c as Et,i as Dt,l as Ot,n as kt,o as At,s as jt,t as Mt,u as Nt}from"./speech-session-UGYrCHlP.js";var Z=e(t(),1),Q=r(),Pt=Object.defineProperty,Ft=(e,t)=>Pt(e,`name`,{value:t,configurable:!0}),It=`Checkbox`,[Lt,Rt]=m(It),[zt,Bt]=Lt(It);function Vt(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[p,m]=f({prop:n,defaultProp:i??!1,onChange:c,caller:It}),[h,g]=Z.useState(null),[_,v]=Z.useState(null),y=Z.useRef(!1),[b,x]=Z.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:u,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:!Xt(i)&&i,isFormControl:S,bubbleInput:_,setBubbleInput:v};return(0,Q.jsx)(zt,{scope:t,...C,children:Yt(d)?d(C):r})}Ft(Vt,`CheckboxProvider`);var Ht=`CheckboxTrigger`,Ut=Z.forwardRef(Ft(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:m,onUserInteraction:h,isFormControl:_,bubbleInput:v}=Bt(Ht,e),y=u(i,d),b=Z.useRef(c);return Z.useEffect(()=>{let e=a?.form;if(e){let t=Ft(()=>f(b.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,f]),(0,Q.jsx)(p.button,{type:`button`,role:`checkbox`,"aria-checked":Xt(c)?`mixed`:c,"aria-required":l,"data-state":Zt(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:y,onKeyDown:g(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:g(n,e=>{h(),f(e=>Xt(e)?!0:!e),v&&_&&(m.current=e.isPropagationStopped(),m.current||e.stopPropagation())})})},`CheckboxTrigger`)),Wt=Z.forwardRef(Ft(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,Q.jsx)(Vt,{__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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ut,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Q.jsx)(Jt,{__scopeCheckbox:n})]})})},`Checkbox`)),Gt=`CheckboxIndicator`,Kt=Z.forwardRef(Ft(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=Bt(Gt,n);return(0,Q.jsx)(j,{present:r||Xt(a.checked)||a.checked===!0,children:(0,Q.jsx)(p.span,{"data-state":Zt(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),qt=`CheckboxBubbleInput`,Jt=Z.forwardRef(Ft(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:d,name:f,value:m,form:h,bubbleInput:_,setBubbleInput:v}=Bt(qt,e),b=u(r,v),x=y(i),S=Z.useRef(!1),C=Z.useRef(s),w=Z.useRef(o);Z.useEffect(()=>{let e=_;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=Xt(s),n.call(e,!Xt(s)&&s),e.dispatchEvent(t),S.current=!1}},[_,s,a,o]);let T=Z.useRef(!Xt(s)&&s);return(0,Q.jsx)(p.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??T.current,required:l,disabled:d,name:f,value:m,form:h,...n,tabIndex:-1,ref:b,onClick:g(t,e=>{S.current&&e.stopPropagation()}),style:{...n.style,...x,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function Yt(e){return typeof e==`function`}Ft(Yt,`isFunction`);function Xt(e){return e===`indeterminate`}Ft(Xt,`isIndeterminate`);function Zt(e){return Xt(e)?`indeterminate`:e?`checked`:`unchecked`}Ft(Zt,`getState`);var Qt=Object.defineProperty,$t=(e,t)=>Qt(e,`name`,{value:t,configurable:!0}),en=`Popover`,[tn,nn]=m(en,[b]),rn=b(),[an,on]=tn(en),sn=$t(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=rn(t),c=Z.useRef(null),[l,u]=Z.useState(!1),[d,p]=f({prop:r,defaultProp:i??!1,onChange:a,caller:en});return(0,Q.jsx)(w,{...s,children:(0,Q.jsx)(an,{scope:t,contentId:M(),triggerRef:c,open:d,onOpenChange:p,onOpenToggle:Z.useCallback(()=>p(e=>!e),[p]),hasCustomAnchor:l,onCustomAnchorAdd:Z.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Z.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),cn=`PopoverTrigger`,ln=Z.forwardRef($t(function(e,t){let{__scopePopover:n,...r}=e,i=on(cn,n),a=rn(n),o=u(t,i.triggerRef),s=(0,Q.jsx)(p.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":bn(i.open),...r,ref:o,onClick:g(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Q.jsx)(x,{asChild:!0,...a,children:s})},`PopoverTrigger`)),un=`PopoverPortal`,[dn,fn]=tn(un,{forceMount:void 0}),pn=$t(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=on(un,t);return(0,Q.jsx)(dn,{scope:t,forceMount:n,children:(0,Q.jsx)(j,{present:n||a.open,children:(0,Q.jsx)(E,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),mn=`PopoverContent`,hn=Z.forwardRef($t(function(e,t){let n=fn(mn,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=on(mn,e.__scopePopover);return(0,Q.jsx)(j,{present:r||a.open,children:a.modal?(0,Q.jsx)(_n,{...i,ref:t}):(0,Q.jsx)(vn,{...i,ref:t})})},`PopoverContent`)),gn=c(`PopoverContent.RemoveScroll`),_n=Z.forwardRef($t(function(e,t){let n=on(mn,e.__scopePopover),r=Z.useRef(null),i=u(t,r),a=Z.useRef(!1);return Z.useEffect(()=>{let e=r.current;if(e)return A(e)},[]),(0,Q.jsx)(D,{as:gn,allowPinchZoom:!0,children:(0,Q.jsx)(yn,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:g(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:g(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:g(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),vn=Z.forwardRef($t(function(e,t){let n=on(mn,e.__scopePopover),r=Z.useRef(!1),i=Z.useRef(!1);return(0,Q.jsx)(yn,{...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`)),yn=Z.forwardRef($t(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=on(mn,n),p=rn(n);return O(),(0,Q.jsx)(T,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Q.jsx)(k,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,Q.jsx)(S,{"data-state":bn(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 bn(e){return e?`open`:`closed`}$t(bn,`getState`);var xn=sn,Sn=ln,Cn=pn,wn=hn,Tn=l(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),En=l(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Dn=l(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),On=l(`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=l(`book-open`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]),An=l(`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`}]]),jn=l(`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`}]]),Mn=l(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Nn=l(`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`}]]),Pn=l(`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`}]]),Fn=l(`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`}]]),In=l(`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`}]]),Ln=l(`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`}]]),Rn=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),zn=l(`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`}]]),Bn=l(`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`}]]),Vn=l(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Hn=l(`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`}]]),Un=l(`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`}]]),Wn=l(`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`}]]),Gn=l(`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`}]]),Kn=l(`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`}]]),qn=l(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),Jn=l(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),Yn=l(`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`}]]),Xn=l(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Zn=l(`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`}]]),Qn=l(`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`}]]),$n=l(`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`}]]),er=l(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),tr=l(`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`}]]),nr=l(`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`}]]),rr=l(`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`}]]),ir=l(`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`}]]),ar=l(`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`}]]),or=l(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]);function sr(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 cr(e,t){let n=sr(e);return n===void 0?t:n}function lr(e){return e===`plan_update`||e===`task_list_update`}function ur(e){return e===`get_plan`||e===`get_task_list`}function dr(e){return e===`update_plan`||e===`update_task_list`}function fr(e){return ur(e)||dr(e)}function pr(e){return sr(e)}var mr=Object.freeze({messages:[],tools:[],approvals:[],agents:[],team:null,currentActivity:null,activityFeed:[],lifecycle:null,sessionTreeRevision:0,thinkingText:``,queuedInputs:[],hadQueuedInput:!1,plan:null,executionMode:null,runMode:null,contextUsage:null,sessionUsage:null,promptCache:null,compaction:null,streaming:!1,error:``,loaded:!1,messageStart:null,hasOlder:!1,olderCursor:null});function hr(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 gr(e,t){let n=e||mr,r=typeof t==`function`?t(n):{...n,...t};return hr(n,r)?r:n}function _r(e,t){return t===void 0?e||[]:Array.isArray(t)?t:[]}function vr(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 yr(e){return!!(e?.streaming||e?.recovering||e?.agents?.some(e=>[`queued`,`starting`,`running`].includes(e.status)))}function br(e){return!!(e&&(e.streaming||String(e.thinkingText||``).trim()||e.tools?.length||e.currentActivity?.type===`agent`||e.activityFeed?.some(e=>e.type===`agent`)||e.team))}function xr(e,t,n){return t&&br(n)?n:br(e.runActivity)?e.runActivity:null}function Sr(e,t){if(e&&(e.loaded||e.streaming||sr(e)!==void 0))return cr(e,null);let n=sr(t);return n===void 0?cr(e,null):n}function Cr(e,t={}){return!!e?.items?.length}var wr=10485760,Tr=20971520,Er=new Set([`txt`,`md`,`json`,`js`,`jsx`,`ts`,`tsx`,`css`,`html`,`xml`,`yaml`,`yml`,`csv`,`log`,`py`,`java`,`go`,`rs`,`sh`,`ps1`,`toml`,`sql`]),Dr=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),Or=new Set([`pdf`,`docx`,`pptx`,`xlsx`,`odt`,`odp`,`ods`,`rtf`,`epub`]),kr=[`image/*`,`text/*`,`application/json`,...[...Dr,...Er,...Or].map(e=>`.${e}`)].join(`,`);function Ar(e){let t=[...e?.files||[]];return t.length?t:[...e?.items||[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile?.()).filter(e=>!!e)}function jr(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 Mr(e){return e.toLowerCase().split(`.`).at(-1)||``}async function Nr(e,t){let n=[...e].slice(0,8),r=[];for(let e of n){if(e.size>wr)throw Error(t(`chat:attachments.nameExceedsThe10MBLimit`,{name:e.name}));let n=Mr(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/`)||Dr.has(n))r.push({...i,kind:`image`,data:await jr(e,t)});else if(e.type.startsWith(`text/`)||e.type===`application/json`||Er.has(n))r.push({...i,kind:`text`,text:await e.text()});else if(Or.has(n))r.push({...i,kind:`document`,extension:n,data:await jr(e,t)});else throw Error(t(`chat:attachments.nameIsNotSupportedChooseAnImageOrTextCodeFile`,{name:e.name}))}return r}function Pr(e){return e.split(/[\\/]/).filter(Boolean).at(-1)||e}function Fr(e){return[...e].map(e=>String(e||``).trim()).filter(Boolean).slice(0,8).map(e=>({id:`path:${e}`,kind:`path`,name:Pr(e),path:e}))}function Ir(e=[],t){let n=(0,Z.useCallback)((e,t)=>_(e,h(),t),[]),[r,i]=(0,Z.useState)(()=>[...e]),[a,o]=(0,Z.useState)(``),s=(0,Z.useRef)([...e]),c=(0,Z.useCallback)(e=>{s.current=e,i(e),t?.(e)},[t]),l=(0,Z.useCallback)(async e=>{try{o(``);let t=await Nr(e||[],n),r=[...s.current,...t].slice(0,8);if(r.filter(e=>e.kind!==`path`).reduce((e,t)=>e+(t.size||0),0)>Tr)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,Z.useCallback)(e=>{let t=Ar(e.clipboardData);t.length&&(e.preventDefault(),l(t))},[l]),removeAttachment:(0,Z.useCallback)(e=>{c(s.current.filter(t=>t.id!==e))},[c]),clearAttachments:(0,Z.useCallback)(()=>c([]),[c]),addAttachments:(0,Z.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,Z.useCallback)(e=>{o(e instanceof Error?e.message:String(e||``))},[])}}function Lr({className:e,...t}){return(0,Q.jsx)(Wt,{"data-slot":`checkbox`,className:W(`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,Q.jsx)(Kt,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(G,{})})})}function Rr({open:e,initialPath:t,onOpenChange:n,onSelect:r}){let{t:i}=v(),[a,o]=(0,Z.useState)(t||``),[c,l]=(0,Z.useState)(null),[u,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),_=(0,Z.useRef)(0),y=(0,Z.useCallback)(async e=>{let t=++_.current;m(!0),g(``);try{let n=await s(`/api/workspace-entries?path=${encodeURIComponent(e.trim())}`);if(t!==_.current)return;o(n.path),l(n),f([])}catch(e){if(t!==_.current)return;g(e instanceof Error?e.message:String(e))}finally{t===_.current&&m(!1)}},[]);(0,Z.useEffect)(()=>{if(!e){_.current+=1;return}o(t||``),l(null),f([]),y(t||``)},[y,t,e]);let b=e=>{e.preventDefault(),y(a)},x=(e,t)=>{f(n=>t?[...n.filter(t=>t!==e),e].slice(-8):n.filter(t=>t!==e))};return(0,Q.jsx)($e,{open:e,onOpenChange:n,children:(0,Q.jsxs)(je,{className:`max-w-[calc(100vw-24px)]! gap-0 overflow-hidden p-0 sm:max-w-[680px]!`,children:[(0,Q.jsxs)(Be,{className:`border-b px-4 py-3 pr-12`,children:[(0,Q.jsx)(He,{children:i(`chat:pathAttachmentPicker.title`)}),(0,Q.jsx)(Ze,{children:i(`chat:pathAttachmentPicker.description`)})]}),(0,Q.jsxs)(`form`,{className:`flex min-w-0 items-center gap-2 px-4 py-3`,onSubmit:b,children:[(0,Q.jsx)(d,{type:`button`,variant:`outline`,size:`icon`,title:i(`common:workspacePicker.parentFolder`),"aria-label":i(`common:workspacePicker.parentFolder`),disabled:p||!c?.parent,onClick:()=>c?.parent&&void y(c.parent),children:(0,Q.jsx)(re,{})}),(0,Q.jsx)(ke,{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,Q.jsxs)(d,{type:`submit`,variant:`secondary`,disabled:p||!a.trim(),children:[p?(0,Q.jsx)(K,{className:`animate-spin`}):(0,Q.jsx)(Me,{}),i(`common:workspacePicker.go`)]})]}),(0,Q.jsx)(ie,{className:`h-[min(400px,50dvh)] border-y bg-muted/20`,children:(0,Q.jsxs)(`div`,{className:`p-2`,children:[c?.directories.map(e=>(0,Q.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:p,onClick:()=>void y(e.path),children:[(0,Q.jsx)(ne,{className:`size-4 text-content-muted`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(Me,{className:`size-4 text-content-muted`})]},e.path)),c?.files.map(e=>{let t=u.includes(e.path);return(0,Q.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,Q.jsx)(fe,{className:`size-4 text-content-muted`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(Lr,{checked:t,"aria-label":i(`chat:pathAttachmentPicker.selectName`,{name:e.name}),onCheckedChange:t=>x(e.path,t===!0)})]},e.path)}),p&&(0,Q.jsxs)(`div`,{className:`flex h-32 items-center justify-center gap-2 text-content-muted`,children:[(0,Q.jsx)(K,{className:`size-4 animate-spin`}),(0,Q.jsx)(`span`,{children:i(`common:workspacePicker.readingFolder`)})]}),!p&&c&&!c.directories.length&&!c.files.length&&(0,Q.jsx)(`div`,{className:`flex h-32 items-center justify-center text-content-muted`,children:i(`chat:pathAttachmentPicker.empty`)})]})}),h&&(0,Q.jsxs)(yt,{variant:`destructive`,className:`mx-4 mt-3 w-auto`,children:[(0,Q.jsx)(Xe,{}),(0,Q.jsx)(vt,{children:h})]}),(0,Q.jsxs)(Re,{className:`m-0 border-t-0 bg-transparent px-4 py-3`,children:[(0,Q.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:i(`common:ui.cancel`)}),(0,Q.jsx)(d,{type:`button`,variant:`secondary`,disabled:!u.length,onClick:()=>{u.length&&(r(u),n(!1))},children:i(`chat:pathAttachmentPicker.attachCount`,{count:u.length})})]})]})})}function zr({cwd:e,selection:t}){let{t:n}=v(),r=Se(),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=async()=>{if(r){o.current?.click();return}if(window.pisperDesktop?.pickFiles){try{let n=await window.pisperDesktop.pickFiles(e);t.addAttachments(Fr(n||[]))}catch(e){t.setError(e)}return}a(!0)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{ref:o,type:`file`,className:`hidden`,accept:kr,multiple:!0,"aria-label":n(`chat:focusSession.addAttachment`),onChange:e=>{let n=[...e.currentTarget.files||[]];e.currentTarget.value=``,n.length&&t.addFiles(n)}}),(0,Q.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,Q.jsx)(_e,{size:17}),t.attachments.length>0&&(0,Q.jsx)(`i`,{children:t.attachments.length})]}),(0,Q.jsx)(Rr,{open:i,initialPath:e,onOpenChange:a,onSelect:e=>t.addAttachments(Fr(e))})]})}function Br({attachments:e,onRemove:t,compact:n=!1}){let{t:r}=v();return e.length?(0,Q.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,Q.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,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``}):(0,Q.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,Q.jsx)(fe,{size:13})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:e.name}),(0,Q.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`?``:` · ${We(e.size)}`,e.truncated?` · ${r(`chat:focusSession.truncated`)}`:``]})]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":r(`chat:focusSession.removeName`,{name:e.name}),onClick:()=>t(String(e.id||``)),children:(0,Q.jsx)(Oe,{size:12})})]},e.id))}):null}function Vr({open:e,sessionId:t,onClose:n,onSelect:r,onCommandSelect:i}){let{t:o}=v(),c=Ie(e=>e.capabilities),l=nt(c,`workflows`),[u,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(`all`),[h,g]=(0,Z.useState)(``),[_,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)({}),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{if(!e)return;let n=!0;return m(`all`),g(``),y(null),x({}),C(!0),T(``),Promise.all([a.getSessionCommands(t),l?s(`/api/workflows`):Promise.resolve({workflows:[]}),s(`/api/plugins?sessionId=${encodeURIComponent(t)}`)]).then(([e,t,r])=>{if(!n)return;let i=new Set(r.callableToolNames||[]);f([...(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?bt(t,o):String(t.label||t.name),description:t.id?xt(t,o):t.description,inputs:[],sourceName:e.name})))])}).catch(e=>{n&&(f([]),T(e instanceof Error?e.message:String(e)))}).finally(()=>n&&C(!1)),()=>{n=!1}},[e,t,o,l]);let E=(0,Z.useMemo)(()=>({all:u.length,prompt:u.filter(e=>e.kind===`prompt`).length,skill:u.filter(e=>e.kind===`skill`).length,tool:u.filter(e=>e.kind===`tool`).length,workflow:u.filter(e=>e.kind===`workflow`).length}),[u]),D=(0,Z.useMemo)(()=>{let e=h.trim().toLowerCase();return u.filter(t=>(p===`all`||t.kind===p)&&(!e||`${t.name} ${t.id} ${t.description} ${t.kind===`tool`?t.sourceName:``}`.toLowerCase().includes(e)))},[p,h,u]),O=e=>{let t=e;m(t),_&&t!==`all`&&_.kind!==t&&y(null)},k=e=>{y(e),x(Object.fromEntries(e.inputs.map(e=>[e.name,e.defaultValue??``])))};return(0,Q.jsx)($e,{open:e,onOpenChange:e=>!e&&n(),children:(0,Q.jsxs)(je,{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,Q.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,Q.jsxs)(`div`,{children:[(0,Q.jsx)(He,{children:o(`chat:resourcePicker.title`)}),(0,Q.jsx)(Ze,{children:o(`chat:resourcePicker.description`)})]}),(0,Q.jsx)(d,{size:`icon-sm`,variant:`ghost`,"aria-label":o(`chat:resourcePicker.close`),onClick:n,children:(0,Q.jsx)(Oe,{})})]}),(0,Q.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,Q.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,Q.jsx)(ot,{value:p,onValueChange:O,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 ${l?`[&_[data-slot='tabs-list']]:grid-cols-[repeat(5,minmax(0,1fr))]`:`[&_[data-slot='tabs-list']]:grid-cols-[repeat(4,minmax(0,1fr))]`}`,children:(0,Q.jsxs)(qe,{"aria-label":o(`chat:resourcePicker.categories`),children:[(0,Q.jsxs)(Ye,{value:`all`,children:[o(`chat:resourcePicker.all`),(0,Q.jsx)(`small`,{children:E.all})]}),(0,Q.jsxs)(Ye,{value:`prompt`,children:[o(`chat:resourcePicker.prompt`),(0,Q.jsx)(`small`,{children:E.prompt})]}),(0,Q.jsxs)(Ye,{value:`skill`,children:[o(`chat:resourcePicker.skill`),(0,Q.jsx)(`small`,{children:E.skill})]}),(0,Q.jsxs)(Ye,{value:`tool`,children:[o(`chat:resourcePicker.tool`),(0,Q.jsx)(`small`,{children:E.tool})]}),l&&(0,Q.jsxs)(Ye,{value:`workflow`,children:[o(`chat:resourcePicker.workflow`),(0,Q.jsx)(`small`,{children:E.workflow})]})]})}),(0,Q.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,Q.jsx)(ct,{size:15}),(0,Q.jsx)(`input`,{autoFocus:!0,value:h,onChange:e=>g(e.target.value),placeholder:o(`chat:resourcePicker.search`)})]}),(0,Q.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:[D.map(e=>{let t=e.kind===`prompt`?Ln:e.kind===`skill`?B:e.kind===`tool`?De:xe;return(0,Q.jsxs)(`button`,{type:`button`,className:_?.kind===e.kind&&_.id===e.id?`active`:``,onClick:()=>k(e),children:[(0,Q.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,Q.jsx)(t,{size:15})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:e.name}),(0,Q.jsx)(`small`,{children:e.description})]}),(0,Q.jsx)(`em`,{children:e.kind===`prompt`?o(`chat:resourcePicker.prompt`):e.kind===`skill`?`Skill`:e.kind===`tool`?o(`chat:resourcePicker.tool`):o(`chat:resourcePicker.workflow`)})]},`${e.kind}:${e.id}`)}),!D.length&&(0,Q.jsx)(`p`,{children:S?o(`chat:resourcePicker.loading`):w||o(`chat:resourcePicker.empty`)})]})]}),(0,Q.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:_?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`strong`,{children:_.name}),(0,Q.jsx)(`p`,{children:_.description||o(`chat:resourcePicker.noDescription`)})]}),_.kind===`workflow`&&_.inputs.length>0&&(0,Q.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:_.inputs.map(e=>(0,Q.jsxs)(`label`,{children:[(0,Q.jsxs)(`span`,{children:[e.label,e.required?` *`:``]}),e.type===`boolean`?(0,Q.jsx)(`input`,{type:`checkbox`,checked:!!b[e.name],onChange:t=>x(n=>({...n,[e.name]:t.target.checked}))}):(0,Q.jsx)(ke,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(b[e.name]??``),onChange:t=>x(n=>({...n,[e.name]:t.target.value}))})]},e.id))}),_.kind===`prompt`&&_.argumentHint&&(0,Q.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:_.argumentHint}),(0,Q.jsx)(d,{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(_){if(_.kind===`prompt`){i(_.invocation||`/${_.name}`),n();return}r({kind:_.kind,resourceId:_.id,resourceName:_.name,arguments:_.kind===`workflow`?b:void 0,behavior:_.kind===`workflow`?`background`:`foreground`}),n()}},children:_.kind===`prompt`?o(`chat:resourcePicker.insertPrompt`):o(`chat:resourcePicker.useResource`)})]}):(0,Q.jsx)(`p`,{children:o(`chat:resourcePicker.chooseResource`)})})]})]})})}var Hr=64,Ur=new Map;function Wr(e,t){let n=t.match(/^\/[^\s]*(?:\s+([\s\S]*))?$/),r=(n?n[1]||``:t).trim();return`${e}${r?` ${r}`:` `}`}function Gr(e){return{text:e?.text||``,attachments:[...e?.attachments||[]]}}function Kr(e){return Gr(Ur.get(e))}function qr(e,t){if(!e)return;let n={...Kr(e),...t};if(n.attachments=[...n.attachments],Ur.delete(e),!(!n.text&&!n.attachments.length))for(Ur.set(e,n);Ur.size>Hr;){let e=Ur.keys().next().value;if(typeof e!=`string`)break;Ur.delete(e)}}function Jr(e){Ur.delete(e)}function Yr(e){let t=(0,Z.useRef)(Kr(e)),[n,r]=(0,Z.useState)(t.current.text),i=(0,Z.useCallback)(t=>qr(e,{attachments:t}),[e]),a=Ir(t.current.attachments,i),o=a.replaceAttachments,s=a.clearAttachments;return(0,Z.useEffect)(()=>{let t=Kr(e);r(t.text),o(t.attachments)},[o,e]),{value:n,updateValue:(0,Z.useCallback)(t=>{r(t),qr(e,{text:t})},[e]),selection:a,clearDraft:(0,Z.useCallback)(()=>{r(``),s(),Jr(e)},[s,e])}}function Xr({sessionId:e,value:t,onChange:n,inputRef:r}){let{t:i,language:o}=v(),s=(0,Z.useId)(),c=t.match(/^\/([^\s]*)$/),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(0),b=!!(c&&l!==t),x=c?.[1]||``;(0,Z.useEffect)(()=>{u(``),f(null),g(!1)},[e]),(0,Z.useEffect)(()=>{if(!b||d)return;let t=!0;return m(!0),g(!1),a.getSessionCommands(e).then(e=>{t&&f(e.commands||[])}).catch(()=>{t&&(f([]),g(!0))}).finally(()=>t&&m(!1)),()=>{t=!1}},[d,b,e]);let S=(0,Z.useMemo)(()=>{let e=x.toLocaleLowerCase(o);return e?(d||[]).filter(t=>`${t.invocation} ${t.name} ${t.description}`.toLocaleLowerCase(o).includes(e)):d||[]},[d,o,x]);(0,Z.useEffect)(()=>{y(0)},[x,d]);let C=()=>{u(t)},w=e=>{let i=Wr(e.invocation,t);n(i),u(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,Z.useEffect)(()=>{if(!b)return;let e=e=>{if(document.activeElement===r.current){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),C();return}S.length&&(e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),y(e=>(e+1)%S.length)):e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),y(e=>(e-1+S.length)%S.length)):(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),w(S[Math.min(_,S.length-1)])))}};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)});let T={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,Q.jsx)(Q.Fragment,{children:b&&(0,Q.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:s,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,Q.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:[S.map((e,t)=>{let n=e.source===`prompt`?Ln:B;return(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===_,className:t===_?`active`:``,onMouseEnter:()=>y(t),onMouseDown:e=>e.preventDefault(),onClick:()=>w(e),children:[(0,Q.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,Q.jsx)(n,{size:15})}),(0,Q.jsxs)(`span`,{className:`composer-command-copy`,children:[(0,Q.jsxs)(`strong`,{children:[e.invocation,e.argumentHint&&(0,Q.jsxs)(`small`,{children:[` `,e.argumentHint]})]}),(0,Q.jsx)(`small`,{children:e.description||i(`chat:commands.noDescription`)})]}),(0,Q.jsxs)(`em`,{children:[e.source===`prompt`?i(`chat:commands.prompt`):i(`chat:commands.skill`),` · `,T[e.scope]]})]},e.invocation)}),!S.length&&(0,Q.jsx)(`p`,{children:i(p?`chat:commands.loading`:h?`chat:commands.loadError`:`chat:commands.empty`)})]})})})}var Zr=[`attachment`,`resource`,`visual`,`model`,`permission`,`run-mode`,`thinking`,`commands`,`git-changes`,`compact-context`,`session-actions`],Qr=new Set(Zr),$r={inline:[...Zr],overflow:[]};function ei(e){return Array.isArray(e)?e.filter((e,t,n)=>typeof e==`string`&&Qr.has(e)&&n.indexOf(e)===t):[]}function ti(e){let t=e&&typeof e==`object`?e:{},n=ei(t.inline),r=new Set(n),i=ei(t.overflow).filter(e=>!r.has(e)),a=new Set([...n,...i]);for(let e of Zr)a.has(e)||n.push(e);return{inline:n,overflow:i}}function ni(e,t,n){let r=ti(e),i=r.inline.filter(e=>e!==t),a=r.overflow.filter(e=>e!==t);return n===`inline`?i.push(t):a.push(t),{inline:i,overflow:a}}function ri(e,t,n){let r=ti(e),i=r.inline.includes(t)?`inline`:`overflow`,a=[...r[i]],o=a.indexOf(t),s=o+n;return o<0||s<0||s>=a.length?r:([a[o],a[s]]=[a[s],a[o]],{...r,[i]:a})}function ii(e,t,n){let r=ti(e),i=new Set(t),a=r.inline.filter(e=>i.has(e)),o=r.overflow.filter(e=>i.has(e)),s=Number.isFinite(n)?Math.max(0,Math.floor(n)):a.length,c=a.slice(0,s),l=a.slice(s);return{inline:c,automaticallyOverflowed:l,overflow:[...l,...o]}}var ai=e(n(),1),oi=8,si=8;function ci({open:e,anchorRef:t,menuRef:n,placement:r=`top`,align:i=`start`,className:a,role:o,ariaLabel:s,onClose:c,children:l}){return(0,Z.useEffect)(()=>{if(!e||!c)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),c())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,c]),(0,Z.useLayoutEffect)(()=>{if(!e)return;let a=()=>{let e=n.current,a=t.current;if(!e||!a)return;let o=a.getBoundingClientRect(),s=window.innerWidth-oi,c=window.innerHeight-oi,l=Math.max(120,r===`top`?o.top-si-oi:c-o.bottom-si);e.style.maxHeight=`${l}px`,e.style.overflowY=`auto`,r===`top`?(e.style.top=`auto`,e.style.bottom=`${window.innerHeight-o.top+si}px`):(e.style.bottom=`auto`,e.style.top=`${o.bottom+si}px`),i===`end`?(e.style.left=`auto`,e.style.right=`${window.innerWidth-o.right}px`):(e.style.right=`auto`,e.style.left=`${o.left}px`);let u=e.getBoundingClientRect();u.right>s?(e.style.right=`auto`,e.style.left=`${Math.max(oi,s-u.width)}px`):u.left<oi&&(e.style.right=`auto`,e.style.left=`${oi}px`)};return a(),window.addEventListener(`resize`,a),window.addEventListener(`scroll`,a,!0),()=>{window.removeEventListener(`resize`,a),window.removeEventListener(`scroll`,a,!0)}},[e,t,n,r,i]),e?(0,ai.createPortal)((0,Q.jsx)(`div`,{ref:n,className:a,style:{position:`fixed`,zIndex:65},role:o,"aria-label":s,children:l}),document.body):null}function li({open:e,children:t,label:n,trayId:r,anchorRef:i,menuRef:a}){return(0,Q.jsx)(ci,{open:e,anchorRef:i,menuRef:a,placement:`top`,align:`start`,className:`composer-tool-tray-shell w-max max-w-[calc(100vw-16px)] overflow-visible rounded-[var(--r-md)] border border-[var(--stroke)] bg-[var(--solid)] p-1.5 shadow-[0_18px_42px_-18px_var(--menu-shadow)] motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1`,role:`toolbar`,ariaLabel:n,children:(0,Q.jsx)(`div`,{id:r,className:`composer-tool-tray flex max-h-[min(52vh,360px)] min-h-9 w-max max-w-full min-w-0 flex-wrap items-center gap-1 overflow-x-hidden overflow-y-auto overscroll-contain`,children:t})})}var ui=oe()(se(e=>({layout:$r,setToolLocation:(t,n)=>e(e=>({layout:ni(e.layout,t,n)})),moveTool:(t,n)=>e(e=>({layout:ri(e.layout,t,n)})),resetLayout:()=>e({layout:$r})}),{name:`pisper-composer-toolbar`,version:1,partialize:({layout:e})=>({layout:e}),merge:(e,t)=>({...t,layout:ti(e?.layout)})}));function di(e,t){return e.inline.join(`\0`)===t.inline.join(`\0`)&&e.overflow.join(`\0`)===t.overflow.join(`\0`)}function fi({ids:e,location:t,labels:n,onMove:r,onReorder:i}){let{t:a}=v(),o=t===`inline`?`overflow`:`inline`,s=t===`inline`?Tn:Xn,c=a(t===`inline`?`chat:focusSession.moveShortcutToOverflow`:`chat:focusSession.pinShortcutToComposer`);return(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:e.map((t,l)=>(0,Q.jsxs)(`div`,{className:`flex min-h-11 min-w-0 items-center gap-2 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px] font-semibold text-[var(--text)]`,children:n[t]}),(0,Q.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,title:a(`chat:focusSession.moveShortcutEarlier`),"aria-label":a(`chat:focusSession.moveShortcutEarlierName`,{name:n[t]}),disabled:l===0,onClick:()=>i(t,-1),children:(0,Q.jsx)(re,{})}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,title:a(`chat:focusSession.moveShortcutLater`),"aria-label":a(`chat:focusSession.moveShortcutLaterName`,{name:n[t]}),disabled:l===e.length-1,onClick:()=>i(t,1),children:(0,Q.jsx)(En,{})}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,title:c,"aria-label":a(`chat:focusSession.moveShortcutName`,{name:n[t],location:c}),onClick:()=>r(t,o),children:(0,Q.jsx)(s,{})})]})]},t))})}function pi({labels:e}){let{t}=v(),n=ui(e=>e.layout),r=ui(e=>e.setToolLocation),i=ui(e=>e.moveTool),a=ui(e=>e.resetLayout);return(0,Q.jsxs)($e,{children:[(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`grid size-9 min-w-9 place-items-center rounded-[var(--r-sm)] border border-transparent bg-[var(--surface-muted)] text-[var(--text-muted)] hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)]`,title:t(`chat:focusSession.customizeShortcuts`),"aria-label":t(`chat:focusSession.customizeShortcuts`),children:(0,Q.jsx)(er,{size:16})})}),(0,Q.jsxs)(je,{className:`gap-4 rounded-[var(--r-md)] p-4`,style:{width:`min(640px, calc(100vw - 24px))`,maxWidth:640},children:[(0,Q.jsxs)(Be,{className:`pr-9`,children:[(0,Q.jsx)(He,{children:t(`chat:focusSession.customizeShortcuts`)}),(0,Q.jsx)(Ze,{className:`sr-only`,children:t(`chat:focusSession.customizeShortcutsDescription`)})]}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-2 gap-5 max-[650px]:grid-cols-1`,children:[(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`mb-2 text-[12px] font-bold text-[var(--text-soft)]`,children:t(`chat:focusSession.composerShortcuts`)}),(0,Q.jsx)(fi,{ids:n.inline,location:`inline`,labels:e,onMove:r,onReorder:i})]}),(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`mb-2 text-[12px] font-bold text-[var(--text-soft)]`,children:t(`chat:focusSession.overflowShortcuts`)}),n.overflow.length?(0,Q.jsx)(fi,{ids:n.overflow,location:`overflow`,labels:e,onMove:r,onReorder:i}):(0,Q.jsx)(`p`,{className:`border-y border-[var(--stroke-soft)] py-3 text-[12px] text-[var(--text-muted)]`,children:t(`chat:focusSession.noOverflowShortcuts`)})]})]}),(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-[var(--stroke-soft)] pt-3`,children:(0,Q.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,disabled:di(n,$r),onClick:a,children:[(0,Q.jsx)(N,{}),t(`chat:focusSession.restoreShortcutDefaults`)]})})]})]})}function mi({...e}){return(0,Q.jsx)(xn,{"data-slot":`popover`,...e})}function hi({...e}){return(0,Q.jsx)(Sn,{"data-slot":`popover-trigger`,...e})}function gi({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,Q.jsx)(Cn,{children:(0,Q.jsx)(wn,{"data-slot":`popover-content`,align:t,sideOffset:n,className:W(`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 _i({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`popover-title`,className:W(`font-medium`,e),...t})}var vi={completed:`completed`,in_progress:`running`,blocked:`blocked`,pending:`pending`};function yi(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 bi(e){return e===`completed`?G:e===`in_progress`?ue:e===`blocked`?Gn:ue}function xi({status:e,t}){let n=bi(e),r=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,Q.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)] ${vi[String(e)]||`pending`}`,children:[(0,Q.jsx)(n,{size:12}),r]})}function Si({item:e,current:t,t:n}){return(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-[8px] min-w-0`,children:[(0,Q.jsx)(xi,{status:e.blocked?`blocked`:e.status,t:n}),(0,Q.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,Q.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,Q.jsx)(ar,{size:11}),e.assignee]}):e.status!==`completed`&&(0,Q.jsx)(`span`,{className:`flex-none text-[var(--text-muted)] text-[11px] [font-style:italic]`,children:n(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-[5px] [padding-left:2px] text-[var(--text-muted)] text-[11px]`,children:[(0,Q.jsx)(Gn,{size:11}),n(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})]})]})}function Ci({plan:e,header:t,collapsible:n=!1}){let{t:r}=v(),i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(!0),s=e?.items||[],c=yi(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,Z.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Un,{className:`flex-none text-[var(--star-strong)]`,size:15}),(0,Q.jsx)(`strong`,{children:r(`chat:planBoard.progress`,{completed:l,total:s.length})}),p?(0,Q.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,Q.jsxs)(`span`,{className:`plan-board-counts @max-[470px]:hidden inline-flex flex-none items-center gap-[8px]`,children:[u>0&&(0,Q.jsx)(`span`,{children:r(`chat:planBoard.countInProgress`,{count:u})}),d>0&&(0,Q.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,Q.jsx)(le,{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,Q.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,Q.jsx)(Si,{item:e,current:e.id===f,t:r},e.id))});return n?(0,Q.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,Q.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,Q.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,Q.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 wi=(0,Z.memo)(Ci);function Ti({usage:e,plan:t,compact:n=!1}){let{t:r}=v(),i=Math.max(0,Number(e?.processedTokens)||0),a=Array.isArray(t?.items)?t.items:[],o=a.filter(e=>e?.status===`completed`).length,s=a.length?r(`chat:planBoard.progress`,{completed:o,total:a.length}):``,c=Number(e?.cacheHitRate),l=e?.cacheHitRate!=null&&Number.isFinite(c),u=l?`${Math.round(Math.max(0,c))}%`:`—`,d=l?``:r(`chat:focusSession.cacheHitRateUnavailable`),f=[r(`chat:focusSession.sessionUsageDetail`,{processed:Y(i),input:Y(e?.input),output:Y(e?.output),cacheRead:Y(e?.cacheRead),cacheWrite:Y(e?.cacheWrite),reasoning:Y(e?.reasoning),requests:Math.max(0,Number(e?.requests)||0)}),d,s].filter(Boolean).join(`
3
+ `);return(0,Q.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] ${n?`[&_small]:hidden gap-[7px]`:``}`,title:f,"aria-label":f,children:[!n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Pn,{size:12}),(0,Q.jsx)(`small`,{children:r(`chat:focusSession.cacheHitRate`)}),(0,Q.jsx)(`strong`,{children:u})]}),(0,Q.jsx)(`i`,{"aria-hidden":`true`})]}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)($n,{size:12}),(0,Q.jsx)(`small`,{children:r(`chat:focusSession.processedTokens`)}),(0,Q.jsx)(`strong`,{children:Y(i)})]}),s&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`i`,{"aria-hidden":`true`}),(0,Q.jsxs)(mi,{children:[(0,Q.jsx)(hi,{asChild:!0,children:(0,Q.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:r(`chat:planBoard.openCurrentPlan`,{progress:s}),"aria-label":r(`chat:planBoard.openCurrentPlan`,{progress:s}),children:[(0,Q.jsx)(Wn,{size:12}),(0,Q.jsx)(`strong`,{children:s})]})}),(0,Q.jsx)(gi,{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,Q.jsx)(wi,{plan:t??null})})]})]})]})}function Ei({usage:e,onThresholdChange:t,compact:n=!1}){let{t:r}=v(),i=Number(e?.contextWindow)||0,a=e?.compactAtPercent==null?80:Number(e.compactAtPercent),o=Number.isFinite(a)?Math.round(a):80,[s,c]=(0,Z.useState)(o),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),p=(0,Z.useRef)(o),m=(0,Z.useRef)(void 0);if((0,Z.useEffect)(()=>{window.clearTimeout(m.current),c(o),p.current=o},[o]),(0,Z.useEffect)(()=>()=>window.clearTimeout(m.current),[]),!i)return null;let h=e?.percent!=null&&Number.isFinite(Number(e.percent)),g=h?Math.max(0,Number(e.percent)):null,_=g==null?null:Math.round(g),y=Math.max(50,o-15),b=g==null?`unknown`:g>=o?`danger`:g>=y?`warning`:`normal`,x=h?e.estimated?r(`chat:focusSession.estimatedContextUsageTokensLimitTokensPercent`,{tokens:Y(e.tokens),limit:Y(i),percent:_}):r(`chat:focusSession.contextUsageTokensLimitTokensPercent`,{tokens:Y(e.tokens),limit:Y(i),percent:_}):r(`chat:focusSession.contextUsageWillUpdateAfterTheNextModelResponseLimitLimitTokens`,{limit:Y(i)}),S=e?.autoCompactEnabled?r(`chat:focusSession.autoCompactionThresholdAboutPercent`,{percent:o}):r(`chat:focusSession.automaticContextCompactionIsDisabled`),C=e?.autoCompactEnabled&&e.compactionCapacityPercent!=null?r(`chat:focusSession.contextUsageToCompactionTokensPercent`,{percent:Math.round(Number(e.compactionCapacityPercent)),tokens:Y(e.remainingBeforeCompaction)}):``,w=`${x} · ${S}${C?` · ${C}`:``}`,T=`${e?.tokens==null?`—`:Y(e.tokens)} / ${Y(i)}`,E=async e=>{let n=Math.min(95,Math.max(50,Math.round(e)));if(c(n),!(!t||n===p.current)){u(!0),f(``);try{await t(n),p.current=n}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}},D=e=>{window.clearTimeout(m.current),c(e),m.current=window.setTimeout(()=>void E(e),250)},O=e=>{window.clearTimeout(m.current),E(e)};return(0,Q.jsxs)(mi,{children:[(0,Q.jsx)(hi,{asChild:!0,children:(0,Q.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)] ${n?`!h-11 grid-cols-[auto_auto] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] px-2 opacity-100 [&.warning_>_span_strong]:text-[var(--warning-strong)] [&.danger_>_span_strong]:text-[var(--danger)]`:``} ${b}`,"aria-label":w,title:w,children:[(0,Q.jsx)(Rn,{size:12}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:n?_==null?`—`:`${_}%`:T}),!n&&(0,Q.jsx)(`small`,{children:_==null?`—`:`${_}%`})]}),!n&&(0,Q.jsx)(`i`,{"aria-hidden":`true`,children:(0,Q.jsx)(`b`,{style:{width:`${Math.min(100,g||0)}%`}})})]})}),(0,Q.jsxs)(gi,{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:[C&&(0,Q.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:C}),(0,Q.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,Q.jsx)(`span`,{children:r(`chat:focusSession.autoCompactionThreshold`)}),(0,Q.jsxs)(`output`,{children:[s,`%`]})]}),(0,Q.jsx)(`input`,{type:`range`,min:`50`,max:`95`,step:`1`,value:s,"aria-label":r(`chat:focusSession.autoCompactionThreshold`),disabled:l,onChange:e=>D(Number(e.currentTarget.value)),onBlur:e=>O(Number(e.currentTarget.value)),onPointerUp:e=>O(Number(e.currentTarget.value)),onKeyUp:e=>{[`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`].includes(e.key)&&O(Number(e.currentTarget.value))}}),(0,Q.jsxs)(`div`,{className:`context-threshold-scale flex items-center justify-between text-[var(--text-tertiary)] text-[10px]`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{children:`50%`}),(0,Q.jsx)(`span`,{children:`95%`})]}),(0,Q.jsx)(`small`,{className:d?`error`:``,children:d||(l?r(`chat:focusSession.savingCompactionThreshold`):`\xA0`)})]})]})}function Di({value:e,models:t,onChange:n,disabled:r,compact:i=!1}){let{t:a}=v(),o=t.find(t=>t.key===e),s=o?`${o.providerName} · ${o.label}`:e.split(`/`).at(-1);return(0,Q.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)] 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,Q.jsx)(ze,{size:i?11:14}),(0,Q.jsxs)(z,{value:e,onChange:e=>n(e.target.value),disabled:r||t.length===0,"aria-label":a(`chat:focusSession.currentChatModel`),children:[!o&&(0,Q.jsx)(`option`,{value:e,children:e.split(`/`).at(-1)}),t.map(e=>(0,Q.jsxs)(`option`,{value:e.key,children:[e.providerName,` · `,e.label]},e.key))]})]})}function Oi({value:e,levels:t,status:n=`supported`,message:r=``,onChange:i,disabled:a,compact:o=!1}){let{t:s}=v(),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,Q.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)] 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,Q.jsx)(Qe,{size:o?11:14}),(0,Q.jsxs)(z,{value:c,onChange:e=>i(e.target.value),disabled:a||l||!u||d,"aria-label":s(`chat:focusSession.currentThinkingLevel`),children:[!t.includes(c)&&(0,Q.jsx)(`option`,{value:c,children:c}),t.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]})}function ki(e){return[[`approval-required`,e(`chat:focusSession.approvalRequired`),e(`chat:focusSession.approvalRequiredShowsADiffBeforeWriting`),Fn],[`workspace-write`,e(`chat:focusSession.workspaceWrite`),e(`chat:focusSession.workspaceWriteRunsCommandsWithAutomaticApproval`),On],[`full-access`,e(`chat:focusSession.fullAccess`),e(`chat:focusSession.fullAccessRunsShellWithoutPerCommandApproval`),Qn]]}function Ai({value:e,onChange:t,disabled:n,compact:r=!1}){let{t:i}=v(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)({left:0,top:0,width:270}),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=ki(i),f=d.find(t=>t[0]===e)||d[0],p=f[3],m=(0,Z.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,Z.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,Z.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,ai.createPortal)((0,Q.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,Q.jsx)(`div`,{className:`[padding:6px_8px_4px] text-[var(--text-muted)] text-[11px] font-[700] tracking-[.04em] [text-transform:uppercase]`,children:i(`chat:focusSession.approvalMode`)}),d.map(([e,n,r,i])=>(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===f[0],className:e===f[0]?`active`:``,onClick:()=>{t(e),o(!1)},children:[(0,Q.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,Q.jsx)(i,{size:13})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:n}),(0,Q.jsx)(`small`,{children:r})]}),e===f[0]&&(0,Q.jsx)(G,{size:13})]},e))]}),document.body);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.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.approvalModeModeDescription`,{mode:f[1],description:f[2]}),disabled:n,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":i(`chat:focusSession.approvalModeMode`,{mode:f[1]}),onClick:()=>o(e=>!e),children:(0,Q.jsx)(p,{size:r?11:14})})}),h]})}function ji(e,{threshold:t=64,onUnreadChange:n,requestFrame:r=e=>requestAnimationFrame(e),cancelFrame:i=e=>cancelAnimationFrame(e),reducedMotion:a}){let o=e.ownerDocument,s=o.defaultView?.matchMedia?.(`(prefers-reduced-motion: reduce)`),c=a||(()=>{let e=o.documentElement.dataset.motion;return e===`reduced`||e!==`full`&&!!s?.matches}),l=!0,u=!1,d=!1,f=null,p=null,m=null,h=e.scrollTop,g=!1,_=!1,v=null,y=()=>Math.max(0,e.scrollHeight-e.clientHeight),b=()=>_||v!==null,x=e=>{u!==e&&(u=e,n(e))},S=()=>{p!==null&&i(p),p=null},C=()=>{f!==null&&i(f),f=null,m=null,S(),g=!1,h=e.scrollTop},w=()=>{S(),g=!0},T=()=>{S(),p=r(()=>{p=r(()=>{if(p=null,l&&!b()&&Math.abs(y()-e.scrollTop)>1){O();return}g=!1,h=e.scrollTop})})},E=t=>{e.scrollTo({top:t,behavior:`instant`}),h=e.scrollTop},D=t=>{if(f=null,d||!l||b())return;let n=y(),i=n-e.scrollTop,a=m===null?1e3/60:Math.min(64,t-m);m=t;let o=1-.85**(Math.max(0,a)/(1e3/60));if(c()||Math.abs(i)<=1){i!==0&&E(n),m=null,T();return}E(e.scrollTop+Math.sign(i)*Math.min(Math.abs(i),Math.max(1,Math.abs(i)*o))),f=r(D)},O=()=>{d||!l||b()||(w(),f===null&&(f=r(D)))},k=()=>{d||(l=!1,C())},A=()=>{l=!0,x(!1),O()},j=()=>{let n=e.scrollTop-h;h=e.scrollTop,!(g||d)&&(n<-.5?k():n>.5&&y()-e.scrollTop<=t&&A())},M=t=>{t.ctrlKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||(t.deltaY<0?k():t.deltaY>0&&y()-e.scrollTop<=1&&A())},N=e=>{let t=e.touches[0];t&&(v={x:t.clientX,y:t.clientY},C())},P=e=>{let t=e.touches[0];if(!t||!v)return;let n=t.clientX-v.x,r=t.clientY-v.y;Math.abs(r)<2||(r>0&&r>Math.abs(n)&&k(),v={x:t.clientX,y:t.clientY})},F=()=>{v=null,O()},I=e=>{e.pointerType===`touch`||e.button>1||(_=!0,C())},L=()=>{_&&(_=!1,O())},R=e=>{let t=e.target;e.defaultPrevented||t?.closest?.(`input, textarea, select, [contenteditable]`)||(e.key===`ArrowUp`||e.key===`PageUp`||e.key===`Home`||e.key===` `&&e.shiftKey)&&k()};e.addEventListener(`scroll`,j,{passive:!0}),e.addEventListener(`wheel`,M,{passive:!0}),e.addEventListener(`touchstart`,N,{passive:!0}),e.addEventListener(`touchmove`,P,{passive:!0}),e.addEventListener(`touchend`,F,{passive:!0}),e.addEventListener(`touchcancel`,F,{passive:!0}),e.addEventListener(`pointerdown`,I,{passive:!0}),e.addEventListener(`keydown`,R),o.addEventListener(`pointerup`,L,{passive:!0}),o.addEventListener(`pointercancel`,L,{passive:!0}),s?.addEventListener?.(`change`,O);let z=typeof ResizeObserver>`u`?null:new ResizeObserver(O);return z?.observe(e),{maintainBottom:O,pauseFollowing:k,contentChanged(){d||(l?O():x(!0))},scrollToBottom(e=`auto`){d||(C(),l=!0,x(!1),e===`smooth`?O():(w(),E(y()),T()))},dispose(){d=!0,C(),z?.disconnect(),e.removeEventListener(`scroll`,j),e.removeEventListener(`wheel`,M),e.removeEventListener(`touchstart`,N),e.removeEventListener(`touchmove`,P),e.removeEventListener(`touchend`,F),e.removeEventListener(`touchcancel`,F),e.removeEventListener(`pointerdown`,I),e.removeEventListener(`keydown`,R),o.removeEventListener(`pointerup`,L),o.removeEventListener(`pointercancel`,L),s?.removeEventListener?.(`change`,O)}}}function Mi(e,{threshold:t=64,resetKey:n}={}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=(0,Z.useCallback)(e=>{r.current=e,a(e)},[]);return(0,Z.useLayoutEffect)(()=>{if(!i)return;let e=ji(i,{threshold:t,onUnreadChange:s});return c.current=e,s(!1),e.scrollToBottom(),()=>{e.dispose(),c.current=null}},[n,i,t]),(0,Z.useEffect)(()=>{c.current?.contentChanged()},[e]),{scrollRef:r,scrollElement:i,setScrollRef:l,hasUnread:o,scrollToBottom:(0,Z.useCallback)((e=`auto`)=>{c.current?.scrollToBottom(e)},[]),maintainBottom:(0,Z.useCallback)(()=>{c.current?.maintainBottom()},[]),pauseFollowing:(0,Z.useCallback)(()=>{c.current?.pauseFollowing()},[])}}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||pr(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||pr(e)?.updatedAt||``}`:e.type===`communication`?`communication:${e.id||``}`: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`,`communication`].includes(t?.type))return r;let i=[...r];t.type===`plan`&&(i=i.filter(e=>e?.type!==`tool`||!fr(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=`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 Wi(e){return(e||0)>0&&Number(e)<650?260:164}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`?Z.useLayoutEffect:Z.useEffect;function ma({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=Z.useReducer(e=>e+1,0)[1],a=Z.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,ai.flushSync)(i):i()),(o=r.onChange)==null||o.call(r,t,n)}},[l]=Z.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=gt.create(e),ga.set(e,t)),t};(0,Z.memo)(({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2})=>{let a=_a(t),o=(0,Z.useMemo)(()=>(e?.length??0)*i,[e,i]);return(0,Q.jsx)(a,{animate:{backgroundPosition:`0% center`},className:W(`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,Z.createContext)(null),ya=({className:e,isStreaming:t=!1,children:n,...r})=>{let i=(0,Z.useMemo)(()=>({isStreaming:t}),[t]);return(0,Q.jsx)(va.Provider,{value:i,children:(0,Q.jsx)(R,{asChild:!0,"data-slot":`plan`,...r,children:(0,Q.jsx)(tt,{className:W(`shadow-none`,e),children:n})})})},ba=({defaultOpen:e=!0,className:t,...n})=>(0,Q.jsx)(R,{className:W(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}}function Ta(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===`send_team_message`?t(`chat:agentRunActivity.messagingTeamMember`):e===`list_team_members`?t(`chat:agentRunActivity.checkingTeamMembers`):e===`run_team_workflow`?t(`chat:agentRunActivity.runningTeamWorkflow`):e===`followup_task`?t(`chat:agentRunActivity.addingSubagentTask`):e===`wait_agent`?t(`chat:agentRunActivity.waitingForSubagent`):e===`interrupt_agent`?t(`chat:agentRunActivity.interruptingSubagent`):ur(e)?t(`chat:agentRunActivity.readingPlan`):dr(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 Ea(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===`send_team_message`?t(`chat:agentRunActivity.teamMessageSent`):e===`list_team_members`?t(`chat:agentRunActivity.teamMembersListed`):e===`run_team_workflow`?t(`chat:agentRunActivity.teamWorkflowStarted`):e===`wait_agent`?t(`chat:agentRunActivity.subagentStatusUpdated`):dr(e)?t(`chat:agentRunActivity.planUpdated`):t(e===`discover_tools`?`chat:agentRunActivity.toolsDiscovered`:`chat:agentRunActivity.currentOperationCompleted`)}function Da(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 Oa(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 ka(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 Aa(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:Y(e.tokensBefore),after:Y(e.estimatedTokensAfter)}):t(`chat:agentRunActivity.summarizingOlderMessages`)}var ja=[],Ma=`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)]`,Na=(0,Z.lazy)(()=>i(()=>import(`./AnimatedList-_pbK4tS3.js`).then(e=>({default:e.AnimatedList})),__vite__mapDeps([0,1,2,3,4,5,6]))),Pa=(0,Z.lazy)(()=>i(()=>import(`./ShinyText-fuaKxKqJ.js`).then(e=>({default:e.ShinyText})),__vite__mapDeps([7,2,1,3,4,6])));function Fa(e,t){return t(e===`queued`?`chat:agentRunActivity.teamTaskQueued`:e===`starting`?`chat:agentRunActivity.teamTaskStarting`:e===`running`?`chat:agentRunActivity.teamTaskRunning`:e===`completed`?`chat:agentRunActivity.teamTaskCompleted`:e===`failed`?`chat:agentRunActivity.teamTaskFailed`:e===`interrupted`?`chat:agentRunActivity.teamTaskInterrupted`:e===`blocked`?`chat:agentRunActivity.teamTaskBlocked`:`chat:agentRunActivity.teamTaskStatusUpdated`)}function Ia(e){let[t,n]=(0,Z.useState)(()=>Date.now());return(0,Z.useEffect)(()=>{if(n(Date.now()),!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function La({startedAt:e,finishedAt:t,streaming:n,language:r}){let i=Ui(Hi(e,t,Ia(n)),r);return(0,Q.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,Q.jsx)(P,{size:12}),i]})}function $(e){return String(e||``).replace(/\s+/g,` `).trim()}function Ra(e){let t=e?.args||{};return e?.name===`bash`?{text:String(t.command||``).trim(),command:!0}:[`read`,`edit`,`write`,`ls`].includes(e?.name)?{text:$(t.path)}:e?.name===`grep`?{text:[t.pattern?`“${$(t.pattern)}”`:``,$(t.path)].filter(Boolean).join(` · `)}:e?.name===`find`?{text:[$(t.pattern),$(t.path)].filter(Boolean).join(` · `)}:e?.name===`browser_automation`?{text:[$(t.action),$(t.url||t.selector)].filter(Boolean).join(` · `)}:e?.name===`spawn_agent`?{text:$(t.taskName)}:[`send_message`,`followup_task`,`wait_agent`,`interrupt_agent`].includes(e?.name)?{text:$(t.target)}:e?.name===`generate_visual`?{text:$(t.outputName||t.kind)}:e?.name===`discover_tools`?{text:$(t.query)}:{text:``}}function za(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,_=ja;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:Ta(e.name,t)}):r?Ea(e.name,t):Ta(e.name,t);let i=Ra(e);p=i.text,h=!!i.command,m=$(e.message)}else if(e.type===`plan`){d=`plan`;let n=pr(e);f=n?.items?.length?t(`chat:agentRunActivity.planUpdated`):t(`chat:agentRunActivity.planCleared`),_=e.changes||ja,p=_.length?t(`chat:agentRunActivity.countPlanChanges`,{count:_.length}):Oa(n,t)}else if(e.type===`agent`){let n=e.agent||{},r=$(n.taskName)||t(`chat:agentRunActivity.subagent`),i=Ni(n.status);f=Da(n.status,r,t),d=i.tone,p=(n.currentActivity?.type===`tool`?Ra(n.currentActivity).text||n.currentActivity.name:``)||$(n.error||n.message),m=n.status===`running`?$(n.output):``,g=n.startedAt||g}else if(e.type===`communication`){let n=e.communication||{};d=`running`,f=t(`chat:agentRunActivity.teamMessageActivity`),p=t(`chat:agentRunActivity.teamMessageDetail`,{from:n.fromTaskName||n.fromAgentId||`lead`,to:n.toTaskName||n.toAgentId||``}),m=$(n.message)}else if(e.type===`compaction`)d=`compacting`,f=t(`chat:agentRunActivity.compactingContext`),p=Aa(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=$(i)),String(i||``).trim()&&(p=$(i))}return{tone:d,title:f,detail:p,output:m,command:h,startedAt:g,changes:_}}function Ba({tone:e}){return e===`failed`?(0,Q.jsx)(Xe,{size:14}):e===`stopped`?(0,Q.jsx)(Te,{size:12}):[`completed`,`plan`].includes(e)?(0,Q.jsx)(G,{size:14}):(0,Q.jsx)(J,{className:`animate-spin`,size:14})}function Va({activity:e,className:t,children:n}){return e.type===`tool`?(0,Q.jsx)(`div`,{className:t,"data-pisper-activity-type":`tool`,children:n}):e.type===`plan`?(0,Q.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,Q.jsx)(ba,{className:t,"data-pisper-activity-type":`agent`,children:n}):(0,Q.jsx)(`div`,{className:t,"data-pisper-activity-type":e.type,children:n})}function Ha({output:e,streaming:t,t:n}){let r=wa(e),i=(0,Z.useRef)(null);return(0,Z.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,Q.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,Q.jsxs)(`summary`,{children:[(0,Q.jsx)(de,{size:13}),(0,Q.jsx)(`span`,{children:n(t?`chat:agentRunActivity.liveCommandOutput`:`chat:agentRunActivity.commandOutput`)}),(0,Q.jsx)(Me,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:13})]}),(0,Q.jsx)(`pre`,{ref:i,children:r.text})]}):null}function Ua(e,t){return e.activity!==t.activity||e.latest!==t.latest||e.t!==t.t||e.streaming!==t.streaming?!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 Wa=(0,Z.memo)(function({activity:e,latest:t,t:n,streaming:r,text:i,thinkingText:a,compaction:o,error:s,stopped:c,notice:l,lastActivityAt:u}){let d=za(e,{t:n,streaming:r,text:i,thinkingText:a,compaction:o,error:s,stopped:c,notice:l,lastActivityAt:u,now:Date.now()}),f=e.name===`bash`&&t&&!!e.output;return(0,Q.jsxs)(Va,{activity:e,className:`agent-run-summary grid w-full min-h-[42px] grid-cols-[28px_minmax(0,1fr)] [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)] [.agent-run-activity.compact_&]:gap-[7px] [.agent-run-activity.compact_&]:p-[4px_5px] @max-[700px]:grid-cols-[28px_minmax(0,1fr)] @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)] ${d.tone} ${t?`current [.agent-run-summary&]:border-[var(--stroke-soft)] [.agent-run-summary&]:bg-[var(--surface-subtle)] [.agent-run-summary&]:opacity-100`:``}`,children:[(0,Q.jsx)(`span`,{className:Ma,children:(0,Q.jsx)(Ba,{tone:d.tone})}),(0,Q.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,Q.jsx)(`strong`,{children:d.title}),d.detail&&(d.command?(0,Q.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:d.detail,children:[`$ `,d.detail]}):(0,Q.jsx)(`small`,{title:d.detail,children:d.detail})),d.changes.length>0&&(0,Q.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:[d.changes.slice(0,4).map(e=>(0,Q.jsx)(`small`,{children:ka(e,n)},`${e.id}-${e.kind}-${e.status}`)),d.changes.length>4&&(0,Q.jsx)(`small`,{children:n(`chat:agentRunActivity.countMoreChanges`,{count:d.changes.length-4})})]}),!f&&d.output&&d.output!==d.detail&&(0,Q.jsx)(`small`,{className:`text-[var(--text-tertiary)]`,title:d.output,children:d.output})]}),f&&(0,Q.jsx)(Ha,{output:e.output,streaming:!!(r&&e.status===`running`),t:n})]})},Ua);function Ga({streaming:e,text:t,thinkingText:n,currentActivity:r,team:i,activityFeed:a=ja,tools:o=ja,compaction:s,error:c,stopped:l,notice:u,startedAt:d,lastActivityAt:f,finishedAt:p,compact:m=!1}){let{t:h,language:g}=v(),_=String(n||``).trim(),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!_)return;let e=window.requestAnimationFrame(()=>{let e=y.current;e&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[_]);let x=a.length?a:o,S=Ii(x),C=Array.isArray(i?.tasks)?i.tasks:[],w=Number(i?.completedTaskCount??0),T=Number(i?.taskCount??C.length),E=Number(i?.tokenUsed??i?.tokensUsed??0),D=Number(i?.tokenBudget??i?.teamTokenBudget??0),O=Array.isArray(i?.communications)?i.communications:[],k=T>0?Math.min(100,Math.round(w/T*100)):0;if((0,Z.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&&!_&&!x.length&&!i)return null;let A=za(Fi({currentActivity:r,compaction:s,text:t,thinkingText:n,lastActivityAt:f}),{t:h,streaming:e,text:t,thinkingText:_?``:n,compaction:s,error:c,stopped:l,notice:u,lastActivityAt:f,now:Date.now()});!e&&x.length&&(A.title=h(`chat:agentRunActivity.currentOperationCompleted`),A.detail=``);let j=e?0:x.length,M=!!(e||s?.active||c||l),N=A.command&&x.length?h(`chat:agentRunActivity.countLiveOperations`,{count:x.length}):i&&T>0?h(`chat:agentRunActivity.teamProgress`,{completed:w,total:T}):A.detail,P=r=>r.map((i,a)=>(0,Q.jsx)(Wa,{activity:i,compaction:s,error:c,lastActivityAt:f,latest:a===r.length-1,notice:u,stopped:l,streaming:e,t:h,text:t,thinkingText:_?``:n},Li(i,a))),F=P(x),I=P(x.slice(-1));return(0,Q.jsxs)(`section`,{className:`agent-run-activity [&.compact]:m-[4px_0_0_40px] w-full overflow-hidden [margin:1px_0_9px] text-[var(--text)] ${m?`compact`:``}`,"aria-live":`polite`,children:[_&&(0,Q.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,Q.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":h(`chat:agentRunActivity.toggleReasoning`),children:[(0,Q.jsx)(`span`,{className:Ma,children:(0,Q.jsx)(Me,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:14})}),(0,Q.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,Q.jsxs)(`strong`,{children:[h(e?`chat:agentRunActivity.reasoningInProgress`:`chat:agentRunActivity.reasoningCompleted`),e?(0,Q.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,Q.jsx)(`i`,{}),(0,Q.jsx)(`i`,{}),(0,Q.jsx)(`i`,{})]}):null]})}),!M&&j===0&&(0,Q.jsx)(La,{startedAt:d,finishedAt:p,streaming:e,language:g})]}),(0,Q.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,Q.jsx)(_t,{streaming:e,children:_})})]}),M&&(0,Q.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] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [.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] ${A.tone}`,"data-pisper-activity-type":`status`,children:[(0,Q.jsx)(`span`,{className:Ma,children:(0,Q.jsx)(Ba,{tone:A.tone})}),(0,Q.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,Q.jsx)(`strong`,{children:e&&[`running`,`waiting`,`compacting`].includes(A.tone)?(0,Q.jsx)(Z.Suspense,{fallback:A.title,children:(0,Q.jsx)(Pa,{children:A.title})}):A.title}),N&&(0,Q.jsx)(`small`,{title:N,children:N})]}),(0,Q.jsx)(La,{startedAt:d,finishedAt:p,streaming:e,language:g})]}),i&&(C.length>0||O.length>0||(i.blockers?.length??0)>0||(i.conflicts?.length??0)>0||!!i.scriptPath||!!i.summary?.text)&&(0,Q.jsxs)(`details`,{className:`agent-team-panel overflow-hidden rounded-[var(--r-sm)] [border:1px_solid_var(--stroke-soft)] [margin:5px_0_2px]`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-[38px] cursor-pointer items-center justify-between gap-[8px] [list-style:none] [padding:6px_8px] [&::-webkit-details-marker]:hidden hover:bg-[var(--surface-hover)]`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[6px]`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`team-status-dot h-[6px] w-[6px] shrink-0 rounded-full ${i.status===`complete`?`bg-[var(--success)]`:i.status===`stalled`||i.status===`budget_limited`?`bg-[var(--warning)]`:i.status===`paused`?`bg-[var(--text-muted)]`:`bg-[var(--accent-strong)] [animation:agent-status-pulse_1.6s_ease-in-out_infinite]`}`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-[650]`,children:i.status===`complete`?h(`chat:agentRunActivity.teamComplete`):i.status===`budget_limited`?h(`chat:agentRunActivity.teamBudgetLimited`):i.status===`paused`?h(`chat:agentRunActivity.teamPaused`):i.status===`stalled`?h(`chat:agentRunActivity.teamStalled`):h(`chat:agentRunActivity.teamActive`)}),T>0&&(0,Q.jsxs)(`small`,{className:`shrink-0 text-[11px] font-[550] text-[var(--text-muted)]`,children:[w,`/`,T,` · `,k,`%`]})]}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-[8px]`,children:[D>0&&(0,Q.jsx)(`small`,{className:`whitespace-nowrap text-[11px] text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamBudget`,{used:E,budget:D})}),(0,Q.jsx)(Me,{size:14,className:`text-[var(--text-muted)] [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,"aria-hidden":`true`})]})]}),T>0&&(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`team-progress-track mx-[8px] mb-[3px] h-[3px] overflow-hidden rounded-full bg-[var(--stroke-soft)]`,children:(0,Q.jsx)(`div`,{className:`team-progress-fill h-full rounded-full bg-[var(--accent-strong)] [transition:width_var(--d2)_var(--ease-out)]`,style:{width:`${k}%`}})}),(0,Q.jsxs)(`div`,{className:`grid max-h-[min(42vh,360px)] grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-[6px] overflow-y-auto overscroll-contain [border-top:1px_solid_var(--stroke-soft)] [padding:7px_8px]`,children:[C.map(e=>{let t=typeof e.role==`string`?e.role.trim():``,n=Fa(e.status,h);return(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-[4px] rounded-[var(--r-xs)] bg-[var(--surface-muted)] [border:1px_solid_var(--stroke-soft)] [padding:7px] text-[11px]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-[6px]`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`team-task-dot h-[6px] w-[6px] shrink-0 rounded-full ${e.status===`running`?`bg-[var(--accent-strong)] [animation:agent-status-pulse_1.6s_ease-in-out_infinite]`:e.status===`completed`?`bg-[var(--success)]`:e.status===`failed`||e.status===`interrupted`?`bg-[var(--danger)]`:e.status===`blocked`?`bg-[var(--warning)]`:`bg-[var(--stroke-default)]`}`}),(0,Q.jsxs)(`span`,{className:`grid min-w-0 gap-[1px]`,children:[(0,Q.jsx)(`strong`,{className:`break-words font-[620]`,children:t?h(`chat:agentRunActivity.teamTaskStatus`,{name:e.taskName,role:t,status:n}):h(`chat:agentRunActivity.teamTaskStatusWithoutRole`,{name:e.taskName,status:n})}),(0,Q.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:n})]})]}),e.error&&(0,Q.jsx)(`small`,{className:`break-words text-[var(--danger)]`,children:e.error}),e.output&&(0,Q.jsx)(`small`,{className:`break-words text-[var(--text-muted)]`,children:e.output})]},e.id||e.taskName)}),(i.blockers?.length??0)>0&&(0,Q.jsx)(`small`,{className:`text-[var(--warning)]`,children:h(`chat:agentRunActivity.teamBlocked`,{count:i.blockers?.length??0})}),(i.conflicts?.length??0)>0&&(0,Q.jsx)(`small`,{className:`text-[var(--danger)]`,children:h(`chat:agentRunActivity.teamConflicts`,{count:i.conflicts?.length??0})}),i.scriptPath&&(0,Q.jsx)(`small`,{className:`break-all text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamScript`,{path:i.scriptPath})}),O.length>0&&(0,Q.jsxs)(`div`,{className:`grid gap-[3px] [border-top:1px_solid_var(--stroke-soft)] [padding-top:5px]`,children:[(0,Q.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamCommunicationCount`,{count:O.length})}),O.slice(-6).map(e=>(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-[1px] rounded-[var(--r-xs)] bg-[var(--surface-muted)] [border-left:2px_solid_var(--accent-border)] [padding:4px_6px]`,children:[(0,Q.jsxs)(`strong`,{className:`break-all text-[11px] font-[620]`,children:[e.fromTaskName||e.fromAgentId||`lead`,` ->`,` `,e.toTaskName||e.toAgentId]}),(0,Q.jsx)(`small`,{className:`break-words text-[var(--text-secondary)]`,children:e.message})]},e.id))]}),i.summary?.text&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamSummary`)}),i.summary.text&&(0,Q.jsx)(`p`,{className:`m-0 line-clamp-4 text-[11px] leading-[1.45] text-[var(--text-secondary)]`,children:i.summary.text})]})]})]},String(i.id||i.scriptPath||`team`)),e&&x.length>0&&(0,Q.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":h(`chat:agentRunActivity.toolActivityAriaLabel`),children:(0,Q.jsx)(Z.Suspense,{fallback:I,children:(0,Q.jsx)(Na,{children:I})})}),j>0&&(0,Q.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,Q.jsxs)(`summary`,{children:[(0,Q.jsx)(`span`,{className:Ma,children:(0,Q.jsx)(Me,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:14})}),(0,Q.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,Q.jsx)(`strong`,{children:h(`chat:agentRunActivity.countCompletedOperations`,{count:j})})}),!M&&(0,Q.jsx)(La,{startedAt:d,finishedAt:p,streaming:e,language:g})]}),(0,Q.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":h(`chat:agentRunActivity.toolActivityAriaLabel`),tabIndex:x.length>3?0:void 0,children:(0,Q.jsx)(Z.Suspense,{fallback:F,children:F})})]})]})}function Ka(e,t){return e.streaming===t.streaming&&e.text===t.text&&e.thinkingText===t.thinkingText&&e.currentActivity===t.currentActivity&&e.team===t.team&&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 qa=(0,Z.memo)(Ga,Ka);function Ja(e){return e instanceof Error?e.message:String(e)}function Ya(e){return/(?:当前会话已经结束运行|session .*?(?:ended|finished|no longer running))/i.test(Ja(e))}function Xa({className:e,from:t,...n}){return(0,Q.jsx)(`div`,{"data-ai-element":`message`,"data-role":t,className:W(`group flex w-full max-w-[95%] flex-col gap-2`,t===`user`?`is-user ml-auto justify-end`:`is-assistant`,e),...n})}function Za({images:e,index:t,onClose:n,onNavigate:r}){let{t:i}=v(),a=(0,Z.useRef)(null),o=e[t],s=t>0,c=t<e.length-1,l=(0,Z.useCallback)(t=>{t>=0&&t<e.length&&r(t)},[e.length,r]);return(0,Z.useEffect)(()=>{let e=document.body.style.overflow,r=e=>{e.key===`Escape`?n():e.key===`ArrowLeft`?(e.preventDefault(),l(t-1)):e.key===`ArrowRight`&&(e.preventDefault(),l(t+1))};return document.body.style.overflow=`hidden`,window.addEventListener(`keydown`,r),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,r)}},[t,l,n]),o?(0,Q.jsxs)(`div`,{className:`image-lightbox [&_img]:h-full [&_img]:min-h-0 [&_img]:w-full [&_img]:object-contain fixed z-[100] inset-0 grid grid-rows-[auto_minmax(0,1fr)] gap-[12px] bg-[var(--lightbox-bg)] [padding:18px_72px_24px_24px] [backdrop-filter:blur(8px)] max-sm:[padding:12px_56px_16px_12px]`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`chat:chatMessage.fullScreenImagePreview`),children:[(0,Q.jsxs)(`div`,{className:`image-lightbox-toolbar flex min-w-0 items-center justify-between gap-[16px] text-[var(--on-ink)]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[10px]`,children:[(0,Q.jsx)(`span`,{className:`overflow-hidden text-[13px] font-[700] text-ellipsis whitespace-nowrap`,title:o.attachment.name,children:o.attachment.name||i(`chat:chatMessage.generatedImage`)}),e.length>1&&(0,Q.jsxs)(`span`,{className:`flex-none text-[12px] font-[600] text-[var(--on-ink)]/70`,children:[t+1,` / `,e.length]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-none items-center gap-[8px]`,children:[(0,Q.jsx)(d,{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,Q.jsxs)(`a`,{href:o.attachment.downloadUrl||o.source,download:o.attachment.name||`generated-image`,"aria-label":i(`chat:chatMessage.downloadOriginal`),title:i(`chat:chatMessage.downloadOriginal`),children:[(0,Q.jsx)(Ve,{size:14}),(0,Q.jsx)(`span`,{className:`max-sm:hidden`,children:i(`chat:chatMessage.downloadOriginal`)})]})}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`size-11 bg-[var(--lightbox-control-bg)] text-[var(--on-ink)] hover:bg-[var(--lightbox-control-bg)] hover:text-[var(--on-ink)]`,"aria-label":i(`chat:chatMessage.closePreview`),title:i(`chat:chatMessage.closePreview`),onClick:n,children:(0,Q.jsx)(Oe,{size:20})})]})]}),(0,Q.jsxs)(`div`,{className:`relative flex min-h-0 items-center justify-center [touch-action:pan-y]`,onTouchStart:e=>{a.current=e.changedTouches[0]?.clientX??null},onTouchEnd:e=>{let n=a.current;a.current=null;let r=e.changedTouches[0]?.clientX;n===null||r===void 0||Math.abs(r-n)<48||l(t+(r<n?1:-1))},onTouchCancel:()=>{a.current=null},children:[e.length>1&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`absolute left-0 z-10 size-11 rounded-full bg-[var(--lightbox-control-bg)] text-[var(--on-ink)] shadow-[0_8px_24px_var(--lightbox-action-shadow)] hover:bg-[var(--lightbox-control-bg)] hover:text-[var(--on-ink)] disabled:opacity-30`,"aria-label":i(`chat:chatMessage.previousImage`),title:i(`chat:chatMessage.previousImage`),disabled:!s,onClick:()=>l(t-1),children:(0,Q.jsx)(Mn,{size:22})}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`absolute right-0 z-10 size-11 rounded-full bg-[var(--lightbox-control-bg)] text-[var(--on-ink)] shadow-[0_8px_24px_var(--lightbox-action-shadow)] hover:bg-[var(--lightbox-control-bg)] hover:text-[var(--on-ink)] disabled:opacity-30`,"aria-label":i(`chat:chatMessage.nextImage`),title:i(`chat:chatMessage.nextImage`),disabled:!c,onClick:()=>l(t+1),children:(0,Q.jsx)(Me,{size:22})})]}),(0,Q.jsx)(`img`,{alt:o.attachment.name||i(`chat:chatMessage.generatedImage`),decoding:`async`,src:o.source})]})]}):null}function Qa({attachments:e,compact:t=!1}){let{t:n}=v(),[r,i]=(0,Z.useState)(null),a=e.flatMap((e,t)=>{let n=e.url||(e.data?`data:${e.mimeType};base64,${e.data}`:``);return e.kind===`image`&&n?[{attachment:e,source:n,attachmentIndex:t}]:[]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,o=e.url||(e.data?`data:${e.mimeType};base64,${e.data}`:``);return e.kind===`image`&&o?(0,Q.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:()=>{let e=a.findIndex(e=>e.attachmentIndex===t);e>=0&&i({images:a,index:e})},title:n(`chat:chatMessage.openFullScreenPreview`),children:[(0,Q.jsx)(`img`,{alt:e.name||n(`chat:chatMessage.imageAttachment`),decoding:`async`,loading:`lazy`,src:o}),(0,Q.jsx)(`small`,{children:e.name||n(`chat:chatMessage.generatedImage`)})]},r):e.kind===`video`&&o?(0,Q.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,Q.jsx)(`video`,{controls:!0,preload:`metadata`,src:o}),(0,Q.jsx)(`small`,{children:e.name||n(`chat:chatMessage.generatedVideo`)})]},r):(0,Q.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,Q.jsx)(fe,{size:12}),e.name||n(`chat:chatMessage.fileAttachment`)]},r)})}),r&&(0,ai.createPortal)((0,Q.jsx)(Za,{images:r.images,index:r.index,onClose:()=>i(null),onNavigate:e=>i(t=>t&&{...t,index:e})}),document.body)]})}function $a({sessionId:e,entryId:t}){let{t:n}=v(),[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{if(!r)return;let n=!0;return f(!0),g(``),a.getSessionTree(e).then(e=>{if(!n)return;let r=e.nodes.find(e=>e.id===t)?.label||``;s(r),l(r)}).catch(e=>n&&g(Ja(e))).finally(()=>n&&f(!1)),()=>{n=!1}},[t,r,e]);let _=async()=>{if(!(p||u)){m(!0),g(``);try{let n=(await a.setSessionTreeLabel(e,t,o)).nodes.find(e=>e.id===t)?.label||``;s(n),l(n),i(!1)}catch(e){g(Ja(e))}finally{m(!1)}}},y=async()=>{if(!(p||u)){m(!0),g(``);try{let n=(await a.setSessionTreeLabel(e,t,``)).nodes.find(e=>e.id===t)?.label||``;s(n),l(n),i(!1)}catch(e){g(Ja(e))}finally{m(!1)}}};return(0,Q.jsxs)(mi,{open:r,onOpenChange:i,children:[(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(hi,{asChild:!0,children:(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:c?`bg-surface-hover text-brand`:void 0,"aria-label":n(`chat:chatMessage.labelThisTurn`),"data-pisper-label-entry":t,children:(0,Q.jsx)(Ee,{size:14})})})}),(0,Q.jsx)(ae,{side:`top`,sideOffset:6,children:n(`chat:chatMessage.labelThisTurn`)})]}),(0,Q.jsx)(gi,{className:`message-label-popover [&_form]:grid [&_form]:gap-[10px] [&_[data-slot='popover-title']]:text-[12px]`,align:`end`,sideOffset:6,children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsx)(_i,{children:n(`chat:sessionTree.nodeLabel`)}),(0,Q.jsx)(ke,{autoFocus:!0,value:o,maxLength:80,disabled:u||p,placeholder:n(`chat:sessionTree.labelPlaceholder`),onChange:e=>s(e.target.value)}),h&&(0,Q.jsx)(`small`,{className:`danger-text`,children:h}),(0,Q.jsxs)(`div`,{className:`message-label-actions flex items-center justify-between gap-[8px]`,children:[(0,Q.jsx)(d,{type:`button`,size:`icon-sm`,variant:`ghost`,title:n(`chat:sessionTree.removeLabel`),"aria-label":n(`chat:sessionTree.removeLabel`),disabled:u||p,onClick:()=>void y(),children:(0,Q.jsx)(q,{})}),(0,Q.jsxs)(d,{className:`message-label-save [.message-label-actions_&]:min-w-[104px] [.message-label-actions_&]:text-[var(--primary-foreground)]`,type:`submit`,disabled:u||p,children:[p?(0,Q.jsx)(K,{className:`animate-spin`}):(0,Q.jsx)(G,{}),n(p?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]})]})]})})]})}function eo(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 to=(0,Z.memo)(function({sessionId:e,message:t,agentState:n,showRunActivity:r,runProps:i,sessionStreaming:a,onBranchFromHere:o,onCreateChildSession:s}){let{t:c}=v(),[l,u]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=!!t.streaming,h=t.text||(r?``:String(t.error||``));return(0,Q.jsxs)(Xa,{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,Q.jsx)(`span`,{children:t.role===`agent`?(0,Q.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,Q.jsx)(st,{size:20})}):`You`}),(0,Q.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,Q.jsx)(qa,{...i}),h&&(0,Q.jsx)(_t,{streaming:m,children:h}),t.attachments&&t.attachments.length>0&&(0,Q.jsx)(Qa,{attachments:t.attachments})]}),t.role===`agent`&&t.turnBoundaryEntryId&&!m&&(0,Q.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,Q.jsx)($a,{sessionId:e,entryId:t.turnBoundaryEntryId}),(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":c(`chat:chatMessage.deriveFromHere`),"data-pisper-derive-entry":t.turnBoundaryEntryId,disabled:l||f||a,onClick:async()=>{let e=t.turnBoundaryEntryId;if(e){u(!0);try{await o(e)}finally{u(!1)}}},children:l?(0,Q.jsx)(K,{className:`animate-spin`,size:14}):(0,Q.jsx)(Bn,{size:14})})}),(0,Q.jsx)(ae,{side:`top`,sideOffset:6,children:c(`chat:chatMessage.deriveFromHere`)})]}),(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":c(`chat:chatMessage.createChildChat`),"data-pisper-child-entry":t.turnBoundaryEntryId,disabled:l||f,onClick:async()=>{let e=t.turnBoundaryEntryId;if(e){p(!0);try{await s(e)}finally{p(!1)}}},children:f?(0,Q.jsx)(K,{className:`animate-spin`,size:14}):(0,Q.jsx)(Kn,{size:14})})}),(0,Q.jsx)(ae,{side:`top`,sideOffset:6,children:c(`chat:chatMessage.createChildChat`)})]})]})]})},eo);function no(e,t){return e.message===t.message}(0,Z.memo)(function({message:e}){return(0,Q.jsxs)(Xa,{from:e.role===`agent`?`assistant`:`user`,className:`[&_>_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)] [&_.markdown-body]:rounded-[var(--r-xs)] [&_.markdown-body]:bg-[var(--surface-subtle)] [&_.markdown-body]:[padding:6px_8px] [&_.markdown-body]:text-[13px] [&_.markdown-body]:leading-[1.45] [&_.markdown-body]:[overflow-wrap:anywhere] [&.agent_.markdown-body]:bg-[var(--accent-soft)] [&_.markdown-body_pre]:max-h-[130px] [&_.markdown-body_pre]:[padding:7px] 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,Q.jsx)(`span`,{children:e.role===`agent`?`Pisper`:`You`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(e.text||!e.streaming)&&(0,Q.jsx)(_t,{streaming:e.streaming,children:e.text}),e.attachments&&e.attachments.length>0&&(0,Q.jsx)(Qa,{attachments:e.attachments,compact:!0})]})]})},no);function ro(e,t){let n=t?.borderBoxSize?.[0];return Math.ceil(n?.blockSize??e.getBoundingClientRect().height)}function io(e,t,n){let[r,i]=(0,Z.useState)(0);return(0,Z.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 ao=(0,Z.memo)(function({sessionId:e,messages:t,streaming:n,latestRunProps:r,scrollElement:i,prefixRef:a,targetEntryId:o,onContentSizeChange:s,onTargetScroll:c,onTargetLocated:l,onBranchFromHere:u,onCreateChildSession:d}){let f=(0,Z.useRef)(null),[p,m]=(0,Z.useState)(``),h=(0,Z.useRef)(t);h.current=t;let g=io(i,a,f),_=(0,Z.useCallback)(e=>h.current[e]?.id??`transcript-message-${e}`,[]),v=(0,Z.useCallback)(()=>Wi(i?.clientWidth),[i]),y=ha({count:t.length,getScrollElement:()=>i,getItemKey:_,estimateSize:v,measureElement:ro,overscan:6,scrollMargin:g,useAnimationFrameWithResizeObserver:!0}),b=y.getVirtualItems(),x=y.getTotalSize();return(0,Z.useLayoutEffect)(()=>{s()},[s,x]),(0,Z.useEffect)(()=>{if(!o)return;let e=t.findIndex(e=>e.turnBoundaryEntryId===o);if(e<0)return;c(),y.scrollToIndex(e,{align:`center`}),m(o);let n=window.requestAnimationFrame(()=>{y.scrollToIndex(e,{align:`center`}),l(o)});return()=>window.cancelAnimationFrame(n)},[t,l,c,o,y]),(0,Z.useEffect)(()=>{if(!p)return;let e=window.setTimeout(()=>m(``),2200);return()=>window.clearTimeout(e)},[p]),(0,Q.jsx)(`div`,{className:`relative w-full`,"data-pisper-transcript-size":t.length,"data-pisper-rendered-count":b.length,ref:f,style:{height:`${x}px`},children:b.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=xr(a,o,r);return(0,Q.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:y.measureElement,style:{top:`${i.start-g}px`},children:(0,Q.jsx)(to,{sessionId:e,message:a,agentState:s,showRunActivity:!!c,runProps:c,sessionStreaming:n,onBranchFromHere:u,onCreateChildSession:d})},i.key)})})}),oo=(0,Z.lazy)(()=>i(()=>import(`./WelcomeEffects-C9iQOeK6.js`),__vite__mapDeps([8,1,2,3,4,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,6])));function so({children:e,title:t}){return(0,Q.jsxs)(`div`,{className:`agent-welcome-content grid w-full max-w-[680px] place-items-center [padding:12px_20px_30px]`,children:[(0,Q.jsx)(`div`,{className:`[animation:transcript-stage-enter_.5s_var(--ease-out)_both]`,children:(0,Q.jsx)(St,{})}),(0,Q.jsx)(`h2`,{className:`text-[var(--accent-strong)]`,children:t}),e]})}function co({label:e}){return(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-[10px]`,children:[(0,Q.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,Q.jsx)(st,{size:19})}),(0,Q.jsx)(`strong`,{className:`text-[13px] font-[650] text-[var(--text-soft)]`,children:e}),(0,Q.jsxs)(`span`,{className:`flex items-end gap-[3px] pb-[3px]`,"aria-hidden":`true`,children:[(0,Q.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_infinite]`}),(0,Q.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_.16s_infinite]`}),(0,Q.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_.32s_infinite]`})]})]}),(0,Q.jsxs)(`div`,{className:`grid w-[min(560px,78vw)] gap-[12px]`,"aria-hidden":`true`,children:[(0,Q.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,Q.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,Q.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 lo(e,t){return[{icon:de,label:e(`chat:focusSession.explainCode`),prompt:e(`chat:focusSession.explainHowThisCodeWorks`)},{icon:I,label:e(`chat:focusSession.writeTests`),prompt:e(`chat:focusSession.writeUnitTestsForTheFollowingCode`)},{icon:F,label:e(`chat:focusSession.refactor`),prompt:e(`chat:focusSession.refactorThisCodeAndExplainTheImprovements`)},{icon:jn,label:e(`chat:focusSession.findABug`),prompt:e(`chat:focusSession.helpMeLocateAndFixThisBug`)},{icon:Ln,label:e(`chat:focusSession.summarize`),prompt:e(`chat:focusSession.summarizeContentAndExtractKeyPoints`)},...t?[{icon:Un,label:e(`chat:focusSession.makeAPlan`),prompt:e(`chat:focusSession.makeAClearActionablePlanForThisGoal`)}]:[],{icon:Hn,label:e(`chat:focusSession.organizeInformation`),prompt:e(`chat:focusSession.organizeThisInformationIntoAClearStructure`)},{icon:Zn,label:e(`chat:focusSession.findIssues`),prompt:e(`chat:focusSession.reviewThisContentAndSuggestImprovements`)}]}function uo({sessionId:e,messages:t,transcriptLoadState:n=`ready`,messageStart:r,hasOlder:i,loadingOlder:a,olderError:o,currentActivity:s,team:c,activityFeed:l,tools:u,thinkingText:f,compaction:p,streaming:m,runStartedAt:h,lastActivityAt:g,runFinishedAt:_,runStopped:y,runNotice:b,error:x,scrollRequest:S,cwd:C,lineage:w,switchingCwd:T,onLoadOlder:E,onBranchFromHere:D,onCreateChildSession:O,onPromptSelect:k,onWorkspace:A}){let{t:j,language:M}=v(),N=Ie(e=>e.capabilities),P=nt(N,`plans`),F=(0,Z.useRef)(null),I=(0,Z.useRef)(null),[L,R]=(0,Z.useState)(()=>Ke(e)),z=t[t.length-1],B=Math.floor((z?.text?.length||0)/64),ee=Ii(l),te=Math.floor(String(f||``).length/128),{scrollRef:V,scrollElement:ne,setScrollRef:re,hasUnread:ie,scrollToBottom:H,maintainBottom:ae,pauseFollowing:U}=Mi(`${e}:${z?.id||``}:${B}:${te}:${z?.attachments?.length||0}:${ee}:${p?.status||``}:${p?.finishedAt||``}:${x||``}:${m?`1`:`0`}`,{resetKey:`${e}:${n}`}),W=(0,Z.useMemo)(()=>({streaming:m,text:z?.role===`agent`?z.text:``,currentActivity:s,team:c,activityFeed:l,tools:u,thinkingText:f,compaction:p,error:x||(z?.role===`agent`?z.error:``),stopped:y,notice:b,startedAt:h,lastActivityAt:g,finishedAt:_}),[m,z,s,c,l,u,f,p,x,y,b,h,g,_]),oe=(0,Z.useCallback)(async()=>{let e=V.current;!e||!i||a||F.current||(U(),F.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop},await E?.()||(F.current=null))},[i,a,E,U,V]),se=(0,Z.useCallback)(e=>{e.currentTarget.scrollTop<=96&&oe()},[oe]);(0,Z.useLayoutEffect)(()=>{let e=F.current,t=V.current;!e||!t||(t.scrollTop=Gi(e,t.scrollHeight),F.current=null)},[r,V]),(0,Z.useEffect)(()=>{R(Ke(e));let t=t=>{let n=t.detail;n?.sessionId===e&&n.targetEntryId&&R(n.targetEntryId)};return window.addEventListener(Fe,t),()=>window.removeEventListener(Fe,t)},[e]),(0,Z.useEffect)(()=>{if(!(!L||r==null)&&!t.some(e=>e.turnBoundaryEntryId===L)&&!a){if(i){oe();return}Le(e,L),R(``)}},[i,oe,a,r,t,e,L]),(0,Z.useEffect)(()=>{S&&H(`smooth`)},[S,H]);let ce=(0,Z.useMemo)(()=>{let e=new Date().getHours();return[j(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(N,`plugins`)?[j(`chat:focusSession.feelLikeBuildingAPlugin`),j(`chat:focusSession.letAgentWriteItsOwnTool`)]:[],...nt(N,`mcp`)?[j(`chat:focusSession.wireUpAnMcpServer`)]:[],...nt(N,`schedules`)?[j(`chat:focusSession.scheduleTheRepetitiveWork`)]:[],...nt(N,`workflows`)?[j(`chat:focusSession.turnRepeatedWorkIntoAWorkflow`)]:[],...nt(N,`multiAgent`)?[j(`chat:focusSession.branchOutAndRunInParallel`)]:[],...nt(N,`memory`)?[j(`chat:focusSession.letMemoryRememberYou`)]:[]].sort(()=>Math.random()-.5).slice(0,3)]},[N,j]),G=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:j(`chat:focusSession.readyToWorkWithTheCurrentDirectoryAndHelpCompleteTheTask`)}),(0,Q.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)]`,"data-target-cursor":!0,title:C,"aria-label":j(`chat:focusSession.changeWorkingDirectoryWorkspace`,{workspace:C||Ge(C,M)}),onClick:A,disabled:T,children:[T?(0,Q.jsx)(J,{className:`animate-spin`,size:14}):(0,Q.jsx)(Ne,{size:14}),(0,Q.jsx)(`span`,{children:j(`chat:focusSession.workingDirectory`)}),(0,Q.jsx)(`strong`,{children:Ge(C,M)}),(0,Q.jsx)(`small`,{children:j(`chat:focusSession.changeDirectory`)})]}),(0,Q.jsx)(`div`,{className:`welcome-chips flex max-w-[560px] flex-wrap justify-center gap-[9px] [margin-top:24px]`,children:lo(j,P).map(e=>(0,Q.jsxs)(`button`,{type:`button`,"data-target-cursor":!0,onClick:()=>k(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)]`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,Q.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 h-full flex-1 overflow-auto overscroll-contain scroll-auto [overflow-anchor:none] m-0 border-0 [padding:26px_max(24px,calc((100%_-_960px)/2))] [padding-bottom:70px] [scroll-padding-bottom:70px]`,"data-pisper-transcript-state":n,"aria-busy":n===`loading`,ref:re,onScroll:se,tabIndex:0,children:[(0,Q.jsxs)(`div`,{className:`[display:flow-root] w-full`,ref:I,children:[w?.parentSessionId&&(0,Q.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":w.parentSessionId,children:[(0,Q.jsx)(Bn,{size:13}),(0,Q.jsx)(`span`,{children:j(`chat:focusSession.derivedFromSession`,{name:w.sourceSessionName||j(`chat:focusSession.unknownSourceSession`)})})]}),(i||a||o)&&(0,Q.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,Q.jsxs)(d,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:oe,children:[(0,Q.jsx)(J,{size:13}),j(`chat:focusSession.retryOlderMessages`)]}):a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{className:`animate-spin`,size:14}),j(`chat:focusSession.loadingOlderMessages`)]}):(0,Q.jsxs)(d,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:oe,children:[(0,Q.jsx)(En,{className:`history-up-arrow [.history-page-loader_&]:[transform:rotate(180deg)]`,size:14}),j(`chat:focusSession.loadOlderMessages`)]})})]}),n===`loading`&&(0,Q.jsx)(co,{label:j(`chat:focusSession.loadingConversationHistory`)}),n===`ready`&&!t.length&&(0,Q.jsx)(`div`,{className:`agent-welcome [[data-mobile-keyboard='open']_&]:pointer-events-none [[data-mobile-keyboard-transition='opening']_&]:pointer-events-none [[data-mobile-keyboard-transition='closing']_&]:pointer-events-none [&_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,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(so,{title:ce[0],children:G}),children:(0,Q.jsx)(oo,{titles:ce,children:G})})}),n===`ready`&&t.length>0&&(0,Q.jsx)(`div`,{className:`[animation:transcript-reveal-enter_.22s_var(--ease-out)_both]`,children:(0,Q.jsx)(ao,{sessionId:e,messages:t,streaming:m,latestRunProps:W,scrollElement:ne,prefixRef:I,targetEntryId:L,onContentSizeChange:ae,onTargetScroll:U,onTargetLocated:t=>{Le(e,t),R(``)},onBranchFromHere:D,onCreateChildSession:O},e)}),x&&(0,Q.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,Q.jsx)(Xe,{size:14}),x]})]}),ie&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-[6px] z-[5] flex justify-center`,children:(0,Q.jsxs)(d,{type:`button`,variant:`outline`,size:`lg`,className:`pointer-events-auto bg-surface-subtle min-h-[32px] [border-color:var(--accent-border)] text-[var(--star-strong)] shadow-[0_8px_18px_-14px_var(--shadow)]`,onClick:()=>H(`smooth`),children:[(0,Q.jsx)(En,{size:14}),j(`chat:focusSession.newContent`)]})})]})}function fo(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 po(e){let t=e.match(/^diff --git "a\/(.+)" "b\/(.+)"$/);if(t)return fo(`b/${t[2]}`);let n=e.match(/^diff --git a\/(.+) b\/(.+)$/);return n?fo(`b/${n[2]}`):``}function mo(){return{lineNumber:null,text:``,tone:`empty`}}function ho(e){let t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return{oldLine:Number(t?.[1])||0,newLine:Number(t?.[2])||0}}function go(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`}:mo(),next:n?{lineNumber:n.lineNumber,text:n.text,tone:`added`}:mo()})}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:po(e),metadata:[],hunks:[]};continue}if(r){if(e.startsWith(`@@ `)){u();let t=ho(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=fo(e.slice(4)):e.startsWith(`+++ `)?r.newPath=fo(e.slice(4)):e.trim()&&r.metadata.push(e)}}return d(),n}function _o({side:e,cell:t}){let n=t.tone===`deleted`?`−`:t.tone===`added`?`+`:` `;return(0,Q.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,Q.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,Q.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,Q.jsx)(`code`,{children:t.text||`\xA0`})]})}function vo({file:e,scrollElement:t}){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(0),a=(0,Z.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,Z.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,Q.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,Q.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,Q.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,Q.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,Q.jsxs)(`div`,{className:`grid min-w-[880px] grid-cols-[minmax(440px,1fr)_minmax(440px,1fr)]`,children:[(0,Q.jsx)(_o,{side:`old`,cell:t.row.old}),(0,Q.jsx)(_o,{side:`next`,cell:t.row.next})]})},e.key)})})}function yo(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 bo(e){return e===`added`?`A`:e===`deleted`?`D`:e===`renamed`?`R`:`M`}function xo({diff:e,truncated:t,onClose:n}){let{t:r}=v(),i=(0,Z.useMemo)(()=>go(e),[e]),a=(0,Z.useMemo)(()=>i.map(yo),[i]),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(null),u=Math.min(o,Math.max(a.length-1,0)),f=a[u];(0,Z.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,ai.createPortal)((0,Q.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,Q.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,Q.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,Q.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,Q.jsx)(In,{size:17})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:r(`chat:focusSession.gitViewDiff`)}),(0,Q.jsx)(`small`,{children:r(`chat:focusSession.gitDiffFileCount`,{count:i.length})})]}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,title:r(`chat:focusSession.gitCloseDiff`),"aria-label":r(`chat:focusSession.gitCloseDiff`),onClick:n,children:(0,Q.jsx)(Oe,{size:17})})]}),a.length?(0,Q.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,Q.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,Q.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,Q.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===u;return(0,Q.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,Q.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:bo(e.status)}),(0,Q.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,Q.jsx)(`strong`,{children:e.name}),e.directory&&(0,Q.jsx)(`small`,{children:e.directory})]}),(0,Q.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,Q.jsxs)(`em`,{className:`added [.git-diff-file-stats_&]:text-[var(--success)]`,children:[`+`,e.added]}),e.deleted>0&&(0,Q.jsxs)(`em`,{className:`deleted [.git-diff-file-stats_&]:text-[var(--danger)]`,children:[`−`,e.deleted]})]})]},`${e.file.path}-${t}`)})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 min-h-0 overflow-auto bg-[var(--surface-subtle)] [padding:12px]`,ref:l,children:[t&&(0,Q.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,Q.jsxs)(`section`,{className:`min-w-[880px] [overflow:clip] [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)]`,children:[(0,Q.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,Q.jsx)(In,{size:14}),(0,Q.jsx)(`strong`,{title:f.file.path,children:f.file.path}),f.file.oldPath&&f.file.newPath&&f.file.oldPath!==f.file.newPath&&(0,Q.jsx)(`small`,{title:f.file.oldPath,children:f.file.oldPath})]}),f.file.metadata.length>0&&(0,Q.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.jsx)(`span`,{children:r(`chat:focusSession.gitDiffOriginal`)}),(0,Q.jsx)(`span`,{children:r(`chat:focusSession.gitDiffModified`)})]}),(0,Q.jsx)(vo,{file:f.file,scrollElement:c})]}):(0,Q.jsx)(`div`,{className:`[padding:28px_16px] text-[var(--text-muted)] text-[12px] text-center`,children:r(`chat:focusSession.gitDiffNoTextChanges`)})]},f.file.path)]})]}):(0,Q.jsx)(`div`,{className:`min-w-0 min-h-0 flex-1 bg-[var(--surface-subtle)] overflow-auto [padding:12px]`,children:(0,Q.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 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}=v(),[i,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=(0,Z.useCallback)(async()=>{if(e){u(!0),S(``);try{let t=await a.getVcsChanges(e);b(t)}catch(e){S(Co(e))}finally{u(!1)}}},[e]);(0,Z.useEffect)(()=>{if(!i)return;D();let e=e=>{let t=e.target instanceof Node?e.target:null;!T.current?.contains(t)&&!E.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)}},[i,D]),(0,Z.useEffect)(()=>{t||D().catch(()=>{})},[t,D]);let O=async t=>{if(!(!e||f)){if(t===`revert`&&!m){h(!0);return}p(t),S(``),w(``);try{let r;t===`commit`?(r=await a.commitVcsChanges(e,g.trim()||So),_(``),w(n(`chat:focusSession.gitCommitted`))):t===`push`?(r=await a.pushVcsChanges(e),w(n(`chat:focusSession.gitPushed`))):(r=await a.revertVcsChanges(e),h(!1),w(n(`chat:focusSession.gitReverted`))),b(r)}catch(e){S(Co(e))}finally{p(null)}}},k=(y?.vcs||(y?.isRepo?`git`:``))===`svn`,A=y?.isRepo?y.files.length:0,j=A>0,M=!!(!k&&y?.isRepo&&(y.ahead??0)>0),N=!!f,P=k?n(`chat:focusSession.vcsSvnWorkspace`):y?.branch||n(`chat:focusSession.gitDetachedHead`),F=y?.isRepo?`${n(`chat:focusSession.gitChanges`)}${y.branch?` · ${y.branch}`:``}${k?` · ${n(`chat:focusSession.vcsSvnWorkspace`)}`:``}${j?` · ${n(`chat:focusSession.gitFilesChanged`,{count:A})}`:``}`:n(`chat:focusSession.gitChanges`);return(0,Q.jsxs)(`div`,{ref:T,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`:``} ${j?`active`:``}`,children:[(0,Q.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:F,"aria-label":F,"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!e,onClick:()=>o(e=>!e),children:[(0,Q.jsx)(ee,{size:14}),j&&(0,Q.jsx)(`i`,{children:A>99?`99+`:A})]}),(0,Q.jsxs)(ci,{open:i,anchorRef:T,menuRef:E,className:`anchored-popup-menu git-changes-menu 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`,ariaLabel:n(`chat:focusSession.gitChanges`),children:[(0,Q.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,Q.jsx)(`span`,{className:`git-changes-menu-icon grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] ${j?`bg-[var(--star-soft)] text-[var(--star-strong)]`:`bg-[var(--surface-muted)] text-[var(--text-muted)]`}`,children:(0,Q.jsx)(ee,{size:15})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:n(`chat:focusSession.gitChanges`)}),(0,Q.jsx)(`small`,{title:y?.cwd||``,children:y?.isRepo?P:l?n(`chat:focusSession.gitLoading`):x&&!y?n(`chat:focusSession.gitLoadFailed`):y?.gitAvailable===!1&&y?.svnAvailable===!1?n(`chat:focusSession.gitUnavailable`):`${n(`chat:focusSession.gitNotARepository`)}${y?.cwd?` · ${Ge(y.cwd,r)}`:``}`})]}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,title:n(`chat:focusSession.gitRefresh`),"aria-label":n(`chat:focusSession.gitRefresh`),disabled:l||N,onClick:()=>void D(),children:(0,Q.jsx)(J,{className:l?`animate-spin`:``,size:13})})]}),x&&(0,Q.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--danger,_#d64545)] text-[11px]`,children:x}),!x&&y?.error&&(0,Q.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--danger,_#d64545)] text-[11px]`,children:y.error}),C&&!x&&(0,Q.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--success,_#2e9e63)] text-[11px]`,children:C}),y?.isRepo&&(0,Q.jsxs)(Q.Fragment,{children:[j?(0,Q.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:[y.files.slice(0,60).map(e=>(0,Q.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,Q.jsx)(`code`,{className:`text-[var(--star-strong)] text-[10px] font-[700]`,children:e.status}),(0,Q.jsx)(`span`,{title:e.path,children:e.path})]},`${e.status}-${e.path}`)),y.files.length>60&&(0,Q.jsx)(`small`,{children:n(`chat:focusSession.gitMoreFiles`,{count:y.files.length-60})})]}):(0,Q.jsx)(`p`,{className:`[margin:4px_7px] text-[var(--text-muted)] text-[11px]`,children:n(`chat:focusSession.gitNoChanges`)}),j&&(0,Q.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,Q.jsx)(`input`,{value:g,placeholder:n(`chat:focusSession.gitCommitMessagePlaceholder`),onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),O(`commit`))}}),(0,Q.jsxs)(d,{type:`button`,disabled:N||t,title:n(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.gitCommit`),onClick:()=>void O(`commit`),children:[f===`commit`?(0,Q.jsx)(J,{className:`animate-spin`,size:12}):(0,Q.jsx)(zn,{size:12}),n(`chat:focusSession.gitCommit`)]})]}),j&&(0,Q.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:()=>{c(!0),o(!1)},children:[(0,Q.jsx)(In,{size:13}),n(`chat:focusSession.gitViewDiff`)]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-[6px] [margin:5px_7px_6px]`,children:[!k&&(0,Q.jsxs)(d,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:N||!M&&!j,title:M?n(`chat:focusSession.gitPushAhead`,{count:y?.ahead||0}):n(`chat:focusSession.gitPush`),onClick:()=>void O(`push`),children:[f===`push`?(0,Q.jsx)(J,{className:`animate-spin`,size:12}):(0,Q.jsx)(ir,{size:12}),n(`chat:focusSession.gitPush`),M?` ↑${y?.ahead}`:``]}),m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(d,{type:`button`,variant:`destructive`,disabled:N||t,title:n(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.gitConfirmRevert`),onClick:()=>void O(`revert`),children:[f===`revert`?(0,Q.jsx)(J,{className:`animate-spin`,size:12}):(0,Q.jsx)(G,{size:12}),n(`chat:focusSession.gitConfirmRevert`)]}),(0,Q.jsxs)(d,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:N,onClick:()=>h(!1),children:[(0,Q.jsx)(Oe,{size:12}),n(`chat:focusSession.gitCancel`)]})]}):(0,Q.jsxs)(d,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:N||t||!j,title:n(k?`chat:focusSession.vcsRevertDescription`:`chat:focusSession.gitRevertDescription`),onClick:()=>void O(`revert`),children:[(0,Q.jsx)(rr,{size:12}),n(`chat:focusSession.gitRevert`)]})]})]})]}),s&&y&&(0,Q.jsx)(xo,{diff:y.diff||``,truncated:y.diffTruncated,onClose:()=>c(!1)})]})}var To=8;function Eo(e,t){(0,Z.useLayoutEffect)(()=>{if(!e)return;let n=()=>{let e=t.current;if(!e)return;e.style.setProperty(`--menu-x-offset`,`0px`),e.style.setProperty(`--menu-y-offset`,`0px`),e.style.removeProperty(`max-height`),e.style.removeProperty(`overflow-y`);let n=To,r=To,i=window.innerWidth-To,a=window.innerHeight-To,o=e.parentElement;for(;o;){let e=getComputedStyle(o);if(/(auto|hidden|scroll|clip)/.test(`${e.overflowX} ${e.overflowY}`)){let e=o.getBoundingClientRect();n=Math.max(n,e.left+To),r=Math.max(r,e.top+To),i=Math.min(i,e.right-To),a=Math.min(a,e.bottom-To)}o=o.parentElement}let s=Math.max(120,a-r),c=e.getBoundingClientRect();c.height>s&&(e.style.maxHeight=`${s}px`,e.style.overflowY=`auto`,c=e.getBoundingClientRect());let l=c.right>i?i-c.right:c.left<n?n-c.left:0,u=c.bottom>a?a-c.bottom:c.top<r?r-c.top:0;e.style.setProperty(`--menu-x-offset`,`${l}px`),e.style.setProperty(`--menu-y-offset`,`${u}px`)};return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[t,e])}var Do=1e3;function Oo({mode:e,goal:t,tokenBudget:n,onTokenBudgetChange:r,onSaveTokenBudget:i,onChange:a,teamAvailable:o=!1,disabled:s=!1}){let{t:c}=v(),[l,u]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=t?.status===`active`,_=!!t?.id,y=g?t?.mode===`team`&&o?`team`:`goal`:e,b=y===`team`?t?.teamTokenBudget:t?.tokenBudget,x=b==null?null:Number(b)>0?Number(b):null,S=n!==x,C=[{value:`plan`,label:c(`chat:focusSession.planMode`),description:c(`chat:focusSession.planModeDescription`),icon:Wn},{value:`goal`,label:c(`chat:focusSession.goalMode`),description:c(`chat:focusSession.goalModeDescription`),icon:tr},...o?[{value:`team`,label:c(`chat:focusSession.teamMode`),description:c(`chat:focusSession.teamModeDescription`),icon:or}]:[]],w=C.find(e=>e.value===y)||C[0],T=w.icon,E=y===`plan`?w.description:g?c(y===`team`?`chat:focusSession.runningAsTeam`:`chat:focusSession.runningAutonomously`):t?.status===`paused`?c(`chat:focusSession.theNextMessageWillResumeTheGoal`):t?.status===`complete`?c(`chat:focusSession.goalComplete`):t?.status===`budget_limited`?c(`chat:focusSession.goalReachedItsBudget`):c(`chat:focusSession.theNextMessageWillStartAGoal`),D=y===`plan`?w.description:E,O=c(`chat:focusSession.goalTokenBudgetUnlimited`),k=_?x==null?c(`chat:focusSession.usedUnlimitedGoalTokens`,{used:Y(t?.tokensUsed)}):c(`chat:focusSession.usedBudgetTokensUsed`,{used:t?.tokensUsed||0,budget:x||0}):``,A=[c(`chat:focusSession.executionMode`),w.label,D,k].filter(Boolean).join(` · `);(0,Z.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target instanceof Node?e.target:null;m.current?.contains(t)||u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]),Eo(l,h);let j=async()=>{if(!(f||!S||!_||!i)){p(!0);try{await i(n)}finally{p(!1)}}};return(0,Q.jsxs)(`div`,{ref:m,className:`task-execution-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)] ${l?`open`:``} ${y===`plan`?``:`active`}`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`task-execution-mode-trigger hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] [.task-execution-mode-select.open_&]:border-[var(--accent-border)] [.task-execution-mode-select.open_&]:bg-[var(--accent-soft)] [.task-execution-mode-select.open_&]:text-[var(--star-strong)] [.task-execution-mode-select.active_&]:text-[var(--star-strong)] grid w-full h-full place-items-center [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-inherit cursor-pointer disabled:cursor-not-allowed disabled:opacity-[.55]`,title:A,"aria-label":A,"aria-haspopup":`menu`,"aria-expanded":l,disabled:s,onClick:()=>u(e=>!e),children:(0,Q.jsx)(T,{size:14})}),l&&(0,Q.jsxs)(`div`,{ref:h,className:`task-execution-mode-menu [translate:var(--menu-x-offset,_0px)_var(--menu-y-offset,_0px)] [&_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(270px,calc(100vw_-_76px))] absolute z-[35] [bottom:calc(100%_+_8px)] left-0 w-[min(270px,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:`menu`,"aria-label":c(`chat:focusSession.executionMode`),children:[(0,Q.jsx)(`div`,{className:`[padding:6px_8px_4px] text-[var(--text-muted)] text-[11px] font-[700] tracking-[.04em] [text-transform:uppercase]`,children:c(`chat:focusSession.executionMode`)}),C.map(e=>{let t=e.icon,n=e.value===y;return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,className:`task-execution-mode-option 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 w-full min-h-[48px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] border-0 rounded-[var(--r-sm)] bg-transparent [padding:6px_7px] text-left ${n?`bg-[var(--accent-soft)]`:``}`,onClick:()=>{a(e.value),u(!1)},children:[(0,Q.jsx)(`span`,{className:`grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Q.jsx)(t,{size:14})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:e.label}),(0,Q.jsx)(`small`,{children:e.description})]}),n&&(0,Q.jsx)(G,{size:13})]},e.value)}),(y===`goal`||y===`team`||_)&&(0,Q.jsxs)(Q.Fragment,{children:[k&&(0,Q.jsx)(`p`,{children:k}),(0,Q.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,Q.jsx)(`label`,{htmlFor:`goal-token-budget-input`,children:c(y===`team`?`chat:focusSession.teamTokenBudget`:`chat:focusSession.goalTokenBudget`)}),(0,Q.jsx)(`input`,{id:`goal-token-budget-input`,type:`number`,min:Do,step:1e3,value:n??``,placeholder:O,"aria-label":c(y===`team`?`chat:focusSession.teamTokenBudget`:`chat:focusSession.goalTokenBudget`),disabled:f,onChange:e=>{let t=e.target.value.trim();if(!t){r(null);return}let n=Number(t);Number.isFinite(n)&&r(Math.max(Do,Math.round(n)))}}),_&&S&&(0,Q.jsxs)(d,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:f,onClick:()=>void j(),children:[f?(0,Q.jsx)(J,{className:`animate-spin`,size:12}):(0,Q.jsx)(G,{size:12}),c(`chat:focusSession.goalBudgetSave`)]})]}),(0,Q.jsx)(`small`,{className:`block [margin:0_7px_5px] text-[var(--text-muted)] text-[10px]`,children:c(y===`team`?`chat:focusSession.teamTokenBudgetHint`:_?`chat:focusSession.goalTokenBudgetUpdateHint`:`chat:focusSession.goalTokenBudgetHint`)})]})]})]})}function ko({session:e,canSplit:t,canClose:n=!0,streaming:r,switchingCwd:i,onSplitLeft:a,onSplitRight:o,onSplitTop:s,onSplitBottom:c,onClosePanel:l,onWorkspace:u,onRename:f,onSessionTree:p}){let{t:m,language:h}=v(),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`top`),x=(0,Z.useRef)(null),S=(0,Z.useRef)(null),C=(0,Z.useRef)(null),w=(0,Z.useCallback)(()=>{_(!1),C.current?.focus()},[]);(0,Z.useEffect)(()=>{if(!g)return;let e=e=>{let t=e.target instanceof Node?e.target:null;!x.current?.contains(t)&&!S.current?.contains(t)&&_(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]);let T=e=>{_(!1),e?.()},E=[[ge,m(`chat:focusSession.splitToLeft`),m(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheLeft`),a],[pe,m(`chat:focusSession.splitToRight`),m(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheRight`),o],[he,m(`chat:focusSession.splitToTop`),m(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheTop`),s],[me,m(`chat:focusSession.splitToBottom`),m(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheBottom`),c]];return(0,Q.jsxs)(`div`,{ref:x,className:`relative flex-none`,children:[(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,ref:C,title:m(`chat:focusSession.chatActions`),"aria-label":m(`chat:focusSession.openChatActionsMenu`),"aria-haspopup":`menu`,"aria-expanded":g,disabled:!e,onClick:()=>{g||b(x.current?.closest(`.focus-composer, .composer-tool-tray`)?`top`:`bottom`),_(e=>!e)},children:(0,Q.jsx)(L,{size:17})}),(0,Q.jsxs)(ci,{open:g,anchorRef:x,menuRef:S,placement:y,align:`end`,onClose:w,className:`anchored-popup-menu permission-mode-menu session-actions-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)] w-[250px] max-w-[calc(100vw_-_16px)] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)] [&_>_button:disabled]:[cursor:not-allowed] [&_>_button:disabled]:opacity-[.5]`,role:`menu`,children:[E.map(([e,n,r,i])=>(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:!t,onClick:()=>T(i),children:[(0,Q.jsx)(e,{size:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:n}),(0,Q.jsx)(`small`,{children:t?r:m(`chat:focusSession.thisGroupHasOnlyOneChat`)})]})]},n)),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:r||i,onClick:()=>T(u),children:[(0,Q.jsx)(Ne,{size:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:m(`chat:focusSession.setWorkingDirectory`)}),(0,Q.jsx)(`small`,{children:r?m(`chat:focusSession.cannotSwitchWhileTheAgentIsRunning`):Ge(e?.cwd,h)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:r,onClick:()=>T(p),children:[(0,Q.jsx)(nr,{size:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:m(`chat:sessionTree.menu`)}),(0,Q.jsx)(`small`,{children:m(r?`chat:sessionTree.waitForRun`:`chat:sessionTree.menuDescription`)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>T(f),children:[(0,Q.jsx)(ve,{size:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:m(`chat:focusSession.renameChat`)}),(0,Q.jsx)(`small`,{children:e?.name||m(`chat:focusSession.newChat`)})]})]}),n&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>T(l),children:[(0,Q.jsx)(Oe,{size:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:m(`chat:focusSession.closeTab`)}),(0,Q.jsx)(`small`,{children:m(`chat:focusSession.keepTheHistoryAndCloseOnlyThisView`)})]})]})]})]})}var Ao=new Set([`user`,`assistant`,`summary`,`compaction`,`position`]),jo=new Set([`tool`,`tool-call`]);function Mo(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 No(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 Po(e,t){let n=[],r=new Map;for(let i of No(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 Fo(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 Io(e){return e.kind===`user`?ar:e.kind===`assistant`?ze:e.kind===`tool`||e.kind===`tool-call`?De:e.kind===`settings`?Ce:e.kind===`label`?Ee:e.kind===`summary`||e.kind===`compaction`?Ln:e.kind===`position`?ee:e.label?An:lt}function Lo({nodes:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let o=ha({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>64,getItemKey:t=>e[t]?.id??`mobile-tree-node-${t}`,overscan:12,useAnimationFrameWithResizeObserver:!0});return(0,Z.useEffect)(()=>{if(!n)return;let t=e.findIndex(e=>e.id===n);t>=0&&o.scrollToIndex(t,{align:`center`})},[e,n,o]),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${o.getTotalSize()}px`},children:o.getVirtualItems().map(t=>{let o=e[t.index],s=Io(o);return(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 w-full px-[12px] py-[4px]`,style:{transform:`translateY(${t.start}px)`},children:(0,Q.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)] grid min-h-[56px] w-full grid-cols-[34px_minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--solid)] p-[7px_9px_7px_4px] text-left ${o.id===n?` selected`:``}${o.active?` active`:``}${o.leaf?` leaf`:``}`,"data-kind":o.kind,"data-pisper-tree-entry":o.id,onClick:()=>a(o.id),children:[(0,Q.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.active_&]:border-[var(--brand-blue-border)] [.session-tree-node.leaf_&]:bg-[var(--star)] [.session-tree-node.leaf_&]:text-[var(--on-accent)] grid size-[28px] place-items-center justify-self-center [border:2px_solid_var(--surface-subtle)] rounded-full bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Q.jsx)(s,{size:14})}),(0,Q.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-[2px] [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_small]:text-[10px] [&_small]:text-[var(--text-muted)] [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_strong]:text-[12px] [&_strong]:font-[650]`,children:[(0,Q.jsx)(`strong`,{children:o.label||o.text||r(o)}),(0,Q.jsx)(`small`,{children:o.label&&o.text?o.text:r(o)})]}),(0,Q.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 items-center gap-[4px] text-[9px] text-[var(--text-muted)] [text-transform:uppercase]`,children:[o.label&&(0,Q.jsx)(An,{size:12}),i(o)]})]})},t.key)})})}function Ro({segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let{nodes:o,children:s}=e,c=o.length>120,l=ha({count:o.length,getScrollElement:()=>t.current,estimateSize:()=>56,getItemKey:e=>o[e]?.id??`tree-node-${e}`,overscan:12,scrollMargin:26,enabled:c,useAnimationFrameWithResizeObserver:!0}),u=e=>{let t=Io(e);return(0,Q.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,Q.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,Q.jsx)(t,{size:14})}),(0,Q.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,Q.jsx)(`strong`,{children:e.label||e.text||r(e)}),(0,Q.jsx)(`small`,{children:e.label&&e.text?e.text:r(e)})]}),(0,Q.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,Q.jsx)(An,{size:12}),i(e)]})]},e.id)};return(0,Z.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,Q.jsxs)(`div`,{className:`session-tree-segment relative flex min-w-[220px] flex-col items-center ${e.active?` active`:``}`,children:[(0,Q.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,Q.jsx)(`div`,{className:`relative w-[220px]`,style:{height:`${l.getTotalSize()}px`},children:l.getVirtualItems().map(e=>(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 w-[220px]`,style:{top:`${e.start-26}px`},children:u(o[e.index])},e.key))}):o.map(u)}),s.length>0&&(0,Q.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,Q.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,Q.jsx)(Ro,{segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a})},e.id))})]})}function zo({view:e,onViewChange:t,query:n,onQueryChange:r,loading:i,error:a,mobileLayout:o,viewportRef:s,segments:c,visibleNodes:l,selectedId:u,typeLabel:d,stateLabel:f,onSelect:p,visibleMarks:m,marksLoading:h,openingMark:g,onOpenMark:_}){let{t:y,language:b}=v(),x=e=>{let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(b,{dateStyle:`medium`,timeStyle:`short`}).format(t):y(`navigation:appOverlays.unknownTime`)};return(0,Q.jsxs)(`div`,{className:`chat-resource-browser flex min-h-0 min-w-0 flex-col bg-transparent session-tree-browser`,children:[(0,Q.jsx)(ot,{className:`chat-resource-tabs w-full [padding:12px_12px_0] session-tree-tabs [&_[data-slot='tabs-list']]:grid [&_[data-slot='tabs-list']]:h-[36px] [&_[data-slot='tabs-list']]:w-full [&_[data-slot='tabs-list']]:grid-cols-[repeat(4,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)]`,value:e,onValueChange:e=>t(e),children:(0,Q.jsxs)(qe,{children:[(0,Q.jsx)(Ye,{value:`conversation`,children:y(`chat:sessionTree.conversation`)}),(0,Q.jsx)(Ye,{value:`labeled`,children:y(`chat:sessionTree.labeled`)}),(0,Q.jsx)(Ye,{value:`all`,children:y(`chat:sessionTree.all`)}),(0,Q.jsx)(Ye,{value:`marks`,children:y(`chat:sessionTree.allMarks`)})]})}),(0,Q.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,Q.jsx)(ct,{size:15}),(0,Q.jsx)(`input`,{value:n,disabled:!!g,onChange:e=>r(e.target.value),placeholder:y(`chat:sessionTree.searchPlaceholder`)})]}),e===`marks`?(0,Q.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:[a&&(0,Q.jsx)(`p`,{className:`danger-text [margin:0_2px]`,children:a}),h?(0,Q.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:y(`chat:sessionTree.loadingMarks`)}):m.length?m.map(e=>(0,Q.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:!!g,"aria-busy":g===e,onClick:()=>_(e),children:[(0,Q.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:g===e?(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,Q.jsx)(Ee,{size:14})}),(0,Q.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,Q.jsx)(`strong`,{children:e.label}),(0,Q.jsx)(`small`,{children:e.sessionName||y(`navigation:appOverlays.untitledChat`)}),(0,Q.jsx)(`small`,{children:y(`chat:sessionTree.markTimes`,{sessionTime:x(e.sessionModified),nodeTime:x(e.nodeTimestamp)})})]}),g===e?(0,Q.jsx)(`em`,{children:y(`chat:sessionTree.navigating`)}):e.active&&(0,Q.jsx)(`em`,{children:y(`chat:sessionTree.markActive`)})]},`${e.sessionId}:${e.entryId}`)):(0,Q.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:y(`chat:sessionTree.noMarksYet`)})]}):(0,Q.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:s,children:c.length>0?o?(0,Q.jsx)(Lo,{nodes:l,viewportRef:s,selectedId:u,typeLabel:d,stateLabel:f,onSelect:p}):(0,Q.jsx)(`div`,{className:`session-tree-canvas flex w-[max-content] min-w-[100%] items-start justify-center gap-[36px] [padding:26px_28px_48px]`,children:c.map(e=>(0,Q.jsx)(Ro,{segment:e,viewportRef:s,selectedId:u,typeLabel:d,stateLabel:f,onSelect:p},e.id))}):(0,Q.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:i?y(`chat:sessionTree.loading`):a||y(`chat:sessionTree.empty`)})})]})}function Bo({mobileLayout:e,selected:t,loading:n,error:r,streaming:i,dataStreaming:a,parentSession:o,parentEntryId:s,childSessions:c,canLabel:l,canDerive:u,label:f,summarize:p,savingLabel:m,creatingChild:h,navigating:g,openingRelatedId:_,typeLabel:y,stateLabel:b,onBackToList:x,onLabelChange:S,onSummarizeChange:C,onSaveLabel:w,onRemoveLabel:T,onCreateChild:E,onNavigate:D,onRefresh:O,onOpenRelated:k}){let{t:A,language:j}=v();return(0,Q.jsxs)(`div`,{className:`chat-resource-config flex min-h-0 min-w-0 flex-col gap-[16px] overflow-y-auto [overscroll-behavior:contain] [padding:18px] session-tree-inspector [&_>_p]:m-[auto] [&_>_p]:text-[12px] [&_>_p]:text-[var(--text-muted)] [&_strong]:text-[14px] [&_p]:text-[12px] [&_p]:text-[var(--text-muted)] ${e?`bg-[var(--solid)]`:`[margin:12px_12px_12px_0] rounded-[var(--r-md)] bg-[color-mix(in_srgb,var(--solid)_88%,var(--surface-subtle))] shadow-[0_10px_28px_-26px_var(--shadow)]`}`,children:[e&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-[2] -mx-[6px] -mt-[8px] flex border-b border-[var(--stroke-soft)] bg-[var(--solid)] px-[2px] pb-[8px]`,children:(0,Q.jsxs)(d,{variant:`ghost`,className:`min-h-[40px] justify-start px-[8px]`,onClick:x,children:[(0,Q.jsx)(Mn,{size:17}),A(`chat:sessionTree.backToNodes`)]})}),t?(0,Q.jsxs)(Q.Fragment,{children:[(o||c.length>0)&&(0,Q.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,Q.jsx)(`strong`,{children:A(`chat:sessionTree.conversationLineage`)}),o&&(0,Q.jsxs)(d,{variant:`outline`,disabled:!!_,onClick:()=>k(o,s),children:[(0,Q.jsx)(lt,{size:13}),A(`chat:sessionTree.returnToOriginalChat`,{name:o.name||A(`chat:chatPage.newChat`)})]}),c.map(e=>(0,Q.jsxs)(d,{variant:`outline`,disabled:!!_,onClick:()=>k(e),children:[(0,Q.jsx)(lt,{size:13}),A(`chat:sessionTree.openSeparateChat`,{name:e.name||A(`chat:chatPage.newChat`)})]},e.id))]}),(0,Q.jsxs)(`div`,{children:[(0,Q.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:[y(t),b(t)&&(0,Q.jsx)(`em`,{children:b(t)})]}),(0,Q.jsx)(`strong`,{children:t.label||y(t)}),(0,Q.jsx)(`p`,{children:t.text||A(`chat:sessionTree.noPreview`)})]}),(0,Q.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:[l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`span`,{children:A(`chat:sessionTree.nodeLabel`)}),(0,Q.jsx)(ke,{value:f,maxLength:80,placeholder:A(`chat:sessionTree.labelPlaceholder`),onChange:e=>S(e.target.value)})]}),(0,Q.jsxs)(d,{variant:`outline`,disabled:m||i||a,onClick:w,children:[(0,Q.jsx)(Ee,{size:14}),A(m?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]}),!!t.label&&(0,Q.jsxs)(d,{variant:`outline`,disabled:m||i||a,onClick:T,children:[(0,Q.jsx)(q,{size:14}),A(`chat:sessionTree.removeLabel`)]})]}),l&&(0,Q.jsxs)(d,{variant:`outline`,disabled:h||i||a,onClick:E,children:[(0,Q.jsx)(Kn,{size:14}),A(h?`chat:sessionTree.creatingChildChat`:`chat:sessionTree.createChildChat`)]}),u&&(0,Q.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,Q.jsx)(`span`,{children:A(`chat:sessionTree.abandonedBranchSummary`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:p,disabled:t.leaf||i||a,onChange:e=>C(e.target.checked)}),(0,Q.jsx)(`small`,{children:A(`chat:sessionTree.abandonedBranchSummaryHint`)})]})]}),u&&(0,Q.jsx)(`p`,{children:A(`chat:sessionTree.sideEffectsRemain`)}),t.timestamp&&(0,Q.jsx)(`p`,{children:new Intl.DateTimeFormat(j,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.timestamp))}),r&&(0,Q.jsx)(`p`,{className:`danger-text`,children:r}),u&&(0,Q.jsxs)(d,{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:g||t.leaf||i||a,onClick:D,children:[(0,Q.jsx)(ee,{size:15}),g?A(`chat:sessionTree.navigating`):t.leaf?A(`chat:sessionTree.currentPosition`):A(`chat:sessionTree.continueFromNode`)]})]}):(0,Q.jsx)(`p`,{children:n?A(`chat:sessionTree.loading`):r||A(`chat:sessionTree.chooseNode`)}),r&&!t&&(0,Q.jsx)(d,{variant:`outline`,onClick:O,children:A(`chat:sessionTree.retry`)})]})}function Vo({open:e,sessionId:t,streaming:n,onClose:r,onNavigated:i,onCreateChildSession:o}){let{t:s,language:c}=v(),l=Se(),u=C(),f=l||u,[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)([]),[_,y]=(0,Z.useState)(`conversation`),[b,x]=(0,Z.useState)(`list`),[S,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(``),[k,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(!1),[z,B]=(0,Z.useState)(!1),[ee,te]=(0,Z.useState)(!1),[V,ne]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(!1),[H,ae]=(0,Z.useState)(``),[U,W]=(0,Z.useState)(``),oe=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e||!t)return;let n=!1;return y(`conversation`),x(`list`),w(``),B(!0),W(``),Promise.all([a.getSessionTree(t),a.listSessions()]).then(([e,t])=>{n||(m(e),g(t.sessions||[]),E(e.leafId||e.nodes[0]?.id||``))}).catch(e=>{n||W(Ja(e))}).finally(()=>{n||B(!1)}),()=>{n=!0}},[e,t]),(0,Z.useEffect)(()=>{e||(m(null),g([]),E(``),x(`list`),O(``),I(null),R(!1),W(``))},[e]),(0,Z.useEffect)(()=>{if(!e||_!==`marks`||j)return;let t=!0;return P(!0),W(``),a.listSessionTreeLabels(500).then(e=>{t&&(A(e.labels||[]),M(!0))}).catch(e=>t&&W(Ja(e))).finally(()=>t&&P(!1)),()=>{t=!1}},[e,_,j]);let se=(0,Z.useMemo)(()=>{let e=S.trim().toLocaleLowerCase(c);return e?k.filter(t=>`${t.label} ${t.sessionName}`.toLocaleLowerCase(c).includes(e)):k},[k,c,S]),ce=async e=>{if(!F){I(e),W(``);try{e.active||await a.navigateSessionTreeTarget(e.sessionId,e.entryId),Ae(e.sessionId,`open`,e.entryId),r()}catch(e){W(Ja(e)),I(null)}}},G=(0,Z.useMemo)(()=>Mo(p?.nodes||[]),[p]),le=(0,Z.useCallback)(e=>({user:s(`chat:sessionTree.userMessage`),assistant:s(`chat:sessionTree.agentMessage`),tool:s(`chat:sessionTree.toolResult`),"tool-call":s(`chat:sessionTree.toolCall`),summary:s(`chat:sessionTree.branchSummary`),compaction:s(`chat:sessionTree.compactionSummary`),settings:s(`chat:sessionTree.settingsChange`),label:s(`chat:sessionTree.labelChange`),position:s(`chat:sessionTree.branchPosition`),extension:s(`chat:sessionTree.extensionEntry`),metadata:s(`chat:sessionTree.metadataEntry`),message:s(`chat:sessionTree.message`)})[e.kind]||e.type,[s]),ue=(0,Z.useMemo)(()=>{let e=S.trim().toLocaleLowerCase(c);return Po(G,t=>(_===`conversation`?Ao.has(t.kind):_!==`labeled`||t.label)?!e||`${t.label} ${t.text} ${le(t)}`.toLocaleLowerCase(c).includes(e):!1)},[G,c,S,le,_]),de=(0,Z.useMemo)(()=>ue.map(Fo),[ue]),fe=(0,Z.useMemo)(()=>No(ue),[ue]),K=(0,Z.useMemo)(()=>No(G),[G]).find(e=>e.id===T)||null,pe=p?.lineage?.parentSessionId?h.find(e=>e.id===p.lineage?.parentSessionId):null,me=(p?.lineage?.childSessionIds||[]).map(e=>h.find(t=>t.id===e)).filter(e=>!!e),he=K?.kind===`assistant`&&K.status===`completed`,ge=he,_e=K?!jo.has(K.kind):!1;(0,Z.useEffect)(()=>{O(K?.label||``),R(!1)},[K?.id,K?.label]),(0,Z.useEffect)(()=>{if(T&&fe.some(e=>e.id===T))return;let e=[...fe].reverse().find(e=>e.active);E(e?.id||fe[0]?.id||``)},[T,fe]),(0,Z.useEffect)(()=>{if(!e||!T)return;let t=requestAnimationFrame(()=>{document.querySelector(`[data-testid="session-tree-list"] .session-tree-node.selected`)?.scrollIntoView({block:`center`})});return()=>cancelAnimationFrame(t)},[e,S,T,_,fe.length]);let ve=async()=>{B(!0),W(``);try{let e=await a.getSessionTree(t);m(e),E(e.leafId||e.nodes[0]?.id||``)}catch(e){W(Ja(e))}finally{B(!1)}},ye=async()=>{if(!(!K||ee)){te(!0),W(``);try{m(await a.setSessionTreeLabel(t,K.id,D))}catch(e){W(Ja(e))}finally{te(!1)}}},be=async()=>{if(!(!K||ee)){te(!0),W(``);try{m(await a.setSessionTreeLabel(t,K.id,``))}catch(e){W(Ja(e))}finally{te(!1)}}},xe=async()=>{if(!(!K||!ge||re)){ie(!0),W(``);try{await o(K.id),r()}catch(e){W(Ja(e))}finally{ie(!1)}}},Ce=async(e,t=``)=>{if(!(!e.id||H)){ae(e.id),W(``);try{t&&await a.navigateSessionTreeTarget(e.id,t),Ae(e.id,`open`,t),r()}catch(e){W(Ja(e))}finally{ae(``)}}},we=async()=>{if(!(!K||V||K.leaf||n||p?.streaming)){ne(!0),W(``);try{let e=await a.navigateSessionTree(t,K.id,L);m(e),e.cancelled||(await i(e.editorText),r())}catch(e){W(Ja(e))}finally{ne(!1)}}},Te=e=>e.leaf?s(`chat:sessionTree.current`):e.branchPoint?s(`chat:sessionTree.fork`):e.active?s(`chat:sessionTree.active`):``;return(0,Q.jsx)($e,{open:e,onOpenChange:e=>!e&&r(),children:(0,Q.jsxs)(je,{className:`chat-resource-dialog grid-rows-[auto_minmax(0,1fr)] overflow-hidden session-tree-dialog ${f?`!h-[calc(100dvh_-_16px)] !w-[calc(100vw_-_16px)] !max-w-none !gap-0 !p-0`:`!h-[min(760px,calc(100dvh_-_32px))] !w-[min(1120px,calc(100vw_-_32px))] !max-w-[1120px]`}`,showCloseButton:!1,children:[(0,Q.jsxs)(`div`,{className:`chat-resource-head flex items-start justify-between gap-[16px] [border-bottom:1px_solid_var(--stroke-soft)] session-tree-head [&_[data-slot='dialog-description']]:mt-[3px] [&_[data-slot='dialog-description']]:text-[12px] [&_[data-slot='dialog-title']]:text-[16px] ${f?`p-[14px]`:`[padding:17px_18px_14px]`}`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.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,Q.jsx)(`span`,{children:(0,Q.jsx)(nr,{size:17})}),(0,Q.jsx)(He,{children:s(`chat:sessionTree.title`)})]}),(0,Q.jsx)(Ze,{children:s(`chat:sessionTree.description`,{nodes:p?.nodeCount||0,branches:p?.branchCount||0})})]}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":s(`common:ui.closeDialog`),title:s(`common:ui.closeDialog`),onClick:r,children:(0,Q.jsx)(Oe,{size:17})})]}),(0,Q.jsxs)(`div`,{className:`chat-resource-body grid min-h-0 overflow-hidden bg-[var(--surface-subtle)] session-tree-layout ${f?`grid-cols-1 grid-rows-[minmax(0,1fr)]`:`!grid-cols-[minmax(0,1fr)_292px]`}`,children:[(!f||b===`list`)&&(0,Q.jsx)(zo,{view:_,onViewChange:e=>{y(e),x(`list`)},query:S,onQueryChange:w,loading:z,error:U,mobileLayout:f,viewportRef:oe,segments:de,visibleNodes:fe,selectedId:T,typeLabel:le,stateLabel:Te,onSelect:e=>{E(e),f&&x(`detail`)},visibleMarks:se,marksLoading:N,openingMark:F,onOpenMark:e=>void ce(e)}),_!==`marks`&&(!f||b===`detail`)&&(0,Q.jsx)(Bo,{mobileLayout:f,selected:K,loading:z,error:U,streaming:n,dataStreaming:!!p?.streaming,parentSession:pe??null,parentEntryId:p?.lineage?.sourceEntryId||``,childSessions:me,canLabel:he,canDerive:_e,label:D,summarize:L,savingLabel:ee,creatingChild:re,navigating:V,openingRelatedId:H,typeLabel:le,stateLabel:Te,onBackToList:()=>x(`list`),onLabelChange:O,onSummarizeChange:R,onSaveLabel:()=>void ye(),onRemoveLabel:()=>void be(),onCreateChild:()=>void xe(),onNavigate:()=>void we(),onRefresh:()=>void ve(),onOpenRelated:(e,t)=>void Ce(e,t??``)})]})]})})}function Ho({visible:e,open:t,sessionId:n,streaming:r,revision:i,pulseToken:o,onOpenChange:s,onNavigated:c,onCreateChildSession:l}){let{t:u}=v(),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!o)return;h(!0);let e=window.setTimeout(()=>h(!1),1800);return()=>window.clearTimeout(e)},[o]),(0,Z.useEffect)(()=>{if(!e||r)return;let t=!0;return a.getSessionTree(n).then(e=>t&&p(e.branchCount||0)).catch(()=>{}),()=>{t=!1}},[i,n,r,e]),e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(d,{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] ${m?`[animation:session-tree-new-node-pulse_1.8s_var(--ease-out)]`:``}`,title:u(`chat:sessionTree.menuDescription`),"data-pisper-recall-pulse":m||void 0,"aria-label":u(`chat:sessionTree.menu`),"aria-haspopup":`dialog`,"aria-expanded":t,onClick:()=>s(!0),children:[(0,Q.jsx)(nr,{size:16}),(0,Q.jsx)(`span`,{children:u(`chat:sessionTree.menu`)}),f>0&&(0,Q.jsx)(`i`,{children:f})]}),(0,Q.jsx)(Vo,{open:t,sessionId:n,streaming:r,onClose:()=>s(!1),onNavigated:c,onCreateChildSession:l})]}):null}function Uo(e){return[`running`,`waiting_approval`].includes(String(e.status||``))}function Wo(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 Go({sessionId:e}){let{t}=v(),[n,r]=(0,Z.useState)([]),[i,o]=(0,Z.useState)(``),s=(0,Z.useCallback)(async()=>{try{let t=await a.getSessionWorkflowRuns(e);r(t.runs||[])}catch{}},[e]);return(0,Z.useEffect)(()=>{s();let e=window.setInterval(s,1500);return()=>window.clearInterval(e)},[s]),n.length?(0,Q.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,Q.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,Q.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:()=>o(n?``:e.id),children:[(0,Q.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,Q.jsx)(xe,{size:14})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:e.workflowName}),(0,Q.jsxs)(`small`,{children:[Wo(e.status,t),` · v`,e.workflowRevision||1]})]}),(0,Q.jsx)(V,{value:e.status===`completed`?100:r}),n?(0,Q.jsx)(le,{size:14}):(0,Q.jsx)(Me,{size:14})]}),n&&(0,Q.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,Q.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,Q.jsx)(`strong`,{children:t(`chat:workflowRun.request`)}),(0,Q.jsx)(`p`,{children:e.sourceMessage})]}),e.inputs&&Object.keys(e.inputs).length>0&&(0,Q.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,Q.jsx)(`strong`,{children:t(`chat:workflowRun.inputs`)}),(0,Q.jsx)(`pre`,{children:JSON.stringify(e.inputs,null,2)})]}),(e.nodes||[]).map(n=>(0,Q.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,Q.jsx)(G,{size:13}):n.status===`failed`?(0,Q.jsx)(te,{size:13}):n.status===`running`?(0,Q.jsx)(J,{className:`animate-spin`,size:13}):(0,Q.jsx)(Te,{size:11}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:n.label}),(n.error||n.summary)&&(0,Q.jsx)(`small`,{children:n.error||n.summary})]}),n.status===`waiting_approval`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(d,{size:`xs`,onClick:async()=>{await a.resolveWorkflowApproval(e.id,n.id,!0),await s()},children:t(`chat:workflowRun.approve`)}),(0,Q.jsx)(d,{size:`xs`,variant:`destructive`,onClick:async()=>{await a.resolveWorkflowApproval(e.id,n.id,!1),await s()},children:t(`chat:workflowRun.reject`)})]})]},n.id)),(e.error||e.summary)&&(0,Q.jsx)(`p`,{children:e.error||e.summary}),Uo(e)&&(0,Q.jsxs)(d,{size:`xs`,variant:`destructive`,onClick:async()=>{await a.stopWorkflowRun(e.id),await s()},children:[(0,Q.jsx)(Te,{"data-icon":`inline-start`}),t(`chat:workflowRun.stop`)]})]})]},e.id)})}):null}(0,Z.lazy)(()=>i(()=>import(`./ClickSpark-BhxL8WOQ.js`).then(e=>({default:e.ClickSpark})),__vite__mapDeps([29,1,2,3,4,6])));var Ko=(0,Z.createContext)(null),qo=({className:e,approval:t,state:n,...r})=>{let i=(0,Z.useMemo)(()=>({approval:t,state:n}),[t,n]);return!t||n===`input-streaming`||n===`input-available`?null:(0,Q.jsx)(Ko.Provider,{value:i,children:(0,Q.jsx)(yt,{className:W(`flex flex-col gap-2`,e),...r})})};function Jo({approvals:e,onResolve:t,compact:n=!1}){let{t:r}=v(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(!1),l=e[0];if((0,Z.useEffect)(()=>s(!1),[l?.id]),!l)return null;let u=l.fileChange,f=typeof u?.diff==`string`?u.diff:``,p=async e=>{if(!c.current){c.current=!0,a(!0);try{await t(l.id,e)}finally{c.current=!1,a(!1)}}};return(0,Q.jsxs)(qo,{approval:{id:l.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":l.id,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(we,{size:n?12:15}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:r(`chat:focusSession.toolRequestsApproval`,{tool:l.toolName})}),(0,Q.jsxs)(`small`,{children:[l.reason,e.length>1?` · ${r(`chat:focusSession.countMoreWaiting`,{count:e.length-1})}`:``]})]})]}),!n&&(0,Q.jsxs)(`div`,{className:`flex [grid-column:1/-1] items-center gap-[10px]`,children:[f&&(0,Q.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,Q.jsx)(In,{size:13}),r(`chat:focusSession.gitViewDiff`)]}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{children:r(`chat:focusSession.viewCallArguments`)}),(0,Q.jsx)(`pre`,{children:JSON.stringify(l.args,null,2)})]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-[5px]`,children:[(0,Q.jsx)(d,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:i,onClick:()=>p(!1),children:r(`chat:focusSession.deny`)}),(0,Q.jsxs)(d,{type:`button`,size:`lg`,disabled:i,onClick:()=>p(!0),children:[i?(0,Q.jsx)(J,{className:`animate-spin`,size:12}):(0,Q.jsx)(G,{size:12}),r(`chat:focusSession.allow`)]})]}),o&&(0,Q.jsx)(xo,{diff:f,truncated:!!u?.truncated,onClose:()=>s(!1)})]})}function Yo({notify:e,onOpenModelSettings:t,onInsertPrompt:n}){let{t:r}=v(),i=async()=>{try{let i=await s(`/api/visual/models`);i.image||i.video?n(r(`chat:focusSession.visualPromptTemplate`)):(e?.(r(`chat:focusSession.configureVisualModelFirst`)),t?.())}catch{n(r(`chat:focusSession.visualPromptTemplate`))}};return(0,Q.jsx)(`button`,{type:`button`,className:`visual-entry-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:r(`chat:focusSession.generateImage`),"aria-label":r(`chat:focusSession.generateImage`),onClick:()=>void i(),children:(0,Q.jsx)(Vn,{size:16})})}function Xo(e){return(e.target instanceof Element?e.target:null)?.closest(`[data-shortcut-recorder], [role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], .xterm, .terminal-xterm, .terminal-panel, [data-terminal]`)?!0:Array.from(document.querySelectorAll(`[role="dialog"], [role="alertdialog"], dialog[open]`)).some(e=>e.getClientRects().length>0)}function Zo(e){let t=(0,Z.useRef)(e);t.current=e;let{enabled:n,binding:r}=e;(0,Z.useEffect)(()=>{if(!n||!r)return;let e=null,i=null,a=()=>{e=null,i&&(i=null,t.current.onCancel())},o=n=>{if(i&&n.key===`Escape`&&!n.isComposing){a(),n.preventDefault();return}!t.current.enabled||n.defaultPrevented||n.isComposing||n.keyCode===229||n.repeat||e||document.visibilityState===`hidden`||Xo(n)||!pt(n,r)||(e=n.code,t.current.onStart()&&(i={code:n.code,ctrl:n.ctrlKey,meta:n.metaKey,alt:n.altKey,shift:n.shiftKey},n.preventDefault()))},s=n=>{n.code===e&&(e=null),i&&(n.code===i.code||i.ctrl&&(!n.ctrlKey||n.code.startsWith(`Control`))||i.meta&&(!n.metaKey||n.code.startsWith(`Meta`))||i.alt&&(!n.altKey||n.code.startsWith(`Alt`))||i.shift&&(!n.shiftKey||n.code.startsWith(`Shift`)))&&(i=null,t.current.onRelease())},c=()=>{document.visibilityState===`hidden`&&a()};return window.addEventListener(`keydown`,o),window.addEventListener(`keyup`,s,!0),window.addEventListener(`blur`,a),document.addEventListener(`visibilitychange`,c),()=>{window.removeEventListener(`keydown`,o),window.removeEventListener(`keyup`,s,!0),window.removeEventListener(`blur`,a),document.removeEventListener(`visibilitychange`,c),a()}},[n,r])}function Qo(e){if(!e.length)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];let n=Math.sqrt(t/e.length);return n<.0056?0:Math.min(1,Math.sqrt(n)*2.6)}function $o(e=.35){let t=0;return{push(n){return t=t*(1-e)+n*e,t},reset(){t=0}}}function es(e,t=140){let n=e.trim();return n.length>t?`${n.slice(0,t-1)}…`:n}var ts=16e3,ns=20,rs=ts*ns/1e3;function is(e,{onsetMs:t=80,minVoicedMs:n=160,silenceMs:r=900}={}){for(let e of[t,n,r])if(!Number.isFinite(e)||e<=0)throw Error(`Invalid VAD endpoint duration`);let i=e(),a=new Int16Array(rs),o=0,s=0,c=0,l=0,u=!1,d=!1,f=!1,p=()=>u&&c*ns>=n;return{get hasSpeech(){return p()},acceptPcm(e){if(f||d)return!1;for(let n=0;n<e.length;n+=1){let f=Number.isFinite(e[n])?Math.max(-1,Math.min(1,e[n])):0;if(a[o++]=f*(f<0?32768:32767),o!==rs)continue;o=0;let m=i.processFrame(a);if(m<0)throw Error(`VAD frame processing failed`);if(m===1)s+=1,c+=1,l=0,s*ns>=t&&(u=!0);else if(s=0,l+=1,u||(c=0),l*ns>=r){if(p())return d=!0,!0;u=!1,c=0}}return!1},reset(){f||(i.destroy(),i=e(),o=s=c=l=0,u=d=!1,a.fill(0))},dispose(){f||(f=!0,o=0,i.destroy())}}}async function as(e={}){let{default:t,VADMode:n}=await i(async()=>{let{default:e,VADMode:t}=await import(`./embedded-D2rqyswH.js`);return{default:e,VADMode:t}},[]),r=await t();return is(()=>new r(e.mode??n.AGGRESSIVE,ts),e)}var os=()=>new DOMException(`Speech setup cancelled.`,`AbortError`);function ss(e){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),l=(0,Z.useRef)(null),u=(0,Z.useRef)(!1),d=(0,Z.useRef)(0),f=(0,Z.useRef)(0),p=(0,Z.useRef)(0),m=(0,Z.useRef)(e);m.current=e;let h=(0,Z.useCallback)(e=>{d.current++,f.current++;let t=l.current;l.current=null,t&&(t.signal.removeEventListener(`abort`,t.abort),e?t.reject(e):t.resolve()),u.current&&(i(!1),o(!1))},[]),g=(0,Z.useCallback)(e=>{u.current&&(n(e),c(``),l.current&&Nt(e,m.current).every(e=>e.status===`installed`)&&h())},[h]),_=(0,Z.useCallback)(async e=>{let t=d.current,n=++f.current,r=()=>u.current&&t===d.current&&n===f.current&&!e?.aborted;try{let t=await Et(e);r()&&g(t)}catch(e){if(r())throw e}},[g]);(0,Z.useEffect)(()=>(u.current=!0,_().catch(()=>{}),()=>{u.current=!1,h(os())}),[h,_]),(0,Z.useEffect)(()=>{if(!r)return;let e=new AbortController,t,n=async()=>{try{await _(e.signal)}catch(t){e.signal.aborted||c(t instanceof Error?t.message:String(t))}finally{e.signal.aborted||(t=setTimeout(()=>void n(),750))}};return n(),()=>{e.abort(),clearTimeout(t)}},[r,_]);let v=(0,Z.useCallback)(async e=>{if(X(e),!u.current)throw os();h(os());let t=++f.current;return new Promise((n,r)=>{let a=()=>{l.current===o&&h(e.reason||os())},o={signal:e,abort:a,resolve:n,reject:r};if(l.current=o,e.addEventListener(`abort`,a,{once:!0}),e.aborted){a();return}Et(e).then(n=>{!u.current||l.current!==o||e.aborted||(t===f.current&&g(n),l.current===o&&i(!0))},e=>{l.current===o&&h(e)})})},[g,h]),y=(0,Z.useCallback)(async e=>{let t=d.current,n=++p.current,r=()=>u.current&&t===d.current&&n===p.current;o(!0),c(``);try{await e(),r()&&await _()}catch(e){r()&&c(e instanceof Error?e.message:String(e))}finally{r()&&o(!1)}},[_]);return{catalog:t,open:r,loading:a,error:s,selectedVoice:t?.defaults.voice||``,ensureReady:v,models:t?Nt(t,e):[],show:()=>{h(os()),i(!0),c(``)},close:()=>h(os()),download:e=>y(()=>jt(e)),cancelDownload:e=>y(()=>At(e)),downloadAll:()=>y(async()=>{if(t)for(let e of Nt(t,m.current))[`installed`,`downloading`,`verifying`].includes(e.status)||await jt(e.id)})}}var cs=8388608;function ls(e,t){return X(t),new Promise((n,r)=>{let i=()=>r(wt(t));t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var us=10,ds=500;async function fs(e,t,n,r){for(let i=0;;i+=1){let a=await fetch(`/api/speech/synthesize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voiceId:t,requestId:n}),signal:r});if(a.status!==409||i>=us)return a;let o=await a.json().catch(()=>({}));if(!o.error||!/busy/i.test(o.error))return a;await ls(new Promise(e=>setTimeout(e,ds)),r)}}async function ps(e){if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Speech synthesis failed (${e.status}).`)}if(!e.headers.get(`content-type`)?.startsWith(`audio/wav`)||!e.body)throw Error(`Invalid speech audio response.`);let t=e.body.getReader(),n=[],r=0;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;if(r+=i.byteLength,r>cs)throw Error(`Speech audio exceeds the supported limit.`);n.push(i)}}finally{await t.cancel().catch(()=>{}),t.releaseLock()}if(r<44)throw Error(`Speech audio is empty.`);let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.length;return i.buffer}async function ms(e,t,n,r){X(n);let i=Ct(n);try{await hs(e,t,i,r)}finally{i.abort(new DOMException(`Speech playback ended.`,`AbortError`)),i.dispose()}}async function hs(e,t,n,r){let{signal:a}=n,{speechSegments:o}=await ls(i(()=>import(`./speech-text-Js_tr4qo.js`),__vite__mapDeps([30,31,1,2,11,4,32,33,34])),a);X(a);let c=(typeof e==`string`?(async function*(){yield*o(e)})():(await ls(i(()=>import(`./speech-stream-text-Cwsgaoku.js`),__vite__mapDeps([35,31,1,2,11,4,32,33,34,36,30])),a)).streamingSpeechSegments(e,a))[Symbol.asyncIterator](),l=!!window.__PISPER_MOBILE_APP__,u=new Set,d,f,p,m=e=>{(l?Ot(`mobile_cancel_speech`,{requestId:e}):s(`/api/speech/cancel`,{method:`POST`,body:{requestId:e},timeout:3e3})).catch(()=>{})},h=()=>{for(let e of u)m(e);try{f?.stop()}catch{}p?.(a.reason||new DOMException(`Speech playback cancelled.`,`AbortError`))};a.addEventListener(`abort`,h,{once:!0});let g=e=>{X(a);let n=crypto.randomUUID();u.add(n);let r=(async()=>{if(l){let r=await Ot(`mobile_synthesize_speech`,{text:e,voiceId:t,requestId:n});if(a.aborted&&(m(n),X(a)),!r||typeof r.audioId!=`string`||!r.audioId.trim()||r.audioId.length>128||!Number.isInteger(r.sampleRate)||r.sampleRate<8e3||r.sampleRate>48e3||!Number.isFinite(r.durationMs)||r.durationMs<=0||r.durationMs>45e3)throw Error(`Invalid native speech audio.`);return{requestId:n,native:r}}let r=Ct(a,6e4);try{let i=await fs(e,t,n,r.signal);return{requestId:n,wav:await ps(i)}}finally{r.dispose()}})();return r.catch(()=>{}),r};try{if(!l){d=new AudioContext({sampleRate:24e3});let e;try{await ls(Promise.race([d.resume(),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Audio playback is unavailable.`)),5e3)})]),a)}finally{clearTimeout(e)}}let e=async()=>{let e=await ls(c.next(),a);return e.done?void 0:g(e.value)},t=e(),n=!1;for(;;){let i=await ls(t,a);if(X(a),!i)break;if(t=e(),t.catch(()=>{}),n=!0,r?.(),i.native){if((await ls(Ot(`mobile_play_speech`,{audioId:i.native.audioId,requestId:i.requestId}),a))?.completed!==!0)throw Error(`Speech playback was interrupted.`)}else{let e=await ls(d.decodeAudioData(i.wav),a);if(X(a),e.numberOfChannels!==1||!Number.isFinite(e.duration)||e.duration<=0||e.duration>45)throw Error(`Invalid speech audio duration.`);let t=d.createBufferSource();f=t,t.buffer=e,t.connect(d.destination);try{await new Promise((e,n)=>{p=n,t.onended=()=>e(),t.start()})}finally{p=void 0,t.onended=null,t.disconnect(),f=void 0}}u.delete(i.requestId),X(a)}if(!n)throw Error(`The reply has no speakable text.`)}finally{a.removeEventListener(`abort`,h),n.abort(new DOMException(`Speech playback ended.`,`AbortError`)),c.return?.(void 0).catch(()=>{});for(let e of u)m(e);try{f?.stop()}catch{}await d?.close().catch(()=>{})}}var gs={schemaVersion:1,scope:`Offline license texts and provenance notices for the catalogued speech resources and local derivatives. This document is not legal advice, commercial-use clearance, a complete training-data rights audit, or approval for redistribution or formal release. Packaging this small notice file does not package the large models or resolve pending obligations. Native sherpa binaries and their compiled or embedded dependencies require a separate license/linkage and source-delivery audit; switching TTS models does not prove the binaries contain no GPL components or satisfy their obligations.`,licenseIdsMeaning:`References identify retained license documents applicable to the described components or their stated source projects. Multiple references are not alternative dual-license choices and are not a complete SPDX expression. A repository declaration does not relicense unrelated bundled data.`,statusDefinitions:{confirmed:`The specific content or source match described in summary was verified; this is not a whole-chain rights guarantee.`,declared:`An upstream license declaration supports the classification, without a complete reproducible provenance proof.`,pending:`The listed provenance, rights, or distribution obligations remain unresolved even where a license declaration exists.`},pathScopes:{model:`Paths are relative to the original downloaded model root. A terminal /** matches every descendant; all other paths are exact.`,shared:`Paths are relative to the application's shared resource root.`},licenses:[{id:`apache-2.0`,name:`Apache License 2.0 (X-ASR source text)`,text:` Apache License
8
+ Version 2.0, January 2004
9
+ http://www.apache.org/licenses/
10
+
11
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
12
+
13
+ 1. Definitions.
14
+
15
+ "License" shall mean the terms and conditions for use, reproduction,
16
+ and distribution as defined by Sections 1 through 9 of this document.
17
+
18
+ "Licensor" shall mean the copyright owner or entity authorized by
19
+ the copyright owner that is granting the License.
20
+
21
+ "Legal Entity" shall mean the union of the acting entity and all
22
+ other entities that control, are controlled by, or are under common
23
+ control with that entity. For the purposes of this definition,
24
+ "control" means (i) the power, direct or indirect, to cause the
25
+ direction or management of such entity, whether by contract or
26
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
27
+ outstanding shares, or (iii) beneficial ownership of such entity.
28
+
29
+ "You" (or "Your") shall mean an individual or Legal Entity
30
+ exercising permissions granted by this License.
31
+
32
+ "Source" form shall mean the preferred form for making modifications,
33
+ including but not limited to software source code, documentation
34
+ source, and configuration files.
35
+
36
+ "Object" form shall mean any form resulting from mechanical
37
+ transformation or translation of a Source form, including but
38
+ not limited to compiled object code, generated documentation,
39
+ and conversions to other media types.
40
+
41
+ "Work" shall mean the work of authorship, whether in Source or
42
+ Object form, made available under the License, as indicated by a
43
+ copyright notice that is included in or attached to the work
44
+ (an example is provided in the Appendix below).
45
+
46
+ "Derivative Works" shall mean any work, whether in Source or Object
47
+ form, that is based on (or derived from) the Work and for which the
48
+ editorial revisions, annotations, elaborations, or other modifications
49
+ represent, as a whole, an original work of authorship. For the purposes
50
+ of this License, Derivative Works shall not include works that remain
51
+ separable from, or merely link (or bind by name) to the interfaces of,
52
+ the Work and Derivative Works thereof.
53
+
54
+ "Contribution" shall mean any work of authorship, including
55
+ the original version of the Work and any modifications or additions
56
+ to that Work or Derivative Works thereof, that is intentionally
57
+ submitted to Licensor for inclusion in the Work by the copyright owner
58
+ or by an individual or Legal Entity authorized to submit on behalf of
59
+ the copyright owner. For the purposes of this definition, "submitted"
60
+ means any form of electronic, verbal, or written communication sent
61
+ to the Licensor or its representatives, including but not limited to
62
+ communication on electronic mailing lists, source code control systems,
63
+ and issue tracking systems that are managed by, or on behalf of, the
64
+ Licensor for the purpose of discussing and improving the Work, but
65
+ excluding communication that is conspicuously marked or otherwise
66
+ designated in writing by the copyright owner as "Not a Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any individual or Legal Entity
69
+ on behalf of whom a Contribution has been received by Licensor and
70
+ subsequently incorporated within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent claims licensable
85
+ by such Contributor that are necessarily infringed by their
86
+ Contribution(s) alone or by combination of their Contribution(s)
87
+ with the Work to which such Contribution(s) was submitted. If You
88
+ institute patent litigation against any entity (including a
89
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
90
+ or a Contribution incorporated within the Work constitutes direct
91
+ or contributory patent infringement, then any patent licenses
92
+ granted to You under this License for that Work shall terminate
93
+ as of the date such litigation is filed.
94
+
95
+ 4. Redistribution. You may reproduce and distribute copies of the
96
+ Work or Derivative Works thereof in any medium, with or without
97
+ modifications, and in Source or Object form, provided that You
98
+ meet the following conditions:
99
+
100
+ (a) You must give any other recipients of the Work or
101
+ Derivative Works a copy of this License; and
102
+
103
+ (b) You must cause any modified files to carry prominent notices
104
+ stating that You changed the files; and
105
+
106
+ (c) You must retain, in the Source form of any Derivative Works
107
+ that You distribute, all copyright, patent, trademark, and
108
+ attribution notices from the Source form of the Work,
109
+ excluding those notices that do not pertain to any part of
110
+ the Derivative Works; and
111
+
112
+ (d) If the Work includes a "NOTICE" text file as part of its
113
+ distribution, then any Derivative Works that You distribute must
114
+ include a readable copy of the attribution notices contained
115
+ within such NOTICE file, excluding those notices that do not
116
+ pertain to any part of the Derivative Works, in at least one
117
+ of the following places: within a NOTICE text file distributed
118
+ as part of the Derivative Works; within the Source form or
119
+ documentation, if provided along with the Derivative Works; or,
120
+ within a display generated by the Derivative Works, if and
121
+ wherever such third-party notices normally appear. The contents
122
+ of the NOTICE file are for informational purposes only and
123
+ do not modify the License. You may add Your own attribution
124
+ notices within Derivative Works that You distribute, alongside
125
+ or as an addendum to the NOTICE text from the Work, provided
126
+ that such additional attribution notices cannot be construed
127
+ as modifying the License.
128
+
129
+ You may add Your own copyright statement to Your modifications and
130
+ may provide additional or different license terms and conditions
131
+ for use, reproduction, or distribution of Your modifications, or
132
+ for any such Derivative Works as a whole, provided Your use,
133
+ reproduction, and distribution of the Work otherwise complies with
134
+ the conditions stated in this License.
135
+
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+
144
+ 6. Trademarks. This License does not grant permission to use the trade
145
+ names, trademarks, service marks, or product names of the Licensor,
146
+ except as required for reasonable and customary use in describing the
147
+ origin of the Work and reproducing the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or conditions
154
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
155
+ PARTICULAR PURPOSE. You are solely responsible for determining the
156
+ appropriateness of using or redistributing the Work and assume any
157
+ risks associated with Your exercise of permissions under this License.
158
+
159
+ 8. Limitation of Liability. In no event and under no legal theory,
160
+ whether in tort (including negligence), contract, or otherwise,
161
+ unless required by applicable law (such as deliberate and grossly
162
+ negligent acts) or agreed to in writing, shall any Contributor be
163
+ liable to You for damages, including any direct, indirect, special,
164
+ incidental, or consequential damages of any character arising as a
165
+ result of this License or out of the use or inability to use the
166
+ Work (including but not limited to damages for loss of goodwill,
167
+ work stoppage, computer failure or malfunction, or any and all
168
+ other commercial damages or losses), even if such Contributor
169
+ has been advised of the possibility of such damages.
170
+
171
+ 9. Accepting Warranty or Additional Liability. While redistributing
172
+ the Work or Derivative Works thereof, You may choose to offer,
173
+ and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this
175
+ License. However, in accepting such obligations, You may act only
176
+ on Your own behalf and on Your sole responsibility, not on behalf
177
+ of any other Contributor, and only if You agree to indemnify,
178
+ defend, and hold each Contributor harmless for any liability
179
+ incurred by, or claims asserted against, such Contributor by reason
180
+ of your accepting any such warranty or additional liability.
181
+
182
+ END OF TERMS AND CONDITIONS
183
+
184
+ APPENDIX: How to apply the Apache License to your work.
185
+
186
+ To apply the Apache License to your work, attach the following
187
+ boilerplate notice, with the fields enclosed by brackets "[]"
188
+ replaced with your own identifying information. (Don't include
189
+ the brackets!) The text should be enclosed in the appropriate
190
+ comment syntax for the file format. We also recommend that a
191
+ file or class name and description of purpose be included on the
192
+ same "printed page" as the copyright notice for easier
193
+ identification within third-party archives.
194
+
195
+ Copyright [yyyy] [name of copyright owner]
196
+
197
+ Licensed under the Apache License, Version 2.0 (the "License");
198
+ you may not use this file except in compliance with the License.
199
+ You may obtain a copy of the License at
200
+
201
+ http://www.apache.org/licenses/LICENSE-2.0
202
+
203
+ Unless required by applicable law or agreed to in writing, software
204
+ distributed under the License is distributed on an "AS IS" BASIS,
205
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
206
+ See the License for the specific language governing permissions and
207
+ limitations under the License.
208
+ `,sourceUrl:`https://raw.githubusercontent.com/Gilgamesh-J/X-ASR/838297cd47fed858e6cf72eaf5a52f948a3edd73/LICENSE`,sha256:`c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4`},{id:`mit-melo`,name:`MIT License (MeloTTS source and conversion package)`,text:`Copyright (c) 2024 MyShell.ai
209
+
210
+ Permission is hereby granted, free of charge, to any person obtaining a copy
211
+ of this software and associated documentation files (the "Software"), to deal
212
+ in the Software without restriction, including without limitation the rights
213
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
214
+ copies of the Software, and to permit persons to whom the Software is
215
+ furnished to do so, subject to the following conditions:
216
+
217
+ The above copyright notice and this permission notice shall be included in all
218
+ copies or substantial portions of the Software.
219
+
220
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
221
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
222
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
223
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
224
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
225
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
226
+ SOFTWARE.`,sourceUrl:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{id:`apache-2.0-sherpa`,name:`Apache License 2.0 (sherpa conversion code; FST source declaration)`,text:`
227
+ Apache License
228
+ Version 2.0, January 2004
229
+ http://www.apache.org/licenses/
230
+
231
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
232
+
233
+ 1. Definitions.
234
+
235
+ "License" shall mean the terms and conditions for use, reproduction,
236
+ and distribution as defined by Sections 1 through 9 of this document.
237
+
238
+ "Licensor" shall mean the copyright owner or entity authorized by
239
+ the copyright owner that is granting the License.
240
+
241
+ "Legal Entity" shall mean the union of the acting entity and all
242
+ other entities that control, are controlled by, or are under common
243
+ control with that entity. For the purposes of this definition,
244
+ "control" means (i) the power, direct or indirect, to cause the
245
+ direction or management of such entity, whether by contract or
246
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
247
+ outstanding shares, or (iii) beneficial ownership of such entity.
248
+
249
+ "You" (or "Your") shall mean an individual or Legal Entity
250
+ exercising permissions granted by this License.
251
+
252
+ "Source" form shall mean the preferred form for making modifications,
253
+ including but not limited to software source code, documentation
254
+ source, and configuration files.
255
+
256
+ "Object" form shall mean any form resulting from mechanical
257
+ transformation or translation of a Source form, including but
258
+ not limited to compiled object code, generated documentation,
259
+ and conversions to other media types.
260
+
261
+ "Work" shall mean the work of authorship, whether in Source or
262
+ Object form, made available under the License, as indicated by a
263
+ copyright notice that is included in or attached to the work
264
+ (an example is provided in the Appendix below).
265
+
266
+ "Derivative Works" shall mean any work, whether in Source or Object
267
+ form, that is based on (or derived from) the Work and for which the
268
+ editorial revisions, annotations, elaborations, or other modifications
269
+ represent, as a whole, an original work of authorship. For the purposes
270
+ of this License, Derivative Works shall not include works that remain
271
+ separable from, or merely link (or bind by name) to the interfaces of,
272
+ the Work and Derivative Works thereof.
273
+
274
+ "Contribution" shall mean any work of authorship, including
275
+ the original version of the Work and any modifications or additions
276
+ to that Work or Derivative Works thereof, that is intentionally
277
+ submitted to Licensor for inclusion in the Work by the copyright owner
278
+ or by an individual or Legal Entity authorized to submit on behalf of
279
+ the copyright owner. For the purposes of this definition, "submitted"
280
+ means any form of electronic, verbal, or written communication sent
281
+ to the Licensor or its representatives, including but not limited to
282
+ communication on electronic mailing lists, source code control systems,
283
+ and issue tracking systems that are managed by, or on behalf of, the
284
+ Licensor for the purpose of discussing and improving the Work, but
285
+ excluding communication that is conspicuously marked or otherwise
286
+ designated in writing by the copyright owner as "Not a Contribution."
287
+
288
+ "Contributor" shall mean Licensor and any individual or Legal Entity
289
+ on behalf of whom a Contribution has been received by Licensor and
290
+ subsequently incorporated within the Work.
291
+
292
+ 2. Grant of Copyright License. Subject to the terms and conditions of
293
+ this License, each Contributor hereby grants to You a perpetual,
294
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
295
+ copyright license to reproduce, prepare Derivative Works of,
296
+ publicly display, publicly perform, sublicense, and distribute the
297
+ Work and such Derivative Works in Source or Object form.
298
+
299
+ 3. Grant of Patent License. Subject to the terms and conditions of
300
+ this License, each Contributor hereby grants to You a perpetual,
301
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
302
+ (except as stated in this section) patent license to make, have made,
303
+ use, offer to sell, sell, import, and otherwise transfer the Work,
304
+ where such license applies only to those patent claims licensable
305
+ by such Contributor that are necessarily infringed by their
306
+ Contribution(s) alone or by combination of their Contribution(s)
307
+ with the Work to which such Contribution(s) was submitted. If You
308
+ institute patent litigation against any entity (including a
309
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
310
+ or a Contribution incorporated within the Work constitutes direct
311
+ or contributory patent infringement, then any patent licenses
312
+ granted to You under this License for that Work shall terminate
313
+ as of the date such litigation is filed.
314
+
315
+ 4. Redistribution. You may reproduce and distribute copies of the
316
+ Work or Derivative Works thereof in any medium, with or without
317
+ modifications, and in Source or Object form, provided that You
318
+ meet the following conditions:
319
+
320
+ (a) You must give any other recipients of the Work or
321
+ Derivative Works a copy of this License; and
322
+
323
+ (b) You must cause any modified files to carry prominent notices
324
+ stating that You changed the files; and
325
+
326
+ (c) You must retain, in the Source form of any Derivative Works
327
+ that You distribute, all copyright, patent, trademark, and
328
+ attribution notices from the Source form of the Work,
329
+ excluding those notices that do not pertain to any part of
330
+ the Derivative Works; and
331
+
332
+ (d) If the Work includes a "NOTICE" text file as part of its
333
+ distribution, then any Derivative Works that You distribute must
334
+ include a readable copy of the attribution notices contained
335
+ within such NOTICE file, excluding those notices that do not
336
+ pertain to any part of the Derivative Works, in at least one
337
+ of the following places: within a NOTICE text file distributed
338
+ as part of the Derivative Works; within the Source form or
339
+ documentation, if provided along with the Derivative Works; or,
340
+ within a display generated by the Derivative Works, if and
341
+ wherever such third-party notices normally appear. The contents
342
+ of the NOTICE file are for informational purposes only and
343
+ do not modify the License. You may add Your own attribution
344
+ notices within Derivative Works that You distribute, alongside
345
+ or as an addendum to the NOTICE text from the Work, provided
346
+ that such additional attribution notices cannot be construed
347
+ as modifying the License.
348
+
349
+ You may add Your own copyright statement to Your modifications and
350
+ may provide additional or different license terms and conditions
351
+ for use, reproduction, or distribution of Your modifications, or
352
+ for any such Derivative Works as a whole, provided Your use,
353
+ reproduction, and distribution of the Work otherwise complies with
354
+ the conditions stated in this License.
355
+
356
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
357
+ any Contribution intentionally submitted for inclusion in the Work
358
+ by You to the Licensor shall be under the terms and conditions of
359
+ this License, without any additional terms or conditions.
360
+ Notwithstanding the above, nothing herein shall supersede or modify
361
+ the terms of any separate license agreement you may have executed
362
+ with Licensor regarding such Contributions.
363
+
364
+ 6. Trademarks. This License does not grant permission to use the trade
365
+ names, trademarks, service marks, or product names of the Licensor,
366
+ except as required for reasonable and customary use in describing the
367
+ origin of the Work and reproducing the content of the NOTICE file.
368
+
369
+ 7. Disclaimer of Warranty. Unless required by applicable law or
370
+ agreed to in writing, Licensor provides the Work (and each
371
+ Contributor provides its Contributions) on an "AS IS" BASIS,
372
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
373
+ implied, including, without limitation, any warranties or conditions
374
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
375
+ PARTICULAR PURPOSE. You are solely responsible for determining the
376
+ appropriateness of using or redistributing the Work and assume any
377
+ risks associated with Your exercise of permissions under this License.
378
+
379
+ 8. Limitation of Liability. In no event and under no legal theory,
380
+ whether in tort (including negligence), contract, or otherwise,
381
+ unless required by applicable law (such as deliberate and grossly
382
+ negligent acts) or agreed to in writing, shall any Contributor be
383
+ liable to You for damages, including any direct, indirect, special,
384
+ incidental, or consequential damages of any character arising as a
385
+ result of this License or out of the use or inability to use the
386
+ Work (including but not limited to damages for loss of goodwill,
387
+ work stoppage, computer failure or malfunction, or any and all
388
+ other commercial damages or losses), even if such Contributor
389
+ has been advised of the possibility of such damages.
390
+
391
+ 9. Accepting Warranty or Additional Liability. While redistributing
392
+ the Work or Derivative Works thereof, You may choose to offer,
393
+ and charge a fee for, acceptance of support, warranty, indemnity,
394
+ or other liability obligations and/or rights consistent with this
395
+ License. However, in accepting such obligations, You may act only
396
+ on Your own behalf and on Your sole responsibility, not on behalf
397
+ of any other Contributor, and only if You agree to indemnify,
398
+ defend, and hold each Contributor harmless for any liability
399
+ incurred by, or claims asserted against, such Contributor by reason
400
+ of your accepting any such warranty or additional liability.
401
+
402
+ END OF TERMS AND CONDITIONS
403
+
404
+ APPENDIX: How to apply the Apache License to your work.
405
+
406
+ To apply the Apache License to your work, attach the following
407
+ boilerplate notice, with the fields enclosed by brackets "[]"
408
+ replaced with your own identifying information. (Don't include
409
+ the brackets!) The text should be enclosed in the appropriate
410
+ comment syntax for the file format. We also recommend that a
411
+ file or class name and description of purpose be included on the
412
+ same "printed page" as the copyright notice for easier
413
+ identification within third-party archives.
414
+
415
+ Copyright [yyyy] [name of copyright owner]
416
+
417
+ Licensed under the Apache License, Version 2.0 (the "License");
418
+ you may not use this file except in compliance with the License.
419
+ You may obtain a copy of the License at
420
+
421
+ http://www.apache.org/licenses/LICENSE-2.0
422
+
423
+ Unless required by applicable law or agreed to in writing, software
424
+ distributed under the License is distributed on an "AS IS" BASIS,
425
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
426
+ See the License for the specific language governing permissions and
427
+ limitations under the License.
428
+ `,sourceUrl:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`},{id:`mit-cppjieba`,name:`MIT License (CppJieba release source)`,text:`The MIT License (MIT)
429
+
430
+ Copyright (c) 2013
431
+
432
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
433
+ this software and associated documentation files (the "Software"), to deal in
434
+ the Software without restriction, including without limitation the rights to
435
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
436
+ the Software, and to permit persons to whom the Software is furnished to do so,
437
+ subject to the following conditions:
438
+
439
+ The above copyright notice and this permission notice shall be included in all
440
+ copies or substantial portions of the Software.
441
+
442
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
443
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
444
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
445
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
446
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
447
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
448
+ `,sourceUrl:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{id:`mit-pypinyin`,name:`MIT License (pypinyin project; historical data provenance pending)`,text:`The MIT License (MIT)
449
+
450
+ Copyright (c) 2016 mozillazg, 闲耘 <hotoo.cn@gmail.com>
451
+
452
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
453
+ this software and associated documentation files (the "Software"), to deal in
454
+ the Software without restriction, including without limitation the rights to
455
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
456
+ the Software, and to permit persons to whom the Software is furnished to do so,
457
+ subject to the following conditions:
458
+
459
+ The above copyright notice and this permission notice shall be included in all
460
+ copies or substantial portions of the Software.
461
+
462
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
463
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
464
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
465
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
466
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
467
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
468
+ `,sourceUrl:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/LICENSE.txt`,sha256:`1e6c90014b4912815c296ee64bb6f6280af47e6d4c5d80e86232dfc5defe764c`},{id:`cmudict-0.6-1998`,name:`CMU Pronouncing Dictionary 0.6 historical permission and attribution notice (1998)`,text:`## Date: August 8, 1998
469
+ ##
470
+ ## The Carnegie Mellon Pronouncing Dictionary [cmudict.0.6] is Copyright 1998
471
+ ## by Carnegie Mellon University. Use of this dictionary, for any research or
472
+ ## commercial purpose, is completely unrestricted. If you make use of or
473
+ ## redistribute this material, we would appreciate acknowlegement of its
474
+ ## origin.
475
+ ##
476
+ ## cmudict.0.6 is the fifth release of cmudict, first released as cmudict.0.1
477
+ ## in September of 1993. There was no generally available public release
478
+ ## of version 0.5.
479
+ ##
480
+ ## See the README in this directory before you use this dictionary.
481
+ ##
482
+ ## Thanks to Bill Huggins at BBN; Bill Fisher at NIST; Alex Hauptman,
483
+ ## Alex Rudnicky, Jack Mostow, Roni Rosenfeld, Richard Stern,
484
+ ## Matthew Siegler, Kevin Lenzo, Maxine Eskenazi, Mosur Ravishankar,
485
+ ## Eric Thayer, Kristie Seymore, and Raj Reddy at CMU; Lin Chase at
486
+ ## LIMSI; Doug Paul at MIT Lincoln Labs; Ben Serridge at MIT SLS; Murray
487
+ ## Spiegel at Bellcore; Tony Robinson at Cambridge UK; David Bowness of
488
+ ## CAE Electronics Ltd. and CRIM; Stephen Hocking; Jerry Quinn at BNR
489
+ ## Canada, and Marshal Midden for bringing to our attention problems and
490
+ ## inadequacies with the first releases. Most special thanks to Bob Weide
491
+ ## for all his work on prior versions of the dictionary.
492
+ ##
493
+ ## We welcome input from users and will continue to acknowledge such input
494
+ ## in subsequent releases. If I failed to acknowledge your input in this
495
+ ## release, please remind me and I will update these comments. If I failed to
496
+ ## fix things that you brought to my attention, please remind me and have
497
+ ## patience. If I actually fixed things that you brought to my attention and
498
+ ## you appreciate it, I wouldn't mind a pat on the back.
499
+ ##
500
+ ## This version differs from previous releases of cmudict most significantly
501
+ ## in the addition of new words from the common ARPA tasks for 1996 and 1997.
502
+ ##
503
+ ## There are undoubtedly still errors and inconsistencies in this dictionary
504
+ ## so keep your eyes open for problems and mail them to me.
505
+ ##
506
+ ## We hope this dictionary is an improvement over cmudict.0.4.
507
+ ##
508
+ ## email: cmudict@cs.cmu.edu
509
+ ## web: http://www.speech.cs.cmu.edu/cgi-bin/cmudict
510
+ ## ftp: ftp://ftp.cs.cmu.edu/project/speech/dict/
511
+ ##
512
+ ## Thank you for your continued interest in the CMU Pronouncing
513
+ ## Dictionary. Further addictions and improvements are planned
514
+ ## for forthcoming releases.
515
+ ##
516
+ `,sourceUrl:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`08ee91f3c05c55160bdc599247ba53e5de8cc2597766fdb22b54a81cb24dd954`}],models:[{id:`x-asr-480ms-int8`,revision:`2026-06-05`,attribution:`X-ASR by Gilgamesh-J / GilgameshWind; trained using icefall and deployed with sherpa-onnx. The locked HF model card expressly covers model artifacts and declares Apache-2.0. The separately discovered GitHub license commit is not the locked HF revision. No root LICENSE or NOTICE was listed in the inspected HF tree; this is not proof that every historical distribution lacks NOTICE. Retain applicable upstream notices when found.`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-x-asr-480ms-streaming-zipformer-transducer-zh-en-punct-int8-2026-06-05.tar.bz2`,sha256:`fa5f63d618e5a01526e275a358bb7772e403f84808a4769fba52cffd8160bf74`},groups:[{id:`xasr-weights`,pathScope:`model`,paths:[`encoder.int8.onnx`,`decoder.onnx`,`joiner.int8.onnx`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Apache-2.0 is explicitly declared for X-ASR model artifacts. The sherpa export script describes icefall streaming ONNX export and INT8 quantization; installed file hashes match the catalog, but the 2026-06-05 archive-to-checkpoint/build identity is not established.`,pendingReasons:[`Exact checkpoint and source commits used to build the 2026-06-05 INT8 archive remain unverified; the export script downloads moving main URLs. Training-data rights are not fully audited.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR token resource, not the SentencePiece or sherpa software. The punctuation export block downloads X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/tokens.txt. Catalog content SHA256: b818a60878b9aae978cbb8ad594acbd403d76d1af2e31ef4197c84e2dbdba27c.`,pendingReasons:[`The historical source revision for the token file in the 2026-06-05 archive is not pinned by the export script.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe`,pathScope:`model`,paths:[`bpe.model`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR BPE resource. The export script renames X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/bpe_punc.model to bpe.model. Its license classification comes from X-ASR, not from the software that reads the SentencePiece format.`,pendingReasons:[`The historical BPE source commit and exact archive build provenance remain unverified.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe-vocab`,pathScope:`shared`,paths:[`speech-resources/xasr-bpe.vocab`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Modified by Pisper: extracted the ordered SentencePiece pieces and scores as UTF-8 piece<TAB>score<LF> lines. This local text derivative retains the source resource license classification; it is not newly licensed as Pisper-owned model data. Original and derived hashes and generator are bound by xasr-bpe-extraction below.`,pendingReasons:[`The source BPE historical provenance remains pending as described in xasr-bpe. A text extraction does not resolve upstream rights.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`}]}],modifications:[{id:`xasr-bpe-extraction`,groupIds:[`xasr-bpe-vocab`],modifiedBy:`Pisper`,summary:`Local BPE text extraction, not retraining. The generator identity records the inspected repository implementation, not a claim about a historical upstream build date.`,source:{path:`bpe.model`,bytes:119265,sha256:`f87a38025a5fdd1e4e9591f6a44bb81295097ce0b80df6f4ab9f44e52c64ca5f`},derived:{path:`speech-resources/xasr-bpe.vocab`,bytes:61562,sha256:`01381aa0c3065832cb8d7462d529e3079a99be56c955ce93b4cb9b78e8aa34e5`},generator:{path:`scripts/speech-bpe.mjs`,sha256:`a1c85731aa3e0be89f04acc79830db784a9d43edb8af9f4fb723bb45bd725786`,method:`sentencePieceModelToVocab decodes ordered protobuf ModelProto.pieces and emits each piece, a tab, its finite score, and a newline without changing the BPE model.`}}]},{id:`vits-melo-tts-zh_en`,revision:`a0d5c6a264c0ef92d70d8661d8cc502d79627cd6`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-melo-tts-zh_en.tar.bz2`,bytes:167006755,sha256:`e58351ed7149f290a54534538badd4077cdbe6fddc964b24d0bee870415d1514`},attribution:`MeloTTS by MyShell.ai; sherpa-onnx ONNX conversion. The retained software license is Copyright (c) 2024 MyShell.ai, MIT. The neural-weight repository separately declares MIT; dictionary and FST resources have separate declarations and pending provenance. Pisper selects the original single female voice via public sid 0 and uses the same original FP32 ONNX, tokens, mixed-language lexicon, dictionary and normalization files on Desktop, Android and iOS. No retraining, quantization, graph/metadata patch or voice-subset derivative is made. The unused new_heteronym.fst and 133-byte model.int8.onnx Git LFS pointer in the transport archive are drained but not installed; retained model files are unchanged. These choices do not imply upstream/speaker endorsement, redistribution approval or completed native-platform acceptance.`,groups:[{id:`melo-weights`,pathScope:`model`,paths:[`model.onnx`],licenseIds:[`mit-melo`],status:`pending`,summary:`The myshell-ai/MeloTTS-Chinese model card at af5d207a364ea4208c6f589c89f57f88414bdd16 declares license: mit for the model repository; this is separate evidence from the MeloTTS software MIT license. The sherpa conversion package carries the exact MyShell.ai MIT text, and original ONNX metadata declares MIT license, melo-vits version 2, Chinese + English, n_speakers=1 and speaker_id=1. The conversion README explicitly describes a single female Chinese+English speaker. sherpa maps public sid 0 to the internal metadata speaker_id; Pisper does not change the graph, metadata or speaker embedding.`,pendingReasons:[`Exact historical checkpoint, training/conversion commits and reproducible archive build identity have not been established; the inspected conversion workflow uses moving upstream references. Training-data permissions, individual speaker consent and applicable personality/publicity rights are not fully audited. The discovered model card revision is evidence of a declaration, not proof of the historical conversion input.`],evidence:[{url:`https://hf-mirror.com/myshell-ai/MeloTTS-Chinese/resolve/af5d207a364ea4208c6f589c89f57f88414bdd16/README.md`,sha256:`40b5b860bacbb3947cbef838719e660d2fe4961eba5b484290b4bedc0253e208`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/run.sh`,sha256:`e2afb98d9028eded2983f780468337fc019a8306db926f89e3bdeed18af867bb`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/sherpa-onnx/csrc/offline-tts-vits-model.cc`,sha256:`060907349036d63b60d035843defe7078b83c8099e0d4de323446c7db0d653d0`}]},{id:`melo-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`mit-melo`,`apache-2.0-sherpa`],status:`declared`,summary:`The sherpa Melo export writes enumerated model.hps symbols to tokens.txt. The original 655-byte token file is retained unchanged. Melo software is MIT; sherpa conversion code is Apache-2.0. These code declarations do not independently establish all underlying training-data rights.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-cppjieba-dictionary`,pathScope:`model`,paths:[`dict/hmm_model.utf8`,`dict/idf.utf8`,`dict/jieba.dict.utf8`,`dict/pos_dict/char_state_tab.utf8`,`dict/pos_dict/prob_emit.utf8`,`dict/pos_dict/prob_start.utf8`,`dict/pos_dict/prob_trans.utf8`,`dict/README.md`,`dict/stop_words.utf8`],licenseIds:[`mit-cppjieba`],status:`confirmed`,summary:`Nine ordinary dictionary/README files are byte-identical to the separately HTTPS-downloaded CppJieba sherpa-onnx-2024-04-19 dict archive. The exact release source MIT license retains Copyright (c) 2013. This confirms the documented source-content match, not a whole-chain data-rights guarantee. The small Melo user.dict.utf8 is separately classified and is NOT the 829194-byte pypinyin-derived user dictionary from that source archive.`,pendingReasons:[],evidence:[{url:`https://ghfast.top/https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2`,sha256:`35c3877c9b9221a5b2d69bbf57d5dbf1ccbe5b7684c60eb42f93db6b2d494f26`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`}]},{id:`melo-user-dictionary`,pathScope:`model`,paths:[`dict/user.dict.utf8`],licenseIds:[`mit-cppjieba`,`mit-melo`],status:`pending`,summary:`Melo ships an unchanged 49-byte user dictionary containing four entries. It matches the locked Melo HF file but differs from the separately downloaded CppJieba release user dictionary. The package MIT text and CppJieba project MIT declaration are retained as source declarations, not proof that either automatically licenses every edit. This file is not attributed to the unrelated historical pypinyin-derived dictionary.`,pendingReasons:[`The exact historical source commit, modifier and license coverage for this 49-byte replacement have not been identified. Retain applicable modifier notices when established.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://huggingface.co/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/dict/user.dict.utf8`,sha256:`495bbf49270408a1234690e1e6a97328f30a482a7a72aa769e8a12e8714b0c62`}]},{id:`melo-english-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`cmudict-0.6-1998`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The English portion is generated by the sherpa Melo export from melo.text.english.eng_dict and refine_syllables, lowercasing words and adding language tone offsets plus kaldi/SF entries. The inspected Melo source reads cmudict.rep or a cached pickle. cmudict.rep contains its own Copyright 1998 Carnegie Mellon University unrestricted research/commercial permission and attribution notice, retained verbatim in cmudict-0.6-1998. This is NOT a substitution of a modern CMUdict BSD license. The retained notice hash covers the complete original comment header; the evidence hash covers the complete 3969309-byte source file. No package script or pickle was executed.`,pendingReasons:[`The precise historical dictionary/cache inputs and all intervening modifications used for this lexicon have not been pinned or reproduced. Trace cached-data equivalence and retain applicable original and modifier notices.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/english.py`,sha256:`28527f574511bfc13fe1f2f6bbb5bfe4072c06e1c7e9b69598138aef81b9905b`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`d127b5ce8b8e695732701e8efde04b9b0fa11991218b1fb9d21bd0c9264636aa`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-chinese-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`mit-pypinyin`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The Chinese portion is generated by the sherpa Melo export from pypinyin character/phrase dictionaries, lazy_pinyin and the Melo pinyin-to-symbol map. Melo code is MIT, sherpa conversion code Apache-2.0, and pypinyin declares MIT. Those software declarations do not relicense external dictionary inputs. The same 6837671-byte mixed-language lexicon is used unchanged on every platform.`,pendingReasons:[`Pin historical pypinyin versions, character/phrase JSON data and Melo phoneme mapping, reproduce the output and trace the actual underlying source-data terms. No particular Zdic, CC-CEDICT or Unihan license is asserted without proof of the actual input chain.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/pinyin_dict.py`,sha256:`245c1f70509432b289cde1f938157cd5ff1372d1d083b577d5fab72b4dfcda08`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/phrases_dict.py`,sha256:`3f6f39bbca68d8d1676ea463cd4620b934b03160cc5042fb9d9007b8f3a80b9e`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/LICENSE.txt`,sha256:`1e6c90014b4912815c296ee64bb6f6280af47e6d4c5d80e86232dfc5defe764c`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`}]},{id:`melo-normalization-fsts`,pathScope:`model`,paths:[`date.fst`,`number.fst`,`phone.fst`],licenseIds:[`apache-2.0-sherpa`],status:`pending`,summary:`All three FSTs are byte-identical to the separately downloaded data/date.fst, data/number.fst and data/phone.fst at csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06 revision 57345c004e13ed640e408c4c29ab56187b18f065, the source repository named by the Melo packaging workflow. That source model card declares Apache-2.0; the full Apache text is retained from sherpa. Neither the OpenFst software license nor the Melo neural-weight MIT declaration independently grants rights to these FST data.`,pendingReasons:[`Exact editable generation rules, compiler/source revisions, underlying data provenance and applicable author/modifier notices remain unverified. No standalone FST LICENSE/NOTICE or complete reproducible source chain was found in the inspected source tree.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/README.md`,sha256:`98b45ea81164d1e1a1dd82255207053b15cd6c69d922a1c5cf3387ce604d4b74`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/date.fst`,sha256:`eb8aa079ae3cb81d8f4404992f39d61a0cb990947512b5b8d1e54d1f6980e718`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/number.fst`,sha256:`743f402181fcfebf76cc2f0546b71fa26476e626fbe4e460fb7b4c3a7a8bd5bd`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/phone.fst`,sha256:`1ac2b6fa56b1442320c4de7db08353bab8963a2b57f365eebcdd3a2d3562f8d7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-package-notices`,pathScope:`model`,paths:[`LICENSE`,`README.md`],licenseIds:[`mit-melo`],status:`confirmed`,summary:`LICENSE is byte-identical to the original MyShell.ai MIT text (Copyright (c) 2024 MyShell.ai), including its exact final newline behavior. README explicitly identifies the single female Chinese+English speaker. The package-level MIT file is not a blanket grant for every bundled dictionary or FST. No upstream NOTICE was listed in the inspected conversion and weight repository trees; this is not proof that none ever existed.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`}]}],modifications:[]}]},_s=gs,vs=e=>gs.models.some(t=>t.id===e);function ys({modelId:e,modelName:t,returnFocus:n,onClose:r}){let{t:i}=v(),a=_s.models.find(t=>t.id===e);if(!a)return null;let o=new Set(a.groups.flatMap(e=>e.licenseIds)),s=_s.licenses.filter(e=>o.has(e.id));return(0,Q.jsx)($e,{open:!0,onOpenChange:e=>{e||r()},children:(0,Q.jsxs)(je,{className:`z-[130] max-h-[85dvh] min-w-0 grid-cols-1 overflow-y-auto rounded-lg sm:max-w-2xl`,overlayClassName:`z-[129]`,onEscapeKeyDown:e=>e.stopPropagation(),onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus()},children:[(0,Q.jsxs)(Be,{children:[(0,Q.jsx)(He,{children:i(`chat:speechModels.notices`)}),(0,Q.jsxs)(Ze,{className:`break-words`,children:[t,` (`,a.revision,`)`]})]}),(0,Q.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:_s.scope}),(0,Q.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:_s.licenseIdsMeaning}),(0,Q.jsx)(`div`,{className:`min-w-0 divide-y`,children:a.groups.map(e=>(0,Q.jsxs)(`details`,{className:`min-w-0 py-3`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.id,e.status===`pending`&&(0,Q.jsx)(`span`,{className:`ml-2 text-xs font-normal text-amber-700 dark:text-amber-400`,children:i(`chat:speechModels.provenancePending`)})]}),(0,Q.jsxs)(`div`,{className:`mt-3 min-w-0 space-y-3 text-sm`,children:[(0,Q.jsx)(`p`,{className:`break-words`,children:e.summary}),e.pendingReasons.map(e=>(0,Q.jsx)(`p`,{className:`break-words text-muted-foreground`,children:e},e)),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs`,children:JSON.stringify({pathScope:e.pathScope,paths:e.paths,licenseIds:e.licenseIds,evidence:e.evidence},null,2)})]})]},e.id))}),(0,Q.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i(`chat:speechModels.modifications`)}),(0,Q.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs`,children:JSON.stringify(a.modifications,null,2)})]}),s.map(e=>(0,Q.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.name,` (`,e.id,`)`]}),(0,Q.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-words text-xs`,children:e.text})]},e.id)),(0,Q.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{size:`icon-sm`,variant:`outline`,onClick:()=>{let e=new Blob([JSON.stringify({..._s,models:[a],licenses:s},null,2)],{type:`application/json;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${a.id}-notices.json`,n.click(),window.setTimeout(()=>URL.revokeObjectURL(t),0)},"aria-label":i(`chat:speechModels.downloadNotices`),children:(0,Q.jsx)(Ve,{})})}),(0,Q.jsx)(ae,{children:i(`chat:speechModels.downloadNotices`)})]})})]})})}var bs=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e/1048576)} MiB`;function xs({manager:e,onClose:t}){let{t:n}=v(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),f=()=>{l.current?.abort(),l.current=null,i(!1)};(0,Z.useEffect)(()=>(e.open||(l.current?.abort(),l.current=null,i(!1),c(null)),()=>{l.current?.abort(),l.current=null}),[e.open]);let p={"not-installed":n(`chat:speechModels.notInstalled`),downloading:n(`chat:speechModels.downloading`),verifying:n(`chat:speechModels.verifying`),installed:n(`chat:speechModels.installed`),cancelled:n(`chat:speechModels.cancelled`),error:n(`chat:speechModels.failed`)},m=e.models.flatMap(e=>e.voices||[]),h=m.find(t=>t.id===e.selectedVoice),g=e.models.some(e=>e.kind===`tts`&&e.status===`installed`),_=e.models.filter(e=>e.status!==`installed`),y=_.some(e=>[`downloading`,`verifying`].includes(e.status)),b=()=>{c(null),f(),e.close(),t()},x=async()=>{if(l.current){f();return}if(!h||!g||_.length)return;let e=new AbortController;l.current=e,i(!0),o(``);try{await ms(h.language===`en`?n(`chat:speechModels.previewEnglish`):n(`chat:speechModels.previewChinese`),h.id,e.signal)}catch(t){e.signal.aborted||o(t instanceof Error?t.message:String(t))}finally{l.current===e&&(l.current=null,i(!1))}};return(0,Q.jsxs)($e,{open:e.open,onOpenChange:e=>{e||b()},children:[(0,Q.jsxs)(je,{className:`z-[110] max-h-[85dvh] overflow-y-auto rounded-lg sm:max-w-md`,overlayClassName:`z-[109]`,onEscapeKeyDown:e=>e.stopPropagation(),children:[(0,Q.jsxs)(Be,{children:[(0,Q.jsx)(He,{children:n(`chat:speechModels.title`)}),(0,Q.jsx)(Ze,{className:`sr-only`,children:n(`chat:speechModels.title`)})]}),!e.catalog&&!e.error&&(0,Q.jsx)(K,{className:`mx-auto my-4 size-5 animate-spin`,"aria-label":n(`chat:speechModels.loading`)}),(0,Q.jsx)(`div`,{className:`min-w-0 divide-y`,children:e.models.map(t=>{let r=[`downloading`,`verifying`].includes(t.status),i=t.totalBytes?Math.min(100,Math.floor(t.downloadedBytes/t.totalBytes*100)):0,a=t.license?.url.startsWith(`https://`)?t.license.url:void 0;return(0,Q.jsxs)(`section`,{className:`min-w-0 space-y-2 py-3 first:pt-0`,"aria-label":t.name,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.kind===`asr`?n(`chat:speechModels.recognition`):n(`chat:speechModels.synthesis`)}),(0,Q.jsx)(`div`,{className:`break-words font-medium`,children:t.name})]}),t.status===`installed`?(0,Q.jsx)(et,{className:`size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-label":p.installed}):(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{size:`icon-sm`,variant:`outline`,disabled:e.loading,onClick:()=>{r?e.cancelDownload(t.id):e.download(t.id)},"aria-label":n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`),children:r?(0,Q.jsx)(Te,{}):(0,Q.jsx)(Ve,{})})}),(0,Q.jsx)(ae,{children:n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:p[t.status]}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:r?`${bs(t.downloadedBytes)} / ${bs(t.totalBytes)}`:bs(t.totalBytes)})]}),r&&(0,Q.jsx)(V,{value:i,"aria-label":t.name,"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100}),t.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:t.error}),t.license&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Q.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`block break-words text-[11px] text-muted-foreground underline underline-offset-2`,children:t.license.name}),vs(t.id)&&(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`chat:speechModels.notices`),onClick:e=>{u.current=e.currentTarget,f(),c(t)},children:(0,Q.jsx)(kn,{})})}),(0,Q.jsx)(ae,{children:n(`chat:speechModels.notices`)})]})]})]},t.id)})}),m.length>0&&(0,Q.jsx)(`div`,{className:`space-y-2 border-t pt-3`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:n(`chat:speechModels.voice`)}),(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{size:`icon`,variant:`outline`,disabled:!g||_.length>0,onClick:()=>void x(),"aria-label":n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`),children:r?(0,Q.jsx)(Te,{}):(0,Q.jsx)(ye,{})})}),(0,Q.jsx)(ae,{children:n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`)})]})]})}),(e.error||a)&&(0,Q.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-destructive`,children:e.error||a}),(0,Q.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:_.length?(0,Q.jsxs)(d,{disabled:e.loading||y,onClick:()=>void e.downloadAll(),children:[(0,Q.jsx)(Ve,{}),n(`chat:speechModels.downloadAll`)]}):(0,Q.jsx)(d,{disabled:!e.catalog,onClick:b,children:n(`chat:speechModels.done`)})})]}),e.open&&s&&(0,Q.jsx)(ys,{modelId:s.id,modelName:s.name,returnFocus:u,onClose:()=>c(null)})]})}var Ss=16e3,Cs=Ss*60;function ws(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`移动端原生桥不可用。`))}async function Ts(){if(!(typeof window>`u`||!window.__PISPER_MOBILE_APP__)&&(await ws(`mobile_request_microphone_permission`)).state!==`granted`)throw Error(`microphone_permission_denied`)}async function Es(e){let t=await e.text().catch(()=>``);try{return JSON.parse(t).error||`语音转写失败 (${e.status})`}catch{return t||`语音转写失败 (${e.status})`}}function Ds(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Os=class{chatSessionId;chunks=[];pending=[];listeners=new Set;controller=null;sessionId=``;nativeRequestId=``;legacy=!1;flushTimer=0;sendChain=Promise.resolve();finished=!1;retainedSamples=0;terms=[];initializing=null;constructor(e=``){this.chatSessionId=e}start(){return this.initializing=this.initialize().catch(async e=>{throw await this.cancel(),e}),this.initializing}async initialize(){this.chunks=[],this.pending=[],this.finished=!1,this.retainedSamples=0;let e=new AbortController;this.controller=e,await o(),X(e.signal);let{loadSpeechHotwords:t,prepareSpeechSession:n}=await i(async()=>{let{loadSpeechHotwords:e,prepareSpeechSession:t}=await import(`./speech-session-UGYrCHlP.js`).then(e=>e.r);return{loadSpeechHotwords:e,prepareSpeechSession:t}},__vite__mapDeps([37,1,11,2,13,36])),{terms:r,hotwords:a}=await t(this.chatSessionId,e.signal);this.terms=r;let s=await n({kinds:[`asr`],hotwords:a},e.signal);if(X(s.signal),s.signal.addEventListener(`abort`,()=>{this.controller===e&&!e.signal.aborted&&this.cancel()},{once:!0}),window.__PISPER_MOBILE_APP__)return;let c=Ct(e.signal,3e4);try{let t=await fetch(`/api/speech/stream/start`,{method:`POST`,headers:{"X-Pisper-Chat-Session":this.chatSessionId},signal:c.signal});if(!t.ok){if(t.status===404){this.legacy=!0;return}throw Error(await Es(t))}let n=await t.json();if(!n.id)throw Error(`语音识别会话创建失败。`);e.signal.aborted&&(await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":n.id}}).catch(()=>{}),X(e.signal)),this.sessionId=n.id,this.pending.push(...this.chunks.splice(0)),this.retainedSamples=0,this.flushTimer=window.setInterval(()=>void this.flushPending(),1e3)}finally{c.dispose()}}acceptPcm(e){if(!e.length||this.finished)return!1;if(window.__PISPER_MOBILE_APP__||!this.sessionId){let t=Cs-this.retainedSamples;if(t<=0)return!0;let n=e.slice(0,t);return this.chunks.push(n),this.retainedSamples+=n.length,this.retainedSamples>=Cs}let t=e.slice();return this.sessionId&&!this.legacy?this.pending.push(t):this.chunks.push(t),!1}onPartial(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emitPartial(e){if(e)for(let t of this.listeners)t(e)}flushPending(){return this.sendChain=this.sendChain.then(async()=>{if(!this.sessionId||this.legacy||this.finished||!this.pending.length)return;let e=Ds(this.pending.splice(0));try{let t=await fetch(`/api/speech/stream/chunk`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ss),"X-Pisper-Speech-Session":this.sessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)return;let n=await t.json();typeof n.text==`string`&&this.emitPartial(n.text.trim())}catch{}}),this.sendChain}async finishStreaming(){window.clearInterval(this.flushTimer),this.flushTimer=0,await this.flushPending(),this.finished=!0;let e=await fetch(`/api/speech/stream/finish`,{method:`POST`,headers:{"X-Pisper-Speech-Session":this.sessionId},signal:this.controller?.signal});if(!e.ok)throw Error(await Es(e));let t=await e.json(),n=typeof t.text==`string`?t.text.trim():``;if(!n)throw Error(`未识别到语音内容。`);return this.emitPartial(n),n}async finishOneShot(e){if(window.__PISPER_MOBILE_APP__){let t=new Uint8Array(e.buffer),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));let i=this.controller;if(!i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);X(i.signal);let a=crypto.randomUUID();this.nativeRequestId=a;let o=await ws(`mobile_transcribe_pcm`,{pcmBase64:btoa(n),hotwords:Tt(this.terms),requestId:a});if(X(i.signal),this.controller!==i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);let s=Dt(typeof o.text==`string`?o.text.trim():``,this.terms);if(!s)throw Error(`未识别到语音内容。`);return this.emitPartial(s),s}let t=await fetch(`/api/speech/transcribe`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ss),"X-Pisper-Chat-Session":this.chatSessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)throw Error(await Es(t));let n=await t.json(),r=typeof n.text==`string`?n.text.trim():``;if(!r)throw Error(`未识别到语音内容。`);return this.emitPartial(r),r}async finish(){if(await this.initializing,!this.controller)throw Error(`语音识别尚未启动。`);if(this.sessionId&&!this.legacy)return this.finishStreaming();this.finished=!0;let e=Ds(this.chunks);if(!e.length)throw Error(`没有采集到语音。`);return this.finishOneShot(e)}async cancel(){if(this.finished=!0,window.clearInterval(this.flushTimer),this.flushTimer=0,this.controller?.abort(),this.controller=null,this.chunks=[],this.pending=[],this.retainedSamples=0,this.nativeRequestId){let e=this.nativeRequestId;this.nativeRequestId=``,await ws(`mobile_cancel_speech`,{requestId:e}).catch(()=>{})}if(this.sessionId&&!this.legacy){let e=this.sessionId;this.sessionId=``,await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":e}}).catch(()=>{})}}async dispose(){await this.cancel(),this.listeners.clear()}};function ks({chatSessionId:e=``}={}){return new Os(e)}var As=`
517
+ class PisperVoiceInputProcessor extends AudioWorkletProcessor {
518
+ constructor(options) {
519
+ super()
520
+ this.targetSampleRate = Number(options?.processorOptions?.targetSampleRate) || 16000
521
+ this.inputSampleRate = sampleRate
522
+ this.ratio = this.inputSampleRate / this.targetSampleRate
523
+ this.inputBuffer = []
524
+ this.readPosition = 0
525
+ this.outputBuffer = []
526
+ }
527
+
528
+ process(inputs, outputs) {
529
+ const channel = inputs[0]?.[0]
530
+ if (channel?.length) {
531
+ for (const sample of channel) this.inputBuffer.push(sample)
532
+ while (this.readPosition + 1 < this.inputBuffer.length) {
533
+ const index = Math.floor(this.readPosition)
534
+ const fraction = this.readPosition - index
535
+ const current = this.inputBuffer[index]
536
+ const next = this.inputBuffer[index + 1]
537
+ this.outputBuffer.push(current + (next - current) * fraction)
538
+ this.readPosition += this.ratio
539
+ }
540
+ const consumed = Math.min(Math.floor(this.readPosition), this.inputBuffer.length)
541
+ if (consumed > 0) {
542
+ this.inputBuffer = this.inputBuffer.slice(consumed)
543
+ this.readPosition -= consumed
544
+ }
545
+ while (this.outputBuffer.length >= 320) {
546
+ const chunk = new Float32Array(this.outputBuffer.splice(0, 320))
547
+ this.port.postMessage(chunk.buffer, [chunk.buffer])
548
+ }
549
+ }
550
+ const output = outputs[0]?.[0]
551
+ if (output) output.fill(0)
552
+ return true
553
+ }
554
+ }
555
+ registerProcessor('pisper-voice-input', PisperVoiceInputProcessor)
556
+ `;async function js(e){let t=new Blob([As],{type:`application/javascript`}),n=URL.createObjectURL(t);try{await e.audioWorklet.addModule(n)}finally{URL.revokeObjectURL(n)}}async function Ms(e,t){if(X(t),!navigator.mediaDevices?.getUserMedia)throw Error(`当前环境不支持麦克风采集。`);if(!window.AudioContext&&!window.webkitAudioContext)throw Error(`当前环境不支持音频处理。`);let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1}),r=null,i=null,a=null,o=null,s=!1,c=null,l=()=>{if(s)return c??Promise.resolve();s=!0,t?.removeEventListener(`abort`,u);for(let e of n.getTracks())e.removeEventListener?.(`ended`,d),e.removeEventListener?.(`mute`,d),e.stop();return c=r?.close().catch(()=>{})??Promise.resolve(),i&&(i.port.onmessage=null,i.port.close()),a?.disconnect(),i?.disconnect(),o?.disconnect(),c},u=()=>{l()},d=()=>{s||(l(),window.dispatchEvent(new Event(`pisper:speech-interrupted`)))},f=()=>{if(X(t),s)throw new DOMException(`Microphone capture was interrupted.`,`AbortError`)};t?.addEventListener(`abort`,u,{once:!0});for(let e of n.getTracks()){if(s)break;e.addEventListener?.(`ended`,d),e.addEventListener?.(`mute`,d),e.readyState===`ended`&&d()}try{f(),r=new(window.AudioContext||window.webkitAudioContext)({latencyHint:`interactive`}),await js(r),f(),a=r.createMediaStreamSource(n),i=new AudioWorkletNode(r,`pisper-voice-input`,{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{targetSampleRate:Ss}}),o=r.createGain(),o.gain.value=0,i.port.onmessage=n=>{!s&&!t?.aborted&&e(new Float32Array(n.data))},a.connect(i),i.connect(o),o.connect(r.destination),await r.resume(),f()}catch(e){throw await l(),e}return{stop:l}}var Ns=32,Ps=50;function Fs(e,t){if(e instanceof DOMException&&e.name===`NotAllowedError`)return`permission`;let n=typeof e==`string`?e:e instanceof Error?e.message:typeof e==`object`&&e&&`message`in e?String(e.message):``;return n.includes(`microphone_permission_denied`)?`permission`:n||t}function Is({onInsert:e,onLiveText:t,sessionId:n,disabled:r=!1,shortcutEnabled:i=!1}){let{t:a}=v(),o=ss([`asr`]),s=mt(e=>e.bindings.voiceInput),[c,l]=(0,Z.useState)(`idle`),[u,d]=(0,Z.useState)(``),f=(0,Z.useRef)(`idle`),p=e=>{f.current=e,l(e)},m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),y=(0,Z.useRef)(0),b=(0,Z.useRef)(0),x=(0,Z.useRef)(()=>{}),S=(0,Z.useRef)(!1),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=(0,Z.useRef)(()=>{}),E=(0,Z.useRef)(0),D=(0,Z.useRef)($o()),O=(0,Z.useRef)(0),[k,A]=(0,Z.useState)([]),j=(0,Z.useRef)([]),M=(0,Z.useRef)(null),N=(0,Z.useRef)(e),P=(0,Z.useRef)(t);N.current=e,P.current=t;let F=()=>{window.clearTimeout(b.current),b.current=0},I=async()=>{F();let e=g.current;g.current=null,e?.abort(),_.current?.(),_.current=null,M.current?.dispose(),M.current=null;let t=h.current;h.current=null;let n=m.current;m.current=null,await Promise.allSettled([t?.stop(),n?.dispose()])},L=e=>{console.warn(`[voice-input]`,e),d(e),p(`error`),window.clearTimeout(E.current),E.current=window.setTimeout(()=>{f.current===`error`&&(d(``),p(`idle`))},4e3)},R=()=>{F(),S.current=!1,p(`idle`),d(``)},z=()=>{C.current=null,w.current=null,y.current+=1,I(),P.current?.(null),R()};T.current=z,(0,Z.useEffect)(()=>{let e=()=>{(w.current!==y.current||C.current===y.current)&&T.current()},t=()=>{document.visibilityState===`hidden`&&e()},n=()=>T.current();return window.addEventListener(`blur`,e),window.addEventListener(`pisper:speech-interrupted`,n),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`pisper:speech-interrupted`,n),document.removeEventListener(`visibilitychange`,t),window.clearTimeout(E.current),e()}},[n,i,r]),(0,Z.useEffect)(()=>{if(c!==`recording`){A([]),j.current=[];return}let e=()=>{let e=performance.now()/1e3,t=O.current,n=j.current,r=[];for(let i=0;i<Ns;i+=1){let a=i/31*2-1,o=Math.cos(a*Math.PI/2)**1.3,s=.1+.06*Math.sin(e*2.2+i*.55)+.04*Math.sin(e*3.7+i*.21),c=.75+.5*Math.abs(Math.sin(e*9+i*1.7)),l=Math.min(1,Math.max(.05,s+t*o*c*1.15)),u=n[i]??l,d=l>u?.55:.28;r.push(u+(l-u)*d)}j.current=r,A(r)};e();let t=window.setInterval(e,Ps);return()=>window.clearInterval(t)},[c]);let B=()=>!r&&(f.current===`idle`||f.current===`error`),ee=async()=>{if(!B())return;let e=++y.current,t=new AbortController;g.current=t,S.current=!1,p(`requesting`),d(``),D.current.reset();let r=ks({chatSessionId:n});m.current=r,_.current=r.onPartial(e=>{m.current===r&&P.current?.(e)});let i=null,s=async t=>{if(i?.dispose(),i=null,e!==y.current)return;if(t instanceof DOMException&&t.name===`AbortError`){let e=++y.current;if(await I(),e!==y.current)return;R();return}let n=++y.current;if(await I(),n!==y.current)return;let r=Fs(t,a(`chat:voiceInput.failed`));L(r===`permission`?a(`chat:voiceInput.permissionDenied`):r)};try{window.__PISPER_MOBILE_APP__&&(w.current=e);try{await Ts()}finally{w.current===e&&(w.current=null)}if(e!==y.current)return;if(window.__PISPER_MOBILE_APP__&&document.visibilityState===`hidden`){z();return}if(await o.ensureReady(t.signal),e!==y.current)return;if(r.start().then(()=>{},()=>s(Error(a(`chat:voiceInput.failed`)))),i=await as(),e!==y.current){i.dispose();return}M.current=i;let n=i,c=await Ms(t=>{if(e!==y.current)return;O.current=D.current.push(Qo(t));let i=n.acceptPcm(t);(r.acceptPcm(t)||i)&&x.current()},t.signal);if(e!==y.current){await c.stop();return}h.current=c,p(`recording`),window.__PISPER_MOBILE_APP__&&(b.current=window.setTimeout(()=>x.current(),6e4))}catch(e){await s(e)}},te=async()=>{if(f.current!==`recording`||S.current)return;C.current=null,S.current=!0,F();let e=++y.current;p(`transcribing`);let t=g.current;g.current=null,t?.abort();let n=h.current;h.current=null;let r=M.current;M.current=null;let i=m.current;try{if(await n?.stop(),e!==y.current)return;if(r&&!r.hasSpeech){if(r.dispose(),P.current?.(null),await I(),e!==y.current)return;R();return}r?.dispose();let t=await i?.finish();if(e!==y.current)return;if(!t)throw Error(a(`chat:voiceInput.empty`));if(N.current(t),await I(),e!==y.current)return;R()}catch(t){if(e!==y.current||(await I(),e!==y.current))return;P.current?.(null);let n=Fs(t,a(`chat:voiceInput.failed`));L(n===`permission`?a(`chat:voiceInput.permissionDenied`):n),S.current=!1}};x.current=()=>void te(),Zo({enabled:i&&!r,binding:s,onStart:()=>B()?(ee(),C.current=y.current,!0):!1,onRelease:()=>{C.current===y.current&&(h.current?te():z())},onCancel:()=>{C.current===y.current&&z()}});let V=c===`recording`?a(`chat:voiceInput.stop`):c===`requesting`?a(`chat:voiceInput.close`):c===`error`?u:a(`chat:voiceInput.open`),ne=s&&c!==`error`?`${V} (${ht(s)})`:V;return(0,Q.jsxs)(`div`,{className:`relative flex flex-none items-center`,children:[c===`recording`&&(0,ai.createPortal)((0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`voice-capsule-pop pointer-events-none fixed bottom-4 left-1/2 z-[80] flex h-10 -translate-x-1/2 items-center gap-[3px] rounded-full border border-[rgba(125,211,252,.35)] bg-[#10141c]/95 px-4`,style:{boxShadow:`0 8px 30px -8px rgba(0,0,0,.55), 0 0 ${14+O.current*26}px rgba(80,180,255,${(.18+O.current*.4).toFixed(3)})`},children:k.map((e,t)=>(0,Q.jsx)(`span`,{className:`w-[3px] rounded-full`,style:{height:`${(3+e*19).toFixed(1)}px`,background:`linear-gradient(180deg, hsl(${210-e*45} 92% ${62+e*10}%), hsl(${222-e*30} 85% ${48+e*8}%))`,transition:`height 70ms linear, background 200ms linear`}},t))}),document.body),c===`error`&&(0,ai.createPortal)((0,Q.jsxs)(`button`,{type:`button`,className:`voice-capsule-pop fixed bottom-4 left-1/2 z-[80] flex h-9 max-w-[min(480px,calc(100vw-32px))] -translate-x-1/2 cursor-pointer items-center gap-2 rounded-full border border-[rgba(248,113,113,.4)] bg-[#1c1012]/95 px-4 text-[12px] text-[#fca5a5] shadow-[0_10px_30px_-10px_rgba(0,0,0,.5)]`,onClick:()=>{window.clearTimeout(E.current),d(``),p(`idle`)},children:[(0,Q.jsx)(qn,{size:13,className:`flex-none`}),(0,Q.jsx)(`span`,{className:`truncate`,children:u})]}),document.body),(0,Q.jsxs)(`button`,{type:`button`,className:`relative grid !size-11 !min-w-11 place-items-center rounded-[var(--r-sm)] border transition-[background-color,color,border-color,box-shadow,transform] duration-200 hover:scale-105 disabled:cursor-not-allowed disabled:opacity-45 ${c===`recording`?`border-[var(--danger)] bg-[var(--danger-soft)] text-[var(--danger-strong)] shadow-[0_0_0_3px_var(--danger-soft)]`:c===`transcribing`||c===`requesting`?`border-transparent bg-[var(--brand-blue-soft)] text-[var(--brand-blue-strong)]`:c===`error`?`border-transparent bg-[var(--danger-soft)] text-[var(--danger-strong)]`:`border-transparent bg-[var(--surface-subtle)] text-[var(--text-muted)] hover:border-[var(--brand-blue)] hover:bg-[var(--brand-blue-soft)] hover:text-[var(--brand-blue-strong)]`}`,title:ne,"aria-label":a(c===`recording`?`chat:voiceInput.stop`:`chat:voiceInput.open`),"aria-pressed":c===`recording`,disabled:r||c===`transcribing`,onClick:c===`recording`?()=>void te():c===`requesting`?()=>z():()=>void ee(),children:[c===`recording`&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-0 animate-ping rounded-[var(--r-sm)] bg-[var(--danger)] opacity-25`}),c===`recording`?(0,Q.jsx)(qn,{size:17}):c===`transcribing`||c===`requesting`?(0,Q.jsx)(K,{className:`animate-spin`,size:17}):c===`error`?(0,Q.jsx)(qn,{size:17}):(0,Q.jsx)(Jn,{size:17})]}),(0,Q.jsx)(xs,{manager:o,onClose:()=>{}})]})}var Ls={idle:{amp:.14,freq:1.7,speed:.22,spike:0,rot:.22,dim:.8,behavior:`calm`},requesting:{amp:.08,freq:1.6,speed:.3,spike:0,rot:.4,dim:.5,behavior:`calm`},listening:{amp:.15,freq:2,speed:.55,spike:.55,rot:.4,dim:1,behavior:`reactive`},transcribing:{amp:.08,freq:1.8,speed:1,spike:0,rot:1.5,dim:.95,behavior:`converge`},thinking:{amp:.2,freq:2.3,speed:.8,spike:0,rot:.85,dim:1,behavior:`swirl`},speaking:{amp:.13,freq:1.9,speed:.5,spike:.1,rot:.35,dim:1,behavior:`beat`},error:{amp:.12,freq:2.2,speed:1.2,spike:0,rot:.1,dim:.9,behavior:`jitter`}},Rs=64,zs=96,Bs=2.6,Vs=Math.PI*2,Hs={dark:{base:[223,233,255],cyan:[89,230,255],magenta:[255,95,210],haloInner:[70,110,170],haloMid:[50,80,140],haloAlpha:.1,composite:`lighter`,alphaBase:.1,alphaFront:.68},light:{base:[34,44,76],cyan:[6,132,180],magenta:[176,48,150],haloInner:[110,140,210],haloMid:[130,160,220],haloAlpha:.16,composite:`source-over`,alphaBase:.18,alphaFront:.85}};function Us(e,t,n){let r=Math.sin(e*127.1+t*311.7+n*74.7)*43758.5453123;return r-Math.floor(r)}function Ws(e){return e*e*(3-2*e)}function Gs(e,t,n){let r=Math.floor(e),i=Math.floor(t),a=Math.floor(n),o=Ws(e-r),s=Ws(t-i),c=Ws(n-a),l=0;for(let e=0;e<=1;e+=1)for(let t=0;t<=1;t+=1)for(let n=0;n<=1;n+=1)l+=(e?o:1-o)*(t?s:1-s)*(n?c:1-c)*Us(r+e,i+t,a+n);return l}function Ks(e){return 1+2.70158*(e-1)**3+1.70158*(e-1)**2}function qs(e){let t=e*.9%1;return Math.exp(-(((t-.12)*9)**2))+.45*Math.exp(-(((t-.34)*9)**2))}function Js({stage:e,level:t,size:n=380,dark:r=!0}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(e),o=(0,Z.useRef)(t),s=(0,Z.useRef)(r);return a.current=e,o.current=t,s.current=r,(0,Z.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let r=Math.min(window.devicePixelRatio||1,2);e.width=n*r,e.height=n*r,t.scale(r,r);let c=new Float32Array(Rs),l=new Float32Array(Rs);for(let e=0;e<Rs;e+=1){let t=-Math.PI/2+(e+.5)/Rs*Math.PI;c[e]=Math.sin(t),l[e]=Math.cos(t)}let u=new Float32Array(zs),d=new Float32Array(zs);for(let e=0;e<zs;e+=1){let t=e/zs*Vs;u[e]=Math.cos(t),d[e]=Math.sin(t)}let f=n/2,p=n*.31,m=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,h=0,g=performance.now(),_=g,v=0,y=0,b={...Ls[a.current]},x=0,S=0,C=0,w=e=>{let r=Math.min((e-g)/1e3,.05);g=e;let i=Ls[a.current],T=Math.min(1,r*5);b={...i,amp:b.amp+(i.amp-b.amp)*T,freq:b.freq+(i.freq-b.freq)*T,speed:b.speed+(i.speed-b.speed)*T,spike:b.spike+(i.spike-b.spike)*T,rot:b.rot+(i.rot-b.rot)*T,dim:b.dim+(i.dim-b.dim)*T};let E=m?.35:1;v+=r*E,y+=b.rot*r*E,x+=(o.current-x)*Math.min(1,r*14);let D=Math.max(0,x-S-.02);S=x,C=Math.min(.6,C*.02**r+D*2.4);let O=x;b.behavior===`beat`?O=Math.max(.08,.4+.28*Math.abs(Math.sin(v*5.2))*Math.sin(v*1.6)+.12*Math.sin(v*9.1)):b.behavior===`converge`?O=.18:b.behavior===`jitter`?O=.3+.2*Math.sin(v*17):b.behavior!==`reactive`&&(O=.1+.05*Math.sin(v*1.3));let k=Ks(Math.min(1,Math.max(0,(e-_)/900))),A=b.behavior===`beat`?O:qs(v)*.5+O*.5,j=k*(1+A*.04+C*.1);b.behavior===`converge`&&(j*=.9+.1*Math.sin(v*4.2)),t.clearRect(0,0,n,n);let M=Hs[s.current?`dark`:`light`],N=t.createRadialGradient(f,f,0,f,f,p*1.7);N.addColorStop(0,`rgba(${M.haloInner[0]},${M.haloInner[1]},${M.haloInner[2]},${(M.haloAlpha*b.dim).toFixed(3)})`),N.addColorStop(.6,`rgba(${M.haloMid[0]},${M.haloMid[1]},${M.haloMid[2]},${(M.haloAlpha*.5*b.dim).toFixed(3)})`),N.addColorStop(1,`rgba(0,0,0,0)`),t.fillStyle=N,t.fillRect(0,0,n,n);let P=Math.sin(y),F=Math.cos(y),I=.38,L=Math.sin(I),R=Math.cos(I),z=v*b.speed,B=b.freq,ee=b.amp*j,te=b.spike*(O+C),V=p*j,ne=Math.floor(v*15),re=b.dim*(.72+.5*A)+C*.3;t.globalCompositeOperation=M.composite;for(let e=0;e<Rs;e+=1){let n=c[e],r=l[e];for(let i=0;i<zs;i+=1){let a=r*u[i],o=n,s=r*d[i],c=Gs(a*B+z,o*B+z*.7,s*B)-.5,l=1+c*2*ee;b.behavior===`reactive`?l+=Math.max(c,0)**2*1.7*te:b.behavior===`swirl`?l+=.03*Math.sin(9*a+v*4.6):b.behavior===`jitter`&&(l+=.02*(Us(e*zs+i,ne,3)-.5));let p=a*l,m=o*l,h=s*l,g=p*F-h*P,_=p*P+h*F,y=m*R-_*L,x=m*L+_*R,S=Bs/(Bs-x),C=f+g*S*V,w=f+y*S*V,T=(x+1)/2,E=Gs(a*1.25+31,o*1.25+z*.12,s*1.25-17),D=M.base;E>.62?D=M.magenta:E<.38&&(D=M.cyan);let O=(M.alphaBase+M.alphaFront*T*T)*re;if(O<.015)continue;let k=(1+1.4*T+te*.4)*(.55+.45*S);t.fillStyle=`rgba(${D[0]},${D[1]},${D[2]},${O.toFixed(3)})`,t.fillRect(C,w,k,k)}}t.globalCompositeOperation=`source-over`,h=requestAnimationFrame(w)};return h=requestAnimationFrame(w),()=>cancelAnimationFrame(h)},[n]),(0,Q.jsx)(`canvas`,{ref:i,className:`pointer-events-none block`,style:{width:n,height:n},"aria-hidden":`true`})}var Ys=new Map;function Xs(e,t){let n=Ys.get(e)??new Set;return n.add(t),Ys.set(e,n),()=>{n.delete(t),n.size||Ys.delete(e)}}function Zs(e){for(let t of Ys.get(e.sessionId)??[])t(e)}function Qs(e,t){let n=t.messages.length-1;for(;n>=0&&t.messages[n].role!==`user`;)--n;let r=t.messages.slice(n+1).filter(e=>e.role===`agent`||e.role===`assistant`),i=r.find(e=>e.streaming)??r.at(-1);Zs({sessionId:e,messageId:i?.id??``,prompt:t.messages[n]?.text,startedAt:t.startedAt??void 0,source:`snapshot`,users:t.messages.filter(e=>e.role===`user`),text:i?.text??``,status:t.error||i?.error?`failed`:t.streaming?i?`streaming`:`started`:`completed`,error:t.error||i?.error})}function $s(e){let t=``,n=0,r=!1,i,a,o=()=>{a?.(),a=void 0},s=()=>{i=wt(e),o()};return e.addEventListener(`abort`,s,{once:!0}),e.aborted&&s(),{get text(){return t},update(e){if(!(r||i)){if(e.length>32e3)throw Error(`Speech text exceeds the supported limit.`);if(!e.startsWith(t))throw Error(`The streamed speech response was rewritten.`);t=e,o()}},finish(e){r&&e===void 0||(r=!0,e!==void 0&&(i=e),o())},async*[Symbol.asyncIterator](){try{for(;;){if(X(e),i)throw i;if(n<t.length){let e=t.slice(n);n=t.length,yield e}else if(r)return;else await new Promise(e=>{a=e})}}finally{e.removeEventListener(`abort`,s),r=!0,o()}}}}function ec(e){let{t}=v(),n=(0,Z.useRef)({...e,t});n.current={...e,t};let[r,i]=(0,Z.useState)(`idle`),[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(0),_=(0,Z.useRef)(`idle`),y=(0,Z.useRef)(0),b=(0,Z.useRef)(null),x=(0,Z.useRef)(Promise.resolve()),S=(0,Z.useRef)(!1),C=(0,Z.useRef)(null),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(!1),E=(0,Z.useRef)(!1),D=(0,Z.useRef)({start:async()=>{},commit:async()=>{},stop:()=>{}}),O=(0,Z.useCallback)(e=>{_.current=e,i(e)},[]),k=e=>w.current&&n.current.open&&e.sessionId===n.current.sessionId&&b.current===e&&y.current===e.generation&&!e.controller.signal.aborted,A=()=>!!(n.current.streaming||n.current.messages.some(e=>e.streaming));function j(){let e=C.current;C.current=null,e?.controller.abort()}function M(){if(C.current)return C.current.preparing;let e=new AbortController,t=n.current.sessionId,r=(async()=>{S.current||=(await n.current.ensureReady?.(e.signal),X(e.signal),!0);let{hotwords:r}=await Mt(t,e.signal);await kt({kinds:[`asr`,`tts`],hotwords:r},e.signal),X(e.signal)})().catch(t=>{throw C.current?.controller===e&&(C.current=null),e.abort(),t});return C.current={controller:e,preparing:r},r}function N(e){window.clearTimeout(e.limitTimer),e.limitTimer=void 0,e.microphone.abort(),e.endpoint?.dispose(),e.endpoint=void 0;let t=e.capture;return e.capture=void 0,t&&(e.captureStopping=t.stop()),e.captureStopping??Promise.resolve()}function P(e){if(e.cleanup)return e.cleanup;e.controller.abort(),e.unsubscribe?.(),e.unsubscribe=void 0,e.responseSubscription?.(),e.responseSubscription=void 0,e.checkOwnership=void 0;let t=N(e),n=e.recognizer;return e.recognizer=void 0,e.cleanup=Promise.allSettled([t,e.capturePending,e.recognizerDisposing,e.playback,n?.dispose()]).then(()=>{}),e.cleanup}function F(){y.current+=1;let e=b.current;if(b.current=null,!e)return;let t=Promise.resolve(),r=n.current.messages.filter(t=>t.role===`user`&&!e.baseline?.has(t.id)),i=n.current.sessionId===e.sessionId&&(r.length>1||r.length===1&&r[0].text?.trim()!==e.prompt);if(e.ownsRun&&!i){e.ownsRun=!1;try{t=Promise.resolve(e.abortRun?.()).catch(()=>{})}catch{}}x.current=Promise.allSettled([x.current,P(e),t]).then(()=>{})}function I(){E.current=!1,F(),O(`idle`),c(``),o(0),u(e=>e.filter(e=>!e.pending))}function L(e,t){if(!k(e))return;let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?t.message:void 0,i=typeof r==`string`&&r.trim()?r:n.current.t(`chat:voiceMode.failed`),a=t instanceof DOMException&&t.name===`NotAllowedError`||i.includes(`microphone_permission_denied`)?n.current.t(`chat:voiceInput.permissionDenied`):i;I(),f(a),O(`error`),n.current.notifyError?.(a)}function R(e){return new Promise(t=>{let n=e.controller.signal,r=()=>{window.clearTimeout(i),n.removeEventListener(`abort`,r),t()},i=window.setTimeout(r,50);n.addEventListener(`abort`,r,{once:!0}),n.aborted&&r()})}async function z(e,t,r){let i=e.controller.signal,a=$s(i),o,s,c,l=!1,d=!1,f=!1,p=!1,m=!1,h=1/0,g=n=>{let r=n.filter(e=>e.role===`user`&&!t.has(e.id));return r.length>1||r.length===1&&r[0].text?.trim()!==e.prompt};e.checkOwnership=()=>{k(e)&&g(n.current.messages)&&(e.ownsRun=!1,L(e,Error(n.current.t(`chat:voiceMode.failed`))))};let _=e=>{a.update(e),u(t=>t.map(t=>t.id===r?{...t,text:e,pending:!e.trim()}:t))};e.responseSubscription=Xs(e.sessionId,r=>{if(!(!k(e)||r.source!==`snapshot`&&t.has(r.messageId)))try{let t=r.source===`snapshot`,i=!!(c&&r.startedAt===c);if(r.users&&g(r.users)||r.prompt!==void 0&&r.prompt.trim()!==e.prompt||s&&r.runId&&s!==r.runId||c&&r.startedAt&&c!==r.startedAt||t&&!i&&!(p&&!r.startedAt&&r.status===`completed`)||!t&&o&&o!==r.messageId)throw e.ownsRun=!1,Error(n.current.t(`chat:voiceMode.failed`));if(p&&t)return;if(s||=r.runId,c||=r.startedAt,r.messageId&&(o=r.messageId),r.status===`recovering`){l=!0;return}if(t&&(l=!0,d=r.status===`streaming`||r.status===`started`),r.status===`started`)return;if(f=!0,r.status===`failed`)throw e.ownsRun=!1,Error(r.error||n.current.t(`chat:voiceMode.failed`));_(r.text),r.status===`completed`&&(p=!0,e.ownsRun=!1,a.finish())}catch(t){a.finish(t),L(e,t)}});let v=Promise.resolve().then(()=>(X(i),n.current.sendPrompt(e.prompt,[],!1,!1,null))).catch(t=>{throw e.ownsRun=!1,a.finish(t),t}).finally(()=>{!f&&!s&&!c&&(e.ownsRun=!1),m=!0,h=Date.now()+15e3}),y=async()=>{for(;k(e);){if(await R(e),!k(e))return;let r=n.current.messages.filter(e=>!t.has(e.id)),i=r.filter(e=>e.role===`user`);if(i.length>1||i.length===1&&i[0].text?.trim()!==e.prompt)throw Error(n.current.t(`chat:voiceMode.failed`));let s=r.filter(e=>e.role===`assistant`||e.role===`agent`),c=s.find(e=>e.error);if(c)throw Error(String(c.error));if(p&&m&&!A())return;let u=s.at(-1);if(!l&&u?.text&&(!f||m&&!A())){if(o&&o!==u.id)throw Error(n.current.t(`chat:voiceMode.failed`));o=u.id,_(u.text)}if(!l&&m&&!A()&&u?.text?.trim()){e.ownsRun=!1,a.finish();return}if(m&&(A()||d)&&(h=Date.now()+15e3),Date.now()>=h)throw Error(n.current.t(`chat:voiceMode.emptyReply`))}};try{e.playback=Promise.resolve().then(()=>n.current.speakText(a,i,()=>{k(e)&&O(`speaking`)})),await Promise.all([v,y(),e.playback])}catch(e){throw a.finish(e),e}finally{e.responseSubscription?.(),e.responseSubscription=void 0,e.checkOwnership=void 0,a.finish()}}async function B(){let e=b.current;if(!e||!k(e)||e.committed||_.current!==`listening`)return;e.committed=!0;let t=e.endpoint?.hasSpeech;O(`transcribing`),o(0);try{if(await N(e),!k(e))return;if(!t){I();return}let r=(await e.recognizer?.finish())?.trim();if(!k(e))return;e.unsubscribe?.(),e.unsubscribe=void 0;let i=e.recognizer;if(e.recognizer=void 0,e.recognizerDisposing=i?.dispose(),await e.recognizerDisposing,!k(e))return;if(c(``),!r)throw Error(n.current.t(`chat:voiceMode.emptyReply`));if(A()){I();return}let a=new Set(n.current.messages.map(e=>e.id));e.baseline=a,e.prompt=r;let o=`voice-agent-${e.generation}`;if(u(t=>[...t.slice(-4),{id:`voice-user-${e.generation}`,role:`user`,text:r},{id:o,role:`agent`,text:``,pending:!0}]),O(`thinking`),e.abortRun=n.current.onAbort,e.ownsRun=!0,await z(e,a,o),!k(e))return;E.current&&!T.current?(O(`idle`),await D.current.start()):I()}catch(t){L(e,t)}}async function ee(){if(!w.current||!n.current.open||T.current||document.hidden||![`idle`,`error`,`speaking`].includes(_.current))return;F();let e={generation:++y.current,sessionId:n.current.sessionId,controller:new AbortController,microphone:new AbortController,permissionPending:!1,committed:!1,commitRequested:!1,ownsRun:!1};b.current=e,E.current=!0,f(``),c(``),o(0),O(`requesting`);let t=$o(),r=0;try{if(await x.current,!k(e)||(await M(),!k(e)))return;if(A()){I();return}e.permissionPending=!0;try{await Ts()}finally{e.permissionPending=!1}if(!k(e))return;if(document.hidden||A()){I();return}let n=await as();if(!k(e)){n.dispose();return}e.endpoint=n;let i=ks({chatSessionId:e.sessionId});if(e.recognizer=i,e.unsubscribe=i.onPartial(t=>{k(e)&&c(t)}),await i.start(),!k(e)||(e.capturePending=Ms(a=>{if(!(!k(e)||e.committed||e.microphone.signal.aborted))try{let s=t.push(Qo(a)),c=performance.now();c-r>=66&&(r=c,o(s));let l=i.acceptPcm(a),u=n.acceptPcm(a);(l||u)&&(e.commitRequested=!0,_.current===`listening`?D.current.commit():e.microphone.abort())}catch(t){L(e,t)}},e.microphone.signal).then(async t=>(!k(e)||e.microphone.signal.aborted?await t.stop():e.capture=t,t)),await e.capturePending,!k(e)))return;if(O(`listening`),e.commitRequested){await D.current.commit();return}e.limitTimer=window.setTimeout(()=>void D.current.commit(),6e4)}catch(t){k(e)&&e.commitRequested&&e.microphone.signal.aborted?(O(`listening`),await D.current.commit()):L(e,t)}}D.current={start:ee,commit:B,stop:I};let te=(0,Z.useCallback)(()=>D.current.commit(),[]),V=(0,Z.useCallback)(()=>{D.current.stop();let e=y.current;x.current.then(()=>{y.current===e&&w.current&&D.current.start()})},[]),ne=(0,Z.useCallback)(()=>{_.current===`listening`?D.current.commit():_.current===`thinking`||_.current===`speaking`?V():(_.current===`idle`||_.current===`error`)&&(T.current=!1,m(!1),D.current.start())},[V]),re=(0,Z.useCallback)(()=>{let e=!T.current;T.current=e,m(e),e?D.current.stop():D.current.start()},[]),ie=(0,Z.useCallback)(()=>{j(),D.current.stop(),f(``),g(0)},[]);return(0,Z.useEffect)(()=>{if(!e.open)return;w.current=!0,S.current=!1,T.current=!1,m(!1),u([]),g(0),O(`idle`),D.current.start();let t=()=>{b.current?.permissionPending&&window.__PISPER_MOBILE_APP__||(j(),D.current.stop())},n=()=>{document.hidden&&t()},r=()=>{j(),D.current.stop()};return window.addEventListener(`blur`,t),window.addEventListener(`pisper:speech-interrupted`,r),document.addEventListener(`visibilitychange`,n),()=>{w.current=!1,j(),D.current.stop(),window.removeEventListener(`blur`,t),window.removeEventListener(`pisper:speech-interrupted`,r),document.removeEventListener(`visibilitychange`,n)}},[e.open,e.sessionId,O]),(0,Z.useEffect)(()=>{b.current?.checkOwnership?.()},[e.messages,e.streaming]),(0,Z.useEffect)(()=>{if(![`listening`,`transcribing`,`thinking`,`speaking`].includes(r))return;let e=window.setInterval(()=>g(e=>e+1),1e3);return()=>window.clearInterval(e)},[r]),{stage:r,level:a,partial:s,turns:l,error:d,muted:p,elapsed:h,toggleMain:ne,toggleMute:re,hangUp:ie,commitListening:te,interrupt:V}}function tc(e){return{idle:e(`chat:voiceMode.idle`),requesting:e(`chat:voiceMode.requesting`),listening:e(`chat:voiceMode.listening`),transcribing:e(`chat:voiceMode.transcribing`),thinking:e(`chat:voiceMode.thinking`),speaking:e(`chat:voiceMode.speaking`),error:e(`chat:voiceMode.failed`)}}function nc(e){let t=Math.floor(e/60),n=e%60;return`${t.toString().padStart(2,`0`)}:${n.toString().padStart(2,`0`)}`}function rc(){let[e,t]=(0,Z.useState)(()=>document.documentElement.dataset.theme!==`light`);return(0,Z.useEffect)(()=>{let e=document.documentElement,n=()=>t(e.dataset.theme!==`light`);n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`data-theme`]}),()=>r.disconnect()},[]),e}function ic(e){let[t,n]=(0,Z.useState)(()=>typeof window>`u`?380:Math.max(48,Math.min(window.innerWidth*.52,window.innerHeight-304,460)));return(0,Z.useEffect)(()=>{if(!e)return;let t=()=>n(Math.max(48,Math.min(window.innerWidth*.52,window.innerHeight-304,460)));return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),Math.floor(t)}function ac({open:e,sessionId:t,messages:n,streaming:r,sendPrompt:i,onAbort:a,onClose:o}){let{t:s}=v(),c=rc(),l=ss([`asr`,`tts`]),u=ec({open:e,sessionId:t,messages:n,streaming:r,sendPrompt:i,onAbort:a,ensureReady:l.ensureReady,speakText:(e,t,n)=>ms(e,l.selectedVoice,t,n)}),{stage:f,level:p,partial:m,turns:h,error:g,elapsed:_}=u,y=ic(e),b=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e)return;let t=document.activeElement;return b.current?.focus({preventScroll:!0}),()=>{t instanceof HTMLElement&&t.isConnected&&t.focus({preventScroll:!0})}},[e]);let x=()=>{try{u.hangUp()}finally{l.close(),o()}},S=f===`listening`||f===`transcribing`||f===`thinking`||f===`speaking`||f===`requesting`;if((0,Z.useEffect)(()=>{if(!e)return;let t=e=>{if(!(l.open||e.defaultPrevented||e.isComposing)){if(e.key===`Escape`){e.preventDefault(),x();return}if(e.key===`Tab`){let t=[...b.current?.querySelectorAll(`button:not(:disabled)`)||[]],n=t[0],r=t[t.length-1];e.shiftKey&&(document.activeElement===n||document.activeElement===b.current)?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())}e.target instanceof Element&&e.target.closest(`input, textarea, select, button, [contenteditable="true"]`)||e.key===` `&&!e.repeat&&(e.preventDefault(),S?u.hangUp():u.toggleMain())}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,o,S,l.open]),!e)return null;let C=tc(s),w=h[h.length-1],T=f===`listening`&&m?m:w?`${w.role,``}${es(w.text,120)}`:``,E=f===`error`?g||s(`chat:voiceMode.failed`):C[f];return(0,ai.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[90] grid grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)_100px_108px] overflow-hidden select-none pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)] ${c?`bg-[#030304] text-[#cfe8ff]`:`bg-[#f2f5fa] text-[#1e2c42]`}`,ref:b,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":s(`chat:voiceMode.title`),children:[(0,Q.jsxs)(`header`,{className:`pointer-events-none absolute left-[calc(env(safe-area-inset-left)_+_28px)] top-[calc(env(safe-area-inset-top)_+_24px)] flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`inline-block size-2 rounded-full ${S?`animate-pulse bg-[#59e6ff]`:c?`bg-[#3b4a5c]`:`bg-[#b6c3d4]`}`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-[13px] font-bold tracking-[0.42em] ${c?`text-[#9be7ff] [text-shadow:0_0_14px_rgba(89,230,255,.45)]`:`text-[#0d6ac9]`}`,children:`PISPER`})]}),(0,Q.jsxs)(`div`,{className:`absolute top-[calc(env(safe-area-inset-top)_+_16px)] right-[calc(env(safe-area-inset-right)_+_16px)] z-10 flex items-center gap-1`,children:[(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{variant:`ghost`,size:`icon-sm`,"aria-label":s(`chat:speechModels.title`),onClick:()=>{u.hangUp(),l.show()},children:(0,Q.jsx)(Dn,{})})}),(0,Q.jsx)(ae,{children:s(`chat:speechModels.title`)})]}),(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{variant:`ghost`,size:`icon-sm`,className:`size-11 flex-none`,"aria-label":s(`chat:speechModels.close`),onClick:x,children:(0,Q.jsx)(Oe,{})})}),(0,Q.jsx)(ae,{children:s(`chat:speechModels.close`)})]})]}),(0,Q.jsx)(xs,{manager:l,onClose:()=>u.hangUp()}),(0,Q.jsx)(`div`,{className:`flex min-h-0 items-center justify-center pt-16 pb-6`,children:(0,Q.jsx)(Js,{stage:f,level:p,size:y,dark:c})}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`max-w-full text-[11px] font-semibold uppercase tracking-normal ${f===`error`?`max-h-full overflow-y-auto break-words text-[#f87171]`:`line-clamp-2 ${c?`text-[#5f7a94]`:`text-[#7488a0]`}`}`,role:`status`,"aria-live":`polite`,children:E}),(0,Q.jsx)(`p`,{className:`m-0 line-clamp-2 min-h-[22px] max-w-[640px] text-[15px] leading-[1.6] ${c?`text-[#d7e6f7]`:`text-[#24344d]`}`,children:T})]}),(0,Q.jsx)(`div`,{className:`relative flex justify-center pt-3 sm:items-center sm:pt-0`,children:(0,Q.jsx)(`button`,{type:`button`,className:`h-11 cursor-pointer rounded-full border bg-transparent px-9 text-[11px] font-semibold uppercase tracking-[0.3em] transition-[box-shadow,background-color,border-color] duration-300 ${c?`border-[rgba(140,220,255,.4)] text-[#9be7ff] hover:border-[rgba(140,220,255,.8)] hover:bg-[rgba(89,230,255,.08)] hover:shadow-[0_0_28px_rgba(89,230,255,.25)]`:`border-[rgba(13,106,201,.45)] text-[#0d6ac9] hover:border-[rgba(13,106,201,.85)] hover:bg-[rgba(13,106,201,.07)] hover:shadow-[0_0_28px_rgba(13,106,201,.18)]`}`,onClick:()=>S?u.hangUp():u.toggleMain(),children:s(S?`chat:voiceMode.endConversation`:`chat:voiceMode.startConversation`)})}),(0,Q.jsxs)(`div`,{className:`pointer-events-none absolute bottom-[calc(env(safe-area-inset-bottom)_+_12px)] right-[calc(env(safe-area-inset-right)_+_20px)] flex items-center gap-2.5 sm:bottom-[calc(env(safe-area-inset-bottom)_+_36px)] sm:right-[calc(env(safe-area-inset-right)_+_28px)]`,children:[(0,Q.jsx)(`span`,{className:`hidden size-9 place-items-center rounded-full sm:grid bg-[linear-gradient(135deg,#2563eb,#38bdf8)] text-[10px] font-bold text-white shadow-[0_0_18px_rgba(56,189,248,.4)]`,"aria-hidden":`true`,children:S?`●`:`○`}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] tabular-nums tracking-[0.12em] ${c?`text-[#7d93ad]`:`text-[#61748c]`}`,children:nc(_)})]}),(0,Q.jsx)(`div`,{className:`absolute bottom-[env(safe-area-inset-bottom)] left-[calc(env(safe-area-inset-left)_+_20px)] sm:bottom-[calc(env(safe-area-inset-bottom)_+_36px)] sm:left-[calc(env(safe-area-inset-left)_+_28px)]`,children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{asChild:!0,children:(0,Q.jsx)(d,{variant:`ghost`,size:`icon`,className:`size-11 flex-none`,disabled:!S&&!u.muted,"aria-label":f===`speaking`||f===`thinking`?s(`chat:voiceMode.interrupt`):u.muted?s(`chat:voiceMode.unmute`):s(`chat:voiceMode.mute`),onClick:()=>f===`speaking`||f===`thinking`?u.interrupt():u.toggleMute(),children:f===`speaking`||f===`thinking`?(0,Q.jsx)(Te,{}):u.muted?(0,Q.jsx)(qn,{}):(0,Q.jsx)(Jn,{})})}),(0,Q.jsx)(ae,{children:f===`speaking`||f===`thinking`?s(`chat:voiceMode.interrupt`):u.muted?s(`chat:voiceMode.unmute`):s(`chat:voiceMode.mute`)})]})})]}),document.body)}var oc=({className:e,defaultOpen:t=!0,...n})=>(0,Q.jsx)(R,{className:W(e),defaultOpen:t,...n});function sc({queuedInputs:e}){let{t}=v();return(0,Q.jsx)(oc,{asChild:!0,defaultOpen:!0,children:(0,Q.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":e.length,children:[(0,Q.jsx)(`span`,{children:t(`chat:focusSession.sentToTheRunningAgent`)}),e.slice(-3).map((e,t)=>(0,Q.jsx)(`small`,{title:e.text,children:e.text},e.id||`${e.behavior}-${t}`)),e.length>3&&(0,Q.jsx)(`em`,{children:t(`chat:focusSession.countMore`,{count:e.length-3})})]})})}function cc({invocation:e,onRemove:t}){let{t:n}=v();return(0,Q.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] ${e.kind}`,children:[e.kind===`tool`?(0,Q.jsx)(De,{size:13}):(0,Q.jsx)(B,{size:13}),(0,Q.jsxs)(`span`,{children:[e.kind===`skill`?`Skill`:e.kind===`tool`?n(`chat:resourcePicker.tool`):n(`chat:resourcePicker.workflow`),` `,`· `,e.resourceName]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":n(`chat:resourcePicker.remove`),onClick:t,children:(0,Q.jsx)(Oe,{size:13})})]})}function lc({compaction:e,streaming:t}){let{t:n}=v();return(0,Q.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)] ${e?.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]`:t?`running`:`idle`}`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(`i`,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:e?.active?n(`chat:focusSession.compactingContext`):n(t?`chat:focusSession.running`:`chat:focusSession.waitingForInput`)})]})}function uc({streaming:e,compactingManually:t,compactionActive:n,disabled:r,onCompact:i}){let{t:a}=v();return(0,Q.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:a(e?`chat:focusSession.manualCompactionWaitForRun`:t||n?`chat:focusSession.compactingContext`:`chat:focusSession.compactContextNow`),"aria-label":a(`chat:focusSession.compactContextNow`),disabled:r,onClick:i,children:t||n?(0,Q.jsx)(J,{className:`animate-spin`,size:14}):(0,Q.jsx)(Yn,{size:14})})}function dc({streaming:e,queueing:t,disabled:n,onAbort:r}){let{t:i}=v(),a=ft(`sendMessage`),o=i(`chat:focusSession.sendMessage`);return(0,Q.jsx)(`button`,{type:e?`button`:`submit`,className:`send-button grid !size-11 flex-none place-items-center rounded-[var(--r-sm)] border-0 bg-[var(--star)] text-[var(--on-accent)] transition-[var(--d1)] cursor-pointer hover:not(:disabled):bg-[var(--star-hover)] hover:not(:disabled):shadow-[var(--sh-star)] active:not(:disabled):scale-[.96] disabled:cursor-not-allowed disabled:border disabled:border-[var(--stroke)] disabled:bg-[var(--surface-muted)] disabled:text-[var(--text-muted)] ${e?`stop !bg-[var(--danger)] hover:not(:disabled):shadow-[0_0_0_3px_var(--danger-soft)]`:``}`,title:e?i(`chat:focusSession.stop`):a?`${o} (${a})`:o,"aria-label":i(e?`chat:focusSession.stop`:`chat:focusSession.sendMessage`),onClick:e?r:void 0,disabled:n,children:e?(0,Q.jsx)(Te,{size:16,fill:`currentColor`}):t?(0,Q.jsx)(J,{className:`animate-spin`,size:17}):(0,Q.jsx)(be,{size:18})})}var fc=36,pc=40;function mc(e){let[t,n]=(0,Z.useState)(1/0);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=t.getBoundingClientRect().width-fc;n(Math.max(0,Math.floor(e/pc)))};if(r(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,r),()=>window.removeEventListener(`resize`,r);let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}var hc=[`plan`,`goal`,`team`];function gc(e){return hc.includes(e)?e:`plan`}function _c({sessionId:e,runMode:t,goalsAvailable:n,teamAvailable:r,workflowsAvailable:i,goal:a,streaming:o,compaction:s,value:c,selection:l,clearDraft:u,promptRef:d,onCompact:f,onGoalPause:p,onSend:m,onQueue:h,setToolsOpen:g,requestTranscriptBottom:_}){let[v,y]=(0,Z.useState)(()=>gc(t)),b=(0,Z.useRef)(t);b.current=t;let[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),T=(0,Z.useRef)(null),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{y(gc(b.current)),T.current=null,S(null),w(null),D(!1),k(!1),j(null)},[e]),(0,Z.useEffect)(()=>{y(gc(t))},[e,t]),(0,Z.useEffect)(()=>{n||y(`plan`),!r&&v===`team`&&y(`goal`),!i&&A?.kind===`workflow`&&j(null)},[v,n,A?.kind,r,i]),(0,Z.useEffect)(()=>{a?.status===`active`&&y(a.mode===`team`&&r?`team`:`goal`)},[a?.id,a?.mode,a?.status,r]),(0,Z.useEffect)(()=>{if(!a?.id){S(null);return}let e=a.mode===`team`?a.teamTokenBudget:a.tokenBudget,t=e==null?null:Number(e),n=t!==null&&Number.isFinite(t)&&t>0?t:null;a.mode===`team`?w(n):S(n)},[a?.id,a?.mode,a?.teamTokenBudget,a?.tokenBudget]),{composerExecutionMode:v,setComposerExecutionMode:y,goalTokenBudget:x,setGoalTokenBudget:S,teamTokenBudget:C,setTeamTokenBudget:w,queueing:E,compactingManually:O,invocation:A,setInvocation:j,requestGoalPause:()=>{if(T.current)return T.current;let e=Promise.resolve().then(()=>p?.());return T.current=e,e.catch(()=>{}),e},compactContext:async()=>{if(!(!f||o||O||s?.active)){k(!0);try{await f()}finally{k(!1)}}},submit:async e=>{if(e.preventDefault(),!c.trim()&&!l.attachments.length&&!A)return;if(o){if(!c.trim()&&!l.attachments.length||E)return;D(!0);let e=await h?.(c,l.attachments,`steer`);if(D(!1),!e)return;u(),y(`plan`),g(!1),_(),d.current&&(d.current.style.height=`auto`);return}let t=T.current;if(t){try{await t}catch{T.current=null;return}T.current=null}else a?.status===`active`&&(v===`plan`||v!==a.mode)&&await p?.();m(c,l.attachments,v===`goal`||v===`team`,v===`team`,v===`team`?C:v===`goal`?x:null,A),_(),u(),y(`plan`),g(!1),j(null),d.current&&(d.current.style.height=`auto`)}}}var vc=[`.composer-tools-trigger`,`.composer-tool-tray-shell`,`.anchored-popup-menu`,`.voice-input-popup`,`.git-diff-dialog-backdrop`,`[data-slot='dialog-content']`,`[data-slot='dialog-overlay']`,`[data-slot='alert-dialog-content']`,`[data-slot='alert-dialog-overlay']`,`[data-slot='popover-content']`,`[data-slot='dropdown-menu-content']`,`[data-slot='dropdown-menu-sub-content']`,`[data-slot='select-content']`,`[data-slot='sheet-content']`,`[data-slot='sheet-overlay']`].join(`, `),yc=(0,Z.memo)(function({session:e,shortcutEnabled:t=!1,messages:n,transcriptLoadState:r=`ready`,messageStart:i,hasOlder:a,loadingOlder:o,olderError:s,model:c,thinkingLevel:l,availableThinkingLevels:u,thinkingStatus:d,thinkingMessage:f,executionMode:p,goal:m,team:h,plan:g,currentActivity:_,activityFeed:y,tools:b,thinkingText:x,queuedInputs:S,compaction:w,contextUsage:T,sessionUsage:E,sessionTreeRevision:D,sessionTreePulse:O,cwd:k,availableModels:A,switchingModel:j,switchingThinking:M,switchingCwd:N,switchingPermission:P,streaming:F,runStartedAt:I,lastActivityAt:L,runFinishedAt:R,runStopped:z,runNotice:ee,approvals:te,error:V,pendingAsset:ne,canSplit:re,canClosePanel:ie=!0,notify:H,onOpenModelSettings:ae,onAssetConsumed:U,onLoadOlder:W,onModelChange:oe,onThinkingLevelChange:se,onExecutionModeChange:ce,onRunModeChange:G,onCompact:le,onCompactionThresholdChange:ue,onGoalPause:de,onGoalBudgetChange:fe,onApproval:K,onWorkspace:pe,onRename:me,onBranchFromHere:he,onCreateChildSession:ge,onTreeNavigated:_e,onSplitLeft:ve,onSplitRight:ye,onSplitTop:be,onSplitBottom:xe,onClosePanel:Ce,onSend:we,onQueue:Te,onAbort:Ee}){let{t:q,language:De}=v(),ke=mt(e=>e.bindings),Ae=ft(`commandPalette`),je=Se(),Me=C(),Pe=je||Me,Fe=Ie(e=>e.capabilities),Le=nt(Fe,`goals`),Re=nt(Fe,`multiAgent`),ze=nt(Fe,`plans`),Be=nt(Fe,`vcs`),Ve=nt(Fe,`workflows`),He=nt(Fe,`visualGeneration`),{value:We,updateValue:Ke,selection:J,clearDraft:qe}=Yr(e.id),[Je,Ye]=(0,Z.useState)(!1),[Xe,Ze]=(0,Z.useState)(!1),[Qe,$e]=(0,Z.useState)(!1),[et,tt]=(0,Z.useState)(!1),[it,ot]=(0,Z.useState)(0),st=J.addAttachments,ct=(0,Z.useRef)(null),lt=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{!dt(e)&&pt(e,ke.focusComposer)&&(e.preventDefault(),ct.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,ke.focusComposer]);let Y=(0,Z.useRef)(null),ht=(0,Z.useRef)(null),gt=(0,Z.useRef)(null),_t=mc(Y),vt=ui(e=>e.layout),yt=(0,Z.useRef)(!1),bt=r!==`ready`||n.length>0,xt=`composer-tool-tray-${e.id}`,St=q(et?`chat:focusSession.collapseQuickActions`:`chat:focusSession.expandQuickActions`),Ct=q(Pe?F?`chat:focusSession.addGuidanceForTheRunningAgent`:`chat:focusSession.writeWhatYouWantToAccomplish`:F?`chat:focusSession.runningAgentComposerHint`:`chat:focusSession.composerHint`),X=()=>ot(e=>e+1),wt=e=>{Ke(e),requestAnimationFrame(()=>{let e=ct.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})},{composerExecutionMode:Tt,setComposerExecutionMode:Et,goalTokenBudget:Dt,setGoalTokenBudget:Ot,teamTokenBudget:kt,setTeamTokenBudget:At,queueing:jt,compactingManually:Mt,invocation:Nt,setInvocation:Pt,requestGoalPause:Ft,compactContext:It,submit:Lt}=_c({sessionId:e.id,runMode:e.runMode,goalsAvailable:Le,teamAvailable:Re,workflowsAvailable:Ve,goal:m,streaming:F,compaction:w,value:We,selection:J,clearDraft:qe,promptRef:ct,onCompact:le,onGoalPause:de,onSend:we,onQueue:Te,setToolsOpen:tt,requestTranscriptBottom:X});(0,Z.useEffect)(()=>{Ye(!1),Ze(!1),tt(!1)},[e.id]),(0,Z.useEffect)(()=>{ne&&(st([ne]),U?.())},[ne,U,st]),(0,Z.useEffect)(()=>{if(!et)return;let e=e=>{e.key===`Escape`&&tt(!1)},t=e=>{let t=e.target;t instanceof Element&&!t.closest(vc)&&tt(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[et]);let Rt=e=>{Ke(e),requestAnimationFrame(()=>{let e=ct.current;e&&(e.focus(),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})},zt=(0,Q.jsx)(ko,{session:e,canSplit:re,canClose:ie,streaming:F,switchingCwd:N,onSplitLeft:ve,onSplitRight:ye,onSplitTop:be,onSplitBottom:xe,onClosePanel:Ce,onWorkspace:pe,onRename:me,onSessionTree:()=>Ze(!0)}),Bt={attachment:q(`chat:focusSession.addAttachment`),resource:q(`chat:resourcePicker.open`),visual:q(`chat:focusSession.generateImage`),model:q(`chat:focusSession.toolbarModel`),permission:q(`chat:focusSession.approvalMode`),"run-mode":q(`chat:focusSession.executionMode`),thinking:q(`chat:focusSession.currentThinkingLevel`),commands:q(`chat:focusSession.commands`),"git-changes":q(`chat:focusSession.gitChanges`),"compact-context":q(`chat:focusSession.compactContextNow`),"session-actions":q(`chat:focusSession.chatActions`)},Vt={attachment:(0,Q.jsx)(zr,{cwd:k,selection:J}),resource:(0,Q.jsx)(`button`,{type:`button`,className:`resource-picker-trigger grid size-9 min-w-9 place-items-center rounded-[var(--r-sm)] border-0 bg-[var(--surface-subtle)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)]`,title:q(`chat:resourcePicker.open`),"aria-label":q(`chat:resourcePicker.open`),onClick:()=>Ye(!0),children:(0,Q.jsx)(B,{size:16})}),visual:He?(0,Q.jsx)(Yo,{notify:H,onOpenModelSettings:ae,onInsertPrompt:Rt}):null,model:(0,Q.jsx)(Di,{value:c,models:A,onChange:oe,disabled:F||j}),permission:(0,Q.jsx)(Ai,{value:p,onChange:ce,disabled:P}),"run-mode":Le?(0,Q.jsx)(Oo,{mode:Tt,goal:m,teamAvailable:Re,disabled:F,tokenBudget:Tt===`team`?kt:Dt,onTokenBudgetChange:Tt===`team`?At:Ot,onSaveTokenBudget:e=>fe?.(e),onChange:e=>{m?.status===`active`&&(e===`plan`||e!==m.mode)&&Ft().catch(()=>{}),Et(e),G(e)}}):null,thinking:(0,Q.jsx)(Oi,{value:l||`medium`,levels:u||[],status:d,message:f,onChange:se,disabled:F||M||j}),commands:(0,Q.jsxs)(`button`,{type:`button`,className:`command-palette-trigger relative grid size-9 min-w-9 place-items-center rounded-[var(--r-sm)] border-0 bg-[var(--surface-subtle)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)] [&_kbd]:sr-only`,title:Ae?q(`chat:focusSession.openCommandPaletteShortcut`,{shortcut:Ae}):q(`chat:focusSession.commands`),"aria-label":Ae?q(`chat:focusSession.openCommandPaletteShortcut`,{shortcut:Ae}):q(`chat:focusSession.commands`),onClick:Ue,children:[(0,Q.jsx)(Nn,{size:16}),(0,Q.jsx)(`kbd`,{children:Ae})]}),"git-changes":Be?(0,Q.jsx)(wo,{sessionId:e.id,streaming:F}):null,"compact-context":(0,Q.jsx)(uc,{streaming:F,compactingManually:Mt,compactionActive:!!w?.active,disabled:!le||F||Mt||!!w?.active||n.length===0,onCompact:()=>void It()}),"session-actions":bt?zt:null},Ht=ii(vt,Zr.filter(e=>Vt[e]!==null),_t),Ut=e=>(0,Q.jsx)(`div`,{className:`composer-toolbar-slot grid size-9 min-w-9 flex-none place-items-center overflow-visible [&>button]:!size-9 [&>button]:!min-w-9 [&>div]:!size-9 [&>div]:!min-w-9 [&>div>button]:!size-9 [&_.git-changes-trigger>i]:!right-0.5 [&_.git-changes-trigger>i]:!top-0.5`,"data-composer-tool-id":e,children:Vt[e]},e);return(0,Q.jsxs)(at,{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 ${bt?`has-conversation`:`is-empty`}`,children:[!bt&&(0,Q.jsx)(rt,{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,Q.jsx)(`div`,{className:`flex [margin-left:auto] items-center gap-[6px]`,children:zt})}),(0,Q.jsx)(Ho,{visible:n.length>0,open:Xe,sessionId:e.id,streaming:!!F,revision:D,pulseToken:O,onOpenChange:Ze,onNavigated:async e=>{e!==null&&Rt(e),await _e?.(),X()},onCreateChildSession:e=>ge(e)}),(0,Q.jsx)(uo,{sessionId:e.id,messages:n,transcriptLoadState:r,messageStart:i,hasOlder:a,loadingOlder:o,olderError:s,currentActivity:_,team:h,activityFeed:y,tools:b,thinkingText:x,compaction:w,streaming:F,runStartedAt:I,lastActivityAt:L,runFinishedAt:R,runStopped:z,runNotice:ee,error:V,scrollRequest:it,cwd:k,lineage:e.lineage,switchingCwd:N,onLoadOlder:W,onBranchFromHere:he,onCreateChildSession:ge,onPromptSelect:Rt,onWorkspace:pe}),(0,Q.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] relative z-20 flex w-[min(960px,calc(100%_-_48px))] flex-none flex-col gap-[7px] [margin:0_auto] [padding:10px_0_0]`,onSubmit:Lt,children:[(0,Q.jsx)(Jo,{approvals:te,onResolve:K}),F&&S.length>0&&(0,Q.jsx)(sc,{queuedInputs:S}),Ve&&(0,Q.jsx)(Go,{sessionId:e.id}),Nt&&(0,Q.jsx)(cc,{invocation:Nt,onRemove:()=>Pt(null)}),(0,Q.jsx)(Br,{attachments:J.attachments,onRemove:J.removeAttachment}),J.attachmentError&&(0,Q.jsx)(`span`,{className:`text-[var(--danger)] text-[13px]`,children:J.attachmentError}),(0,Q.jsx)(lc,{compaction:w,streaming:F}),(0,Q.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,Q.jsx)(Xr,{sessionId:e.id,value:We,onChange:Ke,inputRef:ct}),(0,Q.jsx)(`textarea`,{ref:ct,rows:1,value:We,onChange:e=>{Ke(e.target.value),e.currentTarget.style.height=`auto`,e.currentTarget.style.height=`${Math.min(e.currentTarget.scrollHeight,220)}px`},onPaste:J.pasteFiles,onCompositionStart:()=>yt.current=!0,onCompositionEnd:()=>window.setTimeout(()=>yt.current=!1,0),onKeyDown:e=>{!(e.nativeEvent.isComposing||yt.current)&&pt(e.nativeEvent,ke.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"data-mobile-composer-input":Pe||void 0,enterKeyHint:Pe&&ke.sendMessage===`Enter`?`send`:`enter`,placeholder:Ct}),(0,Q.jsxs)(`div`,{className:`focus-composer-footer flex min-w-0 items-center gap-1`,children:[(0,Q.jsxs)(`div`,{ref:Y,className:`focus-composer-quick-actions flex min-w-0 flex-1 items-center gap-1`,children:[(0,Q.jsx)(`button`,{ref:ht,type:`button`,className:`composer-tools-trigger grid size-9 min-w-9 flex-none place-items-center rounded-[var(--r-sm)] border border-transparent bg-[var(--surface-subtle)] text-[var(--text-muted)] cursor-pointer transition-[background-color,color,border-color,box-shadow] duration-150 hover:border-[var(--brand-blue)] hover:bg-[var(--brand-blue-soft)] hover:text-[var(--brand-blue-strong)] ${et?`active border-[var(--brand-blue)] bg-[var(--brand-blue-soft)] text-[var(--brand-blue-strong)]`:``}`,title:St,"aria-label":St,"aria-expanded":et,"aria-controls":xt,onClick:()=>tt(e=>!e),children:et?(0,Q.jsx)(Oe,{size:17}):(0,Q.jsx)(ut,{size:18})}),(0,Q.jsx)(`div`,{className:`focus-composer-visible-tools flex min-w-0 flex-none items-center gap-1`,children:Ht.inline.map(Ut)}),(0,Q.jsxs)(li,{open:et,label:q(`chat:focusSession.quickActions`),trayId:xt,anchorRef:ht,menuRef:gt,children:[Ht.overflow.map(Ut),Ht.overflow.length>0&&(0,Q.jsx)(`span`,{className:`mx-0.5 h-6 w-px flex-none bg-[var(--stroke-soft)]`,"aria-hidden":`true`}),(0,Q.jsx)(pi,{labels:Bt})]})]}),(0,Q.jsx)(`div`,{className:`focus-composer-secondary flex h-11 min-w-0 flex-none items-center justify-end`,children:(0,Q.jsx)(Ei,{usage:T,onThresholdChange:ue,compact:!0})}),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`grid !size-11 !min-w-11 place-items-center rounded-[var(--r-sm)] border border-transparent bg-[var(--surface-subtle)] text-[var(--text-muted)] transition-[background-color,color,border-color,box-shadow,transform] duration-200 hover:scale-105 hover:border-[var(--brand-blue)] hover:bg-[var(--brand-blue-soft)] hover:text-[var(--brand-blue-strong)]`,title:q(`chat:voiceMode.open`),"aria-label":q(`chat:voiceMode.open`),onClick:()=>$e(!0),children:(0,Q.jsx)(Dn,{size:17})}),(0,Q.jsx)(Is,{sessionId:e.id,shortcutEnabled:t,onLiveText:e=>{if(e===null){lt.current!==null&&(wt(lt.current),lt.current=null);return}lt.current===null&&(lt.current=(ct.current?.value??We).trimEnd());let t=lt.current;wt(t&&e?`${t}\n${e}`:t||e)},onInsert:e=>{let t=lt.current??(ct.current?.value??We).trimEnd();lt.current=null,wt(t?`${t}\n${e}`:e),requestAnimationFrame(()=>ct.current?.focus())}})]}),(0,Q.jsx)(dc,{streaming:F,queueing:jt,disabled:!F&&(jt||!We.trim()&&!J.attachments.length&&!Nt),onAbort:Ee})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 min-h-[26px] items-center gap-[6px] [margin:0_8px_5px] text-[var(--text-tertiary)]`,children:[bt&&(0,Q.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:k,"aria-label":q(`chat:focusSession.changeWorkingDirectoryWorkspace`,{workspace:Ge(k,De)}),onClick:pe,disabled:F||N,children:[(0,Q.jsx)(Ne,{size:12}),(0,Q.jsx)(`span`,{children:Ge(k,De)})]}),(0,Q.jsx)(Ti,{usage:E,plan:ze?g:null,compact:Pe})]})]}),(0,Q.jsx)(Vr,{open:Je,sessionId:e.id,onClose:()=>Ye(!1),onSelect:Pt,onCommandSelect:e=>Rt(Wr(e,We))}),(0,Q.jsx)(ac,{open:Qe,sessionId:e.id,sessionName:e.name||e.id,messages:n,streaming:F,sendPrompt:we,onAbort:Ee,onClose:()=>$e(!1)})]})}),bc=(0,Z.createContext)(null),xc=40,Sc=[];function Cc({params:e,api:t}){let n=(0,Z.useContext)(bc),r=e?.sessionId||it(t?.id),[i,a]=(0,Z.useState)(()=>t.isVisible),[o,s]=(0,Z.useState)(()=>t.isActive);return(0,Z.useEffect)(()=>{s(t.isActive);let e=t.onDidActiveChange(({isActive:e})=>s(e));return()=>e.dispose()},[t]),(0,Z.useEffect)(()=>{a(t.isVisible);let e=t.onDidVisibilityChange(({isVisible:e})=>a(e));return()=>e.dispose()},[t]),i?(0,Q.jsx)(Ec,{sessionId:r,panelId:t.id,shortcutEnabled:o,onFocusCapture:()=>t.setActive(),canSplitPanel:n?.compactDock===!1&&t.group.size>1,canClosePanel:!0}):null}function wc(){try{let e=JSON.parse(localStorage.getItem(ce.mobileSessionTabs)||`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(-6):[]}catch{return[]}}function Tc({sessionIds:e=[],onSelectSession:t,onCreateSession:n}){let{t:r}=v(),i=(0,Z.useContext)(bc),a=i?.activeId||``,[o,s]=(0,Z.useState)(wc),c=(0,Z.useRef)(!1),l=(0,Z.useRef)(null),u=(0,Z.useMemo)(()=>{let e=new Map(i?.sessions.map(e=>[e.id,e]));return o.flatMap(t=>{let n=e.get(t);return n?[n]:[]})},[i?.sessions,o]),d=i?.sessions.find(e=>e.id===a),f=d&&!u.some(e=>e.id===d.id)?[...u,d]:u,p=d?.id||f[0]?.id||``;(0,Z.useEffect)(()=>{let t=new Set(i?.sessions.map(e=>e.id)),n=!c.current&&e.length?e:[];n.length&&(c.current=!0),s(e=>{let r=e.filter(e=>t.has(e));for(let e of[...n,a])e&&t.has(e)&&!r.includes(e)&&r.push(e);let i=r.slice(-6);return i.length===e.length&&i.every((t,n)=>t===e[n])?e:i})},[a,i?.sessions,e]),(0,Z.useEffect)(()=>{localStorage.setItem(ce.mobileSessionTabs,JSON.stringify(o))},[o]),(0,Z.useEffect)(()=>{l.current?.scrollIntoView({block:`nearest`,inline:`center`})},[p]);let m=e=>{let n=Je(f.map(e=>e.id),e,p);s(n.tabIds),n.activeId!==p&&t(n.activeId)};return(0,Q.jsxs)(`div`,{className:`mobile-session-shell flex h-full min-h-0 min-w-0 flex-col bg-[var(--panel)]`,children:[(0,Q.jsxs)(`nav`,{className:`mobile-session-tabs flex h-[52px] flex-none border-b border-[var(--stroke-soft)] bg-[var(--surface-subtle)]`,role:`tablist`,"aria-label":r(`chat:chatPage.openChats`),children:[(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:f.map(e=>{let n=e.name||r(`chat:chatPage.untitledChat`),i=e.id===p;return(0,Q.jsxs)(`div`,{className:`group relative flex h-full min-w-[148px] max-w-[228px] flex-none items-stretch border-b-[3px] transition-colors ${i?`border-[var(--brand-blue)] bg-[var(--solid)] text-[var(--text)]`:`border-transparent bg-transparent text-[var(--text-secondary)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)]`}`,children:[(0,Q.jsxs)(`button`,{ref:i?l:void 0,type:`button`,role:`tab`,id:`mobile-session-tab-${e.id}`,"aria-selected":i,"aria-controls":`mobile-session-tabpanel`,className:`flex min-w-0 flex-1 items-center gap-2 border-0 bg-transparent py-0 pl-3 text-left text-[13px] focus-visible:z-[1] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)] ${i?`font-[650]`:`font-[500]`}`,title:n,onClick:()=>t(e.id),children:[(0,Q.jsx)(lt,{size:15,className:`flex-none`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),e.streaming&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 flex-none rounded-full bg-[var(--brand-blue)]`})]}),(0,Q.jsx)(`button`,{type:`button`,className:`grid w-9 flex-none place-items-center border-0 bg-transparent text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)] focus-visible:z-[1] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,title:r(`chat:chatPage.closeChat`,{title:n}),"aria-label":r(`chat:chatPage.closeChat`,{title:n}),onClick:()=>m(e.id),children:(0,Q.jsx)(Oe,{size:14,"aria-hidden":`true`})})]},e.id)})}),(0,Q.jsx)(`button`,{type:`button`,className:`grid h-full w-[52px] flex-none place-items-center border-0 border-l border-[var(--stroke-soft)] bg-transparent text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,title:r(`chat:chatPage.newChat`),"aria-label":r(`chat:chatPage.newChat`),onClick:()=>void n(),children:(0,Q.jsx)(ut,{size:20,"aria-hidden":`true`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,role:`tabpanel`,id:`mobile-session-tabpanel`,"aria-labelledby":p?`mobile-session-tab-${p}`:void 0,children:p?(0,Q.jsx)(Ec,{sessionId:p,panelId:``,shortcutEnabled:!0,canSplitPanel:!1,canClosePanel:!1}):(0,Q.jsx)(Dc,{onNewSession:n})})]})}function Ec({sessionId:e,panelId:t,shortcutEnabled:n,onFocusCapture:r,canSplitPanel:i,canClosePanel:a}){let o=(0,Z.useContext)(bc),s=o?.subscribeSessionState,c=o?.getSessionState,l=(0,Z.useMemo)(()=>t=>s?.(e,t)??(()=>{}),[s,e]),u=(0,Z.useMemo)(()=>()=>c?.(e),[c,e]),d=(0,Z.useSyncExternalStore)(l,u),f=o?.sessions.find(t=>t.id===e),p=d||mr,m=!!(p.streaming||f?.streaming),h=Sr(d,f),g=d&&Object.hasOwn(d,`team`)?d.team:f?.team??null,_=Cr(h,{streaming:m})?h:null,v=o?.sessionTreePulseSessionId===e?o.sessionTreePulseToken:0,y=o?.loadSessionMessages,b=o?.loadSessionThinkingLevel,x=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{e&&y?.(e,{limit:xc})},[y,e]),(0,Z.useEffect)(()=>{!e||!f||!b||m||p.thinkingStatus||(p.availableThinkingLevels||[]).length||x.current!==e&&(x.current=e,b(e))},[b,f,e,p.availableThinkingLevels,p.thinkingStatus,m]);let S=(0,Z.useMemo)(()=>({onLoadOlder:()=>o?.loadOlderMessages(e)??!1,onModelChange:t=>o?.switchSessionModel(e,t),onThinkingLevelChange:t=>o?.switchSessionThinkingLevel(e,t),onExecutionModeChange:t=>o?.switchSessionExecutionMode(e,t)??!1,onRunModeChange:t=>o?.switchSessionRunMode(e,t)??!1,onGoalPause:()=>o?.pauseGoal(e),onGoalBudgetChange:t=>o?.setGoalBudget(e,t),onCompact:()=>o?.compactSession(e),onApproval:(t,n)=>o?.resolveToolApproval(e,t,n),onWorkspace:()=>{f&&o?.selectSessionWorkspace(f)},onRename:()=>{f&&o?.renameSession(f)},onBranchFromHere:e=>{if(f)return o?.branchFromEntry(f,e)},onCreateChildSession:e=>{if(f)return o?.createChildSession(f,e)},onTreeNavigated:()=>o?.reloadSessionBranch(e),onSplitLeft:()=>o?.splitDockPanel(t,`left`),onSplitRight:()=>o?.splitDockPanel(t,`right`),onSplitTop:()=>o?.splitDockPanel(t,`above`),onSplitBottom:()=>o?.splitDockPanel(t,`below`),onClosePanel:()=>o?.closeDockPanel(t),onSend:(t,n,r,i,a,s)=>o?.sendPrompt(t,e,n,r,i,a,s),onQueue:(t,n,r)=>o?.queuePrompt(t,e,n,r)??!1,onAbort:()=>o?.abort(e)}),[o,e,f,t]);if(!o||!f)return(0,Q.jsxs)(`div`,{className:`session-dock-missing flex h-full min-h-[180px] items-center justify-center gap-[8px] text-[var(--text-secondary)] text-[12px]`,children:[(0,Q.jsx)(Xe,{size:16}),o?`Session unavailable`:`Loading session`]});let C=o.pendingAsset?.asset&&(!o.pendingAsset.targetSessionId||o.pendingAsset.targetSessionId===e)?o.pendingAsset.asset:null;return(0,Q.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:r,children:(0,Q.jsx)(yc,{session:f,shortcutEnabled:n,messages:p.messages||Sc,transcriptLoadState:p.loaded?`ready`:p.loading||!p.error?`loading`:`error`,messageStart:p.messageStart,hasOlder:p.hasOlder,loadingOlder:p.loadingOlder,olderError:p.olderError,model:p.model||f.model||o.defaultModel,thinkingLevel:p.thinkingLevel||f.thinkingLevel||`medium`,availableThinkingLevels:p.availableThinkingLevels||Sc,thinkingStatus:p.thinkingStatus||``,thinkingMessage:p.thinkingMessage||``,executionMode:p.executionMode||f.executionMode||`approval-required`,runMode:p.runMode||f.runMode||`plan`,goal:p.goal??f.goal??null,team:g,plan:_,currentActivity:p.currentActivity,activityFeed:p.activityFeed||Sc,tools:p.tools||Sc,thinkingText:p.thinkingText||``,queuedInputs:p.queuedInputs||Sc,compaction:p.compaction,contextUsage:p.contextUsage,sessionUsage:p.sessionUsage,sessionTreeRevision:p.sessionTreeRevision,sessionTreePulse:v,cwd:p.cwd||f.cwd,availableModels:o.availableModels,switchingModel:p.switchingModel,switchingThinking:p.switchingThinking,switchingCwd:p.switchingCwd,switchingPermission:p.switchingPermission,streaming:m,runStartedAt:p.runStartedAt,lastActivityAt:p.lastActivityAt,runFinishedAt:p.runFinishedAt,runStopped:p.runStopped,runNotice:p.runNotice,approvals:p.approvals||Sc,error:p.error||(o.activeId===e?o.globalError:``),pendingAsset:C,onAssetConsumed:o.onAssetConsumed,notify:o.notify,onOpenModelSettings:o.openModelSettings,onCompactionThresholdChange:o.setCompactionThreshold,canSplit:i,canClosePanel:a,...S})})}function Dc({onNewSession:e,newSessionShortcut:t}){let{t:n}=v();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-[180px] flex-col items-center justify-center gap-[8px] text-center text-[12px] text-[var(--text-secondary)]`,children:[(0,Q.jsx)(lt,{size:34}),(0,Q.jsx)(`strong`,{className:`text-[14px] text-[var(--text)]`,children:n(`chat:chatDock.openAChatToBegin`)}),(0,Q.jsx)(`span`,{className:`max-w-[320px] leading-[1.55]`,children:n(`chat:chatDock.openAChatFromTheSessionListOrSplitItInAnyDirection`)}),e?(0,Q.jsxs)(`button`,{type:`button`,className:`mt-[10px] inline-flex cursor-pointer items-center gap-[6px] rounded-[var(--r-sm)] border-0 bg-[var(--brand-blue)] px-[16px] py-[8px] text-[12px] font-[600] text-white transition-colors duration-[var(--d1)] hover:bg-[var(--brand-blue-hover)] focus-visible:outline-[2px] focus-visible:outline-offset-2 focus-visible:outline-[var(--focus)]`,onClick:()=>void e(),children:[(0,Q.jsx)(ut,{size:14,"aria-hidden":`true`}),n(`chat:chatDock.newChat`),t?(0,Q.jsx)(`kbd`,{className:`ml-[2px] rounded-[4px] border border-white/35 bg-white/10 px-[5px] py-[1px] font-sans text-[10px] font-[500] leading-[1.4]`,children:t}):null]}):null]})}var Oc=`web-preview`;function kc(e,t=`Web preview`){try{return new URL(e).hostname.replace(/^www\./i,``)||t}catch{return t}}export{cr as S,_r as _,Cc as a,dr as b,Qs as c,zi as d,Bi as f,vr as g,gr as h,Tc as i,Ja as l,mr as m,kc as n,bc as o,Vi as p,Dc as r,Zs as s,Oc as t,Ya as u,yr as v,sr as x,lr as y};