wind-agent-cli 1.37.2 → 1.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (510) hide show
  1. package/LICENSE +718 -718
  2. package/README.md +17 -2
  3. package/dist/api-docs.html +901 -901
  4. package/dist/assets/{CodeEditor-B2Wf7Fg0.js → CodeEditor-FvgsnJ7J.js} +6 -6
  5. package/dist/assets/FileTree-NLULrBDi.js +1 -0
  6. package/dist/assets/GitPanel-51KUBbEW.js +4 -0
  7. package/dist/assets/{MarkdownPreview-C0tqYnVu.js → MarkdownPreview-PEEWVWeS.js} +17 -27
  8. package/dist/assets/Shell-BEx66cW_.js +76 -0
  9. package/dist/assets/Shell-DrlLKa8f.css +1 -0
  10. package/dist/assets/StandaloneShell-BkuUCPZP.js +1 -0
  11. package/dist/assets/TaskMasterPanel-DfQG80SF.js +2 -0
  12. package/dist/assets/abnfDiagram-N423BO3Z-Cc0ul87U.js +1 -0
  13. package/dist/assets/arc-BAuugHw_.js +1 -0
  14. package/dist/assets/architectureDiagram-T3A2C74G-DA3G7QZD.js +36 -0
  15. package/dist/assets/{blockDiagram-VBNYF7ZC-DpaEf3mv.js → blockDiagram-VBNYF7ZC-tJ12IJs3.js} +4 -4
  16. package/dist/assets/c4Diagram-5PPSVZJV-5BTMCXL4.js +10 -0
  17. package/dist/assets/channel-BGDgNNQz.js +1 -0
  18. package/dist/assets/{chunk-2GRJ4B5K-DoSdNo8u.js → chunk-2GRJ4B5K-BPaI06Ou.js} +1 -1
  19. package/dist/assets/{chunk-2Q5K7J3B-CE7I3uMn.js → chunk-2Q5K7J3B-HV4zmsEe.js} +1 -1
  20. package/dist/assets/chunk-5RXB4S5H-BAwutJoU.js +231 -0
  21. package/dist/assets/{chunk-5VM5RSS4-B55XgqHZ.js → chunk-5VM5RSS4-B9QAJPrv.js} +1 -1
  22. package/dist/assets/{chunk-6Q2QTUOP-BS1KpefW.js → chunk-6Q2QTUOP-BOIW8bzI.js} +1 -1
  23. package/dist/assets/chunk-GF5L2VYU-DD13o00-.js +206 -0
  24. package/dist/assets/{chunk-JWPE2WC7-DOtkNhMm.js → chunk-JWPE2WC7-CFBm23VK.js} +1 -1
  25. package/dist/assets/{chunk-KBJHAD2P-BXLjviqM.js → chunk-KBJHAD2P-C0i0v8Op.js} +1 -1
  26. package/dist/assets/{chunk-RYQCIY6F-C50fjNNz.js → chunk-RYQCIY6F-DfeK0taV.js} +1 -1
  27. package/dist/assets/{chunk-XXDRQBXY-QBYqCkb7.js → chunk-XXDRQBXY-BKWvf-QE.js} +1 -1
  28. package/dist/assets/classDiagram-JCYQIIEL-C2SNM4oy.js +1 -0
  29. package/dist/assets/classDiagram-v2-OCEON4UE-C2SNM4oy.js +1 -0
  30. package/dist/assets/cose-bilkent-JH36ORCC-CBE8oM7L.js +1 -0
  31. package/dist/assets/{cynefin-VYW2F7L2-DnJa_OlQ.js → cynefin-VYW2F7L2-DziGp35A.js} +11 -23
  32. package/dist/assets/cynefinDiagram-MW4NZA55-CNvtHl39.js +62 -0
  33. package/dist/assets/cytoscape.esm-yzknjiTM.js +321 -0
  34. package/dist/assets/dagre-VZM6K2ZE-Bz9lsU7m.js +4 -0
  35. package/dist/assets/{diagram-7IWD3JNH-pFzs9HEu.js → diagram-7IWD3JNH-CV7D3VSd.js} +5 -5
  36. package/dist/assets/{diagram-B4RE2ZJO-CcehQC7x.js → diagram-B4RE2ZJO-Dj4EjDNC.js} +2 -2
  37. package/dist/assets/diagram-LBJQPF4R-wJ6FHvf-.js +24 -0
  38. package/dist/assets/diagram-Q27KOJAE-DMFYMhOB.js +24 -0
  39. package/dist/assets/diagram-UB23O5K3-DeBSbWAI.js +41 -0
  40. package/dist/assets/ebnfDiagram-BXEA7PRR-2NnJSGhT.js +1 -0
  41. package/dist/assets/erDiagram-JOGREHBK-DrSlg8hr.js +85 -0
  42. package/dist/assets/feature-chat-CvOCyaLe.js +88 -0
  43. package/dist/assets/feature-workspace-CAB6bgPy.js +39 -0
  44. package/dist/assets/{flowDiagram-UKHOOZJN-CJV8fQPR.js → flowDiagram-UKHOOZJN-C0pejU6W.js} +4 -4
  45. package/dist/assets/ganttDiagram-PKOTCBZU-BM0VCUUz.js +292 -0
  46. package/dist/assets/gitGraphDiagram-DS77QQ5N-SbLG0c5_.js +106 -0
  47. package/dist/assets/graph-DOmOIIwC.js +1 -0
  48. package/dist/assets/{index-GFhXZyl2.js → index-BflGfU1C.js} +3 -3
  49. package/dist/assets/index-Btkf0_rU.js +1 -0
  50. package/dist/assets/index-Cr5MbHuj.css +1 -0
  51. package/dist/assets/index-Gqazqfs3.js +1 -0
  52. package/dist/assets/index-nyrkoQK6.js +35 -0
  53. package/dist/assets/infoDiagram-6WML65LV-Cf5DSa66.js +2 -0
  54. package/dist/assets/ishikawaDiagram-WSZJBQD7-DwyFutKy.js +70 -0
  55. package/dist/assets/journeyDiagram-NVQOT4AX-Df0FRhLo.js +139 -0
  56. package/dist/assets/{kanban-definition-27J2QSJJ-B3iL0ztJ.js → kanban-definition-27J2QSJJ-HmpbjrZz.js} +6 -6
  57. package/dist/assets/{layout-D6BstSzF.js → layout-D-LzfAck.js} +1 -1
  58. package/dist/assets/{linear-Cwe9dEKA.js → linear-DOM01LBe.js} +1 -1
  59. package/dist/assets/map-DxJ2ADlA.js +1 -0
  60. package/dist/assets/mermaid.core-C2Ma-_S6.js +306 -0
  61. package/dist/assets/{mindmap-definition-FAOFIHXS-BgfBYMzr.js → mindmap-definition-FAOFIHXS-B4GOIn76.js} +4 -4
  62. package/dist/assets/pegDiagram-VL7TDLO6-BHur7aH2.js +1 -0
  63. package/dist/assets/{pieDiagram-7S7Q4E2Y-DeSrxc4I.js → pieDiagram-7S7Q4E2Y-Cw0UELLV.js} +2 -2
  64. package/dist/assets/quadrantDiagram-CIZ2JOQS-CB2BrX3g.js +7 -0
  65. package/dist/assets/railroadDiagram-AXF67PYL-DPYZYmLX.js +1 -0
  66. package/dist/assets/requirementDiagram-LRYGKXZP-DSX4IJ1n.js +84 -0
  67. package/dist/assets/sankeyDiagram-W5VNT64P-TenC3ZQo.js +40 -0
  68. package/dist/assets/sequenceDiagram-SI44F4Z6-DltGsf3F.js +162 -0
  69. package/dist/assets/sizeCapture-X5ZJPWSS-D7llwbJZ.js +1 -0
  70. package/dist/assets/stateDiagram-OKZ733FA-C-hAvbnY.js +1 -0
  71. package/dist/assets/stateDiagram-v2-UEYNNEHI-DaYSFcRQ.js +1 -0
  72. package/dist/assets/swimlanes-SLNWSIFB-DWD30fv6.js +2 -0
  73. package/dist/assets/swimlanesDiagram-ULZ7WXOC-LTkF2T6t.js +8 -0
  74. package/dist/assets/timeline-definition-Z64GVDOM-quWmimSE.js +120 -0
  75. package/dist/assets/vendor-data-DsEZeNPr.js +4 -0
  76. package/dist/assets/vendor-i18n-B6HjLCnN.js +1 -0
  77. package/dist/assets/vendor-markdown-DkITEES2.js +298 -0
  78. package/dist/assets/vendor-react-C2GTiUCy.js +10 -0
  79. package/dist/assets/vendor-ui-CAUHSABu.js +49 -0
  80. package/dist/assets/vennDiagram-T6HMQDX7-aUQcm8h5.js +34 -0
  81. package/dist/assets/{wardleyDiagram-T6FBY63Y-BNCpsFZV.js → wardleyDiagram-T6FBY63Y-BZ0bwsFQ.js} +2 -2
  82. package/dist/assets/workbox-window.prod.es5-BBnX5xw4.js +2 -0
  83. package/dist/assets/xychartDiagram-ELKLHX3M-DOVzAq63.js +7 -0
  84. package/dist/clear-cache.html +85 -85
  85. package/dist/convert-icons.md +52 -52
  86. package/dist/favicon.png +0 -0
  87. package/dist/favicon.svg +8 -8
  88. package/dist/generate-icons.js +48 -48
  89. package/dist/icons/codex-white.svg +3 -3
  90. package/dist/icons/codex.svg +3 -3
  91. package/dist/icons/cursor-white.svg +11 -11
  92. package/dist/icons/icon-128x128.png +0 -0
  93. package/dist/icons/icon-128x128.svg +11 -11
  94. package/dist/icons/icon-144x144.png +0 -0
  95. package/dist/icons/icon-144x144.svg +11 -11
  96. package/dist/icons/icon-152x152.png +0 -0
  97. package/dist/icons/icon-152x152.svg +11 -11
  98. package/dist/icons/icon-180x180.png +0 -0
  99. package/dist/icons/icon-192x192.png +0 -0
  100. package/dist/icons/icon-192x192.svg +11 -11
  101. package/dist/icons/icon-384x384.png +0 -0
  102. package/dist/icons/icon-384x384.svg +11 -11
  103. package/dist/icons/icon-512x512.png +0 -0
  104. package/dist/icons/icon-512x512.svg +11 -11
  105. package/dist/icons/icon-72x72.png +0 -0
  106. package/dist/icons/icon-72x72.svg +11 -11
  107. package/dist/icons/icon-96x96.png +0 -0
  108. package/dist/icons/icon-96x96.svg +11 -11
  109. package/dist/icons/icon-maskable-192x192.png +0 -0
  110. package/dist/icons/icon-maskable-512x512.png +0 -0
  111. package/dist/icons/icon-template.svg +11 -11
  112. package/dist/icons/new-icon.png +0 -0
  113. package/dist/index.html +48 -58
  114. package/dist/logo-128.png +0 -0
  115. package/dist/logo-256.png +0 -0
  116. package/dist/logo.svg +17 -17
  117. package/dist/manifest.webmanifest +1 -0
  118. package/dist/push-sw.js +48 -0
  119. package/dist/screenshots/setup-screen-mobile.png +0 -0
  120. package/dist/screenshots/setup-screen.png +0 -0
  121. package/dist/sw.js +1 -124
  122. package/dist/workbox-ae5c0bb2.js +1 -0
  123. package/dist-server/server/index.js +1 -1
  124. package/dist-server/server/index.js.map +1 -1
  125. package/dist-server/server/load-env.js +4 -2
  126. package/dist-server/server/load-env.js.map +1 -1
  127. package/dist-server/server/modules/agent/agent.routes.js +1 -1
  128. package/dist-server/server/modules/agent/agent.routes.js.map +1 -1
  129. package/dist-server/server/modules/browser-use/browser-use.service.js +1 -1
  130. package/dist-server/server/modules/browser-use/browser-use.service.js.map +1 -1
  131. package/dist-server/server/modules/cli/cli.service.js +37 -37
  132. package/dist-server/server/modules/cli/cli.service.js.map +1 -1
  133. package/dist-server/server/modules/cli/sandbox.service.js +43 -43
  134. package/dist-server/server/modules/cli/sandbox.service.js.map +1 -1
  135. package/dist-server/server/modules/cli/tests/cli-environment-bootstrap.test.js +74 -74
  136. package/dist-server/server/modules/commands/commands.routes.js +25 -25
  137. package/dist-server/server/modules/commands/commands.routes.js.map +1 -1
  138. package/dist-server/server/modules/commands/tests/commands.test.js +1 -1
  139. package/dist-server/server/modules/commands/tests/commands.test.js.map +1 -1
  140. package/dist-server/server/modules/database/connection.js +1 -1
  141. package/dist-server/server/modules/database/connection.js.map +1 -1
  142. package/dist-server/server/modules/database/migrations.js +190 -190
  143. package/dist-server/server/modules/database/repositories/api-keys.js +3 -3
  144. package/dist-server/server/modules/database/repositories/github-tokens.js +2 -2
  145. package/dist-server/server/modules/database/repositories/notification-channel-endpoints.js +28 -28
  146. package/dist-server/server/modules/database/repositories/notification-preferences.js +4 -4
  147. package/dist-server/server/modules/database/repositories/projects.db.js +61 -61
  148. package/dist-server/server/modules/database/repositories/provider-models.js +35 -35
  149. package/dist-server/server/modules/database/repositories/push-subscriptions.js +5 -5
  150. package/dist-server/server/modules/database/repositories/scan-state.db.js +5 -5
  151. package/dist-server/server/modules/database/repositories/sessions.db.js +93 -93
  152. package/dist-server/server/modules/database/schema.js +177 -177
  153. package/dist-server/server/modules/database/tests/projects.db.integration.test.js +3 -2
  154. package/dist-server/server/modules/database/tests/projects.db.integration.test.js.map +1 -1
  155. package/dist-server/server/modules/database/tests/provider-models.db.integration.test.js +6 -6
  156. package/dist-server/server/modules/database/tests/sessions-provider-mapping.test.js +4 -3
  157. package/dist-server/server/modules/database/tests/sessions-provider-mapping.test.js.map +1 -1
  158. package/dist-server/server/modules/database/tests/sessions.db.integration.test.js +2 -1
  159. package/dist-server/server/modules/database/tests/sessions.db.integration.test.js.map +1 -1
  160. package/dist-server/server/modules/git/git.routes.js +17 -17
  161. package/dist-server/server/modules/notifications/services/notification-orchestrator.service.js +1 -1
  162. package/dist-server/server/modules/notifications/services/notification-orchestrator.service.js.map +1 -1
  163. package/dist-server/server/modules/notifications/vapid-keys.service.js +1 -1
  164. package/dist-server/server/modules/notifications/vapid-keys.service.js.map +1 -1
  165. package/dist-server/server/modules/projects/tests/project-management.service.test.js +2 -1
  166. package/dist-server/server/modules/projects/tests/project-management.service.test.js.map +1 -1
  167. package/dist-server/server/modules/providers/list/codex/codex-app-server.client.js +2 -2
  168. package/dist-server/server/modules/providers/list/codex/codex-app-server.client.js.map +1 -1
  169. package/dist-server/server/modules/providers/list/codex/codex-models.provider.js +1 -1
  170. package/dist-server/server/modules/providers/list/codex/codex-models.provider.js.map +1 -1
  171. package/dist-server/server/modules/providers/list/cursor/cursor-models.provider.js +1 -1
  172. package/dist-server/server/modules/providers/list/cursor/cursor-models.provider.js.map +1 -1
  173. package/dist-server/server/modules/providers/list/cursor/cursor-session-synchronizer.provider.js.map +1 -1
  174. package/dist-server/server/modules/providers/list/opencode/opencode-models.provider.js +13 -13
  175. package/dist-server/server/modules/providers/list/opencode/opencode-runtime.provider.js +9 -9
  176. package/dist-server/server/modules/providers/list/opencode/opencode-runtime.provider.test.js +17 -17
  177. package/dist-server/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.js +25 -25
  178. package/dist-server/server/modules/providers/list/opencode/opencode-sessions.provider.js +27 -27
  179. package/dist-server/server/modules/providers/services/provider-token-usage.service.js +9 -9
  180. package/dist-server/server/modules/providers/services/sessions.service.js +1 -1
  181. package/dist-server/server/modules/providers/tests/claude-auth.test.js +8 -0
  182. package/dist-server/server/modules/providers/tests/claude-auth.test.js.map +1 -1
  183. package/dist-server/server/modules/providers/tests/codex-sessions.test.js +1 -1
  184. package/dist-server/server/modules/providers/tests/codex-sessions.test.js.map +1 -1
  185. package/dist-server/server/modules/providers/tests/mcp.test.js +3 -3
  186. package/dist-server/server/modules/providers/tests/opencode-sessions.test.js +98 -98
  187. package/dist-server/server/modules/providers/tests/opencode-sessions.test.js.map +1 -1
  188. package/dist-server/server/modules/providers/tests/provider-token-usage.service.test.js +18 -18
  189. package/dist-server/server/modules/providers/tests/provider.routes.test.js +1 -1
  190. package/dist-server/server/modules/providers/tests/provider.routes.test.js.map +1 -1
  191. package/dist-server/server/modules/system/system.service.js +1 -1
  192. package/dist-server/server/modules/system/system.service.js.map +1 -1
  193. package/dist-server/server/modules/system/tests/system.service.test.js +1 -1
  194. package/dist-server/server/modules/system/tests/system.service.test.js.map +1 -1
  195. package/dist-server/server/modules/taskmaster/taskmaster.routes.js +423 -422
  196. package/dist-server/server/modules/taskmaster/taskmaster.routes.js.map +1 -1
  197. package/dist-server/server/modules/websocket/services/shell-websocket.service.js +1 -1
  198. package/dist-server/server/modules/websocket/services/shell-websocket.service.js.map +1 -1
  199. package/dist-server/server/modules/worktrees/services/worktree-list.service.js +1 -1
  200. package/dist-server/server/modules/worktrees/services/worktree-open.service.js +1 -1
  201. package/dist-server/server/modules/worktrees/services/worktree-remove.service.js +1 -1
  202. package/electron/cloud.js +260 -260
  203. package/electron/desktopNotifications.js +378 -378
  204. package/electron/desktopWindow.js +766 -766
  205. package/electron/launcher/index.html +14 -14
  206. package/electron/launcher/launcher.css +801 -801
  207. package/electron/launcher/launcher.js +687 -687
  208. package/electron/localServer.js +549 -549
  209. package/electron/main.js +944 -944
  210. package/electron/preload.cjs +60 -60
  211. package/electron/scripts/generate-macos-icon.js +62 -62
  212. package/electron/serverInstaller.js +277 -277
  213. package/electron/tabs.js +87 -87
  214. package/electron/viewHost.js +331 -331
  215. package/package.json +262 -247
  216. package/public/api-docs.html +901 -901
  217. package/scripts/build-client.mjs +30 -0
  218. package/scripts/fix-node-pty.js +67 -67
  219. package/scripts/generate-pwa-icons.ps1 +33 -0
  220. package/scripts/promote-dist-server.mjs +50 -50
  221. package/scripts/release/build-server-bundle.js +176 -176
  222. package/scripts/release/prepare-desktop-app.js +152 -152
  223. package/scripts/verify-pwa-build.mjs +37 -0
  224. package/server/index.ts +399 -399
  225. package/server/load-env.ts +49 -47
  226. package/server/modules/agent/agent.module.ts +52 -52
  227. package/server/modules/agent/agent.routes.ts +1287 -1287
  228. package/server/modules/agent/index.ts +2 -2
  229. package/server/modules/agent/tests/agent.routes.test.ts +205 -205
  230. package/server/modules/assets/assets.routes.ts +150 -150
  231. package/server/modules/assets/index.ts +3 -3
  232. package/server/modules/assets/services/image-assets.service.ts +127 -127
  233. package/server/modules/assets/tests/image-assets.service.test.ts +74 -74
  234. package/server/modules/auth/auth.middleware.ts +163 -163
  235. package/server/modules/auth/auth.module.ts +38 -38
  236. package/server/modules/auth/auth.routes.ts +57 -57
  237. package/server/modules/auth/auth.service.ts +155 -155
  238. package/server/modules/auth/index.ts +9 -9
  239. package/server/modules/auth/tests/auth.service.test.ts +95 -95
  240. package/server/modules/browser-use/browser-use-mcp.routes.ts +120 -120
  241. package/server/modules/browser-use/browser-use-mcp.ts +386 -386
  242. package/server/modules/browser-use/browser-use-runtime.ts +10 -10
  243. package/server/modules/browser-use/browser-use.routes.ts +96 -96
  244. package/server/modules/browser-use/browser-use.service.ts +836 -836
  245. package/server/modules/browser-use/index.ts +11 -11
  246. package/server/modules/browser-use/tests/browser-use.service.test.ts +10 -10
  247. package/server/modules/cli/cli.module.ts +93 -93
  248. package/server/modules/cli/cli.service.ts +248 -248
  249. package/server/modules/cli/cli.ts +19 -19
  250. package/server/modules/cli/index.ts +2 -2
  251. package/server/modules/cli/sandbox.service.ts +398 -398
  252. package/server/modules/cli/tests/cli-environment-bootstrap.test.ts +186 -186
  253. package/server/modules/cli/tests/cli.service.test.ts +86 -86
  254. package/server/modules/cli/tests/sandbox.service.test.ts +58 -58
  255. package/server/modules/commands/commands.module.ts +22 -22
  256. package/server/modules/commands/commands.routes.ts +587 -587
  257. package/server/modules/commands/index.ts +2 -2
  258. package/server/modules/commands/tests/commands.test.ts +110 -110
  259. package/server/modules/database/connection.ts +144 -143
  260. package/server/modules/database/index.ts +17 -17
  261. package/server/modules/database/init-db.ts +17 -17
  262. package/server/modules/database/migrations.ts +515 -515
  263. package/server/modules/database/repositories/api-keys.ts +119 -119
  264. package/server/modules/database/repositories/app-config.ts +53 -53
  265. package/server/modules/database/repositories/credentials.ts +106 -106
  266. package/server/modules/database/repositories/github-tokens.ts +100 -100
  267. package/server/modules/database/repositories/notification-channel-endpoints.ts +153 -153
  268. package/server/modules/database/repositories/notification-preferences.ts +117 -117
  269. package/server/modules/database/repositories/projects.db.ts +196 -196
  270. package/server/modules/database/repositories/provider-models.ts +168 -168
  271. package/server/modules/database/repositories/push-subscriptions.ts +80 -80
  272. package/server/modules/database/repositories/scan-state.db.ts +42 -42
  273. package/server/modules/database/repositories/sessions.db.ts +524 -524
  274. package/server/modules/database/repositories/users.ts +140 -140
  275. package/server/modules/database/repositories/vapid-keys.ts +57 -57
  276. package/server/modules/database/schema.ts +210 -210
  277. package/server/modules/database/tests/projects.db.integration.test.ts +73 -72
  278. package/server/modules/database/tests/provider-models.db.integration.test.ts +125 -125
  279. package/server/modules/database/tests/sessions-provider-mapping.test.ts +110 -109
  280. package/server/modules/database/tests/sessions.db.integration.test.ts +117 -116
  281. package/server/modules/file-tree/file-tree.module.ts +116 -116
  282. package/server/modules/file-tree/file-tree.routes.ts +258 -258
  283. package/server/modules/file-tree/file-tree.service.ts +675 -675
  284. package/server/modules/file-tree/index.ts +2 -2
  285. package/server/modules/file-tree/tests/file-tree.routes.test.ts +157 -157
  286. package/server/modules/file-tree/tests/file-tree.service.test.ts +371 -371
  287. package/server/modules/git/git-branch.service.ts +43 -43
  288. package/server/modules/git/git-parsing.service.ts +66 -66
  289. package/server/modules/git/git.module.ts +22 -22
  290. package/server/modules/git/git.routes.ts +1596 -1596
  291. package/server/modules/git/index.ts +2 -2
  292. package/server/modules/git/tests/git-branch.service.test.ts +60 -60
  293. package/server/modules/git/tests/git-init.routes.test.ts +132 -132
  294. package/server/modules/git/tests/git.test.ts +106 -106
  295. package/server/modules/notifications/index.ts +24 -24
  296. package/server/modules/notifications/notifications.routes.ts +127 -127
  297. package/server/modules/notifications/services/desktop-notification-clients.service.ts +124 -124
  298. package/server/modules/notifications/services/notification-orchestrator.service.js +310 -310
  299. package/server/modules/notifications/tests/notification-orchestrator.integration.test.ts +55 -55
  300. package/server/modules/notifications/vapid-keys.service.ts +38 -38
  301. package/server/modules/notifications/websocket/desktop-notifications-websocket.service.ts +109 -109
  302. package/server/modules/plugins/index.ts +9 -9
  303. package/server/modules/plugins/plugin-process.service.ts +217 -217
  304. package/server/modules/plugins/plugin-registry.service.ts +459 -459
  305. package/server/modules/plugins/plugins.module.ts +33 -33
  306. package/server/modules/plugins/plugins.routes.ts +66 -66
  307. package/server/modules/plugins/plugins.service.ts +147 -147
  308. package/server/modules/plugins/tests/plugins.service.test.ts +32 -32
  309. package/server/modules/projects/index.ts +11 -11
  310. package/server/modules/projects/projects.routes.ts +273 -273
  311. package/server/modules/projects/services/project-clone.service.ts +323 -323
  312. package/server/modules/projects/services/project-delete.service.ts +90 -90
  313. package/server/modules/projects/services/project-management.service.ts +144 -144
  314. package/server/modules/projects/services/project-star.service.ts +78 -78
  315. package/server/modules/projects/services/projects-has-taskmaster.service.ts +248 -248
  316. package/server/modules/projects/services/projects-with-sessions-fetch.service.ts +314 -314
  317. package/server/modules/projects/tests/project-clone.service.test.ts +183 -183
  318. package/server/modules/projects/tests/project-management.service.test.ts +118 -117
  319. package/server/modules/projects/tests/project-star.service.test.ts +123 -123
  320. package/server/modules/projects/tests/projects-has-taskmaster.service.test.ts +105 -105
  321. package/server/modules/providers/README.md +380 -380
  322. package/server/modules/providers/index.ts +10 -10
  323. package/server/modules/providers/list/claude/claude-auth.provider.ts +160 -160
  324. package/server/modules/providers/list/claude/claude-mcp.provider.ts +135 -135
  325. package/server/modules/providers/list/claude/claude-models.provider.ts +294 -294
  326. package/server/modules/providers/list/claude/claude-runtime.provider.js +1068 -1068
  327. package/server/modules/providers/list/claude/claude-session-synchronizer.provider.ts +203 -203
  328. package/server/modules/providers/list/claude/claude-sessions.provider.ts +684 -684
  329. package/server/modules/providers/list/claude/claude-skills.provider.ts +265 -265
  330. package/server/modules/providers/list/claude/claude.provider.ts +30 -30
  331. package/server/modules/providers/list/codex/codex-app-server.client.ts +2 -2
  332. package/server/modules/providers/list/codex/codex-auth.provider.ts +100 -100
  333. package/server/modules/providers/list/codex/codex-mcp.provider.ts +135 -135
  334. package/server/modules/providers/list/codex/codex-models.provider.ts +123 -123
  335. package/server/modules/providers/list/codex/codex-runtime.provider.js +533 -533
  336. package/server/modules/providers/list/codex/codex-session-synchronizer.provider.ts +203 -203
  337. package/server/modules/providers/list/codex/codex-sessions.provider.ts +938 -938
  338. package/server/modules/providers/list/codex/codex-skills.provider.ts +73 -73
  339. package/server/modules/providers/list/codex/codex.provider.ts +28 -28
  340. package/server/modules/providers/list/cursor/cursor-auth.provider.ts +143 -143
  341. package/server/modules/providers/list/cursor/cursor-mcp.provider.ts +108 -108
  342. package/server/modules/providers/list/cursor/cursor-models.provider.ts +119 -119
  343. package/server/modules/providers/list/cursor/cursor-runtime.provider.js +385 -385
  344. package/server/modules/providers/list/cursor/cursor-session-synchronizer.provider.ts +158 -159
  345. package/server/modules/providers/list/cursor/cursor-sessions.provider.ts +654 -654
  346. package/server/modules/providers/list/cursor/cursor-skills.provider.ts +39 -39
  347. package/server/modules/providers/list/cursor/cursor.provider.ts +30 -30
  348. package/server/modules/providers/list/opencode/opencode-auth.provider.ts +110 -110
  349. package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +228 -228
  350. package/server/modules/providers/list/opencode/opencode-models.provider.ts +203 -203
  351. package/server/modules/providers/list/opencode/opencode-runtime.provider.js +434 -434
  352. package/server/modules/providers/list/opencode/opencode-runtime.provider.test.js +261 -261
  353. package/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.ts +179 -179
  354. package/server/modules/providers/list/opencode/opencode-sessions.provider.ts +500 -500
  355. package/server/modules/providers/list/opencode/opencode-skills.provider.ts +78 -78
  356. package/server/modules/providers/list/opencode/opencode.provider.ts +30 -30
  357. package/server/modules/providers/provider.registry.ts +36 -36
  358. package/server/modules/providers/provider.routes.ts +877 -877
  359. package/server/modules/providers/services/mcp.service.ts +109 -109
  360. package/server/modules/providers/services/provider-auth.service.ts +26 -26
  361. package/server/modules/providers/services/provider-capabilities.service.ts +97 -97
  362. package/server/modules/providers/services/provider-models.service.ts +401 -401
  363. package/server/modules/providers/services/provider-runtime.service.ts +108 -108
  364. package/server/modules/providers/services/provider-token-usage.service.ts +357 -357
  365. package/server/modules/providers/services/session-conversations-search.service.ts +1321 -1321
  366. package/server/modules/providers/services/session-synchronizer.service.ts +74 -74
  367. package/server/modules/providers/services/sessions-watcher.service.ts +247 -247
  368. package/server/modules/providers/services/sessions.service.ts +471 -471
  369. package/server/modules/providers/services/skills.service.ts +39 -39
  370. package/server/modules/providers/shared/base/abstract.provider.ts +32 -32
  371. package/server/modules/providers/shared/mcp/mcp.provider.ts +151 -151
  372. package/server/modules/providers/shared/skills/skills.provider.ts +287 -287
  373. package/server/modules/providers/tests/claude-auth.test.ts +157 -150
  374. package/server/modules/providers/tests/claude-sessions.test.ts +61 -61
  375. package/server/modules/providers/tests/codex-sessions.test.ts +231 -231
  376. package/server/modules/providers/tests/mcp.test.ts +349 -349
  377. package/server/modules/providers/tests/opencode-models.test.ts +41 -41
  378. package/server/modules/providers/tests/opencode-sessions.test.ts +522 -522
  379. package/server/modules/providers/tests/provider-attachment-history.test.ts +247 -247
  380. package/server/modules/providers/tests/provider-models.service.test.ts +353 -353
  381. package/server/modules/providers/tests/provider-runtime.service.test.ts +138 -138
  382. package/server/modules/providers/tests/provider-token-usage.service.test.ts +186 -186
  383. package/server/modules/providers/tests/provider.routes.test.ts +244 -244
  384. package/server/modules/providers/tests/sessions-details.test.ts +73 -73
  385. package/server/modules/providers/tests/sessions.service.test.ts +127 -127
  386. package/server/modules/providers/tests/skills.test.ts +692 -692
  387. package/server/modules/settings/index.ts +2 -2
  388. package/server/modules/settings/settings.module.ts +50 -50
  389. package/server/modules/settings/settings.routes.ts +51 -51
  390. package/server/modules/settings/settings.service.ts +186 -186
  391. package/server/modules/settings/tests/settings.service.test.ts +54 -54
  392. package/server/modules/system/index.ts +2 -2
  393. package/server/modules/system/system.module.ts +62 -62
  394. package/server/modules/system/system.routes.ts +21 -21
  395. package/server/modules/system/system.service.ts +76 -76
  396. package/server/modules/system/tests/system.service.test.ts +118 -118
  397. package/server/modules/taskmaster/index.ts +2 -2
  398. package/server/modules/taskmaster/taskmaster.module.ts +24 -24
  399. package/server/modules/taskmaster/taskmaster.routes.ts +1483 -1482
  400. package/server/modules/taskmaster/taskmaster.service.ts +132 -132
  401. package/server/modules/taskmaster/tests/taskmaster.routes.test.ts +144 -144
  402. package/server/modules/taskmaster/tests/taskmaster.service.test.ts +97 -97
  403. package/server/modules/user/index.ts +2 -2
  404. package/server/modules/user/tests/user.service.test.ts +61 -61
  405. package/server/modules/user/user.module.ts +58 -58
  406. package/server/modules/user/user.routes.ts +50 -50
  407. package/server/modules/user/user.service.ts +85 -85
  408. package/server/modules/voice/index.ts +2 -2
  409. package/server/modules/voice/tests/voice.service.test.ts +98 -98
  410. package/server/modules/voice/voice.module.ts +47 -47
  411. package/server/modules/voice/voice.routes.ts +113 -113
  412. package/server/modules/voice/voice.service.ts +192 -192
  413. package/server/modules/websocket/README.md +273 -273
  414. package/server/modules/websocket/index.ts +3 -3
  415. package/server/modules/websocket/services/chat-run-registry.service.ts +343 -343
  416. package/server/modules/websocket/services/chat-session-writer.service.ts +145 -145
  417. package/server/modules/websocket/services/chat-websocket.service.ts +425 -425
  418. package/server/modules/websocket/services/plugin-websocket-proxy.service.ts +65 -65
  419. package/server/modules/websocket/services/shell-websocket.service.ts +503 -503
  420. package/server/modules/websocket/services/websocket-auth.service.ts +59 -59
  421. package/server/modules/websocket/services/websocket-server.service.ts +124 -124
  422. package/server/modules/websocket/services/websocket-state.service.ts +16 -16
  423. package/server/modules/websocket/services/websocket-writer.service.ts +38 -38
  424. package/server/modules/websocket/tests/chat-attachment-filter.test.ts +59 -59
  425. package/server/modules/websocket/tests/chat-run-registry.test.ts +282 -282
  426. package/server/modules/websocket/tests/shell-websocket.service.test.ts +100 -100
  427. package/server/modules/websocket/tests/websocket-heartbeat.service.test.ts +78 -78
  428. package/server/modules/worktrees/index.ts +2 -2
  429. package/server/modules/worktrees/services/worktree-create-and-open.service.ts +53 -53
  430. package/server/modules/worktrees/services/worktree-create.service.ts +104 -104
  431. package/server/modules/worktrees/services/worktree-git.service.ts +207 -207
  432. package/server/modules/worktrees/services/worktree-list.service.ts +143 -143
  433. package/server/modules/worktrees/services/worktree-merge.service.ts +157 -157
  434. package/server/modules/worktrees/services/worktree-open.service.ts +85 -85
  435. package/server/modules/worktrees/services/worktree-remove.service.ts +88 -88
  436. package/server/modules/worktrees/tests/worktree-create-and-open.service.test.ts +68 -68
  437. package/server/modules/worktrees/tests/worktree-create.service.test.ts +142 -142
  438. package/server/modules/worktrees/tests/worktree-git.service.test.ts +84 -84
  439. package/server/modules/worktrees/tests/worktree-list.service.test.ts +45 -45
  440. package/server/modules/worktrees/tests/worktree-merge.service.test.ts +213 -213
  441. package/server/modules/worktrees/tests/worktree-open.service.test.ts +122 -122
  442. package/server/modules/worktrees/tests/worktree-remove.service.test.ts +227 -227
  443. package/server/modules/worktrees/tests/worktrees.routes.test.ts +199 -199
  444. package/server/modules/worktrees/worktrees.module.ts +113 -113
  445. package/server/modules/worktrees/worktrees.routes.ts +116 -116
  446. package/server/shared/claude-cli-path.ts +139 -139
  447. package/server/shared/frontmatter.ts +18 -18
  448. package/server/shared/image-attachments.ts +435 -435
  449. package/server/shared/interfaces.ts +179 -179
  450. package/server/shared/tests/claude-cli-path.test.ts +61 -61
  451. package/server/shared/tests/image-attachments.test.ts +353 -353
  452. package/server/shared/tests/slice-tail-page.test.ts +42 -42
  453. package/server/shared/types.ts +1228 -1228
  454. package/server/shared/utils.ts +1161 -1161
  455. package/server/tsconfig.json +40 -40
  456. package/shared/networkHosts.js +22 -22
  457. package/dist/assets/FileTree-N2IkkHlv.js +0 -127
  458. package/dist/assets/GitPanel-DZCeuFZ2.js +0 -29
  459. package/dist/assets/PluginTabContent-Bnuf-fb8.js +0 -1
  460. package/dist/assets/Shell-BfFnMZ-f.js +0 -81
  461. package/dist/assets/Shell-qxJ8_QYu.css +0 -32
  462. package/dist/assets/StandaloneShell-QmyYwNAl.js +0 -1
  463. package/dist/assets/TaskMasterPanel-fMsmvN9L.js +0 -32
  464. package/dist/assets/abnfDiagram-N423BO3Z-DjPU7HLs.js +0 -1
  465. package/dist/assets/arc-Pdq6Tvr3.js +0 -1
  466. package/dist/assets/architectureDiagram-T3A2C74G-D0JnT0Vh.js +0 -36
  467. package/dist/assets/c4Diagram-5PPSVZJV-MpqlPGFi.js +0 -10
  468. package/dist/assets/channel-Bm0ZLE4z.js +0 -1
  469. package/dist/assets/chunk-5RXB4S5H-B4UQ8snD.js +0 -231
  470. package/dist/assets/chunk-GF5L2VYU-DkEPedJP.js +0 -206
  471. package/dist/assets/classDiagram-JCYQIIEL-DqEOcNxw.js +0 -1
  472. package/dist/assets/classDiagram-v2-OCEON4UE-DqEOcNxw.js +0 -1
  473. package/dist/assets/code-xml-VK1YfShP.js +0 -6
  474. package/dist/assets/cose-bilkent-JH36ORCC-DrVTo1Nh.js +0 -1
  475. package/dist/assets/cynefinDiagram-MW4NZA55-CCxBjw9E.js +0 -62
  476. package/dist/assets/cytoscape.esm-C10L9Icf.js +0 -331
  477. package/dist/assets/dagre-VZM6K2ZE-C_GvE4lu.js +0 -4
  478. package/dist/assets/diagram-LBJQPF4R-hfKcrrxe.js +0 -24
  479. package/dist/assets/diagram-Q27KOJAE-C1semJfK.js +0 -24
  480. package/dist/assets/diagram-UB23O5K3-57hvXQXO.js +0 -41
  481. package/dist/assets/ebnfDiagram-BXEA7PRR-9KIAlAVw.js +0 -1
  482. package/dist/assets/erDiagram-JOGREHBK-B7OzJ767.js +0 -85
  483. package/dist/assets/ganttDiagram-PKOTCBZU-CbMNWWQu.js +0 -292
  484. package/dist/assets/gitGraphDiagram-DS77QQ5N-I_vZ5waO.js +0 -106
  485. package/dist/assets/graph-Cx-EqisW.js +0 -1
  486. package/dist/assets/index-DFnVoqpx.js +0 -1174
  487. package/dist/assets/index-DlSeAkw_.js +0 -11
  488. package/dist/assets/index-ZHwIojzi.js +0 -1
  489. package/dist/assets/index-t1w8KNxn.css +0 -1
  490. package/dist/assets/infoDiagram-6WML65LV-Dh20Tsbq.js +0 -2
  491. package/dist/assets/ishikawaDiagram-WSZJBQD7-DH2Sm3ko.js +0 -70
  492. package/dist/assets/journeyDiagram-NVQOT4AX-BNFQqlVu.js +0 -139
  493. package/dist/assets/map-CV9uif0g.js +0 -1
  494. package/dist/assets/mermaid.core-BYRQSshi.js +0 -312
  495. package/dist/assets/pegDiagram-VL7TDLO6-CNYpECr8.js +0 -1
  496. package/dist/assets/quadrantDiagram-CIZ2JOQS-BXVVQsa6.js +0 -7
  497. package/dist/assets/railroadDiagram-AXF67PYL-JTroIW8F.js +0 -1
  498. package/dist/assets/requirementDiagram-LRYGKXZP-C1Z_inLz.js +0 -84
  499. package/dist/assets/sankeyDiagram-W5VNT64P-DCJgKFUk.js +0 -40
  500. package/dist/assets/sequenceDiagram-SI44F4Z6-D8Wrx5Vc.js +0 -162
  501. package/dist/assets/sizeCapture-X5ZJPWSS-CXqD68vD.js +0 -1
  502. package/dist/assets/stateDiagram-OKZ733FA-CF0Ekqjo.js +0 -1
  503. package/dist/assets/stateDiagram-v2-UEYNNEHI-DARLpEFJ.js +0 -1
  504. package/dist/assets/swimlanes-SLNWSIFB-DVIax_k4.js +0 -2
  505. package/dist/assets/swimlanesDiagram-ULZ7WXOC-CrgDgaY8.js +0 -8
  506. package/dist/assets/timeline-definition-Z64GVDOM-DSqk3ApG.js +0 -120
  507. package/dist/assets/vendor-react-whEHfigN.js +0 -59
  508. package/dist/assets/vennDiagram-T6HMQDX7-DNbTqyG5.js +0 -34
  509. package/dist/assets/xychartDiagram-ELKLHX3M-XsVZphHr.js +0 -7
  510. package/dist/manifest.json +0 -61
