@surething/cockpit 1.0.243 → 1.0.244

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 (611) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +3 -2
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/routes-manifest.json +6 -0
  6. package/.next-prod/server/app/_global-error/page.js +3 -3
  7. package/.next-prod/server/app/_global-error/page.js.nft.json +1 -1
  8. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next-prod/server/app/_global-error.html +1 -1
  10. package/.next-prod/server/app/_global-error.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  14. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  15. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  16. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  17. package/.next-prod/server/app/_not-found/page.js +2 -2
  18. package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
  19. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/.next-prod/server/app/_not-found.html +2 -2
  21. package/.next-prod/server/app/_not-found.rsc +3 -3
  22. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
  23. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  24. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
  25. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  26. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  27. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  28. package/.next-prod/server/app/api/agent/test/route.js +1 -1
  29. package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
  30. package/.next-prod/server/app/api/bash/route.js +1 -1
  31. package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
  32. package/.next-prod/server/app/api/chat/codex/route.js +2 -2
  33. package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
  34. package/.next-prod/server/app/api/chat/deepseek/route.js +1 -1
  35. package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
  36. package/.next-prod/server/app/api/chat/kimi/route.js +2 -2
  37. package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
  38. package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
  39. package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
  40. package/.next-prod/server/app/api/chat/pty-input/route.js +1 -1
  41. package/.next-prod/server/app/api/chat/pty-input/route.js.nft.json +1 -1
  42. package/.next-prod/server/app/api/chat/route.js +1 -1
  43. package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
  44. package/.next-prod/server/app/api/chat/stop/route.js +1 -1
  45. package/.next-prod/server/app/api/chat/stop/route.js.nft.json +1 -1
  46. package/.next-prod/server/app/api/claude-stats/route.js +1 -1
  47. package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
  48. package/.next-prod/server/app/api/commands/route.js +1 -1
  49. package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
  50. package/.next-prod/server/app/api/comments/route.js +1 -1
  51. package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
  52. package/.next-prod/server/app/api/db/columns/route.js +1 -1
  53. package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
  54. package/.next-prod/server/app/api/db/connect/route.js +2 -2
  55. package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
  56. package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
  57. package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
  58. package/.next-prod/server/app/api/db/export/route.js +1 -1
  59. package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
  60. package/.next-prod/server/app/api/db/query/route.js +1 -1
  61. package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
  62. package/.next-prod/server/app/api/db/schemas/route.js +1 -1
  63. package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
  64. package/.next-prod/server/app/api/deepseek/credentials/route.js +1 -1
  65. package/.next-prod/server/app/api/deepseek/credentials/route.js.nft.json +1 -1
  66. package/.next-prod/server/app/api/dev/spans/route.js +1 -1
  67. package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
  68. package/.next-prod/server/app/api/extension/version/route.js +1 -1
  69. package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
  70. package/.next-prod/server/app/api/file/route.js +1 -1
  71. package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
  72. package/.next-prod/server/app/api/files/blame/route.js +1 -1
  73. package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
  74. package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
  75. package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
  76. package/.next-prod/server/app/api/files/copy/route.js +1 -1
  77. package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
  78. package/.next-prod/server/app/api/files/delete/route.js +1 -1
  79. package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
  80. package/.next-prod/server/app/api/files/expanded/route.js +1 -1
  81. package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
  82. package/.next-prod/server/app/api/files/index/route.js +1 -1
  83. package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
  84. package/.next-prod/server/app/api/files/init/route.js +1 -1
  85. package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
  86. package/.next-prod/server/app/api/files/paste/route.js +1 -1
  87. package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
  88. package/.next-prod/server/app/api/files/read/route.js +1 -1
  89. package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
  90. package/.next-prod/server/app/api/files/readdir/route.js +1 -1
  91. package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
  92. package/.next-prod/server/app/api/files/recent/route.js +1 -1
  93. package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
  94. package/.next-prod/server/app/api/files/save/route.js +1 -1
  95. package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
  96. package/.next-prod/server/app/api/files/search/route.js +1 -1
  97. package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
  98. package/.next-prod/server/app/api/files/stat/route.js +1 -1
  99. package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
  100. package/.next-prod/server/app/api/files/text/route.js +1 -1
  101. package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
  102. package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
  103. package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
  104. package/.next-prod/server/app/api/git/branches/route.js +1 -1
  105. package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
  106. package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
  107. package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
  108. package/.next-prod/server/app/api/git/commits/route.js +1 -1
  109. package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
  110. package/.next-prod/server/app/api/git/current-branch/route.js +1 -1
  111. package/.next-prod/server/app/api/git/current-branch/route.js.nft.json +1 -1
  112. package/.next-prod/server/app/api/git/diff/route.js +1 -1
  113. package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
  114. package/.next-prod/server/app/api/git/discard/route.js +1 -1
  115. package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
  116. package/.next-prod/server/app/api/git/stage/route.js +1 -1
  117. package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
  118. package/.next-prod/server/app/api/git/status/route.js +1 -1
  119. package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
  120. package/.next-prod/server/app/api/git/unstage/route.js +1 -1
  121. package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
  122. package/.next-prod/server/app/api/git/worktree/route.js +1 -1
  123. package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
  124. package/.next-prod/server/app/api/global-state/route.js +2 -2
  125. package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
  126. package/.next-prod/server/app/api/health/route.js +1 -1
  127. package/.next-prod/server/app/api/health/route.js.nft.json +1 -1
  128. package/.next-prod/server/app/api/jupyter/load/route.js +1 -1
  129. package/.next-prod/server/app/api/jupyter/load/route.js.nft.json +1 -1
  130. package/.next-prod/server/app/api/jupyter/save/route.js +1 -1
  131. package/.next-prod/server/app/api/jupyter/save/route.js.nft.json +1 -1
  132. package/.next-prod/server/app/api/jupyter/shutdown/route.js +1 -1
  133. package/.next-prod/server/app/api/jupyter/shutdown/route.js.nft.json +1 -1
  134. package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
  135. package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
  136. package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
  137. package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
  138. package/.next-prod/server/app/api/lsp/references/route.js +1 -1
  139. package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
  140. package/.next-prod/server/app/api/lsp/status/route.js +1 -1
  141. package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
  142. package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
  143. package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
  144. package/.next-prod/server/app/api/mysql/columns/route.js +1 -1
  145. package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
  146. package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
  147. package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
  148. package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
  149. package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
  150. package/.next-prod/server/app/api/mysql/export/route.js +1 -1
  151. package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
  152. package/.next-prod/server/app/api/mysql/query/route.js +1 -1
  153. package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
  154. package/.next-prod/server/app/api/mysql/schemas/route.js +2 -2
  155. package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
  156. package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
  157. package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
  158. package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
  159. package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
  160. package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
  161. package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
  162. package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
  163. package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
  164. package/.next-prod/server/app/api/note/route.js +1 -1
  165. package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
  166. package/.next-prod/server/app/api/ollama/config/route.js +1 -0
  167. package/.next-prod/server/app/api/ollama/config/route.js.nft.json +1 -0
  168. package/.next-prod/server/app/api/ollama/config/route_client-reference-manifest.js +1 -0
  169. package/.next-prod/server/app/api/ollama/models/route.js +1 -1
  170. package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
  171. package/.next-prod/server/app/api/ollama/start/route.js +1 -1
  172. package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
  173. package/.next-prod/server/app/api/open-cursor/route.js +1 -1
  174. package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
  175. package/.next-prod/server/app/api/open-vscode/route.js +1 -1
  176. package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
  177. package/.next-prod/server/app/api/pick-folder/route.js +1 -1
  178. package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
  179. package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
  180. package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
  181. package/.next-prod/server/app/api/preview/[...path]/route.js +1 -1
  182. package/.next-prod/server/app/api/preview/[...path]/route.js.nft.json +1 -1
  183. package/.next-prod/server/app/api/project-settings/route.js +1 -1
  184. package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
  185. package/.next-prod/server/app/api/project-state/route.js +2 -2
  186. package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
  187. package/.next-prod/server/app/api/projectGraph/affected/route.js +1 -1
  188. package/.next-prod/server/app/api/projectGraph/affected/route.js.nft.json +1 -1
  189. package/.next-prod/server/app/api/projectGraph/callees/route.js +1 -1
  190. package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -1
  191. package/.next-prod/server/app/api/projectGraph/callers/route.js +1 -1
  192. package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -1
  193. package/.next-prod/server/app/api/projectGraph/coedit/route.js +1 -1
  194. package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -1
  195. package/.next-prod/server/app/api/projectGraph/context/route.js +1 -1
  196. package/.next-prod/server/app/api/projectGraph/context/route.js.nft.json +1 -1
  197. package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
  198. package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
  199. package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
  200. package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
  201. package/.next-prod/server/app/api/projectGraph/impact/route.js +1 -1
  202. package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -1
  203. package/.next-prod/server/app/api/projectGraph/related/route.js +1 -1
  204. package/.next-prod/server/app/api/projectGraph/related/route.js.nft.json +1 -1
  205. package/.next-prod/server/app/api/projectGraph/risk/route.js +1 -1
  206. package/.next-prod/server/app/api/projectGraph/risk/route.js.nft.json +1 -1
  207. package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
  208. package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
  209. package/.next-prod/server/app/api/projects/route.js +1 -1
  210. package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
  211. package/.next-prod/server/app/api/push/public-key/route.js +1 -1
  212. package/.next-prod/server/app/api/push/public-key/route.js.nft.json +1 -1
  213. package/.next-prod/server/app/api/push/subscribe/route.js +1 -1
  214. package/.next-prod/server/app/api/push/subscribe/route.js.nft.json +1 -1
  215. package/.next-prod/server/app/api/push/unsubscribe/route.js +1 -1
  216. package/.next-prod/server/app/api/push/unsubscribe/route.js.nft.json +1 -1
  217. package/.next-prod/server/app/api/redis/command/route.js +1 -1
  218. package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
  219. package/.next-prod/server/app/api/redis/connect/route.js +1 -1
  220. package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
  221. package/.next-prod/server/app/api/redis/delete/route.js +1 -1
  222. package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
  223. package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
  224. package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
  225. package/.next-prod/server/app/api/redis/get/route.js +1 -1
  226. package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
  227. package/.next-prod/server/app/api/redis/keys/route.js +1 -1
  228. package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
  229. package/.next-prod/server/app/api/redis/set/route.js +1 -1
  230. package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
  231. package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
  232. package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
  233. package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
  234. package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
  235. package/.next-prod/server/app/api/review/[id]/route.js +1 -1
  236. package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
  237. package/.next-prod/server/app/api/review/identify/route.js +1 -1
  238. package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
  239. package/.next-prod/server/app/api/review/order/route.js +1 -1
  240. package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
  241. package/.next-prod/server/app/api/review/route.js +1 -1
  242. package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
  243. package/.next-prod/server/app/api/review/share-info/route.js +1 -1
  244. package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
  245. package/.next-prod/server/app/api/review/users/route.js +1 -1
  246. package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
  247. package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
  248. package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
  249. package/.next-prod/server/app/api/services/config/route.js +1 -1
  250. package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
  251. package/.next-prod/server/app/api/services/scripts/route.js +1 -1
  252. package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
  253. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
  254. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
  255. package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
  256. package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
  257. package/.next-prod/server/app/api/session-by-path/route.js +1 -1
  258. package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
  259. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
  260. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
  261. package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
  262. package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
  263. package/.next-prod/server/app/api/sessions/route.js +1 -1
  264. package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
  265. package/.next-prod/server/app/api/settings/route.js +1 -1
  266. package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
  267. package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
  268. package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
  269. package/.next-prod/server/app/api/skills/content/route.js +1 -1
  270. package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
  271. package/.next-prod/server/app/api/skills/route.js +1 -1
  272. package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
  273. package/.next-prod/server/app/api/snapshots/diff/route.js +1 -1
  274. package/.next-prod/server/app/api/snapshots/diff/route.js.nft.json +1 -1
  275. package/.next-prod/server/app/api/snapshots/route.js +1 -1
  276. package/.next-prod/server/app/api/snapshots/route.js.nft.json +1 -1
  277. package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
  278. package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
  279. package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
  280. package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
  281. package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
  282. package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
  283. package/.next-prod/server/app/api/terminal/env/route.js +1 -1
  284. package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
  285. package/.next-prod/server/app/api/terminal/history/route.js +1 -1
  286. package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
  287. package/.next-prod/server/app/api/version/route.js +1 -1
  288. package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
  289. package/.next-prod/server/app/favicon.ico/route.js +1 -1
  290. package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
  291. package/.next-prod/server/app/m/page.js +2 -2
  292. package/.next-prod/server/app/m/page.js.nft.json +1 -1
  293. package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
  294. package/.next-prod/server/app/manifest.webmanifest/route.js +2 -2
  295. package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  296. package/.next-prod/server/app/page.js +2 -2
  297. package/.next-prod/server/app/page.js.nft.json +1 -1
  298. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  299. package/.next-prod/server/app/project/page.js +2 -2
  300. package/.next-prod/server/app/project/page.js.nft.json +1 -1
  301. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  302. package/.next-prod/server/app/review/[id]/page.js +2 -2
  303. package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
  304. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  305. package/.next-prod/server/app-paths-manifest.json +3 -2
  306. package/.next-prod/server/chunks/2939.js +1 -1
  307. package/.next-prod/server/chunks/304.js +1 -1
  308. package/.next-prod/server/chunks/6038.js +1 -0
  309. package/.next-prod/server/chunks/7338.js +4 -4
  310. package/.next-prod/server/chunks/9658.js +4 -4
  311. package/.next-prod/server/chunks/9830.js +1 -1
  312. package/.next-prod/server/middleware-build-manifest.js +1 -1
  313. package/.next-prod/server/pages/404.html +2 -2
  314. package/.next-prod/server/pages/500.html +1 -1
  315. package/.next-prod/server/server-reference-manifest.json +1 -1
  316. package/.next-prod/static/chunks/1871-4468d75ec99d71fc.js +25 -0
  317. package/.next-prod/static/chunks/{6784-a155388d7e43ef3d.js → 6784-53d80dc3b480cf9a.js} +0 -0
  318. package/.next-prod/static/chunks/{9530-60801ba514d5c607.js → 9530-08419cb81f88a0e6.js} +1 -1
  319. package/.next-prod/static/chunks/app/_global-error/page-6d7aa508d9d8bcc3.js +1 -0
  320. package/.next-prod/static/chunks/app/api/agent/test/route-6d7aa508d9d8bcc3.js +1 -0
  321. package/.next-prod/static/chunks/app/api/bash/route-6d7aa508d9d8bcc3.js +1 -0
  322. package/.next-prod/static/chunks/app/api/chat/codex/route-6d7aa508d9d8bcc3.js +1 -0
  323. package/.next-prod/static/chunks/app/api/chat/deepseek/route-6d7aa508d9d8bcc3.js +1 -0
  324. package/.next-prod/static/chunks/app/api/chat/kimi/route-6d7aa508d9d8bcc3.js +1 -0
  325. package/.next-prod/static/chunks/app/api/chat/ollama/route-6d7aa508d9d8bcc3.js +1 -0
  326. package/.next-prod/static/chunks/app/api/chat/pty-input/route-6d7aa508d9d8bcc3.js +1 -0
  327. package/.next-prod/static/chunks/app/api/chat/route-6d7aa508d9d8bcc3.js +1 -0
  328. package/.next-prod/static/chunks/app/api/chat/stop/route-6d7aa508d9d8bcc3.js +1 -0
  329. package/.next-prod/static/chunks/app/api/claude-stats/route-6d7aa508d9d8bcc3.js +1 -0
  330. package/.next-prod/static/chunks/app/api/commands/route-6d7aa508d9d8bcc3.js +1 -0
  331. package/.next-prod/static/chunks/app/api/comments/route-6d7aa508d9d8bcc3.js +1 -0
  332. package/.next-prod/static/chunks/app/api/db/columns/route-6d7aa508d9d8bcc3.js +1 -0
  333. package/.next-prod/static/chunks/app/api/db/connect/route-6d7aa508d9d8bcc3.js +1 -0
  334. package/.next-prod/static/chunks/app/api/db/disconnect/route-6d7aa508d9d8bcc3.js +1 -0
  335. package/.next-prod/static/chunks/app/api/db/export/route-6d7aa508d9d8bcc3.js +1 -0
  336. package/.next-prod/static/chunks/app/api/db/query/route-6d7aa508d9d8bcc3.js +1 -0
  337. package/.next-prod/static/chunks/app/api/db/schemas/route-6d7aa508d9d8bcc3.js +1 -0
  338. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-6d7aa508d9d8bcc3.js +1 -0
  339. package/.next-prod/static/chunks/app/api/dev/spans/route-6d7aa508d9d8bcc3.js +1 -0
  340. package/.next-prod/static/chunks/app/api/extension/version/route-6d7aa508d9d8bcc3.js +1 -0
  341. package/.next-prod/static/chunks/app/api/file/route-6d7aa508d9d8bcc3.js +1 -0
  342. package/.next-prod/static/chunks/app/api/files/blame/route-6d7aa508d9d8bcc3.js +1 -0
  343. package/.next-prod/static/chunks/app/api/files/clipboard/route-6d7aa508d9d8bcc3.js +1 -0
  344. package/.next-prod/static/chunks/app/api/files/copy/route-6d7aa508d9d8bcc3.js +1 -0
  345. package/.next-prod/static/chunks/app/api/files/delete/route-6d7aa508d9d8bcc3.js +1 -0
  346. package/.next-prod/static/chunks/app/api/files/expanded/route-6d7aa508d9d8bcc3.js +1 -0
  347. package/.next-prod/static/chunks/app/api/files/index/route-6d7aa508d9d8bcc3.js +1 -0
  348. package/.next-prod/static/chunks/app/api/files/init/route-6d7aa508d9d8bcc3.js +1 -0
  349. package/.next-prod/static/chunks/app/api/files/paste/route-6d7aa508d9d8bcc3.js +1 -0
  350. package/.next-prod/static/chunks/app/api/files/read/route-6d7aa508d9d8bcc3.js +1 -0
  351. package/.next-prod/static/chunks/app/api/files/readdir/route-6d7aa508d9d8bcc3.js +1 -0
  352. package/.next-prod/static/chunks/app/api/files/recent/route-6d7aa508d9d8bcc3.js +1 -0
  353. package/.next-prod/static/chunks/app/api/files/save/route-6d7aa508d9d8bcc3.js +1 -0
  354. package/.next-prod/static/chunks/app/api/files/search/route-6d7aa508d9d8bcc3.js +1 -0
  355. package/.next-prod/static/chunks/app/api/files/stat/route-6d7aa508d9d8bcc3.js +1 -0
  356. package/.next-prod/static/chunks/app/api/files/text/route-6d7aa508d9d8bcc3.js +1 -0
  357. package/.next-prod/static/chunks/app/api/git/branch-diff/route-6d7aa508d9d8bcc3.js +1 -0
  358. package/.next-prod/static/chunks/app/api/git/branches/route-6d7aa508d9d8bcc3.js +1 -0
  359. package/.next-prod/static/chunks/app/api/git/commit-diff/route-6d7aa508d9d8bcc3.js +1 -0
  360. package/.next-prod/static/chunks/app/api/git/commits/route-6d7aa508d9d8bcc3.js +1 -0
  361. package/.next-prod/static/chunks/app/api/git/current-branch/route-6d7aa508d9d8bcc3.js +1 -0
  362. package/.next-prod/static/chunks/app/api/git/diff/route-6d7aa508d9d8bcc3.js +1 -0
  363. package/.next-prod/static/chunks/app/api/git/discard/route-6d7aa508d9d8bcc3.js +1 -0
  364. package/.next-prod/static/chunks/app/api/git/stage/route-6d7aa508d9d8bcc3.js +1 -0
  365. package/.next-prod/static/chunks/app/api/git/status/route-6d7aa508d9d8bcc3.js +1 -0
  366. package/.next-prod/static/chunks/app/api/git/unstage/route-6d7aa508d9d8bcc3.js +1 -0
  367. package/.next-prod/static/chunks/app/api/git/worktree/route-6d7aa508d9d8bcc3.js +1 -0
  368. package/.next-prod/static/chunks/app/api/global-state/route-6d7aa508d9d8bcc3.js +1 -0
  369. package/.next-prod/static/chunks/app/api/health/route-6d7aa508d9d8bcc3.js +1 -0
  370. package/.next-prod/static/chunks/app/api/jupyter/load/route-6d7aa508d9d8bcc3.js +1 -0
  371. package/.next-prod/static/chunks/app/api/jupyter/save/route-6d7aa508d9d8bcc3.js +1 -0
  372. package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-6d7aa508d9d8bcc3.js +1 -0
  373. package/.next-prod/static/chunks/app/api/lsp/definition/route-6d7aa508d9d8bcc3.js +1 -0
  374. package/.next-prod/static/chunks/app/api/lsp/hover/route-6d7aa508d9d8bcc3.js +1 -0
  375. package/.next-prod/static/chunks/app/api/lsp/references/route-6d7aa508d9d8bcc3.js +1 -0
  376. package/.next-prod/static/chunks/app/api/lsp/status/route-6d7aa508d9d8bcc3.js +1 -0
  377. package/.next-prod/static/chunks/app/api/lsp/warmup/route-6d7aa508d9d8bcc3.js +1 -0
  378. package/.next-prod/static/chunks/app/api/mysql/columns/route-6d7aa508d9d8bcc3.js +1 -0
  379. package/.next-prod/static/chunks/app/api/mysql/connect/route-6d7aa508d9d8bcc3.js +1 -0
  380. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-6d7aa508d9d8bcc3.js +1 -0
  381. package/.next-prod/static/chunks/app/api/mysql/export/route-6d7aa508d9d8bcc3.js +1 -0
  382. package/.next-prod/static/chunks/app/api/mysql/query/route-6d7aa508d9d8bcc3.js +1 -0
  383. package/.next-prod/static/chunks/app/api/mysql/schemas/route-6d7aa508d9d8bcc3.js +1 -0
  384. package/.next-prod/static/chunks/app/api/neo4j/connect/route-6d7aa508d9d8bcc3.js +1 -0
  385. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-6d7aa508d9d8bcc3.js +1 -0
  386. package/.next-prod/static/chunks/app/api/neo4j/query/route-6d7aa508d9d8bcc3.js +1 -0
  387. package/.next-prod/static/chunks/app/api/neo4j/schema/route-6d7aa508d9d8bcc3.js +1 -0
  388. package/.next-prod/static/chunks/app/api/note/route-6d7aa508d9d8bcc3.js +1 -0
  389. package/.next-prod/static/chunks/app/api/ollama/config/route-6d7aa508d9d8bcc3.js +1 -0
  390. package/.next-prod/static/chunks/app/api/ollama/models/route-6d7aa508d9d8bcc3.js +1 -0
  391. package/.next-prod/static/chunks/app/api/ollama/start/route-6d7aa508d9d8bcc3.js +1 -0
  392. package/.next-prod/static/chunks/app/api/open-cursor/route-6d7aa508d9d8bcc3.js +1 -0
  393. package/.next-prod/static/chunks/app/api/open-vscode/route-6d7aa508d9d8bcc3.js +1 -0
  394. package/.next-prod/static/chunks/app/api/pick-folder/route-6d7aa508d9d8bcc3.js +1 -0
  395. package/.next-prod/static/chunks/app/api/pinned-sessions/route-6d7aa508d9d8bcc3.js +1 -0
  396. package/.next-prod/static/chunks/app/api/preview/[...path]/route-6d7aa508d9d8bcc3.js +1 -0
  397. package/.next-prod/static/chunks/app/api/project-settings/route-6d7aa508d9d8bcc3.js +1 -0
  398. package/.next-prod/static/chunks/app/api/project-state/route-6d7aa508d9d8bcc3.js +1 -0
  399. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-6d7aa508d9d8bcc3.js +1 -0
  400. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-6d7aa508d9d8bcc3.js +1 -0
  401. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-6d7aa508d9d8bcc3.js +1 -0
  402. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-6d7aa508d9d8bcc3.js +1 -0
  403. package/.next-prod/static/chunks/app/api/projectGraph/context/route-6d7aa508d9d8bcc3.js +1 -0
  404. package/.next-prod/static/chunks/app/api/projectGraph/file/route-6d7aa508d9d8bcc3.js +1 -0
  405. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-6d7aa508d9d8bcc3.js +1 -0
  406. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-6d7aa508d9d8bcc3.js +1 -0
  407. package/.next-prod/static/chunks/app/api/projectGraph/related/route-6d7aa508d9d8bcc3.js +1 -0
  408. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-6d7aa508d9d8bcc3.js +1 -0
  409. package/.next-prod/static/chunks/app/api/projectGraph/search/route-6d7aa508d9d8bcc3.js +1 -0
  410. package/.next-prod/static/chunks/app/api/projects/route-6d7aa508d9d8bcc3.js +1 -0
  411. package/.next-prod/static/chunks/app/api/push/public-key/route-6d7aa508d9d8bcc3.js +1 -0
  412. package/.next-prod/static/chunks/app/api/push/subscribe/route-6d7aa508d9d8bcc3.js +1 -0
  413. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-6d7aa508d9d8bcc3.js +1 -0
  414. package/.next-prod/static/chunks/app/api/redis/command/route-6d7aa508d9d8bcc3.js +1 -0
  415. package/.next-prod/static/chunks/app/api/redis/connect/route-6d7aa508d9d8bcc3.js +1 -0
  416. package/.next-prod/static/chunks/app/api/redis/delete/route-6d7aa508d9d8bcc3.js +1 -0
  417. package/.next-prod/static/chunks/app/api/redis/disconnect/route-6d7aa508d9d8bcc3.js +1 -0
  418. package/.next-prod/static/chunks/app/api/redis/get/route-6d7aa508d9d8bcc3.js +1 -0
  419. package/.next-prod/static/chunks/app/api/redis/keys/route-6d7aa508d9d8bcc3.js +1 -0
  420. package/.next-prod/static/chunks/app/api/redis/set/route-6d7aa508d9d8bcc3.js +1 -0
  421. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-6d7aa508d9d8bcc3.js +1 -0
  422. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-6d7aa508d9d8bcc3.js +1 -0
  423. package/.next-prod/static/chunks/app/api/review/[id]/route-6d7aa508d9d8bcc3.js +1 -0
  424. package/.next-prod/static/chunks/app/api/review/identify/route-6d7aa508d9d8bcc3.js +1 -0
  425. package/.next-prod/static/chunks/app/api/review/order/route-6d7aa508d9d8bcc3.js +1 -0
  426. package/.next-prod/static/chunks/app/api/review/route-6d7aa508d9d8bcc3.js +1 -0
  427. package/.next-prod/static/chunks/app/api/review/share-info/route-6d7aa508d9d8bcc3.js +1 -0
  428. package/.next-prod/static/chunks/app/api/review/users/route-6d7aa508d9d8bcc3.js +1 -0
  429. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-6d7aa508d9d8bcc3.js +1 -0
  430. package/.next-prod/static/chunks/app/api/services/config/route-6d7aa508d9d8bcc3.js +1 -0
  431. package/.next-prod/static/chunks/app/api/services/scripts/route-6d7aa508d9d8bcc3.js +1 -0
  432. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-6d7aa508d9d8bcc3.js +1 -0
  433. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-6d7aa508d9d8bcc3.js +1 -0
  434. package/.next-prod/static/chunks/app/api/session-by-path/route-6d7aa508d9d8bcc3.js +1 -0
  435. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-6d7aa508d9d8bcc3.js +1 -0
  436. package/.next-prod/static/chunks/app/api/sessions/projects/route-6d7aa508d9d8bcc3.js +1 -0
  437. package/.next-prod/static/chunks/app/api/sessions/route-6d7aa508d9d8bcc3.js +1 -0
  438. package/.next-prod/static/chunks/app/api/settings/route-6d7aa508d9d8bcc3.js +1 -0
  439. package/.next-prod/static/chunks/app/api/skills/[id]/route-6d7aa508d9d8bcc3.js +1 -0
  440. package/.next-prod/static/chunks/app/api/skills/content/route-6d7aa508d9d8bcc3.js +1 -0
  441. package/.next-prod/static/chunks/app/api/skills/route-6d7aa508d9d8bcc3.js +1 -0
  442. package/.next-prod/static/chunks/app/api/snapshots/diff/route-6d7aa508d9d8bcc3.js +1 -0
  443. package/.next-prod/static/chunks/app/api/snapshots/route-6d7aa508d9d8bcc3.js +1 -0
  444. package/.next-prod/static/chunks/app/api/terminal/aliases/route-6d7aa508d9d8bcc3.js +1 -0
  445. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-6d7aa508d9d8bcc3.js +1 -0
  446. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-6d7aa508d9d8bcc3.js +1 -0
  447. package/.next-prod/static/chunks/app/api/terminal/env/route-6d7aa508d9d8bcc3.js +1 -0
  448. package/.next-prod/static/chunks/app/api/terminal/history/route-6d7aa508d9d8bcc3.js +1 -0
  449. package/.next-prod/static/chunks/app/api/version/route-6d7aa508d9d8bcc3.js +1 -0
  450. package/.next-prod/static/chunks/app/manifest.webmanifest/route-6d7aa508d9d8bcc3.js +1 -0
  451. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-6d7aa508d9d8bcc3.js +1 -0
  452. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-6d7aa508d9d8bcc3.js +1 -0
  453. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-6d7aa508d9d8bcc3.js +1 -0
  454. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-6d7aa508d9d8bcc3.js +1 -0
  455. package/.next-prod/static/css/1d52d90207f3b441.css +1 -0
  456. package/.next-prod/static/sMb_F5kg6en8USwL7FYkb/_buildManifest.js +1 -0
  457. package/.next-prod/trace +13 -13
  458. package/.next-prod/trace-build +1 -1
  459. package/.next-prod/types/app/api/ollama/config/route.ts +351 -0
  460. package/.next-prod/types/routes.d.ts +2 -1
  461. package/.next-prod/types/validator.ts +9 -0
  462. package/dist/{chunk-4S76JXBU.mjs → chunk-3X4GQZL4.mjs} +1 -1
  463. package/dist/{chunk-NW4I3U26.mjs → chunk-BFESJMNO.mjs} +158 -17
  464. package/dist/{chunk-V2ZASC2X.mjs → chunk-FMJUH423.mjs} +1 -1
  465. package/dist/httpApi.mjs +2 -2
  466. package/dist/scheduledTasks.mjs +4 -3
  467. package/dist/{server-YK62AFE6.mjs → server-HKW65PHP.mjs} +2 -2
  468. package/dist/wsServer.mjs +4 -4
  469. package/package.json +1 -1
  470. package/.next-prod/server/chunks/6955.js +0 -1
  471. package/.next-prod/server/chunks/8916.js +0 -1
  472. package/.next-prod/server/chunks/9989.js +0 -1
  473. package/.next-prod/static/chunks/1871-560f59face6cdf95.js +0 -25
  474. package/.next-prod/static/chunks/app/_global-error/page-382e54b2d4e69c9e.js +0 -1
  475. package/.next-prod/static/chunks/app/api/agent/test/route-382e54b2d4e69c9e.js +0 -1
  476. package/.next-prod/static/chunks/app/api/bash/route-382e54b2d4e69c9e.js +0 -1
  477. package/.next-prod/static/chunks/app/api/chat/codex/route-382e54b2d4e69c9e.js +0 -1
  478. package/.next-prod/static/chunks/app/api/chat/deepseek/route-382e54b2d4e69c9e.js +0 -1
  479. package/.next-prod/static/chunks/app/api/chat/kimi/route-382e54b2d4e69c9e.js +0 -1
  480. package/.next-prod/static/chunks/app/api/chat/ollama/route-382e54b2d4e69c9e.js +0 -1
  481. package/.next-prod/static/chunks/app/api/chat/pty-input/route-382e54b2d4e69c9e.js +0 -1
  482. package/.next-prod/static/chunks/app/api/chat/route-382e54b2d4e69c9e.js +0 -1
  483. package/.next-prod/static/chunks/app/api/chat/stop/route-382e54b2d4e69c9e.js +0 -1
  484. package/.next-prod/static/chunks/app/api/claude-stats/route-382e54b2d4e69c9e.js +0 -1
  485. package/.next-prod/static/chunks/app/api/commands/route-382e54b2d4e69c9e.js +0 -1
  486. package/.next-prod/static/chunks/app/api/comments/route-382e54b2d4e69c9e.js +0 -1
  487. package/.next-prod/static/chunks/app/api/db/columns/route-382e54b2d4e69c9e.js +0 -1
  488. package/.next-prod/static/chunks/app/api/db/connect/route-382e54b2d4e69c9e.js +0 -1
  489. package/.next-prod/static/chunks/app/api/db/disconnect/route-382e54b2d4e69c9e.js +0 -1
  490. package/.next-prod/static/chunks/app/api/db/export/route-382e54b2d4e69c9e.js +0 -1
  491. package/.next-prod/static/chunks/app/api/db/query/route-382e54b2d4e69c9e.js +0 -1
  492. package/.next-prod/static/chunks/app/api/db/schemas/route-382e54b2d4e69c9e.js +0 -1
  493. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-382e54b2d4e69c9e.js +0 -1
  494. package/.next-prod/static/chunks/app/api/dev/spans/route-382e54b2d4e69c9e.js +0 -1
  495. package/.next-prod/static/chunks/app/api/extension/version/route-382e54b2d4e69c9e.js +0 -1
  496. package/.next-prod/static/chunks/app/api/file/route-382e54b2d4e69c9e.js +0 -1
  497. package/.next-prod/static/chunks/app/api/files/blame/route-382e54b2d4e69c9e.js +0 -1
  498. package/.next-prod/static/chunks/app/api/files/clipboard/route-382e54b2d4e69c9e.js +0 -1
  499. package/.next-prod/static/chunks/app/api/files/copy/route-382e54b2d4e69c9e.js +0 -1
  500. package/.next-prod/static/chunks/app/api/files/delete/route-382e54b2d4e69c9e.js +0 -1
  501. package/.next-prod/static/chunks/app/api/files/expanded/route-382e54b2d4e69c9e.js +0 -1
  502. package/.next-prod/static/chunks/app/api/files/index/route-382e54b2d4e69c9e.js +0 -1
  503. package/.next-prod/static/chunks/app/api/files/init/route-382e54b2d4e69c9e.js +0 -1
  504. package/.next-prod/static/chunks/app/api/files/paste/route-382e54b2d4e69c9e.js +0 -1
  505. package/.next-prod/static/chunks/app/api/files/read/route-382e54b2d4e69c9e.js +0 -1
  506. package/.next-prod/static/chunks/app/api/files/readdir/route-382e54b2d4e69c9e.js +0 -1
  507. package/.next-prod/static/chunks/app/api/files/recent/route-382e54b2d4e69c9e.js +0 -1
  508. package/.next-prod/static/chunks/app/api/files/save/route-382e54b2d4e69c9e.js +0 -1
  509. package/.next-prod/static/chunks/app/api/files/search/route-382e54b2d4e69c9e.js +0 -1
  510. package/.next-prod/static/chunks/app/api/files/stat/route-382e54b2d4e69c9e.js +0 -1
  511. package/.next-prod/static/chunks/app/api/files/text/route-382e54b2d4e69c9e.js +0 -1
  512. package/.next-prod/static/chunks/app/api/git/branch-diff/route-382e54b2d4e69c9e.js +0 -1
  513. package/.next-prod/static/chunks/app/api/git/branches/route-382e54b2d4e69c9e.js +0 -1
  514. package/.next-prod/static/chunks/app/api/git/commit-diff/route-382e54b2d4e69c9e.js +0 -1
  515. package/.next-prod/static/chunks/app/api/git/commits/route-382e54b2d4e69c9e.js +0 -1
  516. package/.next-prod/static/chunks/app/api/git/current-branch/route-382e54b2d4e69c9e.js +0 -1
  517. package/.next-prod/static/chunks/app/api/git/diff/route-382e54b2d4e69c9e.js +0 -1
  518. package/.next-prod/static/chunks/app/api/git/discard/route-382e54b2d4e69c9e.js +0 -1
  519. package/.next-prod/static/chunks/app/api/git/stage/route-382e54b2d4e69c9e.js +0 -1
  520. package/.next-prod/static/chunks/app/api/git/status/route-382e54b2d4e69c9e.js +0 -1
  521. package/.next-prod/static/chunks/app/api/git/unstage/route-382e54b2d4e69c9e.js +0 -1
  522. package/.next-prod/static/chunks/app/api/git/worktree/route-382e54b2d4e69c9e.js +0 -1
  523. package/.next-prod/static/chunks/app/api/global-state/route-382e54b2d4e69c9e.js +0 -1
  524. package/.next-prod/static/chunks/app/api/health/route-382e54b2d4e69c9e.js +0 -1
  525. package/.next-prod/static/chunks/app/api/jupyter/load/route-382e54b2d4e69c9e.js +0 -1
  526. package/.next-prod/static/chunks/app/api/jupyter/save/route-382e54b2d4e69c9e.js +0 -1
  527. package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-382e54b2d4e69c9e.js +0 -1
  528. package/.next-prod/static/chunks/app/api/lsp/definition/route-382e54b2d4e69c9e.js +0 -1
  529. package/.next-prod/static/chunks/app/api/lsp/hover/route-382e54b2d4e69c9e.js +0 -1
  530. package/.next-prod/static/chunks/app/api/lsp/references/route-382e54b2d4e69c9e.js +0 -1
  531. package/.next-prod/static/chunks/app/api/lsp/status/route-382e54b2d4e69c9e.js +0 -1
  532. package/.next-prod/static/chunks/app/api/lsp/warmup/route-382e54b2d4e69c9e.js +0 -1
  533. package/.next-prod/static/chunks/app/api/mysql/columns/route-382e54b2d4e69c9e.js +0 -1
  534. package/.next-prod/static/chunks/app/api/mysql/connect/route-382e54b2d4e69c9e.js +0 -1
  535. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-382e54b2d4e69c9e.js +0 -1
  536. package/.next-prod/static/chunks/app/api/mysql/export/route-382e54b2d4e69c9e.js +0 -1
  537. package/.next-prod/static/chunks/app/api/mysql/query/route-382e54b2d4e69c9e.js +0 -1
  538. package/.next-prod/static/chunks/app/api/mysql/schemas/route-382e54b2d4e69c9e.js +0 -1
  539. package/.next-prod/static/chunks/app/api/neo4j/connect/route-382e54b2d4e69c9e.js +0 -1
  540. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-382e54b2d4e69c9e.js +0 -1
  541. package/.next-prod/static/chunks/app/api/neo4j/query/route-382e54b2d4e69c9e.js +0 -1
  542. package/.next-prod/static/chunks/app/api/neo4j/schema/route-382e54b2d4e69c9e.js +0 -1
  543. package/.next-prod/static/chunks/app/api/note/route-382e54b2d4e69c9e.js +0 -1
  544. package/.next-prod/static/chunks/app/api/ollama/models/route-382e54b2d4e69c9e.js +0 -1
  545. package/.next-prod/static/chunks/app/api/ollama/start/route-382e54b2d4e69c9e.js +0 -1
  546. package/.next-prod/static/chunks/app/api/open-cursor/route-382e54b2d4e69c9e.js +0 -1
  547. package/.next-prod/static/chunks/app/api/open-vscode/route-382e54b2d4e69c9e.js +0 -1
  548. package/.next-prod/static/chunks/app/api/pick-folder/route-382e54b2d4e69c9e.js +0 -1
  549. package/.next-prod/static/chunks/app/api/pinned-sessions/route-382e54b2d4e69c9e.js +0 -1
  550. package/.next-prod/static/chunks/app/api/preview/[...path]/route-382e54b2d4e69c9e.js +0 -1
  551. package/.next-prod/static/chunks/app/api/project-settings/route-382e54b2d4e69c9e.js +0 -1
  552. package/.next-prod/static/chunks/app/api/project-state/route-382e54b2d4e69c9e.js +0 -1
  553. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-382e54b2d4e69c9e.js +0 -1
  554. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-382e54b2d4e69c9e.js +0 -1
  555. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-382e54b2d4e69c9e.js +0 -1
  556. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-382e54b2d4e69c9e.js +0 -1
  557. package/.next-prod/static/chunks/app/api/projectGraph/context/route-382e54b2d4e69c9e.js +0 -1
  558. package/.next-prod/static/chunks/app/api/projectGraph/file/route-382e54b2d4e69c9e.js +0 -1
  559. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-382e54b2d4e69c9e.js +0 -1
  560. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-382e54b2d4e69c9e.js +0 -1
  561. package/.next-prod/static/chunks/app/api/projectGraph/related/route-382e54b2d4e69c9e.js +0 -1
  562. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-382e54b2d4e69c9e.js +0 -1
  563. package/.next-prod/static/chunks/app/api/projectGraph/search/route-382e54b2d4e69c9e.js +0 -1
  564. package/.next-prod/static/chunks/app/api/projects/route-382e54b2d4e69c9e.js +0 -1
  565. package/.next-prod/static/chunks/app/api/push/public-key/route-382e54b2d4e69c9e.js +0 -1
  566. package/.next-prod/static/chunks/app/api/push/subscribe/route-382e54b2d4e69c9e.js +0 -1
  567. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-382e54b2d4e69c9e.js +0 -1
  568. package/.next-prod/static/chunks/app/api/redis/command/route-382e54b2d4e69c9e.js +0 -1
  569. package/.next-prod/static/chunks/app/api/redis/connect/route-382e54b2d4e69c9e.js +0 -1
  570. package/.next-prod/static/chunks/app/api/redis/delete/route-382e54b2d4e69c9e.js +0 -1
  571. package/.next-prod/static/chunks/app/api/redis/disconnect/route-382e54b2d4e69c9e.js +0 -1
  572. package/.next-prod/static/chunks/app/api/redis/get/route-382e54b2d4e69c9e.js +0 -1
  573. package/.next-prod/static/chunks/app/api/redis/keys/route-382e54b2d4e69c9e.js +0 -1
  574. package/.next-prod/static/chunks/app/api/redis/set/route-382e54b2d4e69c9e.js +0 -1
  575. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-382e54b2d4e69c9e.js +0 -1
  576. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-382e54b2d4e69c9e.js +0 -1
  577. package/.next-prod/static/chunks/app/api/review/[id]/route-382e54b2d4e69c9e.js +0 -1
  578. package/.next-prod/static/chunks/app/api/review/identify/route-382e54b2d4e69c9e.js +0 -1
  579. package/.next-prod/static/chunks/app/api/review/order/route-382e54b2d4e69c9e.js +0 -1
  580. package/.next-prod/static/chunks/app/api/review/route-382e54b2d4e69c9e.js +0 -1
  581. package/.next-prod/static/chunks/app/api/review/share-info/route-382e54b2d4e69c9e.js +0 -1
  582. package/.next-prod/static/chunks/app/api/review/users/route-382e54b2d4e69c9e.js +0 -1
  583. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-382e54b2d4e69c9e.js +0 -1
  584. package/.next-prod/static/chunks/app/api/services/config/route-382e54b2d4e69c9e.js +0 -1
  585. package/.next-prod/static/chunks/app/api/services/scripts/route-382e54b2d4e69c9e.js +0 -1
  586. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-382e54b2d4e69c9e.js +0 -1
  587. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-382e54b2d4e69c9e.js +0 -1
  588. package/.next-prod/static/chunks/app/api/session-by-path/route-382e54b2d4e69c9e.js +0 -1
  589. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-382e54b2d4e69c9e.js +0 -1
  590. package/.next-prod/static/chunks/app/api/sessions/projects/route-382e54b2d4e69c9e.js +0 -1
  591. package/.next-prod/static/chunks/app/api/sessions/route-382e54b2d4e69c9e.js +0 -1
  592. package/.next-prod/static/chunks/app/api/settings/route-382e54b2d4e69c9e.js +0 -1
  593. package/.next-prod/static/chunks/app/api/skills/[id]/route-382e54b2d4e69c9e.js +0 -1
  594. package/.next-prod/static/chunks/app/api/skills/content/route-382e54b2d4e69c9e.js +0 -1
  595. package/.next-prod/static/chunks/app/api/skills/route-382e54b2d4e69c9e.js +0 -1
  596. package/.next-prod/static/chunks/app/api/snapshots/diff/route-382e54b2d4e69c9e.js +0 -1
  597. package/.next-prod/static/chunks/app/api/snapshots/route-382e54b2d4e69c9e.js +0 -1
  598. package/.next-prod/static/chunks/app/api/terminal/aliases/route-382e54b2d4e69c9e.js +0 -1
  599. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-382e54b2d4e69c9e.js +0 -1
  600. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-382e54b2d4e69c9e.js +0 -1
  601. package/.next-prod/static/chunks/app/api/terminal/env/route-382e54b2d4e69c9e.js +0 -1
  602. package/.next-prod/static/chunks/app/api/terminal/history/route-382e54b2d4e69c9e.js +0 -1
  603. package/.next-prod/static/chunks/app/api/version/route-382e54b2d4e69c9e.js +0 -1
  604. package/.next-prod/static/chunks/app/manifest.webmanifest/route-382e54b2d4e69c9e.js +0 -1
  605. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-382e54b2d4e69c9e.js +0 -1
  606. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-382e54b2d4e69c9e.js +0 -1
  607. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-382e54b2d4e69c9e.js +0 -1
  608. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-382e54b2d4e69c9e.js +0 -1
  609. package/.next-prod/static/css/9f26a08be661160a.css +0 -1
  610. package/.next-prod/static/uVjxkHKsDvtbJB0cgsKxl/_buildManifest.js +0 -1
  611. /package/.next-prod/static/{uVjxkHKsDvtbJB0cgsKxl → sMb_F5kg6en8USwL7FYkb}/_ssgManifest.js +0 -0
