commandmate 0.35.0 → 0.36.0

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 (230) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +328 -319
  3. package/.next/app-path-routes-manifest.json +26 -26
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +9 -9
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/api/agents/update/route_client-reference-manifest.js +1 -1
  9. package/.next/server/app/api/agents/versions/route_client-reference-manifest.js +1 -1
  10. package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
  11. package/.next/server/app/api/app/update-check/route.js +1 -1
  12. package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/capabilities/route.js +1 -1
  24. package/.next/server/app/api/capabilities/route_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
  27. package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
  30. package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
  33. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/relays/[relayId]/cancel/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/relays/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/remote/pair/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  45. package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  47. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  48. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  50. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  53. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  54. package/.next/server/app/api/settings/default-agents/route_client-reference-manifest.js +1 -1
  55. package/.next/server/app/api/settings/default-surface-mode/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  59. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  63. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  64. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  66. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
  70. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  71. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/worktrees/[id]/clear-composer/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/worktrees/[id]/cli-reference/route_client-reference-manifest.js +1 -1
  74. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  76. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  77. package/.next/server/app/api/worktrees/[id]/env/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  79. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  80. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  83. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  84. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  86. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  87. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  89. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  90. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  92. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  93. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  95. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  96. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  99. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  101. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  102. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  104. package/.next/server/app/api/worktrees/[id]/instances/notes/route_client-reference-manifest.js +1 -1
  105. package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  107. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  108. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  111. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  112. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  114. package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +1 -1
  117. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  118. package/.next/server/app/api/worktrees/[id]/resolve-target/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  121. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  124. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  125. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  128. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  129. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  131. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
  133. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  135. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  136. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
  137. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  139. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  140. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  141. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  143. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  144. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  145. package/.next/server/app/api/worktrees/[id]/verify/config/route_client-reference-manifest.js +1 -1
  146. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
  147. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route_client-reference-manifest.js +1 -1
  148. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
  149. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
  150. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  151. package/.next/server/app/api/worktrees/apply-default-agents/route_client-reference-manifest.js +1 -1
  152. package/.next/server/app/api/worktrees/route.js +1 -1
  153. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  154. package/.next/server/app/chat/page.js +2 -2
  155. package/.next/server/app/chat/page.js.nft.json +1 -1
  156. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  157. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  158. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  159. package/.next/server/app/more/page.js +2 -2
  160. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  161. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  162. package/.next/server/app/page_client-reference-manifest.js +1 -1
  163. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  164. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  165. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  166. package/.next/server/app/sessions/page.js +2 -2
  167. package/.next/server/app/sessions/page.js.nft.json +1 -1
  168. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  169. package/.next/server/app/skills/[skillId]/page.js +1 -1
  170. package/.next/server/app/skills/[skillId]/page.js.nft.json +1 -1
  171. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  172. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  173. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  174. package/.next/server/app/worktrees/[id]/files/[...path]/page.js +2 -2
  175. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  176. package/.next/server/app/worktrees/[id]/page.js +9 -22
  177. package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
  178. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  179. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  180. package/.next/server/app-paths-manifest.json +26 -26
  181. package/.next/server/chunks/1707.js +14 -0
  182. package/.next/server/chunks/3123.js +1 -1
  183. package/.next/server/chunks/3543.js +1 -1
  184. package/.next/server/chunks/364.js +1 -0
  185. package/.next/server/chunks/3945.js +1 -1
  186. package/.next/server/chunks/4802.js +1 -1
  187. package/.next/server/chunks/6130.js +1 -1
  188. package/.next/server/chunks/7004.js +1 -0
  189. package/.next/server/chunks/8142.js +1 -0
  190. package/.next/server/chunks/8728.js +1 -1
  191. package/.next/server/chunks/9123.js +1 -1
  192. package/.next/server/chunks/9627.js +1 -1
  193. package/.next/server/chunks/9701.js +1 -0
  194. package/.next/server/middleware-build-manifest.js +1 -1
  195. package/.next/server/middleware-manifest.json +5 -5
  196. package/.next/server/pages/500.html +1 -1
  197. package/.next/server/server-reference-manifest.json +1 -1
  198. package/.next/static/chunks/2039-117a361f795ddc4b.js +1 -0
  199. package/.next/static/chunks/2053-ce3fe896ad45e50f.js +1 -0
  200. package/.next/static/chunks/2407-6b8ca567e18ad583.js +1 -0
  201. package/.next/static/chunks/3160-79d24ca264a528b9.js +1 -0
  202. package/.next/static/chunks/4949-d804db873cfd9310.js +1 -0
  203. package/.next/static/chunks/{6022-7a7d1760fc9814c7.js → 6022-d2d7bd9373ff3ae9.js} +1 -1
  204. package/.next/static/chunks/6983-3ed2099251793bdf.js +1 -0
  205. package/.next/static/chunks/934-a37509667baa86ee.js +1 -0
  206. package/.next/static/chunks/9526-4fe2fc64be44e5c1.js +1 -0
  207. package/.next/static/chunks/app/chat/page-bfc1f5bb17bd771d.js +1 -0
  208. package/.next/static/chunks/app/more/page-400ffa825f8f150e.js +1 -0
  209. package/.next/static/chunks/app/sessions/page-366edfaa0b1faad2.js +1 -0
  210. package/.next/static/chunks/app/skills/[skillId]/{page-844872df04f52943.js → page-ce8f6fd9e4356580.js} +1 -1
  211. package/.next/static/chunks/app/worktrees/[id]/page-df482ec0c378c77b.js +1 -0
  212. package/.next/static/chunks/{webpack-1dc9eb5ebb4fa5ff.js → webpack-0281b30457d46ebc.js} +1 -1
  213. package/.next/static/css/c511ecdf1e7f18a0.css +1 -0
  214. package/.next/trace +14 -14
  215. package/dist/server/src/lib/auto-yes-state.js +36 -0
  216. package/package.json +1 -1
  217. package/.next/server/chunks/120.js +0 -1
  218. package/.next/server/chunks/7593.js +0 -1
  219. package/.next/static/chunks/1191-b7dfdfe86b1d31d1.js +0 -1
  220. package/.next/static/chunks/2053-9ac860ab4e92ac89.js +0 -1
  221. package/.next/static/chunks/2407-b9001cc6041876e1.js +0 -1
  222. package/.next/static/chunks/4809-145884b958e7d9a6.js +0 -1
  223. package/.next/static/chunks/5542-b6457f305d724a6b.js +0 -1
  224. package/.next/static/chunks/app/chat/page-609c9a0f5ce44799.js +0 -1
  225. package/.next/static/chunks/app/more/page-7c5380e4a7561935.js +0 -1
  226. package/.next/static/chunks/app/sessions/page-6486d9a643c1dc6f.js +0 -1
  227. package/.next/static/chunks/app/worktrees/[id]/page-3a58ae66e203f935.js +0 -1
  228. package/.next/static/css/b09bede85744e1cf.css +0 -1
  229. /package/.next/static/{0vChXhzA5YWj3f0D6A-Cn → zNNp00FuBenN_iZtIvIBP}/_buildManifest.js +0 -0
  230. /package/.next/static/{0vChXhzA5YWj3f0D6A-Cn → zNNp00FuBenN_iZtIvIBP}/_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:h}=e,f=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(f){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,f,d,g,b,x]),E=(0,a.useCallback)(e=>{var a;if(!i||!N.current)return void j(!1);let o=f&&(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==h||h()},[i,l,f,g,b,t,n,r,s,h]),A=(0,a.useCallback)(()=>{N.current&&(N.current=null,C.current=null,j(!1),null==h||h())},[h]);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,35499))},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},35499:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>iK});var a,r=n(95155),s=n(20063),l=n(54388),i=n(12115),o=n(67909),c=n(18955),d=n(37772),u=n(3005),m=n(28019),x=n(48481),h=n(92614),f=n(64269);let p=(0,i.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})})}),g={back:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z",menu:"M4 6h16M4 12h16M4 18h16",search:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"};function b(e){let{worktreeName:t,repositoryName:n,status:a,gitStatus:s,onBackClick:l,onMenuClick:i}=e,o=(0,c.c)("common"),d=(0,c.c)("worktree"),u=(0,c.c)("commandPalette"),{setOpen:b}=(0,h.C)();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:l&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,"aria-label":o("back"),className:"p-2 -ml-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(p,{path:g.back})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:[(0,r.jsx)(x.m,{"data-testid":"status-indicator",status:a,size:"sm",className:"mr-2"}),(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}),s&&"(unknown)"!==s.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:s.currentBranch,"data-testid":"mobile-branch-name",children:(0,f.W5)(s.currentBranch,20)}),s.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:d("git.uncommittedChanges"),children:"*"})]})]})]})]}),(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-end",children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button","data-testid":"mobile-header-command-palette-trigger",onClick:()=>b(!0),"aria-label":u("mobileTrigger"),title:u("mobileTrigger"),className:"p-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(p,{path:g.search})}),i&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:i,"aria-label":o("menu"),className:"p-2 -mr-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(p,{path:g.menu})})]})]})})}var v=n(22479),y=n(26983),j=n(59847),w=n(53842),k=n(23327);function N(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 C=[{id:"terminal",labelKey:"tabs.terminal",icon:(0,r.jsx)(v.A,{size:20,"aria-hidden":"true"})},{id:"history",labelKey:"tabs.history",icon:(0,r.jsx)(y.A,{size:20,"aria-hidden":"true"})},{id:"files",labelKey:"tabs.files",icon:(0,r.jsx)(j.A,{size:20,"aria-hidden":"true"})},{id:"memo",labelKey:"tabs.memo",icon:(0,r.jsx)(w.A,{size:20,"aria-hidden":"true"})},{id:"info",labelKey:"tabs.info",icon:(0,r.jsx)(k.A,{size:20,"aria-hidden":"true"})}];function S(e){let{activeTab:t,onTabChange:n,hasNewOutput:a=!1,hasPrompt:s=!1,hasUpdate:l=!1,onSearchParamsChange:o,inFlow:d=!1}=e,u=(0,c.c)("worktree"),m=(0,i.useRef)([]),x=(0,i.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]),h=(0,i.useCallback)(e=>{n(e),null==o||o("memo"===e?"notes":e)},[n,o]),f=(0,i.useCallback)((e,t)=>{var n;let a=null;switch(e.key){case"ArrowRight":case"ArrowDown":a=(t+1)%C.length;break;case"ArrowLeft":case"ArrowUp":a=(t-1+C.length)%C.length;break;case"Home":a=0;break;case"End":a=C.length-1;break;default:return}e.preventDefault(),null==(n=m.current[a])||n.focus(),h(C[a].id)},[h]),p=(0,i.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")}),s&&(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,s,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:C.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:()=>h(e.id),onKeyDown:e=>f(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&&l&&(0,r.jsx)(N,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":u("tabs.updateAvailable")})]},e.id))})}var I=n(68276),T=n(87364);let E={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function A(e){let{visible:t,duration:n=200}=e,[a,r]=(0,i.useState)(t?"visible":"hidden"),s=(0,i.useRef)(null),l=(0,i.useRef)(t);(0,i.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),(0,i.useEffect)(()=>{let e=l.current;l.current=t,s.current&&(clearTimeout(s.current),s.current=null);let a=e=>{s.current=setTimeout(()=>{r(e),s.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,i.useMemo)(()=>{switch(a){case"fade-in":return E.fadeIn;case"fade-out":return E.fadeOut;default:return E.none}},[a]),isAnimating:c}}var M=n(92539),R=n(8269);let L={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"},P=(0,i.memo)(function(e){let{promptData:t,visible:n,answering:a,onRespond:s,onDismiss:l,cliToolName:o}=e,{shouldRender:c,animationClass:d}=A({visible:n&&null!==t,duration:300}),u=(0,i.useId)(),m=n&&null!==t,x=(0,M.r)({active:m}),[h,f]=(0,i.useState)(0);(0,i.useEffect)(()=>{n||f(0)},[n]);let p=(0,i.useCallback)(e=>{let{deltaY:t}=e;f(t>0?t:0)},[]),g=(0,i.useCallback)(()=>{null==l||l()},[l]),b=(0,i.useCallback)(()=>{f(0)},[]),{ref:v}=(0,R.hU)({axis:"vertical",threshold:100,enabled:m,onSwipeMove:p,onSwipeDown:g,onSwipeEnd:b}),y=(0,i.useCallback)(e=>{x.current=e,v.current=e},[x,v]),j=(0,i.useCallback)(()=>{l&&l()},[l]),w=(0,i.useCallback)(e=>{e.stopPropagation()},[]);if(!c||!t)return null;let k="animate-fade-out"===d;return(0,r.jsxs)(T.t,{componentName:"MobilePromptSheet",children:[(0,r.jsx)("div",{"data-testid":"prompt-overlay",onClick:j,className:"fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ".concat(k?"opacity-0":"opacity-100"," ").concat(k?"pointer-events-none":""),"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:y,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":u,onClick:w,style:{transform:h>0?"translateY(".concat(h,"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(k?"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.jsx)("div",{className:"px-4 pb-6",children:(0,r.jsx)(D,{promptData:t,answering:a,onRespond:s,labelId:u,cliToolName:o})})]})]})});function D(e){let{promptData:t,answering:n,onRespond:a,labelId:s,cliToolName:l}=e,o=(0,c.c)("prompt"),[d,u]=(0,i.useState)(()=>{if("multiple_choice"===t.type){var e;let n=t.options.find(e=>e.isDefault);return null!=(e=null==n?void 0:n.number)?e:null}return null}),[x,h]=(0,i.useState)(""),[f,p]=(0,i.useState)(!1),g=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===d))?e:null},[t,d]),b=(null==g?void 0:g.requiresTextInput)===!0,v=n||f,y=(0,i.useCallback)(async e=>{if(!v){p(!0);try{await a(e)}catch(e){}finally{p(!1)}}},[v,a]),j=(0,i.useCallback)(async()=>{if(!v&&null!==d){p(!0);try{let e=b&&x.trim()?x.trim():d.toString();await a(e)}catch(e){}finally{p(!1)}}},[v,a,d,b,x]);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?o("confirmationFrom",{toolName:l}):o("confirmationFromClaude")}),(0,I.XF)(t)&&t.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:t.instructionText}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:t.question}),v&&(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)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:o("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(F,{promptData:t,disabled:v,onYes:()=>y("yes"),onNo:()=>y("no")}),"multiple_choice"===t.type&&(0,r.jsx)(O,{promptData:t,disabled:v,selectedOption:d,onSelectOption:u,textInputValue:x,onTextInputChange:h,showTextInput:b,onSubmit:j})]})}let F=(0,i.memo)(function(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,c.c)("prompt"),i="yes"===t.defaultOption,o="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(L.base," ").concat(L.primary," ").concat(i?"ring-2 ring-accent-300":""),children:l("yes")}),(0,r.jsx)("button",{type:"button",onClick:s,disabled:n,className:"flex-1 ".concat(L.base," ").concat(o?L.defaultSelected:L.secondary),children:l("no")})]})}),O=(0,i.memo)(function(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,x=(0,i.useId)(),h=(0,c.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:h("selectAnOption")}),(0,r.jsx)(m.z6,{name:x,value:null!=a?String(a):"",onValueChange:e=>s(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)(m.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:h("default")})]})]},e.number)})})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(x),className:"sr-only",children:h("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:h("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:u,disabled:n||null===a,className:"w-full ".concat(L.base," ").concat(L.primary),children:h("submit")})]})});var z=n(86651),_=n(11047),V=n(84926),B=n(37586),U=n(24033),W=n(97624),H=n(37354),K=n(54014),$=n(75676),q=n(26232),G=n(41898),J=n(66966),Y=n(83012);let Q="application/x-commandmate-agent-instance",X=[{mode:"terminal",labelKey:"surfaceMode.showTerminal",icon:v.A},{mode:"chat",labelKey:"surfaceMode.showChat",icon:B.A}],Z="session-note-open";function ee(e,t){let n=(0,J.rC)(),a=null==n?void 0:n.worktrees,r=null==n?void 0:n.refresh,s=(0,i.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]),[l,o]=(0,i.useState)(null);(0,i.useEffect)(()=>{o(null)},[e,t]),(0,i.useEffect)(()=>{var e,t;if(null===l)return;let n=null===l.value?null===s:null!==s&&s.text===l.value.text,a=(null==s?void 0:s.text)!==(null==(e=l.base)?void 0:e.text)||(null==s?void 0:s.updatedAt)!==(null==(t=l.base)?void 0:t.updatedAt);(n||a)&&o(null)},[l,s]);let c=(0,i.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:s}),(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,s,e]);return{note:l?l.value:s,save:c}}function et(e){let{initialText:t,onCommit:n,onCancel:a,ariaLabel:s,placeholder:l,testId:o}=e,[c,d]=(0,i.useState)(t),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()},[]);let m=(0,i.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:l,"aria-label":s,"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 en=(0,i.memo)(function(e){var t;let{worktreeId:n,splitIndex:a,cliToolId:s,instanceId:l,instance:o,availableInstances:d,onInstanceChange:u,status:m="idle",agentModel:h,agentUsage:f,agentUsageDetail:p,onFocus:g,attaching:b=!1,headerExtras:v,surfaceMode:y=$.wf,onSurfaceModeChange:j,isMaximized:w=!1,onToggleMaximize:k,terminal:N,footer:C,style:S,onDropInstance:I,draggedInstanceId:T}=e,E=(0,c.c)("worktree"),[A,M]=(0,i.useState)(null),{note:R,save:L}=ee(n,l),[P,D]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(!1)},[n,l]);let F=(0,i.useCallback)(()=>D(!0),[]),O=(0,i.useCallback)(()=>D(!1),[]),z=(0,i.useCallback)(e=>{L(e),D(!1)},[L]),V=(0,i.useCallback)(()=>{setTimeout(()=>D(!0),0)},[]),B=null!=I,J=(0,i.useCallback)(()=>null==T||d.some(e=>e.id===T)?"allowed":"forbidden",[T,d]),Z=(0,i.useCallback)(e=>{if(!B)return;e.preventDefault();let t=J();e.dataTransfer.dropEffect="forbidden"===t?"none":"move",M(e=>e===t?e:t)},[B,J]),en=(0,i.useCallback)(e=>{if(!B)return;e.preventDefault();let t=J();M(e=>e===t?e:t)},[B,J]),ea=(0,i.useCallback)(()=>{B&&M(null)},[B]),er=(0,i.useCallback)(e=>{if(!B)return;e.preventDefault(),M(null);let t=e.dataTransfer.getData(Q);t&&(null==I||I(t))},[B,I]),es=(0,i.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),el=(0,i.useCallback)(()=>{g()},[g]),ei="Terminal split ".concat(a+1),eo=(0,K.sw)(null!=o?o:{cliTool:s}),ec=E("terminal.selectInstance",{split:ei}),ed=E("terminal.searchOutput",{split:ei}),eu=E("sessionNote.editLabel",{split:ei}),em=R?(0,Y.Uq)(new Date(R.updatedAt)):"",ex=R?E("sessionNote.label",{note:R.text,time:em}):"";return(0,r.jsxs)("div",{role:"region","aria-label":ei,"data-testid":"terminal-split-pane-".concat(a),"data-split-index":a,style:S,className:"flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface".concat(null===A?" focus-within:ring-1 focus-within:ring-accent-500/30":"").concat("allowed"===A?" ring-2 ring-accent-400":"forbidden"===A?" ring-2 ring-red-300 cursor-not-allowed":""),onFocusCapture:el,onMouseDown:g,onDragOver:Z,onDragEnter:en,onDragLeave:ea,onDrop:er,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)(q.rI,{children:[(0,r.jsxs)(q.ty,{"data-testid":"cli-selector-".concat(a),"aria-label":ec,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)(x.m,{status:m,size:"sm","aria-hidden":!0,"data-testid":"split-status-indicator-".concat(a)}),(0,r.jsx)("span",{className:"truncate",children:eo}),(0,r.jsx)(U.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,r.jsxs)(q.SQ,{align:"start",className:"min-w-[10rem]",children:[(0,r.jsx)(q.Hr,{value:l,onValueChange:u,children:d.map(e=>(0,r.jsx)(q.Ht,{value:e.id,children:(0,K.sw)(e)},e.id))}),(0,r.jsx)(q.mB,{}),(0,r.jsxs)(q._2,{"data-testid":"split-session-note-menu-item-".concat(a),onSelect:V,children:[(0,r.jsx)(_.A,{size:14,"aria-hidden":"true",className:"opacity-70"}),E("sessionNote.menuItem")]})]})]}),j?(0,r.jsx)("div",{role:"group","aria-label":E("surfaceMode.groupLabel",{split:ei}),"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:X.map(e=>{let{mode:t,labelKey:n,icon:s}=e,l=y===t,i=E(n);return(0,r.jsx)(G.m_,{content:i,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:()=>j(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,h&&(0,r.jsx)("span",{"data-testid":"split-agent-model-".concat(a),title:E("agentModel.modelLabel",{model:h}),className:"min-w-0 truncate text-[11px] leading-none text-muted-foreground ".concat(R?"max-w-[5rem] shrink-[4]":"max-w-[10rem]"),children:h}),f&&(0,r.jsx)("span",{"data-testid":"split-agent-usage-".concat(a),title:null!=p?p:E("agentSession.chipLabel",{usage:f}),className:"min-w-0 max-w-[10rem] truncate text-[11px] leading-none tabular-nums text-muted-foreground",children:f}),R&&(0,r.jsxs)("button",{type:"button",onClick:F,"aria-label":eu,title:ex,"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)(_.A,{size:11,"aria-hidden":"true",className:"shrink-0 opacity-70"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:R.text}),(0,r.jsx)("span",{"data-testid":"split-session-note-time-".concat(a),className:"shrink-0 tabular-nums opacity-70",children:em})]}),v,(0,r.jsx)(G.m_,{content:ed,placement:"bottom",className:"ml-auto",children:(0,r.jsx)("button",{type:"button",onClick:es,"aria-label":ed,"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"})})})}),k?(0,r.jsx)(G.m_,{content:"".concat(w?E("terminal.restoreSplits"):E("terminal.maximizeSplit",{split:ei})," — ").concat(E("terminal.maximizeShortcutHint")),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsx)("button",{type:"button",onClick:k,"aria-pressed":w,"aria-label":w?E("terminal.restoreSplits"):E("terminal.maximizeSplit",{split:ei}),"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:w?(0,r.jsx)(W.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(H.A,{size:14,"aria-hidden":"true"})})}):null,P?(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)(et,{initialText:null!=(t=null==R?void 0:R.text)?t:"",onCommit:z,onCancel:O,ariaLabel:eu,placeholder:E("sessionNote.placeholder"),testId:"split-session-note-input-".concat(a)}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:E("sessionNote.hint")})]}):null]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[b?(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 ",eo," session..."]}):null,N]}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:C})]})});function ea(e){let{open:t,onClose:n,onSearch:a,onEnd:s,endDisabled:l=!1}=e,o=(0,c.c)("worktree"),d=(0,i.useId)(),u=(0,M.r)({active:t}),m=(0,i.useCallback)(()=>{a(),n()},[a,n]),x=(0,i.useCallback)(()=>{s(),n()},[s,n]),h=(0,i.useCallback)(()=>{window.dispatchEvent(new CustomEvent(Z)),n()},[n]);return((0,i.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:u,"data-testid":"mobile-terminal-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":d,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:d,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:o("terminal.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-search",onClick:m,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)(z.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),o("terminal.searchTerminal")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-session-note",onClick:h,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)(_.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),o("sessionNote.menuItem")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-end",onClick:x,disabled:l,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)(V.A,{size:18,"aria-hidden":"true"}),o("terminal.endSession")]})]})]})]}):null}var er=n(73333),es=n(60734),el=n(31166),ei=n(36402),eo=n(17846),ec=n(69264),ed=n(27307),eu=n(24027),em=n(5917),ex=n(75426),eh=n(51963),ef=n(39867);let ep="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 eg(e){let{open:t,onClose:n,onSearch:a,onCopyContent:s,onCopyPath:l,downloadUrl:o,downloadName:d,contentCopied:u,pathCopied:m}=e,x=(0,c.c)("worktree"),h=(0,i.useId)(),f=(0,M.r)({active:t}),p=(0,i.useCallback)(()=>{a(),n()},[a,n]),g=(0,i.useCallback)(()=>{s(),n()},[s,n]),b=(0,i.useCallback)(()=>{l(),n()},[l,n]);return((0,i.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:f,"data-testid":"mobile-file-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":h,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:h,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:ep,children:[(0,r.jsx)(z.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:ep,children:[u?(0,r.jsx)(em.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(ex.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:ep,children:[m?(0,r.jsx)(em.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(eh.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.copyFilePath")]}),(0,r.jsxs)("a",{"data-testid":"download-file-button",href:o,download:d,onClick:n,className:ep,"aria-label":x("actions.downloadFile"),children:[(0,r.jsx)(ef.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.downloadFile")]})]})]})]}):null}var eb=n(11063);let ev=[{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"]}],ey=ev.map(e=>e.extension),ej=[".md",".html",".htm",".yaml",".yml",".txt"];function ew(e){if(!e)return!1;let t=e.toLowerCase();return ej.includes(t)}eb.j6,eb.j6;var ek=n(60322),eN=n(65229),eC=n(99708),eS=n(57828),eI=n(18514),eT=n(59854),eE=n(76246),eA=n(78660);function eM(e){let[t,n]=(0,i.useState)(!1),[a,r]=(0,i.useState)(""),[s,l]=(0,i.useState)(""),[o,c]=(0,i.useState)([]),[d,u]=(0,i.useState)(0),m=(0,i.useRef)(null),x=(0,i.useRef)(null),h=(0,i.useCallback)(()=>{n(!0),setTimeout(()=>{var e;return null==(e=m.current)?void 0:e.focus()},50)},[]),f=(0,i.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),p=(0,i.useCallback)(()=>{n(!1),r(""),l(""),c([]),u(0),f()},[f]);(0,i.useEffect)(()=>{if(!a||a.length<eA.E2){l(""),f();return}return f(),x.current=setTimeout(()=>{l(a)},eA.e1),f},[a,f]),(0,i.useEffect)(()=>{if(!s||s.length<eA.E2||!e){c([]),u(0);return}let t=e.split("\n"),n=s.toLowerCase(),a=[];t.forEach((e,t)=>{e.toLowerCase().includes(n)&&a.push(t+1)}),c(a),u(0)},[s,e]);let g=(0,i.useCallback)(()=>{0!==o.length&&u(e=>(e+1)%o.length)},[o.length]),b=(0,i.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:h,closeSearch:p,nextMatch:g,prevMatch:b,setSearchQuery:r}}var eR=n(4138),eL=n(90487);function eP(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex h-full items-center justify-center bg-surface text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}n(1226);let eD=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(eP,{})}),eF="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",eO=/^---\s*\nmarp:\s*true/;function ez(e){let{searchInputRef:t,searchQuery:n,searchMatches:a,searchCurrentIdx:s,onQueryChange:l,onPrev:i,onNext:o,onClose:d}=e,u=(0,c.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?i():o())},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:i,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: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.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)(eN.A,{className:"w-4 h-4"})})]})}let e_="\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 eV(e){let{htmlContent:t,filePath:n}=e,[a,s]=(0,i.useState)("preview"),[l,o]=(0,i.useState)("safe"),d=(0,i.useRef)(new Set),u=(0,c.c)("worktree"),m=(0,ei.SC)(),x=(0,i.useCallback)(async e=>{if("interactive"===e&&!d.current.has(n)){if(!await m({description:u("htmlPreview.interactiveModeConfirm")}))return;d.current.add(n)}o(e)},[n,m,u]),h=(0,i.useMemo)(()=>"interactive"!==l?t:t.includes("</body>")?t.replace("</body>","".concat(e_,"</body>")):t+e_,[t,l]);(0,i.useEffect)(()=>{if("interactive"!==l)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)},[l]);let f=(0,i.useMemo)(()=>{try{return eL.A.highlight(t,{language:"html",ignoreIllegals:!0}).value}catch(e){return eL.A.highlightAuto(t).value}},[t]),p=(0,i.useMemo)(()=>Array.from({length:t.split("\n").length},(e,t)=>t+1),[t]),g=(0,i.useMemo)(()=>f.split("\n"),[f]);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:()=>s(e),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat(a===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?u("fileViewer.tabSource"):u("fileViewer.tabPreview")},e))}),(0,r.jsx)("div",{className:"flex gap-1",children:["safe","interactive"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>x(e),className:"px-2 py-1 text-xs font-medium rounded-md transition-colors ".concat(l===e?"safe"===e?"bg-success-subtle text-success-foreground":"bg-warning-subtle text-warning-foreground":"text-muted-foreground hover:bg-muted"),children:"safe"===e?u("fileViewer.sandboxSafe"):u("fileViewer.sandboxInteractive")},e))})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:"source"===a?(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:p.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=g[n])?t:""}})})})]},e)})})}):(0,r.jsx)("iframe",{srcDoc:h,sandbox:eb.Ko[l],title:u("htmlPreview.title",{path:n}),className:"w-full h-full border-0 bg-white"},"".concat(n,"-").concat(l))})]})}function eB(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)(eC.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}let eU=(0,i.memo)(function(e){var t;let{isOpen:n,onClose:a,worktreeId:s,filePath:l,onFileSaved:o,onOpenFile:u}=e,[x,h]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),{copied:v,markCopied:y,reset:j}=(0,eR.q)(),{copied:w,markCopied:k}=(0,eR.q)(),[N,C]=(0,i.useState)(null),[S,I]=(0,i.useState)(0),[T,E]=(0,i.useState)(!1),[A,M]=(0,i.useState)("viewer"),[R,L]=(0,i.useState)(!1),[P,D]=(0,i.useState)(null),[F,O]=(0,i.useState)(!1),_=(0,i.useRef)(null),V=(0,c.c)("worktree"),B=(0,ei.SC)(),U=x?null!=P?P:x.content:void 0,{searchOpen:K,searchQuery:$,searchMatches:q,searchCurrentIdx:G,searchInputRef:J,openSearch:Y,closeSearch:Q,nextMatch:X,prevMatch:Z,setSearchQuery:ee}=eM(U),et=(0,i.useMemo)(()=>!!((null==x?void 0:x.content)&&!x.isImage&&!x.isVideo&&!x.isPdf),[x]),en=null!=(t=null==x?void 0:x.extension.toLowerCase())?t:"",ea="md"===en,er=!!(x&&!x.readOnly&&!x.isHtml&&ew(".".concat(en))),es=ea?A:K?"viewer":"editor",el=(0,i.useCallback)(async()=>{if(et&&U)try{await (0,ek.l)(U),y()}catch(e){}},[et,U,y]),ep=(0,i.useCallback)(async()=>{try{await (0,ek.l)(l),k()}catch(e){}},[l,k]),eb=(0,i.useCallback)(()=>{E(e=>!e)},[]);(0,i.useEffect)(()=>{if(0===q.length||!_.current)return;let e=q[G],t=_.current.querySelector('[data-line="'.concat(e,'"]'));t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})},[G,q]),(0,i.useEffect)(()=>{if(!T||er)return;let e=e=>{"Escape"===e.key&&E(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T,er]),(0,i.useEffect)(()=>{if(!n||!l){h(null),b(null),j(),M("viewer"),L(!1),D(null),O(!1),Q();return}M("viewer"),L(!1),D(null),O(!1),(async()=>{p(!0),b(null);try{let t=await fetch("/api/worktrees/".concat(s,"/files/").concat((0,eE.o)(l)));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)||V("fileViewer.loadError");throw Error(a)}let n=await t.json();h(n)}catch(e){b(e instanceof Error?e.message:V("fileViewer.loadError"))}finally{p(!1)}})()},[n,s,l]),(0,i.useEffect)(()=>{C(null),I(0),x&&"md"===x.extension&&eO.test(x.content)&&!(x.content.length>1e6)&&(async()=>{try{let e=await fetch("/api/worktrees/".concat(s,"/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,s]);let ev=!!(N&&N.length>0),ey=(0,i.useCallback)(e=>{D(e)},[]),ej=(0,i.useCallback)((e,t)=>{h(e=>e?{...e,content:t}:e),D(t),null==o||o(e)},[o]),eC=(0,i.useCallback)(async()=>{(!F||await B({description:V("editor.unsavedCloseConfirm"),variant:"danger"}))&&a()},[F,B,V,a]);(0,i.useEffect)(()=>{if(!er||R)return;let e=e=>{"Escape"===e.key&&(K?Q():T?E(!1):eC())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[er,R,K,T,eC]);let[eA,eP]=(0,i.useState)("");(0,i.useEffect)(()=>{ea&&"viewer"===es&&void 0!==U&&eP(U)},[ea,es,U]),(0,i.useEffect)(()=>{if(!er||!n)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[er,n]);let e_=(0,i.useMemo)(()=>{if(!x||void 0===U||x.isImage||x.isVideo||x.isHtml||x.isPdf)return null;let e=Array.from({length:U.split("\n").length},(e,t)=>t+1);try{return{lineNumbers:e,highlightedHtml:eL.A.highlight(U,{language:x.extension,ignoreIllegals:!0}).value}}catch(t){return{lineNumbers:e,highlightedHtml:eL.A.highlightAuto(U).value}}},[x,U]),eU=()=>x?x.isImage?(0,r.jsx)(eo.a,{src:x.content,alt:x.path,mimeType:x.mimeType}):x.isVideo?(0,r.jsx)(ec.u,{src:x.content,mimeType:x.mimeType}):x.isPdf?(0,r.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,r.jsx)(ed.PdfPreview,{dataUri:x.content,filePath:l,variant:"download"})}):x.isHtml?(0,r.jsx)(eV,{htmlContent:x.content,filePath:l}):eW():null,eW=()=>{if(!e_)return null;let e=new Set(q),t=q.length>0?q[G]:-1,n=e_.highlightedHtml.split("\n");return(0,r.jsx)("div",{ref:_,children:(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:e_.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)})})})})},eH="/api/worktrees/".concat(s,"/files/").concat((0,eE.o)(l),"?download=1"),eK=l?l.split("/").pop()||l:"",e$=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.jsxs)("a",{"data-testid":"download-file-button",href:eH,download:eK,className:e,"aria-label":V("actions.downloadFile"),title:V("actions.download"),children:[(0,r.jsx)(ef.A,{className:"w-3.5 h-3.5"}),t&&(0,r.jsx)("span",{children:V("actions.download")})]})},eq=()=>(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:ep,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":V("actions.copyFilePath"),title:V("actions.copyPath"),children:w?(0,r.jsx)(em.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:l})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[et&&(0,r.jsx)("button",{onClick:Y,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":V("actions.searchInFile"),title:V("actions.search"),children:(0,r.jsx)(z.A,{className:"w-3.5 h-3.5"})}),et&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:el,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":V("actions.copyFileContent"),title:V("actions.copyContent"),children:v?(0,r.jsx)(em.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5"})}),e$("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,r.jsx)("button",{onClick:eb,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":T?V("actions.exitFullscreen"):V("actions.fullscreen"),title:T?V("actions.exitFullscreen"):V("actions.fullscreen"),children:T?(0,r.jsx)(W.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(H.A,{className:"w-3.5 h-3.5"})})]})]}),eG=()=>(null==x?void 0:x.readOnly)&&x.readOnlyReason?(0,r.jsx)(eB,{reason:x.readOnlyReason}):null,eJ=()=>(0,r.jsx)(ez,{searchInputRef:J,searchQuery:$,searchMatches:q,searchCurrentIdx:G,onQueryChange:ee,onPrev:Z,onNext:X,onClose:Q});if(er&&x&&!f&&!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":l,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:eT.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:eb,"aria-pressed":!0,"aria-label":V("actions.exitFullscreen"),className:eF,children:(0,r.jsx)(W.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void eC(),"aria-label":V("actions.close"),className:eF,children:(0,r.jsx)(eN.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:l}),ea&&(0,r.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":V("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)(eS.A,{className:"h-4 w-4"}),V("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)(eI.A,{className:"h-4 w-4"}),V("fileViewer.modeEditor")]})]}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>L(!0),"aria-label":V("fileViewer.moreActions"),className:eF,children:(0,r.jsx)(d.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:eb,"aria-pressed":!1,"aria-label":V("actions.fullscreen"),className:eF,children:(0,r.jsx)(H.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void eC(),"aria-label":V("actions.close"),className:eF,children:(0,r.jsx)(eN.A,{className:"h-5 w-5"})})]}),K&&(0,r.jsx)("div",{className:"flex-shrink-0",children:eJ()}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"viewer"===es?"flex min-h-0 flex-1 flex-col":"hidden",children:K?(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:eW()}):ev?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:V("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:V("actions.next")})]}),(0,r.jsx)("iframe",{srcDoc:N[S],sandbox:"",title:V("fileViewer.slideTitle",{name:l,number:S+1}),className:"w-full flex-1 border-0"})]}):null:ea?(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)(eu.G8,{content:eA,currentFilePath:l,worktreeId:s,onOpenFile:u})}):null}),(0,r.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===es?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,r.jsx)(eD,{worktreeId:s,filePath:l,initialContent:x.content,embedded:!0,onSave:ej,onDirtyChange:O,onContentChange:ey,onOpenFile:u},l)})]}),(0,r.jsx)(eg,{open:R,onClose:()=>L(!1),onSearch:()=>{M("viewer"),Y()},onCopyContent:el,onCopyPath:ep,downloadUrl:eH,downloadName:eK,contentCopied:v,pathCopied:w})]})})}return T&&x&&!f&&!g?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eT.M.MAXIMIZED_EDITOR},children:[eq(),eG(),K&&eJ(),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:eU()})]}):(0,r.jsx)(m.Jh,{isOpen:n,onClose:a,title:l,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[f&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:V("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:e$("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&&!f&&!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:[eq(),eG(),K&&eJ()]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:eU()})]})]})})});var eW=n(36809),eH=n(46892),eK=n(50857),e$=n(94442),eq=n(80344);function eG(e){let{worktreeId:t}=e,[n,a]=(0,i.useState)([]),[s,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),[u,x]=(0,i.useState)(!0),[h,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(""),[v,y]=(0,i.useState)(0),[j,w]=(0,i.useState)("all"),[k,N]=(0,i.useState)(!1),{showToast:C}=(0,e$.dj)(),S=(0,c.c)("worktree");(0,i.useEffect)(()=>{(async()=>{try{x(!0),p(null);let e=await eq.y.getLogs(t);a(e)}catch(e){p((0,eq.hS)(e))}finally{x(!1)}})()},[t]);let I=(0,i.useMemo)(()=>"all"===j?n:n.filter(e=>e.toLowerCase().includes(j)),[n,j]),T=async e=>{try{x(!0),p(null);let n=await eq.y.getLogFile(t,e);d(n.content),l(e),b(""),y(0)}catch(e){p((0,eq.hS)(e))}finally{x(!1)}},E=(0,i.useCallback)(async()=>{if(s)try{N(!0);let e=await eq.y.getLogFile(t,s,{sanitize:!0});await (0,ek.l)(e.content),C(S("logViewer.copied"),"success")}catch(e){C(S("logViewer.exportError",{error:(0,eq.hS)(e)}),"error")}finally{N(!1)}},[t,s,C,S]),A=(0,i.useMemo)(()=>{let e;if(!g||!o)return[];let t=RegExp((0,f.Nt)(g),"gi"),n=[];for(;null!==(e=t.exec(o));)n.push({index:e.index,length:e[0].length});return n},[g,o]);(0,i.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,i.useMemo)(()=>{if(!o||!g||0===A.length)return o;let e="",t=0;return A.forEach((n,a)=>{e+=(0,f.ZD)(o.substring(t,n.index));let r=o.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)(o.substring(t))},[o,g,A,v]);return(0,i.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)(m.Zp,{padding:"md",children:[(0,r.jsx)(m.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)(m.ZB,{children:S("logViewer.title")}),(0,r.jsx)(m.Ex,{variant:"gray",children:I.length})]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(m.$n,{variant:"all"===j?"primary":"ghost",size:"sm",onClick:()=>w("all"),children:S("logViewer.all",{count:n.length})}),(0,r.jsx)(m.$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)(m.$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)(m.$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)(m.$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)(m.Wu,{children:[u&&0===n.length&&(0,r.jsx)("div",{className:"text-center py-4",children:(0,r.jsx)(m.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}),!u&&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(s===e?"bg-accent-50 text-accent-700 border border-accent-200":"hover:bg-muted border border-transparent"),children:e},e))})]})]}),s&&(0,r.jsxs)(m.Zp,{padding:"md",children:[(0,r.jsx)(m.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)(m.ZB,{className:"font-mono text-base",children:s}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:E,disabled:!s||k,title:S("logViewer.copyTitle"),children:k?S("logViewer.exporting"):S("logViewer.export")}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:()=>{l(null),d(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)(m.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)(m.$n,{variant:"ghost",size:"sm",onClick:R,disabled:0===A.length,title:S("logViewer.prevMatch"),children:"↑"}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:M,disabled:0===A.length,title:S("logViewer.nextMatch"),children:"↓"})]})]})]})}),(0,r.jsxs)(m.Wu,{children:[u&&(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)(m.y$,{size:"xl",variant:"accent",className:"inline-block"})}),!u&&o&&(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:o})}),!u&&g&&0===A.length&&o&&(0,r.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:S("logViewer.noMatches",{query:g})})]})]})]})}function eJ(){let[e,t]=(0,i.useState)(null),[n,a]=(0,i.useState)(!0),[r,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return async function(){try{a(!0),s(null);let n=await eq.GQ.checkForUpdate();e||t(n)}catch(t){e||s(t instanceof Error?t.message:"Failed to check for updates")}finally{e||a(!1)}}(),()=>{e=!0}},[]),{data:e,loading:n,error:r}}function eY(e){let{hasUpdate:t,latestVersion:n,releaseUrl:a,updateCommand:s,installType:l}=e,o=(0,c.c)("worktree"),[d,m]=(0,i.useState)("idle"),[x,h]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),g=(0,i.useRef)(!1),b="global"===l,v="npx"===l,y=b||v,j=v?"npx commandmate@latest":"commandmate update",w=(0,i.useCallback)(async()=>{m("starting");try{let e=await eq.GQ.startUpdate();h(e.logPath),m(e.willRestart?"updating":"no-restart")}catch(e){e instanceof eq.hD&&400===e.status?p(o("update.errorNotGlobal")):e instanceof eq.hD&&409===e.status?p(o("update.errorInProgress")):p(o("update.errorGeneric")),m("error")}},[o]);return((0,i.useEffect)(()=>{if("updating"!==d)return;let e=!1,t=Date.now();g.current=!1;let n=setInterval(async()=>{if(e)return;if(Date.now()-t>3e5)return void m("timeout");let n=await eq.GQ.ping();if(!e){if(!n){g.current=!0;return}g.current&&window.location.reload()}},2e3);return()=>{e=!0,clearInterval(n)}},[d]),t)?(0,r.jsxs)("div",{className:"bg-accent-50 border border-accent-200 rounded-lg p-3 mt-2",role:"status","aria-label":o("update.available"),"data-testid":"update-notification-banner",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800 mb-1",children:o("update.available")}),n&&(0,r.jsx)("p",{className:"text-sm text-accent-700 mb-2",children:o("update.latestVersion",{version:n})}),y&&"idle"===d&&(0,r.jsx)(el.$,{variant:"primary",size:"sm",className:"mb-2",onClick:()=>m("confirming"),"data-testid":"update-now-button",children:o("update.updateNow")}),v&&"idle"===d&&(0,r.jsx)("p",{className:"text-xs text-accent-600 mb-2","data-testid":"update-npx-notice",children:o("update.npxRestartNotice")}),("starting"===d||"updating"===d)&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-progress",children:[(0,r.jsxs)("p",{className:"flex items-center text-sm text-accent-800",children:[(0,r.jsx)(u.y,{size:"sm",className:"mr-2"}),"starting"===d?o("update.starting"):o("update.updating")]}),"updating"===d&&(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.updatingHint")})]}),"no-restart"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-no-restart",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.noRestartTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.noRestartDescription")})]}),"timeout"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-timeout",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.timeoutTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.timeoutDescription")}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:j})]}),"error"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-error",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.errorTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:f}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:j})]}),x&&("no-restart"===d||"timeout"===d)&&(0,r.jsx)("p",{className:"text-xs text-accent-500 mb-2","data-testid":"update-log-hint",children:o("update.logHint",{path:x})}),s&&b&&"idle"===d&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("p",{className:"text-xs text-accent-600 mb-1",children:o("update.updateCommand")}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 text-xs text-accent-900 font-mono",children:s})]}),a&&(0,r.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[o("update.viewRelease"),(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),(0,r.jsx)("p",{className:"text-xs text-accent-500 mt-2",children:o("update.dataPreserved")}),(0,r.jsx)(ei.TM,{isOpen:"confirming"===d,title:o("update.confirmTitle"),description:o("update.confirmDescription",{version:null!=n?n:""}),confirmLabel:o("update.confirmButton"),onConfirm:w,onCancel:()=>m("idle")})]}):null}function eQ(e){let{version:t,className:n}=e,a=(0,c.c)("worktree"),{data:s,loading:l}=eJ(),o=(0,i.useMemo)(()=>s&&s.hasUpdate?{hasUpdate:s.hasUpdate,latestVersion:s.latestVersion,releaseUrl:s.releaseUrl,updateCommand:s.updateCommand,installType:s.installType}:null,[s]);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}),l&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"version-loading",children:"..."}),o&&(0,r.jsx)(eY,{...o})]})}let eX="https://github.com/Kewton/CommandMate",eZ="".concat(eX,"/issues"),e0="".concat(eX,"/issues/new"),e1="".concat(e0,"?template=bug_report.md"),e2="".concat(e0,"?template=feature_request.md"),e4="".concat(e0,"?template=question.md");function e5(e){let{className:t}=e,n=(0,c.c)("worktree"),a=[{href:e1,label:n("feedback.bugReport")},{href:e2,label:n("feedback.featureRequest")},{href:e4,label:n("feedback.question")},{href:eZ,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 e3=n(94465),e6=n(38606),e9=n(34681),e8=n(95707),e7=n(14006),te=n(73190),tt=n(56827),tn=n(9900);function ta(e){return""!==(null!=e?e:"").trim()}function tr(e){let{worktreeId:t,cliToolId:n,instanceId:a,composerText:s,onActionSent:l}=e,o=(0,c.c)("worktree"),[d,u]=(0,i.useState)(!1),m=(0,tt.B)(t,n,a,l),x=(0,i.useCallback)(()=>{m(["Enter"])},[m]),h=(0,i.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(()=>{l&&setTimeout(l,tn.LK)}).catch(e=>{console.error("Failed to clear composer:",e)}).finally(()=>{u(!1)})},[t,n,a,l]);if(!ta(s))return null;let f=s.length>300?"".concat(s.slice(0,300),"…"):s;return(0,r.jsxs)("div",{"data-testid":"unsent-composer-bar",role:"region","aria-label":o("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:o("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:f}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:x,"aria-label":o("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:o("unsentComposer.run")}),(0,r.jsx)("button",{type:"button",onClick:h,disabled:d,"aria-label":o("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:o("unsentComposer.clear")})]})]})}var ts=n(51515),tl=n(813),ti=n(16342);let to=/^([^\S\n]*)╹(▀{4,})/,tc=/^([^\S\n]*)[│┃]/;function td(e,t){return"opencode"===e&&null!==function(e){let t=(0,ts.aJ)(e).split("\n"),n=-1,a=-1,r=-1;for(let e=0;e<t.length;e++){let s=to.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=tc.exec(i);if(!e||e[1].length!==a)continue}let o=i.slice((0,ti.sh)(i,r)).trim();""!==o&&(s+=1,""===l&&(l=(0,tl.D)(o,200,"…[truncated]")))}return s<2?null:{id:"opencode_sidebar",matchedText:l,boxRight:r,rows:s}}(null!=t?t:"")}function tu(e){let{cliToolId:t,frame:n}=e,a=(0,c.c)("worktree");return(0,i.useMemo)(()=>td(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 tm=n(40240),tx=n(84228),th=n(62560),tf=n(308),tp=n(80635),tg=n(52407);let tb=(0,i.createContext)({register:()=>{},insertToComposer:()=>{}}),tv=(0,i.createContext)(null);function ty(e){var t;return null!=(t=e.instanceId)?t:e.cliToolId}function tj(e){let{onInsertToComposer:t,children:n}=e,[a,s]=(0,i.useState)(null),l=(0,i.useRef)(t);l.current=t;let o=(0,i.useCallback)(e=>{var t;null==(t=l.current)||t.call(l,e)},[]),c=(0,i.useMemo)(()=>({register:s,insertToComposer:o}),[o]);return(0,r.jsx)(tb.Provider,{value:c,children:(0,r.jsx)(tv.Provider,{value:a,children:n})})}function tw(e){let t=(0,i.useContext)(tv);if(null!==t&&t.target.cliToolId===e.cliToolId&&ty(t.target)===ty(e))return t.send}var tk=n(9708),tN=n(60199),tC=n(52703),tS=n(51021),tI=n(68394),tT=n(17683);let tE=[{mode:"terminal",labelKey:"surfaceMode.terminal",icon:v.A},{mode:"chat",labelKey:"surfaceMode.chat",icon:B.A}],tA=[tS.Mx,"m"],tM="/model",tR=(0,i.memo)(function(e){let{modelLabel:t,usage:n,usageDetail:a,recentChange:s,note:l,onEditNote:i,onOpenPicker:o,onDismissChange:d}=e,u=(0,c.c)("worktree"),m=null!==s,x=u("agentModel.sessionRow",{model:null!=t?t:""}),h=l?(0,Y.Uq)(new Date(l.updatedAt)):"",f=l?u("sessionNote.label",{note:l.text,time:h}):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:o,"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)(e8.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:i,"aria-label":f,title:f,"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)(_.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:h})]}):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]})}),tL=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,live:s,frame:l,onKeysSent:o,onSurfaceModeChange:c}=e,{messages:d,isLoading:u,refresh:m}=(0,tf.Md)({worktreeId:t,cliToolId:n,instanceId:a}),x=(0,i.useCallback)((e,n)=>eq.y.sendMessage(t,e,n),[t]),h=(0,tg.Fx)(),f=(0,i.useMemo)(()=>({offline:(0,tg.sV)(h.signals),reachable:(0,tg._X)(h.signals)}),[h.signals]),{messages:p,sendOptimistic:g,retry:b,discard:v}=(0,tp.v4)({worktreeId:t,serverMessages:d,sendFn:x,onSent:m,connectivity:f});!function(e){let{cliToolId:t,instanceId:n,send:a}=e,{register:r}=(0,i.useContext)(tb);(0,i.useEffect)(()=>(r({target:{cliToolId:t,instanceId:n},send:a}),()=>r(null)),[r,t,n,a])}({cliToolId:n,instanceId:a,send:g});let{worktreePath:y,openFile:j}=(0,tk.O)(),w=(0,i.useContext)(tb).insertToComposer,k=(0,i.useCallback)(e=>{let t=v(e);t&&w(t)},[v,w]);return(0,r.jsx)(tx.wY,{messages:p,worktreeId:t,worktreePath:y,cliToolId:n,instanceId:a,live:s,onSurfaceModeChange:c,frame:l,onKeysSent:o,compact:!0,history:{onFilePathClick:j,isLoading:u,onRetryPending:b,onDiscardPending:k,onInsertToMessage:w}})}),tP=(0,i.memo)(function(e){var t,n;let{worktreeId:a,cliToolId:s,instanceId:l,disableAutoFollow:o,onSurfaceModeChange:d}=e,{terminal:u,prompt:m,agentSession:x,setAutoScroll:h,refresh:f}=(0,th.NK)({worktreeId:a,cliToolId:s,instanceId:l}),{compactTuiLayoutPadding:p,preservePaintedPanelRows:g,mobileWrapMode:b}=(0,tI.EK)(s),v=(0,c.c)("worktree"),y=(0,eW.Ym)(),j=null!=l?l:s,w=function(e,t){let n=(0,J.rC)(),a=null==n?void 0:n.worktrees;return(0,i.useMemo)(()=>{var n;let r=null==a?void 0:a.find(t=>t.id===e);return null!=(n=s_(null==r?void 0:r.sessionStatusByInstance)[t])?n:null},[a,e,t])}(a,j),k=(0,J.rC)(),N=sP(w,null,null==(t=x.session)?void 0:t.agent),C=sO(x.session,x.context,v,y),S=sz(x.session,x.context,v,y),{note:I,save:T}=ee(a,j),[E,A]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=()=>A(!0);return window.addEventListener(Z,e),()=>window.removeEventListener(Z,e)},[]),(0,i.useEffect)(()=>{A(!1)},[a,j]);let M=(0,i.useCallback)(()=>A(!0),[]),R=(0,i.useCallback)(()=>A(!1),[]),L=(0,i.useCallback)(e=>{T(e),A(!1)},[T]),P=null!==N||null!==I,[D,F]=(0,i.useState)(null);(0,tN.T3)(e=>{e.type===tC.T4&&e.worktreeId===a&&e.instance===j&&(F({from:e.from,to:e.to,at:e.at}),null==k||k.refresh())}),(0,i.useEffect)(()=>{if(null===D)return;let e=D.at+3e5-Date.now();if(e<=0)return void F(null);let t=setTimeout(()=>F(null),e);return()=>clearTimeout(t)},[D]);let O=(0,i.useCallback)(()=>F(null),[]);(0,i.useEffect)(()=>{F(null)},[a,j]);let z=(0,tt.B)(a,s,l,f),_=tw({cliToolId:s,instanceId:l}),V=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{null!==V.current&&clearTimeout(V.current)},[]);let B=(0,i.useCallback)(()=>{if("opencode"===s)return void z([...tA]);let e={cliToolId:s,instanceId:l};_?_(tM,e):eq.y.sendMessage(a,tM,e).catch(()=>{}),null!==V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{V.current=null,f()},tn.LK)},[s,l,_,f,z,a]),U=(0,tT.NP)(a),[W,H]=(0,i.useState)($.wf);(0,i.useEffect)(()=>{H((0,tT.TR)(U))},[U]);let K=(0,i.useCallback)(e=>{H(e),(0,tT.If)(U,e)},[U]);(0,i.useEffect)(()=>{null==d||d(W)},[d,W]);let q=u.isUnclassifiedActive&&!m.visible&&"chat"!==W,G=ta(u.composerText),Y=td(s,u.realtimeSnippet||u.output),Q=(0,i.useMemo)(()=>({isRunning:u.isRunning,attaching:u.attaching,sessionStatus:u.sessionStatus,isThinking:u.isThinking,isPromptWaiting:m.visible,promptData:m.data,isSelectionListActive:u.isSelectionListActive,isPagerActive:u.isPagerActive,isDismissablePanelActive:u.isDismissablePanelActive,isUnclassifiedActive:u.isUnclassifiedActive}),[u.isRunning,u.attaching,u.sessionStatus,u.isThinking,u.isSelectionListActive,u.isPagerActive,u.isDismissablePanelActive,u.isUnclassifiedActive,m.visible,m.data]);return(0,r.jsxs)("div",{className:"relative flex flex-col h-full min-h-0",children:[(0,r.jsx)("div",{role:"group","aria-label":v("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(P?"top-9":"top-2"),children:tE.map(e=>{let{mode:t,labelKey:n,icon:a}=e,s=W===t,l=v(n);return(0,r.jsx)("button",{type:"button",onClick:()=>K(t),"aria-pressed":s,"aria-label":l,title:l,"data-testid":"mobile-surface-mode-".concat(t),className:"pointer-events-auto flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-colors touch-manipulation ".concat(s?"bg-accent-500/20 text-accent-600 dark:text-accent-400":"text-muted-foreground"),children:(0,r.jsx)(a,{size:18,"aria-hidden":"true"})},t)})}),P?(0,r.jsx)(tR,{modelLabel:N,usage:C,usageDetail:S,recentChange:D,note:I,onEditNote:M,onOpenPicker:B,onDismissChange:O}):null,E?(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(P?"top-9":"top-2"),children:[(0,r.jsx)(et,{initialText:null!=(n=null==I?void 0:I.text)?n:"",onCommit:L,onCancel:R,ariaLabel:v("sessionNote.menuItem"),placeholder:v("sessionNote.placeholder"),testId:"mobile-session-note-input"}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:v("sessionNote.hint")})]}):null,(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden","data-testid":"mobile-terminal-region",children:"chat"===W?(0,r.jsx)("div",{className:"h-full min-h-0","data-testid":"mobile-chat-surface",children:(0,r.jsx)(tL,{worktreeId:a,cliToolId:s,instanceId:l,live:Q,frame:u.output,onKeysSent:f,onSurfaceModeChange:K})}):(0,r.jsx)(e7.D,{output:u.output,isActive:u.isRunning,isThinking:u.isThinking,autoScroll:u.autoScroll,onScrollChange:h,disableAutoFollow:o,compactTuiLayoutPadding:p,preservePaintedPanelRows:g,wrapMode:b})}),G?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tr,{worktreeId:a,cliToolId:s,instanceId:l,composerText:u.composerText,onActionSent:f})}):null,Y?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tu,{cliToolId:s,frame:u.realtimeSnippet||u.output})}):null,u.isRunning?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1","data-testid":"mobile-quick-keys-slot",children:(0,r.jsx)(tm.XU,{worktreeId:a,cliToolId:s,instanceId:l,hasAgentSession:null!==x.session,onKeysSent:f,compact:!0,collapsible:!0,layout:"mobile"})}):null,q?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1 pb-2",children:(0,r.jsx)(te.U,{worktreeId:a,cliToolId:s,instanceId:l,onKeysSent:f})}):null]})});var tD=n(83051);let tF={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};function tO(){let[e,t]=(0,i.useState)(tF),n=(0,i.useCallback)((e,n,a)=>{t({isOpen:!0,position:e,targetPath:n,targetType:a})},[]),a=(0,i.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,i.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),s=(0,i.useCallback)(()=>{t(tF)},[]);return(0,i.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,i.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:s}}var tz=n(47650),t_=n(7504),tV=n(22198),tB=n(21786),tU=n(26754),tW=n(71360),tH=n(9286);function tK(e,t,n){let a=n-t-8;return a<8?8:Math.min(Math.max(e,8),a)}let t$=(0,i.memo)(function(e){let{isOpen:t,position:n,targetPath:a,targetType:s,onClose:l,onNewFile:o,onNewDirectory:d,onRename:u,onDelete:m,onUpload:x,onMove:h,items:f,ariaLabel:p}=e,g=(0,c.c)("worktree"),b=(0,i.useRef)(null),{shouldRender:v,isExiting:y}=(0,tH.O)(t,tn.$B),j=f?f.map(e=>e.id).join(","):"builtin",w="".concat(n.x,":").concat(n.y,":").concat(s,":").concat(j),[k,N]=(0,i.useState)(null),C=(null==k?void 0:k.key)===w?k:null;(0,i.useLayoutEffect)(()=>{if(!t)return;let e=b.current;if(!e)return;let a=e.getBoundingClientRect();N({key:w,left:tK(n.x,a.width,window.innerWidth),top:tK(n.y,a.height,window.innerHeight)})},[t,w,n.x,n.y]);let S=(0,i.useCallback)(e=>{e&&a&&e(a),l()},[a,l]),I=[{id:"new-file",label:g("fileTree.newFile"),icon:(0,r.jsx)(t_.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(o),showFor:["directory"]},{id:"new-directory",label:g("fileTree.newDirectory"),icon:(0,r.jsx)(tV.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)(tB.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)(eI.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(u)},{id:"move",label:g("contextMenu.move"),icon:(0,r.jsx)(tU.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{h&&a&&s&&h(a,s),l()},showDividerAfter:!0},{id:"delete",label:g("contextMenu.delete"),icon:(0,r.jsx)(tW.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(m),variant:"danger"}],T=f?f.map(e=>{var t,n;return{id:e.id,label:e.label,icon:null!=(t=e.icon)?t:null,onClick:()=>{e.onSelect(),l()},variant:e.variant,showDividerAfter:e.showDividerAfter,disabled:null!=(n=e.disabled)&&n}}):I.filter(e=>!e.showFor||s&&e.showFor.includes(s));if((0,i.useEffect)(()=>{if(!t)return;let e=e=>{if("Escape"===e.key)return void l();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,l]),(0,i.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:eT.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 s=null!=(n=e.disabled)?n:!a;return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem","data-testid":"context-menu-".concat(e.id),onClick:e.onClick,disabled:s,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(s?"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,tz.createPortal)(E,document.body)});var tq=n(55813),tG=n(30061);let tJ="commandmate.worktree.fileMetadataDisplay",tY={showSize:!0,showCreated:!1,showModified:!1},tQ="commandmate:fileMetadataDisplayChange";function tX(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 tZ=(0,i.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"})})}),t0=(0,i.memo)(function(e){let{open:t}=e;return(0,r.jsx)("svg",{"data-testid":"folder-icon",className:"w-5 h-5 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"})})}),t1=(0,i.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))})}),t2=(0,i.memo)(function(e){let{extension:t}=e,n=(0,i.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 ".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"})})}),t4=(0,i.memo)(function e(t){let{item:n,path:a,depth:s,worktreeId:l,expanded:o,cache:d,onToggle:m,onFileSelect:x,onLoadChildren:h,onContextMenu:f,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y=tY}=t,j=(0,c.c)("worktree"),[w,k]=(0,i.useState)(!1),N=a?"".concat(a,"/").concat(n.name):n.name,C=o.has(N),S="directory"===n.type,I=d.get(N),T=(0,i.useMemo)(()=>v?(0,tq.M)(v):void 0,[v]),E=(0,i.useMemo)(()=>{if(S)return;let e=[];if(void 0!==n.size&&e.push("".concat(j("fileTree.metadata.size"),": ").concat(tX(n.size))),n.birthtime){let t=(0,Y.bg)(new Date(n.birthtime),T);t&&e.push("".concat(j("fileTree.metadata.created"),": ").concat(t))}if(n.mtime){let t=(0,Y.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,i.useCallback)(async()=>{S?(C||I||(k(!0),await h(N),k(!1)),m(N)):null==x||x(N)},[S,C,I,N,h,m,x]),M=(0,i.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),A())},[A]),R=(0,i.useCallback)(e=>{e.preventDefault(),null==f||f(e,N,S?"directory":"file")},[N,S,f]),L=function(e){let{delay:t=500,moveThreshold:n=10,onLongPress:a}=e,r=(0,i.useRef)(null),s=(0,i.useRef)(null),l=(0,i.useRef)(null),o=(0,i.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),s.current=null,l.current=null},[]);(0,i.useEffect)(()=>()=>o(),[o]);let c=(0,i.useCallback)(e=>{if(1!==e.touches.length)return;let n=e.touches[0];s.current={x:n.clientX,y:n.clientY},l.current=e,r.current=setTimeout(()=>{l.current&&a(l.current),o()},t)},[t,a,o]),d=(0,i.useCallback)(e=>{if(!s.current||1!==e.touches.length)return;let t=e.touches[0],a=t.clientX-s.current.x,r=t.clientY-s.current.y;Math.sqrt(a*a+r*r)>n&&o()},[n,o]);return{onTouchStart:c,onTouchMove:d,onTouchEnd:(0,i.useCallback)(()=>{o()},[o]),onTouchCancel:(0,i.useCallback)(()=>{o()},[o])}}({onLongPress:(0,i.useCallback)(e=>{null==f||f(e,N,S?"directory":"file")},[N,S,f])}),P={...function(e){let t=Math.min(e,20);return{paddingLeft:"".concat(.5+ +t,"rem")}}(s),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:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-muted rounded transition-colors",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 items-center justify-center",children:w?(0,r.jsx)(u.y,{size:"xs",variant:"accent"}):(0,r.jsx)(tZ,{expanded:C})}):(0,r.jsx)("span",{className:"w-4 h-4"}),S?(0,r.jsx)(t0,{open:C}):(0,r.jsx)(t2,{extension:n.extension}),(0,r.jsx)(tG.nR,{content:n.name,metadata:E,className:"flex-1 truncate text-sm text-foreground",children:"name"===g&&p?(0,r.jsx)(t1,{text:n.name,query:p}):n.name}),y.showSize&&(0,r.jsx)("span",{"data-testid":"tree-item-size",className:"text-xs text-muted-foreground flex-shrink-0",children:S?void 0!==n.itemCount&&j("fileTree.itemCount",{count:n.itemCount}):tX(n.size)}),!S&&y.showCreated&&n.birthtime&&(0,r.jsx)("span",{"data-testid":"tree-item-created",className:"text-xs text-muted-foreground flex-shrink-0",children:(0,Y.fw)(n.birthtime,T)}),!S&&y.showModified&&n.mtime&&(0,r.jsx)("span",{"data-testid":"tree-item-modified",className:"text-xs text-muted-foreground flex-shrink-0",children:(0,Y.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:s+1,worktreeId:l,expanded:o,cache:d,onToggle:m,onFileSelect:x,onLoadChildren:h,onContextMenu:f,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y},t.name))})]})});var t5=n(26989);let t3=[{key:"showSize",labelKey:"fileTree.metadata.showSize"},{key:"showCreated",labelKey:"fileTree.metadata.showCreated"},{key:"showModified",labelKey:"fileTree.metadata.showModified"}];function t6(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 t9=(0,i.memo)(function(e){let{settings:t,onToggle:n}=e,a=(0,c.c)("worktree"),[s,l]=(0,i.useState)(!1),o=(0,i.useRef)(null),d=(0,i.useRef)(null),u=(0,i.useRef)({x:0,y:0}),[x,h]=(0,i.useState)({x:0,y:0});(0,i.useEffect)(()=>{if(!s)return;let e=e=>{o.current&&!o.current.contains(e.target)&&l(!1)},t=e=>{"Escape"===e.key&&l(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[s]),(0,i.useLayoutEffect)(()=>{let e=e=>{u.current=e,h(t=>t.x===e.x&&t.y===e.y?t:e)};if(!s)return void e({x:0,y:0});let t=d.current;if(!t)return;let n=t.getBoundingClientRect();e({x:t6(n.left-u.current.x,n.width,window.innerWidth),y:t6(n.top-u.current.y,n.height,window.innerHeight)})},[s]);let f=(0,i.useCallback)(e=>{n(e)},[n]);return(0,r.jsxs)("div",{className:"relative",ref:o,"data-testid":"file-metadata-toggle",children:[(0,r.jsx)("button",{type:"button","data-testid":"file-metadata-toggle-button",onClick:()=>l(e=>!e),"aria-haspopup":"menu","aria-expanded":s,"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)(t5.A,{className:"w-4 h-4","aria-hidden":"true"})}),s&&(0,r.jsxs)("div",{ref:d,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")}),t3.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)(m.Sc,{"data-testid":"file-metadata-toggle-".concat(e.key),checked:t[e.key],onCheckedChange:()=>f(e.key),className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:a(e.labelKey)})]},e.key))]})]})});function t8(e){let{intervalMs:t,enabled:n,onPoll:a}=e,r=(0,i.useRef)(a);r.current=a;let s=(0,i.useRef)(n);s.current=n;let l=(0,i.useRef)(null);(0,i.useEffect)(()=>{function e(){null!==l.current&&(clearInterval(l.current),l.current=null)}function a(){e(),l.current=setInterval(()=>{r.current()},t)}function i(){"hidden"===document.visibilityState?e():"visible"===document.visibilityState&&s.current&&(r.current(),a())}return n?a():e(),document.addEventListener("visibilitychange",i),()=>{e(),document.removeEventListener("visibilitychange",i)}},[t,n])}function t7(e){return"commandmate:file-tree-expanded:"+e}function ne(e){try{let t=window.localStorage.getItem(t7(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 nt=n(89559),nn=n(48314),na=n(6132);let nr=(0,i.memo)(function(e){let{worktreeId:t,onFileSelect:n,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u,className:x="",refreshTrigger:h=0,pollingEnabled:p=!1,searchQuery:g,searchMode:b,searchResults:v,onSearchResultSelect:y,onResetView:j}=e,w=(0,eW.Ym)(),k=(0,c.c)("worktree"),{settings:N,toggle:C}=function(){let[e,t]=(0,i.useState)(tY),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{var e;let t=window.localStorage.getItem(tJ);if(!t)return{...tY};return e=JSON.parse(t),"object"!=typeof e||null===e?{...tY}:{showSize:"boolean"==typeof e.showSize?e.showSize:tY.showSize,showCreated:"boolean"==typeof e.showCreated?e.showCreated:tY.showCreated,showModified:"boolean"==typeof e.showModified?e.showModified:tY.showModified}}catch(e){return{...tY}}}())},[]),(0,i.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(tQ,e),()=>window.removeEventListener(tQ,e)},[]);let a=(0,i.useCallback)(e=>{n.current=e,t(e);try{window.localStorage.setItem(tJ,JSON.stringify(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(tQ,{detail:{settings:e}}))}catch(e){}},[]);return{settings:e,toggle:(0,i.useCallback)(e=>{a({...n.current,[e]:!n.current[e]})},[a]),setSettings:a}}(),[S,I]=(0,i.useState)(!0),[T,E]=(0,i.useState)(null),[A,M]=(0,i.useState)([]),{expanded:R,setExpanded:L,resetExpanded:P}=function(e){let[t,n]=(0,i.useState)(()=>ne(e)),a=(0,i.useRef)(e);(0,i.useEffect)(()=>{a.current!==e&&(a.current=e,n(ne(e)))},[e]),(0,i.useEffect)(()=>{!function(e,t){try{let n=t7(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,i.useCallback)(()=>{n(new Set)},[]);return{expanded:t,setExpanded:n,resetExpanded:r}}(t),[D,F]=(0,i.useState)(()=>new Map),O=(0,i.useRef)(null),z=(0,i.useRef)(R);z.current=R;let _=(0,i.useRef)(k);_.current=k;let V=(0,i.useRef)(new Set),{menuState:B,openMenu:U,closeMenu:W}=tO(),H=(0,i.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]),K=(0,i.useRef)(!0);(0,i.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]);let $=(0,i.useCallback)(async()=>{if(K.current){I(!0),E(null);try{let e=await H();if(!K.current||!e)return;let t=Array.from(z.current),n=new Map,a=[];for(let e=0;e<t.length;e+=5){if(!K.current)return;let r=t.slice(e,e+5);for(let[e,t]of(await Promise.allSettled(r.map(async e=>{let t=await H(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(!K.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){K.current&&E(e instanceof Error?e.message:_.current("fileTree.loadError"))}finally{K.current&&I(!1)}}},[H,L]);(0,i.useEffect)(()=>{$()},[$,h]);let q=(0,i.useRef)(null),G=(0,i.useRef)(!1);(0,i.useEffect)(()=>{q.current=null},[t]),t8({intervalMs:5e3,enabled:p,onPoll:(0,i.useCallback)(async()=>{if(K.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(!K.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 H(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(!K.current)return;let n=q.current;if(q.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&&$()}finally{G.current=!1}}},[H,$])});let J=(0,i.useCallback)(async e=>{if(!(D.has(e)||V.current.has(e))){V.current.add(e);try{let t=await H(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{V.current.delete(e)}}},[D,H]),Y=(0,i.useCallback)(e=>{L(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[L]),Q=(0,i.useCallback)(()=>{var e;P(),F(new Map),null==(e=O.current)||e.scrollTo({top:0}),null==j||j()},[P,j]),X=(0,i.useMemo)(()=>"content"===b&&v&&0!==v.length?(0,f.q3)(v.map(e=>e.filePath)):new Set,[b,v]);(0,i.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,i.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)(m.EA,{className:"h-4 w-4 shrink-0 rounded"}),(0,r.jsx)(m.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||s)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[a&&(0,r.jsxs)(m.$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)(t_.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),s&&(0,r.jsxs)(m.$n,{variant:"ghost","data-testid":"empty-new-directory-button",onClick:()=>s(""),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)(tV.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:"overflow-auto bg-surface ".concat(x),children:[(0,r.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex items-center gap-1 p-1 border-b border-border",children:[a&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>a(""),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)(t_.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),s&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>s(""),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)(tV.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsx)(t9,{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:()=>{$()},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)(nt.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)(nn.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)(na.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)(m.$n,{variant:"ghost","data-testid":"file-tree-refetch-retry-button",onClick:()=>{$()},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)(t4,{item:e,path:"",depth:0,worktreeId:t,expanded:R,cache:D,onToggle:Y,onFileSelect:y||n,onLoadChildren:J,onContextMenu:U,searchQuery:g,searchMode:b,matchedPaths:X,dateFnsLocaleStr:w,metadataDisplay:N},e.name)),(0,r.jsx)(t$,{isOpen:B.isOpen,position:B.position,targetPath:B.targetPath,targetType:B.targetType,onClose:W,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u})]})});var ns=n(38218);let nl=(0,i.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"})})}),ni=(0,i.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"})})}),no=(0,i.memo)(function(){let e=(0,c.c)("worktree");return(0,r.jsx)(u.y,{size:"sm",variant:"accent","data-testid":"search-loading",role:"status","aria-hidden":!1,"aria-label":e("search.searching")})}),nc=(0,i.memo)(function(e){let{query:t,mode:n,isSearching:a,error:s,onQueryChange:l,onModeChange:o,onClear:d,placeholder:u,className:m=""}=e,x=(0,i.useRef)(null),h=(0,c.c)("worktree"),f=(0,i.useCallback)(e=>{l(e.target.value)},[l]),p=(0,i.useCallback)(()=>{var e;d(),null==(e=x.current)||e.focus()},[d]),g=(0,i.useCallback)(e=>{if("Escape"===e.key)if(t)p();else{var n;null==(n=x.current)||n.blur()}},[t,p]);return(0,i.useEffect)(()=>{if(!(window.innerWidth<ns.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)(nl,{})}),(0,r.jsx)("input",{ref:x,type:"text","data-testid":"search-input",value:t,onChange:f,onKeyDown:g,placeholder:null!=u?u:h("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":h("search.label"),"aria-busy":a}),(0,r.jsx)("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:a?(0,r.jsx)(no,{}):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":h("search.clear"),children:(0,r.jsx)(ni,{})}):null})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mr-1",children:h("search.mode")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-name",onClick:()=>o("name"),className:"px-2 py-0.5 text-xs rounded transition-colors ".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:h("search.modeName")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-content",onClick:()=>o("content"),className:"px-2 py-0.5 text-xs rounded transition-colors ".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:h("search.modeContent")})]}),s&&(0,r.jsx)("div",{"data-testid":"search-error",className:"text-xs text-danger bg-danger-subtle px-2 py-1 rounded",role:"alert",children:s})]})});function nd(e){return 0===e.length?"0":e.map(e=>"".concat(e.id,":").concat(e.title.length,":").concat(e.content.length)).join("|")}var nu=n(12108),nm=n(54916),nx=n(60850);let nh=(0,i.memo)(function(e){var t,n;let{memo:a,onUpdate:s,onDelete:l,isSaving:o,error:d,className:u="",onInsertToMessage:m,onMoveUp:x,onMoveDown:h,canMoveUp:f=!0,canMoveDown:p=!0}=e,g=(0,c.c)("schedule"),b=(0,c.c)("worktree"),v=!!(x||h),[y,j]=(0,i.useState)(a.title),[w,k]=(0,i.useState)(a.content),[N,C]=(0,i.useState)(!1),S=(0,i.useRef)(void 0);(0,i.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let{isSaving:I,error:T,saveNow:E}=(0,nx.U)({value:y,saveFn:async e=>{await s(a.id,{title:e})}}),{isSaving:A,error:M,saveNow:R}=(0,nx.U)({value:w,saveFn:async e=>{await s(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,i.useCallback)(e=>{j(e.target.value)},[]),D=(0,i.useCallback)(e=>{k(e.target.value)},[]),F=(0,i.useCallback)(()=>{E()},[E]),O=(0,i.useCallback)(()=>{R()},[R]),z=(0,i.useCallback)(()=>{l(a.id)},[a.id,l]),_=(0,i.useCallback)(()=>{w.trim()&&(null==m||m(w))},[w,m]),V=(0,i.useCallback)(async()=>{if(w.trim())try{await (0,ek.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!=o?o: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:!f,"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)(nu.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-testid":"memo-move-down-".concat(a.id),onClick:h,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)(U.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)(nm.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:V,"aria-label":g("memoCopyContent"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded",children:N?(0,r.jsx)(em.A,{className:"w-4 h-4 text-success"}):(0,r.jsx)(ex.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})]})}),nf=(0,i.memo)(function(e){let{currentCount:t,maxCount:n,onAdd:a,isLoading:s=!1,className:l=""}=e,i=(0,c.c)("schedule"),o=Math.max(0,n-t),d=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:()=>{d||a()},disabled:d,"aria-label":i("memoAdd"),"aria-disabled":d,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(d?"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)(u.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:i("memoAdd")})]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:i("memoRemaining",{count:o})})]})});function np(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:d,onCompositionStart:u,onCompositionEnd:x}=e,h=(0,c.c)("schedule"),f=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null==(e=f.current)||e.focus()},[]);let p=(0,i.useCallback)(e=>{if("Escape"===e.key)return void d();"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),l())},[d,l]),g=(0,i.useCallback)(e=>{n(e.target.value)},[n]),b=0===a?"0/0":"".concat(s+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":h("memoSearchLabel"),children:[(0,r.jsx)("input",{ref:f,type:"text",value:t,onChange:g,onKeyDown:p,onCompositionStart:u,onCompositionEnd:x,placeholder:h("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":h("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)(m.$n,{variant:"ghost",type:"button",onClick:o,disabled:0===a,"aria-label":h("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)(m.$n,{variant:"ghost",type:"button",onClick:l,disabled:0===a,"aria-label":h("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)(m.$n,{variant:"ghost",type:"button",onClick:d,"aria-label":h("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 ng=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a}=e,s=(0,c.c)("schedule"),l=(0,c.c)("common"),o=(0,ei.SC)(),[d,m]=(0,i.useState)([]),[x,h]=(0,i.useState)(!0),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(!1),k=(0,i.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,i.useState)(""),[r,s]=(0,i.useState)([]),[l,o]=(0,i.useState)(-1),c=(0,i.useRef)(null),d=(0,i.useRef)(""),u=(0,i.useRef)(!1),m=(0,i.useRef)(nd(t)),x=(0,i.useRef)(t);x.current=t;let h=r.length,f=(0,i.useCallback)(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),p=(0,i.useCallback)(e=>{let t=function(e,t){if(t.length<eA.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);s(t),o(t.length>0?0:-1)},[]),g=(0,i.useCallback)(e=>{f(),d.current=e,u.current||(c.current=setTimeout(()=>{p(e)},eA.e1))},[f,p]),b=(0,i.useCallback)(e=>{a(e),g(e)},[g]),v=(0,i.useCallback)(()=>{a(""),d.current="",s([]),o(-1),f()},[f]),y=(0,i.useCallback)(()=>{o(e=>0===h?-1:(e+1)%h)},[h]),j=(0,i.useCallback)(()=>{o(e=>0===h?-1:(e-1+h)%h)},[h]),w=(0,i.useCallback)(()=>{u.current=!0,f()},[f]),k=(0,i.useCallback)(()=>{u.current=!1;let e=d.current;e.length>=eA.E2&&(f(),c.current=setTimeout(()=>{p(e)},eA.e1))},[f,p]);return(0,i.useEffect)(()=>{let e=nd(t);if(e===m.current)return;m.current=e;let n=d.current;n.length>=eA.E2&&p(n)},[t,p]),(0,i.useEffect)(()=>()=>{f(),d.current=""},[f]),{query:n,matches:r,currentMatch:l,totalCount:h,setQuery:b,reset:v,navigateNext:y,navigatePrev:j,onCompositionStart:w,onCompositionEnd:k}}({memos:d}),P=j&&N.length>0,D=P?C:d,F=(0,i.useCallback)(async()=>{h(!0),b(null);try{let e=await eq.$T.getAll(t);m(e.sort((e,t)=>e.position-t.position))}catch(e){b((0,eq.hS)(e))}finally{h(!1)}},[t]);(0,i.useEffect)(()=>{F()},[F]);let O=(0,i.useCallback)(async()=>{p(!0),y(null);try{let e=await eq.$T.create(t,{title:s("memoDefaultTitle"),content:""});m(t=>[...t,e])}catch(e){y((0,eq.hS)(e))}finally{p(!1)}},[t,s]),_=(0,i.useCallback)(async(e,n)=>{await eq.$T.update(t,e,n),m(t=>t.map(t=>t.id===e?{...t,...n}:t))},[t]),V=(0,i.useCallback)(async e=>{var n;let a=d.find(t=>t.id===e);if(await o({description:l("confirmDelete",{name:null!=(n=null==a?void 0:a.title)?n:""}),variant:"danger"}))try{await eq.$T.delete(t,e),m(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Failed to delete memo:",e)}},[t,d,o,l]),B=(0,i.useCallback)(async(e,n)=>{let a=e+n;if(a<0||a>=d.length)return;let r=[...d];[r[e],r[a]]=[r[a],r[e]],m(r);try{await eq.$T.reorder(t,r.map(e=>e.id))}catch(e){b((0,eq.hS)(e)),await F()}},[d,t,F]),U=(0,i.useCallback)(()=>{F()},[F]),W=(0,i.useCallback)(()=>{w(e=>(e&&E(),!e))},[E]),H=(0,i.useCallback)(()=>{w(!1),E()},[E]);return((0,i.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)(u.y,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:s("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:U,"aria-label":l("retry"),className:"px-4 py-2 text-sm font-medium text-white bg-accent-500 rounded-lg hover:bg-accent-600 transition-colors",children:l("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)(np,{query:N,onQueryChange:T,matchCount:I,currentIndex:S,onNext:A,onPrev:M,onClose:H,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:W,"aria-label":s("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,r.jsx)(z.A,{className:"w-4 h-4","aria-hidden":"true"})})]})}),0===d.length&&!P&&!v&&(0,r.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,r.jsx)("p",{children:s("memoEmpty")}),(0,r.jsx)("p",{className:"text-sm",children:s("memoEmptyHint")})]}),P&&0===D.length&&(0,r.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,r.jsx)("p",{children:s("memoNoMatch")})}),D.map((e,t)=>(0,r.jsx)(nh,{memo:e,onUpdate:_,onDelete:V,onInsertToMessage:a,onMoveUp:P?void 0:()=>B(t,-1),onMoveDown:P?void 0:()=>B(t,1),canMoveUp:!P&&t>0,canMoveDown:!P&&t<d.length-1},e.id)),v&&(0,r.jsx)("div",{className:"text-center py-2 text-sm text-danger",children:v}),!P&&(0,r.jsx)(nf,{currentCount:d.length,maxCount:20,onAdd:O,isLoading:f,className:"mt-2"})]})});var nb=n(85872),nv=n(53292),ny=n(53482);let nj={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"},nw=i.memo(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=(0,c.c)("common"),l=(0,ei.SC)(),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(""),[x,h]=(0,i.useState)(!0),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(!1),I=(0,i.useCallback)(e=>{switch(e){case"doing":return a("todo.statusDoing");case"done":return a("todo.statusDone");default:return a("todo.statusTodo")}},[a]),T=(0,i.useCallback)(async()=>{h(!0),b(null);try{let e=await nb.Ar.list(t);d(e)}catch(e){b(e instanceof Error?e.message:a("todo.loadError")),d([])}finally{h(!1)}},[t,a]);(0,i.useEffect)(()=>{T()},[t]);let E=(0,i.useCallback)(async()=>{let e=u.trim();if(e&&!f){p(!0),b(null);try{let n=await nb.Ar.create(t,e);d(e=>[...e,n]),m("")}catch(e){b(e instanceof Error?e.message:a("todo.addError"))}finally{p(!1)}}},[u,f,t,a]),A=(0,i.useCallback)(async e=>{let n=function(e){let t=nb.KG.indexOf(e);return nb.KG[(t+1)%nb.KG.length]}(e.status);d(t=>t.map(t=>t.id===e.id?{...t,status:n,done:"done"===n}:t)),b(null);try{await nb.Ar.update(t,e.id,{status:n})}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),T()}},[t,T,a]),M=(0,i.useCallback)(async e=>{if(await l({description:s("confirmDelete",{name:e.content}),variant:"danger"})){b(null);try{await nb.Ar.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,l,s]),R=(0,i.useCallback)(e=>{y(e),w(e.content),N(e.detail),b(null)},[]),L=(0,i.useCallback)(()=>{y(null),S(!1)},[]),P=(0,i.useCallback)(async()=>{if(!v)return;let e=j.trim();if(e&&!C){S(!0),b(null);try{let n=await nb.Ar.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,i.useCallback)(async(e,n)=>{let r=e+n;if(r<0||r>=o.length)return;let s=[...o];[s[e],s[r]]=[s[r],s[e]],d(s),b(null);try{await nb.Ar.reorder(t,s.map(e=>e.id))}catch(e){b(e instanceof Error?e.message:a("todo.reorderError")),T()}},[o,t,T,a]),F=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),E())},[E]),O=(0,i.useMemo)(()=>({todo:o.filter(e=>"todo"===e.status).length,doing:o.filter(e=>"doing"===e.status).length,done:o.filter(e=>"done"===e.status).length}),[o]);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:nv.Ll,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:f||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===o.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:o.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(nj[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===o.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)(e3.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:nv.Ll,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)(ny.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:nv.bu,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 nk=n(95740),nN=n(66630);function nC(e){let{isOpen:t,onClose:n,title:a,children:s,footer:l,showCloseButton:o=!0}=e,d=(0,c.c)("common"),[u,m]=(0,i.useState)(null);return((0,i.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n]),(0,i.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]),(0,i.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,tz.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:eT.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}),o&&(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)(eN.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:s}),l&&(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:l})]}),document.body):null}let nS=["default","acceptEdits","plan","dontAsk","bypassPermissions"],nI=["read-only","workspace-write","danger-full-access"],nT=["allow-all-tools","yolo"],nE=["--dangerously-skip-permissions"],nA="yolo",nM=[nA,"default","standard","plan","auto-accept","dont-ask"],nR=[],nL=[],nP=[],nD=[],nF={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",opencode:"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions","command-code":nA};function nO(e){switch(e){case"claude":return nS;case"codex":return nI;case"copilot":return nT;case"antigravity":return nE;case"command-code":return nM;case"gemini":return nR;case"vibe-local":return nL;case"opencode":return nP;default:return nD}}let nz=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/;var n_=n(3199);let nV=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],nB={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:null!=(a=nF.claude)?a:"",model:"",agent:"",variant:"",continueSession:!1,title:""},nU="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",nW="block text-xs font-semibold text-foreground mb-1",nH="mt-1 text-xs text-danger-foreground";function nK(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)(nk.A,{size:14,"aria-hidden":"true"}),n]})}function n$(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)(U.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 nq(e){var t,n;let{isOpen:a,worktreeId:s,initialValues:l,originalName:o,onInsertToMessage:d,instances:u,onClose:x,onSaved:h}=e,f=(0,c.c)("schedule"),p=(0,ns.a)(),g=(0,i.useMemo)(()=>u&&u.length>0?u:(0,K.lu)([...K.XH]),[u]),[b,v]=(0,i.useState)(nB),[y,j]=(0,i.useState)(""),[w,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(null),[I,T]=(0,i.useState)(()=>new Set(["basic","advanced","message"]));(0,i.useEffect)(()=>{var e,t,n,r,s,i,o,c,d,u,m,x,h,f;if(!a)return;S(null),N(!1);let p=null!=(t=null==l?void 0:l.cliToolId)?t:nB.cliToolId;v({name:null!=(n=null==l?void 0:l.name)?n:nB.name,cronExpression:null!=(r=null==l?void 0:l.cronExpression)?r:nB.cronExpression,message:null!=(s=null==l?void 0:l.message)?s:nB.message,cliToolId:p,enabled:null!=(i=null==l?void 0:l.enabled)?i:nB.enabled,permission:null!=(o=null==l?void 0:l.permission)?o:nB.permission,model:null!=(c=null==l?void 0:l.model)?c:nB.model,agent:null!=(d=null==l?void 0:l.agent)?d:nB.agent,variant:null!=(u=null==l?void 0:l.variant)?u:nB.variant,continueSession:null!=(m=null==l?void 0:l.continueSession)?m:nB.continueSession,title:null!=(x=null==l?void 0:l.title)?x:nB.title});let b=g.find(e=>e.cliTool===p);j(null!=(f=null!=(h=null==b?void 0:b.id)?h:null==(e=g[0])?void 0:e.id)?f:p)},[a,l,g]),(0,i.useEffect)(()=>{a&&T(new Set(p?["basic"]:["basic","advanced","message"]))},[a,p]);let E=(0,i.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),A=nO(b.cliToolId),M=A.length>0,R="command-code"===b.cliToolId&&b.permission!==nA,L=n_.Vt.has(b.cliToolId),P=n_.aN.has(b.cliToolId),D=!!o,F=(0,i.useMemo)(()=>{let e=b.name.trim();return e?e.length>100?f("edit.errorNameTooLong",{max:100}):nz.test(e)?null:f("edit.errorNameInvalid"):f("edit.errorNameRequired")},[b.name,f]),O=(0,i.useMemo)(()=>!function(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}(b.cronExpression.trim())?f("edit.errorCronInvalid"):null,[b.cronExpression,f]),z=(0,i.useMemo)(()=>b.message.trim()?b.message.length>1e4?f("edit.errorMessageTooLong",{max:1e4}):null:f("edit.errorMessageRequired"),[b.message,f]),_=(0,i.useMemo)(()=>L&&b.model.trim()?(0,n_.JY)(b.model.trim()).valid?null:f("edit.errorModelInvalid"):null,[L,b.model,f]),V=(0,i.useMemo)(()=>P&&b.agent.trim()?(0,n_.sd)(b.agent.trim(),"agent").valid?null:f("edit.errorAgentInvalid"):null,[P,b.agent,f]),U=(0,i.useMemo)(()=>P&&b.variant.trim()?(0,n_.sd)(b.variant.trim(),"variant").valid?null:f("edit.errorVariantInvalid"):null,[P,b.variant,f]),W=(0,i.useMemo)(()=>P&&b.title.trim()?(0,n_.kj)(b.title.trim()).valid?null:f("edit.errorTitleInvalid"):null,[P,b.title,f]),H=!F&&!O&&!z&&!_&&!V&&!U&&!W,$=(0,i.useCallback)(e=>{v(t=>({...t,cliToolId:e,permission:function(e){let t=nF[e];if(void 0!==t)return t;let n=nO(e);return n.length>0?n[0]:""}(e),model:n_.Vt.has(e)?t.model:"",agent:n_.aN.has(e)?t.agent:"",variant:n_.aN.has(e)?t.variant:"",continueSession:!!n_.aN.has(e)&&t.continueSession,title:n_.aN.has(e)?t.title:""}))},[]),q=(0,i.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&(j(e),$(t.cliTool))},[g,$]),G=nV.some(e=>e.value===b.cronExpression)?b.cronExpression:"custom",J=(0,i.useCallback)(e=>{"custom"!==e&&v(t=>({...t,cronExpression:e}))},[]),Y=(0,i.useCallback)(e=>{null==d||d(e),x()},[d,x]),Q=(0,i.useCallback)(async()=>{if(H&&!w){N(!0),S(null);try{let e=await fetch("/api/worktrees/".concat(s,"/cmate/schedules"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name.trim(),cronExpression:b.cronExpression.trim(),message:b.message.trim(),cliToolId:b.cliToolId,enabled:b.enabled,permission:M?b.permission:"",model:L&&b.model.trim()?b.model.trim():void 0,agent:P&&b.agent.trim()?b.agent.trim():void 0,variant:P&&b.variant.trim()?b.variant.trim():void 0,continueSession:!!P&&!!b.continueSession||void 0,title:P&&b.title.trim()?b.title.trim():void 0,originalName:null!=o?o:void 0})});if(!e.ok){let t=await e.json().catch(()=>({}));S(t.error||f("edit.saveError"));return}h(),x()}catch(e){S(f("edit.saveError"))}finally{N(!1)}}},[H,w,s,b,M,L,P,o,h,x,f]),X=null!=(n=null==(t=g.find(e=>e.id===y))?void 0:t.alias)?n:(0,K.f_)(b.cliToolId),Z=b.name.trim()?"".concat(b.name.trim()," \xb7 ").concat(b.cronExpression):b.cronExpression,ee=[X,M?b.permission:null,L&&b.model.trim()?b.model.trim():null,P&&b.agent.trim()?"--agent ".concat(b.agent.trim()):null,P&&b.variant.trim()?"--variant ".concat(b.variant.trim()):null,P&&b.continueSession?"--continue":null].filter(Boolean).join(" \xb7 "),et=b.message.trim(),en=et.length>32?"".concat(et.slice(0,32),"…"):et,ea=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:nW,htmlFor:"schedule-name-input",children:f("edit.name")}),(0,r.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:b.name,maxLength:100,placeholder:f("edit.namePlaceholder"),onChange:e=>v(t=>({...t,name:e.target.value})),className:nU}),F&&(0,r.jsx)("p",{className:nH,"data-testid":"schedule-name-error",children:F})]}),(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:f("edit.cron")}),d&&(0,r.jsx)(nK,{testId:"schedule-cron-ask-ai",label:f("edit.askAiCron"),title:f("edit.askAiHint"),onClick:()=>Y(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.cron"):e("edit.aiPrompts.cronRefine",{current:"`"+n+"`"})}(f,b.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:b.cronExpression,placeholder:f("edit.cronPlaceholder"),onChange:e=>v(t=>({...t,cronExpression:e.target.value})),className:"".concat(nU," font-mono sm:flex-1")}),(0,r.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":f("edit.cronPreset"),value:G,onChange:e=>J(e.target.value),className:"".concat(nU," sm:w-48"),children:[nV.map(e=>(0,r.jsx)("option",{value:e.value,children:f("edit.".concat(e.labelKey))},e.value)),(0,r.jsx)("option",{value:"custom",children:f("edit.cronPresetCustom")})]})]}),O&&(0,r.jsx)("p",{className:nH,"data-testid":"schedule-cron-error",children:O})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"schedule-enabled-toggle",checked:b.enabled,onCheckedChange:e=>v(t=>({...t,enabled:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:f("edit.enabledLabel")})]})]}),er=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:nW,htmlFor:"schedule-cli-tool-select",children:f("edit.cliTool")}),(0,r.jsx)("select",{id:"schedule-cli-tool-select","data-testid":"schedule-cli-tool-select",value:y,onChange:e=>q(e.target.value),className:nU,children:g.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),L&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:nW,htmlFor:"schedule-model-input",children:f("edit.model")}),(0,r.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:b.model,placeholder:f("edit.modelPlaceholder"),onChange:e=>v(t=>({...t,model:e.target.value})),className:nU}),_&&(0,r.jsx)("p",{className:nH,"data-testid":"schedule-model-error",children:_})]}),P&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:nW,htmlFor:"schedule-agent-input",children:f("edit.opencodeAgent")}),(0,r.jsx)("input",{id:"schedule-agent-input","data-testid":"schedule-agent-input",type:"text",value:b.agent,placeholder:f("edit.opencodeAgentPlaceholder"),onChange:e=>v(t=>({...t,agent:e.target.value})),className:nU}),V&&(0,r.jsx)("p",{className:nH,"data-testid":"schedule-agent-error",children:V})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:nW,htmlFor:"schedule-variant-input",children:f("edit.opencodeVariant")}),(0,r.jsx)("input",{id:"schedule-variant-input","data-testid":"schedule-variant-input",type:"text",value:b.variant,placeholder:f("edit.opencodeVariantPlaceholder"),onChange:e=>v(t=>({...t,variant:e.target.value})),className:nU}),U&&(0,r.jsx)("p",{className:nH,"data-testid":"schedule-variant-error",children:U})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:nW,htmlFor:"schedule-title-input",children:f("edit.opencodeTitle")}),(0,r.jsx)("input",{id:"schedule-title-input","data-testid":"schedule-title-input",type:"text",value:b.title,placeholder:f("edit.opencodeTitlePlaceholder"),onChange:e=>v(t=>({...t,title:e.target.value})),className:nU}),W&&(0,r.jsx)("p",{className:nH,"data-testid":"schedule-title-error",children:W})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"schedule-continue-toggle",checked:b.continueSession,onCheckedChange:e=>v(t=>({...t,continueSession:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:f("edit.opencodeContinue")})]})]}),M&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:nW,htmlFor:"schedule-permission-select",children:f("edit.permission")}),(0,r.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:b.permission,onChange:e=>v(t=>({...t,permission:e.target.value})),className:nU,children:A.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),R&&(0,r.jsx)("p",{className:"mt-1 text-xs text-warning-foreground","data-testid":"schedule-permission-readonly-note",children:f("edit.commandCodeReadOnlyNote")})]})]}),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:f("edit.message")}),d&&(0,r.jsx)(nK,{testId:"schedule-message-ask-ai",label:f("edit.askAiMessage"),title:f("edit.askAiHint"),onClick:()=>Y(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.messageDraft"):e("edit.aiPrompts.messageDraftNamed",{name:"`"+n+"`"})}(f,b.name))})]}),(0,r.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:b.message,rows:4,maxLength:1e4,placeholder:f("edit.messagePlaceholder"),onChange:e=>v(t=>({...t,message:e.target.value})),className:"".concat(nU," resize-none")}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[z?(0,r.jsx)("p",{className:nH,"data-testid":"schedule-message-error",children:z}):(0,r.jsx)("span",{}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:f("edit.charCount",{count:b.message.length,max:1e4})})]})]}),el=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(n$,{id:"basic",title:f("edit.sectionBasic"),summary:Z,icon:(0,r.jsx)(k.A,{className:"w-4 h-4"}),isOpen:I.has("basic"),onToggle:E,children:ea}),(0,r.jsx)(n$,{id:"advanced",title:f("edit.sectionAdvanced"),summary:ee,icon:(0,r.jsx)(nN.A,{className:"w-4 h-4"}),isOpen:I.has("advanced"),onToggle:E,children:er}),(0,r.jsx)(n$,{id:"message",title:f("edit.sectionMessage"),summary:en,icon:(0,r.jsx)(B.A,{className:"w-4 h-4"}),isOpen:I.has("message"),onToggle:E,children:es}),C&&(0,r.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:C})]}),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:f("edit.cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-save-button",onClick:()=>void Q(),disabled:!H||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:f("edit.save")})]}),eo=D?f("edit.titleEdit"):f("edit.titleCreate");return p?(0,r.jsx)(nC,{isOpen:a,onClose:x,title:eo,footer:ei,children:el}):(0,r.jsx)(e3.a,{isOpen:a,onClose:x,title:eo,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 nG(e){return new Date(e).toLocaleString()}function nJ(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 nY=(0,i.memo)(function(e){let{worktreeId:t,logs:n}=e,a=(0,c.c)("schedule"),[s,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),u=(0,i.useCallback)(async e=>{if(s===e){l(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),l(e)}}catch(e){console.error("Failed to fetch log detail:",e)}},[t,s]);return 0===n.length?(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:a("noLogs")}):(0,r.jsx)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:n.map(e=>(0,r.jsxs)("div",{className:"border border-border rounded bg-surface",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.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(function(e){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)),children:a("status.".concat(e.status))})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[nG(e.started_at),nJ(e.started_at,e.completed_at)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",nJ(e.started_at,e.completed_at),")"]}),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[a("exitCode"),": ",e.exit_code]})]})]}),s===e.id&&o&&(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:o.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:o.result||a("noOutput")})]})]})]},e.id))})});function nQ(){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 nX(){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 nZ=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a,instances:s}=e,l=(0,c.c)("schedule"),o=(0,ei.SC)(),[d,u]=(0,i.useState)([]),[x,h]=(0,i.useState)([]),[f,p]=(0,i.useState)([]),[g,b]=(0,i.useState)(!0),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)("schedules"),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[I,T]=(0,i.useState)(void 0),[E,A]=(0,i.useState)(void 0),M=(0,i.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();u(t.logs||[])}if(n.ok){let e=await n.json();h(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,i.useEffect)(()=>{M()},[M]);let R=(0,i.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=(function(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})(u).get("Schedules"))?n:[]).find(t=>{var n;return(null!=(n=t[0])?n:"").trim()===e});if(!m)return null;let x=(0,n_.I_)(null!=(a=m[3])?a:"claude"),h=(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:""===h||"true"===h,permission:(null!=(i=m[5])?i:"").trim(),model:null!=(o=x.model)?o:""}}catch(e){return null}},[t]),L=(0,i.useCallback)(()=>{A(void 0),T(void 0),S(!0)},[]),P=(0,i.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,i.useCallback)(async e=>{if(await o({description:l("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,l,M,o]),F=(0,i.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)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:l("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)(m.$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:l("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:[l("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:[l("tabs.logs")," (",d.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:[l("activeSchedulesTitle")," (",f.length,")"]}),(0,r.jsx)("span",{className:"text-xs text-accent-700 dark:text-accent-300",children:l("activeSchedulesDescription")})]}),0===f.length?(0,r.jsx)("p",{className:"text-xs text-accent-800 dark:text-accent-300",children:l("noActiveSchedules")}):(0,r.jsx)("div",{className:"space-y-2",children:f.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?l("activeState.active"):l("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:l("activeState.executing")})]})]}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:[l("cron"),": ",e.cronExpression||"N/A"]}),(0,r.jsxs)("span",{className:"ml-3",children:[l("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:[l("nextRun"),": ",nG(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:l("emptyState.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:l("emptyState.description")}),(0,r.jsxs)(m.$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"})}),l("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:l("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:l("noSchedulesStep1")}),(0,r.jsx)("li",{children:l("noSchedulesStep2")}),(0,r.jsx)("li",{children:l("noSchedulesStep3")}),(0,r.jsx)("li",{children:l("noSchedulesStep4")})]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 flex items-center justify-end",children:(0,r.jsxs)(m.$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"})}),l("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?l("edit.disable"):l("edit.enable"),title:t?l("edit.disable"):l("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)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-edit-".concat(e.name),"aria-label":l("edit.edit"),title:l("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)(nQ,{})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-delete-".concat(e.name),"aria-label":l("edit.delete"),title:l("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)(nX,{})})]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[(0,r.jsxs)("span",{children:[l("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,r.jsxs)("span",{className:"ml-3",children:[l("lastRun"),": ",nG(e.last_executed_at)]})]})]},e.id)})})]})]}):(0,r.jsx)(nY,{worktreeId:t,logs:d})}),(0,r.jsx)(nq,{isOpen:C,worktreeId:t,initialValues:I,originalName:E,onInsertToMessage:a,instances:s,onClose:()=>S(!1),onSaved:()=>{M()}})]})}),n0=(0,i.memo)(function(e){let{worktreeId:t,vibeLocalModel:n,onVibeLocalModelChange:a,vibeLocalContextWindow:s,onVibeLocalContextWindowChange:l}=e,o=(0,c.c)("schedule"),[d,m]=(0,i.useState)([]),[x,h]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null!=s?String(s):""),[j,w]=(0,i.useState)(!1);(0,i.useEffect)(()=>{y(null!=s?String(s):"")},[s]),(0,i.useEffect)(()=>{let e=!1;return p(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(m(t.models),h(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(m([]),h("Failed to fetch models"))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[]);let k=(0,i.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,i.useCallback)(e=>{y(e.target.value)},[]),C=(0,i.useCallback)(async()=>{let e=v.trim(),n=parseInt(e,10),a=""===e||Number.isNaN(n)?null:n,r=null!=s?s: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==l||l(a):y(null!=r?String(r):"")}catch(e){y(null!=r?String(r):"")}finally{w(!1)}}},[v,s,t,l]);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:o("vibeLocalModel")}),f?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"xs",variant:"muted"}),o("loading")]}):x&&0===d.length?(0,r.jsx)("p",{className:"text-xs text-warning-foreground",children:o("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:o("vibeLocalModelDefault")}),d.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:o("vibeLocalContextWindow")}),(0,r.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:K.vz,max:K.NL,value:v,onChange:N,onBlur:C,placeholder:o("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"})]})]})}),n1=Object.freeze({agent:null,providerId:null,modelId:null,variant:null}),n2=[{id:"opencode",label:(0,K.oo)("opencode")}];function n4(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{providerId:e.slice(0,t),modelId:e.slice(t+1)}}let n5=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),[s,l]=(0,i.useState)({}),[o,d]=(0,i.useState)({connected:!1,providers:[],agents:[]}),[u,x]=(0,i.useState)(!0),[h,f]=(0,i.useState)(!1),[p,g]=(0,i.useState)(null);(0,i.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||(l(null!=(n=t.settings)?n:{}),d(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,i.useCallback)(async(e,n)=>{l(t=>({...t,[e]:n})),f(!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&&l(t=>({...t,[e]:s.settings}))}catch(e){g(a("opencodeSettingsSaveError"))}finally{f(!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")}),u?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}),a("loading")]}):(0,r.jsxs)("div",{className:"space-y-4",children:[!o.connected&&(0,r.jsx)("p",{"data-testid":"opencode-settings-offline",className:"text-xs text-muted-foreground",children:a("opencodeSettingsOffline")}),n.map(e=>{var t,l,i,c,d,u;let m=null!=(t=s[e.id])?t:{...n1},x=m.providerId&&m.modelId?"".concat(m.providerId,"/").concat(m.modelId):"",f=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}(o,m),p=null!=(l=null==f?void 0:f.variants)?l:[],g=o.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:h,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!=(c=m.agent)?c:"",disabled:h,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"),o.providers.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-model-select-".concat(e.id),value:x,disabled:h,onChange:t=>{var n,a;let r=n4(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")}),o.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:h,placeholder:a("opencodeModelPlaceholder"),onBlur:t=>{var n,a;let r=n4(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:h,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:h,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"})]}),f&&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")}),h&&(0,r.jsxs)("div",{"data-testid":"opencode-settings-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.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})]})]})}),n3=(0,i.memo)(function(e){let{worktreeId:t,selectedAgents:n,onSelectedAgentsChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,maxAgents:u=2,availableAgents:x=K.XH,persistToServer:h=!0}=e,f=(0,c.c)("schedule"),p=n.length>u?n.slice(0,u):n,[g,b]=(0,i.useState)(()=>new Set(p)),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(g);k.current=g,(0,i.useEffect)(()=>{j||b(new Set(p))},[n,j,u]);let N=g.has("vibe-local"),C=g.has("opencode"),S=(0,i.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(!h){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,h]),I=g.size>=u;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:f("agentSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:f("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)(m.Sc,{"data-testid":"agent-checkbox-".concat(e),"aria-label":(0,K.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,K.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)(m.y$,{size:"xs",variant:"muted"}),f("loading")]}),C&&(0,r.jsx)(n5,{worktreeId:t,instances:n2}),N&&(0,r.jsx)(n0,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})});function n6(e){return"".concat("commandmate:worktree:mobileInstances:").concat(e)}function n9(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 n8=n(49476),n7=n(52056),ae=n(65506),at=n(7620),an=n(50803),aa=n(20017),ar=n(18085),as=n(6191),al=n(27937),ai=n(41108),ao=n(95342),ac=n(63001),ad=n(55449);let au="/api/worktrees/apply-default-agents";var am=n(18848);let ax=["noteInstanceFlag","noteWaitOnPrompt","noteRespondNumber"];function ah(e){let{worktreeId:t,instance:n,isOpen:a,onClose:s}=e,l=(0,c.c)("worktree"),[o,d]=(0,i.useState)(!1),[m,x]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),[p,g]=(0,i.useState)(null),[b,v]=(0,i.useState)(null),[y,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(0);(0,i.useEffect)(()=>{if(!a)return;let e=!1;return d(!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;f(s),g(l)}catch(t){e||x(!0)}finally{e||d(!1)}})(),()=>{e=!0}},[a,t,n.id,w]);let N=h&&p?(0,am.kj)({binary:h.binary,worktreeId:h.worktreeId,instanceId:p.instanceId,portPrefix:h.portPrefix,messagePlaceholder:l("cliCommands.messagePlaceholder")}):null,C=(0,i.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)(e3.a,{isOpen:a,onClose:s,size:"md",title:l("cliCommands.title",{alias:n.alias}),children:(0,r.jsxs)("div",{className:"space-y-4","data-testid":"cli-commands-panel-".concat(n.id),children:[o&&(0,r.jsxs)("div",{"data-testid":"cli-commands-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"xs",variant:"muted"}),l("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:l("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:l("cliCommands.retry")})]}),N&&p&&h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{"data-testid":"cli-commands-target",className:"text-xs text-muted-foreground break-words",children:l("cliCommands.target",{instance:p.instanceId,tool:(0,K.oo)(p.cliToolId),stage:l("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)(n7.A,{className:"w-3 h-3 mt-0.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:l("cliCommands.conflict",{instance:p.conflict.instanceId,roster:(0,K.oo)(p.conflict.rosterCliTool),requested:(0,K.oo)(p.conflict.requestedCliTool)})})]}),(0,r.jsx)("ul",{className:"space-y-3",children:am.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:l("cliCommands.commandLabel.".concat(e))}),(0,r.jsxs)("button",{type:"button","data-testid":"cli-commands-copy-".concat(e),"aria-label":l("cliCommands.copy"),title:l("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)(em.A,{className:"w-3 h-3","aria-hidden":"true"}):(0,r.jsx)(ex.A,{className:"w-3 h-3","aria-hidden":"true"}),b===e?l("cliCommands.copied"):l("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:l("cliCommands.commandDescription.".concat(e))})]},e))}),y&&(0,r.jsx)("p",{"data-testid":"cli-commands-copy-error",className:"text-xs text-danger-foreground",children:l("cliCommands.copyFailed")}),null!==h.portPrefix&&(0,r.jsx)("p",{"data-testid":"cli-commands-port-hint",className:"text-xs text-muted-foreground",children:l("cliCommands.portHint",{port:h.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:l("cliCommands.notesTitle")}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:ax.map(e=>(0,r.jsx)("li",{"data-testid":"cli-commands-".concat(e),className:"text-xs text-muted-foreground",children:l("cliCommands.".concat(e))},e))})]})]})]})})}var af=n(46022),ap=n(45573);function ag(e){return"prompt"===e.tone?"text-warning":"text-muted-foreground"}let ab=(0,i.memo)(function(e){var t;let{worktreeId:n,instances:a,onInstancesChange:s,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:m,modelByInstance:x,sourceByInstance:h,composerTargetInstanceId:f,className:p=""}=e,g=(0,c.c)("schedule"),b=(0,eW.Ym)(),{showToast:v}=(0,e$.dj)(),y=(0,c.c)("common"),j=(0,c.c)("worktree"),w=(0,ei.SC)(),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(null),[I,T]=(0,i.useState)({}),[E,A]=(0,i.useState)(K.XH[0]),[M,R]=(0,i.useState)(null),[L,P]=(0,i.useState)(!1),[D,F]=(0,i.useState)(!1),[O,z]=(0,i.useState)(null),_=(0,i.useCallback)(async e=>{let t=ap.yW["ja"===b?"ja":"en"];if((null!=f?f:(0,ap.xk)())===e.id)return void v(t.self,"info");let a=await (0,ap.P0)(n,e,b);if(null===a)return void v(t.failed,"error");let r=(0,ap.oQ)(a);v(r?t.inserted:t.noComposer,r?"success":"error")},[f,b,v,n]),V=function(e,t,n){let[a,r]=(0,i.useState)({}),s=t.some(e=>"opencode"===e.cliTool);return(0,i.useEffect)(()=>{if(n)return;if(!s)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 l=setInterval(()=>void a(),1e4);return()=>{t=!0,clearInterval(l)}},[e,s,n]),null!=n?n:a}(n,a,h),B=(0,ai.UI)(n),W=(0,i.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]),H=a.length>=K.Ab,$=a.length<=1,G=a.some(e=>"vibe-local"===e.cliTool),J=(0,i.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]),Y=function(e,t){let[n,a]=(0,i.useState)(null),[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),g=(0,i.useCallback)(e=>{s("string"==typeof(null==e?void 0:e.repositoryName)?e.repositoryName:null),o((null==e?void 0:e.repoDeclaresAgents)===!0)},[]),b=(0,i.useCallback)(async()=>{d(!0);try{let t=await fetch("".concat(au,"?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,i.useCallback)(async()=>{d(!0),p(null),m(!1),h(null);try{let e=await fetch(ad.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,ad.IK)(a),m(!0),!0}catch(e){return p("save"),!1}finally{d(!1)}},[t]),y=(0,i.useCallback)(async()=>{d(!0),p(null),m(!1);try{let n=await fetch(au,{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;h(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:l,busy:c,savedDefault:u,appliedCount:x,error:f,refreshEligible:b,saveAsDefault:v,applyToUnchanged:y}}(n,J),Q=J.length>=ac.eu&&J.length<=ac.Wj,X=k||Y.busy,Z=Q&&!Y.repoDeclaresAgents&&null!==Y.eligible&&Y.eligible>0,ee="count"===Y.error?g("agentDefaultsCountError"):"save"===Y.error?g("agentDefaultsSaveError"):"apply"===Y.error?g("agentDefaultsApplyError"):null,et=(0,i.useCallback)(()=>{let e=!D;F(e),e&&Y.refreshEligible()},[D,Y]),en=(0,i.useCallback)(async()=>{if(!Z)return;let e=await Y.refreshEligible();null!==e&&0!==e&&await w({description:g("agentDefaultsApplyConfirm",{count:e,agents:J.map(e=>(0,K.oo)(e)).join(", ")})})&&await Y.applyToUnchanged()},[Z,Y,w,g,J]),ea=(0,i.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?s(t):S(g("agentInstanceSaveError"))}catch(e){S(g("agentInstanceSaveError"))}finally{N(!1)}},[n,s,g]),er=(0,i.useCallback)(()=>{if(a.length>=K.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);ea([...a,{id:e,cliTool:E,alias:function(e,t){let n=(0,K.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,ea]),es=(0,i.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"})&&ea(a.filter(t=>t.id!==e))},[a,ea,w,y]),el=(0,i.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]],ea(r)},[a,ea]),eo=(0,i.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&&ea(a.map(n=>n.id===e?{...n,alias:t}:n))},[a,ea]),ec=(0,i.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),ea(n)},[a,ea]),ed=["flex flex-col p-4",p?"overflow-y-auto":"",p].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:ed,"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,l;let i=e.id in I?I[e.id]:e.alias,o=M===t,c=null!=(s=null==x?void 0:x[e.id])?s:null,d=null==V?void 0:V[e.id],u=sD(d,j),m=!!(l=d)&&("sse"!==l.kind||"live"!==l.liveness),h=(0,ao.g)({owed:B.owedBy(e.id),awaiting:B.awaitedBy(e.id),aliasOf:W}),p=f===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&&ec(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(o?"opacity-50":""),children:[(0,r.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,r.jsx)(n8.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:i,maxLength:K.pQ,disabled:k,placeholder:g("agentInstanceAliasPlaceholder"),onChange:t=>T(n=>({...n,[e.id]:t.target.value})),onBlur:t=>eo(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)(tG.nR,{content:(0,K.oo)(e.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"}),c&&(0,r.jsx)("span",{"data-testid":"agent-instance-model-".concat(e.id),title:j("agentModel.modelLabel",{model:c}),className:"mt-0.5 block truncate text-xs text-muted-foreground",children:c}),u&&(0,r.jsxs)("span",{"data-testid":"agent-instance-source-".concat(e.id),title:j(m?"agentSource.degradedTitle":"agentSource.healthyTitle"),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(m?"text-warning":"text-muted-foreground"),children:[m?(0,r.jsx)(n7.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}):(0,r.jsx)(ae.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:u})]}),h.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(ag(t)),children:[(0,r.jsx)(at.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)(an.A,{className:"w-4 h-4"})}),O===e.id&&(0,r.jsx)(ah,{worktreeId:n,instance:e,isOpen:!0,onClose:()=>z(null)}),(0,r.jsxs)(q.rI,{children:[(0,r.jsx)(q.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)(aa.A,{className:"w-4 h-4"})})}),(0,r.jsxs)(q.SQ,{align:"end",children:[!p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(q._2,{"data-testid":"agent-instance-delegate-".concat(e.id),onSelect:()=>{_(e)},children:[(0,r.jsx)(ar.A,{className:"w-4 h-4"}),ap.yW["ja"===b?"ja":"en"].menuItem]}),(0,r.jsx)(q.mB,{})]}),(0,r.jsxs)(q._2,{"data-testid":"agent-instance-move-up-".concat(e.id),disabled:0===t,onSelect:()=>el(t,-1),children:[(0,r.jsx)(nu.A,{className:"w-4 h-4"}),g("agentInstanceMoveUp")]}),(0,r.jsxs)(q._2,{"data-testid":"agent-instance-move-down-".concat(e.id),disabled:t===a.length-1,onSelect:()=>el(t,1),children:[(0,r.jsx)(U.A,{className:"w-4 h-4"}),g("agentInstanceMoveDown")]}),(0,r.jsx)(q.mB,{}),(0,r.jsxs)(q._2,{"data-testid":"agent-instance-delete-".concat(e.id),disabled:$,onSelect:()=>{es(e.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,r.jsx)(tW.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||H,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:K.XH.map(e=>(0,r.jsx)("option",{value:e,children:(0,K.oo)(e)},e))}),(0,r.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:k||H,onClick:er,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)(as.A,{className:"w-4 h-4"}),g("agentInstanceAdd")]})]}),H&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("agentInstanceMax",{max:K.Ab})}),$&&(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)(u.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}),G&&(0,r.jsx)(n0,{worktreeId:n,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:d,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:et,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)(U.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(al.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:J.map(e=>(0,K.oo)(e)).join(" → ")}),!Q&&(0,r.jsx)("p",{"data-testid":"agent-defaults-invalid",className:"text-xs text-warning-foreground",children:g("agentDefaultsInvalidRoster",{min:ac.eu,max:ac.Wj})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-set-default",disabled:X||!Q,onClick:()=>{Y.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:[Y.repositoryName&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repository","data-repository":Y.repositoryName,className:"text-xs text-muted-foreground",children:g("agentDefaultsRepositoryLabel",{repository:Y.repositoryName})}),Y.repoDeclaresAgents&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repo-declared",className:"text-xs text-warning-foreground",children:g("agentDefaultsRepoDeclared")}),!Y.repoDeclaresAgents&&(0,r.jsx)("span",{"data-testid":"agent-defaults-eligible","data-count":null!=(t=Y.eligible)?t:void 0,className:"block text-xs text-muted-foreground",children:null===Y.eligible?g("agentDefaultsEligibleUnknown"):g("agentDefaultsEligible",{count:Y.eligible})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-apply",disabled:X||!Z,onClick:()=>{en()},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")})]}),Y.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)(em.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),g("agentDefaultsSaved")]}),null!==Y.appliedCount&&(0,r.jsxs)("p",{"data-testid":"agent-defaults-applied","data-count":Y.appliedCount,className:"flex items-center gap-1 text-xs text-success-foreground",children:[(0,r.jsx)(em.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),g("agentDefaultsApplied",{count:Y.appliedCount})]}),ee&&(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:ee}),"count"===Y.error&&(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-retry",disabled:X,onClick:()=>{Y.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)(U.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(al.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)(af.uN,{worktreeId:n,instances:a.map(e=>({id:e.id,cliTool:e.cliTool,alias:e.alias})),variant:"plain"})})]})]})}),av=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,visibleInstanceIds:u,onToggleInstanceVisible:x,modelByInstance:h,sourceByInstance:f,composerTargetInstanceId:p}=e,g=(0,c.c)("schedule"),b=(0,c.c)("worktree"),v=new Set(u),y=u.length<=1,j=(0,ai.UI)(t),w=(0,i.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)(ab,{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,modelByInstance:h,sourceByInstance:f,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==h?void 0:h[e.id])?t:null,l=(0,ao.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)(m.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,K.sw)(e)}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,K.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(ag(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")})]})]})}),ay=Array.from({length:Math.floor(104)+1},(e,t)=>3e5+3e5*t);var aj=n(76351);function aw(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 ak="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 aN(e){let{isOpen:t,worktreeId:n,instances:a,onClose:s,onSaved:l}=e,o=(0,c.c)("schedule"),d=(0,ns.a)(),u=(0,i.useMemo)(()=>a&&a.length>0?a:(0,K.lu)([...K.XH]),[a]),[m,x]=(0,i.useState)(""),[h,f]=(0,i.useState)(()=>{var e,t;return null!=(t=null==(e=u[0])?void 0:e.id)?t:K.XH[0]}),[p,g]=(0,i.useState)(ay[0]),[b,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(null);(0,i.useEffect)(()=>{var e,n;t&&(x(""),g(ay[0]),j(null),v(!1),f(null!=(n=null==(e=u[0])?void 0:e.id)?n:K.XH[0]))},[t,u]),(0,i.useEffect)(()=>{if(!u.some(e=>e.id===h)){var e,t;f(null!=(t=null==(e=u[0])?void 0:e.id)?t:K.XH[0])}},[u,h]);let w=m.trim().length>0&&!b,k=(0,i.useCallback)(async()=>{if(!m.trim()||b)return;let e=u.find(e=>e.id===h);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();l(),"session_not_running"===e.warning?(j("session_not_running"),x("")):s()}}catch(e){}finally{v(!1)}}},[n,u,h,m,p,b,l,s]),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:o("timer.agent")}),(0,r.jsx)("select",{id:"timer-instance-select","data-testid":"timer-instance-select",value:h,onChange:e=>f(e.target.value),className:ak,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:o("timer.message")}),(0,r.jsx)("textarea",{id:"timer-message-input","data-testid":"timer-message-input",value:m,onChange:e=>x(e.target.value),placeholder:o("timer.message"),maxLength:1e4,rows:3,className:"".concat(ak," 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:o("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:ak,children:ay.map(e=>(0,r.jsx)("option",{value:e,children:aw(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:o("timer.sessionWarning")})]}),C=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:o("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:o("timer.register")})]}),S=o("timer.titleCreate");return d?(0,r.jsx)(nC,{isOpen:t,onClose:s,title:S,footer:C,children:N}):(0,r.jsx)(e3.a,{isOpen:t,onClose:s,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 aC(e){return new Date(e).toLocaleString()}function aS(e){var t,n;let{timer:a,instances:s,onClose:l}=e,i=(0,c.c)("schedule"),o=(0,ns.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:i("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:i("timer.agent"),children:(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:d})}),(0,r.jsx)(u,{label:i("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:i("timer.status.".concat(a.status))})}),(0,r.jsx)(u,{label:i("timer.delay"),children:aw(a.delayMs)}),(0,r.jsx)(u,{label:i("timer.scheduledTime"),children:aC(a.scheduledSendTime)}),(0,r.jsx)(u,{label:i("timer.createdTime"),children:aC(a.createdAt)}),null!==a.sentAt&&(0,r.jsx)(u,{label:i("timer.sentTime"),children:aC(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:i("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:i("timer.close")})}),h=i("timer.detailTitle");return o?(0,r.jsx)(nC,{isOpen:!0,title:h,onClose:l,footer:x,children:m}):(0,r.jsx)(e3.a,{isOpen:!0,title:h,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 aI=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),s=(0,ei.SC)(),l=(0,i.useMemo)(()=>n&&n.length>0?n:(0,K.lu)([...K.XH]),[n]),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(!1),[f,p]=(0,i.useState)(null),[,g]=(0,i.useState)(0),b=(0,i.useRef)(null),v=(0,i.useRef)(null),j=(0,i.useRef)(null),w=(0,i.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,i.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,i.useEffect)(()=>{function e(){return w(),b.current=setInterval(()=>{w()},1e4),v.current=setInterval(()=>{g(e=>e+1)},1e3),t}function t(){b.current&&clearInterval(b.current),v.current&&clearInterval(v.current),b.current=null,v.current=null}e();let n=()=>{"hidden"===document.visibilityState?t():e()};return document.addEventListener("visibilitychange",n),()=>{t(),document.removeEventListener("visibilitychange",n)}},[w]);let N=(0,i.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/timers?timerId=").concat(e),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w]),C=(0,i.useCallback)(async()=>{if(await s({description:a("timer.clearConfirm"),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/timers/history"),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w,a,s]),S=o.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===o.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)(y.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:()=>h(!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)(as.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:()=>h(!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)(as.A,{className:"w-3.5 h-3.5"}),a("timer.newTimer")]})]}),o.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=l.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,aj.$B)(e.scheduledSendTime)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:aw(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")}),o.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)(aN,{isOpen:x,worktreeId:t,instances:n,onClose:()=>h(!1),onSaved:()=>{w()}}),(0,r.jsx)(aS,{timer:f,instances:l,onClose:()=>p(null)})]})});var aT=n(35626),aE=n(99648);let aA={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},aM={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},aR={outcome:"unknown",evidenceKind:"not_measured",labelKey:aA.unknown,evidenceKindKey:aM.not_measured,limitationKey:null},aL={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",UNKNOWN:"skills.compatibility.reload.unknown"},aP={NO_SLASH_COMMAND:"skills.compatibility.limitation.noSlashCommand"};function aD(e){return{agent:e,discoveryRoots:[],discovery:aR,invocation:aR,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:aL.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}aE.td,aA.verified,aM.mechanical,aA.verified,aM.mechanical,aL.SESSION_RESTART,aE.Co,aA.verified,aM.self_report,aA.unsupported,aM.mechanical,aP.NO_SLASH_COMMAND,aL.SESSION_RESTART_NO_SLASH,aD("gemini"),aD("vibe-local"),aE.Co,aE.td,aA.verified,aM.mechanical,aA.verified,aM.mechanical,aP.NO_SLASH_COMMAND,aL.SESSION_RESTART,aE.Co,aE.td,aA.verified,aM.mechanical,aA.verified,aM.mechanical,aL.UNKNOWN,aD("antigravity"),aE.Co,aA.verified,aM.mechanical,aA.verified,aM.mechanical,aL.SESSION_RESTART;let aF={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"};aF.SATISFIED,aF.HOST_VERSION_OUT_OF_RANGE,aF.HOST_VERSION_UNKNOWN,aF.RANGE_UNSUPPORTED;let aO={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};aO.CONFIRMED,aO.RESTRICTED,aO.STALE_DECLARATION,aO.UNVERIFIED;let az=/^(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 a_(e){if("string"!=typeof e||e.length>64)return null;let t=az.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 aV={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 aB(e,t){let n=function(e,t){let n=a_(e),a=a_(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}aV.UP_TO_DATE,aV.HIGHEST_COMPATIBLE,aV.LATEST_UNVERIFIED,aV.NONE_COMPATIBLE,aV.INSTALLED_VERSION_INVALID,aV.RANGE_UNSUPPORTED;var aU=n(75333),aW=n(34380),aH=n(37381),aK=n(95584),a$=n(80130);let aq={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function aG(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 aJ(e){var t;let{skillId:n,skillName:a,worktreeId:s,installedVersion:l,versions:o}=e,d=(0,c.c)("skills"),u=(0,i.useMemo)(()=>o.filter(e=>aB(e.version,l)),[o,l]),x=(0,i.useMemo)(()=>{var e,t,n;return null!=(n=null==(e=null!=(t=u.find(e=>"compatible"===e.compatibility.commandmate.status))?t:u[0])?void 0:e.version)?n:null},[u]),[h,f]=(0,i.useState)(aq),p=(0,i.useCallback)(()=>{f({...aq,open:!0,selectedVersion:x})},[x]),g=(0,i.useCallback)(()=>{f(aq)},[]),b=(0,i.useCallback)(async()=>{let e=h.selectedVersion;if(!e)return;f(e=>({...e,busy:!0,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applyResult:null,applyFailure:null}));let t=await (0,a$.Sw)(s,n,{version:e});f(e=>({...e,busy:!1,plan:t.ok?t.data.plan:null,failure:t.ok?null:t.failure}))},[n,h.selectedVersion,s]),v=(0,i.useCallback)(async()=>{var e;let t=h.plan;if(!t||!t.updatable)return;f(e=>({...e,applying:!0,applyFailure:null}));let a=await (0,a$.h2)(s,n,{planToken:t.token,version:t.update.toVersion,acknowledgeRisk:h.riskAcknowledged,acknowledgeRiskIncrease:h.riskIncreaseAcknowledged,idempotencyKey:(e=t.token,"skill-update-".concat(e))});f(e=>({...e,applying:!1,applyResult:a.ok?a.data:null,applyFailure:a.ok?null:a.failure}))},[n,h.plan,h.riskAcknowledged,h.riskIncreaseAcknowledged,s]);if(0===u.length)return(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-uptodate",children:d("update.upToDate",{version:l})});let y=h.plan,j=h.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)(m.Ex,{variant:"info","data-testid":"skill-update-badge",children:d("update.badge")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:d("update.fromTo",{from:l,to:u[0].version})}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:p,"data-testid":"skill-update-trigger",children:d("update.open")})]}),(0,r.jsx)(m.Jh,{isOpen:h.open,onClose:g,title:d("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:d("update.intro",{skill:a,version:l})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:d("update.ready")}),(0,r.jsxs)("label",{className:"block text-xs font-medium text-muted-foreground",children:[d("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=h.selectedVersion)?t:"",onChange:e=>f(t=>({...t,selectedVersion:e.target.value,plan:null,failure:null})),disabled:h.busy,"data-testid":"skill-update-version-select",children:u.map(e=>(0,r.jsxs)("option",{value:e.version,children:[e.version,e.prerelease?" (".concat(d("detail.prerelease"),")"):"","compatible"!==e.compatibility.commandmate.status?" — ".concat(d(aK.OV[e.compatibility.commandmate.status])):""]},e.version))})]}),(0,r.jsx)(m.$n,{variant:"primary",disabled:h.busy||!h.selectedVersion,onClick:b,"data-testid":"skill-update-build",children:h.busy?d("update.building"):d("update.build")}),h.failure&&(0,r.jsxs)(aH.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,r.jsx)("p",{children:d((0,aK.FW)(h.failure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:h.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:d("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:d("update.latestAvailable",{version:y.update.latestVersion})})]}),(0,r.jsx)(aH.u,{tone:y.updatable?"info":"warning","data-testid":"skill-update-next-action",children:d((0,aK.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}),d((0,aK.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:d("plan.riskHeading")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-foreground",children:[(0,r.jsx)(aU.qW,{risk:y.securityDiff.risk.from.effective}),(0,r.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,r.jsx)(aU.qW,{risk:y.securityDiff.risk.to.effective})]}),y.riskIncreased&&y.riskIncreaseMessageKey&&(0,r.jsx)(aH.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:d((0,aK.e5)(y.riskIncreaseMessageKey))}),y.requiresRiskAcknowledgement&&y.riskAcknowledgementMessageKey&&(0,r.jsx)(aH.u,{tone:"warning","data-testid":"skill-update-high-risk",children:d((0,aK.e5)(y.riskAcknowledgementMessageKey))}),y.updatable&&!h.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:h.riskAcknowledged,onChange:e=>f(t=>({...t,riskAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk"}),d("update.ackRisk")]}),y.updatable&&!h.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:h.riskIncreaseAcknowledged,onChange:e=>f(t=>({...t,riskIncreaseAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk-increase"}),d("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:d("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:d(null!=(t=aK.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:d("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:d(null!=(t=aK.z2[e])?t:"plan.permissionsNone")},e)})})]}),(0,r.jsx)(aG,{heading:d("update.scriptsAdded"),paths:y.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,r.jsx)(aG,{heading:d("update.scriptsRemoved"),paths:y.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,r.jsx)(aG,{heading:d("update.executablesAdded"),paths:y.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,r.jsx)(aG,{heading:d("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:d("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:d("update.filesHeading")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-stats",children:d("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)(m.Ex,{variant:null!=(t=aK.JD[e.change])?t:"gray",children:d(null!=(n=aK.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:d("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:d("plan.expiresAt",{timestamp:y.expiresAt})}),y.updatable&&!h.applyResult&&(0,r.jsx)(m.$n,{variant:"primary",disabled:h.applying||y.requiresRiskAcknowledgement&&!h.riskAcknowledged||y.riskIncreased&&!h.riskIncreaseAcknowledged,onClick:v,"data-testid":"skill-update-apply",children:h.applying?d("update.applying"):d("update.apply")}),h.applyFailure&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,r.jsxs)(aH.u,{tone:"danger",children:[(0,r.jsx)("p",{children:d((0,aK.FW)(h.applyFailure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:h.applyFailure.code})})]}),h.applyFailure.nextActionKey&&(0,r.jsx)(aH.u,{tone:"warning",children:d((0,aK.e5)(h.applyFailure.nextActionKey))}),h.applyFailure.blockers&&h.applyFailure.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:h.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}),d((0,aK.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)(aH.u,{tone:"succeeded"===j.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:d((0,aK.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:d("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:d("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:d((0,aK.e5)(e.messageKey),{agent:(0,K.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:d((0,aK.e5)(j.rollback.messageKey),{version:j.rollback.backup.fromVersion})})]})]})]})})]})}let aY={status:"loading",skills:[],failure:null},aQ={status:"loading",skills:[],failure:null};function aX(e){var t,n,a,s,l,o,d,u;let{worktreeId:x,className:h=""}=e,f=(0,c.c)("skills"),[p,g]=(0,i.useState)(aY),[b,v]=(0,i.useState)(aQ),[y,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(0),[N,C]=(0,i.useState)(0);(0,i.useEffect)(()=>{let e=new AbortController;return g(aY),(0,a$.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,i.useEffect)(()=>{let e=new AbortController;return v(aQ),(0,a$.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,i.useMemo)(()=>new Map(b.skills.map(e=>[e.skillId,e.version])),[b.skills]),I=(0,i.useMemo)(()=>new Map(p.skills.map(e=>[e.id,{name:e.name,summary:e.summary,latest:e.latest}])),[p.skills]),T=(0,i.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&&aB(a,s)))}return e},[S,I]),E=(0,i.useMemo)(()=>{var e;return null!=(e=p.skills.find(e=>e.id===y))?e:null},[p.skills,y]),A=(0,i.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!=(s=null==A?void 0:A.version)?s:null,n=E?E.recommendedVersion?e&&"compatible"!==e.status?f("detail.install.blockedIncompatible",{reason:f((0,aK.e5)(e.messageKey),{range:e.requiredRange,currentVersion:null!=(l=e.currentVersion)?l:""})}):null:f("detail.install.blockedNoVersion"):null;return(0,r.jsxs)("div",{className:"flex flex-col min-h-0 ".concat(h).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)(m.$n,{variant:"ghost",size:"sm",onClick:()=>{j(null),C(e=>e+1)},"data-testid":"worktree-skills-back",children:[(0,r.jsx)(aT.A,{size:14,"aria-hidden":"true",className:"mr-1"}),f("worktreePane.back")]}),(0,r.jsx)("h2",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:null!=(o=null==E?void 0:E.name)?o:y})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[A&&E&&(0,r.jsx)(aJ,{skillId:y,skillName:E.name,worktreeId:x,installedVersion:A.version,versions:E.versions}),(0,r.jsx)(aW.B,{skillId:y,version:t,blockedReason:n,worktreeId:x})]})]})}return(0,r.jsx)("div",{className:"flex flex-col min-h-0 ".concat(h).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:f("worktreePane.installedHeading")}),"loading"===b.status?(0,r.jsx)(m.EA,{className:"h-16 w-full rounded-lg","data-testid":"worktree-skills-installed-loading"}):"error"===b.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-installed-error",children:[(0,r.jsxs)(aH.u,{tone:"danger",children:[(0,r.jsx)("p",{children:f("worktreePane.installedError")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:f("state.errorCode",{code:null!=(d=null==(t=b.failure)?void 0:t.code)?d:""})})]}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:()=>C(e=>e+1),"data-testid":"worktree-skills-installed-retry",children:f("state.retry")})]}):0===b.skills.length?(0,r.jsx)(m.Zp,{"data-testid":"worktree-skills-installed-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:f("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)(aU.qW,{risk:e.effectiveRisk}),T.get(e.skillId)&&(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-update-badge-".concat(e.skillId),children:f("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:f("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:f("worktreePane.catalogHeading")}),"loading"===p.status?(0,r.jsx)(m.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===p.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,r.jsxs)(aH.u,{tone:"danger",children:[(0,r.jsx)("p",{children:f("state.errorNotice")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:f("state.errorCode",{code:null!=(u=null==(n=p.failure)?void 0:n.code)?u:""})})]}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:()=>k(e=>e+1),"data-testid":"worktree-skills-catalog-retry",children:f("state.retry")})]}):0===p.skills.length?(0,r.jsx)(m.Zp,{"data-testid":"worktree-skills-catalog-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:f("state.empty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:p.skills.map(e=>{let t=(0,aK.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)(m.Ex,{variant:"info","data-testid":"worktree-skills-catalog-update-badge-".concat(e.id),children:f("worktreePane.updateBadge")}):(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-installed-badge-".concat(e.id),children:f("worktreePane.installedBadge")}))]}),(0,r.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:f("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:f("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)(aU.Xz,{status:e.compatibility.status}),t&&(0,r.jsx)(aU.qW,{risk:t})]})]})},e.id)})})]})]})})}var aZ=n(93499),a0=n(76907),a1=n(52799),a2=n(32209);let a4={pending:"gray",running:"info",waiting_input:"warning",verifying:"info",succeeded:"success",failed:"error",not_started:"warning",cancelled:"gray"},a5={running:"info",passed:"success",failed:"error",not_started:"warning",error:"error",cancelled:"gray"},a3={running:"info",passed:"success",failed:"error",timeout:"error",skipped:"gray",error:"error"},a6=["failed","timeout","error"],a9="".concat(eX,"/blob/main/docs/design/verification-config.md"),a8=".commandmate/verify.yaml";class a7 extends Error{constructor(e,t,n=null){super(e),this.name="VerificationApiError",this.status=t,this.runningRunId=n}}async function re(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 a7(a,e.status,r)}function rt(e){return"/api/worktrees/".concat(encodeURIComponent(e))}async function rn(e,t){var n,a;let r=await fetch("".concat(rt(e),"/tasks?limit=1"),{signal:t});return r.ok?null!=(a=null==(n=(await r.json()).tasks)?void 0:n[0])?a:null:re(r,"Failed to load tasks")}async function ra(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(rt(e),"/verify/runs?limit=").concat(n),{signal:a});return r.ok?null!=(t=(await r.json()).runs)?t:[]:re(r,"Failed to load verification runs")}async function rr(e,t,n){let a=await fetch("".concat(rt(e),"/verify/runs/").concat(t),{signal:n});return 404===a.status?null:a.ok?(await a.json()).run:re(a,"Failed to load the verification run")}async function rs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=await fetch("".concat(rt(e),"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)return re(n,"Failed to start verification");let a=await n.json();if("number"!=typeof a.runId)throw new a7("Verification response carried no run id",n.status);return a.runId}async function rl(e,t){var n,a,r;let s=await fetch("".concat(rt(e),"/verify/config"),{signal:t});if(!s.ok)return re(s,"Failed to load the verification config");let l=await s.json();return{exists:!0===l.exists,path:"string"==typeof l.path?l.path:a8,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 ri(e){var t,n,a;let r=await fetch("".concat(rt(e),"/verify/config"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!r.ok)return re(r,"Failed to draft the verification config");let s=await r.json();return{created:!0===s.created,path:"string"==typeof s.path?s.path:a8,gates:null!=(t=s.gates)?t:[],excluded:null!=(n=s.excluded)?n:[],scanned:null!=(a=s.scanned)?a:[]}}async function ro(e,t){var n;let a=await fetch("".concat(rt(e),"/verify/runs/").concat(t,"/cancel"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!a.ok)return re(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 rc(){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:[]:re(s,"Failed to load the verification history")}let rd={running:null,passed:0,failed:20,not_started:21,error:99,cancelled:99},ru=["passed","failed","not_started","error","cancelled"],rm={"work-evidence":"workEvidence",scope:"scope","env-clean":"envClean",config:"config"},rx={mutex:"reason=mutex-wait",detachedContract:"was NOT judged",noContract:"no contract is attached to this run",notRequired:"success.requireScopeClean: false"};function rh(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function rf(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 rp(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 rg(e){var t,n;let{task:a}=e,s=(0,c.c)("worktree"),l=a.contract,i=null!=(t=l.goal)?t:"",o=i.length>240?"".concat(i.slice(0,240),"…"):i;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)(a1.E,{variant:a4[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:o}),(0,r.jsxs)("div",{className:"space-y-1 pt-1",children:[(0,r.jsx)(rp,{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)(rp,{label:s("verification.contract.scopeDeny"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.deny.join(", ")})}),(0,r.jsx)(rp,{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)(rp,{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)(rp,{label:s("verification.contract.file"),children:(0,r.jsx)("span",{className:"font-mono",children:a.contractPath})}),(0,r.jsx)(rp,{label:s("verification.contract.updated"),children:rh(a.updatedAt)})]})]})}function rb(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 rv(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 ry(e){var t,n,a,s,l,o;let{state:d}=e,u=(0,c.c)("worktree"),{config:m,configError:x,phase:h,runs:f,selectedRun:p,latestRun:g}=d,b=null!=(n=null==m?void 0:m.path)?n:a8,v=(0,i.useCallback)(()=>{d.draftConfig()},[d]),y=(0,i.useCallback)(()=>{d.rerun()},[d]),j=(0,i.useCallback)(()=>{g&&d.selectRun(g.id)},[g,d]),w=(0,i.useCallback)(()=>{d.cancelRun()},[d]),k=null!=(a=f.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!=(s=null==m?void 0:m.plannedGateIds.length)?s: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":h,children:[(0,r.jsx)(rv,{testId:"verification-onboarding-what",children:u("verification.onboarding.what",{path:b})}),(0,r.jsx)(rv,{testId:"verification-onboarding-how",children:u("verification.onboarding.how")}),null!==x&&(0,r.jsx)(rv,{tone:"warning",testId:"verification-config-error",children:u("verification.onboarding.configError",{message:x})}),(null==m?void 0:m.error)!=null&&(0,r.jsx)(rv,{tone:"warning",testId:"verification-config-invalid",children:u("verification.onboarding.invalid",{path:b,message:m.error})}),"unknown"===h&&(0,r.jsx)(rv,{testId:"verification-onboarding-unknown",children:u("verification.onboarding.loading")}),"no-config"===h&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-no-config",children:[(0,r.jsx)(rv,{children:u("verification.onboarding.noConfig.body",{path:b})}),(0,r.jsx)(rv,{children:u("verification.onboarding.noConfig.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(el.$,{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:a9,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)(aZ.A,{size:12,"aria-hidden":"true"})]})]}),d.draftFailure&&(0,r.jsx)(rv,{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"===h&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-configured",children:[(0,r.jsx)(rv,{children:u("verification.onboarding.configured.body",{path:b,count:null!=(l=null==m?void 0:m.gates.length)?l:0})}),(null==(t=d.draftResult)?void 0:t.created)&&(0,r.jsx)(rv,{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!=(o=null==m?void 0:m.gates)?o:[]).map(e=>(0,r.jsx)(rb,{gate:e},e.id))}),(0,r.jsx)(rv,{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)(rv,{testId:"verification-builtin-gates-hint",children:u("verification.onboarding.configured.builtinHint")}),(0,r.jsx)(el.$,{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"===h&&null!==k&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"verification-onboarding-running",children:[(0,r.jsx)(rv,{testId:"verification-running-progress",children:u("verification.onboarding.running.progress",{done:C,total:S})}),(0,r.jsx)(rv,{testId:"verification-running-elapsed",children:u("verification.onboarding.running.elapsed",{elapsed:function(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return"".concat(t,"s");let n=Math.floor(t/60);return"".concat(n,"m ").concat(String(t%60).padStart(2,"0"),"s")}(I)})}),(0,r.jsx)(rv,{children:u("verification.onboarding.running.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(el.$,{type:"button",size:"sm",variant:"secondary",onClick:d.refresh,"data-testid":"verification-running-refresh-button",children:u("verification.onboarding.running.action")}),(0,r.jsx)(el.$,{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)(rv,{testId:"verification-cancel-hint",children:u("verification.runs.cancelHint")}),d.cancelSettling&&(0,r.jsx)(rv,{testId:"verification-cancel-settling",children:u("verification.runs.cancelSettling")}),d.cancelFailure&&(0,r.jsx)(rv,{tone:"warning",testId:"verification-cancel-failure",children:"gone"===d.cancelFailure.kind?u("verification.runs.cancelGone"):u("verification.runs.cancelError",{message:d.cancelFailure.message})})]}),"result"===h&&null!==g&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-result",children:[(0,r.jsx)(rv,{testId:"verification-result-body",children:u("verification.onboarding.result.body",{runId:g.id,verdict:u("verification.runStatus.".concat(g.status))})}),(0,r.jsx)(el.$,{type:"button",size:"sm",variant:"secondary",onClick:j,"data-testid":"verification-show-latest-button",children:u("verification.onboarding.result.action")})]})]})}function rj(e){let{state:t}=e,n=(0,c.c)("worktree"),[a,s]=(0,i.useState)(!1),{availableGateIds:l,selectedGateIds:o,failedGateIds:d,rerunPending:u}=t,m=(0,i.useCallback)(()=>s(e=>!e),[]),x=(0,i.useCallback)(()=>t.setGateSelection(null),[t]),h=(0,i.useCallback)(()=>{t.selectFailedGates(),s(!0)},[t]),f=(0,i.useCallback)(()=>{t.rerun()},[t]);if(0===l.length)return null;let p=null!=o?o:l,g=null===o,b=l.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:l.length}):n("verification.selection.partial",{selected:p.length,total:l.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:l.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)(a2.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)(a1.E,{variant:"error",className:"flex-shrink-0",children:n("verification.gateStatus.failed")})]},e)})}),(0,r.jsx)(el.$,{type:"button",size:"sm",variant:"primary",onClick:f,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)(el.$,{type:"button",size:"sm",variant:"secondary",onClick:h,disabled:0===b.length,"data-testid":"verification-failed-only-button",children:n("verification.selection.failedOnly",{count:b.length})}),!g&&(0,r.jsx)(el.$,{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 rw(e){let{state:t}=e,n=(0,c.c)("worktree"),{repositoryHistoryOpen:a,repositoryHistory:s,repositoryHistoryLoading:l,repositoryHistoryError:o}=t,d=(0,i.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!==o?(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:o})}):l&&0===s.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("verification.runs.history.loading")}):0===s.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:s.map(e=>(0,r.jsx)(rk,{run:e},e.id))})]})]})}function rk(e){let{run:t}=e,n=(0,c.c)("worktree"),a=t.status,s=t.gates.filter(e=>a6.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)(a1.E,{variant:a5[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:rh(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 rN(e){let{gate:t,log:n,onClose:a}=e,s=(0,c.c)("worktree"),[l,o]=(0,i.useState)("idle"),d=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]);let u=""===n?0:n.replace(/\n+$/,"").split("\n").length,m=""!==n.trim(),x=(0,i.useCallback)(()=>{(async()=>{try{await (0,ek.l)(n),o("done")}catch(e){o("failed")}null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o("idle"),2e3)})()},[n]);return(0,r.jsx)(e3.a,{isOpen:!0,onClose:a,size:"xl",title:s("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)(el.$,{type:"button",size:"sm",variant:"secondary",onClick:x,disabled:!m,"data-testid":"verification-gate-log-copy-button",children:[(0,r.jsx)(ex.A,{size:12,"aria-hidden":"true",className:"mr-1"}),s("done"===l?"verification.gates.copied":"failed"===l?"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:s("verification.gates.fullLogSize",{lines:u})})]}),(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:s("verification.gates.fullLogStored")}),""===n?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:s("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 rC(e){let{run:t,selected:n,onSelect:a}=e,s=(0,c.c)("worktree"),l=s("verification.runStatus.".concat(t.status)),i=s("verification.runStatusGloss.".concat(t.status)),o=rd[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:i}),title:i,"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)(a1.E,{variant:a5[t.status],className:"flex-shrink-0",children:l}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:rh(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!==o&&(0,r.jsx)("span",{children:s("verification.runs.exitCode",{code:o})})]})]})})}function rS(){let e=(0,c.c)("worktree"),t=ru.map(t=>{var n;return e("verification.runs.cliLegendItem",{label:e("verification.runStatus.".concat(t)),code:null!=(n=rd[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 rI(e){let{run:t,plannedGateIds:n}=e,a=(0,c.c)("worktree"),s=rd[t.status],l=t.gates.filter(e=>"skipped"===e.status),i=new Set(t.gates.map(e=>e.gateId)),o=n.filter(e=>!i.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)(a1.E,{variant:a5[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))}),o.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:i.size,total:n.length,gates:o.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(rx.mutex)?"mutex":t.includes(rx.detachedContract)?"detachedContract":t.includes(rx.noContract)?"noContract":t.includes(rx.notRequired)?"notRequired":"unknown"}(e.logTail)))})},e.id))})]})]})}function rT(e){var t,n;let{gate:a}=e,s=(0,c.c)("worktree"),l=a6.includes(a.status),[o,d]=(0,i.useState)(null),[u,m]=(0,i.useState)(!1),x=(0,i.useCallback)(()=>m(!1),[]),h=null!=o?o:l,f=(0,ts.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}}(f,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=rm[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)(a1.E,{variant:a3[a.status],className:"flex-shrink-0",children:s("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:s("verification.gates.contractSourceHint"),children:s("verification.gates.contractSource")}),null!==b&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:s("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:s("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:[s("verification.gateStatus.skipped")," — ",s("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:s("verification.gates.exitCode",{code:a.exitCode})}),g&&(0,r.jsx)("span",{children:s("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(!h),"aria-expanded":h,"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:s(h?"verification.gates.hideLog":"verification.gates.showLog")}),""!==f&&(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:s("verification.gates.showFullLog")})]}),u&&(0,r.jsx)(rN,{gate:a,log:f,onClose:x}),h&&(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:s("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:s("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 rE=(0,i.memo)(function(e){var t,n;let{state:a,className:s=""}=e,l=(0,c.c)("worktree"),{worktreeId:o,task:d,runs:u,selectedRunId:m,selectedRun:x,loading:h,error:f,detailError:p,detailLoading:g,rerunPending:b,rerunFailure:v,cancelFailure:y,canLoadMore:j,selectRun:w,refresh:k,rerun:N,loadMore:C}=a,S=(0,i.useCallback)(()=>{N()},[N]);return(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-y-auto bg-surface ".concat(s).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)(a0.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:l("verification.title")})]}),(0,r.jsx)("button",{type:"button",onClick:k,"aria-label":l("verification.refresh"),title:l("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)(nt.A,{size:14,"aria-hidden":"true"})})]}),f&&(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:l("verification.loadError",{message:f})}),h?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"verification-loading",children:l("verification.loading")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ry,{state:a}),(0,r.jsx)(rf,{heading:l("verification.contract.heading"),testId:"verification-contract-section",children:d?(0,r.jsx)(rg,{task:d}):(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-contract-empty",children:l("verification.contract.empty")})}),(0,r.jsxs)(rf,{heading:l("verification.runs.heading"),testId:"verification-runs-section",action:(0,r.jsx)(el.$,{type:"button",size:"sm",variant:"secondary",onClick:S,disabled:b,"data-testid":"verification-rerun-button",children:l(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?l("verification.runs.rerunConflict",{runId:v.runningRunId}):l("verification.runs.rerunConflictUnknown"):l("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?l("verification.runs.cancelGone"):l("verification.runs.cancelError",{message:y.message})}),(0,r.jsx)(rj,{state:a}),(0,r.jsx)(rS,{}),0===u.length?(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-runs-empty",children:l("verification.runs.empty",{worktreeId:o})}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-runs",children:u.map(e=>(0,r.jsx)(rC,{run:e,selected:e.id===m,onSelect:w},e.id))}),j&&(0,r.jsx)(el.$,{type:"button",size:"sm",variant:"ghost",onClick:C,className:"mt-1","data-testid":"verification-load-more-button",children:l("verification.runs.loadMore",{count:10})}),(0,r.jsx)(rw,{state:a})]}),null!==m&&(0,r.jsx)(rf,{heading:l("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?l("verification.gates.notFound"):l("verification.gates.loadError",{message:p})}):null===x?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-loading",children:l(g?"verification.gates.loading":"verification.gates.empty")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rI,{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:l("verification.gates.empty")}):(0,r.jsx)("ul",{className:"space-y-1.5","data-testid":"verification-gates",children:x.gates.map(e=>(0,r.jsx)(rT,{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:l("verification.gates.contractSourceHint")})]})})]})]})});var rA=n(70532),rM=n(46046),rR=n(47972),rL=n(5590),rP=n(25840);class rD extends Error{constructor(e,t,n=[]){super(t),this.name="EnvApiError",this.code=e,this.issues=n}}async function rF(e,t){var n,a,r,s,l,i;let o=await e.json().catch(()=>null);return new rD(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 rO(e,t){let n="/api/worktrees/".concat(encodeURIComponent(e),"/env");return void 0===t?n:"".concat(n,"?file=").concat(encodeURIComponent(t))}async function rz(e,t){var n,a;let r=await fetch(rO(e,t),{cache:"no-store"});if(!r.ok)throw await rF(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 r_(e,t,n){var a;let r=await fetch(rO(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:t,content:n})});if(!r.ok)throw await rF(r,"Failed to save env file");let s=await r.json();return{file:s.file,issues:null!=(a=s.issues)?a:[]}}let rV=/^[A-Za-z_][A-Za-z0-9_]*$/;function rB(e){return e.split(/\r\n|\n|\r/)}function rU(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 rW(e){let t=rB(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(!rV.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,h=l;if(m.startsWith('"')||m.startsWith("'")){x=m[0];let n=m.slice(1),r=rU(n,x,0);for(;-1===r&&e+1<t.length;)e+=1,h=e+1,n+="\n".concat(t[e]),r=rU(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:h,exported:o,quote:x})}return{entries:n,issues:a}}let rH=/[\s#'"$`\\]/;function rK(e){if(!rH.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 r$(e,t,n){let a=rB(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(rK(l.value)))}for(let e of(i.length>0&&""===i[i.length-1]&&i.pop(),l))i.push("".concat(e.key,"=").concat(rK(e.value)));return 0===i.length?"":"".concat(i.join("\n"),"\n")}let rq=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/,rG=0;function rJ(){return rG+=1,"env-row-".concat(rG)}function rY(e){return e.map(e=>({id:rJ(),key:e.key,value:e.value,sourceLine:e.line}))}let rQ="••••••••";function rX(e){return 0===e.length?"":rQ}let rZ="flex-shrink-0 px-2 opacity-80 transition-opacity hover:opacity-100 [@media(hover:none)]:opacity-100",r0={"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"},r1=(0,i.memo)(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=function(e){var t;let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(".env"),[l,o]=(0,i.useState)(null),[c,d]=(0,i.useState)(!0),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)("kv"),[v,y]=(0,i.useState)([]),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)([]),[I,T]=(0,i.useState)(""),[E,A]=(0,i.useState)(new Set),[M,R]=(0,i.useState)(!1),[L,P]=(0,i.useState)(0),D=(0,i.useRef)(0);(0,i.useEffect)(()=>{let t=!1,n=D.current+1;return D.current=n,d(!0),h(null),p(!1),rz(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(rY(c)),w(i),A(new Set),R(!1)}).catch(e=>{var a,r;if(t||D.current!==n)return;let s=e instanceof rD?e:null;h({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,i.useMemo)(()=>"raw"===g?j:r$(k,C,v),[g,j,k,C,v]),O=(0,i.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)rq.test(n[e])&&t.push({line:e+1,code:"control-character",severity:"error"});let a=rW(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,i.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,i.useCallback)(e=>{if(e!==g){if("raw"===e)w(r$(k,C,v));else{let e=rW(j);N(j),S(e.entries),y(rY(e.entries))}b(e)}},[g,k,C,v,j]),V=(0,i.useCallback)(e=>{s(e),b("kv")},[]),B=(0,i.useCallback)(e=>{w(e),p(!1)},[]),U=(0,i.useCallback)((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n)),p(!1)},[]),W=(0,i.useCallback)(e=>{var t,n;let a={id:rJ(),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]))},[]),H=(0,i.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e)),p(!1)},[]),K=(0,i.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),$=(0,i.useCallback)(()=>R(e=>!e),[]),q=(0,i.useCallback)(()=>{A(new Set(v.map(e=>e.key)))},[v]),G=(0,i.useCallback)(()=>A(new Set),[]),J=(0,i.useCallback)(()=>P(e=>e+1),[]),Y=(0,i.useCallback)(()=>{O.valid&&!u&&(m(!0),h(null),r_(e,r,F).then(()=>{p(!0),P(e=>e+1)}).catch(e=>{var t,n;let a=e instanceof rD?e:null;h({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:l,loading:c,saving:u,error:x,saved:f,mode:g,rows:v,rawDraft:j,revealedKeys:E,rawRevealed:M,suggestions:null!=(t=null==l?void 0:l.suggestions)?t:[],issues:O.issues,canSave:O.valid,dirty:z,selectFile:V,setMode:_,setRawDraft:B,updateRow:U,addRow:W,removeRow:H,toggleReveal:K,toggleRawReveal:$,revealAll:q,hideAll:G,reload:J,save:Y}}(t),{mode:l,rows:o,revealedKeys:d,rawRevealed:m}=s,x=(0,i.useMemo)(()=>s.issues.filter(e=>"error"===e.severity),[s.issues]),h=(0,i.useMemo)(()=>s.issues.filter(e=>"warning"===e.severity),[s.issues]),f="raw"===l?m:o.length>0&&o.every(e=>d.has(e.key)),p=(0,i.useCallback)(()=>{if("raw"===l)return void s.toggleRawReveal();f?s.hideAll():s.revealAll()},[l,f,s]),g=(0,i.useMemo)(()=>"raw"!==l||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(rX(l.value)))}return s.join("\n")}(s.rawDraft,rW(s.rawDraft).entries),[l,m,s.rawDraft]),b=(0,i.useCallback)((e,t)=>{var n,s,l;return(0,r.jsx)("li",{children:a(r0[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:s.files.map(e=>(0,r.jsxs)(el.$,{size:"sm",variant:e.name===s.selectedFile?"primary":"ghost",onClick:()=>s.selectFile(e.name),"aria-pressed":e.name===s.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)(a1.E,{variant:"gray",children:a("envManager.notCreated")}),e.isExample&&(0,r.jsx)(a1.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)(el.$,{size:"sm",variant:"kv"===l?"primary":"ghost",onClick:()=>s.setMode("kv"),"aria-pressed":"kv"===l,"data-testid":"env-mode-kv",className:"min-h-[44px]",children:a("envManager.viewKeyValue")}),(0,r.jsx)(el.$,{size:"sm",variant:"raw"===l?"primary":"ghost",onClick:()=>s.setMode("raw"),"aria-pressed":"raw"===l,"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)(el.$,{size:"sm",variant:"ghost",onClick:p,"data-testid":"env-toggle-all","aria-pressed":f,className:"min-h-[44px] gap-1.5",children:[f?(0,r.jsx)(rA.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eS.A,{size:16,"aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:f?a("envManager.hideAll"):a("envManager.revealAll")})]}),(0,r.jsx)(el.$,{size:"sm",variant:"ghost",onClick:s.reload,"data-testid":"env-reload","aria-label":a("envManager.reload"),className:"min-h-[44px]",children:(0,r.jsx)(nt.A,{size:16,"aria-hidden":"true"})}),(0,r.jsxs)(el.$,{size:"sm",variant:"primary",onClick:s.save,loading:s.saving,disabled:!s.canSave||!s.dirty,"data-testid":"env-save",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(rM.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")}),s.loading&&(0,r.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"sm"}),a("envManager.loading")]}),s.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")}),!s.loading&&s.detail&&!s.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:s.selectedFile})}),s.saved&&!s.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)(n7.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)})]}),h.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:h.map(b)})}),!s.loading&&"kv"===l&&(0,r.jsxs)("div",{"data-testid":"env-kv-view",className:"space-y-2",children:[0===o.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")}),o.map(e=>{let t=d.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)(rL.p,{inputSize:"sm",value:e.key,onChange:t=>s.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)(rL.p,{inputSize:"sm",readOnly:!t,value:t?e.value:rX(e.value),onChange:t=>s.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)(el.$,{size:"sm",variant:"ghost",onClick:()=>s.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(rZ," min-h-[44px]"),children:t?(0,r.jsx)(rA.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eS.A,{size:16,"aria-hidden":"true"})}),(0,r.jsx)(el.$,{size:"sm",variant:"ghost",onClick:()=>s.removeRow(e.id),"aria-label":a("envManager.removeRow",{key:e.key}),"data-testid":"env-row-remove",className:"".concat(rZ," min-h-[44px] text-danger"),children:(0,r.jsx)(tW.A,{size:16,"aria-hidden":"true"})})]})]},e.id)}),(0,r.jsxs)(el.$,{size:"sm",variant:"secondary",onClick:()=>s.addRow(),"data-testid":"env-add-row",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(as.A,{size:16,"aria-hidden":"true"}),a("envManager.addRow")]}),s.suggestions.length>0&&(0,r.jsxs)(rR.Zp,{"data-testid":"env-suggestions",className:"mt-3",children:[(0,r.jsxs)(rR.aR,{children:[(0,r.jsx)(rR.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)(rR.Wu,{className:"flex flex-wrap gap-2",children:s.suggestions.map(e=>(0,r.jsxs)(el.$,{size:"sm",variant:"secondary",onClick:()=>s.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)(as.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)))})]})]}),!s.loading&&"raw"===l&&(0,r.jsx)("div",{"data-testid":"env-raw-view",className:"space-y-2",children:m?(0,r.jsx)(rP.T,{value:s.rawDraft,onChange:e=>s.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)(rP.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:rQ})})]})})]})]})}),r2=[{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"}],r4=(0,i.memo)(function(e){var t,n;let{worktreeId:a,className:s="",selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:h,availableAgents:f,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,c.c)("schedule"),[T,E]=(0,i.useState)(null!=(t=null==S?void 0:S.tab)?t:"notes"),A=(0,i.useRef)(null!=(n=null==S?void 0:S.token)?n:null);(0,i.useEffect)(()=>{S&&S.token!==A.current&&(A.current=S.token,E(S.tab))},[S]);let M=(0,i.useCallback)(e=>{E(e)},[]),R=(0,i.useRef)({});return(0,i.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(s),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:r2.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)(ng,{worktreeId:a,className:"h-full",onInsertToMessage:g}),"logs"===T&&(0,r.jsx)(nZ,{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)(av,{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)(n3,{worktreeId:a,selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:h,availableAgents:f,persistToServer:p})),"timer"===T&&(0,r.jsx)(aI,{worktreeId:a,instances:v,selectedAgents:l}),"todo"===T&&(0,r.jsx)(nw,{worktreeId:a,className:"h-full"}),"skills"===T&&(0,r.jsx)(aX,{worktreeId:a,className:"h-full"}),"verification"===T&&(0,r.jsx)(rE,{state:C,className:"h-full"}),"env"===T&&(0,r.jsx)(r1,{worktreeId:a,className:"h-full"})]})]})});var r5=n(2317);let r3=["status","changes","history","advanced"],r6="commandmate:gitPane:",r9={activeTab:"".concat(r6,"activeTab"),historyOpen:"".concat(r6,"historyOpen"),advancedOpen:"".concat(r6,"advancedOpen")};function r8(e){return"string"==typeof e&&r3.includes(e)}let r7=e=>"boolean"==typeof e,se=i.useLayoutEffect;function st(e,t,n){return Math.max(8,Math.min(e,n-t-8))}let sn=(0,i.memo)(function(e){var t,n;let{branches:a,busy:s,actionError:l,hasRunningSession:o,isMobile:d,onCheckout:u}=e,x=(0,c.c)("worktree"),h=(0,c.c)("common"),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(!1),j=(0,i.useRef)(null),w=(0,i.useRef)(null),[k,N]=(0,i.useState)(null),C=a.filter(e=>!e.isCurrent),S=(0,i.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:st(r<a.height+4+8&&s>r?n.top-a.height-4:n.bottom+4,a.height,window.innerHeight),left:st(n.left,a.width,window.innerWidth)})},[]);se(()=>f?(S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}):void N(null),[f,C.length,S]);let I=(0,i.useCallback)(e=>{y(!1),b({...e}),p(!1)},[]),T=(0,i.useCallback)(()=>{g&&(u(g,v),b(null))},[g,v,u]);return(0,r.jsxs)("div",{className:"relative",ref:j,"data-testid":"branch-checkout-dropdown",children:[(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:()=>p(e=>!e),disabled:s||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":f,"aria-label":x("git.checkout.ariaLabel"),children:[x("git.checkout.action"),(0,r.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),f&&"undefined"!=typeof document&&(0,tz.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:s||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),l&&(0,r.jsx)("div",{className:"mt-1 text-xs text-danger-foreground",role:"alert","data-testid":"branch-checkout-error",children:l}),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")}),o&&(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)(m.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(d?"flex-wrap":""),children:[(0,r.jsx)(m.$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:h("cancel")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:T,disabled:s,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")})]})]})})]})}),sa=(0,i.memo)(function(e){let{open:t,onToggle:n,children:a}=e,s=(0,c.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})]})}),sr=(0,i.createContext)(null);function ss(e){let{value:t,children:n}=e;return(0,r.jsx)(sr.Provider,{value:t,children:n})}function sl(){let e=(0,i.useContext)(sr);if(null===e)throw Error("useGitPaneContext must be used within a GitPaneProvider");return e}let si=(0,i.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})})}),so={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"},sc={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},sd=(0,i.memo)(function(e){let{activeTab:t,onTabChange:n}=e,a=(0,c.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:r3.map(e=>{let s=e===t,l=a(sc[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)(si,{path:so[e]}),(0,r.jsx)("span",{children:l})]},e)})})});function su(e){let{activeTab:t,onTabChange:n,className:a="",statusSection:s,quickActionsSection:l,changesSection:i,historySection:o,advancedSection:c}=e,{isMobile:d}=sl();return d?(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-mobile",children:[(0,r.jsx)(sd,{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 sm={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"},sx=(0,i.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"})})}),sh=(0,i.memo)(function(e){let{onClick:t,disabled:n=!1,testId:a,className:s=""}=e,l=(0,c.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)(nk.A,{size:14,"aria-hidden":"true"}),l("git.askAi")]})}),sf=(0,i.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})}),sp=(0,i.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})}),sg={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"}},sb=(0,i.memo)(function(e){var t;let{gitStatus:n,statusLoading:a,statusError:s,onRefresh:l,refreshing:o=!1}=e,{isMobile:d}=sl(),m=(0,c.c)("worktree"),x=(0,eW.Ym)(),h=(0,i.useMemo)(()=>{let e=null==n?void 0:n.lastFetchAt;if(null==e)return m("git.currentStatus.lastFetchNever");let t=(0,Y.fw)(new Date(e).toISOString(),(0,tq.M)(x));return t?m("git.currentStatus.lastFetch",{relative:t}):m("git.currentStatus.lastFetchNever")},[null==n?void 0:n.lastFetchAt,x,m]),f=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:l,disabled:o,className:"p-1 text-muted-foreground hover:text-foreground rounded disabled:opacity-50","aria-label":o?m("git.currentStatus.refreshing"):m("git.currentStatus.refresh"),"aria-busy":o,"data-testid":"git-status-refresh-button",children:o?(0,r.jsx)(u.y,{size:"sm",variant:"accent"}):(0,r.jsx)(sx,{})})]}),a&&!n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:m("git.currentStatus.loading")})]}),s&&!n&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-status-error",children:s}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center flex-wrap ".concat(d?"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]})]}),f&&(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":f,title:m(sg[f].tooltipKey),children:m(sg[f].badgeKey)})]}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:m("git.currentStatus.lastFetchTooltip"),children:h}),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})]})]})]})]})}),sv=(0,i.memo)(function(e){let{progressState:t,operation:n,error:a,conflict:s,conflictFiles:l,hasUpstream:o,onFetch:d,onPull:m,onPush:x,onAbort:h,extraActions:f}=e,{isMobile:p}=sl(),g=(0,c.c)("worktree"),b="running"===t,v=null!=a?a:g("git.network.failed"),[y,j]=(0,i.useState)(0);return(0,i.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:[d&&(0,r.jsx)("button",{type:"button",onClick:d,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:o?void 0:g("git.network.noUpstreamTooltip"),children:g("git.network.push")}),f]}),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)(u.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:h,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}),s&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-network-conflict",children:g("git.network.conflicts",{files:l.join(", ")})})]})}),sy=(0,i.memo)(function(e){let{title:t,testId:n,files:a,actionLabel:s,mode:l,defaultOpen:o,busy:d,onDiff:u,onToggleStage:x,onPreview:h}=e,f=(0,c.c)("worktree"),[p,g]=(0,i.useState)(o),[b,v]=(0,i.useState)(null),[y,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null),S=(0,i.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 h(e,l);j(null!=t?t:"")}catch(e){C(f("git.changes.previewFailed"))}finally{k(!1)}},[b,h,l,f]);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?"▼":"▶"}),f("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:f("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(sm[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":f("git.changes.togglePreview",{path:e.path}),"aria-expanded":t,"data-testid":"git-changes-preview-toggle",children:t?"▼":"▶"}),(0,r.jsx)("button",{type:"button",onClick:()=>u(e.path,l),className:"shrink-0 px-1.5 py-0.5 text-xs text-accent-600 dark:text-accent-400 hover:underline","aria-label":f("git.changes.showDiff",{path:e.path}),"data-testid":"git-changes-diff-button",children:f("git.changes.diff")}),(0,r.jsx)("button",{type:"button",onClick:()=>x(e.path),disabled:d,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":f("git.changes.fileAction",{action:s,path:e.path}),"data-testid":"git-changes-toggle-button",children:s})]}),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)(m.y$,{size:"xs",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:f("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:f("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)(sf,{line:e},t))})}),y.split("\n").length>20&&(0,r.jsx)("button",{type:"button",onClick:()=>u(e.path,l),className:"mt-1 text-xs text-accent-600 dark:text-accent-400 hover:underline","data-testid":"git-changes-preview-more",children:f("git.changes.truncated")})]}))]})]},"".concat(e.status,":").concat(e.path))})})]})}),sj=(0,i.memo)(function(e){var t,n,a;let{staged:s,loading:l,error:i,busy:o,commitMessage:d,amend:u,committing:x,commitError:h,onRefresh:f,onDiff:p,onPreview:g,onStage:b,onUnstage:v,onCommitMessageChange:y,onAmendChange:j,onCommit:w,onCommitAndPush:k}=e,{isMobile:N}=sl(),C=(0,c.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&&d.trim().length>0&&(S.length>0||u),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:f,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":C("git.changes.refresh"),children:(0,r.jsx)(sx,{})})]}),l&&!s&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:C("git.changes.loading")})]}),i&&!s&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-changes-error",children:i}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sy,{title:C("git.changes.staged"),testId:"git-staged-list",files:S,actionLabel:C("git.changes.unstage"),mode:"staged",defaultOpen:A,busy:o,onDiff:p,onPreview:g,onToggleStage:v}),(0,r.jsx)(sy,{title:C("git.changes.unstaged"),testId:"git-unstaged-list",files:I,actionLabel:C("git.changes.stage"),mode:"unstaged",defaultOpen:A,busy:o,onDiff:p,onPreview:g,onToggleStage:b}),(0,r.jsx)(sy,{title:C("git.changes.untracked"),testId:"git-untracked-list",files:T,actionLabel:C("git.changes.stage"),mode:"untracked",defaultOpen:A,busy:o,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:d,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)(m.Sc,{checked:u,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||o,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")})]})]}),h&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:h})]})]})]})}),sw=(0,i.memo)(function(e){let{commits:t,isLoading:n,commitError:a,commitListOpen:s,onToggleCommitList:l,onRefresh:o,selectedCommit:d,onCommitSelect:m,inlineDiffCommit:x,inlineFiles:h,inlineFilesLoading:f,inlineFilesError:p,onToggleInlineDiff:g,onInlineDiffFile:b,changedFiles:v,isLoadingFiles:y,detailError:j,selectedFile:w,onFileSelect:k,diffContent:N,isLoadingDiff:C}=e,{isMobile:S}=sl(),I=(0,c.c)("worktree"),[T,E]=(0,i.useState)(!0),[A,M]=(0,i.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:l,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:s?"▼":"▶"}),I("git.history.title")]}),(0,r.jsx)("button",{type:"button",onClick:o,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":I("git.history.refresh"),children:(0,r.jsx)(sx,{})})]}),s&&n&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",role:"status",children:[(0,r.jsx)(u.y,{size:"lg",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loading")})]}),s&&a&&!n&&(0,r.jsx)("div",{className:"px-3 py-4 text-sm text-danger-foreground",role:"alert",children:a}),s&&!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:[s&&(0,r.jsx)("div",{className:"overflow-y-auto ".concat(d?"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(d===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:[f&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-3",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loadingChangedFiles")})]}),p&&(0,r.jsx)(sp,{message:p}),!f&&!p&&0===h.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("git.history.noChangedFiles")}),!f&&h.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:h.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&&d===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(sm[t.status]),children:t.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:t.path})]})},t.path))})]})]},e.hash)})})}),d&&(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)(sp,{message:j}),y&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(u.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(sm[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)(u.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)(sf,{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 sk(e){return"`"+e+"`"}let sN={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},sC=(0,i.memo)(function(e){let{branches:t,include:n,loading:a,error:s,busy:l,actionError:o,onIncludeChange:d,onRefresh:u,onCreate:x,onDelete:h}=e,{isMobile:f,onInsertToMessage:p}=sl(),g=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!f),[j,w]=(0,i.useState)(!1),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(""),[I,T]=(0,i.useState)(null),[E,A]=(0,i.useState)(!1),M=(0,i.useCallback)(()=>{0!==k.trim().length&&(x(k.trim(),C.trim()||void 0),w(!1),N(""),S(""))},[k,C,x]),R=(0,i.useCallback)(()=>{I&&(h(I.name,E),T(null),A(!1))},[I,E,h]);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:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":g("git.branches.refresh"),children:(0,r.jsx)(sx,{})})]})]}),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:()=>d(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(sN[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)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:g("git.branches.loading")})]}),s&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-error",children:s}),o&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-action-error",children:o}),!a&&!s&&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=l||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)(sh,{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?sk(n.trim()):e("git.aiPrompts.branchCreateBaseHead");return e("git.aiPrompts.branchCreate",{base:a,name:sk(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:l||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)(m.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)(sh,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{p(g(E?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:sk(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:l,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")})]})]})})]})}),sS=(0,i.memo)(function(e){let{stashes:t,loading:n,error:a,busy:s,actionError:l,conflictNotice:o,hasRunningSession:d,onRefresh:u,onPush:x,onPop:h,onApply:f,onDrop:p}=e,{isMobile:g,onInsertToMessage:b}=sl(),v=(0,c.c)("worktree"),y=(0,c.c)("common"),[j,w]=(0,i.useState)(!g),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(!1),[I,T]=(0,i.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)(sh,{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:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":v("git.stash.refresh"),children:(0,r.jsx)(sx,{})})]})]}),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}),l&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-action-error",children:l}),o&&(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:o}),b&&(0,r.jsx)(sh,{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,o))})]}),(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)(m.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:s,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:s,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-apply-button",children:v("git.stash.apply")}),(0,r.jsx)("button",{type:"button",disabled:s,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-pop-button",children:v("git.stash.pop")}),(0,r.jsx)("button",{type:"button",disabled:s,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")]}),d&&(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:s,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")})]})]})]})}),sI={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},sT=(0,i.memo)(function(e){let{selectedCommit:t,busy:n,actionError:a,conflictNotice:s,currentBranch:l,aheadCount:o,hasRunningSession:d,onReset:u,onRevert:x,onForcePush:h}=e,{isMobile:f,onInsertToMessage:p}=sl(),g=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)("mixed"),[k,N]=(0,i.useState)(!0),[C,S]=(0,i.useState)(""),[I,T]=(0,i.useState)(!1),[E,A]=(0,i.useState)(!1),[M,R]=(0,i.useState)(!1),[L,P]=(0,i.useState)(!1),[D,F]=(0,i.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}),s&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:s}),(0,r.jsxs)("div",{className:"flex ".concat(f?"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")}),h&&(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)(m.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)(m.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)(m.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)(m.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)(m.CU,{value:e,"data-testid":"reset-mode-".concat(e)}),g(sI[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")}),d&&(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!=l?l:""}),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)(sh,{className:"mr-auto",testId:"reset-ask-ai",disabled:z,onClick:()=>{O&&(p("hard"===j?g("git.aiPrompts.resetHard",{target:sk(O)}):g("git.aiPrompts.reset",{target:sk(O),mode:j})),T(!1),S(""))}}),(0,r.jsx)("button",{type:"button",disabled:n||z||"hard"===j&&C!==(null!=l?l:""),onClick:()=>{O&&(u(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)})]}),d&&(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)(m.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)(sh,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(g("git.aiPrompts.revert",{commit:sk(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&&h&&(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")}),d&&(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)(m.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)(sh,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(e,t){let{branch:n,ahead:a}=t,r=n?sk(n):e("git.aiPrompts.forcePushCurrentBranch");return e("number"==typeof a&&a>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:r,upstream:sk("origin/".concat(null!=n?n:"<branch>")),ahead:null!=a?a:0})}(g,{branch:l,ahead:null!=o?o:null})),P(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{h(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")})]})]})]})}),sE=(0,i.memo)(function(e){var t,n,a,s;let{worktreeId:l,onDiffSelect:o,isMobile:d=!1,worktree:u,onInsertToMessage:x,className:h=""}=e,f=(0,c.c)("worktree"),{activeTab:p,setActiveTab:g,historyOpen:b,toggleHistory:v,advancedOpen:y,toggleAdvanced:j}=function(){let{value:e,setValue:t,isAvailable:n}=(0,r5.V)({key:r9.activeTab,defaultValue:"status",validate:r8}),{value:a,setValue:r}=(0,r5.V)({key:r9.historyOpen,defaultValue:!0,validate:r7}),{value:s,setValue:l}=(0,r5.V)({key:r9.advancedOpen,defaultValue:!1,validate:r7}),o=(0,i.useCallback)(e=>t(e),[t]);return{activeTab:e,setActiveTab:o,historyOpen:a,toggleHistory:(0,i.useCallback)(()=>r(e=>!e),[r]),advancedOpen:s,toggleAdvanced:(0,i.useCallback)(()=>l(e=>!e),[l]),isPersistent:n}}(),w=Object.values(null!=(n=null==u?void 0:u.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,i.useState)(null),[a,r]=(0,i.useState)(!0),[s,l]=(0,i.useState)(null),o=(0,i.useCallback)(async()=>{l(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/status"));if(!t.ok){let e=await t.json().catch(()=>({}));l(e.error||"Failed to fetch git status");return}let a=await t.json();n(a)}catch(e){l("Failed to fetch git status")}finally{r(!1)}},[e]);return(0,i.useEffect)(()=>{o()},[o]),{gitStatus:t,statusLoading:a,statusError:s,fetchStatus:o}}(l),{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:V,setDiffContent:B,fetchCommits:U,handleCommitSelect:W,handleFileSelect:H,handleToggleInlineDiff:K,handleInlineDiffFile:$,handleRefresh:q}=function(e,t){let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)([]),[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)([]),[x,h]=(0,i.useState)(!1),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(!0),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[I,T]=(0,i.useState)(null),[E,A]=(0,i.useState)(null),M=(0,i.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,i.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,i.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,i.useEffect)(()=>{M()},[M]);let P=(0,i.useCallback)(e=>{s(e),R(e)},[R]),D=(0,i.useCallback)(e=>{r&&(b(e),L(r,e))},[r,L]),F=(0,i.useCallback)(async t=>{if(c===t){d(null),m([]),p(null);return}d(t),m([]),p(null),h(!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{h(!1)}},[e,c]),O=(0,i.useCallback)((e,t)=>{s(e),b(t),o(u),L(e,t)},[u,L]),z=(0,i.useCallback)(()=>{s(null),o([]),b(null),y(null),A(null),M()},[M]);return{commits:n,selectedCommit:r,changedFiles:l,inlineDiffCommit:c,inlineFiles:u,inlineFilesLoading:x,inlineFilesError:f,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}}(l,o),G=(0,i.useCallback)(async()=>{await U(),await S()},[U,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,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!0),[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(""),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null),j=(0,i.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();s(n)}catch(e){d("Failed to fetch changes")}finally{o(!1)}},[e]);(0,i.useEffect)(()=>{j()},[j]);let w=(0,i.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,i.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,i.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:f})});if(!t.ok){let e=await t.json().catch(()=>({}));return y(e.error||"Failed to commit"),!1}return h(""),p(!1),await j(),await a(),!0}catch(e){return y("Failed to commit"),!1}},[e,x,f,j,a]),C=(0,i.useCallback)(async()=>{b(!0);try{await N()}finally{b(!1)}},[N]),S=(0,i.useCallback)(async e=>{b(!0);try{await N()&&await e()}finally{b(!1)}},[N]);return{staged:r,stagedLoading:l,stagedError:c,opBusy:u,commitMessage:x,setCommitMessage:h,amend:f,setAmend:p,committing:g,changesCommitError:v,fetchStaged:j,handleStage:w,handleUnstage:k,handleChangesDiff:(0,i.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,i.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}}(l,{onWorkingDiff:(0,i.useCallback)((e,t)=>{B(e),o(e,t)},[B,o]),onCommitted:G}),{branches:em,branchInclude:ex,branchesLoading:eh,branchesError:ef,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,i.useState)([]),[s,l]=(0,i.useState)("local"),[o,c]=(0,i.useState)(!0),[d,u]=(0,i.useState)(null),[m,x]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),p=(0,i.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,i.useEffect)(()=>{p(s)},[p,s]);let g=(0,i.useCallback)(e=>{l(e)},[]),b=(0,i.useCallback)(()=>{p(s)},[p,s]),v=(0,i.useCallback)(async(t,a)=>{x(!0),f(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(()=>({}));f(e.error||"Failed to checkout branch");return}await Promise.all([n(),p(s)])}catch(e){f("Failed to checkout branch")}finally{x(!1)}},[e,s,n,p]),y=(0,i.useCallback)(async(t,n)=>{x(!0),f(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(()=>({}));f(e.error||"Failed to create branch");return}await p(s)}catch(e){f("Failed to create branch")}finally{x(!1)}},[e,s,p]),j=(0,i.useCallback)(async(t,n)=>{x(!0),f(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(()=>({}));f(e.error||"Failed to delete branch");return}await p(s)}catch(e){f("Failed to delete branch")}finally{x(!1)}},[e,s,p]);return{branches:a,branchInclude:s,branchesLoading:o,branchesError:d,branchBusy:m,branchActionError:h,fetchBranches:p,handleBranchIncludeChange:g,handleBranchesRefresh:b,handleCheckout:v,handleBranchCreate:y,handleBranchDelete:j}}(l,{onCheckoutCascade:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),U()])},[S,es,U])}),{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,i.useState)([]),[s,l]=(0,i.useState)(!0),[o,c]=(0,i.useState)(null),[d,u]=(0,i.useState)(!1),[m,x]=(0,i.useState)(null),[h,f]=(0,i.useState)(null),p=(0,i.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{l(!1)}},[e]);(0,i.useEffect)(()=>{p()},[p]);let g=(0,i.useCallback)(async()=>{await Promise.all([p(),n()])},[p,n]),b=(0,i.useCallback)(async(e,t,n)=>{u(!0),x(null),f(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)":"";f("Stash operation produced conflicts: ".concat(e).concat(t))}await g()}catch(e){x(n)}finally{u(!1)}},[g]),v=(0,i.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,i.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:s,stashError:o,stashBusy:d,stashActionError:m,stashConflictNotice:h,fetchStash:p,handleStashPush:v,handleStashPop:y,handleStashApply:(0,i.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,i.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/").concat(t),{method:"DELETE"},"Failed to drop stash")},[e,b])}}(l,{onStashMutated:(0,i.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,i.useState)(!1),[s,l]=(0,i.useState)(null),[o,c]=(0,i.useState)(null);return{dangerBusy:a,dangerActionError:s,dangerConflictNotice:o,handleReset:(0,i.useCallback)(async(t,a,s)=>{r(!0),l(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(()=>({}));l(e.error||"Failed to reset");return}await n()}catch(e){l("Failed to reset")}finally{r(!1)}},[e,n]),handleRevert:(0,i.useCallback)(async(t,a)=>{r(!0),l(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(()=>({}));l(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){l("Failed to revert")}finally{r(!1)}},[e,n])}}(l,{onHeadMoved:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),eb(ex),U()])},[S,es,eb,ex,U])}),{operation:eV,progressState:eB,error:eU,errorReason:eW,conflict:eH,conflictFiles:eK,runFetch:e$,runPull:eq,runPush:eG,abort:eJ}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onCascade:n}=t,[a,r]=(0,i.useState)(null),[s,l]=(0,i.useState)("idle"),[o,c]=(0,i.useState)(null),[d,u]=(0,i.useState)(null),[m,x]=(0,i.useState)(!1),[h,f]=(0,i.useState)([]),p=(0,i.useRef)(null),g=(0,i.useRef)(n);(0,i.useEffect)(()=>{g.current=n},[n]),(0,i.useEffect)(()=>()=>{var e;null==(e=p.current)||e.abort()},[]);let b=(0,i.useCallback)(async(t,n,a)=>{var s,i,o;c(null),u(null),x(!1),f([]),r(t),l("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((i=null==e?void 0:e.error,"string"==typeof i&&i.length>0?i:null)),l("error");return}let o=await r.json().catch(()=>({success:!0}));"pull"===t&&(null==o?void 0:o.conflict)&&(x(!0),f(Array.isArray(o.conflictFiles)?o.conflictFiles:[])),l("idle")}catch(e){e instanceof Error&&"AbortError"===e.name?l("idle"):(c(null),u(null),l("error"))}finally{r(null),p.current=null,null==(o=g.current)||o.call(g,t)}},[e]),v=(0,i.useCallback)(e=>{let t={prune:!0===e.prune};return void 0!==e.remote&&(t.remote=e.remote),b("fetch","fetch",t)},[b]),y=(0,i.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:s,error:o,errorReason:d,conflict:m,conflictFiles:h,runFetch:v,runPull:y,runPush:(0,i.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,i.useCallback)(()=>{var e;null==(e=p.current)||e.abort()},[])}}(l,{onCascade:(0,i.useCallback)(e=>{S(),eb(ex),"pull"===e&&(es(),U())},[S,eb,ex,es,U])}),eY="auth_failed"===eW?f("git.network.authFailedGuidance"):"protected_branch"===eW?f("git.danger.protectedBranchWarning"):eU,eQ="running"===eB&&("push"===eV||"pull"===eV),eX=(null==k?void 0:k.aheadBehind)!=null,eZ=(0,i.useCallback)(()=>{e$({})},[e$]),e0=(0,i.useCallback)(()=>eu(()=>eG({setUpstream:!eX})),[eu,eG,eX]);t8({intervalMs:5e3,enabled:"running"!==eB,onPoll:S});let e1=(0,i.useMemo)(()=>({isMobile:d,onDiffSelect:o,onInsertToMessage:x}),[d,o,x]),e2=(0,r.jsx)(sb,{gitStatus:k,statusLoading:N,statusError:C,onRefresh:eZ,refreshing:"running"===eB}),e4=(0,r.jsx)(sv,{progressState:eB,operation:eV,error:eY,conflict:eH,conflictFiles:eK,hasUpstream:eX,onPull:()=>eq({}),onPush:()=>eG({setUpstream:!eX}),onAbort:eJ,extraActions:(0,r.jsx)(sn,{branches:em,busy:ep||eQ,actionError:eg,hasRunningSession:w,isMobile:d,onCheckout:ej})}),e5=(0,r.jsx)(sj,{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)(sw,{commits:I,isLoading:F,commitError:_,commitListOpen:b,onToggleCommitList:v,onRefresh:q,selectedCommit:T,onCommitSelect:W,inlineDiffCommit:A,inlineFiles:M,inlineFilesLoading:R,inlineFilesError:L,onToggleInlineDiff:K,onInlineDiffFile:$,changedFiles:E,isLoadingFiles:O,detailError:V,selectedFile:P,onFileSelect:H,diffContent:D,isLoadingDiff:z}),e6=(0,r.jsxs)(sa,{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:f("git.remote")}),(0,r.jsx)("div",{children:(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>e$({}),disabled:"running"===eB,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:f("git.network.fetch")})})]}),(0,r.jsx)(sC,{branches:em,include:ex,loading:eh,error:ef,busy:ep||eQ,actionError:eg,onIncludeChange:ev,onRefresh:ey,onCreate:ew,onDelete:ek}),(0,r.jsx)(sS,{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)(sT,{selectedCommit:T,busy:eD||eQ,actionError:eF,conflictNotice:eO,currentBranch:null!=(a=null==k?void 0:k.currentBranch)?a:null,aheadCount:null!=(s=null==k||null==(t=k.aheadBehind)?void 0:t.ahead)?s:null,hasRunningSession:w,onReset:ez,onRevert:e_,onForcePush:e=>eG(e?{forceWithLease:!0}:{force:!0})})]});return(0,r.jsx)(ss,{value:e1,children:(0,r.jsx)(su,{activeTab:p,onTabChange:g,className:h,statusSection:e2,quickActionsSection:e4,changesSection:e5,historySection:e3,advancedSection:e6})})}),sA=(0,i.memo)(function(e){let{worktreeId:t,worktree:n,onWorktreeUpdate:a}=e,[s,l]=(0,i.useState)(!1),o=(0,c.c)("worktree"),d=(0,i.useRef)(null==n?void 0:n.id),u=(0,i.useRef)(!1),m=sV(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)(sB,{worktreeId:t,worktree:n,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:m,showLogs:s,onToggleLogs:()=>l(!s),onWorktreeUpdate:a})}):(0,r.jsx)("div",{className:"text-muted-foreground text-center py-8",children:o("detail.loadingInfo")})}),sM=(0,i.memo)(function(e){let{activeTab:t,worktreeId:n,worktree:a,messages:s,cliToolId:l,instanceId:i,onFilePathClick:o,onFileSelect:d,onWorktreeUpdate:u,onNewFile:m,onNewDirectory:x,onRename:h,onDelete:f,onUpload:p,onMove:g,onFileTreeReset:b,refreshTrigger:v,fileSearch:y,showToast:j,selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:I,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,disableAutoFollow:R,historySubTab:L,onHistorySubTabChange:P,onDiffSelect:D,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:V,historyUserOnly:B,onHistoryUserOnlyChange:U,useInstanceManagement:W,instances:H,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,verification:G,toolsSubTabRequest:J,onSurfaceModeChange:Y}=e,Q=(0,c.c)("worktree");switch(t){case"terminal":return(0,r.jsx)(T.t,{componentName:"TerminalDisplay",children:(0,r.jsx)(tP,{worktreeId:n,cliToolId:l,instanceId:i,disableAutoFollow:R,onSurfaceModeChange:Y})});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:Q("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:Q("detail.subTabGit")})]}),"message"===L?(0,r.jsx)(T.t,{componentName:"HistoryPane",children:(0,r.jsx)(tD.bl,{messages:s,worktreeId:n,onFilePathClick:o,className:"flex-1 min-h-0",showToast:j,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:V,historyUserOnly:B,onHistoryUserOnlyChange:U})}):(0,r.jsx)(T.t,{componentName:"GitPane",children:(0,r.jsx)(sE,{worktreeId:n,onDiffSelect:D,isMobile:!0,worktree:null!=a?a:void 0,onInsertToMessage:F,className:"flex-1 min-h-0"})})]});case"files":var X;return(0,r.jsx)(T.t,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,r.jsx)(nc,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),(0,r.jsx)(nr,{worktreeId:n,onFileSelect:d,onNewFile:m,onNewDirectory:x,onRename:h,onDelete:f,onUpload:p,onMove:g,onResetView:b,refreshTrigger:v,pollingEnabled:"files"===t,searchQuery:y.query,searchMode:y.mode,searchResults:null==(X=y.results)?void 0:X.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(T.t,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(r4,{worktreeId:n,className:"h-full",selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:I,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,onInsertToMessage:F,useInstanceManagement:W,instances:H,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,modelByInstance:s_(null==a?void 0:a.sessionStatusByInstance),composerTargetInstanceId:i,verification:G,requestedSubTab:J})});case"info":return(0,r.jsx)(sA,{worktreeId:n,worktree:a,onWorktreeUpdate:u});default:return null}}),sR="v".concat("0.36.0"),sL=[{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 sP(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 sD(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 sF(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 sO(e,t,n,a){var r;let s=sF(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 sz(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=sF(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}function s_(e){if(!e)return{};let t={};for(let[n,a]of Object.entries(e)){let e=sP(null==a?void 0:a.model,null==a?void 0:a.reasoningEffort);e&&(t[n]=e)}return t}function sV(e,t,n,a){let[r,s]=(0,i.useState)(!1),[l,o]=(0,i.useState)(""),[c,d]=(0,i.useState)(!1);(0,i.useEffect)(()=>{a()&&e&&(o(e.description||""),s(!1))},[n,e]);let u=(0,i.useCallback)(async()=>{if(e){d(!0);try{let n=await eq.y.updateDescription(e.id,l);t(n),s(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,l,t]),m=(0,i.useCallback)(()=>{o((null==e?void 0:e.description)||""),s(!1)},[e]);return{isEditing:r,text:l,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,i.useCallback)(()=>{s(!0)},[])}}let sB=(0,i.memo)(function(e){var t,n;let{worktreeId:a,worktree:s,cardClassName:l,descriptionEditor:o,showLogs:d,onToggleLogs:u,onWorktreeUpdate:x}=e,{isEditing:h,text:f,setText:p,isSaving:g,handleSave:b,handleCancel:v,startEditing:y}=o,j=(0,c.c)("worktree"),w=(0,c.c)("common"),{copied:k,markCopied:N}=(0,eR.q)(),{copied:C,markCopied:S}=(0,eR.q)(),I=(0,i.useCallback)(async()=>{try{await (0,ek.l)(s.path),N()}catch(e){}},[s.path,N]),T=(0,i.useCallback)(async()=>{try{await (0,ek.l)(s.repositoryPath),S()}catch(e){}},[s.repositoryPath,S]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:l,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:s.name})]}),(0,r.jsxs)("div",{className:l,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)(m.$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)(em.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-base text-foreground",children:null!=(t=s.repositoryDisplayName)?t:s.repositoryName}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:s.repositoryPath})]}),(0,r.jsxs)("div",{className:l,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)(m.$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)(em.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:s.path})]}),(0,r.jsxs)("div",{className:l,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=s.status)?n:"",onChange:async e=>{let t=e.target.value;try{let e=await fetch("/api/worktrees/".concat(s.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:sL.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:l,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")}),!h&&(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")})]}),h?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:f,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)(m.$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)(m.$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:s.description?(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.description}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground italic",children:j("detail.noDescription")})})]}),s.link&&(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.link")}),(0,r.jsx)("a",{href:s.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:s.link})]}),s.updatedAt&&(0,r.jsxs)("div",{className:l,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(s.updatedAt).toLocaleString()})]}),(0,r.jsx)(eQ,{version:sR,className:l}),(0,r.jsx)(e5,{className:l}),(0,r.jsxs)("div",{className:l,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:u,className:"text-sm text-accent-600 hover:text-accent-800",children:d?j("detail.hide"):j("detail.show")})]}),d&&(0,r.jsx)(eG,{worktreeId:a})]})]})}),sU=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeName:o,repositoryName:d,description:u,status:h,gitStatus:p,onBackClick:g,onInfoClick:b,hasUpdate:v,worktreeStatus:y,onWorktreeStatusChange:j,sessionStatusByCli:w,sessionStatusByInstance:k,instances:C,activeInstanceId:S,onActiveInstanceChange:I,onAgentDragStart:T,onAgentDragEnd:E,onKillSession:A,verificationChip:M,agentSessionByInstance:R}=e,L=(0,c.c)("worktree"),P=(0,eW.Ym)(),D=(0,c.c)("common"),F=eH.sb[h],O=F?L(F):void 0,[z,_]=(0,i.useState)(null),V=null==C?void 0:C.find(e=>e.id===S),B=!!S&&null!=(s=null!=(a=null==k||null==(t=k[S])?void 0:t.isRunning)?a:V?null==w||null==(n=w[V.cliTool])?void 0:n.isRunning:void 0)&&s,U=(0,i.useCallback)((e,t)=>{e.dataTransfer.setData(Q,t),e.dataTransfer.effectAllowed="move",_(t),null==T||T(t)},[T]),W=(0,i.useCallback)(()=>{_(null),null==E||E()},[E]),H=u?(0,f.W5)(u,50):null,$=(null!=C?C:[]).map(e=>{var t;return{item:e,status:(0,e6.kA)(null!=(t=null==k?void 0:k[e.id])?t:null==w?void 0:w[e.cliTool]),isActive:e.id===S}}),J=(null!=C?C:[]).some(e=>{var t,n;return(null==(t=null!=(n=null==k?void 0:k[e.id])?n:null==w?void 0:w[e.cliTool])?void 0:t.awaitingInstruction)===!0}),Y=!!A&&B,X=[P,o,d,null!=H?H:"",null!=(l=null==p?void 0:p.currentBranch)?l:"",(null==p?void 0:p.isDirty)?"dirty":"",Y?"end":"",J?"awaiting":"",...$.map(e=>"".concat(e.item.id,":").concat((0,K.sw)(e.item),":").concat(e.status,":").concat(e.isActive?"active":""))].join("\n"),Z=(0,i.useRef)(null),ee=(0,i.useRef)(null),et=function(e,t,n,a,r){let[s,l]=(0,i.useState)(()=>({key:n,pillBudget:4,squeezed:!1})),o=s;return s.key!==n&&l(o={key:n,pillBudget:4,squeezed:!1}),(0,i.useLayoutEffect)(()=>{let e=t.current;e&&!s.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)&&l(e=>{if(e.squeezed)return e;let t=Math.min(e.pillBudget,a);return t>0?{...e,pillBudget:t-1}:{...e,squeezed:!0}})},[t,s,a,r]),(0,i.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,l(e=>s?{key:e.key,pillBudget:4,squeezed:!1}:{...e}))});return r.observe(t),()=>r.disconnect()},[e]),{pillBudget:o.pillBudget,squeezed:o.squeezed}}(Z,ee,X,$.filter(eK.Lm).length,M);return(0,r.jsxs)("div",{ref:Z,"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:ee,"data-testid":"desktop-header-identity",className:"flex items-center gap-3 min-w-0".concat(et.squeezed?" overflow-x-clip":""),children:[(0,r.jsxs)("button",{type:"button",onClick:g,className:"flex flex-shrink-0 items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":L("detail.goBack"),"data-testid":"worktree-back-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:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:L("detail.home")})]}),(0,r.jsx)("div",{className:"w-px h-6 flex-shrink-0 bg-border","aria-hidden":"true"}),(0,r.jsx)(x.m,{"data-testid":"desktop-status-indicator",status:h,size:"lg",label:O}),(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:o}),(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:d}),p&&"(unknown)"!==p.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:p.currentBranch,"data-testid":"desktop-branch-name",children:(0,f.W5)(p.currentBranch,30)}),p.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:L("git.uncommittedChanges"),children:"*"})]}),H&&(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:u,children:H})]})]})]}),M&&(0,r.jsx)("div",{className:"min-w-0 w-[360px] max-w-max",children:M})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 max-w-full","data-testid":"desktop-header-controls",children:[C&&C.length>0&&(()=>{var e,t,n,a;let s=(0,eK.Uw)($,et.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(et.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,K.sw)(n),s=L("detail.statusPill",{label:a,status:D("status.".concat(e.status))}),l=null==k?void 0:k[n.id],i=null==R?void 0:R[n.id],o=sP(null==l?void 0:l.model,null==l?void 0:l.reasoningEffort,null==i||null==(t=i.session)?void 0:t.agent),c=o?L("detail.statusPillWithModel",{label:a,status:D("status.".concat(e.status)),model:o}):s,d=sO(null==i?void 0:i.session,null==i?void 0:i.context,L,P),u=d?L("detail.statusPillWithUsage",{base:c,usage:d}):c,m=sD(null==l?void 0:l.eventSource,L),h=m?L("detail.statusPillWithSource",{base:u,source:m}):u,f=e.isActive,p={draggable:!0,onDragStart:e=>U(e,n.id),onDragEnd:W},g=z===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==I?void 0:I(n.id),...p,"aria-label":h,title:h,"aria-pressed":f,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(f?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground").concat(g),children:[(0,r.jsx)(x.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:s})]},n.id):(0,r.jsx)(G.m_,{content:h,placement:"bottom",children:(0,r.jsx)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==I?void 0:I(n.id),...p,"aria-label":h,"aria-pressed":f,className:"flex items-center justify-center w-6 h-6 rounded-full transition-colors ".concat(f?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted").concat(g),children:(0,r.jsx)(x.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0})})},n.id)}),l.length>0&&(0,r.jsxs)(q.rI,{children:[(0,r.jsx)(q.ty,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":L("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)(x.m,{status:i,size:"sm","aria-hidden":!0,title:void 0}),"+",l.length]})}),(0,r.jsx)(q.SQ,{align:"end",children:l.map(e=>{let t=e.item,n=L("detail.statusPill",{label:(0,K.sw)(t),status:D("status.".concat(e.status))});return(0,r.jsxs)(q._2,{"data-testid":"desktop-agent-overflow-".concat(t.id),onSelect:()=>null==I?void 0:I(t.id),children:[(0,r.jsx)(x.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:n})]},t.id)})})]}),J&&(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:L("awaitingInstruction.label"),children:L("awaitingInstruction.badge")})]})})(),Y&&(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:A,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":L("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),D("end")]}),j&&(0,r.jsx)("select",{value:null!=y?y:"",onChange:e=>{let t=e.target.value;j(""===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":L("detail.worktreeStatusLabel"),children:sL.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:L(e.labelKey)},e.labelKey)})}),(0,r.jsx)(e9.g,{}),(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:b,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":L("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:L("detail.info")}),v&&(0,r.jsx)(N,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":L("tabs.updateAvailable")})]})]})]})}),sW=(0,i.memo)(function(e){let{worktreeId:t,worktree:n,isOpen:a,onClose:s,onWorktreeUpdate:l}=e,[o,d]=(0,i.useState)(!1),u=(0,c.c)("worktree"),m=(0,i.useRef)(a),x=sV(n,l,a,()=>{let e=a&&!m.current;return m.current=a,e});return n?(0,r.jsx)(e3.a,{isOpen:a,onClose:s,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)(sB,{worktreeId:t,worktree:n,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:x,showLogs:o,onToggleLogs:()=>d(!o),onWorktreeUpdate:l})})}):null}),sH=(0,i.memo)(function(){let e=(0,c.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)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:e("detail.loading")})]})})}),sK=(0,i.memo)(function(e){let{message:t,onRetry:n}=e,a=(0,c.c)("worktree"),s=(0,c.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)(m.$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 s$=n(72115);let sq=(0,i.memo)(function(e){let{activityPane:t,rightPane:n,activityPaneWidth:a=18,minPaneWidth:s=10,maxPaneWidth:l=60,onActivityPaneResize:o,className:d=""}=e,u=(0,i.useRef)(null),m=(0,c.c)("worktree"),[x,h]=(0,i.useState)(a),f=o?a:x,p=(0,i.useCallback)(e=>{let t=u.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let r=Math.min(l,Math.max(s,(o?a:x)+e/n*100));o?o(r):h(r)},[a,x,s,l,o]),g=(0,i.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(f,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(T.t,{componentName:"ActivityPane",children:t})}),(0,r.jsx)(s$.f,{onResize:p,orientation:"horizontal",ariaValueNow:f})]}),(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)(T.t,{componentName:"TerminalPane",children:n})})]})})});var sG=n(23570),sJ=n(9540),sY=n(92001),sQ=n(39332),sX=n(16485),sZ=n(78192),s0=n(39324),s1=n(80298),s2=n(55867);let s4=[{id:"files",labelKey:"activityBar.files",icon:sY.A},{id:"git",labelKey:"activityBar.git",icon:sQ.A},{id:"notes",labelKey:"activityBar.notes",icon:_.A},{id:"schedules",labelKey:"activityBar.schedules",icon:sX.A},{id:"agent",labelKey:"activityBar.agent",icon:sZ.A},{id:"timer",labelKey:"activityBar.timer",icon:s0.A},{id:"todo",labelKey:"activityBar.todo",icon:s1.A},{id:"skills",labelKey:"activityBar.skills",icon:nk.A},{id:"verification",labelKey:"activityBar.verification",icon:a0.A},{id:"env",labelKey:"activityBar.env",icon:s2.A}],s5=new Set(s4.map(e=>e.id)),s3="files",s6="__closed__";function s9(e){return"".concat("commandmate.worktree.activeActivity-").concat(e)}var s8=n(32916);let s7=(0,i.memo)(function(e){let{active:t,onToggle:n,className:a=""}=e,s=(0,c.c)("worktree"),l=(0,i.useRef)([]),{isOpen:o,toggle:d}=(0,s8.VF)(),u=(0,i.useCallback)((e,t,a)=>{var r,s,i,o;if("Enter"===e.key||" "===e.key){e.preventDefault(),n(a);return}if("ArrowDown"===e.key){e.preventDefault();let n=(t+1)%s4.length;null==(r=l.current[n])||r.focus();return}if("ArrowUp"===e.key){e.preventDefault();let n=(t-1+s4.length)%s4.length;null==(s=l.current[n])||s.focus();return}if("Home"===e.key){e.preventDefault(),null==(i=l.current[0])||i.focus();return}if("End"===e.key){e.preventDefault(),null==(o=l.current[s4.length-1])||o.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)(G.m_,{content:s("activityBar.toggleSidebar"),placement:"right",children:(0,r.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:d,"aria-label":s("activityBar.toggleSidebar"),"aria-expanded":o,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)(sJ.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":s("activityBar.label"),className:"flex flex-col items-stretch",children:s4.map((e,a)=>{let i=e.icon,o=t===e.id,c=s(e.labelKey);return(0,r.jsx)(G.m_,{content:c,placement:"right",children:(0,r.jsx)("button",{ref:e=>{l.current[a]=e},type:"button",role:"tab","aria-selected":o,"aria-label":c,"aria-controls":"worktree-activity-pane",tabIndex:o||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(o?"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)(i,{size:20,"aria-hidden":"true"})})})},e.id)})})]})}),le="worktree-activity-pane",lt={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentInstancesPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},ln=(0,i.memo)(function(e){let{active:t,activities:n,className:a=""}=e;if(null===t)return(0,r.jsx)("div",{id:le,"data-testid":"activity-pane","data-active":"none",className:"h-full flex flex-col ".concat(a).trim()});let s=n[t],l=lt[t];return(0,r.jsx)("div",{id:le,"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)(T.t,{componentName:l,children:null!=s?s:null})})});var la=n(13577),lr=n(72338),ls=n(90088),ll=n(96195),li=n(56936);let lo=(0,i.memo)(function(e){let{inputRef:t,searchQuery:n,onQueryChange:a,matchCount:s,currentIdx:l,onNextMatch:i,onPrevMatch:o,onClose:d}=e,u=(0,c.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&&d(),"Enter"!==e.key||e.nativeEvent.isComposing||(e.shiftKey?o():i())},placeholder:u("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)(m.$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":u("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:i,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":u("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":u("fileSearch.close"),children:(0,r.jsx)(eN.A,{className:"w-4 h-4"})})]})});var lc=n(40051);function ld(){return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,r.jsx)(u.y,{size:"xl",variant:"accent"})})}let lu=(0,o.default)(()=>n.e(530).then(n.bind(n,530)).then(e=>({default:e.HtmlPreview})),{loadableGenerated:{webpack:()=>[530]},ssr:!1,loading:()=>(0,r.jsx)(ld,{})}),lm=(0,o.default)(()=>Promise.resolve().then(n.bind(n,27307)).then(e=>({default:e.PdfPreview})),{loadableGenerated:{webpack:()=>[27307]},ssr:!1,loading:()=>(0,r.jsx)(ld,{})}),lx=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(ld,{})}),lh=/^---\s*\nmarp:\s*true/;function lf(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(u.y,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:e("fileViewer.loading")})]})}function lp(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 lg(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)(eC.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}function lb(e){let{filePath:t,isMaximized:n,onToggleMaximize:a,copyableContent:s,onSearch:l}=e,i=(0,c.c)("worktree"),{copied:o,markCopied:d}=(0,eR.q)(),{copied:u,markCopied:m}=(0,eR.q)(),x=async()=>{try{await (0,ek.l)(t),d()}catch(e){}},h=async()=>{if(s)try{await (0,ek.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":i("actions.copyFilePath"),title:i("actions.copyPath"),children:o?(0,r.jsx)(em.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eh.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":i("actions.searchInFile"),title:i("actions.search"),children:(0,r.jsx)(z.A,{className:"w-3.5 h-3.5"})}),s&&(0,r.jsx)("button",{type:"button",onClick:h,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":i("actions.copyFileContent"),title:i("actions.copyContent"),children:u?(0,r.jsx)(em.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ex.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":i(n?"actions.minimize":"actions.maximize"),title:i(n?"actions.minimize":"actions.maximize"),children:n?(0,r.jsx)(W.A,{className:"w-4 h-4"}):(0,r.jsx)(H.A,{className:"w-4 h-4"})})]})]})}function lv(e){var t;let{content:n,extension:a,searchMatches:s,searchCurrentIdx:l,totalLines:o,rangeStart:c,worktreeId:d,filePath:u,onLineRangeFetched:m}=e,x=(0,i.useRef)(null),h=(0,i.useMemo)(()=>n.split("\n"),[n]),f=Math.max(1,null!=c?c:1),p=h.length,g=Math.max(null!=o?o:p,p),b=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{b.current.clear()},[n,a]);let v=(0,i.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,h.length),l=h.slice(e,t).join("\n"),i="";try{i=eL.A.highlight(l,{language:a,ignoreIllegals:!0}).value}catch(e){i=eL.A.highlightAuto(l).value}s=i.split("\n"),r.set(n,s)}return null!=(t=s[e-500*n])?t:""},[h,a]),y=(0,i.useMemo)(()=>new Set(null!=s?s:[]),[s]),j=(null!=(t=null==s?void 0:s.length)?t:0)>0?s[null!=l?l:0]:-1,w=(0,ll.Te)({count:g,getScrollElement:()=>x.current,estimateSize:()=>24,overscan:100});(0,i.useEffect)(()=>{if(!s||0===s.length)return;let e=s[null!=l?l:0];if(!Number.isFinite(e))return;let t=Math.max(0,Math.min(g-1,e-1));w.scrollToIndex(t,{align:"center"})},[l,s,w,g]);let k=w.getVirtualItems();return!function(e){let{virtualItems:t,worktreeId:n,filePath:a,onLineRangeFetched:r,loadedStart:s,loadedLineCount:l}=e,o=(0,i.useRef)(new Set);(0,i.useEffect)(()=>{if(!n||!a||!r||0===t.length)return;let e=t[0].index+1,i=t[t.length-1].index+1,c=s+l-1;if(e>=s&&i<=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,eE.o)(a),"?startLine=").concat(d,"&endLine=").concat(u);(0,eq.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,s,l])}({virtualItems:k,worktreeId:d,filePath:u,onLineRangeFetched:m,loadedStart:f,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-f,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)(lc.E,{className:"h-4 w-3/4"})})]},e.key)})})})}function ly(e){let{slides:t,fileName:n}=e,a=(0,c.c)("worktree"),[s,l]=(0,i.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:()=>{l(e=>Math.max(0,e-1))},disabled:0===s,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:[s+1," / ",t.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>{l(e=>Math.min(t.length-1,e+1))},disabled:s===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[s],sandbox:"",title:a("fileViewer.slideTitle",{name:n,number:s+1}),className:"w-full h-full border-0"})})]})}function lj(e){let{marpSlides:t,fileName:n,worktreeId:a,filePath:s,contentText:l,onFileSaved:o,isMaximized:d,onToggleMaximize:u,onDirtyChange:m,onOpenFile:x}=e,h=(0,c.c)("worktree"),[f,p]=(0,i.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"===f?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:h("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"===f?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:h("fileViewer.editor")})]}),(0,r.jsx)(lb,{filePath:s,isMaximized:d,onToggleMaximize:u,copyableContent:l})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===f?(0,r.jsx)(ly,{slides:t,fileName:n}):(0,r.jsx)(lx,{worktreeId:a,filePath:s,onSave:o,initialViewMode:"split",onDirtyChange:m,onOpenFile:x})})]})}function lw(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:eT.M.MAXIMIZED_EDITOR},children:[(0,r.jsx)(lb,{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,tz.createPortal)(l,document.body)}function lk(e){let{tab:t,content:n,worktreeId:a,isMaximized:s,onToggleMaximize:l,onFileSaved:i,onDirtyChange:o,onOpenFile:c}=e,d=eM(n.content);return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)(lb,{filePath:t.path,isMaximized:s,onToggleMaximize:l,copyableContent:n.content,onSearch:d.openSearch}),d.searchOpen&&(0,r.jsx)(lo,{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)(lv,{content:n.content,extension:n.extension,searchMatches:d.searchMatches,searchCurrentIdx:d.searchCurrentIdx}):(0,r.jsx)(lx,{worktreeId:a,filePath:t.path,onSave:i,initialViewMode:"preview",onDirtyChange:o,onOpenFile:c})})]})}function lN(e){var t,n;let{tab:a,content:s,worktreeId:l,isMaximized:o,onToggleMaximize:c,onLoadContent:d}=e,u=eM(s.content),m=(0,i.useCallback)(e=>{var t;d&&d(a.path,{...s,content:e.content,totalLines:e.totalLines,totalBytes:null!=(t=e.totalBytes)?t:s.totalBytes,range:e.range})},[d,a.path,s]),x=void 0!==s.range&&(null!=(n=s.totalLines)?n:0)>s.range.end-s.range.start+1;return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lb,{filePath:a.path,isMaximized:o,onToggleMaximize:c,copyableContent:s.content,onSearch:u.openSearch}),s.readOnly&&s.readOnlyReason&&(0,r.jsx)(lg,{reason:s.readOnlyReason}),u.searchOpen&&(0,r.jsx)(lo,{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)(lv,{content:s.content,extension:s.extension,searchMatches:u.searchOpen?u.searchMatches:void 0,searchCurrentIdx:u.searchOpen?u.searchCurrentIdx:void 0,totalLines:s.totalLines,rangeStart:null==(t=s.range)?void 0:t.start,worktreeId:x?l:void 0,filePath:x?a.path:void 0,onLineRangeFetched:x?m:void 0})})]})}let lC=(0,i.memo)(function(e){var t,n,a,s;let{tab:l,worktreeId:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:x,onDirtyChange:h,onOpenFile:f}=e,p=(0,c.c)("worktree"),g=(0,i.useRef)(p);g.current=p;let b=(0,i.useRef)(!1),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(!1);!function(e){let{tab:t,worktreeId:n,onLoadContent:a}=e,r=(0,i.useRef)(null),s=(0,i.useRef)(a);s.current=a;let l=(0,i.useRef)(t.path);l.current=t.path,t8({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,eE.o)(l.current)),t={};r.current&&(t["If-Modified-Since"]=r.current);try{let n=await (0,eq.E)(e,{headers:t,timeoutMs:li.K3,retries:0});if(304===n.status||!n.ok)return;r.current=n.headers.get("Last-Modified");let a=await n.json();s.current(l.current,a)}catch(e){}}})}({tab:l,worktreeId:o,onLoadContent:d});let k=(0,i.useMemo)(()=>h?e=>h(l.path,e):void 0,[h,l.path]),N=(0,i.useCallback)(()=>{w(e=>!e)},[]);(0,i.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&w(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]),(0,i.useEffect)(()=>{null!==l.content||l.loading||null!==l.error||b.current||(b.current=!0,m(l.path,!0),(async()=>{try{let t=await (0,eq.E)("/api/worktrees/".concat(o,"/files/").concat((0,eE.o)(l.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(l.path,a);return}let n=await t.json();d(l.path,n)}catch(e){u(l.path,e instanceof Error?e.message:g.current("fileViewer.loadError"))}finally{b.current=!1}})())},[l.content,l.loading,l.error,l.path,o,d,u,m]);let C=null!=(a=null==(t=l.content)?void 0:t.content)?a:null,S=null!=(s=null==(n=l.content)?void 0:n.extension)?s:null;if((0,i.useEffect)(()=>{if(!C||"md"!==S||!lh.test(C)||C.length>1e6)return void y(null);let e=!1;return(async()=>{try{let t=await (0,eq.E)("/api/worktrees/".concat(o,"/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,o]),l.loading)return(0,r.jsx)(lf,{});if(l.error)return(0,r.jsx)(lp,{error:l.error});if(!l.content)return null;let{content:I}=l;return I.isImage?(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lb,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(eo.a,{src:I.content,alt:I.path,mimeType:I.mimeType})})]})}):I.isVideo?(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lb,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ec.u,{src:I.content,mimeType:I.mimeType})})]})}):I.isPdf?(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lb,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lm,{dataUri:I.content,filePath:l.path})})]})}):I.readOnly?(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)(lN,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onLoadContent:d})}):I.isHtml?(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lb,{filePath:l.path,isMaximized:j,onToggleMaximize:N,copyableContent:I.content}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lu,{worktreeId:o,filePath:l.path,htmlContent:I.content,onFileSaved:x,onOpenFile:f})})]})}):"md"===I.extension?(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:v?(0,r.jsx)(lj,{marpSlides:v,fileName:l.name,worktreeId:o,filePath:l.path,contentText:I.content,onFileSaved:x,isMaximized:j,onToggleMaximize:N,onDirtyChange:k,onOpenFile:f}):(0,r.jsx)(lk,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:f})})}):ew("."+I.extension)?(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(lk,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:f})})}):(0,r.jsx)(lw,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)(lN,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onLoadContent:d})})}),lS="commandmate:file-tabs:";function lI(e){let t=e.split("/");return t[t.length-1]||e}function lT(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 lE(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 lA={tabs:[],activeIndex:null};function lM(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 lR=(0,i.memo)(function(e){let{tab:t,isActive:n,onActivate:a,onClose:s,onOpenMenu:l}=e,o=(0,c.c)("worktree"),d=(0,i.useCallback)(()=>{n||a(t.path)},[n,a,t.path]),u=(0,i.useCallback)(e=>{e.stopPropagation(),s(t.path)},[s,t.path]),m=(0,i.useCallback)(e=>{l(e,t.path)},[l,t.path]),x=(0,i.useCallback)(e=>{1===e.button&&(e.preventDefault(),e.stopPropagation(),s(t.path))},[s,t.path]),h=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(h),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:o("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":o("fileTabs.closeTab",{name:t.name}),children:(0,r.jsx)(eN.A,{className:"w-3 h-3"})})]})}),lL=(0,i.memo)(function(e){var t,n,a;let{tabs:s,activeIndex:l,worktreeId:o,onClose:u,onActivate:m,onLoadContent:x,onLoadError:h,onSetLoading:f,onFileSaved:p,onDirtyChange:g,onMoveToFront:b,onOpenFile:v}=e,y=(0,c.c)("worktree"),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(null),N=(0,i.useRef)(null),C=(0,i.useRef)({x:0,y:0}),[S,I]=(0,i.useState)({x:0,y:0}),{menuState:T,openMenu:E,openMenuAt:A,closeMenu:M}=tO(),[R,L]=(0,i.useState)(null),P=null!==l&&l>=0&&l<s.length?s[l]:null,D=s.length>5?s.slice(0,5):s,F=s.length>5?s.slice(5):[];(0,i.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,i.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:lM(n.left-C.current.x,n.width,window.innerWidth),y:lM(n.top-C.current.y,n.height,window.innerHeight)})},[j]);let O=(0,i.useCallback)(e=>{w(!1),null==b||b(e)},[b]),z=(0,i.useCallback)(()=>{w(e=>!e)},[]),_=(0,i.useCallback)(e=>{for(let t=e.length-1;t>=0;t--)u(e[t])},[u]),V=(0,i.useCallback)((e,t)=>{let n=lE(s,t,e);if(0===n.length)return;let a=new Set(n);if(s.some(e=>e.isDirty&&a.has(e.path)))return void L({mode:e,anchorPath:t});_(n)},[s,_]),B=T.targetPath,W=(0,i.useMemo)(()=>B?[{id:"close-all-tabs",label:y("fileTabs.closeAll"),icon:(0,r.jsx)(la.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>V("all",B),disabled:0===s.length},{id:"close-other-tabs",label:y("fileTabs.closeOthers"),icon:(0,r.jsx)(lr.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>V("others",B),disabled:0===lE(s,B,"others").length},{id:"close-tabs-to-right",label:y("fileTabs.closeToRight"),icon:(0,r.jsx)(ls.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>V("right",B),disabled:0===lE(s,B,"right").length}]:[],[B,s,V,y]),H=(0,i.useCallback)((e,t)=>{E(e,t,"file")},[E]),K=null!=(a=null!=(n=null==P?void 0:P.path)?n:null==(t=s[0])?void 0:t.path)?a:null,$=(0,i.useCallback)(e=>{if(!K)return;let t=e.currentTarget.getBoundingClientRect();A({x:t.left,y:t.bottom},K,"file")},[K,A]),q=R?lE(s,R.anchorPath,R.mode):[],G=q.filter(e=>{var t;return null==(t=s.find(t=>t.path===e))?void 0:t.isDirty}),J=(0,i.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)(lR,{tab:e,isActive:t===l,onActivate:m,onClose:u,onOpenMenu:H},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)(U.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))})]}),s.length>0&&(0,r.jsx)("button",{type:"button","data-testid":"tab-actions-button",onClick:$,"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)(d.A,{className:"w-4 h-4"})})]}),(0,r.jsx)(t$,{isOpen:T.isOpen,position:T.position,targetPath:T.targetPath,targetType:T.targetType,onClose:M,items:W,ariaLabel:y("fileTabs.tabActions")}),(0,r.jsxs)(e3.a,{isOpen:null!==R,onClose:J,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:G.length})}),(0,r.jsx)("ul",{className:"mt-2 max-h-32 overflow-y-auto text-sm text-muted-foreground",children:G.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)(el.$,{variant:"ghost",size:"sm","data-testid":"file-tabs-close-cancel",onClick:J,children:y("fileTabs.confirmCancel")}),(0,r.jsx)(el.$,{variant:"secondary",size:"sm","data-testid":"file-tabs-close-keep-unsaved",onClick:()=>{let e=new Set(G);_(q.filter(t=>!e.has(t))),L(null)},children:y("fileTabs.confirmKeepUnsaved")}),(0,r.jsx)(el.$,{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)(lC,{tab:P,worktreeId:o,onLoadContent:x,onLoadError:h,onSetLoading:f,onFileSaved:p,onDirtyChange:g,onOpenFile:v},P.path)})]})}),lP=(0,i.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})}),lD=(0,i.memo)(function(e){let{diff:t,filePath:n,onClose:a}=e,s=(0,c.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)(lP,{line:e},t))})})})]})}),lF="commandmate.worktree.filePanelCollapsed",lO="worktree-file-panel",lz=(0,i.createContext)({tabCount:0,hasDiff:!1}),l_="commandmate:filePanelStateChange";function lV(){let[e,t]=(0,i.useState)(!1),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{let e=window.localStorage.getItem(lF);if("true"===e)return!0}catch(e){}return!1}())},[]),(0,i.useEffect)(()=>{let e=e=>{e.detail&&e.detail.collapsed!==n.current&&t(e.detail.collapsed)};return window.addEventListener(l_,e),()=>window.removeEventListener(l_,e)},[]);let a=(0,i.useCallback)(e=>{t(e);try{window.localStorage.setItem(lF,String(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(l_,{detail:{collapsed:e}}))}catch(e){}},[]);return{collapsed:e,toggle:(0,i.useCallback)(()=>{a(!n.current)},[a]),setCollapsed:a}}let lB=(0,i.memo)(function(e){let{terminal:t,terminalHeader:n,fileTabs:a,worktreeId:s,onCloseTab:l,onActivateTab:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,diffContent:x,diffFilePath:h,onCloseDiff:f,onDirtyChange:p,onMoveToFront:g,onOpenFile:b}=e,v=(0,i.useRef)(null),[y,j]=(0,i.useState)(50),{collapsed:w}=lV(),k=(0,i.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,i.useMemo)(()=>({width:"".concat(y,"%")}),[y]),C=(0,i.useMemo)(()=>({width:"".concat(100-y,"%")}),[y]),S=(0,i.useMemo)(()=>({tabCount:a.tabs.length,hasDiff:!!(x&&h)}),[a.tabs.length,x,h]),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&&h?w?(0,r.jsx)(lz.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)(lz.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)(s$.f,{onResize:k,orientation:"horizontal",ariaValueNow:y}),(0,r.jsx)("div",{id:lO,"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&&h&&f?(0,r.jsx)(lD,{diff:x,filePath:h,onClose:f}):(0,r.jsx)(lL,{tabs:a.tabs,activeIndex:a.activeIndex,worktreeId:s,onClose:l,onActivate:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,onDirtyChange:p,onMoveToFront:g,onOpenFile:b})})})]})}):(0,r.jsx)(lz.Provider,{value:S,children:(0,r.jsx)("div",{className:"h-full",children:I})})});var lU=n(7125),lW=n(22509),lH=n(54485),lK=n(70198);let l$=[.5,.5],lq={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]},lG=new Set(K.XH);function lJ(e){return"".concat("commandmate:terminalSplits:").concat(e)}function lY(e){return"object"==typeof e&&null!==e}function lQ(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}function lX(e){return void 0===e||!!Array.isArray(e)&&2===e.length&&e.every(lQ)}function lZ(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 l0(e){let t=e[0];return t?{splits:[{cliToolId:t.cliTool,instanceId:t.id}],widths:[1]}:{splits:lq.splits.map(e=>({...e})),widths:[...lq.widths]}}function l1(e){let t=e.reduce((e,t)=>e+t,0);return t>0?e.map(e=>e/t):e.map(()=>1/e.length)}function l2(e){if(4===e.splits.length)return lX(e.rowHeights)&&void 0!==e.rowHeights?e:{...e,rowHeights:[...l$]};if(void 0===e.rowHeights)return e;let{rowHeights:t,...n}=e;return n}function l4(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?l1(e.widths):l.length<e.widths.length?l1(e.widths.slice(0,l.length)):Array.from({length:l.length},()=>1/l.length),l2({...e,splits:l,widths:n}))}function l5(e,t,n){let a=function(e,t){try{let n=window.localStorage.getItem(lJ(e));if(!n)return l0(t);let a=JSON.parse(n),r=function(e){if(!lY(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(!lY(e))return null;let t=e.cliToolId;if("string"!=typeof t||!lG.has(t))return null;let n=e.instanceId,a="string"==typeof n&&(0,K.n6)(n)?n:t;r.push({cliToolId:t,instanceId:a})}for(let e of n)if(!lQ(e))return null;let s={splits:r,widths:n};return 4===r.length&&void 0!==a&&lX(a)&&(s.rowHeights=[...a]),s}(a);if(r)return l2({...r,widths:l1(r.widths)});return console.warn("[useTerminalSplits] stale state for ".concat(e,"; falling back to default")),l0(t)}catch(n){return console.warn("[useTerminalSplits] failed to parse stored state for ".concat(e,"; using default"),n),l0(t)}}(e,t);return n?l4(a,t):a}var l3=n(81507);let l6=(0,i.memo)(function(e){var t,n,a,s;let{worktreeId:l,instances:o,rosterReady:d=!0,renderPane:u,onFocusedSplitChange:m,showToast:x,onActiveInstanceChange:h,headerInstanceSelection:f}=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,i.useState)(()=>l5(e,t,n)),[s,l]=(0,i.useState)(0),[o,c]=(0,i.useState)(null),d=(0,i.useRef)(a);d.current=a;let u=(0,i.useRef)(t);u.current=t;let m=(0,i.useRef)(n);m.current=n;let x=(0,i.useRef)(e);(0,i.useEffect)(()=>{x.current!==e&&(x.current=e,r(l5(e,u.current,m.current)),l(0),c(null))},[e]);let h=(0,i.useMemo)(()=>t.map(e=>"".concat(e.id,":").concat(e.cliTool)).join("|"),[t]);(0,i.useEffect)(()=>{n&&r(e=>l4(e,u.current))},[h,n]);let f=(0,i.useRef)(e);(0,i.useEffect)(()=>{if(f.current!==e){f.current=e;return}try{window.localStorage.setItem(lJ(e),JSON.stringify(a))}catch(e){}},[a,e]);let p=(0,i.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 l2({...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),l2({...e,splits:a,widths:l})})},[]),g=(0,i.useCallback)(()=>{c(null),r(e=>{if(e.splits.length<=1)return e;let t=e.splits.slice(0,-1),n=l1(e.widths.slice(0,-1));return l2({...e,splits:t,widths:n})})},[]);(0,i.useEffect)(()=>{l(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,i.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,i.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,i.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:[...l$]}:l2({...e,widths:n})})},[]),j=(0,i.useCallback)(e=>{r(t=>4!==t.splits.length?t:Array.isArray(e)&&2===e.length&&lX(e)?{...t,rowHeights:[...e]}:t)},[]),w=(0,i.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,i.useCallback)(e=>{l(e)},[]),N=(0,i.useMemo)(()=>{var e;return(e=a.rowHeights)&&lX(e)?[...e]:[...l$]},[a.rowHeights]),C=(0,i.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:s,setFocusedSplitIndex:k,maximizedIndex:o,toggleMaximize:C}}(l,o,d),A=(0,i.useMemo)(()=>{let e=new Map;for(let t of o)e.set(t.id,t);return e},[o]),M=(0,c.c)("worktree"),{visible:R,toggle:L,setWidth:P}=(0,l3.TG)(),{collapsed:D,toggle:F}=lV(),O=!D,z=(0,i.useRef)(null),[_,V]=(0,i.useState)(!1),B=(0,i.useRef)(p.length),[U,$]=(0,i.useState)(null);(0,i.useEffect)(()=>{p.length>B.current&&$(p.length-1),B.current=p.length},[p.length]),(0,i.useEffect)(()=>{null==m||m(S)},[S,m]);let q=(0,i.useRef)(0),J=(0,i.useRef)(p);J.current=p,(0,i.useEffect)(()=>{if(!f||f.token===q.current)return;q.current=f.token;let{instanceId:e}=f,t=J.current.findIndex(t=>t.instanceId===e);if(0!==t){if(t>0)return void I(t);w(0,e)&&I(0)}},[f,w,I]),(0,i.useEffect)(()=>{if(null===U)return;let e=z.current;if(!e)return;let t=e.querySelector('[data-split-index="'.concat(U,'"]'));if(!t)return;let n=t.querySelector("textarea");null==n||n.focus(),I(U),$(null)},[U,I]);let Y=(0,i.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]),Q=lZ(null!=(t=g[0])?t:1,null!=(n=g[1])?n:1),X=lZ(null!=(a=b[0])?a:1,null!=(s=b[1])?s:1),Z=(0,i.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]),ee=(0,i.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]),et=(0,i.useCallback)(()=>V(!0),[]),en=(0,i.useCallback)(()=>V(!1),[]),ea=(0,i.useCallback)(()=>{N(),P(l3.sg)},[N,P]),er=p.length<4&&!_,es=p.length>1&&!_,el=p.length>1||R,ei=null!==T,eo=p.length>1,ec=4===p.length,ed=(0,i.useCallback)(()=>{E(null!=T?T:S)},[E,T,S]),eu=M(ei?"terminal.restoreSplits":"terminal.maximizeFocusedSplit"),em="".concat(eu," — ").concat(M("terminal.maximizeShortcutHint")),{tabCount:ex,hasDiff:eh}=(0,i.useContext)(lz),ef=0===ex&&!eh,ep="".concat(M(R?"terminal.hideHistory":"terminal.showHistory")," — ").concat(M("terminal.historyAllSplitsHint")),eg=M(ef?"terminal.filesEmptyHint":O?"terminal.hideFiles":"terminal.showFiles"),eb=(0,i.useMemo)(()=>p.map((e,t)=>(0,l3.Ce)(t)).join(" "),[p]),ev=(0,i.useMemo)(()=>p.map((e,t)=>()=>I(t)),[p,I]),ey=(0,i.useMemo)(()=>p.map((e,t)=>e=>w(t,e)),[p,w]),ej=(0,i.useMemo)(()=>p.map((e,t)=>()=>E(t)),[p,E]),ew=(0,i.useMemo)(()=>p.map((e,t)=>e=>{var n,a;let r=(0,K.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==h||h(e),null==x||x("Moved ".concat(r," to Split ").concat(t+1),"success"))}),[p,w,x,h,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:ei?M("terminal.maximizedStatus",{split:(null!=T?T:0)+1}):"".concat(p.length," / ").concat(4," splits")}),(0,r.jsx)(G.m_,{content:M("terminal.addSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:y,disabled:!er,"aria-disabled":!er,"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)(as.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(G.m_,{content:M("terminal.removeSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:j,disabled:!es,"aria-disabled":!es,"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)(lU.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(G.m_,{content:M("terminal.equalizeWidthsHint"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:ea,disabled:!el,"aria-disabled":!el,"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)(lW.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,r.jsx)(G.m_,{content:em,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:ed,disabled:!eo,"aria-disabled":!eo,"aria-pressed":ei,"aria-label":eu,"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:ei?(0,r.jsx)(W.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}):(0,r.jsx)(H.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)(G.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)(lH.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)(G.m_,{content:eg,placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{type:"button",onClick:F,disabled:ef,"aria-disabled":ef,"aria-pressed":O,"aria-expanded":O,"aria-controls":lO,"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)(lK.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":ec?"grid":"row",className:ec?"grid flex-1 min-h-0 w-full overflow-y-auto":"flex flex-1 min-h-0 w-full",style:ec?{gridTemplateColumns:ei?"1fr":"".concat(Q[0],"fr ").concat(4,"px ").concat(Q[1],"fr"),gridTemplateRows:ei?"1fr":"minmax(".concat(280,"px, ").concat(X[0],"fr) ").concat(4,"px minmax(").concat(280,"px, ").concat(X[1],"fr)")}:void 0,children:[p.map((e,t)=>{var n;let a=t===p.length-1,s=null!==T&&T!==t,l=T===t;return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"split-wrapper-".concat(t),"data-hidden":s?"true":void 0,style:ec?{gridColumn:l||t%2==0?1:3,gridRow:l||t<2?1:3,minWidth:0,minHeight:0,...s?{display:"none"}:null}:{flexGrow:l?1:null!=(n=g[t])?n:1,flexShrink:1,flexBasis:0,minWidth:0,...s?{display:"none"}:null},className:"h-full",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:l,onToggleMaximize:ej[t]})}),ec||a?null:(0,r.jsx)(l9,{resizerIdx:t,hidden:null!==T,ariaValueNow:g.length?g[t]/g.reduce((e,t)=>e+t,0)*100:50,onResize:Y,onStart:et,onEnd:en,onDoubleClick:N})]},"split-".concat(t))}),ec?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l9,{resizerIdx:0,testId:"split-grid-column-resizer",gridArea:{gridColumn:2,gridRow:"1 / span 3"},hidden:ei,ariaValueNow:g[0]/(g[0]+g[1])*100,onResize:Z,onStart:et,onEnd:en,onDoubleClick:N}),(0,r.jsx)(l9,{resizerIdx:0,testId:"split-grid-row-resizer",orientation:"vertical",gridArea:{gridColumn:"1 / span 3",gridRow:2},hidden:ei,ariaValueNow:b[0]/(b[0]+b[1])*100,onResize:ee,onStart:et,onEnd:en,onDoubleClick:N})]}):null]})]})});function l9(e){let{resizerIdx:t,ariaValueNow:n,onResize:a,onStart:s,onEnd:l,onDoubleClick:o,hidden:c=!1,orientation:d="horizontal",testId:u,gridArea:m}=e,x=(0,i.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:s,onTouchStartCapture:s,onMouseUpCapture:l,onTouchEndCapture:l,children:(0,r.jsx)(s$.f,{onResize:x,orientation:d,ariaValueNow:n,onDoubleClick:o})})}function l8(e){if(!e)return null;let t=e.decisionId;return"string"==typeof t&&""!==t?t:null}let l7="\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(),ie="bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",it="bg-surface border-2 border-input hover:bg-muted text-foreground focus:ring-ring";function ia(e){let{promptData:t,answering:n,onRespond:a,decisionId:s,onDismiss:l,labelId:o,cliToolName:d}=e,u=(0,c.c)("prompt"),[x,h]=(0,i.useState)(()=>{if("multiple_choice"===t.type){var e;let n=t.options.find(e=>e.isDefault);return null!=(e=null==n?void 0:n.number)?e:null}return null}),[f,p]=(0,i.useState)(""),[g,b]=(0,i.useState)(!1),v=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===x))?e:null},[t,x]),y=(null==v?void 0:v.requiresTextInput)===!0,j=n||g,w=(0,i.useCallback)(async e=>{if(!j){b(!0);try{await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s]),k=(0,i.useCallback)(async()=>{if(!j&&null!==x){b(!0);try{let e=y&&f.trim()?f.trim():x.toString();await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s,x,y,f]),N=(0,i.useCallback)(async e=>{if(!j&&s){b(!0);try{await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s]);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:o,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:"?"}),d?u("confirmationFrom",{toolName:d}):u("confirmationFromClaude")]}),l&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,"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"})})})]}),(0,I.XF)(t)&&t.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:t.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?u("askUserQuestionProgress",{index:t.askUserQuestion.questionIndex+1,total:t.askUserQuestion.questionCount}):u("askUserQuestionSource")}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:(0,I.XF)(t)?t.question:u("unclassifiedTitle")}),j&&(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)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:u("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(io,{promptData:t,disabled:j,onYes:()=>w("yes"),onNo:()=>w("no")}),"multiple_choice"===t.type&&(0,r.jsx)(ic,{promptData:t,disabled:j,selectedOption:x,onSelectOption:h,textInputValue:f,onTextInputChange:p,showTextInput:y,onSubmit:k}),!(0,I.XF)(t)&&(0,r.jsx)(ir,{promptData:t,decisionId:s,disabled:j,onRespond:N})]})}function ir(e){var t,n,a,s,l;let{promptData:i,decisionId:o,disabled:d,onRespond:u}=e,m=(0,c.c)("prompt"),x=o&&null!=(n=i.decisionOptions)?n:null,h=function(e){if(null===l8(e)||Array.isArray(e.decisionOptions)&&e.decisionOptions.length>0)return null;let t=e.askUserQuestion;if(!t||"string"!=typeof t.question||""===t.question||!Array.isArray(t.labels)||0===t.labels.length)return null;let n=t.labels.filter(e=>"string"==typeof e&&""!==e);if(n.length!==t.labels.length)return null;let a="number"==typeof t.questionCount?t.questionCount:1;return 1!==a?null:{question:t.question,labels:n,questionCount:a}}(i);return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"unclassified-prompt-notice",children:[i.message&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:i.message}),i.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:i.askUserQuestion.question}),h?(0,r.jsx)(ii,{choices:h,disabled:d,onRespond:u}):(0,r.jsx)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:i.askUserQuestion.labels.map(e=>(0,r.jsx)("li",{children:e},e))})]}),h?null:x&&x.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(is,{toolName:null!=(a=i.toolName)?a:null,patterns:null!=(s=i.patterns)?s:null,allowAlwaysLabel:null!=(l=null==(t=x.find(e=>"always"===e.reply))?void 0:t.label)?l:null}),(0,r.jsx)(il,{options:x,disabled:d,onRespond:u})]}):(0,r.jsx)("p",{className:"text-sm text-foreground",children:m("unclassifiedInstruction",{command:m("unclassifiedRespondCommand")})})]})}function is(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 il(e){let{options:t,disabled:n,onRespond:a}=e,s=(0,c.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)(m.$n,{variant:"ghost",type:"button",disabled:n,onClick:()=>a(String(e.number)),"data-testid":"structured-decision-option-".concat(e.number),className:"".concat(l7," ").concat(3===e.number?it:ie),children:[e.number,". ",e.label]},e.number))})}function ii(e){let{choices:t,disabled:n,onRespond:a}=e,s=(0,c.c)("prompt"),l=(0,i.useId)(),[o,d]=(0,i.useState)(null),u=(0,i.useCallback)(e=>{let t=o===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)},[o,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:s("selectAnOption")}),(0,r.jsx)(m.z6,{name:l,value:null!=o?String(o):"",onValueChange:e=>d(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.labels.map((e,t)=>(0,r.jsxs)("label",{className:u(t+1),children:[(0,r.jsx)(m.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)))})]}),(0,r.jsx)("button",{type:"button","data-testid":"structured-question-submit",onClick:()=>{null!==o&&a(String(o))},disabled:n||null===o,className:"w-full ".concat(l7," ").concat(ie),children:s("submit")})]})}function io(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,c.c)("prompt"),i="yes"===t.defaultOption,o="no"===t.defaultOption,d="".concat(l7," ").concat(ie," ").concat(i?"primary default highlighted":""),u="".concat(l7," ").concat(o?"bg-foreground text-background hover:bg-foreground/90 primary default highlighted":it);return(0,r.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:a,disabled:n,className:d,children:l("yes")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:s,disabled:n,className:u,children:l("no")})]})}function ic(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,x=(0,i.useId)(),h=(0,c.c)("prompt"),f=(0,i.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:h("selectAnOption")}),(0,r.jsx)(m.z6,{name:x,value:null!=a?String(a):"",onValueChange:e=>s(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>(0,r.jsxs)("label",{className:f(e.number),children:[(0,r.jsx)(m.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:h("default")}),e.description&&(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e.description})]})]},e.number))})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(x),className:"sr-only",children:h("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:h("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:u,disabled:n||null===a,className:"w-full ".concat(l7," ").concat(ie),children:h("submit")})]})}let id=(0,i.memo)(function(e){let t,{promptData:n,messageId:a,decisionId:s,visible:l,answering:o,onRespond:c,onDismiss:d,cliToolName:u}=e,{shouldRender:m,animationClass:x}=A({visible:l&&null!==n,duration:200}),h=(0,i.useId)();if(!m||!n)return null;let f=(t="opacity-100","animate-fade-in"===x?t="opacity-100 transform translate-y-0":"animate-fade-out"===x&&(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(x," ").concat(t));return(0,r.jsx)(T.t,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":h,"aria-modal":"true",className:f,children:(0,r.jsx)(ia,{promptData:n,answering:o,onRespond:c,decisionId:s,onDismiss:d,labelId:h,cliToolName:u})})})});var iu=n(35619),im=n(93141);let ix=(0,i.memo)(function(e){var t,n,a;let{worktreeId:s,cliToolId:l,instanceId:o,diff:d,disabled:u=!1}=e,x=(0,c.c)("worktree"),h=(0,m.SC)(),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),j=(null==d?void 0:d.revertedMessageId)!=null,w=(0,i.useMemo)(()=>{var e,t;return j?null!=(e=null==d?void 0:d.revertedFiles)?e:[]:null!=(t=null==d?void 0:d.files)?t:[]},[j,d]),k=(0,i.useCallback)(async e=>{b(null),p(e);try{let t=await fetch("/api/worktrees/".concat(s,"/opencode/diff"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,instanceId:null!=o?o:l})}),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)}},[s,l,o]),N=(0,i.useCallback)(async()=>{await h({title:x("opencodeDiff.revertConfirmTitle"),description:x("opencodeDiff.revertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.revertConfirmLabel"),variant:"danger"})&&await k("revert")},[h,x,w.length,k]),C=(0,i.useCallback)(async()=>{await h({title:x("opencodeDiff.unrevertConfirmTitle"),description:x("opencodeDiff.unrevertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.unrevertConfirmLabel")})&&await k("unrevert")},[h,x,w.length,k]);return"opencode"!==l?null:d&&(d.files.length>0||d.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)(iu.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!==f?(0,r.jsx)(m.y$,{size:"sm"}):null,j?(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:C,disabled:u||null!==f,children:[(0,r.jsx)(im.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),x("opencodeDiff.unrevert")]}):(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:N,disabled:u||null!==f,children:[(0,r.jsx)(nn.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)(m.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)(lD,{diff:null!=(n=v.patch)?n:"",filePath:null!=(a=v.file)?a:"",onClose:()=>y(null)}):null})]}):null});var ih=n(2954);function ip(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}let ig=(0,i.memo)(function(e){var t,n,a,s,l,o;let{worktreeId:d,splitIndex:u,cliToolId:m,instanceId:x,instance:h,availableInstances:f,onInstanceChange:p,onFocus:g,disabled:b=!1,pendingInsertText:v,onInsertConsumed:y,onMessageSent:j,cliStatus:w="idle",autoYes:k,history:N,onDropInstance:C,draggedInstanceId:S,onRequestSessionEnd:T,agentModel:E,onAgentSessionChange:A,isMaximized:M=!1,onToggleMaximize:R}=e,L=null!=x?x:m,P=null!=(n=k.enabled)&&n,D=null!=(a=k.expiresAt)?a:null,F=null!=(s=k.lastAutoResponse)?s:null,O=k.onToggle,z=null!=(l=null==N?void 0:N.showArchived)&&l,_=null==N?void 0:N.onShowArchivedChange,V=null==N?void 0:N.historyDisplayLimit,B=null==N?void 0:N.onHistoryDisplayLimitChange,U=null!=(o=null==N?void 0:N.historyUserOnly)&&o,W=null==N?void 0:N.onHistoryUserOnlyChange,H=null==N?void 0:N.onInsertToMessage,q=null==N?void 0:N.onFilePathClick,J=null==N?void 0:N.showToast,Y=(0,c.c)("worktree"),Q=(0,eW.Ym)(),X=(0,i.useMemo)(()=>(0,tT.$2)(d,u),[d,u]),[Z,ee]=(0,i.useState)($.wf);(0,i.useEffect)(()=>{ee((0,tT.TR)(X))},[X]);let et=(0,i.useCallback)(e=>{ee(e),(0,tT.If)(X,e)},[X]),ea=(0,i.useRef)(Z);ea.current=Z,(0,i.useEffect)(()=>{function e(e){if(!e.shiftKey||e.altKey||!e.metaKey&&!e.ctrlKey||"m"!==e.key.toLowerCase())return;let t=e.target instanceof Element?e.target:null,n=null==t?void 0:t.closest("[data-split-index]");if(n){if(Number(n.getAttribute("data-split-index"))!==u)return}else if(0!==u||(null==t?void 0:t.closest('input, textarea, select, [contenteditable="true"]')))return;e.preventDefault(),et("chat"===ea.current?"terminal":"chat")}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u,et]);let el=(0,i.useRef)(R);el.current=R,(0,i.useEffect)(()=>{function e(e){if(!e.shiftKey||e.altKey||!e.metaKey&&!e.ctrlKey||"Enter"!==e.key)return;let t=e.target instanceof Element?e.target:null,n=null==t?void 0:t.closest("[data-split-index]");if(n){if(Number(n.getAttribute("data-split-index"))!==u)return}else if(0!==u||(null==t?void 0:t.closest('input, textarea, select, [contenteditable="true"]')))return;let a=el.current;a&&(e.preventDefault(),a())}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]);let{terminal:ei,prompt:eo,agentSession:ec,setAutoScroll:ed,setPromptAnswering:eu,clearPrompt:em,refresh:ex}=(0,th.NK)({worktreeId:d,cliToolId:m,instanceId:L,enabled:!b}),{messages:eh,isLoading:ef,refresh:ep}=(0,tf.Md)({worktreeId:d,cliToolId:m,instanceId:L,limit:V,includeArchived:z,enabled:!b}),eg=(0,i.useCallback)((e,t)=>eq.y.sendMessage(d,e,t),[d]),eb=(0,tg.Fx)(),ev=(0,i.useMemo)(()=>({offline:(0,tg.sV)(eb.signals),reachable:(0,tg._X)(eb.signals)}),[eb.signals]),{messages:ey,sendOptimistic:ej,retry:ew,discard:ek}=(0,tp.v4)({worktreeId:d,serverMessages:eh,sendFn:eg,onSent:ep,connectivity:ev}),{visible:eC,width:eS,toggle:eI,setWidth:eT}=(0,l3.TG)(),eE=i.useRef(null),eA=(0,i.useCallback)(e=>{let t=eE.current;if(!t)return;let n=t.offsetWidth;0!==n&&eT(eS+e/n*100)},[eS,eT]),eM="opencode"===m||"copilot"===m,{compactTuiLayoutPadding:eR,preservePaintedPanelRows:eL}=(0,i.useMemo)(()=>(0,tI.EK)(m),[m]),eP=(0,i.useCallback)(e=>ed(e),[ed]),eD=(0,i.useCallback)(e=>{ex(),ep(),null==j||j(e)},[ex,ep,j]),eF=(0,i.useCallback)(e=>{let t=ek(e);t&&(null==H||H(t))},[ek,H]),eO=(0,i.useCallback)(async(e,t)=>{eu(!0);try{let n=t?{decisionId:t,answer:e,cliTool:m,...L&&L!==m?{instanceId:L}:{}}:ip(e,m,(0,I.XF)(eo.data)?eo.data:null,L),a=await fetch(t?"/api/worktrees/".concat(d,"/respond"):"/api/worktrees/".concat(d,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw Error("Failed to send prompt response: ".concat(a.status));let r=await a.json().catch(()=>null);if((null==r?void 0:r.success)===!1){null==J||J(Y("promptResponse.refused"),"warning"),await ex();return}em(),await ex()}catch(e){console.error("[TerminalSplitPaneContent] prompt response error:",e)}finally{eu(!1)}},[d,m,L,eo.data,eu,em,ex,J,Y]),ez=(0,i.useCallback)(()=>{em()},[em]),e_="chat"===Z,eV=ei.isSelectionListActive,eB=eV&&!e_,eU="running"===ei.sessionStatus,eH=eo.visible&&!P,eK=l8(eo.data),e$=ei.isUnclassifiedActive&&!eV&&!eo.visible&&!e_,eG=ta(ei.composerText),eJ=td(m,ei.realtimeSnippet||ei.output),eY=(0,i.useMemo)(()=>({messages:ey,worktreeId:d,onFilePathClick:null!=q?q:()=>{},isLoading:ef,className:"h-full",showToast:J,onInsertToMessage:H,onRetryPending:ew,onDiscardPending:eF,showArchived:z,onShowArchivedChange:_,historyDisplayLimit:V,onHistoryDisplayLimitChange:B,historyUserOnly:U,onHistoryUserOnlyChange:W,splitIndex:u,cliToolId:m}),[ey,ew,eF,d,q,ef,J,H,z,_,V,B,U,W,u,m]),eQ=(0,i.useMemo)(()=>(0,r.jsx)(tD.bl,{...eY,onCollapse:eI}),[eY,eI]),eX=(0,i.useMemo)(()=>(0,r.jsx)(e7.D,{output:ei.output,isActive:ei.isRunning,attaching:ei.attaching,isThinking:ei.isThinking,autoScroll:ei.autoScroll,onScrollChange:eP,disableAutoFollow:eM,compactTuiLayoutPadding:eR,preservePaintedPanelRows:eL}),[ei.output,ei.isRunning,ei.attaching,ei.isThinking,ei.autoScroll,eP,eM,eR,eL]),eZ=(0,i.useMemo)(()=>(0,r.jsx)("div",{"data-testid":"split-chat-slot-".concat(u),"aria-label":Y("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)(tx.wY,{messages:eY.messages,worktreeId:d,cliToolId:m,instanceId:L,history:eY,live:{isRunning:ei.isRunning,attaching:ei.attaching,sessionStatus:ei.sessionStatus,isThinking:ei.isThinking,isPromptWaiting:eo.visible,promptData:eo.data,isSelectionListActive:ei.isSelectionListActive,isPagerActive:ei.isPagerActive,isDismissablePanelActive:ei.isDismissablePanelActive,isUnclassifiedActive:ei.isUnclassifiedActive},onSurfaceModeChange:et,frame:ei.output,onKeysSent:ex})})}),[eY,u,Y,d,m,L,ei.isRunning,ei.attaching,ei.sessionStatus,ei.isThinking,ei.isSelectionListActive,ei.isPagerActive,ei.isDismissablePanelActive,ei.isUnclassifiedActive,ei.output,ex,eo.visible,eo.data,et]),e0=(0,i.useMemo)(()=>eC?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:(0,tD.Ce)(u),"data-testid":"split-history-slot-".concat(u),"aria-label":"History pane",style:{width:"".concat(eS,"%")},className:"flex-shrink-0 overflow-hidden min-h-0",children:eQ}),(0,r.jsx)(s$.f,{onResize:eA,orientation:"horizontal",ariaValueNow:eS})]}):null,[eC,eS,eQ,eA,u]),e1=(0,i.useMemo)(()=>(0,r.jsxs)("div",{ref:eE,"data-testid":"split-terminal-row-".concat(u),className:"flex h-full min-h-0 w-full",children:[e0,(0,r.jsx)("div",{"data-testid":"split-terminal-slot-".concat(u),style:eC?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0 relative",children:eX})]}),[eC,e0,eX,u]),e2=(0,i.useMemo)(()=>(0,r.jsxs)("div",{ref:eE,"data-testid":"split-chat-row-".concat(u),className:"flex h-full min-h-0 w-full",children:[e0,(0,r.jsx)("div",{"data-testid":"split-chat-output-".concat(u),style:eC?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0",children:eZ})]}),[eC,e0,eZ,u]),e4=(0,i.useMemo)(()=>(0,r.jsxs)("div",{className:"space-y-2","data-testid":"split-footer-".concat(u),children:[eB?(0,r.jsx)(es.y,{worktreeId:d,cliToolId:m,instanceId:L,onKeysSent:ex,showPagerKeys:ei.isPagerActive}):null,e$?(0,r.jsx)(te.U,{worktreeId:d,cliToolId:m,instanceId:L,onKeysSent:ex}):null,eG?(0,r.jsx)(tr,{worktreeId:d,cliToolId:m,instanceId:L,composerText:ei.composerText,onActionSent:ex}):null,eJ?(0,r.jsx)(tu,{cliToolId:m,frame:ei.realtimeSnippet||ei.output}):null,eH?(0,r.jsx)(id,{promptData:eo.data,messageId:eo.messageId,decisionId:eK,visible:eo.visible,answering:eo.answering,onRespond:eO,onDismiss:ez,cliToolName:(0,K.oo)(m)}):null,ei.isRunning?(0,r.jsx)(tm.XU,{worktreeId:d,cliToolId:m,instanceId:L,hasAgentSession:null!==ec.session,onKeysSent:ex,collapsible:!0,layout:"desktop"}):null,(0,r.jsx)(ix,{worktreeId:d,cliToolId:m,instanceId:L,diff:ec.diff,disabled:!ei.isRunning}),(0,r.jsx)(er.E,{worktreeId:d,onMessageSent:eD,onOptimisticSend:ej,cliToolId:m,instanceId:L,isSessionRunning:ei.isRunning,pendingInsertText:null!=v?v:null,onInsertConsumed:y,splitIndex:u,onFocus:g,isProcessing:eU,showToast:J,autoYesSlot:(0,r.jsx)(ih.T,{enabled:P,expiresAt:null!=D?D:null,onToggle:O,lastAutoResponse:null!=F?F:null,cliToolName:m,inline:!0})})]}),[eB,eH,e$,eG,eJ,ei.realtimeSnippet,ei.output,ec.session,ei.composerText,ei.isPagerActive,d,m,L,ex,eo.data,eo.messageId,eK,eo.visible,eo.answering,eO,ez,eD,ej,ei.isRunning,eU,v,y,u,g,P,D,F,O,J,ec.diff]),e5=(0,K.sw)(null!=h?h:{cliTool:m}),e3=(0,i.useCallback)(()=>{null==T||T({cliToolId:m,instanceId:L,label:e5})},[T,m,L,e5]),e6=(0,i.useMemo)(()=>{if(!T||!ei.isRunning)return null;let e=Y("terminal.endSessionFor",{name:e5});return(0,r.jsx)(G.m_,{content:e,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:e3,"aria-label":e,"data-testid":"terminal-end-session-button-".concat(u),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)(eN.A,{size:14,"aria-hidden":"true"})})})},[T,ei.isRunning,Y,e5,e3,u]);(0,i.useEffect)(()=>{null==A||A(L,ec)},[A,L,ec]);let e9=sP(E,null,null==(t=ec.session)?void 0:t.agent),e8=sO(ec.session,ec.context,Y,Q),tt=sz(ec.session,ec.context,Y,Q);return(0,r.jsx)(en,{worktreeId:d,splitIndex:u,cliToolId:m,instanceId:L,instance:h,availableInstances:f,onInstanceChange:p,headerExtras:e6,status:w,agentModel:e9,agentUsage:e8,agentUsageDetail:tt,onFocus:g,attaching:ei.attaching,surfaceMode:Z,onSurfaceModeChange:et,isMaximized:M,onToggleMaximize:R,terminal:"chat"===Z?e2:e1,footer:e4,onDropInstance:C,draggedInstanceId:S})}),ib=(0,i.memo)(function(e){var t;let{task:n,latestRun:a,latestRunGates:s,onOpen:l,className:o=""}=e,d=(0,c.c)("worktree"),[u,m]=(0,i.useState)(!1),x=(0,i.useRef)(null),h=(0,i.useId)(),f=function(e,t){var n;let a=(0,i.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,s),p=(0,i.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))),f&&f.length>0){let t=f.filter(e=>a6.includes(e.status));e.push(t.length>0?d("verification.chip.failingGates",{gates:t.map(e=>e.gateId).join(", ")}):d("verification.chip.gatesPassed",{count:f.length}))}}else e.push(d("verification.chip.noRun"));return e.push(d("verification.chip.openHint")),e},[n,a,f,d]),g=p.join(" \xb7 "),b=(0,i.useCallback)(()=>{m(!1),l()},[l]),v=(0,i.useCallback)(()=>{m(e=>!e)},[]);return(0,i.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(o).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)(a0.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)(a1.E,{variant:a4[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)(a1.E,{variant:a?a5[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":h,"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)(k.A,{size:14,"aria-hidden":"true"})})]}),u&&(0,r.jsxs)("div",{id:h,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))})]})]})}),iv=(0,i.memo)(function(e){let{isBranchMismatch:t,currentBranch:n,initialBranch:a}=e,s=(0,c.c)("worktree"),[l,o]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{o(!1)},[n]),!t||l||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)(n7.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:[s("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:a})," ",s("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>o(!0),className:"p-1 rounded hover:bg-warning-subtle transition-colors","aria-label":s("branchMismatch.dismiss"),children:(0,r.jsx)(eN.A,{className:"w-4 h-4"})})]})});var iy=n(58734);let ij=(0,i.memo)(function(e){let{isOpen:t,onClose:n,onConfirm:a,worktreeId:s,sourcePath:l,sourceType:o}=e,d=(0,c.c)("worktree"),u=(0,c.c)("common"),[x,h]=(0,i.useState)(""),[f,p]=(0,i.useState)(new Set([""])),[g,b]=(0,i.useState)([]),[v,y]=(0,i.useState)(!1),[w,k]=(0,i.useState)(new Set),N=l.includes("/")?l.substring(0,l.lastIndexOf("/")):"";(0,i.useEffect)(()=>{t&&(h(N),p(new Set([""])),b([]),C())},[t,s]);let C=(0,i.useCallback)(async()=>{y(!0);try{let e=await fetch("/api/worktrees/".concat(s,"/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)}},[s]),S=(0,i.useCallback)(async e=>{k(t=>new Set(t).add(e));try{let t=await fetch("/api/worktrees/".concat(s,"/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{k(t=>{let n=new Set(t);return n.delete(e),n})}},[s]),I=(0,i.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 S(e)},[g,S]),T=(0,i.useCallback)(e=>!(e===N||"directory"===o&&(e===l||e.startsWith(l+"/")))&&!0,[N,l,o]),E=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=f.has(e.path),a=x===e.path,s=w.has(e.path),l=T(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&&h(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),I(e.path)},children:s?(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}):(0,r.jsx)(al.A,{className:"w-3 h-3 text-muted-foreground transition-transform ".concat(n?"rotate-90":"")})}),n?(0,r.jsx)(iy.A,{className:"w-4 h-4 text-warning flex-shrink-0"}):(0,r.jsx)(j.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=>E(e,t+1))})]},e.path)},A=T(x);return(0,r.jsx)(e3.a,{isOpen:t,onClose:n,title:d("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:[d("fileTree.moveTo"),": ",(0,r.jsx)("span",{className:"font-mono text-foreground",children:l})]}),(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(T("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{T("")&&h("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(j.A,{className:"w-4 h-4 text-warning flex-shrink-0"}),(0,r.jsx)("span",{children:d("fileTree.rootDirectory")})]}),v?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(m.y$,{size:"md",variant:"muted"})}):g.map(e=>E(e,1))]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(m.$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:u("cancel")}),(0,r.jsx)(m.$n,{variant:"ghost",onClick:()=>a(x),disabled:!A,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:d("fileTree.moveConfirm")})]})]})})});function iw(e,t){let n=e.trim();return n?0>=n.lastIndexOf(".")?n+t:n:""}let ik=(0,i.memo)(function(e){let{isOpen:t,parentPath:n,onConfirm:a,onCancel:s}=e,l=(0,c.c)("worktree"),o=(0,c.c)("common"),[d,u]=(0,i.useState)(""),[m,x]=(0,i.useState)(".md"),h=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(t){u(""),x(".md");let e=setTimeout(()=>{var e;null==(e=h.current)||e.focus()},100);return()=>clearTimeout(e)}},[t]);let f=(0,i.useCallback)(()=>{let e=iw(d,m);e&&a(e)},[d,m,a]),p=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),f())},[f]),g=iw(d,m),b=n?"".concat(n,"/").concat(g):g;return(0,r.jsx)(e3.a,{isOpen:t,onClose:s,title:l("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:l("newFileDialog.fileNameLabel")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{ref:h,id:"new-file-name","data-testid":"new-file-name-input",type:"text",value:d,onChange:e=>u(e.target.value),onKeyDown:p,placeholder:l("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:ej.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:s,className:"px-4 py-2 text-sm font-medium text-foreground bg-muted hover:bg-muted/80 rounded-lg transition-colors",children:o("cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"new-file-confirm-button",onClick:f,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:l("newFileDialog.create")})]})]})})}),iN=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeId:o,worktree:d,worktreeName:u,worktreeStatus:m,instances:x,rosterReady:h,activeInstanceId:f,setActiveInstanceId:p,hasUpdate:g,lastAutoResponse:b,activeActivity:v,onActivityToggle:y,onActivityOpen:j,verification:w,onBackClick:k,onInfoClick:N,onWorktreeStatusChange:C,pendingInsertTextMap:S,setFocusedSplitIndex:I,handleInsertToSplit:E,handleInsertConsumed:A,handleInsertToMessage:M,autoYesStateMap:R,makeAutoYesToggleHandler:L,showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onMessageSent:V,onFilePathClick:B,showToast:U,tabsState:W,tabsActions:H,onLoadContent:K,onLoadError:$,onSetLoading:q,onFilePanelSave:G,onDirtyChange:J,onOpenFile:Y,diffContent:Q,diffFilePath:X,onCloseDiff:Z,fileSearch:ee,fileTreeRefresh:et,onFileSelect:en,onNewFile:ea,onNewDirectory:er,onRename:es,onDelete:el,onUpload:ei,onMove:eo,onFileTreeReset:ec,onDiffSelect:ed,onAgentInstancesChange:eu,vibeLocalModel:em,onVibeLocalModelChange:ex,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ef,isInfoModalOpen:ep,onInfoModalClose:eg,onWorktreeUpdate:eb,fileInputRef:ev,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,eV=(0,c.c)("worktree"),[eB,eU]=i.useState(null),eW=(0,i.useCallback)(e=>eU(e),[]),eH=(0,i.useCallback)(()=>eU(null),[]),eK=(0,i.useMemo)(()=>s_(null==d?void 0:d.sessionStatusByInstance),[null==d?void 0:d.sessionStatusByInstance]),[e$,eq]=(0,i.useState)({}),eG=(0,i.useCallback)((e,t)=>{eq(n=>n[e]===t?n:{...n,[e]:t})},[]),[eJ,eY]=i.useState(null),eQ=i.useRef(0),eX=(0,i.useCallback)(e=>{p(e),eQ.current+=1,eY({instanceId:e,token:eQ.current})},[p]),eZ=(0,i.useCallback)(()=>{j("verification")},[j]),e0=(0,i.useCallback)(e=>{var t,n,a,s,l,i,c,u,m,x;let{splitIndex:h,cliToolId:f,instanceId:g,instance:v,availableInstances:y,onInstanceChange:j,onFocus:w,onDropInstance:k,isMaximized:N,onToggleMaximize:C}=e,I=null!=(c=S.get(h))?c:null,T=R.get(g),M=null!=(u=null==T?void 0:T.enabled)&&u,W=null!=(m=null==T?void 0:T.expiresAt)?m:null,H=(0,e6.kA)(null!=(x=null==d||null==(t=d.sessionStatusByInstance)?void 0:t[g])?x:null==d||null==(n=d.sessionStatusByCli)?void 0:n[f]);return(0,r.jsx)(ig,{worktreeId:o,splitIndex:h,cliToolId:f,instanceId:g,instance:v,availableInstances:y,onInstanceChange:e=>{j(e),0===h&&p(e)},onFocus:w,pendingInsertText:I,onInsertConsumed:()=>A(h),onMessageSent:V,cliStatus:H,onAgentSessionChange:eG,agentModel:sP(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:M,expiresAt:W,lastAutoResponse:b,onToggle:L(f,g)},history:{showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onInsertToMessage:e=>E(h,e),onFilePathClick:B,showToast:U},onDropInstance:k,draggedInstanceId:eB,isMaximized:N,onToggleMaximize:C,onRequestSessionEnd:ek})},[o,S,R,A,V,p,b,L,null==d?void 0:d.sessionStatusByCli,null==d?void 0:d.sessionStatusByInstance,B,U,E,P,D,F,O,z,_,eB,ek,eG]),e1=(0,i.useMemo)(()=>(0,r.jsx)(l6,{worktreeId:o,instances:x,rosterReady:h,renderPane:e0,onFocusedSplitChange:I,showToast:U,onActiveInstanceChange:p,headerInstanceSelection:eJ}),[o,x,h,e0,I,U,p,eJ]),e2=(0,i.useMemo)(()=>(0,r.jsx)(lB,{terminal:e1,terminalHeader:null,fileTabs:W,worktreeId:o,onCloseTab:H.closeTab,onActivateTab:H.activateTab,onLoadContent:K,onLoadError:$,onSetLoading:q,onFileSaved:G,diffContent:Q,diffFilePath:X,onCloseDiff:Z,onDirtyChange:J,onMoveToFront:H.moveToFront,onOpenFile:Y}),[e1,W,o,H.closeTab,H.activateTab,K,$,q,G,Q,X,Z,J,H.moveToFront,Y]),e4=(0,i.useMemo)(()=>(0,r.jsx)(s7,{active:v,onToggle:y}),[v,y]),e5=(0,i.useMemo)(()=>{var e;return{files:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(nc,{query:ee.query,mode:ee.mode,isSearching:ee.isSearching,error:ee.error,onQueryChange:ee.setQuery,onModeChange:ee.setMode,onClear:ee.clearSearch}),(0,r.jsx)(nr,{worktreeId:o,onFileSelect:en,onNewFile:ea,onNewDirectory:er,onRename:es,onDelete:el,onUpload:ei,onMove:eo,onResetView:ec,refreshTrigger:et,pollingEnabled:"files"===v,searchQuery:ee.query,searchMode:ee.mode,searchResults:null==(e=ee.results)?void 0:e.results,className:"flex-1 min-h-0"})]}),git:(0,r.jsx)(sE,{worktreeId:o,onDiffSelect:ed,isMobile:!1,worktree:null!=d?d:void 0,onInsertToMessage:M,className:"h-full"}),notes:(0,r.jsx)(ng,{worktreeId:o,className:"h-full",onInsertToMessage:M}),schedules:(0,r.jsx)(nZ,{worktreeId:o,className:"h-full",onInsertToMessage:M,instances:x}),agent:(0,r.jsx)(ab,{worktreeId:o,instances:x,onInstancesChange:eu,vibeLocalModel:em,onVibeLocalModelChange:ex,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ef,modelByInstance:eK,className:"h-full"}),timer:(0,r.jsx)(aI,{worktreeId:o,instances:x}),todo:(0,r.jsx)(nw,{worktreeId:o,className:"h-full"}),skills:(0,r.jsx)(aX,{worktreeId:o,className:"h-full"}),verification:(0,r.jsx)(rE,{state:w,className:"h-full"}),env:(0,r.jsx)(r1,{worktreeId:o,className:"h-full"})}},[o,d,v,ee.query,ee.mode,ee.isSearching,ee.error,ee.setQuery,ee.setMode,ee.clearSearch,null==(t=ee.results)?void 0:t.results,en,ea,er,es,el,ei,eo,ec,et,ed,M,x,eu,em,ex,eh,ef,eK,w]),e9=(0,i.useMemo)(()=>null===v?null:(0,r.jsx)(ln,{active:v,activities:e5}),[v,e5]);return(0,r.jsx)(T.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex h-full overflow-hidden relative",children:[e4,(0,r.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 min-w-0",children:[(0,r.jsx)(sU,{worktreeName:u,repositoryName:null!=(s=null!=(a=null==d?void 0:d.repositoryDisplayName)?a:null==d?void 0:d.repositoryName)?s:eV("detail.unknownRepository"),description:null==d?void 0:d.description,status:m,gitStatus:null==d?void 0:d.gitStatus,onBackClick:k,onInfoClick:N,hasUpdate:g,worktreeStatus:null!=(l=null==d?void 0:d.status)?l:null,onWorktreeStatusChange:C,sessionStatusByCli:null==d?void 0:d.sessionStatusByCli,sessionStatusByInstance:null==d?void 0:d.sessionStatusByInstance,instances:x,activeInstanceId:f,onActiveInstanceChange:eX,onAgentDragStart:eW,onAgentDragEnd:eH,onKillSession:ew,agentSessionByInstance:e$,verificationChip:(0,r.jsx)(ib,{task:w.task,latestRun:w.latestRun,latestRunGates:null!==w.selectedRun&&w.selectedRun.id===(null==(n=w.latestRun)?void 0:n.id)?w.selectedRun.gates:null,onOpen:eZ})}),(null==d?void 0:d.gitStatus)&&(0,r.jsx)(iv,{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)(sq,{activityPane:e9,rightPane:(0,r.jsx)(sG.cV,{terminal:e2})})})]}),(0,r.jsx)(sW,{worktreeId:o,worktree:d,isOpen:ep,onClose:eg,onWorktreeUpdate:eb}),(0,r.jsx)("input",{ref:ev,type:"file",accept:ey.join(","),onChange:ej,className:"hidden","aria-label":eV("detail.uploadFile")}),(0,r.jsx)(e3.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)(ij,{isOpen:eE,onClose:eA,onConfirm:eM,worktreeId:o,sourcePath:eT.path,sourceType:eT.type}),(0,r.jsx)(ik,{isOpen:eR,parentPath:eL,onConfirm:eP,onCancel:eD})]})})});K.oo;var iC=n(51434);function iS(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:{...$.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:{...$.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 iI(e,t){try{window.localStorage.setItem(s9(e),null!=t?t:s6)}catch(e){}}function iT(e,t){if(e.length!==t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}function iE(e,t){return e instanceof Error&&e.message?e.message:t}function iA(e){return e instanceof DOMException&&"AbortError"===e.name}var iM=n(88731);let iR="commandmate:showArchived",iL="activeCliTab-",iP="activeInstanceId-",iD=[2e3,5e3,1e4],iF={timeoutMs:li.K3,retries:0};function iO(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center h-full bg-surface text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}let iz=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(iO,{})}),i_=(0,i.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)(u.y,{size:"xs"}),(0,r.jsx)("span",{children:t})]})}),iV=(0,i.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)(el.$,{variant:"primary",type:"button",onClick:a,className:"mt-4","data-testid":"worktree-detail-relogin",children:n})]})})}),iB=()=>{},iU=["terminal","history","files","memo","info"],iW=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,onMessageSent:s,isSessionRunning:l,isProcessing:i,showToast:o,pendingInsertText:c,onInsertConsumed:d,autoYesSlot:u}=e,m=tw({cliToolId:n,instanceId:a});return(0,r.jsx)(er.E,{worktreeId:t,onMessageSent:s,cliToolId:n,instanceId:a,isSessionRunning:l,isProcessing:i,showToast:o,pendingInsertText:c,onInsertConsumed:d,onOptimisticSend:m,autoYesSlot:u})}),iH=(0,i.memo)(function(e){var t,n,a,l,o,u,m,h,p,g,v,y;let{worktreeId:j}=e,{activeActivity:w,activeCliTab:k,activeInstanceId:N,activeTab:C,agentInstances:E,autoYesEnabled:A,autoYesExpiresAt:M,autoYesStateMap:L,diffContent:D,diffFilePath:F,disableAutoFollow:O,displayedInstances:z,editorFilePath:_,error:V,fetchCurrentOutput:B,fileInputRef:U,fileSearch:W,fileTreeRefresh:H,handleActivityOpen:q,handleActivityToggle:G,handleAgentInstancesChange:Y,handleAutoYesToggle:Q,handleBackClick:X,handleCloseDiff:Z,handleDelete:ee,handleDiffSelect:et,handleDirtyChange:en,handleEditorClose:er,handleEditorSave:el,handleFileInputChange:eo,handleFilePanelSave:ec,handleFilePathClick:ed,handleFileSelect:eu,handleHistoryDisplayLimitChange:em,handleHistoryUserOnlyChange:ex,handleInfoClick:eh,handleInfoModalClose:ef,handleInsertConsumed:ep,handleInsertConsumedSingle:eg,handleInsertToMessage:eb,handleInsertToSplit:ej,handleKillCancel:ew,handleKillConfirm:ek,openKillConfirm:eN,openActiveKillConfirm:eC,killTarget:eS,isKillPending:eI,handleLoadContent:eT,handleLoadError:eA,handleMessageSent:eM,handleMobileFileViewerClose:eR,handleMobileTabChange:eL,handleMove:eP,handleMoveCancel:eD,handleMoveConfirm:eF,handleNewDirectory:eO,handleNewFile:ez,handleNewFileCancel:e_,handleNewFileConfirm:eV,handleOpenFile:eB,handlePromptDismiss:eW,handlePromptRespond:eH,handleRename:eK,handleReLogin:eG,handleRetry:eY,handleSetLoading:eQ,handleShowArchivedChange:eX,handleUpload:eZ,handleVibeLocalContextWindowChange:e0,handleVibeLocalModelChange:e1,handleWorktreeStatusChange:e2,hasUpdate:e4,historyDisplayLimit:e5,historySubTab:e9,historyUserOnly:e8,isAuthExpired:e7,isEditorMaximized:te,isInfoModalOpen:tt,isMobile:tn,isMoveDialogOpen:ta,isReconnecting:tr,isSelectionListActive:ts,isPagerActive:tl,lastAutoResponse:ti,loading:to,makeAutoYesToggleHandler:tc,mobileFileViewerPath:td,mobileSelectedAgents:tu,moveTarget:tm,newFileParentPath:tx,openMobileDrawer:th,pendingInsertText:tf,pendingInsertTextMap:tp,rosterReady:tg,setActiveInstanceId:tb,setFocusedSplitIndex:tv,setHistorySubTab:ty,setIsEditorMaximized:tw,setWorktree:tC,showArchived:tS,showNewFileDialog:tI,showToast:tT,state:tE,tCommon:tA,tWorktree:tM,tabsActions:tR,tabsState:tL,resetFileTreeView:tP,toggleInstanceVisible:tD,verification:tF,vibeLocalContextWindow:tO,vibeLocalModel:tz,visibleInstanceIds:t_,worktree:tV,worktreeName:tB,worktreeStatus:tU}=function(e){var t,n,a,r,l,o,d,u,m,x;let{worktreeId:h}=e,p=(0,s.useRouter)(),g=(0,ns.a)(),b=(0,i.useRef)(g);b.current=g;let{openMobileDrawer:v}=(0,s8.VF)(),{state:y,actions:j}=function(){let[e,t]=(0,i.useReducer)(iS,void 0,$.mR),{value:n,setValue:a}=(0,r5.V)({key:"commandmate.worktree.leftPaneCollapsed",defaultValue:!1,validate:e=>"boolean"==typeof e}),r=(0,i.useRef)(e.layout.leftPaneCollapsed);r.current=e.layout.leftPaneCollapsed;let s=(0,i.useRef)(!1);(0,i.useEffect)(()=>{s.current||(s.current=!0,n!==r.current&&t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:n}))},[n]);let l=(0,i.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:l}}(),w=(0,c.c)("worktree"),k=(0,c.c)("error"),N=(0,c.c)("common"),C=(0,c.c)("autoYes"),S=(0,ei.SC)(),T=(0,J.rC)(),E=null!=(l=null==T?void 0:T.worktrees.find(e=>e.id===h))?l:null,[A,M]=(0,i.useState)(E),[R,L]=(0,i.useState)(null===E),[P,D]=(0,i.useState)(null),[F,O]=(0,i.useState)(!1),[z,_]=(0,i.useState)(!1),[V,B]=(0,i.useState)(0),U=(0,i.useRef)(0),W=(0,i.useRef)(0),H=(0,i.useRef)(null),q=(0,i.useRef)(async()=>null),G=(0,i.useCallback)(()=>{null!==H.current&&(clearTimeout(H.current),H.current=null)},[]),Y=(0,i.useRef)(null!==E),[Q,X]=(0,i.useState)(!1),[Z,ee]=function(e){let[t,n]=(0,i.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:lI(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=lT(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=lT(t.tabs,n.path,e=>({...e,loading:n.loading}));if(!e)return t;return{...t,tabs:e}}case"SET_ERROR":{let e=lT(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:lI(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:lI(e),content:null,loading:!1,error:null,isDirty:!1}));if(0===e.length)return lA;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=lT(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 lA;case"CLOSE_OTHERS":case"CLOSE_TO_RIGHT":{let e="CLOSE_OTHERS"===n.type?"others":"right",a=new Set(lE(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}},lA),a=(0,i.useRef)(!1),r=(0,i.useRef)(e);(0,i.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(lS+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,i.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(lS+e,JSON.stringify(a))}catch(e){}}},[e,t]);let s=(0,i.useRef)(t);s.current=t;let l=(0,i.useCallback)(e=>{let t=s.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,i.useCallback)(e=>{n({type:"CLOSE_TAB",path:e})},[]),c=(0,i.useCallback)(e=>{n({type:"ACTIVATE_TAB",path:e})},[]),d=(0,i.useCallback)((e,t)=>{n({type:"RENAME_FILE",oldPath:e,newPath:t})},[]),u=(0,i.useCallback)(e=>{n({type:"DELETE_FILE",path:e})},[]),m=(0,i.useCallback)(e=>{n({type:"MOVE_TO_FRONT",path:e})},[]),x=(0,i.useCallback)(()=>{n({type:"CLOSE_ALL"})},[]),h=(0,i.useCallback)(e=>{n({type:"CLOSE_OTHERS",path:e})},[]),f=(0,i.useCallback)(e=>{n({type:"CLOSE_TO_RIGHT",path:e})},[]),p=(0,i.useMemo)(()=>({dispatch:n,openFile:l,closeTab:o,activateTab:c,onFileRenamed:d,onFileDeleted:u,moveToFront:m,closeAllTabs:x,closeOtherTabs:h,closeTabsToRight:f}),[n,l,o,c,d,u,m,x,h,f]);return[t,p]}(h),[et,en]=(0,i.useState)(null),[ea,er]=(0,i.useState)(null),[es,el]=(0,i.useState)(!1),[eo,ec]=(0,i.useState)(new Map),[ed,eu]=(0,i.useState)(null),[em,ex]=(0,i.useState)(!1),[eh,ef]=(0,i.useState)(!1),[ep,eg]=(0,i.useState)(!1),eb=(0,i.useRef)(!1),[ej,ew]=(0,i.useState)(null),[ek,eN]=(0,i.useState)(ad.sA),eC=(0,i.useRef)(ek);eC.current=ek;let eS=(0,i.useRef)(A);eS.current=A;let[eI,eT]=(0,i.useState)(()=>(0,K.lu)((0,ad.sA)())),eA=(0,i.useRef)(eI);eA.current=eI;let[eM,eR]=(0,i.useState)(null),eL=eM===h,[eP,eD]=(0,i.useState)(null),[eF,eO]=(0,i.useState)(null),[ez,e_]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(iL+h);if(e&&(0,K.hR)(e))return e}catch(e){}return(0,ad.sA)()[0]}),eV=(0,i.useCallback)(e=>{e_(e);try{window.localStorage.setItem(iL+h,e)}catch(e){}},[h]),eB=(0,i.useRef)(ez);eB.current=ez;let[eU,eW]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(iP+h);if(e&&(0,K.n6)(e))return e;let t=window.localStorage.getItem(iL+h);if(t&&(0,K.hR)(t))return t}catch(e){}return(0,ad.sA)()[0]}),eH=(0,i.useCallback)(e=>{eW(e);try{window.localStorage.setItem(iP+h,e)}catch(e){}let t=eA.current.find(t=>t.id===e);t&&eV(t.cliTool)},[h,eV]),eK=(0,i.useRef)(eU);eK.current=eU;let eG=(0,i.useRef)(0),eY=(0,i.useRef)(0),eQ=(0,i.useRef)(0),eX=null!=(o=null==(t=eo.get(eU))?void 0:t.enabled)&&o,eZ=null!=(d=null==(n=eo.get(eU))?void 0:n.expiresAt)?d:null,[e0,e1]=(0,i.useState)(0),[e2,e4]=(0,i.useState)(!1),[e5,e3]=(0,i.useState)(""),{active:e6,setActive:e9,toggle:e8}=function(e){let[t,n]=(0,i.useState)(s3),a=(0,i.useRef)(t);a.current=t;let r=(0,i.useRef)(e);return r.current=e,(0,i.useEffect)(()=>{let t=function(e){try{let t=window.localStorage.getItem(s9(e));if(t===s6)return null;if(t&&"string"==typeof t&&s5.has(t))return t}catch(e){}return s3}(e);t!==a.current&&n(t)},[e]),{active:t,setActive:(0,i.useCallback)(e=>{n(e),iI(r.current,e)},[]),toggle:(0,i.useCallback)(e=>{if(a.current===e){n(null),iI(r.current,null);return}n(e),iI(r.current,e)},[])}}(h),{historySubTab:e7,setHistorySubTab:te,showArchived:tt,handleShowArchivedChange:tn,historyUserOnly:ta,handleHistoryUserOnlyChange:tr,historyDisplayLimit:ts,handleHistoryDisplayLimitChange:tl}=function(){let[e,t]=(0,i.useState)("message"),[n,a]=(0,i.useState)(()=>"true"===localStorage.getItem(iR)),r=(0,i.useCallback)(e=>{a(e),localStorage.setItem(iR,String(e))},[]),[s,l]=(0,i.useState)(()=>{try{return"true"===localStorage.getItem(iM.gP)}catch(e){return!1}}),o=(0,i.useCallback)(e=>{l(e);try{localStorage.setItem(iM.gP,String(e))}catch(e){}},[]),[c,d]=(0,i.useState)(()=>{try{let e=localStorage.getItem(iM.wP);if(null===e)return iM.v8;let t=parseInt(e,10);return(0,iM.UK)(t)?t:iM.v8}catch(e){return iM.v8}});return{historySubTab:e,setHistorySubTab:t,showArchived:n,handleShowArchivedChange:r,historyUserOnly:s,handleHistoryUserOnlyChange:o,historyDisplayLimit:c,handleHistoryDisplayLimitChange:(0,i.useCallback)(e=>{d(e);try{localStorage.setItem(iM.wP,String(e))}catch(e){}},[])}}(),ti=(0,i.useRef)(tt);(0,i.useEffect)(()=>{ti.current=tt},[tt]);let to=(0,i.useRef)(ts);(0,i.useEffect)(()=>{to.current=ts},[ts]),(0,i.useEffect)(()=>{(0,ad.qD)()},[]);let{pendingInsertTextMap:tc,pendingInsertText:td,setFocusedSplitIndex:tu,handleInsertToMessage:tm,handleInsertToSplit:tx,handleInsertConsumed:th,handleInsertConsumedSingle:tf}=function(){var e;let[t,n]=(0,i.useState)(()=>new Map),[a,r]=(0,i.useState)(0),s=(0,i.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(a,e),n})},[a]),l=(0,i.useCallback)((e,t)=>{n(n=>{let a=new Map(n);return a.set(e,t),a})},[]),o=(0,i.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,i.useCallback)(()=>o(0),[o]);return{pendingInsertTextMap:t,pendingInsertText:c,focusedSplitIndex:a,setFocusedSplitIndex:r,handleInsertToMessage:s,handleInsertToSplit:l,handleInsertConsumed:o,handleInsertConsumedSingle:d}}(),{diffContent:tp,diffFilePath:tg,handleDiffSelect:tb,handleCloseDiff:tv}=function(e){let[t,n]=(0,i.useState)(null),[a,r]=(0,i.useState)(null);return{diffContent:t,diffFilePath:a,handleDiffSelect:(0,i.useCallback)((t,a)=>{e||(n(t),r(a))},[e]),handleCloseDiff:(0,i.useCallback)(()=>{n(null),r(null)},[])}}(g),ty=function(e){let{worktreeId:t,initialMode:n="name",debounceMs:a=300}=e,[r,s]=(0,i.useState)(""),[l,o]=(0,i.useState)(""),[c,d]=(0,i.useState)(n),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(null),[p,g]=(0,i.useState)(null),b=(0,i.useRef)(null),v=(0,i.useMemo)(()=>(0,f.sg)(e=>{o(e)},a),[a]),y=(0,i.useCallback)(e=>{s(e),v(e),g(null)},[v]),j=(0,i.useCallback)(()=>{s(""),o(""),h(null),g(null),m(!1),b.current&&(b.current.abort(),b.current=null)},[]),w=(0,i.useCallback)(e=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[l]),k=(0,i.useCallback)(()=>x&&0!==x.results.length?(0,f.q3)(x.results.map(e=>e.filePath)):new Set,[x]);return(0,i.useEffect)(()=>{if("content"!==c||!l.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(l),"&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:l,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,l,t]),(0,i.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}),tj=(0,i.useRef)(!1),tw=(0,i.useRef)(h);(0,i.useEffect)(()=>{tw.current!==h&&(j.clearMessages(),tj.current=!1,ec(new Map),U.current=0,W.current=0,G(),O(!1),tw.current=h)},[h,j,G]);let tk=(0,i.useCallback)(async()=>{try{var e,t;let n=await (0,eq.E)("/api/worktrees/".concat(h),iF),a=(0,eq.O0)(n);if(a)throw a;if(!n.ok)throw new eq.hD("Failed to fetch worktree: ".concat(n.status),n.status);let r=(0,eq.xd)(n);if(r)throw r;let s=await n.json();if(M(s),s.selectedAgents){let e=eC.current;s.selectedAgents.length===e.length&&s.selectedAgents.every((t,n)=>t===e[n])||eN(s.selectedAgents)}if(s.agentInstances){let e=eA.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)||eT(t),eR(h)}return"vibeLocalModel"in s&&eD(null!=(e=s.vibeLocalModel)?e:null),"vibeLocalContextWindow"in s&&eO(null!=(t=s.vibeLocalContextWindow)?t:null),U.current=0,W.current=0,G(),O(!1),_(!1),D(null),s}catch(a){let e=a instanceof Error?a.message:"Unknown error",t=a instanceof eq.hD?a.status:0;if(U.current+=1,401===t)return _(!0),O(!1),D(null),null;if(null!==eS.current)return U.current>=3&&O(!0),console.error("[WorktreeDetailRefactored] Error fetching worktree:",a),null;D(e);let n=W.current;return n<iD.length&&(W.current=n+1,G(),H.current=setTimeout(()=>{H.current=null,q.current()},iD[n])),null}},[h,G]);q.current=tk;let tN=(0,i.useCallback)(async()=>{let e=eB.current,t=b.current,n=eK.current,a=++eG.current;try{let r=new URLSearchParams({cliTool:e,unit:"pairs"});t&&r.set("instance",n),ti.current&&r.set("includeArchived","true"),r.set("limit",String(to.current));let s=await (0,eq.E)("/api/worktrees/".concat(h,"/messages?").concat(r.toString()),iF);if(!s.ok)throw Error("Failed to fetch messages: ".concat(s.status));let l=await s.json();if(eG.current!==a||eB.current!==e||t&&eK.current!==n)return;j.setMessages(l.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(r){if(eG.current!==a||eB.current!==e||t&&eK.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching messages:",r)}},[h,j]),tC=(0,i.useCallback)(async()=>{let e=eB.current,t=b.current,n=eK.current,a=++eY.current;try{var r,s,l,i;let o=t?"/api/worktrees/".concat(h,"/current-output?cliTool=").concat(e,"&instance=").concat(encodeURIComponent(n)):"/api/worktrees/".concat(h,"/current-output?cliTool=").concat(e),c=await (0,eq.E)(o,iF);if(!c.ok)return;let d=await c.json();if(eY.current!==a||eB.current!==e||t&&eK.current!==n||d.cliToolId&&d.cliToolId!==e)return;if(d.isPromptWaiting&&d.promptData?j.showPrompt(d.promptData,"prompt-".concat(Date.now())):!d.isPromptWaiting&&y.prompt.visible&&j.clearPrompt(),ef(null!=(r=d.isSelectionListActive)&&r),eg(null!=(s=d.isPagerActive)&&s),eu(null!=(l=d.lastServerResponseTimestamp)?l:null),ex(null!=(i=d.serverPollerActive)&&i),d.autoYes){let a=eb.current,r=d.autoYes,s=t?n:e;ec(e=>{let t=new Map(e);return t.set(s,{enabled:r.enabled,expiresAt:r.expiresAt}),t}),eb.current=r.enabled,a&&!d.autoYes.enabled&&("stop_pattern_matched"===d.autoYes.stopReason||"consecutive_errors"===d.autoYes.stopReason)&&ew(d.autoYes.stopReason)}}catch(r){if(eY.current!==a||eB.current!==e||t&&eK.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching current output:",r)}},[h,j,y.prompt.visible]),tS=(0,i.useCallback)(async()=>{let e=++eQ.current;try{let a=await (0,eq.E)("/api/worktrees/".concat(h,"/auto-yes"),iF);if(!a.ok)return;let r=await a.json();if(eQ.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})}ec(l)}catch(t){if(eQ.current!==e)return;console.error("[WorktreeDetailRefactored] Error fetching auto-yes states:",t)}},[h]),{visibleInstances:tI,visibleInstanceIds:tT,toggleInstanceVisible:tE}=function(e){let{worktreeId:t,roster:n}=e,[a,r]=(0,i.useState)(null);(0,i.useEffect)(()=>{r(function(e){try{let t=window.localStorage.getItem(n6(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 s=(0,i.useMemo)(()=>n9(a,n),[a,n]),l=(0,i.useMemo)(()=>s.map(e=>e.id),[s]),o=(0,i.useMemo)(()=>null!==a&&n.some(e=>a.includes(e.id)),[a,n]),c=(0,i.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(n6(t),JSON.stringify(s))}catch(e){}}},[n,t]),d=(0,i.useCallback)(e=>c(e),[c]);return{visibleInstances:s,visibleInstanceIds:l,hasStoredPreference:o,toggleInstanceVisible:(0,i.useCallback)(e=>{let t=n9(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,i.useCallback)(e=>{null!==a&&c([...n9(a,n).map(e=>e.id),...e])},[a,n,c])}}({worktreeId:h,roster:eI}),tA=g?tI:eI,tM=(0,i.useMemo)(()=>Array.from(new Set(tI.map(e=>e.cliTool))),[tI]),tR=g?tM:ek;(0,i.useEffect)(()=>{0!==tA.length&&(tA.some(e=>e.id===eU)||eH(tA[0].id))},[tA,eU,eH]),(0,i.useEffect)(()=>{let e=tA.find(e=>e.id===eU);e&&e.cliTool!==ez&&eV(e.cliTool)},[tA,eU,ez,eV]);let tL="opencode"===ez||"copilot"===ez,tP=(0,i.useCallback)(e=>{eN(e)},[]),tD=(0,i.useCallback)(e=>{eT(e),eR(h)},[h]),tF=(0,i.useCallback)(e=>{eD(e)},[]),tO=(0,i.useCallback)(e=>{eO(e)},[]),tz=(0,i.useRef)(ez);(0,i.useEffect)(()=>{tz.current!==ez&&(tz.current=ez,j.clearMessages(),j.clearPrompt(),ef(!1),tN(),tC())},[ez,j,tN,tC]),(0,i.useEffect)(()=>{tN()},[tt,tN]),(0,i.useEffect)(()=>{tN()},[ts,tN]);let{showToast:t_}=(0,e$.dj)(),tV=(0,i.useCallback)(()=>{t_("Maximum ".concat(30," file tabs. Close a tab first."),"info")},[t_]),tB=(0,i.useCallback)(e=>{g?en(e):"limit_reached"===ee.openFile(e)&&tV()},[g,ee,tV]),tU=(0,i.useCallback)(e=>{g?en(e):"limit_reached"===ee.openFile(e)&&tV()},[g,ee,tV]),tW=(0,i.useCallback)(e=>{"limit_reached"===ee.openFile(e)&&tV()},[ee,tV]),tH=(0,i.useCallback)(()=>{en(null)},[]),tK=(0,i.useCallback)(e=>{e1(e=>e+1)},[]),t$=(0,i.useCallback)(()=>{er(null)},[]),tq=(0,i.useCallback)(()=>{ty.clearSearch(),ee.closeAllTabs(),en(null),er(null)},[ty,ee]),tG=(0,i.useCallback)(e=>{e1(e=>e+1)},[]),tJ=(0,i.useCallback)(e=>{e8(e)},[e8]),tY=(0,i.useCallback)(e=>{e9(e)},[e9]),tQ=(0,i.useCallback)(()=>{p.push("/")},[p]),tX=(0,i.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();M(e)}}catch(e){}},[h]),tZ=(0,i.useCallback)(()=>{X(!0)},[]),t0=(0,i.useCallback)(()=>{X(!1)},[]),t1=(0,i.useCallback)(async e=>{j.setPromptAnswering(!0);try{let t=ip(e,ez,(0,I.XF)(y.prompt.data)?y.prompt.data:null,b.current?eK.current:void 0),n=await fetch("/api/worktrees/".concat(h,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error("Failed to send prompt response: ".concat(n.status));let a=await n.json().catch(()=>null);if((null==a?void 0:a.success)===!1){t_(w("promptResponse.refused"),"warning"),await tC();return}j.clearPrompt(),await tC()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{j.setPromptAnswering(!1)}},[h,j,tC,ez,y.prompt.data,t_,w]),t2=(0,i.useCallback)(()=>{j.clearPrompt()},[j]),t4=(0,i.useCallback)(e=>{j.setMobileActivePane(e)},[j]),t5=(0,i.useCallback)(()=>{tN(),tC()},[tN,tC]),t3=(0,i.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();ec(t=>{let n=new Map(t);return n.set(a,{enabled:e.enabled,expiresAt:e.expiresAt}),n}),a===eK.current&&(eb.current=e.enabled)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[h]),t6=(0,i.useCallback)(e=>t3(ez,eU)(e),[t3,ez,eU]),[t9,t8]=(0,i.useState)(null),[t7,ne]=(0,i.useState)(!1),nt=(0,i.useRef)(!1),nn=(0,i.useCallback)(e=>{t8(e)},[]),na=(0,i.useCallback)(()=>{let e=eK.current,t=eB.current,n=(0,K.O6)(eA.current,e,t);t8({cliToolId:t,instanceId:e,label:n})},[]),nr=(0,i.useCallback)(async()=>{if(!t9||nt.current)return;nt.current=!0,ne(!0);let e=()=>{t9.instanceId===eK.current&&(j.clearMessages(),j.clearPrompt())};try{await eq.y.killSession(h,t9.cliToolId,t9.instanceId),e(),await tk(),t8(null)}catch(t){t instanceof eq.hD&&404===t.status?(e(),await tk(),t8(null)):t_(w("session.failedToKill"),"error")}finally{nt.current=!1,ne(!1)}},[t9,h,j,tk,t_,w]),nl=(0,i.useCallback)(()=>{nt.current||t8(null)},[]),ni=(0,i.useCallback)(e=>{e3(e),e4(!0)},[]),no=(0,i.useCallback)(async e=>{e4(!1);let t=e5?"".concat(e5,"/").concat(e):e;try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,eE.o)(t)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");e1(e=>e+1)}catch(e){window.alert(k("fileOps.failedToCreateFile"))}},[h,e5,k]),nc=(0,i.useCallback)(()=>{e4(!1)},[]),nd=(0,i.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,eE.o)(n)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");e1(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(k("fileOps.failedToCreateDirectory"))}},[h,k]),nu=(0,i.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,eE.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):"";ee.onFileRenamed(e,"".concat(t).concat(n)),e1(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(k("fileOps.failedToRename"))}},[h,ee,k]),nm=(0,i.useCallback)(async e=>{let t=e.split("/").pop()||e;if(await S({description:N("confirmDelete",{name:t}),variant:"danger"}))try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,eE.o)(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");(ea===e||(null==ea?void 0:ea.startsWith("".concat(e,"/"))))&&er(null),ee.onFileDeleted(e),e1(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(k("fileOps.failedToDelete"))}},[h,ea,ee,N,k,S]);(0,i.useEffect)(()=>{"stop_pattern_matched"===ej?(t_(C("stopPatternMatched"),"info"),ew(null)):"consecutive_errors"===ej&&(t_(C("consecutiveErrorsStopped"),"warning"),ew(null))},[ej,t_,C]);let{moveTarget:nx,isMoveDialogOpen:nh,handleMove:nf,handleMoveConfirm:np,handleMoveCancel:ng}=function(e,t,n,a){let[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!1),c=(0,i.useCallback)((e,t)=>{s({path:e,type:t}),o(!0)},[]),d=(0,i.useCallback)(async l=>{if(r)try{let s=await fetch("/api/worktrees/".concat(e,"/files/").concat(r.path),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:l})}),o=await s.json();if(!s.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{s(null),o(!1)}},[r,e,t,n,a]);return{moveTarget:r,isMoveDialogOpen:l,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,i.useCallback)(()=>{s(null),o(!1)},[])}}(h,()=>e1(e=>e+1),e=>t_(e,"success"),e=>t_(e,"error")),nb=(0,i.useRef)(null),nv=(0,i.useRef)(""),ny=(0,i.useCallback)(e=>{var t;nv.current=e,null==(t=nb.current)||t.click()},[]),nj=(0,i.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=nv.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 ey.includes(t)}(l))return void t_("Unsupported file type: ".concat(l,". Allowed: ").concat(ey.join(", ")),"error");let i=function(e){var t;let n=function(e){let t=e.toLowerCase();return ev.find(e=>e.extension===t)}(e);return null!=(t=null==n?void 0:n.maxFileSize)?t:0x1400000}(l);if(r.size>i)return void t_("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,eE.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";t_(n,"error");return}let t=await e.json();t_("Uploaded: ".concat(t.filename),"success"),e1(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),t_("Upload failed. Please try again.","error")}},[h,t_]),{data:nw}=eJ(),nk=null!=(u=null==nw?void 0:nw.hasUpdate)&&u,{lastAutoResponse:nN}=function(e){let{worktreeId:t,cliTool:n,isPromptWaiting:a,promptData:r,autoYesEnabled:s,lastServerResponseTimestamp:l,serverPollerActive:o}=e,c=(0,i.useRef)(null),[d,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{var e;if(!a){c.current=null;return}if(!r||!s||!(0,I.XF)(r)||o||l&&Date.now()-l<3e3)return;let i=(e={type:r.type,question:r.question},"".concat(e.type,":").concat(e.question));if(c.current===i)return;let d=function(e,t){let n=function(e){if("yes_no"===e.type)return"y";if("multiple_choice"===e.type){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,aj.P0)(e).valid)return{outcome:"unusable",pattern:e};let t=new RegExp(e);for(let a of n){let n=(0,aj.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===d)return;c.current=i,u(d);let m=ip(d,n,r);fetch("/api/worktrees/".concat(t,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}).catch(e=>{console.error("[useAutoYes] Failed to send auto-response:",e)})},[a,r,s,t,n,l,o]),{lastAutoResponse:d}}({worktreeId:h,cliTool:ez,isPromptWaiting:y.prompt.visible,promptData:y.prompt.data,autoYesEnabled:eX,lastServerResponseTimestamp:ed,serverPollerActive:em}),nC=(0,i.useCallback)(async()=>{D(null),O(!1),_(!1),U.current=0,W.current=0,G(),L(!0),await tk()&&await Promise.all([tN(),tC()]),L(!1)},[tk,tN,tC,G]),nS=(0,i.useCallback)(()=>{window.location.href="/login"},[]);(0,i.useEffect)(()=>G,[G]),function(e){let{error:t,handleRetry:n,fetchWorktree:a,fetchMessages:r,fetchCurrentOutput:s,setError:l}=e,o=(0,i.useRef)(0),c=(0,i.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(),s()])}finally{l(null)}}},[t,n,a,r,s,l]);(0,i.useEffect)(()=>(document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c)}),[c])}({error:P,handleRetry:nC,fetchWorktree:tk,fetchMessages:tN,fetchCurrentOutput:tC,setError:D}),(0,i.useEffect)(()=>{if(tj.current)return;let e=!0;return(async()=>{Y.current||L(!0),await Promise.all([tk(),tN(),tC()]),e&&(L(!1),tj.current=!0)})(),()=>{e=!1}},[tk,tN,tC]);let nI=null!=(m=null==A||null==(r=A.sessionStatusByCli)||null==(a=r[ez])?void 0:a.isRunning)&&m;(0,i.useEffect)(()=>{if(R)return;let e=setInterval(async()=>{let e=[tC(),tk()];g&&e.push(tN()),await Promise.all(e),B(e=>e+1)},nI?2e3:5e3);return()=>clearInterval(e)},[R,tC,tk,tN,nI,g]),(0,i.useEffect)(()=>{tS()},[h,eL,tS]),(0,i.useEffect)(()=>{j.setLayoutMode(g?"tabs":"split")},[g,j]);let nT=(0,i.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"})(A,null!==y.error.type,ez),[A,y.error.type,ez]),nE=(0,i.useMemo)(()=>y.layout.mobileActivePane,[y.layout.mobileActivePane]),nA=null!=(x=null==A?void 0:A.name)?x:"Unknown",nM=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_CONTENT",path:e,content:t})},[ee]),nR=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_ERROR",path:e,error:t})},[ee]),nL=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_LOADING",path:e,loading:t})},[ee]),nP=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_DIRTY",path:e,isDirty:t})},[ee]),nD=function(e){var t,n,a;let{worktreeId:r,refreshToken:s=0,enabled:l=!0,limit:o=10}=e,[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)([]),[x,h]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(!0),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(null),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[I,T]=(0,i.useState)(null),[E,A]=(0,i.useState)(null),[M,R]=(0,i.useState)(null),[L,P]=(0,i.useState)(!1),[D,F]=(0,i.useState)(null),[O,z]=(0,i.useState)(null),[_,V]=(0,i.useState)(!1),[B,U]=(0,i.useState)(null),[W,H]=(0,i.useState)(null),[K,$]=(0,i.useState)(null),[q,G]=(0,i.useState)(o),[J,Y]=(0,i.useState)(o),[Q,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)([]),[et,en]=(0,i.useState)(!1),[ea,er]=(0,i.useState)(null),[es,el]=(0,i.useState)(0),ei=(0,i.useRef)(0),eo=(0,i.useRef)(0),ec=(0,i.useRef)(!1),ed=(0,i.useRef)(!1),eu=(0,i.useRef)(!1),em=(0,i.useRef)(!1),ex=(0,i.useRef)(!1),eh=(0,i.useRef)(!1),ef=(0,i.useRef)(null);ef.current=K;let ep=(0,i.useRef)(o);ep.current=q,ed.current=(null==c?void 0:c.status)==="verifying"||u.some(e=>"running"===e.status),(0,i.useEffect)(()=>{if(ei.current+=1,eo.current=0,ec.current=!1,!eh.current){eh.current=!0;return}d(null),m([]),h(null),p(null),b(!0),y(null),w(null),T(null),A(null),R(null),F(null),z(null),U(null),$(null),G(o),Y(o),H(null)},[r]),(0,i.useEffect)(()=>{if(!l)return;let e=new AbortController,t=!1;return(async()=>{try{let n=await rl(r,e.signal);if(t)return;A(n),R(null)}catch(e){if(t||iA(e))return;A(null),R(iE(e,"Failed to load the verification config"))}})(),()=>{t=!0,e.abort()}},[r,l,es]),(0,i.useEffect)(()=>{if(!l)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([rn(r),ra(r,q)]);if(n!==ei.current)return;d(e),m(t),Y(q),y(null)}catch(e){if(n!==ei.current||iA(e))return;y(iE(e,"Failed to load verification data"))}finally{ec.current=!1,n===ei.current&&(b(!1),ep.current!==q&&(eo.current=0,el(e=>e+1)))}})()},[r,s,es,l,q]);let eg=null!=(n=null!=x?x:null==(t=u[0])?void 0:t.id)?n:null,eb=(0,i.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(s,":").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,s,es]);(0,i.useEffect)(()=>{if(!l||null===eg){p(null),w(null),N(!1);return}let e=new AbortController,t=!1;return N(!0),(async()=>{try{let n=await rr(r,eg,e.signal);if(t)return;p(n),w(null===n?"not-found":null)}catch(e){if(t||iA(e))return;p(null),w(iE(e,"Failed to load the verification run"))}finally{t||N(!1)}})(),()=>{t=!0,e.abort()}},[r,l,eb]),(0,i.useEffect)(()=>{if(!l||!Q)return;let e=new AbortController,t=!1;return en(!0),(async()=>{try{let n=await rc({days:7,limit:20},e.signal);if(t)return;ee(n),er(null)}catch(e){if(t||iA(e))return;er(iE(e,"Failed to load the verification history"))}finally{t||en(!1)}})(),()=>{t=!0,e.abort()}},[l,Q,es]);let ev=(0,i.useMemo)(()=>{var e;return null!=(e=null==E?void 0:E.plannedGateIds)?e:[]},[E]),ey=(0,i.useMemo)(()=>{var e;return(null!=(e=null==f?void 0:f.gates)?e:[]).filter(e=>a6.includes(e.status)).map(e=>e.gateId)},[f]),ej=(0,i.useMemo)(()=>{var e;return null!=(e=u.find(e=>"running"===e.status))?e:null},[u]),ew=(0,i.useCallback)(e=>{$(null===e||iT(e,ev)?null:e)},[ev]),ek=(0,i.useCallback)(e=>{$(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 iT(a,ev)?null:a})},[ev]),eN=(0,i.useCallback)(()=>{let e=ev.filter(e=>ey.includes(e));$(0===e.length||iT(e,ev)?null:e)},[ev,ey]),eC=(0,i.useCallback)(()=>{eo.current=0,G(e=>Math.min(e+10,100))},[]),eS=(0,i.useCallback)(()=>{X(e=>!e)},[]),eI=(0,i.useCallback)(()=>{eo.current=0,el(e=>e+1)},[]),eT=(0,i.useCallback)(e=>{h(e)},[]),eE=(0,i.useCallback)(async e=>{if(!eu.current){eu.current=!0,S(!0),T(null),U(null);try{let t=void 0===e?ef.current:e,n=await rs(r,null!==t&&t.length>0?{gateIds:t}:{});h(n),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof a7&&409===t.status;T({kind:e?"conflict":"error",message:iE(t,"Failed to start verification"),runningRunId:t instanceof a7?t.runningRunId:null}),e&&(eo.current=0,el(e=>e+1))}finally{eu.current=!1,S(!1)}}},[r]),eA=(0,i.useCallback)(async()=>{if(!ex.current&&null!==ej){ex.current=!0,V(!0),U(null);try{let e=await ro(r,ej.id);H("running"===e.status?ej.id:null)}catch(e){U({kind:409===(e instanceof a7?e.status:0)?"gone":"error",message:iE(e,"Failed to cancel the verification run")})}finally{ex.current=!1,V(!1),eo.current=0,el(e=>e+1)}}},[r,ej]),eM=(0,i.useCallback)(async()=>{if(!em.current){em.current=!0,P(!0),F(null);try{let e=await ri(r);z(e),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof a7?t.status:0;F({kind:409===e?"conflict":422===e?"empty":"error",message:iE(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:f,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:K,failedGateIds:ey,toggleGate:ek,setGateSelection:ew,selectFailedGates:eN,runningRun:ej,cancelPending:_,cancelSettling:null!==W&&(null==ej?void 0:ej.id)===W,cancelFailure:B,historyLimit:q,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:V,enabled:!R&&!P});return{activeActivity:e6,activeCliTab:ez,activeInstanceId:eU,activeTab:nE,agentInstances:eI,autoYesEnabled:eX,autoYesExpiresAt:eZ,autoYesStateMap:eo,diffContent:tp,diffFilePath:tg,disableAutoFollow:tL,displayedAgents:tR,displayedInstances:tA,editorFilePath:ea,error:P,fetchCurrentOutput:tC,fileInputRef:nb,fileSearch:ty,fileTreeRefresh:e0,handleActivityOpen:tY,handleActivityToggle:tJ,handleAgentInstancesChange:tD,handleAutoYesToggle:t6,handleBackClick:tQ,handleCloseDiff:tv,handleDelete:nm,handleDiffSelect:tb,handleDirtyChange:nP,handleEditorClose:t$,handleEditorSave:tG,handleFileInputChange:nj,handleFilePanelSave:tK,handleFilePathClick:tB,handleFileSelect:tU,handleHistoryDisplayLimitChange:tl,handleHistoryUserOnlyChange:tr,handleInfoClick:tZ,handleInfoModalClose:t0,handleInsertConsumed:th,handleInsertConsumedSingle:tf,handleInsertToMessage:tm,handleInsertToSplit:tx,handleKillCancel:nl,handleKillConfirm:nr,openKillConfirm:nn,openActiveKillConfirm:na,killTarget:t9,isKillPending:t7,handleLoadContent:nM,handleLoadError:nR,handleMessageSent:t5,handleMobileFileViewerClose:tH,handleMobileTabChange:t4,handleMove:nf,resetFileTreeView:tq,handleMoveCancel:ng,handleMoveConfirm:np,handleNewDirectory:nd,handleNewFile:ni,handleNewFileCancel:nc,handleNewFileConfirm:no,handleOpenFile:tW,handlePromptDismiss:t2,handlePromptRespond:t1,handleRename:nu,handleReLogin:nS,handleRetry:nC,handleSelectedAgentsChange:tP,handleSetLoading:nL,handleShowArchivedChange:tn,handleUpload:ny,handleVibeLocalContextWindowChange:tO,rosterReady:eL,handleVibeLocalModelChange:tF,handleWorktreeStatusChange:tX,hasUpdate:nk,historyDisplayLimit:ts,historySubTab:e7,historyUserOnly:ta,isAuthExpired:z,isEditorMaximized:es,isInfoModalOpen:Q,isMobile:g,isMoveDialogOpen:nh,isReconnecting:F,isSelectionListActive:eh,isPagerActive:ep,lastAutoResponse:nN,loading:R,makeAutoYesToggleHandler:t3,mobileFileViewerPath:et,mobileSelectedAgents:tM,moveTarget:nx,newFileParentPath:e5,openMobileDrawer:v,pendingInsertText:td,pendingInsertTextMap:tc,selectedAgents:ek,setActiveCliTab:eV,setActiveInstanceId:eH,setEditorFilePath:er,setFocusedSplitIndex:tu,setHistorySubTab:te,setIsEditorMaximized:el,setWorktree:M,showArchived:tt,showNewFileDialog:e2,showToast:t_,state:y,tCommon:N,tWorktree:w,tabsActions:ee,tabsState:Z,toggleInstanceVisible:tE,vibeLocalContextWindow:eF,verification:nD,vibeLocalModel:eP,visibleInstanceIds:tT,worktree:A,worktreeName:nA,worktreeStatus:nT}}({worktreeId:j}),tW=(0,c.c)("auth"),[tH,tK]=(0,i.useState)(!1),[t$,tq]=(0,i.useState)(null),[tG,tJ]=(0,i.useState)($.wf),tY="terminal"===C&&"chat"===tG,tQ=(0,i.useCallback)(e=>{"memo"!==e&&tq(null),eL(e)},[eL]),tX=(0,i.useCallback)(()=>{tq(e=>{var t;return{tab:"verification",token:(null!=(t=null==e?void 0:e.token)?t:0)+1}}),eL("memo")},[eL]),tZ=function(e){let{worktreeId:t,active:n}=e,{addListener:a}=(0,tN.xM)(),[r,s]=(0,i.useState)(!1),l=(0,i.useRef)(n);return l.current=n,(0,i.useEffect)(()=>{n&&s(!1)},[n]),(0,i.useEffect)(()=>a(e=>{e.worktreeId===t&&("terminal_snapshot"===e.type||"message"===e.type)&&(l.current||s(!0))}),[a,t]),!n&&r}({worktreeId:j,active:"terminal"===C}),{viewportHeight:t0}=(0,iC.C)(),t1=(0,i.useCallback)(e=>{let t=iU.indexOf(C);if(-1===t)return;let n=t+e;n<0||n>=iU.length||tQ(iU[n])},[C,tQ]),{ref:t2}=(0,R.hU)({axis:"horizontal",threshold:60,edgeStartZone:32*("terminal"===C),onSwipeLeft:()=>t1(1),onSwipeRight:()=>t1(-1)}),t4=(0,i.useMemo)(()=>({worktreePath:null==tV?void 0:tV.path,openFile:ed}),[null==tV?void 0:tV.path,ed]);if(to)return(0,r.jsx)(sH,{});if(e7)return(0,r.jsx)(iV,{message:tM("editor.sessionExpired"),loginLabel:tW("login.submitButton"),onLogin:eG});if(V)return(0,r.jsx)(sK,{message:V,onRetry:eY});let t5=(0,K.O6)(E,N,k),t3=null!=(h=null==eS?void 0:eS.label)?h:t5,t6=null!=(g=null==(t=null!=(p=null==tV||null==(n=tV.sessionStatusByInstance)?void 0:n[N])?p:null==tV||null==(a=tV.sessionStatusByCli)?void 0:a[k])?void 0:t.isRunning)&&g,t9=null!=(y=null==(l=null!=(v=null==tV||null==(o=tV.sessionStatusByInstance)?void 0:o[N])?v:null==tV||null==(u=tV.sessionStatusByCli)?void 0:u[k])?void 0:l.isProcessing)&&y;return tn?(0,r.jsx)(T.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsx)(tj,{onInsertToComposer:eb,children:(0,r.jsxs)(tk.k,{value:t4,children:[tr&&(0,r.jsx)(i_,{label:tA("connection.reconnecting")}),(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",style:{height:null!=t0?"".concat(t0,"px"):"100%"},"data-testid":"mobile-worktree-shell",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(b,{worktreeName:tB,repositoryName:null==tV?void 0:tV.repositoryName,status:tU,gitStatus:null==tV?void 0:tV.gitStatus,onBackClick:X,onMenuClick:th})}),tF.task&&(0,r.jsx)("div",{className:"flex-shrink-0 border-b border-border bg-surface px-3 py-1.5",children:(0,r.jsx)(ib,{task:tF.task,latestRun:tF.latestRun,latestRunGates:null!==tF.selectedRun&&tF.selectedRun.id===(null==(m=tF.latestRun)?void 0:m.id)?tF.selectedRun.gates:null,onOpen:tX,className:"w-full justify-start"})}),(null==tV?void 0:tV.gitStatus)&&tV.gitStatus.isBranchMismatch&&(0,r.jsx)("div",{className:"z-35 flex-shrink-0",children:(0,r.jsx)(iv,{isBranchMismatch:tV.gitStatus.isBranchMismatch,currentBranch:tV.gitStatus.currentBranch,initialBranch:tV.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":tM("detail.agentInstanceSelection"),children:z.map(e=>{var t,n,a;let s=(0,e6.kA)(null!=(a=null==tV||null==(t=tV.sessionStatusByInstance)?void 0:t[e.id])?a:null==tV||null==(n=tV.sessionStatusByCli)?void 0:n[e.cliTool]),l=tA("status.".concat(s)),i=N===e.id;return(0,r.jsxs)("button",{onClick:()=>tb(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(i?"text-accent-600 dark:text-accent-400 border-accent-500":"text-muted-foreground hover:text-foreground border-transparent"),"aria-current":i?"page":void 0,children:[(0,r.jsx)(x.m,{status:s,size:"sm",label:tM("detail.statusPill",{label:(0,K.sw)(e),status:l})}),(0,K.sw)(e)]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:()=>tK(!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":tM("terminal.moreActions"),"data-testid":"mobile-more-actions-button",children:(0,r.jsx)(d.A,{size:18,"aria-hidden":"true"})})]}),(0,r.jsx)("main",{className:"flex-1 min-h-0 overflow-y-auto",ref:t2,children:(0,r.jsx)(sM,{activeTab:C,worktreeId:j,worktree:tV,messages:tE.messages,cliToolId:k,instanceId:N,onFilePathClick:ed,onFileSelect:eu,onWorktreeUpdate:tC,onNewFile:ez,onNewDirectory:eO,onRename:eK,onDelete:ee,onUpload:eZ,onMove:eP,onFileTreeReset:tP,refreshTrigger:H,fileSearch:W,showToast:tT,selectedAgents:tu,onSelectedAgentsChange:iB,useInstanceManagement:!0,instances:E,onInstancesChange:Y,visibleInstanceIds:t_,onToggleInstanceVisible:tD,vibeLocalModel:tz,onVibeLocalModelChange:e1,vibeLocalContextWindow:tO,onVibeLocalContextWindowChange:e0,disableAutoFollow:O,historySubTab:e9,onHistorySubTabChange:ty,onDiffSelect:et,onInsertToMessage:eb,showArchived:tS,onShowArchivedChange:eX,historyDisplayLimit:e5,onHistoryDisplayLimitChange:em,historyUserOnly:e8,onHistoryUserOnlyChange:ex,verification:tF,toolsSubTabRequest:t$,onSurfaceModeChange:tJ})}),(0,r.jsxs)("div",{className:"flex-shrink-0 border-t border-border bg-surface z-30",children:[ts&&!tY&&(0,r.jsx)("div",{className:"px-2 pt-1 border-b border-border",children:(0,r.jsx)(es.y,{worktreeId:j,cliToolId:k,instanceId:N,onKeysSent:B,showPagerKeys:tl})}),(0,r.jsx)("div",{className:"p-2",children:(0,r.jsx)(iW,{worktreeId:j,onMessageSent:eM,cliToolId:k,instanceId:N,isSessionRunning:t6,isProcessing:t9,showToast:tT,pendingInsertText:tf,onInsertConsumed:eg,autoYesSlot:(0,r.jsx)(ih.T,{enabled:A,expiresAt:M,onToggle:Q,lastAutoResponse:ti,cliToolName:k,inline:!0,showToolName:!1})})})]}),(0,r.jsx)(S,{activeTab:C,onTabChange:tQ,hasNewOutput:tZ,hasPrompt:tE.prompt.visible,hasUpdate:e4,inFlow:!0}),!A&&(0,r.jsx)(P,{promptData:tE.prompt.data,visible:tE.prompt.visible,answering:tE.prompt.answering,onRespond:eH,onDismiss:eW,cliToolName:(0,K.oo)(k)}),(0,r.jsx)(ea,{open:tH,onClose:()=>tK(!1),onSearch:()=>window.dispatchEvent(new CustomEvent("terminal-search-open")),onEnd:eC,endDisabled:!t6}),(0,r.jsx)(eU,{isOpen:null!==td,onClose:eR,worktreeId:j,filePath:null!=td?td:"",onFileSaved:el,onOpenFile:ed}),(0,r.jsx)("input",{ref:U,type:"file",accept:ey.join(","),onChange:eo,className:"hidden","aria-label":tM("detail.uploadFile")}),(0,r.jsx)(e3.a,{isOpen:null!==eS,onClose:ew,title:tM("session.confirmEnd",{tool:t3}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:tM("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:tA("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:tA("end")})]})]})}),tm&&(0,r.jsx)(ij,{isOpen:ta,onClose:eD,onConfirm:eF,worktreeId:j,sourcePath:tm.path,sourceType:tm.type}),(0,r.jsx)(ik,{isOpen:tI,parentPath:tx,onConfirm:eV,onCancel:e_})]})]})})}):(0,r.jsxs)(tk.k,{value:t4,children:[tr&&(0,r.jsx)(i_,{label:tA("connection.reconnecting")}),(0,r.jsx)(iN,{worktreeId:j,worktree:tV,worktreeName:tB,worktreeStatus:tU,instances:E,rosterReady:tg,activeInstanceId:N,setActiveInstanceId:tb,hasUpdate:e4,lastAutoResponse:ti,activeActivity:w,onActivityToggle:G,onActivityOpen:q,verification:tF,onBackClick:X,onInfoClick:eh,onWorktreeStatusChange:e2,pendingInsertTextMap:tp,setFocusedSplitIndex:tv,handleInsertToSplit:ej,handleInsertConsumed:ep,handleInsertToMessage:eb,autoYesStateMap:L,makeAutoYesToggleHandler:tc,showArchived:tS,onShowArchivedChange:eX,historyDisplayLimit:e5,onHistoryDisplayLimitChange:em,historyUserOnly:e8,onHistoryUserOnlyChange:ex,onMessageSent:eM,onFilePathClick:ed,showToast:tT,tabsState:tL,tabsActions:tR,onLoadContent:eT,onLoadError:eA,onSetLoading:eQ,onFilePanelSave:ec,onDirtyChange:en,onOpenFile:eB,diffContent:D,diffFilePath:F,onCloseDiff:Z,fileSearch:W,fileTreeRefresh:H,onFileSelect:eu,onNewFile:ez,onNewDirectory:eO,onRename:eK,onDelete:ee,onUpload:eZ,onMove:eP,onFileTreeReset:tP,onDiffSelect:et,onAgentInstancesChange:Y,vibeLocalModel:tz,onVibeLocalModelChange:e1,vibeLocalContextWindow:tO,onVibeLocalContextWindowChange:e0,isInfoModalOpen:tt,onInfoModalClose:ef,onWorktreeUpdate:tC,fileInputRef:U,onFileInputChange:eo,onKillSession:eC,onRequestSessionEnd:eN,killTarget:eS,isKillPending:eI,onKillCancel:ew,onKillConfirm:ek,moveTarget:tm,isMoveDialogOpen:ta,onMoveCancel:eD,onMoveConfirm:eF,showNewFileDialog:tI,newFileParentPath:tx,onNewFileConfirm:eV,onNewFileCancel:e_,killDialogTitle:tM("session.confirmEnd",{tool:t3}),killDialogWarning:tM("session.endWarning"),cancelLabel:tA("cancel"),endLabel:tA("end")}),_&&(0,r.jsx)(e3.a,{isOpen:!0,onClose:er,title:_.split("/").pop()||tM("fileViewer.editor"),size:"full",disableClose:te,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(iz,{worktreeId:j,filePath:_,onClose:er,onSave:el,onMaximizedChange:tw})})})]})});function iK(){let e=(0,s.useParams)().id;return(0,r.jsx)(l.GV,{children:(0,r.jsx)(iH,{worktreeId:e})})}},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}}},53292:(e,t,n)=>{"use strict";n.d(t,{Ll:()=>a,bu:()=>r});let a=2e3,r=4e3},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),h=(0,a.useRef)(i),f=(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)(()=>{h.current=i},[i]),(0,a.useEffect)(()=>(p.current=!0,()=>{p.current=!1,f.current&&clearTimeout(f.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=h.current)||a.call(h)}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)(()=>{f.current&&(clearTimeout(f.current),f.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(),f.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;return 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)}}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")})]})}},85872:(e,t,n)=>{"use strict";async function a(e,t){throw Error((await e.json().catch(()=>({}))).error||"".concat(t," (").concat(e.status,")"))}n.d(t,{$C:()=>r,Ar:()=>l,KG:()=>s});let r={async list(e){var t;let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"));return n.ok?null!=(t=(await n.json()).todos)?t:[]:a(n,"Failed to load todos")},async listAll(){var e;let t=await fetch("/api/todos");return t.ok?null!=(e=(await t.json()).todos)?e:[]:a(t,"Failed to load todos")},async create(e,t){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});return n.ok?(await n.json()).todo:a(n,"Failed to create todo")},async update(e,t,n){let r=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?(await r.json()).todo:a(r,"Failed to update todo")},async remove(e,t){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});n.ok||await a(n,"Failed to delete todo")}},s=["todo","doing","done"],l={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:[]:a(n,"Failed to load todos")},async create(e,t,n){let r=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 r.ok?(await r.json()).todo:a(r,"Failed to create todo")},async update(e,t,n){let r=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?(await r.json()).todo:a(r,"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 a(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 a(n,"Failed to reorder todos")}}}},e=>{e.O(0,[6481,6809,4909,2770,790,5694,8566,934,9948,6983,9526,3160,2407,6402,8019,4718,4388,2751,2039,4949,2053,6022,998,8441,1255,7358],()=>e(e.s=20252)),_N_E=e.O()}]);