@jingyi0605/codingns 0.6.0 → 0.6.5

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 (253) hide show
  1. package/bin/codingns.mjs +240 -2
  2. package/dist/public/assets/AdaptiveButlerPage-CfsUVZKl.js +3 -0
  3. package/dist/public/assets/{App-BZvapsi8.js → App-B9HcTkMT.js} +3 -3
  4. package/dist/public/assets/{BootstrapPage-gHSoa4JN.js → BootstrapPage-BgLdZEKQ.js} +1 -1
  5. package/dist/public/assets/ConversationPage-Cj8go7L0.js +4 -0
  6. package/dist/public/assets/{DesktopDetachPreviewPage-4eMRxiBW.js → DesktopDetachPreviewPage-YCBnyC58.js} +1 -1
  7. package/dist/public/assets/DesktopWindowPage-CrvndE23.js +2 -0
  8. package/dist/public/assets/FileContextPanel-CdC7GGw5.js +1 -0
  9. package/dist/public/assets/GitSidebar-z2SBinQh.js +6 -0
  10. package/dist/public/assets/MobileCreateSessionSheet-Cb2HM-y3.js +1 -0
  11. package/dist/public/assets/{MobileTopHeaderFrame-Bwv8Ovm_.js → MobileTopHeaderFrame-etF2HKlm.js} +1 -1
  12. package/dist/public/assets/MobileWorkspaceSwitcherHeader-CuGJ31kb.js +1 -0
  13. package/dist/public/assets/{RelayConnectEntryPage-D_4YL-YH.js → RelayConnectEntryPage-BB6DbGtP.js} +1 -1
  14. package/dist/public/assets/{ServerSettingsModal-CMSm3BZU.js → ServerSettingsModal-Bl1sacZg.js} +1 -1
  15. package/dist/public/assets/SessionIndexPage-NbF9gJnp.js +1 -0
  16. package/dist/public/assets/SettingsPage-DGsmQpLv.js +1 -0
  17. package/dist/public/assets/TerminalManagerPanel-BOm8Hi_v.js +1 -0
  18. package/dist/public/assets/{TerminalPage-DaooFaJ4.js → TerminalPage-B5JNFU6w.js} +19 -19
  19. package/dist/public/assets/TerminalRuntimeFallbackModal-CM3LRKOJ.js +1 -0
  20. package/dist/public/assets/{ToolFilesPage-CGxBvYG0.js → ToolFilesPage-GSqKQsj_.js} +1 -1
  21. package/dist/public/assets/ToolGitPage-BVFWMMQp.js +1 -0
  22. package/dist/public/assets/ToolProcessesPage-DZ456fYz.js +1 -0
  23. package/dist/public/assets/ToolsHomePage-DsJp0y8A.js +1 -0
  24. package/dist/public/assets/WorkbenchLandingPage-DyPei0e-.js +1 -0
  25. package/dist/public/assets/WorkbenchLayout-DlbgBT3n.js +4 -0
  26. package/dist/public/assets/WorkbenchModal-LNfB69qx.js +1 -0
  27. package/dist/public/assets/WorkbenchShellRoute-BsxumYx5.js +1 -0
  28. package/dist/public/assets/WorkbenchShellRoute-DhQo_0vu.css +1 -0
  29. package/dist/public/assets/WorkspaceDebugDetailPage-CaXj5zVI.js +1 -0
  30. package/dist/public/assets/WorkspaceDetailPage-DOexuuaw.js +1 -0
  31. package/dist/public/assets/WorkspaceHomePage-DkCHNjKD.js +1 -0
  32. package/dist/public/assets/{client-runtime-manager-BZpL17fc.js → client-runtime-manager-6OoYHXGd.js} +1 -1
  33. package/dist/public/assets/{file-tree-icon-Db5LXC8h.js → file-tree-icon-9pt1OStn.js} +1 -1
  34. package/dist/public/assets/index-BwlbvwaA.css +1 -0
  35. package/dist/public/assets/index-DSw-TkQL.js +42 -0
  36. package/dist/public/assets/legna-code-6TqgZ4Ls.png +0 -0
  37. package/dist/public/assets/{login-direct-candidate-resolver-1mxe_Oh8.js → login-direct-candidate-resolver-CLlYtBRq.js} +1 -1
  38. package/dist/public/assets/model-switch-api-C-l8-E1S.js +1 -0
  39. package/dist/public/assets/{preferences-service-DWnzl5a0.js → preferences-service-BCcfYP_d.js} +1 -1
  40. package/dist/public/assets/{relay-entry-C5_Iay0I.js → relay-entry-BmLkMKuq.js} +1 -1
  41. package/dist/public/assets/session-runtime-machine-DgtvREca.js +21 -0
  42. package/dist/public/assets/{terminal-runtime-meta-cdtWVfCm.js → terminal-runtime-meta-0h-75uRy.js} +1 -1
  43. package/dist/public/assets/useRegisteredDebugTemplates-rBVmAqh3.js +1 -0
  44. package/dist/public/index.html +2 -2
  45. package/dist/server/config/env.d.ts +2 -0
  46. package/dist/server/config/env.js +7 -0
  47. package/dist/server/config/env.js.map +1 -1
  48. package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +4 -1
  49. package/dist/server/modules/assistant-capability/assistant-capability-service.js +12 -1
  50. package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
  51. package/dist/server/modules/butler/butler-control-session-service.d.ts +4 -1
  52. package/dist/server/modules/butler/butler-control-session-service.js +17 -1
  53. package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
  54. package/dist/server/modules/butler/butler-profile-service.d.ts +3 -1
  55. package/dist/server/modules/butler/butler-profile-service.js +16 -4
  56. package/dist/server/modules/butler/butler-profile-service.js.map +1 -1
  57. package/dist/server/modules/model-switch/cc-switch-adapter.d.ts +7 -0
  58. package/dist/server/modules/model-switch/cc-switch-adapter.js +17 -0
  59. package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
  60. package/dist/server/modules/opencli/opencli-bridge-skill-service.d.ts +12 -0
  61. package/dist/server/modules/opencli/opencli-bridge-skill-service.js +124 -0
  62. package/dist/server/modules/opencli/opencli-bridge-skill-service.js.map +1 -0
  63. package/dist/server/modules/opencli/opencli-catalog-service.d.ts +50 -0
  64. package/dist/server/modules/opencli/opencli-catalog-service.js +345 -0
  65. package/dist/server/modules/opencli/opencli-catalog-service.js.map +1 -0
  66. package/dist/server/modules/opencli/opencli-controller.d.ts +13 -0
  67. package/dist/server/modules/opencli/opencli-controller.js +30 -0
  68. package/dist/server/modules/opencli/opencli-controller.js.map +1 -0
  69. package/dist/server/modules/opencli/opencli-health-service.d.ts +28 -0
  70. package/dist/server/modules/opencli/opencli-health-service.js +106 -0
  71. package/dist/server/modules/opencli/opencli-health-service.js.map +1 -0
  72. package/dist/server/modules/opencli/opencli-install-discovery.d.ts +23 -0
  73. package/dist/server/modules/opencli/opencli-install-discovery.js +130 -0
  74. package/dist/server/modules/opencli/opencli-install-discovery.js.map +1 -0
  75. package/dist/server/modules/opencli/opencli-management-service.d.ts +59 -0
  76. package/dist/server/modules/opencli/opencli-management-service.js +152 -0
  77. package/dist/server/modules/opencli/opencli-management-service.js.map +1 -0
  78. package/dist/server/modules/opencli/opencli-runtime-builder.d.ts +11 -0
  79. package/dist/server/modules/opencli/opencli-runtime-builder.js +214 -0
  80. package/dist/server/modules/opencli/opencli-runtime-builder.js.map +1 -0
  81. package/dist/server/modules/opencli/opencli-runtime-layout.d.ts +3 -0
  82. package/dist/server/modules/opencli/opencli-runtime-layout.js +11 -0
  83. package/dist/server/modules/opencli/opencli-runtime-layout.js.map +1 -0
  84. package/dist/server/modules/opencli/opencli-runtime-profile-service.d.ts +29 -0
  85. package/dist/server/modules/opencli/opencli-runtime-profile-service.js +104 -0
  86. package/dist/server/modules/opencli/opencli-runtime-profile-service.js.map +1 -0
  87. package/dist/server/modules/opencli/opencli-runtime-resolver.d.ts +29 -0
  88. package/dist/server/modules/opencli/opencli-runtime-resolver.js +110 -0
  89. package/dist/server/modules/opencli/opencli-runtime-resolver.js.map +1 -0
  90. package/dist/server/modules/opencli/opencli-session-prompt-service.d.ts +11 -0
  91. package/dist/server/modules/opencli/opencli-session-prompt-service.js +66 -0
  92. package/dist/server/modules/opencli/opencli-session-prompt-service.js.map +1 -0
  93. package/dist/server/modules/parallel-sessions/parallel-session-controller.d.ts +4 -0
  94. package/dist/server/modules/parallel-sessions/parallel-session-controller.js +7 -0
  95. package/dist/server/modules/parallel-sessions/parallel-session-controller.js.map +1 -1
  96. package/dist/server/modules/parallel-sessions/parallel-session-group-service.d.ts +6 -1
  97. package/dist/server/modules/parallel-sessions/parallel-session-group-service.js +36 -2
  98. package/dist/server/modules/parallel-sessions/parallel-session-group-service.js.map +1 -1
  99. package/dist/server/modules/provider/opencode-model-options.d.ts +1 -0
  100. package/dist/server/modules/provider/opencode-model-options.js +54 -12
  101. package/dist/server/modules/provider/opencode-model-options.js.map +1 -1
  102. package/dist/server/modules/provider/provider-catalog-service.d.ts +46 -0
  103. package/dist/server/modules/provider/provider-catalog-service.js +249 -0
  104. package/dist/server/modules/provider/provider-catalog-service.js.map +1 -0
  105. package/dist/server/modules/provider/provider-controller.d.ts +20 -2
  106. package/dist/server/modules/provider/provider-controller.js +65 -5
  107. package/dist/server/modules/provider/provider-controller.js.map +1 -1
  108. package/dist/server/modules/provider/provider-disabled.d.ts +8 -0
  109. package/dist/server/modules/provider/provider-disabled.js +45 -0
  110. package/dist/server/modules/provider/provider-disabled.js.map +1 -0
  111. package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +3 -0
  112. package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
  113. package/dist/server/modules/provider/provider-discovery-helper-process.js +4 -4
  114. package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
  115. package/dist/server/modules/provider/provider-discovery-runtime.d.ts +1 -1
  116. package/dist/server/modules/provider/provider-discovery-runtime.js +17 -9
  117. package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
  118. package/dist/server/modules/sessions/claude-compatible-provider-registry.d.ts +16 -0
  119. package/dist/server/modules/sessions/claude-compatible-provider-registry.js +91 -0
  120. package/dist/server/modules/sessions/claude-compatible-provider-registry.js.map +1 -0
  121. package/dist/server/modules/sessions/claude-runtime-helper-client.d.ts +1 -0
  122. package/dist/server/modules/sessions/claude-runtime-helper-client.js +14 -0
  123. package/dist/server/modules/sessions/claude-runtime-helper-client.js.map +1 -1
  124. package/dist/server/modules/sessions/codex-app-server-helper-client.d.ts +1 -0
  125. package/dist/server/modules/sessions/codex-app-server-helper-client.js +10 -0
  126. package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
  127. package/dist/server/modules/sessions/provider-session-delete-cli.js +2 -0
  128. package/dist/server/modules/sessions/provider-session-delete-cli.js.map +1 -1
  129. package/dist/server/modules/sessions/session-controller.d.ts +7 -0
  130. package/dist/server/modules/sessions/session-controller.js +22 -0
  131. package/dist/server/modules/sessions/session-controller.js.map +1 -1
  132. package/dist/server/modules/sessions/session-history-service.d.ts +18 -2
  133. package/dist/server/modules/sessions/session-history-service.js +330 -29
  134. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  135. package/dist/server/modules/sessions/session-live-runtime-router-service.js +9 -4
  136. package/dist/server/modules/sessions/session-live-runtime-router-service.js.map +1 -1
  137. package/dist/server/modules/sessions/session-live-runtime-service.d.ts +22 -5
  138. package/dist/server/modules/sessions/session-live-runtime-service.js +350 -122
  139. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  140. package/dist/server/modules/sessions/session-message-attachment-service.js +2 -2
  141. package/dist/server/modules/sessions/session-message-attachment-service.js.map +1 -1
  142. package/dist/server/modules/sessions/session-permission-request-service.d.ts +5 -2
  143. package/dist/server/modules/sessions/session-permission-request-service.js +26 -27
  144. package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
  145. package/dist/server/modules/sessions/session-provider-config-service.d.ts +82 -0
  146. package/dist/server/modules/sessions/session-provider-config-service.js +925 -0
  147. package/dist/server/modules/sessions/session-provider-config-service.js.map +1 -0
  148. package/dist/server/modules/sessions/session-provider-error-mapper.d.ts +2 -0
  149. package/dist/server/modules/sessions/session-provider-error-mapper.js +42 -0
  150. package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
  151. package/dist/server/modules/skills/skill-manager-service.d.ts +5 -0
  152. package/dist/server/modules/skills/skill-manager-service.js +26 -0
  153. package/dist/server/modules/skills/skill-manager-service.js.map +1 -1
  154. package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +1 -0
  155. package/dist/server/modules/tasks/task-helper-process-handlers.js +1 -1
  156. package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
  157. package/dist/server/routes/opencli.d.ts +3 -0
  158. package/dist/server/routes/opencli.js +7 -0
  159. package/dist/server/routes/opencli.js.map +1 -0
  160. package/dist/server/routes/providers.js +4 -2
  161. package/dist/server/routes/providers.js.map +1 -1
  162. package/dist/server/server/create-server.d.ts +8 -0
  163. package/dist/server/server/create-server.js +48 -12
  164. package/dist/server/server/create-server.js.map +1 -1
  165. package/dist/server/storage/repositories/opencli-catalog-entry-repository.d.ts +9 -0
  166. package/dist/server/storage/repositories/opencli-catalog-entry-repository.js +85 -0
  167. package/dist/server/storage/repositories/opencli-catalog-entry-repository.js.map +1 -0
  168. package/dist/server/storage/repositories/opencli-provider-repository.d.ts +8 -0
  169. package/dist/server/storage/repositories/opencli-provider-repository.js +88 -0
  170. package/dist/server/storage/repositories/opencli-provider-repository.js.map +1 -0
  171. package/dist/server/storage/repositories/opencli-runtime-profile-repository.d.ts +11 -0
  172. package/dist/server/storage/repositories/opencli-runtime-profile-repository.js +127 -0
  173. package/dist/server/storage/repositories/opencli-runtime-profile-repository.js.map +1 -0
  174. package/dist/server/storage/repositories/provider-control-repository.d.ts +9 -0
  175. package/dist/server/storage/repositories/provider-control-repository.js +51 -0
  176. package/dist/server/storage/repositories/provider-control-repository.js.map +1 -0
  177. package/dist/server/storage/repositories/session-binding-repository.js +44 -5
  178. package/dist/server/storage/repositories/session-binding-repository.js.map +1 -1
  179. package/dist/server/storage/repositories/session-index-repository.js +6 -0
  180. package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
  181. package/dist/server/storage/sqlite/client.js +72 -0
  182. package/dist/server/storage/sqlite/client.js.map +1 -1
  183. package/dist/server/storage/sqlite/schema.sql +71 -0
  184. package/dist/server/types/domain.d.ts +56 -0
  185. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +5 -2
  186. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +40 -8
  187. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -1
  188. package/node_modules/@codingns/session-sync-core/dist/index.d.ts +2 -0
  189. package/node_modules/@codingns/session-sync-core/dist/index.js +2 -0
  190. package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -1
  191. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +10 -1
  192. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +110 -35
  193. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
  194. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
  195. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
  196. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
  197. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +131 -39
  198. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -1
  199. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
  200. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
  201. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
  202. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +8 -1
  203. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +19 -6
  204. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -1
  205. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +1 -0
  206. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +13 -8
  207. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
  208. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +5 -1
  209. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +103 -51
  210. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
  211. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +2 -1
  212. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +41 -21
  213. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
  214. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +32 -8
  215. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -1
  216. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +15 -0
  217. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
  218. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
  219. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +167 -10
  220. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
  221. package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +2 -0
  222. package/node_modules/@codingns/session-sync-core/dist/types.d.ts +1 -1
  223. package/node_modules/@codingns/session-sync-core/dist/types.js +1 -1
  224. package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -1
  225. package/package.json +1 -1
  226. package/dist/public/assets/AdaptiveButlerPage-uFwDdN-F.js +0 -3
  227. package/dist/public/assets/ConversationPage-z3sXtKZ7.js +0 -4
  228. package/dist/public/assets/DesktopWindowPage-CZcoGApB.js +0 -2
  229. package/dist/public/assets/FileContextPanel-C3qex8bb.js +0 -1
  230. package/dist/public/assets/GitSidebar-BK6H16XU.js +0 -6
  231. package/dist/public/assets/MobileCreateSessionSheet-BYfbvK8o.js +0 -1
  232. package/dist/public/assets/MobileSheet-Ckug8hTb.js +0 -1
  233. package/dist/public/assets/MobileWorkspaceSwitcherHeader-RqWrBdn2.js +0 -1
  234. package/dist/public/assets/SessionIndexPage-DuK10DL5.js +0 -1
  235. package/dist/public/assets/SettingsPage-fyD-xaHL.js +0 -1
  236. package/dist/public/assets/TerminalManagerPanel-CCLr1Ypk.js +0 -1
  237. package/dist/public/assets/TerminalRuntimeFallbackModal-aUzjEBwP.js +0 -1
  238. package/dist/public/assets/ToolGitPage-C264yjS9.js +0 -1
  239. package/dist/public/assets/ToolProcessesPage-BOP4A1cb.js +0 -1
  240. package/dist/public/assets/ToolsHomePage-CQxGiKQA.js +0 -1
  241. package/dist/public/assets/WorkbenchLandingPage-CvAY68ca.js +0 -1
  242. package/dist/public/assets/WorkbenchLayout-DGm8Tc5M.js +0 -3
  243. package/dist/public/assets/WorkbenchModal-0tPIIhca.js +0 -1
  244. package/dist/public/assets/WorkbenchShellRoute-BF0nHWOk.css +0 -1
  245. package/dist/public/assets/WorkbenchShellRoute-DBBOsJo9.js +0 -1
  246. package/dist/public/assets/WorkspaceDebugDetailPage-CDerFYd2.js +0 -1
  247. package/dist/public/assets/WorkspaceDetailPage-BlJc1CHE.js +0 -1
  248. package/dist/public/assets/WorkspaceHomePage-BUsKJ3lv.js +0 -1
  249. package/dist/public/assets/default-session-permission-mode-DT4SGiwp.js +0 -1
  250. package/dist/public/assets/index-BZLcEHW3.js +0 -42
  251. package/dist/public/assets/index-BbspQPC2.css +0 -1
  252. package/dist/public/assets/session-runtime-machine-DdLeDqQr.js +0 -17
  253. package/dist/public/assets/useRegisteredDebugTemplates-oFAQNIqh.js +0 -1