@@ -1,29 +0,0 @@
1
- import{c as fe,b as Z,j as e,Y as Fe,G as he,Q as pe,Z as Ae,T as oe,$ as ft,R as V,a0 as P,I as xe,w as Xe,X as we,a1 as pt,A as gt,a2 as Ye,a3 as Le,D as Ze,a4 as Pe,t as bt,L as yt,F as jt,i as Nt}from"./index-DFnVoqpx.js";import{r as n}from"./vendor-react-whEHfigN.js";/**
2
- * @license lucide-react v0.515.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const wt=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],vt=fe("arrow-right-left",wt);/**
7
- * @license lucide-react v0.515.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Ct=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],ve=fe("git-fork",Ct);/**
12
- * @license lucide-react v0.515.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const kt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],et=fe("history",kt);/**
17
- * @license lucide-react v0.515.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const St=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],$t=fe("house",St);/**
22
- * @license lucide-react v0.515.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Et=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],It=fe("tag",Et),Tt="main",Ft=50,tt=[{key:"modified",status:"M"},{key:"added",status:"A"},{key:"deleted",status:"D"},{key:"untracked",status:"U"}],Lt={M:"Modified",A:"Added",D:"Deleted",U:"Untracked"},Me={M:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800/50",A:"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 border-green-200 dark:border-green-800/50",D:"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 border-red-200 dark:border-red-800/50",U:"bg-muted text-muted-foreground border-border"},Rt={discard:"Discard Changes",delete:"Delete File",commit:"Confirm Action",pull:"Confirm Pull",push:"Confirm Push",publish:"Publish Branch",revertLocalCommit:"Revert Local Commit",deleteBranch:"Delete Branch"},At={discard:"Discard",delete:"Delete",commit:"Confirm",pull:"Pull",push:"Push",publish:"Publish",revertLocalCommit:"Revert Commit",deleteBranch:"Delete"},Dt={discard:"bg-red-600 hover:bg-red-700",delete:"bg-red-600 hover:bg-red-700",commit:"bg-primary hover:bg-primary/90",pull:"bg-green-600 hover:bg-green-700",push:"bg-orange-600 hover:bg-orange-700",publish:"bg-purple-600 hover:bg-purple-700",revertLocalCommit:"bg-yellow-600 hover:bg-yellow-700",deleteBranch:"bg-red-600 hover:bg-red-700"},Ot={discard:"bg-red-100 dark:bg-red-900/30",delete:"bg-red-100 dark:bg-red-900/30",commit:"bg-yellow-100 dark:bg-yellow-900/30",pull:"bg-yellow-100 dark:bg-yellow-900/30",push:"bg-yellow-100 dark:bg-yellow-900/30",publish:"bg-yellow-100 dark:bg-yellow-900/30",revertLocalCommit:"bg-yellow-100 dark:bg-yellow-900/30",deleteBranch:"bg-red-100 dark:bg-red-900/30"};function De(t){return t?tt.flatMap(({key:r})=>t[r]||[]):[]}function rt(t){return De(t).length}function We(t){return rt(t)>0}function Bt(t){return Lt[t]||t}function Oe(t){return Me[t]||Me.U}function Mt(t){const r=[],s=t.split(/^diff --git /m).slice(1);for(const a of s){const o=a.split(`
27
- `),i=(o[0]??"").match(/^a\/(.+?) b\/(.+)/);if(!i)continue;const g=i[1],h=i[2];let m="M";const f=o.slice(0,6).join(`
28
- `);f.includes("new file mode")?m="A":f.includes("deleted file mode")&&(m="D");const v=m==="D"?g:h;let y=0,p=0;for(const x of o)x.startsWith("+++")||x.startsWith("---")||(x.startsWith("+")?y++:x.startsWith("-")&&p++);const j=v.lastIndexOf("/"),u=j>=0?v.substring(0,j+1):"",N=j>=0?v.substring(j+1):v;r.push({path:v,directory:u,filename:N,status:m,insertions:y,deletions:p})}return{files:r,totalFiles:r.length,totalInsertions:r.reduce((a,o)=>a+o.insertions,0),totalDeletions:r.reduce((a,o)=>a+o.deletions,0)}}function Wt(){const[t,r]=n.useState(()=>localStorage.getItem("selected-provider")||"claude");return n.useEffect(()=>{const s=()=>{const a=localStorage.getItem("selected-provider")||"claude";r(a)};return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]),t}const M=Z;function _e(t){return t instanceof DOMException&&t.name==="AbortError"}async function O(t,r){if(r?.aborted)throw new DOMException("Request aborted","AbortError");const s=await t.json();if(r?.aborted)throw new DOMException("Request aborted","AbortError");return s}function _t({selectedProject:t,activeView:r,onFileOpen:s}){const[a,o]=n.useState(null),[d,i]=n.useState({}),[g,h]=n.useState(!1),[m,f]=n.useState(""),[v,y]=n.useState([]),[p,j]=n.useState([]),[u,N]=n.useState(!1),[x,T]=n.useState(!1),[I,B]=n.useState({}),[W,w]=n.useState(null),[$,k]=n.useState([]),[L,S]=n.useState([]),[R,G]=n.useState(!1),[J,Y]=n.useState(!1),[U,C]=n.useState(!1),[A,H]=n.useState(!1),[Q,se]=n.useState(!1),[ie,ne]=n.useState(!1),[le,D]=n.useState(!1),[K,z]=n.useState(null),Ce=n.useCallback(()=>z(null),[]),X=n.useRef(t?.projectId??null);n.useEffect(()=>{X.current=t?.projectId??null},[t]);const ge=Wt(),be=n.useCallback(async(c,l)=>{if(!t)return;const b=t.projectId;try{const F=await M(`/api/git/diff?project=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`,{signal:l}),je=await O(F,l);if(l?.aborted||X.current!==b)return;!je.error&&je.diff&&i(Ie=>({...Ie,[c]:je.diff}))}catch(F){if(l?.aborted||_e(F))return;console.error("Error fetching file diff:",F)}},[t]),E=n.useCallback(async c=>{if(!t)return;const l=t.projectId;h(!0);try{const b=await M(`/api/git/status?project=${encodeURIComponent(l)}`,{signal:c}),F=await O(b,c);if(c?.aborted||X.current!==l)return;if(F.error){F.notGitRepository||console.error("Git status error:",F.error),o({error:F.error,details:F.details,notGitRepository:F.notGitRepository}),f("");return}o(F),f(F.branch||Tt),De(F).forEach(Ie=>{be(Ie,c)})}catch(b){if(c?.aborted||_e(b)||X.current!==l)return;console.error("Error fetching git status:",b),o({error:"Git operation failed",details:String(b)}),f("")}finally{h(!1)}},[be,t]),q=n.useCallback(async()=>{if(t)try{const c=await M(`/api/git/branches?project=${encodeURIComponent(t.projectId)}`),l=await O(c);if(!l.error&&l.branches){y(l.branches),k(l.localBranches??l.branches),S(l.remoteBranches??[]);return}y([]),k([]),S([])}catch(c){console.error("Error fetching branches:",c),y([]),k([]),S([])}},[t]),_=n.useCallback(async()=>{if(t)try{const c=await M(`/api/git/remote-status?project=${encodeURIComponent(t.projectId)}`),l=await O(c);if(!l.error){w(l);return}w(null)}catch(c){console.error("Error fetching remote status:",c),w(null)}},[t]),ke=n.useCallback(async c=>{if(!t)return!1;try{const l=await M("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,branch:c})}),b=await O(l);return b.success?(f(c),E(),!0):(console.error("Failed to switch branch:",b.error),!1)}catch(l){return console.error("Error switching branch:",l),!1}},[E,t]),Se=n.useCallback(async c=>{const l=c.trim();if(!t||!l)return!1;G(!0);try{const b=await M("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,branch:l})}),F=await O(b);return F.success?(f(l),q(),E(),!0):(console.error("Failed to create branch:",F.error),!1)}catch(b){return console.error("Error creating branch:",b),!1}finally{G(!1)}},[q,E,t]),$e=n.useCallback(async(c,l=!1)=>{if(!t)return!1;try{const b=await M("/api/git/delete-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,branch:c,force:l})}),F=await O(b);return F.success?(q(),!0):(z(F.error??"Delete branch failed"),!1)}catch(b){return z(b instanceof Error?b.message:"Delete branch failed"),!1}},[q,t]),Ee=n.useCallback(async()=>{if(t){Y(!0);try{const c=await M("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId})}),l=await O(c);if(l.success){E(),_(),q();return}z(l.error??"Fetch failed")}catch(c){z(c instanceof Error?c.message:"Fetch failed")}finally{Y(!1)}}},[q,E,_,t]),ce=n.useCallback(async()=>{if(t){C(!0);try{const c=await M("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId})}),l=await O(c);if(l.success){E(),_();return}z(l.error??"Pull failed")}catch(c){z(c instanceof Error?c.message:"Pull failed")}finally{C(!1)}}},[E,_,t]),de=n.useCallback(async()=>{if(t){H(!0);try{const c=await M("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId})}),l=await O(c);if(l.success){E(),_();return}z(l.error??"Push failed")}catch(c){z(c instanceof Error?c.message:"Push failed")}finally{H(!1)}}},[E,_,t]),me=n.useCallback(async()=>{if(t){se(!0);try{const c=await M("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,branch:m})}),l=await O(c);if(l.success){E(),_();return}console.error("Publish failed:",l.error)}catch(c){console.error("Error publishing branch:",c)}finally{se(!1)}}},[m,E,_,t]),ye=n.useCallback(async c=>{if(t)try{const l=await M("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,file:c})}),b=await O(l);if(b.success){E();return}console.error("Discard failed:",b.error)}catch(l){console.error("Error discarding changes:",l)}},[E,t]),at=n.useCallback(async c=>{if(t)try{const l=await M("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,file:c})}),b=await O(l);if(b.success){E();return}console.error("Delete failed:",b.error)}catch(l){console.error("Error deleting untracked file:",l)}},[E,t]),ot=n.useCallback(async c=>{if(!t||c.length===0)return!1;try{const l=await M("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,files:c})}),b=await O(l);return b.success?(await E(),!0):(z(b.error??"Stage failed"),!1)}catch(l){return z(l instanceof Error?l.message:"Stage failed"),!1}},[E,t]),it=n.useCallback(async c=>{if(!t||c.length===0)return!1;try{const l=await M("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,files:c})}),b=await O(l);return b.success?(await E(),!0):(z(b.error??"Unstage failed"),!1)}catch(l){return z(l instanceof Error?l.message:"Unstage failed"),!1}},[E,t]),Be=n.useCallback(async()=>{if(!t)return;const c=t.projectId;N(!0);try{const l=await M(`/api/git/commits?project=${encodeURIComponent(c)}&limit=${Ft}`),b=await O(l);if(X.current!==c)return;!b.error&&b.commits&&j(b.commits)}catch(l){console.error("Error fetching commits:",l)}finally{X.current===c&&(N(!1),T(!0))}},[t]),lt=n.useCallback(async c=>{if(t)try{const l=await M(`/api/git/commit-diff?project=${encodeURIComponent(t.projectId)}&commit=${c}`),b=await O(l);!b.error&&b.diff&&B(F=>({...F,[c]:b.diff}))}catch(l){console.error("Error fetching commit diff:",l)}},[t]),ct=n.useCallback(async c=>{if(!t||c.length===0)return null;try{const l=await Z("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,files:c,provider:ge})}),b=await O(l);return b.message?b.message:(console.error("Failed to generate commit message:",b.error),null)}catch(l){return console.error("Error generating commit message:",l),null}},[ge,t]),dt=n.useCallback(async(c,l)=>{if(!t||!c.trim()||l.length===0)return!1;try{const b=await M("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,message:c,files:l})}),F=await O(b);return F.success?(E(),_(),!0):(console.error("Commit failed:",F.error),!1)}catch(b){return console.error("Error committing changes:",b),!1}},[E,_,t]),mt=n.useCallback(async()=>{if(!t)throw new Error("No project selected");ne(!0);try{const c=await M("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId})}),l=await O(c);if(l.success)return E(),_(),!0;throw new Error(l.error||"Failed to create initial commit")}catch(c){throw console.error("Error creating initial commit:",c),c}finally{ne(!1)}},[E,_,t]),ut=n.useCallback(async()=>{if(!t)return!1;const c=t.projectId;D(!0);try{const l=await M("/api/git/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:c})}),b=await O(l);return X.current!==c?!1:b.success?(E(),q(),_(),!0):(z(b.error??"Failed to initialize repository"),!1)}catch(l){return X.current===c&&z(l instanceof Error?l.message:"Failed to initialize repository"),!1}finally{D(!1)}},[q,E,_,t]),ht=n.useCallback(async c=>{if(s){if(!t){s(c);return}try{const l=await M(`/api/git/file-with-diff?project=${encodeURIComponent(t.projectId)}&file=${encodeURIComponent(c)}`),b=await O(l);if(b.error){console.error("Error fetching file with diff:",b.error),s(c);return}s(c,{old_string:b.oldContent||"",new_string:b.currentContent||""})}catch(l){console.error("Error opening file:",l),s(c)}}},[s,t]),xt=n.useCallback(()=>{E(),q(),_()},[q,E,_]);return n.useEffect(()=>{const c=new AbortController;return f(""),y([]),k([]),S([]),o(null),w(null),i({}),j([]),B({}),h(!1),N(!1),T(!1),z(null),t?(E(c.signal),q(),_(),()=>{c.abort()}):()=>{c.abort()}},[q,E,_,t]),n.useEffect(()=>{!t||r!=="history"||Be()},[r,Be,t]),{gitStatus:a,gitDiff:d,isLoading:g,isLoadingCommits:u||!x,currentBranch:m,branches:v,localBranches:$,remoteBranches:L,recentCommits:p,commitDiffs:I,remoteStatus:W,isCreatingBranch:R,isFetching:J,isPulling:U,isPushing:A,isPublishing:Q,isCreatingInitialCommit:ie,isInitializingRepository:le,operationError:K,clearOperationError:Ce,refreshAll:xt,switchBranch:ke,createBranch:Se,deleteBranch:$e,handleFetch:Ee,handlePull:ce,handlePush:de,handlePublish:me,discardChanges:ye,deleteUntrackedFile:at,stageFiles:ot,unstageFiles:it,fetchCommitDiff:lt,generateCommitMessage:ct,commitChanges:dt,createInitialCommit:mt,initRepository:ut,openFile:ht}}async function Ut(t){return await t.json()}function zt({projectId:t,onSuccess:r}){const[s,a]=n.useState(!1),o=n.useCallback(async()=>{if(t){a(!0);try{const d=await Z("/api/git/revert-local-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t})}),i=await Ut(d);if(!i.success){console.error("Revert local commit failed:",i.error||i.details||"Unknown error");return}r?.()}catch(d){console.error("Error reverting local commit:",d)}finally{a(!1)}}},[r,t]);return{isRevertingLocalCommit:s,revertLatestLocalCommit:o}}const Te=new Map;function Gt({isMobile:t,projectPath:r,selectedFileCount:s,isHidden:a,onCommit:o,onRequestConfirmation:d}){const[i,g]=n.useState(()=>Te.get(r)??""),h=u=>{g(u),u?Te.set(r,u):Te.delete(r)},[m,f]=n.useState(!1),[v,y]=n.useState(t),p=async(u=i)=>{const N=u.trim();if(!N||s===0||m)return!1;f(!0);try{const x=await o(N);return x&&h(""),x}finally{f(!1)}},j=()=>{const u=i.trim();!u||s===0||m||d({type:"commit",message:`Commit ${s} file${s!==1?"s":""} with message: "${u}"?`,onConfirm:async()=>{await p(u)}})};return e.jsx("div",{className:`transition-all duration-300 ease-in-out ${a?"max-h-0 -translate-y-2 overflow-hidden opacity-0":"max-h-96 translate-y-0 opacity-100"}`,children:t&&v?e.jsx("div",{className:"border-b border-border/60 px-4 py-2",children:e.jsxs("button",{onClick:()=>y(!1),className:"flex w-full items-center justify-center gap-2 rounded-lg bg-primary px-3 py-2 text-sm text-primary-foreground transition-colors hover:bg-primary/90",children:[e.jsx(Fe,{className:"h-4 w-4"}),e.jsxs("span",{children:["Commit ",s," file",s!==1?"s":""]}),e.jsx(he,{className:"h-3 w-3"})]})}):e.jsxs("div",{className:"border-b border-border/60 px-4 py-3",children:[t&&e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Commit Changes"}),e.jsx("button",{onClick:()=>y(!0),className:"rounded-lg p-1 transition-colors hover:bg-accent",children:e.jsx(he,{className:"h-4 w-4 rotate-180"})})]}),e.jsx("textarea",{value:i,onChange:u=>h(u.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full resize-none rounded-xl border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary/30 focus:outline-none focus:ring-2 focus:ring-primary/20",rows:3,onKeyDown:u=>{u.key==="Enter"&&(u.ctrlKey||u.metaKey)&&(u.preventDefault(),p())}}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," file",s!==1?"s":""," selected"]}),e.jsxs("button",{onClick:j,disabled:!i.trim()||s===0||m,className:"flex items-center space-x-1 rounded-lg bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(pe,{className:"h-3 w-3"}),e.jsx("span",{children:m?"Committing...":"Commit"})]})]})]})})}const Ue=2e5,ze=1500;function Ht(t){const r=t.length>Ue,a=(r?t.slice(0,Ue):t).split(`
29
- `),o=a.length>ze;return{lines:o?a.slice(0,ze):a,isCharacterTruncated:r,isLineTruncated:o}}function st({diff:t,isMobile:r,wrapText:s}){const a=n.useMemo(()=>Ht(t||""),[t]),o=a.isCharacterTruncated||a.isLineTruncated;if(!t)return e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No diff available"});const d=(i,g)=>{const h=i.startsWith("+")&&!i.startsWith("+++"),m=i.startsWith("-")&&!i.startsWith("---"),f=i.startsWith("@@");return e.jsx("div",{className:`px-3 py-0.5 font-mono text-xs ${r&&s?"whitespace-pre-wrap break-all":"overflow-x-auto whitespace-pre"} ${h?"bg-green-50 text-green-700 dark:bg-green-950/50 dark:text-green-300":m?"bg-red-50 text-red-700 dark:bg-red-950/50 dark:text-red-300":f?"bg-primary/5 text-primary":"text-muted-foreground/70"}`,children:i},g)};return e.jsxs("div",{className:"diff-viewer",children:[o&&e.jsx("div",{className:"mb-2 rounded-md border border-border bg-card px-3 py-2 text-xs text-muted-foreground",children:"Large diff preview: rendering is limited to keep the tab responsive."}),a.lines.map((i,g)=>d(i,g))]})}function Jt({filePath:t,status:r,isMobile:s,isExpanded:a,isSelected:o,diff:d,wrapText:i,onToggleSelected:g,onToggleExpanded:h,onOpenFile:m,onToggleWrapText:f,onRequestFileAction:v}){const y=Bt(r),p=Oe(r);return e.jsxs("div",{className:"border-b border-border last:border-0",children:[e.jsxs("div",{className:`flex items-center transition-colors hover:bg-accent/50 ${s?"px-2 py-1.5":"px-3 py-2"}`,children:[e.jsx("input",{type:"checkbox",checked:o,onChange:()=>g(t),onClick:j=>j.stopPropagation(),className:`rounded border-border bg-background text-primary checked:bg-primary focus:ring-primary/40 ${s?"mr-1.5":"mr-2"}`}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[e.jsx("button",{onClick:j=>{j.stopPropagation(),h(t)},className:`cursor-pointer rounded p-0.5 hover:bg-accent ${s?"mr-1":"mr-2"}`,title:a?"Collapse diff":"Expand diff",children:e.jsx(Ae,{className:`h-3 w-3 transition-transform duration-200 ease-in-out ${a?"rotate-90":"rotate-0"}`})}),e.jsx("span",{className:`flex-1 truncate ${s?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:j=>{j.stopPropagation(),m(t)},title:"Click to open file",children:t}),e.jsxs("span",{className:"flex items-center gap-1",children:[(r==="M"||r==="D"||r==="U")&&e.jsxs("button",{onClick:j=>{j.stopPropagation(),v(t,r)},className:`${s?"px-2 py-1 text-xs":"p-1"} flex items-center gap-1 rounded font-medium text-destructive hover:bg-destructive/10`,title:r==="U"?"Delete untracked file":"Discard changes",children:[e.jsx(oe,{className:"h-3 w-3"}),s&&e.jsx("span",{children:r==="U"?"Delete":"Discard"})]}),e.jsx("span",{className:`inline-flex h-5 w-5 items-center justify-center rounded border text-[10px] font-bold ${p}`,title:y,children:r})]})]})]}),e.jsxs("div",{className:`duration-400 overflow-hidden bg-muted/50 transition-all ease-in-out ${a&&d?"max-h-[600px] translate-y-0 opacity-100":"max-h-0 -translate-y-1 opacity-0"}`,children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border p-2",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-flex h-5 w-5 items-center justify-center rounded border text-[10px] font-bold ${p}`,children:r}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:y})]}),s&&e.jsx("button",{onClick:j=>{j.stopPropagation(),f()},className:"text-sm text-muted-foreground transition-colors hover:text-foreground",title:i?"Switch to horizontal scroll":"Switch to text wrap",children:i?"Scroll":"Wrap"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:d&&e.jsx(st,{diff:d,isMobile:s,wrapText:i})})]})]})}function Ge({gitStatus:t,gitDiff:r,expandedFiles:s,selectedFiles:a,isMobile:o,wrapText:d,filePaths:i,onToggleSelected:g,onToggleExpanded:h,onOpenFile:m,onToggleWrapText:f,onRequestFileAction:v}){return e.jsx(e.Fragment,{children:tt.map(({key:y,status:p})=>(t[y]||[]).filter(j=>!i||i.has(j)).map(j=>e.jsx(Jt,{filePath:j,status:p,isMobile:o,isExpanded:s.has(j),isSelected:a.has(j),diff:r[j],wrapText:d,onToggleSelected:g,onToggleExpanded:h,onOpenFile:m,onToggleWrapText:f,onRequestFileAction:v},j)))})}const qt=[{status:"M",label:"Modified"},{status:"A",label:"Added"},{status:"D",label:"Deleted"},{status:"U",label:"Untracked"}];function Vt({isMobile:t}){const[r,s]=n.useState(!1);return t?null:e.jsxs("div",{className:"border-b border-border/60",children:[e.jsxs("button",{onClick:()=>s(a=>!a),className:"flex w-full items-center justify-center gap-1 bg-muted/30 px-4 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50",children:[e.jsx(ft,{className:"h-3 w-3"}),e.jsx("span",{children:"File Status Guide"}),r?e.jsx(he,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"})]}),r&&e.jsx("div",{className:"bg-muted/30 px-4 py-3 text-sm",children:e.jsx("div",{className:"flex justify-center gap-6",children:qt.map(a=>e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-flex h-5 w-5 items-center justify-center rounded border text-[10px] font-bold ${Oe(a.status)}`,children:a.status}),e.jsx("span",{className:"italic text-muted-foreground",children:a.label})]},a.status))})})]})}function Qt({isMobile:t,projectPath:r,gitStatus:s,gitDiff:a,isLoading:o,wrapText:d,isCreatingInitialCommit:i,onWrapTextChange:g,onCreateInitialCommit:h,onOpenFile:m,onDiscardFile:f,onDeleteFile:v,onStageFiles:y,onUnstageFiles:p,onCommitChanges:j,onRequestConfirmation:u,onExpandedFilesChange:N}){const[x,T]=n.useState(new Set),[I,B]=n.useState(new Set),[W,w]=n.useState(0),$=n.useRef(Promise.resolve()),k=n.useMemo(()=>De(s),[s]),L=x.size>0,S=n.useCallback(C=>{w(A=>A+1),$.current=$.current.catch(()=>{}).then(C).finally(()=>w(A=>A-1))},[]);n.useEffect(()=>{if(!s||s.error){B(new Set);return}W>0||B(new Set(s.staged??[]))},[s,W]),n.useEffect(()=>{N(L)},[L,N]),n.useEffect(()=>()=>{N(!1)},[N]);const R=n.useCallback(C=>{T(A=>{const H=new Set(A);return H.has(C)?H.delete(C):H.add(C),H})},[]),G=n.useCallback(C=>{const A=I.has(C);B(H=>{const Q=new Set(H);return A?Q.delete(C):Q.add(C),Q}),S(()=>A?p([C]):y([C]))},[S,y,p,I]),J=n.useCallback((C,A)=>{if(A==="U"){u({type:"delete",message:`Delete untracked file "${C}"? This action cannot be undone.`,onConfirm:async()=>{await v(C)}});return}u({type:"discard",message:`Discard all changes to "${C}"? This action cannot be undone.`,onConfirm:async()=>{await f(C)}})},[v,f,u]),Y=n.useCallback(C=>j(C,Array.from(I)),[j,I]),U=n.useMemo(()=>new Set(k.filter(C=>!I.has(C))),[k,I]);return e.jsxs(e.Fragment,{children:[e.jsx(Gt,{isMobile:t,projectPath:r,selectedFileCount:I.size,isHidden:L,onCommit:Y,onRequestConfirmation:u}),!s?.error&&e.jsx(Vt,{isMobile:t}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:o?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(V,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s?.hasCommits===!1&&We(s)?e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-muted/50",children:e.jsx(P,{className:"h-7 w-7 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-2 text-lg font-medium text-foreground",children:"No commits yet"}),e.jsx("p",{className:"mb-6 max-w-md text-sm text-muted-foreground",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),e.jsx("button",{onClick:()=>void h(),disabled:i,className:"flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:i?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Creating Initial Commit..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"h-4 w-4"}),e.jsx("span",{children:"Create Initial Commit"})]})})]}):!s||!We(s)?e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center text-muted-foreground",children:[e.jsx(Fe,{className:"mb-2 h-10 w-10 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No changes detected"})]}):e.jsxs("div",{className:t?"pb-4":"",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 bg-muted/30 px-3 py-1.5",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Staged (",I.size,")"]}),I.size>0&&e.jsx("button",{onClick:()=>{const C=Array.from(I);B(new Set),S(()=>p(C))},className:"text-xs text-primary transition-colors hover:text-primary/80",children:"Unstage All"})]}),I.size===0?e.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:"No staged files"}):e.jsx(Ge,{gitStatus:s,gitDiff:a,expandedFiles:x,selectedFiles:I,isMobile:t,wrapText:d,filePaths:I,onToggleSelected:G,onToggleExpanded:R,onOpenFile:C=>{m(C)},onToggleWrapText:()=>g(!d),onRequestFileAction:J}),e.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 bg-muted/30 px-3 py-1.5",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Changes (",U.size,")"]}),U.size>0&&e.jsx("button",{onClick:()=>{const C=Array.from(U);B(new Set(k)),S(()=>y(C))},className:"text-xs text-primary transition-colors hover:text-primary/80",children:"Stage All"})]}),U.size===0?e.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:"All changes staged"}):e.jsx(Ge,{gitStatus:s,gitDiff:a,expandedFiles:x,selectedFiles:I,isMobile:t,wrapText:d,filePaths:U,onToggleSelected:G,onToggleExpanded:R,onOpenFile:C=>{m(C)},onToggleWrapText:()=>g(!d),onRequestFileAction:J})]})})]})}const He=["#0ea5e9","#f97316","#a855f7","#22c55e","#ef4444","#eab308","#14b8a6","#ec4899","#6366f1","#84cc16"],ae=t=>He[t%He.length];function Kt(t){const r=[],s=[],a=()=>{const o=r.indexOf(null);return o!==-1?o:(r.push(null),r.length-1)};for(const o of t){const d=new Set;r.forEach((u,N)=>{u!==null&&d.add(N)});const i=[];r.forEach((u,N)=>{u===o.hash&&i.push(N)});const g=i.length>0,h=g?i[0]:a(),m=i.slice(1);for(const u of m)r[u]=null;const f=o.parents??[];r[h]=f.length>0?f[0]:null;const v=[];for(const u of f.slice(1)){const N=r.findIndex(x=>x===u);if(N!==-1&&N!==h)v.push(N);else{const x=a();r[x]=u,v.push(x)}}const y=[...d].filter(u=>u!==h&&!i.includes(u)).sort((u,N)=>u-N),p=[];r.forEach((u,N)=>{u!==null&&p.push(N)});const j=Math.max(r.length,h+1);for(;r.length>0&&r[r.length-1]===null;)r.pop();s.push({nodeLane:h,laneCount:j,hasTopContinuation:g,hasParentContinuation:f.length>0,inbound:m,outbound:v,passThrough:y,bottomLanes:p})}return s}const Re=12,ue=56,ee=28,Je=3.5,te=2,re=t=>t*Re+Re/2;function Xt({row:t}){const r=t.laneCount*Re,s=re(t.nodeLane),a=ae(t.nodeLane);return e.jsxs("div",{"aria-hidden":!0,className:"relative shrink-0 self-stretch overflow-hidden",style:{width:r},children:[e.jsxs("svg",{className:"absolute left-0 top-0",width:r,height:ue,fill:"none",children:[t.passThrough.map(o=>e.jsx("path",{d:`M ${re(o)} 0 V ${ue}`,stroke:ae(o),strokeWidth:te},`pass-${o}`)),t.hasTopContinuation&&e.jsx("path",{d:`M ${s} 0 V ${ee}`,stroke:a,strokeWidth:te}),t.hasParentContinuation&&e.jsx("path",{d:`M ${s} ${ee} V ${ue}`,stroke:a,strokeWidth:te}),t.inbound.map(o=>e.jsx("path",{d:`M ${re(o)} 0 Q ${re(o)} ${ee} ${s} ${ee}`,stroke:ae(o),strokeWidth:te},`in-${o}`)),t.outbound.map(o=>e.jsx("path",{d:`M ${s} ${ee} Q ${re(o)} ${ee} ${re(o)} ${ue}`,stroke:ae(o),strokeWidth:te},`out-${o}`)),e.jsx("circle",{cx:s,cy:ee,r:t.inbound.length>0||t.outbound.length>0?Je+.5:Je,fill:a})]}),t.bottomLanes.map(o=>e.jsx("div",{className:"absolute",style:{left:re(o)-te/2,top:ue,bottom:0,width:te,backgroundColor:ae(o)}},`rail-${o}`))]})}function Yt(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Zt({refName:t,color:r}){const s=t.startsWith("tag: "),a=t.startsWith("HEAD -> "),o=s?t.slice(5):a?t.slice(8):t;return e.jsxs("span",{className:"inline-flex max-w-40 items-center gap-1 rounded-full border px-1.5 py-px text-[10px] font-medium leading-4",style:{borderColor:r,color:r,backgroundColor:a?`${r}22`:"transparent"},title:t,children:[s?e.jsx(It,{className:"h-2.5 w-2.5 shrink-0"}):e.jsx(P,{className:"h-2.5 w-2.5 shrink-0"}),e.jsx("span",{className:"truncate",children:o})]})}function Pt({commit:t,isExpanded:r,diff:s,isMobile:a,wrapText:o,graphRow:d,onToggle:i}){const g=n.useMemo(()=>s?Mt(s):null,[s]),h=d?ae(d.nodeLane):"#0ea5e9";return e.jsxs("div",{className:"flex border-b border-border last:border-0",children:[d&&e.jsx(Xt,{row:d}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("button",{type:"button","aria-expanded":r,className:"flex w-full cursor-pointer items-start border-0 bg-transparent p-3 text-left transition-colors hover:bg-accent/50",onClick:i,children:[e.jsx("span",{className:"mr-2 mt-1 rounded p-0.5 hover:bg-accent",children:r?e.jsx(he,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[t.refs&&t.refs.length>0&&e.jsx("span",{className:"mb-0.5 flex flex-wrap gap-1",children:t.refs.map(m=>e.jsx(Zt,{refName:m,color:h},m))}),e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.message}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[t.author," • ",t.date]})]}),e.jsx("span",{className:"flex-shrink-0 font-mono text-sm text-muted-foreground/60",children:t.hash.substring(0,7)})]})})]}),r&&s&&e.jsx("div",{className:"bg-muted/50",children:e.jsxs("div",{className:"max-h-[32rem] overflow-y-auto p-3",children:[e.jsx("p",{className:"mb-2 select-all font-mono text-xs text-muted-foreground/70",children:t.hash}),e.jsxs("div",{className:"mb-3 flex gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground/60",children:"Author "}),t.author]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground/60",children:"Date "}),Yt(t.date)]})]}),g&&e.jsxs("div",{className:"mb-3 flex gap-4 rounded-md bg-muted/80 px-4 py-2 text-center text-xs",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground/60",children:"Files"}),e.jsx("div",{className:"font-semibold text-foreground",children:g.totalFiles})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground/60",children:"Added"}),e.jsxs("div",{className:"font-semibold text-green-600 dark:text-green-400",children:["+",g.totalInsertions]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground/60",children:"Removed"}),e.jsxs("div",{className:"font-semibold text-red-600 dark:text-red-400",children:["-",g.totalDeletions]})]})]}),g&&g.files.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground/60",children:"Changed Files"}),e.jsx("div",{className:"rounded-md border border-border/60",children:g.files.map((m,f)=>e.jsxs("div",{className:`flex items-center gap-2 px-2.5 py-1.5 text-xs ${f<g.files.length-1?"border-b border-border/40":""}`,children:[e.jsx("span",{className:`inline-flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border text-[9px] font-bold ${Oe(m.status)}`,children:m.status}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[m.directory&&e.jsx("span",{className:"text-muted-foreground/60",children:m.directory}),e.jsx("span",{className:"font-medium text-foreground",children:m.filename})]}),e.jsxs("span",{className:"flex-shrink-0 font-mono text-muted-foreground/60",children:[m.insertions>0&&e.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",m.insertions]}),m.insertions>0&&m.deletions>0&&"/",m.deletions>0&&e.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",m.deletions]})]})]},m.path))})]}),e.jsx(st,{diff:s,isMobile:a,wrapText:o})]})})]})]})}function er({isMobile:t,isLoading:r,recentCommits:s,commitDiffs:a,wrapText:o,onFetchCommitDiff:d}){const[i,g]=n.useState(new Set),h=n.useMemo(()=>s.some(f=>f.parents!==void 0)?Kt(s):null,[s]),m=n.useCallback(f=>{const v=!i.has(f);g(y=>{const p=new Set(y);return p.has(f)?p.delete(f):p.add(f),p}),v&&!a[f]&&d(f).catch(y=>{console.error("Failed to fetch commit diff:",y)})},[a,i,d,g]);return e.jsx("div",{className:"flex-1 overflow-y-auto",children:r?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(V,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s.length===0?e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center text-muted-foreground",children:[e.jsx(et,{className:"mb-2 h-10 w-10 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No commits found"})]}):e.jsx("div",{className:t?"pb-4":"",children:s.map((f,v)=>e.jsx(Pt,{commit:f,isExpanded:i.has(f.hash),diff:a[f.hash],isMobile:t,wrapText:o,graphRow:h?.[v],onToggle:()=>m(f.hash)},f.hash))})})}function nt({isOpen:t,currentBranch:r,isCreatingBranch:s,onClose:a,onCreateBranch:o}){const[d,i]=n.useState("");n.useEffect(()=>{t||i("")},[t]);const g=async()=>{const h=d.trim();if(!h)return!1;try{const m=await o(h);return m&&(i(""),a()),m}catch(m){return console.error("Failed to create branch:",m),!1}};return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),e.jsx("div",{className:"relative w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-2xl",role:"dialog","aria-modal":"true","aria-labelledby":"new-branch-title",children:e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{className:"mb-4 text-lg font-semibold text-foreground",children:"Create New Branch"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"git-new-branch-name",className:"mb-2 block text-sm font-medium text-foreground/80",children:"Branch Name"}),e.jsx("input",{id:"git-new-branch-name",type:"text",value:d,onChange:h=>i(h.target.value),onKeyDown:h=>{if(h.key==="Enter"&&!s){h.preventDefault(),h.stopPropagation(),g();return}h.key==="Escape"&&!s&&(h.preventDefault(),h.stopPropagation(),a())},placeholder:"feature/new-feature",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-primary/30 focus:outline-none focus:ring-2 focus:ring-primary/20",autoFocus:!0})]}),e.jsxs("p",{className:"mb-4 text-sm text-muted-foreground",children:["This will create a new branch from the current branch (",r,")"]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:a,className:"rounded-lg px-4 py-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:"Cancel"}),e.jsx("button",{onClick:()=>void g(),disabled:!d.trim()||s,className:"flex items-center space-x-2 rounded-lg bg-primary px-4 py-2 text-sm text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:s?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Creating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3 w-3"}),e.jsx("span",{children:"Create Branch"})]})})]})]})})]}):null}function qe({name:t,isCurrent:r,isRemote:s,aheadCount:a,behindCount:o,isMobile:d,onSwitch:i,onDelete:g}){return e.jsxs("div",{className:`group flex items-center gap-3 border-b border-border/40 px-4 transition-colors hover:bg-accent/40 ${d?"py-2.5":"py-3"} ${r?"bg-primary/5":""}`,children:[e.jsx("div",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border ${r?"border-primary/30 bg-primary/10 text-primary":s?"border-border bg-muted text-muted-foreground":"border-border bg-muted/50 text-muted-foreground"}`,children:s?e.jsx(pt,{className:"h-3.5 w-3.5"}):e.jsx(P,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`truncate text-sm font-medium ${r?"text-foreground":"text-foreground/80"}`,children:t}),r&&e.jsx("span",{className:"shrink-0 rounded-full bg-primary/15 px-1.5 py-0.5 text-xs font-semibold text-primary",children:"current"}),s&&!r&&e.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:"remote"})]}),r&&(a>0||o>0)&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a>0&&e.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["↑",a," ahead"]}),o>0&&e.jsxs("span",{className:"text-primary",children:["↓",o," behind"]})]})]}),e.jsx("div",{className:`flex shrink-0 items-center gap-1 ${r?"opacity-100":"opacity-0 group-hover:opacity-100"} transition-opacity`,children:r?e.jsx(pe,{className:"h-4 w-4 text-primary"}):s?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",title:`Switch to ${t}`,children:"Switch"}),e.jsx("button",{onClick:g,className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",title:`Delete ${t}`,children:e.jsx(oe,{className:"h-3.5 w-3.5"})})]})})]})}function Ve({label:t,count:r}){return e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between bg-background/95 px-4 py-2 backdrop-blur-sm",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:r})]})}function tr({isMobile:t,isLoading:r,currentBranch:s,localBranches:a,remoteBranches:o,remoteStatus:d,isCreatingBranch:i,onSwitchBranch:g,onCreateBranch:h,onDeleteBranch:m,onRequestConfirmation:f}){const[v,y]=n.useState(!1),[p,j]=n.useState(""),u=d?.ahead??0,N=d?.behind??0,x=p.trim().toLowerCase(),T=n.useMemo(()=>x?a.filter(w=>w.toLowerCase().includes(x)):a,[a,x]),I=n.useMemo(()=>x?o.filter(w=>w.toLowerCase().includes(x)):o,[x,o]),B=w=>{f({type:"commit",message:`Switch to branch "${w}"? Make sure you have no uncommitted changes.`,onConfirm:()=>void g(w)})},W=w=>{f({type:"deleteBranch",message:`Delete branch "${w}"? A normal delete only succeeds when the branch is fully merged. This cannot be undone.`,onConfirm:()=>void m(w),alternateConfirmation:{label:"Force delete this unmerged branch",description:"Permanently removes the branch even when it contains commits that have not been merged elsewhere.",actionLabel:"Force delete",onConfirm:()=>void m(w,!0)}})};return r&&a.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(V,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/40 px-4 py-2.5",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.length," local",o.length>0?`, ${o.length} remote`:""]}),e.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1.5 rounded-lg bg-primary/10 px-3 py-1.5 text-sm font-medium text-primary transition-colors hover:bg-primary/20",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"New branch"]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/40 px-4 py-2",children:[e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("input",{type:"text",value:p,onChange:w=>j(w.target.value),placeholder:"Search branches...",className:"w-full bg-transparent text-sm text-foreground placeholder:text-muted-foreground focus:outline-none"}),p&&e.jsx("button",{onClick:()=>j(""),className:"shrink-0 text-muted-foreground transition-colors hover:text-foreground",title:"Clear search",children:e.jsx(we,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[T.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{label:"Local",count:T.length}),T.map(w=>e.jsx(qe,{name:w,isCurrent:w===s,isRemote:!1,aheadCount:w===s?u:0,behindCount:w===s?N:0,isMobile:t,onSwitch:()=>B(w),onDelete:()=>W(w)},`local:${w}`))]}),I.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{label:"Remote",count:I.length}),I.map(w=>e.jsx(qe,{name:w,isCurrent:!1,isRemote:!0,aheadCount:0,behindCount:0,isMobile:t,onSwitch:()=>B(w),onDelete:()=>W(w)},`remote:${w}`))]}),T.length===0&&I.length===0&&e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(P,{className:"h-10 w-10 opacity-30"}),e.jsx("p",{className:"text-sm",children:x?"No branches match your search":"No branches found"})]})]}),e.jsx(nt,{isOpen:v,currentBranch:s,isCreatingBranch:i,onClose:()=>y(!1),onCreateBranch:h})]})}function Ne(t,r){const s=t.error?.message||r,a=t.error?.details;return Array.isArray(a)&&a.length>0?`${s}: ${a.slice(0,5).join(", ")}${a.length>5?", …":""}`:typeof a=="string"&&a.trim()?`${s}: ${a.trim()}`:s}function rr({selectedProject:t,onProjectSelect:r,onProjectsRefresh:s}){const[a,o]=n.useState(null),[d,i]=n.useState(!1),[g,h]=n.useState(!1),[m,f]=n.useState(!1),[v,y]=n.useState(null),p=n.useRef(null),[j,u]=n.useState(null),N=n.useCallback(()=>u(null),[]),x=n.useRef(t?.projectId??null);n.useEffect(()=>{x.current=t?.projectId??null},[t]);const T=n.useCallback(async()=>{if(!t)return;const $=t.projectId;i(!0);try{const k=await Z(`/api/worktrees?project=${encodeURIComponent($)}`),L=await k.json();if(x.current!==$)return;if(!k.ok||!L.data){o(null);return}o(L.data)}catch(k){console.error("Error fetching worktrees:",k),x.current===$&&o(null)}finally{x.current===$&&(i(!1),h(!0))}},[t]);n.useEffect(()=>{o(null),h(!1),u(null),T()},[T]);const I=n.useCallback(async($,k,L)=>{const S=$.trim();if(!t||!S)return!1;const R=t.projectId;f(!0),u(null);try{const G=await Z("/api/worktrees/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:R,branch:S,baseBranch:k})}),J=await G.json();return x.current!==R?!1:!G.ok||!J.data?(u(Ne(J,"Failed to create worktree")),!1):(s?.(),L&&J.data.project&&r?r(J.data.project):T(),!0)}catch(G){return x.current===R&&u(G instanceof Error?G.message:"Failed to create worktree"),!1}finally{f(!1)}},[T,r,s,t]),B=n.useCallback(async $=>{if(!t||p.current!==null)return!1;const k=t.projectId,L=Symbol("open-worktree");p.current=L,y($),u(null);try{const S=await Z("/api/worktrees/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:k,worktreePath:$})}),R=await S.json();return x.current!==k?!1:!S.ok||!R.data?.project?(u(Ne(R,"Failed to open worktree")),!1):(s?.(),r?.(R.data.project),!0)}catch(S){return x.current===k&&u(S instanceof Error?S.message:"Failed to open worktree"),!1}finally{p.current===L&&(p.current=null,y(null))}},[r,s,t]),W=n.useCallback(async($,k)=>{if(!t||p.current!==null)return!1;const L=Symbol("merge-worktree");p.current=L,y($),u(null);try{const S=await Z("/api/worktrees/merge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,worktreePath:$,squash:k.squash,message:k.message,removeAfterMerge:k.removeAfterMerge})}),R=await S.json();return!S.ok||!R.success?(u(Ne(R,"Merge failed")),!1):(s?.(),T(),!0)}catch(S){return u(S instanceof Error?S.message:"Merge failed"),!1}finally{p.current===L&&(p.current=null,y(null))}},[T,s,t]),w=n.useCallback(async($,k)=>{if(!t||p.current!==null)return!1;const L=Symbol("remove-worktree");p.current=L,y($),u(null);try{const S=await Z("/api/worktrees/remove",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.projectId,worktreePath:$,force:k.force,deleteBranch:k.deleteBranch})}),R=await S.json();return!S.ok||!R.success?(u(Ne(R,"Failed to remove worktree")),!1):(s?.(),T(),!0)}catch(S){return u(S instanceof Error?S.message:"Failed to remove worktree"),!1}finally{p.current===L&&(p.current=null,y(null))}},[T,s,t]);return{worktreeData:a,isLoading:d||!g,isCreatingWorktree:m,busyWorktreePath:v,actionError:j,clearActionError:N,refreshWorktrees:T,createWorktree:I,openWorktree:B,mergeWorktree:W,removeWorktree:w}}function Qe(t,r){return t?r?`Squash merge branch '${t}'`:`Merge branch '${t}'`:""}function sr({worktree:t,baseBranch:r,isMerging:s,onClose:a,onMerge:o}){const[d,i]=n.useState(!0),[g,h]=n.useState(""),[m,f]=n.useState(!0),[v,y]=n.useState(!1);n.useEffect(()=>{t&&(i(!0),f(!0),h(Qe(t.branch,!0)),y(!1))},[t]);const p=N=>{i(N),v||h(Qe(t?.branch??null,N))},j=async()=>{if(!t)return;await o(t.path,{squash:d,message:g.trim(),removeAfterMerge:m})&&a()};if(!t)return null;const u=`${t.ahead} commit${t.ahead===1?"":"s"}`;return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),e.jsx("div",{className:"relative w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-2xl",role:"dialog","aria-modal":"true","aria-labelledby":"merge-worktree-title",children:e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{id:"merge-worktree-title",className:"mb-1 text-lg font-semibold text-foreground",children:"Merge Worktree"}),e.jsxs("div",{className:"mb-4 flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"max-w-[45%] truncate rounded-md bg-primary/10 px-2 py-1 font-mono text-primary",children:t.branch}),e.jsx(gt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"max-w-[45%] truncate rounded-md bg-muted px-2 py-1 font-mono text-foreground/80",children:r}),e.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:u})]}),e.jsxs("label",{className:"mb-3 flex cursor-pointer items-start gap-2 text-sm text-foreground/80",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:N=>p(N.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsxs("span",{children:["Squash commits",e.jsxs("span",{className:"block text-xs text-muted-foreground",children:["Combine all ",u," into a single commit on ",r]})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{htmlFor:"merge-worktree-message",className:"mb-2 block text-sm font-medium text-foreground/80",children:"Commit message"}),e.jsx("textarea",{id:"merge-worktree-message",value:g,onChange:N=>{h(N.target.value),y(!0)},rows:2,className:"w-full resize-none rounded-xl border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary/30 focus:outline-none focus:ring-2 focus:ring-primary/20"})]}),e.jsxs("label",{className:"mb-4 flex cursor-pointer items-start gap-2 text-sm text-foreground/80",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:N=>f(N.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsxs("span",{children:["Clean up after merge",e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Remove the worktree and delete its branch once merged"})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:a,className:"rounded-lg px-4 py-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:"Cancel"}),e.jsx("button",{onClick:()=>void j(),disabled:s||!g.trim(),className:"flex items-center space-x-2 rounded-lg bg-primary px-4 py-2 text-sm text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:s?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Merging..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"h-3 w-3"}),e.jsx("span",{children:d?"Squash & Merge":"Merge"})]})})]})]})})]})}function nr(t){return t.replace(/[/\\:*?"<>|\s]+/g,"-").replace(/\.+$/g,"").replace(/^-+|-+$/g,"")}function ar(t){const r=t.split(/[\\/]/).filter(Boolean);return r[r.length-1]??t}function or({isOpen:t,baseBranch:r,localBranches:s,repositoryRoot:a,isCreating:o,onClose:d,onCreate:i}){const[g,h]=n.useState(""),[m,f]=n.useState(""),[v,y]=n.useState(!0);n.useEffect(()=>{if(!t)h(""),y(!0);else{const x=r&&s.includes(r)?r:s[0]??"";f(x)}},[t,r,s]);const p=g.trim(),j=s.includes(p),u=n.useMemo(()=>{if(!p)return null;const x=nr(p);return x?`${ar(a)}-worktrees/${x}`:null},[a,p]),N=async()=>{if(!p)return!1;const x=await i(p,j?null:m||null,v);return x&&d(),x};return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:d}),e.jsx("div",{className:"relative w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-2xl",role:"dialog","aria-modal":"true","aria-labelledby":"new-worktree-title",children:e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{id:"new-worktree-title",className:"mb-1 text-lg font-semibold text-foreground",children:"New Worktree"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Check out a branch in its own folder and work on it in parallel."}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"worktree-branch-name",className:"mb-2 block text-sm font-medium text-foreground/80",children:"Branch"}),e.jsx("input",{id:"worktree-branch-name",type:"text",value:g,onChange:x=>h(x.target.value),onKeyDown:x=>{if(x.key==="Enter"&&!o){x.preventDefault(),x.stopPropagation(),N();return}x.key==="Escape"&&!o&&(x.preventDefault(),x.stopPropagation(),d())},placeholder:"feature/new-feature",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-primary/30 focus:outline-none focus:ring-2 focus:ring-primary/20",autoFocus:!0}),j&&e.jsx("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"Existing branch — it will be checked out as-is."})]}),!j&&e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"worktree-base-branch",className:"mb-2 block text-sm font-medium text-foreground/80",children:"Create from"}),e.jsx("select",{id:"worktree-base-branch",value:m,onChange:x=>f(x.target.value),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-foreground focus:border-primary/30 focus:outline-none focus:ring-2 focus:ring-primary/20",children:s.map(x=>e.jsx("option",{value:x,children:x},x))})]}),u&&e.jsxs("p",{className:"mb-4 rounded-lg bg-muted/50 px-3 py-2 text-xs text-muted-foreground",children:["Will be created in ",e.jsx("span",{className:"font-mono text-foreground/80",children:u})]}),e.jsxs("label",{className:"mb-4 flex cursor-pointer items-center gap-2 text-sm text-foreground/80",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:x=>y(x.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),"Switch to the worktree after creating it"]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:d,className:"rounded-lg px-4 py-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:"Cancel"}),e.jsx("button",{onClick:()=>void N(),disabled:!p||o,className:"flex items-center space-x-2 rounded-lg bg-primary px-4 py-2 text-sm text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:o?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Creating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3 w-3"}),e.jsx("span",{children:"Create Worktree"})]})})]})]})})]}):null}function ir({worktree:t,isRemoving:r,onClose:s,onRemove:a}){const[o,d]=n.useState(!0),[i,g]=n.useState(!1);n.useEffect(()=>{t&&(d(!0),g(!1))},[t]);const h=async()=>{if(!t)return;await a(t.path,{force:i,deleteBranch:o})&&s()};if(!t)return null;const m=t.changedFileCount>0;return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:s}),e.jsx("div",{className:"relative w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-2xl",role:"dialog","aria-modal":"true","aria-labelledby":"remove-worktree-title",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-4 flex items-center",children:[e.jsx("div",{className:"mr-3 rounded-full bg-red-100 p-2 dark:bg-red-900/30",children:e.jsx(oe,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("h3",{id:"remove-worktree-title",className:"text-lg font-semibold text-foreground",children:"Remove Worktree"})]}),e.jsxs("p",{className:"mb-3 text-sm text-muted-foreground",children:["Remove the worktree for"," ",e.jsx("span",{className:"font-mono text-foreground/80",children:t.branch??"detached HEAD"}),"? Its folder is deleted and the linked project is archived — chat sessions stay recoverable."]}),m&&e.jsxs("p",{className:"mb-3 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-600 dark:text-amber-400",children:["This worktree has ",t.changedFileCount," uncommitted change",t.changedFileCount===1?"":"s"," that will be lost."]}),t.branch&&e.jsxs("label",{className:"mb-2 flex cursor-pointer items-center gap-2 text-sm text-foreground/80",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:f=>d(f.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),"Also delete branch ",e.jsx("span",{className:"font-mono",children:t.branch})]}),m&&e.jsxs("label",{className:"mb-2 flex cursor-pointer items-center gap-2 text-sm text-foreground/80",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:f=>g(f.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),"Discard uncommitted changes"]}),e.jsxs("div",{className:"mt-4 flex justify-end space-x-3",children:[e.jsx("button",{onClick:s,className:"rounded-lg px-4 py-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:"Cancel"}),e.jsx("button",{onClick:()=>void h(),disabled:r||m&&!i,className:"flex items-center space-x-2 rounded-lg bg-red-600 px-4 py-2 text-sm text-white transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-50",children:r?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Removing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"h-3 w-3"}),e.jsx("span",{children:"Remove"})]})})]})]})})]})}function lr(t){return t.split(/[\\/]/).filter(Boolean).slice(-2).join("/")||t}function cr({worktree:t,isMobile:r,isBusy:s,onOpen:a,onMerge:o,onRemove:d}){const i=t.branch??(t.headSha?`detached @ ${t.headSha.slice(0,7)}`:"detached");return e.jsxs("div",{className:`group flex items-center gap-3 border-b border-border/40 px-4 transition-colors hover:bg-accent/40 ${r?"py-2.5":"py-3"} ${t.isCurrent?"bg-primary/5":""}`,children:[e.jsx("div",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border ${t.isCurrent?"border-primary/30 bg-primary/10 text-primary":"border-border bg-muted/50 text-muted-foreground"}`,children:t.isMain?e.jsx($t,{className:"h-3.5 w-3.5"}):e.jsx(ve,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`truncate text-sm font-medium ${t.isCurrent?"text-foreground":"text-foreground/80"}`,children:i}),t.isCurrent&&e.jsx("span",{className:"shrink-0 rounded-full bg-primary/15 px-1.5 py-0.5 text-xs font-semibold text-primary",children:"current"}),t.isMain&&e.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:"main worktree"}),t.isLocked&&e.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:"locked"})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"shrink-0 font-mono",children:lr(t.path)}),t.ahead>0&&e.jsxs("span",{className:"shrink-0 text-green-600 dark:text-green-400",children:["↑",t.ahead]}),t.behind>0&&e.jsxs("span",{className:"shrink-0 text-primary",children:["↓",t.behind]}),t.changedFileCount>0&&e.jsxs("span",{className:"shrink-0 text-amber-600 dark:text-amber-400",children:["● ",t.changedFileCount," change",t.changedFileCount===1?"":"s"]}),t.lastCommitSubject&&e.jsx("span",{className:"truncate",children:t.lastCommitSubject})]})]}),e.jsx("div",{className:`flex shrink-0 items-center gap-1 ${t.isCurrent||s?"opacity-100":"opacity-100 sm:opacity-0 sm:focus-within:opacity-100 sm:group-hover:opacity-100"} transition-opacity`,children:s?e.jsx(V,{className:"h-4 w-4 animate-spin text-muted-foreground"}):t.isCurrent?e.jsx(pe,{className:"h-4 w-4 text-primary"}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:a,className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",title:`Switch to ${i}`,children:[e.jsx(vt,{className:"h-3 w-3"}),"Open"]}),!t.isMain&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:o,disabled:!t.branch||t.ahead===0,className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary disabled:cursor-not-allowed disabled:opacity-40",title:t.ahead===0?"Nothing to merge — no commits ahead of the base branch":`Merge ${i} into the base branch`,children:e.jsx(Ye,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:d,className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",title:`Remove worktree for ${i}`,children:e.jsx(oe,{className:"h-3.5 w-3.5"})})]})]})})]})}function dr({isMobile:t,selectedProject:r,localBranches:s,onProjectSelect:a,onProjectsRefresh:o}){const{worktreeData:d,isLoading:i,isCreatingWorktree:g,busyWorktreePath:h,actionError:m,clearActionError:f,refreshWorktrees:v,createWorktree:y,openWorktree:p,mergeWorktree:j,removeWorktree:u}=rr({selectedProject:r,onProjectSelect:a,onProjectsRefresh:o}),[N,x]=n.useState(!1),[T,I]=n.useState(null),[B,W]=n.useState(null),w=d?.worktrees??[],$=w.filter(k=>!k.isMain).length;return i&&w.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(V,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/40 px-4 py-2.5",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:$===0?"No worktrees":`${$} worktree${$===1?"":"s"}`}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>void v(),className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",title:"Refresh worktrees",children:e.jsx(V,{className:`h-3.5 w-3.5 ${i?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>x(!0),disabled:!d,className:"flex items-center gap-1.5 rounded-lg bg-primary/10 px-3 py-1.5 text-sm font-medium text-primary transition-colors hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"New worktree"]})]})]}),m&&e.jsxs("div",{className:"flex items-start gap-2 border-b border-destructive/30 bg-destructive/10 px-4 py-2.5",children:[e.jsx("p",{className:"min-w-0 flex-1 break-words text-xs text-destructive",children:m}),e.jsx("button",{onClick:f,className:"shrink-0 text-destructive/70 transition-colors hover:text-destructive",title:"Dismiss",children:e.jsx(we,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[w.map(k=>e.jsx(cr,{worktree:k,isMobile:t,isBusy:h===k.path,onOpen:()=>void p(k.path),onMerge:()=>I(k),onRemove:()=>W(k)},k.path)),$===0&&e.jsxs("div",{className:"flex flex-col items-center gap-3 px-6 py-10 text-center",children:[e.jsx(ve,{className:"h-10 w-10 text-muted-foreground opacity-30"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground/80",children:"Work on branches in parallel"}),e.jsx("p",{className:"mx-auto mt-1 max-w-xs text-xs text-muted-foreground",children:"A worktree checks out a branch in its own folder, so you can run separate chat sessions side by side and merge the results back when they're ready."})]}),e.jsxs("button",{onClick:()=>x(!0),disabled:!d,className:"flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"Create your first worktree"]})]})]}),e.jsx(or,{isOpen:N,baseBranch:d?.baseBranch??null,localBranches:s,repositoryRoot:d?.repositoryRoot??"",isCreating:g,onClose:()=>x(!1),onCreate:y}),e.jsx(sr,{worktree:T,baseBranch:d?.baseBranch??null,isMerging:T!==null&&h===T.path,onClose:()=>I(null),onMerge:j}),e.jsx(ir,{worktree:B,isRemoving:B!==null&&h===B.path,onClose:()=>W(null),onRemove:u})]})}function mr({isMobile:t,currentBranch:r,branches:s,remoteStatus:a,isLoading:o,isCreatingBranch:d,isFetching:i,isPulling:g,isPushing:h,isPublishing:m,isRevertingLocalCommit:f,operationError:v,onRefresh:y,onRevertLocalCommit:p,onSwitchBranch:j,onCreateBranch:u,onFetch:N,onPull:x,onPush:T,onPublish:I,onClearError:B,onRequestConfirmation:W}){const[w,$]=n.useState(!1),[k,L]=n.useState(!1),[S,R]=n.useState(""),G=n.useRef(null),J=n.useRef(null);n.useEffect(()=>{w?J.current?.focus():R("")},[w]);const Y=n.useMemo(()=>{const D=S.trim().toLowerCase();return D?s.filter(K=>K.toLowerCase().includes(D)):s},[s,S]);n.useEffect(()=>{const D=K=>{G.current&&!G.current.contains(K.target)&&$(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const U=a?.ahead??0,C=a?.behind??0,A=a?.remoteName??"remote",H=i||g||h||m,Q=()=>{W({type:"pull",message:`Pull ${C} commit${C!==1?"s":""} from ${A}?`,onConfirm:x})},se=()=>{W({type:"push",message:`Push ${U} commit${U!==1?"s":""} to ${A}?`,onConfirm:T})},ie=()=>{W({type:"publish",message:`Publish branch "${r}" to ${A}?`,onConfirm:I})},ne=()=>{W({type:"revertLocalCommit",message:"Revert the latest local commit? This removes the commit but keeps its changes staged.",onConfirm:p})},le=async D=>{try{await j(D)&&$(!1)}catch(K){console.error("[GitPanelHeader] Failed to switch branch:",K)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center justify-between border-b border-border/60 ${t?"px-3 py-2":"px-4 py-3"}`,children:[e.jsxs("div",{className:"relative",ref:G,children:[e.jsxs("button",{onClick:()=>$(D=>!D),className:`flex items-center rounded-lg transition-colors hover:bg-accent ${t?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[e.jsx(P,{className:`text-muted-foreground ${t?"h-3 w-3":"h-4 w-4"}`}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`font-medium ${t?"text-xs":"text-sm"}`,children:r}),a?.hasRemote&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs",children:[U>0&&e.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${U} ahead`,children:["↑",U]}),C>0&&e.jsxs("span",{className:"text-primary",title:`${C} behind`,children:["↓",C]}),a.isUpToDate&&e.jsx("span",{className:"text-muted-foreground",title:"Up to date",children:"✓"})]})]}),e.jsx(he,{className:`h-3 w-3 text-muted-foreground transition-transform ${w?"rotate-180":""}`})]}),w&&e.jsxs("div",{className:"absolute left-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-xl border border-border bg-card shadow-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("input",{ref:J,type:"text",value:S,onChange:D=>R(D.target.value),placeholder:"Search branches...",className:"w-full bg-transparent text-sm text-foreground placeholder:text-muted-foreground focus:outline-none"}),S&&e.jsx("button",{onClick:()=>R(""),className:"shrink-0 text-muted-foreground transition-colors hover:text-foreground",title:"Clear search",children:e.jsx(we,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:Y.length===0?e.jsx("div",{className:"px-4 py-3 text-center text-sm text-muted-foreground",children:"No matching branches"}):Y.map(D=>e.jsx("button",{onClick:()=>void le(D),className:`w-full px-4 py-2 text-left text-sm transition-colors hover:bg-accent ${D===r?"bg-accent/50 text-foreground":"text-muted-foreground"}`,children:e.jsxs("span",{className:"flex items-center space-x-2",children:[D===r&&e.jsx(pe,{className:"h-3 w-3 text-primary"}),e.jsx("span",{className:D===r?"font-medium":"",children:D})]})},D))}),e.jsx("div",{className:"border-t border-border py-1",children:e.jsxs("button",{onClick:()=>{L(!0),$(!1)},className:"flex w-full items-center space-x-2 px-4 py-2 text-left text-sm transition-colors hover:bg-accent",children:[e.jsx(xe,{className:"h-3 w-3"}),e.jsx("span",{children:"Create new branch"})]})})]})]}),e.jsxs("div",{className:`flex items-center ${t?"gap-1":"gap-2"}`,children:[a?.hasRemote&&e.jsx(e.Fragment,{children:a.hasUpstream?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>void N(),disabled:H,className:"flex items-center gap-1 rounded-lg bg-primary px-2.5 py-1 text-sm text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",title:`Fetch from ${A}`,children:[e.jsx(V,{className:`h-3 w-3 ${i?"animate-spin":""}`}),!t&&e.jsx("span",{children:i?"Fetching…":"Fetch"})]}),C>0&&e.jsxs("button",{onClick:Q,disabled:H,className:"flex items-center gap-1 rounded-lg bg-green-600 px-2.5 py-1 text-sm text-white transition-colors hover:bg-green-700 disabled:opacity-50",title:`Pull ${C} from ${A}`,children:[e.jsx(Ze,{className:`h-3 w-3 ${g?"animate-pulse":""}`}),!t&&e.jsx("span",{children:g?"Pulling…":`Pull ${C}`})]}),U>0&&e.jsxs("button",{onClick:se,disabled:H,className:"flex items-center gap-1 rounded-lg bg-orange-600 px-2.5 py-1 text-sm text-white transition-colors hover:bg-orange-700 disabled:opacity-50",title:`Push ${U} to ${A}`,children:[e.jsx(Le,{className:`h-3 w-3 ${h?"animate-pulse":""}`}),!t&&e.jsx("span",{children:h?"Pushing…":`Push ${U}`})]})]}):e.jsxs("button",{onClick:ie,disabled:H,className:"flex items-center gap-1 rounded-lg bg-primary px-2.5 py-1 text-sm text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",title:`Publish "${r}" to ${A}`,children:[e.jsx(Le,{className:`h-3 w-3 ${m?"animate-pulse":""}`}),!t&&e.jsx("span",{children:m?"Publishing…":"Publish"})]})}),e.jsx("button",{onClick:ne,disabled:f,className:`rounded-lg transition-colors hover:bg-accent disabled:opacity-50 ${t?"p-1":"p-1.5"}`,title:"Revert latest local commit",children:e.jsx(Pe,{className:`text-muted-foreground ${f?"animate-pulse":""} ${t?"h-3 w-3":"h-4 w-4"}`})}),e.jsx("button",{onClick:y,disabled:o,className:`rounded-lg transition-colors hover:bg-accent ${t?"p-1":"p-1.5"}`,title:"Refresh git status",children:e.jsx(V,{className:`text-muted-foreground ${o?"animate-spin":""} ${t?"h-3 w-3":"h-4 w-4"}`})})]})]}),v&&e.jsxs("div",{className:"flex items-start gap-2 border-b border-destructive/20 bg-destructive/10 px-4 py-2.5 text-sm text-destructive",children:[e.jsx(bt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{className:"flex-1 leading-snug",children:v}),e.jsx("button",{onClick:B,className:"shrink-0 rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(we,{className:"h-3.5 w-3.5"})})]}),e.jsx(nt,{isOpen:k,currentBranch:r,isCreatingBranch:d,onClose:()=>L(!1),onCreateBranch:u})]})}function ur({error:t,details:r,canInitRepository:s=!1,isInitializingRepository:a=!1,initError:o,onInitRepository:d}){const i=s&&!!d;return e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-12 text-muted-foreground",children:[e.jsx("div",{className:"mb-6 flex h-16 w-16 items-center justify-center rounded-2xl bg-muted/50",children:e.jsx(P,{className:"h-8 w-8 opacity-40"})}),i?e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"mb-3 text-center text-lg font-medium text-foreground",children:"No git repository"}),e.jsx("p",{className:"mb-6 max-w-md text-center text-sm leading-relaxed",children:"This project is not a git repository yet. Initialize one to start tracking changes and use source control features."}),e.jsx("button",{onClick:d,disabled:a,className:"flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-60",children:a?e.jsxs(e.Fragment,{children:[e.jsx(yt,{className:"h-4 w-4 animate-spin"}),"Initializing repository..."]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"h-4 w-4"}),"Run git init"]})}),o&&e.jsx("p",{className:"mt-4 max-w-md text-center text-sm leading-relaxed text-destructive",children:o})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"mb-3 text-center text-lg font-medium text-foreground",children:t}),r&&e.jsx("p",{className:"max-w-md text-center text-sm leading-relaxed",children:r})]})]})}const hr=[{id:"changes",label:"Changes",Icon:jt},{id:"history",label:"Commits",Icon:et},{id:"branches",label:"Branches",Icon:P},{id:"worktrees",label:"Worktrees",Icon:ve}];function xr({activeView:t,isHidden:r,changeCount:s,onChange:a}){return e.jsx("div",{className:`border-b border-border/60 transition-all duration-300 ease-in-out ${r?"max-h-0 -translate-y-2 overflow-hidden opacity-0":"max-h-16 translate-y-0 opacity-100"}`,children:e.jsx("div",{className:"scrollbar-hide flex w-full snap-x overflow-x-auto overscroll-x-contain [-webkit-overflow-scrolling:touch]",role:"tablist","aria-label":"Source control views",children:hr.map(({id:o,label:d,Icon:i})=>e.jsx("button",{type:"button",role:"tab","aria-selected":t===o,onClick:()=>a(o),className:`min-w-max flex-none snap-start px-4 py-2 text-sm font-medium transition-colors sm:min-w-0 sm:flex-1 ${t===o?"border-b-2 border-primary text-primary":"text-muted-foreground hover:text-foreground"}`,children:e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(i,{className:"h-4 w-4"}),e.jsx("span",{children:d}),o==="changes"&&s>0&&e.jsx("span",{className:"rounded-full bg-primary/15 px-1.5 py-0.5 text-xs font-semibold text-primary",children:s})]})},o))})})}function Ke(t){return t==="discard"||t==="delete"?e.jsx(oe,{className:"h-4 w-4"}):t==="commit"?e.jsx(pe,{className:"h-4 w-4"}):t==="pull"?e.jsx(Ze,{className:"h-4 w-4"}):t==="revertLocalCommit"?e.jsx(Pe,{className:"h-4 w-4"}):e.jsx(Le,{className:"h-4 w-4"})}function fr({action:t,onCancel:r,onConfirm:s}){const[a,o]=n.useState(!1),d=t?`confirmation-title-${t.type}`:void 0,i=()=>{o(!1),r()},g=()=>{const h=a&&!!t?.alternateConfirmation;o(!1),s(h)};return n.useEffect(()=>{if(!t)return;const h=m=>{m.key==="Escape"&&(o(!1),r())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[t,r]),t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative flex max-h-[calc(100dvh-2rem)] w-full max-w-md flex-col overflow-hidden rounded-xl border border-border bg-card shadow-2xl",role:"dialog","aria-modal":"true","aria-labelledby":d,children:[e.jsxs("div",{className:"flex shrink-0 items-center px-6 pt-6",children:[e.jsx("div",{className:`mr-3 rounded-full p-2 ${Ot[t.type]}`,children:Ke(t.type)}),e.jsx("h3",{id:d,className:"text-lg font-semibold text-foreground",children:Rt[t.type]})]}),e.jsx("p",{className:"scrollbar-thin my-4 min-h-0 flex-1 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words px-6 text-sm text-muted-foreground",children:t.message}),t.alternateConfirmation&&e.jsxs("label",{className:"mx-6 mb-5 flex cursor-pointer items-start gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-3 transition-colors hover:bg-destructive/10",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:h=>o(h.target.checked),className:"mt-0.5 h-4 w-4 shrink-0 accent-destructive"}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-foreground",children:[e.jsx(Nt,{className:"h-3.5 w-3.5 text-destructive"}),t.alternateConfirmation.label]}),e.jsx("span",{className:"mt-1 block text-xs leading-relaxed text-muted-foreground",children:t.alternateConfirmation.description})]})]}),e.jsxs("div",{className:"flex shrink-0 justify-end space-x-3 px-6 pb-6",children:[e.jsx("button",{onClick:i,className:"rounded-lg px-4 py-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:"Cancel"}),e.jsxs("button",{onClick:g,className:`flex items-center space-x-2 rounded-lg px-4 py-2 text-sm text-white transition-colors ${Dt[t.type]}`,children:[Ke(t.type),e.jsx("span",{children:a&&t.alternateConfirmation?t.alternateConfirmation.actionLabel:At[t.type]})]})]})]})]}):null}function br({selectedProject:t,isMobile:r=!1,onFileOpen:s,onProjectSelect:a,onProjectsRefresh:o}){const[d,i]=n.useState("changes"),[g,h]=n.useState(!0),[m,f]=n.useState(!1),[v,y]=n.useState(null),{gitStatus:p,gitDiff:j,isLoading:u,isLoadingCommits:N,currentBranch:x,branches:T,localBranches:I,remoteBranches:B,recentCommits:W,commitDiffs:w,remoteStatus:$,isCreatingBranch:k,isFetching:L,isPulling:S,isPushing:R,isPublishing:G,isCreatingInitialCommit:J,isInitializingRepository:Y,operationError:U,clearOperationError:C,refreshAll:A,switchBranch:H,createBranch:Q,deleteBranch:se,handleFetch:ie,handlePull:ne,handlePush:le,handlePublish:D,discardChanges:K,deleteUntrackedFile:z,stageFiles:Ce,unstageFiles:X,fetchCommitDiff:ge,commitChanges:be,createInitialCommit:E,initRepository:q,openFile:_}=_t({selectedProject:t,activeView:d,onFileOpen:s}),{isRevertingLocalCommit:ke,revertLatestLocalCommit:Se}=zt({projectId:t?.projectId??null,onSuccess:A}),$e=n.useCallback(async(de=!1)=>{if(!v)return;const me=v;y(null);try{await(de?me.alternateConfirmation?.onConfirm??me.onConfirm:me.onConfirm)()}catch(ye){console.error("Error executing confirmation action:",ye)}},[v]),Ee=rt(p),ce=!!p?.notGitRepository;return t?e.jsxs("div",{className:"flex h-full flex-col bg-background",children:[!ce&&e.jsx(mr,{isMobile:r,currentBranch:x,branches:T,remoteStatus:$,isLoading:u,isCreatingBranch:k,isFetching:L,isPulling:S,isPushing:R,isPublishing:G,isRevertingLocalCommit:ke,operationError:U,onRefresh:A,onRevertLocalCommit:Se,onSwitchBranch:H,onCreateBranch:Q,onFetch:ie,onPull:ne,onPush:le,onPublish:D,onClearError:C,onRequestConfirmation:y}),p?.error?e.jsx(ur,{error:p.error,details:p.details,canInitRepository:ce,isInitializingRepository:Y,initError:ce?U:null,onInitRepository:()=>{C(),q()}}):e.jsxs(e.Fragment,{children:[e.jsx(xr,{activeView:d,isHidden:m,changeCount:Ee,onChange:i}),d==="changes"&&e.jsx(Qt,{isMobile:r,projectPath:t.fullPath,gitStatus:p,gitDiff:j,isLoading:u,wrapText:g,isCreatingInitialCommit:J,onWrapTextChange:h,onCreateInitialCommit:E,onOpenFile:_,onDiscardFile:K,onDeleteFile:z,onStageFiles:Ce,onUnstageFiles:X,onCommitChanges:be,onRequestConfirmation:y,onExpandedFilesChange:f},t.fullPath),d==="history"&&e.jsx(er,{isMobile:r,isLoading:u||W.length===0&&N,recentCommits:W,commitDiffs:w,wrapText:g,onFetchCommitDiff:ge}),d==="worktrees"&&e.jsx(dr,{isMobile:r,selectedProject:t,localBranches:I,onProjectSelect:a,onProjectsRefresh:o},t.fullPath),d==="branches"&&e.jsx(tr,{isMobile:r,isLoading:u,currentBranch:x,localBranches:I,remoteBranches:B,remoteStatus:$,isCreatingBranch:k,onSwitchBranch:H,onCreateBranch:Q,onDeleteBranch:se,onRequestConfirmation:y})]}),e.jsx(fr,{action:v,onCancel:()=>y(null),onConfirm:de=>{$e(de)}})]}):e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:e.jsx("p",{children:"Select a project to view source control"})})}export{br as default};
@@ -1 +0,0 @@
1
- import{u as j,a as F,b as y,j as I}from"./index-DFnVoqpx.js";import{r as c}from"./vendor-react-whEHfigN.js";function g(e,r,t){return{theme:e?"dark":"light",project:r?{name:r.projectId,path:r.fullPath||r.path||""}:null,session:t?{id:t.id,title:t.title||t.name||t.id}:null}}function P({pluginName:e,selectedProject:r,selectedSession:t}){const a=c.useRef(null),{isDarkMode:p}=j(),{plugins:C}=F(),x=c.useRef(g(p,r,t)),R=c.useRef(new Set),i=c.useRef(null),s=C.find(n=>n.name===e);return c.useEffect(()=>{const n=g(p,r,t);x.current=n;for(const u of R.current)try{u(n)}catch{}},[p,r,t]),c.useEffect(()=>{if(!a.current||!s?.enabled)return;let n=!0;const u=a.current,U=s?.entry??"index.js",d=R.current;return(async()=>{try{const l=`/api/plugins/${encodeURIComponent(e)}/assets/${encodeURIComponent(U)}`,o=await y(l);if(!o.ok)throw new Error(`Failed to fetch plugin (HTTP ${o.status})`);const v=await o.text(),E=new Blob([v],{type:"application/javascript"}),b=URL.createObjectURL(E),h=await import(b).finally(()=>URL.revokeObjectURL(b));if(!n||!a.current)return;i.current=h;const $={get context(){return x.current},onContextChange(f){return d.add(f),()=>d.delete(f)},async rpc(f,k,w){const T=String(k).replace(/^\//,""),m=await y(`/api/plugins/${encodeURIComponent(e)}/rpc/${T}`,{method:f||"GET",...w!==void 0?{body:JSON.stringify(w)}:{}});if(!m.ok)throw new Error(`RPC error ${m.status}`);return m.json()}};if(await h.mount?.(u,$),!n){try{h.unmount?.(u)}catch{}i.current=null;return}}catch(l){if(!n)return;if(console.error(`[Plugin:${e}] Failed to load:`,l),a.current){const o=document.createElement("div");o.style.cssText="padding:16px;font-size:13px;color:#dc2626",o.textContent=`Plugin failed to load: ${String(l)}`,a.current.replaceChildren(o)}}})(),()=>{n=!1;try{i.current?.unmount?.(u)}catch{}d.clear(),i.current=null}},[e,s?.entry,s?.enabled]),I.jsx("div",{ref:a,className:"h-full w-full overflow-auto"})}export{P as default};