commandmate 0.44.2 → 0.44.3

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 (581) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +149 -149
  3. package/.next/app-path-routes-manifest.json +21 -21
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +12 -12
  6. package/.next/react-loadable-manifest.json +0 -6
  7. package/.next/required-server-files.json +1 -1
  8. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/api/agents/update/route.js +1 -1
  10. package/.next/server/app/api/agents/update/route_client-reference-manifest.js +1 -1
  11. package/.next/server/app/api/agents/versions/route.js +1 -1
  12. package/.next/server/app/api/agents/versions/route_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/app/release-notes/route_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/app/update/route.js +2 -2
  15. package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/auth/login/route.js +1 -1
  18. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/capabilities/route.js +1 -1
  22. package/.next/server/app/api/capabilities/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/daily-summary/route.js +1 -1
  24. package/.next/server/app/api/daily-summary/route.js.nft.json +1 -1
  25. package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/daily-summary/status/route.js +1 -1
  27. package/.next/server/app/api/daily-summary/status/route.js.nft.json +1 -1
  28. package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
  30. package/.next/server/app/api/external-apps/[id]/route.js +1 -1
  31. package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/external-apps/route.js +1 -1
  33. package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/hooks/agent-event/route.js +2 -2
  37. package/.next/server/app/api/hooks/agent-event/route.js.nft.json +1 -1
  38. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/hooks/claude-done/route.js +2 -2
  40. package/.next/server/app/api/hooks/claude-done/route.js.nft.json +1 -1
  41. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/hooks/permission-request/route.js +1 -1
  43. package/.next/server/app/api/hooks/permission-request/route.js.nft.json +1 -1
  44. package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
  45. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  47. package/.next/server/app/api/push/escalation/route.js +1 -1
  48. package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/push/subscriptions/route.js +2 -2
  50. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/push/vapid/route.js +1 -1
  52. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  53. package/.next/server/app/api/relays/[relayId]/cancel/route.js +1 -1
  54. package/.next/server/app/api/relays/[relayId]/cancel/route.js.nft.json +1 -1
  55. package/.next/server/app/api/relays/[relayId]/cancel/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/relays/route.js +1 -1
  57. package/.next/server/app/api/relays/route.js.nft.json +1 -1
  58. package/.next/server/app/api/relays/route_client-reference-manifest.js +1 -1
  59. package/.next/server/app/api/remote/pair/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/repositories/[id]/route.js +1 -1
  61. package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
  63. package/.next/server/app/api/repositories/clone/[jobId]/route.js.nft.json +1 -1
  64. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/repositories/clone/route.js +1 -1
  66. package/.next/server/app/api/repositories/clone/route.js.nft.json +1 -1
  67. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/repositories/restore/route.js +1 -1
  70. package/.next/server/app/api/repositories/restore/route.js.nft.json +1 -1
  71. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/repositories/route.js +1 -1
  73. package/.next/server/app/api/repositories/route.js.nft.json +1 -1
  74. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/repositories/scan/route.js +1 -1
  76. package/.next/server/app/api/repositories/scan/route.js.nft.json +1 -1
  77. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/repositories/sync/route.js +1 -1
  79. package/.next/server/app/api/repositories/sync/route.js.nft.json +1 -1
  80. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/settings/default-agents/route.js +1 -1
  83. package/.next/server/app/api/settings/default-agents/route.js.nft.json +1 -1
  84. package/.next/server/app/api/settings/default-agents/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/settings/default-surface-mode/route_client-reference-manifest.js +1 -1
  86. package/.next/server/app/api/sidebar/group-order/route.js +1 -1
  87. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/skills/[id]/route.js +1 -1
  89. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  90. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  92. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  93. package/.next/server/app/api/skills/route.js +1 -1
  94. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  95. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  96. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/templates/[id]/route.js +2 -2
  99. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/templates/route.js +2 -2
  101. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  102. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
  104. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
  105. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
  106. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  107. package/.next/server/app/api/worktrees/[id]/capture/route.js +1 -1
  108. package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -1
  109. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/worktrees/[id]/clear-composer/route.js +1 -1
  111. package/.next/server/app/api/worktrees/[id]/clear-composer/route.js.nft.json +1 -1
  112. package/.next/server/app/api/worktrees/[id]/clear-composer/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/worktrees/[id]/cli-reference/route_client-reference-manifest.js +1 -1
  114. package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
  115. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js +3 -3
  117. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js.nft.json +1 -1
  118. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
  121. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/worktrees/[id]/direct-input/route.js +1 -1
  123. package/.next/server/app/api/worktrees/[id]/direct-input/route.js.nft.json +1 -1
  124. package/.next/server/app/api/worktrees/[id]/direct-input/route_client-reference-manifest.js +1 -1
  125. package/.next/server/app/api/worktrees/[id]/env/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +2 -2
  128. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js.nft.json +1 -1
  129. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
  131. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/worktrees/[id]/git/branch/create/route.js +1 -1
  133. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route.js +1 -1
  135. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  136. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  137. package/.next/server/app/api/worktrees/[id]/git/checkout/route.js +1 -1
  138. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  139. package/.next/server/app/api/worktrees/[id]/git/commit/route.js +1 -1
  140. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  141. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/api/worktrees/[id]/git/fetch/route.js +1 -1
  143. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  144. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  145. package/.next/server/app/api/worktrees/[id]/git/pull/route.js +1 -1
  146. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  147. package/.next/server/app/api/worktrees/[id]/git/push/route.js +1 -1
  148. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  149. package/.next/server/app/api/worktrees/[id]/git/reset/route.js +1 -1
  150. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  151. package/.next/server/app/api/worktrees/[id]/git/revert/route.js +1 -1
  152. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  153. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  154. package/.next/server/app/api/worktrees/[id]/git/stage/route.js +1 -1
  155. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  156. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  157. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  158. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route.js +1 -1
  159. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  160. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route.js +1 -1
  161. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  162. package/.next/server/app/api/worktrees/[id]/git/stash/push/route.js +1 -1
  163. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  164. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  165. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  166. package/.next/server/app/api/worktrees/[id]/git/unstage/route.js +1 -1
  167. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  168. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  169. package/.next/server/app/api/worktrees/[id]/instances/notes/route.js +1 -1
  170. package/.next/server/app/api/worktrees/[id]/instances/notes/route_client-reference-manifest.js +1 -1
  171. package/.next/server/app/api/worktrees/[id]/instances/opencode/route.js +1 -1
  172. package/.next/server/app/api/worktrees/[id]/instances/opencode/route.js.nft.json +1 -1
  173. package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +1 -1
  174. package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -1
  175. package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
  176. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  177. package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
  178. package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
  179. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  180. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  181. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  182. package/.next/server/app/api/worktrees/[id]/marp-render/route.js +1 -1
  183. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  184. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -1
  185. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  186. package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -1
  187. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  188. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  189. package/.next/server/app/api/worktrees/[id]/opencode/diff/route.js +1 -1
  190. package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -1
  191. package/.next/server/app/api/worktrees/[id]/opencode/session/route.js +1 -1
  192. package/.next/server/app/api/worktrees/[id]/opencode/session/route.js.nft.json +1 -1
  193. package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -1
  194. package/.next/server/app/api/worktrees/[id]/opencode/share/route.js +1 -1
  195. package/.next/server/app/api/worktrees/[id]/opencode/share/route.js.nft.json +1 -1
  196. package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +1 -1
  197. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
  198. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
  199. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  200. package/.next/server/app/api/worktrees/[id]/resolve-target/route_client-reference-manifest.js +1 -1
  201. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
  202. package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
  203. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  204. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  205. package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
  206. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  207. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +2 -2
  208. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js.nft.json +1 -1
  209. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  210. package/.next/server/app/api/worktrees/[id]/schedules/active/route.js +2 -2
  211. package/.next/server/app/api/worktrees/[id]/schedules/active/route.js.nft.json +1 -1
  212. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  213. package/.next/server/app/api/worktrees/[id]/schedules/route.js +3 -3
  214. package/.next/server/app/api/worktrees/[id]/schedules/route.js.nft.json +1 -1
  215. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  216. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  217. package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
  218. package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
  219. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  220. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js +2 -2
  221. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js.nft.json +1 -1
  222. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  223. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  224. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route.js +1 -1
  225. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  226. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  227. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  228. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
  229. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route.js +1 -1
  230. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
  231. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  232. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
  233. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  234. package/.next/server/app/api/worktrees/[id]/special-keys/route.js +1 -1
  235. package/.next/server/app/api/worktrees/[id]/special-keys/route.js.nft.json +1 -1
  236. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  237. package/.next/server/app/api/worktrees/[id]/tasks/route.js +1 -1
  238. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
  239. package/.next/server/app/api/worktrees/[id]/terminal/route.js +2 -2
  240. package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -1
  241. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  242. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  243. package/.next/server/app/api/worktrees/[id]/timers/route.js +1 -1
  244. package/.next/server/app/api/worktrees/[id]/timers/route.js.nft.json +1 -1
  245. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  246. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route.js +1 -1
  247. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  248. package/.next/server/app/api/worktrees/[id]/todos/route.js +1 -1
  249. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  250. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  251. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  252. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  253. package/.next/server/app/api/worktrees/[id]/verify/config/route.js +1 -1
  254. package/.next/server/app/api/worktrees/[id]/verify/config/route_client-reference-manifest.js +1 -1
  255. package/.next/server/app/api/worktrees/[id]/verify/route.js +1 -1
  256. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
  257. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route.js +1 -1
  258. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route_client-reference-manifest.js +1 -1
  259. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
  260. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
  261. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  262. package/.next/server/app/api/worktrees/apply-default-agents/route_client-reference-manifest.js +1 -1
  263. package/.next/server/app/api/worktrees/route.js +1 -1
  264. package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
  265. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  266. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  267. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  268. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  269. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  270. package/.next/server/app/page_client-reference-manifest.js +1 -1
  271. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  272. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  273. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  274. package/.next/server/app/sessions/page.js +1 -1
  275. package/.next/server/app/sessions/page.js.nft.json +1 -1
  276. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  277. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  278. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  279. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  280. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  281. package/.next/server/app/worktrees/[id]/page.js +11 -11
  282. package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
  283. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  284. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  285. package/.next/server/app-paths-manifest.json +21 -21
  286. package/.next/server/chunks/1191.js +2 -2
  287. package/.next/server/chunks/1210.js +1 -1
  288. package/.next/server/chunks/1559.js +2 -0
  289. package/.next/server/chunks/1789.js +1 -0
  290. package/.next/server/chunks/2119.js +1 -1
  291. package/.next/server/chunks/2404.js +1 -1
  292. package/.next/server/chunks/2445.js +1 -1
  293. package/.next/server/chunks/2460.js +1 -1
  294. package/.next/server/chunks/2710.js +1 -1
  295. package/.next/server/chunks/2908.js +1 -1
  296. package/.next/server/chunks/2980.js +1 -1
  297. package/.next/server/chunks/3241.js +1 -1
  298. package/.next/server/chunks/3480.js +1 -1
  299. package/.next/server/chunks/3718.js +1 -1
  300. package/.next/server/chunks/4207.js +2 -2
  301. package/.next/server/chunks/450.js +1 -1
  302. package/.next/server/chunks/4672.js +5 -0
  303. package/.next/server/chunks/{9353.js → 4718.js} +2 -2
  304. package/.next/server/chunks/4837.js +14 -0
  305. package/.next/server/chunks/5048.js +1 -1
  306. package/.next/server/chunks/5209.js +1 -0
  307. package/.next/server/chunks/5595.js +1 -1
  308. package/.next/server/chunks/5625.js +25 -0
  309. package/.next/server/chunks/611.js +1 -1
  310. package/.next/server/chunks/6130.js +1 -1
  311. package/.next/server/chunks/6401.js +1 -1
  312. package/.next/server/chunks/6781.js +1 -1
  313. package/.next/server/chunks/6793.js +3 -3
  314. package/.next/server/chunks/7491.js +2 -2
  315. package/.next/server/chunks/7905.js +1 -1
  316. package/.next/server/chunks/850.js +1 -1
  317. package/.next/server/chunks/8728.js +3 -3
  318. package/.next/server/chunks/8791.js +1 -1
  319. package/.next/server/chunks/8800.js +1 -1
  320. package/.next/server/chunks/8918.js +7 -7
  321. package/.next/server/chunks/9130.js +1 -1
  322. package/.next/server/chunks/9390.js +2 -2
  323. package/.next/server/chunks/9584.js +1 -1
  324. package/.next/server/chunks/9627.js +6 -6
  325. package/.next/server/chunks/9731.js +3 -3
  326. package/.next/server/middleware-manifest.json +5 -5
  327. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  328. package/.next/server/pages/500.html +1 -1
  329. package/.next/server/server-reference-manifest.json +1 -1
  330. package/.next/static/chunks/{1642-fb2e176aaadbd137.js → 1642-767aed8e7c61ef7f.js} +1 -1
  331. package/.next/static/chunks/{2407-051f6f84226a9f2c.js → 2407-06d35bb1aa02de80.js} +1 -1
  332. package/.next/static/chunks/{2619-04bc32f026a0d946.js → 2619-a305ad4810f1393a.js} +1 -1
  333. package/.next/static/chunks/4727-5d695d71e3fdf97b.js +1 -0
  334. package/.next/static/chunks/{8165-3853772f6ae1299b.js → 8165-3525fb42f1b4976e.js} +1 -1
  335. package/.next/static/chunks/app/{layout-9da1ab602bcb3051.js → layout-0d1750b833f5cc3e.js} +1 -1
  336. package/.next/static/chunks/app/sessions/page-2af68c63211c751f.js +1 -0
  337. package/.next/static/chunks/app/worktrees/[id]/page-e36898c3a80e7302.js +1 -0
  338. package/.next/static/chunks/app/worktrees/[id]/terminal/{page-373ea37b16d930c7.js → page-c601f3b3ece6557e.js} +1 -1
  339. package/.next/static/css/057f64a65726c439.css +1 -0
  340. package/.next/trace +13 -13
  341. package/dist/cli/commands/ask.d.ts.map +1 -1
  342. package/dist/cli/commands/ask.js +120 -119
  343. package/dist/cli/commands/attach.d.ts +94 -0
  344. package/dist/cli/commands/attach.d.ts.map +1 -1
  345. package/dist/cli/commands/attach.js +145 -7
  346. package/dist/cli/commands/auto-yes.js +1 -1
  347. package/dist/cli/commands/capture.d.ts.map +1 -1
  348. package/dist/cli/commands/capture.js +3 -5
  349. package/dist/cli/commands/command-target.d.ts +23 -0
  350. package/dist/cli/commands/command-target.d.ts.map +1 -0
  351. package/dist/cli/commands/command-target.js +25 -0
  352. package/dist/cli/commands/instances.d.ts.map +1 -1
  353. package/dist/cli/commands/instances.js +41 -2
  354. package/dist/cli/commands/message-dispatch.d.ts +36 -0
  355. package/dist/cli/commands/message-dispatch.d.ts.map +1 -0
  356. package/dist/cli/commands/message-dispatch.js +63 -0
  357. package/dist/cli/commands/reply.d.ts.map +1 -1
  358. package/dist/cli/commands/reply.js +2 -5
  359. package/dist/cli/commands/respond.d.ts.map +1 -1
  360. package/dist/cli/commands/respond.js +3 -6
  361. package/dist/cli/commands/send.d.ts.map +1 -1
  362. package/dist/cli/commands/send.js +149 -146
  363. package/dist/cli/commands/wait.d.ts.map +1 -1
  364. package/dist/cli/commands/wait.js +589 -431
  365. package/dist/cli/types/api-responses.d.ts +159 -27
  366. package/dist/cli/types/api-responses.d.ts.map +1 -1
  367. package/dist/cli/types/api-responses.js +4 -2
  368. package/dist/cli/utils/api-client.d.ts +25 -5
  369. package/dist/cli/utils/api-client.d.ts.map +1 -1
  370. package/dist/cli/utils/api-client.js +87 -55
  371. package/dist/cli/utils/server-url.d.ts +1 -0
  372. package/dist/cli/utils/server-url.d.ts.map +1 -1
  373. package/dist/cli/utils/server-url.js +7 -0
  374. package/dist/config/uat-isolation.d.ts +140 -0
  375. package/dist/config/uat-isolation.d.ts.map +1 -0
  376. package/dist/config/uat-isolation.js +246 -0
  377. package/dist/lib/global-state.d.ts +12 -0
  378. package/dist/lib/global-state.d.ts.map +1 -0
  379. package/dist/lib/global-state.js +16 -0
  380. package/dist/lib/polling/auto-yes-suppression-reason.d.ts +33 -0
  381. package/dist/lib/polling/auto-yes-suppression-reason.d.ts.map +1 -0
  382. package/dist/lib/polling/auto-yes-suppression-reason.js +2 -0
  383. package/dist/lib/session/prompt-view.d.ts +26 -3
  384. package/dist/lib/session/prompt-view.d.ts.map +1 -1
  385. package/dist/lib/session/prompt-view.js +26 -3
  386. package/dist/lib/session/status-evidence-type.d.ts +16 -0
  387. package/dist/lib/session/status-evidence-type.d.ts.map +1 -0
  388. package/dist/lib/session/status-evidence-type.js +2 -0
  389. package/dist/lib/tmux/legacy-session-alias.d.ts.map +1 -1
  390. package/dist/lib/tmux/legacy-session-alias.js +2 -1
  391. package/dist/server/locales/en/worktree.json +3 -1
  392. package/dist/server/locales/ja/worktree.json +3 -1
  393. package/dist/server/src/cli/types/api-responses.js +4 -2
  394. package/dist/server/src/config/cli-tool-timing-config.js +1 -6
  395. package/dist/server/src/config/uat-isolation.js +246 -0
  396. package/dist/server/src/lib/assistant-response-saver.js +62 -3
  397. package/dist/server/src/lib/auto-yes-lifecycle.js +6 -0
  398. package/dist/server/src/lib/auto-yes-poller.js +450 -160
  399. package/dist/server/src/lib/auto-yes-state.js +2 -2
  400. package/dist/server/src/lib/cli-tools/antigravity.js +38 -79
  401. package/dist/server/src/lib/cli-tools/base.js +151 -0
  402. package/dist/server/src/lib/cli-tools/codex.js +44 -80
  403. package/dist/server/src/lib/cli-tools/command-code.js +24 -56
  404. package/dist/server/src/lib/cli-tools/copilot.js +25 -67
  405. package/dist/server/src/lib/cli-tools/direct-input.js +8 -0
  406. package/dist/server/src/lib/cli-tools/gemini.js +23 -73
  407. package/dist/server/src/lib/cli-tools/opencode-pane-width.js +53 -0
  408. package/dist/server/src/lib/cli-tools/opencode-v2.js +9 -7
  409. package/dist/server/src/lib/cli-tools/opencode.js +21 -85
  410. package/dist/server/src/lib/cli-tools/submit-verified-sender.js +127 -4
  411. package/dist/server/src/lib/cli-tools/vibe-local.js +21 -66
  412. package/dist/server/src/lib/detection/cli-patterns.js +374 -3065
  413. package/dist/server/src/lib/detection/idle-evidence-observation.js +2 -2
  414. package/dist/server/src/lib/detection/prompt-detect-multiple-choice.js +7 -32
  415. package/dist/server/src/lib/detection/prompt-detector.js +2 -35
  416. package/dist/server/src/lib/detection/selection-shape-patterns.js +69 -0
  417. package/dist/server/src/lib/detection/selection-shape.js +32 -520
  418. package/dist/server/src/lib/detection/shared/pasted-text.js +41 -0
  419. package/dist/server/src/lib/detection/shared/shell-pane-command.js +16 -0
  420. package/dist/server/src/lib/detection/shared/strip-box-drawing.js +25 -0
  421. package/dist/server/src/lib/detection/tools/antigravity/detect.js +5 -29
  422. package/dist/server/src/lib/detection/tools/antigravity/dialog.js +2 -15
  423. package/dist/server/src/lib/detection/tools/antigravity/patterns.js +286 -0
  424. package/dist/server/src/lib/detection/tools/claude/detect.js +3 -14
  425. package/dist/server/src/lib/detection/tools/claude/patterns.js +264 -4
  426. package/dist/server/src/lib/detection/tools/claude/prompt.js +2 -10
  427. package/dist/server/src/lib/detection/tools/codex/detect.js +46 -85
  428. package/dist/server/src/lib/detection/tools/codex/live-region.js +33 -2
  429. package/dist/server/src/lib/detection/tools/codex/patterns.js +855 -0
  430. package/dist/server/src/lib/detection/tools/codex/prompt.js +2 -10
  431. package/dist/server/src/lib/detection/tools/command-code/detect.js +8 -50
  432. package/dist/server/src/lib/detection/tools/command-code/dialog.js +2 -18
  433. package/dist/server/src/lib/detection/tools/command-code/patterns.js +234 -0
  434. package/dist/server/src/lib/detection/tools/command-code/selection-shape.js +461 -0
  435. package/dist/server/src/lib/detection/tools/context-above.js +20 -0
  436. package/dist/server/src/lib/detection/tools/copilot/detect.js +10 -35
  437. package/dist/server/src/lib/detection/tools/copilot/patterns.js +640 -0
  438. package/dist/server/src/lib/detection/tools/copilot/prompt.js +2 -10
  439. package/dist/server/src/lib/detection/tools/gemini/patterns.js +29 -0
  440. package/dist/server/src/lib/detection/tools/live-region-specs.js +1 -1
  441. package/dist/server/src/lib/detection/tools/opencode/detect.js +8 -49
  442. package/dist/server/src/lib/detection/tools/opencode/patterns.js +508 -0
  443. package/dist/server/src/lib/detection/tools/opencode-v2/detect.js +7 -42
  444. package/dist/server/src/lib/detection/tools/opencode-v2/patterns.js +63 -0
  445. package/dist/server/src/lib/detection/tools/run-detection.js +6 -47
  446. package/dist/server/src/lib/detection/tools/verdicts.js +59 -0
  447. package/dist/server/src/lib/detection/tools/vibe-local/patterns.js +20 -0
  448. package/dist/server/src/lib/detection/truncate-raw-content.js +38 -0
  449. package/dist/server/src/lib/detection/turn-abandoned.js +66 -0
  450. package/dist/server/src/lib/detection/unclassified-frame-tracker.js +2 -2
  451. package/dist/server/src/lib/global-state.js +16 -0
  452. package/dist/server/src/lib/hooks/agent-session-telemetry.js +4 -6
  453. package/dist/server/src/lib/hooks/permission-decision-state.js +2 -2
  454. package/dist/server/src/lib/hooks/sources/antigravity/history.js +11 -76
  455. package/dist/server/src/lib/hooks/sources/antigravity/hooks-config.js +63 -1
  456. package/dist/server/src/lib/hooks/sources/antigravity/source.js +16 -0
  457. package/dist/server/src/lib/hooks/sources/antigravity/transcript.js +3 -12
  458. package/dist/server/src/lib/hooks/sources/claude/history.js +17 -156
  459. package/dist/server/src/lib/hooks/sources/claude/queued-notice.js +53 -0
  460. package/dist/server/src/lib/hooks/sources/claude/source.js +33 -3
  461. package/dist/server/src/lib/hooks/sources/claude/transcript.js +3 -13
  462. package/dist/server/src/lib/hooks/sources/codex/history.js +11 -74
  463. package/dist/server/src/lib/hooks/sources/codex/hooks-config.js +147 -11
  464. package/dist/server/src/lib/hooks/sources/codex/relay-install.js +64 -21
  465. package/dist/server/src/lib/hooks/sources/codex/transcript.js +5 -15
  466. package/dist/server/src/lib/hooks/sources/command-code/history.js +20 -121
  467. package/dist/server/src/lib/hooks/sources/command-code/transcript.js +3 -13
  468. package/dist/server/src/lib/hooks/sources/copilot/hook-settings.js +161 -31
  469. package/dist/server/src/lib/hooks/sources/define-source.js +40 -55
  470. package/dist/server/src/lib/hooks/sources/event-mapper.js +2 -1
  471. package/dist/server/src/lib/hooks/sources/opencode/diff.js +3 -4
  472. package/dist/server/src/lib/hooks/sources/opencode/history.js +2 -1
  473. package/dist/server/src/lib/hooks/sources/opencode/launch-settings.js +2 -1
  474. package/dist/server/src/lib/hooks/sources/opencode/payloads.js +2 -1
  475. package/dist/server/src/lib/hooks/sources/opencode/ports.js +2 -1
  476. package/dist/server/src/lib/hooks/sources/opencode/subscription.js +4 -3
  477. package/dist/server/src/lib/hooks/sources/opencode/transcript.js +3 -16
  478. package/dist/server/src/lib/hooks/sources/opencode-v2/history.js +2 -1
  479. package/dist/server/src/lib/hooks/sources/opencode-v2/mappers.js +5 -4
  480. package/dist/server/src/lib/hooks/sources/opencode-v2/ports.js +2 -1
  481. package/dist/server/src/lib/hooks/sources/opencode-v2/subscription.js +3 -7
  482. package/dist/server/src/lib/hooks/sources/opencode-v2/usage.js +2 -1
  483. package/dist/server/src/lib/hooks/sources/pending-decisions.js +2 -1
  484. package/dist/server/src/lib/hooks/sources/registry.js +3 -2
  485. package/dist/server/src/lib/hooks/sources/transcript-history.js +262 -0
  486. package/dist/server/src/lib/hooks/sources/turn-body.js +31 -0
  487. package/dist/server/src/lib/hooks/tool-input-normalization-state.js +2 -2
  488. package/dist/server/src/lib/polling/antigravity-permission-receipts.js +2 -2
  489. package/dist/server/src/lib/polling/auto-yes-enter-fallback-state.js +142 -0
  490. package/dist/server/src/lib/polling/auto-yes-enter-fallback.js +187 -0
  491. package/dist/server/src/lib/polling/auto-yes-resolver.js +9 -3
  492. package/dist/server/src/lib/polling/auto-yes-suppression-reason.js +2 -0
  493. package/dist/server/src/lib/polling/auto-yes-suppression-state.js +2 -2
  494. package/dist/server/src/lib/polling/pending-scraped-response.js +190 -0
  495. package/dist/server/src/lib/polling/prompt-dedup-state.js +2 -2
  496. package/dist/server/src/lib/polling/prompt-dedup.js +2 -2
  497. package/dist/server/src/lib/polling/response-checker-dialog-gate.js +95 -0
  498. package/dist/server/src/lib/polling/response-checker-extraction-result.js +50 -0
  499. package/dist/server/src/lib/polling/response-checker-extraction-steps.js +670 -0
  500. package/dist/server/src/lib/polling/response-checker.js +641 -1142
  501. package/dist/server/src/lib/polling/response-dedup.js +3 -4
  502. package/dist/server/src/lib/polling/response-poller-constants.js +17 -0
  503. package/dist/server/src/lib/polling/response-poller-core.js +54 -20
  504. package/dist/server/src/lib/polling/startup-screen.js +142 -0
  505. package/dist/server/src/lib/polling/structured-history-gate.js +3 -2
  506. package/dist/server/src/lib/prompt-answer-semantic.js +178 -0
  507. package/dist/server/src/lib/prompt-answer-sender.js +5 -4
  508. package/dist/server/src/lib/push/failure-episode-state.js +2 -2
  509. package/dist/server/src/lib/push/notification-dedup.js +3 -4
  510. package/dist/server/src/lib/push/prompt-card-state.js +2 -2
  511. package/dist/server/src/lib/push/waiting-push-notifier.js +3 -4
  512. package/dist/server/src/lib/realtime/publisher-registry.js +3 -2
  513. package/dist/server/src/lib/realtime/terminal-broadcast.js +38 -5
  514. package/dist/server/src/lib/realtime/terminal-session-ownership.js +45 -0
  515. package/dist/server/src/lib/relay/relay-delivery.js +3 -2
  516. package/dist/server/src/lib/relay/relay-readiness.js +38 -1
  517. package/dist/server/src/lib/response-cleaner.js +24 -1
  518. package/dist/server/src/lib/response-extractor.js +16 -0
  519. package/dist/server/src/lib/schedule-manager.js +8 -10
  520. package/dist/server/src/lib/session/agent-event-ask-user-question.js +168 -0
  521. package/dist/server/src/lib/session/agent-event-awaiting-instruction.js +104 -0
  522. package/dist/server/src/lib/session/agent-event-dedup.js +539 -0
  523. package/dist/server/src/lib/session/agent-event-model.js +562 -0
  524. package/dist/server/src/lib/session/agent-event-record.js +10 -0
  525. package/dist/server/src/lib/session/agent-event-state.js +106 -1854
  526. package/dist/server/src/lib/session/agent-event-structured-state.js +109 -0
  527. package/dist/server/src/lib/session/agent-event-turn.js +811 -0
  528. package/dist/server/src/lib/session/agent-session-lifecycle.js +11 -2
  529. package/dist/server/src/lib/session/chat-turn-progress.js +322 -0
  530. package/dist/server/src/lib/session/claude-executor.js +45 -5
  531. package/dist/server/src/lib/session/claude-session.js +21 -65
  532. package/dist/server/src/lib/session/cli-session.js +17 -0
  533. package/dist/server/src/lib/session/current-output-builder.js +450 -1103
  534. package/dist/server/src/lib/session/current-output-history-writers.js +255 -0
  535. package/dist/server/src/lib/session/current-output-types.js +9 -0
  536. package/dist/server/src/lib/session/detection-divergence.js +55 -0
  537. package/dist/server/src/lib/session/global-session-constants.js +2 -13
  538. package/dist/server/src/lib/session/hook-turn-hold.js +102 -0
  539. package/dist/server/src/lib/session/layer-disagreement.js +2 -2
  540. package/dist/server/src/lib/session/opencode-session-store.js +2 -1
  541. package/dist/server/src/lib/session/prompt-view.js +26 -3
  542. package/dist/server/src/lib/session/prompt-waiting-composition.js +3 -2
  543. package/dist/server/src/lib/session/provisional-turn.js +3 -1
  544. package/dist/server/src/lib/session/send-user-message.js +1 -1
  545. package/dist/server/src/lib/session/session-starting-state.js +4 -6
  546. package/dist/server/src/lib/session/status-evidence-type.js +2 -0
  547. package/dist/server/src/lib/session/status-evidence.js +2 -2
  548. package/dist/server/src/lib/session/structured-status-merge.js +335 -0
  549. package/dist/server/src/lib/session/waiting-episode-state.js +3 -4
  550. package/dist/server/src/lib/session-cleanup.js +1 -5
  551. package/dist/server/src/lib/skills/install-plan.js +2 -1
  552. package/dist/server/src/lib/skills/snapshot-store.js +2 -2
  553. package/dist/server/src/lib/skills/uninstall-plan.js +2 -2
  554. package/dist/server/src/lib/timer-manager.js +6 -8
  555. package/dist/server/src/lib/tmux/geometry-delegation.js +3 -4
  556. package/dist/server/src/lib/tmux/legacy-session-alias.js +2 -1
  557. package/dist/server/src/lib/tmux/session-hooks.js +2 -1
  558. package/dist/server/src/lib/tmux/session-status-options.js +3 -3
  559. package/dist/server/src/lib/tmux/tmux-capture-cache.js +3 -2
  560. package/dist/server/src/lib/tmux/tmux.js +33 -59
  561. package/dist/server/src/lib/tui-accumulator.js +2 -2
  562. package/dist/server/src/lib/version-checker.js +6 -6
  563. package/dist/server/src/lib/ws-server.js +47 -11
  564. package/docs/en/user-guide/webapp-guide.md +27 -3
  565. package/package.json +1 -1
  566. package/release-notes/0.44.3.json +82 -0
  567. package/scripts/hooks/cmate-agent-event.sh +18 -0
  568. package/.next/server/chunks/1068.js +0 -1
  569. package/.next/server/chunks/4372.js +0 -5
  570. package/.next/server/chunks/6474.js +0 -14
  571. package/.next/server/chunks/967.js +0 -1
  572. package/.next/server/chunks/9798.js +0 -2
  573. package/.next/server/chunks/9882.js +0 -25
  574. package/.next/static/chunks/591-539fec878c9dec5e.js +0 -1
  575. package/.next/static/chunks/app/sessions/page-049e06335187aa91.js +0 -1
  576. package/.next/static/chunks/app/worktrees/[id]/page-2a81397e60f17e63.js +0 -1
  577. package/.next/static/css/38070d879efa1371.css +0 -1
  578. package/dist/server/src/lib/cli-tools/index.js +0 -41
  579. package/dist/server/src/lib/polling/global-session-poller.js +0 -140
  580. /package/.next/static/{QlCqLjorauDDBXPa-C7TK → tWwHQzmvc-rv9KKUtDWfQ}/_buildManifest.js +0 -0
  581. /package/.next/static/{QlCqLjorauDDBXPa-C7TK → tWwHQzmvc-rv9KKUtDWfQ}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1479],{8269:(e,t,n)=>{"use strict";n.d(t,{hU:()=>r});var a=n(12115);function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onSwipeLeft:t,onSwipeRight:n,onSwipeUp:r,onSwipeDown:s,threshold:l=50,enabled:i=!0,axis:o="both",directionLock:c,directionLockThreshold:d=12,suppressWhenScrollable:u=!0,edgeStartZone:m=0,onSwipeMove:x,onSwipeEnd:f}=e,h=null!=c?c:"both"!==o,p="horizontal"===o?"horizontal":"vertical",g="both"===o||"horizontal"===o,b="both"===o||"vertical"===o,v=(0,a.useRef)(null),[y,j]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),N=(0,a.useRef)(null),C=(0,a.useRef)(null),S=(0,a.useCallback)(()=>{k(null)},[]),I=(0,a.useCallback)(e=>{if(!i)return;if(u&&e.target instanceof HTMLElement&&function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vertical",n=e;for(;n;){let e=getComputedStyle(n);if("horizontal"===t){let{overflowX:t}=e;if(("auto"===t||"scroll"===t)&&n.scrollWidth>n.clientWidth)return!0}else{let{overflowY:t}=e;if(("auto"===t||"scroll"===t)&&n.scrollHeight>n.clientHeight)return!0}n=n.parentElement}return!1}(e.target,p)){N.current=null;return}let t=e.touches[0];if(m>0&&v.current){let e=v.current.getBoundingClientRect(),n=t.clientX-e.left,a=e.right-t.clientX;if(n>m&&a>m){N.current=null;return}}N.current={x:t.clientX,y:t.clientY},C.current={committed:null,cancelled:!1},j(!0)},[i,u,p,m]),T=(0,a.useCallback)(e=>{if(!i||!N.current)return;let t=e.touches[0],n=t.clientX-N.current.x,a=t.clientY-N.current.y,r=Math.abs(n),s=Math.abs(a);if(h){let e=C.current;if(e){if(e.cancelled)return;if(null===e.committed&&Math.max(r,s)>=d){let t=r>s?"horizontal":"vertical";if(e.committed=t,t!==o){e.cancelled=!0;return}}if(null!==e.committed&&e.committed!==o)return}}g&&r>s&&r>=l?k(n<0?"left":"right"):b&&s>=l&&k(a<0?"up":"down"),null==x||x({deltaX:n,deltaY:a})},[i,l,o,h,d,g,b,x]),E=(0,a.useCallback)(e=>{var a;if(!i||!N.current)return void j(!1);let o=h&&(null==(a=C.current)?void 0:a.cancelled)===!0,c=e.changedTouches[0];if(!o&&c){let e=c.clientX-N.current.x,a=c.clientY-N.current.y,i=Math.abs(e),o=Math.abs(a);i>o?g&&i>=l&&(e<0?(k("left"),null==t||t()):(k("right"),null==n||n())):b&&o>=l&&(a<0?(k("up"),null==r||r()):(k("down"),null==s||s()))}N.current=null,C.current=null,j(!1),null==f||f()},[i,l,h,g,b,t,n,r,s,f]),A=(0,a.useCallback)(()=>{N.current&&(N.current=null,C.current=null,j(!1),null==f||f())},[f]);return(0,a.useEffect)(()=>{let e=v.current;if(e)return e.addEventListener("touchstart",I),e.addEventListener("touchmove",T),e.addEventListener("touchend",E),e.addEventListener("touchcancel",A),()=>{e.removeEventListener("touchstart",I),e.removeEventListener("touchmove",T),e.removeEventListener("touchend",E),e.removeEventListener("touchcancel",A)}},[I,T,E,A]),{ref:v,isSwiping:y,swipeDirection:w,resetSwipeDirection:S}}},11063:(e,t,n)=>{"use strict";n.d(t,{Ko:()=>r,j6:()=>a}),n(19985);let a=5242880,r={safe:"",interactive:"allow-scripts"}},17846:(e,t,n)=>{"use strict";n.d(t,{a:()=>l});var a=n(95155),r=n(12115),s=n(18955);function l(e){let{src:t,alt:n,onError:l}=e,i=(0,s.c)("worktree"),[o,c]=(0,r.useState)(!1);return o?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,a.jsx)("p",{className:"text-sm",children:i("imageViewer.loadError")}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:n})]}):(0,a.jsx)("div",{className:"flex items-center justify-center p-4",children:(0,a.jsx)("img",{src:t,alt:n,onError:()=>{c(!0),null==l||l()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}},20252:(e,t,n)=>{Promise.resolve().then(n.bind(n,84237))},27307:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PdfPreview:()=>o,default:()=>c});var a=n(95155),r=n(12115),s=n(18955);n(19985);let l=void 0;var i=n(3005);function o(e){let{dataUri:t,filePath:n,variant:o="iframe"}=e,[c,d]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),x=(0,s.c)("worktree");if((0,r.useEffect)(()=>{let e=!1,n=null;return d(null),m(!1),(async()=>{try{let a=await fetch(t);if(!a.ok)throw Error("fetch failed: ".concat(a.status));let r=await a.blob();if(e)return;n=URL.createObjectURL(r),d(n)}catch(t){if(e)return;m(!0)}})(),()=>{e=!0,n&&URL.revokeObjectURL(n)}},[t,n]),u)return(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-3 p-6 text-center","data-testid":"pdf-preview-error",children:[(0,a.jsx)("p",{className:"text-sm text-danger-foreground",children:x("pdfPreview.loadError")}),(0,a.jsx)("a",{href:t,download:n.split("/").pop()||"document.pdf",className:"inline-flex items-center gap-2 px-4 py-2 rounded-md border border-input text-sm text-foreground hover:bg-muted",rel:"noopener",children:x("pdfPreview.downloadPdf")})]});if(!c)return(0,a.jsx)("div",{className:"h-full flex items-center justify-center","data-testid":"pdf-preview-loading",children:(0,a.jsx)(i.y,{size:"xl",variant:"accent"})});if("download"===o){let e=n.split("/").pop()||"document.pdf";return(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-4 p-6 text-center","data-testid":"pdf-preview-download",children:[(0,a.jsx)("svg",{className:"w-16 h-16 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,a.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,a.jsx)("p",{className:"text-sm text-foreground break-all",children:e}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 w-full max-w-xs",children:[(0,a.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-6 py-3 rounded-lg bg-accent-600 hover:bg-accent-700 active:bg-accent-800 text-white text-sm font-medium transition-colors",children:x("pdfPreview.openInNewTab")}),(0,a.jsx)("a",{href:c,download:e,className:"inline-flex items-center justify-center gap-2 px-6 py-2 rounded-lg border border-input text-sm text-foreground hover:bg-muted transition-colors",children:x("pdfPreview.download")})]})]})}return(0,a.jsx)("iframe",{src:c,sandbox:l,title:x("pdfPreview.title",{path:n}),className:"w-full h-full border-0 bg-white","data-testid":"pdf-preview-iframe"})}let c=o},43424:(e,t,n)=>{"use strict";n.d(t,{OO:()=>l,cx:()=>r,hO:()=>s});let a="commandmate.lastOpenedWorktreeId";function r(){try{return window.localStorage.getItem(a)||null}catch(e){return null}}function s(e){if(e)try{window.localStorage.setItem(a,e)}catch(e){}}function l(e){let{lastOpenedId:t,worktreeIds:n}=e;return t&&n.includes(t)?"/worktrees/".concat(encodeURIComponent(t)):"/sessions"}},51434:(e,t,n)=>{"use strict";n.d(t,{C:()=>r});var a=n(12115);function r(){let[e,t]=(0,a.useState)(!1),[n,r]=(0,a.useState)(0),[s,l]=(0,a.useState)(null),i=(0,a.useCallback)(()=>{if(null==window.visualViewport)return;let e=window.visualViewport,n=window.innerHeight,a=e.height,s=n-a,i=s>100;t(i),r(i?s:0),l(a)},[]);return(0,a.useEffect)(()=>{if(null==window.visualViewport)return;let e=window.visualViewport;return i(),e.addEventListener("resize",i),()=>{e.removeEventListener("resize",i)}},[i]),{isKeyboardVisible:e,keyboardHeight:n,viewportHeight:s}}},56639:(e,t,n)=>{"use strict";n.d(t,{iA:()=>d});var a=n(12115),r=n(69352);let s=["http:","https:","data:","blob:","//","/","#","mailto:","javascript:"],l=/^\s*<!doctype/i;function i(e){return new DOMParser().parseFromString(e,"text/html")}var o=n(76246);async function c(e,t){try{let n=await fetch("/api/worktrees/".concat(e,"/files/").concat((0,o.o)(t)));if(!n.ok)return null;let a=await n.json();if(!a||"object"!=typeof a)return null;let{isImage:r,content:s}=a;if(!0!==r||"string"!=typeof s||!s.startsWith("data:"))return null;return s}catch(e){return null}}function d(e,t,n){let[o,d]=(0,a.useState)(null),u=(0,a.useMemo)(()=>(function(e,t){let n=i(e),a=new Set,l=[];for(let e of Array.from(n.querySelectorAll("img[src]"))){var o;let n=null!=(o=e.getAttribute("src"))?o:"";if(a.has(n)||!function(e){if(!e)return!1;let t=e.toLowerCase();return!s.some(e=>t.startsWith(e))}(n))continue;let i=(0,r.WU)(t,n);null!==i&&(a.add(n),l.push({src:n,resolvedPath:i}))}return l})(n,t).slice(0,50),[n,t]);return((0,a.useEffect)(()=>{if(0===u.length)return;let a=!1;return Promise.all(u.map(t=>{let{resolvedPath:n}=t;return c(e,n)})).then(r=>{if(a)return;let s=new Map,o=0;r.forEach((e,t)=>{null!==e&&(o+e.length>2e7||(o+=e.length,s.set(u[t].src,e)))}),d({worktreeId:e,filePath:t,htmlContent:n,html:function(e,t){if(0===t.size)return e;let n=i(e);for(let e of Array.from(n.querySelectorAll("img[src]"))){var a;let n=t.get(null!=(a=e.getAttribute("src"))?a:"");void 0!==n&&e.setAttribute("src",n)}let r=n.documentElement.outerHTML;return l.test(e)?"<!DOCTYPE html>\n".concat(r):r}(n,s)})}).catch(()=>{}),()=>{a=!0}},[e,t,n,u]),o&&o.worktreeId===e&&o.filePath===t&&o.htmlContent===n)?o.html:n}},60850:(e,t,n)=>{"use strict";n.d(t,{U:()=>r});var a=n(12115);function r(e){let{value:t,saveFn:n,debounceMs:r=300,disabled:s=!1,maxRetries:l=3,onSaveComplete:i}=e,[o,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(null),m=(0,a.useRef)(t),x=(0,a.useRef)(n),f=(0,a.useRef)(i),h=(0,a.useRef)(null),p=(0,a.useRef)(!0),g=(0,a.useRef)(t);(0,a.useEffect)(()=>{m.current=t},[t]),(0,a.useEffect)(()=>{x.current=n},[n]),(0,a.useEffect)(()=>{f.current=i},[i]),(0,a.useEffect)(()=>(p.current=!0,()=>{p.current=!1,h.current&&clearTimeout(h.current)}),[]);let b=(0,a.useCallback)(async e=>{if(!p.current)return;c(!0),u(null);let t=null,n=0;for(;n<=l;)try{if(await x.current(e),p.current){var a;c(!1),u(null),null==(a=f.current)||a.call(f)}return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++n<=l){let e=1e3*Math.pow(2,n-1);await new Promise(t=>setTimeout(t,e))}}p.current&&(c(!1),u(t))},[l]),v=(0,a.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),y=(0,a.useCallback)(async()=>{s||(v(),await b(m.current))},[s,v,b]);return(0,a.useEffect)(()=>{if(t!==g.current&&!s)return v(),h.current=setTimeout(()=>{b(m.current)},r),()=>{v()}},[t,s,r,v,b]),{isSaving:o,error:d,saveNow:y}}},64269:(e,t,n)=>{"use strict";function a(e,t){let n=null,a=function(){for(var a=arguments.length,r=Array(a),s=0;s<a;s++)r[s]=arguments[s];n&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)};return a.cancel=()=>{n&&clearTimeout(n),n=null},a}function r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s(e){let t=new Set;for(let n of e){t.add(n);let e=n.split("/"),a="";for(let n=0;n<e.length-1;n++)a=a?"".concat(a,"/").concat(e[n]):e[n],t.add(a)}return t}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;return e.length<=t?e:"".concat(e.substring(0,t-3),"...")}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}n.d(t,{Nt:()=>r,W5:()=>l,ZD:()=>i,q3:()=>s,sg:()=>a})},69264:(e,t,n)=>{"use strict";n.d(t,{u:()=>i});var a=n(95155),r=n(12115),s=n(18955),l=n(3005);function i(e){let{src:t,onError:n}=e,i=(0,s.c)("worktree"),[o,c]=(0,r.useState)(!0),[d,u]=(0,r.useState)(!1);return d?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),(0,a.jsx)("p",{className:"text-sm",children:i("videoViewer.loadError")})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4",children:[o&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,a.jsx)(l.y,{size:"xl",variant:"accent"}),(0,a.jsx)("p",{className:"ml-3 text-muted-foreground",children:i("videoViewer.loading")})]}),(0,a.jsx)("video",{controls:!0,src:t,onLoadedData:()=>{c(!1)},onError:()=>{c(!1),u(!0),null==n||n()},style:{maxWidth:"100%",maxHeight:"500px",display:o?"none":"block"},className:"rounded-lg shadow-sm",children:i("videoViewer.unsupported")})]})}},84237:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>cf});var a,r=n(95155),s=n(12115),l=n(20063),i=n(18955),o=n(37772),c=n(3005),d=n(48407),u=n(48481),m=n(76471),x=n(92614),f=n(64269);let h=(0,s.memo)(function(e){let{path:t,className:n="w-6 h-6"}=e;return(0,r.jsx)("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),p={menu:"M4 6h16M4 12h16M4 18h16",search:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"};function g(e){let{worktreeName:t,repositoryName:n,status:a,statusUnclassified:s,gitStatus:l,onMenuClick:o}=e,c=(0,i.c)("common"),g=(0,i.c)("worktree"),b=(0,i.c)("commandPalette"),{setOpen:v}=(0,x.C)(),y=(0,m.Mq)(a,s);return(0,r.jsx)("header",{"data-testid":"mobile-header",role:"banner",className:"sticky top-0 inset-x-0 bg-surface border-b border-border shadow-sm pt-safe z-40",children:(0,r.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[(0,r.jsx)("div",{className:"w-10 flex-shrink-0",children:o&&(0,r.jsx)(d.$n,{variant:"ghost",type:"button","data-testid":"mobile-header-menu-button",onClick:o,"aria-label":c("menu"),className:"p-2 -ml-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(h,{path:p.menu})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:[(0,r.jsx)(u.m,{"data-testid":"status-indicator",status:a,size:"sm",label:y?c(m.rH):void 0,className:y?"mr-2 ".concat(m.Jd):"mr-2","data-unclassified":y?"true":void 0}),(0,r.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[(0,r.jsx)("h1",{role:"heading","data-testid":"worktree-name",title:t,className:"text-sm font-medium text-foreground truncate text-center leading-tight",children:t}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[n&&(0,r.jsx)("span",{className:"truncate max-w-[100px] text-center",children:n}),l&&"(unknown)"!==l.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[n&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[80px] font-mono",title:l.currentBranch,"data-testid":"mobile-branch-name",children:(0,f.W5)(l.currentBranch,20)}),l.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:g("git.uncommittedChanges"),children:"*"})]})]})]})]}),(0,r.jsx)("div",{className:"w-10 flex-shrink-0 flex items-center justify-end",children:(0,r.jsx)(d.$n,{variant:"ghost",type:"button","data-testid":"mobile-header-command-palette-trigger",onClick:()=>v(!0),"aria-label":b("mobileTrigger"),title:b("mobileTrigger"),className:"p-2 -mr-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(h,{path:p.search})})})]})})}var b=n(22479),v=n(26983),y=n(70198),j=n(53842),w=n(23327);function k(e){let{"data-testid":t,"aria-label":n,className:a=""}=e;return(0,r.jsx)("span",{"data-testid":t,className:"w-2 h-2 rounded-full bg-accent-500 ".concat(a).trim(),"aria-label":n})}let N=[{id:"terminal",labelKey:"tabs.terminal",icon:(0,r.jsx)(b.A,{size:20,"aria-hidden":"true"})},{id:"history",labelKey:"tabs.history",icon:(0,r.jsx)(v.A,{size:20,"aria-hidden":"true"})},{id:"files",labelKey:"tabs.files",icon:(0,r.jsx)(y.A,{size:20,"aria-hidden":"true"})},{id:"memo",labelKey:"tabs.memo",icon:(0,r.jsx)(j.A,{size:20,"aria-hidden":"true"})},{id:"info",labelKey:"tabs.info",icon:(0,r.jsx)(w.A,{size:20,"aria-hidden":"true"})}];function C(e){let{activeTab:t,onTabChange:n,hasNewOutput:a=!1,hasPrompt:l=!1,hasUpdate:o=!1,onSearchParamsChange:c,inFlow:d=!1}=e,u=(0,i.c)("worktree"),m=(0,s.useRef)([]),x=(0,s.useCallback)(e=>{let n=e===t;return"".concat("flex flex-col items-center justify-center flex-1 min-h-[44px] py-2 px-1 transition-colors relative touch-manipulation"," ").concat(n?"text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground")},[t]),f=(0,s.useCallback)(e=>{n(e),null==c||c("memo"===e?"notes":e)},[n,c]),h=(0,s.useCallback)((e,t)=>{var n;let a=null;switch(e.key){case"ArrowRight":case"ArrowDown":a=(t+1)%N.length;break;case"ArrowLeft":case"ArrowUp":a=(t-1+N.length)%N.length;break;case"Home":a=0;break;case"End":a=N.length-1;break;default:return}e.preventDefault(),null==(n=m.current[a])||n.focus(),f(N[a].id)},[f]),p=(0,s.useMemo)(()=>(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)("span",{"data-testid":"new-output-badge",className:"absolute top-1 right-1 w-2 h-2 bg-success rounded-full","aria-label":u("tabs.newOutput")}),l&&(0,r.jsx)("span",{"data-testid":"prompt-badge",className:"absolute top-1 right-3 w-2 h-2 bg-warning rounded-full","aria-label":u("tabs.promptWaiting")})]}),[a,l,u]);return(0,r.jsx)("nav",{"data-testid":"mobile-tab-bar",role:"tablist","aria-label":u("tabs.ariaLabel"),className:"".concat(d?"flex-shrink-0":"fixed bottom-0"," inset-x-0 border-t border-border bg-background supports-[backdrop-filter]:bg-background/80 backdrop-blur-md flex pb-safe z-40"),children:N.map((e,n)=>(0,r.jsxs)("button",{ref:e=>{m.current[n]=e},type:"button","data-testid":"mobile-tab-".concat(e.id),role:"tab","aria-selected":t===e.id,"aria-label":u(e.labelKey),tabIndex:t===e.id?0:-1,onClick:()=>f(e.id),onKeyDown:e=>h(e,n),className:x(e.id),children:[t===e.id&&(0,r.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 inset-x-2 h-0.5 rounded-full bg-accent-500"}),e.icon,(0,r.jsx)("span",{className:"text-xs mt-1 whitespace-nowrap",children:u(e.labelKey)}),"terminal"===e.id&&p,"info"===e.id&&o&&(0,r.jsx)(k,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":u("tabs.updateAvailable")})]},e.id))})}function S(e){return null!=e&&"unclassified"!==e.type}var I=n(87364);let T={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function E(e){let{visible:t,duration:n=200}=e,[a,r]=(0,s.useState)(t?"visible":"hidden"),l=(0,s.useRef)(null),i=(0,s.useRef)(t);(0,s.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),(0,s.useEffect)(()=>{let e=i.current;i.current=t,l.current&&(clearTimeout(l.current),l.current=null);let a=e=>{l.current=setTimeout(()=>{r(e),l.current=null},n)};t&&!e?(r("fade-in"),a("visible")):!t&&e?(r("fade-out"),a("hidden")):t?r(e=>"fade-out"===e?(a("visible"),"fade-in"):e):r(e=>"fade-in"===e?(a("hidden"),"fade-out"):e)},[t,n]);let o="hidden"!==a,c="fade-in"===a||"fade-out"===a;return{shouldRender:o,animationClass:(0,s.useMemo)(()=>{switch(a){case"fade-in":return T.fadeIn;case"fade-out":return T.fadeOut;default:return T.none}},[a]),isAnimating:c}}var A=n(92539),M=n(8269),R=n(14271);let L=/^\[[ xX\u2714]\] /;function P(e){return!0===e.multiSelect||e.options.some(e=>L.test(e.label))}function D(e){var t,n;return"multiple_choice"!==e.type||!0===e.multiSelect?null:null!=(n=null==(t=e.options.find(e=>e.isDefault))?void 0:t.number)?n:null}function F(e){return"multiple_choice"!==e.type||!0!==e.multiSelect?[]:e.options.filter(e=>!0===e.checked).map(e=>e.number)}function O(e,t){let n=(0,R.SD)(t);return"text"in n?n.text:"values"in n?e(n.key,n.values):e(n.key)}function z(e,t){return(null==e?void 0:e.type)==="multiple_choice"&&P(e)||!1===t}function _(e){let{promptData:t,answering:n,answerable:a,send:r,onError:l,canRespondDecision:i=!0}=e,[o,c]=(0,s.useState)(()=>D(t)),[d,u]=(0,s.useState)(()=>F(t)),[m,x]=(0,s.useState)(""),[f,h]=(0,s.useState)(!1),p=function(e){let t=[e.question];if("multiple_choice"===e.type){var n,a;for(let r of(t.push(String(null!=(a=null==(n=e.askUserQuestion)?void 0:n.questionIndex)?a:"")),e.options))t.push("".concat(r.number,":").concat(r.label))}return t.join("\0")}(t),[g,b]=(0,s.useState)(p);p!==g&&(b(p),c(D(t)),u(F(t)),x(""));let v="multiple_choice"===t.type&&!0===t.multiSelect?t.options:null,y=(0,s.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===o))?e:null},[t,o]),j=(0,s.useMemo)(()=>(null!=v?v:[]).filter(e=>d.includes(e.number)&&(0,R.$y)(e)).map(e=>e.number),[v,d]),w=null!==v?j.length>0:null!==y&&(0,R.$y)(y),k=n||f,N=k||!1===a,C=(0,s.useCallback)((e,t)=>{u(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},[]),S=(0,s.useCallback)(async e=>{if(!N){h(!0);try{await r(e)}catch(e){null==l||l(e)}finally{h(!1)}}},[N,r,l]),I=(0,s.useCallback)(async()=>{if(!N&&null!==o){h(!0);try{let e=w&&m.trim()?m.trim():o.toString();await r(e)}catch(e){null==l||l(e)}finally{h(!1)}}},[N,r,l,o,w,m]),T=(0,s.useCallback)(async()=>{if(N)return;let e=[...d].sort((e,t)=>e-t);if(0===e.length)return;let t=w?m.trim():e.join(",");if(""!==t){h(!0);try{await r(t)}catch(e){null==l||l(e)}finally{h(!1)}}},[N,r,l,d,w,m]),E=(0,s.useCallback)(async e=>{if(!N&&i){h(!0);try{await r(e)}catch(e){null==l||l(e)}finally{h(!1)}}},[N,i,r,l]);return{selectedOption:o,setSelectedOption:c,checkedNumbers:d,textInputValue:m,setTextInputValue:x,multiSelectOptions:v,selectedOptionData:y,takesTypedText:w,isBusy:k,isDisabled:N,handleToggleOption:C,handleYesNoClick:S,handleMultipleChoiceSubmit:I,handleMultiSelectSubmit:T,handleDecisionRespond:E}}let B={"opencode-v2":{once:"Allow once",always:"Always allow",reject:"Reject"}};function V(e,t){let n=B[t];if(!e||!n)return e;let a=e.decisionOptions;return Array.isArray(a)&&0!==a.length?{...e,decisionOptions:a.map(e=>"string"==typeof e.reply&&n[e.reply]?{...e,label:n[e.reply]}:e)}:e}let H=/^\d+(?:\s*[,\s]\s*\d+)*$/;function U(e){let t=e.trim();return""===t||t.length>1e3||H.test(t)?null:t}function K(e){return H.test(e.trim())}function W(e){let{showStuckHint:t,onSwitchToDirectInput:n,answerable:a,autoYesEnterSent:s,linkClassName:l}=e,o=(0,i.c)("worktree"),c=o("promptResponse.stuckHintLink");return!1===a&&!0===s?(0,r.jsx)("p",{"data-testid":"prompt-auto-yes-enter-sent",role:"status",className:"mt-3 text-sm text-muted-foreground",children:o("promptResponse.autoYesEnterSent")}):!1===a?(0,r.jsxs)("p",{"data-testid":"prompt-unanswerable-hint",className:"mt-3 text-sm text-warning-foreground",children:[o("promptResponse.unanswerable"),n&&(0,r.jsxs)(r.Fragment,{children:[" ",(0,r.jsx)("button",{type:"button","data-testid":"prompt-stuck-hint-link",onClick:n,"aria-label":c,className:l,children:c})]})]}):t&&n?(0,r.jsxs)("p",{"data-testid":"prompt-stuck-hint",className:"mt-3 text-sm text-warning-foreground",children:[o("promptResponse.stuckHint")," ",(0,r.jsx)("button",{type:"button","data-testid":"prompt-stuck-hint-link",onClick:n,"aria-label":c,className:l,children:c})]}):null}let q={base:"px-6 py-3 rounded-lg font-medium transition-all touch-manipulation disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2",primary:"bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",secondary:"bg-muted border-2 border-input hover:bg-muted/80 text-foreground focus:ring-ring",defaultSelected:"bg-muted-foreground text-background hover:bg-muted-foreground/90"},$=(0,s.memo)(function(e){let{promptData:t,visible:n,answering:a,onRespond:l,onDismiss:i,cliToolName:o,showStuckHint:c,onSwitchToDirectInput:d,answerable:u,autoYesEnterSent:m}=e,{shouldRender:x,animationClass:f}=E({visible:n&&null!==t,duration:300}),h=(0,s.useId)(),p=n&&null!==t,g=(0,A.r)({active:p}),[b,v]=(0,s.useState)(0);(0,s.useEffect)(()=>{n||v(0)},[n]);let y=(0,s.useCallback)(e=>{let{deltaY:t}=e;v(t>0?t:0)},[]),j=(0,s.useCallback)(()=>{null==i||i()},[i]),w=(0,s.useCallback)(()=>{v(0)},[]),{ref:k}=(0,M.hU)({axis:"vertical",threshold:100,enabled:p,onSwipeMove:y,onSwipeDown:j,onSwipeEnd:w}),N=(0,s.useCallback)(e=>{g.current=e,k.current=e},[g,k]),C=(0,s.useCallback)(()=>{i&&i()},[i]),S=(0,s.useCallback)(e=>{e.stopPropagation()},[]);if(!x||!t)return null;let T="animate-fade-out"===f;return(0,r.jsxs)(I.t,{componentName:"MobilePromptSheet",children:[(0,r.jsx)("div",{"data-testid":"prompt-overlay",onClick:C,className:"fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ".concat(T?"opacity-0":"opacity-100"," ").concat(T?"pointer-events-none":""),"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:N,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":h,onClick:S,style:{transform:b>0?"translateY(".concat(b,"px)"):void 0},className:"fixed bottom-0 inset-x-0 bg-surface rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ".concat(T?"translate-y-full":"translate-y-0"),children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-input rounded-full","aria-hidden":"true"})}),(0,r.jsxs)("div",{className:"px-4 pb-6",children:[(0,r.jsx)(G,{promptData:t,answering:a,onRespond:l,labelId:h,cliToolName:o,answerable:u}),(0,r.jsx)(W,{showStuckHint:c,onSwitchToDirectInput:d,answerable:u,autoYesEnterSent:m,linkClassName:"underline font-medium min-h-[44px] touch-manipulation"})]})]})]})});function G(e){let{promptData:t,answering:n,onRespond:a,labelId:s,cliToolName:l,answerable:o}=e,c=(0,i.c)("prompt"),{selectedOption:u,setSelectedOption:m,checkedNumbers:x,textInputValue:f,setTextInputValue:h,multiSelectOptions:p,takesTypedText:g,isBusy:b,isDisabled:v,handleToggleOption:y,handleYesNoClick:j,handleMultipleChoiceSubmit:w,handleMultiSelectSubmit:k,handleDecisionRespond:N}=_({promptData:t,answering:n,answerable:o,send:a}),C=(0,R.ds)(t),I=S(t)?t:null,T=null===I?t:null;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{id:s,className:"text-lg font-semibold text-foreground",children:l?c("confirmationFrom",{toolName:l}):c("confirmationFromClaude")}),(null==I?void 0:I.instructionText)&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-muted-foreground bg-muted rounded p-2 border border-border",children:I.instructionText}),"multiple_choice"===t.type&&t.askUserQuestion&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ask-user-question-progress",children:t.askUserQuestion.questionCount>1?c("askUserQuestionProgress",{index:t.askUserQuestion.questionIndex+1,total:t.askUserQuestion.questionCount}):c("askUserQuestionSource")}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:O(c,C.heading)}),b&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[(0,r.jsx)(d.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:c("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(J,{promptData:t,disabled:v,onYes:()=>j("yes"),onNo:()=>j("no")}),null!==T&&(0,r.jsx)(X,{promptData:T,view:C,disabled:v,onRespond:N}),"multiple_choice"===t.type&&null!==p&&(0,r.jsx)(Q,{promptData:t,disabled:v,checkedNumbers:x,onToggleOption:y,textInputValue:f,onTextInputChange:h,showTextInput:g,onSubmit:k}),"multiple_choice"===t.type&&null===p&&(0,r.jsx)(Y,{promptData:t,disabled:v,selectedOption:u,onSelectOption:m,textInputValue:f,onTextInputChange:h,showTextInput:g,onSubmit:w})]})}let J=(0,s.memo)(function(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,i.c)("prompt"),o="yes"===t.defaultOption,c="no"===t.defaultOption;return(0,r.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)("button",{type:"button",onClick:a,disabled:n,className:"flex-1 ".concat(q.base," ").concat(q.primary," ").concat(o?"ring-2 ring-accent-300":""),children:l("yes")}),(0,r.jsx)("button",{type:"button",onClick:s,disabled:n,className:"flex-1 ".concat(q.base," ").concat(c?q.defaultSelected:q.secondary),children:l("no")})]})}),Y=(0,s.memo)(function(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:l,textInputValue:o,onTextInputChange:c,showTextInput:u,onSubmit:m}=e,x=(0,s.useId)(),f=(0,i.c)("prompt");return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:f("selectAnOption")}),(0,r.jsx)(d.z6,{name:x,value:null!=a?String(a):"",onValueChange:e=>l(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>{let t=a===e.number;return(0,r.jsxs)("label",{className:"flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ".concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(n?"opacity-50 cursor-not-allowed":""),children:[(0,r.jsx)(d.CU,{value:String(e.number),className:"mt-1"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium text-foreground",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{className:"ml-2 text-xs text-accent-600 bg-accent-100 px-2 py-0.5 rounded",children:f("default")}),e.description&&(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground break-words",children:e.description})]})]},e.number)})})]}),u&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:o,onChange:e=>c(e.target.value),disabled:n,placeholder:f("enterValuePlaceholder"),inputMode:"text",enterKeyHint:"done",className:"w-full px-4 py-3 border-2 border-input rounded-lg bg-surface text-foreground focus:outline-none focus:border-ring disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:m,disabled:n||null===a,className:"w-full ".concat(q.base," ").concat(q.primary),children:f("submit")})]})}),Q=(0,s.memo)(function(e){let{promptData:t,disabled:n,checkedNumbers:a,onToggleOption:l,textInputValue:o,onTextInputChange:c,showTextInput:u,onSubmit:m}=e,x=(0,s.useId)(),f=(0,i.c)("prompt"),h=0===a.length,p=u&&""===o.trim();return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"multi-select-prompt-actions",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"multi-select-hint",children:f("multiSelectHint")}),(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:f("selectAllThatApply")}),(0,r.jsx)("div",{role:"group","aria-label":f("selectAllThatApply"),className:"flex flex-col gap-2",children:t.options.map(e=>{let t=a.includes(e.number);return(0,r.jsxs)("label",{className:"flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ".concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(n?"opacity-50 cursor-not-allowed":""),children:[(0,r.jsx)(d.Sc,{checked:t,onCheckedChange:t=>l(e.number,!0===t),disabled:n,className:"mt-1","data-testid":"multi-select-option-".concat(e.number),"aria-label":"".concat(e.number,". ").concat(e.label)}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium text-foreground",children:[e.number,". ",e.label]}),e.description&&(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground break-words",children:e.description})]})]},e.number)})})]}),u&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"multi-text-input-".concat(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"multi-text-input-".concat(x),type:"text",value:o,onChange:e=>c(e.target.value),disabled:n,placeholder:f("enterValuePlaceholder"),inputMode:"text",enterKeyHint:"done",className:"w-full px-4 py-3 border-2 border-input rounded-lg bg-surface text-foreground focus:outline-none focus:border-ring disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button","data-testid":"multi-select-submit",onClick:m,disabled:n||h||p,className:"w-full ".concat(q.base," ").concat(q.primary),children:f("submit")})]})});function X(e){let{promptData:t,view:n,disabled:a,onRespond:s}=e,l=t.message,i="approval"===n.apiTarget?t.decisionOptions:null,o="question"===n.apiTarget?(0,R.zM)(t):null,c=t.askUserQuestion;return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"mobile-structured-decision",children:[c&&!o&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"unclassified-ask-user-question",children:[(0,r.jsx)("p",{className:"text-sm text-foreground break-words",children:c.question}),(0,r.jsx)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:c.labels.map(e=>(0,r.jsx)("li",{children:e},e))})]}),l&&(0,r.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-all rounded border border-border bg-muted p-2 font-mono text-xs text-foreground","data-testid":"mobile-structured-decision-message",children:l}),i?(0,r.jsx)("div",{className:"flex flex-col gap-2",role:"group","data-testid":"mobile-structured-decision-actions",children:i.map(e=>(0,r.jsxs)("button",{type:"button",disabled:a,onClick:()=>void s(String(e.number)),"data-testid":"mobile-structured-decision-option-".concat(e.number),className:"w-full ".concat(q.base," ").concat("reject"===e.reply?q.secondary:q.primary),children:[e.number,". ",e.label]},e.number))}):o?(0,r.jsx)(Z,{choices:o,disabled:a,onRespond:s}):null]})}function Z(e){let{choices:t,disabled:n,onRespond:a}=e,l=(0,i.c)("prompt"),o=(0,s.useId)(),[c,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(""),f=t.custom?U(m):null,h=!0===t.custom&&K(m);return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"mobile-structured-question",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:t.question}),(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:l("selectAnOption")}),(0,r.jsx)(d.z6,{name:o,value:null!=c?String(c):"",onValueChange:e=>{u(Number(e)),x("")},disabled:n,className:"flex flex-col gap-2",children:t.labels.map((e,t)=>(0,r.jsxs)("label",{className:"flex items-start gap-3 p-3 rounded-lg border-2 min-h-[44px] ".concat(c===t+1?"border-accent-500 bg-accent-50 dark:bg-accent-900/30":"border-border bg-surface"," ").concat(n?"opacity-50":""),children:[(0,r.jsx)(d.CU,{value:String(t+1),className:"mt-1"}),(0,r.jsxs)("span",{className:"font-medium",children:[t+1,". ",e]})]},"".concat(t+1,"-").concat(e)))})]}),t.custom&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"free-text-".concat(o),className:"block text-sm text-muted-foreground mb-1",children:l("freeTextLabel")}),(0,r.jsx)("input",{id:"free-text-".concat(o),"data-testid":"mobile-structured-question-free-text",type:"text",value:m,maxLength:1e3,onChange:e=>{x(e.target.value),""!==e.target.value&&u(null)},disabled:n,placeholder:l("enterValuePlaceholder"),enterKeyHint:"send",className:"w-full min-h-[44px] px-4 py-2 border-2 border-input dark:bg-muted dark:text-foreground rounded-lg focus:outline-none focus:border-accent-500 disabled:opacity-50"}),h&&(0,r.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":"mobile-structured-question-free-text-numeric",children:l("freeTextNumericHint")})]}),(0,r.jsx)("button",{type:"button","data-testid":"mobile-structured-question-submit",disabled:n||null===c&&null===f,onClick:()=>{null!==f?a(f):null!==c&&a(String(c))},className:"w-full ".concat(q.base," ").concat(q.primary),children:l("submit")})]})}var ee=n(86651),et=n(11047),en=n(76482),ea=n(84926),er=n(37586),es=n(24033),el=n(97624),ei=n(37354),eo=n(54014),ec=n(75676),ed=n(26232),eu=n(41898),em=n(66966),ex=n(83012);let ef="application/x-commandmate-agent-instance",eh=[{mode:"terminal",labelKey:"surfaceMode.showTerminal",icon:b.A},{mode:"chat",labelKey:"surfaceMode.showChat",icon:er.A}],ep="session-note-open";function eg(e,t){let n=(0,em.rC)(),a=null==n?void 0:n.worktrees,r=null==n?void 0:n.refresh,l=(0,s.useMemo)(()=>(function(e,t,n){var a;let r=null==e?void 0:e.find(e=>e.id===t),s=null==r||null==(a=r.sessionNotes)?void 0:a[n];return s&&"string"==typeof s.text&&0!==s.text.length?{text:s.text,updatedAt:"number"==typeof s.updatedAt?s.updatedAt:0}:null})(a,e,t),[a,e,t]),[i,o]=(0,s.useState)(null);(0,s.useEffect)(()=>{o(null)},[e,t]),(0,s.useEffect)(()=>{var e,t;if(null===i)return;let n=null===i.value?null===l:null!==l&&l.text===i.value.text,a=(null==l?void 0:l.text)!==(null==(e=i.base)?void 0:e.text)||(null==l?void 0:l.updatedAt)!==(null==(t=i.base)?void 0:t.updatedAt);(n||a)&&o(null)},[i,l]);let c=(0,s.useCallback)(n=>{let a=n.replace(/\s+/g," ").trim();Array.from(a).length>100||(o({value:a.length>0?{text:a,updatedAt:Date.now()}:null,base:l}),(async()=>{try{if(!(await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/instances/notes"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:t,text:a})})).ok)return void o(null);await (null==r?void 0:r())}catch(e){o(null)}})())},[t,r,l,e]);return{note:i?i.value:l,save:c}}function eb(e){let{initialText:t,onCommit:n,onCancel:a,ariaLabel:l,placeholder:i,testId:o}=e,[c,d]=(0,s.useState)(t),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()},[]);let m=(0,s.useCallback)(e=>{if("Enter"===e.key){if(e.nativeEvent.isComposing)return;e.preventDefault(),n(c);return}"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),a())},[a,n,c]);return(0,r.jsx)("input",{ref:u,type:"text",value:c,maxLength:100,placeholder:i,"aria-label":l,"data-testid":o,onChange:e=>d(e.target.value),onKeyDown:m,className:"w-full rounded border border-border bg-surface px-2 py-1 text-xs text-surface-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"})}let ev=(0,s.memo)(function(e){var t;let{worktreeId:n,splitIndex:a,cliToolId:l,instanceId:o,instance:c,availableInstances:d,onInstanceChange:x,status:f="idle",statusUnclassified:h=!1,agentModel:p,agentUsage:g,agentUsageDetail:b,onFocus:v,attaching:y=!1,headerExtras:j,surfaceMode:w=ec.wf,onSurfaceModeChange:k,isMaximized:N=!1,onToggleMaximize:C,terminal:S,footer:I,bodyRef:T,style:E,onDropInstance:A,draggedInstanceId:M}=e,R=(0,i.c)("worktree"),L=(0,i.c)("common"),P=(0,m.Mq)(f,h),[D,F]=(0,s.useState)(null),{note:O,save:z}=eg(n,o),[_,B]=(0,s.useState)(!1);(0,s.useEffect)(()=>{B(!1)},[n,o]);let V=(0,s.useCallback)(()=>B(!0),[]),H=(0,s.useCallback)(()=>B(!1),[]),U=(0,s.useCallback)(e=>{z(e),B(!1)},[z]),K=(0,s.useCallback)(()=>{setTimeout(()=>B(!0),0)},[]),W=null!=A,q=(0,s.useCallback)(()=>null==M||d.some(e=>e.id===M)?"allowed":"forbidden",[M,d]),$=(0,s.useCallback)(e=>{if(!W)return;e.preventDefault();let t=q();e.dataTransfer.dropEffect="forbidden"===t?"none":"move",F(e=>e===t?e:t)},[W,q]),G=(0,s.useCallback)(e=>{if(!W)return;e.preventDefault();let t=q();F(e=>e===t?e:t)},[W,q]),J=(0,s.useCallback)(()=>{W&&F(null)},[W]),Y=(0,s.useCallback)(e=>{if(!W)return;e.preventDefault(),F(null);let t=e.dataTransfer.getData(ef);t&&(null==A||A(t))},[W,A]),Q=(0,s.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),X=(0,s.useCallback)(()=>{v()},[v]),Z="Terminal split ".concat(a+1),ee=(0,eo.sw)(null!=c?c:{cliTool:l}),en=R("terminal.selectInstance",{split:Z}),ea=R("terminal.searchOutput",{split:Z}),er=R("sessionNote.editLabel",{split:Z}),em=O?(0,ex.Uq)(new Date(O.updatedAt)):"",ep=O?R("sessionNote.label",{note:O.text,time:em}):"";return(0,r.jsxs)("div",{role:"region","aria-label":Z,"data-testid":"terminal-split-pane-".concat(a),"data-split-index":a,style:E,className:"flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface".concat(null===D?" focus-within:ring-1 focus-within:ring-accent-500/30":"").concat("allowed"===D?" ring-2 ring-accent-400":"forbidden"===D?" ring-2 ring-red-300 cursor-not-allowed":""),onFocusCapture:X,onMouseDown:v,onDragOver:$,onDragEnter:G,onDragLeave:J,onDrop:Y,children:[(0,r.jsxs)("div",{className:"relative px-2 py-1 flex items-center gap-2 bg-surface-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)(ed.rI,{children:[(0,r.jsxs)(ed.ty,{"data-testid":"cli-selector-".concat(a),"aria-label":en,className:"flex items-center gap-1.5 min-w-0 max-w-[12rem] rounded px-1.5 py-0.5 text-xs border border-border bg-surface text-surface-foreground hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:ring-2 data-[state=open]:ring-ring transition-colors",children:[(0,r.jsx)(u.m,{status:f,size:"sm","aria-hidden":!0,"data-testid":"split-status-indicator-".concat(a),label:P?L(m.rH):void 0,className:P?m.Jd:void 0,"data-unclassified":P?"true":void 0}),(0,r.jsx)("span",{className:"truncate",children:ee}),(0,r.jsx)(es.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,r.jsxs)(ed.SQ,{align:"start",className:"min-w-[10rem]",children:[(0,r.jsx)(ed.Hr,{value:o,onValueChange:x,children:d.map(e=>(0,r.jsx)(ed.Ht,{value:e.id,children:(0,eo.sw)(e)},e.id))}),(0,r.jsx)(ed.mB,{}),(0,r.jsxs)(ed._2,{"data-testid":"split-session-note-menu-item-".concat(a),onSelect:K,children:[(0,r.jsx)(et.A,{size:14,"aria-hidden":"true",className:"opacity-70"}),R("sessionNote.menuItem")]})]})]}),k?(0,r.jsx)("div",{role:"group","aria-label":R("surfaceMode.groupLabel",{split:Z}),"data-testid":"surface-mode-toggle-".concat(a),className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-border bg-surface p-0.5",children:eh.map(e=>{let{mode:t,labelKey:n,icon:s}=e,l=w===t,i=R(n);return(0,r.jsx)(eu.m_,{content:i,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:()=>k(t),"aria-pressed":l,"aria-label":i,"data-testid":"surface-mode-".concat(t,"-").concat(a),className:"flex items-center justify-center rounded px-1.5 py-0.5 touch-manipulation transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(l?"bg-accent-500/15 text-accent-600 dark:text-accent-400":"text-muted-foreground hover:bg-muted hover:text-surface-foreground"),children:(0,r.jsx)(s,{size:14,"aria-hidden":"true"})})},t)})}):null,p&&(0,r.jsx)("span",{"data-testid":"split-agent-model-".concat(a),title:R("agentModel.modelLabel",{model:p}),className:"min-w-0 truncate text-[11px] leading-none text-muted-foreground ".concat(O?"max-w-[5rem] shrink-[4]":"max-w-[10rem]"),children:p}),g&&(0,r.jsx)("span",{"data-testid":"split-agent-usage-".concat(a),title:null!=b?b:R("agentSession.chipLabel",{usage:g}),className:"min-w-0 max-w-[10rem] truncate text-[11px] leading-none tabular-nums text-muted-foreground",children:g}),O&&(0,r.jsxs)("button",{type:"button",onClick:V,"aria-label":er,title:ep,"data-testid":"split-session-note-".concat(a),className:"flex min-w-0 max-w-[16rem] shrink items-center gap-1 rounded px-1 py-0.5 text-[11px] leading-none text-muted-foreground hover:bg-muted-foreground/10 hover:text-surface-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(et.A,{size:11,"aria-hidden":"true",className:"shrink-0 opacity-70"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:O.text}),(0,r.jsx)("span",{"data-testid":"split-session-note-time-".concat(a),className:"shrink-0 tabular-nums opacity-70",children:em})]}),j,(0,r.jsx)(eu.m_,{content:ea,placement:"bottom",className:"ml-auto",children:(0,r.jsx)("button",{type:"button",onClick:Q,"aria-label":ea,"data-testid":"terminal-search-button-".concat(a),className:"flex items-center gap-1 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-surface-foreground hover:bg-muted-foreground/10 rounded transition-colors",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})}),C?(0,r.jsx)(eu.m_,{content:"".concat(N?R("terminal.restoreSplits"):R("terminal.maximizeSplit",{split:Z})," — ").concat(R("terminal.maximizeShortcutHint")),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsx)("button",{type:"button",onClick:C,"aria-pressed":N,"aria-label":N?R("terminal.restoreSplits"):R("terminal.maximizeSplit",{split:Z}),"data-testid":"toggle-maximize-".concat(a),className:"flex flex-shrink-0 items-center justify-center px-1.5 py-0.5 text-muted-foreground hover:text-surface-foreground hover:bg-muted-foreground/10 rounded transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:N?(0,r.jsx)(el.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(ei.A,{size:14,"aria-hidden":"true"})})}):null,_?(0,r.jsxs)("div",{"data-testid":"split-session-note-editor-".concat(a),className:"absolute inset-x-2 top-full z-30 mt-1 rounded-md border border-border bg-surface p-2 shadow-lg",children:[(0,r.jsx)(eb,{initialText:null!=(t=null==O?void 0:O.text)?t:"",onCommit:U,onCancel:H,ariaLabel:er,placeholder:R("sessionNote.placeholder"),testId:"split-session-note-input-".concat(a)}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:R("sessionNote.hint")})]}):null]}),(0,r.jsxs)("div",{ref:T,className:"flex-1 min-h-0 relative","data-testid":"split-body-".concat(a),children:[y?(0,r.jsxs)("div",{"data-testid":"terminal-attach-skeleton-".concat(a),className:"absolute inset-0 flex items-center justify-center text-xs text-muted-foreground bg-surface-2/80",role:"status","aria-live":"polite",children:["Attaching ",ee," session..."]}):null,S]}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:I})]})}),ey={tab:"directInputKeyboard.unavailableTab",chat:"directInputKeyboard.unavailableChat",session:"directInputKeyboard.unavailableSession"};function ej(e){let{open:t,onClose:n,onSearch:a,searchTarget:l="terminal",onEnd:o,endDisabled:c=!1,onDirectInput:d,directInputUnavailableReason:u=null}=e,m=(0,i.c)("worktree"),x=(0,s.useId)(),f=(0,s.useId)(),h=(0,A.r)({active:t}),p=(0,s.useCallback)(()=>{a(),n()},[a,n]),g=(0,s.useCallback)(()=>{o(),n()},[o,n]),b=(0,s.useCallback)(()=>{window.dispatchEvent(new CustomEvent(ep)),n()},[n]),v=(0,s.useCallback)(()=>{d&&null===u&&(n(),d())},[d,u,n]);return((0,s.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&n()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"terminal-actions-overlay",onClick:n,className:"fixed inset-0 bg-black/50 z-50","aria-hidden":"true"}),(0,r.jsxs)("div",{ref:h,"data-testid":"mobile-terminal-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":x,tabIndex:-1,className:"fixed bottom-0 inset-x-0 z-50 rounded-t-2xl border-t border-border bg-surface pb-safe",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30","aria-hidden":"true"})}),(0,r.jsx)("h2",{id:x,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:m("terminal.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-search",onClick:p,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm text-foreground hover:bg-muted transition-colors touch-manipulation",children:[(0,r.jsx)(ee.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),m("chat"===l?"chatTranscript.openSearch":"terminal.searchTerminal")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-session-note",onClick:b,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm text-foreground hover:bg-muted transition-colors touch-manipulation",children:[(0,r.jsx)(et.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),m("sessionNote.menuItem")]}),d?(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-direct-input",onClick:v,"aria-label":m("directInputKeyboard.menuItem"),"aria-disabled":null!==u||void 0,"aria-describedby":null!==u?f:void 0,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-left text-sm text-foreground transition-colors touch-manipulation ".concat(null!==u?"":"hover:bg-muted"),children:[(0,r.jsx)(en.A,{size:18,"aria-hidden":"true",className:"shrink-0 text-muted-foreground ".concat(null!==u?"opacity-40":"")}),(0,r.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,r.jsx)("span",{className:null!==u?"opacity-40":void 0,children:m("directInputKeyboard.menuItem")}),null!==u?(0,r.jsx)("span",{id:f,"data-testid":"actions-sheet-direct-input-reason",className:"text-xs text-muted-foreground",children:m(ey[u])}):null]})]}):null,(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-end",onClick:g,disabled:c,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm text-danger hover:bg-danger/10 transition-colors touch-manipulation disabled:opacity-40 disabled:hover:bg-transparent",children:[(0,r.jsx)(ea.A,{size:18,"aria-hidden":"true"}),m("terminal.endSession")]})]})]})]}):null}var ew=n(65229),ek=n(9900);let eN=["Enter","Escape","Tab","BTab","BSpace","DC","Up","Down","Left","Right","Home","End","PageUp","PageDown","C-a","C-b","C-c","C-d","C-e","C-f","C-g","C-h","C-i","C-j","C-k","C-l","C-m","C-n","C-o","C-p","C-q","C-r","C-s","C-t","C-u","C-v","C-w","C-x","C-y","C-z"];function eC(e){return"string"==typeof e&&eN.includes(e)}let eS={Enter:"Enter",Escape:"Escape",Backspace:"BSpace",Delete:"DC",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown"};function eI(e,t,n,a){let[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1),c=(0,s.useRef)([]),d=(0,s.useRef)(!1),u=(0,s.useRef)(0),m=(0,s.useRef)(!0),x=(0,s.useRef)(null),f=(0,s.useRef)(a);(0,s.useEffect)(()=>{f.current=a},[a]),(0,s.useEffect)(()=>(m.current=!0,()=>{m.current=!1,null!==x.current&&(clearTimeout(x.current),x.current=null)}),[]);let h=(0,s.useCallback)((e,t)=>{!e.settled&&(e.settled=!0,e.resolve(t),u.current-=1,0===u.current&&m.current&&o(!1))},[]),p=(0,s.useCallback)(()=>{let a=()=>{if(d.current)return;let r=c.current.splice(0,32);if(0===r.length)return;d.current=!0;let s=r.map(e=>e.event),i=n&&n!==t?{cliToolId:t,events:s,instanceId:n}:{cliToolId:t,events:s};fetch("/api/worktrees/".concat(encodeURIComponent(e),"/direct-input"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}).then(e=>{if(!e.ok)throw Error("direct-input responded ".concat(e.status));for(let{ticket:e}of(d.current=!1,r))null!==e&&(e.remaining-=1,0===e.remaining&&h(e,!0));if(c.current.length>0)return void a();m.current&&(null!==x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{var e;x.current=null,null==(e=f.current)||e.call(f)},ek.LK))}).catch(()=>{d.current=!1;let e=c.current;for(let{ticket:t}of(c.current=[],[...r,...e]))null!==t&&h(t,!1);m.current&&l("directInput.error")})};a()},[e,t,n,h]);return{send:(0,s.useCallback)(e=>{if(0!==e.length){for(let t of(l(null),e))c.current.push({event:t,ticket:null});p()}},[p]),error:r,sendAndWait:(0,s.useCallback)(e=>0===e.length?Promise.resolve(!0):(l(null),new Promise(t=>{let n={remaining:e.length,settled:!1,resolve:t};for(let t of(u.current+=1,o(!0),e))c.current.push({event:t,ticket:n});p()})),[p]),isSending:i}}function eT(e,t,n,a,r){return r?{kind:"named",id:e,label:t,key:n,repeats:a,swipeUp:r}:{kind:"named",id:e,label:t,key:n,repeats:a}}let eE=[[eT("esc","ESC","Escape",!1),eT("enter","ENTER","Enter",!1),eT("bs","BS","BSpace",!0,{key:"DC",label:"DEL"}),eT("home","HOME","Home",!1),eT("up","↑","Up",!0),eT("end","END","End",!1),eT("pgup","PGUP","PageUp",!0)],[eT("tab","TAB","Tab",!1),{kind:"modifier",id:"ctrl",label:"CTRL"},{kind:"modifier",id:"shift",label:"SHIFT"},eT("left","←","Left",!0),eT("down","↓","Down",!0),eT("right","→","Right",!0),eT("pgdn","PGDN","PageDown",!0)]];function eA(e){return[...e].map(e=>({kind:"char",char:e,span:1}))}function eM(e,t,n){return[e,...eA(t),{kind:"char",char:" ",span:4},...eA(n)]}let eR={alpha:[eA("qwertyuiop"),eA("asdfghjkl-"),eA("zxcvbnm,./"),eM({kind:"page",target:"symbol",label:"123",span:2},"_:","'?")],symbol:[eA("1234567890"),eA("!@#$%^&*()"),eA("~`|\\[]{}<>"),eM({kind:"page",target:"alpha",label:"ABC",span:2},"+=",';"')]},eL={Escape:"ESC",Enter:"ENTER",BSpace:"BS",DC:"DEL",Home:"HOME",End:"END",PageUp:"PGUP",PageDown:"PGDN",Up:"↑",Down:"↓",Left:"←",Right:"→",Tab:"TAB",BTab:"⇧TAB"},eP=/^[a-z]$/;function eD(e,t){if(null===t)return"named"===e.type?{type:"key",key:e.key}:{type:"text",text:e.char};if("ctrl"===t.modifier){if("char"!==e.type||!eP.test(e.char))return null;let t="C-".concat(e.char);return eC(t)?{type:"key",key:t}:null}return"named"===e.type?"Tab"===e.key?{type:"key",key:"BTab"}:null:eP.test(e.char)?{type:"text",text:e.char.toUpperCase()}:null}function eF(e){return e.length>=32}function eO(e,t){let{sending:n,staged:a,modifier:r}=t;if(n)return!1;switch(e.kind){case"press":return!eF(a)&&null!==eD(e.press,r);case"page":return null===r;case"modifier":return!0}}function ez(e){null!==e.timer&&clearTimeout(e.timer),null!==e.interval&&clearInterval(e.interval),e.timer=null,e.interval=null}let e_={WebkitTouchCallout:"none",WebkitTapHighlightColor:"transparent",WebkitUserSelect:"none"},eB={1:"col-span-1",2:"col-span-2",4:"col-span-4"},eV="flex h-11 min-w-[44px] shrink-0 items-center justify-center px-2 text-xs font-medium touch-manipulation select-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-disabled:opacity-40",eH={normal:"border-border bg-surface text-foreground",pressed:"border-accent-500 bg-accent-500/30 text-foreground",oneShot:"border-accent-500 bg-accent-500/20 text-accent-600 dark:text-accent-400",locked:"border-accent-600 bg-accent-600 text-white underline underline-offset-2"};function eU(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:l,onClose:o}=e,c=(0,i.c)("worktree"),d=(0,s.useId)(),{sendAndWait:u,isSending:m}=eI(t,n,a,l),[x,f]=(0,s.useState)([]),h=(0,s.useRef)([]),[p,g]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(!1),[y,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)("alpha"),[N,C]=(0,s.useState)(!1),[S,I]=(0,s.useState)(null),T=(0,s.useRef)(null),E=(0,s.useRef)(!0),A=(0,s.useRef)(null);(0,s.useEffect)(()=>{E.current=!0;let e=document.activeElement;return e instanceof HTMLElement&&e.blur(),()=>{E.current=!1;let e=T.current;null!==e&&ez(e),T.current=null}},[]),(0,s.useEffect)(()=>{let e=e=>{let t=T.current;null!==t&&t.pointerId===e.pointerId&&(ez(t),T.current=null,I(null))};return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e)}},[]),(0,s.useEffect)(()=>{let e=A.current;e&&(e.scrollLeft=e.scrollWidth)},[x]);let M=eF(x),R=function(e){let t=[];for(let n of e){let e=t[t.length-1];if("key"===n.type&&(null==e?void 0:e.event.type)==="key"&&e.event.key===n.key){t[t.length-1]={...e,count:e.count+1};continue}t.push({label:"key"===n.type?function(e){let t=eL[e];return void 0!==t?t:"^".concat(e.slice(2).toUpperCase())}(n.key):n.text,count:1,event:n})}return t}(x),L=x.length,P=()=>({sending:v.current,staged:h.current,modifier:b.current}),D={sending:m,staged:x,modifier:p};function F(e){h.current=e,f(e),C(!1)}function O(e){b.current=e,g(e),null!==e&&(j(!0),k("alpha"))}function z(e){var t;if(v.current)return!1;let n=eD(e,b.current);if(null===n)return!1;let a=function(e,t){if(eF(e))return null;let n=e[e.length-1];return"text"===t.type&&(null==n?void 0:n.type)==="text"&&n.text.length+t.text.length<=4096?[...e.slice(0,-1),{type:"text",text:n.text+t.text}]:[...e,t]}(h.current,n);if(null===a)return!1;F(a);let r=null===(t=b.current)||t.locked?t:null;return r!==b.current&&O(r),!0}function _(e,t){if(eO(e,P()))switch(e.kind){case"press":z(t&&e.swipe?e.swipe:e.press);return;case"modifier":var n,a;O((n=b.current,a=e.modifier,(null==n?void 0:n.modifier)===a?null:{modifier:a,locked:!1}));return;case"page":k(e.target);return}}function B(e){ez(e),T.current=null,I(null)}function V(e){let{keyId:t,testId:n,action:a,label:s,ariaLabel:l,spanClass:i,faceClass:o="",hint:c}=e,d=eO(a,D),u="modifier"===a.kind&&(null==p?void 0:p.modifier)===a.modifier?p.locked?"locked":"oneShot":S===t?"pressed":"normal";return(0,r.jsxs)("button",{type:"button","data-testid":n,"aria-label":l,"aria-disabled":!d||void 0,"aria-pressed":"modifier"===a.kind?(null==p?void 0:p.modifier)===a.modifier:void 0,"data-modifier-state":"modifier"===a.kind?(null==p?void 0:p.modifier)===a.modifier?p.locked?"locked":"one-shot":"off":void 0,className:"".concat("relative flex h-11 min-w-0 items-stretch p-0.5 touch-none select-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"," ").concat(i),...{onPointerDown(e){if(e.preventDefault(),0!==e.button||null!==T.current||!eO(a,P()))return;let n=e.currentTarget;try{var r;null==(r=n.setPointerCapture)||r.call(n,e.pointerId)}catch(e){}let s=n.getBoundingClientRect(),l={pointerId:e.pointerId,action:a,start:{x:e.clientX,y:e.clientY},rect:{left:s.left,top:s.top,right:s.right,bottom:s.bottom},longPressed:!1,timer:null,interval:null};T.current=l,I(t);try{"undefined"!=typeof navigator&&"function"==typeof navigator.vibrate&&navigator.vibrate(10)}catch(e){}"modifier"===a.kind?l.timer=setTimeout(()=>{l.timer=null,l.longPressed=!0,O({modifier:a.modifier,locked:!0})},450):"press"===a.kind&&a.repeats&&(l.timer=setTimeout(()=>{l.timer=null,l.longPressed=!0,z(a.press)&&(l.interval=setInterval(()=>{z(a.press)||ez(l)},80))},450))},onPointerUp(e){var t,n,a;let r=T.current;if(null===r||r.pointerId!==e.pointerId||(B(r),r.longPressed))return;let s="press"===r.action.kind&&void 0!==r.action.swipe,l=(t=r.start,n={x:e.clientX,y:e.clientY},a=r.rect,s&&t.y-n.y>=24?"swipe":n.x>=a.left&&n.x<=a.right&&n.y>=a.top&&n.y<=a.bottom?"tap":"none");"none"!==l&&_(r.action,"swipe"===l)},onPointerCancel(e){let t=T.current;null!==t&&t.pointerId===e.pointerId&&B(t)},onClick(e){0===e.detail&&_(a,!1)}},children:[(0,r.jsxs)("span",{"aria-hidden":void 0!==l||void 0,className:"relative flex flex-1 items-center justify-center rounded-md border ".concat(eH[u]," ").concat(d?"":"opacity-40"," ").concat(o),children:[s,c?(0,r.jsx)("span",{"aria-hidden":"true",className:"absolute right-1 top-0.5 text-[9px] leading-none text-muted-foreground",children:c}):null]}),S===t?(0,r.jsx)("span",{"aria-hidden":"true","data-testid":"direct-key-bubble",className:"pointer-events-none absolute bottom-full left-1/2 z-40 mb-1 -translate-x-1/2 whitespace-nowrap rounded-md border border-border bg-surface px-3 py-1.5 font-mono text-xl text-foreground shadow-lg",children:s}):null]},t)}function H(e){var t;let n=c("directInputKeyboard.keys.".concat(e.id));return"modifier"===e.kind?V({keyId:e.id,testId:"direct-key-".concat(e.id),action:{kind:"modifier",modifier:e.id},label:e.label,ariaLabel:n,spanClass:"col-span-1",faceClass:"text-xs font-semibold"}):V({keyId:e.id,testId:"direct-key-".concat(e.id),action:{kind:"press",press:{type:"named",key:e.key},swipe:e.swipeUp?{type:"named",key:e.swipeUp.key}:void 0,repeats:e.repeats},label:e.label,ariaLabel:n,spanClass:"col-span-1",faceClass:"text-xs font-semibold",hint:null==(t=e.swipeUp)?void 0:t.label})}let U=(null==p?void 0:p.modifier)==="shift";function K(e){var t,n;let a=null!=(t=eB[e.span])?t:"col-span-1";if("page"===e.kind)return V({keyId:"page-".concat(e.target),testId:"direct-key-page",action:{kind:"page",target:e.target},label:e.label,ariaLabel:c("symbol"===e.target?"directInputKeyboard.keys.toSymbols":"directInputKeyboard.keys.toAlpha"),spanClass:a,faceClass:"text-xs font-semibold"});let r=" "===e.char,s=r?"␣":U&&/^[a-z]$/.test(e.char)?e.char.toUpperCase():e.char;return V({keyId:"char-".concat(e.char),testId:(n=e.char,"direct-key-char-".concat(n.codePointAt(0))),action:{kind:"press",press:{type:"char",char:e.char},repeats:!1},label:s,ariaLabel:r?c("directInputKeyboard.keys.space"):void 0,spanClass:a,faceClass:"font-mono text-sm"})}async function W(){if(v.current||N||0===h.current.length)return;v.current=!0;let e=T.current;null!==e&&B(e);let t=await u(h.current);v.current=!1,E.current&&(t?(h.current=[],f([])):C(!0))}let q=!m&&L>0;return(0,r.jsxs)("div",{role:"group","aria-label":c("directInputKeyboard.groupLabel"),"data-testid":"mobile-direct-input-keyboard","data-modifier":null===p?"none":"".concat(p.modifier).concat(p.locked?"-locked":""),className:"select-none bg-surface-2 text-foreground",style:e_,children:[(0,r.jsx)("div",{role:"status",children:M?(0,r.jsx)("p",{"data-testid":"direct-input-full",className:"bg-warning-subtle px-3 py-1.5 text-xs text-warning-foreground",children:c("directInputKeyboard.full",{max:32})}):null}),(0,r.jsx)("div",{role:"alert",children:N?(0,r.jsxs)("div",{"data-testid":"direct-input-failed",className:"flex items-center gap-2 bg-danger-subtle pl-3 text-xs text-danger-foreground",children:[(0,r.jsx)("p",{className:"flex-1 py-1.5",children:c("directInputKeyboard.sendFailed")}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-failed-ok",onClick:()=>C(!1),className:"".concat(eV," text-danger-foreground"),children:c("directInputKeyboard.acknowledge")})]}):null}),(0,r.jsxs)("div",{role:"group","aria-label":c("directInputKeyboard.confirmRowLabel"),"aria-busy":!!m||void 0,"data-testid":"direct-input-confirm-row",className:"flex h-11 items-stretch bg-surface",children:[(0,r.jsx)("button",{type:"button","data-testid":"direct-input-toggle-chars","aria-expanded":y,"aria-controls":y?d:void 0,"aria-label":c(y?"directInputKeyboard.hideChars":"directInputKeyboard.showChars"),onClick:()=>j(e=>!e),className:"".concat(eV," ").concat(y?"text-accent-600 dark:text-accent-400":"text-muted-foreground"),children:"ABC"}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center",children:[(0,r.jsx)("ul",{ref:A,"aria-label":c("directInputKeyboard.stagedLabel"),"data-testid":"direct-input-chips",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 scrollbar-hide",children:R.map((e,t)=>{let n="text"===e.event.type?e.label.replace(/ /g,"␣"):e.label,a=e.count>1?"".concat(n,"\xd7").concat(e.count):n;return(0,r.jsx)("li",{"data-testid":"direct-input-chip","aria-label":e.count>1?c("directInputKeyboard.chipRepeat",{key:n,count:e.count}):void 0,className:"shrink-0 whitespace-nowrap rounded border border-border bg-surface-2 px-1.5 py-0.5 font-mono text-xs text-foreground",children:a},t)})}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-clear","aria-label":c("directInputKeyboard.clearAll"),"aria-disabled":!q||void 0,onClick:function(){v.current||0===h.current.length||F([])},className:"".concat(eV," text-muted-foreground"),children:(0,r.jsx)(ew.A,{size:16,"aria-hidden":"true"})})]}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-undo","aria-label":c("directInputKeyboard.undoAria"),"aria-disabled":!q||void 0,onClick:function(){v.current||0===h.current.length||F(function(e){let t=e[e.length-1];if(void 0===t)return[];let n=e.slice(0,-1);if("text"===t.type){let e=[...t.text];if(e.length>1)return[...n,{type:"text",text:e.slice(0,-1).join("")}]}return n}(h.current))},className:"".concat(eV," text-foreground"),children:c("directInputKeyboard.undo")}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-send","aria-label":c("directInputKeyboard.sendAria",{count:L}),"aria-disabled":!(q&&!N)||void 0,onClick:()=>void W(),className:"".concat(eV," bg-accent-600 text-white"),children:c("directInputKeyboard.send",{count:L})}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-close","aria-label":c("directInputKeyboard.closeAria"),onClick:o,className:"".concat(eV," text-muted-foreground"),children:c("directInputKeyboard.close")}),(0,r.jsx)("span",{className:"sr-only","aria-live":"polite","data-testid":"direct-input-count",children:c("directInputKeyboard.stagedCount",{count:L})})]}),(0,r.jsx)("div",{role:"group","aria-label":c("directInputKeyboard.specialKeysLabel"),"data-testid":"direct-input-special-keys",children:eE.map((e,t)=>(0,r.jsx)("div",{className:"grid grid-cols-7",children:e.map(H)},t))}),y?(0,r.jsx)("div",{id:d,role:"group","aria-label":c("directInputKeyboard.charKeysLabel"),"data-testid":"direct-input-char-panel","data-page":w,children:eR[w].map((e,t)=>(0,r.jsx)("div",{className:"grid grid-cols-10",children:e.map(K)},"".concat(w,"-").concat(t)))}):null]})}var eK=n(73333),eW=n(92509),eq=n(31166),e$=n(67909),eG=n(36402),eJ=n(17846),eY=n(69264),eQ=n(27307),eX=n(24027),eZ=n(5917),e0=n(75426),e1=n(51963),e2=n(39867);let e4="flex w-full items-center gap-3 rounded-lg px-3 min-h-[44px] py-3 text-sm text-foreground hover:bg-muted transition-colors touch-manipulation";function e5(e){let{open:t,onClose:n,onSearch:a,onCopyContent:l,onCopyPath:o,downloadUrl:c,downloadName:d,contentCopied:u,pathCopied:m}=e,x=(0,i.c)("worktree"),f=(0,s.useId)(),h=(0,A.r)({active:t}),p=(0,s.useCallback)(()=>{a(),n()},[a,n]),g=(0,s.useCallback)(()=>{l(),n()},[l,n]),b=(0,s.useCallback)(()=>{o(),n()},[o,n]);return((0,s.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&(e.stopPropagation(),n())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"file-actions-overlay",onClick:n,className:"fixed inset-0 bg-black/50 z-50","aria-hidden":"true"}),(0,r.jsxs)("div",{ref:h,"data-testid":"mobile-file-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,className:"fixed bottom-0 inset-x-0 z-50 rounded-t-2xl border-t border-border bg-surface pb-safe",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30","aria-hidden":"true"})}),(0,r.jsx)("h2",{id:f,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:x("fileViewer.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-search",onClick:p,className:e4,children:[(0,r.jsx)(ee.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.searchInFile")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-content",onClick:g,className:e4,children:[u?(0,r.jsx)(eZ.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(e0.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.copyFileContent")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-path",onClick:b,className:e4,children:[m?(0,r.jsx)(eZ.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(e1.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.copyFilePath")]}),(0,r.jsxs)("a",{"data-testid":"download-file-button",href:c,download:d,onClick:n,className:e4,"aria-label":x("actions.downloadFile"),children:[(0,r.jsx)(e2.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.downloadFile")]})]})]})]}):null}var e3=n(11063);let e6=[{extension:".png",maxFileSize:0x1400000,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:0x1400000,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:0x1400000,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".mp4",maxFileSize:0x6400000,allowedMimeTypes:["video/mp4"],magicBytes:[{bytes:[102,116,121,112],offset:4}]},{extension:".txt",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:0x1400000,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:0x1400000,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:0x1400000,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]}],e8=e6.map(e=>e.extension),e9=[".md",".html",".htm",".yaml",".yml",".txt"];function e7(e){if(!e)return!1;let t=e.toLowerCase();return e9.includes(t)}e3.j6,e3.j6;var te=n(60322),tt=n(99708),tn=n(57828),ta=n(18514),tr=n(59854),ts=n(76246),tl=n(56639),ti=n(78660);function to(e){let[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(""),[l,i]=(0,s.useState)(""),[o,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(0),m=(0,s.useRef)(null),x=(0,s.useRef)(null),f=(0,s.useCallback)(()=>{n(!0),setTimeout(()=>{var e;return null==(e=m.current)?void 0:e.focus()},50)},[]),h=(0,s.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),p=(0,s.useCallback)(()=>{n(!1),r(""),i(""),c([]),u(0),h()},[h]);(0,s.useEffect)(()=>{if(!a||a.length<ti.E2){i(""),h();return}return h(),x.current=setTimeout(()=>{i(a)},ti.e1),h},[a,h]),(0,s.useEffect)(()=>{if(!l||l.length<ti.E2||!e){c([]),u(0);return}let t=e.split("\n"),n=l.toLowerCase(),a=[];t.forEach((e,t)=>{e.toLowerCase().includes(n)&&a.push(t+1)}),c(a),u(0)},[l,e]);let g=(0,s.useCallback)(()=>{0!==o.length&&u(e=>(e+1)%o.length)},[o.length]),b=(0,s.useCallback)(()=>{0!==o.length&&u(e=>(e-1+o.length)%o.length)},[o.length]);return{searchOpen:t,searchQuery:a,searchMatches:o,searchCurrentIdx:d,searchInputRef:m,openSearch:f,closeSearch:p,nextMatch:g,prevMatch:b,setSearchQuery:r}}var tc=n(4138),td=n(90487);function tu(){let e=(0,i.c)("worktree");return(0,r.jsxs)("div",{className:"flex h-full items-center justify-center bg-surface text-muted-foreground",children:[(0,r.jsx)(d.y$,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}n(1226);let tm=(0,e$.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(tu,{})}),tx="flex min-h-[44px] min-w-[44px] flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground transition-colors touch-manipulation",tf=/^---\s*\nmarp:\s*true/;function th(e){let{searchInputRef:t,searchQuery:n,searchMatches:a,searchCurrentIdx:s,onQueryChange:l,onPrev:o,onNext:c,onClose:d}=e,u=(0,i.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-border",children:[(0,r.jsx)("input",{ref:t,type:"text",value:n,onChange:e=>l(e.target.value),onKeyDown:e=>{"Escape"===e.key&&d(),"Enter"!==e.key||e.nativeEvent.isComposing||(e.shiftKey?o():c())},placeholder:u("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:bg-surface-2 text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:a.length>0?"".concat(s+1,"/").concat(a.length):"0/0"}),(0,r.jsx)("button",{onClick:o,disabled:0===a.length,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground disabled:text-muted-foreground","aria-label":u("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)("button",{onClick:c,disabled:0===a.length,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground disabled:text-muted-foreground","aria-label":u("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)("button",{onClick:d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground","aria-label":u("fileSearch.close"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})}let tp="\n<script>\ndocument.addEventListener('click', function(e) {\n var target = e.target;\n while (target && target.tagName !== 'A') {\n target = target.parentElement;\n }\n if (target && target.href) {\n e.preventDefault();\n parent.postMessage({\n type: 'commandmate:link-click',\n href: target.getAttribute('href')\n }, '*');\n }\n});\n<\/script>";function tg(e){let{worktreeId:t,htmlContent:n,filePath:a}=e,[l,o]=(0,s.useState)("preview"),[c,d]=(0,s.useState)("safe"),u=(0,s.useRef)(new Set),m=(0,i.c)("worktree"),x=(0,eG.SC)(),f=(0,s.useCallback)(async e=>{if("interactive"===e&&!u.current.has(a)){if(!await x({description:m("htmlPreview.interactiveModeConfirm")}))return;u.current.add(a)}d(e)},[a,x,m]),h=(0,tl.iA)(t,a,n),p=(0,s.useMemo)(()=>"interactive"!==c?h:h.includes("</body>")?h.replace("</body>","".concat(tp,"</body>")):h+tp,[h,c]);(0,s.useEffect)(()=>{if("interactive"!==c)return;let e=e=>{if("null"!==e.origin)return;let t=e.data;if(!t||"object"!=typeof t||"commandmate:link-click"!==t.type||"string"!=typeof t.href)return;let n=t.href;(n.startsWith("http://")||n.startsWith("https://"))&&window.open(n,"_blank","noopener,noreferrer")};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[c]);let g=(0,s.useMemo)(()=>{try{return td.A.highlight(n,{language:"html",ignoreIllegals:!0}).value}catch(e){return td.A.highlightAuto(n).value}},[n]),b=(0,s.useMemo)(()=>Array.from({length:n.split("\n").length},(e,t)=>t+1),[n]),v=(0,s.useMemo)(()=>g.split("\n"),[g]);return(0,r.jsxs)("div",{className:"flex flex-col h-full","data-testid":"html-preview-mobile",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,r.jsx)("div",{className:"flex gap-1",children:["source","preview"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>o(e),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat(l===e?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:"source"===e?m("fileViewer.tabSource"):m("fileViewer.tabPreview")},e))}),(0,r.jsx)("div",{className:"flex gap-1",children:["safe","interactive"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>f(e),className:"px-2 py-1 text-xs font-medium rounded-md transition-colors ".concat(c===e?"safe"===e?"bg-success-subtle text-success-foreground":"bg-warning-subtle text-warning-foreground":"text-muted-foreground hover:bg-muted"),children:"safe"===e?m("fileViewer.sandboxSafe"):m("fileViewer.sandboxInteractive")},e))})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:"source"===l?(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:b.map(e=>{var t;let n=e-1;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap text-muted-foreground",children:e}),(0,r.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,r.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:null!=(t=v[n])?t:""}})})})]},e)})})}):(0,r.jsx)("iframe",{srcDoc:p,sandbox:e3.Ko[c],title:m("htmlPreview.title",{path:a}),className:"w-full h-full border-0 bg-white"},"".concat(a,"-").concat(c))})]})}function tb(e){let{reason:t}=e;return(0,r.jsxs)("div",{"data-testid":"file-read-only-notice","data-reason-code":t.code,role:"status",className:"flex items-center gap-2 px-3 py-2 bg-warning-subtle border-b border-warning-border text-xs text-warning-foreground",children:[(0,r.jsx)(tt.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}let tv=(0,s.memo)(function(e){var t;let{isOpen:n,onClose:a,worktreeId:l,filePath:c,onFileSaved:u,onOpenFile:m}=e,[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),{copied:v,markCopied:y,reset:j}=(0,tc.q)(),{copied:w,markCopied:k}=(0,tc.q)(),[N,C]=(0,s.useState)(null),[S,I]=(0,s.useState)(0),[T,E]=(0,s.useState)(!1),[A,M]=(0,s.useState)("viewer"),[R,L]=(0,s.useState)(!1),[P,D]=(0,s.useState)(null),[F,O]=(0,s.useState)(!1),z=(0,s.useRef)(null),_=(0,i.c)("worktree"),B=(0,eG.SC)(),V=x?null!=P?P:x.content:void 0,{searchOpen:H,searchQuery:U,searchMatches:K,searchCurrentIdx:W,searchInputRef:q,openSearch:$,closeSearch:G,nextMatch:J,prevMatch:Y,setSearchQuery:Q}=to(V),X=(0,s.useMemo)(()=>!!((null==x?void 0:x.content)&&!x.isImage&&!x.isVideo&&!x.isPdf),[x]),Z=null!=(t=null==x?void 0:x.extension.toLowerCase())?t:"",et="md"===Z,en=!!(x&&!x.readOnly&&!x.isHtml&&e7(".".concat(Z))),ea=et?A:H?"viewer":"editor",er=(0,s.useCallback)(async()=>{if(X&&V)try{await (0,te.l)(V),y()}catch(e){}},[X,V,y]),es=(0,s.useCallback)(async()=>{try{await (0,te.l)(c),k()}catch(e){}},[c,k]),eo=(0,s.useCallback)(()=>{E(e=>!e)},[]);(0,s.useEffect)(()=>{if(0===K.length||!z.current)return;let e=K[W],t=z.current.querySelector('[data-line="'.concat(e,'"]'));t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})},[W,K]),(0,s.useEffect)(()=>{if(!T||en)return;let e=e=>{"Escape"===e.key&&E(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T,en]),(0,s.useEffect)(()=>{if(!n||!c){f(null),b(null),j(),M("viewer"),L(!1),D(null),O(!1),G();return}M("viewer"),L(!1),D(null),O(!1),(async()=>{p(!0),b(null);try{let t=await fetch("/api/worktrees/".concat(l,"/files/").concat((0,ts.o)(c)));if(!t.ok){var e;let n=await t.json(),a="string"==typeof n.error?n.error:(null==(e=n.error)?void 0:e.message)||_("fileViewer.loadError");throw Error(a)}let n=await t.json();f(n)}catch(e){b(e instanceof Error?e.message:_("fileViewer.loadError"))}finally{p(!1)}})()},[n,l,c]),(0,s.useEffect)(()=>{C(null),I(0),x&&"md"===x.extension&&tf.test(x.content)&&!(x.content.length>1e6)&&(async()=>{try{let e=await fetch("/api/worktrees/".concat(l,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:x.content})});if(e.ok){let t=await e.json();C(t.slides)}}catch(e){}})()},[x,l]);let ec=!!(N&&N.length>0),ed=(0,s.useCallback)(e=>{D(e)},[]),eu=(0,s.useCallback)((e,t)=>{f(e=>e?{...e,content:t}:e),D(t),null==u||u(e)},[u]),em=(0,s.useCallback)(async()=>{(!F||await B({description:_("editor.unsavedCloseConfirm"),variant:"danger"}))&&a()},[F,B,_,a]);(0,s.useEffect)(()=>{if(!en||R)return;let e=e=>{"Escape"===e.key&&(H?G():T?E(!1):em())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[en,R,H,T,em]);let[ex,ef]=(0,s.useState)("");(0,s.useEffect)(()=>{et&&"viewer"===ea&&void 0!==V&&ef(V)},[et,ea,V]),(0,s.useEffect)(()=>{if(!en||!n)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[en,n]);let eh=(0,s.useMemo)(()=>{if(!x||void 0===V||x.isImage||x.isVideo||x.isHtml||x.isPdf)return null;let e=Array.from({length:V.split("\n").length},(e,t)=>t+1);try{return{lineNumbers:e,highlightedHtml:td.A.highlight(V,{language:x.extension,ignoreIllegals:!0}).value}}catch(t){return{lineNumbers:e,highlightedHtml:td.A.highlightAuto(V).value}}},[x,V]),ep=()=>x?x.isImage?(0,r.jsx)(eJ.a,{src:x.content,alt:x.path,mimeType:x.mimeType}):x.isVideo?(0,r.jsx)(eY.u,{src:x.content,mimeType:x.mimeType}):x.isPdf?(0,r.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,r.jsx)(eQ.PdfPreview,{dataUri:x.content,filePath:c,variant:"download"})}):x.isHtml?(0,r.jsx)(tg,{worktreeId:l,htmlContent:x.content,filePath:c}):eg():null,eg=()=>{if(!eh)return null;let e=new Set(K),t=K.length>0?K[W]:-1,n=eh.highlightedHtml.split("\n");return(0,r.jsx)("div",{ref:z,children:(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:eh.lineNumbers.map(a=>{var s;let l=a-1,i=a===t,o=e.has(a);return(0,r.jsxs)("tr",{"data-line":a,className:i?"bg-warning/30":o?"bg-warning/15":"",children:[(0,r.jsx)("td",{className:"pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap ".concat(i||o?"text-warning-foreground":"text-muted-foreground"),children:a}),(0,r.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,r.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:null!=(s=n[l])?s:""}})})})]},a)})})})})},eb="/api/worktrees/".concat(l,"/files/").concat((0,ts.o)(c),"?download=1"),ev=c?c.split("/").pop()||c:"",ey=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.jsxs)("a",{"data-testid":"download-file-button",href:eb,download:ev,className:e,"aria-label":_("actions.downloadFile"),title:_("actions.download"),children:[(0,r.jsx)(e2.A,{className:"w-3.5 h-3.5"}),t&&(0,r.jsx)("span",{children:_("actions.download")})]})},ej=()=>(0,r.jsxs)("div",{className:"bg-muted px-3 py-1.5 border-b border-border flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("button",{onClick:es,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":_("actions.copyFilePath"),title:_("actions.copyPath"),children:w?(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(e1.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:c})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[X&&(0,r.jsx)("button",{onClick:$,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":_("actions.searchInFile"),title:_("actions.search"),children:(0,r.jsx)(ee.A,{className:"w-3.5 h-3.5"})}),X&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:er,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":_("actions.copyFileContent"),title:_("actions.copyContent"),children:v?(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(e0.A,{className:"w-3.5 h-3.5"})}),ey("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,r.jsx)("button",{onClick:eo,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":T?_("actions.exitFullscreen"):_("actions.fullscreen"),title:T?_("actions.exitFullscreen"):_("actions.fullscreen"),children:T?(0,r.jsx)(el.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(ei.A,{className:"w-3.5 h-3.5"})})]})]}),ek=()=>(null==x?void 0:x.readOnly)&&x.readOnlyReason?(0,r.jsx)(tb,{reason:x.readOnlyReason}):null,eN=()=>(0,r.jsx)(th,{searchInputRef:q,searchQuery:U,searchMatches:K,searchCurrentIdx:W,onQueryChange:Q,onPrev:Y,onNext:J,onClose:G});if(en&&x&&!h&&!g){let e=e=>"flex min-h-[44px] items-center justify-center gap-1 rounded-md px-2 text-xs font-medium touch-manipulation transition-colors ".concat(e?"bg-surface shadow-sm text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground");return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-testid":"markdown-file-screen",role:"dialog","aria-modal":"true","aria-label":c,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:tr.M.MAXIMIZED_EDITOR},children:[T?(0,r.jsxs)("div",{"data-testid":"markdown-file-immersive-controls",className:"absolute right-2 top-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-surface/90 shadow-sm",children:[(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:eo,"aria-pressed":!0,"aria-label":_("actions.exitFullscreen"),className:tx,children:(0,r.jsx)(el.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void em(),"aria-label":_("actions.close"),className:tx,children:(0,r.jsx)(ew.A,{className:"h-5 w-5"})})]}):(0,r.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1 border-b border-border bg-muted px-2",children:[(0,r.jsx)("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:c}),et&&(0,r.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":_("fileViewer.modeSwitch"),className:"flex flex-shrink-0 items-center gap-0.5 rounded-lg bg-muted p-0.5",children:[(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-viewer","aria-pressed":"viewer"===A,onClick:()=>M("viewer"),className:e("viewer"===A),children:[(0,r.jsx)(tn.A,{className:"h-4 w-4"}),_("fileViewer.modeViewer")]}),(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-editor","aria-pressed":"editor"===A,onClick:()=>M("editor"),className:e("editor"===A),children:[(0,r.jsx)(ta.A,{className:"h-4 w-4"}),_("fileViewer.modeEditor")]})]}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>L(!0),"aria-label":_("fileViewer.moreActions"),className:tx,children:(0,r.jsx)(o.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:eo,"aria-pressed":!1,"aria-label":_("actions.fullscreen"),className:tx,children:(0,r.jsx)(ei.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void em(),"aria-label":_("actions.close"),className:tx,children:(0,r.jsx)(ew.A,{className:"h-5 w-5"})})]}),H&&(0,r.jsx)("div",{className:"flex-shrink-0",children:eN()}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"viewer"===ea?"flex min-h-0 flex-1 flex-col":"hidden",children:H?(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:eg()}):ec?N?(0,r.jsxs)("div",{className:"flex h-full flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 bg-muted border-b border-border",children:[(0,r.jsx)("button",{type:"button",onClick:()=>I(e=>Math.max(0,e-1)),disabled:0===S,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:_("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[S+1," / ",N.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>I(e=>Math.min(N.length-1,e+1)),disabled:S===N.length-1,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:_("actions.next")})]}),(0,r.jsx)("iframe",{srcDoc:N[S],sandbox:"",title:_("fileViewer.slideTitle",{name:c,number:S+1}),className:"w-full flex-1 border-0"})]}):null:et?(0,r.jsx)("div",{"data-testid":"markdown-file-preview",className:"prose prose-sm dark:prose-invert min-h-0 max-w-none flex-1 overflow-y-auto p-4",children:(0,r.jsx)(eX.G8,{content:ex,currentFilePath:c,worktreeId:l,onOpenFile:m})}):null}),(0,r.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===ea?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,r.jsx)(tm,{worktreeId:l,filePath:c,initialContent:x.content,embedded:!0,onSave:eu,onDirtyChange:O,onContentChange:ed,onOpenFile:m},c)})]}),(0,r.jsx)(e5,{open:R,onClose:()=>L(!1),onSearch:()=>{M("viewer"),$()},onCopyContent:er,onCopyPath:es,downloadUrl:eb,downloadName:ev,contentCopied:v,pathCopied:w})]})})}return T&&x&&!h&&!g?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:tr.M.MAXIMIZED_EDITOR},children:[ej(),ek(),H&&eN(),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:ep()})]}):(0,r.jsx)(d.Jh,{isOpen:n,onClose:a,title:c,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[h&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(d.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:_("fileViewer.loading")})]}),g&&(0,r.jsxs)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("p",{className:"text-sm text-danger-foreground",children:g})]}),(0,r.jsx)("div",{className:"mt-3",children:ey("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium bg-surface border border-border text-foreground hover:bg-muted transition-colors",!0)})]}),x&&!h&&!g&&(0,r.jsxs)("div",{className:"bg-muted rounded-lg overflow-hidden flex flex-col min-h-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex-shrink-0",children:[ej(),ek(),H&&eN()]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:ep()})]})]})})});var ty=n(36809),tj=n(46892),tw=n(50857),tk=n(94442),tN=n(80344);function tC(e){let{worktreeId:t}=e,[n,a]=(0,s.useState)([]),[l,o]=(0,s.useState)(null),[c,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(!0),[h,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(0),[j,w]=(0,s.useState)("all"),[k,N]=(0,s.useState)(!1),{showToast:C}=(0,tk.dj)(),S=(0,i.c)("worktree");(0,s.useEffect)(()=>{(async()=>{try{x(!0),p(null);let e=await tN.y.getLogs(t);a(e)}catch(e){p((0,tN.hS)(e))}finally{x(!1)}})()},[t]);let I=(0,s.useMemo)(()=>"all"===j?n:n.filter(e=>e.toLowerCase().includes(j)),[n,j]),T=async e=>{try{x(!0),p(null);let n=await tN.y.getLogFile(t,e);u(n.content),o(e),b(""),y(0)}catch(e){p((0,tN.hS)(e))}finally{x(!1)}},E=(0,s.useCallback)(async()=>{if(l)try{N(!0);let e=await tN.y.getLogFile(t,l,{sanitize:!0});await (0,te.l)(e.content),C(S("logViewer.copied"),"success")}catch(e){C(S("logViewer.exportError",{error:(0,tN.hS)(e)}),"error")}finally{N(!1)}},[t,l,C,S]),A=(0,s.useMemo)(()=>{let e;if(!g||!c)return[];let t=RegExp((0,f.Nt)(g),"gi"),n=[];for(;null!==(e=t.exec(c));)n.push({index:e.index,length:e[0].length});return n},[g,c]);(0,s.useEffect)(()=>{y(0)},[g]);let M=()=>{A.length>0&&y(e=>(e+1)%A.length)},R=()=>{A.length>0&&y(e=>(e-1+A.length)%A.length)},L=(0,s.useMemo)(()=>{if(!c||!g||0===A.length)return c;let e="",t=0;return A.forEach((n,a)=>{e+=(0,f.ZD)(c.substring(t,n.index));let r=c.substring(n.index,n.index+n.length),s=a===v;e+='<mark class="'.concat(s?"bg-warning text-black":"bg-warning-border text-black",'" data-match-index="').concat(a,'">').concat((0,f.ZD)(r),"</mark>"),t=n.index+n.length}),e+=(0,f.ZD)(c.substring(t))},[c,g,A,v]);return(0,s.useEffect)(()=>{A.length>0&&v>=0&&setTimeout(()=>{let e=document.querySelector('mark[data-match-index="'.concat(v,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)},[v,A.length]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(d.Zp,{padding:"md",children:[(0,r.jsx)(d.aR,{children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(d.ZB,{children:S("logViewer.title")}),(0,r.jsx)(d.Ex,{variant:"gray",children:I.length})]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(d.$n,{variant:"all"===j?"primary":"ghost",size:"sm",onClick:()=>w("all"),children:S("logViewer.all",{count:n.length})}),(0,r.jsx)(d.$n,{variant:"claude"===j?"primary":"ghost",size:"sm",onClick:()=>w("claude"),children:S("logViewer.toolCount",{tool:"Claude",count:n.filter(e=>e.toLowerCase().includes("claude")).length})}),(0,r.jsx)(d.$n,{variant:"codex"===j?"primary":"ghost",size:"sm",onClick:()=>w("codex"),children:S("logViewer.toolCount",{tool:"Codex",count:n.filter(e=>e.toLowerCase().includes("codex")).length})}),(0,r.jsx)(d.$n,{variant:"gemini"===j?"primary":"ghost",size:"sm",onClick:()=>w("gemini"),children:S("logViewer.toolCount",{tool:"Gemini",count:n.filter(e=>e.toLowerCase().includes("gemini")).length})}),(0,r.jsx)(d.$n,{variant:"antigravity"===j?"primary":"ghost",size:"sm",onClick:()=>w("antigravity"),children:S("logViewer.toolCount",{tool:"Antigravity",count:n.filter(e=>e.toLowerCase().includes("antigravity")).length})})]})]})}),(0,r.jsxs)(d.Wu,{children:[m&&0===n.length&&(0,r.jsx)("div",{className:"text-center py-4",children:(0,r.jsx)(d.y$,{size:"lg",variant:"accent",className:"inline-block"})}),h&&(0,r.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:h}),!m&&0===I.length&&!h&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"all"===j?S("logViewer.empty"):S("logViewer.emptyFiltered",{tool:j})}),I.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:I.map(e=>(0,r.jsx)("button",{onClick:()=>T(e),className:"w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ".concat(l===e?"bg-accent-50 text-accent-700 border border-accent-200":"hover:bg-muted border border-transparent"),children:e},e))})]})]}),l&&(0,r.jsxs)(d.Zp,{padding:"md",children:[(0,r.jsx)(d.aR,{children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(d.ZB,{className:"font-mono text-base",children:l}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(d.$n,{variant:"ghost",size:"sm",onClick:E,disabled:!l||k,title:S("logViewer.copyTitle"),children:k?S("logViewer.exporting"):S("logViewer.export")}),(0,r.jsx)(d.$n,{variant:"ghost",size:"sm",onClick:()=>{o(null),u(null),b(""),y(0)},children:S("actions.close")})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)(d.pd,{type:"text",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),e.shiftKey?R():M())},placeholder:S("logViewer.searchPlaceholder"),className:"w-full pr-20"}),A.length>0&&(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:[v+1," / ",A.length]})]}),A.length>0&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(d.$n,{variant:"ghost",size:"sm",onClick:R,disabled:0===A.length,title:S("logViewer.prevMatch"),children:"↑"}),(0,r.jsx)(d.$n,{variant:"ghost",size:"sm",onClick:M,disabled:0===A.length,title:S("logViewer.nextMatch"),children:"↓"})]})]})]})}),(0,r.jsxs)(d.Wu,{children:[m&&(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)(d.y$,{size:"xl",variant:"accent",className:"inline-block"})}),!m&&c&&(0,r.jsx)("div",{className:"bg-[#111827] text-[#f3f4f6] rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:g&&A.length>0?(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:L||""}}):(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:c})}),!m&&g&&0===A.length&&c&&(0,r.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:S("logViewer.noMatches",{query:g})})]})]})]})}var tS=n(63470),tI=n(79361);function tT(e){let{version:t,className:n}=e,a=(0,i.c)("worktree"),{checking:s}=(0,tS.Y)();return(0,r.jsxs)("div",{className:n,"data-testid":"version-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:a("update.version")}),(0,r.jsx)("p",{className:"text-sm text-foreground",children:t}),s&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"version-loading",children:"..."}),(0,r.jsx)(tI.V,{})]})}let tE="https://github.com/Kewton/CommandMate",tA="".concat(tE,"/issues"),tM="".concat(tE,"/issues/new"),tR="".concat(tM,"?template=bug_report.md"),tL="".concat(tM,"?template=feature_request.md"),tP="".concat(tM,"?template=question.md");function tD(e){let{className:t}=e,n=(0,i.c)("worktree"),a=[{href:tR,label:n("feedback.bugReport")},{href:tL,label:n("feedback.featureRequest")},{href:tP,label:n("feedback.question")},{href:tA,label:n("feedback.viewIssues")}];return(0,r.jsxs)("div",{className:t,"data-testid":"feedback-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-2",children:n("feedback.title")}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:a.map(e=>{let{href:t,label:n}=e;return(0,r.jsxs)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[n,(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},t)})})]})}var tF=n(94465),tO=n(38606),tz=n(34681),t_=n(72137);let tB="v".concat("0.44.3"),tV=[{value:null,labelKey:"worktreeStatus.notSet"},{value:"ready",labelKey:"worktreeStatus.ready"},{value:"in_progress",labelKey:"worktreeStatus.inProgress"},{value:"in_review",labelKey:"worktreeStatus.inReview"},{value:"done",labelKey:"worktreeStatus.done"}];function tH(e,t,n){return(0,m.Mq)(e,(0,tO.px)(n?null==t?void 0:t[n]:void 0))}function tU(e,t,n){if(!e)return null;let a=t?"".concat(e," \xb7 ").concat(t):e;return n?"".concat(n," \xb7 ").concat(a):a}function tK(e,t){if(!e||!e.liveness&&!e.degradedReason)return null;let n=t("sse"===e.kind?"agentSource.kindSse":"scraper"===e.kind?"agentSource.kindScraper":"agentSource.kindHooks"),a=void 0===e.degradedReason?null:"port_identity_changed"===e.degradedReason?t("agentSource.reasonPortIdentityChanged"):"heartbeat_stale"===e.degradedReason?t("agentSource.reasonHeartbeatStale"):"not_subscribed"===e.degradedReason?t("agentSource.reasonNotSubscribed"):t("agentSource.reasonOther",{reason:e.degradedReason}),r=["stale"===e.liveness?t("agentSource.livenessStale"):"live"===e.liveness?t("agentSource.livenessLive"):null,a].filter(e=>null!==e).join(" \xb7 ");return r?t("agentSource.line",{kind:n,state:r}):t("agentSource.lineBare",{kind:n})}function tW(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return"number"==typeof e&&Number.isFinite(e)?new Intl.NumberFormat(t,{style:"currency",currency:"USD",minimumFractionDigits:n,maximumFractionDigits:n}).format(e):null}function tq(e,t,n,a){var r;let s=tW(null==e?void 0:e.cost,a),l=(r=null==t?void 0:t.tokens,"number"==typeof r&&Number.isFinite(r)?new Intl.NumberFormat(a,{notation:"compact",maximumFractionDigits:1}).format(r):null),i=[];return s&&i.push(s),l&&i.push("number"==typeof(null==t?void 0:t.percent)?n("agentSession.context",{tokens:l,percent:t.percent}):l),i.length>0?i.join(" \xb7 "):null}function t$(e){if(!e)return{};let t={};for(let[n,a]of Object.entries(e)){let e=tU(null==a?void 0:a.model,null==a?void 0:a.reasoningEffort);e&&(t[n]=e)}return t}function tG(e,t,n,a){let[r,l]=(0,s.useState)(!1),[i,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>{a()&&e&&(o(e.description||""),l(!1))},[n,e]);let u=(0,s.useCallback)(async()=>{if(e){d(!0);try{let n=await tN.y.updateDescription(e.id,i);t(n),l(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,i,t]),m=(0,s.useCallback)(()=>{o((null==e?void 0:e.description)||""),l(!1)},[e]);return{isEditing:r,text:i,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,s.useCallback)(()=>{l(!0)},[])}}let tJ=(0,s.memo)(function(e){var t,n;let{worktreeId:a,worktree:l,cardClassName:o,descriptionEditor:c,showLogs:u,onToggleLogs:m,onWorktreeUpdate:x}=e,{isEditing:f,text:h,setText:p,isSaving:g,handleSave:b,handleCancel:v,startEditing:y}=c,j=(0,i.c)("worktree"),w=(0,i.c)("common"),{copied:k,markCopied:N}=(0,tc.q)(),{copied:C,markCopied:S}=(0,tc.q)(),I=(0,s.useCallback)(async()=>{try{await (0,te.l)(l.path),N()}catch(e){}},[l.path,N]),T=(0,s.useCallback)(async()=>{try{await (0,te.l)(l.repositoryPath),S()}catch(e){}},[l.repositoryPath,S]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:o,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.worktree")}),(0,r.jsx)("p",{className:"text-lg font-semibold text-foreground",children:l.name})]}),(0,r.jsxs)("div",{className:o,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.repository")}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:T,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":j("detail.copyRepositoryPath"),title:C?j("detail.copied"):j("detail.copyRepositoryPath"),children:C?(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(e1.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-base text-foreground",children:null!=(t=l.repositoryDisplayName)?t:l.repositoryName}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:l.repositoryPath})]}),(0,r.jsxs)("div",{className:o,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.path")}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:I,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":j("detail.copyWorktreePath"),title:k?j("detail.copied"):j("detail.copyPath"),children:k?(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(e1.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:l.path})]}),(0,r.jsxs)("div",{className:o,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.status")}),(0,r.jsx)("select",{value:null!=(n=l.status)?n:"",onChange:async e=>{let t=e.target.value;try{let e=await fetch("/api/worktrees/".concat(l.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===t?null:t})});if(e.ok&&x){let t=await e.json();x(t)}}catch(e){}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":j("detail.worktreeStatusLabel"),children:tV.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:j(e.labelKey)},e.labelKey)})})]}),(0,r.jsxs)("div",{className:o,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.description")}),!f&&(0,r.jsx)("button",{type:"button",onClick:y,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:j("actions.edit")})]}),f?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:h,onChange:e=>p(e.target.value),placeholder:j("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:b,disabled:g,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:g?j("actions.saving"):j("actions.save")}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:v,disabled:g,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:w("cancel")})]})]}):(0,r.jsx)("div",{className:"min-h-[50px]",children:l.description?(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:l.description}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground italic",children:j("detail.noDescription")})})]}),l.link&&(0,r.jsxs)("div",{className:o,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.link")}),(0,r.jsx)("a",{href:l.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:l.link})]}),l.updatedAt&&(0,r.jsxs)("div",{className:o,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.lastUpdated")}),(0,r.jsx)("p",{className:"text-sm text-foreground",children:new Date(l.updatedAt).toLocaleString()})]}),(0,r.jsx)(tT,{version:tB,className:o}),(0,r.jsx)(tD,{className:o}),(0,r.jsxs)("div",{className:o,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.logs")}),(0,r.jsx)("button",{type:"button",onClick:m,className:"text-sm text-accent-600 hover:text-accent-800",children:u?j("detail.hide"):j("detail.show")})]}),u&&(0,r.jsx)(tC,{worktreeId:a})]})]})}),tY=(0,s.memo)(function(e){var t,n,a,l,o,c,x;let{worktreeName:h,repositoryName:p,description:g,status:b,gitStatus:v,onInfoClick:y,hasUpdate:j,worktreeStatus:w,onWorktreeStatusChange:N,sessionStatusByCli:C,sessionStatusByInstance:S,instances:I,activeInstanceId:T,onActiveInstanceChange:E,onAgentDragStart:A,onAgentDragEnd:M,onKillSession:R,verificationChip:L,agentSessionByInstance:P}=e,D=(0,i.c)("worktree"),F=(0,ty.Ym)(),O=(0,i.c)("common"),z=tj.sb[b],_=z?D(z):void 0,[B,V]=(0,s.useState)(null),H=null==I?void 0:I.find(e=>e.id===T),U=!!T&&null!=(o=null!=(l=null==S||null==(t=S[T])?void 0:t.isRunning)?l:H?null==C||null==(n=C[H.cliTool])?void 0:n.isRunning:void 0)&&o,K=tH(b,C,null==H?void 0:H.cliTool),W=(0,s.useCallback)((e,t)=>{e.dataTransfer.setData(ef,t),e.dataTransfer.effectAllowed="move",V(t),null==A||A(t)},[A]),q=(0,s.useCallback)(()=>{V(null),null==M||M()},[M]),$=g?(0,f.W5)(g,50):null,G=(null!=I?I:[]).map(e=>{var t;return{item:e,status:(0,tO.kA)(null!=(t=null==S?void 0:S[e.id])?t:null==C?void 0:C[e.cliTool]),isActive:e.id===T}}),J=new Set((null!=I?I:[]).filter(e=>{var t;return(0,tO.px)(null!=(t=null==S?void 0:S[e.id])?t:null==C?void 0:C[e.cliTool])}).map(e=>e.id)),Y=(e,t)=>(0,m.Mq)(t,J.has(e))?O(m.rH):O("status.".concat(t)),Q=(e,t)=>(0,m.Mq)(t,J.has(e))?m.Jd:void 0,X=(null!=I?I:[]).some(e=>{var t,n;return(null==(t=null!=(n=null==S?void 0:S[e.id])?n:null==C?void 0:C[e.cliTool])?void 0:t.awaitingInstruction)===!0}),Z=!!R&&U,ee=(0,tS.Y)(),et="".concat(null!=(c=null==(a=ee.updateInfo)?void 0:a.latestVersion)?c:"",":").concat(ee.hasUpdate,":").concat(ee.state),en=[F,h,p,null!=$?$:"",null!=(x=null==v?void 0:v.currentBranch)?x:"",(null==v?void 0:v.isDirty)?"dirty":"",Z?"end":"",X?"awaiting":"",et,...G.map(e=>"".concat(e.item.id,":").concat((0,eo.sw)(e.item),":").concat(e.status,":").concat(e.isActive?"active":"")+(J.has(e.item.id)?":unclassified":""))].join("\n"),ea=(0,s.useRef)(null),er=(0,s.useRef)(null),es=function(e,t,n,a,r){let[l,i]=(0,s.useState)(()=>({key:n,pillBudget:4,squeezed:!1})),o=l;return l.key!==n&&i(o={key:n,pillBudget:4,squeezed:!1}),(0,s.useLayoutEffect)(()=>{let e=t.current;e&&!l.squeezed&&function(e){if(e.scrollWidth>e.clientWidth+1)return!0;for(let t of Array.from(e.querySelectorAll("*")))if(!(t.scrollWidth<=t.clientWidth+1)&&"visible"===getComputedStyle(t).overflowX)return!0;return!1}(e)&&i(e=>{if(e.squeezed)return e;let t=Math.min(e.pillBudget,a);return t>0?{...e,pillBudget:t-1}:{...e,squeezed:!0}})},[t,l,a,r]),(0,s.useEffect)(()=>{let t=e.current;if(!t||"undefined"==typeof ResizeObserver)return;let n=null,a=null,r=new ResizeObserver(e=>{var t;let r=null==(t=e[e.length-1])?void 0:t.contentRect;if(!r)return;let s=r.width!==n;(s||r.height!==a)&&(n=r.width,a=r.height,i(e=>s?{key:e.key,pillBudget:4,squeezed:!1}:{...e}))});return r.observe(t),()=>r.disconnect()},[e]),{pillBudget:o.pillBudget,squeezed:o.squeezed}}(ea,er,en,G.filter(tw.Lm).length,L);return(0,r.jsxs)("div",{ref:ea,"data-testid":"desktop-header",className:"flex items-center justify-between gap-3 px-4 py-3 bg-surface border-b border-border",children:[(0,r.jsxs)("div",{ref:er,"data-testid":"desktop-header-identity",className:"flex items-center gap-3 min-w-0".concat(es.squeezed?" overflow-x-clip":""),children:[(0,r.jsx)(u.m,{"data-testid":"desktop-status-indicator",status:b,size:"lg",label:K?O(m.rH):_,className:K?m.Jd:void 0,"data-unclassified":K?"true":void 0}),(0,r.jsxs)("div",{className:"flex flex-col min-w-[6rem] shrink-4",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:h}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"truncate max-w-[200px]",children:p}),v&&"(unknown)"!==v.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:v.currentBranch,"data-testid":"desktop-branch-name",children:(0,f.W5)(v.currentBranch,30)}),v.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:D("git.uncommittedChanges"),children:"*"})]}),$&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,r.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:g,children:$})]})]})]}),L&&(0,r.jsx)("div",{className:"min-w-0 w-[360px] max-w-max",children:L})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 max-w-full","data-testid":"desktop-header-controls",children:[I&&I.length>0&&(()=>{var e,t,n,a;let s=(0,tw.Uw)(G,es.pillBudget),l=s.filter(e=>"overflow"===e.slot),i=null!=(a=null!=(n=null==(e=l.find(e=>"running"===e.status||"generating"===e.status))?void 0:e.status)?n:null==(t=l.find(e=>"waiting"===e.status))?void 0:t.status)?a:null;return(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0".concat(es.squeezed?" overflow-x-clip":""),"data-testid":"desktop-agent-status-row",children:[s.map(e=>{var t;if("overflow"===e.slot)return null;let n=e.item,a=(0,eo.sw)(n),s=Y(n.id,e.status),l=Q(n.id,e.status),i=D("detail.statusPill",{label:a,status:s}),o=null==S?void 0:S[n.id],c=null==P?void 0:P[n.id],d=tU(null==o?void 0:o.model,null==o?void 0:o.reasoningEffort,null==c||null==(t=c.session)?void 0:t.agent),m=d?D("detail.statusPillWithModel",{label:a,status:s,model:d}):i,x=tq(null==c?void 0:c.session,null==c?void 0:c.context,D,F),f=x?D("detail.statusPillWithUsage",{base:m,usage:x}):m,h=tK(null==o?void 0:o.eventSource,D),p=h?D("detail.statusPillWithSource",{base:f,source:h}):f,g=e.isActive,b={draggable:!0,onDragStart:e=>W(e,n.id),onDragEnd:q},v=B===n.id?" opacity-50 cursor-grabbing":"";return"pill"===e.slot?(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==E?void 0:E(n.id),...b,"aria-label":p,title:p,"aria-pressed":g,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(g?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground").concat(v),children:[(0,r.jsx)(u.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0,className:l}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:i})]},n.id):(0,r.jsx)(eu.m_,{content:p,placement:"bottom",children:(0,r.jsx)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==E?void 0:E(n.id),...b,"aria-label":p,"aria-pressed":g,className:"flex items-center justify-center w-6 h-6 rounded-full transition-colors ".concat(g?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted").concat(v),children:(0,r.jsx)(u.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0,className:l})})},n.id)}),l.length>0&&(0,r.jsxs)(ed.rI,{children:[(0,r.jsx)(ed.ty,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":D("agentStatus.moreAgents",{count:l.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[i&&(0,r.jsx)(u.m,{status:i,size:"sm","aria-hidden":!0,title:void 0}),"+",l.length]})}),(0,r.jsx)(ed.SQ,{align:"end",children:l.map(e=>{let t=e.item,n=D("detail.statusPill",{label:(0,eo.sw)(t),status:Y(t.id,e.status)});return(0,r.jsxs)(ed._2,{"data-testid":"desktop-agent-overflow-".concat(t.id),onSelect:()=>null==E?void 0:E(t.id),children:[(0,r.jsx)(u.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0,className:Q(t.id,e.status)}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:n})]},t.id)})})]}),X&&(0,r.jsx)("span",{"data-testid":"desktop-awaiting-instruction-badge",className:"flex-shrink-0 rounded-full bg-success-subtle px-1.5 py-0.5 text-[10px] font-medium leading-4 text-success-foreground",title:D("awaitingInstruction.label"),children:D("awaitingInstruction.badge")})]})})(),Z&&(0,r.jsxs)(d.$n,{variant:"ghost",type:"button",onClick:R,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":D("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),O("end")]}),N&&(0,r.jsx)("select",{value:null!=w?w:"",onChange:e=>{let t=e.target.value;N(""===t?null:t)},onClick:e=>e.stopPropagation(),className:"flex-shrink-0 text-xs px-2 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent cursor-pointer","data-testid":"desktop-status-dropdown","aria-label":D("detail.worktreeStatusLabel"),children:tV.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:D(e.labelKey)},e.labelKey)})}),(0,r.jsx)(t_.H,{}),(0,r.jsx)(tz.g,{}),(0,r.jsxs)(d.$n,{variant:"ghost",type:"button",onClick:y,className:"relative flex flex-shrink-0 items-center gap-1.5 px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors","aria-label":D("detail.viewInfo"),"data-testid":"desktop-info-button",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.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"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:D("detail.info")}),j&&(0,r.jsx)(k,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":D("tabs.updateAvailable")})]})]})]})}),tQ=(0,s.memo)(function(e){let{worktreeId:t,worktree:n,isOpen:a,onClose:l,onWorktreeUpdate:o}=e,[c,d]=(0,s.useState)(!1),u=(0,i.c)("worktree"),m=(0,s.useRef)(a),x=tG(n,o,a,()=>{let e=a&&!m.current;return m.current=a,e});return n?(0,r.jsx)(tF.a,{isOpen:a,onClose:l,title:u("detail.infoModalTitle"),size:"md",children:(0,r.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto","data-testid":"worktree-info-modal",children:(0,r.jsx)(tJ,{worktreeId:t,worktree:n,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:x,showLogs:c,onToggleLogs:()=>d(!c),onWorktreeUpdate:o})})}):null}),tX=(0,s.memo)(function(){let e=(0,i.c)("worktree");return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(d.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:e("detail.loading")})]})})}),tZ=(0,s.memo)(function(e){let{message:t,onRetry:n}=e,a=(0,i.c)("worktree"),s=(0,i.c)("common");return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,r.jsxs)("div",{className:"text-center p-6 bg-danger-subtle rounded-lg border border-danger-border max-w-md",children:[(0,r.jsx)("svg",{className:"mx-auto h-12 w-12 text-danger-foreground/70 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.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,r.jsx)("p",{className:"text-danger-foreground font-medium",children:a("detail.errorLoading")}),(0,r.jsx)("p",{className:"text-danger-foreground/80 text-sm mt-2",children:t}),n&&(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:n,className:"mt-4 px-4 py-2 bg-danger-foreground text-danger-subtle rounded-lg hover:opacity-90 transition-opacity focus:outline-none focus:ring-2 focus:ring-danger focus:ring-offset-2 ring-offset-background",children:s("retry")})]})})});var t0=n(95707),t1=n(14006),t2=n(73190),t4=n(88155),t5=n(89599),t3=n(56827);function t6(e){return""!==(null!=e?e:"").trim()}function t8(e){let{worktreeId:t,cliToolId:n,instanceId:a,composerText:l,onActionSent:o}=e,c=(0,i.c)("worktree"),[d,u]=(0,s.useState)(!1),m=(0,t3.B)(t,n,a,o),x=(0,s.useCallback)(()=>{m(["Enter"])},[m]),f=(0,s.useCallback)(()=>{u(!0);let e=a&&a!==n?{cliToolId:n,instanceId:a}:{cliToolId:n};fetch("/api/worktrees/".concat(encodeURIComponent(t),"/clear-composer"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(()=>{o&&setTimeout(o,ek.LK)}).catch(e=>{console.error("Failed to clear composer:",e)}).finally(()=>{u(!1)})},[t,n,a,o]);if(!t6(l))return null;let h=l.length>300?"".concat(l.slice(0,300),"…"):l;return(0,r.jsxs)("div",{"data-testid":"unsent-composer-bar",role:"region","aria-label":c("unsentComposer.regionLabel"),className:"flex flex-wrap items-center gap-2 px-2 py-1.5 bg-info-subtle border border-info-border rounded-lg",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-info-foreground shrink-0",children:c("unsentComposer.label")}),(0,r.jsx)("code",{"data-testid":"unsent-composer-text",className:"flex-1 min-w-0 font-mono text-xs text-foreground break-all line-clamp-3 whitespace-pre-wrap",children:h}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:x,"aria-label":c("unsentComposer.run"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-info-foreground text-info-subtle hover:opacity-90 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",children:c("unsentComposer.run")}),(0,r.jsx)("button",{type:"button",onClick:f,disabled:d,"aria-label":c("unsentComposer.clear"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-surface border border-info-border text-info-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",children:c("unsentComposer.clear")})]})]})}var t9=n(51515),t7=n(813),ne=n(16342);let nt=/^([^\S\n]*)╹(▀{4,})/,nn=/^([^\S\n]*)[│┃]/;function na(e,t){return"opencode"===e&&null!==function(e){let t=(0,t9.aJ)(e).split("\n"),n=-1,a=-1,r=-1;for(let e=0;e<t.length;e++){let s=nt.exec(t[e]);s&&(n=e,r=(a=s[1].length)+1+s[2].length)}if(-1===n)return null;let s=0,l="";for(let e=0;e<t.length;e++){let i=t[e];if(e!==n){let e=nn.exec(i);if(!e||e[1].length!==a)continue}let o=i.slice((0,ne.sh)(i,r)).trim();""!==o&&(s+=1,""===l&&(l=(0,t7.D)(o,200,"…[truncated]")))}return s<2?null:{id:"opencode_sidebar",matchedText:l,boxRight:r,rows:s}}(null!=t?t:"")}function nr(e){let{cliToolId:t,frame:n}=e,a=(0,i.c)("worktree");return(0,s.useMemo)(()=>na(t,n),[t,n])?(0,r.jsxs)("div",{"data-testid":"opencode-sidebar-notice",role:"status","aria-label":a("opencodeSidebar.regionLabel"),className:"flex flex-wrap items-center gap-2 px-2 py-1.5 bg-warning-subtle border border-warning-border rounded-lg",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-warning-foreground shrink-0",children:a("opencodeSidebar.label")}),(0,r.jsx)("span",{className:"flex-1 min-w-0 text-xs text-foreground",children:a("opencodeSidebar.body")}),(0,r.jsx)("code",{"data-testid":"opencode-sidebar-notice-chord",className:"shrink-0 font-mono text-xs px-1.5 py-0.5 rounded bg-surface border border-warning-border text-warning-foreground",children:"ctrl+x b"})]}):null}var ns=n(92833),nl=n(58597);function ni(e,t){return(0,s.useMemo)(()=>({isRunning:e.isRunning,attaching:e.attaching,sessionStatus:e.sessionStatus,isThinking:e.isThinking,isPromptWaiting:t.visible,promptData:t.data,isSelectionListActive:e.isSelectionListActive,isPagerActive:e.isPagerActive,isDismissablePanelActive:e.isDismissablePanelActive,isUnclassifiedActive:e.isUnclassifiedActive,startingSince:e.startingSince}),[e.isRunning,e.attaching,e.sessionStatus,e.isThinking,e.isSelectionListActive,e.isPagerActive,e.isDismissablePanelActive,e.isUnclassifiedActive,e.startingSince,t.visible,t.data])}var no=n(32771),nc=n(308),nd=n(80635),nu=n(52407);function nm(e){let{worktreeId:t,serverMessages:n,onSent:a}=e,r=(0,s.useCallback)((e,n)=>tN.y.sendMessage(t,e,n),[t]),l=(0,nu.Fx)(),i=(0,s.useMemo)(()=>({offline:(0,nu.sV)(l.signals),reachable:(0,nu._X)(l.signals)}),[l.signals]);return(0,nd.v4)({worktreeId:t,serverMessages:n,sendFn:r,onSent:a,connectivity:i})}function nx(e,t){return(0,s.useCallback)(n=>{let a=e(n);a&&(null==t||t(a))},[e,t])}let nf=(0,s.createContext)({register:()=>{},insertToComposer:()=>{}}),nh=(0,s.createContext)(null);function np(e){var t;return null!=(t=e.instanceId)?t:e.cliToolId}function ng(e){let{onInsertToComposer:t,children:n}=e,[a,l]=(0,s.useState)(null),i=(0,s.useRef)(t);i.current=t;let o=(0,s.useCallback)(e=>{var t;null==(t=i.current)||t.call(i,e)},[]),c=(0,s.useMemo)(()=>({register:l,insertToComposer:o}),[o]);return(0,r.jsx)(nf.Provider,{value:c,children:(0,r.jsx)(nh.Provider,{value:a,children:n})})}function nb(e){let t=(0,s.useContext)(nh);if(null!==t&&t.target.cliToolId===e.cliToolId&&np(t.target)===np(e))return t.send}var nv=n(9708),ny=n(26788),nj=n(60199),nw=n(52703);function nk(e){var t;let{showSessionRow:n,sessionNote:a,onCommit:s,onCancel:l}=e,o=(0,i.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"mobile-session-note-editor",className:"absolute inset-x-2 z-40 rounded-md border border-border bg-surface p-2 shadow-lg ".concat(n?"top-9":"top-2"),children:[(0,r.jsx)(eb,{initialText:null!=(t=null==a?void 0:a.text)?t:"",onCommit:s,onCancel:l,ariaLabel:o("sessionNote.menuItem"),placeholder:o("sessionNote.placeholder"),testId:"mobile-session-note-input"}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:o("sessionNote.hint")})]})}let nN=[{mode:"terminal",labelKey:"surfaceMode.terminal",icon:b.A},{mode:"chat",labelKey:"surfaceMode.chat",icon:er.A}];function nC(e){let{surfaceMode:t,showSessionRow:n,directInputOpen:a,onSurfaceToggle:s,showToolActivity:l,onToggleToolActivity:o}=e,c=(0,i.c)("worktree");return(0,r.jsxs)("div",{role:"group","aria-label":c("surfaceMode.groupLabelMobile"),"data-testid":"mobile-surface-mode-toggle",className:"pointer-events-none absolute right-2 z-30 flex items-center gap-0.5 rounded-full border border-border bg-surface-2/95 p-0.5 shadow-lg backdrop-blur ".concat(n?"top-9":"top-2"),children:[nN.map(e=>{let{mode:n,labelKey:l,icon:i}=e,o=t===n,d=c(l);return(0,r.jsx)("button",{type:"button",onClick:()=>s(n),"aria-pressed":o,"aria-label":d,"aria-disabled":!!a||void 0,title:d,"data-testid":"mobile-surface-mode-".concat(n),className:"pointer-events-auto flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-colors touch-manipulation ".concat(o?"bg-accent-500/20 text-accent-600 dark:text-accent-400":"text-muted-foreground"," ").concat(a?"opacity-40":""),children:(0,r.jsx)(i,{size:18,"aria-hidden":"true"})},n)}),"chat"===t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"mx-0.5 h-6 w-px bg-border"}),(0,r.jsx)("button",{type:"button",onClick:o,"aria-pressed":l,"aria-label":l?c("chatTranscript.toolActivity.hide"):c("chatTranscript.toolActivity.show"),title:l?c("chatTranscript.toolActivity.hide"):c("chatTranscript.toolActivity.show"),"data-testid":"mobile-chat-tool-activity-toggle",className:"pointer-events-auto flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-colors touch-manipulation ".concat(l?"bg-accent-500/15 text-accent-700 dark:text-accent-400":"text-muted-foreground"),children:(0,r.jsx)(j.A,{size:18,"aria-hidden":"true"})})]}):null]})}var nS=n(51021),nI=n(68394),nT=n(17683);function nE(e){let[t,n]=(0,s.useState)(ec.wf);return(0,s.useEffect)(()=>{n((0,nT.TR)(e))},[e]),{surfaceMode:t,handleSurfaceModeChange:(0,s.useCallback)(t=>{n(t),(0,nT.If)(e,t)},[e])}}function nA(e,t,n,a){var r;return{model:tU(e,null,null==(r=t.session)?void 0:r.agent),usage:tq(t.session,t.context,n,a),usageDetail:function(e,t,n,a){let r=[];(null==e?void 0:e.title)&&r.push(n("agentSession.titleLabel",{title:e.title})),(null==e?void 0:e.agent)&&r.push(n("agentSession.agentLabel",{agent:e.agent}));let s=tW(null==e?void 0:e.cost,a,4);s&&r.push(n("agentSession.costLabel",{cost:s}));let l=function(e){if(!e)return null;if(null!==e.total)return e.total;let t=[e.input,e.output,e.reasoning,e.cacheRead,e.cacheWrite].filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===t.length?null:t.reduce((e,t)=>e+t,0)}(null==e?void 0:e.tokens);if(null!==l&&r.push(n("agentSession.spentLabel",{tokens:new Intl.NumberFormat(a).format(l)})),"number"==typeof(null==t?void 0:t.tokens)){let e=new Intl.NumberFormat(a).format(t.tokens);r.push("number"==typeof t.limit&&"number"==typeof t.percent?n("agentSession.contextLabel",{tokens:e,limit:new Intl.NumberFormat(a).format(t.limit),percent:t.percent}):n("agentSession.contextUnknownLabel",{tokens:e}))}return r.length>0?r.join("\n"):null}(t.session,t.context,n,a)}}let nM="top-16",nR=[nS.Mx,"m"],nL="/model",nP=(0,s.memo)(function(e){let{modelLabel:t,usage:n,usageDetail:a,recentChange:s,note:l,onEditNote:o,onOpenPicker:c,onDismissChange:d}=e,u=(0,i.c)("worktree"),m=null!==s,x=u("agentModel.sessionRow",{model:null!=t?t:""}),f=l?(0,ex.Uq)(new Date(l.updatedAt)):"",h=l?u("sessionNote.label",{note:l.text,time:f}):u("sessionNote.menuItem");return(0,r.jsxs)("div",{"data-testid":"mobile-session-row","data-model-changed":m?"true":"false",className:"relative z-20 flex h-7 shrink-0 items-center gap-2 border-b px-3 text-[11px] leading-none ".concat(m?"border-warning-border bg-warning-subtle text-warning-foreground":"border-border bg-surface-2 text-muted-foreground"),children:[t?(0,r.jsxs)("button",{type:"button",onClick:c,"aria-label":x,title:x,"data-testid":"mobile-session-model",className:"relative flex min-w-0 basis-0 grow items-center gap-1.5 truncate text-left touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-[''] ".concat(l?"shrink-[4]":"shrink"),children:[(0,r.jsx)(t0.A,{size:12,"aria-hidden":"true",className:"shrink-0"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:t})]}):null,l?(0,r.jsxs)("button",{type:"button",onClick:o,"aria-label":h,title:h,"data-testid":"mobile-session-note",className:"relative flex min-w-0 shrink basis-0 grow items-center gap-1 text-left touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-['']",children:[(0,r.jsx)(et.A,{size:12,"aria-hidden":"true",className:"shrink-0 opacity-70"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:l.text}),(0,r.jsx)("span",{"data-testid":"mobile-session-note-time",className:"shrink-0 tabular-nums opacity-70",children:f})]}):null,n?(0,r.jsx)("span",{"data-testid":"mobile-session-usage",title:null!=a?a:u("agentSession.chipLabel",{usage:n}),className:"min-w-0 max-w-[10rem] shrink-0 truncate tabular-nums",children:n}):null,s?(0,r.jsx)("button",{type:"button",onClick:d,"aria-label":u("agentModel.changedRecentlyDetail",{from:s.from,to:s.to}),title:u("agentModel.changedRecentlyDetail",{from:s.from,to:s.to}),"data-testid":"mobile-session-model-changed",className:"relative shrink-0 rounded-full border border-warning-border bg-warning/20 px-1.5 py-0.5 font-medium touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-['']",children:u("agentModel.changedRecently")}):null]})}),nD=(0,s.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,live:l,frame:i,onKeysSent:o,onSurfaceModeChange:c}=e,{messages:d,isLoading:u,refresh:m}=(0,nc.Md)({worktreeId:t,cliToolId:n,instanceId:a}),{messages:x,sendOptimistic:f,retry:h,discard:p}=nm({worktreeId:t,serverMessages:d,onSent:m});!function(e){let{cliToolId:t,instanceId:n,send:a}=e,{register:r}=(0,s.useContext)(nf);(0,s.useEffect)(()=>(r({target:{cliToolId:t,instanceId:n},send:a}),()=>r(null)),[r,t,n,a])}({cliToolId:n,instanceId:a,send:f});let{worktreePath:g,openFile:b}=(0,nv.O)(),v=(0,s.useContext)(nf).insertToComposer,y=nx(p,v);return(0,r.jsx)(nl.wY,{messages:x,worktreeId:t,worktreePath:g,cliToolId:n,instanceId:a,live:l,onSurfaceModeChange:c,frame:i,onKeysSent:o,compact:!0,history:{onFilePathClick:b,isLoading:u,onRetryPending:h,onDiscardPending:y,onInsertToMessage:v,hideCornerControls:!0,openSearchOnWindowEvent:!0,searchBarTopClassName:nM}})}),nF=(0,s.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,disableAutoFollow:l,onSurfaceModeChange:o,directInputOpen:c=!1}=e,{terminal:d,prompt:u,agentSession:m,setAutoScroll:x,refresh:f}=(0,no.NK)({worktreeId:t,cliToolId:n,instanceId:a}),{compactTuiLayoutPadding:h,preservePaintedPanelRows:p,mobileWrapMode:g}=(0,nI.EK)(n),b=(0,i.c)("worktree"),v=(0,ty.Ym)(),y=null!=a?a:n,{model:j,usage:w,usageDetail:k}=nA(function(e,t){let n=(0,em.rC)(),a=null==n?void 0:n.worktrees;return(0,s.useMemo)(()=>{var n;let r=null==a?void 0:a.find(t=>t.id===e);return null!=(n=t$(null==r?void 0:r.sessionStatusByInstance)[t])?n:null},[a,e,t])}(t,y),m,b,v),{sessionNote:N,noteEditing:C,openNoteEditor:S,closeNoteEditor:I,commitNote:T}=function(e,t){let{note:n,save:a}=eg(e,t),[r,l]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=()=>l(!0);return window.addEventListener(ep,e),()=>window.removeEventListener(ep,e)},[]),(0,s.useEffect)(()=>{l(!1)},[e,t]);let i=(0,s.useCallback)(()=>l(!0),[]);return{sessionNote:n,noteEditing:r,openNoteEditor:i,closeNoteEditor:(0,s.useCallback)(()=>l(!1),[]),commitNote:(0,s.useCallback)(e=>{a(e),l(!1)},[a])}}(t,y),E=null!==j||null!==N,{recentModelChange:A,dismissModelChange:M}=function(e,t){let n=(0,em.rC)(),[a,r]=(0,s.useState)(null);(0,nj.T3)(a=>{a.type===nw.T4&&a.worktreeId===e&&a.instance===t&&(r({from:a.from,to:a.to,at:a.at}),null==n||n.refresh())}),(0,s.useEffect)(()=>{if(null===a)return;let e=a.at+3e5-Date.now();if(e<=0)return void r(null);let t=setTimeout(()=>r(null),e);return()=>clearTimeout(t)},[a]);let l=(0,s.useCallback)(()=>r(null),[]);return(0,s.useEffect)(()=>{r(null)},[e,t]),{recentModelChange:a,dismissModelChange:l}}(t,y),R=(0,t3.B)(t,n,a,f),L=nb({cliToolId:n,instanceId:a}),P=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{null!==P.current&&clearTimeout(P.current)},[]);let D=(0,s.useCallback)(()=>{if("opencode"===n)return void R([...nR]);let e={cliToolId:n,instanceId:a};L?L(nL,e):tN.y.sendMessage(t,nL,e).catch(()=>{}),null!==P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,f()},ek.LK)},[n,a,L,f,R,t]),{surfaceMode:F,handleSurfaceModeChange:O}=nE((0,nT.NP)(t)),z=(0,s.useCallback)(e=>{c||O(e)},[c,O]),[_,B]=(0,ny.Af)(),V=(0,s.useRef)(null),H=(0,s.useRef)(d.autoScroll);H.current=d.autoScroll,(0,s.useEffect)(()=>{let e=V.current;if(!c||l||null===e)return;let t=()=>{if(!H.current)return;let t=e.querySelector('[role="log"]');t&&(t.scrollTop=t.scrollHeight)};if(t(),"undefined"==typeof ResizeObserver)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[c,l]),(0,s.useEffect)(()=>{null==o||o(F)},[o,F]);let U=(0,t5.Bj)((0,t5.qi)(t,y),d.startingSince),K=d.isUnclassifiedActive&&!u.visible&&"chat"!==F&&!U.starting,W=t6(d.composerText),q=na(n,d.realtimeSnippet||d.output),$=ni(d,u),G="chat"===F&&(0,nl.BM)($,d.output,n);return(0,r.jsxs)("div",{className:"relative flex flex-col h-full min-h-0",children:[(0,r.jsx)(nC,{surfaceMode:F,showSessionRow:E,directInputOpen:c,onSurfaceToggle:z,showToolActivity:_,onToggleToolActivity:B}),E?(0,r.jsx)(nP,{modelLabel:j,usage:w,usageDetail:k,recentChange:A,note:N,onEditNote:S,onOpenPicker:D,onDismissChange:M}):null,C?(0,r.jsx)(nk,{showSessionRow:E,sessionNote:N,onCommit:T,onCancel:I}):null,(0,r.jsx)("div",{ref:V,className:"flex-1 min-h-0 overflow-hidden","data-testid":"mobile-terminal-region",children:"chat"===F?(0,r.jsx)("div",{className:"h-full min-h-0","data-testid":"mobile-chat-surface",children:(0,r.jsx)(nD,{worktreeId:t,cliToolId:n,instanceId:a,live:$,frame:d.output,onKeysSent:f,onSurfaceModeChange:O})}):U.noticeVisible&&null!==U.startingSince?(0,r.jsx)(t4.TE,{cliToolId:n,startingSince:U.startingSince,onShowTerminal:U.revealTerminal}):(0,r.jsx)(t1.D,{output:d.output,isActive:d.isRunning,isThinking:d.isThinking,autoScroll:d.autoScroll,onScrollChange:x,disableAutoFollow:l,compactTuiLayoutPadding:h,preservePaintedPanelRows:p,wrapMode:g,searchBarTopClassName:nM})}),W&&!c?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(t8,{worktreeId:t,cliToolId:n,instanceId:a,composerText:d.composerText,onActionSent:f})}):null,q?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(nr,{cliToolId:n,frame:d.realtimeSnippet||d.output})}):null,!d.isRunning||c||G?null:(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1","data-testid":"mobile-quick-keys-slot",children:(0,r.jsx)(ns.XU,{worktreeId:t,cliToolId:n,instanceId:a,hasAgentSession:null!==m.session,onKeysSent:f,compact:!0,collapsible:!0,layout:"mobile"})}),K&&!c?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1 pb-2",children:(0,r.jsx)(t2.U,{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:f})}):null]})});var nO=n(83051);let nz={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};function n_(){let[e,t]=(0,s.useState)(nz),n=(0,s.useCallback)((e,n,a)=>{t({isOpen:!0,position:e,targetPath:n,targetType:a})},[]),a=(0,s.useCallback)((e,t,a)=>{let r,s;if(e.preventDefault(),"touches"in e&&e.touches.length>0)r=e.touches[0].clientX,s=e.touches[0].clientY;else{if(!("clientX"in e))return;r=e.clientX,s=e.clientY}n({x:r,y:s},t,a)},[n]),r=(0,s.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),l=(0,s.useCallback)(()=>{t(nz)},[]);return(0,s.useEffect)(()=>{if(!e.isOpen)return;let t=()=>{r()},n=setTimeout(()=>{document.addEventListener("click",t)},0);return()=>{clearTimeout(n),document.removeEventListener("click",t)}},[e.isOpen,r]),(0,s.useEffect)(()=>{if(!e.isOpen)return;let t=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[e.isOpen,r]),{menuState:e,openMenu:a,openMenuAt:n,closeMenu:r,resetMenu:l}}var nB=n(47650),nV=n(7504),nH=n(22198),nU=n(21786),nK=n(26754),nW=n(71360),nq=n(9286);function n$(e,t,n){let a=n-t-8;return a<8?8:Math.min(Math.max(e,8),a)}let nG=(0,s.memo)(function(e){let{isOpen:t,position:n,targetPath:a,targetType:l,onClose:o,onNewFile:c,onNewDirectory:d,onRename:u,onDelete:m,onUpload:x,onMove:f,items:h,ariaLabel:p}=e,g=(0,i.c)("worktree"),b=(0,s.useRef)(null),{shouldRender:v,isExiting:y}=(0,nq.O)(t,ek.$B),j=h?h.map(e=>e.id).join(","):"builtin",w="".concat(n.x,":").concat(n.y,":").concat(l,":").concat(j),[k,N]=(0,s.useState)(null),C=(null==k?void 0:k.key)===w?k:null;(0,s.useLayoutEffect)(()=>{if(!t)return;let e=b.current;if(!e)return;let a=e.getBoundingClientRect();N({key:w,left:n$(n.x,a.width,window.innerWidth),top:n$(n.y,a.height,window.innerHeight)})},[t,w,n.x,n.y]);let S=(0,s.useCallback)(e=>{e&&a&&e(a),o()},[a,o]),I=[{id:"new-file",label:g("fileTree.newFile"),icon:(0,r.jsx)(nV.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(c),showFor:["directory"]},{id:"new-directory",label:g("fileTree.newDirectory"),icon:(0,r.jsx)(nH.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(d),showFor:["directory"]},{id:"upload",label:g("contextMenu.uploadFile"),icon:(0,r.jsx)(nU.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(x),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:g("contextMenu.rename"),icon:(0,r.jsx)(ta.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(u)},{id:"move",label:g("contextMenu.move"),icon:(0,r.jsx)(nK.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{f&&a&&l&&f(a,l),o()},showDividerAfter:!0},{id:"delete",label:g("contextMenu.delete"),icon:(0,r.jsx)(nW.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(m),variant:"danger"}],T=h?h.map(e=>{var t,n;return{id:e.id,label:e.label,icon:null!=(t=e.icon)?t:null,onClick:()=>{e.onSelect(),o()},variant:e.variant,showDividerAfter:e.showDividerAfter,disabled:null!=(n=e.disabled)&&n}}):I.filter(e=>!e.showFor||l&&e.showFor.includes(l));if((0,s.useEffect)(()=>{if(!t)return;let e=e=>{if("Escape"===e.key)return void o();if("ArrowDown"===e.key||"ArrowUp"===e.key){var t;let n;e.preventDefault();let a=null==(t=b.current)?void 0:t.querySelectorAll('[role="menuitem"]');if(!(null==a?void 0:a.length))return;let r=Array.from(a).findIndex(e=>e===document.activeElement);n="ArrowDown"===e.key?r<a.length-1?r+1:0:r>0?r-1:a.length-1,a[n].focus()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,o]),(0,s.useEffect)(()=>{if(t&&b.current){let e=b.current.querySelector('[role="menuitem"]');e&&e.focus()}},[t]),!v)return null;let E=(0,r.jsx)("div",{ref:b,"data-testid":"context-menu",role:"menu","aria-label":null!=p?p:g("contextMenu.label"),className:"fixed min-w-[160px] py-1 bg-surface rounded-lg shadow-lg border border-border ".concat(y?"animate-out fade-out-0 zoom-out-95 duration-100 fill-mode-forwards pointer-events-none":"animate-in fade-in-0 zoom-in-95 duration-100"),style:{zIndex:tr.M.CONTEXT_MENU,left:"".concat(C?C.left:0,"px"),top:"".concat(C?C.top:0,"px")},children:T.map((e,t)=>{var n;let l=null!=(n=e.disabled)?n:!a;return(0,r.jsxs)(s.Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem","data-testid":"context-menu-".concat(e.id),onClick:e.onClick,disabled:l,className:"w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors focus:outline-none focus:bg-muted ".concat("danger"===e.variant?"text-danger hover:bg-danger-subtle focus:bg-danger-subtle":"text-foreground hover:bg-muted"," ").concat(l?"opacity-50 cursor-not-allowed":""),children:[e.icon,(0,r.jsx)("span",{children:e.label})]}),e.showDividerAfter&&t<T.length-1&&(0,r.jsx)("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-border"})]},e.id)})});return"undefined"==typeof document?E:(0,nB.createPortal)(E,document.body)});var nJ=n(55813),nY=n(30061);let nQ="commandmate.worktree.fileMetadataDisplay",nX={showSize:!0,showCreated:!1,showModified:!1},nZ="commandmate:fileMetadataDisplayChange";function n0(e){return void 0===e?"":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB")}let n1=(0,s.memo)(function(e){let{expanded:t}=e;return(0,r.jsx)("svg",{"data-testid":"chevron-icon",className:"w-4 h-4 text-muted-foreground transition-transform ".concat(t?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),n2=(0,s.memo)(function(e){let{open:t}=e;return(0,r.jsx)("svg",{"data-testid":"folder-icon",className:"w-5 h-5 flex-shrink-0 text-warning",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t?(0,r.jsx)("path",{d:"M19 20H5c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h6c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2zM5 6v12h14V8h-7l-2-2H5z"}):(0,r.jsx)("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}),n4=(0,s.memo)(function(e){let{text:t,query:n}=e;if(!n||!n.trim())return(0,r.jsx)(r.Fragment,{children:t});let a=(0,f.Nt)(n),s=t.split(RegExp("(".concat(a,")"),"gi"));return(0,r.jsx)(r.Fragment,{children:s.map((e,t)=>e.toLowerCase()===n.toLowerCase()?(0,r.jsx)("mark",{className:"bg-warning-border text-foreground px-0.5 rounded",children:e},t):(0,r.jsx)("span",{children:e},t))})}),n5=(0,s.memo)(function(e){let{extension:t}=e,n=(0,s.useMemo)(()=>t&&({ts:"text-info",tsx:"text-info",js:"text-warning",jsx:"text-warning",json:"text-warning",md:"text-muted-foreground",css:"text-accent-500",scss:"text-accent-500",html:"text-warning",py:"text-success"})[t]||"text-muted-foreground",[t]);return(0,r.jsx)("svg",{"data-testid":"file-icon",className:"w-5 h-5 flex-shrink-0 ".concat(n),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),n3=(0,s.memo)(function e(t){let{item:n,path:a,depth:l,worktreeId:o,expanded:d,cache:u,onToggle:m,onFileSelect:x,onLoadChildren:f,onContextMenu:h,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y=nX}=t,j=(0,i.c)("worktree"),[w,k]=(0,s.useState)(!1),N=a?"".concat(a,"/").concat(n.name):n.name,C=d.has(N),S="directory"===n.type,I=u.get(N),T=(0,s.useMemo)(()=>v?(0,nJ.M)(v):void 0,[v]),E=(0,s.useMemo)(()=>{if(S)return;let e=[];if(void 0!==n.size&&e.push("".concat(j("fileTree.metadata.size"),": ").concat(n0(n.size))),n.birthtime){let t=(0,ex.bg)(new Date(n.birthtime),T);t&&e.push("".concat(j("fileTree.metadata.created"),": ").concat(t))}if(n.mtime){let t=(0,ex.bg)(new Date(n.mtime),T);t&&e.push("".concat(j("fileTree.metadata.modified"),": ").concat(t))}return e.length>0?e.join("\n"):void 0},[S,n.size,n.birthtime,n.mtime,T,j]),A=(0,s.useCallback)(async()=>{S?(C||I||(k(!0),await f(N),k(!1)),m(N)):null==x||x(N)},[S,C,I,N,f,m,x]),M=(0,s.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),A())},[A]),R=(0,s.useCallback)(e=>{e.preventDefault(),null==h||h(e,N,S?"directory":"file")},[N,S,h]),L=function(e){let{delay:t=500,moveThreshold:n=10,onLongPress:a}=e,r=(0,s.useRef)(null),l=(0,s.useRef)(null),i=(0,s.useRef)(null),o=(0,s.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),l.current=null,i.current=null},[]);(0,s.useEffect)(()=>()=>o(),[o]);let c=(0,s.useCallback)(e=>{if(1!==e.touches.length)return;let n=e.touches[0];l.current={x:n.clientX,y:n.clientY},i.current=e,r.current=setTimeout(()=>{i.current&&a(i.current),o()},t)},[t,a,o]),d=(0,s.useCallback)(e=>{if(!l.current||1!==e.touches.length)return;let t=e.touches[0],a=t.clientX-l.current.x,r=t.clientY-l.current.y;Math.sqrt(a*a+r*r)>n&&o()},[n,o]);return{onTouchStart:c,onTouchMove:d,onTouchEnd:(0,s.useCallback)(()=>{o()},[o]),onTouchCancel:(0,s.useCallback)(()=>{o()},[o])}}({onLongPress:(0,s.useCallback)(e=>{null==h||h(e,N,S?"directory":"file")},[N,S,h])}),P={...function(e){let t=Math.min(e,20);return{"--tree-indent":"".concat(.5+ +t,"rem")}}(l),touchAction:"manipulation",WebkitTouchCallout:"none"};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"tree-item-".concat(n.name),role:"treeitem","aria-selected":!1,"aria-expanded":S?C:void 0,tabIndex:0,className:"@container flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-muted rounded transition-colors pl-[min(var(--tree-indent),max(0.5rem,calc(100%_-_7rem)))]",style:P,onClick:A,onKeyDown:M,onContextMenu:R,onTouchStart:L.onTouchStart,onTouchMove:L.onTouchMove,onTouchEnd:L.onTouchEnd,onTouchCancel:L.onTouchCancel,children:[S?(0,r.jsx)("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:w?(0,r.jsx)(c.y,{size:"xs",variant:"accent"}):(0,r.jsx)(n1,{expanded:C})}):(0,r.jsx)("span",{className:"w-4 h-4 flex-shrink-0"}),S?(0,r.jsx)(n2,{open:C}):(0,r.jsx)(n5,{extension:n.extension}),(0,r.jsx)(nY.nR,{content:n.name,metadata:E,className:"flex-1 truncate text-sm text-foreground @min-[176px]:min-w-16",children:"name"===g&&p?(0,r.jsx)(n4,{text:n.name,query:p}):n.name}),y.showSize&&(0,r.jsx)("span",{"data-testid":"tree-item-size",className:"hidden @min-[176px]:block truncate text-xs text-muted-foreground",children:S?void 0!==n.itemCount&&j("fileTree.itemCount",{count:n.itemCount}):n0(n.size)}),!S&&y.showCreated&&n.birthtime&&(0,r.jsx)("span",{"data-testid":"tree-item-created",className:"hidden @min-[296px]:block truncate text-xs text-muted-foreground",children:(0,ex.fw)(n.birthtime,T)}),!S&&y.showModified&&n.mtime&&(0,r.jsx)("span",{"data-testid":"tree-item-modified",className:"hidden ".concat(y.showCreated?"@min-[416px]:block":"@min-[296px]:block"," truncate text-xs text-muted-foreground"),children:(0,ex.fw)(n.mtime,T)})]}),S&&C&&I&&(0,r.jsx)("div",{role:"group",children:I.filter(e=>{let t=N?"".concat(N,"/").concat(e.name):e.name;if(!(null==p?void 0:p.trim()))return!0;if("name"===g){let t=p.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===g&&b&&b.size>0){if(b.has(t))return!0;if("directory"===e.type){for(let e of b)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>(0,r.jsx)(e,{item:t,path:N,depth:l+1,worktreeId:o,expanded:d,cache:u,onToggle:m,onFileSelect:x,onLoadChildren:f,onContextMenu:h,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y},t.name))})]})});var n6=n(26989);let n8=[{key:"showSize",labelKey:"fileTree.metadata.showSize"},{key:"showCreated",labelKey:"fileTree.metadata.showCreated"},{key:"showModified",labelKey:"fileTree.metadata.showModified"}];function n9(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let n7=(0,s.memo)(function(e){let{settings:t,onToggle:n}=e,a=(0,i.c)("worktree"),[l,o]=(0,s.useState)(!1),c=(0,s.useRef)(null),u=(0,s.useRef)(null),m=(0,s.useRef)({x:0,y:0}),[x,f]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(!l)return;let e=e=>{c.current&&!c.current.contains(e.target)&&o(!1)},t=e=>{"Escape"===e.key&&o(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]),(0,s.useLayoutEffect)(()=>{let e=e=>{m.current=e,f(t=>t.x===e.x&&t.y===e.y?t:e)};if(!l)return void e({x:0,y:0});let t=u.current;if(!t)return;let n=t.getBoundingClientRect();e({x:n9(n.left-m.current.x,n.width,window.innerWidth),y:n9(n.top-m.current.y,n.height,window.innerHeight)})},[l]);let h=(0,s.useCallback)(e=>{n(e)},[n]);return(0,r.jsxs)("div",{className:"relative",ref:c,"data-testid":"file-metadata-toggle",children:[(0,r.jsx)("button",{type:"button","data-testid":"file-metadata-toggle-button",onClick:()=>o(e=>!e),"aria-haspopup":"menu","aria-expanded":l,"aria-label":a("fileTree.metadata.settingsLabel"),title:a("fileTree.metadata.settingsLabel"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:(0,r.jsx)(n6.A,{className:"w-4 h-4","aria-hidden":"true"})}),l&&(0,r.jsxs)("div",{ref:u,role:"menu","data-testid":"file-metadata-toggle-menu",className:"absolute right-0 top-full z-20 mt-1 min-w-[12rem] rounded border border-border bg-surface shadow-lg p-1",style:0!==x.x||0!==x.y?{transform:"translate(".concat(x.x,"px, ").concat(x.y,"px)")}:void 0,children:[(0,r.jsx)("div",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:a("fileTree.metadata.settingsTitle")}),n8.map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-xs text-foreground hover:bg-muted rounded cursor-pointer",children:[(0,r.jsx)(d.Sc,{"data-testid":"file-metadata-toggle-".concat(e.key),checked:t[e.key],onCheckedChange:()=>h(e.key),className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:a(e.labelKey)})]},e.key))]})]})});function ae(e){let{intervalMs:t,enabled:n,onPoll:a}=e,r=(0,s.useRef)(a);r.current=a;let l=(0,s.useRef)(n);l.current=n;let i=(0,s.useRef)(null);(0,s.useEffect)(()=>{function e(){null!==i.current&&(clearInterval(i.current),i.current=null)}function a(){e(),i.current=setInterval(()=>{r.current()},t)}function s(){"hidden"===document.visibilityState?e():"visible"===document.visibilityState&&l.current&&(r.current(),a())}return n?a():e(),document.addEventListener("visibilitychange",s),()=>{e(),document.removeEventListener("visibilitychange",s)}},[t,n])}function at(e){return"commandmate:file-tree-expanded:"+e}function an(e){try{let t=window.localStorage.getItem(at(e));if(!t)return new Set;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(e=>"string"==typeof e))return new Set(n)}catch(e){}return new Set}var aa=n(89559),ar=n(48314),as=n(6132);let al=(0,s.memo)(function(e){let{worktreeId:t,onFileSelect:n,onNewFile:a,onNewDirectory:l,onRename:o,onDelete:c,onUpload:u,onMove:m,className:x="",refreshTrigger:h=0,pollingEnabled:p=!1,searchQuery:g,searchMode:b,searchResults:v,onSearchResultSelect:y,onResetView:j}=e,w=(0,ty.Ym)(),k=(0,i.c)("worktree"),{settings:N,toggle:C}=function(){let[e,t]=(0,s.useState)(nX),n=(0,s.useRef)(e);n.current=e,(0,s.useEffect)(()=>{t(function(){try{var e;let t=window.localStorage.getItem(nQ);if(!t)return{...nX};return e=JSON.parse(t),"object"!=typeof e||null===e?{...nX}:{showSize:"boolean"==typeof e.showSize?e.showSize:nX.showSize,showCreated:"boolean"==typeof e.showCreated?e.showCreated:nX.showCreated,showModified:"boolean"==typeof e.showModified?e.showModified:nX.showModified}}catch(e){return{...nX}}}())},[]),(0,s.useEffect)(()=>{let e=e=>{if(e.detail){var a,r;a=e.detail.settings,r=n.current,(a.showSize!==r.showSize||a.showCreated!==r.showCreated||a.showModified!==r.showModified)&&t(e.detail.settings)}};return window.addEventListener(nZ,e),()=>window.removeEventListener(nZ,e)},[]);let a=(0,s.useCallback)(e=>{n.current=e,t(e);try{window.localStorage.setItem(nQ,JSON.stringify(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(nZ,{detail:{settings:e}}))}catch(e){}},[]);return{settings:e,toggle:(0,s.useCallback)(e=>{a({...n.current,[e]:!n.current[e]})},[a]),setSettings:a}}(),[S,I]=(0,s.useState)(!0),[T,E]=(0,s.useState)(null),[A,M]=(0,s.useState)([]),{expanded:R,setExpanded:L,resetExpanded:P}=function(e){let[t,n]=(0,s.useState)(()=>an(e)),a=(0,s.useRef)(e);(0,s.useEffect)(()=>{a.current!==e&&(a.current=e,n(an(e)))},[e]),(0,s.useEffect)(()=>{!function(e,t){try{let n=at(e);if(0===t.size)return void window.localStorage.removeItem(n);window.localStorage.setItem(n,JSON.stringify(Array.from(t)))}catch(e){}}(a.current,t)},[t]);let r=(0,s.useCallback)(()=>{n(new Set)},[]);return{expanded:t,setExpanded:n,resetExpanded:r}}(t),[D,F]=(0,s.useState)(()=>new Map),O=(0,s.useRef)(null),z=(0,s.useRef)(R);z.current=R;let _=(0,s.useRef)(k);_.current=k;let B=(0,s.useRef)(new Set),{menuState:V,openMenu:H,closeMenu:U}=n_(),K=(0,s.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{let n=e?"/api/worktrees/".concat(t,"/tree/").concat(e):"/api/worktrees/".concat(t,"/tree"),a=await fetch(n);if(!a.ok)throw Error(_.current("fileTree.loadDirectoryError",{status:a.status}));return await a.json()}catch(e){throw console.error("[FileTreeView] Error fetching directory:",e),e}},[t]),W=(0,s.useRef)(!0);(0,s.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]);let q=(0,s.useCallback)(async()=>{if(W.current){I(!0),E(null);try{let e=await K();if(!W.current||!e)return;let t=Array.from(z.current),n=new Map,a=[];for(let e=0;e<t.length;e+=5){if(!W.current)return;let r=t.slice(e,e+5);for(let[e,t]of(await Promise.allSettled(r.map(async e=>{let t=await K(e);return{dirPath:e,data:t}}))).entries())"fulfilled"===t.status&&t.value.data?n.set(t.value.dirPath,t.value.data.items):a.push(r[e])}if(!W.current)return;M(e.items),F(n),a.length>0&&L(e=>{let t=new Set(e);for(let e of a)e&&t.delete(e);return t})}catch(e){W.current&&E(e instanceof Error?e.message:_.current("fileTree.loadError"))}finally{W.current&&I(!1)}}},[K,L]);(0,s.useEffect)(()=>{q()},[q,h]);let $=(0,s.useRef)(null),G=(0,s.useRef)(!1);(0,s.useEffect)(()=>{$.current=null},[t]),ae({intervalMs:5e3,enabled:p,onPoll:(0,s.useCallback)(async()=>{if(W.current&&!G.current){G.current=!0;try{let e=["",...Array.from(z.current)],t=new Map;for(let n=0;n<e.length;n+=5){if(!W.current)return;let a=e.slice(n,n+5);for(let{dirPath:e,hash:n}of(await Promise.all(a.map(async e=>{try{var t;let n=await K(e);return{dirPath:e,hash:JSON.stringify(null!=(t=null==n?void 0:n.items)?t:null)}}catch(t){return{dirPath:e,hash:"unavailable"}}}))))t.set(e,n)}if(!W.current)return;let n=$.current;if($.current=t,null===n)return;let a=!1;for(let[e,r]of t){let t=n.get(e);if(void 0!==t&&t!==r){a=!0;break}}a&&q()}finally{G.current=!1}}},[K,q])});let J=(0,s.useCallback)(async e=>{if(!(D.has(e)||B.current.has(e))){B.current.add(e);try{let t=await K(e);t&&F(n=>{let a=new Map(n);return a.set(e,t.items),a})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{B.current.delete(e)}}},[D,K]),Y=(0,s.useCallback)(e=>{L(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[L]),Q=(0,s.useCallback)(()=>{var e;P(),F(new Map),null==(e=O.current)||e.scrollTo({top:0}),null==j||j()},[P,j]),X=(0,s.useMemo)(()=>"content"===b&&v&&0!==v.length?(0,f.q3)(v.map(e=>e.filePath)):new Set,[b,v]);(0,s.useEffect)(()=>{X.size>0&&L(e=>{let t=new Set(e);for(let e of X)(D.has(e)||(null==v?void 0:v.some(t=>t.filePath.startsWith(e+"/"))))&&t.add(e);return t})},[X,D,v,L]);let Z=(0,s.useMemo)(()=>{if(!(null==g?void 0:g.trim()))return A;if("name"===b){let e=g.toLowerCase(),t=(n,a)=>n.filter(n=>{let r=a?"".concat(a,"/").concat(n.name):n.name,s=n.name.toLowerCase().includes(e);if("directory"===n.type){let e=D.get(r);if(e&&t(e,r).length>0)return!0}return s});return t(A,"")}return"content"===b&&X.size>0?A.filter(e=>{if(X.has(e.name))return!0;if("directory"===e.type){for(let t of X)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):A},[A,g,b,X,D]);if(S&&0===A.length)return(0,r.jsx)("div",{"data-testid":"file-tree-loading",className:"p-2 ".concat(x),role:"status","aria-label":k("fileTree.loading"),children:[0,8,16,8,0,8].map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1.5 pr-2",style:{paddingLeft:"".concat(8+e,"px")},children:[(0,r.jsx)(d.EA,{className:"h-4 w-4 shrink-0 rounded"}),(0,r.jsx)(d.EA,{className:"h-4 ".concat(t%3==0?"w-32":t%3==1?"w-24":"w-40"," max-w-full")})]},t))});if(T&&0===A.length)return(0,r.jsx)("div",{"data-testid":"file-tree-error",className:"p-4 bg-danger-subtle border border-danger-border rounded-lg ".concat(x),children:(0,r.jsx)("p",{className:"text-sm text-danger",children:T})});let ee=S&&A.length>0,et=!!T&&A.length>0;return 0===A.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:"p-4 text-center text-muted-foreground ".concat(x),children:[(0,r.jsx)("p",{className:"text-sm",children:k("fileTree.empty")}),(a||l)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[a&&(0,r.jsxs)(d.$n,{variant:"ghost","data-testid":"empty-new-file-button",onClick:()=>a(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(nV.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),l&&(0,r.jsxs)(d.$n,{variant:"ghost","data-testid":"empty-new-directory-button",onClick:()=>l(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(nH.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]})]})]}):(null==g?void 0:g.trim())&&0===Z.length?(0,r.jsx)("div",{"data-testid":"file-tree-no-results",className:"p-4 text-center text-muted-foreground ".concat(x),children:(0,r.jsx)("p",{className:"text-sm",children:k("content"===b?"fileTree.noResultsContaining":"fileTree.noResultsMatching",{query:g})})}):(0,r.jsxs)("div",{ref:O,"data-testid":"file-tree-view",role:"tree","aria-label":k("fileTree.label"),className:"@container overflow-auto bg-surface ".concat(x),children:[(0,r.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex flex-wrap items-center gap-1 p-1 border-b border-border",children:[a&&(0,r.jsx)(eu.m_,{content:k("fileTree.newFile"),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>a(""),"aria-label":k("fileTree.newFile"),className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(nV.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden @min-[360px]:inline",children:k("fileTree.newFile")})]})}),l&&(0,r.jsx)(eu.m_,{content:k("fileTree.newDirectory"),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>l(""),"aria-label":k("fileTree.newDirectory"),className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(nH.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden @min-[360px]:inline",children:k("fileTree.newDirectory")})]})}),(0,r.jsxs)("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-1",children:[(0,r.jsx)(n7,{settings:N,onToggle:C}),ee&&(0,r.jsxs)("div",{"data-testid":"file-tree-refetch-indicator",role:"status","aria-live":"polite",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"w-3 h-3 border-2 border-input border-t-accent-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"sr-only",children:k("fileTree.refreshing")})]}),(0,r.jsx)("button",{"data-testid":"file-tree-refresh-button",type:"button",onClick:()=>{q()},disabled:ee,"aria-label":k("fileTree.refreshLabel"),title:k("actions.refresh"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,r.jsx)(aa.A,{className:"w-4 h-4 ".concat(ee?"animate-spin":""),"aria-hidden":"true"})}),(0,r.jsx)("button",{"data-testid":"file-tree-reset-button",type:"button",onClick:Q,"aria-label":k("fileTree.resetViewLabel"),title:k("actions.resetView"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:(0,r.jsx)(ar.A,{className:"w-4 h-4","aria-hidden":"true"})})]})]}),et&&(0,r.jsxs)("div",{"data-testid":"file-tree-refetch-error",role:"alert",className:"flex items-center gap-2 px-2 py-1 text-xs bg-danger-subtle border-b border-danger-border text-danger-foreground",children:[(0,r.jsx)(as.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:T}),(0,r.jsx)(d.$n,{variant:"ghost","data-testid":"file-tree-refetch-retry-button",onClick:()=>{q()},className:"px-2 py-0.5 text-xs rounded border border-danger-border hover:bg-danger-subtle transition-colors",children:k("actions.retry")})]}),Z.map(e=>(0,r.jsx)(n3,{item:e,path:"",depth:0,worktreeId:t,expanded:R,cache:D,onToggle:Y,onFileSelect:y||n,onLoadChildren:J,onContextMenu:H,searchQuery:g,searchMode:b,matchedPaths:X,dateFnsLocaleStr:w,metadataDisplay:N},e.name)),(0,r.jsx)(nG,{isOpen:V.isOpen,position:V.position,targetPath:V.targetPath,targetType:V.targetType,onClose:U,onNewFile:a,onNewDirectory:l,onRename:o,onDelete:c,onUpload:u,onMove:m})]})});var ai=n(38218);let ao=(0,s.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),ac=(0,s.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),ad=(0,s.memo)(function(){let e=(0,i.c)("worktree");return(0,r.jsx)(c.y,{size:"sm",variant:"accent","data-testid":"search-loading",role:"status","aria-hidden":!1,"aria-label":e("search.searching")})}),au=(0,s.memo)(function(e){let{query:t,mode:n,isSearching:a,error:l,onQueryChange:o,onModeChange:c,onClear:d,placeholder:u,className:m=""}=e,x=(0,s.useRef)(null),f=(0,i.c)("worktree"),h=(0,s.useCallback)(e=>{o(e.target.value)},[o]),p=(0,s.useCallback)(()=>{var e;d(),null==(e=x.current)||e.focus()},[d]),g=(0,s.useCallback)(e=>{if("Escape"===e.key)if(t)p();else{var n;null==(n=x.current)||n.blur()}},[t,p]);return(0,s.useEffect)(()=>{if(!(window.innerWidth<ai.D)){let e=setTimeout(()=>{var e;null==(e=x.current)||e.focus()},100);return()=>clearTimeout(e)}},[]),(0,r.jsxs)("div",{"data-testid":"search-bar",className:"flex flex-col gap-2 p-2 bg-surface dark:bg-surface-2 border-b border-border ".concat(m),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(ao,{})}),(0,r.jsx)("input",{ref:x,type:"text","data-testid":"search-input",value:t,onChange:h,onKeyDown:g,placeholder:null!=u?u:f("search.placeholder"),className:"flex-1 min-w-0 px-2 py-1 text-sm bg-muted text-foreground border border-input rounded focus:outline-none focus:ring-1 focus:ring-ring focus:border-accent-500","aria-label":f("search.label"),"aria-busy":a}),(a||!!t)&&(0,r.jsx)("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:a?(0,r.jsx)(ad,{}):t?(0,r.jsx)("button",{type:"button","data-testid":"search-clear",onClick:p,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors","aria-label":f("search.clear"),children:(0,r.jsx)(ac,{})}):null})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mr-1 whitespace-nowrap",children:f("search.mode")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-name",onClick:()=>c("name"),className:"px-2 py-0.5 text-xs rounded transition-colors whitespace-nowrap flex-shrink-0 ".concat("name"===n?"bg-accent-100 dark:bg-accent-900 text-accent-700 dark:text-accent-300 font-medium":"bg-muted text-muted-foreground hover:bg-muted/80"),"aria-pressed":"name"===n,children:f("search.modeName")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-content",onClick:()=>c("content"),className:"px-2 py-0.5 text-xs rounded transition-colors whitespace-nowrap flex-shrink-0 ".concat("content"===n?"bg-accent-100 dark:bg-accent-900 text-accent-700 dark:text-accent-300 font-medium":"bg-muted text-muted-foreground hover:bg-muted/80"),"aria-pressed":"content"===n,children:f("search.modeContent")})]}),l&&(0,r.jsx)("div",{"data-testid":"search-error",className:"text-xs text-danger bg-danger-subtle px-2 py-1 rounded",role:"alert",children:l})]})});function am(e){return 0===e.length?"0":e.map(e=>"".concat(e.id,":").concat(e.title.length,":").concat(e.content.length)).join("|")}var ax=n(12108),af=n(54916),ah=n(60850);let ap=(0,s.memo)(function(e){var t,n;let{memo:a,onUpdate:l,onDelete:o,isSaving:c,error:d,className:u="",onInsertToMessage:m,onMoveUp:x,onMoveDown:f,canMoveUp:h=!0,canMoveDown:p=!0}=e,g=(0,i.c)("schedule"),b=(0,i.c)("worktree"),v=!!(x||f),[y,j]=(0,s.useState)(a.title),[w,k]=(0,s.useState)(a.content),[N,C]=(0,s.useState)(!1),S=(0,s.useRef)(void 0);(0,s.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let{isSaving:I,error:T,saveNow:E}=(0,ah.U)({value:y,saveFn:async e=>{await l(a.id,{title:e})}}),{isSaving:A,error:M,saveNow:R}=(0,ah.U)({value:w,saveFn:async e=>{await l(a.id,{content:e})}}),L=null!=(n=null!=(t=null!=d?d:null==T?void 0:T.message)?t:null==M?void 0:M.message)?n:null,P=(0,s.useCallback)(e=>{j(e.target.value)},[]),D=(0,s.useCallback)(e=>{k(e.target.value)},[]),F=(0,s.useCallback)(()=>{E()},[E]),O=(0,s.useCallback)(()=>{R()},[R]),z=(0,s.useCallback)(()=>{o(a.id)},[a.id,o]),_=(0,s.useCallback)(()=>{w.trim()&&(null==m||m(w))},[w,m]),B=(0,s.useCallback)(async()=>{if(w.trim())try{await (0,te.l)(w),C(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>C(!1),2e3)}catch(e){}},[w]);return(0,r.jsxs)("div",{"data-testid":"memo-card","data-memo-id":a.id,tabIndex:-1,className:"bg-surface dark:bg-surface-2 border border-border rounded-lg p-4 space-y-3 focus:outline-none ".concat(u),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",value:y,onChange:P,onBlur:F,placeholder:g("memoTitlePlaceholder"),className:"flex-1 min-w-0 text-sm font-medium text-foreground bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(null!=c?c:I||A)&&(0,r.jsx)("span",{"data-testid":"saving-indicator",className:"text-xs text-muted-foreground",children:b("actions.saving")}),v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"memo-move-up-".concat(a.id),onClick:x,disabled:!h,"aria-label":g("memoMoveUp"),title:g("memoMoveUp"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(ax.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-testid":"memo-move-down-".concat(a.id),onClick:f,disabled:!p,"aria-label":g("memoMoveDown"),title:g("memoMoveDown"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(es.A,{className:"w-4 h-4","aria-hidden":"true"})})]}),m&&(0,r.jsx)("button",{type:"button","data-testid":"insert-memo-content",onClick:_,"aria-label":g("memoInsertToMessage"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 transition-colors rounded",title:g("memoInsertToMessage"),children:(0,r.jsx)(af.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:B,"aria-label":g("memoCopyContent"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded",children:N?(0,r.jsx)(eZ.A,{className:"w-4 h-4 text-success"}):(0,r.jsx)(e0.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{type:"button",onClick:z,"aria-label":g("memoDelete"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-danger transition-colors rounded",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.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,r.jsx)("textarea",{value:w,onChange:D,onBlur:O,placeholder:g("memoContentPlaceholder"),rows:4,className:"w-full text-sm text-foreground bg-muted border border-border rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),L&&(0,r.jsx)("div",{className:"text-xs text-danger",children:L})]})}),ag=(0,s.memo)(function(e){let{currentCount:t,maxCount:n,onAdd:a,isLoading:s=!1,className:l=""}=e,o=(0,i.c)("schedule"),d=Math.max(0,n-t),u=t>=n||s;return(0,r.jsxs)("div",{"data-testid":"memo-add-button",className:"flex flex-col items-center gap-2 ".concat(l),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{u||a()},disabled:u,"aria-label":o("memoAdd"),"aria-disabled":u,className:"\n flex items-center gap-2 px-4 py-2 rounded-lg border-2 border-dashed\n transition-colors focus:outline-none focus:ring-2 focus:ring-ring\n ".concat(u?"border-border text-muted-foreground cursor-not-allowed opacity-50":"border-border text-muted-foreground hover:border-accent-400 dark:hover:border-accent-500 hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/30","\n "),children:[s?(0,r.jsx)(c.y,{"data-testid":"loading-indicator",size:"md",variant:"accent"}):(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:o("memoAdd")})]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:o("memoRemaining",{count:d})})]})});function ab(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:l,onNext:o,onPrev:c,onClose:u,onCompositionStart:m,onCompositionEnd:x}=e,f=(0,i.c)("schedule"),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e;null==(e=h.current)||e.focus()},[]);let p=(0,s.useCallback)(e=>{if("Escape"===e.key)return void u();"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),o())},[u,o]),g=(0,s.useCallback)(e=>{n(e.target.value)},[n]),b=0===a?"0/0":"".concat(l+1,"/").concat(a);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border border-input rounded",role:"search","aria-label":f("memoSearchLabel"),children:[(0,r.jsx)("input",{ref:h,type:"text",value:t,onChange:g,onKeyDown:p,onCompositionStart:m,onCompositionEnd:x,placeholder:f("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":f("memoSearchInputLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:b}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:c,disabled:0===a,"aria-label":f("memoSearchPrev"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:o,disabled:0===a,"aria-label":f("memoSearchNext"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:u,"aria-label":f("memoSearchClose"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}let av=(0,s.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a}=e,l=(0,i.c)("schedule"),o=(0,i.c)("common"),d=(0,eG.SC)(),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(!0),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(!1),k=(0,s.useRef)(null),{query:N,matches:C,currentMatch:S,totalCount:I,setQuery:T,reset:E,navigateNext:A,navigatePrev:M,onCompositionStart:R,onCompositionEnd:L}=function(e){let{memos:t}=e,[n,a]=(0,s.useState)(""),[r,l]=(0,s.useState)([]),[i,o]=(0,s.useState)(-1),c=(0,s.useRef)(null),d=(0,s.useRef)(""),u=(0,s.useRef)(!1),m=(0,s.useRef)(am(t)),x=(0,s.useRef)(t);x.current=t;let f=r.length,h=(0,s.useCallback)(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),p=(0,s.useCallback)(e=>{let t=function(e,t){if(t.length<ti.E2||0===e.length)return[];let n=t.toLowerCase();return e.filter(e=>-1!==e.title.toLowerCase().indexOf(n)||-1!==e.content.toLowerCase().indexOf(n))}(x.current,e);l(t),o(t.length>0?0:-1)},[]),g=(0,s.useCallback)(e=>{h(),d.current=e,u.current||(c.current=setTimeout(()=>{p(e)},ti.e1))},[h,p]),b=(0,s.useCallback)(e=>{a(e),g(e)},[g]),v=(0,s.useCallback)(()=>{a(""),d.current="",l([]),o(-1),h()},[h]),y=(0,s.useCallback)(()=>{o(e=>0===f?-1:(e+1)%f)},[f]),j=(0,s.useCallback)(()=>{o(e=>0===f?-1:(e-1+f)%f)},[f]),w=(0,s.useCallback)(()=>{u.current=!0,h()},[h]),k=(0,s.useCallback)(()=>{u.current=!1;let e=d.current;e.length>=ti.E2&&(h(),c.current=setTimeout(()=>{p(e)},ti.e1))},[h,p]);return(0,s.useEffect)(()=>{let e=am(t);if(e===m.current)return;m.current=e;let n=d.current;n.length>=ti.E2&&p(n)},[t,p]),(0,s.useEffect)(()=>()=>{h(),d.current=""},[h]),{query:n,matches:r,currentMatch:i,totalCount:f,setQuery:b,reset:v,navigateNext:y,navigatePrev:j,onCompositionStart:w,onCompositionEnd:k}}({memos:u}),P=j&&N.length>0,D=P?C:u,F=(0,s.useCallback)(async()=>{f(!0),b(null);try{let e=await tN.$T.getAll(t);m(e.sort((e,t)=>e.position-t.position))}catch(e){b((0,tN.hS)(e))}finally{f(!1)}},[t]);(0,s.useEffect)(()=>{F()},[F]);let O=(0,s.useCallback)(async()=>{p(!0),y(null);try{let e=await tN.$T.create(t,{title:l("memoDefaultTitle"),content:""});m(t=>[...t,e])}catch(e){y((0,tN.hS)(e))}finally{p(!1)}},[t,l]),z=(0,s.useCallback)(async(e,n)=>{await tN.$T.update(t,e,n),m(t=>t.map(t=>t.id===e?{...t,...n}:t))},[t]),_=(0,s.useCallback)(async e=>{var n;let a=u.find(t=>t.id===e);if(await d({description:o("confirmDelete",{name:null!=(n=null==a?void 0:a.title)?n:""}),variant:"danger"}))try{await tN.$T.delete(t,e),m(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Failed to delete memo:",e)}},[t,u,d,o]),B=(0,s.useCallback)(async(e,n)=>{let a=e+n;if(a<0||a>=u.length)return;let r=[...u];[r[e],r[a]]=[r[a],r[e]],m(r);try{await tN.$T.reorder(t,r.map(e=>e.id))}catch(e){b((0,tN.hS)(e)),await F()}},[u,t,F]),V=(0,s.useCallback)(()=>{F()},[F]),H=(0,s.useCallback)(()=>{w(e=>(e&&E(),!e))},[E]),U=(0,s.useCallback)(()=>{w(!1),E()},[E]);return((0,s.useEffect)(()=>{var e;if(!P||S<0)return;let t=C[S];if(!t)return;let n=null==(e=k.current)?void 0:e.querySelector('[data-memo-id="'.concat(t.id,'"]'));n&&(n.scrollIntoView({block:"nearest"}),n.focus({preventScroll:!0}))},[P,S,C]),x)?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(c.y,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:l("memoLoading")})]})}):g?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,r.jsx)("svg",{className:"w-12 h-12 text-danger",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("span",{className:"text-sm text-danger-foreground",children:g}),(0,r.jsx)("button",{type:"button",onClick:V,"aria-label":o("retry"),className:"px-4 py-2 text-sm font-medium text-white bg-accent-500 rounded-lg hover:bg-accent-600 transition-colors",children:o("retry")})]})}):(0,r.jsxs)("div",{ref:k,"data-testid":"memo-pane",className:"flex flex-col gap-4 p-4 overflow-y-auto ".concat(n),children:[(0,r.jsx)("div",{"data-testid":"memo-pane-header",className:"flex items-center gap-2",children:j?(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(ab,{query:N,onQueryChange:T,matchCount:I,currentIndex:S,onNext:A,onPrev:M,onClose:U,onCompositionStart:R,onCompositionEnd:L})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("button",{type:"button","data-testid":"memo-search-toggle",onClick:H,"aria-label":l("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,r.jsx)(ee.A,{className:"w-4 h-4","aria-hidden":"true"})})]})}),0===u.length&&!P&&!v&&(0,r.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,r.jsx)("p",{children:l("memoEmpty")}),(0,r.jsx)("p",{className:"text-sm",children:l("memoEmptyHint")})]}),P&&0===D.length&&(0,r.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,r.jsx)("p",{children:l("memoNoMatch")})}),D.map((e,t)=>(0,r.jsx)(ap,{memo:e,onUpdate:z,onDelete:_,onInsertToMessage:a,onMoveUp:P?void 0:()=>B(t,-1),onMoveDown:P?void 0:()=>B(t,1),canMoveUp:!P&&t>0,canMoveDown:!P&&t<u.length-1},e.id)),v&&(0,r.jsx)("div",{className:"text-center py-2 text-sm text-danger",children:v}),!P&&(0,r.jsx)(ag,{currentCount:u.length,maxCount:20,onAdd:O,isLoading:h,className:"mt-2"})]})});async function ay(e,t){throw Error((await e.json().catch(()=>({}))).error||"".concat(t," (").concat(e.status,")"))}let aj=["todo","doing","done"],aw={async list(e){var t;let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"));return n.ok?null!=(t=(await n.json()).todos)?t:[]:ay(n,"Failed to load todos")},async create(e,t,n){let a=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(void 0!==n?{content:t,detail:n}:{content:t})});return a.ok?(await a.json()).todo:ay(a,"Failed to create todo")},async update(e,t,n){let a=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return a.ok?(await a.json()).todo:ay(a,"Failed to update todo")},async remove(e,t){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});n.ok||await ay(n,"Failed to delete todo")},async reorder(e,t){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({todoIds:t})});n.ok||await ay(n,"Failed to reorder todos")}};var ak=n(53482);let aN={todo:"border-input text-muted-foreground",doing:"border-warning-border bg-warning-subtle text-warning-foreground",done:"border-success-border bg-success-subtle text-success-foreground"},aC=s.memo(function(e){let{worktreeId:t,className:n=""}=e,a=(0,i.c)("worktree"),l=(0,i.c)("common"),o=(0,eG.SC)(),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(""),[x,f]=(0,s.useState)(!0),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(""),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)(!1),I=(0,s.useCallback)(e=>{switch(e){case"doing":return a("todo.statusDoing");case"done":return a("todo.statusDone");default:return a("todo.statusTodo")}},[a]),T=(0,s.useCallback)(async()=>{f(!0),b(null);try{let e=await aw.list(t);d(e)}catch(e){b(e instanceof Error?e.message:a("todo.loadError")),d([])}finally{f(!1)}},[t,a]);(0,s.useEffect)(()=>{T()},[t]);let E=(0,s.useCallback)(async()=>{let e=u.trim();if(e&&!h){p(!0),b(null);try{let n=await aw.create(t,e);d(e=>[...e,n]),m("")}catch(e){b(e instanceof Error?e.message:a("todo.addError"))}finally{p(!1)}}},[u,h,t,a]),A=(0,s.useCallback)(async e=>{let n=function(e){let t=aj.indexOf(e);return aj[(t+1)%aj.length]}(e.status);d(t=>t.map(t=>t.id===e.id?{...t,status:n,done:"done"===n}:t)),b(null);try{await aw.update(t,e.id,{status:n})}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),T()}},[t,T,a]),M=(0,s.useCallback)(async e=>{if(await o({description:l("confirmDelete",{name:e.content}),variant:"danger"})){b(null);try{await aw.remove(t,e.id),d(t=>t.filter(t=>t.id!==e.id))}catch(e){b(e instanceof Error?e.message:a("todo.deleteError"))}}},[t,a,o,l]),R=(0,s.useCallback)(e=>{y(e),w(e.content),N(e.detail),b(null)},[]),L=(0,s.useCallback)(()=>{y(null),S(!1)},[]),P=(0,s.useCallback)(async()=>{if(!v)return;let e=j.trim();if(e&&!C){S(!0),b(null);try{let n=await aw.update(t,v.id,{content:e,detail:k});d(e=>e.map(e=>e.id===v.id?n:e)),L()}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),S(!1)}}},[v,j,k,C,t,L,a]),D=(0,s.useCallback)(async(e,n)=>{let r=e+n;if(r<0||r>=c.length)return;let s=[...c];[s[e],s[r]]=[s[r],s[e]],d(s),b(null);try{await aw.reorder(t,s.map(e=>e.id))}catch(e){b(e instanceof Error?e.message:a("todo.reorderError")),T()}},[c,t,T,a]),F=(0,s.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),E())},[E]),O=(0,s.useMemo)(()=>({todo:c.filter(e=>"todo"===e.status).length,doing:c.filter(e=>"doing"===e.status).length,done:c.filter(e=>"done"===e.status).length}),[c]);return(0,r.jsxs)("div",{"data-testid":"todo-pane",className:"flex flex-col h-full overflow-y-auto p-4 ".concat(n).trim(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),onKeyDown:F,maxLength:2e3,placeholder:a("todo.addPlaceholder"),"data-testid":"todo-input",className:"flex-1 min-w-0 rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("button",{type:"button",onClick:E,disabled:h||0===u.trim().length,"data-testid":"todo-add-button",className:"shrink-0 rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:a("todo.add")})]}),(0,r.jsxs)("div",{className:"mb-2 flex justify-end gap-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{"data-testid":"todo-count-todo",children:[I("todo")," ",O.todo]}),(0,r.jsxs)("span",{"data-testid":"todo-count-doing",children:[I("doing")," ",O.doing]}),(0,r.jsxs)("span",{"data-testid":"todo-count-done",children:[I("done")," ",O.done]})]}),g&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:g}),x?(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-loading",children:a("todo.loading")}):0===c.length?(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-empty",children:a("todo.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"todo-list",children:c.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-1 py-1 hover:bg-muted group","data-testid":"todo-item",children:[(0,r.jsx)("button",{type:"button",onClick:()=>A(e),"data-testid":"todo-status","data-status":e.status,"aria-label":a("todo.cycleStatus",{status:I(e.status)}),title:a("todo.cycleStatus",{status:I(e.status)}),className:"shrink-0 inline-flex min-h-[44px] items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium sm:min-h-0 ".concat(aN[e.status]),children:I(e.status)}),(0,r.jsxs)("button",{type:"button",onClick:()=>R(e),"data-testid":"todo-content","aria-label":a("todo.edit"),title:a("todo.edit"),className:"group/content flex min-h-[44px] min-w-0 flex-1 items-center gap-1.5 text-left sm:min-h-0",children:[(0,r.jsx)("span",{className:"min-w-0 break-words text-sm ".concat("done"===e.status?"line-through text-muted-foreground":"text-foreground group-hover/content:text-accent-700 dark:group-hover/content:text-accent-300"),children:e.content}),""!==e.detail.trim()&&(0,r.jsxs)("svg",{"data-testid":"todo-detail-indicator","aria-label":a("todo.hasDetail"),className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,r.jsx)("title",{children:a("todo.hasDetail")}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h10"})]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>D(t,-1),disabled:0===t,"aria-label":a("todo.moveUp"),"data-testid":"todo-move-up",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{type:"button",onClick:()=>D(t,1),disabled:t===c.length-1,"aria-label":a("todo.moveDown"),"data-testid":"todo-move-down",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{type:"button",onClick:()=>M(e),"aria-label":a("todo.delete"),"data-testid":"todo-delete",className:"inline-flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center text-muted-foreground opacity-100 transition-opacity hover:text-danger-foreground sm:min-h-0 sm:min-w-0 sm:opacity-0 sm:group-hover:opacity-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},e.id))}),(0,r.jsx)(tF.a,{isOpen:null!==v,onClose:L,title:a("todo.editTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:a("todo.contentLabel")}),(0,r.jsx)("input",{type:"text",value:j,onChange:e=>w(e.target.value),maxLength:2e3,placeholder:a("todo.contentPlaceholder"),"data-testid":"todo-edit-content",className:"w-full rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:a("todo.detailLabel")}),""!==k.trim()&&(0,r.jsx)(ak.i,{text:k,label:a("todo.copyDetail"),className:"!border-input !bg-surface dark:!bg-surface-2 !text-muted-foreground hover:!bg-muted"})]}),(0,r.jsx)("textarea",{value:k,onChange:e=>N(e.target.value),maxLength:4e3,rows:6,placeholder:a("todo.detailPlaceholder"),"data-testid":"todo-edit-detail",className:"w-full resize-y rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:L,"data-testid":"todo-edit-cancel",className:"rounded-md border border-input px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted",children:a("todo.cancel")}),(0,r.jsx)("button",{type:"button",onClick:P,disabled:C||0===j.trim().length,"data-testid":"todo-edit-save",className:"rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:a("todo.save")})]})]})})]})});var aS=n(95740),aI=n(66630);function aT(e){let{isOpen:t,onClose:n,title:a,children:l,footer:o,showCloseButton:c=!0}=e,d=(0,i.c)("common"),[u,m]=(0,s.useState)(null);return((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n]),(0,s.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]),(0,s.useEffect)(()=>{if(!t)return;let e=window.visualViewport;if(!e)return;let n=()=>m(e.height);return n(),e.addEventListener("resize",n),()=>e.removeEventListener("resize",n)},[t]),t)?(0,nB.createPortal)((0,r.jsxs)("div",{"data-testid":"full-screen-modal",role:"dialog","aria-modal":"true",className:"fixed inset-0 flex flex-col bg-surface animate-slide-up",style:{zIndex:tr.M.MODAL,height:u?"".concat(u,"px"):"100dvh"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-foreground truncate pr-2",children:a}),c&&(0,r.jsx)("button",{type:"button",onClick:n,"aria-label":d("close"),"data-testid":"full-screen-modal-close",className:"flex-shrink-0 -mr-1 p-1 text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(ew.A,{className:"w-6 h-6"})})]}),(0,r.jsx)("div",{"data-testid":"full-screen-modal-body",className:"flex-1 min-h-0 overflow-y-auto overscroll-contain px-4 py-4",onFocusCapture:e=>{let t=e.target;t&&"function"==typeof t.scrollIntoView&&window.requestAnimationFrame(()=>{t.scrollIntoView({block:"center",behavior:"smooth"})})},children:l}),o&&(0,r.jsx)("div",{"data-testid":"full-screen-modal-footer",className:"flex-shrink-0 border-t border-border bg-surface px-4 py-3",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:o})]}),document.body):null}let aE=["default","acceptEdits","plan","dontAsk","bypassPermissions"],aA=["read-only","workspace-write","danger-full-access"],aM=["allow-all-tools","yolo"],aR=["--dangerously-skip-permissions"],aL=["default","standard","plan","auto-accept","dont-ask"],aP="yolo",aD=[aP,...aL],aF=[],aO=[],az=[],a_="default",aB=[a_,"auto"],aV=[],aH={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",opencode:"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions","command-code":aP,"opencode-v2":a_},aU=[];function aK(e){return!aU.includes(e)}function aW(e){switch(e){case"claude":return aE;case"codex":return aA;case"copilot":return aM;case"antigravity":return aR;case"command-code":return aD;case"gemini":return aF;case"vibe-local":return aO;case"opencode":return az;case"opencode-v2":return aB;default:return aV}}let aq=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function a$(e){return e.replace(RegExp(aq.source,"g"),"")}let aG=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/;function aJ(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}var aY=n(3199);let aQ=["edit_file","write_file","shell_command","monitor_command","kill_shell"];function aX(e){let t=new Map,n=e.split("\n"),a=null,r=!1,s=!1;for(let e of n){let n=e.trim(),l=n.match(/^##\s+(.+)$/);if(l){a=l[1].trim(),r=!1,s=!1,t.has(a)||t.set(a,[]);continue}if(!n||!n.startsWith("|")||!a)continue;if(!r){r=!0;continue}if(!s){if(n.match(/^\|[\s-:|]+\|$/)){s=!0;continue}s=!0}let i=n.split("|").slice(1,-1).map(e=>e.trim());i.length>0&&t.get(a).push(i)}return t}function aZ(e,t){return"command-code"===e&&aL.includes(t.trim())}var a0=n(26020);let a1={en:{bannerTitle:"CMATE.md has schedules to check",body:"With a --permission-mode value as Permission (default / standard / plan / auto-accept / dont-ask), command-code print mode (`commandcode -p`) rejects the write tools the agent calls directly (edit_file / write_file / shell_command / monitor_command / kill_shell). This is a warning and does not stop the schedule from being saved or run. Set Permission to `yolo` if the task needs to write."},ja:{bannerTitle:"CMATE.md に確認が必要なスケジュールがあります",body:"Permission が --permission-mode の値(default / standard / plan / auto-accept / dont-ask)のとき、command-code の print モード(`commandcode -p`)は、エージェントが直接呼ぶ書き込み系ツール(edit_file / write_file / shell_command / monitor_command / kill_shell)を拒否します。これは警告で、スケジュールの登録も実行も止めません。書き込みが必要な作業なら Permission を `yolo` にしてください。"}};function a2(e){return a1[(0,a0.d9)(e)?e:a0.Xn]}let a4=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],a5={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:null!=(a=aH.claude)?a:"",model:"",agent:"",variant:"",continueSession:!1,title:""},a3="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring",a6="block text-xs font-semibold text-foreground mb-1",a8="mt-1 text-xs text-danger-foreground";function a9(e){let{onClick:t,label:n,title:a,testId:s}=e;return(0,r.jsxs)("button",{type:"button","data-testid":s,onClick:t,title:a,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle transition-colors",children:[(0,r.jsx)(aS.A,{size:14,"aria-hidden":"true"}),n]})}function a7(e){let{id:t,title:n,summary:a,icon:s,isOpen:l,onToggle:i,children:o}=e,c="schedule-section-".concat(t,"-content");return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("button",{type:"button","data-testid":"schedule-section-".concat(t),"aria-expanded":l,"aria-controls":c,onClick:()=>i(t),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left bg-surface-2 hover:bg-muted transition-colors",children:[(0,r.jsx)("span",{className:"flex-shrink-0 text-accent-600 dark:text-accent-400",children:s}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-sm font-semibold text-foreground",children:n}),a&&(0,r.jsx)("span",{"data-testid":"schedule-section-".concat(t,"-summary"),className:"block truncate text-xs text-muted-foreground",children:a})]}),(0,r.jsx)(es.A,{className:"flex-shrink-0 w-4 h-4 text-muted-foreground transition-transform ".concat(l?"rotate-180":"")})]}),l&&(0,r.jsx)("div",{id:c,className:"px-3 py-3 flex flex-col gap-4",children:o})]})}function re(e){var t,n;let{isOpen:a,worktreeId:l,initialValues:o,originalName:c,onInsertToMessage:u,instances:m,onClose:x,onSaved:f}=e,h=(0,i.c)("schedule"),p=(0,ty.Ym)(),g=(0,ai.a)(),b=(0,s.useMemo)(()=>(m&&m.length>0?m:(0,eo.lu)([...eo.XH])).filter(e=>aK(e.cliTool)),[m]),[v,y]=(0,s.useState)(a5),[j,k]=(0,s.useState)(""),[N,C]=(0,s.useState)(!1),[S,I]=(0,s.useState)(null),[T,E]=(0,s.useState)(()=>new Set(["basic","advanced","message"]));(0,s.useEffect)(()=>{var e,t,n,r,s,l,i,c,d,u,m,x,f,h;if(!a)return;I(null),C(!1);let p=null!=(t=null==o?void 0:o.cliToolId)?t:a5.cliToolId;y({name:null!=(n=null==o?void 0:o.name)?n:a5.name,cronExpression:null!=(r=null==o?void 0:o.cronExpression)?r:a5.cronExpression,message:null!=(s=null==o?void 0:o.message)?s:a5.message,cliToolId:p,enabled:null!=(l=null==o?void 0:o.enabled)?l:a5.enabled,permission:null!=(i=null==o?void 0:o.permission)?i:a5.permission,model:null!=(c=null==o?void 0:o.model)?c:a5.model,agent:null!=(d=null==o?void 0:o.agent)?d:a5.agent,variant:null!=(u=null==o?void 0:o.variant)?u:a5.variant,continueSession:null!=(m=null==o?void 0:o.continueSession)?m:a5.continueSession,title:null!=(x=null==o?void 0:o.title)?x:a5.title});let g=b.find(e=>e.cliTool===p);k(null!=(h=null!=(f=null==g?void 0:g.id)?f:null==(e=b[0])?void 0:e.id)?h:p)},[a,o,b]),(0,s.useEffect)(()=>{a&&E(new Set(g?["basic"]:["basic","advanced","message"]))},[a,g]);let A=(0,s.useCallback)(e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),M=aW(v.cliToolId),R=M.length>0,L=aZ(v.cliToolId,v.permission),P=aY.Vt.has(v.cliToolId),D=aY.aN.has(v.cliToolId),F=!!c,O=(0,s.useMemo)(()=>{let e=v.name.trim();return e?e.length>100?h("edit.errorNameTooLong",{max:100}):aG.test(e)?null:h("edit.errorNameInvalid"):h("edit.errorNameRequired")},[v.name,h]),z=(0,s.useMemo)(()=>aJ(v.cronExpression.trim())?null:h("edit.errorCronInvalid"),[v.cronExpression,h]),_=(0,s.useMemo)(()=>v.message.trim()?v.message.length>1e4?h("edit.errorMessageTooLong",{max:1e4}):null:h("edit.errorMessageRequired"),[v.message,h]),B=(0,s.useMemo)(()=>P&&v.model.trim()?(0,aY.JY)(v.model.trim()).valid?null:h("edit.errorModelInvalid"):null,[P,v.model,h]),V=(0,s.useMemo)(()=>D&&v.agent.trim()?(0,aY.sd)(v.agent.trim(),"agent").valid?null:h("edit.errorAgentInvalid"):null,[D,v.agent,h]),H=(0,s.useMemo)(()=>D&&v.variant.trim()?(0,aY.sd)(v.variant.trim(),"variant").valid?(0,aY.z7)(v.cliToolId,v.model,v.variant)?h("edit.errorVariantNeedsModel"):null:h("edit.errorVariantInvalid"):null,[D,v.cliToolId,v.model,v.variant,h]),U=(0,s.useMemo)(()=>D&&v.title.trim()?(0,aY.kj)(v.title.trim()).valid?null:h("edit.errorTitleInvalid"):null,[D,v.title,h]),K=!O&&!z&&!_&&!B&&!V&&!H&&!U,W=(0,s.useCallback)(e=>{y(t=>({...t,cliToolId:e,permission:function(e){let t=aH[e];if(void 0!==t)return t;let n=aW(e);return n.length>0?n[0]:""}(e),model:aY.Vt.has(e)?t.model:"",agent:aY.aN.has(e)?t.agent:"",variant:aY.aN.has(e)?t.variant:"",continueSession:!!aY.aN.has(e)&&t.continueSession,title:aY.aN.has(e)?t.title:""}))},[]),q=(0,s.useCallback)(e=>{let t=b.find(t=>t.id===e);t&&(k(e),W(t.cliTool))},[b,W]),$=a4.some(e=>e.value===v.cronExpression)?v.cronExpression:"custom",G=(0,s.useCallback)(e=>{"custom"!==e&&y(t=>({...t,cronExpression:e}))},[]),J=(0,s.useCallback)(e=>{null==u||u(e),x()},[u,x]),Y=(0,s.useCallback)(async()=>{if(K&&!N){C(!0),I(null);try{let e=await fetch("/api/worktrees/".concat(l,"/cmate/schedules"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.name.trim(),cronExpression:v.cronExpression.trim(),message:v.message.trim(),cliToolId:v.cliToolId,enabled:v.enabled,permission:R?v.permission:"",model:P&&v.model.trim()?v.model.trim():void 0,agent:D&&v.agent.trim()?v.agent.trim():void 0,variant:D&&v.variant.trim()?v.variant.trim():void 0,continueSession:!!D&&!!v.continueSession||void 0,title:D&&v.title.trim()?v.title.trim():void 0,originalName:null!=c?c:void 0})});if(!e.ok){let t=await e.json().catch(()=>({}));I(t.error||h("edit.saveError"));return}f(),x()}catch(e){I(h("edit.saveError"))}finally{C(!1)}}},[K,N,l,v,R,P,D,c,f,x,h]),Q=null!=(n=null==(t=b.find(e=>e.id===j))?void 0:t.alias)?n:(0,eo.f_)(v.cliToolId),X=v.name.trim()?"".concat(v.name.trim()," \xb7 ").concat(v.cronExpression):v.cronExpression,Z=[Q,R?v.permission:null,P&&v.model.trim()?v.model.trim():null,D&&v.agent.trim()?"--agent ".concat(v.agent.trim()):null,D&&v.variant.trim()?"--variant ".concat(v.variant.trim()):null,D&&v.continueSession?"--continue":null].filter(Boolean).join(" \xb7 "),ee=v.message.trim(),et=ee.length>32?"".concat(ee.slice(0,32),"…"):ee,en=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a6,htmlFor:"schedule-name-input",children:h("edit.name")}),(0,r.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:v.name,maxLength:100,placeholder:h("edit.namePlaceholder"),onChange:e=>y(t=>({...t,name:e.target.value})),className:a3}),O&&(0,r.jsx)("p",{className:a8,"data-testid":"schedule-name-error",children:O})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-cron-input",children:h("edit.cron")}),u&&(0,r.jsx)(a9,{testId:"schedule-cron-ask-ai",label:h("edit.askAiCron"),title:h("edit.askAiHint"),onClick:()=>J(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.cron"):e("edit.aiPrompts.cronRefine",{current:"`"+n+"`"})}(h,v.cronExpression))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)("input",{id:"schedule-cron-input","data-testid":"schedule-cron-input",type:"text",value:v.cronExpression,placeholder:h("edit.cronPlaceholder"),onChange:e=>y(t=>({...t,cronExpression:e.target.value})),className:"".concat(a3," font-mono sm:flex-1")}),(0,r.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":h("edit.cronPreset"),value:$,onChange:e=>G(e.target.value),className:"".concat(a3," sm:w-48"),children:[a4.map(e=>(0,r.jsx)("option",{value:e.value,children:h("edit.".concat(e.labelKey))},e.value)),(0,r.jsx)("option",{value:"custom",children:h("edit.cronPresetCustom")})]})]}),z&&(0,r.jsx)("p",{className:a8,"data-testid":"schedule-cron-error",children:z})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(d.Sc,{"data-testid":"schedule-enabled-toggle",checked:v.enabled,onCheckedChange:e=>y(t=>({...t,enabled:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:h("edit.enabledLabel")})]})]}),ea=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a6,htmlFor:"schedule-cli-tool-select",children:h("edit.cliTool")}),(0,r.jsx)("select",{id:"schedule-cli-tool-select","data-testid":"schedule-cli-tool-select",value:j,onChange:e=>q(e.target.value),className:a3,children:b.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),P&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a6,htmlFor:"schedule-model-input",children:h("edit.model")}),(0,r.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:v.model,placeholder:h("edit.modelPlaceholder"),onChange:e=>y(t=>({...t,model:e.target.value})),className:a3}),B&&(0,r.jsx)("p",{className:a8,"data-testid":"schedule-model-error",children:B})]}),D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a6,htmlFor:"schedule-agent-input",children:h("edit.opencodeAgent")}),(0,r.jsx)("input",{id:"schedule-agent-input","data-testid":"schedule-agent-input",type:"text",value:v.agent,placeholder:h("edit.opencodeAgentPlaceholder"),onChange:e=>y(t=>({...t,agent:e.target.value})),className:a3}),V&&(0,r.jsx)("p",{className:a8,"data-testid":"schedule-agent-error",children:V})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a6,htmlFor:"schedule-variant-input",children:h("edit.opencodeVariant")}),(0,r.jsx)("input",{id:"schedule-variant-input","data-testid":"schedule-variant-input",type:"text",value:v.variant,placeholder:h("edit.opencodeVariantPlaceholder"),onChange:e=>y(t=>({...t,variant:e.target.value})),className:a3}),H&&(0,r.jsx)("p",{className:a8,"data-testid":"schedule-variant-error",children:H})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a6,htmlFor:"schedule-title-input",children:h("edit.opencodeTitle")}),(0,r.jsx)("input",{id:"schedule-title-input","data-testid":"schedule-title-input",type:"text",value:v.title,placeholder:h("edit.opencodeTitlePlaceholder"),onChange:e=>y(t=>({...t,title:e.target.value})),className:a3}),U&&(0,r.jsx)("p",{className:a8,"data-testid":"schedule-title-error",children:U})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(d.Sc,{"data-testid":"schedule-continue-toggle",checked:v.continueSession,onCheckedChange:e=>y(t=>({...t,continueSession:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:h("edit.opencodeContinue")})]})]}),R&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a6,htmlFor:"schedule-permission-select",children:h("edit.permission")}),(0,r.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:v.permission,onChange:e=>y(t=>({...t,permission:e.target.value})),className:a3,children:M.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),L&&(0,r.jsx)("p",{className:"mt-1 text-xs text-warning-foreground","data-testid":"schedule-permission-write-tools-denied-note",children:a2(p).body})]})]}),es=(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-message-input",children:h("edit.message")}),u&&(0,r.jsx)(a9,{testId:"schedule-message-ask-ai",label:h("edit.askAiMessage"),title:h("edit.askAiHint"),onClick:()=>J(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.messageDraft"):e("edit.aiPrompts.messageDraftNamed",{name:"`"+n+"`"})}(h,v.name))})]}),(0,r.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:v.message,rows:4,maxLength:1e4,placeholder:h("edit.messagePlaceholder"),onChange:e=>y(t=>({...t,message:e.target.value})),className:"".concat(a3," resize-none")}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[_?(0,r.jsx)("p",{className:a8,"data-testid":"schedule-message-error",children:_}):(0,r.jsx)("span",{}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:h("edit.charCount",{count:v.message.length,max:1e4})})]})]}),el=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(a7,{id:"basic",title:h("edit.sectionBasic"),summary:X,icon:(0,r.jsx)(w.A,{className:"w-4 h-4"}),isOpen:T.has("basic"),onToggle:A,children:en}),(0,r.jsx)(a7,{id:"advanced",title:h("edit.sectionAdvanced"),summary:Z,icon:(0,r.jsx)(aI.A,{className:"w-4 h-4"}),isOpen:T.has("advanced"),onToggle:A,children:ea}),(0,r.jsx)(a7,{id:"message",title:h("edit.sectionMessage"),summary:et,icon:(0,r.jsx)(er.A,{className:"w-4 h-4"}),isOpen:T.has("message"),onToggle:A,children:es}),S&&(0,r.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:S})]}),ei=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:x,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:h("edit.cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-save-button",onClick:()=>void Y(),disabled:!K||N,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:h("edit.save")})]}),ec=F?h("edit.titleEdit"):h("edit.titleCreate");return g?(0,r.jsx)(aT,{isOpen:a,onClose:x,title:ec,footer:ei,children:el}):(0,r.jsx)(tF.a,{isOpen:a,onClose:x,title:ec,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[el,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:ei})]})})}function rt(e){return new Date(e).toLocaleString()}function rn(e,t){if(null===t)return null;let n=t-e;if(n<0)return null;let a=Math.floor(n/1e3),r=Math.floor(a/60),s=a%60;return r>0?"".concat(r,"m ").concat(s,"s"):"".concat(s,"s")}let ra=(0,s.memo)(function(e){let{worktreeId:t}=e,n=(0,ty.Ym)(),[a,l]=(0,s.useState)([]);if((0,s.useEffect)(()=>{let e=!1,n=t=>{e||l(e=>0===e.length&&0===t.length?e:t)};return(async()=>{try{var e;let a=await fetch("/api/worktrees/".concat(t,"/files/CMATE.md")),r=a.ok?await a.json():null,s="string"==typeof(null==r?void 0:r.content)?r.content:"";n(function(e){let t=[],n=0;for(let r=0;r<e.length;r++){var a;let s=e[r],l=function(e){let t=[];for(let n=0;n<e.length;n++){let a=e[n];if(a.length<3){t.push({row:n,message:"Row ".concat(n+1,": insufficient columns (need at least 3, got ").concat(a.length,")"),field:"columns"});continue}let[r,s,l]=a,i=a$(r);aG.test(i)||t.push({row:n,message:"Row ".concat(n+1,': invalid name "').concat(i,'"'),field:"name"}),aJ(s)||t.push({row:n,message:"Row ".concat(n+1,': invalid cron "').concat(s,'"'),field:"cron"}),a$(l).trim()||t.push({row:n,message:"Row ".concat(n+1,": empty message"),field:"message"});let{result:o,errors:c}=(0,aY.zK)(a[3]||"");for(let e of c)t.push({row:n,message:"Row ".concat(n+1,": ").concat(e),field:e.includes("Model")?"model":"cliTool"});o&&!(0,eo.hR)(o.cliToolId)&&t.push({row:n,message:"Row ".concat(n+1,': unknown CLI Tool "').concat(o.cliToolId,'"'),field:"cliTool"}),o&&(0,eo.hR)(o.cliToolId)&&!aK(o.cliToolId)&&t.push({row:n,message:"Row ".concat(n+1,': CLI Tool "').concat(o.cliToolId,'" is not supported in schedules yet'),field:"cliTool"});let d=a[5];if(void 0!==d&&""!==d.trim()){let e=d.trim(),a=o.cliToolId;("claude"===a?aE:"codex"===a?aA:"copilot"===a?aM:"antigravity"===a?aR:"command-code"===a?aD:"opencode-v2"===a?aB:[]).includes(e)||t.push({row:n,message:"Row ".concat(n+1,': invalid permission "').concat(e,'" for ').concat(a),field:"permission"})}}return t}([s]);if(l.some(e=>"permission"!==e.field))continue;if(n>=100)break;if(n++,l.length>0)continue;let[i,,,o,c,d]=s;if(a=c,void 0!==a&&""!==a&&"true"!==a.toLowerCase())continue;let{result:u}=(0,aY.zK)(o||""),m=(null!=d?d:"").trim();if(!aZ(u.cliToolId,m))continue;let x=a$(i);t.push({row:r,name:x,field:"permission",code:"command-code-direct-write-tools-denied",cliToolId:u.cliToolId,permission:m,message:"Row ".concat(r+1,': schedule "').concat(x,'" runs command-code with the --permission-mode value "').concat(m,'", ')+"so commandcode -p rejects the write tools the agent calls directly "+"(".concat(aQ.join(", "),"). ")+'This is a warning, not an error: the schedule still runs. Use "yolo" if it needs to write.'})}return t}(null!=(e=aX(s).get("Schedules"))?e:[]))}catch(e){n([])}})(),()=>{e=!0}},[t]),0===a.length)return null;let i=a2(n);return(0,r.jsxs)("div",{role:"status","data-testid":"schedule-config-warnings",className:"rounded border border-warning-border bg-warning-subtle p-3 text-warning-foreground",children:[(0,r.jsx)("p",{className:"text-sm font-semibold",children:i.bannerTitle}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:a.map(e=>(0,r.jsxs)("li",{"data-testid":"schedule-config-warning-".concat(e.name),"data-warning-code":e.code,className:"text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:e.name}),(0,r.jsxs)("span",{className:"ml-2 font-mono",children:[e.cliToolId," / ",e.permission]})]},"".concat(e.row,"-").concat(e.name)))}),(0,r.jsx)("p",{className:"mt-2 text-xs",children:i.body})]})}),rr=(0,s.memo)(function(e){let{worktreeId:t,logs:n}=e,a=(0,i.c)("schedule"),[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),u=(0,s.useCallback)(async e=>{if(l===e){o(null),d(null);return}try{let n=await fetch("/api/worktrees/".concat(t,"/execution-logs/").concat(e));if(n.ok){let t=await n.json();d(t.log),o(e)}}catch(e){console.error("Failed to fetch log detail:",e)}},[t,l]),m=(0,r.jsx)(ra,{worktreeId:t});return 0===n.length?(0,r.jsxs)("div",{className:"space-y-2",children:[m,(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:a("noLogs")})]}):(0,r.jsxs)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:[m,n.map(e=>(0,r.jsxs)("div",{className:"border border-border rounded bg-surface","data-testid":"execution-log-row","data-warning":e.warning?"true":void 0,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>void u(e.id),className:"w-full text-left p-3 hover:bg-muted transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm truncate max-w-[60%]",children:e.schedule_name||a("unknownSchedule")}),(0,r.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(function(e,t){if(t&&"completed"===e)return"text-warning-foreground bg-warning-subtle";switch(e){case"completed":return"text-success-foreground bg-success-subtle";case"failed":return"text-danger-foreground bg-danger-subtle";case"timeout":return"text-warning-foreground bg-warning-subtle";case"running":return"text-accent-600 dark:text-accent-400 bg-accent-50 dark:bg-accent-900/30";case"cancelled":return"text-muted-foreground bg-muted"}}(e.status,!!e.warning)),"data-testid":"execution-log-status",children:[e.warning&&(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠ "}),a("status.".concat(e.status))]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[rt(e.started_at),rn(e.started_at,e.completed_at)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",rn(e.started_at,e.completed_at),")"]}),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[a("exitCode"),": ",e.exit_code]})]}),e.warning&&(0,r.jsxs)("div",{className:"text-xs text-warning-foreground mt-1 break-words","data-testid":"execution-log-warning",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠ "}),e.warning]})]}),l===e.id&&c&&(0,r.jsxs)("div",{className:"border-t border-border p-3 bg-muted space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:a("message")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground",children:c.message})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:a("response")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground max-h-60 overflow-y-auto",children:c.result||a("noOutput")})]})]})]},e.id))]})});function rs(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M13.586 3.586a2 2 0 112.828 2.828l-8.5 8.5a1 1 0 01-.43.26l-3 .857a.5.5 0 01-.617-.618l.857-3a1 1 0 01.26-.43l8.5-8.5z"})})}function rl(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M8 2a1 1 0 00-.894.553L6.382 4H3a1 1 0 000 2h.293l.668 9.357A2 2 0 005.956 17h8.088a2 2 0 001.995-1.643L16.707 6H17a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0012 2H8zm1 5a1 1 0 012 0v6a1 1 0 11-2 0V7zm-3 0a1 1 0 011 1v5a1 1 0 11-2 0V8a1 1 0 011-1z",clipRule:"evenodd"})})}let ri=(0,s.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a,instances:l}=e,o=(0,i.c)("schedule"),c=(0,eG.SC)(),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)([]),[h,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(!0),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)("schedules"),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.useState)(void 0),[E,A]=(0,s.useState)(void 0),M=(0,s.useCallback)(async()=>{b(!0),y(null);try{let[e,n,a]=await Promise.all([fetch("/api/worktrees/".concat(t,"/execution-logs")),fetch("/api/worktrees/".concat(t,"/schedules")),fetch("/api/worktrees/".concat(t,"/schedules/active"))]);if(e.ok){let t=await e.json();m(t.logs||[])}if(n.ok){let e=await n.json();f(e.schedules||[])}if(a.ok){let e=await a.json();p(e.schedules||[])}else p([])}catch(e){y(e instanceof Error?e.message:"Failed to fetch data")}finally{b(!1)}},[t]);(0,s.useEffect)(()=>{M()},[M]);let R=(0,s.useCallback)(async e=>{try{var n,a,r,s,l,i,o;let c=await fetch("/api/worktrees/".concat(t,"/files/CMATE.md"));if(!c.ok)return null;let d=await c.json(),u="string"==typeof d.content?d.content:"",m=(null!=(n=aX(u).get("Schedules"))?n:[]).find(t=>{var n;return(null!=(n=t[0])?n:"").trim()===e});if(!m)return null;let x=(0,aY.I_)(null!=(a=m[3])?a:"claude"),f=(null!=(r=m[4])?r:"true").trim().toLowerCase();return{name:e,cronExpression:(null!=(s=m[1])?s:"").trim(),message:(null!=(l=m[2])?l:"").trim(),cliToolId:x.cliToolId||"claude",enabled:""===f||"true"===f,permission:(null!=(i=m[5])?i:"").trim(),model:null!=(o=x.model)?o:""}}catch(e){return null}},[t]),L=(0,s.useCallback)(()=>{A(void 0),T(void 0),S(!0)},[]),P=(0,s.useCallback)(async e=>{let t=await R(e.name);A(e.name),T(null!=t?t:{name:e.name,cronExpression:e.cron_expression,message:e.message,cliToolId:e.cli_tool_id,enabled:1===e.enabled,permission:"",model:""}),S(!0)},[R]),D=(0,s.useCallback)(async e=>{if(await c({description:o("edit.confirmDelete",{name:e}),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/cmate/schedules"),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})})).ok&&await M()}catch(e){console.error("Failed to delete schedule:",e)}},[t,o,M,c]),F=(0,s.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/cmate/schedules"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,enabled:1!==e.enabled})})).ok&&await M()}catch(e){console.error("Failed to toggle schedule:",e)}},[t,M]);return g?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(d.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:o("loading")})]})}):v?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("span",{className:"text-sm text-danger-foreground",children:v}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:()=>void M(),className:"ml-2 px-3 py-1 text-sm text-white bg-accent-500 rounded hover:bg-accent-600",children:o("retry")})]})}):(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(n),children:[(0,r.jsxs)("div",{className:"flex shrink-0 border-b border-border px-4 pt-3",children:[(0,r.jsxs)("button",{type:"button","data-testid":"schedule-tab-schedules",role:"tab","aria-selected":"schedules"===j,onClick:()=>w("schedules"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("schedules"===j?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"),children:[o("tabs.schedules")," (",x.length,")"]}),(0,r.jsxs)("button",{type:"button","data-testid":"schedule-tab-logs",role:"tab","aria-selected":"logs"===j,onClick:()=>w("logs"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("logs"===j?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"),children:[o("tabs.logs")," (",u.length,")"]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:"schedules"===j?(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"rounded border border-accent-100 bg-accent-50/60 p-3 dark:border-accent-900/40 dark:bg-accent-950/20",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsxs)("span",{className:"text-sm font-semibold text-accent-900 dark:text-accent-200",children:[o("activeSchedulesTitle")," (",h.length,")"]}),(0,r.jsx)("span",{className:"text-xs text-accent-700 dark:text-accent-300",children:o("activeSchedulesDescription")})]}),0===h.length?(0,r.jsx)("p",{className:"text-xs text-accent-800 dark:text-accent-300",children:o("noActiveSchedules")}):(0,r.jsx)("div",{className:"space-y-2",children:h.map(e=>(0,r.jsxs)("div",{className:"rounded border border-accent-200/80 bg-white/80 p-3 dark:border-accent-900/40 dark:bg-surface/60",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(e.isCronActive?"bg-success-subtle text-success-foreground":"bg-danger-subtle text-danger-foreground"),children:e.isCronActive?o("activeState.active"):o("activeState.inactive")}),e.isExecuting&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-100 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300",children:o("activeState.executing")})]})]}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:[o("cron"),": ",e.cronExpression||"N/A"]}),(0,r.jsxs)("span",{className:"ml-3",children:[o("agentLabel"),": ",e.cliToolId]}),e.model&&(0,r.jsxs)("span",{className:"ml-3",children:["model: ",e.model]}),e.nextRunAt&&(0,r.jsxs)("span",{className:"ml-3",children:[o("nextRun"),": ",rt(e.nextRunAt)]})]})]},e.scheduleId))})]}),0===x.length?(0,r.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,r.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,r.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-7 h-7",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7.5V12l3 2"})]})}),(0,r.jsx)("p",{className:"font-semibold text-foreground mb-1",children:o("emptyState.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:o("emptyState.description")}),(0,r.jsxs)(d.$n,{variant:"ghost",type:"button","data-testid":"schedule-empty-cta",onClick:L,className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),o("emptyState.createButton")]}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-manual-toggle","aria-expanded":k,onClick:()=>N(e=>!e),className:"mt-5 text-xs text-accent-700 dark:text-accent-300 hover:underline",children:o("emptyState.manualToggle")}),k&&(0,r.jsxs)("ol",{"data-testid":"schedule-manual-steps",className:"mt-3 text-xs text-left inline-block space-y-1.5 list-decimal list-inside text-muted-foreground",children:[(0,r.jsx)("li",{children:o("noSchedulesStep1")}),(0,r.jsx)("li",{children:o("noSchedulesStep2")}),(0,r.jsx)("li",{children:o("noSchedulesStep3")}),(0,r.jsx)("li",{children:o("noSchedulesStep4")})]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 flex items-center justify-end",children:(0,r.jsxs)(d.$n,{variant:"ghost",type:"button","data-testid":"schedule-new-button",onClick:L,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 rounded transition-colors whitespace-nowrap",children:[(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-3.5 h-3.5",children:(0,r.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),o("edit.newSchedule")]})}),(0,r.jsx)("div",{className:"space-y-2",children:x.map(e=>{let t=1===e.enabled;return(0,r.jsxs)("div",{className:"border border-border rounded p-3 bg-white dark:bg-surface",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-sm truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,"aria-label":t?o("edit.disable"):o("edit.enable"),title:t?o("edit.disable"):o("edit.enable"),"data-testid":"schedule-toggle-".concat(e.name),onClick:()=>void F(e),className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ".concat(t?"bg-success":"bg-input"),children:(0,r.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ".concat(t?"translate-x-4":"translate-x-0.5")})}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button","data-testid":"schedule-edit-".concat(e.name),"aria-label":o("edit.edit"),title:o("edit.edit"),onClick:()=>void P(e),className:"p-1.5 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded transition-colors",children:(0,r.jsx)(rs,{})}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button","data-testid":"schedule-delete-".concat(e.name),"aria-label":o("edit.delete"),title:o("edit.delete"),onClick:()=>void D(e.name),className:"p-1.5 text-muted-foreground hover:text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:(0,r.jsx)(rl,{})})]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[(0,r.jsxs)("span",{children:[o("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,r.jsxs)("span",{className:"ml-3",children:[o("lastRun"),": ",rt(e.last_executed_at)]})]})]},e.id)})})]})]}):(0,r.jsx)(rr,{worktreeId:t,logs:u})}),(0,r.jsx)(re,{isOpen:C,worktreeId:t,initialValues:I,originalName:E,onInsertToMessage:a,instances:l,onClose:()=>S(!1),onSaved:()=>{M()}})]})}),ro=(0,s.memo)(function(e){let{worktreeId:t,vibeLocalModel:n,onVibeLocalModelChange:a,vibeLocalContextWindow:l,onVibeLocalContextWindowChange:o}=e,d=(0,i.c)("schedule"),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null!=l?String(l):""),[j,w]=(0,s.useState)(!1);(0,s.useEffect)(()=>{y(null!=l?String(l):"")},[l]),(0,s.useEffect)(()=>{let e=!1;return p(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(m(t.models),f(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(m([]),f("Failed to fetch models"))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[]);let k=(0,s.useCallback)(async e=>{let n=e.target.value,r=""===n?null:n;b(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalModel:r})})).ok&&a(r)}catch(e){}finally{b(!1)}},[t,a]),N=(0,s.useCallback)(e=>{y(e.target.value)},[]),C=(0,s.useCallback)(async()=>{let e=v.trim(),n=parseInt(e,10),a=""===e||Number.isNaN(n)?null:n,r=null!=l?l:null;if(a!==r){w(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalContextWindow:a})})).ok?null==o||o(a):y(null!=r?String(r):"")}catch(e){y(null!=r?String(r):"")}finally{w(!1)}}},[v,l,t,o]);return(0,r.jsxs)("div",{className:"mt-4 pt-4 border-t border-border",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:d("vibeLocalModel")}),h?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(c.y,{size:"xs",variant:"muted"}),d("loading")]}):x&&0===u.length?(0,r.jsx)("p",{className:"text-xs text-warning-foreground",children:d("ollamaNotAvailable")}):(0,r.jsxs)("select",{"data-testid":"vibe-local-model-select",value:null!=n?n:"",onChange:k,disabled:g,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:d("vibeLocalModelDefault")}),u.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.parameterSize?" (".concat(e.parameterSize,")"):""]},e.name))]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:d("vibeLocalContextWindow")}),(0,r.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:eo.vz,max:eo.NL,value:v,onChange:N,onBlur:C,placeholder:d("vibeLocalContextWindowDefault"),disabled:j,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]})]})}),rc=Object.freeze({agent:null,providerId:null,modelId:null,variant:null}),rd=[{id:"opencode",label:(0,eo.oo)("opencode")}];function ru(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{providerId:e.slice(0,t),modelId:e.slice(t+1)}}let rm=(0,s.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,i.c)("schedule"),[l,o]=(0,s.useState)({}),[c,u]=(0,s.useState)({connected:!1,providers:[],agents:[]}),[m,x]=(0,s.useState)(!0),[f,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1;return x(!0),fetch("/api/worktrees/".concat(t,"/instances/opencode")).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(t=>{var n,a;e||(o(null!=(n=t.settings)?n:{}),u(null!=(a=t.catalog)?a:{connected:!1,providers:[],agents:[]}),g(null))}).catch(()=>{e||g(a("opencodeSettingsLoadError"))}).finally(()=>{e||x(!1)}),()=>{e=!0}},[t,a]);let b=(0,s.useCallback)(async(e,n)=>{o(t=>({...t,[e]:n})),h(!0),g(null);try{let r=await fetch("/api/worktrees/".concat(t,"/instances/opencode"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:e,...n})});if(!r.ok)return void g(a("opencodeSettingsSaveError"));let s=await r.json();s.settings&&o(t=>({...t,[e]:s.settings}))}catch(e){g(a("opencodeSettingsSaveError"))}finally{h(!1)}},[t,a]);return(0,r.jsxs)("div",{className:"mt-4 pt-4 border-t border-border","data-testid":"opencode-instance-settings",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-1",children:a("opencodeSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:a("opencodeSettingsDescription")}),m?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(d.y$,{size:"xs",variant:"muted"}),a("loading")]}):(0,r.jsxs)("div",{className:"space-y-4",children:[!c.connected&&(0,r.jsx)("p",{"data-testid":"opencode-settings-offline",className:"text-xs text-muted-foreground",children:a("opencodeSettingsOffline")}),n.map(e=>{var t,s,i,o,d,u;let m=null!=(t=l[e.id])?t:{...rc},x=m.providerId&&m.modelId?"".concat(m.providerId,"/").concat(m.modelId):"",h=function(e,t){var n;if(!t.providerId||!t.modelId)return null;let a=e.providers.find(e=>e.id===t.providerId);return null!=(n=null==a?void 0:a.models.find(e=>e.id===t.modelId))?n:null}(c,m),p=null!=(s=null==h?void 0:h.variants)?s:[],g=c.agents.filter(e=>"primary"===e.mode);return(0,r.jsxs)("div",{className:"space-y-2",children:[n.length>1&&(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:e.label}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeAgent"),g.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-agent-select-".concat(e.id),value:null!=(i=m.agent)?i:"",disabled:f,onChange:t=>void b(e.id,{...m,agent:""===t.target.value?null:t.target.value}),className:"mt-1 w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:a("opencodeDefault")}),g.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-agent-input-".concat(e.id),defaultValue:null!=(o=m.agent)?o:"",disabled:f,placeholder:a("opencodeAgentPlaceholder"),onBlur:t=>void b(e.id,{...m,agent:""===t.target.value.trim()?null:t.target.value.trim()}),className:"mt-1 w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeModel"),c.providers.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-model-select-".concat(e.id),value:x,disabled:f,onChange:t=>{var n,a;let r=ru(t.target.value);b(e.id,{...m,providerId:null!=(n=null==r?void 0:r.providerId)?n:null,modelId:null!=(a=null==r?void 0:r.modelId)?a:null,variant:null})},className:"mt-1 w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:a("opencodeDefault")}),c.providers.map(e=>(0,r.jsx)("optgroup",{label:e.name,children:e.models.map(t=>(0,r.jsx)("option",{value:"".concat(e.id,"/").concat(t.id),children:t.name},t.id))},e.id))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-model-input-".concat(e.id),defaultValue:x,disabled:f,placeholder:a("opencodeModelPlaceholder"),onBlur:t=>{var n,a;let r=ru(t.target.value.trim());b(e.id,{...m,providerId:null!=(n=null==r?void 0:r.providerId)?n:null,modelId:null!=(a=null==r?void 0:r.modelId)?a:null})},className:"mt-1 w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeVariant"),p.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-variant-select-".concat(e.id),value:null!=(d=m.variant)?d:"",disabled:f,onChange:t=>void b(e.id,{...m,variant:""===t.target.value?null:t.target.value}),className:"mt-1 w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:a("opencodeDefault")}),p.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-variant-input-".concat(e.id),defaultValue:null!=(u=m.variant)?u:"",disabled:f,placeholder:a("opencodeVariantPlaceholder"),onBlur:t=>void b(e.id,{...m,variant:""===t.target.value.trim()?null:t.target.value.trim()}),className:"mt-1 w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]}),h&&0===p.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("opencodeNoVariants")})]},e.id)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("opencodeVariantLaunchNote")}),f&&(0,r.jsxs)("div",{"data-testid":"opencode-settings-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(d.y$,{size:"xs",variant:"muted"}),a("loading")]}),p&&(0,r.jsx)("p",{"data-testid":"opencode-settings-error",className:"text-xs text-danger-foreground",children:p})]})]})}),rx=(0,s.memo)(function(e){let{worktreeId:t,selectedAgents:n,onSelectedAgentsChange:a,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:u,maxAgents:m=2,availableAgents:x=eo.XH,persistToServer:f=!0}=e,h=(0,i.c)("schedule"),p=n.length>m?n.slice(0,m):n,[g,b]=(0,s.useState)(()=>new Set(p)),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),k=(0,s.useRef)(g);k.current=g,(0,s.useEffect)(()=>{j||b(new Set(p))},[n,j,m]);let N=g.has("vibe-local"),C=g.has("opencode"),S=(0,s.useCallback)(async(e,n)=>{let r=new Set(k.current);if(n?r.add(e):(r.delete(e),w(!0)),b(r),r.size>=2){let e=Array.from(r);if(!f){b(new Set(e)),a(e),w(!1);return}y(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectedAgents:e})})).ok?(b(new Set(e)),a(e)):b(new Set(p))}catch(e){b(new Set(p))}finally{y(!1),w(!1)}}},[t,p,a,f]),I=g.size>=m;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:h("agentSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:h("selectAgents")}),(0,r.jsx)("div",{className:"space-y-3",children:x.map(e=>{let t=g.has(e),n=!t&&I;return(0,r.jsxs)("label",{className:"flex items-center gap-3 p-2 rounded-lg border transition-colors ".concat(t?"border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30":n?"border-border bg-muted opacity-50":"border-border hover:border-input hover:bg-muted"),children:[(0,r.jsx)(d.Sc,{"data-testid":"agent-checkbox-".concat(e),"aria-label":(0,eo.oo)(e),checked:t,disabled:n||v,onCheckedChange:t=>S(e,!0===t)}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:(0,eo.oo)(e)})]},e)})}),v&&(0,r.jsxs)("div",{"data-testid":"agent-settings-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(d.y$,{size:"xs",variant:"muted"}),h("loading")]}),C&&(0,r.jsx)(rm,{worktreeId:t,instances:rd}),N&&(0,r.jsx)(ro,{worktreeId:t,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:u})]})});function rf(e){return"".concat("commandmate:worktree:mobileInstances:").concat(e)}function rh(e,t){if(0===t.length)return[];if(null!==e){let n=new Set(e),a=t.filter(e=>n.has(e.id));if(a.length>0)return a}return[...t]}var rp=n(49476),rg=n(52056),rb=n(65506),rv=n(7620),ry=n(50803),rj=n(20017),rw=n(18085),rk=n(6191),rN=n(27937),rC=n(41108),rS=n(95342),rI=n(63001),rT=n(55449);let rE="/api/worktrees/apply-default-agents";var rA=n(18848);let rM=["noteInstanceFlag","noteWaitOnPrompt","noteRespondNumber"];function rR(e){let{worktreeId:t,instance:n,isOpen:a,onClose:l}=e,o=(0,i.c)("worktree"),[d,u]=(0,s.useState)(!1),[m,x]=(0,s.useState)(!1),[f,h]=(0,s.useState)(null),[p,g]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[y,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)(0);(0,s.useEffect)(()=>{if(!a)return;let e=!1;return u(!0),x(!1),v(null),j(!1),(async()=>{try{let[a,r]=await Promise.all([fetch("/api/worktrees/".concat(t,"/cli-reference")),fetch("/api/worktrees/".concat(t,"/resolve-target?instance=").concat(encodeURIComponent(n.id)))]);if(e)return;if(!a.ok||!r.ok)return void x(!0);let[s,l]=await Promise.all([a.json(),r.json()]);if(e)return;h(s),g(l)}catch(t){e||x(!0)}finally{e||u(!1)}})(),()=>{e=!0}},[a,t,n.id,w]);let N=f&&p?(0,rA.kj)({binary:f.binary,worktreeId:f.worktreeId,instanceId:p.instanceId,portPrefix:f.portPrefix,messagePlaceholder:o("cliCommands.messagePlaceholder")}):null,C=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(t),v(e),j(!1)}catch(e){console.error("[InstanceCliCommandsModal] clipboard write failed:",e),v(null),j(!0)}},[]);return(0,r.jsx)(tF.a,{isOpen:a,onClose:l,size:"md",title:o("cliCommands.title",{alias:n.alias}),children:(0,r.jsxs)("div",{className:"space-y-4","data-testid":"cli-commands-panel-".concat(n.id),children:[d&&(0,r.jsxs)("div",{"data-testid":"cli-commands-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(c.y,{size:"xs",variant:"muted"}),o("cliCommands.loading")]}),m&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{"data-testid":"cli-commands-error",className:"text-xs text-danger-foreground",children:o("cliCommands.loadError")}),(0,r.jsx)("button",{type:"button","data-testid":"cli-commands-retry",onClick:()=>k(e=>e+1),className:"text-xs font-medium px-2 py-1 rounded-md border border-input text-foreground hover:bg-muted",children:o("cliCommands.retry")})]}),N&&p&&f&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{"data-testid":"cli-commands-target",className:"text-xs text-muted-foreground break-words",children:o("cliCommands.target",{instance:p.instanceId,tool:(0,eo.oo)(p.cliToolId),stage:o("cliCommands.resolvedBy.".concat(p.resolvedBy))})}),p.conflict&&(0,r.jsxs)("p",{"data-testid":"cli-commands-conflict",className:"flex items-start gap-1 text-xs text-warning",children:[(0,r.jsx)(rg.A,{className:"w-3 h-3 mt-0.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:o("cliCommands.conflict",{instance:p.conflict.instanceId,roster:(0,eo.oo)(p.conflict.rosterCliTool),requested:(0,eo.oo)(p.conflict.requestedCliTool)})})]}),(0,r.jsx)("ul",{className:"space-y-3",children:rA.wx.map(e=>(0,r.jsxs)("li",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:o("cliCommands.commandLabel.".concat(e))}),(0,r.jsxs)("button",{type:"button","data-testid":"cli-commands-copy-".concat(e),"aria-label":o("cliCommands.copy"),title:o("cliCommands.copy"),onClick:()=>void C(e,N[e]),className:"flex items-center gap-1 shrink-0 text-xs px-2 py-1 rounded-md border border-input text-muted-foreground hover:text-foreground hover:bg-muted",children:[b===e?(0,r.jsx)(eZ.A,{className:"w-3 h-3","aria-hidden":"true"}):(0,r.jsx)(e0.A,{className:"w-3 h-3","aria-hidden":"true"}),b===e?o("cliCommands.copied"):o("cliCommands.copy")]})]}),(0,r.jsx)("code",{"data-testid":"cli-commands-command-".concat(e),className:"block whitespace-pre-wrap break-all rounded-md bg-terminal-surface px-2 py-1.5 font-mono text-xs text-terminal-foreground",children:N[e]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:o("cliCommands.commandDescription.".concat(e))})]},e))}),y&&(0,r.jsx)("p",{"data-testid":"cli-commands-copy-error",className:"text-xs text-danger-foreground",children:o("cliCommands.copyFailed")}),null!==f.portPrefix&&(0,r.jsx)("p",{"data-testid":"cli-commands-port-hint",className:"text-xs text-muted-foreground",children:o("cliCommands.portHint",{port:f.portPrefix})}),(0,r.jsxs)("div",{className:"rounded-md border border-border bg-surface-2 p-3",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:o("cliCommands.notesTitle")}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:rM.map(e=>(0,r.jsx)("li",{"data-testid":"cli-commands-".concat(e),className:"text-xs text-muted-foreground",children:o("cliCommands.".concat(e))},e))})]})]})]})})}var rL=n(58165),rP=n(45573);function rD(e){return"prompt"===e.tone?"text-warning":"text-muted-foreground"}let rF=(0,s.memo)(function(e){var t;let{worktreeId:n,instances:a,onInstancesChange:l,vibeLocalModel:o,onVibeLocalModelChange:d,vibeLocalContextWindow:u,onVibeLocalContextWindowChange:m,modelByInstance:x,sourceByInstance:f,composerTargetInstanceId:h,className:p=""}=e,g=(0,i.c)("schedule"),b=(0,ty.Ym)(),{showToast:v}=(0,tk.dj)(),y=(0,i.c)("common"),j=(0,i.c)("worktree"),w=(0,eG.SC)(),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(null),[I,T]=(0,s.useState)({}),[E,A]=(0,s.useState)(eo.XH[0]),[M,R]=(0,s.useState)(null),[L,P]=(0,s.useState)(!1),[D,F]=(0,s.useState)(!1),[O,z]=(0,s.useState)(null),_=(0,s.useCallback)(async e=>{let t=rP.yW["ja"===b?"ja":"en"];if((null!=h?h:(0,rP.xk)())===e.id)return void v(t.self,"info");let a=await (0,rP.P0)(n,e,b);if(null===a)return void v(t.failed,"error");let r=(0,rP.oQ)(a);v(r?t.inserted:t.noComposer,r?"success":"error")},[h,b,v,n]),B=function(e,t,n){let[a,r]=(0,s.useState)({}),l=t.some(e=>"opencode"===e.cliTool);return(0,s.useEffect)(()=>{if(n)return;if(!l)return void r({});let t=!1,a=async()=>{try{var n;let a=await fetch("/api/worktrees/".concat(e));if(!a.ok)return;let s=await a.json();if(t)return;let l={};for(let[e,t]of Object.entries(null!=(n=s.sessionStatusByInstance)?n:{}))(null==t?void 0:t.eventSource)&&(l[e]=t.eventSource);r(l)}catch(e){}};a();let s=setInterval(()=>void a(),1e4);return()=>{t=!0,clearInterval(s)}},[e,l,n]),null!=n?n:a}(n,a,f),V=(0,rC.UI)(n),H=(0,s.useCallback)(e=>{var t,r;return e.worktreeId!==n?"".concat(e.instanceId," @ ").concat(e.worktreeId):null!=(r=null==(t=a.find(t=>t.id===e.instanceId))?void 0:t.alias)?r:e.instanceId},[a,n]),U=a.length>=eo.Ab,K=a.length<=1,W=a.some(e=>"vibe-local"===e.cliTool),q=(0,s.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.cliTool)||(e.add(n.cliTool),t.push(n.cliTool));return t},[a]),$=function(e,t){let[n,a]=(0,s.useState)(null),[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(null),g=(0,s.useCallback)(e=>{l("string"==typeof(null==e?void 0:e.repositoryName)?e.repositoryName:null),o((null==e?void 0:e.repoDeclaresAgents)===!0)},[]),b=(0,s.useCallback)(async()=>{d(!0);try{let t=await fetch("".concat(rE,"?worktreeId=").concat(encodeURIComponent(e)));if(!t.ok)throw Error(String(t.status));let n=await t.json(),r=null==n?void 0:n.eligible;if("number"!=typeof r||!Number.isFinite(r))throw Error("unexpected body");return a(r),g(n),p(null),r}catch(e){return a(null),p("count"),null}finally{d(!1)}},[e,g]),v=(0,s.useCallback)(async()=>{d(!0),p(null),m(!1),f(null);try{let e=await fetch(rT.zk,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:t})}),n=await e.json().catch(()=>null),a=null==n?void 0:n.defaultSelectedAgents;if(!e.ok||!Array.isArray(a))return p("save"),!1;return(0,rT.IK)(a),m(!0),!0}catch(e){return p("save"),!1}finally{d(!1)}},[t]),y=(0,s.useCallback)(async()=>{d(!0),p(null),m(!1);try{let n=await fetch(rE,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:e,agents:t})}),r=await n.json().catch(()=>null),s=null==r?void 0:r.updated;if(!n.ok||"number"!=typeof s||!Number.isFinite(s))return p("apply"),null;f(s),g(r);let l=r.eligible;return"number"==typeof l&&Number.isFinite(l)&&a(l),s}catch(e){return p("apply"),null}finally{d(!1)}},[e,t,g]);return{eligible:n,repositoryName:r,repoDeclaresAgents:i,busy:c,savedDefault:u,appliedCount:x,error:h,refreshEligible:b,saveAsDefault:v,applyToUnchanged:y}}(n,q),G=q.length>=rI.eu&&q.length<=rI.Wj,J=k||$.busy,Y=G&&!$.repoDeclaresAgents&&null!==$.eligible&&$.eligible>0,Q="count"===$.error?g("agentDefaultsCountError"):"save"===$.error?g("agentDefaultsSaveError"):"apply"===$.error?g("agentDefaultsApplyError"):null,X=(0,s.useCallback)(()=>{let e=!D;F(e),e&&$.refreshEligible()},[D,$]),Z=(0,s.useCallback)(async()=>{if(!Y)return;let e=await $.refreshEligible();null!==e&&0!==e&&await w({description:g("agentDefaultsApplyConfirm",{count:e,agents:q.map(e=>(0,eo.oo)(e)).join(", ")})})&&await $.applyToUnchanged()},[Y,$,w,g,q]),ee=(0,s.useCallback)(async e=>{let t=e.map((e,t)=>({...e,order:t}));N(!0),S(null);try{(await fetch("/api/worktrees/".concat(n),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:t})})).ok?l(t):S(g("agentInstanceSaveError"))}catch(e){S(g("agentInstanceSaveError"))}finally{N(!1)}},[n,l,g]),et=(0,s.useCallback)(()=>{if(a.length>=eo.Ab)return;let e=function(e,t){let n=new Set(t.map(e=>e.id));if(!n.has(e))return e;let a=2;for(;n.has("".concat(e,"-").concat(a));)a++;return"".concat(e,"-").concat(a)}(E,a);ee([...a,{id:e,cliTool:E,alias:function(e,t){let n=(0,eo.oo)(e);if(t===e)return n;let a=t.slice(e.length+1);return a?"".concat(n," ").concat(a):n}(E,e),order:a.length}])},[E,a,ee]),en=(0,s.useCallback)(async e=>{var t;if(a.length<=1)return;let n=a.find(t=>t.id===e);await w({description:y("confirmDelete",{name:null!=(t=null==n?void 0:n.alias)?t:""}),variant:"danger"})&&ee(a.filter(t=>t.id!==e))},[a,ee,w,y]),ea=(0,s.useCallback)((e,t)=>{let n=e+t;if(n<0||n>=a.length)return;let r=[...a];[r[e],r[n]]=[r[n],r[e]],ee(r)},[a,ee]),er=(0,s.useCallback)((e,t)=>{T(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n});let n=a.find(t=>t.id===e);n&&t!==n.alias&&ee(a.map(n=>n.id===e?{...n,alias:t}:n))},[a,ee]),el=(0,s.useCallback)((e,t)=>{if(e===t||e<0||t<0||e>=a.length||t>=a.length)return;let n=[...a],[r]=n.splice(e,1);n.splice(t,0,r),ee(n)},[a,ee]),ei=["flex flex-col p-4",p?"overflow-y-auto":"",p].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:ei,"data-testid":"agent-instances-pane",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:g("agentInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:g("agentInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-2",children:a.map((e,t)=>{var s;let l=e.id in I?I[e.id]:e.alias,i=M===t,o=null!=(s=null==x?void 0:x[e.id])?s:null,c=null==B?void 0:B[e.id],d=tK(c,j),u=!!c&&("sse"!==c.kind||"live"!==c.liveness),m=(0,rS.g)({owed:V.owedBy(e.id),awaiting:V.awaitedBy(e.id),aliasOf:H}),f=h===e.id;return(0,r.jsxs)("div",{"data-testid":"agent-instance-row-".concat(e.id),draggable:!0,onDragStart:()=>R(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{null!==M&&el(M,t),R(null)},onDragEnd:()=>R(null),className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface transition-colors hover:border-accent-300 dark:hover:border-accent-700 focus-within:border-accent-500 ".concat(i?"opacity-50":""),children:[(0,r.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,r.jsx)(rp.A,{className:"w-4 h-4"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("input",{type:"text","data-testid":"agent-instance-alias-".concat(e.id),"aria-label":g("agentInstanceAliasLabel"),value:l,maxLength:eo.pQ,disabled:k,placeholder:g("agentInstanceAliasPlaceholder"),onChange:t=>T(n=>({...n,[e.id]:t.target.value})),onBlur:t=>er(e.id,t.target.value),onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||e.currentTarget.blur()},className:"w-full text-sm font-medium border border-input rounded-md px-2 py-1 bg-surface dark:bg-surface-2 text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"}),(0,r.jsx)(nY.nR,{content:(0,eo.oo)(e.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"}),o&&(0,r.jsx)("span",{"data-testid":"agent-instance-model-".concat(e.id),title:j("agentModel.modelLabel",{model:o}),className:"mt-0.5 block truncate text-xs text-muted-foreground",children:o}),d&&(0,r.jsxs)("span",{"data-testid":"agent-instance-source-".concat(e.id),title:j(u?"agentSource.degradedTitle":"agentSource.healthyTitle"),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(u?"text-warning":"text-muted-foreground"),children:[u?(0,r.jsx)(rg.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}):(0,r.jsx)(rb.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:d})]}),m.map(t=>(0,r.jsxs)("span",{"data-testid":"agent-instance-relay-".concat(t.tone,"-").concat(e.id),title:j("relay.".concat(t.titleKey)),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(rD(t)),children:[(0,r.jsx)(rv.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:j("relay.".concat(t.key),t.params)})]},t.key))]}),(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-cli-".concat(e.id),"aria-label":j("cliCommands.open"),title:j("cliCommands.open"),onClick:()=>z(e.id),className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted",children:(0,r.jsx)(ry.A,{className:"w-4 h-4"})}),O===e.id&&(0,r.jsx)(rR,{worktreeId:n,instance:e,isOpen:!0,onClose:()=>z(null)}),(0,r.jsxs)(ed.rI,{children:[(0,r.jsx)(ed.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-menu-".concat(e.id),"aria-label":g("agentInstanceActions"),title:g("agentInstanceActions"),disabled:k,className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(rj.A,{className:"w-4 h-4"})})}),(0,r.jsxs)(ed.SQ,{align:"end",children:[!f&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(ed._2,{"data-testid":"agent-instance-delegate-".concat(e.id),onSelect:()=>{_(e)},children:[(0,r.jsx)(rw.A,{className:"w-4 h-4"}),rP.yW["ja"===b?"ja":"en"].menuItem]}),(0,r.jsx)(ed.mB,{})]}),(0,r.jsxs)(ed._2,{"data-testid":"agent-instance-move-up-".concat(e.id),disabled:0===t,onSelect:()=>ea(t,-1),children:[(0,r.jsx)(ax.A,{className:"w-4 h-4"}),g("agentInstanceMoveUp")]}),(0,r.jsxs)(ed._2,{"data-testid":"agent-instance-move-down-".concat(e.id),disabled:t===a.length-1,onSelect:()=>ea(t,1),children:[(0,r.jsx)(es.A,{className:"w-4 h-4"}),g("agentInstanceMoveDown")]}),(0,r.jsx)(ed.mB,{}),(0,r.jsxs)(ed._2,{"data-testid":"agent-instance-delete-".concat(e.id),disabled:K,onSelect:()=>{en(e.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,r.jsx)(nW.A,{className:"w-4 h-4"}),g("agentInstanceDelete")]})]})]})]},e.id)})}),(0,r.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,r.jsx)("select",{"data-testid":"agent-instance-add-tool","aria-label":g("agentInstanceBaseTool"),value:E,disabled:k||U,onChange:e=>A(e.target.value),className:"flex-1 min-w-0 text-sm border border-input rounded-md px-2 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:eo.XH.map(e=>(0,r.jsx)("option",{value:e,children:(0,eo.oo)(e)},e))}),(0,r.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:k||U,onClick:et,className:"flex items-center gap-1 text-sm font-medium px-3 py-2 rounded-md border border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 hover:bg-accent-100 dark:hover:bg-accent-900/50 disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[(0,r.jsx)(rk.A,{className:"w-4 h-4"}),g("agentInstanceAdd")]})]}),U&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("agentInstanceMax",{max:eo.Ab})}),K&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("agentInstanceMin",{min:1})}),k&&(0,r.jsxs)("div",{"data-testid":"agent-instances-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(c.y,{size:"xs",variant:"muted"}),g("loading")]}),C&&(0,r.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:C}),W&&(0,r.jsx)(ro,{worktreeId:n,vibeLocalModel:o,onVibeLocalModelChange:d,vibeLocalContextWindow:u,onVibeLocalContextWindowChange:m}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"agent-defaults-toggle","aria-expanded":D,onClick:X,className:"flex w-full items-center gap-1 text-left text-sm font-semibold text-foreground hover:text-accent-600 dark:hover:text-accent-400",children:[D?(0,r.jsx)(es.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(rN.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),g("agentDefaults")]}),D&&(0,r.jsxs)("div",{className:"mt-2 space-y-3","data-testid":"agent-defaults-section",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:g("agentDefaultsDescription")}),(0,r.jsx)("p",{"data-testid":"agent-defaults-roster",className:"text-xs font-medium text-foreground break-words",children:q.map(e=>(0,eo.oo)(e)).join(" → ")}),!G&&(0,r.jsx)("p",{"data-testid":"agent-defaults-invalid",className:"text-xs text-warning-foreground",children:g("agentDefaultsInvalidRoster",{min:rI.eu,max:rI.Wj})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-set-default",disabled:J||!G,onClick:()=>{$.saveAsDefault()},className:"w-full text-sm font-medium px-3 py-2 rounded-md border border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 hover:bg-accent-100 dark:hover:bg-accent-900/50 disabled:opacity-40 disabled:cursor-not-allowed",children:g("agentDefaultsSetDefault")}),(0,r.jsxs)("div",{className:"space-y-1",children:[$.repositoryName&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repository","data-repository":$.repositoryName,className:"text-xs text-muted-foreground",children:g("agentDefaultsRepositoryLabel",{repository:$.repositoryName})}),$.repoDeclaresAgents&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repo-declared",className:"text-xs text-warning-foreground",children:g("agentDefaultsRepoDeclared")}),!$.repoDeclaresAgents&&(0,r.jsx)("span",{"data-testid":"agent-defaults-eligible","data-count":null!=(t=$.eligible)?t:void 0,className:"block text-xs text-muted-foreground",children:null===$.eligible?g("agentDefaultsEligibleUnknown"):g("agentDefaultsEligible",{count:$.eligible})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-apply",disabled:J||!Y,onClick:()=>{Z()},className:"w-full text-sm font-medium px-3 py-2 rounded-md border border-border bg-surface text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed",children:g("agentDefaultsApply")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:g("agentDefaultsApplyScope")})]}),$.savedDefault&&(0,r.jsxs)("p",{"data-testid":"agent-defaults-saved",className:"flex items-center gap-1 text-xs text-success-foreground",children:[(0,r.jsx)(eZ.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),g("agentDefaultsSaved")]}),null!==$.appliedCount&&(0,r.jsxs)("p",{"data-testid":"agent-defaults-applied","data-count":$.appliedCount,className:"flex items-center gap-1 text-xs text-success-foreground",children:[(0,r.jsx)(eZ.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),g("agentDefaultsApplied",{count:$.appliedCount})]}),Q&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{"data-testid":"agent-defaults-error",className:"text-xs text-danger-foreground",children:Q}),"count"===$.error&&(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-retry",disabled:J,onClick:()=>{$.refreshEligible()},className:"text-xs font-medium underline text-accent-700 dark:text-accent-300 disabled:opacity-40 disabled:cursor-not-allowed",children:g("agentDefaultsRetry")})]})]})]}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"agent-updates-toggle","aria-expanded":L,onClick:()=>P(e=>!e),className:"flex w-full items-center gap-1 text-left text-sm font-semibold text-foreground hover:text-accent-600 dark:hover:text-accent-400",children:[L?(0,r.jsx)(es.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(rN.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),y("agentUpdates.title")]}),L&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(rL.uN,{worktreeId:n,instances:a.map(e=>({id:e.id,cliTool:e.cliTool,alias:e.alias})),variant:"plain"})})]})]})}),rO=(0,s.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:u,visibleInstanceIds:m,onToggleInstanceVisible:x,modelByInstance:f,sourceByInstance:h,composerTargetInstanceId:p}=e,g=(0,i.c)("schedule"),b=(0,i.c)("worktree"),v=new Set(m),y=m.length<=1,j=(0,rC.UI)(t),w=(0,s.useCallback)(e=>{var a,r;return e.worktreeId!==t?"".concat(e.instanceId," @ ").concat(e.worktreeId):null!=(r=null==(a=n.find(t=>t.id===e.instanceId))?void 0:a.alias)?r:e.instanceId},[n,t]);return(0,r.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,r.jsx)(rF,{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:u,modelByInstance:f,sourceByInstance:h,composerTargetInstanceId:p}),(0,r.jsxs)("div",{"data-testid":"mobile-visible-instances",className:"px-4 pb-4 border-t border-border mt-2 pt-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:g("mobileVisibleInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:g("mobileVisibleInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-1",children:n.map(e=>{var t;let n=v.has(e.id),a=n&&y,s=null!=(t=null==f?void 0:f[e.id])?t:null,l=(0,rS.g)({owed:j.owedBy(e.id),awaiting:j.awaitedBy(e.id),aliasOf:w});return(0,r.jsxs)("label",{className:"flex items-center gap-2 p-2 rounded-lg cursor-pointer ".concat(a?"opacity-60 cursor-not-allowed":"hover:bg-muted"),children:[(0,r.jsx)(d.Sc,{"data-testid":"mobile-visible-instance-toggle-".concat(e.id),checked:n,disabled:a,onCheckedChange:()=>x(e.id)}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-foreground truncate",children:(0,eo.sw)(e)}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,eo.oo)(e.cliTool)}),s&&(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-model-".concat(e.id),title:b("agentModel.modelLabel",{model:s}),className:"block text-xs text-muted-foreground truncate",children:s}),l.map(t=>(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-relay-".concat(t.tone,"-").concat(e.id),title:b("relay.".concat(t.titleKey)),className:"block text-xs truncate ".concat(rD(t)),children:b("relay.".concat(t.key),t.params)},t.key))]})]},e.id)})}),y&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("mobileVisibleInstanceMin")})]})]})}),rz=Array.from({length:Math.floor(104)+1},(e,t)=>3e5+3e5*t);var r_=n(76351);function rB(e){let t=Math.floor(e/6e4),n=Math.floor(t/60),a=t%60;return n>0&&a>0?"".concat(n,"h ").concat(a,"m"):n>0?"".concat(n,"h"):"".concat(a,"m")}let rV="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring";function rH(e){let{isOpen:t,worktreeId:n,instances:a,onClose:l,onSaved:o}=e,c=(0,i.c)("schedule"),d=(0,ai.a)(),u=(0,s.useMemo)(()=>a&&a.length>0?a:(0,eo.lu)([...eo.XH]),[a]),[m,x]=(0,s.useState)(""),[f,h]=(0,s.useState)(()=>{var e,t;return null!=(t=null==(e=u[0])?void 0:e.id)?t:eo.XH[0]}),[p,g]=(0,s.useState)(rz[0]),[b,v]=(0,s.useState)(!1),[y,j]=(0,s.useState)(null);(0,s.useEffect)(()=>{var e,n;t&&(x(""),g(rz[0]),j(null),v(!1),h(null!=(n=null==(e=u[0])?void 0:e.id)?n:eo.XH[0]))},[t,u]),(0,s.useEffect)(()=>{if(!u.some(e=>e.id===f)){var e,t;h(null!=(t=null==(e=u[0])?void 0:e.id)?t:eo.XH[0])}},[u,f]);let w=m.trim().length>0&&!b,k=(0,s.useCallback)(async()=>{if(!m.trim()||b)return;let e=u.find(e=>e.id===f);if(e){j(null),v(!0);try{let t=await fetch("/api/worktrees/".concat(n,"/timers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:e.cliTool,instanceId:e.id,message:m.trim(),delayMs:p})});if(t.ok){let e=await t.json();o(),"session_not_running"===e.warning?(j("session_not_running"),x("")):l()}}catch(e){}finally{v(!1)}}},[n,u,f,m,p,b,o,l]),N=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-instance-select",children:c("timer.agent")}),(0,r.jsx)("select",{id:"timer-instance-select","data-testid":"timer-instance-select",value:f,onChange:e=>h(e.target.value),className:rV,children:u.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-message-input",children:c("timer.message")}),(0,r.jsx)("textarea",{id:"timer-message-input","data-testid":"timer-message-input",value:m,onChange:e=>x(e.target.value),placeholder:c("timer.message"),maxLength:1e4,rows:3,className:"".concat(rV," resize-none")})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-delay-select",children:c("timer.delay")}),(0,r.jsx)("select",{id:"timer-delay-select","data-testid":"timer-delay-select",value:p,onChange:e=>g(Number(e.target.value)),className:rV,children:rz.map(e=>(0,r.jsx)("option",{value:e,children:rB(e)},e))})]}),"session_not_running"===y&&(0,r.jsx)("div",{"data-testid":"timer-session-warning",className:"text-xs p-2 rounded bg-warning-subtle text-warning-foreground",children:c("timer.sessionWarning")})]}),C=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:l,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:c("timer.close")}),(0,r.jsx)("button",{type:"button","data-testid":"timer-register-button",onClick:()=>void k(),disabled:!w,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:c("timer.register")})]}),S=c("timer.titleCreate");return d?(0,r.jsx)(aT,{isOpen:t,onClose:l,title:S,footer:C,children:N}):(0,r.jsx)(tF.a,{isOpen:t,onClose:l,title:S,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[N,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:C})]})})}function rU(e){return new Date(e).toLocaleString()}function rK(e){var t,n;let{timer:a,instances:s,onClose:l}=e,o=(0,i.c)("schedule"),c=(0,ai.a)();if(!a)return null;let d=null!=(n=null==(t=s.find(e=>e.id===a.instanceId))?void 0:t.alias)?n:a.cliToolId,u=e=>{let{label:t,children:n}=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-0.5",children:t}),(0,r.jsx)("div",{className:"text-sm text-foreground break-words",children:n})]})},m=(0,r.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"timer-detail-body",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:o("timer.message")}),(0,r.jsx)("pre",{"data-testid":"timer-detail-message",className:"text-sm whitespace-pre-wrap break-words font-mono text-foreground bg-muted rounded p-2 max-h-60 overflow-y-auto",children:a.message})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(u,{label:o("timer.agent"),children:(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:d})}),(0,r.jsx)(u,{label:o("timer.statusLabel"),children:(0,r.jsx)("span",{className:function(e){switch(e){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(a.status),children:o("timer.status.".concat(a.status))})}),(0,r.jsx)(u,{label:o("timer.delay"),children:rB(a.delayMs)}),(0,r.jsx)(u,{label:o("timer.scheduledTime"),children:rU(a.scheduledSendTime)}),(0,r.jsx)(u,{label:o("timer.createdTime"),children:rU(a.createdAt)}),null!==a.sentAt&&(0,r.jsx)(u,{label:o("timer.sentTime"),children:rU(a.sentAt)})]}),"failed"===a.status&&a.error&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-danger-foreground mb-1",children:o("timer.failureReason")}),(0,r.jsx)("pre",{"data-testid":"timer-detail-error",className:"text-xs whitespace-pre-wrap break-words font-mono text-danger-foreground bg-danger-subtle rounded p-2 max-h-40 overflow-y-auto",children:a.error})]})]}),x=(0,r.jsx)("div",{className:"flex items-center justify-end",children:(0,r.jsx)("button",{type:"button","data-testid":"timer-detail-close",onClick:l,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:o("timer.close")})}),f=o("timer.detailTitle");return c?(0,r.jsx)(aT,{isOpen:!0,title:f,onClose:l,footer:x,children:m}):(0,r.jsx)(tF.a,{isOpen:!0,title:f,onClose:l,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[m,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:x})]})})}let rW=(0,s.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,i.c)("schedule"),l=(0,eG.SC)(),o=(0,s.useMemo)(()=>n&&n.length>0?n:(0,eo.lu)([...eo.XH]),[n]),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),[,g]=(0,s.useState)(0),b=(0,s.useRef)(null),y=(0,s.useRef)(null),j=(0,s.useRef)(null),w=(0,s.useCallback)(async()=>{try{let n=await fetch("/api/worktrees/".concat(t,"/timers"));if(n.ok){var e;let t=await n.json();d(t.timers),m(null!=(e=t.hasMore)&&e),t.timers.length>0?j.current=t.timers[t.timers.length-1].createdAt:j.current=null}}catch(e){}},[t]),k=(0,s.useCallback)(async()=>{if(null!=j.current)try{let n=new URLSearchParams;n.set("before",String(j.current)),n.set("limit",String(50));let a=await fetch("/api/worktrees/".concat(t,"/timers?").concat(n));if(a.ok){var e;let t=await a.json();d(e=>[...e,...t.timers]),m(null!=(e=t.hasMore)&&e),t.timers.length>0&&(j.current=t.timers[t.timers.length-1].createdAt)}}catch(e){}},[t]);(0,s.useEffect)(()=>{function e(){return w(),b.current=setInterval(()=>{w()},1e4),y.current=setInterval(()=>{g(e=>e+1)},1e3),t}function t(){b.current&&clearInterval(b.current),y.current&&clearInterval(y.current),b.current=null,y.current=null}e();let n=()=>{"hidden"===document.visibilityState?t():e()};return document.addEventListener("visibilitychange",n),()=>{t(),document.removeEventListener("visibilitychange",n)}},[w]);let N=(0,s.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/timers?timerId=").concat(e),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w]),C=(0,s.useCallback)(async()=>{if(await l({description:a("timer.clearConfirm"),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/timers/history"),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w,a,l]),S=c.filter(e=>"pending"===e.status).length>=5;return(0,r.jsxs)("div",{className:"flex flex-col h-full p-3 gap-3 overflow-auto",children:[0===c.length?(0,r.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,r.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,r.jsx)(v.A,{className:"w-7 h-7"})}),(0,r.jsx)("p",{className:"font-semibold text-foreground mb-1",children:a("timer.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:a("timer.noTimers")}),(0,r.jsxs)("button",{type:"button","data-testid":"timer-empty-cta",onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,r.jsx)(rk.A,{className:"w-4 h-4"}),a("timer.createButton")]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[S&&(0,r.jsx)("span",{className:"text-xs text-warning-foreground",children:a("timer.maxReached",{max:5})}),(0,r.jsxs)("button",{type:"button","data-testid":"timer-new-button",onClick:()=>f(!0),disabled:S,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded transition-colors whitespace-nowrap",children:[(0,r.jsx)(rk.A,{className:"w-3.5 h-3.5"}),a("timer.newTimer")]})]}),c.map(e=>{var t,n;return(0,r.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"timer-row",onClick:()=>p(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),p(e))},className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface text-left cursor-pointer hover:bg-muted transition-colors",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm text-foreground truncate",children:e.message.length>60?e.message.slice(0,60)+"...":e.message}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:null!=(n=null==(t=o.find(t=>t.id===e.instanceId))?void 0:t.alias)?n:e.cliToolId}),(0,r.jsx)("span",{className:function(e){switch(e){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(e.status),children:a("timer.status.".concat(e.status))}),"pending"===e.status&&(0,r.jsx)("span",{className:"text-muted-foreground",children:(0,r_.$B)(e.scheduledSendTime)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:rB(e.delayMs)})]})]}),"pending"===e.status&&(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),N(e.id)},className:"px-2 py-1 text-xs text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:a("timer.cancel")})]},e.id)}),u&&(0,r.jsx)("button",{type:"button",onClick:k,className:"px-3 py-2 text-sm text-accent-600 dark:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded-md transition-colors text-center",children:a("timer.loadMore")}),c.some(e=>"pending"!==e.status)&&(0,r.jsx)("button",{type:"button",onClick:C,className:"px-3 py-2 text-sm text-muted-foreground hover:bg-muted rounded-md transition-colors text-center",children:a("timer.clearHistory")})]}),(0,r.jsx)(rH,{isOpen:x,worktreeId:t,instances:n,onClose:()=>f(!1),onSaved:()=>{w()}}),(0,r.jsx)(rK,{timer:h,instances:o,onClose:()=>p(null)})]})});var rq=n(35626),r$=n(99648);let rG={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},rJ={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},rY={outcome:"unknown",evidenceKind:"not_measured",labelKey:rG.unknown,evidenceKindKey:rJ.not_measured,limitationKey:null},rQ={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",PICKED_UP_LIVE:"skills.compatibility.reload.pickedUpLive",UNKNOWN:"skills.compatibility.reload.unknown"},rX={NO_SLASH_COMMAND:"skills.compatibility.limitation.noSlashCommand"};function rZ(e){return{agent:e,discoveryRoots:[],discovery:rY,invocation:rY,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:rQ.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}r$.td,rG.verified,rJ.mechanical,rG.verified,rJ.mechanical,rQ.SESSION_RESTART,r$.Co,rG.verified,rJ.self_report,rG.unsupported,rJ.mechanical,rX.NO_SLASH_COMMAND,rQ.SESSION_RESTART_NO_SLASH,rZ("gemini"),rZ("vibe-local"),r$.Co,r$.td,rG.verified,rJ.mechanical,rG.verified,rJ.mechanical,rX.NO_SLASH_COMMAND,rQ.SESSION_RESTART,r$.Co,r$.td,rG.verified,rJ.mechanical,rG.verified,rJ.mechanical,rQ.UNKNOWN,rZ("antigravity"),r$.Co,rG.verified,rJ.mechanical,rG.verified,rJ.mechanical,rQ.SESSION_RESTART,r$.Co,r$.td,rG.verified,rJ.mechanical,rG.verified,rJ.mechanical,rX.NO_SLASH_COMMAND,rQ.PICKED_UP_LIVE;let r0={SATISFIED:"SKILL_COMPAT_SATISFIED",HOST_VERSION_OUT_OF_RANGE:"SKILL_COMPAT_HOST_VERSION_OUT_OF_RANGE",HOST_VERSION_UNKNOWN:"SKILL_COMPAT_HOST_VERSION_UNKNOWN",RANGE_UNSUPPORTED:"SKILL_COMPAT_RANGE_UNSUPPORTED"};r0.SATISFIED,r0.HOST_VERSION_OUT_OF_RANGE,r0.HOST_VERSION_UNKNOWN,r0.RANGE_UNSUPPORTED;let r1={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};r1.CONFIRMED,r1.RESTRICTED,r1.STALE_DECLARATION,r1.UNVERIFIED;let r2=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function r4(e){if("string"!=typeof e||e.length>64)return null;let t=r2.exec(e);return t?{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),prerelease:t[4]?t[4].split("."):[],build:t[5]?t[5].split("."):[]}:null}let r5={UP_TO_DATE:"SKILL_UPDATE_UP_TO_DATE",HIGHEST_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_HIGHEST_COMPATIBLE",LATEST_UNVERIFIED:"SKILL_UPDATE_RECOMMEND_LATEST_UNVERIFIED",NONE_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_NONE_COMPATIBLE",INSTALLED_VERSION_INVALID:"SKILL_UPDATE_INSTALLED_VERSION_INVALID",RANGE_UNSUPPORTED:"SKILL_UPDATE_RANGE_UNSUPPORTED"};function r3(e,t){let n=function(e,t){let n=r4(e),a=r4(t);return n&&a?n.major!==a.major?n.major<a.major?-1:1:n.minor!==a.minor?n.minor<a.minor?-1:1:n.patch!==a.patch?n.patch<a.patch?-1:1:function(e,t){if(0===e.length&&0===t.length)return 0;if(0===e.length)return 1;if(0===t.length)return -1;let n=Math.min(e.length,t.length);for(let a=0;a<n;a++){let n=e[a],r=t[a];if(n===r)continue;let s=/^\d+$/.test(n),l=/^\d+$/.test(r);if(s&&l)return Number(n)<Number(r)?-1:1;if(s)return -1;if(l)return 1;return n<r?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}(n.prerelease,a.prerelease):null}(e,t);return null!==n&&n>0}r5.UP_TO_DATE,r5.HIGHEST_COMPATIBLE,r5.LATEST_UNVERIFIED,r5.NONE_COMPATIBLE,r5.INSTALLED_VERSION_INVALID,r5.RANGE_UNSUPPORTED;var r6=n(75333),r8=n(34380),r9=n(37381),r7=n(95584),se=n(80130);let st={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function sn(e){let{heading:t,paths:n,testid:a}=e;return 0===n.length?null:(0,r.jsxs)("div",{"data-testid":a,children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:n.map(e=>(0,r.jsx)("li",{className:"break-all font-mono text-xs text-foreground",children:e},e))})]})}function sa(e){var t;let{skillId:n,skillName:a,worktreeId:l,installedVersion:o,versions:c}=e,u=(0,i.c)("skills"),m=(0,s.useMemo)(()=>c.filter(e=>r3(e.version,o)),[c,o]),x=(0,s.useMemo)(()=>{var e,t,n;return null!=(n=null==(e=null!=(t=m.find(e=>"compatible"===e.compatibility.commandmate.status))?t:m[0])?void 0:e.version)?n:null},[m]),[f,h]=(0,s.useState)(st),p=(0,s.useCallback)(()=>{h({...st,open:!0,selectedVersion:x})},[x]),g=(0,s.useCallback)(()=>{h(st)},[]),b=(0,s.useCallback)(async()=>{let e=f.selectedVersion;if(!e)return;h(e=>({...e,busy:!0,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applyResult:null,applyFailure:null}));let t=await (0,se.Sw)(l,n,{version:e});h(e=>({...e,busy:!1,plan:t.ok?t.data.plan:null,failure:t.ok?null:t.failure}))},[n,f.selectedVersion,l]),v=(0,s.useCallback)(async()=>{var e;let t=f.plan;if(!t||!t.updatable)return;h(e=>({...e,applying:!0,applyFailure:null}));let a=await (0,se.h2)(l,n,{planToken:t.token,version:t.update.toVersion,acknowledgeRisk:f.riskAcknowledged,acknowledgeRiskIncrease:f.riskIncreaseAcknowledged,idempotencyKey:(e=t.token,"skill-update-".concat(e))});h(e=>({...e,applying:!1,applyResult:a.ok?a.data:null,applyFailure:a.ok?null:a.failure}))},[n,f.plan,f.riskAcknowledged,f.riskIncreaseAcknowledged,l]);if(0===m.length)return(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-uptodate",children:u("update.upToDate",{version:o})});let y=f.plan,j=f.applyResult;return(0,r.jsxs)("div",{"data-testid":"skill-update-dialog-host",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(d.Ex,{variant:"info","data-testid":"skill-update-badge",children:u("update.badge")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("update.fromTo",{from:o,to:m[0].version})}),(0,r.jsx)(d.$n,{variant:"secondary",size:"sm",onClick:p,"data-testid":"skill-update-trigger",children:u("update.open")})]}),(0,r.jsx)(d.Jh,{isOpen:f.open,onClose:g,title:u("update.heading"),size:"lg",children:(0,r.jsxs)("div",{className:"space-y-3 p-4","data-testid":"skill-update-dialog",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:u("update.intro",{skill:a,version:o})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:u("update.ready")}),(0,r.jsxs)("label",{className:"block text-xs font-medium text-muted-foreground",children:[u("update.versionPicker"),(0,r.jsx)("select",{className:"".concat("w-full rounded-md border border-input bg-surface px-3 py-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"," mt-1"),value:null!=(t=f.selectedVersion)?t:"",onChange:e=>h(t=>({...t,selectedVersion:e.target.value,plan:null,failure:null})),disabled:f.busy,"data-testid":"skill-update-version-select",children:m.map(e=>(0,r.jsxs)("option",{value:e.version,children:[e.version,e.prerelease?" (".concat(u("detail.prerelease"),")"):"","compatible"!==e.compatibility.commandmate.status?" — ".concat(u(r7.OV[e.compatibility.commandmate.status])):""]},e.version))})]}),(0,r.jsx)(d.$n,{variant:"primary",disabled:f.busy||!f.selectedVersion,onClick:b,"data-testid":"skill-update-build",children:f.busy?u("update.building"):u("update.build")}),f.failure&&(0,r.jsxs)(r9.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,r.jsx)("p",{children:u((0,r7.FW)(f.failure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:u("state.errorCode",{code:f.failure.code})})]}),y&&(0,r.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-plan",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground",children:u("update.fromTo",{from:y.update.fromVersion,to:y.update.toVersion})}),null!==y.update.latestVersion&&y.update.latestVersion!==y.update.toVersion&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("update.latestAvailable",{version:y.update.latestVersion})})]}),(0,r.jsx)(r9.u,{tone:y.updatable?"info":"warning","data-testid":"skill-update-next-action",children:u((0,r7.e5)(y.nextActionKey))}),y.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-blockers",children:y.blockers.map(e=>{var t;return(0,r.jsxs)("li",{className:"text-xs text-danger-foreground",children:[e.path&&(0,r.jsx)("span",{className:"mr-1 break-all font-mono",children:e.path}),u((0,r7.e5)(e.messageKey))]},"".concat(e.code,":").concat(null!=(t=e.path)?t:""))})}),(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-risk",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("plan.riskHeading")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-foreground",children:[(0,r.jsx)(r6.qW,{risk:y.securityDiff.risk.from.effective}),(0,r.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,r.jsx)(r6.qW,{risk:y.securityDiff.risk.to.effective})]}),y.riskIncreased&&y.riskIncreaseMessageKey&&(0,r.jsx)(r9.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:u((0,r7.e5)(y.riskIncreaseMessageKey))}),y.requiresRiskAcknowledgement&&y.riskAcknowledgementMessageKey&&(0,r.jsx)(r9.u,{tone:"warning","data-testid":"skill-update-high-risk",children:u((0,r7.e5)(y.riskAcknowledgementMessageKey))}),y.updatable&&!f.applyResult&&y.requiresRiskAcknowledgement&&(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:f.riskAcknowledged,onChange:e=>h(t=>({...t,riskAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk"}),u("update.ackRisk")]}),y.updatable&&!f.applyResult&&y.riskIncreased&&(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:f.riskIncreaseAcknowledged,onChange:e=>h(t=>({...t,riskIncreaseAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk-increase"}),u("update.ackRiskIncrease")]})]}),(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-security-diff",children:[y.securityDiff.permissions.added.length>0&&(0,r.jsxs)("div",{"data-testid":"skill-update-permissions-added",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("update.permissionsAdded")}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:y.securityDiff.permissions.added.map(e=>{var t;return(0,r.jsx)("li",{className:"text-xs text-foreground",children:u(null!=(t=r7.z2[e])?t:"plan.permissionsNone")},e)})})]}),y.securityDiff.permissions.removed.length>0&&(0,r.jsxs)("div",{"data-testid":"skill-update-permissions-removed",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("update.permissionsRemoved")}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:y.securityDiff.permissions.removed.map(e=>{var t;return(0,r.jsx)("li",{className:"text-xs text-foreground",children:u(null!=(t=r7.z2[e])?t:"plan.permissionsNone")},e)})})]}),(0,r.jsx)(sn,{heading:u("update.scriptsAdded"),paths:y.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,r.jsx)(sn,{heading:u("update.scriptsRemoved"),paths:y.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,r.jsx)(sn,{heading:u("update.executablesAdded"),paths:y.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,r.jsx)(sn,{heading:u("update.executablesRemoved"),paths:y.securityDiff.executables.removed,testid:"skill-update-executables-removed"})]}),y.securityDiff.changelogs.length>0&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-changelogs",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("detail.changelogHeading")}),y.securityDiff.changelogs.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:e.version}),(0,r.jsx)("p",{className:"whitespace-pre-wrap text-xs text-muted-foreground",children:e.changelog})]},e.version))]}),(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-files",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("update.filesHeading")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-stats",children:u("update.stats",{added:y.stats.added,updated:y.stats.updated,removed:y.stats.removed,unchanged:y.stats.unchanged})}),(0,r.jsx)("ul",{className:"space-y-1",children:y.files.filter(e=>"unchanged"!==e.change).map(e=>{var t,n;return(0,r.jsxs)("li",{"data-testid":"skill-update-file",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(d.Ex,{variant:null!=(t=r7.JD[e.change])?t:"gray",children:u(null!=(n=r7.KS[e.change])?n:"update.change.update")}),(0,r.jsx)("span",{className:"break-all font-mono text-xs text-foreground",children:e.path})]}),e.diff&&(0,r.jsxs)("details",{className:"mt-1",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:u("update.showDiff")}),(0,r.jsx)("pre",{className:"mt-1 overflow-x-auto rounded-md bg-muted p-2 text-xs text-foreground",children:e.diff})]})]},e.path)})})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-expiry",children:u("plan.expiresAt",{timestamp:y.expiresAt})}),y.updatable&&!f.applyResult&&(0,r.jsx)(d.$n,{variant:"primary",disabled:f.applying||y.requiresRiskAcknowledgement&&!f.riskAcknowledged||y.riskIncreased&&!f.riskIncreaseAcknowledged,onClick:v,"data-testid":"skill-update-apply",children:f.applying?u("update.applying"):u("update.apply")}),f.applyFailure&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,r.jsxs)(r9.u,{tone:"danger",children:[(0,r.jsx)("p",{children:u((0,r7.FW)(f.applyFailure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:u("state.errorCode",{code:f.applyFailure.code})})]}),f.applyFailure.nextActionKey&&(0,r.jsx)(r9.u,{tone:"warning",children:u((0,r7.e5)(f.applyFailure.nextActionKey))}),f.applyFailure.blockers&&f.applyFailure.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:f.applyFailure.blockers.map(e=>{var t;return(0,r.jsxs)("li",{className:"text-xs text-danger-foreground",children:[e.path&&(0,r.jsx)("span",{className:"mr-1 break-all font-mono",children:e.path}),u((0,r7.e5)(e.messageKey))]},"".concat(e.code,":").concat(null!=(t=e.path)?t:""))})})]})]}),j&&(0,r.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-result",children:[(0,r.jsx)(r9.u,{tone:"succeeded"===j.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:u((0,r7.e5)(j.operation.nextActionKey))}),"reload"in j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-foreground",children:u("update.fromTo",{from:j.update.fromVersion,to:j.update.toVersion})}),(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-result-reload",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("operation.reloadHeading")}),(0,r.jsx)("ul",{className:"space-y-1",children:j.reload.agents.map(e=>(0,r.jsx)("li",{className:"text-xs text-muted-foreground",children:u((0,r7.e5)(e.messageKey),{agent:(0,eo.f_)(e.agent),skillId:j.reload.skillId,version:j.reload.version})},e.agent))})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-result-rollback",children:u((0,r7.e5)(j.rollback.messageKey),{version:j.rollback.backup.fromVersion})})]})]})]})})]})}let sr={status:"loading",skills:[],failure:null},ss={status:"loading",skills:[],failure:null};function sl(e){var t,n,a,l,o,c,u,m;let{worktreeId:x,className:f=""}=e,h=(0,i.c)("skills"),[p,g]=(0,s.useState)(sr),[b,v]=(0,s.useState)(ss),[y,j]=(0,s.useState)(null),[w,k]=(0,s.useState)(0),[N,C]=(0,s.useState)(0);(0,s.useEffect)(()=>{let e=new AbortController;return g(sr),(0,se.s5)(e.signal).then(t=>{e.signal.aborted||g(t.ok?{status:"loaded",skills:t.data.skills,failure:null}:{status:"error",skills:[],failure:t.failure})}).catch(()=>{}),()=>e.abort()},[w]),(0,s.useEffect)(()=>{let e=new AbortController;return v(ss),(0,se.Gj)(x,e.signal).then(t=>{e.signal.aborted||v(t.ok?{status:"loaded",skills:t.data.skills,failure:null}:{status:"error",skills:[],failure:t.failure})}).catch(()=>{}),()=>e.abort()},[x,N]);let S=(0,s.useMemo)(()=>new Map(b.skills.map(e=>[e.skillId,e.version])),[b.skills]),I=(0,s.useMemo)(()=>new Map(p.skills.map(e=>[e.id,{name:e.name,summary:e.summary,latest:e.latest}])),[p.skills]),T=(0,s.useMemo)(()=>{let e=new Map;for(let[r,s]of S){var t,n,a;e.set(r,(a=null!=(n=null==(t=I.get(r))?void 0:t.latest)?n:null,null!==s&&null!==a&&r3(a,s)))}return e},[S,I]),E=(0,s.useMemo)(()=>{var e;return null!=(e=p.skills.find(e=>e.id===y))?e:null},[p.skills,y]),A=(0,s.useMemo)(()=>{var e;return null!=(e=b.skills.find(e=>e.skillId===y))?e:null},[b.skills,y]);if(y){let e=null!=(a=null==E?void 0:E.compatibility)?a:null,t=E?E.recommendedVersion:null!=(l=null==A?void 0:A.version)?l:null,n=E?E.recommendedVersion?e&&"compatible"!==e.status?h("detail.install.blockedIncompatible",{reason:h((0,r7.e5)(e.messageKey),{range:e.requiredRange,currentVersion:null!=(o=e.currentVersion)?o:""})}):null:h("detail.install.blockedNoVersion"):null;return(0,r.jsxs)("div",{className:"flex flex-col min-h-0 ".concat(f).trim(),"data-testid":"worktree-skills-pane",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border p-3",children:[(0,r.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>{j(null),C(e=>e+1)},"data-testid":"worktree-skills-back",children:[(0,r.jsx)(rq.A,{size:14,"aria-hidden":"true",className:"mr-1"}),h("worktreePane.back")]}),(0,r.jsx)("h2",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:null!=(c=null==E?void 0:E.name)?c:y})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[A&&E&&(0,r.jsx)(sa,{skillId:y,skillName:E.name,worktreeId:x,installedVersion:A.version,versions:E.versions}),(0,r.jsx)(r8.B,{skillId:y,version:t,blockedReason:n,worktreeId:x})]})]})}return(0,r.jsx)("div",{className:"flex flex-col min-h-0 ".concat(f).trim(),"data-testid":"worktree-skills-pane",children:(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-3",children:[(0,r.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-installed",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:h("worktreePane.installedHeading")}),"loading"===b.status?(0,r.jsx)(d.EA,{className:"h-16 w-full rounded-lg","data-testid":"worktree-skills-installed-loading"}):"error"===b.status?(0,r.jsxs)(d.Zp,{className:"space-y-2","data-testid":"worktree-skills-installed-error",children:[(0,r.jsxs)(r9.u,{tone:"danger",children:[(0,r.jsx)("p",{children:h("worktreePane.installedError")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:h("state.errorCode",{code:null!=(u=null==(t=b.failure)?void 0:t.code)?u:""})})]}),(0,r.jsx)(d.$n,{variant:"secondary",size:"sm",onClick:()=>C(e=>e+1),"data-testid":"worktree-skills-installed-retry",children:h("state.retry")})]}):0===b.skills.length?(0,r.jsx)(d.Zp,{"data-testid":"worktree-skills-installed-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:h("worktreePane.installedEmpty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:b.skills.map(e=>{var t;let n=I.get(e.skillId);return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>j(e.skillId),"data-testid":"worktree-skills-installed-".concat(e.skillId),className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"break-all text-sm font-semibold text-foreground",children:null!=(t=null==n?void 0:n.name)?t:e.skillId}),(0,r.jsx)(r6.qW,{risk:e.effectiveRisk}),T.get(e.skillId)&&(0,r.jsx)(d.Ex,{variant:"info","data-testid":"worktree-skills-update-badge-".concat(e.skillId),children:h("worktreePane.updateBadge")})]}),(null==n?void 0:n.summary)&&(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2","data-testid":"worktree-skills-installed-summary-".concat(e.skillId),children:n.summary}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h("worktreePane.version",{version:e.version})})]})},e.skillId)})})]}),(0,r.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-catalog",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:h("worktreePane.catalogHeading")}),"loading"===p.status?(0,r.jsx)(d.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===p.status?(0,r.jsxs)(d.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,r.jsxs)(r9.u,{tone:"danger",children:[(0,r.jsx)("p",{children:h("state.errorNotice")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:h("state.errorCode",{code:null!=(m=null==(n=p.failure)?void 0:n.code)?m:""})})]}),(0,r.jsx)(d.$n,{variant:"secondary",size:"sm",onClick:()=>k(e=>e+1),"data-testid":"worktree-skills-catalog-retry",children:h("state.retry")})]}):0===p.skills.length?(0,r.jsx)(d.Zp,{"data-testid":"worktree-skills-catalog-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:h("state.empty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:p.skills.map(e=>{let t=(0,r7.gh)(e),n=S.has(e.id),a=!0===T.get(e.id);return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>j(e.id),"data-testid":"worktree-skills-catalog-".concat(e.id),className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"min-w-0 break-all text-sm font-semibold text-foreground",children:e.name}),n&&(a?(0,r.jsx)(d.Ex,{variant:"info","data-testid":"worktree-skills-catalog-update-badge-".concat(e.id),children:h("worktreePane.updateBadge")}):(0,r.jsx)(d.Ex,{variant:"info","data-testid":"worktree-skills-installed-badge-".concat(e.id),children:h("worktreePane.installedBadge")}))]}),(0,r.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:h("card.provider",{provider:e.provider.name})}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground","data-testid":"worktree-skills-catalog-version-".concat(e.id),children:h("worktreePane.version",{version:e.latest})}),e.summary&&(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2","data-testid":"worktree-skills-catalog-summary-".concat(e.id),children:e.summary}),(0,r.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[e.compatibility&&(0,r.jsx)(r6.Xz,{status:e.compatibility.status}),t&&(0,r.jsx)(r6.qW,{risk:t})]})]})},e.id)})})]})]})})}var si=n(93499),so=n(76907),sc=n(52799),sd=n(32209);let su={pending:"gray",running:"info",waiting_input:"warning",verifying:"info",succeeded:"success",failed:"error",not_started:"warning",cancelled:"gray"},sm={running:"info",passed:"success",failed:"error",not_started:"warning",error:"error",cancelled:"gray"},sx={running:"info",passed:"success",failed:"error",timeout:"error",skipped:"gray",error:"error"},sf=["failed","timeout","error"],sh="".concat(tE,"/blob/main/docs/design/verification-config.md"),sp=".commandmate/verify.yaml";class sg extends Error{constructor(e,t,n=null){super(e),this.name="VerificationApiError",this.status=t,this.runningRunId=n}}async function sb(e,t){let n=await e.json().catch(()=>({})),a="string"==typeof n.error?n.error:"".concat(t," (").concat(e.status,")"),r="number"==typeof n.runningRunId?n.runningRunId:null;throw new sg(a,e.status,r)}function sv(e){return"/api/worktrees/".concat(encodeURIComponent(e))}async function sy(e,t){var n,a;let r=await fetch("".concat(sv(e),"/tasks?limit=1"),{signal:t});return r.ok?null!=(a=null==(n=(await r.json()).tasks)?void 0:n[0])?a:null:sb(r,"Failed to load tasks")}async function sj(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,a=arguments.length>2?arguments[2]:void 0,r=await fetch("".concat(sv(e),"/verify/runs?limit=").concat(n),{signal:a});return r.ok?null!=(t=(await r.json()).runs)?t:[]:sb(r,"Failed to load verification runs")}async function sw(e,t,n){let a=await fetch("".concat(sv(e),"/verify/runs/").concat(t),{signal:n});return 404===a.status?null:a.ok?(await a.json()).run:sb(a,"Failed to load the verification run")}async function sk(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=await fetch("".concat(sv(e),"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)return sb(n,"Failed to start verification");let a=await n.json();if("number"!=typeof a.runId)throw new sg("Verification response carried no run id",n.status);return a.runId}async function sN(e,t){var n,a,r;let s=await fetch("".concat(sv(e),"/verify/config"),{signal:t});if(!s.ok)return sb(s,"Failed to load the verification config");let l=await s.json();return{exists:!0===l.exists,path:"string"==typeof l.path?l.path:sp,gates:null!=(n=l.gates)?n:[],options:null!=(a=l.options)?a:null,plannedGateIds:null!=(r=l.plannedGateIds)?r:[],error:"string"==typeof l.error?l.error:null}}async function sC(e){var t,n,a;let r=await fetch("".concat(sv(e),"/verify/config"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!r.ok)return sb(r,"Failed to draft the verification config");let s=await r.json();return{created:!0===s.created,path:"string"==typeof s.path?s.path:sp,gates:null!=(t=s.gates)?t:[],excluded:null!=(n=s.excluded)?n:[],scanned:null!=(a=s.scanned)?a:[]}}async function sS(e,t){var n;let a=await fetch("".concat(sv(e),"/verify/runs/").concat(t,"/cancel"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!a.ok)return sb(a,"Failed to cancel the verification run");let r=await a.json();return{runId:"number"==typeof r.runId?r.runId:t,status:null!=(n=r.status)?n:"cancelled"}}async function sI(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,a=new URLSearchParams;void 0!==t.worktreeId&&a.set("worktreeId",t.worktreeId),void 0!==t.days&&a.set("days",String(t.days)),void 0!==t.limit&&a.set("limit",String(t.limit));let r=a.toString(),s=await fetch("/api/verification/runs".concat(r?"?".concat(r):""),{signal:n});return s.ok?null!=(e=(await s.json()).runs)?e:[]:sb(s,"Failed to load the verification history")}let sT={running:null,passed:0,failed:20,not_started:21,error:99,cancelled:99},sE=["passed","failed","not_started","error","cancelled"],sA={"work-evidence":"workEvidence",scope:"scope","env-clean":"envClean",config:"config"},sM={mutex:"reason=mutex-wait",detachedContract:"was NOT judged",noContract:"no contract is attached to this run",notRequired:"success.requireScopeClean: false"};var sR=n(36603);function sL(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function sP(e){let{heading:t,action:n,children:a,testId:s}=e;return(0,r.jsxs)("section",{className:"border-b border-border px-3 py-3 last:border-b-0","data-testid":s,children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),n]}),a]})}function sD(e){let{label:t,children:n}=e;return(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:t}),(0,r.jsx)("span",{className:"min-w-0 break-words text-xs text-foreground",children:n})]})}function sF(e){var t,n;let{task:a}=e,s=(0,i.c)("worktree"),l=a.contract,o=null!=(t=l.goal)?t:"",c=o.length>240?"".concat(o.slice(0,240),"…"):o;return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-contract",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"min-w-0 break-words text-sm font-medium text-foreground",children:l.title||a.title}),(0,r.jsx)(sc.E,{variant:su[a.status],"data-testid":"verification-task-status",children:s("task.status.".concat(a.status))})]}),(0,r.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:c}),(0,r.jsxs)("div",{className:"space-y-1 pt-1",children:[(0,r.jsx)(sD,{label:s("verification.contract.scopeAllow"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.allow.join(", ")||"—"})}),l.scope.deny.length>0&&(0,r.jsx)(sD,{label:s("verification.contract.scopeDeny"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.deny.join(", ")})}),(0,r.jsx)(sD,{label:s("verification.contract.gates"),children:(0,r.jsx)("span",{className:"font-mono",children:null===l.verify.gates?s("verification.contract.gatesAll"):l.verify.gates.join(", ")||s("verification.contract.gatesAll")})}),(0,r.jsx)(sD,{label:s("verification.contract.autoYes"),children:(0,r.jsx)("span",{className:"font-mono",children:null!=(n=l.autoYes.mode)?n:s("verification.contract.autoYesUnset")})}),a.contractPath&&(0,r.jsx)(sD,{label:s("verification.contract.file"),children:(0,r.jsx)("span",{className:"font-mono",children:a.contractPath})}),(0,r.jsx)(sD,{label:s("verification.contract.updated"),children:sL(a.updatedAt)})]})]})}function sO(e){let{gate:t}=e;return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 rounded-md border border-border bg-surface px-2 py-1.5","data-testid":"verification-declared-gate-".concat(t.id),children:[(0,r.jsx)("span",{className:"break-all font-mono text-xs font-medium text-foreground",children:t.id}),(0,r.jsx)("span",{className:"break-all font-mono text-[11px] text-muted-foreground",children:t.command})]})}function sz(e){let{children:t,testId:n,tone:a="muted"}=e;return(0,r.jsx)("p",{className:"whitespace-pre-line break-words ".concat("warning"===a?"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground":"text-xs text-muted-foreground"),"data-testid":n,role:"warning"===a?"alert":void 0,children:t})}function s_(e){var t,n,a,l,o,c;let{state:d}=e,u=(0,i.c)("worktree"),{config:m,configError:x,phase:f,runs:h,selectedRun:p,latestRun:g}=d,b=null!=(n=null==m?void 0:m.path)?n:sp,v=(0,s.useCallback)(()=>{d.draftConfig()},[d]),y=(0,s.useCallback)(()=>{d.rerun()},[d]),j=(0,s.useCallback)(()=>{g&&d.selectRun(g.id)},[g,d]),w=(0,s.useCallback)(()=>{d.cancelRun()},[d]),k=null!=(a=h.find(e=>"running"===e.status))?a:null,N=p&&k&&p.id===k.id?p.gates:[],C=N.filter(e=>"running"!==e.status).length,S=Math.max(null!=(l=null==m?void 0:m.plannedGateIds.length)?l:0,N.length),I=k?Date.now()-new Date(k.startedAt).getTime():0;return(0,r.jsxs)("section",{className:"space-y-2 border-b border-border px-3 py-3","data-testid":"verification-onboarding","data-phase":f,children:[(0,r.jsx)(sz,{testId:"verification-onboarding-what",children:u("verification.onboarding.what",{path:b})}),(0,r.jsx)(sz,{testId:"verification-onboarding-how",children:u("verification.onboarding.how")}),null!==x&&(0,r.jsx)(sz,{tone:"warning",testId:"verification-config-error",children:u("verification.onboarding.configError",{message:x})}),(null==m?void 0:m.error)!=null&&(0,r.jsx)(sz,{tone:"warning",testId:"verification-config-invalid",children:u("verification.onboarding.invalid",{path:b,message:m.error})}),"unknown"===f&&(0,r.jsx)(sz,{testId:"verification-onboarding-unknown",children:u("verification.onboarding.loading")}),"no-config"===f&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-no-config",children:[(0,r.jsx)(sz,{children:u("verification.onboarding.noConfig.body",{path:b})}),(0,r.jsx)(sz,{children:u("verification.onboarding.noConfig.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"primary",onClick:v,disabled:d.draftPending,"data-testid":"verification-draft-button",children:u(d.draftPending?"verification.onboarding.noConfig.pending":"verification.onboarding.noConfig.action")}),(0,r.jsxs)("a",{href:sh,target:"_blank",rel:"noreferrer noopener","data-testid":"verification-docs-link",className:"inline-flex items-center gap-1 rounded text-xs font-medium text-accent-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 touch-manipulation",children:[u("verification.onboarding.noConfig.docs"),(0,r.jsx)(si.A,{size:12,"aria-hidden":"true"})]})]}),d.draftFailure&&(0,r.jsx)(sz,{tone:"warning",testId:"verification-draft-failure",children:"conflict"===d.draftFailure.kind?u("verification.onboarding.noConfig.conflict",{path:b}):"empty"===d.draftFailure.kind?u("verification.onboarding.noConfig.empty",{path:b}):u("verification.onboarding.noConfig.error",{message:d.draftFailure.message})})]}),"configured"===f&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-configured",children:[(0,r.jsx)(sz,{children:u("verification.onboarding.configured.body",{path:b,count:null!=(o=null==m?void 0:m.gates.length)?o:0})}),(null==(t=d.draftResult)?void 0:t.created)&&(0,r.jsx)(sz,{testId:"verification-draft-created",children:u("verification.onboarding.noConfig.created",{path:d.draftResult.path,count:d.draftResult.gates.length})}),(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("verification.onboarding.configured.gatesHeading")}),(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-declared-gates",children:(null!=(c=null==m?void 0:m.gates)?c:[]).map(e=>(0,r.jsx)(sO,{gate:e},e.id))}),(0,r.jsx)(sz,{testId:"verification-builtin-gates",children:u("verification.onboarding.configured.builtin",{gates:(function(e){if(null===e)return[];let t=new Set(e.gates.map(e=>e.id));return e.plannedGateIds.filter(e=>!t.has(e))})(m).join(", ")})}),(0,r.jsx)(sz,{testId:"verification-builtin-gates-hint",children:u("verification.onboarding.configured.builtinHint")}),(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"primary",onClick:y,disabled:d.rerunPending,"data-testid":"verification-run-button",children:u(d.rerunPending?"verification.runs.rerunPending":"verification.onboarding.configured.action")})]}),"running"===f&&null!==k&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"verification-onboarding-running",children:[(0,r.jsx)(sz,{testId:"verification-running-progress",children:u("verification.onboarding.running.progress",{done:C,total:S})}),(0,r.jsx)(sz,{testId:"verification-running-elapsed",children:u("verification.onboarding.running.elapsed",{elapsed:(0,sR.C)(I)})}),(0,r.jsx)(sz,{children:u("verification.onboarding.running.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"secondary",onClick:d.refresh,"data-testid":"verification-running-refresh-button",children:u("verification.onboarding.running.action")}),(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"danger",onClick:w,disabled:d.cancelPending,"data-testid":"verification-cancel-button",children:u(d.cancelPending?"verification.runs.cancelPending":"verification.runs.cancel")})]}),(0,r.jsx)(sz,{testId:"verification-cancel-hint",children:u("verification.runs.cancelHint")}),d.cancelSettling&&(0,r.jsx)(sz,{testId:"verification-cancel-settling",children:u("verification.runs.cancelSettling")}),d.cancelFailure&&(0,r.jsx)(sz,{tone:"warning",testId:"verification-cancel-failure",children:"gone"===d.cancelFailure.kind?u("verification.runs.cancelGone"):u("verification.runs.cancelError",{message:d.cancelFailure.message})})]}),"result"===f&&null!==g&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-result",children:[(0,r.jsx)(sz,{testId:"verification-result-body",children:u("verification.onboarding.result.body",{runId:g.id,verdict:u("verification.runStatus.".concat(g.status))})}),(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"secondary",onClick:j,"data-testid":"verification-show-latest-button",children:u("verification.onboarding.result.action")})]})]})}function sB(e){let{state:t}=e,n=(0,i.c)("worktree"),[a,l]=(0,s.useState)(!1),{availableGateIds:o,selectedGateIds:c,failedGateIds:d,rerunPending:u}=t,m=(0,s.useCallback)(()=>l(e=>!e),[]),x=(0,s.useCallback)(()=>t.setGateSelection(null),[t]),f=(0,s.useCallback)(()=>{t.selectFailedGates(),l(!0)},[t]),h=(0,s.useCallback)(()=>{t.rerun()},[t]);if(0===o.length)return null;let p=null!=c?c:o,g=null===c,b=o.filter(e=>d.includes(e));return(0,r.jsxs)("div",{className:"mb-2 rounded-md border border-border bg-surface-2 px-2 py-2","data-testid":"verification-gate-selector","data-selection":g?"all":p.join(","),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:n("verification.selection.heading")}),(0,r.jsx)("button",{type:"button",onClick:m,"aria-expanded":a,"data-testid":"verification-gate-selector-toggle",className:"rounded text-[11px] font-medium text-accent-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 touch-manipulation",children:a?n("verification.selection.close"):n("verification.selection.open")})]}),(0,r.jsx)("p",{className:"mt-0.5 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-selector-summary",children:g?n("verification.selection.all",{count:o.length}):n("verification.selection.partial",{selected:p.length,total:o.length,gates:p.join(", ")})}),a&&(0,r.jsxs)("div",{className:"mt-2 space-y-2","data-testid":"verification-gate-selector-body",children:[(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-gate-checkboxes",children:o.map(e=>{let a="verification-gate-select-".concat(e),s=d.includes(e);return(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsx)(sd.S,{id:a,checked:p.includes(e),onCheckedChange:()=>t.toggleGate(e),"data-testid":a,"aria-label":n("verification.selection.gateLabel",{gateId:e})}),(0,r.jsx)("label",{htmlFor:a,className:"min-w-0 flex-1 cursor-pointer break-all font-mono text-[11px] text-foreground touch-manipulation",children:e}),s&&(0,r.jsx)(sc.E,{variant:"error",className:"flex-shrink-0",children:n("verification.gateStatus.failed")})]},e)})}),(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"primary",onClick:h,disabled:u,"data-testid":"verification-run-selected-button",children:u?n("verification.runs.rerunPending"):g?n("verification.selection.runAll"):n("verification.selection.runSelected",{count:p.length})}),(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.selection.hint")})]}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"secondary",onClick:f,disabled:0===b.length,"data-testid":"verification-failed-only-button",children:n("verification.selection.failedOnly",{count:b.length})}),!g&&(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"ghost",onClick:x,"data-testid":"verification-select-all-button",children:n("verification.selection.selectAll")})]}),0===b.length&&(0,r.jsx)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-failed-only-empty",children:n("verification.selection.failedOnlyEmpty")})]})}function sV(e){let{state:t}=e,n=(0,i.c)("worktree"),{repositoryHistoryOpen:a,repositoryHistory:l,repositoryHistoryLoading:o,repositoryHistoryError:c}=t,d=(0,s.useCallback)(()=>{t.toggleRepositoryHistory()},[t]);return(0,r.jsxs)("div",{className:"mt-2","data-testid":"verification-repository-history",children:[(0,r.jsx)("button",{type:"button",onClick:d,"aria-expanded":a,"data-testid":"verification-repository-history-toggle",className:"rounded text-[11px] font-medium text-accent-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 touch-manipulation",children:n(a?"verification.runs.history.close":"verification.runs.history.open")}),a&&(0,r.jsxs)("div",{className:"mt-1 space-y-1","data-testid":"verification-repository-history-body",children:[(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.runs.history.hint")}),null!==c?(0,r.jsx)("p",{className:"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-[11px] text-warning-foreground","data-testid":"verification-repository-history-error",role:"alert",children:n("verification.runs.history.error",{message:c})}):o&&0===l.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("verification.runs.history.loading")}):0===l.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"verification-repository-history-empty",children:n("verification.runs.history.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-repository-history-runs",children:l.map(e=>(0,r.jsx)(sH,{run:e},e.id))})]})]})}function sH(e){let{run:t}=e,n=(0,i.c)("worktree"),a=t.status,s=t.gates.filter(e=>sf.includes(e.status)).map(e=>e.gateId);return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 rounded-md border border-border bg-surface px-2 py-1.5","data-testid":"verification-history-run-".concat(t.id),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(sc.E,{variant:sm[a],className:"flex-shrink-0",children:n("verification.runStatus.".concat(a))}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",children:t.worktreeId})]}),(0,r.jsxs)("span",{className:"flex flex-wrap gap-x-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)("span",{children:n("verification.runs.runLabel",{runId:t.id})}),(0,r.jsx)("span",{children:sL(t.startedAt)})]}),s.length>0&&(0,r.jsx)("span",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.runs.history.failingGates",{gates:s.join(", ")})})]})}function sU(e){let{gate:t,log:n,onClose:a}=e,l=(0,i.c)("worktree"),[o,c]=(0,s.useState)("idle"),d=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]);let u=""===n?0:n.replace(/\n+$/,"").split("\n").length,m=""!==n.trim(),x=(0,s.useCallback)(()=>{(async()=>{try{await (0,te.l)(n),c("done")}catch(e){c("failed")}null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c("idle"),2e3)})()},[n]);return(0,r.jsx)(tF.a,{isOpen:!0,onClose:a,size:"xl",title:l("verification.gates.fullLogTitle",{gateId:t.gateId,runId:t.runId}),children:(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-gate-full-log-".concat(t.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)(eq.$,{type:"button",size:"sm",variant:"secondary",onClick:x,disabled:!m,"data-testid":"verification-gate-log-copy-button",children:[(0,r.jsx)(e0.A,{size:12,"aria-hidden":"true",className:"mr-1"}),l("done"===o?"verification.gates.copied":"failed"===o?"verification.gates.copyFailed":"verification.gates.copyLog")]}),(0,r.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground","data-testid":"verification-gate-log-size",children:l("verification.gates.fullLogSize",{lines:u})})]}),(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:l("verification.gates.fullLogStored")}),""===n?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:l("verification.gates.noLog")}):(0,r.jsx)("pre",{className:"max-h-[60vh] overflow-auto rounded bg-terminal-surface p-2 font-mono text-[11px] leading-relaxed text-terminal-foreground",children:n})]})})}function sK(e){let{run:t,selected:n,onSelect:a}=e,s=(0,i.c)("worktree"),l=s("verification.runStatus.".concat(t.status)),o=s("verification.runStatusGloss.".concat(t.status)),c=sT[t.status];return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>a(t.id),"aria-current":n?"true":void 0,"aria-label":s("verification.runs.select",{runId:t.id,verdict:l,gloss:o}),title:o,"data-testid":"verification-run-".concat(t.id),className:"flex w-full flex-col gap-0.5 rounded-md border px-2 py-2 text-left text-xs transition-colors touch-manipulation focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(n?"border-accent-500 bg-accent-50 dark:bg-accent-900/30":"border-border bg-surface hover:bg-muted"),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(sc.E,{variant:sm[t.status],className:"flex-shrink-0",children:l}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:sL(t.startedAt)})]}),(0,r.jsxs)("span",{className:"flex flex-wrap gap-x-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)("span",{children:s("verification.runs.runLabel",{runId:t.id})}),(0,r.jsx)("span",{children:s("verification.runs.trigger",{trigger:t.trigger})}),null!==c&&(0,r.jsx)("span",{children:s("verification.runs.exitCode",{code:c})})]})]})})}function sW(){let e=(0,i.c)("worktree"),t=sE.map(t=>{var n;return e("verification.runs.cliLegendItem",{label:e("verification.runStatus.".concat(t)),code:null!=(n=sT[t])?n:0})}).join(" / ");return(0,r.jsx)("p",{className:"mb-2 break-words text-[11px] text-muted-foreground","data-testid":"verification-cli-exit-legend",children:e("verification.runs.cliLegend",{items:t})})}function sq(e){let{run:t,plannedGateIds:n}=e,a=(0,i.c)("worktree"),s=sT[t.status],l=t.gates.filter(e=>"skipped"===e.status),o=new Set(t.gates.map(e=>e.gateId)),c=n.filter(e=>!o.has(e));return(0,r.jsxs)("div",{className:"mb-2 space-y-1 rounded-md border border-border bg-surface-2 px-2 py-2","data-testid":"verification-run-verdict",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:a("verification.gates.verdictHeading")}),(0,r.jsx)(sc.E,{variant:sm[t.status],className:"flex-shrink-0",children:a("verification.runStatus.".concat(t.status))}),null!==s&&(0,r.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:a("verification.runs.exitCode",{code:s})})]}),(0,r.jsx)("p",{className:"break-words text-xs text-muted-foreground","data-testid":"verification-run-verdict-gloss",children:a("verification.runStatusGloss.".concat(t.status))}),c.length>0&&(0,r.jsx)("p",{className:"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground","data-testid":"verification-run-partial",children:a("verification.runs.partial",{ran:o.size,total:n.length,gates:c.join(", ")})}),l.length>0&&(0,r.jsxs)("div",{className:"space-y-0.5 pt-1","data-testid":"verification-run-skip-reasons",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:a("verification.gates.skipHeading")}),(0,r.jsx)("ul",{className:"space-y-0.5",children:l.map(e=>(0,r.jsx)("li",{className:"break-words text-xs text-muted-foreground",children:a("verification.gates.skipReasonFor",{gateId:e.gateId,reason:a("verification.gates.skipReason.".concat(function(e){let t=null!=e?e:"";return t.includes("skipped: worktreePath is the server process working directory and options.skipInPrimaryCheckout is true.")?"primaryCheckout":t.includes("skipped: the work-evidence gate did not pass.")?"workEvidence":t.includes("skipped: the verification run was cancelled.")?"cancelled":t.includes(sM.mutex)?"mutex":t.includes(sM.detachedContract)?"detachedContract":t.includes(sM.noContract)?"noContract":t.includes(sM.notRequired)?"notRequired":"unknown"}(e.logTail)))})},e.id))})]})]})}function s$(e){var t,n;let{gate:a}=e,l=(0,i.c)("worktree"),o=sf.includes(a.status),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),x=(0,s.useCallback)(()=>m(!1),[]),f=null!=c?c:o,h=(0,t9.aJ)(null!=(t=a.logTail)?t:""),p=function(e,t){let n=(null!=e?e:"").replace(/\n+$/,"");if(""===n)return{lines:[],omitted:0};let a=n.split("\n");return a.length<=40?{lines:a,omitted:0}:{lines:a.slice(-40),omitted:a.length-t}}(h,40),g=function(e){if(null==e||!Number.isFinite(e))return null;if(e<1e3)return"".concat(Math.max(0,Math.round(e)),"ms");let t=e/1e3;return t<10?"".concat(t.toFixed(1),"s"):"".concat(Math.round(t),"s")}(a.durationMs),b=null!=(n=sA[a.gateId])?n:null;return(0,r.jsxs)("li",{className:"rounded-md border border-border bg-surface p-2","data-testid":"verification-gate-".concat(a.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(sc.E,{variant:sx[a.status],className:"flex-shrink-0",children:l("verification.gateStatus.".concat(a.status))}),(0,r.jsx)("span",{className:"min-w-0 break-all font-mono text-xs font-medium text-foreground",children:a.gateId}),"contract"===a.source&&(0,r.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground",title:l("verification.gates.contractSourceHint"),children:l("verification.gates.contractSource")}),null!==b&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:l("verification.gates.builtinBadge")})]}),null!==b&&(0,r.jsx)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-about-".concat(a.gateId),children:l("verification.gates.builtin.".concat(b))}),"skipped"===a.status&&(0,r.jsxs)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-skipped-".concat(a.gateId),children:[l("verification.gateStatus.skipped")," — ",l("verification.gateStatusGloss.skipped")]}),(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground",children:[null!==a.exitCode&&void 0!==a.exitCode&&(0,r.jsx)("span",{children:l("verification.gates.exitCode",{code:a.exitCode})}),g&&(0,r.jsx)("span",{children:l("verification.gates.duration",{duration:g})}),a.command&&(0,r.jsx)("span",{className:"break-all",children:a.command})]}),(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>d(!f),"aria-expanded":f,"data-testid":"verification-gate-log-toggle-".concat(a.gateId),className:"rounded text-[11px] font-medium text-accent-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 touch-manipulation",children:l(f?"verification.gates.hideLog":"verification.gates.showLog")}),""!==h&&(0,r.jsx)("button",{type:"button",onClick:()=>m(!0),"data-testid":"verification-gate-full-log-button-".concat(a.gateId),className:"rounded text-[11px] font-medium text-accent-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 touch-manipulation",children:l("verification.gates.showFullLog")})]}),u&&(0,r.jsx)(sU,{gate:a,log:h,onClose:x}),f&&(0,r.jsx)("div",{className:"mt-1","data-testid":"verification-gate-log-".concat(a.gateId),children:0===p.lines.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:l("verification.gates.noLog")}):(0,r.jsxs)(r.Fragment,{children:[p.omitted>0&&(0,r.jsx)("p",{className:"mb-1 text-[11px] text-muted-foreground",children:l("verification.gates.logOmitted",{count:p.omitted,runId:a.runId})}),(0,r.jsx)("pre",{className:"max-h-64 overflow-auto rounded bg-terminal-surface p-2 font-mono text-[11px] leading-relaxed text-terminal-foreground",children:p.lines.join("\n")})]})})]})}let sG=(0,s.memo)(function(e){var t,n;let{state:a,className:l=""}=e,o=(0,i.c)("worktree"),{worktreeId:c,task:d,runs:u,selectedRunId:m,selectedRun:x,loading:f,error:h,detailError:p,detailLoading:g,rerunPending:b,rerunFailure:v,cancelFailure:y,canLoadMore:j,selectRun:w,refresh:k,rerun:N,loadMore:C}=a,S=(0,s.useCallback)(()=>{N()},[N]);return(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-y-auto bg-surface ".concat(l).trim(),"data-testid":"verification-pane",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(so.A,{size:16,"aria-hidden":"true",className:"flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("h2",{className:"truncate text-sm font-semibold text-foreground",children:o("verification.title")})]}),(0,r.jsx)("button",{type:"button",onClick:k,"aria-label":o("verification.refresh"),title:o("verification.refresh"),"data-testid":"verification-refresh-button",className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:(0,r.jsx)(aa.A,{size:14,"aria-hidden":"true"})})]}),h&&(0,r.jsx)("p",{className:"border-b border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground","data-testid":"verification-error",role:"alert",children:o("verification.loadError",{message:h})}),f?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"verification-loading",children:o("verification.loading")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s_,{state:a}),(0,r.jsx)(sP,{heading:o("verification.contract.heading"),testId:"verification-contract-section",children:d?(0,r.jsx)(sF,{task:d}):(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-contract-empty",children:o("verification.contract.empty")})}),(0,r.jsxs)(sP,{heading:o("verification.runs.heading"),testId:"verification-runs-section",action:(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"secondary",onClick:S,disabled:b,"data-testid":"verification-rerun-button",children:o(b?"verification.runs.rerunPending":"verification.runs.rerun")}),children:[v&&(0,r.jsx)("p",{className:"mb-2 rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground","data-testid":"verification-rerun-failure",role:"alert",children:"conflict"===v.kind?null!==v.runningRunId?o("verification.runs.rerunConflict",{runId:v.runningRunId}):o("verification.runs.rerunConflictUnknown"):o("verification.runs.rerunError",{message:v.message})}),y&&(0,r.jsx)("p",{className:"mb-2 rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground","data-testid":"verification-runs-cancel-failure",role:"alert",children:"gone"===y.kind?o("verification.runs.cancelGone"):o("verification.runs.cancelError",{message:y.message})}),(0,r.jsx)(sB,{state:a}),(0,r.jsx)(sW,{}),0===u.length?(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-runs-empty",children:o("verification.runs.empty",{worktreeId:c})}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-runs",children:u.map(e=>(0,r.jsx)(sK,{run:e,selected:e.id===m,onSelect:w},e.id))}),j&&(0,r.jsx)(eq.$,{type:"button",size:"sm",variant:"ghost",onClick:C,className:"mt-1","data-testid":"verification-load-more-button",children:o("verification.runs.loadMore",{count:10})}),(0,r.jsx)(sV,{state:a})]}),null!==m&&(0,r.jsx)(sP,{heading:o("verification.gates.heading",{runId:m}),testId:"verification-gates-section",children:null!==p?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-error",role:"alert",children:"not-found"===p?o("verification.gates.notFound"):o("verification.gates.loadError",{message:p})}):null===x?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-loading",children:o(g?"verification.gates.loading":"verification.gates.empty")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sq,{run:x,plannedGateIds:null!=(n=null==(t=a.config)?void 0:t.plannedGateIds)?n:[]}),0===x.gates.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-empty",children:o("verification.gates.empty")}):(0,r.jsx)("ul",{className:"space-y-1.5","data-testid":"verification-gates",children:x.gates.map(e=>(0,r.jsx)(s$,{gate:e},e.id))}),x.gates.some(e=>"contract"===e.source)&&(0,r.jsx)("p",{className:"mt-2 break-words text-[11px] text-muted-foreground","data-testid":"verification-contract-source-hint",children:o("verification.gates.contractSourceHint")})]})})]})]})});var sJ=n(70532),sY=n(46046),sQ=n(47972),sX=n(5590),sZ=n(25840);class s0 extends Error{constructor(e,t,n=[]){super(t),this.name="EnvApiError",this.code=e,this.issues=n}}async function s1(e,t){var n,a,r,s,l,i;let o=await e.json().catch(()=>null);return new s0(null!=(s=null==o||null==(n=o.error)?void 0:n.code)?s:"HTTP_".concat(e.status),null!=(l=null==o||null==(a=o.error)?void 0:a.message)?l:t,null!=(i=null==o||null==(r=o.error)?void 0:r.issues)?i:[])}function s2(e,t){let n="/api/worktrees/".concat(encodeURIComponent(e),"/env");return void 0===t?n:"".concat(n,"?file=").concat(encodeURIComponent(t))}async function s4(e,t){var n,a;let r=await fetch(s2(e,t),{cache:"no-store"});if(!r.ok)throw await s1(r,"Failed to load env files");let s=await r.json();return{files:null!=(n=s.files)?n:[],selected:null!=(a=s.selected)?a:null}}async function s5(e,t,n){var a;let r=await fetch(s2(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:t,content:n})});if(!r.ok)throw await s1(r,"Failed to save env file");let s=await r.json();return{file:s.file,issues:null!=(a=s.issues)?a:[]}}let s3=/^[A-Za-z_][A-Za-z0-9_]*$/;function s6(e){return e.split(/\r\n|\n|\r/)}function s8(e,t,n){for(let a=n;a<e.length;a+=1){if('"'===t&&"\\"===e[a]){a+=1;continue}if(e[a]===t)return a}return -1}function s9(e){let t=s6(e),n=[],a=[],r=new Map;for(let e=0;e<t.length;e+=1){let s,l=e+1,i=t[e].trim();if(""===i||i.startsWith("#"))continue;let o=/^export\s+/.test(i),c=o?i.replace(/^export\s+/,""):i,d=c.indexOf("=");if(-1===d){a.push({line:l,code:"invalid-syntax",severity:"error"});continue}let u=c.slice(0,d).trim();if(!s3.test(u)){a.push({line:l,code:"invalid-key",severity:"error",...u.length>0&&u.length<=64?{key:u}:{}});continue}let m=c.slice(d+1).replace(/^[ \t]+/,""),x=null,f=l;if(m.startsWith('"')||m.startsWith("'")){x=m[0];let n=m.slice(1),r=s8(n,x,0);for(;-1===r&&e+1<t.length;)e+=1,f=e+1,n+="\n".concat(t[e]),r=s8(n,x,0);if(-1===r){a.push({line:l,code:"unterminated-quote",severity:"error",key:u});continue}let i=n.slice(0,r);s='"'===x?function(e){let t="";for(let n=0;n<e.length;n+=1){let a=e[n];if("\\"!==a||n===e.length-1){t+=a;continue}let r=e[n+1];switch(n+=1,r){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+=" ";break;case"\\":t+="\\";break;case'"':t+='"';break;default:t+="\\".concat(r)}}return t}(i):i}else s=(function(e){let t=/\s#/.exec(e);return t?e.slice(0,t.index):e})(m).replace(/[ \t]+$/,"");void 0!==r.get(u)&&a.push({line:l,code:"duplicate-key",severity:"warning",key:u}),r.set(u,l),n.push({key:u,value:s,line:l,endLine:f,exported:o,quote:x})}return{entries:n,issues:a}}let s7=/[\s#'"$`\\]/;function le(e){if(!s7.test(e))return e;let t=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t");return'"'.concat(t,'"')}function lt(e,t,n){let a=s6(e),r=new Map(t.map(e=>[e.line,e])),s=new Map,l=[];for(let e of n)null!==e.sourceLine&&r.has(e.sourceLine)?s.set(e.sourceLine,e):l.push(e);let i=[],o=0;for(let e=0;e<a.length;e+=1){let t=e+1;if(t<=o)continue;let n=r.get(t);if(!n){i.push(a[e]);continue}o=n.endLine;let l=s.get(t);l&&i.push("".concat(n.exported?"export ":"").concat(l.key,"=").concat(le(l.value)))}for(let e of(i.length>0&&""===i[i.length-1]&&i.pop(),l))i.push("".concat(e.key,"=").concat(le(e.value)));return 0===i.length?"":"".concat(i.join("\n"),"\n")}let ln=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/,la=0;function lr(){return la+=1,"env-row-".concat(la)}function ls(e){return e.map(e=>({id:lr(),key:e.key,value:e.value,sourceLine:e.line}))}let ll="••••••••";function li(e){return 0===e.length?"":ll}let lo="flex-shrink-0 px-2 opacity-80 transition-opacity hover:opacity-100 [@media(hover:none)]:opacity-100",lc={"invalid-syntax":"envManager.issues.invalidSyntax","invalid-key":"envManager.issues.invalidKey","unterminated-quote":"envManager.issues.unterminatedQuote","duplicate-key":"envManager.issues.duplicateKey","control-character":"envManager.issues.controlCharacter","too-large":"envManager.issues.tooLarge","too-many-entries":"envManager.issues.tooManyEntries"},ld=(0,s.memo)(function(e){let{worktreeId:t,className:n=""}=e,a=(0,i.c)("worktree"),l=function(e){var t;let[n,a]=(0,s.useState)([]),[r,l]=(0,s.useState)(".env"),[i,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(!0),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)("kv"),[v,y]=(0,s.useState)([]),[j,w]=(0,s.useState)(""),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)([]),[I,T]=(0,s.useState)(""),[E,A]=(0,s.useState)(new Set),[M,R]=(0,s.useState)(!1),[L,P]=(0,s.useState)(0),D=(0,s.useRef)(0);(0,s.useEffect)(()=>{let t=!1,n=D.current+1;return D.current=n,d(!0),f(null),p(!1),s4(e,r).then(e=>{var r,s;if(t||D.current!==n)return;a(e.files);let l=e.selected;o(l);let i=null!=(r=null==l?void 0:l.content)?r:"",c=null!=(s=null==l?void 0:l.entries)?s:[];T(i),N(i),S(c),y(ls(c)),w(i),A(new Set),R(!1)}).catch(e=>{var a,r;if(t||D.current!==n)return;let s=e instanceof s0?e:null;f({code:null!=(a=null==s?void 0:s.code)?a:"UNKNOWN",message:null!=(r=null==s?void 0:s.message)?r:e instanceof Error?e.message:"Failed to load"}),o(null)}).finally(()=>{t||D.current!==n||d(!1)}),()=>{t=!0}},[e,r,L]);let F=(0,s.useMemo)(()=>"raw"===g?j:lt(k,C,v),[g,j,k,C,v]),O=(0,s.useMemo)(()=>(function(e){let t=[];if("string"!=typeof e)return{valid:!1,issues:[{line:null,code:"invalid-syntax",severity:"error"}],entries:[]};if(new TextEncoder().encode(e).length>262144)return{valid:!1,issues:[{line:null,code:"too-large",severity:"error"}],entries:[]};let n=e.split(/\r\n|\n|\r/);for(let e=0;e<n.length;e+=1)ln.test(n[e])&&t.push({line:e+1,code:"control-character",severity:"error"});let a=s9(e);return t.push(...a.issues),a.entries.length>1e3&&t.push({line:null,code:"too-many-entries",severity:"error"}),t.sort((e,t)=>{var n,a;return(null!=(n=e.line)?n:0)-(null!=(a=t.line)?a:0)}),{valid:!t.some(e=>"error"===e.severity),issues:t,entries:a.entries}})(F),[F]),z=(0,s.useMemo)(()=>"raw"===g?j!==I:k!==I||v.length!==C.length||v.some((e,t)=>{var n,a;return e.key!==(null==(n=C[t])?void 0:n.key)||e.value!==(null==(a=C[t])?void 0:a.value)}),[g,j,I,k,v,C]),_=(0,s.useCallback)(e=>{if(e!==g){if("raw"===e)w(lt(k,C,v));else{let e=s9(j);N(j),S(e.entries),y(ls(e.entries))}b(e)}},[g,k,C,v,j]),B=(0,s.useCallback)(e=>{l(e),b("kv")},[]),V=(0,s.useCallback)(e=>{w(e),p(!1)},[]),H=(0,s.useCallback)((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n)),p(!1)},[]),U=(0,s.useCallback)(e=>{var t,n;let a={id:lr(),key:null!=(t=null==e?void 0:e.key)?t:"",value:null!=(n=null==e?void 0:e.value)?n:"",sourceLine:null};y(e=>[...e,a]),p(!1),(null==e?void 0:e.key)&&A(t=>new Set([...t,e.key]))},[]),K=(0,s.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e)),p(!1)},[]),W=(0,s.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),q=(0,s.useCallback)(()=>R(e=>!e),[]),$=(0,s.useCallback)(()=>{A(new Set(v.map(e=>e.key)))},[v]),G=(0,s.useCallback)(()=>A(new Set),[]),J=(0,s.useCallback)(()=>P(e=>e+1),[]),Y=(0,s.useCallback)(()=>{O.valid&&!u&&(m(!0),f(null),s5(e,r,F).then(()=>{p(!0),P(e=>e+1)}).catch(e=>{var t,n;let a=e instanceof s0?e:null;f({code:null!=(t=null==a?void 0:a.code)?t:"UNKNOWN",message:null!=(n=null==a?void 0:a.message)?n:e instanceof Error?e.message:"Failed to save"})}).finally(()=>m(!1)))},[O.valid,u,e,r,F]);return{files:n,selectedFile:r,detail:i,loading:c,saving:u,error:x,saved:h,mode:g,rows:v,rawDraft:j,revealedKeys:E,rawRevealed:M,suggestions:null!=(t=null==i?void 0:i.suggestions)?t:[],issues:O.issues,canSave:O.valid,dirty:z,selectFile:B,setMode:_,setRawDraft:V,updateRow:H,addRow:U,removeRow:K,toggleReveal:W,toggleRawReveal:q,revealAll:$,hideAll:G,reload:J,save:Y}}(t),{mode:o,rows:d,revealedKeys:u,rawRevealed:m}=l,x=(0,s.useMemo)(()=>l.issues.filter(e=>"error"===e.severity),[l.issues]),f=(0,s.useMemo)(()=>l.issues.filter(e=>"warning"===e.severity),[l.issues]),h="raw"===o?m:d.length>0&&d.every(e=>u.has(e.key)),p=(0,s.useCallback)(()=>{if("raw"===o)return void l.toggleRawReveal();h?l.hideAll():l.revealAll()},[o,h,l]),g=(0,s.useMemo)(()=>"raw"!==o||m?"":function(e,t){let n=e.split(/\r\n|\n|\r/),a=new Map,r=new Set;for(let e of t){a.set(e.line,e);for(let t=e.line+1;t<=e.endLine;t+=1)r.add(t)}let s=[];for(let e=0;e<n.length;e+=1){let t=e+1;if(r.has(t))continue;let l=a.get(t);if(!l){s.push(n[e]);continue}s.push("".concat(l.exported?"export ":"").concat(l.key,"=").concat(li(l.value)))}return s.join("\n")}(l.rawDraft,s9(l.rawDraft).entries),[o,m,l.rawDraft]),b=(0,s.useCallback)((e,t)=>{var n,s,l;return(0,r.jsx)("li",{children:a(lc[e.code],{line:null!=(n=e.line)?n:0,key:null!=(s=e.key)?s:""})},"".concat(e.code,"-").concat(null!=(l=e.line)?l:"file","-").concat(t))},[a]);return(0,r.jsxs)("div",{"data-testid":"env-manager-pane",role:"region","aria-label":a("envManager.title"),className:"flex flex-col h-full min-h-0 bg-background ".concat(n).trim(),children:[(0,r.jsxs)("div",{className:"flex-shrink-0 border-b border-border bg-surface dark:bg-surface-2 p-2 space-y-2",children:[(0,r.jsx)("div",{role:"group","aria-label":a("envManager.filePickerLabel"),className:"flex gap-1 overflow-x-auto scrollbar-hide",children:l.files.map(e=>(0,r.jsxs)(eq.$,{size:"sm",variant:e.name===l.selectedFile?"primary":"ghost",onClick:()=>l.selectFile(e.name),"aria-pressed":e.name===l.selectedFile,"data-testid":"env-file-".concat(e.name),className:"flex-shrink-0 whitespace-nowrap min-h-[44px] gap-1.5 font-mono text-xs",children:[e.name,!e.exists&&(0,r.jsx)(sc.E,{variant:"gray",children:a("envManager.notCreated")}),e.isExample&&(0,r.jsx)(sc.E,{variant:"info",children:a("envManager.templateBadge")})]},e.name))}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("div",{role:"group","aria-label":a("envManager.viewModeLabel"),className:"flex gap-1",children:[(0,r.jsx)(eq.$,{size:"sm",variant:"kv"===o?"primary":"ghost",onClick:()=>l.setMode("kv"),"aria-pressed":"kv"===o,"data-testid":"env-mode-kv",className:"min-h-[44px]",children:a("envManager.viewKeyValue")}),(0,r.jsx)(eq.$,{size:"sm",variant:"raw"===o?"primary":"ghost",onClick:()=>l.setMode("raw"),"aria-pressed":"raw"===o,"data-testid":"env-mode-raw",className:"min-h-[44px]",children:a("envManager.viewRaw")})]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsxs)(eq.$,{size:"sm",variant:"ghost",onClick:p,"data-testid":"env-toggle-all","aria-pressed":h,className:"min-h-[44px] gap-1.5",children:[h?(0,r.jsx)(sJ.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(tn.A,{size:16,"aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:h?a("envManager.hideAll"):a("envManager.revealAll")})]}),(0,r.jsx)(eq.$,{size:"sm",variant:"ghost",onClick:l.reload,"data-testid":"env-reload","aria-label":a("envManager.reload"),className:"min-h-[44px]",children:(0,r.jsx)(aa.A,{size:16,"aria-hidden":"true"})}),(0,r.jsxs)(eq.$,{size:"sm",variant:"primary",onClick:l.save,loading:l.saving,disabled:!l.canSave||!l.dirty,"data-testid":"env-save",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(sY.A,{size:16,"aria-hidden":"true"}),a("envManager.save")]})]})]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-3",children:[(0,r.jsx)("p",{"data-testid":"env-description",className:"text-xs text-muted-foreground",children:a("envManager.description")}),l.loading&&(0,r.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-muted-foreground",children:[(0,r.jsx)(c.y,{size:"sm"}),a("envManager.loading")]}),l.error&&(0,r.jsx)("div",{role:"alert","data-testid":"env-error",className:"rounded-md border border-danger-border bg-danger-subtle p-2 text-sm text-danger-foreground",children:a("envManager.loadError")}),!l.loading&&l.detail&&!l.detail.exists&&(0,r.jsx)("p",{"data-testid":"env-not-created",className:"rounded-md border border-border bg-muted p-2 text-xs text-muted-foreground",children:a("envManager.notCreatedHint",{file:l.selectedFile})}),l.saved&&!l.dirty&&(0,r.jsx)("p",{"data-testid":"env-saved",className:"text-xs text-success-foreground",children:a("envManager.saved")}),x.length>0&&(0,r.jsxs)("div",{role:"alert","data-testid":"env-errors",className:"rounded-md border border-danger-border bg-danger-subtle p-2 text-xs text-danger-foreground",children:[(0,r.jsxs)("p",{className:"flex items-center gap-1.5 font-medium",children:[(0,r.jsx)(rg.A,{size:14,"aria-hidden":"true"}),a("envManager.validationFailed")]}),(0,r.jsx)("ul",{className:"mt-1 list-disc pl-5 space-y-0.5",children:x.map(b)})]}),f.length>0&&(0,r.jsx)("div",{"data-testid":"env-warnings",className:"rounded-md border border-warning-border bg-warning-subtle p-2 text-xs text-warning-foreground",children:(0,r.jsx)("ul",{className:"list-disc pl-5 space-y-0.5",children:f.map(b)})}),!l.loading&&"kv"===o&&(0,r.jsxs)("div",{"data-testid":"env-kv-view",className:"space-y-2",children:[0===d.length&&(0,r.jsx)("p",{"data-testid":"env-empty",className:"px-1 py-4 text-center text-sm text-muted-foreground",children:a("envManager.empty")}),d.map(e=>{let t=u.has(e.key);return(0,r.jsxs)("div",{"data-testid":"env-row","data-env-key":e.key,className:"flex flex-col gap-1 rounded-md border border-border bg-surface dark:bg-surface-2 p-2 sm:flex-row sm:items-center sm:gap-2",children:[(0,r.jsx)(sX.p,{inputSize:"sm",value:e.key,onChange:t=>l.updateRow(e.id,{key:t.target.value}),"aria-label":a("envManager.keyLabel"),spellCheck:!1,autoComplete:"off","data-testid":"env-row-key",className:"font-mono text-xs sm:w-2/5"}),(0,r.jsxs)("div",{className:"flex flex-1 items-center gap-1",children:[(0,r.jsx)(sX.p,{inputSize:"sm",readOnly:!t,value:t?e.value:li(e.value),onChange:t=>l.updateRow(e.id,{value:t.target.value}),"aria-label":a("envManager.valueLabel",{key:e.key}),spellCheck:!1,autoComplete:"off","data-testid":"env-row-value","data-masked":t?"false":"true",className:"flex-1 font-mono text-xs"}),(0,r.jsx)(eq.$,{size:"sm",variant:"ghost",onClick:()=>l.toggleReveal(e.key),"aria-label":t?a("envManager.hideValue",{key:e.key}):a("envManager.showValue",{key:e.key}),"aria-pressed":t,"data-testid":"env-row-reveal",className:"".concat(lo," min-h-[44px]"),children:t?(0,r.jsx)(sJ.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(tn.A,{size:16,"aria-hidden":"true"})}),(0,r.jsx)(eq.$,{size:"sm",variant:"ghost",onClick:()=>l.removeRow(e.id),"aria-label":a("envManager.removeRow",{key:e.key}),"data-testid":"env-row-remove",className:"".concat(lo," min-h-[44px] text-danger"),children:(0,r.jsx)(nW.A,{size:16,"aria-hidden":"true"})})]})]},e.id)}),(0,r.jsxs)(eq.$,{size:"sm",variant:"secondary",onClick:()=>l.addRow(),"data-testid":"env-add-row",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(rk.A,{size:16,"aria-hidden":"true"}),a("envManager.addRow")]}),l.suggestions.length>0&&(0,r.jsxs)(sQ.Zp,{"data-testid":"env-suggestions",className:"mt-3",children:[(0,r.jsxs)(sQ.aR,{children:[(0,r.jsx)(sQ.ZB,{className:"text-sm",children:a("envManager.suggestionsTitle")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("envManager.suggestionsHint")})]}),(0,r.jsx)(sQ.Wu,{className:"flex flex-wrap gap-2",children:l.suggestions.map(e=>(0,r.jsxs)(eq.$,{size:"sm",variant:"secondary",onClick:()=>l.addRow({key:e.key,value:e.value}),"data-testid":"env-suggestion-".concat(e.key),className:"min-h-[44px] gap-1.5 font-mono text-xs",children:[(0,r.jsx)(rk.A,{size:14,"aria-hidden":"true"}),e.key,(0,r.jsx)("span",{className:"font-sans text-muted-foreground",children:e.source})]},"".concat(e.source,":").concat(e.key)))})]})]}),!l.loading&&"raw"===o&&(0,r.jsx)("div",{"data-testid":"env-raw-view",className:"space-y-2",children:m?(0,r.jsx)(sZ.T,{value:l.rawDraft,onChange:e=>l.setRawDraft(e.target.value),"aria-label":a("envManager.rawLabel"),spellCheck:!1,"data-testid":"env-raw-editor",className:"min-h-[240px] font-mono text-xs"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sZ.T,{readOnly:!0,value:g,"aria-label":a("envManager.rawMaskedLabel"),spellCheck:!1,"data-testid":"env-raw-masked",className:"min-h-[240px] font-mono text-xs"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("envManager.rawMaskedHint",{mask:ll})})]})})]})]})}),lu=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"},{id:"timer",labelKey:"timerTab"},{id:"todo",labelKey:"todoTab"},{id:"skills",labelKey:"skillsTab"},{id:"verification",labelKey:"verificationTab"},{id:"env",labelKey:"envTab"}],lm=(0,s.memo)(function(e){var t,n;let{worktreeId:a,className:l="",selectedAgents:o,onSelectedAgentsChange:c,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:f,availableAgents:h,persistToServer:p,onInsertToMessage:g,useInstanceManagement:b=!1,instances:v,onInstancesChange:y,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,composerTargetInstanceId:N,verification:C,requestedSubTab:S}=e,I=(0,i.c)("schedule"),[T,E]=(0,s.useState)(null!=(t=null==S?void 0:S.tab)?t:"notes"),A=(0,s.useRef)(null!=(n=null==S?void 0:S.token)?n:null);(0,s.useEffect)(()=>{S&&S.token!==A.current&&(A.current=S.token,E(S.tab))},[S]);let M=(0,s.useCallback)(e=>{E(e)},[]),R=(0,s.useRef)({});return(0,s.useEffect)(()=>{var e,t;null==(t=R.current[T])||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest",inline:"nearest"})},[T]),(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(l),children:[(0,r.jsx)("div",{className:"flex overflow-x-auto scrollbar-hide border-b border-border bg-surface dark:bg-surface-2 flex-shrink-0",children:lu.map(e=>(0,r.jsx)("button",{type:"button",ref:t=>{R.current[e.id]=t},onClick:()=>M(e.id),className:"flex-shrink-0 whitespace-nowrap px-3 py-2 text-sm font-medium transition-colors ".concat(T===e.id?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground hover:bg-muted"),children:I(e.labelKey)},e.id))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===T&&(0,r.jsx)(av,{worktreeId:a,className:"h-full",onInsertToMessage:g}),"logs"===T&&(0,r.jsx)(ri,{worktreeId:a,className:"h-full",onInsertToMessage:g,instances:v}),"agent"===T&&(b&&v&&y&&j&&w?(0,r.jsx)("div",{className:"h-full overflow-y-auto",children:(0,r.jsx)(rO,{worktreeId:a,instances:v,onInstancesChange:y,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,composerTargetInstanceId:N})}):(0,r.jsx)(rx,{worktreeId:a,selectedAgents:o,onSelectedAgentsChange:c,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:f,availableAgents:h,persistToServer:p})),"timer"===T&&(0,r.jsx)(rW,{worktreeId:a,instances:v,selectedAgents:o}),"todo"===T&&(0,r.jsx)(aC,{worktreeId:a,className:"h-full"}),"skills"===T&&(0,r.jsx)(sl,{worktreeId:a,className:"h-full"}),"verification"===T&&(0,r.jsx)(sG,{state:C,className:"h-full"}),"env"===T&&(0,r.jsx)(ld,{worktreeId:a,className:"h-full"})]})]})});var lx=n(2317);let lf=["status","changes","history","advanced"],lh="commandmate:gitPane:",lp={activeTab:"".concat(lh,"activeTab"),historyOpen:"".concat(lh,"historyOpen"),advancedOpen:"".concat(lh,"advancedOpen")};function lg(e){return"string"==typeof e&&lf.includes(e)}let lb=e=>"boolean"==typeof e,lv=s.useLayoutEffect;function ly(e,t,n){return Math.max(8,Math.min(e,n-t-8))}let lj=(0,s.memo)(function(e){var t,n;let{branches:a,busy:l,actionError:o,hasRunningSession:c,isMobile:u,onCheckout:m}=e,x=(0,i.c)("worktree"),f=(0,i.c)("common"),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(!1),j=(0,s.useRef)(null),w=(0,s.useRef)(null),[k,N]=(0,s.useState)(null),C=a.filter(e=>!e.isCurrent),S=(0,s.useCallback)(()=>{let e=j.current,t=w.current;if(!e||!t)return;let n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),r=window.innerHeight-n.bottom,s=n.top;N({top:ly(r<a.height+4+8&&s>r?n.top-a.height-4:n.bottom+4,a.height,window.innerHeight),left:ly(n.left,a.width,window.innerWidth)})},[]);lv(()=>h?(S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}):void N(null),[h,C.length,S]);let I=(0,s.useCallback)(e=>{y(!1),b({...e}),p(!1)},[]),T=(0,s.useCallback)(()=>{g&&(m(g,v),b(null))},[g,v,m]);return(0,r.jsxs)("div",{className:"relative",ref:j,"data-testid":"branch-checkout-dropdown",children:[(0,r.jsxs)(d.$n,{variant:"ghost",type:"button",onClick:()=>p(e=>!e),disabled:l||0===C.length,className:"flex items-center gap-1 px-2 py-1 text-xs rounded border border-input text-accent-700 dark:text-accent-300 hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-checkout-dropdown-toggle","aria-haspopup":"menu","aria-expanded":h,"aria-label":x("git.checkout.ariaLabel"),children:[x("git.checkout.action"),(0,r.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),h&&"undefined"!=typeof document&&(0,nB.createPortal)((0,r.jsx)("div",{ref:w,className:"fixed z-50 min-w-[12rem] max-w-[calc(100vw-1rem)] max-h-64 overflow-y-auto rounded border border-border bg-surface shadow-lg",style:{top:null!=(t=null==k?void 0:k.top)?t:-9999,left:null!=(n=null==k?void 0:k.left)?n:-9999},role:"menu","data-testid":"branch-checkout-menu",children:0===C.length?(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:x("git.checkout.noBranches")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:C.map(e=>{var t;let n=null!==e.checkedOutWorktreePath;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>I(e),disabled:l||n,className:"w-full text-left px-3 py-1.5 font-mono text-xs text-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":x("git.checkout.checkoutBranch",{name:e.name}),title:n?x("git.checkout.checkedOutElsewhere",{path:null!=(t=e.checkedOutWorktreePath)?t:""}):void 0,children:[e.name,e.isDefault&&(0,r.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:x("git.checkout.defaultBadge")})]})},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})}),document.body),o&&(0,r.jsx)("div",{className:"mt-1 text-xs text-danger-foreground",role:"alert","data-testid":"branch-checkout-error",children:o}),g&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-checkout-confirm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[x("git.checkout.confirmTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:g.name}),x("git.checkout.confirmTitleSuffix")]}),(0,r.jsx)("div",{className:"rounded border border-warning-border bg-warning-subtle px-3 py-2 text-xs text-warning-foreground",role:"alert","data-testid":"branch-history-loss-warning",children:x("git.checkout.historyLossWarning")}),c&&(0,r.jsx)("div",{className:"rounded border border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground",role:"alert","data-testid":"branch-session-warning",children:x("git.checkout.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(d.Sc,{checked:v,onCheckedChange:e=>y(!0===e),"data-testid":"branch-checkout-force"}),x("git.checkout.forceLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 ".concat(u?"flex-wrap":""),children:[(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:()=>b(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:f("cancel")}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:T,disabled:l,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50","data-testid":"branch-checkout-confirm-button",children:x("git.checkout.action")})]})]})})]})}),lw=(0,s.memo)(function(e){let{open:t,onToggle:n,children:a}=e,s=(0,i.c)("worktree");return(0,r.jsxs)("div",{className:"flex flex-col border-t border-border","data-testid":"git-advanced-section",children:[(0,r.jsxs)("button",{type:"button",onClick:n,className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground","data-testid":"git-advanced-toggle","aria-expanded":t,children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:t?"▼":"▶"}),s("git.advancedOperations")]}),t&&(0,r.jsx)("div",{className:"flex flex-col","data-testid":"git-advanced-content",children:a})]})}),lk=(0,s.createContext)(null);function lN(e){let{value:t,children:n}=e;return(0,r.jsx)(lk.Provider,{value:t,children:n})}function lC(){let e=(0,s.useContext)(lk);if(null===e)throw Error("useGitPaneContext must be used within a GitPaneProvider");return e}let lS=(0,s.memo)(function(e){let{path:t}=e;return(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),lI={status:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",changes:"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",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",advanced:"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"},lT={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},lE=(0,s.memo)(function(e){let{activeTab:t,onTabChange:n}=e,a=(0,i.c)("worktree");return(0,r.jsx)("div",{role:"tablist","aria-label":a("git.paneSections"),"data-testid":"git-pane-mobile-tabs",className:"flex shrink-0 border-b border-border bg-surface sticky top-0 z-30",children:lf.map(e=>{let s=e===t,l=a(lT[e]);return(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":s,"aria-label":l,"data-testid":"git-tab-".concat(e),onClick:()=>n(e),className:"flex flex-1 flex-col items-center justify-center gap-1 py-2 px-1 text-xs transition-colors border-b-2 ".concat(s?"text-accent-600 dark:text-accent-400 border-accent-500 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground border-transparent hover:text-foreground hover:bg-muted"),children:[(0,r.jsx)(lS,{path:lI[e]}),(0,r.jsx)("span",{children:l})]},e)})})});function lA(e){let{activeTab:t,onTabChange:n,className:a="",statusSection:s,quickActionsSection:l,changesSection:i,historySection:o,advancedSection:c}=e,{isMobile:d}=lC();return d?(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-mobile",children:[(0,r.jsx)(lE,{activeTab:t,onTabChange:n}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0","data-testid":"git-pane-mobile-panel","data-active-tab":t,children:["status"===t&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[s,l]}),"changes"===t&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:i}),"history"===t&&o,"advanced"===t&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:c})]})]}):(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-desktop",children:[(0,r.jsx)("div",{"data-testid":"git-group-read","data-git-group":"read",className:"border-l-2 border-info-border bg-info-subtle",children:s}),(0,r.jsxs)("div",{"data-testid":"git-group-write","data-git-group":"write",className:"border-l-2 border-input bg-muted/70 dark:bg-muted/30",children:[l,i]}),(0,r.jsx)("div",{"data-testid":"git-group-history","data-git-group":"read",className:"flex-1 flex flex-col min-h-0 border-l-2 border-info-border bg-info-subtle",children:o}),(0,r.jsx)("div",{"data-testid":"git-group-advanced","data-git-group":"advanced",className:"border-l-2 border-t-2 border-input bg-muted/50 dark:bg-muted/40",children:c})]})}let lM={added:"text-success-foreground",modified:"text-warning-foreground",deleted:"text-danger-foreground",renamed:"text-info",untracked:"text-accent-600 dark:text-accent-400",unmerged:"text-warning-foreground"},lR=(0,s.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),lL=(0,s.memo)(function(e){let{onClick:t,disabled:n=!1,testId:a,className:s=""}=e,l=(0,i.c)("worktree");return(0,r.jsxs)("button",{type:"button",disabled:n,onClick:t,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle disabled:opacity-50 disabled:cursor-not-allowed ".concat(s),"data-testid":a,title:l("git.askAiTooltip"),children:[(0,r.jsx)(aS.A,{size:14,"aria-hidden":"true"}),l("git.askAi")]})}),lP=(0,s.memo)(function(e){let{line:t}=e,n="whitespace-pre font-mono text-xs";return t.startsWith("+")&&!t.startsWith("+++")?n+=" text-success-foreground bg-success-subtle":t.startsWith("-")&&!t.startsWith("---")?n+=" text-danger-foreground bg-danger-subtle":t.startsWith("@@")?n+=" text-info":n+=" text-foreground",(0,r.jsx)("div",{className:n,children:t})}),lD=(0,s.memo)(function(e){let{message:t}=e;return(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-danger-foreground",role:"alert",children:t})}),lF={no_upstream:{badgeKey:"git.currentStatus.noUpstreamBadge",tooltipKey:"git.currentStatus.noUpstreamTooltip"},upstream_gone:{badgeKey:"git.currentStatus.upstreamGoneBadge",tooltipKey:"git.currentStatus.upstreamGoneTooltip"},detached:{badgeKey:"git.currentStatus.detachedBadge",tooltipKey:"git.currentStatus.detachedTooltip"},error:{badgeKey:"git.currentStatus.aheadBehindErrorBadge",tooltipKey:"git.currentStatus.aheadBehindErrorTooltip"}},lO=(0,s.memo)(function(e){var t;let{gitStatus:n,statusLoading:a,statusError:l,onRefresh:o,refreshing:d=!1}=e,{isMobile:u}=lC(),m=(0,i.c)("worktree"),x=(0,ty.Ym)(),f=(0,s.useMemo)(()=>{let e=null==n?void 0:n.lastFetchAt;if(null==e)return m("git.currentStatus.lastFetchNever");let t=(0,ex.fw)(new Date(e).toISOString(),(0,nJ.M)(x));return t?m("git.currentStatus.lastFetch",{relative:t}):m("git.currentStatus.lastFetchNever")},[null==n?void 0:n.lastFetchAt,x,m]),h=n&&!n.aheadBehind&&null!=(t=n.aheadBehindReason)?t:null;return(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-status-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:m("git.currentStatus.title")}),(0,r.jsx)("button",{type:"button",onClick:o,disabled:d,className:"p-1 text-muted-foreground hover:text-foreground rounded disabled:opacity-50","aria-label":d?m("git.currentStatus.refreshing"):m("git.currentStatus.refresh"),"aria-busy":d,"data-testid":"git-status-refresh-button",children:d?(0,r.jsx)(c.y,{size:"sm",variant:"accent"}):(0,r.jsx)(lR,{})})]}),a&&!n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",role:"status",children:[(0,r.jsx)(c.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:m("git.currentStatus.loading")})]}),l&&!n&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-status-error",children:l}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center flex-wrap ".concat(u?"gap-1.5":"gap-2"),children:[(0,r.jsx)("span",{className:"inline-flex items-center max-w-full truncate rounded px-2 py-0.5 text-xs font-mono bg-accent-50 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300","data-testid":"git-status-branch-chip",title:n.currentBranch,children:n.currentBranch}),n.isDirty&&(0,r.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-warning-subtle text-warning-foreground","data-testid":"git-status-dirty-badge",children:m("git.currentStatus.uncommitted")}),n.aheadBehind&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-mono bg-muted text-foreground","data-testid":"git-status-ahead-behind",children:[(0,r.jsxs)("span",{title:m("git.currentStatus.aheadTooltip"),children:["↑",n.aheadBehind.ahead]}),(0,r.jsxs)("span",{title:m("git.currentStatus.behindTooltip"),children:["↓",n.aheadBehind.behind]})]}),h&&(0,r.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-muted text-muted-foreground border border-border","data-testid":"git-status-ahead-behind-reason","data-reason":h,title:m(lF[h].tooltipKey),children:m(lF[h].badgeKey)})]}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:m("git.currentStatus.lastFetchTooltip"),children:f}),n.isBranchMismatch&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs bg-warning-subtle text-warning-foreground border border-warning-border",role:"alert","data-testid":"git-status-mismatch-warning",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠"}),(0,r.jsxs)("span",{children:[m("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:n.initialBranch})," ",m("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n.currentBranch})]})]})]})]})}),lz=(0,s.memo)(function(e){let{progressState:t,operation:n,error:a,conflict:l,conflictFiles:o,hasUpstream:d,onFetch:u,onPull:m,onPush:x,onAbort:f,extraActions:h}=e,{isMobile:p}=lC(),g=(0,i.c)("worktree"),b="running"===t,v=null!=a?a:g("git.network.failed"),[y,j]=(0,s.useState)(0);return(0,s.useEffect)(()=>{if(!b)return void j(0);let e=setInterval(()=>j(e=>e+1),1e3);return()=>clearInterval(e)},[b]),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-network-section",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:g("git.network.quickActions")}),(0,r.jsxs)("div",{className:"flex items-center ".concat(p?"flex-wrap gap-1.5":"gap-2"),children:[u&&(0,r.jsx)("button",{type:"button",onClick:u,disabled:b,className:"px-2 py-1 text-xs rounded border border-border text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:g("git.network.fetch")}),(0,r.jsx)("button",{type:"button",onClick:m,disabled:b,className:"px-2 py-1 text-xs rounded border border-accent-300 dark:border-accent-700 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50","data-testid":"git-pull-button",children:g("git.network.pull")}),(0,r.jsx)("button",{type:"button",onClick:x,disabled:b,className:"px-2 py-1 text-xs rounded border border-success-border text-success-foreground hover:bg-success-subtle disabled:opacity-50","data-testid":"git-push-button",title:d?void 0:g("git.network.noUpstreamTooltip"),children:g("git.network.push")}),h]}),b&&(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded px-2 py-1 text-xs bg-accent-50 text-accent-800 dark:bg-accent-900/20 dark:text-accent-300 ".concat(p?"sticky top-0 z-40":""),"data-testid":"git-network-progress-bar",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",role:"status","data-testid":"git-network-operation-spinner",children:[(0,r.jsx)(c.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:g("git.network.progress",{operation:g("push"===n?"git.network.pushing":"pull"===n?"git.network.pulling":"git.network.fetching"),elapsed:y})})]}),(0,r.jsx)("button",{type:"button",onClick:f,className:"ml-auto px-1.5 py-0.5 rounded border border-accent-400 dark:border-accent-600 hover:bg-accent-100 dark:hover:bg-accent-900/40","data-testid":"git-network-abort-button",children:g("git.network.abort")})]}),"error"===t&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-network-operation-error",children:v}),l&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-network-conflict",children:g("git.network.conflicts",{files:o.join(", ")})})]})}),l_=(0,s.memo)(function(e){let{title:t,testId:n,files:a,actionLabel:l,mode:o,defaultOpen:c,busy:u,onDiff:m,onToggleStage:x,onPreview:f}=e,h=(0,i.c)("worktree"),[p,g]=(0,s.useState)(c),[b,v]=(0,s.useState)(null),[y,j]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1),[N,C]=(0,s.useState)(null),S=(0,s.useCallback)(async e=>{if(b===e){v(null),j(null),C(null);return}v(e),j(null),C(null),k(!0);try{let t=await f(e,o);j(null!=t?t:"")}catch(e){C(h("git.changes.previewFailed"))}finally{k(!1)}},[b,f,o,h]);return(0,r.jsxs)("div",{className:"border-t border-border","data-testid":n,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),className:"w-full flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:p?"▼":"▶"}),h("git.changes.listHeader",{title:t,count:a.length})]}),p&&0===a.length&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:h("git.changes.empty")}),p&&a.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:a.map(e=>{let t=b===e.path;return(0,r.jsxs)("li",{className:"flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,r.jsx)("span",{className:"inline-block w-16 shrink-0 text-xs font-medium ".concat(lM[e.status]),children:e.status}),(0,r.jsx)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:e.path,children:e.path}),(0,r.jsx)("button",{type:"button",onClick:()=>S(e.path),className:"shrink-0 w-5 text-center text-xs text-muted-foreground hover:text-foreground","aria-label":h("git.changes.togglePreview",{path:e.path}),"aria-expanded":t,"data-testid":"git-changes-preview-toggle",children:t?"▼":"▶"}),(0,r.jsx)("button",{type:"button",onClick:()=>m(e.path,o),className:"shrink-0 px-1.5 py-0.5 text-xs text-accent-600 dark:text-accent-400 hover:underline","aria-label":h("git.changes.showDiff",{path:e.path}),"data-testid":"git-changes-diff-button",children:h("git.changes.diff")}),(0,r.jsx)("button",{type:"button",onClick:()=>x(e.path),disabled:u,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","aria-label":h("git.changes.fileAction",{action:l,path:e.path}),"data-testid":"git-changes-toggle-button",children:l})]}),t&&(0,r.jsxs)("div",{className:"px-3 pb-2 bg-muted/40","data-testid":"git-changes-inline-preview",children:[w&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2",role:"status",children:[(0,r.jsx)(d.y$,{size:"xs",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:h("git.changes.loadingPreview")})]}),N&&(0,r.jsx)("div",{className:"py-2 text-xs text-danger-foreground",role:"alert",children:N}),!w&&!N&&null!==y&&(""===y.trim()?(0,r.jsx)("div",{className:"py-2 text-xs text-muted-foreground",children:h("git.changes.noDiff")}):(0,r.jsxs)("div",{className:"overflow-x-auto",children:[(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:y.split("\n").slice(0,20).map((e,t)=>(0,r.jsx)(lP,{line:e},t))})}),y.split("\n").length>20&&(0,r.jsx)("button",{type:"button",onClick:()=>m(e.path,o),className:"mt-1 text-xs text-accent-600 dark:text-accent-400 hover:underline","data-testid":"git-changes-preview-more",children:h("git.changes.truncated")})]}))]})]},"".concat(e.status,":").concat(e.path))})})]})}),lB=(0,s.memo)(function(e){var t,n,a;let{staged:s,loading:l,error:o,busy:c,commitMessage:u,amend:m,committing:x,commitError:f,onRefresh:h,onDiff:p,onPreview:g,onStage:b,onUnstage:v,onCommitMessageChange:y,onAmendChange:j,onCommit:w,onCommitAndPush:k}=e,{isMobile:N}=lC(),C=(0,i.c)("worktree"),S=null!=(t=null==s?void 0:s.staged)?t:[],I=null!=(n=null==s?void 0:s.unstaged)?n:[],T=null!=(a=null==s?void 0:s.untracked)?a:[],E=!x&&u.trim().length>0&&(S.length>0||m),A=!N;return(0,r.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-changes-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:C("git.changes.title")}),(0,r.jsx)("button",{type:"button",onClick:h,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":C("git.changes.refresh"),children:(0,r.jsx)(lR,{})})]}),l&&!s&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(d.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:C("git.changes.loading")})]}),o&&!s&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-changes-error",children:o}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l_,{title:C("git.changes.staged"),testId:"git-staged-list",files:S,actionLabel:C("git.changes.unstage"),mode:"staged",defaultOpen:A,busy:c,onDiff:p,onPreview:g,onToggleStage:v}),(0,r.jsx)(l_,{title:C("git.changes.unstaged"),testId:"git-unstaged-list",files:I,actionLabel:C("git.changes.stage"),mode:"unstaged",defaultOpen:A,busy:c,onDiff:p,onPreview:g,onToggleStage:b}),(0,r.jsx)(l_,{title:C("git.changes.untracked"),testId:"git-untracked-list",files:T,actionLabel:C("git.changes.stage"),mode:"untracked",defaultOpen:A,busy:c,onDiff:p,onPreview:g,onToggleStage:b}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-2 border-t border-border",children:[(0,r.jsx)("textarea",{value:u,onChange:e=>y(e.target.value),placeholder:C("git.changes.commitMessage"),rows:N?2:3,className:"w-full resize-y rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"git-commit-message","aria-label":C("git.changes.commitMessage")}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(d.Sc,{checked:m,onCheckedChange:e=>j(!0===e),"data-testid":"git-amend-checkbox"}),C("git.changes.amend")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:w,disabled:!E,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-button",children:C(x?"git.changes.committing":"git.changes.commit")}),(0,r.jsx)("button",{type:"button",onClick:k,disabled:!E||c,title:C("git.changes.commitAndPushTooltip"),className:"px-3 py-1 text-xs font-medium rounded border border-accent-600 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-push-button",children:C("git.changes.commitAndPush")})]})]}),f&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:f})]})]})]})}),lV=(0,s.memo)(function(e){let{commits:t,isLoading:n,commitError:a,commitListOpen:l,onToggleCommitList:o,onRefresh:d,selectedCommit:u,onCommitSelect:m,inlineDiffCommit:x,inlineFiles:f,inlineFilesLoading:h,inlineFilesError:p,onToggleInlineDiff:g,onInlineDiffFile:b,changedFiles:v,isLoadingFiles:y,detailError:j,selectedFile:w,onFileSelect:k,diffContent:N,isLoadingDiff:C}=e,{isMobile:S}=lC(),I=(0,i.c)("worktree"),[T,E]=(0,s.useState)(!0),[A,M]=(0,s.useState)(!0);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:o,className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:l?"▼":"▶"}),I("git.history.title")]}),(0,r.jsx)("button",{type:"button",onClick:d,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":I("git.history.refresh"),children:(0,r.jsx)(lR,{})})]}),l&&n&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",role:"status",children:[(0,r.jsx)(c.y,{size:"lg",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loading")})]}),l&&a&&!n&&(0,r.jsx)("div",{className:"px-3 py-4 text-sm text-danger-foreground",role:"alert",children:a}),l&&!n&&!a&&0===t.length&&(0,r.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:I("git.history.empty")}),!n&&!a&&t.length>0&&(0,r.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[l&&(0,r.jsx)("div",{className:"overflow-y-auto ".concat(u?"max-h-[40%] shrink-0":"flex-1"),children:(0,r.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>{let t=x===e.hash;return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{className:"flex items-stretch",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(e.hash),className:"flex-1 min-w-0 text-left px-3 py-2 text-sm hover:bg-muted transition-colors ".concat(u===e.hash?"bg-accent-50 dark:bg-accent-900/30":""),children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400 shrink-0",children:e.shortHash}),(0,r.jsx)("span",{className:"truncate text-foreground",children:e.message})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:e.author}),(0,r.jsx)("span",{children:new Date(e.date).toLocaleDateString()})]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>g(e.hash),className:"shrink-0 px-2 text-xs text-accent-600 dark:text-accent-400 hover:bg-muted hover:underline","aria-label":I("git.history.viewDiffFor",{hash:e.shortHash}),"aria-expanded":t,"data-testid":"git-commit-view-diff-button",children:t?I("git.history.hideDiff"):I("git.history.viewDiff")})]}),t&&(0,r.jsxs)("div",{className:"border-t border-border bg-muted/40","data-testid":"git-commit-inline-files",children:[h&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-3",role:"status",children:[(0,r.jsx)(c.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loadingChangedFiles")})]}),p&&(0,r.jsx)(lD,{message:p}),!h&&!p&&0===f.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("git.history.noChangedFiles")}),!h&&f.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:f.map(t=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>b(e.hash,t.path),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ".concat(w===t.path&&u===e.hash?"bg-accent-50 dark:bg-accent-900/30":""),"aria-label":I("git.history.showCommitDiff",{path:t.path}),"data-testid":"git-commit-inline-file",children:[(0,r.jsx)("span",{className:"inline-block w-14 font-medium ".concat(lM[t.status]),children:t.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:t.path})]})},t.path))})]})]},e.hash)})})}),u&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 border-t border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>E(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:T?"▼":"▶"}),I("git.history.changedFiles")]}),T&&(0,r.jsxs)(r.Fragment,{children:[j&&(0,r.jsx)(lD,{message:j}),y&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(c.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loadingChangedFiles")})]}),!y&&!j&&0===v.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("git.history.noChangedFiles")}),!y&&v.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:v.map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>k(e.path),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ".concat(w===e.path?"bg-accent-50 dark:bg-accent-900/30":""),children:[(0,r.jsx)("span",{className:"inline-block w-14 font-medium ".concat(lM[e.status]),children:e.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:e.path})]})},e.path))})]}),S&&w&&(0,r.jsxs)("div",{className:"border-t border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>M(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:A?"▼":"▶"}),I("git.history.diffLabel",{file:w})]}),A&&(0,r.jsxs)(r.Fragment,{children:[C&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(c.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loadingDiff")})]}),!C&&N&&(0,r.jsx)("div",{className:"overflow-x-auto p-2",children:(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:N.split("\n").map((e,t)=>(0,r.jsx)(lP,{line:e},t))})})}),!C&&!N&&!j&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("git.history.noDiff")})]})]}),!S&&w&&!j&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border",children:C?I("git.history.loadingDiff"):I("git.history.diffInFilePanel",{file:w})})]})]})]})});function lH(e){return"`"+e+"`"}let lU={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},lK=(0,s.memo)(function(e){let{branches:t,include:n,loading:a,error:l,busy:o,actionError:c,onIncludeChange:u,onRefresh:m,onCreate:x,onDelete:f}=e,{isMobile:h,onInsertToMessage:p}=lC(),g=(0,i.c)("worktree"),b=(0,i.c)("common"),[v,y]=(0,s.useState)(!h),[j,w]=(0,s.useState)(!1),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)(""),[I,T]=(0,s.useState)(null),[E,A]=(0,s.useState)(!1),M=(0,s.useCallback)(()=>{0!==k.trim().length&&(x(k.trim(),C.trim()||void 0),w(!1),N(""),S(""))},[k,C,x]),R=(0,s.useCallback)(()=>{I&&(f(I.name,E),T(null),A(!1))},[I,E,f]);return(0,r.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-branches-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:v?"▼":"▶"}),g("git.branches.title")]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>w(!0),className:"px-2 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted","data-testid":"git-branch-create-open",children:g("git.branches.newButton")}),(0,r.jsx)("button",{type:"button",onClick:m,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":g("git.branches.refresh"),children:(0,r.jsx)(lR,{})})]})]}),v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center gap-1 px-3 pb-2",children:["local","remote","all"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>u(e),className:"px-2 py-0.5 text-xs rounded ".concat(n===e?"bg-accent-100 text-accent-800 dark:bg-accent-900/40 dark:text-accent-200":"text-muted-foreground hover:bg-muted"),"data-testid":"git-branches-tab-".concat(e),children:g(lU[e])},e))}),a&&0===t.length&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(d.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:g("git.branches.loading")})]}),l&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-error",children:l}),c&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-action-error",children:c}),!a&&!l&&0===t.length&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-muted-foreground",children:g("git.branches.empty")}),t.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border max-h-64 overflow-y-auto",children:t.map(e=>{let t=o||e.isCurrent||e.isDefault;return(0,r.jsxs)("li",{className:"flex items-center gap-2 px-3 py-1.5","data-testid":"git-branch-row",children:[(0,r.jsxs)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:e.name,children:[e.isCurrent&&(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 mr-1",children:"●"}),e.name,e.isDefault&&(0,r.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:g("git.branches.defaultBadge")})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{A(!1),T(e)},disabled:t,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-danger-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":g("git.branches.deleteBranch",{name:e.name}),children:g("git.branches.delete")})]},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})]}),j&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-create-modal",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:g("git.branches.createTitle")}),(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:g("git.branches.namePlaceholder"),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-name-input","aria-label":g("git.branches.nameLabel")}),(0,r.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-from-select","aria-label":g("git.branches.baseLabel"),children:[(0,r.jsx)("option",{value:"",children:g("git.branches.currentHead")}),t.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},"from:".concat(e.isRemote?"r":"l",":").concat(e.name)))]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&(0,r.jsx)(lL,{className:"mr-auto",testId:"branch-create-ask-ai",disabled:0===k.trim().length,onClick:()=>{p(function(e,t,n){let a=n&&n.trim().length>0?lH(n.trim()):e("git.aiPrompts.branchCreateBaseHead");return e("git.aiPrompts.branchCreate",{base:a,name:lH(t.trim())})}(g,k,C)),w(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>w(!1),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:b("cancel")}),(0,r.jsx)("button",{type:"button",onClick:M,disabled:o||0===k.trim().length,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-create-submit",children:g("git.branches.create")})]})]})}),I&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-delete-confirm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[g("git.branches.deleteTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:I.name}),g("git.branches.deleteTitleSuffix")]}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(d.Sc,{checked:E,onCheckedChange:e=>A(!0===e),"data-testid":"branch-delete-force"}),g("git.branches.forceDeleteLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&I&&(0,r.jsx)(lL,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{p(g(E?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:lH(I.name)})),T(null),A(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>T(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:b("cancel")}),(0,r.jsx)("button",{type:"button",onClick:R,disabled:o,className:"px-3 py-1 text-xs font-medium rounded bg-danger text-white hover:bg-danger/90 disabled:opacity-50","data-testid":"branch-delete-confirm-button",children:g("git.branches.delete")})]})]})})]})}),lW=(0,s.memo)(function(e){let{stashes:t,loading:n,error:a,busy:l,actionError:o,conflictNotice:c,hasRunningSession:u,onRefresh:m,onPush:x,onPop:f,onApply:h,onDrop:p}=e,{isMobile:g,onInsertToMessage:b}=lC(),v=(0,i.c)("worktree"),y=(0,i.c)("common"),[j,w]=(0,s.useState)(!g),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.useState)(null);return(0,r.jsxs)("div",{className:"border-b border-border","data-testid":"git-stash-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>w(e=>!e),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:j?"▼":"▶"}),v("git.stash.titlePrefix"),t.length>0&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:v("git.stash.count",{count:t.length})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[j&&b&&t.length>0&&(0,r.jsx)(lL,{testId:"stash-cleanup-ask-ai",onClick:()=>b(function(e,t){let n=e("git.aiPrompts.stashCleanup");if(0===t.length)return n;let a=t.map(e=>"- stash@{".concat(e.index,"}: ").concat(e.message)).join("\n");return"".concat(n,"\n\n").concat(e("git.aiPrompts.stashCleanupCurrent"),"\n").concat(a)}(v,t))}),(0,r.jsx)("button",{type:"button",onClick:m,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":v("git.stash.refresh"),children:(0,r.jsx)(lR,{})})]})]}),j&&(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[a&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-error",children:a}),o&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-action-error",children:o}),c&&(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-stash-conflict",children:c}),b&&(0,r.jsx)(lL,{className:"shrink-0",testId:"stash-conflict-ask-ai",onClick:()=>b(function(e,t){let n=e("git.aiPrompts.stashConflict");return t&&t.trim().length>0?"".concat(n,"\n\n").concat(t.trim()):n}(v,c))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:v("git.stash.messagePlaceholder"),className:"w-full px-2 py-1 text-xs border border-input rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"git-stash-push-message"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(d.Sc,{checked:C,onCheckedChange:e=>S(!0===e),"data-testid":"git-stash-include-untracked"}),v("git.stash.includeUntracked")]}),(0,r.jsx)("button",{type:"button",disabled:l,onClick:()=>{x(k,C),N(""),S(!1)},className:"px-2 py-1 text-xs rounded bg-accent-600 hover:bg-accent-700 text-white disabled:opacity-50","data-testid":"stash-push-button",children:v("git.stash.push")})]})]}),n?(0,r.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",role:"status",children:v("git.stash.loading")}):0===t.length?(0,r.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",children:v("git.stash.empty")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>(0,r.jsx)("li",{className:"py-1.5","data-testid":"git-stash-row",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400",children:["stash@","{",e.index,"}"]}),(0,r.jsx)("span",{className:"ml-2 text-xs text-foreground truncate",children:e.message})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",disabled:l,onClick:()=>h(e.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-apply-button",children:v("git.stash.apply")}),(0,r.jsx)("button",{type:"button",disabled:l,onClick:()=>f(e.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-pop-button",children:v("git.stash.pop")}),(0,r.jsx)("button",{type:"button",disabled:l,onClick:()=>T(e.index),className:"px-1.5 py-0.5 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"stash-drop-button",children:v("git.stash.drop")})]})]})},e.index))})]}),null!==I&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"git-stash-drop-confirm",role:"dialog",children:[(0,r.jsxs)("p",{className:"text-xs text-danger-foreground",children:["stash@","{",I,"}",v("git.stash.dropConfirmSuffix")]}),u&&(0,r.jsx)("p",{className:"mt-1 text-xs text-danger-foreground","data-testid":"git-stash-drop-session-warning",children:v("git.danger.runningSessionWarning")}),(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:l,onClick:()=>{p(I),T(null)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"git-stash-drop-confirm-button",children:v("git.stash.drop")}),(0,r.jsx)("button",{type:"button",onClick:()=>T(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:y("cancel")})]})]})]})}),lq={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},l$=(0,s.memo)(function(e){let{selectedCommit:t,busy:n,actionError:a,conflictNotice:l,currentBranch:o,aheadCount:c,hasRunningSession:u,onReset:m,onRevert:x,onForcePush:f}=e,{isMobile:h,onInsertToMessage:p}=lC(),g=(0,i.c)("worktree"),b=(0,i.c)("common"),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)("mixed"),[k,N]=(0,s.useState)(!0),[C,S]=(0,s.useState)(""),[I,T]=(0,s.useState)(!1),[E,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[L,P]=(0,s.useState)(!1),[D,F]=(0,s.useState)(!0),O=k?"HEAD":t,z=!k&&!t;return(0,r.jsxs)("div",{className:"border-t-2 border-danger-border","data-testid":"git-danger-zone-section",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-danger-foreground bg-danger-subtle cursor-pointer hover:bg-danger-subtle","data-testid":"git-danger-zone-toggle",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:v?"▼":"▶"}),g("git.danger.title")]}),v&&(0,r.jsxs)("div",{className:"px-3 py-3 space-y-2 bg-danger-subtle",children:[a&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-danger-zone-error",children:a}),l&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:l}),(0,r.jsxs)("div",{className:"flex ".concat(h?"flex-col":"flex-row"," gap-2"),children:[(0,r.jsx)("button",{type:"button",onClick:()=>T(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle","data-testid":"git-danger-zone-reset-open",children:g("git.danger.resetOpen")}),(0,r.jsx)("button",{type:"button",disabled:!t,onClick:()=>A(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-danger-zone-revert-open",children:g("git.danger.revertOpen")}),f&&(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>P(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-force-push-open",children:g("git.danger.forcePushOpen")})]}),!t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:g("git.danger.selectCommitHint")})]}),I&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"reset-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:g("git.danger.resetTitle")}),(0,r.jsxs)(d.z6,{value:k?"head":"commit",onValueChange:e=>N("head"===e),name:"reset-target",className:"flex flex-col gap-1 mb-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(d.CU,{value:"head","data-testid":"reset-target-head"}),g("git.danger.resetTargetHead")]}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(d.CU,{value:"commit",disabled:!t,"data-testid":"reset-target-commit"}),g("git.danger.resetTargetSelectedPrefix"),t?g("git.danger.resetTargetSelectedHash",{hash:t.slice(0,7)}):g("git.danger.resetTargetNoneSelected")]})]}),(0,r.jsx)(d.z6,{value:j,onValueChange:e=>w(e),name:"reset-mode",className:"flex flex-col gap-1 mb-2",children:["soft","mixed","hard"].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(d.CU,{value:e,"data-testid":"reset-mode-".concat(e)}),g(lq[e])]},e))}),"hard"===j&&(0,r.jsxs)("div",{className:"mb-2 space-y-1",children:[(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-history-loss-warning",children:g("git.danger.resetHardWarning")}),u&&(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:g("git.danger.runningSessionWarning")}),(0,r.jsx)("input",{type:"text",value:C,onChange:e=>S(e.target.value),placeholder:g("git.danger.confirmPlaceholder",{branch:null!=o?o:""}),className:"w-full px-2 py-1 text-xs border border-danger-border rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"reset-hard-branch-input"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(lL,{className:"mr-auto",testId:"reset-ask-ai",disabled:z,onClick:()=>{O&&(p("hard"===j?g("git.aiPrompts.resetHard",{target:lH(O)}):g("git.aiPrompts.reset",{target:lH(O),mode:j})),T(!1),S(""))}}),(0,r.jsx)("button",{type:"button",disabled:n||z||"hard"===j&&C!==(null!=o?o:""),onClick:()=>{O&&(m(O,j,"hard"===j?C:void 0),T(!1),S(""))},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"reset-confirm-button",children:g("git.danger.reset")}),(0,r.jsx)("button",{type:"button",onClick:()=>{T(!1),S("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),E&&t&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"revert-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:g("git.danger.revertTitle")}),(0,r.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[g("git.danger.revertBodyPrefix"),(0,r.jsx)("span",{className:"font-mono",children:t.slice(0,7)})]}),u&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"revert-session-warning",children:g("git.danger.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,r.jsx)(d.Sc,{checked:M,onCheckedChange:e=>R(!0===e),"data-testid":"revert-no-commit"}),g("git.danger.revertNoCommit")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(lL,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(g("git.aiPrompts.revert",{commit:lH(t.slice(0,7))})),A(!1),R(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{x(t,M),A(!1),R(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"revert-confirm-button",children:g("git.danger.revert")}),(0,r.jsx)("button",{type:"button",onClick:()=>{A(!1),R(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),L&&f&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"force-push-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:g("git.danger.forcePushTitle")}),(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:g("git.danger.protectedBranchWarning")}),u&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:g("git.danger.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,r.jsx)(d.Sc,{checked:D,onCheckedChange:e=>F(!0===e),"data-testid":"force-push-with-lease"}),g("git.danger.forceWithLease")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(lL,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(e,t){let{branch:n,ahead:a}=t,r=n?lH(n):e("git.aiPrompts.forcePushCurrentBranch");return e("number"==typeof a&&a>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:r,upstream:lH("origin/".concat(null!=n?n:"<branch>")),ahead:null!=a?a:0})}(g,{branch:o,ahead:null!=c?c:null})),P(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{f(D),P(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"force-push-confirm-button",children:g("git.danger.forcePush")}),(0,r.jsx)("button",{type:"button",onClick:()=>P(!1),className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]})]})}),lG=(0,s.memo)(function(e){var t,n,a,l;let{worktreeId:o,onDiffSelect:c,isMobile:u=!1,worktree:m,onInsertToMessage:x,className:f=""}=e,h=(0,i.c)("worktree"),{activeTab:p,setActiveTab:g,historyOpen:b,toggleHistory:v,advancedOpen:y,toggleAdvanced:j}=function(){let{value:e,setValue:t,isAvailable:n}=(0,lx.V)({key:lp.activeTab,defaultValue:"status",validate:lg}),{value:a,setValue:r}=(0,lx.V)({key:lp.historyOpen,defaultValue:!0,validate:lb}),{value:l,setValue:i}=(0,lx.V)({key:lp.advancedOpen,defaultValue:!1,validate:lb}),o=(0,s.useCallback)(e=>t(e),[t]);return{activeTab:e,setActiveTab:o,historyOpen:a,toggleHistory:(0,s.useCallback)(()=>r(e=>!e),[r]),advancedOpen:l,toggleAdvanced:(0,s.useCallback)(()=>i(e=>!e),[i]),isPersistent:n}}(),w=Object.values(null!=(n=null==m?void 0:m.sessionStatusByCli)?n:{}).some(e=>(null==e?void 0:e.isRunning)===!0),{gitStatus:k,statusLoading:N,statusError:C,fetchStatus:S}=function(e){let[t,n]=(0,s.useState)(null),[a,r]=(0,s.useState)(!0),[l,i]=(0,s.useState)(null),o=(0,s.useCallback)(async()=>{i(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/status"));if(!t.ok){let e=await t.json().catch(()=>({}));i(e.error||"Failed to fetch git status");return}let a=await t.json();n(a)}catch(e){i("Failed to fetch git status")}finally{r(!1)}},[e]);return(0,s.useEffect)(()=>{o()},[o]),{gitStatus:t,statusLoading:a,statusError:l,fetchStatus:o}}(o),{commits:I,selectedCommit:T,changedFiles:E,inlineDiffCommit:A,inlineFiles:M,inlineFilesLoading:R,inlineFilesError:L,selectedFile:P,diffContent:D,isLoading:F,isLoadingFiles:O,isLoadingDiff:z,commitError:_,detailError:B,setDiffContent:V,fetchCommits:H,handleCommitSelect:U,handleFileSelect:K,handleToggleInlineDiff:W,handleInlineDiffFile:q,handleRefresh:$}=function(e,t){let[n,a]=(0,s.useState)([]),[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)([]),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(!0),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.useState)(null),[E,A]=(0,s.useState)(null),M=(0,s.useCallback)(async()=>{w(!0),T(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/log"));if(!t.ok){let e=await t.json();T(e.error||"Failed to fetch commit history");return}let n=await t.json();a(n.commits)}catch(e){T("Failed to fetch commit history")}finally{w(!1)}},[e]),R=(0,s.useCallback)(async t=>{N(!0),o([]),b(null),y(null),A(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json();A(e.error||"Failed to fetch commit details");return}let a=await n.json();o(a.files)}catch(e){A("Failed to fetch commit details")}finally{N(!1)}},[e]),L=(0,s.useCallback)(async(n,a)=>{S(!0),y(null),A(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/diff?commit=").concat(n,"&file=").concat(encodeURIComponent(a)));if(!r.ok){let e=await r.json();A(e.error||"Failed to fetch diff");return}let s=await r.json();y(s.diff),t(s.diff,a)}catch(e){A("Failed to fetch diff")}finally{S(!1)}},[e,t]);(0,s.useEffect)(()=>{M()},[M]);let P=(0,s.useCallback)(e=>{l(e),R(e)},[R]),D=(0,s.useCallback)(e=>{r&&(b(e),L(r,e))},[r,L]),F=(0,s.useCallback)(async t=>{if(c===t){d(null),m([]),p(null);return}d(t),m([]),p(null),f(!0);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json().catch(()=>({}));p(e.error||"Failed to fetch commit details");return}let a=await n.json();m(Array.isArray(a.files)?a.files:[])}catch(e){p("Failed to fetch commit details")}finally{f(!1)}},[e,c]),O=(0,s.useCallback)((e,t)=>{l(e),b(t),o(u),L(e,t)},[u,L]),z=(0,s.useCallback)(()=>{l(null),o([]),b(null),y(null),A(null),M()},[M]);return{commits:n,selectedCommit:r,changedFiles:i,inlineDiffCommit:c,inlineFiles:u,inlineFilesLoading:x,inlineFilesError:h,selectedFile:g,diffContent:v,isLoading:j,isLoadingFiles:k,isLoadingDiff:C,commitError:I,detailError:E,setDiffContent:y,fetchCommits:M,handleCommitSelect:P,handleFileSelect:D,handleToggleInlineDiff:F,handleInlineDiffFile:O,handleRefresh:z}}(o,c),G=(0,s.useCallback)(async()=>{await H(),await S()},[H,S]),{staged:J,stagedLoading:Y,stagedError:Q,opBusy:X,commitMessage:Z,setCommitMessage:ee,amend:et,setAmend:en,committing:ea,changesCommitError:er,fetchStaged:es,handleStage:el,handleUnstage:ei,handleChangesDiff:eo,fetchWorkingDiffText:ec,commit:ed,commitAndPush:eu}=function(e,t){let{onWorkingDiff:n,onCommitted:a}=t,[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!0),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(""),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null),j=(0,s.useCallback)(async()=>{d(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/staged"));if(!t.ok){let e=await t.json().catch(()=>({}));d(e.error||"Failed to fetch changes");return}let n=await t.json();l(n)}catch(e){d("Failed to fetch changes")}finally{o(!1)}},[e]);(0,s.useEffect)(()=>{j()},[j]);let w=(0,s.useCallback)(async t=>{m(!0),d(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/stage"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[t]})});if(!n.ok){let e=await n.json().catch(()=>({}));d(e.error||"Failed to stage file");return}await j()}catch(e){d("Failed to stage file")}finally{m(!1)}},[e,j]),k=(0,s.useCallback)(async t=>{m(!0),d(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/unstage"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[t]})});if(!n.ok){let e=await n.json().catch(()=>({}));d(e.error||"Failed to unstage file");return}await j()}catch(e){d("Failed to unstage file")}finally{m(!1)}},[e,j]),N=(0,s.useCallback)(async()=>{y(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/commit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:x,amend:h})});if(!t.ok){let e=await t.json().catch(()=>({}));return y(e.error||"Failed to commit"),!1}return f(""),p(!1),await j(),await a(),!0}catch(e){return y("Failed to commit"),!1}},[e,x,h,j,a]),C=(0,s.useCallback)(async()=>{b(!0);try{await N()}finally{b(!1)}},[N]),S=(0,s.useCallback)(async e=>{b(!0);try{await N()&&await e()}finally{b(!1)}},[N]);return{staged:r,stagedLoading:i,stagedError:c,opBusy:u,commitMessage:x,setCommitMessage:f,amend:h,setAmend:p,committing:g,changesCommitError:v,fetchStaged:j,handleStage:w,handleUnstage:k,handleChangesDiff:(0,s.useCallback)(async(t,a)=>{try{let r=await fetch("/api/worktrees/".concat(e,"/git/working-diff?file=").concat(encodeURIComponent(t),"&mode=").concat(a));if(!r.ok)return;let s=await r.json();"string"==typeof s.diff&&n(s.diff,t)}catch(e){}},[e,n]),fetchWorkingDiffText:(0,s.useCallback)(async(t,n)=>{try{let a=await fetch("/api/worktrees/".concat(e,"/git/working-diff?file=").concat(encodeURIComponent(t),"&mode=").concat(n));if(!a.ok)return null;let r=await a.json();return"string"==typeof r.diff?r.diff:null}catch(e){return null}},[e]),commit:C,commitAndPush:S}}(o,{onWorkingDiff:(0,s.useCallback)((e,t)=>{V(e),c(e,t)},[V,c]),onCommitted:G}),{branches:em,branchInclude:ex,branchesLoading:ef,branchesError:eh,branchBusy:ep,branchActionError:eg,fetchBranches:eb,handleBranchIncludeChange:ev,handleBranchesRefresh:ey,handleCheckout:ej,handleBranchCreate:ew,handleBranchDelete:ek}=function(e,t){let{onCheckoutCascade:n}=t,[a,r]=(0,s.useState)([]),[l,i]=(0,s.useState)("local"),[o,c]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(!1),[f,h]=(0,s.useState)(null),p=(0,s.useCallback)(async t=>{u(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/branches?include=").concat(t));if(!n.ok){let e=await n.json().catch(()=>({}));u(e.error||"Failed to fetch branches");return}let a=await n.json();r(Array.isArray(a.branches)?a.branches:[])}catch(e){u("Failed to fetch branches")}finally{c(!1)}},[e]);(0,s.useEffect)(()=>{p(l)},[p,l]);let g=(0,s.useCallback)(e=>{i(e)},[]),b=(0,s.useCallback)(()=>{p(l)},[p,l]),v=(0,s.useCallback)(async(t,a)=>{x(!0),h(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t.name,force:a})});if(!r.ok){let e=await r.json().catch(()=>({}));h(e.error||"Failed to checkout branch");return}await Promise.all([n(),p(l)])}catch(e){h("Failed to checkout branch")}finally{x(!1)}},[e,l,n,p]),y=(0,s.useCallback)(async(t,n)=>{x(!0),h(null);try{let a=await fetch("/api/worktrees/".concat(e,"/git/branch/create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,from:n})});if(!a.ok){let e=await a.json().catch(()=>({}));h(e.error||"Failed to create branch");return}await p(l)}catch(e){h("Failed to create branch")}finally{x(!1)}},[e,l,p]),j=(0,s.useCallback)(async(t,n)=>{x(!0),h(null);try{let a=await fetch("/api/worktrees/".concat(e,"/git/branch/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,force:n})});if(!a.ok){let e=await a.json().catch(()=>({}));h(e.error||"Failed to delete branch");return}await p(l)}catch(e){h("Failed to delete branch")}finally{x(!1)}},[e,l,p]);return{branches:a,branchInclude:l,branchesLoading:o,branchesError:d,branchBusy:m,branchActionError:f,fetchBranches:p,handleBranchIncludeChange:g,handleBranchesRefresh:b,handleCheckout:v,handleBranchCreate:y,handleBranchDelete:j}}(o,{onCheckoutCascade:(0,s.useCallback)(async()=>{await Promise.all([S(),es(),H()])},[S,es,H])}),{stashes:eN,stashLoading:eC,stashError:eS,stashBusy:eI,stashActionError:eT,stashConflictNotice:eE,fetchStash:eA,handleStashPush:eM,handleStashPop:eR,handleStashApply:eL,handleStashDrop:eP}=function(e,t){let{onStashMutated:n}=t,[a,r]=(0,s.useState)([]),[l,i]=(0,s.useState)(!0),[o,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null),[f,h]=(0,s.useState)(null),p=(0,s.useCallback)(async()=>{c(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/stash"));if(!t.ok){let e=await t.json().catch(()=>({}));c(e.error||"Failed to fetch stashes");return}let n=await t.json();r(Array.isArray(n.stashes)?n.stashes:[])}catch(e){c("Failed to fetch stashes")}finally{i(!1)}},[e]);(0,s.useEffect)(()=>{p()},[p]);let g=(0,s.useCallback)(async()=>{await Promise.all([p(),n()])},[p,n]),b=(0,s.useCallback)(async(e,t,n)=>{u(!0),x(null),h(null);try{let a=await fetch(e,t),r=await a.json().catch(()=>({}));if(!a.ok)return void x(r.error||n);if(r.conflict){let e=Array.isArray(r.conflictFiles)?r.conflictFiles.join(", "):"",t=r.stashRetained?" (stash retained)":"";h("Stash operation produced conflicts: ".concat(e).concat(t))}await g()}catch(e){x(n)}finally{u(!1)}},[g]),v=(0,s.useCallback)((t,n)=>{b("/api/worktrees/".concat(e,"/git/stash/push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t||void 0,includeUntracked:n})},"Failed to stash changes")},[e,b]),y=(0,s.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/pop"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:t})},"Failed to pop stash")},[e,b]);return{stashes:a,stashLoading:l,stashError:o,stashBusy:d,stashActionError:m,stashConflictNotice:f,fetchStash:p,handleStashPush:v,handleStashPop:y,handleStashApply:(0,s.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/apply"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:t})},"Failed to apply stash")},[e,b]),handleStashDrop:(0,s.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/").concat(t),{method:"DELETE"},"Failed to drop stash")},[e,b])}}(o,{onStashMutated:(0,s.useCallback)(async()=>{await Promise.all([S(),es()])},[S,es])}),{dangerBusy:eD,dangerActionError:eF,dangerConflictNotice:eO,handleReset:ez,handleRevert:e_}=function(e,t){let{onHeadMoved:n}=t,[a,r]=(0,s.useState)(!1),[l,i]=(0,s.useState)(null),[o,c]=(0,s.useState)(null);return{dangerBusy:a,dangerActionError:l,dangerConflictNotice:o,handleReset:(0,s.useCallback)(async(t,a,s)=>{r(!0),i(null),c(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/reset"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:t,mode:a,confirmBranch:s})});if(!r.ok){let e=await r.json().catch(()=>({}));i(e.error||"Failed to reset");return}await n()}catch(e){i("Failed to reset")}finally{r(!1)}},[e,n]),handleRevert:(0,s.useCallback)(async(t,a)=>{r(!0),i(null),c(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/revert"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:t,noCommit:a})});if(!r.ok){let e=await r.json().catch(()=>({}));i(e.error||"Failed to revert");return}let s=await r.json().catch(()=>({}));if(s.conflict){let e=Array.isArray(s.conflictFiles)?s.conflictFiles.join(", "):"";c("Revert produced conflicts: ".concat(e))}await n()}catch(e){i("Failed to revert")}finally{r(!1)}},[e,n])}}(o,{onHeadMoved:(0,s.useCallback)(async()=>{await Promise.all([S(),es(),eb(ex),H()])},[S,es,eb,ex,H])}),{operation:eB,progressState:eV,error:eH,errorReason:eU,conflict:eK,conflictFiles:eW,runFetch:eq,runPull:e$,runPush:eG,abort:eJ}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onCascade:n}=t,[a,r]=(0,s.useState)(null),[l,i]=(0,s.useState)("idle"),[o,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(!1),[f,h]=(0,s.useState)([]),p=(0,s.useRef)(null),g=(0,s.useRef)(n);(0,s.useEffect)(()=>{g.current=n},[n]),(0,s.useEffect)(()=>()=>{var e;null==(e=p.current)||e.abort()},[]);let b=(0,s.useCallback)(async(t,n,a)=>{var s,l,o;c(null),u(null),x(!1),h([]),r(t),i("running");let d=new AbortController;p.current=d;try{let r=await fetch("/api/worktrees/".concat(e,"/git/").concat(n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:d.signal});if(!r.ok){let e=await r.json().catch(()=>({}));u((s=null==e?void 0:e.reason,"auth_failed"===s?"auth_failed":"protected_branch"===s?"protected_branch":null)),c((l=null==e?void 0:e.error,"string"==typeof l&&l.length>0?l:null)),i("error");return}let o=await r.json().catch(()=>({success:!0}));"pull"===t&&(null==o?void 0:o.conflict)&&(x(!0),h(Array.isArray(o.conflictFiles)?o.conflictFiles:[])),i("idle")}catch(e){e instanceof Error&&"AbortError"===e.name?i("idle"):(c(null),u(null),i("error"))}finally{r(null),p.current=null,null==(o=g.current)||o.call(g,t)}},[e]),v=(0,s.useCallback)(e=>{let t={prune:!0===e.prune};return void 0!==e.remote&&(t.remote=e.remote),b("fetch","fetch",t)},[b]),y=(0,s.useCallback)(e=>{let t={rebase:!0===e.rebase,ffOnly:!0===e.ffOnly};return void 0!==e.remote&&(t.remote=e.remote),void 0!==e.branch&&(t.branch=e.branch),b("pull","pull",t)},[b]);return{operation:a,progressState:l,error:o,errorReason:d,conflict:m,conflictFiles:f,runFetch:v,runPull:y,runPush:(0,s.useCallback)(e=>{let t={force:!0===e.force,forceWithLease:!0===e.forceWithLease,setUpstream:!0===e.setUpstream};return void 0!==e.remote&&(t.remote=e.remote),void 0!==e.branch&&(t.branch=e.branch),b("push","push",t)},[b]),abort:(0,s.useCallback)(()=>{var e;null==(e=p.current)||e.abort()},[])}}(o,{onCascade:(0,s.useCallback)(e=>{S(),eb(ex),"pull"===e&&(es(),H())},[S,eb,ex,es,H])}),eY="auth_failed"===eU?h("git.network.authFailedGuidance"):"protected_branch"===eU?h("git.danger.protectedBranchWarning"):eH,eQ="running"===eV&&("push"===eB||"pull"===eB),eX=(null==k?void 0:k.aheadBehind)!=null,eZ=(0,s.useCallback)(()=>{eq({})},[eq]),e0=(0,s.useCallback)(()=>eu(()=>eG({setUpstream:!eX})),[eu,eG,eX]);ae({intervalMs:5e3,enabled:"running"!==eV,onPoll:S});let e1=(0,s.useMemo)(()=>({isMobile:u,onDiffSelect:c,onInsertToMessage:x}),[u,c,x]),e2=(0,r.jsx)(lO,{gitStatus:k,statusLoading:N,statusError:C,onRefresh:eZ,refreshing:"running"===eV}),e4=(0,r.jsx)(lz,{progressState:eV,operation:eB,error:eY,conflict:eK,conflictFiles:eW,hasUpstream:eX,onPull:()=>e$({}),onPush:()=>eG({setUpstream:!eX}),onAbort:eJ,extraActions:(0,r.jsx)(lj,{branches:em,busy:ep||eQ,actionError:eg,hasRunningSession:w,isMobile:u,onCheckout:ej})}),e5=(0,r.jsx)(lB,{staged:J,loading:Y,error:Q,busy:X||eQ,commitMessage:Z,amend:et,committing:ea,commitError:er,onRefresh:es,onDiff:eo,onPreview:ec,onStage:el,onUnstage:ei,onCommitMessageChange:ee,onAmendChange:en,onCommit:ed,onCommitAndPush:e0}),e3=(0,r.jsx)(lV,{commits:I,isLoading:F,commitError:_,commitListOpen:b,onToggleCommitList:v,onRefresh:$,selectedCommit:T,onCommitSelect:U,inlineDiffCommit:A,inlineFiles:M,inlineFilesLoading:R,inlineFilesError:L,onToggleInlineDiff:W,onInlineDiffFile:q,changedFiles:E,isLoadingFiles:O,detailError:B,selectedFile:P,onFileSelect:K,diffContent:D,isLoadingDiff:z}),e6=(0,r.jsxs)(lw,{open:y,onToggle:j,children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-advanced-fetch",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:h("git.remote")}),(0,r.jsx)("div",{children:(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:()=>eq({}),disabled:"running"===eV,className:"px-2 py-1 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:h("git.network.fetch")})})]}),(0,r.jsx)(lK,{branches:em,include:ex,loading:ef,error:eh,busy:ep||eQ,actionError:eg,onIncludeChange:ev,onRefresh:ey,onCreate:ew,onDelete:ek}),(0,r.jsx)(lW,{stashes:eN,loading:eC,error:eS,busy:eI||eQ,actionError:eT,conflictNotice:eE,hasRunningSession:w,onRefresh:eA,onPush:eM,onPop:eR,onApply:eL,onDrop:eP}),(0,r.jsx)(l$,{selectedCommit:T,busy:eD||eQ,actionError:eF,conflictNotice:eO,currentBranch:null!=(a=null==k?void 0:k.currentBranch)?a:null,aheadCount:null!=(l=null==k||null==(t=k.aheadBehind)?void 0:t.ahead)?l:null,hasRunningSession:w,onReset:ez,onRevert:e_,onForcePush:e=>eG(e?{forceWithLease:!0}:{force:!0})})]});return(0,r.jsx)(lN,{value:e1,children:(0,r.jsx)(lA,{activeTab:p,onTabChange:g,className:f,statusSection:e2,quickActionsSection:e4,changesSection:e5,historySection:e3,advancedSection:e6})})}),lJ=(0,s.memo)(function(e){let{worktreeId:t,worktree:n,onWorktreeUpdate:a}=e,[l,o]=(0,s.useState)(!1),c=(0,i.c)("worktree"),d=(0,s.useRef)(null==n?void 0:n.id),u=(0,s.useRef)(!1),m=tG(n,a,null==n?void 0:n.id,()=>{let e=(null==n?void 0:n.id)!==d.current;return d.current=null==n?void 0:n.id,e&&!u.current});return(u.current=m.isEditing,n)?(0,r.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,r.jsx)(tJ,{worktreeId:t,worktree:n,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:m,showLogs:l,onToggleLogs:()=>o(!l),onWorktreeUpdate:a})}):(0,r.jsx)("div",{className:"text-muted-foreground text-center py-8",children:c("detail.loadingInfo")})}),lY=(0,s.memo)(function(e){let{activeTab:t,worktreeId:n,worktree:a,messages:s,cliToolId:l,instanceId:o,onFilePathClick:c,onFileSelect:d,onWorktreeUpdate:u,onNewFile:m,onNewDirectory:x,onRename:f,onDelete:h,onUpload:p,onMove:g,onFileTreeReset:b,refreshTrigger:v,fileSearch:y,showToast:j,selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:T,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,disableAutoFollow:R,historySubTab:L,onHistorySubTabChange:P,onDiffSelect:D,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:H,useInstanceManagement:U,instances:K,onInstancesChange:W,visibleInstanceIds:q,onToggleInstanceVisible:$,verification:G,toolsSubTabRequest:J,onSurfaceModeChange:Y,directInputOpen:Q}=e,X=(0,i.c)("worktree");switch(t){case"terminal":return(0,r.jsx)(I.t,{componentName:"TerminalDisplay",children:(0,r.jsx)(nF,{worktreeId:n,cliToolId:l,instanceId:o,disableAutoFollow:R,onSurfaceModeChange:Y,directInputOpen:Q})});case"history":return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>P("message"),className:"flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ".concat("message"===L?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"),children:X("detail.subTabMessage")}),(0,r.jsx)("button",{type:"button",onClick:()=>P("git"),className:"flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ".concat("git"===L?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"),children:X("detail.subTabGit")})]}),"message"===L?(0,r.jsx)(I.t,{componentName:"HistoryPane",children:(0,r.jsx)(nO.bl,{messages:s,worktreeId:n,onFilePathClick:c,className:"flex-1 min-h-0",showToast:j,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:H})}):(0,r.jsx)(I.t,{componentName:"GitPane",children:(0,r.jsx)(lG,{worktreeId:n,onDiffSelect:D,isMobile:!0,worktree:null!=a?a:void 0,onInsertToMessage:F,className:"flex-1 min-h-0"})})]});case"files":var Z;return(0,r.jsx)(I.t,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,r.jsx)(au,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),(0,r.jsx)(al,{worktreeId:n,onFileSelect:d,onNewFile:m,onNewDirectory:x,onRename:f,onDelete:h,onUpload:p,onMove:g,onResetView:b,refreshTrigger:v,pollingEnabled:"files"===t,searchQuery:y.query,searchMode:y.mode,searchResults:null==(Z=y.results)?void 0:Z.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(I.t,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(lm,{worktreeId:n,className:"h-full",selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:T,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,onInsertToMessage:F,useInstanceManagement:U,instances:K,onInstancesChange:W,visibleInstanceIds:q,onToggleInstanceVisible:$,modelByInstance:t$(null==a?void 0:a.sessionStatusByInstance),composerTargetInstanceId:o,verification:G,requestedSubTab:J})});case"info":return(0,r.jsx)(lJ,{worktreeId:n,worktree:a,onWorktreeUpdate:u});default:return null}});var lQ=n(72115);let lX=(0,s.memo)(function(e){let{activityPane:t,rightPane:n,activityPaneWidth:a=18,minPaneWidth:l=10,maxPaneWidth:o=60,onActivityPaneResize:c,className:d=""}=e,u=(0,s.useRef)(null),m=(0,i.c)("worktree"),[x,f]=(0,s.useState)(a),h=c?a:x,p=(0,s.useCallback)(e=>{let t=u.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let r=Math.min(o,Math.max(l,(c?a:x)+e/n*100));c?c(r):f(r)},[a,x,l,o,c]),g=(0,s.useMemo)(()=>"flex h-full min-h-0 ".concat(d).trim(),[d]);return(0,r.jsx)("div",{ref:u,className:"h-full",children:(0,r.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:g,children:[null!==t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":m("desktopLayout.activityPane"),style:{width:"".concat(h,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(I.t,{componentName:"ActivityPane",children:t})}),(0,r.jsx)(lQ.f,{onResize:p,orientation:"horizontal",ariaValueNow:h})]}),(0,r.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":m("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,r.jsx)(I.t,{componentName:"TerminalPane",children:n})})]})})});var lZ=n(23570),l0=n(5379),l1=n(15870),l2=n(9540),l4=n(39332),l5=n(16485),l3=n(78192),l6=n(39324),l8=n(80298),l9=n(55867);let l7=[{id:"files",labelKey:"activityBar.files",icon:y.A},{id:"git",labelKey:"activityBar.git",icon:l4.A},{id:"notes",labelKey:"activityBar.notes",icon:et.A},{id:"schedules",labelKey:"activityBar.schedules",icon:l5.A},{id:"agent",labelKey:"activityBar.agent",icon:l3.A},{id:"timer",labelKey:"activityBar.timer",icon:l6.A},{id:"todo",labelKey:"activityBar.todo",icon:l8.A},{id:"skills",labelKey:"activityBar.skills",icon:aS.A},{id:"verification",labelKey:"activityBar.verification",icon:so.A},{id:"env",labelKey:"activityBar.env",icon:l9.A}],ie=new Set(l7.map(e=>e.id)),it="files",ia="__closed__";function ir(e){return"".concat("commandmate.worktree.activeActivity-").concat(e)}var is=n(32916),il=n(65380),ii=n(45195),io=n(89275),ic=n(40823);function id(){let e=(0,i.c)("worktree"),t=(0,io.Hq)(),{theme:n,setTheme:a}=(0,l0.D)(),{currentLocale:l,switchLocale:o}=(0,ii.g)(),c=(0,il.H)(),{open:d}=(0,ic.V0)(),u=(0,s.useRef)(!1),m=e("activityBar.settings"),x="0.44.3",f=(0,s.useCallback)(async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(e){window.location.href="/login"}},[]);return(0,r.jsxs)(ed.rI,{children:[(0,r.jsx)(eu.m_,{content:m,placement:"right",children:(0,r.jsx)(ed.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"activity-bar-settings","aria-label":m,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,r.jsx)(l1.A,{size:20,"aria-hidden":"true"})})})}),(0,r.jsxs)(ed.SQ,{side:"right",align:"end",className:"w-56",onCloseAutoFocus:()=>{u.current&&(u.current=!1,queueMicrotask(d))},children:[(0,r.jsx)(ed.lp,{"data-testid":"activity-bar-settings-version",children:e("activityBar.settingsMenu.version",{version:x?"v".concat(x):"-"})}),(0,r.jsx)(ed._2,{onSelect:()=>{u.current=!0},children:e("activityBar.settingsMenu.settings")}),(0,r.jsx)(ed._2,{onSelect:()=>t.push("/skills"),children:e("activityBar.settingsMenu.skills")}),(0,r.jsx)(ed.mB,{}),(0,r.jsx)(ed.lp,{children:e("activityBar.settingsMenu.theme")}),(0,r.jsxs)(ed.Hr,{value:null!=n?n:"system",onValueChange:e=>a(e),children:[(0,r.jsx)(ed.Ht,{value:"light",children:e("activityBar.settingsMenu.themeLight")}),(0,r.jsx)(ed.Ht,{value:"dark",children:e("activityBar.settingsMenu.themeDark")}),(0,r.jsx)(ed.Ht,{value:"system",children:e("activityBar.settingsMenu.themeSystem")})]}),(0,r.jsx)(ed.lp,{children:e("activityBar.settingsMenu.language")}),(0,r.jsx)(ed.Hr,{value:l,onValueChange:e=>o(e),children:a0.dI.map(e=>(0,r.jsx)(ed.Ht,{value:e,children:a0.vK[e]},e))}),(0,r.jsx)(ed.mB,{}),(0,r.jsx)(ed._2,{asChild:!0,children:(0,r.jsx)("a",{href:"https://github.com/kewton/MyCodeBranchDesk",target:"_blank",rel:"noopener noreferrer",children:e("activityBar.settingsMenu.github")})}),c&&(0,r.jsx)(ed._2,{onSelect:()=>{f()},children:e("activityBar.settingsMenu.logout")})]})]})}let iu=(0,s.memo)(function(e){let{active:t,onToggle:n,className:a=""}=e,l=(0,i.c)("worktree"),o=(0,s.useRef)([]),{isOpen:c,toggle:d}=(0,is.VF)(),u=(0,s.useCallback)((e,t,a)=>{var r,s,l,i;if("Enter"===e.key||" "===e.key){e.preventDefault(),n(a);return}if("ArrowDown"===e.key){e.preventDefault();let n=(t+1)%l7.length;null==(r=o.current[n])||r.focus();return}if("ArrowUp"===e.key){e.preventDefault();let n=(t-1+l7.length)%l7.length;null==(s=o.current[n])||s.focus();return}if("Home"===e.key){e.preventDefault(),null==(l=o.current[0])||l.focus();return}if("End"===e.key){e.preventDefault(),null==(i=o.current[l7.length-1])||i.focus();return}},[n]);return(0,r.jsxs)("div",{"data-testid":"activity-bar",className:"flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ".concat(a).trim(),children:[(0,r.jsx)(eu.m_,{content:l("activityBar.toggleSidebar"),placement:"right",children:(0,r.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:d,"aria-label":l("activityBar.toggleSidebar"),"aria-expanded":c,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,r.jsx)(l2.A,{size:20,"aria-hidden":"true"})})}),(0,r.jsx)("div",{className:"mx-2 my-1 border-b border-border","aria-hidden":"true"}),(0,r.jsx)("div",{id:"worktree-activity-bar",role:"tablist","aria-orientation":"vertical","aria-label":l("activityBar.label"),className:"flex flex-col items-stretch",children:l7.map((e,a)=>{let s=e.icon,i=t===e.id,c=l(e.labelKey);return(0,r.jsx)(eu.m_,{content:c,placement:"right",children:(0,r.jsx)("button",{ref:e=>{o.current[a]=e},type:"button",role:"tab","aria-selected":i,"aria-label":c,"aria-controls":"worktree-activity-pane",tabIndex:i||null===t&&0===a?0:-1,onClick:()=>n(e.id),onKeyDown:t=>u(t,a,e.id),"data-testid":"activity-bar-button-".concat(e.id),className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,r.jsx)("span",{"aria-hidden":"true",className:"flex items-center justify-center h-9 w-9 rounded-md transition-colors ".concat(i?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"),children:(0,r.jsx)(s,{size:20,"aria-hidden":"true"})})})},e.id)})}),(0,r.jsx)("div",{className:"mt-auto",children:(0,r.jsx)(id,{})})]})}),im="worktree-activity-pane",ix={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentInstancesPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},ih=(0,s.memo)(function(e){let{active:t,activities:n,className:a=""}=e;if(null===t)return(0,r.jsx)("div",{id:im,"data-testid":"activity-pane","data-active":"none",className:"h-full flex flex-col ".concat(a).trim()});let s=n[t],l=ix[t];return(0,r.jsx)("div",{id:im,"data-testid":"activity-pane","data-active":t,role:"tabpanel","aria-labelledby":"activity-bar-button-".concat(t),className:"h-full flex flex-col min-h-0 ".concat(a).trim(),children:(0,r.jsx)(I.t,{componentName:l,children:null!=s?s:null})})});var ip=n(13577),ig=n(72338),ib=n(90088),iv=n(96195),iy=n(56936);let ij=(0,s.memo)(function(e){let{inputRef:t,searchQuery:n,onQueryChange:a,matchCount:s,currentIdx:l,onNextMatch:o,onPrevMatch:c,onClose:u}=e,m=(0,i.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,r.jsx)("input",{ref:t,type:"text",value:n,onChange:e=>a(e.target.value),onKeyDown:e=>{"Escape"===e.key&&u(),"Enter"!==e.key||e.nativeEvent.isComposing||(e.shiftKey?c():o())},placeholder:m("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:s>0?"".concat(l+1,"/").concat(s):"0/0"}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:c,disabled:0===s,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":m("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:o,disabled:0===s,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":m("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:u,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":m("fileSearch.close"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})});var iw=n(40051);function ik(){return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,r.jsx)(c.y,{size:"xl",variant:"accent"})})}let iN=(0,e$.default)(()=>n.e(530).then(n.bind(n,530)).then(e=>({default:e.HtmlPreview})),{loadableGenerated:{webpack:()=>[530]},ssr:!1,loading:()=>(0,r.jsx)(ik,{})}),iC=(0,e$.default)(()=>Promise.resolve().then(n.bind(n,27307)).then(e=>({default:e.PdfPreview})),{loadableGenerated:{webpack:()=>[27307]},ssr:!1,loading:()=>(0,r.jsx)(ik,{})}),iS=(0,e$.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(ik,{})}),iI=/^---\s*\nmarp:\s*true/;function iT(){let e=(0,i.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(c.y,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:e("fileViewer.loading")})]})}function iE(e){let{error:t}=e;return(0,r.jsx)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4 m-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("p",{className:"text-sm text-danger-foreground",children:t})]})})}function iA(e){let{reason:t}=e;return(0,r.jsxs)("div",{"data-testid":"file-read-only-notice","data-reason-code":t.code,role:"status",className:"flex items-center gap-2 px-3 py-2 bg-warning-subtle border-b border-warning-border text-xs text-warning-foreground",children:[(0,r.jsx)(tt.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}function iM(e){let{filePath:t,isMaximized:n,onToggleMaximize:a,copyableContent:s,onSearch:l}=e,o=(0,i.c)("worktree"),{copied:c,markCopied:d}=(0,tc.q)(),{copied:u,markCopied:m}=(0,tc.q)(),x=async()=>{try{await (0,te.l)(t),d()}catch(e){}},f=async()=>{if(s)try{await (0,te.l)(s),m()}catch(e){}};return(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("button",{type:"button",onClick:x,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.copyFilePath"),title:o("actions.copyPath"),children:c?(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(e1.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:t,children:t})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l&&(0,r.jsx)("button",{type:"button",onClick:l,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.searchInFile"),title:o("actions.search"),children:(0,r.jsx)(ee.A,{className:"w-3.5 h-3.5"})}),s&&(0,r.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.copyFileContent"),title:o("actions.copyContent"),children:u?(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(e0.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:a,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o(n?"actions.minimize":"actions.maximize"),title:o(n?"actions.minimize":"actions.maximize"),children:n?(0,r.jsx)(el.A,{className:"w-4 h-4"}):(0,r.jsx)(ei.A,{className:"w-4 h-4"})})]})]})}function iR(e){var t;let{content:n,extension:a,searchMatches:l,searchCurrentIdx:i,totalLines:o,rangeStart:c,worktreeId:d,filePath:u,onLineRangeFetched:m}=e,x=(0,s.useRef)(null),f=(0,s.useMemo)(()=>n.split("\n"),[n]),h=Math.max(1,null!=c?c:1),p=f.length,g=Math.max(null!=o?o:p,p),b=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{b.current.clear()},[n,a]);let v=(0,s.useCallback)(e=>{var t;let n=Math.floor(e/500),r=b.current,s=r.get(n);if(!s){let e=500*n,t=Math.min(e+500,f.length),l=f.slice(e,t).join("\n"),i="";try{i=td.A.highlight(l,{language:a,ignoreIllegals:!0}).value}catch(e){i=td.A.highlightAuto(l).value}s=i.split("\n"),r.set(n,s)}return null!=(t=s[e-500*n])?t:""},[f,a]),y=(0,s.useMemo)(()=>new Set(null!=l?l:[]),[l]),j=(null!=(t=null==l?void 0:l.length)?t:0)>0?l[null!=i?i:0]:-1,w=(0,iv.Te)({count:g,getScrollElement:()=>x.current,estimateSize:()=>24,overscan:100});(0,s.useEffect)(()=>{if(!l||0===l.length)return;let e=l[null!=i?i:0];if(!Number.isFinite(e))return;let t=Math.max(0,Math.min(g-1,e-1));w.scrollToIndex(t,{align:"center"})},[i,l,w,g]);let k=w.getVirtualItems();return!function(e){let{virtualItems:t,worktreeId:n,filePath:a,onLineRangeFetched:r,loadedStart:l,loadedLineCount:i}=e,o=(0,s.useRef)(new Set);(0,s.useEffect)(()=>{if(!n||!a||!r||0===t.length)return;let e=t[0].index+1,s=t[t.length-1].index+1,c=l+i-1;if(e>=l&&s<=c)return;let d=Math.max(1,500*Math.floor((e-1)/500)+1),u=d+500-1;if(o.current.has(d))return;o.current.add(d);let m="/api/worktrees/".concat(n,"/files/").concat((0,ts.o)(a),"?startLine=").concat(d,"&endLine=").concat(u);(0,tN.E)(m).then(async e=>e.ok?e.json():null).then(e=>{o.current.delete(d),e&&!0===e.success&&r({content:e.content,range:e.range,totalLines:e.totalLines,totalBytes:e.totalBytes})}).catch(()=>{o.current.delete(d)})},[t,n,a,r,l,i])}({virtualItems:k,worktreeId:d,filePath:u,onLineRangeFetched:m,loadedStart:h,loadedLineCount:p}),(0,r.jsx)("div",{className:"overflow-auto h-full",ref:x,"data-testid":"file-content-code",children:(0,r.jsx)("div",{style:{height:w.getTotalSize(),width:"100%",position:"relative"},children:k.map(e=>{let t=e.index+1,n=t-h,a=n>=0&&n<p,s=t===j,l=y.has(t),i=a?v(n):"";return(0,r.jsxs)("div",{"data-line":t,"data-index":e.index,ref:w.measureElement,className:"absolute left-0 right-0 flex font-mono text-sm ".concat(s?"bg-warning/30":l?"bg-warning/15":""),style:{top:0,transform:"translateY(".concat(e.start,"px)"),height:"".concat(24,"px"),lineHeight:"".concat(24,"px")},children:[(0,r.jsx)("div",{className:"px-3 text-right select-none border-r border-border bg-muted dark:bg-muted/50 whitespace-nowrap ".concat(s||l?"text-warning-foreground":"text-muted-foreground"),style:{minWidth:"4rem"},children:t}),(0,r.jsx)("div",{className:"px-4 text-foreground flex-1 min-w-0 overflow-hidden",children:a?(0,r.jsx)("code",{className:"hljs",style:{padding:0,background:"transparent",whiteSpace:"pre"},dangerouslySetInnerHTML:{__html:i}}):(0,r.jsx)(iw.E,{className:"h-4 w-3/4"})})]},e.key)})})})}function iL(e){let{slides:t,fileName:n}=e,a=(0,i.c)("worktree"),[l,o]=(0,s.useState)(0);return 0===t.length?(0,r.jsx)("div",{className:"p-4 text-muted-foreground",children:a("fileViewer.noSlides",{fileName:n})}):(0,r.jsxs)("div",{className:"h-full flex flex-col","data-testid":"marp-preview",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border bg-muted",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{o(e=>Math.max(0,e-1))},disabled:0===l,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:a("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[l+1," / ",t.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>{o(e=>Math.min(t.length-1,e+1))},disabled:l===t.length-1,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:a("actions.next")})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,r.jsx)("iframe",{srcDoc:t[l],sandbox:"",title:a("fileViewer.slideTitle",{name:n,number:l+1}),className:"w-full h-full border-0"})})]})}function iP(e){let{marpSlides:t,fileName:n,worktreeId:a,filePath:l,contentText:o,onFileSaved:c,isMaximized:d,onToggleMaximize:u,onDirtyChange:m,onOpenFile:x}=e,f=(0,i.c)("worktree"),[h,p]=(0,s.useState)("slides");return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>p("slides"),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat("slides"===h?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:f("fileViewer.slides")}),(0,r.jsx)("button",{type:"button",onClick:()=>p("editor"),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat("editor"===h?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:f("fileViewer.editor")})]}),(0,r.jsx)(iM,{filePath:l,isMaximized:d,onToggleMaximize:u,copyableContent:o})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===h?(0,r.jsx)(iL,{slides:t,fileName:n}):(0,r.jsx)(iS,{worktreeId:a,filePath:l,onSave:c,initialViewMode:"split",onDirtyChange:m,onOpenFile:x})})]})}function iD(e){let{children:t,isMaximized:n,onToggle:a,filePath:s}=e;if(!n)return(0,r.jsx)(r.Fragment,{children:t});let l=(0,r.jsxs)("div",{"data-testid":"maximized-file-overlay",className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:tr.M.MAXIMIZED_EDITOR},children:[(0,r.jsx)(iM,{filePath:s,isMaximized:n,onToggleMaximize:a}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:t})]});return"undefined"==typeof document?l:(0,nB.createPortal)(l,document.body)}function iF(e){let{tab:t,content:n,worktreeId:a,isMaximized:s,onToggleMaximize:l,onFileSaved:i,onDirtyChange:o,onOpenFile:c}=e,d=to(n.content);return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)(iM,{filePath:t.path,isMaximized:s,onToggleMaximize:l,copyableContent:n.content,onSearch:d.openSearch}),d.searchOpen&&(0,r.jsx)(ij,{inputRef:d.searchInputRef,searchQuery:d.searchQuery,onQueryChange:d.setSearchQuery,matchCount:d.searchMatches.length,currentIdx:d.searchCurrentIdx,onNextMatch:d.nextMatch,onPrevMatch:d.prevMatch,onClose:d.closeSearch}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:d.searchOpen&&d.searchQuery.length>=2?(0,r.jsx)(iR,{content:n.content,extension:n.extension,searchMatches:d.searchMatches,searchCurrentIdx:d.searchCurrentIdx}):(0,r.jsx)(iS,{worktreeId:a,filePath:t.path,onSave:i,initialViewMode:"preview",onDirtyChange:o,onOpenFile:c})})]})}function iO(e){var t,n;let{tab:a,content:l,worktreeId:i,isMaximized:o,onToggleMaximize:c,onLoadContent:d}=e,u=to(l.content),m=(0,s.useCallback)(e=>{var t;d&&d(a.path,{...l,content:e.content,totalLines:e.totalLines,totalBytes:null!=(t=e.totalBytes)?t:l.totalBytes,range:e.range})},[d,a.path,l]),x=void 0!==l.range&&(null!=(n=l.totalLines)?n:0)>l.range.end-l.range.start+1;return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(iM,{filePath:a.path,isMaximized:o,onToggleMaximize:c,copyableContent:l.content,onSearch:u.openSearch}),l.readOnly&&l.readOnlyReason&&(0,r.jsx)(iA,{reason:l.readOnlyReason}),u.searchOpen&&(0,r.jsx)(ij,{inputRef:u.searchInputRef,searchQuery:u.searchQuery,onQueryChange:u.setSearchQuery,matchCount:u.searchMatches.length,currentIdx:u.searchCurrentIdx,onNextMatch:u.nextMatch,onPrevMatch:u.prevMatch,onClose:u.closeSearch}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(iR,{content:l.content,extension:l.extension,searchMatches:u.searchOpen?u.searchMatches:void 0,searchCurrentIdx:u.searchOpen?u.searchCurrentIdx:void 0,totalLines:l.totalLines,rangeStart:null==(t=l.range)?void 0:t.start,worktreeId:x?i:void 0,filePath:x?a.path:void 0,onLineRangeFetched:x?m:void 0})})]})}let iz=(0,s.memo)(function(e){var t,n,a,l;let{tab:o,worktreeId:c,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:x,onDirtyChange:f,onOpenFile:h}=e,p=(0,i.c)("worktree"),g=(0,s.useRef)(p);g.current=p;let b=(0,s.useRef)(!1),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(!1);!function(e){let{tab:t,worktreeId:n,onLoadContent:a}=e,r=(0,s.useRef)(null),l=(0,s.useRef)(a);l.current=a;let i=(0,s.useRef)(t.path);i.current=t.path,ae({intervalMs:5e3,enabled:function(e){if(null===e.content||e.loading||e.isDirty||e.content.isPdf)return!1;let{totalBytes:t}=e.content;return void 0===t||!(t>=1048576)}(t),onPoll:async()=>{let e="/api/worktrees/".concat(n,"/files/").concat((0,ts.o)(i.current)),t={};r.current&&(t["If-Modified-Since"]=r.current);try{let n=await (0,tN.E)(e,{headers:t,timeoutMs:iy.K3,retries:0});if(304===n.status||!n.ok)return;r.current=n.headers.get("Last-Modified");let a=await n.json();l.current(i.current,a)}catch(e){}}})}({tab:o,worktreeId:c,onLoadContent:d});let k=(0,s.useMemo)(()=>f?e=>f(o.path,e):void 0,[f,o.path]),N=(0,s.useCallback)(()=>{w(e=>!e)},[]);(0,s.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&w(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]),(0,s.useEffect)(()=>{null!==o.content||o.loading||null!==o.error||b.current||(b.current=!0,m(o.path,!0),(async()=>{try{let t=await (0,tN.E)("/api/worktrees/".concat(c,"/files/").concat((0,ts.o)(o.path)));if(304===t.status)return;if(!t.ok){var e;let n=await t.json(),a="string"==typeof n.error?n.error:(null==(e=n.error)?void 0:e.message)||g.current("fileViewer.loadError");u(o.path,a);return}let n=await t.json();d(o.path,n)}catch(e){u(o.path,e instanceof Error?e.message:g.current("fileViewer.loadError"))}finally{b.current=!1}})())},[o.content,o.loading,o.error,o.path,c,d,u,m]);let C=null!=(a=null==(t=o.content)?void 0:t.content)?a:null,S=null!=(l=null==(n=o.content)?void 0:n.extension)?l:null;if((0,s.useEffect)(()=>{if(!C||"md"!==S||!iI.test(C)||C.length>1e6)return void y(null);let e=!1;return(async()=>{try{let t=await (0,tN.E)("/api/worktrees/".concat(c,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:C})});if(t.ok){let n=await t.json();e||y(Array.isArray(n.slides)?n.slides:null)}}catch(e){}})(),()=>{e=!0}},[C,S,c]),o.loading)return(0,r.jsx)(iT,{});if(o.error)return(0,r.jsx)(iE,{error:o.error});if(!o.content)return null;let{content:I}=o;return I.isImage?(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(iM,{filePath:o.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(eJ.a,{src:I.content,alt:I.path,mimeType:I.mimeType})})]})}):I.isVideo?(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(iM,{filePath:o.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(eY.u,{src:I.content,mimeType:I.mimeType})})]})}):I.isPdf?(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(iM,{filePath:o.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(iC,{dataUri:I.content,filePath:o.path})})]})}):I.readOnly?(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsx)(iO,{tab:o,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onLoadContent:d})}):I.isHtml?(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(iM,{filePath:o.path,isMaximized:j,onToggleMaximize:N,copyableContent:I.content}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(iN,{worktreeId:c,filePath:o.path,htmlContent:I.content,onFileSaved:x,onOpenFile:h})})]})}):"md"===I.extension?(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:v?(0,r.jsx)(iP,{marpSlides:v,fileName:o.name,worktreeId:c,filePath:o.path,contentText:I.content,onFileSaved:x,isMaximized:j,onToggleMaximize:N,onDirtyChange:k,onOpenFile:h}):(0,r.jsx)(iF,{tab:o,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:h})})}):e7("."+I.extension)?(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(iF,{tab:o,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:h})})}):(0,r.jsx)(iD,{isMaximized:j,onToggle:N,filePath:o.path,children:(0,r.jsx)(iO,{tab:o,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onLoadContent:d})})}),i_="commandmate:file-tabs:";function iB(e){let t=e.split("/");return t[t.length-1]||e}function iV(e,t,n){let a=e.findIndex(e=>e.path===t);if(-1===a)return null;let r=[...e];return r[a]=n(r[a]),r}function iH(e,t,n){if("all"===n)return e.map(e=>e.path);let a=e.findIndex(e=>e.path===t);return -1===a?[]:"others"===n?e.filter((e,t)=>t!==a).map(e=>e.path):e.slice(a+1).map(e=>e.path)}let iU={tabs:[],activeIndex:null};function iK(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let iW=(0,s.memo)(function(e){let{tab:t,isActive:n,onActivate:a,onClose:l,onOpenMenu:o}=e,c=(0,i.c)("worktree"),d=(0,s.useCallback)(()=>{n||a(t.path)},[n,a,t.path]),u=(0,s.useCallback)(e=>{e.stopPropagation(),l(t.path)},[l,t.path]),m=(0,s.useCallback)(e=>{o(e,t.path)},[o,t.path]),x=(0,s.useCallback)(e=>{1===e.button&&(e.preventDefault(),e.stopPropagation(),l(t.path))},[l,t.path]),f=n?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,r.jsxs)("div",{"data-testid":"file-tab-".concat(t.path),"data-active":n,onClick:d,onAuxClick:x,onContextMenu:m,className:"flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ".concat(f),children:[(0,r.jsx)("span",{className:"truncate max-w-[120px]",title:t.path,children:t.name}),t.isDirty&&(0,r.jsx)("span",{"data-testid":"file-tab-dirty-".concat(t.path),className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:c("fileTabs.unsavedChanges")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":c("fileTabs.closeTab",{name:t.name}),children:(0,r.jsx)(ew.A,{className:"w-3 h-3"})})]})}),iq=(0,s.memo)(function(e){var t,n,a;let{tabs:l,activeIndex:c,worktreeId:d,onClose:u,onActivate:m,onLoadContent:x,onLoadError:f,onSetLoading:h,onFileSaved:p,onDirtyChange:g,onMoveToFront:b,onOpenFile:v}=e,y=(0,i.c)("worktree"),[j,w]=(0,s.useState)(!1),k=(0,s.useRef)(null),N=(0,s.useRef)(null),C=(0,s.useRef)({x:0,y:0}),[S,I]=(0,s.useState)({x:0,y:0}),{menuState:T,openMenu:E,openMenuAt:A,closeMenu:M}=n_(),[R,L]=(0,s.useState)(null),P=null!==c&&c>=0&&c<l.length?l[c]:null,D=l.length>5?l.slice(0,5):l,F=l.length>5?l.slice(5):[];(0,s.useEffect)(()=>{if(!j)return;let e=e=>{k.current&&!k.current.contains(e.target)&&w(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[j]),(0,s.useLayoutEffect)(()=>{let e=e=>{C.current=e,I(t=>t.x===e.x&&t.y===e.y?t:e)};if(!j)return void e({x:0,y:0});let t=N.current;if(!t)return;let n=t.getBoundingClientRect();e({x:iK(n.left-C.current.x,n.width,window.innerWidth),y:iK(n.top-C.current.y,n.height,window.innerHeight)})},[j]);let O=(0,s.useCallback)(e=>{w(!1),null==b||b(e)},[b]),z=(0,s.useCallback)(()=>{w(e=>!e)},[]),_=(0,s.useCallback)(e=>{for(let t=e.length-1;t>=0;t--)u(e[t])},[u]),B=(0,s.useCallback)((e,t)=>{let n=iH(l,t,e);if(0===n.length)return;let a=new Set(n);if(l.some(e=>e.isDirty&&a.has(e.path)))return void L({mode:e,anchorPath:t});_(n)},[l,_]),V=T.targetPath,H=(0,s.useMemo)(()=>V?[{id:"close-all-tabs",label:y("fileTabs.closeAll"),icon:(0,r.jsx)(ip.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("all",V),disabled:0===l.length},{id:"close-other-tabs",label:y("fileTabs.closeOthers"),icon:(0,r.jsx)(ig.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("others",V),disabled:0===iH(l,V,"others").length},{id:"close-tabs-to-right",label:y("fileTabs.closeToRight"),icon:(0,r.jsx)(ib.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("right",V),disabled:0===iH(l,V,"right").length}]:[],[V,l,B,y]),U=(0,s.useCallback)((e,t)=>{E(e,t,"file")},[E]),K=null!=(a=null!=(n=null==P?void 0:P.path)?n:null==(t=l[0])?void 0:t.path)?a:null,W=(0,s.useCallback)(e=>{if(!K)return;let t=e.currentTarget.getBoundingClientRect();A({x:t.left,y:t.bottom},K,"file")},[K,A]),q=R?iH(l,R.anchorPath,R.mode):[],$=q.filter(e=>{var t;return null==(t=l.find(t=>t.path===e))?void 0:t.isDirty}),G=(0,s.useCallback)(()=>L(null),[]);return(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,r.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:D.map((e,t)=>(0,r.jsx)(iW,{tab:e,isActive:t===c,onActivate:m,onClose:u,onOpenMenu:U},e.path))}),F.length>0&&(0,r.jsxs)("div",{className:"relative flex-shrink-0",ref:k,children:[(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:z,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,r.jsx)(es.A,{className:"w-3 h-3 transition-transform ".concat(j?"rotate-180":"")}),(0,r.jsxs)("span",{children:["+",F.length]})]}),j&&(0,r.jsx)("div",{ref:N,"data-testid":"tab-dropdown-menu",className:"absolute right-0 top-full mt-1 bg-surface border border-border rounded-md shadow-lg z-50 min-w-[200px] max-h-[300px] overflow-y-auto",style:0!==S.x||0!==S.y?{transform:"translate(".concat(S.x,"px, ").concat(S.y,"px)")}:void 0,children:F.map(e=>(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-item-".concat(e.path),onClick:()=>O(e.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:e.path,children:[e.name,e.isDirty&&(0,r.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},e.path))})]}),l.length>0&&(0,r.jsx)("button",{type:"button","data-testid":"tab-actions-button",onClick:W,"aria-haspopup":"menu","aria-expanded":T.isOpen,"aria-label":y("fileTabs.tabActions"),title:y("fileTabs.tabActions"),className:"flex-shrink-0 flex items-center px-2 py-2 text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:(0,r.jsx)(o.A,{className:"w-4 h-4"})})]}),(0,r.jsx)(nG,{isOpen:T.isOpen,position:T.position,targetPath:T.targetPath,targetType:T.targetType,onClose:M,items:H,ariaLabel:y("fileTabs.tabActions")}),(0,r.jsxs)(tF.a,{isOpen:null!==R,onClose:G,title:y("fileTabs.confirmCloseTitle"),size:"sm",children:[(0,r.jsx)("p",{"data-testid":"file-tabs-close-confirm-body",className:"text-sm text-foreground",children:y("fileTabs.confirmCloseBody",{count:$.length})}),(0,r.jsx)("ul",{className:"mt-2 max-h-32 overflow-y-auto text-sm text-muted-foreground",children:$.map(e=>(0,r.jsx)("li",{className:"truncate",title:e,children:e},e))}),(0,r.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,r.jsx)(eq.$,{variant:"ghost",size:"sm","data-testid":"file-tabs-close-cancel",onClick:G,children:y("fileTabs.confirmCancel")}),(0,r.jsx)(eq.$,{variant:"secondary",size:"sm","data-testid":"file-tabs-close-keep-unsaved",onClick:()=>{let e=new Set($);_(q.filter(t=>!e.has(t))),L(null)},children:y("fileTabs.confirmKeepUnsaved")}),(0,r.jsx)(eq.$,{variant:"danger",size:"sm","data-testid":"file-tabs-close-discard",onClick:()=>{_(q),L(null)},children:y("fileTabs.confirmDiscard")})]})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:P&&(0,r.jsx)(iz,{tab:P,worktreeId:d,onLoadContent:x,onLoadError:f,onSetLoading:h,onFileSaved:p,onDirtyChange:g,onOpenFile:v},P.path)})]})}),i$=(0,s.memo)(function(e){let{line:t}=e,n="whitespace-pre font-mono text-xs leading-5";return t.startsWith("+")&&!t.startsWith("+++")?n+=" text-success-foreground bg-success-subtle":t.startsWith("-")&&!t.startsWith("---")?n+=" text-danger-foreground bg-danger-subtle":t.startsWith("@@")?n+=" text-info bg-info/10":t.startsWith("diff --git")||t.startsWith("index ")||t.startsWith("---")||t.startsWith("+++")?n+=" text-muted-foreground":n+=" text-foreground",(0,r.jsx)("div",{className:n,children:t})}),iG=(0,s.memo)(function(e){let{diff:t,filePath:n,onClose:a}=e,s=(0,i.c)("worktree");return(0,r.jsxs)("div",{className:"h-full flex flex-col bg-surface",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-muted shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-accent-600 dark:text-accent-400 shrink-0",children:s("diffViewer.badge")}),(0,r.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:n})]}),(0,r.jsx)("button",{type:"button",onClick:a,className:"p-1 text-muted-foreground hover:text-foreground rounded shrink-0","aria-label":s("diffViewer.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-2",children:(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:t.split("\n").map((e,t)=>(0,r.jsx)(i$,{line:e},t))})})})]})}),iJ="commandmate.worktree.filePanelCollapsed",iY="worktree-file-panel",iQ=(0,s.createContext)({tabCount:0,hasDiff:!1}),iX="commandmate:filePanelStateChange";function iZ(){let[e,t]=(0,s.useState)(!1),n=(0,s.useRef)(e);n.current=e,(0,s.useEffect)(()=>{t(function(){try{let e=window.localStorage.getItem(iJ);if("true"===e)return!0}catch(e){}return!1}())},[]),(0,s.useEffect)(()=>{let e=e=>{e.detail&&e.detail.collapsed!==n.current&&t(e.detail.collapsed)};return window.addEventListener(iX,e),()=>window.removeEventListener(iX,e)},[]);let a=(0,s.useCallback)(e=>{t(e);try{window.localStorage.setItem(iJ,String(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(iX,{detail:{collapsed:e}}))}catch(e){}},[]);return{collapsed:e,toggle:(0,s.useCallback)(()=>{a(!n.current)},[a]),setCollapsed:a}}let i0=(0,s.memo)(function(e){let{terminal:t,terminalHeader:n,fileTabs:a,worktreeId:l,onCloseTab:i,onActivateTab:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,diffContent:x,diffFilePath:f,onCloseDiff:h,onDirtyChange:p,onMoveToFront:g,onOpenFile:b}=e,v=(0,s.useRef)(null),[y,j]=(0,s.useState)(50),{collapsed:w}=iZ(),k=(0,s.useCallback)(e=>{let t=v.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let a=e/n*100;j(e=>Math.min(80,Math.max(20,e+a)))},[]),N=(0,s.useMemo)(()=>({width:"".concat(y,"%")}),[y]),C=(0,s.useMemo)(()=>({width:"".concat(100-y,"%")}),[y]),S=(0,s.useMemo)(()=>({tabCount:a.tabs.length,hasDiff:!!(x&&f)}),[a.tabs.length,x,f]),I=(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[n,(0,r.jsx)("div",{className:"flex-1 min-h-0",children:t})]});return a.tabs.length>0||x&&f?w?(0,r.jsx)(iQ.Provider,{value:S,children:(0,r.jsx)("div",{ref:v,className:"flex h-full min-h-0",children:(0,r.jsx)("div",{"data-testid":"terminal-pane",style:{width:"100%"},className:"flex-shrink-0 overflow-hidden",children:I})})}):(0,r.jsx)(iQ.Provider,{value:S,children:(0,r.jsxs)("div",{ref:v,className:"flex h-full min-h-0",children:[(0,r.jsx)("div",{"data-testid":"terminal-pane",style:N,className:"flex-shrink-0 overflow-hidden",children:I}),(0,r.jsx)(lQ.f,{onResize:k,orientation:"horizontal",ariaValueNow:y}),(0,r.jsx)("div",{id:iY,"data-testid":"file-panel-pane",style:C,className:"flex-grow overflow-hidden flex",children:(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:x&&f&&h?(0,r.jsx)(iG,{diff:x,filePath:f,onClose:h}):(0,r.jsx)(iq,{tabs:a.tabs,activeIndex:a.activeIndex,worktreeId:l,onClose:i,onActivate:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,onDirtyChange:p,onMoveToFront:g,onOpenFile:b})})})]})}):(0,r.jsx)(iQ.Provider,{value:S,children:(0,r.jsx)("div",{className:"h-full",children:I})})}),i1=(0,s.createContext)(!1),i2=i1.Provider;var i4=n(7125),i5=n(22509),i3=n(54485),i6=n(55412);let i8=[.5,.5],i9={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]},i7=new Set(eo.XH);function oe(e){return"".concat("commandmate:terminalSplits:").concat(e)}function ot(e){return"object"==typeof e&&null!==e}function on(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}function oa(e){return void 0===e||!!Array.isArray(e)&&2===e.length&&e.every(on)}function or(e,t){let n=e+t;if(!Number.isFinite(n)||n<=0)return[1,1];let a=Math.min(e,t);return!Number.isFinite(a)||a<=0?[1,1]:[e/a,t/a]}function os(e){let t=e[0];return t?{splits:[{cliToolId:t.cliTool,instanceId:t.id}],widths:[1]}:{splits:i9.splits.map(e=>({...e})),widths:[...i9.widths]}}function ol(e){let t=e.reduce((e,t)=>e+t,0);return t>0?e.map(e=>e/t):e.map(()=>1/e.length)}function oi(e){if(4===e.splits.length)return oa(e.rowHeights)&&void 0!==e.rowHeights?e:{...e,rowHeights:[...i8]};if(void 0===e.rowHeights)return e;let{rowHeights:t,...n}=e;return n}function oo(e,t){let n;if(0===t.length)return e;let a=new Map(t.map(e=>[e.id,e.cliTool])),r=new Set,s=Math.min(Math.max(e.splits.length,1),t.length,4),l=[];for(let t of e.splits){if(l.length>=s)break;let e=a.get(t.instanceId);e&&!r.has(t.instanceId)&&(r.add(t.instanceId),l.push({cliToolId:e,instanceId:t.instanceId}))}for(let e of t){if(l.length>=s)break;r.has(e.id)||(r.add(e.id),l.push({cliToolId:e.cliTool,instanceId:e.id}))}return(0===l.length&&l.push({cliToolId:t[0].cliTool,instanceId:t[0].id}),l.length===e.splits.length&&l.every((t,n)=>t.instanceId===e.splits[n].instanceId&&t.cliToolId===e.splits[n].cliToolId))?e:(n=l.length===e.widths.length?ol(e.widths):l.length<e.widths.length?ol(e.widths.slice(0,l.length)):Array.from({length:l.length},()=>1/l.length),oi({...e,splits:l,widths:n}))}function oc(e,t,n){let a=function(e,t){try{let n=window.localStorage.getItem(oe(e));if(!n)return os(t);let a=JSON.parse(n),r=function(e){if(!ot(e))return null;let{splits:t,widths:n,rowHeights:a}=e;if(!Array.isArray(t)||!Array.isArray(n)||t.length<1||t.length>4||n.length!==t.length)return null;let r=[];for(let e of t){if(!ot(e))return null;let t=e.cliToolId;if("string"!=typeof t||!i7.has(t))return null;let n=e.instanceId,a="string"==typeof n&&(0,eo.n6)(n)?n:t;r.push({cliToolId:t,instanceId:a})}for(let e of n)if(!on(e))return null;let s={splits:r,widths:n};return 4===r.length&&void 0!==a&&oa(a)&&(s.rowHeights=[...a]),s}(a);if(r)return oi({...r,widths:ol(r.widths)});return console.warn("[useTerminalSplits] stale state for ".concat(e,"; falling back to default")),os(t)}catch(n){return console.warn("[useTerminalSplits] failed to parse stored state for ".concat(e,"; using default"),n),os(t)}}(e,t);return n?oo(a,t):a}var od=n(81507);let ou=(0,s.memo)(function(e){var t,n,a,l;let{worktreeId:o,instances:c,rosterReady:d=!0,renderPane:u,onFocusedSplitChange:m,showToast:x,onActiveInstanceChange:f,headerInstanceSelection:h}=e,{splits:p,widths:g,rowHeights:b,setRowHeights:v,addSplit:y,removeSplit:j,setSplitInstance:w,setSplitWidth:k,resetWidths:N,availableInstanceIds:C,focusedSplitIndex:S,setFocusedSplitIndex:I,maximizedIndex:T,toggleMaximize:E}=function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],[a,r]=(0,s.useState)(()=>oc(e,t,n)),[l,i]=(0,s.useState)(0),[o,c]=(0,s.useState)(null),d=(0,s.useRef)(a);d.current=a;let u=(0,s.useRef)(t);u.current=t;let m=(0,s.useRef)(n);m.current=n;let x=(0,s.useRef)(e);(0,s.useEffect)(()=>{x.current!==e&&(x.current=e,r(oc(e,u.current,m.current)),i(0),c(null))},[e]);let f=(0,s.useMemo)(()=>t.map(e=>"".concat(e.id,":").concat(e.cliTool)).join("|"),[t]);(0,s.useEffect)(()=>{n&&r(e=>oo(e,u.current))},[f,n]);let h=(0,s.useRef)(e);(0,s.useEffect)(()=>{if(h.current!==e){h.current=e;return}try{window.localStorage.setItem(oe(e),JSON.stringify(a))}catch(e){}},[a,e]);let p=(0,s.useCallback)(()=>{c(null),r(e=>{if(e.splits.length>=4)return e;let t=new Set(e.splits.map(e=>e.instanceId)),n=function(e,t){for(let n of e)if(!t.has(n.id))return n;return null}(u.current,t);if(!n)return e;let a=[...e.splits,{cliToolId:n.cliTool,instanceId:n.id}];if(4===a.length)return oi({...e,splits:a,widths:Array.from({length:4},()=>.25)});let r=e.widths.length-1,s=e.widths[r]/2,l=[...e.widths];return l[r]=s,l.push(s),oi({...e,splits:a,widths:l})})},[]),g=(0,s.useCallback)(()=>{c(null),r(e=>{if(e.splits.length<=1)return e;let t=e.splits.slice(0,-1),n=ol(e.widths.slice(0,-1));return oi({...e,splits:t,widths:n})})},[]);(0,s.useEffect)(()=>{i(e=>{let t=a.splits.length-1;return e>t?t:e<0?0:e}),c(e=>null!==e&&e>a.splits.length-1?null:e)},[a.splits.length]);let b=(0,s.useCallback)((e,t)=>{let n=d.current,a=u.current;if(e<0||e>=n.splits.length)return!1;let s=a.find(e=>e.id===t);if(!s||n.splits[e].instanceId===t)return!1;for(let a=0;a<n.splits.length;a++)if(a!==e&&n.splits[a].instanceId===t)return!1;return r(n=>{if(e<0||e>=n.splits.length||n.splits[e].instanceId===t)return n;for(let a=0;a<n.splits.length;a++)if(a!==e&&n.splits[a].instanceId===t)return n;let a=n.splits.map((n,a)=>a===e?{cliToolId:s.cliTool,instanceId:t}:n);return{...n,splits:a}}),!0},[]),v=(0,s.useCallback)(e=>{r(t=>e.length!==t.widths.length||!function(e){if(!Array.isArray(e))return!1;for(let t of e)if("number"!=typeof t||!Number.isFinite(t)||t<=0)return!1;return!0}(e)?t:{...t,widths:[...e]})},[]),y=(0,s.useCallback)(()=>{c(null),r(e=>{let t=e.splits.length;if(0===t)return e;let n=Array.from({length:t},()=>1/t);return 4===t?{...e,widths:n,rowHeights:[...i8]}:oi({...e,widths:n})})},[]),j=(0,s.useCallback)(e=>{r(t=>4!==t.splits.length?t:Array.isArray(e)&&2===e.length&&oa(e)?{...t,rowHeights:[...e]}:t)},[]),w=(0,s.useCallback)(e=>{let n=new Set;for(let t=0;t<a.splits.length;t++)t!==e&&n.add(a.splits[t].instanceId);return t.filter(e=>!n.has(e.id)).map(e=>e.id)},[a.splits,t]),k=(0,s.useCallback)(e=>{i(e)},[]),N=(0,s.useMemo)(()=>{var e;return(e=a.rowHeights)&&oa(e)?[...e]:[...i8]},[a.rowHeights]),C=(0,s.useCallback)(e=>{e<0||e>=d.current.splits.length||c(t=>t===e?null:e)},[]);return{splits:a.splits,widths:a.widths,rowHeights:N,setRowHeights:j,addSplit:p,removeSplit:g,setSplitInstance:b,setSplitWidth:v,resetWidths:y,availableInstanceIds:w,focusedSplitIndex:l,setFocusedSplitIndex:k,maximizedIndex:o,toggleMaximize:C}}(o,c,d),A=(0,s.useMemo)(()=>{let e=new Map;for(let t of c)e.set(t.id,t);return e},[c]),M=(0,i.c)("worktree"),{visible:R,toggle:L,setWidth:P}=(0,od.TG)(),{collapsed:D,toggle:F}=iZ(),O=!D,z=(0,s.useRef)(null),[_,B]=(0,s.useState)(!1),V=(0,s.useRef)(p.length),[H,U]=(0,s.useState)(null);(0,s.useEffect)(()=>{p.length>V.current&&U(p.length-1),V.current=p.length},[p.length]),(0,s.useEffect)(()=>{null==m||m(S)},[S,m]);let K=(0,s.useRef)(0),W=(0,s.useRef)(p);W.current=p,(0,s.useEffect)(()=>{if(!h||h.token===K.current)return;K.current=h.token;let{instanceId:e}=h,t=W.current.findIndex(t=>t.instanceId===e);if(0!==t){if(t>0)return void I(t);w(0,e)&&I(0)}},[h,w,I]),(0,s.useEffect)(()=>{if(null===H)return;let e=z.current;if(!e)return;let t=e.querySelector('[data-split-index="'.concat(H,'"]'));if(!t)return;let n=t.querySelector("textarea");null==n||n.focus(),I(H),U(null)},[H,I]);let q=(0,s.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=g.reduce((e,t)=>e+t,0),s=t/a*r,l=[...g],i=l[e]+s,o=l[e+1]-s,c=.05*r;i<c||o<c||(l[e]=i,l[e+1]=o,k(l))},[g,k]),$=or(null!=(t=g[0])?t:1,null!=(n=g[1])?n:1),G=or(null!=(a=b[0])?a:1,null!=(l=b[1])?l:1),J=(0,s.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=g[0]+g[1];if(!(r>0))return;let s=t/a*r,l=g[0]+s,i=g[1]-s,o=.05*r;l<o||i<o||k([l,i,l,i])},[g,k]),Y=(0,s.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetHeight;if(0===a)return;let r=b[0]+b[1];if(!(r>0))return;let s=t/a*r,l=b[0]+s,i=b[1]-s,o=.05*r;l<o||i<o||v([l,i])},[b,v]),Q=(0,s.useCallback)(()=>B(!0),[]),X=(0,s.useCallback)(()=>B(!1),[]),Z=(0,s.useCallback)(()=>{N(),P(od.sg)},[N,P]),ee=p.length<4&&!_,et=p.length>1&&!_,en=p.length>1||R,ea=null!==T,er=p.length>1,es=4===p.length,ec=(0,s.useCallback)(()=>{E(null!=T?T:S)},[E,T,S]),ed=M(ea?"terminal.restoreSplits":"terminal.maximizeFocusedSplit"),em="".concat(ed," — ").concat(M("terminal.maximizeShortcutHint")),{tabCount:ex,hasDiff:ef}=(0,s.useContext)(iQ),eh=0===ex&&!ef,ep="".concat(M(R?"terminal.hideHistory":"terminal.showHistory")," — ").concat(M("terminal.historyAllSplitsHint")),eg=M(eh?"terminal.filesEmptyHint":O?"terminal.hideFiles":"terminal.showFiles"),eb=(0,s.useMemo)(()=>p.map((e,t)=>(0,od.Ce)(t)).join(" "),[p]),ev=(0,s.useMemo)(()=>p.map((e,t)=>()=>I(t)),[p,I]),ey=(0,s.useMemo)(()=>p.map((e,t)=>e=>w(t,e)),[p,w]),ej=(0,s.useMemo)(()=>p.map((e,t)=>()=>E(t)),[p,E]),ew=(0,s.useMemo)(()=>p.map((e,t)=>e=>{var n,a;let r=(0,eo.sw)(null!=(a=A.get(e))?a:{cliTool:"claude",alias:e});if((null==(n=p[t])?void 0:n.instanceId)===e)return;let s=p.findIndex((n,a)=>a!==t&&n.instanceId===e);if(-1!==s){null==x||x("".concat(r," is already in use by split ").concat(s+1),"warning");return}w(t,e)&&(null==f||f(e),null==x||x("Moved ".concat(r," to Split ").concat(t+1),"success"))}),[p,w,x,f,A]);return(0,r.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{"data-testid":"split-count-label",className:"text-xs text-muted-foreground tabular-nums mr-1 truncate",children:ea?M("terminal.maximizedStatus",{split:(null!=T?T:0)+1}):"".concat(p.length," / ").concat(4," splits")}),(0,r.jsx)(eu.m_,{content:M("terminal.addSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:y,disabled:!ee,"aria-disabled":!ee,"aria-label":M("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,r.jsx)(rk.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(eu.m_,{content:M("terminal.removeSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:j,disabled:!et,"aria-disabled":!et,"aria-label":M("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,r.jsx)(i4.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(eu.m_,{content:M("terminal.equalizeWidthsHint"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:Z,disabled:!en,"aria-disabled":!en,"aria-label":M("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,r.jsx)(i5.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,r.jsx)(eu.m_,{content:em,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:ec,disabled:!er,"aria-disabled":!er,"aria-pressed":ea,"aria-label":ed,"data-testid":"toggle-maximize-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:ea?(0,r.jsx)(el.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}):(0,r.jsx)(ei.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,r.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,r.jsx)(eu.m_,{content:ep,placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{type:"button",onClick:L,"aria-pressed":R,"aria-expanded":R,"aria-controls":eb,"aria-label":M(R?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap text-xs px-2 py-0.5 rounded border transition-colors ".concat(R?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"),children:[(0,r.jsx)(i3.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:M("terminal.historyLabel")})]})}),(0,r.jsx)(eu.m_,{content:eg,placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{type:"button",onClick:F,disabled:eh,"aria-disabled":eh,"aria-pressed":O,"aria-expanded":O,"aria-controls":iY,"aria-label":M(O?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap text-xs px-2 py-0.5 rounded border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ".concat(O?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"),children:[(0,r.jsx)(i6.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:M("terminal.filesLabel")}),ex>0&&(0,r.jsx)("span",{"data-testid":"open-files-count",className:"ml-0.5 min-w-[1.25rem] px-1 rounded-full bg-muted text-[10px] leading-4 text-muted-foreground tabular-nums text-center",children:ex})]})})]}),(0,r.jsxs)("div",{ref:z,"data-testid":"terminal-split-layout","data-layout":es?"grid":"row",className:es?"grid flex-1 min-h-0 w-full overflow-y-auto":"flex flex-1 min-h-0 w-full",style:es?{gridTemplateColumns:ea?"1fr":"".concat($[0],"fr ").concat(4,"px ").concat($[1],"fr"),gridTemplateRows:ea?"1fr":"minmax(".concat(280,"px, ").concat(G[0],"fr) ").concat(4,"px minmax(").concat(280,"px, ").concat(G[1],"fr)")}:void 0,children:[p.map((e,t)=>{var n;let a=t===p.length-1,l=null!==T&&T!==t,i=T===t;return(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"split-wrapper-".concat(t),"data-hidden":l?"true":void 0,style:es?{gridColumn:i||t%2==0?1:3,gridRow:i||t<2?1:3,minWidth:0,minHeight:0,...l?{display:"none"}:null}:{flexGrow:i?1:null!=(n=g[t])?n:1,flexShrink:1,flexBasis:0,minWidth:0,...l?{display:"none"}:null},className:"h-full",children:(0,r.jsx)(i2,{value:l,children:u({splitIndex:t,cliToolId:e.cliToolId,instanceId:e.instanceId,instance:A.get(e.instanceId),availableInstances:C(t).map(e=>A.get(e)).filter(e=>void 0!==e),onInstanceChange:ey[t],onFocus:ev[t],isFocused:S===t,onDropInstance:ew[t],isMaximized:i,onToggleMaximize:ej[t]})})}),es||a?null:(0,r.jsx)(om,{resizerIdx:t,hidden:null!==T,ariaValueNow:g.length?g[t]/g.reduce((e,t)=>e+t,0)*100:50,onResize:q,onStart:Q,onEnd:X,onDoubleClick:N})]},"split-".concat(t))}),es?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(om,{resizerIdx:0,testId:"split-grid-column-resizer",gridArea:{gridColumn:2,gridRow:"1 / span 3"},hidden:ea,ariaValueNow:g[0]/(g[0]+g[1])*100,onResize:J,onStart:Q,onEnd:X,onDoubleClick:N}),(0,r.jsx)(om,{resizerIdx:0,testId:"split-grid-row-resizer",orientation:"vertical",gridArea:{gridColumn:"1 / span 3",gridRow:2},hidden:ea,ariaValueNow:b[0]/(b[0]+b[1])*100,onResize:Y,onStart:Q,onEnd:X,onDoubleClick:N})]}):null]})]})});function om(e){let{resizerIdx:t,ariaValueNow:n,onResize:a,onStart:l,onEnd:i,onDoubleClick:o,hidden:c=!1,orientation:d="horizontal",testId:u,gridArea:m}=e,x=(0,s.useCallback)(e=>a(t,e),[t,a]);return(0,r.jsx)("div",{"data-testid":null!=u?u:"split-resizer-".concat(t),style:{...m,...c?{display:"none"}:null},onMouseDownCapture:l,onTouchStartCapture:l,onMouseUpCapture:i,onTouchEndCapture:i,children:(0,r.jsx)(lQ.f,{onResize:x,orientation:d,ariaValueNow:n,onDoubleClick:o})})}var ox=n(52771),of=n(88894),oh=n(49509);let op="BTab",og=(0,s.memo)(function(e){var t,n;let{worktreeId:a,cliToolId:l,instanceId:o,agentMode:c,sessionStatus:d,isPromptWaiting:u,isSelectionListActive:m,isDismissablePanelActive:x,isUnclassifiedActive:f,onKeysSent:h}=e,p=(0,i.c)("worktree"),g=(0,s.useId)(),{activeKey:b,markPressed:v}=(0,oh.t)(),y=(0,t3.B)(a,l,o,h),j=(0,s.useMemo)(()=>{var e;return"ready"===(e={sessionStatus:d,isPromptWaiting:u,isSelectionListActive:m,isDismissablePanelActive:x,isUnclassifiedActive:f}).sessionStatus&&!e.isPromptWaiting&&!e.isSelectionListActive&&!e.isDismissablePanelActive&&!e.isUnclassifiedActive},[d,u,m,x,f]),w=(0,s.useCallback)(()=>{j&&(v(op),y([op]))},[j,v,y]);if(!(l&&ox.AO.includes(l)))return null;let k=(0,ox.PD)(c),N=null!=(n=null==(t=(0,of.h)(l))?void 0:t.noteId)?n:null,C=N?p("agentMode.note.".concat(N)):null,S=N?p("agentMode.noteShort.".concat(N)):null,I=k?p("agentMode.mode.".concat(c)):null;return(0,r.jsxs)("div",{className:"grid grid-flow-col grid-cols-[max-content] auto-cols-[minmax(0,max-content)] items-center gap-1","data-testid":"agent-mode-control",children:[(0,r.jsx)("button",{type:"button",onClick:w,disabled:!j,className:"min-w-[44px] px-2 py-1 rounded-full border text-xs font-medium transition-colors\n disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent\n ".concat(b===op?"border-accent-500 bg-accent-500 text-white":"border-border text-muted-foreground hover:text-accent-600 hover:border-accent-400 dark:hover:text-accent-400"),"aria-label":k?p("agentMode.cycleFromAria",{mode:I}):p("agentMode.cycleAria"),title:null!=C?C:void 0,"aria-describedby":C?g:void 0,"data-testid":"agent-mode-cycle-button","data-agent-mode":c,"data-enabled":String(j),children:(0,r.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,r.jsx)("span",{children:p("agentMode.label")}),(0,r.jsx)("span",{className:"hidden @min-[400px]:inline opacity-60","data-testid":"agent-mode-key-notation",children:"shift+tab"})]})}),k||C?(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden","data-testid":"agent-mode-captions",children:[k?(0,r.jsx)("span",{className:"min-w-0 truncate px-2 py-1 rounded-full bg-muted text-xs text-muted-foreground","data-testid":"agent-mode-chip","data-agent-mode":c,children:I}):null,C?(0,r.jsx)("span",{"aria-hidden":"true",title:C,className:"min-w-0 truncate px-2 py-1 rounded-full border border-warning-border bg-warning-subtle text-xs text-warning-foreground","data-testid":"agent-mode-note",children:S}):null]}):null,C?(0,r.jsx)("span",{id:g,className:"sr-only",children:C}):null]})});function ob(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:l,onClose:o}=e,c=(0,i.c)("worktree"),d=(0,s.useRef)(null),{send:u,error:m}=eI(t,n,a,l);(0,s.useEffect)(()=>{var e;null==(e=d.current)||e.focus()},[]);let x=(0,s.useCallback)(e=>{let t=function(e){if(!0===e.isComposing||229===e.keyCode||e.metaKey||e.altKey)return null;if("Tab"===e.key)return e.ctrlKey?null:{type:"key",key:e.shiftKey?"BTab":"Tab"};if(e.ctrlKey){if(1!==e.key.length)return null;let t="C-".concat(e.key.toLowerCase());return eC(t)?{type:"key",key:t}:null}let t=eS[e.key];return void 0!==t?{type:"key",key:t}:1==[...e.key].length?{type:"text",text:e.key}:null}(e.nativeEvent);null!==t&&(e.preventDefault(),u([t]))},[u]),f=(0,s.useCallback)(e=>{let t=e.data;t&&u([{type:"text",text:t}]),d.current&&(d.current.value="")},[u]),h=(0,s.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text");t&&u(function(e){let t=e.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),n=[];for(let e=0;e<t.length;e+=4096)n.push({type:"text",text:t.slice(e,e+4096)});return n}(t))},[u]);return(0,r.jsxs)("div",{"data-testid":"direct-input-bar",role:"region","aria-label":c("directInput.toggleAria"),className:"flex flex-wrap items-center gap-2 px-2 py-1.5 bg-info-subtle border border-info-border rounded-lg",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-info-foreground shrink-0",children:c("directInput.notice")}),(0,r.jsx)("input",{ref:d,type:"text","data-testid":"direct-input-capture",placeholder:c("directInput.placeholder"),"aria-label":c("directInput.placeholder"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,onKeyDown:x,onCompositionEnd:f,onPaste:h,className:"flex-1 min-w-[8rem] min-h-[32px] px-2 rounded-md font-mono text-xs bg-surface border border-info-border text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-close",onClick:o,"aria-label":c("directInput.close"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-surface border border-info-border text-info-foreground hover:bg-muted transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background shrink-0",children:c("directInput.close")}),m?(0,r.jsx)("p",{role:"alert","data-testid":"direct-input-error",className:"w-full text-xs text-danger-foreground",children:c(m)}):null]})}let ov="\n px-6 py-2 rounded-lg font-medium transition-all\n disabled:opacity-50 disabled:cursor-not-allowed\n focus:outline-none focus:ring-2 focus:ring-offset-2\n".trim(),oy="bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",oj="bg-surface border-2 border-input hover:bg-muted text-foreground focus:ring-ring";function ow(e){}function ok(e){var t,n;let{promptData:a,answering:l,onRespond:o,decisionId:c,onDismiss:u,labelId:m,cliToolName:x,answerable:f}=e,h=(0,i.c)("prompt"),{selectedOption:p,setSelectedOption:g,checkedNumbers:b,textInputValue:v,setTextInputValue:y,multiSelectOptions:j,takesTypedText:w,isBusy:k,isDisabled:N,handleToggleOption:C,handleYesNoClick:I,handleMultipleChoiceSubmit:T,handleMultiSelectSubmit:E,handleDecisionRespond:A}=_({promptData:a,answering:l,answerable:f,send:(0,s.useCallback)(e=>o(e,c),[o,c]),onError:ow,canRespondDecision:!!c}),M=(t=a,n=c,(0,R.ds)({...t,decisionId:null!=n?n:null})),L=S(a)?a:null,P=null===L?a:null;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h3",{id:m,className:"text-lg font-semibold text-warning-foreground flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xl","aria-hidden":"true",children:"?"}),x?h("confirmationFrom",{toolName:x}):h("confirmationFromClaude")]}),u&&(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:u,"aria-label":"close",className:"p-1 rounded hover:bg-warning-border/50 transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5 text-warning-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(null==L?void 0:L.instructionText)&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-muted-foreground bg-muted rounded p-2 border border-border",children:L.instructionText}),"multiple_choice"===a.type&&a.askUserQuestion&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ask-user-question-progress",children:a.askUserQuestion.questionCount>1?h("askUserQuestionProgress",{index:a.askUserQuestion.questionIndex+1,total:a.askUserQuestion.questionCount}):h("askUserQuestionSource")}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:O(h,M.heading)}),k&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[(0,r.jsx)(d.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:h("sending")})]}),"yes_no"===a.type&&(0,r.jsx)(oT,{promptData:a,disabled:N,onYes:()=>I("yes"),onNo:()=>I("no")}),"multiple_choice"===a.type&&null!==j&&(0,r.jsx)(oA,{promptData:a,disabled:N,checkedNumbers:b,onToggleOption:C,textInputValue:v,onTextInputChange:y,showTextInput:w,onSubmit:E}),"multiple_choice"===a.type&&null===j&&(0,r.jsx)(oE,{promptData:a,disabled:N,selectedOption:p,onSelectOption:g,textInputValue:v,onTextInputChange:y,showTextInput:w,onSubmit:T}),P&&(0,r.jsx)(oN,{promptData:P,view:M,viewSource:{...P,decisionId:M.decisionId},disabled:N,onRespond:A})]})}function oN(e){var t,n,a,s,l;let{promptData:o,view:c,viewSource:d,disabled:u,onRespond:m}=e,x=(0,i.c)("prompt"),f="approval"===c.apiTarget&&null!=(n=o.decisionOptions)?n:null,h="question"===c.apiTarget?(0,R.zM)(d):null;return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"unclassified-prompt-notice",children:[o.message&&o.message.includes("\n")?(0,r.jsx)("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-all rounded border border-border bg-muted p-2 font-mono text-xs text-foreground","data-testid":"structured-decision-message",children:o.message}):o.message?(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:o.message}):null,o.askUserQuestion&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"unclassified-ask-user-question",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:o.askUserQuestion.question}),h?(0,r.jsx)(oI,{choices:h,disabled:u,onRespond:m}):(0,r.jsx)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:o.askUserQuestion.labels.map(e=>(0,r.jsx)("li",{children:e},e))})]}),h?null:f&&f.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(oC,{toolName:null!=(a=o.toolName)?a:null,patterns:null!=(s=o.patterns)?s:null,allowAlwaysLabel:null!=(l=null==(t=f.find(e=>"always"===e.reply))?void 0:t.label)?l:null}),(0,r.jsx)(oS,{options:f,disabled:u,onRespond:m})]}):(0,r.jsx)("p",{className:"text-sm text-foreground",children:x("unclassifiedInstruction",{command:x("unclassifiedRespondCommand")})})]})}function oC(e){let{toolName:t,patterns:n,allowAlwaysLabel:a}=e,s=null!==n&&n.length>0;return t||s?(0,r.jsxs)("div",{className:"space-y-1","data-testid":"structured-decision-subject",children:[t&&(0,r.jsx)("p",{className:"text-sm font-medium text-foreground font-mono break-all","data-testid":"structured-decision-tool",children:t}),s&&(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a&&(0,r.jsx)("span",{"data-testid":"structured-decision-patterns-label",children:a}),(0,r.jsx)("ul",{className:"mt-0.5 flex flex-wrap gap-1","data-testid":"structured-decision-patterns",children:n.map(e=>(0,r.jsx)("li",{className:"font-mono break-all bg-muted border border-border rounded px-1.5 py-0.5",children:e},e))})]})]}):null}function oS(e){let{options:t,disabled:n,onRespond:a}=e,s=(0,i.c)("prompt");return(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":s("selectAnOption"),"data-testid":"structured-decision-actions",children:t.map(e=>(0,r.jsxs)(d.$n,{variant:"ghost",type:"button",disabled:n,onClick:()=>a(String(e.number)),"data-testid":"structured-decision-option-".concat(e.number),className:"".concat(ov," ").concat(3===e.number?oj:oy),children:[e.number,". ",e.label]},e.number))})}function oI(e){let{choices:t,disabled:n,onRespond:a}=e,l=(0,i.c)("prompt"),o=(0,s.useId)(),[c,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(""),f=t.custom?U(m):null,h=!0===t.custom&&K(m),p=(0,s.useCallback)(e=>{let t=c===e,a=n?"opacity-50 cursor-not-allowed":"";return"".concat("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all"," ").concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(a)},[c,n]);return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"structured-question-actions",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:l("selectAnOption")}),(0,r.jsx)(d.z6,{name:o,value:null!=c?String(c):"",onValueChange:e=>{u(Number(e)),x("")},disabled:n,className:"flex flex-col gap-2",children:t.labels.map((e,t)=>(0,r.jsxs)("label",{className:p(t+1),children:[(0,r.jsx)(d.CU,{value:String(t+1),className:"mt-1"}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsxs)("span",{className:"font-medium",children:[t+1,". ",e]})})]},"".concat(t+1,"-").concat(e)))})]}),t.custom&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"free-text-".concat(o),className:"block text-sm text-muted-foreground mb-1",children:l("freeTextLabel")}),(0,r.jsx)("input",{id:"free-text-".concat(o),"data-testid":"structured-question-free-text",type:"text",value:m,maxLength:1e3,onChange:e=>{x(e.target.value),""!==e.target.value&&u(null)},disabled:n,placeholder:l("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-input dark:bg-muted dark:text-foreground rounded-lg focus:outline-none focus:border-accent-500 disabled:opacity-50"}),h&&(0,r.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":"structured-question-free-text-numeric",children:l("freeTextNumericHint")})]}),(0,r.jsx)("button",{type:"button","data-testid":"structured-question-submit",onClick:()=>{null!==f?a(f):null!==c&&a(String(c))},disabled:n||null===c&&null===f,className:"w-full ".concat(ov," ").concat(oy),children:l("submit")})]})}function oT(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,i.c)("prompt"),o="yes"===t.defaultOption,c="no"===t.defaultOption,u="".concat(ov," ").concat(oy," ").concat(o?"primary default highlighted":""),m="".concat(ov," ").concat(c?"bg-foreground text-background hover:bg-foreground/90 primary default highlighted":oj);return(0,r.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:a,disabled:n,className:u,children:l("yes")}),(0,r.jsx)(d.$n,{variant:"ghost",type:"button",onClick:s,disabled:n,className:m,children:l("no")})]})}function oE(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:l,textInputValue:o,onTextInputChange:c,showTextInput:u,onSubmit:m}=e,x=(0,s.useId)(),f=(0,i.c)("prompt"),h=(0,s.useCallback)(e=>{let t=a===e,r=n?"opacity-50 cursor-not-allowed":"";return"".concat("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all"," ").concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(r)},[a,n]);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:f("selectAnOption")}),(0,r.jsx)(d.z6,{name:x,value:null!=a?String(a):"",onValueChange:e=>l(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>(0,r.jsxs)("label",{className:h(e.number),children:[(0,r.jsx)(d.CU,{value:String(e.number),className:"mt-1","aria-describedby":e.isDefault?"default-".concat(e.number):void 0}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{id:"default-".concat(e.number),className:"ml-2 text-xs text-accent-600 dark:text-accent-400 bg-accent-100 dark:bg-accent-900/30 px-2 py-0.5 rounded",children:f("default")}),e.description&&(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e.description})]})]},e.number))})]}),u&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:o,onChange:e=>c(e.target.value),disabled:n,placeholder:f("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-input dark:bg-muted dark:text-foreground rounded-lg focus:outline-none focus:border-accent-500 disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:m,disabled:n||null===a,className:"w-full ".concat(ov," ").concat(oy),children:f("submit")})]})}function oA(e){let{promptData:t,disabled:n,checkedNumbers:a,onToggleOption:l,textInputValue:o,onTextInputChange:c,showTextInput:u,onSubmit:m}=e,x=(0,s.useId)(),f=(0,i.c)("prompt"),h=(0,s.useCallback)(e=>{let t=n?"opacity-50 cursor-not-allowed":"";return"".concat("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all"," ").concat(e?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(t)},[n]),p=0===a.length,g=u&&""===o.trim();return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"multi-select-prompt-actions",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"multi-select-hint",children:f("multiSelectHint")}),(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:f("selectAllThatApply")}),(0,r.jsx)("div",{role:"group","aria-label":f("selectAllThatApply"),className:"flex flex-col gap-2",children:t.options.map(e=>{let t=a.includes(e.number);return(0,r.jsxs)("label",{className:h(t),children:[(0,r.jsx)(d.Sc,{checked:t,onCheckedChange:t=>l(e.number,!0===t),disabled:n,className:"mt-1","data-testid":"multi-select-option-".concat(e.number),"aria-label":"".concat(e.number,". ").concat(e.label)}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.description&&(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e.description})]})]},e.number)})})]}),u&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"multi-text-input-".concat(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"multi-text-input-".concat(x),type:"text",value:o,onChange:e=>c(e.target.value),disabled:n,placeholder:f("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-input dark:bg-muted dark:text-foreground rounded-lg focus:outline-none focus:border-accent-500 disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button","data-testid":"multi-select-submit",onClick:m,disabled:n||p||g,className:"w-full ".concat(ov," ").concat(oy),children:f("submit")})]})}let oM=(0,s.memo)(function(e){let t,{promptData:n,messageId:a,decisionId:l,visible:i,answering:o,onRespond:c,onDismiss:d,cliToolName:u,showStuckHint:m,onSwitchToDirectInput:x,answerable:f,autoYesEnterSent:h}=e,{shouldRender:p,animationClass:g}=E({visible:i&&null!==n,duration:200}),b=(0,s.useId)();if(!p||!n)return null;let v=(t="opacity-100","animate-fade-in"===g?t="opacity-100 transform translate-y-0":"animate-fade-out"===g&&(t="opacity-0 transform translate-y-2"),"".concat("bg-warning-subtle border-2 border-warning-border rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out"," ").concat(g," ").concat(t));return(0,r.jsx)(I.t,{componentName:"PromptPanel",children:(0,r.jsxs)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":b,"aria-modal":"true",className:v,children:[(0,r.jsx)(ok,{promptData:n,answering:o,onRespond:c,decisionId:l,onDismiss:d,labelId:b,cliToolName:u,answerable:f}),(0,r.jsx)(W,{showStuckHint:m,onSwitchToDirectInput:x,answerable:f,autoYesEnterSent:h,linkClassName:"underline font-medium hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-warning-border rounded"})]})})});var oR=n(1962),oL=n(35619),oP=n(93141);let oD=(0,s.memo)(function(e){var t,n,a;let{worktreeId:l,cliToolId:o,instanceId:c,diff:u,disabled:m=!1}=e,x=(0,i.c)("worktree"),f=(0,d.SC)(),[h,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),j=(null==u?void 0:u.revertedMessageId)!=null,w=(0,s.useMemo)(()=>{var e,t;return j?null!=(e=null==u?void 0:u.revertedFiles)?e:[]:null!=(t=null==u?void 0:u.files)?t:[]},[j,u]),k=(0,s.useCallback)(async e=>{b(null),p(e);try{let t=await fetch("/api/worktrees/".concat(l,"/opencode/diff"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,instanceId:null!=c?c:o})}),n=await t.json().catch(()=>({}));if(409===t.status&&"SESSION_BUSY"===n.code)return void b("busy");if(!t.ok)return void b("failed");!1===n.applied&&b("noop")}catch(e){b("failed")}finally{p(null)}},[l,o,c]),N=(0,s.useCallback)(async()=>{await f({title:x("opencodeDiff.revertConfirmTitle"),description:x("opencodeDiff.revertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.revertConfirmLabel"),variant:"danger"})&&await k("revert")},[f,x,w.length,k]),C=(0,s.useCallback)(async()=>{await f({title:x("opencodeDiff.unrevertConfirmTitle"),description:x("opencodeDiff.unrevertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.unrevertConfirmLabel")})&&await k("unrevert")},[f,x,w.length,k]);return"opencode"!==o?null:u&&(u.files.length>0||u.revertedFiles.length>0)?(0,r.jsxs)("div",{className:"border-t border-border bg-muted/30 px-3 py-2 text-xs","data-testid":"opencode-turn-diff-panel",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(oL.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:j?x("opencodeDiff.revertedTitle"):x("opencodeDiff.title")}),(0,r.jsx)("span",{className:"text-muted-foreground",children:j?x("opencodeDiff.revertedSubtitle",{count:w.length}):x("opencodeDiff.subtitle",{count:w.length})}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1",children:[null!==h?(0,r.jsx)(d.y$,{size:"sm"}):null,j?(0,r.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:C,disabled:m||null!==h,children:[(0,r.jsx)(oP.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),x("opencodeDiff.unrevert")]}):(0,r.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:N,disabled:m||null!==h,children:[(0,r.jsx)(ar.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),x("opencodeDiff.revert")]})]})]}),null!==g?(0,r.jsx)("p",{className:"mt-1 text-danger-foreground",role:"status",children:x("opencodeDiff.".concat(g))}):null,(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:w.map((e,t)=>{var n,a;let s=null!=(n=e.file)?n:x("opencodeDiff.unnamedFile"),l=function(e){let t=[];return e.additions>0&&t.push("+".concat(e.additions)),e.deletions>0&&t.push("−".concat(e.deletions)),t.join(" ")}(e);return(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[null!==e.patch&&null!==e.file?(0,r.jsx)("button",{type:"button",className:"truncate text-info underline-offset-2 hover:underline",onClick:()=>y(e),title:x("opencodeDiff.openDiff",{file:s}),children:s}):(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:s}),null!==e.status?(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:x("opencodeDiff.status.".concat(e.status))}):null,""!==l?(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:l}):null]},"".concat(null!=(a=e.file)?a:"unnamed","-").concat(t))})}),(0,r.jsx)(d.Jh,{isOpen:null!==v,onClose:()=>y(null),title:null!=(t=null==v?void 0:v.file)?t:void 0,size:"xl",children:null!==v?(0,r.jsx)(iG,{diff:null!=(n=v.patch)?n:"",filePath:null!=(a=v.file)?a:"",onClose:()=>y(null)}):null})]}):null});var oF=n(2954),oO=n(63881),oz=n(8355);function o_(e,t,n,a){let r={answer:e,cliTool:t};if(a&&a!==t&&(r.instanceId=a),n&&(r.promptType=n.type,"multiple_choice"===n.type)){let e=n.options.find(e=>e.isDefault);e&&(r.defaultOptionNumber=e.number),n.submitMode&&(r.submitMode=n.submitMode)}return r}function oB(e,t,n,a){return{decisionId:e,answer:t,cliTool:n,...a&&a!==n?{instanceId:a}:{}}}var oV=n(34419);function oH(e,t){let n=e.target instanceof Element?e.target:null,a=null==n?void 0:n.closest("[data-split-index]");if(a){if(Number(a.getAttribute("data-split-index"))!==t)return!1}else if(0!==t||(null==n?void 0:n.closest('input, textarea, select, [contenteditable="true"]')))return!1;return!0}let oU=(0,s.memo)(function(e){var t,n,a,l,o,c,d;let{worktreeId:u,splitIndex:m,cliToolId:x,instanceId:f,instance:h,availableInstances:p,onInstanceChange:g,onFocus:b,disabled:v=!1,pendingInsertText:y,onInsertConsumed:j,onMessageSent:w,cliStatus:k="idle",cliStatusUnclassified:N=!1,autoYes:C,history:I,onDropInstance:T,draggedInstanceId:E,onRequestSessionEnd:A,agentModel:M,onAgentSessionChange:L,isMaximized:P=!1,onToggleMaximize:D}=e,F=null!=f?f:x,O=null!=(n=C.enabled)&&n,_=null!=(a=C.expiresAt)?a:null,B=null!=(l=C.lastAutoResponse)?l:null,H=C.onToggle,U=null!=(o=null==I?void 0:I.showArchived)&&o,K=null==I?void 0:I.onShowArchivedChange,W=null==I?void 0:I.historyDisplayLimit,q=null==I?void 0:I.onHistoryDisplayLimitChange,$=null!=(c=null==I?void 0:I.historyUserOnly)&&c,G=null==I?void 0:I.onHistoryUserOnlyChange,J=null==I?void 0:I.onInsertToMessage,Y=null==I?void 0:I.onFilePathClick,Q=null==I?void 0:I.showToast,X=(0,i.c)("worktree"),Z=(0,ty.Ym)(),[ee,et]=(0,s.useState)(null),[ea,er]=(0,s.useState)(null),es=(0,oO.b4)(ee,ea,oz.LA),el=(0,s.useMemo)(()=>(0,oz.h0)(m),[m]),{surfaceMode:ei,handleSurfaceModeChange:ec}=nE((0,s.useMemo)(()=>(0,nT.$2)(u,m),[u,m])),ed=(0,s.useRef)(ei);ed.current=ei,(0,s.useEffect)(()=>{function e(e){e.shiftKey&&!e.altKey&&(e.metaKey||e.ctrlKey)&&"m"===e.key.toLowerCase()&&oH(e,m)&&(e.preventDefault(),ec("chat"===ed.current?"terminal":"chat"))}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m,ec]);let em=(0,s.useRef)(D);em.current=D,(0,s.useEffect)(()=>{function e(e){if(!e.shiftKey||e.altKey||!e.metaKey&&!e.ctrlKey||"Enter"!==e.key||!oH(e,m))return;let t=em.current;t&&(e.preventDefault(),t())}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m]);let{terminal:ex,prompt:ef,agentSession:eh,setAutoScroll:ep,setPromptAnswering:eg,clearPrompt:eb,refresh:ey}=(0,no.NK)({worktreeId:u,cliToolId:x,instanceId:F,enabled:!v}),ej=(0,t5.Bj)((0,t5.qi)(u,F),ex.startingSince),ek=ej.starting,[eN,eC]=(0,s.useState)(!1);(0,s.useEffect)(()=>{eC(!1)},[u,x,F]),(0,s.useEffect)(()=>{ex.isRunning||eC(!1)},[ex.isRunning]);let eS=X("directInput.toggle"),eI=X("directInput.toggleAria"),eT=(0,s.useCallback)(()=>{eC(e=>!e)},[]),eE=(0,s.useCallback)(()=>{eC(!1)},[]),eA=ef.visible&&!ek&&(!O||z(ef.data,ef.answerable)),eM=(0,s.useContext)(i1),eR=eA&&!eM,{showStuckHint:eL,markSubmitted:eP}=(0,oR.Cb)({promptData:eR?ef.data:null,targetKey:"".concat(u,":").concat(x,":").concat(F)}),eD=(0,s.useCallback)(()=>{eC(!0)},[]),{messages:eF,isLoading:eO,refresh:ez}=(0,nc.Md)({worktreeId:u,cliToolId:x,instanceId:F,limit:W,includeArchived:U,enabled:!v}),{messages:e_,sendOptimistic:eB,retry:eV,discard:eH}=nm({worktreeId:u,serverMessages:eF,onSent:ez}),{visible:eU,width:eq,toggle:e$,setWidth:eG}=(0,od.TG)(),eJ=s.useRef(null),eY=(0,s.useCallback)(e=>{let t=eJ.current;if(!t)return;let n=t.offsetWidth;0!==n&&eG(eq+e/n*100)},[eq,eG]),eQ="opencode"===x||"copilot"===x,{compactTuiLayoutPadding:eX,preservePaintedPanelRows:eZ}=(0,s.useMemo)(()=>(0,nI.EK)(x),[x]),e0=(0,s.useCallback)(e=>ep(e),[ep]),e1=(0,s.useCallback)(e=>{ey(),ez(),null==w||w(e)},[ey,ez,w]),e2=nx(eH,J),e4=(0,s.useCallback)(async(e,t)=>{let n;eP(),eg(!0);try{let a=t?oB(t,e,x,F):o_(e,x,S(ef.data)?ef.data:null,F),r=await fetch(t?"/api/worktrees/".concat(u,"/respond"):"/api/worktrees/".concat(u,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});n=await (0,oV.a_)(r)}catch(e){console.error("[TerminalSplitPaneContent] prompt response error:",e),n="failed"}try{if("answered"===n)eb();else{let e=oV.J4[n];null==Q||Q(X(e.messageKey),e.type)}await ey()}finally{eg(!1)}},[u,x,F,ef.data,eg,eb,ey,Q,X,eP]),e5=(0,s.useCallback)(()=>{eb()},[eb]),e3="chat"===ei,e6=ex.isSelectionListActive,e8=e6&&!e3&&!ek,e9="running"===ex.sessionStatus&&!N,e7=null!=(d=null==(t=(0,R.ds)(ef.data))?void 0:t.decisionId)?d:null,te=(0,s.useMemo)(()=>V(ef.data,x),[ef.data,x]),tt=ex.isUnclassifiedActive&&!e6&&!ef.visible&&!e3&&!ek,tn=t6(ex.composerText),ta=na(x,ex.realtimeSnippet||ex.output),tr=(0,s.useMemo)(()=>({messages:e_,worktreeId:u,onFilePathClick:null!=Y?Y:()=>{},isLoading:eO,className:"h-full",showToast:Q,onInsertToMessage:J,onRetryPending:eV,onDiscardPending:e2,showArchived:U,onShowArchivedChange:K,historyDisplayLimit:W,onHistoryDisplayLimitChange:q,historyUserOnly:$,onHistoryUserOnlyChange:G,splitIndex:m,cliToolId:x}),[e_,eV,e2,u,Y,eO,Q,J,U,K,W,q,$,G,m,x]),ts=(0,s.useMemo)(()=>(0,r.jsx)(nO.bl,{...tr,onCollapse:e$}),[tr,e$]),tl=(0,s.useMemo)(()=>ej.noticeVisible&&null!==ej.startingSince?(0,r.jsx)(t4.TE,{cliToolId:x,startingSince:ej.startingSince,onShowTerminal:ej.revealTerminal}):(0,r.jsx)(t1.D,{output:ex.output,isActive:ex.isRunning,attaching:ex.attaching,isThinking:ex.isThinking,autoScroll:ex.autoScroll,onScrollChange:e0,disableAutoFollow:eQ,compactTuiLayoutPadding:eX,preservePaintedPanelRows:eZ}),[ej.noticeVisible,ej.revealTerminal,ej.startingSince,x,ex.output,ex.isRunning,ex.attaching,ex.isThinking,ex.autoScroll,e0,eQ,eX,eZ]),ti=ni(ex,ef),to=e3&&(0,nl.BM)(ti,ex.output,x),tc=(0,s.useMemo)(()=>(0,r.jsx)("div",{"data-testid":"split-chat-slot-".concat(m),"aria-label":X("surfaceMode.chatSurfaceLabel"),className:"flex h-full min-h-0 w-full overflow-hidden bg-surface text-surface-foreground",children:(0,r.jsx)("div",{className:"min-w-0 min-h-0 flex-1 overflow-hidden",children:(0,r.jsx)(nl.wY,{messages:tr.messages,worktreeId:u,cliToolId:x,instanceId:F,history:tr,live:ti,onSurfaceModeChange:ec,frame:ex.output,onKeysSent:ey})})}),[tr,m,X,u,x,F,ti,ex.output,ey,ec]),td=(0,s.useMemo)(()=>eU?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:(0,nO.Ce)(m),"data-testid":"split-history-slot-".concat(m),"aria-label":"History pane",style:{width:"".concat(eq,"%")},className:"flex-shrink-0 overflow-hidden min-h-0",children:ts}),(0,r.jsx)(lQ.f,{onResize:eY,orientation:"horizontal",ariaValueNow:eq})]}):null,[eU,eq,ts,eY,m]),tu=(0,s.useMemo)(()=>(0,r.jsxs)("div",{ref:eJ,"data-testid":"split-terminal-row-".concat(m),className:"flex h-full min-h-0 w-full",children:[td,(0,r.jsx)("div",{"data-testid":"split-terminal-slot-".concat(m),style:eU?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0 relative",children:tl})]}),[eU,td,tl,m]),tm=(0,s.useMemo)(()=>(0,r.jsxs)("div",{ref:eJ,"data-testid":"split-chat-row-".concat(m),className:"flex h-full min-h-0 w-full",children:[td,(0,r.jsx)("div",{"data-testid":"split-chat-output-".concat(m),style:eU?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0",children:tc})]}),[eU,td,tc,m]),tx=(0,s.useMemo)(()=>(0,r.jsxs)("div",{ref:er,className:"space-y-2","data-testid":"split-footer-".concat(m),children:[e8?(0,r.jsx)(eW.Z,{worktreeId:u,cliToolId:x,instanceId:F,onKeysSent:ey,frame:ex.output,surface:"terminal",showPagerKeys:ex.isPagerActive}):null,tt?(0,r.jsx)(t2.U,{worktreeId:u,cliToolId:x,instanceId:F,onKeysSent:ey}):null,tn?(0,r.jsx)(t8,{worktreeId:u,cliToolId:x,instanceId:F,composerText:ex.composerText,onActionSent:ey}):null,ta?(0,r.jsx)(nr,{cliToolId:x,frame:ex.realtimeSnippet||ex.output}):null,eA?(0,r.jsx)(oM,{promptData:te,messageId:ef.messageId,decisionId:e7,visible:ef.visible,answering:ef.answering,onRespond:e4,onDismiss:e5,cliToolName:(0,eo.oo)(x),showStuckHint:eL,onSwitchToDirectInput:ex.isRunning?eD:void 0,answerable:ef.answerable,autoYesEnterSent:ef.autoYesEnterSent}):null,ex.isRunning&&!to?(0,r.jsx)(ns.XU,{worktreeId:u,cliToolId:x,instanceId:F,hasAgentSession:null!==eh.session,onKeysSent:ey,collapsible:!0,layout:"desktop"}):null,(0,r.jsx)(oD,{worktreeId:u,cliToolId:x,instanceId:F,diff:eh.diff,disabled:!ex.isRunning}),eN?(0,r.jsx)(ob,{worktreeId:u,cliToolId:x,instanceId:F,onKeysSent:ey,onClose:eE}):null,(0,r.jsx)(eK.E,{worktreeId:u,onMessageSent:e1,onOptimisticSend:eB,cliToolId:x,instanceId:F,isSessionRunning:ex.isRunning,isSessionStarting:ek,pendingInsertText:null!=y?y:null,onInsertConsumed:j,splitIndex:m,onFocus:b,heightScope:el,maxHeight:es,isProcessing:e9,showToast:Q,agentModeSlot:(0,r.jsx)(og,{worktreeId:u,cliToolId:x,instanceId:F,agentMode:ex.agentMode,sessionStatus:ex.sessionStatus,isPromptWaiting:ef.visible,isSelectionListActive:ex.isSelectionListActive,isDismissablePanelActive:ex.isDismissablePanelActive,isUnclassifiedActive:ex.isUnclassifiedActive,onKeysSent:ey}),autoYesSlot:(0,r.jsx)(oF.T,{enabled:O,expiresAt:null!=_?_:null,onToggle:H,lastAutoResponse:null!=B?B:null,cliToolName:x,inline:!0}),directInputSlot:(0,r.jsxs)("button",{type:"button","data-testid":"direct-input-toggle","aria-pressed":eN,"aria-label":eI,title:eI,disabled:!ex.isRunning,onClick:eT,className:"shrink-0 inline-flex items-center gap-1 h-[22px] px-1 @min-[520px]:px-2 rounded-md border text-[11px] font-medium leading-none whitespace-nowrap transition-colors disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(eN?"bg-info-subtle border-info-border text-info-foreground":"bg-surface border-border text-muted-foreground hover:bg-muted"),children:[(0,r.jsx)(en.A,{size:14,"aria-hidden":"true",className:"shrink-0"}),(0,r.jsx)("span",{className:"hidden @min-[520px]:inline","data-testid":"direct-input-toggle-label",children:eS})]})})]}),[e8,eA,tt,tn,ta,ex.realtimeSnippet,ex.output,eh.session,to,ex.composerText,ex.agentMode,ex.sessionStatus,ex.isSelectionListActive,ex.isDismissablePanelActive,ex.isUnclassifiedActive,ex.isPagerActive,u,x,F,ey,te,ef.messageId,e7,ef.visible,ef.answering,ef.answerable,ef.autoYesEnterSent,e4,e5,eL,eD,e1,eB,ex.isRunning,ek,e9,y,j,m,b,O,_,B,H,eN,eT,eE,eS,eI,Q,el,es,eh.diff]),tf=(0,eo.sw)(null!=h?h:{cliTool:x}),th=(0,s.useCallback)(()=>{null==A||A({cliToolId:x,instanceId:F,label:tf})},[A,x,F,tf]),tp=(0,s.useMemo)(()=>{if(!A||!ex.isRunning)return null;let e=X("terminal.endSessionFor",{name:tf});return(0,r.jsx)(eu.m_,{content:e,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:th,"aria-label":e,"data-testid":"terminal-end-session-button-".concat(m),className:"flex items-center justify-center p-0.5 rounded text-muted-foreground hover:text-danger focus:text-danger hover:bg-danger/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-danger/50 transition-colors",children:(0,r.jsx)(ew.A,{size:14,"aria-hidden":"true"})})})},[A,ex.isRunning,X,tf,th,m]);(0,s.useEffect)(()=>{null==L||L(F,eh)},[L,F,eh]);let{model:tg,usage:tb,usageDetail:tv}=nA(M,eh,X,Z);return(0,r.jsx)(ev,{worktreeId:u,splitIndex:m,cliToolId:x,instanceId:F,instance:h,availableInstances:p,onInstanceChange:g,headerExtras:tp,status:k,statusUnclassified:N,agentModel:tg,agentUsage:tb,agentUsageDetail:tv,onFocus:b,attaching:ex.attaching,surfaceMode:ei,onSurfaceModeChange:ec,isMaximized:P,onToggleMaximize:D,terminal:"chat"===ei?tm:tu,footer:tx,bodyRef:et,onDropInstance:T,draggedInstanceId:E})}),oK=(0,s.memo)(function(e){var t;let{task:n,latestRun:a,latestRunGates:l,onOpen:o,className:c=""}=e,d=(0,i.c)("worktree"),[u,m]=(0,s.useState)(!1),x=(0,s.useRef)(null),f=(0,s.useId)(),h=function(e,t){var n;let a=(0,s.useRef)(null);return(null!==e&&t&&t.length>0&&(a.current={runId:e.id,gates:t}),t&&t.length>0)?t:null!==e&&(null==(n=a.current)?void 0:n.runId)===e.id?a.current.gates:null}(a,l),p=(0,s.useMemo)(()=>{let e=[n?d("verification.chip.taskReason",{title:n.title,status:d("task.status.".concat(n.status))}):d("verification.chip.noTask")];if(a){if(e.push(d("verification.chip.runReason",{verdict:d("verification.runStatus.".concat(a.status)),runId:a.id})),e.push(d("verification.runStatusGloss.".concat(a.status))),h&&h.length>0){let t=h.filter(e=>sf.includes(e.status));e.push(t.length>0?d("verification.chip.failingGates",{gates:t.map(e=>e.gateId).join(", ")}):d("verification.chip.gatesPassed",{count:h.length}))}}else e.push(d("verification.chip.noRun"));return e.push(d("verification.chip.openHint")),e},[n,a,h,d]),g=p.join(" \xb7 "),b=(0,s.useCallback)(()=>{m(!1),o()},[o]),v=(0,s.useCallback)(()=>{m(e=>!e)},[]);return(0,s.useEffect)(()=>{if(!u)return;let e=e=>{var t;null!=(t=x.current)&&t.contains(e.target)||m(!1)},t=e=>{"Escape"===e.key&&m(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[u]),(0,r.jsxs)("div",{ref:x,className:"relative inline-flex max-w-full ".concat(c).trim(),children:[(0,r.jsxs)("div",{className:"inline-flex min-w-0 max-w-full grow items-center gap-1 rounded-full border border-border bg-surface-2 pr-1 text-xs text-foreground",children:[(0,r.jsxs)("button",{type:"button",onClick:b,"data-testid":"verification-status-chip","aria-label":g,title:g,className:"inline-flex min-w-0 flex-1 items-center gap-1.5 rounded-full px-2 py-1 transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:[(0,r.jsx)(so.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"truncate font-medium","data-testid":"verification-chip-title",children:n?(t=n.title,t.length<=36?t:"".concat(t.slice(0,35),"…")):d("verification.title")}),n&&(0,r.jsx)(sc.E,{variant:su[n.status],className:"flex-shrink-0 px-1.5 py-0","data-testid":"verification-chip-task-status",children:d("task.status.".concat(n.status))}),(0,r.jsx)(sc.E,{variant:a?sm[a.status]:"gray",className:"flex-shrink-0 px-1.5 py-0 font-mono","data-testid":"verification-chip-run-status",children:a?d("verification.chip.resultBadge",{verdict:d("verification.runStatus.".concat(a.status))}):d("verification.chip.unverified")})]}),(0,r.jsx)("button",{type:"button",onClick:v,"data-testid":"verification-chip-reason-toggle","aria-expanded":u,"aria-controls":f,"aria-label":d(u?"verification.chip.hideReason":"verification.chip.showReason"),className:"inline-flex min-h-[32px] min-w-[32px] flex-shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:(0,r.jsx)(w.A,{size:14,"aria-hidden":"true"})})]}),u&&(0,r.jsxs)("div",{id:f,role:"tooltip","data-testid":"verification-chip-reason-popover",className:"absolute left-0 top-full z-50 mt-1 w-72 max-w-[80vw] rounded-lg border border-border bg-surface p-3 text-xs leading-relaxed text-foreground shadow-lg",children:[(0,r.jsx)("p",{className:"mb-1 font-semibold",children:d("verification.chip.reasonHeading")}),(0,r.jsx)("ul",{className:"space-y-1",children:p.map(e=>(0,r.jsx)("li",{className:"break-words",children:e},e))})]})]})}),oW=(0,s.memo)(function(e){let{isBranchMismatch:t,currentBranch:n,initialBranch:a}=e,l=(0,i.c)("worktree"),[o,c]=(0,s.useState)(!1);return((0,s.useEffect)(()=>{c(!1)},[n]),!t||o||null===a)?null:(0,r.jsxs)("div",{"data-testid":"branch-mismatch-alert",role:"alert",className:"flex items-center gap-3 px-4 py-2 bg-warning-subtle border border-warning-border text-warning-foreground rounded-lg",children:[(0,r.jsx)(rg.A,{className:"w-5 h-5 text-warning flex-shrink-0"}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsxs)("span",{className:"text-sm",children:[l("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:a})," ",l("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>c(!0),className:"p-1 rounded hover:bg-warning-subtle transition-colors","aria-label":l("branchMismatch.dismiss"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})});var oq=n(58734),o$=n(59847);let oG=(0,s.memo)(function(e){let{isOpen:t,onClose:n,onConfirm:a,worktreeId:l,sourcePath:o,sourceType:c}=e,u=(0,i.c)("worktree"),m=(0,i.c)("common"),[x,f]=(0,s.useState)(""),[h,p]=(0,s.useState)(new Set([""])),[g,b]=(0,s.useState)([]),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)(new Set),k=o.includes("/")?o.substring(0,o.lastIndexOf("/")):"";(0,s.useEffect)(()=>{t&&(f(k),p(new Set([""])),b([]),N())},[t,l]);let N=(0,s.useCallback)(async()=>{y(!0);try{let e=await fetch("/api/worktrees/".concat(l,"/tree"));if(!e.ok)return;let t=(await e.json()).items.filter(e=>"directory"===e.type).map(e=>({name:e.name,path:e.name,loaded:!1}));b(t)}catch(e){}finally{y(!1)}},[l]),C=(0,s.useCallback)(async e=>{w(t=>new Set(t).add(e));try{let t=await fetch("/api/worktrees/".concat(l,"/tree/").concat(e));if(!t.ok)return;let n=(await t.json()).items.filter(e=>"directory"===e.type).map(t=>({name:t.name,path:"".concat(e,"/").concat(t.name),loaded:!1}));b(t=>(function e(t,n,a){return t.map(t=>t.path===n?{...t,children:a,loaded:!0}:t.children?{...t,children:e(t.children,n,a)}:t)})(t,e,n))}catch(e){}finally{w(t=>{let n=new Set(t);return n.delete(e),n})}},[l]),S=(0,s.useCallback)(async e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});let t=function e(t,n){for(let a of t){if(a.path===n)return a;if(a.children){let t=e(a.children,n);if(t)return t}}return null}(g,e);t&&!t.loaded&&await C(e)},[g,C]),I=(0,s.useCallback)(e=>!(e===k||"directory"===c&&(e===o||e.startsWith(o+"/")))&&!0,[k,o,c]),T=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=h.has(e.path),a=x===e.path,s=j.has(e.path),l=I(e.path);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(a?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(l?"":"opacity-40 cursor-not-allowed"),style:{paddingLeft:"".concat(.5+1.25*t,"rem")},onClick:()=>{l&&f(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),S(e.path)},children:s?(0,r.jsx)(d.y$,{size:"xs",variant:"muted"}):(0,r.jsx)(rN.A,{className:"w-3 h-3 text-muted-foreground transition-transform ".concat(n?"rotate-90":"")})}),n?(0,r.jsx)(oq.A,{className:"w-4 h-4 text-warning flex-shrink-0"}):(0,r.jsx)(o$.A,{className:"w-4 h-4 text-warning flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.name})]}),n&&e.children&&(0,r.jsx)("div",{children:e.children.map(e=>T(e,t+1))})]},e.path)},E=I(x);return(0,r.jsx)(tF.a,{isOpen:t,onClose:n,title:u("fileTree.moveDialogTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:[u("fileTree.moveTo"),": ",(0,r.jsx)("span",{className:"font-mono text-foreground",children:o})]}),(0,r.jsxs)("div",{className:"border border-border rounded-lg max-h-64 overflow-y-auto p-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(""===x?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(I("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{I("")&&f("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(o$.A,{className:"w-4 h-4 text-warning flex-shrink-0"}),(0,r.jsx)("span",{children:u("fileTree.rootDirectory")})]}),v?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(d.y$,{size:"md",variant:"muted"})}):g.map(e=>T(e,1))]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(d.$n,{variant:"ghost",onClick:n,className:"px-4 py-2 text-sm text-foreground bg-white border border-border rounded-md hover:bg-muted transition-colors",children:m("cancel")}),(0,r.jsx)(d.$n,{variant:"ghost",onClick:()=>a(x),disabled:!E,className:"px-4 py-2 text-sm text-white bg-accent-600 rounded-md hover:bg-accent-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:u("fileTree.moveConfirm")})]})]})})});function oJ(e,t){let n=e.trim();return n?0>=n.lastIndexOf(".")?n+t:n:""}let oY=(0,s.memo)(function(e){let{isOpen:t,parentPath:n,onConfirm:a,onCancel:l}=e,o=(0,i.c)("worktree"),c=(0,i.c)("common"),[d,u]=(0,s.useState)(""),[m,x]=(0,s.useState)(".md"),f=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(t){u(""),x(".md");let e=setTimeout(()=>{var e;null==(e=f.current)||e.focus()},100);return()=>clearTimeout(e)}},[t]);let h=(0,s.useCallback)(()=>{let e=oJ(d,m);e&&a(e)},[d,m,a]),p=(0,s.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),h())},[h]),g=oJ(d,m),b=n?"".concat(n,"/").concat(g):g;return(0,r.jsx)(tF.a,{isOpen:t,onClose:l,title:o("newFileDialog.title"),size:"sm",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"new-file-name",className:"block text-sm font-medium text-foreground mb-1",children:o("newFileDialog.fileNameLabel")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{ref:f,id:"new-file-name","data-testid":"new-file-name-input",type:"text",value:d,onChange:e=>u(e.target.value),onKeyDown:p,placeholder:o("newFileDialog.placeholder"),className:"flex-1 px-3 py-2 border border-input rounded-lg bg-surface text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,r.jsx)("select",{"data-testid":"new-file-ext-select",value:m,onChange:e=>x(e.target.value),className:"px-3 py-2 border border-input rounded-lg bg-surface text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",children:e9.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),g&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-mono bg-muted rounded px-2 py-1",children:b}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:l,className:"px-4 py-2 text-sm font-medium text-foreground bg-muted hover:bg-muted/80 rounded-lg transition-colors",children:c("cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"new-file-confirm-button",onClick:h,disabled:!g,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",children:o("newFileDialog.create")})]})]})})}),oQ=(0,s.memo)(function(e){var t,n,a,l,o;let{worktreeId:c,worktree:d,worktreeName:u,worktreeStatus:m,instances:x,rosterReady:f,activeInstanceId:h,setActiveInstanceId:p,instanceSelectionRequest:g=null,onInstanceSelectionHandled:b,hasUpdate:v,lastAutoResponse:y,activeActivity:j,onActivityToggle:w,onActivityOpen:k,verification:N,onInfoClick:C,onWorktreeStatusChange:S,pendingInsertTextMap:T,setFocusedSplitIndex:E,handleInsertToSplit:A,handleInsertConsumed:M,handleInsertToMessage:R,autoYesStateMap:L,makeAutoYesToggleHandler:P,showArchived:D,onShowArchivedChange:F,historyDisplayLimit:O,onHistoryDisplayLimitChange:z,historyUserOnly:_,onHistoryUserOnlyChange:B,onMessageSent:V,onFilePathClick:H,showToast:U,tabsState:K,tabsActions:W,onLoadContent:q,onLoadError:$,onSetLoading:G,onFilePanelSave:J,onDirtyChange:Y,onOpenFile:Q,diffContent:X,diffFilePath:Z,onCloseDiff:ee,fileSearch:et,fileTreeRefresh:en,onFileSelect:ea,onNewFile:er,onNewDirectory:es,onRename:el,onDelete:ei,onUpload:eo,onMove:ec,onFileTreeReset:ed,onDiffSelect:eu,onAgentInstancesChange:em,vibeLocalModel:ex,onVibeLocalModelChange:ef,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ep,isInfoModalOpen:eg,onInfoModalClose:eb,onWorktreeUpdate:ev,fileInputRef:ey,onFileInputChange:ej,onKillSession:ew,onRequestSessionEnd:ek,killTarget:eN,isKillPending:eC,onKillCancel:eS,onKillConfirm:eI,moveTarget:eT,isMoveDialogOpen:eE,onMoveCancel:eA,onMoveConfirm:eM,showNewFileDialog:eR,newFileParentPath:eL,onNewFileConfirm:eP,onNewFileCancel:eD,killDialogTitle:eF,killDialogWarning:eO,cancelLabel:ez,endLabel:e_}=e,eB=(0,i.c)("worktree"),[eV,eH]=s.useState(null),eU=(0,s.useCallback)(e=>eH(e),[]),eK=(0,s.useCallback)(()=>eH(null),[]),eW=(0,s.useMemo)(()=>t$(null==d?void 0:d.sessionStatusByInstance),[null==d?void 0:d.sessionStatusByInstance]),[eq,e$]=(0,s.useState)({}),eG=(0,s.useCallback)((e,t)=>{e$(n=>n[e]===t?n:{...n,[e]:t})},[]),[eJ,eY]=s.useState(null),eQ=s.useRef(0),eX=(0,s.useCallback)(e=>{p(e),eQ.current+=1,eY({instanceId:e,token:eQ.current})},[p]),eZ=s.useRef(0);s.useEffect(()=>{g&&g.token!==eZ.current&&(eZ.current=g.token,eX(g.instanceId),null==b||b(g.token))},[g,eX,b]);let e0=(0,s.useCallback)(()=>{k("verification")},[k]),e1=(0,s.useCallback)(e=>{var t,n,a,s,l,i,o,u,m,x;let{splitIndex:f,cliToolId:h,instanceId:g,instance:b,availableInstances:v,onInstanceChange:j,onFocus:w,onDropInstance:k,isMaximized:N,onToggleMaximize:C}=e,S=null!=(o=T.get(f))?o:null,I=L.get(g),E=null!=(u=null==I?void 0:I.enabled)&&u,R=null!=(m=null==I?void 0:I.expiresAt)?m:null,K=null!=(x=null==d||null==(t=d.sessionStatusByInstance)?void 0:t[g])?x:null==d||null==(n=d.sessionStatusByCli)?void 0:n[h],W=(0,tO.kA)(K),q=(0,tO.px)(K);return(0,r.jsx)(oU,{worktreeId:c,splitIndex:f,cliToolId:h,instanceId:g,instance:b,availableInstances:v,onInstanceChange:e=>{j(e),0===f&&p(e)},onFocus:w,pendingInsertText:S,onInsertConsumed:()=>M(f),onMessageSent:V,cliStatus:W,cliStatusUnclassified:q,onAgentSessionChange:eG,agentModel:tU(null==d||null==(s=d.sessionStatusByInstance)||null==(a=s[g])?void 0:a.model,null==d||null==(i=d.sessionStatusByInstance)||null==(l=i[g])?void 0:l.reasoningEffort),autoYes:{enabled:E,expiresAt:R,lastAutoResponse:y,onToggle:P(h,g)},history:{showArchived:D,onShowArchivedChange:F,historyDisplayLimit:O,onHistoryDisplayLimitChange:z,historyUserOnly:_,onHistoryUserOnlyChange:B,onInsertToMessage:e=>A(f,e),onFilePathClick:H,showToast:U},onDropInstance:k,draggedInstanceId:eV,isMaximized:N,onToggleMaximize:C,onRequestSessionEnd:ek})},[c,T,L,M,V,p,y,P,null==d?void 0:d.sessionStatusByCli,null==d?void 0:d.sessionStatusByInstance,H,U,A,D,F,O,z,_,B,eV,ek,eG]),e2=(0,s.useMemo)(()=>(0,r.jsx)(ou,{worktreeId:c,instances:x,rosterReady:f,renderPane:e1,onFocusedSplitChange:E,showToast:U,onActiveInstanceChange:p,headerInstanceSelection:eJ}),[c,x,f,e1,E,U,p,eJ]),e4=(0,s.useMemo)(()=>(0,r.jsx)(i0,{terminal:e2,terminalHeader:null,fileTabs:K,worktreeId:c,onCloseTab:W.closeTab,onActivateTab:W.activateTab,onLoadContent:q,onLoadError:$,onSetLoading:G,onFileSaved:J,diffContent:X,diffFilePath:Z,onCloseDiff:ee,onDirtyChange:Y,onMoveToFront:W.moveToFront,onOpenFile:Q}),[e2,K,c,W.closeTab,W.activateTab,q,$,G,J,X,Z,ee,Y,W.moveToFront,Q]),e5=(0,s.useMemo)(()=>(0,r.jsx)(iu,{active:j,onToggle:w}),[j,w]),e3=(0,s.useMemo)(()=>{var e;return{files:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(au,{query:et.query,mode:et.mode,isSearching:et.isSearching,error:et.error,onQueryChange:et.setQuery,onModeChange:et.setMode,onClear:et.clearSearch}),(0,r.jsx)(al,{worktreeId:c,onFileSelect:ea,onNewFile:er,onNewDirectory:es,onRename:el,onDelete:ei,onUpload:eo,onMove:ec,onResetView:ed,refreshTrigger:en,pollingEnabled:"files"===j,searchQuery:et.query,searchMode:et.mode,searchResults:null==(e=et.results)?void 0:e.results,className:"flex-1 min-h-0"})]}),git:(0,r.jsx)(lG,{worktreeId:c,onDiffSelect:eu,isMobile:!1,worktree:null!=d?d:void 0,onInsertToMessage:R,className:"h-full"}),notes:(0,r.jsx)(av,{worktreeId:c,className:"h-full",onInsertToMessage:R}),schedules:(0,r.jsx)(ri,{worktreeId:c,className:"h-full",onInsertToMessage:R,instances:x}),agent:(0,r.jsx)(rF,{worktreeId:c,instances:x,onInstancesChange:em,vibeLocalModel:ex,onVibeLocalModelChange:ef,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ep,modelByInstance:eW,className:"h-full"}),timer:(0,r.jsx)(rW,{worktreeId:c,instances:x}),todo:(0,r.jsx)(aC,{worktreeId:c,className:"h-full"}),skills:(0,r.jsx)(sl,{worktreeId:c,className:"h-full"}),verification:(0,r.jsx)(sG,{state:N,className:"h-full"}),env:(0,r.jsx)(ld,{worktreeId:c,className:"h-full"})}},[c,d,j,et.query,et.mode,et.isSearching,et.error,et.setQuery,et.setMode,et.clearSearch,null==(t=et.results)?void 0:t.results,ea,er,es,el,ei,eo,ec,ed,en,eu,R,x,em,ex,ef,eh,ep,eW,N]),e6=(0,s.useMemo)(()=>null===j?null:(0,r.jsx)(ih,{active:j,activities:e3}),[j,e3]);return(0,r.jsx)(I.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex h-full overflow-hidden relative",children:[e5,(0,r.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 min-w-0",children:[(0,r.jsx)(tY,{worktreeName:u,repositoryName:null!=(l=null!=(a=null==d?void 0:d.repositoryDisplayName)?a:null==d?void 0:d.repositoryName)?l:eB("detail.unknownRepository"),description:null==d?void 0:d.description,status:m,gitStatus:null==d?void 0:d.gitStatus,onInfoClick:C,hasUpdate:v,worktreeStatus:null!=(o=null==d?void 0:d.status)?o:null,onWorktreeStatusChange:S,sessionStatusByCli:null==d?void 0:d.sessionStatusByCli,sessionStatusByInstance:null==d?void 0:d.sessionStatusByInstance,instances:x,activeInstanceId:h,onActiveInstanceChange:eX,onAgentDragStart:eU,onAgentDragEnd:eK,onKillSession:ew,agentSessionByInstance:eq,verificationChip:(0,r.jsx)(oK,{task:N.task,latestRun:N.latestRun,latestRunGates:null!==N.selectedRun&&N.selectedRun.id===(null==(n=N.latestRun)?void 0:n.id)?N.selectedRun.gates:null,onOpen:e0})}),(null==d?void 0:d.gitStatus)&&(0,r.jsx)(oW,{isBranchMismatch:d.gitStatus.isBranchMismatch,currentBranch:d.gitStatus.currentBranch,initialBranch:d.gitStatus.initialBranch}),(0,r.jsx)("div",{className:"flex-1 min-h-0 min-w-0",children:(0,r.jsx)(lX,{activityPane:e6,rightPane:(0,r.jsx)(lZ.cV,{terminal:e4})})})]}),(0,r.jsx)(tQ,{worktreeId:c,worktree:d,isOpen:eg,onClose:eb,onWorktreeUpdate:ev}),(0,r.jsx)("input",{ref:ey,type:"file",accept:e8.join(","),onChange:ej,className:"hidden","aria-label":eB("detail.uploadFile")}),(0,r.jsx)(tF.a,{isOpen:null!==eN,onClose:eS,title:eF,size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:eO}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:eS,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:ez}),(0,r.jsx)("button",{type:"button",onClick:eI,disabled:eC,"data-testid":"kill-session-confirm-button",className:"px-4 py-2 text-sm font-medium rounded-md bg-danger hover:bg-danger/90 text-white disabled:opacity-60 disabled:cursor-not-allowed",children:e_})]})]})}),eT&&(0,r.jsx)(oG,{isOpen:eE,onClose:eA,onConfirm:eM,worktreeId:c,sourcePath:eT.path,sourceType:eT.type}),(0,r.jsx)(oY,{isOpen:eR,parentPath:eL,onConfirm:eP,onCancel:eD})]})})});eo.oo;var oX=n(51434),oZ=n(68955);function o0(e,t){switch(t.type){case"SET_PHASE":return{...e,phase:t.phase};case"SHOW_PROMPT":return{...e,phase:"prompt",prompt:{data:t.data,messageId:t.messageId,visible:!0,answering:!1}};case"CLEAR_PROMPT":return{...e,prompt:{...ec.kQ}};case"SET_PROMPT_ANSWERING":return{...e,prompt:{...e.prompt,answering:t.answering}};case"SET_LAYOUT_MODE":return{...e,layout:{...e.layout,mode:t.mode}};case"SET_MOBILE_ACTIVE_PANE":return{...e,layout:{...e.layout,mobileActivePane:t.pane}};case"SET_SPLIT_RATIO":return{...e,layout:{...e.layout,splitRatio:t.ratio}};case"SET_LEFT_PANE_TAB":return{...e,layout:{...e.layout,leftPaneTab:t.tab}};case"TOGGLE_LEFT_PANE":return{...e,layout:{...e.layout,leftPaneCollapsed:!e.layout.leftPaneCollapsed}};case"SET_LEFT_PANE_COLLAPSED":return{...e,layout:{...e.layout,leftPaneCollapsed:t.collapsed}};case"SET_ACTIVE_ACTIVITY":return{...e,layout:{...e.layout,activityBar:{...e.layout.activityBar,active:t.activity}}};case"TOGGLE_ACTIVITY":{let n=e.layout.activityBar.active===t.activity?null:t.activity;return{...e,layout:{...e.layout,activityBar:{...e.layout.activityBar,active:n}}}}case"TOGGLE_HISTORY_PANE":{let t=!e.layout.historyPane.visible;return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,visible:t,collapsed:!t}}}}case"SET_HISTORY_PANE_VISIBLE":return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,visible:t.visible,collapsed:!t.visible}}};case"SET_HISTORY_WIDTH":return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,width:t.width}}};case"SET_ERROR":return{...e,error:t.error};case"CLEAR_ERROR":return{...e,error:{...ec.mS}};case"INCREMENT_RETRY_COUNT":return{...e,error:{...e.error,retryCount:e.error.retryCount+1}};case"SET_MESSAGES":return{...e,messages:t.messages};case"ADD_MESSAGE":return{...e,messages:[...e.messages,t.message]};case"UPDATE_MESSAGE":return{...e,messages:e.messages.map(e=>e.id===t.id?{...e,...t.updates}:e)};case"CLEAR_MESSAGES":return{...e,messages:[]};case"SET_WS_CONNECTED":return{...e,wsConnected:t.connected};default:return e}}function o1(e,t){try{window.localStorage.setItem(ir(e),null!=t?t:ia)}catch(e){}}function o2(e,t){if(e.length!==t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}function o4(e,t){return e instanceof Error&&e.message?e.message:t}function o5(e){return e instanceof DOMException&&"AbortError"===e.name}var o3=n(75477),o6=n(93493),o8=n(40153),o9=n(88731);let o7="commandmate:showArchived";var ce=n(7636),ct=n(72099);let cn="activeCliTab-",ca="activeInstanceId-",cr=Object.freeze({...o8.b,offersPlanApprove:!1}),cs=[2e3,5e3,1e4],cl={timeoutMs:iy.K3,retries:0},ci=(0,s.memo)(function(e){let{label:t}=e;return(0,r.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"worktree-detail-reconnecting-banner",className:"fixed top-2 left-1/2 z-50 flex -translate-x-1/2 items-center gap-2 rounded-full border border-warning-border bg-warning-subtle px-3 py-1 text-xs text-warning-foreground shadow-sm",children:[(0,r.jsx)(c.y,{size:"xs"}),(0,r.jsx)("span",{children:t})]})}),co=(0,s.memo)(function(e){let{message:t,loginLabel:n,onLogin:a}=e;return(0,r.jsx)("div",{className:"flex h-full min-h-[200px] items-center justify-center",role:"alert","aria-live":"assertive","data-testid":"worktree-detail-session-expired",children:(0,r.jsxs)("div",{className:"max-w-md rounded-lg border border-border bg-surface p-6 text-center",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:t}),(0,r.jsx)(eq.$,{variant:"primary",type:"button",onClick:a,className:"mt-4","data-testid":"worktree-detail-relogin",children:n})]})})}),cc=()=>{},cd=["terminal","history","files","memo","info"],cu=(0,s.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,onMessageSent:s,isSessionRunning:l,isSessionStarting:i,isProcessing:o,showToast:c,pendingInsertText:d,onInsertConsumed:u,autoYesSlot:m,agentModeSlot:x}=e,f=nb({cliToolId:n,instanceId:a});return(0,r.jsx)(eK.E,{worktreeId:t,onMessageSent:s,cliToolId:n,instanceId:a,isSessionRunning:l,isSessionStarting:i,isProcessing:o,showToast:c,pendingInsertText:d,onInsertConsumed:u,onOptimisticSend:f,autoYesSlot:m,agentModeSlot:x})}),cm=(0,s.memo)(function(e){var t,n,a,c,d,x,h,p,b,v,y,j,w,k;let{worktreeId:N}=e,{activeActivity:T,activeCliTab:E,activeInstanceId:A,activeTab:L,agentInstances:D,autoYesEnabled:F,autoYesExpiresAt:O,autoYesStateMap:_,diffContent:B,diffFilePath:H,disableAutoFollow:U,displayedInstances:K,error:W,fetchCurrentOutput:q,fileInputRef:G,fileSearch:J,fileTreeRefresh:Y,handleActivityOpen:Q,handleActivityToggle:X,handleAgentInstancesChange:Z,handleAutoYesToggle:ee,handleCloseDiff:et,handleDelete:en,handleDiffSelect:ea,handleDirtyChange:er,handleEditorSave:es,handleFileInputChange:el,handleFilePanelSave:ei,handleFilePathClick:ed,handleFileSelect:eu,handleHistoryDisplayLimitChange:ex,handleHistoryUserOnlyChange:ef,handleInfoClick:eh,handleInfoModalClose:ep,handleInsertConsumed:eg,handleInsertConsumedSingle:eb,handleInsertToMessage:ev,handleInsertToSplit:ey,handleKillCancel:ew,handleKillConfirm:ek,openKillConfirm:eN,openActiveKillConfirm:eC,killTarget:eS,isKillPending:eI,handleLoadContent:eT,handleLoadError:eE,handleMessageSent:eA,handleMobileFileViewerClose:eM,handleMobileTabChange:eR,handleMove:eL,handleMoveCancel:eP,handleMoveConfirm:eD,handleNewDirectory:eF,handleNewFile:eO,handleNewFileCancel:ez,handleNewFileConfirm:e_,handleOpenFile:eB,handlePromptDismiss:eV,handlePromptRespond:eH,handleRename:eK,handleReLogin:eq,handleRetry:e$,handleSetLoading:eJ,handleShowArchivedChange:eY,handleUpload:eQ,handleVibeLocalContextWindowChange:eX,handleVibeLocalModelChange:eZ,handleWorktreeStatusChange:e0,hasUpdate:e1,historyDisplayLimit:e2,historySubTab:e4,historyUserOnly:e5,isAuthExpired:e3,isInfoModalOpen:e9,isMobile:e7,isMoveDialogOpen:te,isReconnecting:tt,isSelectionListActive:tn,isPagerActive:ta,promptAnswerable:tr,promptAutoYesEnterSent:tl,selectionListReading:ti,isDismissablePanelActive:to,isUnclassifiedActive:tc,sessionStatus:td,agentMode:tu,startingSince:tm,lastAutoResponse:tx,loading:tf,makeAutoYesToggleHandler:th,mobileFileViewerPath:tp,mobileSelectedAgents:tg,moveTarget:tb,newFileParentPath:ty,openMobileDrawer:tj,pendingInsertText:tw,pendingInsertTextMap:tC,rosterReady:tI,instanceSelectionRequest:tT,acknowledgeInstanceSelection:tE,setActiveInstanceId:tA,setFocusedSplitIndex:tM,setHistorySubTab:tR,setWorktree:tL,showArchived:tP,showNewFileDialog:tD,showToast:tz,state:t_,tCommon:tB,tWorktree:tV,tabsActions:tU,tabsState:tK,resetFileTreeView:tW,toggleInstanceVisible:tq,verification:t$,vibeLocalContextWindow:tG,vibeLocalModel:tJ,visibleInstanceIds:tY,worktree:tQ,worktreeName:t0,worktreeStatus:t1}=function(e){var t,n,a,r,o,c,d,u,m,x;let{worktreeId:h}=e,p=(0,ai.a)(),g=(0,s.useRef)(p);g.current=p;let{openMobileDrawer:b}=(0,is.VF)(),v=(0,l.useRouter)(),y=(0,l.usePathname)(),j=(0,l.useSearchParams)(),w=null!=(o=null==j?void 0:j.get(ce.Kp))?o:null,{state:k,actions:N}=function(){let[e,t]=(0,s.useReducer)(o0,void 0,ec.mR),{value:n,setValue:a}=(0,lx.V)({key:"commandmate.worktree.leftPaneCollapsed",defaultValue:!1,validate:e=>"boolean"==typeof e}),r=(0,s.useRef)(e.layout.leftPaneCollapsed);r.current=e.layout.leftPaneCollapsed;let l=(0,s.useRef)(!1);(0,s.useEffect)(()=>{l.current||(l.current=!0,n!==r.current&&t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:n}))},[n]);let i=(0,s.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),showPrompt:(e,n)=>t({type:"SHOW_PROMPT",data:e,messageId:n}),clearPrompt:()=>t({type:"CLEAR_PROMPT"}),setPromptAnswering:e=>t({type:"SET_PROMPT_ANSWERING",answering:e}),setError:e=>t({type:"SET_ERROR",error:e}),clearError:()=>t({type:"CLEAR_ERROR"}),setMessages:e=>t({type:"SET_MESSAGES",messages:e}),addMessage:e=>t({type:"ADD_MESSAGE",message:e}),updateMessage:(e,n)=>t({type:"UPDATE_MESSAGE",id:e,updates:n}),clearMessages:()=>t({type:"CLEAR_MESSAGES"}),setMobileActivePane:e=>t({type:"SET_MOBILE_ACTIVE_PANE",pane:e}),setLeftPaneTab:e=>t({type:"SET_LEFT_PANE_TAB",tab:e}),setLayoutMode:e=>t({type:"SET_LAYOUT_MODE",mode:e}),setSplitRatio:e=>t({type:"SET_SPLIT_RATIO",ratio:e}),setWsConnected:e=>t({type:"SET_WS_CONNECTED",connected:e}),toggleLeftPane:()=>{let e=!r.current;t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:e}),a(e)},setActiveActivity:e=>t({type:"SET_ACTIVE_ACTIVITY",activity:e}),toggleActivity:e=>t({type:"TOGGLE_ACTIVITY",activity:e}),toggleHistoryPane:()=>t({type:"TOGGLE_HISTORY_PANE"}),setHistoryPaneVisible:e=>t({type:"SET_HISTORY_PANE_VISIBLE",visible:e}),setHistoryWidth:e=>t({type:"SET_HISTORY_WIDTH",width:e})}),[a]);return{state:e,dispatch:t,actions:i}}(),C=(0,i.c)("worktree"),I=(0,i.c)("error"),T=(0,i.c)("common"),E=(0,i.c)("autoYes"),A=(0,eG.SC)(),M=(0,em.rC)(),L=null!=(c=null==M?void 0:M.worktrees.find(e=>e.id===h))?c:null,[D,F]=(0,s.useState)(L),[O,z]=(0,s.useState)(null===L),[_,B]=(0,s.useState)(null),[V,H]=(0,s.useState)(!1),[U,K]=(0,s.useState)(!1),[W,q]=(0,s.useState)(0),$=(0,s.useRef)(0),G=(0,s.useRef)(0),J=(0,s.useRef)(null),Y=(0,s.useRef)(async()=>null),Q=(0,s.useCallback)(()=>{null!==J.current&&(clearTimeout(J.current),J.current=null)},[]),X=(0,s.useRef)(null!==L),[Z,ee]=(0,s.useState)(!1),[et,en]=function(e){let[t,n]=(0,s.useReducer)(function e(t,n){switch(n.type){case"OPEN_FILE":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1!==e){if(t.activeIndex===e)return t;return{...t,activeIndex:e}}if(t.tabs.length>=30)return t;let a={path:n.path,name:iB(n.path),content:null,loading:!1,error:null,isDirty:!1},r=[...t.tabs,a];return{tabs:r,activeIndex:r.length-1}}case"CLOSE_TAB":{var a,r;let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e)return t;let s=t.tabs.filter((t,n)=>n!==e),l=(a=t.activeIndex,0===(r=s.length)||null===a?null:e<a?a-1:e===a?Math.min(e,r-1):a);return{tabs:s,activeIndex:l}}case"ACTIVATE_TAB":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e||t.activeIndex===e)return t;return{...t,activeIndex:e}}case"SET_CONTENT":{let e=iV(t.tabs,n.path,e=>({...e,content:n.content,loading:!1,error:null,isDirty:!1}));if(!e)return t;return{...t,tabs:e}}case"SET_LOADING":{let e=iV(t.tabs,n.path,e=>({...e,loading:n.loading}));if(!e)return t;return{...t,tabs:e}}case"SET_ERROR":{let e=iV(t.tabs,n.path,e=>({...e,error:n.error,loading:!1}));if(!e)return t;return{...t,tabs:e}}case"RENAME_FILE":{let e=t.tabs.findIndex(e=>e.path===n.oldPath);if(-1===e)return t;let a=[...t.tabs];return a[e]={...a[e],path:n.newPath,name:iB(n.newPath)},{...t,tabs:a}}case"DELETE_FILE":return e(t,{type:"CLOSE_TAB",path:n.path});case"RESTORE":{let e=n.paths.slice(0,30).map(e=>({path:e,name:iB(e),content:null,loading:!1,error:null,isDirty:!1}));if(0===e.length)return iU;let t=n.activePath?Math.max(0,e.findIndex(e=>e.path===n.activePath)):0;return{tabs:e,activeIndex:t}}case"SET_DIRTY":{let e=t.tabs.find(e=>e.path===n.path);if(e&&e.isDirty===n.isDirty)return t;let a=iV(t.tabs,n.path,e=>({...e,isDirty:n.isDirty}));if(!a)return t;return{...t,tabs:a}}case"MOVE_TO_FRONT":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e||0===e)return t;return{tabs:[t.tabs[e],...t.tabs.filter((t,n)=>n!==e)],activeIndex:0}}case"CLOSE_ALL":if(0===t.tabs.length)return t;return iU;case"CLOSE_OTHERS":case"CLOSE_TO_RIGHT":{let e="CLOSE_OTHERS"===n.type?"others":"right",a=new Set(iH(t.tabs,n.path,e));if(0===a.size)return t;let r=t.tabs.filter(e=>!a.has(e.path));return{tabs:r,activeIndex:function(e,t,n){var a;if(0===t.length)return null;let r=null!==e.activeIndex?null==(a=e.tabs[e.activeIndex])?void 0:a.path:void 0;if(void 0!==r){let e=t.findIndex(e=>e.path===r);if(-1!==e)return e}let s=t.findIndex(e=>e.path===n);return -1!==s?s:0}(t,r,n.path)}}default:return t}},iU),a=(0,s.useRef)(!1),r=(0,s.useRef)(e);(0,s.useEffect)(()=>{if(r.current!==e&&(r.current=e,a.current=!1),a.current)return;a.current=!0;let t=function(e){try{let t=window.localStorage.getItem(i_+e);if(!t)return null;let n=JSON.parse(t);if("object"==typeof n&&null!==n&&Array.isArray(n.paths)&&n.paths.every(e=>"string"==typeof e)&&(null===n.activePath||"string"==typeof n.activePath))return n}catch(e){}return null}(e);t&&t.paths.length>0&&n({type:"RESTORE",paths:t.paths,activePath:t.activePath})},[e]),(0,s.useEffect)(()=>{if(a.current){var n,r;try{let a={paths:t.tabs.map(e=>e.path),activePath:null!==t.activeIndex&&null!=(r=null==(n=t.tabs[t.activeIndex])?void 0:n.path)?r:null};window.localStorage.setItem(i_+e,JSON.stringify(a))}catch(e){}}},[e,t]);let l=(0,s.useRef)(t);l.current=t;let i=(0,s.useCallback)(e=>{let t=l.current.tabs;return -1!==t.findIndex(t=>t.path===e)?(n({type:"OPEN_FILE",path:e}),"activated"):t.length>=30?"limit_reached":(n({type:"OPEN_FILE",path:e}),"opened")},[]),o=(0,s.useCallback)(e=>{n({type:"CLOSE_TAB",path:e})},[]),c=(0,s.useCallback)(e=>{n({type:"ACTIVATE_TAB",path:e})},[]),d=(0,s.useCallback)((e,t)=>{n({type:"RENAME_FILE",oldPath:e,newPath:t})},[]),u=(0,s.useCallback)(e=>{n({type:"DELETE_FILE",path:e})},[]),m=(0,s.useCallback)(e=>{n({type:"MOVE_TO_FRONT",path:e})},[]),x=(0,s.useCallback)(()=>{n({type:"CLOSE_ALL"})},[]),f=(0,s.useCallback)(e=>{n({type:"CLOSE_OTHERS",path:e})},[]),h=(0,s.useCallback)(e=>{n({type:"CLOSE_TO_RIGHT",path:e})},[]),p=(0,s.useMemo)(()=>({dispatch:n,openFile:i,closeTab:o,activateTab:c,onFileRenamed:d,onFileDeleted:u,moveToFront:m,closeAllTabs:x,closeOtherTabs:f,closeTabsToRight:h}),[n,i,o,c,d,u,m,x,f,h]);return[t,p]}(h),[ea,er]=(0,s.useState)(null),[es,el]=(0,s.useState)(o6.bk),[ei,ed]=(0,s.useState)(new Map),[eu,ex]=(0,s.useState)(null),[ef,eh]=(0,s.useState)(!1),[ep,eg]=(0,s.useState)(void 0),[eb,ev]=(0,s.useState)(!1),[ey,ej]=(0,s.useState)(cr),ew=(0,s.useRef)(!1),[ek,eN]=(0,s.useState)(null),[eC,eS]=(0,s.useState)(rT.sA),eI=(0,s.useRef)(eC);eI.current=eC;let eT=(0,s.useRef)(D);eT.current=D;let[eE,eA]=(0,s.useState)(()=>(0,eo.lu)((0,rT.sA)())),eM=(0,s.useRef)(eE);eM.current=eE;let[eR,eL]=(0,s.useState)(null),eP=eR===h,[eD,eF]=(0,s.useState)(null),[eO,ez]=(0,s.useState)(null),[e_,eB]=(0,s.useState)(()=>{try{let e=window.localStorage.getItem(cn+h);if(e&&(0,eo.hR)(e))return e}catch(e){}return(0,rT.sA)()[0]}),eV=(0,s.useCallback)(e=>{eB(e);try{window.localStorage.setItem(cn+h,e)}catch(e){}},[h]),eH=(0,s.useRef)(e_);eH.current=e_;let[eU,eK]=(0,s.useState)(()=>{try{let e=window.localStorage.getItem(ca+h);if(e&&(0,eo.n6)(e))return e;let t=window.localStorage.getItem(cn+h);if(t&&(0,eo.hR)(t))return t}catch(e){}return(0,rT.sA)()[0]}),eW=(0,s.useCallback)(e=>{eK(e);try{window.localStorage.setItem(ca+h,e)}catch(e){}let t=eM.current.find(t=>t.id===e);t&&eV(t.cliTool)},[h,eV]),eq=(0,s.useRef)(eU);eq.current=eU;let e$=(0,s.useRef)(0),eJ=(0,s.useRef)(0),eY=(0,s.useRef)(0),eQ=null!=(d=null==(t=ei.get(eU))?void 0:t.enabled)&&d,eX=null!=(u=null==(n=ei.get(eU))?void 0:n.expiresAt)?u:null,[eZ,e0]=(0,s.useState)(0),[e1,e2]=(0,s.useState)(!1),[e4,e5]=(0,s.useState)(""),{active:e3,setActive:e9,toggle:e7}=function(e){let[t,n]=(0,s.useState)(it),a=(0,s.useRef)(t);a.current=t;let r=(0,s.useRef)(e);return r.current=e,(0,s.useEffect)(()=>{let t=function(e){try{let t=window.localStorage.getItem(ir(e));if(t===ia)return null;if(t&&"string"==typeof t&&ie.has(t))return t}catch(e){}return it}(e);t!==a.current&&n(t)},[e]),{active:t,setActive:(0,s.useCallback)(e=>{n(e),o1(r.current,e)},[]),toggle:(0,s.useCallback)(e=>{if(a.current===e){n(null),o1(r.current,null);return}n(e),o1(r.current,e)},[])}}(h),{historySubTab:te,setHistorySubTab:tt,showArchived:tn,handleShowArchivedChange:ta,historyUserOnly:tr,handleHistoryUserOnlyChange:tl,historyDisplayLimit:ti,handleHistoryDisplayLimitChange:to}=function(){let[e,t]=(0,s.useState)("message"),[n,a]=(0,s.useState)(()=>"true"===localStorage.getItem(o7)),r=(0,s.useCallback)(e=>{a(e),localStorage.setItem(o7,String(e))},[]),[l,i]=(0,s.useState)(()=>{try{return"true"===localStorage.getItem(o9.gP)}catch(e){return!1}}),o=(0,s.useCallback)(e=>{i(e);try{localStorage.setItem(o9.gP,String(e))}catch(e){}},[]),[c,d]=(0,s.useState)(()=>{try{let e=localStorage.getItem(o9.wP);if(null===e)return o9.v8;let t=parseInt(e,10);return(0,o9.UK)(t)?t:o9.v8}catch(e){return o9.v8}});return{historySubTab:e,setHistorySubTab:t,showArchived:n,handleShowArchivedChange:r,historyUserOnly:l,handleHistoryUserOnlyChange:o,historyDisplayLimit:c,handleHistoryDisplayLimitChange:(0,s.useCallback)(e=>{d(e);try{localStorage.setItem(o9.wP,String(e))}catch(e){}},[])}}(),tc=(0,s.useRef)(tn);(0,s.useEffect)(()=>{tc.current=tn},[tn]);let td=(0,s.useRef)(ti);(0,s.useEffect)(()=>{td.current=ti},[ti]),(0,s.useEffect)(()=>{(0,rT.qD)()},[]);let{pendingInsertTextMap:tu,pendingInsertText:tm,setFocusedSplitIndex:tx,handleInsertToMessage:tf,handleInsertToSplit:th,handleInsertConsumed:tp,handleInsertConsumedSingle:tg}=function(){var e;let[t,n]=(0,s.useState)(()=>new Map),[a,r]=(0,s.useState)(0),l=(0,s.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(a,e),n})},[a]),i=(0,s.useCallback)((e,t)=>{n(n=>{let a=new Map(n);return a.set(e,t),a})},[]),o=(0,s.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),c=null!=(e=t.get(0))?e:null,d=(0,s.useCallback)(()=>o(0),[o]);return{pendingInsertTextMap:t,pendingInsertText:c,focusedSplitIndex:a,setFocusedSplitIndex:r,handleInsertToMessage:l,handleInsertToSplit:i,handleInsertConsumed:o,handleInsertConsumedSingle:d}}(),{diffContent:tb,diffFilePath:tv,handleDiffSelect:ty,handleCloseDiff:tj}=function(e){let[t,n]=(0,s.useState)(null),[a,r]=(0,s.useState)(null);return{diffContent:t,diffFilePath:a,handleDiffSelect:(0,s.useCallback)((t,a)=>{e||(n(t),r(a))},[e]),handleCloseDiff:(0,s.useCallback)(()=>{n(null),r(null)},[])}}(p),tw=function(e){let{worktreeId:t,initialMode:n="name",debounceMs:a=300}=e,[r,l]=(0,s.useState)(""),[i,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(n),[u,m]=(0,s.useState)(!1),[x,h]=(0,s.useState)(null),[p,g]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useMemo)(()=>(0,f.sg)(e=>{o(e)},a),[a]);(0,s.useEffect)(()=>()=>v.cancel(),[v]);let y=(0,s.useCallback)(e=>{l(e),v(e),g(null)},[v]),j=(0,s.useCallback)(()=>{l(""),o(""),h(null),g(null),m(!1),b.current&&(b.current.abort(),b.current=null)},[]),w=(0,s.useCallback)(e=>{if(!i.trim())return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[i]),k=(0,s.useCallback)(()=>x&&0!==x.results.length?(0,f.q3)(x.results.map(e=>e.filePath)):new Set,[x]);return(0,s.useEffect)(()=>{if("content"!==c||!i.trim())return void h(null);b.current&&b.current.abort();let e=new AbortController;return b.current=e,(async()=>{m(!0),g(null);try{var n,a;let r=await fetch("/api/worktrees/".concat(encodeURIComponent(t),"/search?q=").concat(encodeURIComponent(i),"&mode=content"),{signal:e.signal});if(!r.ok){let e=await r.json();throw Error((null==(n=e.error)?void 0:n.message)||"Search failed: ".concat(r.status))}let s=await r.json();if(s.success)h({mode:"content",query:i,results:s.results,totalMatches:s.totalMatches,truncated:s.truncated,executionTimeMs:s.executionTimeMs});else throw Error((null==(a=s.error)?void 0:a.message)||"Search failed")}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;g(e instanceof Error?e.message:"An error occurred while searching"),h(null)}finally{m(!1)}})(),()=>{e.abort()}},[c,i,t]),(0,s.useEffect)(()=>{"name"===c&&(h(null),m(!1),g(null))},[c]),{query:r,mode:c,isSearching:u,results:x,error:p,setQuery:y,setMode:d,clearSearch:j,filterByName:w,getMatchedPaths:k}}({worktreeId:h}),tC=(0,s.useRef)(!1),tI=(0,s.useRef)(h);(0,s.useEffect)(()=>{tI.current!==h&&(N.clearMessages(),N.clearPrompt(),ej(cr),tC.current=!1,ed(new Map),$.current=0,G.current=0,Q(),H(!1),tI.current=h)},[h,N,Q]);let tT=(0,s.useCallback)(async()=>{try{var e,t;let n=await (0,tN.E)("/api/worktrees/".concat(h),cl),a=(0,tN.O0)(n);if(a)throw a;if(!n.ok)throw new tN.hD("Failed to fetch worktree: ".concat(n.status),n.status);let r=(0,tN.xd)(n);if(r)throw r;let s=await n.json();if(F(s),s.selectedAgents){let e=eI.current;s.selectedAgents.length===e.length&&s.selectedAgents.every((t,n)=>t===e[n])||eS(s.selectedAgents)}if(s.agentInstances){let e=eM.current,t=s.agentInstances;t.length===e.length&&t.every((t,n)=>t.id===e[n].id&&t.cliTool===e[n].cliTool&&t.alias===e[n].alias)||eA(t),eL(h)}return"vibeLocalModel"in s&&eF(null!=(e=s.vibeLocalModel)?e:null),"vibeLocalContextWindow"in s&&ez(null!=(t=s.vibeLocalContextWindow)?t:null),$.current=0,G.current=0,Q(),H(!1),K(!1),B(null),s}catch(a){let e=a instanceof Error?a.message:"Unknown error",t=a instanceof tN.hD?a.status:0;if($.current+=1,401===t)return K(!0),H(!1),B(null),null;if(null!==eT.current)return $.current>=3&&H(!0),console.error("[WorktreeDetailRefactored] Error fetching worktree:",a),null;B(e);let n=G.current;return n<cs.length&&(G.current=n+1,Q(),J.current=setTimeout(()=>{J.current=null,Y.current()},cs[n])),null}},[h,Q]);Y.current=tT;let tE=(0,s.useCallback)(async()=>{let e=eH.current,t=g.current,n=eq.current,a=++e$.current,r=()=>e$.current!==a||eH.current!==e||t&&eq.current!==n;try{let a=new URLSearchParams({cliTool:e,unit:"pairs"});t&&a.set("instance",n),tc.current&&a.set("includeArchived","true"),a.set("limit",String(td.current));let s=await (0,tN.E)("/api/worktrees/".concat(h,"/messages?").concat(a.toString()),cl);if(!s.ok)throw Error("Failed to fetch messages: ".concat(s.status));let l=await s.json();if(r())return;N.setMessages(l.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){if(r())return;console.error("[WorktreeDetailRefactored] Error fetching messages:",e)}},[h,N]),tA=(0,s.useCallback)(async()=>{let e=eH.current,t=g.current,n=eq.current,a=++eJ.current,r=()=>eJ.current!==a||eH.current!==e||t&&eq.current!==n;try{var s,l,i,o,c,d,u,m,x,f;let a=t?"/api/worktrees/".concat(h,"/current-output?cliTool=").concat(e,"&instance=").concat(encodeURIComponent(n)):"/api/worktrees/".concat(h,"/current-output?cliTool=").concat(e),p=await (0,tN.E)(a,cl);if(!p.ok){409===p.status&&await (0,no.y$)(p)&&!r()&&(N.clearPrompt(),eg(void 0),ev(!1),el(o6.bk),ej(cr));return}let g=await p.json();if(r()||g.cliToolId&&g.cliToolId!==e)return;let b=g.isSelectionListActive?(0,o6.gO)(null!=(s=g.fullOutput)?s:g.realtimeSnippet):o6.bk;el(e=>(0,o6.hq)(e,b)?e:b),g.isPromptWaiting&&g.promptData?(N.showPrompt(g.promptData,"prompt-".concat(Date.now())),eg(g.promptAnswerable),ev((0,ct.r)(null==(l=g.autoYes)?void 0:l.lastEnterFallback))):!g.isPromptWaiting&&k.prompt.visible&&N.clearPrompt();let v={isSelectionListActive:null!=(i=g.isSelectionListActive)&&i,isPagerActive:null!=(o=g.isPagerActive)&&o,offersPlanApprove:(0,o3.S$)(g.realtimeSnippet||g.fullOutput).offersPlanApprove,isDismissablePanelActive:null!=(c=g.isDismissablePanelActive)&&c,isUnclassifiedActive:null!=(d=g.isUnclassifiedActive)&&d,sessionStatus:null!=(u=g.sessionStatus)?u:"",agentMode:null!=(m=g.agentMode)?m:oZ.J_,startingSince:"number"==typeof g.startingSince?g.startingSince:null};if(ej(e=>(0,o8.B)(e,v)?e:v),ex(null!=(x=g.lastServerResponseTimestamp)?x:null),eh(null!=(f=g.serverPollerActive)&&f),g.autoYes){let a=ew.current,r=g.autoYes,s=t?n:e;ed(e=>{let t=new Map(e);return t.set(s,{enabled:r.enabled,expiresAt:r.expiresAt}),t}),ew.current=r.enabled,a&&!g.autoYes.enabled&&("stop_pattern_matched"===g.autoYes.stopReason||"consecutive_errors"===g.autoYes.stopReason)&&eN(g.autoYes.stopReason)}}catch(e){if(r())return;console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[h,N,k.prompt.visible]),tM=(0,s.useCallback)(async()=>{let e=++eY.current;try{let a=await (0,tN.E)("/api/worktrees/".concat(h,"/auto-yes"),cl);if(!a.ok)return;let r=await a.json();if(eY.current!==e)return;let s=null==r?void 0:r.instances;if(!s||"object"!=typeof s)return;let l=new Map;for(let[e,a]of Object.entries(s))if(a&&"object"==typeof a){var t,n;l.set(e,{enabled:null!=(t=a.enabled)&&t,expiresAt:null!=(n=a.expiresAt)?n:null})}ed(l)}catch(t){if(eY.current!==e)return;console.error("[WorktreeDetailRefactored] Error fetching auto-yes states:",t)}},[h]),{visibleInstances:tR,visibleInstanceIds:tL,toggleInstanceVisible:tP,showInstances:tD}=function(e){let{worktreeId:t,roster:n}=e,[a,r]=(0,s.useState)(null);(0,s.useEffect)(()=>{r(function(e){try{let t=window.localStorage.getItem(rf(e));if(null===t)return null;let n=JSON.parse(t);if(!Array.isArray(n))return null;let a=n.filter(e=>"string"==typeof e);return a.length>0?a:null}catch(e){return null}}(t))},[t]);let l=(0,s.useMemo)(()=>rh(a,n),[a,n]),i=(0,s.useMemo)(()=>l.map(e=>e.id),[l]),o=(0,s.useMemo)(()=>null!==a&&n.some(e=>a.includes(e.id)),[a,n]),c=(0,s.useCallback)(e=>{let a=new Set(e),s=n.filter(e=>a.has(e.id)).map(e=>e.id);if(!(s.length<1)){r(s);try{window.localStorage.setItem(rf(t),JSON.stringify(s))}catch(e){}}},[n,t]),d=(0,s.useCallback)(e=>c(e),[c]);return{visibleInstances:l,visibleInstanceIds:i,hasStoredPreference:o,toggleInstanceVisible:(0,s.useCallback)(e=>{let t=rh(a,n).map(e=>e.id);if(t.includes(e)){if(t.length<=1)return;c(t.filter(t=>t!==e))}else c([...t,e])},[a,n,c]),setVisibleInstanceIds:d,showInstances:(0,s.useCallback)(e=>{null!==a&&c([...rh(a,n).map(e=>e.id),...e])},[a,n,c])}}({worktreeId:h,roster:eE}),tF=p?tR:eE,tO=(0,s.useMemo)(()=>Array.from(new Set(tR.map(e=>e.cliTool))),[tR]);(0,s.useEffect)(()=>{0!==tF.length&&(tF.some(e=>e.id===eU)||eW(tF[0].id))},[tF,eU,eW]),(0,s.useEffect)(()=>{let e=tF.find(e=>e.id===eU);e&&e.cliTool!==e_&&eV(e.cliTool)},[tF,eU,e_,eV]);let[tz,t_]=(0,s.useState)(null),tB=(0,s.useRef)(0),tV=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e;if(null===w){tV.current=null;return}if(!eP||tV.current===w)return;tV.current=w,eE.some(e=>e.id===w)&&(g.current?(tD([w]),eW(w)):(eW(w),tB.current+=1,t_({instanceId:w,token:tB.current})));let t=new URLSearchParams(null!=(e=null==j?void 0:j.toString())?e:"");t.delete(ce.Kp);let n=t.toString(),a=null!=y?y:"/worktrees/".concat(h);v.replace(n?"".concat(a,"?").concat(n):a,{scroll:!1})},[w,eP,eE,tD,eW,j,y,h,v]);let tH=(0,s.useCallback)(e=>{t_(t=>null!==t&&t.token===e?null:t)},[]),tU="opencode"===e_||"copilot"===e_,tK=(0,s.useCallback)(e=>{eA(e),eL(h)},[h]),tW=(0,s.useCallback)(e=>{eF(e)},[]),tq=(0,s.useCallback)(e=>{ez(e)},[]),t$="".concat(e_,"::").concat(p?eU:e_),tG=(0,s.useRef)(t$);(0,s.useEffect)(()=>{tG.current!==t$&&(tG.current=t$,N.clearMessages(),N.clearPrompt(),ej(cr),tE(),tA())},[t$,N,tE,tA]),(0,s.useEffect)(()=>{tE()},[tn,tE]),(0,s.useEffect)(()=>{tE()},[ti,tE]);let{showToast:tJ}=(0,tk.dj)(),tY=(0,s.useCallback)(()=>{tJ("Maximum ".concat(30," file tabs. Close a tab first."),"info")},[tJ]),tQ=(0,s.useCallback)(e=>{p?er(e):"limit_reached"===en.openFile(e)&&tY()},[p,en,tY]),tX=(0,s.useCallback)(e=>{p?er(e):"limit_reached"===en.openFile(e)&&tY()},[p,en,tY]),tZ=(0,s.useCallback)(e=>{"limit_reached"===en.openFile(e)&&tY()},[en,tY]),t0=(0,s.useCallback)(()=>{er(null)},[]),t1=(0,s.useCallback)(e=>{e0(e=>e+1)},[]),t2=(0,s.useCallback)(()=>{tw.clearSearch(),en.closeAllTabs(),er(null)},[tw,en]),t4=(0,s.useCallback)(e=>{e7(e)},[e7]),t5=(0,s.useCallback)(e=>{e9(e)},[e9]),t3=(0,s.useCallback)(async e=>{try{let t=await fetch("/api/worktrees/".concat(h),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:e})});if(t.ok){let e=await t.json();F(e)}}catch(e){}},[h]),t6=(0,s.useCallback)(()=>{ee(!0)},[]),t8=(0,s.useCallback)(()=>{ee(!1)},[]),t9=(0,s.useCallback)(async e=>{let t;N.setPromptAnswering(!0);try{let n=o_(e,e_,S(k.prompt.data)?k.prompt.data:null,g.current?eq.current:void 0),a=await fetch("/api/worktrees/".concat(h,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});t=await (0,oV.a_)(a)}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e),t="failed"}try{if("answered"===t)N.clearPrompt();else{let e=oV.J4[t];tJ(C(e.messageKey),e.type)}await tA()}finally{N.setPromptAnswering(!1)}},[h,N,tA,e_,k.prompt.data,tJ,C]),t7=(0,s.useCallback)(()=>{N.clearPrompt()},[N]),ne=(0,s.useCallback)(e=>{N.setMobileActivePane(e)},[N]),nt=(0,s.useCallback)(()=>{tE(),tA()},[tE,tA]),nn=(0,s.useCallback)((e,t)=>async n=>{let a=null!=t?t:e;try{let t=await fetch("/api/worktrees/".concat(h,"/auto-yes"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:n.enabled,cliToolId:e,instanceId:a,duration:n.duration,stopPattern:n.stopPattern})});if(t.ok){let e=await t.json();ed(t=>{let n=new Map(t);return n.set(a,{enabled:e.enabled,expiresAt:e.expiresAt}),n}),a===eq.current&&(ew.current=e.enabled)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[h]),na=(0,s.useCallback)(e=>nn(e_,eU)(e),[nn,e_,eU]),[nr,ns]=(0,s.useState)(null),[nl,ni]=(0,s.useState)(!1),nc=(0,s.useRef)(!1),nd=(0,s.useCallback)(e=>{ns(e)},[]),nu=(0,s.useCallback)(()=>{let e=eq.current,t=eH.current,n=(0,eo.O6)(eM.current,e,t);ns({cliToolId:t,instanceId:e,label:n})},[]),nm=(0,s.useCallback)(async()=>{if(!nr||nc.current)return;nc.current=!0,ni(!0);let e=()=>{nr.instanceId===eq.current&&(N.clearMessages(),N.clearPrompt())};try{await tN.y.killSession(h,nr.cliToolId,nr.instanceId),e(),await tT(),ns(null)}catch(t){t instanceof tN.hD&&404===t.status?(e(),await tT(),ns(null)):tJ(C("session.failedToKill"),"error")}finally{nc.current=!1,ni(!1)}},[nr,h,N,tT,tJ,C]),nx=(0,s.useCallback)(()=>{nc.current||ns(null)},[]),nf=(0,s.useCallback)(e=>{e5(e),e2(!0)},[]),nh=(0,s.useCallback)(async e=>{e2(!1);let t=e4?"".concat(e4,"/").concat(e):e;try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,ts.o)(t)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");e0(e=>e+1)}catch(e){window.alert(I("fileOps.failedToCreateFile"))}},[h,e4,I]),np=(0,s.useCallback)(()=>{e2(!1)},[]),ng=(0,s.useCallback)(async e=>{let t=window.prompt("Enter directory name:");if(!t)return;let n=e?"".concat(e,"/").concat(t):t;try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,ts.o)(n)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");e0(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(I("fileOps.failedToCreateDirectory"))}},[h,I]),nb=(0,s.useCallback)(async e=>{let t=e.split("/").pop()||"",n=window.prompt("Enter new name:",t);if(n&&n!==t)try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,ts.o)(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:n})})).ok)throw Error("Failed to rename");let t=e.includes("/")?e.substring(0,e.lastIndexOf("/")+1):"";en.onFileRenamed(e,"".concat(t).concat(n)),e0(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(I("fileOps.failedToRename"))}},[h,en,I]),nv=(0,s.useCallback)(async e=>{let t=e.split("/").pop()||e;if(await A({description:T("confirmDelete",{name:t}),variant:"danger"}))try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,ts.o)(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");en.onFileDeleted(e),e0(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(I("fileOps.failedToDelete"))}},[h,en,T,I,A]);(0,s.useEffect)(()=>{"stop_pattern_matched"===ek?(tJ(E("stopPatternMatched"),"info"),eN(null)):"consecutive_errors"===ek&&(tJ(E("consecutiveErrorsStopped"),"warning"),eN(null))},[ek,tJ,E]);let{moveTarget:ny,isMoveDialogOpen:nj,handleMove:nw,handleMoveConfirm:nk,handleMoveCancel:nN}=function(e,t,n,a){let[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1),c=(0,s.useCallback)((e,t)=>{l({path:e,type:t}),o(!0)},[]),d=(0,s.useCallback)(async s=>{if(r)try{let l=await fetch("/api/worktrees/".concat(e,"/files/").concat(r.path),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:s})}),o=await l.json();if(!l.ok||!o.success){var i;let e=(null==(i=o.error)?void 0:i.message)||"Failed to move";null==a||a(e);return}null==n||n("Moved successfully"),t()}catch(e){null==a||a("Failed to move")}finally{l(null),o(!1)}},[r,e,t,n,a]);return{moveTarget:r,isMoveDialogOpen:i,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,s.useCallback)(()=>{l(null),o(!1)},[])}}(h,()=>e0(e=>e+1),e=>tJ(e,"success"),e=>tJ(e,"error")),nC=(0,s.useRef)(null),nS=(0,s.useRef)(""),nI=(0,s.useCallback)(e=>{var t;nS.current=e,null==(t=nC.current)||t.click()},[]),nT=(0,s.useCallback)(async e=>{var t,n,a;let r=null==(t=e.target.files)?void 0:t[0];if(!r)return;e.target.value="";let s=nS.current,l=".".concat(null==(n=r.name.split(".").pop())?void 0:n.toLowerCase());if(!function(e){if(!e)return!1;let t=e.toLowerCase();return e8.includes(t)}(l))return void tJ("Unsupported file type: ".concat(l,". Allowed: ").concat(e8.join(", ")),"error");let i=function(e){var t;let n=function(e){let t=e.toLowerCase();return e6.find(e=>e.extension===t)}(e);return null!=(t=null==n?void 0:n.maxFileSize)?t:0x1400000}(l);if(r.size>i)return void tJ("File too large. Maximum size: ".concat((i/1024/1024).toFixed(1),"MB"),"error");let o=new FormData;o.append("file",r);try{let e=await fetch("/api/worktrees/".concat(h,"/upload/").concat((0,ts.o)(s||".")),{method:"POST",body:o});if(!e.ok){let t=await e.json().catch(()=>({})),n=(null==t||null==(a=t.error)?void 0:a.message)||"Failed to upload file";tJ(n,"error");return}let t=await e.json();tJ("Uploaded: ".concat(t.filename),"success"),e0(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),tJ("Upload failed. Please try again.","error")}},[h,tJ]),{hasUpdate:nE}=(0,tS.Y)(),{lastAutoResponse:nA}=function(e){let{worktreeId:t,cliTool:n,isPromptWaiting:a,promptData:r,autoYesEnabled:l,lastServerResponseTimestamp:i,serverPollerActive:o,instanceId:c}=e,d=(0,s.useRef)(null),u=(0,s.useRef)(0),m="".concat(t,"::").concat(n,"::").concat(null!=c?c:n),x=(0,s.useRef)(m);x.current=m;let[f,h]=(0,s.useState)(null);return(0,s.useEffect)(()=>{var e,s;if(!a){d.current=null;return}if(!r||!l||(null==(e=(0,R.ds)(r))?void 0:e.kind)!=="screen-choices"||!S(r)||o||i&&Date.now()-i<3e3)return;let c=(s={type:r.type,question:r.question},"".concat(s.type,":").concat(s.question));if(d.current===c)return;let f=function(e,t){let n=function(e){if("yes_no"===e.type)return"y";if("multiple_choice"===e.type){if(P(e))return null;let t=e.options.find(e=>e.isDefault),n=null!=t?t:e.options[0];return!n||n.requiresTextInput?null:n.number.toString()}return null}(e);if(null===n)return{answer:null,suppressedBy:null};let a=function(e,t,n){if(!n)return null;if("off"===n.mode)return{reason:"mode-off"};let a=function(e,t){if(0===t.length)return{outcome:"no-match"};let n=e.map(e=>e.length>2e4?e.slice(0,2e4):e);for(let e of t){if(e.length>200||!(0,r_.P0)(e).valid)return{outcome:"unusable",pattern:e};let t=new RegExp(e);for(let a of n){let n=(0,r_.eJ)(t,a);if(null===n)return{outcome:"unusable",pattern:e};if(n)return{outcome:"match",pattern:e}}}return{outcome:"no-match"}}(t,n.denyPatterns);return"match"===a.outcome?{reason:"deny-pattern",pattern:a.pattern}:"unusable"===a.outcome?{reason:"deny-pattern-unusable",pattern:a.pattern}:"safe"===n.mode?"yes_no"===e?null:{reason:"type-not-allowed"}:"allow-listed"===n.mode?n.allowPromptTypes.includes(e)?null:{reason:"type-not-allowed"}:null}(e.type,function(e){let t=[e.question];if(e.approvalTarget&&t.push(e.approvalTarget),"multiple_choice"===e.type)for(let n of e.options)t.push(n.label);else t.push(...e.options);return t}(e),t);return a?{answer:null,suppressedBy:a.reason,pattern:a.pattern}:{answer:n,suppressedBy:null}}(r,void 0).answer;if(null===f)return;d.current=c,h(null);let p=++u.current,g=o_(f,n,r);fetch("/api/worktrees/".concat(t,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}).then(oV.a_).then(e=>{let t=p===u.current&&m===x.current;"answered"===e&&t&&h(f)}).catch(e=>{console.error("[useAutoYes] Failed to send auto-response:",e)})},[a,r,l,t,n,m,i,o]),{lastAutoResponse:f}}({worktreeId:h,cliTool:e_,isPromptWaiting:k.prompt.visible,promptData:k.prompt.data,autoYesEnabled:eQ,lastServerResponseTimestamp:eu,serverPollerActive:ef}),nM=(0,s.useCallback)(async()=>{B(null),H(!1),K(!1),$.current=0,G.current=0,Q(),z(!0),await tT()&&await Promise.all([tE(),tA()]),z(!1)},[tT,tE,tA,Q]),nR=(0,s.useCallback)(()=>{window.location.href="/login"},[]);(0,s.useEffect)(()=>Q,[Q]),function(e){let{error:t,handleRetry:n,fetchWorktree:a,fetchMessages:r,fetchCurrentOutput:l,setError:i}=e,o=(0,s.useRef)(0),c=(0,s.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-o.current<5e3)){if(o.current=e,t)return void n();try{await Promise.all([a(),r(),l()])}finally{i(null)}}},[t,n,a,r,l,i]);(0,s.useEffect)(()=>(document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c)}),[c])}({error:_,handleRetry:nM,fetchWorktree:tT,fetchMessages:tE,fetchCurrentOutput:tA,setError:B}),(0,s.useEffect)(()=>{if(tC.current)return;let e=!0;return(async()=>{X.current||z(!0),await Promise.all([tT(),tE(),tA()]),e&&(z(!1),tC.current=!0)})(),()=>{e=!1}},[tT,tE,tA]);let nL=null!=(m=null==D||null==(r=D.sessionStatusByCli)||null==(a=r[e_])?void 0:a.isRunning)&&m;(0,s.useEffect)(()=>{if(O)return;let e=setInterval(async()=>{let e=[tA(),tT()];p&&e.push(tE()),await Promise.all(e),q(e=>e+1)},nL?2e3:5e3);return()=>clearInterval(e)},[O,tA,tT,tE,nL,p]),(0,s.useEffect)(()=>{tM()},[h,eP,tM]),(0,s.useEffect)(()=>{N.setLayoutMode(p?"tabs":"split")},[p,N]);let nP=(0,s.useMemo)(()=>(function(e,t){var n;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"claude";if(t)return"error";if(!e)return"idle";let r=null==(n=e.sessionStatusByCli)?void 0:n[a];if(r){if(r.isWaitingForResponse)return"waiting";if(r.isProcessing)return"running";if(r.isRunning)return"ready"}if("claude"===a){if(e.isWaitingForResponse)return"waiting";if(e.isProcessing)return"running";if(e.isSessionRunning)return"ready"}return"idle"})(D,null!==k.error.type,e_),[D,k.error.type,e_]),nD=(0,s.useMemo)(()=>k.layout.mobileActivePane,[k.layout.mobileActivePane]),nF=null!=(x=null==D?void 0:D.name)?x:"Unknown",nO=(0,s.useCallback)((e,t)=>{en.dispatch({type:"SET_CONTENT",path:e,content:t})},[en]),nz=(0,s.useCallback)((e,t)=>{en.dispatch({type:"SET_ERROR",path:e,error:t})},[en]),n_=(0,s.useCallback)((e,t)=>{en.dispatch({type:"SET_LOADING",path:e,loading:t})},[en]),nB=(0,s.useCallback)((e,t)=>{en.dispatch({type:"SET_DIRTY",path:e,isDirty:t})},[en]),nV=function(e){var t,n,a;let{worktreeId:r,refreshToken:l=0,enabled:i=!0,limit:o=10}=e,[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(!0),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.useState)(null),[E,A]=(0,s.useState)(null),[M,R]=(0,s.useState)(null),[L,P]=(0,s.useState)(!1),[D,F]=(0,s.useState)(null),[O,z]=(0,s.useState)(null),[_,B]=(0,s.useState)(!1),[V,H]=(0,s.useState)(null),[U,K]=(0,s.useState)(null),[W,q]=(0,s.useState)(null),[$,G]=(0,s.useState)(o),[J,Y]=(0,s.useState)(o),[Q,X]=(0,s.useState)(!1),[Z,ee]=(0,s.useState)([]),[et,en]=(0,s.useState)(!1),[ea,er]=(0,s.useState)(null),[es,el]=(0,s.useState)(0),ei=(0,s.useRef)(0),eo=(0,s.useRef)(0),ec=(0,s.useRef)(!1),ed=(0,s.useRef)(!1),eu=(0,s.useRef)(!1),em=(0,s.useRef)(!1),ex=(0,s.useRef)(!1),ef=(0,s.useRef)(!1),eh=(0,s.useRef)(null);eh.current=W;let ep=(0,s.useRef)(o);ep.current=$,ed.current=(null==c?void 0:c.status)==="verifying"||u.some(e=>"running"===e.status),(0,s.useEffect)(()=>{if(ei.current+=1,eo.current=0,ec.current=!1,!ef.current){ef.current=!0;return}d(null),m([]),f(null),p(null),b(!0),y(null),w(null),T(null),A(null),R(null),F(null),z(null),H(null),q(null),G(o),Y(o),K(null)},[r]),(0,s.useEffect)(()=>{if(!i)return;let e=new AbortController,t=!1;return(async()=>{try{let n=await sN(r,e.signal);if(t)return;A(n),R(null)}catch(e){if(t||o5(e))return;A(null),R(o4(e,"Failed to load the verification config"))}})(),()=>{t=!0,e.abort()}},[r,i,es]),(0,s.useEffect)(()=>{if(!i)return;let e=0===eo.current,t=15e3*!ed.current;if(!e&&Date.now()-eo.current<t||ec.current)return;let n=ei.current;ec.current=!0,eo.current=Date.now(),(async()=>{try{let[e,t]=await Promise.all([sy(r),sj(r,$)]);if(n!==ei.current)return;d(e),m(t),Y($),y(null)}catch(e){if(n!==ei.current||o5(e))return;y(o4(e,"Failed to load verification data"))}finally{ec.current=!1,n===ei.current&&(b(!1),ep.current!==$&&(eo.current=0,el(e=>e+1)))}})()},[r,l,es,i,$]);let eg=null!=(n=null!=x?x:null==(t=u[0])?void 0:t.id)?n:null,eb=(0,s.useMemo)(()=>{var e,t;if(null===eg)return null;let n=u.find(e=>e.id===eg);return(null==n?void 0:n.status)==="running"?"".concat(eg,":running:").concat(l,":").concat(es):"".concat(eg,":").concat(null!=(e=null==n?void 0:n.status)?e:"unlisted",":").concat(null!=(t=null==n?void 0:n.finishedAt)?t:"")},[eg,u,l,es]);(0,s.useEffect)(()=>{if(!i||null===eg){p(null),w(null),N(!1);return}let e=new AbortController,t=!1;return N(!0),(async()=>{try{let n=await sw(r,eg,e.signal);if(t)return;p(n),w(null===n?"not-found":null)}catch(e){if(t||o5(e))return;p(null),w(o4(e,"Failed to load the verification run"))}finally{t||N(!1)}})(),()=>{t=!0,e.abort()}},[r,i,eb]),(0,s.useEffect)(()=>{if(!i||!Q)return;let e=new AbortController,t=!1;return en(!0),(async()=>{try{let n=await sI({days:7,limit:20},e.signal);if(t)return;ee(n),er(null)}catch(e){if(t||o5(e))return;er(o4(e,"Failed to load the verification history"))}finally{t||en(!1)}})(),()=>{t=!0,e.abort()}},[i,Q,es]);let ev=(0,s.useMemo)(()=>{var e;return null!=(e=null==E?void 0:E.plannedGateIds)?e:[]},[E]),ey=(0,s.useMemo)(()=>{var e;return(null!=(e=null==h?void 0:h.gates)?e:[]).filter(e=>sf.includes(e.status)).map(e=>e.gateId)},[h]),ej=(0,s.useMemo)(()=>{var e;return null!=(e=u.find(e=>"running"===e.status))?e:null},[u]),ew=(0,s.useCallback)(e=>{q(null===e||o2(e,ev)?null:e)},[ev]),ek=(0,s.useCallback)(e=>{q(t=>{let n=new Set(null!=t?t:ev);n.has(e)?n.delete(e):n.add(e);let a=ev.filter(e=>n.has(e));return o2(a,ev)?null:a})},[ev]),eN=(0,s.useCallback)(()=>{let e=ev.filter(e=>ey.includes(e));q(0===e.length||o2(e,ev)?null:e)},[ev,ey]),eC=(0,s.useCallback)(()=>{eo.current=0,G(e=>Math.min(e+10,100))},[]),eS=(0,s.useCallback)(()=>{X(e=>!e)},[]),eI=(0,s.useCallback)(()=>{eo.current=0,el(e=>e+1)},[]),eT=(0,s.useCallback)(e=>{f(e)},[]),eE=(0,s.useCallback)(async e=>{if(!eu.current){eu.current=!0,S(!0),T(null),H(null);try{let t=void 0===e?eh.current:e,n=await sk(r,null!==t&&t.length>0?{gateIds:t}:{});f(n),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof sg&&409===t.status;T({kind:e?"conflict":"error",message:o4(t,"Failed to start verification"),runningRunId:t instanceof sg?t.runningRunId:null}),e&&(eo.current=0,el(e=>e+1))}finally{eu.current=!1,S(!1)}}},[r]),eA=(0,s.useCallback)(async()=>{if(!ex.current&&null!==ej){ex.current=!0,B(!0),H(null);try{let e=await sS(r,ej.id);K("running"===e.status?ej.id:null)}catch(e){H({kind:409===(e instanceof sg?e.status:0)?"gone":"error",message:o4(e,"Failed to cancel the verification run")})}finally{ex.current=!1,B(!1),eo.current=0,el(e=>e+1)}}},[r,ej]),eM=(0,s.useCallback)(async()=>{if(!em.current){em.current=!0,P(!0),F(null);try{let e=await sC(r);z(e),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof sg?t.status:0;F({kind:409===e?"conflict":422===e?"empty":"error",message:o4(t,"Failed to draft the verification config")}),409===e&&(eo.current=0,el(e=>e+1))}finally{em.current=!1,P(!1)}}},[r]);return{worktreeId:r,task:c,runs:u,latestRun:null!=(a=u[0])?a:null,selectedRunId:eg,selectedRun:h,loading:g,error:v,detailError:j,detailLoading:k,rerunPending:C,rerunFailure:I,config:E,configError:M,phase:u.some(e=>"running"===e.status)?"running":null===E?"unknown":E.exists?0===u.length?"configured":"result":"no-config",draftPending:L,draftFailure:D,draftResult:O,availableGateIds:ev,selectedGateIds:W,failedGateIds:ey,toggleGate:ek,setGateSelection:ew,selectFailedGates:eN,runningRun:ej,cancelPending:_,cancelSettling:null!==U&&(null==ej?void 0:ej.id)===U,cancelFailure:V,historyLimit:$,canLoadMore:u.length>=J&&J<100,repositoryHistoryOpen:Q,repositoryHistory:Z,repositoryHistoryLoading:et,repositoryHistoryError:ea,selectRun:eT,refresh:eI,rerun:eE,cancelRun:eA,loadMore:eC,toggleRepositoryHistory:eS,draftConfig:eM}}({worktreeId:h,refreshToken:W,enabled:!O&&!_});return{activeActivity:e3,activeCliTab:e_,activeInstanceId:eU,activeTab:nD,agentInstances:eE,autoYesEnabled:eQ,autoYesExpiresAt:eX,autoYesStateMap:ei,diffContent:tb,diffFilePath:tv,disableAutoFollow:tU,displayedInstances:tF,error:_,fetchCurrentOutput:tA,fileInputRef:nC,fileSearch:tw,fileTreeRefresh:eZ,handleActivityOpen:t5,handleActivityToggle:t4,handleAgentInstancesChange:tK,handleAutoYesToggle:na,handleCloseDiff:tj,handleDelete:nv,handleDiffSelect:ty,handleDirtyChange:nB,handleEditorSave:t1,handleFileInputChange:nT,handleFilePanelSave:t1,handleFilePathClick:tQ,handleFileSelect:tX,handleHistoryDisplayLimitChange:to,handleHistoryUserOnlyChange:tl,handleInfoClick:t6,handleInfoModalClose:t8,handleInsertConsumed:tp,handleInsertConsumedSingle:tg,handleInsertToMessage:tf,handleInsertToSplit:th,handleKillCancel:nx,handleKillConfirm:nm,openKillConfirm:nd,openActiveKillConfirm:nu,killTarget:nr,isKillPending:nl,handleLoadContent:nO,handleLoadError:nz,handleMessageSent:nt,handleMobileFileViewerClose:t0,handleMobileTabChange:ne,handleMove:nw,resetFileTreeView:t2,handleMoveCancel:nN,handleMoveConfirm:nk,handleNewDirectory:ng,handleNewFile:nf,handleNewFileCancel:np,handleNewFileConfirm:nh,handleOpenFile:tZ,handlePromptDismiss:t7,handlePromptRespond:t9,handleRename:nb,handleReLogin:nR,handleRetry:nM,handleSetLoading:n_,handleShowArchivedChange:ta,handleUpload:nI,handleVibeLocalContextWindowChange:tq,rosterReady:eP,instanceSelectionRequest:tz,acknowledgeInstanceSelection:tH,handleVibeLocalModelChange:tW,handleWorktreeStatusChange:t3,hasUpdate:nE,historyDisplayLimit:ti,historySubTab:te,historyUserOnly:tr,isAuthExpired:U,isInfoModalOpen:Z,isMobile:p,isMoveDialogOpen:nj,isReconnecting:V,isSelectionListActive:ey.isSelectionListActive,isPagerActive:ey.isPagerActive,promptAnswerable:ep,promptAutoYesEnterSent:eb,offersPlanApprove:ey.offersPlanApprove,isDismissablePanelActive:ey.isDismissablePanelActive,isUnclassifiedActive:ey.isUnclassifiedActive,sessionStatus:ey.sessionStatus,agentMode:ey.agentMode,startingSince:ey.startingSince,lastAutoResponse:nA,loading:O,makeAutoYesToggleHandler:nn,mobileFileViewerPath:ea,mobileSelectedAgents:tO,moveTarget:ny,newFileParentPath:e4,openMobileDrawer:b,pendingInsertText:tm,pendingInsertTextMap:tu,selectedAgents:eC,selectionListReading:es,setActiveInstanceId:eW,setFocusedSplitIndex:tx,setHistorySubTab:tt,setWorktree:F,showArchived:tn,showNewFileDialog:e1,showToast:tJ,state:k,tCommon:T,tWorktree:C,tabsActions:en,tabsState:et,toggleInstanceVisible:tP,vibeLocalContextWindow:eO,verification:nV,vibeLocalModel:eD,visibleInstanceIds:tL,worktree:D,worktreeName:nF,worktreeStatus:nP}}({worktreeId:N}),t2=(0,i.c)("auth"),[t4,t5]=(0,s.useState)(!1),[t3,t6]=(0,s.useState)(null),[t8,t9]=(0,s.useState)(ec.wf),t7="terminal"===L&&"chat"===t8,ne=(0,s.useCallback)(e=>{"memo"!==e&&t6(null),eR(e)},[eR]),nt=(0,s.useCallback)(()=>{t6(e=>{var t;return{tab:"verification",token:(null!=(t=null==e?void 0:e.token)?t:0)+1}}),eR("memo")},[eR]),nn=function(e){let{worktreeId:t,active:n}=e,{addListener:a}=(0,nj.xM)(),[r,l]=(0,s.useState)(!1),i=(0,s.useRef)(n);return i.current=n,(0,s.useEffect)(()=>{n&&l(!1)},[n]),(0,s.useEffect)(()=>a(e=>{e.worktreeId===t&&("terminal_snapshot"===e.type||"message"===e.type)&&(i.current||l(!0))}),[a,t]),!n&&r}({worktreeId:N,active:"terminal"===L}),{viewportHeight:na}=(0,oX.C)(),nr=(0,s.useCallback)(e=>{let t=cd.indexOf(L);if(-1===t)return;let n=t+e;n<0||n>=cd.length||ne(cd[n])},[L,ne]),{ref:ns}=(0,M.hU)({axis:"horizontal",threshold:60,edgeStartZone:32*("terminal"===L),onSwipeLeft:()=>nr(1),onSwipeRight:()=>nr(-1)}),nl=(0,s.useMemo)(()=>({worktreePath:null==tQ?void 0:tQ.path,openFile:ed}),[null==tQ?void 0:tQ.path,ed]),ni=null!=(y=null==(t=null!=(v=null==tQ||null==(n=tQ.sessionStatusByInstance)?void 0:n[A])?v:null==tQ||null==(a=tQ.sessionStatusByCli)?void 0:a[E])?void 0:t.isRunning)&&y,nc="number"==typeof tm||"number"==typeof(null==tQ||null==(d=tQ.sessionStatusByInstance)||null==(c=d[A])?void 0:c.startingSince),[nd,nu]=(0,s.useState)(!1),nm="terminal"!==L?"tab":"chat"===t8?"chat":ni?null:"session",nx=nd&&null===nm;(0,s.useEffect)(()=>{nu(!1)},[N,E,A]),(0,s.useEffect)(()=>{ni||nu(!1)},[ni]),(0,s.useEffect)(()=>{("terminal"!==L||"chat"===t8)&&nu(!1)},[L,t8]);let nf=(0,s.useCallback)(()=>nu(!0),[]),nh=(0,s.useCallback)(()=>nu(!1),[]),np=e7&&!nx&&!nc&&(!F||z(t_.prompt.data,tr)),{showStuckHint:nb,markSubmitted:ny}=(0,oR.Cb)({promptData:np&&t_.prompt.visible?t_.prompt.data:null,targetKey:"".concat(N,":").concat(E,":").concat(A)}),nw=(0,R.KX)(t_.prompt.visible?t_.prompt.data:null),nk=(0,s.useMemo)(()=>V(t_.prompt.data,E),[t_.prompt.data,E]),nN=(0,s.useCallback)(async e=>{let t;if(ny(),!nw)return void await eH(e);try{let n=await fetch("/api/worktrees/".concat(N,"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oB(nw,e,E,A))});t=await (0,oV.a_)(n)}catch(e){console.error("[WorktreeDetailRefactored] Error answering a decision:",e),t="failed"}if("answered"===t)eV();else{let e=oV.J4[t];tz(tV(e.messageKey),e.type)}await q()},[ny,eH,nw,N,E,A,tz,tV,q,eV]),[nC,nS]=(0,s.useState)(0),nI=(0,s.useCallback)(()=>{(0,nT.CO)(),(0,nT.If)((0,nT.NP)(N),"terminal"),eR("terminal"),t9("terminal"),nS(e=>e+1),nu(!0)},[N,eR]);if(tf)return(0,r.jsx)(tX,{});if(e3)return(0,r.jsx)(co,{message:tV("editor.sessionExpired"),loginLabel:t2("login.submitButton"),onLogin:eq});if(W)return(0,r.jsx)(tZ,{message:W,onRetry:e$});let nE=(0,eo.O6)(D,A,E),nA=null!=(j=null==eS?void 0:eS.label)?j:nE,nM=null!=(k=null==(x=null!=(w=null==tQ||null==(h=tQ.sessionStatusByInstance)?void 0:h[A])?w:null==tQ||null==(p=tQ.sessionStatusByCli)?void 0:p[E])?void 0:x.isProcessing)&&k;return e7?(0,r.jsx)(I.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsx)(ng,{onInsertToComposer:ev,children:(0,r.jsxs)(nv.k,{value:nl,children:[tt&&(0,r.jsx)(ci,{label:tB("connection.reconnecting")}),(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",style:{height:null!=na?"".concat(na,"px"):"100%"},"data-testid":"mobile-worktree-shell",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(g,{worktreeName:t0,repositoryName:null==tQ?void 0:tQ.repositoryName,status:t1,statusUnclassified:tH(t1,null==tQ?void 0:tQ.sessionStatusByCli,E),gitStatus:null==tQ?void 0:tQ.gitStatus,onMenuClick:tj})}),t$.task&&!nx&&(0,r.jsx)("div",{className:"flex-shrink-0 border-b border-border bg-surface px-3 py-1.5",children:(0,r.jsx)(oK,{task:t$.task,latestRun:t$.latestRun,latestRunGates:null!==t$.selectedRun&&t$.selectedRun.id===(null==(b=t$.latestRun)?void 0:b.id)?t$.selectedRun.gates:null,onOpen:nt,className:"w-full justify-start"})}),(null==tQ?void 0:tQ.gitStatus)&&tQ.gitStatus.isBranchMismatch&&!nx&&(0,r.jsx)("div",{className:"z-35 flex-shrink-0",children:(0,r.jsx)(oW,{isBranchMismatch:tQ.gitStatus.isBranchMismatch,currentBranch:tQ.gitStatus.currentBranch,initialBranch:tQ.gitStatus.initialBranch})}),(0,r.jsxs)("div",{className:"flex-shrink-0 z-30 flex items-center gap-2 px-3 py-1.5 bg-surface-2 border-b border-border",children:[(0,r.jsx)("nav",{className:"flex gap-1 flex-1 min-w-0 overflow-x-auto scrollbar-hide","aria-label":tV("detail.agentInstanceSelection"),children:K.map(e=>{var t,n,a;let s=null!=(a=null==tQ||null==(t=tQ.sessionStatusByInstance)?void 0:t[e.id])?a:null==tQ||null==(n=tQ.sessionStatusByCli)?void 0:n[e.cliTool],l=(0,tO.kA)(s),i=(0,m.Mq)(l,(0,tO.px)(s)),o=tB(i?m.rH:"status.".concat(l)),c=A===e.id;return(0,r.jsxs)("button",{onClick:()=>tA(e.id),className:"flex-shrink-0 whitespace-nowrap min-h-[44px] px-1.5 py-1 font-medium text-xs transition-colors flex items-center gap-1 border-b-2 touch-manipulation ".concat(c?"text-accent-600 dark:text-accent-400 border-accent-500":"text-muted-foreground hover:text-foreground border-transparent"),"aria-current":c?"page":void 0,children:[(0,r.jsx)(u.m,{status:l,size:"sm",label:tV("detail.statusPill",{label:(0,eo.sw)(e),status:o}),className:i?m.Jd:void 0,"data-unclassified":i?"true":void 0}),(0,eo.sw)(e)]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:()=>t5(!0),className:"flex-shrink-0 flex items-center justify-center min-h-[44px] min-w-[44px] rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors touch-manipulation","aria-label":tV("terminal.moreActions"),"data-testid":"mobile-more-actions-button",children:(0,r.jsx)(o.A,{size:18,"aria-hidden":"true"})})]}),(0,r.jsx)("main",{className:"flex-1 min-h-0 overflow-y-auto",ref:ns,children:(0,r.jsx)(lY,{activeTab:L,worktreeId:N,worktree:tQ,messages:t_.messages,cliToolId:E,instanceId:A,onFilePathClick:ed,onFileSelect:eu,onWorktreeUpdate:tL,onNewFile:eO,onNewDirectory:eF,onRename:eK,onDelete:en,onUpload:eQ,onMove:eL,onFileTreeReset:tW,refreshTrigger:Y,fileSearch:J,showToast:tz,selectedAgents:tg,onSelectedAgentsChange:cc,useInstanceManagement:!0,instances:D,onInstancesChange:Z,visibleInstanceIds:tY,onToggleInstanceVisible:tq,vibeLocalModel:tJ,onVibeLocalModelChange:eZ,vibeLocalContextWindow:tG,onVibeLocalContextWindowChange:eX,disableAutoFollow:U,historySubTab:e4,onHistorySubTabChange:tR,onDiffSelect:ea,onInsertToMessage:ev,showArchived:tP,onShowArchivedChange:eY,historyDisplayLimit:e2,onHistoryDisplayLimitChange:ex,historyUserOnly:e5,onHistoryUserOnlyChange:ef,verification:t$,toolsSubTabRequest:t3,onSurfaceModeChange:t9,directInputOpen:nx},nC)}),(0,r.jsxs)("div",{className:"flex-shrink-0 border-t border-border bg-surface z-30",children:[nx?(0,r.jsx)(eU,{worktreeId:N,cliToolId:E,instanceId:A,onKeysSent:q,onClose:nh},"".concat(N,":").concat(E,":").concat(A)):null,tn&&!t7&&!nx&&!nc&&(0,r.jsx)("div",{className:"px-2 pt-1 border-b border-border",children:(0,r.jsx)(eW.Z,{worktreeId:N,cliToolId:E,instanceId:A,onKeysSent:q,reading:ti,surface:"terminal",showPagerKeys:ta})}),(0,r.jsx)("div",{className:nx?"p-2 hidden":"p-2","aria-hidden":!!nx||void 0,"data-testid":"mobile-composer-wrapper",children:(0,r.jsx)(cu,{worktreeId:N,onMessageSent:eA,cliToolId:E,instanceId:A,isSessionRunning:ni,isSessionStarting:nc,isProcessing:nM,showToast:tz,pendingInsertText:tw,onInsertConsumed:eb,agentModeSlot:(0,r.jsx)(og,{worktreeId:N,cliToolId:E,instanceId:A,agentMode:tu,sessionStatus:td,isPromptWaiting:t_.prompt.visible,isSelectionListActive:tn,isDismissablePanelActive:to,isUnclassifiedActive:tc,onKeysSent:q}),autoYesSlot:(0,r.jsx)(oF.T,{enabled:F,expiresAt:O,onToggle:ee,lastAutoResponse:tx,cliToolName:E,inline:!0,showToolName:!1})})})]}),(0,r.jsx)(C,{activeTab:L,onTabChange:ne,hasNewOutput:nn,hasPrompt:t_.prompt.visible,hasUpdate:e1,inFlow:!0}),np&&(0,r.jsx)($,{promptData:nk,visible:t_.prompt.visible,answering:t_.prompt.answering,onRespond:nN,onDismiss:eV,cliToolName:(0,eo.oo)(E),showStuckHint:nb,onSwitchToDirectInput:ni?nI:void 0,answerable:tr,autoYesEnterSent:tl}),(0,r.jsx)(ej,{open:t4,onClose:()=>t5(!1),searchTarget:t7?"chat":"terminal",onSearch:()=>window.dispatchEvent(new CustomEvent(t7?"chat-search-open":"terminal-search-open")),onEnd:eC,endDisabled:!ni,onDirectInput:nf,directInputUnavailableReason:nm}),(0,r.jsx)(tv,{isOpen:null!==tp,onClose:eM,worktreeId:N,filePath:null!=tp?tp:"",onFileSaved:es,onOpenFile:ed}),(0,r.jsx)("input",{ref:G,type:"file",accept:e8.join(","),onChange:el,className:"hidden","aria-label":tV("detail.uploadFile")}),(0,r.jsx)(tF.a,{isOpen:null!==eS,onClose:ew,title:tV("session.confirmEnd",{tool:nA}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:tV("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:ew,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:tB("cancel")}),(0,r.jsx)("button",{type:"button",onClick:ek,disabled:eI,className:"px-4 py-2 text-sm font-medium rounded-md bg-danger hover:bg-danger/90 text-white disabled:opacity-60 disabled:cursor-not-allowed",children:tB("end")})]})]})}),tb&&(0,r.jsx)(oG,{isOpen:te,onClose:eP,onConfirm:eD,worktreeId:N,sourcePath:tb.path,sourceType:tb.type}),(0,r.jsx)(oY,{isOpen:tD,parentPath:ty,onConfirm:e_,onCancel:ez})]})]})})}):(0,r.jsxs)(nv.k,{value:nl,children:[tt&&(0,r.jsx)(ci,{label:tB("connection.reconnecting")}),(0,r.jsx)(oQ,{worktreeId:N,worktree:tQ,worktreeName:t0,worktreeStatus:t1,instances:D,rosterReady:tI,activeInstanceId:A,setActiveInstanceId:tA,instanceSelectionRequest:tT,onInstanceSelectionHandled:tE,hasUpdate:e1,lastAutoResponse:tx,activeActivity:T,onActivityToggle:X,onActivityOpen:Q,verification:t$,onInfoClick:eh,onWorktreeStatusChange:e0,pendingInsertTextMap:tC,setFocusedSplitIndex:tM,handleInsertToSplit:ey,handleInsertConsumed:eg,handleInsertToMessage:ev,autoYesStateMap:_,makeAutoYesToggleHandler:th,showArchived:tP,onShowArchivedChange:eY,historyDisplayLimit:e2,onHistoryDisplayLimitChange:ex,historyUserOnly:e5,onHistoryUserOnlyChange:ef,onMessageSent:eA,onFilePathClick:ed,showToast:tz,tabsState:tK,tabsActions:tU,onLoadContent:eT,onLoadError:eE,onSetLoading:eJ,onFilePanelSave:ei,onDirtyChange:er,onOpenFile:eB,diffContent:B,diffFilePath:H,onCloseDiff:et,fileSearch:J,fileTreeRefresh:Y,onFileSelect:eu,onNewFile:eO,onNewDirectory:eF,onRename:eK,onDelete:en,onUpload:eQ,onMove:eL,onFileTreeReset:tW,onDiffSelect:ea,onAgentInstancesChange:Z,vibeLocalModel:tJ,onVibeLocalModelChange:eZ,vibeLocalContextWindow:tG,onVibeLocalContextWindowChange:eX,isInfoModalOpen:e9,onInfoModalClose:ep,onWorktreeUpdate:tL,fileInputRef:G,onFileInputChange:el,onKillSession:eC,onRequestSessionEnd:eN,killTarget:eS,isKillPending:eI,onKillCancel:ew,onKillConfirm:ek,moveTarget:tb,isMoveDialogOpen:te,onMoveCancel:eP,onMoveConfirm:eD,showNewFileDialog:tD,newFileParentPath:ty,onNewFileConfirm:e_,onNewFileCancel:ez,killDialogTitle:tV("session.confirmEnd",{tool:nA}),killDialogWarning:tV("session.endWarning"),cancelLabel:tB("cancel"),endLabel:tB("end")})]})});var cx=n(43424);function cf(){let e=(0,l.useParams)().id;return(0,s.useEffect)(()=>{(0,cx.hO)(e)},[e]),(0,r.jsx)(cm,{worktreeId:e})}}},e=>{e.O(0,[6481,6809,4909,2770,2619,8566,6322,8283,5521,6192,1642,8407,2407,344,6654,8606,4768,2751,8165,8811,4727,9619,2053,998,8441,1255,7358],()=>e(e.s=20252)),_N_E=e.O()}]);