@@ -0,0 +1 @@
1
+ import{b as c,j as n,t as r,A as Yn}from"./index-DSw-TkQL.js";import{f as Zn,e as Di,g as Ei}from"./App-B9HcTkMT.js";import{ao as ki,u as Mi,h as Ri,v as _i}from"./model-switch-api-C-l8-E1S.js";import{b4 as Ti,a_ as Jn,b as en,w as wt,b5 as Fi,u as Ai,a5 as Me,b6 as Li,b7 as yt,b8 as Ve,b9 as Bi,ba as Wi,bb as $i}from"./WorkbenchLayout-DlbgBT3n.js";import{W as Ln}from"./WorkbenchModal-LNfB69qx.js";import{a as Mt,b as Rt,F as Oi}from"./file-tree-icon-9pt1OStn.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-BmLkMKuq.js";const Hi=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),zi=["._"];function xt(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function Ui(t){const i=t.trim().toLowerCase();return i?Hi.has(i)||zi.some(l=>i.startsWith(l)):!1}function nn(t,i,l){return l?[...t]:t.filter(o=>!Ui(i(o)))}function Nt(t,i){return nn(t,l=>l.name,i)}function Vi(t,i){return i?t:Object.entries(t).reduce((l,[o,h])=>(l[o]=Nt(h,!1),l),{})}async function Zt(t,i){const[l,o]=await Promise.all([Ti(i),ki(t)]);return Ki(l.changes,o.items)}function Ki(t,i){const l=new Set(i.map(o=>Et(o.path)));return t.filter(o=>l.has(Et(o.path))||o.oldPath!==null&&l.has(Et(o.oldPath)))}function Gi(t){const i=Bn("","");for(const l of t){const o=Et(l.path),h=o.split("/").filter(Boolean);let d=i;h.forEach((b,y)=>{const C=h.slice(0,y+1).join("/");if(y===h.length-1){d.children.set(`file:${C}`,{kind:"file",name:b,path:o,change:l});return}const T=`directory:${C}`,M=d.children.get(T);if(M&&M.kind==="directory"){d=M;return}const Y=Bn(b,C);d.children.set(T,Y),d=Y})}return ei(In([...i.children.values()]))}function Qn(t,i){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return an(t)?`${l} ${i}`:l}function an(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Dt(t){return t.split("/").filter(Boolean).pop()??t}function Et(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Bn(t,i){return{kind:"directory",name:t,path:i,children:new Map}}function In(t){return[...t].sort((i,l)=>i.kind!==l.kind?i.kind==="directory"?-1:1:i.name.localeCompare(l.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:In([...i.children.values()])}:i)}function ei(t){return t.map(i=>{var b;if(i.kind!=="directory")return i;const l=ei(i.children);let o=i.name,h=i.path,d=l;for(;d.length===1&&((b=d[0])==null?void 0:b.kind)==="directory";){const y=d[0];o=`${o}/${y.name}`,h=y.path,d=y.children}return{kind:"directory",name:o,path:h,children:d}})}const Xi=450,qi=60*1e3,Wn=20,$n=16;function Yi({sessionId:t,workspaceId:i,showSystemFiles:l,selectedPath:o,refreshVersion:h,onCountChange:d,onSelectFile:b,onOpenFile:y}){const[C,T]=c.useState("tree"),[M,Y]=c.useState([]),[me,U]=c.useState(!0),[pe,be]=c.useState(!1),[V,ft]=c.useState([]),E=c.useRef(null),Tt=Jn(),{showToast:je}=Zn();c.useEffect(()=>{const m=en(gt(i,t),qi);T("tree"),Y(m??[]),U(m===null),be(!1),ft([]),E.current=null},[t,i]),c.useEffect(()=>{let m=!1;async function j(){U(!0);try{const v=await Zt(t,i);m||(Y(v),wt(gt(i,t),v))}catch(v){m||je({title:Jt(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{m||U(!1)}}return j(),()=>{m=!0}},[h,t,je,i]);async function Se(){U(!0);try{const m=await Zt(t,i);Y(m),wt(gt(i,t),m)}catch(m){je({title:Jt(m,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{U(!1)}}async function D(){if(R.length!==0){be(!0);try{await Fi(i,R.map(j=>j.path));const m=await Zt(t,i);Y(m),wt(gt(i,t),m),je({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(m){je({title:Jt(m,r("git.stageFailed")),tone:"error"})}finally{be(!1)}}}function F(m){ft(j=>j.includes(m)?j.filter(v=>v!==m):[...j,m])}function K(m){const j=Date.now(),v=E.current;return E.current={filePath:m,timestamp:j},(v==null?void 0:v.filePath)===m&&j-v.timestamp<=Xi}async function $(m,j){if(j&&K(m)){await y(m),E.current=null;return}j||(E.current=null),await b(m)}const ne=c.useMemo(()=>nn(M,m=>Dt(m.path),l),[M,l]),R=ne.filter(m=>!m.staged),Re=Gi(ne),ie=new Set(V);return c.useEffect(()=>{d==null||d(ne.length)},[d,ne.length]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"file-panel-session-toolbar",children:[n.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":r("conversation.filePanelSessionViewLabel"),children:[n.jsx("button",{className:C==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="tree",onClick:()=>T("tree"),children:r("conversation.filePanelSessionTreeView")}),n.jsx("button",{className:C==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="list",onClick:()=>T("list"),children:r("conversation.filePanelSessionListView")})]}),n.jsxs("div",{className:"file-panel-session-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Se(),disabled:me||pe,children:r("conversation.filePanelRefresh")}),n.jsx("button",{className:"primary-button",type:"button",onClick:()=>void D(),disabled:pe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),n.jsxs("div",{className:"file-panel-session-summary",children:[n.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ne.length}`}),n.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),n.jsx("div",{ref:Tt,className:"file-tree","data-scrollbar-autohide":"true",children:me?n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ne.length===0?n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):C==="tree"?ti({nodes:Re,depth:0,collapsedPathSet:ie,selectedPath:o,onToggleTreePath:F,onFileClick:$}):Zi({items:ne,selectedPath:o,onFileClick:$})})]})}function ti({nodes:t,depth:i,collapsedPathSet:l,selectedPath:o,onToggleTreePath:h,onFileClick:d}){return t.map(b=>{if(b.kind==="directory"){const y=!l.has(b.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":y,style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>h(b.path),children:[n.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:y?"v":">"}),n.jsx("span",{className:"file-tree-label",children:b.name})]}),y?n.jsx("div",{className:"file-tree-children",children:ti({nodes:b.children,depth:i+1,collapsedPathSet:l,selectedPath:o,onToggleTreePath:h,onFileClick:d})}):null]},`session-directory:${b.path}`)}return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":o===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>void d(b.change.path,!an(b.change)),children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(b.name),"aria-hidden":"true",children:Mt(b.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:b.name}),n.jsx("span",{className:"file-tree-path",children:Qn(b.change,r("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),n.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function Zi({items:t,selectedPath:i,onFileClick:l}){return t.map(o=>n.jsx("div",{className:"file-session-list-item",children:n.jsxs("button",{className:"file-session-list-button",type:"button","data-active":i===o.path,onClick:()=>void l(o.path,!an(o)),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(o.path)),"aria-hidden":"true",children:Mt(Dt(o.path))}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:Dt(o.path)}),n.jsx("span",{className:"file-tree-path",children:Qn(o,r("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":o.status,children:o.status}),n.jsx("span",{className:"file-session-badge subtle",children:o.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${o.path}`))}function gt(t,i){return`file-panel.session-changes.${t}.${i}`}function Jt(t,i){return t instanceof Yn?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??i):i}const g="",Ji=450,ee=8,Pt=4,Qi=176,Ii=120,ea=300*1e3,ta=60*1e3,On=1600,na=20,ia=16;function qa({className:t,sessionId:i,workspaceId:l,hideHeading:o=!1,hideTabs:h=!1,externalRevealRequest:d=null,externalWindowMode:b=!1,workbenchShellOverrides:y}){var Tn,Fn;const C=Ai(),{navigationGroups:T,subscribeFileTree:M,requestFileTreeRefresh:Y,addFileTreeSnapshotListener:me,subscribeGitSnapshot:U,requestGitRefresh:pe,addGitSnapshotListener:be}={...C,...y},[V,ft]=c.useState({}),[E,Tt]=c.useState([]),[je,Se]=c.useState([]),[D,F]=c.useState(g),[K,$]=c.useState([]),[ne,R]=c.useState(null),[Re,ie]=c.useState(!1),[m,j]=c.useState(!1),[v,dt]=c.useState(!1),[Ge,Xe]=c.useState(!1),[A,qe]=c.useState(""),[Ft,G]=c.useState(null),[ht,mt]=c.useState(!1),[we,Ye]=c.useState(null),[X,Ze]=c.useState("workspace"),[sn,_e]=c.useState(0),[rn,At]=c.useState(0),[Je,Z]=c.useState(!1),[Qe,L]=c.useState(!1),[ae,O]=c.useState(null),[ve,Te]=c.useState(null),[B,Fe]=c.useState(null),[P,Lt]=c.useState(null),[w,Ie]=c.useState(null),[Bt,Ae]=c.useState(""),[on,cn]=c.useState([]),[J,Wt]=c.useState(!1),[oi,ye]=c.useState(null),un=c.useId(),le=c.useRef({}),se=c.useRef({}),_=c.useRef([]),Q=c.useRef(g),et=c.useRef(!1),tt=c.useRef(null),ci=Jn(),fn=c.useRef(null),dn=c.useRef(null),$t=c.useRef(null),hn=c.useRef(null),mn=c.useRef(null),xe=c.useRef(0),re=c.useRef(new Map),{showToast:S}=Zn(),nt=Di(),I=Mi(e=>e.showSystemFiles),it=!!(i!=null&&i.trim()),pn=o&&nt.isMobile;c.useEffect(()=>{Me("file_panel.props",{sessionId:i,workspaceId:l,externalWindowMode:b})},[b,i,l]),c.useEffect(()=>{Q.current=D},[D]);function Ne(e){ft(a=>{const s=typeof e=="function"?e(a):e;return le.current=s,s})}function Le(e){Tt(a=>{const s=typeof e=="function"?e(a):e;return _.current=s,s})}c.useEffect(()=>{var f,p;if(Ut(),!l){Ut(),et.current=!1,le.current={},se.current={},_.current=[],Q.current=g,Ne({}),Le([]),Se([]),F(g),Xe(!1),qe(""),G(null),mt(!1),ie(!1),Wt(!1),ye(null),$([]),R(null),O(null),Te(null),Fe(null),Ie(null),Ae("");return}et.current=!0;const e=en(Kn(l),ea);Me("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((p=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:p.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Pa((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),s=Vn((e==null?void 0:e.expandedDirectories)??[],a),u=St((e==null?void 0:e.treeCache)??{},a,s);le.current=u,se.current=Gn((e==null?void 0:e.treeRevisionByPath)??{},u),_.current=s,Q.current=a,Ne(u),Le(s),Se([]),F(a),ie(!1),j(!1),Xe(!1),qe(""),G(null),mt(!1),queueMicrotask(()=>{et.current=!1})},[l]),c.useEffect(()=>{if(!d||d.workspaceId!==l)return;const e=()=>{if(mn.current===d.requestId)return;mn.current=d.requestId,Ze("workspace"),(d.openViewer?He(d.filePath):ce(d.filePath)).catch(s=>{S({title:te(s,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(et.current){queueMicrotask(e);return}e()},[d,He,ce,S,l]),c.useEffect(()=>{if(l)return me(e=>{e.workspaceId===l&&(se.current={...se.current,[e.path]:typeof e.revision=="string"?e.revision:null},Ne(a=>({...a,[e.path]:e.items})),e.path===g&&ie(!1),Se(a=>a.filter(s=>s!==e.path)),di(e.path,e.items))})},[me,l]),c.useEffect(()=>()=>{Ut()},[]),c.useEffect(()=>{l&&M(l,It(_.current,Q.current),{knownRevisionByPath:se.current})},[D,E,M,l]),c.useEffect(()=>{$([]),R(null),Ye(null),ye(null),_e(0),Z(!1),L(!1),O(null),Te(null),Fe(null),Ie(null),Ae(""),tt.current=null,xe.current+=1},[i]),c.useEffect(()=>{!it&&X==="session"&&Ze("workspace")},[X,it]),c.useEffect(()=>{h&&X!=="workspace"&&Ze("workspace")},[X,h]),c.useEffect(()=>{if(!Je&&!Qe&&!ae)return;function e(s){var x,N,fe;if(!(s.target instanceof Node))return;const u=((x=fn.current)==null?void 0:x.contains(s.target))??!1,f=((N=dn.current)==null?void 0:N.contains(s.target))??!1,p=((fe=$t.current)==null?void 0:fe.contains(s.target))??!1;!u&&!f&&!p&&(Z(!1),L(!1),O(null),Te(null))}function a(s){s.key==="Escape"&&(Z(!1),L(!1),O(null),Te(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Je,Qe,ae]),c.useLayoutEffect(()=>{if(!ae||typeof window>"u"){Te(null);return}const e=ae;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Te(fa({x:e.positionX,y:e.positionY},{width:f.width||Qi,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const s=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[ae]),c.useEffect(()=>{if(!l)return;const e=Vn(E,D),a=St(V,D,e);wt(Kn(l),{treeCache:a,treeRevisionByPath:Gn(se.current,a),expandedDirectories:e,activeDirectoryPath:D})},[D,E,V,l]),c.useEffect(()=>{if(et.current)return;const e=St(V,D,E);ja(V,e)||Ne(e)},[D,E,V]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function s(f){if(!a)return;const p=Nt(le.current[g]??[],I),x=(f==null?void 0:f.silent)!==!0&&p.length===0;x&&ie(!0),Me("file_panel.load_root_tree.start",{sessionId:i,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:p.length});try{const N=await zt(g,{force:!0});e||(Me("file_panel.load_root_tree.end",{sessionId:i,workspaceId:a,itemCount:N.length}),Ne(fe=>({...St(fe,Q.current,_.current),[g]:N})))}catch(N){!e&&!Xn(N)&&S({title:te(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&ie(!1)}}if(Nt(le.current[g]??[],I).length>0){const f=window.setTimeout(()=>{a&&(M(a,It(_.current,Q.current),{knownRevisionByPath:se.current}),s({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return s(),()=>{e=!0}},[i,I,S,l]),c.useEffect(()=>{if(!l||!i){At(0);return}const e=en(Sa(l,i),ta);Me("file_panel.session_change_count.snapshot",{sessionId:i,workspaceId:l,cached:e!==null,cachedCount:e}),At(e??0)},[i,sn,l]),c.useEffect(()=>{if(!l){cn([]);return}const e=l.trim();U(e),pe(e)},[l,U,pe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return be(a=>{var s;a.workspaceId===e&&cn(((s=a.status)==null?void 0:s.changes)??[])})},[be,l]);const pt=c.useMemo(()=>nn(on,e=>xt(e.path),I),[on,I]),W=c.useMemo(()=>{const e=new Map,a=new Set;for(const s of pt){const u=s.path.replace(/\\/g,"/"),f=s.worktreeStatus??s.stagedStatus??s.status;e.set(u,f);const p=u.split("/");for(let x=1;x<p.length;x++)a.add(p.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[pt]),De=c.useMemo(()=>Vi(V,I),[I,V]),Ee=c.useMemo(()=>Ft===null?null:Nt(Ft,I),[Ft,I]),Be=De[g]??[],oe=Ge&&Ee!==null,bt=c.useMemo(()=>J?tn(Be,De,W.statusByPath,W.changedDirs):Be,[W.changedDirs,W.statusByPath,Be,J,De]),ui=c.useMemo(()=>oe?(Ee??[]).map(e=>z(e.path,e.kind)):ni(bt,De,E,J,W.statusByPath,W.changedDirs),[E,W.changedDirs,W.statusByPath,oe,J,Ee,De,bt]),We=((Tn=T.find(e=>e.workspace.id===l))==null?void 0:Tn.workspace)??null,k=Un(K),Ot=(k==null?void 0:k.path)??null,ge=(k==null?void 0:k.kind)==="file"?k.path:null,vt=c.useMemo(()=>new Set(K.map(e=>e.path)),[K]),at=c.useMemo(()=>jt(K),[K]),Ht=!!(We!=null&&We.path&&K.length===1&&Ot),bn=K.length===1&&(k==null?void 0:k.kind)==="file",vn=at.length>0,ke=at.length>0,lt=!!(P!=null&&P.items.length&&l),yn=!!l&&K.length===1&&k!==null,xn=!!((ge?he(ge):D)&&E.length),gn=P?P.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:P.items.length}):r("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,H=w?pa(w):null;async function Pn(e,a=!1){if(!l)return[];if(!a){const s=le.current[e];if(s)return s}e===g?ie(!0):Se(s=>kt(s,e));try{const s=await zt(e,{force:a});return Ne(u=>({...u,[e]:s})),s}catch(s){throw Xn(s)||S({title:te(s,r("conversation.filePanelLoadFailed")),tone:"error"}),s}finally{e===g?ie(!1):Se(s=>s.filter(u=>u!==e))}}async function Pe(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??Q.current,s=(e==null?void 0:e.expandedDirectories)??_.current,u=Ca(le.current,a,s);Me("file_panel.refresh_tree_cache.start",{sessionId:i,workspaceId:l,targetDirectories:u});const p=(await Promise.all(u.map(async x=>{const N=await zt(x,{force:!0});return[x,N]}))).reduce((x,[N,fe])=>(x[N]=fe,x),{});Me("file_panel.refresh_tree_cache.end",{sessionId:i,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(p).length}),Ne(p)}async function zt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const u=le.current[e];if(u)return u}const s=It(kt(_.current,e),e||Q.current);return M(l,s,{knownRevisionByPath:se.current}),Y(l,[e],{knownRevisionByPath:se.current}),fi(e,On,{allowCached:(a==null?void 0:a.force)!==!0})}function fi(e,a=On,s){const u=le.current[e];return(s==null?void 0:s.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,p)=>{const x=window.setTimeout(()=>{hi(e,x),p(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=re.current.get(e)??[];re.current.set(e,[...N,{resolve:f,reject:p,timerId:x}])})}function di(e,a){const s=re.current.get(e)??[];s.length!==0&&(re.current.delete(e),s.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function hi(e,a){const u=(re.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){re.current.delete(e);return}re.current.set(e,u)}function Ut(){for(const[e,a]of re.current.entries())a.forEach(s=>{window.clearTimeout(s.timerId),s.reject(new Error(`FILE_TREE_ABORTED:${e}`))});re.current.clear()}function $e(e){$([e]),R(e.path)}function st(e){F(e.kind==="directory"?e.path:he(e.path))}function mi(e){const a=sa(ui,ne,e);$(a),R(e.path),st(e)}function pi(e){const a=la(K,e),s=Un(a);$(a),R(e.path),s&&st(s)}function Cn(e){$e(e),st(e)}function Oe(e,a){if(a!=null&&a.shiftKey){mi(e);return}if(Ct(a)){pi(e);return}Cn(e)}async function rt(e,a=!1){const s=ut(e,a);if(!s.length){F(g);return}Le(u=>si(u,s)),F(s[s.length-1]??g);for(const u of s)try{await Pn(u)}catch{return}}async function ce(e){const a=z(e,"file");$e(a),st(a),await rt(e)}async function He(e){Ye(e),ye(null),tt.current=null,xe.current+=1,ce(e);const a=xe.current,s=e.replace(/\\/g,"/"),u=W.statusByPath.get(s);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Li(l,e,!1);xe.current===a&&ye(f.content||null)}catch{xe.current===a&&ye(null)}}function jn(e){const a=Date.now(),s=tt.current;return tt.current={filePath:e,timestamp:a},(s==null?void 0:s.filePath)===e&&a-s.timestamp<=Ji}function Ce(){tt.current=null}async function bi(e,a){const s=z(e,"file");if(a!=null&&a.shiftKey||Ct(a)){Ce(),Oe(s,a);return}if(jn(e)){await He(e);return}Oe(s,a),await rt(e)}function Sn(){Xe(!1),qe(""),G(null),Ce()}async function vi(e,a){const s=z(e.path,e.kind);if(a!=null&&a.shiftKey||Ct(a)){Ce(),Oe(s,a);return}if(e.kind==="directory"){Sn(),Oe(s,a),await wn(e.path);return}if(jn(e.path)){Sn(),await He(e.path);return}await ce(e.path)}async function wn(e){if($e(z(e,"directory")),F(e),!_.current.includes(e))try{await Pn(e),Le(a=>kt(a,e))}catch{}}async function Nn(e){if($e(z(e,"directory")),F(e),_.current.includes(e)){Dn(e);return}await wn(e)}function Dn(e){Le(a=>a.filter(s=>s!==e&&!s.startsWith(`${e}/`))),F(he(e)),$([]),R(null)}async function En(){if(!l)return;const e=l;try{if(pe(e),await Pe(),ge&&await rt(ge),oe&&A.trim()){const a=await Ve(e,A.trim());G(a.items)}}catch(a){S({title:te(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function yi(e){if(e==null||e.preventDefault(),!l||!A.trim()){G(null);return}mt(!0);try{const a=await Ve(l,A.trim());G(a.items)}catch(a){S({title:te(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{mt(!1)}}function kn(){if(Ge){Xe(!1),qe(""),G(null);return}Xe(!0)}function q(e){L(!1),e()}function Mn(){var e;(e=hn.current)==null||e.click()}async function xi(e){var p;const a=((p=e.target.files)==null?void 0:p[0])??null;if(e.target.value="",!a||!l)return;const s=aa(a.name);if(!s){S({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Hn(D,k),f=zn(u,s);dt(!0);try{const x=await ba(a);await Bi({workspaceId:l,path:f,contentBase64:x}),await Pe(),await ce(f),S({title:r("conversation.filePanelUploadSuccess",{name:s}),tone:"success"})}catch(x){S({title:te(x,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{dt(!1)}}async function Vt(e=ge){if(!(!l||!e)){dt(!0);try{const a=await Wi(l,e),s=va(a.contentBase64);ya(a.fileName,new Blob([s],{type:"application/octet-stream"})),S({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){S({title:te(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{dt(!1)}}}function Rn(){const e=ge?he(ge):D;!e||!_.current.includes(e)||Dn(e)}function Kt(){Ie(null),Ae("")}function Gt(){m||Kt()}function ze(e,a=Hn(D,k)){if(!l)return;const s=a,u=s?`${s}/`:"";Z(!1),L(!1),O(null),Ie({mode:e,baseDirectory:s}),Ae(u)}function Xt(e=k){!l||!e||(Z(!1),L(!1),O(null),Ie({mode:"rename",target:e}),Ae(e.path))}async function gi(e){if(e==null||e.preventDefault(),!l||!w)return;const a=(Bt??"").trim();if(a){if(w.mode==="rename"&&Ke(w.target.path)===Ke(a)){Gt();return}j(!0);try{if(w.mode==="rename"){const s=w.target.path,u=z(a,w.target.kind),f=we?li(we,s,a):null;if(await yt({workspaceId:l,opType:"rename",srcPath:s,dstPath:a}),P&&Lt({...P,items:ma(P.items,s,a)}),Kt(),Ce(),await Pe(),w.target.kind==="directory"?(await rt(a,!0),$e(u),F(a)):await ce(a),f!==we&&(xe.current+=1,Ye(f),ye(null)),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:r("conversation.filePanelRenameSuccess",{name:xt(a)||a}),tone:"success"});return}if(await yt({workspaceId:l,opType:w.mode,dstPath:a,content:w.mode==="create_file"?"":void 0}),Kt(),await Pe(),w.mode==="create_directory"?(await rt(a,!0),$e(z(a,"directory")),F(a)):await ce(a),oe&&A.trim()){const s=await Ve(l,A.trim());G(s.items)}_e(s=>s+1)}catch(s){S({title:te(s,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}}function ue(e,a=at){var u;if(a.length===0)return;const s=jt(a);Lt({mode:e,items:s}),$(s),R(((u=s[s.length-1])==null?void 0:u.path)??null),S({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:s.length}):r("conversation.filePanelCutSelectionSuccess",{count:s.length}),tone:"success"}),O(null)}async function ot(e=ca(k,D)){if(!l||!P||!P.items.length)return;const a=e??g,s=P.items.map(u=>({source:u,destinationPath:zn(a,xt(u.path)||u.path)}));j(!0);try{for(const p of s)P.mode==="cut"&&Ke(p.source.path)===Ke(p.destinationPath)||await yt({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:p.source.path,dstPath:p.destinationPath});const u=s.map(p=>z(p.destinationPath,p.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Lt(null),$(u),R((f==null?void 0:f.path)??null),f&&st(f),Ce(),await Pe({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?he(f.path):Q.current,expandedDirectories:_.current}),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),O(null)}catch(u){await Pe().catch(()=>{}),S({title:te(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{j(!1)}}function qt(e=at){!e.length||m||(Fe(jt(e)),O(null))}async function Pi(){var a,s;if(!l||!(B!=null&&B.length))return;const e=jt(B);j(!0);try{for(const p of e)await yt({workspaceId:l,opType:"delete",srcPath:p.path});const u=ua(D,e),f=_.current.filter(p=>!e.some(x=>x.kind==="directory"&&_t(x.path,p)));if(we&&e.some(p=>_t(p.path,we))&&(xe.current+=1,Ye(null),ye(null)),Fe(null),$([]),R(null),Q.current=u,_.current=f,F(u),Le(f),Ce(),await Pe({activeDirectoryPath:u,expandedDirectories:f}),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:xt(((a=e[0])==null?void 0:a.path)??"")||((s=e[0])==null?void 0:s.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){S({title:te(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}async function Ue(e,a=k){const s=(We==null?void 0:We.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!s){Z(!1);return}try{const f=ha(s),p=e==="absolute"?da(s,u,f):Ke(u,f);await xa(p,nt),S({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){S({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Z(!1),O(null)}}function Ci(e,a,s){return[{id:`open-${e.path}`,label:e.kind==="directory"?E.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Nn(e.path);return}He(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Vt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||m||v,onSelect:()=>{ze("create_file",s)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||m||v,onSelect:()=>{ze("create_directory",s)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||m||v,onSelect:()=>Xt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>ue("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>ue("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{ot(s)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ue("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ue("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||m||v,onSelect:()=>qt(a)}]}async function _n(e,a){if(nt.isMobile)return;e.preventDefault();const s=z(a.path,a.kind),u=vt.has(s.path)?at:[s],f=s.kind==="directory"?s.path:he(s.path);vt.has(s.path)||Cn(s);const p=Ci(s,u,f);if(nt.isDesktop){await $i(p);return}nt.isWeb&&(Z(!1),L(!1),O({positionX:e.clientX,positionY:e.clientY,items:p}))}c.useEffect(()=>{if(X!=="workspace")return;function e(a){if(!ra(a)||a.altKey||a.shiftKey||oa(a.target))return;const s=a.key.toLowerCase();if(s==="c"&&ke){a.preventDefault(),ue("copy");return}if(s==="x"&&ke){a.preventDefault(),ue("cut");return}s==="v"&&lt&&(a.preventDefault(),ot())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[X,ke,lt,ue,ot]);function Yt(e,a){return n.jsx(n.Fragment,{children:e.map(s=>{const u=z(s.path,s.kind),f=s.kind==="directory",p=f&&E.includes(s.path),x=f&&je.includes(s.path),N=De[s.path]??[],fe=J?tn(N,De,W.statusByPath,W.changedDirs):N,Si=vt.has(s.path),wi=Ot===s.path,ct=W.statusByPath.get(s.path.replace(/\\/g,"/")),An=f&&W.changedDirs.has(s.path.replace(/\\/g,"/")),Ni=(P==null?void 0:P.mode)==="cut"&&P.items.some(de=>de.path===s.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-active":wi,"data-selected":Si,"data-cut-pending":Ni||void 0,"data-kind":s.kind,"aria-expanded":f?p:void 0,style:{paddingInlineStart:`${na+a*ia}px`},onClick:de=>{if(f){if(de.shiftKey||Ct(de)){Ce(),Oe(u,de);return}Ce(),Oe(u,de),Nn(s.path);return}bi(s.path,de)},onContextMenu:de=>{_n(de,s)},children:[n.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:p?"v":">"}),f?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(s.name),"aria-hidden":"true",children:Mt(s.name)}),n.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":An||void 0,children:s.name}),!f&&ct?n.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&An?n.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,x?n.jsx("span",{className:"file-tree-meta",children:r("common.loading")}):null]}),f&&p?n.jsx("div",{className:"file-tree-children",children:x&&!N.length?n.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):fe.length?Yt(fe,a+1):n.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${s.kind}-${s.path}`)})})}function ji(e){return n.jsx(n.Fragment,{children:e.map(a=>{const s=a.kind==="directory",u=vt.has(a.path),f=Ot===a.path;return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:p=>{vi(a,p)},onContextMenu:p=>{_n(p,a)},children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),s?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(a.name),"aria-hidden":"true",children:Mt(a.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:a.name}),n.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return n.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?n.jsxs(n.Fragment,{children:[n.jsx(Oi,{workspaceId:l,filePath:we,open:we!==null,onClose:()=>{xe.current+=1,Ye(null),ye(null)},onSaved:async e=>{await Pe(),await ce(e),_e(a=>a+1)},diffContent:oi}),o?null:n.jsx("div",{className:"file-panel-heading-row",children:n.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),h?null:n.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[n.jsx("button",{className:X==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":X==="workspace",onClick:()=>Ze("workspace"),children:r("conversation.filePanelWorkspaceTab")}),n.jsxs("button",{className:X==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":X==="session",onClick:()=>{it&&Ze("session")},disabled:!it,children:[r("conversation.filePanelSessionTab"),n.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${rn}`,children:rn})]})]}),X==="workspace"?n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:hn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void xi(e)}),pn?n.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("conversation.filePanelTitle"),children:n.jsxs("div",{className:"file-mobile-action-shell",ref:dn,children:[n.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Qe,"data-active":Qe,onClick:()=>{Z(!1),L(e=>!e)},children:[n.jsx("span",{children:r("conversation.filePanelActionsMenu")}),n.jsx(Ba,{})]}),Qe?n.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ue("copy")),disabled:!ke,children:r("conversation.filePanelCopy")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ue("cut")),disabled:!ke,children:r("conversation.filePanelCut")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ot()),disabled:!lt||m||v,children:r("conversation.filePanelPaste")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),kn()},children:Ge?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Wt(e=>!e)},disabled:pt.length===0,children:J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(En),disabled:Re||m||ht,children:r("conversation.filePanelRefresh")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Rn()},disabled:!xn,children:r("conversation.filePanelCollapseCurrent")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Mn()},disabled:m||v,children:r("conversation.filePanelUpload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(Vt),disabled:!bn||v,children:r("conversation.filePanelDownload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(Xt),disabled:!yn||m||v,children:r("conversation.filePanelRenameMove")}),n.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>q(qt),disabled:!vn||m||v,children:r("conversation.filePanelDelete")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ze("create_file")),disabled:m||v,children:r("conversation.filePanelNewFile")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ze("create_directory")),disabled:m||v,children:r("conversation.filePanelNewDirectory")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>Ue("absolute")),disabled:!Ht,children:r("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>Ue("relative")),disabled:!Ht,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):n.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>ue("copy"),disabled:!ke,children:n.jsx(Ea,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>ue("cut"),disabled:!ke,children:n.jsx(ka,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void ot(),disabled:!lt||m||v,children:n.jsx(Ma,{})}),n.jsxs("div",{className:"file-toolbar-menu-shell",ref:fn,children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Je,"data-active":Je,onClick:()=>{L(!1),Z(e=>!e)},disabled:!Ht,children:n.jsx(Da,{})}),Je?n.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ue("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ue("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:Rn,disabled:!xn,children:n.jsx(wa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void En(),disabled:Re||m||ht,children:n.jsx(Na,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Ge,onClick:kn,disabled:Re,children:n.jsx(qn,{})}),pt.length>0?n.jsx("button",{className:"file-toolbar-button",type:"button",title:J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":J,onClick:()=>Wt(e=>!e),children:n.jsx(Wa,{})}):null,n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:Mn,disabled:m||v,children:n.jsx(_a,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Vt(),disabled:!bn||v,children:n.jsx(Ta,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>Xt(),disabled:!yn||m||v,children:n.jsx(La,{})}),n.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>qt(),disabled:!vn||m||v,children:n.jsx(Fa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void ze("create_file"),disabled:m||v,children:n.jsx(Ra,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void ze("create_directory"),disabled:m||v,children:n.jsx(Aa,{})})]}),ae&&typeof document<"u"?Ei.createPortal(n.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(ve==null?void 0:ve.left)??Math.max(8,ae.positionX)}px`,top:`${(ve==null?void 0:ve.top)??Math.max(8,ae.positionY)}px`,maxHeight:ve?`${ve.maxHeight}px`:void 0},children:ae.items.map(e=>n.jsx("button",{className:["file-web-context-menu-item",e.label===r("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{O(null),e.onSelect()},children:e.label},e.id))}),document.body):null,gn?n.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:gn}):null,Ge?n.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void yi(e),children:[n.jsx("input",{value:A,onChange:e=>qe(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),pn?n.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:ht,children:r("conversation.filePanelSearchButton")}):n.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:ht,children:n.jsx(qn,{})})]}):null,n.jsx("div",{ref:ci,className:"file-tree","data-search-mode":oe,"data-scrollbar-autohide":"true",children:Re&&Be.length===0?n.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):oe?Ee!=null&&Ee.length?ji(Ee):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):J?bt.length?Yt(bt,0):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):Be.length?Yt(Be,0):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),n.jsx(Ln,{open:w!==null,title:(H==null?void 0:H.title)??"",description:H==null?void 0:H.description,onClose:Gt,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void gi(e),children:[n.jsx(Ri,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:un,description:(w==null?void 0:w.mode)==="rename"?w.target.path:(w==null?void 0:w.baseDirectory)||void 0,children:n.jsx("input",{id:un,type:"text",value:Bt??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>Ae(e.target.value)})}),n.jsxs(_i,{children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:m,onClick:Gt,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:m||!(Bt??"").trim(),children:m?(H==null?void 0:H.pendingLabel)??r("common.loading"):(H==null?void 0:H.submitLabel)??r("common.save")})]})]})}),n.jsxs(Ln,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{m||Fe(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Fn=B[0])==null?void 0:Fn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:m,onClick:()=>Fe(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:m,onClick:()=>{Pi()},children:m?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):it&&i?n.jsx(Yi,{sessionId:i,workspaceId:l,showSystemFiles:I,selectedPath:ge,refreshVersion:sn,onCountChange:At,onSelectFile:ce,onOpenFile:He}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function he(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function ut(t,i=!1){const l=t.split("/").filter(Boolean),o=i?l.length:l.length-1,h=[];for(let d=0;d<o;d+=1)h.push(l.slice(0,d+1).join("/"));return h}function Hn(t,i){return t||((i==null?void 0:i.kind)==="directory"?i.path:i!=null&&i.path?he(i.path):g)}function zn(t,i){return t?`${t}/${i}`:i}function aa(t){var i;return((i=t.split(/[/\\]/).pop())==null?void 0:i.trim())??""}function z(t,i){return{path:t,kind:i}}function Un(t){return t[t.length-1]??null}function la(t,i){return t.findIndex(o=>o.path===i.path)>=0?t.filter(o=>o.path!==i.path):[...t,i]}function sa(t,i,l){const o=t.findIndex(y=>y.path===l.path);if(o<0)return[l];const h=i?t.findIndex(y=>y.path===i):o;if(h<0)return[l];const d=Math.min(h,o),b=Math.max(h,o);return t.slice(d,b+1)}function Ct(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ra(t){return t.ctrlKey||t.metaKey}function oa(t){if(!(t instanceof HTMLElement))return!1;const i=t.tagName.toLowerCase();return i==="input"||i==="textarea"||i==="select"||t.isContentEditable}function jt(t){const i=[...new Map(t.map(o=>[o.path,o])).values()].sort((o,h)=>o.path.localeCompare(h.path)),l=[];for(const o of i)l.some(h=>h.kind==="directory"&&_t(h.path,o.path))||l.push(o);return l}function ca(t,i){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?he(t.path):i}function ua(t,i){let l=t;for(;l&&i.some(o=>o.kind==="directory"&&_t(o.path,l));)l=he(l);return l}function ni(t,i,l,o,h,d){const b=[];for(const y of t){if(b.push(z(y.path,y.kind)),y.kind!=="directory"||!l.includes(y.path))continue;const C=i[y.path]??[],T=o?tn(C,i,h,d):C;b.push(...ni(T,i,l,o,h,d))}return b}function fa(t,i,l){const o=Math.max(0,l.width),h=Math.max(0,l.height),d=Math.max(0,h-ee*2),b=Math.max(0,o-ee*2),y=Math.min(Math.max(i.width,0),b),C=Math.max(0,h-t.y-Pt-ee),T=Math.max(0,t.y-Pt-ee),M=C<i.height&&T>C,me=Qt(Math.max(M?T:C,Ii),0,d),U=Math.min(Math.max(i.height,0),me),pe=M?t.y-Pt-U:t.y+Pt,be=Math.max(ee,h-ee-U),V=Math.max(ee,o-ee-y);return{top:Qt(pe,ee,be),left:Qt(t.x,ee,V),maxHeight:Math.max(0,me)}}function Qt(t,i,l){return!Number.isFinite(t)||l<i?i:Math.min(Math.max(t,i),l)}function Ke(t,i="posix"){return t?ii(t,i):"."}function da(t,i,l){const o=ii(t,l),h=Ke(i,l).replace(/^\.[/\\]?/,"");if(!h)return o;const d=ai(l),b=h.replace(/^[/\\]+/,"");return b?o.endsWith("/")||o.endsWith("\\")?`${o}${b}`:`${o}${d}${b}`:o}function ha(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ii(t,i){return t&&(ai(i)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function ai(t){return t==="windows"?"\\":"/"}function _t(t,i){return i===t||i.startsWith(`${t}/`)}function li(t,i,l){return t===i?l:t.startsWith(`${i}/`)?`${l}${t.slice(i.length)}`:t}function ma(t,i,l){return t.map(o=>({...o,path:li(o.path,i,l)}))}function pa(t){return t.mode==="create_file"?{title:r("conversation.filePanelNewFile"),description:r("conversation.filePanelCreateFileDescription"),submitLabel:r("conversation.filePanelCreateFileSubmit"),pendingLabel:r("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:r("conversation.filePanelNewDirectory"),description:r("conversation.filePanelCreateDirectoryDescription"),submitLabel:r("conversation.filePanelCreateDirectorySubmit"),pendingLabel:r("conversation.filePanelCreatingDirectory")}:{title:r("conversation.filePanelRenameMove"),description:r("conversation.filePanelRenameDescription"),submitLabel:r("conversation.filePanelRenameSubmit"),pendingLabel:r("conversation.filePanelRenaming")}}async function ba(t){const i=await t.arrayBuffer(),l=new Uint8Array(i),o=32768;let h="";for(let d=0;d<l.length;d+=o){const b=l.subarray(d,d+o);h+=String.fromCharCode(...b)}return btoa(h)}function va(t){const i=atob(t),l=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)l[o]=i.charCodeAt(o);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function ya(t,i){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(i),o=document.createElement("a");o.href=l,o.download=t,document.body.append(o),o.click(),o.remove(),window.URL.revokeObjectURL(l)}async function xa(t,i){var l;if(!(i.isDesktop&&(await i.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!ga(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function ga(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=t,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function Pa(t,i){return t&&ut(t,!0).every(h=>h in i)?t:g}function Vn(t,i){if(!i)return[];const l=ut(i,!0);return t.filter(o=>l.includes(o))}function St(t,i,l){const o=ln(i,l);return Object.entries(t).reduce((h,[d,b])=>(o.has(d)&&(h[d]=b),h),{})}function Ca(t,i,l){const h=[...ln(i,l)].filter(d=>d===g||d in t);return h.length?h:[g]}function ln(t,i){const l=new Set([g]),o=si(i,ut(t,!0));for(const h of o){l.add(h);for(const d of ut(h,!0))l.add(d)}return l}function ja(t,i){const l=Object.keys(t),o=Object.keys(i);return l.length!==o.length?!1:l.every(h=>t[h]===i[h])}function kt(t,i){return t.includes(i)?t:[...t,i]}function si(t,i){return i.reduce((l,o)=>kt(l,o),t)}function Kn(t){return`file-panel.workspace-tree.${t}`}function Sa(t,i){return`file-panel.session-change-count.${t}.${i}`}function Gn(t,i){return Object.fromEntries(Object.keys(i).map(l=>[l,t[l]??null]))}function It(t,i){return[...ln(i,t)]}function te(t,i){return t instanceof Yn?t.message:i}function Xn(t){return t instanceof Error&&(t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")||t.message.startsWith("FILE_TREE_ABORTED:"))}function wa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function Na(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function qn(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function Da(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ea(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ka(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function Ma(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ra(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function _a(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ta(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Fa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Aa(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function La(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ba(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function Wa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function tn(t,i,l,o){const h=[];for(const d of t){const b=d.path.replace(/\\/g,"/");d.kind==="file"?l.has(b)&&h.push(d):ri(b,i,l,o)&&h.push(d)}return h}function ri(t,i,l,o,h){const d=h??new Set;if(d.has(t))return!1;d.add(t);const b=i[t];if(!b)return o.has(t);for(const y of b){const C=y.path.replace(/\\/g,"/");if(y.kind==="file"){if(l.has(C))return!0}else if(ri(C,i,l,o,d))return!0}return!1}export{qa as FileContextPanel};
@@ -0,0 +1,6 @@
1
+ import{b as l,t as n,j as e,A as Bn}from"./index-DSw-TkQL.js";import{u as Ri,e as wi,f as Ai,g as jn}from"./App-B9HcTkMT.js";import{u as Pi,a5 as st,b as Cn,bc as Nn,w as Di,bd as Li,be as _i,b4 as Fi,bf as vn,bg as Oi,bh as Sn,bi as ki,b6 as Gi,bj as $i,b5 as Bi,bk as Ui,a_ as Un,bl as Vi,bb as Wi,bm as Tn,_ as zi,c as Ki,bn as Ii,bo as Xi}from"./WorkbenchLayout-DlbgBT3n.js";import{S as qi,y as Yi,z as Zi,e as Ji}from"./model-switch-api-C-l8-E1S.js";import{F as Qi,a as Ft,b as Ot}from"./file-tree-icon-9pt1OStn.js";import{W as Oe}from"./WorkbenchModal-LNfB69qx.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-BmLkMKuq.js";const Rt=56,Mn=28,wt=72,at=8,En=960,Hn=60*1e3,Rn=20,wn=9,An=9,At=68,F=12,rt=8,kt=260,es=120,Pt=6e4,ot={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function Ms({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:h=!1,workbenchShellOverrides:d}){const j=Ri(),f=wi(),x=Pi(),{subscribeGitSnapshot:b,requestGitRefresh:v,addGitSnapshotListener:E,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:p}={...x,...d},[r,m]=l.useState(null),[y,R]=l.useState(null),[C,M]=l.useState([]),[_,w]=l.useState(0),[I,ie]=l.useState(null),[he,ct]=l.useState(!1),[$,ge]=l.useState(null),[se,X]=l.useState(null),[fe,pe]=l.useState(""),[$e,B]=l.useState(!1),[N,A]=l.useState(!1),[Zn,Vt]=l.useState([]),[ee,Wt]=l.useState(!0),[te,W]=l.useState(!1),[O,Jn]=l.useState(()=>typeof window<"u"?window.innerWidth<=En:!1),[ut,U]=l.useState([]),[be,z]=l.useState(null),[xe,ae]=l.useState("unstaged"),[ye,q]=l.useState(null),[re,Y]=l.useState(null),[Qn,dt]=l.useState(!1),[ei,mt]=l.useState(null),[ti,Be]=l.useState(!1),[zt,Ue]=l.useState(null),[D,je]=l.useState(null),[Kt,Ce]=l.useState(null),[ni,Ne]=l.useState(!1),[ve,oe]=l.useState(null),[ne,ht]=l.useState(!1),[ii,Se]=l.useState(!1),[si,It]=l.useState([]),[ps,Xt]=l.useState(!1),[Ve,gt]=l.useState(new Set),[ai,Te]=l.useState(new Map),[We,qt]=l.useState(null),[ri,Me]=l.useState(!1),[P,Z]=l.useState(ot),[Yt,ze]=l.useState("generic"),[Zt,Ke]=l.useState(null),[k,ft]=l.useState(null),[G,pt]=l.useState(null),[Jt,Qt]=l.useState(Rt),[bt,xt]=l.useState(!1),[en,Ee]=l.useState(null),[oi,He]=l.useState(null),tn=l.useRef(null),nn=l.useRef(null),sn=l.useRef(null),an=l.useRef(null),rn=l.useRef(null),on=l.useRef(null),yt=l.useRef(null),Re=l.useRef(new Map),Ie=l.useRef(new Map),we=l.useRef(0),ln=l.useRef(u),cn=l.useRef(u),Xe=l.useRef(null),{showToast:H}=Ai(),un=f.isDesktop&&!O;l.useEffect(()=>{st("git_sidebar.props",{workspaceId:i,externalWindowMode:h})},[h,i]),l.useEffect(()=>{cn.current=u},[u]),l.useEffect(()=>{Vt([]),Wt(!0),w(0),ie(null),ct(!1),X(null),pe(""),W(!1),U([]),z(null),ae("unstaged"),q(null),Y(null),dt(!1),mt(null),Be(!1),Ue(null),je(null),Ce(null),Ne(!1),oe(null),ht(!1),Se(!1),It([]),gt(new Set),Te(new Map),qt(null),Me(!1),Z(ot),ze("generic"),Ke(null),ft(null),pt(null),xt(!1),Qt(Rt),Ee(null),He(null),Ie.current.clear(),Re.current.clear()},[i]),l.useEffect(()=>{function t(){Jn(window.innerWidth<=En)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!bt)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function o(g){fn(g.clientY)}function c(){xt(!1)}return window.addEventListener("pointermove",o),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",c)}},[bt]),l.useEffect(()=>{var c,g;if(!(i!=null&&i.trim())){Xe.current=null,m(null),R(null),M([]),w(0),ie(null),ge(null),B(!1);return}const t=i.trim(),s=Cn(ke(t),Hn),o=Lt(s);if(st("git_sidebar.snapshot",{workspaceId:t,cached:o,cachedHistoryCount:((c=s==null?void 0:s.history)==null?void 0:c.length)??0,cachedChangedCount:((g=s==null?void 0:s.status)==null?void 0:g.changes.length)??0}),o&&s){jt(s,t),B(!1);return}Xe.current=null,Nn(ke(t)),m(null),R(null),M([]),w(0),ie(null),ge(null),B(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return E(t=>{var s,o,c;t.workspaceId===i.trim()&&(st("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((o=t.branches)==null?void 0:o.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),jt(t,t.workspaceId),B(!1))})},[E,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=Cn(ke(t),Hn),o=Lt(s)?(s==null?void 0:s.revision)??null:null;b(t,{knownRevision:o}),cn.current&&K()},[v,b,i]),l.useEffect(()=>{const t=ln.current;ln.current=u,i!=null&&i.trim()&&!t&&u&&v(i.trim(),{knownRevision:y})},[u,v,y,i]),l.useEffect(()=>{const t=i==null?void 0:i.trim();if(!t||Xe.current!==t)return;const s={revision:y,status:r,history:C,historyTotalCount:_,historyNextCursor:I,branches:$};if(!Lt(s)){Nn(ke(t));return}Di(ke(t),s)},[$,C,I,_,y,r,i]),l.useEffect(()=>{if(!r||!se)return;r.changes.find(s=>s.path===se)||X(null)},[se,r]),l.useEffect(()=>{os(an.current)},[fe]),l.useEffect(()=>{O||(U([]),z(null),q(null),Ke(null))},[O]),l.useEffect(()=>{if(!r){U([]);return}const t=new Set(r.changes.map(s=>s.path));U(s=>s.filter(o=>t.has(o)))},[r]);function li(){const t=sn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(o=>{o.scrollTop=0})}function jt(t,s){Xe.current=(s==null?void 0:s.trim())??(i==null?void 0:i.trim())??null,R(typeof t.revision=="string"?t.revision:null),m(t.status),M(Array.isArray(t.history)?t.history:[]),w(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),ie(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),ge(t.branches??null)}function K(t){i!=null&&i.trim()&&(B(!0),st("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),v(i.trim(),{knownRevision:y}))}async function Ct(t){if(!(i!=null&&i.trim()))return;const s=i.trim();B(!0);try{const[o,c,g]=await Promise.all([Fi(s),vn(s,Rn,null),Oi(s)]);jt({status:o,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:g}),v(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{li()})}catch(o){H({title:L(o,n("git.panelLoadFailed")),tone:"error"})}finally{B(!1)}}async function qe(){if(!(!i||!I||he)){ct(!0);try{const t=await vn(i,Rn,I);M(s=>{const o=new Set(s.map(g=>g.commitHash)),c=t.items.filter(g=>!o.has(g.commitHash));return[...s,...c]}),w(t.totalCount),ie(t.nextCursor)}catch(t){H({title:L(t,n("git.panelLoadFailed")),tone:"error"})}finally{ct(!1)}}}function ci(t){if(!ee||he||!I)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&qe()}async function ui(){if(i){A(!0);try{const t=await _i(i,"ai");pe(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){H({title:L(t,n("git.draftFailed")),tone:"error"})}finally{A(!1)}}}async function Ye(t,s){if(i&&t.length){A(!0);try{const o=s?await $i(i,t):await Bi(i,t);m(o),X(t[t.length-1]??null),U(c=>c.filter(g=>!t.includes(g))),z(null),K()}catch(o){B(!1),H({title:L(o,n("git.stageFailed")),tone:"error"})}finally{A(!1)}}}async function Nt(t){if(i&&t.length){A(!0);try{const s=await Vi(i,t);m(s),t.includes(se??"")&&X(null),U(o=>o.filter(c=>!t.includes(c))),z(null),K()}catch(s){B(!1),H({title:L(s,n("git.discardFailed")),tone:"error"})}finally{A(!1)}}}async function di(){if(!(!i||!fe.trim())){A(!0);try{await ki(i,ss(fe)),H({title:n("git.commitSuccess"),tone:"success"}),pe(""),X(null),K()}catch(t){H({title:L(t,n("git.commitFailed")),tone:"error"})}finally{A(!1)}}}async function mi(){if(i!=null&&i.trim()){A(!0),B(!0);try{const t=await Li(i.trim());m(t),M([]),w(0),ie(null),ge(null),H({title:n("git.initSuccess"),tone:"success"}),K()}catch(t){H({title:L(t,n("git.initFailed")),tone:"error"})}finally{A(!1),B(!1)}}}function Ze(t){Z(ds(We)),Me(!0),hi(t)}async function hi(t){const s=i==null?void 0:i.trim();if(!s){ze("generic");return}try{const o=await Sn(s);if((i==null?void 0:i.trim())!==s)return;ze(hs(o,t))}catch{if((i==null?void 0:i.trim())!==s)return;ze("generic")}}function gi(){const t=ms(P),s=Yt==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(P.authMode==="basic"){if(!P.username.trim()){H({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!P.password){H({title:s,tone:"error"});return}}if(P.authMode==="token"&&!P.token){H({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}qt(t),Me(!1),H({title:t?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:t&&P.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function dn(){if(i){Xt(!0);try{const t=await Sn(i);if(t.length===0){H({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){mn([t[0].name]);return}It(t),gt(new Set),Te(new Map),Se(!0)}catch(t){H({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Xt(!1)}}}async function mn(t){if(!i||t.length===0)return;A(!0),Te(new Map);const s=new Map;let o=!1;try{for(const c of t)try{const g=await Tn(i,"push",c,We,P.rememberOnHost);s.set(c,{ok:!0,summary:g.summary})}catch(g){if(o=!0,s.set(c,{ok:!1,summary:L(g,n("git.remoteFailed"))}),Te(new Map(s)),Gn(g)){Ze(c);return}}Te(s),K(),o||(H({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),Se(!1))}finally{A(!1)}}async function vt(t){if(i){if(t==="push"){W(!1),dn();return}A(!0);try{const s=await Tn(i,t,void 0,We,P.rememberOnHost);H({title:s.summary,tone:"success"}),W(!1),K()}catch(s){if(Gn(s)){Ze();return}H({title:L(s,n("git.remoteFailed")),tone:"error"})}finally{A(!1)}}}async function le(){if(i){A(!0);try{const t=await Ui(i);pe(t.commitSubject??""),H({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),W(!1),K()}catch(t){H({title:L(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{A(!1)}}}async function fi(t){if(i){A(!0);try{const s=await Ii(i,t,!1);ge(s),W(!1),K()}catch(s){H({title:L(s,n("git.branchFailed")),tone:"error"})}finally{A(!1)}}}async function St(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const o=Ie.current.get(t);if(o)return o;const c=await Xi(s,t);return Ie.current.set(t,c),c}async function Ae(t){Y(null),q(null),mt(t),Ue(null);const s=Ie.current.get(t)??null;if(je(s),Be(!s),s)return;const o=we.current+1;we.current=o;try{const c=await St(t);if(we.current!==o)return;je(c)}catch(c){if(we.current!==o)return;Ue(L(c,n("git.commitDetailLoadFailed"))),je(null)}finally{we.current===o&&Be(!1)}}function pi(){mt(null),Be(!1),Ue(null),je(null)}async function Pe(t){try{const s=await St(t);await V(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){H({title:L(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function De(t){Y(null),q(null),Ce(t),oe(null),Ne(!0)}function bi(t){var o;const s=((o=C[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return[{id:`view-changes:${t.commitHash}`,label:n("git.viewCommitChanges"),onSelect:()=>void Ae(t.commitHash)},{id:`copy-hash:${t.commitHash}`,label:n("git.copyCommitHash"),onSelect:()=>void V(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void V(me(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void Pe(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>De(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:N,onSelect:()=>void le()}]:[]]}async function hn(t){Y(null),q(null),await Wi(bi(t))}async function xi(){var t,s;if(!(!i||!Kt||!ve||ne)){ht(!0);try{const o=await St(Kt),c=await Yi({workspaceId:i,provider:ve,content:rs(o),clientRequestId:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:zi()}),g=c.session??await Zi(c.sessionId);p(g),S(),T(g.workspaceId),j(Ki(g.workspaceId,g.sessionId)),Ne(!1),Ce(null),oe(null),H({title:n("git.explainCommitStarted"),tone:"success"})}catch(o){H({title:L(o,n("git.explainCommitFailed")),tone:"error"})}finally{ht(!1)}}}function Je(t){Vt(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}const yi=450;function gn(t){const s=Date.now(),o=tn.current;return tn.current={filePath:t,timestamp:s},(o==null?void 0:o.filePath)===t&&s-o.timestamp<=yi}async function Qe(t,s){if(s.binary){H({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")He(null),Ee(t);else if(i)try{const o=await Gi(i,t,s.staged);He(o.content),Ee(t)}catch{He(null),Ee(t)}}function et(t){X(t),z(null),U(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}function fn(t){const s=nn.current;if(!s||!Number.isFinite(t))return;const o=s.getBoundingClientRect(),c=o.height-at;if(!Number.isFinite(o.top)||!Number.isFinite(o.height)||c<=0)return;const g=(t-o.top-at/2)/c*100;if(!Number.isFinite(g))return;const Fe=Math.max(Mn,Math.min(wt,Math.round(g)));Qt(Fe)}function ji(t){t.preventDefault(),fn(t.clientY),xt(!0)}const Le=(r==null?void 0:r.changes)??[],J=Le.filter(t=>Gt(t,"staged")),ce=Le.filter(t=>Gt(t,"unstaged")),pn=On(J,"staged"),bn=On(ce,"unstaged"),tt=new Set(Zn),nt=new Set(ut),ue=kn(ut,Le,"staged"),de=kn(ut,Le,"unstaged"),Tt=Le.length===0&&((r==null?void 0:r.snapshot.ahead)??0)>0,Ci=J.length>0&&fe.trim().length>0,it=($==null?void 0:$.currentBranch)??(r==null?void 0:r.snapshot.branch)??n("common.unknown"),Mt=We!==null,_e=Yt==="github",Ni=_e?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),vi=_e?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),Si=_e?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),Ti=_e?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Et=Number.isFinite(Jt)?Jt:Rt,Mi=ee?`minmax(120px, ${Et}fr) ${at}px minmax(140px, ${100-Et}fr)`:`minmax(120px, 1fr) ${at}px auto`,Ei=cs(r);l.useEffect(()=>{be==="staged"&&ue.length===0&&z(null),be==="unstaged"&&de.length===0&&z(null)},[be,ue.length,de.length]),l.useEffect(()=>{if(!O)return;const t=ce.length>0?"unstaged":J.length>0?"staged":"history";ae(s=>s==="unstaged"&&ce.length>0||s==="staged"&&J.length>0?s:t)},[O,J.length,ce.length]),l.useEffect(()=>{ye&&(C.some(t=>t.commitHash===ye)||q(null))},[C,ye]),l.useEffect(()=>{re&&(C.some(t=>t.commitHash===re)||Y(null))},[re,C]),l.useEffect(()=>{O&&xe!=="history"&&te&&W(!1)},[O,te,xe]),l.useLayoutEffect(()=>{if(O||!te){ft(null);return}function t(){const o=rn.current,c=on.current;!o||!c||typeof window>"u"||ft($n(o.getBoundingClientRect(),{width:c.getBoundingClientRect().width||kt,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[N,$==null?void 0:$.local.length,it,O,te,Mt]);const Q=ye??re;l.useLayoutEffect(()=>{if(!Q){pt(null);return}const t=Q;function s(){const c=Re.current.get(t)??null,g=yt.current;!c||!g||typeof window>"u"||pt($n(c.getBoundingClientRect(),{width:g.getBoundingClientRect().width||kt,height:g.getBoundingClientRect().height||g.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const o=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[Q,C.length]),l.useEffect(()=>{if(!Q||typeof document>"u")return;const t=Q;function s(o){const c=o.target;if(!(c instanceof Node))return;const g=Re.current.get(t)??null,Fe=yt.current;g!=null&&g.contains(c)||Fe!=null&&Fe.contains(c)||(q(null),Y(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[Q]);async function V(t,s){var o;try{if(f.isDesktop&&(await f.bridge.writeClipboardText(t)).ok){H({title:s,tone:"success"});return}if(typeof navigator<"u"&&((o=navigator.clipboard)!=null&&o.writeText)){await navigator.clipboard.writeText(t),H({title:s,tone:"success"});return}if(as(t)){H({title:s,tone:"success"});return}}catch{H({title:n("common.copyContentFailed"),tone:"error"})}}async function xn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await Nt(t)}function yn(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!O,o=s?{top:(k==null?void 0:k.top)??F,left:(k==null?void 0:k.left)??F,maxHeight:k==null?void 0:k.maxHeight,transformOrigin:(k==null?void 0:k.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?on:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:o,children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.currentBranch")}),e.jsx("strong",{className:"git-menu-branch",children:it})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:Mt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>Ze(),children:e.jsx("span",{children:n("git.remoteAuthAction")})})]})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.branchTitle")}),e.jsx("div",{className:"git-menu-branch-list",children:$==null?void 0:$.local.map(g=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||g.current,onClick:()=>void fi(g.name),children:e.jsx("span",{children:g.current?`${n("git.switchBranch")} ${g.name}`:`${n("git.switchBranchTo")} ${g.name}`})},g.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>{W(!1),dt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void vt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void vt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void vt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void le(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||$e,onClick:()=>void Ct({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:jn.createPortal(c,document.body):c}function Ht(t,s){if(s){Re.current.set(t,s);return}Re.current.delete(t)}function Hi(){var o;if(!Q||typeof document>"u")return null;const t=C.find(c=>c.commitHash===Q);if(!t)return null;const s=((o=C[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return jn.createPortal(e.jsx("div",{ref:yt,className:"git-history-entry-menu","data-floating":"true",style:{top:(G==null?void 0:G.top)??F,left:(G==null?void 0:G.left)??F,maxHeight:G==null?void 0:G.maxHeight,transformOrigin:(G==null?void 0:G.transformOrigin)??"top right"},children:e.jsx(ns,{item:t,canUndo:s,actioning:N,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void V(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void V(me(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void Pe(c),onExplainCommitChange:c=>void De(c),onUndoLastCommit:()=>void le()})}),document.body)}return r&&!Ei?e.jsx("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:e.jsxs("section",{className:"git-card git-scaffold-section git-disabled-state",children:[e.jsxs("div",{className:"git-disabled-copy",children:[e.jsx("h3",{children:n("git.uninitializedTitle")}),e.jsx("p",{children:n("git.uninitializedDescription")})]}),e.jsx("div",{className:"git-primary-actions",children:e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>void mi(),disabled:N||$e||!i,children:N?n("git.initInProgress"):n("git.initRepository")})})]})}):e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:an,rows:1,value:fe,onChange:t=>pe(In(t.target.value)),onKeyDown:t=>{t.key==="Enter"&&t.preventDefault()},placeholder:n("git.commitSubjectPlaceholder")}),e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.generateDraft"),title:n("git.generateDraft"),onClick:()=>void ui(),disabled:N||$e,children:e.jsx(fs,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Ct({resetTreeScroll:!0}),disabled:N||$e||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(Tt){dn();return}di()},disabled:N||!Tt&&!Ci,children:Tt?n("git.pushNow"):n("git.commitNow")})]})]}),O?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Dt,{title:n("git.stagedChangesTitle"),count:J.length,expanded:xe==="staged",onToggle:()=>ae("staged"),children:e.jsx(Dn,{title:n("git.stagedChangesTitle"),nodes:pn,collapsedTreePathSet:tt,onToggleTreePath:Je,onToggleMobileSelection:et,selectedMobilePathSet:nt,selectedTargets:ue,actioning:N,variant:"staged",swipeRowState:Zt,onSwipeRowChange:Ke,onStageToggle:Ye,onDiscardWithConfirm:xn,onClearSelectedTargets:()=>U(t=>t.filter(s=>!ue.includes(s))),onPreviewFile:Qe})}),e.jsx(Dt,{title:n("git.changesTitle"),count:ce.length,expanded:xe==="unstaged",onToggle:()=>ae("unstaged"),children:e.jsx(Dn,{title:n("git.changesTitle"),nodes:bn,collapsedTreePathSet:tt,onToggleTreePath:Je,onToggleMobileSelection:et,selectedMobilePathSet:nt,selectedTargets:de,actioning:N,variant:"unstaged",swipeRowState:Zt,onSwipeRowChange:Ke,onStageToggle:Ye,onDiscardWithConfirm:xn,onClearSelectedTargets:()=>U(t=>t.filter(s=>!de.includes(s))),onPreviewFile:Qe})}),e.jsxs(Dt,{title:n("git.recentVersionsTitle"),count:_,expanded:xe==="history",onToggle:()=>ae("history"),trailingContent:e.jsx("span",{className:"badge",children:it}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":te,onClick:()=>{ae("history"),W(t=>!t)},disabled:N,children:e.jsx(Ge,{})}),children:[te?e.jsx("div",{className:"git-mobile-operations-shell",children:yn()}):null,e.jsx(ts,{history:C,historyLoadingMore:he,hasMore:!!I,actioning:N,openCommitHash:ye,onMenuTriggerRef:Ht,onToggleMenu:t=>q(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(me(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Pe(t),onExplainCommitChange:t=>void De(t),onUndoLastCommit:()=>void le(),onLoadMore:()=>void qe()})]})]}):e.jsxs("div",{ref:nn,className:"git-content-split",style:{gridTemplateRows:Mi},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:sn,className:"git-tree-panel-body",children:[J.length>0?e.jsx(Pn,{title:n("git.stagedChangesTitle"),count:J.length,nodes:pn,selectedPath:se,collapsedTreePathSet:tt,onToggleTreePath:Je,onSelectFile:X,onPreviewFile:(t,s)=>{gn(t)&&Qe(t,s)},onToggleMobileSelection:et,onStageToggle:Ye,onDiscard:Nt,actioning:N,variant:"staged",isMobileViewport:O,selectedMobilePathSet:nt,selectedTargets:ue,mobileActionMenuOpen:be==="staged",onToggleMobileActionMenu:()=>z(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>U(t=>t.filter(s=>!ue.includes(s)))}):null,e.jsx(Pn,{title:n("git.changesTitle"),count:ce.length,nodes:bn,selectedPath:se,collapsedTreePathSet:tt,onToggleTreePath:Je,onSelectFile:X,onPreviewFile:(t,s)=>{gn(t)&&Qe(t,s)},onToggleMobileSelection:et,onStageToggle:Ye,onDiscard:Nt,actioning:N,variant:"unstaged",isMobileViewport:O,selectedMobilePathSet:nt,selectedTargets:de,mobileActionMenuOpen:be==="unstaged",onToggleMobileActionMenu:()=>z(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>U(t=>t.filter(s=>!de.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Mn,"aria-valuemax":wt,"aria-valuenow":ee?Et:wt,"data-dragging":bt,onPointerDown:ji,children:e.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),e.jsxs("section",{className:"git-card git-history-section",children:[e.jsxs("div",{className:"git-history-topbar",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":ee,"aria-label":ee?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Wt(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(lt,{expanded:ee}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:_})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:it}),e.jsx("button",{className:"git-icon-button",type:"button",ref:rn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>W(t=>!t),disabled:N,children:e.jsx(Ge,{})}),te?yn({desktopFloating:!0}):null]})]}),ee?e.jsx(_n,{history:C,historyLoadingMore:he,hasMore:!!I,actioning:N,openCommitHash:re,useNativeContextMenu:un,onMenuTriggerRef:Ht,onScroll:ci,onToggleMenu:t=>{if(un){const s=C.find(o=>o.commitHash===t);s&&hn(s);return}Y(s=>s===t?null:t)},onOpenContextMenu:t=>void hn(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(me(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Pe(t),onExplainCommitChange:t=>void De(t),onUndoLastCommit:()=>void le(),onLoadMore:()=>void qe()}):null]})]}),e.jsxs(Oe,{open:ii,title:n("git.selectRemoteTitle"),description:n("git.selectRemoteDesc"),onClose:()=>{N||Se(!1)},children:[e.jsxs("div",{className:"git-remote-auth-banner",children:[e.jsxs("div",{className:"git-remote-auth-banner-copy",children:[e.jsx("strong",{children:n("git.remoteAuthStatusLabel")}),e.jsx("span",{children:Mt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")})]}),e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>Ze(),children:n("git.remoteAuthAction")})]}),e.jsx("div",{className:"git-remote-select-list",children:si.map(t=>{const s=Ve.has(t.name),o=ai.get(t.name);return e.jsxs("label",{className:"git-remote-item",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:N,onChange:()=>{gt(c=>{const g=new Set(c);return g.has(t.name)?g.delete(t.name):g.add(t.name),g})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),o&&e.jsx("span",{className:`git-remote-result ${o.ok?"ok":"err"}`,children:o.summary})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>Se(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:N||Ve.size===0,onClick:()=>void mn(Array.from(Ve)),children:N?n("git.pushing"):n("git.pushSelected",{count:String(Ve.size)})})]})]}),e.jsxs(Oe,{open:ri,title:n("git.remoteAuthTitle"),description:Ni,onClose:()=>{N||Me(!1)},children:[e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:P.authMode,disabled:N,onChange:t=>Z(s=>({...s,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),P.authMode==="basic"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:P.username,placeholder:Ti,autoComplete:"username",onChange:t=>Z(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:vi}),e.jsx("input",{type:"password",value:P.password,placeholder:Si,autoComplete:"current-password",onChange:t=>Z(s=>({...s,password:t.target.value}))})]})]}):null,P.authMode==="token"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:P.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>Z(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:P.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>Z(s=>({...s,token:t.target.value}))})]})]}):null,_e?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,P.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:P.rememberOnHost,onChange:t=>Z(s=>({...s,rememberOnHost:t.target.checked}))}),e.jsx("span",{children:n("git.remoteAuthRemember")})]}):null,e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthSessionHint")})]}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>Me(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:N,onClick:gi,children:n("git.remoteAuthSave")})]})]}),e.jsx(Oe,{open:Qn,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(_)}),onClose:()=>dt(!1),children:e.jsx(_n,{history:C,historyLoadingMore:he,hasMore:!!I,actioning:N,openCommitHash:re,className:"git-history-modal-list",onMenuTriggerRef:Ht,onToggleMenu:t=>Y(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(me(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Pe(t),onExplainCommitChange:t=>void De(t),onUndoLastCommit:()=>void le(),onLoadMore:()=>void qe()})}),e.jsx(Oe,{open:ei!==null,className:"git-commit-detail-modal",title:(D==null?void 0:D.subject)||n("git.commitDetailTitle"),description:D?n("git.commitDetailDescription",{hash:D.shortHash}):n("git.commitDetailLoading"),onClose:pi,children:ti?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):zt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:zt})}):D?e.jsxs("div",{className:"git-commit-detail-shell",children:[e.jsxs("div",{className:"git-commit-detail-meta-grid",children:[e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitVersionLabel")}),e.jsx("strong",{children:D.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:D.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:D.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:ls(D.authoredAt)})]})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsx("div",{className:"git-commit-detail-section-header",children:e.jsx("h3",{children:n("git.commitMessageLabel")})}),e.jsx("pre",{className:"git-commit-detail-message",children:me(D)})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.changedFilesTitle")}),e.jsx("span",{className:"workbench-section-counter",children:D.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:D.changedFiles.map(t=>e.jsxs("div",{className:"git-commit-detail-file-item",children:[e.jsx("span",{className:"git-commit-detail-file-status","data-status":t.status,children:t.status}),e.jsxs("div",{className:"git-commit-detail-file-copy",children:[e.jsx("strong",{children:t.path}),t.oldPath?e.jsx("span",{children:n("git.renamedFromLabel",{path:t.oldPath})}):null]})]},`${t.status}:${t.oldPath??""}:${t.path}`))})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.commitDiffLabel")}),D.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:D.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Oe,{open:ni,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{ne||(Ne(!1),Ce(null),oe(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(qi,{workspaceId:i,selectedProvider:ve,pendingProvider:ne?ve:null,disabled:ne,onSelect:t=>oe(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:ne,onClick:()=>{Ne(!1),Ce(null),oe(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!ve||ne,onClick:()=>void xi(),children:ne?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(Qi,{workspaceId:i,filePath:en,open:en!==null,onClose:()=>{Ee(null),He(null)},onSaved:async()=>{await Ct({resetTreeScroll:!0})},diffContent:oi}),Hi()]})}function Pn({title:a,count:i,nodes:u,selectedPath:h,collapsedTreePathSet:d,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:E,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:r,selectedTargets:m,mobileActionMenuOpen:y,onToggleMobileActionMenu:R,onClearSelectedTargets:C}){const M=Un(),_=Ut(u),w=T==="staged"?n("git.unstageAll"):n("git.stageAll");return e.jsxs("section",{className:"git-tree-group","data-variant":T,children:[e.jsxs("div",{className:"git-section-header git-tree-group-header",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"git-tree-group-actions",children:[e.jsx("span",{className:"workbench-section-counter",children:i}),!p&&_.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":w,title:w,onClick:()=>void v(_,T==="staged"),disabled:S,children:e.jsx($t,{staged:T==="staged"})}),T==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void E(_),disabled:S,children:e.jsx(Bt,{})}):null]}):null,p&&m.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:R,disabled:S,children:e.jsx(Ge,{})}):null]}),p&&y?e.jsxs("div",{className:"git-selection-menu",children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.selectedFiles")}),e.jsx("strong",{className:"git-menu-branch",children:m.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void v(m,T==="staged"),children:e.jsx("span",{children:T==="staged"?n("git.unstage"):n("git.stage")})}),T==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void E(m),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:C,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{ref:M,className:"git-tree-shell",role:"tree","aria-label":a,"data-scrollbar-autohide":"true",children:u.length?Wn({nodes:u,depth:0,collapsedTreePathSet:d,selectedPath:h,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:E,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Dt({title:a,count:i,expanded:u,onToggle:h,trailingContent:d,headerAction:j,children:f}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:h,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(lt,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[d,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),j?e.jsx("div",{className:"git-mobile-section-header-action",children:j}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:f}):null]})}function Dn({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:j,selectedTargets:f,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:E,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:p,onPreviewFile:r}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[f.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",f.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:x,onClick:()=>void S(f,b==="staged"),children:b==="staged"?n("git.unstage"):n("git.stage")}),b==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:x,onClick:()=>void T(f,`${f.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:x,onClick:p,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?Vn({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:j,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:E,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Vn({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:E,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(p=>{if(p.kind==="directory"){const y=!u.has(p.path),R=Ut(p.children),C=`directory:${p.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Ln,{rowKey:C,openState:(b==null?void 0:b.path)===C?b.direction:null,onOpenStateChange:M=>v(M?{path:C,direction:M}:null),trailingActions:R.length>0?[{label:x==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void E(R,x==="staged")},...x==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(R,p.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${wn+i*An}px`},onClick:()=>h(p.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":y,children:e.jsx(lt,{expanded:y})}),e.jsx("span",{className:"git-mobile-record-title",children:p.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:R.length})]})}),y?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Vn({nodes:p.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:E,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},C)}const r=`file:${p.path}`,m=j.has(p.path);return e.jsx(Ln,{rowKey:r,openState:(b==null?void 0:b.path)===r?b.direction:null,onOpenStateChange:y=>v(y?{path:r,direction:y}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(p.change.path,p.change)},{label:x==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void E([p.change.path],x==="staged")},...x==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S([p.change.path],p.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":m,style:{paddingInlineStart:`${wn+i*An}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${p.name}`,onChange:()=>d(p.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>d(p.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(p.name),"aria-hidden":"true",children:Ft(p.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:p.name}),e.jsx("span",{className:"git-mobile-record-path",children:p.path})]}),e.jsx("span",{className:"git-status-badge","data-status":p.status,children:p.status})]})]})},r)})}function Ln({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:h,children:d}){const j=Ji(),f=l.useRef(null),[x,b]=l.useState(0),v=((h==null?void 0:h.length)??0)*At;l.useEffect(()=>{i||b(0)},[i,a]);const E=x!==0?x:i==="trailing"?-v:0;function S(m){var y,R;m.button===0&&(f.current={pointerId:m.pointerId,startX:m.clientX},(R=(y=m.currentTarget).setPointerCapture)==null||R.call(y,m.pointerId))}function T(m){const y=f.current;if(!y||y.pointerId!==m.pointerId)return;const R=v>0?v+10:0,C=Math.max(-R,Math.min(0,m.clientX-y.startX));b(C)}function p(m){var R,C;const y=f.current;if(!(!y||y.pointerId!==m.pointerId)){if((C=(R=m.currentTarget).releasePointerCapture)==null||C.call(R,m.pointerId),f.current=null,x<=-44&&(h!=null&&h.length)){j.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function r(m){var R,C;const y=f.current;!y||y.pointerId!==m.pointerId||((C=(R=m.currentTarget).releasePointerCapture)==null||C.call(R,m.pointerId),f.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":x!==0,children:[h==null?void 0:h.map((m,y)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":m.tone,style:{right:y*At,width:At},onClick:()=>{j.trigger(m.tone==="danger"?"warning":"action"),u(null),m.onPress()},children:m.label},`trailing-${y}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${E}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:p,onPointerCancel:r,children:d})]})}function ts({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:d,onMenuTriggerRef:j,onToggleMenu:f,onViewCommitChanges:x,onCopyCommitHash:b,onCopyCommitMessage:v,onCopyCommitVersion:E,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:p}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(r=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":r.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":r.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-mobile-history-copy",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:r.subject,children:r.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":r.commitKind,children:Xn(r.commitKind)})]}),r.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:r.refs.map(m=>e.jsx("span",{className:"git-history-ref-pill","data-kind":m.kind,"data-remote-index":String(qn(m.remoteName)),children:m.name},`${r.commitHash}:${m.kind}:${m.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:r.commitHash.slice(0,8)}),e.jsx("span",{children:r.authorName}),e.jsx("time",{dateTime:r.authoredAt,children:Yn(r.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:m=>j(r.commitHash,m),"aria-label":n("git.historyItemMenu"),onClick:()=>f(r.commitHash),children:e.jsx(Ge,{})})]})},r.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:p,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function _n({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:d,className:j,useNativeContextMenu:f=!1,onMenuTriggerRef:x,onScroll:b,onToggleMenu:v,onOpenContextMenu:E,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:p,onCopyCommitVersion:r,onExplainCommitChange:m,onUndoLastCommit:y,onLoadMore:R}){const C=Un();return a.length?e.jsxs("div",{ref:C,className:["git-history-list",j].filter(Boolean).join(" "),onScroll:b,"data-scrollbar-autohide":"true",children:[a.map(M=>{const _=d===M.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":M.commitKind,"data-menu-open":_?"true":"false",onContextMenu:w=>{!f||!E||(w.preventDefault(),w.stopPropagation(),E(M))},children:[e.jsx("span",{className:"git-history-marker","data-kind":M.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-history-body",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:M.subject,children:M.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":M.commitKind,children:Xn(M.commitKind)}),f?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:w=>x(M.commitHash,w),"aria-label":n("git.historyItemMenu"),onClick:()=>{v(M.commitHash)},children:e.jsx(Ge,{})})]})]}),M.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:M.refs.map(w=>e.jsx("span",{className:"git-history-ref-pill","data-kind":w.kind,"data-remote-index":String(qn(w.remoteName)),children:w.name},`${M.commitHash}:${w.kind}:${w.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:M.commitHash.slice(0,8)}),e.jsx("span",{children:M.authorName}),e.jsx("time",{dateTime:M.authoredAt,children:Yn(M.authoredAt)})]})]})]},M.commitHash)}),i?e.jsxs("p",{className:"git-history-loading",children:[n("git.refreshNow"),"..."]}):null,u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:R,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function ns({item:a,canUndo:i,actioning:u,onViewCommitChanges:h,onCopyCommitHash:d,onCopyCommitMessage:j,onCopyCommitVersion:f,onExplainCommitChange:x,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>h(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>d(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>j(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>f(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>x(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),i?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:b,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function Wn({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:d,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:E,variant:S,isMobileViewport:T,selectedMobilePathSet:p}){return a.map(r=>{if(r.kind==="directory"){const R=!u.has(r.path),C=Ut(r.children),M=`${S==="staged"?n("git.unstage"):n("git.stage")} ${r.path}`,_=`${n("git.discard")} ${r.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":R,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>d(r.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":R,children:e.jsx(lt,{expanded:R})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:r.name})]}),!T&&C.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":M,title:M,onClick:()=>void b(C,S==="staged"),disabled:E,children:e.jsx($t,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":_,title:_,onClick:()=>void v(C),disabled:E,children:e.jsx(Bt,{})}):null]}):null]}),R?e.jsx("div",{className:"git-tree-children",role:"group",children:Wn({nodes:r.children,depth:i+1,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:d,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:E,variant:S,isMobileViewport:T,selectedMobilePathSet:p})}):null]},`directory:${r.path}`)}const m=p.has(r.path),y=T?m:h===r.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":y,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${r.name}`,onChange:()=>x(r.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":y,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>x(r.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(r.name),"aria-hidden":"true",children:Ft(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]})]},`file:${r.path}`):e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":y,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":y,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{j(r.change.path),f&&f(r.change.path,r.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(r.name),"aria-hidden":"true",children:Ft(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":r.variant==="staged"?n("git.unstage"):n("git.stage"),title:r.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void b([r.change.path],r.variant==="staged"),disabled:E,children:e.jsx($t,{staged:r.variant==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discard"),title:n("git.discard"),onClick:()=>void v([r.change.path]),disabled:E,children:e.jsx(Bt,{})}):null]})]},`file:${r.path}`)})}function Fn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function On(a,i){const u=Fn("","");for(const h of a){const d=h.path.replace(/\\/g,"/"),j=d.split("/").filter(Boolean);let f=u;j.forEach((x,b)=>{const v=j.slice(0,b+1).join("/");if(b===j.length-1){f.children.set(`file:${v}`,{kind:"file",name:x,path:d,change:h,status:is(h,i),variant:i});return}const E=`directory:${v}`,S=f.children.get(E);if(S&&S.kind==="directory"){f=S;return}const T=Fn(x,v);f.children.set(E,T),f=T})}return Kn(zn([...u.children.values()]))}function zn(a){return[...a].sort((i,u)=>i.kind!==u.kind?i.kind==="directory"?-1:1:i.name.localeCompare(u.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:zn([...i.children.values()])}:i)}function Kn(a){return a.map(i=>{var f;if(i.kind!=="directory")return i;const u=Kn(i.children);let h=i.name,d=i.path,j=u;for(;j.length===1&&((f=j[0])==null?void 0:f.kind)==="directory";){const x=j[0];h=`${h}/${x.name}`,d=x.path,j=x.children}return{kind:"directory",name:h,path:d,children:j}})}function kn(a,i,u){const h=new Set(a);return i.filter(d=>Gt(d,u)&&h.has(d.path)).map(d=>d.path)}function Ut(a){const i=[],u=new Set;function h(d){if(d.kind==="file"){u.has(d.path)||(u.add(d.path),i.push(d.path));return}d.children.forEach(h)}return a.forEach(h),i}function Gt(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function is(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function ss(a){return{subject:In(a).trim(),body:null,footer:null,source:"manual"}}function In(a){return a.replace(/[\r\n]+/g," ")}function as(a){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=a,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function me(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
2
+
3
+ ${u}`:i}function rs(a){const i=a.changedFiles.map(d=>`- [${d.status}] ${d.path}${d.oldPath?` (from ${d.oldPath})`:""}`).join(`
4
+ `),u=a.diffContent.length>Pt?a.diffContent.slice(0,Pt):a.diffContent,h=a.diffContent.length>Pt||a.diffTruncated?`
5
+ 注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${a.versionLabel}`,`Commit Hash:${a.commitHash}`,`提交标题:${a.subject}`,`提交作者:${a.authorName} <${a.authorEmail}>`,`提交时间:${a.authoredAt}`,"","变更文件:",i||"- 无",h,"","Diff:",u||"(empty diff)"].join(`
6
+ `)}function os(a){if(!a)return;a.style.height="0px";const i=Math.min(Math.max(a.scrollHeight,34),120);a.style.height=`${i}px`,a.style.overflowY=a.scrollHeight>120?"auto":"hidden"}function Xn(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function qn(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function ls(a){const i=Date.parse(a);return Number.isNaN(i)?a:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(i)}function L(a,i){return a instanceof Bn?us(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function ke(a){return`git-sidebar.snapshot.${a}`}function Lt(a){return a?!!(a.status||a.branches||a.history.length>0||a.historyTotalCount>0||a.historyNextCursor||a.revision):!1}function cs(a){return a?a.snapshot.enabled!==!1:!0}function us(a){switch(a.errorCode){case"UNAUTHORIZED":return n("git.errors.unauthorized");case"WORKSPACE_NOT_FOUND":return n("git.errors.workspaceNotFound");case"INVALID_WORKSPACE":return n("git.errors.invalidWorkspace");case"NOT_GIT_REPOSITORY":return n("git.errors.notGitRepository");case"GIT_REPO_NOT_FOUND":return n("git.errors.repoNotFound");case"PATH_OUT_OF_WORKSPACE":return n("git.errors.pathOutOfWorkspace");case"INVALID_TARGET":return n("git.errors.invalidTarget");case"NOT_STAGED":return n("git.errors.notStaged");case"EMPTY_STAGED_CHANGES":return n("git.errors.emptyStagedChanges");case"BRANCH_CONFLICT":return n("git.errors.branchConflict");case"BRANCH_NOT_FOUND":return n("git.errors.branchNotFound");case"REMOTE_NOT_FOUND":return n("git.errors.remoteNotFound");case"GIT_REMOTE_AUTH_FAILED":return n("git.errors.remoteAuthFailed");case"GIT_PUSH_FAILED":return n("git.errors.pushFailed");case"GIT_PULL_FAILED":return n("git.errors.pullFailed");case"GIT_REMOTE_FAILED":return n("git.errors.remoteFailed");case"GIT_COMMAND_TIMEOUT":return n("git.errors.commandTimeout");case"GIT_INIT_FAILED":return n("git.errors.initFailed");case"GIT_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function Gn(a){return a instanceof Bn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function ds(a){return!a||!a.mode||a.mode==="none"?ot:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:!1}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:!1}:ot}function ms(a){return a.authMode==="none"?null:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}}function hs(a,i){const u=a.find(d=>d.name===i)??a.find(d=>d.name==="origin")??a[0];if(!u)return"generic";const h=u.pushUrl||u.fetchUrl;return gs(h)?"github":"generic"}function gs(a){const i=(a==null?void 0:a.trim().toLowerCase())??"";return i.startsWith("https://github.com/")||i.startsWith("http://github.com/")||i.startsWith("ssh://git@github.com/")||i.startsWith("git@github.com:")}function $n(a,i,u){const h=Math.max(0,u.width),d=Math.max(0,u.height),j=Math.max(0,d-F*2),f=Math.max(0,h-F*2),x=Math.min(Math.max(i.width||kt,0),f),b=Math.max(0,d-a.bottom-rt-F),v=Math.max(0,a.top-rt-F),E=b<i.height&&v>b,T=_t(Math.max(E?v:b,es),0,j),p=Math.min(Math.max(i.height,0),T),r=E?a.top-rt-p:a.bottom+rt,m=Math.max(F,d-F-p),y=Math.max(F,h-F-x);return{top:_t(r,F,m),left:_t(a.right-x,F,y),maxHeight:Math.max(0,T),transformOrigin:`${E?"bottom":"top"} right`}}function _t(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function lt({expanded:a}){return e.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function $t({staged:a}){return a?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Bt(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function fs(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"})})}function Ge(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function Yn(a){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(a))}catch{return a}}export{Ms as GitSidebar,$n as resolveGitOperationsMenuPosition};
@@ -0,0 +1 @@
1
+ import{b as c,j as e,t as n}from"./index-DSw-TkQL.js";import{e as j,M as f,f as p,h as g,i as M,j as S,k as v,S as L}from"./model-switch-api-C-l8-E1S.js";function E({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[a,m]=c.useState(""),[h,u]=c.useState(!1),k=j(),i=c.useMemo(()=>t??l.map(s=>({workspace:s,label:s.name,subtitle:s.path,depth:0,kind:"workspace",meta:null})),[t,l]),w=c.useMemo(()=>i.map(s=>s.workspace.id).join("|"),[i]);if(c.useEffect(()=>{o&&(m(N(i,d)),u(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===a)??i[0]??null;return e.jsxs(f,{open:o,title:n("shell.createSessionModalTitle"),description:n("shell.createSessionModalDescription"),kind:"form",height:"three-quarter",className:"mobile-create-session-sheet",cardClassName:"mobile-create-session-sheet-card",bodyClassName:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",showHandle:!0,onClose:b,children:[e.jsx(p,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(g,{label:n("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${n("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{k.trigger("selection"),u(s=>!s)},children:[e.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[e.jsx("strong",{children:(r==null?void 0:r.label)??n("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??n("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(M,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(S,{as:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":s.kind,"data-worktree-depth":s.depth,selected:s.workspace.id===a,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===a?e.jsx(I,{}):e.jsx(y,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==a&&k.trigger("selection"),m(s.workspace.id),u(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(v,{className:"mobile-workspace-home-worktree-badge",children:n("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(p,{className:"mobile-create-session-provider-block",heading:n("shell.createSessionProviderLabel"),children:e.jsx(L,{disabled:!a,workspaceId:a||null,onSelect:s=>{a&&x(a,s)}})})]})}function N(o,l){var t;return l&&o.some(d=>d.workspace.id===l)?l:((t=o[0])==null?void 0:t.workspace.id)??""}function C({expanded:o}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":o?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function y(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function I(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{E as M};
@@ -1 +1 @@
1
- import{j as i}from"./index-BZLcEHW3.js";function m({children:e,className:o,frameRef:r,...a}){return i.jsx("div",{ref:r,className:["mobile-top-header-frame",o].filter(Boolean).join(" "),...a,children:e})}export{m as M};
1
+ import{j as i}from"./index-DSw-TkQL.js";function m({children:e,className:o,frameRef:r,...a}){return i.jsx("div",{ref:r,className:["mobile-top-header-frame",o].filter(Boolean).join(" "),...a,children:e})}export{m as M};
@@ -0,0 +1 @@
1
+ import{b as j,f as B,h as $,j as t,t as l}from"./index-DSw-TkQL.js";import{e as K,i as F,j as P,k as S,M as G}from"./model-switch-api-C-l8-E1S.js";import{b1 as q,m as z,b2 as D,ax as X,b3 as J}from"./WorkbenchLayout-DlbgBT3n.js";import{u as Q,f as V}from"./App-B9HcTkMT.js";import{M as Y}from"./MobileTopHeaderFrame-etF2HKlm.js";function Z(s){return s.flatMap(o=>[{workspace:o.workspace,label:o.workspace.name,subtitle:o.workspace.path,depth:0,kind:"workspace",meta:null},...v(o.childWorktrees??[])])}function we(s,o){const a=o==null?void 0:o.trim();if(!a)return null;for(const i of s){if(i.workspace.id===a)return{workspace:i.workspace,sessions:i.sessions,childWorktrees:i.childWorktrees??[],meta:null};const n=H(i.childWorktrees??[],a);if(n)return n}return null}function v(s){return s.flatMap(o=>[{workspace:o.workspace,label:o.meta.displayName||o.workspace.name,subtitle:o.workspace.path,depth:o.meta.depth,kind:"worktree",meta:o.meta},...v(o.children)])}function H(s,o){for(const a of s){if(a.workspace.id===o)return{workspace:a.workspace,sessions:a.sessions,childWorktrees:a.children,meta:a.meta};const i=H(a.children,o);if(i)return i}return null}const W=10080*60*1e3;function ee(s,o){return se(s.hosts,s.activeHostId).flatMap(a=>{const i=a.id===s.activeHostId?o:oe(a.id);return[{kind:"host",host:a,workspaceCount:i.length},...i.map(n=>({kind:"workspace",host:a,workspace:n.workspace,option:n}))]})}function se(s,o){return[...s].sort((a,i)=>{if(a.id===o)return-1;if(i.id===o)return 1;const n=a.lastConnectedAt??a.updatedAt??a.createdAt;return(i.lastConnectedAt??i.updatedAt??i.createdAt).localeCompare(n)})}function oe(s){const o=q(W,s);return o?Z(z(o)):[]}function ke({currentWorkspace:s,workspaces:o,workspaceOptions:a,onSelectWorkspace:i,className:n,containerRef:w,heading:N,content:C,sheetContent:k,triggerLabel:M,triggerAriaLabel:L,onTriggerClick:c,trailing:A,gestureHandlers:y}){const[u,d]=j.useState(!1),[m,b]=j.useState(null),f=K(),I=Q(),{showToast:T}=V(),r=B(e=>e),h=$(r),E=a??o.map(e=>({workspace:{...e,repoRoot:e.path},label:e.name,subtitle:e.path,depth:0,kind:"workspace",meta:null})),O=ee(r,E),p=(s==null?void 0:s.name)??(h==null?void 0:h.name)??null,x=(s==null?void 0:s.path)??(h==null?void 0:h.baseUrl)??null;if(!p)return null;async function R(e){const U=e.kind==="host"?`host:${e.host.id}`:`workspace:${e.host.id}:${e.workspace.id}`;if(!m){b(U);try{e.host.id!==r.activeHostId&&(f.trigger("selection"),await D.switchHost(e.host.id)),e.kind==="host"?I(X()):(e.workspace.id!==(s==null?void 0:s.id)||e.host.id!==r.activeHostId)&&await(i==null?void 0:i(e.workspace.id)),d(!1)}catch(_){T({title:te(_,e.host.name),tone:"error"})}finally{b(null)}}}return t.jsxs(t.Fragment,{children:[t.jsx(Y,{className:n,frameRef:w,...y,children:t.jsxs("section",{className:"mobile-workspace-home-header",children:[t.jsx("h1",{className:"mobile-workspace-switcher-heading",children:N??p}),t.jsxs("div",{className:"mobile-workspace-home-toolbar-top",children:[t.jsxs("button",{type:"button",className:"mobile-workspace-home-switcher","aria-label":L??l("shell.workspaceHomeSwitcherLabel"),onClick:()=>{if(c){c();return}f.trigger("selection"),d(!0)},children:[t.jsx("span",{className:"mobile-workspace-home-switcher-label",children:M??p}),t.jsx(ne,{})]}),t.jsx("div",{className:"mobile-workspace-home-toolbar-actions",children:A})]}),x?t.jsx("p",{className:"mobile-workspace-home-path",children:x}):null,C]})}),u&&!c?t.jsxs(ie,{open:u,title:l("shell.hostWorkspaceSwitcherTitle"),onClose:()=>d(!1),children:[t.jsx(F,{className:"mobile-workspace-home-group mobile-workspace-home-sheet-group",children:O.map(e=>t.jsx(P,{as:"button",className:"mobile-workspace-home-row mobile-workspace-home-sheet-row","data-host-entry-kind":e.kind,"data-host-active":e.host.id===r.activeHostId,"data-worktree-kind":e.kind==="workspace"?e.option.kind:void 0,"data-worktree-depth":e.kind==="workspace"?e.option.depth+1:0,disabled:m!==null,selected:e.kind==="host"&&e.host.id===r.activeHostId||e.kind==="workspace"&&e.workspace.id===(s==null?void 0:s.id)&&e.host.id===r.activeHostId,trailing:t.jsx("span",{className:"mobile-workspace-home-row-trailing",children:e.kind==="host"&&e.host.id===r.activeHostId?t.jsx(g,{}):e.kind==="workspace"&&e.workspace.id===(s==null?void 0:s.id)&&e.host.id===r.activeHostId?t.jsx(g,{}):t.jsx(re,{})}),style:{"--mobile-workspace-tree-depth":String(e.kind==="host"?0:e.option.depth+1)},onClick:()=>{R(e)},label:t.jsxs("span",{className:e.kind==="host"?"mobile-workspace-home-sheet-label mobile-host-workspace-switcher-host-label":"mobile-workspace-home-sheet-label",children:[e.kind==="host"?t.jsx(S,{className:"mobile-host-workspace-switcher-host-badge",children:l("shell.hostSwitcherNodeBadge")}):null,e.kind==="workspace"&&e.option.kind==="worktree"?t.jsx(S,{className:"mobile-workspace-home-worktree-badge",children:l("shell.mobileWorktreeBadge")}):null,t.jsx("span",{className:"mobile-workspace-home-sheet-label-text",children:e.kind==="host"?e.host.name:e.option.label})]}),description:t.jsx("span",{className:"mobile-workspace-home-sheet-description",children:e.kind==="host"?ae(e.host,e.workspaceCount):e.option.subtitle})},e.kind==="host"?`host-${e.host.id}`:`workspace-${e.host.id}-${e.workspace.id}`))}),k?k(()=>d(!1)):null]}):null]})}function te(s,o){return s instanceof J?s.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:o}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function ae(s,o){return s?s.lastUsername?l("shell.hostSwitcherWorkspaceCountWithUser",{username:s.lastUsername,count:o}):o>0?l("shell.hostSwitcherWorkspaceCount",{count:o}):s.baseUrl:""}function ie({open:s,title:o,onClose:a,children:i}){return t.jsx(G,{open:s,title:o,kind:"picker",height:"three-quarter",className:"mobile-host-workspace-switcher-sheet",bodyClassName:"mobile-workspace-home-form",showHandle:!0,onClose:a,children:i})}function ne(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function re(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function g(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{ke as M,we as a,Z as f};
@@ -1 +1 @@
1
- import{o as m,b as d,e as g,j as n,t as i}from"./index-BZLcEHW3.js";import{u as p,c as f,d as y}from"./App-BZvapsi8.js";import{b as E}from"./relay-entry-C5_Iay0I.js";function I(){const r=p(),{tunnelDomain:t}=f(),[e]=y(),s=m(),[a,c]=d.useState(null);return d.useEffect(()=>{var u;const l=((u=e.get("controlBaseUrl"))==null?void 0:u.trim())??"";if(!t||!l){c(s("auth.relayEntryInvalid"));return}let o=!1;const h=x(e.get("returnTo"));return g.update(E(g.getState(),{tunnelDomain:t,controlBaseUrl:l,bindingId:e.get("bindingId"),hostFingerprint:e.get("hostFingerprint")})).then(()=>{o||r(`/login?returnTo=${encodeURIComponent(h)}`,{replace:!0})}).catch(()=>{o||c(s("auth.relayEntryInvalid"))}),()=>{o=!0}},[r,e,s,t]),n.jsxs("section",{children:[n.jsx("h1",{children:i("auth.relayEntryTitle")}),n.jsx("p",{children:i("auth.relayEntryDescription")}),a?n.jsx("p",{children:a}):null,a?null:n.jsx("p",{children:i("common.loading")})]})}function x(r){const t=r==null?void 0:r.trim();return!t||!t.startsWith("/")?"/":t}export{I as RelayConnectEntryPage};
1
+ import{o as m,b as d,e as g,j as n,t as i}from"./index-DSw-TkQL.js";import{u as p,c as f,d as y}from"./App-B9HcTkMT.js";import{b as E}from"./relay-entry-BmLkMKuq.js";function I(){const r=p(),{tunnelDomain:t}=f(),[e]=y(),s=m(),[a,c]=d.useState(null);return d.useEffect(()=>{var u;const l=((u=e.get("controlBaseUrl"))==null?void 0:u.trim())??"";if(!t||!l){c(s("auth.relayEntryInvalid"));return}let o=!1;const h=x(e.get("returnTo"));return g.update(E(g.getState(),{tunnelDomain:t,controlBaseUrl:l,bindingId:e.get("bindingId"),hostFingerprint:e.get("hostFingerprint")})).then(()=>{o||r(`/login?returnTo=${encodeURIComponent(h)}`,{replace:!0})}).catch(()=>{o||c(s("auth.relayEntryInvalid"))}),()=>{o=!0}},[r,e,s,t]),n.jsxs("section",{children:[n.jsx("h1",{children:i("auth.relayEntryTitle")}),n.jsx("p",{children:i("auth.relayEntryDescription")}),a?n.jsx("p",{children:a}):null,a?null:n.jsx("p",{children:i("common.loading")})]})}function x(r){const t=r==null?void 0:r.trim();return!t||!t.startsWith("/")?"/":t}export{I as RelayConnectEntryPage};
@@ -1 +1 @@
1
- import{b as n,n as U,j as r,t as s,e as N}from"./index-BZLcEHW3.js";import{r as E,b as k}from"./relay-entry-C5_Iay0I.js";import{a as h,s as O,t as P,v as w}from"./App-BZvapsi8.js";import{W as T}from"./WorkbenchModal-0tPIIhca.js";function z({isOpen:t,onClose:u,onSave:c,theme:$="dark"}){const d=h(e=>e.baseUrl),B=h(e=>e.options),p=h(e=>e.presetOptions),f=P(),[i,o]=n.useState(d),[g,l]=n.useState(null),[v,m]=n.useState(!1),a=n.useMemo(()=>{try{return U(i)}catch{return null}},[i]),x=O(a??i,B),S=p.find(e=>e.value===x)??null,b="server-settings-preset",j="server-settings-address";if(n.useEffect(()=>{t&&(o(d),l(null),m(!1))},[t,d]),!t)return null;async function I(){if(!a){l(s("auth.serverInvalid"));return}m(!0);try{const e=await E(a);e?await N.update(k(N.getState(),e)):w.setBaseUrl(a),c==null||c(a),u()}catch(e){l(e instanceof Error&&e.message.trim()?e.message:s("auth.serverInvalid"))}finally{m(!1)}}function C(){a&&o(a)}return r.jsx(T,{open:t,title:s("auth.serverSettingsTitle"),description:s("auth.serverHint"),className:"server-settings-modal-card",onClose:u,children:r.jsxs("form",{className:"server-settings-modal-form",onSubmit:e=>{e.preventDefault(),I()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:b,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:b,"aria-label":s("auth.serverPreset"),value:x,onChange:e=>{const y=e.target.value;y!==f&&(o(y),l(null))},children:[p.map(e=>r.jsx("option",{value:e.value,children:V(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:f,children:s("auth.serverCustomOption")})]})]}),S?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:S.source==="discovered"?r.jsx("span",{className:"server-settings-modal-tag","data-tone":"discovered",children:s("auth.serverDiscoveredTag")}):null}):null,r.jsxs("label",{className:"workbench-modal-field",htmlFor:j,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:j,"aria-label":s("auth.serverAddress"),value:i,placeholder:s("auth.serverPlaceholder"),disabled:v,onBlur:C,onChange:e=>{o(e.target.value),l(null)}})]}),g?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:g}):r.jsx("p",{className:"server-settings-modal-hint",children:s("auth.serverHint")}),r.jsxs("div",{className:"workbench-modal-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:s("common.cancel")}),r.jsx("button",{type:"submit",className:"primary-button",disabled:v,children:v?s("common.loading"):s("auth.saveServerSettings")})]})]})})}function V(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{z as ServerSettingsModal};
1
+ import{b as n,n as U,j as r,t as s,e as N}from"./index-DSw-TkQL.js";import{r as E,b as k}from"./relay-entry-BmLkMKuq.js";import{a as h,s as O,t as P,v as w}from"./App-B9HcTkMT.js";import{W as T}from"./WorkbenchModal-LNfB69qx.js";function z({isOpen:t,onClose:u,onSave:c,theme:$="dark"}){const d=h(e=>e.baseUrl),B=h(e=>e.options),p=h(e=>e.presetOptions),f=P(),[i,o]=n.useState(d),[g,l]=n.useState(null),[v,m]=n.useState(!1),a=n.useMemo(()=>{try{return U(i)}catch{return null}},[i]),x=O(a??i,B),S=p.find(e=>e.value===x)??null,b="server-settings-preset",j="server-settings-address";if(n.useEffect(()=>{t&&(o(d),l(null),m(!1))},[t,d]),!t)return null;async function I(){if(!a){l(s("auth.serverInvalid"));return}m(!0);try{const e=await E(a);e?await N.update(k(N.getState(),e)):w.setBaseUrl(a),c==null||c(a),u()}catch(e){l(e instanceof Error&&e.message.trim()?e.message:s("auth.serverInvalid"))}finally{m(!1)}}function C(){a&&o(a)}return r.jsx(T,{open:t,title:s("auth.serverSettingsTitle"),description:s("auth.serverHint"),className:"server-settings-modal-card",onClose:u,children:r.jsxs("form",{className:"server-settings-modal-form",onSubmit:e=>{e.preventDefault(),I()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:b,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:b,"aria-label":s("auth.serverPreset"),value:x,onChange:e=>{const y=e.target.value;y!==f&&(o(y),l(null))},children:[p.map(e=>r.jsx("option",{value:e.value,children:V(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:f,children:s("auth.serverCustomOption")})]})]}),S?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:S.source==="discovered"?r.jsx("span",{className:"server-settings-modal-tag","data-tone":"discovered",children:s("auth.serverDiscoveredTag")}):null}):null,r.jsxs("label",{className:"workbench-modal-field",htmlFor:j,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:j,"aria-label":s("auth.serverAddress"),value:i,placeholder:s("auth.serverPlaceholder"),disabled:v,onBlur:C,onChange:e=>{o(e.target.value),l(null)}})]}),g?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:g}):r.jsx("p",{className:"server-settings-modal-hint",children:s("auth.serverHint")}),r.jsxs("div",{className:"workbench-modal-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:s("common.cancel")}),r.jsx("button",{type:"submit",className:"primary-button",disabled:v,children:v?s("common.loading"):s("auth.saveServerSettings")})]})]})})}function V(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{z as ServerSettingsModal};
@@ -0,0 +1 @@
1
+ import{b as h,j as e,t as a}from"./index-DSw-TkQL.js";import{g as ve,u as ye}from"./App-B9HcTkMT.js";import{e as je,a as be}from"./model-switch-api-C-l8-E1S.js";import{D as ue,E as Ne,F as ke,G as Me,H as Ee,I as xe,J as Ae,K as Ce,u as Pe,L as Ie,M as De,N as he,g as Le,O as ie,P as oe,Q as Te,n as Re,c as Ge}from"./WorkbenchLayout-DlbgBT3n.js";import{f as Oe,a as me,M as We}from"./MobileWorkspaceSwitcherHeader-CuGJ31kb.js";import{M as $e}from"./MobileCreateSessionSheet-Cb2HM-y3.js";import{w as pe}from"./styles-DRVvx_kv.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./WorkbenchModal-LNfB69qx.js";import"./relay-entry-BmLkMKuq.js";import"./MobileTopHeaderFrame-etF2HKlm.js";const Be=420,Fe=156;function He({entry:n,isFavorite:t,isActive:r=!1,depth:d=0,variant:l="default",workspaceTone:N="root",hasSubsessions:m=!1,subsessionsExpanded:k=!1,showActions:z=!0,onActivate:J,onToggleSubsessions:$,onToggleFavorite:ae,onArchive:B,onUnarchive:re,onRename:u}){var C;const[g,L]=h.useState(!1),[T,R]=h.useState(null),[w,F]=h.useState(null),M=h.useRef(null),G=h.useRef(!1),O=h.useRef(null),H=je(),{session:c,workspace:le}=n,V=c.title??c.sessionId,Q=be(c.provider),_=[Q,Ve(c.lastMessageAt??c.updatedAt??null),ue(c)].filter(Boolean).join(" · "),K=Ke(c),U=K?Ue(K):null,W=l==="mobile"?null:ue(c),X=W?Ne("session-list-activity-badge",c):null,E=l!=="mobile",Z=E?ke(c.parallelGroup):null,q=E?Me(c.parallelGroup):null,ce=E?Ee(c.parallelGroup):void 0;h.useEffect(()=>()=>{A()},[]),h.useLayoutEffect(()=>{if(!g||!w||typeof window>"u"){R(null);return}const i=()=>{var P,I;const f=Ae(w,{width:((P=O.current)==null?void 0:P.offsetWidth)??0,height:((I=O.current)==null?void 0:I.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:Fe});R({position:"fixed",left:`${Math.round(f.left)}px`,top:`${Math.round(f.top)}px`,width:`${Math.round(f.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(f.maxHeight)}px`,transformOrigin:f.transformOrigin})},S=f=>{var I;const P=f.target;P&&!((I=O.current)!=null&&I.contains(P))&&y()},ne=f=>{f.key==="Escape"&&y()};return i(),window.addEventListener("pointerdown",S),window.addEventListener("keydown",ne),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",ne),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[w,g]);function Y(i){F(i),L(!0)}function y(){L(!1),F(null)}function A(){M.current!==null&&(window.clearTimeout(M.current),M.current=null)}function ee(i){if(!z||i.pointerType==="mouse")return;const S={x:i.clientX,y:i.clientY};A(),M.current=window.setTimeout(()=>{G.current=!0,H.trigger("gesture"),Y(S)},Be)}function s(){A()}function o(){if(G.current){G.current=!1;return}H.trigger("selection"),J(c.sessionId)}const p=async()=>{const i=window.prompt(a("shell.renameModalDescription"),V);i&&(await u(c.sessionId,i.trim()),y())},v=async()=>{if(c.isArchived){await re(c.sessionId),y();return}await B(c.sessionId),y()},j=()=>{ae(c.sessionId),y()},x=i=>{if(i.key!=="ContextMenu"&&!(i.shiftKey&&i.key==="F10"))return;i.preventDefault(),i.stopPropagation();const S=i.currentTarget.getBoundingClientRect();Y({x:S.right,y:S.bottom})},se=g&&typeof document<"u"?ve.createPortal(e.jsxs("div",{ref:O,className:"session-action-menu surface-card",role:"menu","aria-label":a("shell.sessionMoreAction"),style:T??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:i=>i.stopPropagation(),children:[e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:j,children:t?a("shell.unfavoriteAction"):a("shell.favoriteAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void v(),children:c.isArchived?a("shell.unarchiveAction"):a("shell.archiveAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void p(),children:a("shell.renameAction")})]}),document.body):null;return e.jsxs("article",{className:"session-list-item","data-depth":d,"data-active":r,"data-workspace-tone":N,"data-has-subsessions":m,"data-variant":l,"data-parallel-group":E&&c.parallelGroup?"true":void 0,"data-parallel-role":E?((C=c.parallelGroup)==null?void 0:C.role)??void 0:void 0,style:ce,onContextMenu:i=>{z&&(i.preventDefault(),i.stopPropagation(),Y({x:i.clientX,y:i.clientY}))},children:[m?e.jsx("button",{type:"button",className:"session-list-subsession-toggle","aria-label":k?a("shell.subagentCollapse"):a("shell.subagentExpand"),title:k?a("shell.subagentCollapse"):a("shell.subagentExpand"),"aria-expanded":k,onClick:i=>{i.stopPropagation(),H.trigger("selection"),$==null||$()},children:e.jsx("span",{className:fe(c,{isActive:r,hasSubsessions:m}),"aria-hidden":"true"})}):e.jsx("span",{className:fe(c,{isActive:r,hasSubsessions:m}),"aria-hidden":"true"}),e.jsx("button",{type:"button",className:"session-list-link",onClick:o,onPointerDown:ee,onPointerUp:s,onPointerCancel:s,onPointerLeave:s,onKeyDown:x,children:e.jsxs("div",{className:"session-list-copy",children:[e.jsxs("div",{className:"session-list-title-row",children:[e.jsx("div",{className:"session-list-title",children:V||a("shell.searchEntry")}),Z?e.jsx("span",{className:"session-list-parallel-badge",children:Z}):null,q?e.jsx("span",{className:"session-list-parallel-role-badge",children:q}):null]}),e.jsx("div",{className:"session-list-meta",children:l==="mobile"?e.jsx(e.Fragment,{children:e.jsx("span",{children:_})}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:le.name}),W&&X?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:X,children:W})]}):null,e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:Q})]})}),U?e.jsx("div",{className:"session-list-error",title:K??void 0,children:U}):null]})}),se]})}function fe(n,t){return Ce("session-list-indicator",n,{isActive:t.isActive,hasSubagents:t.hasSubsessions})}function Ve(n){return n?new Date(n).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):a("common.unknown")}function _e(n){return xe(n)||n.syncStatus==="error"}function Ke(n){var d,l;if(!_e(n))return null;const t=((d=n.lastErrorCode)==null?void 0:d.trim())??"",r=((l=n.lastErrorDetail)==null?void 0:l.replace(/\s+/g," ").trim())??"";return t&&r&&!r.includes(t)?`${t} · ${r}`:r||t||(n.syncStatus==="error"&&!xe(n)?a("conversation.syncStatusError"):a("conversation.runtimeErrorTitle"))}function Ue(n,t=96){return n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}const te=5;function us(){var ee;const n=ye(),{navigationGroups:t,favoriteSessionIds:r,currentWorkspaceId:d,currentSessionId:l,navigationLoading:N,selectWorkspace:m,toggleFavoriteSession:k,archiveSession:z,unarchiveSession:J,renameSession:$,startDraftSession:ae}=Pe(),B=Oe(t),re=h.useMemo(()=>Ie(t),[t]),u=me(t,d)??me(t,((ee=t[0])==null?void 0:ee.workspace.id)??null),g=B.find(s=>s.workspace.id===(u==null?void 0:u.workspace.id))??(u?{workspace:u.workspace,label:u.workspace.name,subtitle:u.workspace.path}:null),L=h.useMemo(()=>new Set(r),[r]),T=h.useMemo(()=>u?u.sessions.filter(s=>{if(s.isArchived)return!1;const o=De(s,{mode:"mobile"});if(!o)return!0;const p=u.sessions.find(v=>v.sessionId===o);return!p||!p.isArchived}).map(s=>({session:s,workspace:u.workspace})):[],[u]),R=h.useMemo(()=>T.filter(s=>L.has(s.session.sessionId)),[T,L]),w=h.useMemo(()=>he(T,{mode:"mobile"}),[T]),F=h.useMemo(()=>he(R,{mode:"mobile"}),[R]),M=h.useMemo(()=>u?u.sessions.filter(s=>s.isArchived===!0&&!Le(s)):[],[u]),G=(u==null?void 0:u.workspace.id)??"",O=!!G,[H,c]=h.useState([]),[le,V]=h.useState({}),[Q,_]=h.useState(!1),[K,U]=h.useState(!1),[W,X]=h.useState(null);h.useEffect(()=>{V(s=>{const o={};for(const p of w){const v=ie(oe(p));if(v.length===0)continue;const j=v.findIndex(x=>x.item.session.sessionId===l);o[p.item.session.sessionId]=Qe(v.length,te,s[p.item.session.sessionId],j)}return Ze(s,o)?s:o})},[l,w]),h.useEffect(()=>{if(!l)return;const s=Te(w,l,o=>o.session.sessionId);s.length!==0&&c(o=>{const p=new Set(o);let v=!1;for(const j of s)p.has(j)||(p.add(j),v=!0);return v?Array.from(p):o})},[l,w]);function E(s){c(o=>o.includes(s)?o.filter(p=>p!==s):[...o,s])}function Z(s){return le[s]??te}function q(s){V(o=>({...o,[s]:(o[s]??te)+te}))}function ce(s,o){pe("immersive"),n(Ge(s,o))}function Y(s,o){_(!1),pe("immersive"),ae(s,o)}async function y(s){X(s);try{await J(s)}finally{X(o=>o===s?null:o)}}function A(s,o=!1,p=[],v=!1,j=!1){var de;const x=s.item.session.sessionId,se=s.children,C=s.depth===0&&se.length>0,i=o||C&&H.includes(x),S=i&&C,ne=S?Je(s,Z(x)):s,f=i?ne.children:[],P=ie(se).length,I=ie(f).length,we=S&&I<P,Se=s.depth>0?[...p,v]:[...p];return e.jsxs("div",{className:"session-list-tree-node",children:[e.jsxs("div",{className:"session-list-tree-row",style:{"--session-tree-depth":s.depth},children:[s.depth>0?e.jsxs("div",{className:"session-tree-guides","aria-hidden":"true",style:{"--session-tree-depth":s.depth},children:[p.map((b,D)=>b?e.jsx("span",{className:"session-tree-guide-column",style:{"--session-tree-level":D+1}},`${x}:ancestor:${D}`):null),e.jsx("span",{className:"session-tree-guide-branch","data-continue":v,"data-first":j,style:{"--session-tree-level":s.depth},children:e.jsx("span",{className:"session-tree-guide-branch-horizontal"})})]}):null,e.jsx(He,{entry:s.item,isFavorite:L.has(x),isActive:l===x,depth:s.depth,variant:"mobile",workspaceTone:((de=re[s.item.workspace.id])==null?void 0:de.tone)??"root",hasSubsessions:C,subsessionsExpanded:i,onActivate:b=>ce(s.item.workspace.id,b),onToggleSubsessions:C?()=>E(x):void 0,onToggleFavorite:b=>{k(b)},onArchive:b=>z(b),onUnarchive:b=>J(b),onRename:(b,D)=>$(b,D)})]}),i&&f.length>0?e.jsx("div",{className:"session-list-children",children:f.map((b,D)=>A(b,!0,Se,D<f.length-1,D===0))}):null,we?e.jsx("div",{className:"session-list-children",children:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>q(x),children:a("shell.subagentExpandMore")})}):null]},`${s.item.workspace.id}:${x}`)}return e.jsxs("main",{className:"session-index-page mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(We,{currentWorkspace:g?{id:g.workspace.id,name:g.label,path:g.subtitle}:null,workspaces:t.map(s=>s.workspace),workspaceOptions:B,onSelectWorkspace:s=>{m(s),n(Re(s))},content:e.jsx("button",{type:"button",className:"primary-button mobile-session-index-create-button",disabled:N||!O,onClick:()=>_(!0),children:a("shell.createSession")})}),e.jsxs("div",{className:"mobile-page-top-body",children:[e.jsx("div",{className:"session-index-archive-actions",children:e.jsxs("button",{type:"button",className:"primary-button mobile-session-index-create-button session-index-archive-button",disabled:N||!u,onClick:()=>U(!0),children:[e.jsx("span",{children:a("shell.archiveViewAction")}),e.jsx("span",{className:"session-index-archive-count",children:M.length})]})}),F.length>0?e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.favoriteSectionTitle")})}),e.jsx("span",{className:"session-section-count",children:R.length})]}),e.jsx("div",{className:"session-current-workspace-list",children:F.map(s=>A(s))})]}):null,e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.mobileConversationCurrentWorkspaceSection")})}),e.jsx("span",{className:"session-section-count",children:w.length})]}),w.length===0?e.jsx("p",{className:"session-section-empty",children:N?a("shell.searchSessionHint"):a("shell.emptyWorkspaceSessions")}):e.jsx("div",{className:"session-current-workspace-list",children:w.map(s=>A(s))})]})]}),e.jsx($e,{open:Q,workspaces:t.map(s=>s.workspace),workspaceOptions:B,initialWorkspaceId:d??G,onClose:()=>_(!1),onSelect:Y}),e.jsx(Xe,{open:K,workspaceName:(g==null?void 0:g.label)??(u==null?void 0:u.workspace.name)??null,sessions:M,restoringSessionId:W,onClose:()=>{W||U(!1)},onRestore:s=>void y(s)})]})}function Xe({open:n,workspaceName:t,sessions:r,restoringSessionId:d,onClose:l,onRestore:N}){return h.useEffect(()=>{if(!n)return;function m(k){k.key==="Escape"&&!d&&l()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[l,n,d]),!n||typeof document>"u"?null:ve.createPortal(e.jsxs("div",{className:"workbench-modal-layer",children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":a("common.close"),disabled:!!d,onClick:l}),e.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":a("shell.archiveModalTitle"),children:[e.jsx("div",{className:"workbench-modal-header",children:e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{children:a("shell.archiveModalTitle")}),e.jsx("p",{children:t?`${t} · ${a("shell.archiveModalDescription")}`:a("shell.archiveModalDescription")})]})}),e.jsx("div",{className:"workbench-modal-body",children:r.length>0?e.jsx("div",{className:"workbench-archive-list",children:r.map(m=>e.jsxs("article",{className:"workbench-archive-item",children:[e.jsxs("div",{className:"workbench-archive-item-main",children:[e.jsx("strong",{title:m.title??m.sessionId,children:m.title??m.sessionId}),e.jsx("p",{children:Ye(m)})]}),e.jsx("button",{type:"button",className:"secondary-button",disabled:d===m.sessionId,onClick:()=>{N(m.sessionId)},children:a("shell.unarchiveAction")})]},m.sessionId))}):e.jsx("p",{className:"workbench-section-empty",children:a("shell.archiveEmpty")})})]})]}),document.body)}function Ye(n){const t=be(n.provider),r=ze(n.lastMessageAt??n.updatedAt??null);return[t,r].filter(Boolean).join(" · ")}function ze(n){if(!n)return null;const t=Date.parse(n);return Number.isNaN(t)?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}function Je(n,t){const r=new Set(ie(oe(n)).sort((d,l)=>(l.item.session.lastMessageAt??l.item.session.updatedAt).localeCompare(d.item.session.lastMessageAt??d.item.session.updatedAt)).slice(0,t).map(d=>d.item.session.sessionId));return{...n,children:ge(oe(n),r)}}function ge(n,t){return n.flatMap(r=>{const d=ge(oe(r),t);return!t.has(r.item.session.sessionId)&&d.length===0?[]:[{...r,children:d}]})}function Qe(n,t,r,d=-1){if(n<=0)return 0;const l=d>=0?Math.max(t,d+1):t;return Math.min(n,Math.max(r??0,l))}function Ze(n,t){const r=Object.keys(n),d=Object.keys(t);return r.length!==d.length?!1:r.every(l=>n[l]===t[l])}export{us as SessionIndexPage};