@@ -12,4 +12,4 @@
12
12
  `:"")+(e.status?`<status>${e.status}</status>
13
13
  `:"")+(e.summary?`<summary>${e.summary}</summary>
14
14
  `:"")+(e.output_file?`<output-file>${e.output_file}</output-file>
15
- `:"")+"</task-notification>";t(t=>[...t,{id:n,role:"system",content:e.summary||"",systemEvent:{kind:"task-notification",...e.status?{status:e.status}:{},detail:r}}])}return}if("user"===e.type&&e._human){let n=e.message?.content,r="string"==typeof n?n:Array.isArray(n)?n.map(e=>e?.text||"").join(""):"",s="string"==typeof e._turnId?e._turnId:null,l="number"==typeof e._ts?e._ts:null,a=s?`live-user-${s}`:`live-user-${++c.current}`;t(e=>{if(s&&e.some(e=>e.id===a))return e;for(let t=e.length-1;t>=0;t--){if("user"!==e[t].role)continue;let n=e[t].timestamp?Date.parse(e[t].timestamp):NaN;if(null===l||Number.isNaN(n)){if(e[t].content===r)return e}else if(n>=l)return e;break}return[...e,{id:a,role:"user",content:r}]});return}"result"===e.type&&(d.current=!1);let n=i.current??u();t(t=>(0,l.F)(t,e,{engine:a,assistantId:n}))};(0,s.h)({url:e?`/ws/session-stream?sessionId=${encodeURIComponent(e)}`:"/ws/session-stream",enabled:n&&!!e,onMessage:e=>{if("run-snapshot"===e.type&&Array.isArray(e.events)){if("running"!==e.status)return void o?.onRunningChange?.(!1);let n=e.events.find(e=>e?.type==="user"&&e?._human),r=n?.message?.content,s="string"==typeof r?r:"",l=new Set,a=new Set;for(let t of e.events){let e=t?.uuid;if("string"==typeof e&&l.add(e),t?.type==="assistant"&&Array.isArray(t.message?.content))for(let e of t.message.content)e?.name&&"string"==typeof e.id&&a.add(e.id)}let u="number"==typeof e.startedAt?e.startedAt:null;for(let n of(t(e=>{let t=e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("live-"))),n=t[t.length-1],r=n?.timestamp?Date.parse(n.timestamp):NaN;if(null!==u&&!Number.isNaN(r)){let e=t.length;for(;e>0;){let n=t[e-1],r=n.timestamp?Date.parse(n.timestamp):NaN;if(!Number.isNaN(r)&&r>=u)e--;else break}return e<t.length?t.slice(0,e):t}if(!s)return t;let o=-1;for(let e=t.length-1;e>=0;e--)if("user"===t[e].role){t[e].content===s&&(o=e);break}return -1===o?t:t.slice(o+1).every(e=>"assistant"===e.role&&("string"==typeof e.id&&l.has(e.id)||!!e.toolCalls?.length&&e.toolCalls.every(e=>a.has(e.id))))?t.slice(0,o):t}),i.current=null,c.current=0,d.current=!1,e.events))h(n);o?.onRunningChange?.(!0)}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type){o?.onRunningChange?.(!1),o?.onComplete?.();return}h(e.message),o?.onRunningChange?.(!0)}else"run-idle"===e.type&&o?.onRunningChange?.(!1)}})}},65992:(e,t,n)=>{n.d(t,{zB:()=>T,e$:()=>R,vP:()=>S});var r=n(95155),s=n(12115),l=n(79114),a=n(49433),o=n(77725),i=n(62111),c=n(70188),d=n(64428),u=n(12710),h=n(33210),m=n(32967),f=n(88780),x=n(30133);function p({value:e,onChange:t,className:n}){let{t:s}=(0,l.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["split","unified"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:s("split"===n?"diffViewer.viewSplit":"diffViewer.viewUnified")},n))})}var g=n(67362),b=n(47215),v=n(5135),y=n(9573);let w=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],k=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function j(e){return w.some(t=>t.test(e))?"test":k.some(t=>t.test(e))?"docs":null}function C(e,t){if(t&&e.startsWith(t)){let n=e.slice(t.length);return n.startsWith("/")?n.slice(1):n}return e}function N(e,t){let n=[];for(let r of e)if("Edit"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.old_string&&"string"==typeof e.new_string){let s=C(e.file_path,t);n.push({key:r.id,toolName:"Edit",subject:`[Edit] ${s}`,legacy:!0,changeClass:j(s),files:[{path:s,status:"modified",old_string:e.old_string,new_string:e.new_string,fileClass:j(s)}]})}}else if("Write"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.content){let s=C(e.file_path,t);n.push({key:r.id,toolName:"Write",subject:`[Write] ${s}`,legacy:!0,changeClass:j(s),files:[{path:s,status:"added",old_string:"",new_string:e.content,fileClass:j(s)}]})}}return n}function S(e,t,n){let r=e.map(e=>{let t=new Set(e.commit.toolFiles);return{key:e.commit.toolId??e.commit.hash,shortHash:e.commit.hash.slice(0,7),toolName:e.commit.toolName??"tool",subject:e.commit.subject,timestamp:e.commit.timestamp,truncated:!0===e.truncated,changeClass:function(e){if(0===e.length)return null;let t=j(e[0]);return null===t?null:e.every(e=>j(e)===t)?t:null}(e.files.map(e=>e.path)),files:e.files.map(e=>({path:e.path,status:e.status,additions:e.additions,deletions:e.deletions,old_string:e.oldContent??"",new_string:e.newContent??"",unviewable:e.binary||null===e.oldContent&&null===e.newContent,external:t.size>0&&!t.has(e.path),fileClass:j(e.path)}))}});return r.length>0?r:N(t,n)}function L({additions:e,deletions:t}){return(0,r.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,r.jsxs)("span",{className:"text-green-11",children:["+",e]}),(0,r.jsxs)("span",{className:"text-red-11",children:["-",t]})]})}function E({cls:e}){return(0,r.jsx)("span",{className:`text-[10px] px-1 py-px rounded flex-shrink-0 ${"test"===e?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400/80":"bg-sky-500/15 text-sky-600 dark:text-sky-400/80"}`,children:e})}function M(e){let t=new Date(1e3*e),n=new Date,r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),o=`${r}-${s} ${l}:${a}`;return t.getFullYear()===n.getFullYear()?o:`${t.getFullYear()}-${o}`}function R({toolCalls:e,cwd:t,onClose:n,onContentSearch:d}){let{t:w}=(0,l.Bd)(),k=(0,s.useRef)(null),[j,C]=(0,s.useState)(null);(0,s.useEffect)(()=>{C(k.current)},[]);let T=(0,s.useMemo)(()=>e.map(e=>e.id).filter(Boolean),[e]),$=T.join(","),[I,P]=(0,s.useState)(0),A=(0,o.Z)(t&&T.length>0?(0,y.se)(t,T):a.succeed([]),[t,$,I]),_=(0,s.useMemo)(()=>e.filter(e=>["Edit","Write","MultiEdit","NotebookEdit"].includes(e.name)).map(e=>e.id),[e]);(0,s.useEffect)(()=>{if("success"!==A.status||I>=2)return;let e=new Set(A.data.map(e=>e.commit.toolId));if(_.some(t=>!e.has(t))){let e=setTimeout(()=>P(e=>e+1),2e3);return()=>clearTimeout(e)}},[A,I,_]);let D=(0,s.useRef)([]),F="loading"===A.status&&0===D.current.length,W=(0,s.useMemo)(()=>{if("success"===A.status){let n=S(A.data,e,t);return n.length>0&&(D.current=n),n}return"loading"===A.status&&D.current.length>0?D.current:"loading"===A.status?[]:N(e,t)},[A,e,t]),[B,V]=(0,s.useState)(null),[O,z]=(0,s.useState)(null),[H,U]=(0,s.useState)(new Set),[K,q]=(0,s.useState)(()=>window.innerWidth>=768),[Z,X]=(0,s.useState)("compact"),[G,J]=(0,s.useState)("split"),[Y,Q]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),en=(0,s.useMemo)(()=>W.find(e=>e.key===B)??null,[W,B]),er=(0,s.useRef)(null);(0,s.useEffect)(()=>{en&&(er.current=en)},[en]);let es=en??er.current,el=(0,s.useMemo)(()=>es?(0,f.Do)(es.files):[],[es]),ea=(0,s.useMemo)(()=>es?.files.find(e=>e.path===O)??null,[es,O]),eo=(0,s.useCallback)(e=>{V(e.key),z(e.files[0]?.path??null),U(new Set((0,f.Sz)((0,f.Do)(e.files))))},[]);(0,s.useEffect)(()=>{W.length>0&&null==B&&eo(W[0])},[W,B,eo]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(Y)return void Q(!1);if(ee)return void et(null);(0,i.k)(),n()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n,Y,ee]);let ei=(0,s.useMemo)(()=>W.reduce((e,t)=>e+t.files.length,0),[W]),ec=e=>(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:e});return(0,r.jsx)(c.SU,{container:j,children:(0,r.jsxs)("div",{ref:k,className:"relative bg-card shadow-xl w-full h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:()=>q(e=>!e),"aria-label":w("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${K?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:(0,r.jsx)(u.A,{className:"w-4 h-4"})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:w("diffViewer.fileChanges",{count:ei})})]}),(0,r.jsx)("button",{onClick:n,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[K&&(0,r.jsx)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:W.map(e=>{let t;return(0,r.jsxs)("div",{onClick:()=>eo(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${B===e.key?"bg-brand/10":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.shortHash&&(0,r.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),void 0!==e.timestamp&&(0,r.jsx)("span",{className:"text-xs text-slate-9",children:M(e.timestamp)}),e.changeClass&&(0,r.jsx)("span",{className:"ml-auto",children:(0,r.jsx)(E,{cls:e.changeClass})})]}),(0,r.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":e.subject,children:e.subject}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:w("commitDetail.nChanges",{count:e.files.length})}),(t=function(e){let t=!1,n=0,r=0;for(let s of e.files)(void 0!==s.additions||void 0!==s.deletions)&&(t=!0),n+=s.additions??0,r+=s.deletions??0;return t?{additions:n,deletions:r}:null}(e))&&(t.additions>0||t.deletions>0)?(0,r.jsx)(L,{additions:t.additions,deletions:t.deletions}):null]})]},e.key)})}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:F?ec(w("diffViewer.loadingSnapshots")):0===W.length?ec(w("diffViewer.noChanges")):es?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,r.jsx)(m.A,{className:"w-3.5 h-3.5"}),es.toolName]}),es.shortHash&&(0,r.jsx)("span",{className:"font-mono text-brand",children:es.shortHash}),void 0!==es.timestamp&&(0,r.jsx)("span",{children:M(es.timestamp)}),(0,r.jsx)("span",{className:"flex-1 min-w-0 truncate","data-tooltip":es.subject,children:es.subject}),es.truncated&&(0,r.jsx)("span",{className:"text-amber-500",children:w("diffViewer.truncated")}),es.legacy&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":w("diffViewer.reconstructedHint"),children:w("diffViewer.reconstructed")}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,r.jsx)(x.y,{value:Z,onChange:X}),(0,r.jsx)(p,{value:G,onChange:J})]})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[K&&(0,r.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:(0,r.jsx)(f.VO,{files:el,selectedPath:O,expandedPaths:H,onToggle:e=>U(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{!e.isDirectory&&e.file&&(z(e.file.path),window.innerWidth<768&&q(!1))},cwd:t||"",showChanges:!0,renderActions:e=>{if(e.isDirectory)return null;let t=e.file;return t?(0,r.jsxs)(r.Fragment,{children:[t.fileClass&&(0,r.jsx)(E,{cls:t.fileClass}),t.external&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":w("diffViewer.externalChange")})]}):null}})}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:ea?ea.unviewable?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:w("diffViewer.notViewable")}):"unified"===G?(0,r.jsx)(g.xU,{oldContent:ea.old_string,newContent:ea.new_string,filePath:ea.path,compact:"compact"===Z}):(0,r.jsx)(g.xZ,{oldContent:ea.old_string,newContent:ea.new_string,filePath:ea.path,isNew:"added"===ea.status,isDeleted:"deleted"===ea.status,cwd:t,enableComments:!0,onContentSearch:d,compact:"compact"===Z,onPreview:"deleted"===ea.status?void 0:(0,b.e$)(ea.path)?()=>Q(!0):ea.path.endsWith(".json")?()=>et({content:ea.new_string,filePath:ea.path}):void 0,previewLabel:ea.path.endsWith(".json")?w("common.readable"):w("common.preview")}):(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:w("diffViewer.selectFileToView")})})]})]}):ec(w("diffViewer.selectFileToView"))})]}),Y&&ea&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50 p-2 md:p-4",onClick:()=>Q(!1),children:(0,r.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(v.M,{content:ea.new_string,filePath:ea.path,cwd:t||"",onClose:()=>Q(!1)})})}),ee&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50 p-2 md:p-4",onClick:()=>et(null),children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:ee.filePath}),(0,r.jsx)("button",{onClick:()=>et(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)(h.A,{className:"w-4 h-4"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,b.xb)(ee.content)})})]})})]})})}function T({toolCalls:e,cwd:t,onClose:n,onContentSearch:s}){return(0,r.jsx)(d.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:n,children:(0,r.jsx)(R,{toolCalls:e,cwd:t,onClose:n,onContentSearch:s?e=>{n(),s(e)}:void 0})})})}},67362:(e,t,n)=>{n.d(t,{xU:()=>j,xZ:()=>k});var r=n(95155),s=n(12115),l=n(47650),a=n(79114),o=n(64702),i=n(1058),c=n(90717),d=n(70188),u=n(48347),h=n(89109),m=n(7320),f=n(22576),x=n(34075),p=n(56978),g=n(17196);function b({lines:e,containerRef:t}){let n=(0,s.useRef)(null),[l,a]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:s}=e,l=n.current?.clientHeight||0;if(r<=s)a({top:0,height:l});else{let e=l/r;a({top:t*e,height:s*e})}};return r(),e.addEventListener("scroll",r),window.addEventListener("resize",r),()=>{e.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[t]),0===e.length)return null;let o=100/e.length;return(0,r.jsxs)("div",{ref:n,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let r=t.current,s=n.current;if(!r||!s)return;let l=s.getBoundingClientRect(),a=(e.clientY-l.top)/l.height*r.scrollHeight-r.clientHeight/2;r.scrollTo({top:Math.max(0,a),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,r.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*o}%`,height:`${Math.max(o,.5)}%`,minHeight:"2px"}},t)),(0,r.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${l.top}px`,height:`${Math.max(l.height,10)}px`}})]})}var v=n(37614),y=n(27570);function w(e){return e.params?`${e.name}(${e.params.join(", ")})`:e.name}function k({oldContent:e,newContent:t,filePath:n,isNew:j=!1,isDeleted:C=!1,cwd:N,enableComments:S=!1,onPreview:L,previewLabel:E,onContentSearch:M,targetLine:R,compact:T=!1,symbols:$}){let{t:I}=(0,a.Bd)(),P=E??I("common.preview"),A=(0,s.useMemo)(()=>(0,f.X)(e,t),[e,t]),_=(0,s.useRef)(null),D=(0,s.useRef)(null),F=(0,s.useRef)(null),W=(0,s.useRef)(!1),[B,V]=(0,s.useState)(!1),O=(0,d.iN)(),z=(0,u.r)(),H=S&&!!N,{comments:U,addComment:K,updateComment:q,deleteComment:Z,refresh:X}=(0,i._)({cwd:N||"",filePath:n}),[G,J]=(0,s.useState)(null),[Y,Q]=(0,s.useState)(null);(0,s.useEffect)(()=>{F.current!==Y&&Q(F.current)});let{toolbarRef:ee,bumpRef:et,clearToolbar:en}=(0,y.L)({enabled:H,container:Y,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-new-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-new-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>{let n=[],r=0;for(let s of A)("unchanged"===s.type||"added"===s.type)&&++r>=e&&r<=t&&n.push(s.content);return n.join("\n")}}),[er,es]=(0,s.useState)(null),[el,ea]=(0,s.useState)(null);(0,s.useEffect)(()=>{V(!0)},[]);let eo=(0,s.useMemo)(()=>{let e=new Set;for(let t of U)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[U]),ei=(0,s.useMemo)(()=>{let e=new Map;for(let t of U){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[U]),ec=(0,s.useCallback)((e,t)=>{t.stopPropagation(),J({comment:e,x:t.clientX,y:t.clientY}),en(),es(null),ea(null)},[en]),ed=(0,s.useCallback)(()=>{let e=ee.current;e&&(es({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),en())},[en,ee]),eu=(0,s.useCallback)(()=>{let e=ee.current;e&&(ea({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),en())},[en,ee]),eh=(0,s.useCallback)(()=>{let e=ee.current;if(!e||!M)return;let t=e.selectedText.trim();en(),t&&M(t)},[M,en,ee]),em=(0,s.useCallback)(async(e,t)=>{if(z&&N)try{let r=await (0,c.$3)(N),s=[];for(let e of r)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:n,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let l=(0,c.Gw)(s,t);z.sendMessage(l),await (0,c.RP)(N),X()}catch(e){console.error("Failed to send to AI:",e)}},[z,n,N,X]),ef=(0,s.useCallback)(e=>{el&&em(el,e)},[el,em]),ex=(0,s.useCallback)(e=>{er&&em(er,e)},[er,em]),ep=(0,s.useCallback)(async e=>{er&&(await K(er.range.start,er.range.end,e,er.selectedText),es(null))},[er,K]);(0,s.useEffect)(()=>{let e=D.current,t=F.current;if(!e||!t)return;let n=(e,t)=>{W.current||(W.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{W.current=!1}))},r=()=>n(e,t),s=()=>n(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",s)}},[]);let{leftLines:eg,rightLines:eb}=(0,s.useMemo)(()=>{let e=[],t=[],n=0,r=0;for(let s=0;s<A.length;s++){let l=A[s];if("unchanged"===l.type){for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});n++,r++,e.push({lineNum:n,content:l.content,type:"unchanged",originalIdx:s}),t.push({lineNum:r,content:l.content,type:"unchanged",originalIdx:s})}else"removed"===l.type?(n++,e.push({lineNum:n,content:l.content,type:"removed",originalIdx:s})):"added"===l.type&&(r++,t.push({lineNum:r,content:l.content,type:"added",originalIdx:s}))}for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:e,rightLines:t}},[A]),ev=(0,s.useMemo)(()=>A.map(e=>e.content),[A]),ey=(0,p.C)(ev,n),[ew,ek]=(0,s.useState)(()=>new Map);(0,s.useLayoutEffect)(()=>{ek(new Map),eR.measure()},[eg,eb]);let ej=(0,s.useMemo)(()=>$??[],[$]),{rows:eC,gaps:eN}=(0,s.useMemo)(()=>T?function(e,t,n,r=[]){let s=e.length,l=n=>"unchanged"!==e[n].type||"unchanged"!==t[n].type,a=new Set;for(let e=0;e<s;e++){if(!l(e))continue;let t=Math.max(0,e-3),n=Math.min(s-1,e+3);for(let e=t;e<=n;e++)a.add(e)}let o=[];for(let e=0;e<s;e++){if(a.has(e))continue;let t=e;for(;e<s&&!a.has(e);)e++;o.push({id:o.length,startIdx:t,endIdx:e-1}),e--}for(let e of o){let t=n.get(e.id)??{topRevealed:0,bottomRevealed:0},r=e.endIdx-e.startIdx+1,s=Math.max(0,Math.min(t.topRevealed,r)),l=Math.max(0,Math.min(t.bottomRevealed,r-s));for(let t=e.startIdx;t<e.startIdx+s;t++)a.add(t);for(let t=e.endIdx-l+1;t<=e.endIdx;t++)a.add(t)}let i=[];for(let e=0;e<s;e++){let n;if(a.has(e)){i.push({kind:"diff",idx:e});continue}let l=e;for(;e<s&&!a.has(e);)e++;let c=e-1;e--;let d=o.find(e=>e.startIdx<=l&&c<=e.endIdx);if(!d)continue;let u=c-l+1,h=Math.min(20,u);if(r.length>0&&c+1<s)for(let e=c+1;e<s;e++){let s=t[e].lineNum;if(!(s<=0)){n=function(e,t){let n=null;for(let r of e)r.startLine<=t&&t<=r.endLine&&(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r);return n}(r,s)??void 0;break}}i.push({kind:"gap-expand",gapId:d.id,direction:"up",revealCount:h}),i.push({kind:"gap-label",gapId:d.id,hiddenCount:u,enclosingFn:n}),i.push({kind:"gap-expand",gapId:d.id,direction:"down",revealCount:h})}return{rows:i,gaps:o}}(eg,eb,ew,ej):{rows:eg.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[T,eg,eg,eb,ew,ej]),eS=(0,s.useCallback)((e,t)=>{let n=eN.find(t=>t.id===e);n&&ek(r=>{let s=r.get(e)??{topRevealed:0,bottomRevealed:0},l=n.endIdx-n.startIdx+1-s.topRevealed-s.bottomRevealed;if(l<=0)return r;let a=Math.min(20,l),o="up"===t?{...s,topRevealed:s.topRevealed+a}:{...s,bottomRevealed:s.bottomRevealed+a};return new Map(r).set(e,o)})},[eN]),eL=(0,s.useCallback)(e=>{for(let t of eN)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[eN]),eE=(0,s.useCallback)(e=>eC[e]?.kind==="gap-label"?28:20,[eC]),eM=(0,s.useCallback)(e=>{let t=eC[e];if(!t)return e;if("gap-label"===t.kind)return`gl:${t.gapId}`;if("gap-expand"===t.kind)return`ge:${t.gapId}:${t.direction}`;let n=eg[t.idx],r=eb[t.idx];return`d:${n?.lineNum??"x"}:${n?.type??"x"}:${r?.lineNum??"x"}:${r?.type??"x"}`},[eC,eg,eb]),eR=(0,o.Te)({count:eC.length,getScrollElement:()=>_.current,estimateSize:eE,getItemKey:eM,overscan:20}),eT=j?"w-1/4":C?"w-3/4":"w-1/2",e$=j?"w-3/4":C?"w-1/4":"w-1/2",eI=(0,s.useMemo)(()=>eC.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=eg[e.idx],n=eb[e.idx];return"removed"===t.type?{type:"removed"}:n?.type==="added"?{type:"added"}:{type:"unchanged"}}),[eC,eg,eb]),eP=eR.getTotalSize(),eA=eR.getVirtualItems();return(0,s.useEffect)(()=>{if(!R)return;let e=("after"===R.side?eb:eg).findIndex(e=>e.lineNum===R.line);if(-1===e)return;let t=eC.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eL(e);if(null!==t){let e=eN.find(e=>e.id===t);if(!e)return;let n=e.endIdx-e.startIdx+1;ek(e=>{let r=e.get(t)??{topRevealed:0,bottomRevealed:0};if(r.topRevealed+r.bottomRevealed>=n)return e;let s=new Map(e);return s.set(t,{topRevealed:n,bottomRevealed:0}),s})}return}let n=requestAnimationFrame(()=>{eR.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(n)},[R,eg,eb,eC]),(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,r.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,r.jsx)("div",{className:`${eT} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:j?"(New File)":C?"Deleted":"Old"}),(0,r.jsxs)("div",{className:`${e$} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,r.jsx)("span",{className:"block text-center",children:C?"(Deleted)":"New"}),(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[L&&(0,r.jsx)("button",{onClick:L,className:"text-muted-foreground hover:text-foreground transition-colors",children:P}),!C&&t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,x.oR)(I("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:I("common.copy")})]})]}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:_,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"flex",style:{height:`${eP}px`},children:[(0,r.jsx)("div",{ref:D,className:`${eT} overflow-x-auto border-r border-border`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eA.map(e=>{let t=eC[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let n="gap-label"===t.kind;return(0,r.jsx)("div",{ref:eR.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:n?"bg-accent border-y border-border":""},e.key)}let n=eg[t.idx];return(0,r.jsxs)("div",{ref:eR.measureElement,"data-index":e.index,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===n.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:n.lineNum||""}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:n.originalIdx>=0&&ey[n.originalIdx]||(0,g.ZD)(n.content||" ")}})]},e.key)})})}),(0,r.jsx)("div",{ref:F,className:`${e$} overflow-x-auto`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eA.map(e=>{let t=eC[e.index];if("gap-expand"===t.kind)return(0,r.jsx)("button",{ref:eR.measureElement,"data-index":e.index,type:"button",onClick:()=>eS(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-accent hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,r.jsx)("span",{className:"select-none",children:I("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,r.jsxs)("div",{ref:eR.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:I("diffViewer.gap.hidden",{count:t.hiddenCount})}),t.enclosingFn&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,r.jsx)("span",{className:"truncate min-w-0 font-medium",title:w(t.enclosingFn),children:w(t.enclosingFn)})]})]},e.key);let n=eb[t.idx],s=n?.lineNum||0,l=s>0&&eo.has(s),a=ei.get(s),o=a?.[0],i=er&&s>=er.range.start&&s<=er.range.end,c=el&&s>=el.range.start&&s<=el.range.end,d=i||c;return(0,r.jsxs)("div",{ref:eR.measureElement,"data-index":e.index,"data-new-line":s||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${d?"bg-blue-9/20":l?"bg-amber-9/10":n?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,r.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${d?"bg-blue-9/30":""}`,style:{width:H?"52px":"40px"},children:[H&&s>0&&l&&o&&(0,r.jsx)("button",{onClick:e=>ec(o,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:I("codeViewer.nComments",{count:a?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),H&&s>0&&!l&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"flex-1 text-right pr-1",children:s||""})]}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:n?.originalIdx>=0&&ey[n.originalIdx]||(0,g.ZD)(n?.content||" ")}})]},e.key)})})})]})}),(0,r.jsx)(b,{lines:eI,containerRef:_})]}),B&&O&&(0,l.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.f,{floatingToolbarRef:ee,bumpRef:et,container:O,onAddComment:ed,onSendToAI:eu,onSearch:M?eh:void 0,isChatLoading:z?.isLoading??!1}),er&&(0,r.jsx)(m.t,{x:er.x,y:er.y,range:er.range,filePath:n,lineSnapshot:er.lineSnapshot,container:O,onSubmit:ep,onSendToAI:z?ex:void 0,onClose:()=>es(null),isChatLoading:z?.isLoading}),el&&(0,r.jsx)(m.G,{x:el.x,y:el.y,range:el.range,filePath:n,lineSnapshot:el.lineSnapshot,container:O,onSubmit:ef,onClose:()=>ea(null),isChatLoading:z?.isLoading}),G&&(0,r.jsx)(v.t,{x:G.x,y:G.y,comment:G.comment,container:O,onClose:()=>J(null),onUpdateComment:q,onDeleteComment:Z})]}),O)]})}function j({oldContent:e,newContent:t,filePath:n,compact:l=!1}){let{t:i}=(0,a.Bd)(),c=(0,s.useMemo)(()=>(0,f.X)(e,t),[e,t]),d=(0,s.useRef)(null),u=(0,s.useMemo)(()=>c.map(e=>e.content),[c]),h=(0,p.C)(u,n),[m,x]=(0,s.useState)(()=>new Set);(0,s.useEffect)(()=>{x(new Set)},[e,t,n]);let b=(0,s.useMemo)(()=>l?function(e,t){let n=e.length,r=Array(n).fill(!1);for(let t=0;t<n;t++){if("unchanged"===e[t].type)continue;let s=Math.max(0,t-3),l=Math.min(n-1,t+3);for(let e=s;e<=l;e++)r[e]=!0}let s=[],l=0,a=0;for(;a<n;){if(r[a]){s.push({kind:"line",line:e[a],index:a}),a++;continue}let o=a;for(;o<n&&!r[o];)o++;let i=l++;if(t.has(i))for(let t=a;t<o;t++)s.push({kind:"line",line:e[t],index:t});else s.push({kind:"gap",id:i,count:o-a});a=o}return s}(c,m):c.map((e,t)=>({kind:"line",line:e,index:t})),[l,c,m]),v=(0,s.useCallback)(e=>{let t=b[e];if(!t)return e;if("gap"===t.kind)return`gap:${t.id}`;let n=t.line;return`${n.type}:${n.oldLineNum??"x"}:${n.newLineNum??"x"}`},[b]),y=(0,o.Te)({count:b.length,getScrollElement:()=>d.current,estimateSize:()=>20,getItemKey:v,overscan:20});return(0,r.jsx)("div",{ref:d,className:"font-mono text-sm overflow-auto h-full",children:(0,r.jsx)("div",{style:{height:`${y.getTotalSize()}px`,position:"relative"},children:y.getVirtualItems().map(e=>{let t=b[e.index];if(!t)return null;let n={position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`};if("gap"===t.kind){let s=i("diffViewer.gap.hidden",{count:t.count});return(0,r.jsx)("div",{style:n,onClick:()=>x(e=>new Set(e).add(t.id)),className:"flex items-center cursor-pointer bg-slate-2 hover:bg-accent border-y border-border text-xs text-slate-9 select-none",title:s,children:(0,r.jsx)("span",{className:"w-full text-center",children:s})},e.key)}let s=t.line;return(0,r.jsxs)("div",{style:n,className:`flex ${"removed"===s.type?"bg-red-9/15 dark:bg-red-9/25":"added"===s.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==s.type?s.oldLineNum:""}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==s.type?s.newLineNum:""}),(0,r.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===s.type?"text-red-11":"added"===s.type?"text-green-11":"text-slate-9"}`,children:"removed"===s.type?"-":"added"===s.type?"+":" "}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:h[t.index]||(0,g.ZD)(s.content||" ")}})]},e.key)})})})}},67589:(e,t,n)=>{n.d(t,{z:()=>o,m:()=>c});var r=n(12115),s=n(49433),l=n(86957),a=n(82680);let o=e=>s.tryPromise({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new a.uV({message:"session-by-path failed",cause:e})}),i=new Map;function c(e,t,n,{cwd:d,initialSessionId:u,onSessionId:h,onTitleChange:m,onTokenUsage:f,liveRunningRef:x}){let[p,g]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[k,j]=(0,r.useState)(void 0),[C,N]=(0,r.useState)(0),[S,L]=(0,r.useState)(null),[E,M]=(0,r.useState)(null),R=(0,r.useRef)(m);R.current=m;let T=(0,r.useRef)(f);T.current=f;let $=(0,r.useRef)(void 0),I=(0,r.useRef)(0),P=(0,r.useCallback)(async(e,n,r=!1,s,a,c=!1)=>{if(r){let e=Date.now();if(!c&&e-I.current<5e3)return;I.current=e}let d=(e,r)=>{e.fingerprint&&($.current=e.fingerprint),void 0!==e.totalTurns&&N(e.totalTurns),void 0!==e.hasMore&&w(e.hasMore),e.messages&&e.messages.length>0&&(r?t(t=>(function(e,t){if(0===t.length)return e;let n=0;if(e.length>0&&e[0].id!==t[0].id){n=-1;for(let r=e.length-1;r>=0;r--)if(e[r].id===t[0].id){n=r;break}}if(n<0)return t;let r=e.slice(n),s=0;for(let e=0;e<Math.min(r.length,t.length)&&r[e].id===t[e].id&&r[e].content===t[e].content;e++)s=e+1;return s===r.length&&s===t.length?e:s===r.length&&s<t.length?[...e,...t.slice(s)]:[...e.slice(0,n),...r.slice(0,s),...t.slice(s)]})(t,e.messages)):x?.current||t(e.messages),L(n)),e.sessionId&&h(e.sessionId),e.engine&&M(e.engine),e.title&&R.current?.(e.title),e.usage&&T.current?.({inputTokens:e.usage.input_tokens||0,outputTokens:e.usage.output_tokens||0,cacheCreationInputTokens:e.usage.cache_creation_input_tokens||0,cacheReadInputTokens:e.usage.cache_read_input_tokens||0,totalCostUsd:0})},u=`${e}::${n}`,m=!r&&void 0===a,f=m?i.get(u):void 0;r||(f?d(f.data,!1):g(!0));try{let t={cwd:e,sessionId:n,limit:s,beforeTurnIndex:a};r&&$.current?t.ifFingerprint=$.current:f&&(t.ifFingerprint=f.fingerprint);let c=await l.t4.runPromiseExit(o(t));if("Success"===c._tag&&c.value){let e=c.value;if(e.notModified)return;if(d(e,r),m&&e.fingerprint&&e.messages&&e.messages.length>0&&(i.delete(u),i.set(u,{data:e,fingerprint:e.fingerprint}),i.size>20)){let e=i.keys().next().value;void 0!==e&&i.delete(e)}}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{r||g(!1)}},[t,h]),A=(0,r.useCallback)(async()=>{if(d&&n&&!b&&y){v(!0);try{let r=void 0!==k?k:C-Math.ceil(e.filter(e=>"user"===e.role).length),s=await l.t4.runPromiseExit(o({cwd:d,sessionId:n,limit:10,beforeTurnIndex:r>0?r:void 0}));if("Success"===s._tag&&s.value){let e=s.value;if(e.messages&&e.messages.length>0){t(t=>[...e.messages,...t]);let s=e.messages.filter(e=>"user"===e.role).length;j(r-s),L(n)}void 0!==e.hasMore&&w(e.hasMore),e.fingerprint&&($.current=e.fingerprint)}else"Failure"===s._tag&&console.error("Failed to load more history:",s.cause)}finally{v(!1)}}},[d,n,b,y,k,C,e,t]),_=(0,r.useCallback)(async e=>{g(!0);let n=s.tryPromise({try:async()=>{let t=await fetch(`/api/session/${e}/history`);return t.ok?await t.json():null},catch:e=>new a.uV({message:"load session history failed",cause:e})}),r=await l.t4.runPromiseExit(n);"Success"===r._tag&&r.value?.messages&&r.value.messages.length>0?(t(r.value.messages),L(e)):"Failure"===r._tag&&console.error("Failed to load history:",r.cause),g(!1)},[t]);return(0,r.useEffect)(()=>{d&&u&&P(d,u,!1,10)},[]),{isLoadingHistory:p,isLoadingMore:b,hasMoreHistory:y,loadMoreHistory:A,loadHistory:_,loadHistoryByCwdAndSessionId:P,loadedSessionId:S,loadedEngine:E}}},70188:(e,t,n)=>{n.d(t,{Ee:()=>h,SU:()=>c,ft:()=>u,iN:()=>d});var r=n(95155),s=n(12115),l=n(79114),a=n(47650),o=n(34075);let i=(0,s.createContext)(null);function c({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function d(){return(0,s.useContext)(i)}function u({x:e,y:t,path:n,cwd:c,isDirectory:d,onClose:h,onCreateFile:m,onDelete:f,onRefresh:x,onCopyFile:p,onPaste:g}){let{t:b}=(0,l.Bd)(),v=(0,s.useRef)(null),y=(0,s.useContext)(i),w=n.split("/").pop()||n,k=`${c}/${n}`,j=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",C=j?`${c}/${j}`:c,N=d?n:j,S=d?k:C;(0,s.useEffect)(()=>{let e=e=>{v.current&&!v.current.contains(e.target)&&h()},t=e=>{"Escape"===e.key&&h()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[h]);let[L,E]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(v.current&&y){let n=y.getBoundingClientRect(),r=v.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s=Math.min(s,n.width-r.width-8),l=Math.min(l,n.height-r.height-8),E({x:s=Math.max(8,s),y:l=Math.max(8,l)})}else if(v.current){let n=v.current.getBoundingClientRect();E({x:Math.max(8,Math.min(e,window.innerWidth-n.width-8)),y:Math.max(8,Math.min(t,window.innerHeight-n.height-8))})}},[e,t,y]);let M=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),(0,o.oR)(b("toast.copiedName",{name:t}),"success")}catch{(0,o.oR)(b("toast.copyFailed"),"error")}h()},[h,b]),R=d?n:j,T=[{label:b("fileContextMenu.copyRelativePath"),value:n},{label:b("fileContextMenu.copyAbsolutePath"),value:k},{label:b("fileContextMenu.copyRelativeDirPath"),value:N||"."},{label:b("fileContextMenu.copyAbsoluteDirPath"),value:S},{label:d?b("fileContextMenu.copyFolderName"):b("fileContextMenu.copyFileName"),value:w}],$=(0,r.jsxs)("div",{ref:v,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lg py-1 w-fit whitespace-nowrap",style:{left:L.x,top:L.y},children:[m&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{h(),m(R)},children:b("fileContextMenu.createFile")}),p&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{h(),p(n)},children:d?b("fileContextMenu.copyFolder"):b("fileContextMenu.copyFile")}),g&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{h(),g(R)},children:b("fileContextMenu.pasteHere")}),f&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-accent transition-colors",onClick:()=>{h(),f(n,d,w)},children:d?b("fileContextMenu.deleteFolder"):b("fileContextMenu.deleteFile")}),(m||f||p||g)&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),T.map((e,t)=>(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>M(e.value,e.label),children:e.label},t))]});return y?(0,a.createPortal)($,y):$}function h(){let[e,t]=(0,s.useState)(null);return{contextMenu:e,showContextMenu:(0,s.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,s.useCallback)(()=>{t(null)},[])}}},73395:(e,t,n)=>{n.d(t,{M:()=>ed});var r=n(95155),s=n(12115),l=n(83897),a=n(64428),o=n(34075),i=n(12651),c=n(81165),d=n(16950),u=n(11019),h=n(12612),m=n(79114),f=n(86957),x=n(67589);function p({cwd:e,sessionId:t,toolCall:n,workflowRef:l,onClose:o}){let{t:i}=(0,m.Bd)(),[c,d]=(0,s.useState)(null),[u,h]=(0,s.useState)(null),[g,b]=(0,s.useState)(!1),v=(0,s.useRef)(void 0),y=l?!!l.running:!n?.result,w=(0,s.useCallback)(async()=>{let r=await f.t4.runPromiseExit((0,x.z)({cwd:e,sessionId:t,...l?{workflowId:l.runId,workflowAgentId:l.agentId}:{toolUseId:n?.id},ifFingerprint:v.current}));if(b(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(v.current=s.fingerprint),!s.notModified&&(s.messages&&d(s.messages),s.subagent&&h(s.subagent))},[e,t,n?.id,l?.runId,l?.agentId]);(0,s.useEffect)(()=>{if(w(),!y)return;let e=setInterval(w,5e3);return()=>clearInterval(e)},[y,w]);let k=(0,s.useRef)(null),j=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let e=k.current;e&&j.current&&(e.scrollTop=e.scrollHeight)},[c]);let C="string"==typeof n?.input?.description?n.input.description:"",N=l?l.label||"":[u?.agentType,C].filter(Boolean).join(" \xb7 ");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:o,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDD16"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.subagent")}),N&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:N,children:N}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:o,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{ref:k,onScroll:()=>{let e=k.current;e&&(j.current=e.scrollTop+e.clientHeight>=e.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(g?"chat.subagentEmpty":"common.loading")}):c.map(t=>(0,r.jsx)(el,{message:t,cwd:e},t.id))})]})})})}function g(e){return e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):"0"}function b(e){if(!e)return"–";let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return`${n}m${t%60}s`}let v={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function y({cwd:e,sessionId:t,runId:n,isRunning:l,onClose:o}){let{t:i}=(0,m.Bd)(),[c,d]=(0,s.useState)(null),[u,h]=(0,s.useState)(!1),[v,k]=(0,s.useState)(null),j=(0,s.useRef)(void 0),C=l||null!=c&&"completed"!==c.status&&"failed"!==c.status,N=(0,s.useCallback)(async()=>{let r=await f.t4.runPromiseExit((0,x.z)({cwd:e,sessionId:t,workflowId:n,ifFingerprint:j.current}));if(h(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(j.current=s.fingerprint),!s.notModified&&s.workflow&&d(s.workflow)},[e,t,n]);(0,s.useEffect)(()=>{if(N(),!C)return;let e=setInterval(N,5e3);return()=>clearInterval(e)},[C,N]);let S=[];if(c?.agents){let e=new Map;for(let t of c.agents){let n=t.phaseTitle||i("chat.workflowUngrouped");e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let[t,n]of e)S.push({title:t,agents:n})}let L=c?[c.workflowName,c.status,`${c.agentCount??c.agents?.length??0} ${i("chat.workflowAgents")}`,`${g(c.totalTokens)} tok`,b(c.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,r.jsxs)(a.ZL,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:o,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.workflowRun")}),L&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:L,children:L}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[C&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:o,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(u?"chat.workflowEmpty":"common.loading")}):(0,r.jsxs)(r.Fragment,{children:[c.summary&&(0,r.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:c.summary}),S.map(e=>(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:e.title}),e.agents.map(e=>(0,r.jsx)(w,{agent:e,onOpen:()=>e.agentId&&k({runId:n,agentId:e.agentId,label:e.label,running:"done"!==e.state&&C})},`${e.index}-${e.agentId}`))]},e.title))]})})]})}),v&&(0,r.jsx)(p,{cwd:e,sessionId:t,workflowRef:v,onClose:()=>k(null)})]})}function w({agent:e,onOpen:t}){let{t:n}=(0,m.Bd)(),[l,a]=(0,s.useState)(!1),o=e.state&&v[e.state]||"text-muted-foreground",i=e.resultPreview||e.promptPreview||"";return(0,r.jsxs)("div",{className:"border border-border rounded-md mb-1 bg-secondary/50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,r.jsx)("button",{onClick:()=>a(e=>!e),className:"text-slate-9 text-xs flex-shrink-0",title:n(l?"chat.collapse":"chat.expand"),children:l?"▲":"▼"}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0",title:e.label||"",children:e.label||e.agentId}),(0,r.jsx)("span",{className:`text-[10px] flex-shrink-0 ${o}`,children:e.state}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[g(e.tokens)," tok \xb7 ",b(e.durationMs)]}),e.agentId&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:t,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&t()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:n("chat.subagentViewTitle"),children:n("chat.workflowViewAgent")})]}),l&&i&&(0,r.jsx)("pre",{className:"text-[11px] bg-secondary px-2 py-1.5 rounded-b overflow-x-auto max-h-32 overflow-y-auto text-muted-foreground whitespace-pre-wrap border-t border-border",children:i})]})}var k=n(60938),j=n(67362),C=n(38408),N=n(13219),S=n(47176),L=n(97251),E=n(56045),M=n(50860),R=n(47215);function T({filePath:e}){let[t,n]=(0,s.useState)(null),[l,a]=(0,s.useState)(!0),[o,i]=(0,s.useState)(null),c=(0,s.useRef)(!1),d=(0,R.e$)(e),u=(0,R.u)(e);return((0,s.useEffect)(()=>{u?a(!1):c.current||(c.current=!0,(async()=>{a(!0),i(null);let t=await f.t4.runPromiseExit((0,k.nM)(e));if("Success"===t._tag)n(t.value.content??null);else{let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;i(n instanceof Error?n.message:"Failed to load file")}a(!1),c.current=!1})())},[e,u]),o)?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-xs text-red-11",children:o})}):l?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,R.u)(e)?(0,r.jsx)(M.I,{absPath:e,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:e.split("/").pop()||"image"}):t?d?(0,r.jsx)(I,{content:t}):(0,r.jsx)(C.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}let $=[L.W];function I({content:e}){let t=(0,s.useRef)(null);return(0,r.jsxs)("div",{className:"h-full flex",children:[(0,r.jsx)(S.l,{content:e,containerRef:t}),(0,r.jsx)("div",{ref:t,className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(N.T,{content:e,rehypePlugins:$})})]})}function P({title:e,content:t,toolName:n,onClose:l}){let{t:i}=(0,m.Bd)(),c=(0,R.jU)(t),d=(0,R.zs)(t),u=(0,R.oK)(t),h=!!d,f=!!u,[x,p]=(0,s.useState)(("Read"===n||"Write"===n)&&f?"file":h?"diff-unified":c?"readable":"json"),g=(0,s.useRef)(null),b=(0,E.o)(g);(0,s.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===x&&c){e.preventDefault(),b.open();return}if("Escape"===e.key){if(b.isVisible)return void b.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l,x,c,b]);let v=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:l,children:(0,r.jsxs)("div",{className:"bg-card shadow-xl w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:e}),u&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(u),(0,o.oR)(i("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:i("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[c&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>p("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.sideBySide"),children:"Split"}),(0,r.jsx)("button",{onClick:()=>p("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.unified"),children:"Unified"})]}),f&&(0,r.jsx)("button",{onClick:()=>p("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.previewFile"),children:"File"}),(0,r.jsx)("button",{onClick:()=>p("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("common.readable")}),(0,r.jsx)("button",{onClick:()=>p("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,r.jsx)("button",{onClick:l,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===x&&u?(0,r.jsx)(T,{filePath:u}):"diff-unified"===x&&d?(0,r.jsx)(j.xU,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"diff-split"===x&&d?(0,r.jsx)(j.xZ,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"readable"===x&&c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E._,{search:b}),(0,r.jsx)("pre",{ref:g,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,R.xb)(t)})]}):(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:c?(0,R.C6)(t):t})})]})});return(0,r.jsx)(a.ZL,{children:v})}let A={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function _({toolCall:e,cwd:t,sessionId:n}){var l;let{t:a}=(0,m.Bd)(),[i,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[h,f]=(0,s.useState)(!1),[x,g]=(0,s.useState)(!1),b=A[e.name]||"\uD83D\uDD27",v="Agent"===e.name||"Task"===e.name,w=v&&!!t&&!!n,k="Workflow"===e.name,j=k&&(l=e.result)?l.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,C=k&&!!j&&!!t&&!!n,N="Skill"===e.name,S=v||k||N,L=(()=>{let t=e.input;if("Bash"===e.name&&t.command&&"string"==typeof t.command)return t.command;if(v&&t.description&&"string"==typeof t.description)return t.description;if(k){let e=["string"==typeof t.name?t.name:"","string"==typeof t.args?t.args:"string"==typeof t.resumeFromRunId?t.resumeFromRunId:""].filter(Boolean).join(" \xb7 ");if(e)return e}if(N&&"string"==typeof t.skill){let e="string"==typeof t.args?t.args:"";return[t.skill,e].filter(Boolean).join(" \xb7 ")}return"Glob"===e.name&&t.pattern&&"string"==typeof t.pattern||"Grep"===e.name&&t.pattern&&"string"==typeof t.pattern?t.pattern:"ToolSearch"===e.name&&t.query&&"string"==typeof t.query?t.query:"TaskCreate"===e.name&&t.subject&&"string"==typeof t.subject?t.subject:t.file_path&&"string"==typeof t.file_path?t.file_path:t.path&&"string"==typeof t.path?t.path:null})(),E="Glob"===e.name||"Grep"===e.name||"Bash"===e.name||v||k||N,M=L?E?L:(e=>{if(t&&e.startsWith(t)){let n=e.slice(t.length);return n.startsWith("/")?n.slice(1):n}let n=e.split("/");return n.length>2?".../"+n.slice(-2).join("/"):e})(L):null,R=t=>{let n="input"===t?a("toolCall.inputParams"):a("toolCall.resultLabel"),r="input"===t?JSON.stringify(e.input,null,2):"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2);u({title:`${e.name}${M?` ${M}`:""} - ${n}`,content:r,toolName:e.name})};return(0,r.jsxs)("div",{className:"my-1 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,r.jsxs)("button",{onClick:()=>c(!i),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,r.jsx)("span",{className:"text-sm",children:b}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:e.name}),M&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:L||"",children:M}),!S&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),L&&(navigator.clipboard.writeText(L),(0,o.oR)(a("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),L&&(navigator.clipboard.writeText(L),(0,o.oR)(a("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:a("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[w&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),f(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),f(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("chat.subagentViewTitle"),children:a("chat.subagent")}),C&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),g(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),g(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("chat.workflowViewTitle"),children:a("chat.workflowRun")}),i&&!e.isLoading&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),R("input")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),R("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("toolCall.inputParamsTitle"),children:a("toolCall.input")}),e.result&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),R("result")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),R("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("toolCall.resultTitle"),children:a("toolCall.result")})]}),e.isLoading?(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,r.jsx)("span",{className:"text-slate-9 text-xs",children:i?"▲":"▼"})]})]}),i&&(0,r.jsxs)("div",{className:"border-t border-border",children:[(0,r.jsxs)("div",{className:"px-3 py-2",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a("toolCall.inputParams"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(e.input,null,2)})]}),e.result&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a("toolCall.resultLabel"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2)})]}),e.skillContent&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:e.skillContent})]})]}),d&&(0,r.jsx)(P,{title:d.title,content:d.content,toolName:d.toolName,onClose:()=>u(null)}),h&&t&&n&&(0,r.jsx)(p,{cwd:t,sessionId:n,toolCall:e,onClose:()=>f(!1)}),x&&t&&n&&j&&(0,r.jsx)(y,{cwd:t,sessionId:n,runId:j,isRunning:!!e.isLoading,onClose:()=>g(!1)})]})}var D=n(62111),F=n(56204),W=n(67635),B=n(33210),V=n(58515),O=n(36201),z=n(55804),H=n(37618);function U(e){let t=e.input?.questions||[],n=e.input?.answers||{},r={};if(e.result)try{let t=JSON.parse(e.result);t?.answers&&(r=t.answers)}catch{}return{questions:t,answers:{...n,...r}}}function K(e,t){return`${e}-${t}`}function q({toolCalls:e,onClose:t}){let{t:n}=(0,m.Bd)(),i=(0,l.nH)(),[c,d]=(0,s.useState)({}),[u,h]=(0,s.useState)({}),[f,x]=(0,s.useState)({}),[p,g]=(0,s.useState)({});(0,s.useEffect)(()=>{let t={};e.forEach((e,n)=>{let{questions:r,answers:s}=U(e);r.forEach((e,r)=>{let l=s[e.question];if(l){let s=K(n,r);t[s]=l,e.options.some(e=>e.label===l)||(h(e=>({...e,[s]:!0})),x(e=>({...e,[s]:l})))}})}),queueMicrotask(()=>d(t))},[e]),(0,D.E)(t);let b=e.reduce((e,t)=>{let{questions:n}=U(t);return e+n.length},0),v=Object.values(p).filter(Boolean).length,y=(0,s.useCallback)((e,t)=>{d(n=>({...n,[e]:t})),h(t=>({...t,[e]:!1}))},[]),w=(0,s.useCallback)(e=>{h(t=>{let n=!t[e];if(n){let t=f[e]||"";t&&d(n=>({...n,[e]:t}))}return{...t,[e]:n}})},[f]),k=(0,s.useCallback)((e,t)=>{x(n=>({...n,[e]:t})),t&&d(n=>({...n,[e]:t}))},[]),j=(0,s.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),C=(0,s.useCallback)(()=>{let t=v>0,r=[];return e.forEach((e,s)=>{let{questions:l}=U(e);l.forEach((e,l)=>{let a=K(s,l);if(t&&!p[a])return;let o=c[a];r.push(`Q: ${e.question}`),r.push(`A: ${o||n("askQuestion.notSelected")}`),r.push("")})}),r.join("\n").trim()},[e,c,p,v,n]),N=(0,s.useCallback)(()=>{navigator.clipboard.writeText(C()),(0,o.oR)(v>0?n("toast.copiedQA",{count:v}):n("toast.copiedAllQA"))},[C,v,n]),S=(0,s.useCallback)(()=>{i?(i.sendMessage(C()),(0,o.oR)(n("toast.sentQA")),t()):(0,o.oR)(n("askQuestion.sendNoChat"))},[i,C,t,n]),L=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:t,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:n("askQuestion.title")}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[n("askQuestion.nQuestions",{count:b}),v>0&&` \xb7 ${n("askQuestion.checkedN",{count:v})}`]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:S,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:v>0?n("askQuestion.sendChecked",{count:v}):n("askQuestion.sendAll"),children:(0,r.jsx)(F.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:N,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:v>0?n("askQuestion.copyChecked",{count:v}):n("askQuestion.copyAll"),children:(0,r.jsx)(W.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)(B.A,{className:"w-5 h-5"})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:e.map((t,s)=>{let{questions:l}=U(t);return l.map((t,a)=>{let o=K(s,a),i=c[o],d=u[o]||!1,h=p[o]||!1;return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("button",{onClick:()=>j(o),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:n("askQuestion.checkToCopy"),children:h?(0,r.jsx)(V.A,{className:"w-4 h-4 text-brand"}):(0,r.jsx)(O.A,{className:"w-4 h-4 text-muted-foreground"})}),t.header&&(0,r.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:t.header}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t.question})]}),(0,r.jsxs)("div",{className:"space-y-1 ml-7",children:[t.options.map((e,t)=>{let n=i===e.label&&!d;return(0,r.jsxs)("button",{onClick:()=>y(o,e.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${n?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:n?(0,r.jsx)(z.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:`text-sm ${n?"text-foreground font-medium":"text-foreground"}`,children:e.label}),e.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]})]},t)}),(0,r.jsxs)("button",{onClick:()=>w(o),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${d?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:d?(0,r.jsx)(z.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(H.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:n("askQuestion.custom")})]})]}),d&&(0,r.jsx)("div",{className:"ml-6 mt-1",children:(0,r.jsx)("input",{type:"text",autoFocus:!0,value:f[o]||"",onChange:e=>k(o,e.target.value),placeholder:n("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground placeholder:text-muted-foreground"})})]}),(s!==e.length-1||a!==l.length-1)&&(0,r.jsx)("div",{className:"border-b border-border/50 mt-3"})]},o)})})})]})});return(0,r.jsx)(a.ZL,{children:L})}var Z=n(65992),X=n(9573);let G=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]);var J=n(5135),Y=n(38175),Q=n(70188),ee=n(83448);function et({image:e,onClose:t}){let{t:n}=(0,m.Bd)(),s=(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsx)("button",{onClick:t,className:"absolute top-4 right-4 w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:n("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,r.jsx)(a.ZL,{children:s})}function en({filePath:e,onClose:t}){return(0,r.jsx)(a.ZL,{children:(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsx)("button",{onClick:t,className:"absolute top-4 right-4 w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,r.jsx)("img",{src:`/api/file?path=${encodeURIComponent(e)}&raw=true`,alt:e.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]})})}function er({filePath:e,content:t,cwd:n,onClose:l}){let[o,i]=(0,s.useState)(null);return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:l,children:(0,r.jsx)("div",{ref:i,className:"bg-card shadow-xl w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(Q.SU,{container:o,children:(0,r.jsx)(J.M,{content:t,filePath:e,cwd:n,onClose:l})})})})})}function es({filePath:e,content:t,cwd:n,onClose:s,onContentSearch:l}){let{t:i}=(0,m.Bd)();return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:s,children:(0,r.jsxs)("div",{className:"bg-card shadow-xl w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},title:e,onClick:()=>{navigator.clipboard.writeText(e),(0,o.oR)(i("common.copiedPath"))},children:["‎",e]}),(0,r.jsx)("button",{onClick:s,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-accent transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,r.jsx)(Y.E,{content:t,filePath:e,cwd:n,onContentSearch:l?e=>{l(e),s()}:void 0})})]})})})}let el=(0,s.memo)(function({message:e,cwd:t,sessionId:n,onFork:l,onApprovePlan:x,isLoading:p,onContentSearch:g,onShowFileDiff:b}){let v,y,w,k,{t:j}=(0,m.Bd)(),[C,S]=(0,s.useState)(null),[L,E]=(0,s.useState)(()=>1===(e.toolCalls?.length||0)),[M,T]=(0,s.useState)(!1),[$,I]=(0,s.useState)(!1),[P,A]=(0,s.useState)(!1),D="user"===e.role,F=e.images&&e.images.length>0,W=e.toolCalls?.length||0,B=!!n&&!!t&&!!l,V=(0,s.useMemo)(()=>e.toolCalls?.some(e=>{let t;return t=e.name,!G.has(t)})||!1,[e.toolCalls]),O=(0,s.useMemo)(()=>(0,Z.vP)([],e.toolCalls??[],t).length>0,[e.toolCalls,t]),[z,H]=(0,s.useState)(!1),U=O||z;(0,s.useEffect)(()=>{if(!V||O||!t)return;let n=(e.toolCalls??[]).map(e=>e.id).filter(Boolean);if(0===n.length)return;let r=(e.toolCalls??[]).filter(e=>["Edit","Write","MultiEdit","NotebookEdit"].includes(e.name)).map(e=>e.id),s=!1,l=null,a=0,o=()=>{f.t4.runPromiseExit((0,X.xK)(t,n)).then(e=>{if(s)return;let t="Success"===e._tag?e.value:[];if(t.length>0)return void H(!0);let n=new Set(t.map(e=>e.toolId));r.some(e=>!n.has(e))&&a<2&&(a+=1,l=setTimeout(o,2e3))})};return o(),()=>{s=!0,l&&clearTimeout(l)}},[V,O,t,e.toolCalls]);let K=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("TodoWrite"===e.toolCalls[t].name)return e.toolCalls[t];return null},[e.toolCalls]),J=(0,s.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),Y=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("ExitPlanMode"===e.toolCalls[t].name){let n=e.toolCalls[t].input?.plan;return"string"==typeof n&&n?n:null}return null},[e.toolCalls]),Q=(0,s.useMemo)(()=>e.toolCalls?.filter(e=>"ExitPlanMode"!==e.name)??[],[e.toolCalls]),el=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=new Set,n=[];for(let r of e.toolCalls)if("Read"===r.name||"Edit"===r.name||"Write"===r.name){let e=r.input.file_path;e&&((0,R.e$)(e)||(0,R.aR)(e)||(0,R.u)(e))&&!t.has(e)&&(t.add(e),n.push(e))}return n},[e.toolCalls]),ea=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=[];for(let n of e.toolCalls){let e=n.input?.thought;if(e&&"string"==typeof e){let r=e.match(/PREVIOUS:\s*(.*?)\s*→\s*THIS:\s*(.*?)\s*→\s*EXPECT:\s*(.*)/i);r?t.push({previous:r[1].trim(),current:r[2].trim(),expect:r[3].trim(),raw:e,toolName:n.name}):t.push({previous:"",current:e,expect:"",raw:e,toolName:n.name})}}return t},[e.toolCalls]),[eo,ei]=(0,s.useState)(null),[ec,ed]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!eo||(0,R.u)(eo))return void queueMicrotask(()=>ed(null));let e=!1;return f.t4.runPromiseExit((0,ee.an)(eo)).then(t=>{e||("Success"===t._tag&&void 0!==t.value.content?ed(t.value.content):((0,o.oR)(j("toast.readFileFailed"),"error"),ei(null)))}),()=>{e=!0}},[eo,j]);let eu=()=>{e.content&&(navigator.clipboard.writeText(e.content),(0,o.oR)(j("toast.copiedMessage")))},eh=()=>{B&&l(e.id)},em=(e=>{if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${n}-${r} ${s}:${l}`})(e.timestamp);if("system"===e.role){let t=e.systemEvent,n=t?.kind==="task-notification"?"failed"===t.status?"⚠️":"stopped"===t.status?"⏹️":"\uD83D\uDD14":"ℹ️",s=t?.detail||e.content;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex justify-center my-2 px-2","data-role":"system",children:(0,r.jsxs)("button",{type:"button",onClick:()=>A(!0),className:"flex items-center gap-1.5 max-w-[85%] text-[11px] text-muted-foreground bg-secondary/40 border border-border/50 rounded-full px-3 py-1 hover:bg-secondary hover:text-foreground transition-colors cursor-pointer",title:j("chat.viewDetails",{defaultValue:"Click for details"}),children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:n}),(0,r.jsx)("span",{className:"truncate",children:e.content})]})}),P&&(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:()=>A(!1),children:(0,r.jsxs)("div",{className:"bg-card shadow-xl w-full max-w-4xl max-h-[80vh] rounded-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-foreground flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:n}),t?.kind==="task-notification"?j("chat.taskNotification",{defaultValue:"Task notification"}):j("chat.systemNotice",{defaultValue:"Notice"})]}),(0,r.jsx)("button",{onClick:()=>A(!1),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-accent transition-colors",children:"✕"})]}),(0,r.jsx)("pre",{className:"flex-1 overflow-auto px-4 py-3 text-xs text-foreground whitespace-pre-wrap break-words",children:s})]})})})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:`flex flex-col ${D?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[em&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mb-0.5 px-1",children:em}),(0,r.jsxs)("div",{className:`flex ${D?"justify-end":"justify-start"} w-full`,children:[D&&(0,r.jsxs)("div",{className:"self-start mt-2 mr-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,r.jsx)("button",{onClick:eu,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),B&&(0,r.jsx)("button",{onClick:eh,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.forkSession"),children:(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,r.jsx)("path",{d:"M12 12v3"})]})})]}),(0,r.jsxs)("div",{className:`max-w-[80%] ${D?"bg-accent text-foreground border border-brand rounded-2xl rounded-br-md":"bg-accent text-foreground dark:text-slate-11 rounded-2xl rounded-bl-md"} px-4 py-2`,children:[F&&(0,r.jsx)("div",{className:`flex flex-wrap gap-2 ${e.content?"mb-2":""}`,children:e.images.map((e,t)=>(0,r.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>S(e),children:(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:j("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),e.content&&(0,r.jsxs)("div",{className:"break-words",children:[(0,r.jsx)(N.T,{content:e.content,isUser:D,isStreaming:e.isStreaming,enableMath:!1}),e.isStreaming&&(0,r.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]}),K&&(w=(y=Array.isArray(v=K.input?.todos)?v:[]).filter(e=>"completed"===e.status).length,k=y.length,(0,r.jsx)("div",{className:`${e.content||F?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${k>0?w/k*100:0}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[w,"/",k]})]}),y.map((e,t)=>(0,r.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===e.status?"opacity-50":""}`,children:["completed"===e.status?(0,r.jsx)(i.A,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):"in_progress"===e.status?(0,r.jsx)(c.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,r.jsx)(d.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,r.jsx)("span",{className:`text-xs truncate ${"completed"===e.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===e.status&&e.activeForm?e.activeForm:e.content})]},t))]})})),Y&&(0,r.jsx)("div",{className:`${e.content||F||K?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-brand/40 rounded-lg overflow-hidden bg-secondary/50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-border bg-brand/10",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDCCB"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:j("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)(N.T,{content:Y,isUser:!1,enableMath:!1})}),x&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:j("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,r.jsxs)("button",{onClick:()=>x(),disabled:p,className:"flex items-center gap-1.5 px-3 py-1 rounded-md bg-brand text-white text-xs font-medium hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex-shrink-0",children:[(0,r.jsx)("span",{children:"✓"}),(0,r.jsx)("span",{children:j("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),el.length>0&&(0,r.jsx)("div",{className:`${e.content||F||K?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-0.5",children:el.map(e=>(0,r.jsxs)("button",{onClick:()=>ei(e),className:"flex items-center gap-1.5 w-full text-left hover:bg-accent rounded px-1 py-0.5 transition-colors group/md",children:[(0,R.u)(e)?(0,r.jsxs)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"}),(0,r.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4-4 3 3 4-4 5 5"})]}):(0,R.aR)(e)?(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}):(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:e.split("/").pop()})]},e))})}),ea.length>0&&(0,r.jsx)("div",{className:`${e.content||F||K||el.length>0?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border text-muted-foreground",children:[(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium w-[60px]",children:"Tool"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Previous"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Action"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Expect"})]})}),(0,r.jsx)("tbody",{children:ea.map((e,t)=>(0,r.jsxs)("tr",{className:t<ea.length-1?"border-b border-border/50":"",children:[(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground font-mono",children:e.toolName}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.previous||"—"}),(0,r.jsx)("td",{className:"px-2 py-1 text-foreground",children:e.current}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.expect||"—"})]},t))})]})})}),Q.length>0&&(0,r.jsx)("div",{className:`${e.content||F?"mt-2":""}`,children:W>0?(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("button",{onClick:()=>E(!L),className:"flex-1 px-3 py-1.5 flex items-center gap-2 text-left hover:bg-accent transition-colors active:bg-muted",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDD27"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:j("chat.toolCalls",{count:Q.length})}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:L?j("chat.collapse"):j("chat.expand")})]}),J.length>0&&(0,r.jsx)("button",{onClick:()=>I(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:j("chat.viewQuestions"),children:(0,r.jsx)(u.A,{className:"w-4 h-4"})}),U&&(0,r.jsx)("button",{onClick:()=>{b&&e.toolCalls?b(e.toolCalls,t):T(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:j("chat.viewAllFileChanges"),children:(0,r.jsx)(h.A,{className:"w-4 h-4"})})]}),L&&(0,r.jsx)("div",{className:"border-t border-border p-2 space-y-1",children:Q.map((e,s)=>(0,r.jsx)(_,{toolCall:e,cwd:t,sessionId:n},`${e.id}-${s}`))})]}):Q.map((e,s)=>(0,r.jsx)(_,{toolCall:e,cwd:t,sessionId:n},`${e.id}-${s}`))})]}),!D&&(0,r.jsxs)("div",{className:"self-start mt-2 ml-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,r.jsx)("button",{onClick:eu,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),B&&(0,r.jsx)("button",{onClick:eh,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.forkSession"),children:(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,r.jsx)("path",{d:"M12 12v3"})]})})]})]})]}),C&&(0,r.jsx)(et,{image:C,onClose:()=>S(null)}),M&&e.toolCalls&&(0,r.jsx)(Z.zB,{toolCalls:e.toolCalls,cwd:t,onClose:()=>T(!1),onContentSearch:g}),$&&J.length>0&&(0,r.jsx)(q,{toolCalls:J,onClose:()=>I(!1)}),eo&&(0,R.u)(eo)&&(0,r.jsx)(en,{filePath:eo,onClose:()=>ei(null)}),eo&&!(0,R.u)(eo)&&null!==ec&&((0,R.aR)(eo)?(0,r.jsx)(es,{filePath:eo,content:ec,cwd:t,onClose:()=>ei(null),onContentSearch:g}):(0,r.jsx)(er,{filePath:eo,content:ec,cwd:t||"",onClose:()=>ei(null)}))]})});var ea=n(1058),eo=n(90717),ei=n(89109),ec=n(7320);let ed=(0,s.forwardRef)(function({messages:e,isLoading:t,cwd:n,sessionId:a,engine:o,apiRetryInfo:i,ptyNotice:c,hasMoreHistory:d,isLoadingMore:u,onLoadMore:h,onFork:f,isActive:x=!0,onContentSearch:p,onShowFileDiff:g,onApprovePlan:b},v){let{t:y}=(0,m.Bd)(),w=(0,s.useRef)(null),k=(0,s.useRef)(null),j=(0,s.useRef)(null),C=(0,s.useRef)(null),[N,S]=(0,s.useState)(null),[L,E]=(0,s.useState)(!0),[M,R]=(0,s.useState)(!1),[T,$]=(0,s.useState)(!1);(0,s.useEffect)(()=>{S(C.current)},[]);let{isSearchVisible:I,searchQuery:P,setSearchQuery:A,matches:_,currentMatchIndex:D,goToNextMatch:F,goToPrevMatch:W,closeSearch:B,searchInputRef:V,handleSearchKeyDown:O}=function(e){let[t,n]=(0,s.useState)(!1),[r,l]=(0,s.useState)(""),[a,o]=(0,s.useState)([]),[i,c]=(0,s.useState)(0),d=(0,s.useRef)(null),u=(0,s.useRef)([]),h=(0,s.useCallback)(()=>{let t=e.current;t&&(t.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||""),e),t.normalize())}),u.current=[])},[e]),m=(0,s.useCallback)(t=>{if(h(),!t||!e.current){o([]),c(0);return}let n=[],r=[],s=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let l,a=e.getAttribute("data-message-id")||"",o=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),c=[];for(;l=i.nextNode();)c.push(l);for(let e of c){let l=(e.textContent||"").toLowerCase(),i=0,c=[];for(;;){let e=l.indexOf(s,i);if(-1===e)break;c.push({start:e,end:e+t.length}),i=e+1}if(0!==c.length)for(let t=c.length-1;t>=0;t--){let s=c[t];e.splitText(s.end);let l=e.splitText(s.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=l.textContent,l.parentNode.replaceChild(i,l),n.push({messageId:a,markIndex:o}),r.push(i),o++}}}),n.reverse(),r.reverse(),u.current=r,o(n),c(n.length>0?0:-1)},[e,h]);(0,s.useEffect)(()=>{queueMicrotask(()=>m(r))},[r,m]),(0,s.useEffect)(()=>{let e=u.current;e.forEach((e,t)=>{e.className=t===i?"chat-search-current":"chat-search-match"}),i>=0&&i<e.length&&e[i].scrollIntoView({behavior:"smooth",block:"center"})},[i,a]);let f=(0,s.useCallback)(()=>{0!==a.length&&c(e=>(e+1)%a.length)},[a.length]),x=(0,s.useCallback)(()=>{0!==a.length&&c(e=>(e-1+a.length)%a.length)},[a.length]),p=(0,s.useCallback)(()=>{n(!0),setTimeout(()=>d.current?.focus(),0)},[]),g=(0,s.useCallback)(()=>{n(!1),l(""),h(),o([]),c(0)},[h]),b=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?x():f()),"Escape"===e.key&&g()},[f,x,g]);return(0,s.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),e.stopPropagation(),p())};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)},[e,p]),{isSearchVisible:t,searchQuery:r,setSearchQuery:l,matches:a,currentMatchIndex:i,goToNextMatch:f,goToPrevMatch:x,openSearch:p,closeSearch:g,searchInputRef:d,handleSearchKeyDown:b}}(C),z=(0,l.nH)(),H=(0,s.useRef)(null),U=(0,s.useRef)(()=>{}),{addComment:K,refresh:q}=(0,ea._)({cwd:n||"",filePath:eo.Un}),[Z,X]=(0,s.useState)(null),[G,J]=(0,s.useState)(null),Y=(0,s.useCallback)(e=>{if(Z||G)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){H.current=null,U.current();return}let n=t.toString().trim();if(!n){H.current=null,U.current();return}let r=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(r?.closest('[data-role="user"]')){H.current=null,U.current();return}H.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:n,lineSnapshot:n},U.current()},[Z,G]),Q=(0,s.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&H.current&&(H.current=null,U.current())},[]),ee=(0,s.useCallback)(()=>{let e=H.current;e&&(X({x:e.x,y:e.y,text:e.selectedText}),H.current=null,U.current(),window.getSelection()?.removeAllRanges())},[]),et=(0,s.useCallback)(()=>{let e=H.current;e&&(J({x:e.x,y:e.y,text:e.selectedText}),H.current=null,U.current(),window.getSelection()?.removeAllRanges())},[]),en=(0,s.useCallback)(()=>{let e=H.current;if(!e||!p)return;let t=e.selectedText.trim();H.current=null,U.current(),window.getSelection()?.removeAllRanges(),t&&p(t)},[p]),er=(0,s.useCallback)(async e=>{Z&&(await K(0,0,e,Z.text),X(null))},[Z,K]),es=(0,s.useCallback)(async(e,t)=>{if(z&&n)try{let r=(await (0,eo.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));r.push({filePath:eo.Un,startLine:0,endLine:0,codeContent:e});let s=(0,eo.Gw)(r,t);z.sendMessage(s),await (0,eo.RP)(n),q()}catch(e){console.error("Failed to send to AI:",e)}},[z,n,q]),ed=(0,s.useCallback)(e=>{G&&es(G.text,e)},[G,es]),eu=(0,s.useCallback)(e=>{Z&&es(Z.text,e)},[Z,es]),eh=(0,s.useMemo)(()=>{let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),!0))},[e]),em=(0,s.useRef)(0),ef=(0,s.useRef)(!1),ex=(0,s.useCallback)(()=>{let e=j.current;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<50},[]),ep=(0,s.useCallback)(()=>{let e=j.current;return!e||e.scrollTop<50},[]),eg=(0,s.useCallback)(()=>{let e=ex(),t=ep();if(E(e),R(!t),$(!e),t&&d&&!u&&h){let e=j.current;e&&(em.current=e.scrollHeight,ef.current=!0),h()}},[ex,ep,d,u,h]),eb=(0,s.useCallback)(()=>{k.current?.scrollIntoView({behavior:"smooth"})},[]),ev=(0,s.useCallback)(()=>{w.current?.scrollIntoView({behavior:"smooth"})},[]),ey=(0,s.useCallback)(e=>{let t=j.current;if(!t)return;let n=t.querySelector(`[data-message-id="${e}"]`);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.classList.add("ring-2","ring-brand","ring-offset-2"),setTimeout(()=>{n.classList.remove("ring-2","ring-brand","ring-offset-2")},2e3))},[]);(0,s.useImperativeHandle)(v,()=>({scrollToMessage:ey}),[ey]);let ew=(0,s.useRef)(0),ek=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let t=ew.current,n=e.length;ew.current=n,!ek.current&&L&&n>t&&w.current?.scrollIntoView({behavior:"smooth"})},[e,L]),(0,s.useEffect)(()=>{L&&t&&w.current?.scrollIntoView({behavior:"smooth"})},[t,L]),(0,s.useEffect)(()=>{if(ef.current&&!u){let e=j.current;if(e){let t=e.scrollHeight-em.current;e.scrollTop=t,ef.current=!1}}},[e,u]);let ej=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{x&&ej.current&&e.length>0&&(ej.current=!1,w.current?.scrollIntoView({behavior:"instant"}))},[x,e.length]),(0,s.useEffect)(()=>{ek.current&&e.length>0&&(ek.current=!1,x?w.current?.scrollIntoView({behavior:"instant"}):ej.current=!0)},[e.length,x]),(0,r.jsxs)("div",{ref:C,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:Y,onMouseDown:Q,children:[I&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,r.jsx)("input",{ref:V,type:"text",value:P,onChange:e=>A(e.target.value),onKeyDown:O,placeholder:y("codeViewer.searchChat"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:_.length>0?`${D+1}/${_.length}`:y("common.noMatch")}),(0,r.jsx)("button",{onClick:W,disabled:0===_.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:y("codeViewer.prevShiftEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:F,disabled:0===_.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:y("codeViewer.nextEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:B,className:"p-1 rounded hover:bg-accent",title:y("codeViewer.closeEsc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{ref:j,onScroll:eg,className:"relative flex-1 min-h-0 overflow-y-auto p-4",children:0!==e.length||t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:k}),d&&(0,r.jsx)("div",{className:"flex justify-center py-3",children:u?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("span",{children:y("chat.loadMoreHistory")})]}):(0,r.jsx)("button",{onClick:h,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:y("chat.scrollUpForMore")})}),eh.map(e=>(0,r.jsx)("div",{"data-message-id":e.id,className:"transition-[box-shadow] duration-300",children:(0,r.jsx)(el,{message:e,cwd:n,sessionId:a,onFork:f,onApprovePlan:b,isLoading:t,onContentSearch:p,onShowFileDiff:g})},e.id)),t&&(0,r.jsx)("div",{className:"flex justify-start mb-4",children:(0,r.jsxs)("div",{className:"bg-accent rounded-2xl rounded-bl-md px-4 py-3 max-w-[90%]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,r.jsx)("span",{className:"inline-block w-5 h-5 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("span",{className:"text-sm",children:"claude2"===o?"Claude 2 is thinking...":"codex"===o?"Codex is thinking...":"kimi"===o?"Kimi is thinking...":"ollama"===o?"Ollama is thinking...":"deepseek"===o?"DeepSeek is thinking...":y("chat.claudeThinking")})]}),i&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-400 border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{children:["Retrying API call (attempt ",i.attempt,i.maxRetries>0?`/${i.maxRetries}`:"",i.delayMs>0?`, delay ${(i.delayMs/1e3).toFixed(1)}s`:"",")"]}),(i.errorStatus||i.error)&&(0,r.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[i.errorStatus?`${i.errorStatus}`:"",i.errorStatus&&i.error?" \xb7 ":"",i.error||""]})]})]}),c&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-400 border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01M5.07 19h13.86c1.54 0 2.5-1.67 1.73-3L13.73 4a2 2 0 00-3.46 0L3.34 16c-.77 1.33.19 3 1.73 3z"})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 break-words",children:c})]})]})}),(0,r.jsx)("div",{ref:w})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-slate-9",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,r.jsx)("div",{children:y("chat.startConversation")})]})})}),M&&e.length>0&&(0,r.jsx)("button",{onClick:eb,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:y("chat.jumpToStart"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),T&&e.length>0&&(0,r.jsx)("button",{onClick:ev,className:"absolute bottom-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:y("chat.jumpToLatest"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),N&&(0,r.jsx)(ei.f,{floatingToolbarRef:H,bumpRef:U,container:N,onAddComment:ee,onSendToAI:et,onSearch:p?en:void 0,isChatLoading:z?.isLoading}),Z&&N&&(0,r.jsx)(ec.t,{x:Z.x,y:Z.y,range:{start:0,end:0},lineSnapshot:Z.text,container:N,onSubmit:er,onSendToAI:z?eu:void 0,onClose:()=>X(null),isChatLoading:z?.isLoading}),G&&N&&(0,r.jsx)(ec.G,{x:G.x,y:G.y,range:{start:0,end:0},lineSnapshot:G.text,container:N,onSubmit:ed,onClose:()=>J(null),isChatLoading:z?.isLoading})]})})},75346:(e,t,n)=>{n.d(t,{n:()=>s});var r=n(88292);let s={SessionChange:(0,r.R)("session-change"),ViewChange:(0,r.R)("view-change"),OpenNote:(0,r.R)("open-note"),LangChange:(0,r.R)("lang-change"),TabAdd:(0,r.R)("tab-add"),TabClose:(0,r.R)("tab-close"),SwitchSession:(0,r.R)("switch-session"),ProjectChange:(0,r.R)("project-change"),OpenProject:(0,r.R)("open-project"),SessionComplete:(0,r.R)("session-complete"),OpenTokenStats:(0,r.R)("open-token-stats"),PinnedSessionsChanged:(0,r.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,r.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,r.R)("screenshot-prepare"),ScreenshotDone:(0,r.R)("screenshot-done")}},77725:(e,t,n)=>{n.d(t,{Z:()=>d});var r=n(12115),s=n(10592),l=n(86359),a=n(80905),o=n(49433),i=n(80286),c=n(86957);function d(e,t){let[n,d]=(0,r.useState)({status:"loading"});return(0,r.useEffect)(()=>{d({status:"loading"});let t=c.t4.runFork(e);return t.addObserver(e=>{s.YW(e,{onSuccess:e=>d({status:"success",data:e}),onFailure:e=>{let t=l.od(e);d({status:"error",error:a.Ru(t)?t.value:e})}})}),()=>{o.runFork(i.G(t))}},t),n}},82292:(e,t,n)=>{function r(e,t){for(let n of e){if(n.path===t)return n;if(n.children){let e=r(n.children,t);if(e)return e}}return null}function s(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let s=e.split("/");return s.pop(),s.join("/")}function l(e){let t=[];for(let n of e){let e=n.split("/"),r=t;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1,l=e.slice(0,t+1).join("/"),a=r.find(e=>e.name===n);a||(a={name:n,path:l,isDirectory:!s,children:s?void 0:[]},r.push(a)),!s&&a.children&&(r=a.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>{e.children&&n(e.children)})};return n(t),t}function a(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}n.d(t,{B_:()=>f,HR:()=>function e(t,n){if(0===n.length)return t;let r=new Map(n.map(e=>[e.path,e]));return t.map(t=>{let n=r.get(t.path);return n&&t.isDirectory?void 0===t.children&&void 0!==n.children?{...t,children:n.children}:void 0!==t.children&&void 0!==n.children?{...t,children:e(t.children,n.children)}:t:t})},KH:()=>d,MB:()=>r,S7:()=>s,fw:()=>u,q3:()=>c,r6:()=>h,tE:()=>m,tW:()=>a,u:()=>i,v3:()=>l});let o=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function i(e){let t=e.split(".").pop()?.toLowerCase();return o.has(t||"")}function c(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase(),l=e=>{if(r.add(e.path),e.children)for(let t of e.children)l(t)},a=(e,t)=>{let o=e.name.toLowerCase(),i=n?o===s:o.includes(s);if(i&&e.children)return l(e),t.forEach(e=>r.add(e)),!0;let c=!1;if(e.children)for(let n of e.children)a(n,[...t,e.path])&&(c=!0);return(!!i||!!c)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)a(t,[]);return r}function d(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase();for(let t of e){let e=t.split("/");for(let t=0;t<e.length;t++){let l=e[t].toLowerCase();if(n?l===s:l.includes(s)){for(let t=0;t<=e.length-1;t++)r.add(e.slice(0,t+1).join("/"));break}}}return r}function u(e){let t=Math.floor(Math.floor((Date.now()-1e3*e)/1e3)/60),n=Math.floor(t/60),r=Math.floor(n/24),s=Math.floor(r/30),l=Math.floor(r/365);return l>0?`${l}y ago`:s>0?`${s}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function h(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return r?`${s}-${l} ${a}:${o}`:`${t.getFullYear()}-${s}-${l} ${a}:${o}`}let m=()=>{},f=50},83448:(e,t,n)=>{n.d(t,{Cr:()=>k,JC:()=>f,M5:()=>h,Pk:()=>d,QW:()=>g,Zr:()=>p,an:()=>w,em:()=>c,l1:()=>m,n_:()=>x,pw:()=>u,qD:()=>y,td:()=>i,z2:()=>b});var r=n(49433),s=n(82680);let l=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>l(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=(e,t)=>l(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=()=>l("/api/settings"),c=e=>o("/api/settings",e),d=()=>l("/api/deepseek/credentials"),u=e=>o("/api/deepseek/credentials",{apiKey:e}),h=()=>l("/api/commands"),m=()=>l("/api/skills"),f=e=>a("/api/bash",e),x=e=>r.tryPromise({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new s.uV({message:"POST /api/session-by-path failed",cause:e})}),p=(e,t)=>a(`/api/session/${encodeURIComponent(e)}/fork`,t),g=e=>l(`/api/sessions/projects/${encodeURIComponent(e)}`),b=()=>l("/api/global-state").pipe(r.map(e=>e.sessions??[])),v=()=>r.tryPromise({try:async()=>{let e=await fetch("/api/ollama/models");return 503===e.status?{_tag:"not-running"}:e.ok?{_tag:"ok",models:(await e.json()).models??[]}:{_tag:"error",message:"Failed to fetch models"}},catch:e=>new s.uV({message:"fetch ollama models failed",cause:e})}),y=e=>r.gen(function*(){let t=yield*v();if("not-running"!==t._tag)return t;e&&(yield*r.sync(e));let n=yield*r.tryPromise({try:async()=>{let e=await fetch("/api/ollama/start",{method:"POST"}),t=await e.json().catch(()=>({}));return 404===e.status?{_tag:"not-installed",message:t.message||"Ollama is not installed"}:e.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:e=>new s.uV({message:"start ollama failed",cause:e})});if("not-installed"===n._tag)return{_tag:"not-installed",message:n.message};if("error"===n._tag)return{_tag:"error",message:n.message};let l=yield*v();return"not-running"===l._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:l}),w=e=>l(`/api/file?path=${encodeURIComponent(e)}`),k=e=>l(`/api/claude-stats?engine=${encodeURIComponent(e)}`)},83897:(e,t,n)=>{n.d(t,{k_:()=>o,nH:()=>i});var r=n(95155),s=n(12115),l=n(48347);let a=(0,s.createContext)(null);function o({children:e}){let t=(0,s.useRef)(new Map),n=(0,s.useRef)(null),[i,c]=(0,s.useState)(!1),d=(0,s.useCallback)((e,n)=>{t.current.set(n,e)},[]),u=(0,s.useCallback)(e=>{t.current.delete(e)},[]),h=(0,s.useCallback)(e=>{n.current=e},[]),m=(0,s.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let s=t.current.get(r);s?s(e):console.warn(`No chat sender registered for tab ${r}`)},[]),f=(0,s.useMemo)(()=>({sendMessage:m,isLoading:i,registerChat:d,unregisterChat:u,setActiveTab:h,setIsLoading:c}),[m,i,d,u,h]),x=(0,s.useMemo)(()=>({sendMessage:m,isLoading:i}),[m,i]);return(0,r.jsx)(a.Provider,{value:f,children:(0,r.jsx)(l.H,{value:x,children:e})})}function i(){return(0,s.useContext)(a)}},88780:(e,t,n)=>{n.d(t,{Do:()=>u,Sz:()=>h,VO:()=>d,wI:()=>m});var r=n(95155),s=n(12115),l=n(79114),a=n(70188),o=n(14575);function i({status:e}){let{label:t,className:n}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[e]||{label:"?",className:"text-muted-foreground"};return(0,r.jsx)("span",{className:`text-xs font-bold ${n}`,children:t})}let c=s.memo(function e({node:t,level:n,selectedPath:l,expandedPaths:a,onSelect:c,onToggle:d,onContextMenu:u,showChanges:h=!1,renderActions:m}){let f=l===t.path,x=a.has(t.path),p=(0,s.useCallback)(()=>{t.isDirectory?d(t.path):c(t)},[t,c,d]),g=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),u(e,t.path,t.isDirectory)},[t.path,t.isDirectory,u]);return t.isDirectory?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*n+8}px`},onClick:p,onContextMenu:g,children:[(0,r.jsx)("span",{className:"text-slate-9 text-xs",children:x?"▼":"▶"}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),m&&m(t)]}),x&&t.children.map(t=>(0,r.jsx)(e,{node:t,level:n+1,selectedPath:l,expandedPaths:a,onSelect:c,onToggle:d,onContextMenu:u,showChanges:h,renderActions:m},t.path))]}):(0,r.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${f?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*n+8}px`},onClick:p,onContextMenu:g,children:[(0,r.jsx)(o.o,{name:t.name,size:16,className:"flex-shrink-0"}),(0,r.jsx)("span",{className:`text-sm flex-1 truncate ${f?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),t.status&&(0,r.jsx)(i,{status:t.status}),h&&void 0!==t.additions&&void 0!==t.deletions&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,r.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]}),m&&m(t)]})});function d({files:e,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:o,cwd:i,showChanges:u=!1,renderActions:h,emptyMessage:m,className:f}){let{t:x}=(0,l.Bd)(),p=m??x("gitFileTree.noFiles"),{contextMenu:g,showContextMenu:b,hideContextMenu:v}=(0,a.Ee)();return 0===e.length?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:p}):(0,r.jsxs)("div",{className:f||"py-1",children:[e.map(e=>(0,r.jsx)(c,{node:e,level:0,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:o,onContextMenu:b,showChanges:u,renderActions:h},e.path)),g&&(0,r.jsx)(a.ft,{x:g.x,y:g.y,path:g.path,cwd:i,isDirectory:g.isDirectory,onClose:v})]})}function u(e){let t=[];for(let n of e){let e=n.path.split("/"),r=t;for(let t=0;t<e.length;t++){let s=e[t],l=t===e.length-1,a=e.slice(0,t+1).join("/"),o=r.find(e=>e.name===s);o||(o={name:s,path:a,isDirectory:!l,children:[],...l&&{status:n.status,additions:n.additions,deletions:n.deletions,oldPath:n.oldPath,file:n}},r.push(o)),l||(r=o.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>n(e.children))};return n(t),t}function h(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),n(r.children))};return n(e),t}function m(e){let t=[],n=e=>{if(e.isDirectory)for(let t of e.children)n(t);else t.push(e)};return n(e),t}},89109:(e,t,n)=>{n.d(t,{f:()=>o});var r=n(95155),s=n(12115),l=n(79114);function a({x:e,y:t,visible:n,container:s,onAddComment:o,onSendToAI:i,onSearch:c,isChatLoading:d}){let{t:u}=(0,l.Bd)(),h=s.getBoundingClientRect(),m=e-h.left,f=Math.max(0,t-h.top-40);return(0,r.jsxs)("div",{className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-xl p-1.5",style:{left:m+8,top:f,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:o,children:u("floatingToolbar.addComment")}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:i,disabled:d,title:u(d?"comments.aiResponding":"floatingToolbar.sendToAI"),children:u("floatingToolbar.sendToAI")}),c&&(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:c,children:u("floatingToolbar.search")})]})}let o=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:l,onSendToAI:o,onSearch:i,isChatLoading:c}){let[d,u]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>u(e=>e+1)},[t]);let h=(0,s.useMemo)(()=>e.current,[d]);return(0,r.jsx)(a,{x:h?.x??0,y:h?.y??0,visible:!!h,container:n,onAddComment:l,onSendToAI:o,onSearch:i,isChatLoading:c})})},90717:(e,t,n)=>{n.d(t,{$3:()=>u,Cm:()=>d,Gw:()=>f,RP:()=>h,Un:()=>m,zL:()=>c});var r=n(69809),s=n(49433),l=n(86957),a=n(82680),o=n(46456);let i=new Set;function c(e){return i.add(e),()=>i.delete(e)}function d(){i.forEach(e=>e())}async function u(e){let t=await l.t4.runPromiseExit((0,o.lb)(e));if("Success"!==t._tag)throw Error("Failed to fetch comments");let n=t.value.comments??[];if(0===n.length)return[];let r=new Map;for(let e of n)e.selectedText||(r.has(e.filePath)||r.set(e.filePath,[]),r.get(e.filePath).push(e));let i=new Map;await Promise.all(Array.from(r.keys()).map(async t=>{let n=await l.t4.runPromiseExit(s.tryPromise({try:async()=>{let n=await fetch(`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);return n.ok?await n.json():null},catch:e=>new a.uV({message:`read file text ${t} failed`,cause:e})}));"Success"===n._tag&&n.value&&"string"==typeof n.value.content?i.set(t,n.value.content.split("\n")):"Failure"===n._tag&&console.error(`Failed to read file ${t}:`,n.cause)}));let c=[];for(let e of n){if(e.selectedText){c.push({...e,codeContent:e.selectedText});continue}let t=i.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),s=Math.min(t.length,e.endLine);n=t.slice(r,s).join("\n")}c.push({...e,codeContent:n})}return c}async function h(e){let t=await l.t4.runPromiseExit((0,o.tj)(e));return"Success"===t._tag?(d(),!0):(console.error("Failed to clear comments:",t.cause),!1)}let m="__chat__";function f(e,t){let n=e.filter(e=>e.filePath===m),s=e.filter(e=>e.filePath!==m),l=[];for(let e of(s.length>0&&(l.push(`${r.A.t("comments.codeRef")}`,""),s.forEach((e,t)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";l.push(`[${t+1}] ${e.filePath}${n}`),l.push("```"),l.push(e.codeContent),l.push("```"),e.note&&l.push(r.A.t("comments.note",{content:e.note})),l.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");l.push(t),e.note&&l.push(e.note),l.push("")}if(t.trim()){for(;l.length>0&&""===l[l.length-1];)l.pop();l.push(t.trim())}return l.join("\n").trim()}},95045:(e,t,n)=>{n.d(t,{F:()=>a});var r=n(49433),s=n(88292),l=n(86957);let a=(e,t)=>{l.t4.runFork(r.flatMap(s.d,n=>n.publish(e,t)))}},95942:(e,t,n)=>{n.d(t,{EE:()=>o,K2:()=>i,ri:()=>c});var r=n(95155),s=n(12115),l=n(79114),a=n(8422);let o=80,i=24,c=(0,s.forwardRef)(function({visible:e,running:t,onInput:n},c){let{t:d}=(0,l.Bd)(),u=(0,s.useRef)(n);(0,s.useEffect)(()=>{u.current=n},[n]);let[h,m]=(0,s.useState)(!1),f=(0,s.useRef)(!1);(0,s.useEffect)(()=>{t&&!f.current?m(!0):!t&&f.current&&m(!1),f.current=t},[t]);let x=(0,s.useRef)(null),p=(0,s.useRef)(null),g=(0,s.useRef)(""),b=(0,s.useCallback)(()=>{if(p.current||!x.current)return;let e=new a.B({cols:o,rows:i,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace',convertEol:!1,scrollback:2e3,theme:{background:"#0a0a0a",foreground:"#d4d4d8"},disableStdin:!1,allowProposedApi:!0});e.open(x.current),e.onData(e=>u.current?.(e)),g.current&&e.write(g.current),p.current=e},[]);return((0,s.useEffect)(()=>{h&&e?b():(p.current?.dispose(),p.current=null)},[h,e,b]),(0,s.useImperativeHandle)(c,()=>({write:e=>{g.current+=e,g.current.length>2e5&&(g.current=g.current.slice(-15e4)),p.current?.write(e)},clear:()=>{g.current="",p.current?.clear()}}),[]),e)?(0,r.jsxs)("div",{className:"absolute top-12 right-3 z-30 rounded-lg border border-border bg-card shadow-lg overflow-hidden",style:{width:h?"auto":180},"data-testid":"pty-floating-window",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(e=>!e),"data-testid":"pty-floating-toggle",className:"w-full flex items-center justify-between gap-3 px-2.5 py-1.5 text-xs bg-accent/60 hover:bg-accent",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${t?"bg-green-500 animate-pulse":"bg-muted-foreground"}`}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[d("chat.ptyTerminal"),t?` \xb7 ${d("chat.ptyRunning")}`:""]})]}),(0,r.jsx)("span",{className:"text-muted-foreground",children:h?`${d("chat.ptyCollapse")} ▾`:`${d("chat.ptyExpand")} ▸`})]}),(0,r.jsx)("div",{ref:x,"data-testid":"pty-floating-term",style:{display:h?"block":"none",padding:4},className:"bg-[#0a0a0a]"})]}):null})}}]);
15
+ `:"")+"</task-notification>";t(t=>[...t,{id:n,role:"system",content:e.summary||"",systemEvent:{kind:"task-notification",...e.status?{status:e.status}:{},detail:r}}])}return}if("user"===e.type&&e._human){let n=e.message?.content,r="string"==typeof n?n:Array.isArray(n)?n.map(e=>e?.text||"").join(""):"",s="string"==typeof e._turnId?e._turnId:null,l="number"==typeof e._ts?e._ts:null,a=s?`live-user-${s}`:`live-user-${++c.current}`;t(e=>{if(s&&e.some(e=>e.id===a))return e;for(let t=e.length-1;t>=0;t--){if("user"!==e[t].role)continue;let n=e[t].timestamp?Date.parse(e[t].timestamp):NaN;if(null===l||Number.isNaN(n)){if(e[t].content===r)return e}else if(n>=l)return e;break}return[...e,{id:a,role:"user",content:r}]});return}"result"===e.type&&(d.current=!1);let n=i.current??u();t(t=>(0,l.F)(t,e,{engine:a,assistantId:n}))};(0,s.h)({url:e?`/ws/session-stream?sessionId=${encodeURIComponent(e)}`:"/ws/session-stream",enabled:n&&!!e,onMessage:e=>{if("run-snapshot"===e.type&&Array.isArray(e.events)){if("running"!==e.status)return void o?.onRunningChange?.(!1);let n=e.events.find(e=>e?.type==="user"&&e?._human),r=n?.message?.content,s="string"==typeof r?r:"",l=new Set,a=new Set;for(let t of e.events){let e=t?.uuid;if("string"==typeof e&&l.add(e),t?.type==="assistant"&&Array.isArray(t.message?.content))for(let e of t.message.content)e?.name&&"string"==typeof e.id&&a.add(e.id)}let u="number"==typeof e.startedAt?e.startedAt:null;for(let n of(t(e=>{let t=e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("live-"))),n=t[t.length-1],r=n?.timestamp?Date.parse(n.timestamp):NaN;if(null!==u&&!Number.isNaN(r)){let e=t.length;for(;e>0;){let n=t[e-1],r=n.timestamp?Date.parse(n.timestamp):NaN;if(!Number.isNaN(r)&&r>=u)e--;else break}return e<t.length?t.slice(0,e):t}if(!s)return t;let o=-1;for(let e=t.length-1;e>=0;e--)if("user"===t[e].role){t[e].content===s&&(o=e);break}return -1===o?t:t.slice(o+1).every(e=>"assistant"===e.role&&("string"==typeof e.id&&l.has(e.id)||!!e.toolCalls?.length&&e.toolCalls.every(e=>a.has(e.id))))?t.slice(0,o):t}),i.current=null,c.current=0,d.current=!1,e.events))h(n);o?.onRunningChange?.(!0)}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type){o?.onRunningChange?.(!1),o?.onComplete?.();return}h(e.message),o?.onRunningChange?.(!0)}else"run-idle"===e.type&&o?.onRunningChange?.(!1)}})}},65992:(e,t,n)=>{n.d(t,{zB:()=>T,e$:()=>R,vP:()=>S});var r=n(95155),s=n(12115),l=n(79114),a=n(49433),o=n(77725),i=n(62111),c=n(70188),d=n(64428),u=n(12710),h=n(33210),m=n(32967),f=n(88780),x=n(30133);function p({value:e,onChange:t,className:n}){let{t:s}=(0,l.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["split","unified"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:s("split"===n?"diffViewer.viewSplit":"diffViewer.viewUnified")},n))})}var g=n(67362),b=n(47215),v=n(5135),y=n(9573);let w=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],k=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function j(e){return w.some(t=>t.test(e))?"test":k.some(t=>t.test(e))?"docs":null}function C(e,t){if(t&&e.startsWith(t)){let n=e.slice(t.length);return n.startsWith("/")?n.slice(1):n}return e}function N(e,t){let n=[];for(let r of e)if("Edit"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.old_string&&"string"==typeof e.new_string){let s=C(e.file_path,t);n.push({key:r.id,toolName:"Edit",subject:`[Edit] ${s}`,legacy:!0,changeClass:j(s),files:[{path:s,status:"modified",old_string:e.old_string,new_string:e.new_string,fileClass:j(s)}]})}}else if("Write"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.content){let s=C(e.file_path,t);n.push({key:r.id,toolName:"Write",subject:`[Write] ${s}`,legacy:!0,changeClass:j(s),files:[{path:s,status:"added",old_string:"",new_string:e.content,fileClass:j(s)}]})}}return n}function S(e,t,n){let r=e.map(e=>{let t=new Set(e.commit.toolFiles);return{key:e.commit.toolId??e.commit.hash,shortHash:e.commit.hash.slice(0,7),toolName:e.commit.toolName??"tool",subject:e.commit.subject,timestamp:e.commit.timestamp,truncated:!0===e.truncated,changeClass:function(e){if(0===e.length)return null;let t=j(e[0]);return null===t?null:e.every(e=>j(e)===t)?t:null}(e.files.map(e=>e.path)),files:e.files.map(e=>({path:e.path,status:e.status,additions:e.additions,deletions:e.deletions,old_string:e.oldContent??"",new_string:e.newContent??"",unviewable:e.binary||null===e.oldContent&&null===e.newContent,external:t.size>0&&!t.has(e.path),fileClass:j(e.path)}))}});return r.length>0?r:N(t,n)}function L({additions:e,deletions:t}){return(0,r.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,r.jsxs)("span",{className:"text-green-11",children:["+",e]}),(0,r.jsxs)("span",{className:"text-red-11",children:["-",t]})]})}function E({cls:e}){return(0,r.jsx)("span",{className:`text-[10px] px-1 py-px rounded flex-shrink-0 ${"test"===e?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400/80":"bg-sky-500/15 text-sky-600 dark:text-sky-400/80"}`,children:e})}function M(e){let t=new Date(1e3*e),n=new Date,r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),o=`${r}-${s} ${l}:${a}`;return t.getFullYear()===n.getFullYear()?o:`${t.getFullYear()}-${o}`}function R({toolCalls:e,cwd:t,onClose:n,onContentSearch:d}){let{t:w}=(0,l.Bd)(),k=(0,s.useRef)(null),[j,C]=(0,s.useState)(null);(0,s.useEffect)(()=>{C(k.current)},[]);let T=(0,s.useMemo)(()=>e.map(e=>e.id).filter(Boolean),[e]),$=T.join(","),[I,P]=(0,s.useState)(0),A=(0,o.Z)(t&&T.length>0?(0,y.se)(t,T):a.succeed([]),[t,$,I]),_=(0,s.useMemo)(()=>e.filter(e=>["Edit","Write","MultiEdit","NotebookEdit"].includes(e.name)).map(e=>e.id),[e]);(0,s.useEffect)(()=>{if("success"!==A.status||I>=2)return;let e=new Set(A.data.map(e=>e.commit.toolId));if(_.some(t=>!e.has(t))){let e=setTimeout(()=>P(e=>e+1),2e3);return()=>clearTimeout(e)}},[A,I,_]);let D=(0,s.useRef)([]),F="loading"===A.status&&0===D.current.length,W=(0,s.useMemo)(()=>{if("success"===A.status){let n=S(A.data,e,t);return n.length>0&&(D.current=n),n}return"loading"===A.status&&D.current.length>0?D.current:"loading"===A.status?[]:N(e,t)},[A,e,t]),[B,V]=(0,s.useState)(null),[O,z]=(0,s.useState)(null),[H,U]=(0,s.useState)(new Set),[K,q]=(0,s.useState)(()=>window.innerWidth>=768),[Z,X]=(0,s.useState)("compact"),[G,J]=(0,s.useState)("split"),[Y,Q]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),en=(0,s.useMemo)(()=>W.find(e=>e.key===B)??null,[W,B]),er=(0,s.useRef)(null);(0,s.useEffect)(()=>{en&&(er.current=en)},[en]);let es=en??er.current,el=(0,s.useMemo)(()=>es?(0,f.Do)(es.files):[],[es]),ea=(0,s.useMemo)(()=>es?.files.find(e=>e.path===O)??null,[es,O]),eo=(0,s.useCallback)(e=>{V(e.key),z(e.files[0]?.path??null),U(new Set((0,f.Sz)((0,f.Do)(e.files))))},[]);(0,s.useEffect)(()=>{W.length>0&&null==B&&eo(W[0])},[W,B,eo]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(Y)return void Q(!1);if(ee)return void et(null);(0,i.k)(),n()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n,Y,ee]);let ei=(0,s.useMemo)(()=>W.reduce((e,t)=>e+t.files.length,0),[W]),ec=e=>(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:e});return(0,r.jsx)(c.SU,{container:j,children:(0,r.jsxs)("div",{ref:k,className:"relative bg-card shadow-xl w-full h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:()=>q(e=>!e),"aria-label":w("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${K?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:(0,r.jsx)(u.A,{className:"w-4 h-4"})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:w("diffViewer.fileChanges",{count:ei})})]}),(0,r.jsx)("button",{onClick:n,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[K&&(0,r.jsx)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:W.map(e=>{let t;return(0,r.jsxs)("div",{onClick:()=>eo(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${B===e.key?"bg-brand/10":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.shortHash&&(0,r.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),void 0!==e.timestamp&&(0,r.jsx)("span",{className:"text-xs text-slate-9",children:M(e.timestamp)}),e.changeClass&&(0,r.jsx)("span",{className:"ml-auto",children:(0,r.jsx)(E,{cls:e.changeClass})})]}),(0,r.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":e.subject,children:e.subject}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:w("commitDetail.nChanges",{count:e.files.length})}),(t=function(e){let t=!1,n=0,r=0;for(let s of e.files)(void 0!==s.additions||void 0!==s.deletions)&&(t=!0),n+=s.additions??0,r+=s.deletions??0;return t?{additions:n,deletions:r}:null}(e))&&(t.additions>0||t.deletions>0)?(0,r.jsx)(L,{additions:t.additions,deletions:t.deletions}):null]})]},e.key)})}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:F?ec(w("diffViewer.loadingSnapshots")):0===W.length?ec(w("diffViewer.noChanges")):es?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,r.jsx)(m.A,{className:"w-3.5 h-3.5"}),es.toolName]}),es.shortHash&&(0,r.jsx)("span",{className:"font-mono text-brand",children:es.shortHash}),void 0!==es.timestamp&&(0,r.jsx)("span",{children:M(es.timestamp)}),(0,r.jsx)("span",{className:"flex-1 min-w-0 truncate","data-tooltip":es.subject,children:es.subject}),es.truncated&&(0,r.jsx)("span",{className:"text-amber-500",children:w("diffViewer.truncated")}),es.legacy&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":w("diffViewer.reconstructedHint"),children:w("diffViewer.reconstructed")}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,r.jsx)(x.y,{value:Z,onChange:X}),(0,r.jsx)(p,{value:G,onChange:J})]})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[K&&(0,r.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:(0,r.jsx)(f.VO,{files:el,selectedPath:O,expandedPaths:H,onToggle:e=>U(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{!e.isDirectory&&e.file&&(z(e.file.path),window.innerWidth<768&&q(!1))},cwd:t||"",showChanges:!0,renderActions:e=>{if(e.isDirectory)return null;let t=e.file;return t?(0,r.jsxs)(r.Fragment,{children:[t.fileClass&&(0,r.jsx)(E,{cls:t.fileClass}),t.external&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":w("diffViewer.externalChange")})]}):null}})}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:ea?ea.unviewable?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:w("diffViewer.notViewable")}):"unified"===G?(0,r.jsx)(g.xU,{oldContent:ea.old_string,newContent:ea.new_string,filePath:ea.path,compact:"compact"===Z}):(0,r.jsx)(g.xZ,{oldContent:ea.old_string,newContent:ea.new_string,filePath:ea.path,isNew:"added"===ea.status,isDeleted:"deleted"===ea.status,cwd:t,enableComments:!0,onContentSearch:d,compact:"compact"===Z,onPreview:"deleted"===ea.status?void 0:(0,b.e$)(ea.path)?()=>Q(!0):ea.path.endsWith(".json")?()=>et({content:ea.new_string,filePath:ea.path}):void 0,previewLabel:ea.path.endsWith(".json")?w("common.readable"):w("common.preview")}):(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:w("diffViewer.selectFileToView")})})]})]}):ec(w("diffViewer.selectFileToView"))})]}),Y&&ea&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50 p-2 md:p-4",onClick:()=>Q(!1),children:(0,r.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(v.M,{content:ea.new_string,filePath:ea.path,cwd:t||"",onClose:()=>Q(!1)})})}),ee&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50 p-2 md:p-4",onClick:()=>et(null),children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:ee.filePath}),(0,r.jsx)("button",{onClick:()=>et(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)(h.A,{className:"w-4 h-4"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,b.xb)(ee.content)})})]})})]})})}function T({toolCalls:e,cwd:t,onClose:n,onContentSearch:s}){return(0,r.jsx)(d.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:n,children:(0,r.jsx)(R,{toolCalls:e,cwd:t,onClose:n,onContentSearch:s?e=>{n(),s(e)}:void 0})})})}},67362:(e,t,n)=>{n.d(t,{xU:()=>j,xZ:()=>k});var r=n(95155),s=n(12115),l=n(47650),a=n(79114),o=n(64702),i=n(1058),c=n(90717),d=n(70188),u=n(48347),h=n(89109),m=n(7320),f=n(22576),x=n(34075),p=n(56978),g=n(17196);function b({lines:e,containerRef:t}){let n=(0,s.useRef)(null),[l,a]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:s}=e,l=n.current?.clientHeight||0;if(r<=s)a({top:0,height:l});else{let e=l/r;a({top:t*e,height:s*e})}};return r(),e.addEventListener("scroll",r),window.addEventListener("resize",r),()=>{e.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[t]),0===e.length)return null;let o=100/e.length;return(0,r.jsxs)("div",{ref:n,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let r=t.current,s=n.current;if(!r||!s)return;let l=s.getBoundingClientRect(),a=(e.clientY-l.top)/l.height*r.scrollHeight-r.clientHeight/2;r.scrollTo({top:Math.max(0,a),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,r.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*o}%`,height:`${Math.max(o,.5)}%`,minHeight:"2px"}},t)),(0,r.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${l.top}px`,height:`${Math.max(l.height,10)}px`}})]})}var v=n(37614),y=n(27570);function w(e){return e.params?`${e.name}(${e.params.join(", ")})`:e.name}function k({oldContent:e,newContent:t,filePath:n,isNew:j=!1,isDeleted:C=!1,cwd:N,enableComments:S=!1,onPreview:L,previewLabel:E,onContentSearch:M,targetLine:R,compact:T=!1,symbols:$}){let{t:I}=(0,a.Bd)(),P=E??I("common.preview"),A=(0,s.useMemo)(()=>(0,f.X)(e,t),[e,t]),_=(0,s.useRef)(null),D=(0,s.useRef)(null),F=(0,s.useRef)(null),W=(0,s.useRef)(!1),[B,V]=(0,s.useState)(!1),O=(0,d.iN)(),z=(0,u.r)(),H=S&&!!N,{comments:U,addComment:K,updateComment:q,deleteComment:Z,refresh:X}=(0,i._)({cwd:N||"",filePath:n}),[G,J]=(0,s.useState)(null),[Y,Q]=(0,s.useState)(null);(0,s.useEffect)(()=>{F.current!==Y&&Q(F.current)});let{toolbarRef:ee,bumpRef:et,clearToolbar:en}=(0,y.L)({enabled:H,container:Y,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-new-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-new-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>{let n=[],r=0;for(let s of A)("unchanged"===s.type||"added"===s.type)&&++r>=e&&r<=t&&n.push(s.content);return n.join("\n")}}),[er,es]=(0,s.useState)(null),[el,ea]=(0,s.useState)(null);(0,s.useEffect)(()=>{V(!0)},[]);let eo=(0,s.useMemo)(()=>{let e=new Set;for(let t of U)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[U]),ei=(0,s.useMemo)(()=>{let e=new Map;for(let t of U){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[U]),ec=(0,s.useCallback)((e,t)=>{t.stopPropagation(),J({comment:e,x:t.clientX,y:t.clientY}),en(),es(null),ea(null)},[en]),ed=(0,s.useCallback)(()=>{let e=ee.current;e&&(es({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),en())},[en,ee]),eu=(0,s.useCallback)(()=>{let e=ee.current;e&&(ea({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),en())},[en,ee]),eh=(0,s.useCallback)(()=>{let e=ee.current;if(!e||!M)return;let t=e.selectedText.trim();en(),t&&M(t)},[M,en,ee]),em=(0,s.useCallback)(async(e,t)=>{if(z&&N)try{let r=await (0,c.$3)(N),s=[];for(let e of r)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:n,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let l=(0,c.Gw)(s,t);z.sendMessage(l),await (0,c.RP)(N),X()}catch(e){console.error("Failed to send to AI:",e)}},[z,n,N,X]),ef=(0,s.useCallback)(e=>{el&&em(el,e)},[el,em]),ex=(0,s.useCallback)(e=>{er&&em(er,e)},[er,em]),ep=(0,s.useCallback)(async e=>{er&&(await K(er.range.start,er.range.end,e,er.selectedText),es(null))},[er,K]);(0,s.useEffect)(()=>{let e=D.current,t=F.current;if(!e||!t)return;let n=(e,t)=>{W.current||(W.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{W.current=!1}))},r=()=>n(e,t),s=()=>n(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",s)}},[]);let{leftLines:eg,rightLines:eb}=(0,s.useMemo)(()=>{let e=[],t=[],n=0,r=0;for(let s=0;s<A.length;s++){let l=A[s];if("unchanged"===l.type){for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});n++,r++,e.push({lineNum:n,content:l.content,type:"unchanged",originalIdx:s}),t.push({lineNum:r,content:l.content,type:"unchanged",originalIdx:s})}else"removed"===l.type?(n++,e.push({lineNum:n,content:l.content,type:"removed",originalIdx:s})):"added"===l.type&&(r++,t.push({lineNum:r,content:l.content,type:"added",originalIdx:s}))}for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:e,rightLines:t}},[A]),ev=(0,s.useMemo)(()=>A.map(e=>e.content),[A]),ey=(0,p.C)(ev,n),[ew,ek]=(0,s.useState)(()=>new Map);(0,s.useLayoutEffect)(()=>{ek(new Map),eR.measure()},[eg,eb]);let ej=(0,s.useMemo)(()=>$??[],[$]),{rows:eC,gaps:eN}=(0,s.useMemo)(()=>T?function(e,t,n,r=[]){let s=e.length,l=n=>"unchanged"!==e[n].type||"unchanged"!==t[n].type,a=new Set;for(let e=0;e<s;e++){if(!l(e))continue;let t=Math.max(0,e-3),n=Math.min(s-1,e+3);for(let e=t;e<=n;e++)a.add(e)}let o=[];for(let e=0;e<s;e++){if(a.has(e))continue;let t=e;for(;e<s&&!a.has(e);)e++;o.push({id:o.length,startIdx:t,endIdx:e-1}),e--}for(let e of o){let t=n.get(e.id)??{topRevealed:0,bottomRevealed:0},r=e.endIdx-e.startIdx+1,s=Math.max(0,Math.min(t.topRevealed,r)),l=Math.max(0,Math.min(t.bottomRevealed,r-s));for(let t=e.startIdx;t<e.startIdx+s;t++)a.add(t);for(let t=e.endIdx-l+1;t<=e.endIdx;t++)a.add(t)}let i=[];for(let e=0;e<s;e++){let n;if(a.has(e)){i.push({kind:"diff",idx:e});continue}let l=e;for(;e<s&&!a.has(e);)e++;let c=e-1;e--;let d=o.find(e=>e.startIdx<=l&&c<=e.endIdx);if(!d)continue;let u=c-l+1,h=Math.min(20,u);if(r.length>0&&c+1<s)for(let e=c+1;e<s;e++){let s=t[e].lineNum;if(!(s<=0)){n=function(e,t){let n=null;for(let r of e)r.startLine<=t&&t<=r.endLine&&(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r);return n}(r,s)??void 0;break}}i.push({kind:"gap-expand",gapId:d.id,direction:"up",revealCount:h}),i.push({kind:"gap-label",gapId:d.id,hiddenCount:u,enclosingFn:n}),i.push({kind:"gap-expand",gapId:d.id,direction:"down",revealCount:h})}return{rows:i,gaps:o}}(eg,eb,ew,ej):{rows:eg.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[T,eg,eg,eb,ew,ej]),eS=(0,s.useCallback)((e,t)=>{let n=eN.find(t=>t.id===e);n&&ek(r=>{let s=r.get(e)??{topRevealed:0,bottomRevealed:0},l=n.endIdx-n.startIdx+1-s.topRevealed-s.bottomRevealed;if(l<=0)return r;let a=Math.min(20,l),o="up"===t?{...s,topRevealed:s.topRevealed+a}:{...s,bottomRevealed:s.bottomRevealed+a};return new Map(r).set(e,o)})},[eN]),eL=(0,s.useCallback)(e=>{for(let t of eN)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[eN]),eE=(0,s.useCallback)(e=>eC[e]?.kind==="gap-label"?28:20,[eC]),eM=(0,s.useCallback)(e=>{let t=eC[e];if(!t)return e;if("gap-label"===t.kind)return`gl:${t.gapId}`;if("gap-expand"===t.kind)return`ge:${t.gapId}:${t.direction}`;let n=eg[t.idx],r=eb[t.idx];return`d:${n?.lineNum??"x"}:${n?.type??"x"}:${r?.lineNum??"x"}:${r?.type??"x"}`},[eC,eg,eb]),eR=(0,o.Te)({count:eC.length,getScrollElement:()=>_.current,estimateSize:eE,getItemKey:eM,overscan:20}),eT=j?"w-1/4":C?"w-3/4":"w-1/2",e$=j?"w-3/4":C?"w-1/4":"w-1/2",eI=(0,s.useMemo)(()=>eC.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=eg[e.idx],n=eb[e.idx];return"removed"===t.type?{type:"removed"}:n?.type==="added"?{type:"added"}:{type:"unchanged"}}),[eC,eg,eb]),eP=eR.getTotalSize(),eA=eR.getVirtualItems();return(0,s.useEffect)(()=>{if(!R)return;let e=("after"===R.side?eb:eg).findIndex(e=>e.lineNum===R.line);if(-1===e)return;let t=eC.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eL(e);if(null!==t){let e=eN.find(e=>e.id===t);if(!e)return;let n=e.endIdx-e.startIdx+1;ek(e=>{let r=e.get(t)??{topRevealed:0,bottomRevealed:0};if(r.topRevealed+r.bottomRevealed>=n)return e;let s=new Map(e);return s.set(t,{topRevealed:n,bottomRevealed:0}),s})}return}let n=requestAnimationFrame(()=>{eR.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(n)},[R,eg,eb,eC]),(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,r.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,r.jsx)("div",{className:`${eT} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:j?"(New File)":C?"Deleted":"Old"}),(0,r.jsxs)("div",{className:`${e$} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,r.jsx)("span",{className:"block text-center",children:C?"(Deleted)":"New"}),(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[L&&(0,r.jsx)("button",{onClick:L,className:"text-muted-foreground hover:text-foreground transition-colors",children:P}),!C&&t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,x.oR)(I("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:I("common.copy")})]})]}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:_,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"flex",style:{height:`${eP}px`},children:[(0,r.jsx)("div",{ref:D,className:`${eT} overflow-x-auto border-r border-border`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eA.map(e=>{let t=eC[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let n="gap-label"===t.kind;return(0,r.jsx)("div",{ref:eR.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:n?"bg-accent border-y border-border":""},e.key)}let n=eg[t.idx];return(0,r.jsxs)("div",{ref:eR.measureElement,"data-index":e.index,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===n.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:n.lineNum||""}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:n.originalIdx>=0&&ey[n.originalIdx]||(0,g.ZD)(n.content||" ")}})]},e.key)})})}),(0,r.jsx)("div",{ref:F,className:`${e$} overflow-x-auto`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eA.map(e=>{let t=eC[e.index];if("gap-expand"===t.kind)return(0,r.jsx)("button",{ref:eR.measureElement,"data-index":e.index,type:"button",onClick:()=>eS(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-accent hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,r.jsx)("span",{className:"select-none",children:I("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,r.jsxs)("div",{ref:eR.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:I("diffViewer.gap.hidden",{count:t.hiddenCount})}),t.enclosingFn&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,r.jsx)("span",{className:"truncate min-w-0 font-medium",title:w(t.enclosingFn),children:w(t.enclosingFn)})]})]},e.key);let n=eb[t.idx],s=n?.lineNum||0,l=s>0&&eo.has(s),a=ei.get(s),o=a?.[0],i=er&&s>=er.range.start&&s<=er.range.end,c=el&&s>=el.range.start&&s<=el.range.end,d=i||c;return(0,r.jsxs)("div",{ref:eR.measureElement,"data-index":e.index,"data-new-line":s||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eE(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${d?"bg-blue-9/20":l?"bg-amber-9/10":n?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,r.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${d?"bg-blue-9/30":""}`,style:{width:H?"52px":"40px"},children:[H&&s>0&&l&&o&&(0,r.jsx)("button",{onClick:e=>ec(o,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:I("codeViewer.nComments",{count:a?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),H&&s>0&&!l&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"flex-1 text-right pr-1",children:s||""})]}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:n?.originalIdx>=0&&ey[n.originalIdx]||(0,g.ZD)(n?.content||" ")}})]},e.key)})})})]})}),(0,r.jsx)(b,{lines:eI,containerRef:_})]}),B&&O&&(0,l.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.f,{floatingToolbarRef:ee,bumpRef:et,container:O,onAddComment:ed,onSendToAI:eu,onSearch:M?eh:void 0,isChatLoading:z?.isLoading??!1}),er&&(0,r.jsx)(m.t,{x:er.x,y:er.y,range:er.range,filePath:n,lineSnapshot:er.lineSnapshot,container:O,onSubmit:ep,onSendToAI:z?ex:void 0,onClose:()=>es(null),isChatLoading:z?.isLoading}),el&&(0,r.jsx)(m.G,{x:el.x,y:el.y,range:el.range,filePath:n,lineSnapshot:el.lineSnapshot,container:O,onSubmit:ef,onClose:()=>ea(null),isChatLoading:z?.isLoading}),G&&(0,r.jsx)(v.t,{x:G.x,y:G.y,comment:G.comment,container:O,onClose:()=>J(null),onUpdateComment:q,onDeleteComment:Z})]}),O)]})}function j({oldContent:e,newContent:t,filePath:n,compact:l=!1}){let{t:i}=(0,a.Bd)(),c=(0,s.useMemo)(()=>(0,f.X)(e,t),[e,t]),d=(0,s.useRef)(null),u=(0,s.useMemo)(()=>c.map(e=>e.content),[c]),h=(0,p.C)(u,n),[m,x]=(0,s.useState)(()=>new Set);(0,s.useEffect)(()=>{x(new Set)},[e,t,n]);let b=(0,s.useMemo)(()=>l?function(e,t){let n=e.length,r=Array(n).fill(!1);for(let t=0;t<n;t++){if("unchanged"===e[t].type)continue;let s=Math.max(0,t-3),l=Math.min(n-1,t+3);for(let e=s;e<=l;e++)r[e]=!0}let s=[],l=0,a=0;for(;a<n;){if(r[a]){s.push({kind:"line",line:e[a],index:a}),a++;continue}let o=a;for(;o<n&&!r[o];)o++;let i=l++;if(t.has(i))for(let t=a;t<o;t++)s.push({kind:"line",line:e[t],index:t});else s.push({kind:"gap",id:i,count:o-a});a=o}return s}(c,m):c.map((e,t)=>({kind:"line",line:e,index:t})),[l,c,m]),v=(0,s.useCallback)(e=>{let t=b[e];if(!t)return e;if("gap"===t.kind)return`gap:${t.id}`;let n=t.line;return`${n.type}:${n.oldLineNum??"x"}:${n.newLineNum??"x"}`},[b]),y=(0,o.Te)({count:b.length,getScrollElement:()=>d.current,estimateSize:()=>20,getItemKey:v,overscan:20});return(0,r.jsx)("div",{ref:d,className:"font-mono text-sm overflow-auto h-full",children:(0,r.jsx)("div",{style:{height:`${y.getTotalSize()}px`,position:"relative"},children:y.getVirtualItems().map(e=>{let t=b[e.index];if(!t)return null;let n={position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`};if("gap"===t.kind){let s=i("diffViewer.gap.hidden",{count:t.count});return(0,r.jsx)("div",{style:n,onClick:()=>x(e=>new Set(e).add(t.id)),className:"flex items-center cursor-pointer bg-slate-2 hover:bg-accent border-y border-border text-xs text-slate-9 select-none",title:s,children:(0,r.jsx)("span",{className:"w-full text-center",children:s})},e.key)}let s=t.line;return(0,r.jsxs)("div",{style:n,className:`flex ${"removed"===s.type?"bg-red-9/15 dark:bg-red-9/25":"added"===s.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==s.type?s.oldLineNum:""}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==s.type?s.newLineNum:""}),(0,r.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===s.type?"text-red-11":"added"===s.type?"text-green-11":"text-slate-9"}`,children:"removed"===s.type?"-":"added"===s.type?"+":" "}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:h[t.index]||(0,g.ZD)(s.content||" ")}})]},e.key)})})})}},67589:(e,t,n)=>{n.d(t,{z:()=>o,m:()=>c});var r=n(12115),s=n(49433),l=n(86957),a=n(82680);let o=e=>s.tryPromise({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new a.uV({message:"session-by-path failed",cause:e})}),i=new Map;function c(e,t,n,{cwd:d,initialSessionId:u,onSessionId:h,onTitleChange:m,onTokenUsage:f,liveRunningRef:x}){let[p,g]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[k,j]=(0,r.useState)(void 0),[C,N]=(0,r.useState)(0),[S,L]=(0,r.useState)(null),[E,M]=(0,r.useState)(null),R=(0,r.useRef)(m);R.current=m;let T=(0,r.useRef)(f);T.current=f;let $=(0,r.useRef)(void 0),I=(0,r.useRef)(0),P=(0,r.useCallback)(async(e,n,r=!1,s,a,c=!1)=>{if(r){let e=Date.now();if(!c&&e-I.current<5e3)return;I.current=e}let d=(e,r)=>{e.fingerprint&&($.current=e.fingerprint),void 0!==e.totalTurns&&N(e.totalTurns),void 0!==e.hasMore&&w(e.hasMore),e.messages&&e.messages.length>0&&(r?t(t=>(function(e,t){if(0===t.length)return e;let n=0;if(e.length>0&&e[0].id!==t[0].id){n=-1;for(let r=e.length-1;r>=0;r--)if(e[r].id===t[0].id){n=r;break}}if(n<0)return t;let r=e.slice(n),s=0;for(let e=0;e<Math.min(r.length,t.length)&&r[e].id===t[e].id&&r[e].content===t[e].content;e++)s=e+1;return s===r.length&&s===t.length?e:s===r.length&&s<t.length?[...e,...t.slice(s)]:[...e.slice(0,n),...r.slice(0,s),...t.slice(s)]})(t,e.messages)):x?.current||t(e.messages),L(n)),e.sessionId&&h(e.sessionId),e.engine&&M(e.engine),e.title&&R.current?.(e.title),e.usage&&T.current?.({inputTokens:e.usage.input_tokens||0,outputTokens:e.usage.output_tokens||0,cacheCreationInputTokens:e.usage.cache_creation_input_tokens||0,cacheReadInputTokens:e.usage.cache_read_input_tokens||0,totalCostUsd:0})},u=`${e}::${n}`,m=!r&&void 0===a,f=m?i.get(u):void 0;r||(f?d(f.data,!1):g(!0));try{let t={cwd:e,sessionId:n,limit:s,beforeTurnIndex:a};r&&$.current?t.ifFingerprint=$.current:f&&(t.ifFingerprint=f.fingerprint);let c=await l.t4.runPromiseExit(o(t));if("Success"===c._tag&&c.value){let e=c.value;if(e.notModified)return;if(d(e,r),m&&e.fingerprint&&e.messages&&e.messages.length>0&&(i.delete(u),i.set(u,{data:e,fingerprint:e.fingerprint}),i.size>20)){let e=i.keys().next().value;void 0!==e&&i.delete(e)}}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{r||g(!1)}},[t,h]),A=(0,r.useCallback)(async()=>{if(d&&n&&!b&&y){v(!0);try{let r=void 0!==k?k:C-Math.ceil(e.filter(e=>"user"===e.role).length),s=await l.t4.runPromiseExit(o({cwd:d,sessionId:n,limit:10,beforeTurnIndex:r>0?r:void 0}));if("Success"===s._tag&&s.value){let e=s.value;if(e.messages&&e.messages.length>0){t(t=>[...e.messages,...t]);let s=e.messages.filter(e=>"user"===e.role).length;j(r-s),L(n)}void 0!==e.hasMore&&w(e.hasMore),e.fingerprint&&($.current=e.fingerprint)}else"Failure"===s._tag&&console.error("Failed to load more history:",s.cause)}finally{v(!1)}}},[d,n,b,y,k,C,e,t]),_=(0,r.useCallback)(async e=>{g(!0);let n=s.tryPromise({try:async()=>{let t=await fetch(`/api/session/${e}/history`);return t.ok?await t.json():null},catch:e=>new a.uV({message:"load session history failed",cause:e})}),r=await l.t4.runPromiseExit(n);"Success"===r._tag&&r.value?.messages&&r.value.messages.length>0?(t(r.value.messages),L(e)):"Failure"===r._tag&&console.error("Failed to load history:",r.cause),g(!1)},[t]);return(0,r.useEffect)(()=>{d&&u&&P(d,u,!1,10)},[]),{isLoadingHistory:p,isLoadingMore:b,hasMoreHistory:y,loadMoreHistory:A,loadHistory:_,loadHistoryByCwdAndSessionId:P,loadedSessionId:S,loadedEngine:E}}},70188:(e,t,n)=>{n.d(t,{Ee:()=>h,SU:()=>c,ft:()=>u,iN:()=>d});var r=n(95155),s=n(12115),l=n(79114),a=n(47650),o=n(34075);let i=(0,s.createContext)(null);function c({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function d(){return(0,s.useContext)(i)}function u({x:e,y:t,path:n,cwd:c,isDirectory:d,onClose:h,onCreateFile:m,onDelete:f,onRefresh:x,onCopyFile:p,onPaste:g}){let{t:b}=(0,l.Bd)(),v=(0,s.useRef)(null),y=(0,s.useContext)(i),w=n.split("/").pop()||n,k=`${c}/${n}`,j=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",C=j?`${c}/${j}`:c,N=d?n:j,S=d?k:C;(0,s.useEffect)(()=>{let e=e=>{v.current&&!v.current.contains(e.target)&&h()},t=e=>{"Escape"===e.key&&h()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[h]);let[L,E]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(v.current&&y){let n=y.getBoundingClientRect(),r=v.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s=Math.min(s,n.width-r.width-8),l=Math.min(l,n.height-r.height-8),E({x:s=Math.max(8,s),y:l=Math.max(8,l)})}else if(v.current){let n=v.current.getBoundingClientRect();E({x:Math.max(8,Math.min(e,window.innerWidth-n.width-8)),y:Math.max(8,Math.min(t,window.innerHeight-n.height-8))})}},[e,t,y]);let M=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),(0,o.oR)(b("toast.copiedName",{name:t}),"success")}catch{(0,o.oR)(b("toast.copyFailed"),"error")}h()},[h,b]),R=d?n:j,T=[{label:b("fileContextMenu.copyRelativePath"),value:n},{label:b("fileContextMenu.copyAbsolutePath"),value:k},{label:b("fileContextMenu.copyRelativeDirPath"),value:N||"."},{label:b("fileContextMenu.copyAbsoluteDirPath"),value:S},{label:d?b("fileContextMenu.copyFolderName"):b("fileContextMenu.copyFileName"),value:w}],$=(0,r.jsxs)("div",{ref:v,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lg py-1 w-fit whitespace-nowrap",style:{left:L.x,top:L.y},children:[m&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{h(),m(R)},children:b("fileContextMenu.createFile")}),p&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{h(),p(n)},children:d?b("fileContextMenu.copyFolder"):b("fileContextMenu.copyFile")}),g&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{h(),g(R)},children:b("fileContextMenu.pasteHere")}),f&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-accent transition-colors",onClick:()=>{h(),f(n,d,w)},children:d?b("fileContextMenu.deleteFolder"):b("fileContextMenu.deleteFile")}),(m||f||p||g)&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),T.map((e,t)=>(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>M(e.value,e.label),children:e.label},t))]});return y?(0,a.createPortal)($,y):$}function h(){let[e,t]=(0,s.useState)(null);return{contextMenu:e,showContextMenu:(0,s.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,s.useCallback)(()=>{t(null)},[])}}},73395:(e,t,n)=>{n.d(t,{M:()=>ed});var r=n(95155),s=n(12115),l=n(83897),a=n(64428),o=n(34075),i=n(12651),c=n(81165),d=n(16950),u=n(11019),h=n(12612),m=n(79114),f=n(86957),x=n(67589);function p({cwd:e,sessionId:t,toolCall:n,workflowRef:l,onClose:o}){let{t:i}=(0,m.Bd)(),[c,d]=(0,s.useState)(null),[u,h]=(0,s.useState)(null),[g,b]=(0,s.useState)(!1),v=(0,s.useRef)(void 0),y=l?!!l.running:!n?.result,w=(0,s.useCallback)(async()=>{let r=await f.t4.runPromiseExit((0,x.z)({cwd:e,sessionId:t,...l?{workflowId:l.runId,workflowAgentId:l.agentId}:{toolUseId:n?.id},ifFingerprint:v.current}));if(b(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(v.current=s.fingerprint),!s.notModified&&(s.messages&&d(s.messages),s.subagent&&h(s.subagent))},[e,t,n?.id,l?.runId,l?.agentId]);(0,s.useEffect)(()=>{if(w(),!y)return;let e=setInterval(w,5e3);return()=>clearInterval(e)},[y,w]);let k=(0,s.useRef)(null),j=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let e=k.current;e&&j.current&&(e.scrollTop=e.scrollHeight)},[c]);let C="string"==typeof n?.input?.description?n.input.description:"",N=l?l.label||"":[u?.agentType,C].filter(Boolean).join(" \xb7 ");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:o,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDD16"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.subagent")}),N&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:N,children:N}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:o,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{ref:k,onScroll:()=>{let e=k.current;e&&(j.current=e.scrollTop+e.clientHeight>=e.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(g?"chat.subagentEmpty":"common.loading")}):c.map(t=>(0,r.jsx)(el,{message:t,cwd:e},t.id))})]})})})}function g(e){return e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):"0"}function b(e){if(!e)return"–";let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return`${n}m${t%60}s`}let v={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function y({cwd:e,sessionId:t,runId:n,isRunning:l,onClose:o}){let{t:i}=(0,m.Bd)(),[c,d]=(0,s.useState)(null),[u,h]=(0,s.useState)(!1),[v,k]=(0,s.useState)(null),j=(0,s.useRef)(void 0),C=l||null!=c&&"completed"!==c.status&&"failed"!==c.status,N=(0,s.useCallback)(async()=>{let r=await f.t4.runPromiseExit((0,x.z)({cwd:e,sessionId:t,workflowId:n,ifFingerprint:j.current}));if(h(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(j.current=s.fingerprint),!s.notModified&&s.workflow&&d(s.workflow)},[e,t,n]);(0,s.useEffect)(()=>{if(N(),!C)return;let e=setInterval(N,5e3);return()=>clearInterval(e)},[C,N]);let S=[];if(c?.agents){let e=new Map;for(let t of c.agents){let n=t.phaseTitle||i("chat.workflowUngrouped");e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let[t,n]of e)S.push({title:t,agents:n})}let L=c?[c.workflowName,c.status,`${c.agentCount??c.agents?.length??0} ${i("chat.workflowAgents")}`,`${g(c.totalTokens)} tok`,b(c.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,r.jsxs)(a.ZL,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:o,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.workflowRun")}),L&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:L,children:L}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[C&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:o,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(u?"chat.workflowEmpty":"common.loading")}):(0,r.jsxs)(r.Fragment,{children:[c.summary&&(0,r.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:c.summary}),S.map(e=>(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:e.title}),e.agents.map(e=>(0,r.jsx)(w,{agent:e,onOpen:()=>e.agentId&&k({runId:n,agentId:e.agentId,label:e.label,running:"done"!==e.state&&C})},`${e.index}-${e.agentId}`))]},e.title))]})})]})}),v&&(0,r.jsx)(p,{cwd:e,sessionId:t,workflowRef:v,onClose:()=>k(null)})]})}function w({agent:e,onOpen:t}){let{t:n}=(0,m.Bd)(),[l,a]=(0,s.useState)(!1),o=e.state&&v[e.state]||"text-muted-foreground",i=e.resultPreview||e.promptPreview||"";return(0,r.jsxs)("div",{className:"border border-border rounded-md mb-1 bg-secondary/50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,r.jsx)("button",{onClick:()=>a(e=>!e),className:"text-slate-9 text-xs flex-shrink-0",title:n(l?"chat.collapse":"chat.expand"),children:l?"▲":"▼"}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0",title:e.label||"",children:e.label||e.agentId}),(0,r.jsx)("span",{className:`text-[10px] flex-shrink-0 ${o}`,children:e.state}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[g(e.tokens)," tok \xb7 ",b(e.durationMs)]}),e.agentId&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:t,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&t()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:n("chat.subagentViewTitle"),children:n("chat.workflowViewAgent")})]}),l&&i&&(0,r.jsx)("pre",{className:"text-[11px] bg-secondary px-2 py-1.5 rounded-b overflow-x-auto max-h-32 overflow-y-auto text-muted-foreground whitespace-pre-wrap border-t border-border",children:i})]})}var k=n(60938),j=n(67362),C=n(38408),N=n(13219),S=n(47176),L=n(97251),E=n(56045),M=n(50860),R=n(47215);function T({filePath:e}){let[t,n]=(0,s.useState)(null),[l,a]=(0,s.useState)(!0),[o,i]=(0,s.useState)(null),c=(0,s.useRef)(!1),d=(0,R.e$)(e),u=(0,R.u)(e);return((0,s.useEffect)(()=>{u?a(!1):c.current||(c.current=!0,(async()=>{a(!0),i(null);let t=await f.t4.runPromiseExit((0,k.nM)(e));if("Success"===t._tag)n(t.value.content??null);else{let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;i(n instanceof Error?n.message:"Failed to load file")}a(!1),c.current=!1})())},[e,u]),o)?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-xs text-red-11",children:o})}):l?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,R.u)(e)?(0,r.jsx)(M.I,{absPath:e,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:e.split("/").pop()||"image"}):t?d?(0,r.jsx)(I,{content:t}):(0,r.jsx)(C.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}let $=[L.W];function I({content:e}){let t=(0,s.useRef)(null);return(0,r.jsxs)("div",{className:"h-full flex",children:[(0,r.jsx)(S.l,{content:e,containerRef:t}),(0,r.jsx)("div",{ref:t,className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(N.T,{content:e,rehypePlugins:$})})]})}function P({title:e,content:t,toolName:n,onClose:l}){let{t:i}=(0,m.Bd)(),c=(0,R.jU)(t),d=(0,R.zs)(t),u=(0,R.oK)(t),h=!!d,f=!!u,[x,p]=(0,s.useState)(("Read"===n||"Write"===n)&&f?"file":h?"diff-unified":c?"readable":"json"),g=(0,s.useRef)(null),b=(0,E.o)(g);(0,s.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===x&&c){e.preventDefault(),b.open();return}if("Escape"===e.key){if(b.isVisible)return void b.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l,x,c,b]);let v=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:l,children:(0,r.jsxs)("div",{className:"bg-card shadow-xl w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:e}),u&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(u),(0,o.oR)(i("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:i("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[c&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>p("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.sideBySide"),children:"Split"}),(0,r.jsx)("button",{onClick:()=>p("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.unified"),children:"Unified"})]}),f&&(0,r.jsx)("button",{onClick:()=>p("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.previewFile"),children:"File"}),(0,r.jsx)("button",{onClick:()=>p("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("common.readable")}),(0,r.jsx)("button",{onClick:()=>p("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===x?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,r.jsx)("button",{onClick:l,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===x&&u?(0,r.jsx)(T,{filePath:u}):"diff-unified"===x&&d?(0,r.jsx)(j.xU,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"diff-split"===x&&d?(0,r.jsx)(j.xZ,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"readable"===x&&c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E._,{search:b}),(0,r.jsx)("pre",{ref:g,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,R.xb)(t)})]}):(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:c?(0,R.C6)(t):t})})]})});return(0,r.jsx)(a.ZL,{children:v})}let A={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function _({toolCall:e,cwd:t,sessionId:n}){var l;let{t:a}=(0,m.Bd)(),[i,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[h,f]=(0,s.useState)(!1),[x,g]=(0,s.useState)(!1),b=A[e.name]||"\uD83D\uDD27",v="Agent"===e.name||"Task"===e.name,w=v&&!!t&&!!n,k="Workflow"===e.name,j=k&&(l=e.result)?l.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,C=k&&!!j&&!!t&&!!n,N="Skill"===e.name,S=v||k||N,L=(()=>{let t=e.input;if("Bash"===e.name&&t.command&&"string"==typeof t.command)return t.command;if(v&&t.description&&"string"==typeof t.description)return t.description;if(k){let e=["string"==typeof t.name?t.name:"","string"==typeof t.args?t.args:"string"==typeof t.resumeFromRunId?t.resumeFromRunId:""].filter(Boolean).join(" \xb7 ");if(e)return e}if(N&&"string"==typeof t.skill){let e="string"==typeof t.args?t.args:"";return[t.skill,e].filter(Boolean).join(" \xb7 ")}return"Glob"===e.name&&t.pattern&&"string"==typeof t.pattern||"Grep"===e.name&&t.pattern&&"string"==typeof t.pattern?t.pattern:"ToolSearch"===e.name&&t.query&&"string"==typeof t.query?t.query:"TaskCreate"===e.name&&t.subject&&"string"==typeof t.subject?t.subject:t.file_path&&"string"==typeof t.file_path?t.file_path:t.path&&"string"==typeof t.path?t.path:null})(),E="Glob"===e.name||"Grep"===e.name||"Bash"===e.name||v||k||N,M=L?E?L:(e=>{if(t&&e.startsWith(t)){let n=e.slice(t.length);return n.startsWith("/")?n.slice(1):n}let n=e.split("/");return n.length>2?".../"+n.slice(-2).join("/"):e})(L):null,R=t=>{let n="input"===t?a("toolCall.inputParams"):a("toolCall.resultLabel"),r="input"===t?JSON.stringify(e.input,null,2):"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2);u({title:`${e.name}${M?` ${M}`:""} - ${n}`,content:r,toolName:e.name})};return(0,r.jsxs)("div",{className:"my-1 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,r.jsxs)("button",{onClick:()=>c(!i),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,r.jsx)("span",{className:"text-sm",children:b}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:e.name}),M&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:L||"",children:M}),!S&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),L&&(navigator.clipboard.writeText(L),(0,o.oR)(a("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),L&&(navigator.clipboard.writeText(L),(0,o.oR)(a("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:a("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[w&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),f(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),f(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("chat.subagentViewTitle"),children:a("chat.subagent")}),C&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),g(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),g(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("chat.workflowViewTitle"),children:a("chat.workflowRun")}),i&&!e.isLoading&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),R("input")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),R("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("toolCall.inputParamsTitle"),children:a("toolCall.input")}),e.result&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),R("result")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),R("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:a("toolCall.resultTitle"),children:a("toolCall.result")})]}),e.isLoading?(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,r.jsx)("span",{className:"text-slate-9 text-xs",children:i?"▲":"▼"})]})]}),i&&(0,r.jsxs)("div",{className:"border-t border-border",children:[(0,r.jsxs)("div",{className:"px-3 py-2",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a("toolCall.inputParams"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(e.input,null,2)})]}),e.result&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a("toolCall.resultLabel"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2)})]}),e.skillContent&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:e.skillContent})]})]}),d&&(0,r.jsx)(P,{title:d.title,content:d.content,toolName:d.toolName,onClose:()=>u(null)}),h&&t&&n&&(0,r.jsx)(p,{cwd:t,sessionId:n,toolCall:e,onClose:()=>f(!1)}),x&&t&&n&&j&&(0,r.jsx)(y,{cwd:t,sessionId:n,runId:j,isRunning:!!e.isLoading,onClose:()=>g(!1)})]})}var D=n(62111),F=n(56204),W=n(67635),B=n(33210),V=n(58515),O=n(36201),z=n(55804),H=n(37618);function U(e){let t=e.input?.questions||[],n=e.input?.answers||{},r={};if(e.result)try{let t=JSON.parse(e.result);t?.answers&&(r=t.answers)}catch{}return{questions:t,answers:{...n,...r}}}function K(e,t){return`${e}-${t}`}function q({toolCalls:e,onClose:t}){let{t:n}=(0,m.Bd)(),i=(0,l.nH)(),[c,d]=(0,s.useState)({}),[u,h]=(0,s.useState)({}),[f,x]=(0,s.useState)({}),[p,g]=(0,s.useState)({});(0,s.useEffect)(()=>{let t={};e.forEach((e,n)=>{let{questions:r,answers:s}=U(e);r.forEach((e,r)=>{let l=s[e.question];if(l){let s=K(n,r);t[s]=l,e.options.some(e=>e.label===l)||(h(e=>({...e,[s]:!0})),x(e=>({...e,[s]:l})))}})}),queueMicrotask(()=>d(t))},[e]),(0,D.E)(t);let b=e.reduce((e,t)=>{let{questions:n}=U(t);return e+n.length},0),v=Object.values(p).filter(Boolean).length,y=(0,s.useCallback)((e,t)=>{d(n=>({...n,[e]:t})),h(t=>({...t,[e]:!1}))},[]),w=(0,s.useCallback)(e=>{h(t=>{let n=!t[e];if(n){let t=f[e]||"";t&&d(n=>({...n,[e]:t}))}return{...t,[e]:n}})},[f]),k=(0,s.useCallback)((e,t)=>{x(n=>({...n,[e]:t})),t&&d(n=>({...n,[e]:t}))},[]),j=(0,s.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),C=(0,s.useCallback)(()=>{let t=v>0,r=[];return e.forEach((e,s)=>{let{questions:l}=U(e);l.forEach((e,l)=>{let a=K(s,l);if(t&&!p[a])return;let o=c[a];r.push(`Q: ${e.question}`),r.push(`A: ${o||n("askQuestion.notSelected")}`),r.push("")})}),r.join("\n").trim()},[e,c,p,v,n]),N=(0,s.useCallback)(()=>{navigator.clipboard.writeText(C()),(0,o.oR)(v>0?n("toast.copiedQA",{count:v}):n("toast.copiedAllQA"))},[C,v,n]),S=(0,s.useCallback)(()=>{i?(i.sendMessage(C()),(0,o.oR)(n("toast.sentQA")),t()):(0,o.oR)(n("askQuestion.sendNoChat"))},[i,C,t,n]),L=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:t,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:n("askQuestion.title")}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[n("askQuestion.nQuestions",{count:b}),v>0&&` \xb7 ${n("askQuestion.checkedN",{count:v})}`]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:S,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:v>0?n("askQuestion.sendChecked",{count:v}):n("askQuestion.sendAll"),children:(0,r.jsx)(F.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:N,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:v>0?n("askQuestion.copyChecked",{count:v}):n("askQuestion.copyAll"),children:(0,r.jsx)(W.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,r.jsx)(B.A,{className:"w-5 h-5"})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:e.map((t,s)=>{let{questions:l}=U(t);return l.map((t,a)=>{let o=K(s,a),i=c[o],d=u[o]||!1,h=p[o]||!1;return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("button",{onClick:()=>j(o),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:n("askQuestion.checkToCopy"),children:h?(0,r.jsx)(V.A,{className:"w-4 h-4 text-brand"}):(0,r.jsx)(O.A,{className:"w-4 h-4 text-muted-foreground"})}),t.header&&(0,r.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:t.header}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t.question})]}),(0,r.jsxs)("div",{className:"space-y-1 ml-7",children:[t.options.map((e,t)=>{let n=i===e.label&&!d;return(0,r.jsxs)("button",{onClick:()=>y(o,e.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${n?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:n?(0,r.jsx)(z.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:`text-sm ${n?"text-foreground font-medium":"text-foreground"}`,children:e.label}),e.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]})]},t)}),(0,r.jsxs)("button",{onClick:()=>w(o),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${d?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:d?(0,r.jsx)(z.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(H.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:n("askQuestion.custom")})]})]}),d&&(0,r.jsx)("div",{className:"ml-6 mt-1",children:(0,r.jsx)("input",{type:"text",autoFocus:!0,value:f[o]||"",onChange:e=>k(o,e.target.value),placeholder:n("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground placeholder:text-muted-foreground"})})]}),(s!==e.length-1||a!==l.length-1)&&(0,r.jsx)("div",{className:"border-b border-border/50 mt-3"})]},o)})})})]})});return(0,r.jsx)(a.ZL,{children:L})}var Z=n(65992),X=n(9573);let G=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]);var J=n(5135),Y=n(38175),Q=n(70188),ee=n(83448);function et({image:e,onClose:t}){let{t:n}=(0,m.Bd)(),s=(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsx)("button",{onClick:t,className:"absolute top-4 right-4 w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:n("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,r.jsx)(a.ZL,{children:s})}function en({filePath:e,onClose:t}){return(0,r.jsx)(a.ZL,{children:(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsx)("button",{onClick:t,className:"absolute top-4 right-4 w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,r.jsx)("img",{src:`/api/file?path=${encodeURIComponent(e)}&raw=true`,alt:e.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]})})}function er({filePath:e,content:t,cwd:n,onClose:l}){let[o,i]=(0,s.useState)(null);return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:l,children:(0,r.jsx)("div",{ref:i,className:"bg-card shadow-xl w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(Q.SU,{container:o,children:(0,r.jsx)(J.M,{content:t,filePath:e,cwd:n,onClose:l})})})})})}function es({filePath:e,content:t,cwd:n,onClose:s,onContentSearch:l}){let{t:i}=(0,m.Bd)();return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:s,children:(0,r.jsxs)("div",{className:"bg-card shadow-xl w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},title:e,onClick:()=>{navigator.clipboard.writeText(e),(0,o.oR)(i("common.copiedPath"))},children:["‎",e]}),(0,r.jsx)("button",{onClick:s,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-accent transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,r.jsx)(Y.E,{content:t,filePath:e,cwd:n,onContentSearch:l?e=>{l(e),s()}:void 0})})]})})})}let el=(0,s.memo)(function({message:e,cwd:t,sessionId:n,onFork:l,onApprovePlan:x,isLoading:p,onContentSearch:g,onShowFileDiff:b}){let v,y,w,k,{t:j}=(0,m.Bd)(),[C,S]=(0,s.useState)(null),[L,E]=(0,s.useState)(()=>1===(e.toolCalls?.length||0)),[M,T]=(0,s.useState)(!1),[$,I]=(0,s.useState)(!1),[P,A]=(0,s.useState)(!1),D="user"===e.role,F=e.images&&e.images.length>0,W=e.toolCalls?.length||0,B=!!n&&!!t&&!!l,V=(0,s.useMemo)(()=>e.toolCalls?.some(e=>{let t;return t=e.name,!G.has(t)})||!1,[e.toolCalls]),O=(0,s.useMemo)(()=>(0,Z.vP)([],e.toolCalls??[],t).length>0,[e.toolCalls,t]),[z,H]=(0,s.useState)(!1),U=O||z;(0,s.useEffect)(()=>{if(!V||O||!t)return;let n=(e.toolCalls??[]).map(e=>e.id).filter(Boolean);if(0===n.length)return;let r=(e.toolCalls??[]).filter(e=>["Edit","Write","MultiEdit","NotebookEdit"].includes(e.name)).map(e=>e.id),s=!1,l=null,a=0,o=()=>{f.t4.runPromiseExit((0,X.xK)(t,n)).then(e=>{if(s)return;let t="Success"===e._tag?e.value:[];if(t.length>0)return void H(!0);let n=new Set(t.map(e=>e.toolId));r.some(e=>!n.has(e))&&a<2&&(a+=1,l=setTimeout(o,2e3))})};return o(),()=>{s=!0,l&&clearTimeout(l)}},[V,O,t,e.toolCalls]);let K=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("TodoWrite"===e.toolCalls[t].name)return e.toolCalls[t];return null},[e.toolCalls]),J=(0,s.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),Y=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("ExitPlanMode"===e.toolCalls[t].name){let n=e.toolCalls[t].input?.plan;return"string"==typeof n&&n?n:null}return null},[e.toolCalls]),Q=(0,s.useMemo)(()=>e.toolCalls?.filter(e=>"ExitPlanMode"!==e.name)??[],[e.toolCalls]),el=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=new Set,n=[];for(let r of e.toolCalls)if("Read"===r.name||"Edit"===r.name||"Write"===r.name){let e=r.input.file_path;e&&((0,R.e$)(e)||(0,R.aR)(e)||(0,R.u)(e))&&!t.has(e)&&(t.add(e),n.push(e))}return n},[e.toolCalls]),ea=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=[];for(let n of e.toolCalls){let e=n.input?.thought;if(e&&"string"==typeof e){let r=e.match(/PREVIOUS:\s*(.*?)\s*→\s*THIS:\s*(.*?)\s*→\s*EXPECT:\s*(.*)/i);r?t.push({previous:r[1].trim(),current:r[2].trim(),expect:r[3].trim(),raw:e,toolName:n.name}):t.push({previous:"",current:e,expect:"",raw:e,toolName:n.name})}}return t},[e.toolCalls]),[eo,ei]=(0,s.useState)(null),[ec,ed]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!eo||(0,R.u)(eo))return void queueMicrotask(()=>ed(null));let e=!1;return f.t4.runPromiseExit((0,ee.an)(eo)).then(t=>{e||("Success"===t._tag&&void 0!==t.value.content?ed(t.value.content):((0,o.oR)(j("toast.readFileFailed"),"error"),ei(null)))}),()=>{e=!0}},[eo,j]);let eu=()=>{e.content&&(navigator.clipboard.writeText(e.content),(0,o.oR)(j("toast.copiedMessage")))},eh=()=>{B&&l(e.id)},em=(e=>{if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${n}-${r} ${s}:${l}`})(e.timestamp);if("system"===e.role){let t=e.systemEvent,n=t?.kind==="task-notification"?"failed"===t.status?"⚠️":"stopped"===t.status?"⏹️":"\uD83D\uDD14":"ℹ️",s=t?.detail||e.content;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex justify-center my-2 px-2","data-role":"system",children:(0,r.jsxs)("button",{type:"button",onClick:()=>A(!0),className:"flex items-center gap-1.5 max-w-[85%] text-[11px] text-muted-foreground bg-secondary/40 border border-border/50 rounded-full px-3 py-1 hover:bg-secondary hover:text-foreground transition-colors cursor-pointer",title:j("chat.viewDetails",{defaultValue:"Click for details"}),children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:n}),(0,r.jsx)("span",{className:"truncate",children:e.content})]})}),P&&(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:()=>A(!1),children:(0,r.jsxs)("div",{className:"bg-card shadow-xl w-full max-w-4xl max-h-[80vh] rounded-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-foreground flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:n}),t?.kind==="task-notification"?j("chat.taskNotification",{defaultValue:"Task notification"}):j("chat.systemNotice",{defaultValue:"Notice"})]}),(0,r.jsx)("button",{onClick:()=>A(!1),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-accent transition-colors",children:"✕"})]}),(0,r.jsx)("pre",{className:"flex-1 overflow-auto px-4 py-3 text-xs text-foreground whitespace-pre-wrap break-words",children:s})]})})})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:`flex flex-col ${D?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[em&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mb-0.5 px-1",children:em}),(0,r.jsxs)("div",{className:`flex ${D?"justify-end":"justify-start"} w-full`,children:[D&&(0,r.jsxs)("div",{className:"self-start mt-2 mr-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,r.jsx)("button",{onClick:eu,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),B&&(0,r.jsx)("button",{onClick:eh,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.forkSession"),children:(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,r.jsx)("path",{d:"M12 12v3"})]})})]}),(0,r.jsxs)("div",{className:`max-w-[80%] ${D?"bg-accent text-foreground border border-brand rounded-2xl rounded-br-md":"bg-accent text-foreground dark:text-slate-11 rounded-2xl rounded-bl-md"} px-4 py-2`,children:[F&&(0,r.jsx)("div",{className:`flex flex-wrap gap-2 ${e.content?"mb-2":""}`,children:e.images.map((e,t)=>(0,r.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>S(e),children:(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:j("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),e.content&&(0,r.jsxs)("div",{className:"break-words",children:[(0,r.jsx)(N.T,{content:e.content,isUser:D,isStreaming:e.isStreaming,enableMath:!1}),e.isStreaming&&(0,r.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]}),K&&(w=(y=Array.isArray(v=K.input?.todos)?v:[]).filter(e=>"completed"===e.status).length,k=y.length,(0,r.jsx)("div",{className:`${e.content||F?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${k>0?w/k*100:0}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[w,"/",k]})]}),y.map((e,t)=>(0,r.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===e.status?"opacity-50":""}`,children:["completed"===e.status?(0,r.jsx)(i.A,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):"in_progress"===e.status?(0,r.jsx)(c.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,r.jsx)(d.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,r.jsx)("span",{className:`text-xs truncate ${"completed"===e.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===e.status&&e.activeForm?e.activeForm:e.content})]},t))]})})),Y&&(0,r.jsx)("div",{className:`${e.content||F||K?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-brand/40 rounded-lg overflow-hidden bg-secondary/50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-border bg-brand/10",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDCCB"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:j("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)(N.T,{content:Y,isUser:!1,enableMath:!1})}),x&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:j("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,r.jsxs)("button",{onClick:()=>x(),disabled:p,className:"flex items-center gap-1.5 px-3 py-1 rounded-md bg-brand text-white text-xs font-medium hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex-shrink-0",children:[(0,r.jsx)("span",{children:"✓"}),(0,r.jsx)("span",{children:j("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),el.length>0&&(0,r.jsx)("div",{className:`${e.content||F||K?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-0.5",children:el.map(e=>(0,r.jsxs)("button",{onClick:()=>ei(e),className:"flex items-center gap-1.5 w-full text-left hover:bg-accent rounded px-1 py-0.5 transition-colors group/md",children:[(0,R.u)(e)?(0,r.jsxs)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"}),(0,r.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4-4 3 3 4-4 5 5"})]}):(0,R.aR)(e)?(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}):(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:e.split("/").pop()})]},e))})}),ea.length>0&&(0,r.jsx)("div",{className:`${e.content||F||K||el.length>0?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border text-muted-foreground",children:[(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium w-[60px]",children:"Tool"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Previous"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Action"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Expect"})]})}),(0,r.jsx)("tbody",{children:ea.map((e,t)=>(0,r.jsxs)("tr",{className:t<ea.length-1?"border-b border-border/50":"",children:[(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground font-mono",children:e.toolName}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.previous||"—"}),(0,r.jsx)("td",{className:"px-2 py-1 text-foreground",children:e.current}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.expect||"—"})]},t))})]})})}),Q.length>0&&(0,r.jsx)("div",{className:`${e.content||F?"mt-2":""}`,children:W>0?(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("button",{onClick:()=>E(!L),className:"flex-1 px-3 py-1.5 flex items-center gap-2 text-left hover:bg-accent transition-colors active:bg-muted",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDD27"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:j("chat.toolCalls",{count:Q.length})}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:L?j("chat.collapse"):j("chat.expand")})]}),J.length>0&&(0,r.jsx)("button",{onClick:()=>I(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:j("chat.viewQuestions"),children:(0,r.jsx)(u.A,{className:"w-4 h-4"})}),U&&(0,r.jsx)("button",{onClick:()=>{b&&e.toolCalls?b(e.toolCalls,t):T(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:j("chat.viewAllFileChanges"),children:(0,r.jsx)(h.A,{className:"w-4 h-4"})})]}),L&&(0,r.jsx)("div",{className:"border-t border-border p-2 space-y-1",children:Q.map((e,s)=>(0,r.jsx)(_,{toolCall:e,cwd:t,sessionId:n},`${e.id}-${s}`))})]}):Q.map((e,s)=>(0,r.jsx)(_,{toolCall:e,cwd:t,sessionId:n},`${e.id}-${s}`))})]}),!D&&(0,r.jsxs)("div",{className:"self-start mt-2 ml-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,r.jsx)("button",{onClick:eu,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),B&&(0,r.jsx)("button",{onClick:eh,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:j("chat.forkSession"),children:(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,r.jsx)("path",{d:"M12 12v3"})]})})]})]})]}),C&&(0,r.jsx)(et,{image:C,onClose:()=>S(null)}),M&&e.toolCalls&&(0,r.jsx)(Z.zB,{toolCalls:e.toolCalls,cwd:t,onClose:()=>T(!1),onContentSearch:g}),$&&J.length>0&&(0,r.jsx)(q,{toolCalls:J,onClose:()=>I(!1)}),eo&&(0,R.u)(eo)&&(0,r.jsx)(en,{filePath:eo,onClose:()=>ei(null)}),eo&&!(0,R.u)(eo)&&null!==ec&&((0,R.aR)(eo)?(0,r.jsx)(es,{filePath:eo,content:ec,cwd:t,onClose:()=>ei(null),onContentSearch:g}):(0,r.jsx)(er,{filePath:eo,content:ec,cwd:t||"",onClose:()=>ei(null)}))]})});var ea=n(1058),eo=n(90717),ei=n(89109),ec=n(7320);let ed=(0,s.forwardRef)(function({messages:e,isLoading:t,cwd:n,sessionId:a,engine:o,apiRetryInfo:i,ptyNotice:c,hasMoreHistory:d,isLoadingMore:u,onLoadMore:h,onFork:f,isActive:x=!0,onContentSearch:p,onShowFileDiff:g,onApprovePlan:b},v){let{t:y}=(0,m.Bd)(),w=(0,s.useRef)(null),k=(0,s.useRef)(null),j=(0,s.useRef)(null),C=(0,s.useRef)(null),[N,S]=(0,s.useState)(null),[L,E]=(0,s.useState)(!0),[M,R]=(0,s.useState)(!1),[T,$]=(0,s.useState)(!1);(0,s.useEffect)(()=>{S(C.current)},[]);let{isSearchVisible:I,searchQuery:P,setSearchQuery:A,matches:_,currentMatchIndex:D,goToNextMatch:F,goToPrevMatch:W,closeSearch:B,searchInputRef:V,handleSearchKeyDown:O}=function(e){let[t,n]=(0,s.useState)(!1),[r,l]=(0,s.useState)(""),[a,o]=(0,s.useState)([]),[i,c]=(0,s.useState)(0),d=(0,s.useRef)(null),u=(0,s.useRef)([]),h=(0,s.useCallback)(()=>{let t=e.current;t&&(t.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||""),e),t.normalize())}),u.current=[])},[e]),m=(0,s.useCallback)(t=>{if(h(),!t||!e.current){o([]),c(0);return}let n=[],r=[],s=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let l,a=e.getAttribute("data-message-id")||"",o=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),c=[];for(;l=i.nextNode();)c.push(l);for(let e of c){let l=(e.textContent||"").toLowerCase(),i=0,c=[];for(;;){let e=l.indexOf(s,i);if(-1===e)break;c.push({start:e,end:e+t.length}),i=e+1}if(0!==c.length)for(let t=c.length-1;t>=0;t--){let s=c[t];e.splitText(s.end);let l=e.splitText(s.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=l.textContent,l.parentNode.replaceChild(i,l),n.push({messageId:a,markIndex:o}),r.push(i),o++}}}),n.reverse(),r.reverse(),u.current=r,o(n),c(n.length>0?0:-1)},[e,h]);(0,s.useEffect)(()=>{queueMicrotask(()=>m(r))},[r,m]),(0,s.useEffect)(()=>{let e=u.current;e.forEach((e,t)=>{e.className=t===i?"chat-search-current":"chat-search-match"}),i>=0&&i<e.length&&e[i].scrollIntoView({behavior:"smooth",block:"center"})},[i,a]);let f=(0,s.useCallback)(()=>{0!==a.length&&c(e=>(e+1)%a.length)},[a.length]),x=(0,s.useCallback)(()=>{0!==a.length&&c(e=>(e-1+a.length)%a.length)},[a.length]),p=(0,s.useCallback)(()=>{n(!0),setTimeout(()=>d.current?.focus(),0)},[]),g=(0,s.useCallback)(()=>{n(!1),l(""),h(),o([]),c(0)},[h]),b=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?x():f()),"Escape"===e.key&&g()},[f,x,g]);return(0,s.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),e.stopPropagation(),p())};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)},[e,p]),{isSearchVisible:t,searchQuery:r,setSearchQuery:l,matches:a,currentMatchIndex:i,goToNextMatch:f,goToPrevMatch:x,openSearch:p,closeSearch:g,searchInputRef:d,handleSearchKeyDown:b}}(C),z=(0,l.nH)(),H=(0,s.useRef)(null),U=(0,s.useRef)(()=>{}),{addComment:K,refresh:q}=(0,ea._)({cwd:n||"",filePath:eo.Un}),[Z,X]=(0,s.useState)(null),[G,J]=(0,s.useState)(null),Y=(0,s.useCallback)(e=>{if(Z||G)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){H.current=null,U.current();return}let n=t.toString().trim();if(!n){H.current=null,U.current();return}let r=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(r?.closest('[data-role="user"]')){H.current=null,U.current();return}H.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:n,lineSnapshot:n},U.current()},[Z,G]),Q=(0,s.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&H.current&&(H.current=null,U.current())},[]),ee=(0,s.useCallback)(()=>{let e=H.current;e&&(X({x:e.x,y:e.y,text:e.selectedText}),H.current=null,U.current(),window.getSelection()?.removeAllRanges())},[]),et=(0,s.useCallback)(()=>{let e=H.current;e&&(J({x:e.x,y:e.y,text:e.selectedText}),H.current=null,U.current(),window.getSelection()?.removeAllRanges())},[]),en=(0,s.useCallback)(()=>{let e=H.current;if(!e||!p)return;let t=e.selectedText.trim();H.current=null,U.current(),window.getSelection()?.removeAllRanges(),t&&p(t)},[p]),er=(0,s.useCallback)(async e=>{Z&&(await K(0,0,e,Z.text),X(null))},[Z,K]),es=(0,s.useCallback)(async(e,t)=>{if(z&&n)try{let r=(await (0,eo.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));r.push({filePath:eo.Un,startLine:0,endLine:0,codeContent:e});let s=(0,eo.Gw)(r,t);z.sendMessage(s),await (0,eo.RP)(n),q()}catch(e){console.error("Failed to send to AI:",e)}},[z,n,q]),ed=(0,s.useCallback)(e=>{G&&es(G.text,e)},[G,es]),eu=(0,s.useCallback)(e=>{Z&&es(Z.text,e)},[Z,es]),eh=(0,s.useMemo)(()=>{let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),!0))},[e]),em=(0,s.useRef)(0),ef=(0,s.useRef)(!1),ex=(0,s.useCallback)(()=>{let e=j.current;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<50},[]),ep=(0,s.useCallback)(()=>{let e=j.current;return!e||e.scrollTop<50},[]),eg=(0,s.useCallback)(()=>{let e=ex(),t=ep();if(E(e),R(!t),$(!e),t&&d&&!u&&h){let e=j.current;e&&(em.current=e.scrollHeight,ef.current=!0),h()}},[ex,ep,d,u,h]),eb=(0,s.useCallback)(()=>{k.current?.scrollIntoView({behavior:"smooth"})},[]),ev=(0,s.useCallback)(()=>{w.current?.scrollIntoView({behavior:"smooth"})},[]),ey=(0,s.useCallback)(e=>{let t=j.current;if(!t)return;let n=t.querySelector(`[data-message-id="${e}"]`);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.classList.add("ring-2","ring-brand","ring-offset-2"),setTimeout(()=>{n.classList.remove("ring-2","ring-brand","ring-offset-2")},2e3))},[]);(0,s.useImperativeHandle)(v,()=>({scrollToMessage:ey}),[ey]);let ew=(0,s.useRef)(0),ek=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let t=ew.current,n=e.length;ew.current=n,!ek.current&&L&&n>t&&w.current?.scrollIntoView({behavior:"smooth"})},[e,L]),(0,s.useEffect)(()=>{L&&t&&w.current?.scrollIntoView({behavior:"smooth"})},[t,L]),(0,s.useEffect)(()=>{if(ef.current&&!u){let e=j.current;if(e){let t=e.scrollHeight-em.current;e.scrollTop=t,ef.current=!1}}},[e,u]);let ej=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{x&&ej.current&&e.length>0&&(ej.current=!1,w.current?.scrollIntoView({behavior:"instant"}))},[x,e.length]),(0,s.useEffect)(()=>{ek.current&&e.length>0&&(ek.current=!1,x?w.current?.scrollIntoView({behavior:"instant"}):ej.current=!0)},[e.length,x]),(0,r.jsxs)("div",{ref:C,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:Y,onMouseDown:Q,children:[I&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,r.jsx)("input",{ref:V,type:"text",value:P,onChange:e=>A(e.target.value),onKeyDown:O,placeholder:y("codeViewer.searchChat"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:_.length>0?`${D+1}/${_.length}`:y("common.noMatch")}),(0,r.jsx)("button",{onClick:W,disabled:0===_.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:y("codeViewer.prevShiftEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:F,disabled:0===_.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:y("codeViewer.nextEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:B,className:"p-1 rounded hover:bg-accent",title:y("codeViewer.closeEsc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{ref:j,onScroll:eg,className:"relative flex-1 min-h-0 overflow-y-auto p-4",children:0!==e.length||t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:k}),d&&(0,r.jsx)("div",{className:"flex justify-center py-3",children:u?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("span",{children:y("chat.loadMoreHistory")})]}):(0,r.jsx)("button",{onClick:h,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:y("chat.scrollUpForMore")})}),eh.map(e=>(0,r.jsx)("div",{"data-message-id":e.id,className:"transition-[box-shadow] duration-300",children:(0,r.jsx)(el,{message:e,cwd:n,sessionId:a,onFork:f,onApprovePlan:b,isLoading:t,onContentSearch:p,onShowFileDiff:g})},e.id)),t&&(0,r.jsx)("div",{className:"flex justify-start mb-4",children:(0,r.jsxs)("div",{className:"bg-accent rounded-2xl rounded-bl-md px-4 py-3 max-w-[90%]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,r.jsx)("span",{className:"inline-block w-5 h-5 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("span",{className:"text-sm",children:"claude2"===o?"Claude 2 is thinking...":"codex"===o?"Codex is thinking...":"kimi"===o?"Kimi is thinking...":"ollama"===o?"Ollama is thinking...":"deepseek"===o?"DeepSeek is thinking...":y("chat.claudeThinking")})]}),i&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-400 border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{children:["Retrying API call (attempt ",i.attempt,i.maxRetries>0?`/${i.maxRetries}`:"",i.delayMs>0?`, delay ${(i.delayMs/1e3).toFixed(1)}s`:"",")"]}),(i.errorStatus||i.error)&&(0,r.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[i.errorStatus?`${i.errorStatus}`:"",i.errorStatus&&i.error?" \xb7 ":"",i.error||""]})]})]}),c&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-400 border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01M5.07 19h13.86c1.54 0 2.5-1.67 1.73-3L13.73 4a2 2 0 00-3.46 0L3.34 16c-.77 1.33.19 3 1.73 3z"})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 break-words",children:c})]})]})}),(0,r.jsx)("div",{ref:w})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-slate-9",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,r.jsx)("div",{children:y("chat.startConversation")})]})})}),M&&e.length>0&&(0,r.jsx)("button",{onClick:eb,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:y("chat.jumpToStart"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),T&&e.length>0&&(0,r.jsx)("button",{onClick:ev,className:"absolute bottom-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:y("chat.jumpToLatest"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),N&&(0,r.jsx)(ei.f,{floatingToolbarRef:H,bumpRef:U,container:N,onAddComment:ee,onSendToAI:et,onSearch:p?en:void 0,isChatLoading:z?.isLoading}),Z&&N&&(0,r.jsx)(ec.t,{x:Z.x,y:Z.y,range:{start:0,end:0},lineSnapshot:Z.text,container:N,onSubmit:er,onSendToAI:z?eu:void 0,onClose:()=>X(null),isChatLoading:z?.isLoading}),G&&N&&(0,r.jsx)(ec.G,{x:G.x,y:G.y,range:{start:0,end:0},lineSnapshot:G.text,container:N,onSubmit:ed,onClose:()=>J(null),isChatLoading:z?.isLoading})]})})},75346:(e,t,n)=>{n.d(t,{n:()=>s});var r=n(88292);let s={SessionChange:(0,r.R)("session-change"),ViewChange:(0,r.R)("view-change"),OpenNote:(0,r.R)("open-note"),LangChange:(0,r.R)("lang-change"),TabAdd:(0,r.R)("tab-add"),TabClose:(0,r.R)("tab-close"),SwitchSession:(0,r.R)("switch-session"),ProjectChange:(0,r.R)("project-change"),OpenProject:(0,r.R)("open-project"),SessionComplete:(0,r.R)("session-complete"),OpenTokenStats:(0,r.R)("open-token-stats"),PinnedSessionsChanged:(0,r.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,r.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,r.R)("screenshot-prepare"),ScreenshotDone:(0,r.R)("screenshot-done")}},77725:(e,t,n)=>{n.d(t,{Z:()=>d});var r=n(12115),s=n(10592),l=n(86359),a=n(80905),o=n(49433),i=n(80286),c=n(86957);function d(e,t){let[n,d]=(0,r.useState)({status:"loading"});return(0,r.useEffect)(()=>{d({status:"loading"});let t=c.t4.runFork(e);return t.addObserver(e=>{s.YW(e,{onSuccess:e=>d({status:"success",data:e}),onFailure:e=>{let t=l.od(e);d({status:"error",error:a.Ru(t)?t.value:e})}})}),()=>{o.runFork(i.G(t))}},t),n}},82292:(e,t,n)=>{function r(e,t){for(let n of e){if(n.path===t)return n;if(n.children){let e=r(n.children,t);if(e)return e}}return null}function s(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let s=e.split("/");return s.pop(),s.join("/")}function l(e){let t=[];for(let n of e){let e=n.split("/"),r=t;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1,l=e.slice(0,t+1).join("/"),a=r.find(e=>e.name===n);a||(a={name:n,path:l,isDirectory:!s,children:s?void 0:[]},r.push(a)),!s&&a.children&&(r=a.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>{e.children&&n(e.children)})};return n(t),t}function a(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}n.d(t,{B_:()=>f,HR:()=>function e(t,n){if(0===n.length)return t;let r=new Map(n.map(e=>[e.path,e]));return t.map(t=>{let n=r.get(t.path);return n&&t.isDirectory?void 0===t.children&&void 0!==n.children?{...t,children:n.children}:void 0!==t.children&&void 0!==n.children?{...t,children:e(t.children,n.children)}:t:t})},KH:()=>d,MB:()=>r,S7:()=>s,fw:()=>u,q3:()=>c,r6:()=>h,tE:()=>m,tW:()=>a,u:()=>i,v3:()=>l});let o=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function i(e){let t=e.split(".").pop()?.toLowerCase();return o.has(t||"")}function c(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase(),l=e=>{if(r.add(e.path),e.children)for(let t of e.children)l(t)},a=(e,t)=>{let o=e.name.toLowerCase(),i=n?o===s:o.includes(s);if(i&&e.children)return l(e),t.forEach(e=>r.add(e)),!0;let c=!1;if(e.children)for(let n of e.children)a(n,[...t,e.path])&&(c=!0);return(!!i||!!c)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)a(t,[]);return r}function d(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase();for(let t of e){let e=t.split("/");for(let t=0;t<e.length;t++){let l=e[t].toLowerCase();if(n?l===s:l.includes(s)){for(let t=0;t<=e.length-1;t++)r.add(e.slice(0,t+1).join("/"));break}}}return r}function u(e){let t=Math.floor(Math.floor((Date.now()-1e3*e)/1e3)/60),n=Math.floor(t/60),r=Math.floor(n/24),s=Math.floor(r/30),l=Math.floor(r/365);return l>0?`${l}y ago`:s>0?`${s}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function h(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return r?`${s}-${l} ${a}:${o}`:`${t.getFullYear()}-${s}-${l} ${a}:${o}`}let m=()=>{},f=50},83448:(e,t,n)=>{n.d(t,{Cr:()=>C,F4:()=>h,JC:()=>p,M5:()=>f,Pk:()=>d,QW:()=>v,Zr:()=>b,an:()=>j,em:()=>c,l1:()=>x,n_:()=>g,pw:()=>u,qD:()=>k,td:()=>i,yS:()=>m,z2:()=>y});var r=n(49433),s=n(82680);let l=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>l(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=(e,t)=>l(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=()=>l("/api/settings"),c=e=>o("/api/settings",e),d=()=>l("/api/deepseek/credentials"),u=e=>o("/api/deepseek/credentials",{apiKey:e}),h=()=>l("/api/ollama/config"),m=e=>o("/api/ollama/config",e),f=()=>l("/api/commands"),x=()=>l("/api/skills"),p=e=>a("/api/bash",e),g=e=>r.tryPromise({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new s.uV({message:"POST /api/session-by-path failed",cause:e})}),b=(e,t)=>a(`/api/session/${encodeURIComponent(e)}/fork`,t),v=e=>l(`/api/sessions/projects/${encodeURIComponent(e)}`),y=()=>l("/api/global-state").pipe(r.map(e=>e.sessions??[])),w=()=>r.tryPromise({try:async()=>{let e=await fetch("/api/ollama/models");return 503===e.status?{_tag:"not-running"}:e.ok?{_tag:"ok",models:(await e.json()).models??[]}:{_tag:"error",message:"Failed to fetch models"}},catch:e=>new s.uV({message:"fetch ollama models failed",cause:e})}),k=e=>r.gen(function*(){let t=yield*w();if("not-running"!==t._tag)return t;e&&(yield*r.sync(e));let n=yield*r.tryPromise({try:async()=>{let e=await fetch("/api/ollama/start",{method:"POST"}),t=await e.json().catch(()=>({}));return 404===e.status?{_tag:"not-installed",message:t.message||"Ollama is not installed"}:e.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:e=>new s.uV({message:"start ollama failed",cause:e})});if("not-installed"===n._tag)return{_tag:"not-installed",message:n.message};if("error"===n._tag)return{_tag:"error",message:n.message};let l=yield*w();return"not-running"===l._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:l}),j=e=>l(`/api/file?path=${encodeURIComponent(e)}`),C=e=>l(`/api/claude-stats?engine=${encodeURIComponent(e)}`)},83897:(e,t,n)=>{n.d(t,{k_:()=>o,nH:()=>i});var r=n(95155),s=n(12115),l=n(48347);let a=(0,s.createContext)(null);function o({children:e}){let t=(0,s.useRef)(new Map),n=(0,s.useRef)(null),[i,c]=(0,s.useState)(!1),d=(0,s.useCallback)((e,n)=>{t.current.set(n,e)},[]),u=(0,s.useCallback)(e=>{t.current.delete(e)},[]),h=(0,s.useCallback)(e=>{n.current=e},[]),m=(0,s.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let s=t.current.get(r);s?s(e):console.warn(`No chat sender registered for tab ${r}`)},[]),f=(0,s.useMemo)(()=>({sendMessage:m,isLoading:i,registerChat:d,unregisterChat:u,setActiveTab:h,setIsLoading:c}),[m,i,d,u,h]),x=(0,s.useMemo)(()=>({sendMessage:m,isLoading:i}),[m,i]);return(0,r.jsx)(a.Provider,{value:f,children:(0,r.jsx)(l.H,{value:x,children:e})})}function i(){return(0,s.useContext)(a)}},88780:(e,t,n)=>{n.d(t,{Do:()=>u,Sz:()=>h,VO:()=>d,wI:()=>m});var r=n(95155),s=n(12115),l=n(79114),a=n(70188),o=n(14575);function i({status:e}){let{label:t,className:n}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[e]||{label:"?",className:"text-muted-foreground"};return(0,r.jsx)("span",{className:`text-xs font-bold ${n}`,children:t})}let c=s.memo(function e({node:t,level:n,selectedPath:l,expandedPaths:a,onSelect:c,onToggle:d,onContextMenu:u,showChanges:h=!1,renderActions:m}){let f=l===t.path,x=a.has(t.path),p=(0,s.useCallback)(()=>{t.isDirectory?d(t.path):c(t)},[t,c,d]),g=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),u(e,t.path,t.isDirectory)},[t.path,t.isDirectory,u]);return t.isDirectory?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*n+8}px`},onClick:p,onContextMenu:g,children:[(0,r.jsx)("span",{className:"text-slate-9 text-xs",children:x?"▼":"▶"}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),m&&m(t)]}),x&&t.children.map(t=>(0,r.jsx)(e,{node:t,level:n+1,selectedPath:l,expandedPaths:a,onSelect:c,onToggle:d,onContextMenu:u,showChanges:h,renderActions:m},t.path))]}):(0,r.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${f?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*n+8}px`},onClick:p,onContextMenu:g,children:[(0,r.jsx)(o.o,{name:t.name,size:16,className:"flex-shrink-0"}),(0,r.jsx)("span",{className:`text-sm flex-1 truncate ${f?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),t.status&&(0,r.jsx)(i,{status:t.status}),h&&void 0!==t.additions&&void 0!==t.deletions&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,r.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]}),m&&m(t)]})});function d({files:e,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:o,cwd:i,showChanges:u=!1,renderActions:h,emptyMessage:m,className:f}){let{t:x}=(0,l.Bd)(),p=m??x("gitFileTree.noFiles"),{contextMenu:g,showContextMenu:b,hideContextMenu:v}=(0,a.Ee)();return 0===e.length?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:p}):(0,r.jsxs)("div",{className:f||"py-1",children:[e.map(e=>(0,r.jsx)(c,{node:e,level:0,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:o,onContextMenu:b,showChanges:u,renderActions:h},e.path)),g&&(0,r.jsx)(a.ft,{x:g.x,y:g.y,path:g.path,cwd:i,isDirectory:g.isDirectory,onClose:v})]})}function u(e){let t=[];for(let n of e){let e=n.path.split("/"),r=t;for(let t=0;t<e.length;t++){let s=e[t],l=t===e.length-1,a=e.slice(0,t+1).join("/"),o=r.find(e=>e.name===s);o||(o={name:s,path:a,isDirectory:!l,children:[],...l&&{status:n.status,additions:n.additions,deletions:n.deletions,oldPath:n.oldPath,file:n}},r.push(o)),l||(r=o.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>n(e.children))};return n(t),t}function h(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),n(r.children))};return n(e),t}function m(e){let t=[],n=e=>{if(e.isDirectory)for(let t of e.children)n(t);else t.push(e)};return n(e),t}},89109:(e,t,n)=>{n.d(t,{f:()=>o});var r=n(95155),s=n(12115),l=n(79114);function a({x:e,y:t,visible:n,container:s,onAddComment:o,onSendToAI:i,onSearch:c,isChatLoading:d}){let{t:u}=(0,l.Bd)(),h=s.getBoundingClientRect(),m=e-h.left,f=Math.max(0,t-h.top-40);return(0,r.jsxs)("div",{className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-xl p-1.5",style:{left:m+8,top:f,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:o,children:u("floatingToolbar.addComment")}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:i,disabled:d,title:u(d?"comments.aiResponding":"floatingToolbar.sendToAI"),children:u("floatingToolbar.sendToAI")}),c&&(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:c,children:u("floatingToolbar.search")})]})}let o=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:l,onSendToAI:o,onSearch:i,isChatLoading:c}){let[d,u]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>u(e=>e+1)},[t]);let h=(0,s.useMemo)(()=>e.current,[d]);return(0,r.jsx)(a,{x:h?.x??0,y:h?.y??0,visible:!!h,container:n,onAddComment:l,onSendToAI:o,onSearch:i,isChatLoading:c})})},90717:(e,t,n)=>{n.d(t,{$3:()=>u,Cm:()=>d,Gw:()=>f,RP:()=>h,Un:()=>m,zL:()=>c});var r=n(69809),s=n(49433),l=n(86957),a=n(82680),o=n(46456);let i=new Set;function c(e){return i.add(e),()=>i.delete(e)}function d(){i.forEach(e=>e())}async function u(e){let t=await l.t4.runPromiseExit((0,o.lb)(e));if("Success"!==t._tag)throw Error("Failed to fetch comments");let n=t.value.comments??[];if(0===n.length)return[];let r=new Map;for(let e of n)e.selectedText||(r.has(e.filePath)||r.set(e.filePath,[]),r.get(e.filePath).push(e));let i=new Map;await Promise.all(Array.from(r.keys()).map(async t=>{let n=await l.t4.runPromiseExit(s.tryPromise({try:async()=>{let n=await fetch(`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);return n.ok?await n.json():null},catch:e=>new a.uV({message:`read file text ${t} failed`,cause:e})}));"Success"===n._tag&&n.value&&"string"==typeof n.value.content?i.set(t,n.value.content.split("\n")):"Failure"===n._tag&&console.error(`Failed to read file ${t}:`,n.cause)}));let c=[];for(let e of n){if(e.selectedText){c.push({...e,codeContent:e.selectedText});continue}let t=i.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),s=Math.min(t.length,e.endLine);n=t.slice(r,s).join("\n")}c.push({...e,codeContent:n})}return c}async function h(e){let t=await l.t4.runPromiseExit((0,o.tj)(e));return"Success"===t._tag?(d(),!0):(console.error("Failed to clear comments:",t.cause),!1)}let m="__chat__";function f(e,t){let n=e.filter(e=>e.filePath===m),s=e.filter(e=>e.filePath!==m),l=[];for(let e of(s.length>0&&(l.push(`${r.A.t("comments.codeRef")}`,""),s.forEach((e,t)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";l.push(`[${t+1}] ${e.filePath}${n}`),l.push("```"),l.push(e.codeContent),l.push("```"),e.note&&l.push(r.A.t("comments.note",{content:e.note})),l.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");l.push(t),e.note&&l.push(e.note),l.push("")}if(t.trim()){for(;l.length>0&&""===l[l.length-1];)l.pop();l.push(t.trim())}return l.join("\n").trim()}},95045:(e,t,n)=>{n.d(t,{F:()=>a});var r=n(49433),s=n(88292),l=n(86957);let a=(e,t)=>{l.t4.runFork(r.flatMap(s.d,n=>n.publish(e,t)))}},95942:(e,t,n)=>{n.d(t,{EE:()=>o,K2:()=>i,ri:()=>c});var r=n(95155),s=n(12115),l=n(79114),a=n(8422);let o=80,i=24,c=(0,s.forwardRef)(function({visible:e,running:t,onInput:n},c){let{t:d}=(0,l.Bd)(),u=(0,s.useRef)(n);(0,s.useEffect)(()=>{u.current=n},[n]);let[h,m]=(0,s.useState)(!1),f=(0,s.useRef)(!1);(0,s.useEffect)(()=>{t&&!f.current?m(!0):!t&&f.current&&m(!1),f.current=t},[t]);let x=(0,s.useRef)(null),p=(0,s.useRef)(null),g=(0,s.useRef)(""),b=(0,s.useCallback)(()=>{if(p.current||!x.current)return;let e=new a.B({cols:o,rows:i,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace',convertEol:!1,scrollback:2e3,theme:{background:"#0a0a0a",foreground:"#d4d4d8"},disableStdin:!1,allowProposedApi:!0});e.open(x.current),e.onData(e=>u.current?.(e)),g.current&&e.write(g.current),p.current=e},[]);return((0,s.useEffect)(()=>{h&&e?b():(p.current?.dispose(),p.current=null)},[h,e,b]),(0,s.useImperativeHandle)(c,()=>({write:e=>{g.current+=e,g.current.length>2e5&&(g.current=g.current.slice(-15e4)),p.current?.write(e)},clear:()=>{g.current="",p.current?.clear()}}),[]),e)?(0,r.jsxs)("div",{className:"absolute top-12 right-3 z-30 rounded-lg border border-border bg-card shadow-lg overflow-hidden",style:{width:h?"auto":180},"data-testid":"pty-floating-window",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(e=>!e),"data-testid":"pty-floating-toggle",className:"w-full flex items-center justify-between gap-3 px-2.5 py-1.5 text-xs bg-accent/60 hover:bg-accent",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${t?"bg-green-500 animate-pulse":"bg-muted-foreground"}`}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[d("chat.ptyTerminal"),t?` \xb7 ${d("chat.ptyRunning")}`:""]})]}),(0,r.jsx)("span",{className:"text-muted-foreground",children:h?`${d("chat.ptyCollapse")} ▾`:`${d("chat.ptyExpand")} ▸`})]}),(0,r.jsx)("div",{ref:x,"data-testid":"pty-floating-term",style:{display:h?"block":"none",padding:4},className:"bg-[#0a0a0a]"})]}):null})}}]);