@jingyi0605/codingns 0.9.0 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/bin/codingns.mjs +75 -0
  2. package/dist/public/assets/{AdaptiveButlerPage-B17QiMyT.js → AdaptiveButlerPage-khJQh6a_.js} +2 -2
  3. package/dist/public/assets/{App-CFBwDUNA.js → App-If9gThKM.js} +6 -6
  4. package/dist/public/assets/{BootstrapPage-W5wU3BPh.js → BootstrapPage-DcfYtoLC.js} +1 -1
  5. package/dist/public/assets/{ConversationPage-DQLX1bUh.js → ConversationPage-Bfb7GLTM.js} +1 -1
  6. package/dist/public/assets/{DesktopDetachPreviewPage-DTPeuAW-.js → DesktopDetachPreviewPage-CXUPMcBz.js} +1 -1
  7. package/dist/public/assets/{DesktopModal-6ii53_Y9.js → DesktopModal-bMdI1jEe.js} +1 -1
  8. package/dist/public/assets/DesktopWindowPage-D1xwgS-7.js +2 -0
  9. package/dist/public/assets/FileContextPanel-C4syif3B.js +1 -0
  10. package/dist/public/assets/GitSidebar-DduL9aTV.js +6 -0
  11. package/dist/public/assets/MobileCreateSessionSheet-DWPBsEx8.js +1 -0
  12. package/dist/public/assets/{MobileSheet-opTWyRe1.js → MobileSheet-BXvQPkxt.js} +1 -1
  13. package/dist/public/assets/{MobileTopHeaderFrame-BbNON3Y4.js → MobileTopHeaderFrame-vdYOyaaB.js} +1 -1
  14. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-BZEzPeMj.js → MobileWorkspaceSwitcherHeader-DT330cAx.js} +1 -1
  15. package/dist/public/assets/{PluginAccessOverview-mQDmAljp.js → PluginAccessOverview-C77TeZTK.js} +1 -1
  16. package/dist/public/assets/{PluginContainerPage-CcxUJpM4.js → PluginContainerPage-DdSwOCw-.js} +1 -1
  17. package/dist/public/assets/{PluginDetailPage-D5--ACIt.js → PluginDetailPage-BK1yTzvO.js} +1 -1
  18. package/dist/public/assets/{PluginsListPage-D_oJxYXT.js → PluginsListPage-DAAwSc6W.js} +1 -1
  19. package/dist/public/assets/{RelayConnectEntryPage-DROxpnkv.js → RelayConnectEntryPage-4Yyo2p8b.js} +1 -1
  20. package/dist/public/assets/{ServerSettingsModal-CUUOPqSe.js → ServerSettingsModal-C_DEisHs.js} +1 -1
  21. package/dist/public/assets/{SessionIndexPage-C2Jxh6Gp.js → SessionIndexPage-DyMikN_x.js} +1 -1
  22. package/dist/public/assets/SettingsPage-CDAVsPr3.js +2 -0
  23. package/dist/public/assets/TerminalManagerPanel-4OR47vcf.js +1 -0
  24. package/dist/public/assets/{TerminalPage-CwWyFDj8.js → TerminalPage-Pvx396YX.js} +1 -1
  25. package/dist/public/assets/{TerminalRuntimeFallbackModal-CSVVbO8r.js → TerminalRuntimeFallbackModal-KvG6k4AQ.js} +1 -1
  26. package/dist/public/assets/{ToolFilesPage-QBEY8oCf.js → ToolFilesPage-DrYHk0N-.js} +1 -1
  27. package/dist/public/assets/{ToolGitPage-BKoZ2l9v.js → ToolGitPage-Dz1q-Ns_.js} +1 -1
  28. package/dist/public/assets/{ToolProcessesPage-BOH0ib4G.js → ToolProcessesPage-CRhphOmM.js} +1 -1
  29. package/dist/public/assets/{ToolsHomePage-BcMZ3BCQ.js → ToolsHomePage-BJSDLR6T.js} +1 -1
  30. package/dist/public/assets/{WorkbenchLandingPage-B5zoppEl.js → WorkbenchLandingPage-BlkxdOLC.js} +1 -1
  31. package/dist/public/assets/WorkbenchLayout-D-U7ghT0.js +1022 -0
  32. package/dist/public/assets/{WorkbenchModal-NGmPgqaE.js → WorkbenchModal-xbx1o6MO.js} +1 -1
  33. package/dist/public/assets/WorkbenchShellRoute-DyWSCHz_.js +1 -0
  34. package/dist/public/assets/WorkbenchShellRoute-htbkGbtW.css +1 -0
  35. package/dist/public/assets/WorkspaceDebugDetailPage-B4ol2_a5.js +1 -0
  36. package/dist/public/assets/WorkspaceDetailPage-DMakfmHR.js +1 -0
  37. package/dist/public/assets/WorkspaceHomePage-tmCafatd.js +1 -0
  38. package/dist/public/assets/{client-runtime-manager-DXbI9K1K.js → client-runtime-manager-Bwau7p1v.js} +1 -1
  39. package/dist/public/assets/index-DmUJ8tIw.css +1 -0
  40. package/dist/public/assets/index-_OCkVmfl.js +50 -0
  41. package/dist/public/assets/{login-direct-candidate-resolver-DkKyFtQJ.js → login-direct-candidate-resolver-CKUQ07IA.js} +1 -1
  42. package/dist/public/assets/{plugin-permission-copy-CzN269Bk.js → plugin-permission-copy-DIVk5jNp.js} +1 -1
  43. package/dist/public/assets/{plugins-api-Bv9DHpLF.js → plugins-api-DHJVvPZw.js} +1 -1
  44. package/dist/public/assets/{preferences-service-D2ISL2Zz.js → preferences-service-CyxxeBmS.js} +1 -1
  45. package/dist/public/assets/{relay-entry-Bg0OisQy.js → relay-entry-B5GmiOrR.js} +1 -1
  46. package/dist/public/assets/{terminal-runtime-meta-C8t-CIDF.js → terminal-runtime-meta-DBsyT35T.js} +1 -1
  47. package/dist/public/assets/useRegisteredDebugTemplates-wCGD2SLW.js +1 -0
  48. package/dist/public/assets/workbench-navigation-RyUjchbD.js +1 -0
  49. package/dist/public/index.html +2 -2
  50. package/dist/server/config/env.d.ts +1 -0
  51. package/dist/server/config/env.js +3 -0
  52. package/dist/server/config/env.js.map +1 -1
  53. package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.js.map +1 -1
  54. package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.d.ts +1 -0
  55. package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js +31 -0
  56. package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js.map +1 -1
  57. package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.js.map +1 -1
  58. package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.d.ts +1 -0
  59. package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js +1 -0
  60. package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js.map +1 -1
  61. package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js +4 -1
  62. package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js.map +1 -1
  63. package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js +140 -16
  64. package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js.map +1 -1
  65. package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js +2 -2
  66. package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js.map +1 -1
  67. package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.d.ts +20 -3
  68. package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js +3 -3
  69. package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js.map +1 -1
  70. package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +1 -1
  71. package/dist/server/modules/assistant-capability/assistant-capability-controller.js +8 -7
  72. package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
  73. package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +14 -13
  74. package/dist/server/modules/assistant-capability/assistant-capability-service.js +27 -24
  75. package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
  76. package/dist/server/modules/auth/auth-controller.d.ts +27 -1
  77. package/dist/server/modules/auth/auth-controller.js +20 -0
  78. package/dist/server/modules/auth/auth-controller.js.map +1 -1
  79. package/dist/server/modules/auth/auth-service.d.ts +32 -1
  80. package/dist/server/modules/auth/auth-service.js +217 -2
  81. package/dist/server/modules/auth/auth-service.js.map +1 -1
  82. package/dist/server/modules/bootstrap/bootstrap-service.js +1 -0
  83. package/dist/server/modules/bootstrap/bootstrap-service.js.map +1 -1
  84. package/dist/server/modules/butler/assistant-automation-service.d.ts +1 -1
  85. package/dist/server/modules/butler/assistant-automation-service.js +9 -10
  86. package/dist/server/modules/butler/assistant-automation-service.js.map +1 -1
  87. package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.d.ts +32 -0
  88. package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js +93 -0
  89. package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js.map +1 -0
  90. package/dist/server/modules/butler/assistant-sandbox-service.d.ts +69 -0
  91. package/dist/server/modules/butler/assistant-sandbox-service.js +399 -0
  92. package/dist/server/modules/butler/assistant-sandbox-service.js.map +1 -0
  93. package/dist/server/modules/butler/butler-action-context-service.js +2 -2
  94. package/dist/server/modules/butler/butler-action-context-service.js.map +1 -1
  95. package/dist/server/modules/butler/butler-control-action-service.d.ts +5 -5
  96. package/dist/server/modules/butler/butler-control-action-service.js +19 -19
  97. package/dist/server/modules/butler/butler-control-action-service.js.map +1 -1
  98. package/dist/server/modules/butler/butler-control-session-service.d.ts +1 -1
  99. package/dist/server/modules/butler/butler-control-session-service.js +27 -26
  100. package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
  101. package/dist/server/modules/butler/butler-control-timer-service.js +4 -5
  102. package/dist/server/modules/butler/butler-control-timer-service.js.map +1 -1
  103. package/dist/server/modules/butler/butler-controller.d.ts +2 -2
  104. package/dist/server/modules/butler/butler-controller.js +19 -17
  105. package/dist/server/modules/butler/butler-controller.js.map +1 -1
  106. package/dist/server/modules/butler/butler-follow-up-service.d.ts +3 -0
  107. package/dist/server/modules/butler/butler-follow-up-service.js +11 -1
  108. package/dist/server/modules/butler/butler-follow-up-service.js.map +1 -1
  109. package/dist/server/modules/butler/butler-inbox-service.d.ts +3 -0
  110. package/dist/server/modules/butler/butler-inbox-service.js +14 -2
  111. package/dist/server/modules/butler/butler-inbox-service.js.map +1 -1
  112. package/dist/server/modules/butler/butler-profile-service.d.ts +5 -5
  113. package/dist/server/modules/butler/butler-profile-service.js +17 -16
  114. package/dist/server/modules/butler/butler-profile-service.js.map +1 -1
  115. package/dist/server/modules/butler/butler-project-service.d.ts +7 -6
  116. package/dist/server/modules/butler/butler-project-service.js +35 -21
  117. package/dist/server/modules/butler/butler-project-service.js.map +1 -1
  118. package/dist/server/modules/butler/butler-session-service.d.ts +5 -2
  119. package/dist/server/modules/butler/butler-session-service.js +51 -27
  120. package/dist/server/modules/butler/butler-session-service.js.map +1 -1
  121. package/dist/server/modules/butler/butler-session-summary-service.d.ts +2 -2
  122. package/dist/server/modules/butler/butler-session-summary-service.js +23 -9
  123. package/dist/server/modules/butler/butler-session-summary-service.js.map +1 -1
  124. package/dist/server/modules/butler/context-aggregator.js +9 -9
  125. package/dist/server/modules/butler/context-aggregator.js.map +1 -1
  126. package/dist/server/modules/butler/patrol-execution-service.d.ts +0 -1
  127. package/dist/server/modules/butler/patrol-execution-service.js +6 -12
  128. package/dist/server/modules/butler/patrol-execution-service.js.map +1 -1
  129. package/dist/server/modules/channels/wechat-claw-client.d.ts +51 -0
  130. package/dist/server/modules/channels/wechat-claw-client.js +245 -0
  131. package/dist/server/modules/channels/wechat-claw-client.js.map +1 -0
  132. package/dist/server/modules/file/file-controller.d.ts +11 -2
  133. package/dist/server/modules/file/file-controller.js +404 -17
  134. package/dist/server/modules/file/file-controller.js.map +1 -1
  135. package/dist/server/modules/file/file-search-service.js +200 -12
  136. package/dist/server/modules/file/file-search-service.js.map +1 -1
  137. package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +18 -5
  138. package/dist/server/modules/file/workspace-file-bridge-service.d.ts +9 -0
  139. package/dist/server/modules/file/workspace-file-bridge-service.js +3 -0
  140. package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -1
  141. package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +9 -0
  142. package/dist/server/modules/file/workspace-file-bridge-watch-service.js +28 -0
  143. package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -1
  144. package/dist/server/modules/sessions/session-controller.js +3 -3
  145. package/dist/server/modules/sessions/session-controller.js.map +1 -1
  146. package/dist/server/modules/sessions/session-history-service.d.ts +8 -3
  147. package/dist/server/modules/sessions/session-history-service.js +126 -11
  148. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  149. package/dist/server/modules/sessions/session-live-runtime-service.js +25 -15
  150. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  151. package/dist/server/modules/sessions/session-permission-request-service.js +28 -15
  152. package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
  153. package/dist/server/modules/tasks/task-types.d.ts +1 -0
  154. package/dist/server/modules/tasks/task-types.js +1 -0
  155. package/dist/server/modules/tasks/task-types.js.map +1 -1
  156. package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.d.ts +1 -1
  157. package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js +22 -5
  158. package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js.map +1 -1
  159. package/dist/server/modules/workbench/workbench-controller.d.ts +5 -0
  160. package/dist/server/modules/workbench/workbench-controller.js +20 -0
  161. package/dist/server/modules/workbench/workbench-controller.js.map +1 -1
  162. package/dist/server/modules/workbench/workbench-service.d.ts +6 -6
  163. package/dist/server/modules/workbench/workbench-service.js +42 -45
  164. package/dist/server/modules/workbench/workbench-service.js.map +1 -1
  165. package/dist/server/modules/workspace/affairs-library-controller.d.ts +8 -0
  166. package/dist/server/modules/workspace/affairs-library-controller.js +11 -0
  167. package/dist/server/modules/workspace/affairs-library-controller.js.map +1 -1
  168. package/dist/server/modules/workspace/affairs-library-preview-link-service.d.ts +6 -0
  169. package/dist/server/modules/workspace/affairs-library-preview-link-service.js +12 -2
  170. package/dist/server/modules/workspace/affairs-library-preview-link-service.js.map +1 -1
  171. package/dist/server/modules/workspace/affairs-library-service.d.ts +12 -1
  172. package/dist/server/modules/workspace/affairs-library-service.js +294 -96
  173. package/dist/server/modules/workspace/affairs-library-service.js.map +1 -1
  174. package/dist/server/modules/workspace/affairs-lightweight-session-controller.d.ts +8 -0
  175. package/dist/server/modules/workspace/affairs-lightweight-session-controller.js +55 -8
  176. package/dist/server/modules/workspace/affairs-lightweight-session-controller.js.map +1 -1
  177. package/dist/server/modules/workspace/affairs-lightweight-session-service.d.ts +13 -0
  178. package/dist/server/modules/workspace/affairs-lightweight-session-service.js +167 -21
  179. package/dist/server/modules/workspace/affairs-lightweight-session-service.js.map +1 -1
  180. package/dist/server/modules/workspace/affairs-tag-controller.d.ts +3 -0
  181. package/dist/server/modules/workspace/affairs-tag-controller.js +5 -0
  182. package/dist/server/modules/workspace/affairs-tag-controller.js.map +1 -1
  183. package/dist/server/modules/workspace/affairs-tag-service.d.ts +34 -1
  184. package/dist/server/modules/workspace/affairs-tag-service.js +568 -4
  185. package/dist/server/modules/workspace/affairs-tag-service.js.map +1 -1
  186. package/dist/server/modules/workspace/teable-api-client.d.ts +118 -0
  187. package/dist/server/modules/workspace/teable-api-client.js +142 -0
  188. package/dist/server/modules/workspace/teable-api-client.js.map +1 -0
  189. package/dist/server/modules/workspace/teable-catalog-controller.d.ts +18 -0
  190. package/dist/server/modules/workspace/teable-catalog-controller.js +17 -0
  191. package/dist/server/modules/workspace/teable-catalog-controller.js.map +1 -0
  192. package/dist/server/modules/workspace/teable-catalog-service.d.ts +36 -0
  193. package/dist/server/modules/workspace/teable-catalog-service.js +124 -0
  194. package/dist/server/modules/workspace/teable-catalog-service.js.map +1 -0
  195. package/dist/server/modules/workspace/teable-credential-service.d.ts +8 -0
  196. package/dist/server/modules/workspace/teable-credential-service.js +37 -0
  197. package/dist/server/modules/workspace/teable-credential-service.js.map +1 -0
  198. package/dist/server/modules/workspace/teable-field-mapping-controller.d.ts +25 -0
  199. package/dist/server/modules/workspace/teable-field-mapping-controller.js +31 -0
  200. package/dist/server/modules/workspace/teable-field-mapping-controller.js.map +1 -0
  201. package/dist/server/modules/workspace/teable-field-mapping-service.d.ts +38 -0
  202. package/dist/server/modules/workspace/teable-field-mapping-service.js +215 -0
  203. package/dist/server/modules/workspace/teable-field-mapping-service.js.map +1 -0
  204. package/dist/server/modules/workspace/teable-global-binding-controller.d.ts +22 -0
  205. package/dist/server/modules/workspace/teable-global-binding-controller.js +25 -0
  206. package/dist/server/modules/workspace/teable-global-binding-controller.js.map +1 -0
  207. package/dist/server/modules/workspace/teable-global-binding-service.d.ts +35 -0
  208. package/dist/server/modules/workspace/teable-global-binding-service.js +151 -0
  209. package/dist/server/modules/workspace/teable-global-binding-service.js.map +1 -0
  210. package/dist/server/modules/workspace/teable-mirror-sync-controller.d.ts +29 -0
  211. package/dist/server/modules/workspace/teable-mirror-sync-controller.js +50 -0
  212. package/dist/server/modules/workspace/teable-mirror-sync-controller.js.map +1 -0
  213. package/dist/server/modules/workspace/teable-mirror-sync-service.d.ts +157 -0
  214. package/dist/server/modules/workspace/teable-mirror-sync-service.js +917 -0
  215. package/dist/server/modules/workspace/teable-mirror-sync-service.js.map +1 -0
  216. package/dist/server/modules/workspace/teable-runtime-controller.d.ts +58 -0
  217. package/dist/server/modules/workspace/teable-runtime-controller.js +60 -0
  218. package/dist/server/modules/workspace/teable-runtime-controller.js.map +1 -0
  219. package/dist/server/modules/workspace/teable-runtime-service.d.ts +96 -0
  220. package/dist/server/modules/workspace/teable-runtime-service.js +362 -0
  221. package/dist/server/modules/workspace/teable-runtime-service.js.map +1 -0
  222. package/dist/server/modules/workspace/teable-workbench-sync-config-controller.d.ts +22 -0
  223. package/dist/server/modules/workspace/teable-workbench-sync-config-controller.js +20 -0
  224. package/dist/server/modules/workspace/teable-workbench-sync-config-controller.js.map +1 -0
  225. package/dist/server/modules/workspace/teable-workbench-sync-config-service.d.ts +22 -0
  226. package/dist/server/modules/workspace/teable-workbench-sync-config-service.js +159 -0
  227. package/dist/server/modules/workspace/teable-workbench-sync-config-service.js.map +1 -0
  228. package/dist/server/modules/workspace/workspace-controller.d.ts +1 -1
  229. package/dist/server/modules/workspace/workspace-controller.js +7 -7
  230. package/dist/server/modules/workspace/workspace-controller.js.map +1 -1
  231. package/dist/server/modules/workspace/workspace-service.d.ts +7 -0
  232. package/dist/server/modules/workspace/workspace-service.js +151 -10
  233. package/dist/server/modules/workspace/workspace-service.js.map +1 -1
  234. package/dist/server/routes/affairs.d.ts +9 -1
  235. package/dist/server/routes/affairs.js +120 -1
  236. package/dist/server/routes/affairs.js.map +1 -1
  237. package/dist/server/routes/auth.js +6 -0
  238. package/dist/server/routes/auth.js.map +1 -1
  239. package/dist/server/routes/workbench.js +15 -0
  240. package/dist/server/routes/workbench.js.map +1 -1
  241. package/dist/server/routes/workspaces.js +51 -41
  242. package/dist/server/routes/workspaces.js.map +1 -1
  243. package/dist/server/server/create-server.d.ts +18 -0
  244. package/dist/server/server/create-server.js +99 -7
  245. package/dist/server/server/create-server.js.map +1 -1
  246. package/dist/server/server/start-host.js +20 -0
  247. package/dist/server/server/start-host.js.map +1 -1
  248. package/dist/server/shared/http/request-diagnostics.d.ts +56 -0
  249. package/dist/server/shared/http/request-diagnostics.js +256 -0
  250. package/dist/server/shared/http/request-diagnostics.js.map +1 -0
  251. package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.d.ts +18 -0
  252. package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js +191 -0
  253. package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js.map +1 -0
  254. package/dist/server/storage/repositories/auth-token-repository.d.ts +1 -0
  255. package/dist/server/storage/repositories/auth-token-repository.js +8 -0
  256. package/dist/server/storage/repositories/auth-token-repository.js.map +1 -1
  257. package/dist/server/storage/repositories/auth-user-repository.d.ts +50 -0
  258. package/dist/server/storage/repositories/auth-user-repository.js +198 -27
  259. package/dist/server/storage/repositories/auth-user-repository.js.map +1 -1
  260. package/dist/server/storage/repositories/butler-control-session-repository.d.ts +4 -1
  261. package/dist/server/storage/repositories/butler-control-session-repository.js +55 -8
  262. package/dist/server/storage/repositories/butler-control-session-repository.js.map +1 -1
  263. package/dist/server/storage/repositories/butler-profile-repository.d.ts +2 -1
  264. package/dist/server/storage/repositories/butler-profile-repository.js +35 -6
  265. package/dist/server/storage/repositories/butler-profile-repository.js.map +1 -1
  266. package/dist/server/storage/repositories/butler-project-repository.d.ts +2 -0
  267. package/dist/server/storage/repositories/butler-project-repository.js +38 -4
  268. package/dist/server/storage/repositories/butler-project-repository.js.map +1 -1
  269. package/dist/server/storage/repositories/butler-session-repository.d.ts +2 -1
  270. package/dist/server/storage/repositories/butler-session-repository.js +35 -6
  271. package/dist/server/storage/repositories/butler-session-repository.js.map +1 -1
  272. package/dist/server/storage/repositories/session-binding-repository.d.ts +3 -0
  273. package/dist/server/storage/repositories/session-binding-repository.js +70 -2
  274. package/dist/server/storage/repositories/session-binding-repository.js.map +1 -1
  275. package/dist/server/storage/repositories/session-index-repository.js +7 -5
  276. package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
  277. package/dist/server/storage/repositories/user-affairs-library-setting-repository.js +8 -5
  278. package/dist/server/storage/repositories/user-affairs-library-setting-repository.js.map +1 -1
  279. package/dist/server/storage/repositories/user-teable-credential-repository.d.ts +9 -0
  280. package/dist/server/storage/repositories/user-teable-credential-repository.js +45 -0
  281. package/dist/server/storage/repositories/user-teable-credential-repository.js.map +1 -0
  282. package/dist/server/storage/repositories/user-teable-field-mapping-repository.d.ts +10 -0
  283. package/dist/server/storage/repositories/user-teable-field-mapping-repository.js +69 -0
  284. package/dist/server/storage/repositories/user-teable-field-mapping-repository.js.map +1 -0
  285. package/dist/server/storage/repositories/user-teable-global-setting-repository.d.ts +8 -0
  286. package/dist/server/storage/repositories/user-teable-global-setting-repository.js +52 -0
  287. package/dist/server/storage/repositories/user-teable-global-setting-repository.js.map +1 -0
  288. package/dist/server/storage/repositories/user-teable-mirror-record-mapping-repository.d.ts +9 -0
  289. package/dist/server/storage/repositories/user-teable-mirror-record-mapping-repository.js +66 -0
  290. package/dist/server/storage/repositories/user-teable-mirror-record-mapping-repository.js.map +1 -0
  291. package/dist/server/storage/repositories/user-teable-mirror-table-binding-repository.d.ts +9 -0
  292. package/dist/server/storage/repositories/user-teable-mirror-table-binding-repository.js +67 -0
  293. package/dist/server/storage/repositories/user-teable-mirror-table-binding-repository.js.map +1 -0
  294. package/dist/server/storage/repositories/user-teable-sync-log-repository.d.ts +14 -0
  295. package/dist/server/storage/repositories/user-teable-sync-log-repository.js +97 -0
  296. package/dist/server/storage/repositories/user-teable-sync-log-repository.js.map +1 -0
  297. package/dist/server/storage/repositories/user-teable-workbench-sync-config-repository.d.ts +8 -0
  298. package/dist/server/storage/repositories/user-teable-workbench-sync-config-repository.js +55 -0
  299. package/dist/server/storage/repositories/user-teable-workbench-sync-config-repository.js.map +1 -0
  300. package/dist/server/storage/repositories/workspace-repository.d.ts +3 -1
  301. package/dist/server/storage/repositories/workspace-repository.js +24 -10
  302. package/dist/server/storage/repositories/workspace-repository.js.map +1 -1
  303. package/dist/server/storage/sqlite/client.js +692 -1
  304. package/dist/server/storage/sqlite/client.js.map +1 -1
  305. package/dist/server/storage/sqlite/schema.sql +200 -10
  306. package/dist/server/types/domain.d.ts +114 -1
  307. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +34 -7
  308. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -1
  309. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +3 -7
  310. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
  311. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.d.ts +22 -3
  312. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js +29 -2
  313. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js.map +1 -1
  314. package/node_modules/@codingns/session-sync-core/package.json +3 -1
  315. package/package.json +1 -1
  316. package/dist/public/assets/DesktopWindowPage-D0blSuKd.js +0 -2
  317. package/dist/public/assets/FileContextPanel-BrKO8Xt6.js +0 -1
  318. package/dist/public/assets/GitSidebar-BdwiDtOr.js +0 -6
  319. package/dist/public/assets/MobileCreateSessionSheet-Cx_dBiBb.js +0 -1
  320. package/dist/public/assets/SettingsPage-BlAZCHsy.js +0 -2
  321. package/dist/public/assets/TerminalManagerPanel-CjzbiWjl.js +0 -1
  322. package/dist/public/assets/WorkbenchLayout-CikJBS62.js +0 -1019
  323. package/dist/public/assets/WorkbenchShellRoute-BbbSOiZw.js +0 -1
  324. package/dist/public/assets/WorkbenchShellRoute-DT3VMjWD.css +0 -1
  325. package/dist/public/assets/WorkspaceDebugDetailPage-CVivdPx5.js +0 -1
  326. package/dist/public/assets/WorkspaceDetailPage-DgOSjscR.js +0 -1
  327. package/dist/public/assets/WorkspaceHomePage-HPa7M_Vh.js +0 -1
  328. package/dist/public/assets/index-BxJPQpFM.css +0 -1
  329. package/dist/public/assets/index-CeXGOT_T.js +0 -50
  330. package/dist/public/assets/useRegisteredDebugTemplates-Bol3NVfN.js +0 -1
  331. package/dist/public/assets/workbench-navigation-B7IjRQd8.js +0 -1
