@surething/cockpit 1.0.275 → 1.0.276

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 (711) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +3 -1
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/cockpit-build.json +1 -1
  5. package/.next-prod/prerender-manifest.json +4 -4
  6. package/.next-prod/routes-manifest.json +14 -0
  7. package/.next-prod/server/app/_global-error/page.js +2 -2
  8. package/.next-prod/server/app/_global-error/page.js.nft.json +1 -1
  9. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next-prod/server/app/_global-error.html +1 -1
  11. package/.next-prod/server/app/_global-error.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next-prod/server/app/_not-found/page.js +1 -1
  16. package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next-prod/server/app/_not-found.html +2 -2
  19. package/.next-prod/server/app/_not-found.rsc +3 -3
  20. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
  21. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
  22. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  24. package/.next-prod/server/app/api/agent/test/route.js +1 -1
  25. package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
  26. package/.next-prod/server/app/api/bash/route.js +1 -1
  27. package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
  28. package/.next-prod/server/app/api/bots/[id]/route.js +1 -0
  29. package/.next-prod/server/app/api/bots/[id]/route.js.nft.json +1 -0
  30. package/.next-prod/server/app/api/bots/[id]/route_client-reference-manifest.js +1 -0
  31. package/.next-prod/server/app/api/bots/route.js +1 -0
  32. package/.next-prod/server/app/api/bots/route.js.nft.json +1 -0
  33. package/.next-prod/server/app/api/bots/route_client-reference-manifest.js +1 -0
  34. package/.next-prod/server/app/api/chat/codex/route.js +1 -1
  35. package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
  36. package/.next-prod/server/app/api/chat/deepseek/route.js +1 -1
  37. package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
  38. package/.next-prod/server/app/api/chat/glm/route.js +1 -1
  39. package/.next-prod/server/app/api/chat/glm/route.js.nft.json +1 -1
  40. package/.next-prod/server/app/api/chat/kimi/route.js +1 -1
  41. package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
  42. package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
  43. package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
  44. package/.next-prod/server/app/api/chat/route.js +1 -1
  45. package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
  46. package/.next-prod/server/app/api/chat/stop/route.js +1 -1
  47. package/.next-prod/server/app/api/chat/stop/route.js.nft.json +1 -1
  48. package/.next-prod/server/app/api/claude-stats/route.js +1 -1
  49. package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
  50. package/.next-prod/server/app/api/commands/route.js +1 -1
  51. package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
  52. package/.next-prod/server/app/api/comments/route.js +1 -1
  53. package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
  54. package/.next-prod/server/app/api/db/columns/route.js +2 -2
  55. package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
  56. package/.next-prod/server/app/api/db/connect/route.js +1 -1
  57. package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
  58. package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
  59. package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
  60. package/.next-prod/server/app/api/db/export/route.js +1 -1
  61. package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
  62. package/.next-prod/server/app/api/db/query/route.js +1 -1
  63. package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
  64. package/.next-prod/server/app/api/db/schemas/route.js +1 -1
  65. package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
  66. package/.next-prod/server/app/api/deepseek/balance/route.js +1 -1
  67. package/.next-prod/server/app/api/deepseek/balance/route.js.nft.json +1 -1
  68. package/.next-prod/server/app/api/deepseek/credentials/route.js +1 -1
  69. package/.next-prod/server/app/api/deepseek/credentials/route.js.nft.json +1 -1
  70. package/.next-prod/server/app/api/deepseek/models/route.js +1 -1
  71. package/.next-prod/server/app/api/deepseek/models/route.js.nft.json +1 -1
  72. package/.next-prod/server/app/api/dev/spans/route.js +1 -1
  73. package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
  74. package/.next-prod/server/app/api/extension/version/route.js +1 -1
  75. package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
  76. package/.next-prod/server/app/api/file/route.js +1 -1
  77. package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
  78. package/.next-prod/server/app/api/files/blame/route.js +1 -1
  79. package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
  80. package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
  81. package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
  82. package/.next-prod/server/app/api/files/copy/route.js +1 -1
  83. package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
  84. package/.next-prod/server/app/api/files/delete/route.js +1 -1
  85. package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
  86. package/.next-prod/server/app/api/files/expanded/route.js +1 -1
  87. package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
  88. package/.next-prod/server/app/api/files/index/route.js +1 -1
  89. package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
  90. package/.next-prod/server/app/api/files/init/route.js +1 -1
  91. package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
  92. package/.next-prod/server/app/api/files/paste/route.js +1 -1
  93. package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
  94. package/.next-prod/server/app/api/files/read/route.js +1 -1
  95. package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
  96. package/.next-prod/server/app/api/files/readdir/route.js +1 -1
  97. package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
  98. package/.next-prod/server/app/api/files/recent/route.js +1 -1
  99. package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
  100. package/.next-prod/server/app/api/files/save/route.js +1 -1
  101. package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
  102. package/.next-prod/server/app/api/files/search/route.js +1 -1
  103. package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
  104. package/.next-prod/server/app/api/files/stat/route.js +1 -1
  105. package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
  106. package/.next-prod/server/app/api/files/text/route.js +1 -1
  107. package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
  108. package/.next-prod/server/app/api/git/blob/route.js +1 -1
  109. package/.next-prod/server/app/api/git/blob/route.js.nft.json +1 -1
  110. package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
  111. package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
  112. package/.next-prod/server/app/api/git/branches/route.js +1 -1
  113. package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
  114. package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
  115. package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
  116. package/.next-prod/server/app/api/git/commits/route.js +1 -1
  117. package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
  118. package/.next-prod/server/app/api/git/current-branch/route.js +1 -1
  119. package/.next-prod/server/app/api/git/current-branch/route.js.nft.json +1 -1
  120. package/.next-prod/server/app/api/git/diff/route.js +1 -1
  121. package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
  122. package/.next-prod/server/app/api/git/discard/route.js +1 -1
  123. package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
  124. package/.next-prod/server/app/api/git/stage/route.js +1 -1
  125. package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
  126. package/.next-prod/server/app/api/git/status/route.js +1 -1
  127. package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
  128. package/.next-prod/server/app/api/git/unstage/route.js +1 -1
  129. package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
  130. package/.next-prod/server/app/api/git/worktree/route.js +1 -1
  131. package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
  132. package/.next-prod/server/app/api/glm/credentials/route.js +1 -1
  133. package/.next-prod/server/app/api/glm/credentials/route.js.nft.json +1 -1
  134. package/.next-prod/server/app/api/glm/models/route.js +1 -1
  135. package/.next-prod/server/app/api/glm/models/route.js.nft.json +1 -1
  136. package/.next-prod/server/app/api/glm/usage/route.js +1 -1
  137. package/.next-prod/server/app/api/glm/usage/route.js.nft.json +1 -1
  138. package/.next-prod/server/app/api/global-state/route.js +2 -2
  139. package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
  140. package/.next-prod/server/app/api/health/route.js +1 -1
  141. package/.next-prod/server/app/api/health/route.js.nft.json +1 -1
  142. package/.next-prod/server/app/api/html-apps/[id]/route.js +1 -1
  143. package/.next-prod/server/app/api/html-apps/[id]/route.js.nft.json +1 -1
  144. package/.next-prod/server/app/api/html-apps/route.js +1 -1
  145. package/.next-prod/server/app/api/html-apps/route.js.nft.json +1 -1
  146. package/.next-prod/server/app/api/instructions/config/route.js +1 -1
  147. package/.next-prod/server/app/api/instructions/config/route.js.nft.json +1 -1
  148. package/.next-prod/server/app/api/kimi/credentials/route.js +1 -1
  149. package/.next-prod/server/app/api/kimi/credentials/route.js.nft.json +1 -1
  150. package/.next-prod/server/app/api/kimi/models/route.js +1 -1
  151. package/.next-prod/server/app/api/kimi/models/route.js.nft.json +1 -1
  152. package/.next-prod/server/app/api/kimi/usage/route.js +1 -1
  153. package/.next-prod/server/app/api/kimi/usage/route.js.nft.json +1 -1
  154. package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
  155. package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
  156. package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
  157. package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
  158. package/.next-prod/server/app/api/lsp/references/route.js +1 -1
  159. package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
  160. package/.next-prod/server/app/api/lsp/status/route.js +1 -1
  161. package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
  162. package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
  163. package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
  164. package/.next-prod/server/app/api/mysql/columns/route.js +1 -1
  165. package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
  166. package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
  167. package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
  168. package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
  169. package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
  170. package/.next-prod/server/app/api/mysql/export/route.js +1 -1
  171. package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
  172. package/.next-prod/server/app/api/mysql/query/route.js +1 -1
  173. package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
  174. package/.next-prod/server/app/api/mysql/schemas/route.js +1 -1
  175. package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
  176. package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
  177. package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
  178. package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
  179. package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
  180. package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
  181. package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
  182. package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
  183. package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
  184. package/.next-prod/server/app/api/note/route.js +1 -1
  185. package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
  186. package/.next-prod/server/app/api/ollama/config/route.js +1 -1
  187. package/.next-prod/server/app/api/ollama/config/route.js.nft.json +1 -1
  188. package/.next-prod/server/app/api/ollama/models/route.js +1 -1
  189. package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
  190. package/.next-prod/server/app/api/ollama/start/route.js +1 -1
  191. package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
  192. package/.next-prod/server/app/api/open-cursor/route.js +1 -1
  193. package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
  194. package/.next-prod/server/app/api/open-vscode/route.js +1 -1
  195. package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
  196. package/.next-prod/server/app/api/pick-folder/route.js +1 -1
  197. package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
  198. package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
  199. package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
  200. package/.next-prod/server/app/api/project-settings/route.js +1 -1
  201. package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
  202. package/.next-prod/server/app/api/project-state/route.js +2 -2
  203. package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
  204. package/.next-prod/server/app/api/projectGraph/affected/route.js +1 -1
  205. package/.next-prod/server/app/api/projectGraph/affected/route.js.nft.json +1 -1
  206. package/.next-prod/server/app/api/projectGraph/callees/route.js +1 -1
  207. package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -1
  208. package/.next-prod/server/app/api/projectGraph/callers/route.js +1 -1
  209. package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -1
  210. package/.next-prod/server/app/api/projectGraph/coedit/route.js +1 -1
  211. package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -1
  212. package/.next-prod/server/app/api/projectGraph/context/route.js +1 -1
  213. package/.next-prod/server/app/api/projectGraph/context/route.js.nft.json +1 -1
  214. package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
  215. package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
  216. package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
  217. package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
  218. package/.next-prod/server/app/api/projectGraph/impact/route.js +1 -1
  219. package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -1
  220. package/.next-prod/server/app/api/projectGraph/related/route.js +1 -1
  221. package/.next-prod/server/app/api/projectGraph/related/route.js.nft.json +1 -1
  222. package/.next-prod/server/app/api/projectGraph/risk/route.js +1 -1
  223. package/.next-prod/server/app/api/projectGraph/risk/route.js.nft.json +1 -1
  224. package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
  225. package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
  226. package/.next-prod/server/app/api/projects/route.js +1 -1
  227. package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
  228. package/.next-prod/server/app/api/push/public-key/route.js +1 -1
  229. package/.next-prod/server/app/api/push/public-key/route.js.nft.json +1 -1
  230. package/.next-prod/server/app/api/push/subscribe/route.js +1 -1
  231. package/.next-prod/server/app/api/push/subscribe/route.js.nft.json +1 -1
  232. package/.next-prod/server/app/api/push/unsubscribe/route.js +1 -1
  233. package/.next-prod/server/app/api/push/unsubscribe/route.js.nft.json +1 -1
  234. package/.next-prod/server/app/api/redis/command/route.js +1 -1
  235. package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
  236. package/.next-prod/server/app/api/redis/connect/route.js +1 -1
  237. package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
  238. package/.next-prod/server/app/api/redis/delete/route.js +1 -1
  239. package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
  240. package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
  241. package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
  242. package/.next-prod/server/app/api/redis/get/route.js +1 -1
  243. package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
  244. package/.next-prod/server/app/api/redis/keys/route.js +1 -1
  245. package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
  246. package/.next-prod/server/app/api/redis/set/route.js +1 -1
  247. package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
  248. package/.next-prod/server/app/api/restart/route.js +1 -1
  249. package/.next-prod/server/app/api/restart/route.js.nft.json +1 -1
  250. package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
  251. package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
  252. package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
  253. package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
  254. package/.next-prod/server/app/api/review/[id]/route.js +1 -1
  255. package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
  256. package/.next-prod/server/app/api/review/identify/route.js +1 -1
  257. package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
  258. package/.next-prod/server/app/api/review/order/route.js +1 -1
  259. package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
  260. package/.next-prod/server/app/api/review/route.js +1 -1
  261. package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
  262. package/.next-prod/server/app/api/review/share-info/route.js +1 -1
  263. package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
  264. package/.next-prod/server/app/api/review/users/route.js +1 -1
  265. package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
  266. package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
  267. package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
  268. package/.next-prod/server/app/api/services/config/route.js +1 -1
  269. package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
  270. package/.next-prod/server/app/api/services/scripts/route.js +1 -1
  271. package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
  272. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
  273. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
  274. package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
  275. package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
  276. package/.next-prod/server/app/api/session/[sessionId]/turn/route.js +2 -2
  277. package/.next-prod/server/app/api/session/[sessionId]/turn/route.js.nft.json +1 -1
  278. package/.next-prod/server/app/api/session/user-messages/route.js +1 -1
  279. package/.next-prod/server/app/api/session/user-messages/route.js.nft.json +1 -1
  280. package/.next-prod/server/app/api/session-by-path/route.js +1 -1
  281. package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
  282. package/.next-prod/server/app/api/sessions/delegate/route.js +1 -1
  283. package/.next-prod/server/app/api/sessions/delegate/route.js.nft.json +1 -1
  284. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
  285. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
  286. package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
  287. package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
  288. package/.next-prod/server/app/api/sessions/route.js +1 -1
  289. package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
  290. package/.next-prod/server/app/api/sessions/search/route.js +1 -1
  291. package/.next-prod/server/app/api/sessions/search/route.js.nft.json +1 -1
  292. package/.next-prod/server/app/api/sessions/status/route.js +1 -1
  293. package/.next-prod/server/app/api/sessions/status/route.js.nft.json +1 -1
  294. package/.next-prod/server/app/api/settings/route.js +1 -1
  295. package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
  296. package/.next-prod/server/app/api/shutdown/route.js +1 -1
  297. package/.next-prod/server/app/api/shutdown/route.js.nft.json +1 -1
  298. package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
  299. package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
  300. package/.next-prod/server/app/api/skills/content/route.js +1 -1
  301. package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
  302. package/.next-prod/server/app/api/skills/route.js +1 -1
  303. package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
  304. package/.next-prod/server/app/api/snapshots/blob/route.js +1 -1
  305. package/.next-prod/server/app/api/snapshots/blob/route.js.nft.json +1 -1
  306. package/.next-prod/server/app/api/snapshots/diff/route.js +1 -1
  307. package/.next-prod/server/app/api/snapshots/diff/route.js.nft.json +1 -1
  308. package/.next-prod/server/app/api/snapshots/route.js +1 -1
  309. package/.next-prod/server/app/api/snapshots/route.js.nft.json +1 -1
  310. package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
  311. package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
  312. package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
  313. package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
  314. package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
  315. package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
  316. package/.next-prod/server/app/api/terminal/env/route.js +1 -1
  317. package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
  318. package/.next-prod/server/app/api/terminal/history/route.js +1 -1
  319. package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
  320. package/.next-prod/server/app/api/update/route.js +1 -1
  321. package/.next-prod/server/app/api/update/route.js.nft.json +1 -1
  322. package/.next-prod/server/app/api/update-state/route.js +1 -1
  323. package/.next-prod/server/app/api/update-state/route.js.nft.json +1 -1
  324. package/.next-prod/server/app/api/version/route.js +1 -1
  325. package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
  326. package/.next-prod/server/app/apps/[...path]/route.js +1 -1
  327. package/.next-prod/server/app/apps/[...path]/route.js.nft.json +1 -1
  328. package/.next-prod/server/app/favicon.ico/route.js +1 -1
  329. package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
  330. package/.next-prod/server/app/m/page.js +1 -1
  331. package/.next-prod/server/app/m/page.js.nft.json +1 -1
  332. package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
  333. package/.next-prod/server/app/manifest.webmanifest/route.js +2 -2
  334. package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  335. package/.next-prod/server/app/page.js +1 -1
  336. package/.next-prod/server/app/page.js.nft.json +1 -1
  337. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  338. package/.next-prod/server/app/project/page.js +1 -1
  339. package/.next-prod/server/app/project/page.js.nft.json +1 -1
  340. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  341. package/.next-prod/server/app/review/[id]/page.js +1 -1
  342. package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
  343. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  344. package/.next-prod/server/app-paths-manifest.json +3 -1
  345. package/.next-prod/server/chunks/2493.js +13 -9
  346. package/.next-prod/server/chunks/{7956.js → 3354.js} +2 -2
  347. package/.next-prod/server/chunks/6495.js +1 -1
  348. package/.next-prod/server/chunks/6548.js +1 -1
  349. package/.next-prod/server/chunks/7438.js +764 -0
  350. package/.next-prod/server/chunks/{1653.js → 8022.js} +2 -2
  351. package/.next-prod/server/middleware-build-manifest.js +1 -1
  352. package/.next-prod/server/pages/404.html +2 -2
  353. package/.next-prod/server/pages/500.html +1 -1
  354. package/.next-prod/server/server-reference-manifest.json +1 -1
  355. package/.next-prod/static/O8neHUIr3dQhe1jcOUsQ8/_buildManifest.js +1 -0
  356. package/.next-prod/static/chunks/{103-1f50be74a00f89af.js → 50015-b81552adf20a6a33.js} +2 -2
  357. package/.next-prod/static/chunks/72539-049ac78fc767d177.js +17 -0
  358. package/.next-prod/static/chunks/89656-d9dd3a8559041236.js +34 -0
  359. package/.next-prod/static/chunks/99092-5b836813f4b1d4b3.js +716 -0
  360. package/.next-prod/static/chunks/app/_global-error/{page-b56c0b18a3b4d026.js → page-e2f146f38bb4df42.js} +1 -1
  361. package/.next-prod/static/chunks/app/api/agent/test/{route-b56c0b18a3b4d026.js → route-e2f146f38bb4df42.js} +1 -1
  362. package/.next-prod/static/chunks/app/api/bash/{route-b56c0b18a3b4d026.js → route-e2f146f38bb4df42.js} +1 -1
  363. package/.next-prod/static/chunks/app/api/{chat/codex/route-b56c0b18a3b4d026.js → bots/[id]/route-e2f146f38bb4df42.js} +1 -1
  364. package/.next-prod/static/chunks/app/api/bots/route-e2f146f38bb4df42.js +1 -0
  365. package/.next-prod/static/chunks/app/api/chat/codex/route-e2f146f38bb4df42.js +1 -0
  366. package/.next-prod/static/chunks/app/api/chat/deepseek/route-e2f146f38bb4df42.js +1 -0
  367. package/.next-prod/static/chunks/app/api/chat/glm/route-e2f146f38bb4df42.js +1 -0
  368. package/.next-prod/static/chunks/app/api/chat/kimi/route-e2f146f38bb4df42.js +1 -0
  369. package/.next-prod/static/chunks/app/api/chat/ollama/route-e2f146f38bb4df42.js +1 -0
  370. package/.next-prod/static/chunks/app/api/chat/route-e2f146f38bb4df42.js +1 -0
  371. package/.next-prod/static/chunks/app/api/chat/stop/route-e2f146f38bb4df42.js +1 -0
  372. package/.next-prod/static/chunks/app/api/claude-stats/route-e2f146f38bb4df42.js +1 -0
  373. package/.next-prod/static/chunks/app/api/commands/route-e2f146f38bb4df42.js +1 -0
  374. package/.next-prod/static/chunks/app/api/comments/route-e2f146f38bb4df42.js +1 -0
  375. package/.next-prod/static/chunks/app/api/db/columns/route-e2f146f38bb4df42.js +1 -0
  376. package/.next-prod/static/chunks/app/api/db/connect/route-e2f146f38bb4df42.js +1 -0
  377. package/.next-prod/static/chunks/app/api/db/disconnect/route-e2f146f38bb4df42.js +1 -0
  378. package/.next-prod/static/chunks/app/api/db/export/route-e2f146f38bb4df42.js +1 -0
  379. package/.next-prod/static/chunks/app/api/db/query/route-e2f146f38bb4df42.js +1 -0
  380. package/.next-prod/static/chunks/app/api/db/schemas/route-e2f146f38bb4df42.js +1 -0
  381. package/.next-prod/static/chunks/app/api/deepseek/balance/route-e2f146f38bb4df42.js +1 -0
  382. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-e2f146f38bb4df42.js +1 -0
  383. package/.next-prod/static/chunks/app/api/deepseek/models/route-e2f146f38bb4df42.js +1 -0
  384. package/.next-prod/static/chunks/app/api/dev/spans/route-e2f146f38bb4df42.js +1 -0
  385. package/.next-prod/static/chunks/app/api/extension/version/route-e2f146f38bb4df42.js +1 -0
  386. package/.next-prod/static/chunks/app/api/file/route-e2f146f38bb4df42.js +1 -0
  387. package/.next-prod/static/chunks/app/api/files/blame/route-e2f146f38bb4df42.js +1 -0
  388. package/.next-prod/static/chunks/app/api/files/clipboard/route-e2f146f38bb4df42.js +1 -0
  389. package/.next-prod/static/chunks/app/api/files/copy/route-e2f146f38bb4df42.js +1 -0
  390. package/.next-prod/static/chunks/app/api/files/delete/route-e2f146f38bb4df42.js +1 -0
  391. package/.next-prod/static/chunks/app/api/files/expanded/route-e2f146f38bb4df42.js +1 -0
  392. package/.next-prod/static/chunks/app/api/files/index/route-e2f146f38bb4df42.js +1 -0
  393. package/.next-prod/static/chunks/app/api/files/init/route-e2f146f38bb4df42.js +1 -0
  394. package/.next-prod/static/chunks/app/api/files/paste/route-e2f146f38bb4df42.js +1 -0
  395. package/.next-prod/static/chunks/app/api/files/read/route-e2f146f38bb4df42.js +1 -0
  396. package/.next-prod/static/chunks/app/api/files/readdir/route-e2f146f38bb4df42.js +1 -0
  397. package/.next-prod/static/chunks/app/api/files/recent/route-e2f146f38bb4df42.js +1 -0
  398. package/.next-prod/static/chunks/app/api/files/save/route-e2f146f38bb4df42.js +1 -0
  399. package/.next-prod/static/chunks/app/api/files/search/route-e2f146f38bb4df42.js +1 -0
  400. package/.next-prod/static/chunks/app/api/files/stat/route-e2f146f38bb4df42.js +1 -0
  401. package/.next-prod/static/chunks/app/api/files/text/route-e2f146f38bb4df42.js +1 -0
  402. package/.next-prod/static/chunks/app/api/git/blob/route-e2f146f38bb4df42.js +1 -0
  403. package/.next-prod/static/chunks/app/api/git/branch-diff/route-e2f146f38bb4df42.js +1 -0
  404. package/.next-prod/static/chunks/app/api/git/branches/route-e2f146f38bb4df42.js +1 -0
  405. package/.next-prod/static/chunks/app/api/git/commit-diff/route-e2f146f38bb4df42.js +1 -0
  406. package/.next-prod/static/chunks/app/api/git/commits/route-e2f146f38bb4df42.js +1 -0
  407. package/.next-prod/static/chunks/app/api/git/current-branch/route-e2f146f38bb4df42.js +1 -0
  408. package/.next-prod/static/chunks/app/api/git/diff/route-e2f146f38bb4df42.js +1 -0
  409. package/.next-prod/static/chunks/app/api/git/discard/route-e2f146f38bb4df42.js +1 -0
  410. package/.next-prod/static/chunks/app/api/git/stage/route-e2f146f38bb4df42.js +1 -0
  411. package/.next-prod/static/chunks/app/api/git/status/route-e2f146f38bb4df42.js +1 -0
  412. package/.next-prod/static/chunks/app/api/git/unstage/route-e2f146f38bb4df42.js +1 -0
  413. package/.next-prod/static/chunks/app/api/git/worktree/route-e2f146f38bb4df42.js +1 -0
  414. package/.next-prod/static/chunks/app/api/glm/credentials/route-e2f146f38bb4df42.js +1 -0
  415. package/.next-prod/static/chunks/app/api/glm/models/route-e2f146f38bb4df42.js +1 -0
  416. package/.next-prod/static/chunks/app/api/glm/usage/route-e2f146f38bb4df42.js +1 -0
  417. package/.next-prod/static/chunks/app/api/global-state/route-e2f146f38bb4df42.js +1 -0
  418. package/.next-prod/static/chunks/app/api/health/route-e2f146f38bb4df42.js +1 -0
  419. package/.next-prod/static/chunks/app/api/html-apps/[id]/route-e2f146f38bb4df42.js +1 -0
  420. package/.next-prod/static/chunks/app/api/html-apps/route-e2f146f38bb4df42.js +1 -0
  421. package/.next-prod/static/chunks/app/api/instructions/config/route-e2f146f38bb4df42.js +1 -0
  422. package/.next-prod/static/chunks/app/api/kimi/credentials/route-e2f146f38bb4df42.js +1 -0
  423. package/.next-prod/static/chunks/app/api/kimi/models/route-e2f146f38bb4df42.js +1 -0
  424. package/.next-prod/static/chunks/app/api/kimi/usage/route-e2f146f38bb4df42.js +1 -0
  425. package/.next-prod/static/chunks/app/api/lsp/definition/route-e2f146f38bb4df42.js +1 -0
  426. package/.next-prod/static/chunks/app/api/lsp/hover/route-e2f146f38bb4df42.js +1 -0
  427. package/.next-prod/static/chunks/app/api/lsp/references/route-e2f146f38bb4df42.js +1 -0
  428. package/.next-prod/static/chunks/app/api/lsp/status/route-e2f146f38bb4df42.js +1 -0
  429. package/.next-prod/static/chunks/app/api/lsp/warmup/route-e2f146f38bb4df42.js +1 -0
  430. package/.next-prod/static/chunks/app/api/mysql/columns/route-e2f146f38bb4df42.js +1 -0
  431. package/.next-prod/static/chunks/app/api/mysql/connect/route-e2f146f38bb4df42.js +1 -0
  432. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-e2f146f38bb4df42.js +1 -0
  433. package/.next-prod/static/chunks/app/api/mysql/export/route-e2f146f38bb4df42.js +1 -0
  434. package/.next-prod/static/chunks/app/api/mysql/query/route-e2f146f38bb4df42.js +1 -0
  435. package/.next-prod/static/chunks/app/api/mysql/schemas/route-e2f146f38bb4df42.js +1 -0
  436. package/.next-prod/static/chunks/app/api/neo4j/connect/route-e2f146f38bb4df42.js +1 -0
  437. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-e2f146f38bb4df42.js +1 -0
  438. package/.next-prod/static/chunks/app/api/neo4j/query/route-e2f146f38bb4df42.js +1 -0
  439. package/.next-prod/static/chunks/app/api/neo4j/schema/route-e2f146f38bb4df42.js +1 -0
  440. package/.next-prod/static/chunks/app/api/note/route-e2f146f38bb4df42.js +1 -0
  441. package/.next-prod/static/chunks/app/api/ollama/config/route-e2f146f38bb4df42.js +1 -0
  442. package/.next-prod/static/chunks/app/api/ollama/models/route-e2f146f38bb4df42.js +1 -0
  443. package/.next-prod/static/chunks/app/api/ollama/start/route-e2f146f38bb4df42.js +1 -0
  444. package/.next-prod/static/chunks/app/api/open-cursor/route-e2f146f38bb4df42.js +1 -0
  445. package/.next-prod/static/chunks/app/api/open-vscode/route-e2f146f38bb4df42.js +1 -0
  446. package/.next-prod/static/chunks/app/api/pick-folder/route-e2f146f38bb4df42.js +1 -0
  447. package/.next-prod/static/chunks/app/api/pinned-sessions/route-e2f146f38bb4df42.js +1 -0
  448. package/.next-prod/static/chunks/app/api/project-settings/route-e2f146f38bb4df42.js +1 -0
  449. package/.next-prod/static/chunks/app/api/project-state/route-e2f146f38bb4df42.js +1 -0
  450. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-e2f146f38bb4df42.js +1 -0
  451. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-e2f146f38bb4df42.js +1 -0
  452. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-e2f146f38bb4df42.js +1 -0
  453. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-e2f146f38bb4df42.js +1 -0
  454. package/.next-prod/static/chunks/app/api/projectGraph/context/route-e2f146f38bb4df42.js +1 -0
  455. package/.next-prod/static/chunks/app/api/projectGraph/file/route-e2f146f38bb4df42.js +1 -0
  456. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-e2f146f38bb4df42.js +1 -0
  457. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-e2f146f38bb4df42.js +1 -0
  458. package/.next-prod/static/chunks/app/api/projectGraph/related/route-e2f146f38bb4df42.js +1 -0
  459. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-e2f146f38bb4df42.js +1 -0
  460. package/.next-prod/static/chunks/app/api/projectGraph/search/route-e2f146f38bb4df42.js +1 -0
  461. package/.next-prod/static/chunks/app/api/projects/route-e2f146f38bb4df42.js +1 -0
  462. package/.next-prod/static/chunks/app/api/push/public-key/route-e2f146f38bb4df42.js +1 -0
  463. package/.next-prod/static/chunks/app/api/push/subscribe/route-e2f146f38bb4df42.js +1 -0
  464. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-e2f146f38bb4df42.js +1 -0
  465. package/.next-prod/static/chunks/app/api/redis/command/route-e2f146f38bb4df42.js +1 -0
  466. package/.next-prod/static/chunks/app/api/redis/connect/route-e2f146f38bb4df42.js +1 -0
  467. package/.next-prod/static/chunks/app/api/redis/delete/route-e2f146f38bb4df42.js +1 -0
  468. package/.next-prod/static/chunks/app/api/redis/disconnect/route-e2f146f38bb4df42.js +1 -0
  469. package/.next-prod/static/chunks/app/api/redis/get/route-e2f146f38bb4df42.js +1 -0
  470. package/.next-prod/static/chunks/app/api/redis/keys/route-e2f146f38bb4df42.js +1 -0
  471. package/.next-prod/static/chunks/app/api/redis/set/route-e2f146f38bb4df42.js +1 -0
  472. package/.next-prod/static/chunks/app/api/restart/route-e2f146f38bb4df42.js +1 -0
  473. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-e2f146f38bb4df42.js +1 -0
  474. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-e2f146f38bb4df42.js +1 -0
  475. package/.next-prod/static/chunks/app/api/review/[id]/route-e2f146f38bb4df42.js +1 -0
  476. package/.next-prod/static/chunks/app/api/review/identify/route-e2f146f38bb4df42.js +1 -0
  477. package/.next-prod/static/chunks/app/api/review/order/route-e2f146f38bb4df42.js +1 -0
  478. package/.next-prod/static/chunks/app/api/review/route-e2f146f38bb4df42.js +1 -0
  479. package/.next-prod/static/chunks/app/api/review/share-info/route-e2f146f38bb4df42.js +1 -0
  480. package/.next-prod/static/chunks/app/api/review/users/route-e2f146f38bb4df42.js +1 -0
  481. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-e2f146f38bb4df42.js +1 -0
  482. package/.next-prod/static/chunks/app/api/services/config/route-e2f146f38bb4df42.js +1 -0
  483. package/.next-prod/static/chunks/app/api/services/scripts/route-e2f146f38bb4df42.js +1 -0
  484. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-e2f146f38bb4df42.js +1 -0
  485. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-e2f146f38bb4df42.js +1 -0
  486. package/.next-prod/static/chunks/app/api/session/[sessionId]/turn/route-e2f146f38bb4df42.js +1 -0
  487. package/.next-prod/static/chunks/app/api/session/user-messages/route-e2f146f38bb4df42.js +1 -0
  488. package/.next-prod/static/chunks/app/api/session-by-path/route-e2f146f38bb4df42.js +1 -0
  489. package/.next-prod/static/chunks/app/api/sessions/delegate/route-e2f146f38bb4df42.js +1 -0
  490. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-e2f146f38bb4df42.js +1 -0
  491. package/.next-prod/static/chunks/app/api/sessions/projects/route-e2f146f38bb4df42.js +1 -0
  492. package/.next-prod/static/chunks/app/api/sessions/route-e2f146f38bb4df42.js +1 -0
  493. package/.next-prod/static/chunks/app/api/sessions/search/route-e2f146f38bb4df42.js +1 -0
  494. package/.next-prod/static/chunks/app/api/sessions/status/route-e2f146f38bb4df42.js +1 -0
  495. package/.next-prod/static/chunks/app/api/settings/route-e2f146f38bb4df42.js +1 -0
  496. package/.next-prod/static/chunks/app/api/shutdown/route-e2f146f38bb4df42.js +1 -0
  497. package/.next-prod/static/chunks/app/api/skills/[id]/route-e2f146f38bb4df42.js +1 -0
  498. package/.next-prod/static/chunks/app/api/skills/content/route-e2f146f38bb4df42.js +1 -0
  499. package/.next-prod/static/chunks/app/api/skills/route-e2f146f38bb4df42.js +1 -0
  500. package/.next-prod/static/chunks/app/api/snapshots/blob/route-e2f146f38bb4df42.js +1 -0
  501. package/.next-prod/static/chunks/app/api/snapshots/diff/route-e2f146f38bb4df42.js +1 -0
  502. package/.next-prod/static/chunks/app/api/snapshots/route-e2f146f38bb4df42.js +1 -0
  503. package/.next-prod/static/chunks/app/api/terminal/aliases/route-e2f146f38bb4df42.js +1 -0
  504. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-e2f146f38bb4df42.js +1 -0
  505. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-e2f146f38bb4df42.js +1 -0
  506. package/.next-prod/static/chunks/app/api/terminal/env/route-e2f146f38bb4df42.js +1 -0
  507. package/.next-prod/static/chunks/app/api/terminal/history/route-e2f146f38bb4df42.js +1 -0
  508. package/.next-prod/static/chunks/app/api/update/route-e2f146f38bb4df42.js +1 -0
  509. package/.next-prod/static/chunks/app/api/update-state/route-e2f146f38bb4df42.js +1 -0
  510. package/.next-prod/static/chunks/app/api/version/route-e2f146f38bb4df42.js +1 -0
  511. package/.next-prod/static/chunks/app/apps/[...path]/route-e2f146f38bb4df42.js +1 -0
  512. package/.next-prod/static/chunks/app/layout-347ca1b3228d5b23.js +1 -0
  513. package/.next-prod/static/chunks/app/manifest.webmanifest/route-e2f146f38bb4df42.js +1 -0
  514. package/.next-prod/static/chunks/app/page-2ade7ecd21636624.js +1 -0
  515. package/.next-prod/static/chunks/app/project/page-2ade7ecd21636624.js +1 -0
  516. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-e2f146f38bb4df42.js +1 -0
  517. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-e2f146f38bb4df42.js +1 -0
  518. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-e2f146f38bb4df42.js +1 -0
  519. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-e2f146f38bb4df42.js +1 -0
  520. package/.next-prod/static/css/7a02a222d1299650.css +1 -0
  521. package/.next-prod/trace +15 -15
  522. package/.next-prod/trace-build +1 -1
  523. package/.next-prod/types/app/api/bots/[id]/route.ts +353 -0
  524. package/.next-prod/types/app/api/bots/route.ts +353 -0
  525. package/.next-prod/types/routes.d.ts +3 -1
  526. package/.next-prod/types/validator.ts +18 -0
  527. package/README.md +13 -0
  528. package/README.zh.md +13 -0
  529. package/bots/README.md +86 -0
  530. package/bots/cockpit-helper/BOT.md +95 -0
  531. package/bots/cockpit-helper/commitments/active.md +3 -0
  532. package/bots/cockpit-helper/evidence/refs.md +3 -0
  533. package/bots/cockpit-helper/identity/persona.md +25 -0
  534. package/bots/cockpit-helper/identity/principles.md +49 -0
  535. package/bots/cockpit-helper/memory/facts.md +3 -0
  536. package/bots/cockpit-helper/relationships/user.md +3 -0
  537. package/dist/{chunk-JJWVBF6H.mjs → chunk-BCWVTDEZ.mjs} +648 -140
  538. package/dist/{chunk-6R4AHIIV.mjs → chunk-QY2K7YIF.mjs} +1 -1
  539. package/dist/httpApi.mjs +2 -2
  540. package/dist/scheduledTasks.mjs +80 -14
  541. package/dist/wsServer.mjs +2 -2
  542. package/package.json +2 -1
  543. package/skills/README.md +18 -2
  544. package/skills/bot/SKILL.md +155 -0
  545. package/skills/bot-run/SKILL.md +214 -0
  546. package/skills/bot-turn/SKILL.md +99 -0
  547. package/skills/bot-turn/attach.md +45 -0
  548. package/skills/bot-turn/export.md +113 -0
  549. package/skills/bot-turn/review.md +101 -0
  550. package/skills/bot-turn/writing.md +110 -0
  551. package/.next-prod/server/chunks/5750.js +0 -762
  552. package/.next-prod/static/chunks/72539-7e4ca2de5c9f3f90.js +0 -17
  553. package/.next-prod/static/chunks/89656-bc48af1f9ee9c312.js +0 -32
  554. package/.next-prod/static/chunks/99092-36ee2c49e4c4c059.js +0 -716
  555. package/.next-prod/static/chunks/app/api/chat/deepseek/route-b56c0b18a3b4d026.js +0 -1
  556. package/.next-prod/static/chunks/app/api/chat/glm/route-b56c0b18a3b4d026.js +0 -1
  557. package/.next-prod/static/chunks/app/api/chat/kimi/route-b56c0b18a3b4d026.js +0 -1
  558. package/.next-prod/static/chunks/app/api/chat/ollama/route-b56c0b18a3b4d026.js +0 -1
  559. package/.next-prod/static/chunks/app/api/chat/route-b56c0b18a3b4d026.js +0 -1
  560. package/.next-prod/static/chunks/app/api/chat/stop/route-b56c0b18a3b4d026.js +0 -1
  561. package/.next-prod/static/chunks/app/api/claude-stats/route-b56c0b18a3b4d026.js +0 -1
  562. package/.next-prod/static/chunks/app/api/commands/route-b56c0b18a3b4d026.js +0 -1
  563. package/.next-prod/static/chunks/app/api/comments/route-b56c0b18a3b4d026.js +0 -1
  564. package/.next-prod/static/chunks/app/api/db/columns/route-b56c0b18a3b4d026.js +0 -1
  565. package/.next-prod/static/chunks/app/api/db/connect/route-b56c0b18a3b4d026.js +0 -1
  566. package/.next-prod/static/chunks/app/api/db/disconnect/route-b56c0b18a3b4d026.js +0 -1
  567. package/.next-prod/static/chunks/app/api/db/export/route-b56c0b18a3b4d026.js +0 -1
  568. package/.next-prod/static/chunks/app/api/db/query/route-b56c0b18a3b4d026.js +0 -1
  569. package/.next-prod/static/chunks/app/api/db/schemas/route-b56c0b18a3b4d026.js +0 -1
  570. package/.next-prod/static/chunks/app/api/deepseek/balance/route-b56c0b18a3b4d026.js +0 -1
  571. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-b56c0b18a3b4d026.js +0 -1
  572. package/.next-prod/static/chunks/app/api/deepseek/models/route-b56c0b18a3b4d026.js +0 -1
  573. package/.next-prod/static/chunks/app/api/dev/spans/route-b56c0b18a3b4d026.js +0 -1
  574. package/.next-prod/static/chunks/app/api/extension/version/route-b56c0b18a3b4d026.js +0 -1
  575. package/.next-prod/static/chunks/app/api/file/route-b56c0b18a3b4d026.js +0 -1
  576. package/.next-prod/static/chunks/app/api/files/blame/route-b56c0b18a3b4d026.js +0 -1
  577. package/.next-prod/static/chunks/app/api/files/clipboard/route-b56c0b18a3b4d026.js +0 -1
  578. package/.next-prod/static/chunks/app/api/files/copy/route-b56c0b18a3b4d026.js +0 -1
  579. package/.next-prod/static/chunks/app/api/files/delete/route-b56c0b18a3b4d026.js +0 -1
  580. package/.next-prod/static/chunks/app/api/files/expanded/route-b56c0b18a3b4d026.js +0 -1
  581. package/.next-prod/static/chunks/app/api/files/index/route-b56c0b18a3b4d026.js +0 -1
  582. package/.next-prod/static/chunks/app/api/files/init/route-b56c0b18a3b4d026.js +0 -1
  583. package/.next-prod/static/chunks/app/api/files/paste/route-b56c0b18a3b4d026.js +0 -1
  584. package/.next-prod/static/chunks/app/api/files/read/route-b56c0b18a3b4d026.js +0 -1
  585. package/.next-prod/static/chunks/app/api/files/readdir/route-b56c0b18a3b4d026.js +0 -1
  586. package/.next-prod/static/chunks/app/api/files/recent/route-b56c0b18a3b4d026.js +0 -1
  587. package/.next-prod/static/chunks/app/api/files/save/route-b56c0b18a3b4d026.js +0 -1
  588. package/.next-prod/static/chunks/app/api/files/search/route-b56c0b18a3b4d026.js +0 -1
  589. package/.next-prod/static/chunks/app/api/files/stat/route-b56c0b18a3b4d026.js +0 -1
  590. package/.next-prod/static/chunks/app/api/files/text/route-b56c0b18a3b4d026.js +0 -1
  591. package/.next-prod/static/chunks/app/api/git/blob/route-b56c0b18a3b4d026.js +0 -1
  592. package/.next-prod/static/chunks/app/api/git/branch-diff/route-b56c0b18a3b4d026.js +0 -1
  593. package/.next-prod/static/chunks/app/api/git/branches/route-b56c0b18a3b4d026.js +0 -1
  594. package/.next-prod/static/chunks/app/api/git/commit-diff/route-b56c0b18a3b4d026.js +0 -1
  595. package/.next-prod/static/chunks/app/api/git/commits/route-b56c0b18a3b4d026.js +0 -1
  596. package/.next-prod/static/chunks/app/api/git/current-branch/route-b56c0b18a3b4d026.js +0 -1
  597. package/.next-prod/static/chunks/app/api/git/diff/route-b56c0b18a3b4d026.js +0 -1
  598. package/.next-prod/static/chunks/app/api/git/discard/route-b56c0b18a3b4d026.js +0 -1
  599. package/.next-prod/static/chunks/app/api/git/stage/route-b56c0b18a3b4d026.js +0 -1
  600. package/.next-prod/static/chunks/app/api/git/status/route-b56c0b18a3b4d026.js +0 -1
  601. package/.next-prod/static/chunks/app/api/git/unstage/route-b56c0b18a3b4d026.js +0 -1
  602. package/.next-prod/static/chunks/app/api/git/worktree/route-b56c0b18a3b4d026.js +0 -1
  603. package/.next-prod/static/chunks/app/api/glm/credentials/route-b56c0b18a3b4d026.js +0 -1
  604. package/.next-prod/static/chunks/app/api/glm/models/route-b56c0b18a3b4d026.js +0 -1
  605. package/.next-prod/static/chunks/app/api/glm/usage/route-b56c0b18a3b4d026.js +0 -1
  606. package/.next-prod/static/chunks/app/api/global-state/route-b56c0b18a3b4d026.js +0 -1
  607. package/.next-prod/static/chunks/app/api/health/route-b56c0b18a3b4d026.js +0 -1
  608. package/.next-prod/static/chunks/app/api/html-apps/[id]/route-b56c0b18a3b4d026.js +0 -1
  609. package/.next-prod/static/chunks/app/api/html-apps/route-b56c0b18a3b4d026.js +0 -1
  610. package/.next-prod/static/chunks/app/api/instructions/config/route-b56c0b18a3b4d026.js +0 -1
  611. package/.next-prod/static/chunks/app/api/kimi/credentials/route-b56c0b18a3b4d026.js +0 -1
  612. package/.next-prod/static/chunks/app/api/kimi/models/route-b56c0b18a3b4d026.js +0 -1
  613. package/.next-prod/static/chunks/app/api/kimi/usage/route-b56c0b18a3b4d026.js +0 -1
  614. package/.next-prod/static/chunks/app/api/lsp/definition/route-b56c0b18a3b4d026.js +0 -1
  615. package/.next-prod/static/chunks/app/api/lsp/hover/route-b56c0b18a3b4d026.js +0 -1
  616. package/.next-prod/static/chunks/app/api/lsp/references/route-b56c0b18a3b4d026.js +0 -1
  617. package/.next-prod/static/chunks/app/api/lsp/status/route-b56c0b18a3b4d026.js +0 -1
  618. package/.next-prod/static/chunks/app/api/lsp/warmup/route-b56c0b18a3b4d026.js +0 -1
  619. package/.next-prod/static/chunks/app/api/mysql/columns/route-b56c0b18a3b4d026.js +0 -1
  620. package/.next-prod/static/chunks/app/api/mysql/connect/route-b56c0b18a3b4d026.js +0 -1
  621. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-b56c0b18a3b4d026.js +0 -1
  622. package/.next-prod/static/chunks/app/api/mysql/export/route-b56c0b18a3b4d026.js +0 -1
  623. package/.next-prod/static/chunks/app/api/mysql/query/route-b56c0b18a3b4d026.js +0 -1
  624. package/.next-prod/static/chunks/app/api/mysql/schemas/route-b56c0b18a3b4d026.js +0 -1
  625. package/.next-prod/static/chunks/app/api/neo4j/connect/route-b56c0b18a3b4d026.js +0 -1
  626. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-b56c0b18a3b4d026.js +0 -1
  627. package/.next-prod/static/chunks/app/api/neo4j/query/route-b56c0b18a3b4d026.js +0 -1
  628. package/.next-prod/static/chunks/app/api/neo4j/schema/route-b56c0b18a3b4d026.js +0 -1
  629. package/.next-prod/static/chunks/app/api/note/route-b56c0b18a3b4d026.js +0 -1
  630. package/.next-prod/static/chunks/app/api/ollama/config/route-b56c0b18a3b4d026.js +0 -1
  631. package/.next-prod/static/chunks/app/api/ollama/models/route-b56c0b18a3b4d026.js +0 -1
  632. package/.next-prod/static/chunks/app/api/ollama/start/route-b56c0b18a3b4d026.js +0 -1
  633. package/.next-prod/static/chunks/app/api/open-cursor/route-b56c0b18a3b4d026.js +0 -1
  634. package/.next-prod/static/chunks/app/api/open-vscode/route-b56c0b18a3b4d026.js +0 -1
  635. package/.next-prod/static/chunks/app/api/pick-folder/route-b56c0b18a3b4d026.js +0 -1
  636. package/.next-prod/static/chunks/app/api/pinned-sessions/route-b56c0b18a3b4d026.js +0 -1
  637. package/.next-prod/static/chunks/app/api/project-settings/route-b56c0b18a3b4d026.js +0 -1
  638. package/.next-prod/static/chunks/app/api/project-state/route-b56c0b18a3b4d026.js +0 -1
  639. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-b56c0b18a3b4d026.js +0 -1
  640. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-b56c0b18a3b4d026.js +0 -1
  641. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-b56c0b18a3b4d026.js +0 -1
  642. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-b56c0b18a3b4d026.js +0 -1
  643. package/.next-prod/static/chunks/app/api/projectGraph/context/route-b56c0b18a3b4d026.js +0 -1
  644. package/.next-prod/static/chunks/app/api/projectGraph/file/route-b56c0b18a3b4d026.js +0 -1
  645. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-b56c0b18a3b4d026.js +0 -1
  646. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-b56c0b18a3b4d026.js +0 -1
  647. package/.next-prod/static/chunks/app/api/projectGraph/related/route-b56c0b18a3b4d026.js +0 -1
  648. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-b56c0b18a3b4d026.js +0 -1
  649. package/.next-prod/static/chunks/app/api/projectGraph/search/route-b56c0b18a3b4d026.js +0 -1
  650. package/.next-prod/static/chunks/app/api/projects/route-b56c0b18a3b4d026.js +0 -1
  651. package/.next-prod/static/chunks/app/api/push/public-key/route-b56c0b18a3b4d026.js +0 -1
  652. package/.next-prod/static/chunks/app/api/push/subscribe/route-b56c0b18a3b4d026.js +0 -1
  653. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-b56c0b18a3b4d026.js +0 -1
  654. package/.next-prod/static/chunks/app/api/redis/command/route-b56c0b18a3b4d026.js +0 -1
  655. package/.next-prod/static/chunks/app/api/redis/connect/route-b56c0b18a3b4d026.js +0 -1
  656. package/.next-prod/static/chunks/app/api/redis/delete/route-b56c0b18a3b4d026.js +0 -1
  657. package/.next-prod/static/chunks/app/api/redis/disconnect/route-b56c0b18a3b4d026.js +0 -1
  658. package/.next-prod/static/chunks/app/api/redis/get/route-b56c0b18a3b4d026.js +0 -1
  659. package/.next-prod/static/chunks/app/api/redis/keys/route-b56c0b18a3b4d026.js +0 -1
  660. package/.next-prod/static/chunks/app/api/redis/set/route-b56c0b18a3b4d026.js +0 -1
  661. package/.next-prod/static/chunks/app/api/restart/route-b56c0b18a3b4d026.js +0 -1
  662. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-b56c0b18a3b4d026.js +0 -1
  663. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-b56c0b18a3b4d026.js +0 -1
  664. package/.next-prod/static/chunks/app/api/review/[id]/route-b56c0b18a3b4d026.js +0 -1
  665. package/.next-prod/static/chunks/app/api/review/identify/route-b56c0b18a3b4d026.js +0 -1
  666. package/.next-prod/static/chunks/app/api/review/order/route-b56c0b18a3b4d026.js +0 -1
  667. package/.next-prod/static/chunks/app/api/review/route-b56c0b18a3b4d026.js +0 -1
  668. package/.next-prod/static/chunks/app/api/review/share-info/route-b56c0b18a3b4d026.js +0 -1
  669. package/.next-prod/static/chunks/app/api/review/users/route-b56c0b18a3b4d026.js +0 -1
  670. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-b56c0b18a3b4d026.js +0 -1
  671. package/.next-prod/static/chunks/app/api/services/config/route-b56c0b18a3b4d026.js +0 -1
  672. package/.next-prod/static/chunks/app/api/services/scripts/route-b56c0b18a3b4d026.js +0 -1
  673. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-b56c0b18a3b4d026.js +0 -1
  674. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-b56c0b18a3b4d026.js +0 -1
  675. package/.next-prod/static/chunks/app/api/session/[sessionId]/turn/route-b56c0b18a3b4d026.js +0 -1
  676. package/.next-prod/static/chunks/app/api/session/user-messages/route-b56c0b18a3b4d026.js +0 -1
  677. package/.next-prod/static/chunks/app/api/session-by-path/route-b56c0b18a3b4d026.js +0 -1
  678. package/.next-prod/static/chunks/app/api/sessions/delegate/route-b56c0b18a3b4d026.js +0 -1
  679. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-b56c0b18a3b4d026.js +0 -1
  680. package/.next-prod/static/chunks/app/api/sessions/projects/route-b56c0b18a3b4d026.js +0 -1
  681. package/.next-prod/static/chunks/app/api/sessions/route-b56c0b18a3b4d026.js +0 -1
  682. package/.next-prod/static/chunks/app/api/sessions/search/route-b56c0b18a3b4d026.js +0 -1
  683. package/.next-prod/static/chunks/app/api/sessions/status/route-b56c0b18a3b4d026.js +0 -1
  684. package/.next-prod/static/chunks/app/api/settings/route-b56c0b18a3b4d026.js +0 -1
  685. package/.next-prod/static/chunks/app/api/shutdown/route-b56c0b18a3b4d026.js +0 -1
  686. package/.next-prod/static/chunks/app/api/skills/[id]/route-b56c0b18a3b4d026.js +0 -1
  687. package/.next-prod/static/chunks/app/api/skills/content/route-b56c0b18a3b4d026.js +0 -1
  688. package/.next-prod/static/chunks/app/api/skills/route-b56c0b18a3b4d026.js +0 -1
  689. package/.next-prod/static/chunks/app/api/snapshots/blob/route-b56c0b18a3b4d026.js +0 -1
  690. package/.next-prod/static/chunks/app/api/snapshots/diff/route-b56c0b18a3b4d026.js +0 -1
  691. package/.next-prod/static/chunks/app/api/snapshots/route-b56c0b18a3b4d026.js +0 -1
  692. package/.next-prod/static/chunks/app/api/terminal/aliases/route-b56c0b18a3b4d026.js +0 -1
  693. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-b56c0b18a3b4d026.js +0 -1
  694. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-b56c0b18a3b4d026.js +0 -1
  695. package/.next-prod/static/chunks/app/api/terminal/env/route-b56c0b18a3b4d026.js +0 -1
  696. package/.next-prod/static/chunks/app/api/terminal/history/route-b56c0b18a3b4d026.js +0 -1
  697. package/.next-prod/static/chunks/app/api/update/route-b56c0b18a3b4d026.js +0 -1
  698. package/.next-prod/static/chunks/app/api/update-state/route-b56c0b18a3b4d026.js +0 -1
  699. package/.next-prod/static/chunks/app/api/version/route-b56c0b18a3b4d026.js +0 -1
  700. package/.next-prod/static/chunks/app/apps/[...path]/route-b56c0b18a3b4d026.js +0 -1
  701. package/.next-prod/static/chunks/app/layout-5e8ca15dabb4d8c2.js +0 -1
  702. package/.next-prod/static/chunks/app/manifest.webmanifest/route-b56c0b18a3b4d026.js +0 -1
  703. package/.next-prod/static/chunks/app/page-eb7a11e6dd6a9e94.js +0 -1
  704. package/.next-prod/static/chunks/app/project/page-eb7a11e6dd6a9e94.js +0 -1
  705. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-b56c0b18a3b4d026.js +0 -1
  706. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-b56c0b18a3b4d026.js +0 -1
  707. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-b56c0b18a3b4d026.js +0 -1
  708. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-b56c0b18a3b4d026.js +0 -1
  709. package/.next-prod/static/css/08c892de6d5e2335.css +0 -1
  710. package/.next-prod/static/mTTTlFslhC7zzHMDXGNOW/_buildManifest.js +0 -1
  711. /package/.next-prod/static/{mTTTlFslhC7zzHMDXGNOW → O8neHUIr3dQhe1jcOUsQ8}/_ssgManifest.js +0 -0
@@ -1,762 +0,0 @@
1
- exports.id=5750,exports.ids=[5750],exports.modules={208:(a,b,c)=>{"use strict";c.d(b,{A:()=>g});var d=c(529);let e=JSON.parse('{"common":{"save":"Save","cancel":"Cancel","delete":"Delete","close":"Close","minimize":"Minimize","copy":"Copy","edit":"Edit","file":"File","codeMap":"Code Map","diff":"Diff","confirm":"Confirm","loading":"Loading...","search":"Search","refresh":"Refresh","retry":"Retry","submit":"Submit","copied":"Copied","saved":"Saved","failed":"Failed","noMatch":"No matches","noData":"No data","done":"Done","justNow":"just now","minutesAgo":"{{count}}m ago","hoursAgo":"{{count}}h ago","daysAgo":"{{count}}d ago","monthsAgo":"{{count}}mo ago","yearsAgo":"{{count}}y ago","saveFailed":"Save failed","copyFailed":"Copy failed","deleteFailed":"Delete failed","operationFailed":"Operation failed","copiedPath":"Path copied","copyPath":"Copy path","openInConsole":"Open in Console bubble","copyAbsPath":"Copy absolute path","loadMore":"Load more","noResult":"No results","selected":"Selected","selectAll":"Select all","hint":"Notice","confirmBtn":"OK","cancelBtn":"Cancel","preview":"Preview","readable":"Readable","previous":"Previous","next":"Next","all":"All","input":"Input","result":"Result","line":"Line","lines":"lines","running":"Running","connecting":"Connecting","connected":"Connected","connectionFailed":"Connection failed","builtin":"Built-in","global":"Global","project":"Project","current":"Current","code":"Code"},"htmlApps":{"title":"HTML Apps","addTooltip":"Add to HTML panel","added":"Added to HTML panel","alreadyAdded":"Already added","addFailed":"Failed to add","add":"Add","adding":"Adding...","addHtmlApp":"Add HTML app","searchPlaceholder":"Search HTML apps...","pathLabel":"Absolute path to the .html file","invalid":"Invalid","builtin":"Built-in","noDescription":"No description","emptyNoApps":"No custom HTML apps yet.","emptyCreatePrefix":"Use","emptyCreateSuffix":"in chat to create a new app.","addExisting":"add an existing HTML file","viewDocs":"view docs","emptyNoMatch":"No HTML apps match your search."},"skills":{"addTooltip":"Add to Skills panel","added":"Added to Skills panel","alreadyAdded":"Already added","addFailed":"Failed to add","title":"Skills","searchPlaceholder":"Search skills...","clearSearch":"Clear","addSkill":"Add Skill","emptyNoSkills":"No skills yet.","emptyIntroPrefix":"Use","emptyIntroSuffix":"in chat to distil a reusable workflow into a SKILL.md file.","emptyNoMatch":"No skills match your search.","viewDocs":"view docs","pathLabel":"Absolute path to SKILL.md","pathPlaceholder":"/Users/you/.../skills/foo/SKILL.md","add":"Add","adding":"Adding...","invalid":"Invalid","copyPath":"Copy path","noDescription":"No description","previewTitle":"Skill Preview","source":"Source","cannotRead":"File cannot be read."},"toast":{"savedSuccess":"Saved","saveFailed":"Save failed","copiedName":"Copied: {{name}}","copyFailed":"Copy failed","deleteFailed":"Delete failed","operationFailed":"Operation failed","staged":"Staged","stageFailed":"Stage failed","unstaged":"Unstaged","unstageFailed":"Unstage failed","stagedNFiles":"Staged {{count}} files","unstagedNFiles":"Unstaged {{count}} files","discardFailed":"Discard failed","discardedNFiles":"Discarded changes in {{count}} files","deletedFile":"File deleted","discardedChanges":"Changes discarded","pastedFile":"Pasted: {{name}}","pasteFailed":"Paste failed","noFileToPaste":"No file to paste","createdFile":"Created: {{name}}","createFailed":"Create failed","movedToTrash":"Moved to trash: {{name}}","copiedPageUrl":"Page URL copied","copiedDirPath":"Directory path copied","switchedToBranch":"Switched to {{branch}}","switchBranchFailed":"Branch switch failed","loadBranchFailed":"Failed to load branches","copiedCommand":"Copied: {{command}}","copiedMessage":"Message copied","sentToPeer":"Sent to the other pane","sendToPeerFailed":"Failed to send to the other pane","forkFailed":"Failed to fork session","excerptFailed":"Failed to excerpt this turn","turnDeleted":"Turn deleted","deleteTurnFailed":"Failed to delete this turn","copiedUrl":"URL copied","copiedOutput":"Output copied","copiedCmd":"Command copied","copiedComment":"Comment copied","copiedAllComments":"All comments copied","copiedFileContent":"File content copied","copiedQA":"Copied {{count}} Q&A","copiedAllQA":"All Q&A copied","sentQA":"Sent to AI","readFileFailed":"Failed to read file","fileOutsideProject":"File is outside this project — only Markdown, CSV and images can be previewed","reviewCreated":"Review created, link copied","reviewUpdated":"Review updated, link copied","reviewCreateFailed":"Failed to create review","sharingClosed":"Sharing disabled","sharingCloseFailed":"Failed to disable sharing","linkCopied":"Link copied","addCommentFailed":"Failed to add comment","deleteCommentFailed":"Failed to delete comment","editCommentFailed":"Failed to edit comment","addReplyFailed":"Failed to add reply","deleteReplyFailed":"Failed to delete reply","editReplyFailed":"Failed to edit reply","disconnected":"Disconnected: {{id}}","pluginReloading":"Reloading extension...","worktreeCreateSuccess":"Worktree created: {{name}}","worktreeCreateFailed":"Failed to create worktree","worktreeLoadFailed":"Failed to load worktree list","worktreeDeleted":"Worktree deleted","worktreeDeleteFailed":"Failed to delete worktree","worktreeLocked":"Locked","worktreeUnlocked":"Unlocked"},"workspace":{"selectProject":"Select a project to start","searchProjectPath":"Search project path...","loadingProjects":"Loading projects...","projectNotFound":"No projects found","sessions":"{{count}} sessions","loadingSessions":"Loading sessions...","noSessions":"No sessions","loadingText":"Loading...","openProject":"Open Project","expandSidebar":"Expand sidebar","collapseSidebar":"Collapse sidebar","notes":"Notes","skills":"Skills","apps":"Apps","settings":"Settings","help":"Help","updateAvailable":"v{{version}} available","copyUpgradeCommand":"Copy cockpit update","updateNow":"Update now","updating":"Updating…","updateComplete":"Update complete","updateFailed":"Update failed","updateCardPreparing":"Preparing update…","updateCardInstalling":"Downloading and installing","updateCardRepairing":"Repairing native dependency","updateCardUpToDate":"Already on the latest version, v{{version}}","updateCardCopyFix":"Copy fix command","updateCardFixCopied":"Fix command copied","updateCardRollingBack":"Install failed, rolling back","updateCardRestarting":"Restarting Cockpit…","updateCardDone":"Updated to v{{version}}","updateCardElapsed":"{{seconds}}s elapsed","updateCardBaseline":"last time ~{{seconds}}s","updateCardNoLiveStatus":"Live status unavailable; the update is still running","updateCardRolledBack":"Rolled back to the previous version; Cockpit is usable.","updateCardManualHint":"You can retry from a terminal:","updateCardLogHint":"Log: {{path}}","updateRestartNote":"Cockpit will restart in the background.","viewChangelog":"View changelog","serverRestarted":"Cockpit was updated in the background.","reloadNow":"Reload","upgradeCommandCopied":"Copied `cockpit update`","projectNotes":"Project Notes","closeProject":"Close project"},"mobile":{"useDesktop":"Desktop","messagePlaceholder":"Message…","send":"Send","stop":"Stop","enableNotifications":"Enable notifications","disableNotifications":"Disable notifications","notifyError":"Could not enable notifications"},"sessions":{"recentSessions":"Recent Sessions","favorites":"Favorite Sessions","noFavorites":"No favorite sessions yet. Click the star in the tab bar to add.","addFavorite":"Add to favorites","removeFavorite":"Remove from favorites","runningCount":"{{count}} running","unreadCount":"{{count}} unread","noSessions":"No sessions yet","running":"Running","done":"Done","editTitle":"Edit title","projectSessions":"Project Sessions","browseAllSessions":"Browse all sessions","sessionList":"Session List","search":"Search","searchSessions":"Search sessions...","searchRecentSessions":"Search recent sessions","loadSessionsFailed":"Failed to load sessions","loadingSessions":"Loading sessions...","noMatchingSessions":"No matching sessions","noSessionsYet":"No sessions yet","projectList":"Project List","openFolder":"Open Folder","selectingFolder":"Selecting...","loadingHistory":"Loading history..."},"scheduledTasks":{"title":"Scheduled Tasks","aboutToTrigger":"About to trigger","secondsLater":"in {{count}}s","minutesLater":"in {{count}}m","hoursMinutesLater":"in {{h}}h {{m}}m","hoursLater":"in {{h}}h","onceType":"Once ({{minutes}}min)","everyNMinutes":"Every {{minutes}}min","completed":"Completed","paused":"Paused","activeCount":"{{running}} active","pausedCount":"{{paused}} paused","noScheduledTasks":"No scheduled tasks. Click the clock button in the chat input to create one.","lastResult":"Last","runNow":"Run now","deleteFailed":"Failed to delete the task","resume":"Resume","pause":"Pause","completedCount":"Completed ({{count}})","groupPendingReview":"Finished \xb7 to review","groupUpcoming":"Running \xb7 upcoming","openSession":"Open session","selectTaskHint":"Select a task on the left to preview its session messages","noTaskMessages":"No messages in this task\'s session yet","success":"Success","failure":"Failed","createTask":"Create Scheduled Task","editTask":"Edit Scheduled Task","sendMessage":"Message","messagePlaceholder":"Enter message to send...","taskFile":"Task File","taskFilePlaceholder":"/Users/you/project/tasks/daily-report.md","taskFileHint":"Absolute path. On each fire the agent reads this file first and acts on what it describes — edits take effect on the next run.","taskFilePromptHeader":"Read this task file first, then act accordingly:","type":"Type","once":"Once","interval":"Interval","quickSelect":"Quick Select","customCron":"Custom Cron Expression","customMinutes":"Custom minutes","cronPlaceholder":"e.g. 0 9 * * 1-5 (weekdays at 9am)","cronFormat":"Format: min hour day month weekday (e.g. 0 9 * * 1-5)","minutesPlaceholder":"Minutes","limitTimeRange":"Limit execution time range","to":"to","saveBtn":"Save ({{modKey}}↩)","createBtn":"Create ({{modKey}}↩)","5minLater":"In 5 minutes","15minLater":"In 15 minutes","30minLater":"In 30 minutes","1hourLater":"In 1 hour","every15min":"Every 15 min","every30min":"Every 30 min","every1hour":"Every 1 hour","every2hours":"Every 2 hours","daily9am":"Daily 09:00","daily6pm":"Daily 18:00","weeklyMon9am":"Mon 09:00","monthly1st9am":"1st of month 09:00"},"cron":{"everyNMinutes":"Every {{n}} minutes","everyNHours":"Every {{n}} hours","everyMinute":"Every minute","everyHourAtMin":"Every hour at minute {{m}}","hourlyEveryMin":"{{h}}:xx every minute","daily":"Daily at {{time}}","weekdays":"Weekdays","weekends":"Weekends","dowSun":"Sun","dowMon":"Mon","dowTue":"Tue","dowWed":"Wed","dowThu":"Thu","dowFri":"Fri","dowSat":"Sat","monthPrefix":"","dayOfMonth":"","dayRange":"{{a}}th to {{b}}th","weekdayPrefix":"","weekdayRange":"{{a}} to {{b}}"},"blockViewer":{"empty":{"body":"Select a file in the left tree to see its code map.","hint":"or press ⌘K to search."},"fileMode":{"loading":"Loading…","notFound":"This file is not indexed (unsupported language or beyond the file cap)."},"buildProgress":{"listing":"Listing files…","contexts":"Reading project config…","parsing":"Parsing files","resolving":"Resolving imports…","edges":"Building call graph…","done":"Finishing up…"},"search":{"tooltip":"Search (⌘K)","hint":"Start typing to search","noResults":"No matches","files":"Files","symbols":"Symbols"},"viewerToggle":{"toBlock":"Show code map","toCode":"Back to code view"},"tabs":{"toc":"Functions","history":"Trail"},"toc":{"title":"this file","empty":"No functions detected.","notIndexed":"File not in project graph (unsupported language / not in git tracked set / file cap reached)."},"history":{"title":"recent","empty":"Click an input or output pin to begin tracing.","clear":"Clear history"},"refresh":"Rebuild project graph","retry":"Retry"},"blockDiffViewer":{"loading":"Building code map…","unsupported":"Code map diff is not available for this file type.","unsupportedHint":"Switch back to the regular diff view to read it.","error":"Code map diff failed: {{message}}","noBlockChanges":"No code-map changes (formatting / whitespace only).","noBefore":"(new)","noAfter":"(removed)","kind":{"added":"added","deleted":"deleted","modified":"modified"}},"fileBrowser":{"directoryTree":"Tree","searchTab":"Search","recentTab":"Recent","changesTab":"Status","historyTab":"History","searchFiles":"Search files...","clear":"Clear","exactMatchOn":"Exact match (on)","exactMatchOff":"Exact match (off)","refreshTree":"Refresh directory tree","collapseAll":"Collapse all directories","searchFileContent":"Search file contents...","caseSensitive":"Case sensitive","wholeWord":"Whole word","regex":"Regex","fileTypes":"File types (ts,tsx)","compareMode":"Compare","compareModeOff":"Close branch comparison","compareModeOn":"Compare with selected branch","createFile":"New File","createFileIn":"New File (in {{path}}/)","fileName":"File name...","noRecentFiles":"No recent files","stagingArea":"Staged ({{count}})","changesSummary_one":"{{count}} change","changesSummary_other":"{{count}} changes","noChanges":"No changes in working tree","refreshChanges":"Refresh changes","unstageAll":"Unstage all","noStagedFiles":"No staged files","unstageNFiles":"Unstage {{count}} files","unstageFile":"Unstage","workspace":"Workspace ({{count}})","discardAll":"Discard all","stageAll":"Stage all","noUnstagedChanges":"No unstaged changes","discardNFiles":"Discard changes in {{count}} files","stageNFiles":"Stage {{count}} files","discardChanges":"Discard changes","stageFile":"Stage file","loadingDiff":"Loading diff...","noDiffFiles":"No diff files","nFilesChanged":"{{count}} files changed (vs {{branch}})","loadingCommits":"Loading commits...","noCommits":"No commits","allLoaded":"All {{count}} records loaded","locateInTree":"Locate in directory tree","unsaved":"Unsaved","saveBeforeSwitch":"Current file has unsaved changes. Save before switching?","saveAndSwitch":"Save and switch","closeEdit":"Close edit (ESC)","closeBtn":"Close","copyFileContent":"Copy file content","toggleJsonReadable":"Toggle JSON readable mode","previewMarkdown":"Preview Markdown","exitPreview":"Exit Preview","collapseAllJson":"Fold","expandAllJson":"Full","viewBlame":"View line-by-line change history","viewDiff":"View changes against HEAD","exitDiff":"Exit Diff","diffLoadFailed":"Failed to load diff","editFile":"Edit file","backToPreview":"Back to preview","cannotPreview":"Cannot preview this file","selectFileToPreview":"Select a file to preview","staged":"Staged","unstaged":"Unstaged","selectFileToViewDiff":"Select a file to view diff","loadingDiffContent":"Loading diff...","clickCompareToLoad":"Click \\"Compare\\" to load branch diff","selectCommitToView":"Select a commit to view details","confirmDelete":"Confirm Delete","confirmDeleteMessage":"Move <file>{{name}}</file> to trash?","nFilesNMatches":"{{files}} files, {{matches}} matches","resultsTruncated":"Results truncated","noContentSearchResults":"No results","enterKeywordToSearch":"Enter keyword to search file contents","searchMinChars":"Search requires at least 2 characters"},"csv":{"table":"Table","raw":"Raw","empty":"Empty table","summary":"{{rows}} rows \xb7 {{cols}} columns","summaryFiltered":"{{rows}} / {{total}} rows matched \xb7 {{cols}} columns","loadMore":"Load more ({{shown}} / {{total}} shown)","filterPlaceholder":"Filter rows…","filterColumn":"Filter column","clearFilter":"Clear filter","allColumns":"All columns","noMatch":"No matching rows","sortHint":"Click to sort (asc / desc / off)"},"codeViewer":{"fileModifiedExternally":"File was modified externally. Saving will overwrite external changes.","useDiskVersion":"Use disk version","forceOverwrite":"Force overwrite","searchPlaceholder":"Search...","caseSensitive":"Case sensitive","wholeWordMatch":"Whole word match","unsavedConfirm":"You have unsaved changes. Close anyway?","discardChanges":"Discard changes","continueEditing":"Continue editing","unsavedExitConfirm":"You have unsaved changes. Exit edit mode?","clickToViewDetails":"Click to view details","clickToViewCommit":"Click to view commit details","nComments":"{{count}} comments","searchChat":"Search chat...","prevShiftEnter":"Previous (Shift+Enter)","nextEnter":"Next (Enter)","closeEsc":"Close (Esc)"},"chat":{"startConversation":"Start a conversation","loadMoreHistory":"Load more...","scrollUpForMore":"↑ Scroll up to load more history","jumpToStart":"Jump to start","jumpToLatest":"Jump to latest","jumpToPrevUserMessage":"Previous user message","jumpToNextUserMessage":"Next user message","recentUserMessages":"Recent user messages","moreUserMessages":"More","userMessage":"User message","recentUserMessageNumber":"Recent user message {{index}} of {{total}}","imageMessage":"Image message","copyMessage":"Copy message","copyImage":"Copy image","copiedImage":"Image copied","forkSession":"Fork session from here","excerptTurn":"Excerpt this turn to a new session","newSession":"New session","continueFromHere":"Continue from here","continueFromHereDesc":"Keep all context through this turn","onlyThisTurn":"Only this turn","onlyThisTurnDesc":"Keep only this question and answer","deleteTurn":"Delete turn","deletingTurn":"Deleting…","deleteTurnConfirm":"Delete this question, answer, and its tool records? This cannot be undone.","deleteTurnConfirmAction":"Delete turn","deleteTurnWhileRunning":"A turn cannot be deleted while the session is running","sendToPeerPane":"Send this message to the other pane","imageN":"Image {{index}}","imagePreview":"Image preview","toolCalls":"{{count}} tool calls","collapse":"▲ Collapse","expand":"▼ Expand","showMore":"Show more","showLess":"Show less","subagent":"Subagent","subagentEmpty":"No subagent transcript found","subagentViewTitle":"View subagent transcript","workflowRun":"Run details","workflowViewTitle":"View workflow run details","workflowEmpty":"No workflow run journal found","workflowAgents":"agents","workflowViewAgent":"View","workflowUngrouped":"Ungrouped","viewQuestions":"View questions","viewAllFileChanges":"View all file changes","requestFailed":"Request failed","cannotReadStream":"Cannot read response stream","errorRetry":"An error occurred, please retry","codexResumeFailed":"Previous session is in use by another Codex client — started a new session; history was not carried over","codexResumeFailedPrevious":"Previous session","codexResumeFailedNew":"New session","placeholder":"Type a message, Enter to send (Shift+Enter for new line, paste images; start a line with / (main session) or @ (subagent) for commands, multiple allowed)","placeholderDisabled":"Generating... you can keep typing (ESC to cancel; if stuck, cancel and resend \'continue\')","imageSizeLimit":"Image size exceeds limit (max 5MB), current: {{size}}MB","viewGitChanges":"View Git changes","viewAllComments":"View all comments","userMessages":"User messages","projectNotes":"Project Notes","scheduledTasks":"Scheduled Tasks","quickInstructions":"Quick Instructions","globalInstructions":"Global Instructions","projectInstructions":"Project Instructions","noQuickInstructions":"No quick instructions yet","addQuickInstruction":"Add quick instruction","quickInstructionPlaceholder":"One-line instruction — Enter to save, Esc to cancel","insertQuickInstruction":"Insert into input (without sending)","addInstructionGroup":"New group","instructionGroupNamePlaceholder":"Group name — Enter to save, Esc to cancel","instructionGroupLabel":"Group","instructionGroupNone":"No group","deleteInstructionGroupConfirm":"Deleting \\"{{name}}\\" also deletes the {{count}} instruction(s) inside it. Continue?","editGlobalInstructions":"Edit global instructions","editProjectInstructions":"Edit project instructions","quickInstructionsMarkdownHint":"One top-level entry per line. Add lines beginning with “- ” after a group name for its instructions.","quickInstructionsMarkdownPlaceholder":"Continue\\nDraw with text\\n- Draw a login flow\\n- Draw a system architecture","quickInstructionsMarkdownError":"Invalid format on line {{line}}.","savingQuickInstructions":"Saving...","saveQuickInstructionsFailed":"Could not save. Your edits are still here; please try again.","context":"Context","output":"Output","copiedCommandTooltip":"Copied!","copyCommandTooltip":"Copy command: {{command}}","executedCommand":"Executed `{{command}}`{{exitInfo}}, output:\\n```\\n{{output}}\\n```","executedCommandFailed":"Failed to execute `{{command}}`: {{error}}","executionMode":"Execution Mode","checkBalance":"Check balance","balanceFailed":"Query failed — check the API key","balanceNeedsKey":"Set a DeepSeek API key first","balanceUnavailable":"Account is not available for requests","balanceEmpty":"No balance returned","openUsagePage":"Open DeepSeek usage console","checkQuota":"Check quota","quotaFailed":"Quota unavailable — check the API key","quotaNeedsKey":"Set an API key first","quotaEmpty":"No quota returned","quotaResetAt":"Resets {{time}}","openProviderConsole":"Open the provider console","planMode":"Plan mode","planModeDesc":"read-only, plans first without edits","planModeOn":"Plan mode on — read-only; send a task to get a plan","planModeOff":"Plan mode off","planModeHint":"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement.","noHistory":"No history context","noHistoryDesc":"each prompt is independent","noHistoryHint":"No history context: each message is sent to the model on its own, with no prior conversation. The transcript above still records everything.","planTitle":"Plan (awaiting your review)","approvePlan":"Approve & run","planApproveHint":"No approval dialog here — click to exit plan mode and execute","approvePlanPrompt":"Approved — proceed with the plan above.","maximizePane":"Maximize this pane","restorePane":"Restore both panes","closePane":"Close this pane","singlePane":"Single pane","splitPane":"Split into two panes"},"console":{"enterCommandOrUrl":"Enter a command or URL to start","emptyIntro":"Type any of the following in the input bar to create a bubble:","bubbleCommand":"Command","bubbleInteractive":"Interactive","bubbleBrowser":"Browser","bubbleBrowserNoteIframe":"Some sites block iframe embedding — install Cockpit Bridge under Settings → Browser Extension before opening.","bubbleBrowserNoteCookie":"If a logged-in site first shows as signed out, refresh a few times to restore it.","bubbleDatabase":"Database","bubbleFilePreview":"File preview","loadingMore":"Loading...","loadMoreHistory":"Load more history","quickCommands":"Quick Commands","singleColumn":"Single column","dualColumn":"Dual column","envVars":"Environment Variables","launchShell":"Launch interactive shell","htmlApps":"HTML apps","inputPlaceholder":"Enter command or URL and press Enter... (↑↓ history, Tab complete)","scopeProject":"Project","scopeGlobal":"Global","tabSwitchEscClose":"Tab to switch \xb7 Esc to close","copyOutput":"Copy output","copyCommand":"Copy command","rerun":"Re-run","deleteRecord":"Delete record","searchPlaceholder":"Search...","searchMode":"Search","filterMode":"Filter","prevShiftEnter":"Previous (Shift+Enter)","nextEnter":"Next (Enter)","loadingTerminal":"Loading terminal...","clickToInput":"Click terminal area to type","stdinPlaceholder":"stdin input...","runningText":"Running...","exitCode":"Exit code: {{code}}","totalLines":"{{count}} lines total","globalCommands":"Global Commands","projectCommands":"Project Commands","noCustomCommands":"No custom commands yet","namePlaceholder":"Name","commandPlaceholder":"Command","restoreTooltip":"Restore ({{modKey}}M / ESC)","screenshotting":"Screenshotting...","outputFileDeleted":"[Output file deleted]"},"browser":{"blankPage":"Blank page","copyUrl":"Copy URL","openInNewWindow":"Open in new window","exitMaximize":"Exit maximize ({{modKey}}M)","maximize":"Maximize ({{modKey}}M)","pageLoadFailed":"Page load failed","clickToWake":"Click to wake","sleeping":"Sleeping","loadingPage":"Loading...","loadFailed":"Load failed"},"database":{"connectionFailed":"Connection failed","connected":"Connected","connecting":"Connecting...","refreshTableList":"Refresh table list","filterTable":"T Tables","filterView":"V Views","noTables":"No tables","tabStructure":"Structure","tabData":"Data","tabSql":"SQL","filterActive":"Filter: {{count}} cols","clearAllFilters":"Clear all filters","deleteNRows":"Delete {{count}} rows","confirmDeleteRows":"Confirm delete?","copyCsvSelected":"Copy selected rows as CSV","copyCsvAll":"Export all as CSV","copyJsonSelected":"Copy selected rows as JSON","copyJsonAll":"Export all as JSON","copyCSV":"Copy CSV","CSV":"CSV","copyJSON":"Copy JSON","JSON":"JSON","selectTable":"Select a table","selectTableToView":"Select a table to view structure","selectTableForData":"Select a table to view data","columns":"Columns","colName":"Name","colType":"Type","colNullable":"Nullable","colDefault":"Default","primaryKey":"Primary Key","foreignKeys":"Foreign Keys","indexes":"Indexes","enable":"Enable","commaValues":"Comma-separated values","likePattern":"%pattern%","valuePlaceholder":"Value","apply":"Apply","clearFilter":"Clear","addRow":"+ Add Row","totalRows":"{{count}} rows","rowsAffected":"{{command}} — {{count}} rows affected ({{duration}}ms)","queryRows":"{{count}} rows ({{duration}}ms)","resultTruncated":"[Results truncated to 1000 rows]","sqlPlaceholder":"Enter SQL... ({{modKey}}Enter to execute)","executing":"Executing...","execute":"▶ Execute","deleteRowsFailed":"{{count}} rows failed to delete","inputParams":"Input Parameters","resultLabel":"Result"},"mysql":{"connectionFailed":"Connection failed","connected":"Connected","connecting":"Connecting...","refreshTableList":"Refresh table list","filterTable":"T Tables","filterView":"V Views","noTables":"No tables","tabStructure":"Structure","tabData":"Data","tabSql":"SQL","filterActive":"Filter: {{count}} cols","clearAllFilters":"Clear all filters","deleteNRows":"Delete {{count}} rows","confirmDeleteRows":"Confirm delete?","copyCsvSelected":"Copy selected rows as CSV","copyCsvAll":"Export all as CSV","copyJsonSelected":"Copy selected rows as JSON","copyJsonAll":"Export all as JSON","copyCSV":"Copy CSV","CSV":"CSV","copyJSON":"Copy JSON","JSON":"JSON","selectTable":"Select a table","selectTableToView":"Select a table to view structure","selectTableForData":"Select a table to view data","columns":"Columns","colName":"Name","colType":"Type","colNullable":"Nullable","colDefault":"Default","primaryKey":"Primary Key","foreignKeys":"Foreign Keys","indexes":"Indexes","enable":"Enable","commaValues":"Comma-separated values","likePattern":"%pattern%","valuePlaceholder":"Value","apply":"Apply","clearFilter":"Clear","addRow":"+ Add Row","totalRows":"{{count}} rows","rowsAffected":"{{command}} — {{count}} rows affected ({{duration}}ms)","queryRows":"{{count}} rows ({{duration}}ms)","resultTruncated":"[Results truncated to 1000 rows]","sqlPlaceholder":"Enter SQL... ({{modKey}}Enter to execute)","executing":"Executing...","execute":"▶ Execute","deleteRowsFailed":"{{count}} rows failed to delete"},"redis":{"neverExpires":"Never expires","expired":"Expired","loadFailed":"Load failed","deleteFailed":"Delete failed","saveFailed":"Save failed","scanPlaceholder":"SCAN pattern...","scanSearch":"Search (SCAN)","noKeys":"No keys","loadMore":"Load more...","tabData":"Data","tabInfo":"Info","tabCli":"CLI","selectKey":"Select a key","keyNotExist":"Key does not exist","unsupportedType":"Unsupported type: {{type}}","nItems":"{{total}} items","showingN":"showing {{count}}","nMembers":"{{total}} members","nEntries":"{{total}} entries","cliHint":"Enter Redis commands, e.g. PING, GET key, KEYS *","cliPlaceholder":"Enter command..."},"git":{"switchBranch":"Switch branch","searchBranch":"Search branches...","noBranches":"No branches available","noMatchingBranches":"No matching branches","localBranches":"Local Branches","remoteBranches":"Remote Branches","branchNotFound":"Branch not found","selectBranch":"Select branch...","currentBranch":"Current","notGitRepo":"Current directory is not a Git repository","cannotGetBranches":"Cannot get branch info","getBranchesFailed":"Failed to get branch info","discardAllConfirm":"Discard changes in {{count}} workspace files? This cannot be undone.","worktree":{"title":"Git Worktree","count":"{{count}} worktrees","selectBranch":"Select branch","addWorktree":"+ Add Worktree","confirmDelete":"Confirm Delete","confirmDeleteMsg":"Delete this worktree?","path":"Path:","branch":"Branch:","locked":"Locked","unlock":"Unlock","lock":"Lock","searchBranch":"Search branches...","noBranches":"No available branches"}},"comments":{"addComment":"Add Comment","lineRange":"Line {{start}}-{{end}}","inputPlaceholder":"Enter comment...","newComment":"New comment {{range}}","commentPlaceholder":"Enter comment... ({{modKey}}Enter to submit, Esc to cancel)","nComments":"{{count}} comments","allComments":"All Comments","copyAllComments":"Copy all comments","noComments":"No comments yet","clearAll":"Clear all","totalComments":"{{count}} comments total","aiReply":"AI Reply","noContent":"(no content)","linesCount":"({{count}} lines)","codeRef":"Here are my annotated comments and references:","note":"Note: {{content}}","submitting":"Submitting...","enterSubmit":"Enter to submit \xb7 Shift+Enter for new line","submitComment":"Submit Comment","askAI":"Ask AI","inputQuestion":"Enter your question...","aiGenerating":"Generating, please wait...","enterSend":"Enter to send \xb7 Shift+Enter for new line","sendToAI":"Send to AI","aiResponding":"AI is responding..."},"fileContextMenu":{"createFile":"New File","copyFile":"Copy File","copyFolder":"Copy Folder","pasteHere":"Paste Here","deleteFile":"Delete File","deleteFolder":"Delete Folder","copyRelativePath":"Copy Relative Path","copyAbsolutePath":"Copy Absolute Path","copyRelativeDirPath":"Copy Relative Dir Path","copyAbsoluteDirPath":"Copy Absolute Dir Path","copyFileName":"Copy File Name","copyFolderName":"Copy Folder Name"},"settings":{"title":"Settings","theme":"Theme","themeLight":"Light","themeDark":"Dark","themeSystem":"System","browserExtension":"Browser Extension","extensionInstalled":"Cockpit Bridge installed","extensionNotInstalled":"Cockpit Bridge not installed","extensionDescription":"After installing the Chrome extension, link navigation in iframes will be intercepted: new tab links create new bubbles, page navigation updates the current bubble.","installSteps":"Installation steps:","step1":"1. Open Chrome and navigate to","step2":"2. Enable \\"Developer mode\\" in the top-right corner","step3":"3. Click \\"Load unpacked\\"","step4mac":"4. Press <kbd>Cmd+Shift+G</kbd> → paste the path below → Enter","copyExtensionPath":"Copy extension directory path","reloadExtension":"Reload extension","about":"About","language":"Language","languageAuto":"System","switchDark":"Switch to dark","switchLight":"Switch to light","agentsBundled":"bundled"},"editor":{"placeholder":"Write something... Type / for commands","noteTitle":"{{name}} - Notes","noteUntitled":"Notes","saving":"Saving...","conflictReloaded":"This note was changed elsewhere. Loaded the latest version; your recent unsaved edits were discarded.","linkPlaceholder":"Enter URL...","confirmLink":"Confirm","removeLink":"Remove link","heading1":"Heading 1","heading2":"Heading 2","heading3":"Heading 3","bold":"Bold","italic":"Italic","strikethrough":"Strikethrough","inlineCode":"Inline code","link":"Link","bulletList":"Bullet list","orderedList":"Ordered list","taskList":"Task list","blockquote":"Blockquote","codeBlock":"Code block","table":"Table","horizontalRule":"Horizontal rule","insertRowAbove":"Insert row above","insertRowBelow":"Insert row below","insertColumnLeft":"Insert column left","insertColumnRight":"Insert column right","deleteRow":"Delete row","deleteColumn":"Delete column","deleteTable":"Delete table","deleteCodeBlock":"Delete code block","toc":"TOC","expandToc":"Expand TOC","collapseToc":"Collapse TOC"},"slashCommands":{"heading1":"Heading 1","heading1Desc":"Large heading","heading2":"Heading 2","heading2Desc":"Medium heading","heading3":"Heading 3","heading3Desc":"Small heading","bulletList":"Bullet List","bulletListDesc":"Bulleted list","orderedList":"Ordered List","orderedListDesc":"Numbered list","taskList":"Task List","taskListDesc":"Checkable task list","blockquote":"Blockquote","blockquoteDesc":"Quote block","codeBlock":"Code Block","codeBlockDesc":"Code snippet","table":"Table","tableDesc":"Insert 3\xd73 table","horizontalRule":"Divider","horizontalRuleDesc":"Horizontal divider","link":"Link","linkDesc":"Insert hyperlink"},"commands":{"plan":"Enable plan mode \xb7 /plan <task> to plan it \xb7 /plan off to disable"},"review":{"reviewManagement":"Review Management","allReviews":"All Reviews","noOpenReviews":"No open reviews","viewComments":"View comments","nComments":"{{count}} comments","nDocs":"{{count}} docs","nReviews":"{{count}} reviews","docList":"Document List","allReviewsList":"All Reviews","expandList":"Expand list","collapseList":"Collapse list","closeReview":"Close review","reopenReview":"Reopen","deleteReview":"Delete review","noOpenDocs":"No open documents","noReviews":"No reviews","sharing":"Sharing","notShared":"Not shared","closeSharing":"Disable sharing","enableSharing":"Enable sharing","view":"View","setNickname":"Set your nickname","nicknameHint":"Other reviewers will see this name","nicknamePlaceholder":"Enter nickname","skipForNow":"Skip for now","identitySettings":"Identity Settings","reviewNickname":"Review Nickname","random":"Random","selectTextToComment":"Select text to add comment","selectTextHint":"Select text on the left to add a comment","prevComment":"Previous","nextComment":"Next","commentsCount":"{{count}} comments","commentsNavCount":"{{current}}/{{total}} comments","allCommentsTitle":"All Comments","commentsCountBrief":"{{count}}","closedCount":"{{count}} closed","copyAllComments":"Copy all comments","noComments":"No comments yet","closedComments":"Closed ({{count}})","closedLabel":"Closed","moreReplies":"+{{count}} replies","copyComment":"Copy comment","reopen":"Reopen","closeComment":"Close comment","editComment":"Edit comment","deleteComment":"Delete comment","edited":"(edited)","editReply":"Edit reply","deleteReply":"Delete reply","reply":"Reply","replyPlaceholder":"Add a reply...","selectedText":"Selected text","addCommentPlaceholder":"Add a comment...","enterSubmitHint":"Enter to submit, Shift+Enter for new line","commentBtn":"Comment","reviewNotExist":"Review does not exist or has been deleted","loadFailed":"Load failed","networkError":"Network error","reviewNotFound":"Review not found","checkLink":"Please check the link","updatedAt":"Updated {{date}}","active":"Active","closed":"Closed","viewAllComments":"View all comments","viewCommentBtn":"View Comments","copyLink":"Copy Link","reviewSummary":"Review Comments Summary — {{title}}","totalNComments":"{{count}} comments total","quoteRef":"Quote: \\"{{text}}\\"","commentAuthor":"Comment ({{author}}): {{content}}","replyAuthor":" ↳ {{author}}: {{content}}"},"markdown":{"copied":"✓ Copied","copy":"Copy"},"imagePreview":{"previewImage":"Preview image","deleteImage":"Delete image","copyImage":"Copy image","copiedImage":"Image copied"},"tokenStats":{"title":"Claude Code Token Stats","activeHours":"Active Hours Distribution","hourSessions":"{{h}}:00 — {{count}} sessions","messages":"Messages","toolCalls":"Tool Calls","activityTrend":"Activity Trend","byModel":"By Model","tokenUsage":"Token Usage","equivalentCost":"Equivalent Cost","modelCostDetail":"Model Cost Details","model":"Model","share":"Share","total":"Total","totalSessions":"Total Sessions","totalMessages":"Total Messages","equivalentApiCost":"Equivalent API Cost","longestSession":"Longest Session","firstUse":"First Use","notFound":"~/.claude/stats-cache.json not found","day":"Day","week":"Week","month":"Month"},"toolCall":{"inputParams":"Input Parameters","resultLabel":"Result","inputParamsTitle":"View input parameters","resultTitle":"View result","input":"Input","result":"Result","foldedLines":"... ({{count}} lines)"},"fileEditor":{"unsavedConfirm":"You have unsaved changes. Close anyway?","discardChanges":"Discard changes","continueEditing":"Continue editing","externallyModified":"File was modified externally. Saving will overwrite external changes.","useDiskVersion":"Use disk version","forceOverwrite":"Force overwrite"},"quickFileOpen":{"placeholder":"Type file name to open...","noMatch":"No matching files","recent":"Recent","selectHint":"Select","openHint":"Open","closeHint":"Close"},"envManager":{"title":"Environment Variables","tabScope":"Current Tab Only","globalScope":"Global Environment Variables","varNamePlaceholder":"Variable name (e.g. NODE_ENV)","varValuePlaceholder":"Value (e.g. production)","valuePlaceholder":"Value","noVars":"No environment variables yet. Add one to get started."},"aliasManager":{"title":"Command Aliases","description":"Set shortcut aliases for common commands (global)","aliasPlaceholder":"Alias (e.g. ll)","commandPlaceholder":"Full command (e.g. ls -la)","fullCommandPlaceholder":"Full command","usage":"Usage tip:","usageDesc":"Type an alias to execute the corresponding full command","noAliases":"No command aliases yet. Add one to get started."},"diffViewer":{"fileChanges":"File Changes ({{count}})","expandFull":"Expand to full width","exitFull":"Back to column","toggleFileTree":"Toggle file tree","selectFileToView":"Select a file to view changes","sideBySide":"Side by side","unified":"Unified","viewSplit":"Split","viewUnified":"Unified","previewFile":"Preview file","copiedAll":"Full text copied","compact":"Compact","full":"Full","gap":{"hidden":"{{count}} lines hidden","more":"\xb7\xb7\xb7 more +{{count}} \xb7\xb7\xb7","expandUp":"Expand {{count}} lines up","expandDown":"Expand {{count}} lines down","expandAll":"Click to expand {{count}} lines"},"loadingSnapshots":"Loading snapshots…","noChanges":"No file changes detected in this turn","notViewable":"Binary or oversized file — diff not viewable","externalChange":"Concurrent change from another session/process","reconstructed":"reconstructed","reconstructedHint":"Rebuilt from tool-call parameters — not a disk snapshot","truncated":"Too many files — list truncated","imageBefore":"Before","imageAfter":"After","imageAdded":"Added","imageDeleted":"Deleted","imageLoadFailed":"Failed to load image","imageUnavailable":"Image not present in either revision"},"commitDetail":{"title":"Commit Details","hash":"Hash:","author":"Author:","date":"Date:","files":"Files:","nChanges":"{{count}} changes","loadingFiles":"Loading files...","noFileChanges":"No file changes","loadingDiff":"Loading diff...","selectFileToView":"Select a file to view diff"},"askQuestion":{"title":"Questions","nQuestions":"{{count}} questions","checkedN":"{{count}} checked","copyChecked":"Copy {{count}} checked Q&A","copyAll":"Copy all Q&A","sendChecked":"Send {{count}} checked Q&A to AI","sendAll":"Send all Q&A to AI","sendNoChat":"No active chat session","checkToCopy":"Check to copy","custom":"Custom","customPlaceholder":"Enter custom answer...","notSelected":"(not selected)"},"tabBar":{"closeTab":"Close tab","closeAll":"Close all tabs","newTab":"New tab"},"tabManagerTopBar":{"copyPageUrl":"Copy page URL","copyDirPath":"Copy directory path","refreshProject":"Refresh project","openInVSCode":"Open in VS Code","openInCursor":"Open in Cursor","aliasesGlobal":"Command Aliases (Global)","tokenStats":"Token Stats","openSurething":"Open Surething"},"hoverTooltip":{"findReferences":"Find References","search":"Search"},"todoViewer":{"title":"Task List","progress":"{{completed}} / {{total}} done"},"userMessages":{"title":"User Messages","noMessages":"No user messages","searchPlaceholder":"Search user messages…","noResults":"No matching messages","loadFailed":"Failed to load","count":"{{shown}} / {{total}}","jumping":"Loading the turns around this message…"},"shortIdBadge":{"clickToDisconnect":"Click to disconnect","clickToRegister":"Click to register and copy CLI command","setTitle":"Name this bubble (so /cc can find it later)","setTitlePlaceholder":"set title","editTitle":"Edit title","titleSet":"Title: {{title}}","dialogTitle":"Name this bubble","dialogPlaceholder":"e.g. alloydb proxy, staging admin"},"api":{"pathForbidden":"Operation not allowed on this path","deleteForbidden":"Delete not allowed on this path","notAFolder":"Target is not a folder","imageTooLarge":"Image too large to preview","cannotPreviewBinary":"Cannot preview binary file","fileTooLarge":"File too large to preview (over 10MB)","fileModifiedExternally":"File was modified externally","pickFolderPrompt":"Select project folder"},"confirm":{"title":"Notice","ok":"OK","cancel":"Cancel"},"floatingToolbar":{"addComment":"Add Comment","sendToAI":"Send to AI","search":"Search"},"quickReply":{"optionA":"A","optionB":"B","optionC":"C","optionD":"D","allRecommended":"Rest recommended","thisOne":"This one","notThis":"Not this","why":"Why?","elaborate":"Say more","example":"Give an example","start":"Do it","continue":"Continue","ok":"OK","done":"Done","edit":"Edit quick replies","editTitle":"Edit quick replies","editHint":"One line per row; separate phrases with commas. Each phrase is sent to the chat exactly as written.","editPlaceholder":"This one, Not this\\nWhy?, Say more","restoreDefault":"Restore defaults","save":"Save","cancel":"Cancel","customizedFor":"Customizing the {{lang}} phrases — the other language is unaffected.","langEn":"English","langZh":"Chinese","saveFailed":"Failed to save quick replies"},"searchResults":{"title":"Search Results","nMatches":"({{count}} matches)","searching":"Searching...","noResults":"No matches","scopeSelected":"Selected","scopeAll":"All"},"references":{"title":"References","searching":"Searching...","notFound":"No references found"},"gitFileTree":{"noFiles":"No files"},"deps":{"action":"Dependencies","none":"none","symbolMessage":"Analyse the dependencies of {{name}} ({{path}}:{{lines}}).\\n\\nCallers: {{callers}}\\nCalls: {{callees}}\\nExternal: {{externals}}\\n\\nExplain which modules it is coupled to, and which of those dependencies could be narrowed."},"explain":{"action":"Explain","fileMessage":"Explain {{path}}","symbolMessage":"Explain {{name}} ({{path}}:{{lines}})","selectionMessage":"Explain","commitFileMessage":"Explain what git commit {{hash}} changed in {{path}}","compareFileMessage":"Explain the git changes to {{path}} in {{base}}..HEAD","stagedFileMessage":"Explain the git staged changes to {{path}}","unstagedFileMessage":"Explain the git working tree changes to {{path}}"},"reviewUtils":{"adjectives":["Happy","Brave","Quiet","Bright","Gentle","Agile","Free","Clear","Flying","Relaxed","Lively","Wise","Calm","Alert","Composed","Steady","Cheerful","Warm","Bold","Poised"],"nouns":["Panda","Dolphin","Crane","Snow Leopard","Skylark","Squirrel","Flying Fish","Deer","Bluebird","Silver Fox","Owl","Dragonfly","Firefly","Sea Turtle","Butterfly","Monkey","Red-crowned Crane","Antelope","Swallow","Penguin"]}}'),f=JSON.parse('{"common":{"save":"保存","cancel":"取消","delete":"删除","close":"关闭","minimize":"最小化","copy":"复制","edit":"编辑","file":"文件","codeMap":"代码地图","diff":"Diff","confirm":"确认","loading":"加载中...","search":"搜索","refresh":"刷新","retry":"重试","submit":"提交","copied":"已复制","saved":"已保存","failed":"失败","noMatch":"无匹配","noData":"无数据","done":"完成","justNow":"刚刚","minutesAgo":"{{count}}分钟前","hoursAgo":"{{count}}小时前","daysAgo":"{{count}}天前","monthsAgo":"{{count}}个月前","yearsAgo":"{{count}}年前","saveFailed":"保存失败","copyFailed":"复制失败","deleteFailed":"删除失败","operationFailed":"操作失败","copiedPath":"已复制路径","copyPath":"复制路径","openInConsole":"在 Console 气泡打开","copyAbsPath":"复制绝对路径","loadMore":"加载更多","noResult":"无匹配结果","selected":"已选择","selectAll":"全选","hint":"提示","confirmBtn":"确定","cancelBtn":"取消","preview":"预览","readable":"可读","previous":"上一个","next":"下一个","all":"全部","input":"输入","result":"结果","line":"行","lines":"行","running":"运行中","connecting":"连接中","connected":"已连接","connectionFailed":"连接失败","builtin":"内置","global":"全局","project":"项目","current":"当前","code":"代码"},"htmlApps":{"title":"HTML 应用","addTooltip":"添加到 HTML 面板","added":"已添加到 HTML 面板","alreadyAdded":"已添加过","addFailed":"添加失败","add":"添加","adding":"添加中...","addHtmlApp":"添加 HTML 应用","searchPlaceholder":"搜索 HTML 应用...","pathLabel":".html 文件的绝对路径","invalid":"无效","builtin":"内置","noDescription":"无描述","emptyNoApps":"还没有自定义 HTML 应用。","emptyCreatePrefix":"在聊天里使用","emptyCreateSuffix":"创建新应用。","addExisting":"添加已有 HTML 文件","viewDocs":"查看文档","emptyNoMatch":"没有匹配的 HTML 应用。"},"skills":{"addTooltip":"添加到 Skills 面板","added":"已添加到 Skills 面板","alreadyAdded":"已添加过","addFailed":"添加失败","title":"Skills","searchPlaceholder":"搜索 skills...","clearSearch":"清除","addSkill":"添加 Skill","emptyNoSkills":"还没有 skill。","emptyIntroPrefix":"在聊天里使用","emptyIntroSuffix":"把可复用经验整理成 SKILL.md。","emptyNoMatch":"没有匹配的 skill。","viewDocs":"查看文档","pathLabel":"SKILL.md 的绝对路径","pathPlaceholder":"/Users/you/.../skills/foo/SKILL.md","add":"添加","adding":"添加中...","invalid":"无效","copyPath":"复制路径","noDescription":"无描述","previewTitle":"Skill 预览","source":"源码","cannotRead":"无法读取文件。"},"toast":{"savedSuccess":"已保存","saveFailed":"保存失败","copiedName":"已复制: {{name}}","copyFailed":"复制失败","deleteFailed":"删除失败","operationFailed":"操作失败","staged":"已暂存","stageFailed":"暂存失败","unstaged":"已取消暂存","unstageFailed":"取消暂存失败","stagedNFiles":"已暂存 {{count}} 个文件","unstagedNFiles":"已取消暂存 {{count}} 个文件","discardFailed":"放弃变更失败","discardedNFiles":"已放弃 {{count}} 个文件的变更","deletedFile":"已删除文件","discardedChanges":"已放弃变更","pastedFile":"已粘贴: {{name}}","pasteFailed":"粘贴失败","noFileToPaste":"没有可粘贴的文件","createdFile":"已创建文件: {{name}}","createFailed":"创建失败","movedToTrash":"已移动到回收站: {{name}}","copiedPageUrl":"已复制页面地址","copiedDirPath":"已复制目录路径","switchedToBranch":"已切换到 {{branch}}","switchBranchFailed":"切换分支失败","loadBranchFailed":"加载分支列表失败","copiedCommand":"已复制: {{command}}","copiedMessage":"已复制消息","sentToPeer":"已发送到另一栏","sendToPeerFailed":"发送到另一栏失败","forkFailed":"分叉会话失败","excerptFailed":"摘录本轮失败","turnDeleted":"已删除本轮","deleteTurnFailed":"删除本轮失败","copiedUrl":"已复制网址","copiedOutput":"已复制输出","copiedCmd":"已复制命令","copiedComment":"已复制评论","copiedAllComments":"已复制全部评论","copiedFileContent":"已复制文件内容","copiedQA":"已复制 {{count}} 个问答","copiedAllQA":"已复制所有问答","sentQA":"已发送给 AI","readFileFailed":"读取文件失败","fileOutsideProject":"文件在当前项目之外,仅支持预览 Markdown、CSV 和图片","reviewCreated":"评审已创建,链接已复制","reviewUpdated":"评审已更新,链接已复制","reviewCreateFailed":"创建评审失败","sharingClosed":"已关闭分享","sharingCloseFailed":"关闭分享失败","linkCopied":"链接已复制","addCommentFailed":"添加评论失败","deleteCommentFailed":"删除评论失败","editCommentFailed":"编辑评论失败","addReplyFailed":"添加回复失败","deleteReplyFailed":"删除回复失败","editReplyFailed":"编辑回复失败","disconnected":"已断开: {{id}}","pluginReloading":"插件重载中...","worktreeCreateSuccess":"Worktree 创建成功: {{name}}","worktreeCreateFailed":"创建 worktree 失败","worktreeLoadFailed":"加载 worktree 列表失败","worktreeDeleted":"Worktree 已删除","worktreeDeleteFailed":"删除 worktree 失败","worktreeLocked":"已锁定","worktreeUnlocked":"已解锁"},"workspace":{"selectProject":"选择一个项目开始","searchProjectPath":"搜索项目路径...","loadingProjects":"加载项目中...","projectNotFound":"未找到项目","sessions":"{{count}} 会话","loadingSessions":"加载会话...","noSessions":"无会话记录","loadingText":"加载中...","openProject":"打开项目","expandSidebar":"展开侧边栏","collapseSidebar":"折叠侧边栏","notes":"笔记","skills":"技能","apps":"应用","settings":"设置","help":"帮助","updateAvailable":"新版本 v{{version}} 可用","copyUpgradeCommand":"复制 cockpit update","updateNow":"立即更新","updating":"正在更新…","updateComplete":"更新完成","updateFailed":"更新失败","updateCardPreparing":"正在准备更新…","updateCardInstalling":"正在下载并安装","updateCardRepairing":"正在修复原生依赖","updateCardUpToDate":"已是最新版本 v{{version}}","updateCardCopyFix":"复制修复命令","updateCardFixCopied":"已复制修复命令","updateCardRollingBack":"安装失败,正在回滚","updateCardRestarting":"正在重启 Cockpit…","updateCardDone":"已更新到 v{{version}}","updateCardElapsed":"已用 {{seconds}} 秒","updateCardBaseline":"上次约 {{seconds}} 秒","updateCardNoLiveStatus":"暂时读不到实时状态,更新仍在进行","updateCardRolledBack":"已回滚到原版本,Cockpit 可正常使用。","updateCardManualHint":"可在终端手动重试:","updateCardLogHint":"日志:{{path}}","updateRestartNote":"Cockpit 将在后台重启。","viewChangelog":"查看变更日志","serverRestarted":"Cockpit 已在后台更新。","reloadNow":"刷新","upgradeCommandCopied":"已复制 `cockpit update`","projectNotes":"项目笔记","closeProject":"关闭项目"},"mobile":{"useDesktop":"桌面版","messagePlaceholder":"发消息…","send":"发送","stop":"停止","enableNotifications":"开启通知","disableNotifications":"关闭通知","notifyError":"无法开启通知"},"sessions":{"recentSessions":"最近会话","favorites":"收藏会话","noFavorites":"暂无收藏会话,在 Tab 栏点击星标可添加","addFavorite":"收藏此会话","removeFavorite":"取消收藏","runningCount":"{{count}} 运行中","unreadCount":"{{count}} 未读","noSessions":"暂无会话记录","running":"运行中","done":"完成","editTitle":"编辑标题","projectSessions":"项目会话","browseAllSessions":"浏览所有会话","sessionList":"会话列表","search":"搜索","searchSessions":"搜索会话...","searchRecentSessions":"搜索最近会话","loadSessionsFailed":"加载会话失败","loadingSessions":"加载会话中...","noMatchingSessions":"未找到匹配的会话","noSessionsYet":"暂无会话","projectList":"项目列表","openFolder":"打开文件夹","selectingFolder":"选择中...","loadingHistory":"加载历史消息..."},"scheduledTasks":{"title":"定时任务","aboutToTrigger":"即将触发","secondsLater":"{{count}}秒后","minutesLater":"{{count}}分钟后","hoursMinutesLater":"{{h}}小时{{m}}分后","hoursLater":"{{h}}小时后","onceType":"一次性 ({{minutes}}分钟)","everyNMinutes":"每{{minutes}}分钟","completed":"已完成","paused":"已暂停","activeCount":"{{running}} 个活跃","pausedCount":"{{paused}} 个暂停","noScheduledTasks":"暂无定时任务,在聊天输入栏点击时钟按钮创建","lastResult":"上次","runNow":"立即运行","deleteFailed":"删除任务失败","resume":"恢复","pause":"暂停","completedCount":"已完成 ({{count}})","groupPendingReview":"运行完成待查看","groupUpcoming":"运行中 \xb7 待运行","openSession":"打开会话","selectTaskHint":"选择左侧任务,查看它的会话消息","noTaskMessages":"该任务的会话暂无消息","success":"成功","failure":"失败","createTask":"创建定时任务","editTask":"编辑定时任务","sendMessage":"发送消息","messagePlaceholder":"输入要发送的消息...","taskFile":"任务文件","taskFilePlaceholder":"/Users/you/project/tasks/daily-report.md","taskFileHint":"填写绝对路径。触发时会让 agent 先读取该文件,再按其中描述执行——文件内容改动下次触发即生效。","taskFilePromptHeader":"请先读取以下任务文件,再据此执行:","type":"类型","once":"一次性","interval":"周期","quickSelect":"快捷选择","customCron":"自定义 Cron 表达式","customMinutes":"自定义分钟数","cronPlaceholder":"例: 0 9 * * 1-5 (工作日9点)","cronFormat":"格式:分 时 日 月 星期(如 0 9 * * 1-5)","minutesPlaceholder":"分钟数","limitTimeRange":"限制执行时段","to":"至","saveBtn":"保存 ({{modKey}}↩)","createBtn":"创建 ({{modKey}}↩)","5minLater":"5 分钟后","15minLater":"15 分钟后","30minLater":"30 分钟后","1hourLater":"1 小时后","every15min":"每 15 分钟","every30min":"每 30 分钟","every1hour":"每 1 小时","every2hours":"每 2 小时","daily9am":"每天 09:00","daily6pm":"每天 18:00","weeklyMon9am":"每周一 09:00","monthly1st9am":"每月 1 号 09:00"},"cron":{"everyNMinutes":"每 {{n}} 分钟","everyNHours":"每 {{n}} 小时整点","everyMinute":"每分钟","everyHourAtMin":"每小时第 {{m}} 分","hourlyEveryMin":"{{h}} 点每分钟","daily":"每天 {{time}}","weekdays":"工作日","weekends":"周末","dowSun":"日","dowMon":"一","dowTue":"二","dowWed":"三","dowThu":"四","dowFri":"五","dowSat":"六","monthPrefix":"月","dayOfMonth":"号","dayRange":"{{a}}号到{{b}}号","weekdayPrefix":"周","weekdayRange":"周{{a}}到周{{b}}"},"blockViewer":{"empty":{"body":"在左侧文件树选择一个文件,查看它的代码地图。","hint":"或按 ⌘K 搜索。"},"fileMode":{"loading":"加载中…","notFound":"该文件未索引(不支持的语言或超出文件上限)。"},"buildProgress":{"listing":"正在扫描文件…","contexts":"正在读取项目配置…","parsing":"正在解析文件","resolving":"正在解析引用关系…","edges":"正在构建调用图…","done":"即将完成…"},"search":{"tooltip":"搜索 (⌘K)","hint":"开始输入以搜索","noResults":"未找到匹配","files":"文件","symbols":"符号"},"viewerToggle":{"toBlock":"显示代码地图","toCode":"返回代码视图"},"tabs":{"toc":"函数列表","history":"跳转记录"},"toc":{"title":"本文件","empty":"未检测到函数。","notIndexed":"该文件未被项目图收录(扩展未支持 / 不在 git 跟踪集 / 超出文件上限)。"},"history":{"title":"最近","empty":"点击左右两侧的 pin 开始追踪调用链。","clear":"清空历史"},"refresh":"重新构建项目图","retry":"重试"},"blockDiffViewer":{"loading":"正在生成代码地图…","unsupported":"该文件类型暂不支持代码地图 diff","unsupportedHint":"切回常规 diff 视图查看。","error":"代码地图 diff 失败:{{message}}","noBlockChanges":"代码地图无变化(仅格式或空白)。","noBefore":"(新增)","noAfter":"(已删除)","kind":{"added":"新增","deleted":"删除","modified":"修改"}},"fileBrowser":{"directoryTree":"目录树","searchTab":"搜索","recentTab":"最近","changesTab":"变更","historyTab":"历史","searchFiles":"搜索文件...","clear":"清除","exactMatchOn":"全词匹配(已开启)","exactMatchOff":"全词匹配(已关闭)","refreshTree":"刷新目录树","collapseAll":"折叠所有目录","searchFileContent":"搜索文件内容...","caseSensitive":"区分大小写","wholeWord":"完整词","regex":"正则","fileTypes":"文件类型 (ts,tsx)","compareMode":"对比","compareModeOff":"关闭分支对比","compareModeOn":"与选定分支对比","createFile":"新建文件","createFileIn":"新建文件 (在 {{path}}/)","fileName":"文件名...","noRecentFiles":"暂无最近浏览的文件","stagingArea":"暂存区 ({{count}})","changesSummary_one":"{{count}} 个变更","changesSummary_other":"{{count}} 个变更","noChanges":"工作区无变更","refreshChanges":"刷新变更列表","unstageAll":"全部取消","noStagedFiles":"无暂存的文件","unstageNFiles":"取消暂存 {{count}} 个文件","unstageFile":"取消暂存","workspace":"工作区 ({{count}})","discardAll":"放弃所有","stageAll":"全部暂存","noUnstagedChanges":"无未暂存的变更","discardNFiles":"放弃 {{count}} 个文件的变更","stageNFiles":"暂存 {{count}} 个文件","discardChanges":"放弃变更","stageFile":"暂存文件","loadingDiff":"加载对比文件中...","noDiffFiles":"无差异文件","nFilesChanged":"{{count}} 个文件变更(vs {{branch}})","loadingCommits":"加载提交记录中...","noCommits":"无提交记录","allLoaded":"已加载全部 {{count}} 条记录","locateInTree":"在目录树中定位","unsaved":"未保存","saveBeforeSwitch":"当前文件有未保存的修改,是否保存后切换?","saveAndSwitch":"保存并切换","closeEdit":"关闭编辑 (ESC)","closeBtn":"关闭","copyFileContent":"复制文件内容","toggleJsonReadable":"切换 JSON 可读模式","previewMarkdown":"预览 Markdown 渲染效果","exitPreview":"退出预览","collapseAllJson":"折叠","expandAllJson":"展开","viewBlame":"查看每行代码的修改记录","viewDiff":"查看相对 HEAD 的改动","exitDiff":"退出 Diff","diffLoadFailed":"加载差异失败","editFile":"编辑文件","backToPreview":"返回预览","cannotPreview":"无法预览此文件","selectFileToPreview":"选择文件以预览","staged":"已暂存","unstaged":"未暂存","selectFileToViewDiff":"选择文件查看差异","loadingDiffContent":"加载差异中...","clickCompareToLoad":"点击「对比」加载分支差异","selectCommitToView":"选择提交查看详情","confirmDelete":"确认删除","confirmDeleteMessage":"确定要将 <file>{{name}}</file> 移动到回收站吗?","nFilesNMatches":"{{files}} 个文件,{{matches}} 处匹配","resultsTruncated":"结果已截断","noContentSearchResults":"无匹配结果","enterKeywordToSearch":"输入关键词搜索文件内容","searchMinChars":"搜索内容至少需要 2 个字符"},"csv":{"table":"表格","raw":"原始内容","empty":"空表格","summary":"{{rows}} 行 \xb7 {{cols}} 列","summaryFiltered":"匹配 {{rows}} / {{total}} 行 \xb7 {{cols}} 列","loadMore":"加载更多(已显示 {{shown}} / {{total}})","filterPlaceholder":"筛选内容…","filterColumn":"筛选列","clearFilter":"清除筛选","allColumns":"全部列","noMatch":"没有匹配的行","sortHint":"点击排序(升序 / 降序 / 取消)"},"codeViewer":{"fileModifiedExternally":"文件已被外部修改,保存将覆盖外部更改","useDiskVersion":"使用磁盘版本","forceOverwrite":"强制覆盖","searchPlaceholder":"搜索...","caseSensitive":"区分大小写","wholeWordMatch":"全字匹配","unsavedConfirm":"有未保存的修改,确定关闭?","discardChanges":"放弃修改","continueEditing":"继续编辑","unsavedExitConfirm":"有未保存的修改,确定退出编辑模式?","clickToViewDetails":"点击查看详情","clickToViewCommit":"点击查看 commit 详情","nComments":"{{count}} 条评论","searchChat":"搜索聊天内容...","prevShiftEnter":"上一个 (Shift+Enter)","nextEnter":"下一个 (Enter)","closeEsc":"关闭 (Esc)"},"chat":{"startConversation":"开始对话吧","loadMoreHistory":"加载更多...","scrollUpForMore":"↑ 向上滚动加载更多历史","jumpToStart":"跳转到开始","jumpToLatest":"跳转到最新","jumpToPrevUserMessage":"上一条用户消息","jumpToNextUserMessage":"下一条用户消息","recentUserMessages":"最近的用户消息","moreUserMessages":"更多","userMessage":"用户消息","recentUserMessageNumber":"最近用户消息 {{index}}/{{total}}","imageMessage":"图片消息","copyMessage":"复制消息","copyImage":"复制图片","copiedImage":"已复制图片","forkSession":"从此处分叉会话","excerptTurn":"摘录本轮到新会话","newSession":"新建会话","continueFromHere":"延续到此处","continueFromHereDesc":"保留截至本轮的全部上下文","onlyThisTurn":"仅提取本轮","onlyThisTurnDesc":"只带这一轮问答","deleteTurn":"删除本轮","deletingTurn":"正在删除…","deleteTurnConfirm":"确定删除这一轮的问题、回答及工具记录吗?此操作无法撤销。","deleteTurnConfirmAction":"删除本轮","deleteTurnWhileRunning":"会话运行期间不能删除","sendToPeerPane":"发送本条消息到另一栏","imageN":"图片 {{index}}","imagePreview":"图片预览","toolCalls":"{{count}} 个工具调用","collapse":"▲ 收起","expand":"▼ 展开","showMore":"显示更多","showLess":"收起","subagent":"子代理","subagentEmpty":"未找到子代理消息记录","subagentViewTitle":"查看子代理执行过程","workflowRun":"运行详情","workflowViewTitle":"查看工作流运行详情","workflowEmpty":"未找到工作流运行记录","workflowAgents":"个代理","workflowViewAgent":"查看","workflowUngrouped":"未分组","viewQuestions":"查看提问","viewAllFileChanges":"查看所有文件变更","requestFailed":"请求失败","cannotReadStream":"无法读取响应流","errorRetry":"发生错误,请重试","codexResumeFailed":"原会话被其他 Codex 客户端占用,已新建会话,历史未继承","codexResumeFailedPrevious":"原会话","codexResumeFailedNew":"新会话","placeholder":"输入消息,Enter 发送(Shift+Enter 换行,可粘贴图片;行首 /(主会话)或 @(子代理)唤起命令,支持多行多命令)","placeholderDisabled":"生成中... 可继续输入 (ESC 取消;卡住太久可取消后重发「继续」)","imageSizeLimit":"图片大小超过限制(最大 5MB),当前大小: {{size}}MB","viewGitChanges":"查看 Git 变更","viewAllComments":"查看所有评论","userMessages":"用户消息列表","projectNotes":"项目笔记","scheduledTasks":"定时任务","quickInstructions":"快捷指令","globalInstructions":"全局指令","projectInstructions":"项目指令","noQuickInstructions":"暂无快捷指令","addQuickInstruction":"新增快捷指令","quickInstructionPlaceholder":"输入一句话指令,Enter 保存,Esc 取消","insertQuickInstruction":"填入输入框(不发送)","addInstructionGroup":"新增分组","instructionGroupNamePlaceholder":"输入分组名,Enter 保存,Esc 取消","instructionGroupLabel":"所属分组","instructionGroupNone":"不分组","deleteInstructionGroupConfirm":"删除分组「{{name}}」会同时删除组内 {{count}} 条指令,确定继续?","editGlobalInstructions":"编辑全局指令","editProjectInstructions":"编辑项目指令","quickInstructionsMarkdownHint":"一级内容每行一条;分组名称后的「- 」开头行是该分组的子命令。","quickInstructionsMarkdownPlaceholder":"按推荐实施\\n用文本画图\\n- 画一个登录流程\\n- 画一个系统架构","quickInstructionsMarkdownError":"第 {{line}} 行格式不正确。","savingQuickInstructions":"保存中...","saveQuickInstructionsFailed":"保存失败,修改仍然保留,请重试。","context":"上下文","output":"输出","copiedCommandTooltip":"已复制!","copyCommandTooltip":"复制命令: {{command}}","executedCommand":"执行了 `{{command}}`{{exitInfo}},输出:\\n```\\n{{output}}\\n```","executedCommandFailed":"执行 `{{command}}` 失败:{{error}}","executionMode":"执行模式","checkBalance":"查询余额","balanceFailed":"查询失败,请检查 API Key","balanceNeedsKey":"请先配置 DeepSeek API Key","balanceUnavailable":"账户当前不可用","balanceEmpty":"接口未返回余额","openUsagePage":"打开 DeepSeek 用量控制台","checkQuota":"查询额度","quotaFailed":"额度查询失败,请检查 API Key","quotaNeedsKey":"请先设置 API Key","quotaEmpty":"未返回额度信息","quotaResetAt":"{{time}} 重置","openProviderConsole":"打开服务商控制台","planMode":"计划模式","planModeDesc":"只读,先出计划不改代码","planModeOn":"已开启计划模式——只读;发一个任务即可拿到计划","planModeOff":"已关闭计划模式","planModeHint":"计划模式:只读探索、产出计划但不改文件。取消勾选后重发才会实现。","noHistory":"不带历史上下文","noHistoryDesc":"每次提问均独立","noHistoryHint":"不带历史上下文:每条消息单独发给模型,不带之前的对话。上方的会话记录照常保留。","planTitle":"计划(待你确认)","approvePlan":"批准并执行","planApproveHint":"本环境无审批弹窗,点此退出计划模式并执行","approvePlanPrompt":"已批准,按上述计划开始执行。","maximizePane":"放大本栏","restorePane":"还原双栏","closePane":"关闭本栏","singlePane":"切回单栏","splitPane":"并排双栏"},"console":{"enterCommandOrUrl":"输入命令或网址开始使用","emptyIntro":"在下方输入框输入以下内容,即可创建对应气泡:","bubbleCommand":"命令","bubbleInteractive":"交互终端","bubbleBrowser":"浏览器","bubbleBrowserNoteIframe":"部分网站会拦截 iframe 嵌入,请在「设置 → 浏览器插件」安装 Cockpit Bridge 后再打开。","bubbleBrowserNoteCookie":"已登录的网站若首次显示未登录,多刷新几次即可恢复。","bubbleDatabase":"数据库","bubbleFilePreview":"文件预览","loadingMore":"加载中...","loadMoreHistory":"加载更多历史","quickCommands":"快捷命令","singleColumn":"单列布局","dualColumn":"双列布局","envVars":"环境变量","launchShell":"启动交互终端","htmlApps":"HTML 应用","inputPlaceholder":"输入命令或网址并按 Enter... (↑↓ 历史, Tab 补全)","scopeProject":"项目","scopeGlobal":"全局","tabSwitchEscClose":"Tab 切换 \xb7 Esc 关闭","copyOutput":"复制输出","copyCommand":"复制命令","rerun":"重新运行","deleteRecord":"删除记录","searchPlaceholder":"搜索...","searchMode":"搜索","filterMode":"过滤","prevShiftEnter":"上一个 (Shift+Enter)","nextEnter":"下一个 (Enter)","loadingTerminal":"加载终端...","clickToInput":"点击终端区域输入","stdinPlaceholder":"stdin 输入...","runningText":"运行中...","exitCode":"退出代码: {{code}}","totalLines":"共 {{count}} 行","globalCommands":"全局命令","projectCommands":"项目命令","noCustomCommands":"暂无自定义命令","namePlaceholder":"名称","commandPlaceholder":"命令","restoreTooltip":"还原 ({{modKey}}M / ESC)","screenshotting":"截图中...","outputFileDeleted":"[输出文件已删除]"},"browser":{"blankPage":"空白页","copyUrl":"复制网址","openInNewWindow":"在新窗口打开","exitMaximize":"退出最大化 ({{modKey}}M)","maximize":"最大化 ({{modKey}}M)","pageLoadFailed":"页面加载失败","clickToWake":"点击唤醒","sleeping":"已休眠","loadingPage":"加载中...","loadFailed":"加载失败"},"database":{"connectionFailed":"连接失败","connected":"已连接","connecting":"连接中...","refreshTableList":"刷新表列表","filterTable":"T 表","filterView":"V 视图","noTables":"无表","tabStructure":"结构","tabData":"数据","tabSql":"SQL","filterActive":"筛选: {{count}}列","clearAllFilters":"清除所有筛选","deleteNRows":"删除 {{count}} 行","confirmDeleteRows":"确认删除?","copyCsvSelected":"复制选中行为 CSV","copyCsvAll":"导出全表 CSV","copyJsonSelected":"复制选中行为 JSON","copyJsonAll":"导出全表 JSON","copyCSV":"复制 CSV","CSV":"CSV","copyJSON":"复制 JSON","JSON":"JSON","selectTable":"选择左侧表格","selectTableToView":"选择表以查看结构","selectTableForData":"选择表以查看数据","columns":"列","colName":"名称","colType":"类型","colNullable":"可空","colDefault":"默认值","primaryKey":"主键","foreignKeys":"外键","indexes":"索引","enable":"启用","commaValues":"逗号分隔多值","likePattern":"%pattern%","valuePlaceholder":"值","apply":"应用","clearFilter":"清除","addRow":"+ 新增行","totalRows":"{{count}} 行","rowsAffected":"{{command}} — {{count}} 行受影响 ({{duration}}ms)","queryRows":"{{count}} 行 ({{duration}}ms)","resultTruncated":"[结果已截断至1000行]","sqlPlaceholder":"输入 SQL... ({{modKey}}Enter 执行)","executing":"执行中...","execute":"▶ 执行","deleteRowsFailed":"{{count}} 行删除失败","inputParams":"输入参数","resultLabel":"结果"},"mysql":{"connectionFailed":"连接失败","connected":"已连接","connecting":"连接中...","refreshTableList":"刷新表列表","filterTable":"T 表","filterView":"V 视图","noTables":"无表","tabStructure":"结构","tabData":"数据","tabSql":"SQL","filterActive":"筛选: {{count}}列","clearAllFilters":"清除所有筛选","deleteNRows":"删除 {{count}} 行","confirmDeleteRows":"确认删除?","copyCsvSelected":"复制选中行为 CSV","copyCsvAll":"导出全表 CSV","copyJsonSelected":"复制选中行为 JSON","copyJsonAll":"导出全表 JSON","copyCSV":"复制 CSV","CSV":"CSV","copyJSON":"复制 JSON","JSON":"JSON","selectTable":"选择左侧表格","selectTableToView":"选择表以查看结构","selectTableForData":"选择表以查看数据","columns":"列","colName":"名称","colType":"类型","colNullable":"可空","colDefault":"默认值","primaryKey":"主键","foreignKeys":"外键","indexes":"索引","enable":"启用","commaValues":"逗号分隔多值","likePattern":"%pattern%","valuePlaceholder":"值","apply":"应用","clearFilter":"清除","addRow":"+ 新增行","totalRows":"{{count}} 行","rowsAffected":"{{command}} — {{count}} 行受影响 ({{duration}}ms)","queryRows":"{{count}} 行 ({{duration}}ms)","resultTruncated":"[结果已截断至1000行]","sqlPlaceholder":"输入 SQL... ({{modKey}}Enter 执行)","executing":"执行中...","execute":"▶ 执行","deleteRowsFailed":"{{count}} 行删除失败"},"redis":{"neverExpires":"永不过期","expired":"已过期","loadFailed":"加载失败","deleteFailed":"删除失败","saveFailed":"保存失败","scanPlaceholder":"SCAN 模式...","scanSearch":"搜索 (SCAN)","noKeys":"无 key","loadMore":"加载更多...","tabData":"数据","tabInfo":"信息","tabCli":"CLI","selectKey":"选择左侧 Key","keyNotExist":"Key 不存在","unsupportedType":"不支持的类型: {{type}}","nItems":"{{total}} items","showingN":"显示 {{count}}","nMembers":"{{total}} members","nEntries":"{{total}} entries","cliHint":"输入 Redis 命令,如 PING, GET key, KEYS *","cliPlaceholder":"输入命令..."},"git":{"switchBranch":"切换分支","searchBranch":"搜索分支...","noBranches":"无可切换分支","noMatchingBranches":"无匹配分支","localBranches":"本地分支","remoteBranches":"远程分支","branchNotFound":"未找到分支","selectBranch":"选择分支...","currentBranch":"当前","notGitRepo":"当前目录不是 Git 仓库","cannotGetBranches":"无法获取分支信息","getBranchesFailed":"获取分支信息失败","discardAllConfirm":"确定要放弃工作区的 {{count}} 个文件的变更吗?此操作不可恢复。","worktree":{"title":"Git Worktree","count":"{{count}} 个 worktree","selectBranch":"选择分支","addWorktree":"+ 添加 Worktree","confirmDelete":"确认删除","confirmDeleteMsg":"确定要删除 worktree 吗?","path":"路径:","branch":"分支:","locked":"已锁定","unlock":"解锁","lock":"锁定","searchBranch":"搜索分支...","noBranches":"无可用分支"}},"comments":{"addComment":"添加评论","lineRange":"行 {{start}}-{{end}}","inputPlaceholder":"输入评论...","newComment":"新评论 {{range}}","commentPlaceholder":"输入评论... ({{modKey}}Enter 提交, Esc 取消)","nComments":"{{count}} 条评论","allComments":"所有评论","copyAllComments":"复制全部评论","noComments":"暂无评论","clearAll":"清空所有","totalComments":"共 {{count}} 条评论","aiReply":"AI 回复","noContent":"(无内容)","linesCount":"({{count}} 行)","codeRef":"以下是我标注的评论和引用:","note":"备注: {{content}}","submitting":"提交中...","enterSubmit":"Enter 提交 \xb7 Shift+Enter 换行","submitComment":"提交评论","askAI":"提问 AI","inputQuestion":"输入你的问题...","aiGenerating":"正在生成中,请稍候...","enterSend":"Enter 发送 \xb7 Shift+Enter 换行","sendToAI":"发送 AI","aiResponding":"AI 正在响应中..."},"fileContextMenu":{"createFile":"新建文件","copyFile":"复制文件","copyFolder":"复制文件夹","pasteHere":"粘贴到此处","deleteFile":"删除文件","deleteFolder":"删除文件夹","copyRelativePath":"复制相对路径","copyAbsolutePath":"复制绝对路径","copyRelativeDirPath":"复制相对文件夹路径","copyAbsoluteDirPath":"复制绝对文件夹路径","copyFileName":"复制文件名","copyFolderName":"复制文件夹名"},"settings":{"title":"设置","theme":"主题","themeLight":"浅色","themeDark":"深色","themeSystem":"跟随系统","browserExtension":"浏览器插件","extensionInstalled":"Cockpit Bridge 已安装","extensionNotInstalled":"Cockpit Bridge 未安装","extensionDescription":"安装 Chrome 插件后,iframe 内的链接跳转将被拦截:新标签链接创建新气泡,页面内导航更新当前气泡。","installSteps":"安装步骤:","step1":"1. 打开 Chrome 地址栏输入","step2":"2. 开启右上角「开发者模式」","step3":"3. 点击「加载已解压的扩展程序」","step4mac":"4. 按 <kbd>Cmd+Shift+G</kbd> → 粘贴下方路径 → 回车","copyExtensionPath":"复制插件目录路径","reloadExtension":"重载插件","about":"关于","language":"语言","languageAuto":"跟随系统","switchDark":"切换暗色","switchLight":"切换亮色","agentsBundled":"内置"},"editor":{"placeholder":"写点什么... 输入 / 打开快捷命令","noteTitle":"{{name}} - 笔记","noteUntitled":"笔记","saving":"保存中...","conflictReloaded":"笔记已被其他地方修改,已加载最新版本,刚才未保存的编辑已丢弃","linkPlaceholder":"输入链接地址...","confirmLink":"确认","removeLink":"移除链接","heading1":"标题 1","heading2":"标题 2","heading3":"标题 3","bold":"粗体","italic":"斜体","strikethrough":"删除线","inlineCode":"行内代码","link":"链接","bulletList":"无序列表","orderedList":"有序列表","taskList":"待办列表","blockquote":"引用","codeBlock":"代码块","table":"表格","horizontalRule":"分割线","insertRowAbove":"在上方插入行","insertRowBelow":"在下方插入行","insertColumnLeft":"在左侧插入列","insertColumnRight":"在右侧插入列","deleteRow":"删除当前行","deleteColumn":"删除当前列","deleteTable":"删除表格","deleteCodeBlock":"删除代码块","toc":"目录","expandToc":"展开目录","collapseToc":"收起目录"},"slashCommands":{"heading1":"标题 1","heading1Desc":"大标题","heading2":"标题 2","heading2Desc":"中标题","heading3":"标题 3","heading3Desc":"小标题","bulletList":"无序列表","bulletListDesc":"项目符号列表","orderedList":"有序列表","orderedListDesc":"编号列表","taskList":"待办列表","taskListDesc":"可勾选的任务列表","blockquote":"引用","blockquoteDesc":"引用块","codeBlock":"代码块","codeBlockDesc":"代码片段","table":"表格","tableDesc":"插入 3\xd73 表格","horizontalRule":"分割线","horizontalRuleDesc":"水平分割线","link":"链接","linkDesc":"插入超链接"},"commands":{"plan":"开启计划模式 \xb7 /plan <任务> 直接规划该任务 \xb7 /plan off 关闭"},"review":{"reviewManagement":"评审管理","allReviews":"所有评审","noOpenReviews":"暂无开放评审","viewComments":"查看评论","nComments":"{{count}} 条评论","nDocs":"{{count}} 文档","nReviews":"{{count}} 评审","docList":"文档列表","allReviewsList":"所有评审","expandList":"展开列表","collapseList":"折叠列表","closeReview":"关闭评审","reopenReview":"重新开放","deleteReview":"删除评审","noOpenDocs":"暂无开放文档","noReviews":"暂无评审","sharing":"分享中","notShared":"未分享","closeSharing":"关闭分享","enableSharing":"开启分享评审","view":"查看","setNickname":"设置你的昵称","nicknameHint":"其他评审人将看到这个名字","nicknamePlaceholder":"输入昵称","skipForNow":"下次再说","identitySettings":"身份设置","reviewNickname":"评审昵称","random":"随机","selectTextToComment":"选中左侧文本添加评论","selectTextHint":"选中左侧文本即可添加评论","prevComment":"上一条","nextComment":"下一条","commentsCount":"{{count}} 条评论","commentsNavCount":"{{current}}/{{total}} 条评论","allCommentsTitle":"全部评论","commentsCountBrief":"{{count}} 条","closedCount":"{{count}} 条已关闭","copyAllComments":"复制全部评论","noComments":"暂无评论","closedComments":"已关闭 ({{count}})","closedLabel":"已关闭","moreReplies":"+{{count}} 条回复","copyComment":"复制评论","reopen":"重开","closeComment":"关闭评论","editComment":"编辑评论","deleteComment":"删除评论","edited":"(已编辑)","editReply":"编辑回复","deleteReply":"删除回复","reply":"回复","replyPlaceholder":"添加回复...","selectedText":"选中文本","addCommentPlaceholder":"添加评论...","enterSubmitHint":"Enter 提交,Shift+Enter 换行","commentBtn":"评论","reviewNotExist":"评审不存在或已被删除","loadFailed":"加载失败","networkError":"网络错误","reviewNotFound":"评审不存在","checkLink":"请检查链接是否正确","updatedAt":"更新于 {{date}}","active":"开放中","closed":"已关闭","viewAllComments":"查看全部评论","viewCommentBtn":"查看评论","copyLink":"复制链接","reviewSummary":"评审评论汇总 — {{title}}","totalNComments":"共 {{count}} 条评论","quoteRef":"引用: \\"{{text}}\\"","commentAuthor":"评论 ({{author}}): {{content}}","replyAuthor":" ↳ {{author}}: {{content}}"},"markdown":{"copied":"✓ 已复制","copy":"复制"},"imagePreview":{"previewImage":"预览图片","deleteImage":"删除图片","copyImage":"复制图片","copiedImage":"已复制图片"},"tokenStats":{"title":"Claude Code Token 统计","activeHours":"活跃时段分布","hourSessions":"{{h}}:00 — {{count}} 次会话","messages":"消息","toolCalls":"工具调用","activityTrend":"活动趋势","byModel":"按模型","tokenUsage":"Token 用量","equivalentCost":"等效费用","modelCostDetail":"模型费用明细","model":"模型","share":"占比","total":"合计","totalSessions":"总会话","totalMessages":"总消息","equivalentApiCost":"等效 API 费用","longestSession":"最长会话","firstUse":"首次使用","notFound":"未找到 ~/.claude/stats-cache.json","day":"日","week":"周","month":"月"},"toolCall":{"inputParams":"输入参数","resultLabel":"结果","inputParamsTitle":"查看输入参数","resultTitle":"查看结果","input":"输入","result":"结果","foldedLines":"... ({{count}} 行)"},"fileEditor":{"unsavedConfirm":"有未保存的修改,确定关闭?","discardChanges":"放弃修改","continueEditing":"继续编辑","externallyModified":"文件已被外部修改,保存将覆盖外部更改","useDiskVersion":"使用磁盘版本","forceOverwrite":"强制覆盖"},"quickFileOpen":{"placeholder":"输入文件名快速打开...","noMatch":"没有匹配的文件","recent":"最近","selectHint":"选择","openHint":"打开","closeHint":"关闭"},"envManager":{"title":"环境变量管理","tabScope":"当前 Tab 专用","globalScope":"全局环境变量","varNamePlaceholder":"变量名(如 NODE_ENV)","varValuePlaceholder":"值(如 production)","valuePlaceholder":"值","noVars":"还没有环境变量,添加一个试试"},"aliasManager":{"title":"命令别名管理","description":"为常用命令设置快捷别名(全局生效)","aliasPlaceholder":"别名(如 ll)","commandPlaceholder":"完整命令(如 ls -la)","fullCommandPlaceholder":"完整命令","usage":"使用提示:","usageDesc":"输入别名即可执行对应的完整命令","noAliases":"还没有命令别名,添加一个试试"},"diffViewer":{"fileChanges":"文件变更 ({{count}})","expandFull":"扩展到全屏","exitFull":"回到分栏","toggleFileTree":"切换文件目录","selectFileToView":"选择左侧文件查看变更","sideBySide":"并列对比","unified":"统一对比","viewSplit":"双栏","viewUnified":"单栏","previewFile":"预览文件","copiedAll":"已复制全文","compact":"精简","full":"全文","gap":{"hidden":"已隐藏 {{count}} 行","more":"\xb7\xb7\xb7 更多 +{{count}} \xb7\xb7\xb7","expandUp":"向上展开 {{count}} 行","expandDown":"向下展开 {{count}} 行","expandAll":"点击展开 {{count}} 行"},"loadingSnapshots":"正在加载快照…","noChanges":"本轮未检测到文件变更","notViewable":"二进制或超大文件,无法展示 diff","externalChange":"同期其他会话/外部进程的变更","reconstructed":"参数重建","reconstructedHint":"由工具调用参数重建,非磁盘快照","truncated":"文件过多,仅显示部分","imageBefore":"变更前","imageAfter":"变更后","imageAdded":"新增","imageDeleted":"已删除","imageLoadFailed":"图片加载失败","imageUnavailable":"该版本无此图片"},"commitDetail":{"title":"提交详情","hash":"哈希:","author":"作者:","date":"日期:","files":"文件:","nChanges":"{{count}} 个变更","loadingFiles":"加载文件中...","noFileChanges":"无文件变更","loadingDiff":"加载差异中...","selectFileToView":"选择文件查看差异"},"askQuestion":{"title":"提问","nQuestions":"{{count}} 个问题","checkedN":"已勾选 {{count}}","copyChecked":"复制勾选的 {{count}} 个问答","copyAll":"复制所有问答","sendChecked":"发送勾选的 {{count}} 个问答给 AI","sendAll":"发送所有问答给 AI","sendNoChat":"没有可用的聊天会话","checkToCopy":"勾选以复制","custom":"自定义","customPlaceholder":"输入自定义回答...","notSelected":"(未选择)"},"tabBar":{"closeTab":"关闭标签","closeAll":"关闭所有标签","newTab":"新建标签"},"tabManagerTopBar":{"copyPageUrl":"复制页面地址","copyDirPath":"复制目录路径","refreshProject":"刷新当前项目","openInVSCode":"在 VS Code 中打开","openInCursor":"在 Cursor 中打开","aliasesGlobal":"命令别名(全局)","tokenStats":"Token 统计","openSurething":"打开 Surething"},"hoverTooltip":{"findReferences":"查找引用","search":"搜索"},"todoViewer":{"title":"任务列表","progress":"{{completed}} / {{total}} 完成"},"userMessages":{"title":"用户消息列表","noMessages":"暂无用户消息","searchPlaceholder":"搜索用户消息…","noResults":"没有匹配的消息","loadFailed":"加载失败","count":"{{shown}} / {{total}} 条","jumping":"正在加载该消息所在的对话…"},"shortIdBadge":{"clickToDisconnect":"点击断开连接","clickToRegister":"点击注册并复制 CLI 命令","setTitle":"给这个气泡命名(便于 /cc 通过 connection list 找到它)","setTitlePlaceholder":"设置标题","editTitle":"编辑标题","titleSet":"标题:{{title}}","dialogTitle":"给气泡命名","dialogPlaceholder":"例如:alloydb 代理、预发管理后台"},"api":{"pathForbidden":"不允许操作此路径","deleteForbidden":"不允许删除此路径","notAFolder":"目标不是文件夹","imageTooLarge":"图片文件过大,无法预览","cannotPreviewBinary":"无法预览二进制文件","fileTooLarge":"文件过大,无法预览(超过 10MB)","fileModifiedExternally":"文件已被外部修改","pickFolderPrompt":"选择项目文件夹"},"confirm":{"title":"提示","ok":"确定","cancel":"取消"},"floatingToolbar":{"addComment":"添加评论","sendToAI":"发送 AI","search":"搜索"},"quickReply":{"optionA":"A","optionB":"B","optionC":"C","optionD":"D","allRecommended":"其他按推荐","thisOne":"就这个","notThis":"不要这样","why":"为什么","elaborate":"展开说","example":"举个例子","start":"开始做","continue":"继续","ok":"OK","done":"做完了","edit":"编辑快捷短语","editTitle":"编辑快捷短语","editHint":"一行对应面板的一行,行内用逗号分隔。每个短语会原样发送到对话。","editPlaceholder":"就这个,不要这样\\n为什么,展开说","restoreDefault":"恢复默认","save":"保存","cancel":"取消","customizedFor":"当前编辑的是{{lang}}短语,另一种语言不受影响。","langEn":"英文","langZh":"中文","saveFailed":"保存快捷短语失败"},"searchResults":{"title":"搜索结果","nMatches":"({{count}} 处匹配)","searching":"搜索中...","noResults":"无匹配结果","scopeSelected":"选中","scopeAll":"全部"},"references":{"title":"引用","searching":"搜索中...","notFound":"未找到引用"},"gitFileTree":{"noFiles":"无文件"},"deps":{"action":"依赖关系","none":"无","symbolMessage":"分析 {{name}} ({{path}}:{{lines}}) 的依赖关系。\\n\\n调用者:{{callers}}\\n调用了:{{callees}}\\n外部依赖:{{externals}}\\n\\n请说明它耦合在哪些模块上,以及哪些依赖是可以收敛掉的。"},"explain":{"action":"解释一下","fileMessage":"解释一下 {{path}}","symbolMessage":"解释一下 {{name}} ({{path}}:{{lines}})","selectionMessage":"解释一下","commitFileMessage":"解释一下 git commit {{hash}} 对 {{path}} 的改动","compareFileMessage":"解释一下 git {{base}}..HEAD 中 {{path}} 的改动","stagedFileMessage":"解释一下 git 暂存区中 {{path}} 的改动","unstagedFileMessage":"解释一下 git 工作区中 {{path}} 的改动"},"reviewUtils":{"adjectives":["快乐","勇敢","安静","明亮","温柔","灵巧","自由","清澈","飞翔","悠闲","活泼","聪慧","淡定","机敏","从容","坚定","爽朗","和煦","奔放","沉稳"],"nouns":["熊猫","海豚","白鹤","雪豹","云雀","松鼠","飞鱼","梅花鹿","青鸟","银狐","猫头鹰","蜻蜓","萤火虫","海龟","蝴蝶","金丝猴","丹顶鹤","羚羊","燕子","企鹅"]}}');d.Ay.isInitialized||d.Ay.init({resources:{en:{translation:e},zh:{translation:f}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});let g=d.Ay},1512:(a,b,c)=>{"use strict";c.d(b,{H:()=>e});let d=a=>"unread"===a?0:"loading"===a?1:2;function e(a){return[...a].sort((a,b)=>d(a.status)-d(b.status)||b.lastActive-a.lastActive)}},2633:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{d:()=>l});var e=c(48249),f=c(67484),g=c(44384),h=c(73887),i=c(55287);c(57063);var j=c(7833);c(77156),c(33281);var k=a([h,i]);function l({skillId:a,onClose:b}){let{t:c}=(0,g.Bd)(),[d,k]=(0,f.useState)(null),[m,n]=(0,f.useState)(!0),[o,p]=(0,f.useState)("preview"),q=(0,f.useCallback)(async()=>{if(d?.path)try{await navigator.clipboard.writeText(d.path),(0,j.oR)(c("common.copiedPath"),"success")}catch{(0,j.oR)(c("common.copyFailed"),"error")}},[d,c]);return(0,e.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-[70%] h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground truncate",children:d?.name?`/${d.name}`:c("skills.previewTitle")}),(0,e.jsx)("button",{onClick:q,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:c("skills.copyPath"),children:(0,e.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),d?.path&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5",children:d.path})]}),(0,e.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,e.jsx)("button",{onClick:()=>p("preview"),className:`px-3 py-1 transition-colors ${"preview"===o?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:c("common.preview")}),(0,e.jsx)("button",{onClick:()=>p("source"),className:`px-3 py-1 transition-colors ${"source"===o?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:c("skills.source")})]}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors flex-shrink-0",title:c("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),m?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:c("common.loading")}):d&&d.valid?"preview"===o?(0,e.jsx)(h.M,{content:d.content,filePath:d.path,cwd:d.path.slice(0,Math.max(0,d.path.lastIndexOf("/"))),embedded:!0,onClose:b}):(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(i.XO,{content:d.content,filePath:d.path,className:"min-h-full"})}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:c("skills.cannotRead")})]})]})}[h,i]=k.then?(await k)():k,d()}catch(a){d(a)}})},2929:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{s:()=>W});var e=c(48249),f=c(67484),g=c(7833),h=c(44256),i=c(15273),j=c(14839),k=c(72419),l=c(44218),m=c(49681),n=c(21735),o=c(33740),p=c(55313),q=c(32616),r=c(1619),s=c(18812),t=c(59347),u=c(60251),v=c(85862),w=c(80983),x=c(69424),y=c(57632),z=c(18479),A=c(39247),B=c(60591),C=c(87808),D=c(39238),E=c(90031),F=c(13265),G=c(76306),H=c(5900),I=c(33281),J=c(36688),K=c(41224),L=c(44384),M=a([y,w,D,E,J]);async function N(a,b){if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");try{await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]);return}catch(b){if("image/png"===a.type)throw b}let c=await new Promise((a,c)=>{let d=new Image;d.onload=()=>{let b=document.createElement("canvas");b.width=d.naturalWidth,b.height=d.naturalHeight;let e=b.getContext("2d");e?(e.drawImage(d,0,0),b.toBlob(b=>{b?a(b):c(Error("Could not encode image"))},"image/png")):c(Error("Canvas is unavailable"))},d.onerror=()=>c(Error("Could not load image")),d.src=b});await navigator.clipboard.write([new ClipboardItem({"image/png":c})])}function O({image:a,onClose:b}){let{t:c}=(0,L.Bd)(),d=`data:${a.media_type};base64,${a.data}`,f=async b=>{b.stopPropagation();try{await N(function(a,b){let c=atob(a),d=new Uint8Array(c.length);for(let a=0;a<c.length;a+=1)d[a]=c.charCodeAt(a);return new Blob([d],{type:b})}(a.data,a.media_type),d),(0,g.oR)(c("chat.copiedImage"),"success")}catch{(0,g.oR)(c("common.copyFailed"),"error")}},j=(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,e.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:f,className:"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",title:c("chat.copyImage"),children:(0,e.jsx)(i.A,{className:"w-5 h-5"})}),(0,e.jsx)("button",{type:"button",onClick:b,className:"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",title:c("common.close"),children:(0,e.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("img",{src:d,alt:c("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]});return(0,e.jsx)(h.ZL,{children:j})}function P({filePath:a,onClose:b}){let{t:c}=(0,L.Bd)(),d=`/api/file?path=${encodeURIComponent(a)}&raw=true`,f=async b=>{b.stopPropagation();try{let b,e=await fetch(d);if(!e.ok)throw Error("Could not read image");let f=await e.blob(),h=f.type?f:new Blob([f],{type:(b=a.slice(a.lastIndexOf(".")).toLowerCase(),".jpg"===b||".jpeg"===b?"image/jpeg":".png"===b?"image/png":".gif"===b?"image/gif":".webp"===b?"image/webp":".svg"===b?"image/svg+xml":".bmp"===b?"image/bmp":".ico"===b?"image/x-icon":".avif"===b?"image/avif":"image/png")});await N(h,d),(0,g.oR)(c("chat.copiedImage"),"success")}catch{(0,g.oR)(c("common.copyFailed"),"error")}};return(0,e.jsx)(h.ZL,{children:(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,e.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:f,className:"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",title:c("chat.copyImage"),children:(0,e.jsx)(i.A,{className:"w-5 h-5"})}),(0,e.jsx)("button",{type:"button",onClick:b,className:"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",title:c("common.close"),children:(0,e.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("img",{src:d,alt:a.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]})})}function Q(a){let b=a.replace(/\/+$/,"");return b.startsWith("/private/")?b.slice(8):b}[y,w,D,E,J]=M.then?(await M)():M;let S=(0,f.memo)(function({text:a,isAside:b,isUser:c,isStreaming:d,onOpenFileLink:h,onPreviewFile:i,cwd:k}){let{t:l}=(0,L.Bd)(),m=(0,f.useMemo)(()=>{if(c||!h)return;let a=a=>{i&&((0,B.e$)(a)||(0,B.u)(a)||(0,B.Zy)(a))?i(a):(0,g.oR)(l("toast.fileOutsideProject"),"error")};return b=>{let c=function(a,b){let c;if(!a||a.startsWith("#")||/^[a-z][a-z0-9+.-]*:/i.test(a)&&!a.startsWith("file:"))return null;let d=a;try{d=decodeURIComponent(a)}catch{}d.startsWith("file://")&&(d=d.slice(7));let e=d.indexOf("#"),f=e>=0?d.slice(e+1):"",g=e>=0?d.slice(0,e):d,h=g.indexOf("?"),i=h>=0?g.slice(h+1):"";g=h>=0?g.slice(0,h):g;let j=f.match(/^L?(\d+)(?:-L?\d+)?$/i)?.[1],k=i.match(/(?:^|[&;])(?:line|L)=(\d+)(?:$|[&;])/i)?.[1],l=g.match(/:(\d+)(?::\d+)?$/),m=j||k||l?.[1];if(m&&(c=Number(m),l&&(g=g.slice(0,-l[0].length))),!(g=g.trim()))return null;let n=c&&c>0?{lineNumber:c}:{},o=b?Q(b):"";if(g.startsWith("/")){let a=Q(g);return o&&a===o?null:o&&a.startsWith(o+"/")?{rel:(0,B.WU)("",a.slice(o.length+1)),abs:null,...n}:{rel:(0,B.WU)("",a),abs:a,...n}}return g.startsWith("./")||g.startsWith("../")||g.includes("/")||/\.[A-Za-z0-9][A-Za-z0-9_-]*$/.test(g)?{rel:(0,B.WU)("",g),abs:null,...n}:null}(b,k);return!!c&&(c.abs?k?I.t4.runPromise((0,C.r6)(k,c.rel)).then(b=>{b.ok&&b.data?.exists?h({path:c.rel,...c.lineNumber?{lineNumber:c.lineNumber}:{}}):a(c.abs)}).catch(()=>a(c.abs)):a(c.abs):h({path:c.rel,...c.lineNumber?{lineNumber:c.lineNumber}:{}}),!0)}},[k,c,h,i,l]),n=(0,f.useMemo)(()=>{if(!c)return a=>{let b=(0,F.i)(a,window.location.origin);return b?((0,G.V)(b,a),!0):!!m&&m(a)}},[c,m]),o=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(H.T,{content:a,isUser:c,isStreaming:d,onLinkClick:n}),d&&(0,e.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]});return b?(0,e.jsxs)("div",{className:"flex gap-1.5 break-words opacity-65",children:[(0,e.jsx)(j.A,{className:"w-3 h-3 mt-[5px] shrink-0 text-muted-foreground","aria-hidden":!0}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:o})]}):(0,e.jsx)("div",{className:"break-words",children:o})}),T="28em",U=(0,f.memo)(function({children:a}){let{t:b}=(0,L.Bd)(),[c,d]=(0,f.useState)(!1),[g,h]=(0,f.useState)(!1),i=(0,f.useRef)(null),j=(0,f.useRef)(null),m=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(c)return;let a=j.current,b=m.current;if(!a||!b)return;let d=()=>h(a.scrollHeight>a.clientHeight+1);d();let e=new ResizeObserver(d);return e.observe(b),()=>e.disconnect()},[c]);let n=(0,f.useCallback)(()=>{if(!c)return void d(!0);let a=i.current?.closest("[data-message-id]")??i.current;d(!1),requestAnimationFrame(()=>{a&&a.getBoundingClientRect().top<0&&a.scrollIntoView({block:"start",behavior:"auto"})})},[c]);return(0,e.jsxs)("div",{ref:i,children:[(0,e.jsx)("div",{ref:j,className:c?void 0:"overflow-hidden",style:c?void 0:{maxHeight:T},children:(0,e.jsx)("div",{ref:m,children:a})}),g&&(0,e.jsxs)(e.Fragment,{children:[!c&&(0,e.jsx)("div",{className:"text-muted-foreground leading-none pt-1 select-none",children:"…"}),(0,e.jsxs)("button",{type:"button",onClick:n,className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[b(c?"chat.showLess":"chat.showMore"),c?(0,e.jsx)(k.A,{className:"w-3.5 h-3.5"}):(0,e.jsx)(l.A,{className:"w-3.5 h-3.5"})]})]})]})});function R({collapsible:a,children:b}){return a?(0,e.jsx)(U,{children:b}):(0,e.jsx)(e.Fragment,{children:b})}let V=new Map,W=(0,f.memo)(function({message:a,cwd:b,sessionId:c,onFork:d,onDeleteTurn:i,forkSupported:j=!0,onSendToPeer:k,peerSide:C,onApprovePlan:F,isLoading:G,onContentSearch:M,onShowFileDiff:N,onOpenFileLink:Q,disableOverlays:T=!1}){let U,W,X,Y,{t:Z,i18n:$}=(0,L.Bd)(),[_,aa]=(0,f.useState)(null),[ab,ac]=(0,f.useState)(()=>1===(a.toolCalls?.length||0)),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(!1),[ah,ai]=(0,f.useState)(!1),[aj,ak]=(0,f.useState)(!1),[al,am]=(0,f.useState)(!1),an=(0,f.useRef)(null),ao=(0,f.useRef)(null),ap="user"===a.role,aq=a.images&&a.images.length>0,ar=a.toolCalls?.length||0,as=!!c&&!!b&&!!d&&j,at=!!c&&!!b&&!!i;(0,f.useEffect)(()=>{if(!aj)return;let a=a=>{an.current?.contains(a.target)||ak(!1)},b=a=>{"Escape"===a.key&&(ak(!1),ao.current?.focus())};return document.addEventListener("pointerdown",a),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("keydown",b)}},[aj]);let au=(0,f.useMemo)(()=>a.toolCalls?.some(a=>(0,A.h)(a.name))||!1,[a.toolCalls]),av=(0,f.useMemo)(()=>{let b=a.parts;if(!b?.length)return a.content?[{text:a.content,isAside:!1}]:[];let c=-1;b.forEach((a,b)=>{"tool"===a.type&&(c=b)});let d=[];return b.forEach((a,b)=>{"text"===a.type&&d.push({text:a.text,isAside:b<c})}),d},[a.parts,a.content]),aw=(0,f.useMemo)(()=>(0,y.vP)([],a.toolCalls??[],b).length>0,[a.toolCalls,b]),[ax,ay]=(0,f.useState)(!1),az=aw||ax;(0,f.useEffect)(()=>{N&&a.toolCalls?.length&&N(a.id,a.toolCalls,b,c??void 0,!0)},[N,a.id,a.toolCalls,b,c]),(0,f.useEffect)(()=>{if(!au||aw||!b)return;let d=(a.toolCalls??[]).map(a=>a.id).filter(Boolean);if(0===d.length)return;let e=(a.toolCalls??[]).filter(a=>(0,A.h)(a.name)).map(a=>a.id),f=!1,g=null,h=0,i=()=>{I.t4.runPromiseExit((0,z.xK)(b,d,c??void 0)).then(a=>{if(f)return;let b="Success"===a._tag?a.value:[];if(b.length>0)return void ay(!0);let c=new Set(b.map(a=>a.toolId));e.some(a=>!c.has(a))&&h<2&&(h+=1,g=setTimeout(i,2e3))})};return i(),()=>{f=!0,g&&clearTimeout(g)}},[au,aw,b,c,a.toolCalls]);let aA=(0,f.useMemo)(()=>{if(!a.toolCalls)return null;for(let b=a.toolCalls.length-1;b>=0;b--)if("TodoWrite"===a.toolCalls[b].name)return a.toolCalls[b];return null},[a.toolCalls]),aB=(0,f.useMemo)(()=>a.toolCalls?a.toolCalls.filter(a=>"AskUserQuestion"===a.name):[],[a.toolCalls]),aC=(0,f.useMemo)(()=>{if(!a.toolCalls)return null;for(let b=a.toolCalls.length-1;b>=0;b--)if("ExitPlanMode"===a.toolCalls[b].name){let c=a.toolCalls[b].input?.plan;return"string"==typeof c&&c?c:null}return null},[a.toolCalls]),aD=(0,f.useMemo)(()=>a.toolCalls?.filter(a=>"ExitPlanMode"!==a.name)??[],[a.toolCalls]),aE=(0,f.useMemo)(()=>{if(!a.toolCalls)return[];let b=new Set,c=[];for(let d of a.toolCalls)if("Read"===d.name||"Edit"===d.name||"Write"===d.name){let a=d.input.file_path;a&&((0,B.e$)(a)||(0,B.aR)(a)||(0,B.u)(a)||(0,B.Zy)(a))&&!b.has(a)&&(b.add(a),c.push(a))}return c},[a.toolCalls]),aF=(0,f.useMemo)(()=>{if(!a.toolCalls)return[];let b=[];for(let c of a.toolCalls){let a=c.input?.thought;if(a&&"string"==typeof a){let d=a.match(/PREVIOUS:\s*(.*?)\s*→\s*THIS:\s*(.*?)\s*→\s*EXPECT:\s*(.*)/i);d?b.push({previous:d[1].trim(),current:d[2].trim(),expect:d[3].trim(),raw:a,toolName:c.name}):b.push({previous:"",current:a,expect:"",raw:a,toolName:c.name})}}return b},[a.toolCalls]),[aG,aH]=(0,f.useState)(null),[aI,aJ]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!aG||(0,B.u)(aG))return void queueMicrotask(()=>aJ(null));let a=!1;return I.t4.runPromiseExit((0,K.an)(aG)).then(b=>{a||("Success"===b._tag&&void 0!==b.value.content?aJ(b.value.content):((0,g.oR)(Z("toast.readFileFailed"),"error"),aH(null)))}),()=>{a=!0}},[aG,Z]);let aK=async()=>{if(at&&!G&&!al&&await (0,g.lJ)(Z("chat.deleteTurnConfirm",{defaultValue:"Delete this question, answer, and its tool records? This cannot be undone."}),{title:Z("chat.deleteTurn",{defaultValue:"Delete turn"}),confirmText:Z("chat.deleteTurnConfirmAction",{defaultValue:"Delete turn"}),danger:!0})){am(!0);try{await i(a.id)}finally{am(!1)}}},aL=!!C&&!!k&&!!a.content,aM=(0,f.useMemo)(()=>{var b;let c;if(!a.timestamp)return"";let d=new Date(a.timestamp);return isNaN(d.getTime())?"":(b=$.language,!(c=V.get(b))&&(c=new Intl.DateTimeFormat(b,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),V.set(b,c)),c).format(d)},[a.timestamp,$.language]);if("system"===a.role){let b=a.systemEvent,c=b?.kind==="task-notification"?"failed"===b.status?"⚠️":"stopped"===b.status?"⏹️":"\uD83D\uDD14":"ℹ️",d=b?.detail||a.content;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex justify-center my-2 px-2","data-role":"system",children:(0,e.jsxs)("button",{type:"button",onClick:()=>ai(!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:Z("chat.viewDetails",{defaultValue:"Click for details"}),children:[(0,e.jsx)("span",{className:"flex-shrink-0",children:c}),(0,e.jsx)("span",{className:"truncate",children:a.content})]})}),ah&&(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:()=>ai(!1),children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-4xl max-h-[80vh] rounded-lg flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm text-foreground flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:c}),b?.kind==="task-notification"?Z("chat.taskNotification",{defaultValue:"Task notification"}):Z("chat.systemNotice",{defaultValue:"Notice"})]}),(0,e.jsx)("button",{onClick:()=>ai(!1),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors",children:"✕"})]}),(0,e.jsx)("pre",{className:"flex-1 overflow-auto px-4 py-3 text-xs text-foreground whitespace-pre-wrap break-words",children:d})]})})})]})}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:`flex flex-col ${ap?"items-end":"items-start"} mb-4 group`,"data-role":a.role,children:[(0,e.jsx)("div",{className:`relative flex items-start ${ap?"justify-end":"justify-start"} w-full`,children:(0,e.jsxs)("div",{className:`chat-turn px-4 py-2 text-foreground ${ap?"max-w-[80%] bg-muted rounded-2xl rounded-br-md border border-brand/40":"w-full"}`,children:[aq&&(0,e.jsx)("div",{className:`flex flex-wrap gap-2 ${a.content?"mb-2":""}`,children:a.images.map((a,b)=>(0,e.jsx)("div",{className:`relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 ${T?"":"cursor-pointer hover:opacity-90 transition-opacity"}`,onClick:T?void 0:()=>aa(a),children:(0,e.jsx)("img",{src:`data:${a.media_type};base64,${a.data}`,alt:Z("chat.imageN",{index:b+1}),className:"w-full h-full object-cover"})},b))}),av.length>0&&(0,e.jsx)(R,{collapsible:ap,children:(0,e.jsx)("div",{className:"space-y-3",children:av.map((c,d)=>(0,e.jsx)(S,{text:c.text,isAside:c.isAside,isUser:ap,isStreaming:!!a.isStreaming&&d===av.length-1,onOpenFileLink:Q,onPreviewFile:aH,cwd:b},d))})}),aA&&(U=aA.input?.todos,X=(W=Array.isArray(U)?U:[]).filter(a=>"completed"===a.status).length,Y=W.length,(0,e.jsx)("div",{className:`${a.content||aq?"mt-2":""}`,children:(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,e.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${Y>0?X/Y*100:0}%`}})}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[X,"/",Y]})]}),W.map((a,b)=>(0,e.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===a.status?"opacity-50":""}`,children:["completed"===a.status?(0,e.jsx)(m.A,{className:"w-3 h-3 text-green-11 flex-shrink-0"}):"in_progress"===a.status?(0,e.jsx)(n.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,e.jsx)(o.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,e.jsx)("span",{className:`text-xs truncate ${"completed"===a.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===a.status&&a.activeForm?a.activeForm:a.content})]},b))]})})),aC&&(0,e.jsx)("div",{className:`${a.content||aq||aA?"mt-2":""}`,children:(0,e.jsxs)("div",{className:"border border-brand/40 rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-border bg-brand/10",children:[(0,e.jsx)("span",{className:"text-sm",children:"\uD83D\uDCCB"}),(0,e.jsx)("span",{className:"text-xs font-medium text-foreground",children:Z("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,e.jsx)("div",{className:"px-3 py-2",children:(0,e.jsx)(H.T,{content:aC,isUser:!1})}),F&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:Z("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,e.jsxs)("button",{onClick:()=>F(),disabled:G,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,e.jsx)("span",{children:"✓"}),(0,e.jsx)("span",{children:Z("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),aE.length>0&&(0,e.jsx)("div",{className:`${a.content||aq||aA?"mt-2":""}`,children:(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-0.5",children:aE.map(a=>(0,e.jsxs)("button",{disabled:T,onClick:()=>aH(a),className:"flex items-center gap-1.5 w-full text-left rounded px-1 py-0.5 group/md transition-colors enabled:hover:bg-hover disabled:cursor-default",children:[(0,B.u)(a)?(0,e.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,e.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,e.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4-4 3 3 4-4 5 5"})]}):(0,B.Zy)(a)?(0,e.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,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm0 4h16M10 10v10"})}):(0,B.aR)(a)?(0,e.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,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}):(0,e.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,e.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,e.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:a.split("/").pop()})]},a))})}),aF.length>0&&(0,e.jsx)("div",{className:`${a.content||aq||aA||aE.length>0?"mt-2":""}`,children:(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-border text-muted-foreground",children:[(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium w-[60px]",children:"Tool"}),(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Previous"}),(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Action"}),(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Expect"})]})}),(0,e.jsx)("tbody",{children:aF.map((a,b)=>(0,e.jsxs)("tr",{className:b<aF.length-1?"border-b border-border/50":"",children:[(0,e.jsx)("td",{className:"px-2 py-1 text-muted-foreground font-mono",children:a.toolName}),(0,e.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:a.previous||"—"}),(0,e.jsx)("td",{className:"px-2 py-1 text-foreground",children:a.current}),(0,e.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:a.expect||"—"})]},b))})]})})}),aD.length>0&&(0,e.jsx)("div",{className:`${a.content||aq?"mt-3":""}`,children:ar>0?(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsxs)("button",{onClick:()=>ac(!ab),className:"flex-1 px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors active:bg-muted",children:[(0,e.jsx)("span",{className:"text-sm",children:"\uD83D\uDD27"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:Z("chat.toolCalls",{count:aD.length})}),(0,e.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:ab?Z("chat.collapse"):Z("chat.expand")})]}),!T&&aB.length>0&&(0,e.jsx)("button",{onClick:()=>ag(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:Z("chat.viewQuestions"),children:(0,e.jsx)(p.A,{className:"w-4 h-4"})}),!T&&az&&(0,e.jsx)("button",{onClick:()=>{N&&a.toolCalls?N(a.id,a.toolCalls,b,c??void 0):ae(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:Z("chat.viewAllFileChanges"),children:(0,e.jsx)(q.A,{className:"w-4 h-4"})})]}),ab&&(0,e.jsx)("div",{className:"border-t border-line-1",children:aD.map((a,d)=>(0,e.jsx)(w.K,{toolCall:a,cwd:b,sessionId:c,disableOverlays:T},`${a.id}-${d}`))})]}):aD.map((a,d)=>(0,e.jsx)(w.K,{toolCall:a,cwd:b,sessionId:c,disableOverlays:T},`${a.id}-${d}`))})]})}),(aM||a.content||as||at)&&(0,e.jsxs)("div",{className:`flex items-center gap-1 mt-0.5 px-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity ${ap?"flex-row-reverse":""}`,children:[a.content&&(0,e.jsx)("button",{onClick:()=>{a.content&&(navigator.clipboard.writeText(a.content),(0,g.oR)(Z("toast.copiedMessage")))},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:Z("chat.copyMessage"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})}),as&&(0,e.jsxs)("div",{ref:an,className:"relative",children:[(0,e.jsxs)("button",{ref:ao,type:"button",onClick:()=>ak(a=>!a),className:"flex items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-hover hover:text-foreground","aria-expanded":aj,title:Z("chat.newSession"),children:[(0,e.jsx)(r.A,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{children:Z("chat.newSession")}),(0,e.jsx)(l.A,{className:`h-3 w-3 transition-transform ${aj?"rotate-180":""}`})]}),aj&&(0,e.jsxs)("div",{role:"group","aria-label":Z("chat.newSession"),className:`absolute bottom-full z-50 mb-1 w-56 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lv2 ${ap?"right-0":"left-0"}`,children:[(0,e.jsxs)("button",{type:"button",onClick:()=>{as&&(ak(!1),d(a.id,"prefix"))},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-hover focus-visible:bg-hover focus-visible:outline-none",children:[(0,e.jsx)(r.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block text-xs font-medium",children:Z("chat.continueFromHere")}),(0,e.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:Z("chat.continueFromHereDesc")})]})]}),(0,e.jsxs)("button",{type:"button",onClick:()=>{as&&(ak(!1),d(a.id,"single"))},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-hover focus-visible:bg-hover focus-visible:outline-none",children:[(0,e.jsx)(s.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block text-xs font-medium",children:Z("chat.onlyThisTurn")}),(0,e.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:Z("chat.onlyThisTurnDesc")})]})]})]})]}),at&&(0,e.jsxs)("button",{type:"button",onClick:aK,disabled:G||al,className:"flex items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-red-3 hover:text-red-11 disabled:cursor-not-allowed disabled:opacity-40",title:G?Z("chat.deleteTurnWhileRunning"):Z("chat.deleteTurn"),children:[(0,e.jsx)(t.A,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{children:al?Z("chat.deletingTurn"):Z("chat.deleteTurn")})]}),aL&&(0,e.jsx)("button",{onClick:()=>{aL&&k(a.content)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:Z("chat.sendToPeerPane"),children:"right"===C?(0,e.jsx)(u.A,{className:"w-4 h-4"}):(0,e.jsx)(v.A,{className:"w-4 h-4"})}),aM&&(0,e.jsx)("span",{className:"text-[11px] text-muted-foreground mx-1",children:aM})]})]}),_&&(0,e.jsx)(O,{image:_,onClose:()=>aa(null)}),ad&&a.toolCalls&&(0,e.jsx)(y.zB,{toolCalls:a.toolCalls,cwd:b,sessionId:c??void 0,onClose:()=>ae(!1),onContentSearch:M}),af&&aB.length>0&&(0,e.jsx)(x.$,{toolCalls:aB,onClose:()=>ag(!1)}),aG&&(0,B.u)(aG)&&(0,e.jsx)(P,{filePath:aG,onClose:()=>aH(null)}),aG&&!(0,B.u)(aG)&&null!==aI&&((0,B.aR)(aG)?(0,e.jsx)(D.N,{filePath:aG,content:aI,cwd:b,onClose:()=>aH(null),onContentSearch:M}):(0,B.Zy)(aG)?(0,e.jsx)(E.s,{filePath:aG,content:aI,onClose:()=>aH(null)}):(0,e.jsx)(J.x,{filePath:aG,content:aI,cwd:b||"",onClose:()=>aH(null)}))]})});d()}catch(a){d(a)}})},3033:(a,b,c)=>{"use strict";c.d(b,{w:()=>r});var d=c(48249),e=c(67484),f=c(44384);c(33281);var g=c(83768),h=c(57063);c(41224);let i={"claude-fable-5-1":{input:10,output:50,cacheRead:.25,cacheWrite:12.5},"claude-mythos-5-1":{input:10,output:50,cacheRead:.25,cacheWrite:12.5},"claude-fable-5":{input:10,output:50,cacheRead:1,cacheWrite:12.5},"claude-mythos-5":{input:10,output:50,cacheRead:1,cacheWrite:12.5},"claude-opus-5":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-8":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-7":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-6":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-5":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-sonnet-5":{input:2,output:10,cacheRead:.2,cacheWrite:2.5},"claude-sonnet-4-6":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-sonnet-4-5":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-haiku-4-5":{input:1,output:5,cacheRead:.1,cacheWrite:1.25}},j={input:3,output:15,cacheRead:.3,cacheWrite:3.75};function k(a){return a.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/(\d)-(?=\d)/g,"$1.").replace(/-/g," ").replace(/\b\w/g,a=>a.toUpperCase())}let l={light:["#2a78d6","#eb6834","#1baf7a","#eda100","#e87ba4","#008300","#4a3aa7","#e34948"],dark:["#3987e5","#d95926","#199e70","#c98500","#d55181","#008300","#9085e9","#e66767"]},m={light:{messages:"#2a78d6",toolCalls:"#1baf7a",messagesRgb:"42, 120, 214"},dark:{messages:"#3987e5",toolCalls:"#199e70",messagesRgb:"57, 135, 229"}};function n(a){return a>=1e9?`${(a/1e9).toFixed(1)}B`:a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function o(a){return a>=1e3?`$${a.toFixed(0)}`:a>=100?`$${a.toFixed(1)}`:`$${a.toFixed(2)}`}function p({data:a,height:b=200,formatValue:c=n}){let f=(0,e.useRef)(null),g=(0,e.useRef)(null),[h,i]=(0,e.useState)(null),j=(0,e.useRef)([]);(0,e.useCallback)(()=>{let d=f.current,e=g.current;if(!d||!e)return;let h=window.devicePixelRatio||1,i=e.getBoundingClientRect().width;d.width=i*h,d.height=b*h,d.style.width=`${i}px`,d.style.height=`${b}px`;let k=d.getContext("2d");k.scale(h,h),k.clearRect(0,0,i,b);let{labels:l,datasets:m}=a;if(0===l.length)return;let n=i-50-12,o=b-8-28,p=function(a){if(a<=0)return 1;let b=Math.pow(10,Math.floor(Math.log10(a))),c=a/b;return c<=1?b:c<=2?2*b:c<=5?5*b:10*b}(Math.max(1,...l.map((a,b)=>m.reduce((a,c)=>a+c.data[b],0))));k.fillStyle=getComputedStyle(d).getPropertyValue("color")||"#888",k.font="10px ui-monospace, monospace",k.textAlign="right",k.textBaseline="middle";for(let a=0;a<=4;a++){var q;let b=p/4*a,e=8+o-b/p*o;k.fillText(c(b),44,e),k.strokeStyle=(q="--line-2",getComputedStyle(d).getPropertyValue(q).trim()||"#333"),k.lineWidth=.5,k.beginPath(),k.moveTo(50,e),k.lineTo(50+n,e),k.stroke()}let r=n/l.length,s=Math.max(4,Math.min(.6*r,32)),t=[];l.forEach((a,b)=>{let c=50+b*r+(r-s)/2,e=0;m.forEach(d=>{var f,g,h,i,j,l;let m=d.data[b];if(m<=0)return;let n=Math.max(1,m/p*o),q=8+o-e-n;k.fillStyle=d.color,f=k,g=c,h=q,i=s,l=2,(j=n)<1||(l=Math.min(l,j/2,i/2),f.beginPath(),f.moveTo(g+l,h),f.lineTo(g+i-l,h),f.quadraticCurveTo(g+i,h,g+i,h+l),f.lineTo(g+i,h+j-l),f.quadraticCurveTo(g+i,h+j,g+i-l,h+j),f.lineTo(g+l,h+j),f.quadraticCurveTo(g,h+j,g,h+j-l),f.lineTo(g,h+l),f.quadraticCurveTo(g,h,g+l,h),f.fill()),t.push({x:c,y:q,w:s,h:n,label:a,value:m,dataset:d.label,color:d.color}),e+=n}),k.fillStyle=getComputedStyle(d).getPropertyValue("color")||"#888",k.font="9px ui-monospace, monospace",k.textAlign="center",k.textBaseline="top",b%(l.length>20?Math.ceil(l.length/15):1)==0&&k.fillText(a,c+s/2,8+o+6)}),j.current=t},[a,b,c]);let k=(0,e.useCallback)(a=>{let b=f.current?.getBoundingClientRect();if(!b)return;let d=a.clientX-b.left,e=a.clientY-b.top,g=j.current.find(a=>d>=a.x&&d<=a.x+a.w&&e>=a.y&&e<=a.y+a.h);g?i({x:a.clientX-b.left,y:g.y-4,content:`${g.dataset}: ${c(g.value)}`}):i(null)},[c]);return(0,d.jsxs)("div",{ref:g,className:"relative w-full text-muted-foreground",children:[(0,d.jsx)("canvas",{ref:f,className:"w-full",style:{height:b},onMouseMove:k,onMouseLeave:()=>i(null)}),h&&(0,d.jsx)("div",{className:"absolute pointer-events-none bg-popover text-popover-foreground text-[10px] px-2 py-1 rounded shadow-lv2 border border-border whitespace-nowrap z-10",style:{left:h.x,top:h.y,transform:"translate(-50%, -100%)"},children:h.content})]})}function q({hourCounts:a}){let{t:b}=(0,f.Bd)(),{resolvedTheme:c}=(0,g.DP)(),e=m[c],h=Math.max(1,...Object.values(a)),i=Array.from({length:24},(a,b)=>b);return(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:b("tokenStats.activeHours")}),(0,d.jsx)("div",{className:"flex gap-[2px] items-end h-16",children:i.map(c=>{let f=a[String(c)]||0,g=f/h;return(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-0.5",title:b("tokenStats.hourSessions",{h:c,count:f}),children:[(0,d.jsx)("div",{className:"w-full rounded-sm transition-all",style:{height:`${Math.max(2,48*g)}px`,backgroundColor:g>0?`rgba(${e.messagesRgb}, ${.2+.8*g})`:"var(--muted)"}}),c%3==0&&(0,d.jsx)("span",{className:"text-[8px] text-muted-foreground",children:c})]},c)})})]})}function r({isOpen:a,onClose:b}){var c;let t,u,{t:v}=(0,f.Bd)(),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(!0),[A,B]=(0,e.useState)("day"),[C,D]=(0,e.useState)("tokens"),[E,F]=(0,e.useState)(null),{resolvedTheme:G}=(0,g.DP)(),H=(0,e.useMemo)(()=>{var a;let b,c,d=Object.keys(w?.modelUsage||{}).filter(a=>!a.startsWith("<")),e=new Map;for(let a of w?.dailyModelTokens||[])for(let[b,c]of Object.entries(a.tokensByModel)){let d=e.get(b);c>0&&(!d||a.date<d)&&e.set(b,a.date)}return a=[...d].sort((a,b)=>(e.get(a)??"￿").localeCompare(e.get(b)??"￿")||a.localeCompare(b)),b=l[G],c={},a.forEach((a,d)=>{c[a]=b[d%b.length]}),c},[w,G]),I=(0,e.useMemo)(()=>w?.modelUsage?Object.entries(w.modelUsage).filter(([a])=>!a.startsWith("<")).map(([a,b])=>{let c;return{id:a,label:k(a),color:H[a],usage:b,cost:(c=function(a){let b=a.replace(/-\d{8}$/,""),c=i[b];if(c)return c;let d=b.toLowerCase();return d.includes("fable")||d.includes("mythos")?{input:10,output:50,cacheRead:1,cacheWrite:12.5}:d.includes("opus")?{input:5,output:25,cacheRead:.5,cacheWrite:6.25}:d.includes("haiku")?{input:1,output:5,cacheRead:.1,cacheWrite:1.25}:j}(a),b.inputTokens/1e6*c.input+b.outputTokens/1e6*c.output+b.cacheReadInputTokens/1e6*c.cacheRead+b.cacheCreationInputTokens/1e6*c.cacheWrite),totalTokens:b.inputTokens+b.outputTokens+b.cacheReadInputTokens+b.cacheCreationInputTokens}}).sort((a,b)=>b.cost-a.cost):[],[w,H]),J=(0,e.useMemo)(()=>I.reduce((a,b)=>a+b.cost,0),[I]),K=(0,e.useMemo)(()=>I.map(a=>a.id),[I]),L=(0,e.useMemo)(()=>{let a={};for(let b of I)a[b.id]=b.totalTokens>0?b.cost/b.totalTokens:0;return a},[I]),{activityChart:M,tokenChart:N,costChart:O}=(0,e.useMemo)(()=>{let a=w?.dailyActivity||[],b=w?.dailyModelTokens||[];if("day"===A){let c=a.slice(-60),d=b.slice(-60),e={labels:c.map(a=>a.date.slice(5)),datasets:[{label:v("tokenStats.messages"),data:c.map(a=>a.messageCount),color:m[G].messages},{label:v("tokenStats.toolCalls"),data:c.map(a=>a.toolCallCount),color:m[G].toolCalls}]},f=d.map(a=>a.date.slice(5));return{activityChart:e,tokenChart:{labels:f,datasets:K.map(a=>({id:a,label:k(a),data:d.map(b=>b.tokensByModel[a]||0),color:H[a]}))},costChart:{labels:f,datasets:K.map(a=>({id:a,label:k(a),data:d.map(b=>(b.tokensByModel[a]||0)*(L[a]||0)),color:H[a]}))}}}if("week"===A){let c=function(a,b){let c=new Map;for(let b of a){let a=new Date(b.date),d=new Date(a);d.setDate(a.getDate()-a.getDay());let e=d.toISOString().slice(0,10),f=e.slice(5);c.has(e)||c.set(e,{label:f,messages:0,sessions:0,tools:0,tokensByModel:{}});let g=c.get(e);g.messages+=b.messageCount,g.sessions+=b.sessionCount,g.tools+=b.toolCallCount}for(let a of b){let b=new Date(a.date),d=new Date(b);d.setDate(b.getDate()-b.getDay());let e=d.toISOString().slice(0,10);c.has(e)||c.set(e,{label:e.slice(5),messages:0,sessions:0,tools:0,tokensByModel:{}});let f=c.get(e);for(let[b,c]of Object.entries(a.tokensByModel))f.tokensByModel[b]=(f.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:v("tokenStats.messages"),data:c.map(a=>a.messages),color:m[G].messages},{label:v("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:m[G].toolCalls}]};return{activityChart:e,tokenChart:{labels:d,datasets:K.map(a=>({id:a,label:k(a),data:c.map(b=>b.tokensByModel[a]||0),color:H[a]}))},costChart:{labels:d,datasets:K.map(a=>({id:a,label:k(a),data:c.map(b=>(b.tokensByModel[a]||0)*(L[a]||0)),color:H[a]}))}}}let c=function(a,b){let c=new Map;for(let b of a){let a=b.date.slice(0,7);c.has(a)||c.set(a,{label:a,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(a);d.messages+=b.messageCount,d.sessions+=b.sessionCount,d.tools+=b.toolCallCount}for(let a of b){let b=a.date.slice(0,7);c.has(b)||c.set(b,{label:b,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(b);for(let[b,c]of Object.entries(a.tokensByModel))d.tokensByModel[b]=(d.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:v("tokenStats.messages"),data:c.map(a=>a.messages),color:m[G].messages},{label:v("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:m[G].toolCalls}]};return{activityChart:e,tokenChart:{labels:d,datasets:K.map(a=>({id:a,label:k(a),data:c.map(b=>b.tokensByModel[a]||0),color:H[a]}))},costChart:{labels:d,datasets:K.map(a=>({id:a,label:k(a),data:c.map(b=>(b.tokensByModel[a]||0)*(L[a]||0)),color:H[a]}))}}},[w,A,K,L,H,v]),P=E&&H[E]?E:null,Q=(0,e.useMemo)(()=>{let a="tokens"===C?N:O;return P?{...a,datasets:a.datasets.filter(a=>a.id===P)}:a},[N,O,C,P]);if((0,h.E)(b,a),!a)return null;let R=[{key:"day",label:v("tokenStats.day")},{key:"week",label:v("tokenStats.week")},{key:"month",label:v("tokenStats.month")}];return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:"relative bg-card rounded-xl shadow-lv3 w-full max-w-4xl mx-4 max-h-[90vh] flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-6 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:v("tokenStats.title")}),(0,d.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:R.map(a=>(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${A===a.key?"bg-background text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,onClick:()=>B(a.key),children:a.label},a.key))})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-6",children:y?(0,d.jsx)("div",{className:"text-center text-muted-foreground py-12",children:v("common.loading")}):w?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,d.jsx)(s,{label:v("tokenStats.totalSessions"),value:String(w.totalSessions??0)}),(0,d.jsx)(s,{label:v("tokenStats.totalMessages"),value:n(w.totalMessages??0)}),(0,d.jsx)(s,{label:v("tokenStats.equivalentApiCost"),value:o(J),highlight:!0}),(0,d.jsx)(s,{label:v("tokenStats.longestSession"),value:w.longestSession?(t=Math.floor((c=w.longestSession.duration)/36e5),u=Math.floor(c%36e5/6e4),t>0?`${t}h ${u}m`:`${u}m`):"-"}),(0,d.jsx)(s,{label:v("tokenStats.firstUse"),value:w.firstSessionDate?w.firstSessionDate.slice(0,10):"-"})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:v("tokenStats.activityTrend")}),(0,d.jsxs)("div",{className:"flex items-center gap-3 text-[10px]",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:m[G].messages}}),v("tokenStats.messages")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:m[G].toolCalls}}),v("tokenStats.toolCalls")]})]})]}),(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(p,{data:M,height:180})})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:v("tokenStats.byModel")}),(0,d.jsxs)("div",{className:"flex bg-muted rounded-md p-0.5",children:[(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"tokens"===C?"bg-background text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,onClick:()=>D("tokens"),children:v("tokenStats.tokenUsage")}),(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"cost"===C?"bg-background text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,onClick:()=>D("cost"),children:v("tokenStats.equivalentCost")})]})]}),(0,d.jsx)("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:I.map(a=>(0,d.jsxs)("button",{onClick:()=>F(P===a.id?null:a.id),className:`flex items-center gap-1 rounded-sm transition-opacity hover:opacity-100 ${P&&P!==a.id?"opacity-40":""}`,children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:a.color}}),a.label]},a.id))})]}),(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(p,{data:Q,height:180,formatValue:"tokens"===C?n:o})})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:v("tokenStats.modelCostDetail")}),(0,d.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,d.jsxs)("table",{className:"w-full text-xs",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"bg-muted/50 text-muted-foreground",children:[(0,d.jsx)("th",{className:"text-left px-3 py-2 font-medium",children:v("tokenStats.model")}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Input"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Output"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Read"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Write"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:v("tokenStats.share")}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:v("tokenStats.equivalentCost")})]})}),(0,d.jsxs)("tbody",{children:[I.map(a=>(0,d.jsxs)("tr",{className:"border-t border-border",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a.color}}),a.label]})}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(a.usage.inputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(a.usage.outputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(a.usage.cacheReadInputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(a.usage.cacheCreationInputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:J>0?`${(a.cost/J*100).toFixed(1)}%`:"-"}),(0,d.jsx)("td",{className:"px-3 py-2 text-right font-medium text-foreground",children:o(a.cost)})]},a.id)),(0,d.jsxs)("tr",{className:"border-t-2 border-border bg-muted/30",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-medium text-foreground",children:v("tokenStats.total")}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(I.reduce((a,b)=>a+b.usage.inputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(I.reduce((a,b)=>a+b.usage.outputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(I.reduce((a,b)=>a+b.usage.cacheReadInputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:n(I.reduce((a,b)=>a+b.usage.cacheCreationInputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:"100%"}),(0,d.jsx)("td",{className:"px-3 py-2 text-right font-bold text-foreground",children:o(J)})]})]})]})})]}),w.hourCounts&&Object.keys(w.hourCounts).length>0&&(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(q,{hourCounts:w.hourCounts})})]}):(0,d.jsx)("div",{className:"text-center text-muted-foreground py-12",children:v("tokenStats.notFound")})})]})]})}function s({label:a,value:b,highlight:c}){return(0,d.jsxs)("div",{className:"bg-muted/30 rounded-lg px-3 py-2.5",children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:a}),(0,d.jsx)("div",{className:`text-sm font-semibold mt-0.5 ${c?"text-brand":"text-foreground"}`,children:b})]})}},3588:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabBar:()=>o});var e=c(48249),f=c(67484),g=c(40311),h=c(63565),i=c(32753),j=c(72529),k=c(44256),l=c(44384);function m({number:a,status:b,statusLabel:c,isActive:d,pinned:f}){let h="normal"!==b?(0,g.c)(b,d):f?"border-transparent bg-amber-9 text-black/80":d?"border-transparent bg-brand/25 text-brand":"border-transparent bg-muted-foreground/25 text-foreground/75";return(0,e.jsx)("span",{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border font-mono text-[9px] font-medium leading-none tabular-nums transition-colors ${h}`,role:"normal"!==b?"status":void 0,"aria-label":c,"aria-hidden":"normal"===b?"true":void 0,children:a})}function n({onNewTab:a,onNewCodexTab:b,onNewKimiTab:c,onNewGlmTab:d,onNewOllamaTab:g,onNewDeepseekTab:i}){let[j,l]=(0,f.useState)(!1),m=(0,f.useRef)(null),o=(0,f.useRef)(null),[p,q]=(0,f.useState)({top:0,right:0}),r=(0,k.F2)();return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{ref:m,onClick:()=>{if(!j&&m.current){let a=m.current.getBoundingClientRect(),b=r?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0,e=b?.width??window.innerWidth;q({top:a.bottom+4-d,right:e-(a.right-c)})}l(a=>!a)},className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:"New tab",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),j&&(0,e.jsx)(k.ZL,{children:(0,e.jsx)("div",{ref:o,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lv2 py-1 min-w-[140px]",style:{top:p.top,right:p.right},children:h.CX.map(f=>(0,e.jsxs)("button",{onClick:()=>{l(!1),"codex"===f?b?.():"kimi"===f?c?.():"glm"===f?d?.():"ollama"===f?g?.():"deepseek"===f?i?.():a()},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,e.jsx)(h.eV,{engine:f,className:"h-3.5 w-3.5"}),h.H[f]]},f))})})]})}function o({tabs:a,selectedTabId:b,unreadTabs:c,globalLoadingTabs:d,dragTabIndex:f,dragOverTabIndex:g,isPinned:h,onSwitchTab:k,onCloseTab:p,onCloseAllTabs:q,onNewTab:r,onNewCodexTab:s,onNewKimiTab:t,onNewGlmTab:u,onNewOllamaTab:v,onNewDeepseekTab:w,onOpenProjectSessions:x,onDragStart:y,onDragOver:z,onDrop:A,onDragEnd:B,sideBySide:C,onToggleSideBySide:D}){let{t:E}=(0,l.Bd)();return(0,e.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,e.jsxs)("div",{className:"flex items-center px-2 gap-1 overflow-x-auto",children:[a.map((a,l)=>{let n=a.id===b,o=h?.(a.id)??!1,q=a.isLoading||d.has(a.id)?"loading":c.has(a.id)&&!n?"unread":"normal";return(0,e.jsx)(j.m,{content:a.title,delay:200,className:"flex-1 min-w-16 max-w-[260px]",children:(0,e.jsxs)("div",{draggable:!0,onDragStart:()=>y(l),onDragOver:a=>z(a,l),onDrop:()=>A(l),onDragEnd:B,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg border-t-[1.5px] transition-colors ${n?"border-brand bg-slate-4 text-foreground font-medium":"border-transparent text-muted-foreground hover:bg-secondary/50"} ${f===l?"opacity-50":""} ${g===l?"border-l-2 border-brand":""}`,onClick:()=>k(a.id),children:[(0,e.jsx)("div",{className:"h-4 w-4 -translate-x-1 flex-shrink-0",children:(0,e.jsx)(m,{number:l+1,status:q,statusLabel:"loading"===q?E("sessions.running"):"unread"===q?E("sessions.done"):void 0,isActive:n,pinned:o})}),(0,e.jsx)("span",{className:"flex-1 min-w-0 truncate",children:a.title}),(0,e.jsxs)("span",{className:"relative ml-1 h-4 w-4 translate-x-1 shrink-0",children:[(0,e.jsx)("span",{className:"absolute inset-0 inline-flex items-center justify-center transition-opacity group-hover:opacity-0 group-focus-within:opacity-0",children:(0,e.jsx)(i.S,{engine:a.engine,size:"sm"})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),p(a.id)},className:"absolute inset-0 flex items-center justify-center rounded opacity-0 transition-opacity hover:bg-muted group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","data-tooltip":E("tabBar.closeTab"),"aria-label":E("tabBar.closeTab"),children:(0,e.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),(0,e.jsx)(n,{onNewTab:r,onNewCodexTab:s,onNewKimiTab:t,onNewGlmTab:u,onNewOllamaTab:v,onNewDeepseekTab:w}),q&&(0,e.jsx)("button",{onClick:q,className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-destructive hover:bg-hover rounded transition-colors",title:E("tabBar.closeAll"),"aria-label":E("tabBar.closeAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),x&&(0,e.jsx)("button",{onClick:x,className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:E("sessions.projectSessions"),"aria-label":E("sessions.projectSessions"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),D&&(0,e.jsx)("button",{onClick:D,className:"flex-shrink-0 p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:C?E("chat.singlePane"):E("chat.splitPane"),"aria-label":C?E("chat.singlePane"):E("chat.splitPane"),"aria-pressed":C,children:(0,e.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",strokeWidth:2}),!C&&(0,e.jsx)("path",{strokeWidth:2,d:"M12 4v16"})]})})]})})}d()}catch(a){d(a)}})},4263:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>g});var e=c(12629),f=a([e]);e=(f.then?(await f)():f)[0];let h="/tree-sitter",i=null,j=new Map;async function g(a){let b,c=await (!(b=j.get(a))&&(b=(async()=>(await (!i&&(i=e.Parser.init({locateFile:a=>`${h}/${a}`})),i),e.Language.load(`${h}/tree-sitter-${a}.wasm`)))(),j.set(a,b)),b),d=new e.Parser;return d.setLanguage(c),d}d()}catch(a){d(a)}})},4325:(a,b,c)=>{"use strict";c.d(b,{$2:()=>u,N4:()=>k,_I:()=>t,fX:()=>l,fZ:()=>m});let d="cockpit update",e={visible:!1,stage:"preparing",startedAt:0,baselineMs:null,installedVersion:null,upToDate:!1,error:null,rolledBack:!1,fixCommand:d,logPath:null,live:!1},f="cockpit:update-seen-at",g=e,h=new Set,i=!1;function j(a){g={...g,...a},h.forEach(a=>a())}function k(a){return h.add(a),()=>h.delete(a)}function l(){return g}function m(){try{window.localStorage.setItem(f,String(Date.now()))}catch{}j({visible:!1})}let n=a=>new Promise(b=>setTimeout(b,a));async function o(){try{let a=await fetch("/api/health",{cache:"no-store",signal:AbortSignal.timeout(2e3)});if(!a.ok)return null;let b=await a.json();return{pid:"number"==typeof b.pid?b.pid:null,version:b.version??null}}catch{return null}}async function p(){try{let a=await fetch("/api/update-state",{cache:"no-store",signal:AbortSignal.timeout(2e3)});if(!a.ok)return{state:null,logPath:null};let b=await a.json();return{state:b.state??null,logPath:b.logPath??null}}catch{return{state:null,logPath:null}}}async function q(a){try{let b=await fetch(`http://127.0.0.1:${a}/`,{cache:"no-store",signal:AbortSignal.timeout(1500)});if(!b.ok)return null;return await b.json()}catch{return null}}function r(a){switch(a){case"installing":return"installing";case"repairing":return"repairing";case"rolling-back":return"rolling-back";case"restarting":case"done":return"restarting";default:return"preparing"}}function s(a,b={}){j({stage:"failed",error:a,...b})}async function t(){if(!i){i=!0,j({...e,visible:!0,stage:"preparing",startedAt:Date.now()});try{let a=await p();j({baselineMs:a.state?.installMs??a.state?.prevInstallMs??null,logPath:a.logPath});let b=await o(),c=b?.pid??null,e=b?.version??null,f=await fetch("/api/update",{method:"POST"});if(!f.ok){let a=await f.json().catch(()=>({}));s(a.error??`HTTP ${f.status}`);return}let h=await f.json().catch(()=>({})),i=h.statusPort??null;j({logPath:h.logPath??g.logPath});let k=0,l=null!==i,m=Date.now()+3e5;for(;Date.now()<m;){if(await n(1e3),l&&null!==i){let a=await q(i);if(a){if(k=0,j({live:!0}),"failed"===a.phase)return void s(a.error??"install failed",{rolledBack:!0===a.rolledBack,fixCommand:a.fixCommand??d,live:!0});j({stage:r(a.phase),installedVersion:a.installed??g.installedVersion,baselineMs:g.baselineMs??a.prevInstallMs??null})}else++k>=3&&(l=!1,j({live:!1}))}let a=await o();if(a?.pid!=null&&(null===c||a.pid!==c)){let{state:b}=await p();if(b?.phase==="failed")return void s(b.error??"update failed",{rolledBack:!0===b.rolledBack,fixCommand:b.fixCommand??d});let c=a.version??g.installedVersion;j({stage:"done",installedVersion:c,upToDate:null!==c&&c===e});return}}s("timeout")}catch(a){s(a instanceof Error?a.message:String(a))}finally{i=!1}}}async function u(){if(i||g.visible)return;let{state:a,logPath:b}=await p();if(!a?.phase||"done"===a.phase)return;let c=a.startedAt??0,h=a.installMs??a.prevInstallMs??null;if("failed"===a.phase){let g=0;try{g=Number(window.localStorage.getItem(f))||0}catch{}if((a.finishedAt??0)<=g)return;j({...e,visible:!0,stage:"failed",startedAt:c,baselineMs:h,error:a.error??"unknown error",rolledBack:!0===a.rolledBack,fixCommand:a.fixCommand??d,logPath:b});return}if(!(!c||Date.now()-c>6e5)){i=!0,j({...e,visible:!0,stage:r(a.phase),startedAt:c,baselineMs:h,logPath:b});try{let a=c+3e5;for(;Date.now()<a;){await n(1e3);let{state:a}=await p();if(a?.phase){if("failed"===a.phase)return void s(a.error??"install failed",{rolledBack:!0===a.rolledBack,fixCommand:a.fixCommand??d});if("done"===a.phase)return void j({stage:"done",installedVersion:a.installed??null,upToDate:!0===a.unchanged});j({stage:r(a.phase)})}}s("timeout")}finally{i=!1}}}},4462:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>f});var d=c(48249),e=c(44384);function f({onBrowseProjects:a}){let{t:b}=(0,e.Bd)();return(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 bg-card",children:[(0,d.jsx)("svg",{className:"w-14 h-14 text-muted-foreground/40",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"})}),(0,d.jsx)("p",{className:"text-sm text-muted-foreground",children:b("workspace.selectProject")}),(0,d.jsxs)("button",{onClick:a,className:"flex items-center gap-2 px-4 py-2 text-sm rounded-lg bg-primary text-primary-foreground hover:opacity-90 transition-opacity",children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),b("workspace.openProject")]})]})}},4857:(a,b,c)=>{"use strict";c.d(b,{Q:()=>e});var d=c(67484);function e(){let a=(0,d.useRef)([]),b=(0,d.useRef)([]),c=(0,d.useCallback)(c=>{a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),b.current=[]},[]),e=(0,d.useCallback)(c=>{if(0===a.current.length)return null;let d=a.current.pop();return b.current.push(c),b.current.length>50&&(b.current=b.current.slice(-50)),d},[]),f=(0,d.useCallback)(c=>{if(0===b.current.length)return null;let d=b.current.pop();return a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),d},[]);return{push:c,goBack:e,goForward:f,canGoBack:(0,d.useCallback)(()=>a.current.length>0,[]),canGoForward:(0,d.useCallback)(()=>b.current.length>0,[])}}},5585:(a,b,c)=>{"use strict";c.d(b,{Providers:()=>p});var d=c(48249),e=c(29491),f=c(83768),g=c(7833),h=c(67484),i=c(74429);function j(){let[a,b]=(0,h.useState)(null);(0,h.useRef)(null).current=a,(0,h.useRef)(null);let c=(0,h.useRef)(null),[e,f]=(0,h.useState)({left:0,top:0}),[g,j]=(0,h.useState)(!1);return g&&a?(0,i.createPortal)((0,d.jsx)("div",{ref:c,className:"fixed z-[9999] max-w-[min(80vw,64rem)] px-2 py-1 bg-tooltip text-tooltip-foreground text-xs font-mono rounded shadow-lv3 border border-line-1 whitespace-pre-wrap break-words pointer-events-none",style:{left:e.left,top:e.top},children:a.text}),document.body):null}var k=c(44384),l=c(4325);c(29939);let m=new Set(["preparing","installing","repairing","rolling-back","restarting"]);function n(){return(0,d.jsxs)("svg",{className:"h-4 w-4 flex-shrink-0 animate-spin text-brand",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:4}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}function o(){let{t:a}=(0,k.Bd)(),b=(0,h.useSyncExternalStore)(l.N4,l.fX,l.fX),[c,e]=(0,h.useState)(()=>Date.now());(0,h.useRef)(!1);let{stale:f}=function(){let[a,b]=(0,h.useState)(!1);return{stale:a}}(),[i,j]=(0,h.useState)(!1),[o,p]=(0,h.useState)(!1),q=b.visible&&m.has(b.stage),r=(0,h.useCallback)(()=>{navigator.clipboard.writeText(b.fixCommand),(0,g.oR)(a("workspace.updateCardFixCopied"))},[b.fixCommand,a]),s=!b.visible&&f&&!i;if(!o||!b.visible&&!s)return null;let t=b.startedAt?Math.max(0,Math.round((c-b.startedAt)/1e3)):0,u=b.baselineMs?Math.round(b.baselineMs/1e3):null,v=s||"done"===b.stage,w=s||!m.has(b.stage),x=v&&!b.upToDate,y=s?a("workspace.serverRestarted"):(()=>{switch(b.stage){case"preparing":return a("workspace.updateCardPreparing");case"installing":return a("workspace.updateCardInstalling");case"repairing":return a("workspace.updateCardRepairing");case"rolling-back":return a("workspace.updateCardRollingBack");case"restarting":return a("workspace.updateCardRestarting");case"done":if(!b.installedVersion)return a("workspace.updateComplete");return b.upToDate?a("workspace.updateCardUpToDate",{version:b.installedVersion}):a("workspace.updateCardDone",{version:b.installedVersion});case"failed":return a("workspace.updateFailed")}})();return(0,d.jsx)("div",{className:"fixed top-4 right-4 z-[110] w-80 rounded-lg border border-border\n bg-background/95 p-3 shadow-lv2 backdrop-blur",role:"status","aria-live":"polite",children:(0,d.jsxs)("div",{className:"flex items-start gap-2.5",children:[q?(0,d.jsx)(n,{}):v?(0,d.jsx)("svg",{className:"h-4 w-4 flex-shrink-0 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"h-4 w-4 flex-shrink-0 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("div",{className:"text-sm text-foreground",children:y}),q&&(0,d.jsxs)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:[a("workspace.updateCardElapsed",{seconds:t}),null!==u&&(0,d.jsxs)(d.Fragment,{children:[" \xb7 ",a("workspace.updateCardBaseline",{seconds:u})]})]}),q&&!b.live&&(0,d.jsx)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground/80",children:a("workspace.updateCardNoLiveStatus")}),q&&(0,d.jsx)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:a("workspace.updateRestartNote")}),!s&&"failed"===b.stage&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"mt-1 break-words text-[11px] leading-snug text-muted-foreground",children:b.error}),b.rolledBack&&(0,d.jsx)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:a("workspace.updateCardRolledBack")}),(0,d.jsx)("div",{className:"mt-2 text-[11px] leading-snug text-muted-foreground",children:a("workspace.updateCardManualHint")}),(0,d.jsx)("code",{className:"mt-1 block break-all rounded bg-hover px-2 py-1.5 text-[11px]\n leading-snug text-foreground",children:b.fixCommand}),(0,d.jsx)("button",{type:"button",onClick:r,className:"mt-1.5 w-full rounded-md border border-border px-2.5 py-1.5 text-xs\n text-foreground transition-colors hover:bg-hover",children:a("workspace.updateCardCopyFix")}),b.logPath&&(0,d.jsx)("div",{className:"mt-1.5 break-all text-[11px] leading-snug text-muted-foreground/80",children:a("workspace.updateCardLogHint",{path:b.logPath})})]}),x&&(0,d.jsx)("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-2 w-full rounded-md bg-primary px-2.5 py-1.5 text-xs\n text-primary-foreground transition-opacity hover:opacity-90",children:a("workspace.reloadNow")})]}),w&&(0,d.jsx)("button",{type:"button",onClick:()=>{j(!0),s||(0,l.fZ)()},"aria-label":a("common.close"),className:"-mr-1 -mt-1 rounded p-1 text-muted-foreground transition-colors hover:bg-hover",children:(0,d.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function p({children:a}){return(0,d.jsx)(e.I18nProvider,{children:(0,d.jsx)(f.NP,{children:(0,d.jsxs)(g.tE,{children:[a,(0,d.jsx)(j,{}),(0,d.jsx)(o,{})]})})})}},5900:(a,b,c)=>{"use strict";c.d(b,{T:()=>D});var d=c(48249),e=c(98051),f=c(38368),g=c(33972),h=c(10841),i=c(99773),j=c(36513);c(55583),c(87023);var k=c(50757),l=c(27454),m=c(37752),n=c(67484),o=c(64676),p=c(83768),q=c(15466),r=c(49216);function s(a){return{type:"tableCell",children:[{type:"text",value:a}]}}let t=[c(4014).A,function(){return a=>{let b=a.children;for(let a=0;a<b.length;a++){let c=b[a];if("yaml"!==c.type)continue;let d=null;try{let a=r.Ay.load(c.value??"");a&&"object"==typeof a&&!Array.isArray(a)&&(d=a)}catch{d=null}let e=d?Object.entries(d):[];if(0===e.length){b.splice(a,1),a--;continue}let f={type:"tableRow",children:[s("Field"),s("Value")]},g=e.map(([a,b])=>({type:"tableRow",children:[s(a),s(function(a){if(null==a)return"";if("string"==typeof a)return a.replace(/\s*\n\s*/g," ").trim();if("number"==typeof a||"boolean"==typeof a)return String(a);try{return JSON.stringify(a)}catch{return String(a)}}(b))]}));b[a]={type:"table",align:["left","left"],children:[f,...g]}}}}];function u(a){return!(!a.trim()||/\n[ \t]*\n/.test(a)||a.includes("$"))}function v(a){if(!a.includes("\\(")&&!a.includes("\\["))return a;let b=[],c=a=>(b.push(a),`\u0000MATHMASK${b.length-1}\u0000`);return a.replace(/```[\s\S]*?```/g,c).replace(/~~~[\s\S]*?~~~/g,c).replace(/`[^`\n]+`/g,c).replace(/\\\[([^\u0000]*?)\\\]/g,(a,b)=>u(b)?`$$${b}$$`:a).replace(/\\\(([^\u0000]*?)\\\)/g,(a,b)=>u(b)?`$${b}$`:a).replace(/\u0000MATHMASK(\d+)\u0000/g,(a,c)=>b[+c])}let w=[...t,f.A,g.A,function(){return(a,b)=>{let c=String(b?.value??"");c&&function a(b,c){let d=b.children;if(d)for(let e=0;e<d.length;e++)c(d[e],e,b),a(d[e],c)}(a,(a,b,d)=>{var e;if("inlineMath"!==a.type)return;let f=a.position?.start?.offset,g=a.position?.end?.offset;void 0!==f&&void 0!==g&&(e=a.value??"","$$"!==c.slice(f,f+2)&&(!e||/^\s|\s$/.test(e)||/\d/.test(c[f-1]??"")||/\d/.test(c[g]??"")||0)&&(d.children[b]={type:"text",value:c.slice(f,g),position:a.position}))})}},h.jb],x=[...t,f.A,h.jb],y=[i.A,j.A],z=[i.A];function A(a){let b=[],c=a=>(b.push(a),` MASK${b.length-1} `);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/^(\|.+\|)$/gm,a=>/^\|[\s:|-]+\|$/.test(a)?a:a.replace(/`([^`]*)`/g,(a,b)=>b.includes("|")?"`"+b.replace(/\|/g,"\\|")+"`":a)).replace(/ MASK(\d+) /g,(a,c)=>b[+c])}let B=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clippath","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan","use"]);function C(a){let b=[],c=a=>(b.push(a),`\u0000MASK${b.length-1}\u0000`);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/`[^`\n]+`/g,a=>c(a)).replace(/<\/?([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(a,b)=>{let c=b.toLowerCase();return B.has(c)||c.includes("-")?a:a.replace(/</g,"&lt;").replace(/>/g,"&gt;")}).replace(/\u0000MASK(\d+)\u0000/g,(a,c)=>b[+c])}let D=(0,n.memo)(function({content:a,isUser:b=!1,isStreaming:c=!1,enableMath:f=!0,isDark:g,rehypePlugins:h,onLinkClick:i,basePath:j}){let r=(0,p.Ql)(),s=g??r?.resolvedTheme==="dark",t=(0,n.useRef)(null),u=(0,n.useMemo)(()=>({code({className:a,children:b,node:c,...e}){let f=/language-(\w+)/.exec(a||"");if(!("string"==typeof b||"number"==typeof b||Array.isArray(b)&&b.every(a=>"string"==typeof a||"number"==typeof a)))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...e,children:b});let g=String(b);if(!f&&!a&&!g.includes("\n"))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...e,children:b});let h=g.replace(/\n$/,""),i=f?.[1]||"text",j=Number(e["data-source-start"])||0,n=j?j+1:0,o=0;return(0,d.jsx)(k.A,{style:s?l.A:m.A,language:i,PreTag:"div",className:"md-figure",customStyle:{margin:"1.35em 0",borderRadius:"0.375rem",fontSize:"0.92em"},wrapLines:!0,lineProps:()=>{let a=n+o;return o++,{"data-source-start":a,"data-source-end":a,style:{display:"block"}}},children:h})},p:({children:a,node:b,...c})=>(0,d.jsx)("p",{...c,children:a}),h1:({children:a,node:b,...c})=>(0,d.jsx)("h1",{...c,children:a}),h2:({children:a,node:b,...c})=>(0,d.jsx)("h2",{...c,children:a}),h3:({children:a,node:b,...c})=>(0,d.jsx)("h3",{...c,children:a}),ul:({children:a,node:b,...c})=>(0,d.jsx)("ul",{className:"list-disc",...c,children:a}),ol:({children:a,node:b,...c})=>(0,d.jsx)("ol",{className:"list-decimal",...c,children:a}),li:({children:a,node:b,...c})=>(0,d.jsx)("li",{...c,children:a}),blockquote:({children:a,node:b,...c})=>(0,d.jsx)("blockquote",{className:"border-l-2 border-border pl-4 text-muted-foreground",...c,children:a}),a:({href:a,children:b,node:c,...e})=>(0,d.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...e,onClick:b=>{if(a){if(a.startsWith("#")){(0,q.O)(t.current,a.slice(1))&&b.preventDefault();return}i?.(a)&&b.preventDefault()}},children:b}),table:({children:a,node:b,...c})=>(0,d.jsx)("div",{className:"md-figure overflow-x-auto",...c,children:(0,d.jsx)("table",{className:"min-w-full border border-border",children:a})}),thead:({children:a,node:b,...c})=>(0,d.jsx)("thead",{className:"bg-accent",...c,children:a}),th:({children:a,node:b,...c})=>(0,d.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...c,children:a}),td:({children:a,node:b,...c})=>(0,d.jsx)("td",{className:"px-4 py-2 border-b border-border",...c,children:a}),hr:({node:a,...b})=>(0,d.jsx)("hr",{className:"border-border",...b}),img:({src:a,alt:b,node:c,height:e,width:f,style:g,...h})=>{let i=j&&"string"==typeof a?(0,o.xh)(a,j):a;if(!(e||f||g))return(0,d.jsx)("img",{src:i,alt:b||"",className:"max-w-full h-auto rounded-lg my-3",...h});let k=a=>a?/^\d+$/.test(String(a))?`${a}px`:String(a):void 0,l={...g,height:k(e)??g?.height,width:k(f)??g?.width};return(0,d.jsx)("img",{src:i,alt:b||"",style:l,className:"inline-block align-middle",...h})},strong:({children:a,node:b,...c})=>(0,d.jsx)("strong",{className:"font-bold",...c,children:a}),em:({children:a,node:b,...c})=>(0,d.jsx)("em",{className:"italic",...c,children:a}),del:({children:a,node:b,...c})=>(0,d.jsx)("del",{className:"line-through",...c,children:a})}),[s,i,j]),B=f?w:x,D=f?y:z,E=(0,n.useMemo)(()=>{if(b||c)return C(a);let d=C(A(!function(a){if(/^\|[\s:|-]+\|$/m.test(a))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(a)||/\+[-=]{2,}\+/.test(a))return!0;let b=a.split("\n").filter(a=>/^\s*\||\|\s*$/.test(a));if(b.length>=3){let a=b.map(a=>(a.match(/\|/g)||[]).length);return!a.every(b=>b===a[0])||!(a[0]>=3)}return!1}(a)||/^```[\s\S]*```$/m.test(a.trim())?a:"```text\n"+a.trim()+"\n```"));return f?v(d):d},[a,b,c,f]),F=(0,n.useMemo)(()=>h?.length?[...D,...h]:D,[h,D]);if(b)return(0,d.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:a});if(c){let b=a.lastIndexOf("\n");if(-1===b)return(0,d.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:a});let c=a.slice(0,b+1),g=a.slice(b+1);return(0,d.jsxs)("div",{className:"markdown-body",ref:t,children:[(0,d.jsx)(e.oz,{remarkPlugins:B,rehypePlugins:D,components:u,children:f?v(C(A(c))):C(A(c))}),g&&(0,d.jsx)("span",{className:"md-tail whitespace-pre-wrap",children:g})]})}return(0,d.jsx)("div",{className:"markdown-body",ref:t,children:(0,d.jsx)(e.oz,{remarkPlugins:B,rehypePlugins:F,components:u,children:E})})})},6478:(a,b,c)=>{"use strict";c.d(b,{P:()=>j});var d=c(67484),e=c(44384),f=c(7833),g=c(33281),h=c(47276),i=c(35857);function j(){let{t:a}=(0,e.Bd)();return(0,d.useCallback)(async b=>{let c=await g.t4.runPromiseExit((0,h.ot)(b));if("Success"===c._tag)c.value.alreadyExists?(0,f.oR)(a("htmlApps.alreadyAdded"),"info"):((0,f.oR)(a("htmlApps.added"),"success"),(0,i.N)());else{let b="Fail"===c.cause._tag?c.cause.error:null,d=b?.cause,e=d instanceof Error?d.message:a("htmlApps.addFailed");(0,f.oR)(e,"error")}},[a])}},6612:(a,b,c)=>{"use strict";c.d(b,{TabManager:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManager() from the server but TabManager is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabManager.tsx","TabManager")},6662:(a,b,c)=>{"use strict";c.d(b,{W:()=>j});var d=c(67484),e=c(9804),f=c(79606),g=c(33281),h=c(87808),i=c(25419);function j({cwd:a}){let[b,c]=(0,d.useState)([]),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(new Set),[o,p]=(0,d.useState)([]),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)(null),[u,v]=(0,d.useState)(new Set),[w,x]=(0,d.useState)(null),[y,z]=(0,d.useState)(""),[A,B]=(0,d.useState)(!1),[C,D]=(0,d.useState)(null),[E,F]=(0,d.useState)(!0),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(null),K=(0,d.useRef)(null),[L,M]=(0,d.useState)(!1),[N,O]=(0,d.useState)(null),[P,Q]=(0,d.useState)("center"),[R,S]=(0,d.useState)(null),[T,U]=(0,d.useState)(null),[V,W]=(0,d.useState)(!1),[X,Y]=(0,d.useState)([]),[Z,$]=(0,d.useState)(!1),[_,aa]=(0,d.useState)(null),[ab,ac]=(0,d.useState)(null),[ad,ae]=(0,d.useState)(!0),[af,ag]=(0,d.useState)(!1),[ah,ai]=(0,d.useState)(!1),aj=(0,d.useMemo)(()=>o.map(a=>a.path).filter(Boolean),[o]),ak=(0,d.useMemo)(()=>(0,e.v3)(aj),[aj]),al=(0,d.useMemo)(()=>new Set((0,e.tW)(ak)),[ak]),am=(0,d.useMemo)(()=>y?k?(0,e.KH)(k,y,A):(0,e.q3)(b,y,A):null,[b,k,y,A]),an=w??u,ao=(0,d.useRef)(null),ap=(0,d.useCallback)(b=>{ao.current&&clearTimeout(ao.current),ao.current=setTimeout(()=>{g.t4.runFork((0,h.Ft)(a,Array.from(b)).pipe(f.sFT(a=>f.OH5(()=>console.error("Error saving expanded paths:",a))),f.NWQ(()=>f.rIH)))},500)},[a]),aq=(0,d.useCallback)(async()=>{F(!0),J(null),await g.t4.runPromise((0,h.mP)(a).pipe(f.YWq({onSuccess:a=>{a.error?J(a.error):(c(a.files??[]),a.expandedPaths&&Array.isArray(a.expandedPaths)&&v(new Set(a.expandedPaths)))},onFailure:a=>{console.error("Error loading files:",a),J("Failed to load files")}}))),F(!1)},[a]),ar=(0,d.useCallback)(()=>{g.t4.runPromise((0,h.DZ)(a).pipe(f.YWq({onSuccess:a=>{a.paths&&l(a.paths)},onFailure:a=>{console.error("Error loading file index:",a)}})))},[a]),as=(0,d.useCallback)(async b=>{n(a=>new Set([...a,b])),await g.t4.runPromise((0,h.gZ)(a,b).pipe(f.YWq({onSuccess:a=>{a.children&&c(c=>{if(!b){let b=new Map(c.map(a=>[a.path,a]));return a.children.map(a=>{let c=b.get(a.path);return c?.children&&a.isDirectory?{...a,children:c.children}:a})}let d=structuredClone(c),f=(0,e.MB)(d,b);return f&&(f.children=a.children),d})},onFailure:a=>{console.error("Error loading directory:",a)}}))),n(a=>{let c=new Set(a);return c.delete(b),c})},[a]);(0,d.useRef)(m).current=m;let at=(0,d.useCallback)(async()=>{await g.t4.runPromise((0,h.r9)(a).pipe(f.YWq({onSuccess:a=>p(a.files??[]),onFailure:a=>console.error("Error loading recent files:",a)})))},[a]),au=(0,d.useCallback)(async b=>{p(a=>{let c=a.filter(a=>a.path!==b);return[{path:b},...c].slice(0,15)}),await g.t4.runPromise((0,h.YW)(a,b).pipe(f.sFT(a=>f.OH5(()=>console.error("Error adding to recent files:",a))),f.NWQ(()=>f.rIH)))},[a]),av=(0,d.useCallback)((b,c,d,e)=>{p(a=>a.map(a=>a.path===b?{...a,scrollLine:c,cursorLine:d,cursorCol:e}:a)),g.t4.runFork((0,h.YW)(a,b,{scrollLine:c,cursorLine:d,cursorCol:e}).pipe(f.NWQ(()=>f.rIH)))},[a]),aw=(0,d.useCallback)(a=>o.find(b=>b.path===a),[o]),ax=(0,d.useCallback)(async b=>{let c=b||q;c&&($(!0),aa(null),await g.t4.runPromise((0,h.eE)(a,c).pipe(f.YWq({onSuccess:a=>{a.error?aa(a.error):Y(a.blame??[])},onFailure:a=>{console.error("Error loading blame:",a),aa("Failed to load blame info")}}))),$(!1))},[a,q]),ay=(0,d.useCallback)(async b=>{H(!0),t(null),W(!1),Y([]),aa(null),ac(null);let c=f.JkU(function*(){let c=yield*(0,h.r6)(a,b);if(!c.ok)return{type:"error",message:c.data?.error||"Failed to stat file"};let d=c.data??{};if(!d.exists)return{type:"error",message:"File not found"};if("dir"===d.kind)return{type:"error",message:"Path is a directory"};switch(d.category){case"image":return{type:"image",size:d.size,mtime:d.mtimeMs,...d.isSymlink?{isSymlink:!0,symlinkTarget:d.symlinkTarget}:{}};case"pdf":return{type:"pdf",size:d.size,mtime:d.mtimeMs,...d.isSymlink?{isSymlink:!0,symlinkTarget:d.symlinkTarget}:{}};case"binary":return{type:"binary",message:"Cannot preview binary file",size:d.size,mtime:d.mtimeMs};case"too-large":return{type:"error",message:"File too large to preview",size:d.size,mtime:d.mtimeMs};default:{let c=yield*(0,i.K)(a,b);if(409===c.status)return{type:"binary",message:c.data?.error||"Cannot preview binary file",size:d.size,mtime:d.mtimeMs};if(!c.ok)return{type:"error",message:c.data?.error||"Failed to load file"};let e=c.data??{};return{type:"text",content:e.content,size:e.size,mtime:e.mtimeMs,...e.isSymlink?{isSymlink:!0,symlinkTarget:e.symlinkTarget}:{}}}}});await g.t4.runPromise(c.pipe(f.YWq({onSuccess:a=>t(a),onFailure:a=>{console.error("Error loading file content:",a),t({type:"error",message:"Failed to load file"})}}))),au(b),ax(b),H(!1)},[a,au,ax]),az=(0,d.useCallback)(()=>{V?W(!1):(W(!0),0===X.length&&ax())},[V,X.length,ax]),aA=(0,d.useCallback)((a,b)=>{if(!a)return;if(r(a),O(b??null),null==b){let b=o.find(b=>b.path===a);b?.scrollLine?(O(b.scrollLine),Q("start"),S(b.cursorLine??null),U(b.cursorCol??null)):(Q("center"),S(null),U(null))}else Q("center"),S(null),U(null);ay(a);let c=a.split("/");if(c.length>1){let a=[];for(let b=1;b<c.length;b++)a.push(c.slice(0,b).join("/"));v(b=>{let c=new Set(b),d=!1;for(let b of a)c.has(b)||(c.add(b),d=!0);return d&&ap(c),d?c:b})}},[ay,ap,o]),aB=(0,d.useCallback)(a=>{if(w)x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c});else{let c=!u.has(a);if(v(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),ap(c),c}),c){let c=(0,e.MB)(b,a);c&&c.isDirectory&&!c.children&&as(a)}}},[w,ap,u,b,as]);return{files:b,setFiles:c,fileIndex:k,setFileIndex:l,loadingDirs:m,expandedPaths:u,setExpandedPaths:v,searchTreeExpandedPaths:w,setSearchTreeExpandedPaths:x,effectiveExpandedPaths:an,searchQuery:y,setSearchQuery:z,searchExactMatch:A,setSearchDirExact:B,matchedPaths:am,creatingItem:C,setCreatingItem:D,isLoadingFiles:E,fileError:I,searchInputRef:K,shouldScrollToSelected:L,setShouldScrollToSelected:M,targetLineNumber:N,setTargetLineNumber:O,targetScrollAlign:P,setTargetScrollAlign:Q,initialCursorLine:R,initialCursorCol:T,setInitialCursorLine:S,setInitialCursorCol:U,selectedPath:q,setSelectedPath:r,fileContent:s,setFileContent:t,isLoadingContent:G,recentFiles:o,recentFilePaths:aj,setRecentFiles:p,recentFilesTree:ak,recentTreeDirPaths:al,showBlame:V,setShowBlame:W,blameLines:X,isLoadingBlame:Z,blameError:_,blameSelectedCommit:ab,setBlameSelectedCommit:ac,previewMarkdown:ad,setPreviewMarkdown:ae,previewHtml:af,setPreviewHtml:ag,showEditor:ah,setShowEditor:ai,saveExpandedPaths:ap,loadFiles:aq,loadFileIndex:ar,loadDirectory:as,loadRecentFiles:at,addToRecentFiles:au,updateRecentFilePosition:av,getRecentFilePosition:aw,loadFileContent:ay,loadBlame:ax,handleToggleBlame:az,handleSelectFile:aA,handleToggle:aB}}},6900:(a,b,c)=>{"use strict";c.d(b,{x:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(7833),h=c(33281),i=c(85655),j=c(9804),k=c(57031),l=c(88214);function m({isOpen:a,onClose:b,cwd:c}){let n,{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(""),[F,G]=(0,e.useState)(!1),[H,I]=(0,e.useState)([]),[J,K]=(0,e.useState)(""),[L,M]=(0,e.useState)(!1),N=(0,e.useCallback)((a,b)=>a?._tag==="Fail"&&a.error?.cause instanceof Error?a.error.cause.message:o(b),[o]),O=(0,e.useCallback)(async()=>{w(!0);let a=await h.t4.runPromiseExit((0,i.FK)(c));if("Success"===a._tag){let b=a.value;q(b.worktrees),s(b.nextPath),u(b.nextRandomWord),b.gitUserName&&E(b.gitUserName)}else console.error("Failed to load worktrees:",a.cause),(0,g.oR)(o("toast.worktreeLoadFailed"),"error");w(!1)},[c,o]),P=(0,e.useCallback)(a=>{let{local:b,remote:c}=a;return c.includes("origin/main")?"origin/main":c.includes("origin/master")?"origin/master":b.includes("main")?"main":b.includes("master")?"master":c.length>0?c[0]:b.length>0?b[0]:"main"},[]),Q=async()=>{if(!r)return;let a="origin/main",b=await h.t4.runPromiseExit((0,i.r4)(c));"Success"===b._tag&&(a=P(b.value));let d=t||function(){let a="bcdfghjklmnprstvwz",b=["a","e","i","o","u","ai","au","ea","ee","ia","io","oa","oo","ou","ui"],c="";for(let d=0;d<2;d++)c+=a[Math.floor(Math.random()*a.length)],c+=b[Math.floor(Math.random()*b.length)];return c}(),e=D?`${D}/${d}`:d;y(!0);let f=await h.t4.runPromiseExit((0,i.CM)({action:"add",cwd:c,path:r,newBranch:e,baseBranch:a}));"Success"===f._tag?((0,g.oR)(o("toast.worktreeCreateSuccess",{name:e}),"success"),O()):(console.error("Failed to create worktree:",f.cause),(0,g.oR)(N(f.cause,"toast.worktreeCreateFailed"),"error")),y(!1)},R=async()=>{M(!0),K(""),G(!0);let a=await h.t4.runPromiseExit((0,i.r4)(c));if("Success"===a._tag){let b=a.value,c=b.local??[],d=b.remote??[],e=new Set(p.map(a=>a.branch).filter(Boolean));I([...c.filter(a=>!e.has(a)),...d.filter(a=>!e.has(a)&&!c.includes(a.replace(/^origin\//,"")))])}else(0,g.oR)(o("toast.loadBranchFailed"),"error");M(!1)},S=async a=>{if(!r)return;G(!1),y(!0);let b=await h.t4.runPromiseExit((0,i.CM)({action:"add",cwd:c,path:r,branch:a}));"Success"===b._tag?((0,g.oR)(o("toast.worktreeCreateSuccess",{name:a}),"success"),O()):(console.error("Failed to create worktree:",b.cause),(0,g.oR)(N(b.cause,"toast.worktreeCreateFailed"),"error")),y(!1)},T=async()=>{if(!z)return;C(!0);let a=await h.t4.runPromiseExit((0,i.CM)({action:"remove",cwd:c,path:z.path}));"Success"===a._tag?((0,g.oR)(o("toast.worktreeDeleted"),"success"),A(null),O()):(console.error("Failed to delete worktree:",a.cause),(0,g.oR)(N(a.cause,"toast.worktreeDeleteFailed"),"error")),C(!1)},U=async a=>{let b=a.isLocked?"unlock":"lock",d=await h.t4.runPromiseExit((0,i.CM)({action:b,cwd:c,path:a.path}));"Success"===d._tag?((0,g.oR)(a.isLocked?o("toast.worktreeUnlocked"):o("toast.worktreeLocked"),"success"),O()):(console.error("Failed to toggle lock:",d.cause),(0,g.oR)(N(d.cause,"toast.operationFailed"),"error"))};return a?(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-[480px] max-h-[80vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Git Worktrees"}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:o("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:v?(0,d.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):(0,d.jsx)("div",{className:"space-y-2",children:p.map(a=>{let e,f=a.path===c;return(0,d.jsxs)("div",{className:`group p-3 rounded-lg border transition-colors ${f?"border-brand bg-brand/5":"border-border hover:bg-hover cursor-pointer"}`,onClick:()=>{a.path!==c&&((0,k.F)(l.n.OpenProject,{cwd:a.path}),b())},children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${f?"bg-brand":"bg-muted-foreground/30"}`}),(0,d.jsx)("span",{className:"font-medium text-foreground truncate",children:a.branch||(a.isDetached?"detached":"unknown")}),a.isLocked&&(0,d.jsx)("span",{className:"text-amber-11",title:o("git.worktree.locked"),children:"\uD83D\uDD12"}),f&&(0,d.jsxs)("span",{className:"text-xs text-brand",children:["(",o("common.current"),")"]})]}),(0,d.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:!f&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),U(a)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-secondary rounded transition-colors",title:a.isLocked?o("git.worktree.unlock"):o("git.worktree.lock"),children:a.isLocked?(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"})}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),A(a)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-secondary rounded transition-colors",title:o("common.delete"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]}),(0,d.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2 pl-4",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:a.path}),null!=a.createdAt&&(e=(0,j.fw)(a.createdAt/1e3),(0,d.jsx)("span",{className:`text-xs flex-shrink-0 ${"just now"===e?"text-brand":"text-muted-foreground/70"}`,"data-tooltip":new Date(a.createdAt).toLocaleString(),children:e}))]}),a.isDetached&&(0,d.jsx)("div",{className:"mt-1 text-xs text-amber-11 pl-4",children:"(detached HEAD)"})]},a.path)})})}),F&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-3 flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,d.jsx)("input",{value:J,onChange:a=>K(a.target.value),placeholder:o("git.worktree.searchBranch"),className:"flex-1 bg-secondary text-sm text-foreground rounded px-2.5 py-1.5 outline-none",autoFocus:!0,autoComplete:"off",spellCheck:"false"}),(0,d.jsx)("button",{onClick:()=>G(!1),className:"text-xs text-muted-foreground hover:text-foreground px-2 py-1.5",children:o("common.cancel")})]}),(0,d.jsx)("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:L?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:o("common.loading")}):0===(n=H.filter(a=>a.toLowerCase().includes(J.toLowerCase()))).length?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:o("git.worktree.noBranches")}):n.map(a=>(0,d.jsx)("button",{onClick:()=>S(a),className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-hover transition-colors truncate",children:(0,d.jsx)("span",{className:`${a.startsWith("origin/")?"text-muted-foreground":"text-foreground"}`,children:a})},a))})]}),(0,d.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between flex-shrink-0",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:o("git.worktree.count",{count:p.length})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:R,disabled:!r||x,className:`px-3 py-1.5 text-sm rounded transition-colors ${r&&!x?"bg-secondary text-foreground hover:bg-hover":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:o("git.worktree.selectBranch")}),(0,d.jsx)("button",{onClick:Q,disabled:!r||x,className:`px-3 py-1.5 text-sm rounded transition-colors ${r&&!x?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:x?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):o("git.worktree.addWorktree")})]})]}),z&&(0,d.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-scrim rounded-lg",onClick:()=>A(null),children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-[360px] p-4",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground mb-3",children:o("git.worktree.confirmDelete")}),(0,d.jsxs)("div",{className:"text-sm text-muted-foreground mb-4",children:[(0,d.jsx)("p",{className:"mb-2",children:o("git.worktree.confirmDeleteMsg")}),(0,d.jsxs)("p",{className:"text-xs",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:o("git.worktree.path")}),(0,d.jsx)("span",{className:"text-foreground",children:z.path})]}),(0,d.jsxs)("p",{className:"text-xs",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:o("git.worktree.branch")}),(0,d.jsx)("span",{className:"text-foreground",children:z.branch||"detached"})]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>A(null),className:"px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:o("common.cancel")}),(0,d.jsx)("button",{onClick:T,disabled:B,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 transition-colors disabled:opacity-50",children:B?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):o("common.delete")})]})]})})]})}):null}},7031:(a,b,c)=>{"use strict";c.d(b,{H:()=>g,r:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g({value:a,children:b}){return(0,d.jsx)(f.Provider,{value:a,children:b})}function h(){return(0,e.useContext)(f)}},7122:(a,b,c)=>{"use strict";c.d(b,{Ee:()=>m,SU:()=>j,ft:()=>l,iN:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(74429),h=c(7833);let i=(0,e.createContext)(null);function j({container:a,children:b}){return(0,d.jsx)(i.Provider,{value:a,children:b})}function k(){return(0,e.useContext)(i)}function l({x:a,y:b,path:c,cwd:j,isDirectory:k,onClose:m,onCreateFile:n,onDelete:o,onRefresh:p,onCopyFile:q,onPaste:r,onExplain:s,explainDisabled:t}){let{t:u}=(0,f.Bd)(),v=(0,e.useRef)(null),w=(0,e.useContext)(i),x=c.split("/").pop()||c,y=`${j}/${c}`,z=c.includes("/")?c.substring(0,c.lastIndexOf("/")):"",A=z?`${j}/${z}`:j,B=k?c:z,C=k?y:A,[D,E]=(0,e.useState)({x:0,y:0}),F=(0,e.useCallback)(async(a,b)=>{try{await navigator.clipboard.writeText(a),(0,h.oR)(u("toast.copiedName",{name:b}),"success")}catch{(0,h.oR)(u("toast.copyFailed"),"error")}m()},[m,u]),G=k?c:z,H=!!s&&!k,I=[{label:u("fileContextMenu.copyRelativePath"),value:c},{label:u("fileContextMenu.copyAbsolutePath"),value:y},{label:u("fileContextMenu.copyRelativeDirPath"),value:B||"."},{label:u("fileContextMenu.copyAbsoluteDirPath"),value:C},{label:k?u("fileContextMenu.copyFolderName"):u("fileContextMenu.copyFileName"),value:x}],J=(0,d.jsxs)("div",{ref:v,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lv2 py-1 w-fit whitespace-nowrap",style:{left:D.x,top:D.y},children:[H&&(0,d.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",disabled:t,title:t?u("comments.aiResponding"):void 0,onClick:()=>{m(),s(c)},children:u("explain.action")}),H&&(0,d.jsx)("div",{className:"my-1 border-t border-border"}),n&&(0,d.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),n(G)},children:u("fileContextMenu.createFile")}),q&&(0,d.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),q(c)},children:k?u("fileContextMenu.copyFolder"):u("fileContextMenu.copyFile")}),r&&(0,d.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),r(G)},children:u("fileContextMenu.pasteHere")}),o&&(0,d.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-hover transition-colors",onClick:()=>{m(),o(c,k,x)},children:k?u("fileContextMenu.deleteFolder"):u("fileContextMenu.deleteFile")}),!!(n||q||r||o)&&(0,d.jsx)("div",{className:"my-1 border-t border-border"}),I.map((a,b)=>(0,d.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>F(a.value,a.label),children:a.label},b))]});return w?(0,g.createPortal)(J,w):J}function m(){let[a,b]=(0,e.useState)(null);return{contextMenu:a,showContextMenu:(0,e.useCallback)((a,c,d)=>{a.preventDefault(),a.stopPropagation(),b({x:a.clientX,y:a.clientY,path:c,isDirectory:d})},[]),hideContextMenu:(0,e.useCallback)(()=>{b(null)},[])}}},7833:(a,b,c)=>{"use strict";c.d(b,{dj:()=>h,lJ:()=>l,oR:()=>n,tE:()=>i});var d=c(48249),e=c(67484),f=c(208);let g=(0,e.createContext)(null);function h(){let a=(0,e.useContext)(g);if(!a)throw Error("useToast must be used within a ToastProvider");return a}function i({children:a}){let[b,c]=(0,e.useState)([]),f=(0,e.useCallback)((a,b="success")=>{let d=`toast-${Date.now()}`;c(c=>[...c,{id:d,message:a,type:b}])},[]),h=(0,e.useCallback)(a=>{c(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)(g.Provider,{value:{showToast:f},children:[a,(0,d.jsx)(j,{toasts:b,onRemove:h})]})}function j({toasts:a,onRemove:b}){return(0,d.jsx)("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 max-w-[26rem]",children:a.map(a=>(0,d.jsx)(k,{toast:a,onRemove:b},a.id))})}function k({toast:a,onRemove:b}){let c={success:"bg-green-9",error:"bg-red-9",info:"bg-brand"}[a.type],e={success:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),error:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),info:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}[a.type];return(0,d.jsxs)("div",{className:`${c} text-white px-4 py-3 rounded-lg shadow-lv2 flex items-center gap-3 min-w-[200px] animate-slide-in`,style:{animation:"slideIn 0.3s ease-out"},children:[e,(0,d.jsx)("span",{className:"text-sm",children:a.message}),(0,d.jsx)("button",{onClick:()=>b(a.id),className:"ml-auto p-1 hover:bg-white/20 rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function l(a,b){let{title:c=f.A.t("confirm.title",{defaultValue:"Confirm"}),confirmText:d=f.A.t("confirm.ok",{defaultValue:"OK"}),cancelText:e=f.A.t("confirm.cancel",{defaultValue:"Cancel"}),danger:g=!1}=b||{};return new Promise(b=>{let f=document.createElement("div");f.className="fixed inset-0 z-[200] flex items-center justify-center",f.style.animation="confirmFadeIn 0.15s ease-out";let h=a=>{f.style.animation="confirmFadeOut 0.12s ease-in",f.addEventListener("animationend",()=>{document.body.removeChild(f),b(a)},{once:!0})};f.addEventListener("mousedown",a=>{a.target===f&&h(!1)});let i=a=>{"Escape"===a.key?(a.stopPropagation(),document.removeEventListener("keydown",i,!0),h(!1)):"Enter"===a.key&&(a.stopPropagation(),document.removeEventListener("keydown",i,!0),h(!0))};document.addEventListener("keydown",i,!0),f.innerHTML=`
2
- <div class="fixed inset-0 bg-scrim"></div>
3
- <div class="relative bg-card border border-border rounded-xl shadow-lv3 p-6 max-w-sm w-full mx-4" style="animation: confirmScaleIn 0.15s ease-out">
4
- <div class="text-base font-medium text-foreground mb-2">${c}</div>
5
- <div class="text-sm text-muted-foreground mb-6">${a}</div>
6
- <div class="flex justify-end gap-3">
7
- <button data-action="cancel" class="px-4 py-2 text-sm rounded-lg border border-border text-foreground hover:bg-hover transition-colors">${e}</button>
8
- <button data-action="confirm" class="px-4 py-2 text-sm rounded-lg ${g?"bg-red-9 hover:bg-red-10 text-white":"bg-brand hover:bg-brand/90 text-white"} transition-colors">${d}</button>
9
- </div>
10
- </div>
11
- `,f.querySelector('[data-action="cancel"]').addEventListener("click",()=>{document.removeEventListener("keydown",i,!0),h(!1)}),f.querySelector('[data-action="confirm"]').addEventListener("click",()=>{document.removeEventListener("keydown",i,!0),h(!0)}),document.body.appendChild(f),f.querySelector('[data-action="confirm"]')?.focus()})}let m=null;function n(a,b="success"){let c=(m||((m=document.createElement("div")).id="toast-container",m.className="fixed top-4 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 max-w-[26rem]",document.body.appendChild(m)),m),d=document.createElement("div");d.className=`${"success"===b?"bg-green-9":"error"===b?"bg-red-9":"bg-brand"} text-white px-4 py-3 rounded-lg shadow-lv2 flex items-center gap-3 min-w-[200px]`,d.style.animation="slideIn 0.3s ease-out",d.innerHTML=`
12
- <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">${"success"===b?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />':"error"===b?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />'}</svg>
13
- <span class="text-sm">${a}</span>
14
- `,c.appendChild(d),setTimeout(()=>{d.style.animation="slideOut 0.3s ease-in",setTimeout(()=>{c.removeChild(d)},300)},3e3)}},8077:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ProjectSidebar:()=>y});var e=c(48249),f=c(67484),g=c(44384),h=c(37370),i=c(25608),j=c(32459),k=c(18499),l=c(74991),m=c(98982),n=c(13054),o=c(7833),p=c(29939),q=c(64340),r=c(42390),s=c(50514),t=c(24703),u=a([i,j,k,l]);[i,j,k,l]=u.then?(await u)():u;let z=a=>"unread"===a?0:"loading"===a?1:2;function v({className:a=""}){return(0,e.jsxs)("svg",{className:a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,e.jsx)("rect",{x:"4",y:"4",width:"6",height:"6",rx:"1.5"}),(0,e.jsx)("rect",{x:"4",y:"14",width:"6",height:"6",rx:"1.5"}),(0,e.jsx)("rect",{x:"14",y:"14",width:"6",height:"6",rx:"1.5"}),(0,e.jsx)("path",{d:"M17 3v8"}),(0,e.jsx)("path",{d:"M13 7h8"})]})}function w({item:a,active:b,onClick:c,className:d=""}){return(0,e.jsx)("button",{type:"button",onClick:c,className:`h-8 w-8 rounded-md border bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 active:scale-95 transition-all flex items-center justify-center ${b?"border-brand/80 text-brand":"border-border/70"} ${d}`,title:`${a.title}
15
- ${a.path}`,children:a.icon?(0,e.jsx)("span",{className:"text-base leading-none",children:a.icon}):(0,e.jsx)(s.A,{className:"w-4 h-4"})})}function x({collapsed:a,previews:b,activePath:c,onOpenApps:d,onShowPreview:h}){let{t:i}=(0,g.Bd)(),[j,k]=(0,f.useState)(null),l=(0,f.useRef)(null),m=b.length>4,n=m?b.slice(0,3):b.slice(0,4),o=m?b.slice(3):[],p=(0,e.jsxs)("button",{type:"button",onClick:()=>{d(),k(null)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("htmlApps.title"),children:[(0,e.jsx)("span",{className:"h-7 w-7 flex-shrink-0 rounded-md border border-border/70 bg-transparent flex items-center justify-center",children:(0,e.jsx)(v,{className:"w-4 h-4"})}),(0,e.jsx)("span",{className:"min-w-0 flex-1",children:(0,e.jsx)("span",{className:"block text-xs font-medium truncate",children:i("htmlApps.title")})})]},"html-apps-list"),q=a=>{h(a),k(null)},r=a=>(0,e.jsxs)("div",{className:"max-h-[19.75rem] overflow-y-auto p-1.5 space-y-1",children:[p,a.map(a=>(0,e.jsxs)("button",{type:"button",onClick:()=>q(a),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left hover:bg-hover transition-colors ${c===a.path?"text-brand":"text-muted-foreground hover:text-foreground"}`,title:a.path,children:[(0,e.jsx)("span",{className:"h-7 w-7 flex-shrink-0 rounded-md border border-border/70 bg-transparent flex items-center justify-center",children:a.icon?(0,e.jsx)("span",{className:"text-base leading-none",children:a.icon}):(0,e.jsx)(s.A,{className:"w-4 h-4"})}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"block text-xs font-medium truncate",children:a.title}),(0,e.jsx)("span",{className:"block text-[10px] font-mono text-muted-foreground truncate",children:a.path})]})]},a.path))]});return a?(0,e.jsxs)("div",{ref:l,className:"relative p-2 border-t border-border",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>"collapsed"===a?null:"collapsed"),className:`w-full h-8 rounded-md border bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 transition-colors flex items-center justify-center ${c?"border-brand/80 text-brand":"border-border/70"}`,title:i("htmlApps.title"),children:(0,e.jsx)(v,{className:"w-4 h-4"})}),"collapsed"===j&&(0,e.jsx)("div",{className:"absolute left-full bottom-0 ml-2 w-64 rounded-lg border border-border bg-card shadow-lv3 z-50",children:r(b)})]}):(0,e.jsx)("div",{ref:l,className:"p-2 border-t border-border",children:(0,e.jsxs)("div",{className:"grid grid-cols-5 gap-1.5",children:[(0,e.jsx)("button",{type:"button",onClick:d,className:"h-8 w-8 rounded-md border border-border/70 bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 active:scale-95 transition-all flex items-center justify-center",title:i("htmlApps.title"),children:(0,e.jsx)(v,{className:"w-4 h-4"})}),n.map(a=>(0,e.jsx)(w,{item:a,active:c===a.path,onClick:()=>q(a)},a.path)),m&&(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>"more"===a?null:"more"),className:"h-8 w-8 rounded-md border border-border/70 bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 transition-colors flex items-center justify-center",title:i("common.loadMore"),children:(0,e.jsx)(t.A,{className:"w-4 h-4"})}),"more"===j&&(0,e.jsx)("div",{className:"absolute left-0 bottom-full mb-2 w-64 rounded-lg border border-border bg-card shadow-lv3 z-50",children:r(o)})]})]})})}function y({projects:a,activeIndex:b,collapsed:c,currentCwd:d,onSelectProject:s,onRemoveProject:t,onReorderProjects:u,onToggleCollapse:v,onOpenSessionBrowser:w,onOpenSettings:A,onOpenNote:B,onOpenSkills:C,onOpenApps:D,htmlAppPreviews:E,activeHtmlAppPreviewPath:F,onShowHtmlAppPreview:G,onSwitchProject:H,onResolveSessionNumbers:I,sessionOrders:J,sessionNumbers:K}){let{t:L,i18n:M}=(0,g.Bd)(),{latest:N,hasUpdate:O}=(0,q.r)(),[P,Q]=(0,f.useState)(!1),R=(0,f.useRef)(null),S=(0,f.useCallback)(()=>{navigator.clipboard.writeText("cockpit update"),(0,o.oR)(L("workspace.upgradeCommandCopied")),Q(!1)},[L]),{isUpdating:T,start:U}=(0,r.P)(),V=(0,f.useCallback)(()=>{Q(!1),U()},[U]),{pinnedSessions:W,unpinSession:X,updateTitle:Y,reorder:Z}=(0,m.P)(),{tasks:$,unreadCount:_,reload:aa,pauseTask:ab,resumeTask:ac,triggerTask:ad,deleteTask:ae,updateTask:af,markRead:ag}=(0,n.nS)(),[ah,ai]=(0,f.useState)(null),[aj,ak]=(0,f.useState)(null),[al,am]=(0,f.useState)([]);(0,f.useRef)(al);let an=(0,f.useRef)(aa),ao=(0,f.useCallback)(a=>{try{if("task-fired"===a.type)return void an.current();let{data:b}=a;if(!b)return;am(b.sessions||[])}catch{}},[]);(0,p.h)({url:"/ws/global-state",onMessage:ao});let ap=new Set(al.filter(a=>"loading"===a.status).map(a=>a.cwd)),aq=new Set(al.filter(a=>"unread"===a.status).map(a=>a.cwd)),ar=(0,f.useMemo)(()=>{let b=new Map;for(let c of a){let a=J[c.cwd]??[],d=al.filter(a=>a.cwd===c.cwd).map(b=>({session:b,position:a.indexOf(b.sessionId)})).filter(({session:a,position:b})=>b>=0||"loading"===a.status||"unread"===a.status).sort((a,b)=>{let c=z(a.session.status)-z(b.session.status);return 0!==c?c:b.session.lastActive-a.session.lastActive}),e=d.find(({session:a})=>2===z(a.status)),f=d.filter(({session:a})=>2>z(a.status)||a===e?.session).slice(0,3).sort((a,b)=>a.position<0?b.position<0?0:1:b.position<0?-1:a.position-b.position).map(({session:a,position:b})=>({sessionId:a.sessionId,label:b>=0?String(b+1):"\xb7",status:"loading"===a.status?"loading":"unread"===a.status?"unread":"normal"}));f.length>0&&b.set(c.cwd,f)}return b},[a,al,J]),as=(0,f.useCallback)(a=>{ai(a)},[]),at=(0,f.useCallback)((a,b)=>{a.preventDefault(),null!==ah&&ah!==b&&ak(b)},[ah]),au=(0,f.useCallback)(b=>{if(null!==ah&&ah!==b){let c=[...a],[d]=c.splice(ah,1);c.splice(b,0,d),u(c)}ai(null),ak(null)},[ah,a,u]),av=(0,f.useCallback)(()=>{ai(null),ak(null)},[]);return(0,e.jsxs)("div",{className:`h-full bg-card border-r border-border flex flex-col transition-all duration-200 ${c?"w-12":"w-56"}`,children:[(0,e.jsxs)("div",{className:"group p-2 border-b border-border relative",children:[(0,e.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:w,title:c?L("workspace.openProject"):void 0,children:[(0,e.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),!c&&(0,e.jsx)("span",{className:"text-sm",children:L("workspace.openProject")})]}),c?(0,e.jsx)("button",{className:"absolute inset-0 m-2 flex items-center justify-center px-2 py-2 rounded-lg bg-popover shadow-lv1 text-foreground transition z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:v,title:L("workspace.expandSidebar"),children:(0,e.jsx)("svg",{className:"w-5 h-5 flex-shrink-0 rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}):(0,e.jsx)("button",{className:"absolute top-1/2 -translate-y-1/2 right-2 p-2 rounded-lg bg-popover shadow-lv1 text-foreground transition z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:v,title:L("workspace.collapseSidebar"),children:(0,e.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:a.map((a,d)=>{var f;let g;return(0,e.jsx)("div",{draggable:!0,onDragStart:()=>as(d),onDragOver:a=>at(a,d),onDrop:()=>au(d),onDragEnd:av,className:`${aj===d?"border-t-2 border-brand":""} ${ah===d?"opacity-50":""}`,children:(0,e.jsx)(i.ProjectItem,{index:d,name:(g=(f=a.cwd).split("/").filter(Boolean))[g.length-1]||f,cwd:a.cwd,isActive:d===b,collapsed:c,hasUnread:aq.has(a.cwd),isLoading:ap.has(a.cwd),sessionBadges:ar.get(a.cwd),onClick:()=>s(d),onSelectSession:b=>H(a.cwd,b),onRemove:()=>t(d),onOpenNote:()=>B(a.cwd)})},a.cwd)})}),(0,e.jsx)(x,{collapsed:c,previews:E,activePath:F,onOpenApps:D,onShowPreview:G}),(0,e.jsxs)("div",{className:"p-2 border-t border-border space-y-1",children:[(0,e.jsx)(j.e,{currentCwd:d,onSwitchProject:H,onResolveSessionNumbers:I,collapsed:c,sessions:al}),(0,e.jsx)(k._,{collapsed:c,pinnedSessions:W,sessionNumbers:K,currentCwd:d,onSwitchProject:H,onUnpin:X,onUpdateTitle:Y,onReorder:Z}),(0,e.jsx)(l.I,{collapsed:c,tasks:$,unreadCount:_,sessionNumbers:K,onSwitchProject:H,onPause:ab,onResume:ac,onTrigger:ad,onDelete:ae,onMarkRead:ag,onUpdateTask:af}),(0,e.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:C,title:c?L("workspace.skills"):void 0,children:[(0,e.jsx)(h.A,{className:"w-5 h-5 flex-shrink-0"}),!c&&(0,e.jsx)("span",{className:"text-sm",children:L("workspace.skills")})]}),(0,e.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:()=>B(),title:c?L("workspace.notes"):void 0,children:[(0,e.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),!c&&(0,e.jsx)("span",{className:"text-sm",children:L("workspace.notes")})]}),(0,e.jsxs)("div",{className:`relative flex items-center gap-2 px-2 py-2 rounded-lg cursor-pointer text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:A,title:L("workspace.settings"),children:[(0,e.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),c&&O&&(0,e.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500",title:N?L("workspace.updateAvailable",{version:N}):void 0})]}),!c&&(0,e.jsx)("span",{className:"flex-1 text-sm",children:L("workspace.settings")}),!c&&O&&N&&(0,e.jsxs)("div",{ref:R,className:"relative -mr-2",children:[(0,e.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),Q(a=>!a)},className:"px-1.5 py-0.5 rounded text-xs font-mono font-medium text-brand hover:bg-brand/10 transition-colors",title:L("workspace.updateAvailable",{version:N}),"aria-label":L("workspace.updateAvailable",{version:N}),children:["v",N]}),P&&(0,e.jsxs)("div",{className:"absolute left-full bottom-full ml-2 mb-1 w-56 rounded-lg border border-border bg-popover shadow-lv2 p-2 z-50",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-2 px-1",children:L("workspace.updateAvailable",{version:N})}),(0,e.jsxs)("button",{type:"button",onClick:V,disabled:T,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left\n hover:bg-hover transition-colors disabled:opacity-60 disabled:cursor-default",children:[T?(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:4}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("span",{className:"flex-1",children:T?L("workspace.updating"):L("workspace.updateNow")})]}),(0,e.jsxs)("button",{type:"button",onClick:S,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left hover:bg-hover transition-colors",children:[(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2}),(0,e.jsx)("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2})]}),(0,e.jsx)("span",{className:"flex-1",children:L("workspace.copyUpgradeCommand")})]}),(0,e.jsxs)("a",{href:`https://opencockpit.dev/${M.language?.startsWith("zh")?"zh":"en"}/changelog/`,target:"_blank",rel:"noopener",onClick:()=>Q(!1),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm hover:bg-hover transition-colors",children:[(0,e.jsx)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("span",{className:"flex-1",children:L("workspace.viewChangelog")}),(0,e.jsx)("svg",{className:"w-3 h-3 flex-shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]}),!c&&(0,e.jsx)("a",{href:`https://opencockpit.dev/${M.language?.startsWith("zh")?"zh":"en"}/docs/get-started/quickstart/`,target:"_blank",rel:"noopener",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",onClick:a=>a.stopPropagation(),title:L("workspace.help"),"aria-label":L("workspace.help"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),(0,e.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2})]})})]})]})]})}d()}catch(a){d(a)}})},9804:(a,b,c)=>{"use strict";function d(a,b){for(let c of a){if(c.path===b)return c;if(c.children){let a=d(c.children,b);if(a)return a}}return null}function e(a,b){if(!a)return"";let c=d(b,a);if(c?.isDirectory)return a;let e=a.split("/");return e.pop(),e.join("/")}function f(a){let b=[];for(let c of a){let a=c.split("/"),d=b;for(let b=0;b<a.length;b++){let c=a[b],e=b===a.length-1,f=a.slice(0,b+1).join("/"),g=d.find(a=>a.name===c);g||(g={name:c,path:f,isDirectory:!e,children:e?void 0:[]},d.push(g)),!e&&g.children&&(d=g.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>{a.children&&c(a.children)})};return c(b),b}function g(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),d.children&&c(d.children))};return c(a),b}c.d(b,{B_:()=>o,HR:()=>function a(b,c){if(0===c.length)return b;let d=new Map(c.map(a=>[a.path,a]));return b.map(b=>{let c=d.get(b.path);return c&&b.isDirectory?void 0===b.children&&void 0!==c.children?{...b,children:c.children}:void 0!==b.children&&void 0!==c.children?{...b,children:a(b.children,c.children)}:b:b})},KH:()=>k,MB:()=>d,S7:()=>e,fw:()=>l,q3:()=>j,r6:()=>m,tE:()=>n,tW:()=>g,u:()=>i,v3:()=>f});let h=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"]);function i(a){let b=a.split(".").pop()?.toLowerCase();return h.has(b||"")}function j(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase(),f=a=>{if(d.add(a.path),a.children)for(let b of a.children)f(b)},g=(a,b)=>{let h=a.name.toLowerCase(),i=c?h===e:h.includes(e);if(i&&a.children)return f(a),b.forEach(a=>d.add(a)),!0;let j=!1;if(a.children)for(let c of a.children)g(c,[...b,a.path])&&(j=!0);return(!!i||!!j)&&(d.add(a.path),b.forEach(a=>d.add(a)),!0)};for(let b of a)g(b,[]);return d}function k(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase();for(let b of a){let a=b.split("/");for(let b=0;b<a.length;b++){let f=a[b].toLowerCase();if(c?f===e:f.includes(e)){for(let b=0;b<=a.length-1;b++)d.add(a.slice(0,b+1).join("/"));break}}}return d}function l(a){let b=Math.floor(Math.floor((Date.now()-1e3*a)/1e3)/60),c=Math.floor(b/60),d=Math.floor(c/24),e=Math.floor(d/30),f=Math.floor(d/365);return f>0?`${f}y ago`:e>0?`${e}mo ago`:d>0?`${d}d ago`:c>0?`${c}h ago`:b>0?`${b}m ago`:"just now"}function m(a){let b=new Date(a),c=new Date,d=b.getFullYear()===c.getFullYear(),e=String(b.getMonth()+1).padStart(2,"0"),f=String(b.getDate()).padStart(2,"0"),g=String(b.getHours()).padStart(2,"0"),h=String(b.getMinutes()).padStart(2,"0");return d?`${e}-${f} ${g}:${h}`:`${b.getFullYear()}-${e}-${f} ${g}:${h}`}let n=()=>{},o=50},12568:(a,b,c)=>{"use strict";c.d(b,{ReviewDropdown:()=>o});var d=c(48249),e=c(67484),f=c(44384),g=c(29939),h=c(61130),i=c(79606),j=c(33281),k=c(83120);let l="review-last-viewed";function m(){try{return JSON.parse(localStorage.getItem(l)||"{}")}catch{return{}}}function n(a,b){if(!a.lastCommentAt)return!1;let c=b[a.id];return!c||a.lastCommentAt>c}function o({cwd:a}){let{t:b}=(0,f.Bd)(),[c,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)([]),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)({open:!1,comments:[],title:"",userNameMap:{}}),A=(0,e.useRef)(null),B=(0,e.useRef)(null),[C,D]=(0,e.useState)(null),E=(0,e.useCallback)(async()=>{t(!0);let a=await j.t4.runPromiseExit((0,k.Y_)());"Success"===a._tag&&r(a.value.reviews??[]),t(!1)},[]),F=(0,e.useCallback)(a=>{let{data:b}=a;Array.isArray(b)&&b.some(a=>"review"===a.type)&&E()},[E]);(0,g.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"/")}`,onMessage:F,enabled:!!a});let G=(0,e.useMemo)(()=>q.filter(a=>a.active),[q]),H=(0,e.useMemo)(()=>G.some(a=>n(a,w)),[G,w]),I=(0,e.useCallback)(a=>{let b;(b=m())[a]=Date.now(),localStorage.setItem(l,JSON.stringify(b)),x(m()),window.open(`${window.location.origin}/review/${a}`,"_blank")},[]),J=(0,e.useCallback)(async(a,b)=>{a.stopPropagation();let[c,d]=await Promise.all([j.t4.runPromiseExit((0,k.JK)(b)),j.t4.runPromiseExit((0,k.BL)())]);if("Success"!==c._tag)return;let e=c.value.review,f={};if("Success"===d._tag)for(let[a,b]of Object.entries(d.value.users))f[a]=b.name;z({open:!0,comments:e.comments||[],title:e.title??"",userNameMap:f})},[]),K=(0,e.useCallback)((a,b)=>{B.current=b,a.dataTransfer.effectAllowed="move";let c=a.currentTarget;requestAnimationFrame(()=>c.classList.add("opacity-30"))},[]),L=(0,e.useCallback)(a=>{B.current=null,D(null),a.currentTarget instanceof HTMLElement&&a.currentTarget.classList.remove("opacity-30")},[]),M=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",B.current&&B.current!==b&&D(b)},[]),N=(0,e.useCallback)((a,b)=>{a.preventDefault(),D(null);let c=B.current;B.current=null,c&&c!==b&&r(a=>{let d=[...a],e=d.findIndex(a=>a.id===c),f=d.findIndex(a=>a.id===b);if(-1===e||-1===f)return a;let[g]=d.splice(e,1);d.splice(f,0,g);let h=d.map(a=>a.id);return j.t4.runFork((0,k.z1)(h).pipe(i.NWQ(()=>i.rIH))),d})},[]);return(0,d.jsxs)("div",{ref:A,className:"relative",children:[(0,d.jsxs)("button",{onClick:()=>p(a=>!a),className:`relative p-2 rounded-lg transition-colors ${c?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:b("review.reviewManagement"),children:[(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),H&&(0,d.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full"})]}),c&&(0,d.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-popover border border-border rounded-lg shadow-lv3 z-50 overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:b("review.allReviews")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground/60 ml-1.5",children:G.length})]}),(0,d.jsx)("button",{onClick:E,className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",title:b("common.refresh"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("div",{className:"max-h-80 overflow-y-auto",children:s&&0===q.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("common.loading")}):0===G.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("review.noOpenReviews")}):G.map(a=>{let c,e,f,g,h,i=n(a,w);return(0,d.jsxs)("div",{draggable:!0,onDragStart:b=>K(b,a.id),onDragEnd:L,onDragOver:b=>M(b,a.id),onDrop:b=>N(b,a.id),onMouseEnter:b=>{let c=b.currentTarget.getBoundingClientRect();v({id:a.id,text:a.title,top:c.top+c.height/2,left:c.left})},onMouseLeave:()=>v(b=>b?.id===a.id?null:b),onClick:()=>I(a.id),className:`group px-3 py-2 cursor-pointer border-b transition-colors ${C===a.id?"border-b-brand border-t border-t-transparent":"border-b-border/50"} hover:bg-hover`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i?"bg-red-500":"bg-green-500"}`}),(0,d.jsx)("span",{className:`text-xs truncate flex-1 ${i?"font-medium text-foreground":""}`,children:a.title}),a.commentCount>0&&(0,d.jsx)("button",{onClick:b=>J(b,a.id),className:"flex-shrink-0 p-0.5 rounded text-muted-foreground/0 group-hover:text-muted-foreground/60 hover:!text-brand hover:!bg-brand/10 transition-colors",title:b("review.viewComments"),children:(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/50 mt-0.5 pl-3",children:[(0,d.jsx)("span",{children:(e=String((c=new Date(a.updatedAt||a.createdAt)).getMonth()+1).padStart(2,"0"),f=String(c.getDate()).padStart(2,"0"),g=String(c.getHours()).padStart(2,"0"),h=String(c.getMinutes()).padStart(2,"0"),`${e}-${f} ${g}:${h}`)}),a.commentCount>0&&(0,d.jsx)("span",{children:b("review.nComments",{count:a.commentCount})})]})]},a.id)})})]}),u&&c&&(0,d.jsx)("div",{className:"fixed z-[60] px-2 py-1 text-xs bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-nowrap pointer-events-none",style:{top:u.top,left:u.left-8,transform:"translate(-100%, -50%)"},children:u.text}),(0,d.jsx)(h.ReviewCommentsListModal,{isOpen:y.open,onClose:()=>z(a=>({...a,open:!1})),comments:y.comments,reviewTitle:y.title,userNameMap:y.userNameMap})]})}},13054:(a,b,c)=>{"use strict";c.d(b,{P_:()=>m,Q_:()=>n,nS:()=>p});var d=c(67484),e=c(57031),f=c(88214),g=c(79606),h=c(208),i=c(7833),j=c(33281),k=c(71192);let l=(a,b,c)=>g.$mh({try:async()=>{let d=await fetch(a,{method:b,headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw Error(`HTTP ${d.status}`);return await d.json()},catch:c=>new k.uV({message:`${b} ${a} failed`,cause:c})});function m(a){return a.split("/").pop()||a}function n(a){return a.resolvedPrompt||a.message||a.taskFile||""}function o(){(0,e.F)(f.n.ScheduledTasksChanged,{}),document.querySelectorAll("iframe").forEach(a=>{try{a.contentWindow?.postMessage({type:"SCHEDULED_TASKS_CHANGED"},"*")}catch{}})}function p(){let[a,b]=(0,d.useState)([]),[c,e]=(0,d.useState)(0),f=(0,d.useCallback)(()=>{let a;j.t4.runPromise((a="/api/scheduled-tasks",g.$mh({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:b=>new k.uV({message:`fetch ${a} failed`,cause:b})})).pipe(g.YWq({onSuccess:a=>{b(a.tasks??[]),e(a.unreadCount??0)},onFailure:()=>{}})))},[]),m=(0,d.useCallback)(async a=>{let b=await j.t4.runPromiseExit(l("/api/scheduled-tasks","POST",{language:h.A.language,...a}));if("Success"!==b._tag)return null;let c=b.value;return c.task?(f(),o(),c.task):null},[f]),n=(0,d.useCallback)(async a=>{await j.t4.runPromise(l("/api/scheduled-tasks","PATCH",a).pipe(g.NLW).pipe(g.NWQ(()=>g.rIH))),f(),o()},[f]),p=(0,d.useCallback)(a=>n({id:a,action:"pause"}),[n]),q=(0,d.useCallback)(a=>n({id:a,action:"resume"}),[n]),r=(0,d.useCallback)(async a=>{await j.t4.runPromise(l("/api/scheduled-tasks","DELETE",{id:a}).pipe(g.NLW).pipe(g.as(!0),g.DM4(()=>!1)))||(0,i.oR)(h.A.t("scheduledTasks.deleteFailed"),"error"),f(),o()},[f]),s=(0,d.useCallback)((a,b)=>n({id:a,action:"update",fields:{...b,language:h.A.language}}),[n]),t=(0,d.useCallback)(a=>n({id:a,action:"trigger"}),[n]),u=(0,d.useCallback)(a=>n({id:a,action:"markRead"}),[n]);return{tasks:a,unreadCount:c,reload:f,createTask:m,pauseTask:p,resumeTask:q,triggerTask:t,deleteTask:r,updateTask:s,markRead:u,markAllRead:(0,d.useCallback)(()=>n({action:"markAllRead"}),[n]),reorderTasks:(0,d.useCallback)(a=>n({action:"reorder",fields:{orderedIds:a}}),[n])}}},13265:(a,b,c)=>{"use strict";c.d(b,{i:()=>e});let d="http://cockpit.invalid";function e(a,b){let c;if(!a)return null;let e=a.trim();try{if(e.startsWith("/")){if((c=new URL(e,d)).origin!==d)return null}else if(!b||(c=new URL(e)).origin!==b)return null}catch{return null}if("/project"!==c.pathname)return null;let f=c.searchParams.get("cwd"),g=c.searchParams.get("sessionId");return f&&g?{cwd:f,sessionId:g}:null}},13512:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{d:()=>o,o:()=>n});var e=c(67484),f=c(36043),g=c(74754),h=c(91579),i=c(208),j=c(7031),k=c(38896),l=c(36984),m=c(37690);function n(a,b){let c,d=document.createTreeWalker(a,NodeFilter.SHOW_TEXT),e=b,f=null;for(;c=d.nextNode();){f=c;let a=c.textContent.length;if(e<=a)return{node:c,offset:e};e-=a}return f?{node:f,offset:f.textContent.length}:null}function o({content:a,filePath:b,showSearch:c=!0,cwd:d,enableComments:n=!1,scrollToLine:p=null,scrollToLineAlign:q="center",onScrollToLineComplete:r,visibleLineRef:s,onContentSearch:t}){let[u,v]=(0,e.useState)(!1),w=(0,e.useRef)(null),x=(0,e.useRef)(null),y=(0,e.useRef)(null),z=(0,j.r)(),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(null);(0,e.useRef)(null);let[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(""),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(0),[O,P]=(0,e.useState)(0),Q=(0,e.useRef)(!1),[R,S]=(0,e.useState)(null),T=(0,e.useRef)(!1),U=(0,e.useRef)(null),[V,W]=(0,e.useState)(null),[X,Y]=(0,e.useState)(null),Z=(0,e.useMemo)(()=>a.split("\n"),[a]),[$,_]=(0,e.useState)(null),aa=n&&!!d,{toolbarRef:ab,bumpRef:ac,clearToolbar:ad}=(0,m.L)({enabled:aa,container:$,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-line]");if(!c)return null;let d=parseInt(c.getAttribute("data-line")||"0",10);return!Number.isFinite(d)||d<=0?null:{start:d,end:d}},buildLineSnapshot:({start:a,end:b})=>Z.slice(a-1,b).join("\n")}),ae=(0,e.useRef)(null),[af,ag]=(0,e.useState)(0),{comments:ah,addComment:ai,updateComment:aj,deleteComment:ak,refresh:al}=(0,g._)({cwd:d||"",filePath:b}),am=(0,k.C)(Z,b),an=(0,e.useMemo)(()=>{let a=new Map;for(let b of ah){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[ah]),ao=(0,e.useMemo)(()=>{let a=new Set;for(let b of ah)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[ah]),ap=(0,e.useMemo)(()=>(0,l.Np)(Z,G,I,K),[Z,G,I,K]),aq=(0,e.useMemo)(()=>{let a=[];for(let b=0;b<Z.length;b++)a.push({type:"code",lineIndex:b});return a},[Z.length]),ar=(0,f.Te)({count:aq.length,getScrollElement:()=>w.current,estimateSize:()=>20,overscan:10}),as=(0,e.useCallback)(()=>{0!==ap.length&&(N(a=>(a+1)%ap.length),P(a=>a+1))},[ap.length]),at=(0,e.useCallback)(()=>{0!==ap.length&&(N(a=>(a-1+ap.length)%ap.length),P(a=>a+1))},[ap.length]);(0,e.useRef)(p).current=p;let au=(0,e.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?at():as()),"Escape"===a.key&&(F(!1),H(""))},[as,at]),av=(0,e.useCallback)((a,b)=>{aa&&(b.stopPropagation(),S({comment:a,x:b.clientX,y:b.clientY}),ad(),W(null),Y(null))},[aa,ad]),aw=(0,e.useCallback)(()=>{let a=ab.current;a&&(W({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ad())},[ad,ab]),ax=(0,e.useCallback)(()=>{let a=ab.current;a&&(Y({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ad())},[ad,ab]),ay=(0,e.useCallback)(()=>{let a=ab.current;a&&z&&(ad(),(0,h.Ff)(z.sendMessage,{filePath:b,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},i.A.t("explain.selectionMessage")))},[z,b,ad,ab]),az=(0,e.useCallback)(()=>{let a=ab.current;if(!a||!t)return;let b=a.selectedText.trim();ad(),b&&t(b)},[t,ad,ab]),aA=(0,e.useCallback)(async a=>{V&&(await ai(V.range.start,V.range.end,a,V.selectedText),W(null))},[V,ai]),aB=(0,e.useCallback)(async(a,c)=>{if(z&&d)try{let e=await (0,h.$3)(d),f=[];for(let a of e)f.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});f.push({filePath:b,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot});let g=(0,h.Gw)(f,c);z.sendMessage(g),await (0,h.RP)(d),al()}catch(a){console.error("Failed to send to AI:",a)}},[z,b,d,al]),aC=(0,e.useCallback)(a=>{X&&aB(X,a)},[X,aB]),aD=(0,e.useCallback)(a=>{V&&aB(V,a)},[V,aB]),aE=(0,e.useCallback)((a,b,c)=>{let d=Z[a];if(!d)return b;let e=[];if(G&&ap.length>0)for(let b of ap.filter(b=>b.lineIndex===a)){let c=ap[M]?.lineIndex===a&&ap[M]?.startCol===b.startCol;e.push({start:b.startCol,end:b.endCol,cls:c?"hl-cur":"hl-m"})}if(c&&!G&&c.length>=1){let a=c.toLowerCase(),b=d.toLowerCase(),f=0;for(;-1!==(f=b.indexOf(a,f));)e.push({start:f,end:f+c.length,cls:"hl-kw"}),f+=1}if(0===e.length)return b;if(e.sort((a,b)=>a.start-b.start||a.end-b.end),e.length>l.ZR){let a=e.findIndex(a=>"hl-cur"===a.cls),b=e.slice(0,l.ZR);a>=l.ZR&&(b[b.length-1]=e[a]),e=b}let f=[],g=0;for(let a of e){if(a.start<g)continue;a.start>g&&f.push((0,l.ZD)(d.substring(g,a.start)));let b=(0,l.ZD)(d.substring(a.start,a.end));f.push(`<span class="${a.cls}">${b}</span>`),g=a.end}g<d.length&&f.push((0,l.ZD)(d.substring(g)));let h=(0,l.ZD)(d);if(b!==h){let a=b;for(let b of e){let c=d.substring(b.start,b.end),e=(0,l.ZD)(c),f=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=RegExp(`(?<=>)([^<]*?)(${f})`,""),h=`$1<span class="${b.cls}">${e}</span>`,i=a.replace(g,h);i.length>a.length+200||(a=i)}return a}return f.join("")},[G,ap,M,Z]);return{parentRef:w,containerRef:x,searchInputRef:y,floatingToolbarRef:ab,suppressHoverRef:T,savedSelectionRef:U,highlightedLines:am,isMounted:u,cmdHeld:A,flashLine:C,isSearchVisible:E,searchQuery:G,caseSensitive:I,wholeWord:K,currentMatchIndex:M,viewingComment:R,bumpToolbarRef:ac,addCommentInput:V,sendToAIInput:X,aiBridge:z,commentsEnabled:aa,comments:ah,updateComment:aj,deleteComment:ak,lines:Z,matches:ap,rowData:aq,virtualizer:ar,commentsByEndLine:an,linesWithComments:ao,setIsSearchVisible:F,setSearchQuery:H,suppressMatchScrollRef:Q,setCaseSensitive:J,setWholeWord:L,setViewingComment:S,setAddCommentInput:W,setSendToAIInput:Y,goToNextMatch:as,goToPrevMatch:at,handleSearchKeyDown:au,handleCommentBubbleClick:av,handleToolbarAddComment:aw,handleToolbarSendToAI:ax,handleToolbarExplain:ay,handleToolbarSearch:az,handleCommentSubmit:aA,handleSendToAISubmit:aC,handleCommentSendToAI:aD,getHighlightedLineHtml:aE,inlineBlameLineRef:ae,inlineBlameVersion:af}}d()}catch(a){d(a)}})},14222:(a,b,c)=>{"use strict";c.d(b,{c:()=>g,k:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g({value:a,children:b}){return(0,d.jsx)(f.Provider,{value:a,children:b})}function h(){return(0,e.useContext)(f)}},15105:(a,b,c)=>{"use strict";c.d(b,{G:()=>l,f:()=>m});var d=c(67484);function e(){if("u"<typeof document)return null;let a=document.querySelector('meta[name="cockpit-bridge"]');if(!a)return null;let b=a.dataset.id,c=a.dataset.version;return b?{id:b,version:c||"unknown"}:null}let f=null,g=new Set;function h(){g.forEach(a=>a())}function i(a){g.add(a);let b=e();return b&&!f&&(f=b,Promise.resolve().then(h)),()=>{g.delete(a)}}function j(){return f}function k(){return null}if("u">typeof document&&(f=e()),"u">typeof MutationObserver&&"u">typeof document){let a=new MutationObserver(()=>{let a=e();a&&(!f||a.id!==f.id||a.version!==f.version)&&(f=a,h())}),b=document.head||document.documentElement;b&&a.observe(b,{childList:!0})}function l(){return(0,d.useSyncExternalStore)(i,j,k)}function m(){return f??e()}},15466:(a,b,c)=>{"use strict";function d(a){return a.trim().toLowerCase().replace(/[\s]+/g,"-").replace(/[^\w一-鿿぀-ヿ가-힯-]/g,"").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"")}function e(a,b){if(!a)return!1;let c=b;try{c=decodeURIComponent(b)}catch{}let e=d(c);if(!e)return!1;for(let b of a.querySelectorAll("h1, h2, h3, h4, h5, h6"))if(d(b.textContent||"")===e)return b.scrollIntoView({behavior:"smooth",block:"start"}),!0;return!1}c.d(b,{O:()=>e})},15578:(a,b,c)=>{"use strict";c.d(b,{S:()=>g,q:()=>f});let d=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],e=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function f(a){return d.some(b=>b.test(a))?"test":e.some(b=>b.test(a))?"docs":null}function g(a){if(0===a.length)return null;let b=f(a[0]);return null===b?null:a.every(a=>f(a)===b)?b:null}},15790:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{x:()=>k});var e=c(48249),f=c(67484),g=c(44384);c(33281);var h=c(2929);c(81206);var i=c(13054),j=a([h]);function k({task:a,onOpenSession:b}){let{t:c}=(0,g.Bd)(),{cwd:d,sessionId:j}=a,[l,m]=(0,f.useState)(null);(0,f.useRef)(void 0);let n=(0,f.useRef)(null),o=(0,f.useRef)(null),p=(0,f.useRef)(!0),[q,r]=(0,f.useState)(!0),s=(0,f.useCallback)(()=>{let a=n.current;if(!a)return;let b=a.scrollTop+a.clientHeight>=a.scrollHeight-40;p.current=b,r(b||a.scrollTop<=40)},[]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[(0,e.jsx)("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border flex-shrink-0",children:(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":d,children:(0,i.P_)(d)}),(0,e.jsx)("div",{className:"text-[11px] text-muted-foreground truncate","data-tooltip":(0,i.Q_)(a),children:(0,i.Q_)(a)})]})}),(0,e.jsxs)("div",{className:"relative flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:n,onScroll:s,className:"flex-1 overflow-y-auto px-8 py-4",children:null===l||0===l.length?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:c(null===l?"common.loading":"scheduledTasks.noTaskMessages")}):(0,e.jsx)("div",{ref:o,className:"mx-auto w-full max-w-[var(--chat-column)] [&_a]:pointer-events-none",children:l.map(a=>(0,e.jsx)(h.s,{message:a,cwd:d,disableOverlays:!0},a.id))})}),(0,e.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pb-4",children:(0,e.jsxs)("button",{onClick:b,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-brand text-white text-sm font-medium shadow-lv3 hover:bg-brand/90 transition-opacity ${q?"opacity-100 pointer-events-auto":"opacity-0"}`,title:c("scheduledTasks.openSession"),children:[(0,e.jsx)("span",{children:c("scheduledTasks.openSession")}),(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7-7 7M3 12h18"})})]})})]})]})}h=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},15819:(a,b,c)=>{"use strict";c.d(b,{aO:()=>d,iG:()=>e,jL:()=>f});let d="relative w-full max-w-[calc((100vw_-_28rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",e="relative w-full max-w-[calc((100vw_-_14rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",f="grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-3"},16618:(a,b,c)=>{"use strict";function d(a){let b=0xdeadbeef,c=0x41c6ce57;for(let d=0;d<a.length;d++){let e=a.charCodeAt(d);b=Math.imul(b^e,0x9e3779b1),c=Math.imul(c^e,0x5f356495)}return b=Math.imul(b^b>>>16,0x85ebca6b)^Math.imul(c^c>>>13,0xc2b2ae35),(0x100000000*(2097151&(c=Math.imul(c^c>>>16,0x85ebca6b)^Math.imul(b^b>>>13,0xc2b2ae35)))+(b>>>0)>>>0).toString(16)}function e(a){return a.replace(/\s+/g," ").trim()}function f(a,b){return a?`${a}>${b}`:b}function g(a){let b=a.childForFieldName("name");if(b)return b.text;for(let b=0;b<a.namedChildCount;b++){let c=a.namedChild(b);if(c&&("identifier"===c.type||"type_identifier"===c.type||"property_identifier"===c.type))return c.text}return"<anonymous>"}function h(a,b,c,g,i=[],j){return{qualifiedName:f(g,b),name:b,kind:c,startLine:a.startPosition.row+1,endLine:a.endPosition.row+1,contentHash:d(e(a.text)),children:i,params:j}}function i(a){let b=a.childForFieldName("parameter");if(b)return[b.text];let c=a.childForFieldName("parameters");if(!c)return;let d=[];for(let a=0;a<c.namedChildCount;a++){let b=c.namedChild(a);b&&d.push(function a(b){switch(b.type){case"required_parameter":case"optional_parameter":{let c=b.childForFieldName("pattern");return c?a(c):b.text}case"assignment_pattern":{let c=b.childForFieldName("left");return c?a(c):b.text}case"default_parameter":case"typed_default_parameter":{let a=b.childForFieldName("name");return a?a.text:b.text}case"typed_parameter":for(let a=0;a<b.namedChildCount;a++){let c=b.namedChild(a);if(c?.type==="identifier")return c.text}return b.text;default:return b.text}}(b))}return d}c.d(b,{Hs:()=>k});let j={theorem:"function",def:"function",abbrev:"function",example:"function",instance:"const",structure:"class",inductive:"type",axiom:"const",opaque:"const",constant:"const"};function k(a,b){var c;let k,l,m=[],n=function(a){let b=[],c=-1,f=-1;for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(e){if("import_statement"===e.type||"export_statement"===e.type&&null!==e.childForFieldName("source")||"import_from_statement"===e.type||"future_import_statement"===e.type||"import"===e.type)b.push(e),c<0&&(c=e.startPosition.row+1),f=e.endPosition.row+1;else if(c>=0)break}}return c<0?null:{qualifiedName:"__imports__",name:"imports",kind:"unknown",startLine:c,endLine:f,contentHash:d(e(b.map(a=>a.text).join("\n"))),children:[]}}(a);if(n&&m.push(n),"lean"===b)m.push(...function(a){let b=[],c=[];for(let f=0;f<a.namedChildCount;f++){let g=a.namedChild(f);if(!g)continue;switch(g.type){case"namespace":c.push(g.childForFieldName("name")?.text??null);continue;case"section":c.push(null);continue;case"end":c.pop();continue}let h=null;if("declaration"===g.type)for(let a=0;a<g.namedChildCount;a++){let b=g.namedChild(a);if(b&&b.type in j){h=b;break}}else g.type in j&&(h=g);if(!h)continue;let i=h.childForFieldName("name")?.text??h.type,k=c.filter(a=>null!==a);b.push({qualifiedName:[...k,i].join("."),name:i,kind:j[h.type],startLine:g.startPosition.row+1,endLine:function(a){let b=a.endPosition.row+1,c=a.text.replace(/\s+$/,""),d=a.text.slice(c.length);if(!d)return b;let e=d.split("\n").length-1;return Math.max(a.startPosition.row+1,b-e)}(g),contentHash:d(e(g.text)),children:[]})}return b}(a));else for(let b=0;b<a.namedChildCount;b++){let c=a.namedChild(b);c&&m.push(...function a(b,c,j=!1){switch(b.type){case"export_statement":case"export_default_declaration":{let d=[];for(let e=0;e<b.namedChildCount;e++){let f=b.namedChild(e);f&&d.push(...a(f,c,!0))}return d}case"function_declaration":case"generator_function_declaration":case"function_definition":return[h(b,g(b),"function",c,[],i(b))];case"class_declaration":case"abstract_class_declaration":{let a=g(b),d=f(c,a),e=function(a,b){if(!a)return[];let c=[];for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(e){if("method_definition"===e.type)c.push(h(e,g(e),"method",b,[],i(e)));else if("public_field_definition"===e.type){let a=e.childForFieldName("value");a&&("arrow_function"===a.type||"function_expression"===a.type)&&c.push(h(e,g(e),"method",b,[],i(a)))}}}return c}(b.childForFieldName("body"),d);return[h(b,a,"class",c,e)]}case"interface_declaration":return[h(b,g(b),"interface",c)];case"type_alias_declaration":return[h(b,g(b),"type",c)];case"enum_declaration":return[h(b,g(b),"enum",c)];case"lexical_declaration":case"variable_declaration":return function(a,b){let c=[];for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(!e||"variable_declarator"!==e.type)continue;let f=e.childForFieldName("name"),j=e.childForFieldName("value");if(!f)continue;let k=f.text,l=j&&("arrow_function"===j.type||"function_expression"===j.type),m=l&&j?i(j):void 0;if(c.push(h(a,k,l?"function":"const",b,[],m)),j&&"object"===j.type&&!l){let a=b?`${b}>${k}`:k;for(let b=0;b<j.namedChildCount;b++){let d=j.namedChild(b);if(d){if("pair"===d.type){let b=d.childForFieldName("key"),e=d.childForFieldName("value");if(!b||!e||"property_identifier"!==b.type&&"identifier"!==b.type||"arrow_function"!==e.type&&"function_expression"!==e.type)continue;c.push(h(d,b.text,"method",a,[],i(e)))}else if("method_definition"===d.type){let b=g(d);b&&c.push(h(d,b,"method",a,[],i(d)))}}}}}return c}(b,c);case"class_definition":{let a=g(b),j=f(c,a),k=function a(b,c){if(!b)return[];let j=[];for(let k=0;k<b.namedChildCount;k++){let l=b.namedChild(k);if(l){if("function_definition"===l.type)j.push(h(l,g(l),"method",c,[],i(l)));else if("decorated_definition"===l.type){let b=l.childForFieldName("definition");if(b?.type==="function_definition")j.push({...h(b,g(b),"method",c,[],i(b)),startLine:l.startPosition.row+1,contentHash:d(e(l.text))});else if(b?.type==="class_definition"){let i=g(b),k=f(c,i),m=a(b.childForFieldName("body"),k);j.push({...h(b,i,"class",c,m),startLine:l.startPosition.row+1,contentHash:d(e(l.text))})}}else if("class_definition"===l.type){let b=g(l),d=f(c,b),e=a(l.childForFieldName("body"),d);j.push(h(l,b,"class",c,e))}}}return j}(b.childForFieldName("body"),j);return[h(b,a,"class",c,k)]}case"decorated_definition":{let f=b.childForFieldName("definition");if(!f)return[];return a(f,c,!1).map(a=>({...a,startLine:b.startPosition.row+1,contentHash:d(e(b.text))}))}case"expression_statement":{let a=[];for(let g=0;g<b.namedChildCount;g++){let h=b.namedChild(g);if(h?.type==="assignment"){let g=function(a,b,c){let g=b.childForFieldName("left");if(!g||"identifier"!==g.type)return null;let h=g.text;return{qualifiedName:f(c,h),name:h,kind:"const",startLine:a.startPosition.row+1,endLine:a.endPosition.row+1,contentHash:d(e(a.text)),children:[]}}(b,h,c);g&&a.push(g)}}return a.push(...function(a,b){let c=null;for(let b=0;b<a.namedChildCount;b++){let d=a.namedChild(b);if(d){if("call_expression"===d.type){c=d;break}if("await_expression"===d.type){for(let a=0;a<d.namedChildCount;a++){let b=d.namedChild(a);if(b?.type==="call_expression"){c=b;break}}break}}}if(!c)return[];let d=c.childForFieldName("function"),e=c.childForFieldName("arguments");if(!d||!e)return[];let f=null,g=[];for(let a=0;a<e.namedChildCount;a++){let b=e.namedChild(a);if(b){if(null===f&&("string"===b.type||"template_string"===b.type)){let a=b.text;f=a.length>=2&&/^["'`]/.test(a)?a.slice(1,-1):a}("arrow_function"===b.type||"function_expression"===b.type)&&g.push(b)}}if(0===g.length||!f)return[];let j=function a(b){if("identifier"===b.type)return b.text;if("member_expression"===b.type){let a=b.childForFieldName("property");return a?.text??""}if("call_expression"===b.type){let c=b.childForFieldName("function");return c?a(c):""}return""}(d),k=j?`${j} ${f}`:f;return g.map((a,c)=>h(a,g.length>1?`${k} #${c+1}`:k,"function",b,[],i(a)))}(b,c)),a}default:return[]}}(c,void 0,!1))}return!function(a,b){let c=new Map;for(let b=0;b<a.namedChildCount;b++){let d=a.namedChild(b);d&&d.type.endsWith("comment")&&c.set(d.endPosition.row+1,d)}if(0===c.size)return;let d=new Set;for(let a of b)for(let b=a.startLine;b<=a.endLine;b++)d.add(b);for(let a of b){if("unknown"===a.kind)continue;let b=a.startLine;for(;;){let a=c.get(b-1);if(!a)break;let e=a.startPosition.row+1,f=!1;for(let a=e;a<=b-1;a++)if(d.has(a)){f=!0;break}if(f)break;b=e}if(b!==a.startLine){for(let c=b;c<a.startLine;c++)d.add(c);a.startLine=b}}}(a,m),m.push(...function(a,b){let c=a.text.split("\n"),f=c.length;if(0===f)return[];let g=new Uint8Array(f+2);for(let a of b){let b=Math.max(1,a.startLine),c=Math.min(f,a.endLine);for(let a=b;a<=c;a++)g[a]=1}let h=[],i=(a,b)=>{let f=!1;for(let d=a;d<=b;d++){let a=c[d-1];if(a&&a.trim().length>0){f=!0;break}}if(!f)return;let g=c.slice(a-1,b).join("\n");h.push({qualifiedName:`__code_${a}_${b}__`,name:"code",kind:"unknown",startLine:a,endLine:b,contentHash:d(e(g)),children:[]})},j=-1;for(let a=1;a<=f;a++)g[a]?j>=0&&(i(j,a-1),j=-1):j<0&&(j=a);return j>=0&&i(j,f),h}(a,m)),c=m,k=new Map,(l=a=>{for(let b of a){let a=(k.get(b.qualifiedName)??0)+1;k.set(b.qualifiedName,a),a>1&&(b.qualifiedName=`${b.qualifiedName}#${a}`),l(b.children)}})(c),m}},16665:(a,b,c)=>{Promise.resolve().then(c.bind(c,55632)),Promise.resolve().then(c.bind(c,99829)),Promise.resolve().then(c.bind(c,24943)),Promise.resolve().then(c.bind(c,74837)),Promise.resolve().then(c.bind(c,85906)),Promise.resolve().then(c.bind(c,72399)),Promise.resolve().then(c.bind(c,25702)),Promise.resolve().then(c.bind(c,47938)),Promise.resolve().then(c.bind(c,19562)),Promise.resolve().then(c.bind(c,83022)),Promise.resolve().then(c.bind(c,6612)),Promise.resolve().then(c.bind(c,93448)),Promise.resolve().then(c.bind(c,65395)),Promise.resolve().then(c.bind(c,84747))},17966:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{i:()=>m});var e=c(32580),f=c(16618),g=c(84398),h=c(4263),i=a([h]);function j(a){return a.qualifiedName.startsWith("__code_")||a.qualifiedName.startsWith("__heading_")}function k(a){return!j(a)&&"__file__"!==a.qualifiedName}async function l(a,b){if(!a)return[];let c=(0,g.k)(b);if(!c)return null;let d=(await (0,h.$)(c)).parse(a);if(!d)return null;try{return(0,f.Hs)(d.rootNode,c)}finally{d.delete()}}async function m(a,b,c,d,f){let h=new Set;if(a!==b)for(let c of(0,e.X)(d?"":a,f?"":b))"added"===c.type&&void 0!==c.newLineNum&&h.add(c.newLineNum);if(!(0,g.k)(c))return{addedLines:h};let[i,m]=await Promise.all([l(d?"":a,c),l(f?"":b,c)]),n=m??[],o=function(a,b){let c=new Map;for(let b of a)c.set(b.qualifiedName,b);let d=new Map;for(let a of b)d.set(a.qualifiedName,a);let e=[];for(let a of b){let b=c.get(a.qualifiedName);b?b.contentHash!==a.contentHash&&e.push({id:`mod:${a.qualifiedName}`,changeKind:"modified",qname:a.qualifiedName}):e.push({id:`add:${a.qualifiedName}`,changeKind:"added",qname:a.qualifiedName})}for(let b of a)d.has(b.qualifiedName)||e.push({id:`del:${b.qualifiedName}`,changeKind:"deleted",qname:b.qualifiedName});return e}((i??[]).filter(k),n.filter(k)),p=new Set;for(let a of o)"deleted"!==a.changeKind&&p.add(a.qname);for(let a of function(a,b){if(0===b.size)return[];let c=[];for(let d of a)if(j(d)){for(let a of b)if(a>=d.startLine&&a<=d.endLine){c.push(d.qualifiedName);break}}return c}(n,h))p.add(a);return{changedQnames:p,addedLines:h}}h=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},18479:(a,b,c)=>{"use strict";c.d(b,{se:()=>h,xK:()=>g});var d=c(79606),e=c(71192);let f=a=>d.$mh({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),g=(a,b,c)=>f(`/api/snapshots?cwd=${encodeURIComponent(a)}&toolIds=${encodeURIComponent(b.join(","))}${c?`&sessionKey=${encodeURIComponent(c)}`:""}`).pipe(d.TjK(a=>a.commits??[])),h=(a,b,c)=>g(a,b,c).pipe(d.qIB(b=>d.Q7R(b.map(b=>{let c;return c=b.hash,f(`/api/snapshots/diff?cwd=${encodeURIComponent(a)}&commit=${encodeURIComponent(c)}`)}),{concurrency:4})))},18499:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{_:()=>l});var e=c(48249),f=c(67484),g=c(44384);c(79606),c(33281);var h=c(74228),i=c(32753);c(41224);var j=c(50508),k=a([j]);j=(k.then?(await k)():k)[0];let m=(a,b)=>`${a}
16
- ${b}`;function l({collapsed:a,pinnedSessions:b,sessionNumbers:c,currentCwd:d,onSwitchProject:k,onUnpin:n,onUpdateTitle:o,onReorder:p}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(!1),t=(0,f.useRef)(null),[u,v]=(0,f.useState)(null),[w,x]=(0,f.useState)(""),y=(0,f.useRef)(null),z=(0,j.o$)(),{show:A,hide:B}=z,[C,D]=(0,f.useState)(null),[E,F]=(0,f.useState)(null),[G,H]=(0,f.useState)({}),I=(0,f.useCallback)(a=>{u||(k(a.cwd,a.sessionId),s(!1))},[k,u]),J=(0,f.useCallback)((a,b)=>{b.stopPropagation(),B(),v(a.sessionId),x(a.customTitle||"")},[B]),K=(0,f.useCallback)(()=>{u&&w.trim()&&o(u,w.trim()),v(null)},[u,w,o]),L=(0,f.useCallback)(a=>{B(),D(a)},[B]),M=(0,f.useCallback)((a,b)=>{a.preventDefault(),F(b)},[]),N=(0,f.useCallback)(a=>{if(null===C||C===a){D(null),F(null);return}let c=[...b],[d]=c.splice(C,1);c.splice(a,0,d),p(c),D(null),F(null)},[C,b,p]),O=(0,f.useCallback)(()=>{D(null),F(null)},[]);return(0,e.jsxs)("div",{className:"relative",ref:t,children:[(0,e.jsxs)("button",{onClick:()=>s(!r),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${a?"w-full justify-center":"w-full"}`,title:a?q("sessions.favorites"):void 0,children:[(0,e.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),!a&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:q("sessions.favorites")}),a&&b.length>0&&(0,e.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-popover border border-border",children:b.length})]}),r&&(0,e.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lv2 z-50 flex flex-col",children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:(0,e.jsx)("span",{className:"text-sm font-medium",children:q("sessions.favorites")})}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:q("sessions.noFavorites")}):b.map((a,f)=>{let g=G[m(a.cwd,a.sessionId)],k=u===a.sessionId;return(0,e.jsxs)("div",{draggable:!0,onDragStart:()=>L(f),onDragOver:a=>M(a,f),onDrop:()=>N(f),onDragEnd:O,onClick:()=>I(a),onMouseEnter:b=>{k||A(g??{cwd:a.cwd,sessionId:a.sessionId,title:a.customTitle},b)},onMouseLeave:B,className:`group w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 cursor-pointer ${f!==b.length-1?"border-b border-border/50":""} ${d===a.cwd?"bg-accent/50":""} ${C===f?"opacity-50":""} ${E===f?"border-t-2 border-brand":""}`,children:[(0,e.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,e.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,e.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(i.S,{engine:g?.engine}),(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:(0,j.Qr)(a.cwd)}),g?.lastActive?(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(0,j.fw)(q,g.lastActive)}):null,(0,e.jsx)(h.l,{coordinate:c?.[m(a.cwd,a.sessionId)],status:(0,h.S)(g?.status),statusLabel:(0,j.Mm)(q,g?.status),className:"ml-auto"})]}),k?(0,e.jsx)("input",{ref:y,type:"text",value:w,onChange:a=>x(a.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||("Enter"===a.key&&K(),"Escape"===a.key&&v(null))},onBlur:K,onClick:a=>a.stopPropagation(),className:"w-full text-xs px-1 py-0.5 border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring mt-0.5"}):(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:a.customTitle||g?.title||a.sessionId.slice(0,8)}),!k&&g?.lastUserMessage&&(0,e.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:g.lastUserMessage})]}),!k&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:[(0,e.jsx)("button",{onClick:b=>J(a,b),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:q("sessions.editTitle"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),B(),n(a.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:q("sessions.removeFavorite"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},a.sessionId)})})]}),(0,e.jsx)(j.LD,{...z})]})}d()}catch(a){d(a)}})},18921:(a,b,c)=>{"use strict";c.d(b,{_:()=>i,o:()=>h});var d=c(67484),e=c.n(d),f=c(208);let g="json-search-highlight-style";function h(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[h,i]=(0,d.useState)(!1),[j,k]=(0,d.useState)(0),[l,m]=(0,d.useState)(0),n=(0,d.useRef)(null),o=(0,d.useRef)([]);(0,d.useCallback)(()=>{let b;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),o.current=[];let c=a.current;if(!c||!e){k(0),m(0);return}!function(){if(document.getElementById(g))return;let a=document.createElement("style");a.id=g,a.textContent="::highlight(json-search){background:var(--highlight)}::highlight(json-search-current){background:var(--highlight-current)}",document.head.appendChild(a)}();let d=c.textContent||"",f=h?e:e.toLowerCase(),i=h?d:d.toLowerCase(),j=[],l=0;for(;l<i.length;){let a=i.indexOf(f,l);if(-1===a)break;j.push([a,a+f.length]),l=a+1}if(0===j.length){k(0),m(0);return}let n=document.createTreeWalker(c,NodeFilter.SHOW_TEXT),p=0,q=0,r=[],s=null,t=0;for(;(b=n.nextNode())&&q<j.length;){let a=b.textContent?.length||0,c=p,d=p+a;for(;q<j.length;){let[a,e]=j[q];if(a>=d)break;if(!s)if(a>=c)(s=document.createRange()).setStart(b,a-c),t=e;else break;if(t<=d)s.setEnd(b,t-c),r.push(s),s=null,q++;else break}p=d}o.current=r,k(r.length),m(a=>r.length>0?Math.min(a,r.length-1):0),CSS.highlights&&r.length>0&&CSS.highlights.set("json-search",new Highlight(...r))},[a,e,h]);let p=(0,d.useCallback)((a,b)=>{let c=a.getBoundingClientRect();(b.top<c.top||b.bottom>c.bottom)&&(a.scrollTop+=b.top-c.top-c.height/2+b.height/2)},[]);(0,d.useCallback)(b=>{CSS.highlights?.delete("json-search-current");let c=o.current[b];if(!c||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(c));let d=c.getBoundingClientRect(),e=a.current?.parentElement;e&&p(e,d)},[a,p]);let q=(0,d.useCallback)(()=>{0!==j&&m(a=>(a+1)%j)},[j]),r=(0,d.useCallback)(()=>{0!==j&&m(a=>(a-1+j)%j)},[j]),s=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>n.current?.focus(),0)},[]),t=(0,d.useCallback)(()=>{c(!1),f(""),m(0)},[]),u=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?r():q()),"Escape"===a.key&&(a.preventDefault(),t())},[q,r,t]);return{isVisible:b,query:e,setQuery:f,caseSensitive:h,setCaseSensitive:i,matchCount:j,currentIndex:l,searchInputRef:n,open:s,close:t,goToNext:q,goToPrev:r,handleKeyDown:u}}function i({search:a}){return a.isVisible?e().createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},e().createElement("input",{ref:a.searchInputRef,type:"text",value:a.query,onChange:b=>a.setQuery(b.target.value),onKeyDown:a.handleKeyDown,placeholder:f.A.t("codeViewer.searchPlaceholder"),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"}),e().createElement("button",{onClick:()=>a.setCaseSensitive(a=>!a),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${a.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:f.A.t("codeViewer.caseSensitive")},"Aa"),e().createElement("span",{className:"text-xs text-muted-foreground"},a.matchCount>0?`${a.currentIndex+1}/${a.matchCount}`:f.A.t("common.noMatch")),e().createElement("button",{onClick:a.goToPrev,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.previous")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),e().createElement("button",{onClick:a.goToNext,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.next")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),e().createElement("button",{onClick:a.close,className:"p-1 rounded hover:bg-accent",title:f.A.t("common.close")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}},18946:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{X:()=>i});var e=c(48249),f=c(67484),g=c(58554),h=a([g]);function i({tabId:a,cwd:b,sessionId:c,engine:d,onEngineChange:h,ollamaModel:j,onOllamaModelChange:k,deepseekModel:l,onDeepseekModelChange:m,kimiModel:n,onKimiModelChange:o,glmModel:p,onGlmModelChange:q,claudeModel:r,onClaudeModelChange:s,claudeEffort:t,onClaudeEffortChange:u,claudeContextWindow:v,onClaudeContextWindowChange:w,claudeFastMode:x,onClaudeFastModeChange:y,claudeThinking:z,onClaudeThinkingChange:A,codexModel:B,onCodexModelChange:C,codexReasoningEffort:D,onCodexReasoningEffortChange:E,planMode:F,onPlanModeChange:G,noHistory:H,onNoHistoryChange:I,isActive:J,isFocused:K,peerTabId:L,peerSide:M,refreshSignal:N,onStateChange:O,onShowGitStatus:P,onOpenNote:Q,isFavorite:R,onToggleFavorite:S,onCreateScheduledTask:T,onOpenSession:U,onContentSearch:V,onShowFileDiff:W,onOpenFileLink:X}){let Y=(0,f.useCallback)(b=>{O(a,{isLoading:b})},[a,O]),Z=(0,f.useCallback)(b=>{O(a,{sessionId:b})},[a,O]),$=(0,f.useCallback)(b=>{O(a,{title:b})},[a,O]),_=(0,f.useCallback)(b=>{h?.(a,b)},[a,h]),aa=(0,f.useCallback)(b=>{k?.(a,b)},[a,k]),ab=(0,f.useCallback)(b=>{m?.(a,b)},[a,m]),ac=(0,f.useCallback)(b=>{o?.(a,b)},[a,o]),ad=(0,f.useCallback)(b=>{q?.(a,b)},[a,q]),ae=(0,f.useCallback)(b=>{s?.(a,b)},[a,s]),af=(0,f.useCallback)(b=>{u?.(a,b)},[a,u]),ag=(0,f.useCallback)(b=>{w?.(a,b)},[a,w]),ah=(0,f.useCallback)(b=>{y?.(a,b)},[a,y]),ai=(0,f.useCallback)(b=>{A?.(a,b)},[a,A]),aj=(0,f.useCallback)(b=>{C?.(a,b)},[a,C]),ak=(0,f.useCallback)(b=>{E?.(a,b)},[a,E]),al=(0,f.useCallback)(b=>{G?.(a,b)},[a,G]),am=(0,f.useCallback)(b=>{I?.(a,b)},[a,I]),an=(0,f.useCallback)(()=>{S?.(a)},[a,S]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:_,ollamaModel:j,onOllamaModelChange:aa,deepseekModel:l,onDeepseekModelChange:ab,kimiModel:n,onKimiModelChange:ac,glmModel:p,onGlmModelChange:ad,claudeModel:r,onClaudeModelChange:ae,claudeEffort:t,onClaudeEffortChange:af,claudeContextWindow:v,onClaudeContextWindowChange:ag,claudeFastMode:x,onClaudeFastModeChange:ah,claudeThinking:z,onClaudeThinkingChange:ai,codexModel:B,onCodexModelChange:aj,codexReasoningEffort:D,onCodexReasoningEffortChange:ak,planMode:F,onPlanModeChange:al,noHistory:H,onNoHistoryChange:am,hideHeader:!0,hideSidebar:!0,isActive:J,isFocused:K,peerTabId:L,peerSide:M,refreshSignal:N,onLoadingChange:Y,onSessionIdChange:Z,onTitleChange:$,onShowGitStatus:P,onOpenNote:Q,isFavorite:R,onToggleFavorite:c&&S?an:void 0,onCreateScheduledTask:T,onOpenSession:U,onContentSearch:V,onShowFileDiff:W,onOpenFileLink:X})}g=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},19545:(a,b,c)=>{"use strict";c.d(b,{Qe:()=>f,up:()=>e});var d=c(208);function e(a){return a.storage.markdown.getMarkdown()}function f(){return[{label:d.A.t("slashCommands.heading1"),icon:"H1",description:d.A.t("slashCommands.heading1Desc"),action:a=>a.chain().focus().toggleHeading({level:1}).run()},{label:d.A.t("slashCommands.heading2"),icon:"H2",description:d.A.t("slashCommands.heading2Desc"),action:a=>a.chain().focus().toggleHeading({level:2}).run()},{label:d.A.t("slashCommands.heading3"),icon:"H3",description:d.A.t("slashCommands.heading3Desc"),action:a=>a.chain().focus().toggleHeading({level:3}).run()},{label:d.A.t("slashCommands.bulletList"),icon:"•",description:d.A.t("slashCommands.bulletListDesc"),action:a=>a.chain().focus().toggleBulletList().run()},{label:d.A.t("slashCommands.orderedList"),icon:"1.",description:d.A.t("slashCommands.orderedListDesc"),action:a=>a.chain().focus().toggleOrderedList().run()},{label:d.A.t("slashCommands.taskList"),icon:"☑",description:d.A.t("slashCommands.taskListDesc"),action:a=>a.chain().focus().toggleTaskList().run()},{label:d.A.t("slashCommands.blockquote"),icon:"❝",description:d.A.t("slashCommands.blockquoteDesc"),action:a=>a.chain().focus().toggleBlockquote().run()},{label:d.A.t("slashCommands.codeBlock"),icon:"<>",description:d.A.t("slashCommands.codeBlockDesc"),action:a=>a.chain().focus().toggleCodeBlock().run()},{label:d.A.t("slashCommands.table"),icon:"▦",description:d.A.t("slashCommands.tableDesc"),action:a=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{label:d.A.t("slashCommands.horizontalRule"),icon:"──",description:d.A.t("slashCommands.horizontalRuleDesc"),action:a=>a.chain().focus().setHorizontalRule().run()},{label:d.A.t("slashCommands.link"),icon:"\uD83D\uDD17",description:d.A.t("slashCommands.linkDesc"),action:a=>{window.dispatchEvent(new CustomEvent("tiptap-insert-link"))}}]}f()},19562:(a,b,c)=>{"use strict";c.d(b,{SettingsModal:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call SettingsModal() from the server but SettingsModal is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/SettingsModal.tsx","SettingsModal")},19593:(a,b,c)=>{"use strict";c.d(b,{C0:()=>m});var d=c(48249),e=c(67484),f=c(10316),g=c(46674),h=c(72419),i=c(44218),j=c(44384);let k=/^-?[\d,]*\.?\d+%?$/;function l(a){return k.test(a)?parseFloat(a.replace(/,/g,"")):NaN}function m({content:a,filePath:b,className:c="",action:n}){let{t:o}=(0,j.Bd)(),[p,q]=(0,e.useState)(500),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(-1),[v,w]=(0,e.useState)(null),{header:x,body:y,columnCount:z}=(0,e.useMemo)(()=>{let c=(function(a,b){let c=[],d=[],e="",f=!1,g=!1,h=()=>{d.push(e),c.push(d),d=[],e="",g=!1};for(let c=0;c<a.length;c++){let i=a[c];if(f){if('"'!==i){e+=i;continue}'"'===a[c+1]?(e+='"',c++):f=!1;continue}if('"'===i&&""===e){f=!0,g=!0;continue}if(i===b){d.push(e),e="",g=!0;continue}if("\r"===i){"\n"===a[c+1]&&c++,h();continue}if("\n"===i){h();continue}e+=i,g=!0}return(g||""!==e||d.length>0)&&h(),c})(a,function(a,b){if(b&&/\.tsv$/i.test(b))return" ";let c=a.slice(0,65536),d={",":0,";":0," ":0,"|":0},e=!1,f=0;for(let a=0;a<c.length&&f<5;a++){let b=c[a];if('"'===b){e=!e;continue}if(!e){if("\n"===b){f++;continue}b in d&&d[b]++}}let g=Object.entries(d).sort((a,b)=>b[1]-a[1])[0];return g[1]>0?g[0]:","}(a,b)).filter(a=>a.length>1||""!==a[0]),d=c.reduce((a,b)=>Math.max(a,b.length),0),e=c.slice(1).map((a,b)=>({index:b,cells:a}));return{header:c[0]??[],body:e,columnCount:d}},[a,b]),A=(0,e.useMemo)(()=>{let a=r.trim().toLowerCase();return a?y.filter(b=>t>=0?(b.cells[t]??"").toLowerCase().includes(a):b.cells.some(b=>b.toLowerCase().includes(a))):y},[y,r,t]),B=(0,e.useMemo)(()=>{if(!v)return A;let a="asc"===v.dir?1:-1;return[...A].sort((b,c)=>(function(a,b,c){if(""===a||""===b)return a===b?0:""===a?1:-1;let d=l(a),e=l(b);return isNaN(d)||isNaN(e)?a.localeCompare(b,void 0,{numeric:!0})*c:(d-e)*c})(b.cells[v.col]??"",c.cells[v.col]??"",a))},[A,v]),C=(0,e.useCallback)(a=>{w(b=>b&&b.col===a?"asc"===b.dir?{col:a,dir:"desc"}:null:{col:a,dir:"asc"})},[]);if(0===z)return(0,d.jsx)("div",{className:`flex items-center justify-center ${c}`,children:(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:o("csv.empty")})});let D=B.slice(0,p);return(0,d.jsxs)("div",{className:`flex flex-col min-h-0 ${c}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-0.5 rounded border border-border bg-card focus-within:border-brand transition-colors",children:[(0,d.jsx)(f.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0","aria-hidden":!0}),(0,d.jsx)("input",{value:r,onChange:a=>s(a.target.value),placeholder:o("csv.filterPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs text-foreground placeholder:text-muted-foreground outline-none"}),r&&(0,d.jsx)("button",{onClick:()=>s(""),className:"text-muted-foreground hover:text-foreground flex-shrink-0",title:o("csv.clearFilter"),children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("select",{value:t,onChange:a=>u(Number(a.target.value)),className:"text-xs bg-card text-muted-foreground border border-border rounded px-1 py-1 max-w-[10rem] flex-shrink-0",title:o("csv.filterColumn"),children:[(0,d.jsx)("option",{value:-1,children:o("csv.allColumns")}),Array.from({length:z},(a,b)=>(0,d.jsx)("option",{value:b,children:x[b]||`#${b+1}`},b))]}),n&&(0,d.jsx)("button",{onClick:n.onClick,className:"text-xs px-2 py-1 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:n.label})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,d.jsxs)("table",{className:"text-xs border-collapse w-max min-w-full",children:[(0,d.jsx)("thead",{className:"sticky top-0 z-10",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"sticky left-0 z-20 bg-accent border-b border-r border-border px-2 py-1.5 text-right font-normal text-muted-foreground select-none",children:"#"}),Array.from({length:z},(a,b)=>(0,d.jsx)("th",{onClick:()=>C(b),className:"bg-accent border-b border-border px-2 py-1.5 text-left font-medium text-foreground whitespace-nowrap cursor-pointer select-none hover:bg-hover",title:o("csv.sortHint"),children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[x[b]??"",v?.col===b&&("asc"===v.dir?(0,d.jsx)(h.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}):(0,d.jsx)(i.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}))]})},b))]})}),(0,d.jsx)("tbody",{children:D.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-hover",children:[(0,d.jsx)("td",{className:"sticky left-0 bg-card border-b border-r border-border px-2 py-1 text-right text-muted-foreground tabular-nums select-none",children:a.index+1}),Array.from({length:z},(b,c)=>{let e=a.cells[c]??"";return(0,d.jsx)("td",{title:e.length>60?e:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${k.test(e)?"text-right tabular-nums":""}`,children:e},c)})]},a.index))})]}),0===D.length&&(0,d.jsx)("div",{className:"p-4 text-xs text-muted-foreground",children:o("csv.noMatch")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:[(0,d.jsx)("span",{children:A.length===y.length?o("csv.summary",{rows:y.length,cols:z}):o("csv.summaryFiltered",{rows:A.length,total:y.length,cols:z})}),D.length<B.length&&(0,d.jsx)("button",{onClick:()=>q(a=>a+500),className:"px-1.5 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:o("csv.loadMore",{shown:D.length,total:B.length})})]})]})}},20291:(a,b,c)=>{"use strict";c.d(b,{p:()=>i});var d=c(67484),e=c(208),f=c(79606),g=c(33281),h=c(71192);function i({cwd:a,onSearchComplete:b}){let[c,j]=(0,d.useState)(""),[k,l]=(0,d.useState)([]),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(new Set),[s,t]=(0,d.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[u,v]=(0,d.useState)(null),w=(0,d.useRef)(null),x=(0,d.useCallback)(async c=>{let d=c.trim();if(!d){l([]),v(null);return}if(d.length<2)return void p(e.A.t("fileBrowser.searchMinChars"));n(!0),p(null);let i=new URLSearchParams({cwd:a,q:c,caseSensitive:String(s.caseSensitive),wholeWord:String(s.wholeWord),regex:String(s.regex),fileType:s.fileType}),j=f.$mh({try:async()=>{let a=await fetch(`/api/files/search?${i}`),b=await a.json();if(b.error)throw Error(b.error);return b},catch:a=>new h.uV({message:"content search failed",cause:a})});await g.t4.runPromise(j.pipe(f.YWq({onSuccess:a=>{l(a.results),v({totalFiles:a.totalFiles,totalMatches:a.totalMatches,truncated:a.truncated}),r(new Set(a.results.map(a=>a.path))),a.results.length>0&&b?.()},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Search failed"),l([])}}))),n(!1)},[a,s,b]);return{contentSearchQuery:c,setContentSearchQuery:j,contentSearchResults:k,isSearching:m,searchError:o,searchExpandedPaths:q,searchOptions:s,setSearchOptions:t,searchStats:u,contentSearchInputRef:w,performContentSearch:x,handleSearchToggle:(0,d.useCallback)(a=>{r(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},20586:(a,b,c)=>{"use strict";c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(7122),i=c(61591);function j({status:a}){let{label:b,className:c}={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"}}[a]||{label:"?",className:"text-muted-foreground"};return(0,d.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let k=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=f===b.path,p=g.has(b.path),q=(0,e.useCallback)(()=>{b.isDirectory?k(b.path):h(b)},[b,h,k]),r=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);return b.isDirectory?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-hover cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)("span",{className:"text-foreground-subtle text-xs",children:p?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m,renderActions:n},b.path))]}):(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${o?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)(i.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,d.jsx)(j,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,d.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]}),n&&n(b)]})});function l({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:i,showChanges:j=!1,renderActions:m,emptyMessage:n,className:o,onExplain:p,explainDisabled:q}){let{t:r}=(0,g.Bd)(),s=n??r("gitFileTree.noFiles"),{contextMenu:t,showContextMenu:u,hideContextMenu:v}=(0,h.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:s}):(0,d.jsxs)("div",{className:o||"py-1",children:[a.map(a=>(0,d.jsx)(k,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:u,showChanges:j,renderActions:m},a.path)),t&&(0,d.jsx)(h.ft,{x:t.x,y:t.y,path:t.path,cwd:i,isDirectory:t.isDirectory,onClose:v,onExplain:p,explainDisabled:q})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},21482:(a,b,c)=>{"use strict";c.d(b,{D:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(46674);function h({results:a,loading:b,totalMatches:c,onSelect:i,onClose:j,scope:k,onScopeChange:l,selectedPath:m}){let{t:n}=(0,f.Bd)(),o=function(){let[a,b]=(0,e.useState)(new Map),[c,d]=(0,e.useState)(!1);return(0,e.useRef)(0),a}(),p="selected"===k?a.filter(a=>a.path===m):a,q=p.reduce((a,b)=>a+b.matches.length,0);return(0,d.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsxs)("span",{className:"text-xs font-medium text-foreground truncate",children:[n("searchResults.title")," ",!b&&n("searchResults.nMatches",{count:"selected"===k?q:c})]}),(0,d.jsxs)("div",{className:"flex items-center rounded border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,d.jsx)("button",{onClick:()=>l("selected"),className:`px-2 py-0.5 ${"selected"===k?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:n("searchResults.scopeSelected")}),(0,d.jsx)("button",{onClick:()=>l("all"),className:`px-2 py-0.5 border-l border-border ${"all"===k?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:n("searchResults.scopeAll")})]})]}),(0,d.jsx)("button",{onClick:j,className:"p-0.5 rounded hover:bg-hover text-muted-foreground flex-shrink-0",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.searching")}):0===p.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.noResults")}):p.map(a=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:a.path}),a.matches.map((b,c)=>{let e=`${a.path}:${b.lineNumber}`,f=o.get(e);return(0,d.jsxs)("button",{onClick:()=>i(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),f?(0,d.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:f}}):(0,d.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}c(36984)},21538:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(35208),i=c(39238),j=c(74691),k=c(60333),l=c(20586),m=c(46242),n=c(21787),o=c(9804),p=c(33281),q=c(85655),r=c(60591),s=c(18921),t=c(7031);c(57063);var u=a([h,i]);function v({isOpen:a,onClose:b,commit:c,cwd:d,embedded:u=!1,initialFilePath:w,onContentSearch:x,onLocateInTree:y}){let{t:z}=(0,g.Bd)(),[A,B]=(0,f.useState)([]),[C,D]=(0,f.useState)([]),[E,F]=(0,f.useState)(new Set),[G,H]=(0,f.useState)(null),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)(!1),[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)("compact"),[U,V]=(0,f.useState)("unified"),W=(0,f.useRef)(null),X=(0,s.o)(W),Y=(0,t.r)(),Z=c?.shortHash,$=(0,f.useCallback)(a=>{Z&&Y?.sendMessage(z("explain.commitFileMessage",{hash:Z,path:a}))},[Y,z,Z]),_=(0,f.useCallback)(a=>{c&&(H(a),N(!0),p.t4.runPromiseExit((0,q.Zi)(d,c.hash,a.path)).then(a=>{"Success"===a._tag?J(a.value):console.error(a.cause),N(!1)}))},[d,c]),aa=(0,f.useCallback)(a=>{F(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ab=(0,f.useMemo)(()=>{if(!c)return"";if(c.date){var a;let b,d,e,f,g,h,i;return a=c.date,b=new Date(a),d=new Date,e=b.getFullYear()===d.getFullYear(),f=String(b.getMonth()+1).padStart(2,"0"),g=String(b.getDate()).padStart(2,"0"),h=String(b.getHours()).padStart(2,"0"),i=String(b.getMinutes()).padStart(2,"0"),e?`${f}-${g} ${h}:${i}`:`${b.getFullYear()}-${f}-${g} ${h}:${i}`}return c.time?new Date(1e3*c.time).toLocaleString():""},[c]),ac=I?.filePath,ad=(0,f.useMemo)(()=>ac?(0,e.jsx)(n.d,{cwd:d,filePath:ac,onLocateInTree:y}):null,[d,ac,y]);if(!a||!c)return null;let ae=!!I&&(!0===I.isImage||(0,o.u)(I.filePath)),af=(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:c.subject}),c.body&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap mb-3 max-h-32 overflow-y-auto border-l-2 border-border pl-3",children:c.body}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:z("commitDetail.hash")}),(0,e.jsx)("span",{className:"font-mono bg-accent px-1.5 py-0.5 rounded",children:c.hash})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:z("commitDetail.author")}),(0,e.jsx)("span",{children:c.author}),(0,e.jsxs)("span",{className:"text-foreground-subtle",children:["<",c.authorEmail,">"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:z("commitDetail.date")}),(0,e.jsx)("span",{children:ab}),c.relativeDate&&(0,e.jsxs)("span",{className:"text-foreground-subtle",children:["(",c.relativeDate,")"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:z("commitDetail.files")}),(0,e.jsx)("span",{children:z("commitDetail.nChanges",{count:A.length})})]}),!ae&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(j.y,{value:S,onChange:T}),(0,e.jsx)(k.q,{value:U,onChange:V})]})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:K?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:z("commitDetail.loadingFiles")}):(0,e.jsx)(l.VO,{files:C,selectedPath:G?.path||null,expandedPaths:E,onSelect:a=>a.file&&_(a.file),onToggle:aa,cwd:d,showChanges:!0,emptyMessage:z("commitDetail.noFileChanges"),className:"py-1",onExplain:Y&&Z?$:void 0,explainDisabled:Y?.isLoading})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:M?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("commitDetail.loadingDiff")}):I?ae?(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:ad}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(m.M,{cwd:d,filePath:I.filePath,oldRev:I.oldRev??(I.isNew?null:`${c.hash}^1`),newRev:I.newRev??(I.isDeleted?null:c.hash)})})]}):"unified"===U?(0,e.jsx)(h.xU,{oldContent:I.oldContent,newContent:I.newContent,filePath:I.filePath,cwd:d,enableComments:!0,compact:"compact"===S,headerLeading:ad,onPreview:I.isDeleted?void 0:(0,r.aR)(I.filePath)?()=>R({content:I.newContent,filePath:I.filePath}):I.filePath.endsWith(".json")?()=>P({content:I.newContent,filePath:I.filePath}):void 0,previewLabel:(0,r.aR)(I.filePath)?z("common.preview"):z("common.readable"),onContentSearch:x}):(0,e.jsx)(h.xZ,{oldContent:I.oldContent,newContent:I.newContent,filePath:I.filePath,isNew:I.isNew,isDeleted:I.isDeleted,cwd:d,enableComments:!0,compact:"compact"===S,headerLeading:ad,onPreview:I.isDeleted?void 0:(0,r.aR)(I.filePath)?()=>R({content:I.newContent,filePath:I.filePath}):I.filePath.endsWith(".json")?()=>P({content:I.newContent,filePath:I.filePath}):void 0,previewLabel:(0,r.aR)(I.filePath)?z("common.preview"):z("common.readable"),onContentSearch:x}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("commitDetail.selectFileToView")})})]})]}),ag=O&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>P(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:O.filePath}),(0,e.jsx)("button",{onClick:()=>P(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(s._,{search:X}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{ref:W,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,r.xb)(O.content)})})]})}),ah=Q&&(0,e.jsx)(i.N,{filePath:Q.filePath,content:Q.content,cwd:d,onClose:()=>R(null)});return u?(0,e.jsxs)("div",{className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsx)("button",{onClick:b,className:"absolute top-2 right-2 z-10 p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:z("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),af,ag,ah]}):(0,e.jsx)("div",{className:"fixed inset-0 z-[60] bg-scrim",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card w-full h-full flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:z("commitDetail.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),af,ag,ah]})})}[h,i]=u.then?(await u)():u,d()}catch(a){d(a)}})},21672:(a,b,c)=>{"use strict";c.d(b,{D:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(46674);function h({references:a,loading:b,onSelect:c,onClose:i}){let{t:j}=(0,f.Bd)(),k=function(){let[a,b]=(0,e.useState)(new Map),[c,d]=(0,e.useState)(!1);return(0,e.useRef)(0),a}(),l=[],m=new Map;for(let b=0;b<a.length;b++){let c=a[b],d=m.get(c.file);void 0===d&&(d=l.length,m.set(c.file,d),l.push({file:c.file,items:[]})),l[d].items.push({ref:c,idx:b})}return(0,d.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[j("references.title")," ",!b&&`(${a.length})`]}),(0,d.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("references.searching")}):0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("references.notFound")}):l.map(({file:a,items:b})=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:a}),b.map(({ref:a,idx:b})=>(0,d.jsxs)("button",{onClick:()=>c(a),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:a.line}),k.has(b)?(0,d.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:k.get(b)}}):(0,d.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:a.lineText||""})]},`${a.line}-${a.column}-${b}`))]},a))})]})}c(36984)},21787:(a,b,c)=>{"use strict";c.d(b,{d:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(72529),h=c(7833);let i=(0,e.memo)(function({cwd:a,filePath:b,onLocateInTree:c}){let{t:e}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground truncate",title:b,children:b}),(0,d.jsx)(g.m,{content:e("common.copyAbsPath"),children:(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(e("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})}),c&&(0,d.jsx)(g.m,{content:e("fileBrowser.locateInTree"),children:(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),c(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})})]})})},23328:(a,b,c)=>{"use strict";c.d(b,{AJ:()=>q,Cb:()=>C,D0:()=>y,DN:()=>l,Jn:()=>j,MR:()=>m,Ok:()=>v,QF:()=>i,SN:()=>r,UV:()=>B,Vv:()=>t,Yj:()=>A,Yn:()=>z,bv:()=>s,cm:()=>n,cv:()=>u,jO:()=>w,tp:()=>x,uc:()=>p,y8:()=>o});var d=c(79606),e=c(71192);let f=a=>d.$mh({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>g(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>d.JkU(function*(){let c=new URLSearchParams({cwd:a});b&&c.set("tabId",b);let d=yield*f(`/api/terminal/env?${c}`);return{env:d.env||{},home:d.home||""}}),j=()=>f("/api/terminal/aliases").pipe(d.TjK(a=>a.aliases||{})),k=(a,b)=>`/api/terminal/bubble-order?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}`,l=(a,b)=>f(k(a,b)).pipe(d.TjK(a=>a.order||[])),m=(a,b)=>f(k(a,b)).pipe(d.TjK(a=>a.titles||{})),n=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,order:c,sourceId:d}),o=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,titles:{[c]:d}}),p=(a,b,c,d=100)=>f(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&page=${c}&pageSize=${d}`),q=(a,b,c,d)=>h("/api/terminal/history",{cwd:a,tabId:b,entry:c,sourceId:d}),r=(a,b,c,d)=>g(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&commandId=${encodeURIComponent(c)}${d?`&sourceId=${encodeURIComponent(d)}`:""}`,{method:"DELETE"}),s=(a,b,c,d,e)=>g("/api/terminal/history",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:b,id:c,fields:d,sourceId:e})}),t=a=>h("/api/terminal/env",a),u=a=>h("/api/terminal/aliases",{aliases:a}),v=a=>h("/api/terminal/register",a),w=a=>h("/api/terminal/unregister",a),x=a=>d.$mh({try:async()=>{let b=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"POST /api/terminal/autocomplete failed",cause:a})}),y=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),z=a=>h("/api/project-settings",a),A=()=>f("/api/services/config?scope=global"),B=a=>f(`/api/services/config?cwd=${encodeURIComponent(a)}`),C=a=>{let b;return b="/api/services/config",d.$mh({try:async()=>{let c=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:a=>new e.uV({message:`POST ${b} failed`,cause:a})})}},23389:(a,b,c)=>{"use strict";function d(a){return/^~(?=$|[/\\])/.test(a.trim())}function e(a,b){return b&&d(a)?b.replace(/[/\\]+$/,"")+a.trim().slice(1):a}c.d(b,{D:()=>e,P:()=>d})},23700:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(2929),k=c(81206),l=a([j]);function m({cwd:a,sessionId:b,toolCall:c,workflowRef:d,running:l,onClose:n}){let{t:o}=(0,g.Bd)(),[p,q]=(0,f.useState)(null),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),v=(0,f.useRef)(void 0),w=d?!!d.running:l??!c?.result;(0,f.useCallback)(async()=>{let e=await i.t4.runPromiseExit((0,k.z)({cwd:a,sessionId:b,...d?{workflowId:d.runId,workflowAgentId:d.agentId}:{toolUseId:c?.id},ifFingerprint:v.current}));if(u(!0),"Success"!==e._tag||!e.value)return;let f=e.value;f.fingerprint&&(v.current=f.fingerprint),!f.notModified&&(f.messages&&q(f.messages),f.subagent&&s(f.subagent))},[a,b,c?.id,d?.runId,d?.agentId]);let x=(0,f.useRef)(null),y=(0,f.useRef)(!0),z="string"==typeof c?.input?.description?c.input.description:"",A=d?d.label||"":[r?.agentType,z].filter(Boolean).join(" \xb7 ");return(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:a=>{a.stopPropagation(),n()},children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-base",children:"\uD83E\uDD16"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:o("chat.subagent")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[w&&(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("button",{onClick:n,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:o("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{ref:x,onScroll:()=>{let a=x.current;a&&(y.current=a.scrollTop+a.clientHeight>=a.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===p?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:o(t?"chat.subagentEmpty":"common.loading")}):p.map(c=>(0,e.jsx)(j.s,{message:c,cwd:a,sessionId:b},c.id))})]})})})}j=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},23734:(a,b,c)=>{"use strict";c.d(b,{R:()=>e,d:()=>f});var d=c(28031);let e=(a,b)=>({id:a,legacyType:b??a.replace(/-/g,"_").toUpperCase()}),f=d.Io("@cockpit/IframeBus")},23860:(a,b,c)=>{"use strict";c.d(b,{F:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return a}},23881:(a,b,c)=>{"use strict";c.d(b,{s:()=>i});var d=c(48249),e=c(67484),f=c(44384);function g(a){return a.replace(/^\([^)]+\)\s*/,"")}function h(a){let b=g(a),c=b.match(/^(?:function|const|let|var|class|interface|type|enum|async function)\s+([a-zA-Z_$][\w$]*)/);if(c)return c[1];let d=a.match(/\([^)]+\)\s+(?:[\w$]+\.)*([a-zA-Z_$][\w$]*)/);if(d)return d[1];let e=b.match(/([a-zA-Z_$][\w$]*)/);return e?e[1]:b.split(/[(\s:]/)[0]}let i=(0,e.forwardRef)(function({displayString:a,documentation:b,x:c,y:i,container:j,onMouseEnter:k,onMouseLeave:l,onFindReferences:m,onSearch:n,onExplain:o,explainDisabled:p},q){let{t:r}=(0,f.Bd)(),s=(0,e.useRef)(null);(0,e.useImperativeHandle)(q,()=>s.current,[]);let t=j.getBoundingClientRect(),u=c-t.left,v=i-t.top,w=(0,e.useMemo)(()=>g(a),[a]),x=(0,e.useMemo)(()=>(function(a){let b,c=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b/g,e=[],f=0,g=0,h=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b|"[^"]*"|'[^']*'|\b\d+\b/g;for(;null!==(b=h.exec(a));){b.index>f&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f,b.index)},g++));let h=b[0];/^["']/.test(h)?e.push((0,d.jsx)("span",{className:"text-green-11",children:h},g++)):/^\d+$/.test(h)?e.push((0,d.jsx)("span",{className:"text-orange-11",children:h},g++)):c.test(h)?(c.lastIndex=0,e.push((0,d.jsx)("span",{className:"text-violet-11",children:h},g++))):e.push((0,d.jsx)("span",{className:"text-foreground",children:h},g++)),f=b.index+h.length}return f<a.length&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f)},g++)),e})(w),[w]);return(0,e.useEffect)(()=>{if(!s.current)return;let a=s.current,b=j.getBoundingClientRect(),d=a.getBoundingClientRect(),e=c-b.left,f=i-b.top;e+d.width>b.width-8&&(e=b.width-d.width-8),e<8&&(e=8),f+d.height>b.height-8&&(f=f-d.height-24),a.style.left=`${e}px`,a.style.top=`${f}px`},[c,i,j]),(0,d.jsxs)("div",{ref:s,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-lv3 px-3 py-2 pointer-events-none",style:{left:u,top:v},children:[(0,d.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:x}),b&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:b})]}),(m||n||o)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1.5"}),(0,d.jsxs)("div",{className:"flex items-center gap-3 pointer-events-auto",onMouseEnter:k,onMouseLeave:l,children:[m&&(0,d.jsx)("button",{onClick:m,className:"text-[11px] text-brand hover:underline cursor-pointer",children:r("hoverTooltip.findReferences")}),n&&(0,d.jsx)("button",{onClick:()=>n(h(a)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:r("hoverTooltip.search")}),o&&(0,d.jsx)("button",{onClick:()=>o(h(a)),disabled:p,title:p?r("comments.aiResponding"):void 0,className:"text-[11px] text-brand hover:underline cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline",children:r("explain.action")})]})]})]})})},24680:(a,b,c)=>{"use strict";c.d(b,{l:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(72529);function h({content:a,containerRef:b,width:c="w-80"}){let{t:i}=(0,f.Bd)(),j=(0,e.useMemo)(()=>(function(a){let b=[],c=a.split("\n"),d=!1;for(let a=0;a<c.length;a++){let e=c[a];if(e.trimStart().startsWith("```")){d=!d;continue}if(d)continue;let f=/^(#{1,6})\s+(.+)$/.exec(e);f&&b.push({level:f[1].length,text:f[2].replace(/\s*#+\s*$/,"").replace(/\\([!-\/:-@[-`{-~])/g,"$1"),sourceLine:a+1})}return b})(a),[a]),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),o=(0,e.useCallback)(a=>{let c=b.current;if(!c)return;let d=c.querySelector(`h1[data-source-start="${a}"], h2[data-source-start="${a}"], h3[data-source-start="${a}"], h4[data-source-start="${a}"], h5[data-source-start="${a}"], h6[data-source-start="${a}"]`);d&&d.scrollIntoView({behavior:"smooth",block:"start"})},[b]);return 0===j.length?null:(0,d.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${k?"w-8":c}`,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border flex-shrink-0",children:[!k&&(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("editor.toc")}),(0,d.jsx)("button",{onClick:()=>l(a=>!a),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:i(k?"editor.expandToc":"editor.collapseToc"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k?(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}):(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),!k&&(0,d.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:j.map((a,b)=>(0,d.jsx)(g.m,{content:a.text,delay:400,children:(0,d.jsx)("button",{onClick:()=>o(a.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-hover ${m===a.sourceLine?"text-brand font-medium bg-brand/5":"text-muted-foreground"}`,style:{paddingLeft:`${(a.level-1)*12+8}px`},children:a.text})},b))})]})}},24724:(a,b,c)=>{"use strict";c.d(b,{h:()=>l});var d=c(48249),e=c(67484),f=c.n(e),g=c(36043),h=c(7122),i=c(61591);let j={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},k=f().memo(function({item:a,isSelected:b,isExpanded:c,isLoading:f,onSelect:g,onToggle:h,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=a,q=o?j[o]:null,r=(0,e.useCallback)(()=>{m.isDirectory?h(m.path):g(m.path)},[m.isDirectory,m.path,g,h]),s=(0,e.useCallback)(a=>{k(a,m.path,m.isDirectory)},[m.path,m.isDirectory,k]),t=!m.isDirectory&&(".env"===m.name||m.name.startsWith(".env.")),u=o?q.text:p?"text-amber-11":t?"text-yellow-600 dark:text-yellow-500":b&&!m.isDirectory?"text-brand":"text-foreground";return(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-hover ${b?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?f?(0,d.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,d.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,d.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${c?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,d.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,d.jsx)(i.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,d.jsx)("span",{className:`text-sm truncate flex-1 ${u}`,"data-tooltip":m.isSymlink&&m.symlinkTarget?`${m.path} → ${m.symlinkTarget}`:m.path,children:m.name}),m.isSymlink&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,d.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function l({files:a,selectedPath:b,expandedPaths:c,matchedPaths:f=null,gitStatusMap:i=null,loadingDirs:j,onSelect:m,onToggle:n,cwd:o,shouldScrollToSelected:p=!1,onScrolledToSelected:q,className:r,renderActions:s,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x,onExplain:y,explainDisabled:z}){let A=(0,e.useRef)(null),{contextMenu:B,showContextMenu:C,hideContextMenu:D}=(0,h.Ee)(),E=(0,e.useMemo)(()=>(function a(b,c,d,e=null,f=0){let g=[];for(let h of b){if(null!==d&&!d.has(h.path))continue;let b=e?.get(h.path),i=h.isDirectory?function(a,b){if(!b)return!1;let c=a+"/";for(let a of b.keys())if(a.startsWith(c))return!0;return!1}(h.path,e):void 0;g.push({node:h,level:f,gitStatus:b,hasChangedChildren:i}),h.isDirectory&&h.children&&c.has(h.path)&&g.push(...a(h.children,c,d,e,f+1))}return g})(a,c,f,i),[a,c,f,i]),F=(0,g.Te)({count:E.length,getScrollElement:()=>A.current,estimateSize:()=>26,overscan:10});return((0,e.useRef)(q).current=q,0===E.length)?(0,d.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,d.jsxs)("div",{ref:A,className:r||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,d.jsx)("div",{style:{height:`${F.getTotalSize()}px`,width:"100%",position:"relative"},children:F.getVirtualItems().map(a=>{let e=E[a.index];return(0,d.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,d.jsx)(k,{item:e,isSelected:b===e.node.path,isExpanded:c.has(e.node.path),isLoading:j?.has(e.node.path),onSelect:m,onToggle:n,onContextMenu:C,renderActions:s})},e.node.path)})}),B&&(0,d.jsx)(h.ft,{x:B.x,y:B.y,path:B.path,cwd:o,isDirectory:B.isDirectory,onClose:D,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x,onExplain:y,explainDisabled:z})]})}},24943:(a,b,c)=>{"use strict";c.d(b,{NoteModal:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteModal() from the server but NoteModal is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteModal.tsx","NoteModal")},25414:(a,b,c)=>{"use strict";function d(a,b,c){return b?a?c?`${a.replace(/\n+$/,"")}
17
-
18
- ${b}`:a+b:b:a}function e(a,b,c=!1){let d=a||[];if(!b)return d;let f=d[d.length-1];return c||f?.type!=="text"?[...d,{type:"text",text:b}]:[...d.slice(0,-1),{type:"text",text:f.text+b}]}function f(a){return null!=a.parent_tool_use_id}c.d(b,{FM:()=>k,Nn:()=>f,A7:()=>h,Uy:()=>i,fD:()=>j});let g=["task_started","task_progress","task_notification"];function h(a){return"system"===a.type&&g.includes(a.subtype??"")}function i(a,b){let c={status:"running",...a};return"task_notification"===b.subtype&&(c.status=b.status??"completed"),b.task_id&&(c.id=b.task_id),b.last_tool_name&&(c.lastToolName=b.last_tool_name),b.summary&&(c.summary=b.summary),"number"==typeof b.usage?.tool_uses&&(c.toolUses=b.usage.tool_uses),"number"==typeof b.usage?.duration_ms&&(c.durationMs=b.usage.duration_ms),c}function j(a){let b=!1,c=a.map(a=>a.toolCalls?.some(a=>a.task?.status==="running")?(b=!0,{...a,toolCalls:a.toolCalls.map(a=>a.task?.status==="running"?{...a,task:{...a.task,status:"unknown"}}:a)}):a);return b?c:a}function k(a,b,c){let{engine:g,assistantId:j}=c;if(f(b))return a;if(h(b)){let c=b.tool_use_id;if(!c||b.ambient)return a;let d=!1,e=a.map(a=>a.toolCalls?.some(a=>a.id===c)?(d=!0,{...a,toolCalls:a.toolCalls.map(a=>a.id===c?{...a,task:i(a.task,b)}:a)}):a);return d?e:a}if("stream_event"===b.type){let c=b.event;if(c?.type==="content_block_delta"&&c.delta?.type==="text_delta"&&c.delta.text){let b=c.delta.text;return a.map(a=>a.id===j?{...a,content:d(a.content||"",b,!!a.pendingTextBreak),parts:e(a.parts,b,!!a.pendingTextBreak),pendingTextBreak:!1}:a)}return a}if("assistant"===b.type){let c=b.message?.content;if(!Array.isArray(c))return a;let f=a,h=b.message?.model==="<synthetic>";if("codex"===g||"ollama"===g||h){let a=c.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("");a&&(f=f.map(b=>b.id===j?{...b,content:d(b.content||"",a,!!b.pendingTextBreak),parts:e(b.parts,a,!!b.pendingTextBreak),pendingTextBreak:!1}:b))}for(let a of c)if(a.name){let b={id:a.id||`tool-${j}-${a.name}`,name:a.name,input:a.input||{},isLoading:!0};f=f.map(a=>a.id!==j||a.toolCalls?.some(a=>a.id===b.id)?a:{...a,toolCalls:[...a.toolCalls||[],b],parts:function(a,b){let c=a||[];return c.some(a=>"tool"===a.type&&a.id===b)?c:[...c,{type:"tool",id:b}]}(a.parts,b.id),pendingTextBreak:!0})}return f}if("user"===b.type){let c=b.message?.content;if(!Array.isArray(c))return a;let d=a;for(let a of c)if(a.tool_use_id){let b=a.tool_use_id,c="string"==typeof a.content?a.content:JSON.stringify(a.content);d=d.map(a=>a.id===j?{...a,toolCalls:a.toolCalls?.map(a=>a.id===b?{...a,result:c,isLoading:!1}:a)}:a)}return d}if("error"===b.type){let c=b.error||"An error occurred. Please try again.",f=`⚠️ ${c}`;return a.map(a=>a.id===j?{...a,content:d(a.content||"",f,!0),parts:e(a.parts,f,!0),isStreaming:!1}:a)}if("result"===b.type){let c="string"==typeof b.result?b.result.trim():"";return a.map(a=>a.id===j?{...a,content:!a.content&&c?c:a.content,parts:!a.content&&c?e(a.parts,c):a.parts,isStreaming:!1,toolCalls:a.toolCalls?.map(a=>({...a,isLoading:!1}))}:a)}return a}},25419:(a,b,c)=>{"use strict";c.d(b,{K:()=>f});var d=c(79606),e=c(71192);let f=(a,b)=>{let c,f;return c=`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,f={cache:"no-store"},d.$mh({try:async()=>{let a=await fetch(c,f),b=null;try{b=await a.json()}catch{}return{status:a.status,ok:a.ok,data:b}},catch:a=>new e.uV({message:`GET ${c} failed`,cause:a})})}},25608:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ProjectItem:()=>n});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(40311),j=c(29939),k=c(85655);function l({number:a,status:b,isActive:c}){return(0,e.jsx)("span",{className:`flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-[4px] border font-mono text-[10px] font-medium leading-none tabular-nums transition-colors ${(0,i.c)(b,c)}`,"aria-hidden":"true",children:a})}function m({badge:a,onSelect:b}){return(0,e.jsx)("button",{type:"button",onClick:c=>{c.stopPropagation(),b(a.sessionId)},className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border font-mono text-[9px] font-medium leading-none tabular-nums transition-transform hover:scale-125 ${(0,i.c)(a.status,!1)}`,title:a.label,children:a.label})}let a=[],o=()=>{};function n({index:b,name:c,cwd:d,isActive:i,collapsed:p,hasUnread:q,isLoading:r,sessionBadges:s,onClick:t,onSelectSession:u,onRemove:v,onOpenNote:w}){let{t:x}=(0,g.Bd)(),[y,z]=(0,f.useState)(!1),[A,B]=(0,f.useState)(null),C=(0,f.useCallback)(()=>{h.t4.runPromiseExit((0,k.ue)(d)).then(a=>{"Success"===a._tag&&B(a.value.branch)})},[d]),D=(0,f.useCallback)(a=>{a?.type==="watch"&&Array.isArray(a.data)&&a.data.some(a=>"git"===a.type)&&C()},[C]);(0,j.h)({url:`/ws/watch?cwd=${encodeURIComponent(d)}`,onMessage:D});let E=s??a,F=A?p?`${c} \xb7 ${A}`:A:d;return(0,e.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${p?"justify-center":""} ${i?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:t,onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),"data-tooltip":F,children:[(0,e.jsx)(l,{number:b+1,status:p?r?"loading":q&&!i?"unread":"normal":"normal",isActive:i}),!p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:`flex-1 truncate text-sm ${i?"text-brand":""}`,children:c}),y&&(0,e.jsxs)("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[w&&(0,e.jsx)("button",{className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),w()},title:x("workspace.projectNotes"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,e.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-11 transition-colors",onClick:a=>{a.stopPropagation(),v()},title:x("workspace.closeProject"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),E.length>0&&(0,e.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0",children:E.map(a=>(0,e.jsx)(m,{badge:a,onSelect:u??o},a.sessionId))})]})]})}d()}catch(a){d(a)}})},25667:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>j});var e=c(48249),f=c(67484),g=c(72899);c(33281),c(85655);var h=c(17966),i=a([h]);function j({cwd:a,filePath:b,oldContent:c,newContent:d,isNew:h=!1,isDeleted:i=!1,changedFiles:k,fileGitStatusMap:l,enableComments:m=!1,compact:n=!0,onContentSearch:o,onSwitchToCode:p,headerExtraLeft:q,headerExtraRight:r}){let[s,t]=(0,f.useState)(b),[u,v]=(0,f.useState)(null);return(0,e.jsx)(g.O,{cwd:a,highlightedFilePath:b,changedFiles:k,enableComments:m,qnameFilter:n?u?.changedQnames:void 0,qnameFilterFile:s,accentQnames:u?.changedQnames,accentFile:s,addedLines:u?.addedLines,addedLinesFile:s,compact:n,onFocalChange:a=>a&&t(a),onContentSearch:o,onSwitchToCode:p,headerExtraLeft:q,headerExtraRight:r})}h=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},25702:(a,b,c)=>{"use strict";c.d(b,{Providers:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Providers() from the server but Providers is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/Providers.tsx","Providers")},26362:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{T:()=>q});var e=c(48249),f=c(67484),g=c(74429),h=c(74754),i=c(91579),j=c(208),k=c(7122),l=c(7031),m=c(41051),n=c(42140),o=c(70596),p=c(37690);function q({cwd:a,enableComments:b=!1,filePath:c,diffLines:d,containerEl:r,onContentSearch:s}){let t=(0,k.iN)(),u=(0,l.r)(),v=b&&!!a,{comments:w,addComment:x,updateComment:y,deleteComment:z,refresh:A}=(0,h._)({cwd:a||"",filePath:c}),[B,C]=(0,f.useState)(null),{toolbarRef:D,bumpRef:E,clearToolbar:F}=(0,p.L)({enabled:v,container:r,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-new-line]");if(!c)return null;let d=parseInt(c.getAttribute("data-new-line")||"0",10);return!Number.isFinite(d)||d<=0?null:{start:d,end:d}},buildLineSnapshot:({start:a,end:b})=>{let c=[],e=0;for(let f of d)("unchanged"===f.type||"added"===f.type)&&++e>=a&&e<=b&&c.push(f.content);return c.join("\n")}}),[G,H]=(0,f.useState)(null),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)(!1),M=(0,f.useMemo)(()=>{let a=new Set;for(let b of w)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[w]),N=(0,f.useMemo)(()=>{let a=new Map;for(let b of w){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[w]),O=(0,f.useCallback)((a,b)=>{b.stopPropagation(),C({comment:a,x:b.clientX,y:b.clientY}),F(),H(null),J(null)},[F]),P=(0,f.useCallback)(()=>{let a=D.current;a&&(H({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),F())},[F,D]),Q=(0,f.useCallback)(()=>{let a=D.current;a&&(J({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),F())},[F,D]),R=(0,f.useCallback)(()=>{let a=D.current;a&&u&&(F(),(0,i.Ff)(u.sendMessage,{filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},j.A.t("explain.selectionMessage")))},[u,c,F,D]),S=(0,f.useCallback)(()=>{let a=D.current;if(!a||!s)return;let b=a.selectedText.trim();F(),b&&s(b)},[s,F,D]),T=(0,f.useCallback)(async(b,d)=>{if(u&&a)try{let e=await (0,i.$3)(a),f=[];for(let a of e)f.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});f.push({filePath:c,startLine:b.range.start,endLine:b.range.end,codeContent:b.lineSnapshot});let g=(0,i.Gw)(f,d);u.sendMessage(g),await (0,i.RP)(a),A()}catch(a){console.error("Failed to send to AI:",a)}},[u,c,a,A]),U=(0,f.useCallback)(a=>{I&&T(I,a)},[I,T]),V=(0,f.useCallback)(a=>{G&&T(G,a)},[G,T]),W=(0,f.useCallback)(async a=>{G&&(await x(G.range.start,G.range.end,a,G.selectedText),H(null))},[G,x]),X=K&&t?(0,g.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.fS,{floatingToolbarRef:D,bumpRef:E,container:t,onAddComment:P,onSendToAI:Q,onSearch:s?S:void 0,onExplain:u?R:void 0,isChatLoading:u?.isLoading??!1}),G&&(0,e.jsx)(n.t,{x:G.x,y:G.y,range:G.range,filePath:c,lineSnapshot:G.lineSnapshot,container:t,onSubmit:W,onSendToAI:u?V:void 0,onClose:()=>H(null),isChatLoading:u?.isLoading}),I&&(0,e.jsx)(n.G,{x:I.x,y:I.y,range:I.range,filePath:c,lineSnapshot:I.lineSnapshot,container:t,onSubmit:U,onClose:()=>J(null),isChatLoading:u?.isLoading}),B&&(0,e.jsx)(o.t,{x:B.x,y:B.y,comment:B.comment,container:t,onClose:()=>C(null),onUpdateComment:y,onDeleteComment:z})]}),t):null;return{commentsEnabled:v,linesWithComments:M,commentsByEndLine:N,handleCommentBubbleClick:O,addCommentRange:G?.range??null,sendToAIRange:I?.range??null,commentPortal:X}}d()}catch(a){d(a)}})},28602:(a,b,c)=>{"use strict";function d(){return!("u"<typeof navigator)&&(/Mac|iPhone|iPad/.test(navigator.platform||"")||navigator.userAgentData?.platform==="macOS")}function e(){return d()?"⌘":"Ctrl+"}c.d(b,{L:()=>d,Mu:()=>e}),process.platform,process.platform,process.platform},28797:(a,b,c)=>{"use strict";function d(a){let b=a.split(".").pop()?.toLowerCase();return b?["ts","tsx","js","jsx","mjs","cjs"].includes(b)?"typescript":["py","pyi"].includes(b)?"python":null:null}c.d(b,{c:()=>d})},29412:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>p});var e=c(48249),f=c(67484),g=c(44384),h=c(37370),i=c(7833),j=c(15819),k=c(77156),l=c(59336),m=c(2633),n=c(33281),o=a([m]);function p({isOpen:a,onClose:b}){let{t:c,i18n:d}=(0,g.Bd)(),[h,o]=(0,f.useState)([]),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(""),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(""),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(null),D=(0,f.useRef)(null),E=(0,f.useCallback)(async()=>{s(!0);let a=await n.t4.runPromiseExit((0,k.Hy)());"Success"===a._tag?o(a.value):console.error("Failed to load skills",a.cause),s(!1)},[]),F=(0,f.useMemo)(()=>{let a=t.trim().toLowerCase();return a?h.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):h},[h,t]),G=d.resolvedLanguage?.startsWith("zh")?"https://opencockpit.dev/zh/docs/agent/skills/":"https://opencockpit.dev/en/docs/agent/skills/",H=(0,f.useCallback)(async()=>{let a=x.trim();if(!a)return;A(!0);let b=await n.t4.runPromiseExit((0,k.L5)(a));if("Success"===b._tag)(0,i.oR)(b.value.alreadyExists?c("skills.alreadyAdded"):c("skills.added"),b.value.alreadyExists?"info":"success"),y(""),w(!1),await E(),b.value.alreadyExists||(0,l.k)();else{let a="Fail"===b.cause._tag?b.cause.error:null,d=a?.cause,e=d instanceof Error?d.message:c("skills.addFailed");(0,i.oR)(e,"error")}A(!1)},[x,E,c]),I=(0,f.useCallback)(async a=>{let b=await n.t4.runPromiseExit((0,k.hp)(a));"Success"===b._tag?(o(b=>b.filter(b=>b.id!==a)),(0,l.k)()):(0,i.oR)(c("common.deleteFailed"),"error")},[c]),J=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,i.oR)(c("common.copiedPath"),"success")}catch{(0,i.oR)(c("common.copyFailed"),"error")}},[c]);return a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,e.jsxs)("div",{className:j.aO,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:c("skills.title")}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("input",{ref:D,type:"text",value:t,onChange:a=>u(a.target.value),placeholder:c("skills.searchPlaceholder"),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),t&&(0,e.jsx)("button",{onClick:()=>{u(""),D.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:c("skills.clearSearch"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("button",{onClick:()=>w(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:[(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),c("skills.addSkill")]}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:c("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:r?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:c("common.loading")}):0===F.length?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm space-y-2",children:0===h.length?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{children:c("skills.emptyNoSkills")}),(0,e.jsxs)("p",{children:[c("skills.emptyIntroPrefix")," ",(0,e.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/skillify"})," ",c("skills.emptyIntroSuffix")]}),(0,e.jsxs)("p",{children:[(0,e.jsx)("button",{type:"button",onClick:()=>w(!0),className:"text-brand hover:underline",children:c("skills.addSkill")})," \xb7 ",(0,e.jsx)("a",{href:G,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline",children:c("skills.viewDocs")})]})]}):c("skills.emptyNoMatch")}):(0,e.jsx)("div",{className:j.jL,children:F.map(a=>(0,e.jsx)(q,{skill:a,onPreview:()=>C(a.id),onDelete:()=>I(a.id),onCopyPath:()=>J(a.path)},a.id))})})]})]}),v&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:()=>{z||(w(!1),y(""))}}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-lg mx-4 p-5",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:c("skills.addSkill")}),(0,e.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:c("skills.pathLabel")}),(0,e.jsx)("input",{type:"text",value:x,onChange:a=>y(a.target.value),onKeyDown:a=>{"Enter"!==a.key||z||H()},placeholder:c("skills.pathPlaceholder"),autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,e.jsx)("button",{onClick:()=>{w(!1),y("")},disabled:z,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:c("common.cancel")}),(0,e.jsx)("button",{onClick:H,disabled:z||!x.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:z?c("skills.adding"):c("skills.add")})]})]})]}),B&&(0,e.jsx)(m.d,{skillId:B,onClose:()=>C(null)})]}):null}function q({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let{t:i}=(0,g.Bd)(),[j,k]=(0,f.useState)(!1);return(0,e.jsxs)("div",{onClick:a.valid?b:void 0,role:a.valid?"button":void 0,tabIndex:a.valid?0:void 0,onKeyDown:c=>{a.valid&&("Enter"===c.key||" "===c.key)&&(c.preventDefault(),b())},className:`group flex flex-col h-56 border border-border rounded-lg p-3 hover:border-brand hover:shadow-lv2 transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${a.valid?"cursor-pointer":"opacity-60"}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 flex-shrink-0",children:[(0,e.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:a.icon?(0,e.jsx)("span",{children:a.icon}):(0,e.jsx)(h.A,{className:"w-5 h-5"})}),(0,e.jsxs)("span",{className:"font-mono text-sm font-medium text-foreground truncate flex-1 min-w-0","data-tooltip":`/${a.name}`,children:["/",a.name]}),!a.valid&&(0,e.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:i("skills.invalid")}),(0,e.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:j?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),k(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:i("common.confirm")}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),k(!1)},className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:i("common.cancel")})]}):(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),k(!0)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:i("common.delete"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 7h22M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3"})})})})]}),(0,e.jsxs)("div",{className:"font-mono text-xs text-muted-foreground mt-2 flex-shrink-0 break-all line-clamp-2","data-tooltip":a.path,children:[a.path,(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),d()},className:"inline-flex align-middle ml-1 p-0.5 hover:text-foreground hover:bg-hover rounded transition-colors",title:i("skills.copyPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("p",{className:"text-sm text-muted-foreground mt-2 pt-2 border-t border-border/60 break-words line-clamp-4","data-tooltip":a.description||void 0,children:a.description||(0,e.jsx)("span",{className:"italic opacity-60",children:i("skills.noDescription")})}),a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-auto pt-1 truncate flex-shrink-0","data-tooltip":a.argumentHint,children:a.argumentHint})]})}m=(o.then?(await o)():o)[0],d()}catch(a){d(a)}})},29491:(a,b,c)=>{"use strict";c.d(b,{I18nProvider:()=>g});var d=c(48249);c(67484);var e=c(44384),f=c(208);function g({children:a}){return(0,d.jsx)(e.xC,{i18n:f.A,children:a})}c(33281),c(65484)},29939:(a,b,c)=>{"use strict";c.d(b,{D:()=>h,h:()=>i});var d=c(67484),e=c(88055),f=c(21586);e.EV(f.YA(1),1.5).pipe(e.gP(e.ji(f.YA(10))),e.y$(e.t5(10))),e.EV(f.ne(200),2).pipe(e.gP(e.ji(f.YA(5))),e.y$(e.t5(5))),e.EV(f.YA(1),2).pipe(e.et,e.gP(e.ji(f.YA(30))),e.y$(e.t5(8))),e.ji(f.YA(30)),e.ji(f.YA(1)),e.ji(f.YA(30)),f.ne(50),e.BW;let g=new Set;function h(a){return g.add(a),()=>{g.delete(a)}}function i({url:a,onMessage:b,enabled:c=!0}){(0,d.useRef)(b)}},30337:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,15098,23)),Promise.resolve().then(c.t.bind(c,47644,23)),Promise.resolve().then(c.t.bind(c,33859,23)),Promise.resolve().then(c.t.bind(c,98099,23)),Promise.resolve().then(c.t.bind(c,16237,23)),Promise.resolve().then(c.t.bind(c,98562,23)),Promise.resolve().then(c.t.bind(c,36675,23))},30458:(a,b,c)=>{"use strict";c.d(b,{E:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(28602),i=c(71697);let j={once:[{labelKey:"scheduledTasks.5minLater",value:5},{labelKey:"scheduledTasks.15minLater",value:15},{labelKey:"scheduledTasks.30minLater",value:30},{labelKey:"scheduledTasks.1hourLater",value:60}],interval:[{labelKey:"scheduledTasks.every15min",value:15},{labelKey:"scheduledTasks.every30min",value:30},{labelKey:"scheduledTasks.every1hour",value:60},{labelKey:"scheduledTasks.every2hours",value:120}],cron:[{labelKey:"scheduledTasks.daily9am",value:"0 9 * * *"},{labelKey:"scheduledTasks.daily6pm",value:"0 18 * * *"},{labelKey:"scheduledTasks.weeklyMon9am",value:"0 9 * * 1"},{labelKey:"scheduledTasks.monthly1st9am",value:"0 9 1 * *"}]};function k({onClose:a,onCreate:b,editTask:c,onUpdate:l}){let{t:m}=(0,f.Bd)(),n=!!c,[o,p]=(0,e.useState)(c?.type||"once"),[q,r]=(0,e.useState)(c?.message||""),[s,t]=(0,e.useState)(c?.taskFile?"file":"message"),[u,v]=(0,e.useState)(c?.taskFile||""),[w,x]=(0,e.useState)(c?String(c.delayMinutes||c.intervalMinutes||""):""),[y,z]=(0,e.useState)(c?.cron||""),[A,B]=(0,e.useState)(c?.activeFrom||"09:00"),[C,D]=(0,e.useState)(c?.activeTo||"18:00"),[E,F]=(0,e.useState)(!!(c?.activeFrom&&c?.activeTo)),[G,H]=(0,e.useState)(null),I=(0,e.useRef)(null),J=(0,e.useRef)(null),K=(0,i.n)({value:q,onChange:r,textareaRef:J}),L=(0,e.useCallback)(()=>{let d="file"===s,e=d?{message:"",taskFile:u.trim()}:{message:q.trim(),taskFile:""};if(d?!e.taskFile:!e.message)return;let f=null;if("once"===o){let a=G||parseInt(w,10);if(!a||a<=0)return;f={...e,type:"once",delayMinutes:a}}else if("interval"===o){let a=G||parseInt(w,10);if(!a||a<=0)return;f={...e,type:"interval",intervalMinutes:a,...E?{activeFrom:A,activeTo:C}:{}}}else if("cron"===o){let a=G||y.trim();if(!a)return;f={...e,type:"cron",cron:a}}f&&(n&&c&&l?l(c.id,f):b(f),a())},[q,s,u,o,G,w,y,E,A,C,b,a,n,c,l]);return(0,d.jsxs)("div",{ref:I,className:`w-[28rem] max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lv2 z-50 ${n?"":"absolute bottom-full left-0 mb-2"}`,onKeyDown:b=>{"Escape"===b.key?a():"Enter"===b.key&&(b.metaKey||b.ctrlKey)&&L()},children:[(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 rounded-t-lg",children:(0,d.jsx)("span",{className:"text-sm font-medium",children:n?m("scheduledTasks.editTask"):m("scheduledTasks.createTask")})}),(0,d.jsxs)("div",{className:"p-4 space-y-4 max-h-[min(52rem,calc(100vh-3rem))] overflow-y-auto",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"flex gap-1 mb-1.5",children:["message","file"].map(a=>(0,d.jsx)("button",{onClick:()=>t(a),className:`px-2 py-1 text-xs rounded transition-colors ${s===a?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"message"===a?m("scheduledTasks.sendMessage"):m("scheduledTasks.taskFile")},a))}),"message"===s?(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("textarea",{ref:J,value:q,onChange:a=>{r(a.target.value),K.trackCaret(a.target)},onSelect:a=>K.trackCaret(a.currentTarget),onKeyDown:a=>{K.handleKeyDown(a)},placeholder:m("scheduledTasks.messagePlaceholder"),rows:5,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring resize-y min-h-[6rem]"}),(0,d.jsx)(i.V,{ac:K,className:"absolute top-full left-0 right-0 mt-1 max-h-48 z-10"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{type:"text",value:u,onChange:a=>v(a.target.value),placeholder:m("scheduledTasks.taskFilePlaceholder"),className:"w-full px-2 py-1.5 text-sm font-mono border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:m("scheduledTasks.taskFileHint")})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:m("scheduledTasks.type")}),(0,d.jsx)("div",{className:"flex gap-1",children:["once","interval","cron"].map(a=>(0,d.jsx)("button",{onClick:()=>{p(a),H(null),x(""),z("")},className:`flex-1 px-2 py-1 text-xs rounded transition-colors ${o===a?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"once"===a?m("scheduledTasks.once"):"interval"===a?m("scheduledTasks.interval"):"Cron"},a))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:m("scheduledTasks.quickSelect")}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1",children:j[o].map(a=>(0,d.jsx)("button",{onClick:()=>{H(a.value),"cron"===o?z(String(a.value)):x(String(a.value))},className:`px-2 py-1 text-xs rounded border transition-colors ${G===a.value?"border-brand bg-brand/10 text-brand":"border-border text-muted-foreground hover:text-foreground hover:border-foreground/30"}`,children:m(a.labelKey)},a.labelKey))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:"cron"===o?m("scheduledTasks.customCron"):m("scheduledTasks.customMinutes")}),"cron"===o?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{type:"text",value:y,onChange:a=>{z(a.target.value),H(null)},placeholder:m("scheduledTasks.cronPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring font-mono"}),y.trim()&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:function(a){let b=g.A.t,c=a.trim().split(/\s+/);if(5!==c.length)return null;let[d,e,f,h,i]=c,j={0:b("cron.dowSun"),1:b("cron.dowMon"),2:b("cron.dowTue"),3:b("cron.dowWed"),4:b("cron.dowThu"),5:b("cron.dowFri"),6:b("cron.dowSat")},k={1:`1${b("cron.monthPrefix")}`,2:`2${b("cron.monthPrefix")}`,3:`3${b("cron.monthPrefix")}`,4:`4${b("cron.monthPrefix")}`,5:`5${b("cron.monthPrefix")}`,6:`6${b("cron.monthPrefix")}`,7:`7${b("cron.monthPrefix")}`,8:`8${b("cron.monthPrefix")}`,9:`9${b("cron.monthPrefix")}`,10:`10${b("cron.monthPrefix")}`,11:`11${b("cron.monthPrefix")}`,12:`12${b("cron.monthPrefix")}`};try{let a="";if(d.includes("/")||e.includes("/")){if("*"===e&&d.includes("/"))return b("cron.everyNMinutes",{n:d.split("/")[1]});if("0"===d&&e.includes("/"))return b("cron.everyNHours",{n:e.split("/")[1]});return null}let c=parseInt(e,10),g=parseInt(d,10);if(isNaN(c)&&"*"!==e||isNaN(g)&&"*"!==d)return null;a="*"===e&&"*"===d?b("cron.everyMinute"):"*"===e?b("cron.everyHourAtMin",{m:g}):"*"===d?b("cron.hourlyEveryMin",{h:c}):`${String(c).padStart(2,"0")}:${String(g).padStart(2,"0")}`;let l=[];if("*"!==h){let a=h.split(",").map(a=>k[a]||`${a}${b("cron.monthPrefix")}`);l.push(a.join(", "))}if("*"!==f)if(f.includes("-")){let[a,c]=f.split("-");l.push(b("cron.dayRange",{a,b:c}))}else f.includes(",")?l.push(f.split(",").map(a=>`${a}${b("cron.dayOfMonth")}`).join(", ")):l.push(`${f}${b("cron.dayOfMonth")}`);if("*"!==i)if("1-5"===i)l.push(b("cron.weekdays"));else if("0,6"===i||"6,0"===i)l.push(b("cron.weekends"));else{let a=i.split(",").map(a=>{if(a.includes("-")){let[c,d]=a.split("-");return b("cron.weekdayRange",{a:j[c]||c,b:j[d]||d})}return`${b("cron.weekdayPrefix")}${j[a]||a}`});l.push(a.join(", "))}if(0===l.length&&"*"===f&&"*"===h&&"*"===i)return b("cron.daily",{time:a});return`${l.join(" ")} ${a}`}catch{return null}}(y.trim())||(0,d.jsx)("span",{className:"text-destructive",children:m("scheduledTasks.cronFormat")})})]}):(0,d.jsx)("input",{type:"number",value:w,onChange:a=>{x(a.target.value),H(null)},placeholder:m("scheduledTasks.minutesPlaceholder"),min:1,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]}),"interval"===o&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-1 cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:E,onChange:a=>F(a.target.checked),className:"rounded border-border"}),m("scheduledTasks.limitTimeRange")]}),E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("input",{type:"time",value:A,onChange:a=>B(a.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:m("scheduledTasks.to")}),(0,d.jsx)("input",{type:"time",value:C,onChange:a=>D(a.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,d.jsx)("button",{onClick:L,disabled:!(("file"===s?!!u.trim():!!q.trim())&&("once"===o||"interval"===o?!!(G||w&&parseInt(w,10)>0):"cron"===o&&!!(G||y.trim()))),className:"w-full py-1.5 text-sm font-medium rounded bg-brand text-white hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:n?m("scheduledTasks.saveBtn",{modKey:(0,h.Mu)()}):m("scheduledTasks.createBtn",{modKey:(0,h.Mu)()})})]})]})}},30905:(a,b,c)=>{"use strict";c.d(b,{C:()=>e});var d=c(208);function e(a,b){if("codex_resume_failed"!==a.notice)return null;let c=a.previous_session_id||"",e=d.A.t("chat.codexResumeFailed",{defaultValue:"Previous session is in use by another Codex client — started a new session; history was not carried over"}),f=[...c?[`${d.A.t("chat.codexResumeFailedPrevious",{defaultValue:"Previous session"})}: ${c}`]:[],...a.session_id?[`${d.A.t("chat.codexResumeFailedNew",{defaultValue:"New session"})}: ${a.session_id}`]:[]],g=[e,...f.length?["",...f]:[],...a.error?["",a.error]:[]].join("\n");return{id:b,role:"system",content:e,systemEvent:{kind:"meta",detail:g}}}},32459:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>p});var e=c(48249),f=c(67484),g=c(44384),h=c(96286),i=c(40311),j=c(82795),k=c(32753),l=c(74228),m=c(1512),n=c(50508),o=a([n]);function p({currentCwd:a,onSwitchProject:b,onResolveSessionNumbers:c,collapsed:d,sessions:o}){let{t:q}=(0,g.Bd)(),r=(0,f.useMemo)(()=>(0,m.H)(o),[o]),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(!1),[w,x]=(0,f.useState)({}),y=(0,f.useRef)(0),z=(0,f.useRef)(null),A=(0,n.o$)(),{show:B,hide:C}=A,D=(0,f.useCallback)(a=>{b(a.cwd,a.sessionId),t(!1)},[b]),E=(0,f.useCallback)(()=>{let a=!s;if(t(a),a){let a=++y.current;x({}),c().then(b=>{y.current===a&&x(b)})}else y.current+=1},[s,c]),F=o.filter(a=>"loading"===a.status).length,G=o.filter(a=>"unread"===a.status).length;return(0,e.jsxs)("div",{className:"relative",ref:z,children:[(0,e.jsxs)("button",{onClick:E,className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${d?"w-full justify-center":"w-full"}`,title:d?q("sessions.recentSessions"):void 0,children:[(0,e.jsx)(h.A,{className:"w-5 h-5 flex-shrink-0"}),!d&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:q("sessions.recentSessions")}),F>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-xs font-medium rounded-full flex items-center justify-center ${(0,i.c)("loading",!1)} ${d?"absolute -top-1 -right-1":""}`,children:F}),G>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 bg-orange-11/15 text-orange-11 text-xs font-medium rounded-full flex items-center justify-center ${d&&!F?"absolute -top-1 -right-1":""}`,children:G})]}),s&&(0,e.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[600px] bg-popover border border-border rounded-lg shadow-lv2 z-50 flex flex-col",children:[(0,e.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:q("sessions.recentSessions")}),F>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",q("sessions.runningCount",{count:F}),")"]}),G>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",q("sessions.unreadCount",{count:G}),")"]}),(0,e.jsxs)("button",{onClick:()=>{t(!1),v(!0)},className:"ml-auto flex items-center gap-1 p-1 -mr-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:q("sessions.searchRecentSessions"),children:[(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m21 21-4.35-4.35m2.35-5.4a7.75 7.75 0 1 1-15.5 0 7.75 7.75 0 0 1 15.5 0Z"})}),(0,e.jsx)("span",{className:"text-xs",children:q("sessions.search")})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===r.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:q("sessions.noSessions")}):r.map((b,c)=>(0,e.jsx)("button",{onClick:()=>D(b),onMouseEnter:a=>B(b,a),onMouseLeave:C,className:`w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 ${c!==r.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(k.S,{engine:b.engine}),(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:(0,n.Qr)(b.cwd)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(0,n.fw)(q,b.lastActive)}),(0,e.jsx)(l.l,{coordinate:w[`${b.cwd}
19
- ${b.sessionId}`],status:(0,l.S)(b.status),statusLabel:(0,n.Mm)(q,b.status),className:"ml-auto"})]}),b.title&&(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":b.title,children:b.title}),b.lastUserMessage&&(0,e.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:b.lastUserMessage})]})},`${b.cwd}-${b.sessionId}`))})]}),(0,e.jsx)(n.LD,{...A}),(0,e.jsx)(j.e,{isOpen:u,onClose:()=>v(!1),onSwitchProject:b,sessionNumbers:w})]})}n=(o.then?(await o)():o)[0],d()}catch(a){d(a)}})},32465:(a,b,c)=>{"use strict";c.d(b,{Y:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(76592),h=c(46674),i=c(59347),j=c(24520),k=c(33281),l=c(23328);function m({onClose:a,onSave:b}){let{t:c}=(0,f.Bd)(),[n,o]=(0,e.useState)({}),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!0);(0,e.useCallback)(async()=>{u(!0);let a=await k.t4.runPromiseExit((0,l.Jn)());"Success"===a._tag?o(a.value):console.error("Failed to load aliases:",a.cause),u(!1)},[]);let v=()=>{p.trim()&&r.trim()&&(o(a=>({...a,[p.trim()]:r.trim()})),q(""),s(""))},w=async()=>{let c=await k.t4.runPromiseExit((0,l.cv)(n));"Success"===c._tag?(b(n),a()):console.error("Failed to save aliases:",c.cause)};return(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-lv3 w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,d.jsx)(g.A,{className:"w-5 h-5"}),c("aliasManager.title")]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("aliasManager.description")})]}),(0,d.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-hover transition-colors",children:(0,d.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:t?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:c("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(n).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void o(b=>({...b,[a]:c}))},placeholder:c("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,d.jsx)("button",{onClick:()=>{o(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:p,onChange:a=>q(a.target.value),placeholder:c("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),v())}})]}),(0,d.jsx)("input",{type:"text",value:r,onChange:a=>s(a.target.value),placeholder:c("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),v())}})]}),(0,d.jsx)("button",{onClick:v,disabled:!p.trim()||!r.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,d.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,d.jsx)("strong",{children:c("aliasManager.usage")}),c("aliasManager.usageDesc")]}),(0,d.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(n).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:c("aliasManager.noAliases")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm hover:bg-hover transition-colors",children:c("common.cancel")}),(0,d.jsx)("button",{onClick:w,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:c("common.save")})]})]})})}},32580:(a,b,c)=>{"use strict";function d(a,b){let c=a.split("\n"),d=b.split("\n"),e=[],f=c.length,g=d.length,h=Array(f+1).fill(null).map(()=>Array(g+1).fill(0));for(let a=1;a<=f;a++)for(let b=1;b<=g;b++)c[a-1]===d[b-1]?h[a][b]=h[a-1][b-1]+1:h[a][b]=Math.max(h[a-1][b],h[a][b-1]);let i=f,j=g,k=[];for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(k.push({type:"unchanged",content:c[i-1],oldLineNum:i,newLineNum:j}),i--,j--):j>0&&(0===i||h[i][j-1]>=h[i-1][j])?(k.push({type:"added",content:d[j-1],newLineNum:j}),j--):(k.push({type:"removed",content:c[i-1],oldLineNum:i}),i--);for(;k.length>0;)e.push(k.pop());return e}c.d(b,{X:()=>d})},32753:(a,b,c)=>{"use strict";c.d(b,{S:()=>f});var d=c(48249),e=c(63565);function f({engine:a,tooltip:b,size:c="md"}){let g=a||"claude";return(0,e.ch)(g)?(0,d.jsx)("span",{className:"shrink-0 inline-flex items-center","data-tooltip":b??e.H[g],children:(0,d.jsx)(e.eV,{engine:g,className:"sm"===c?"h-3 w-3":"h-3.5 w-3.5"})}):(0,d.jsx)("span",{className:"shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded bg-muted text-muted-foreground","data-tooltip":b??g,children:g})}},33281:(a,b,c)=>{"use strict";c.d(b,{t4:()=>K});var d=c(95753),e=c(88512),f=c(79606),g=c(28582),h=c(61808);let i=d.Um(h.j9,h.dl((a=>{switch((a??"").toLowerCase()){case"all":return g.u8;case"trace":return g.Cn;case"debug":return g.y;case"info":default:return g.R2;case"warning":case"warn":return g.N5;case"error":return g.$D;case"fatal":return g.Lj;case"none":return g.NV}})(process.env.COCKPIT_LOG_LEVEL)));var j=c(1239),k=c(69063);let l=globalThis,m=l.__cockpitSpanRing??={buffer:[],index:new Map},n=a=>{let b="abcdef0123456789",c="";for(let d=0;d<a;d++)c+=b.charAt(Math.floor(Math.random()*b.length));return c};class o{constructor(a,b,c,d,e,f){this.name=a,this.parent=b,this.context=c,this.startTime=e,this.kind=f,this._tag="Span",this.sampled=!0,this.attributes=new Map,this.events=[],this.traceId=j.Ru(b)?b.value.traceId:n(32),this.spanId=n(16),this.status={_tag:"Started",startTime:e},this.links=Array.from(d),function(a){if(m.buffer.push(a),m.index.set(a.spanId,m.buffer.length-1),m.buffer.length>500){m.buffer.shift(),m.index.clear();for(let a=0;a<m.buffer.length;a++)m.index.set(m.buffer[a].spanId,a)}}(function(a,b,c,d,e,f){return{traceId:b,spanId:a,parentSpanId:c,name:d,kind:e,startTimeNs:f.toString(),endTimeNs:null,durationMs:null,attributes:{},events:[],status:"started"}}(this.spanId,this.traceId,function(a){return j.Ru(a)?a.value.spanId:null}(b),a,f,e))}end(a,b){this.status={_tag:"Ended",endTime:a,exit:b,startTime:this.status.startTime},function(a,b,c){let d=m.index.get(a);if(void 0===d)return;let e=m.buffer[d];if(!e)return;let f=Number(b-BigInt(e.startTimeNs))/1e6;m.buffer[d]={...e,endTimeNs:b.toString(),durationMs:Math.round(100*f)/100,status:"Success"===c._tag?"ok":"error",errorMessage:"Failure"===c._tag?function(a){if(a instanceof Error)return a.message;if("string"==typeof a)return a;try{return JSON.stringify(a)}catch{return String(a)}}(c.cause):void 0}}(this.spanId,a,"Success"===b._tag?{_tag:"Success"}:{_tag:"Failure",cause:b.cause})}attribute(a,b){this.attributes.set(a,b),function(a,b,c){let d=m.index.get(a);if(void 0===d)return;let e=m.buffer[d];e&&(m.buffer[d]={...e,attributes:{...e.attributes,[b]:c}})}(this.spanId,a,b)}event(a,b,c){this.events.push([a,b,c??{}]),function(a,b,c,d){let e=m.index.get(a);if(void 0===e)return;let f=m.buffer[e];f&&(m.buffer[e]={...f,events:[...f.events,{name:b,timeNs:c.toString(),attributes:d}]})}(this.spanId,a,b,c)}addLinks(a){this.links.push(...a)}}let p=k.L8({span:(a,b,c,d,e,f)=>new o(a,b,c,d,e,f),context:a=>a()}),q=d.Py(k.sh,p);d.Ie;var r=c(66473);let s=r.eu("dev","prod")("COCKPIT_ENV").pipe(r.IQ("prod")),t=r.Yj("COCKPIT_HOST").pipe(r.IQ("127.0.0.1")),u=r.nd("COCKPIT_PORT").pipe(r.NW(()=>r.nd("PORT")),r.IQ(3457)),v=r.uK(r.Yj("COCKPIT_OPEN_PROJECT")).pipe(r.Tj(a=>"Some"===a._tag?a.value:void 0)),w=r.zM("COCKPIT_NO_OPEN").pipe(r.IQ(!1)),x=r.Yj("COCKPIT_LOG_LEVEL").pipe(r.IQ("info")),y=r.nd("COCKPIT_SNAPSHOT_KEEP_DAYS").pipe(r.IQ(7)),z=r.nd("COCKPIT_SNAPSHOT_REPO_TTL_DAYS").pipe(r.IQ(30)),A=r.nd("COCKPIT_SNAPSHOT_MAX_FILE_KB").pipe(r.IQ(2048)),B=r.nd("COCKPIT_SESSION_KEEP_DAYS").pipe(r.IQ(30)),C=r.nd("COCKPIT_DELEGATE_MAX").pipe(r.tf({message:"COCKPIT_DELEGATE_MAX must be >= 1",validation:a=>a>=1}),r.IQ(4));f.JkU(function*(){let a=yield*s,b=yield*t,c=yield*u,d=yield*v,e=yield*w,g=yield*x,h=yield*y,i=yield*z,j=yield*A,k=yield*B,l=yield*C,m=yield*f.OH5(()=>{let a="u">typeof process?process.env:void 0,b=a?.HOME||a?.USERPROFILE||".",c=a?.COCKPIT_HOME;return c?c.replace(/^~(?=$|\/)/,b):b+"/.cockpit"});return{env:a,host:b,port:3457===c&&"dev"===a?3456:c,cockpitDir:m,openProject:d,openBrowser:!e,logLevel:g,logFile:m+"/logs/cockpit.log",snapshotKeepDays:h,snapshotRepoTtlDays:i,snapshotMaxFileKb:j,sessionKeepDays:k,delegateMaxConcurrent:l}}).pipe(f.QgK);let D=d.Ie;var E=c(7846),F=c(55805),G=c(23734);let H=d.P1(G.d,f.JkU(function*(){let a=yield*E.dT();return yield*f.Q56(f.OH5(()=>b=>{f.MY7(E.mk(a,b))}),a=>f.OH5(()=>{})),G.d.of({publish:(a,b)=>f.OH5(()=>{}),subscribe:b=>F.qdp(a).pipe(F.pbD(a=>{var c;return c=a.data,!!c&&"object"==typeof c&&(c.topic===b.id||c.type===b.legacyType)}),F.TjK(a=>((a,b)=>{if(a.topic===b.id)return a.msg;let{type:c,...d}=a;return d})(a.data,b)))})})),I=d.Um(i,q,D),J=d.Um(I,H),K=e.L8(J);f.rIH},34001:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{NoteModal:()=>G});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(13191),j=c(63229),k=c(19043),l=c(48197),m=c(9731),n=c(44551),o=c(53116),p=c(16512),q=c(56444),r=c(11537),s=c(73555),t=c(1370),u=c(80118),v=c(54727),w=c(19545),x=c(92451),y=c(83179),z=c(33281),A=c(79606),B=c(7833),C=c(65484),D=c(43321),E=c(43037),F=c(39031);function G({isOpen:a,onClose:b,projectCwd:c,projectName:d}){let{t:H}=(0,g.Bd)(),[I,J]=(0,f.useState)(!0),[K,L]=(0,f.useState)(!1),M=(0,f.useRef)(null),N=(0,f.useRef)(!1),O=(0,f.useRef)(void 0),[P,Q]=(0,f.useState)(null),R=(0,f.useRef)(null),S=(0,f.useCallback)(async a=>{let b=(0,D.D)(a);L(!0);let d=await z.t4.runPromiseExit((0,C.Cq)(c,b,O.current).pipe(A.sFT(a=>A.OH5(()=>console.error("Failed to save note:",a)))));if("Success"===d._tag){let a=d.value;a.conflict?(V.current?.commands.setContent(a.content,{emitUpdate:!1}),O.current=a.mtime,N.current=!1,(0,B.oR)(H("editor.conflictReloaded"),"info")):(O.current=a.mtime,N.current=!1)}L(!1)},[c,H]),T=(0,f.useCallback)(a=>{N.current=!0,M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{S(a)},5e3)},[S]),U=(0,i.hG)({immediatelyRender:!1,extensions:[j.A.configure({heading:!1,link:!1}),u.R.configure({levels:[1,2,3]}),v.y,k.A.configure({placeholder:()=>h.A.t("editor.placeholder")}),l.XI.configure({resizable:!0}),m.H,n.n,o.A,p._,r.Ay.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),q.$H.configure({nested:!0}),E.E3,F.IS,s.o.configure({html:!0,transformCopiedText:!1,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},clipboardTextSerializer:a=>a.content.textBetween(0,a.content.size,"\n").replace(/\n+$/,""),transformCopied:a=>{let b=a=>!!a&&a.isTextblock&&0===a.content.size,c=a.content,{openStart:d,openEnd:e}=a;for(;c.childCount>1&&b(c.lastChild);)c=c.cut(0,c.size-c.lastChild.nodeSize),e=0;for(;c.childCount>1&&b(c.firstChild);)c=c.cut(c.firstChild.nodeSize),d=0;return new t.Ji(c,d,e)},handleClick:(a,b,c)=>{if(c.metaKey||c.ctrlKey){let c=a.state.doc.resolve(b).marks().find(a=>"link"===a.type.name)?.attrs;if(c?.href)return window.open(c.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(a,b)=>{if("Backspace"===b.key&&V.current){let a=V.current;if(a.isActive("codeBlock")){let{$from:b}=a.state.selection,c=b.node(b.depth);if("codeBlock"===c.type.name&&""===c.textContent)return a.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==b.key||P||setTimeout(()=>{if(!V.current)return;let{from:a}=V.current.state.selection,b=V.current.state.doc.textBetween(Math.max(0,a-1),a,"\n");if("/"===b){R.current=a;let b=V.current.view.coordsAtPos(a);Q({query:"",position:{top:b.bottom+4,left:b.left}})}},0),!1}},onUpdate:({editor:a})=>{let b=(0,w.up)(a);if(T(b),null!==R.current){let{from:b}=a.state.selection;if(b<R.current)Q(null),R.current=null;else{let c=a.state.doc.textBetween(R.current,b,"\n");c.includes(" ")||c.includes("\n")?(Q(null),R.current=null):Q(a=>a?{...a,query:c}:null)}}}}),V=(0,f.useRef)(null),W=(0,f.useCallback)(()=>{if(M.current&&(clearTimeout(M.current),M.current=null),N.current&&U){let a=(0,w.up)(U);S(a)}Q(null),R.current=null,b()},[U,S,b]);return a?(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:W}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:d?H("editor.noteTitle",{name:d}):H("editor.noteUntitled")}),K&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:H("editor.saving")})]}),(0,e.jsx)("button",{onClick:W,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(y.NoteToolbar,{editor:U}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:I?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,e.jsx)("span",{children:H("common.loading")})}):(0,e.jsx)(i.$Z,{editor:U})})]}),P&&U&&(0,e.jsx)(x.U,{editor:U,query:P.query,position:P.position,onClose:()=>{Q(null),R.current=null}})]}):null}d()}catch(a){d(a)}})},34728:(a,b,c)=>{"use strict";c.d(b,{U:()=>j});var d=c(67484),e=c(44384),f=c(7833),g=c(77156),h=c(59336),i=c(33281);function j(){let{t:a}=(0,e.Bd)();return(0,d.useCallback)(async b=>{let c=await i.t4.runPromiseExit((0,g.L5)(b));if("Success"===c._tag)c.value.alreadyExists?(0,f.oR)(a("skills.alreadyAdded"),"info"):((0,f.oR)(a("skills.added"),"success"),(0,h.k)());else{let b="Fail"===c.cause._tag?c.cause.error:null,d=b?.cause,e=d instanceof Error?d.message:a("skills.addFailed");(0,f.oR)(e,"error")}},[a])}},35208:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{xU:()=>u,xZ:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(36043),i=c(32580),j=c(73414),k=c(7833),l=c(38896),m=c(36984),n=c(74542),o=c(26362),p=c(89719),q=a([o]);function r(a){return(0,f.useCallback)((b,c)=>{if(!a||c<=0)return;let d=(0,p.A)(b,b.currentTarget);d&&a(c,d.column,d.rect)},[a])}function s(a){return a.params?`${a.name}(${a.params.join(", ")})`:a.name}function t({oldContent:a,newContent:b,filePath:c,isNew:d=!1,isDeleted:p=!1,cwd:q,enableComments:u=!1,onPreview:v,previewLabel:w,headerLeading:x,onContentSearch:y,targetLine:z,compact:A=!1,symbols:B,onTokenHover:C,onTokenHoverLeave:D,onTokenHoverCancel:E}){let{t:F}=(0,g.Bd)(),G=r(C),H=w??F("common.preview"),I=(0,f.useMemo)(()=>(0,i.X)(a,b),[a,b]),J=(0,f.useRef)(null),K=(0,f.useRef)(null),L=(0,f.useRef)(null);(0,f.useRef)(!1);let[M,N]=(0,f.useState)(null),{commentsEnabled:O,linesWithComments:P,commentsByEndLine:Q,handleCommentBubbleClick:R,addCommentRange:S,sendToAIRange:T,commentPortal:U}=(0,o.T)({cwd:q,enableComments:u,filePath:c,diffLines:I,containerEl:M,onContentSearch:y}),{leftLines:V,rightLines:W}=(0,f.useMemo)(()=>{let a=[],b=[],c=0,d=0;for(let e=0;e<I.length;e++){let f=I[e];if("unchanged"===f.type){for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});c++,d++,a.push({lineNum:c,content:f.content,type:"unchanged",originalIdx:e}),b.push({lineNum:d,content:f.content,type:"unchanged",originalIdx:e})}else"removed"===f.type?(c++,a.push({lineNum:c,content:f.content,type:"removed",originalIdx:e})):"added"===f.type&&(d++,b.push({lineNum:d,content:f.content,type:"added",originalIdx:e}))}for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:a,rightLines:b}},[I]),X=(0,f.useMemo)(()=>I.map(a=>a.content),[I]),Y=(0,l.C)(X,c),[Z,$]=(0,f.useState)(()=>new Map),_=(0,f.useMemo)(()=>B??[],[B]),{rows:aa,gaps:ab}=(0,f.useMemo)(()=>A?(0,j.pU)(V,W,Z,_):{rows:V.map((a,b)=>({kind:"diff",idx:b})),gaps:[]},[A,V,V,W,Z,_]),ac=(0,f.useCallback)((a,b)=>{let c=ab.find(b=>b.id===a);c&&$(d=>{let e=d.get(a)??{topRevealed:0,bottomRevealed:0},f=c.endIdx-c.startIdx+1-e.topRevealed-e.bottomRevealed;if(f<=0)return d;let g=Math.min(j.YO,f),h="up"===b?{...e,topRevealed:e.topRevealed+g}:{...e,bottomRevealed:e.bottomRevealed+g};return new Map(d).set(a,h)})},[ab]);(0,f.useCallback)(a=>{for(let b of ab)if(a>=b.startIdx&&a<=b.endIdx)return b.id;return null},[ab]);let ad=(0,f.useCallback)(a=>aa[a]?.kind==="gap-label"?28:20,[aa]),ae=(0,f.useCallback)(a=>{let b=aa[a];if(!b)return a;if("gap-label"===b.kind)return`gl:${b.gapId}`;if("gap-expand"===b.kind)return`ge:${b.gapId}:${b.direction}`;let c=V[b.idx],d=W[b.idx];return`d:${c?.lineNum??"x"}:${c?.type??"x"}:${d?.lineNum??"x"}:${d?.type??"x"}`},[aa,V,W]),af=(0,h.Te)({count:aa.length,getScrollElement:()=>J.current,estimateSize:ad,getItemKey:ae,overscan:20}),ag=d?"w-1/4":p?"w-3/4":"w-1/2",ah=d?"w-3/4":p?"w-1/4":"w-1/2",ai=(0,f.useMemo)(()=>aa.map(a=>{if("diff"!==a.kind)return{type:"unchanged"};let b=V[a.idx],c=W[a.idx];return"removed"===b.type?{type:"removed"}:c?.type==="added"?{type:"added"}:{type:"unchanged"}}),[aa,V,W]),aj=af.getTotalSize(),ak=af.getVirtualItems();return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[x&&(0,e.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:x}),(0,e.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,e.jsx)("div",{className:`${ag} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:d?"(New File)":p?"Deleted":"Old"}),(0,e.jsxs)("div",{className:`${ah} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,e.jsx)("span",{className:"block text-center",children:p?"(Deleted)":"New"}),(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[v&&(0,e.jsx)("button",{onClick:v,className:"text-muted-foreground hover:text-foreground transition-colors",children:H}),!p&&b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,k.oR)(F("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:F("common.copy")})]})]}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:J,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,e.jsxs)("div",{className:"flex",style:{height:`${aj}px`},children:[(0,e.jsx)("div",{ref:K,className:`${ag} overflow-x-auto border-r border-border`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ak.map(a=>{let b=aa[a.index];if("gap-expand"===b.kind||"gap-label"===b.kind){let c="gap-label"===b.kind;return(0,e.jsx)("div",{ref:af.measureElement,"data-index":a.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,ad(a.index))}px`,transform:`translateY(${a.start}px)`},className:c?"bg-accent border-y border-border":""},a.key)}let c=V[b.idx];return(0,e.jsxs)("div",{ref:af.measureElement,"data-index":a.index,"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(a.size,ad(a.index))}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===c.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:c.lineNum||""}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c.originalIdx>=0&&Y[c.originalIdx]||(0,m.ZD)(c.content||" ")}})]},a.key)})})}),(0,e.jsx)("div",{ref:L,className:`${ah} overflow-x-auto`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ak.map(a=>{let b=aa[a.index];if("gap-expand"===b.kind)return(0,e.jsx)("button",{ref:af.measureElement,"data-index":a.index,type:"button",onClick:()=>ac(b.gapId,b.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,ad(a.index))}px`,transform:`translateY(${a.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-hover 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:F("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),"aria-label":F("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),children:(0,e.jsx)("span",{className:"select-none",children:F("diffViewer.gap.more",{count:b.revealCount})})},a.key);if("gap-label"===b.kind)return(0,e.jsxs)("div",{ref:af.measureElement,"data-index":a.index,"data-gap-id":b.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,ad(a.index))}px`,transform:`translateY(${a.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,e.jsx)("span",{className:"flex-shrink-0",children:F("diffViewer.gap.hidden",{count:b.hiddenCount})}),b.enclosingFn&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,e.jsx)("span",{className:"truncate min-w-0 font-medium","data-tooltip":s(b.enclosingFn),children:s(b.enclosingFn)})]})]},a.key);let c=W[b.idx],d=c?.lineNum||0,f=d>0&&P.has(d),g=Q.get(d),h=g?.[0],i=S&&d>=S.start&&d<=S.end,j=T&&d>=T.start&&d<=T.end,k=i||j;return(0,e.jsxs)("div",{ref:af.measureElement,"data-index":a.index,"data-new-line":d||void 0,"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(a.size,ad(a.index))}px`,transform:`translateY(${a.start}px)`},className:`flex ${k?"bg-blue-9/20":f?"bg-amber-9/10":c?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-foreground-subtle select-none border-r border-border ${k?"bg-blue-9/30":""}`,style:{width:O?"52px":"40px"},children:[O&&d>0&&f&&h&&(0,e.jsx)("button",{onClick:a=>R(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:F("codeViewer.nComments",{count:g?.length}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.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"})})}),O&&d>0&&!f&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"flex-1 text-right pr-1",children:d||""})]}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",onMouseOver:C?a=>G(a,d):void 0,onMouseLeave:C?D:void 0,onMouseDown:C?E:void 0,dangerouslySetInnerHTML:{__html:c?.originalIdx>=0&&Y[c.originalIdx]||(0,m.ZD)(c?.content||" ")}})]},a.key)})})})]})}),(0,e.jsx)(n.b,{lines:ai,containerRef:J})]}),U]})}function u({oldContent:a,newContent:b,filePath:c,cwd:d,enableComments:p=!1,onPreview:q,previewLabel:s,headerLeading:t,onContentSearch:v,compact:w=!1,onTokenHover:x,onTokenHoverLeave:y,onTokenHoverCancel:z}){let{t:A}=(0,g.Bd)(),B=r(x),C=s??A("common.preview"),D=(0,f.useMemo)(()=>(0,i.X)(a,b),[a,b]),E=(0,f.useRef)(null),F=(0,f.useMemo)(()=>D.map(a=>a.content),[D]),G=(0,l.C)(F,c),[H,I]=(0,f.useState)(null),{commentsEnabled:J,linesWithComments:K,commentsByEndLine:L,handleCommentBubbleClick:M,addCommentRange:N,sendToAIRange:O,commentPortal:P}=(0,o.T)({cwd:d,enableComments:p,filePath:c,diffLines:D,containerEl:H,onContentSearch:v}),[Q,R]=(0,f.useState)(()=>new Set),S=(0,f.useMemo)(()=>w?function(a,b){let c=a.length,d=Array(c).fill(!1);for(let b=0;b<c;b++){if("unchanged"===a[b].type)continue;let e=Math.max(0,b-j.aj),f=Math.min(c-1,b+j.aj);for(let a=e;a<=f;a++)d[a]=!0}let e=[],f=0,g=0;for(;g<c;){if(d[g]){e.push({kind:"line",line:a[g],index:g}),g++;continue}let h=g;for(;h<c&&!d[h];)h++;let i=f++;if(b.has(i))for(let b=g;b<h;b++)e.push({kind:"line",line:a[b],index:b});else e.push({kind:"gap",id:i,count:h-g});g=h}return e}(D,Q):D.map((a,b)=>({kind:"line",line:a,index:b})),[w,D,Q]),T=(0,f.useCallback)(a=>{let b=S[a];if(!b)return a;if("gap"===b.kind)return`gap:${b.id}`;let c=b.line;return`${c.type}:${c.oldLineNum??"x"}:${c.newLineNum??"x"}`},[S]),U=(0,h.Te)({count:S.length,getScrollElement:()=>E.current,estimateSize:()=>20,getItemKey:T,overscan:20}),V=(0,f.useMemo)(()=>S.map(a=>"gap"===a.kind?{type:"unchanged"}:{type:a.line.type}),[S]);return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(t||q||b)&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-end gap-2 px-2 py-1 border-b border-border bg-accent text-xs",children:[t&&(0,e.jsx)("div",{className:"mr-auto min-w-0",children:t}),q&&(0,e.jsx)("button",{onClick:q,className:"text-muted-foreground hover:text-foreground transition-colors",children:C}),b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,k.oR)(A("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:A("common.copy")}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:E,className:"flex-1 min-w-0 overflow-auto",children:(0,e.jsx)("div",{style:{height:`${U.getTotalSize()}px`,position:"relative"},children:U.getVirtualItems().map(a=>{let b=S[a.index];if(!b)return null;let c={position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`};if("gap"===b.kind){let d=A("diffViewer.gap.hidden",{count:b.count});return(0,e.jsx)("div",{style:c,onClick:()=>R(a=>new Set(a).add(b.id)),className:"flex items-center cursor-pointer bg-slate-2 hover:bg-hover border-y border-border text-xs text-foreground-subtle select-none","data-tooltip":d,children:(0,e.jsx)("span",{className:"w-full text-center",children:d})},a.key)}let d=b.line,f="removed"!==d.type?d.newLineNum??0:0,g=f>0&&K.has(f),h=L.get(f),i=h?.[0],j=N&&f>=N.start&&f<=N.end,k=O&&f>=O.start&&f<=O.end;return(0,e.jsxs)("div",{style:c,"data-new-line":f||void 0,className:`flex ${j||k?"bg-blue-9/20":g?"bg-amber-9/10":"removed"===d.type?"bg-red-9/15 dark:bg-red-9/25":"added"===d.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[J&&(0,e.jsx)("span",{className:"w-5 flex-shrink-0 flex items-center justify-center select-none",children:f>0&&g&&i&&(0,e.jsx)("button",{onClick:a=>M(i,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:A("codeViewer.nComments",{count:h?.length}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.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"})})})}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"added"!==d.type?d.oldLineNum:""}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"removed"!==d.type?d.newLineNum:""}),(0,e.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===d.type?"text-red-11":"added"===d.type?"text-green-11":"text-foreground-subtle"}`,children:"removed"===d.type?"-":"added"===d.type?"+":" "}),(0,e.jsx)("span",{className:"flex-1 whitespace-pre pl-1",onMouseOver:x?a=>B(a,f):void 0,onMouseLeave:x?y:void 0,onMouseDown:x?z:void 0,dangerouslySetInnerHTML:{__html:G[b.index]||(0,m.ZD)(d.content||" ")}})]},a.key)})})}),(0,e.jsx)(n.b,{lines:V,containerRef:E})]}),P]})}o=(q.then?(await q)():q)[0],d()}catch(a){d(a)}})},35606:(a,b,c)=>{"use strict";function d(a,b){switch(a){case"codex":return`codex resume ${b}`;case"kimi":case"glm":case"deepseek":case"ollama":return`${a} ${b}`;default:return`claude -r ${b}`}}c.d(b,{X:()=>d})},35857:(a,b,c)=>{"use strict";function d(){}c.d(b,{N:()=>d})},36688:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{x:()=>k});var e=c(48249),f=c(67484),g=c(44256),h=c(7122),i=c(73887),j=a([i]);function k({filePath:a,content:b,cwd:c,onClose:d,zClassName:j="z-50"}){let[l,m]=(0,f.useState)(null);return(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:`fixed inset-0 ${j} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:d,children:(0,e.jsx)("div",{ref:m,className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(h.SU,{container:l,children:(0,e.jsx)(i.M,{content:b,filePath:a,cwd:c,onClose:d})})})})})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},36984:(a,b,c)=>{"use strict";c.d(b,{Np:()=>k,ZD:()=>h,ZR:()=>i,b8:()=>j,kS:()=>f,sQ:()=>g});let d=null,e=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml","lean4"];function f(){return d||(d=Promise.resolve().then(c.bind(c,78908)).then(({createHighlighter:a})=>a({themes:["github-dark","github-light"],langs:[...e]}))),d}function g(a){let b=a.split("/").pop()?.toLowerCase()||"",c=b.split(".").pop()?.toLowerCase();if(".env"===b||b.startsWith(".env.")||"dockerfile"===b||b.startsWith("dockerfile.")||"makefile"===b)return"bash";let d={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",lean:"lean4",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[c||""]||"text";return e.includes(d)?d:"text"}function h(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}let i=2e3;function j(a){return a.length>i?h(a.map(a=>a.content).join("")):a.map(a=>a.color?`<span style="color:${a.color}">${h(a.content)}</span>`:h(a.content)).join("")}function k(a,b,c,d){if(!b)return[];let e=[],f=c?b:b.toLowerCase();for(let b=0;b<a.length;b++){let g=c?a[b]:a[b].toLowerCase(),h=0;for(;;){let a=g.indexOf(f,h);if(-1===a)break;let c=a+f.length;if(d){let d=a>0?g[a-1]:" ",f=c<g.length?g[c]:" ",h=!/\w/.test(d),i=!/\w/.test(f);h&&i&&e.push({lineIndex:b,startCol:a,endCol:c})}else e.push({lineIndex:b,startCol:a,endCol:c});h=a+1}}return e}},37202:(a,b,c)=>{"use strict";c.d(b,{M:()=>n,O:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(74429),h=c(74228);let i=[],j=[];function k(){j.forEach(a=>a())}function l(a){let b=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;i=[...i,{...a,id:b}],k()}function m(a){i=i.filter(b=>b.id!==a),k()}function n({onNavigate:a}){let b=function(){let[,a]=(0,e.useState)(0);return i}();return 0===b.length?null:(0,g.createPortal)((0,d.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:b.map(b=>(0,d.jsx)(o,{item:b,onNavigate:a,onRemove:m},b.id))}),document.body)}function o({item:a,onNavigate:b,onRemove:c}){let{t:g}=(0,f.Bd)(),[i,j]=(0,e.useState)(!1),k=(0,e.useRef)(void 0),l=(0,e.useCallback)(()=>{j(!0),setTimeout(()=>c(a.id),300)},[a.id,c]),m=(0,e.useCallback)(()=>{clearTimeout(k.current),b(a.cwd,a.sessionId),c(a.id)},[a,b,c]),n=(0,e.useCallback)(()=>{clearTimeout(k.current)},[]),p=(0,e.useCallback)(()=>{k.current=setTimeout(l,2e3)},[l]);return(0,d.jsxs)("div",{className:`group pointer-events-auto relative bg-popover border border-border rounded-lg shadow-lv3 px-3 py-3 min-h-[84px] min-w-[260px] max-w-[340px] cursor-pointer transition-all ${i?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:i?void 0:"slideInLeft 0.3s ease-out"},onClick:m,onMouseEnter:n,onMouseLeave:p,children:[(0,d.jsx)("div",{className:"pointer-events-none absolute inset-0 rounded-lg bg-hover opacity-0 group-hover:opacity-100 transition-opacity"}),(0,d.jsxs)("div",{className:"relative flex items-start gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-green-9 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.projectName}),(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:g("common.done")}),(0,d.jsx)(h.l,{projectNumber:a.projectNumber,sessionNumber:a.sessionNumber,className:"ml-auto"}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.message&&(0,d.jsx)("div",{className:"relative text-xs text-muted-foreground line-clamp-2 break-words mt-1 ml-6",children:a.message})]})}},37388:(a,b,c)=>{"use strict";c.d(b,{KJ:()=>h,M2:()=>j,T$:()=>i,ej:()=>g,n8:()=>f});var d=c(79606),e=c(71192);let f=a=>d.$mh({try:async()=>{let b=await fetch(`/api/project-state?cwd=${encodeURIComponent(a)}`);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"loadProjectState failed",cause:a})}),g=a=>d.$mh({try:async()=>{let b=await fetch("/api/project-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"saveProjectState failed",cause:a})}),h=(a,b,c)=>d.$mh({try:async()=>{let d=await fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c,action:"status"})});if(!d.ok)throw Error(`HTTP ${d.status}`)},catch:a=>new e.uV({message:"updateSessionStatus failed",cause:a})}),i=(a,b)=>d.$mh({try:async()=>{let c=await fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,action:"touch"})});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:a=>new e.uV({message:"touchRecentSession failed",cause:a})}),j=a=>d.$mh({try:async()=>{let b=await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markReadBySessionId",fields:{sessionId:a}})});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"markScheduledTasksReadBySession failed",cause:a})})},37690:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(67484);function e({enabled:a,container:b,resolveLineRange:c,buildLineSnapshot:f,dragThresholdPx:g=5}){let h=(0,d.useRef)(null),i=(0,d.useRef)(()=>{}),j=(0,d.useRef)(c),k=(0,d.useRef)(f),l=(0,d.useRef)(g);return j.current=c,k.current=f,l.current=g,{toolbarRef:h,bumpRef:i,clearToolbar:()=>{h.current&&(h.current=null,i.current())}}}},37701:(a,b,c)=>{"use strict";c.d(b,{Fe:()=>d,Ff:()=>h,Z8:()=>g,wL:()=>e});let d=a=>a?.toLowerCase().startsWith("zh")?"zh":"en",e=(a,b)=>{if(!a||"object"!=typeof a)return null;let c=a.quickReplies;return c&&"object"==typeof c?(a=>{if(!Array.isArray(a))return null;let b=[];for(let c of a.slice(0,12)){if(!Array.isArray(c))continue;let a=[];for(let b of c.slice(0,8)){if("string"!=typeof b)continue;let c=b.trim().slice(0,200);c&&a.push(c)}a.length&&b.push(a)}return b.length?b:null})(c[b]):null},f=/[,,]/,g=a=>a.split("\n").map(a=>a.split(f).map(a=>a.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(a=>a.length>0).slice(0,12),h=(a,b)=>a.map(a=>a.join("zh"===b?",":", ")).join("\n")},38878:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManagerTopBar:()=>u});var e=c(48249),f=c(67484),g=c(94192),h=c(12568),i=c(7833),j=c(44384),k=c(57031),l=c(88214),m=c(79606),n=c(33281),o=c(85655),p=c(35606),q=c(65484);function r({className:a}){return(0,e.jsxs)("svg",{className:a,fill:"none",viewBox:"0 0 100 100","aria-hidden":"true",children:[(0,e.jsx)("path",{fill:"#0065A9",d:"M96.461 10.796 75.857.876a6.23 6.23 0 0 0-7.107 1.207l-67.451 61.5a4.167 4.167 0 0 0 .004 6.162l5.51 5.009a4.167 4.167 0 0 0 5.32.236l81.228-61.62c2.725-2.067 6.639-.124 6.639 3.297v-.24a6.25 6.25 0 0 0-3.539-5.63Z"}),(0,e.jsx)("path",{fill:"#007ACC",d:"m96.461 89.204-20.604 9.92a6.229 6.229 0 0 1-7.107-1.207l-67.451-61.5a4.167 4.167 0 0 1 .004-6.162l5.51-5.009a4.167 4.167 0 0 1 5.32-.236l81.228 61.62c2.725 2.067 6.639.124 6.639-3.297v.24a6.25 6.25 0 0 0-3.539 5.63Z"}),(0,e.jsx)("path",{fill:"#1F9CF0",d:"M75.858 99.126a6.232 6.232 0 0 1-7.108-1.21c2.306 2.307 6.25.674 6.25-2.588V4.672c0-3.262-3.944-4.895-6.25-2.589a6.232 6.232 0 0 1 7.108-1.21l20.6 9.908A6.25 6.25 0 0 1 100 16.413v67.174a6.25 6.25 0 0 1-3.541 5.633l-20.601 9.906Z"})]})}function s({className:a}){return(0,e.jsx)("svg",{className:a,viewBox:"0 0 466.73 532.09",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"})})}function t({cwd:a,currentBranch:b,onSwitched:c}){let{t:d}=(0,j.Bd)(),[g,h]=(0,f.useState)(!1),[k,l]=(0,f.useState)([]),[m,p]=(0,f.useState)(!1),[r,s]=(0,f.useState)(!1),[u,v]=(0,f.useState)(""),w=(0,f.useRef)(null),x=(0,f.useRef)(null),y=(0,f.useCallback)(async()=>{p(!0);let b=await n.t4.runPromiseExit((0,o.r4)(a));if("Success"===b._tag){let a=b.value,c=a.local??[],d=a.remote??[],e=[...c,...d.filter(a=>!c.includes(a.replace(/^origin\//,"")))];l(e)}else(0,i.oR)(d("toast.loadBranchFailed"),"error");p(!1)},[a,d]),z=(0,f.useCallback)(()=>{h(!0),v(""),y()},[y]),A=(0,f.useCallback)(()=>{h(!1)},[]),B=async b=>{s(!0);let e=await n.t4.runPromiseExit((0,q.Kl)({action:"checkout",cwd:a,path:a,branch:b}));if("Success"===e._tag){let a=b.replace(/^origin\//,"");(0,i.oR)(d("toast.switchedToBranch",{branch:a}),"success"),A(),c()}else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:d("toast.switchBranchFailed");(0,i.oR)(c,"error")}s(!1)},C=k.filter(a=>a!==b&&a.toLowerCase().includes(u.toLowerCase()));return(0,e.jsxs)("div",{className:"relative",ref:w,children:[(0,e.jsx)("button",{onClick:g?A:z,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:d("git.switchBranch"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),g&&(0,e.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lv2 z-50 overflow-hidden",children:[(0,e.jsx)("div",{className:"p-2 border-b border-border",children:(0,e.jsx)("input",{ref:x,type:"text",value:u,onChange:a=>v(a.target.value),placeholder:d("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none",onKeyDown:a=>{"Escape"===a.key&&A()}})}),(0,e.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:m?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("common.loading")}):0===C.length?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:u?d("git.noMatchingBranches"):d("git.noBranches")}):C.map(a=>(0,e.jsx)("button",{onClick:()=>B(a),disabled:r,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-hover transition-colors truncate disabled:opacity-50",children:(0,e.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function u({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:d,onOpenWorktree:f,onOpenAliasManager:o,onBranchSwitched:v}){let{t:w}=(0,j.Bd)(),x=b?.sessionId?(0,p.X)(b.engine,b.sessionId):null;return(0,e.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:w("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,i.oR)(w("toast.copiedPageUrl"),"success")})}}),a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${a}`,children:a}),(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(w("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:w("tabManagerTopBar.copyDirPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsxs)("button",{onClick:f,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:"Git Worktrees",children:[(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,e.jsx)("span",{className:"text-sm",children:d||"main"})]}),(0,e.jsx)(t,{cwd:a,currentBranch:d,onSwitched:()=>v?.()})]})]}),(0,e.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,e.jsx)(g.gT,{})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(h.ReviewDropdown,{cwd:a}),(0,e.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.refreshProject"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,q.em)(b.cwd).pipe(m.NWQ(()=>m.rIH)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openInVSCode"),children:(0,e.jsx)(r,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,q.Q1)(b.cwd).pipe(m.NWQ(()=>m.rIH)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openInCursor"),children:(0,e.jsx)(s,{className:"w-4 h-4"})}),x&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(x).then(()=>{(0,i.oR)(w("toast.copiedCommand",{command:x}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("chat.copyCommandTooltip",{command:x}),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.aliasesGlobal"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,e.jsx)("button",{onClick:()=>(0,k.F)(l.n.OpenTokenStats,{}),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.tokenStats"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,e.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openSurething"),children:(0,e.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}d()}catch(a){d(a)}})},38896:(a,b,c)=>{"use strict";c.d(b,{C:()=>f});var d=c(67484),e=c(36984);function f(a,b){let[c,f]=(0,d.useState)(null),[g,h]=(0,d.useState)(!1),i=(0,d.useMemo)(()=>a.join("\n"),[a]),j=`${i}:${b}:${g}`;return(0,d.useMemo)(()=>c&&c.key===j?c.html:a.map(a=>(0,e.ZD)(a||" ")),[a,j,c])}},39031:(a,b,c)=>{"use strict";c.d(b,{IS:()=>h});var d=c(32891),e=c(10259),f=c(87748);let g=new Set(["taskItem","listItem"]),h=d.YY.create({name:"dropShellCleanup",addProseMirrorPlugins:()=>[new e.k_({key:new e.hs("dropShellCleanup"),appendTransaction(a,b,c){let d=[];if(a.forEach((b,c)=>{let e;if("drop"!==b.getMeta("uiEvent")||!b.docChanged)return;let g=(e=[],b.steps.forEach((a,c)=>{a instanceof f.Ln&&(0!==a.slice.size||a.from>=a.to||e.push(b.mapping.slice(c+1).map(a.from)))}),e);for(let b=c+1;b<a.length;b++)g=g.map(c=>a[b].mapping.map(c));d.push(...g)}),0===d.length)return null;let e=c.tr,h=!1;for(let a of d){let b=function(a,b){if(b<0||b>a.content.size)return null;let c=a.resolve(b);for(let a=c.depth;a>0;a--){var d;if(d=c.node(a),!g.has(d.type.name)||1!==d.childCount||null===d.firstChild||!d.firstChild.isTextblock||0!==d.firstChild.content.size)continue;let b=a;for(;b>1&&1===c.node(b-1).childCount;)b--;return{from:c.before(b),to:c.after(b)}}return null}(e.doc,e.mapping.map(a));if(b)try{e.delete(b.from,b.to),h=!0}catch{}}return h?e:null}})]})},39238:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{N:()=>r});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(64825),k=c(66400),l=c(86588),m=c(64676),n=c(40893),o=c(6478),p=c(48587),q=a([p]);function r({filePath:a,content:b,cwd:c,onClose:d,onContentSearch:q}){let{t:s}=(0,g.Bd)(),t=(0,o.P)(),[u,v]=(0,f.useState)("preview");return(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.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"},"data-tooltip":a,onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(s("common.copiedPath"))},children:["‎",a]}),(0,e.jsx)("button",{onClick:()=>v(a=>"preview"===a?"source":"preview"),className:`px-1.5 py-0.5 text-xs rounded transition-colors flex-shrink-0 ${"preview"===u?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:"preview"===u?s("fileBrowser.exitPreview"):s("common.preview")}),(0,e.jsx)("button",{onClick:()=>t(a),title:s("htmlApps.addTooltip"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),d()},title:s("common.openInConsole"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{let b=(0,m.Xe)(a,c);window.open((0,m.PB)(b,window.location.origin),"_blank")},title:s("browser.openInNewWindow"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(l.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:"preview"===u?(0,e.jsx)(n.O,{content:b,filePath:a,cwd:c,onContentSearch:q?a=>{q(a),d()}:void 0}):(0,e.jsx)(p.y,{entryPath:a,entryContent:b,cwd:c})})]})})})}p=(q.then?(await q)():q)[0],d()}catch(a){d(a)}})},39247:(a,b,c)=>{"use strict";c.d(b,{h:()=>e});let d=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),e=a=>!d.has(a)},39796:(a,b,c)=>{"use strict";function d(a,b,c,d){return d&&c&&b.includes(a)}function e(a,b,c,d){let e=d?[c]:a;return{panes:e,activePane:d?0:b,row:e.length>1||d,split:e.length>1,diffOrder:e.length}}function f(a,b){return b&&a.split?a.panes[a.activePane]??null:null}function g(a,b,c,d,e){let f=b.indexOf(a);if(-1===f)return"relative hidden";if(e)return"absolute inset-0 z-30 border-y border-y-transparent";if(!d)return"relative h-full block";let g=b.length>1?` border-y ${f===c?"border-y-brand":"border-y-transparent"}`:"";return`relative h-full flex-1 min-w-0${g}${f>0?" border-l border-border":""}`}c.d(b,{XL:()=>f,gF:()=>d,p_:()=>e,vZ:()=>g})},40159:(a,b,c)=>{"use strict";c.d(b,{S:()=>l,j:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(44256),i=c(89719);function j({blame:a,onClick:b}){let{t:c}=(0,f.Bd)(),i=(0,e.useRef)(null),k=(0,e.useRef)(null),l=(0,h.F2)(),m=(0,e.useRef)(!1),n=(0,e.useRef)(!1),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=(0,e.useRef)(null),r=(0,e.useRef)(a),s=(0,e.useRef)(b),t=(0,e.useCallback)(()=>{let a,b=k.current,c=i.current;if(!b||!c)return;let d=c.getBoundingClientRect(),e=b.getBoundingClientRect(),f=l?.getBoundingClientRect(),g=f?.left??0,h=f?.top??0,j=f?.width??window.innerWidth,m=f?.height??window.innerHeight,n=d.left-g;n+e.width>j-8&&(n=j-e.width-8),n<8&&(n=8);let o=d.top-h,p=d.bottom-h;(a=o-e.height-4<0?p+4:o-e.height-4)+e.height>m-8&&(a=m-e.height-8),b.style.left=`${n}px`,b.style.top=`${a}px`},[l]),u=(0,e.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),p.current&&(clearTimeout(p.current),p.current=null),m.current=!1,n.current=!1,k.current&&(k.current.style.display="none"),q.current&&(document.removeEventListener("mousedown",q.current.down),document.removeEventListener("mouseup",q.current.up),q.current=null)},[]),v=(0,e.useCallback)(()=>{let a=k.current;if(!a||m.current)return;m.current=!0,a.style.left="-9999px",a.style.top="-9999px",a.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(t));let b=0,c=0,d=a=>{b=a.clientX,c=a.clientY},e=a=>{if(!(Math.abs(a.clientX-b)>5||Math.abs(a.clientY-c)>5)){let b;b=a.target,k.current?.contains(b)||i.current?.contains(b)||u()}};document.addEventListener("mousedown",d),document.addEventListener("mouseup",e),q.current={down:d,up:e}},[t,u]),w=(0,e.useCallback)(()=>{if(o.current&&clearTimeout(o.current),p.current&&(clearTimeout(p.current),p.current=null),m.current)return;let a=window.getSelection();(!a||a.isCollapsed)&&(o.current=setTimeout(v,500))},[v]),x=(0,e.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),m.current&&(p.current=setTimeout(()=>{n.current||u()},200))},[u]),y=(0,e.useCallback)(()=>{n.current=!0,p.current&&(clearTimeout(p.current),p.current=null)},[]),z=(0,e.useCallback)(()=>{n.current=!1,u()},[u]),A=(0,e.useCallback)(a=>{a.stopPropagation();let b=window.getSelection();b&&b.toString().length>0&&k.current?.contains(b.anchorNode)||(s.current?.(r.current),u())},[u]),B=a.message.split("\n")[0]||"",C=a.message.split("\n").slice(1).join("\n").trim();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{ref:i,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:w,onMouseLeave:x,children:[a.author.split(" ")[0],", ",function(a){let b=g.A.t,c=Math.floor((Date.now()-1e3*a)/1e3);if(c<60)return b("common.justNow");let d=Math.floor(c/60);if(d<60)return b("common.minutesAgo",{count:d});let e=Math.floor(d/60);if(e<24)return b("common.hoursAgo",{count:e});let f=Math.floor(e/24);if(f<30)return b("common.daysAgo",{count:f});let h=Math.floor(f/30);return h<12?b("common.monthsAgo",{count:h}):b("common.yearsAgo",{count:Math.floor(h/12)})}(a.time)," \xb7 ",B]}),(0,d.jsx)(h.ZL,{children:(0,d.jsxs)("div",{ref:k,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-lv3 p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:y,onMouseLeave:z,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,d.jsx)("span",{className:"font-mono text-brand",children:a.hash}),(0,d.jsx)("span",{className:"text-muted-foreground",children:a.author}),(0,d.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*a.time).toLocaleString()})]}),(0,d.jsx)("div",{className:"font-medium",children:B}),C&&(0,d.jsx)("div",{className:"mt-1 text-muted-foreground",children:C}),(0,d.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:A,children:c("codeViewer.clickToViewDetails")})]})})]})}let k=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}],l=(0,e.memo)(function({virtualKey:a,lineNum:b,highlightedHtml:c,hasComments:g,firstComment:h,lineCommentsCount:k,isInRange:l,showLineNumbers:m,lineNumChars:n,commentsEnabled:o,virtualItemSize:p,virtualItemStart:q,onCommentBubbleClick:r,onCmdClick:s,onTokenHover:t,onTokenHoverLeave:u,flashLine:v,blameLine:w,showBlameInfo:x,blameAuthorColor:y,isBlameHovered:z,onBlameClick:A,onBlameMouseEnter:B,onBlameMouseLeave:C,inlineBlameData:D,onInlineBlameClick:E,isCursorLine:F,cursorCol:G}){let{t:H}=(0,f.Bd)(),I=(0,e.useMemo)(()=>F&&null!=G?function(a,b){let c=0,d=0;for(;d<a.length;){if("<"===a[d]){let b=a.indexOf(">",d);if(-1!==b){d=b+1;continue}}if(c===b){let b;if("&"===a[d]){let c=a.indexOf(";",d);b=-1!==c&&c-d<10?c+1:d+1}else b=d+1;let c=a.substring(d,b);return a.substring(0,d)+'<span class="vi-char-cursor">'+c+"</span>"+a.substring(b)}if("&"===a[d]){let b=a.indexOf(";",d);d=-1!==b&&b-d<10?b+1:d+1}else d++;c++}return a+'<span class="vi-char-cursor"> </span>'}(c,G):c,[c,F,G]),J=(0,e.useCallback)(a=>{if(!a.metaKey||!s)return;a.preventDefault(),a.stopPropagation();let c=a.currentTarget,d=(0,i.j)(a,c);window.getSelection()?.removeAllRanges(),s(b,d)},[b,s]),K=(0,e.useCallback)(a=>{if(!t)return;let c=(0,i.A)(a,a.currentTarget);c&&t(b,c.column,c.rect)},[b,t]),L=(0,e.useCallback)(()=>{w&&A&&A(w)},[w,A]),M=(0,e.useCallback)(a=>{w&&B&&B(w,a)},[w,B]);return(0,d.jsxs)("div",{"data-line":b,style:{position:"absolute",top:0,left:0,width:"100%",height:`${p}px`,transform:`translateY(${q}px)`,backgroundColor:z&&y?y.bg:void 0},className:`flex ${v===b?"flash-line":""} ${F?"vi-cursor-line":""} ${l?"bg-blue-9/20":g?"bg-amber-9/10":"hover:bg-hover"}`,children:[(0,d.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-card",style:{backgroundImage:z&&y?`linear-gradient(${y.bg}, ${y.bg})`:void 0},children:[w&&y&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,d.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-hover",onMouseEnter:M,onMouseLeave:C,onClick:L,title:H("codeViewer.clickToViewCommit"),children:x?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"font-medium",style:{color:y.border},children:w.hash}),(0,d.jsx)("span",{className:"truncate flex-1",children:w.author.split(" ")[0]})]}):null})]}),m&&(0,d.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${l?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[o&&g&&h&&(0,d.jsx)("button",{onClick:a=>r(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:H("codeViewer.nComments",{count:k}),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.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"})})}),o&&!g&&(0,d.jsx)("span",{className:"w-4"}),(0,d.jsx)("span",{className:"text-right",style:{minWidth:`${n}ch`},children:b})]})]}),(0,d.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:J,onMouseOver:K,onMouseLeave:u,"data-code-content":!0,children:[(0,d.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),D&&(0,d.jsx)(j,{blame:D,onClick:E})]})]},a)})},40311:(a,b,c)=>{"use strict";function d(a,b){return"loading"===a?"relative session-number-running border-transparent bg-orange-11/15 text-orange-11":"unread"===a?"border-transparent bg-orange-11/15 text-orange-11":b?"border-transparent bg-brand/15 text-brand":"border-transparent bg-muted-foreground/15 text-muted-foreground"}c.d(b,{c:()=>d})},40699:(a,b,c)=>{"use strict";c.d(b,{u:()=>i});var d=c(67484),e=c(29939),f=c(85943),g=c(25414),h=c(30905);function i(a,b,c,i,j){let k=(0,d.useRef)(null),l=(0,d.useRef)(0),m=(0,d.useRef)(0),n=(0,d.useRef)(!1),o=(0,d.useRef)(!1),p=(0,d.useRef)(!1),q=(0,d.useRef)(void 0),r=()=>{let a=`live-asst-${++l.current}`;return k.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",isStreaming:!0}]),a},s=a=>{if((0,g.Nn)(a))return;let c=a=>{j?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(a))})},d=a=>{!n.current&&"string"==typeof a&&a&&(m.current+=(0,f.r)(a),c(m.current))};if("system"===a.type&&"init"===a.subtype){let a=o.current;p.current=!0,a||(m.current=0,n.current=!1,j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(Date.now())),r();return}if("usage_update"===a.type){"number"==typeof a.output_tokens&&Number.isFinite(a.output_tokens)&&(n.current=!0,m.current=Math.max(m.current,Math.round(a.output_tokens)),c(m.current));return}if("stream_event"===a.type){let b=a.event;b?.type==="content_block_delta"&&b.delta?.type==="text_delta"&&d(b.delta.text)}if("system"===a.type&&"background_tasks_changed"===a.subtype){let b=a.tasks??[];j?.onBackgroundTasks?.(b.filter(a=>!a.ambient).map(a=>({task_id:a.task_id,description:a.description})));return}if((0,g.A7)(a)&&(j?.taskStore?.applyEvent(a),b(b=>(0,g.FM)(b,a,{engine:i,assistantId:k.current??""})),"task_notification"!==a.subtype))return;if("system"===a.type&&"task_notification"===a.subtype){if(!p.current){let c=`live-tasknotif-${a.task_id||++l.current}`,d=`<task-notification>
20
- `+(a.task_id?`<task-id>${a.task_id}</task-id>
21
- `:"")+(a.tool_use_id?`<tool-use-id>${a.tool_use_id}</tool-use-id>
22
- `:"")+(a.status?`<status>${a.status}</status>
23
- `:"")+(a.summary?`<summary>${a.summary}</summary>
24
- `:"")+(a.output_file?`<output-file>${a.output_file}</output-file>
25
- `:"")+"</task-notification>";b(b=>[...b,{id:c,role:"system",content:a.summary||"",systemEvent:{kind:"task-notification",...a.status?{status:a.status}:{},detail:d}}])}return}if("system"===a.type&&"notice"===a.subtype){let c=(0,h.C)(a,`live-notice-${++l.current}`);c&&b(a=>[...a,c]);return}if("user"===a.type&&a._human){let c=a.message?.content,d="string"==typeof c?c:Array.isArray(c)?c.map(a=>a?.text||"").join(""):"",e="string"==typeof a._turnId?a._turnId:null;e&&(q.current=e);let f="number"==typeof a._ts?a._ts:null,g=e?`live-user-${e}`:`live-user-${++l.current}`;b(a=>{if(e&&a.some(a=>a.id===g))return a;for(let b=a.length-1;b>=0;b--){if("user"!==a[b].role)continue;let c=a[b].timestamp?Date.parse(a[b].timestamp):NaN;if(null===f||Number.isNaN(c)){if(a[b].content===d)return a}else if(c>=f)return a;break}return[...a,{id:g,role:"user",content:d}]});return}if("result"===a.type&&(p.current=!1,o.current=!0),"assistant"===a.type&&Array.isArray(a.message?.content))for(let b of a.message.content)b.text?d(b.text):b.name&&d(`${b.name} ${JSON.stringify(b.input??{})}`);if("user"===a.type&&Array.isArray(a.message?.content))for(let b of a.message.content)d("string"==typeof b.content?b.content:JSON.stringify(b.content??""));let e=k.current??r();b(b=>(0,g.FM)(b,a,{engine:i,assistantId:e}))};(0,e.h)({url:a?`/ws/session-stream?sessionId=${encodeURIComponent(a)}`:"/ws/session-stream",enabled:c&&!!a,onMessage:a=>{if("run-snapshot"===a.type&&Array.isArray(a.events)){if("string"==typeof a.runId&&a.runId&&(q.current=a.runId),"running"!==a.status){j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1;return}let c=a.events.find(a=>a?.type==="user"&&a?._human),d=c?.message?.content,e="string"==typeof d?d:"",f=new Set,h=new Set;for(let b of a.events){let a=b?.uuid;if("string"==typeof a&&f.add(a),b?.type==="assistant"&&Array.isArray(b.message?.content))for(let a of b.message.content)a?.name&&"string"==typeof a.id&&h.add(a.id)}let i="number"==typeof a.startedAt?a.startedAt:null;b(a=>{let b=a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("live-"))),c=b[b.length-1],d=c?.timestamp?Date.parse(c.timestamp):NaN;if(null!==i&&!Number.isNaN(d)){let a=b.length;for(;a>0;){let c=b[a-1],d=c.timestamp?Date.parse(c.timestamp):NaN;if(!Number.isNaN(d)&&d>=i)a--;else break}return a<b.length?b.slice(0,a):b}if(!e)return b;let g=-1;for(let a=b.length-1;a>=0;a--)if("user"===b[a].role){b[a].content===e&&(g=a);break}return -1===g?b:b.slice(g+1).every(a=>"assistant"===a.role&&("string"==typeof a.id&&f.has(a.id)||!!a.toolCalls?.length&&a.toolCalls.every(a=>h.has(a.id))))?b.slice(0,g):b}),k.current=null,l.current=0,m.current=0,n.current=!1,o.current=!1,p.current=!1;let r="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let b of(null!==r&&(m.current=r,n.current=!0,j?.onLiveOutputTokens?.({outputTokens:r})),a.events))s(b);j?.onRunningChange?.(!0),j?.onRunStartedAt?.("number"==typeof a.startedAt?a.startedAt:Date.now())}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1,j?.onComplete?.();return}s(a.message),j?.onRunningChange?.(!0)}else"run-idle"===a.type&&(j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1)}})}},40893:(a,b,c)=>{"use strict";c.d(b,{O:()=>m});var d=c(48249),e=c(67484),f=c(7031),g=c(41051),h=c(42140),i=c(64676),j=c(74754),k=c(91579),l=c(208);function m({content:a,filePath:b,cwd:c,onContentSearch:n,reloadKey:o=0}){let p=(0,f.r)(),q=!!c,r=(0,e.useMemo)(()=>(0,i.qF)(b,c)?{mode:"url",url:(0,i.Xe)(b,c)}:{mode:"srcdoc",html:a??""},[a,b,c]),{addComment:s,refresh:t}=(0,j._)({cwd:c||"",filePath:b}),[u,v]=(0,e.useState)(null),w=(0,e.useRef)(null),x=(0,e.useRef)(null),y=(0,e.useRef)(()=>{}),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(null),D=(0,e.useRef)(!1),E=(0,e.useCallback)(()=>{x.current&&(x.current=null,y.current())},[]),F=(0,e.useCallback)(()=>{let a=w.current,b=a?.contentWindow;if(b){let a=document.documentElement.classList.contains("dark");b.postMessage({type:"THEME_CHANGE",theme:a?"dark":"light"},"*"),b.postMessage({type:"cockpit:language-change",lang:l.A.language},"*")}if(!q)return;let c=a?.contentDocument;a&&c&&(c.addEventListener("mouseup",b=>{if(D.current)return;let c=a.contentWindow?.getSelection(),d=c&&!c.isCollapsed?c.toString().trim():"";if(!d)return void E();let e=a.getBoundingClientRect();x.current={x:e.left+b.clientX,y:e.top+b.clientY,range:{start:0,end:0},selectedText:d,lineSnapshot:d},y.current()}),c.addEventListener("mousedown",()=>{E(),A(null),C(null)}),c.addEventListener("scroll",()=>E(),{capture:!0,passive:!0}))},[q,E]),G=(0,e.useCallback)(()=>{let a=x.current;a&&(A({x:a.x,y:a.y,text:a.selectedText}),E(),w.current?.contentWindow?.getSelection()?.removeAllRanges())},[E]),H=(0,e.useCallback)(()=>{let a=x.current;a&&(C({x:a.x,y:a.y,text:a.selectedText}),E(),w.current?.contentWindow?.getSelection()?.removeAllRanges())},[E]),I=(0,e.useCallback)(()=>{let a=x.current;a&&p&&(E(),w.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,k.Ff)(p.sendMessage,{filePath:b,startLine:0,endLine:0,codeContent:a.selectedText},l.A.t("explain.selectionMessage")))},[p,b,E]),J=(0,e.useCallback)(()=>{let a=x.current;if(!a||!n)return;let b=a.selectedText.trim();E(),w.current?.contentWindow?.getSelection()?.removeAllRanges(),b&&n(b)},[n,E]),K=(0,e.useCallback)(async a=>{z&&(await s(0,0,a,z.text),A(null))},[z,s]),L=(0,e.useCallback)(async(a,d)=>{if(p&&c)try{let e=(await (0,k.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));e.push({filePath:b,startLine:0,endLine:0,codeContent:a});let f=(0,k.Gw)(e,d);p.sendMessage(f),await (0,k.RP)(c),t()}catch(a){console.error("[HtmlAppFrame] send to AI failed:",a)}},[p,c,b,t]),M=(0,e.useCallback)(a=>{B&&L(B.text,a)},[B,L]),N=(0,e.useCallback)(a=>{z&&L(z.text,a)},[z,L]);return(0,d.jsxs)("div",{ref:v,className:"relative h-full w-full bg-white",children:[(0,d.jsx)("iframe",{ref:w,..."url"===r.mode?{src:r.url}:{srcDoc:r.html},title:b,className:"h-full w-full border-0",onLoad:F},`${b}:${o}`),q&&u&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.fS,{floatingToolbarRef:x,bumpRef:y,container:u,onAddComment:G,onSendToAI:H,onSearch:n?J:void 0,onExplain:p?I:void 0,isChatLoading:p?.isLoading}),z&&(0,d.jsx)(h.t,{x:z.x,y:z.y,range:{start:0,end:0},filePath:b,lineSnapshot:z.text,container:u,onSubmit:K,onSendToAI:p?N:void 0,onClose:()=>A(null),isChatLoading:p?.isLoading}),B&&(0,d.jsx)(h.G,{x:B.x,y:B.y,range:{start:0,end:0},filePath:b,lineSnapshot:B.text,container:u,onSubmit:M,onClose:()=>C(null),isChatLoading:p?.isLoading})]})]})}},41051:(a,b,c)=>{"use strict";c.d(b,{SZ:()=>g,fS:()=>j});var d=c(48249),e=c(67484),f=c(44384);let g=[["quickReply.optionA","quickReply.optionB","quickReply.optionC","quickReply.optionD"],["quickReply.allRecommended","quickReply.thisOne","quickReply.notThis"],["quickReply.why","quickReply.elaborate","quickReply.example"],["quickReply.start","quickReply.continue","quickReply.ok","quickReply.done"]];function h({rows:a,placeAbove:b,onHeight:c,onPick:g,onEdit:i,onMouseEnter:j,onMouseLeave:k}){let{t:l}=(0,f.Bd)(),m=(0,e.useRef)(null);return(0,d.jsxs)("div",{ref:m,className:`absolute ${b?"bottom-full mb-1":"top-full mt-1"} left-0 z-[201] flex flex-col gap-1 bg-card border border-border rounded-lg shadow-lv3 p-1.5`,onMouseEnter:j,onMouseLeave:k,children:[i&&(0,d.jsx)("button",{className:"absolute top-0.5 right-0.5 p-1 text-muted-foreground hover:text-brand transition-colors",onClick:i,title:l("quickReply.edit"),"aria-label":l("quickReply.edit"),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.map((a,b)=>(0,d.jsx)("div",{className:`flex items-center gap-1${i&&0===b?" pr-5":""}`,children:a.map((a,c)=>(0,d.jsx)("button",{className:"px-2 py-1 text-xs whitespace-nowrap border border-border text-foreground rounded hover:border-brand hover:bg-hover transition-colors",onClick:()=>g(a),children:a},`${b}:${c}:${a}`))},b))]})}function i({x:a,y:b,visible:c,container:j,onAddComment:k,onSendToAI:l,onSearch:m,onExplain:n,onQuickReply:o,quickReplyRows:p,onEditQuickReplies:q,isChatLoading:r}){let{t:s}=(0,f.Bd)(),t=(0,e.useRef)(null),[u,v]=(0,e.useState)({w:0,h:0}),[w,x]=(0,e.useState)(0),[y,z]=(0,e.useState)(null),A=(0,e.useRef)(null),B=(0,e.useCallback)(a=>{x(b=>b===a?b:a)},[]),C=(0,e.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,e.useCallback)(a=>{C(),z(a)},[C]),E=(0,e.useCallback)(()=>{C(),A.current=setTimeout(()=>z(null),150)},[C]),F=j.getBoundingClientRect(),G=a-F.left,H=Math.max(0,b-F.top-40),I=Math.max(0,Math.min(G+8,F.width-u.w-8)),J=w>0&&H+u.h+8+w>F.height,K=(0,e.useMemo)(()=>p??g.map(a=>a.map(a=>s(a))),[p,s]),L=a=>o&&y===a?(0,d.jsx)(h,{rows:K,onEdit:q,placeAbove:J,onHeight:B,onPick:b=>{z(null),o(a,b)},onMouseEnter:C,onMouseLeave:E}):null;return(0,d.jsxs)("div",{ref:t,className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-lv3 p-1.5",style:{left:I,top:H,visibility:c?"visible":"hidden",pointerEvents:c?"auto":"none"},children:[(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>D("comment"),onMouseLeave:E,children:[(0,d.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:k,children:s("floatingToolbar.addComment")}),L("comment")]}),(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>{r||D("ai")},onMouseLeave:E,children:[(0,d.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:l,disabled:r,title:r?s("comments.aiResponding"):void 0,children:s("floatingToolbar.sendToAI")}),L("ai")]}),n&&(0,d.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:n,disabled:r,title:r?s("comments.aiResponding"):void 0,children:s("explain.action")}),m&&(0,d.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:m,children:s("floatingToolbar.search")})]})}let j=(0,e.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:f,onSendToAI:g,onSearch:h,onExplain:j,onQuickReply:k,quickReplyRows:l,onEditQuickReplies:m,isChatLoading:n}){let[o,p]=(0,e.useState)(0),q=(0,e.useMemo)(()=>a.current,[o]);return(0,d.jsx)(i,{x:q?.x??0,y:q?.y??0,visible:!!q,container:c,onAddComment:f,onSendToAI:g,onSearch:h,onExplain:j,onQuickReply:k,quickReplyRows:l,onEditQuickReplies:m,isChatLoading:n})})},41170:(a,b,c)=>{"use strict";c.d(b,{GR:()=>k,LM:()=>i,Ux:()=>l});let d={mode:"follow",pinTop:null},e={mode:"free",pinTop:null};function f(a){return Math.max(0,a.scrollHeight-a.spacer)}function g(a){return Math.max(0,f(a)-a.clientHeight)}function h(a,b){return a<=0?0:Math.max(0,a+b.clientHeight-f(b))}function i(a){return f(a)-a.scrollTop-a.clientHeight<50}function j(a,b="auto"){return{owner:d,spacer:0,scrollTo:g(a),behavior:b}}function k(a,b,c){if(!(c.clientHeight>0))return null;switch(b.type){case"reset":return{owner:d,spacer:0,scrollTo:null,behavior:"auto"};case"toEnd":return j(c,"smooth");case"readFrom":{let a=b.top;return{owner:{mode:"reading",pinTop:a},spacer:h(a,c),scrollTo:a,behavior:"auto"}}case"settle":{if("reading"===a.mode){let b=a.pinTop??c.scrollTop;return{owner:a,spacer:h(b,c),scrollTo:null,behavior:"auto"}}if(c.spacer<=0)return null;let b=Math.min(c.scrollTop,g(c));return{owner:b>=g(c)?d:e,spacer:0,scrollTo:b,behavior:"smooth",deferSpacer:!0}}case"pin":{let a=h(b.top,c);if(a<=0)return j(c);return{owner:{mode:"pinned",pinTop:b.top},spacer:a,scrollTo:b.top,behavior:"smooth"}}case"release":if("pinned"!==a.mode&&"reading"!==a.mode)return null;return{owner:e,spacer:h(c.scrollTop,c),scrollTo:null,behavior:"auto"};case"content":case"viewport":if("follow"===a.mode)return j(c);if("pinned"===a.mode){let d=a.pinTop??c.scrollTop,e=h(d,c);if(e<=0)return j(c);return{owner:a,spacer:e,scrollTo:"viewport"===b.type?d:null,behavior:"auto"}}if("reading"===a.mode){let d=a.pinTop??c.scrollTop;return{owner:a,spacer:h(d,c),scrollTo:"viewport"===b.type?d:null,behavior:"auto"}}return{owner:a,spacer:h(c.scrollTop,c),scrollTo:null,behavior:"auto"}}}function l(a,b){return"pinned"===a.mode||"reading"===a.mode?a:50>Math.abs(b.scrollTop-g(b))?d:e}},41224:(a,b,c)=>{"use strict";c.d(b,{$N:()=>y,$x:()=>H,Cr:()=>E,F4:()=>r,Fi:()=>o,Hw:()=>l,JC:()=>v,M5:()=>t,Ny:()=>m,QW:()=>z,ZQ:()=>G,Zr:()=>x,_9:()=>F,an:()=>D,dM:()=>q,dQ:()=>n,em:()=>k,hZ:()=>I,he:()=>p,l1:()=>u,nM:()=>i,n_:()=>w,qD:()=>C,td:()=>j,yS:()=>s,z2:()=>A});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>g("/api/session/user-messages",{cwd:a,sessionId:b}),j=()=>f("/api/settings"),k=a=>h("/api/settings",a),l=a=>f(`/api/${a}/credentials`),m=a=>f(`/api/${a}/credentials?reveal=1`),n=(a,b)=>h(`/api/${a}/credentials`,{apiKey:b}),o=a=>f(`/api/${a}/models`),p=()=>f("/api/deepseek/balance"),q=a=>f(`/api/${a}/usage`),r=()=>f("/api/ollama/config"),s=a=>h("/api/ollama/config",a),t=()=>f("/api/commands"),u=()=>f("/api/skills"),v=a=>g("/api/bash",a),w=a=>d.$mh({try:async()=>{let b=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return b.ok?await b.json():null},catch:a=>new e.uV({message:"POST /api/session-by-path failed",cause:a})}),x=(a,b)=>g(`/api/session/${encodeURIComponent(a)}/fork`,b),y=(a,b)=>f(`/api/session/${encodeURIComponent(a)}/turn`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),z=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),A=()=>f("/api/global-state").pipe(d.TjK(a=>a.sessions??[])),B=()=>d.$mh({try:async()=>{let a=await fetch("/api/ollama/models");return 503===a.status?{_tag:"not-running"}:a.ok?{_tag:"ok",models:(await a.json()).models??[]}:{_tag:"error",message:"Failed to fetch models"}},catch:a=>new e.uV({message:"fetch ollama models failed",cause:a})}),C=a=>d.JkU(function*(){let b=yield*B();if("not-running"!==b._tag)return b;a&&(yield*d.OH5(a));let c=yield*d.$mh({try:async()=>{let a=await fetch("/api/ollama/start",{method:"POST"}),b=await a.json().catch(()=>({}));return 404===a.status?{_tag:"not-installed",message:b.message||"Ollama is not installed"}:a.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:a=>new e.uV({message:"start ollama failed",cause:a})});if("not-installed"===c._tag)return{_tag:"not-installed",message:c.message};if("error"===c._tag)return{_tag:"error",message:c.message};let f=yield*B();return"not-running"===f._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:f}),D=a=>f(`/api/file?path=${encodeURIComponent(a)}`),E=()=>f("/api/claude-stats"),F=a=>Array.isArray(a.items),G=()=>f("/api/instructions/config?scope=global"),H=a=>f(`/api/instructions/config?cwd=${encodeURIComponent(a)}`),I=a=>g("/api/instructions/config",a)},41357:(a,b,c)=>{"use strict";c.d(b,{H:()=>e});var d=c(67484);function e({cwd:a,selectedPath:b,gitStatusMap:c,renameOldPaths:f,isText:g,refreshKey:h}){let i=b?c?.get(b):void 0,j=g&&("M"===i||"R"===i),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(()=>new Set);(0,d.useRef)(new Set);let q=j&&!!b&&o.has(b);return{canDiff:j,showDiff:q,toggleDiff:(0,d.useCallback)(()=>{b&&p(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},[b]),diff:k,isLoadingDiff:m}}c(79606),c(33281),c(85655)},42140:(a,b,c)=>{"use strict";c.d(b,{G:()=>h,t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,range:c,filePath:h,lineSnapshot:i,container:j,onSubmit:k,onSendToAI:l,onClose:m,isChatLoading:n}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(!1),t=(0,e.useRef)(null),u=(0,e.useRef)(null),[v,w]=(0,e.useState)({x:0,y:0}),x=i?.split("\n").slice(0,5).join("\n"),y=!!i&&i.split("\n").length>5,z=()=>{!r&&p.trim()&&(s(!0),k(p.trim()))};return(0,d.jsxs)("div",{ref:t,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:v.x,top:v.y},children:[(0,d.jsxs)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-amber-11",children:o("comments.addComment")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:o("comments.lineRange",{start:c.start,end:c.end})})]}),h&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:h})]}),i&&(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[x,y&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:u,value:p,onChange:a=>q(a.target.value),placeholder:o("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:r,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),z()),"Escape"!==a.key||r||m()}}),(0,d.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:o(r?"comments.submitting":"comments.enterSubmit")}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-amber-11 text-amber-11 rounded-md hover:bg-amber-9/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:z,disabled:r||!p.trim(),children:o("comments.submitComment")}),l&&(0,d.jsx)("button",{className:"px-3 py-1 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:()=>{!r&&!n&&l&&p.trim()&&(s(!0),l(p.trim()),m())},disabled:r||n||!p.trim(),title:n?o("comments.aiResponding"):void 0,children:o("comments.sendToAI")})]})]})]})]})}function h({x:a,y:b,range:c,filePath:g,lineSnapshot:i,container:j,onSubmit:k,onClose:l,isChatLoading:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)(""),q=(0,e.useRef)(null),r=(0,e.useRef)(null),[s,t]=(0,e.useState)({x:0,y:0}),u=i?.split("\n").slice(0,5).join("\n"),v=!!i&&i.split("\n").length>5;return(0,d.jsxs)("div",{ref:q,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:s.x,top:s.y},children:[(0,d.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-brand",children:n("comments.askAI")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:n("comments.lineRange",{start:c.start,end:c.end})})]}),g&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:g})]}),i&&(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[u,v&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:r,value:o,onChange:a=>p(a.target.value),placeholder:n("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:m,onKeyDown:a=>{"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),!m&&o.trim()&&(k(o.trim()),l())),"Escape"===a.key&&l()}}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:n(m?"comments.aiGenerating":"comments.enterSend")})]})]})}},42319:(a,b,c)=>{"use strict";function d(a,b){return a?.cwd&&a.sessionId&&(a.cwd!==b.cwd||b.sessionId&&a.sessionId!==b.sessionId)?{cwd:a.cwd,sessionId:a.sessionId}:null}c.d(b,{_:()=>d})},42390:(a,b,c)=>{"use strict";c.d(b,{P:()=>f});var d=c(67484),e=c(4325);function f(){let a=(0,d.useSyncExternalStore)(e.N4,e.fX,e.fX),b=(0,d.useCallback)(()=>{(0,e._I)()},[]);return{isUpdating:a.visible&&"done"!==a.stage&&"failed"!==a.stage,start:b}}},42910:(a,b,c)=>{"use strict";c.d(b,{Z:()=>k});var d=c(48249),e=c(67484),f=c(44256),g=c(63565),h=c(33281),i=c(41224);let j={deepseek:{label:"DeepSeek",apiKeysUrl:"https://platform.deepseek.com/api_keys",modelsEndpoint:"/v1/models"},kimi:{label:"Kimi",apiKeysUrl:"https://www.kimi.com/code/console",modelsEndpoint:"/coding/v1/models"},glm:{label:"GLM",apiKeysUrl:"https://bigmodel.cn/apikey/platform",modelsEndpoint:"/coding/paas/v4/models",regions:[{id:"cn",label:"中国大陆",hint:"open.bigmodel.cn"},{id:"global",label:"International",hint:"api.z.ai"}]}};function k({engine:a,currentModel:b,onModelChange:c,onHasKeyChange:l}){let m=j[a],[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)([]),[H,I]=(0,e.useState)(null),[J,K]=(0,e.useState)(null),L=(0,e.useRef)(null),M=(0,e.useRef)(null),N=(0,e.useRef)(null),O=(0,e.useRef)(null);(0,e.useRef)(b),(0,e.useRef)(c),(0,e.useRef)(l);let[P,Q]=(0,e.useState)({top:0,left:0}),R=(0,f.F2)(),S=(0,e.useCallback)(async()=>{y(!0),C(null),I(null);let[d,e]=await Promise.all([h.t4.runPromiseExit((0,i.Hw)(a)),h.t4.runPromiseExit((0,i.td)())]);if("Failure"===d._tag){C("Failed to load settings"),y(!1);return}q(d.value.hasKey),s(d.value.maskedKey),u(""),w(!1);let f="Success"===e._tag?e.value:void 0,g=f?.engines?.[a],j=g?.builtinModel;m.regions&&K(g?.region??("en"===f?.language?"global":"cn"));let k=[];if(d.value.hasKey){let b=await h.t4.runPromiseExit((0,i.Fi)(a));"Success"===b._tag?k=b.value.models:I("Failed to load models — check the API key")}G(k);let l=k.map(a=>a.id),n=j&&l.includes(j)?j:l[0];!n||b&&l.includes(b)||c(n),y(!1)},[a,b,c,m.regions]),T=(0,e.useCallback)(async b=>{let c=await h.t4.runPromiseExit((0,i.td)()),d=("Success"===c._tag?c.value:{}).engines||{},e={...d,[a]:{...d[a]||{},builtinModel:b}};if("Failure"===(await h.t4.runPromiseExit((0,i.em)({engines:e})))._tag)throw Error("Failed to save settings")},[a]),U=(0,e.useCallback)(async b=>{K(b);let c=await h.t4.runPromiseExit((0,i.td)()),d=("Success"===c._tag?c.value:{}).engines||{};"Failure"===(await h.t4.runPromiseExit((0,i.em)({engines:{...d,[a]:{...d[a]||{},region:b}}})))._tag?C("Failed to save region"):S()},[a,S]),V=async()=>{let b=t.trim();if(!b)return;A(!0),C(null);let c=await h.t4.runPromiseExit((0,i.dQ)(a,b));"Failure"===c._tag?C("Save failed"):(q(c.value.hasKey),s(c.value.maskedKey),u(""),w(!1),S()),A(!1)},W=async()=>{A(!0),C(null);let b=await h.t4.runPromiseExit((0,i.dQ)(a,""));"Failure"===b._tag?C("Clear failed"):(q(b.value.hasKey),s(b.value.maskedKey),u(""),w(!1),G([])),A(!1)},X=async()=>{let b=await h.t4.runPromiseExit((0,i.Ny)(a));if("Failure"===b._tag||!b.value.apiKey)return void C("Copy failed");try{await navigator.clipboard.writeText(b.value.apiKey)}catch{C("Clipboard unavailable");return}C(null),E(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>E(!1),1500)},Y=async a=>{c(a);try{await T(a)}catch{}},Z=p?b||"Select model":"Set API key",$=p?void 0:g.Aw,_=b||"",aa=n?(0,d.jsx)(f.ZL,{children:(0,d.jsx)("div",{ref:M,className:`${g.ys} min-w-[280px]`,style:{top:P.top,left:P.left},children:x?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),(0,d.jsx)("a",{href:m.apiKeysUrl,target:"_blank",rel:"noopener","data-testid":`${a}-api-keys-link`,title:`Open ${m.label} API keys page`,"aria-label":`Open ${m.label} API keys page`,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]}),p&&!v?(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:r}),(0,d.jsx)("button",{onClick:X,"data-testid":`${a}-copy-api-key`,title:D?"Copied":"Copy API key","aria-label":"Copy API key",className:`p-1 rounded transition-colors ${D?"text-green-11":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,disabled:z,children:D?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:()=>{w(!0),u(""),setTimeout(()=>N.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:z,children:"Edit"}),(0,d.jsx)("button",{onClick:W,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:z,children:"Clear"})]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:N,type:"password",value:t,onChange:a=>u(a.target.value),onKeyDown:a=>{"Enter"===a.key&&V()},placeholder:"sk-...",className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${g.Fx}`,autoFocus:!0}),(0,d.jsx)("button",{onClick:V,disabled:z||!t.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${g.$T}`,children:z?"Saving...":"Save"}),p&&(0,d.jsx)("button",{onClick:()=>{w(!1),u("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),B&&(0,d.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:B})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"}),m.regions&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Region"}),(0,d.jsx)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":`${a}-region-toggle`,children:m.regions.map(b=>(0,d.jsx)("button",{type:"button","data-testid":`${a}-region-${b.id}`,onClick:()=>U(b.id),title:b.hint,className:`px-2 py-0.5 ${J===b.id?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-hover"}`,children:b.label},b.id))})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"})]}),(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),H&&(0,d.jsx)("div",{className:"mb-1 text-[11px] text-red-11",children:H}),!H&&0===F.length&&(0,d.jsx)("div",{className:"mb-1 text-[11px] text-muted-foreground",children:p?`No models returned by ${m.modelsEndpoint}`:"Save an API key to list models"}),(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:F.map(a=>{var b;let c=_===a.id,e=(b=a.contextTokens)&&!(b<=0)?b>=1048576?`${Math.round(b/1048576)}M`:`${Math.round(b/1024)}K`:null;return(0,d.jsxs)("button",{onClick:()=>Y(a.id),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${c?g.yI:"text-foreground hover:bg-hover"}`,children:[(0,d.jsx)(g.hG,{selected:c}),(0,d.jsx)("span",{className:"truncate",children:a.id}),a.label&&a.label!==a.id&&(0,d.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:a.label}),e&&(0,d.jsx)("span",{className:"ml-auto pl-2 text-[10px] text-muted-foreground flex-shrink-0",children:e})]},a.id)})})]})]})})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.XY,{buttonRef:L,label:Z,labelClassName:$,title:`Configure ${m.label}`,onClick:()=>{if(!n){if(L.current){let a=L.current.getBoundingClientRect(),b=R?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;Q({top:a.bottom+4-d,left:a.left-c})}S()}o(a=>!a)},icon:(0,d.jsx)(g.eV,{engine:a}),testId:`${a}-config-picker`}),aa]})}},43037:(a,b,c)=>{"use strict";c.d(b,{E3:()=>g});var d=c(32891);function e(a){return a.classList.contains("task-list-item")}let f=/^\s*\[\/\]\s?/,g=d.YY.create({name:"markdownTaskListFix",addStorage:()=>({markdown:{parse:{updateDOM(a){var b;for(let c of Array.from(a.querySelectorAll("li"))){if(e(c))continue;let a=c.parentElement;a&&"UL"===a.tagName&&(b=c.textContent||"",/^\s*\[\/\]/.test(b)&&(!function(a){let b=a.ownerDocument.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=b.nextNode();for(;c&&!(c.nodeValue&&""!==c.nodeValue.trim());)c=b.nextNode();c&&c.nodeValue&&(c.nodeValue=c.nodeValue.replace(f,""))}(c),c.classList.add("task-list-item"),c.setAttribute("data-type","taskItem"),c.setAttribute("data-status","doing"),a.classList.add("contains-task-list")))}!function(a){for(let b of Array.from(a.querySelectorAll("ul.contains-task-list"))){let a=Array.from(b.children).filter(a=>"LI"===a.tagName);if(0===a.length)continue;let c=function(a){let b=[];for(let c of a){let a=b[b.length-1];a&&a.isTask===c.isTask?a.items.push(c):b.push({isTask:c.isTask,items:[c]})}return b}(a.map(a=>({isTask:e(a),el:a})));if(c.length<=1){c[0]?.isTask&&b.setAttribute("data-type","taskList");continue}let d=b.ownerDocument,f=d.createDocumentFragment();for(let a of c){let b=d.createElement("ul");for(let{el:c}of(a.isTask&&(b.setAttribute("class","contains-task-list"),b.setAttribute("data-type","taskList")),a.items))b.appendChild(c);f.appendChild(b)}b.replaceWith(f)}}(a)}}}})})},43209:(a,b,c)=>{"use strict";c.d(b,{Q:()=>n});var d=c(48249),e=c(67484),f=c(44384),g=c(15819),h=c(57031),i=c(88214),j=c(33281),k=c(41224),l=c(32753),m=c(74228);function n({isOpen:a,onClose:b,cwd:c,onSelectSession:o,projectNumber:p,openSessionIds:q=[]}){let{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)([]),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(""),A=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a;if(!c)return;v(!0),x(null);let b=(a=c.replace(/[^a-zA-Z0-9]/g,"-")).length<=200?a:`${a.slice(0,200)}-${function(a){let b=0;for(let c=0;c<a.length;c++)b=(b<<5)-b+a.charCodeAt(c)|0;return Math.abs(b).toString(36)}(c)}`,d=await j.t4.runPromiseExit((0,k.QW)(b));"Success"===d._tag?t(d.value):x("Failed to load sessions"),v(!1)},[c]);let B=s.filter(a=>{if(!y)return!0;let b=y.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:g.iG,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate","data-tooltip":c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{ref:A,type:"text",placeholder:r("sessions.searchSessions"),value:y,onChange:a=>z(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),y&&(0,d.jsx)("button",{onClick:()=>{z(""),A.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:r("fileBrowser.clear"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[u&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:r("sessions.loadingSessions")})]})}),w&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:w})}),!u&&!w&&0===B.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:r(y?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!u&&!w&&B.length>0&&(0,d.jsx)("div",{className:g.jL,children:B.map(a=>{let e=a.path.split("/").pop()||"",f=a.sessionId||e.replace(".jsonl",""),g=q.indexOf(f);return(0,d.jsxs)("div",{onClick:()=>{let d,e;return d=a.path.split("/").pop()||"",e=a.sessionId||d.replace(".jsonl",""),void(o?(o(e,a.title),b()):(0,h.F)(i.n.OpenProject,{cwd:c,sessionId:e}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)(l.S,{engine:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":a.title,children:a.title}),p&&g>=0&&(0,d.jsx)(m.l,{projectNumber:p,sessionNumber:g+1,className:"ml-auto"})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path)})})]})]})]}):null}},43321:(a,b,c)=>{"use strict";c.d(b,{D:()=>f});let d=/^\s*[-*+]\s+(?:\\?\[ \\?\]|\\?\[[xX/]\\?\])\s*$/,e=/^\s*(```|~~~)/;function f(a){if(!a)return a;let b=a.split("\n"),c=[],f=!1;for(let a of b){if(e.test(a)){f=!f,c.push(a);continue}if(f){c.push(a);continue}d.test(a)||c.push(a)}let g=[],h=0,i=!1;for(let a of c){if(e.test(a)){i=!i,g.push(a),h=0;continue}if(!i&&""===a.trim()){if((h+=1)>=2)continue;g.push(a);continue}h=0,g.push(a)}return g.join("\n")}},43489:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,60440,23)),Promise.resolve().then(c.t.bind(c,84342,23)),Promise.resolve().then(c.t.bind(c,82265,23)),Promise.resolve().then(c.t.bind(c,35421,23)),Promise.resolve().then(c.t.bind(c,61335,23)),Promise.resolve().then(c.t.bind(c,70664,23)),Promise.resolve().then(c.bind(c,74661))},44256:(a,b,c)=>{"use strict";c.d(b,{F2:()=>m,ZL:()=>k,a9:()=>l});var d=c(48249),e=c(67484),f=c(74429);let g=()=>()=>{},h=()=>document.body,i=()=>null,j=(0,e.createContext)(null);function k({children:a}){let b=(0,e.useContext)(j),c=(0,e.useSyncExternalStore)(g,h,i),d=b??c;return d?(0,f.createPortal)(a,d):null}function l({children:a}){let[b,c]=(0,e.useState)(null);return(0,d.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,d.jsx)(j.Provider,{value:b,children:a}),(0,d.jsx)("div",{ref:c,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function m(){return(0,e.useContext)(j)}},44616:(a,b,c)=>{Promise.resolve().then(c.bind(c,67045))},46242:(a,b,c)=>{"use strict";c.d(b,{M:()=>g});var d=c(48249),e=c(88018);let f=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function g({cwd:a,filePath:b,oldRev:c,newRev:h}){return(0,d.jsx)(e.K,{filePath:b,oldSrc:c?f(a,c,b):null,newSrc:h?f(a,h,b):null})}},47276:(a,b,c)=>{"use strict";c.d(b,{m3:()=>i,mi:()=>g,ot:()=>h});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/html-apps"),h=a=>f("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/api/html-apps/${encodeURIComponent(a)}`,{method:"DELETE"})},47604:(a,b,c)=>{"use strict";c.d(b,{f:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(63565),i=c(41224);let j={CNY:"\xa5",USD:"$"};function k({hasKey:a}){let{t:b}=(0,f.Bd)(),[c,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(null),q=(0,e.useCallback)(async()=>{l(!0),p(null);let a=await g.t4.runPromiseExit((0,i.he)());"Failure"===a._tag?(n(null),p(b("chat.balanceFailed",{defaultValue:"Query failed — check the API key"}))):n(a.value),l(!1)},[b]),r=m?m.balances.map(a=>`${j[a.currency]??(a.currency?`${a.currency} `:"")}${a.totalBalance}`).join(" / "):"",s=!!(m&&!m.isAvailable);return(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[c&&(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!c&&o&&(0,d.jsx)("span",{className:"text-xs text-red-11",children:o}),!c&&!o&&m&&(0,d.jsx)("span",{className:`text-xs font-mono ${s?"text-red-11":h.pe.deepseek}`,"data-tooltip":s?b("chat.balanceUnavailable",{defaultValue:"Account is not available for requests"}):void 0,"data-testid":"deepseek-balance-value",children:r||b("chat.balanceEmpty",{defaultValue:"No balance returned"})}),(0,d.jsx)("button",{type:"button","data-testid":"deepseek-balance-button",disabled:!a||c,onClick:q,"data-tooltip":a?void 0:b("chat.balanceNeedsKey",{defaultValue:"Set a DeepSeek API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:b("chat.checkBalance",{defaultValue:"Check balance"})}),(0,d.jsx)("a",{href:"https://platform.deepseek.com/usage",target:"_blank",rel:"noopener","data-testid":"deepseek-usage-link",title:b("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),"aria-label":b("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}},47938:(a,b,c)=>{"use strict";c.d(b,{SessionBrowser:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call SessionBrowser() from the server but SessionBrowser is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/SessionBrowser.tsx","SessionBrowser")},48587:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{y:()=>k});var e=c(48249),f=c(67484),g=c(33407),h=c(62742);c(33281);var i=c(55287);c(87808),c(25419);var j=a([i]);function k({entryPath:a,entryContent:b}){let c,d=(0,f.useMemo)(()=>{let b,c;return(c=(b=a.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":b.slice(0,c)},[a]),j=(0,f.useRef)(new Map),[l,m]=(0,f.useState)([]),[n,o]=(0,f.useState)(a),[p,q]=(0,f.useState)(!0),r=l.find(a=>a.abs===n),s=l.length>1||p;return(0,e.jsxs)("div",{className:"flex h-full",children:[s&&(0,e.jsxs)("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto",children:[l.map(a=>(0,e.jsxs)("button",{onClick:()=>o(a.abs),"data-tooltip":a.rel,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 min-w-0 transition-colors ${n===a.abs?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover"}`,children:["image"===a.kind?(0,e.jsx)(g.A,{className:"w-3.5 h-3.5 flex-shrink-0"}):(0,e.jsx)(h.A,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:a.rel})]},a.abs)),p&&(0,e.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"…"})]}),(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:r?.kind==="image"?(0,e.jsx)("div",{className:"h-full flex items-center justify-center p-4 overflow-auto bg-background",children:(0,e.jsx)("img",{src:`/api/file?path=${encodeURIComponent(n)}&raw=true`,alt:(c=n.replace(/\\/g,"/")).slice(c.lastIndexOf("/")+1),className:"max-w-full max-h-full object-contain"})}):(0,e.jsx)(i.Cv,{content:j.current.get(n)??"",filePath:n,cwd:d},n)})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},48830:(a,b,c)=>{"use strict";c.d(b,{n:()=>x});var d=c(48249),e=c(67484),f=c(44384),g=c(7833),h=c(15819),i=c(10316),j=c(46674),k=c(24520),l=c(50514),m=c(15273),n=c(45231),o=c(66400),p=c(86588),q=c(82594),r=c(59347),s=c(33281),t=c(64676),u=c(40893),v=c(35857),w=c(47276);function x({isOpen:a,htmlAppPreviews:b,activeHtmlAppPreviewPath:c,onShowHtmlAppPreview:r,onMinimizeHtmlAppPreview:z,onCloseHtmlAppPreview:A,onClose:B,onOpenApp:C}){let{t:D,i18n:E}=(0,f.Bd)(),[F,G]=(0,e.useState)([]),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(""),[L,M]=(0,e.useState)(!1),[N,O]=(0,e.useState)(""),[P,Q]=(0,e.useState)(!1),[R,S]=(0,e.useState)({}),T=(0,e.useRef)(null),U=(0,e.useCallback)(async()=>{I(!0);let a=await s.t4.runPromiseExit((0,w.mi)());"Success"===a._tag?G(a.value):console.error("Failed to load html apps",a.cause),I(!1)},[]),V=(0,e.useCallback)(()=>{M(!1),B()},[B]),W=(0,e.useMemo)(()=>{let a=J.trim().toLowerCase();return a?F.filter(b=>b.name.toLowerCase().includes(a)||b.title.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):F},[F,J]),X=(0,e.useMemo)(()=>F.filter(a=>!a.builtin).length,[F]),Y=J.trim().length>0,Z=E.resolvedLanguage?.startsWith("zh")?"https://opencockpit.dev/zh/docs/agent/html-apps/":"https://opencockpit.dev/en/docs/agent/html-apps/",$=(0,e.useCallback)(async()=>{let a=N.trim();if(!a)return;Q(!0);let b=await s.t4.runPromiseExit((0,w.ot)(a));if("Success"===b._tag)b.value.alreadyExists?(0,g.oR)(D("htmlApps.alreadyAdded"),"info"):((0,g.oR)(D("htmlApps.added"),"success"),(0,v.N)()),O(""),M(!1),await U();else{let a="Fail"===b.cause._tag?b.cause.error:null,c=a?.cause,d=c instanceof Error?c.message:D("htmlApps.addFailed");(0,g.oR)(d,"error")}Q(!1)},[N,U,D]),_=(0,e.useCallback)(async a=>{"Success"===(await s.t4.runPromiseExit((0,w.m3)(a)))._tag?(G(b=>b.filter(b=>b.id!==a)),(0,v.N)()):(0,g.oR)(D("common.deleteFailed"),"error")},[D]),aa=(0,e.useCallback)(a=>{C?C(a):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),V()},[V,C]),ab=(0,e.useCallback)(a=>{C?C(a):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),z()},[z,C]),ac=(0,e.useCallback)(a=>{let b=(0,t.Xe)(a);window.open((0,t.PB)(b,window.location.origin),"_blank")},[]),ad=(0,e.useCallback)(a=>{S(b=>({...b,[a]:(b[a]||0)+1}))},[]),ae=(0,e.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,g.oR)(D("common.copiedPath"),"success")}catch{(0,g.oR)(D("common.copyFailed"),"error")}},[D]);return(0,d.jsxs)(d.Fragment,{children:[a&&(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:V}),(0,d.jsxs)("div",{className:h.aO,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:D("htmlApps.title")}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(i.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-foreground-subtle pointer-events-none"}),(0,d.jsx)("input",{ref:T,type:"text",value:J,onChange:a=>K(a.target.value),placeholder:D("htmlApps.searchPlaceholder"),className:"pl-7 pr-6 py-1 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),J&&(0,d.jsx)("button",{onClick:()=>{K(""),T.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:D("fileBrowser.clear"),children:(0,d.jsx)(j.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("button",{onClick:()=>M(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:D("htmlApps.addHtmlApp"),children:[(0,d.jsx)(k.A,{className:"w-4 h-4"})," ",D("htmlApps.add")]}),(0,d.jsx)("button",{onClick:V,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:D("common.close"),children:(0,d.jsx)(j.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:H?(0,d.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:D("common.loading")}):(0,d.jsxs)(d.Fragment,{children:[W.length>0&&(0,d.jsx)("div",{className:h.jL,children:W.map(a=>(0,d.jsx)(y,{app:a,onOpenConsole:()=>aa(a.path),onOpenExternal:()=>ac(a.path),onPreview:()=>{r({path:a.path,title:a.title,icon:a.icon}),V()},onDelete:()=>_(a.id),onCopyPath:()=>ae(a.path)},a.id))}),0===W.length&&Y&&(0,d.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:D("htmlApps.emptyNoMatch")}),!Y&&0===X&&(0,d.jsxs)("div",{className:`text-center text-muted-foreground py-8 text-sm space-y-2${W.length>0?" mt-4 border-t border-border/60":""}`,children:[(0,d.jsx)("p",{children:D("htmlApps.emptyNoApps")}),(0,d.jsxs)("p",{children:[D("htmlApps.emptyCreatePrefix")," ",(0,d.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/html"})," ",D("htmlApps.emptyCreateSuffix")]}),(0,d.jsxs)("p",{children:[(0,d.jsx)("button",{type:"button",onClick:()=>M(!0),className:"text-brand hover:underline",children:D("htmlApps.addExisting")})," \xb7 ",(0,d.jsx)("a",{href:Z,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline",children:D("htmlApps.viewDocs")})]})]})]})})]})]}),a&&L&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:()=>{P||(M(!1),O(""))}}),(0,d.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-lg mx-4 p-5",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:D("htmlApps.addHtmlApp")}),(0,d.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:D("htmlApps.pathLabel")}),(0,d.jsx)("input",{type:"text",value:N,onChange:a=>O(a.target.value),onKeyDown:a=>{"Enter"!==a.key||P||$()},placeholder:"/Users/you/.../report.html",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,d.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,d.jsx)("button",{onClick:()=>{M(!1),O("")},disabled:P,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:D("common.cancel")}),(0,d.jsx)("button",{onClick:$,disabled:P||!N.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:P?D("htmlApps.adding"):D("htmlApps.add")})]})]})]}),b.map(a=>{let b=c===a.path;return(0,d.jsx)("div",{className:b?"fixed inset-0 z-[60] flex items-center justify-center bg-scrim p-0 md:p-4":"hidden",onClick:z,children:(0,d.jsxs)("div",{className:"bg-card shadow-lv3 border border-brand/30 w-full h-full md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.icon?(0,d.jsx)("span",{className:"text-base leading-none flex-shrink-0",children:a.icon}):(0,d.jsx)(l.A,{className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[35%]","data-tooltip":a.title,children:a.title}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground flex-shrink-0","aria-hidden":"true",children:"-"}),(0,d.jsx)("span",{className:"font-mono text-sm text-muted-foreground truncate min-w-0","data-tooltip":a.path,children:a.path}),(0,d.jsx)("button",{onClick:()=>ae(a.path),className:"text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.copyPath"),"aria-label":D("common.copyPath"),children:(0,d.jsx)(m.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("button",{onClick:z,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.minimize"),children:(0,d.jsx)(n.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ab(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.openInConsole"),children:(0,d.jsx)(o.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ac(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("browser.openInNewWindow"),children:(0,d.jsx)(p.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ad(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.refresh"),children:(0,d.jsx)(q.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>A(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,d.jsx)(u.O,{filePath:a.path,reloadKey:R[a.path]||0})})]})},a.path)})]})}function y({app:a,onOpenConsole:b,onOpenExternal:c,onPreview:g,onDelete:h,onCopyPath:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:`group flex flex-col h-full border border-border rounded-lg p-3 hover:border-brand hover:shadow-lv2 transition-all cursor-pointer ${a.valid?"":"opacity-60"}`,onClick:()=>a.valid&&g(),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,d.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:a.icon?(0,d.jsx)("span",{children:a.icon}):(0,d.jsx)(p.A,{className:"w-5 h-5"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground truncate","data-tooltip":a.title,children:a.title}),(0,d.jsxs)("div",{className:"font-mono text-[11px] text-muted-foreground truncate","data-tooltip":`/${a.name}`,children:["/",a.name]})]}),!a.valid&&(0,d.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:j("htmlApps.invalid")}),a.builtin&&(0,d.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:j("htmlApps.builtin")}),(0,d.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("button",{onClick:b,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:j("common.openInConsole"),children:(0,d.jsx)(o.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:c,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:j("browser.openInNewWindow"),children:(0,d.jsx)(p.A,{className:"w-4 h-4"})}),a.builtin?null:k?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>{l(!1),h()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:j("common.confirm")}),(0,d.jsx)("button",{onClick:()=>l(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:j("common.cancel")})]}):(0,d.jsx)("button",{onClick:()=>l(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:j("common.delete"),children:(0,d.jsx)(r.A,{className:"w-4 h-4"})})]})]}),(0,d.jsxs)("div",{className:"font-mono text-xs text-muted-foreground mt-2 break-all",children:[a.path,(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),i()},className:"inline-flex align-middle ml-1 p-0.5 hover:text-foreground hover:bg-hover rounded transition-colors",title:j("common.copyPath"),children:(0,d.jsx)(m.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("p",{className:"text-sm text-muted-foreground mt-2 pt-2 border-t border-border/60 break-words whitespace-pre-wrap",children:a.description||(0,d.jsx)("span",{className:"italic opacity-60",children:j("htmlApps.noDescription")})})]})}},50508:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{LD:()=>l,Mm:()=>j,Qr:()=>a,fw:()=>i,o$:()=>k});var e=c(48249),f=c(67484),g=c(33281),h=c(85655);let a=a=>a.split("/").pop()||a;function i(a,b){let c=Math.floor((Date.now()-b)/6e4);if(c<1)return a("common.justNow");if(c<60)return a("common.minutesAgo",{count:c});let d=Math.floor(c/60);return d<24?a("common.hoursAgo",{count:d}):a("common.daysAgo",{count:Math.floor(d/24)})}function j(a,b){return"loading"===b?a("sessions.running"):"unread"===b?a("sessions.done"):void 0}function k(){let[a,b]=(0,f.useState)(null),[c,d]=(0,f.useState)({}),e=(0,f.useCallback)((a,c)=>{let e=c.currentTarget.getBoundingClientRect(),f=e.top;f+260>window.innerHeight&&(f=Math.max(8,window.innerHeight-260-8)),b({session:a,top:f,left:e.right+8}),d(b=>a.cwd in b?b:(g.t4.runPromiseExit((0,h.ue)(a.cwd)).then(b=>{"Success"===b._tag&&d(c=>({...c,[a.cwd]:b.value.branch}))}),{...b,[a.cwd]:null}))},[]),i=(0,f.useCallback)(()=>b(null),[]);return{card:a,branch:a?c[a.session.cwd]??null:null,show:e,hide:i}}function l({card:b,branch:c}){if(!b)return null;let{session:d}=b,f=(d.firstMessages?.length??0)>0||(d.lastMessages?.length??0)>0;return(0,e.jsxs)("div",{className:"fixed z-[60] w-72 max-h-[260px] overflow-y-auto bg-popover border border-border rounded-lg shadow-lv2 p-3 pointer-events-none",style:{top:b.top,left:b.left},children:[(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:a(d.cwd)}),d.title&&(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate mt-0.5",children:d.title}),(0,e.jsx)("div",{className:"text-[10px] text-foreground-faint truncate mt-0.5",children:d.cwd}),c&&(0,e.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-normal min-w-0",children:[(0,e.jsxs)("svg",{className:"w-3 h-3 flex-shrink-0 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"6",cy:"6",r:"2.5"}),(0,e.jsx)("circle",{cx:"6",cy:"18",r:"2.5"}),(0,e.jsx)("circle",{cx:"18",cy:"7",r:"2.5"}),(0,e.jsx)("path",{strokeLinecap:"round",d:"M6 8.5v7M8.5 6.5h4.5a3 3 0 013 3v0"})]}),(0,e.jsx)("span",{className:"truncate",children:c})]}),f?(0,e.jsxs)("div",{className:"space-y-0.5 text-xs border-t border-border/50 mt-2 pt-2",children:[d.firstMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`f-${b}`)),(d.lastMessages?.length??0)>0&&(0,e.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),d.lastMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`l-${b}`))]}):d.lastUserMessage?(0,e.jsx)("div",{className:"text-xs text-foreground/90 border-t border-border/50 mt-2 pt-2 line-clamp-3 break-words",children:d.lastUserMessage}):null]})}d()}catch(a){d(a)}})},53036:(a,b,c)=>{"use strict";c.d(b,{I:()=>f});var d=c(48249),e=c(67484);function f(a){let{refreshKey:b,className:c="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:f="max-w-full max-h-full object-contain",alt:g}=a,h="absPath"in a&&"string"==typeof a.absPath,i=h?void 0:a.cwd,j=h?void 0:a.path,k=h?a.absPath:void 0,[l,m]=(0,e.useState)({kind:"loading"});if((0,e.useRef)(0),"loading"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(l.size/1024/1024)," MB)"]})});if("error"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("div",{className:"text-sm text-red-11",children:l.message})});let n=h?`/api/file?path=${encodeURIComponent(k)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(i)}&path=${encodeURIComponent(j)}&v=${encodeURIComponent(l.etag)}`;return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("img",{src:n,alt:g??(j||k),className:f})})}c(33281),c(87808)},53113:(a,b,c)=>{Promise.resolve().then(c.bind(c,4462)),Promise.resolve().then(c.bind(c,29491)),Promise.resolve().then(c.bind(c,34001)),Promise.resolve().then(c.bind(c,83179)),Promise.resolve().then(c.bind(c,25608)),Promise.resolve().then(c.bind(c,8077)),Promise.resolve().then(c.bind(c,5585)),Promise.resolve().then(c.bind(c,77120)),Promise.resolve().then(c.bind(c,77220)),Promise.resolve().then(c.bind(c,3588)),Promise.resolve().then(c.bind(c,77462)),Promise.resolve().then(c.bind(c,38878)),Promise.resolve().then(c.bind(c,82634)),Promise.resolve().then(c.bind(c,99033))},54727:(a,b,c)=>{"use strict";c.d(b,{y:()=>q});var d=c(32891),e=c(10259),f=c(1370);function g(a){let b=[];return a.forEach((a,c)=>b.push({node:a,start:c,end:c+a.nodeSize})),b}function h(a,b){return"heading"===a.type.name&&a.attrs.level<=b}function i(a){for(let b=a.depth;b>0;b--){let c=a.node(b).type.name;if("listItem"===c||"taskItem"===c)return b}return -1}function j(a,b,c,d,e){let f=b.slice(c,d),g=b.slice(d,e);a.replaceWith(c,e,g.content.append(f.content))}function k(a,b){let c=Math.max(0,Math.min(b,a.doc.content.size));a.setSelection(e.U3.near(a.doc.resolve(c)))}let l=new Set(["paragraph","bulletList","orderedList","taskList"]);function m(a,b,c){let{doc:d,selection:e}=a,h=e.$from,i=h.before(1),j=g(d),m=j.findIndex(a=>a.start===i);if(m<0)return!1;let n=m;for(;n>0&&l.has(j[n-1].node.type.name);)n--;let o=m;for(;o<j.length-1&&l.has(j[o+1].node.type.name);)o++;let p=[],q=-1,r="paragraph"===j[m].node.type.name?-1:h.index(1);for(let a=n;a<=o;a++){let b=j[a].node;if("paragraph"===b.type.name)a===m&&(q=p.length),p.push({kind:"paragraph",node:b});else{let c=b.type.name,d=0;b.forEach(b=>{a===m&&d===r&&(q=p.length),p.push({kind:c,node:b}),d++})}}if(q<0)return!1;let s=q+(c>0?1:-1);if(s<0||s>=p.length)return!1;if(b){let c,d,e,g=p[q];p[q]=p[s],p[s]=g;let i=function(a,b){let c=[],d=0;for(;d<a.length;){if("paragraph"===a[d].kind){c.push(a[d].node),d++;continue}let e=a[d].kind,f=[];for(;d<a.length&&a[d].kind===e;)f.push(a[d].node),d++;c.push(b.schema.nodes[e].create(null,f))}return f.FK.from(c)}(p,a),l=j[n].start,m=j[o].end,r=a.tr;r.replaceWith(l,m,i);let t=(c=0,d=0,e=-1,i.forEach(a=>{if(!(e>=0))if("paragraph"===a.type.name)c===s&&(e=d+1),c++,d+=a.nodeSize;else{let b=d+1;a.forEach(a=>{e>=0||(c===s&&(e=b+2),c++,b+=a.nodeSize)}),d+=a.nodeSize}}),e);k(r,t>=0?l+t+h.parentOffset:l),b(r.scrollIntoView())}return!0}function n(a,b,c){let d=a.selection.$from;if(1===d.depth&&"heading"===d.parent.type.name)return function(a,b,c){let{doc:d,selection:e}=a,f=e.$from.before(1),i=g(d),l=i.findIndex(a=>a.start===f);if(l<0)return!1;let m=i[l].node.attrs.level,n=l+1;for(;n<i.length&&!h(i[n].node,m);)n++;let o=i[l].start,p=i[n-1].end;if(c>0){if(n>=i.length)return!1;let c=i[n].node.attrs.level,f=n+1;for(;f<i.length&&!h(i[f].node,c);)f++;let g=i[f-1].end;if(b){let c=a.tr,f=d.slice(p,g).content.size;j(c,d,o,p,g),k(c,o+f+(e.from-o)),b(c.scrollIntoView())}return!0}if(0===l)return!1;let q=l-1;for(;q>=0&&!h(i[q].node,m);)q--;if(q<0||i[q].node.attrs.level<m)return!1;let r=i[q].start;if(b){let c=a.tr;j(c,d,r,o,p),k(c,r+(e.from-o)),b(c.scrollIntoView())}return!0}(a,b,c);let e=i(d);if(e>0){let f=d.node(e-1),g=d.index(e-1);return(c>0?g<f.childCount-1:g>0)?function(a,b,c,d){let{doc:e,selection:f}=a,g=f.$from,h=g.node(d),i=g.node(d-1),l=g.index(d-1),m=g.before(d),n=m+h.nodeSize;if(c>0){if(l>=i.childCount-1)return!1;let c=n+i.child(l+1).nodeSize;if(b){let d=a.tr,g=e.slice(n,c).content.size;j(d,e,m,n,c),k(d,m+g+(f.from-m)),b(d.scrollIntoView())}return!0}if(l<=0)return!1;let o=m-i.child(l-1).nodeSize;if(b){let c=a.tr;j(c,e,o,m,n),k(c,o+(f.from-m)),b(c.scrollIntoView())}return!0}(a,b,c,e):2===e&&m(a,b,c)}let f=d.depth>=1?d.node(d.depth-1).type.name:"doc";return"paragraph"===d.parent.type.name&&"doc"===f&&m(a,b,c)}function o(a,b){let{state:c}=a,d=c.selection.$from,e=d.parent.type.name;if("doc"===(d.depth>=1?d.node(d.depth-1).type.name:"doc")&&("heading"===e||"paragraph"===e)){let c=(("heading"===e?d.parent.attrs.level-1:3)+(b>0?1:-1)+4)%4;return 3===c?a.chain().setParagraph().run():a.chain().setHeading({level:c+1}).run()}let f=i(d);if(f>0){let c=d.node(f).type.name;return b<0?a.commands.liftListItem(c):a.commands.sinkListItem(c)}return!1}function p(a,b){let{state:c}=a,d=c.selection;if(!d.empty)return!1;let e=d.$from,f=b>0?1:-1;for(let b=e.depth;b>0;b--)if("taskItem"===e.node(b).type.name){let d=e.before(b),g=c.doc.nodeAt(d);if(!g)return!1;let h=g.attrs.status??"todo",i=(("doing"===h?2:"done"===h?3:1)+f+4)%4;if(0===i)return a.chain().toggleTaskList().run();let j=2===i?"doing":3===i?"done":"todo";return a.chain().command(({tr:a})=>{let b=a.doc.nodeAt(d);return!!b&&(a.setNodeMarkup(d,void 0,{...b.attrs,status:j}),!0)}).run()}if("paragraph"!==e.parent.type.name)return!1;let g=e.depth>=1?e.node(e.depth-1).type.name:"doc";return("doc"===g||"listItem"===g)&&(1==(0+f+4)%4?a.chain().toggleTaskList().run():a.chain().toggleTaskList().command(({tr:a})=>(function(a,b){let c=a.selection.$from;for(let d=c.depth;d>0;d--)if("taskItem"===c.node(d).type.name){let e=c.before(d),f=a.doc.nodeAt(e);f&&a.setNodeMarkup(e,void 0,{...f.attrs,status:b});break}return!0})(a,"done")).run())}let q=d.YY.create({name:"noteOrgKeymap",addKeyboardShortcuts(){return{"Alt-ArrowUp":()=>this.editor.commands.command(({state:a,dispatch:b})=>n(a,b,-1)),"Alt-ArrowDown":()=>this.editor.commands.command(({state:a,dispatch:b})=>n(a,b,1)),"Alt-ArrowLeft":()=>o(this.editor,-1),"Alt-ArrowRight":()=>o(this.editor,1),"Shift-ArrowRight":()=>p(this.editor,1),"Shift-ArrowLeft":()=>p(this.editor,-1)}}})},55287:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cv:()=>C,XO:()=>A});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(33281),j=c(87808),k=c(25419),l=c(7122),m=c(42140),n=c(38896),o=c(36984),p=c(41051),q=c(70596),r=c(40159),s=c(13512),t=c(9804),u=c(7833),v=c(83377),w=a([s]);s=(w.then?(await w)():w)[0];let B="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function x(a){let b=window.getSelection();if(!b?.rangeCount)return null;let c=b.getRangeAt(0),d=c.startContainer;for(;d&&d.parentElement!==a;)d=d.parentElement;if(!d)return null;let e=Array.from(a.children).indexOf(d);if(e<0)return null;let f=document.createRange();f.selectNodeContents(d),f.setEnd(c.startContainer,c.startOffset);let g=f.toString().length;return{line:e,offset:g}}function y(a,b){let c,d=a.children[b.line];if(!d)return;let e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=b.offset;for(;c=e.nextNode();){let a=c.textContent?.length||0;if(f<=a){let a=window.getSelection(),b=document.createRange();b.setStart(c,f),b.collapse(!0),a?.removeAllRanges(),a?.addRange(b);return}f-=a}let g=window.getSelection(),h=document.createRange();h.selectNodeContents(d),h.collapse(!1),g?.removeAllRanges(),g?.addRange(h)}function z(a){return a.map(a=>`<div style="${B}">${a}</div>`).join("")}let C=(0,f.forwardRef)(function({content:a,filePath:b,showLineNumbers:c=!0,showSearch:d=!0,className:n="",cwd:w,enableComments:A=!1,scrollToLine:C=null,scrollToLineAlign:D="center",onScrollToLineComplete:E,highlightKeyword:F=null,visibleLineRef:G,onCmdClick:H,onTokenHover:I,onTokenHoverLeave:J,onTokenHoverCancel:K,blameLines:L,inlineBlameLines:M,onSelectCommit:N,editable:O=!1,initialMtime:P,onEditorClose:Q,onSaved:R,onEditorStateChange:S,viMode:T=!1,onContentMutate:U,onEnterInsertMode:V,onViSave:W,viStateRef:X,initialCursorLine:Y,initialCursorCol:Z,onInitialCursorSet:$,onContentSearch:_},aa){let{t:ab}=(0,g.Bd)(),ac=(0,f.useRef)(a),ad=(0,f.useRef)(!1),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(()=>a.split("\n").length),ak=(0,f.useRef)(a.split("\n").length),[al,am]=(0,f.useState)({show:!1}),an=(0,f.useRef)(null),ao=(0,f.useRef)(null),ap=(0,f.useRef)(P),aq=(0,f.useRef)(null),ar=(0,f.useRef)(!1),as=(0,f.useRef)(!1),{parentRef:at,containerRef:au,searchInputRef:av,floatingToolbarRef:aw,suppressHoverRef:ax,bumpToolbarRef:ay,savedSelectionRef:az,highlightedLines:aA,isMounted:aB,cmdHeld:aC,flashLine:aD,isSearchVisible:aE,searchQuery:aF,caseSensitive:aG,wholeWord:aH,currentMatchIndex:aI,viewingComment:aJ,addCommentInput:aK,sendToAIInput:aL,aiBridge:aM,commentsEnabled:aN,updateComment:aO,deleteComment:aP,lines:aQ,matches:aR,rowData:aS,virtualizer:aT,commentsByEndLine:aU,linesWithComments:aV,setIsSearchVisible:aW,setSearchQuery:aX,setCaseSensitive:aY,setWholeWord:aZ,setViewingComment:a$,setAddCommentInput:a_,setSendToAIInput:a0,goToNextMatch:a1,goToPrevMatch:a2,handleSearchKeyDown:a3,handleCommentBubbleClick:a4,handleToolbarAddComment:a5,handleToolbarSendToAI:a6,handleToolbarExplain:a7,handleToolbarSearch:a8,handleCommentSubmit:a9,handleSendToAISubmit:ba,handleCommentSendToAI:bb,getHighlightedLineHtml:bc,suppressMatchScrollRef:bd,inlineBlameLineRef:be,inlineBlameVersion:bf}=(0,s.d)({content:a,filePath:b,showSearch:d,cwd:w,enableComments:!O&&A,scrollToLine:O?null:C,scrollToLineAlign:O?"center":D,onScrollToLineComplete:O?void 0:E,visibleLineRef:O?void 0:G,onContentSearch:_}),bg=(0,l.iN)(),bh=(0,f.useRef)(null),bi=(0,f.useRef)(null),bj=(0,f.useRef)({line:0,col:0}),bk=(0,f.useRef)({line:0,col:0}),bl=(0,v.A)({lines:aQ,enabled:T&&!O,onContentChange:a=>{bj.current={line:bk.current.line,col:bk.current.col},U?.(a)},onEnterInsert:(a,b,c)=>{let d=b;if("a"===c)d=b+1;else if("A"===c)d=(aQ[a]??"").length;else if("I"===c){let b=(aQ[a]??"").search(/\S/);d=b>=0?b:0}else("o"===c||"O"===c)&&(d=0);bj.current={line:a,col:d},V?.(a)},onSave:W,getVisibleLineCount:()=>{let a=at.current;return a?Math.floor(a.clientHeight/20):20},scrollToLine:(a,b)=>{let c=aS.findIndex(b=>"code"===b.type&&b.lineIndex===a);c>=0&&aT.scrollToIndex(c,{align:b||"auto"})},onSearchExecute:a=>{aX(a),aW(!1)},onSearchNext:a1,onSearchPrev:a2,onSearchClear:()=>{aX("")}});(0,f.useEffect)(()=>{X&&(X.current={cursorLine:bl.state.cursorLine,cursorCol:bl.state.cursorCol}),bk.current={line:bl.state.cursorLine,col:bl.state.cursorCol}},[X,bl.state.cursorLine,bl.state.cursorCol]);let bm=(0,f.useRef)(null);(0,f.useEffect)(()=>{T&&!O&&null!=Y&&b&&bm.current!==b&&(bm.current=b,bl.setCursorLine(Y-1),null!=Z&&bl.setCursorCol(Z-1),$?.())},[T,O,Y,Z,b]),(0,f.useEffect)(()=>{if(!T||O)return;let a=au.current;if(!a)return;let b=a=>{let b=a.target;"TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable||bl.handleKeyDown(a)&&(a.preventDefault(),a.stopPropagation())};return a.addEventListener("keydown",b,!0),()=>a.removeEventListener("keydown",b,!0)},[T,O,bl.handleKeyDown]),(0,f.useEffect)(()=>{if(!T||O)return;let a=au.current;a&&"normal"===bl.state.mode&&requestAnimationFrame(()=>{let b=document.activeElement;b&&("TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable)||a.focus()})},[T,O,bl.state.mode,a]);let bn=(0,f.useCallback)(a=>{if(!T||O)return;let b=a.target.closest("[data-line]");if(b){let c=parseInt(b.getAttribute("data-line"),10);if(!isNaN(c)){bl.setCursorLine(c-1);let d=b.querySelector("[data-code-content]");if(d){let b=document.caretRangeFromPoint(a.clientX,a.clientY);if(b&&d.contains(b.startContainer)){let a,e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=0;for(;a=e.nextNode();){if(a===b.startContainer){f+=b.startOffset;break}f+=a.textContent?.length||0}let g=aQ[c-1]??"";bl.setCursorCol(Math.max(0,Math.min(f,Math.max(0,g.length-1))))}}}}let c=a.target;if("TEXTAREA"===c.tagName||"INPUT"===c.tagName||c.isContentEditable)return;let d=au.current;d&&d.focus()},[T,O,bl.setCursorLine,bl.setCursorCol,aQ]),bo=(0,f.useCallback)(a=>{T&&!O&&requestAnimationFrame(()=>{let a=window.getSelection(),b=a?.toString().trim();b&&/^\S+$/.test(b)&&(bd.current=!0,aX(b))})},[T,O,aX,bd]);(0,f.useEffect)(()=>{"command"===bl.state.mode?setTimeout(()=>bh.current?.focus(),0):"search"===bl.state.mode&&setTimeout(()=>bi.current?.focus(),0)},[bl.state.mode]),(0,f.useEffect)(()=>{let a=at.current;if(!a)return;let b=()=>{(K??J)?.()};return a.addEventListener("mousedown",b),()=>a.removeEventListener("mousedown",b)},[K,J]),(0,f.useEffect)(()=>{aK||aL?(ax.current=!0,J?.()):aw.current||(ax.current=!1)},[aK,aL,J]),(0,f.useLayoutEffect)(()=>{let a=az.current;if(!a)return;let b=window.getSelection();if(b&&!b.isCollapsed)return;let c=at.current;if(!c)return;let d=c.querySelector(`[data-line="${a.startLine}"]`),e=c.querySelector(`[data-line="${a.endLine}"]`);if(!d||!e)return;let f=(0,s.o)(d,a.startOffset),g=(0,s.o)(e,a.endOffset);if(f&&g)try{let a=document.createRange();a.setStart(f.node,f.offset),a.setEnd(g.node,g.offset),b?.removeAllRanges(),b?.addRange(a)}catch{}});let bp=(0,f.useCallback)((a,b,c)=>{ax.current||I?.(a,b,c)},[I]),bq=(0,f.useCallback)((a,b)=>{ax.current||H?.(a,b)},[H]),br=Math.max(4,String(O?ai:aQ.length).length),bs=(0,f.useMemo)(()=>{let a=0;for(let b of aQ){let c=0;for(let a=0;a<b.length;a++)" "===b[a]?c+=2-c%2:c+=1;c>a&&(a=c)}return a},[aQ]);(0,f.useEffect)(()=>{if(O){ac.current=a;let b=a.split("\n").length;ak.current=b,aj(b),ad.current=!1,af(!1),am({show:!1}),ap.current=P}},[O,a,P]),(0,f.useEffect)(()=>{if(!O)return;let b=an.current;if(!b)return;let c=a.split("\n"),d=c.map((a,b)=>aA[b]||(0,o.ZD)(a||" "));b.innerHTML=z(d),requestAnimationFrame(()=>{let a,d;T?(a=Math.max(0,Math.min(bj.current.line,c.length-1)),d=bj.current.col):(a=Math.max(0,Math.min((G?.current??1)-1,c.length-1)),d=0),b.focus(),y(b,{line:a,offset:d});let e=G?.current??1;ao.current&&(ao.current.scrollTop=(e-1)*20)})},[O]),(0,f.useEffect)(()=>{O&&S?.({isDirty:ae,isSaving:ag})},[O,ae,ag,S]);let bt=(0,f.useCallback)(()=>{let a=an.current;if(!a)return ac.current;let b=[];for(let c of a.childNodes){let a=c.textContent||"";b.push(" "===a?"":a)}return b.join("\n")},[]),bu=(0,f.useCallback)(()=>{aq.current&&clearTimeout(aq.current),aq.current=setTimeout(async()=>{let a=an.current;if(a&&!as.current){ac.current=bt();try{let c=await (0,o.kS)(),d=(0,o.sQ)(b),e=document.documentElement.classList.contains("dark"),f=ac.current.split("\n"),g=c.codeToTokens(f.join("\n"),{lang:d,theme:e?"github-dark":"github-light"}).tokens.map(a=>(0,o.b8)(a)),h=x(a);ar.current=!0,a.innerHTML=z(g),ar.current=!1,h&&y(a,h)}catch{}}},300)},[b,bt]);(0,f.useEffect)(()=>{if(O)return()=>{aq.current&&clearTimeout(aq.current)}},[O]);let bv=(0,f.useCallback)(()=>{let a=an.current;if(!a)return;ad.current||(ad.current=!0,af(!0));let b=a.children.length;b!==ak.current&&(ak.current=b,aj(b))},[]),bw=(0,f.useCallback)(()=>{ar.current||as.current||(bv(),bu())},[bv,bu]),bx=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing&&("Tab"===a.key&&(a.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===a.key)){a.preventDefault();let b=an.current;if(!b)return;let c=window.getSelection();if(!c?.rangeCount)return;let d=c.getRangeAt(0);d.deleteContents();let e=d.startContainer;for(;e&&e.parentElement!==b;)e=e.parentElement;if(!e||!(e instanceof HTMLElement))return;let f=x(b),g=Array.from(b.children).indexOf(e),h=e.textContent||"",i=f?.offset??h.length,j=h.substring(0,i),k=h.substring(i);e.innerHTML=(0,o.ZD)(j||" ");let l=document.createElement("div");l.setAttribute("style",B),l.innerHTML=(0,o.ZD)(k||" "),e.after(l),y(b,{line:g+1,offset:0}),bv(),bu()}},[bv,bu]),by=(0,f.useCallback)(a=>{a.preventDefault();let b=a.clipboardData.getData("text/plain");document.execCommand("insertText",!1,b)},[]),bz=(0,f.useCallback)(async(a=!1)=>{if(!w)return;ac.current=bt(),ah(!0);let c=await i.t4.runPromiseExit((0,j.OJ)({cwd:w,path:b,content:ac.current,expectedMtime:a?void 0:ap.current}));if("Failure"===c._tag){console.error("Error saving file:",c.cause),(0,u.oR)(ab("toast.saveFailed"),"error"),ah(!1);return}let d=c.value,e=d.data;if(409===d.status&&e?.conflict){let a=await i.t4.runPromiseExit((0,k.K)(w,b));"Success"===a._tag&&a.value.ok&&"string"==typeof a.value.data?.content?am({show:!0,diskContent:a.value.data.content}):am({show:!0}),ah(!1);return}if(!d.ok){console.error("Error saving file: status",d.status),(0,u.oR)(ab("toast.saveFailed"),"error"),ah(!1);return}let f=e?.mtime;f&&(ap.current=f),ad.current=!1,af(!1),am({show:!1}),(0,u.oR)(ab("toast.savedSuccess"),"success"),R?.(),ah(!1)},[w,b,bt,R,ab]),bA=(0,f.useCallback)(async()=>{ae&&!ag&&await bz(!1)},[ae,ag,bz]),bB=(0,f.useCallback)(async()=>{am({show:!1}),await bz(!0)},[bz]),bC=(0,f.useCallback)(()=>{if(void 0!==al.diskContent){ac.current=al.diskContent;let b=al.diskContent.split("\n").length;ak.current=b,aj(b);let c=al.diskContent!==a;ad.current=c,af(c);let d=an.current;if(d){let a=al.diskContent.split("\n");d.innerHTML=z(a.map(a=>(0,o.ZD)(a||" "))),bu()}}am({show:!1}),R?.()},[al.diskContent,a,R,bu]),bD=(0,f.useCallback)(()=>{let a=ao.current;return a?Math.floor(a.scrollTop/20)+1:G?.current??1},[G]),bE=(0,f.useCallback)(async()=>{(!ae||await (0,u.lJ)(ab("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ab("codeViewer.discardChanges"),cancelText:ab("codeViewer.continueEditing")}))&&Q?.(bD())},[ae,Q,bD]);(0,f.useEffect)(()=>{if(!O)return;let a=a=>{(a.metaKey||a.ctrlKey)&&"s"===a.key&&(a.preventDefault(),bA())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[O,bA]);let bF=(0,f.useCallback)(()=>{let a=bt();U?.(a);let b=an.current,c=b?x(b):null,d=bD();if(bl.enterNormal(),c){bl.setCursorLine(c.line);let b=a.split("\n")[c.line]??"";bl.setCursorCol(Math.max(0,Math.min(c.offset,Math.max(0,b.length-1))))}else bl.setCursorLine(Math.max(0,d-1));Q?.(d)},[bt,U,bD,Q,bl]);(0,f.useEffect)(()=>{if(!O)return;let a=a=>{let b="Escape"===a.key,c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;(b||T&&c)&&(a.preventDefault(),a.stopPropagation(),T?ad.current?(0,u.lJ)(ab("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ab("codeViewer.discardChanges"),cancelText:ab("codeViewer.continueEditing")}).then(a=>{a&&bF()}):bF():bE())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[O,T,bE,bF]);let bG=(0,f.useCallback)(()=>{ad.current||(ad.current=!0,af(!0))},[]);(0,f.useImperativeHandle)(aa,()=>({save:bA,close:bE,markDirty:bG,get isDirty(){return ad.current},get isSaving(){return ag}}),[bA,bE,bG,ag]);let bH=!!(L&&L.length>0),bI=(0,f.useMemo)(()=>{if(!L)return new Map;let a=[...new Set(L.map(a=>a.author))],b=new Map;return a.forEach((a,c)=>{b.set(a,r.j[c%r.j.length])}),b},[L]),[bJ,bK]=(0,f.useState)(null),[bL,bM]=(0,f.useState)(null);(0,f.useEffect)(()=>{bK(null),bM(null)},[L]);let bN=(0,f.useCallback)((a,b)=>{bK(a.author);let c=b.currentTarget.getBoundingClientRect();bM({line:a,x:c.right+8,y:c.top})},[]),bO=(0,f.useCallback)(()=>{bK(null),bM(null)},[]),bP=(0,f.useCallback)(a=>{if(!N)return;let b={hash:a.hashFull,shortHash:a.hash,author:a.author,authorEmail:a.authorEmail,date:new Date(1e3*a.time).toISOString(),subject:a.message.split("\n")[0]||"",body:a.message.split("\n").slice(1).join("\n").trim(),time:a.time};N(b),bM(null)},[N]),bQ=`${br+2}ch`;return(0,e.jsxs)("div",{ref:au,className:`h-full flex flex-col outline-none ${n}`,tabIndex:0,onClick:bn,onDoubleClick:bo,children:[O&&al.show&&(0,e.jsxs)("div",{className:"px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 flex items-center gap-3 flex-shrink-0",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-amber-11 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),(0,e.jsx)("span",{className:"text-sm text-foreground flex-1",children:ab("codeViewer.fileModifiedExternally")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bC,className:"px-3 py-1 text-sm rounded border border-border hover:bg-hover transition-colors",children:ab("codeViewer.useDiskVersion")}),(0,e.jsx)("button",{onClick:bB,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ab("codeViewer.forceOverwrite")})]})]}),!O&&d&&aE&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)("input",{ref:av,type:"text",value:aF,onChange:a=>aX(a.target.value),onKeyDown:a3,placeholder:ab("codeViewer.searchPlaceholder"),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,e.jsx)("button",{onClick:()=>aY(!aG),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aG?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ab("codeViewer.caseSensitive"),children:"Aa"}),(0,e.jsx)("button",{onClick:()=>aZ(!aH),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aH?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ab("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aR.length>0?`${aI+1}/${aR.length}`:ab("common.noMatch")}),(0,e.jsx)("button",{onClick:a2,disabled:0===aR.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ab("common.previous"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{onClick:a1,disabled:0===aR.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ab("common.next"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{onClick:()=>{aW(!1),aX("")},className:"p-1 rounded hover:bg-hover",title:ab("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),O?(0,e.jsx)("div",{ref:ao,className:"flex-1 overflow-auto bg-card",children:(0,e.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,e.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-card",style:{width:bQ},children:Array.from({length:ai},(a,b)=>(0,e.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:b+1},b))}),(0,e.jsx)("div",{ref:an,contentEditable:!0,suppressContentEditableWarning:!0,onInput:bw,onKeyDown:bx,onPaste:by,onCompositionStart:()=>{as.current=!0},onCompositionEnd:()=>{as.current=!1,bw()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,e.jsx)("div",{ref:at,className:`flex-1 overflow-auto font-mono text-sm bg-card${aC?" cmd-held-container":""}`,children:(0,e.jsx)("div",{style:{height:`${aT.getTotalSize()}px`,minWidth:"100%",width:bH?`calc(${br+bs+10}ch + 13rem)`:`${br+bs+10}ch`,position:"relative"},children:aT.getVirtualItems().map(a=>{let b=aS[a.index];if("code"!==b.type)return null;let d=b.lineIndex,f=d+1,g=aA[d]||(0,o.ZD)(aQ[d]||""),h=bc(d,g,F),i=aV.has(f),j=aU.get(f),k=j?.[0],l=!!(aK&&f>=aK.range.start&&f<=aK.range.end),m=bf>=0?be.current:null,n=!O&&M&&m===f?M[d]??null:null,p=bH?L[d]:void 0,q=bH&&d>0?L[d-1]:void 0,s=!!p&&(!q||q.hash!==p.hash),t=p?bI.get(p.author):void 0;return(0,e.jsx)(r.S,{virtualKey:a.key,lineNum:f,highlightedHtml:h,hasComments:i,firstComment:k,lineCommentsCount:j?.length,isInRange:l,showLineNumbers:c,lineNumChars:br,commentsEnabled:aN,virtualItemSize:a.size,virtualItemStart:a.start,onCommentBubbleClick:a4,onCmdClick:bq,onTokenHover:bp,onTokenHoverLeave:J,flashLine:aD,blameLine:p,showBlameInfo:s,blameAuthorColor:t,isBlameHovered:!!(p&&bJ===p.author),onBlameClick:bP,onBlameMouseEnter:bN,onBlameMouseLeave:bO,inlineBlameData:n,onInlineBlameClick:bP,isCursorLine:T&&!O&&bl.state.cursorLine===d,cursorCol:T&&!O&&bl.state.cursorLine===d?bl.state.cursorCol:void 0},a.key)})})}),T&&(0,e.jsxs)("div",{className:"vi-status-bar flex-shrink-0 h-6 bg-card border-t border-border flex items-center px-3 text-xs font-mono select-none",children:["normal"===bl.state.mode&&(0,e.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===bl.state.mode&&(0,e.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===bl.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:":"}),(0,e.jsx)("input",{ref:bh,value:bl.state.commandInput,onChange:a=>bl.setCommandInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bl.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===bl.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:"/"}),(0,e.jsx)("input",{ref:bi,value:bl.state.searchInput,onChange:a=>bl.setSearchInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bl.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),bl.state.keyBuffer&&"normal"===bl.state.mode&&(0,e.jsx)("span",{className:"ml-2 text-muted-foreground",children:bl.state.keyBuffer}),bl.state.isDirty&&("normal"===bl.state.mode||"command"===bl.state.mode)&&(0,e.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,e.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[bl.state.cursorLine+1,":",bl.state.cursorCol+1]})]}),aB&&bg&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[!O&&(0,e.jsx)(p.fS,{floatingToolbarRef:aw,bumpRef:ay,container:bg,onAddComment:a5,onSendToAI:a6,onSearch:_?a8:void 0,onExplain:aM?a7:void 0,isChatLoading:aM?.isLoading}),!O&&aK&&(0,e.jsx)(m.t,{x:aK.x,y:aK.y,range:aK.range,filePath:b,lineSnapshot:aK.lineSnapshot,container:bg,onSubmit:a9,onSendToAI:aM?bb:void 0,onClose:()=>a_(null),isChatLoading:aM?.isLoading}),!O&&aL&&(0,e.jsx)(m.G,{x:aL.x,y:aL.y,range:aL.range,filePath:b,lineSnapshot:aL.lineSnapshot,container:bg,onSubmit:ba,onClose:()=>a0(null),isChatLoading:aM?.isLoading}),!O&&aJ&&(0,e.jsx)(q.t,{x:aJ.x,y:aJ.y,comment:aJ.comment,container:bg,onClose:()=>a$(null),onUpdateComment:aO,onDeleteComment:aP}),bL&&(0,e.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lv2 p-3 max-w-lg",style:{left:Math.min(bL.x,window.innerWidth-450),top:Math.max(8,Math.min(bL.y,window.innerHeight-200))},children:[(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:bI.get(bL.line.author)?.border||"#666"},children:bL.line.hash}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:bL.line.author}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:bL.line.authorEmail})]})]}),(0,e.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:bL.line.message}),(0,e.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,t.fw)(bL.line.time)," \xb7 ",new Date(1e3*bL.line.time).toLocaleString(),(0,e.jsx)("span",{className:"ml-2 text-brand",children:ab("codeViewer.clickToViewDetails")})]})]})]}),bg)]})});function A({content:a,filePath:b,className:c=""}){let d=(0,f.useMemo)(()=>a.split("\n"),[a]),g=(0,n.C)(d,b),h=Math.max(4,String(d.length).length);return(0,e.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${c}`,children:d.map((a,b)=>(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)("span",{className:"text-foreground-subtle select-none pr-4 text-right",style:{minWidth:`${h+2}ch`},children:b+1}),(0,e.jsx)("span",{className:"flex-1",dangerouslySetInnerHTML:{__html:g[b]||(0,o.ZD)(a||" ")}})]},b))})}d()}catch(a){d(a)}})},55632:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call EmptyState() from the server but EmptyState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/EmptyState.tsx","EmptyState")},56444:(a,b,c)=>{"use strict";c.d(b,{$H:()=>i});var d=c(32891),e=c(6993);let f={todo:"doing",doing:"done",done:"todo"},g={todo:"false",doing:"mixed",done:"true"},h=/^\s*(\[([ x/])?\])\s$/,i=e.L.extend({addAttributes:()=>({status:{default:"todo",keepOnSplit:!1,parseHTML:a=>(function(a){let b=a.getAttribute("data-status");if("todo"===b||"doing"===b||"done"===b)return b;let c=a.getAttribute("data-checked");return""===c||"true"===c?"done":"todo"})(a),renderHTML:a=>({"data-status":a.status,"data-checked":"done"===a.status?"true":"false"})}}),addStorage:()=>({markdown:{serialize(a,b){var c;a.write(`${"done"===(c=b.attrs.status)?"[x]":"doing"===c?"[/]":"[ ]"} `),a.renderContent(b)}}}),addInputRules(){return[(0,d.tG)({find:h,type:this.type,getAttributes:a=>{let b=a[a.length-1];return{status:"x"===b?"done":"/"===b?"doing":"todo"}}})]},renderHTML({HTMLAttributes:a}){return["li",(0,d.KV)(this.options.HTMLAttributes,a,{"data-type":this.name}),0]},addNodeView(){return({node:a,getPos:b,editor:c})=>{let d=document.createElement("li");d.setAttribute("data-type",this.name);let e=document.createElement("label");e.classList.add("task-marker"),e.contentEditable="false";let h=document.createElement("span");h.classList.add("task-marker-box"),h.setAttribute("role","checkbox"),e.appendChild(h);let i=document.createElement("div");d.append(e,i);let j=a=>{let b=a.attrs.status??"todo";d.dataset.status=b,d.dataset.checked="done"===b?"true":"false",h.setAttribute("aria-checked",g[b])};return j(a),e.addEventListener("mousedown",a=>a.preventDefault()),e.addEventListener("click",a=>{if(a.preventDefault(),!c.isEditable||"function"!=typeof b)return;let d=b();"number"==typeof d&&c.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:a})=>{let b=a.doc.nodeAt(d);if(!b)return!1;let c=b.attrs.status??"todo";return a.setNodeMarkup(d,void 0,{...b.attrs,status:f[c]}),!0}).run()}),{dom:d,contentDOM:i,update:b=>b.type===a.type&&(j(b),!0)}}}})},57014:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>x});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(35208),j=c(74691),k=c(60333),l=c(73887),m=c(39238),n=c(60591),o=c(18921),p=c(72529),q=c(85984),r=c(65543),s=c(25667),t=c(53036),u=c(88018),v=c(9804),w=a([s,i,l,m]);[s,i,l,m]=w.then?(await w)():w;let y=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function x({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:w,changedFiles:z,fileGitStatusMap:A,onContentSearch:B,locateInTree:C,jsonPreview:D,setJsonPreview:E,jsonPreviewSearch:F,jsonPreviewPreRef:G,onTokenHover:H,onTokenHoverLeave:I,onTokenHoverCancel:J}){let{t:K}=(0,g.Bd)(),L="unstaged"===b.type?{onTokenHover:H,onTokenHoverLeave:I,onTokenHoverCancel:J}:{},[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)("file"),[Q,R]=(0,f.useState)("compact"),[S,T]=(0,f.useState)("unified"),U=b.file.path,V=b.file.oldPath||U,W=(0,v.u)(U),X=U.startsWith("/")?U:a?`${a.replace(/\/$/,"")}/${U}`:U,{state:Y}=(0,q.V)(a,U),Z=(0,f.useMemo)(()=>{if("ready"===Y.state)return Y.data.functions.filter(r._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[Y]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[W||"map"!==O?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:U}),(0,e.jsx)(p.m,{content:K("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${U}`),(0,h.oR)(K("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(p.m,{content:K("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),C(U)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===b.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===b.type?K("fileBrowser.staged"):K("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!W&&(0,e.jsx)(j.y,{value:Q,onChange:R}),!W&&"file"===O&&(0,e.jsx)(k.q,{value:S,onChange:T}),!W&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),P(a)},className:`px-2 py-0.5 text-xs transition-colors ${O===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:K("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:W?(0,e.jsx)(u.K,{filePath:U,oldSrc:c.isNew?null:y(a,"staged"===b.type?"HEAD":":0","staged"===b.type?V:U),newSrc:c.isDeleted||"staged"!==b.type?null:y(a,":0",U),newNode:c.isDeleted||"staged"===b.type?void 0:(0,e.jsx)(t.I,{cwd:a,path:U,className:"flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:U})}):"unified"===S?(0,e.jsx)(i.xU,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,cwd:a,enableComments:!0,compact:"compact"===Q,onPreview:!c.isDeleted&&(0,n.e$)(U)?()=>w(!0):!c.isDeleted&&(0,n.aR)(U)?()=>N(!0):!c.isDeleted&&U.endsWith(".json")?()=>E({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:U.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:B,...L}):(0,e.jsx)(i.xZ,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,isNew:c.isNew,isDeleted:c.isDeleted,cwd:a,enableComments:!0,compact:"compact"===Q,symbols:Z,onPreview:!c.isDeleted&&(0,n.e$)(U)?()=>w(!0):!c.isDeleted&&(0,n.aR)(U)?()=>N(!0):!c.isDeleted&&U.endsWith(".json")?()=>E({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:U.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:B,...L})})]}):(0,e.jsx)(s.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:z,fileGitStatusMap:A,enableComments:!0,compact:"compact"===Q,onContentSearch:B,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=A.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.m,{content:K("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(K("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(p.m,{content:K("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),C(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),c&&(0,e.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"staged"===c?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===c?K("fileBrowser.staged"):K("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.y,{value:Q,onChange:R}),(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),P(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${O===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:K("file"===a?"common.file":"common.codeMap")},a))})]})}),d&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>w(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(l.M,{content:c.newContent,filePath:c.filePath,cwd:a,onClose:()=>w(!1)})})}),M&&(0,e.jsx)(m.N,{filePath:X,content:c.newContent,cwd:a,onClose:()=>N(!1)}),D&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>E(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:D.filePath}),(0,e.jsx)("button",{onClick:()=>E(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(o._,{search:F}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{ref:G,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,n.xb)(D.content)})})]})})]})}d()}catch(a){d(a)}})},57031:(a,b,c)=>{"use strict";c.d(b,{F:()=>g});var d=c(79606),e=c(23734),f=c(33281);let g=(a,b)=>{f.t4.runFork(d.qIB(e.d,c=>c.publish(a,b)))}},57063:(a,b,c)=>{"use strict";function d(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function e(a,b=!0){}c.d(b,{E:()=>e,k:()=>d}),c(67484)},57632:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e$:()=>L,vP:()=>H,zB:()=>M});var e=c(48249),f=c(67484),g=c(44384),h=c(79606),i=c(87819);c(57063);var j=c(7122),k=c(44256),l=c(99191),m=c(67216),n=c(92340),o=c(52490),p=c(46674),q=c(145),r=c(20586),s=c(74691),t=c(60333),u=c(88018),v=c(35208),w=c(60591),x=c(73887),y=c(39238),z=c(18479),A=c(15578),B=c(39247),C=a([v,x,y]);[v,x,y]=C.then?(await C)():C;let N=(a,b,c)=>`/api/snapshots/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function D(a){return a.fullSubject||a.subject}function E(a,b,c){let d=D(a),e=d.split("\n"),f=e.length>c?e.slice(0,c).join("\n"):d,g=f.length>b?f.slice(0,b):f;return e.length>c||f.length>b?`${g.trimEnd()}…`:g}function F(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function G(a,b){let c=[];for(let d of a)if("Edit"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string){let e=F(a.file_path,b);c.push({key:d.id,toolName:"Edit",subject:`[Edit] ${e}`,legacy:!0,changeClass:(0,A.q)(e),files:[{path:e,status:"modified",old_string:a.old_string,new_string:a.new_string,fileClass:(0,A.q)(e)}]})}}else if("Write"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.content){let e=F(a.file_path,b);c.push({key:d.id,toolName:"Write",subject:`[Write] ${e}`,legacy:!0,changeClass:(0,A.q)(e),files:[{path:e,status:"added",old_string:"",new_string:a.content,fileClass:(0,A.q)(e)}]})}}return c}function H(a,b,c){var d;let e,f=a.map(a=>{let b=new Set(a.commit.toolFiles);return{key:a.commit.toolId??a.commit.hash,shortHash:a.commit.hash.slice(0,7),toolName:a.commit.toolName??"tool",subject:a.commit.subject,timestamp:a.commit.timestamp,truncated:!0===a.truncated,changeClass:(0,A.S)(a.files.map(a=>a.path)),files:a.files.map(a=>({path:a.path,status:a.status,additions:a.additions,deletions:a.deletions,old_string:a.oldContent??"",new_string:a.newContent??"",unviewable:!a.isImage&&(a.binary||null===a.oldContent&&null===a.newContent),isImage:a.isImage,oldRev:a.oldRev,newRev:a.newRev,external:b.size>0&&!b.has(a.path),fileClass:(0,A.q)(a.path)}))}});return d=f.length>0?f:G(b,c),e=new Map(b.map(a=>[a.id,a])),d.map(a=>{let b=function(a){if(!a)return;let b=a.input;return"string"==typeof b.description&&b.description?b.description:"string"==typeof b.command&&b.command?b.command:"string"==typeof b.prompt&&b.prompt?b.prompt:"string"==typeof b.file_path&&b.file_path?b.file_path:"string"==typeof b.notebook_path&&b.notebook_path?b.notebook_path:void 0}(e.get(a.key));return b?{...a,fullSubject:`[${a.toolName}] ${b}`}:a})}function I({additions:a,deletions:b}){return(0,e.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,e.jsxs)("span",{className:"text-green-11",children:["+",a]}),(0,e.jsxs)("span",{className:"text-red-11",children:["-",b]})]})}function J({cls:a}){return(0,e.jsx)("span",{className:`text-[10px] px-1 py-px rounded flex-shrink-0 ${"test"===a?"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:a})}function K(a){let b=new Date(1e3*a),c=new Date,d=String(b.getMonth()+1).padStart(2,"0"),e=String(b.getDate()).padStart(2,"0"),f=String(b.getHours()).padStart(2,"0"),g=String(b.getMinutes()).padStart(2,"0"),h=`${d}-${e} ${f}:${g}`;return b.getFullYear()===c.getFullYear()?h:`${b.getFullYear()}-${h}`}function L({toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:k,fullscreen:A,onToggleFullscreen:C}){let{t:F}=(0,g.Bd)(),M=(0,f.useRef)(null),[O,P]=(0,f.useState)(null),Q=(0,f.useMemo)(()=>a.map(a=>a.id).filter(Boolean),[a]),R=Q.join(","),[S,T]=(0,f.useState)(0),U=(0,i.Z)(b&&Q.length>0?(0,z.se)(b,Q,c):h.PyW([]),[b,c,R,S]);(0,f.useMemo)(()=>a.filter(a=>(0,B.h)(a.name)).map(a=>a.id),[a]);let V=(0,f.useRef)([]),W="loading"===U.status&&0===V.current.length,X=(0,f.useMemo)(()=>{if("success"===U.status){let c=H(U.data,a,b);return c.length>0&&(V.current=c),c}return"loading"===U.status&&V.current.length>0?V.current:"loading"===U.status?[]:G(a,b)},[U,a,b]),[Y,Z]=(0,f.useState)(null),[$,_]=(0,f.useState)(null),[aa,ab]=(0,f.useState)(new Set),[ac,ad]=(0,f.useState)(()=>!0),[ae,af]=(0,f.useState)("compact"),[ag,ah]=(0,f.useState)("unified"),[ai,aj]=(0,f.useState)(!1),[ak,al]=(0,f.useState)(!1),[am,an]=(0,f.useState)(null),ao=(0,f.useMemo)(()=>X.find(a=>a.key===Y)??null,[X,Y]),ap=(0,f.useRef)(null),aq=ao??ap.current,ar=(0,f.useMemo)(()=>aq?(0,r.Do)(aq.files):[],[aq]),as=(0,f.useMemo)(()=>aq?.files.find(a=>a.path===$)??null,[aq,$]),at=(0,f.useCallback)(a=>{Z(a.key),_(a.files[0]?.path??null),ab(new Set((0,r.Sz)((0,r.Do)(a.files))))},[]),au=(0,f.useMemo)(()=>X.reduce((a,b)=>a+b.files.length,0),[X]),av=a=>(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:a});return(0,e.jsx)(j.SU,{container:O,children:(0,e.jsxs)("div",{ref:M,className:"relative bg-card shadow-lv3 w-full h-full flex flex-col rounded-lg",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:`${l.o} justify-between px-3`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>ad(a=>!a),"aria-label":F("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${ac?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,e.jsx)(m.A,{className:"w-4 h-4"})}),(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:F("diffViewer.fileChanges",{count:au})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[C&&(0,e.jsx)("button",{onClick:C,"aria-label":A?F("diffViewer.exitFull"):F("diffViewer.expandFull"),title:A?F("diffViewer.exitFull"):F("diffViewer.expandFull"),"aria-pressed":!0===A,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:A?(0,e.jsx)(n.A,{className:"w-4 h-4"}):(0,e.jsx)(o.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(p.A,{className:"w-5 h-5"})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ac&&(0,e.jsx)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:X.map(a=>{let b;return(0,e.jsxs)("div",{onClick:()=>at(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${Y===a.key?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[a.shortHash&&(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),void 0!==a.timestamp&&(0,e.jsx)("span",{className:"text-xs text-foreground-subtle",children:K(a.timestamp)}),a.changeClass&&(0,e.jsx)("span",{className:"ml-auto",children:(0,e.jsx)(J,{cls:a.changeClass})})]}),(0,e.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":D(a),children:E(a,320,10)}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{children:F("commitDetail.nChanges",{count:a.files.length})}),(b=function(a){let b=!1,c=0,d=0;for(let e of a.files)(void 0!==e.additions||void 0!==e.deletions)&&(b=!0),c+=e.additions??0,d+=e.deletions??0;return b?{additions:c,deletions:d}:null}(a))&&(b.additions>0||b.deletions>0)?(0,e.jsx)(I,{additions:b.additions,deletions:b.deletions}):null]})]},a.key)})}),(0,e.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:W?av(F("diffViewer.loadingSnapshots")):0===X.length?av(F("diffViewer.noChanges")):aq?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(q.A,{className:"w-3.5 h-3.5"}),aq.toolName]}),aq.shortHash&&(0,e.jsx)("span",{className:"font-mono text-brand",children:aq.shortHash}),void 0!==aq.timestamp&&(0,e.jsx)("span",{children:K(aq.timestamp)}),(0,e.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":D(aq),children:E(aq,640,6)}),aq.truncated&&(0,e.jsx)("span",{className:"text-amber-11",children:F("diffViewer.truncated")}),aq.legacy&&(0,e.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":F("diffViewer.reconstructedHint"),children:F("diffViewer.reconstructed")}),(0,e.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!as?.isImage&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.y,{value:ae,onChange:af}),(0,e.jsx)(t.q,{value:ag,onChange:ah})]})})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ac&&(0,e.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:(0,e.jsx)(r.VO,{files:ar,selectedPath:$,expandedPaths:aa,onToggle:a=>ab(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c}),onSelect:a=>{!a.isDirectory&&a.file&&_(a.file.path)},cwd:b||"",showChanges:!0,renderActions:a=>{if(a.isDirectory)return null;let b=a.file;return b?(0,e.jsxs)(e.Fragment,{children:[b.fileClass&&(0,e.jsx)(J,{cls:b.fileClass}),b.external&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":F("diffViewer.externalChange")})]}):null}})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:as?as.isImage?(0,e.jsx)(u.K,{filePath:as.path,oldSrc:b&&as.oldRev?N(b,as.oldRev,as.path):null,newSrc:b&&as.newRev?N(b,as.newRev,as.path):null}):as.unviewable?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:F("diffViewer.notViewable")}):"unified"===ag?(0,e.jsx)(v.xU,{oldContent:as.old_string,newContent:as.new_string,filePath:as.path,cwd:b,enableComments:!0,onContentSearch:k,compact:"compact"===ae,onPreview:"deleted"===as.status?void 0:(0,w.e$)(as.path)?()=>aj(!0):(0,w.aR)(as.path)?()=>al(!0):as.path.endsWith(".json")?()=>an({content:as.new_string,filePath:as.path}):void 0,previewLabel:as.path.endsWith(".json")?F("common.readable"):F("common.preview")}):(0,e.jsx)(v.xZ,{oldContent:as.old_string,newContent:as.new_string,filePath:as.path,isNew:"added"===as.status,isDeleted:"deleted"===as.status,cwd:b,enableComments:!0,onContentSearch:k,compact:"compact"===ae,onPreview:"deleted"===as.status?void 0:(0,w.e$)(as.path)?()=>aj(!0):(0,w.aR)(as.path)?()=>al(!0):as.path.endsWith(".json")?()=>an({content:as.new_string,filePath:as.path}):void 0,previewLabel:as.path.endsWith(".json")?F("common.readable"):F("common.preview")}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:F("diffViewer.selectFileToView")})})]})]}):av(F("diffViewer.selectFileToView"))})]}),ai&&as&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>aj(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(x.M,{content:as.new_string,filePath:as.path,cwd:b||"",onClose:()=>aj(!1)})})}),ak&&as&&(0,e.jsx)(y.N,{filePath:as.path,content:as.new_string,cwd:b,onClose:()=>al(!1),onContentSearch:k}),am&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>an(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:am.filePath}),(0,e.jsx)("button",{onClick:()=>an(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(p.A,{className:"w-4 h-4"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,w.xb)(am.content)})})]})})]})})}function M({toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:f}){return(0,e.jsx)(k.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:d,children:(0,e.jsx)(L,{toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:f?a=>{d(),f(a)}:void 0})})})}d()}catch(a){d(a)}})},58554:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>J});var e=c(48249),f=c(67484),g=c(60661),h=c(77949),i=c(7833),j=c(40699),k=c(33281),l=c(41224),m=c(57031),n=c(88214),o=c(63041),p=c(74429),q=c(62473),r=c(14222),s=c(86686),t=c(75513),u=c(81206),v=c(97951),w=c(93780),x=c(99843),y=c(80514),z=c(43209),A=c(95401),B=c(42910),C=c(65139),D=c(47604),E=c(60812),F=c(99191),G=c(84844),H=c(44384),I=a([x]);x=(I.then?(await I)():I)[0];let K=`${F.o} pl-3 pr-14 bg-card/50`;function J({tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:F,ollamaModel:I,onOllamaModelChange:L,deepseekModel:M,onDeepseekModelChange:N,kimiModel:O,onKimiModelChange:P,glmModel:Q,onGlmModelChange:R,claudeModel:S,onClaudeModelChange:T,claudeEffort:U,onClaudeEffortChange:V,claudeContextWindow:W,onClaudeContextWindowChange:X,claudeFastMode:Y,onClaudeFastModeChange:Z,claudeThinking:$,onClaudeThinkingChange:_,codexModel:aa,onCodexModelChange:ab,codexReasoningEffort:ac,onCodexReasoningEffortChange:ad,planMode:ae,onPlanModeChange:af,noHistory:ag,onNoHistoryChange:ah,hideHeader:ai,hideSidebar:aj,isActive:ak=!0,isFocused:al=ak,peerTabId:am,peerSide:an,refreshSignal:ao,onLoadingChange:ap,onSessionIdChange:aq,onTitleChange:ar,onShowGitStatus:as,onOpenNote:at,isFavorite:au,onToggleFavorite:av,onCreateScheduledTask:aw,onOpenSession:ax,onContentSearch:ay,onShowFileDiff:az,onOpenFileLink:aA,onOpenSessionBrowser:aB,onOpenSettings:aC}){let aD,{t:aE}=(0,H.Bd)(),aF=(0,r.k)(),[aG,aH]=(0,f.useState)(""),[aI,aJ]=(0,f.useState)([]),aK=(0,t.nH)(),[aL,aM]=(0,f.useState)([]),[aN,aO]=(0,f.useState)(null),[aP,aQ]=(0,f.useState)(!1),[aR,aS]=(0,f.useState)(!1),[aT,aU]=(0,f.useState)(!1),[aV,aW]=(0,f.useState)(!1),[aX,aY]=(0,f.useState)(null),[aZ,a$]=(0,f.useState)(!1),a_=ae??aZ,a0=(0,f.useCallback)(a=>{a$(a),af?.(a)},[af]),[a1,a2]=(0,f.useState)(!1),a3=ag??a1,a4=(0,f.useCallback)(a=>{a2(a),ah?.(a)},[ah]),[a5,a6]=(0,f.useState)(!1),a7=(0,f.useRef)(null);(0,f.useRef)(null);let a8=(0,f.useCallback)(async a=>{if(!b)return;let c=await k.t4.runPromiseExit((0,l.n_)({cwd:b,sessionId:a}));"Success"===c._tag&&c.value&&"string"==typeof c.value.title?ar?.(c.value.title):"Failure"===c._tag&&console.error("Failed to fetch session title:",c.cause)},[b,ar]),a9=(0,f.useRef)(null),[ba,bb]=(0,f.useState)(!1),[bc,bd]=(0,f.useState)(null),[be,bf]=(0,f.useState)(null),[bg,bh]=(0,f.useState)(v.R),bi=(0,f.useMemo)(()=>(0,w.hC)(),[]),bj=(0,f.useRef)(!1),{isLoadingHistory:bk,isLoadingMore:bl,hasMoreHistory:bm,loadMoreHistory:bn,ensureTurnLoaded:bo,loadHistoryByCwdAndSessionId:bp,loadedSessionId:bq,loadedEngine:br}=(0,u.m)(aL,aM,aN,{cwd:b,initialSessionId:c,onSessionId:aO,onTitleChange:ar,onTokenUsage:aY,liveRunningRef:bj}),bs=br??d??void 0,bt=!bs||"claude"===bs,bu="codex"===bs,bv=S??C.BV,bw=(0,C.NR)(bv,U),bx=(0,C.OO)(bv,W),by=aa??C.kn,bz=(0,C.oJ)(by,ac),bA="deepseek"===bs||"kimi"===bs||"glm"===bs?bs:null,bB="kimi"===bA?O:"glm"===bA?Q:M,bC="kimi"===bA?P:"glm"===bA?R:N,bD="ollama"===bs||null!==bA||bt||bu,{isLoading:bE,tokenUsage:bF,liveOutputTokens:bG,runningStartedAt:bH,rateLimitInfo:bI,apiRetryInfo:bJ,backgroundTasks:bK,handleSend:bL,handleStop:bM}=(0,v.e)(aL,aM,{sessionId:aN,cwd:b,engine:bs,planMode:a_,noHistory:a3,ollamaModel:I,engineModel:bB,claudeModel:bv,claudeEffort:bw,claudeContextWindow:bx,claudeFastMode:Y,claudeThinking:$,codexModel:by,codexReasoningEffort:bz,onSessionId:aO,onFetchTitle:a8,onRunComplete:()=>a9.current?.(),taskStore:bi}),bN=(0,f.useCallback)((...a)=>(a7.current?.pinNextUserMessage(),bL(...a)),[bL]),bO=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(bt){let b=/^\/plan(?:\s+([\s\S]*))?$/.exec(a.trim());if(b){let a=(b[1]??"").trim();"off"===a.toLowerCase()?(a0(!1),(0,i.oR)(aE("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===a?(a0(!0),(0,i.oR)(aE("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(a0(!0),bN(a,c,{permissionMode:"plan"}));return}}if(d.startsWith("!")&&d.length>1){let e=d.slice(1).trim();if(!e)return void bN(a,c);let f=a.split("\n").slice(1).join("\n").trim(),g=await k.t4.runPromiseExit((0,l.JC)({command:e,cwd:b}));if("Success"===g._tag){let a=g.value,b=[a.stdout,a.stderr].filter(Boolean).join("\n")||"(no output)",d=a.exitCode?` (exit code: ${a.exitCode})`:"",h=aE("chat.executedCommand",{command:e,exitInfo:d,output:b});f&&(h+=`
26
-
27
- ${f}`),bN(h,c)}else bN(aE("chat.executedCommandFailed",{command:e,error:g.cause}),c);return}bN(a,c)},[bN,b,aE,bt,a0]),bP=(0,f.useCallback)(()=>{a0(!1),bN(aE("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[bN,a0,aE]),bQ=bq||aN,bR=ak&&!bE&&!!bQ;(0,j.u)(bQ,aM,bR,bs,{onRunningChange:a=>{bj.current=a,bb(a)},onLiveOutputTokens:bd,onRunStartedAt:bf,onBackgroundTasks:a=>bh(a.length?a:v.R),taskStore:bi,onComplete:()=>{b&&bQ&&bp(b,bQ,!0,10)}}),(0,f.useRef)(ak),(0,f.useRef)(0);let bS=bF||aX,bT=bE?bG:ba?bc:null,bU=bE?bH:ba?be:null,bV=bE?bK:ba?bg:v.R;(0,f.useRef)(!1);let bW=(0,f.useCallback)(async(a,c)=>{let d=bq??aN;if(!b||!d)return;let e=await k.t4.runPromiseExit((0,l.Zr)(d,{cwd:b,fromMessageUuid:a,scope:c}));if("Success"===e._tag&&e.value.newSessionId){let a=e.value.newSessionId;ax?ax(a,"single"===c?"Excerpt":"Fork"):(0,m.F)(n.n.OpenProject,{cwd:b,sessionId:a})}else"Failure"===e._tag&&(console.error("Fork failed:",e.cause),(0,i.oR)("single"===c?aE("toast.excerptFailed",{defaultValue:"Failed to excerpt this turn"}):aE("toast.forkFailed",{defaultValue:"Failed to fork session"}),"error"))},[b,bq,aN,ax,aE]),bX=(0,f.useRef)(bW);bX.current=bW;let bY=(0,f.useRef)((a,b)=>bX.current(a,b)).current,bZ=(0,f.useCallback)(async a=>{let c=bq??aN;if(!b||!c||bE||ba)return;let d=Math.max(10,aL.filter(a=>"user"===a.role).length),e=await k.t4.runPromiseExit((0,l.$N)(c,{cwd:b,messageUuid:a}));"Success"===e._tag?(aM(b=>{let c=b.findIndex(b=>b.id===a);if(c<0)return b;let d=c;for(;d>=0&&"user"!==b[d].role;)d-=1;if(d<0)return b;let e=d+1;for(;e<b.length&&"user"!==b[e].role;)e+=1;return[...b.slice(0,d),...b.slice(e)]}),await bp(b,c,!1,d,void 0,!0),(0,i.oR)(aE("toast.turnDeleted",{defaultValue:"Turn deleted"}),"success")):(console.error("Delete turn failed:",e.cause),(0,i.oR)(aE("toast.deleteTurnFailed",{defaultValue:"Failed to delete this turn"}),"error"))},[b,bq,aN,bE,ba,aL,bp,aE]),b$=(0,f.useRef)(bZ);b$.current=bZ;let b_=(0,f.useRef)(a=>b$.current(a)).current,b0=(0,f.useCallback)(a=>{if(am&&aK){if(!aK.sendToTab(am,a))return void(0,i.oR)(aE("toast.sendToPeerFailed",{defaultValue:"Failed to send to the other pane"}),"error");(0,i.oR)(aE("toast.sentToPeer",{defaultValue:"Sent to the other pane"}),"success")}},[am,aK,aE]),b1=(0,f.useRef)(b0);b1.current=b0;let b2=(0,f.useRef)(a=>b1.current(a)).current,b3=(0,f.useCallback)(()=>{aU(!0)},[]),b4=(0,f.useCallback)(()=>{aW(!0)},[]),b5=(0,f.useRef)(aL);b5.current=aL;let b6=(0,f.useCallback)(async a=>{if(b5.current.some(b=>b.id===a.id))return void a7.current?.scrollToMessage(a.id);await bo(a.turnIndex);for(let b=0;b<30;b++)if(await new Promise(a=>requestAnimationFrame(()=>a())),a7.current?.scrollToMessage(a.id))return},[bo]),b7=(0,f.useMemo)(()=>{if(aw&&b&&a)return c=>{aw({...c,cwd:b,tabId:a,sessionId:aN??crypto.randomUUID(),engine:bs,..."ollama"===bs&&I&&{model:I},...bA&&bB&&{model:bB},...bt&&{model:bv},...bu&&{model:by}})}},[aw,b,a,aN,bs,I,bA,bB,bt,bv,bu,by]),b8=bD?(0,e.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer select-none","data-tooltip":aE("chat.noHistoryDesc",{defaultValue:"each prompt is independent"}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"nohistory-toggle",checked:a3,onChange:a=>a4(a.target.checked),className:"peer sr-only"}),(0,e.jsx)("span",{"aria-hidden":"true",className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-muted-foreground/30 transition-colors peer-checked:bg-brand peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring",children:(0,e.jsx)("span",{className:`h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${a3?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-foreground",children:[(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"}),aE("chat.noHistory",{defaultValue:"No history context"})]})]}):null;return(0,e.jsx)(w.I$.Provider,{value:bi,children:(0,e.jsxs)("div",{className:`flex ${ai&&aj?"h-full":"h-screen"} bg-card`,children:[(0,e.jsxs)("div",{id:"chat-screen",className:"flex-1 flex flex-col min-w-0 relative",onMouseEnter:()=>aQ(!0),onMouseLeave:()=>aQ(!1),children:[!ai&&(0,e.jsx)(o.e,{cwd:b,sessionId:aN,engine:bs,onOpenProjectSessions:()=>aS(!0),onOpenSessionBrowser:aB,onOpenSettings:aC}),(bt||bu)&&(0,e.jsxs)("div",{className:K,children:[(0,e.jsx)(C.Yd,{engine:bu?"codex":"claude",claudeModel:bv,onClaudeModelChange:T,claudeEffort:bw,onClaudeEffortChange:V,claudeContextWindow:bx,onClaudeContextWindowChange:X,claudeFastMode:Y,onClaudeFastModeChange:Z,claudeThinking:$,onClaudeThinkingChange:_,codexModel:by,onCodexModelChange:ab,codexReasoningEffort:bz,onCodexReasoningEffortChange:ad}),bt&&(0,e.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer select-none","data-tooltip":aE("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:a_,onChange:a=>a0(a.target.checked),className:"peer sr-only"}),(0,e.jsx)("span",{"aria-hidden":"true",className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-muted-foreground/30 transition-colors peer-checked:bg-brand peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring",children:(0,e.jsx)("span",{className:`h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${a_?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-foreground",children:[(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"}),aE("chat.planMode",{defaultValue:"Plan mode"})]})]}),b8]}),"ollama"===bs&&(0,e.jsxs)("div",{className:K,children:[L&&(0,e.jsx)(A.m,{currentModel:I,onModelChange:L}),b8]}),bA&&(0,e.jsxs)("div",{className:K,children:[bC&&(0,e.jsx)(B.Z,{engine:bA,currentModel:bB,onModelChange:bC,onHasKeyChange:a6}),b8,(0,e.jsx)("div",{className:"ml-auto pl-2",children:"deepseek"===bA?(0,e.jsx)(D.f,{hasKey:a5}):(0,e.jsx)(E.J,{engine:bA,hasKey:a5})})]}),bk?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:aE("sessions.loadingHistory")})}):(0,e.jsx)(x.M,{ref:a7,messages:aL,isLoading:bE||ba,liveOutputTokens:bT,runningStartedAt:bU,cwd:b,sessionId:aN,engine:bs,apiRetryInfo:bJ,backgroundTasks:bV,hasMoreHistory:bm,isLoadingMore:bl,onLoadMore:bn,onFork:bY,onDeleteTurn:b_,onSendToPeer:b2,peerSide:an,isActive:ak,onContentSearch:ay,onShowFileDiff:az,onOpenFileLink:aA,onApprovePlan:bP,onShowUserMessages:b4}),bS&&(0,e.jsx)(q.g,{tokenUsage:bS,rateLimitInfo:bI}),aF&&!al?null:(aD=(0,e.jsx)(y.V,{onSend:bO,disabled:bE||ba,cwd:b,engine:bs,onShowGitStatus:as,onShowComments:b?b3:void 0,onOpenNote:at,isFavorite:au,onToggleFavorite:av,onCreateScheduledTask:b7,draft:aG,setDraft:aH,draftImages:aI,setDraftImages:aJ}),aF?(0,p.createPortal)(aD,aF):aD)]}),!ai&&b&&(0,e.jsx)(z.Q,{isOpen:aR,onClose:()=>aS(!1),cwd:b}),b&&(0,e.jsx)(G.i,{isOpen:aT,onClose:()=>aU(!1),cwd:b}),(0,e.jsx)(s.f,{isOpen:aV,onClose:()=>aW(!1),cwd:b,sessionId:bq??aN,onSelectMessage:b6})]})})}d()}catch(a){d(a)}})},58904:(a,b,c)=>{"use strict";c.d(b,{e:()=>k});var d=c(67484),e=c(20586),f=c(7833),g=c(208),h=c(79606),i=c(33281),j=c(85655);function k({cwd:a,addToRecentFiles:b}){let[c,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)(null),[u,v]=(0,d.useState)(!1),[w,x]=(0,d.useState)(new Set),[y,z]=(0,d.useState)(new Set),[A,B]=(0,d.useState)([]),[C,D]=(0,d.useState)([]),E=(0,d.useMemo)(()=>{let a=new Set((0,e.Sz)(A));for(let b of w)a.delete(b);return a},[A,w]),F=(0,d.useMemo)(()=>{let a=new Set((0,e.Sz)(C));for(let b of y)a.delete(b);return a},[C,y]),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(0),K=(0,d.useCallback)(async()=>{n(!0),p(null),await i.t4.runPromise((0,j.lv)(a).pipe(h.YWq({onSuccess:a=>{l(a);let b=(0,e.Do)(a.staged),c=(0,e.Do)(a.unstaged);B(b),D(c)},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Unknown error")}}))),n(!1)},[a]),L=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=(0,d.useCallback)(a=>{z(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),N=(0,d.useCallback)((a,c)=>{r({file:a,type:c}),b(a.path)},[b]),O=(0,d.useCallback)(async(a,b,c,d)=>{let e=await i.t4.runPromiseExit(a);"Success"===e._tag?(await K(),(0,f.oR)(b,"success")):(console.error(c,e.cause),(0,f.oR)(d,"error"))},[K]),P=(0,d.useCallback)(b=>O((0,j.Iz)(a,[b]),g.A.t("toast.staged"),"Error staging file:",g.A.t("toast.stageFailed")),[a,O]),Q=(0,d.useCallback)(b=>O((0,j.X0)(a,[b]),g.A.t("toast.unstaged"),"Error unstaging file:",g.A.t("toast.unstageFailed")),[a,O]),R=(0,d.useCallback)(async b=>{0!==b.length&&await O((0,j.Iz)(a,b),g.A.t("toast.stagedNFiles",{count:b.length}),"Error staging files:",g.A.t("toast.stageFailed"))},[a,O]),S=(0,d.useCallback)(async b=>{0!==b.length&&await O((0,j.X0)(a,b),g.A.t("toast.unstagedNFiles",{count:b.length}),"Error unstaging files:",g.A.t("toast.unstageFailed"))},[a,O]),T=(0,d.useCallback)(async b=>{if(0===b.length)return;let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path),e=h.JkU(function*(){c.length>0&&(yield*(0,j.Ub)(a,c,!0)),d.length>0&&(yield*(0,j.Ub)(a,d,!1))});await O(e,g.A.t("toast.discardedNFiles",{count:b.length}),"Error discarding files:",g.A.t("toast.discardFailed"))},[a,O]),U=(0,d.useCallback)(async()=>{c?.unstaged.length&&await O((0,j.Iz)(a,c.unstaged.map(a=>a.path)),g.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"Error staging all files:",g.A.t("toast.stageFailed"))},[a,c,O]),V=(0,d.useCallback)(async()=>{c?.staged.length&&await O((0,j.X0)(a,c.staged.map(a=>a.path)),g.A.t("toast.unstagedNFiles",{count:c.staged.length}),"Error unstaging all files:",g.A.t("toast.unstageFailed"))},[a,c,O]),W=(0,d.useCallback)(async b=>{let c="untracked"===b.status;await O((0,j.Ub)(a,[b.path],c),c?g.A.t("toast.deletedFile"):g.A.t("toast.discardedChanges"),"Error discarding file:",g.A.t("toast.discardFailed"))},[a,O]),X=(0,d.useCallback)(async()=>{if(!c?.unstaged.length||!await (0,f.lJ)(g.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))return;let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path),e=c.unstaged.length,i=h.JkU(function*(){d.length>0&&(yield*(0,j.Ub)(a,d,!1)),b.length>0&&(yield*(0,j.Ub)(a,b,!0))});await O(i,g.A.t("toast.discardedNFiles",{count:e}),"Error discarding all:",g.A.t("toast.discardFailed"))},[a,c,O]);return{status:c,setStatus:l,statusLoading:m,statusError:o,statusSelectedFile:q,statusDiff:s,statusDiffLoading:u,stagedExpandedPaths:E,unstagedExpandedPaths:F,stagedTree:A,setStagedTree:B,unstagedTree:C,setUnstagedTree:D,showStatusDiffPreview:G,setShowStatusDiffPreview:H,fetchStatus:K,handleStagedToggle:L,handleUnstagedToggle:M,handleStatusFileSelect:N,handleStage:P,handleUnstage:Q,handleStageFiles:R,handleUnstageFiles:S,handleDiscardFiles:T,handleStageAll:U,handleUnstageAll:V,handleDiscardFile:W,handleDiscardAll:X,refreshDiff:(0,d.useCallback)(()=>J(a=>a+1),[])}}},59336:(a,b,c)=>{"use strict";function d(){}function e(a){return()=>{}}c.d(b,{U:()=>e,k:()=>d})},60333:(a,b,c)=>{"use strict";c.d(b,{q:()=>f});var d=c(48249),e=c(44384);function f({value:a,onChange:b,className:c}){let{t:g}=(0,e.Bd)();return(0,d.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${c??""}`,children:["split","unified"].map(c=>(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),b(c)},className:`px-2 py-0.5 text-xs transition-colors ${a===c?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:g("split"===c?"diffViewer.viewSplit":"diffViewer.viewUnified")},c))})}},60591:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,C_:()=>v,Hz:()=>u,WU:()=>w,Zy:()=>t,aR:()=>s,cG:()=>i,d9:()=>j,e$:()=>r,jU:()=>g,oK:()=>x,u:()=>q,xb:()=>k,zs:()=>o});var d=c(67484),e=c.n(d),f=c(208);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}let i={key:"hsl(var(--blue-11))",str:"hsl(var(--green-11))",num:"hsl(var(--violet-11))",bool:"hsl(var(--red-11))",punct:"hsl(var(--slate-11))",fold:"hsl(var(--slate-11))"},j=e().createContext({version:0,collapsed:!1});function k(a,b=i){try{let c=JSON.parse(a);return n(c,0,b)}catch{return a}}let l=(a,b)=>e().createElement("span",{style:{color:a}},b);function m({label:a,labelColor:b,value:c,indent:d,colors:g}){let h=e().useContext(j),[i,k]=e().useState(null),o=i&&i.version===h.version?i.collapsed:h.collapsed,[p,q]=e().useState({x:0,y:0}),r="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,s={onMouseDown:a=>{q({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-p.x,c=a.clientY-p.y;b*b+c*c>25||(a.stopPropagation(),k({version:h.version,collapsed:!o}))},style:{cursor:"pointer"}};if(r&&o&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],h=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",s,l(b,a),l(g.punct,": "),l(g.str,d),l(g.fold,` ${f.A.t("toolCall.foldedLines",{count:h})}`))}let t=e().createElement(e().Fragment,null,l(b,a),l(g.punct,": "),n(c,d,g));return r?e().createElement("span",s,t):t}function n(a,b,c){let d=" ".repeat(b);if(null===a)return l(c.bool,"null");if(void 0===a)return l(c.bool,"undefined");if("string"==typeof a){let b=a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+d);return l(c.str,b)}if("number"==typeof a)return l(c.num,String(a));if("boolean"==typeof a)return l(c.bool,String(a));if(Array.isArray(a))return 0===a.length?l(c.punct,"[]"):e().createElement(e().Fragment,null,l(c.punct,"["),"\n",...a.map((f,g)=>e().createElement("span",{key:g},d+" ",e().createElement(m,{label:`[${g}]`,labelColor:c.key,value:f,indent:b+1,colors:c}),g<a.length-1?e().createElement(e().Fragment,null,l(c.punct,","),"\n"):"\n")),d,l(c.punct,"]"));if("object"==typeof a){let f=Object.entries(a);return 0===f.length?l(c.punct,"{}"):e().createElement(e().Fragment,null,l(c.punct,"{"),"\n",...f.map(([a,g],h)=>e().createElement("span",{key:a},d+" ",e().createElement(m,{label:a,labelColor:c.key,value:g,indent:b+1,colors:c}),h<f.length-1?e().createElement(e().Fragment,null,l(c.punct,","),"\n"):"\n")),d,l(c.punct,"}"))}return String(a)}function o(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let p=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function q(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return p.has(b)}function r(a){return a.toLowerCase().endsWith(".md")}function s(a){let b=a.toLowerCase();return b.endsWith(".html")||b.endsWith(".htm")}function t(a){let b=a.toLowerCase();return b.endsWith(".csv")||b.endsWith(".tsv")}function u(a){return a.toLowerCase().endsWith(".json")}function v(a){return"skill.md"===a.slice(a.lastIndexOf("/")+1).toLowerCase()}function w(a,b){let c=b.startsWith("/")?[]:a.split("/").slice(0,-1);for(let a of b.replace(/^\//,"").split("/"))""!==a&&"."!==a&&(".."===a?c.pop():c.push(a));return c.join("/")}function x(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},60812:(a,b,c)=>{"use strict";c.d(b,{J:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(63565),i=c(41224);let j={kimi:"https://www.kimi.com/code/console",glm:"https://bigmodel.cn/coding-plan/personal/usage"};function k(a){let b=a.remaining??"?",c=a.limit??"?";return`${a.label} ${b}/${c}`}function l({engine:a,hasKey:b}){let{t:c}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(null),s=(0,e.useCallback)(async()=>{n(!0),r(null);let b=await g.t4.runPromiseExit((0,i.dM)(a));"Failure"===b._tag?(p(null),r(c("chat.quotaFailed",{defaultValue:"Quota unavailable — check the API key"}))):p(b.value),n(!1)},[c,a]),t=o?.windows??[],u=[o?.tier,...t.map(k)].filter(Boolean).join(" \xb7 "),v=function(a){if(!a)return null;let b=new Date(a);return Number.isNaN(b.getTime())?null:`${b.getMonth()+1}/${b.getDate()} ${String(b.getHours()).padStart(2,"0")}:${String(b.getMinutes()).padStart(2,"0")}`}(t.reduce((a,b)=>b.resetTime&&(!a||b.resetTime>a)?b.resetTime:a,null)),w=t.some(a=>0===a.remaining);return(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[m&&(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!m&&q&&(0,d.jsx)("span",{className:"text-xs text-red-11",children:q}),!m&&!q&&o&&(0,d.jsx)("span",{className:`text-xs font-mono ${w?"text-red-11":h.pe[a]}`,"data-tooltip":v?c("chat.quotaResetAt",{defaultValue:"Resets {{time}}",time:v}):void 0,"data-testid":`${a}-quota-value`,children:u||c("chat.quotaEmpty",{defaultValue:"No quota returned"})}),(0,d.jsx)("button",{type:"button","data-testid":`${a}-quota-button`,disabled:!b||m,onClick:s,"data-tooltip":b?void 0:c("chat.quotaNeedsKey",{defaultValue:"Set an API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:c("chat.checkQuota",{defaultValue:"Check quota"})}),(0,d.jsx)("a",{href:j[a],target:"_blank",rel:"noopener","data-testid":`${a}-console-link`,title:c("chat.openProviderConsole",{defaultValue:"Open the provider console"}),"aria-label":c("chat.openProviderConsole",{defaultValue:"Open the provider console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}},61130:(a,b,c)=>{"use strict";c.d(b,{ReviewCommentsListModal:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(44256),h=c(7833),i=c(208);function j(a,b,c){let d=(a,c)=>b[a]||c,e=[],f=null!=c?`[${c+1}] `:"",g=a.anchor.selectedText.length>200?a.anchor.selectedText.slice(0,197)+"...":a.anchor.selectedText;for(let b of(e.push(`${f}${i.A.t("review.quoteRef",{text:g})}`),e.push(i.A.t("review.commentAuthor",{author:d(a.authorId,a.author),content:a.content})),a.replies))e.push(i.A.t("review.replyAuthor",{author:d(b.authorId,b.author),content:b.content}));return e.join("\n")}function k({isOpen:a,onClose:b,comments:c,reviewTitle:m,userNameMap:n,onCommentClick:o}){let{t:p}=(0,f.Bd)(),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1);if(!a)return null;let u=[...c].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),v=(a,b)=>n[a]||b,w=async a=>{r(a.id);try{let b=j(a,n);await navigator.clipboard.writeText(b),(0,h.oR)(p("toast.copiedComment"))}catch{(0,h.oR)(p("toast.copyFailed"),"error")}finally{r(null)}},x=async()=>{if(0!==c.length){t(!0);try{let a=function(a,b,c){if(0===a.length)return"";let d=[...a].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),e=[i.A.t("review.reviewSummary",{title:b}),""];return d.forEach((a,b)=>{e.push(j(a,c,b)),e.push("")}),e.push(i.A.t("review.totalNComments",{count:a.length})),e.join("\n").trim()}(c,m,n);await navigator.clipboard.writeText(a),(0,h.oR)(p("toast.copiedAllComments"))}catch{(0,h.oR)(p("toast.copyFailed"),"error")}finally{t(!1)}}},y=a=>{o?.(a),b()},z=u.filter(a=>!a.closed),A=u.filter(a=>a.closed),B=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-lv3 flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border ",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:p("review.allCommentsTitle")}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[p("review.commentsCountBrief",{count:c.length}),A.length>0&&` (${p("review.closedCount",{count:A.length})})`]}),c.length>0&&(0,d.jsx)("button",{onClick:x,disabled:s,className:"p-1 rounded hover:bg-hover text-muted-foreground disabled:opacity-50",title:p("review.copyAllComments"),children:s?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:0===c.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,d.jsx)("div",{className:"text-2xl mb-2",children:"\uD83D\uDCAC"}),(0,d.jsx)("span",{className:"text-sm",children:p("review.noComments")})]}):(0,d.jsxs)("div",{className:"space-y-2",children:[z.map((a,b)=>(0,d.jsx)(l,{comment:a,index:b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y},a.id)),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"text-[11px] text-muted-foreground/60 pt-2 pb-1 px-1",children:p("review.closedComments",{count:A.length})}),A.map((a,b)=>(0,d.jsx)(l,{comment:a,index:z.length+b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y,closed:!0},a.id))]})]})})]})});return(0,d.jsx)(g.ZL,{children:B})}function l({comment:a,index:b,resolveAuthor:c,copyingId:e,onCopy:f,onClick:g,closed:h}){let j=a.anchor.selectedText.length>100?a.anchor.selectedText.slice(0,97)+"...":a.anchor.selectedText;return(0,d.jsxs)("div",{className:`rounded-lg border border-border hover:border-muted-foreground/30 transition-all cursor-pointer group ${h?"opacity-50":""}`,onClick:()=>g(a.id),children:[(0,d.jsx)("div",{className:"px-3 pt-2.5 pb-1",children:(0,d.jsx)("div",{className:"text-xs bg-yellow-500/10 border-l-2 border-yellow-500 px-2 py-1 rounded-r text-muted-foreground truncate",children:j})}),(0,d.jsxs)("div",{className:"px-3 pt-1.5 pb-2 flex items-start gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,d.jsx)("span",{className:"w-4 h-4 rounded-full bg-brand/20 text-brand flex items-center justify-center text-[9px] font-bold flex-shrink-0",children:c(a.authorId,a.author).charAt(0)}),(0,d.jsx)("span",{className:"text-xs font-medium",children:c(a.authorId,a.author)}),(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(a.createdAt).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}),h&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:i.A.t("review.closedLabel")})]}),(0,d.jsx)("p",{className:"text-sm text-foreground line-clamp-2 pl-6",children:a.content}),a.replies.length>0&&(0,d.jsxs)("div",{className:"pl-6 mt-1 space-y-0.5",children:[a.replies.slice(0,3).map(a=>(0,d.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[(0,d.jsx)("span",{className:"font-medium",children:c(a.authorId,a.author)}),": ",a.content]},a.id)),a.replies.length>3&&(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/60",children:i.A.t("review.moreReplies",{count:a.replies.length-3})})]})]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),f(a)},disabled:e===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground transition-opacity disabled:opacity-50 flex-shrink-0 mt-0.5",title:i.A.t("review.copyComment"),children:e===a.id?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})]})]})}},61135:()=>{},61349:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(44256);c(33281),c(87808);var i=c(35208),j=c(55287),k=c(5900),l=c(24680),m=c(84835),n=c(7833),o=c(64676),p=c(18921),q=c(53036),r=c(60591),s=a([j,i]);function t({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,r.e$)(a);return((0,r.u)(a),h)?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})}):d?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,r.u)(a)?(0,e.jsx)(q.I,{absPath:a,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:a.split("/").pop()||"image"}):b?k?(0,e.jsx)(u,{content:b,filePath:a}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[j,i]=s.then?(await s)():s;let w=[m.W];function u({content:a,filePath:b}){let c=(0,f.useRef)(null),d=(0,f.useMemo)(()=>(0,o.J4)(b),[b]);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:c}),(0,e.jsx)("div",{ref:c,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,basePath:d,rehypePlugins:w})})]})}function v({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,r.jU)(b),l=(0,r.zs)(b),m=(0,r.oK)(b),o=!!l,q=!!m,[s,u]=(0,f.useState)(("Read"===c||"Write"===c)&&q?"file":o?"diff-unified":k?"readable":"json"),w=(0,f.useRef)(null),x=(0,p.o)(w),y=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[o&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>u("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>u("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),q&&(0,e.jsx)("button",{onClick:()=>u("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>u("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>u("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===s&&m?(0,e.jsx)(t,{filePath:m}):"diff-unified"===s&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===s&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===s&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p._,{search:x}),(0,e.jsx)("pre",{ref:w,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,r.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,r.C6)(b):b})})]})});return(0,e.jsx)(h.ZL,{children:y})}d()}catch(a){d(a)}})},61591:(a,b,c)=>{"use strict";c.d(b,{o:()=>g});var d=c(48249);c(67484);let e={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",lean:"#448aff",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},f={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,d.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):"lean"===j?(0,d.jsx)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:(0,d.jsx)("path",{d:"M3.45 1.5 1.5 2.5 12 22.5 22.5 2.5 20.55 1.5 15.9 10.35H8.1ZM9 12h6l-3 6Z",fill:i,fillRule:"evenodd"})}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"env"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},61632:(a,b,c)=>{"use strict";c.d(b,{y:()=>k});var d=c(67484),e=c(20586),f=c(9804),g=c(208),h=c(79606),i=c(33281),j=c(85655);function k({cwd:a,addToRecentFiles:b}){let[c,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(""),[o,p]=(0,d.useState)([]),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)([]),[u,v]=(0,d.useState)([]),[w,x]=(0,d.useState)(new Set),[y,z]=(0,d.useState)(null),[A,B]=(0,d.useState)(null),[C,D]=(0,d.useState)(!1),[E,F]=(0,d.useState)(!1),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(!0),[K,L]=(0,d.useState)(!1),[M,N]=(0,d.useState)(!1),[O,P]=(0,d.useState)(null),Q=(0,d.useRef)(null),[R,S]=(0,d.useState)(null),[T,U]=(0,d.useState)(!1),[V,W]=(0,d.useState)(""),[X,Y]=(0,d.useState)(""),[Z,$]=(0,d.useState)([]),[_,aa]=(0,d.useState)([]),[ab,ac]=(0,d.useState)(new Set),[ad,ae]=(0,d.useState)(null),[af,ag]=(0,d.useState)(null),[ah,ai]=(0,d.useState)(!1),[aj,ak]=(0,d.useState)(!1),al=(0,d.useCallback)(()=>{D(!0),P(null),i.t4.runPromise((0,j.r4)(a).pipe(h.YWq({onSuccess:a=>{a.local&&a.current?(l(a),n(a.current),a.upstream&&W(a.upstream)):(P(g.A.t("git.cannotGetBranches")),l(null))},onFailure:a=>{console.error(a),"NotFoundError"===a._tag?P(g.A.t("git.notGitRepo")):P(g.A.t("git.getBranchesFailed")),l(null)}}))).finally(()=>D(!1))},[a]),am=(0,d.useCallback)(b=>{F(!0),r(null),t([]),v([]),z(null),B(null),J(!0),i.t4.runPromise((0,j.Bj)(a,b,f.B_).pipe(h.YWq({onSuccess:a=>{let b=a.commits||[];p(b),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>F(!1))},[a]),an=(0,d.useCallback)(()=>{if(G||!I||!m)return;H(!0);let b=o.length;i.t4.runPromise((0,j.Bj)(a,m,f.B_,b).pipe(h.YWq({onSuccess:a=>{let b=a.commits||[];b.length>0&&p(a=>[...a,...b]),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>H(!1))},[a,m,o.length,G,I]),ao=(0,d.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&an()},[an]),ap=(0,d.useCallback)(b=>{r(b),z(null),B(null),L(!0),i.t4.runPromise((0,j.Zi)(a,b.hash).pipe(h.YWq({onSuccess:a=>{let b=a.files||[];t(b);let c=(0,e.Do)(b);v(c),x(new Set((0,e.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>L(!1))},[a]),aq=(0,d.useCallback)(c=>{q&&(z(c),b(c.path),N(!0),i.t4.runPromise((0,j.Zi)(a,q.hash,c.path).pipe(h.YWq({onSuccess:a=>B(a),onFailure:a=>{console.error(a)}}))).finally(()=>N(!1)))},[a,q,b]),ar=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),as=(0,d.useCallback)(b=>{ai(!0),ae(null),ag(null),i.t4.runPromise((0,j.yy)(a,b).pipe(h.YWq({onSuccess:a=>{let b=a.files||[];$(b);let c=(0,e.Do)(b);aa(c),ac(new Set((0,e.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>ai(!1))},[a]),at=(0,d.useCallback)(c=>{ae(c),b(c.path),ak(!0),i.t4.runPromise((0,j.yy)(a,X,c.path).pipe(h.YWq({onSuccess:a=>ag(a),onFailure:a=>{console.error(a)}}))).finally(()=>ak(!1))},[a,X,b]),au=(0,d.useCallback)(a=>{ac(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),av=(0,d.useCallback)(a=>{if(U(a),a){let a="origin/main";Y(a),as(a)}else $([]),aa([]),ae(null),ag(null),Y("")},[V,as]);return{branches:c,selectedBranch:m,setSelectedBranch:n,commits:o,setCommits:p,selectedCommit:q,setSelectedCommit:r,historyFiles:s,historyFileTree:u,historyExpandedPaths:w,historySelectedFile:y,historyFileDiff:A,isLoadingBranches:C,isLoadingCommits:E,isLoadingMore:G,hasMoreCommits:I,setHasMoreCommits:J,isLoadingHistoryFiles:K,isLoadingHistoryDiff:M,historyError:O,commitListRef:Q,tooltipPos:R,loadBranches:al,loadCommits:am,loadMoreCommits:an,handleCommitListScroll:ao,handleSelectCommit:ap,handleSelectHistoryFile:aq,handleHistoryToggle:ar,handleCommitInfoMouseMove:(0,d.useCallback)(a=>{S({x:a.clientX,y:a.clientY})},[]),handleCommitInfoMouseLeave:(0,d.useCallback)(()=>{S(null)},[]),compareMode:T,toggleCompareMode:av,compareBaseBranch:X,setCompareBaseBranch:Y,upstreamBranch:V,compareFiles:Z,compareFileTree:_,compareExpandedPaths:ab,compareSelectedFile:ad,compareFileDiff:af,isLoadingCompareFiles:ah,isLoadingCompareDiff:aj,handleSelectCompareFile:at,handleCompareToggle:au,loadCompareFiles:as}}},62473:(a,b,c)=>{"use strict";c.d(b,{g:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[h,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-11":b?.status==="allowed_warning"?"text-amber-11":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-h;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border ",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,"data-tooltip":[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5","data-tooltip":[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},63041:(a,b,c)=>{"use strict";c.d(b,{e:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(35606);function h({cwd:a,sessionId:b,engine:c,onOpenProjectSessions:i,onOpenSessionBrowser:j,onOpenSettings:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),o=b?(0,g.X)(c,b):null;return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:j,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),o&&(0,d.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(o).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${m?"text-green-11 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:m?l("chat.copiedCommandTooltip"):l("chat.copyCommandTooltip",{command:o}),children:m?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:k,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}},63565:(a,b,c)=>{"use strict";c.d(b,{$T:()=>n,Aw:()=>o,CX:()=>j,Fx:()=>m,H:()=>g,XY:()=>s,ch:()=>h,eV:()=>q,hG:()=>r,pe:()=>k,yI:()=>l,ys:()=>p});var d=c(48249);c(67484);var e=c(42742),f=c(44218);let g={claude:"Claude",codex:"Codex",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function h(a){return!!a&&a in g}let i={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5},j=Object.keys(i).sort((a,b)=>i[a]-i[b]),k={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",deepseek:"text-sky-600 dark:text-sky-400",kimi:"text-purple-600 dark:text-purple-400",glm:"text-amber-600 dark:text-amber-400",ollama:"text-violet-600 dark:text-violet-400"},l="bg-accent font-medium text-foreground",m="focus:border-brand",n="bg-brand text-white hover:bg-brand/90",o="text-rose-600 dark:text-rose-400",p="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function q({engine:a,className:b="h-3.5 w-3.5"}){return(0,d.jsx)("img",{alt:"","aria-hidden":"true",src:`/agent-icons/${a}.svg`,className:`${b} flex-shrink-0`})}function r({selected:a}){return(0,d.jsx)("span",{className:"flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center text-foreground",children:a&&(0,d.jsx)(e.A,{className:"h-3.5 w-3.5"})})}function s({label:a,title:b,onClick:c,buttonRef:e,icon:g,labelClassName:h,labelMaxWidth:i="max-w-[160px]",testId:j}){return(0,d.jsxs)("button",{ref:e,type:"button",onClick:c,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:b,"data-testid":j,children:[g,(0,d.jsx)("span",{className:`truncate ${i} ${h??""}`,children:a}),(0,d.jsx)(f.A,{className:"h-3 w-3 flex-shrink-0"})]})}},64340:(a,b,c)=>{"use strict";c.d(b,{r:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(),[c,e]=(0,d.useState)(),[f,g]=(0,d.useState)(!1),h=!!a&&!!c&&function(a,b){let c=a=>a.replace(/^v/,"").split("-")[0].split(".").map(a=>parseInt(a,10)||0),d=c(a),e=c(b),f=Math.max(d.length,e.length);for(let a=0;a<f;a++){let b=d[a]??0,c=e[a]??0;if(b!==c)return b-c}return 0}(c,a)>0;return{current:a,latest:f?c??"999.0.0":c,hasUpdate:!!f||h}}c(33281),c(65484)},64676:(a,b,c)=>{"use strict";c.d(b,{GV:()=>s,J4:()=>i,Kx:()=>t,OP:()=>w,PB:()=>v,Xe:()=>m,hE:()=>u,qF:()=>j,xh:()=>p});var d=c(23389);let e=`
28
- (function () {
29
- if (window.cockpit) return;
30
-
31
- // Language — parked on <html data-cockpit-lang>, NOT delivered by listener
32
- // alone. The host pushes cockpit:language-change once, on the iframe's load
33
- // event. Anything registering a listener later misses it forever, and the
34
- // widget bundles (/html-lib markdown / json / pdf) are lazily fetched — they
35
- // always register after load, so they used to fall back to navigator.language
36
- // and disagree with the Cockpit setting until the user toggled it. This script
37
- // is injected at the very start of <head>, so it is guaranteed to be listening
38
- // first; parking the value turns a one-shot message into order-independent
39
- // state any later reader can just read.
40
- //
41
- // A DEDICATED attribute, not <html lang>: pages ship their own lang="en" (the
42
- // built-in file-viewer does), so <html lang> cannot distinguish "the host told
43
- // us" from "the document's own default" — reading it would pin every reader to
44
- // the page's hardcoded value and silently kill the navigator fallback.
45
- var applyLang = function (lang) {
46
- if (!lang) return;
47
- try {
48
- document.documentElement.setAttribute('data-cockpit-lang', lang);
49
- document.documentElement.lang = lang; // keep the document honest for a11y
50
- } catch (e) {}
51
- };
52
- window.addEventListener('message', function (ev) {
53
- var d = ev && ev.data;
54
- if (d && d.type === 'cockpit:language-change') applyLang(d.lang);
55
- });
56
-
57
- // Dock — the one floating container every piece of host chrome mounts into
58
- // (theme toggle, bash call log). Independent floating buttons do not work:
59
- // they all default to the same corner and cover each other, and the user then
60
- // has to drag each one separately off whatever the app put underneath.
61
- //
62
- // The dock is DRAGGABLE and snaps to whichever of the 4 viewport corners it
63
- // was released nearest to. A fixed corner is unworkable: the host picks the
64
- // spot, the app owns the content, and any app with its own corner affordance
65
- // (close button, toolbar, TOC) had it permanently covered with no escape.
66
- // Only the CORNER is persisted, never pixels: on resize/rotate a remembered
67
- // coordinate can land off-screen, while a corner is always re-derivable. It is
68
- // remembered GLOBALLY (not per app) — one gesture then holds for every HTML
69
- // app, which is the common case since apps tend to crowd the same corner.
70
- //
71
- // Created lazily on the first add(), so a page that activates neither feature
72
- // gets no DOM at all.
73
- var DOCK_BTN_CSS = 'width:36px;height:36px;border-radius:8px;flex:none;' +
74
- 'border:1px solid rgba(128,128,128,.3);background:rgba(128,128,128,.14);' +
75
- 'color:inherit;cursor:pointer;font-size:14px;line-height:1;display:flex;' +
76
- 'align-items:center;justify-content:center;padding:0';
77
- var dock = (function () {
78
- // Key predates the dock: a user who already dragged the lone theme button
79
- // keeps that choice instead of silently getting reset to the default corner.
80
- var CORNER_KEY = 'htmlapp-theme-corner'; // 'tl' | 'tr' | 'bl' | 'br'
81
- var CORNER_MARGIN = 10;
82
- var corner = 'tr'; // default = the historic position
83
- try {
84
- var storedCorner = localStorage.getItem(CORNER_KEY);
85
- if (storedCorner === 'tl' || storedCorner === 'tr' ||
86
- storedCorner === 'bl' || storedCorner === 'br') corner = storedCorner;
87
- } catch (e) {}
88
-
89
- var el = null;
90
- var queued = [];
91
- var watchers = [];
92
-
93
- var applyCorner = function () {
94
- if (el) {
95
- var s = el.style;
96
- var atTop = corner.charAt(0) === 't';
97
- var atLeft = corner.charAt(1) === 'l';
98
- s.top = atTop ? CORNER_MARGIN + 'px' : 'auto';
99
- s.bottom = atTop ? 'auto' : CORNER_MARGIN + 'px';
100
- s.left = atLeft ? CORNER_MARGIN + 'px' : 'auto';
101
- s.right = atLeft ? 'auto' : CORNER_MARGIN + 'px';
102
- }
103
- for (var i = 0; i < watchers.length; i++) {
104
- try { watchers[i](corner); } catch (e) {}
105
- }
106
- };
107
-
108
- var dragging = false; // past the slop threshold for THIS gesture
109
- var didDrag = false; // a drag happened -> swallow the trailing click
110
- var held = null; // element holding the pointer capture; see pointerdown
111
- var startX = 0, startY = 0, grabX = 0, grabY = 0;
112
-
113
- var build = function () {
114
- el = document.createElement('div');
115
- // touch-action:none — the drag is pointer-driven, so the browser must not
116
- // also treat the gesture as a scroll. Without it a touch-drag inside an
117
- // iframe can scroll-chain to the Cockpit shell behind it.
118
- el.style.cssText = 'position:fixed;z-index:2147483647;display:flex;' +
119
- 'flex-direction:column;gap:8px;touch-action:none';
120
- applyCorner();
121
-
122
- // Pointer LISTENERS sit on the container (one set for every button), but
123
- // the CAPTURE has to stay on the pressed button: per Pointer Events, a
124
- // click is dispatched to the capture target, so capturing on the container
125
- // silently eats every button click — the buttons render and do nothing.
126
- // Capturing the child instead keeps click on the button, and the moves it
127
- // now receives still bubble up to these listeners.
128
- el.addEventListener('pointerdown', function (ev) {
129
- if (ev.button) return; // primary button / touch / pen only
130
- dragging = false;
131
- didDrag = false; // reset here, so a swallowed click
132
- // can never leak into the next press
133
- startX = ev.clientX; startY = ev.clientY;
134
- var r = el.getBoundingClientRect();
135
- grabX = ev.clientX - r.left; grabY = ev.clientY - r.top;
136
- var target = ev.target && ev.target.setPointerCapture ? ev.target : el;
137
- held = null;
138
- // No capture (or a refused one) just means no drag this gesture — the
139
- // click still works, which is the one thing that must never break.
140
- try { target.setPointerCapture(ev.pointerId); held = target; } catch (e) {}
141
- });
142
-
143
- el.addEventListener('pointermove', function (ev) {
144
- if (!held || !held.hasPointerCapture || !held.hasPointerCapture(ev.pointerId)) return;
145
- if (!dragging) {
146
- // Slop before a press becomes a drag: a finger never holds as still as
147
- // a mouse, so touch needs the looser threshold or taps turn into drags.
148
- var slop = ev.pointerType === 'touch' ? 8 : 5;
149
- if (Math.abs(ev.clientX - startX) < slop &&
150
- Math.abs(ev.clientY - startY) < slop) return;
151
- dragging = true; didDrag = true;
152
- }
153
- ev.preventDefault();
154
- var s = el.style;
155
- s.right = 'auto'; s.bottom = 'auto'; // free-float while held
156
- s.left = (ev.clientX - grabX) + 'px';
157
- s.top = (ev.clientY - grabY) + 'px';
158
- });
159
-
160
- var release = function (ev) {
161
- if (!held) return;
162
- try { held.releasePointerCapture(ev.pointerId); } catch (e) {}
163
- held = null;
164
- };
165
-
166
- el.addEventListener('pointerup', function (ev) {
167
- release(ev);
168
- if (!dragging) return;
169
- dragging = false;
170
- var r = el.getBoundingClientRect();
171
- corner = ((r.top + r.height / 2) < window.innerHeight / 2 ? 't' : 'b') +
172
- ((r.left + r.width / 2) < window.innerWidth / 2 ? 'l' : 'r');
173
- try { localStorage.setItem(CORNER_KEY, corner); } catch (e) {}
174
- applyCorner();
175
- });
176
-
177
- el.addEventListener('pointercancel', function (ev) {
178
- dragging = false;
179
- release(ev);
180
- applyCorner(); // snap back rather than strand it
181
- });
182
-
183
- // Capture phase on the container, so the click that trails a drag is
184
- // swallowed BEFORE it reaches the button it was released over. Buttons
185
- // keep plain click handlers, so keyboard activation still toggles.
186
- el.addEventListener('click', function (ev) {
187
- if (!didDrag) return;
188
- didDrag = false;
189
- ev.stopPropagation();
190
- ev.preventDefault();
191
- }, true);
192
-
193
- window.addEventListener('resize', applyCorner);
194
- document.body.appendChild(el);
195
- };
196
-
197
- var flush = function () {
198
- if (!document.body) return; // retried on DOMContentLoaded
199
- if (!el) build();
200
- for (var i = 0; i < queued.length; i++) el.appendChild(queued[i]);
201
- queued = [];
202
- };
203
- document.addEventListener('DOMContentLoaded', flush);
204
-
205
- return {
206
- // The order fixes the slot regardless of WHEN a button is added — the theme
207
- // toggle waits for DOMContentLoaded, the log button for the page's first
208
- // bash call, so append order alone would shuffle them around.
209
- add: function (node, order) {
210
- node.style.order = String(order);
211
- queued.push(node);
212
- flush();
213
- },
214
- corner: function () { return corner; },
215
- // Panels anchored to the dock re-place themselves on every corner change.
216
- watch: function (fn) { watchers.push(fn); }
217
- };
218
- })();
219
-
220
- // Host theme, tracked UNCONDITIONALLY — deliberately separate from the opt-in
221
- // theme block below. Host chrome (the call-log panel) has to match Cockpit on
222
- // EVERY previewed page, but the .dark class is only maintained for pages that
223
- // declared <meta name="cockpit-theme">, which most previewed files never do.
224
- // Reading the class alone would leave the panel stuck dark on a light page.
225
- var hostDark = null; // null = the host has not told us anything yet
226
- var themeActive = false; // page opted into theming -> .dark is authoritative
227
- window.addEventListener('message', function (ev) {
228
- var d = ev && ev.data;
229
- if (!d || d.type !== 'THEME_CHANGE') return;
230
- hostDark = d.theme === 'dark' || (d.theme === 'system' &&
231
- !!(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches));
232
- applyAuditTheme();
233
- });
234
-
235
- // Effective dark/light for host chrome: the page's own theme when it opted in
236
- // (so its toggle — and any stored per-app choice — drives the panel too), else
237
- // whatever the host last pushed, else the OS preference.
238
- function chromeDark() {
239
- try {
240
- if (themeActive) return document.documentElement.classList.contains('dark');
241
- if (hostDark !== null) return hostDark;
242
- return !!(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches);
243
- } catch (e) { return false; }
244
- }
245
-
246
- // Theme — OPT-IN. The floating toggle + any .dark class management
247
- // happen ONLY when the page declares <meta name="cockpit-theme" content="...">.
248
- // Rationale: injection is by file type, not by SDK usage, so plain one-off pages
249
- // (notes, reports) with no dark styling used to get a dead button that toggled a
250
- // .dark class nothing responds to. Requiring an explicit opt-in marker keeps the
251
- // button off those pages, while apps that provide :root/.dark tokens just add the
252
- // meta to get a free host-managed toggle — no per-app button code needed.
253
- // content="auto" → first load with no stored choice follows the OS preference
254
- // content="light" → first load defaults to light (still user-toggleable)
255
- // content="dark" → first load defaults to dark
256
- // The user's explicit toggle is REMEMBERED per app (key namespaced by cockpit-name,
257
- // else page path) across reloads, and wins over the content default on next load.
258
- // localStorage is SHARED with Cockpit + every other app, hence the namespaced key.
259
- // Apps can also drive it programmatically via window.cockpit.toggleTheme().
260
- var toggleTheme = function () {};
261
- var initTheme = function () {
262
- try {
263
- var themeMeta = function (n) {
264
- var el = document.querySelector('meta[name="' + n + '"]');
265
- return el ? el.content : '';
266
- };
267
- var themeSetting = (themeMeta('cockpit-theme') || '').toLowerCase().trim();
268
- if (themeSetting) {
269
- themeActive = true;
270
- var themeKey = 'htmlapp-theme:' + (themeMeta('cockpit-name') || location.pathname);
271
- // Store the explicit choice both ways so it round-trips regardless of the
272
- // content default (a bare "store only dark" model would lose a user's light
273
- // choice under content="auto" on a dark OS).
274
- var themeStore = function (d) {
275
- try { localStorage.setItem(themeKey, d ? 'dark' : 'light'); } catch (e) {}
276
- };
277
- var themeBtn = null;
278
- var setDark = function (d, persist) {
279
- document.documentElement.classList.toggle('dark', !!d);
280
- if (persist) themeStore(!!d);
281
- if (themeBtn) themeBtn.textContent = d ? '☀️' : '\u{1F319}';
282
- applyAuditTheme(); // host chrome follows the page it is sitting on
283
- };
284
- toggleTheme = function () {
285
- setDark(!document.documentElement.classList.contains('dark'), true);
286
- };
287
- // Init: remembered user choice wins; else the content default; "auto" follows OS.
288
- var stored = null;
289
- try { stored = localStorage.getItem(themeKey); } catch (e) {}
290
- var initDark;
291
- if (stored === 'dark' || stored === 'light') initDark = stored === 'dark';
292
- else if (themeSetting === 'dark') initDark = true;
293
- else if (themeSetting === 'auto') initDark = !!(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches);
294
- else initDark = false; // light / unknown
295
- setDark(initDark, false);
296
- // Follow the Cockpit host theme by default: the console bubble pushes a
297
- // THEME_CHANGE on iframe load and ThemeProvider broadcasts it on toggle.
298
- // An explicit per-app user choice (stored) always wins over the host.
299
- window.addEventListener('message', function (ev) {
300
- var d = ev && ev.data;
301
- if (!d || d.type !== 'THEME_CHANGE') return;
302
- var userChoice = null;
303
- try { userChoice = localStorage.getItem(themeKey); } catch (e) {}
304
- if (userChoice === 'dark' || userChoice === 'light') return;
305
- var hostDark = d.theme === 'dark' || (d.theme === 'system' &&
306
- !!(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches));
307
- setDark(hostDark, false);
308
- });
309
- // Positioning, dragging and corner memory all belong to the dock — this
310
- // button only has to look like one and say what it does.
311
- themeBtn = document.createElement('button');
312
- themeBtn.type = 'button';
313
- themeBtn.setAttribute('aria-label', 'Toggle theme');
314
- themeBtn.textContent = document.documentElement.classList.contains('dark') ? '☀️' : '\u{1F319}';
315
- themeBtn.style.cssText = DOCK_BTN_CSS;
316
- // A click handler rather than pointerup, so keyboard activation
317
- // (Enter/Space on the focused button) still toggles. The click that
318
- // trails a drag is swallowed by the dock before it gets here.
319
- themeBtn.onclick = function () { toggleTheme(); };
320
- dock.add(themeBtn, 0);
321
- }
322
- } catch (e) {}
323
- };
324
- // This script is injected at the START of <head>, BEFORE the page's own
325
- // <meta> tags are parsed — reading them synchronously here always misses
326
- // them. Defer theme init until the DOM is ready so the opt-in meta is seen.
327
- if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initTheme);
328
- else initTheme();
329
-
330
- var CWD = __CWD__;
331
- var WS_URL = __WS_URL__;
332
-
333
- var ws = null;
334
- var ready = false;
335
- var queue = []; // [{ id, s }] — pending frames, drained on open
336
- var handlers = {}; // id -> { onStdout, onStderr, onExit, onError, gen }
337
- var seq = 0;
338
- var gen = 0; // connection generation; see ensureWs
339
-
340
- function resolveWsUrl() {
341
- if (WS_URL) return WS_URL;
342
- var proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
343
- return proto + '//' + location.host + '/ws/bash?cwd=' + encodeURIComponent(CWD);
344
- }
345
-
346
- function failAll(reason) {
347
- var ids = Object.keys(handlers);
348
- for (var i = 0; i < ids.length; i++) {
349
- var h = handlers[ids[i]];
350
- delete handlers[ids[i]];
351
- if (h && h.onError) h.onError(reason);
352
- }
353
- }
354
-
355
- /**
356
- * Fail only the commands carried by ONE connection. Handlers are tagged with
357
- * the generation of the socket that actually wrote them, so a socket that has
358
- * been replaced can report its own losses without touching its successor's
359
- * in-flight work.
360
- */
361
- function failGen(g, reason) {
362
- var ids = Object.keys(handlers);
363
- for (var i = 0; i < ids.length; i++) {
364
- var h = handlers[ids[i]];
365
- if (!h || h.gen !== g) continue;
366
- delete handlers[ids[i]];
367
- if (h.onError) h.onError(reason);
368
- }
369
- }
370
-
371
- function ensureWs() {
372
- if (ws && (ws.readyState === 0 || ws.readyState === 1)) return;
373
- // A socket in CLOSING(2) is replaced here rather than waited on, so two
374
- // sockets can briefly coexist. Shared state (\`ready\`, \`queue\`) may only
375
- // be touched by the CURRENT socket — otherwise a replaced socket's late
376
- // onclose flips \`ready\` to false while its successor is already open, and
377
- // since the successor's onopen has long since fired nothing ever sets it
378
- // back: every later bash() then queues forever with no error at all.
379
- var myGen = ++gen;
380
- var sock;
381
- try { sock = new WebSocket(resolveWsUrl()); }
382
- catch (e) { failAll(String(e)); return; }
383
- ws = sock;
384
- ready = false;
385
- sock.onopen = function () {
386
- if (ws !== sock) return;
387
- ready = true;
388
- var q = queue; queue = [];
389
- for (var i = 0; i < q.length; i++) {
390
- // Re-tag: this socket, not the one queued them, is the carrier.
391
- if (handlers[q[i].id]) handlers[q[i].id].gen = myGen;
392
- sock.send(q[i].s);
393
- }
394
- };
395
- // NOT generation-guarded: ids are globally unique, so a late frame can only
396
- // belong to the command this very socket carried. Dropping it would leave
397
- // that command's promise unsettled forever.
398
- sock.onmessage = function (ev) {
399
- var msg;
400
- try { msg = JSON.parse(ev.data); } catch (e) { return; }
401
- if (msg.type === 'ping') return;
402
- var h = handlers[msg.id];
403
- if (!h) return;
404
- if (msg.type === 'stdout') { if (h.onStdout) h.onStdout(msg.data); }
405
- else if (msg.type === 'stderr') { if (h.onStderr) h.onStderr(msg.data); }
406
- else if (msg.type === 'exit') { delete handlers[msg.id]; if (h.onExit) h.onExit(msg.code); }
407
- else if (msg.type === 'error') { delete handlers[msg.id]; if (h.onError) h.onError(msg.message); }
408
- };
409
- sock.onclose = function () {
410
- if (ws === sock) {
411
- ready = false;
412
- // Drop anything still queued and fail it here. These are shell commands
413
- // with side effects: letting a later reconnect drain this queue would
414
- // re-run them with their handlers already gone, so the output would go
415
- // nowhere and the caller would never learn it ran twice.
416
- var q = queue; queue = [];
417
- for (var i = 0; i < q.length; i++) {
418
- var qh = handlers[q[i].id];
419
- if (!qh) continue;
420
- delete handlers[q[i].id];
421
- if (qh.onError) qh.onError('connection closed');
422
- }
423
- }
424
- // Always report THIS connection's own losses, current or replaced — a
425
- // replaced socket still owes an answer to whatever it was carrying.
426
- failGen(myGen, 'connection closed');
427
- };
428
- sock.onerror = function () { /* onclose follows */ };
429
- }
430
-
431
- function send(obj) {
432
- var s = JSON.stringify(obj);
433
- ensureWs();
434
- // Tag AFTER ensureWs — it may have opened a new connection, and what
435
- // matters is which socket ends up carrying this command.
436
- if (obj.id && handlers[obj.id]) handlers[obj.id].gen = gen;
437
- if (ready && ws && ws.readyState === 1) ws.send(s);
438
- else queue.push({ id: obj.id, s: s });
439
- }
440
-
441
- // ── Bash call log ─────────────────────────────────────────────────────────
442
- // Every bash() the page issues is recorded and shown in a floating panel, so
443
- // the user can audit what a previewed page actually ran. Previewing a local
444
- // .html RUNS it, with full shell access, and until now that happened with no
445
- // trace anywhere: /ws/bash deliberately stays out of terminal history and logs
446
- // only the cwd of a connection, never a command.
447
- //
448
- // NOT opt-in via <meta>, unlike the theme toggle: a page that could switch the
449
- // log off by omitting a tag would simply omit it. Instead the button stays
450
- // hidden until the page's FIRST bash call — so a plain note/report still gets
451
- // no chrome, and the button appearing is itself the signal that this page ran
452
- // something.
453
- //
454
- // In memory, per page: a reload clears the log, and so does the panel's Clear
455
- // button. NOT localStorage — that store is shared with Cockpit and writable by
456
- // the page, so a persisted log would be forgeable by the very code it audits.
457
- // Nothing is exposed on window.cockpit for the same reason: this is host
458
- // chrome reporting on the page, not a feature the page gets to drive.
459
- var AUDIT_MAX = 300; // ring bound — a page can call bash() in a loop
460
- // Two palettes, applied as custom properties on the panel: every descendant
461
- // reads var(--cpk-*), so a theme flip is one property write instead of a
462
- // re-render, and rows built earlier restyle themselves.
463
- var AUDIT_THEME = {
464
- dark: {
465
- bg: 'rgba(28,28,30,.97)', fg: '#e8e8ea', bd: 'rgba(255,255,255,.14)',
466
- line: 'rgba(255,255,255,.09)', btn: 'rgba(255,255,255,.22)',
467
- shadow: '0 8px 30px rgba(0,0,0,.45)',
468
- running: '#e0a648', exit: '#4ea774', error: '#e0605c', killed: '#8a8a8e'
469
- },
470
- light: {
471
- bg: 'rgba(255,255,255,.98)', fg: '#1c1c1e', bd: 'rgba(0,0,0,.16)',
472
- line: 'rgba(0,0,0,.09)', btn: 'rgba(0,0,0,.22)',
473
- shadow: '0 8px 30px rgba(0,0,0,.18)',
474
- // Darker than their dark-mode counterparts — the same green/amber that
475
- // reads well on near-black washes out entirely on near-white.
476
- running: '#9a6510', exit: '#2f7d52', error: '#c0392b', killed: '#6b6b70'
477
- }
478
- };
479
- var AUDIT_HEAD_BTN_CSS = 'border:1px solid var(--cpk-btn);background:transparent;' +
480
- 'color:inherit;border-radius:6px;padding:2px 8px;font-size:11px;cursor:pointer;flex:none';
481
- var calls = [];
482
- var callIndex = {}; // id -> record, only while in flight
483
- var auditBtn = null, auditPanel = null, auditList = null, auditTitle = null;
484
- var auditOpen = false;
485
-
486
- function auditStart(id, command, cwd, background) {
487
- try {
488
- var rec = {
489
- command: String(command),
490
- cwd: cwd,
491
- background: !!background,
492
- startedAt: Date.now(),
493
- endedAt: 0,
494
- state: 'running', // running | exit | error | killed
495
- code: null,
496
- message: ''
497
- };
498
- calls.push(rec);
499
- if (calls.length > AUDIT_MAX) calls.shift();
500
- callIndex[id] = rec;
501
- mountAuditBtn();
502
- renderAudit();
503
- } catch (e) {}
504
- }
505
-
506
- // The state is terminal once set: kill() settles the record itself, and a real
507
- // exit frame may still arrive afterwards for the same id.
508
- function auditSettle(id, state, detail) {
509
- try {
510
- var rec = callIndex[id];
511
- if (!rec) return;
512
- delete callIndex[id];
513
- if (rec.state !== 'running') return;
514
- rec.state = state;
515
- rec.endedAt = Date.now();
516
- if (state === 'exit') rec.code = detail;
517
- else if (detail != null) rec.message = String(detail);
518
- renderAudit();
519
- } catch (e) {}
520
- }
521
-
522
- function auditStatusText(rec) {
523
- if (rec.state === 'running') return 'running';
524
- if (rec.state === 'killed') return 'killed';
525
- if (rec.state === 'error') return rec.message ? 'error: ' + rec.message : 'error';
526
- return 'exit ' + rec.code;
527
- }
528
-
529
- function auditRow(rec) {
530
- var row = document.createElement('div');
531
- row.style.cssText = 'padding:8px 10px;border-top:1px solid var(--cpk-line)';
532
- var cmd = document.createElement('div');
533
- // textContent, never innerHTML — this string comes from the page being audited.
534
- cmd.textContent = rec.command;
535
- cmd.style.cssText = 'font-family:ui-monospace,SFMono-Regular,Menlo,monospace;' +
536
- 'font-size:12px;line-height:1.45;white-space:pre-wrap;word-break:break-all';
537
- var bits = [];
538
- try { bits.push(new Date(rec.startedAt).toTimeString().slice(0, 8)); } catch (e) {}
539
- bits.push(auditStatusText(rec));
540
- if (rec.endedAt) bits.push(((rec.endedAt - rec.startedAt) / 1000).toFixed(2) + 's');
541
- if (rec.background) bits.push('background');
542
- // Only when it differs from the page's own cwd — otherwise it is noise on
543
- // every single row.
544
- if (rec.cwd && rec.cwd !== CWD) bits.push(rec.cwd);
545
- var bad = rec.state === 'error' || (rec.state === 'exit' && rec.code !== 0);
546
- var meta = document.createElement('div');
547
- meta.textContent = bits.join(' \xb7 ');
548
- meta.style.cssText = 'margin-top:3px;font-size:11px;color:var(--cpk-' +
549
- (bad ? 'error' : rec.state) + ')';
550
- row.appendChild(cmd);
551
- row.appendChild(meta);
552
- return row;
553
- }
554
-
555
- // Records accumulate whether or not anyone is looking; this only paints, and
556
- // a closed panel is repainted once on open instead. That is not a micro
557
- // optimization: a page can call bash() in a loop, and rebuilding every row per
558
- // call behind a hidden panel is quadratic work for nobody.
559
- function renderAudit() {
560
- if (!auditPanel || !auditOpen) return;
561
- auditTitle.textContent = 'Bash calls (' + calls.length + ')';
562
- while (auditList.firstChild) auditList.removeChild(auditList.firstChild);
563
- if (!calls.length) {
564
- var empty = document.createElement('div');
565
- empty.style.cssText = 'padding:14px 10px;font-size:12px;opacity:.6';
566
- empty.textContent = 'No calls recorded.';
567
- auditList.appendChild(empty);
568
- return;
569
- }
570
- // Newest first: the reason to open this panel is almost always "what did it
571
- // just run".
572
- for (var i = calls.length - 1; i >= 0; i--) auditList.appendChild(auditRow(calls[i]));
573
- }
574
-
575
- // Called on every host theme change, including before the panel exists.
576
- function applyAuditTheme() {
577
- if (!auditPanel) return;
578
- var tone = AUDIT_THEME[chromeDark() ? 'dark' : 'light'];
579
- for (var k in tone) auditPanel.style.setProperty('--cpk-' + k, tone[k]);
580
- }
581
-
582
- function placeAuditPanel() {
583
- if (!auditPanel) return;
584
- var c = dock.corner();
585
- var s = auditPanel.style;
586
- var atTop = c.charAt(0) === 't';
587
- var atLeft = c.charAt(1) === 'l';
588
- s.top = atTop ? '10px' : 'auto';
589
- s.bottom = atTop ? 'auto' : '10px';
590
- // 56px = dock margin (10) + button (36) + gap (10): beside the dock, never
591
- // under it, on whichever side the dock currently sits.
592
- s.left = atLeft ? '56px' : 'auto';
593
- s.right = atLeft ? 'auto' : '56px';
594
- }
595
-
596
- function buildAuditPanel() {
597
- auditPanel = document.createElement('div');
598
- // z-index one below the dock, so the panel can never bury its own toggle.
599
- auditPanel.style.cssText = 'position:fixed;z-index:2147483646;width:380px;' +
600
- 'max-width:calc(100vw - 76px);max-height:60vh;display:none;flex-direction:column;' +
601
- 'background:var(--cpk-bg);color:var(--cpk-fg);border:1px solid var(--cpk-bd);' +
602
- 'border-radius:10px;box-shadow:var(--cpk-shadow);overflow:hidden;' +
603
- 'font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif';
604
- applyAuditTheme();
605
- var head = document.createElement('div');
606
- head.style.cssText = 'display:flex;align-items:center;gap:8px;padding:8px 10px;flex:none;' +
607
- 'border-bottom:1px solid var(--cpk-line);font-size:12px';
608
- auditTitle = document.createElement('div');
609
- auditTitle.style.cssText = 'flex:1;font-weight:600';
610
- var clearBtn = document.createElement('button');
611
- clearBtn.type = 'button';
612
- clearBtn.textContent = 'Clear';
613
- clearBtn.style.cssText = AUDIT_HEAD_BTN_CSS;
614
- clearBtn.onclick = function () {
615
- // Still-running calls survive the clear: they have no result yet, and
616
- // dropping their rows would make a command that is at this moment
617
- // executing look like it never happened.
618
- var keep = [];
619
- for (var i = 0; i < calls.length; i++) {
620
- if (calls[i].state === 'running') keep.push(calls[i]);
621
- }
622
- calls = keep;
623
- renderAudit();
624
- };
625
- var closeBtn = document.createElement('button');
626
- closeBtn.type = 'button';
627
- closeBtn.textContent = '✕';
628
- closeBtn.setAttribute('aria-label', 'Close');
629
- closeBtn.style.cssText = AUDIT_HEAD_BTN_CSS;
630
- closeBtn.onclick = function () { setAuditOpen(false); };
631
- head.appendChild(auditTitle);
632
- head.appendChild(clearBtn);
633
- head.appendChild(closeBtn);
634
- auditList = document.createElement('div');
635
- auditList.style.cssText = 'overflow:auto;flex:1';
636
- auditPanel.appendChild(head);
637
- auditPanel.appendChild(auditList);
638
- placeAuditPanel();
639
- dock.watch(placeAuditPanel);
640
- document.body.appendChild(auditPanel);
641
- }
642
-
643
- function setAuditOpen(open) {
644
- auditOpen = !!open;
645
- if (auditOpen && !auditPanel) buildAuditPanel();
646
- if (auditPanel) auditPanel.style.display = auditOpen ? 'flex' : 'none';
647
- if (auditBtn) auditBtn.setAttribute('aria-expanded', auditOpen ? 'true' : 'false');
648
- if (auditOpen) renderAudit();
649
- }
650
-
651
- function mountAuditBtn() {
652
- if (auditBtn) return;
653
- auditBtn = document.createElement('button');
654
- auditBtn.type = 'button';
655
- auditBtn.setAttribute('aria-label', 'Bash call log');
656
- auditBtn.setAttribute('aria-expanded', 'false');
657
- auditBtn.title = 'Bash call log';
658
- auditBtn.textContent = '\u{1F4DC}';
659
- auditBtn.style.cssText = DOCK_BTN_CSS;
660
- auditBtn.onclick = function () { setAuditOpen(!auditOpen); };
661
- dock.add(auditBtn, 1); // below the theme toggle, whichever mounts first
662
- }
663
-
664
- function run(command, opts) {
665
- opts = opts || {};
666
- var id = 'c' + (++seq);
667
- var cwd = opts.cwd || CWD;
668
- auditStart(id, command, cwd, opts.background);
669
- handlers[id] = {
670
- onStdout: opts.onStdout,
671
- onStderr: opts.onStderr,
672
- // Settle the record BEFORE handing control to the app's own callback: a
673
- // callback that throws must not leave the log stuck showing "running".
674
- onExit: function (code) { auditSettle(id, 'exit', code); if (opts.onExit) opts.onExit(code); },
675
- onError: function (m) { auditSettle(id, 'error', m); if (opts.onError) opts.onError(m); }
676
- };
677
- send({ type: 'exec', id: id, command: command, cwd: cwd });
678
- return id;
679
- }
680
-
681
- function bash(command, opts) {
682
- opts = opts || {};
683
- if (opts.background) {
684
- var id = run(command, {
685
- cwd: opts.cwd,
686
- background: true,
687
- onStdout: opts.onOutput,
688
- onStderr: opts.onStderr || opts.onOutput,
689
- onExit: opts.onExit,
690
- onError: opts.onError
691
- });
692
- return { kill: function () {
693
- send({ type: 'kill', id: id });
694
- delete handlers[id];
695
- // Settle here rather than waiting for the exit frame: the handler is
696
- // gone, so nothing else will ever settle this record.
697
- auditSettle(id, 'killed');
698
- } };
699
- }
700
- return new Promise(function (resolve, reject) {
701
- var out = '', err = '';
702
- run(command, {
703
- cwd: opts.cwd,
704
- onStdout: function (d) { out += d; },
705
- onStderr: function (d) { err += d; },
706
- onExit: function (code) { resolve({ stdout: out, stderr: err, exitCode: code }); },
707
- onError: function (m) { reject(new Error(m)); }
708
- });
709
- });
710
- }
711
-
712
- // toggleTheme is reassigned by the deferred initTheme — forward lazily so the
713
- // exported function always calls the current implementation, not the no-op.
714
- window.cockpit = {
715
- cwd: CWD,
716
- bash: bash,
717
- toggleTheme: function () { toggleTheme(); },
718
- // Current host language ('' until the host's first push, so apps can fall
719
- // back to navigator themselves). Apps PERCEIVE the language and own their
720
- // own strings — this is not an i18n runtime.
721
- get lang() {
722
- return document.documentElement.getAttribute('data-cockpit-lang') || '';
723
- }
724
- };
725
- window.addEventListener('beforeunload', function () {
726
- try { if (ws) ws.close(); } catch (e) {}
727
- });
728
- })();
729
- `;function f(a){return/^([/\\]|[A-Za-z]:)/.test(a)}function g(a){return f(a)||(0,d.P)(a)}function h(a,b){let c=a.replace(/[/\\]+$/,"");return b?`${c}/${b}`:c}function i(a,b){let c,d=(c=Math.max(a.lastIndexOf("/"),a.lastIndexOf("\\")))<0?"":0===c?"/":a.slice(0,c);return g(a)?d:b?h(b,d):d}function j(a,b){return g(a)||!!b}let k="/apps/local/",l="/apps/builtin/";function m(a,b){let c=a.trim();return k+n(g(c)?c:h(b??"",c)).replace(/\\/g,"/").split("/").map(encodeURIComponent).join("/").replace(/^\//,"")}function n(a){let b=/^[A-Za-z]:/.exec(a)?.[0]??"",c=b?a.slice(b.length):a,d=/^[/\\]/.test(c),e=[];for(let a of c.split(/[/\\]/))if(a&&"."!==a){if(".."===a){e.length&&".."!==e[e.length-1]?e.pop():d||b||e.push("..");continue}e.push(a)}return b+(d||b?"/":"")+e.join("/")}let o=/^([a-z][a-z0-9+.-]*:|\/\/|\/)/i;function p(a,b,c){let d=a.trim();if(!d||o.test(d)||!j(b,c))return a;let e=f(b)?b:h(c,b),g=d.search(/[?#]/),i=g<0?d:d.slice(0,g),k=g<0?"":d.slice(g);if(!i)return a;let l=i;try{l=decodeURIComponent(i)}catch{}return m(n(h(e,l)))+k}let q=[{chip:"*.md",exts:["md"]},{chip:"*.png/jpg/gif/webp/svg",exts:["png","jpg","jpeg","gif","webp","svg"]},{chip:"*.pdf",exts:["pdf"]},{chip:"*.json",exts:["json"]},{chip:"*.csv",exts:["csv"]},{chip:"*.tsv",exts:["tsv"]}],r=RegExp(`\\.(${q.flatMap(a=>a.exts).join("|")})$`,"i"),s=q.map(a=>a.chip);function t(a){return r.test(a.trim())}function u(a,b){let c=a.trim();return l+"file-viewer/index.html?file="+encodeURIComponent(n(g(c)?c:h(b??"",c)).replace(/\\/g,"/"))}function v(a,b){try{let c=new URL(a,b);if(!c.pathname.startsWith(l)&&!c.pathname.startsWith(k))return a;return"localhost"===c.hostname&&(c.hostname="127.0.0.1"),c.toString()}catch{return a}}function w(a,b){let c=a=>JSON.stringify(a).replace(/</g,"\\u003c"),d="<script>"+e.replaceAll("__CWD__",c(b.cwd)).replaceAll("__WS_URL__",c(b.wsUrl??""))+"<\/script>",f=a.match(/<head[^>]*>/i);if(f&&void 0!==f.index){let b=f.index+f[0].length;return a.slice(0,b)+d+a.slice(b)}let g=a.match(/<html[^>]*>/i);if(g&&void 0!==g.index){let b=g.index+g[0].length;return a.slice(0,b)+d+a.slice(b)}return d+a}},65139:(a,b,c)=>{"use strict";c.d(b,{BV:()=>h,NR:()=>t,OO:()=>v,Yd:()=>y,kn:()=>i,oJ:()=>o});var d=c(48249),e=c(67484),f=c(44256),g=c(63565);let h="claude-opus-5",i="gpt-5.6-sol",j=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultracode",label:"Ultracode"},{id:"ultrathink",label:"Ultrathink"}],k=[{id:"claude-sonnet-5",label:"Claude Sonnet 5",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-opus-5",label:"Claude Opus 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-fable-5-1",label:"Claude Fable 5.1",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-fable-5",label:"Claude Fable 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-opus-4-8",label:"Claude Opus 4.8",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",fast:!0},{id:"claude-opus-4-7",label:"Claude Opus 4.7",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"xhigh",fast:!0},{id:"claude-opus-4-6",label:"Claude Opus 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",thinking:!0}],l=[{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultra",label:"Ultra"}],m=[{id:"gpt-6-astra",label:"GPT-6-Astra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"},{id:"gpt-5.6-sol",label:"GPT-5.6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-terra",label:"GPT-5.6-Terra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-luna",label:"GPT-5.6-Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"}];function n(a){return m.find(b=>b.id===a)?.defaultReasoning??"low"}function o(a,b){let c=m.find(b=>b.id===a)?.reasoning;return b&&(!c||c.includes(b))?b:n(a)}function p(a,b){return a.find(a=>a.id===b)?.label??b}function q(a){return k.find(b=>b.id===a)?.fast===!0}function r(a){return k.find(b=>b.id===a)?.thinking===!0}function s(a){let b=k.find(b=>b.id===a);return b?b.defaultEffort:"high"}function t(a,b){let c=k.find(b=>b.id===a),d=c?.effort;return b&&(!c||d?.includes(b))?b:s(a)}function u(a){let b=k.find(b=>b.id===a);return b?b.defaultContext:"200k"}function v(a,b){let c=k.find(b=>b.id===a),d=c?.context;return b&&(!c||d?.includes(b))?b:u(a)}function w({value:a,selected:b,label:c,defaultValue:e,onSelect:f}){return(0,d.jsxs)("button",{type:"button",onClick:()=>f(a),className:`flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition-colors ${b?g.yI:"text-muted-foreground hover:bg-hover hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"mt-0.5",children:(0,d.jsx)(g.hG,{selected:b})}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c}),(0,d.jsx)("span",{className:"shrink-0",children:e&&(0,d.jsx)("span",{className:"rounded bg-muted px-1.5 text-[10px] font-medium text-muted-foreground",children:"Default"})})]})}function x({title:a,selected:b,value:c,items:h,onSelect:i,icon:j,testId:k}){let l=(0,e.useRef)(null),m=(0,e.useRef)(null),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)({top:0,left:0}),r=(0,f.F2)();return(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(g.XY,{buttonRef:l,label:c,labelMaxWidth:"max-w-[180px]",title:`${a}: ${c}`,onClick:()=>{n||(()=>{let a=l.current?.getBoundingClientRect();if(!a)return;let b=r?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;q({top:a.bottom+4-d,left:a.left-c})})(),o(a=>!a)},icon:j,testId:k}),n&&(0,d.jsx)(f.ZL,{children:(0,d.jsxs)("div",{ref:m,className:`${g.ys} min-w-[190px]`,style:{top:p.top,left:p.left},children:[(0,d.jsx)("div",{className:"px-3 pb-1 text-[11px] font-medium text-muted-foreground",children:a}),(0,d.jsx)("div",{className:"flex flex-col",children:h.map(a=>(0,d.jsx)(w,{value:a.id,selected:b===a.id,label:a.label,defaultValue:a.defaultValue,onSelect:a=>{i(a),o(!1)}},a.id))})]})})]})}function y(a){let b,c,e=a.engine??"claude",f=a.claudeModel??h,w=s(f),y=(b=k.find(a=>a.id===f)?.effort)?b.map(a=>j.find(b=>b.id===a)??{id:a,label:a}):[],z=t(f,a.claudeEffort),A=u(f),B=k.find(a=>a.id===f)?.context??[],C=v(f,a.claudeContextWindow),D=a.claudeFastMode??!1,E=a.claudeThinking??!1,F=a.codexModel??i,G=n(F),H=(c=m.find(a=>a.id===F)?.reasoning)?c.map(a=>l.find(b=>b.id===a)??{id:a,label:a}):l,I=o(F,a.codexReasoningEffort);return"claude"!==e?(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(x,{title:"Model",selected:F,value:p(m,F),items:m.map(a=>({id:a.id,label:a.label,defaultValue:a.id===i})),onSelect:b=>{a.onCodexModelChange?.(b),a.onCodexReasoningEffortChange?.(n(b))},icon:(0,d.jsx)(g.eV,{engine:"codex"}),testId:"codex-model-picker"}),(0,d.jsx)(x,{title:"Reasoning",selected:I,value:p(l,I),items:H.map(a=>({...a,defaultValue:a.id===G})),onSelect:b=>a.onCodexReasoningEffortChange?.(b),testId:"codex-reasoning-picker"})]}):(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(x,{title:"Model",selected:f,value:p(k,f),items:k.map(a=>({id:a.id,label:a.label,defaultValue:a.id===h})),onSelect:b=>{a.onClaudeModelChange?.(b);let c=s(b),d=u(b);c&&a.onClaudeEffortChange?.(c),d&&a.onClaudeContextWindowChange?.(d),q(b)||a.onClaudeFastModeChange?.(!1),r(b)||a.onClaudeThinkingChange?.(!1)},icon:(0,d.jsx)(g.eV,{engine:"claude"}),testId:"claude-model-picker"}),z&&y.length>0&&(0,d.jsx)(x,{title:"Reasoning",selected:z,value:p(j,z),items:y.map(a=>({...a,defaultValue:a.id===w})),onSelect:b=>a.onClaudeEffortChange?.(b),testId:"claude-reasoning-picker"}),C&&B.length>0&&(0,d.jsx)(x,{title:"Context Window",selected:C,value:"1m"===C?"1M":"200K",items:B.map(a=>({id:a,label:"1m"===a?"1M":"200K",defaultValue:a===A})),onSelect:b=>a.onClaudeContextWindowChange?.(b),testId:"claude-context-picker"}),q(f)&&(0,d.jsx)(x,{title:"Fast Mode",selected:D?"on":"off",value:D?"Fast On":"Fast Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:b=>a.onClaudeFastModeChange?.("on"===b),testId:"claude-fast-mode-picker"}),r(f)&&(0,d.jsx)(x,{title:"Thinking",selected:E?"on":"off",value:E?"Thinking On":"Thinking Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:b=>a.onClaudeThinkingChange?.("on"===b),testId:"claude-thinking-picker"})]})}},65395:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>e});var d=c(77943);(0,d.registerClientReference)(function(){throw Error("Attempted to call reconcileStatusTabIds() from the server but reconcileStatusTabIds is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","reconcileStatusTabIds"),(0,d.registerClientReference)(function(){throw Error("Attempted to call repairPanes() from the server but repairPanes is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","repairPanes");let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,It:()=>s,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b,c)=>d.$mh({try:async()=>{let d=l(a),e=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b,baseMtime:c})});if(409===e.status){let a=await e.json();return{conflict:!0,content:a.content??"",mtime:a.mtime}}if(!e.ok)throw Error(`HTTP ${e.status}`);return{conflict:!1,mtime:(await e.json()).mtime}},catch:b=>new e.uV({message:`POST ${l(a)} failed`,cause:b})}),o=()=>f("/api/sessions/projects"),p=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),q=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),r=a=>g("/api/project-settings",a),s=()=>f("/api/pick-folder"),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},69424:(a,b,c)=>{"use strict";c.d(b,{$:()=>s});var d=c(48249),e=c(67484),f=c(44384),g=c(57063),h=c(7833),i=c(44256),j=c(74118),k=c(15273),l=c(46674),m=c(99941),n=c(44643),o=c(32026),p=c(11732),q=c(75513);function r(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function s({toolCalls:a,onClose:b}){let{t:c}=(0,f.Bd)(),t=(0,q.nH)(),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)({}),[A,B]=(0,e.useState)({});(0,g.E)(b);let C=a.reduce((a,b)=>{let{questions:c}=r(b);return a+c.length},0),D=Object.values(A).filter(Boolean).length,E=(0,e.useCallback)((a,b)=>{v(c=>({...c,[a]:b})),x(b=>({...b,[a]:!1}))},[]),F=(0,e.useCallback)(a=>{x(b=>{let c=!b[a];if(c){let b=y[a]||"";b&&v(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[y]),G=(0,e.useCallback)((a,b)=>{z(c=>({...c,[a]:b})),b&&v(c=>({...c,[a]:b}))},[]),H=(0,e.useCallback)(a=>{B(b=>({...b,[a]:!b[a]}))},[]),I=(0,e.useCallback)(()=>{let b=D>0,d=[];return a.forEach((a,e)=>{let{questions:f}=r(a);f.forEach((a,f)=>{let g=`${e}-${f}`;if(b&&!A[g])return;let h=u[g];d.push(`Q: ${a.question}`),d.push(`A: ${h||c("askQuestion.notSelected")}`),d.push("")})}),d.join("\n").trim()},[a,u,A,D,c]),J=(0,e.useCallback)(()=>{navigator.clipboard.writeText(I()),(0,h.oR)(D>0?c("toast.copiedQA",{count:D}):c("toast.copiedAllQA"))},[I,D,c]),K=(0,e.useCallback)(()=>{t?(t.sendMessage(I()),(0,h.oR)(c("toast.sentQA")),b()):(0,h.oR)(c("askQuestion.sendNoChat"))},[t,I,b,c]),L=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:C}),D>0&&` \xb7 ${c("askQuestion.checkedN",{count:D})}`]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:K,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:D>0?c("askQuestion.sendChecked",{count:D}):c("askQuestion.sendAll"),children:(0,d.jsx)(j.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:J,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:D>0?c("askQuestion.copyChecked",{count:D}):c("askQuestion.copyAll"),children:(0,d.jsx)(k.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,e)=>{let{questions:f}=r(b);return f.map((b,g)=>{let h=`${e}-${g}`,i=u[h],j=w[h]||!1,k=A[h]||!1;return(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("button",{onClick:()=>H(h),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-hover transition-colors",title:c("askQuestion.checkToCopy"),children:k?(0,d.jsx)(m.A,{className:"w-4 h-4 text-brand"}):(0,d.jsx)(n.A,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,d.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:b.header}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,d.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=i===a.label&&!j;return(0,d.jsxs)("button",{onClick:()=>E(h,a.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-hover ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,d.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,d.jsxs)("button",{onClick:()=>F(h),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${j?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:j?(0,d.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(p.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),j&&(0,d.jsx)("div",{className:"ml-6 mt-1",children:(0,d.jsx)("input",{type:"text",autoFocus:!0,value:y[h]||"",onChange:a=>G(h,a.target.value),placeholder:c("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"})})]}),(e!==a.length-1||g!==f.length-1)&&(0,d.jsx)("div",{className:"border-b border-border/50 mt-3"})]},h)})})})]})});return(0,d.jsx)(i.ZL,{children:L})}},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>ah});var e=c(48249),f=c(67484),g=c.n(f),h=c(74429),i=c(44256),j=c(33281),k=c(87808),l=c(25419),m=c(85655),n=c(21538),o=c(35208),p=c(74691),q=c(60333),r=c(7833),s=c(24724),t=c(20586),u=c(7122),v=c(55287),w=c(60591),x=c(19593),y=c(64825),z=c(66400),A=c(86588),B=c(64676),C=c(6478),D=c(34728),E=c(9804),F=c(73887),G=c(40893),H=c(92608),I=c(94239),J=c(29939),K=c(23860),L=c(7031),M=c(72899),N=c(25667),O=c(57014),P=c(46242),Q=c(21787),R=c(94308),S=c(53036),T=c(91975),U=c(6662),V=c(20291),W=c(58904),X=c(61632),Y=c(41357),Z=c(76855),$=c(4857),_=c(44384),aa=c(18921),ab=c(28797),ac=c(23881),ad=c(21672),ae=c(21482),af=c(94192),ag=a([n,N,o,F,v,O]);[n,N,o,F,v,O]=ag.then?(await ag)():ag;let ah=g().memo(function({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:g,searchQueryTrigger:ag,fileOpenRequest:ah}){let ai,aj,ak,al,am,an,{t:ao}=(0,_.Bd)(),ap=(0,L.r)(),aq=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.fileMessage",{path:a}))},[ap,ao]),ar=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.stagedFileMessage",{path:a}))},[ap,ao]),as=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.unstagedFileMessage",{path:a}))},[ap,ao]),at=(0,C.P)(),au=(0,D.U)(),{activeView:av,onViewChange:aw}=(0,af.R8)(),[ax,ay]=(0,f.useState)(c),[az,aA]=(0,f.useState)("code"),aB=(0,f.useRef)(null),aC=(0,f.useRef)(!1),[aD,aE]=(0,f.useState)(null),[aF,aG]=(0,f.useState)(null),[aH,aI]=(0,f.useState)(!1),aJ=(0,f.useRef)(1),aK=(0,f.useRef)(null),[aL,aM]=(0,f.useState)(null),aN=(0,f.useRef)(null),[aO,aP]=(0,f.useState)({isDirty:!1,isSaving:!1}),[aQ,aR]=(0,f.useState)(!1),[aS,aT]=(0,f.useState)(null),[aU,aV]=(0,f.useState)("compact"),[aW,aX]=(0,f.useState)("unified"),[aY,aZ]=(0,f.useState)("full"),[a$,a_]=(0,f.useState)("unified"),[a0,a1]=(0,f.useState)(320),a2=(0,f.useRef)(null),a3=(0,f.useCallback)(a=>{"mouse"===a.pointerType&&0===a.button&&(a.preventDefault(),a2.current={startX:a.clientX,startWidth:a0},a.currentTarget.setPointerCapture(a.pointerId))},[a0]),a4=(0,f.useCallback)(a=>{let b=a2.current;if(!b)return;let c=b.startWidth+(a.clientX-b.startX);a1(Math.min(480,Math.max(320,c)))},[]),a5=(0,f.useCallback)(a=>{a2.current&&(a2.current=null,a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId))},[]),a6=(0,f.useRef)(null),a7=(0,aa.o)(a6),a8=(0,f.useRef)(null),a9=(0,aa.o)(a8),ba=(0,Z.Sn)(b),bb=(0,Z.Xm)(b),bc=(0,Z.po)(b),bd=(0,$.Q)(),be=(0,K.F)(),bf=(0,U.W)({cwd:b});(0,Z.JL)(b,bf.selectedPath);let bg=(0,f.useMemo)(()=>{let a=bf.fileContent,b=bf.selectedPath;return a&&"text"===a.type&&"string"==typeof a.content&&b&&(0,w.Hz)(b)?(0,w.xb)(a.content,w.cG):null},[bf.fileContent,bf.selectedPath]),[bh,bi]=(0,f.useState)({version:0,collapsed:!1}),bj=(0,V.p)({cwd:b,onSearchComplete:()=>aR(!0)}),bk=(0,W.e)({cwd:b,addToRecentFiles:bf.addToRecentFiles}),bl=(0,f.useMemo)(()=>{let a=new Set;if(bk.status){for(let b of bk.status.staged)a.add(b.path);for(let b of bk.status.unstaged)a.add(b.path)}return a},[bk.status]),bm=(0,f.useMemo)(()=>{let a=new Map;if(bk.status){for(let b of bk.status.staged)a.set(b.path,"staged");for(let b of bk.status.unstaged)a.set(b.path,"unstaged")}return a},[bk.status]),bn=(0,X.y)({cwd:b,addToRecentFiles:bf.addToRecentFiles}),bo=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.compareFileMessage",{base:bn.compareBaseBranch,path:a}))},[ap,ao,bn.compareBaseBranch]),bp=(0,f.useRef)(!1),bq=(0,f.useCallback)(a=>{bf.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),bf.showEditor||(bp.current=!0,bf.setShowEditor(!0))},[bf]),br=(0,f.useCallback)(a=>{bf.setShowEditor(!0)},[bf]),bs=(0,f.useCallback)(async()=>{if(!bf.fileContent||"text"!==bf.fileContent.type||!bf.fileContent.content)return;let a=await j.t4.runPromiseExit((0,k.OJ)({cwd:b,path:bf.selectedPath,content:bf.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&bf.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,r.oR)(ao("toast.savedSuccess"),"success")}catch{(0,r.oR)(ao("toast.saveFailed"),"error")}},[b,bf]),bt=(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a=aJ.current,b=aK.current;a>0&&bf.updateRecentFilePosition(bf.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[bf]),bu=(0,f.useCallback)(async(a,b)=>{let c=a!==bf.selectedPath;if(c&&bf.showEditor){if(aO.isDirty&&(!await (0,r.lJ)(ao("fileBrowser.saveBeforeSwitch"),{confirmText:ao("fileBrowser.saveAndSwitch"),cancelText:ao("common.cancel")})||(await aN.current?.save(),aN.current?.isDirty)))return;bf.setShowEditor(!1)}c&&bt(),bf.handleSelectFile(a,b)},[bf,bt,aO.isDirty,ao]),bv=(0,f.useMemo)(()=>{let a=bj.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,E.v3)(c),e=new Set((0,E.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[bj.contentSearchResults]),[bw,bx]=(0,f.useState)(new Set),by=(0,f.useCallback)(a=>{bx(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),bz=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=bv.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[bv.matchMap]),bA=aQ&&bj.contentSearchResults.length>0,[bB,bC]=(0,f.useState)("selected"),bD=!!bf.selectedPath&&null!==(0,ab.c)(bf.selectedPath),[bE,bF]=(0,f.useState)(!1),bG=(0,f.useCallback)(async(a,c)=>{if(!bf.selectedPath||!bD)return;let d=await ba.goToDefinition(bf.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),g===bf.selectedPath?bf.setTargetLineNumber(e.line):bu(g,e.line)},[bf,b,bD,ba,bd]),bH=(0,f.useCallback)((a,b,c,d,e)=>{a&&null!==(0,ab.c)(a)&&(bF(b),bb.onTokenMouseEnter(a,c,d,e))},[bb]),bI=(0,f.useCallback)((a,b,c)=>{bD&&bH(bf.selectedPath,!1,a,b,c)},[bf.selectedPath,bD,bH]),bJ=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;bf.selectedPath&&bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),d===bf.selectedPath?bf.setTargetLineNumber(a.line):bu(d,a.line)},[bf,b,bd]),bK=(0,f.useMemo)(()=>{if(!bk.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":case"untracked":return"A";case"deleted":return"D";case"renamed":return"R"}};for(let c of bk.status.staged)a.set(c.path,b(c.status));for(let c of bk.status.unstaged)a.set(c.path,b(c.status));return a},[bk.status]),bL=(0,f.useMemo)(()=>{if(!bk.status)return null;let a=new Map;for(let b of bk.status.staged)"renamed"===b.status&&b.oldPath&&a.set(b.path,b.oldPath);return a},[bk.status]),bM=(0,f.useCallback)(a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},[bj.setContentSearchQuery,bj.performContentSearch]),bN=(0,Y.H)({cwd:b,selectedPath:bf.selectedPath,gitStatusMap:bK,renameOldPaths:bL,isText:bf.fileContent?.type==="text",refreshKey:bf.fileContent?.mtime}),bO="tree"===ax&&bN.showDiff,bP=(0,f.useCallback)(a=>{ay(a),bf.setBlameSelectedCommit(null),"history"===a&&bn.selectedBranch&&bn.loadCommits(bn.selectedBranch)},[bf,bn.selectedBranch,bn.loadCommits]);(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a={filePath:bf.selectedPath,lineNumber:aJ.current},b=bd.goBack(a);b&&(b.filePath===bf.selectedPath?bf.setTargetLineNumber(b.lineNumber):bu(b.filePath,b.lineNumber))},[bf,bd]),(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a={filePath:bf.selectedPath,lineNumber:aJ.current},b=bd.goForward(a);b&&(b.filePath===bf.selectedPath?bf.setTargetLineNumber(b.lineNumber):bu(b.filePath,b.lineNumber))},[bf,bd]);let bQ=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await j.t4.runPromiseExit((0,k.__)({cwd:b,path:a}));"Success"===d._tag?(0,r.oR)(ao("toast.copiedName",{name:c}),"success"):(0,r.oR)(ao("toast.copyFailed"),"error")},[b,ao]),bR=(0,f.useCallback)(async a=>{let c=await j.t4.runPromiseExit((0,k.dt)());if("Success"!==c._tag||!c.value.path)return void(0,r.oR)(ao("toast.noFileToPaste"),"info");let d=c.value.path,e=await j.t4.runPromiseExit((0,k.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,r.oR)(ao("toast.pastedFile",{name:e.value.newName}),"success"),bf.loadDirectory(a),bf.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:ao("toast.pasteFailed");(0,r.oR)(c,"error")}},[b,bf,ao]);(0,f.useRef)(0),(0,f.useRef)(be),(0,f.useRef)(ax),(0,f.useRef)(!1);let bS=(0,f.useRef)(bn.selectedBranch);bS.current=bn.selectedBranch;let bT=(0,f.useRef)(bf.selectedPath);bT.current=bf.selectedPath;let bU=(0,f.useRef)(bf.fileContent?.type);bU.current=bf.fileContent?.type;let bV=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!Array.isArray(c))return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(j.t4.runPromise((0,k.mP)(b)).then(a=>{a.error||bf.setFiles(b=>(0,E.HR)(a.files??[],b))}).catch(()=>{})),f.push(j.t4.runPromise((0,k.DZ)(b)).then(a=>{a.paths&&bf.setFileIndex(a.paths)}).catch(()=>{})),f.push(j.t4.runPromise((0,k.r9)(b)).then(a=>{bf.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(j.t4.runPromise((0,m.lv)(b)).then(a=>{bk.setStatus(a);let b=(0,t.Do)(a.staged),c=(0,t.Do)(a.unstaged);bk.setStagedTree(b),bk.setUnstagedTree(c)}).catch(()=>{})),bk.refreshDiff(),d&&bn.loadBranches();let a=bS.current;a&&f.push(j.t4.runPromise((0,m.Bj)(b,a,E.B_)).then(a=>{let b=a.commits??[];bn.setCommits(b),bn.setHasMoreCommits(b.length>=E.B_)}).catch(()=>{}))}let g=bT.current,h=bU.current;g&&"text"===h&&f.push(j.t4.runPromise((0,l.K)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&bf.setFileContent({type:"text",content:b.content,size:b.size,mtime:b.mtimeMs,...b.isSymlink?{isSymlink:!0,symlinkTarget:b.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,J.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:bV,enabled:be});let bW=(0,f.useCallback)(a=>{bu(a),bf.setShouldScrollToSelected(!0),ay("tree")},[bf,bu]);(0,f.useRef)(bu),(0,f.useRef)(null);let{setPreviewMarkdown:bX,setShouldScrollToSelected:bY}=bf,bZ=(0,f.useCallback)(({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,r.oR)(ao("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bW(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),[b,bW,ao]),b$=(0,f.useCallback)(({focalFile:a})=>"tree"===ax&&bN.canDiff&&a===bf.selectedPath?(0,e.jsxs)(e.Fragment,{children:[bN.showDiff&&(0,e.jsx)(p.y,{value:aY,onChange:aZ}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bN.showDiff?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,title:bN.showDiff?ao("fileBrowser.exitDiff"):ao("fileBrowser.viewDiff"),children:ao("common.diff")})]}):null,[ax,bN.canDiff,bN.showDiff,bN.toggleDiff,bf.selectedPath,aY,ao]),[b_,b0]=(0,f.useState)(null),b1=(0,f.useCallback)((a,b)=>{bf.setPreviewMarkdown(!0),bW(a),b0(b),b&&setTimeout(()=>b0(null),400)},[bf,bW]);return(0,e.jsxs)(u.SU,{container:aD,children:[(0,e.jsxs)("div",{ref:aB,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 flex flex-col overflow-hidden",style:{width:a0},children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>bP("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>bP("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>bP("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>bP("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>bP("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.historyTab")})]}),"tree"===ax&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:bf.searchInputRef,type:"text",value:bf.searchQuery,onChange:a=>bf.setSearchQuery(a.target.value),placeholder:ao("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),bf.searchQuery&&(0,e.jsx)("button",{onClick:()=>{bf.setSearchQuery(""),bf.searchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:ao("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>bf.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${bf.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:bf.searchExactMatch?ao("fileBrowser.exactMatchOn"):ao("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>bf.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:()=>bf.searchTreeExpandedPaths?bf.setSearchTreeExpandedPaths(new Set):bf.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===ax&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:bj.contentSearchInputRef,type:"text",value:bj.contentSearchQuery,onChange:a=>bj.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bj.performContentSearch(bj.contentSearchQuery)},placeholder:ao("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),bj.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>{bj.setContentSearchQuery(""),bj.contentSearchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:ao("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>bj.performContentSearch(bj.contentSearchQuery),disabled:bj.isSearching||!bj.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:bj.isSearching?"...":ao("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bj.searchOptions.caseSensitive,onChange:a=>bj.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bj.searchOptions.wholeWord,onChange:a=>bj.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bj.searchOptions.regex,onChange:a=>bj.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:bj.searchOptions.fileType,onChange:a=>bj.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:ao("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground"})]})]}),"history"===ax&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:bn.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:bn.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>bn.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:ao("fileBrowser.compareModeOff"),children:ao("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(R.e,{branches:bn.branches,selectedBranch:bn.compareBaseBranch,onSelect:a=>{bn.setCompareBaseBranch(a),bn.loadCompareFiles(a)},isLoading:bn.isLoadingBranches,pinnedBranches:["origin/main",...bn.upstreamBranch&&"origin/main"!==bn.upstreamBranch?[bn.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(R.e,{branches:bn.branches,selectedBranch:bn.selectedBranch,onSelect:a=>{bn.setSelectedBranch(a)},isLoading:bn.isLoadingBranches,pinnedBranches:["origin/main",...bn.upstreamBranch&&"origin/main"!==bn.upstreamBranch?[bn.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>bn.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-hover border border-border",title:ao("fileBrowser.compareModeOn"),children:ao("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===ax?"":"hidden"}`,children:[bf.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:bf.creatingItem.parentPath?ao("fileBrowser.createFileIn",{path:bf.creatingItem.parentPath}):ao("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:ao("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{aC.current=!0},onCompositionEnd:()=>{aC.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(aC.current)return;let c=a.target.value.trim();if(!c)return;let d=bf.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await j.t4.runPromiseExit((0,k.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,r.oR)(ao("toast.createdFile",{name:c}),"success"),bf.setCreatingItem(null),bf.loadDirectory(d),bf.loadFileIndex(),d&&bf.setExpandedPaths(a=>new Set([...a,d])),bu(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,r.oR)(a||ao("toast.createFailed"),"error")}else(0,r.oR)(ao("toast.createFailed"),"error")}else"Escape"===a.key&&bf.setCreatingItem(null)},onBlur:()=>bf.setCreatingItem(null)})]}),bf.isLoadingFiles&&0===bf.files.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("common.loading")}):bf.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bf.fileError}):(0,e.jsx)(s.h,{files:bf.files,selectedPath:bf.selectedPath,expandedPaths:bf.effectiveExpandedPaths,matchedPaths:bf.matchedPaths,gitStatusMap:bK,loadingDirs:bf.loadingDirs,onSelect:a=>{bf.setShouldScrollToSelected(!1),bu(a)},onToggle:bf.handleToggle,cwd:b,shouldScrollToSelected:bf.shouldScrollToSelected,onScrolledToSelected:()=>bf.setShouldScrollToSelected(!1),onCreateFile:a=>bf.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>aG({path:a,isDirectory:b,name:c}),onRefresh:()=>bf.loadFiles(),onCopyFile:bQ,onPaste:bR,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===ax?"":"hidden"}`,children:bj.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bj.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bj.searchError}):0===bj.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:bj.contentSearchQuery?ao("fileBrowser.noContentSearchResults"):ao("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[bj.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b border-border flex-shrink-0",children:[ao("fileBrowser.nFilesNMatches",{files:bj.searchStats.totalFiles,matches:bj.searchStats.totalMatches}),bj.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",ao("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(s.h,{files:bv.files,selectedPath:bf.selectedPath,expandedPaths:bw,onSelect:a=>{let b=bv.matchMap.get(a);bu(a,b?.matches[0]?.lineNumber),aQ||aR(!0)},onToggle:by,cwd:b,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading,renderActions:bz,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===ax?"":"hidden"}`,children:0===bf.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noRecentFiles")}):(0,e.jsx)(s.h,{files:bf.recentFilesTree,selectedPath:bf.selectedPath,expandedPaths:bf.recentTreeDirPaths,onSelect:bu,onToggle:E.tE,cwd:b,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===ax?"":"hidden"}`,children:bk.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bk.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:bk.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:ao("fileBrowser.stagingArea",{count:bk.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>bk.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]}),(bk.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:bk.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:ao("fileBrowser.unstageAll")})]}),(0,e.jsx)(t.VO,{files:bk.stagedTree,selectedPath:bk.statusSelectedFile?.type==="staged"?bk.statusSelectedFile.file.path:null,expandedPaths:bk.stagedExpandedPaths,onSelect:a=>a.file&&bk.handleStatusFileSelect(a.file,"staged"),onToggle:bk.handleStagedToggle,cwd:b,emptyMessage:ao("fileBrowser.noStagedFiles"),className:"py-1",onExplain:ap?ar:void 0,explainDisabled:ap?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,t.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bk.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:ao("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bk.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:ao("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:ao("fileBrowser.workspace",{count:bk.status?.unstaged.length||0})}),(bk.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bk.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:ao("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:bk.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:ao("fileBrowser.stageAll")})]})]}),(0,e.jsx)(t.VO,{files:bk.unstagedTree,selectedPath:bk.statusSelectedFile?.type==="unstaged"?bk.statusSelectedFile.file.path:null,expandedPaths:bk.unstagedExpandedPaths,onSelect:a=>a.file&&bk.handleStatusFileSelect(a.file,"unstaged"),onToggle:bk.handleUnstagedToggle,cwd:b,emptyMessage:ao("fileBrowser.noUnstagedChanges"),className:"py-1",onExplain:ap?as:void 0,explainDisabled:ap?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,t.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bk.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:ao("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bk.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:ao("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bk.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:ao("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bk.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:ao("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===ax?"":"hidden"}`,children:bn.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:bn.historyError})]})}):bn.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:bn.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingDiff")}):0===bn.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:ao("fileBrowser.nFilesChanged",{count:bn.compareFiles.length,branch:bn.compareBaseBranch})})}),(0,e.jsx)(t.VO,{files:bn.compareFileTree,expandedPaths:bn.compareExpandedPaths,onToggle:bn.handleCompareToggle,selectedPath:bn.compareSelectedFile?.path||null,onSelect:a=>{a.file&&bn.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0,onExplain:ap?bo:void 0,explainDisabled:ap?.isLoading})]})}):(0,e.jsx)("div",{ref:bn.commitListRef,className:"flex-1 overflow-y-auto",onScroll:bn.handleCommitListScroll,children:bn.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingCommits")}):0===bn.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[bn.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>bn.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${bn.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-foreground-subtle","data-tooltip":a.date,children:[a.relativeDate," \xb7 ",(0,E.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),bn.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!bn.hasMoreCommits&&bn.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-foreground-subtle",children:ao("fileBrowser.allLoaded",{count:bn.commits.length})})]})})})]})]}),(0,e.jsx)("div",{onPointerDown:a3,onPointerMove:a4,onPointerUp:a5,onPointerCancel:a5,className:"w-[5px] flex-shrink-0 relative cursor-col-resize group",children:(0,e.jsx)("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover:bg-brand transition-colors"})}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===ax||"search"===ax||"recent"===ax)&&(bf.blameSelectedCommit?(0,e.jsx)(n.n,{isOpen:!0,onClose:()=>bf.setBlameSelectedCommit(null),commit:bf.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:bf.selectedPath||void 0,onLocateInTree:bW,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):"map"===az?bO&&bN.diff?(0,e.jsx)(N.r,{cwd:b,filePath:bN.diff.filePath,oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,isNew:bN.diff.isNew,isDeleted:bN.diff.isDeleted,changedFiles:bl,fileGitStatusMap:bm,compact:"compact"===aY,enableComments:!0,onSwitchToCode:()=>aA("code"),onContentSearch:bM,headerExtraLeft:bZ,headerExtraRight:b$}):(0,e.jsx)(M.O,{cwd:b,highlightedFilePath:bf.selectedPath,changedFiles:bl,onSwitchToCode:()=>aA("code"),enableComments:!0,onContentSearch:bM,headerExtraLeft:bZ,headerExtraRight:b$}):bf.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:bf.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${bf.selectedPath}`),(0,r.oR)(ao("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bW(bf.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:bf.showEditor?(0,e.jsxs)(e.Fragment,{children:[aO.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:ao("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>aN.current?.save(),disabled:!aO.isDirty||aO.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aO.isDirty&&!aO.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:aO.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):ao("common.save")}),(0,e.jsx)("button",{onClick:()=>aN.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.closeEdit"),children:ao("fileBrowser.closeBtn")})]}):bO?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.y,{value:aY,onChange:aZ}),(0,e.jsx)(q.q,{value:a$,onChange:a_}),!(0,w.e$)(bf.selectedPath)&&!(0,w.aR)(bf.selectedPath)&&!(0,w.Hz)(bf.selectedPath)&&!(0,w.Zy)(bf.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("blockViewer.viewerToggle.toBlock"),children:ao("common.codeMap")}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors bg-brand text-white",children:ao("fileBrowser.exitDiff")})]}):(0,e.jsxs)(e.Fragment,{children:["tree"===ax&&bN.canDiff&&(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.viewDiff"),children:ao("common.diff")}),bf.fileContent?.type==="text"&&(0,w.e$)(bf.selectedPath)&&(0,e.jsx)(H.ShareReviewToggle,{content:bf.fileContent.content||"",sourceFile:bf.selectedPath&&b&&bf.selectedPath.startsWith(b)?bf.selectedPath.slice(b.endsWith("/")?b.length:b.length+1):bf.selectedPath||""}),bf.fileContent?.type==="text"&&(0,w.Hz)(bf.selectedPath)&&bf.previewMarkdown&&!bf.showBlame&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:[!0,!1].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bi(b=>({version:b.version+1,collapsed:a}))},className:`px-2 py-0.5 text-xs transition-colors ${bh.collapsed===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:ao(a?"fileBrowser.collapseAllJson":"fileBrowser.expandAllJson")},String(a)))}),bf.fileContent?.type==="text"&&((0,w.e$)(bf.selectedPath)||(0,w.aR)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))&&(aj=(ai=(0,w.aR)(bf.selectedPath))?bf.previewHtml:bf.previewMarkdown,(0,e.jsx)("button",{onClick:()=>ai?bf.setPreviewHtml(a=>!a):bf.setPreviewMarkdown(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aj?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:aj?ao("fileBrowser.exitPreview"):ao("common.preview")})),bf.fileContent?.type==="text"&&(0,w.C_)(bf.selectedPath||"")&&(al=(ak=bf.selectedPath||"").startsWith("/")?ak:b?`${b.replace(/\/$/,"")}/${ak}`:ak,(0,e.jsx)("button",{onClick:()=>au(al),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("skills.addTooltip"),children:(0,e.jsx)(y.A,{className:"w-3.5 h-3.5"})})),bf.fileContent?.type==="text"&&(0,w.aR)(bf.selectedPath)&&(an=(am=bf.selectedPath||"").startsWith("/")?am:b?`${b.replace(/\/$/,"")}/${am}`:am,(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>at(an),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("htmlApps.addTooltip"),children:(0,e.jsx)(y.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:an}})),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("common.openInConsole"),children:(0,e.jsx)(z.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>{let a=(0,B.Xe)(an);window.open((0,B.PB)(a,window.location.origin),"_blank")},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("browser.openInNewWindow"),children:(0,e.jsx)(A.A,{className:"w-3.5 h-3.5"})})]})),bf.fileContent?.type==="text"&&!(bf.previewMarkdown&&((0,w.e$)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))||bf.previewHtml&&(0,w.aR)(bf.selectedPath))&&(0,e.jsx)("button",{onClick:bf.handleToggleBlame,disabled:bf.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bf.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-hover"} disabled:opacity-50`,title:ao("fileBrowser.viewBlame"),children:bf.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),bf.fileContent?.type==="text"&&!(bf.previewMarkdown&&((0,w.e$)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))||bf.previewHtml&&(0,w.aR)(bf.selectedPath))&&(0,e.jsx)("button",{onClick:()=>bf.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.editFile"),children:ao("common.edit")}),bf.fileContent?.type==="text"&&bf.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(bf.fileContent.content),(0,r.oR)(ao("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.copyFileContent"),children:ao("common.copy")}),bf.fileContent?.type==="text"&&!(0,w.e$)(bf.selectedPath)&&!(0,w.aR)(bf.selectedPath)&&!(0,w.Hz)(bf.selectedPath)&&!(0,w.Zy)(bf.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("blockViewer.viewerToggle.toBlock"),children:ao("common.codeMap")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:bf.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bf.fileContent?"text"===bf.fileContent.type&&"string"==typeof bf.fileContent.content?bO?bN.isLoadingDiff&&!bN.diff?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bN.diff?"unified"===a$?(0,e.jsx)(o.xU,{oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,filePath:bN.diff.filePath,cwd:b,enableComments:!0,compact:"compact"===aY,onContentSearch:bM,onTokenHover:(a,b,c)=>bH(bN.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.clearHover}):(0,e.jsx)(o.xZ,{oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,filePath:bN.diff.filePath,isNew:bN.diff.isNew,isDeleted:bN.diff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===aY,onContentSearch:bM,onTokenHover:(a,b,c)=>bH(bN.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.clearHover}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{children:ao("fileBrowser.diffLoadFailed")}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"mt-2 text-brand hover:underline text-sm",children:ao("fileBrowser.exitDiff")})]})}):bf.showBlame&&bf.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:bf.blameError}),(0,e.jsx)("button",{onClick:()=>bf.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:ao("fileBrowser.backToPreview")})]})}):bf.showBlame&&0===bf.blameLines.length&&bf.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bf.previewMarkdown&&(0,w.Hz)(bf.selectedPath)&&!bf.showBlame?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-background text-foreground",children:[(0,e.jsx)(aa._,{search:a7}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:a6,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,e.jsx)(w.d9.Provider,{value:bh,children:bg})})})]}):bf.previewMarkdown&&(0,w.Zy)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)(x.C0,{content:bf.fileContent.content,filePath:bf.selectedPath,className:"h-full"}):bf.previewMarkdown&&(0,w.e$)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(F.M,{content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,embedded:!0,onLocalMdLink:b1,scrollToAnchor:b_})}):bf.previewHtml&&(0,w.aR)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)(G.O,{content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)(v.Cv,{ref:aN,content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,enableComments:!0,scrollToLine:aL??bf.targetLineNumber,scrollToLineAlign:null!=aL?"start":bf.targetScrollAlign,onScrollToLineComplete:()=>{aM(null),bf.setTargetLineNumber(null)},highlightKeyword:"search"===ax?bj.contentSearchQuery:null,visibleLineRef:aJ,viStateRef:aK,initialCursorLine:bf.initialCursorLine,initialCursorCol:bf.initialCursorCol,onInitialCursorSet:()=>{bf.setInitialCursorLine(null),bf.setInitialCursorCol(null)},onCmdClick:bD?bG:void 0,onTokenHover:bD?bI:void 0,onTokenHoverLeave:bD?bb.onTokenMouseLeave:void 0,onTokenHoverCancel:bD?bb.clearHover:void 0,blameLines:bf.showBlame&&bf.blameLines.length>0?bf.blameLines:void 0,inlineBlameLines:bf.blameLines.length>0?bf.blameLines:void 0,onSelectCommit:bf.setBlameSelectedCommit,editable:bf.showEditor,initialMtime:bf.fileContent.mtime,onEditorClose:a=>{bf.setShowEditor(!1),aM(a)},onSaved:()=>{let a=aJ.current??1;bf.loadFileContent(bf.selectedPath),bf.setShowEditor(!1),aM(a)},onEditorStateChange:aP,viMode:!0,onContentMutate:bq,onEnterInsertMode:br,onViSave:bs,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):"image"===bf.fileContent.type&&bf.selectedPath?(0,e.jsx)(S.I,{cwd:b,path:bf.selectedPath,refreshKey:bf.fileContent.mtime,alt:bf.selectedPath}):"pdf"===bf.fileContent.type&&bf.selectedPath?(0,e.jsx)(T.t,{cwd:b,path:bf.selectedPath,refreshKey:bf.fileContent.mtime}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,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,e.jsx)("p",{children:bf.fileContent.message||ao("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:ao("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:ao("fileBrowser.selectFileToPreview")})]})})),"status"===ax&&(bk.statusSelectedFile&&bk.statusDiff?(0,e.jsx)(O.m,{cwd:b,selected:bk.statusSelectedFile,diff:bk.statusDiff,showMarkdownPreview:bk.showStatusDiffPreview,setShowMarkdownPreview:bk.setShowStatusDiffPreview,changedFiles:bl,fileGitStatusMap:bm,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},locateInTree:bW,jsonPreview:aS,setJsonPreview:aT,jsonPreviewSearch:a9,jsonPreviewPreRef:a8,onTokenHover:(a,b,c)=>bH(bk.statusDiff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.clearHover}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:ao("fileBrowser.selectFileToViewDiff")})})),"history"===ax&&!bn.historyError&&(bn.compareMode?bn.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingDiffContent")}):bn.compareFileDiff?(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border flex-shrink-0",children:[(0,e.jsx)(Q.d,{cwd:b,filePath:bn.compareFileDiff.filePath,onLocateInTree:bW}),!(0,E.u)(bn.compareFileDiff.filePath)&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(p.y,{value:aU,onChange:aV}),(0,e.jsx)(q.q,{value:aW,onChange:aX})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,E.u)(bn.compareFileDiff.filePath)?(0,e.jsx)(P.M,{cwd:b,filePath:bn.compareFileDiff.filePath,oldRev:bn.compareFileDiff.oldRev??(bn.compareFileDiff.isNew?null:bn.compareBaseBranch),newRev:bn.compareFileDiff.newRev??(bn.compareFileDiff.isDeleted?null:"HEAD")}):"unified"===aW?(0,e.jsx)(o.xU,{oldContent:bn.compareFileDiff.oldContent,newContent:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath,cwd:b,enableComments:!0,compact:"compact"===aU,onPreview:!bn.compareFileDiff.isDeleted&&bn.compareFileDiff.filePath.endsWith(".json")?()=>aT({content:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath}):void 0,previewLabel:ao("common.readable"),onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)(o.xZ,{oldContent:bn.compareFileDiff.oldContent,newContent:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath,isNew:bn.compareFileDiff.isNew,isDeleted:bn.compareFileDiff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===aU,onPreview:!bn.compareFileDiff.isDeleted&&bn.compareFileDiff.filePath.endsWith(".json")?()=>aT({content:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath}):void 0,previewLabel:ao("common.readable"),onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:bn.compareFiles.length>0?ao("fileBrowser.selectFileToViewDiff"):ao("fileBrowser.clickCompareToLoad")})}):bn.selectedCommit?(0,e.jsx)(n.n,{isOpen:!0,onClose:()=>bn.setSelectedCommit(null),commit:bn.selectedCommit,cwd:b,embedded:!0,onLocateInTree:bW,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:ao("fileBrowser.selectCommitToView")})}))]})]}),aH&&(0,e.jsx)(I.c,{files:bf.files,fileIndex:bf.fileIndex,recentFiles:bf.recentFilePaths,onSelectFile:a=>{bu(a),bf.setShouldScrollToSelected(!0),ay("tree")},onClose:()=>aI(!1)}),(bA||bc.visible)&&(0,e.jsxs)("div",{className:`flex ${bc.visible&&bA?"":"flex-col"}`,children:[bA&&(0,e.jsx)("div",{className:bc.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(ae.D,{results:bj.contentSearchResults,loading:bj.isSearching,totalMatches:bj.searchStats?.totalMatches??0,onSelect:(a,b)=>{bf.selectedPath&&bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),aA("code"),bu(a,b)},onClose:()=>aR(!1),scope:bB,onScopeChange:bC,selectedPath:bf.selectedPath})}),bc.visible&&(0,e.jsx)("div",{className:bA?"flex-1 min-w-0":"",children:(0,e.jsx)(ad.D,{references:bc.references,loading:bc.loading,onSelect:bJ,onClose:bc.closeReferences})})]})]}),aF&&(0,e.jsx)(i.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim",onClick:()=>aG(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:ao("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:ao("fileBrowser.confirmDeleteMessage",{name:aF.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>aG(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-hover transition-colors",children:ao("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=aF;aG(null);let d=await j.t4.runPromiseExit((0,k.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,r.oR)(ao("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";bf.loadDirectory(b),bf.loadFileIndex(),bf.selectedPath===a&&bu("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:ao("toast.deleteFailed");(0,r.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:ao("common.delete")})]})]})})}),bb.hoverInfo&&aD&&(0,h.createPortal)((0,e.jsx)(ac.s,{ref:bb.setTooltipEl,displayString:bb.hoverInfo.displayString,documentation:bb.hoverInfo.documentation,x:bb.hoverInfo.x,y:bb.hoverInfo.y,container:aD,onMouseEnter:bb.onCardMouseEnter,onMouseLeave:bb.onCardMouseLeave,onFindReferences:bE?void 0:()=>{let{filePath:a,line:b,column:c}=bb.hoverInfo;bb.clearHover(),bc.findReferences(a,b,c)},onSearch:a=>{bb.clearHover(),ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},onExplain:ap?a=>{let{filePath:b,line:c}=bb.hoverInfo;bb.clearHover(),ap.sendMessage(ao("explain.symbolMessage",{name:a,path:b,lines:String(c)}))}:void 0,explainDisabled:ap?.isLoading}),aD)]})});d()}catch(a){d(a)}})},70440:(a,b,c)=>{"use strict";function d(){return[{type:"image/x-icon",sizes:"16x16",url:"/favicon.ico?a49a3c8f7b751288"}]}c.r(b),c.d(b,{default:()=>d})},70596:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:h,onClose:i,onUpdateComment:j,onDeleteComment:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(c.content),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=async()=>{o.trim()&&(await j(c.id,o.trim()),n(!1))},u=async()=>{await k(c.id),i()};return(0,d.jsx)("div",{ref:q,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:r.x,top:r.y},children:(0,d.jsx)("div",{className:"p-3",children:m?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),t()),"Escape"===a.key&&(n(!1),p(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{n(!1),p(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:l("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:l("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>n(!0),className:"p-1 rounded hover:bg-hover text-muted-foreground",title:l("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{onClick:u,className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-red-9",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})})})}},71192:(a,b,c)=>{"use strict";c.d(b,{m_:()=>f,uV:()=>e});var d=c(81218);class e extends d.rN("AppError"){}d.rN("DBError"),d.rN("WSError"),d.rN("FSError"),d.rN("AgentError"),d.rN("ValidationError");class f extends d.rN("NotFoundError"){}d.rN("PermissionError")},71697:(a,b,c)=>{"use strict";c.d(b,{V:()=>j,n:()=>i});var d=c(48249),e=c(67484),f=c(44384);c(59336);var g=c(33281),h=c(41224);function i({value:a,onChange:b,textareaRef:c,extraCommands:d}){let[f,j]=(0,e.useState)(a.length),[k,l]=(0,e.useState)([]),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(0),[q,r]=(0,e.useState)(()=>a.length>0),s=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a=await g.t4.runPromiseExit((0,h.l1)());if("Success"===a._tag){let b=a.value.skills??a.value;n((Array.isArray(b)?b:[]).filter(a=>a.valid&&!!a.name).map(a=>({name:`/${a.name}`,description:a.description||"",source:"skill",skillPath:a.path,argumentHint:a.argumentHint})))}else console.error("Failed to load skills:",a.cause)},[]);let t=(0,e.useMemo)(()=>{let b=0===f?0:a.lastIndexOf("\n",f-1)+1,c=a.indexOf("\n",f),d=-1===c?a.length:c;return{text:a.slice(b,d),start:b,end:d}},[a,f]),u=(0,e.useMemo)(()=>{let a=t.text.match(/^\s*([/@])([a-zA-Z0-9-]*)$/);return a?{marker:a[1],verb:a[2].toLowerCase()}:null},[t.text]),v=(0,e.useMemo)(()=>{if(!u)return[];let{verb:a}=u,b=b=>b.name.slice(1).toLowerCase().startsWith(a);return[...(d??[]).filter(b),...k.filter(b),...m.filter(b)]},[u,d,k,m]),w=!q&&!!u&&v.length>0;(0,e.useRef)(a);let x=(0,e.useCallback)(a=>{j(a.selectionStart??0)},[]),y=(0,e.useCallback)(d=>{let e=u?.marker??"/",f=`${e}${d.name.slice(1)} `,g=a.slice(0,t.start),h=a.slice(t.end),i=g.length+f.length;b(g+f+h),j(i),requestAnimationFrame(()=>{let a=c.current;a&&(a.focus(),a.setSelectionRange(i,i))})},[a,t,u,b,c]),z=(0,e.useCallback)(a=>{if(a.nativeEvent.isComposing||!w||0===v.length)return!1;let b=()=>{a.preventDefault(),a.stopPropagation()};return"ArrowDown"===a.key?(b(),p(a=>(a+1)%v.length),!0):"ArrowUp"===a.key?(b(),p(a=>(a-1+v.length)%v.length),!0):"Enter"===a.key||"Tab"===a.key?(b(),y(v[o]),!0):"Escape"===a.key&&(b(),r(!0),!0)},[w,v,o,y]);return{isOpen:w,items:v,selectedIndex:o,marker:u?.marker??"/",listRef:s,selectCommand:y,handleKeyDown:z,trackCaret:x}}function j({ac:a,className:b=""}){let{t:c}=(0,f.Bd)(),{isOpen:e,items:g,selectedIndex:h,marker:i,listRef:k,selectCommand:l}=a;return e&&0!==g.length?(0,d.jsx)("div",{ref:k,className:`overflow-y-auto bg-card border border-border rounded-lg shadow-lv2 ${b}`,children:g.map((a,b)=>{let e=b>0?g[b-1]:null,f="skill"===a.source&&(!e||"skill"!==e.source),j="skill"!==a.source&&0===b;return(0,d.jsxs)("div",{children:[j&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),f&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),(0,d.jsxs)("div",{onClick:()=>l(a),className:`px-4 py-2 cursor-pointer ${b===h?"bg-brand/10":"hover:bg-hover"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:i+a.name.slice(1)}),(0,d.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:"builtin"===a.source?c(`commands.${a.name.slice(1)}`,{defaultValue:a.description}):a.description}),(0,d.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return c("common.builtin");case"skill":return"Skill"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,d.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}):null}},72399:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectSidebar.tsx","ProjectSidebar")},72529:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(48249),e=c(67484);function f({content:a,children:b,className:c}){if(c)return(0,d.jsx)("div",{"data-tooltip":a,className:c,children:b});let g=e.Children.toArray(b);if(1===g.length&&(0,e.isValidElement)(g[0])){let b=g[0];return(0,e.cloneElement)(b,{"data-tooltip":a})}return(0,d.jsx)("div",{"data-tooltip":a,style:{display:"contents"},children:b})}},72899:(a,b,c)=>{"use strict";c.d(b,{O:()=>ab});var d=c(48249),e=c(67484),f=c(44384),g=c(10316),h=c(46674),i=c(80600),j=c(69924);c(33281),c(85655),c(87808);var k=c(33982),l=c(34622),m=c(34948),n=c(26875),o=c(87148),p=c(82633);function q({kind:a,qname:b,className:c}){let e=`${(function(a,b){if("__file__"===b||"__preamble__"===b||b&&b.startsWith("__heading_"))return"text-muted-foreground/60";switch(a){case"function":case"method":return"text-violet-11";case"class":return"text-amber-11";case"interface":return"text-blue-11";default:return"text-muted-foreground/60"}})(a,b)} ${c??""}`.trim();if("__file__"===b)return(0,d.jsx)(i.A,{className:e});if("__preamble__"===b)return(0,d.jsx)(k.A,{className:e});if(b&&b.startsWith("__heading_"))return(0,d.jsx)(l.A,{className:e});switch(a){case"function":case"method":return(0,d.jsx)(m.A,{className:e});case"class":return(0,d.jsx)(n.A,{className:e});case"interface":return(0,d.jsx)(o.A,{className:e});default:return(0,d.jsx)(p.A,{className:e})}}var r=c(85984),s=c(29939);function t({cwd:a}){let{t:b}=(0,f.Bd)(),[c,g]=(0,e.useState)(null),h=(0,e.useCallback)(b=>{b?.type==="graphProgress"&&b.data&&b.data.cwd===a&&g(b.data)},[a]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(a)}`,onMessage:h});let i=(0,e.useRef)("");if(c?.currentFile&&(i.current=c.currentFile),!c)return(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:b("blockViewer.fileMode.loading","Loading…")});let j=b(`blockViewer.buildProgress.${c.phase}`,u[c.phase]),k=Math.max(0,Math.min(100,Math.round(c.percent)));return(0,d.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-8",children:(0,d.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-baseline justify-between text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:j}),(0,d.jsx)("span",{className:"tabular-nums",children:"parsing"===c.phase&&c.filesTotal>0?`${c.filesDone} / ${c.filesTotal}`:`${k}%`})]}),(0,d.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:(0,d.jsx)("div",{className:"h-full rounded-full bg-primary transition-[width] duration-150 ease-linear",style:{width:`${k}%`}})}),(0,d.jsx)("div",{className:"h-4 truncate text-left font-mono text-[11px] leading-4 text-muted-foreground/70",dir:"rtl",title:"done"===c.phase?"":i.current,children:"done"===c.phase?"":i.current})]})})}let u={listing:"Listing files…",contexts:"Reading project config…",parsing:"Parsing files",resolving:"Resolving imports…",edges:"Building call graph…",done:"Finishing up…"};var v=c(7031),w=c(74754),x=c(91579),y=c(83768),z=c(36984),A=c(72529);function B({entries:a,onSelect:b,onClear:c}){let{t:e}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"function-history-drawer",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,d.jsx)("div",{className:"flex items-center text-xs text-muted-foreground font-mono min-w-0",children:(0,d.jsx)("span",{className:"truncate",children:0===a.length?e("blockViewer.history.title"):`${e("blockViewer.history.title")} \xb7 ${a.length}/15`})}),a.length>0&&(0,d.jsx)(A.m,{content:e("blockViewer.history.clear"),children:(0,d.jsx)("button",{onClick:c,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,d.jsx)(h.A,{className:"w-3 h-3"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===a.length?(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:e("blockViewer.history.empty")}):a.map((a,c)=>{var e;let f;return(0,d.jsx)(A.m,{content:`${a.qname} \xb7 ${a.filePath}`,children:(0,d.jsxs)("button",{onClick:()=>b(a),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:transition-colors group flex items-start gap-1.5",children:[(0,d.jsx)(q,{kind:a.kind??"unknown",qname:a.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:a.name}),(0,d.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(f=(e=a.filePath).lastIndexOf("/"))>=0?e.slice(f+1):e,a.kind&&(0,d.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",a.kind]})]})]})]})},`${a.filePath}::${a.qname}::${c}`)})})]})}function C(a,b){let c=a.filter(a=>a.filePath!==b.filePath||a.qname!==b.qname),d=[b,...c];return d.length>15?d.slice(0,15):d}var D=c(65543);function E({functions:a,counts:b,totalLines:c,currentQname:g,onSelect:h,notIndexed:i,onRebuild:j}){let{t:k}=(0,f.Bd)(),l=(0,e.useMemo)(()=>a.filter(D._),[a]);return(0,d.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"file-toc-section",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:[k("blockViewer.toc.title"),l.length>0&&` \xb7 ${l.length}`,null!=c&&` \xb7 ${c} ${k("common.lines")}`]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===l.length?i?(0,d.jsxs)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/80 leading-relaxed flex flex-col gap-2",children:[(0,d.jsx)("span",{className:"italic",children:k("blockViewer.toc.notIndexed")}),j&&(0,d.jsx)("button",{type:"button",onClick:j,className:"self-start px-2 py-1 rounded border border-border bg-secondary/60 hover:bg-secondary text-[10px] text-foreground transition-colors",children:k("blockViewer.refresh")})]}):(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:k("blockViewer.toc.empty")}):l.map(a=>{let c=g===a.qualifiedName,e=b?.get(a.qualifiedName),f=e?[e.in>0&&["in",e.in,"text-amber-11/80"],e.out>0&&["out",e.out,"text-green-11/80"],e.self>0&&["self",e.self,"text-muted-foreground/60"]].filter(Boolean):[];return(0,d.jsx)(A.m,{content:`${a.qualifiedName} \xb7 L${a.startLine}`,children:(0,d.jsxs)("button",{onClick:()=>h(a.qualifiedName,a.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-start gap-1.5 min-w-0 ${c?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,d.jsx)(q,{kind:a.kind,qname:a.qualifiedName,className:"w-3 h-3 flex-shrink-0 mt-0.5"}),(0,d.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`flex-1 min-w-0 text-xs font-mono truncate ${c?"font-semibold text-brand":""}`,children:a.name}),(0,d.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground/50 tabular-nums",children:a.endLine-a.startLine+1})]}),f.length>0&&(0,d.jsx)("span",{className:"block text-[10px] font-mono truncate",children:f.map(([a,b,c],e)=>(0,d.jsxs)("span",{className:c,children:[e>0&&(0,d.jsx)("span",{className:"text-muted-foreground/30",children:" \xb7 "}),a," ",b]},a))})]})]})},a.qualifiedName)})})]})}var F=c(37690),G=c(22341);function H({comments:a,startLine:b,endLine:c,lineHeight:e,bodyTopOffset:f,rowOf:g,onCommentClick:h}){let i=new Map;for(let d of a){if(d.endLine<b||d.endLine>c)continue;let a=i.get(d.endLine);a?a.push(d):i.set(d.endLine,[d])}return 0===i.size?null:(0,d.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(i.entries()).map(([a,c])=>{let i=g?g(a):a-b,j=c[0],k=c.length-1;return(0,d.jsx)(A.m,{content:1===c.length?j.content:`${c.length} comments — click to view`,children:(0,d.jsxs)("button",{onClick:a=>h(j,a),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-lv1 transition-colors",style:{top:`${f+i*e+e/2-8}px`},children:[(0,d.jsx)(G.A,{className:"w-2.5 h-2.5"}),k>0&&(0,d.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:k+1})]})},a)})})}function I(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function J({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:f}){let g,h=(0,e.useRef)(null),i=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),j=(0,e.useMemo)(()=>{if(i.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=i.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,i]);if(i.total<=0)return null;let k=(a,b)=>{let c=I(i,a),d=I(i,b);return null===c||null===d?null:{top:c/i.total*100,heightPct:(d-c+1)/i.total*100}};return(0,d.jsxs)("div",{ref:h,onClick:a=>{let b=h.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(i,(a.clientY-c.top)/c.height*i.total);if(!d)return;let e=d.line,g=j.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void f(g.qname,e);if(j.length>0){let a=Math.max(2,Math.round(.05*i.total)),b=I(i,e);if(null!==b){let c=null,d=1/0;for(let a of j){let e=I(i,a.start),f=I(i,a.end);if(null===e||null===f)continue;let g=b<e?e-b:b>f?b-f:0;g<d&&(c=a,d=g)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;f(c.qname,a);return}}}let k=i.blocks.find(a=>a.qname===d.qname);k&&f(k.qname,k.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[j.map(a=>{let b=k(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((g=k(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${g.top}%`,height:`${Math.max(1.2,g.heightPct)}%`}}):null)]})}var K=c(73414),L=c(41051),M=c(42140),N=c(70596);function O(a){let b=a.lastIndexOf("/");return b>=0?a.slice(b+1):a}function P(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let Q="flex-shrink-0 h-4 leading-4 px-1.5 rounded text-[10px] text-brand hover:bg-brand/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent";function R({symbol:a,fileSource:b,hasChange:c,onHighlighted:g,comments:h,onCommentClick:i,addedLines:j,upstream:k,downstream:l,fold:m,onExpandGap:n}){let{resolvedTheme:o}=(0,y.DP)(),{t:p}=(0,f.Bd)(),r=(0,v.r)(),s=(k?.length??0)+(l?.length??0)>0;(0,e.useMemo)(()=>(0,z.sQ)(a.filePath),[a.filePath]);let[t,u]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),A=(0,e.useMemo)(()=>{if(!t)return null;let b=b=>{let c=t[b-a.startLine]??"",d=j?.has(b)?" bg-green-9/15":"";return`<div class="flex${d}" style="min-width:max-content" data-line="${b}"><span class="select-none pr-3 text-muted-foreground/60 tabular-nums" style="min-width:3.2rem;text-align:right">${b}</span><span class="whitespace-pre">${c}</span></div>`};return m?m.segments.map(a=>{if("gap"===a.kind){var c;let b,d,e;return c=a.startLine,d=P(p("diffViewer.gap.hidden",{count:b=a.endLine-c+1})),e=P(p("diffViewer.gap.expandAll",{count:b})),`<div class="flex items-center cursor-pointer select-none hover:bg-hover" style="min-width:max-content;height:${U}px" data-fold-gap="${c}" title="${e}"><span class="select-none pr-3 text-muted-foreground/40" style="min-width:3.2rem;text-align:right">⋯</span><span class="text-[10px] text-muted-foreground/60 whitespace-pre">${d}</span></div>`}let d="";for(let c=a.startLine;c<=a.endLine;c++)d+=b(c);return d}).join(""):t.map((c,d)=>b(a.startLine+d)).join("")},[t,m,j,a.startLine,p]),B=(0,e.useCallback)(b=>{if(!n)return;let c=b.target,d=c?.closest?.("[data-fold-gap]");if(!d)return;let e=Number(d.getAttribute("data-fold-gap"));Number.isFinite(e)&&n(a.qualifiedName,e)},[n,a.qualifiedName]);return(0,d.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,d.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border text-xs",children:[(0,d.jsx)(q,{kind:a.kind,qname:a.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),!a.qualifiedName.startsWith("__code_")&&(0,d.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,d.jsx)("span",{className:"font-medium",children:a.name}),void 0!==a.params&&(0,d.jsxs)("span",{className:"text-muted-foreground/80",children:["(",a.params.join(", "),")"]})]}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:["unknown"!==a.kind&&`${a.kind} \xb7 `,a.endLine-a.startLine+1," ",p("common.lines")]}),r&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>r.sendMessage(p("explain.symbolMessage",{name:a.name,path:a.filePath,lines:`${a.startLine}-${a.endLine}`})),disabled:r.isLoading,title:r.isLoading?p("comments.aiResponding"):void 0,className:Q,children:p("explain.action")}),s&&(0,d.jsx)("button",{onClick:()=>r.sendMessage(p("deps.symbolMessage",{name:a.name,path:a.filePath,lines:`${a.startLine}-${a.endLine}`,...function(a,b,c){let d=a=>{switch(a.kind){case"cross":case"self":return`${a.external.name} (${a.external.filePath})`;case"method":return`${a.receiverName}.${a.methodName}()`;case"ext":return null}},e=a=>{let b=a.map(d).filter(a=>null!==a);return b.length?b.join(", "):c},f=new Map;for(let a of b){if("ext"!==a.kind)continue;let b=f.get(a.packageSpec);b?b.push(a.name):f.set(a.packageSpec,[a.name])}let g=[...f].map(([a,b])=>`${a} (${b.join(", ")})`);return{callers:e(a),callees:e(b),externals:g.length?g.join("; "):c}}(k??[],l??[],p("deps.none"))})),disabled:r.isLoading,title:r.isLoading?p("comments.aiResponding"):void 0,className:Q,children:p("deps.action")})]}),(0,d.jsx)("span",{className:"flex-1"}),c&&(0,d.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,d.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${U}px`},onClick:B,children:[!b&&(0,d.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),w&&(0,d.jsx)("span",{className:"text-red-11",children:w}),A&&(0,d.jsx)("div",{dangerouslySetInnerHTML:{__html:A}})]}),h&&h.length>0&&i&&(0,d.jsx)(H,{comments:h,startLine:a.startLine,endLine:a.endLine,lineHeight:U,bodyTopOffset:V+W,rowOf:m?.rowOf,onCommentClick:i})]})}function S({side:a,pin:b,accent:c,onClick:e}){let f,g,h,i,j,k,l,m=b.lines.length;"ext"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="ext",h="text-muted-foreground/60",i=b.name,j=b.packageSpec,k="external",l=b.packageSpec):"method"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="method",h="text-muted-foreground/60",i=`${b.receiverName}.${b.methodName}`,j=null,k="method (unresolved)",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):"self"===b.kind?(f="bg-secondary/40 border-border hover:border-muted-foreground",g="self",h="text-muted-foreground/70",i=b.external.name,j=null,k="same-file",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):(f="in"===a?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",g=a,h="in"===a?"text-amber-11":"text-green-11",i=b.external.name,j=O(b.external.filePath),k="in"===a?"caller":"callee",l=b.external.filePath);let n=c&&"ext"!==b.kind&&"method"!==b.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),e()},className:`${f}${n} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors block`,"data-tooltip":`${k} \xb7 ${i}${l?" \xb7 "+l:""}`,children:(0,d.jsxs)("span",{className:"block h-[26px] leading-[13px] overflow-hidden",children:[(0,d.jsx)("span",{className:`${h} float-left mr-1.5 text-[9px] uppercase tracking-wider font-semibold`,children:g}),(j||m>1)&&(0,d.jsxs)("span",{className:"float-right clear-both ml-1.5 max-w-[60%] truncate text-muted-foreground/70",children:[j,m>1&&(0,d.jsxs)("span",{className:"text-muted-foreground/60",children:[j?" ":"","\xb7",m,"\xd7"]})]}),(0,d.jsx)("span",{className:"font-medium break-all",children:i})]})})}let T="w-44 @min-[900px]:w-52 @min-[1100px]:w-60 @min-[1400px]:w-72 @min-[1800px]:w-80 @min-[2400px]:w-96",U=18,V=29,W=8;function X(a,b){switch(b.kind){case"cross":return`${a}:x:${b.external.filePath}::${b.external.qualifiedName}`;case"self":return`${a}:s:${b.external.filePath}::${b.external.qualifiedName}`;case"ext":return`${a}:e:${b.packageSpec}::${b.name}`;case"method":return`${a}:m:${b.receiverName}::${b.methodName}`}}function Y(a,b){return"ext"!==a.kind&&"method"!==a.kind&&(b?.has(a.external.qualifiedName)??!1)}function Z(a){return{filePath:a.filePath,qname:a.qualifiedName,name:a.name,kind:a.kind}}function $({symbol:a,fileSource:b,hasChange:c,upstream:e,downstream:f,onPinClick:g,onHighlighted:h,comments:i,onCommentClick:j,accentQnames:k,addedLines:l,fold:m,onExpandGap:n}){let o=function(a,b,c){if(0===a.length)return[];let d=a.map((a,c)=>{var d,e;return{i:c,line:(d=a.lines[0]??b.startLine,e=b.startLine,Math.max(e,Math.min(b.endLine,d)))}});d.sort((a,b)=>a.line-b.line||a.i-b.i);let e=Array(a.length).fill(0),f=-1/0;for(let{i:a,line:g}of d){let d=Math.max(V+W+(c?c.rowOf(g):g-b.startLine)*U,f);e[a]=d,f=d+34}return e}(f,a,m);return(0,d.jsxs)("div",{"data-block-qname":a.qualifiedName,"data-start-line":a.startLine,"data-end-line":a.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,d.jsx)("div",{className:`${T} flex-shrink-0 flex flex-col gap-1 pt-1`,children:0===e.length?(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):e.map(b=>(0,d.jsx)(S,{side:"in",pin:b,accent:Y(b,k),onClick:()=>g(b,a)},X("in",b)))}),(0,d.jsx)(R,{symbol:a,fileSource:b,hasChange:c,onHighlighted:h,comments:i,onCommentClick:j,addedLines:l,upstream:e,downstream:f,fold:m,onExpandGap:n}),(0,d.jsx)("div",{className:`${T} flex-shrink-0 relative`,children:0===f.length?(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):f.map((b,c)=>(0,d.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${o[c]}px`},children:(0,d.jsx)(S,{side:"out",pin:b,accent:Y(b,k),onClick:()=>g(b,a)})},X("out",b)))})]})}function _({cwd:a,onSelect:b,onClose:c}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)({files:[],symbols:[]}),[n,o]=(0,e.useState)(0),[p,q]=(0,e.useState)(!1),r=(0,e.useMemo)(()=>[...l.files,...l.symbols],[l]),s=(0,e.useCallback)(a=>{if("Escape"===a.key)return void c();if(0!==r.length){if("ArrowDown"===a.key)a.preventDefault(),o(a=>Math.min(a+1,r.length-1));else if("ArrowUp"===a.key)a.preventDefault(),o(a=>Math.max(a-1,0));else if("Enter"===a.key){a.preventDefault();let c=r[n];c&&b(c)}}},[r,n,c,b]);return(0,d.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:c,children:(0,d.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-lv3 overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,d.jsx)(g.A,{className:"w-4 h-4 text-muted-foreground"}),(0,d.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),onKeyDown:s,placeholder:i("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),p&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,d.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground",children:(0,d.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===r.length&&j&&!p&&(0,d.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("blockViewer.search.noResults","No matches")}),(0,d.jsx)(aa,{label:i("blockViewer.search.files","Files"),hits:l.files,startIdx:0,activeIdx:n,onSelect:b,setActive:o}),(0,d.jsx)(aa,{label:i("blockViewer.search.symbols","Symbols"),hits:l.symbols,startIdx:l.files.length,activeIdx:n,onSelect:b,setActive:o})]})]})})}function aa({label:a,hits:b,startIdx:c,activeIdx:e,onSelect:f,setActive:g}){return 0===b.length?null:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:a}),b.map((a,b)=>{let h=c+b,j=h===e;return(0,d.jsxs)("button",{onMouseEnter:()=>g(h),onClick:()=>f(a),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${j?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===a.type?(0,d.jsx)(i.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,d.jsx)(q,{kind:a.target.kind,qname:a.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,d.jsx)("span",{className:"font-mono truncate",children:a.label}),a.hint&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:a.hint})]})]},`${a.type}:${a.label}:${b}`)})]})}function ab({cwd:a,highlightedFilePath:b,changedFiles:c,onSwitchToCode:g,enableComments:h=!1,onContentSearch:i,onFocalChange:j,qnameFilter:k,qnameFilterFile:l,accentQnames:m,accentFile:n,addedLines:o,addedLinesFile:p,compact:q=!1,headerExtraLeft:s,headerExtraRight:u}){let{t:y}=(0,f.Bd)(),[z,A]=(0,e.useState)("toc"),[D,G]=(0,e.useState)(null),H=D??b??null,{state:I,refresh:P}=(0,r.V)(a,H),[Q,R]=(0,e.useState)(null),S=(0,e.useMemo)(()=>Q?Q.content.split("\n").length:null,[Q]);(0,e.useRef)(null);let[U,V]=(0,e.useState)([]),[W,X]=(0,e.useState)(!1),[Y,aa]=(0,e.useState)(null),ae=(0,e.useRef)(0);(0,e.useRef)(0);let[af,ag]=(0,e.useState)(()=>new Set);"ready"===I.state&&I.data.filePath;let ah=(0,e.useCallback)(a=>{ag(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c})},[]),ai=(0,e.useCallback)((a,b)=>{if("ext"===a.kind||"method"===a.kind){let a=b.filePath;if(!a)return;ae.current+=1,aa({filePath:a,qname:"__imports__",nonce:ae.current});return}let c=Z(b),d=Z(a.external);V(a=>C(C(a,c),d)),G(d.filePath),ae.current+=1,aa({filePath:d.filePath,qname:d.qname,nonce:ae.current})},[]),aj=(0,e.useCallback)(a=>{G(a.filePath),ae.current+=1,aa({filePath:a.filePath,qname:a.qname,nonce:ae.current})},[]),ak=(0,e.useCallback)(a=>{X(!1),G(a.target.filePath),"symbol"===a.type&&(ae.current+=1,aa({filePath:a.target.filePath,qname:a.target.qualifiedName,line:a.target.startLine,nonce:ae.current}))},[]),al=(0,e.useCallback)((a,b)=>{H&&(ae.current+=1,aa({filePath:H,qname:a,line:b,nonce:ae.current}))},[H]),[am,an]=(0,e.useState)(()=>new Set),ao=(0,e.useCallback)((a,b)=>{an(c=>{let d=new Set(c);return d.add(`${H}#${a}#${b}`),d})},[H]),[ap,aq]=(0,e.useState)(null),[ar,as]=(0,e.useState)(null),at=(0,e.useMemo)(()=>{if("ready"!==I.state||!ar)return null;let a=I.data.functions;if(0===a.length)return null;let b=(ar.start+ar.end)/2;for(let c of a)if(c.startLine<=b&&b<=c.endLine)return c.qualifiedName;let c=null;for(let b of a)b.startLine<=ar.start&&(!c||b.startLine>c.startLine)&&(c=b);return c?.qualifiedName??null},[I,ar]),au=h&&!!a&&!!H,av=(0,v.r)(),{comments:aw,addComment:ax,updateComment:ay,deleteComment:az,refresh:aA}=(0,w._)({cwd:a,filePath:H??""}),[aB,aC]=(0,e.useState)(null),{toolbarRef:aD,bumpRef:aE,clearToolbar:aF}=(0,F.L)({enabled:au,container:aB,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-line]");if(!c||!aB||!aB.contains(c))return null;let d=c.getAttribute("data-line");if(!d)return null;let e=parseInt(d,10);return Number.isFinite(e)?{start:e,end:e}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Q?.content;return c?c.split("\n").slice(a-1,b).join("\n"):""}}),[aG,aH]=(0,e.useState)(null),[aI,aJ]=(0,e.useState)(null),[aK,aL]=(0,e.useState)(null),aM=(0,e.useCallback)(()=>{let a=aD.current;a&&(aH({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aF())},[aF,aD]),aN=(0,e.useCallback)(()=>{let a=aD.current;a&&(aJ({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aF())},[aF,aD]),aO=(0,e.useCallback)(()=>{let a=aD.current;a&&av&&H&&(aF(),(0,x.Ff)(av.sendMessage,{filePath:H,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},y("explain.selectionMessage")))},[av,H,aF,aD,y]),aP=(0,e.useCallback)(()=>{let a=aD.current;if(!a||!i)return;let b=a.selectedText.trim();aF(),b&&i(b)},[i,aF,aD]),aQ=(0,e.useCallback)(async a=>{aG&&(await ax(aG.range.start,aG.range.end,a,aG.selectedText),aH(null))},[aG,ax]),aR=(0,e.useCallback)(async(b,c)=>{if(av&&a&&H)try{let d=(await (0,x.$3)(a)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));d.push({filePath:H,startLine:b.range.start,endLine:b.range.end,codeContent:b.lineSnapshot});let e=(0,x.Gw)(d,c);av.sendMessage(e),await (0,x.RP)(a),aA()}catch(a){console.error("[BlockViewer] send to AI failed:",a)}},[av,a,H,aA]),aS=(0,e.useCallback)(a=>{aI&&aR(aI,a)},[aI,aR]),aT=(0,e.useCallback)(a=>{aG&&aR(aG,a)},[aG,aR]),aU=(0,e.useCallback)((a,b)=>{b.stopPropagation(),aL({comment:a,x:b.clientX,y:b.clientY}),aF(),aH(null),aJ(null)},[aF]);if(!H)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:null,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,refreshDisabled:!0,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,d.jsx)("span",{children:y("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,d.jsx)("span",{className:"text-xs",children:y("blockViewer.empty.hint","or press ⌘K to search.")})]}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]});if("idle"===I.state||"loading"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,refreshDisabled:!0,extraLeft:s,extraRight:u}),(0,d.jsx)(t,{cwd:a})]});if("notFound"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:y("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]});if("error"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,d.jsx)("span",{className:"text-red-11",children:I.message}),(0,d.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:y("blockViewer.retry","Retry")})]})]});let aV=I.data,aW=aV.functions;if(0===aW.length&&Q){let a=Math.max(1,S??1);aW=[{filePath:aV.filePath,qualifiedName:"__file__",name:O(aV.filePath),kind:"unknown",startLine:1,endLine:a}]}let aX=l&&l===aV.filePath,aY=n&&n===aV.filePath,aZ=p&&p===aV.filePath;aX&&k&&(aW=aW.filter(a=>k.has(a.qualifiedName)));let a$=aY?m:void 0,a_=aZ?o:void 0,a0=new Map;if(q&&a_)for(let a of aW)a0.set(a.qualifiedName,function(a,b,c,d,e=K.aj){if(b<a)return null;let f=[];for(let d of c)d>=a&&d<=b&&f.push(d);f.sort((a,b)=>a-b);let g=[];for(let c of f){let d=Math.max(a,c-e),f=Math.min(b,c+e),h=g[g.length-1];h&&d<=h.endLine+1?f>h.endLine&&(h.endLine=f):g.push({startLine:d,endLine:f})}let h=[],i=a;for(let a of g)a.startLine>i&&h.push({startLine:i,endLine:a.startLine-1}),i=a.endLine+1;i<=b&&h.push({startLine:i,endLine:b});let j=[],k=[];for(let a of h)a.endLine-a.startLine+1<2||d(a.startLine)?k.push(a):j.push(a);if(0===j.length)return null;g=function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[];for(let a of b){let b=c[c.length-1];b&&a.startLine<=b.endLine+1?a.endLine>b.endLine&&(b.endLine=a.endLine):c.push({...a})}return c}([...g,...k]);let l=[];for(let a of[...g.map(a=>({kind:"lines",...a})),...j.map(a=>({kind:"gap",...a}))].sort((a,b)=>a.startLine-b.startLine))l.push(a);let m=[],n=0;for(let a of l)m.push(n),n+="gap"===a.kind?1:a.endLine-a.startLine+1;let o=n;return{segments:l,visibleRuns:g,hiddenCount:j.reduce((a,b)=>a+(b.endLine-b.startLine+1),0),rowOf:b=>{for(let a=0;a<l.length;a++){let c=l[a];if(b<c.startLine)break;if(b<=c.endLine)return"gap"===c.kind?m[a]:m[a]+(b-c.startLine)}return b<a?0:Math.max(0,o-1)}}}(a.startLine,a.endLine,a_,b=>am.has(`${aV.filePath}#${a.qualifiedName}#${b}`)));let a1=ac(aV.upstreamCalls),a2=ac(aV.downstreamCalls),a3=new Map(aW.map(a=>[a.qualifiedName,a])),a4=new Map,a5=new Map;for(let a of aV.intraCalls){let b=a3.get(a.to),c=a3.get(a.from);if(b){let c=a4.get(a.from),d={kind:"self",external:b,lines:a.lines};c?c.push(d):a4.set(a.from,[d])}if(c){let b=a5.get(a.to),d={kind:"self",external:c,lines:a.lines};b?b.push(d):a5.set(a.to,[d])}}let a6=new Map;for(let a of aV.externalCalls??[]){let b=a6.get(a.focalQname),c={kind:"ext",name:a.external.name,packageSpec:a.external.packageSpec,lines:a.lines};b?b.push(c):a6.set(a.focalQname,[c])}let a7=new Map;for(let a of aV.methodCalls??[]){let b=a7.get(a.focalQname),c={kind:"method",receiverName:a.receiverName,methodName:a.methodName,lines:a.lines};b?b.push(c):a7.set(a.focalQname,[c])}let a8=new Map;for(let a of aW){let b=a.qualifiedName,c={in:a1.get(b)?.length??0,out:a2.get(b)?.length??0,self:(a5.get(b)?.length??0)+(a4.get(b)?.length??0)};(c.in||c.out||c.self)&&a8.set(b,c)}let a9=c.has(aV.filePath);return(0,d.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:aV.fileCount,functionCount:aV.functions.length,upstreamCount:aV.upstreamCalls.length,downstreamCount:aV.downstreamCalls.length,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{ref:aC,className:"@container flex-1 relative min-h-0 flex",children:[(0,d.jsxs)("div",{className:`${T} flex-shrink-0 border-r border-border flex flex-col`,children:[(0,d.jsx)("div",{className:"flex-shrink-0 flex border-b border-border",children:[["toc",y("blockViewer.tabs.toc")],["history",y("blockViewer.tabs.history")]].map(([a,b])=>(0,d.jsx)("button",{onClick:()=>A(a),className:`flex-1 px-2 py-1.5 text-xs font-medium transition-colors ${z===a?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground"}`,children:b},a))}),(0,d.jsx)("div",{className:"toc"===z?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(E,{functions:aW,counts:a8,totalLines:S,currentQname:at,onSelect:al,notIndexed:aV.notIndexed,onRebuild:P})}),(0,d.jsx)("div",{className:"history"===z?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(B,{entries:U,onSelect:aj,onClear:()=>V([])})})]}),(0,d.jsx)("div",{ref:aq,className:"@container flex-1 min-w-0 overflow-auto",children:(0,d.jsx)("div",{className:"flex flex-col gap-3 p-3",children:aW.map(a=>{let b,c,e,f,g,h;return(0,d.jsx)($,{symbol:a,fileSource:Q?.content??null,hasChange:a9,upstream:(b=a1.get(a.qualifiedName),c=a5.get(a.qualifiedName),[...(b??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...c??[]]),downstream:(e=a2.get(a.qualifiedName),f=a4.get(a.qualifiedName),g=a7.get(a.qualifiedName),h=a6.get(a.qualifiedName),[...(e??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...f??[],...g??[],...h??[]]),onPinClick:ai,onHighlighted:ah,comments:au?aw:void 0,onCommentClick:au?aU:void 0,accentQnames:a$,addedLines:a_,fold:a0.get(a.qualifiedName),onExpandGap:ao},`${a.qualifiedName}#${a.startLine}`)})})}),au&&aB&&(0,d.jsx)(L.fS,{floatingToolbarRef:aD,bumpRef:aE,container:aB,onAddComment:aM,onSendToAI:aN,onSearch:i?aP:void 0,onExplain:av&&H?aO:void 0,isChatLoading:av?.isLoading}),au&&aG&&(0,d.jsx)(M.t,{x:aG.x,y:aG.y,range:aG.range,filePath:H??void 0,lineSnapshot:aG.lineSnapshot,container:aB,onSubmit:aQ,onSendToAI:av&&H?aT:void 0,onClose:()=>aH(null),isChatLoading:av?.isLoading}),au&&aI&&H&&(0,d.jsx)(M.G,{x:aI.x,y:aI.y,range:aI.range,filePath:H,lineSnapshot:aI.lineSnapshot,container:aB,onSubmit:aS,onClose:()=>aJ(null),isChatLoading:av?.isLoading}),au&&aK&&(0,d.jsx)(N.t,{x:aK.x,y:aK.y,comment:aK.comment,container:aB,onClose:()=>aL(null),onUpdateComment:ay,onDeleteComment:az}),a_&&a_.size>0&&aW.length>0&&(0,d.jsx)(J,{addedLines:a_,blockRanges:aW.flatMap(a=>{let b=a0.get(a.qualifiedName);return b?b.visibleRuns.map(b=>({qname:a.qualifiedName,startLine:b.startLine,endLine:b.endLine})):[{qname:a.qualifiedName,startLine:a.startLine,endLine:a.endLine}]}),viewportRange:ar,onJumpToLine:al}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]})]})}function ac(a){let b=new Map;for(let c of a){let a=b.get(c.focalQname);if(!a){b.set(c.focalQname,[c]);continue}a.some(a=>a.external.filePath===c.external.filePath&&a.external.qualifiedName===c.external.qualifiedName)||a.push(c)}return b}function ad({focalFile:a,fileCount:b,functionCount:c,upstreamCount:e,downstreamCount:h,onSwitchToCode:i,onSearch:k,onRefresh:l,refreshDisabled:m,extraLeft:n,extraRight:o}){let{t:p}=(0,f.Bd)(),q={focalFile:a,blockCount:c??0,upstreamCount:e??0,downstreamCount:h??0};return(0,d.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,d.jsx)("span",{className:"truncate min-w-0",children:a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-foreground",children:a}),"number"==typeof c&&(0,d.jsxs)("span",{className:"ml-2",children:["\xb7 ",c," blocks"]}),"number"==typeof e&&"number"==typeof h&&(0,d.jsxs)("span",{className:"ml-2",children:["\xb7 ",e," in \xb7 ",h," out"]})]}):(0,d.jsx)("span",{children:null!==b?`${b} files`:"…"})}),n&&(0,d.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:n(q)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o&&(0,d.jsx)("span",{className:"flex items-center gap-1",children:o(q)}),(0,d.jsxs)("button",{onClick:k,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":p("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,d.jsx)(g.A,{className:"w-3 h-3"})," ⌘K"]}),(0,d.jsx)("button",{onClick:l,disabled:m,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":p("blockViewer.refresh","Rebuild project graph"),children:(0,d.jsx)(j.A,{className:"w-3 h-3"})}),i&&(0,d.jsx)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:p("common.code","Code")})]})]})}},73414:(a,b,c)=>{"use strict";c.d(b,{YO:()=>e,aj:()=>d,pU:()=>f});let d=3,e=20;function f(a,b,c,g=[]){let h=a.length,i=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,j=new Set;for(let a=0;a<h;a++){if(!i(a))continue;let b=Math.max(0,a-d),c=Math.min(h-1,a+d);for(let a=b;a<=c;a++)j.add(a)}let k=[];for(let a=0;a<h;a++){if(j.has(a))continue;let b=a;for(;a<h&&!j.has(a);)a++;k.push({id:k.length,startIdx:b,endIdx:a-1}),a--}for(let a of k){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)j.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)j.add(b)}let l=[];for(let a=0;a<h;a++){let c;if(j.has(a)){l.push({kind:"diff",idx:a});continue}let d=a;for(;a<h&&!j.has(a);)a++;let f=a-1;a--;let i=k.find(a=>a.startIdx<=d&&f<=a.endIdx);if(!i)continue;let m=f-d+1,n=Math.min(e,m);if(g.length>0&&f+1<h)for(let a=f+1;a<h;a++){let d=b[a].lineNum;if(!(d<=0)){c=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(g,d)??void 0;break}}l.push({kind:"gap-expand",gapId:i.id,direction:"up",revealCount:n}),l.push({kind:"gap-label",gapId:i.id,hiddenCount:m,enclosingFn:c}),l.push({kind:"gap-expand",gapId:i.id,direction:"down",revealCount:n})}return{rows:l,gaps:k}}},73887:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>A});var e=c(48249),f=c(67484),g=c(44384),h=c(64825),i=c(74429),j=c(7122),k=c(7833),l=c(41051),m=c(42140),n=c(70596),o=c(74754),p=c(7031),q=c(91579),r=c(208),s=c(5900),t=c(64676),u=c(84835);c(15466);var v=c(60591),w=c(34728),x=c(24680),y=c(92608),z=c(37690);let a=[u.W];function A({content:b,filePath:c,cwd:d,onClose:u,sourceFile:B,embedded:C=!1,onLocalMdLink:D,scrollToAnchor:E}){let F=B||(d&&c.startsWith(d)?c.slice(d.endsWith("/")?d.length:d.length+1):c),{t:G}=(0,g.Bd)(),H=(0,j.iN)(),I=(0,p.r)(),J=(0,w.U)(),{comments:K,addComment:L,updateComment:M,deleteComment:N,refresh:O}=(0,o._)({cwd:d,filePath:c}),[P,Q]=(0,f.useState)(!1),[R,S]=(0,f.useState)(null),[T,U]=(0,f.useState)(null),[V,W]=(0,f.useState)(null),X=(0,f.useMemo)(()=>b.split("\n"),[b]),Y=(0,f.useMemo)(()=>(0,t.J4)(c,d),[c,d]),[Z,$]=(0,f.useState)(null),_=(0,f.useRef)(null),aa=(0,f.useRef)({onLocalMdLink:D,sourceFile:F});aa.current={onLocalMdLink:D,sourceFile:F};let ab=(0,f.useRef)(a=>{let{onLocalMdLink:b,sourceFile:c}=aa.current;if(!b||/^[a-z][a-z0-9+.-]*:/i.test(a))return!1;let d=a.indexOf("#"),e=d>=0?a.slice(0,d):a,f=d>=0?a.slice(d+1):null;if(!e)return!1;let g=e;try{g=decodeURIComponent(e)}catch{}return!!(0,v.e$)(g)&&(b((0,v.WU)(c,g),f),!0)}).current,{toolbarRef:ac,bumpRef:ad,clearToolbar:ae}=(0,z.L)({enabled:!0,container:Z,resolveLineRange:a=>{let b=function(a){let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a;if(!b||!("closest"in b))return null;let c=b.closest("[data-source-start]");if(!c)return null;let d=c.getAttribute("data-source-start"),e=c.getAttribute("data-source-end");return d&&e?{start:parseInt(d,10),end:parseInt(e,10)}:null}(a);return b?{start:b.start,end:b.end}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Math.max(0,a-1),d=Math.min(X.length,b);return X.slice(c,d).join("\n")}}),af=(0,f.useCallback)(()=>{let a=ac.current;a&&(S({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ae())},[ae,ac]),ag=(0,f.useCallback)(()=>{let a=ac.current;a&&(U({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ae())},[ae,ac]),ah=(0,f.useCallback)(()=>{let a=ac.current;a&&I&&(ae(),(0,q.Ff)(I.sendMessage,{filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},r.A.t("explain.selectionMessage")))},[I,c,ae,ac]),ai=(0,f.useCallback)(async a=>{R&&(await L(R.range.start,R.range.end,a,R.selectedText),S(null))},[R,L]),aj=(0,f.useCallback)(async(a,b)=>{if(I)try{let e=await (0,q.$3)(d),f=[];for(let a of e)f.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});f.push({filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot});let g=(0,q.Gw)(f,b);I.sendMessage(g),await (0,q.RP)(d),O()}catch(a){console.error("Failed to send to AI:",a)}},[I,c,d,O]),ak=(0,f.useCallback)(a=>{T&&aj(T,a)},[T,aj]),al=(0,f.useCallback)(a=>{R&&aj(R,a)},[R,aj]);(0,f.useMemo)(()=>{if(0===K.length)return[];let a=new Map;for(let b of K){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[K]);let[am,an]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[!C&&(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-brand transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":c,onClick:()=>{navigator.clipboard.writeText(c),(0,k.oR)(G("common.copiedPath"))},children:["‎",c]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(y.ShareReviewToggle,{content:b,sourceFile:F}),(0,v.C_)(c)&&(0,e.jsx)("button",{onClick:()=>J(c.startsWith("/")||!d?c:`${d.replace(/\/$/,"")}/${c}`),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:G("skills.addTooltip"),children:(0,e.jsx)(h.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:u,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:G("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)(x.l,{content:b,containerRef:_}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:_,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(s.T,{content:b,basePath:Y,rehypePlugins:a,onLinkClick:ab})}),am.map(({key:a,top:b,comments:c})=>(0,e.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),W({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-lv1 hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),P&&H&&(0,i.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.fS,{floatingToolbarRef:ac,bumpRef:ad,container:H,onAddComment:af,onSendToAI:ag,onExplain:I?ah:void 0,isChatLoading:I?.isLoading}),R&&(0,e.jsx)(m.t,{x:R.x,y:R.y,range:R.range,filePath:c,lineSnapshot:R.lineSnapshot,container:H,onSubmit:ai,onSendToAI:I?al:void 0,onClose:()=>S(null),isChatLoading:I?.isLoading}),T&&(0,e.jsx)(m.G,{x:T.x,y:T.y,range:T.range,filePath:c,lineSnapshot:T.lineSnapshot,container:H,onSubmit:ak,onClose:()=>U(null),isChatLoading:I?.isLoading}),V&&(0,e.jsx)(n.t,{x:V.x,y:V.y,comment:V.comment,container:H,onClose:()=>W(null),onUpdateComment:M,onDeleteComment:N})]}),H)]})}d()}catch(a){d(a)}})},74228:(a,b,c)=>{"use strict";c.d(b,{S:()=>f,l:()=>g});var d=c(48249),e=c(40311);function f(a){return"loading"===a||"unread"===a?a:"normal"}function g({projectNumber:a,sessionNumber:b,coordinate:c,status:f="normal",statusLabel:h,className:i=""}){if(c){let[d,e]=c.split(".");a??=d,b??=e}if(null==a&&null==b&&"normal"!==f&&(b="\xb7"),null==a&&null==b)return null;let j="flex h-4 w-4 items-center justify-center border",k=[a,b].filter(a=>null!=a).join(".");return(0,d.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[9px] font-medium leading-none tabular-nums flex-shrink-0 ${i}`,"aria-label":h?`${k} \xb7 ${h}`:k,children:[null!=a&&(0,d.jsx)("span",{className:`${j} rounded-[4px] ${(0,e.c)("normal",!1)}`,children:a}),null!=b&&(0,d.jsx)("span",{className:`${j} rounded-full ${(0,e.c)(f,!1)}`,title:h,children:b})]})}},74542:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},74691:(a,b,c)=>{"use strict";c.d(b,{y:()=>f});var d=c(48249),e=c(44384);function f({value:a,onChange:b,className:c}){let{t:g}=(0,e.Bd)();return(0,d.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${c??""}`,children:["compact","full"].map(c=>(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),b(c)},className:`px-2 py-0.5 text-xs transition-colors ${a===c?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:g("compact"===c?"diffViewer.compact":"diffViewer.full")},c))})}},74754:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(67484);c(91579);var e=c(33281),f=c(89800);function g({cwd:a,filePath:b}){let[c,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useCallback)(async()=>{if(!a||!b)return;j(!0),l(null);let c=await e.t4.runPromiseExit((0,f.lb)(a,b));if("Success"===c._tag)h(c.value.comments??[]);else{let a="Fail"===c.cause._tag?c.cause.error:null,b=a?.cause;l(b instanceof Error?b.message:"Failed to load comments")}j(!1)},[a,b]),n=(0,d.useCallback)(async(c,d,g,i)=>{let j=await e.t4.runPromiseExit((0,f.BC)({cwd:a,filePath:b,startLine:c,endLine:d,content:g,...i?{selectedText:i}:{}}));if("Success"===j._tag&&j.value.comment){let a=j.value.comment;return h(b=>[...b,a]),a}return"Failure"===j._tag&&console.error("Failed to add comment:",j.cause),null},[a,b]),o=(0,d.useCallback)(async(b,c)=>{let d=await e.t4.runPromiseExit((0,f.vv)(a,b,c));if("Success"===d._tag&&d.value.comment){let a=d.value.comment;return h(c=>c.map(c=>c.id===b?a:c)),!0}return"Failure"===d._tag&&console.error("Failed to update comment:",d.cause),!1},[a]),p=(0,d.useCallback)(async b=>{let c=await e.t4.runPromiseExit((0,f.Tu)(a,b));return"Success"===c._tag?(h(a=>a.filter(a=>a.id!==b)),!0):(console.error("Failed to delete comment:",c.cause),!1)},[a]),q=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:i,error:k,addComment:n,updateComment:o,deleteComment:p,refresh:m,getCommentsForLine:q}}},74837:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteToolbar() from the server but NoteToolbar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteToolbar.tsx","NoteToolbar")},74991:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{I:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(29588),i=c(7833),j=c(15819);c(33281);var k=c(13054),l=c(30458),m=c(36688),n=c(32753),o=c(74228),p=c(15790);c(41224);var q=a([p,m]);function r(a){return a.engine||"claude"}function s(a){return a.lastFiredAt??a.createdAt}[p,m]=q.then?(await q)():q;let u=[{key:"pendingReview",labelKey:"scheduledTasks.groupPendingReview"},{key:"upcoming",labelKey:"scheduledTasks.groupUpcoming"},{key:"paused",labelKey:"scheduledTasks.paused"}];function t({collapsed:a,tasks:b,unreadCount:c,sessionNumbers:d,onSwitchProject:q,onPause:v,onResume:w,onTrigger:x,onDelete:y,onMarkRead:z,onUpdateTask:A}){let{t:B}=(0,g.Bd)(),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(null),G=(0,f.useRef)(null),H=(0,f.useRef)(null),[I,J]=(0,f.useState)(null),K=(0,f.useCallback)(()=>{F(null),G.current=null,J(null)},[]),[L,M]=(0,f.useState)(null),[N,O]=(0,f.useState)(null),[P,Q]=(0,f.useState)(null),[R,S]=(0,f.useState)(null),T=b.filter(a=>!a.completed),U=T.filter(a=>!a.paused).length,V=(0,f.useMemo)(()=>(function(a){let b=[],c=[],d=[];for(let e of a)e.unread||e.completed?b.push(e):e.paused?d.push(e):c.push(e);return b.sort((a,b)=>Number(!!b.unread)-Number(!!a.unread)||s(b)-s(a)),c.sort((a,b)=>(a.nextFireTime||Number.MAX_SAFE_INTEGER)-(b.nextFireTime||Number.MAX_SAFE_INTEGER)),d.sort((a,b)=>s(b)-s(a)),{pendingReview:b,upcoming:c,paused:d}})(b),[b]),W=P?b.find(a=>a.id===P)??null:null,[,X]=(0,f.useState)(0),Y=(0,f.useCallback)(()=>{M(null),O(null)},[]),Z=(0,f.useCallback)(async a=>{let b=!!a.taskFile;try{await navigator.clipboard.writeText(b?a.taskFile:a.message),(0,i.oR)(B(b?"common.copiedPath":"toast.copiedMessage"),"success")}catch{(0,i.oR)(B("common.copyFailed"),"error")}},[B]),$=(0,f.useCallback)(()=>{D(!1),Q(null)},[]),_=(0,f.useCallback)(a=>{q(a.cwd,a.sessionId),a.unread&&z(a.id),$()},[q,z,$]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{onClick:()=>D(!0),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${a?"w-full justify-center":"w-full"}`,title:a?B("scheduledTasks.title"):void 0,children:[(0,e.jsx)(h.A,{className:"w-5 h-5 flex-shrink-0"}),!a&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:B("scheduledTasks.title")}),c>0?(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 bg-orange-11/15 text-orange-11 text-xs font-medium rounded-full flex items-center justify-center ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,e.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-popover border border-border",children:b.length}):null]}),C&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:$}),(0,e.jsxs)("div",{className:j.aO,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:B("scheduledTasks.title")}),T.length>0&&(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[B("scheduledTasks.activeCount",{running:U}),T.length-U>0?` \xb7 ${B("scheduledTasks.pausedCount",{paused:T.length-U})}`:""]})]}),(0,e.jsx)("button",{onClick:$,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 flex min-h-0",children:0===b.length?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:B("scheduledTasks.noScheduledTasks")})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-full md:w-[360px] min-h-0 flex-shrink-0 md:border-r border-border overflow-y-auto",children:(0,e.jsx)("div",{className:"p-3 space-y-4",children:u.map(({key:a,labelKey:b})=>{let c=V[a];return 0===c.length?null:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"sticky top-0 z-10 -mx-3 px-3 py-1 bg-card text-[11px] font-medium text-muted-foreground",children:[B(b)," (",c.length,")"]}),(0,e.jsx)("div",{className:"mt-1 space-y-2",children:c.map(a=>{let b,c;return b=a.id===P,(0,e.jsxs)("div",{onClick:()=>Q(a.id),onMouseLeave:()=>S(b=>b===a.id?null:b),className:`group p-3 rounded border cursor-pointer transition-all hover:border-brand hover:shadow-lv2 ${b?"border-brand bg-brand/5 shadow-lv2":a.unread?"border-brand/40 bg-brand/5":"border-border"} ${a.completed?"opacity-70":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)(n.S,{engine:r(a),tooltip:(c=r(a),a.model?`${c} \xb7 ${a.model}`:c)}),(0,e.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":a.cwd,children:(0,k.P_)(a.cwd)}),(0,e.jsx)(o.l,{coordinate:d?.[`${a.cwd}
730
- ${a.sessionId}`]}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0 group-hover:hidden",children:a.completed?B("scheduledTasks.completed"):a.paused?B("scheduledTasks.paused"):B("common.running")}),R===a.id?(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),S(null),y(a.id)},className:"px-2 py-0.5 text-[10px] rounded bg-red-9 text-white hover:bg-red-10",children:B("common.confirm")}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),S(null)},className:"px-2 py-0.5 text-[10px] rounded border border-border text-muted-foreground hover:text-foreground",children:B("common.cancel")})]}):(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.taskFile&&(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),M(a.taskFile)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:B("common.preview"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),Z(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:B(a.taskFile?"common.copyPath":"common.copy"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),x(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:B("scheduledTasks.runNow"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),G.current=b.currentTarget,F(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:B("common.edit"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.completed?null:a.paused?(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-11",title:B("scheduledTasks.resume"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),v(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-amber-11",title:B("scheduledTasks.pause"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),S(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:B("common.delete"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"text-xs text-foreground line-clamp-3 mb-1 whitespace-pre-wrap break-words","data-tooltip":(0,k.Q_)(a),children:(0,k.Q_)(a)}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate",children:function(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}(a,B)}),(0,e.jsx)("span",{children:"\xb7"}),(0,e.jsx)("span",{className:"flex-shrink-0",children:a.completed?"success"===a.lastResult?B("scheduledTasks.success"):B("scheduledTasks.failure"):a.paused?B("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,B)}),!a.completed&&a.lastFiredAt&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{children:"\xb7"}),(0,e.jsxs)("span",{className:"flex-shrink-0",children:[B("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]},a.id)})})]},a)})})}),(0,e.jsx)("div",{className:"hidden md:flex flex-1 min-w-0",children:W?(0,e.jsx)(p.x,{task:W,onOpenSession:()=>_(W)},W.id):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-xs text-muted-foreground",children:B("scheduledTasks.selectTaskHint")})})]})})]})]}),L&&null!==N&&(0,e.jsx)(m.x,{filePath:L,content:N,cwd:L.slice(0,Math.max(0,L.lastIndexOf("/"))),onClose:Y,zClassName:"z-[80]"}),E&&(0,e.jsx)("div",{ref:H,className:"fixed z-[100]",style:{top:I?.top??0,left:I?.left??0,visibility:I?"visible":"hidden"},children:(0,e.jsx)(l.E,{onClose:K,onCreate:()=>{},editTask:{id:E.id,message:E.message,taskFile:E.taskFile,type:E.type,delayMinutes:E.delayMinutes,intervalMinutes:E.intervalMinutes,activeFrom:E.activeFrom,activeTo:E.activeTo,cron:E.cron},onUpdate:(a,b)=>{A(a,b),K()}})})]})}d()}catch(a){d(a)}})},75310:(a,b,c)=>{"use strict";function d(a,b){let c=`/project?cwd=${encodeURIComponent(a)}`;return b?.sessionId?(c+=`&sessionId=${encodeURIComponent(b.sessionId)}`,b.switchToAgent&&(c+="&view=agent")):b?.blank&&(c+="&newChat=1"),c}c.d(b,{f:()=>d})},75513:(a,b,c)=>{"use strict";c.d(b,{k_:()=>h,nH:()=>i});var d=c(48249),e=c(67484),f=c(7031);let g=(0,e.createContext)(null);function h({children:a}){let b=(0,e.useRef)(new Map),c=(0,e.useRef)(null),[i,j]=(0,e.useState)(()=>new Set),k=i.size>0,l=(0,e.useCallback)((a,b)=>{j(c=>{if(b===c.has(a))return c;let d=new Set(c);return b?d.add(a):d.delete(a),d})},[]),m=(0,e.useCallback)((a,c)=>{b.current.set(c,a)},[]),n=(0,e.useCallback)(a=>{b.current.delete(a),j(b=>{if(!b.has(a))return b;let c=new Set(b);return c.delete(a),c})},[]),o=(0,e.useCallback)(a=>{c.current=a},[]),p=(0,e.useCallback)(a=>{let d=c.current;if(!d)return void console.warn("No active tab to send message");let e=b.current.get(d);e?e(a):console.warn(`No chat sender registered for tab ${d}`)},[]),q=(0,e.useCallback)((a,c)=>{let d=b.current.get(a);return d?(d(c),!0):(console.warn(`No chat sender registered for tab ${a}`),!1)},[]),r=(0,e.useMemo)(()=>({sendMessage:p,sendToTab:q,isLoading:k,registerChat:m,unregisterChat:n,setActiveTab:o,setChatLoading:l}),[p,q,k,m,n,o,l]),s=(0,e.useMemo)(()=>({sendMessage:p,isLoading:k}),[p,k]);return(0,d.jsx)(g.Provider,{value:r,children:(0,d.jsx)(f.H,{value:s,children:a})})}function i(){return(0,e.useContext)(g)}},76306:(a,b,c)=>{"use strict";c.d(b,{V:()=>g});var d=c(57031),e=c(88214);let f={isFramed:()=>window.parent!==window,publishOpenProject:a=>(0,d.F)(e.n.OpenProject,a),navigate:a=>window.location.assign(a)};function g(a,b,c=f){c.isFramed()?c.publishOpenProject({cwd:a.cwd,sessionId:a.sessionId,switchToAgent:!0}):c.navigate(b)}},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>q,metadata:()=>o,viewport:()=>p});var d=c(5735),e=c(30768),f=c.n(e),g=c(93868),h=c.n(g),i=c(83503),j=c.n(i),k=c(29021),l=c(33873);c(61135);var m=c(25702);let n="";try{n=(0,k.readFileSync)((0,l.join)(process.cwd(),"public","boot.js"),"utf8")}catch{}let o={title:"OpenCockpit",description:"OpenCockpit is a local-first AI development hub with chat agents, a file explorer, terminals, and browser bubbles in one swipeable workspace. One seat. One AI.",appleWebApp:{capable:!0,statusBarStyle:"default",title:"Cockpit"},icons:{icon:"/icons/icon-192x192.png",apple:"/icons/icon-192x192.png"}},p={themeColor:[{media:"(prefers-color-scheme: light)",color:"#f9f9fb"},{media:"(prefers-color-scheme: dark)",color:"#111113"}]};function q({children:a}){return(0,d.jsxs)("html",{lang:"en",suppressHydrationWarning:!0,className:"overflow-hidden",children:[(0,d.jsxs)("head",{children:[(0,d.jsx)("script",{dangerouslySetInnerHTML:{__html:n}}),(0,d.jsx)("script",{dangerouslySetInnerHTML:{__html:`window.__COCKPIT_BUILD_ID__=${JSON.stringify(process.env.COCKPIT_BUILD_ID??null)};window.__COCKPIT_FORCE_UPDATE__=${JSON.stringify("1"===process.env.COCKPIT_FORCE_UPDATE_BADGE)}`}})]}),(0,d.jsx)("body",{className:`${f().variable} ${h().variable} ${j().variable} antialiased overflow-hidden`,children:(0,d.jsx)(m.Providers,{children:a})})]})}},76855:(a,b,c)=>{"use strict";c.d(b,{Sn:()=>i,Xm:()=>j,po:()=>k,JL:()=>l});var d=c(67484);c(28797);var e=c(79606),f=c(33281),g=c(71192);let h=(a,b)=>e.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new g.uV({message:`${a} failed`,cause:b})});function i(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);let g=await f.t4.runPromiseExit(h("/api/lsp/definition",{cwd:a,filePath:b,line:d,column:e}));return(c(!1),"Success"===g._tag)?g.value.definitions??[]:(console.error("[useLSP] definition error:",g.cause),[])},[a]),loading:b}}function j(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),g=(0,d.useRef)(null),i=(0,d.useRef)(0),j=(0,d.useRef)(!1),k=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),m=(0,d.useCallback)(a=>{k.current=a},[]),n=(0,d.useRef)(!1),o=(0,d.useRef)(null),p=(0,d.useCallback)(()=>{let a=k.current;a&&n.current&&(a.style.pointerEvents="none"),n.current=!1,o.current&&(k.current?.removeEventListener("mouseleave",o.current),o.current=null)},[]),q=(0,d.useCallback)(()=>{let a=k.current;if(!a||n.current)return;n.current=!0,j.current=!0,a.style.pointerEvents="auto";let b=()=>{j.current=!1,p(),i.current++,c(null)};o.current=b,a.addEventListener("mouseleave",b)},[p]),r=(0,d.useCallback)((b,d,j,k)=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current);let l=++i.current;e.current=setTimeout(async()=>{let e=await f.t4.runPromiseExit(h("/api/lsp/hover",{cwd:a,filePath:b,line:d,column:j}));if(l!==i.current||"Success"!==e._tag)return;let g=e.value.hover;g&&g.displayString&&c({...g,x:k.x,y:k.y,filePath:b,line:d,column:j})},300)},[a]),s=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),i.current++,g.current=setTimeout(function(){if(j.current)return;let a=k.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=l.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void q()}c(null)},150)},[q]),t=(0,d.useCallback)(()=>{j.current=!0,g.current&&clearTimeout(g.current)},[]);return{hoverInfo:b,onTokenMouseEnter:r,onTokenMouseLeave:s,onCardMouseEnter:t,onCardMouseLeave:(0,d.useCallback)(()=>{j.current=!1,i.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current),j.current=!1,p(),i.current++,c(null)},[p]),setTooltipEl:m}}function k(a){let[b,c]=(0,d.useState)([]),[e,g]=(0,d.useState)(!1),[i,j]=(0,d.useState)(!1);return{references:b,loading:e,visible:i,findReferences:(0,d.useCallback)(async(b,d,e)=>{g(!0),j(!0);let i=await f.t4.runPromiseExit(h("/api/lsp/references",{cwd:a,filePath:b,line:d,column:e}));"Success"===i._tag?c(i.value.references??[]):(console.error("[useLSP] references error:",i.cause),c([])),g(!1)},[a]),closeReferences:(0,d.useCallback)(()=>{j(!1),c([])},[])}}function l(a,b){(0,d.useRef)(null)}},77120:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{SessionBrowser:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(15819),i=c(57031),j=c(88214),k=c(33281),l=c(65484),m=c(74228),n=c(32753);function o({isOpen:a,onClose:b,onSelectSession:c,onAddProject:d,sessionNumbers:p={},projectNumbers:q={}}){let{t:r}=(0,g.Bd)(),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)([]),[w,x]=(0,f.useState)({}),[y,z]=(0,f.useState)(!1),[A,B]=(0,f.useState)(null),[C,D]=(0,f.useState)(""),E=(0,f.useRef)(null);(0,f.useCallback)(async()=>{z(!0),B(null),x({});let a=await k.t4.runPromiseExit((0,l.H7)());"Success"===a._tag?v(a.value):B("Failed to load projects"),z(!1)},[]);let F=(0,f.useCallback)(async a=>{x(b=>({...b,[a]:{...b[a],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));let b=await k.t4.runPromiseExit((0,l.QW)(a));"Success"===b._tag?x(c=>({...c,[a]:{...c[a],isLoading:!1,sessions:b.value}})):x(b=>({...b,[a]:{...b[a],isLoading:!1,error:"Failed to load sessions"}}))},[]),G=(0,f.useCallback)(a=>{let b=w[a];b?.isExpanded?x(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?x(b=>({...b,[a]:{...b[a],isExpanded:!0}})):F(a)},[w,F]),H=(0,f.useCallback)(async()=>{if(s)return;t(!0);let a=await k.t4.runPromiseExit((0,l.It)());"Success"===a._tag&&a.value.folder&&d&&(d(a.value.folder),b()),t(!1)},[s,d,b]);return a?(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,e.jsxs)("div",{className:h.aO,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("sessions.projectList")}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("input",{ref:E,type:"text",placeholder:r("workspace.searchProjectPath"),value:C,onChange:a=>D(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),C&&(0,e.jsx)("button",{onClick:()=>{D(""),E.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:r("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),d&&(0,e.jsxs)("button",{onClick:H,disabled:s,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:[(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),s?r("sessions.selectingFolder"):r("sessions.openFolder")]}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[y&&(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,e.jsx)("span",{children:r("workspace.loadingProjects")})]})}),A&&(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:A})}),!y&&!A&&0===u.length&&(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:r("workspace.projectNotFound")})}),!y&&!A&&u.filter(a=>a.fullPath.toLowerCase().includes(C.toLowerCase())).map(a=>{let b=w[a.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null},d=q[a.fullPath];return(0,e.jsxs)("div",{className:"mb-3",children:[(0,e.jsxs)("button",{onClick:()=>G(a.encodedPath),className:"w-full flex items-center gap-2 p-2 rounded hover:bg-hover transition-colors text-left",children:[(0,e.jsx)("svg",{className:`w-3 h-3 text-muted-foreground transition-transform ${b.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),d&&(0,e.jsx)(m.l,{projectNumber:d}),(0,e.jsx)("span",{className:"flex-1 text-xs font-medium text-foreground truncate","data-tooltip":a.fullPath,children:a.fullPath}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a.sessionCount,")"]})]}),b.isExpanded&&(0,e.jsxs)("div",{className:"ml-6 mt-2",children:[b.isLoading&&(0,e.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-3 w-3",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,e.jsx)("span",{children:r("sessions.loadingSessions")})]}),b.error&&(0,e.jsx)("div",{className:"p-3 text-xs text-red-11",children:b.error}),!b.isLoading&&!b.error&&(0,e.jsx)("div",{className:h.jL,children:b.sessions.map(b=>{var d;let f=b.path.split("/").pop()||"",g=b.sessionId||f.replace(".jsonl",""),h=p[`${a.fullPath}
731
- ${g}`],[k,l]=h?.split(".")??[];return(0,e.jsxs)("div",{onClick:()=>{var d;let e,f;return d=a.fullPath,e=b.path.split("/").pop()||"",f=b.sessionId||e.replace(".jsonl",""),void(c?c(d,f):(0,i.F)(j.n.OpenProject,{cwd:d,sessionId:f}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)(n.S,{engine:b.engine}),(0,e.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":b.title,children:b.title}),h&&(0,e.jsx)(m.l,{projectNumber:k,sessionNumber:l,className:"ml-auto"})]}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:(d=b.modifiedAt,new Date(d).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}))}),(0,e.jsxs)("div",{className:"space-y-0.5 text-xs",children:[b.firstMessages.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),b.lastMessages.length>0&&(0,e.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),b.lastMessages.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]})]},b.path)})})]})]},a.encodedPath)})]})]})]}):null}d()}catch(a){d(a)}})},77156:(a,b,c)=>{"use strict";c.d(b,{Bz:()=>j,Hy:()=>g,L5:()=>h,hp:()=>i});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/skills"),h=a=>f("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),j=a=>f(`/api/skills/content?id=${encodeURIComponent(a)}`)},77220:(a,b,c)=>{"use strict";c.d(b,{SettingsModal:()=>n});var d=c(48249),e=c(67484),f=c(44384),g=c(83768),h=c(7833),i=c(28602),j=c(15105),k=c(33281),l=c(79606),m=c(65484);function n({isOpen:a,onClose:b}){let{t:c,i18n:o}=(0,f.Bd)(),{theme:p,setTheme:q}=(0,g.DP)(),r=(0,j.G)(),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)("auto"),A=(0,e.useCallback)(a=>{z(a),k.t4.runFork((0,m.DZ)({language:a}).pipe(l.NWQ(()=>l.rIH)));let b="auto"===a?navigator.language.startsWith("zh")?"zh":"en":a;o.changeLanguage(b)},[o]),B=r?"installed":"not-installed",C=r?.version??null;if(!a)return null;let D=[{value:"system",label:c("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:c("settings.themeLight"),icon:"☀️"},{value:"dark",label:c("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-2xl mx-4 overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:c("settings.title")}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{className:"p-4 space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.theme")}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:D.map(a=>(0,d.jsxs)("button",{onClick:()=>q(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${p===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"text-xl",children:a.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.language")}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:c("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(a=>(0,d.jsxs)("button",{onClick:()=>A(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${y===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"text-xl",children:a.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.browserExtension")}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===B?"bg-green-500":"bg-slate-400"}`}),(0,d.jsxs)("span",{children:["installed"===B&&`${c("settings.extensionInstalled")}${C?` (v${C})`:""}`,"not-installed"===B&&c("settings.extensionNotInstalled")]})]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:c("settings.extensionDescription")}),"installed"!==B&&(0,d.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,d.jsx)("p",{className:"font-medium text-foreground",children:c("settings.installSteps")}),(0,d.jsxs)("p",{children:[c("settings.step1")," ",(0,d.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,d.jsx)("p",{children:c("settings.step2")}),(0,d.jsx)("p",{children:c("settings.step3")}),(0,i.L)()&&(0,d.jsx)("p",{dangerouslySetInnerHTML:{__html:c("settings.step4mac")}})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:()=>{let a=s||"chrome-extension";navigator.clipboard.writeText(a),(0,h.oR)(c("toast.copiedName",{name:a}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:c("settings.copyExtensionPath")}),"installed"===B&&(0,d.jsx)("button",{onClick:()=>{r?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(r.id,{type:"reload"}),(0,h.oR)(c("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:c("settings.reloadExtension")})]}),s&&(0,d.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:s})]})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.about")}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,d.jsxs)("p",{children:["Cockpit",u?` v${u}`:""]}),(w?.claude||w?.codex)&&(0,d.jsx)("p",{className:"text-muted-foreground/60",children:[w.claude&&`Claude Code ${w.claude}`,w.codex&&`Codex ${w.codex}`,c("settings.agentsBundled")].filter(Boolean).join(" \xb7 ")}),(0,d.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}},77462:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>K});var e=c(48249),f=c(67484),g=c(44384),h=c(14222),i=c(43209),j=c(70151),k=c(6900),l=c(85905),m=c(32465),n=c(75513),o=c(57632),p=c(79327),q=c(39796),r=c(94192),s=c(44256),t=c(82634),u=c(38878),v=c(3588),w=c(92340),x=c(52490),y=c(18946),z=c(29939),A=c(98982),B=c(13054),C=c(79606),D=c(23734),E=c(88214),F=c(33281),G=c(65484);c(37388);var H=a([u,v,y,o,j]);function I(a,b){if(!b.split)return{};let c=b.panes.indexOf(a);return -1===c?{}:{peerTabId:b.panes[1-c],peerSide:0===c?"right":"left"}}function J({tabId:a,panes:b,activePane:c,row:d,maximized:f,onFocusPane:h,onClosePane:i,onToggleMaximize:j,children:k}){let{t:l}=(0,g.Bd)(),m=b.indexOf(a),n=b.length>1;return(0,e.jsxs)("div",{onMouseDownCapture:n?()=>h(m):void 0,style:d&&-1!==m&&!f?{order:m}:void 0,className:`group/pane ${(0,q.vZ)(a,b,c,d,f)}`,children:[n&&-1!==m&&(0,e.jsxs)("div",{className:"absolute top-1 right-1 z-20 flex items-center gap-0.5 opacity-0 pointer-events-none transition-opacity focus-within:opacity-100 focus-within:pointer-events-auto group-hover/pane:opacity-100 group-hover/pane:pointer-events-auto",children:[(0,e.jsx)("button",{type:"button",onClick:()=>j(m),title:l(f?"chat.restorePane":"chat.maximizePane"),"aria-label":l(f?"chat.restorePane":"chat.maximizePane"),"aria-pressed":f,className:"flex items-center justify-center w-6 h-6 text-muted-foreground transition-colors hover:text-foreground",children:f?(0,e.jsx)(w.A,{className:"w-3.5 h-3.5"}):(0,e.jsx)(x.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:()=>i(m),title:l("chat.closePane"),"aria-label":l("chat.closePane"),className:"flex items-center justify-center w-6 h-6 text-muted-foreground transition-colors hover:text-foreground",children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),k]})}function K({initialCwd:a,initialSessionId:b,initialBlank:c,initialView:d}){let{t:w}=(0,g.Bd)(),[x,H]=(0,f.useState)(d??"agent"),[L,M]=(0,f.useState)(null),{tabs:N,activeTabId:O,activeTab:P,paneTabIds:Q,activePane:R,toggleSideBySide:S,focusPane:T,closePane:U,unreadTabs:V,globalLoadingTabs:W,pageVisible:X,dragTabIndex:Y,dragOverTabIndex:Z,closeTab:$,closeAllTabs:_,switchTab:aa,handleSelectSession:ab,handleNewTab:ac,handleNewCodexTab:ad,handleNewKimiTab:ae,handleNewGlmTab:af,handleNewOllamaTab:ag,handleNewDeepseekTab:ah,handleOpenSession:ai,updateTabState:aj,updateTabEngine:ak,updateTabOllamaModel:al,updateTabDeepseekModel:am,updateTabKimiModel:an,updateTabGlmModel:ao,updateTabClaudeModel:ap,updateTabClaudeEffort:aq,updateTabClaudeContextWindow:ar,updateTabClaudeFastMode:as,updateTabClaudeThinking:at,updateTabCodexModel:au,updateTabCodexReasoningEffort:av,updateTabPlanMode:aw,updateTabNoHistory:ax,handleTabDragStart:ay,handleTabDragOver:az,handleTabDrop:aA,handleTabDragEnd:aB}=(0,t.useTabState)({initialCwd:a,initialSessionId:b,initialBlank:c,activeView:x}),{isPinned:aC,pinSession:aD,unpinSession:aE}=(0,A.P)(),{createTask:aF}=(0,B.nS)(),aG=(0,f.useCallback)(a=>{let b=N.find(b=>b.id===a);return!!b?.sessionId&&aC(b.sessionId)},[N,aC]),aH=(0,f.useCallback)(b=>{let c=N.find(a=>a.id===b);c?.sessionId&&(aC(c.sessionId)?aE(c.sessionId):aD(c.sessionId,c.cwd||a||"",c.title))},[N,aC,aD,aE,a]),[aI,aJ]=(0,f.useState)(!1),[aK,aL]=(0,f.useState)(!1),[aM,aN]=(0,f.useState)(!1),[aO,aP]=(0,f.useState)(null),[aQ,aR]=(0,f.useState)(!1),[aS,aT]=(0,f.useState)("tree"),[aU,aV]=(0,f.useState)(0),[aW,aX]=(0,f.useState)(null),[aY,aZ]=(0,f.useState)(0),[a$,a_]=(0,f.useState)(null),[a0,a1]=(0,f.useState)(null),a2=null!==a0,a3=(0,f.useMemo)(()=>(0,q.p_)(Q,R,O,a2),[Q,R,O,a2]),[a4,a5]=(0,f.useState)(null),[a6,a7]=(0,f.useState)(),[a8,a9]=(0,f.useState)(!1);(0,f.useRef)(null);let ba=(0,f.useCallback)(b=>{H(b),a&&(F.t4.runFork((0,G.Yn)({cwd:a,settings:{activeView:b}}).pipe(C.NWQ(()=>C.rIH))),F.t4.runFork(C.qIB(D.d,c=>c.publish(E.n.ViewChange,{cwd:a,view:b}))))},[a]),bb=(0,f.useCallback)(async()=>{if(!a)return;let b=await F.t4.runPromiseExit((0,G.b2)(a));if("Success"===b._tag){let c=b.value;if(aR(!!c.isGitRepo),c.isGitRepo&&c.worktrees&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&aP(b.branch)}}else console.error("Failed to load git info:",b.cause)},[a]),bc=(0,f.useCallback)(a=>{let{data:b}=a;Array.isArray(b)&&b.some(a=>"git"===a.type)&&bb()},[bb]);(0,z.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:bc,enabled:!!a});let bd=(0,f.useCallback)(()=>{aT("status"),aV(a=>a+1),ba("explorer")},[ba]),be=(0,f.useCallback)(a=>{aX(a),aZ(a=>a+1),ba("explorer")},[ba]),bf=(0,f.useCallback)(()=>ba("agent"),[ba]),[bg,bh]=(0,f.useState)(!1),[bi,bj]=(0,f.useState)(!1),bk=(0,q.XL)(a3,bi),bl=(0,f.useCallback)(a=>{bj(a=>!a),T(a)},[T]),bm=(0,f.useCallback)(()=>bh(a=>!a),[]),bn=(0,f.useCallback)(()=>a1(null),[]),bo=(0,f.useRef)(a2),bp=(0,f.useRef)(bk),bq=(0,f.useCallback)(()=>{bo.current?bn():null!==bp.current?bj(!1):S()},[S,bn]),br=(0,f.useCallback)((a,b,c,d,e)=>{a1(f=>(0,p.y)(f,{messageId:a,toolCalls:b,cwd:c,sessionId:d},!0===e)),e||ba("agent")},[ba]),bs=(0,f.useCallback)(a=>{a_({...a,nonce:Date.now()}),ba("explorer")},[ba]),bt=(0,f.useCallback)(()=>{a&&F.t4.runFork(C.qIB(D.d,b=>b.publish(E.n.OpenNote,{cwd:a})))},[a]);return(0,e.jsx)(n.k_,{children:(0,e.jsx)(r.fY,{activeView:x,onViewChange:ba,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(u.TabManagerTopBar,{initialCwd:a,activeTab:P,isGitRepo:aQ,currentBranch:aO,onOpenWorktree:()=>aL(!0),onOpenAliasManager:()=>aN(!0),onBranchSwitched:bb}),a8&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),w("console.screenshotting")]}),a?(0,e.jsxs)(r.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(s.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(v.TabBar,{tabs:N,selectedTabId:O,sideBySide:a3.split,onToggleSideBySide:bq,unreadTabs:V,globalLoadingTabs:W,dragTabIndex:Y,dragOverTabIndex:Z,isPinned:aG,onSwitchTab:aa,onCloseTab:$,onCloseAllTabs:_,onNewTab:ac,onNewCodexTab:ad,onNewKimiTab:ae,onNewGlmTab:af,onNewOllamaTab:ag,onNewDeepseekTab:ah,onOpenProjectSessions:()=>aJ(!0),onDragStart:ay,onDragOver:az,onDrop:aA,onDragEnd:aB}),(0,e.jsx)(h.c,{value:a3.split?L:null,children:(0,e.jsxs)("div",{className:`flex-1 overflow-hidden relative ${a3.row?"flex":""}`,children:[N.map(a=>(0,e.jsx)(J,{tabId:a.id,panes:a3.panes,activePane:a3.activePane,row:a3.row,maximized:bk===a.id,onFocusPane:T,onClosePane:U,onToggleMaximize:bl,children:(0,e.jsx)(y.X,{tabId:a.id,...I(a.id,a3),cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:ak,ollamaModel:a.ollamaModel,onOllamaModelChange:al,deepseekModel:a.deepseekModel,onDeepseekModelChange:am,kimiModel:a.kimiModel,onKimiModelChange:an,glmModel:a.glmModel,onGlmModelChange:ao,claudeModel:a.claudeModel,onClaudeModelChange:ap,claudeEffort:a.claudeEffort,onClaudeEffortChange:aq,claudeContextWindow:a.claudeContextWindow,onClaudeContextWindowChange:ar,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:as,claudeThinking:a.claudeThinking,onClaudeThinkingChange:at,codexModel:a.codexModel,onCodexModelChange:au,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:av,planMode:a.planMode,onPlanModeChange:aw,noHistory:a.noHistory,onNoHistoryChange:ax,isActive:(0,q.gF)(a.id,Q,"agent"===x,X),isFocused:a.id===O,refreshSignal:a4,onStateChange:aj,onShowGitStatus:bd,onContentSearch:be,onShowFileDiff:br,onOpenFileLink:bs,onOpenNote:bt,isFavorite:aG(a.id),onToggleFavorite:aH,onCreateScheduledTask:aF,onOpenSession:ai})},a.id)),a0&&(0,e.jsx)("div",{className:bg?"absolute inset-0 z-30 bg-card":"h-full flex-1 min-w-0 border-l border-border",style:bg?void 0:{order:a3.diffOrder},children:(0,e.jsx)(o.e$,{toolCalls:a0.toolCalls,cwd:a0.cwd,sessionId:a0.sessionId,onClose:bn,onContentSearch:be,fullscreen:bg,onToggleFullscreen:bm},a0.messageId)})]})}),a3.split&&(0,e.jsx)("div",{ref:M,className:"flex-shrink-0"})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden relative",children:(0,e.jsx)(s.a9,{children:(0,e.jsx)(j.g,{onClose:bf,cwd:a,initialTab:aS,tabSwitchTrigger:aU,initialSearchQuery:aW,searchQueryTrigger:aY,fileOpenRequest:a$})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(s.a9,{children:(0,e.jsx)(l.J,{cwd:a,tabId:"default",onOpenNote:bt})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(v.TabBar,{tabs:N,selectedTabId:O,sideBySide:a3.split,onToggleSideBySide:bq,unreadTabs:V,globalLoadingTabs:W,dragTabIndex:Y,dragOverTabIndex:Z,isPinned:aG,onSwitchTab:aa,onCloseTab:$,onCloseAllTabs:_,onNewTab:ac,onNewCodexTab:ad,onNewKimiTab:ae,onNewGlmTab:af,onNewDeepseekTab:ah,onDragStart:ay,onDragOver:az,onDrop:aA,onDragEnd:aB}),(0,e.jsx)(h.c,{value:a3.split?L:null,children:(0,e.jsx)("div",{className:`flex-1 overflow-hidden relative ${a3.row?"flex":""}`,children:N.map(a=>(0,e.jsx)(J,{tabId:a.id,panes:a3.panes,activePane:a3.activePane,row:a3.row,maximized:bk===a.id,onFocusPane:T,onClosePane:U,onToggleMaximize:bl,children:(0,e.jsx)(y.X,{tabId:a.id,...I(a.id,a3),cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:ak,ollamaModel:a.ollamaModel,onOllamaModelChange:al,deepseekModel:a.deepseekModel,onDeepseekModelChange:am,kimiModel:a.kimiModel,onKimiModelChange:an,glmModel:a.glmModel,onGlmModelChange:ao,claudeModel:a.claudeModel,onClaudeModelChange:ap,claudeEffort:a.claudeEffort,onClaudeEffortChange:aq,claudeContextWindow:a.claudeContextWindow,onClaudeContextWindowChange:ar,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:as,claudeThinking:a.claudeThinking,onClaudeThinkingChange:at,codexModel:a.codexModel,onCodexModelChange:au,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:av,planMode:a.planMode,onPlanModeChange:aw,noHistory:a.noHistory,onNoHistoryChange:ax,isActive:(0,q.gF)(a.id,Q,!0,X),isFocused:a.id===O,refreshSignal:a4,onStateChange:aj,isFavorite:aG(a.id),onToggleFavorite:aH,onCreateScheduledTask:aF,onOpenSession:ai})},a.id))})}),a3.split&&(0,e.jsx)("div",{ref:M,className:"flex-shrink-0"})]})]}),a&&(0,e.jsx)(i.Q,{isOpen:aI,onClose:()=>aJ(!1),cwd:a,onSelectSession:ab,projectNumber:a6,openSessionIds:N.map(a=>a.sessionId)}),a&&aQ&&(0,e.jsx)(k.x,{isOpen:aK,onClose:()=>aL(!1),cwd:a}),aM&&(0,e.jsx)(m.Y,{onClose:()=>aN(!1),onSave:()=>aN(!1)})]})})})}[u,v,y,o,j]=H.then?(await H)():H,d()}catch(a){d(a)}})},79327:(a,b,c)=>{"use strict";function d(a,b,c){return c?a?.messageId!==b.messageId?a:{...a,toolCalls:b.toolCalls}:b}c.d(b,{y:()=>d})},80118:(a,b,c)=>{"use strict";c.d(b,{R:()=>j});var d=c(66142),e=c(10259),f=c(37361);let g=new e.hs("headingFold");function h(a){let b=a.attrs.foldState;return"folded"===b||"children"===b?b:"expanded"}function i(a){let b=[],c=[];return a.forEach((a,d)=>{let e=d+a.nodeSize;if("heading"===a.type.name){let g=a.attrs.level;for(;c.length&&c[c.length-1].level>=g;)c.pop();let i=h(a),j=c.some(a=>"folded"===a.state),k=["note-heading"];"expanded"!==i&&k.push("is-collapsed"),j&&k.push("note-folded-hidden"),b.push(f.NZ.node(d,e,{class:k.join(" ")})),b.push(f.NZ.widget(d+1,(a,b)=>{let c;return(c=document.createElement("span")).className="note-fold-toggle",c.contentEditable="false",c.setAttribute("data-fold-state",i),c.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation();let d=b();if(null==d)return;let e=d-1,f=a.state.doc.nodeAt(e);f&&"heading"===f.type.name&&a.dispatch(a.state.tr.setNodeMarkup(e,void 0,{...f.attrs,foldState:"expanded"===h(f)?"folded":"expanded"}))}),c},{side:-1,key:`fold-${d}-${i}`})),c.push({level:g,state:i})}else c.some(a=>"folded"===a.state||"children"===a.state)&&b.push(f.NZ.node(d,e,{class:"note-folded-hidden"}))}),f.zF.create(a,b)}let j=d.A.extend({addAttributes(){return{...this.parent?.(),foldState:{default:"expanded",keepOnSplit:!1,parseHTML:a=>"true"===a.getAttribute("data-collapsed")?"folded":"expanded",renderHTML:a=>a.foldState&&"expanded"!==a.foldState?{"data-collapsed":"true"}:{}}}},addKeyboardShortcuts(){let a=this.name;return{Tab:()=>{var b;let c,d,e,{state:f}=this.editor,{$from:g}=f.selection;if(g.parent.type.name!==a)return!1;let i=g.before(g.depth),j=f.doc.nodeAt(i);if(!j||j.type.name!==a)return!1;let k=j.attrs.level,l=(b=f.doc,d=[],e=!1,b.forEach((b,c)=>{if(c===i){e=!0;return}if(e&&b.type.name===a){if(b.attrs.level<=k){e=!1;return}d.push(c)}}),d),m=l.length>0,n=h(j),o=null;return m?"expanded"===n?c="folded":(c="folded"===n?"children":"expanded",o="expanded"):c="expanded"===n?"folded":"expanded",this.editor.chain().command(({tr:b})=>{if(b.setNodeMarkup(i,void 0,{...j.attrs,foldState:c}),o)for(let c of l){let d=b.doc.nodeAt(c);d&&d.type.name===a&&b.setNodeMarkup(c,void 0,{...d.attrs,foldState:o})}return!0}).run()}}},addStorage:()=>({markdown:{serialize(a,b){a.write(a.repeat("#",b.attrs.level)+" "),a.renderInline(b,!1),"expanded"!==h(b)&&a.write(" \x3c!-- fold --\x3e"),a.closeBlock(b)},parse:{updateDOM(a){a.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(a=>{let b=a.lastChild;for(;b&&3===b.nodeType&&!(b.textContent||"").trim();){let c=b.previousSibling;a.removeChild(b),b=c}if(b&&8===b.nodeType&&/^\s*fold\s*$/.test(b.textContent||"")){let c=b.previousSibling;a.removeChild(b),c&&3===c.nodeType&&(c.textContent=(c.textContent||"").replace(/\s+$/,"")),a.setAttribute("data-collapsed","true")}})}}}}),addProseMirrorPlugins:()=>[new e.k_({key:g,state:{init:(a,{doc:b})=>i(b),apply:(a,b)=>a.docChanged?i(a.doc):b},props:{decorations:a=>g.getState(a)}})]})},80514:(a,b,c)=>{"use strict";c.d(b,{V:()=>S});var d=c(48249),e=c(67484),f=c(44384),g=c(16944),h=c(29588),i=c(3623),j=c(44256),k=c(7833);function l({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=async b=>{b.stopPropagation();try{var d;if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");let b=await (d=a.preview,new Promise((a,b)=>{let c=new Image;c.onload=()=>{let d=document.createElement("canvas");d.width=c.naturalWidth,d.height=c.naturalHeight;let e=d.getContext("2d");e?(e.drawImage(c,0,0),d.toBlob(c=>{c?a(c):b(Error("Could not encode image"))},"image/png")):b(Error("Canvas is unavailable"))},c.onerror=()=>b(Error("Could not load image")),c.src=d}));await navigator.clipboard.write([new ClipboardItem({"image/png":b})]),(0,k.oR)(c("imagePreview.copiedImage"),"success")}catch{(0,k.oR)(c("common.copyFailed"),"error")}},g=(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,d.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:e,className:"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",title:c("imagePreview.copyImage"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V5a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2M7 7h6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z"})})}),(0,d.jsx)("button",{type:"button",onClick:b,className:"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",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]});return(0,d.jsx)(j.ZL,{children:g})}function m({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[h,i]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>i(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),h&&(0,d.jsx)(l,{image:h,onClose:()=>i(null)})]})}var n=c(30458),o=c(74429),p=c(65032),q=c(44218),r=c(42742),s=c(33999),t=c(74118),u=c(12625),v=c(46674),w=c(19794),x=c(24520),y=c(76193),z=c(72529),A=c(33281),B=c(41224),C=c(57063);let D=()=>Math.random().toString(36).slice(2,10);function E(a){let b=[],c=null;for(let[d,e]of a.split(/\r?\n/).entries()){if(!e.trim())continue;let a=e.match(/^\s*-(?:\s+(.*))?$/);if(a){let b=(a[1]??"").trim();if(!c)return{ok:!1,line:d+1};c.isGroup=!0,b&&c.children.push(b);continue}if(/^\s/.test(e))return{ok:!1,line:d+1};let f=e.trim();f&&(c={text:f,children:[],isGroup:!1},b.push(c))}return{ok:!0,nodes:b.map(a=>a.isGroup?{id:D(),name:a.text,items:a.children.map(a=>({id:D(),text:a}))}:{id:D(),text:a.text})}}function F({title:a,nodes:b,onSave:c,onClose:g}){let{t:h}=(0,f.Bd)(),[i,k]=(0,e.useState)(()=>b.flatMap(a=>(0,B._9)(a)?[a.name,...a.items.length>0?a.items.map(a=>`- ${a.text}`):["- "]]:[a.text]).join("\n")),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(!1),p=E(i);(0,C.E)(g);let q=(0,e.useCallback)(async()=>{let a=E(i);!a.ok||l||((m(!0),o(!1),await c(a.nodes))?g():(m(!1),o(!0)))},[g,c,l,i]);return(0,d.jsx)(j.ZL,{children:(0,d.jsx)("div",{"data-quick-instruction-layer":"",className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onMouseDown:a=>{a.target===a.currentTarget&&g()},children:(0,d.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":a,className:"w-full max-w-4xl max-h-[90vh] bg-card border border-border rounded-xl shadow-lv3 flex flex-col",children:[(0,d.jsxs)("header",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:a}),(0,d.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h("chat.quickInstructionsMarkdownHint")})]}),(0,d.jsx)("button",{type:"button",onClick:g,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded","aria-label":h("common.cancel"),children:(0,d.jsx)(v.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 px-4 py-3",children:(0,d.jsx)("textarea",{autoFocus:!0,value:i,onChange:a=>k(a.target.value),placeholder:h("chat.quickInstructionsMarkdownPlaceholder"),rows:24,spellCheck:!1,className:"w-full h-[60vh] min-h-80 max-h-[70vh] resize-y px-3 py-2 text-sm font-mono leading-6 bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-brand"})}),(0,d.jsxs)("footer",{className:"flex items-center justify-between gap-3 px-4 py-3 border-t border-border",children:[(0,d.jsx)("span",{className:"text-xs text-destructive",children:p.ok?n?h("chat.saveQuickInstructionsFailed"):"":h("chat.quickInstructionsMarkdownError",{line:p.line})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:g,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground rounded hover:bg-hover",children:h("common.cancel")}),(0,d.jsx)("button",{type:"button",disabled:!p.ok||l,onClick:q,className:"px-3 py-1.5 text-xs rounded border border-brand text-brand hover:bg-brand/10 disabled:opacity-40",children:h(l?"chat.savingQuickInstructions":"common.save")})]})]})]})})})}let G="data-quick-instruction-layer",H=()=>Math.random().toString(36).slice(2,10);function I({groups:a,value:b,onChange:c,onSubmit:g,onCancel:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,s]=(0,e.useState)(0),t=(0,e.useRef)(null),u=(0,e.useRef)(null),v=[null,...a.map(a=>a.id)],w=null===b?i("chat.instructionGroupNone"):a.find(a=>a.id===b)?.name??i("chat.instructionGroupNone"),x=(0,e.useCallback)(()=>{let c=t.current?.getBoundingClientRect();c&&(m(((a,b,c)=>{let d=Math.min(a.width,c.width-16),e=Math.min(Math.max(8,a.left),Math.max(8,c.width-d-8)),f=c.height-a.bottom-2-8,g=a.top-2-8,h=28*b+8;if(f>=Math.min(h,96)||f>=g)return{left:e,top:a.bottom+2,width:d,maxHeight:Math.max(28,Math.min(h,f))};let i=Math.max(28,Math.min(h,g));return{left:e,top:a.top-2-i,width:d,maxHeight:i}})(c,a.length+1,{width:window.innerWidth,height:window.innerHeight})),s(Math.max(0,v.indexOf(b))),k(!0))},[a.length,v,b]),y=(0,e.useCallback)(()=>{k(!1),m(null),t.current?.focus()},[]),z=(0,e.useCallback)(a=>{c(a),y()},[c,y]),A=(0,e.useCallback)(a=>{j?"Escape"===a.key?(a.preventDefault(),a.stopPropagation(),y()):"ArrowDown"===a.key?(a.preventDefault(),a.stopPropagation(),s(a=>Math.min(v.length-1,a+1))):"ArrowUp"===a.key?(a.preventDefault(),a.stopPropagation(),s(a=>Math.max(0,a-1))):"Enter"===a.key&&(a.preventDefault(),a.stopPropagation(),z(v[n]??null)):"ArrowDown"===a.key||" "===a.key?(a.preventDefault(),a.stopPropagation(),x()):"Enter"===a.key?(a.preventDefault(),a.stopPropagation(),g()):"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),h())},[j,x,y,z,v,n,g,h]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{ref:t,type:"button",onClick:()=>j?y():x(),onKeyDown:A,className:"w-[140px] min-w-0 flex-shrink-0 px-2 py-1 flex items-center gap-1 text-xs rounded border border-input bg-background hover:bg-hover focus:outline-none focus:ring-1 focus:ring-ring transition-colors",title:i("chat.instructionGroupLabel"),children:[(0,d.jsx)(p.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:`flex-1 min-w-0 truncate text-left ${null===b?"text-muted-foreground":""}`,children:w}),(0,d.jsx)(q.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"})]}),j&&l&&(0,o.createPortal)((0,d.jsx)("div",{ref:u,[G]:"",role:"listbox",style:{left:l.left,top:l.top,width:l.width,maxHeight:l.maxHeight},className:"fixed z-[60] py-1 bg-popover border border-border rounded-lg shadow-lv2 overflow-y-auto",children:v.map((c,e)=>{let f=c===b;return(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":f,onClick:()=>z(c),onMouseEnter:()=>s(e),className:`w-full min-w-0 px-2 py-1 flex items-center gap-1.5 text-xs text-left transition-colors ${e===n?"bg-hover":""}`,children:[(0,d.jsx)(r.A,{className:`w-3 h-3 flex-shrink-0 ${f?"text-brand":"opacity-0"}`}),(0,d.jsx)("span",{className:`flex-1 min-w-0 truncate ${null===c?"text-muted-foreground":""}`,children:null===c?i("chat.instructionGroupNone"):a.find(a=>a.id===c)?.name})]},c??"__none__")})}),document.body)]})}function J({initialValue:a,placeholder:b,groupChoices:c,initialGroupId:f,onCommit:g,onCancel:h}){let[i,j]=(0,e.useState)(a),[k,l]=(0,e.useState)(f??null),m=(0,e.useCallback)(()=>{let a=i.trim();a&&g(a,k)},[i,k,g]),n=(0,e.useCallback)(a=>{"Enter"!==a.key||a.nativeEvent.isComposing?"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),h()):(a.preventDefault(),a.stopPropagation(),m())},[m,h]);return(0,d.jsxs)("div",{className:"mb-1 flex items-center gap-1",children:[(0,d.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),onKeyDown:n,placeholder:b,autoFocus:!0,className:"flex-1 min-w-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring"}),c&&c.length>0&&(0,d.jsx)(I,{groups:c,value:k,onChange:l,onSubmit:m,onCancel:h})]})}let K=(a,b)=>`flex items-center group min-w-0 rounded transition-opacity ${a?"opacity-50":""} ${b?"border-t-2 border-brand":""}`,L="p-1 text-muted-foreground hover:text-foreground rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",M=(0,e.memo)(function({item:a,isDragging:b,isDragOver:c,onSelect:e,onInsert:g,onEdit:h,onDelete:j,onDragStart:k,onDragOver:l,onDrop:m,onDragEnd:n,management:o=!0}){let{t:p}=(0,f.Bd)();return(0,d.jsxs)("div",{draggable:o,onDragStart:o?()=>k(a.id):void 0,onDragOver:o?b=>l(b,a.id):void 0,onDrop:o?()=>m(a.id):void 0,onDragEnd:o?n:void 0,className:K(b,c),children:[o&&(0,d.jsx)(s.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),(0,d.jsx)(z.m,{content:a.text,children:(0,d.jsxs)("button",{type:"button",onClick:()=>e(a.text),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",children:[(0,d.jsx)(t.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"truncate",children:a.text})]})}),(0,d.jsx)("button",{type:"button",onClick:()=>g(a.text),className:L,title:p("chat.insertQuickInstruction"),children:(0,d.jsx)(i.A,{className:"w-3 h-3"})}),o&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",onClick:()=>h(a.id),className:L,title:p("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>j(a.id),className:`${L} hover:text-destructive`,title:p("common.delete"),children:(0,d.jsx)(v.A,{className:"w-3 h-3"})})]})]})}),N=(0,e.memo)(function({group:a,isOpen:b,isDragging:c,isDragOver:g,isDragActive:h,onHoverOpen:i,onHoverClose:j,onToggle:k,onRename:l,onDelete:m,onDragStart:n,onDragOver:o,onDrop:q,onDragEnd:r,management:t=!0}){let{t:x}=(0,f.Bd)(),y=(0,e.useRef)(null),z=(0,e.useCallback)(()=>y.current?.getBoundingClientRect(),[]);return(0,d.jsxs)("div",{ref:y,draggable:t,onDragStart:t?()=>n(a.id):void 0,onDragOver:t?b=>o(b,a.id):void 0,onDrop:t?()=>q(a.id):void 0,onDragEnd:t?r:void 0,onMouseEnter:()=>{if(h)return;let b=z();b&&i(a.id,b)},onMouseLeave:()=>{h||j()},className:`${K(c,g)} ${b?"bg-hover":""}`,children:[t&&(0,d.jsx)(s.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),(0,d.jsxs)("button",{type:"button",onClick:()=>{let b=z();b&&k(a.id,b)},className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",title:a.name,children:[(0,d.jsx)(p.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"flex-1 min-w-0 truncate",children:a.name}),(0,d.jsxs)("span",{className:"ml-auto flex items-center gap-1 flex-shrink-0 text-[10px] text-muted-foreground",children:[a.items.length>0&&a.items.length,(0,d.jsx)(w.A,{className:"w-3 h-3"})]})]}),t&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",onClick:()=>l(a.id),className:L,title:x("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>m(a.id),className:`${L} hover:text-destructive`,title:x("common.delete"),children:(0,d.jsx)(v.A,{className:"w-3 h-3"})})]})]})});function O({group:a,position:b,groupChoices:c,editId:e,isAdding:g,isDragActive:h,dragId:i,dragOverId:j,onMouseEnter:k,onMouseLeave:l,onSelect:m,onInsert:n,onStartEdit:p,onCommitEdit:q,onCancelEdit:r,onDelete:s,onStartAdd:t,onCommitAdd:u,onCancelAdd:v,onDragStart:w,onDragOver:y,onDrop:z,onDragEnd:A,management:B=!0}){let{t:C}=(0,f.Bd)();return(0,o.createPortal)((0,d.jsxs)("div",{[G]:"",onMouseEnter:k,onMouseLeave:()=>{h||l()},style:{left:b.left,top:b.top,width:b.width,maxHeight:b.maxHeight},className:"fixed z-50 p-2 bg-popover border border-border rounded-lg shadow-lv2 overflow-y-auto",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1 truncate",children:a.name}),B&&(0,d.jsx)("button",{type:"button",onClick:t,className:"p-0.5 text-muted-foreground hover:text-foreground rounded flex-shrink-0",title:C("chat.addQuickInstruction"),children:(0,d.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}),B&&g&&(0,d.jsx)(J,{initialValue:"",placeholder:C("chat.quickInstructionPlaceholder"),onCommit:a=>u(a),onCancel:v}),0===a.items.length&&!g&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:C("chat.noQuickInstructions")}),a.items.map(b=>e===b.id?(0,d.jsx)(J,{initialValue:b.text,placeholder:C("chat.quickInstructionPlaceholder"),groupChoices:c,initialGroupId:a.id,onCommit:(a,c)=>q(b.id,a,c),onCancel:r},`edit-${b.id}`):(0,d.jsx)(M,{item:b,isDragging:i===b.id,isDragOver:j===b.id&&i!==b.id,onSelect:m,onInsert:n,onEdit:p,onDelete:s,onDragStart:w,onDragOver:y,onDrop:z,onDragEnd:A,management:B},b.id))]}),document.body)}function P({label:a,nodes:b,scope:c,openGroupId:g,flyoutPosition:h,onOpenFlyout:i,onCloseFlyout:j,onKeepFlyout:l,onSave:m,onSelect:n,onInsert:o,management:p=!0,onManage:q}){let{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)(null),[v,w]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(null),G=b.filter(B._9),I=g?G.find(a=>a.id===g)??null:null,K=(0,e.useRef)(b);K.current=b;let L=(0,e.useRef)(g);L.current=g;let Q=(0,e.useRef)(null),R=(0,e.useCallback)(a=>{A(null),m(c,a)},[m,c]),S=(0,e.useCallback)(a=>{t(null),R([...K.current,{id:H(),text:a}])},[R]),T=(0,e.useCallback)(a=>{t(null),R([...K.current,{id:H(),name:a,items:[]}])},[R]),U=(0,e.useCallback)((a,b,c,d)=>{let e=K.current,f={id:a,text:b};if(c===d)return void R(e.map(b=>(0,B._9)(b)?b.id===d?{...b,items:b.items.map(b=>b.id===a?f:b)}:b:null===d&&b.id===a?f:b));let g=null===c?e.filter(b=>(0,B._9)(b)||b.id!==a):e.map(b=>(0,B._9)(b)&&b.id===c?{...b,items:b.items.filter(b=>b.id!==a)}:b);R(null===d?[...g,f]:g.map(a=>(0,B._9)(a)&&a.id===d?{...a,items:[...a.items,f]}:a))},[R]),V=(0,e.useCallback)((a,b)=>{R(K.current.map(c=>(0,B._9)(c)&&c.id===a?{...c,name:b}:c))},[R]),W=(0,e.useCallback)(async a=>{let b=K.current.find(b=>b.id===a);if(b&&(0,B._9)(b)&&b.items.length>0){if(!await (0,k.lJ)(r("chat.deleteInstructionGroupConfirm",{name:b.name,count:b.items.length}),{danger:!0,confirmText:r("common.delete")}))return;j()}A(null),R(K.current.filter(b=>b.id!==a))},[R,r,j]),X=(0,e.useCallback)(a=>{let b=L.current;b&&R(K.current.map(c=>(0,B._9)(c)&&c.id===b?a(c):c))},[R]),Y=(0,e.useCallback)(a=>{w(!1),X(b=>({...b,items:[...b.items,{id:H(),text:a}]}))},[X]),Z=(0,e.useCallback)(a=>{A(null),X(b=>({...b,items:b.items.filter(b=>b.id!==a)}))},[X]),$=(0,e.useCallback)((a,b,c)=>{U(a,b,L.current,c)},[U]),_=(0,e.useCallback)(a=>{Q.current=a,D(a)},[]),aa=(0,e.useCallback)(()=>{_(null),F(null)},[_]),ab=(0,e.useCallback)(a=>{_(a),j()},[_,j]),ac=(0,e.useCallback)((a,b)=>{a.preventDefault(),F(b)},[]),ad=(a,b,c)=>{let d=a.findIndex(a=>a.id===b),e=a.findIndex(a=>a.id===c);if(d<0||e<0)return a;let f=[...a],[g]=f.splice(d,1);return f.splice(e,0,g),f},ae=(0,e.useCallback)(a=>{let b=Q.current;aa(),b&&b!==a&&R(ad(K.current,b,a))},[R,aa]),af=(0,e.useCallback)(a=>{let b=Q.current;aa(),b&&b!==a&&X(c=>({...c,items:ad(c.items,b,a)}))},[X,aa]),ag=a=>{let b=K.current.find(b=>(0,B._9)(b)&&b.id===a);return b&&(0,B._9)(b)?b.items.length:0},ah=(0,e.useCallback)((a,b)=>{i(c,a,b,ag(a),!1)},[i,c]),ai=(0,e.useCallback)((a,b)=>{L.current===a?j():i(c,a,b,ag(a),!0)},[i,j,c]);return(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:a}),p?(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)("button",{type:"button",onClick:()=>{A(null),t("group")},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:r("chat.addInstructionGroup"),children:(0,d.jsx)(y.A,{className:"w-3.5 h-3.5"})}),(0,d.jsx)("button",{type:"button",onClick:()=>{A(null),t("instruction")},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:r("chat.addQuickInstruction"),children:(0,d.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}):q?(0,d.jsx)("button",{type:"button",onClick:q,className:"p-1 text-muted-foreground hover:text-brand rounded hover:bg-hover transition-colors",title:r("common.edit"),"aria-label":r("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3.5 h-3.5"})}):null]}),"instruction"===s&&(0,d.jsx)(J,{initialValue:"",placeholder:r("chat.quickInstructionPlaceholder"),onCommit:a=>S(a),onCancel:()=>t(null)}),"group"===s&&(0,d.jsx)(J,{initialValue:"",placeholder:r("chat.instructionGroupNamePlaceholder"),onCommit:a=>T(a),onCancel:()=>t(null)}),0===b.length&&!s&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:r("chat.noQuickInstructions")}),b.map(a=>z===a.id?(0,B._9)(a)?(0,d.jsx)(J,{initialValue:a.name,placeholder:r("chat.instructionGroupNamePlaceholder"),onCommit:b=>V(a.id,b),onCancel:()=>A(null)},`edit-${a.id}`):(0,d.jsx)(J,{initialValue:a.text,placeholder:r("chat.quickInstructionPlaceholder"),groupChoices:G,initialGroupId:null,onCommit:(b,c)=>U(a.id,b,null,c),onCancel:()=>A(null)},`edit-${a.id}`):(0,B._9)(a)?(0,d.jsx)(N,{group:a,isOpen:g===a.id,isDragging:C===a.id,isDragOver:E===a.id&&C!==a.id,isDragActive:null!==C,onHoverOpen:ah,onHoverClose:j,onToggle:ai,onRename:A,onDelete:W,onDragStart:ab,onDragOver:ac,onDrop:ae,onDragEnd:aa,management:p},a.id):(0,d.jsx)(M,{item:a,isDragging:C===a.id,isDragOver:E===a.id&&C!==a.id,onSelect:n,onInsert:o,onEdit:A,onDelete:W,onDragStart:ab,onDragOver:ac,onDrop:ae,onDragEnd:aa,management:p},a.id)),I&&h&&(0,d.jsx)(O,{group:I,position:h,groupChoices:G,editId:z,isAdding:v,isDragActive:null!==C,dragId:C,dragOverId:E,onMouseEnter:l,onMouseLeave:j,onSelect:n,onInsert:o,onStartEdit:A,onCommitEdit:$,onCancelEdit:()=>A(null),onDelete:Z,onStartAdd:()=>{A(null),w(!0)},onCommitAdd:Y,onCancelAdd:()=>w(!1),onDragStart:_,onDragOver:ac,onDrop:af,onDragEnd:aa,management:p})]})}function Q({cwd:a,anchorRef:b,onClose:c,onSelect:g,onInsert:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(null),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),s.current&&(clearTimeout(s.current),s.current=null)},[]),u=(0,e.useCallback)((a,b,c,d,e)=>{t();let f=()=>{var e;let f,g,h,i,j,k,l;return o({scope:a,groupId:b,position:(g=(e={width:window.innerWidth,height:window.innerHeight}).width-c.right-4-8,h=c.left-4-8,i=288,g>=288?f=c.right+4:h>=288?f=c.left-4-288:g>=h?(i=Math.max(180,g),f=c.right+4):(i=Math.max(180,h),f=c.left-4-i),f=Math.min(Math.max(8,f),Math.max(8,e.width-i-8)),k=Math.min(j=Math.max(90,.6*e.height),30*d+40),(l=c.top-4)+k>e.height-8&&(l=e.height-8-k),{left:f,top:l=Math.max(8,l),width:i,maxHeight:j})})};e?f():r.current=setTimeout(f,150)},[t]),v=(0,e.useCallback)(()=>{t(),s.current=setTimeout(()=>o(null),300)},[t]),w=(0,e.useCallback)(()=>t(),[t]),x=(0,e.useCallback)(async(b,c)=>{let d="global"===b?k:m;d(c);let e=await A.t4.runPromiseExit((0,B.hZ)("global"===b?{scope:"global",instructions:c}:{cwd:a,instructions:c}));return"Failure"===e._tag?(console.error(`Failed to save ${b} instructions:`,e.cause),!1):(e.value?.instructions&&d(e.value.instructions),!0)},[a]),y=(0,e.useCallback)(a=>{c(),g(a)},[c,g]),z=(0,e.useCallback)(a=>{c(),h(a)},[c,h]),C=(0,e.useCallback)(async a=>!!p&&x(p,a),[p,x]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"absolute bottom-full left-0 mb-2 w-80 max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lv2 z-50 max-h-[70vh] overflow-y-auto",children:[(0,d.jsx)(P,{label:i("chat.globalInstructions"),nodes:j,scope:"global",openGroupId:n?.scope==="global"?n.groupId:null,flyoutPosition:n?.scope==="global"?n.position:null,onOpenFlyout:u,onCloseFlyout:v,onKeepFlyout:w,onSave:x,onSelect:y,onInsert:z,management:!1,onManage:()=>{t(),o(null),q("global")}}),a&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsx)(P,{label:i("chat.projectInstructions"),nodes:l,scope:"project",openGroupId:n?.scope==="project"?n.groupId:null,flyoutPosition:n?.scope==="project"?n.position:null,onOpenFlyout:u,onCloseFlyout:v,onKeepFlyout:w,onSave:x,onSelect:y,onInsert:z,management:!1,onManage:()=>{t(),o(null),q("project")}})]})]}),p&&(0,d.jsx)(F,{title:i("global"===p?"chat.editGlobalInstructions":"chat.editProjectInstructions"),nodes:"global"===p?j:l,onSave:C,onClose:()=>q(null)})]})}var R=c(71697);let S=(0,e.memo)(function({onSend:a,disabled:b,cwd:c,engine:j,onShowGitStatus:k,onShowComments:l,onOpenNote:o,isFavorite:p,onToggleFavorite:q,onCreateScheduledTask:r,draft:s,setDraft:t,draftImages:u,setDraftImages:v}){let{t:w}=(0,f.Bd)(),x=(0,e.useState)(""),y=(0,e.useState)([]),[z,A]=void 0!==s&&t?[s,t]:x,[B,C]=void 0!==u&&v?[u,v]:y,[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(!1),H=(0,e.useRef)(null),I=(0,e.useRef)(null),J=(0,e.useCallback)(()=>{let a=H.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,e.useLayoutEffect)(()=>{J()},[z,J]);let K=(0,e.useMemo)(()=>j&&"claude"!==j?[]:[{name:"/plan",description:"Enable plan mode (read-only). /plan <task> to plan a task; /plan off to disable.",source:"builtin",argumentHint:"[task|off]"}],[j]),L=(0,R.n)({value:z,onChange:A,textareaRef:H,extraCommands:K}),M=(0,e.useCallback)(()=>{let c=z.trim();(c||B.length>0)&&!b&&(a(c,B.length>0?B:void 0),A(""),C([]),H.current&&(H.current.style.height="auto"))},[z,B,b,a]),N=(0,e.useCallback)(c=>{b||a(c)},[b,a]),O=(0,e.useCallback)(a=>{A(b=>{let c=b.replace(/\s+$/,"");return c?`${c}
732
- ${a}`:a}),requestAnimationFrame(()=>{let a=H.current;a&&(a.focus(),a.setSelectionRange(a.value.length,a.value.length))})},[]),P=(0,e.useCallback)(a=>{a.nativeEvent.isComposing||!L.handleKeyDown(a)&&("Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),M()))},[L,M]),S=(0,e.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(w("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};C(a=>[...a,e])},e.readAsDataURL(c)}}},[w]),T=(0,e.useCallback)(a=>{C(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(m,{images:B,onRemove:T,disabled:b}),(0,d.jsx)(R.V,{ac:L,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64"}),(0,d.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[k&&(0,d.jsx)("button",{onClick:k,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:w("chat.viewGitChanges"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),l&&(0,d.jsx)("button",{onClick:l,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:w("chat.viewAllComments"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),o&&(0,d.jsx)("button",{onClick:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:w("chat.projectNotes"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),q&&(0,d.jsx)("button",{onClick:q,className:`p-2 rounded-lg transition-all ${p?"text-amber-9 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95":"text-muted-foreground hover:text-amber-9 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95"}`,title:w(p?"sessions.removeFavorite":"sessions.addFavorite"),"aria-label":w(p?"sessions.removeFavorite":"sessions.addFavorite"),"aria-pressed":p,children:(0,d.jsx)(g.A,{className:"w-5 h-5",fill:p?"currentColor":"none"})}),r&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>E(!D),className:`p-2 rounded-lg transition-all ${D?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:w("chat.scheduledTasks"),children:(0,d.jsx)(h.A,{className:"w-5 h-5"})}),D&&(0,d.jsx)(n.E,{onClose:()=>E(!1),onCreate:r})]}),(0,d.jsxs)("div",{className:"relative",ref:I,children:[(0,d.jsx)("button",{onClick:()=>G(!F),className:`p-2 rounded-lg transition-all ${F?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:w("chat.quickInstructions"),children:(0,d.jsx)(i.A,{className:"w-5 h-5"})}),F&&(0,d.jsx)(Q,{cwd:c,anchorRef:I,onClose:()=>G(!1),onSelect:N,onInsert:O})]}),(0,d.jsx)("textarea",{ref:H,value:z,onChange:a=>{A(a.target.value),L.trackCaret(a.target)},onSelect:a=>L.trackCaret(a.currentTarget),onKeyDown:P,onPaste:S,placeholder:b?w("chat.placeholderDisabled"):w("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground"})]})]})})},80983:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(23700),j=c(92701),k=c(93780),l=c(61349),m=a([l,i,j]);[l,i,j]=m.then?(await m)():m;let p={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",ApplyPatch:"\uD83E\uDDE9",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function n(a){return"object"==typeof a&&null!==a}function o({toolCall:a,cwd:b,sessionId:c,disableOverlays:d=!1}){var m;let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(null),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(!1),z=p[a.name]||"\uD83D\uDD27",A="Agent"===a.name||"Task"===a.name,B=A&&!!b&&!!c,C="Workflow"===a.name,D=C&&(m=a.result)?m.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,E=C&&!!D&&!!b&&!!c,F=(0,k.v2)(a.id)??a.task,G=F?.status==="running",H=!!a.isLoading||G,I=F?G||!!a.isLoading:!a.result,J=G?[F?.lastToolName,F?.toolUses?String(F.toolUses):null].filter(Boolean).join(" \xb7 "):"",K="Skill"===a.name,L="ApplyPatch"===a.name||A||C||K,M=a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a},N=(()=>{let b=a.input;if("Bash"===a.name&&b.command&&"string"==typeof b.command)return b.command;if("ApplyPatch"===a.name&&Array.isArray(b.changes)){let a=b.changes.filter(n).flatMap(a=>{let b="string"==typeof a.path?a.path:"";if(!b)return[];let c="string"==typeof a.kind&&a.kind?a.kind:"update";return`${c} ${M(b)}`});if(a.length>0)return a.join(" \xb7 ")}if(A&&b.description&&"string"==typeof b.description)return b.description;if(C){let a="string"==typeof b.name?b.name:"",c="string"==typeof b.args?b.args:"string"==typeof b.resumeFromRunId?b.resumeFromRunId:"",d=[a,c].filter(Boolean).join(" \xb7 ");if(d)return d}if(K&&"string"==typeof b.skill){let a="string"==typeof b.args?b.args:"";return[b.skill,a].filter(Boolean).join(" \xb7 ")}return"Glob"===a.name&&b.pattern&&"string"==typeof b.pattern||"Grep"===a.name&&b.pattern&&"string"==typeof b.pattern?b.pattern:"ToolSearch"===a.name&&b.query&&"string"==typeof b.query?b.query:"TaskCreate"===a.name&&b.subject&&"string"==typeof b.subject?b.subject:b.file_path&&"string"==typeof b.file_path?b.file_path:b.path&&"string"==typeof b.path?b.path:null})(),O="Glob"===a.name||"Grep"===a.name||"Bash"===a.name||"ApplyPatch"===a.name||A||C||K,P=N?O?N:M(N):null,Q=b=>{let c="input"===b?q("toolCall.inputParams"):q("toolCall.resultLabel"),d="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);u({title:`${a.name}${P?` ${P}`:""} - ${c}`,content:d,toolName:a.name})};return(0,e.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,e.jsxs)("button",{onClick:()=>s(!r),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors",children:[(0,e.jsx)("span",{className:"text-sm",children:z}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),P&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":N||"",children:P}),!L&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),N&&(navigator.clipboard.writeText(N),(0,h.oR)(q("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),N&&(navigator.clipboard.writeText(N),(0,h.oR)(q("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:q("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[B&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),w(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),w(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("chat.subagentViewTitle"),children:q("chat.subagent")}),E&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),y(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),y(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("chat.workflowViewTitle"),children:q("chat.workflowRun")}),J&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:J}),r&&!a.isLoading&&!d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),Q("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),Q("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("toolCall.inputParamsTitle"),children:q("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),Q("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),Q("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("toolCall.resultTitle"),children:q("toolCall.result")})]}),H?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-foreground-subtle text-xs",children:r?"▲":"▼"})]})]}),r&&(0,e.jsxs)("div",{className:"border-t border-line-1",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]}),a.skillContent&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:a.skillContent})]})]}),t&&(0,e.jsx)(l.M,{title:t.title,content:t.content,toolName:t.toolName,onClose:()=>u(null)}),v&&b&&c&&(0,e.jsx)(i.f,{cwd:b,sessionId:c,toolCall:a,running:I,onClose:()=>w(!1)}),x&&b&&c&&D&&(0,e.jsx)(j.K,{cwd:b,sessionId:c,runId:D,isRunning:H,onClose:()=>y(!1)})]})}d()}catch(a){d(a)}})},81064:(a,b,c)=>{Promise.resolve().then(c.bind(c,81227))},81206:(a,b,c)=>{"use strict";c.d(b,{z:()=>h,m:()=>j});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=a=>e.$mh({try:async()=>{let b=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return b.ok?await b.json():null},catch:a=>new g.uV({message:"session-by-path failed",cause:a})}),i=new Map;function j(a,b,c,{cwd:k,initialSessionId:l,onSessionId:m,onTitleChange:n,onTokenUsage:o,liveRunningRef:p}){let[q,r]=(0,d.useState)(!1),[s,t]=(0,d.useState)(!1),[u,v]=(0,d.useState)(!1),[w,x]=(0,d.useState)(void 0),[y,z]=(0,d.useState)(0),[A,B]=(0,d.useState)(null),[C,D]=(0,d.useState)(null),E=(0,d.useRef)(null);E.current=A;let F=(0,d.useRef)(n);F.current=n;let G=(0,d.useRef)(o);G.current=o;let H=(0,d.useRef)(void 0),I=(0,d.useRef)(0),J=(0,d.useCallback)(async(a,c,d=!1,e,g,j=!1)=>{if(d){let a=Date.now();if(!j&&a-I.current<5e3)return;I.current=a}let k=(a,d)=>{a.fingerprint&&(H.current=a.fingerprint),void 0!==a.totalTurns&&z(a.totalTurns),void 0!==a.hasMore&&v(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>(function(a,b){if(0===b.length)return a;let c=0;if(a.length>0&&a[0].id!==b[0].id){c=-1;for(let d=a.length-1;d>=0;d--)if(a[d].id===b[0].id){c=d;break}}if(c<0)return b;let d=a.slice(c),e=0;for(let a=0;a<Math.min(d.length,b.length)&&d[a].id===b[a].id&&d[a].content===b[a].content;a++)e=a+1;return e===d.length&&e===b.length?a:e===d.length&&e<b.length?[...a,...b.slice(e)]:[...a.slice(0,c),...d.slice(0,e),...b.slice(e)]})(b,a.messages)):p?.current||b(a.messages),B(c)),a.sessionId&&m(a.sessionId),a.engine&&D(a.engine),a.title&&F.current?.(a.title),a.usage&&G.current?.({inputTokens:a.usage.input_tokens||0,outputTokens:a.usage.output_tokens||0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens||0,cacheReadInputTokens:a.usage.cache_read_input_tokens||0,totalCostUsd:0})},l=`${a}::${c}`;j&&i.delete(l);let n=!d&&void 0===g,o=n?i.get(l):void 0;d||(o?k(o.data,!1):r(!0));try{let b={cwd:a,sessionId:c,limit:e,beforeTurnIndex:g};d&&H.current?b.ifFingerprint=H.current:o&&(b.ifFingerprint=o.fingerprint);let j=await f.t4.runPromiseExit(h(b));if("Success"===j._tag&&j.value){let a=j.value;if(a.notModified)return;if(k(a,d),n&&a.fingerprint&&a.messages&&a.messages.length>0&&(i.delete(l),i.set(l,{data:a,fingerprint:a.fingerprint}),i.size>20)){let a=i.keys().next().value;void 0!==a&&i.delete(a)}}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||r(!1)}},[b,m]),K=(0,d.useCallback)(async()=>{if(k&&c&&!s&&u){t(!0);try{let d=void 0!==w?w:y-Math.ceil(a.filter(a=>"user"===a.role).length),e=await f.t4.runPromiseExit(h({cwd:k,sessionId:c,limit:10,beforeTurnIndex:d>0?d:void 0}));if("Success"===e._tag&&e.value){let a=e.value;if(a.messages&&a.messages.length>0){b(b=>[...a.messages,...b]);let e=a.messages.filter(a=>"user"===a.role).length;x(a.startTurnIndex??d-e),B(c)}void 0!==a.hasMore&&v(a.hasMore),a.fingerprint&&(H.current=a.fingerprint)}else"Failure"===e._tag&&console.error("Failed to load more history:",e.cause)}finally{t(!1)}}},[k,c,s,u,w,y,a,b]);return{isLoadingHistory:q,isLoadingMore:s,hasMoreHistory:u,loadMoreHistory:K,ensureTurnLoaded:(0,d.useCallback)(async a=>{let d=E.current??c;if(k&&d&&!(a<0)){t(!0);try{let c=await f.t4.runPromiseExit(h({cwd:k,sessionId:d,fromTurnIndex:a}));if("Failure"===c._tag)return void console.error("Failed to load turns for jump:",c.cause);if(!c.value||E.current&&E.current!==d)return;let e=c.value;if(e.messages&&e.messages.length>0){let c=e.messages;b(a=>(function(a,b){if(0===b.length)return a;let c=new Set(b.map(a=>a.id)),d=a.map(a=>c.has(a.id)).lastIndexOf(!0);if(d<0)return b;let e=a.slice(d+1);return 0===e.length?b:[...b,...e]})(a,c)),x(e.startTurnIndex??a),B(d)}void 0!==e.totalTurns&&z(e.totalTurns),void 0!==e.hasMore&&v(e.hasMore),e.fingerprint&&(H.current=e.fingerprint)}finally{t(!1)}}},[k,c,b]),loadHistory:(0,d.useCallback)(async a=>{if(!k)return;r(!0);let c=e.$mh({try:async()=>{let b=await fetch(`/api/session/${encodeURIComponent(a)}/history?cwd=${encodeURIComponent(k)}`);return b.ok?await b.json():null},catch:a=>new g.uV({message:"load session history failed",cause:a})}),d=await f.t4.runPromiseExit(c);"Success"===d._tag&&d.value?.messages&&d.value.messages.length>0?(b(d.value.messages),B(a)):"Failure"===d._tag&&console.error("Failed to load history:",d.cause),r(!1)},[k,b]),loadHistoryByCwdAndSessionId:J,loadedSessionId:A,loadedEngine:C}}},81227:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx","default")},82634:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>o});var d=c(67484),e=c(23860),f=c(29939);c(57031),c(88214);var g=c(79606),h=c(33281),i=c(37388);function j(a,b,c,d,e){let f=new Set(b.map(a=>a.id)),g=new Set([...a].filter(a=>f.has(a))),h=new Map;for(let a of c){if(a.cwd!==d)continue;let b="codex"===a.engine?m(a.sessionId):a.sessionId;h.set(b,a.status??"normal")}for(let a of b){if(!a.sessionId)continue;let b=h.get(a.sessionId);void 0!==b&&(b===e?g.add(a.id):g.delete(a.id))}return g}function k(a,b){return a.size===b.size&&[...a].every(a=>b.has(a))}c(71192);let l=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\.jsonl)?$/i;function m(a){let b=a.match(l);return b?.[1]??a}function n(a,b,c){let d=new Set(b.map(a=>a.id)),e=new Set(a.filter(a=>d.has(a))),f=[],g=[];for(let h of a){if(d.has(h)&&!g.includes(h)){g.push(h);continue}let a=new Set([...g,...e]),i=[...b].reverse().find(b=>!a.has(b.id));if(i){g.push(i.id),e.add(i.id);continue}let j={id:`tab-${Date.now()}-pane${f.length}`,cwd:c,title:"New Chat"};f.push(j),g.push(j.id)}return{panes:g,created:f}}function o({initialCwd:a,initialSessionId:b,initialBlank:c,activeView:l}){(0,d.useRef)(!1);let p=(0,d.useRef)(!0),[q,r]=(0,d.useState)(!1);(0,d.useCallback)(()=>{p.current=!1,r(!0)},[]);let s=(0,d.useRef)(l),t=(0,e.F)(),u=(0,d.useRef)(t),[v,w]=(0,d.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:b?`Session ${b.slice(0,6)}...`:"New Chat"}]),[x,y]=(0,d.useState)(()=>[v[0]?.id??""]),[z,A]=(0,d.useState)(0),B=(0,d.useRef)(z),C=(0,d.useRef)(x),D=x[z]??x[0]??"",E=(0,d.useCallback)(a=>{y(b=>{let c=b.indexOf(a);if(-1!==c)return c!==B.current&&A(c),b;let d=[...b];return d[B.current]=a,d})},[]),[F,G]=(0,d.useState)(new Set),[H,I]=(0,d.useState)(new Set),J=(0,d.useRef)(v),K=(0,d.useRef)([]),L=(0,d.useRef)(D);(0,d.useRef)(null);let M=(0,d.useRef)(new Set),N=(0,d.useCallback)((b,c)=>{a&&b&&h.t4.runFork((0,i.KJ)(a,b,c).pipe(g.h9N(()=>g.rIH)))},[a]),O=(0,d.useCallback)(b=>{a&&(I(c=>{let d=j(c,J.current,b,a,"loading");return k(c,d)?c:d}),G(c=>{let d=j(c,J.current,b,a,"unread");return k(c,d)?c:d}))},[a]),[P,Q]=(0,d.useState)(null),[R,S]=(0,d.useState)(null),T=(0,d.useCallback)(b=>{a&&h.t4.runPromise((0,i.n8)(a).pipe(g.h9N(()=>g.PyW(null)))).then(c=>{if(!c)return;let d=c.engines||{},e={};for(let[a,b]of Object.entries(d))e["codex"===b?m(a):a]=b;let f=[];for(let a of c.sessions||[]){let b="codex"===d[a]?m(a):a;f.includes(b)||f.push(b)}let g=c.ollamaModels||{},h=c.deepseekModels||{},i=c.kimiModels||{},j=c.glmModels||{},k=c.claudeModels||{},l=c.claudeEfforts||{},o=c.claudeContextWindows||{},p=c.claudeFastModes||{},q=c.claudeThinkings||{},r=c.codexModels||{},s=c.codexReasoningEfforts||{},t=c.planModes||{},u=c.noHistories||{},v=J.current,x=new Set(b),z=v.filter(a=>!a.sessionId||!x.has(a.sessionId)),A=new Set(z.map(a=>a.sessionId).filter(Boolean)),B=f.filter(a=>!A.has(a));if(z.length===v.length&&0===B.length)return;let D=[...z,...B.map((b,c)=>({id:`tab-${Date.now()}-sync-${c}`,cwd:a,sessionId:b,title:`Session ${b.slice(0,6)}...`,engine:e[b]||void 0,ollamaModel:g[b]||void 0,deepseekModel:h[b]||void 0,kimiModel:i[b]||void 0,glmModel:j[b]||void 0,claudeModel:k[b]||void 0,claudeEffort:l[b]||void 0,claudeContextWindow:o[b]||void 0,claudeFastMode:p[b]??void 0,claudeThinking:q[b]??void 0,codexModel:r[b]||void 0,codexReasoningEffort:s[b]||void 0,planMode:t[b]||void 0,noHistory:u[b]||void 0}))];0===D.length&&(D=[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]);let{panes:E,created:F}=n(C.current,D,a);F.length&&(D=[...D,...F]),w(D),y(E)})},[a]),U=(0,d.useCallback)(b=>{if(a){if("global-state"===b.type&&Array.isArray(b.data?.sessions)){K.current=b.data.sessions,p.current||O(b.data.sessions);return}p.current||"project-state-changed"!==b.type||b.cwd!==a||T(b.closedSessionIds??[])}},[a,T,O]);(0,f.h)({url:"/ws/global-state",enabled:!!a,onMessage:U});let V=(0,d.useCallback)((a,b,c,d)=>{let{engine:e,ollamaModel:f,deepseekModel:g,kimiModel:h,glmModel:i,claudeModel:j,claudeEffort:k,claudeContextWindow:l,claudeFastMode:m,claudeThinking:n,codexModel:o,codexReasoningEffort:p,planMode:q,noHistory:r,appendToEnd:s=!1}=d??{},t={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat"),engine:e,ollamaModel:f,deepseekModel:g,kimiModel:h,glmModel:i,claudeModel:j,claudeEffort:k,claudeContextWindow:l,claudeFastMode:m,claudeThinking:n,codexModel:o,codexReasoningEffort:p,planMode:q,noHistory:r};w(a=>{if(s)return[...a,t];let b=a.findIndex(a=>a.id===D);if(-1===b)return[...a,t];let c=[...a];return c.splice(b+1,0,t),c}),E(t.id)},[D]),W=(0,d.useCallback)(b=>{let c=J.current.find(a=>a.id===b);c?.sessionId&&M.current.add(c.sessionId);let d=J.current.filter(a=>a.id!==b),{panes:e,created:f}=n(C.current,d,a);w([...d,...f]),y(e)},[a]),X=(0,d.useCallback)(()=>{A(0),J.current.forEach(a=>{a.sessionId&&M.current.add(a.sessionId)});let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};E(b.id),w([b])},[a]),Y=(0,d.useCallback)((b,c)=>{let d=v.find(a=>a.sessionId===b);d?E(d.id):a?h.t4.runPromise((0,i.n8)(a).pipe(g.h9N(()=>g.PyW(null)))).then(d=>{let e=J.current.find(a=>a.sessionId===b);e?E(e.id):V(a,b,c,{engine:d?.engines?.[b],ollamaModel:d?.ollamaModels?.[b],deepseekModel:d?.deepseekModels?.[b],kimiModel:d?.kimiModels?.[b],glmModel:d?.glmModels?.[b],claudeModel:d?.claudeModels?.[b],claudeEffort:d?.claudeEfforts?.[b],claudeContextWindow:d?.claudeContextWindows?.[b],claudeFastMode:d?.claudeFastModes?.[b],claudeThinking:d?.claudeThinkings?.[b],codexModel:d?.codexModels?.[b],codexReasoningEffort:d?.codexReasoningEfforts?.[b],planMode:d?.planModes?.[b],noHistory:d?.noHistories?.[b],appendToEnd:!0})}):V(a,b,c,{appendToEnd:!0})},[v,a,V]),Z=(0,d.useCallback)(()=>{V(a,void 0,void 0,{appendToEnd:!0})},[a,V]),$=(0,d.useCallback)(()=>{V(a,void 0,"New Codex Chat",{engine:"codex",appendToEnd:!0})},[a,V]),_=(0,d.useCallback)(()=>{V(a,void 0,"New Kimi Chat",{engine:"kimi",kimiModel:"k3",appendToEnd:!0})},[a,V]),aa=(0,d.useCallback)(()=>{V(a,void 0,"New GLM Chat",{engine:"glm",glmModel:"glm-5.3",appendToEnd:!0})},[a,V]),ab=(0,d.useCallback)(b=>{V(a,void 0,b?`New Ollama (${b})`:"New Ollama Chat",{engine:"ollama",ollamaModel:b,appendToEnd:!0})},[a,V]),ac=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a&&c.engine!==b?{...c,engine:b}:c))},[]),ad=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,ollamaModel:b}:c))},[]),ae=(0,d.useCallback)(()=>{V(a,void 0,"New DeepSeek Chat",{engine:"deepseek",deepseekModel:"deepseek-v4-flash",appendToEnd:!0})},[a,V]),af=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,deepseekModel:b}:c))},[]),ag=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,kimiModel:b}:c))},[]),ah=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,glmModel:b}:c))},[]),ai=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,claudeModel:b}:c))},[]),aj=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,claudeEffort:b}:c))},[]),ak=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,claudeContextWindow:b}:c))},[]),al=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,claudeFastMode:b}:c))},[]),am=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,claudeThinking:b}:c))},[]),an=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,codexModel:b}:c))},[]),ao=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,codexReasoningEffort:b}:c))},[]),ap=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,planMode:b}:c))},[]),aq=(0,d.useCallback)((a,b)=>{w(c=>c.map(c=>c.id===a?{...c,noHistory:b}:c))},[]),ar=(0,d.useCallback)((b,c)=>{let d=J.current.find(a=>a.id===L.current);V(a,b,c,{engine:d?.engine,ollamaModel:d?.ollamaModel,deepseekModel:d?.deepseekModel,kimiModel:d?.kimiModel,glmModel:d?.glmModel,claudeModel:d?.claudeModel,claudeEffort:d?.claudeEffort,claudeContextWindow:d?.claudeContextWindow,claudeFastMode:d?.claudeFastMode,claudeThinking:d?.claudeThinking,codexModel:d?.codexModel,codexReasoningEffort:d?.codexReasoningEffort})},[a,V]),as=(0,d.useCallback)((a,b)=>{w(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!s.current||"agent"===s.current;if(a===D&&c&&u.current){let a=d.sessionId||b.sessionId;a&&N(a,"normal")}else G(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[D,N]),at=(0,d.useCallback)(()=>{let b=C.current;if(b.length>1){y([b[B.current]]),A(0);return}let c=J.current,d=c.findIndex(a=>a.id===b[0]),e=c[d+1]??c[d-1];if(e){y([b[0],e.id]),A(0);return}let f={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};w(a=>[...a,f]),y([b[0],f.id]),A(1)},[a]),au=(0,d.useCallback)(a=>{let b=C.current;b.length<2||(y(b.filter((b,c)=>c!==a)),A(0))},[]),av=(0,d.useCallback)(a=>{A(a)},[]),aw=(0,d.useCallback)(a=>{E(a),G(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=J.current.find(b=>b.id===a);return d?.sessionId&&(N(d.sessionId,"normal"),h.t4.runFork((0,i.M2)(d.sessionId).pipe(g.h9N(()=>g.rIH)))),c})},[N]),ax=(0,d.useCallback)(a=>{Q(a)},[]),ay=(0,d.useCallback)((a,b)=>{a.preventDefault(),null!==P&&P!==b&&S(b)},[P]),az=(0,d.useCallback)(a=>{null!==P&&P!==a&&w(b=>{let c=[...b],[d]=c.splice(P,1);return c.splice(a,0,d),c}),Q(null),S(null)},[P]),aA=(0,d.useCallback)(()=>{Q(null),S(null)},[]),aB=v.find(a=>a.id===D);return{tabs:v,activeTabId:D,activeTab:aB,paneTabIds:x,activePane:z,unreadTabs:F,globalLoadingTabs:H,pageVisible:t,dragTabIndex:P,dragOverTabIndex:R,addTab:V,toggleSideBySide:at,focusPane:av,closePane:au,closeTab:W,closeAllTabs:X,switchTab:aw,handleSelectSession:Y,handleNewTab:Z,handleNewCodexTab:$,handleNewKimiTab:_,handleNewGlmTab:aa,handleNewOllamaTab:ab,handleNewDeepseekTab:ae,handleOpenSession:ar,updateTabState:as,updateTabEngine:ac,updateTabOllamaModel:ad,updateTabDeepseekModel:af,updateTabKimiModel:ag,updateTabGlmModel:ah,updateTabClaudeModel:ai,updateTabClaudeEffort:aj,updateTabClaudeContextWindow:ak,updateTabClaudeFastMode:al,updateTabClaudeThinking:am,updateTabCodexModel:an,updateTabCodexReasoningEffort:ao,updateTabPlanMode:ap,updateTabNoHistory:aq,handleTabDragStart:ax,handleTabDragOver:ay,handleTabDrop:az,handleTabDragEnd:aA}}},82795:(a,b,c)=>{"use strict";c.d(b,{e:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(15819),h=c(33281),i=c(41224),j=c(32753),k=c(74228),l=c(1512);function m({isOpen:a,onClose:b,onSwitchProject:c,sessionNumbers:n={}}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(""),x=(0,e.useRef)(null);(0,e.useCallback)(async()=>{s(!0),u(null);let a=await h.t4.runPromiseExit((0,i.z2)());"Success"===a._tag?q([...a.value]):u(o("sessions.loadSessionsFailed")),s(!1)},[o]);let y=(0,l.H)(p).filter(a=>{if(!v)return!0;let b=v.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.cwd.toLowerCase().includes(b)||(a.title?.toLowerCase().includes(b)??!1)||(a.lastUserMessage?.toLowerCase().includes(b)??!1)||(a.firstMessages?.some(a=>a.toLowerCase().includes(b))??!1)||(a.lastMessages?.some(a=>a.toLowerCase().includes(b))??!1)});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:g.aO,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:o("sessions.recentSessions")})}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{ref:x,type:"text",placeholder:o("sessions.searchSessions"),value:v,onChange:a=>w(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),v&&(0,d.jsx)("button",{onClick:()=>{w(""),x.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:o("fileBrowser.clear"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[r&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:o("sessions.loadingSessions")})]})}),t&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:t})}),!r&&!t&&0===y.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:v?o("sessions.noMatchingSessions"):o("sessions.noSessions")})}),!r&&!t&&y.length>0&&(0,d.jsx)("div",{className:g.jL,children:y.map(a=>{let e;return(0,d.jsxs)("div",{onClick:()=>{c(a.cwd,a.sessionId),b()},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)(j.S,{engine:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":a.cwd,children:(e=a.cwd).split("/").pop()||e}),(0,d.jsx)(k.l,{coordinate:n[`${a.cwd}
733
- ${a.sessionId}`],status:(0,k.S)(a.status),statusLabel:"loading"===a.status?o("sessions.running"):"unread"===a.status?o("sessions.done"):void 0,className:"ml-auto"})]}),a.title&&(0,d.jsx)("div",{className:"text-xs font-medium text-foreground truncate mb-1","data-tooltip":a.title,children:a.title}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.lastActive).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(a.firstMessages?.length??0)>0||(a.lastMessages?.length??0)>0?(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),(a.lastMessages?.length??0)>0&&(0,d.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]}):a.lastUserMessage?(0,d.jsxs)("div",{className:"text-xs text-foreground truncate","data-tooltip":a.lastUserMessage,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a.lastUserMessage]}):null]},`${a.cwd}-${a.sessionId}`)})})]})]})]}):null}},83022:(a,b,c)=>{"use strict";c.d(b,{TabBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabBar() from the server but TabBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabBar.tsx","TabBar")},83120:(a,b,c)=>{"use strict";c.d(b,{BL:()=>q,Gm:()=>n,JK:()=>l,Wr:()=>o,Y8:()=>t,Y_:()=>k,_c:()=>r,bx:()=>m,dU:()=>s,i7:()=>x,jw:()=>u,mu:()=>v,vy:()=>w,z1:()=>p});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),j=a=>f(a,{method:"DELETE"}),k=()=>f("/api/review"),l=a=>{let b;return b=`/api/review/${encodeURIComponent(a)}`,d.$mh({try:async()=>{let a=await fetch(b);if(404===a.status)throw Object.assign(Error("not found"),{__404__:!0});if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>a?.__404__?new e.m_({resource:"review",id:b}):new e.uV({message:`GET ${b} failed`,cause:a})})},m=a=>g("/api/review",a),n=(a,b)=>i(`/api/review/${encodeURIComponent(a)}`,b),o=a=>j(`/api/review/${encodeURIComponent(a)}`),p=a=>i("/api/review/order",{order:a}),q=()=>f("/api/review/users"),r=()=>f("/api/review/share-info"),s=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/comments`,b),t=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/comments`,b),u=(a,b)=>j(`/api/review/${encodeURIComponent(a)}/comments?commentId=${encodeURIComponent(b)}`),v=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/replies`,b),w=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/replies`,b),x=(a,b,c)=>j(`/api/review/${encodeURIComponent(a)}/replies?commentId=${encodeURIComponent(b)}&replyId=${encodeURIComponent(c)}`)},83179:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({editor:a,onClose:b,position:c}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(()=>a.getAttributes("link").href||""),k=(0,e.useRef)(null),l=()=>{let c=i.trim();if(c){let b=c.match(/^https?:\/\//)?c:`https://${c}`;a.chain().focus().extendMarkRange("link").setLink({href:b}).run()}else a.chain().focus().extendMarkRange("link").unsetLink().run();b()},m=c?{top:c.top,left:c.left}:{};return(0,d.jsxs)("div",{className:`${c?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-lv2 p-2 flex items-center gap-2`,style:m,children:[(0,d.jsx)("input",{ref:k,type:"text",value:i,onChange:a=>j(a.target.value),onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),l()):"Escape"===a.key&&(a.preventDefault(),b())},placeholder:h("editor.linkPlaceholder"),className:"bg-background border border-border rounded px-2 py-1 text-sm w-64 outline-none focus:border-brand"}),(0,d.jsx)("button",{onClick:l,className:"p-1 rounded text-sm font-medium text-brand hover:bg-brand/10 transition-colors",title:h("editor.confirmLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}),a.isActive("link")&&(0,d.jsx)("button",{onClick:()=>{a.chain().focus().extendMarkRange("link").unsetLink().run(),b()},className:"p-1 rounded text-sm font-medium text-red-11 hover:bg-red-500/10 transition-colors",title:h("editor.removeLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})}function h({editor:a}){let{t:b}=(0,f.Bd)(),[c,i]=(0,e.useState)(!1),j=(0,e.useRef)(null),[,k]=(0,e.useState)(0);if(!a)return null;let l=a=>`p-1.5 rounded text-xs font-medium transition-colors ${a?"bg-brand/15 text-brand":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,m="w-px h-5 bg-border mx-0.5",n=a.isActive("table");return(0,d.jsxs)("div",{className:"flex items-center gap-0.5 px-4 py-1.5 border-b border-border flex-shrink-0 flex-wrap",children:[(0,d.jsx)("button",{className:l(a.isActive("heading",{level:1})),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),title:b("editor.heading1"),children:"H1"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:2})),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),title:b("editor.heading2"),children:"H2"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:3})),onClick:()=>a.chain().focus().toggleHeading({level:3}).run(),title:b("editor.heading3"),children:"H3"}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bold")),onClick:()=>a.chain().focus().toggleBold().run(),title:b("editor.bold"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),(0,d.jsx)("button",{className:l(a.isActive("italic")),onClick:()=>a.chain().focus().toggleItalic().run(),title:b("editor.italic"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),(0,d.jsx)("button",{className:l(a.isActive("strike")),onClick:()=>a.chain().focus().toggleStrike().run(),title:b("editor.strikethrough"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("code")),onClick:()=>a.chain().focus().toggleCode().run(),title:b("editor.inlineCode"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{ref:j,className:l(a.isActive("link")),onClick:()=>i(!c),title:b("editor.link"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),c&&(0,d.jsx)(g,{editor:a,onClose:()=>i(!1),position:null})]}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bulletList")),onClick:()=>a.chain().focus().toggleBulletList().run(),title:b("editor.bulletList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),(0,d.jsx)("button",{className:l(a.isActive("orderedList")),onClick:()=>a.chain().focus().toggleOrderedList().run(),title:b("editor.orderedList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("taskList")),onClick:()=>a.chain().focus().toggleTaskList().run(),title:b("editor.taskList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM17.99 9l-1.41-1.42-6.59 6.59-2.58-2.57-1.42 1.41 4 3.99z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("blockquote")),onClick:()=>a.chain().focus().toggleBlockquote().run(),title:b("editor.blockquote"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),(0,d.jsx)("button",{className:l(a.isActive("codeBlock")),onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.codeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zm-7.5-4.5L15 12l-2.5-2.5L11 11l1.5 1.5L11 14l1.5 1.5zM9.5 14.5L7 12l2.5-2.5L11 11 9.5 12.5 11 14l-1.5.5z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:b("editor.table"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-9 15H4v-4h7v4zm0-6H4V7h7v4zm9 6h-7v-4h7v4zm0-6h-7V7h7v4z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().setHorizontalRule().run(),title:b("editor.horizontalRule"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 11h16v2H4z"})})}),n&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowBefore().run(),title:b("editor.insertRowAbove"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zM11 17H4v-2h7v2zm0-4H4v-2h7v2zm9 4h-7v-2h7v2zm0-4h-7v-2h7v2z"}),(0,d.jsx)("path",{d:"M14 1h-4v2H8v2h2v2h4V5h2V3h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowAfter().run(),title:b("editor.insertRowBelow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v10h20V6c0-1.1-.9-2-2-2zM11 12H4v-2h7v2zm0-4H4V6h7v2zm9 4h-7v-2h7v2zm0-4h-7V6h7v2z"}),(0,d.jsx)("path",{d:"M14 19h-4v2H8v2h2v-2h4v2h2v-2h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnBefore().run(),title:b("editor.insertColumnLeft"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 11H10v-2h7v2zm0-4H10V9h7v2z"}),(0,d.jsx)("path",{d:"M1 14v-4h2V8h2v2h-2v4h2v2H3v-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnAfter().run(),title:b("editor.insertColumnRight"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M4 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h10V4H4zm7 11H4v-2h7v2zm0-4H4V9h7v2z"}),(0,d.jsx)("path",{d:"M18 4v20h2c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-2z"}),(0,d.jsx)("path",{d:"M21 14v-4h2V8h2v2h-2v4h2v2h-2v-2z",opacity:".6"})]})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-11 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteRow().run(),title:b("editor.deleteRow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zm-8 8H4v-2h8v2z"}),(0,d.jsx)("path",{d:"M15 13l-1.41 1.41L15.17 16l-1.58 1.59L15 19l1.59-1.59L18.17 19l1.42-1.41L18 16l1.59-1.59L18.17 13 16.59 14.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-11 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteColumn().run(),title:b("editor.deleteColumn"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 7H10V9h7v2z"}),(0,d.jsx)("path",{d:"M13 16l-1.41 1.41L13.17 19l-1.58 1.59L13 22l1.59-1.59L16.17 22l1.42-1.41L16 19l1.59-1.59L16.17 16l-1.58 1.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-11 hover:bg-red-500/10",onClick:()=>a.chain().focus().deleteTable().run(),title:b("editor.deleteTable"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]}),a.isActive("codeBlock")&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-11 hover:bg-red-500/10",onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.deleteCodeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})]})}},83377:(a,b,c)=>{"use strict";c.d(b,{A:()=>e});var d=c(67484);function e({lines:a,enabled:b,onContentChange:c,onEnterInsert:f,onSave:g,getVisibleLineCount:h,scrollToLine:i,onSearchExecute:j,onSearchNext:k,onSearchPrev:l,onSearchClear:m}){let[n,o]=(0,d.useState)("normal"),[p,q]=(0,d.useState)(-1),[r,s]=(0,d.useState)(0),[t,u]=(0,d.useState)(!1),[v,w]=(0,d.useState)(""),[x,y]=(0,d.useState)(""),[z,A]=(0,d.useState)(""),[B,C]=(0,d.useState)(""),D=(0,d.useRef)([]),E=(0,d.useRef)([]),F=(0,d.useRef)([]),G=(0,d.useRef)(null),H=(0,d.useRef)(a),I=(0,d.useCallback)((a,b)=>Math.max(0,Math.min(b,Math.max(0,(H.current[a]??"").length-1))),[]);(0,d.useRef)(a.length);let J=(0,d.useCallback)(()=>{G.current&&(clearTimeout(G.current),G.current=null),w("")},[]),K=(0,d.useCallback)(()=>{G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{w(""),G.current=null},500)},[]),L=(0,d.useCallback)((a,b)=>{D.current.push(b),E.current=[],u(!0),c(a.join("\n"))},[c]),M=(0,d.useCallback)((a,b)=>{let c=Math.max(0,Math.min(a,H.current.length-1));q(c),s(I(c,b??0)),i(c,"auto")},[i,I]),N=(0,d.useCallback)(a=>{q(b=>{let c=Math.max(0,Math.min(b+a,H.current.length-1));return i(c,"auto"),s(a=>Math.max(0,Math.min(a,Math.max(0,(H.current[c]??"").length-1)))),c})},[i]),O=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);if(0===a.length)return;let c=a[b];F.current=[c];let d=[...a];d.splice(b,1),0===d.length&&d.push("");let e=Math.min(b,d.length-1);L(d,{lineIndex:b,oldLines:[c],newLines:[],cursorLine:b}),q(e),s(0)},[p,L]),P=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);a.length>0&&(F.current=[a[b]])},[p]),Q=(0,d.useCallback)(()=>{let a=F.current;if(0===a.length)return;let b=H.current,c=Math.min(p,b.length-1)+1,d=[...b];d.splice(c,0,...a),L(d,{lineIndex:c,oldLines:[],newLines:[...a],cursorLine:p}),q(c),s(0),i(c,"auto")},[p,L,i]),R=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1),c=a[b];if(!c||0===c.length)return;let d=c.substring(1),e=[...a];e[b]=d,L(e,{lineIndex:b,oldLines:[c],newLines:[d],cursorLine:p})},[p,L]),S=(0,d.useCallback)(()=>{let a=D.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?d.splice(b.lineIndex,0,...b.oldLines):0===b.oldLines.length&&b.newLines.length>0?(d.splice(b.lineIndex,b.newLines.length),0===d.length&&d.push("")):d.splice(b.lineIndex,b.newLines.length,...b.oldLines),E.current.push(b),c(d.join("\n")),q(Math.min(b.cursorLine,d.length-1)),i(Math.min(b.cursorLine,d.length-1),"auto"),0===a.length&&u(!1)},[c,i]),T=(0,d.useCallback)(()=>{let a=E.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?(d.splice(b.lineIndex,b.oldLines.length),0===d.length&&d.push("")):0===b.oldLines.length&&b.newLines.length>0?d.splice(b.lineIndex,0,...b.newLines):d.splice(b.lineIndex,b.oldLines.length,...b.newLines),D.current.push(b),u(!0),c(d.join("\n"));let e=b.lineIndex+Math.max(0,b.newLines.length-1);q(Math.min(e,d.length-1)),i(Math.min(e,d.length-1),"auto")},[c,i]),U=(0,d.useCallback)(a=>{let b=H.current,c=Math.min(p,b.length-1);if("o"===a||"O"===a){let d="o"===a?c+1:c,e=[...b];e.splice(d,0,""),L(e,{lineIndex:d,oldLines:[],newLines:[""],cursorLine:p}),c=d,q(d)}o("insert"),f(c,r,a)},[p,r,L,f]),V=(0,d.useCallback)(()=>{o("normal"),J()},[J]),W=(0,d.useCallback)(()=>{o("command"),y("")},[]),X=(0,d.useCallback)(()=>{o("normal"),y("")},[]),Y=(0,d.useCallback)(()=>{o("search"),A("")},[]),Z=(0,d.useCallback)(()=>{o("normal"),A("")},[]),$=(0,d.useCallback)(a=>{let b=a.trim();if("w"===b){g?.(),o("normal"),y("");return}if("q"===b){o("normal"),y("");return}if("wq"===b){g?.(),o("normal"),y("");return}if("noh"===b||"nohlsearch"===b){m?.(),o("normal"),y("");return}let c=parseInt(b,10);if(!isNaN(c)&&c>0){let a=Math.min(c-1,H.current.length-1);q(a),i(a,"center"),o("normal"),y("");return}o("normal"),y("")},[g,m,i]),_=(0,d.useCallback)(a=>{if(!a){o("normal"),A("");return}C(a),j?.(a),o("normal"),A("")},[j]),aa=(0,d.useCallback)(a=>{if(!b)return!1;let c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;if("insert"===n)return("Escape"===a.key||!!c)&&(V(),!0);if("command"===n)return!a.isComposing&&("Escape"===a.key||c?X():"Enter"===a.key?$(x):"Backspace"===a.key?0===x.length?X():y(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||y(b=>b+a.key),!0);if("search"===n)return!a.isComposing&&("Escape"===a.key||c?Z():"Enter"===a.key?_(z):"Backspace"===a.key?0===z.length?Z():A(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||A(b=>b+a.key),!0);if(p<0&&(q(0),s(0)),a.metaKey)return!1;if(a.ctrlKey)return"d"===a.key?(N(Math.max(1,Math.floor(h()/2))),J(),!0):"u"===a.key?(N(-Math.max(1,Math.floor(h()/2))),J(),!0):"r"===a.key&&(T(),J(),!0);let d=a.key,e=v+d;if("g"===e)return w("g"),K(),!0;if("gg"===e)return M(0),J(),!0;if("d"===e)return w("d"),K(),!0;if("dd"===e)return O(),J(),!0;if("y"===e)return w("y"),K(),!0;if("yy"===e)return P(),J(),!0;if(v&&e!==d&&J(),"j"===d||"ArrowDown"===d)return N(1),!0;if("k"===d||"ArrowUp"===d)return N(-1),!0;if("h"===d||"ArrowLeft"===d)return s(a=>Math.max(0,a-1)),!0;if("l"===d||"ArrowRight"===d){let a=Math.max(0,(H.current[p]??"").length-1);return s(b=>Math.min(a,b+1)),!0}if("0"===d)return s(0),!0;if("$"===d)return s(Math.max(0,(H.current[p]??"").length-1)),!0;if("^"===d){let a=(H.current[p]??"").search(/\S/);return s(a>=0?a:0),!0}return"G"===d?(M(H.current.length-1),!0):"x"===d?(R(),!0):"p"===d?(Q(),!0):"u"===d?(S(),!0):"i"===d||"a"===d||"I"===d||"A"===d||"o"===d||"O"===d?(U(d),!0):"/"===d?(Y(),!0):"n"===d?(k?.(),!0):"N"===d?(l?.(),!0):":"===d?(W(),!0):"Escape"!==d&&1===d.length},[b,n,v,x,z,p,V,U,W,X,Y,Z,$,_,N,M,h,O,P,Q,R,S,T,J,K,k,l]);return{state:{mode:n,cursorLine:p,cursorCol:r,isDirty:t,keyBuffer:v,commandInput:x,searchInput:z,lastSearch:B},handleKeyDown:aa,enterNormal:V,enterInsert:U,setCursorLine:q,setCursorCol:s,setCommandInput:y,setSearchInput:A,setIsDirty:u,clearUndoHistory:(0,d.useCallback)(()=>{D.current=[],E.current=[]},[])}}},83768:(a,b,c)=>{"use strict";c.d(b,{DP:()=>g,NP:()=>i,Ql:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g(){let a=(0,e.useContext)(f);if(!a)throw Error("useTheme must be used within a ThemeProvider");return a}function h(){return(0,e.useContext)(f)}function i({children:a}){let[b,c]=(0,e.useState)("system"),[g,h]=(0,e.useState)("light"),j=(0,e.useCallback)(()=>"light",[]),k=(0,e.useCallback)(a=>{let b=document.documentElement;b.classList.remove("light","dark"),b.classList.add(a),h(a);let c=document.querySelector('meta[name="theme-color"]'),d="dark"===a?"#111113":"#f9f9fb";c&&c.setAttribute("content",d)},[]),l=(0,e.useCallback)(a=>{c(a),localStorage.setItem("theme",a),k("system"===a?j():a),document.querySelectorAll("iframe").forEach(b=>{b.contentWindow?.postMessage({type:"THEME_CHANGE",theme:a},"*")})},[j,k]);return(0,d.jsx)(f.Provider,{value:{theme:b,resolvedTheme:g,setTheme:l},children:a})}},84398:(a,b,c)=>{"use strict";function d(a){let b=a.split("/").pop()?.toLowerCase()??"";switch(b.includes(".")?b.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";case"lean":return"lean";default:return null}}c.d(b,{k:()=>d})},84747:(a,b,c)=>{"use strict";c.d(b,{Workspace:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Workspace() from the server but Workspace is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/Workspace.tsx","Workspace")},84835:(a,b,c)=>{"use strict";c.d(b,{W:()=>f});var d=c(50300);let e=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function f(){return a=>{(0,d.YR)(a,"element",a=>{if(e.has(a.tagName)&&a.position&&(a.properties||(a.properties={}),a.properties["data-source-start"]=a.position.start.line,a.properties["data-source-end"]=a.position.end.line,"pre"===a.tagName)){let b=a.children?.find(a=>"element"===a.type&&"code"===a.tagName);b&&(b.properties||(b.properties={}),b.properties["data-source-start"]=a.position.start.line,b.properties["data-source-end"]=a.position.end.line)}})}}},84844:(a,b,c)=>{"use strict";c.d(b,{i:()=>p});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(91579),i=c(7031),j=c(44256),k=c(7833),l=c(33281),m=c(89800),n=c(25419);function o(a){if(0===a.length)return"";let b=[g.A.t("comments.codeRef"),""],c=a.filter(a=>a.filePath===h.Un),d=a.filter(a=>a.filePath!==h.Un);for(let a of(d.length>0&&d.forEach((a,c)=>{let d=a.startLine>0||a.endLine>0?`:${a.startLine}-${a.endLine}`:"";b.push(`[${c+1}] ${a.filePath}${d}`),b.push("```"),b.push(a.codeContent),b.push("```"),a.content&&b.push(g.A.t("comments.note",{content:a.content})),b.push("")}),c)){let c=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");b.push(c),a.content&&b.push(a.content),b.push("")}return b.join("\n").trim()}function p({isOpen:a,onClose:b,cwd:c,onNavigateToComment:g}){let{t:q}=(0,f.Bd)(),r=(0,i.r)(),[s,t]=(0,e.useState)([]),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(!1);(0,e.useCallback)(async()=>{if(!c)return;v(!0);let a=await l.t4.runPromiseExit((0,m.$)(c));"Success"===a._tag?t(a.value.comments??[]):console.error("Failed to load comments:",a.cause),v(!1)},[c]);let C=async a=>{let b=await l.t4.runPromiseExit((0,m.Tu)(c,a));"Success"===b._tag?(t(b=>b.filter(b=>b.id!==a)),(0,h.Cm)()):console.error("Failed to delete comment:",b.cause)},D=async a=>{x(a.id);try{let b="";if(a.selectedText)b=a.selectedText;else{let d=await l.t4.runPromiseExit((0,n.K)(c,a.filePath));if("Success"!==d._tag||!d.value.ok)throw Error("Failed to read file");b=(d.value.data?.content||"").split("\n").slice(a.startLine-1,a.endLine).join("\n")}let d={filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,content:a.content,codeContent:b},e=o([d]);await navigator.clipboard.writeText(e),(0,k.oR)(q("toast.copiedComment"))}catch(a){console.error("Failed to copy comment:",a)}finally{x(null)}},E=async()=>{if(0!==s.length){z(!0);try{let a=await (0,h.$3)(c),b=o(a);await navigator.clipboard.writeText(b),(0,k.oR)(q("toast.copiedAllComments"))}catch(a){console.error("Failed to copy all comments:",a)}finally{z(!1)}}},F=async()=>{if(0!==s.length&&r&&!r.isLoading&&!A){B(!0);try{let a=(await (0,h.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0})),d=(0,h.Gw)(a,"");r.sendMessage(d),await (0,h.RP)(c),t([]),b()}catch(a){console.error("Failed to send comments to AI:",a)}finally{B(!1)}}},G=s.reduce((a,b)=>(a[b.filePath]||(a[b.filePath]=[]),a[b.filePath].push(b),a),{});if(!a)return null;let H=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-lv3 flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border ",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:q("comments.allComments")}),s.length>0&&(0,d.jsx)("button",{onClick:E,disabled:y,className:"p-1 rounded hover:bg-hover text-muted-foreground disabled:opacity-50",title:q("comments.copyAllComments"),children:y?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:u?(0,d.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:q("common.loading")}):0===s.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,d.jsx)("svg",{className:"w-12 h-12 mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsx)("span",{children:q("comments.noComments")})]}):(0,d.jsx)("div",{className:"space-y-4",children:Object.entries(G).map(([a,b])=>(0,d.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:a===h.Un?q("comments.aiReply"):a}),(0,d.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",q("comments.nComments",{count:b.length}),")"]})]}),(0,d.jsx)("div",{className:"divide-y divide-border",children:b.map(a=>{var b;return(0,d.jsx)("div",{className:"px-3 py-2 hover:bg-hover cursor-pointer group",onClick:()=>g?.(a),children:(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.startLine>0||a.endLine>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-brand font-mono",children:[q("common.line")," ",a.startLine===a.endLine?a.startLine:`${a.startLine}-${a.endLine}`]}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",q("comments.linesCount",{count:a.endLine-a.startLine+1}),")"]})]}):a.selectedText?(0,d.jsxs)("span",{className:"text-xs text-muted-foreground italic truncate max-w-[200px]",children:["“",a.selectedText.slice(0,50),a.selectedText.length>50?"...":"","”"]}):null,(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:(b=a.updatedAt||a.createdAt)?new Date(b).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):""})]}),(0,d.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.content||(0,d.jsx)("span",{className:"text-muted-foreground italic",children:q("comments.noContent")})})]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),D(a)},disabled:w===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground transition-opacity disabled:opacity-50",title:q("common.copy"),children:w===a.id?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:b=>{b.stopPropagation(),C(a.id)},className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground hover:text-red-9 transition-opacity",title:q("common.delete"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})},a.id)})})]},a))})}),(0,d.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:q("comments.totalComments",{count:s.length})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[r&&(0,d.jsx)("button",{onClick:F,disabled:0===s.length||r.isLoading||A,className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",title:r.isLoading?q("comments.aiResponding"):void 0,children:A?q("comments.submitting"):q("comments.sendToAI")}),(0,d.jsx)("button",{onClick:async()=>{0===s.length||await (0,h.RP)(c)&&t([])},disabled:0===s.length,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 disabled:opacity-50 disabled:cursor-not-allowed",children:q("comments.clearAll")})]})]})]})});return(0,d.jsx)(j.ZL,{children:H})}},85655:(a,b,c)=>{"use strict";c.d(b,{Bj:()=>j,CM:()=>t,FK:()=>s,Iz:()=>n,MB:()=>u,Ub:()=>p,X0:()=>o,Zi:()=>k,lv:()=>m,oh:()=>r,r4:()=>h,ue:()=>i,w2:()=>q,yy:()=>l});var d=c(79606),e=c(71192);let f=a=>d.$mh({try:async()=>{let b=await fetch(a);if(!b.ok){let a;try{a=(await b.json()).error}catch{}throw Error(a||`HTTP ${b.status}`)}return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),h=a=>f(`/api/git/branches?cwd=${encodeURIComponent(a)}`).pipe(d.qIB(b=>"Failed to get branches"===b.error?d.fJG(new e.m_({resource:"git-repo",id:a})):d.PyW(b))),i=a=>f(`/api/git/current-branch?cwd=${encodeURIComponent(a)}`),j=(a,b,c,d)=>f(`/api/git/commits?cwd=${encodeURIComponent(a)}&branch=${encodeURIComponent(b)}&limit=${c}${"number"==typeof d?`&offset=${d}`:""}`),k=(a,b,c)=>f(`/api/git/commit-diff?cwd=${encodeURIComponent(a)}&hash=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),l=(a,b,c)=>f(`/api/git/branch-diff?cwd=${encodeURIComponent(a)}&base=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),m=a=>f(`/api/git/status?cwd=${encodeURIComponent(a)}`),n=(a,b)=>g("/api/git/stage",{cwd:a,files:b}),o=(a,b)=>g("/api/git/unstage",{cwd:a,files:b}),p=(a,b,c)=>g("/api/git/discard",{cwd:a,files:b,isUntracked:c}),q=(a,b,c,d)=>{let e=new URLSearchParams({cwd:a,file:b,type:c});return d&&e.set("oldPath",d),f(`/api/git/diff?${e}`)},r=a=>f(`/api/git/diff?${a.toString()}`),s=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),t=a=>d.$mh({try:async()=>{let b=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/git/worktree failed",cause:a})}),u=a=>f(`/api/projectGraph/search?${a.toString()}`)},85905:(a,b,c)=>{"use strict";c.d(b,{J:()=>bd});var d=c(48249),e=c(67484),f=c(44384),g=c(46674),h=c(15273),i=c(62956),j=c(82594),k=c(10316),l=c(72419),m=c(44218),n=c(7833),o=c(34678);function p(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}var q=c(29939),r=c(33281),s=c(74429);function t({open:a,anchorRef:b,initialValue:c,onCancel:g,onSave:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(c),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(null),p=(0,e.useRef)(null),q=(0,e.useRef)(null);if((0,e.useCallback)(()=>{let a=b.current;if(!a)return;let c=a.getBoundingClientRect(),d=q.current?.offsetHeight??0,e=c.bottom+4;if(d&&e+d>window.innerHeight-8){let a=c.top-4-d;a>=8&&(e=a)}let f=c.left;o({top:e,left:f=Math.max(f=Math.min(f,window.innerWidth-260-8),8)})},[b]),!a||"u"<typeof document)return null;let r=async()=>{if(!l){m(!0);try{await h(j.trim())}finally{m(!1)}}};return(0,s.createPortal)((0,d.jsxs)("div",{ref:q,style:{top:n?.top??0,left:n?.left??0,width:260,visibility:n?"visible":"hidden"},className:"fixed z-[100] rounded-lg border border-border bg-card p-3 shadow-lv3",children:[(0,d.jsx)("div",{className:"mb-2 text-sm font-medium text-foreground",children:i("shortIdBadge.dialogTitle")}),(0,d.jsx)("input",{ref:p,type:"text",value:j,onChange:a=>k(a.target.value.slice(0,64)),onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||229===a.keyCode||(a.preventDefault(),r())},placeholder:i("shortIdBadge.dialogPlaceholder"),maxLength:64,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm font-mono outline-none focus:border-brand"}),(0,d.jsxs)("div",{className:"mt-3 flex justify-end gap-2 text-sm",children:[(0,d.jsx)("button",{onClick:g,className:"rounded px-3 py-1 text-muted-foreground hover:bg-hover",disabled:l,children:i("common.cancel")}),(0,d.jsx)("button",{onClick:()=>void r(),className:"rounded bg-brand px-3 py-1 text-white hover:opacity-90 disabled:opacity-50",disabled:l,children:l?"…":i("common.save")})]})]}),document.body)}var u=c(23328);let v=(0,e.memo)(function({shortId:a,type:b,onRegister:c,onUnregister:g,fullId:h,projectCwd:i,tabId:j,registered:k}){let{t:l}=(0,f.Bd)(),[m,o]=(0,e.useState)(!1),p=k??m,[s,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(!1),y=(0,e.useRef)(null);(0,e.useEffect)(()=>{if(!h||!i||!j)return;let a=!1;return r.t4.runPromiseExit((0,u.MR)(i,j)).then(b=>{if(a||"Success"!==b._tag)return;let c=b.value[h];"string"==typeof c&&v(c)}),()=>{a=!0}},[h,i,j]),(0,q.h)({url:"/ws/global-state",enabled:!!h&&!!i&&!!j,onMessage:a=>{"console-delta"!==a.type||"rename"!==a.op||a.cwd!==i||a.tabId!==j||a.titles&&h&&Object.prototype.hasOwnProperty.call(a.titles,h)&&v(a.titles[h]??"")}});let z=(0,e.useCallback)(async d=>{if(d.stopPropagation(),p)await g(),o(!1),(0,n.oR)(l("toast.disconnected",{id:a}));else{await c(),o(!0);let d=`cockpit ${b} ${a}`;navigator.clipboard.writeText(d),(0,n.oR)(l("toast.copiedCommand",{command:d}))}},[p,a,b,c,g,l]),A=!!(h&&i&&j),B=(0,e.useCallback)(a=>{a.stopPropagation(),A&&x(!0)},[A]),C=(0,e.useCallback)(async a=>{h&&i&&j&&("Success"===(await r.t4.runPromiseExit((0,u.y8)(i,j,h,a)))._tag&&v(a),x(!1))},[h,i,j]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{onClick:z,onDoubleClick:a=>a.stopPropagation(),className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:p?l("shortIdBadge.clickToDisconnect"):l("shortIdBadge.clickToRegister"),children:[(0,d.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${p?"bg-green-500":"bg-muted-foreground/40"}`}),a]}),A&&(s?(0,d.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground",title:l("shortIdBadge.titleSet",{title:s})||s,children:[(0,d.jsx)("span",{className:"px-1 py-0.5 rounded bg-muted/40 max-w-[120px] truncate",children:s}),(0,d.jsx)("button",{ref:y,onClick:B,className:"opacity-50 hover:opacity-100 transition-opacity","aria-label":l("shortIdBadge.editTitle"),title:l("shortIdBadge.editTitle"),children:"✎"})]}):(0,d.jsxs)("button",{ref:y,onClick:B,className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground/50 hover:text-muted-foreground italic transition-colors",title:l("shortIdBadge.setTitle"),children:["(",l("shortIdBadge.setTitlePlaceholder"),") ✎"]})),(0,d.jsx)(t,{open:w,anchorRef:y,initialValue:s,onCancel:()=>x(!1),onSave:C})]})});var w=c(28602),x=c(79606);let y=(0,e.lazy)(()=>c.e(8764).then(c.bind(c,98764)).then(a=>({default:a.XtermRenderer}))),z={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},A=/\x1b\[[0-9;]*m/g;function B({output:a,query:b,mode:c,currentIdx:f,matchListRef:g}){let h=(0,e.useRef)(null);h.current||(h.current=new o.v,h.current.use_classes=!0);let i=a.split("\n"),j=b.toLowerCase(),k=0;return g.current=[],(0,d.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:i.map((a,b)=>{let e=a.replace(A,""),i=e.toLowerCase().includes(j);if("filter"===c&&!i)return null;if(!i){let c=h.current.ansi_to_html(a);return(0,d.jsx)("div",{dangerouslySetInnerHTML:{__html:c}},b)}let l=[],m=0,n=e.toLowerCase(),o=0;for(;o<n.length;){let a=n.indexOf(j,o);if(-1===a)break;a>m&&l.push((0,d.jsx)("span",{children:e.slice(m,a)},`t${m}`));let b=k++,c=b===f;l.push((0,d.jsx)("mark",{ref:a=>{g.current[b]=a},className:c?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:e.slice(a,a+j.length)},`m${a}`)),o=m=a+j.length}return m<e.length&&l.push((0,d.jsx)("span",{children:e.slice(m)},`t${m}`)),(0,d.jsx)("div",{children:l},b)})})}let C=(0,e.memo)(function({commandId:a,tabId:b,projectCwd:c,command:q,output:s,exitCode:t,isRunning:A,selected:C,onSelect:D,onInterrupt:E,onStdin:F,onDelete:G,onRerun:H,timestamp:I,usePty:J,subscribePtyOutput:K,subscribePtyReset:L,subscribePtyRefresh:M,onPtyResize:N,onToggleMaximize:O,maximized:P,expandedHeight:Q,bubbleContentHeight:R,onTitleMouseDown:S}){let{t:T}=(0,f.Bd)(),U=(0,e.useRef)(null),V=(0,e.useRef)(null),W=(0,e.useRef)(!0),X=(0,e.useRef)(null),Y=(0,e.useRef)(null),Z=(a=>{if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`})(I),$=a&&b?p(b+a):void 0,[_,aa]=(0,e.useState)(!1),[ab,ac]=(0,e.useState)(""),ad=(0,e.useRef)(null),ae=(0,e.useRef)(null);(0,e.useEffect)(()=>{if(!K||!a)return;let b=()=>ad.current?K(a,ad.current.write):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[K,a]),(0,e.useEffect)(()=>{if(!L||!a)return;let b=()=>ad.current?L(a,ad.current.reset):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[L,a]),(0,e.useEffect)(()=>{if(!M||!a)return;let b=()=>ad.current?M(a,ad.current.refresh):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[M,a]);let[af,ag]=(0,e.useState)(!1),[ah,ai]=(0,e.useState)(""),[aj,ak]=(0,e.useState)("search"),[al,am]=(0,e.useState)(0),an=(0,e.useRef)([]),ao=(0,e.useRef)(null),ap=(0,e.useRef)(0);(0,e.useEffect)(()=>{ao.current||(ao.current=new o.v,ao.current.use_classes=!0)},[]),(0,e.useLayoutEffect)(()=>{let a=V.current;if(a&&ao.current){if(s.length<ap.current&&(ao.current=new o.v,ao.current.use_classes=!0,ap.current=0,a.innerHTML=""),s.length>ap.current){let b=s.slice(ap.current),c=ao.current.ansi_to_html(b);ap.current=s.length,a.insertAdjacentHTML("beforeend",c)}if(U.current){let a=U.current.scrollHeight>U.current.clientHeight;aa(a),a&&(U.current.scrollTop=U.current.scrollHeight)}}},[s]),(0,e.useEffect)(()=>(A&&W.current&&U.current&&(null!==X.current&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight),X.current=null})),()=>{null!==X.current&&cancelAnimationFrame(X.current)}),[s,A]),(0,e.useEffect)(()=>{if(!P)return;let a=a=>{"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),O?.())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[P,O]);let aq=s?s.split("\n").length:0,ar=(0,e.useCallback)(()=>{ag(!0),requestAnimationFrame(()=>ae.current?.focus())},[]),as=(0,e.useCallback)(()=>{ag(!1),ai(""),am(0),ad.current?.clearSearch()},[]),at=(0,e.useCallback)(a=>{a.trim()&&(J?ad.current?.findNext(a):am(a=>{let b=a+1,c=an.current[b];return c?(c.scrollIntoView({block:"nearest"}),b):(an.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[J]),au=(0,e.useCallback)(a=>{a.trim()&&(J?ad.current?.findPrevious(a):am(a=>{let b=a-1;if(b>=0)return an.current[b]?.scrollIntoView({block:"nearest"}),b;let c=an.current.length-1;return c>=0&&an.current[c]?.scrollIntoView({block:"nearest"}),Math.max(c,0)}))},[J]);(0,e.useEffect)(()=>{if(!C)return;let a=a=>{if((a.metaKey||a.ctrlKey)&&"f"===a.key){a.preventDefault(),a.stopPropagation(),ar();return}if("Escape"===a.key&&af){a.preventDefault(),a.stopPropagation(),as();return}};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[C,af,ar,as]);let av=P&&Q?Q-41:R??360;return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-card text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${P?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${P?"":C?"border-brand":"border-brand/30"}`,onClick:D,children:[P?(0,d.jsxs)("div",{onDoubleClick:()=>O?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,d.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,d.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:q}),A&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),T("console.runningText")]}),A&&E&&(0,d.jsx)("button",{onClick:E,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-lv2 active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,d.jsx)("button",{onClick:()=>O?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:T("console.restoreTooltip",{modKey:(0,w.Mu)()}),children:(0,d.jsx)(g.A,{className:"w-4 h-4"})})]}):(0,d.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>S?.(),onDoubleClick:a=>{a.stopPropagation(),O?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${C?"border-brand":"border-brand/30"}`,children:[(0,d.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:">_"}),$&&a&&b&&(0,d.jsx)(v,{shortId:$,type:"terminal",onRegister:()=>{r.t4.runFork((0,u.Ok)({tabId:b,commandId:a,command:q,projectCwd:c}).pipe(x.NWQ(()=>x.rIH)))},onUnregister:()=>{r.t4.runFork((0,u.jO)({commandId:a}).pipe(x.NWQ(()=>x.rIH)))},fullId:a,projectCwd:c,tabId:b}),(0,d.jsx)("span",{className:"font-mono text-foreground truncate",children:q}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(q),(0,n.oR)(T("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:T("console.copyCommand"),children:(0,d.jsx)(h.A,{className:"w-3.5 h-3.5"})}),(0,d.jsx)("span",{className:"flex-1"}),_&&!A&&(0,d.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:T("console.totalLines",{count:aq})}),s&&(0,d.jsx)("button",{onClick:a=>{let b;a.stopPropagation(),b=s.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(b),(0,n.oR)(T("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:T("console.copyOutput"),children:(0,d.jsx)(i.A,{className:"w-3.5 h-3.5"})}),H&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),H()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:T("console.rerun"),children:(0,d.jsx)(j.A,{className:"w-3.5 h-3.5"})}),G&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),G()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:T("console.deleteRecord"),children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),af&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,d.jsx)(k.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,d.jsx)("input",{ref:ae,value:ah,onChange:a=>{let b=a.target.value;ai(b),am(0),J&&(b.trim()?ad.current?.findNext(b):ad.current?.clearSearch())},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?au(ah):at(ah))},placeholder:T("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none",autoComplete:"off",spellCheck:"false"}),!J&&(0,d.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,d.jsx)("button",{onClick:()=>ak("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===aj?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:T("console.searchMode")}),(0,d.jsx)("button",{onClick:()=>ak("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===aj?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:T("console.filterMode")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)("button",{onClick:()=>au(ah),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:T("console.prevShiftEnter"),children:(0,d.jsx)(l.A,{className:"w-3.5 h-3.5"})}),(0,d.jsx)("button",{onClick:()=>at(ah),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:T("console.nextEnter"),children:(0,d.jsx)(m.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("button",{onClick:as,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),J?(0,d.jsxs)("div",{className:"relative group",style:{height:av,overflow:"hidden"},children:[(0,d.jsx)(e.Suspense,{fallback:(0,d.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:av},children:T("console.loadingTerminal")}),children:(0,d.jsx)(y,{ref:ad,output:s,isRunning:A,onInput:F,onResize:N,maximized:P,height:av,directWrite:!!K})}),!A&&(0,d.jsx)("div",{className:"absolute inset-0 bg-background/50 pointer-events-none"}),!A&&H&&(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",onClick:a=>{a.stopPropagation(),H()},children:(0,d.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-tooltip text-tooltip-foreground text-xs",children:[(0,d.jsx)(j.A,{className:"w-3.5 h-3.5"}),T("console.rerun")]})})]}):(0,d.jsx)("div",{ref:U,className:"overflow-auto px-4 py-2",style:{height:av},onScroll:()=>{if(U.current){let{scrollTop:a,scrollHeight:b,clientHeight:c}=U.current;W.current=b-a-c<50}},children:af&&ah.trim()?(0,d.jsx)(B,{output:s,query:ah,mode:aj,currentIdx:al,matchListRef:an}):(0,d.jsx)("pre",{ref:V,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),A&&!P&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),J?(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:T("console.clickToInput")}):F?(0,d.jsx)("input",{ref:Y,value:ab,onChange:a=>ac(a.target.value),onKeyDown:a=>{if(a.ctrlKey&&!a.metaKey&&!a.altKey){let b=z[a.key.toLowerCase()];if(b){a.preventDefault(),a.stopPropagation(),F(b);return}}"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),F(ab+"\n"),ac("")),"Tab"===a.key&&(a.preventDefault(),F(" "))},placeholder:T("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none",autoComplete:"off",spellCheck:"false"}):(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:T("console.runningText")}),E&&(0,d.jsx)("button",{onClick:E,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),Z&&(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:Z})]}),!A&&void 0!==t&&!P&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===t?"bg-green-500":"bg-red-500"}`}),(0,d.jsx)("span",{children:T("console.exitCode",{code:t})}),(0,d.jsx)("span",{className:"flex-1"}),Z&&(0,d.jsx)("span",{className:"text-[11px] flex-shrink-0",children:Z})]})]})})});var D=c(64676);let E=new Map;function F(a){E.set(a.type,a)}function G(a){return E.get(a)}function H(a){for(let b of E.values())if(b.match(a))return b;return null}c(57031),c(88214);var I=c(71192);let J=(a,b)=>x.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new I.uV({message:`POST ${a} failed`,cause:b})}),K=(a,b)=>r.t4.runPromise(J(`/api/${a}/disconnect`,{id:b}).pipe(x.NWQ(()=>x.rIH))),L=a=>r.t4.runPromise(J("/api/browser/unregister",{id:a}).pipe(x.NWQ(()=>x.rIH))),M=a=>r.t4.runPromise(a.pipe(x.h9N(a=>x.OH5(()=>{if(a.cause instanceof Error)throw a.cause;throw Error(a.message)})))),N=(a,b)=>{if(a&&"object"==typeof a&&"error"in a){let b=a.error;if("string"==typeof b&&b.length>0)return b;if(b&&"object"==typeof b){let a=b.message;if("string"==typeof a&&a.length>0)return a;let c=b._tag;if("string"==typeof c&&c.length>0)return c}}return`HTTP ${b}`},O=(a,b)=>M(x.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(N(d,c.status));return d},catch:b=>new I.uV({message:`POST ${a} failed`,cause:b})})),P=(a,b)=>M(x.$mh({try:async()=>{let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(N(e,d.status));return e},catch:b=>new I.uV({message:`GET ${a} failed`,cause:b})})),Q=(a,b)=>M(x.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return c.blob()},catch:b=>new I.uV({message:`POST blob ${a} failed`,cause:b})}));var R=c(15105);function S(a){let b=a.trim().toLowerCase();return b.startsWith("http://")||b.startsWith("https://")}async function T(a){let b=(0,R.f)()?.id??null;return!!b&&new Promise(c=>{try{let d=globalThis.chrome?.runtime;if(!d?.sendMessage)return void c(!1);let e=setTimeout(()=>c(!1),2e3);d.sendMessage(b,{type:"prepare-iframe",url:a},a=>{clearTimeout(e),c(a?.ok??!1)})}catch{c(!1)}})}function U({url:a,id:b,selected:c,maximized:g,expandedHeight:h,bubbleContentHeight:i,onSelect:j,onClose:k,onToggleMaximize:l,onNewTab:m,timestamp:o,onTitleMouseDown:q,initialSleeping:r,onSleep:s,onWake:t,projectCwd:u,baseCwd:x,tabId:y,autoConnect:z}){let{t:A,i18n:B}=(0,f.Bd)(),[C,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(null),[H,I]=(0,e.useState)(a),[J,K]=(0,e.useState)(null),[M,N]=(0,e.useState)(r??!1),O=(0,e.useRef)(null),P=(0,e.useRef)(null),Q=(0,e.useRef)(null);(0,e.useRef)(!0),(0,e.useCallback)(()=>{M||(N(!0),K(null),s?.(b))},[M,b,s]),(0,e.useCallback)(()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]);let{shortId:R,connected:V,connect:W,disconnect:X}=function(a,b,c){let d=(0,e.useMemo)(()=>p(a),[a]),[f,g]=(0,e.useState)(!1),h=(0,e.useRef)(null);(0,e.useRef)([]),(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(c);let i=(0,e.useRef)([]);(0,e.useCallback)(a=>{let c=b.current;if(!c?.contentWindow){let b=h.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"browser:cmd-result",reqId:a.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}c.contentWindow.postMessage({type:"cockpit:cmd",reqId:a.reqId,action:a.action,params:a.params},"*")},[b]);let j=(0,e.useCallback)(()=>f&&h.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(a=>{i.current.push(a),f||g(!0)}),[f]);return{shortId:d,connected:f,connect:j,disconnect:(0,e.useCallback)(()=>{g(!1)},[])}}(b,Q,!!J&&!M&&!C);(0,e.useRef)(V).current=V,(0,e.useRef)(!1);let Y=(0,e.useCallback)(()=>{if(N(!1),t?.(b),!S(a))return void K((0,D.Kx)(a)?(0,D.hE)(a,x):(0,D.Xe)(a,x));let c=function(a){if(!a)return a;try{let b=new URL(a);return b.searchParams.set("_cockpit","1"),b.toString()}catch{let b=a.includes("?")?"&":"?";return`${a}${b}_cockpit=1`}}(a);!function(a){try{let b=new URL(a).hostname;return"localhost"===b||"127.0.0.1"===b}catch{return!1}}(a)?T(a).then(()=>K(c)):K(c)},[a,b,t,x]),Z=(0,e.useCallback)(()=>{E(!1);let a=Q.current?.contentWindow;if(!a)return;let b=document.documentElement.classList.contains("dark");a.postMessage({type:"THEME_CHANGE",theme:b?"dark":"light"},"*"),a.postMessage({type:"cockpit:language-change",lang:B.language},"*")},[B]),$=(0,e.useCallback)(()=>{E(!1),G(A("browser.pageLoadFailed"))},[]),_=(0,e.useCallback)(()=>{if(M)return void Y();let a=P.current?.querySelector("iframe");if(a&&J){E(!0),G(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[M,Y,J]),aa=(0,e.useCallback)(()=>{if(!H)return;let a=S(H)?H:(0,D.Kx)(H)?(0,D.hE)(H,x):(0,D.Xe)(H,x);window.open((0,D.PB)(a,window.location.origin),"_blank")},[H,x]),ab=function(a){if(!a)return"";try{let b=new URL(a);return b.port?`${b.hostname}:${b.port}`:b.hostname}catch{return a.split("/").pop()||a}}(H);return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-accent text-foreground
734
- relative transition-colors cursor-pointer
735
- ${g?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
736
- ${g?"":c?"border-brand":"border-brand/30"}`,onClick:g?void 0:j,children:[g?(0,d.jsxs)("div",{onDoubleClick:l,className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41},children:[(0,d.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),R&&(0,d.jsx)(v,{shortId:R,type:"browser",registered:V,onRegister:()=>W(),onUnregister:async()=>{X(),await L(R)},fullId:b,projectCwd:u,tabId:y}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono",children:H||A("browser.blankPage")}),H&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(H),(0,n.oR)(A("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:A("browser.copyUrl"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("span",{className:"flex-1"}),C&&(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,d.jsx)("button",{onClick:_,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:A("common.refresh"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:aa,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:A("browser.openInNewWindow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,d.jsx)("button",{onClick:l,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:A("browser.exitMaximize",{modKey:(0,w.Mu)()}),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})})})]}):(0,d.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>q?.(),onDoubleClick:a=>{a.stopPropagation(),l()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing
737
- ${c?"border-brand":"border-brand/30"}`,children:[(0,d.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-3 h-3 inline-block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),R&&(0,d.jsx)(v,{shortId:R,type:"browser",registered:V,onRegister:()=>W(),onUnregister:async()=>{X(),await L(R)},fullId:b,projectCwd:u,tabId:y}),(0,d.jsx)("span",{className:"font-mono text-foreground truncate",children:H||A("browser.blankPage")}),H&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(H),(0,n.oR)(A("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:A("browser.copyUrl"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("span",{className:"flex-1"}),C&&(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),aa()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:A("browser.openInNewWindow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),_()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:A("common.refresh"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:A("common.close"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{ref:P,className:"w-full",style:{height:g&&h?h-41:i??360},children:M?(0,d.jsxs)("div",{className:"relative overflow-hidden cursor-pointer group h-full",onClick:a=>{a.stopPropagation(),_()},children:[(0,d.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-muted/30",children:[(0,d.jsx)("svg",{className:"w-10 h-10 mb-2 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground/60",children:ab})]}),(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-black/60 text-white text-xs",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})}),A("browser.clickToWake")]})})]}):a?F?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center text-muted-foreground p-6 h-full",children:[(0,d.jsx)("svg",{className:"w-10 h-10 mb-3 text-red-11",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,d.jsx)("p",{className:"text-xs",children:F}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),_()},className:"mt-2 px-3 py-1 text-xs bg-secondary text-foreground rounded hover:bg-hover transition-colors",children:A("common.retry")})]}):(0,d.jsxs)("div",{className:"relative overflow-hidden h-full",style:{contain:"strict"},children:[C&&(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-card/80 z-10",children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),J?(0,d.jsx)("iframe",{ref:Q,src:J,className:"border-0 bg-white",allow:"clipboard-write; clipboard-read",style:g?{width:"100%",height:"100%"}:{position:"absolute",top:0,left:0,width:"200%",height:"200%",transform:"scale(0.5)",transformOrigin:"top left"},onLoad:Z,onError:$,title:`Browser: ${ab}`,"data-browser-id":b}):(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})})]}):(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center text-muted-foreground h-full",children:[(0,d.jsx)("svg",{className:"w-10 h-10 mb-2 text-foreground-faint",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),(0,d.jsx)("p",{className:"text-xs",children:A("browser.blankPage")})]})}),!g&&a&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${M?"bg-yellow-500":C?"bg-brand animate-pulse":F?"bg-red-500":"bg-green-500"}`}),(0,d.jsx)("span",{className:"truncate",children:M?A("browser.sleeping"):C?A("browser.loadingPage"):F?A("browser.loadFailed"):ab}),(0,d.jsx)("span",{className:"flex-1"}),o&&(0,d.jsx)("span",{className:"text-[11px] flex-shrink-0",children:function(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}(o)})]})]})})}F({type:"browser",idPrefix:"browser",match(a){let b=a.trim().toLowerCase();return!!(b.startsWith("http://")||b.startsWith("https://"))||b.endsWith(".html")||b.endsWith(".htm")||(0,D.Kx)(b)},parse:a=>({url:a.trim(),cwd:""}),fromHistory:a=>({url:a.url,cwd:a.cwd??"",autoConnect:!!a.autoConnect}),toHistory:a=>({url:a.url,cwd:a.cwd??"",...a.autoConnect?{autoConnect:!0}:{}}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k,extra:l}){return(0,d.jsx)(U,{id:a.id,url:a.url,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k,onNewTab:l?.addBrowserItem,initialSleeping:l?.initialSleeping,onSleep:l?.onSleep,onWake:l?.onWake,projectCwd:l?.projectCwd,baseCwd:a.cwd||l?.projectCwd,tabId:l?.tabId,autoConnect:a.autoConnect})}});var V=c(44256);let W=[{value:"=",label:"="},{value:"!=",label:"≠"},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:"≥"},{value:"<=",label:"≤"},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function X(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function Y(a){return`"${a.replace(/"/g,'""')}"`}function Z(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function $({text:a}){let[b,c]=(0,e.useState)(!1),[f,g]=(0,e.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),h=(0,e.useRef)(null),i=(0,e.useRef)(null),j=(0,e.useRef)(!1),k=(0,V.F2)(),l=(0,e.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{j.current||c(!1)},80)},[]),m=(0,e.useCallback)(()=>{i.current&&clearTimeout(i.current),j.current=!1,i.current=setTimeout(()=>{let a=h.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=k?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,i=d?.width??window.innerWidth,j=d?.height??window.innerHeight,l=b.left-e,m=b.top-f,n=b.bottom-f,o=Math.min(600,i-l-8),p=m-8,q=j-n-8,r=p>q&&p>80,s=r?p-4:q-4;g({x:o<200?Math.max(8,i-600-8):l,y:r?m-4:n+4,maxW:o<200?Math.min(600,i-16):o,maxH:Math.max(60,s),above:r}),c(!0)},350)},[k]),n=(0,e.useCallback)(()=>{l()},[l]),o=(0,e.useCallback)(()=>{j.current=!0,i.current&&clearTimeout(i.current)},[]),p=(0,e.useCallback)(()=>{j.current=!1,l()},[l]);return(0,d.jsxs)("span",{ref:h,className:"block truncate",onMouseEnter:m,onMouseLeave:n,children:[a,b&&(0,d.jsx)(V.ZL,{children:(0,d.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-pre-wrap break-all select-text cursor-text",style:{left:f.x,top:f.y,maxWidth:f.maxW,maxHeight:f.maxH,transform:f.above?"translateY(-100%)":void 0},onMouseEnter:o,onMouseLeave:p,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}function _({id:a,connectionString:b,displayName:c,selected:g,maximized:h,expandedHeight:i,bubbleContentHeight:j,onSelect:k,onClose:l,onToggleMaximize:m,timestamp:o,onTitleMouseDown:p}){let{t:q}=(0,f.Bd)(),{showToast:r}=(0,n.dj)(),[s,t]=(0,e.useState)("connecting"),[u,v]=(0,e.useState)(""),[x,y]=(0,e.useState)([]),[z,A]=(0,e.useState)("public"),[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)("table"),[H,I]=(0,e.useState)("data"),[J,K]=(0,e.useState)([]),[L,M]=(0,e.useState)([]),[N,R]=(0,e.useState)([]),[S,T]=(0,e.useState)([]),[U,V]=(0,e.useState)(null),[W,ab]=(0,e.useState)(0),[ae,af]=(0,e.useState)(!1),[ag,ah]=(0,e.useState)(0),[ai,aj]=(0,e.useState)(new Set),[ak,al]=(0,e.useState)(!1),[am,an]=(0,e.useState)(null),[ao,ap]=(0,e.useState)({}),[aq,ar]=(0,e.useState)(!1),[as,at]=(0,e.useState)({}),[au,av]=(0,e.useState)({}),[aw,ax]=(0,e.useState)(null),[ay,az]=(0,e.useState)(""),[aA,aB]=(0,e.useState)(null),[aC,aD]=(0,e.useState)(""),[aE,aF]=(0,e.useState)(!1),aG=(0,e.useRef)(null),aH=(0,e.useCallback)(async()=>{t("connecting"),v("");try{let c=await O("/api/db/connect",{id:a,connectionString:b});y(c.schemas||[]),c.schemas?.length>0&&!c.schemas.includes("public")&&A(c.schemas[0]),t("connected")}catch(a){v(a instanceof Error?a.message:String(a)),t("error")}},[a,b]),aI=(0,e.useCallback)(async()=>{if("connected"===s)try{let c=await P("/api/db/schemas",{id:a,connectionString:b,schema:z});C(c.tables||[])}catch{}},[a,b,z,s]),aJ=(0,e.useCallback)(async(c,d,e,f)=>{af(!0);let g=e??au,h=void 0!==f?f:aw;try{let e=`${Y(z)}.${Y(c)}`,{where:f,params:i}=function(a){let b=[],c=[],d=1;for(let[e,f]of Object.entries(a)){if(!f.enabled)continue;let a=Y(e);if("IS NULL"===f.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===f.op)b.push(`${a} IS NOT NULL`);else if("IN"===f.op){let e=f.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===e.length)continue;let g=e.map(a=>(c.push(a),`$${d++}`));b.push(`${a}::text IN (${g.join(", ")})`)}else"LIKE"===f.op||f.op,b.push(`${a}::text ${f.op} $${d++}`),c.push(f.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${Y(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,l=await O("/api/db/query",{id:a,connectionString:b,sql:k,params:i});V(l);let m=`SELECT count(*)::int AS cnt FROM ${e}${f}`,n=await O("/api/db/query",{id:a,connectionString:b,sql:m,params:i});ah(n.rows?.[0]?.cnt??0)}catch{}af(!1)},[a,b,z,au,aw]),aK=(0,e.useCallback)(async c=>{E(c),ab(0),an(null),ar(!1),aj(new Set),al(!1),av({}),ax(null);try{let d=await P("/api/db/columns",{id:a,connectionString:b,schema:z,table:c});K(d.columns||[]),M(d.primaryKeys||[]),R(d.foreignKeys||[]),T(d.indexes||[])}catch{}aJ(c,0,{},null)},[a,b,z,aJ]),aL=(0,e.useCallback)(async()=>{if(ay.trim()){aF(!0),aD(""),aB(null);try{let c=await O("/api/db/query",{id:a,connectionString:b,sql:ay});aB(c)}catch(a){aD(a instanceof Error?a.message:String(a))}aF(!1)}},[a,b,ay]),aM=(0,e.useCallback)(async()=>{if(null===am||!U||!D)return;let c=U.rows[am],d=[],e=[],f=1;for(let a of J)void 0!==ao[a.name]&&ao[a.name]!==Z(c[a.name]??"")&&(d.push(`${Y(a.name)} = $${f}`),e.push(""===ao[a.name]&&a.nullable?null:ao[a.name]),f++);if(0===d.length)return void an(null);let g=L.length>0?L:J.map(a=>a.name),h=[];for(let a of g)null===c[a]||void 0===c[a]?h.push(`${Y(a)} IS NULL`):(h.push(`${Y(a)} = $${f}`),e.push(c[a]),f++);let i=`UPDATE ${Y(z)}.${Y(D)} SET ${d.join(", ")} WHERE ${h.join(" AND ")}`;try{await O("/api/db/query",{id:a,connectionString:b,sql:i,params:e}),an(null),aJ(D,W,au,aw)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[am,U,D,J,L,ao,a,b,z,aJ,W,au,aw]),aN=(0,e.useCallback)(async()=>{if(!D)return;let c=[],d=[],e=[],f=1;for(let a of J)void 0!==as[a.name]&&""!==as[a.name]&&(c.push(Y(a.name)),d.push(as[a.name]),e.push(`$${f}`),f++);if(0===c.length)return;let g=`INSERT INTO ${Y(z)}.${Y(D)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await O("/api/db/query",{id:a,connectionString:b,sql:g,params:d}),ar(!1),at({}),aJ(D,W,au,aw)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[D,J,as,a,b,z,aJ,W,au,aw]),aO=(0,e.useCallback)(async()=>{if(0===ai.size||!U||!D)return;let c=L.length>0?L:J.map(a=>a.name),d=0;for(let e of Array.from(ai).sort((a,b)=>b-a)){let f=U.rows[e];if(!f)continue;let g=[],h=[],i=1;for(let a of c)null===f[a]||void 0===f[a]?g.push(`${Y(a)} IS NULL`):(g.push(`${Y(a)} = $${i}`),h.push(f[a]),i++);let j=`DELETE FROM ${Y(z)}.${Y(D)} WHERE ctid = (SELECT ctid FROM ${Y(z)}.${Y(D)} WHERE ${g.join(" AND ")} LIMIT 1)`;try{await O("/api/db/query",{id:a,connectionString:b,sql:j,params:h})}catch{d++}}aj(new Set),al(!1),aJ(D,W,au,aw),d>0&&alert(q("database.deleteRowsFailed",{count:d}))},[ai,U,D,L,J,a,b,z,aJ,W,au,aw]),aP=(0,e.useCallback)(async c=>{if(!D)return;if(ai.size>0&&U){let a,b=U.fields.map(a=>a.name),d=Array.from(ai).sort((a,b)=>a-b).map(a=>U.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${Y(z)}.${Y(D)}`;try{let e=await Q("/api/db/export",{id:a,connectionString:b,sql:d,format:c}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=`${D}.${c}`,g.click(),URL.revokeObjectURL(f)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[D,a,b,z,ai,U]),aQ=(0,e.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aL())},[aL]),aR=Math.max(1,Math.ceil(ag/50)),aS=(0,e.useCallback)(a=>{D&&(ab(a),aJ(D,a,au,aw))},[D,aJ,au,aw]),aT=(0,e.useCallback)((a,b)=>{let c={...au};b?c[a]=b:delete c[a],av(c),ab(0),aj(new Set),D&&aJ(D,0,c,aw)},[au,aw,D,aJ]),aU=(0,e.useCallback)(()=>{av({}),ab(0),aj(new Set),D&&aJ(D,0,{},aw)},[aw,D,aJ]),aV=(0,e.useCallback)(a=>{ax(a),ab(0),aj(new Set),D&&aJ(D,0,au,a)},[au,D,aJ]);return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-accent text-foreground
738
- relative transition-colors cursor-pointer
739
- ${h?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
740
- ${h?"":g?"border-brand":"border-brand/30"}`,onClick:h?void 0:k,children:[(0,d.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:p,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${h?"bg-card":"bg-card/50"}`,style:h?{height:41}:void 0,children:[(0,d.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC18"}),(0,d.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===s&&(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===s&&(0,d.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:q("database.connectionFailed")}),"connected"===s&&(0,d.jsx)("span",{className:"text-[10px] text-green-11 flex-shrink-0",children:q("database.connected")}),(0,d.jsx)("span",{className:"flex-1"}),o&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:X(o)}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:h?q("browser.exitMaximize",{modKey:(0,w.Mu)()}):q("browser.maximize",{modKey:(0,w.Mu)()}),children:h?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:q("common.close"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{style:{height:h&&i?i-41:j??360},className:"flex overflow-hidden",children:["connecting"===s&&(0,d.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),q("database.connecting")]}),"error"===s&&(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,d.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:u}),(0,d.jsx)("button",{onClick:aH,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:q("common.retry")})]}),"connected"===s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[x.length>1?(0,d.jsx)("select",{value:z,onChange:a=>{A(a.target.value),E(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:x.map(a=>(0,d.jsx)("option",{value:a,children:a},a))}):(0,d.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:z}),(0,d.jsx)("button",{onClick:aI,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:q("database.refreshTableList"),children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M1 1v5h5"}),(0,d.jsx)("path",{d:"M15 15v-5h-5"}),(0,d.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,d.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,d.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,d.jsx)("button",{onClick:()=>G(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${F===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:q("database.filterTable"),view:q("database.filterView")}[a]},a))}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[B.filter(a=>"table"===F?"view"!==a.type:"view"===a.type).map(a=>(0,d.jsxs)("div",{onClick:()=>aK(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${D===a.name?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,d.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,d.jsx)($,{text:a.name})}),(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===B.length&&(0,d.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:q("database.noTables")})]})]}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,d.jsx)("button",{onClick:()=>I(a),className:`px-3 py-1.5 text-xs transition-colors ${H===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:q("database.tabStructure"),data:q("database.tabData"),sql:"SQL"}[a]},a)),D&&"data"===H&&(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(au).some(a=>a.enabled)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-brand",children:q("database.filterActive",{count:Object.values(au).filter(a=>a.enabled).length})}),(0,d.jsx)("button",{onClick:aU,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:q("database.clearAllFilters"),children:"✕"}),(0,d.jsx)("span",{className:"text-border",children:"|"})]}),ai.size>0&&!ak&&(0,d.jsx)("button",{onClick:()=>al(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:q("database.deleteNRows",{count:ai.size})}),ak&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-destructive",children:q("database.confirmDeleteRows")}),(0,d.jsx)("button",{onClick:aO,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:q("common.confirm")}),(0,d.jsx)("button",{onClick:()=>al(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:q("common.cancel")})]}),(0,d.jsx)("button",{onClick:()=>aP("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ai.size>0?q("database.copyCsvSelected"):q("database.copyCsvAll"),children:ai.size>0?q("database.copyCSV"):q("database.CSV")}),(0,d.jsx)("button",{onClick:()=>aP("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ai.size>0?q("database.copyJsonSelected"):q("database.copyJsonAll"),children:ai.size>0?q("database.copyJSON"):q("database.JSON")})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:D||"sql"===H?"structure"===H?(0,d.jsx)(aa,{columns:J,primaryKeys:L,foreignKeys:N,indexes:S}):"data"===H?(0,d.jsx)(ac,{result:U,loading:ae,columns:J,page:W,totalPages:aR,totalRows:ag,onPageChange:aS,filters:au,sort:aw,onFilterChange:aT,onSortChange:aV,selectedRows:ai,onSelectedRowsChange:a=>{aj(a),al(!1)},editingRowIdx:am,editValues:ao,onStartEdit:a=>{if(!U)return;let b=U.rows[a],c={};for(let a of J)c[a.name]=null==b[a.name]?"":Z(b[a.name]);ap(c),an(a)},onEditChange:(a,b)=>ap(c=>({...c,[a]:b})),onSaveEdit:aM,onCancelEdit:()=>an(null),isAddingRow:aq,newRowValues:as,onStartAdd:()=>{ar(!0),at({})},onNewRowChange:(a,b)=>at(c=>({...c,[a]:b})),onSaveNewRow:aN,onCancelAdd:()=>{ar(!1),at({})},onCellCopy:a=>{navigator.clipboard.writeText(a),r(q("common.copied"))}}):(0,d.jsx)(ad,{sqlInput:ay,onSqlChange:az,onExecute:aL,onKeyDown:aQ,result:aA,error:aC,loading:aE,sqlRef:aG,onCellCopy:a=>{navigator.clipboard.writeText(a),r(q("common.copied"))}}):(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:q("database.selectTable")})})]})]})]}),!h&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===s?"bg-green-500":"error"===s?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,d.jsx)("span",{children:{connecting:q("common.connecting"),connected:q("common.connected"),error:q("common.connectionFailed")}[s]}),"connected"===s&&D&&(0,d.jsx)("span",{className:"text-muted-foreground/70",children:D}),(0,d.jsx)("span",{className:"flex-1"}),o&&(0,d.jsx)("span",{className:"text-[11px] flex-shrink-0",children:X(o)})]})]})})}function aa({columns:a,primaryKeys:b,foreignKeys:c,indexes:e}){let{t:g}=(0,f.Bd)();return 0===a.length?(0,d.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:g("database.selectTableToView")}):(0,d.jsxs)("div",{className:"p-2 space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:g("database.columns")}),(0,d.jsxs)("table",{className:"w-full text-xs",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("database.colName")}),(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("database.colType")}),(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("database.colNullable")}),(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("database.colDefault")})]})}),(0,d.jsx)("tbody",{children:a.map(a=>(0,d.jsxs)("tr",{className:"border-b border-border/50 hover:bg-hover",children:[(0,d.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,d.jsx)("span",{className:"text-amber-11 mr-1",title:g("database.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,d.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,d.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,d.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:g("database.foreignKeys")}),(0,d.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,d.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),e.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:g("database.indexes")}),(0,d.jsx)("div",{className:"space-y-0.5",children:e.map(a=>(0,d.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate","data-tooltip":a.definition,children:a.name},a.name))})]})]})}function ab({filter:a,onApply:b,onClear:c,onToggle:g,onClose:h,colName:i,anchorRect:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(a?.op||"="),[n,o]=(0,e.useState)(a?.value||""),p=(0,e.useRef)(null),q=(0,V.F2)(),r="IS NULL"!==l&&"IS NOT NULL"!==l,s=()=>{(!r||n.trim())&&b({op:l,value:n.trim(),enabled:!0})},t=q?.getBoundingClientRect(),u=t?.left??0,v=t?.top??0,w=t?.width??1e3,x=j.left-u;x+220>w-8&&(x=w-220-8),x<8&&(x=8);let y=j.bottom+2-v;return(0,d.jsx)(V.ZL,{children:(0,d.jsxs)("div",{ref:p,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lv2 p-2 space-y-2",style:{left:x,top:y},onClick:a=>a.stopPropagation(),children:[a&&(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>g(a.target.checked),className:"w-3 h-3 accent-brand"}),k("database.enable")]}),(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,d.jsx)("select",{value:l,onChange:a=>m(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:W.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))}),r&&(0,d.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),s())},placeholder:k("IN"===l?"database.commaValues":"LIKE"===l?"database.likePattern":"database.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:s,disabled:r&&!n.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:k("database.apply")}),a&&(0,d.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:k("database.clearFilter")})]})]})})}function ac({result:a,loading:b,columns:c,page:g,totalPages:h,totalRows:i,onPageChange:j,filters:k,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:p,editingRowIdx:q,editValues:r,onStartEdit:s,onEditChange:t,onSaveEdit:u,onCancelEdit:v,isAddingRow:w,newRowValues:x,onStartAdd:y,onNewRowChange:z,onSaveNewRow:A,onCancelAdd:B,onCellCopy:C}){let{t:D}=(0,f.Bd)(),[E,F]=(0,e.useState)(null),[G,H]=(0,e.useState)({left:0,bottom:0});if(!a&&!b)return(0,d.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:D("database.selectTableForData")});let I=a?.fields||[],J=a?.rows||[],K={};for(let a of c)K[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let L=J.length>0&&o.size===J.length,M=o.size>0&&!L;return(0,d.jsxs)("div",{className:"flex flex-col h-full",children:[(0,d.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,d.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,d.jsx)("input",{type:"checkbox",checked:L,ref:a=>{a&&(a.indeterminate=M)},onChange:()=>{L?p(new Set):p(new Set(J.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(a=>{let b=l?.column===a.name?l.dir:null,c=k[a.name],e=c?.enabled;return(0,d.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,d.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,K[a.name]&&(0,d.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:K[a.name]}),"ASC"===b&&(0,d.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,d.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,d.jsx)("button",{onClick:b=>{if(b.stopPropagation(),E===a.name)return void F(null);let c=b.currentTarget.closest("th").getBoundingClientRect();H({left:c.left,bottom:c.bottom}),F(a.name)},className:`ml-1 inline-flex items-center transition-colors ${e?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,d.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),E===a.name&&(0,d.jsx)(ab,{filter:c||null,onApply:b=>{m(a.name,b),F(null)},onClear:()=>{m(a.name,null),F(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>F(null),colName:a.name,anchorRect:G})]},a.name)})]})}),(0,d.jsxs)("tbody",{children:[w&&(0,d.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,d.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,d.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,d.jsx)("button",{onClick:A,className:"text-[10px] text-green-11 hover:text-green-9",title:D("common.save"),children:"✓"}),(0,d.jsx)("button",{onClick:B,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]})}),I.map(a=>(0,d.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,d.jsx)("input",{type:"text",value:x[a.name]??"",onChange:b=>z(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),J.map((a,b)=>(0,d.jsxs)("tr",{className:`hover:bg-hover ${o.has(b)?"bg-brand/5":""} ${q===b?"bg-blue-500/5":""}`,children:[(0,d.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:q===b?(0,d.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,d.jsx)("button",{onClick:u,className:"text-[10px] text-green-11 hover:text-green-9",title:D("common.save"),children:"✓"}),(0,d.jsx)("button",{onClick:v,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]}):(0,d.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),p(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(c=>(0,d.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===q&&s(b)},onContextMenu:b=>{b.preventDefault(),C(Z(a[c.name]))},children:q===b?(0,d.jsx)("input",{type:"text",value:r[c.name]??"",onChange:a=>t(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,d.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,d.jsx)($,{text:Z(a[c.name])})},c.name))]},b))]})]}),0===J.length&&!b&&(0,d.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:D("common.noData")})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:y,disabled:w,className:"px-1.5 py-0.5 text-[10px] text-green-11 hover:text-green-9 disabled:opacity-30",children:D("database.addRow")}),(0,d.jsx)("span",{children:D("database.totalRows",{count:i})}),a?.duration!==void 0&&(0,d.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:()=>j(g-1),disabled:0===g,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,d.jsxs)("span",{children:[g+1," / ",h]}),(0,d.jsx)("button",{onClick:()=>j(g+1),disabled:g>=h-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function ad({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:e,result:g,error:h,loading:i,sqlRef:j,onCellCopy:k}){let{t:l}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex flex-col h-full",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,d.jsx)("textarea",{ref:j,value:a,onChange:a=>b(a.target.value),onKeyDown:e,placeholder:l("database.sqlPlaceholder",{modKey:(0,w.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("button",{onClick:c,disabled:i||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:l(i?"database.executing":"database.execute")}),g?.duration!==void 0&&(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[g.command&&!g.fields?l("database.rowsAffected",{command:g.command,count:g.rowCount,duration:g.duration}):l("database.queryRows",{count:g.rows?.length??0,duration:g.duration}),g.truncated&&` ${l("database.resultTruncated")}`]})]})]}),h&&(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:h}),g?.fields&&g.rows&&(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsx)("tr",{children:g.fields.map(a=>(0,d.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,d.jsx)("tbody",{children:g.rows.map((a,b)=>(0,d.jsx)("tr",{className:"hover:bg-hover",children:g.fields.map(b=>(0,d.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),k(Z(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,d.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,d.jsx)($,{text:Z(a[b.name])})},b.name))},b))})]})})]})}F({type:"database",idPrefix:"db",match(a){let b=a.trim().toLowerCase();return b.startsWith("postgresql://")||b.startsWith("postgres://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"postgres";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k}){return(0,d.jsx)(_,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){await K("db",a.id)}});let ae=[{value:"=",label:"="},{value:"!=",label:"!="},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:">="},{value:"<=",label:"<="},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function af(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function ag(a){return`\`${a.replace(/`/g,"``")}\``}function ah(a){try{let b=a.match(/\/\/[^/]+\/([^?]+)/);if(b)return b[1]}catch{}return""}function ai(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function aj({text:a}){let[b,c]=(0,e.useState)(!1),[f,g]=(0,e.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),h=(0,e.useRef)(null),i=(0,e.useRef)(null),j=(0,e.useRef)(!1),k=(0,V.F2)(),l=(0,e.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{j.current||c(!1)},80)},[]),m=(0,e.useCallback)(()=>{i.current&&clearTimeout(i.current),j.current=!1,i.current=setTimeout(()=>{let a=h.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=k?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,i=d?.width??window.innerWidth,j=d?.height??window.innerHeight,l=b.left-e,m=b.top-f,n=b.bottom-f,o=Math.min(600,i-l-8),p=m-8,q=j-n-8,r=p>q&&p>80,s=r?p-4:q-4;g({x:o<200?Math.max(8,i-600-8):l,y:r?m-4:n+4,maxW:o<200?Math.min(600,i-16):o,maxH:Math.max(60,s),above:r}),c(!0)},350)},[k]),n=(0,e.useCallback)(()=>{l()},[l]),o=(0,e.useCallback)(()=>{j.current=!0,i.current&&clearTimeout(i.current)},[]),p=(0,e.useCallback)(()=>{j.current=!1,l()},[l]);return(0,d.jsxs)("span",{ref:h,className:"block truncate",onMouseEnter:m,onMouseLeave:n,children:[a,b&&(0,d.jsx)(V.ZL,{children:(0,d.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-pre-wrap break-all select-text cursor-text",style:{left:f.x,top:f.y,maxWidth:f.maxW,maxHeight:f.maxH,transform:f.above?"translateY(-100%)":void 0},onMouseEnter:o,onMouseLeave:p,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}function ak({id:a,connectionString:b,displayName:c,selected:g,maximized:h,expandedHeight:i,bubbleContentHeight:j,onSelect:k,onClose:l,onToggleMaximize:m,timestamp:o,onTitleMouseDown:p}){let{t:q}=(0,f.Bd)(),{showToast:r}=(0,n.dj)(),[s,t]=(0,e.useState)("connecting"),[u,v]=(0,e.useState)(""),[x,y]=(0,e.useState)([]),[z,A]=(0,e.useState)(()=>ah(b)),[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)("table"),[H,I]=(0,e.useState)("data"),[J,K]=(0,e.useState)([]),[L,M]=(0,e.useState)([]),[N,R]=(0,e.useState)([]),[S,T]=(0,e.useState)([]),[U,V]=(0,e.useState)(null),[W,X]=(0,e.useState)(0),[Y,Z]=(0,e.useState)(!1),[$,_]=(0,e.useState)(0),[aa,ab]=(0,e.useState)(new Set),[ac,ad]=(0,e.useState)(!1),[ae,am]=(0,e.useState)(null),[ap,aq]=(0,e.useState)({}),[ar,as]=(0,e.useState)(!1),[at,au]=(0,e.useState)({}),[av,aw]=(0,e.useState)({}),[ax,ay]=(0,e.useState)(null),[az,aA]=(0,e.useState)(""),[aB,aC]=(0,e.useState)(null),[aD,aE]=(0,e.useState)(""),[aF,aG]=(0,e.useState)(!1),aH=(0,e.useRef)(null),aI=(0,e.useCallback)(async()=>{t("connecting"),v("");try{let c=await O("/api/mysql/connect",{id:a,connectionString:b});y(c.schemas||[]);let d=ah(b);c.schemas?.length>0&&d&&c.schemas.includes(d)?A(d):c.schemas?.length>0&&A(c.schemas[0]),t("connected")}catch(a){v(a instanceof Error?a.message:String(a)),t("error")}},[a,b]),aJ=(0,e.useCallback)(async()=>{if("connected"===s)try{let c=await P("/api/mysql/schemas",{id:a,connectionString:b,schema:z});C(c.tables||[])}catch{}},[a,b,z,s]),aK=(0,e.useCallback)(async(c,d,e,f)=>{Z(!0);let g=e??av,h=void 0!==f?f:ax;try{let e=`${ag(z)}.${ag(c)}`,{where:f,params:i}=function(a){let b=[],c=[];for(let[d,e]of Object.entries(a)){if(!e.enabled)continue;let a=ag(d);if("IS NULL"===e.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===e.op)b.push(`${a} IS NOT NULL`);else if("IN"===e.op){let d=e.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===d.length)continue;let f=d.map(a=>(c.push(a),"?"));b.push(`${a} IN (${f.join(", ")})`)}else"LIKE"===e.op||e.op,b.push(`${a} ${e.op} ?`),c.push(e.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${ag(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,l=await O("/api/mysql/query",{id:a,connectionString:b,sql:k,params:i});V(l);let m=`SELECT count(*) AS cnt FROM ${e}${f}`,n=await O("/api/mysql/query",{id:a,connectionString:b,sql:m,params:i});_(n.rows?.[0]?.cnt??0)}catch{}Z(!1)},[a,b,z,av,ax]),aL=(0,e.useCallback)(async c=>{E(c),X(0),am(null),as(!1),ab(new Set),ad(!1),aw({}),ay(null);try{let d=await P("/api/mysql/columns",{id:a,connectionString:b,schema:z,table:c});K(d.columns||[]),M(d.primaryKeys||[]),R(d.foreignKeys||[]),T(d.indexes||[])}catch{}aK(c,0,{},null)},[a,b,z,aK]),aM=(0,e.useCallback)(async()=>{if(az.trim()){aG(!0),aE(""),aC(null);try{let c=await O("/api/mysql/query",{id:a,connectionString:b,sql:az});aC(c)}catch(a){aE(a instanceof Error?a.message:String(a))}aG(!1)}},[a,b,az]),aN=(0,e.useCallback)(async()=>{if(null===ae||!U||!D)return;let c=U.rows[ae],d=[],e=[];for(let a of J)void 0!==ap[a.name]&&ap[a.name]!==ai(c[a.name]??"")&&(d.push(`${ag(a.name)} = ?`),e.push(""===ap[a.name]&&a.nullable?null:ap[a.name]));if(0===d.length)return void am(null);let f=L.length>0?L:J.map(a=>a.name),g=[];for(let a of f)null===c[a]||void 0===c[a]?g.push(`${ag(a)} IS NULL`):(g.push(`${ag(a)} = ?`),e.push(c[a]));let h=`UPDATE ${ag(z)}.${ag(D)} SET ${d.join(", ")} WHERE ${g.join(" AND ")}`;try{await O("/api/mysql/query",{id:a,connectionString:b,sql:h,params:e}),am(null),aK(D,W,av,ax)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[ae,U,D,J,L,ap,a,b,z,aK,W,av,ax]),aO=(0,e.useCallback)(async()=>{if(!D)return;let c=[],d=[],e=[];for(let a of J)void 0!==at[a.name]&&""!==at[a.name]&&(c.push(ag(a.name)),d.push(at[a.name]),e.push("?"));if(0===c.length)return;let f=`INSERT INTO ${ag(z)}.${ag(D)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await O("/api/mysql/query",{id:a,connectionString:b,sql:f,params:d}),as(!1),au({}),aK(D,W,av,ax)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[D,J,at,a,b,z,aK,W,av,ax]),aP=(0,e.useCallback)(async()=>{if(0===aa.size||!U||!D)return;let c=L.length>0?L:J.map(a=>a.name),d=0;for(let e of Array.from(aa).sort((a,b)=>b-a)){let f=U.rows[e];if(!f)continue;let g=[],h=[];for(let a of c)null===f[a]||void 0===f[a]?g.push(`${ag(a)} IS NULL`):(g.push(`${ag(a)} = ?`),h.push(f[a]));let i=`DELETE FROM ${ag(z)}.${ag(D)} WHERE ${g.join(" AND ")} LIMIT 1`;try{await O("/api/mysql/query",{id:a,connectionString:b,sql:i,params:h})}catch{d++}}ab(new Set),ad(!1),aK(D,W,av,ax),d>0&&alert(q("mysql.deleteRowsFailed",{count:d}))},[aa,U,D,L,J,a,b,z,aK,W,av,ax]),aQ=(0,e.useCallback)(async c=>{if(!D)return;if(aa.size>0&&U){let a,b=U.fields.map(a=>a.name),d=Array.from(aa).sort((a,b)=>a-b).map(a=>U.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${ag(z)}.${ag(D)}`;try{let e=await Q("/api/mysql/export",{id:a,connectionString:b,sql:d,format:c}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=`${D}.${c}`,g.click(),URL.revokeObjectURL(f)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[D,a,b,z,aa,U]),aR=(0,e.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aM())},[aM]),aS=Math.max(1,Math.ceil($/50)),aT=(0,e.useCallback)(a=>{D&&(X(a),aK(D,a,av,ax))},[D,aK,av,ax]),aU=(0,e.useCallback)((a,b)=>{let c={...av};b?c[a]=b:delete c[a],aw(c),X(0),ab(new Set),D&&aK(D,0,c,ax)},[av,ax,D,aK]),aV=(0,e.useCallback)(()=>{aw({}),X(0),ab(new Set),D&&aK(D,0,{},ax)},[ax,D,aK]),aW=(0,e.useCallback)(a=>{ay(a),X(0),ab(new Set),D&&aK(D,0,av,a)},[av,D,aK]);return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-accent text-foreground
741
- relative transition-colors cursor-pointer
742
- ${h?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
743
- ${h?"":g?"border-brand":"border-brand/30"}`,onClick:h?void 0:k,children:[(0,d.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:p,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${h?"bg-card":"bg-card/50"}`,style:h?{height:41}:void 0,children:[(0,d.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC2C"}),(0,d.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===s&&(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===s&&(0,d.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:q("mysql.connectionFailed")}),"connected"===s&&(0,d.jsx)("span",{className:"text-[10px] text-green-11 flex-shrink-0",children:q("mysql.connected")}),(0,d.jsx)("span",{className:"flex-1"}),o&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:af(o)}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:h?q("browser.exitMaximize",{modKey:(0,w.Mu)()}):q("browser.maximize",{modKey:(0,w.Mu)()}),children:h?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:q("common.close"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{style:{height:h&&i?i-41:j??360},className:"flex overflow-hidden",children:["connecting"===s&&(0,d.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),q("mysql.connecting")]}),"error"===s&&(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,d.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:u}),(0,d.jsx)("button",{onClick:aI,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:q("common.retry")})]}),"connected"===s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[x.length>1?(0,d.jsx)("select",{value:z,onChange:a=>{A(a.target.value),E(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:x.map(a=>(0,d.jsx)("option",{value:a,children:a},a))}):(0,d.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:z}),(0,d.jsx)("button",{onClick:aJ,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:q("mysql.refreshTableList"),children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M1 1v5h5"}),(0,d.jsx)("path",{d:"M15 15v-5h-5"}),(0,d.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,d.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,d.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,d.jsx)("button",{onClick:()=>G(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${F===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:q("mysql.filterTable"),view:q("mysql.filterView")}[a]},a))}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[B.filter(a=>"table"===F?"view"!==a.type:"view"===a.type).map(a=>(0,d.jsxs)("div",{onClick:()=>aL(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${D===a.name?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,d.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,d.jsx)(aj,{text:a.name})}),(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===B.length&&(0,d.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:q("mysql.noTables")})]})]}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,d.jsx)("button",{onClick:()=>I(a),className:`px-3 py-1.5 text-xs transition-colors ${H===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:q("mysql.tabStructure"),data:q("mysql.tabData"),sql:"SQL"}[a]},a)),D&&"data"===H&&(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(av).some(a=>a.enabled)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-brand",children:q("mysql.filterActive",{count:Object.values(av).filter(a=>a.enabled).length})}),(0,d.jsx)("button",{onClick:aV,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:q("mysql.clearAllFilters"),children:"✕"}),(0,d.jsx)("span",{className:"text-border",children:"|"})]}),aa.size>0&&!ac&&(0,d.jsx)("button",{onClick:()=>ad(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:q("mysql.deleteNRows",{count:aa.size})}),ac&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-destructive",children:q("mysql.confirmDeleteRows")}),(0,d.jsx)("button",{onClick:aP,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:q("common.confirm")}),(0,d.jsx)("button",{onClick:()=>ad(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:q("common.cancel")})]}),(0,d.jsx)("button",{onClick:()=>aQ("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:aa.size>0?q("mysql.copyCsvSelected"):q("mysql.copyCsvAll"),children:aa.size>0?q("mysql.copyCSV"):q("mysql.CSV")}),(0,d.jsx)("button",{onClick:()=>aQ("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:aa.size>0?q("mysql.copyJsonSelected"):q("mysql.copyJsonAll"),children:aa.size>0?q("mysql.copyJSON"):q("mysql.JSON")})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:D||"sql"===H?"structure"===H?(0,d.jsx)(al,{columns:J,primaryKeys:L,foreignKeys:N,indexes:S}):"data"===H?(0,d.jsx)(an,{result:U,loading:Y,columns:J,page:W,totalPages:aS,totalRows:$,onPageChange:aT,filters:av,sort:ax,onFilterChange:aU,onSortChange:aW,selectedRows:aa,onSelectedRowsChange:a=>{ab(a),ad(!1)},editingRowIdx:ae,editValues:ap,onStartEdit:a=>{if(!U)return;let b=U.rows[a],c={};for(let a of J)c[a.name]=null==b[a.name]?"":ai(b[a.name]);aq(c),am(a)},onEditChange:(a,b)=>aq(c=>({...c,[a]:b})),onSaveEdit:aN,onCancelEdit:()=>am(null),isAddingRow:ar,newRowValues:at,onStartAdd:()=>{as(!0),au({})},onNewRowChange:(a,b)=>au(c=>({...c,[a]:b})),onSaveNewRow:aO,onCancelAdd:()=>{as(!1),au({})},onCellCopy:a=>{navigator.clipboard.writeText(a),r(q("common.copied"))}}):(0,d.jsx)(ao,{sqlInput:az,onSqlChange:aA,onExecute:aM,onKeyDown:aR,result:aB,error:aD,loading:aF,sqlRef:aH,onCellCopy:a=>{navigator.clipboard.writeText(a),r(q("common.copied"))}}):(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:q("mysql.selectTable")})})]})]})]}),!h&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===s?"bg-green-500":"error"===s?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,d.jsx)("span",{children:{connecting:q("common.connecting"),connected:q("common.connected"),error:q("common.connectionFailed")}[s]}),"connected"===s&&D&&(0,d.jsx)("span",{className:"text-muted-foreground/70",children:D}),(0,d.jsx)("span",{className:"flex-1"}),o&&(0,d.jsx)("span",{className:"text-[11px] flex-shrink-0",children:af(o)})]})]})})}function al({columns:a,primaryKeys:b,foreignKeys:c,indexes:e}){let{t:g}=(0,f.Bd)();return 0===a.length?(0,d.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:g("mysql.selectTableToView")}):(0,d.jsxs)("div",{className:"p-2 space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:g("mysql.columns")}),(0,d.jsxs)("table",{className:"w-full text-xs",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("mysql.colName")}),(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("mysql.colType")}),(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("mysql.colNullable")}),(0,d.jsx)("th",{className:"px-1.5 py-1 font-medium",children:g("mysql.colDefault")})]})}),(0,d.jsx)("tbody",{children:a.map(a=>(0,d.jsxs)("tr",{className:"border-b border-border/50 hover:bg-hover",children:[(0,d.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,d.jsx)("span",{className:"text-amber-11 mr-1",title:g("mysql.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,d.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,d.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,d.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:g("mysql.foreignKeys")}),(0,d.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,d.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),e.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:g("mysql.indexes")}),(0,d.jsx)("div",{className:"space-y-0.5",children:e.map(a=>(0,d.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate","data-tooltip":a.definition,children:a.name},a.name))})]})]})}function am({filter:a,onApply:b,onClear:c,onToggle:g,onClose:h,colName:i,anchorRect:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(a?.op||"="),[n,o]=(0,e.useState)(a?.value||""),p=(0,e.useRef)(null),q=(0,V.F2)(),r="IS NULL"!==l&&"IS NOT NULL"!==l,s=()=>{(!r||n.trim())&&b({op:l,value:n.trim(),enabled:!0})},t=q?.getBoundingClientRect(),u=t?.left??0,v=t?.top??0,w=t?.width??1e3,x=j.left-u;x+220>w-8&&(x=w-220-8),x<8&&(x=8);let y=j.bottom+2-v;return(0,d.jsx)(V.ZL,{children:(0,d.jsxs)("div",{ref:p,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lv2 p-2 space-y-2",style:{left:x,top:y},onClick:a=>a.stopPropagation(),children:[a&&(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>g(a.target.checked),className:"w-3 h-3 accent-brand"}),k("mysql.enable")]}),(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,d.jsx)("select",{value:l,onChange:a=>m(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:ae.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))}),r&&(0,d.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),s())},placeholder:k("IN"===l?"mysql.commaValues":"LIKE"===l?"mysql.likePattern":"mysql.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:s,disabled:r&&!n.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:k("mysql.apply")}),a&&(0,d.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:k("mysql.clearFilter")})]})]})})}function an({result:a,loading:b,columns:c,page:g,totalPages:h,totalRows:i,onPageChange:j,filters:k,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:p,editingRowIdx:q,editValues:r,onStartEdit:s,onEditChange:t,onSaveEdit:u,onCancelEdit:v,isAddingRow:w,newRowValues:x,onStartAdd:y,onNewRowChange:z,onSaveNewRow:A,onCancelAdd:B,onCellCopy:C}){let{t:D}=(0,f.Bd)(),[E,F]=(0,e.useState)(null),[G,H]=(0,e.useState)({left:0,bottom:0});if(!a&&!b)return(0,d.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:D("mysql.selectTableForData")});let I=a?.fields||[],J=a?.rows||[],K={};for(let a of c)K[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let L=J.length>0&&o.size===J.length,M=o.size>0&&!L;return(0,d.jsxs)("div",{className:"flex flex-col h-full",children:[(0,d.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,d.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,d.jsx)("input",{type:"checkbox",checked:L,ref:a=>{a&&(a.indeterminate=M)},onChange:()=>{L?p(new Set):p(new Set(J.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(a=>{let b=l?.column===a.name?l.dir:null,c=k[a.name],e=c?.enabled;return(0,d.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,d.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,K[a.name]&&(0,d.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:K[a.name]}),"ASC"===b&&(0,d.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,d.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,d.jsx)("button",{onClick:b=>{if(b.stopPropagation(),E===a.name)return void F(null);let c=b.currentTarget.closest("th").getBoundingClientRect();H({left:c.left,bottom:c.bottom}),F(a.name)},className:`ml-1 inline-flex items-center transition-colors ${e?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,d.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),E===a.name&&(0,d.jsx)(am,{filter:c||null,onApply:b=>{m(a.name,b),F(null)},onClear:()=>{m(a.name,null),F(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>F(null),colName:a.name,anchorRect:G})]},a.name)})]})}),(0,d.jsxs)("tbody",{children:[w&&(0,d.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,d.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,d.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,d.jsx)("button",{onClick:A,className:"text-[10px] text-green-11 hover:text-green-9",title:D("common.save"),children:"✓"}),(0,d.jsx)("button",{onClick:B,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]})}),I.map(a=>(0,d.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,d.jsx)("input",{type:"text",value:x[a.name]??"",onChange:b=>z(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),J.map((a,b)=>(0,d.jsxs)("tr",{className:`hover:bg-hover ${o.has(b)?"bg-brand/5":""} ${q===b?"bg-blue-500/5":""}`,children:[(0,d.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:q===b?(0,d.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,d.jsx)("button",{onClick:u,className:"text-[10px] text-green-11 hover:text-green-9",title:D("common.save"),children:"✓"}),(0,d.jsx)("button",{onClick:v,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]}):(0,d.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),p(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(c=>(0,d.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===q&&s(b)},onContextMenu:b=>{b.preventDefault(),C(ai(a[c.name]))},children:q===b?(0,d.jsx)("input",{type:"text",value:r[c.name]??"",onChange:a=>t(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,d.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,d.jsx)(aj,{text:ai(a[c.name])})},c.name))]},b))]})]}),0===J.length&&!b&&(0,d.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:D("common.noData")})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:y,disabled:w,className:"px-1.5 py-0.5 text-[10px] text-green-11 hover:text-green-9 disabled:opacity-30",children:D("mysql.addRow")}),(0,d.jsx)("span",{children:D("mysql.totalRows",{count:i})}),a?.duration!==void 0&&(0,d.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:()=>j(g-1),disabled:0===g,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,d.jsxs)("span",{children:[g+1," / ",h]}),(0,d.jsx)("button",{onClick:()=>j(g+1),disabled:g>=h-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function ao({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:e,result:g,error:h,loading:i,sqlRef:j,onCellCopy:k}){let{t:l}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex flex-col h-full",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,d.jsx)("textarea",{ref:j,value:a,onChange:a=>b(a.target.value),onKeyDown:e,placeholder:l("mysql.sqlPlaceholder",{modKey:(0,w.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("button",{onClick:c,disabled:i||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:l(i?"mysql.executing":"mysql.execute")}),g?.duration!==void 0&&(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[g.command&&!g.fields?l("mysql.rowsAffected",{command:g.command,count:g.rowCount,duration:g.duration}):l("mysql.queryRows",{count:g.rows?.length??0,duration:g.duration}),g.truncated&&` ${l("mysql.resultTruncated")}`]})]})]}),h&&(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:h}),g?.fields&&g.rows&&(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsx)("tr",{children:g.fields.map(a=>(0,d.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,d.jsx)("tbody",{children:g.rows.map((a,b)=>(0,d.jsx)("tr",{className:"hover:bg-hover",children:g.fields.map(b=>(0,d.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),k(ai(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,d.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,d.jsx)(aj,{text:ai(a[b.name])})},b.name))},b))})]})})]})}F({type:"mysql",idPrefix:"mysql",match:a=>a.trim().toLowerCase().startsWith("mysql://"),parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"mysql";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k}){return(0,d.jsx)(ak,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){await K("mysql",a.id)}});let ap={string:{label:"S",color:"text-emerald-600 dark:text-emerald-400 bg-emerald-500/15"},hash:{label:"H",color:"text-blue-600 dark:text-blue-400 bg-blue-500/15"},list:{label:"L",color:"text-orange-600 dark:text-orange-400 bg-orange-500/15"},set:{label:"SET",color:"text-teal-600 dark:text-teal-400 bg-teal-500/15"},zset:{label:"Z",color:"text-purple-600 dark:text-purple-400 bg-purple-500/15"},stream:{label:"STR",color:"text-pink-600 dark:text-pink-400 bg-pink-500/15"}};function aq({type:a}){let b=ap[a]||{label:"?",color:"text-muted-foreground bg-muted"};return(0,d.jsx)("span",{className:`inline-block text-[9px] font-mono font-bold leading-none px-1 py-0.5 rounded flex-shrink-0 ${b.color}`,children:b.label})}function ar({text:a}){let[b,c]=(0,e.useState)(!1),[f,g]=(0,e.useState)({x:0,y:0,above:!0}),h=(0,e.useRef)(null),i=(0,e.useRef)(null),j=(0,V.F2)(),k=(0,e.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{let a=h.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=j?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,i=d?.height??window.innerHeight,k=b.top-f,l=b.bottom-f,m=k>i/2;g({x:b.left-e,y:m?k-4:l+4,above:m}),c(!0)},350)},[j]),l=(0,e.useCallback)(()=>{i.current&&clearTimeout(i.current),c(!1)},[]);return(0,d.jsxs)("span",{ref:h,className:"block truncate",onMouseEnter:k,onMouseLeave:l,children:[a,b&&(0,d.jsx)(V.ZL,{children:(0,d.jsx)("div",{className:"fixed z-[9999] max-w-[500px] max-h-[200px] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-pre-wrap break-all select-text",style:{left:f.x,top:f.y,transform:f.above?"translateY(-100%)":void 0},children:a})})]})}function as({id:a,connectionString:b,displayName:c,selected:g,maximized:h,expandedHeight:i,bubbleContentHeight:j,onSelect:k,onClose:l,onToggleMaximize:m,timestamp:o,onTitleMouseDown:p}){var q;let{t:r}=(0,f.Bd)(),{showToast:s}=(0,n.dj)(),[t,u]=(0,e.useState)("connecting"),[v,x]=(0,e.useState)(""),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)([]),[C,D]=(0,e.useState)("0"),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)("*"),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(null),[M,N]=(0,e.useState)(null),[P,Q]=(0,e.useState)(!1),[R,S]=(0,e.useState)(null),[T,U]=(0,e.useState)(!1),[V,W]=(0,e.useState)("data"),[X,Y]=(0,e.useState)(""),[Z,$]=(0,e.useState)(""),[_,aa]=(0,e.useState)([]),[ab,ac]=(0,e.useState)(!1),ad=(0,e.useRef)(null),ae=(0,e.useRef)(null),af=(0,e.useCallback)(async()=>{u("connecting"),x("");try{let c=await O("/api/redis/connect",{id:a,connectionString:b});z(c),u("connected")}catch(a){x(a instanceof Error?a.message:String(a)),u("error")}},[a,b]),ag=(0,e.useCallback)(async(c,d,e)=>{J(!0);try{let f=await O("/api/redis/keys",{id:a,connectionString:b,pattern:c,cursor:d,count:200});B(a=>e?[...a,...f.keys]:f.keys),D(f.cursor),F(f.hasMore)}catch{}J(!1)},[a,b]),ah=(0,e.useCallback)(()=>{L(null),N(null),ag(G,"0",!1)},[G,ag]),ai=(0,e.useCallback)(async c=>{L(c),Q(!0),S(null),U(!1);try{let d=await O("/api/redis/get",{id:a,connectionString:b,key:c});N(d)}catch(a){N(null),s(a instanceof Error?a.message:r("redis.loadFailed"))}Q(!1)},[a,b,s]),aj=(0,e.useCallback)(async()=>{if(K)try{await O("/api/redis/delete",{id:a,connectionString:b,keys:[K]}),L(null),N(null),U(!1),ag(G,"0",!1)}catch(a){s(a instanceof Error?a.message:r("redis.deleteFailed"))}},[K,a,b,G,ag,s]),ak=(0,e.useCallback)(async()=>{if(K&&null!==R)try{await O("/api/redis/set",{id:a,connectionString:b,key:K,value:R,type:"string"}),S(null),ai(K),s(r("common.saved"))}catch(a){s(a instanceof Error?a.message:r("redis.saveFailed"))}},[K,R,a,b,ai,s]),al=(0,e.useCallback)(async()=>{try{let c=await O("/api/redis/command",{id:a,connectionString:b,command:"INFO"});Y("string"==typeof c.result?c.result:String(c.result))}catch{}},[a,b]),am=(0,e.useCallback)(async()=>{let c,d=Z.trim();if(!d)return;ac(!0),$("");let e=[],f=/(?:"([^"]*)")|(?:'([^']*)')|(\S+)/g;for(;null!==(c=f.exec(d));)e.push(c[1]??c[2]??c[3]);let g=e[0]||"",h=e.slice(1);try{let c=await O("/api/redis/command",{id:a,connectionString:b,command:g,args:h});aa(a=>[...a,{command:d,result:c.result,duration:c.duration,isError:!1}])}catch(a){aa(b=>[...b,{command:d,result:a instanceof Error?a.message:String(a),duration:0,isError:!0}])}ac(!1)},[Z,a,b]);return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-accent text-foreground
744
- relative transition-colors cursor-pointer
745
- ${h?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
746
- ${h?"":g?"border-brand":"border-brand/30"}`,onClick:h?void 0:k,children:[(0,d.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:p,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${h?"bg-card":"bg-card/50"}`,style:h?{height:41}:void 0,children:[(0,d.jsx)("span",{className:"text-sm flex-shrink-0",children:"♦"}),(0,d.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===t&&(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===t&&(0,d.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:r("common.connectionFailed")}),"connected"===t&&y&&(0,d.jsxs)("span",{className:"text-[10px] text-red-11 flex-shrink-0",children:["v",y.version," \xb7 ",y.dbSize," keys \xb7 ",y.memory]}),(0,d.jsx)("span",{className:"flex-1"}),o&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:function(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}(o)}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:h?r("browser.exitMaximize",{modKey:(0,w.Mu)()}):r("browser.maximize",{modKey:(0,w.Mu)()}),children:h?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:r("common.close"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{style:{height:h&&i?i-41:j??360},className:"flex overflow-hidden",children:["connecting"===t&&(0,d.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),r("common.connecting"),"..."]}),"error"===t&&(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,d.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:v}),(0,d.jsx)("button",{onClick:af,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:r("common.retry")})]}),"connected"===t&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[(0,d.jsx)("input",{type:"text",value:G,onChange:a=>H(a.target.value),onKeyDown:a=>{"Enter"===a.key&&ah()},placeholder:r("redis.scanPlaceholder"),className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring"}),(0,d.jsx)("button",{onClick:ah,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:r("redis.scanSearch"),children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"6.5",cy:"6.5",r:"4.5"}),(0,d.jsx)("path",{d:"M10 10l4 4"})]})}),(0,d.jsx)("button",{onClick:()=>ag(G,"0",!1),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:r("common.refresh"),children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M1 1v5h5"}),(0,d.jsx)("path",{d:"M15 15v-5h-5"}),(0,d.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,d.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[A.map(a=>(0,d.jsxs)("div",{onClick:()=>ai(a.key),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer transition-colors ${K===a.key?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)(aq,{type:a.type}),(0,d.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:(0,d.jsx)(ar,{text:a.key})})]},a.key)),0===A.length&&!I&&(0,d.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:r("redis.noKeys")}),I&&(0,d.jsx)("div",{className:"p-2 flex items-center justify-center",children:(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"})}),E&&!I&&(0,d.jsx)("button",{onClick:()=>ag(G,C,!0),className:"w-full py-1.5 text-[10px] text-brand hover:text-brand/80 transition-colors",children:r("redis.loadMore")})]}),(0,d.jsxs)("div",{className:"px-2 py-1 border-t border-border text-[10px] text-muted-foreground",children:[A.length," keys",E?"+":"",y?` / ${y.dbSize} total`:""]})]}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["data","info","cli"].map(a=>(0,d.jsx)("button",{onClick:()=>W(a),className:`px-3 py-1.5 text-xs transition-colors ${V===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{data:r("redis.tabData"),info:r("redis.tabInfo"),cli:"CLI"}[a]},a)),K&&"data"===V&&(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[M&&(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["TTL: ",function(a,b){if(-1===a)return b("redis.neverExpires");if(-2===a)return b("redis.expired");if(a<60)return`${a}s`;if(a<3600)return`${Math.floor(a/60)}m${a%60>0?` ${a%60}s`:""}`;let c=Math.floor(a/3600),d=Math.floor(a%3600/60);return`${c}h${d>0?` ${d}m`:""}`}(M.ttl,r),null!==M.size?` \xb7 ${null==(q=M.size)?"":q<1024?`${q} B`:q<1048576?`${(q/1024).toFixed(1)} KB`:`${(q/1048576).toFixed(1)} MB`}`:""]}),T?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-[10px] text-destructive",children:[r("common.confirm"),"?"]}),(0,d.jsx)("button",{onClick:aj,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:r("common.confirm")}),(0,d.jsx)("button",{onClick:()=>U(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:r("common.cancel")})]}):(0,d.jsx)("button",{onClick:()=>U(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:r("common.delete")})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:"data"===V?(0,d.jsx)(at,{selectedKey:K,keyValue:M,keyLoading:P,editingValue:R,onStartEdit:a=>S(a),onEditChange:S,onSaveEdit:ak,onCancelEdit:()=>S(null),onCellCopy:a=>{navigator.clipboard.writeText(a),s(r("common.copied"))}}):"info"===V?(0,d.jsx)(au,{infoText:X,onRefresh:al}):(0,d.jsx)(av,{cliInput:Z,onInputChange:$,onExecute:am,history:_,loading:ab,endRef:ad,inputRef:ae})})]})]})]})]})})}function at({selectedKey:a,keyValue:b,keyLoading:c,editingValue:e,onStartEdit:g,onEditChange:h,onSaveEdit:i,onCancelEdit:j,onCellCopy:k}){let{t:l}=(0,f.Bd)();if(!a)return(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:l("redis.selectKey")});if(c)return(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if(!b)return(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:l("redis.keyNotExist")});let{type:m,value:n}=b;if("string"===m){let b=String(n??""),c=null!==e;return(0,d.jsxs)("div",{className:"p-3 h-full flex flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,d.jsx)(aq,{type:"string"}),(0,d.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,d.jsx)("span",{className:"flex-1"}),c?(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:i,className:"px-2 py-0.5 text-[10px] text-white bg-brand rounded hover:bg-brand/90",children:l("common.save")}),(0,d.jsx)("button",{onClick:j,className:"px-2 py-0.5 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground",children:l("common.cancel")})]}):(0,d.jsx)("button",{onClick:()=>g(b),className:"px-2 py-0.5 text-[10px] text-brand hover:text-brand/80 bg-brand/10 rounded transition-colors",children:l("common.edit")})]}),c?(0,d.jsx)("textarea",{value:e,onChange:a=>h(a.target.value),className:"flex-1 w-full px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-none focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}):(0,d.jsx)("pre",{className:"flex-1 overflow-auto text-xs font-mono bg-muted/30 rounded p-2 whitespace-pre-wrap break-all select-text cursor-text",onContextMenu:a=>{a.preventDefault(),k(b)},children:b})]})}if("hash"===m){let b=Object.entries(n||{});return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,d.jsx)(aq,{type:"hash"}),(0,d.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[b.length," fields"]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-1/3",children:"Field"}),(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Value"})]})}),(0,d.jsx)("tbody",{children:b.map(([a,b])=>(0,d.jsxs)("tr",{className:"hover:bg-hover",children:[(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[150px]",onContextMenu:b=>{b.preventDefault(),k(a)},children:(0,d.jsx)(ar,{text:a})}),(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:a=>{a.preventDefault(),k(b)},children:(0,d.jsx)(ar,{text:b})})]},a))})]})})]})}if("list"===m){let b=n?.items||[],c=n?.total||0;return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,d.jsx)(aq,{type:"list"}),(0,d.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nItems",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-16",children:"#"}),(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Value"})]})}),(0,d.jsx)("tbody",{children:b.map((a,b)=>(0,d.jsxs)("tr",{className:"hover:bg-hover",children:[(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 text-muted-foreground",children:b}),(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:b=>{b.preventDefault(),k(a)},children:(0,d.jsx)(ar,{text:a})})]},b))})]})})]})}if("set"===m){let b=n?.items||[],c=n?.total||0;return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,d.jsx)(aq,{type:"set"}),(0,d.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nMembers",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsx)("tr",{children:(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Member"})})}),(0,d.jsx)("tbody",{children:b.map((a,b)=>(0,d.jsx)("tr",{className:"hover:bg-hover",children:(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[400px]",onContextMenu:b=>{b.preventDefault(),k(a)},children:(0,d.jsx)(ar,{text:a})})},b))})]})})]})}if("zset"===m){let b=n?.items||[],c=n?.total||0;return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,d.jsx)(aq,{type:"zset"}),(0,d.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nMembers",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Member"}),(0,d.jsx)("th",{className:"px-2 py-1 text-right text-muted-foreground font-medium border-b border-border w-28",children:"Score"})]})}),(0,d.jsx)("tbody",{children:b.map((a,b)=>(0,d.jsxs)("tr",{className:"hover:bg-hover",children:[(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:b=>{b.preventDefault(),k(a.member)},children:(0,d.jsx)(ar,{text:a.member})}),(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono text-right text-muted-foreground",children:a.score})]},b))})]})})]})}if("stream"===m){let b=n?.entries||[],c=n?.total||0;return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,d.jsx)(aq,{type:"stream"}),(0,d.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nEntries",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-40",children:"ID"}),(0,d.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Fields"})]})}),(0,d.jsx)("tbody",{children:b.map(([a,b])=>{let c=[];for(let a=0;a<b.length;a+=2)c.push(`${b[a]}: ${b[a+1]}`);return(0,d.jsxs)("tr",{className:"hover:bg-hover",children:[(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono text-muted-foreground",children:a}),(0,d.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",children:(0,d.jsx)(ar,{text:c.join(", ")})})]},a)})})]})})]})}return(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:l("redis.unsupportedType",{type:m})})}function au({infoText:a,onRefresh:b}){let{t:c}=(0,f.Bd)();if(!a)return(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})});let e=[],g=null;for(let b of a.split("\n")){let a=b.trim();if(a){if(a.startsWith("#"))g={title:a.replace(/^#\s*/,""),items:[]},e.push(g);else if(g&&a.includes(":")){let b=a.indexOf(":");g.items.push({key:a.slice(0,b),value:a.slice(b+1)})}}}return(0,d.jsxs)("div",{className:"p-2 space-y-3 overflow-auto h-full",children:[(0,d.jsx)("div",{className:"flex justify-end",children:(0,d.jsx)("button",{onClick:b,className:"px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:c("common.refresh")})}),e.map(a=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1 font-medium",children:a.title}),(0,d.jsx)("div",{className:"space-y-0",children:a.items.map(({key:a,value:b})=>(0,d.jsxs)("div",{className:"flex items-start gap-2 px-1.5 py-0.5 text-xs hover:bg-hover rounded",children:[(0,d.jsx)("span",{className:"text-muted-foreground font-mono flex-shrink-0 w-48 truncate",children:a}),(0,d.jsx)("span",{className:"font-mono text-foreground break-all",children:b})]},a))})]},a.title))]})}function av({cliInput:a,onInputChange:b,onExecute:c,history:e,loading:g,endRef:h,inputRef:i}){let{t:j}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex flex-col h-full",children:[(0,d.jsxs)("div",{className:"flex-1 overflow-auto p-2 font-mono text-xs space-y-2",onClick:()=>i.current?.focus(),children:[0===e.length&&(0,d.jsx)("div",{className:"text-muted-foreground text-center py-4",children:j("redis.cliHint")}),e.map((a,b)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"text-brand",children:[(0,d.jsx)("span",{className:"text-muted-foreground mr-1",children:">"}),a.command,a.duration>0&&(0,d.jsxs)("span",{className:"text-muted-foreground/50 ml-2",children:["(",a.duration,"ms)"]})]}),(0,d.jsx)("pre",{className:`whitespace-pre-wrap break-all mt-0.5 ${a.isError?"text-destructive":"text-foreground"}`,children:a.isError?`(error) ${a.result}`:function a(b,c=0){let d=" ".repeat(c);return null===b?`${d}(nil)`:"number"==typeof b?`${d}(integer) ${b}`:"string"==typeof b?`${d}"${b}"`:Array.isArray(b)?0===b.length?`${d}(empty array)`:b.map((b,c)=>`${d}${c+1}) ${a(b,0)}`).join("\n"):`${d}${String(b)}`}(a.result)})]},b)),(0,d.jsx)("div",{ref:h})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-t border-border bg-card/30 flex-shrink-0",children:[(0,d.jsx)("span",{className:"text-xs text-brand font-mono flex-shrink-0",children:">"}),(0,d.jsx)("input",{ref:i,type:"text",value:a,onChange:a=>b(a.target.value),onKeyDown:a=>{"Enter"!==a.key||g||c()},placeholder:j("redis.cliPlaceholder"),className:"flex-1 min-w-0 text-xs font-mono bg-transparent border-0 focus:outline-none",autoComplete:"off",spellCheck:!1,disabled:g}),g&&(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"})]})]})}F({type:"redis",idPrefix:"redis",match(a){let b=a.trim().toLowerCase();return b.startsWith("redis://")||b.startsWith("rediss://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"0";c=`db${d}@${a.hostname}${a.port?":"+a.port:":6379"}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k}){return(0,d.jsx)(as,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){await K("redis",a.id)}});var aw=c(83768);let ax=["#4C8BF5","#E74C3C","#2ECC71","#F39C12","#9B59B6","#1ABC9C","#E67E22","#3498DB","#E91E63","#00BCD4"];function ay(a){if(!a)return"";let b=new Date(a);return isNaN(b.getTime())?"":`${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")} ${String(b.getHours()).padStart(2,"0")}:${String(b.getMinutes()).padStart(2,"0")}`}function az({nodes:a,rels:b,allLabels:c}){let f=(0,e.useRef)(null),g=(0,e.useRef)(null);(0,aw.Ql)()?.resolvedTheme;let h=(0,e.useRef)([]);(0,e.useRef)(0);let i=(0,e.useRef)(null);(0,e.useRef)({w:0,h:0}),(0,e.useRef)(new Map);let[j,k]=(0,e.useState)(null),l=(0,e.useRef)(null),m=(0,e.useCallback)(a=>{let b=g.current?.getBoundingClientRect();if(!b)return null;let c=a.clientX-b.left,d=a.clientY-b.top;return h.current.find(a=>{let b=(a.x||0)-c,e=(a.y||0)-d;return b*b+e*e<400})||null},[]);return(0,d.jsxs)("div",{ref:f,className:"relative w-full h-full",children:[(0,d.jsx)("canvas",{ref:g,className:"cursor-grab active:cursor-grabbing absolute inset-0",onMouseDown:a=>{let b=m(a);if(b){let c=g.current.getBoundingClientRect();i.current={nodeId:b.id,offsetX:a.clientX-c.left-(b.x||0),offsetY:a.clientY-c.top-(b.y||0)}}},onMouseMove:a=>{if(i.current){let b=g.current.getBoundingClientRect(),c=h.current.find(a=>a.id===i.current.nodeId);c&&(c.x=a.clientX-b.left-i.current.offsetX,c.y=a.clientY-b.top-i.current.offsetY,c.vx=0,c.vy=0)}else{let b=m(a);l.current=b,k(b)}},onMouseUp:()=>{i.current=null},onMouseLeave:()=>{i.current=null,l.current=null,k(null)}}),j&&!i.current&&(0,d.jsxs)("div",{className:"absolute top-2 left-2 bg-popover text-popover-foreground border border-border rounded px-2 py-1 text-xs max-w-[300px] pointer-events-none",children:[(0,d.jsxs)("div",{className:"font-medium",children:[j.labels.join(", ")," #",String(j.id)]}),Object.entries(j.properties).slice(0,8).map(([a,b])=>(0,d.jsxs)("div",{className:"truncate",children:[(0,d.jsxs)("span",{className:"text-muted-foreground",children:[a,":"]})," ",String(b)]},a))]})]})}function aA({id:a,connectionString:b,displayName:c,selected:f,maximized:g,expandedHeight:h,bubbleContentHeight:i,onSelect:j,onClose:k,onToggleMaximize:l,timestamp:m,onTitleMouseDown:n}){let[o,p]=(0,e.useState)("connecting"),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(null),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)("labels"),[B,C]=(0,e.useState)(""),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)(!1),[H,I]=(0,e.useState)(""),J=(0,e.useRef)(null),[K,L]=(0,e.useState)([]),[M,N]=(0,e.useState)([]),[P,Q]=(0,e.useState)("schema"),R=(0,e.useCallback)(async()=>{p("connecting");try{let c=await O("/api/neo4j/connect",{id:a,connectionString:b});t(c),p("connected")}catch(a){r(a instanceof Error?a.message:String(a)),p("error")}},[a,b]),S=(0,e.useCallback)(async()=>{y(!0);try{let c=await O("/api/neo4j/schema",{id:a,connectionString:b});v(c)}catch{}y(!1)},[a,b]),T=(0,e.useCallback)(async c=>{let d=c||B.trim();if(d){G(!0),I("");try{var e;let c,f,g=await O("/api/neo4j/query",{id:a,connectionString:b,cypher:d});E(g);let{nodes:h,rels:i}=(e=g.records,c=new Map,f=[],e.forEach(a=>Object.values(a).forEach(function a(b){if(b&&"object"==typeof b)if("node"===b._type){let a=b._id;c.has(a)||c.set(a,{id:a,labels:b._labels||[],properties:Object.fromEntries(Object.entries(b).filter(([a])=>!a.startsWith("_")))})}else if("relationship"===b._type)f.push({id:b._id,type:b._relType,startId:b._start,endId:b._end,properties:Object.fromEntries(Object.entries(b).filter(([a])=>!a.startsWith("_")))});else if("path"===b._type){let c=b.segments;c?.forEach(b=>{a(b.start),a(b.relationship),a(b.end)})}else Array.isArray(b)&&b.forEach(a)})),{nodes:Array.from(c.values()),rels:f});h.length>0&&(L(h),N(i))}catch(a){I(a instanceof Error?a.message:String(a))}G(!1)}},[a,b,B]),U=(0,e.useCallback)(a=>{let b=`MATCH (n:\`${a}\`) RETURN n LIMIT 25`;C(b),Q("cypher"),T(b)},[T]),V=(0,e.useCallback)(a=>{let b=`MATCH (a)-[r:\`${a}\`]->(b) RETURN a, r, b LIMIT 25`;C(b),Q("graph"),T(b)},[T]);return(0,d.jsx)("div",{className:"flex flex-col items-start",onClick:j,children:(0,d.jsxs)("div",{className:`w-full bg-accent text-foreground relative transition-colors ${f?"ring-1 ring-ring":""} rounded-lg overflow-hidden`,children:[(0,d.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:l,onMouseDown:n,className:"flex items-center gap-2 px-4 py-1.5 border-b border-border cursor-grab active:cursor-grabbing select-none",children:[(0,d.jsx)("span",{className:"text-sm flex-shrink-0",children:"⬡"}),(0,d.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===o&&(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"connected"===o&&(0,d.jsx)("span",{className:"text-[10px] text-green-11 flex-shrink-0",children:"Connected"}),"error"===o&&(0,d.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:"Error"}),m&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:ay(m)}),"connected"===o&&s&&(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:["v",s.version," \xb7 ",s.nodeCount.toLocaleString(),"n \xb7 ",s.relationshipCount.toLocaleString(),"r"]}),(0,d.jsx)("span",{className:"flex-1"}),"connected"===o&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),S(),R()},disabled:x,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 disabled:opacity-40",title:"Refresh",children:(0,d.jsx)("svg",{className:`w-3.5 h-3.5 ${x?"animate-spin":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g?(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"}):(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{style:{height:g&&h?h-41:i??360},className:"flex flex-col overflow-hidden",children:["connecting"===o&&(0,d.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Connecting..."]}),"error"===o&&(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-xs p-4 gap-2",children:[(0,d.jsx)("p",{className:"text-destructive",children:q}),(0,d.jsx)("button",{onClick:R,className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Retry"})]}),"connected"===o&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:["schema","cypher","graph"].map(a=>(0,d.jsx)("button",{onClick:()=>Q(a),className:`px-3 py-1.5 text-xs transition-colors ${P===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{schema:"Schema",cypher:"Cypher",graph:"Graph"}[a]},a))}),(0,d.jsxs)("div",{className:"flex-1 overflow-hidden flex",children:["schema"===P&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"w-40 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:(0,d.jsx)("div",{className:"flex-1 overflow-y-auto text-xs",children:[{key:"labels",label:"Labels",count:u?.labels.length},{key:"relationships",label:"Relationships",count:u?.relationshipTypes.length},{key:"properties",label:"Properties",count:u?.propertyKeys.length},{key:"indexes",label:"Indexes",count:u?.indexes.length},{key:"constraints",label:"Constraints",count:u?.constraints.length}].map(a=>(0,d.jsxs)("div",{onClick:()=>A(a.key),className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer truncate transition-colors ${z===a.key?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate min-w-0 flex-1",children:a.label}),(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count??0})]},a.key))})}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[x&&(0,d.jsxs)("div",{className:"flex items-center justify-center p-4 gap-2 text-muted-foreground",children:[(0,d.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"})," Loading..."]}),!x&&"labels"===z&&u?.labels.map(a=>{var b;return(0,d.jsxs)("div",{onClick:()=>U(a.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:(b=a.name,ax[u.labels.map(a=>a.name).indexOf(b)%ax.length])}}),(0,d.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:a.name}),(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count.toLocaleString()})]},a.name)}),!x&&"relationships"===z&&u?.relationshipTypes.map(a=>(0,d.jsxs)("div",{onClick:()=>V(a.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:"→"}),(0,d.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:a.name}),(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count.toLocaleString()})]},a.name)),!x&&"properties"===z&&u?.propertyKeys.map(a=>(0,d.jsx)("div",{className:"px-2 py-1 font-mono text-muted-foreground hover:bg-brand/10 transition-colors",children:a},a)),!x&&"indexes"===z&&u?.indexes.map(a=>(0,d.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("div",{className:"font-mono text-foreground",children:a.name}),(0,d.jsxs)("div",{className:"text-muted-foreground",children:[a.type," \xb7 ",a.labelsOrTypes?.join(", ")," \xb7 (",a.properties?.join(", "),") \xb7 ",a.state]})]},a.name)),!x&&"constraints"===z&&u?.constraints.map(a=>(0,d.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("div",{className:"font-mono text-foreground",children:a.name}),(0,d.jsxs)("div",{className:"text-muted-foreground",children:[a.type," \xb7 ",a.labelsOrTypes?.join(", ")," \xb7 (",a.properties?.join(", "),")"]})]},a.name))]})]}),"cypher"===P&&(0,d.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"p-2 border-b border-border flex-shrink-0",children:[(0,d.jsx)("textarea",{ref:J,value:B,onChange:a=>C(a.target.value),onKeyDown:a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),T())},placeholder:`Enter Cypher query (${(0,w.Mu)()}+Enter to run)`,className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,d.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[(0,w.Mu)(),"+Enter to execute"]}),(0,d.jsx)("button",{onClick:()=>T(),disabled:F||!B.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:F?"Running...":"Execute"})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-auto",children:[H&&(0,d.jsx)("div",{className:"p-2 text-xs text-destructive",children:H}),D&&!H&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-2 py-1 text-[10px] text-muted-foreground border-b border-border flex items-center gap-2",children:[(0,d.jsxs)("span",{children:[D.records.length," rows"]}),(0,d.jsxs)("span",{children:[D.duration,"ms"]}),Object.entries(D.counters).filter(([,a])=>a>0).map(([a,b])=>(0,d.jsxs)("span",{children:[a,": ",b]},a))]}),D.records.length>0&&(0,d.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,d.jsx)("tr",{children:D.keys.map(a=>(0,d.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a},a))})}),(0,d.jsx)("tbody",{children:D.records.map((a,b)=>(0,d.jsx)("tr",{className:"hover:bg-hover",children:D.keys.map(b=>(0,d.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",children:null===a[b]?(0,d.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):function(a){if(null==a)return"null";if("object"==typeof a){if("node"===a._type){let b=a._labels?.[0]||"",c=a.name||a.title||a.id||"";return`(${b}${c?": "+c:""})`}return"relationship"===a._type?`[${a._relType}]`:JSON.stringify(a)}return String(a)}(a[b])},b))},b))})]})]})]})]}),"graph"===P&&(0,d.jsx)("div",{className:"flex-1 relative",children:0===K.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-xs text-muted-foreground gap-2",children:[(0,d.jsx)("p",{children:"Run a Cypher query that returns nodes to visualize"}),(0,d.jsx)("button",{onClick:()=>{let a="MATCH (a)-[r]->(b) RETURN a, r, b LIMIT 50";C(a),T(a)},className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Load sample graph"})]}):(0,d.jsx)(az,{nodes:K,rels:M,allLabels:u?.labels.map(a=>a.name)||[]})})]})]})]}),!g&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===o?"bg-green-500":"error"===o?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,d.jsx)("span",{children:{connecting:"Connecting",connected:"Connected",error:"Error"}[o]}),"connected"===o&&s&&(0,d.jsx)("span",{className:"text-muted-foreground/70",children:s.edition}),(0,d.jsx)("span",{className:"flex-1"}),m&&(0,d.jsx)("span",{className:"text-[11px] flex-shrink-0",children:ay(m)})]})]})})}F({type:"neo4j",idPrefix:"neo4j",match(a){let b=a.trim().toLowerCase();return b.startsWith("neo4j://")||b.startsWith("neo4j+s://")||b.startsWith("bolt://")||b.startsWith("bolt+s://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b);c=`${a.hostname}${a.port?":"+a.port:":7687"}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k}){return(0,d.jsx)(aA,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:f,timestamp:g,onSelect:h,onClose:i,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){await K("neo4j",a.id)}});let aB=null,aC="",aD=0,aE=null,aF=!1,aG=new Map,aH=null,aI=null;function aJ(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){aH&&(aH(b.commands),aH=null);return}let d=b.commandId;if(!d)return;let e=aG.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&aG.delete(d)}}function aK(a){aB?.readyState===WebSocket.OPEN&&aB.send(JSON.stringify(a))}function aL(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);aC===c&&aB||(function(){if(aF=!0,aE&&(clearTimeout(aE),aE=null),aB){let a=aB;aB=null,a.close()}aG.clear(),aH&&(aH([]),aH=null),aI=null,aC="",aD=0}(),aF=!1,aC=c,function a(){if(aF||!aC)return;let b=new WebSocket(aC);aB=b,b.onopen=()=>{for(let a of(aD=0,aG.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=aJ,b.onclose=()=>{if(aB!==b||(aB=null,aF))return;aE&&clearTimeout(aE);let c=Math.min(1e3*Math.pow(1.5,aD),1e4);aD++,aE=setTimeout(a,c)},b.onerror=()=>{}}())}function aM(){return new Promise((a,b)=>{if(aB?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{aB?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(d),a())},50),d=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function aN(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:i,rows:j,sourceId:k,onData:l,onError:m}=a;aL(f);try{await aM()}catch{m("WebSocket connection failed");return}aG.delete(d),aG.set(d,{onData:l,onError:m}),aK({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...i?{cols:i,rows:j}:{},...k?{sourceId:k}:{}})}async function aO(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;aL(c);try{await aM()}catch{e("WebSocket connection failed");return}aG.set(b,{onData:d,onError:e}),aK({type:"attach",commandId:b})}function aP(a,b){aK({type:"stdin",commandId:a,data:b})}function aQ(a,b,c){aK({type:"resize",commandId:a,cols:b,rows:c})}function aR(a){aK({type:"interrupt",pid:a})}async function aS(a){try{aL(a);try{await aM()}catch{return[]}return await new Promise(a=>{aH=b=>{a(b)},aK({type:"running"}),setTimeout(()=>{aH&&(aH=null,a([]))},3e3)})}finally{aI=null}}let aT=(0,e.memo)(function({item:a,selected:b,maximized:c,initialSleeping:e,tabId:f,projectCwd:g,expandedHeight:h,bubbleContentHeight:i,onDragStart:j,onDragOver:k,onDragEnter:l,onDragLeave:m,onDrop:n,onDragEnd:o,onSelectId:p,onInterruptId:q,onStdin:r,onDeleteCommand:s,onRerun:t,subscribePtyOutput:u,subscribePtyReset:v,subscribePtyRefresh:w,ptySizeRef:x,resizePty:y,onToggleMaximizeId:z,onTitleMouseDown:A,onClosePlugin:B,addBrowserItem:D,onSleep:E,onWake:F}){let H={draggable:!0,onDragStart:b=>j(b,a.data.id),onDragOver:b=>k(b,a.data.id),onDragEnter:l,onDragLeave:m,onDrop:n,onDragEnd:o};if("command"===a.type){let e=a.data;return(0,d.jsx)("div",{"data-bubble-id":e.id,className:"group/cmd rounded-lg transition-shadow",...H,children:(0,d.jsx)(C,{commandId:e.id,tabId:f,projectCwd:g,command:e.command,output:e.output,exitCode:e.exitCode,isRunning:e.isRunning,selected:b,onSelect:()=>{p(e.id)},onInterrupt:e.isRunning?()=>q(e.id):void 0,onStdin:e.isRunning?a=>r(e.id,a):void 0,onDelete:()=>{e.isRunning&&e.pid&&aR(e.pid),s(e.id)},onRerun:()=>t(e.id),timestamp:e.timestamp,usePty:e.usePty,subscribePtyOutput:e.usePty?u:void 0,subscribePtyReset:e.usePty?v:void 0,subscribePtyRefresh:e.usePty?w:void 0,onPtyResize:(a,b)=>{x.current.set(e.id,{cols:a,rows:b}),y(e.id,a,b)},onToggleMaximize:()=>z(e.id),maximized:c,expandedHeight:h,bubbleContentHeight:i,onTitleMouseDown:A})})}let I=G(a.type);if(!I)return null;let J=I.Component,K=a.data;return(0,d.jsx)("div",{"data-bubble-id":K.id,className:"rounded-lg transition-shadow",...H,children:(0,d.jsx)(J,{item:K,selected:b,maximized:c,expandedHeight:h,bubbleContentHeight:i,timestamp:K.timestamp,onSelect:()=>{p(K.id)},onClose:()=>B(K.id),onToggleMaximize:()=>z(K.id),onTitleMouseDown:A,extra:{addBrowserItem:D,initialSleeping:e,onSleep:E,onWake:F,projectCwd:g,tabId:f}})})});var aU=c(59347),aV=c(24520);function aW({cwd:a,tabId:b,onClose:c,onSave:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)({}),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(!0);(0,e.useCallback)(async()=>{q(!0);let c=await r.t4.runPromiseExit((0,u.QF)(a,b));"Success"===c._tag?k(c.value.env):console.error("Failed to load env:",c.cause),q(!1)},[a,b]);let s=()=>{l.trim()&&(k(a=>({...a,[l.trim()]:n})),m(""),o(""))},t=async()=>{let d=await r.t4.runPromiseExit((0,u.Vv)({cwd:a,tabId:b,env:j}));"Success"===d._tag?(h(j),c()):console.error("Failed to save env:",d.cause)};return(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-lv3 w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:i("envManager.title")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b?i("envManager.tabScope"):i("envManager.globalScope")})]}),(0,d.jsx)("button",{onClick:c,className:"p-1 rounded hover:bg-hover transition-colors",children:(0,d.jsx)(g.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:i("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(j).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void k(b=>({...b,[a]:c}))},placeholder:i("envManager.valuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"}),(0,d.jsx)("button",{onClick:()=>{k(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,d.jsx)(aU.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsx)("input",{type:"text",value:l,onChange:a=>m(a.target.value),placeholder:i("envManager.varNamePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),s())}}),(0,d.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:i("envManager.varValuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),s())}}),(0,d.jsx)("button",{onClick:s,disabled:!l.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(aV.A,{className:"w-4 h-4"})})]}),0===Object.keys(j).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:i("envManager.noVars")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:c,className:"px-4 py-2 rounded-lg text-sm hover:bg-hover transition-colors",children:i("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:i("common.save")})]})]})})}var aX=c(32465),aY=c(95801),aZ=c(69004),a$=c(75155),a_=c(64672),a0=c(88282),a1=c(72529);function a2({onAdd:a,onCancel:b}){let{t:c}=(0,f.Bd)(),[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)("");return(0,d.jsxs)("div",{className:"flex gap-1 mb-1",children:[(0,d.jsx)("input",{type:"text",value:g,onChange:a=>h(a.target.value),placeholder:c("console.namePlaceholder"),className:"w-24 flex-shrink-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0,onKeyDown:a=>{"Escape"===a.key&&b()}}),(0,d.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),placeholder:c("console.commandPlaceholder"),className:"flex-1 min-w-0 px-2 py-1 text-xs font-mono rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",onKeyDown:c=>{"Enter"!==c.key||c.nativeEvent.isComposing?"Escape"===c.key&&b():(c.preventDefault(),c.stopPropagation(),g.trim()&&i.trim()&&a(g.trim(),i.trim()))}})]})}function a3({label:a,commands:b,isAdding:c,onStartAdd:e,onAdd:h,onCancelAdd:i,onDelete:j,onExecute:k}){let{t:l}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:a}),(0,d.jsx)("button",{type:"button",onClick:e,className:"p-0.5 text-muted-foreground hover:text-foreground rounded",children:(0,d.jsx)(aV.A,{className:"w-3.5 h-3.5"})})]}),c&&(0,d.jsx)(a2,{onAdd:(a,b)=>h(a,b),onCancel:i}),0===b.length&&!c&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:l("console.noCustomCommands")}),b.map((a,b)=>(0,d.jsx)(a1.m,{content:a.command,children:(0,d.jsxs)("div",{className:"flex items-center group min-w-0",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>k(a.command),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",children:[(0,d.jsx)(a0.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"truncate",children:a.name})]}),(0,d.jsx)("button",{type:"button",onClick:()=>j(b),className:"p-1 text-muted-foreground hover:text-destructive rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:(0,d.jsx)(g.A,{className:"w-3 h-3"})})]})},b))]})}function a4({cwd:a,show:b,onClose:c,onExecute:g,onAddPluginItem:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)(null),p=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let[b,c]=await Promise.all([r.t4.runPromiseExit((0,u.Yj)()),r.t4.runPromiseExit((0,u.UV)(a))]);"Success"===b._tag&&k(b.value.customCommands||[]),"Success"===c._tag&&m(c.value.customCommands||[])},[a]);let q=(0,e.useCallback)(async a=>{k(a);let b=await r.t4.runPromiseExit((0,u.Cb)({scope:"global",customCommands:a}));"Failure"===b._tag?console.error("Failed to save global commands:",b.cause):b.value?.customCommands&&k(b.value.customCommands)},[]),s=(0,e.useCallback)(async b=>{m(b);let c=await r.t4.runPromiseExit((0,u.Cb)({cwd:a,customCommands:b}));"Failure"===c._tag?console.error("Failed to save project commands:",c.cause):c.value?.customCommands&&m(c.value.customCommands)},[a]),t=(0,e.useCallback)(a=>{c();let b=H(a);b?h?.(b.type,a.trim()):g(a)},[c,g,h]);return b?(0,d.jsxs)("div",{ref:p,className:"absolute bottom-full left-0 mb-2 w-72 bg-popover border border-border rounded-lg shadow-lv2 z-50 max-h-[70vh] overflow-y-auto",children:[(0,d.jsx)(a3,{label:i("console.globalCommands"),commands:j,isAdding:"global"===n,onStartAdd:()=>o("global"),onAdd:(a,b)=>{q([...j,{name:a,command:b}]),o(null)},onCancelAdd:()=>o(null),onDelete:a=>q(j.filter((b,c)=>c!==a)),onExecute:t}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsx)(a3,{label:i("console.projectCommands"),commands:l,isAdding:"project"===n,onStartAdd:()=>o("project"),onAdd:(a,b)=>{s([...l,{name:a,command:b}]),o(null)},onCancelAdd:()=>o(null),onDelete:a=>s(l.filter((b,c)=>c!==a)),onExecute:t})]}):null}function a5({cwd:a,currentCwd:b,commandHistoryRef:c,gridLayout:g,onGridLayoutChange:h,onExecute:i,onAddPluginItem:j,onShowEnvManager:k,onOpenShell:l,onOpenNote:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)(""),[q,s]=(0,e.useState)(-1),[t,v]=(0,e.useState)(""),[w,x]=(0,e.useState)([]),[y,z]=(0,e.useState)(0),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)([]),[G,I]=(0,e.useState)([]),[J,K]=(0,e.useState)(!1),[L,M]=(0,e.useState)(0),N=(0,e.useRef)(null),O=(0,e.useRef)(null),P=(0,e.useRef)(!1),{projectCommands:Q,globalCommands:R,expandCustomCommand:S,loadQuickCommands:T}=function(a){let[b,c]=(0,e.useState)([]),[d,f]=(0,e.useState)([]),g=(0,e.useCallback)(async()=>{let[b,d]=await Promise.all([r.t4.runPromiseExit((0,u.UV)(a)),r.t4.runPromiseExit((0,u.Yj)())]);"Success"===b._tag&&c(b.value.customCommands||[]),"Success"===d._tag&&f(d.value.customCommands||[])},[a]),h=[...b,...d],i=(0,e.useCallback)(a=>{let c=a.trim().split(/\s+/),e=c[0];if(!e.startsWith("/")||e.length<=1)return null;let f=e.slice(1),g=b.find(a=>a.name===f)??d.find(a=>a.name===f);return g?g.command+(c.length>1?" "+c.slice(1).join(" "):""):null},[b,d]);return{quickCustomCommands:h,projectCommands:b,globalCommands:d,expandCustomCommand:i,loadQuickCommands:g}}(a),U=(0,e.useCallback)(a=>{if(K(!1),"html"===a.kind){j?.("browser",a.path),p("");return}let b=a.cmd.command,c=H(b);c?j?.(c.type,b.trim()):i(b),p("")},[i,j]),V=(0,e.useCallback)(a=>{if(a.preventDefault(),P.current||!o.trim())return;if(o.startsWith("/")){let a=o.slice(1).trim(),b=E.find(b=>b.name===a);if(b){j?.("browser",b.path),p(""),s(-1),v(""),K(!1);return}}let b=S(o)??o,c=H(b);c?j?.(c.type,b.trim()):i(b),p(""),s(-1),v("")},[o,i,j,S,E]),W=(0,e.useCallback)(async()=>{if(!N.current)return;let a=N.current.selectionStart||0,c=await r.t4.runPromiseExit((0,u.tp)({cwd:b,input:o,cursorPosition:a}));if("Success"===c._tag){let b=c.value,d=b.suggestions;if(d&&d.length>0&&(x(d),z(0),B(!0),1===d.length)){let c=o.substring(0,b.replaceStart??0),e=o.substring(b.replaceEnd??a);p(c+d[0]+e),B(!1),setTimeout(()=>{if(N.current){let a=(b.replaceStart??0)+d[0].length;N.current.setSelectionRange(a,a)}},0)}}else console.error("Autocomplete error:",c.cause)},[b,o]),X=(0,e.useCallback)(a=>{if(!N.current)return;let b=N.current.selectionStart||0,c=o.substring(0,b),d=o.substring(b),e=c.split(/\s+/),f=b-(e[e.length-1]||"").length;p(o.substring(0,f)+a+d),B(!1),setTimeout(()=>{if(N.current){let b=f+a.length;N.current.setSelectionRange(b,b)}},0)},[o]),Y=(0,e.useCallback)(a=>{if(a.nativeEvent.isComposing)return;if(J&&G.length>0){if("ArrowUp"===a.key){a.preventDefault(),M(a=>(a-1+G.length)%G.length);return}if("ArrowDown"===a.key){a.preventDefault(),M(a=>(a+1)%G.length);return}if("Tab"===a.key||"Enter"===a.key){a.preventDefault(),U(G[L]);return}if("Escape"===a.key){a.preventDefault(),K(!1);return}}if("Tab"===a.key){if(a.preventDefault(),A&&w.length>0){let a=(y+1)%w.length;z(a),X(w[a])}else W();return}if("Escape"===a.key&&A){a.preventDefault(),B(!1);return}let b=c.current;if(b&&0!==b.length){if("ArrowUp"===a.key){a.preventDefault(),-1===q&&v(o);let c=-1===q?b.length-1:Math.max(0,q-1);s(c),p(b[c])}else if("ArrowDown"===a.key){if(a.preventDefault(),-1===q)return;let c=q+1;c>=b.length?(s(-1),p(t)):(s(c),p(b[c]))}}},[q,o,t,A,w,y,W,X,J,G,L,U,c]);return(0,d.jsx)("div",{className:"border-t border-border p-4",children:(0,d.jsxs)("form",{onSubmit:V,className:"relative flex gap-2 items-center",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{type:"button",onClick:()=>{C||T(),D(!C)},className:`p-2 rounded-lg transition-all ${C?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:n("console.quickCommands"),children:(0,d.jsx)(aY.A,{className:"w-4 h-4"})}),(0,d.jsx)(a4,{cwd:a,show:C,onClose:()=>D(!1),onExecute:i,onAddPluginItem:j})]}),m&&(0,d.jsx)("button",{type:"button",onClick:m,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:n("chat.projectNotes"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{type:"button",onClick:()=>h(!g),className:`p-2 rounded-lg transition-all ${g?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:g?n("console.singleColumn"):n("console.dualColumn"),children:g?(0,d.jsx)(aZ.A,{className:"w-4 h-4"}):(0,d.jsx)(a$.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{type:"button",onClick:k,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:n("console.envVars"),children:(0,d.jsx)(a_.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{type:"button",onClick:l,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:n("console.launchShell"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,d.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),(0,d.jsx)("input",{ref:N,type:"text",value:o,onChange:a=>{p(a.target.value),-1!==q&&(s(-1),v("")),B(!1)},onKeyDown:Y,onCompositionStart:()=>{P.current=!0},onCompositionEnd:()=>{P.current=!1},placeholder:n("console.inputPlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring font-mono"}),J&&G.length>0&&(0,d.jsx)("div",{ref:O,className:"absolute bottom-full left-0 right-0 mb-1 max-h-64 overflow-y-auto bg-popover border border-border rounded-lg shadow-lv2 z-50",children:G.map((a,b)=>(0,d.jsx)("div",{onClick:()=>U(a),className:`flex items-center gap-3 px-3 py-1.5 cursor-pointer text-sm ${b===L?"bg-brand/10":"hover:bg-hover"}`,children:"html"===a.kind?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"font-mono font-medium text-foreground",children:["/",a.name]}),(0,d.jsx)("span",{className:"flex-1 text-muted-foreground truncate",children:a.path}),(0,d.jsx)("span",{className:"text-[10px] text-brand/70 flex-shrink-0",children:"HTML"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"font-mono font-medium text-foreground",children:["/",a.cmd.name]}),(0,d.jsx)("span",{className:"flex-1 text-muted-foreground truncate",children:a.cmd.command}),(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/60 flex-shrink-0",children:"project"===a.cmd.scope?n("console.scopeProject"):n("console.scopeGlobal")})]})},"html"===a.kind?`html-${a.name}`:`cmd-${a.cmd.scope}-${a.cmd.name}`))}),A&&w.length>1&&(0,d.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 bg-popover border border-border rounded-lg shadow-lv2 max-h-48 overflow-y-auto z-50",children:[(0,d.jsx)("div",{className:"py-1",children:w.map((a,b)=>(0,d.jsx)("button",{type:"button",onClick:()=>X(a),className:`w-full px-3 py-1.5 text-left text-sm font-mono hover:bg-hover transition-colors ${b===y?"bg-accent":""}`,children:a},b))}),(0,d.jsx)("div",{className:"border-t border-border px-3 py-1 text-xs text-muted-foreground",children:n("console.tabSwitchEscClose")})]})]})})}function a6({showTop:a,showBottom:b,onScrollTop:c,onScrollBottom:e}){let{t:g}=(0,f.Bd)();return(0,d.jsxs)(d.Fragment,{children:[a&&(0,d.jsx)("button",{onClick:c,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-lv2 rounded-full transition-all hover:shadow-lv2 active:scale-95 z-10",title:g("chat.jumpToStart"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),b&&(0,d.jsx)("button",{onClick:e,className:"absolute bottom-20 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-lv2 rounded-full transition-all hover:shadow-lv2 active:scale-95 z-10",title:g("chat.jumpToLatest"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})}c(47276);var a7=c(23389);function a8(){return`cmd-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}let a9="__cockpit_open_preferred_shell__",ba="shell",bb=new Set([a9,"zsh","bash","sh","fish","nu","python","python3","node","irb","lua","vim","nvim","vi","nano","emacs","top","htop","less","man"]),bc=[{key:"command",label:"console.bubbleCommand",triggers:["ls","git status","npm run dev"]},{key:"pty",label:"console.bubbleInteractive",triggers:["zsh","bash","vim","python"]},{key:"browser",label:"console.bubbleBrowser",triggers:["https://…","*.html"],notes:["console.bubbleBrowserNoteIframe","console.bubbleBrowserNoteCookie"]},{key:"database",label:"console.bubbleDatabase",triggers:["postgresql://","mysql://","redis://","neo4j://"]},{key:"filePreview",label:"console.bubbleFilePreview",triggers:[...D.GV]}],bd=(0,e.memo)(function({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:g,onOpenNote:h}){let{t:i}=(0,f.Bd)(),{consoleItems:j,scrollRef:k,selectedCommandId:l,setSelectedCommandId:m,interruptCommand:n,sendStdin:o,deleteCommand:p,rerunCommand:s,ptySizeRef:t,resizePty:v,executeCommand:w,addPluginItem:y,closePluginItem:z,sleepingBubbles:A,handleBubbleSleep:B,handleBubbleWake:C,scrollToBottom:D,currentCwd:E,commandHistoryRef:F,setCustomEnv:I,setAliases:J,saveBubbleOrder:K,hasMoreHistory:L,loadHistory:M,currentPage:N,isLoadingHistory:O,subscribePtyOutput:P,subscribePtyReset:Q,subscribePtyRefresh:R}=function({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d}){let[f,g]=(0,e.useState)([]),[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)(new Set),[l,m]=(0,e.useState)(b||a),[n,o]=(0,e.useState)(!1),[p,s]=(0,e.useState)(!1),[t,v]=(0,e.useState)(0),[w,y]=(0,e.useState)(null),[z,A]=(0,e.useState)({}),B=(0,e.useRef)(""),[C,D]=(0,e.useState)({}),[E,F]=(0,e.useState)(null),I=(0,e.useRef)(null),J=(0,e.useRef)(new Map),K=(0,e.useRef)(new Map),L=(0,e.useRef)(new Set),M=(0,e.useRef)([]),N=(0,e.useRef)(new Map),O=(0,e.useRef)(new Map),P=(0,e.useRef)(new Map),Q=(0,e.useRef)(null),R=(0,e.useRef)(null),S=(0,e.useRef)([]),T=(0,e.useRef)("");T.current||(T.current="u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():`s_${Date.now()}_${Math.random().toString(36).slice(2)}`);let U=(0,e.useRef)(null),V=(0,e.useCallback)(()=>{if(J.current.size>0){let a=new Map(J.current);J.current.clear(),g(b=>b.map(b=>{let c=a.get(b.id);return void 0!==c?{...b,output:c}:b}))}I.current=null},[]),W=(0,e.useCallback)((a,b)=>{if(L.current.has(a)){let c=O.current.get(a);if(c&&c.size>0)for(let a of c)a(b);else P.current.has(a)||P.current.set(a,[]),P.current.get(a).push(b);return}let c=(K.current.get(a)||"")+b;if(c.length>2097152){let b=function(a){let b=a.slice(-2097152),c=0;if(b.length>0){let a=b.charCodeAt(0);a>=56320&&a<=57343&&(c=1)}let d=Math.min(b.length,64);for(let a=c;a<d;a++){let d=b.charCodeAt(a);if(27===d){c=a;break}if((!(d>=48)||!(d<=63))&&59!==d&&63!==d&&32!==d){d>=64&&d<=126&&(c=a+1);break}}return c>0?b.slice(c):b}(c);K.current.set(a,b),J.current.set(a,b)}else K.current.set(a,c),J.current.set(a,c);null===I.current&&(I.current=requestAnimationFrame(V))},[V]),X=(0,e.useCallback)((a,b=!1)=>{K.current.delete(a),L.current.delete(a),J.current.delete(a),P.current.delete(a),b||(O.current.delete(a),Z.current.delete(a))},[]),Y=(0,e.useCallback)((a,b)=>{O.current.has(a)||O.current.set(a,new Set),O.current.get(a).add(b);let c=P.current.get(a);if(c&&c.length>0){for(let a of c)b(a);P.current.delete(a)}return()=>{O.current.get(a)?.delete(b)}},[]),Z=(0,e.useRef)(new Map),$=(0,e.useCallback)((a,b)=>(Z.current.has(a)||Z.current.set(a,new Set),Z.current.get(a).add(b),()=>{Z.current.get(a)?.delete(b)}),[]),_=(0,e.useRef)(new Map),aa=(0,e.useCallback)((a,b)=>(_.current.has(a)||_.current.set(a,new Set),_.current.get(a).add(b),()=>{_.current.get(a)?.delete(b)}),[]),ab=(0,e.useCallback)(a=>(null!==I.current&&(cancelAnimationFrame(I.current),I.current=null),V(),K.current.get(a)||""),[V]),ac=(0,e.useCallback)(()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight)},[]),ad=(0,e.useCallback)(async(b=0)=>{if(c){o(!0);try{let d=await r.t4.runPromise((0,u.uc)(a,c,b,100)).catch(a=>(console.error("Failed to load history:",a),null));if(d){let a=[],c=[],e=new Set;for(let b of d.entries){let d=G(b.type);if(d){let a=d.fromHistory(b);c.push({id:b.id,_type:b.type,timestamp:b.timestamp,...a}),b.sleeping&&e.add(b.id)}else{if(b.running)continue;let c=b.id.includes("-")&&3===b.id.split("-").length?b.id:a8();a.push({id:c,command:b.command,output:b.output,exitCode:b.exitCode,isRunning:!1,timestamp:b.timestamp,cwd:b.cwd,usePty:b.usePty})}}0===b?(g(a),i(c),e.size>0&&k(e)):(g(b=>{let c=new Set(b.map(a=>a.id)),d=a.filter(a=>!c.has(a.id));return[...b,...d]}),i(a=>{let b=new Set(a.map(a=>a.id)),d=c.filter(a=>!b.has(a.id));return[...a,...d]})),s(d.hasMore),v(b)}}catch(a){console.error("Failed to load history:",a)}finally{o(!1)}}},[a,c]),ae=(0,e.useCallback)(async b=>{c&&await r.t4.runPromise((0,u.AJ)(a,c,{id:b.id,command:b.command,output:b.output,exitCode:b.exitCode,timestamp:b.timestamp,cwd:l},T.current).pipe(x.sFT(a=>x.OH5(()=>console.error("Failed to save cd history:",a))),x.NWQ(()=>x.rIH)))},[a,c,l]);(0,e.useCallback)(async b=>{try{let d=await (aI||(aI=aS(a)));if(b.current)return;for(let e of d){if(c&&e.tabId!==c)continue;if(b.current)break;let d=e.commandId;g(a=>a.find(a=>a.id===d)?a.map(a=>a.id===d?{...a,isRunning:!0,exitCode:void 0,pid:e.pid,...e.usePty?{usePty:!0}:{}}:a):[...a,{id:d,command:e.command,output:"",isRunning:!0,pid:e.pid,timestamp:e.timestamp,cwd:e.cwd,...e.usePty?{usePty:!0}:{}}]),K.current.set(d,""),e.usePty&&L.current.add(d),await aO({commandId:d,projectCwd:a,onData:(a,b)=>{if("pid"===a)"string"==typeof b.command&&g(a=>a.map(a=>a.id===d?{...a,command:b.command}:a));else if("stdout"===a||"stderr"===a)W(d,b.data);else if("exit"===a){let a=ab(d);X(d),g(c=>c.map(c=>c.id===d?{...c,output:a,exitCode:b.code,isRunning:!1,pid:void 0}:c))}},onError:()=>{g(a=>a.map(a=>a.id===d&&a.isRunning?{...a,isRunning:!1}:a))}})}}catch{}},[a,c,W,ab,X]);let af=(0,e.useCallback)((b,c)=>{K.current.set(b,""),c&&L.current.add(b),aO({commandId:b,projectCwd:a,onData:(a,c)=>{if("pid"===a)g(a=>a.map(a=>a.id===b?{...a,pid:c.pid,..."string"==typeof c.command?{command:c.command}:{}}:a));else if("stdout"===a||"stderr"===a)W(b,c.data);else if("exit"===a){let a=ab(b);X(b),g(d=>d.map(d=>d.id===b?{...d,output:a,exitCode:c.code,isRunning:!1,pid:void 0}:d))}},onError:()=>{g(a=>a.map(a=>a.id===b&&a.isRunning?{...a,isRunning:!1}:a))}}).catch(()=>{})},[a,W,ab,X]),ag=(0,e.useCallback)(a=>{let b=a?.id;if(!a||!b||S.current.some(a=>a.data.id===b))return;let c=a.type,d=c?G(c):void 0;if(d)i(e=>e.some(a=>a.id===b)?e:[...e,{id:b,_type:c,timestamp:a.timestamp??new Date().toISOString(),...d.fromHistory(a)}]),a.sleeping&&k(a=>new Set(a).add(b));else{let c=!!a.running;g(d=>d.some(a=>a.id===b)?d:[...d,{id:b,command:a.command??"",output:a.output??"",exitCode:a.exitCode,isRunning:c,timestamp:a.timestamp??new Date().toISOString(),cwd:a.cwd,usePty:a.usePty}]),c&&af(b,!!a.usePty)}F(a=>a&&!a.includes(b)?[...a,b]:a)},[af]),ah=(0,e.useCallback)(a=>{if("add"===a.op)a.entry&&ag(a.entry);else if("rerun"===a.op){let b=a.entry,c=b?.id;if(!b||!c)return;if(!S.current.some(a=>a.data.id===c))return void ag(b);let d=!!b.usePty;if(d){let a=Z.current.get(c);if(a)for(let b of a)b()}X(c,d),g(a=>a.map(a=>a.id===c?{...a,output:"",exitCode:void 0,isRunning:!0,pid:void 0}:a)),af(c,d)}else if("update"===a.op){let b=a.id,c=a.fields;if(!b||!c)return;void 0!==c.sleeping&&k(a=>{let d=new Set(a);return c.sleeping?d.add(b):d.delete(b),d}),(void 0!==c.exitCode||void 0!==c.running)&&g(a=>a.map(a=>a.id===b?{...a,...void 0!==c.exitCode?{exitCode:c.exitCode}:{},...void 0!==c.running?{isRunning:c.running}:{}}:a))}else if("delete"===a.op){let b=a.id;if(!b)return;g(a=>a.filter(a=>a.id!==b)),i(a=>a.filter(a=>a.id!==b)),F(a=>a?a.filter(a=>a!==b):a),k(a=>{if(!a.has(b))return a;let c=new Set(a);return c.delete(b),c}),X(b)}else"clear"===a.op?(g([]),i([]),F([]),k(new Set)):"reorder"===a.op&&Array.isArray(a.order)&&F(a.order)},[ag,af,X]);(0,q.h)({url:"/ws/global-state",enabled:!!a&&!!c,onMessage:b=>{"console-delta"!==b.type||b.cwd!==a||b.tabId!==c||b.sourceId&&b.sourceId===T.current||ah(b)}});let ai=(0,e.useCallback)(async b=>{let e,f=b.trim().split(/\s+/),h=f[0],i=b;C[h]&&(i=C[h]+(f.length>1?" "+f.slice(1).join(" "):""));let j=H(i);if(j)return void R.current?.(j.type,i.trim());let k=a8(),n=new Date().toISOString(),o=(e=i.trim().split(/\s+/)[0],bb.has(e)),p={id:k,command:i===a9?ba:b,output:i!==b&&i!==a9?`→ ${i}
747
- `:"",isRunning:!0,timestamp:n,cwd:l,...o?{usePty:!0}:{}};if(g(a=>a.some(a=>a.id===k)?a:[...a,p]),y(k),K.current.set(k,p.output),o&&L.current.add(k),setTimeout(ac,100),i.trim().startsWith("cd ")){let a=i.trim().substring(3).trim(),b=l;(0,a7.P)(a)?b=B.current?(0,a7.D)(a,B.current):l:a.startsWith("/")?b=a:".."===a?b=l.split("/").slice(0,-1).join("/")||"/":"."!==a&&(b=`${l}/${a}`.replace(/\/+/g,"/")),m(b),d?.(b),g(a=>a.map(a=>{if(a.id===k){let c={...a,output:`Changed directory to: ${b}`,exitCode:0,isRunning:!1};return ae(c),c}return a}));return}try{await aN({cwd:l,command:i,commandId:k,tabId:c||"",projectCwd:a,env:z,usePty:o,sourceId:T.current,onData:(a,b)=>{if("pid"===a)g(a=>a.map(a=>a.id===k?{...a,pid:b.pid,..."string"==typeof b.command?{command:b.command}:{}}:a));else if("stdout"===a||"stderr"===a)W(k,b.data);else if("exit"===a){let a=ab(k);X(k),g(c=>c.map(c=>c.id===k?{...c,output:a,exitCode:b.code,isRunning:!1,pid:void 0}:c))}},onError:a=>{let b=ab(k);X(k),g(c=>c.map(c=>c.id===k?{...c,output:b+`
748
- Error: ${a}`,exitCode:1,isRunning:!1,pid:void 0}:c))}})}catch(b){let a=ab(k);X(k),g(c=>c.map(c=>c.id===k?{...c,output:a+`
749
- Error: ${b.message}`,exitCode:1,isRunning:!1,pid:void 0}:c))}},[C,l,z,c,a,W,ab,X,ac,d,ae]),aj=(0,e.useCallback)(a=>{let b=f.find(b=>b.id===a);b?.isRunning&&b.pid&&aR(b.pid)},[f]),ak=(0,e.useCallback)(async b=>{let d=f.find(a=>a.id===b);if(!d)return;d.isRunning&&d.pid&&(aR(d.pid),await new Promise(a=>setTimeout(a,200)));let e=d.command.trim().split(/\s+/),h=e[0],i=d.usePty&&d.command===ba,j=i?a9:d.command;!i&&C[h]&&(j=C[h]+(e.length>1?" "+e.slice(1).join(" "):""));let k=d.usePty||!1;if(k){let a=Z.current.get(b);if(a)for(let b of a)b()}X(b,k);let m=j!==d.command?`→ ${j}
750
- `:"";k||K.current.set(b,m),k&&L.current.add(b),g(a=>a.map(a=>a.id===b?{...a,output:k?"":m,exitCode:void 0,isRunning:!0,pid:void 0}:a));let n=N.current.get(b);try{await aN({cwd:d.cwd||l,command:j,commandId:b,tabId:c||"",projectCwd:a,env:z,usePty:k,sourceId:T.current,...k&&n?{cols:n.cols,rows:n.rows}:{},onData:(a,c)=>{if("pid"===a)g(a=>a.map(a=>a.id===b?{...a,pid:c.pid,..."string"==typeof c.command?{command:c.command}:{}}:a));else if("stdout"===a||"stderr"===a)W(b,c.data);else if("exit"===a){let a=ab(b);X(b),g(d=>d.map(d=>d.id===b?{...d,output:a,exitCode:c.code,isRunning:!1,pid:void 0}:d))}},onError:a=>{let c=ab(b);X(b),g(d=>d.map(d=>d.id===b?{...d,output:c+`
751
- Error: ${a}`,exitCode:1,isRunning:!1,pid:void 0}:d))}})}catch(c){let a=ab(b);X(b),g(d=>d.map(d=>d.id===b?{...d,output:a+`
752
- Error: ${c.message}`,exitCode:1,isRunning:!1,pid:void 0}:d))}},[f,C,l,z,c,a,W,ab,X]),al=(0,e.useCallback)(async b=>{g(a=>a.filter(a=>a.id!==b)),X(b),c&&await r.t4.runPromise((0,u.SN)(a,c,b,T.current).pipe(x.sFT(a=>x.OH5(()=>console.error("Failed to delete command:",a))),x.NWQ(()=>x.rIH)))},[a,c,X]),am=(0,e.useCallback)((b,d,e)=>{var f;let g=G(b);if(!g)return;let h=g.parse(d);"cwd"in h&&!h.cwd&&(h.cwd=l);let j={id:(f=g.idPrefix,`${f}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),_type:b,timestamp:new Date().toISOString(),...h};if(i(a=>[...a,j]),y(j.id),setTimeout(ac,100),e){let b=E&&E.length>0?[...E]:S.current.map(a=>a.data.id),d=b.indexOf(e);-1!==d?b.splice(d+1,0,j.id):b.push(j.id),F(b),c&&r.t4.runFork((0,u.cm)(a,c,b,T.current).pipe(x.NWQ(()=>x.rIH)))}if(c){let d=g.toHistory(j);r.t4.runFork((0,u.AJ)(a,c,{type:b,id:j.id,timestamp:j.timestamp,...d},T.current).pipe(x.sFT(a=>x.OH5(()=>console.error(`Failed to save ${b} item:`,a))),x.NWQ(()=>x.rIH)))}},[ac,a,c,E]),an=(0,e.useCallback)(async b=>{let d=h.find(a=>a.id===b);if(i(a=>a.filter(a=>a.id!==b)),y(a=>a===b?null:a),k(a=>{let c=new Set(a);return c.delete(b),c}),d){let a=G(d._type);a?.onClose?.(d)}c&&r.t4.runFork((0,u.SN)(a,c,b,T.current).pipe(x.sFT(a=>x.OH5(()=>console.error("Failed to delete plugin item:",a))),x.NWQ(()=>x.rIH)))},[h,a,c]);R.current=am,Q.current=ai;let ao=(0,e.useCallback)((b,d)=>{c&&r.t4.runFork((0,u.bv)(a,c,b,{sleeping:d},T.current).pipe(x.NWQ(()=>x.rIH)))},[a,c]),ap=(0,e.useCallback)(a=>{k(b=>new Set(b).add(a)),ao(a,!0)},[ao]),aq=(0,e.useCallback)(a=>{k(b=>{let c=new Set(b);return c.delete(a),c}),ao(a,!1)},[ao]),ar=(0,e.useCallback)(async b=>{F(b),c&&await r.t4.runPromise((0,u.cm)(a,c,b,T.current).pipe(x.NWQ(()=>x.rIH)))},[a,c]),as=(0,e.useMemo)(()=>{let a=[...f.map(a=>({type:"command",data:a})),...h.map(a=>({type:a._type,data:a}))];if(!E||0===E.length)return a.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime());let b=new Map(E.map((a,b)=>[a,b])),c=[],d=[];for(let e of a)b.has(e.data.id)?c.push(e):d.push(e);return c.sort((a,c)=>b.get(a.data.id)-b.get(c.data.id)),d.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime()),[...c,...d]},[f,h,E]);return S.current=as,{commands:f,pluginItems:h,sleepingBubbles:j,consoleItems:as,currentCwd:l,selectedCommandId:w,setSelectedCommandId:y,customEnv:z,setCustomEnv:A,aliases:C,setAliases:D,isLoadingHistory:n,hasMoreHistory:p,currentPage:t,scrollRef:U,commandHistoryRef:M,ptySizeRef:N,executeCommandRef:Q,executeCommand:ai,interruptCommand:aj,rerunCommand:ak,deleteCommand:al,addPluginItem:am,closePluginItem:an,handleBubbleSleep:ap,handleBubbleWake:aq,loadHistory:ad,scrollToBottom:ac,saveBubbleOrder:ar,sendStdin:aP,resizePty:aQ,subscribePtyOutput:Y,subscribePtyReset:$,subscribePtyRefresh:aa}}({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:g}),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)(0),[W,X]=(0,e.useState)(0),[Y,Z]=(0,e.useState)(!0),[$,_]=(0,e.useState)(!1),[aa,ab]=(0,e.useState)(!1),[ac,ad]=(0,e.useState)(!1),[ae,af]=(0,e.useState)(!1),ag=(0,e.useRef)(null),ah=(0,e.useRef)(null),ai=(0,e.useRef)(null),aj=(0,e.useRef)(!1),ak=(0,e.useRef)(null),al=(0,e.useRef)(null),am=(0,e.useRef)([]),an=(0,e.useCallback)(()=>{let a=k.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[k]),ao=(0,e.useCallback)(()=>{let a=k.current;return!a||a.scrollTop<50},[k]),ap=(0,e.useCallback)(()=>{ad(!ao()),af(!an())},[an,ao]),aq=(0,e.useCallback)(()=>{ah.current?.scrollIntoView({behavior:"smooth"})},[]),ar=(0,e.useCallback)(()=>{aj.current=!0},[]),as=(0,e.useCallback)((a,b)=>{if(!aj.current)return void a.preventDefault();aj.current=!1,ak.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b),a.currentTarget.style.opacity="0.4";let c=a.currentTarget.querySelector("[data-drag-handle]");if(c){let b=c.cloneNode(!0);b.style.cssText="position:fixed;top:-9999px;left:-9999px;width:"+c.offsetWidth+"px;background:hsl(var(--card));color:hsl(var(--foreground));box-shadow:var(--elevation-2);border-radius:8px;padding:4px 12px;opacity:0.9;",document.body.appendChild(b),a.dataTransfer.setDragImage(b,20,16),requestAnimationFrame(()=>document.body.removeChild(b))}},[]),at=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",al.current=b},[]),au=(0,e.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.add("ring-2","ring-brand")},[]),av=(0,e.useCallback)(a=>{a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aw=(0,e.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.remove("ring-2","ring-brand")},[]),ax=(0,e.useCallback)(a=>{a.currentTarget.style.opacity="1";let b=ak.current,c=al.current;if(ak.current=null,al.current=null,!b||!c||b===c)return;let d=am.current.map(a=>a.data.id),e=d.indexOf(b),f=d.indexOf(c);if(-1===e||-1===f)return;let g=[...d];g[e]=c,g[f]=b,K(g)},[K]),ay=(0,e.useCallback)(a=>{T(b=>b===a?null:a)},[]),az=(0,e.useCallback)((a,b)=>y("browser",a,b),[y]),aA=W>0?Math.floor((W-32-12)/2-41):void 0;return(0,d.jsxs)("div",{ref:ag,className:"h-full flex flex-col bg-background relative",children:[(0,d.jsx)("div",{ref:k,onScroll:ap,className:`console-scroll-root flex-1 overflow-y-auto ${S?"":"py-4 px-4"}`,children:0===j.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-4 text-sm",children:[(0,d.jsx)("p",{className:"text-muted-foreground",children:i("console.emptyIntro")}),(0,d.jsx)("ul",{className:"flex flex-col gap-2",children:bc.map(a=>(0,d.jsxs)("li",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:"w-16 flex-shrink-0 text-foreground font-medium",children:i(a.label)}),(0,d.jsxs)("span",{className:"flex-1 flex flex-col gap-1",children:[(0,d.jsx)("span",{className:"flex flex-wrap gap-1",children:a.triggers.map(a=>(0,d.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-xs font-mono text-muted-foreground",children:a},a))}),a.notes?.map(a=>(0,d.jsx)("span",{className:"text-xs leading-snug text-muted-foreground/70",children:i(a)},a))]})]},a.key))}),(0,d.jsxs)("button",{type:"button",onClick:()=>w(a9),title:i("console.launchShell"),className:"self-start flex items-center gap-2 px-4 py-2 rounded-lg border border-input bg-background text-sm text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 transition-all",children:[(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,d.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),"New PTY"]})]})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{ref:ah}),L&&(0,d.jsx)("div",{className:"flex justify-center mb-4",children:(0,d.jsx)("button",{onClick:()=>M(N+1),disabled:O,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors disabled:opacity-50",children:O?i("console.loadingMore"):i("console.loadMoreHistory")})}),(0,d.jsx)("div",{className:S?"flex flex-col gap-3":Y?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:j.map(b=>(0,d.jsx)(aT,{item:b,selected:l===b.data.id,maximized:S===b.data.id,initialSleeping:A.has(b.data.id),tabId:c,projectCwd:a,expandedHeight:U,bubbleContentHeight:aA,onDragStart:as,onDragOver:at,onDragEnter:au,onDragLeave:av,onDrop:aw,onDragEnd:ax,onSelectId:m,onInterruptId:n,onStdin:o,onDeleteCommand:p,onRerun:s,subscribePtyOutput:P,subscribePtyReset:Q,subscribePtyRefresh:R,ptySizeRef:t,resizePty:v,onToggleMaximizeId:ay,onTitleMouseDown:ar,onClosePlugin:z,addBrowserItem:az,onSleep:B,onWake:C},b.data.id))}),(0,d.jsx)("div",{ref:ai})]})}),!S&&j.length>0&&(0,d.jsx)(a6,{showTop:ac,showBottom:ae,onScrollTop:aq,onScrollBottom:D}),(0,d.jsx)(a5,{cwd:a,currentCwd:E,commandHistoryRef:F,gridLayout:Y,onGridLayoutChange:b=>{Z(b),r.t4.runFork((0,u.Yn)({cwd:a,settings:{gridLayout:b}}).pipe(x.sFT(a=>x.OH5(()=>console.error("Failed to save project settings:",a))),x.NWQ(()=>x.rIH)))},onExecute:w,onAddPluginItem:y,onShowEnvManager:()=>_(!0),onOpenShell:()=>w(a9),onOpenNote:h}),$&&(0,d.jsx)(aW,{cwd:a,tabId:c,onClose:()=>_(!1),onSave:a=>I(a)}),aa&&(0,d.jsx)(aX.Y,{onClose:()=>ab(!1),onSave:a=>J(a)})]})})},85906:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectItem.tsx","ProjectItem")},85943:(a,b,c)=>{"use strict";function d(a){let b=0,c=0;for(let d of a)/[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\u{20000}-\u{2a6df}\uac00-\ud7af]/u.test(d)?b+=1:c+=1;return Math.max(1,Math.ceil(b+c/4))}c.d(b,{r:()=>d})},85984:(a,b,c)=>{"use strict";c.d(b,{V:()=>k});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=new Map,i=new Map;async function j(a,b,c=!1){let d=`${a}::${b}`;if(c)!function(a){if(!a){h.clear(),i.clear();return}let b=`${a}::`;for(let a of h.keys())a.startsWith(b)&&h.delete(a);for(let a of i.keys())a.startsWith(b)&&i.delete(a)}(a);else{let a=h.get(d);if(a)return a;let b=i.get(d);if(b)return b}let k=e.$mh({try:async()=>{let e=new URLSearchParams({cwd:a,path:b});c&&e.set("refresh","1");let f=await fetch(`/api/projectGraph/file-functions?${e}`);if(404===f.status)return"not-found";if(!f.ok)throw Error((await f.json().catch(()=>({error:`HTTP ${f.status}`}))).error||`HTTP ${f.status}`);let g=await f.json();return h.set(d,g),g},catch:a=>new g.uV({message:"fetchFileFunctions failed",cause:a})}),l=f.t4.runPromiseExit(k).then(a=>{if("Success"===a._tag)return a.value;let b="Fail"===a.cause._tag?a.cause.error:null,c=b?.cause;if(c instanceof Error)throw c;throw Error(b?.message??"fetchFileFunctions failed")}).finally(()=>i.delete(d));return i.set(d,l),l}function k(a,b){let[c,e]=(0,d.useState)({state:"idle"}),f=(0,d.useRef)(!0),g=(0,d.useCallback)((a,b,c)=>{e({state:"loading"}),j(a,b,c).then(a=>{f.current&&("not-found"===a?e({state:"notFound"}):e({state:"ready",data:a}))}).catch(a=>{f.current&&e({state:"error",message:a.message})})},[]);return{state:c,refresh:(0,d.useCallback)(()=>{a&&b&&g(a,b,!0)},[a,b,g])}}},86508:(a,b,c)=>{"use strict";c.d(b,{j:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(57063),h=c(44256),i=c(37701);function j({initialRows:a,lang:b,isCustomized:c,onSave:k,onRestoreDefault:l,onClose:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)(()=>(0,i.Ff)(a,b));(0,g.E)(m);let q=(0,e.useCallback)(()=>{k((0,i.Z8)(o)),m()},[o,k,m]),r=(0,e.useCallback)(()=>{l(),m()},[l,m]);return(0,d.jsx)(h.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onClick:m,children:(0,d.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 w-full max-w-md flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:n("quickReply.editTitle")}),(0,d.jsx)("button",{onClick:m,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors","aria-label":n("quickReply.cancel"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{className:"px-4 py-3 flex flex-col gap-2",children:[(0,d.jsx)("p",{className:"text-xs text-muted-foreground",children:n("quickReply.editHint")}),(0,d.jsx)("textarea",{autoFocus:!0,value:o,onChange:a=>p(a.target.value),placeholder:n("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs font-mono bg-background border border-border rounded text-foreground focus:outline-none focus:border-brand resize-y"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground",children:n("quickReply.customizedFor",{lang:n("zh"===b?"quickReply.langZh":"quickReply.langEn")})})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:r,disabled:!c,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:n("quickReply.restoreDefault")}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:m,className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-hover transition-colors",children:n("quickReply.cancel")}),(0,d.jsx)("button",{onClick:q,className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",children:n("quickReply.save")})]})]})]})})})}},86686:(a,b,c)=>{"use strict";c.d(b,{f:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(57063),h=c(15819),i=c(44256);function j({isOpen:a,onClose:b,cwd:c,sessionId:k,onSelectMessage:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(null),v=(0,e.useRef)(null),w=(0,e.useRef)(null);(0,g.E)(b,a);let x=(0,e.useMemo)(()=>{if(!n)return[];let a=n.map((a,b)=>({entry:a,ordinal:b+1})),b=r.trim().toLowerCase();return b?a.filter(a=>a.entry.content.toLowerCase().includes(b)):a},[n,r]);r.trim().length;let y=(0,e.useCallback)(async a=>{u(a.id);try{await l(a)}finally{u(null)}b()},[l,b]);if(!a)return null;let z=null===n,A=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:b,children:(0,d.jsxs)("div",{className:h.iG,onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:m("userMessages.title")}),n&&n.length>0&&(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:m("userMessages.count",{shown:x.length,total:n.length})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{ref:w,type:"text",autoFocus:!0,placeholder:m("userMessages.searchPlaceholder"),value:r,onChange:a=>s(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),r&&(0,d.jsx)("button",{onClick:()=>{s(""),w.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:m("fileBrowser.clear"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsx)("div",{ref:v,className:"flex-1 overflow-y-auto",children:z?(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:m("common.loading")}):p?(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:m("userMessages.loadFailed")}):0===n.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:m("userMessages.noMessages")}):0===x.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:m("userMessages.noResults")}):(0,d.jsx)("div",{className:"divide-y divide-border",children:x.map(({entry:a,ordinal:b})=>{let c,e=a.timestamp?function(a){let b=new Date(a);if(Number.isNaN(b.getTime()))return"";let c=new Date;return b.toDateString()===c.toDateString()?b.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):b.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}(a.timestamp):"";return(0,d.jsx)("button",{onClick:()=>{y(a)},className:"w-full px-4 py-3 text-left hover:bg-hover transition-colors","data-tooltip":(c=a.content.trim()).length>500?`${c.slice(0,500)}…`:c,children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[b,"."]}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"text-sm text-foreground truncate",children:a.content.replace(/\s+/g," ").trim()}),t===a.id&&(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:m("userMessages.jumping")})]}),e&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:e})]})},a.id)})})})]})});return(0,d.jsx)(i.ZL,{children:A})}c(33281),c(41224)},87808:(a,b,c)=>{"use strict";c.d(b,{DZ:()=>i,Ft:()=>m,Nn:()=>t,OJ:()=>q,VK:()=>u,YW:()=>l,__:()=>s,dt:()=>r,eA:()=>p,eE:()=>n,gZ:()=>j,mP:()=>h,nM:()=>v,r6:()=>o,r9:()=>k});var d=c(79606),e=c(71192);let f=(a,b={})=>d.$mh({try:async()=>{let c=await fetch(a,b.init);if(b.passThroughStatuses&&b.passThroughStatuses.includes(c.status))return await c.json().catch(()=>({}));if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),g=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),h=a=>f(`/api/files/init?cwd=${encodeURIComponent(a)}`),i=a=>f(`/api/files/index?cwd=${encodeURIComponent(a)}`),j=(a,b)=>f(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),k=a=>f(`/api/files/recent?cwd=${encodeURIComponent(a)}`),l=(a,b,c)=>g("/api/files/recent",{cwd:a,file:b,...c??{}}),m=(a,b)=>g("/api/files/expanded",{cwd:a,paths:b}),n=(a,b)=>f(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`).pipe(d.h9N(a=>d.PyW({error:a.message}))),o=(a,b)=>{let c,f;return c=`/api/files/stat?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,f={cache:"no-store"},d.$mh({try:async()=>{let a=await fetch(c,f),b=null;try{b=await a.json()}catch{}return{status:a.status,ok:a.ok,data:b}},catch:a=>new e.uV({message:`GET ${c} failed`,cause:a})})},p=a=>f(`/api/files/text?${a.toString()}`),q=a=>d.$mh({try:async()=>{let b=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=null;try{c=await b.json()}catch{}return{status:b.status,ok:b.ok,data:c}},catch:a=>new e.uV({message:"POST /api/files/save failed",cause:a})}),r=()=>f("/api/files/clipboard"),s=a=>d.$mh({try:async()=>{let b=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"POST /api/files/clipboard failed",cause:a})}),t=a=>d.$mh({try:async()=>{let b=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/paste failed",cause:a})}),u=a=>d.$mh({try:async()=>{let b=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/delete failed",cause:a})}),v=a=>f(`/api/file?path=${encodeURIComponent(a)}`)},87819:(a,b,c)=>{"use strict";c.d(b,{Z:()=>e});var d=c(67484);function e(a,b){let[c,e]=(0,d.useState)({status:"loading"});return c}c(13426),c(79883),c(1239),c(79606),c(95046),c(33281)},88018:(a,b,c)=>{"use strict";c.d(b,{K:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({label:a,labelClassName:b,src:c,node:h,alt:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col items-center gap-2",children:[(0,d.jsx)("div",{className:`text-xs font-medium ${b}`,children:a}),(0,d.jsx)("div",{className:"w-full flex-1 flex items-center justify-center rounded border border-border bg-secondary p-3 min-h-[8rem]",children:h?(0,d.jsx)("div",{className:"w-full min-w-0",children:h}):k?(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:j("diffViewer.imageLoadFailed")}):(0,d.jsx)("img",{src:c,alt:i,onError:()=>l(!0),className:"max-w-full max-h-[60vh] object-contain"})})]})}function h({filePath:a,oldSrc:b,newSrc:c,oldNode:e,newNode:i}){let{t:j}=(0,f.Bd)(),k=!!e||!!b,l=!!i||!!c;return(0,d.jsxs)("div",{className:"h-full overflow-auto p-4",children:[(0,d.jsx)("div",{className:"text-xs font-mono text-muted-foreground mb-3 truncate",children:a}),k||l?(0,d.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[k&&(0,d.jsx)(g,{label:j(l?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:b,node:e,alt:`${a} (before)`}),l&&(0,d.jsx)(g,{label:j(k?"diffViewer.imageAfter":"diffViewer.imageAdded"),labelClassName:"text-green-11",src:c,node:i,alt:`${a} (after)`})]}):(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:j("diffViewer.imageUnavailable")})]})}},88214:(a,b,c)=>{"use strict";c.d(b,{n:()=>e});var d=c(23734);let e={SessionChange:(0,d.R)("session-change"),ViewChange:(0,d.R)("view-change"),OpenNote:(0,d.R)("open-note"),LangChange:(0,d.R)("lang-change"),TabAdd:(0,d.R)("tab-add"),TabClose:(0,d.R)("tab-close"),SwitchSession:(0,d.R)("switch-session"),ProjectChange:(0,d.R)("project-change"),OpenProject:(0,d.R)("open-project"),SessionComplete:(0,d.R)("session-complete"),OpenTokenStats:(0,d.R)("open-token-stats"),PinnedSessionsChanged:(0,d.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,d.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,d.R)("screenshot-prepare"),ScreenshotDone:(0,d.R)("screenshot-done")}},89719:(a,b,c)=>{"use strict";function d(a,b){let c,d=document.caretRangeFromPoint(a.clientX,a.clientY);if(!d||!b.contains(d.startContainer))return 1;let e=d.startContainer,f=d.startOffset,g=document.createTreeWalker(b,NodeFilter.SHOW_TEXT),h=1;for(;c=g.nextNode();){if(c===e){h+=f;break}h+=c.textContent?.length||0}return h}function e(a,b){if(0!==a.buttons)return null;let c=window.getSelection();if(c&&!c.isCollapsed)return null;let e=a.target;if("SPAN"!==e.tagName||!e.style.color)return null;let f=e.getBoundingClientRect();return{column:d(a,b),rect:{x:f.left,y:f.bottom+4}}}c.d(b,{A:()=>e,j:()=>d})},89800:(a,b,c)=>{"use strict";c.d(b,{$:()=>i,BC:()=>j,Tu:()=>l,lb:()=>h,tj:()=>m,vv:()=>k});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>f(`/api/comments?cwd=${encodeURIComponent(a)}${b?`&filePath=${encodeURIComponent(b)}`:""}`),i=a=>f(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`),j=a=>f("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),k=(a,b,c)=>f("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,id:b,content:c})}),l=(a,b)=>g(`/api/comments?cwd=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"}),m=a=>g(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`,{method:"DELETE"})},90031:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{s:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(19593),k=c(55287),l=a([k]);function m({filePath:a,content:b,onClose:c,zClassName:d="z-50"}){let{t:l}=(0,g.Bd)(),[n,o]=(0,f.useState)("table");return(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:`fixed inset-0 ${d} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:c,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.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"},"data-tooltip":a,onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(l("common.copiedPath"))},children:["‎",a]}),(0,e.jsx)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5 flex-shrink-0",children:["table","raw"].map(a=>(0,e.jsx)("button",{onClick:()=>o(a),className:`px-2 py-0.5 text-xs rounded transition-colors ${n===a?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:l(`csv.${a}`)},a))}),(0,e.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:"table"===n?(0,e.jsx)(j.C0,{content:b,filePath:a,className:"h-full"}):(0,e.jsx)(k.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}k=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},91579:(a,b,c)=>{"use strict";c.d(b,{$3:()=>l,Cm:()=>k,Ff:()=>p,Gw:()=>o,RP:()=>m,Un:()=>n,zL:()=>j});var d=c(208),e=c(79606),f=c(33281),g=c(71192),h=c(89800);let i=new Set;function j(a){return i.add(a),()=>i.delete(a)}function k(){i.forEach(a=>a())}async function l(a){let b=await f.t4.runPromiseExit((0,h.lb)(a));if("Success"!==b._tag)throw Error("Failed to fetch comments");let c=b.value.comments??[];if(0===c.length)return[];let d=new Map;for(let a of c)a.selectedText||(d.has(a.filePath)||d.set(a.filePath,[]),d.get(a.filePath).push(a));let i=new Map;await Promise.all(Array.from(d.keys()).map(async b=>{let c=await f.t4.runPromiseExit(e.$mh({try:async()=>{let c=await fetch(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`);return c.ok?await c.json():null},catch:a=>new g.uV({message:`read file text ${b} failed`,cause:a})}));"Success"===c._tag&&c.value&&"string"==typeof c.value.content?i.set(b,c.value.content.split("\n")):"Failure"===c._tag&&console.error(`Failed to read file ${b}:`,c.cause)}));let j=[];for(let a of c){if(a.selectedText){j.push({...a,codeContent:a.selectedText});continue}let b=i.get(a.filePath),c="";if(b){let d=Math.max(0,a.startLine-1),e=Math.min(b.length,a.endLine);c=b.slice(d,e).join("\n")}j.push({...a,codeContent:c})}return j}async function m(a){let b=await f.t4.runPromiseExit((0,h.tj)(a));return"Success"===b._tag?(k(),!0):(console.error("Failed to clear comments:",b.cause),!1)}let n="__chat__";function o(a,b){let c=a.filter(a=>a.filePath===n),e=a.filter(a=>a.filePath!==n),f=[];for(let a of(e.length>0&&(f.push(`${d.A.t("comments.codeRef")}`,""),e.forEach((a,b)=>{let c=a.startLine>0||a.endLine>0?`:${a.startLine}-${a.endLine}`:"";f.push(`[${b+1}] ${a.filePath}${c}`),f.push("```"),f.push(a.codeContent),f.push("```"),a.note&&f.push(d.A.t("comments.note",{content:a.note})),f.push("")})),c)){let b=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");f.push(b),a.note&&f.push(a.note),f.push("")}if(b.trim()){for(;f.length>0&&""===f[f.length-1];)f.pop();f.push(b.trim())}return f.join("\n").trim()}function p(a,b,c){a(o([b],c))}},91975:(a,b,c)=>{"use strict";c.d(b,{t:()=>h});var d=c(48249),e=c(67484),f=c(36043);let g=96/72;function h({cwd:a,path:b,refreshKey:c}){let k=(0,e.useRef)(null),[l,m]=(0,e.useState)({kind:"loading"}),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(0),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(0),[v,w]=(0,e.useState)({kind:"auto"}),[x,y]=(0,e.useState)(1),[z,A]=(0,e.useState)(!0),B=(0,e.useMemo)(()=>r?.length?Math.max(...r.map(a=>a.w)):0,[r]),C=Math.min(B>0&&t>0?t/B:g,g),D="auto"===v.kind?C:v.factor*g,E=Math.round(D/g*100),F=(0,e.useMemo)(()=>r?r.map(a=>a.h*D+16):[],[r,D]),G=B*D,H=(0,e.useRef)(1);H.current=C/g;let I=(0,e.useRef)(F);I.current=F;let J=(0,f.Te)({count:p,getScrollElement:()=>k.current,estimateSize:a=>I.current[a]??0,overscan:2}),K=(0,e.useCallback)(()=>{let a=k.current;if(!a||0===p)return;let b=a.scrollTop,c=J.getVirtualItems().find(a=>a.end>b);y((c?c.index:p-1)+1)},[J,p]),L=(0,e.useCallback)(a=>{w(b=>({kind:"fixed",factor:Math.min(4,Math.max(.25,("auto"===b.kind?H.current:b.factor)*a))}))},[]),M=(0,e.useCallback)(()=>L(1.2),[L]),N=(0,e.useCallback)(()=>L(.8333333333333334),[L]),O=(0,e.useCallback)(()=>w({kind:"auto"}),[]),P=(0,e.useCallback)(()=>A(a=>!a),[]),Q=(0,e.useCallback)(a=>{J.scrollToIndex(a,{align:"start"}),y(a+1)},[J]),R=J.getVirtualItems(),S=J.getTotalSize(),T=(0,e.useMemo)(()=>(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border text-muted-foreground text-xs select-none",children:[(0,d.jsx)("button",{onClick:P,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors ${z?"text-foreground":""}`,title:z?"Hide thumbnails":"Show thumbnails","aria-label":"Toggle thumbnails",children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),(0,d.jsx)("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),(0,d.jsx)("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),(0,d.jsx)("span",{className:"tabular-nums",children:p>0?`${x} / ${p}`:"—"}),(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:N,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom out","aria-label":"Zoom out",children:"−"}),(0,d.jsxs)("button",{onClick:O,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors tabular-nums min-w-[3.5rem] ${"auto"===v.kind?"":"text-foreground"}`,title:"Reset to automatic zoom",children:[E,"%"]}),(0,d.jsx)("button",{onClick:M,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom in","aria-label":"Zoom in",children:"+"})]})]}),[p,x,E,v.kind,M,N,O,z,P]);return"error"===l.kind?(0,d.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[T,(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,d.jsx)("div",{className:"text-sm text-red-11",children:l.message})})]}):(0,d.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[T,(0,d.jsxs)("div",{className:"flex-1 flex min-h-0",children:[z&&n&&r&&(0,d.jsx)(i,{doc:n,numPages:p,sizes:r,maxPageW:B,currentPage:x,onSelect:Q}),(0,d.jsx)("div",{ref:k,onScroll:K,className:"flex-1 overflow-auto px-4 py-4",children:"loading"!==l.kind&&n&&r&&!(G<=0)?(0,d.jsx)("div",{style:{height:S,width:Math.max(G,t),position:"relative"},children:R.map(a=>(0,d.jsx)("div",{"data-index":a.index,className:"absolute left-0 top-0 w-full flex justify-center",style:{transform:`translateY(${a.start}px)`,paddingBottom:16},children:(0,d.jsx)(j,{doc:n,pageNumber:a.index+1,scale:D,width:r[a.index].w*D,height:r[a.index].h*D})},a.key))}):(0,d.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})})})]})]})}function i({doc:a,numPages:b,sizes:c,maxPageW:g,currentPage:h,onSelect:k}){let l=(0,e.useRef)(null),m=g>0?100/g:0,n=(0,e.useMemo)(()=>c.map(a=>a.h*m+18+12),[c,m]),o=(0,e.useRef)(n);o.current=n;let p=(0,f.Te)({count:b,getScrollElement:()=>l.current,estimateSize:a=>o.current[a]??0,overscan:3}),q=p.getVirtualItems();return(0,d.jsx)("div",{ref:l,className:"shrink-0 overflow-auto border-r border-border py-2",style:{width:132},children:(0,d.jsx)("div",{style:{height:p.getTotalSize(),width:"100%",position:"relative"},children:q.map(b=>{let e=h===b.index+1;return(0,d.jsxs)("div",{className:"absolute left-0 top-0 w-full flex flex-col items-center",style:{transform:`translateY(${b.start}px)`,paddingBottom:12},children:[(0,d.jsx)("button",{onClick:()=>k(b.index),className:`rounded-sm overflow-hidden transition-shadow ${e?"ring-2 ring-brand":"ring-1 ring-border hover:ring-muted-foreground"}`,title:`Page ${b.index+1}`,"aria-label":`Go to page ${b.index+1}`,children:(0,d.jsx)(j,{doc:a,pageNumber:b.index+1,scale:m,width:c[b.index].w*m,height:c[b.index].h*m})}),(0,d.jsx)("span",{className:`mt-0.5 text-[11px] tabular-nums leading-none ${e?"text-foreground font-medium":"text-muted-foreground"}`,style:{height:18},children:b.index+1})]},b.key)})})})}function j({doc:a,pageNumber:b,scale:c,width:f,height:g}){let h=(0,e.useRef)(null);return(0,d.jsx)("div",{className:"bg-white shadow-lv2",style:{width:f,height:g},children:(0,d.jsx)("canvas",{ref:h,className:"block"})})}},92451:(a,b,c)=>{"use strict";c.d(b,{U:()=>g});var d=c(48249),e=c(67484),f=c(19545);function g({editor:a,query:b,position:c,onClose:h}){let[i,j]=(0,e.useState)(0),k=(0,e.useRef)(null),l=(0,f.Qe)().filter(a=>a.label.toLowerCase().includes(b.toLowerCase())||a.description.toLowerCase().includes(b.toLowerCase()));return 0===l.length?null:(0,d.jsx)("div",{ref:k,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lv2 py-1 w-56 max-h-64 overflow-y-auto",style:{top:c.top,left:c.left},children:l.map((c,e)=>(0,d.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${e===i?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover hover:text-foreground"}`,onClick:()=>{a.chain().focus().deleteRange({from:a.state.selection.from-b.length-1,to:a.state.selection.from}).run(),c.action(a),h()},onMouseEnter:()=>j(e),children:[(0,d.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:c.icon}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-medium",children:c.label}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:c.description})]})]},c.label))})}},92608:(a,b,c)=>{"use strict";c.d(b,{ShareReviewToggle:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(7833),h=c(33281),i=c(83120);function j({content:a,sourceFile:b}){let c,k,l,m,n,{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(!0),[t,u]=(0,e.useState)(!1),v=p?.active===!0,w=(0,e.useCallback)(async()=>{u(!0);let c=b.split("/").pop()||b,d=await h.t4.runPromiseExit((0,i.bx)({title:c,content:a,sourceFile:b}));if("Success"!==d._tag||!d.value.review){(0,g.oR)(o("toast.reviewCreateFailed"),"error"),u(!1);return}let e=d.value.review;q({id:e.id,active:!0,updatedAt:e.updatedAt||e.createdAt});let f=await h.t4.runPromiseExit((0,i._c)()),j="Success"===f._tag&&f.value.shareBase?`${f.value.shareBase}/review/${e.id}`:`${window.location.origin}/review/${e.id}`;try{await navigator.clipboard.writeText(j)}catch{}(0,g.oR)(e.existing?o("toast.reviewUpdated"):o("toast.reviewCreated"),"success"),u(!1)},[a,b,o]),x=(0,e.useCallback)(async()=>{p&&(u(!0),"Success"===(await h.t4.runPromiseExit((0,i.Gm)(p.id,{active:!1})))._tag?(q(a=>a?{...a,active:!1}:null),(0,g.oR)(o("toast.sharingClosed"),"success")):(0,g.oR)(o("toast.sharingCloseFailed"),"error"),u(!1))},[p,o]),y=(0,e.useCallback)(()=>{t||(v?x():w())},[t,v,w,x]),z=(0,e.useCallback)(()=>{p&&window.open(`${window.location.origin}/review/${p.id}`,"_blank")},[p]);return r?null:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:y,disabled:t,className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${t?"opacity-50 cursor-wait":"cursor-pointer"} ${v?"bg-green-500":"bg-muted-foreground/30"}`,title:v?o("review.closeSharing"):o("review.enableSharing"),children:(0,d.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white transition-transform ${v?"translate-x-3.5":"translate-x-0.5"}`})}),(0,d.jsx)("span",{className:`text-[11px] ${v?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,children:v?o("review.sharing"):o("review.notShared")}),v&&p&&p.updatedAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(k=String((c=new Date(p.updatedAt)).getMonth()+1).padStart(2,"0"),l=String(c.getDate()).padStart(2,"0"),m=String(c.getHours()).padStart(2,"0"),n=String(c.getMinutes()).padStart(2,"0"),`${k}-${l} ${m}:${n}`)}),(0,d.jsx)("button",{onClick:z,className:"text-[11px] text-brand hover:underline",children:o("review.view")})]})]})}},92701:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(81206),k=c(23700),l=a([k]);function m(a){return a?a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a):"0"}function n(a){if(!a)return"–";let b=Math.round(a/1e3);if(b<60)return`${b}s`;let c=Math.floor(b/60);return`${c}m${b%60}s`}k=(l.then?(await l)():l)[0];let q={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function o({cwd:a,sessionId:b,runId:c,isRunning:d,onClose:l}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useRef)(void 0),y=d||null!=r&&"completed"!==r.status&&"failed"!==r.status;(0,f.useCallback)(async()=>{let d=await i.t4.runPromiseExit((0,j.z)({cwd:a,sessionId:b,workflowId:c,ifFingerprint:x.current}));if(u(!0),"Success"!==d._tag||!d.value)return;let e=d.value;e.fingerprint&&(x.current=e.fingerprint),!e.notModified&&e.workflow&&s(e.workflow)},[a,b,c]);let z=[];if(r?.agents){let a=new Map;for(let b of r.agents){let c=b.phaseTitle||q("chat.workflowUngrouped");a.has(c)||a.set(c,[]),a.get(c).push(b)}for(let[b,c]of a)z.push({title:b,agents:c})}let A=r?[r.workflowName,r.status,`${r.agentCount??r.agents?.length??0} ${q("chat.workflowAgents")}`,`${m(r.totalTokens)} tok`,n(r.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,e.jsxs)(h.ZL,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:l,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:q("chat.workflowRun")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:q("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===r?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:q(t?"chat.workflowEmpty":"common.loading")}):(0,e.jsxs)(e.Fragment,{children:[r.summary&&(0,e.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:r.summary}),z.map(a=>(0,e.jsxs)(f.Fragment,{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:a.title}),a.agents.map(a=>(0,e.jsx)(p,{agent:a,onOpen:()=>a.agentId&&w({runId:c,agentId:a.agentId,label:a.label,running:"done"!==a.state&&y})},`${a.index}-${a.agentId}`))]},a.title))]})})]})}),v&&(0,e.jsx)(k.f,{cwd:a,sessionId:b,workflowRef:v,onClose:()=>w(null)})]})}function p({agent:a,onOpen:b}){let{t:c}=(0,g.Bd)(),[d,h]=(0,f.useState)(!1),i=a.state&&q[a.state]||"text-muted-foreground",j=a.resultPreview||a.promptPreview||"";return(0,e.jsxs)("div",{className:"border border-border rounded-md mb-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,e.jsx)("button",{onClick:()=>h(a=>!a),className:"text-foreground-subtle text-xs flex-shrink-0",title:c(d?"chat.collapse":"chat.expand"),children:d?"▲":"▼"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0","data-tooltip":a.label||"",children:a.label||a.agentId}),(0,e.jsx)("span",{className:`text-[10px] flex-shrink-0 ${i}`,children:a.state}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[m(a.tokens)," tok \xb7 ",n(a.durationMs)]}),a.agentId&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:b,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&b()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:c("chat.subagentViewTitle"),children:c("chat.workflowViewAgent")})]}),d&&j&&(0,e.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:j})]})}d()}catch(a){d(a)}})},93448:(a,b,c)=>{"use strict";c.d(b,{TabManagerTopBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManagerTopBar() from the server but TabManagerTopBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabManagerTopBar.tsx","TabManagerTopBar")},93780:(a,b,c)=>{"use strict";c.d(b,{I$:()=>g,hC:()=>f,v2:()=>h});var d=c(67484),e=c(25414);function f(){let a=new Map,b=new Set,c=()=>b.forEach(a=>a());return{applyEvent(b){let d=b.tool_use_id;if(!d||b.ambient)return;let f=(0,e.Uy)(a.get(d),b);a.set(d,f),c()},getTask:b=>a.get(b),settleRunning(){let b=!1;for(let[c,d]of a)"running"===d.status&&(a.set(c,{...d,status:"unknown"}),b=!0);b&&c()},subscribe:a=>(b.add(a),()=>b.delete(a))}}let g=(0,d.createContext)({applyEvent:()=>{},getTask:()=>void 0,settleRunning:()=>{},subscribe:()=>()=>{}});function h(a){let b=(0,d.useContext)(g),c=(0,d.useCallback)(()=>a?b.getTask(a):void 0,[b,a]);return(0,d.useSyncExternalStore)(b.subscribe,c,c)}},94192:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[k,l]=(0,e.useState)(!1);f.indexOf(a),f.length;let[m,n]=(0,e.useState)(!1),o={activeView:a,onViewChange:b,dragOffset:(()=>{if(!m)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:m&&k};return(0,d.jsx)(h.Provider,{value:o,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=f.indexOf(g),o=f.length;return(0,d.jsx)("div",{ref:l,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:m,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/o*100,c=-(100/o*n)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},94239:(a,b,c)=>{"use strict";c.d(b,{c:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(61591),h=c(44256);function i({path:a,matchedIndices:b}){let c=(0,e.useMemo)(()=>new Set(b),[b]),f=a.lastIndexOf("/"),g=f>=0?a.slice(0,f+1):"",h=f>=0?a.slice(f+1):a,j=(a,b,e)=>{let f=[],g="",h=!1;for(let e=0;e<a.length;e++){let i=b+e,j=c.has(i);j!==h&&g&&(f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${e}`):(0,d.jsx)("span",{children:g},`${b}-${e}`)),g=""),h=j,g+=a[e]}return g&&f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,d.jsx)("span",{children:g},`${b}-end`)),(0,d.jsx)("span",{className:e,children:f})};return(0,d.jsxs)("span",{className:"truncate",children:[g&&j(g,0,"text-muted-foreground"),j(h,g.length,"text-foreground")]})}function j({files:a,fileIndex:b,recentFiles:c,onSelectFile:k,onClose:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(0),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),u=(0,e.useMemo)(()=>{if(!n.trim()){let a=new Set(c);return[...c.map(a=>({path:a,score:0,matchedIndices:[]})),...t.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}))]}let a=[];for(let b of t){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)c[i]===d[f]&&(e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10),i>a.lastIndexOf("/")&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++);return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,n.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[n,t,c]),v=(0,e.useCallback)(a=>{o(a),q(0)},[]),w=(0,e.useCallback)(a=>{k(a),l()},[k,l]),x=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),q(a=>Math.min(a+1,u.length-1));break;case"ArrowUp":a.preventDefault(),q(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),u[p]&&w(u[p].path);break;case"Escape":a.preventDefault(),l()}},[u,p,w,l]);return(0,d.jsx)(h.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:l,children:(0,d.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-lv3 overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,d.jsx)("input",{ref:r,value:n,onChange:a=>v(a.target.value),onKeyDown:x,placeholder:m("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,d.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,d.jsx)("div",{ref:s,className:"flex-1 overflow-y-auto py-1",children:0===u.length?(0,d.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:m("quickFileOpen.noMatch")}):u.map((a,b)=>(0,d.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===p?"bg-brand/15 text-foreground":"hover:bg-hover text-foreground"}`,"data-tooltip":a.path,onClick:()=>w(a.path),children:[(0,d.jsx)(g.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)(i,{path:a.path,matchedIndices:a.matchedIndices}),!n.trim()&&c.includes(a.path)&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:m("quickFileOpen.recent")})]},a.path))}),(0,d.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",m("quickFileOpen.selectHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",m("quickFileOpen.openHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",m("quickFileOpen.closeHint")]})]})]})})})}},94308:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:h,pinnedBranches:i=[]}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=m.toLowerCase(),r=new Set([...a?.local||[],...a?.remote||[]]),s=i.filter(a=>r.has(a)&&a.toLowerCase().includes(q)),t=new Set(s),u=a?.local.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],v=a?.remote.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],w=a=>{c(a),l(!1),n("")};return(0,d.jsxs)("div",{className:"relative",ref:o,children:[(0,d.jsxs)("button",{onClick:()=>l(!k),disabled:h,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||j("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",j("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-foreground-subtle transition-transform ${k?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),k&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lv2 max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:p,type:"text",value:m,onChange:a=>n(a.target.value),placeholder:j("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length>0&&s.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${c}`)),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:j("git.localBranches")}),u.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),v.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:j("git.remoteBranches")}),v.map(a=>(0,d.jsxs)("div",{onClick:()=>w(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===s.length&&0===u.length&&0===v.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:j("git.noMatchingBranches")})]})]})]})}},95401:(a,b,c)=>{"use strict";c.d(b,{m:()=>k});var d=c(48249),e=c(67484),f=c(44256),g=c(33281),h=c(63565),i=c(41224);function j(a){return"env"===a?"from env var":"default"===a?"default":null}function k({currentModel:a,onModelChange:b}){let[c,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)("default"),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(""),[I,J]=(0,e.useState)("default"),[K,L]=(0,e.useState)(""),[M,N]=(0,e.useState)(!1),O=(0,e.useRef)(null),P=(0,e.useRef)(null),Q=(0,e.useRef)(null),[R,S]=(0,e.useState)({top:0,left:0}),T=(0,f.F2)(),U=(0,e.useCallback)(async()=>{p(!0),r(null);let a=await g.t4.runPromiseExit((0,i.qD)(()=>t(!0)));if(t(!1),"Failure"===a._tag)r("Connection error");else{let b=a.value;switch(b._tag){case"ok":n(b.models);break;case"not-installed":case"error":r(b.message);break;case"not-running":r("Ollama is not running")}}p(!1)},[]),V=(0,e.useCallback)(a=>{B(a.baseUrl),D(a.baseUrlSource),F(a.hasKey),H(a.maskedKey),J(a.keySource),L(""),N(!1)},[]),W=(0,e.useCallback)(async()=>{v(!0),z(null);let a=await g.t4.runPromiseExit((0,i.F4)());"Failure"===a._tag?z("Failed to load config"):V(a.value),v(!1)},[V]),X=async()=>{x(!0),z(null);let a=await g.t4.runPromiseExit((0,i.yS)({baseUrl:A}));"Failure"===a._tag?z("Save failed"):(V(a.value),await U()),x(!1)},Y=async()=>{let a=K.trim();if(!a)return;x(!0),z(null);let b=await g.t4.runPromiseExit((0,i.yS)({apiKey:a}));"Failure"===b._tag?z("Save failed"):V(b.value),x(!1)},Z=async()=>{x(!0),z(null);let a=await g.t4.runPromiseExit((0,i.yS)({apiKey:""}));"Failure"===a._tag?z("Clear failed"):V(a.value),x(!1)},$=a?a.replace(/:latest$/,""):"Select model",_=j(C),aa=j(I),ab=c?(0,d.jsx)(f.ZL,{children:(0,d.jsxs)("div",{ref:P,className:`${h.ys} min-w-[300px]`,style:{top:R.top,left:R.left},children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Server URL"}),_&&!u&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:_})]}),u?(0,d.jsxs)("div",{className:"flex items-center gap-2 py-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:A,onChange:a=>B(a.target.value),onKeyDown:a=>{"Enter"===a.key&&X()},placeholder:"http://127.0.0.1:11434",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${h.Fx}`}),(0,d.jsx)("button",{onClick:X,disabled:w,className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${h.$T}`,children:w?"...":"Save"})]})]}),(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),aa&&E&&!u&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:aa})]}),u?null:E&&!M?(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:G}),(0,d.jsx)("button",{onClick:()=>{N(!0),L(""),setTimeout(()=>Q.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:w,children:"Edit"}),(0,d.jsx)("button",{onClick:Z,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:w,children:"Clear"})]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:Q,type:"password",value:K,onChange:a=>L(a.target.value),onKeyDown:a=>{"Enter"===a.key&&Y()},placeholder:"optional — for authenticated servers",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${h.Fx}`}),(0,d.jsx)("button",{onClick:Y,disabled:w||!K.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${h.$T}`,children:w?"...":"Save"}),E&&(0,d.jsx)("button",{onClick:()=>{N(!1),L("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),y&&(0,d.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:y})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"}),(0,d.jsx)("div",{className:"px-3 pt-1 pb-0.5",children:(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Model"})}),(0,d.jsx)("div",{className:"max-h-[240px] overflow-y-auto",children:o||s?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),s?"Starting Ollama...":"Loading models..."]}):q?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-red-11",children:q}):0===m.length?(0,d.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,d.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):m.map(c=>{var e;let f=c.name===a;return(0,d.jsxs)("button",{onClick:()=>{b(c.name),l(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors ${f?h.yI:"text-foreground hover:bg-hover"}`,children:[(0,d.jsx)(h.hG,{selected:f}),(0,d.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,d.jsx)("span",{className:"ml-auto pl-2 text-muted-foreground flex-shrink-0",children:c.parameter_size||((e=c.size)<1e9?`${(e/1e6).toFixed(0)}M`:`${(e/1e9).toFixed(1)}G`)})]},c.name)})})]})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h.XY,{buttonRef:O,label:$,title:"Configure Ollama",onClick:()=>{if(!c){if(O.current){let a=O.current.getBoundingClientRect(),b=T?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;S({top:a.bottom+4-d,left:a.left-c})}W(),U()}l(a=>!a)},icon:(0,d.jsx)(h.eV,{engine:"ollama"}),testId:"ollama-config-picker"}),ab]})}},97572:(a,b,c)=>{"use strict";c.d(b,{g:()=>g,v:()=>f});var d=c(79606),e=c(71192);let f=d.$mh({try:async()=>{let a=await fetch("/api/projects");if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>new e.uV({message:"fetch /api/projects failed",cause:a})}),g=a=>d.$mh({try:async()=>{let b=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"save /api/projects failed",cause:a})})},97951:(a,b,c)=>{"use strict";c.d(b,{R:()=>j,e:()=>k});var d=c(67484),e=c(85943),f=c(25414),g=c(30905),h=c(208),i=c(29939);let j=[];function k(a,b,{sessionId:c,cwd:l,engine:m,planMode:n,noHistory:o,ollamaModel:p,engineModel:q,claudeModel:r,claudeEffort:s,claudeContextWindow:t,claudeFastMode:u,claudeThinking:v,codexModel:w,codexReasoningEffort:x,onSessionId:y,onFetchTitle:z,onRunComplete:A,taskStore:B}){let[C,D]=(0,d.useState)(!1),[E,F]=(0,d.useState)(null),[G,H]=(0,d.useState)(null),[I,J]=(0,d.useState)(null),[K,L]=(0,d.useState)(null),[M,N]=(0,d.useState)(null),[O,P]=(0,d.useState)(j),Q=(0,d.useRef)(null),[R,S]=(0,d.useState)(null),T=(0,d.useRef)(R);T.current=R;let U=(0,d.useRef)(!1),V=(0,d.useRef)(A);V.current=A;let W=(0,d.useRef)(B);W.current=B;let X=(0,d.useRef)(!1),Y=(0,d.useRef)(null),Z=(0,d.useRef)(c);Z.current=c;let $=(0,d.useRef)(null),_=(0,d.useRef)(null),aa=(0,d.useRef)(null),ab=(0,d.useRef)(!1),ac=(0,d.useRef)(!1),ad=(0,d.useRef)(0),ae=(0,d.useCallback)(()=>{let a=$.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>(0,f.FM)(a,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:d}}},{engine:m,assistantId:c})),$.current={messageId:c,text:""}}_.current=null},[b,m]),af=(0,d.useCallback)(()=>{_.current&&(clearTimeout(_.current),_.current=null),Y.current&&(clearTimeout(Y.current),Y.current=null),ae(),b(f.fD),W.current?.settleRunning(),D(!1),H(null),J(null),P(j);let a=T.current,c=aa.current;a&&b(b=>b.map(b=>b.id===a.assistantId||b.id===c?{...b,isStreaming:!1}:b)),S(null),V.current?.()},[ae,b]),ag=(0,d.useCallback)(()=>{let a=T.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Z.current,runId:a?.runKey})}).catch(()=>{}),af()},[af]),ah=(0,d.useCallback)((a,c)=>{let d=a.type;if((0,f.Nn)(a))return;let i=a=>{if(U.current||"string"!=typeof a||!a)return;let b=(0,e.r)(a);H(a=>({outputTokens:(a?.outputTokens||0)+b}))};if("system"===d&&"init"===a.subtype){let c=a.session_id,d=ab.current;if(y(c),Z.current=c,d||(J(a=>a??Date.now()),H(null),U.current=!1),N(null),d){let a=`auto-asst-${++ad.current}`;aa.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:T.current?.runKey}])}ac.current=!0;return}if("system"===d&&"background_tasks_changed"===a.subtype){let b=(a.tasks??[]).filter(a=>!a.ambient).map(a=>({task_id:a.task_id,description:a.description}));P(b.length?b:j);return}if(!(0,f.A7)(a)||(W.current?.applyEvent(a),b(b=>(0,f.FM)(b,a,{engine:m,assistantId:c})),"task_notification"===a.subtype)){if("system"===d&&"task_notification"===a.subtype){if(!ac.current){let c=a.status,d=a.summary||"",e=a.task_id,f=`<task-notification>
753
- `+(e?`<task-id>${e}</task-id>
754
- `:"")+(a.tool_use_id?`<tool-use-id>${a.tool_use_id}</tool-use-id>
755
- `:"")+(c?`<status>${c}</status>
756
- `:"")+(d?`<summary>${d}</summary>
757
- `:"")+(a.output_file?`<output-file>${a.output_file}</output-file>
758
- `:"")+"</task-notification>",g=`auto-tasknotif-${e||++ad.current}`;b(a=>[...a,{id:g,role:"system",content:d,systemEvent:{kind:"task-notification",...c?{status:c}:{},detail:f},runKey:T.current?.runKey}])}return}if("system"===d&&"notice"===a.subtype){let c=(0,g.C)(a,`auto-notice-${++ad.current}`);c&&b(a=>[...a,{...c,runKey:T.current?.runKey}]);return}if("system"===d&&"api_retry"===a.subtype)return void N({attempt:a.attempt??0,maxRetries:a.max_retries??0,delayMs:a.retry_delay_ms??0,errorStatus:a.error_status,error:a.error});if("rate_limit_event"===d){let b=a.rate_limit_info;b&&L({status:b.status||"allowed",resetsAt:b.resetsAt,rateLimitType:b.rateLimitType,utilization:b.utilization,overageStatus:b.overageStatus,overageDisabledReason:b.overageDisabledReason,isUsingOverage:b.isUsingOverage,surpassedThreshold:b.surpassedThreshold});return}if("usage_update"===d){let b=a.output_tokens;if("number"==typeof b&&Number.isFinite(b)){U.current=!0;let a=Math.max(0,Math.round(b));H(b=>({outputTokens:Math.max(b?.outputTokens||0,a)}))}return}if("error"===d){let d=a.error||h.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});N(null),_.current&&(clearTimeout(_.current),_.current=null),ae(),b(a=>a.map(a=>a.id===c?{...a,content:a.content?`${a.content}
759
-
760
- ⚠️ ${d}`:`⚠️ ${d}`,isStreaming:!1}:a));return}if("stream_event"===d){N(a=>a?null:a);let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";i(a),$.current&&$.current.messageId===c?$.current.text+=a:$.current={messageId:c,text:a},_.current||(_.current=setTimeout(ae,50))}return}if("assistant"===d){let d=a.message?.content;if(Array.isArray(d))for(let a of d)a.text?i(a.text):a.name&&i(`${a.name} ${JSON.stringify(a.input??{})}`);b(b=>(0,f.FM)(b,a,{engine:m,assistantId:c}))}if("user"===d){let d=a.message?.content;if(Array.isArray(d))for(let a of d)i("string"==typeof a.content?a.content:JSON.stringify(a.content??""));b(b=>(0,f.FM)(b,a,{engine:m,assistantId:c}))}if("result"===d){ac.current=!1,ab.current=!0,N(null),_.current&&(clearTimeout(_.current),_.current=null),ae();let d=Z.current;d&&l&&b(a=>(2===a.length&&z(d),a));let e=a.usage,g=a.total_cost_usd;e&&F({inputTokens:e.input_tokens||0,outputTokens:e.output_tokens||0,cacheCreationInputTokens:e.cache_creation_input_tokens||0,cacheReadInputTokens:e.cache_read_input_tokens||0,totalCostUsd:g||0}),b(b=>(0,f.FM)(b,a,{engine:m,assistantId:c}))}}},[b,ae,y,z,l,m]);return(0,i.h)({url:R?`/ws/session-stream?sessionId=${encodeURIComponent(R.runKey)}`:"/ws/session-stream",enabled:!!R,onMessage:a=>{X.current=!0,Y.current&&(clearTimeout(Y.current),Y.current=null);let c=T.current;if(c)if("run-snapshot"===a.type&&Array.isArray(a.events)){_.current&&(clearTimeout(_.current),_.current=null),$.current=null,aa.current=c.assistantId,ab.current=!1,ac.current=!1,U.current=!1,H(null);let d="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let e of(null!==d&&(U.current=!0,H({outputTokens:d})),b(a=>a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("auto-")&&a.runKey===c.runKey)).map(a=>a.id===c.assistantId?{...a,content:"",toolCalls:[]}:a)),a.events))ah(e,aa.current??c.assistantId);a.status&&"running"!==a.status&&af()}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type)return void af();ah(a.message,aa.current??c.assistantId)}else"run-idle"===a.type&&af()}}),{isLoading:C,tokenUsage:E,liveOutputTokens:G,runningStartedAt:I,rateLimitInfo:K,apiRetryInfo:M,backgroundTasks:O,handleSend:(0,d.useCallback)(async(a,c,d)=>{let e=d&&"permissionMode"in d?"plan"===d.permissionMode:n,f=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),g={id:`user-${Date.now()}`,role:"user",content:a,images:f};b(a=>[...a,g]),D(!0),H(null),U.current=!1,J(Date.now()),N(null),P(j);let i=function(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}(),k=`assistant-${Date.now()}`,y={id:k,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,y]),aa.current=k,ab.current=!1,ac.current=!1;let z=!m||"claude"===m,A="deepseek"===m||"kimi"===m||"glm"===m,B="ollama"===m||A||z||"codex"===m;try{if("ollama"===m&&!p)throw Error("Please select an Ollama model first (click the model picker above)");let c="codex"===m?"/api/chat/codex":"kimi"===m?"/api/chat/kimi":"ollama"===m?"/api/chat/ollama":"deepseek"===m?"/api/chat/deepseek":"glm"===m?"/api/chat/glm":"/api/chat",d=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:Z.current,runId:i,images:f,cwd:l,language:h.A.language,..."ollama"===m&&p&&{model:p},...A&&q&&{model:q},...z&&r&&{model:r},...z&&s&&{claudeEffort:s},...z&&t&&{claudeContextWindow:t},...z&&void 0!==u&&{claudeFastMode:u},...z&&void 0!==v&&{claudeThinking:v},..."codex"===m&&w&&{model:w},..."codex"===m&&x&&{codexReasoningEffort:x},...e&&z&&{permissionMode:"plan"},...B&&o&&{noHistory:!0}})});if(!d.ok){let a=await d.json().catch(()=>null);throw Error(a?.error||h.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let g=await d.json().catch(()=>({}));S({runKey:g.runKey||i,assistantId:k}),X.current=!1,Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{T.current&&!X.current&&(b(a=>a.map(a=>a.id!==k||a.content?a:{...a,content:h.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),af())},15e3)}catch(c){console.error("Chat error:",c);let a=c instanceof Error?c.message:h.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});b(b=>b.map(b=>b.id===k?{...b,content:a,isStreaming:!1}:b)),D(!1),S(null)}},[l,m,n,o,p,q,r,s,t,u,v,w,x,b,af]),handleStop:ag,abortControllerRef:Q}}},98982:(a,b,c)=>{"use strict";c.d(b,{P:()=>j});var d=c(67484),e=c(57031),f=c(88214),g=c(79606),h=c(33281),i=c(71192);function j(){let[a,b]=(0,d.useState)([]),c=(0,d.useCallback)(()=>{let a=g.$mh({try:async()=>{let a=await fetch("/api/pinned-sessions");return await a.json()},catch:a=>new i.uV({message:"loadPinnedSessions failed",cause:a})});h.t4.runPromise(a.pipe(g.YWq({onSuccess:a=>b(a.sessions||[]),onFailure:()=>{}})))},[]),j=(0,d.useCallback)(a=>{b(a);let c=g.$mh({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:a})})},catch:a=>new i.uV({message:"savePinnedSessions failed",cause:a})});h.t4.runFork(c.pipe(g.NWQ(()=>g.rIH))),(0,e.F)(f.n.PinnedSessionsChanged,{})},[]),k=(0,d.useCallback)(b=>a.some(a=>a.sessionId===b),[a]),l=(0,d.useCallback)((b,c,d)=>{a.some(a=>a.sessionId===b)||j([...a,{sessionId:b,cwd:c,customTitle:d}])},[a,j]),m=(0,d.useCallback)(b=>{j(a.filter(a=>a.sessionId!==b))},[a,j]),n=(0,d.useCallback)((b,c)=>{j(a.map(a=>a.sessionId===b?{...a,customTitle:c}:a))},[a,j]);return{pinnedSessions:a,isPinned:k,pinSession:l,unpinSession:m,updateTitle:n,reorder:(0,d.useCallback)(a=>{j(a)},[j]),reload:c}}},99033:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Workspace:()=>y});var e=c(48249),f=c(67484),g=c(44384),h=c(8077),i=c(4462),j=c(77120),k=c(77220),l=c(48830),m=c(3033),n=c(34001),o=c(29412),p=c(37202),q=c(87819),r=c(79606),s=c(33281),t=c(97572),u=c(37388),v=c(75310),w=c(42319),x=a([h,j,n,o]);function y({initialCwd:a,initialSessionId:b,initialBlank:c}){let{t:d}=(0,g.Bd)(),[x,z]=(0,f.useState)([]),[A,B]=(0,f.useState)(0),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(!1),[G,H]=(0,f.useState)(!1),[I,J]=(0,f.useState)(!1),[K,L]=(0,f.useState)(!1),[M,N]=(0,f.useState)(null),[O,P]=(0,f.useState)(!1),[Q,R]=(0,f.useState)(!1),[S,T]=(0,f.useState)([]),[U,V]=(0,f.useState)(null),[W,X]=(0,f.useState)({}),[Y,Z]=(0,f.useState)({}),[$,_]=(0,f.useState)(!1),[aa,ab]=(0,f.useState)(new Set),ac=(0,f.useRef)(new Map),ad=(0,f.useRef)(new Map),ae=(0,f.useRef)(new Map);(0,f.useRef)(null),(0,q.Z)(t.v,[]);let af=(0,f.useCallback)(async(a,b,c)=>{let d=await s.t4.runPromise((0,t.g)({projects:a,activeIndex:b,collapsed:c}).pipe(r.gPK));"Left"===d._tag&&console.error("Failed to save projects:",d.left)},[]),ag=(0,f.useCallback)((a,b)=>{let c=x[A]?.cwd,d=c?{cwd:c,sessionId:ae.current.get(c)}:void 0,e=(0,w._)(d,{cwd:a,sessionId:b});e&&s.t4.runFork((0,u.T$)(e.cwd,e.sessionId).pipe(r.h9N(()=>r.rIH)))},[x,A]),ah=(0,f.useCallback)(a=>{let b=x[A]?.cwd,c=b?ac.current.get(b):null,d=c?.contentWindow;if(!d)return;let e=d.document.createEvent("CustomEvent");e.initCustomEvent("console-open-browser",!1,!1,{url:a}),d.dispatchEvent(e)},[A,x]),ai=(0,f.useCallback)(a=>{T(b=>b.some(b=>b.path===a.path)?b:[...b,a]),V(a.path)},[]),aj=(0,f.useCallback)(()=>{V(null)},[]),ak=(0,f.useCallback)(a=>{T(b=>b.filter(b=>b.path!==a)),V(b=>b===a?null:b)},[]),al=(0,f.useMemo)(()=>{let a={};return x.forEach((b,c)=>{(Y[b.cwd]??[]).forEach((d,e)=>{d&&(a[`${b.cwd}
761
- ${d}`]=`${c+1}.${e+1}`)})}),a},[x,Y]),am=(0,f.useCallback)(()=>{let a=crypto.randomUUID(),b=new Map(x.map((a,b)=>[a.cwd,b+1])),c=[...ac.current.values()];return 0===c.length?Promise.resolve({}):new Promise(d=>{let e={},f=new Set(c.map(a=>a.contentWindow).filter(Boolean)),g=()=>{window.removeEventListener("message",h),clearTimeout(i),X(e),d(e)},h=c=>{if(c.data?.type!=="SESSION_NUMBERS"||c.data?.requestId!==a||!f.delete(c.source))return;let d=b.get(c.data.cwd);d&&Array.isArray(c.data.sessionIds)&&c.data.sessionIds.forEach((a,b)=>{"string"==typeof a&&(e[`${c.data.cwd}
762
- ${a}`]=`${d}.${b+1}`)}),0===f.size&&g()};window.addEventListener("message",h);let i=window.setTimeout(g,300);c.forEach(b=>b.contentWindow?.postMessage({type:"GET_SESSION_NUMBERS",requestId:a},"*"))})},[x]),an=Object.fromEntries(x.map((a,b)=>[a.cwd,b+1])),ao=(0,f.useCallback)((a,b,c=!1)=>{let d=new URL(window.location.href);d.searchParams.set("cwd",a),b?d.searchParams.set("sessionId",b):d.searchParams.delete("sessionId"),c?d.searchParams.set("newChat","1"):d.searchParams.delete("newChat"),window.history.replaceState({},"",d.toString());let e=a.split("/").filter(Boolean).pop();document.title=e||"Cockpit"},[]);(0,f.useRef)(!1);let ap=(0,f.useCallback)(a=>{let b=x[a];if(b&&(a!==A&&ag(b.cwd,ae.current.get(b.cwd)),B(a),af(x,a,C),b?.cwd)){let a=ae.current.get(b.cwd);ao(b.cwd,a??void 0,null===a)}},[x,A,C,af,ao,ag]),aq=(0,f.useCallback)(a=>{let b=x.filter((b,c)=>c!==a),c=A;a<A?c=A-1:a===A&&c>=b.length&&(c=Math.max(0,b.length-1)),z(b),B(c),af(b,c,C)},[x,A,C,af]),ar=(0,f.useCallback)(a=>{let b=x[A],c=a.findIndex(a=>a.cwd===b?.cwd);z(a),B(c>=0?c:0),af(a,c>=0?c:0,C)},[x,A,C,af]),as=(0,f.useCallback)(()=>{let a=!C;D(a),af(x,A,a)},[x,A,C,af]),at=(0,f.useCallback)((a,b)=>{ag(a,b),ae.current.set(a,b);let c=x.findIndex(b=>b.cwd===a);if(c>=0){let d=ac.current.get(a);d?.contentWindow?d.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"):ad.current.set(a,{sessionId:b,switchToAgent:!0}),B(c),af(x,c,C)}else{let c=[...x,{cwd:a}],d=c.length-1;z(c),B(d),af(c,d,C),ad.current.set(a,{sessionId:b,switchToAgent:!0})}ao(a,b),F(!1)},[x,C,af,ao,ag]),au=(0,f.useCallback)((a,b)=>{ag(a,b),ae.current.set(a,b);let c=x.findIndex(b=>b.cwd===a);if(c>=0){let d=ac.current.get(a);d?.contentWindow?d.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"):ad.current.set(a,{sessionId:b,switchToAgent:!0}),c!==A&&(B(c),af(x,c,C))}else{let c=[...x,{cwd:a}],d=c.length-1;z(c),B(d),af(c,d,C),ad.current.set(a,{sessionId:b,switchToAgent:!0})}ao(a,b)},[x,A,C,af,ao,ag]);return $?(0,e.jsxs)("div",{className:"h-screen flex bg-background overflow-hidden",children:[(0,e.jsx)(h.ProjectSidebar,{projects:x,activeIndex:A,collapsed:C,currentCwd:x[A]?.cwd,onSelectProject:ap,onRemoveProject:aq,onReorderProjects:ar,onToggleCollapse:as,onOpenSessionBrowser:()=>F(!0),onOpenSettings:()=>H(!0),onOpenNote:a=>{N(a??null),L(!0)},onOpenSkills:()=>P(!0),onOpenApps:()=>R(!0),htmlAppPreviews:S,activeHtmlAppPreviewPath:U,onShowHtmlAppPreview:ai,onSwitchProject:au,onResolveSessionNumbers:am,sessionOrders:Y,sessionNumbers:al}),(0,e.jsx)("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:0===x.length?(0,e.jsx)(i.EmptyState,{onBrowseProjects:()=>F(!0)}):(0,e.jsx)("div",{className:"flex-1 relative overflow-hidden",children:x.map((a,b)=>{let c;return aa.has(a.cwd)&&(0,e.jsx)("iframe",{ref:b=>{b?ac.current.set(a.cwd,b):ac.current.delete(a.cwd)},src:(c=ad.current.get(a.cwd),(0,v.f)(a.cwd,c)),className:`absolute inset-0 w-full h-full border-0 ${b===A?"block":"hidden"}`,title:`Project: ${a.cwd}`},a.cwd)})})}),(0,e.jsx)(j.SessionBrowser,{isOpen:E,onClose:()=>F(!1),onSelectSession:at,sessionNumbers:W,projectNumbers:an,onAddProject:a=>{let b=x.findIndex(b=>b.cwd===a);if(ag(a,b>=0?ae.current.get(a):void 0),b>=0)B(b),af(x,b,C);else{let b=[...x,{cwd:a}],c=b.length-1;z(b),B(c),af(b,c,C)}F(!1)}}),(0,e.jsx)(k.SettingsModal,{isOpen:G,onClose:()=>H(!1)}),(0,e.jsx)(m.w,{isOpen:I,onClose:()=>J(!1)}),(0,e.jsx)(n.NoteModal,{isOpen:K,onClose:()=>{L(!1),N(null)},projectCwd:M,projectName:M?M.split("/").pop():null}),(0,e.jsx)(o.g,{isOpen:O,onClose:()=>P(!1)}),(0,e.jsx)(l.n,{isOpen:Q,htmlAppPreviews:S,activeHtmlAppPreviewPath:U,onShowHtmlAppPreview:ai,onMinimizeHtmlAppPreview:aj,onCloseHtmlAppPreview:ak,onClose:()=>R(!1),onOpenApp:ah}),(0,e.jsx)(p.M,{onNavigate:au})]}):(0,e.jsx)("div",{className:"h-screen flex items-center justify-center bg-card",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,e.jsx)("span",{children:d("workspace.loadingText")})]})})}[h,j,n,o]=x.then?(await x)():x,d()}catch(a){d(a)}})},99087:(a,b,c)=>{"use strict";c.d(b,{a:()=>e});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[g,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(0),k=(0,d.useRef)(null),l=(0,d.useRef)([]),m=(0,d.useCallback)(()=>{let b=a.current;b&&(b.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(a=>{let b=a.parentNode;b&&(b.replaceChild(document.createTextNode(a.textContent||""),a),b.normalize())}),l.current=[])},[a]);(0,d.useCallback)(b=>{if(m(),!b||!a.current){h([]),j(0);return}let c=[],d=[],e=b.toLowerCase();a.current.querySelectorAll("[data-message-id]").forEach(a=>{let f,g=a.getAttribute("data-message-id")||"",h=0,i=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null),j=[];for(;f=i.nextNode();)j.push(f);for(let a of j){let f=(a.textContent||"").toLowerCase(),i=0,j=[];for(;;){let a=f.indexOf(e,i);if(-1===a)break;j.push({start:a,end:a+b.length}),i=a+1}if(0!==j.length)for(let b=j.length-1;b>=0;b--){let e=j[b];a.splitText(e.end);let f=a.splitText(e.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=f.textContent,f.parentNode.replaceChild(i,f),c.push({messageId:g,markIndex:h}),d.push(i),h++}}}),c.reverse(),d.reverse(),l.current=d,h(c),j(c.length>0?0:-1)},[a,m]);let n=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a+1)%g.length)},[g.length]),o=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a-1+g.length)%g.length)},[g.length]),p=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>k.current?.focus(),0)},[]),q=(0,d.useCallback)(()=>{c(!1),f(""),m(),h([]),j(0)},[m]),r=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?o():n()),"Escape"===a.key&&q()},[n,o,q]);return{isSearchVisible:b,searchQuery:e,setSearchQuery:f,matches:g,currentMatchIndex:i,goToNextMatch:n,goToPrevMatch:o,openSearch:p,closeSearch:q,searchInputRef:k,handleSearchKeyDown:r}}},99191:(a,b,c)=>{"use strict";c.d(b,{o:()=>d});let d="flex items-center gap-2 h-9 flex-shrink-0 border-b border-border"},99829:(a,b,c)=>{"use strict";c.d(b,{I18nProvider:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call I18nProvider() from the server but I18nProvider is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/I18nProvider.tsx","I18nProvider")},99843:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>w});var e=c(48249),f=c(67484),g=c(75513),h=c(63565),i=c(2929),j=c(99087),k=c(74754),l=c(91579),m=c(41051),n=c(42140),o=c(44384),p=c(33281),q=c(41224),r=c(86508),s=c(37701),t=c(41170),u=a([i]);i=(u.then?(await u)():u)[0];function v({value:a}){let[b,c]=(0,f.useState)(a);return(0,f.useRef)(a),(0,f.useRef)(null),(0,e.jsx)("span",{className:"tabular-nums",children:b})}let w=(0,f.forwardRef)(function({messages:a,isLoading:b,cwd:c,sessionId:d,engine:u,apiRetryInfo:w,backgroundTasks:x,liveOutputTokens:y,runningStartedAt:z,hasMoreHistory:A,isLoadingMore:B,onLoadMore:C,onFork:D,onDeleteTurn:E,onSendToPeer:F,peerSide:G,isActive:H=!0,onContentSearch:I,onShowFileDiff:J,onOpenFileLink:K,onApprovePlan:L,onShowUserMessages:M},N){let{t:O,i18n:P}=(0,o.Bd)(),Q=(0,f.useRef)(null),R=(0,f.useRef)(null),S=(0,f.useRef)(null),T=(0,f.useRef)(null),U=(0,f.useRef)(null),V=(0,f.useRef)(null),[W,X]=(0,f.useState)(null),Y=(0,f.useRef)({mode:"follow",pinTop:null}),Z=(0,f.useRef)(null),$=(0,f.useRef)(!1),_=(0,f.useRef)(H),aa=(0,f.useCallback)(()=>{let a=S.current;return a?{clientHeight:a.clientHeight,scrollHeight:a.scrollHeight,scrollTop:a.scrollTop,spacer:Z.current?.offsetHeight??0}:null},[]),ab=(0,f.useRef)(null),ac=(0,f.useCallback)(a=>{let b=aa();if(!b)return!1;let c=(0,t.GR)(Y.current,a,b);if(!c)return!1;ab.current?.(),Y.current=c.owner;let d=()=>{Z.current&&(Z.current.style.height=`${c.spacer}px`)};c.deferSpacer||d();let e=S.current;if(null!==c.scrollTo&&e?.scrollTo({top:c.scrollTo,behavior:c.behavior}),c.deferSpacer&&e){let a=()=>{c(),d()},b=setTimeout(a,700),c=()=>{clearTimeout(b),e.removeEventListener("scrollend",a),ab.current=null};e.addEventListener("scrollend",a,{once:!0}),ab.current=c}return!0},[aa]);(0,f.useEffect)(()=>()=>ab.current?.(),[]);let[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(!1),[ah,ai]=(0,f.useState)(null),[aj,ak]=(0,f.useState)(0);(0,f.useEffect)(()=>{X(V.current)},[]),(0,f.useEffect)(()=>{if(!b||!z)return void ak(0);let a=()=>ak(Math.max(0,Math.floor((Date.now()-z)/1e3)));a();let c=setInterval(a,1e3);return()=>clearInterval(c)},[b,z]);let al=(0,f.useMemo)(()=>(0,h.ch)(u)?h.H[u]:h.H.claude,[u]),am=(0,h.ch)(u)?u:"claude",an=(0,f.useMemo)(()=>{let a=Math.floor(aj/60),b=aj%60;return a>0?`${a}m${b}s`:`${b}s`},[aj]),{isSearchVisible:ao,searchQuery:ap,setSearchQuery:aq,matches:ar,currentMatchIndex:as,goToNextMatch:at,goToPrevMatch:au,closeSearch:av,searchInputRef:aw,handleSearchKeyDown:ax}=(0,j.a)(V),ay=(0,g.nH)(),az=(0,f.useRef)(null),aA=(0,f.useRef)(()=>{}),{addComment:aB,refresh:aC}=(0,k._)({cwd:c||"",filePath:l.Un}),[aD,aE]=(0,f.useState)(null),[aF,aG]=(0,f.useState)(null),aH=(0,f.useCallback)(a=>{if(aD||aF)return;let b=window.getSelection();if(!b||b.isCollapsed||!b.rangeCount){az.current=null,aA.current();return}let c=b.toString().trim();if(!c){az.current=null,aA.current();return}let d=b.anchorNode instanceof HTMLElement?b.anchorNode:b.anchorNode?.parentElement;if(d?.closest('[data-role="user"]')){az.current=null,aA.current();return}az.current={x:a.clientX,y:a.clientY,range:{start:0,end:0},selectedText:c,lineSnapshot:c},aA.current()},[aD,aF]),aI=(0,f.useCallback)(a=>{let b=a.target;!(b.closest(".floating-toolbar")||b.closest('[class*="z-[200]"]'))&&az.current&&(az.current=null,aA.current())},[]),aJ=(0,f.useCallback)(()=>{let a=az.current;a&&(aE({x:a.x,y:a.y,text:a.selectedText}),az.current=null,aA.current(),window.getSelection()?.removeAllRanges())},[]),aK=(0,f.useCallback)(()=>{let a=az.current;a&&(aG({x:a.x,y:a.y,text:a.selectedText}),az.current=null,aA.current(),window.getSelection()?.removeAllRanges())},[]),aL=(0,f.useCallback)(()=>{let a=az.current;a&&ay&&(az.current=null,aA.current(),window.getSelection()?.removeAllRanges(),(0,l.Ff)(ay.sendMessage,{filePath:l.Un,startLine:0,endLine:0,codeContent:a.selectedText},O("explain.selectionMessage")))},[ay,O]),aM=(0,f.useCallback)(()=>{let a=az.current;if(!a||!I)return;let b=a.selectedText.trim();az.current=null,aA.current(),window.getSelection()?.removeAllRanges(),b&&I(b)},[I]),aN=(0,f.useCallback)(async a=>{aD&&(await aB(0,0,a,aD.text),aE(null))},[aD,aB]),aO=(0,f.useCallback)(async(a,b)=>{if(ay&&c)try{let d=(await (0,l.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));d.push({filePath:l.Un,startLine:0,endLine:0,codeContent:a});let e=(0,l.Gw)(d,b);ay.sendMessage(e),await (0,l.RP)(c),aC()}catch(a){console.error("Failed to send to AI:",a)}},[ay,c,aC]),aP=(0,f.useCallback)((a,b)=>{let c=az.current;if(!c)return;let d=c.selectedText;az.current=null,aA.current(),window.getSelection()?.removeAllRanges(),"comment"===a?aB(0,0,b,d):aO(d,b)},[aB,aO]),aQ=(0,s.Fe)(P.language),[aR,aS]=(0,f.useState)(null),[aT,aU]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let a=!1;return p.t4.runPromiseExit((0,q.td)()).then(b=>{a||aS("Success"===b._tag?(0,s.wL)(b.value,aQ):null)}),()=>{a=!0}},[aQ]);let aV=(0,f.useCallback)(a=>{p.t4.runPromiseExit((0,q.td)()).then(b=>{let c={..."Success"===b._tag?b.value.quickReplies??{}:{}};return a?c[aQ]=a:delete c[aQ],p.t4.runPromiseExit((0,q.em)({quickReplies:c})).then(b=>{"Success"===b._tag?aS(a):console.error("Failed to save quick replies:",b.cause)})})},[aQ]),aW=(0,f.useCallback)(()=>{az.current=null,aA.current(),window.getSelection()?.removeAllRanges(),aU(!0)},[]),aX=(0,f.useMemo)(()=>aR??m.SZ.map(a=>a.map(a=>O(a))),[aR,O]),aY=(0,f.useCallback)(a=>{aF&&aO(aF.text,a)},[aF,aO]),aZ=(0,f.useCallback)(a=>{aD&&aO(aD.text,a)},[aD,aO]),a$=(0,f.useMemo)(()=>{let b=new Set;return a.filter(a=>!b.has(a.id)&&(b.add(a.id),"assistant"!==a.role||!!a.isStreaming||!!a.content||!!a.images?.length||!!a.toolCalls?.length||!!a.parts?.length))},[a]),a_=(0,f.useMemo)(()=>a$.filter(a=>"user"===a.role),[a$]),a0=(0,f.useMemo)(()=>a_.slice(-10),[a_]),a1=A||a_.length>10,a2=(0,f.useRef)(0),a3=(0,f.useRef)(!1),a4=(0,f.useCallback)(()=>{let a=S.current;return!a||a.scrollTop<50},[]),a5=(0,f.useCallback)((a=!1)=>{let b=S.current;if(!b)return;if(a&&a0.length>0)return void ai(a0[a0.length-1].id);let c=b.getBoundingClientRect(),d=null,e=null;for(let a of a0){let f=b.querySelector(`[data-message-id="${CSS.escape(a.id)}"]`);if(!f)continue;let g=f.getBoundingClientRect().top;!e&&g<c.bottom&&(e=a.id),g<=c.top+12&&(d=a.id)}ai(d??e)},[a0]),a6=(0,f.useCallback)(()=>{let a=aa(),b=!a||(0,t.LM)(a),c=a4();if(a&&(Y.current=(0,t.Ux)(Y.current,a)),ae(!c),ag(!b),a5(b),c&&A&&!B&&C){let a=S.current;a&&(a2.current=a.scrollHeight,a3.current=!0),C()}},[a4,aa,a5,A,B,C]),a7=(0,f.useCallback)(()=>{ac({type:"release"}),R.current?.scrollIntoView({behavior:"smooth"})},[ac]),a8=(0,f.useCallback)(()=>{ac({type:"toEnd"})},[ac]),a9=(0,f.useCallback)(a=>{let b=S.current;if(!b)return!1;let c=b.querySelector(`[data-message-id="${a}"]`);if(!c)return!1;let d=c.getBoundingClientRect().top-b.getBoundingClientRect().top;return b.scrollTo({top:b.scrollTop+d-8,behavior:"auto"}),ac({type:"release"}),T.current&&clearTimeout(T.current),U.current?.classList.remove("flash-turn"),c.classList.remove("flash-turn"),c.offsetWidth,c.classList.add("flash-turn"),U.current=c,T.current=setTimeout(()=>{c.classList.remove("flash-turn"),U.current=null,T.current=null},2e3),!0},[ac]),ba=(0,f.useRef)(!1),bb=(0,f.useCallback)(()=>{ba.current=!0},[]);(0,f.useImperativeHandle)(N,()=>({scrollToMessage:a9,pinNextUserMessage:bb}),[a9,bb]),(0,f.useLayoutEffect)(()=>{let a;if(!ba.current)return;let b=S.current;if(!b)return;for(let b=a$.length-1;b>=0;b-=1)if("user"===a$[b].role){a=a$[b];break}if(!a)return;let c=b.querySelector(`[data-message-id="${CSS.escape(a.id)}"]`);if(!c)return;ba.current=!1;let d=c.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop;ac({type:"pin",top:Math.max(0,d-8)})},[a$,ac]),(0,f.useLayoutEffect)(()=>{let a=_.current;_.current=H,a&&!H&&b&&($.current=!0)},[H,b]),(0,f.useLayoutEffect)(()=>{a3.current||ac({type:"content"})},[a,b,ac]),(0,f.useEffect)(()=>{let a=S.current;if(!a)return;let b=new ResizeObserver(()=>ac({type:"viewport"}));return b.observe(a),()=>b.disconnect()},[ac]),(0,f.useEffect)(()=>{let a=S.current;if(!a)return;let b=()=>ac({type:"release"});return a.addEventListener("wheel",b,{passive:!0}),a.addEventListener("touchmove",b,{passive:!0}),a.addEventListener("keydown",b),()=>{a.removeEventListener("wheel",b),a.removeEventListener("touchmove",b),a.removeEventListener("keydown",b)}},[ac]);let bc=(0,f.useRef)(d);(0,f.useEffect)(()=>{let a=bc.current;bc.current=d,a&&a!==d&&(ba.current=!1,$.current=!1,ac({type:"reset"}))},[d,ac]),(0,f.useLayoutEffect)(()=>{if(a3.current&&!B){let a=S.current;if(a){let b=a.scrollHeight-a2.current;a.scrollTop=b,a3.current=!1}}},[a,B]);let bd=(0,f.useRef)(b),be=(0,f.useRef)(!1);return(0,f.useEffect)(()=>{let a=bd.current;bd.current=b,a&&!b&&(be.current=!ac({type:"settle"}))},[b,ac]),(0,f.useLayoutEffect)(()=>{if(H){if($.current){let a=S.current,b=a?.querySelectorAll('[data-role="user"]'),c=b?.item((b?.length??0)-1);if(a&&c){let b=c.getBoundingClientRect().top-a.getBoundingClientRect().top+a.scrollTop;if(ac({type:"readFrom",top:Math.max(0,b-8)})){$.current=!1,be.current=!1;return}}}ac({type:"viewport"}),be.current&&(be.current=!1,ac({type:"settle"}))}},[H,ac]),(0,f.useEffect)(()=>{if(!H)return;let a=aa();a5(!!a&&(0,t.LM)(a))},[a,H,aa,a5]),(0,e.jsxs)("div",{ref:V,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:aH,onMouseDown:aI,children:[ao&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)("input",{ref:aw,type:"text",value:ap,onChange:a=>aq(a.target.value),onKeyDown:ax,placeholder:O("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,e.jsx)("span",{className:"text-xs text-muted-foreground",children:ar.length>0?`${as+1}/${ar.length}`:O("common.noMatch")}),(0,e.jsx)("button",{onClick:au,disabled:0===ar.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:O("codeViewer.prevShiftEnter"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{onClick:at,disabled:0===ar.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:O("codeViewer.nextEnter"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{onClick:av,className:"p-1 rounded hover:bg-hover",title:O("codeViewer.closeEsc"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{ref:S,onScroll:a6,className:"relative flex-1 min-h-0 overflow-y-auto px-8 py-4",children:0!==a.length||b?(0,e.jsxs)("div",{className:"mx-auto w-full max-w-[var(--chat-column)]",children:[(0,e.jsx)("div",{ref:R}),A&&(0,e.jsx)("div",{className:"flex justify-center py-3",children:B?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("span",{children:O("chat.loadMoreHistory")})]}):(0,e.jsx)("button",{onClick:C,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:O("chat.scrollUpForMore")})}),a$.map(a=>(0,e.jsx)("div",{"data-message-id":a.id,"data-role":a.role,children:(0,e.jsx)(i.s,{message:a,cwd:c,sessionId:d,onFork:D,onDeleteTurn:E,forkSupported:!0,onSendToPeer:F,peerSide:G,onApprovePlan:L,isLoading:b,onContentSearch:I,onShowFileDiff:J,onOpenFileLink:K})},a.id)),b&&(0,e.jsx)("div",{className:"flex justify-start mb-4",children:(0,e.jsxs)("div",{className:"px-1 py-1 max-w-[90%]",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[(0,e.jsx)("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center","aria-hidden":"true",children:(0,e.jsx)(h.eV,{engine:am,className:"h-4 w-4"})}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground/80",children:[al," running ",an," \xb7 processing"," ",(0,e.jsx)(v,{value:y?.outputTokens??0})]})]}),x&&x.length>0&&(0,e.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-muted-foreground border-t border-border/50 pt-2",children:[(0,e.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,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{children:["Waiting on ",x.length," background task",x.length>1?"s":""]}),x.map(a=>(0,e.jsx)("div",{className:"text-muted-foreground/80 break-words",children:a.description},a.task_id))]})]}),w&&(0,e.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-11 border-t border-border/50 pt-2",children:[(0,e.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,e.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,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{children:["Retrying API call (attempt ",w.attempt,w.maxRetries>0?`/${w.maxRetries}`:"",w.delayMs>0?`, delay ${(w.delayMs/1e3).toFixed(1)}s`:"",")"]}),(w.errorStatus||w.error)&&(0,e.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[w.errorStatus?`${w.errorStatus}`:"",w.errorStatus&&w.error?" \xb7 ":"",w.error||""]})]})]})]})}),(0,e.jsx)("div",{ref:Z,"aria-hidden":!0}),(0,e.jsx)("div",{ref:Q})]}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,e.jsx)("div",{children:O("chat.startConversation")})]})})}),(a0.length>0||ad||af)&&(0,e.jsxs)("nav",{className:"absolute top-1/2 z-10 flex -translate-y-1/2 flex-col items-center gap-2",style:{right:"max(0.5rem, calc(50% - var(--chat-column) / 2 - 2.25rem))"},"aria-label":O("chat.recentUserMessages"),children:[ad&&a.length>0&&(0,e.jsx)("button",{onClick:a7,className:"mb-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-all hover:bg-hover hover:text-foreground active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:O("chat.jumpToStart"),"aria-label":O("chat.jumpToStart"),children:(0,e.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 5h14M12 19V9m-5 5l5-5 5 5"})})}),a1&&M&&(0,e.jsx)("button",{onClick:M,className:"mb-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:O("chat.moreUserMessages"),"aria-label":O("chat.moreUserMessages"),children:(0,e.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a0.map((a,b)=>{let c=ah===a.id,d=a.content.replace(/\s+/g," ").trim()||(a.images?.length?O("chat.imageMessage"):O("chat.userMessage"));return(0,e.jsxs)("div",{className:"group relative flex h-3 items-center",children:[(0,e.jsx)("button",{onClick:b=>{a9(a.id),b.detail>0&&b.currentTarget.blur()},className:"flex h-3 w-7 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-current":c?"true":void 0,"aria-label":O("chat.recentUserMessageNumber",{index:b+1,total:a0.length}),children:(0,e.jsx)("span",{"aria-hidden":!0,className:`h-0.5 rounded-full transition-all ${c?"w-4 bg-foreground":"w-3 bg-foreground/20 group-hover:w-4 group-hover:bg-foreground/45"}`})}),(0,e.jsx)("div",{className:"pointer-events-none absolute right-8 top-1/2 hidden w-72 -translate-y-1/2 rounded-xl border border-border bg-card px-3 py-2.5 text-left shadow-lv2 group-hover:block group-focus-within:block",children:(0,e.jsx)("div",{className:"line-clamp-4 text-sm leading-5 text-foreground",children:d})})]},a.id)}),af&&a.length>0&&(0,e.jsx)("button",{onClick:a8,className:"mt-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-all hover:bg-hover hover:text-foreground active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:O("chat.jumpToLatest"),"aria-label":O("chat.jumpToLatest"),children:(0,e.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 19H5m7-14v10m5-5l-5 5-5-5"})})})]}),W&&(0,e.jsx)(m.fS,{floatingToolbarRef:az,bumpRef:aA,container:W,onAddComment:aJ,onSendToAI:aK,onSearch:I?aM:void 0,onExplain:ay?aL:void 0,onQuickReply:aP,quickReplyRows:aX,onEditQuickReplies:aW,isChatLoading:ay?.isLoading}),aT&&(0,e.jsx)(r.j,{initialRows:aX,lang:aQ,isCustomized:null!==aR,onSave:a=>aV(a.length?a:null),onRestoreDefault:()=>aV(null),onClose:()=>aU(!1)}),aD&&W&&(0,e.jsx)(n.t,{x:aD.x,y:aD.y,range:{start:0,end:0},lineSnapshot:aD.text,container:W,onSubmit:aN,onSendToAI:ay?aZ:void 0,onClose:()=>aE(null),isChatLoading:ay?.isLoading}),aF&&W&&(0,e.jsx)(n.G,{x:aF.x,y:aF.y,range:{start:0,end:0},lineSnapshot:aF.text,container:W,onSubmit:aY,onClose:()=>aG(null),isChatLoading:ay?.isLoading})]})});d()}catch(a){d(a)}})}};