commandmate 0.1.5 → 0.1.6

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 (330) hide show
  1. package/.next/BUILD_ID +1 -0
  2. package/.next/app-build-manifest.json +72 -0
  3. package/.next/app-path-routes-manifest.json +1 -0
  4. package/.next/build-manifest.json +32 -0
  5. package/.next/cache/.tsbuildinfo +1 -0
  6. package/.next/cache/config.json +7 -0
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/1.pack +0 -0
  9. package/.next/cache/webpack/client-production/2.pack +0 -0
  10. package/.next/cache/webpack/client-production/index.pack +0 -0
  11. package/.next/cache/webpack/client-production/index.pack.old +0 -0
  12. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  13. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  14. package/.next/cache/webpack/server-production/0.pack +0 -0
  15. package/.next/cache/webpack/server-production/index.pack +0 -0
  16. package/.next/export-marker.json +1 -0
  17. package/.next/images-manifest.json +1 -0
  18. package/.next/next-minimal-server.js.nft.json +1 -0
  19. package/.next/next-server.js.nft.json +1 -0
  20. package/.next/package.json +1 -0
  21. package/.next/prerender-manifest.json +1 -0
  22. package/.next/react-loadable-manifest.json +249 -0
  23. package/.next/required-server-files.json +1 -0
  24. package/.next/routes-manifest.json +1 -0
  25. package/.next/server/app/_not-found/page.js +1 -0
  26. package/.next/server/app/_not-found/page.js.nft.json +1 -0
  27. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  28. package/.next/server/app/_not-found.html +1 -0
  29. package/.next/server/app/_not-found.meta +6 -0
  30. package/.next/server/app/_not-found.rsc +10 -0
  31. package/.next/server/app/api/external-apps/[id]/health/route.js +45 -0
  32. package/.next/server/app/api/external-apps/[id]/health/route.js.nft.json +1 -0
  33. package/.next/server/app/api/external-apps/[id]/route.js +45 -0
  34. package/.next/server/app/api/external-apps/[id]/route.js.nft.json +1 -0
  35. package/.next/server/app/api/external-apps/route.js +45 -0
  36. package/.next/server/app/api/external-apps/route.js.nft.json +1 -0
  37. package/.next/server/app/api/hooks/claude-done/route.js +19 -0
  38. package/.next/server/app/api/hooks/claude-done/route.js.nft.json +1 -0
  39. package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -0
  40. package/.next/server/app/api/repositories/clone/[jobId]/route.js.nft.json +1 -0
  41. package/.next/server/app/api/repositories/clone/route.js +1 -0
  42. package/.next/server/app/api/repositories/clone/route.js.nft.json +1 -0
  43. package/.next/server/app/api/repositories/route.js +1 -0
  44. package/.next/server/app/api/repositories/route.js.nft.json +1 -0
  45. package/.next/server/app/api/repositories/scan/route.js +1 -0
  46. package/.next/server/app/api/repositories/scan/route.js.nft.json +1 -0
  47. package/.next/server/app/api/repositories/sync/route.js +1 -0
  48. package/.next/server/app/api/repositories/sync/route.js.nft.json +1 -0
  49. package/.next/server/app/api/slash-commands/route.js +1 -0
  50. package/.next/server/app/api/slash-commands/route.js.nft.json +1 -0
  51. package/.next/server/app/api/slash-commands.body +1 -0
  52. package/.next/server/app/api/slash-commands.meta +1 -0
  53. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -0
  54. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -0
  55. package/.next/server/app/api/worktrees/[id]/capture/route.js +2 -0
  56. package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -0
  57. package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -0
  58. package/.next/server/app/api/worktrees/[id]/cli-tool/route.js.nft.json +1 -0
  59. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -0
  60. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -0
  61. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -0
  62. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js.nft.json +1 -0
  63. package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -0
  64. package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -0
  65. package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -0
  66. package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -0
  67. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js +1 -0
  68. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js.nft.json +1 -0
  69. package/.next/server/app/api/worktrees/[id]/logs/route.js +19 -0
  70. package/.next/server/app/api/worktrees/[id]/logs/route.js.nft.json +1 -0
  71. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -0
  72. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js.nft.json +1 -0
  73. package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -0
  74. package/.next/server/app/api/worktrees/[id]/memos/route.js.nft.json +1 -0
  75. package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -0
  76. package/.next/server/app/api/worktrees/[id]/messages/route.js.nft.json +1 -0
  77. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -0
  78. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -0
  79. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -0
  80. package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -0
  81. package/.next/server/app/api/worktrees/[id]/route.js +1 -0
  82. package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -0
  83. package/.next/server/app/api/worktrees/[id]/search/route.js +1 -0
  84. package/.next/server/app/api/worktrees/[id]/search/route.js.nft.json +1 -0
  85. package/.next/server/app/api/worktrees/[id]/send/route.js +1 -0
  86. package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -0
  87. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -0
  88. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js.nft.json +1 -0
  89. package/.next/server/app/api/worktrees/[id]/start-polling/route.js +1 -0
  90. package/.next/server/app/api/worktrees/[id]/start-polling/route.js.nft.json +1 -0
  91. package/.next/server/app/api/worktrees/[id]/terminal/route.js +1 -0
  92. package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -0
  93. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -0
  94. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js.nft.json +1 -0
  95. package/.next/server/app/api/worktrees/[id]/tree/route.js +1 -0
  96. package/.next/server/app/api/worktrees/[id]/tree/route.js.nft.json +1 -0
  97. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -0
  98. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js.nft.json +1 -0
  99. package/.next/server/app/api/worktrees/[id]/viewed/route.js +1 -0
  100. package/.next/server/app/api/worktrees/[id]/viewed/route.js.nft.json +1 -0
  101. package/.next/server/app/api/worktrees/route.js +1 -0
  102. package/.next/server/app/api/worktrees/route.js.nft.json +1 -0
  103. package/.next/server/app/apple-icon.png/route.js +1 -0
  104. package/.next/server/app/apple-icon.png/route.js.nft.json +1 -0
  105. package/.next/server/app/apple-icon.png.body +0 -0
  106. package/.next/server/app/apple-icon.png.meta +1 -0
  107. package/.next/server/app/icon.png/route.js +1 -0
  108. package/.next/server/app/icon.png/route.js.nft.json +1 -0
  109. package/.next/server/app/icon.png.body +0 -0
  110. package/.next/server/app/icon.png.meta +1 -0
  111. package/.next/server/app/index.html +9 -0
  112. package/.next/server/app/index.meta +5 -0
  113. package/.next/server/app/index.rsc +8 -0
  114. package/.next/server/app/page.js +16 -0
  115. package/.next/server/app/page.js.nft.json +1 -0
  116. package/.next/server/app/page_client-reference-manifest.js +1 -0
  117. package/.next/server/app/proxy/[...path]/route.js +45 -0
  118. package/.next/server/app/proxy/[...path]/route.js.nft.json +1 -0
  119. package/.next/server/app/worktrees/[id]/files/[...path]/page.js +1 -0
  120. package/.next/server/app/worktrees/[id]/files/[...path]/page.js.nft.json +1 -0
  121. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -0
  122. package/.next/server/app/worktrees/[id]/page.js +21 -0
  123. package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -0
  124. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -0
  125. package/.next/server/app/worktrees/[id]/simple-terminal/page.js +4 -0
  126. package/.next/server/app/worktrees/[id]/simple-terminal/page.js.nft.json +1 -0
  127. package/.next/server/app/worktrees/[id]/simple-terminal/page_client-reference-manifest.js +1 -0
  128. package/.next/server/app/worktrees/[id]/terminal/page.js +6 -0
  129. package/.next/server/app/worktrees/[id]/terminal/page.js.nft.json +1 -0
  130. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -0
  131. package/.next/server/app-paths-manifest.json +46 -0
  132. package/.next/server/chunks/1318.js +29 -0
  133. package/.next/server/chunks/1528.js +1 -0
  134. package/.next/server/chunks/1682.js +6 -0
  135. package/.next/server/chunks/2518.js +12 -0
  136. package/.next/server/chunks/3053.js +1 -0
  137. package/.next/server/chunks/3673.js +1 -0
  138. package/.next/server/chunks/3853.js +1 -0
  139. package/.next/server/chunks/434.js +1 -0
  140. package/.next/server/chunks/4471.js +2 -0
  141. package/.next/server/chunks/4893.js +2 -0
  142. package/.next/server/chunks/5972.js +12 -0
  143. package/.next/server/chunks/6550.js +1 -0
  144. package/.next/server/chunks/6621.js +1 -0
  145. package/.next/server/chunks/7213.js +1 -0
  146. package/.next/server/chunks/7425.js +500 -0
  147. package/.next/server/chunks/8585.js +1 -0
  148. package/.next/server/chunks/8887.js +1 -0
  149. package/.next/server/chunks/8948.js +2 -0
  150. package/.next/server/chunks/9703.js +31 -0
  151. package/.next/server/chunks/9723.js +19 -0
  152. package/.next/server/chunks/font-manifest.json +1 -0
  153. package/.next/server/edge-runtime-webpack.js +2 -0
  154. package/.next/server/edge-runtime-webpack.js.map +1 -0
  155. package/.next/server/font-manifest.json +1 -0
  156. package/.next/server/functions-config-manifest.json +1 -0
  157. package/.next/server/interception-route-rewrite-manifest.js +1 -0
  158. package/.next/server/middleware-build-manifest.js +1 -0
  159. package/.next/server/middleware-manifest.json +32 -0
  160. package/.next/server/middleware-react-loadable-manifest.js +1 -0
  161. package/.next/server/next-font-manifest.js +1 -0
  162. package/.next/server/next-font-manifest.json +1 -0
  163. package/.next/server/pages/404.html +1 -0
  164. package/.next/server/pages/500.html +1 -0
  165. package/.next/server/pages/_app.js +1 -0
  166. package/.next/server/pages/_app.js.nft.json +1 -0
  167. package/.next/server/pages/_document.js +1 -0
  168. package/.next/server/pages/_document.js.nft.json +1 -0
  169. package/.next/server/pages/_error.js +1 -0
  170. package/.next/server/pages/_error.js.nft.json +1 -0
  171. package/.next/server/pages-manifest.json +1 -0
  172. package/.next/server/server-reference-manifest.js +1 -0
  173. package/.next/server/server-reference-manifest.json +1 -0
  174. package/.next/server/src/middleware.js +14 -0
  175. package/.next/server/src/middleware.js.map +1 -0
  176. package/.next/server/webpack-runtime.js +1 -0
  177. package/.next/static/chunks/0dbeb660.3e800dfbd28be3bd.js +53 -0
  178. package/.next/static/chunks/1015.0eaa4da7f61149bc.js +59 -0
  179. package/.next/static/chunks/1098.49268c9fe1b028fa.js +1 -0
  180. package/.next/static/chunks/13.feeafc7cc620f8c4.js +1 -0
  181. package/.next/static/chunks/1423.7b1e8bf760d28078.js +1 -0
  182. package/.next/static/chunks/1582.9f8590f71ff798ca.js +55 -0
  183. package/.next/static/chunks/1817.a66d96cedb761daa.js +262 -0
  184. package/.next/static/chunks/2117-d845c2cd62e344a6.js +2 -0
  185. package/.next/static/chunks/2398.0b21e4eb7006a230.js +93 -0
  186. package/.next/static/chunks/2526.8ac62b527c9ab703.js +43 -0
  187. package/.next/static/chunks/2626.2125083a1ff3b80a.js +29 -0
  188. package/.next/static/chunks/2689.720a4874b02d4211.js +174 -0
  189. package/.next/static/chunks/2853-d11a80b03c9a1640.js +1 -0
  190. package/.next/static/chunks/2957-327e43ef4c12808f.js +1 -0
  191. package/.next/static/chunks/2cdb6380.35626fc6e41bbba4.js +136 -0
  192. package/.next/static/chunks/30d07d85-393352a92199f695.js +3 -0
  193. package/.next/static/chunks/3559.f073f72c4466ce0e.js +1 -0
  194. package/.next/static/chunks/3574.7a94c27e6a496a56.js +63 -0
  195. package/.next/static/chunks/383.20683891c9a5f2c4.js +4 -0
  196. package/.next/static/chunks/3843.3fdda732987f7bb8.js +1 -0
  197. package/.next/static/chunks/3852.822389f445c9b427.js +1 -0
  198. package/.next/static/chunks/3991.4bc063cb5be3a86c.js +1 -0
  199. package/.next/static/chunks/4212.52c1bb34fc97d0d0.js +131 -0
  200. package/.next/static/chunks/4327.3b84aa049900fdeb.js +60 -0
  201. package/.next/static/chunks/4362.7bd6f0282e49d79b.js +1 -0
  202. package/.next/static/chunks/4721.40615a5f4f32b5fb.js +1 -0
  203. package/.next/static/chunks/4851-45df4d388db5623f.js +1 -0
  204. package/.next/static/chunks/5112.17318d1c6b28044b.js +1 -0
  205. package/.next/static/chunks/5126.93fa4e797d609286.js +56 -0
  206. package/.next/static/chunks/5387.47590ac4ef66c864.js +5 -0
  207. package/.next/static/chunks/5813.4483664ba482beb1.js +1 -0
  208. package/.next/static/chunks/6143.1450875bd03a2366.js +36 -0
  209. package/.next/static/chunks/6406.9653f0d41ab85059.js +1 -0
  210. package/.next/static/chunks/656.d72f25ce819bd77e.js +149 -0
  211. package/.next/static/chunks/6678.492e73ca42b2a273.js +62 -0
  212. package/.next/static/chunks/6725-f7607851b7d57eb1.js +1 -0
  213. package/.next/static/chunks/6792.3c01ac4dda4b5c6d.js +1 -0
  214. package/.next/static/chunks/7004.808cbf327ef5955e.js +1 -0
  215. package/.next/static/chunks/7290.09ef84cf94f90c4d.js +1 -0
  216. package/.next/static/chunks/7415.6b481c2baf363262.js +148 -0
  217. package/.next/static/chunks/7648-325564a6e12a3257.js +1 -0
  218. package/.next/static/chunks/7665.47fccad04449a8f9.js +215 -0
  219. package/.next/static/chunks/7753.6bdce86b7fde3d10.js +166 -0
  220. package/.next/static/chunks/8125.245a9df052d274fb.js +1 -0
  221. package/.next/static/chunks/816-7e340dad784be28c.js +1 -0
  222. package/.next/static/chunks/8288.4883743fa40672e2.js +24 -0
  223. package/.next/static/chunks/8522.1607e96011c66877.js +1 -0
  224. package/.next/static/chunks/8772.863c564498d88487.js +1 -0
  225. package/.next/static/chunks/8841.dadeb1ece8e46004.js +1 -0
  226. package/.next/static/chunks/8885.f8d9912b40d74811.js +1 -0
  227. package/.next/static/chunks/90542734.c1553d0fe7fc14fc.js +1 -0
  228. package/.next/static/chunks/9365-733d8c05712d2888.js +1 -0
  229. package/.next/static/chunks/9552.b7dfb7903ead934b.js +1 -0
  230. package/.next/static/chunks/9834.295b45635ce04f5e.js +24 -0
  231. package/.next/static/chunks/app/_not-found/page-a9d04e58c81115ec.js +1 -0
  232. package/.next/static/chunks/app/layout-37e55f11dcc8b1bf.js +1 -0
  233. package/.next/static/chunks/app/page-9cd00de9cc0abc43.js +1 -0
  234. package/.next/static/chunks/app/worktrees/[id]/files/[...path]/page-9e5adf57cbbbdf05.js +1 -0
  235. package/.next/static/chunks/app/worktrees/[id]/page-8c6676303b63fdaf.js +1 -0
  236. package/.next/static/chunks/app/worktrees/[id]/simple-terminal/page-16feb3e86e42f4d1.js +1 -0
  237. package/.next/static/chunks/app/worktrees/[id]/terminal/page-be802baffc84dbd2.js +1 -0
  238. package/.next/static/chunks/d3ac728e.6c9c508274d4d2d5.js +1 -0
  239. package/.next/static/chunks/fd9d1056-bbe86e4ae099d5cd.js +1 -0
  240. package/.next/static/chunks/framework-8e0e0f4a6b83a956.js +1 -0
  241. package/.next/static/chunks/main-a960f4a5e1a2f598.js +1 -0
  242. package/.next/static/chunks/main-app-420d93e43682fee5.js +1 -0
  243. package/.next/static/chunks/pages/_app-3c9ca398d360b709.js +1 -0
  244. package/.next/static/chunks/pages/_error-cf5ca766ac8f493f.js +1 -0
  245. package/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  246. package/.next/static/chunks/webpack-3fc79fab9bb738d7.js +1 -0
  247. package/.next/static/css/5eacd01f773eed7f.css +11 -0
  248. package/.next/static/css/85fa6dafca566008.css +1 -0
  249. package/.next/static/css/e174aa24f94ce607.css +3 -0
  250. package/.next/static/pQTquVjewvoJa7BML07ip/_buildManifest.js +1 -0
  251. package/.next/static/pQTquVjewvoJa7BML07ip/_ssgManifest.js +1 -0
  252. package/.next/trace +5 -0
  253. package/.next/types/app/api/external-apps/[id]/health/route.ts +343 -0
  254. package/.next/types/app/api/external-apps/[id]/route.ts +343 -0
  255. package/.next/types/app/api/external-apps/route.ts +343 -0
  256. package/.next/types/app/api/hooks/claude-done/route.ts +343 -0
  257. package/.next/types/app/api/repositories/clone/[jobId]/route.ts +343 -0
  258. package/.next/types/app/api/repositories/clone/route.ts +343 -0
  259. package/.next/types/app/api/repositories/route.ts +343 -0
  260. package/.next/types/app/api/repositories/scan/route.ts +343 -0
  261. package/.next/types/app/api/repositories/sync/route.ts +343 -0
  262. package/.next/types/app/api/slash-commands/route.ts +343 -0
  263. package/.next/types/app/api/worktrees/[id]/auto-yes/route.ts +343 -0
  264. package/.next/types/app/api/worktrees/[id]/capture/route.ts +343 -0
  265. package/.next/types/app/api/worktrees/[id]/cli-tool/route.ts +343 -0
  266. package/.next/types/app/api/worktrees/[id]/current-output/route.ts +343 -0
  267. package/.next/types/app/api/worktrees/[id]/files/[...path]/route.ts +343 -0
  268. package/.next/types/app/api/worktrees/[id]/interrupt/route.ts +343 -0
  269. package/.next/types/app/api/worktrees/[id]/kill-session/route.ts +343 -0
  270. package/.next/types/app/api/worktrees/[id]/logs/[filename]/route.ts +343 -0
  271. package/.next/types/app/api/worktrees/[id]/logs/route.ts +343 -0
  272. package/.next/types/app/api/worktrees/[id]/memos/[memoId]/route.ts +343 -0
  273. package/.next/types/app/api/worktrees/[id]/memos/route.ts +343 -0
  274. package/.next/types/app/api/worktrees/[id]/messages/route.ts +343 -0
  275. package/.next/types/app/api/worktrees/[id]/prompt-response/route.ts +343 -0
  276. package/.next/types/app/api/worktrees/[id]/respond/route.ts +343 -0
  277. package/.next/types/app/api/worktrees/[id]/route.ts +343 -0
  278. package/.next/types/app/api/worktrees/[id]/search/route.ts +343 -0
  279. package/.next/types/app/api/worktrees/[id]/send/route.ts +343 -0
  280. package/.next/types/app/api/worktrees/[id]/slash-commands/route.ts +343 -0
  281. package/.next/types/app/api/worktrees/[id]/start-polling/route.ts +343 -0
  282. package/.next/types/app/api/worktrees/[id]/terminal/route.ts +343 -0
  283. package/.next/types/app/api/worktrees/[id]/tree/[...path]/route.ts +343 -0
  284. package/.next/types/app/api/worktrees/[id]/tree/route.ts +343 -0
  285. package/.next/types/app/api/worktrees/[id]/upload/[...path]/route.ts +343 -0
  286. package/.next/types/app/api/worktrees/[id]/viewed/route.ts +343 -0
  287. package/.next/types/app/api/worktrees/route.ts +343 -0
  288. package/.next/types/app/page.ts +79 -0
  289. package/.next/types/app/proxy/[...path]/route.ts +343 -0
  290. package/.next/types/app/worktrees/[id]/files/[...path]/page.ts +79 -0
  291. package/.next/types/app/worktrees/[id]/page.ts +79 -0
  292. package/.next/types/app/worktrees/[id]/simple-terminal/page.ts +79 -0
  293. package/.next/types/app/worktrees/[id]/terminal/page.ts +79 -0
  294. package/.next/types/package.json +1 -0
  295. package/README.md +39 -8
  296. package/dist/server/server.js +123 -0
  297. package/dist/server/src/lib/claude-output.js +33 -0
  298. package/dist/server/src/lib/claude-session.js +312 -0
  299. package/dist/server/src/lib/cli-patterns.js +137 -0
  300. package/dist/server/src/lib/cli-session.js +73 -0
  301. package/dist/server/src/lib/cli-tools/base.js +51 -0
  302. package/dist/server/src/lib/cli-tools/claude.js +65 -0
  303. package/dist/server/src/lib/cli-tools/codex.js +132 -0
  304. package/dist/server/src/lib/cli-tools/gemini.js +122 -0
  305. package/dist/server/src/lib/cli-tools/index.js +22 -0
  306. package/dist/server/src/lib/cli-tools/manager.js +143 -0
  307. package/dist/server/src/lib/cli-tools/types.js +5 -0
  308. package/dist/server/src/lib/conversation-logger.js +25 -0
  309. package/dist/server/src/lib/db-instance.js +51 -0
  310. package/dist/server/src/lib/db-migrations.js +777 -0
  311. package/dist/server/src/lib/db.js +835 -0
  312. package/dist/server/src/lib/env.js +179 -0
  313. package/dist/server/src/lib/log-manager.js +234 -0
  314. package/dist/server/src/lib/logger.js +232 -0
  315. package/dist/server/src/lib/prompt-detector.js +285 -0
  316. package/dist/server/src/lib/response-poller.js +638 -0
  317. package/dist/server/src/lib/tmux.js +299 -0
  318. package/dist/server/src/lib/worktrees.js +231 -0
  319. package/dist/server/src/lib/ws-server.js +323 -0
  320. package/dist/server/src/types/clone.js +39 -0
  321. package/dist/server/src/types/conversation.js +9 -0
  322. package/dist/server/src/types/external-apps.js +6 -0
  323. package/dist/server/src/types/infinite-messages.js +65 -0
  324. package/dist/server/src/types/markdown-editor.js +94 -0
  325. package/dist/server/src/types/models.js +5 -0
  326. package/dist/server/src/types/sidebar.js +89 -0
  327. package/dist/server/src/types/slash-commands.js +47 -0
  328. package/dist/server/src/types/ui-actions.js +8 -0
  329. package/dist/server/src/types/ui-state.js +62 -0
  330. package/package.json +8 -4