@@ -1 +0,0 @@
1
- import{b as c,E as tn,j as i,t as r,F as ft,A as In}from"./index-CeXGOT_T.js";import{f as ei,e as Fi,g as _i}from"./App-CFBwDUNA.js";import{bA as Ai,bB as Li,bC as ti,bD as nn,bE as Bi,bF as Mt,bG as Rt,f as Wi,u as $i,ai as Fe,bH as Qt,bI as Oi,bJ as Hi,bK as Vi,bL as ut,bM as gt,bN as Xe,bO as Ui,bP as zi,bQ as Ki,bR as Gi,bS as Xi}from"./WorkbenchLayout-CikJBS62.js";import{k as qi,M as Yi}from"./workbench-navigation-B7IjRQd8.js";import{W as $n}from"./WorkbenchModal-NGmPgqaE.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-6ii53_Y9.js";import"./relay-entry-Bg0OisQy.js";import"./MobileSheet-opTWyRe1.js";async function Nt(t,n){const[l,s]=await Promise.all([Ai(n),Li(t)]);return Ji(l.changes,s.items)}function Ji(t,n){const l=new Set(n.map(s=>Et(s.path)));return t.filter(s=>l.has(Et(s.path))||s.oldPath!==null&&l.has(Et(s.oldPath)))}function Qi(t){const n=On("","");for(const l of t){const s=Et(l.path),m=s.split("/").filter(Boolean);let h=n;m.forEach((b,x)=>{const j=m.slice(0,x+1).join("/");if(x===m.length-1){h.children.set(`file:${j}`,{kind:"file",name:b,path:s,change:l});return}const F=`directory:${j}`,M=h.children.get(F);if(M&&M.kind==="directory"){h=M;return}const Z=On(b,j);h.children.set(F,Z),h=Z})}return ai(ii([...n.children.values()]))}function ni(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return ln(t)?`${l} ${n}`:l}function ln(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 On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ii(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ii([...n.children.values()])}:n)}function ai(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=ai(n.children);let s=n.name,m=n.path,h=l;for(;h.length===1&&((b=h[0])==null?void 0:b.kind)==="directory";){const x=h[0];s=`${s}/${x.name}`,m=x.path,h=x.children}return{kind:"directory",name:s,path:m,children:h}})}const Zi=450,Ii=60*1e3,Hn=20,Vn=16;function ea({sessionId:t,workspaceId:n,showSystemFiles:l,selectedPath:s,refreshVersion:m,onCountChange:h,onSelectFile:b,onOpenFile:x}){const[j,F]=c.useState("tree"),[M,Z]=c.useState([]),[ye,K]=c.useState(!0),[xe,ge]=c.useState(!1),[G,ht]=c.useState([]),E=c.useRef(null),Ft=ti(),{showToast:Ne}=ei();c.useEffect(()=>{const p=tn(Ct(n,t),Ii);F("tree"),Z(p??[]),K(p===null),ge(!1),ht([]),E.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function w(){K(!0);try{const v=await Nt(t,n);p||(Z(v),ft(Ct(n,t),v))}catch(v){p||Ne({title:Zt(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||K(!1)}}return w(),()=>{p=!0}},[m,t,Ne,n]);async function De(){K(!0);try{const p=await Nt(t,n);Z(p),ft(Ct(n,t),p)}catch(p){Ne({title:Zt(p,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{K(!1)}}async function D(){if(R.length!==0){ge(!0);try{await Bi(n,R.map(w=>w.path));const p=await Nt(t,n);Z(p),ft(Ct(n,t),p),Ne({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){Ne({title:Zt(p,r("git.stageFailed")),tone:"error"})}finally{ge(!1)}}}function _(p){ht(w=>w.includes(p)?w.filter(v=>v!==p):[...w,p])}function X(p){const w=Date.now(),v=E.current;return E.current={filePath:p,timestamp:w},(v==null?void 0:v.filePath)===p&&w-v.timestamp<=Zi}async function $(p,w){if(w&&X(p)){await x(p),E.current=null;return}w||(E.current=null),await b(p)}const ie=c.useMemo(()=>nn(M,p=>Dt(p.path),l),[M,l]),R=ie.filter(p=>!p.staged),_e=Qi(ie),ae=new Set(G);return c.useEffect(()=>{h==null||h(ie.length)},[h,ie.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":r("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:j==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="tree",onClick:()=>F("tree"),children:r("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:j==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="list",onClick:()=>F("list"),children:r("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void De(),disabled:ye||xe,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void D(),disabled:xe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ie.length}`}),i.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),i.jsx("div",{ref:Ft,className:"file-tree","data-scrollbar-autohide":"true",children:ye?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ie.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):j==="tree"?li({nodes:_e,depth:0,collapsedPathSet:ae,selectedPath:s,onToggleTreePath:_,onFileClick:$}):ta({items:ie,selectedPath:s,onFileClick:$})})]})}function li({nodes:t,depth:n,collapsedPathSet:l,selectedPath:s,onToggleTreePath:m,onFileClick:h}){return t.map(b=>{if(b.kind==="directory"){const x=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":x,style:{paddingInlineStart:`${Hn+n*Vn}px`},onClick:()=>m(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:x?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),x?i.jsx("div",{className:"file-tree-children",children:li({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:s,onToggleTreePath:m,onFileClick:h})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":s===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Hn+n*Vn}px`},onClick:()=>void h(b.change.path,!ln(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(b.name),"aria-hidden":"true",children:Mt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:ni(b.change,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function ta({items:t,selectedPath:n,onFileClick:l}){return t.map(s=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===s.path,onClick:()=>void l(s.path,!ln(s)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(s.path)),"aria-hidden":"true",children:Mt(Dt(s.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Dt(s.path)}),i.jsx("span",{className:"file-tree-path",children:ni(s,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":s.status,children:s.status}),i.jsx("span",{className:"file-session-badge subtle",children:s.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${s.path}`))}function Ct(t,n){return`file-panel.session-changes.${t}.${n}`}function Zt(t,n){return t instanceof In?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const g="",na=450,ne=8,Pt=4,ia=176,aa=120,la=300*1e3,oa=60*1e3,Un=1600,ra=220,sa=20,ca=16;function ua(){if(typeof document>"u")return;const t=document.querySelector(".workbench-modal-card.file-viewer-modal"),n=t==null?void 0:t.getBoundingClientRect();if(!(!n||n.width<=0||n.height<=0))return{width:Math.round(n.width),height:Math.round(n.height),minWidth:720,minHeight:480}}function nl({className:t,sessionId:n,workspaceId:l,hideHeading:s=!1,hideTabs:m=!1,externalRevealRequest:h=null,externalWindowMode:b=!1,workbenchShellOverrides:x}){var Ln,Bn;const j=Wi(),{navigationGroups:F,subscribeFileTree:M,requestFileTreeRefresh:Z,addFileTreeSnapshotListener:ye,subscribeGitSnapshot:K,requestGitRefresh:xe,addGitSnapshotListener:ge}={...j,...x},[G,ht]=c.useState({}),[E,Ft]=c.useState([]),[Ne,De]=c.useState([]),[D,_]=c.useState(g),[X,$]=c.useState([]),[ie,R]=c.useState(null),[_e,ae]=c.useState(!1),[p,w]=c.useState(!1),[v,mt]=c.useState(!1),[Ye,Je]=c.useState(!1),[A,Qe]=c.useState(""),[_t,q]=c.useState(null),[pt,bt]=c.useState(!1),[le,Ae]=c.useState(null),[O,Ze]=c.useState("workspace"),[rn,Ee]=c.useState(0),[sn,At]=c.useState(0),[Ie,I]=c.useState(!1),[et,L]=c.useState(!1),[oe,H]=c.useState(null),[Ce,Le]=c.useState(null),[B,Be]=c.useState(null),[C,Lt]=c.useState(null),[S,tt]=c.useState(null),[Bt,We]=c.useState(""),[cn,un]=c.useState([]),[ee,Wt]=c.useState(!1),[hi,re]=c.useState(null),fn=c.useId(),se=c.useRef({}),Y=c.useRef({}),T=c.useRef([]),te=c.useRef(g),nt=c.useRef(!1),it=c.useRef(null),mi=ti(),dn=c.useRef(null),hn=c.useRef(null),$t=c.useRef(null),mn=c.useRef(null),pn=c.useRef(null),ce=c.useRef(0),ue=c.useRef(new Map),{showToast:P}=ei(),Pe=Fi(),V=$i(e=>e.showSystemFiles),$e=!!(n!=null&&n.trim()),bn=s&&Pe.isMobile;c.useEffect(()=>{Fe("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=D},[D]);function Ot(e){At(e),!(!l||!n)&&ft(Yn(l,n),e)}async function vn(){if(!l||!n){Ot(0);return}const e=await Nt(n,l),a=nn(e,o=>ut(o.path),V).length;Ot(a)}function ke(e){ht(a=>{const o=typeof e=="function"?e(a):e;return se.current=o,o})}function Oe(e){Ft(a=>{const o=typeof e=="function"?e(a):e;return T.current=o,o})}c.useEffect(()=>{var f,d;if(zt(),!l){zt(),nt.current=!1,se.current={},Y.current={},T.current=[],te.current=g,ke({}),Oe([]),De([]),_(g),Je(!1),Qe(""),q(null),bt(!1),ae(!1),Wt(!1),re(null),$([]),R(null),H(null),Le(null),Be(null),tt(null),We("");return}nt.current=!0;const e=tn(qn(l),la);Fe("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ea((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),o=Xn((e==null?void 0:e.expandedDirectories)??[],a),u=St((e==null?void 0:e.treeCache)??{},a,o);se.current=u,Y.current=Jn((e==null?void 0:e.treeRevisionByPath)??{},u),T.current=o,te.current=a,ke(u),Oe(o),De([]),_(a),ae(!1),w(!1),Je(!1),Qe(""),q(null),bt(!1),queueMicrotask(()=>{nt.current=!1})},[l]),c.useEffect(()=>{if(!h||h.workspaceId!==l)return;const e=()=>{if(pn.current===h.requestId)return;pn.current=h.requestId,Ze("workspace"),(h.openViewer?ze(h.filePath):he(h.filePath)).catch(o=>{P({title:Q(o,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(nt.current){queueMicrotask(e);return}e()},[h,ze,he,P,l]),c.useEffect(()=>{if(l)return ye(e=>{e.workspaceId===l&&(Y.current={...Y.current,[e.path]:typeof e.revision=="string"?e.revision:null},ke(a=>({...a,[e.path]:e.items})),e.path===g&&ae(!1),De(a=>a.filter(o=>o!==e.path)),wn(e.path,e.items))})},[ye,l]),c.useEffect(()=>()=>{zt()},[]),c.useEffect(()=>{l&&M(l,en(T.current,te.current),{knownRevisionByPath:Y.current})},[D,E,M,l]),c.useEffect(()=>{$([]),R(null),Ae(null),re(null),Ee(0),I(!1),L(!1),H(null),Le(null),Be(null),tt(null),We(""),it.current=null,ce.current+=1},[n]),c.useEffect(()=>{!$e&&O==="session"&&Ze("workspace")},[O,$e]),c.useEffect(()=>{m&&O!=="workspace"&&Ze("workspace")},[O,m]),c.useEffect(()=>{if(!Ie&&!et&&!oe)return;function e(o){var y,N,pe;if(!(o.target instanceof Node))return;const u=((y=dn.current)==null?void 0:y.contains(o.target))??!1,f=((N=hn.current)==null?void 0:N.contains(o.target))??!1,d=((pe=$t.current)==null?void 0:pe.contains(o.target))??!1;!u&&!f&&!d&&(I(!1),L(!1),H(null),Le(null))}function a(o){o.key==="Escape"&&(I(!1),L(!1),H(null),Le(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Ie,et,oe]),c.useLayoutEffect(()=>{if(!oe||typeof window>"u"){Le(null);return}const e=oe;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Le(ya({x:e.positionX,y:e.positionY},{width:f.width||ia,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const o=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[oe]),c.useEffect(()=>{if(!l)return;const e=Xn(E,D),a=St(G,D,e);ft(qn(l),{treeCache:a,treeRevisionByPath:Jn(Y.current,a),expandedDirectories:e,activeDirectoryPath:D})},[D,E,G,l]),c.useEffect(()=>{if(nt.current)return;const e=St(G,D,E);Ma(G,e)||ke(e)},[D,E,G]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function o(f){if(!a)return;const d=Qt(se.current[g]??[],V),y=(f==null?void 0:f.silent)!==!0&&d.length===0;y&&ae(!0),Fe("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await Ut(g,{force:!0});e||(Fe("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),ke(pe=>({...St(pe,te.current,T.current),[g]:N})))}catch(N){!e&&!Qn(N)&&P({title:Q(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&y&&ae(!1)}}if(Qt(se.current[g]??[],V).length>0){const f=window.setTimeout(()=>{a&&(M(a,en(T.current,te.current),{knownRevisionByPath:Y.current}),o({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return o(),()=>{e=!0}},[n,V,P,l]),c.useEffect(()=>{if(!l||!n){At(0);return}const e=tn(Yn(l,n),oa);Fe("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),At(e??0);let a=!1;return vn().catch(()=>{}),()=>{a=!0}},[n,rn,V,l]),c.useEffect(()=>{if(!l){un([]);return}const e=l.trim();K(e),xe(e)},[l,K,xe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return ge(a=>{var o;a.workspaceId===e&&un(((o=a.status)==null?void 0:o.changes)??[])})},[ge,l]);const vt=c.useMemo(()=>nn(cn,e=>ut(e.path),V),[cn,V]),W=c.useMemo(()=>{const e=new Map,a=new Set;for(const o of vt){const u=o.path.replace(/\\/g,"/"),f=o.worktreeStatus??o.stagedStatus??o.status;e.set(u,f);const d=u.split("/");for(let y=1;y<d.length;y++)a.add(d.slice(0,y).join("/"))}return{statusByPath:e,changedDirs:a}},[vt]),Me=c.useMemo(()=>Oi(G,V),[V,G]),Re=c.useMemo(()=>_t===null?null:Qt(_t,V),[_t,V]),He=Me[g]??[],fe=Ye&&Re!==null,yt=c.useMemo(()=>ee?an(He,Me,W.statusByPath,W.changedDirs):He,[W.changedDirs,W.statusByPath,He,ee,Me]),pi=c.useMemo(()=>fe?(Re??[]).map(e=>z(e.path,e.kind)):oi(yt,Me,E,ee,W.statusByPath,W.changedDirs),[E,W.changedDirs,W.statusByPath,fe,ee,Re,Me,yt]),de=((Ln=F.find(e=>e.workspace.id===l))==null?void 0:Ln.workspace)??null,k=Gn(X),Ht=(k==null?void 0:k.path)??null,je=(k==null?void 0:k.kind)==="file"?k.path:null,xt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),at=c.useMemo(()=>wt(X),[X]),Vt=!!(de!=null&&de.path&&X.length===1&&Ht),yn=X.length===1&&(k==null?void 0:k.kind)==="file",xn=at.length>0,Te=at.length>0,lt=!!(C!=null&&C.items.length&&l),gn=!!l&&X.length===1&&k!==null,Cn=!!((je?ve(je):D)&&E.length),Pn=C?C.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:C.items.length}):r("conversation.filePanelClipboardCutReady",{count:C.items.length}):null,U=S?Pa(S):null;async function jn(e,a=!1){if(!l)return[];if(!a){const o=se.current[e];if(o)return o}e===g?ae(!0):De(o=>kt(o,e));try{const o=await Ut(e,{force:a});return ke(u=>({...u,[e]:o})),o}catch(o){throw Qn(o)||P({title:Q(o,r("conversation.filePanelLoadFailed")),tone:"error"}),o}finally{e===g?ae(!1):De(o=>o.filter(u=>u!==e))}}async function we(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,o=(e==null?void 0:e.expandedDirectories)??T.current,u=ka(se.current,a,o);Fe("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async y=>{const N=await Ut(y,{force:!0});return[y,N]}))).reduce((y,[N,pe])=>(y[N]=pe,y),{});Fe("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),ke(d)}async function Ut(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=se.current[e];if(d)return d}const o=en(kt(T.current,e),e||te.current);M(l,o,{knownRevisionByPath:Y.current}),Z(l,[e],{knownRevisionByPath:Y.current});const u=bi(e,Un,{allowCached:(a==null?void 0:a.force)!==!0}),f=Ra(ra).then(async()=>{if(!l)return[];const y=(await Gi(l,e||void 0)).items;return Y.current={...Y.current,[e]:null},wn(e,y),y});try{return await Promise.race([u,f])}catch(d){if(!fi(d))throw d;return await f}}function bi(e,a=Un,o){const u=se.current[e];return(o==null?void 0:o.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const y=window.setTimeout(()=>{vi(e,y),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=ue.current.get(e)??[];ue.current.set(e,[...N,{resolve:f,reject:d,timerId:y}])})}function wn(e,a){const o=ue.current.get(e)??[];o.length!==0&&(ue.current.delete(e),o.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function vi(e,a){const u=(ue.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){ue.current.delete(e);return}ue.current.set(e,u)}function zt(){for(const[e,a]of ue.current.entries())a.forEach(o=>{window.clearTimeout(o.timerId),o.reject(new Error(`FILE_TREE_ABORTED:${e}`))});ue.current.clear()}function Ve(e){$([e]),R(e.path)}function ot(e){_(e.kind==="directory"?e.path:ve(e.path))}function yi(e){const a=ha(pi,ie,e);$(a),R(e.path),ot(e)}function xi(e){const a=da(X,e),o=Gn(a);$(a),R(e.path),o&&ot(o)}function Sn(e){Ve(e),ot(e)}function Ue(e,a){if(a!=null&&a.shiftKey){yi(e);return}if(jt(a)){xi(e);return}Sn(e)}async function rt(e,a=!1){const o=dt(e,a);if(!o.length){_(g);return}Oe(u=>ui(u,o)),_(o[o.length-1]??g);for(const u of o)try{await jn(u)}catch{return}}async function he(e){const a=z(e,"file");Ve(a),ot(a),await rt(e)}async function ze(e){Ae(e),re(null),it.current=null,ce.current+=1,he(e),await gi(e)}async function gi(e){const a=ce.current,o=e.replace(/\\/g,"/"),u=W.statusByPath.get(o);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Hi(l,e,!1);ce.current===a&&re(f.content||null)}catch{ce.current===a&&re(null)}}async function Ci(e){if(!l)return;const a=ua(),o=await Ui(Pe,{workspaceId:l,workspaceName:(de==null?void 0:de.name)??null,sessionId:n??null,filePath:e,bounds:a});if(!o.ok){P({title:o.detail??r("conversation.fileViewerOpenInWindowFailed"),tone:"error"});return}ce.current+=1,Ae(null),re(null)}function Nn(e){const a=Date.now(),o=it.current;return it.current={filePath:e,timestamp:a},(o==null?void 0:o.filePath)===e&&a-o.timestamp<=na}function Se(){it.current=null}async function Pi(e,a){const o=z(e,"file");if(a!=null&&a.shiftKey||jt(a)){Se(),Ue(o,a);return}if(Nn(e)){await ze(e);return}Ue(o,a),await rt(e)}function Dn(){Je(!1),Qe(""),q(null),Se()}async function ji(e,a){const o=z(e.path,e.kind);if(a!=null&&a.shiftKey||jt(a)){Se(),Ue(o,a);return}if(e.kind==="directory"){Dn(),Ue(o,a),await En(e.path);return}if(Nn(e.path)){Dn(),await ze(e.path);return}await he(e.path)}async function En(e){if(Ve(z(e,"directory")),_(e),!T.current.includes(e))try{await jn(e),Oe(a=>kt(a,e))}catch{}}async function kn(e){if(Ve(z(e,"directory")),_(e),T.current.includes(e)){Mn(e);return}await En(e)}function Mn(e){Oe(a=>a.filter(o=>o!==e&&!o.startsWith(`${e}/`))),_(ve(e)),$([]),R(null)}async function Rn(){if(!l)return;const e=l;try{if(xe(e),await we(),je&&await rt(je),fe&&A.trim()){const a=await Xe(e,A.trim());q(a.items)}if($e&&n)if(O==="session")Ee(a=>a+1);else try{await vn()}catch(a){P({title:Q(a,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){P({title:Q(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function wi(e){if(e==null||e.preventDefault(),!l||!A.trim()){q(null);return}bt(!0);try{const a=await Xe(l,A.trim());q(a.items)}catch(a){P({title:Q(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{bt(!1)}}function Tn(){if(Ye){Je(!1),Qe(""),q(null);return}Je(!0)}function J(e){L(!1),e()}function Fn(){var e;(e=mn.current)==null||e.click()}async function Si(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const o=fa(a.name);if(!o){P({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=zn(D,k),f=Kn(u,o);mt(!0);try{const y=await ja(a);await zi({workspaceId:l,path:f,contentBase64:y}),await we(),await he(f),P({title:r("conversation.filePanelUploadSuccess",{name:o}),tone:"success"})}catch(y){P({title:Q(y,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{mt(!1)}}async function Kt(e=je){if(!(!l||!e)){mt(!0);try{const a=await Ki(l,e),o=wa(a.contentBase64);Sa(a.fileName,new Blob([o],{type:"application/octet-stream"})),P({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){P({title:Q(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{mt(!1)}}}function _n(){const e=je?ve(je):D;!e||!T.current.includes(e)||Mn(e)}function Gt(){tt(null),We("")}function Xt(){p||Gt()}function Ke(e,a=zn(D,k)){if(!l)return;const o=a,u=o?`${o}/`:"";I(!1),L(!1),H(null),tt({mode:e,baseDirectory:o}),We(u)}function qt(e=k){!l||!e||(I(!1),L(!1),H(null),tt({mode:"rename",target:e}),We(e.path))}async function Ni(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Bt??"").trim();if(a){if(S.mode==="rename"&&qe(S.target.path)===qe(a)){Xt();return}w(!0);try{if(S.mode==="rename"){const o=S.target.path,u=z(a,S.target.kind),f=le?ci(le,o,a):null;if(await gt({workspaceId:l,opType:"rename",srcPath:o,dstPath:a}),C&&Lt({...C,items:Ca(C.items,o,a)}),Gt(),Se(),await we(),S.target.kind==="directory"?(await rt(a,!0),Ve(u),_(a)):await he(a),f!==le&&(ce.current+=1,Ae(f),re(null)),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:r("conversation.filePanelRenameSuccess",{name:ut(a)||a}),tone:"success"});return}if(await gt({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0}),Gt(),await we(),S.mode==="create_directory"?(await rt(a,!0),Ve(z(a,"directory")),_(a)):await he(a),fe&&A.trim()){const o=await Xe(l,A.trim());q(o.items)}Ee(o=>o+1)}catch(o){P({title:Q(o,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function me(e,a=at){var u;if(a.length===0)return;const o=wt(a);Lt({mode:e,items:o}),$(o),R(((u=o[o.length-1])==null?void 0:u.path)??null),P({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:o.length}):r("conversation.filePanelCutSelectionSuccess",{count:o.length}),tone:"success"}),H(null)}async function st(e=ba(k,D)){if(!l||!C||!C.items.length)return;const a=e??g,o=C.items.map(u=>({source:u,destinationPath:Kn(a,ut(u.path)||u.path)}));w(!0);try{for(const d of o)C.mode==="cut"&&qe(d.source.path)===qe(d.destinationPath)||await gt({workspaceId:l,opType:C.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath});const u=o.map(d=>z(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(C.mode==="cut"&&Lt(null),$(u),R((f==null?void 0:f.path)??null),f&&ot(f),Se(),await we({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?ve(f.path):te.current,expandedDirectories:T.current}),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),H(null)}catch(u){await we().catch(()=>{}),P({title:Q(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function Yt(e=at){!e.length||p||(Be(wt(e)),H(null))}async function Di(){var a,o;if(!l||!(B!=null&&B.length))return;const e=wt(B);w(!0);try{for(const d of e)await gt({workspaceId:l,opType:"delete",srcPath:d.path});const u=va(D,e),f=T.current.filter(d=>!e.some(y=>y.kind==="directory"&&Tt(y.path,d)));if(le&&e.some(d=>Tt(d.path,le))&&(ce.current+=1,Ae(null),re(null)),Be(null),$([]),R(null),te.current=u,T.current=f,_(u),Oe(f),Se(),await we({activeDirectoryPath:u,expandedDirectories:f}),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:ut(((a=e[0])==null?void 0:a.path)??"")||((o=e[0])==null?void 0:o.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){P({title:Q(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function Ge(e,a=k){const o=(de==null?void 0:de.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!o){I(!1);return}try{const f=ga(o),d=e==="absolute"?xa(o,u,f):qe(u,f);await Na(d,Pe),P({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){P({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{I(!1),H(null)}}function Ei(e,a,o){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"){kn(e.path);return}ze(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Kt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||p||v,onSelect:()=>{Ke("create_file",o)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||p||v,onSelect:()=>{Ke("create_directory",o)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||p||v,onSelect:()=>qt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>me("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>me("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{st(o)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ge("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ge("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||p||v,onSelect:()=>Yt(a)}]}async function An(e,a){if(Pe.isMobile)return;e.preventDefault();const o=z(a.path,a.kind),u=xt.has(o.path)?at:[o],f=o.kind==="directory"?o.path:ve(o.path);xt.has(o.path)||Sn(o);const d=Ei(o,u,f);if(Pe.isDesktop){await Xi(d);return}Pe.isWeb&&(I(!1),L(!1),H({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!ma(a)||a.altKey||a.shiftKey||pa(a.target))return;const o=a.key.toLowerCase();if(o==="c"&&Te){a.preventDefault(),me("copy");return}if(o==="x"&&Te){a.preventDefault(),me("cut");return}o==="v"&&lt&&(a.preventDefault(),st())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,Te,lt,me,st]);function Jt(e,a){return i.jsx(i.Fragment,{children:e.map(o=>{const u=z(o.path,o.kind),f=o.kind==="directory",d=f&&E.includes(o.path),y=f&&Ne.includes(o.path),N=Me[o.path]??[],pe=ee?an(N,Me,W.statusByPath,W.changedDirs):N,Mi=xt.has(o.path),Ri=Ht===o.path,ct=W.statusByPath.get(o.path.replace(/\\/g,"/")),Wn=f&&W.changedDirs.has(o.path.replace(/\\/g,"/")),Ti=(C==null?void 0:C.mode)==="cut"&&C.items.some(be=>be.path===o.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":Ri,"data-selected":Mi,"data-cut-pending":Ti||void 0,"data-kind":o.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${sa+a*ca}px`},onClick:be=>{if(f){if(be.shiftKey||jt(be)){Se(),Ue(u,be);return}Se(),Ue(u,be),kn(o.path);return}Pi(o.path,be)},onContextMenu:be=>{An(be,o)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(o.name),"aria-hidden":"true",children:Mt(o.name)}),i.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":Wn||void 0,children:o.name}),!f&&ct?i.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&Wn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,y?i.jsx("span",{className:"file-tree-meta",children:r("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:y&&!N.length?i.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):pe.length?Jt(pe,a+1):i.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${o.kind}-${o.path}`)})})}function ki(e){return i.jsx(i.Fragment,{children:e.map(a=>{const o=a.kind==="directory",u=xt.has(a.path),f=Ht===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{ji(a,d)},onContextMenu:d=>{An(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),o?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(a.name),"aria-hidden":"true",children:Mt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Vi,{workspaceId:l,filePath:le,open:le!==null,onClose:()=>{ce.current+=1,Ae(null),re(null)},onSaved:async e=>{await we(),await he(e),Ee(a=>a+1)},diffContent:hi,showDetachAction:Pe.isDesktop&&Pe.bridge.supported,onDetach:()=>{le&&Ci(le)}}),s?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),m?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Ze("workspace"),children:r("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{$e&&Ze("session")},disabled:!$e,children:[r("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${sn}`,children:sn})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:mn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void Si(e)}),bn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:hn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":et,"data-active":et,onClick:()=>{I(!1),L(e=>!e)},children:[i.jsx("span",{children:r("conversation.filePanelActionsMenu")}),i.jsx(za,{})]}),et?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>me("copy")),disabled:!Te,children:r("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>me("cut")),disabled:!Te,children:r("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>st()),disabled:!lt||p||v,children:r("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Tn()},children:Ye?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Wt(e=>!e)},disabled:vt.length===0,children:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(Rn),disabled:_e||p||pt,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),_n()},disabled:!Cn,children:r("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Fn()},disabled:p||v,children:r("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(Kt),disabled:!yn||v,children:r("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(qt),disabled:!gn||p||v,children:r("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>J(Yt),disabled:!xn||p||v,children:r("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ke("create_file")),disabled:p||v,children:r("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ke("create_directory")),disabled:p||v,children:r("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ge("absolute")),disabled:!Vt,children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ge("relative")),disabled:!Vt,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>me("copy"),disabled:!Te,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>me("cut"),disabled:!Te,children:i.jsx(La,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void st(),disabled:!lt||p||v,children:i.jsx(Ba,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:dn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Ie,"data-active":Ie,onClick:()=>{L(!1),I(e=>!e)},disabled:!Vt,children:i.jsx(_a,{})}),Ie?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ge("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ge("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:_n,disabled:!Cn,children:i.jsx(Ta,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void Rn(),disabled:_e||p||pt,children:i.jsx(Fa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Ye,onClick:Tn,disabled:_e,children:i.jsx(Zn,{})}),vt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Wt(e=>!e),children:i.jsx(Ka,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:Fn,disabled:p||v,children:i.jsx($a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Kt(),disabled:!yn||v,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>qt(),disabled:!gn||p||v,children:i.jsx(Ua,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>Yt(),disabled:!xn||p||v,children:i.jsx(Ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void Ke("create_file"),disabled:p||v,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void Ke("create_directory"),disabled:p||v,children:i.jsx(Va,{})})]}),oe&&typeof document<"u"?_i.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(Ce==null?void 0:Ce.left)??Math.max(8,oe.positionX)}px`,top:`${(Ce==null?void 0:Ce.top)??Math.max(8,oe.positionY)}px`,maxHeight:Ce?`${Ce.maxHeight}px`:void 0},children:oe.items.map(e=>i.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:()=>{H(null),e.onSelect()},children:e.label},e.id))}),document.body):null,Pn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":C==null?void 0:C.mode,children:Pn}):null,Ye?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void wi(e),children:[i.jsx("input",{value:A,onChange:e=>Qe(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),bn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:r("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:i.jsx(Zn,{})})]}):null,i.jsx("div",{ref:mi,className:"file-tree","data-search-mode":fe,"data-scrollbar-autohide":"true",children:_e&&He.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):fe?Re!=null&&Re.length?ki(Re):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):ee?yt.length?Jt(yt,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):He.length?Jt(He,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:S!==null,title:(U==null?void 0:U.title)??"",description:U==null?void 0:U.description,onClose:Xt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void Ni(e),children:[i.jsx(qi,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:fn,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:i.jsx("input",{id:fn,type:"text",value:Bt??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>We(e.target.value)})}),i.jsxs(Yi,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:Xt,children:r("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!(Bt??"").trim(),children:p?(U==null?void 0:U.pendingLabel)??r("common.loading"):(U==null?void 0:U.submitLabel)??r("common.save")})]})]})}),i.jsxs($n,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||Be(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Bn=B[0])==null?void 0:Bn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>Be(null),children:r("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{Di()},children:p?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):$e&&n?i.jsx(ea,{sessionId:n,workspaceId:l,showSystemFiles:V,selectedPath:je,refreshVersion:rn,onCountChange:Ot,onSelectFile:he,onOpenFile:ze}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function ve(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function dt(t,n=!1){const l=t.split("/").filter(Boolean),s=n?l.length:l.length-1,m=[];for(let h=0;h<s;h+=1)m.push(l.slice(0,h+1).join("/"));return m}function zn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?ve(n.path):g)}function Kn(t,n){return t?`${t}/${n}`:n}function fa(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function z(t,n){return{path:t,kind:n}}function Gn(t){return t[t.length-1]??null}function da(t,n){return t.findIndex(s=>s.path===n.path)>=0?t.filter(s=>s.path!==n.path):[...t,n]}function ha(t,n,l){const s=t.findIndex(x=>x.path===l.path);if(s<0)return[l];const m=n?t.findIndex(x=>x.path===n):s;if(m<0)return[l];const h=Math.min(m,s),b=Math.max(m,s);return t.slice(h,b+1)}function jt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ma(t){return t.ctrlKey||t.metaKey}function pa(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function wt(t){const n=[...new Map(t.map(s=>[s.path,s])).values()].sort((s,m)=>s.path.localeCompare(m.path)),l=[];for(const s of n)l.some(m=>m.kind==="directory"&&Tt(m.path,s.path))||l.push(s);return l}function ba(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?ve(t.path):n}function va(t,n){let l=t;for(;l&&n.some(s=>s.kind==="directory"&&Tt(s.path,l));)l=ve(l);return l}function oi(t,n,l,s,m,h){const b=[];for(const x of t){if(b.push(z(x.path,x.kind)),x.kind!=="directory"||!l.includes(x.path))continue;const j=n[x.path]??[],F=s?an(j,n,m,h):j;b.push(...oi(F,n,l,s,m,h))}return b}function ya(t,n,l){const s=Math.max(0,l.width),m=Math.max(0,l.height),h=Math.max(0,m-ne*2),b=Math.max(0,s-ne*2),x=Math.min(Math.max(n.width,0),b),j=Math.max(0,m-t.y-Pt-ne),F=Math.max(0,t.y-Pt-ne),M=j<n.height&&F>j,ye=It(Math.max(M?F:j,aa),0,h),K=Math.min(Math.max(n.height,0),ye),xe=M?t.y-Pt-K:t.y+Pt,ge=Math.max(ne,m-ne-K),G=Math.max(ne,s-ne-x);return{top:It(xe,ne,ge),left:It(t.x,ne,G),maxHeight:Math.max(0,ye)}}function It(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function qe(t,n="posix"){return t?ri(t,n):"."}function xa(t,n,l){const s=ri(t,l),m=qe(n,l).replace(/^\.[/\\]?/,"");if(!m)return s;const h=si(l),b=m.replace(/^[/\\]+/,"");return b?s.endsWith("/")||s.endsWith("\\")?`${s}${b}`:`${s}${h}${b}`:s}function ga(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ri(t,n){return t&&(si(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function si(t){return t==="windows"?"\\":"/"}function Tt(t,n){return n===t||n.startsWith(`${t}/`)}function ci(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function Ca(t,n,l){return t.map(s=>({...s,path:ci(s.path,n,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 ja(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),s=32768;let m="";for(let h=0;h<l.length;h+=s){const b=l.subarray(h,h+s);m+=String.fromCharCode(...b)}return btoa(m)}function wa(t){const n=atob(t),l=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)l[s]=n.charCodeAt(s);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Sa(t,n){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=t,document.body.append(s),s.click(),s.remove(),window.URL.revokeObjectURL(l)}async function Na(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Da(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function Da(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ea(t,n){return t&&dt(t,!0).every(m=>m in n)?t:g}function Xn(t,n){if(!n)return[];const l=dt(n,!0);return t.filter(s=>l.includes(s))}function St(t,n,l){const s=on(n,l);return Object.entries(t).reduce((m,[h,b])=>(s.has(h)&&(m[h]=b),m),{})}function ka(t,n,l){const m=[...on(n,l)].filter(h=>h===g||h in t);return m.length?m:[g]}function on(t,n){const l=new Set([g]),s=ui(n,dt(t,!0));for(const m of s){l.add(m);for(const h of dt(m,!0))l.add(h)}return l}function Ma(t,n){const l=Object.keys(t),s=Object.keys(n);return l.length!==s.length?!1:l.every(m=>t[m]===n[m])}function kt(t,n){return t.includes(n)?t:[...t,n]}function ui(t,n){return n.reduce((l,s)=>kt(l,s),t)}function qn(t){return`file-panel.workspace-tree.${t}`}function Yn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Jn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function en(t,n){return[...on(n,t)]}function Q(t,n){return t instanceof In?t.message:n}function fi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function Qn(t){return fi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Ra(t){return new Promise(n=>{window.setTimeout(n,t)})}function Ta(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function Fa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Zn(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 _a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.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"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Aa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function La(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.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 Ha(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Va(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ua(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function Ka(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function an(t,n,l,s){const m=[];for(const h of t){const b=h.path.replace(/\\/g,"/");h.kind==="file"?l.has(b)&&m.push(h):di(b,n,l,s)&&m.push(h)}return m}function di(t,n,l,s,m){const h=m??new Set;if(h.has(t))return!1;h.add(t);const b=n[t];if(!b)return s.has(t);for(const x of b){const j=x.path.replace(/\\/g,"/");if(x.kind==="file"){if(l.has(j))return!0}else if(di(j,n,l,s,h))return!0}return!1}export{nl as FileContextPanel};
@@ -1,6 +0,0 @@
1
- import{b as l,E as Rn,ac as Hn,F as ki,t as n,j as e,A as qn}from"./index-CeXGOT_T.js";import{u as Gi,e as $i,f as Ui,g as wn}from"./App-CFBwDUNA.js";import{f as Bi,ai as ut,a3 as Vi,bK as Wi,bT as zi,bU as Ki,bA as Ii,bV as Pn,bW as Xi,bX as qi,bJ as Yi,bY as Zi,bE as Ji,bZ as Qi,bC as Yn,b_ as es,bS as ts,b$ as An,_ as ns,Z as is,$ as ss,c0 as as,bF as Wt,bG as zt,c1 as rs,c2 as os,aD as ls}from"./WorkbenchLayout-CikJBS62.js";import{W as Oe}from"./WorkbenchModal-NGmPgqaE.js";import{a as cs}from"./workbench-navigation-B7IjRQd8.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-6ii53_Y9.js";import"./relay-entry-Bg0OisQy.js";import"./MobileSheet-opTWyRe1.js";const Ot=56,Dn=28,kt=72,dt=8,Ln=960,_n=60*1e3,Fn=20,On=9,kn=9,Gt=68,O=12,mt=8,Kt=260,us=120,$t=6e4,ht={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function Os({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:h=!1,workbenchShellOverrides:g}){const j=Gi(),f=$i(),x=Bi(),{subscribeGitSnapshot:b,requestGitRefresh:v,addGitSnapshotListener:R,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:p}={...x,...g},[o,m]=l.useState(null),[y,H]=l.useState(null),[C,M]=l.useState([]),[F,P]=l.useState(0),[X,se]=l.useState(null),[be,pt]=l.useState(!1),[U,xe]=l.useState(null),[ae,q]=l.useState(null),[ye,je]=l.useState(""),[$e,B]=l.useState(!1),[N,A]=l.useState(!1),[ai,Zt]=l.useState([]),[te,Jt]=l.useState(!0),[ne,z]=l.useState(!1),[k,ri]=l.useState(()=>typeof window<"u"?window.innerWidth<=Ln:!1),[bt,V]=l.useState([]),[Ce,K]=l.useState(null),[Ne,re]=l.useState("unstaged"),[ve,Y]=l.useState(null),[oe,Z]=l.useState(null),[oi,xt]=l.useState(!1),[li,yt]=l.useState(null),[ci,Ue]=l.useState(!1),[Qt,Be]=l.useState(null),[_,Se]=l.useState(null),[en,Te]=l.useState(null),[ui,Me]=l.useState(!1),[Ee,le]=l.useState(null),[ie,jt]=l.useState(!1),[di,ce]=l.useState(!1),[Ve,Ct]=l.useState("push"),[We,ze]=l.useState([]),[mi,Ke]=l.useState(!1),[Ie,Xe]=l.useState(new Set),[hi,ue]=l.useState(new Map),[qe,tn]=l.useState({}),[gi,de]=l.useState(!1),[Ye,nn]=l.useState(null),[D,J]=l.useState(ht),[sn,an]=l.useState("generic"),[rn,Ze]=l.useState(null),[G,Nt]=l.useState(null),[$,vt]=l.useState(null),[on,ln]=l.useState(Ot),[St,Tt]=l.useState(!1),[cn,Re]=l.useState(null),[fi,He]=l.useState(null),un=l.useRef(null),dn=l.useRef(null),mn=l.useRef(null),hn=l.useRef(null),gn=l.useRef(null),fn=l.useRef(null),Mt=l.useRef(null),we=l.useRef(new Map),Je=l.useRef(new Map),Pe=l.useRef(0),pn=l.useRef(u),bn=l.useRef(u),Qe=l.useRef(null),{showToast:E}=Ui(),xn=f.isDesktop&&!k;l.useEffect(()=>{ut("git_sidebar.props",{workspaceId:i,externalWindowMode:h})},[h,i]),l.useEffect(()=>{bn.current=u},[u]),l.useEffect(()=>{Zt([]),Jt(!0),P(0),se(null),pt(!1),q(null),je(""),z(!1),V([]),K(null),re("unstaged"),Y(null),Z(null),xt(!1),yt(null),Ue(!1),Be(null),Se(null),Te(null),Me(!1),le(null),jt(!1),ce(!1),Ct("push"),ze([]),Xe(new Set),ue(new Map),tn({}),de(!1),nn(null),J(ht),an("generic"),Ze(null),Nt(null),vt(null),Tt(!1),ln(Ot),Re(null),He(null),Je.current.clear(),we.current.clear()},[i]),l.useEffect(()=>{function t(){ri(window.innerWidth<=Ln)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!St)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function r(d){vn(d.clientY)}function c(){Tt(!1)}return window.addEventListener("pointermove",r),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",c)}},[St]),l.useEffect(()=>{var c,d;if(!(i!=null&&i.trim())){Qe.current=null,m(null),H(null),M([]),P(0),se(null),xe(null),B(!1);return}const t=i.trim(),s=Rn(ke(t),_n),r=Bt(s);if(ut("git_sidebar.snapshot",{workspaceId:t,cached:r,cachedHistoryCount:((c=s==null?void 0:s.history)==null?void 0:c.length)??0,cachedChangedCount:((d=s==null?void 0:s.status)==null?void 0:d.changes.length)??0}),r&&s){Et(s,t),B(!1);return}Qe.current=null,Hn(ke(t)),m(null),H(null),M([]),P(0),se(null),xe(null),B(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return R(t=>{var s,r,c;t.workspaceId===i.trim()&&(ut("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((r=t.branches)==null?void 0:r.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),Et(t,t.workspaceId),B(!1))})},[R,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=Rn(ke(t),_n),r=Bt(s)?(s==null?void 0:s.revision)??null:null;b(t,{knownRevision:r}),bn.current&&I()},[v,b,i]),l.useEffect(()=>{const t=pn.current;pn.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||Qe.current!==t)return;const s={revision:y,status:o,history:C,historyTotalCount:F,historyNextCursor:X,branches:U};if(!Bt(s)){Hn(ke(t));return}ki(ke(t),s)},[U,C,X,F,y,o,i]),l.useEffect(()=>{if(!o||!ae)return;o.changes.find(s=>s.path===ae)||q(null)},[ae,o]),l.useEffect(()=>{bs(hn.current)},[ye]),l.useEffect(()=>{k||(V([]),K(null),Y(null),Ze(null))},[k]),l.useEffect(()=>{if(!o){V([]);return}const t=new Set(o.changes.map(s=>s.path));V(s=>s.filter(r=>t.has(r)))},[o]);function pi(){const t=mn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(r=>{r.scrollTop=0})}function Et(t,s){Qe.current=(s==null?void 0:s.trim())??(i==null?void 0:i.trim())??null,H(typeof t.revision=="string"?t.revision:null),m(t.status),M(Array.isArray(t.history)?t.history:[]),P(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),se(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),xe(t.branches??null)}function I(t){i!=null&&i.trim()&&(B(!0),ut("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),v(i.trim(),{knownRevision:y}))}async function Rt(t){if(!(i!=null&&i.trim()))return;const s=i.trim();B(!0);try{const[r,c,d]=await Promise.all([Ii(s),Pn(s,Fn,null),Xi(s)]);Et({status:r,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:d}),v(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{pi()})}catch(r){E({title:L(r,n("git.panelLoadFailed")),tone:"error"})}finally{B(!1)}}async function et(){if(!(!i||!X||be)){pt(!0);try{const t=await Pn(i,Fn,X);M(s=>{const r=new Set(s.map(d=>d.commitHash)),c=t.items.filter(d=>!r.has(d.commitHash));return[...s,...c]}),P(t.totalCount),se(t.nextCursor)}catch(t){E({title:L(t,n("git.panelLoadFailed")),tone:"error"})}finally{pt(!1)}}}function bi(t){if(!te||be||!X)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&et()}async function xi(){if(i){A(!0);try{const t=await Ki(i,"ai");je(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){E({title:L(t,n("git.draftFailed")),tone:"error"})}finally{A(!1)}}}async function tt(t,s){if(i&&t.length){A(!0);try{const r=s?await Zi(i,t):await Ji(i,t);m(r),q(t[t.length-1]??null),V(c=>c.filter(d=>!t.includes(d))),K(null),I()}catch(r){B(!1),E({title:L(r,n("git.stageFailed")),tone:"error"})}finally{A(!1)}}}async function Ht(t){if(i&&t.length){A(!0);try{const s=await es(i,t);m(s),t.includes(ae??"")&&q(null),V(r=>r.filter(c=>!t.includes(c))),K(null),I()}catch(s){B(!1),E({title:L(s,n("git.discardFailed")),tone:"error"})}finally{A(!1)}}}async function yi(){if(!(!i||!ye.trim())){A(!0);try{await qi(i,gs(ye)),E({title:n("git.commitSuccess"),tone:"success"}),je(""),q(null),I()}catch(t){E({title:L(t,n("git.commitFailed")),tone:"error"})}finally{A(!1)}}}async function ji(){if(i!=null&&i.trim()){A(!0),B(!0);try{const t=await zi(i.trim());m(t),M([]),P(0),se(null),xe(null),E({title:n("git.initSuccess"),tone:"success"}),I()}catch(t){E({title:L(t,n("git.initFailed")),tone:"error"})}finally{A(!1),B(!1)}}}async function wt(){const t=i==null?void 0:i.trim();if(!t)return[];const s=await as(t);return(i==null?void 0:i.trim())!==t?[]:(ze(s),s)}async function nt(t){const s=await wt(),r=gt(s,t);if(!r){E({title:n("git.noRemotes"),tone:"error"});return}const c=qe[r.name]??null;nn(r.name),an(vs(s,r.name)),J(Cs((c==null?void 0:c.auth)??null,(c==null?void 0:c.rememberOnHost)??!1)),de(!0)}async function Ci(){if(i!=null&&i.trim()){Ke(!0);try{const t=await wt();if(t.length===0){E({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){await nt(t[0].name);return}Ct("auth"),Xe(new Set),ue(new Map),ce(!0)}catch(t){E({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Ke(!1)}}}function Ni(){const t=Ye==null?void 0:Ye.trim();if(!t){de(!1);return}const s=Ns(D),r=sn==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(D.authMode==="basic"){if(!D.username.trim()){E({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!D.password){E({title:r,tone:"error"});return}}if(D.authMode==="token"&&!D.token){E({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}tn(c=>{if(!s){const{[t]:d,...w}=c;return w}return{...c,[t]:{auth:s,rememberOnHost:D.rememberOnHost}}}),de(!1),E({title:s?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:s&&D.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function yn(){if(i){Ke(!0);try{const t=await wt();if(t.length===0){E({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){jn([t[0].name]);return}Ct("push"),Xe(new Set),ue(new Map),ce(!0)}catch(t){E({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Ke(!1)}}}async function jn(t){if(!i||t.length===0)return;A(!0),ue(new Map);const s=new Map;let r=!1;try{for(const c of t){const d=qe[c]??null;try{const w=await An(i,"push",c,d==null?void 0:d.auth,(d==null?void 0:d.rememberOnHost)??!1);s.set(c,{ok:!0,summary:w.summary}),d!=null&&d.rememberOnHost&&d.auth&&ze(Oi=>Oi.map(Ft=>Ft.name===c?{...Ft,credentialConfigured:!0}:Ft))}catch(w){if(r=!0,s.set(c,{ok:!1,summary:L(w,n("git.remoteFailed"))}),ue(new Map(s)),Kn(w)){nt(c);return}}}ue(s),I(),r||(E({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ce(!1))}finally{A(!1)}}async function Pt(t){if(i){if(t==="push"){z(!1),yn();return}A(!0);try{const s=In(We),r=s?qe[s]??null:null,c=await An(i,t,void 0,r==null?void 0:r.auth,(r==null?void 0:r.rememberOnHost)??!1);E({title:c.summary,tone:"success"}),s&&(r!=null&&r.rememberOnHost)&&r.auth&&ze(d=>d.map(w=>w.name===s?{...w,credentialConfigured:!0}:w)),z(!1),I()}catch(s){if(Kn(s)){nt(In(We));return}E({title:L(s,n("git.remoteFailed")),tone:"error"})}finally{A(!1)}}}async function me(){if(i){A(!0);try{const t=await Qi(i);je(t.commitSubject??""),E({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),z(!1),I()}catch(t){E({title:L(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{A(!1)}}}async function vi(t){if(i){A(!0);try{const s=await rs(i,t,!1);xe(s),z(!1),I()}catch(s){E({title:L(s,n("git.branchFailed")),tone:"error"})}finally{A(!1)}}}async function At(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const r=Je.current.get(t);if(r)return r;const c=await os(s,t);return Je.current.set(t,c),c}async function Ae(t){Z(null),Y(null),yt(t),Be(null);const s=Je.current.get(t)??null;if(Se(s),Ue(!s),s)return;const r=Pe.current+1;Pe.current=r;try{const c=await At(t);if(Pe.current!==r)return;Se(c)}catch(c){if(Pe.current!==r)return;Be(L(c,n("git.commitDetailLoadFailed"))),Se(null)}finally{Pe.current===r&&Ue(!1)}}function Si(){yt(null),Ue(!1),Be(null),Se(null)}async function De(t){try{const s=await At(t);await W(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){E({title:L(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Le(t){Z(null),Y(null),Te(t),le(null),Me(!0)}function Ti(t){var r;const s=((r=C[0])==null?void 0:r.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 W(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void W(pe(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void De(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Le(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:N,onSelect:()=>void me()}]:[]]}async function Cn(t){Z(null),Y(null),await ts(Ti(t))}async function Mi(){var t,s;if(!(!i||!en||!Ee||ie)){jt(!0);try{const r=await At(en),c=await ns({workspaceId:i,provider:Ee,content:ps(r),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:is()}),d=c.session??await ss(c.sessionId);p(d),S(),T(d.workspaceId),j(cs(d.workspaceId,d.sessionId)),Me(!1),Te(null),le(null),E({title:n("git.explainCommitStarted"),tone:"success"})}catch(r){E({title:L(r,n("git.explainCommitFailed")),tone:"error"})}finally{jt(!1)}}}function it(t){Zt(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}const Ei=450;function Nn(t){const s=Date.now(),r=un.current;return un.current={filePath:t,timestamp:s},(r==null?void 0:r.filePath)===t&&s-r.timestamp<=Ei}async function st(t,s){if(s.binary){E({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")He(null),Re(t);else if(i)try{const r=await Yi(i,t,s.staged);He(r.content),Re(t)}catch{He(null),Re(t)}}function at(t){q(t),K(null),V(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}function vn(t){const s=dn.current;if(!s||!Number.isFinite(t))return;const r=s.getBoundingClientRect(),c=r.height-dt;if(!Number.isFinite(r.top)||!Number.isFinite(r.height)||c<=0)return;const d=(t-r.top-dt/2)/c*100;if(!Number.isFinite(d))return;const w=Math.max(Dn,Math.min(kt,Math.round(d)));ln(w)}function Ri(t){t.preventDefault(),vn(t.clientY),Tt(!0)}const _e=(o==null?void 0:o.changes)??[],Q=_e.filter(t=>It(t,"staged")),he=_e.filter(t=>It(t,"unstaged")),Sn=Wn(Q,"staged"),Tn=Wn(he,"unstaged"),rt=new Set(ai),ot=new Set(bt),ge=zn(bt,_e,"staged"),fe=zn(bt,_e,"unstaged"),Dt=_e.length===0&&((o==null?void 0:o.snapshot.ahead)??0)>0,Hi=Q.length>0&&ye.trim().length>0,lt=(U==null?void 0:U.currentBranch)??(o==null?void 0:o.snapshot.branch)??n("common.unknown"),ct=gt(We,Ye),Fe=sn==="github",wi=Fe?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),Pi=Fe?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),Ai=Fe?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),Di=Fe?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Lt=Number.isFinite(on)?on:Ot,Li=te?`minmax(120px, ${Lt}fr) ${dt}px minmax(140px, ${100-Lt}fr)`:`minmax(120px, 1fr) ${dt}px auto`,_i=ys(o);l.useEffect(()=>{Ce==="staged"&&ge.length===0&&K(null),Ce==="unstaged"&&fe.length===0&&K(null)},[Ce,ge.length,fe.length]),l.useEffect(()=>{if(!k)return;const t=he.length>0?"unstaged":Q.length>0?"staged":"history";re(s=>s==="unstaged"&&he.length>0||s==="staged"&&Q.length>0?s:t)},[k,Q.length,he.length]),l.useEffect(()=>{ve&&(C.some(t=>t.commitHash===ve)||Y(null))},[C,ve]),l.useEffect(()=>{oe&&(C.some(t=>t.commitHash===oe)||Z(null))},[oe,C]),l.useEffect(()=>{k&&Ne!=="history"&&ne&&z(!1)},[k,ne,Ne]),l.useLayoutEffect(()=>{if(k||!ne){Nt(null);return}function t(){const r=gn.current,c=fn.current;!r||!c||typeof window>"u"||Nt(Xn(r.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,U==null?void 0:U.local.length,lt,k,ne]);const ee=ve??oe;l.useLayoutEffect(()=>{if(!ee){vt(null);return}const t=ee;function s(){const c=we.current.get(t)??null,d=Mt.current;!c||!d||typeof window>"u"||vt(Xn(c.getBoundingClientRect(),{width:d.getBoundingClientRect().width||Kt,height:d.getBoundingClientRect().height||d.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const r=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[ee,C.length]),l.useEffect(()=>{if(!ee||typeof document>"u")return;const t=ee;function s(r){const c=r.target;if(!(c instanceof Node))return;const d=we.current.get(t)??null,w=Mt.current;d!=null&&d.contains(c)||w!=null&&w.contains(c)||(Y(null),Z(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[ee]);async function W(t,s){var r;try{if(f.isDesktop&&(await f.bridge.writeClipboardText(t)).ok){E({title:s,tone:"success"});return}if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText)){await navigator.clipboard.writeText(t),E({title:s,tone:"success"});return}if(fs(t)){E({title:s,tone:"success"});return}}catch{E({title:n("common.copyContentFailed"),tone:"error"})}}async function Mn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await Ht(t)}function En(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!k,r=s?{top:(G==null?void 0:G.top)??O,left:(G==null?void 0:G.left)??O,maxHeight:G==null?void 0:G.maxHeight,transformOrigin:(G==null?void 0:G.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?fn:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:r,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:lt})]}),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:n("git.remoteAuthManageHint")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||mi,onClick:()=>void Ci(),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:U==null?void 0:U.local.map(d=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||d.current,onClick:()=>void vi(d.name),children:e.jsx("span",{children:d.current?`${n("git.switchBranch")} ${d.name}`:`${n("git.switchBranchTo")} ${d.name}`})},d.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>{z(!1),xt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void me(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||$e,onClick:()=>void Rt({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:wn.createPortal(c,document.body):c}function _t(t,s){if(s){we.current.set(t,s);return}we.current.delete(t)}function Fi(){var r;if(!ee||typeof document>"u")return null;const t=C.find(c=>c.commitHash===ee);if(!t)return null;const s=((r=C[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return wn.createPortal(e.jsx("div",{ref:Mt,className:"git-history-entry-menu","data-floating":"true",style:{top:($==null?void 0:$.top)??O,left:($==null?void 0:$.left)??O,maxHeight:$==null?void 0:$.maxHeight,transformOrigin:($==null?void 0:$.transformOrigin)??"top right"},children:e.jsx(ms,{item:t,canUndo:s,actioning:N,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void W(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void W(pe(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void De(c),onExplainCommitChange:c=>void Le(c),onUndoLastCommit:()=>void me()})}),document.body)}return o&&!_i?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 ji(),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:hn,rows:1,value:ye,onChange:t=>je(ti(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 xi(),disabled:N||$e,children:e.jsx(Ms,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Rt({resetTreeScroll:!0}),disabled:N||$e||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(Dt){yn();return}yi()},disabled:N||!Dt&&!Hi,children:Dt?n("git.pushNow"):n("git.commitNow")})]})]}),k?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Ut,{title:n("git.stagedChangesTitle"),count:Q.length,expanded:Ne==="staged",onToggle:()=>re("staged"),children:e.jsx($n,{title:n("git.stagedChangesTitle"),nodes:Sn,collapsedTreePathSet:rt,onToggleTreePath:it,onToggleMobileSelection:at,selectedMobilePathSet:ot,selectedTargets:ge,actioning:N,variant:"staged",swipeRowState:rn,onSwipeRowChange:Ze,onStageToggle:tt,onDiscardWithConfirm:Mn,onClearSelectedTargets:()=>V(t=>t.filter(s=>!ge.includes(s))),onPreviewFile:st})}),e.jsx(Ut,{title:n("git.changesTitle"),count:he.length,expanded:Ne==="unstaged",onToggle:()=>re("unstaged"),children:e.jsx($n,{title:n("git.changesTitle"),nodes:Tn,collapsedTreePathSet:rt,onToggleTreePath:it,onToggleMobileSelection:at,selectedMobilePathSet:ot,selectedTargets:fe,actioning:N,variant:"unstaged",swipeRowState:rn,onSwipeRowChange:Ze,onStageToggle:tt,onDiscardWithConfirm:Mn,onClearSelectedTargets:()=>V(t=>t.filter(s=>!fe.includes(s))),onPreviewFile:st})}),e.jsxs(Ut,{title:n("git.recentVersionsTitle"),count:F,expanded:Ne==="history",onToggle:()=>re("history"),trailingContent:e.jsx("span",{className:"badge",children:lt}),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":ne,onClick:()=>{re("history"),z(t=>!t)},disabled:N,children:e.jsx(Ge,{})}),children:[ne?e.jsx("div",{className:"git-mobile-operations-shell",children:En()}):null,e.jsx(ds,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:ve,onMenuTriggerRef:_t,onToggleMenu:t=>Y(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()})]})]}):e.jsxs("div",{ref:dn,className:"git-content-split",style:{gridTemplateRows:Li},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:mn,className:"git-tree-panel-body",children:[Q.length>0?e.jsx(Gn,{title:n("git.stagedChangesTitle"),count:Q.length,nodes:Sn,selectedPath:ae,collapsedTreePathSet:rt,onToggleTreePath:it,onSelectFile:q,onPreviewFile:(t,s)=>{Nn(t)&&st(t,s)},onToggleMobileSelection:at,onStageToggle:tt,onDiscard:Ht,actioning:N,variant:"staged",isMobileViewport:k,selectedMobilePathSet:ot,selectedTargets:ge,mobileActionMenuOpen:Ce==="staged",onToggleMobileActionMenu:()=>K(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>V(t=>t.filter(s=>!ge.includes(s)))}):null,e.jsx(Gn,{title:n("git.changesTitle"),count:he.length,nodes:Tn,selectedPath:ae,collapsedTreePathSet:rt,onToggleTreePath:it,onSelectFile:q,onPreviewFile:(t,s)=>{Nn(t)&&st(t,s)},onToggleMobileSelection:at,onStageToggle:tt,onDiscard:Ht,actioning:N,variant:"unstaged",isMobileViewport:k,selectedMobilePathSet:ot,selectedTargets:fe,mobileActionMenuOpen:Ce==="unstaged",onToggleMobileActionMenu:()=>K(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>V(t=>t.filter(s=>!fe.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Dn,"aria-valuemax":kt,"aria-valuenow":te?Lt:kt,"data-dragging":St,onPointerDown:Ri,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":te,"aria-label":te?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Jt(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(ft,{expanded:te}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:F})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:lt}),e.jsx("button",{className:"git-icon-button",type:"button",ref:gn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>z(t=>!t),disabled:N,children:e.jsx(Ge,{})}),ne?En({desktopFloating:!0}):null]})]}),te?e.jsx(Bn,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:oe,useNativeContextMenu:xn,onMenuTriggerRef:_t,onScroll:bi,onToggleMenu:t=>{if(xn){const s=C.find(r=>r.commitHash===t);s&&Cn(s);return}Z(s=>s===t?null:t)},onOpenContextMenu:t=>void Cn(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()}):null]})]}),e.jsxs(Oe,{open:di,title:Ve==="push"?n("git.selectRemoteTitle"):n("git.remoteAuthManageTitle"),description:Ve==="push"?n("git.selectRemoteDesc"):n("git.remoteAuthManageDescription"),onClose:()=>{N||ce(!1)},children:[e.jsx("div",{className:"git-remote-select-list",children:We.map(t=>{const s=Ie.has(t.name),r=hi.get(t.name),c=Ss(t,qe[t.name]??null);return e.jsxs("div",{className:"git-remote-item",children:[Ve==="push"?e.jsxs("label",{className:"git-remote-item-selector",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:N,onChange:()=>{Xe(d=>{const w=new Set(d);return w.has(t.name)?w.delete(t.name):w.add(t.name),w})}}),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}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})]}):e.jsx("div",{className:"git-remote-item-selector git-remote-item-selector-static",children: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}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})}),e.jsxs("div",{className:"git-remote-item-meta",children:[e.jsx("span",{className:`git-remote-credential-badge ${c.kind}`,children:c.label}),e.jsx("button",{className:"secondary-button git-remote-inline-action",type:"button",disabled:N,onClick:()=>void nt(t.name),children:n("git.remoteAuthAction")})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>ce(!1),children:n("common.close")}),Ve==="push"?e.jsx("button",{className:"primary-button",type:"button",disabled:N||Ie.size===0,onClick:()=>void jn(Array.from(Ie)),children:N?n("git.pushing"):n("git.pushSelected",{count:String(Ie.size)})}):null]})]}),e.jsxs(Oe,{open:gi,title:n("git.remoteAuthTitle"),description:wi,onClose:()=>{N||de(!1)},children:[ct?e.jsxs("div",{className:"git-remote-auth-target",children:[e.jsx("strong",{children:ct.name}),e.jsx("span",{children:ct.pushUrl||ct.fetchUrl})]}):null,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:D.authMode,disabled:N,onChange:t=>J(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")})]})]}),D.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:D.username,placeholder:Di,autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:Pi}),e.jsx("input",{type:"password",value:D.password,placeholder:Ai,autoComplete:"current-password",onChange:t=>J(s=>({...s,password:t.target.value}))})]})]}):null,D.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:D.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>J(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:D.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>J(s=>({...s,token:t.target.value}))})]})]}):null,Fe?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,D.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:D.rememberOnHost,onChange:t=>J(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:()=>de(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:N,onClick:Ni,children:n("git.remoteAuthSave")})]})]}),e.jsx(Oe,{open:oi,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(F)}),onClose:()=>xt(!1),children:e.jsx(Bn,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:oe,className:"git-history-modal-list",onMenuTriggerRef:_t,onToggleMenu:t=>Z(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()})}),e.jsx(Oe,{open:li!==null,className:"git-commit-detail-modal",title:(_==null?void 0:_.subject)||n("git.commitDetailTitle"),description:_?n("git.commitDetailDescription",{hash:_.shortHash}):n("git.commitDetailLoading"),onClose:Si,children:ci?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):Qt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:Qt})}):_?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:_.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:_.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:_.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:xs(_.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:pe(_)})]}),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:_.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:_.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")}),_.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:_.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Oe,{open:ui,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{ie||(Me(!1),Te(null),le(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(Vi,{workspaceId:i,selectedProvider:Ee,pendingProvider:ie?Ee:null,disabled:ie,onSelect:t=>le(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:ie,onClick:()=>{Me(!1),Te(null),le(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Ee||ie,onClick:()=>void Mi(),children:ie?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(Wi,{workspaceId:i,filePath:cn,open:cn!==null,onClose:()=>{Re(null),He(null)},onSaved:async()=>{await Rt({resetTreeScroll:!0})},diffContent:fi}),Fi()]})}function Gn({title:a,count:i,nodes:u,selectedPath:h,collapsedTreePathSet:g,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:R,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o,selectedTargets:m,mobileActionMenuOpen:y,onToggleMobileActionMenu:H,onClearSelectedTargets:C}){const M=Yn(),F=Yt(u),P=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&&F.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":P,title:P,onClick:()=>void v(F,T==="staged"),disabled:S,children:e.jsx(Xt,{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 R(F),disabled:S,children:e.jsx(qt,{})}):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:H,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 R(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?Jn({nodes:u,depth:0,collapsedTreePathSet:g,selectedPath:h,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:R,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Ut({title:a,count:i,expanded:u,onToggle:h,trailingContent:g,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(ft,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[g,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 $n({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,selectedTargets:f,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:R,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:p,onPreviewFile:o}){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?Zn({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:R,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Zn({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:R,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(p=>{if(p.kind==="directory"){const y=!u.has(p.path),H=Yt(p.children),C=`directory:${p.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Un,{rowKey:C,openState:(b==null?void 0:b.path)===C?b.direction:null,onOpenStateChange:M=>v(M?{path:C,direction:M}:null),trailingActions:H.length>0?[{label:x==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void R(H,x==="staged")},...x==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(H,p.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${On+i*kn}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(ft,{expanded:y})}),e.jsx("span",{className:"git-mobile-record-title",children:p.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:H.length})]})}),y?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Zn({nodes:p.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:R,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},C)}const o=`file:${p.path}`,m=j.has(p.path);return e.jsx(Un,{rowKey:o,openState:(b==null?void 0:b.path)===o?b.direction:null,onOpenStateChange:y=>v(y?{path:o,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 R([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:`${On+i*kn}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${p.name}`,onChange:()=>g(p.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>g(p.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(p.name),"aria-hidden":"true",children:Wt(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})]})]})},o)})}function Un({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:h,children:g}){const j=ls(),f=l.useRef(null),[x,b]=l.useState(0),v=((h==null?void 0:h.length)??0)*Gt;l.useEffect(()=>{i||b(0)},[i,a]);const R=x!==0?x:i==="trailing"?-v:0;function S(m){var y,H;m.button===0&&(f.current={pointerId:m.pointerId,startX:m.clientX},(H=(y=m.currentTarget).setPointerCapture)==null||H.call(y,m.pointerId))}function T(m){const y=f.current;if(!y||y.pointerId!==m.pointerId)return;const H=v>0?v+10:0,C=Math.max(-H,Math.min(0,m.clientX-y.startX));b(C)}function p(m){var H,C;const y=f.current;if(!(!y||y.pointerId!==m.pointerId)){if((C=(H=m.currentTarget).releasePointerCapture)==null||C.call(H,m.pointerId),f.current=null,x<=-44&&(h!=null&&h.length)){j.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function o(m){var H,C;const y=f.current;!y||y.pointerId!==m.pointerId||((C=(H=m.currentTarget).releasePointerCapture)==null||C.call(H,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*Gt,width:Gt},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(${R}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:p,onPointerCancel:o,children:g})]})}function ds({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,onMenuTriggerRef:j,onToggleMenu:f,onViewCommitChanges:x,onCopyCommitHash:b,onCopyCommitMessage:v,onCopyCommitVersion:R,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:p}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(o=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":o.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":o.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:o.subject,children:o.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":o.commitKind,children:ni(o.commitKind)})]}),o.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:o.refs.map(m=>e.jsx("span",{className:"git-history-ref-pill","data-kind":m.kind,"data-remote-index":String(ii(m.remoteName)),children:m.name},`${o.commitHash}:${m.kind}:${m.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:o.commitHash.slice(0,8)}),e.jsx("span",{children:o.authorName}),e.jsx("time",{dateTime:o.authoredAt,children:si(o.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:m=>j(o.commitHash,m),"aria-label":n("git.historyItemMenu"),onClick:()=>f(o.commitHash),children:e.jsx(Ge,{})})]})},o.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 Bn({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,className:j,useNativeContextMenu:f=!1,onMenuTriggerRef:x,onScroll:b,onToggleMenu:v,onOpenContextMenu:R,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:p,onCopyCommitVersion:o,onExplainCommitChange:m,onUndoLastCommit:y,onLoadMore:H}){const C=Yn();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 F=g===M.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":M.commitKind,"data-menu-open":F?"true":"false",onContextMenu:P=>{!f||!R||(P.preventDefault(),P.stopPropagation(),R(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:ni(M.commitKind)}),f?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:P=>x(M.commitHash,P),"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(P=>e.jsx("span",{className:"git-history-ref-pill","data-kind":P.kind,"data-remote-index":String(ii(P.remoteName)),children:P.name},`${M.commitHash}:${P.kind}:${P.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:si(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:H,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function ms({item:a,canUndo:i,actioning:u,onViewCommitChanges:h,onCopyCommitHash:g,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:()=>g(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 Jn({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:R,variant:S,isMobileViewport:T,selectedMobilePathSet:p}){return a.map(o=>{if(o.kind==="directory"){const H=!u.has(o.path),C=Yt(o.children),M=`${S==="staged"?n("git.unstage"):n("git.stage")} ${o.path}`,F=`${n("git.discard")} ${o.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":H,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>g(o.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":H,children:e.jsx(ft,{expanded:H})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:o.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:R,children:e.jsx(Xt,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":F,title:F,onClick:()=>void v(C),disabled:R,children:e.jsx(qt,{})}):null]}):null]}),H?e.jsx("div",{className:"git-tree-children",role:"group",children:Jn({nodes:o.children,depth:i+1,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:R,variant:S,isMobileViewport:T,selectedMobilePathSet:p})}):null]},`directory:${o.path}`)}const m=p.has(o.path),y=T?m:h===o.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")} ${o.name}`,onChange:()=>x(o.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(o.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(o.name),"aria-hidden":"true",children:Wt(o.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:o.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":o.status,children:o.status})})]})]},`file:${o.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(o.change.path),f&&f(o.change.path,o.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(o.name),"aria-hidden":"true",children:Wt(o.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:o.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":o.status,children:o.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":o.variant==="staged"?n("git.unstage"):n("git.stage"),title:o.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void b([o.change.path],o.variant==="staged"),disabled:R,children:e.jsx(Xt,{staged:o.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([o.change.path]),disabled:R,children:e.jsx(qt,{})}):null]})]},`file:${o.path}`)})}function Vn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function Wn(a,i){const u=Vn("","");for(const h of a){const g=h.path.replace(/\\/g,"/"),j=g.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:g,change:h,status:hs(h,i),variant:i});return}const R=`directory:${v}`,S=f.children.get(R);if(S&&S.kind==="directory"){f=S;return}const T=Vn(x,v);f.children.set(R,T),f=T})}return ei(Qn([...u.children.values()]))}function Qn(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:Qn([...i.children.values()])}:i)}function ei(a){return a.map(i=>{var f;if(i.kind!=="directory")return i;const u=ei(i.children);let h=i.name,g=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}`,g=x.path,j=x.children}return{kind:"directory",name:h,path:g,children:j}})}function zn(a,i,u){const h=new Set(a);return i.filter(g=>It(g,u)&&h.has(g.path)).map(g=>g.path)}function Yt(a){const i=[],u=new Set;function h(g){if(g.kind==="file"){u.has(g.path)||(u.add(g.path),i.push(g.path));return}g.children.forEach(h)}return a.forEach(h),i}function It(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function hs(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function gs(a){return{subject:ti(a).trim(),body:null,footer:null,source:"manual"}}function ti(a){return a.replace(/[\r\n]+/g," ")}function fs(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 pe(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
2
-
3
- ${u}`:i}function ps(a){const i=a.changedFiles.map(g=>`- [${g.status}] ${g.path}${g.oldPath?` (from ${g.oldPath})`:""}`).join(`
4
- `),u=a.diffContent.length>$t?a.diffContent.slice(0,$t):a.diffContent,h=a.diffContent.length>$t||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 bs(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 ni(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function ii(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function xs(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 qn?js(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function ke(a){return`git-sidebar.snapshot.${a}`}function Bt(a){return a?!!(a.status||a.branches||a.history.length>0||a.historyTotalCount>0||a.historyNextCursor||a.revision):!1}function ys(a){return a?a.snapshot.enabled!==!1:!0}function js(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 Kn(a){return a instanceof qn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function Cs(a,i=!1){return!a||!a.mode||a.mode==="none"?ht:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:i}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:i}:ht}function Ns(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 vs(a,i){const u=gt(a,i);if(!u)return"generic";const h=u.pushUrl||u.fetchUrl;return Ts(h)?"github":"generic"}function gt(a,i){return a.find(u=>u.name===i)??a.find(u=>u.name==="origin")??a[0]??null}function In(a){var i;return(i=gt(a))==null?void 0:i.name}function Ss(a,i){return i!=null&&i.auth?{kind:"session",label:n("git.remoteAuthConfiguredInSession")}:a.credentialConfigured?{kind:"host",label:n("git.remoteAuthConfiguredOnHost")}:{kind:"missing",label:n("git.remoteAuthNotConfigured")}}function Ts(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 Xn(a,i,u){const h=Math.max(0,u.width),g=Math.max(0,u.height),j=Math.max(0,g-O*2),f=Math.max(0,h-O*2),x=Math.min(Math.max(i.width||Kt,0),f),b=Math.max(0,g-a.bottom-mt-O),v=Math.max(0,a.top-mt-O),R=b<i.height&&v>b,T=Vt(Math.max(R?v:b,us),0,j),p=Math.min(Math.max(i.height,0),T),o=R?a.top-mt-p:a.bottom+mt,m=Math.max(O,g-O-p),y=Math.max(O,h-O-x);return{top:Vt(o,O,m),left:Vt(a.right-x,O,y),maxHeight:Math.max(0,T),transformOrigin:`${R?"bottom":"top"} right`}}function Vt(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function ft({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 Xt({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 qt(){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 Ms(){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 si(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{Os as GitSidebar,Xn as resolveGitOperationsMenuPosition};
@@ -1 +0,0 @@
1
- import{b as c,j as e,t as n}from"./index-CeXGOT_T.js";import{j as k,k as j,A as f,B as g,J as M}from"./workbench-navigation-B7IjRQd8.js";import{M as v}from"./MobileSheet-opTWyRe1.js";import{aD as L,a3 as S}from"./WorkbenchLayout-CikJBS62.js";function H({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[a,u]=c.useState(""),[h,m]=c.useState(!1),p=L(),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&&(u(N(i,d)),m(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===a)??i[0]??null;return e.jsxs(v,{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(k,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(j,{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:()=>{p.trigger("selection"),m(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(f,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(g,{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&&p.trigger("selection"),u(s.workspace.id),m(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(M,{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(k,{className:"mobile-create-session-provider-block",heading:n("shell.createSessionProviderLabel"),children:e.jsx(S,{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{H as M};