@@ -0,0 +1,21 @@
1
+ (()=>{var e={};e.id=130,e.ids=[130],e.modules={98860:e=>{"use strict";e.exports=require("jsdom")},72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},55315:e=>{"use strict";e.exports=require("path")},17360:e=>{"use strict";e.exports=require("url")},49411:e=>{"use strict";e.exports=require("node:path")},97742:e=>{"use strict";e.exports=require("node:process")},41041:e=>{"use strict";e.exports=require("node:url")},80205:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GlobalError:()=>l.a,__next_app__:()=>m,originalPathname:()=>u,pages:()=>d,routeModule:()=>p,tree:()=>c}),r(22570),r(25086),r(35866);var a=r(23191),n=r(88716),s=r(37922),l=r.n(s),i=r(95231),o={};for(let e in i)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);r.d(t,o);let c=["",{children:["worktrees",{children:["[id]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(r.bind(r,22570)),"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx"]}]},{}]},{metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(r.bind(r,63601))).default(e)],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(r.bind(r,25086)),"/home/runner/work/CommandMate/CommandMate/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(r.t.bind(r,35866,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(r.bind(r,63601))).default(e)],openGraph:[],twitter:[],manifest:void 0}}],d=["/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx"],u="/worktrees/[id]/page",m={require:r,loadChunk:()=>Promise.resolve()},p=new a.AppPageRouteModule({definition:{kind:n.x.APP_PAGE,page:"/worktrees/[id]/page",pathname:"/worktrees/[id]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:c}})},87923:(e,t,r)=>{Promise.resolve().then(r.bind(r,89249))},62829:e=>{"use strict";let{entries:t,setPrototypeOf:r,isFrozen:a,getPrototypeOf:n,getOwnPropertyDescriptor:s}=Object,{freeze:l,seal:i,create:o}=Object,{apply:c,construct:d}="undefined"!=typeof Reflect&&Reflect;l||(l=function(e){return e}),i||(i=function(e){return e}),c||(c=function(e,t){for(var r=arguments.length,a=Array(r>2?r-2:0),n=2;n<r;n++)a[n-2]=arguments[n];return e.apply(t,a)}),d||(d=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return new e(...r)});let u=C(Array.prototype.forEach),m=C(Array.prototype.lastIndexOf),p=C(Array.prototype.pop),h=C(Array.prototype.push),f=C(Array.prototype.splice),x=C(String.prototype.toLowerCase),g=C(String.prototype.toString),b=C(String.prototype.match),y=C(String.prototype.replace),w=C(String.prototype.indexOf),v=C(String.prototype.trim),j=C(Object.prototype.hasOwnProperty),k=C(RegExp.prototype.test),N=(Z=TypeError,function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return d(Z,t)});function C(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,a=Array(r>1?r-1:0),n=1;n<r;n++)a[n-1]=arguments[n];return c(e,t,a)}}function S(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;r&&r(e,null);let s=t.length;for(;s--;){let r=t[s];if("string"==typeof r){let e=n(r);e!==r&&(a(t)||(t[s]=e),r=e)}e[r]=!0}return e}function E(e){let r=o(null);for(let[a,n]of t(e))j(e,a)&&(Array.isArray(n)?r[a]=function(e){for(let t=0;t<e.length;t++)j(e,t)||(e[t]=null);return e}(n):n&&"object"==typeof n&&n.constructor===Object?r[a]=E(n):r[a]=n);return r}function T(e,t){for(;null!==e;){let r=s(e,t);if(r){if(r.get)return C(r.get);if("function"==typeof r.value)return C(r.value)}e=n(e)}return function(){return null}}let M=l(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),A=l(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),R=l(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_=l(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),L=l(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),D=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),P=l(["#text"]),O=l(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),I=l(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),F=l(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),$=l(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),z=i(/\{\{[\w\W]*|[\w\W]*\}\}/gm),W=i(/<%[\w\W]*|[\w\W]*%>/gm),U=i(/\$\{[\w\W]*/gm),H=i(/^data-[\-\w.\u00B7-\uFFFF]+$/),B=i(/^aria-[\-\w]+$/),G=i(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),q=i(/^(?:\w+script|data):/i),V=i(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Y=i(/^html$/i);var Z,K=Object.freeze({__proto__:null,ARIA_ATTR:B,ATTR_WHITESPACE:V,CUSTOM_ELEMENT:i(/^[a-z][.\w]*(-[.\w]+)+$/i),DATA_ATTR:H,DOCTYPE_NAME:Y,ERB_EXPR:W,IS_ALLOWED_URI:G,IS_SCRIPT_OR_DATA:q,MUSTACHE_EXPR:z,TMPLIT_EXPR:U});let X={element:1,text:3,progressingInstruction:7,comment:8,document:9},J=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let r=null,a="data-tt-policy-suffix";t&&t.hasAttribute(a)&&(r=t.getAttribute(a));let n="dompurify"+(r?"#"+r:"");try{return e.createPolicy(n,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+n+" could not be created."),null}},Q=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};var ee=function e(){let r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window,n=t=>e(t);if(n.version="3.3.1",n.removed=[],!a||!a.document||a.document.nodeType!==X.document||!a.Element)return n.isSupported=!1,n;let{document:s}=a,i=s,c=i.currentScript,{DocumentFragment:d,HTMLTemplateElement:C,Node:z,Element:W,NodeFilter:U,NamedNodeMap:H=a.NamedNodeMap||a.MozNamedAttrMap,HTMLFormElement:B,DOMParser:q,trustedTypes:V}=a,Z=W.prototype,ee=T(Z,"cloneNode"),et=T(Z,"remove"),er=T(Z,"nextSibling"),ea=T(Z,"childNodes"),en=T(Z,"parentNode");if("function"==typeof C){let e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let es="",{implementation:el,createNodeIterator:ei,createDocumentFragment:eo,getElementsByTagName:ec}=s,{importNode:ed}=i,eu=Q();n.isSupported="function"==typeof t&&"function"==typeof en&&el&&void 0!==el.createHTMLDocument;let{MUSTACHE_EXPR:em,ERB_EXPR:ep,TMPLIT_EXPR:eh,DATA_ATTR:ef,ARIA_ATTR:ex,IS_SCRIPT_OR_DATA:eg,ATTR_WHITESPACE:eb,CUSTOM_ELEMENT:ey}=K,{IS_ALLOWED_URI:ew}=K,ev=null,ej=S({},[...M,...A,...R,...L,...P]),ek=null,eN=S({},[...O,...I,...F,...$]),eC=Object.seal(o(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),eS=null,eE=null,eT=Object.seal(o(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),eM=!0,eA=!0,eR=!1,e_=!0,eL=!1,eD=!0,eP=!1,eO=!1,eI=!1,eF=!1,e$=!1,ez=!1,eW=!0,eU=!1,eH=!0,eB=!1,eG={},eq=null,eV=S({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),eY=null,eZ=S({},["audio","video","img","source","image","track"]),eK=null,eX=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),eJ="http://www.w3.org/1998/Math/MathML",eQ="http://www.w3.org/2000/svg",e0="http://www.w3.org/1999/xhtml",e1=e0,e2=!1,e4=null,e5=S({},[eJ,eQ,e0],g),e3=S({},["mi","mo","mn","ms","mtext"]),e6=S({},["annotation-xml"]),e8=S({},["title","style","font","a","script"]),e7=null,e9=["application/xhtml+xml","text/html"],te=null,tt=null,tr=s.createElement("form"),ta=function(e){return e instanceof RegExp||e instanceof Function},tn=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!tt||tt!==e){if(e&&"object"==typeof e||(e={}),e=E(e),te="application/xhtml+xml"===(e7=-1===e9.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE)?g:x,ev=j(e,"ALLOWED_TAGS")?S({},e.ALLOWED_TAGS,te):ej,ek=j(e,"ALLOWED_ATTR")?S({},e.ALLOWED_ATTR,te):eN,e4=j(e,"ALLOWED_NAMESPACES")?S({},e.ALLOWED_NAMESPACES,g):e5,eK=j(e,"ADD_URI_SAFE_ATTR")?S(E(eX),e.ADD_URI_SAFE_ATTR,te):eX,eY=j(e,"ADD_DATA_URI_TAGS")?S(E(eZ),e.ADD_DATA_URI_TAGS,te):eZ,eq=j(e,"FORBID_CONTENTS")?S({},e.FORBID_CONTENTS,te):eV,eS=j(e,"FORBID_TAGS")?S({},e.FORBID_TAGS,te):E({}),eE=j(e,"FORBID_ATTR")?S({},e.FORBID_ATTR,te):E({}),eG=!!j(e,"USE_PROFILES")&&e.USE_PROFILES,eM=!1!==e.ALLOW_ARIA_ATTR,eA=!1!==e.ALLOW_DATA_ATTR,eR=e.ALLOW_UNKNOWN_PROTOCOLS||!1,e_=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,eL=e.SAFE_FOR_TEMPLATES||!1,eD=!1!==e.SAFE_FOR_XML,eP=e.WHOLE_DOCUMENT||!1,eF=e.RETURN_DOM||!1,e$=e.RETURN_DOM_FRAGMENT||!1,ez=e.RETURN_TRUSTED_TYPE||!1,eI=e.FORCE_BODY||!1,eW=!1!==e.SANITIZE_DOM,eU=e.SANITIZE_NAMED_PROPS||!1,eH=!1!==e.KEEP_CONTENT,eB=e.IN_PLACE||!1,ew=e.ALLOWED_URI_REGEXP||G,e1=e.NAMESPACE||e0,e3=e.MATHML_TEXT_INTEGRATION_POINTS||e3,e6=e.HTML_INTEGRATION_POINTS||e6,eC=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ta(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(eC.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ta(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(eC.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(eC.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),eL&&(eA=!1),e$&&(eF=!0),eG&&(ev=S({},P),ek=[],!0===eG.html&&(S(ev,M),S(ek,O)),!0===eG.svg&&(S(ev,A),S(ek,I),S(ek,$)),!0===eG.svgFilters&&(S(ev,R),S(ek,I),S(ek,$)),!0===eG.mathMl&&(S(ev,L),S(ek,F),S(ek,$))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?eT.tagCheck=e.ADD_TAGS:(ev===ej&&(ev=E(ev)),S(ev,e.ADD_TAGS,te))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?eT.attributeCheck=e.ADD_ATTR:(ek===eN&&(ek=E(ek)),S(ek,e.ADD_ATTR,te))),e.ADD_URI_SAFE_ATTR&&S(eK,e.ADD_URI_SAFE_ATTR,te),e.FORBID_CONTENTS&&(eq===eV&&(eq=E(eq)),S(eq,e.FORBID_CONTENTS,te)),e.ADD_FORBID_CONTENTS&&(eq===eV&&(eq=E(eq)),S(eq,e.ADD_FORBID_CONTENTS,te)),eH&&(ev["#text"]=!0),eP&&S(ev,["html","head","body"]),ev.table&&(S(ev,["tbody"]),delete eS.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw N('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw N('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');es=(r=e.TRUSTED_TYPES_POLICY).createHTML("")}else void 0===r&&(r=J(V,c)),null!==r&&"string"==typeof es&&(es=r.createHTML(""));l&&l(e),tt=e}},ts=S({},[...A,...R,..._]),tl=S({},[...L,...D]),ti=function(e){let t=en(e);t&&t.tagName||(t={namespaceURI:e1,tagName:"template"});let r=x(e.tagName),a=x(t.tagName);return!!e4[e.namespaceURI]&&(e.namespaceURI===eQ?t.namespaceURI===e0?"svg"===r:t.namespaceURI===eJ?"svg"===r&&("annotation-xml"===a||e3[a]):!!ts[r]:e.namespaceURI===eJ?t.namespaceURI===e0?"math"===r:t.namespaceURI===eQ?"math"===r&&e6[a]:!!tl[r]:e.namespaceURI===e0?(t.namespaceURI!==eQ||!!e6[a])&&(t.namespaceURI!==eJ||!!e3[a])&&!tl[r]&&(e8[r]||!ts[r]):"application/xhtml+xml"===e7&&!!e4[e.namespaceURI])},to=function(e){h(n.removed,{element:e});try{en(e).removeChild(e)}catch(t){et(e)}},tc=function(e,t){try{h(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){h(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e){if(eF||e$)try{to(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}}},td=function(e){let t=null,a=null;if(eI)e="<remove></remove>"+e;else{let t=b(e,/^[\r\n\t ]+/);a=t&&t[0]}"application/xhtml+xml"===e7&&e1===e0&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");let n=r?r.createHTML(e):e;if(e1===e0)try{t=new q().parseFromString(n,e7)}catch(e){}if(!t||!t.documentElement){t=el.createDocument(e1,"template",null);try{t.documentElement.innerHTML=e2?es:n}catch(e){}}let l=t.body||t.documentElement;return(e&&a&&l.insertBefore(s.createTextNode(a),l.childNodes[0]||null),e1===e0)?ec.call(t,eP?"html":"body")[0]:eP?t.documentElement:l},tu=function(e){return ei.call(e.ownerDocument||e,e,U.SHOW_ELEMENT|U.SHOW_COMMENT|U.SHOW_TEXT|U.SHOW_PROCESSING_INSTRUCTION|U.SHOW_CDATA_SECTION,null)},tm=function(e){return e instanceof B&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof H)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},tp=function(e){return"function"==typeof z&&e instanceof z};function th(e,t,r){u(e,e=>{e.call(n,t,r,tt)})}let tf=function(e){let t=null;if(th(eu.beforeSanitizeElements,e,null),tm(e))return to(e),!0;let r=te(e.nodeName);if(th(eu.uponSanitizeElement,e,{tagName:r,allowedTags:ev}),eD&&e.hasChildNodes()&&!tp(e.firstElementChild)&&k(/<[/\w!]/g,e.innerHTML)&&k(/<[/\w!]/g,e.textContent)||e.nodeType===X.progressingInstruction||eD&&e.nodeType===X.comment&&k(/<[/\w]/g,e.data))return to(e),!0;if(!(eT.tagCheck instanceof Function&&eT.tagCheck(r))&&(!ev[r]||eS[r])){if(!eS[r]&&tg(r)&&(eC.tagNameCheck instanceof RegExp&&k(eC.tagNameCheck,r)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(r)))return!1;if(eH&&!eq[r]){let t=en(e)||e.parentNode,r=ea(e)||e.childNodes;if(r&&t){let a=r.length;for(let n=a-1;n>=0;--n){let a=ee(r[n],!0);a.__removalCount=(e.__removalCount||0)+1,t.insertBefore(a,er(e))}}}return to(e),!0}return e instanceof W&&!ti(e)||("noscript"===r||"noembed"===r||"noframes"===r)&&k(/<\/no(script|embed|frames)/i,e.innerHTML)?(to(e),!0):(eL&&e.nodeType===X.text&&(t=e.textContent,u([em,ep,eh],e=>{t=y(t,e," ")}),e.textContent!==t&&(h(n.removed,{element:e.cloneNode()}),e.textContent=t)),th(eu.afterSanitizeElements,e,null),!1)},tx=function(e,t,r){if(eW&&("id"===t||"name"===t)&&(r in s||r in tr))return!1;if(eA&&!eE[t]&&k(ef,t));else if(eM&&k(ex,t));else if(eT.attributeCheck instanceof Function&&eT.attributeCheck(t,e));else if(!ek[t]||eE[t]){if(!(tg(e)&&(eC.tagNameCheck instanceof RegExp&&k(eC.tagNameCheck,e)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(e))&&(eC.attributeNameCheck instanceof RegExp&&k(eC.attributeNameCheck,t)||eC.attributeNameCheck instanceof Function&&eC.attributeNameCheck(t,e))||"is"===t&&eC.allowCustomizedBuiltInElements&&(eC.tagNameCheck instanceof RegExp&&k(eC.tagNameCheck,r)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(r))))return!1}else if(eK[t]);else if(k(ew,y(r,eb,"")));else if(("src"===t||"xlink:href"===t||"href"===t)&&"script"!==e&&0===w(r,"data:")&&eY[e]);else if(eR&&!k(eg,y(r,eb,"")));else if(r)return!1;return!0},tg=function(e){return"annotation-xml"!==e&&b(e,ey)},tb=function(e){th(eu.beforeSanitizeAttributes,e,null);let{attributes:t}=e;if(!t||tm(e))return;let a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ek,forceKeepAttr:void 0},s=t.length;for(;s--;){let{name:l,namespaceURI:i,value:o}=t[s],c=te(l),d="value"===l?o:v(o);if(a.attrName=c,a.attrValue=d,a.keepAttr=!0,a.forceKeepAttr=void 0,th(eu.uponSanitizeAttribute,e,a),d=a.attrValue,eU&&("id"===c||"name"===c)&&(tc(l,e),d="user-content-"+d),eD&&k(/((--!?|])>)|<\/(style|title|textarea)/i,d)||"attributename"===c&&b(d,"href")){tc(l,e);continue}if(a.forceKeepAttr)continue;if(!a.keepAttr||!e_&&k(/\/>/i,d)){tc(l,e);continue}eL&&u([em,ep,eh],e=>{d=y(d,e," ")});let m=te(e.nodeName);if(!tx(m,c,d)){tc(l,e);continue}if(r&&"object"==typeof V&&"function"==typeof V.getAttributeType){if(i);else switch(V.getAttributeType(m,c)){case"TrustedHTML":d=r.createHTML(d);break;case"TrustedScriptURL":d=r.createScriptURL(d)}}if(d!==o)try{i?e.setAttributeNS(i,l,d):e.setAttribute(l,d),tm(e)?to(e):p(n.removed)}catch(t){tc(l,e)}}th(eu.afterSanitizeAttributes,e,null)},ty=function e(t){let r=null,a=tu(t);for(th(eu.beforeSanitizeShadowDOM,t,null);r=a.nextNode();)th(eu.uponSanitizeShadowNode,r,null),tf(r),tb(r),r.content instanceof d&&e(r.content);th(eu.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null,s=null,l=null,o=null;if((e2=!e)&&(e="<!-->"),"string"!=typeof e&&!tp(e)){if("function"==typeof e.toString){if("string"!=typeof(e=e.toString()))throw N("dirty is not a string, aborting")}else throw N("toString is not a function")}if(!n.isSupported)return e;if(eO||tn(t),n.removed=[],"string"==typeof e&&(eB=!1),eB){if(e.nodeName){let t=te(e.nodeName);if(!ev[t]||eS[t])throw N("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof z)(s=(a=td("<!---->")).ownerDocument.importNode(e,!0)).nodeType===X.element&&"BODY"===s.nodeName?a=s:"HTML"===s.nodeName?a=s:a.appendChild(s);else{if(!eF&&!eL&&!eP&&-1===e.indexOf("<"))return r&&ez?r.createHTML(e):e;if(!(a=td(e)))return eF?null:ez?es:""}a&&eI&&to(a.firstChild);let c=tu(eB?e:a);for(;l=c.nextNode();)tf(l),tb(l),l.content instanceof d&&ty(l.content);if(eB)return e;if(eF){if(e$)for(o=eo.call(a.ownerDocument);a.firstChild;)o.appendChild(a.firstChild);else o=a;return(ek.shadowroot||ek.shadowrootmode)&&(o=ed.call(i,o,!0)),o}let m=eP?a.outerHTML:a.innerHTML;return eP&&ev["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&k(Y,a.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+m),eL&&u([em,ep,eh],e=>{m=y(m,e," ")}),r&&ez?r.createHTML(m):m},n.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};tn(e),eO=!0},n.clearConfig=function(){tt=null,eO=!1},n.isValidAttribute=function(e,t,r){return tt||tn({}),tx(te(e),te(t),r)},n.addHook=function(e,t){"function"==typeof t&&h(eu[e],t)},n.removeHook=function(e,t){if(void 0!==t){let r=m(eu[e],t);return -1===r?void 0:f(eu[e],r,1)[0]}return p(eu[e])},n.removeHooks=function(e){eu[e]=[]},n.removeAllHooks=function(){eu=Q()},n}();e.exports=ee},24420:(e,t,r)=>{function a(e){return e&&e.default||e}e.exports=global.DOMPurify=global.DOMPurify||("undefined"!=typeof window?a(r(62829)):function(){let e=a(r(62829)),{JSDOM:t}=a(r(98860)),{window:n}=new t("<!DOCTYPE html>");return e(n)}())},62881:(e,t,r)=>{"use strict";r.d(t,{Z:()=>u});var a=r(17577);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),l=e=>{let t=s(e);return t.charAt(0).toUpperCase()+t.slice(1)},i=(...e)=>e.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim(),o=e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var c={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let d=(0,a.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:l,iconNode:d,...u},m)=>(0,a.createElement)("svg",{ref:m,...c,width:t,height:t,stroke:e,strokeWidth:n?24*Number(r)/Number(t):r,className:i("lucide",s),...!l&&!o(u)&&{"aria-hidden":"true"},...u},[...d.map(([e,t])=>(0,a.createElement)(e,t)),...Array.isArray(l)?l:[l]])),u=(e,t)=>{let r=(0,a.forwardRef)(({className:r,...s},o)=>(0,a.createElement)(d,{ref:o,iconNode:t,className:i(`lucide-${n(l(e))}`,`lucide-${e}`,r),...s}));return r.displayName=l(e),r}},98091:(e,t,r)=>{"use strict";r.d(t,{Z:()=>a});let a=(0,r(62881).Z)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},43353:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return s}});let a=r(91174);r(10326),r(17577);let n=a._(r(77028));function s(e,t){var r;let a={loading:e=>{let{error:t,isLoading:r,pastDelay:a}=e;return null}};"function"==typeof e&&(a.loader=e);let s={...a,...t};return(0,n.default)({...s,modules:null==(r=s.loadableGenerated)?void 0:r.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},933:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return n}});let a=r(94129);function n(e){let{reason:t,children:r}=e;throw new a.BailoutToCSRError(t)}},77028:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return c}});let a=r(10326),n=r(17577),s=r(933),l=r(46618);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},c=function(e){let t={...o,...e},r=(0,n.lazy)(()=>t.loader().then(i)),c=t.loading;function d(e){let i=c?(0,a.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,o=t.ssr?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.PreloadCss,{moduleIds:t.modules}),(0,a.jsx)(r,{...e})]}):(0,a.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(r,{...e})});return(0,a.jsx)(n.Suspense,{fallback:i,children:o})}return d.displayName="LoadableComponent",d}},46618:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadCss",{enumerable:!0,get:function(){return s}});let a=r(10326),n=r(54580);function s(e){let{moduleIds:t}=e,r=(0,n.getExpectedRequestStore)("next/dynamic css"),s=[];if(r.reactLoadableManifest&&t){let e=r.reactLoadableManifest;for(let r of t){if(!e[r])continue;let t=e[r].files.filter(e=>e.endsWith(".css"));s.push(...t)}}return 0===s.length?null:(0,a.jsx)(a.Fragment,{children:s.map(e=>(0,a.jsx)("link",{precedence:"dynamic",rel:"stylesheet",href:r.assetPrefix+"/_next/"+encodeURI(e),as:"style"},e))})}},89249:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>tq});var a=r(10326),n=r(35047),s=r(75433),l=r(17577),i=r.n(l);let o={output:"",realtimeSnippet:"",isActive:!1,isThinking:!1,autoScroll:!0,lastUpdated:null},c={data:null,messageId:null,visible:!1,answering:!1},d={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5},u={type:null,message:null,retryable:!1,retryCount:0};function m(){return{phase:"idle",terminal:{...o},prompt:{...c},layout:{...d},error:{...u},messages:[],wsConnected:!1}}function p(e,t){switch(t.type){case"SET_PHASE":return{...e,phase:t.phase};case"SET_TERMINAL_OUTPUT":return{...e,terminal:{...e.terminal,output:t.output,realtimeSnippet:t.realtimeSnippet,lastUpdated:new Date}};case"SET_TERMINAL_ACTIVE":return{...e,terminal:{...e.terminal,isActive:t.isActive}};case"SET_TERMINAL_THINKING":return{...e,terminal:{...e.terminal,isThinking:t.isThinking}};case"SET_AUTO_SCROLL":return{...e,terminal:{...e.terminal,autoScroll:t.enabled}};case"SHOW_PROMPT":return{...e,phase:"prompt",prompt:{data:t.data,messageId:t.messageId,visible:!0,answering:!1}};case"CLEAR_PROMPT":return{...e,prompt:{...c}};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"SET_ERROR":return{...e,error:t.error};case"CLEAR_ERROR":return{...e,error:{...u}};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};case"START_WAITING_FOR_RESPONSE":return{...e,phase:"waiting",terminal:{...e.terminal,isActive:!0,output:"",realtimeSnippet:""},prompt:{...c}};case"RESPONSE_RECEIVED":return{...e,phase:"complete",messages:[...e.messages,t.message],terminal:{...e.terminal,isActive:!1,isThinking:!1}};case"SESSION_ENDED":return{...e,phase:"idle",terminal:{...o},prompt:{...c}};default:return e}}var h=r(2982),f=r(87403);class x extends l.Component{constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary:${this.props.componentName||"unknown"}]`,e,t),this.props.onError?.(e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:a.jsx(g,{componentName:this.props.componentName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}}function g({componentName:e,error:t,onRetry:r}){return(0,a.jsxs)("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-red-800 mb-2",children:[a.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:a.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),a.jsx("span",{className:"font-medium",children:e?`${e}でエラーが発生しました`:"エラーが発生しました"})]}),t&&a.jsx("p",{className:"text-sm text-red-600 mb-3",children:t.message}),r&&a.jsx("button",{onClick:r,className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 transition-colors text-sm",children:"再試行"})]})}let b=["flex-shrink-0","bg-gray-700","transition-colors","duration-150","hover:bg-blue-500","focus:outline-none","focus:ring-2","focus:ring-blue-500","focus:ring-offset-2","focus:ring-offset-gray-900"],y=["w-1","h-full","cursor-col-resize","hover:w-2"],w=["h-1","w-full","cursor-row-resize","hover:h-2"];function v(e,t){return"touches"in e&&e.touches.length>0?t?e.touches[0].clientX:e.touches[0].clientY:"clientX"in e?t?e.clientX:e.clientY:0}let j=(0,l.memo)(function({onResize:e,orientation:t="horizontal",ariaValueNow:r=50,onDoubleClick:n,minRatio:s=.1}){let[i,o]=(0,l.useState)(!1),c=(0,l.useRef)(0),d=(0,l.useRef)(null),u="horizontal"===t,m=(0,l.useCallback)(e=>{e.preventDefault(),o(!0),c.current=v(e,u)},[u]),p=(0,l.useCallback)(e=>{1===e.touches.length&&(o(!0),c.current=v(e,u))},[u]),h=(0,l.useCallback)(t=>{if(!i)return;let r=v(t,u);e(r-c.current),c.current=r},[i,u,e]),f=(0,l.useCallback)(t=>{if(!i||1!==t.touches.length)return;let r=v(t,u);e(r-c.current),c.current=r},[i,u,e]),x=(0,l.useCallback)(()=>{o(!1)},[]),g=(0,l.useCallback)(()=>{n&&n()},[n]),j=(0,l.useCallback)(t=>{let r=0;u?"ArrowRight"===t.key?r=10:"ArrowLeft"===t.key&&(r=-10):"ArrowDown"===t.key?r=10:"ArrowUp"===t.key&&(r=-10),0!==r&&(t.preventDefault(),e(r))},[u,e]);(0,l.useEffect)(()=>(i&&(document.addEventListener("mousemove",h),document.addEventListener("mouseup",x),document.addEventListener("touchmove",f),document.addEventListener("touchend",x),document.body.style.userSelect="none",document.body.style.cursor=u?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",x),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",x),document.body.style.userSelect="",document.body.style.cursor=""}),[i,h,x,f,u]);let k=(0,l.useMemo)(()=>[...b,...u?y:w,...i?["bg-blue-500","dragging",u?"w-2":"h-2"]:[]].join(" "),[u,i]);return a.jsx("div",{ref:d,role:"separator","aria-orientation":t,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Resize panes. Use ${u?"left and right":"up and down"} arrow keys to adjust.`,tabIndex:0,className:k,onMouseDown:m,onTouchStart:p,onKeyDown:j,onDoubleClick:g})}),k={left:"History",right:"Terminal"},N={left:"HistoryPane",right:"TerminalPane"},C=(0,l.memo)(function({pane:e,isActive:t,onClick:r}){return a.jsx("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`${e}-panel`,onClick:r,className:`flex-1 py-2 px-4 text-sm font-medium transition-colors ${t?"text-blue-400 border-b-2 border-blue-400 bg-gray-900":"text-gray-400 hover:text-gray-300"}`,children:k[e]})}),S=(0,l.memo)(function({leftPane:e,rightPane:t}){let[r,n]=(0,l.useState)("right"),s=(0,l.useCallback)(()=>n("left"),[]),i=(0,l.useCallback)(()=>n("right"),[]);return(0,a.jsxs)("div",{"data-testid":"mobile-layout",className:"flex flex-col h-full",children:[(0,a.jsxs)("div",{className:"flex border-b border-gray-700 bg-gray-800",role:"tablist",children:[a.jsx(C,{pane:"left",isActive:"left"===r,onClick:s}),a.jsx(C,{pane:"right",isActive:"right"===r,onClick:i})]}),a.jsx("div",{id:`${r}-panel`,role:"tabpanel",className:"flex-1 overflow-hidden",children:a.jsx(x,{componentName:N[r],children:"left"===r?e:t})})]})}),E=(0,l.memo)(function({leftPane:e,rightPane:t,leftWidth:r,onResize:n,className:s}){let i=(0,l.useMemo)(()=>({width:`${r}%`}),[r]),o=(0,l.useMemo)(()=>({width:`${100-r}%`}),[r]),c=(0,l.useMemo)(()=>`flex h-full min-h-0 ${s}`.trim(),[s]);return(0,a.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:c,children:[a.jsx("div",{"data-testid":"left-pane","aria-label":"History pane",style:i,className:"flex-shrink-0 overflow-hidden",children:a.jsx(x,{componentName:N.left,children:e})}),a.jsx(j,{onResize:n,orientation:"horizontal",ariaValueNow:r}),a.jsx("div",{"data-testid":"right-pane","aria-label":"Terminal pane",style:o,className:"flex-grow overflow-hidden",children:a.jsx(x,{componentName:N.right,children:t})})]})}),T=(0,l.memo)(function({leftPane:e,rightPane:t,initialLeftWidth:r=50,minLeftWidth:n=20,maxLeftWidth:s=80,className:i=""}){let o=(0,h.d)(),c=(0,l.useRef)(null),[d,u]=(0,l.useState)(r),m=(0,l.useCallback)(e=>{let t=c.current;if(!t)return;let r=t.offsetWidth;if(0===r)return;let a=e/r*100;u(e=>Math.min(s,Math.max(n,e+a)))},[n,s]);return o?a.jsx(S,{leftPane:e,rightPane:t}):a.jsx("div",{ref:c,className:"h-full",children:a.jsx(E,{leftPane:e,rightPane:t,leftWidth:d,onResize:m,className:i})})});var M=r(24420),A=r.n(M),R=r(43053);let _=new(r.n(R)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function L(){return(0,a.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,a.jsxs)("span",{className:"flex gap-1",children:[a.jsx("span",{className:"animate-pulse delay-0",children:"."}),a.jsx("span",{className:"animate-pulse delay-150",children:"."}),a.jsx("span",{className:"animate-pulse delay-300",children:"."})]}),a.jsx("span",{className:"text-sm",children:"Thinking"})]})}let D=(0,l.memo)(function({output:e,isActive:t,isThinking:r=!1,autoScroll:n=!0,onScrollChange:s,className:i=""}){let{scrollRef:o,autoScroll:c,handleScroll:d,scrollToBottom:u}=function(e={}){let{initialAutoScroll:t=!0,onAutoScrollChange:r}=e,a=(0,l.useRef)(null),[n,s]=(0,l.useState)(t),i=(0,l.useCallback)(e=>{s(e),r?.(e)},[r]),o=(0,l.useCallback)(()=>{let e=a.current;if(!e)return!0;let{scrollTop:t,scrollHeight:r,clientHeight:n}=e;return r-n-t<=50},[]),c=(0,l.useCallback)(()=>{let e=o();e&&!n?i(!0):!e&&n&&i(!1)},[n,o,i]),d=(0,l.useCallback)(()=>{let e=a.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),n||i(!0))},[n,i]);return{scrollRef:a,autoScroll:n,setAutoScroll:i,scrollToBottom:d,handleScroll:c}}({initialAutoScroll:n,onAutoScrollChange:s}),m=function(e){let t=_.toHtml(e);return A().sanitize(t,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}(e||"");(0,l.useEffect)(()=>{c&&o.current&&o.current.scrollTo({top:o.current.scrollHeight,behavior:"smooth"})},[m,c,o]);let p=(0,l.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",t?"active":"",t?"border-blue-500":"",i].filter(Boolean).join(" "),[t,i]);return(0,a.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,a.jsxs)("div",{ref:o,role:"log","aria-live":"polite","aria-label":"Terminal output",className:p,onScroll:d,children:[a.jsx("div",{className:"whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:m}}),t&&r&&a.jsx(L,{})]}),!c&&a.jsx("button",{onClick:u,className:"absolute bottom-4 right-4 bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-md text-sm shadow-lg transition-colors","aria-label":"Scroll to bottom",children:"Scroll to bottom"})]})}),P=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function O(e){let t=e.split("\n");if(t.length<=5&&e.length<=300)return{text:e,isTruncated:!1};let r=t.slice(0,5).join("\n");return r.length>300&&(r=r.slice(0,300)),{text:r,isTruncated:!0}}let I=(0,l.memo)(function({content:e,onFilePathClick:t}){let r=(0,l.useMemo)(()=>(function(e){let t=e.match(P);if(!t||0===t.length)return[{type:"text",content:e}];let r=[],a=0;return t.forEach(t=>{let n=e.indexOf(t,a);n>a&&r.push({type:"text",content:e.slice(a,n)}),r.push({type:"path",content:t}),a=n+t.length}),a<e.length&&r.push({type:"text",content:e.slice(a)}),r})(e),[e]),n=(0,l.useCallback)(e=>()=>t(e),[t]);return a.jsx("span",{children:r.map((e,t)=>"path"===e.type?a.jsx("button",{type:"button",onClick:n(e.content),className:"text-blue-400 hover:text-blue-300 hover:underline cursor-pointer font-mono text-sm","aria-label":`Open file: ${e.content}`,children:e.content},t):a.jsx("span",{children:e.content},t))})});function F(){return(0,a.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-gray-400 py-2",children:[(0,a.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"150ms"}}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),a.jsx("span",{className:"text-sm",children:"Waiting for response..."})]})}let $=(0,l.memo)(function({message:e,onFilePathClick:t}){let r=(0,l.useMemo)(()=>e.timestamp.toLocaleTimeString(),[e.timestamp]);return(0,a.jsxs)("div",{className:"bg-blue-900/30 border-l-4 border-blue-500 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"text-xs font-medium text-blue-400",children:"You"}),a.jsx("span",{className:"text-xs text-gray-500",children:r})]}),a.jsx("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words",children:a.jsx(I,{content:e.content,onFilePathClick:t})})]})}),z=(0,l.memo)(function({message:e,index:t,total:r,isExpanded:n,onFilePathClick:s}){let i=(0,l.useMemo)(()=>e.timestamp.toLocaleTimeString(),[e.timestamp]),{text:o,isTruncated:c}=(0,l.useMemo)(()=>O(e.content),[e.content]),d=n||!c?e.content:o;return(0,a.jsxs)("div",{className:"assistant-message-item",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Assistant"}),a.jsx("span",{className:"text-xs text-gray-500",children:i}),r>1&&(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:["(",t+1,"/",r,")"]})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[a.jsx(I,{content:d,onFilePathClick:s}),!n&&c&&a.jsx("span",{className:"text-gray-500",children:"..."})]})]})}),W=(0,l.memo)(function({messages:e,isExpanded:t,onFilePathClick:r}){return a.jsx("div",{className:"bg-gray-800/50 border-l-4 border-gray-600 p-3 border-t border-gray-700 space-y-3",children:e.map((n,s)=>(0,a.jsxs)(i().Fragment,{children:[s>0&&a.jsx("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-gray-600"}),a.jsx(z,{message:n,index:s,total:e.length,isExpanded:t,onFilePathClick:r})]},n.id))})});function U(){return(0,a.jsxs)("div",{"data-testid":"orphan-indicator",className:"bg-yellow-900/20 text-yellow-400 text-xs px-3 py-1 flex items-center gap-2",children:[a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{children:"System Message"})]})}let H=(0,l.memo)(function({pair:e,onFilePathClick:t,isExpanded:r=!1,onToggleExpand:n}){let s=(0,l.useMemo)(()=>e.assistantMessages.some(e=>{let{isTruncated:t}=O(e.content);return t}),[e.assistantMessages]),i=(0,l.useCallback)(()=>{n&&n()},[n]),o=(0,l.useMemo)(()=>{let t="pending"===e.status?"pending":"orphan"===e.status?"orphan border-l-4 border-yellow-600":"";return`border border-gray-700 rounded-lg overflow-hidden mb-4 transition-colors ${t}`.trim()},[e.status]),c=(0,l.useMemo)(()=>{if(e.userMessage){let t=e.userMessage.content.substring(0,50);return`Conversation: ${t}${e.userMessage.content.length>50?"...":""}`}return"System message"},[e.userMessage]);return(0,a.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":c,className:o,children:["orphan"===e.status&&a.jsx(U,{}),e.userMessage&&a.jsx($,{message:e.userMessage,onFilePathClick:t}),"pending"===e.status?a.jsx("div",{className:"bg-gray-800/30 border-l-4 border-gray-600 p-3 border-t border-gray-700",children:a.jsx(F,{})}):e.assistantMessages.length>0?(0,a.jsxs)("div",{className:"relative",children:[a.jsx(W,{messages:e.assistantMessages,isExpanded:r,onFilePathClick:t}),s&&a.jsx("div",{className:"absolute top-2 right-2",children:(0,a.jsxs)("button",{type:"button",onClick:i,className:"text-xs text-blue-400 hover:text-blue-300 flex items-center gap-1 transition-colors bg-gray-800/80 px-2 py-1 rounded","aria-expanded":r,"aria-label":r?"Collapse message":"Expand message",children:[a.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),r?"Collapse":"Expand"]})})]}):null]})});function B(){return(0,a.jsxs)("div",{"data-testid":"loading-indicator",className:"flex items-center justify-center py-4",role:"status","aria-label":"Loading messages",children:[(0,a.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-100"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-200"})]}),a.jsx("span",{className:"ml-2 text-sm text-gray-400",children:"Loading..."})]})}function G(){return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[a.jsx("svg",{className:"w-12 h-12 mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),a.jsx("p",{className:"text-sm",children:"No messages yet"})]})}let q=["h-full","flex","flex-col","overflow-y-auto","overflow-x-hidden","bg-gray-900","rounded-lg","border","border-gray-700"],V=(0,l.memo)(function({messages:e,worktreeId:t,onFilePathClick:r,isLoading:n=!1,className:s=""}){let i=(0,l.useRef)(null),o=(0,l.useRef)(0),c=(0,l.useRef)(e.length);(0,l.useLayoutEffect)(()=>{let e=i.current;e&&(o.current=e.scrollTop)}),(0,l.useLayoutEffect)(()=>{let t=i.current,r=c.current;t&&e.length===r&&requestAnimationFrame(()=>{t.scrollTop=o.current}),c.current=e.length},[e.length]);let{pairs:d,isExpanded:u,toggleExpand:m}=function(e){let t=(0,l.useMemo)(()=>(function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),r=[],a=null;for(let e of t)if("user"===e.role)a={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},r.push(a);else if("assistant"===e.role){if(a&&null!==a.userMessage)a.assistantMessages.push(e),a.status="completed";else if(a&&null===a.userMessage)a.assistantMessages.push(e);else{let t={id:`orphan-${e.id}`,userMessage:null,assistantMessages:[e],status:"orphan"};r.push(t),a=t}}return r})(e),[e]),[r,a]=(0,l.useState)(new Set),n=(0,l.useCallback)(e=>{a(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),s=(0,l.useCallback)(e=>r.has(e),[r]),i=(0,l.useCallback)(()=>{a(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:r,toggleExpand:n,isExpanded:s,expandAll:i,collapseAll:(0,l.useCallback)(()=>{a(new Set)},[])}}(e),p=(0,l.useMemo)(()=>[...q,s].filter(Boolean).join(" "),[s]),h=(0,l.useCallback)(e=>r(e),[r]),f=(0,l.useCallback)(e=>()=>m(e),[m]);return(0,a.jsxs)("div",{ref:i,role:"region","aria-label":"Message history",className:p,children:[a.jsx("div",{className:"sticky top-0 bg-gray-900 border-b border-gray-700 px-4 py-2 z-10",children:a.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Message History"})}),a.jsx("div",{className:"flex-1 p-4 min-h-0",children:n?a.jsx(B,{}):0===e.length?a.jsx(G,{}):d.map(e=>a.jsx(H,{pair:e,onFilePathClick:h,isExpanded:u(e.id),onToggleExpand:f(e.id)},e.id))})]})}),Y={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function Z({visible:e,duration:t=200}){let[r,a]=(0,l.useState)(e?"visible":"hidden");(0,l.useRef)(null),(0,l.useRef)(e);let n="hidden"!==r,s="fade-in"===r||"fade-out"===r;return{shouldRender:n,animationClass:(0,l.useMemo)(()=>{switch(r){case"fade-in":return Y.fadeIn;case"fade-out":return Y.fadeOut;default:return Y.none}},[r]),isAnimating:s}}let K=`
2
+ px-6 py-2 rounded-lg font-medium transition-all
3
+ disabled:opacity-50 disabled:cursor-not-allowed
4
+ focus:outline-none focus:ring-2 focus:ring-offset-2
5
+ `.trim(),X="bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500";function J({promptData:e,answering:t,onRespond:r,onDismiss:n,labelId:s}){let[i,o]=(0,l.useState)(()=>{if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault);return t?.number??null}return null}),[c,d]=(0,l.useState)(""),[u,m]=(0,l.useState)(!1),p=(0,l.useMemo)(()=>"multiple_choice"!==e.type?null:e.options.find(e=>e.number===i)??null,[e,i]),h=p?.requiresTextInput===!0,f=t||u,x=(0,l.useCallback)(async e=>{if(!f){m(!0);try{await r(e)}catch(e){}finally{m(!1)}}},[f,r]),g=(0,l.useCallback)(async()=>{if(!f&&null!==i){m(!0);try{let e=h&&c.trim()?c.trim():i.toString();await r(e)}catch(e){}finally{m(!1)}}},[f,r,i,h,c]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("h3",{id:s,className:"text-lg font-semibold text-yellow-800 flex items-center gap-2",children:[a.jsx("span",{className:"text-xl","aria-hidden":"true",children:"?"}),"Claudeからの確認"]}),n&&a.jsx("button",{type:"button",onClick:n,"aria-label":"close",className:"p-1 rounded hover:bg-yellow-200 transition-colors",children:a.jsx("svg",{className:"w-5 h-5 text-yellow-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsx("p",{className:"text-gray-800 leading-relaxed",children:e.question}),f&&(0,a.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("span",{children:"送信中..."})]}),"yes_no"===e.type&&a.jsx(Q,{promptData:e,disabled:f,onYes:()=>x("yes"),onNo:()=>x("no")}),"multiple_choice"===e.type&&a.jsx(ee,{promptData:e,disabled:f,selectedOption:i,onSelectOption:o,textInputValue:c,onTextInputChange:d,showTextInput:h,onSubmit:g})]})}function Q({promptData:e,disabled:t,onYes:r,onNo:n}){let s="yes"===e.defaultOption,l="no"===e.defaultOption,i=`${K} ${X} ${s?"primary default highlighted":""}`,o=`${K} ${l?"bg-gray-600 text-white hover:bg-gray-700 primary default highlighted":"bg-white border-2 border-gray-300 hover:bg-gray-50 text-gray-800 focus:ring-gray-500"}`;return(0,a.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":"Yes or No options",children:[a.jsx("button",{type:"button",onClick:r,disabled:t,className:i,children:"Yes"}),a.jsx("button",{type:"button",onClick:n,disabled:t,className:o,children:"No"})]})}function ee({promptData:e,disabled:t,selectedOption:r,onSelectOption:n,textInputValue:s,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)(),u=(0,l.useCallback)(e=>{let a=r===e,n=t?"opacity-50 cursor-not-allowed":"";return`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${a?"bg-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"} ${n}`},[r,t]);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("fieldset",{children:[a.jsx("legend",{className:"sr-only",children:"Select an option"}),a.jsx("div",{className:"space-y-2",children:e.options.map(e=>(0,a.jsxs)("label",{className:u(e.number),children:[a.jsx("input",{type:"radio",name:d,value:e.number,checked:r===e.number,onChange:()=>n(e.number),disabled:t,className:"mt-1","aria-describedby":e.isDefault?`default-${e.number}`:void 0}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&a.jsx("span",{id:`default-${e.number}`,className:"ml-2 text-xs text-blue-600 bg-blue-100 px-2 py-0.5 rounded",children:"デフォルト"})]})]},e.number))})]}),o&&(0,a.jsxs)("div",{className:"mt-3",children:[a.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),a.jsx("input",{id:`text-input-${d}`,type:"text",value:s,onChange:e=>i(e.target.value),disabled:t,placeholder:"値を入力してください...",className:"w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 disabled:opacity-50"})]}),a.jsx("button",{type:"button",onClick:c,disabled:t||null===r,className:`w-full ${K} ${X}`,children:"Submit"})]})}function et({promptData:e,messageId:t,visible:r,answering:n,onRespond:s,onDismiss:i}){let o;let{shouldRender:c,animationClass:d}=Z({visible:r&&null!==e,duration:200}),u=(0,l.useId)();if(!c||!e)return null;let m=(o="opacity-100","animate-fade-in"===d?o="opacity-100 transform translate-y-0":"animate-fade-out"===d&&(o="opacity-0 transform translate-y-2"),`bg-yellow-50 border-2 border-yellow-300 rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out ${d} ${o}`);return a.jsx(x,{componentName:"PromptPanel",children:a.jsx("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":u,"aria-modal":"true",className:m,children:a.jsx(J,{promptData:e,answering:n,onRespond:s,onDismiss:i,labelId:u})})})}var er=r(61421);let ea=(0,l.memo)(function({path:e,className:t="w-6 h-6"}){return a.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}),en={back:"M15 19l-7-7 7-7",menu:"M4 6h16M4 12h16M4 18h16"};function es({worktreeName:e,repositoryName:t,status:r,onBackClick:n,onMenuClick:s}){let i=(0,l.useMemo)(()=>er.xh[r],[r]);return a.jsx("header",{"data-testid":"mobile-header",role:"banner",className:"fixed top-0 inset-x-0 bg-white border-b border-gray-200 shadow-sm pt-safe z-40",children:(0,a.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[a.jsx("div",{className:"w-10 flex-shrink-0",children:n&&a.jsx("button",{type:"button",onClick:n,"aria-label":"Back",className:"p-2 -ml-2 rounded-full hover:bg-gray-100 transition-colors",children:a.jsx(ea,{path:en.back})})}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:["spinner"===i.type?a.jsx("span",{"data-testid":"status-indicator","aria-label":i.label,className:`w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 border-2 border-t-transparent animate-spin ${i.className}`}):a.jsx("span",{"data-testid":"status-indicator","aria-label":i.label,className:`w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 ${i.className}`}),(0,a.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[a.jsx("h1",{role:"heading","data-testid":"worktree-name",title:e,className:"text-sm font-medium text-gray-900 truncate text-center leading-tight",children:e}),t&&a.jsx("span",{className:"text-xs text-gray-500 truncate text-center",children:t})]})]}),a.jsx("div",{className:"w-10 flex-shrink-0 flex justify-end",children:s&&a.jsx("button",{type:"button",onClick:s,"aria-label":"Menu",className:"p-2 -mr-2 rounded-full hover:bg-gray-100 transition-colors",children:a.jsx(ea,{path:en.menu})})})]})})}let el=(0,l.memo)(function({path:e,className:t="w-5 h-5"}){return a.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}),ei={terminal:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",files:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z",memo:"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",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},eo=[{id:"terminal",label:"Terminal",icon:a.jsx(el,{path:ei.terminal})},{id:"history",label:"History",icon:a.jsx(el,{path:ei.history})},{id:"files",label:"Files",icon:a.jsx(el,{path:ei.files})},{id:"memo",label:"Memo",icon:a.jsx(el,{path:ei.memo})},{id:"info",label:"Info",icon:a.jsx(el,{path:ei.info})}];function ec({activeTab:e,onTabChange:t,hasNewOutput:r=!1,hasPrompt:n=!1}){let s=(0,l.useCallback)(e=>{t(e)},[t]),i=(0,l.useCallback)(t=>{let r=t===e;return`flex flex-col items-center justify-center flex-1 py-2 px-1 transition-colors relative ${r?"text-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`},[e]),o=(0,l.useMemo)(()=>(0,a.jsxs)(a.Fragment,{children:[r&&a.jsx("span",{"data-testid":"new-output-badge",className:"absolute top-1 right-1 w-2 h-2 bg-green-500 rounded-full","aria-label":"New output available"}),n&&a.jsx("span",{"data-testid":"prompt-badge",className:"absolute top-1 right-3 w-2 h-2 bg-yellow-500 rounded-full","aria-label":"Prompt waiting"})]}),[r,n]);return a.jsx("nav",{"data-testid":"mobile-tab-bar",role:"tablist","aria-label":"Mobile navigation",className:"fixed bottom-0 inset-x-0 bg-white border-t border-gray-200 flex pb-safe z-40",children:eo.map(t=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":e===t.id,"aria-label":t.label,onClick:()=>s(t.id),className:i(t.id),children:[t.icon,a.jsx("span",{className:"text-xs mt-1",children:t.label}),"terminal"===t.id&&o]},t.id))})}let ed={base:"px-6 py-3 rounded-lg font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2",primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-white border-2 border-gray-300 hover:bg-gray-50 text-gray-800 focus:ring-gray-500",defaultSelected:"bg-gray-600 text-white hover:bg-gray-700"};function eu({promptData:e,visible:t,answering:r,onRespond:n,onDismiss:s}){let{shouldRender:i,animationClass:o}=Z({visible:t&&null!==e,duration:300}),c=(0,l.useId)(),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(0),h=(0,l.useRef)(null),f=(0,l.useCallback)(e=>{u(e.touches[0].clientY)},[]),g=(0,l.useCallback)(e=>{if(null===d)return;let t=e.touches[0].clientY-d;t>0&&p(t)},[d]),b=(0,l.useCallback)(()=>{m>100&&s&&s(),p(0),u(null)},[m,s]),y=(0,l.useCallback)(()=>{s&&s()},[s]),w=(0,l.useCallback)(e=>{e.stopPropagation()},[]);if(!i||!e)return null;let v="animate-fade-out"===o,j=m>0?`translateY(${m}px)`:void 0;return(0,a.jsxs)(x,{componentName:"MobilePromptSheet",children:[a.jsx("div",{"data-testid":"prompt-overlay",onClick:y,className:`fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ${v?"opacity-0":"opacity-100"} ${v?"pointer-events-none":""}`,"aria-hidden":"true"}),(0,a.jsxs)("div",{ref:h,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":c,onClick:w,onTouchStart:f,onTouchMove:g,onTouchEnd:b,style:{transform:j},className:`fixed bottom-0 inset-x-0 bg-white rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ${v?"translate-y-full":"translate-y-0"}`,children:[a.jsx("div",{className:"flex justify-center pt-3 pb-2",children:a.jsx("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-gray-300 rounded-full","aria-hidden":"true"})}),a.jsx("div",{className:"px-4 pb-6",children:a.jsx(em,{promptData:e,answering:r,onRespond:n,labelId:c})})]})]})}function em({promptData:e,answering:t,onRespond:r,labelId:n}){let[s,i]=(0,l.useState)(()=>{if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault);return t?.number??null}return null}),[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(!1),m=(0,l.useMemo)(()=>"multiple_choice"!==e.type?null:e.options.find(e=>e.number===s)??null,[e,s]),p=m?.requiresTextInput===!0,h=t||d,f=(0,l.useCallback)(async e=>{if(!h){u(!0);try{await r(e)}catch{}finally{u(!1)}}},[h,r]),x=(0,l.useCallback)(async()=>{if(!h&&null!==s){u(!0);try{let e=p&&o.trim()?o.trim():s.toString();await r(e)}catch{}finally{u(!1)}}},[h,r,s,p,o]);return(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("h3",{id:n,className:"text-lg font-semibold text-gray-900",children:"Claudeからの確認"}),a.jsx("p",{className:"text-gray-700 leading-relaxed",children:e.question}),h&&(0,a.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("span",{children:"送信中..."})]}),"yes_no"===e.type&&a.jsx(ep,{promptData:e,disabled:h,onYes:()=>f("yes"),onNo:()=>f("no")}),"multiple_choice"===e.type&&a.jsx(eh,{promptData:e,disabled:h,selectedOption:s,onSelectOption:i,textInputValue:o,onTextInputChange:c,showTextInput:p,onSubmit:x})]})}let ep=(0,l.memo)(function({promptData:e,disabled:t,onYes:r,onNo:n}){let s="yes"===e.defaultOption,l="no"===e.defaultOption;return(0,a.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":"Yes or No options",children:[a.jsx("button",{type:"button",onClick:r,disabled:t,className:`flex-1 ${ed.base} ${ed.primary} ${s?"ring-2 ring-blue-300":""}`,children:"Yes"}),a.jsx("button",{type:"button",onClick:n,disabled:t,className:`flex-1 ${ed.base} ${l?ed.defaultSelected:ed.secondary}`,children:"No"})]})}),eh=(0,l.memo)(function({promptData:e,disabled:t,selectedOption:r,onSelectOption:n,textInputValue:s,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)();return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("fieldset",{children:[a.jsx("legend",{className:"sr-only",children:"Select an option"}),a.jsx("div",{className:"space-y-2",children:e.options.map(e=>{let s=r===e.number;return(0,a.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${s?"bg-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"} ${t?"opacity-50 cursor-not-allowed":""}`,children:[a.jsx("input",{type:"radio",name:d,value:e.number,checked:s,onChange:()=>n(e.number),disabled:t,className:"mt-1"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&a.jsx("span",{className:"ml-2 text-xs text-blue-600 bg-blue-100 px-2 py-0.5 rounded",children:"デフォルト"})]})]},e.number)})})]}),o&&(0,a.jsxs)("div",{className:"mt-3",children:[a.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),a.jsx("input",{id:`text-input-${d}`,type:"text",value:s,onChange:e=>i(e.target.value),disabled:t,placeholder:"値を入力してください...",className:"w-full px-4 py-3 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 disabled:opacity-50"})]}),a.jsx("button",{type:"button",onClick:c,disabled:t||null===r,className:`w-full ${ed.base} ${ed.primary}`,children:"Submit"})]})});var ef=r(15470);let ex={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};var eg=r(62881);let eb=(0,eg.Z)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),ey=(0,eg.Z)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),ew=(0,eg.Z)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]),ev=(0,eg.Z)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var ej=r(98091);let ek=(0,l.memo)(function({isOpen:e,position:t,targetPath:r,targetType:n,onClose:s,onNewFile:o,onNewDirectory:c,onRename:d,onDelete:u,onUpload:m}){let p=(0,l.useRef)(null),h=(0,l.useCallback)(e=>{e&&r&&e(r),s()},[r,s]),f=[{id:"new-file",label:"New File",icon:a.jsx(eb,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>h(o),showFor:["directory"]},{id:"new-directory",label:"New Directory",icon:a.jsx(ey,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>h(c),showFor:["directory"]},{id:"upload",label:"Upload File",icon:a.jsx(ew,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>h(m),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:"Rename",icon:a.jsx(ev,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>h(d),showDividerAfter:"file"===n},{id:"delete",label:"Delete",icon:a.jsx(ej.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>h(u),variant:"danger"}].filter(e=>!e.showFor||n&&e.showFor.includes(n));return((0,l.useEffect)(()=>{if(!e)return;let t=e=>{if("Escape"===e.key){s();return}if("ArrowDown"===e.key||"ArrowUp"===e.key){let t;e.preventDefault();let r=p.current?.querySelectorAll('[role="menuitem"]');if(!r?.length)return;let a=Array.from(r).findIndex(e=>e===document.activeElement);t="ArrowDown"===e.key?a<r.length-1?a+1:0:a>0?a-1:r.length-1,r[t].focus()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,s]),(0,l.useEffect)(()=>{if(e&&p.current){let e=p.current.querySelector('[role="menuitem"]');e&&e.focus()}},[e]),e)?a.jsx("div",{ref:p,"data-testid":"context-menu",role:"menu","aria-label":"File actions",className:"fixed z-50 min-w-[160px] py-1 bg-white rounded-lg shadow-lg border border-gray-200 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:`${t.x}px`,top:`${t.y}px`},children:f.map((e,t)=>(0,a.jsxs)(i().Fragment,{children:[(0,a.jsxs)("button",{role:"menuitem",onClick:e.onClick,disabled:!r,className:`w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors focus:outline-none focus:bg-gray-100 ${"danger"===e.variant?"text-red-600 hover:bg-red-50 focus:bg-red-50":"text-gray-700 hover:bg-gray-100"} ${r?"":"opacity-50 cursor-not-allowed"}`,children:[e.icon,a.jsx("span",{children:e.label})]}),e.showDividerAfter&&t<f.length-1&&a.jsx("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-gray-200"})]},e.id))}):null});function eN(e,t){let r=null;return(...a)=>{r&&clearTimeout(r),r=setTimeout(()=>{e(...a),r=null},t)}}function eC(e){let t=new Set;for(let r of e){t.add(r);let e=r.split("/"),a="";for(let r=0;r<e.length-1;r++)a=a?`${a}/${e[r]}`:e[r],t.add(a)}return t}let eS=(0,l.memo)(function({expanded:e}){return a.jsx("svg",{"data-testid":"chevron-icon",className:`w-4 h-4 text-gray-500 transition-transform ${e?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),eE=(0,l.memo)(function({open:e}){return a.jsx("svg",{"data-testid":"folder-icon",className:"w-5 h-5 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e?a.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"}):a.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"})})}),eT=(0,l.memo)(function({text:e,query:t}){if(!t||!t.trim())return a.jsx(a.Fragment,{children:e});let r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=e.split(RegExp(`(${r})`,"gi"));return a.jsx(a.Fragment,{children:n.map((e,r)=>e.toLowerCase()===t.toLowerCase()?a.jsx("mark",{className:"bg-yellow-200 text-gray-900 px-0.5 rounded",children:e},r):a.jsx("span",{children:e},r))})}),eM=(0,l.memo)(function({extension:e}){let t=(0,l.useMemo)(()=>e&&({ts:"text-blue-500",tsx:"text-blue-500",js:"text-yellow-400",jsx:"text-yellow-400",json:"text-yellow-600",md:"text-gray-500",css:"text-pink-500",scss:"text-pink-500",html:"text-orange-500",py:"text-green-500"})[e]||"text-gray-400",[e]);return a.jsx("svg",{"data-testid":"file-icon",className:`w-5 h-5 ${t}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.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"})})}),eA=(0,l.memo)(function e({item:t,path:r,depth:n,worktreeId:s,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:f}){var x;let[g,b]=(0,l.useState)(!1),y=r?`${r}/${t.name}`:t.name,w=i.has(y),v="directory"===t.type,j=o.get(y),k=(0,l.useCallback)(async()=>{v?(w||j||(b(!0),await u(y),b(!1)),c(y)):d?.(y)},[v,w,j,y,u,c,d]),N=(0,l.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),k())},[k]),C=(0,l.useCallback)(e=>{m?.(e,y,v?"directory":"file")},[y,v,m]),S={paddingLeft:`${.5+1*Math.min(n,20)}rem`};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{"data-testid":`tree-item-${t.name}`,role:"treeitem","aria-selected":!1,"aria-expanded":v?w:void 0,tabIndex:0,className:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-gray-100 rounded transition-colors",style:S,onClick:k,onKeyDown:N,onContextMenu:C,children:[v?a.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:g?a.jsx("span",{className:"w-3 h-3 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):a.jsx(eS,{expanded:w})}):a.jsx("span",{className:"w-4 h-4"}),v?a.jsx(eE,{open:w}):a.jsx(eM,{extension:t.extension}),a.jsx("span",{className:"flex-1 truncate text-sm text-gray-700",children:"name"===h&&p?a.jsx(eT,{text:t.name,query:p}):t.name}),a.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",children:v?void 0!==t.itemCount&&`${t.itemCount} items`:void 0===(x=t.size)?"":x<1024?`${x} B`:x<1048576?`${(x/1024).toFixed(1)} KB`:`${(x/1048576).toFixed(1)} MB`})]}),v&&w&&j&&a.jsx("div",{role:"group",children:j.filter(e=>{let t=y?`${y}/${e.name}`:e.name;if(!p?.trim())return!0;if("name"===h){let t=p.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===h&&f&&f.size>0){if(f.has(t))return!0;if("directory"===e.type){for(let e of f)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>a.jsx(e,{item:t,path:y,depth:n+1,worktreeId:s,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:f},t.name))})]})}),eR=(0,l.memo)(function({worktreeId:e,onFileSelect:t,onNewFile:r,onNewDirectory:n,onRename:s,onDelete:i,onUpload:o,className:c="",refreshTrigger:d=0,searchQuery:u,searchMode:m,searchResults:p,onSearchResultSelect:h}){let[f,x]=(0,l.useState)(!0),[g,b]=(0,l.useState)(null),[y,w]=(0,l.useState)([]),[v,j]=(0,l.useState)(new Set),[k,N]=(0,l.useState)(()=>new Map),{menuState:C,openMenu:S,closeMenu:E}=function(){let[e,t]=(0,l.useState)(ex);return{menuState:e,openMenu:(0,l.useCallback)((e,r,a)=>{e.preventDefault(),t({isOpen:!0,position:{x:e.clientX,y:e.clientY},targetPath:r,targetType:a})},[]),closeMenu:(0,l.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),resetMenu:(0,l.useCallback)(()=>{t(ex)},[])}}(),T=(0,l.useCallback)(async(t="")=>{try{let r=t?`/api/worktrees/${e}/tree/${t}`:`/api/worktrees/${e}/tree`,a=await fetch(r);if(!a.ok)throw Error(`Failed to load directory: ${a.status}`);return await a.json()}catch(e){throw console.error("[FileTreeView] Error fetching directory:",e),e}},[e]);(0,l.useEffect)(()=>{let e=!0;return(async()=>{x(!0),b(null),N(new Map);try{let t=await T();e&&t&&w(t.items)}catch(t){e&&b(t instanceof Error?t.message:"Failed to load files")}finally{e&&x(!1)}})(),()=>{e=!1}},[T,d]);let M=(0,l.useCallback)(async e=>{if(!k.has(e))try{let t=await T(e);t&&k.set(e,t.items)}catch(e){console.error("[FileTreeView] Error loading children:",e)}},[k,T]),A=(0,l.useCallback)(e=>{j(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),R=(0,l.useMemo)(()=>"content"===m&&p&&0!==p.length?eC(p.map(e=>e.filePath)):new Set,[m,p]);(0,l.useEffect)(()=>{R.size>0&&j(e=>{let t=new Set(e);for(let e of R)(k.has(e)||p?.some(t=>t.filePath.startsWith(e+"/")))&&t.add(e);return t})},[R,k,p]);let _=(0,l.useMemo)(()=>{if(!u?.trim())return y;if("name"===m){let e=u.toLowerCase(),t=(r,a)=>r.filter(r=>{let n=a?`${a}/${r.name}`:r.name,s=r.name.toLowerCase().includes(e);if("directory"===r.type){let e=k.get(n);if(e&&t(e,n).length>0)return!0}return s});return t(y,"")}return"content"===m&&R.size>0?y.filter(e=>{if(R.has(e.name))return!0;if("directory"===e.type){for(let t of R)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):y},[y,u,m,R,k]);return f?(0,a.jsxs)("div",{"data-testid":"file-tree-loading",className:`flex items-center justify-center p-4 ${c}`,children:[a.jsx("span",{className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Loading files..."})]}):g?a.jsx("div",{"data-testid":"file-tree-error",className:`p-4 bg-red-50 border border-red-200 rounded-lg ${c}`,children:a.jsx("p",{className:"text-sm text-red-600",children:g})}):0===y.length?a.jsx("div",{"data-testid":"file-tree-empty",className:`p-4 text-center text-gray-500 ${c}`,children:a.jsx("p",{className:"text-sm",children:"No files found"})}):u?.trim()&&0===_.length?a.jsx("div",{"data-testid":"file-tree-no-results",className:`p-4 text-center text-gray-500 ${c}`,children:(0,a.jsxs)("p",{className:"text-sm",children:["No ","content"===m?"files containing":"files matching",' "',u,'"']})}):(0,a.jsxs)("div",{"data-testid":"file-tree-view",role:"tree","aria-label":"File tree",className:`overflow-auto bg-white ${c}`,children:[_.map(r=>a.jsx(eA,{item:r,path:"",depth:0,worktreeId:e,expanded:v,cache:k,onToggle:A,onFileSelect:h||t,onLoadChildren:M,onContextMenu:S,searchQuery:u,searchMode:m,matchedPaths:R},r.name)),a.jsx(ek,{isOpen:C.isOpen,position:C.position,targetPath:C.targetPath,targetType:C.targetType,onClose:E,onNewFile:r,onNewDirectory:n,onRename:s,onDelete:i,onUpload:o})]})}),e_=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),eL=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),eD=(0,l.memo)(function(){return a.jsx("div",{"data-testid":"search-loading",className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin","aria-label":"Searching..."})}),eP=(0,l.memo)(function({query:e,mode:t,isSearching:r,error:n,onQueryChange:s,onModeChange:i,onClear:o,placeholder:c="Search files...",className:d=""}){let u=(0,l.useRef)(null),m=(0,l.useCallback)(e=>{s(e.target.value)},[s]),p=(0,l.useCallback)(()=>{o(),u.current?.focus()},[o]),h=(0,l.useCallback)(t=>{"Escape"===t.key&&(e?p():u.current?.blur())},[e,p]);return(0,l.useEffect)(()=>{if(!(window.innerWidth<768)){let e=setTimeout(()=>{u.current?.focus()},100);return()=>clearTimeout(e)}},[]),(0,a.jsxs)("div",{"data-testid":"search-bar",className:`flex flex-col gap-2 p-2 bg-white border-b border-gray-200 ${d}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-shrink-0",children:a.jsx(e_,{})}),a.jsx("input",{ref:u,type:"text","data-testid":"search-input",value:e,onChange:m,onKeyDown:h,placeholder:c,className:"flex-1 min-w-0 px-2 py-1 text-sm bg-gray-50 border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search files","aria-busy":r}),a.jsx("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:r?a.jsx(eD,{}):e?a.jsx("button",{type:"button","data-testid":"search-clear",onClick:p,className:"p-1 text-gray-400 hover:text-gray-600 rounded transition-colors","aria-label":"Clear search",children:a.jsx(eL,{})}):null})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Mode:"}),a.jsx("button",{type:"button","data-testid":"mode-name",onClick:()=>i("name"),className:`px-2 py-0.5 text-xs rounded transition-colors ${"name"===t?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,"aria-pressed":"name"===t,children:"Name"}),a.jsx("button",{type:"button","data-testid":"mode-content",onClick:()=>i("content"),className:`px-2 py-0.5 text-xs rounded transition-colors ${"content"===t?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,"aria-pressed":"content"===t,children:"Content"})]}),n&&a.jsx("div",{"data-testid":"search-error",className:"text-xs text-red-600 bg-red-50 px-2 py-1 rounded",role:"alert",children:n})]})}),eO=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),eI=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}),eF=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.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"})})}),e$=[{id:"history",label:"History",icon:a.jsx(eO,{})},{id:"files",label:"Files",icon:a.jsx(eI,{})},{id:"memo",label:"Memo",icon:a.jsx(eF,{})}],ez=(0,l.memo)(function({activeTab:e,onTabChange:t,className:r=""}){let n=(0,l.useCallback)(e=>{t(e)},[t]),s=(0,l.useCallback)((e,r)=>{("Enter"===r.key||" "===r.key)&&(r.preventDefault(),t(e))},[t]),i=(0,l.useCallback)(t=>{let r=t===e;return`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset ${r?"bg-blue-50 text-blue-600 border-b-2 border-blue-600":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`},[e]);return a.jsx("div",{role:"tablist","aria-label":"Left pane view switcher",className:`flex border-b border-gray-200 bg-white ${r}`,children:e$.map(t=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":e===t.id,"aria-label":t.label,tabIndex:0,onClick:()=>n(t.id),onKeyDown:e=>s(t.id,e),className:i(t.id),children:[t.icon,a.jsx("span",{children:t.label})]},t.id))})});var eW=r(77758);function eU({src:e,alt:t,onError:r}){let[n,s]=(0,l.useState)(!1);return n?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[a.jsx("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children: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"})}),a.jsx("p",{className:"text-sm",children:"Failed to load image"}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:t})]}):a.jsx("div",{className:"flex items-center justify-center p-4",children:a.jsx("img",{src:e,alt:t,onError:()=>{s(!0),r?.()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}function eH({isOpen:e,onClose:t,worktreeId:r,filePath:n}){let[s,i]=(0,l.useState)(null),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null);return a.jsx(eW.u_,{isOpen:e,onClose:t,title:n,size:"xl",children:(0,a.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] overflow-y-auto",children:[o&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"ml-3 text-gray-600",children:"Loading file..."})]}),d&&a.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("p",{className:"text-sm text-red-800",children:d})]})}),s&&!o&&!d&&(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg overflow-hidden",children:[a.jsx("div",{className:"bg-gray-100 px-4 py-2 border-b border-gray-200",children:(0,a.jsxs)("p",{className:"text-xs text-gray-600 font-mono",children:[s.worktreePath,"/",s.path]})}),s.isImage?a.jsx(eU,{src:s.content,alt:s.path,mimeType:s.mimeType}):a.jsx("div",{className:"p-4",children:a.jsx("pre",{className:"text-sm overflow-x-auto",children:a.jsx("code",{className:`language-${s.extension}`,children:s.content})})})]})]})})}var eB=r(60962),eG=r(83173),eq=r(26394),eV=r(43286),eY=r(72339);let eZ=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],eK={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...eZ,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...eZ],h2:[["className","sr-only"]],img:[...eZ,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...eZ,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...eZ],table:[...eZ],ul:[...eZ,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},eX={}.hasOwnProperty;function eJ(e,t){if(t&&"object"==typeof t)switch("string"==typeof t.type?t.type:""){case"comment":return function(e,t){if(e.schema.allowComments){let e="string"==typeof t.value?t.value:"",r=e.indexOf("-->"),a={type:"comment",value:r<0?e:e.slice(0,r)};return e2(a,t),a}}(e,t);case"doctype":return function(e,t){if(e.schema.allowDoctypes){let e={type:"doctype"};return e2(e,t),e}}(e,t);case"element":return function(e,t){let r="string"==typeof t.tagName?t.tagName:"";e.stack.push(r);let a=eQ(e,t.children),n=function(e,t){let r;let a=e.stack[e.stack.length-1],n=e.schema.attributes,s=e.schema.required,l=n&&eX.call(n,a)?n[a]:void 0,i=n&&eX.call(n,"*")?n["*"]:void 0,o=t&&"object"==typeof t?t:{},c={};for(r in o)if(eX.call(o,r)){let t=o[r],a=e0(e,e4(l,r),r,t);null==a&&(a=e0(e,e4(i,r),r,t)),null!=a&&(c[r]=a)}if(s&&eX.call(s,a)){let e=s[a];for(r in e)eX.call(e,r)&&!eX.call(c,r)&&(c[r]=e[r])}return c}(e,t.properties);e.stack.pop();let s=!1;if(r&&"*"!==r&&(!e.schema.tagNames||e.schema.tagNames.includes(r))&&(s=!0,e.schema.ancestors&&eX.call(e.schema.ancestors,r))){let t=e.schema.ancestors[r],a=-1;for(s=!1;++a<t.length;)e.stack.includes(t[a])&&(s=!0)}if(!s)return e.schema.strip&&!e.schema.strip.includes(r)?a:void 0;let l={type:"element",tagName:r,properties:n,children:a};return e2(l,t),l}(e,t);case"root":return function(e,t){let r={type:"root",children:eQ(e,t.children)};return e2(r,t),r}(e,t);case"text":return function(e,t){let r={type:"text",value:"string"==typeof t.value?t.value:""};return e2(r,t),r}(0,t)}}function eQ(e,t){let r=[];if(Array.isArray(t)){let a=-1;for(;++a<t.length;){let n=eJ(e,t[a]);n&&(Array.isArray(n)?r.push(...n):r.push(n))}}return r}function e0(e,t,r,a){return t?Array.isArray(a)?function(e,t,r,a){let n=-1,s=[];for(;++n<a.length;){let l=e1(e,t,r,a[n]);("number"==typeof l||"string"==typeof l)&&s.push(l)}return s}(e,t,r,a):e1(e,t,r,a):void 0}function e1(e,t,r,a){if(("boolean"==typeof a||"number"==typeof a||"string"==typeof a)&&function(e,t,r){let a=e.schema.protocols&&eX.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!a||0===a.length)return!0;let n=String(r),s=n.indexOf(":"),l=n.indexOf("?"),i=n.indexOf("#"),o=n.indexOf("/");if(s<0||o>-1&&s>o||l>-1&&s>l||i>-1&&s>i)return!0;let c=-1;for(;++c<a.length;){let e=a[c];if(s===e.length&&n.slice(0,e.length)===e)return!0}return!1}(e,r,a)){if("object"==typeof t&&t.length>1){let e=!1,r=0;for(;++r<t.length;){let n=t[r];if(n&&"object"==typeof n&&"flags"in n){if(n.test(String(a))){e=!0;break}}else if(n===a){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(r)?e.schema.clobberPrefix+a:a}}function e2(e,t){let r=(0,eY.FK)(t);t.data&&(e.data=(0,eV.ZP)(t.data)),r&&(e.position=r)}function e4(e,t){let r;let a=-1;if(e)for(;++a<e.length;){let n=e[a],s="string"==typeof n?n:n[0];if(s===t)return n;"data*"===s&&(r=n)}if(t.length>4&&"data"===t.slice(0,4).toLowerCase())return r}function e5(e){return function(t){return function(e,t){let r={type:"root",children:[]},a=eJ({schema:t?{...eK,...t}:eK,stack:[]},e);return a&&(Array.isArray(a)?1===a.length?r=a[0]:r.children=a:r=a),r}(t,e)}}var e3=r(42283);r(4803);let e6=(0,eg.Z)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),e8=(0,eg.Z)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),e7=(0,eg.Z)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),e9=(0,eg.Z)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),te=(0,eg.Z)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),tt=(0,eg.Z)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),tr=(0,eg.Z)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),ta=(0,eg.Z)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),tn=(0,eg.Z)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),ts=(0,eg.Z)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),tl=(0,eg.Z)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),ti=3e3;function to({type:e,iconColor:t}){let r=`h-5 w-5 ${t}`;switch(e){case"success":return a.jsx(tn,{className:r,"data-testid":"toast-icon-success"});case"error":return a.jsx(ts,{className:r,"data-testid":"toast-icon-error"});default:return a.jsx(tl,{className:r,"data-testid":"toast-icon-info"})}}function tc({id:e,message:t,type:r,onClose:n,duration:s=ti}){let i=(0,l.useRef)(null),o=function(e){switch(e){case"success":return{bgColor:"bg-green-50",borderColor:"border-green-200",textColor:"text-green-800",iconColor:"text-green-500"};case"error":return{bgColor:"bg-red-50",borderColor:"border-red-200",textColor:"text-red-800",iconColor:"text-red-500"};default:return{bgColor:"bg-blue-50",borderColor:"border-blue-200",textColor:"text-blue-800",iconColor:"text-blue-500"}}}(r),c=(0,l.useCallback)(()=>{i.current&&clearTimeout(i.current),n(e)},[e,n]);return(0,a.jsxs)("div",{"data-testid":`toast-${e}`,role:"alert",className:`
6
+ ${o.bgColor}
7
+ ${o.borderColor}
8
+ ${o.textColor}
9
+ border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]
10
+ flex items-start gap-3
11
+ animate-slide-in
12
+ `,children:[a.jsx(to,{type:r,iconColor:o.iconColor}),a.jsx("p",{className:"flex-1 text-sm font-medium",children:t}),a.jsx("button",{"data-testid":"toast-close-button",onClick:c,"aria-label":"Close notification",className:`
13
+ ${o.textColor}
14
+ hover:opacity-70
15
+ focus:outline-none focus:ring-2 focus:ring-offset-2
16
+ transition-opacity
17
+ `,children:a.jsx(ta,{className:"h-4 w-4"})})]})}function td({toasts:e,onClose:t}){return a.jsx("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(e=>a.jsx(tc,{id:e.id,message:e.message,type:e.type,onClose:t,duration:e.duration},e.id))})}function tu(){let[e,t]=(0,l.useState)([]),r=(0,l.useRef)(0);return{toasts:e,showToast:(0,l.useCallback)((e,a="info",n=ti)=>{let s=`toast-${++r.current}-${Date.now()}`,l={id:s,message:e,type:a,duration:n};return t(e=>[...e,l]),s},[]),removeToast:(0,l.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),clearToasts:(0,l.useCallback)(()=>{t([])},[])}}var tm=r(43353),tp=r.n(tm);let th=(0,eg.Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),tf=tp()(async()=>{},{loadableGenerated:{modules:["components/worktree/MermaidCodeBlock.tsx -> ./MermaidDiagram"]},ssr:!1,loading:()=>(0,a.jsxs)("div",{className:"mermaid-loading flex items-center gap-2 text-gray-500 p-4",children:[a.jsx(th,{className:"animate-spin h-4 w-4"}),a.jsx("span",{children:"Loading diagram..."})]})});function tx({className:e,children:t,inline:r}){if(r)return a.jsx("code",{className:e,children:t});if(e&&e.split(" ").includes("language-mermaid")){let e=null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(e=>"string"==typeof e?e:"").join(""):String(t);return a.jsx(tf,{code:e})}return a.jsx("code",{className:e,children:t})}function tg(){return"undefined"==typeof document?null:document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null}async function tb(e){if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullscreen)return e.webkitRequestFullscreen();if(e.mozRequestFullScreen)return e.mozRequestFullScreen();if(e.msRequestFullscreen)return e.msRequestFullscreen();throw Error("Fullscreen API not supported")}async function ty(){if("undefined"!=typeof document){if(document.exitFullscreen)return document.exitFullscreen();if(document.webkitExitFullscreen)return document.webkitExitFullscreen();if(document.mozCancelFullScreen)return document.mozCancelFullScreen();if(document.msExitFullscreen)return document.msExitFullscreen()}}function tw(e){let{key:t,defaultValue:r,validate:a,serialize:n=JSON.stringify,deserialize:s=JSON.parse}=e,[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(r);(0,l.useCallback)(()=>r,[t,r,a,s]);let u=(0,l.useCallback)(e=>{},[t,n]);return{value:c,setValue:(0,l.useCallback)(e=>{d(t=>{let r="function"==typeof e?e(t):e;return u(r),r})},[u]),removeValue:(0,l.useCallback)(()=>{d(r)},[t,r]),isAvailable:i}}let tv=()=>!1;var tj=r(22202);let tk={split:{showEditor:!0,showPreview:!0,editorWidth:"w-1/2",previewWidth:"w-1/2"},editor:{showEditor:!0,showPreview:!1,editorWidth:"w-full",previewWidth:"w-0"},preview:{showEditor:!1,showPreview:!0,editorWidth:"w-0",previewWidth:"w-full"}},tN={WARNING_THRESHOLD:512e3};function tC(e){return"number"==typeof e&&e>=.1&&e<=.9}function tS(e){return"boolean"==typeof e}function tE({worktreeId:e,filePath:t,onClose:r,onSave:n,initialViewMode:s,onMaximizedChange:i}){let[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(""),[f,x]=(0,l.useState)(()=>s&&("split"===s||"editor"===s||"preview"===s)?s:"split"),[g,b]=(0,l.useState)(!0),[y,w]=(0,l.useState)(!1),[v,k]=(0,l.useState)(null),[N,C]=(0,l.useState)(!1),[S,E]=(0,l.useState)("editor"),[T,M]=(0,l.useState)(null),{toasts:A,showToast:R,removeToast:_}=tu(),L=(0,l.useRef)(null);(0,l.useRef)(null);let D=(0,l.useRef)(null),P=(0,l.useRef)(null),O=(0,h.d)(),{isKeyboardVisible:I,keyboardHeight:F}=function(){let[e,t]=(0,l.useState)(!1),[r,a]=(0,l.useState)(0);return(0,l.useCallback)(()=>{if(!tv())return;let e=window.visualViewport,r=window.innerHeight-e.height,n=r>100;t(n),a(n?r:0)},[]),{isKeyboardVisible:e,keyboardHeight:r}}(),{value:$,setValue:z}=tw({key:"commandmate:md-editor-maximized",defaultValue:!1,validate:tS}),{isFullscreen:W,isFallbackMode:U,enterFullscreen:H,exitFullscreen:B,toggleFullscreen:G}=function(e={}){let{elementRef:t,onEnter:r,onExit:a,onError:n}=e,[s,i]=(0,l.useState)(!1),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null);(0,l.useCallback)(()=>{let e=null!=tg();i(e),!e&&o&&c(!1)},[o]);let m=(0,l.useCallback)(async()=>{if(u(null),"undefined"!=typeof navigator&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)){i(!0),c(!0),r?.();return}if("undefined"!=typeof document&&(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)&&t?.current)try{await tb(t.current),i(!0),c(!1),r?.()}catch(t){let e=t instanceof Error?t.message:"Failed to enter fullscreen";u(e),n?.(t instanceof Error?t:Error(e)),i(!0),c(!0),r?.()}else i(!0),c(!0),r?.()},[t,r,n]),p=(0,l.useCallback)(async()=>{if(u(null),o){i(!1),c(!1),a?.();return}if(tg())try{await ty(),i(!1),a?.()}catch(t){let e=t instanceof Error?t.message:"Failed to exit fullscreen";u(e),n?.(t instanceof Error?t:Error(e)),i(!1),c(!1),a?.()}else i(!1),c(!1),a?.()},[o,a,n]),h=(0,l.useCallback)(async()=>{s?await p():await m()},[s,m,p]);return{isFullscreen:s,isFallbackMode:o,enterFullscreen:m,exitFullscreen:p,toggleFullscreen:h,error:d}}({elementRef:D,onEnter:()=>z(!0),onExit:()=>z(!1)}),{value:q,setValue:V}=tw({key:"commandmate:md-editor-split-ratio",defaultValue:.5,validate:tC}),{ref:Y}=function(e={}){let{onSwipeLeft:t,onSwipeRight:r,onSwipeUp:a,onSwipeDown:n,threshold:s=50,enabled:i=!0}=e,o=(0,l.useRef)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),p=(0,l.useRef)(null),h=(0,l.useCallback)(()=>{m(null)},[]);return(0,l.useCallback)(e=>{if(!i)return;let t=e.touches[0];p.current={x:t.clientX,y:t.clientY},d(!0)},[i]),(0,l.useCallback)(e=>{if(!i||!p.current)return;let t=e.touches[0],r=t.clientX-p.current.x,a=t.clientY-p.current.y,n=Math.abs(r),l=Math.abs(a);n>l&&n>=s?m(r<0?"left":"right"):l>=s&&m(a<0?"up":"down")},[i,s]),(0,l.useCallback)(e=>{if(!i||!p.current){d(!1);return}let l=e.changedTouches[0],o=l.clientX-p.current.x,c=l.clientY-p.current.y,u=Math.abs(o),h=Math.abs(c);u>h?u>=s&&(o<0?(m("left"),t?.()):(m("right"),r?.())):h>=s&&(c<0?(m("up"),a?.()):(m("down"),n?.())),p.current=null,d(!1)},[i,s,t,r,a,n]),{ref:o,isSwiping:c,swipeDirection:u,resetSwipeDirection:h}}({onSwipeDown:()=>{W&&B()},threshold:100,enabled:W&&O}),Z=o!==d,K=tk[f],X=O&&!1,J=(0,l.useMemo)(()=>eN(e=>{p(e)},300),[]);(0,l.useCallback)(async()=>{b(!0),k(null);try{let r=await fetch(`/api/worktrees/${e}/files/${t}`),a=await r.json();if(!r.ok||!a.success)throw Error(a.error?.message||"Failed to load file");let n=a.content||"";c(n),u(n),p(n),new Blob([n]).size>tN.WARNING_THRESHOLD&&C(!0)}catch(e){k(e instanceof Error?e.message:"Failed to load file")}finally{b(!1)}},[e,t]);let Q=(0,l.useCallback)(async()=>{if(Z&&!y){w(!0);try{let r=await fetch(`/api/worktrees/${e}/files/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o})}),a=await r.json();if(!r.ok||!a.success)throw Error(a.error?.message||"Failed to save file");u(o),R("File saved successfully","success"),n&&n(t)}catch(e){R(e instanceof Error?e.message:"Failed to save file","error")}finally{w(!1)}}},[e,t,o,Z,y,n,R]),ee=(0,l.useCallback)(e=>{let t=e.target.value;c(t),J(t)},[J]),et=(0,l.useCallback)(e=>{x(e)},[]),er=(0,l.useCallback)(()=>{(!Z||window.confirm("You have unsaved changes. Are you sure you want to close?"))&&r&&r()},[Z,r]),ea=(0,l.useCallback)(e=>{if(!P.current)return;let t=P.current.offsetWidth;if(0===t)return;let r=e/t;V(e=>Math.max(.1,Math.min(.9,e+r)))},[V]),en=(0,l.useCallback)(()=>{V(.5)},[V]),es=(0,l.useCallback)(e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key){e.preventDefault(),Q();return}if((e.ctrlKey||e.metaKey)&&e.shiftKey&&"F"===e.key){e.preventDefault(),G();return}if("Escape"===e.key&&W){e.preventDefault(),B();return}},[Q,G,B,W]),el=(0,l.useMemo)(()=>{let e="flex flex-col bg-white";return W&&U?`${e} fixed inset-0`:`${e} h-full`},[W,U]),ei=(0,l.useMemo)(()=>{if(W)return{zIndex:tj.k.MAXIMIZED_EDITOR}},[W]),eo=(0,l.useMemo)(()=>{if("split"===f&&!X)return{width:`${100*q}%`,flexShrink:0}},[f,q,X]),ec=(0,l.useMemo)(()=>{if("split"===f&&!X)return{width:`${(1-q)*100}%`,flexShrink:0}},[f,q,X]),ed=(0,l.useMemo)(()=>{if(I&&F>0)return{paddingBottom:F}},[I,F]),eu=(0,l.useMemo)(()=>({code:tx}),[]),em=(0,l.useMemo)(()=>a.jsx(eG.UG,{remarkPlugins:[eq.Z],rehypePlugins:[e5,e3.Z],components:eu,children:m}),[m,eu]);if(g)return a.jsx("div",{"data-testid":"markdown-editor",className:"flex items-center justify-center h-full bg-white",children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"mt-4 text-gray-600",children:"Loading..."})]})});if(v)return a.jsx("div",{"data-testid":"markdown-editor-error",className:"flex items-center justify-center h-full bg-white",children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx(e6,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),a.jsx("p",{className:"text-red-600",children:v}),r&&a.jsx("button",{onClick:r,className:"mt-4 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg",children:"Close"})]})});let ep=(0,a.jsxs)("div",{ref:e=>{D.current=e,Y.current=e},"data-testid":"markdown-editor",className:el,style:ei,onKeyDown:es,role:W&&U?"dialog":void 0,"aria-modal":W&&U?"true":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 bg-gray-50",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-shrink",children:[a.jsx(e8,{className:"h-4 w-4 text-gray-500 flex-shrink-0"}),a.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:t}),Z&&a.jsx("span",{"data-testid":"dirty-indicator",className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 flex-shrink-0",children:"Unsaved"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!X&&(0,a.jsxs)("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:[a.jsx("button",{"data-testid":"view-mode-split","aria-pressed":"split"===f,onClick:()=>et("split"),className:`p-1.5 rounded ${"split"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Split view",children:a.jsx(e7,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"view-mode-editor","aria-pressed":"editor"===f,onClick:()=>et("editor"),className:`p-1.5 rounded ${"editor"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Editor only",children:a.jsx(e8,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"view-mode-preview","aria-pressed":"preview"===f,onClick:()=>et("preview"),className:`p-1.5 rounded ${"preview"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Preview only",children:a.jsx(e9,{className:"h-4 w-4"})})]}),a.jsx("button",{"data-testid":"maximize-button",onClick:G,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:W?"Exit fullscreen (ESC)":"Enter fullscreen (Ctrl+Shift+F)","aria-pressed":W,children:W?a.jsx(te,{className:"h-4 w-4"}):a.jsx(tt,{className:"h-4 w-4"})}),(0,a.jsxs)("button",{"data-testid":"save-button",onClick:Q,disabled:!Z||y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${Z&&!y?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:[a.jsx(tr,{className:"h-4 w-4"}),y?"Saving...":"Save"]}),r&&a.jsx("button",{"data-testid":"close-button",onClick:er,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:"Close",children:a.jsx(ta,{className:"h-4 w-4"})})]})]}),W&&(0,a.jsxs)("div",{"data-testid":"maximize-hint",className:"flex items-center justify-center px-4 py-1 bg-gray-800 text-gray-300 text-xs",children:["Press ESC to exit fullscreen ",O&&"(or swipe down)"]}),N&&(0,a.jsxs)("div",{"data-testid":"large-file-warning",className:"flex items-center gap-2 px-4 py-2 bg-yellow-50 border-b border-yellow-200 text-yellow-800 text-sm",children:[a.jsx(e6,{className:"h-4 w-4"}),"Large file: Performance may be affected.",a.jsx("button",{onClick:()=>C(!1),className:"ml-auto text-yellow-600 hover:text-yellow-800",children:a.jsx(ta,{className:"h-4 w-4"})})]}),X&&(0,a.jsxs)("div",{className:"flex border-b border-gray-200",children:[(0,a.jsxs)("button",{"data-testid":"mobile-tab-editor",onClick:()=>E("editor"),className:`flex-1 py-2 text-sm font-medium ${"editor"===S?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"}`,children:[a.jsx(e8,{className:"h-4 w-4 inline-block mr-1"}),"Editor"]}),(0,a.jsxs)("button",{"data-testid":"mobile-tab-preview",onClick:()=>E("preview"),className:`flex-1 py-2 text-sm font-medium ${"preview"===S?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"}`,children:[a.jsx(e9,{className:"h-4 w-4 inline-block mr-1"}),"Preview"]})]}),(0,a.jsxs)("div",{ref:P,className:"flex flex-1 overflow-hidden",style:ed,children:[X?"editor"===S&&a.jsx("div",{"data-testid":"markdown-editor-container",className:"flex flex-col overflow-hidden w-full",children:a.jsx("textarea",{ref:L,"data-testid":"markdown-editor-textarea",value:o,onChange:ee,onKeyDown:es,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}):a.jsx("div",{"data-testid":"markdown-editor-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${K.showEditor?"":"hidden"}`,style:"split"===f?eo:{width:K.showEditor?"100%":"0%"},children:a.jsx("textarea",{ref:L,"data-testid":"markdown-editor-textarea",value:o,onChange:ee,onKeyDown:es,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}),"split"===f&&K.showEditor&&K.showPreview&&!X&&a.jsx(j,{onResize:ea,onDoubleClick:en,orientation:"horizontal",ariaValueNow:Math.round(100*q),minRatio:.1}),X?"preview"===S&&a.jsx("div",{"data-testid":"markdown-preview-container",className:"flex flex-col overflow-hidden w-full",children:a.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:em})}):a.jsx("div",{"data-testid":"markdown-preview-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${K.showPreview?"":"hidden"}`,style:"split"===f?ec:{width:K.showPreview?"100%":"0%"},children:a.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:em})})]}),a.jsx(td,{toasts:A,onClose:_})]});return W&&U&&T?(0,eB.createPortal)(ep,T):ep}let tT=[".md"],tM=[{extension:".png",maxFileSize:5242880,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:5242880,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:5242880,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".txt",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:5242880,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:5242880,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:5242880,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]}],tA=tM.map(e=>e.extension);var tR=r(73002);function t_({value:e,saveFn:t,debounceMs:r=300,disabled:a=!1,maxRetries:n=3,onSaveComplete:s}){let[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(null),u=(0,l.useRef)(e),m=(0,l.useRef)(t),p=(0,l.useRef)(s),h=(0,l.useRef)(null),f=(0,l.useRef)(!0);(0,l.useRef)(e);let x=(0,l.useCallback)(async e=>{if(!f.current)return;o(!0),d(null);let t=null,r=0;for(;r<=n;)try{await m.current(e),f.current&&(o(!1),d(null),p.current?.());return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++r<=n){let e=1e3*Math.pow(2,r-1);await new Promise(t=>setTimeout(t,e))}}f.current&&(o(!1),d(t))},[n]),g=(0,l.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]);return{isSaving:i,error:c,saveNow:(0,l.useCallback)(async()=>{a||(g(),await x(u.current))},[a,g,x])}}let tL=(0,l.memo)(function({memo:e,onUpdate:t,onDelete:r,isSaving:n,error:s,className:i=""}){let[o,c]=(0,l.useState)(e.title),[d,u]=(0,l.useState)(e.content),{isSaving:m,error:p,saveNow:h}=t_({value:o,saveFn:async r=>{await t(e.id,{title:r})}}),{isSaving:f,error:x,saveNow:g}=t_({value:d,saveFn:async r=>{await t(e.id,{content:r})}}),b=s??p?.message??x?.message??null,y=(0,l.useCallback)(e=>{c(e.target.value)},[]),w=(0,l.useCallback)(e=>{u(e.target.value)},[]),v=(0,l.useCallback)(()=>{h()},[h]),j=(0,l.useCallback)(()=>{g()},[g]),k=(0,l.useCallback)(()=>{r(e.id)},[e.id,r]);return(0,a.jsxs)("div",{"data-testid":"memo-card",className:`bg-white border border-gray-200 rounded-lg p-4 space-y-3 ${i}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"text",value:o,onChange:y,onBlur:v,placeholder:"Memo title",className:"flex-1 text-sm font-medium text-gray-900 bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(n??(m||f))&&a.jsx("span",{"data-testid":"saving-indicator",className:"text-xs text-gray-400",children:"Saving..."}),a.jsx("button",{type:"button",onClick:k,"aria-label":"Delete memo",className:"p-1 text-gray-400 hover:text-red-500 transition-colors rounded",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),a.jsx("textarea",{value:d,onChange:w,onBlur:j,placeholder:"Enter memo content...",rows:4,className:"w-full text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),b&&a.jsx("div",{className:"text-xs text-red-500",children:b})]})}),tD=(0,l.memo)(function({currentCount:e,maxCount:t,onAdd:r,isLoading:n=!1,className:s=""}){let l=e>=t||n;return(0,a.jsxs)("div",{"data-testid":"memo-add-button",className:`flex flex-col items-center gap-2 ${s}`,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{l||r()},disabled:l,"aria-label":"Add Memo","aria-disabled":l,className:`
18
+ flex items-center gap-2 px-4 py-2 rounded-lg border-2 border-dashed
19
+ transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500
20
+ ${l?"border-gray-200 text-gray-400 cursor-not-allowed opacity-50":"border-gray-300 text-gray-600 hover:border-blue-400 hover:text-blue-600 hover:bg-blue-50"}
21
+ `,children:[n?a.jsx("span",{"data-testid":"loading-indicator",className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),a.jsx("span",{className:"text-sm font-medium",children:"Add Memo"})]}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[Math.max(0,t-e)," remaining"]})]})}),tP=(0,l.memo)(function({worktreeId:e,className:t=""}){let[r,n]=(0,l.useState)([]),[s,i]=(0,l.useState)(!0),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(null),h=(0,l.useCallback)(async()=>{i(!0),u(null);try{let t=await tR.nE.getAll(e);n(t.sort((e,t)=>e.position-t.position))}catch(e){u((0,tR.zG)(e))}finally{i(!1)}},[e]);(0,l.useEffect)(()=>{h()},[h]);let f=(0,l.useCallback)(async()=>{c(!0),p(null);try{let t=await tR.nE.create(e,{title:"Memo",content:""});n(e=>[...e,t])}catch(e){p((0,tR.zG)(e))}finally{c(!1)}},[e]),x=(0,l.useCallback)(async(t,r)=>{await tR.nE.update(e,t,r),n(e=>e.map(e=>e.id===t?{...e,...r}:e))},[e]),g=(0,l.useCallback)(async t=>{try{await tR.nE.delete(e,t),n(e=>e.filter(e=>e.id!==t))}catch(e){console.error("Failed to delete memo:",e)}},[e]),b=(0,l.useCallback)(()=>{h()},[h]);return s?a.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"text-sm text-gray-500",children:"Loading memos..."})]})}):d?a.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[a.jsx("svg",{className:"w-12 h-12 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{className:"text-sm text-red-600",children:d}),a.jsx("button",{type:"button",onClick:b,"aria-label":"Retry",className:"px-4 py-2 text-sm font-medium text-white bg-blue-500 rounded-lg hover:bg-blue-600 transition-colors",children:"Retry"})]})}):(0,a.jsxs)("div",{"data-testid":"memo-pane",className:`flex flex-col gap-4 p-4 overflow-y-auto ${t}`,children:[0===r.length&&!m&&(0,a.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[a.jsx("p",{children:"No memos yet."}),a.jsx("p",{className:"text-sm",children:"Click the button below to add one."})]}),r.map(e=>a.jsx(tL,{memo:e,onUpdate:x,onDelete:g},e.id)),m&&a.jsx("div",{className:"text-center py-2 text-sm text-red-500",children:m}),a.jsx(tD,{currentCount:r.length,maxCount:5,onAdd:f,isLoading:o,className:"mt-2"})]})});var tO=r(28676);function tI({isOpen:e,onConfirm:t,onCancel:r}){return a.jsx(tO.u,{isOpen:e,onClose:r,title:"Auto Yesモードを有効にしますか?",size:"sm",showCloseButton:!0,children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:"機能説明"}),(0,a.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[a.jsx("li",{children:"yes/no確認 → 自動で「yes」を送信"}),a.jsx("li",{children:"複数選択肢 → デフォルトまたは先頭の選択肢を自動選択"})]}),a.jsx("p",{className:"mt-1",children:"1時間後に自動でOFFになります。"})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:"リスクについて"}),a.jsx("p",{children:"自動応答により、意図しない操作(ファイルの削除・上書き等)が 実行される可能性があります。内容を十分に理解した上でご利用ください。"})]}),a.jsx("div",{className:"bg-yellow-50 border-l-4 border-yellow-400 p-3",children:(0,a.jsxs)("p",{className:"text-sm text-yellow-800",children:[a.jsx("span",{className:"font-medium",children:"免責事項:"}),"Auto Yesモードの使用により発生した問題について、 開発者は一切の責任を負いません。自己責任でご利用ください。"]})}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:"キャンセル"}),a.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium rounded-md bg-yellow-600 hover:bg-yellow-700 text-white",children:"同意して有効化"})]})]})})}let tF=(0,l.memo)(function({enabled:e,expiresAt:t,onToggle:r,lastAutoResponse:n}){let[s,i]=(0,l.useState)(""),[o,c]=(0,l.useState)(null),[d,u]=(0,l.useState)(!1),[m,p]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!e||!t){i("");return}let r=()=>{i(function(e){let t=Math.max(0,e-Date.now());return`${Math.floor(t/6e4).toString().padStart(2,"0")}:${Math.floor(t%6e4/1e3).toString().padStart(2,"0")}`}(t))};r();let a=setInterval(r,1e3);return()=>clearInterval(a)},[e,t]),(0,l.useEffect)(()=>{if(!n)return;c(`Auto responded: "${n}"`);let e=setTimeout(()=>c(null),2e3);return()=>clearTimeout(e)},[n]);let h=(0,l.useCallback)(()=>{e?(u(!0),r(!1).finally(()=>u(!1))):p(!0)},[e,r]),f=(0,l.useCallback)(()=>{p(!1),u(!0),r(!0).finally(()=>u(!1))},[r]),x=(0,l.useCallback)(()=>{p(!1)},[]);return(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 bg-gray-50 border-b border-gray-200",children:[a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":"Auto Yes mode",disabled:d,onClick:h,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${e?"bg-blue-600":"bg-gray-300"} ${d?"opacity-50":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Auto Yes"}),e&&s&&a.jsx("span",{className:"text-sm text-gray-500","aria-label":"Time remaining",children:s}),o&&a.jsx("span",{className:"text-sm text-green-600 animate-pulse",children:o}),a.jsx(tI,{isOpen:m,onConfirm:f,onCancel:x})]})}),t$=(0,l.memo)(function({worktreeName:e,repositoryName:t,description:r,status:n,onBackClick:s,onInfoClick:l,onMenuClick:i}){let o=er.Ie[n],c=r?r.length>50?`${r.substring(0,50)}...`:r:null;return(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-white border-b border-gray-200",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:i,className:"p-2 -ml-2 rounded-lg text-gray-600 hover:text-gray-900 hover:bg-gray-100 transition-colors","aria-label":"Toggle sidebar",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),(0,a.jsxs)("button",{type:"button",onClick:s,className:"flex items-center gap-1 text-gray-600 hover:text-gray-900 transition-colors","aria-label":"Go back to worktree list",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),a.jsx("span",{className:"text-sm font-medium",children:"Back"})]}),a.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),"spinner"===o.type?a.jsx("span",{"data-testid":"desktop-status-indicator",title:o.label,"aria-label":o.label,className:`w-3 h-3 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${o.className}`}):a.jsx("span",{"data-testid":"desktop-status-indicator",title:o.label,"aria-label":o.label,className:`w-3 h-3 rounded-full flex-shrink-0 ${o.className}`}),(0,a.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("h1",{className:"text-lg font-semibold text-gray-900 truncate max-w-[200px] leading-tight",children:e}),c&&a.jsx("span",{className:"text-sm text-gray-500 truncate max-w-md",title:r,children:c})]}),a.jsx("span",{className:"text-xs text-gray-500 truncate max-w-md",children:t})]})]}),(0,a.jsxs)("button",{type:"button",onClick:l,className:"flex items-center gap-1.5 px-3 py-1.5 text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors","aria-label":"View worktree information",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{className:"text-sm font-medium",children:"Info"})]})]})}),tz=(0,l.memo)(function({worktree:e,isOpen:t,onClose:r,onWorktreeUpdate:n}){let[s,i]=(0,l.useState)(!1),[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(!1),m=(0,l.useRef)(t);(0,l.useEffect)(()=>{let r=t&&!m.current;m.current=t,r&&e&&(c(e.description||""),i(!1))},[e,t]);let p=(0,l.useCallback)(async()=>{if(e){u(!0);try{let t=await tR.Iv.updateDescription(e.id,o);n(t),i(!1)}catch(e){console.error("Failed to save description:",e)}finally{u(!1)}}},[e,o,n]),h=(0,l.useCallback)(()=>{c(e?.description||""),i(!1)},[e]);return e?a.jsx(tO.u,{isOpen:t,onClose:r,title:"Worktree Information",size:"md",children:(0,a.jsxs)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto",children:[(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Worktree"}),a.jsx("p",{className:"text-lg font-semibold text-gray-900",children:e.name})]}),(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Repository"}),a.jsx("p",{className:"text-base text-gray-900",children:e.repositoryName}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 break-all",children:e.repositoryPath})]}),(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Path"}),a.jsx("p",{className:"text-sm text-gray-700 break-all font-mono",children:e.path})]}),e.status&&(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Status"}),a.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${"done"===e.status?"bg-green-100 text-green-800":"doing"===e.status?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`,children:e.status.toUpperCase()})]}),(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Description"}),!s&&a.jsx("button",{type:"button",onClick:()=>i(!0),className:"text-sm text-blue-600 hover:text-blue-800",children:"Edit"})]}),s?(0,a.jsxs)("div",{className:"space-y-3",children:[a.jsx("textarea",{value:o,onChange:e=>c(e.target.value),placeholder:"Add notes about this branch...",className:"w-full min-h-[150px] p-3 border border-gray-300 rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",autoFocus:!0}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:p,disabled:d,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:d?"Saving...":"Save"}),a.jsx("button",{type:"button",onClick:h,disabled:d,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 disabled:opacity-50 text-sm font-medium",children:"Cancel"})]})]}):a.jsx("div",{className:"min-h-[50px]",children:e.description?a.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:e.description}):a.jsx("p",{className:"text-sm text-gray-400 italic",children:"No description added yet"})})]}),e.link&&(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Link"}),a.jsx("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline break-all",children:e.link})]}),e.updatedAt&&(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Last Updated"}),a.jsx("p",{className:"text-sm text-gray-700",children:new Date(e.updatedAt).toLocaleString()})]})]})}):null}),tW=(0,l.memo)(function(){return a.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("p",{className:"text-gray-600",children:"Loading worktree..."})]})})}),tU=(0,l.memo)(function({message:e,onRetry:t}){return a.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,a.jsxs)("div",{className:"text-center p-6 bg-red-50 rounded-lg border border-red-200 max-w-md",children:[a.jsx("svg",{className:"mx-auto h-12 w-12 text-red-400 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("p",{className:"text-red-600 font-medium",children:"Error loading worktree"}),a.jsx("p",{className:"text-red-500 text-sm mt-2",children:e}),t&&a.jsx("button",{type:"button",onClick:t,className:"mt-4 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2",children:"Retry"})]})})}),tH=(0,l.memo)(function({worktree:e,onWorktreeUpdate:t}){let[r,n]=(0,l.useState)(!1),[s,i]=(0,l.useState)(""),[o,c]=(0,l.useState)(!1),d=(0,l.useRef)(e?.id);(0,l.useEffect)(()=>{let t=e?.id!==d.current;d.current=e?.id,t&&e&&!r&&i(e.description||"")},[e,r]);let u=(0,l.useCallback)(async()=>{if(e){c(!0);try{let r=await tR.Iv.updateDescription(e.id,s);t(r),n(!1)}catch(e){console.error("Failed to save description:",e)}finally{c(!1)}}},[e,s,t]),m=(0,l.useCallback)(()=>{i(e?.description||""),n(!1)},[e]);return e?(0,a.jsxs)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:[(0,a.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Worktree"}),a.jsx("p",{className:"text-lg font-semibold text-gray-900",children:e.name})]}),(0,a.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Repository"}),a.jsx("p",{className:"text-base text-gray-900",children:e.repositoryName}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 break-all",children:e.repositoryPath})]}),(0,a.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Path"}),a.jsx("p",{className:"text-sm text-gray-700 break-all font-mono",children:e.path})]}),e.status&&(0,a.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Status"}),a.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${"done"===e.status?"bg-green-100 text-green-800":"doing"===e.status?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`,children:e.status.toUpperCase()})]}),(0,a.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Description"}),!r&&a.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-sm text-blue-600 hover:text-blue-800",children:"Edit"})]}),r?(0,a.jsxs)("div",{className:"space-y-3",children:[a.jsx("textarea",{value:s,onChange:e=>i(e.target.value),placeholder:"Add notes about this branch...",className:"w-full min-h-[150px] p-3 border border-gray-300 rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",autoFocus:!0}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:u,disabled:o,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:o?"Saving...":"Save"}),a.jsx("button",{type:"button",onClick:m,disabled:o,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 disabled:opacity-50 text-sm font-medium",children:"Cancel"})]})]}):a.jsx("div",{className:"min-h-[50px]",children:e.description?a.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:e.description}):a.jsx("p",{className:"text-sm text-gray-400 italic",children:"No description added yet"})})]}),e.link&&(0,a.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Link"}),a.jsx("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline break-all",children:e.link})]}),e.updatedAt&&(0,a.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Last Updated"}),a.jsx("p",{className:"text-sm text-gray-700",children:new Date(e.updatedAt).toLocaleString()})]})]}):a.jsx("div",{className:"text-gray-500 text-center py-8",children:"Loading worktree info..."})}),tB=(0,l.memo)(function({activeTab:e,worktreeId:t,worktree:r,messages:n,terminalOutput:s,isTerminalActive:l,isThinking:i,onFilePathClick:o,onFileSelect:c,onWorktreeUpdate:d,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:f,refreshTrigger:g,fileSearch:b}){switch(e){case"terminal":return a.jsx(x,{componentName:"TerminalDisplay",children:a.jsx(D,{output:s,isActive:l,isThinking:i,className:"h-full"})});case"history":return a.jsx(x,{componentName:"HistoryPane",children:a.jsx(V,{messages:n,worktreeId:t,onFilePathClick:o,className:"h-full"})});case"files":return a.jsx(x,{componentName:"FileTreeView",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eP,{query:b.query,mode:b.mode,isSearching:b.isSearching,error:b.error,onQueryChange:b.setQuery,onModeChange:b.setMode,onClear:b.clearSearch}),a.jsx(eR,{worktreeId:t,onFileSelect:c,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:f,refreshTrigger:g,searchQuery:b.query,searchMode:b.mode,searchResults:b.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return a.jsx(x,{componentName:"MemoPane",children:a.jsx(tP,{worktreeId:t,className:"h-full"})});case"info":return a.jsx(tH,{worktree:r,onWorktreeUpdate:d});default:return null}}),tG=(0,l.memo)(function({worktreeId:e}){let t=(0,n.useRouter)(),r=(0,h.d)(),{toggle:s,openMobileDrawer:i}=(0,f.Sz)(),{state:o,actions:c}=function(){let[e,t]=(0,l.useReducer)(p,void 0,m),r=(0,l.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),setTerminalOutput:(e,r)=>t({type:"SET_TERMINAL_OUTPUT",output:e,realtimeSnippet:r}),setTerminalActive:e=>t({type:"SET_TERMINAL_ACTIVE",isActive:e}),setTerminalThinking:e=>t({type:"SET_TERMINAL_THINKING",isThinking:e}),showPrompt:(e,r)=>t({type:"SHOW_PROMPT",data:e,messageId:r}),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,r)=>t({type:"UPDATE_MESSAGE",id:e,updates:r}),clearMessages:()=>t({type:"CLEAR_MESSAGES"}),startWaitingForResponse:e=>t({type:"START_WAITING_FOR_RESPONSE",cliToolId:e}),responseReceived:e=>t({type:"RESPONSE_RECEIVED",message:e}),sessionEnded:()=>t({type:"SESSION_ENDED"}),setAutoScroll:e=>t({type:"SET_AUTO_SCROLL",enabled:e}),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})}),[]);return{state:e,dispatch:t,actions:r}}(),[d,u]=(0,l.useState)(null),[g,b]=(0,l.useState)(!0),[y,w]=(0,l.useState)(null),[v,j]=(0,l.useState)(!1),[k,N]=(0,l.useState)(null),[C,S]=(0,l.useState)(null),[E,M]=(0,l.useState)(!1),[A,R]=(0,l.useState)(!1),[_,L]=(0,l.useState)(null),[P,O]=(0,l.useState)(0),I=function(e){let{worktreeId:t,initialMode:r="name",debounceMs:a=300}=e,[n,s]=(0,l.useState)(""),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(r),[u,m]=(0,l.useState)(!1),[p,h]=(0,l.useState)(null),[f,x]=(0,l.useState)(null),g=(0,l.useRef)(null),b=(0,l.useMemo)(()=>eN(e=>{o(e)},a),[a]),y=(0,l.useCallback)(e=>{s(e),b(e),x(null)},[b]),w=(0,l.useCallback)(()=>{s(""),o(""),h(null),x(null),m(!1),g.current&&(g.current.abort(),g.current=null)},[]),v=(0,l.useCallback)(e=>{if(!i.trim())return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[i]),j=(0,l.useCallback)(()=>p&&0!==p.results.length?eC(p.results.map(e=>e.filePath)):new Set,[p]);return{query:n,mode:c,isSearching:u,results:p,error:f,setQuery:y,setMode:d,clearSearch:w,filterByName:v,getMatchedPaths:j}}({worktreeId:e}),F=(0,l.useRef)(!1),$=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}`);if(!t.ok)throw Error(`Failed to fetch worktree: ${t.status}`);let r=await t.json();return u(r),r}catch(e){return w(e instanceof Error?e.message:"Unknown error"),null}},[e]),z=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/messages?cliTool=claude`);if(!t.ok)throw Error(`Failed to fetch messages: ${t.status}`);let r=await t.json();c.setMessages(r.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching messages:",e)}},[e,c]),W=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/current-output?cliTool=claude`);if(!t.ok)return;let r=await t.json(),a=r.fullOutput??r.realtimeSnippet??"";(a||r.isRunning)&&c.setTerminalOutput(a,r.realtimeSnippet??""),c.setTerminalActive(r.isRunning??!1),c.setTerminalThinking(r.thinking??!1),r.isPromptWaiting&&r.promptData?c.showPrompt(r.promptData,`prompt-${Date.now()}`):!r.isPromptWaiting&&o.prompt.visible&&c.clearPrompt(),r.autoYes&&(R(r.autoYes.enabled),L(r.autoYes.expiresAt))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[e,c,o.prompt.visible]),U=(0,l.useCallback)(e=>{N(e)},[]),H=(0,l.useCallback)(e=>{let t=e.split(".").pop()?.toLowerCase(),r=t?`.${t}`:"";tT.includes(r)?S(e):N(e)},[]),B=(0,l.useCallback)(()=>{N(null)},[]),G=(0,l.useCallback)(()=>{S(null)},[]),q=(0,l.useCallback)(e=>{console.log("[WorktreeDetailRefactored] File saved:",e)},[]),Y=(0,l.useCallback)(e=>{c.setLeftPaneTab(e)},[c]),Z=(0,l.useCallback)(()=>{t.push("/")},[t]),K=(0,l.useCallback)(()=>{j(!0)},[]),X=(0,l.useCallback)(()=>{j(!1)},[]),J=(0,l.useCallback)(async t=>{c.setPromptAnswering(!0);try{let r=await fetch(`/api/worktrees/${e}/prompt-response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answer:t,cliTool:"claude"})});if(!r.ok)throw Error(`Failed to send prompt response: ${r.status}`);c.clearPrompt(),await W()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{c.setPromptAnswering(!1)}},[e,c,W]),Q=(0,l.useCallback)(()=>{c.clearPrompt()},[c]),ee=(0,l.useCallback)(e=>{c.setMobileActivePane(e)},[c]),er=(0,l.useCallback)(e=>{c.setAutoScroll(e)},[c]),ea=(0,l.useCallback)(()=>{z(),W()},[z,W]),en=(0,l.useCallback)(async t=>{try{let r=await fetch(`/api/worktrees/${e}/auto-yes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})});if(r.ok){let e=await r.json();R(e.enabled),L(e.expiresAt)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[e]),el=(0,l.useCallback)(async t=>{let r=window.prompt("Enter file name (e.g., document.md):");if(!r)return;let a=r.endsWith(".md")?r:`${r}.md`,n=t?`${t}/${a}`:a;try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");O(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create file:",e),window.alert("ファイルの作成に失敗しました")}},[e]),ei=(0,l.useCallback)(async t=>{let r=window.prompt("Enter directory name:");if(!r)return;let a=t?`${t}/${r}`:r;try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");O(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert("ディレクトリの作成に失敗しました")}},[e]),eo=(0,l.useCallback)(async t=>{let r=t.split("/").pop()||"",a=window.prompt("Enter new name:",r);if(a&&a!==r)try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:a})})).ok)throw Error("Failed to rename");O(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert("リネームに失敗しました")}},[e]),ed=(0,l.useCallback)(async t=>{let r=t.split("/").pop()||t;if(window.confirm(`"${r}" を削除しますか?`))try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(t)}?recursive=true`,{method:"DELETE"})).ok)throw Error("Failed to delete");(C===t||C?.startsWith(`${t}/`))&&S(null),O(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert("削除に失敗しました")}},[e,C]),{toasts:em,showToast:ep,removeToast:eh}=tu(),ex=(0,l.useRef)(null),eg=(0,l.useRef)(""),eb=(0,l.useCallback)(e=>{eg.current=e,ex.current?.click()},[]),ey=(0,l.useCallback)(async t=>{let r=t.target.files?.[0];if(!r)return;t.target.value="";let a=eg.current,n=`.${r.name.split(".").pop()?.toLowerCase()}`;if(!function(e){if(!e)return!1;let t=e.toLowerCase();return tA.includes(t)}(n)){ep(`Unsupported file type: ${n}. Allowed: ${tA.join(", ")}`,"error");return}let s=function(e){let t=function(e){let t=e.toLowerCase();return tM.find(e=>e.extension===t)}(e);return t?.maxFileSize??5242880}(n);if(r.size>s){ep(`File too large. Maximum size: ${(s/1024/1024).toFixed(1)}MB`,"error");return}let l=new FormData;l.append("file",r);try{let t=await fetch(`/api/worktrees/${e}/upload/${encodeURIComponent(a||".")}`,{method:"POST",body:l});if(!t.ok){let e=await t.json().catch(()=>({})),r=e?.error?.message||"Failed to upload file";ep(r,"error");return}let r=await t.json();ep(`Uploaded: ${r.filename}`,"success"),O(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),ep("Upload failed. Please try again.","error")}},[e,ep]),{lastAutoResponse:ew}=function({worktreeId:e,cliTool:t,isPromptWaiting:r,promptData:a,autoYesEnabled:n}){(0,l.useRef)(null);let[s,i]=(0,l.useState)(null);return{lastAutoResponse:s}}({worktreeId:e,cliTool:"claude",isPromptWaiting:o.prompt.visible,promptData:o.prompt.data,autoYesEnabled:A}),ev=(0,l.useCallback)(async()=>{w(null),b(!0),await $()&&await Promise.all([z(),W()]),b(!1)},[$,z,W]);(0,l.useEffect)(()=>{if(F.current)return;let e=!0;return(async()=>{b(!0);let t=await $();e&&(t&&await Promise.all([z(),W()]),e&&(b(!1),F.current=!0))})(),()=>{e=!1}},[$,z,W]),(0,l.useEffect)(()=>{if(g||y)return;let e=setInterval(async()=>{await Promise.all([W(),$(),z()])},o.terminal.isActive?2e3:5e3);return()=>clearInterval(e)},[g,y,W,$,z,o.terminal.isActive]),(0,l.useEffect)(()=>{c.setLayoutMode(r?"tabs":"split")},[r,c]);let ej=(0,l.useMemo)(()=>(function(e,t){if(t)return"error";if(!e)return"idle";let r=e.sessionStatusByCli?.claude;if(r){if(r.isWaitingForResponse)return"waiting";if(r.isProcessing)return"running";if(r.isRunning)return"ready"}return e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isSessionRunning?"ready":"idle"})(d,null!==o.error.type),[d,o.error.type]),ek=(0,l.useMemo)(()=>o.layout.mobileActivePane,[o.layout.mobileActivePane]),eS=(0,l.useMemo)(()=>o.layout.leftPaneTab,[o.layout.leftPaneTab]),eE=d?.name??"Unknown";return g?a.jsx(tW,{}):y?a.jsx(tU,{message:y,onRetry:ev}):r?a.jsx(x,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(es,{worktreeName:eE,repositoryName:d?.repositoryName,status:ej,onBackClick:Z,onMenuClick:i}),a.jsx("div",{className:"fixed top-14 inset-x-0 z-30",children:a.jsx(tF,{enabled:A,expiresAt:_,onToggle:en,lastAutoResponse:ew})}),a.jsx("main",{className:"flex-1 pt-[6.25rem] pb-32 overflow-hidden",style:{paddingBottom:"calc(8rem + env(safe-area-inset-bottom, 0px))"},children:a.jsx(tB,{activeTab:ek,worktreeId:e,worktree:d,messages:o.messages,terminalOutput:o.terminal.output,isTerminalActive:o.terminal.isActive,isThinking:o.terminal.isThinking,onFilePathClick:U,onFileSelect:H,onWorktreeUpdate:u,onNewFile:el,onNewDirectory:ei,onRename:eo,onDelete:ed,onUpload:eb,refreshTrigger:P,fileSearch:I})}),a.jsx("div",{className:"fixed left-0 right-0 border-t border-gray-200 bg-white p-2 z-30",style:{bottom:"calc(4rem + env(safe-area-inset-bottom, 0px))"},children:a.jsx(ef.R,{worktreeId:e,onMessageSent:ea,cliToolId:"claude",isSessionRunning:o.terminal.isActive})}),a.jsx(ec,{activeTab:ek,onTabChange:ee,hasNewOutput:!1,hasPrompt:o.prompt.visible}),!A&&a.jsx(eu,{promptData:o.prompt.data,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:J,onDismiss:Q}),a.jsx(eH,{isOpen:null!==k,onClose:B,worktreeId:e,filePath:k??""}),C&&a.jsx(tO.u,{isOpen:!0,onClose:G,title:C.split("/").pop()||"Editor",size:"full",disableClose:E,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tE,{worktreeId:e,filePath:C,onClose:G,onSave:q,onMaximizedChange:M})})}),a.jsx("input",{ref:ex,type:"file",accept:tA.join(","),onChange:ey,className:"hidden","aria-label":"Upload file"}),a.jsx(td,{toasts:em,onClose:eh})]})}):a.jsx(x,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col relative",children:[a.jsx(t$,{worktreeName:eE,repositoryName:d?.repositoryName??"Unknown",description:d?.description,status:ej,onBackClick:Z,onInfoClick:K,onMenuClick:s}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(T,{leftPane:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(ez,{activeTab:eS,onTabChange:Y}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["history"===eS&&a.jsx(V,{messages:o.messages,worktreeId:e,onFilePathClick:U,className:"h-full"}),"files"===eS&&a.jsx(x,{componentName:"FileTreeView",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eP,{query:I.query,mode:I.mode,isSearching:I.isSearching,error:I.error,onQueryChange:I.setQuery,onModeChange:I.setMode,onClear:I.clearSearch}),a.jsx(eR,{worktreeId:e,onFileSelect:H,onNewFile:el,onNewDirectory:ei,onRename:eo,onDelete:ed,onUpload:eb,refreshTrigger:P,searchQuery:I.query,searchMode:I.mode,searchResults:I.results?.results,className:"flex-1 min-h-0"})]})}),"memo"===eS&&a.jsx(x,{componentName:"MemoPane",children:a.jsx(tP,{worktreeId:e,className:"h-full"})})]})]}),rightPane:a.jsx(D,{output:o.terminal.output,isActive:o.terminal.isActive,isThinking:o.terminal.isThinking,autoScroll:o.terminal.autoScroll,onScrollChange:er}),initialLeftWidth:40,minLeftWidth:20,maxLeftWidth:60})}),a.jsx("div",{className:"flex-shrink-0 border-t border-gray-200 p-4 bg-gray-50",children:a.jsx(ef.R,{worktreeId:e,onMessageSent:ea,cliToolId:"claude",isSessionRunning:o.terminal.isActive})}),a.jsx(tF,{enabled:A,expiresAt:_,onToggle:en,lastAutoResponse:ew}),o.prompt.visible&&!A&&a.jsx("div",{className:"fixed bottom-20 left-1/2 transform -translate-x-1/2 z-50 w-full max-w-2xl px-4",children:a.jsx(et,{promptData:o.prompt.data,messageId:o.prompt.messageId,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:J,onDismiss:Q})}),a.jsx(tz,{worktree:d,isOpen:v,onClose:X,onWorktreeUpdate:u}),a.jsx(eH,{isOpen:null!==k,onClose:B,worktreeId:e,filePath:k??""}),C&&a.jsx(tO.u,{isOpen:!0,onClose:G,title:C.split("/").pop()||"Editor",size:"full",disableClose:E,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tE,{worktreeId:e,filePath:C,onClose:G,onSave:q,onMaximizedChange:M})})}),a.jsx("input",{ref:ex,type:"file",accept:tA.join(","),onChange:ey,className:"hidden","aria-label":"Upload file"}),a.jsx(td,{toasts:em,onClose:eh})]})})});function tq(){let e=(0,n.useParams)().id;return a.jsx(s.Vw,{children:a.jsx(tG,{worktreeId:e})})}},22570:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>a});let a=(0,r(68570).createProxy)(String.raw`/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx#default`)},4803:()=>{}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,4471,6621,434,8887,3053,6550,9703],()=>r(80205));module.exports=a})();