@vantran-se/openchamber-web 1.23.0 → 1.24.3

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 (362) hide show
  1. package/bin/cli.test.js +29 -6
  2. package/bin/lib/cli-http.js +5 -1
  3. package/bin/lib/commands-status.js +5 -0
  4. package/dist/assets/{CodeMirrorCommentWidgets-DFg2wnpo.js → CodeMirrorCommentWidgets-BjJHrzmU.js} +1 -1
  5. package/dist/assets/DiffView-COVQhWGd.js +4 -0
  6. package/dist/assets/FilesView-B1V5JxFX.js +13 -0
  7. package/dist/assets/GitView-CDOJy5Ay.js +6 -0
  8. package/dist/assets/GuestAttachDialog-D3S0Rjic.js +1 -0
  9. package/dist/assets/{JsonTreeView-BKdsjg5B.js → JsonTreeView-D0C9nU7K.js} +1 -1
  10. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  11. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  12. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  13. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  14. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  15. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  16. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  17. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  18. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  19. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  20. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  21. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  22. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  23. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  24. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  25. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  26. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  27. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  28. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  29. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  30. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  31. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  32. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  33. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  34. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  35. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  36. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  37. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  38. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  39. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  40. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  41. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  42. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  43. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  44. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  45. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  46. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  47. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  48. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  49. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  50. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  51. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  52. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  53. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  54. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  55. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  56. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  57. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  58. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  59. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  60. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  61. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  62. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  63. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  64. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  65. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  66. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  67. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  68. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  69. package/dist/assets/LinearIssuesView-D7FKg1XJ.js +1 -0
  70. package/dist/assets/{MarkdownImageGallery-_5gEVr0X.js → MarkdownImageGallery-BrFjAVEf.js} +1 -1
  71. package/dist/assets/MarkdownRendererImpl-DWepTafh.js +12 -0
  72. package/dist/assets/{OnboardingScreen-DdP4_nuc.js → OnboardingScreen-Dyxxiqdt.js} +1 -1
  73. package/dist/assets/{PatchDiff-am3SAss2.js → PatchDiff-DnEhjXcC.js} +1 -1
  74. package/dist/assets/PierreDiffViewer-DyxZVVVR.js +210 -0
  75. package/dist/assets/{PlanView-BoJxdRZe.js → PlanView-LW2z_EAP.js} +4 -4
  76. package/dist/assets/PluginPane-B4tKno2h.js +3 -0
  77. package/dist/assets/SettingsView-DEaMulN9.js +29 -0
  78. package/dist/assets/{SettingsWindow-DVTdDSol.js → SettingsWindow-FLDJXOgQ.js} +1 -1
  79. package/dist/assets/SubmoduleDiffSummary-CvVwD-Vi.js +1 -0
  80. package/dist/assets/ToolOutputDialog-BiP0x2Rw.js +15 -0
  81. package/dist/assets/{ToolPartDiffPreview-C7WLk5i9.js → ToolPartDiffPreview-CkR4msKP.js} +2 -2
  82. package/dist/assets/{VirtualizedFileDiff-DcdgkH-x.js → VirtualizedFileDiff-0pyr_mHY.js} +4 -4
  83. package/dist/assets/WalkthroughView-yNj4nOP5.js +4 -0
  84. package/dist/assets/appThemeRegistry-BuUKhbYQ.js +1 -0
  85. package/dist/assets/commitAndPush-DvJKa3Ks.js +1 -0
  86. package/dist/assets/{computeVirtualFileMetrics-C8byMnRh.js → computeVirtualFileMetrics-DxTBMuu-.js} +2 -2
  87. package/dist/assets/de-DgxgFyGG.js +10 -0
  88. package/dist/assets/es-BFsZj5F_.js +16 -0
  89. package/dist/assets/fr-jdZ5KKQi.js +14 -0
  90. package/dist/assets/{index-BB7ryz8y.js → index-CKHjPKbq.js} +1 -1
  91. package/dist/assets/index-Cbci4i1W.js +40 -0
  92. package/dist/assets/index-DqaMWNrC.css +1 -0
  93. package/dist/assets/{isDiffPlainText-45ujMPGb.js → isDiffPlainText-D7FkBMP6.js} +1 -1
  94. package/dist/assets/{isFilePlainText-Cc4KFSYi.js → isFilePlainText-CL2vsrIZ.js} +1 -1
  95. package/dist/assets/ja-C5kKrhO4.js +16 -0
  96. package/dist/assets/ko-DXDTT_0O.js +16 -0
  97. package/dist/assets/main-CZALtVek.js +896 -0
  98. package/dist/assets/main-CgXMBNvG.js +2 -0
  99. package/dist/assets/{markdown-shiki.worker-D5fBU-lw.js → markdown-shiki.worker-CahLvHIq.js} +5 -5
  100. package/dist/assets/markdownCore-Dh7WEsdM.js +5 -0
  101. package/dist/assets/miniChat-CwTmDixi.js +2 -0
  102. package/dist/assets/mobile-CLf2vCtO.js +2 -0
  103. package/dist/assets/patchFileDiff-Bsba8KFp.js +13 -0
  104. package/dist/assets/pl-D-7x4Y8Q.js +16 -0
  105. package/dist/assets/pt-BR-CSBZrHa8.js +16 -0
  106. package/dist/assets/renderElectronMiniChatApp-C5gAFBk0.js +2 -0
  107. package/dist/assets/renderMobileApp-V4hYd32H.js +25 -0
  108. package/dist/assets/runtimeEndpointReset-DhlHCn-2.js +25 -0
  109. package/dist/assets/scheduledTasksApi-DzjbLd8P.js +1 -0
  110. package/dist/assets/shikiHighlight-8_3csmr6.js +1 -0
  111. package/dist/assets/surface-B6n7wJtt.js +1 -0
  112. package/dist/assets/textMateThemeFromAppTheme-CHo2fCgW.js +1 -0
  113. package/dist/assets/tr-Dr-oJ22L.js +7 -0
  114. package/dist/assets/uk-9Nx83UcI.js +16 -0
  115. package/dist/assets/useAppFontEffects-khZXpFL_.js +7333 -0
  116. package/dist/assets/useInlineCommentController-DkQ_gqpn.js +2 -0
  117. package/dist/assets/useRootScrollLock-DdvHf9Pt.js +2 -0
  118. package/dist/assets/{vendor-base-ui-DdV8vhHn.js → vendor-base-ui-CsXYnR5c.js} +1 -1
  119. package/dist/assets/{vendor-codemirror-language-data-DzlSIu_W.js → vendor-codemirror-language-data-CdzUmUyZ.js} +2 -2
  120. package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +1 -0
  121. package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
  122. package/dist/assets/{vendor-motion-dom-D_o3BTI3.js → vendor-motion-dom-DcCgeG69.js} +1 -1
  123. package/dist/assets/{vendor-remixicon-react-Dil0zKKT.js → vendor-remixicon-react-BDmGmFCA.js} +1 -1
  124. package/dist/assets/vendor-strip-json-comments-5dJlOkP1.js +4 -0
  125. package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
  126. package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
  127. package/dist/assets/vendor-zod-CgAdXWZO.js +39 -0
  128. package/dist/assets/{web-components-CdGfR2XJ.js → web-components-B8IcVQAA.js} +2 -2
  129. package/dist/assets/zh-CN-Bxy_Hj3r.js +16 -0
  130. package/dist/assets/zh-TW-0BB4gpHM.js +16 -0
  131. package/dist/index.html +6 -4
  132. package/dist/mini-chat.html +6 -4
  133. package/dist/mobile.html +6 -4
  134. package/package.json +12 -9
  135. package/server/built-in-extensions/registry.json +4 -0
  136. package/server/index.d.ts +2 -0
  137. package/server/index.js +47 -23
  138. package/server/lib/agent-memory/runtime.js +7 -2
  139. package/server/lib/agent-memory/runtime.test.js +22 -0
  140. package/server/lib/agent-tool/DOCUMENTATION.md +17 -4
  141. package/server/lib/agent-tool/runtime.js +62 -15
  142. package/server/lib/agent-tool/runtime.test.js +88 -2
  143. package/server/lib/changelog/update-notes.js +2 -1
  144. package/server/lib/changelog/update-notes.test.js +19 -0
  145. package/server/lib/event-stream/DOCUMENTATION.md +26 -0
  146. package/server/lib/event-stream/delta-coalescer.js +0 -0
  147. package/server/lib/event-stream/delta-coalescer.test.js +292 -0
  148. package/server/lib/event-stream/global-hub.js +68 -13
  149. package/server/lib/event-stream/global-hub.test.js +182 -0
  150. package/server/lib/event-stream/global-ws-bridge.js +16 -18
  151. package/server/lib/event-stream/index.js +4 -0
  152. package/server/lib/event-stream/protocol.js +21 -7
  153. package/server/lib/event-stream/runtime.js +9 -6
  154. package/server/lib/event-stream/runtime.test.js +60 -0
  155. package/server/lib/fs/DOCUMENTATION.md +10 -1
  156. package/server/lib/fs/git-process.test.js +77 -0
  157. package/server/lib/fs/routes.js +58 -5
  158. package/server/lib/fs/routes.test.js +116 -0
  159. package/server/lib/fs/search.js +2 -1
  160. package/server/lib/git/DOCUMENTATION.md +30 -6
  161. package/server/lib/git/routes.js +37 -11
  162. package/server/lib/git/routes.test.js +78 -0
  163. package/server/lib/git/serial-refresh.js +93 -0
  164. package/server/lib/git/serial-refresh.test.js +112 -0
  165. package/server/lib/git/service.js +588 -74
  166. package/server/lib/git/service.test.js +492 -0
  167. package/server/lib/github/DOCUMENTATION.md +5 -0
  168. package/server/lib/github/pr-status.js +5 -5
  169. package/server/lib/github/pr-status.test.js +1 -1
  170. package/server/lib/github/routes.js +6 -6
  171. package/server/lib/guests/DOCUMENTATION.md +68 -0
  172. package/server/lib/guests/auth-store.js +184 -0
  173. package/server/lib/guests/auth-store.test.js +112 -0
  174. package/server/lib/guests/background.test.js +83 -0
  175. package/server/lib/guests/builtins.js +34 -0
  176. package/server/lib/guests/builtins.test.js +174 -0
  177. package/server/lib/guests/catalog.js +477 -0
  178. package/server/lib/guests/catalog.test.js +390 -0
  179. package/server/lib/guests/clone.js +297 -0
  180. package/server/lib/guests/extract-zip.js +136 -0
  181. package/server/lib/guests/extract-zip.test.js +109 -0
  182. package/server/lib/guests/files.js +308 -0
  183. package/server/lib/guests/files.test.js +262 -0
  184. package/server/lib/guests/grant-scope.js +81 -0
  185. package/server/lib/guests/grant-scope.test.js +75 -0
  186. package/server/lib/guests/host-session.js +73 -0
  187. package/server/lib/guests/host-session.test.js +30 -0
  188. package/server/lib/guests/html-styles.js +6 -0
  189. package/server/lib/guests/html-styles.test.js +45 -0
  190. package/server/lib/guests/html-tokens.js +73 -0
  191. package/server/lib/guests/html-tokens.test.js +53 -0
  192. package/server/lib/guests/install.js +406 -0
  193. package/server/lib/guests/install.test.js +338 -0
  194. package/server/lib/guests/oauth.js +501 -0
  195. package/server/lib/guests/oauth.test.js +481 -0
  196. package/server/lib/guests/persist.js +336 -0
  197. package/server/lib/guests/persist.test.js +288 -0
  198. package/server/lib/guests/request.js +112 -0
  199. package/server/lib/guests/request.test.js +206 -0
  200. package/server/lib/guests/routes.js +838 -0
  201. package/server/lib/guests/service.js +538 -0
  202. package/server/lib/guests/service.test.js +277 -0
  203. package/server/lib/guests/sockets.js +129 -0
  204. package/server/lib/guests/sockets.test.js +110 -0
  205. package/server/lib/guests/ssh-install.test.js +188 -0
  206. package/server/lib/guests/storage.js +68 -0
  207. package/server/lib/guests/storage.test.js +59 -0
  208. package/server/lib/guests/updates.js +294 -0
  209. package/server/lib/guests/updates.test.js +334 -0
  210. package/server/lib/guests/upload.js +50 -0
  211. package/server/lib/guests/upload.test.js +131 -0
  212. package/server/lib/linear/DOCUMENTATION.md +1 -1
  213. package/server/lib/message-queue/DOCUMENTATION.md +17 -1
  214. package/server/lib/message-queue/runtime.js +34 -1
  215. package/server/lib/message-queue/runtime.test.js +83 -6
  216. package/server/lib/notifications/DOCUMENTATION.md +1 -1
  217. package/server/lib/notifications/emitter-runtime.js +4 -3
  218. package/server/lib/notifications/routes.js +5 -0
  219. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -0
  220. package/server/lib/openchamber-sessions/routes.js +62 -29
  221. package/server/lib/openchamber-sessions/routes.test.js +96 -0
  222. package/server/lib/opencode/DOCUMENTATION.md +73 -5
  223. package/server/lib/opencode/bootstrap-runtime.js +1 -0
  224. package/server/lib/opencode/core-routes.js +39 -1
  225. package/server/lib/opencode/env-runtime.js +5 -1
  226. package/server/lib/opencode/env-runtime.test.js +72 -0
  227. package/server/lib/opencode/feature-routes-runtime.js +30 -1
  228. package/server/lib/opencode/lifecycle-process.test.js +84 -0
  229. package/server/lib/opencode/lifecycle.js +58 -70
  230. package/server/lib/opencode/lifecycle.test.js +29 -0
  231. package/server/lib/opencode/managed-plugin-config.js +1 -1
  232. package/server/lib/opencode/openchamber-routes.js +72 -14
  233. package/server/lib/opencode/openchamber-routes.test.js +71 -3
  234. package/server/lib/opencode/proxy.js +33 -0
  235. package/server/lib/opencode/session-runtime.js +68 -0
  236. package/server/lib/opencode/session-runtime.test.js +43 -0
  237. package/server/lib/opencode/settings-helpers.js +11 -0
  238. package/server/lib/opencode/settings-helpers.test.js +24 -2
  239. package/server/lib/opencode/settings-normalization-runtime.js +2 -0
  240. package/server/lib/opencode/settings-normalization-runtime.test.js +13 -0
  241. package/server/lib/opencode/settings-registry.json +18 -0
  242. package/server/lib/opencode/settings-runtime.js +36 -9
  243. package/server/lib/opencode/settings-runtime.test.js +158 -2
  244. package/server/lib/opencode/shutdown-runtime.js +3 -0
  245. package/server/lib/opencode/shutdown-runtime.test.js +24 -0
  246. package/server/lib/opencode/theme-archive.js +53 -0
  247. package/server/lib/opencode/theme-catalog.js +171 -0
  248. package/server/lib/opencode/theme-catalog.test.js +125 -0
  249. package/server/lib/opencode/theme-import.test.js +144 -0
  250. package/server/lib/opencode/theme-runtime.js +100 -28
  251. package/server/lib/opencode/theme-runtime.test.js +15 -0
  252. package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
  253. package/server/lib/permission-auto-accept/runtime.js +13 -0
  254. package/server/lib/permission-auto-accept/runtime.test.js +37 -1
  255. package/server/lib/project-context/DOCUMENTATION.md +13 -3
  256. package/server/lib/project-context/runtime.js +8 -2
  257. package/server/lib/project-context/runtime.test.js +54 -0
  258. package/server/lib/projects/DOCUMENTATION.md +2 -1
  259. package/server/lib/projects/project-config.js +40 -11
  260. package/server/lib/projects/project-config.test.js +97 -0
  261. package/server/lib/projects/project-id.js +26 -0
  262. package/server/lib/quota/DOCUMENTATION.md +0 -1
  263. package/server/lib/quota/providers/index.js +0 -7
  264. package/server/lib/realtime-proxy-terminal.test.js +150 -0
  265. package/server/lib/realtime-proxy.js +2 -0
  266. package/server/lib/relay/DOCUMENTATION.md +20 -0
  267. package/server/lib/relay/host-client.js +7 -0
  268. package/server/lib/relay/host-client.test.js +14 -0
  269. package/server/lib/routing/DOCUMENTATION.md +83 -0
  270. package/server/lib/routing/defaults.js +98 -0
  271. package/server/lib/routing/feature-flag.js +11 -0
  272. package/server/lib/routing/history.js +34 -0
  273. package/server/lib/routing/jev.js +98 -0
  274. package/server/lib/routing/routes.http.test.js +100 -0
  275. package/server/lib/routing/routes.js +81 -0
  276. package/server/lib/routing/runtime.js +217 -0
  277. package/server/lib/routing/runtime.test.js +188 -0
  278. package/server/lib/routing/store.js +249 -0
  279. package/server/lib/routing/store.test.js +96 -0
  280. package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
  281. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
  282. package/server/lib/scheduled-tasks/runtime.js +14 -4
  283. package/server/lib/scheduled-tasks/runtime.test.js +67 -0
  284. package/server/lib/security/request-security.js +9 -5
  285. package/server/lib/security/request-security.test.js +37 -0
  286. package/server/lib/session-assist/DOCUMENTATION.md +131 -66
  287. package/server/lib/session-assist/context.js +127 -0
  288. package/server/lib/session-assist/context.test.js +132 -0
  289. package/server/lib/session-assist/prompt.js +54 -0
  290. package/server/lib/session-assist/runtime.js +111 -257
  291. package/server/lib/session-assist/runtime.test.js +203 -0
  292. package/server/lib/small-model/DOCUMENTATION.md +14 -2
  293. package/server/lib/small-model/call.js +37 -6
  294. package/server/lib/small-model/call.test.js +182 -0
  295. package/server/lib/terminal/DOCUMENTATION.md +23 -2
  296. package/server/lib/terminal/runtime.js +27 -5
  297. package/server/lib/terminal/runtime.test.js +67 -0
  298. package/server/lib/terminal/shutdown.js +106 -0
  299. package/server/lib/terminal/shutdown.test.js +84 -0
  300. package/server/lib/tts/service.test.js +78 -0
  301. package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
  302. package/server/lib/ui-auth/session-cookie.js +51 -0
  303. package/server/lib/ui-auth/session-cookie.test.js +46 -0
  304. package/server/lib/ui-auth/ui-auth.js +56 -17
  305. package/server/lib/ui-auth/ui-auth.test.js +96 -0
  306. package/server/lib/walkthrough/DOCUMENTATION.md +15 -5
  307. package/server/lib/walkthrough/pr-source.test.js +21 -0
  308. package/server/lib/walkthrough/pull-request.js +7 -4
  309. package/server/lib/walkthrough/pull-request.test.js +16 -0
  310. package/server/lib/walkthrough/routes.js +19 -0
  311. package/server/lib/walkthrough/routes.test.js +26 -0
  312. package/server/lib/walkthrough/sources.js +13 -2
  313. package/server/opencode-worktree-readiness.test.js +130 -0
  314. package/dist/assets/DiffView-3Dn4QHbu.js +0 -4
  315. package/dist/assets/DirtyBranchSwitchDialog-CwOerqVi.js +0 -1
  316. package/dist/assets/FilesView-BdTOpew9.js +0 -17
  317. package/dist/assets/GitView-Dqf9vHJh.js +0 -6
  318. package/dist/assets/LinearIssuesView-CmbeL7I6.js +0 -1
  319. package/dist/assets/MarkdownRendererImpl-wVZlx4dd.js +0 -12
  320. package/dist/assets/PierreDiffViewer-DCsydlKs.js +0 -161
  321. package/dist/assets/SettingsView-CcM8pF5O.js +0 -28
  322. package/dist/assets/ToolOutputDialog-BgfTbDZ4.js +0 -15
  323. package/dist/assets/WalkthroughView-BEVUDxuw.js +0 -4
  324. package/dist/assets/appThemeRegistry-BK0dHKa6.js +0 -1
  325. package/dist/assets/de-C8jV7J9y.js +0 -10
  326. package/dist/assets/es-BI6J1M5R.js +0 -16
  327. package/dist/assets/fr-D6oDFt7E.js +0 -14
  328. package/dist/assets/index-BqhiCmYS.js +0 -39
  329. package/dist/assets/index-FqSOBz0J.css +0 -1
  330. package/dist/assets/ja-C_4i5EQu.js +0 -16
  331. package/dist/assets/ko-BFbOTpbq.js +0 -16
  332. package/dist/assets/main-C9ETLKFc.js +0 -2
  333. package/dist/assets/main-CJmb2dF8.js +0 -930
  334. package/dist/assets/markdownCore-DVuZpnli.js +0 -5
  335. package/dist/assets/miniChat-B4Ytoq2n.js +0 -2
  336. package/dist/assets/mobile-BUT6-lo1.js +0 -2
  337. package/dist/assets/patchFileDiff-8j1apICU.js +0 -13
  338. package/dist/assets/pl-COFvT56l.js +0 -16
  339. package/dist/assets/pt-BR-DtVOO2Lj.js +0 -16
  340. package/dist/assets/registerCustomTheme-BBXUCRnG.js +0 -1
  341. package/dist/assets/renderElectronMiniChatApp-B6vUG-vF.js +0 -2
  342. package/dist/assets/renderMobileApp-BNgHraq6.js +0 -25
  343. package/dist/assets/runtimeEndpointReset-B8LYpWvr.js +0 -17
  344. package/dist/assets/scheduledTasksApi-GC4epIYA.js +0 -1
  345. package/dist/assets/shikiHighlight-BJISeZsQ.js +0 -1
  346. package/dist/assets/surface-BvRzS58U.js +0 -1
  347. package/dist/assets/tr-B8Q0Go2l.js +0 -7
  348. package/dist/assets/uk-Dk4a-Fn-.js +0 -16
  349. package/dist/assets/useAppFontEffects-DpFNefUA.js +0 -7284
  350. package/dist/assets/useGitComparison-Dfxaqd0s.js +0 -1
  351. package/dist/assets/useInlineCommentController-CscsE4t-.js +0 -2
  352. package/dist/assets/useRootScrollLock-BaCvuRlT.js +0 -1
  353. package/dist/assets/vendor-framer-motion-livSKyyV.js +0 -1
  354. package/dist/assets/vendor-zod-BPAANqvH.js +0 -39
  355. package/dist/assets/zh-CN-B_BXxG1Q.js +0 -16
  356. package/dist/assets/zh-TW-DLrl1SPZ.js +0 -16
  357. package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
  358. package/server/lib/mcp-reconnect/runtime.js +0 -122
  359. package/server/lib/mcp-reconnect/runtime.test.js +0 -140
  360. package/server/lib/quota/providers/crof.js +0 -96
  361. package/server/lib/quota/providers/crof.test.js +0 -98
  362. /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
@@ -1 +0,0 @@
1
- import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as J,aw as Ee,a7 as be,a8 as ye,I as E,a9 as we,h as Z,B as Y,a2 as Te,hc as Ie,bL as fe,bM as ue,bN as pe,bO as ge,bP as xe,bQ as ve,bb as Me,c5 as Pe,t as ae}from"./useAppFontEffects-DpFNefUA.js";import{u as ke}from"./index-BqhiCmYS.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Re=Se.M;function Fe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Fe(p);return Se[e]??Re}const $e=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=He(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=J(),H=u.description,R=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let $;t[7]!==a?($=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=$):$=t[8];const W=$;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const F=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let P;t[13]!==v?(P=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=P):P=t[14];const q=o?F:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==H||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:H,"aria-label":H,children:u.code}),t[17]=u.code,t[18]=H,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Q;t[30]===Symbol.for("react.memo_cache_sentinel")?(Q={color:"var(--status-success)"},t[30]=Q):Q=t[30];let i;t[31]!==R?(i=s.jsxs("span",{style:Q,children:["+",R]}),t[31]=R,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:F;let ee;return t[46]!==T||t[47]!==d||t[48]!==P||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:P,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=P,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Qe=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=J(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),H=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),R=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from(H[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[H,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(R);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),R.forEach(m=>n.add(m)),n})},[f,R]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe(H[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,H,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),$=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice($,$+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,$]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),F=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=F.length,P=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||F.length===0||(await g(F),c(!1))},[F,r,g]),K=N.useCallback(async()=>{!d||!u||P||(await d(u.paths),I(null))},[P,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:Z("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:Z("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:Z("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:Z("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx($e,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Q=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:Z(Q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:Z("relative",Q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!P&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:P,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:P||!u,children:a(P?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=J(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const $=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const F=y.scrollHeight,X=Math.min(Math.max(F,he),re);y.style.height=`${X}px`,y.style.overflowY=F>re?"auto":"hidden",F>re&&!$&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",H=S?"sentences":"off",R=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=Z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==H||e[15]!==R||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:H,spellCheck:R,className:z,style:T}),e[13]=h,e[14]=H,e[15]=R,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=J();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=J(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:H}=Me();let R;e[5]!==o?(R=o("gitView.commit.title"),e[5]=o,e[6]=R):R=e[6];let A;e[7]!==R?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:R}),e[7]=R,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let $;e[22]!==o?($=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=$):$=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==H||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==$?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:$,disabled:W,hasTouchInput:H,isMobile:I}),e[24]=r,e[25]=H,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=$,e[31]=L):L=e[31];let F;e[32]!==V||e[33]!==k||e[34]!==o?(F=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=F):F=e[35];const X=a||f!==null||v||t===0;let P;e[36]!==o?(P=o("gitView.commit.generateAria"),e[36]=o,e[37]=P):P=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==P||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":P,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=P,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Q=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Q||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Q,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==F||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,F,D]}),e[72]=L,e[73]=F,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Je=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=J(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pe,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Qe as C,Je as D,Ze as a};
@@ -1,17 +0,0 @@
1
- import{f as ot,R as s,c as Ws,j as r,r as at}from"./vendor-react-BUCujlKS.js";import{Z as Pa,_ as Ma,$ as Da,a0 as za,t as Xe,a as Us,u as vt,dA as La,G as Ks,A as Aa,h as Hs,a5 as qs,e as Ia,dy as Oa,a4 as Ba,dz as $a}from"./index-BqhiCmYS.js";import{f as Ht,y as Gs,ac as gi,bY as _a,h as q,hI as Wa,fw as Ua,T as lr,B as O,I as F,W as Ka,N as Ha,bb as qa,ae as Ga,cc as Xa,eg as Xs,hJ as Js,hK as Ja,h6 as Qa,fx as Ya,t as Q,l as Qs,au as pn,c7 as or,cK as Za,b as eo,hL as Dr,bK as to,av as gn,hM as Ys,c8 as Zs,c9 as ei,gm as ro,hN as no,hO as so,hP as io,bL as vi,bM as xi,bN as wi,bO as bi,bP as yi,bQ as ji,ao as jn,ap as Fn,aw as Ar,ar as Nn,b9 as Ir,bR as vn,ax as xn,c4 as ti,a7 as Ot,a8 as Bt,a9 as $t,bI as ao,bJ as oo,g as Br,ba as lo,bl as co}from"./useAppFontEffects-DpFNefUA.js";import{a9 as uo,J as fo,K as mo,L as ho,M as po,Q as go}from"./runtimeEndpointReset-B8LYpWvr.js";import{c as ri,s as vo,P as wn,C as xo}from"./shikiHighlight-BJISeZsQ.js";import{a as wo}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Nt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as bo,J as yo,F as jo}from"./JsonTreeView-BKdsjg5B.js";import{ensurePierreThemeRegistered as ni,getResolvedShikiTheme as Fo}from"./appThemeRegistry-BK0dHKa6.js";import{V as No,W as Co}from"./Virtualizer-CZlLSacm.js";import{V as So}from"./Virtualizer-D_a8gKmg.js";import{u as zr,c as ko,e as Ro}from"./scheduledTasksApi-GC4epIYA.js";import{D as To}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Eo,u as Vo,n as Po}from"./useInlineCommentController-CscsE4t-.js";import{b as Mo}from"./CodeMirrorCommentWidgets-DFg2wnpo.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BPAANqvH.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-DdV8vhHn.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DzlSIu_W.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-CdGfR2XJ.js";import"./computeVirtualFileMetrics-C8byMnRh.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-Cc4KFSYi.js";import"./registerCustomTheme-BBXUCRnG.js";function si(a){const e=ot.c(41),{containerRef:n,filePath:d,fileContent:x}=a,{t:g}=Ht(),w=Gs($o),v=Gs(Bo),f=gi(),j=_a(Oo),[m,y]=s.useState(null),[N,S]=s.useState(""),[C,T]=s.useState(!1),o=s.useRef(!1),E=s.useRef(null),D=s.useRef(null),[A,V]=s.useState(null);let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{y(null),S(""),T(!1),o.current=!1,D.current=null,V(null)},e[0]=P):P=e[0];const M=P;let k,I;e[1]!==n?(k=()=>{const $=n.current;if(!$)return;const H=()=>{if(o.current)return;const ne=window.getSelection(),ke=ne?.toString().trim()??"";if(!ne||!ke||ne.rangeCount===0){M();return}const oe=ne.getRangeAt(0);if(!$.contains(oe.commonAncestorContainer)){M();return}const le=oe.getBoundingClientRect();D.current=oe.cloneRange(),S(ke),y({x:le.left+le.width/2,y:le.top-10})},re=ne=>{E.current?.contains(ne.target)||o.current&&M()};return document.addEventListener("selectionchange",H),document.addEventListener("pointerdown",re),()=>{document.removeEventListener("selectionchange",H),document.removeEventListener("pointerdown",re)}},I=[n,M],e[1]=n,e[2]=k,e[3]=I):(k=e[2],I=e[3]),s.useEffect(k,I);let _;e[4]!==x?(_=$=>{const H=de=>x.slice(0,de).split(`
2
- `).length,re=Ao,ne=(de,Ve)=>{for(const Pe of re(de)){const Re=x.indexOf(Pe,Ve);if(Re>=0)return Re}return-1},ke=$.length>=8?x.indexOf($):-1;if(ke>=0){const de=H(ke);return{start:de,end:de+$.split(`
3
- `).length-1}}const oe=$.split(`
4
- `).map(Lo).filter(Boolean);if(oe.length===0)return null;const le=ne(oe[0],0);if(le<0)return null;const be=H(le);if(oe.length===1)return{start:be,end:be};const Ee=ne(oe[oe.length-1],le);return Ee<0?null:{start:be,end:Math.max(be,H(Ee))}},e[4]=x,e[5]=_):_=e[5];const L=_;let X;e[6]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{const $=D.current;if(!$){V(null);return}V(Wa($))},e[6]=X):X=e[6];const Ce=X;let W,Y;e[7]!==C?(W=()=>{if(!C)return;let $=null;const H=()=>{$===null&&($=window.requestAnimationFrame(()=>{$=null,Ce()}))};return document.addEventListener("scroll",H,{capture:!0,passive:!0}),window.addEventListener("resize",H),()=>{$!==null&&window.cancelAnimationFrame($),document.removeEventListener("scroll",H,{capture:!0}),window.removeEventListener("resize",H)}},Y=[C,Ce],e[7]=C,e[8]=W,e[9]=Y):(W=e[8],Y=e[9]),s.useEffect(W,Y);let ee;e[10]!==N?(ee=()=>{N&&(T(!0),o.current=!0,Ce(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ee):ee=e[11];const ce=ee;let te;e[12]!==j||e[13]!==w||e[14]!==f||e[15]!==d||e[16]!==v||e[17]!==L||e[18]!==N?(te=$=>{const H=w??(v?"draft":null);if(!N||!H||!f){M();return}const re=L(N);j({directory:f,sessionKey:H},{source:"file-quote",fileLabel:d,startLine:re?.start??0,endLine:re?.end??0,code:N,language:"",text:$.trim()}),M(),queueMicrotask(zo)},e[12]=j,e[13]=w,e[14]=f,e[15]=d,e[16]=v,e[17]=L,e[18]=N,e[19]=te):te=e[19];const Se=te;if(!m)return null;let B;e[20]!==C||e[21]!==L||e[22]!==N?(B=C?L(N):null,e[20]=C,e[21]=L,e[22]=N,e[23]=B):B=e[23];const ve=B;let xe;e[24]!==m.x||e[25]!==m.y?(xe={left:m.x,top:m.y,transform:"translate(-50%, -100%)"},e[24]=m.x,e[25]=m.y,e[26]=xe):xe=e[26];let ue;e[27]!==C||e[28]!==A?(ue=C&&A&&A.length>0?Ws.createPortal(r.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:A.map(Do)}),document.body):null,e[27]=C,e[28]=A,e[29]=ue):ue=e[29];let ae;e[30]!==C||e[31]!==d||e[32]!==ve||e[33]!==ce||e[34]!==Se||e[35]!==g?(ae=C?r.jsx("div",{className:"w-[min(420px,80vw)]",children:r.jsx(Eo,{fileLabel:d,lineRange:ve?{start:ve.start,end:ve.end}:void 0,onSave:Se,onCancel:M})}):r.jsx("div",{className:q("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:r.jsx("button",{type:"button",onClick:ce,className:q("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:g("chat.textSelection.title.commentOnSelection"),children:g("chat.textSelection.actions.comment")})}),e[30]=C,e[31]=d,e[32]=ve,e[33]=ce,e[34]=Se,e[35]=g,e[36]=ae):ae=e[36];let we;return e[37]!==xe||e[38]!==ue||e[39]!==ae?(we=Ws.createPortal(r.jsxs("div",{ref:E,className:"fixed z-50",style:xe,children:[ue,ae]}),document.body),e[37]=xe,e[38]=ue,e[39]=ae,e[40]=we):we=e[40],we}function Do(a,e){return r.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:a.left,top:a.top,width:a.width,height:a.height}},e)}function zo(){Ua()}function Lo(a){return a.trim()}function Ao(a){const e=a.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Io)}function Io(a){return a.length>=8}function Oo(a){return a.addDraft}function Bo(a){return a.newSessionDraft?.open}function $o(a){return a.currentSessionId}const _o=(a,e)=>{if(!e)return null;const n=Number.parseInt(a.trim(),10);return!Number.isFinite(n)||n<1?null:Math.min(n,e.state.doc.lines)},ii=(a,e)=>{const n=a.state.doc.lineAt(e.main.head);return{lineNumber:n.number,character:e.main.head-n.from+1,selection:e}},ai=(a,e,n)=>{const d=a.state.doc.line(e),x=Math.max(1,Math.min(n,d.length+1)),g=d.from+x-1;a.dispatch({selection:wo.cursor(g),effects:Nt.scrollIntoView(g,{y:"center"})})};function Wo({open:a,onOpenChange:e,view:n,variant:d="overlay"}){const{t:x}=Ht(),[g,w]=s.useState(""),v=s.useRef(null),f=s.useRef(!1),j=s.useRef(null),m=s.useRef(null),y=s.useMemo(()=>_o(g,n),[g,n]);s.useEffect(()=>{!a||!n||(f.current=!1,v.current=ii(n,n.state.selection),w(""))},[a,n]),s.useEffect(()=>{a&&window.requestAnimationFrame(()=>{m.current?.focus(),m.current?.select()})},[a]),s.useEffect(()=>{if(!(!a||!n||!v.current)){if(y===null){const{selection:o}=v.current;n.dispatch({selection:o,effects:Nt.scrollIntoView(o.main.from,{y:"center"})});return}ai(n,y,v.current.character)}},[y,a,n]);const N=s.useCallback(()=>{if(!n||f.current||!v.current)return;const{selection:o}=v.current;n.dispatch({selection:o,effects:Nt.scrollIntoView(o.main.from,{y:"center"})})},[n]),S=s.useCallback(o=>{o||N(),e(o)},[e,N]),C=s.useCallback(()=>{!n||y===null||!v.current||(f.current=!0,ai(n,y,v.current.character),e(!1),n.focus())},[y,e,n]);s.useEffect(()=>{if(!a)return;const o=D=>{const A=j.current,V=D.target;!A||!(V instanceof Node)||A.contains(V)||S(!1)},E=D=>{D.key==="Escape"&&(D.preventDefault(),S(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",E,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",E,!0)}},[S,a,d]);const T=s.useMemo(()=>{if(!n)return x("goToLineDialog.helper.editorUnavailable");if(y===null){const o=v.current??ii(n,n.state.selection);return x("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:n.state.doc.lines})}return x("goToLineDialog.helper.goToLine",{line:y})},[y,x,n]);return d==="inline"?a?r.jsxs("div",{ref:j,className:"ml-1 flex h-6 items-center gap-1",children:[r.jsx(lr,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>w(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),C())},placeholder:x("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),r.jsx(O,{variant:"outline",size:"xs",onClick:C,disabled:!n||y===null,className:"h-6 px-2",children:x("goToLineDialog.actions.go")})]}):null:r.jsx("div",{ref:j,className:q("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",a?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:r.jsxs("div",{className:"min-w-0",children:[r.jsx(lr,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>w(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),C())},placeholder:x("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),r.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:T})]})})}const Uo=(a,e)=>{const n=e.trim().toLowerCase(),d=[];if(!n)return d;const x=a.toLowerCase();let g=0;for(;;){const w=x.indexOf(n,g);if(w===-1)break;d.push({start:w,end:w+n.length}),g=w+n.length}return d},_r="data-md-find",bn="data-md-find-current",Fi="rounded-[2px] bg-status-warning/30 text-foreground",Ko="rounded-[2px] bg-status-warning/60 text-foreground",Ho=120,qo=a=>a instanceof Element&&a.hasAttribute(_r),Go=a=>a.target instanceof Element&&a.target.hasAttribute(_r)?!0:[...a.addedNodes].some(e=>qo(e)),Ni=a=>{const e=new Set;a.querySelectorAll(`mark[${_r}]`).forEach(n=>{const d=n.parentNode;d&&(d.replaceChild(document.createTextNode(n.textContent??""),n),e.add(d))}),e.forEach(n=>n.normalize())},Xo=(a,e)=>{Ni(a);const n=e.trim().toLowerCase();if(!n)return[];const d=[],x=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,{acceptNode(w){const v=w.parentElement;return!v||v.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),g=[];for(;x.nextNode();){const w=x.currentNode;w instanceof Text&&g.push(w)}for(const w of g){const v=w.nodeValue??"";if(!v)continue;const f=Uo(v,n);if(f.length===0)continue;const j=w.parentNode;if(!j)continue;const m=document.createDocumentFragment();let y=0;for(const N of f){N.start>y&&m.appendChild(document.createTextNode(v.slice(y,N.start)));const S=document.createElement("mark");S.setAttribute(_r,""),S.className=Fi,S.textContent=v.slice(N.start,N.end),m.appendChild(S),d.push(S),y=N.end}y<v.length&&m.appendChild(document.createTextNode(v.slice(y))),j.replaceChild(m,w)}return d},oi=({containerRef:a,open:e,onOpenChange:n,focusNonce:d,className:x})=>{const{t:g}=Ht(),[w,v]=s.useState(""),[f,j]=s.useState(0),[m,y]=s.useState(0),N=s.useRef(null),S=s.useRef([]),C=s.useRef(w);C.current=w;const T=s.useRef(null),o=s.useRef(null),E=s.useCallback((k,I=!1)=>{const _=a.current;if(!_){S.current=[],j(0),y(0);return}S.current=Xo(_,k);const L=S.current.length;j(L),y(X=>!I||L===0?0:Math.min(X,L-1))},[a]),D=s.useCallback((k,I=!1)=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{T.current=null,E(k,I)},Ho)},[E]);s.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const A=s.useCallback(()=>{n(!1);const k=o.current;o.current=null,k?.isConnected&&k.focus()},[n]);s.useEffect(()=>{const k=a.current;if(!e||!k)return;const I=new MutationObserver(_=>{!C.current.trim()||!_.some(X=>!Go(X))||D(C.current,!0)});return I.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{I.disconnect(),Ni(k)}},[a,e,D]),s.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!o.current&&(o.current=k),N.current?.focus()},[e]),s.useEffect(()=>{e&&d>0&&(N.current?.focus(),N.current?.select())},[e,d]),s.useEffect(()=>{const k=a.current;if(!k||(k.querySelectorAll(`mark[${bn}]`).forEach(_=>{_.removeAttribute(bn),_.className=Fi}),f===0))return;const I=S.current[Math.min(Math.max(m,0),f-1)];I&&(I.setAttribute(bn,""),I.className=Ko,I.scrollIntoView({block:"nearest"}))},[a,m,f]);const V=s.useCallback(()=>{y(k=>f===0?0:(k+1)%f)},[f]),P=s.useCallback(()=>{y(k=>f===0?0:(k-1+f)%f)},[f]),M=s.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?P():V()):k.key==="Escape"&&(k.preventDefault(),A())},[A,V,P]);return e?r.jsxs("div",{className:q("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",x),children:[r.jsx(F,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),r.jsx(lr,{ref:N,value:w,onChange:k=>{v(k.target.value),D(k.target.value)},onKeyDown:M,placeholder:g("filesView.preview.find.placeholder"),"aria-label":g("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),r.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":f>0?g("filesView.preview.find.countAria",{current:m+1,total:f}):g("filesView.preview.find.noMatches"),children:w.trim()&&f===0?g("filesView.preview.find.noMatches"):f>0?`${m+1}/${f}`:""}),r.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:g("filesView.preview.find.previousAria"),"aria-label":g("filesView.preview.find.previousAria"),disabled:f===0,children:r.jsx(F,{name:"arrow-up",className:"size-3.5"})}),r.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:V,title:g("filesView.preview.find.nextAria"),"aria-label":g("filesView.preview.find.nextAria"),disabled:f===0,children:r.jsx(F,{name:"arrow-down",className:"size-3.5"})}),r.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:A,title:g("filesView.preview.find.closeAria"),"aria-label":g("filesView.preview.find.closeAria"),children:r.jsx(F,{name:"close",className:"size-3.5"})})]}):null},Jo=a=>{let e=!0;return{poll:async()=>{if(!e||a.isDirty())return!1;const n=a.getLoadedContent(),d=a.getLoadedRevision();try{const x=await a.readContent();if(!e||a.isDirty()||d!==a.getLoadedRevision())return!1;if(x===n)return!0;const g=await a.readContent();return!e||a.isDirty()||g!==x||d!==a.getLoadedRevision()?!1:(a.applyContent(x),!0)}catch{return!1}},dispose:()=>{e=!1}}},Qo=1,Yo=(a,e)=>e.size!==a.size||e.mtimeMs!==void 0&&a.mtimeMs!==void 0&&Math.abs(e.mtimeMs-a.mtimeMs)>=Qo;function li(){const a=ot.c(8),[e]=at.useState(Zo),n=at.useRef(!1);let d;a[0]!==e?(d=f=>{if(f==null){e.cleanUp(),n.current=!1;return}n.current||(n.current=!0,e.setup(f,f.firstElementChild??void 0))},a[0]=e,a[1]=d):d=a[1];const x=d;let g,w;a[2]!==e?(g=()=>()=>{n.current=!1,e.cleanUp()},w=[e],a[2]=e,a[3]=g,a[4]=w):(g=a[3],w=a[4]),at.useLayoutEffect(g,w);let v;return a[5]!==x||a[6]!==e?(v={virtualizer:e,setScroller:x},a[5]=x,a[6]=e,a[7]=v):v=a[7],v}function Zo(){return new So}const _t=new Map,el=100;function Lr(a){const[e,n]=at.useState(null),d=at.useRef(null),x=at.useRef(null),g=at.useRef(null),w=at.useCallback((v,f)=>{v&&f instanceof bo&&(g.current={key:a,file:f,node:v});const j=d.current,m=x.current,y=()=>{d.current===j&&(j?.(),m?.())};f?queueMicrotask(y):y()},[a]);return at.useLayoutEffect(()=>{if(!e||!a)return;const v=_t.get(a)??{top:0,left:0};let f=!0;const j=()=>g.current?.key===a?g.current.file:null,m=E=>g.current?.key===a?g.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${E-1}"]`):null,y=()=>{S.disconnect(),C.disconnect()},N=()=>{if(!f)return;const E=j(),D=v.line&&E?.getLinePosition(v.line.number),A=v.line&&m(v.line.number);let V=v.top;v.line&&D&&(V=(E?.top??0)+D.top-v.line.offset),v.line&&A&&(V=e.scrollTop+A.getBoundingClientRect().top-e.getBoundingClientRect().top-v.line.offset),e.scrollTop=V,e.scrollLeft=v.left,(!v.line||A)&&Math.abs(e.scrollTop-V)<1&&Math.abs(e.scrollLeft-v.left)<1&&(f=!1,y())},S=new ResizeObserver(N),C=new MutationObserver(()=>{if(f){for(const E of e.children)S.observe(E);N()}});S.observe(e);for(const E of e.children)S.observe(E);C.observe(e,{childList:!0,subtree:!0});const T=()=>{if(f)return;const E=j(),D=E?.getNumericScrollAnchor(e.scrollTop-(E.top??0)),A=D&&m(D.lineNumber),V=A?A.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(_t.delete(a),_t.set(a,{top:e.scrollTop,left:e.scrollLeft,line:D&&V!==null&&V>=0&&V<e.clientHeight?{number:D.lineNumber,offset:V}:void 0}),_t.size>el){const P=_t.keys().next().value;P!==void 0&&_t.delete(P)}},o=()=>{f=!1,y()};return d.current=N,x.current=T,N(),e.addEventListener("scroll",T,{passive:!0}),e.addEventListener("wheel",o,{passive:!0}),e.addEventListener("touchstart",o,{passive:!0}),e.addEventListener("pointerdown",o,{passive:!0}),e.addEventListener("keydown",o),()=>{d.current=null,x.current=null,g.current?.key===a&&(g.current=null),y(),e.removeEventListener("scroll",T),e.removeEventListener("wheel",o),e.removeEventListener("touchstart",o),e.removeEventListener("pointerdown",o),e.removeEventListener("keydown",o)}},[a,e]),{setScroller:n,restore:w}}function tl(a){return!(!a.autoSaveEnabled||!a.isDirty||!a.canWrite||a.isSaving||a.fileLoading||a.isNonEditableBinary||!a.selectedFilePath||a.loadedFilePath!==a.selectedFilePath)}function rl(a){return a.selectedFilePath?a.isDirty?!(a.fileLoading||a.loadedFilePath!==a.selectedFilePath||a.isNonEditableBinary||a.draftContent===""&&a.fileContent!==""&&a.loadedFilePath!==a.selectedFilePath):!0:!1}const nl='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function ci(){if(typeof document>"u")return!1;const a=document.documentElement.getAttribute("data-theme");return a==="dark"||!a&&window.matchMedia("(prefers-color-scheme: dark)").matches}const sl=s.forwardRef(function({xml:e,readOnly:n,className:d,onChange:x},g){const w=s.useRef(e),v=s.useRef(null),f=s.useRef(!1),[j,m]=s.useState(ci),y=s.useRef(e),N=s.useRef(e);N.current!==e&&(N.current=e,y.current=e,w.current=e);const S=s.useRef(j);S.current!==j&&(S.current=j,y.current=w.current);const C=s.useRef(null);s.useEffect(()=>{const E=()=>m(ci());E();const D=new MutationObserver(E);return D.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>D.disconnect()},[]),s.useEffect(()=>{const E=setTimeout(()=>{C.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(E)},[]),s.useImperativeHandle(g,()=>({getXml:()=>w.current}));const T=s.useCallback(()=>{!e&&!f.current&&(f.current=!0,setTimeout(()=>{v.current?.template({})},500))},[e]),o=s.useCallback(E=>{w.current=E.xml,x?.(E.xml)},[x]);return r.jsx("div",{ref:C,className:q("h-full w-full",d),children:r.jsx(To,{ref:v,xml:y.current||nl,autosave:!0,urlParameters:{ui:n?"simple":j?"dark":"kennedy",spin:!0,libraries:!n,chrome:n,nav:n,layers:n,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:T,onAutoSave:o},j?"dark":"light")})}),il=a=>{const e=K(a);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const n=e.lastIndexOf("/");if(n<0)return e;if(n===0)return"/";const d=e.slice(0,n);return/^[A-Za-z]:$/.test(d)?`${d}/`:d},al=a=>{const e=ot.c(8),{label:n,iconDataUrl:d}=a,[x,g]=s.useState(!1);let w;e[0]!==n?(w=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=w):w=e[1];const v=w;if(d&&!x){let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>g(!0),e[2]=m):m=e[2];let y;return e[3]!==d?(y=r.jsx("img",{src:d,alt:"",className:"size-4 rounded-sm",onError:m}),e[3]=d,e[4]=y):y=e[4],y}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=q("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=f):f=e[5];let j;return e[6]!==v?(j=r.jsx("span",{className:f,children:v}),e[6]=v,e[7]=j):j=e[7],j},ol=a=>a.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),K=a=>{if(!a)return"";const e=a.replace(/\\/g,"/"),n=e.startsWith("//");let d=e.replace(/\/+/g,"/");n&&!d.startsWith("//")&&(d=`/${d}`);const x=d==="/",g=/^[A-Za-z]:\/$/.test(d);return!x&&!g&&(d=d.replace(/\/+$/,"")),d},ll=a=>a.startsWith("/")||a.startsWith("//")||/^[A-Za-z]:\//.test(a),Kt=a=>/^[A-Za-z]:\//.test(a)?a.toLowerCase():a,$r=(a,e)=>{const n=K(e),d=K(a);if(!n||!d)return!1;const x=Kt(n),g=Kt(d);return g===x||g.startsWith(`${x}/`)},ui=(a,e)=>{const n=K(e),d=K(a);if(!$r(d,n))return[];const g=d.slice(n.length).replace(/^\//,"").split("/"),w=[];let v=n;for(let f=0;f<g.length-1;f++)v=v?`${v}/${g[f]}`:g[f],w.push(v);return w},Or=(a,e)=>{if(!e)return"";const n=K(e);if(!a||!$r(n,a))return n;const d=n.slice(a.length);return d.startsWith("/")?d.slice(1):d},cl=new Set(["node_modules"]),ul=a=>{const e=ot.c(3),{status:n}=a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=d):d=e[0];const x=d[n];let g;return e[1]!==x?(g=r.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:x}}),e[1]=x,e[2]=g):g=e[2],g},di=a=>{const e=ot.c(11),{name:n}=a,d=s.useRef(null),x=s.useRef(null),[g,w]=s.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const N=d.current,S=x.current;if(!N||!S)return;const C=()=>{w(S.scrollWidth>N.clientWidth+1)};C();const T=new ResizeObserver(C);return T.observe(N),T.observe(S),()=>{T.disconnect()}},e[0]=v):v=e[0];let f;e[1]!==n?(f=[n],e[1]=n,e[2]=f):f=e[2],s.useLayoutEffect(v,f);let j;e[3]!==n?(j=r.jsx("span",{ref:x,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:n}),e[3]=n,e[4]=j):j=e[4];let m;e[5]!==n||e[6]!==g?(m=g?r.jsxs("span",{className:"open-file-name-marquee-track",children:[r.jsx("span",{className:"open-file-name-marquee-item",children:n}),r.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:n})]}):r.jsx("span",{className:"block min-w-0 truncate",children:n}),e[5]=n,e[6]=g,e[7]=m):m=e[7];let y;return e[8]!==j||e[9]!==m?(y=r.jsxs("span",{ref:d,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[j,m]}),e[8]=j,e[9]=m,e[10]=y):y=e[10],y},dl=a=>cl.has(a),fl=a=>{const e=K(a);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},ml=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("is a directory")||n.includes("eisdir")},fi=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("file not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")},Wt=2e5,hl=2e5;function pl(a){const e=a.length>400?`${a.slice(0,200)}${a.slice(-200)}`:a;let n=2166136261;for(let d=0;d<e.length;d+=1)n^=e.charCodeAt(d),n=n+((n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24))>>>0;return`${a.length}:${n.toString(16)}`}const gl=a=>{let e=0,n=0;for(let d=0;d<a.length;d+=1)a.charCodeAt(d)===10&&(d>0&&a.charCodeAt(d-1)===13?e+=1:n+=1);return e>n?`\r
5
- `:`
6
- `},Ci=a=>a.replace(/\r\n/g,`
7
- `).replace(/\r/g,`
8
- `),vl=(a,e)=>{const n=Ci(a);return e===`\r
9
- `?n.replace(/\n/g,`\r
10
- `):n},Si=(a,e)=>r.jsx(Ar,{filePath:a,extension:e}),mi=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},xl=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},yn=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="html"||e==="htm"},wl=a=>{const e=ot.c(76),{node:n,root:d,isExpanded:x,isActive:g,isMobile:w,isBrowserClient:v,alwaysShowActions:f,status:j,badge:m,permissions:y,downloadFile:N,contextMenuPath:S,setContextMenuPath:C,rightClickMenuPath:T,setRightClickMenuPath:o,onSelect:E,onToggle:D,onRevealPath:A,onOpenDialog:V}=a,{t:P}=Ht(),M=n.type==="directory",{canRename:k,canCreateFile:I,canCreateFolder:_,canDelete:L,canReveal:X}=y,Ce=!M&&!!N,W=X&&!v,Y=k||I||_||L||Ce||W;let ee;e[0]!==Y||e[1]!==n.path||e[2]!==o?(ee=fe=>{Y&&(fe?.preventDefault(),o(n.path))},e[0]=Y,e[1]=n.path,e[2]=o,e[3]=ee):ee=e[3];const ce=ee;let te;e[4]!==M||e[5]!==n||e[6]!==E||e[7]!==D?(te=()=>{M?D(n.path):E(n)},e[4]=M,e[5]=n,e[6]=E,e[7]=D,e[8]=te):te=e[8];const Se=te;let B;e[9]!==n.path||e[10]!==C||e[11]!==o?(B=fe=>{fe.stopPropagation(),o(null),C(n.path)},e[9]=n.path,e[10]=C,e[11]=o,e[12]=B):B=e[12];const ve=B;let xe;e[13]!==I||e[14]!==_||e[15]!==L||e[16]!==k||e[17]!==W||e[18]!==N||e[19]!==v||e[20]!==M||e[21]!==n||e[22]!==V||e[23]!==A||e[24]!==d||e[25]!==P?(xe=fe=>{const{Item:pe,Separator:tt}=fe;return r.jsxs(r.Fragment,{children:[k&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("rename",n)},children:[r.jsx(F,{name:"edit",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.rename")]}),r.jsxs(pe,{onClick:G=>{G.stopPropagation(),Br(n.path).then(lt=>{if(lt.ok){Q.success(P("sidebarFilesTree.toast.pathCopied"));return}Q.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.copyPath")]}),r.jsxs(pe,{onClick:G=>{G.stopPropagation();const lt=Or(d,n.path)||n.path;Br(lt).then(me=>{if(me.ok){Q.success(P("filesView.toast.relativePathCopied"));return}Q.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ",P("filesView.tree.menu.copyRelativePath")]}),!M&&N&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),N(n.path).catch(lt=>{console.error("Download failed:",lt),Q.error(P("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(F,{name:"download",className:"mr-2 size-4"})," ",P(v?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),W&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),A(n.path)},children:[r.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",P(co())]}),M&&(I||_)&&r.jsxs(r.Fragment,{children:[r.jsx(tt,{}),I&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("createFile",n)},children:[r.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFile")]}),_&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("createFolder",n)},children:[r.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFolder")]})]}),L&&r.jsxs(r.Fragment,{children:[r.jsx(tt,{}),r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("delete",n)},className:"text-destructive focus:text-destructive",children:[r.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.delete")]})]})]})},e[13]=I,e[14]=_,e[15]=L,e[16]=k,e[17]=W,e[18]=N,e[19]=v,e[20]=M,e[21]=n,e[22]=V,e[23]=A,e[24]=d,e[25]=P,e[26]=xe):xe=e[26];const ue=xe,ae=T===n.path;let we;e[27]!==n.path||e[28]!==o?(we=fe=>o(fe?n.path:null),e[27]=n.path,e[28]=o,e[29]=we):we=e[29];const $=w?void 0:ce;let H;e[30]!==$?(H=r.jsx("div",{className:"group relative flex items-center",onContextMenu:$}),e[30]=$,e[31]=H):H=e[31];const re=w?void 0:ce,ne=g?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ke;e[32]!==ne?(ke=q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",ne),e[32]=ne,e[33]=ke):ke=e[33];let oe;e[34]!==M||e[35]!==x||e[36]!==n.extension||e[37]!==n.path?(oe=M?x?r.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):r.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Si(n.path,n.extension),e[34]=M,e[35]=x,e[36]=n.extension,e[37]=n.path,e[38]=oe):oe=e[38];let le;e[39]!==n.name||e[40]!==n.path?(le=r.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[39]=n.name,e[40]=n.path,e[41]=le):le=e[41];let be;e[42]!==M||e[43]!==j?(be=!M&&j&&r.jsx(ul,{status:j}),e[42]=M,e[43]=j,e[44]=be):be=e[44];let Ee;e[45]!==m||e[46]!==M?(Ee=M&&m&&r.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[m.modified>0&&r.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",m.modified]}),m.added>0&&r.jsxs("span",{className:"text-[var(--status-success)]",children:["+",m.added]})]}),e[45]=m,e[46]=M,e[47]=Ee):Ee=e[47];let de;e[48]!==Se||e[49]!==ke||e[50]!==oe||e[51]!==le||e[52]!==be||e[53]!==Ee||e[54]!==re?(de=r.jsxs("button",{type:"button",onClick:Se,onContextMenu:re,className:ke,children:[oe,le,be,Ee]}),e[48]=Se,e[49]=ke,e[50]=oe,e[51]=le,e[52]=be,e[53]=Ee,e[54]=re,e[55]=de):de=e[55];let Ve;e[56]!==f||e[57]!==S||e[58]!==ve||e[59]!==Y||e[60]!==w||e[61]!==n.path||e[62]!==ue||e[63]!==C?(Ve=Y&&r.jsx("div",{className:q("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:r.jsxs(jn,{open:S===n.path,onOpenChange:fe=>C(fe?n.path:null),children:[r.jsx(Fn,{asChild:!0,children:r.jsx(O,{variant:"ghost",size:"icon",className:"size-6",onClick:ve,children:r.jsx(F,{name:"more-2-fill",className:"size-4"})})}),r.jsx(Nn,{align:"end",side:"bottom",onCloseAutoFocus:()=>C(null),children:ue({Item:Ir,Separator:lo})})]})}),e[56]=f,e[57]=S,e[58]=ve,e[59]=Y,e[60]=w,e[61]=n.path,e[62]=ue,e[63]=C,e[64]=Ve):Ve=e[64];let Pe;e[65]!==de||e[66]!==Ve||e[67]!==H?(Pe=r.jsxs(po,{render:H,children:[de,Ve]}),e[65]=de,e[66]=Ve,e[67]=H,e[68]=Pe):Pe=e[68];let Re;e[69]!==ue?(Re=r.jsx(fo,{className:"min-w-[180px]",children:ue({Item:ho,Separator:mo})}),e[69]=ue,e[70]=Re):Re=e[70];let Z;return e[71]!==Pe||e[72]!==Re||e[73]!==ae||e[74]!==we?(Z=r.jsxs(go,{open:ae,onOpenChange:we,children:[Pe,Re]}),e[71]=Pe,e[72]=Re,e[73]=ae,e[74]=we,e[75]=Z):Z=e[75],Z},bl=a=>{const e=ot.c(83),{activeDialog:n,dialogData:d,dialogInputValue:x,onDialogInputChange:g,isDialogSubmitting:w,onDialogSubmit:v,onClose:f,inputRef:j}=a,{t:m}=Ht(),y=!!n;let N;e[0]!==f?(N=B=>!B&&f(),e[0]=f,e[1]=N):N=e[1];let S;e[2]!==n||e[3]!==m?(S=n==="createFile"&&m("filesView.dialog.createFile.title"),e[2]=n,e[3]=m,e[4]=S):S=e[4];let C;e[5]!==n||e[6]!==m?(C=n==="createFolder"&&m("filesView.dialog.createFolder.title"),e[5]=n,e[6]=m,e[7]=C):C=e[7];let T;e[8]!==n||e[9]!==m?(T=n==="rename"&&m("filesView.dialog.rename.title"),e[8]=n,e[9]=m,e[10]=T):T=e[10];let o;e[11]!==n||e[12]!==m?(o=n==="delete"&&m("filesView.dialog.delete.title"),e[11]=n,e[12]=m,e[13]=o):o=e[13];let E;e[14]!==S||e[15]!==C||e[16]!==T||e[17]!==o?(E=r.jsxs(bi,{children:[S,C,T,o]}),e[14]=S,e[15]=C,e[16]=T,e[17]=o,e[18]=E):E=e[18];let D;e[19]!==n||e[20]!==d?.path||e[21]!==m?(D=n==="createFile"&&m("filesView.dialog.createFile.description",{path:d?.path??m("filesView.dialog.rootFallback")}),e[19]=n,e[20]=d?.path,e[21]=m,e[22]=D):D=e[22];let A;e[23]!==n||e[24]!==d?.path||e[25]!==m?(A=n==="createFolder"&&m("filesView.dialog.createFolder.description",{path:d?.path??m("filesView.dialog.rootFallback")}),e[23]=n,e[24]=d?.path,e[25]=m,e[26]=A):A=e[26];let V;e[27]!==n||e[28]!==d?.name||e[29]!==m?(V=n==="rename"&&m("filesView.dialog.rename.description",{name:d?.name??""}),e[27]=n,e[28]=d?.name,e[29]=m,e[30]=V):V=e[30];let P;e[31]!==n||e[32]!==d?.name||e[33]!==m?(P=n==="delete"&&m("filesView.dialog.delete.description",{name:d?.name??""}),e[31]=n,e[32]=d?.name,e[33]=m,e[34]=P):P=e[34];let M;e[35]!==V||e[36]!==P||e[37]!==D||e[38]!==A?(M=r.jsxs(yi,{children:[D,A,V,P]}),e[35]=V,e[36]=P,e[37]=D,e[38]=A,e[39]=M):M=e[39];let k;e[40]!==M||e[41]!==E?(k=r.jsxs(wi,{children:[E,M]}),e[40]=M,e[41]=E,e[42]=k):k=e[42];let I;e[43]!==n||e[44]!==x||e[45]!==j||e[46]!==g||e[47]!==v||e[48]!==m?(I=n!=="delete"&&r.jsx("div",{className:"py-4",children:r.jsx(lr,{value:x,onChange:B=>g(B.target.value),placeholder:m(n==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:B=>{B.key==="Enter"&&v()},ref:j})}),e[43]=n,e[44]=x,e[45]=j,e[46]=g,e[47]=v,e[48]=m,e[49]=I):I=e[49];let _;e[50]!==m?(_=m("filesView.dialog.cancel"),e[50]=m,e[51]=_):_=e[51];let L;e[52]!==w||e[53]!==f||e[54]!==_?(L=r.jsx(O,{variant:"outline",onClick:f,disabled:w,children:_}),e[52]=w,e[53]=f,e[54]=_,e[55]=L):L=e[55];const X=n==="delete"?"destructive":"default";let Ce;e[56]!==v?(Ce=()=>{v()},e[56]=v,e[57]=Ce):Ce=e[57];let W;e[58]!==n||e[59]!==x||e[60]!==w?(W=w||n!=="delete"&&!x.trim(),e[58]=n,e[59]=x,e[60]=w,e[61]=W):W=e[61];let Y;e[62]!==n||e[63]!==w||e[64]!==m?(Y=w?r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):m(n==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=n,e[63]=w,e[64]=m,e[65]=Y):Y=e[65];let ee;e[66]!==X||e[67]!==Ce||e[68]!==W||e[69]!==Y?(ee=r.jsx(O,{variant:X,onClick:Ce,disabled:W,children:Y}),e[66]=X,e[67]=Ce,e[68]=W,e[69]=Y,e[70]=ee):ee=e[70];let ce;e[71]!==L||e[72]!==ee?(ce=r.jsxs(ji,{children:[L,ee]}),e[71]=L,e[72]=ee,e[73]=ce):ce=e[73];let te;e[74]!==j||e[75]!==k||e[76]!==I||e[77]!==ce?(te=r.jsxs(xi,{initialFocus:j,children:[k,I,ce]}),e[74]=j,e[75]=k,e[76]=I,e[77]=ce,e[78]=te):te=e[78];let Se;return e[79]!==y||e[80]!==N||e[81]!==te?(Se=r.jsx(vi,{open:y,onOpenChange:N,children:te}),e[79]=y,e[80]=N,e[81]=te,e[82]=Se):Se=e[82],Se},Ut=new Map,yl=100,hi=a=>{const e=ot.c(13);let n,d,x;e[0]!==a?({positionKey:d,onViewReady:n,...x}=a,e[0]=a,e[1]=n,e[2]=d,e[3]=x):(n=e[1],d=e[2],x=e[3]);const g=s.useRef(null);let w,v;e[4]!==d?(w=()=>()=>{const m=g.current;if(!m)return;const{anchor:y,head:N}=m.state.selection.main;if(Ut.delete(d),Ut.set(d,{scroll:m.scrollSnapshot(),anchor:y,head:N}),Ut.size>yl){const S=Ut.keys().next().value;S!==void 0&&Ut.delete(S)}},v=[d],e[4]=d,e[5]=w,e[6]=v):(w=e[5],v=e[6]),s.useLayoutEffect(w,v);let f;e[7]!==n||e[8]!==d?(f=m=>{g.current=m;const y=Ut.get(d);y&&m.dispatch({selection:{anchor:Math.min(y.anchor,m.state.doc.length),head:Math.min(y.head,m.state.doc.length)},effects:y.scroll}),n?.(m)},e[7]=n,e[8]=d,e[9]=f):f=e[9];let j;return e[10]!==x||e[11]!==f?(j=r.jsx(xo,{...x,onViewReady:f}),e[10]=x,e[11]=f,e[12]=j):j=e[12],j},pi=(a,e,n)=>{const d=ot.c(8),[x,g]=s.useState(""),[w,v]=s.useState(0);let f,j;d[0]!==a||d[1]!==n||d[2]!==e?(f=()=>{if(!a){g("");return}let y=!1;g("");const N=Ia(),S=Oa(N);Ba(N).then(T=>{y||!T||(g(a),e(null))}).catch(T=>{y||(e(T instanceof Error?T.message:n),g(a))});const C=$a(()=>{y||(g(a),v(jl),e(null))});return()=>{y=!0,S(),C()}},j=[a,e,n],d[0]=a,d[1]=n,d[2]=e,d[3]=f,d[4]=j):(f=d[3],j=d[4]),s.useEffect(f,j);let m;return d[5]!==w||d[6]!==x?(m={readyKey:x,nonce:w},d[5]=w,d[6]=x,d[7]=m):m=d[7],m},Wu=({mode:a="full"})=>{const{t:e}=Ht(),{files:n,runtime:d}=Ka(),{currentTheme:x,availableThemes:g,lightThemeId:w,darkThemeId:v}=Ha(),{isMobile:f,isTablet:j,screenWidth:m}=qa(),y=Pa(d.platform),N=f||j,S=Ma(),C=Da(),T=gi()??"",o=K(T.trim()),E=a!=="editor-only",D=a==="editor-only"&&!f,A=za(t=>t.searchFiles),V=Ga(T),[P,M]=s.useState(""),k=Xa(P,200),I=s.useRef(null),[_,L]=s.useState(!1),[X,Ce]=s.useState(!0),[W,Y]=s.useState(!1),[ee,ce]=s.useState(!1),te=s.useRef(0),Se=s.useCallback(t=>{te.current=Math.max(0,te.current+(t?1:-1))},[]),[B,ve]=s.useState("edit"),[xe,ue]=s.useState("edit"),[ae,we]=s.useState("tree"),[$,H]=s.useState("edit"),[re,ne]=s.useState("preview"),[ke,oe]=s.useState(0),le=s.useRef({}),be=s.useRef({}),Ee=s.useRef({}),de=s.useRef({}),Ve=s.useMemo(()=>g.find(t=>t.metadata.id===w)??Xs(!1),[g,w]),Pe=s.useMemo(()=>g.find(t=>t.metadata.id===v)??Xs(!0),[g,v]);s.useEffect(()=>{ni(Ve),ni(Pe)},[Ve,Pe]);const Re=s.useMemo(()=>[],[]),Z=Xe(t=>o?t.byRoot[o]?.openPaths??Re:Re),fe=Xe(t=>o?t.byRoot[o]?.selectedPath??null:null),pe=Xe(t=>o?t.byRoot[o]?.expandedPaths??Re:Re),tt=Xe(t=>t.removeOpenPath),G=Xe(t=>t.removeOpenPathsByPrefix),lt=Xe(t=>t.removeExpandedPathsByPrefix),me=Xe(t=>t.setSelectedPath),Cn=Xe(t=>t.toggleExpandedPath),cr=Xe(t=>t.expandPaths),Ct=s.useCallback(t=>{const i=K(t),l=i.split("/"),u=l[l.length-1]||i,p=u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;return{name:u,path:i,type:"file",extension:p}},[]),St=s.useMemo(()=>Z.map(Ct),[Z,Ct]),Wr=s.useMemo(()=>{if(fe){const t=Kt(fe);if(Z.some(i=>Kt(i)===t))return fe}return Z[0]??null},[Z,fe]),c=s.useMemo(()=>Wr?Ct(Wr):null,[Wr,Ct]),_e=c?.path??"",[,ki]=s.useState(0);s.useEffect(()=>{if(!o||!fe)return;const t=Kt(fe);Z.some(l=>Kt(l)===t)||me(o,Z[0]??null)},[Z,o,fe,me]);const ur=!!(o&&_e&&!$r(_e,o)),Sn=ur?Js(_e):void 0,xt=s.useMemo(()=>({allowOutsideWorkspace:a==="editor-only"&&ur,outsideFileGrant:Sn,directory:o||void 0}),[a,ur,Sn,o]),Je=s.useCallback(async t=>{const i=Js(t),l=await Ja(t,o,a==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==i&&ki(u=>u+1),l},[a,o]),Ur=s.useRef(null),[kn,Ri]=s.useState({left:!1,right:!1}),Rn=s.useCallback(()=>{const t=Ur.current;t&&Ri({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),Tn=s.useRef(Rn);Tn.current=Rn,s.useEffect(()=>{const t=Ur.current;if(!t)return;const i=()=>Tn.current();i(),t.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(t),()=>{t.removeEventListener("scroll",i),l.disconnect()}},[St.length]);const[En,Kr]=s.useState({}),[dr,qt]=s.useState({}),Ae=s.useRef(new Set),Ie=s.useRef(new Set),rt=s.useRef(new Map),Vn=s.useRef(0),[Pn,fr]=s.useState([]),[Ti,mr]=s.useState(!1),[z,he]=s.useState(""),{isPlaying:hr,play:Ei,stop:Vi}=Qa(),[Me,ct]=s.useState(!1),[Qe,ge]=s.useState(null),[Pi,Oe]=s.useState(""),[ye,se]=s.useState(null),ut=JSON.stringify([Us(),o,ye]),[ie,je]=s.useState(""),[Gt,Hr]=s.useState(!1),[Mn,Mi]=s.useState(`
11
- `),Di=s.useRef(null),Ye=s.useRef(null),De=s.useRef(null),dt=s.useRef(""),Xt=s.useRef(""),nt=s.useRef(null),Dn=s.useRef(null),We=s.useRef(null),qr=s.useRef(""),Gr=s.useRef(0),Jt=s.useRef(0),kt=s.useRef(null),[pr,zi]=s.useState(0),[Li,Rt]=s.useState("idle"),[Ai,gr]=s.useState(!1),[wt,zn]=s.useState(!1),Fe=vt(t=>t.autoSaveEnabled),Ii=vt(t=>t.setAutoSaveEnabled),[Xr,Qt]=s.useState(!1),Tt=s.useRef(null),Yt=s.useRef(null),Zt=s.useRef(!1),er=s.useRef(null),tr=s.useRef(null),Ue=s.useRef(null),vr=s.useRef(null),[Oi,Jr]=s.useState(0),Et=s.useRef(null),bt=s.useRef({key:"",attempts:0});s.useEffect(()=>()=>{Et.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Et.current),Et.current=null)},[]);const[yt,Qr]=s.useState(null),[jt,Bi]=s.useState(null),[ft,Ln]=s.useState(""),[$i,Yr]=s.useState(!1),[_i,Wi]=s.useState(null),[Ui,Ki]=s.useState(null),[Hi,An]=s.useState(!1),[qi,In]=s.useState(!1),[Gi,Zr]=s.useState(!1),[On,xr]=s.useState(!1),[Bn,$n]=s.useState(0),wr=s.useRef(null),br=s.useCallback(t=>{const i=t?.currentTarget??wr.current;if(!i)return;const l=document.activeElement;l&&l!==document.body&&l!==i&&(Ya(l)||i.contains(l))||i.focus({preventScroll:!0})},[]),yr=s.useRef(null),_n=!!n.writeFile,Wn=!!n.createDirectory,Un=!!n.rename,Kn=!!n.delete,Hn=!!n.revealPath,Xi=zr(t=>t.availableApps),Ji=zr(t=>t.isCacheStale),qn=zr(t=>t.initialize),Qi=zr(t=>t.loadInstalledApps);s.useEffect(()=>{qn()},[qn]);const Yi=s.useCallback(t=>{n.revealPath&&n.revealPath(t).catch(()=>{Q.error(e("sidebarFilesTree.toast.revealFailed"))})},[n,e]),Zi=s.useCallback(async t=>{if(!c?.path||await La(c.path,t.id,t.appName)||await Ks(c.path,t.appName))return;const u=il(c.path)||o;u&&await Ks(u,t.appName)||Q.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,c?.path,e]),en=s.useCallback((t,i)=>{Qr(t),Bi(i),Ln(t==="rename"&&i.name||""),Yr(!1)},[]),[U,Ke]=s.useState(null),Vt=s.useRef(!1),mt=s.useRef(null),[Gn,Pt]=s.useState(!1),Ze=vt(t=>t.pendingFileNavigation),jr=vt(t=>t.setPendingFileNavigation),tn=vt(t=>t.pendingFileFocusPath),rn=vt(t=>t.setPendingFileFocusPath),Xn=vt(t=>t.fileEditorKeymap),rr=Qs(t=>t.settingsDefaultFileViewerPreview),ea=Qs(t=>t.showMessageTTSButtons);s.useEffect(()=>{const t=()=>{Vt.current=!1,mt.current=null,Pt(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),s.useEffect(()=>()=>{er.current!==null&&window.clearTimeout(er.current),tr.current!==null&&window.clearTimeout(tr.current)},[]);const ta=s.useCallback((t,i)=>{const l=t.split(`
12
- `),u=Math.max(1,i.start),p=Math.min(l.length,i.end);return u>p?"":l.slice(u-1,p).join(`
13
- `)},[]),Jn=s.useRef(null),ra=Vo({source:"file",fileLabel:c?.path??null,language:c?.path&&pn(c.path)||"text",getCodeForRange:t=>ta(z,Po(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:Qn,commentText:Fr,setCommentText:Yn,editingDraftId:Nr,setSelection:Zn,saveComment:es,cancel:nr,reset:ts,startEdit:rs,deleteDraft:ns}=ra;s.useEffect(()=>{Ke(null),ts(),je(""),Hr(!1)},[c?.path,ts]),s.useEffect(()=>{Zn(U)},[U,Zn]),s.useEffect(()=>{if(!U&&!Nr)return;const t=l=>{const u=l.target;u.closest('[data-comment-input="true"]')||u.closest('[data-comment-card="true"]')||u.closest(".cm-gutterElement")||u.closest("[data-sonner-toast]")||u.closest("[data-sonner-toaster]")||Fr.trim()||(Ke(null),nr())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[nr,Fr,Nr,U]);const ss=s.useCallback((t,i)=>{const l=i??U??void 0;i&&Ke(i),es(t,l),Ke(null)},[U,es]),is=s.useCallback((t,i)=>{const l=[];for(const u of i){if(!(u&&typeof u.name=="string"&&u.name.length>0)||!S&&u.name.startsWith(".")||!C&&dl(u.name))continue;const p=u.name,h=K(u.path||""),b=h?ll(h)?h:K(`${t}/${h}`):K(`${t}/${p}`),R=u.isDirectory?"directory":"file",J=R==="file"&&p.includes(".")?p.split(".").pop()?.toLowerCase():void 0;l.push({name:p,path:b,type:R,extension:J})}return ol(l)},[C,S]),Be=s.useCallback(async t=>{const i=K(t.trim());if(!i||Ae.current.has(i)||Ie.current.has(i))return;Ie.current=new Set(Ie.current),Ie.current.add(i);const l=Vn.current+1;Vn.current=l,rt.current=new Map(rt.current),rt.current.set(i,l);const u=()=>rt.current.get(i)===l;await(n.listDirectory?n.listDirectory(i).then(h=>h.entries.map(b=>({name:b.name,path:b.path,isDirectory:b.isDirectory}))):Aa.listLocalDirectory(i).then(h=>h.map(b=>({name:b.name,path:b.path,isDirectory:b.isDirectory})))).then(h=>{if(!u())return;const b=is(i,h);Ae.current=new Set(Ae.current),Ae.current.add(i),qt(R=>{if(!R[i])return R;const J={...R};return delete J[i],J}),Kr(R=>({...R,[i]:b}))}).catch(h=>{if(!u())return;const b=h instanceof Error?h.message:String(h??"");if(b==="Directory not found"&&o&&i!==o){lt(o,i),qt(R=>{if(!R[i])return R;const J={...R};return delete J[i],J});return}console.error("Failed to load files directory:",h),qt(R=>({...R,[i]:b}))}).finally(()=>{u()&&(rt.current=new Map(rt.current),rt.current.delete(i),Ie.current=new Set(Ie.current),Ie.current.delete(i))})},[n,is,lt,o]),Cr=s.useCallback(async()=>{o&&(Ae.current=new Set,Ie.current=new Set,rt.current=new Map,qt({}),Kr(t=>Object.keys(t).length===0?t:{}),await Be(o))},[Be,o]),et=s.useCallback(async t=>{if(!t){await Cr();return}const i=K(t);Ae.current=new Set(Ae.current),Ae.current.delete(i),Ie.current=new Set(Ie.current),Ie.current.delete(i),await Be(i)},[Be,Cr]),as=s.useRef(""),os=s.useRef("");s.useEffect(()=>{if(!o)return;const t=`${o}|h${S?"1":"0"}|g${C?"1":"0"}`,i=as.current!==o,l=os.current!==t;!i&&!l||(i&&(as.current=o,he(""),ge(null),Oe(""),se(null),L(!1)),l&&(os.current=t,Ae.current=new Set,Ie.current=new Set,rt.current=new Map,qt({}),Kr(u=>Object.keys(u).length===0?u:{}),Be(o)))},[Be,o,C,S]),s.useEffect(()=>{if(!n.listDirectory)return;const t=()=>{if(!document.hidden&&pe.length>0)for(const i of pe)et(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[pe,n.listDirectory,et]),s.useEffect(()=>{if(!n.listDirectory||pe.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of pe)et(i)},8e3);return()=>clearInterval(t)},[pe,n.listDirectory,et]);const na=s.useCallback(async t=>{if(t?.preventDefault(),!jt||!yt)return;Yr(!0);const i=()=>{Qr(null)},l=p=>{Q.error(p)},u=()=>{Yr(!1)};if(yt==="createFile"){if(!ft.trim()){l(e("sidebarFilesTree.toast.filenameRequired")),u();return}if(!n.writeFile){l(e("sidebarFilesTree.toast.writeNotSupported")),u();return}const p=jt.path,h=p?`${p}/`:"",b=K(`${h}${ft.trim()}`);await n.writeFile(b,"").then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.fileCreated")),await et(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(yt==="createFolder"){if(!ft.trim()){l(e("sidebarFilesTree.toast.folderNameRequired")),u();return}const p=jt.path,h=p?`${p}/`:"",b=K(`${h}${ft.trim()}`);await n.createDirectory(b).then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.folderCreated")),await et(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(yt==="rename"){if(!ft.trim()){l(e("sidebarFilesTree.toast.nameRequired")),u();return}if(!n.rename){l(e("sidebarFilesTree.toast.renameNotSupported")),u();return}const p=jt.path,h=p.split("/").slice(0,-1).join("/"),b=h?`${h}/`:"",R=K(`${b}${ft.trim()}`);await n.rename(p,R).then(async J=>{J.success&&(Q.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await et(h),o&&G(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(yt==="delete"){if(!n.delete){l(e("sidebarFilesTree.toast.deleteNotSupported")),u();return}const p=jt.path,h=p.split("/").slice(0,-1).join("/");await n.delete(p).then(async b=>{b.success&&(Q.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await et(h),o&&G(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}u()},[yt,jt,ft,n,et,f,G,o,c?.path,me,e]);s.useEffect(()=>{if(!T){fr([]),mr(!1);return}const t=k.trim();if(!t){fr([]),mr(!1);return}let i=!1;return mr(!0),A(T,t,150,{includeHidden:S,respectGitignore:!C,type:"file"}).then(l=>{if(i)return;const p=l.filter(h=>C||!fl(h.path)).map(h=>({name:h.name,path:K(h.path),type:"file",extension:h.extension,relativePath:h.relativePath}));fr(p)}).catch(()=>{i||fr([])}).finally(()=>{i||mr(!1)}),()=>{i=!0}},[T,k,A,S,C]);const Sr=s.useCallback(async(t,i)=>{const l=await Je(t);if(n.readFile)return(await n.readFile(t,{...l,directory:o||void 0,...i})).content??"";const u=new URLSearchParams({path:t});l.allowOutsideWorkspace&&u.set("allowOutsideWorkspace","true"),l.outsideFileGrant&&u.set("outsideFileGrant",l.outsideFileGrant),o&&u.set("directory",o);const p=await Hs(`/api/fs/read?${u.toString()}`,i?.fresh?{cache:"no-store"}:void 0);if(!p.ok){const h=await p.json().catch(()=>({error:p.statusText}));throw new Error(h.error||e("filesView.error.readFileFailed"))}return p.text()},[n,Je,o,e]),ht=s.useCallback(async t=>{if(n.statFile){const i=await Je(t),l=await n.statFile(t,{...i,directory:o||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[n,Je,o]);s.useEffect(()=>{if(!o||!n.statFile||Z.length===0)return;let t=!1;const i=[...Z];return Promise.all(i.map(async l=>{try{const u=await Je(l),p=await n.statFile?.(l,{...u,directory:o||void 0});!t&&p&&!p.isFile&&G(o,l)}catch(u){!t&&fi(u)&&G(o,l)}})),()=>{t=!0}},[n,Z,G,Je,o]);const nn=s.useMemo(()=>z.length>Wt?`${z.slice(0,Wt)}
14
-
15
- … truncated …`:z,[z]),ze=ie!==nn,Mt=s.useCallback(async()=>{if(!c||!n.writeFile)return Q.error(e("filesView.toast.savingNotSupported")),!1;const t=or(c.path)||wt;if(!rl({selectedFilePath:c.path,loadedFilePath:ye,fileLoading:Me,isDirty:ze,draftContent:ie,fileContent:z,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):ie===""&&z!==""&&ye!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${z.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!ze)return!0;Hr(!0);try{const i=vl(ie,Mn);if(!(await n.writeFile(c.path,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;if(he(ie),qr.current=i,Gr.current+=1,o&&$r(c.path,o)){const u=Or(o,c.path);u&&Za.requestGitRefresh({directory:o,paths:[u]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(K(c.path))){const u=eo.getState().projects.find(p=>K(p.path)===K(o));if(u)try{await ko(u.id)}catch{Q.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&Dr(c.path)&&(dt.current=ie,Xt.current=ie),ht(c.path).then(u=>{u&&(We.current=u)}).catch(()=>{}),!0}catch(i){return Q.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Hr(!1)}},[wt,ie,z,Me,n,ze,Mn,ye,ht,o,c,e]);s.useEffect(()=>{Fe||(Rt("idle"),Ye.current&&(clearTimeout(Ye.current),Ye.current=null))},[Fe]);const ls=1500;s.useEffect(()=>{const t=!!(c&&n.writeFile),i=!!(c?.path&&(or(c.path)||wt));if(tl({autoSaveEnabled:Fe,isDirty:ze,canWrite:t,isSaving:Gt,fileLoading:Me,selectedFilePath:c?.path,loadedFilePath:ye,isNonEditableBinary:i}))return Ye.current=setTimeout(()=>{Mt().then(l=>{l&&(Rt("saved"),setTimeout(()=>Rt("idle"),2e3))})},ls),()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)}},[Fe,wt,ie,Me,ze,ye,c,n.writeFile,Gt,Mt]),s.useEffect(()=>{Rt("idle")},[c?.path]),to({save_file:t=>{if(!(t.target instanceof Node)||!vr.current?.contains(t.target))return!1;Ye.current&&(clearTimeout(Ye.current),Ye.current=null),Gt||Mt().then(i=>{i&&(Rt("saved"),setTimeout(()=>Rt("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(qe&&Le()==="preview"){if(f||!(W?yr.current:wr.current)?.contains(t.target))return!1;xr(!0),$n(l=>l+1);return}if(!vr.current?.contains(t.target))return!1;ce(!0)}});const Dt=s.useCallback(t=>{const i=Ci(t);qr.current=t,Gr.current+=1,Mi(gl(t)),he(i),dt.current=i,Xt.current=i,je(i.length>Wt?`${i.slice(0,Wt)}
16
-
17
- … truncated …`:i)},[]),cs=s.useCallback(async t=>{const i=Jt.current+1;Jt.current=i;const l=()=>{if(!o)return!1;const R=Xe.getState().byRoot[o],J=R?.selectedPath??R?.openPaths[0]??null;return Jt.current===i&&J===t.path};if(ge(null),Oe(""),se(null),zn(!1),ct(!0),await Je(t.path),!l())return;const u=gn(t.path),p=Ys(t.path),h=Zs(t.path),b=or(t.path);if(f&&L(!0),d.isDesktop&&u&&!p){he(""),je("");return}if(!d.isDesktop&&u&&!p){he(""),je(""),se(t.path),ct(!1);return}if(h){he(""),je(""),se(t.path),ct(!1);return}if(b){he(""),je(""),se(t.path),ct(!1);return}await Sr(t.path).then(R=>{if(l()){if(ei(R)){zn(!0),he(""),je(""),se(t.path);return}Dt(R),se(t.path),ht(t.path).then(J=>{J&&l()&&(We.current=J)}).catch(()=>{})}}).catch(R=>{if(l()){if(ml(R)){if(ct(!1),o&&me(o,null),ge(null),he(""),je(""),se(null),We.current=null,P.trim().length>0&&M(""),f&&L(!1),o){const ar=[...ui(t.path,o),t.path];ar.length>0&&cr(o,ar);for(const gt of ar)Ae.current.has(gt)||Be(gt)}return}if(fi(R)){o&&G(o,t.path),he(""),je(""),ge(null),We.current=null,f&&L(!1);return}he(""),je(""),ge(R instanceof Error?R.message:e("filesView.error.readFileFailed")),We.current=null}}).finally(()=>{l()&&ct(!1)})},[Dt,cr,f,Be,Sr,ht,G,Je,o,d.isDesktop,P,me,e]),kr=s.useCallback(async(t,i)=>{if(!o)return;const l=ui(t,o),u=i?[...l,t]:l;u.length>0&&cr(o,u);const p=u.map(h=>{if(!Ae.current.has(h))return Be(h)}).filter(Boolean);await Promise.all(p)},[cr,Be,o]),us=s.useCallback((t,i)=>{const l=i.findIndex(u=>u.path===t);return l===-1||i.length<=1?null:i[l+1]??i[l-1]??null},[]),Te=s.useCallback(async t=>{if(Zt.current)Zt.current=!1;else if(ze){Qt(!0),Tt.current=t;return}o&&(me(o,t.path),kr(t.path,!1)),ge(null),Oe(""),he(""),dt.current="",Xt.current="",je(""),se(null),f&&L(!0)},[kr,ze,f,o,me]);s.useEffect(()=>{c?.path&&kr(c.path,!1)},[kr,c?.path]),s.useEffect(()=>{if(!c){Jt.current+=1,kt.current=null,ct(!1);return}if(ye===c.path||kt.current===c.path)return;const t=c.path;kt.current=t,cs(c).finally(()=>{kt.current===t&&(kt.current=null)})},[pr,cs,ye,c]);const Rr=s.useRef(ze);Rr.current=ze,s.useEffect(()=>Ro(({runtimeKey:t,paths:i})=>{const l=c?.path;t!==Us()||!l||Rr.current||!i.includes(K(l))||(Jt.current+=1,kt.current=null,We.current=null,Oe(""),ge(null),se(null),zi(u=>u+1))}),[c?.path]),s.useEffect(()=>{if(!c?.path||ye!==c.path)return;const t=c.path,i=()=>Rr.current||Dr(t)&&dt.current!==Xt.current,l=!or(t)&&!gn(t)&&!wt?Jo({readContent:()=>Sr(t,{fresh:!0}),getLoadedContent:()=>qr.current,getLoadedRevision:()=>Gr.current,isDirty:i,applyContent:b=>{if(ei(b)){se(null);return}Dt(b)}}):null;let u=!1,p=!1;const h=window.setInterval(()=>{document.hidden||p||(p=!0,ht(t).then(async b=>{if(u||!b)return;const R=We.current;if(!R||R.path!==t){We.current=b;return}if(Yo(R,b)){if(l&&b.size<=hl){await l.poll()&&!u&&(We.current=b);return}Rr.current||(We.current=b,se(null))}}).catch(()=>{}).finally(()=>{p=!1}))},2e3);return()=>{u=!0,l?.dispose(),window.clearInterval(h)}},[Dt,wt,ye,Sr,ht,c?.path]);const sa=s.useCallback(()=>{const t=Tt.current,i=Yt.current;if(Tt.current=null,Yt.current=null,Zt.current=!0,Qt(!1),je(nn),i){o&&tt(o,i),c?.path===i&&(t?Te(t):(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1)));return}if(t){Te(t);return}},[nn,Te,f,tt,o,c?.path,me]),ia=s.useCallback(async()=>{const t=Tt.current,i=Yt.current;if(!await Mt()){Zt.current=!1;return}if(Tt.current=null,Yt.current=null,Zt.current=!0,Qt(!1),i){o&&tt(o,i),c?.path===i&&(t?await Te(t):(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1)));return}if(t){await Te(t);return}},[Te,f,tt,o,Mt,c?.path,me]),ds=s.useCallback(t=>{const i=c?.path===t,l=us(t,St);if(i&&ze){Qt(!0),Tt.current=l,Yt.current=t;return}if(o&&tt(o,t),!!i){if(l){Te(l);return}o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1)}},[us,Te,ze,f,St,tt,o,c?.path,me]),aa=s.useCallback(t=>{if(Z.includes(t))return"open";if(V?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=V.files.find(u=>u.path===i);if(l){if(l.index==="A"||l.working_dir==="?")return"git-added";if(l.index==="D")return"git-deleted";if(l.index==="M"||l.working_dir==="M")return"git-modified"}}return null},[Z,V,o]),oa=s.useCallback(t=>{if(!V?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=i?`${i}/`:"";let u=0,p=0;for(const h of V.files)h.path.startsWith(l)&&((h.index==="M"||h.working_dir==="M")&&u++,(h.index==="A"||h.working_dir==="?")&&p++);return u+p>0?{modified:u,added:p}:null},[V,o]),la=s.useCallback(async t=>{const i=K(t);o&&(Cn(o,i),Ae.current.has(i)||await Be(i))},[Be,o,Cn]),ca=s.useMemo(()=>({canRename:Un,canCreateFile:_n,canCreateFolder:Wn,canDelete:Kn,canReveal:Hn}),[Un,_n,Wn,Kn,Hn]);function fs(t,i){const l=En[t]??[];return l.map((u,p)=>{const h=u.type==="directory",b=h&&pe.includes(u.path),R=c?.path===u.path,J=p===l.length-1;return r.jsxs("li",{className:"relative",children:[i>0&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),J&&r.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),r.jsx(wl,{node:u,root:o,isExpanded:b,isActive:R,isMobile:f,isBrowserClient:y,alwaysShowActions:N,status:h?void 0:aa(u.path),badge:h?oa(u.path):void 0,permissions:ca,downloadFile:n.downloadFile,contextMenuPath:_i,setContextMenuPath:Wi,rightClickMenuPath:Ui,setRightClickMenuPath:Ki,onSelect:Te,onToggle:la,onRevealPath:Yi,onOpenDialog:en}),h&&b&&r.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[dr[u.path]?r.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:dr[u.path],children:dr[u.path]}),r.jsxs(O,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{et(u.path)},children:[r.jsx(F,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,fs(u.path,i+1)]})]},u.path)})}const Ne=!!(c?.path&&gn(c.path)),Tr=!!(c?.path&&Ys(c.path)),$e=!!(c?.path&&Zs(c.path)),sn=!!(c?.path&&(or(c.path)||wt)),st=sn&&!Ne&&!$e,ms=s.useMemo(()=>K(Ze?.path??""),[Ze?.path]),zt=!!(Ze&&ms&&_e&&_e===ms&&!Me&&!Qe&&!Ne&&!$e&&!st),pt=s.useMemo(()=>Or(o,_e),[_e,o]),ua=!!(c&&(!Ne||Tr)&&!$e&&!st&&z.length>0),da=!!(c&&pt.length>0),He=!!(c&&!ur&&!sn&&!Ne&&n.writeFile&&z.length<=Wt),qe=!!(c?.path&&mi(c.path)),Lt=!!(c?.path&&xl(c.path)),At=!!(c?.path&&yn(c.path)),sr=!!(c?.path&&Dr(c.path)),Er=!!(c&&!sn&&!Ne)&&!qe&&!sr&&!(At&&$==="preview"),fa=qe&&xe==="edit"||At&&$==="edit"||Lt&&ae==="text"||!qe&&!At&&!Lt&&B==="edit",Vr=s.useMemo(()=>_e?ro(_e):null,[_e]),[hs,an]=s.useState(null);s.useEffect(()=>{let t=!1;const i=c?.path;if(!i||Vr){an(null);return}return an(null),no(i).then(l=>{t||an(l)}),()=>{t=!0}},[c?.path,Vr]),s.useEffect(()=>{!He&&B==="edit"&&ve("view")},[He,B]);const on="openchamber:files:md-viewer-mode",ln="openchamber:files:html-viewer-mode",cn="openchamber:files:json-viewer-mode";s.useEffect(()=>{const t=c?.path;if(!t)return;ve(le.current[t]??"edit");let i=rr?"preview":"edit";try{const p=localStorage.getItem(on);(p==="preview"||p==="edit")&&(i=p)}catch{}ue(be.current[t]??i);let l=rr?"preview":"edit";try{const p=localStorage.getItem(ln);(p==="preview"||p==="edit")&&(l=p)}catch{}H(Ee.current[t]??l),ne(de.current[t]??(rr?"preview":"edit"));let u=rr?"tree":"text";try{const p=localStorage.getItem(cn);(p==="tree"||p==="text")&&(u=p)}catch{}we(u)},[c?.path,rr]);const ma=s.useCallback(t=>{const i=c?.path;i&&(le.current[i]=t),ve(t)},[c?.path]),ha=s.useCallback(t=>{const i=c?.path;i&&(be.current[i]=t),ue(t);try{localStorage.setItem(on,t)}catch{}},[c?.path]),Le=s.useCallback(()=>xe,[xe]),ps=c&&qe&&Le()==="preview"&&!Me?c.path:null;s.useEffect(()=>{!ps||f||br()},[br,W,f,ps]);const pa=s.useCallback(t=>{we(t);try{localStorage.setItem(cn,t)}catch{}},[]),ga=s.useCallback(t=>{const i=c?.path;i&&(Ee.current[i]=t),H(t);try{localStorage.setItem(ln,t)}catch{}},[c?.path]),va=s.useCallback(t=>{const i=c?.path;if(i&&(de.current[i]=t),De.current&&(clearTimeout(De.current),De.current=null),nt.current!==null&&(cancelAnimationFrame(nt.current),nt.current=null),t==="edit")je(dt.current||z),ne(t);else{dt.current=ie;const l=i;ne("edit"),nt.current=requestAnimationFrame(()=>{nt.current=requestAnimationFrame(()=>{nt.current=null,!(o&&l&&Xe.getState().byRoot[o]?.selectedPath!==l)&&(oe(u=>u+1),ne("preview"))})});return}},[ie,z,o,c?.path]),un=s.useCallback(async(t,i)=>{if(!n.writeFile||i===Xt.current)return!1;if(!(await n.writeFile(t,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;Dt(i);const u=await ht(t).catch(()=>null);return u&&(We.current=u),!0},[Dt,n,ht,e]);s.useEffect(()=>()=>{De.current&&(clearTimeout(De.current),De.current=null),nt.current!==null&&(cancelAnimationFrame(nt.current),nt.current=null)},[re,c?.path]);const xa=s.useCallback(t=>{if(dt.current=t,!Fe||!c?.path||re!=="preview"||!n.writeFile)return;De.current&&clearTimeout(De.current);const i=c.path;De.current=setTimeout(()=>{De.current=null,un(i,t).then(l=>{l&&(gr(!0),setTimeout(()=>gr(!1),1500))}).catch(l=>{Q.error(l instanceof Error?l.message:e("filesView.toast.saveFailed"))})},ls)},[Fe,re,n.writeFile,un,c?.path,e]),wa=s.useMemo(()=>sr&&(dt.current||ie)||z,[ie,z,sr]),gs=s.useCallback(()=>$,[$]);s.useEffect(()=>{const t=l=>{const u=l?"preview":"edit",p=l?"tree":"text";for(const h of Z)le.current[h]="edit",mi(h)&&(be.current[h]=u),yn(h)&&(Ee.current[h]=u),Dr(h)&&(de.current[h]=u);ve("edit"),ue(u),H(u),ne(u),we(p);try{localStorage.setItem(on,u),localStorage.setItem(ln,u),localStorage.setItem(cn,p)}catch{}},i=l=>{const u=!!l.detail?.enabled;t(u)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",i)}},[Z]),s.useEffect(()=>{if(!Ze||!o)return;const t=()=>{typeof window>"u"||Et.current===null&&(Et.current=window.requestAnimationFrame(()=>{Et.current=null,Jr(it=>it+1)}))},i=(it,Ft)=>{if(it.state.doc.length!==Ft.length)return!1;if(Ft.length===0)return!0;const hn=Math.min(128,Ft.length);if(it.state.sliceDoc(0,hn)!==Ft.slice(0,hn))return!1;const _s=Math.max(0,Ft.length-hn);return it.state.sliceDoc(_s,Ft.length)===Ft.slice(_s)},l=K(Ze.path);if(!l){jr(null),bt.current={key:"",attempts:0};return}const u=`${l}:${Ze.line}:${Ze.column??1}`;if(bt.current.key!==u&&(bt.current={key:u,attempts:0}),c?.path!==l){if(Xr)return;Te(Ct(l));return}if(Me||ye!==l)return;if(Qe||Ne||$e||st){jr(null),bt.current={key:"",attempts:0};return}if(!He)return;if(B!=="edit"){ve("edit");return}const p=Ue.current;if(!p){t();return}if(!i(p,ie)){t();return}const h=Math.max(1,Math.min(Ze.line,p.state.doc.lines)),b=p.state.doc.line(h),R=Math.max(1,Ze.column||1),J=Math.max(0,b.to-b.from),ar=Math.min(J,R-1),gt=b.from+ar;if(!(p.state.selection.main.head===gt)||bt.current.attempts===0){bt.current.attempts+=1,p.dispatch({selection:{anchor:gt},effects:Nt.scrollIntoView(gt,{y:"center"})}),p.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const it=Ue.current;it&&(it.dispatch({selection:{anchor:gt},effects:Nt.scrollIntoView(gt,{y:"center"})}),it.focus())}),jr(null),bt.current={key:"",attempts:0}},[He,Xr,ie,Oi,Qe,Me,Ne,$e,st,ye,Te,Ze,o,c?.path,jr,B,Ct]),s.useEffect(()=>{if(!tn||!o)return;const t=K(tn);if(!t){rn(null);return}c?.path===t&&(Me||ye!==t||(!Qe&&!Ne&&!$e&&!st&&He&&B==="edit"&&Ue.current?.focus(),rn(null)))},[He,Qe,Me,Ne,$e,st,ye,tn,o,c?.path,rn,B]);const It=s.useCallback(t=>{if(!f||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(i.offsetTop+i.height))<=0)return;const p=t.state.selection.main.head,h=t.coordsAtPos(p);if(!h)return;const b=Math.round(i.offsetTop+i.height),J=h.bottom+20-b;J<=0||(t.scrollDOM.scrollTop+=J)},[f]);s.useEffect(()=>{if(!f||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{It(Ue.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[f,It]),so("open_go_to_line",t=>{if(!He||B!=="edit"||f)return!1;const i=t.target;if(i?.closest('[role="dialog"]')||!(i instanceof Node)||!vr.current?.contains(i))return!1;const l=!!i?.closest(".cm-editor");if(!!i?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;Zr(!0)});const Pr=vt(t=>t.editorFontSize),vs=s.useMemo(()=>{if(!c?.path)return[ri(x,{fontSize:Pr})];const t=pn(c.path),i=[ri(x,t?{syntaxColors:!1,fontSize:Pr}:{fontSize:Pr})],l=Vr??hs;return l&&i.push(l),t&&i.push(vo({language:t,themeName:x.metadata.id,theme:Fo(x)})),X&&i.push(Nt.lineWrapping),f&&i.push(Nt.updateListener.of(u=>{u.view.hasFocus&&(u.selectionSet||u.focusChanged||u.viewportChanged||u.geometryChanged)&&window.requestAnimationFrame(()=>{It(u.view)})})),i},[x,c?.path,Vr,hs,X,f,It,Pr]),xs=s.useMemo(()=>({light:Ve.metadata.id,dark:Pe.metadata.id}),[Ve.metadata.id,Pe.metadata.id]),ir=c?.path&&$e&&(!xt.allowOutsideWorkspace||xt.outsideFileGrant)?`${c.path}|${xt.allowOutsideWorkspace?"outside":"workspace"}|${xt.outsideFileGrant??""}|${pr}`:"",Mr=c?.path&&At&&$==="preview"&&!d.isVSCode?`${c.path}|${pr}`:"",ws=e("filesView.error.readFileFailed"),{readyKey:bs,nonce:ba}=pi(Mr,ge,ws),{readyKey:ys,nonce:js}=pi(ir,ge,ws),ya=!!(Mr&&bs!==Mr),Fs=!!(ir&&ys!==ir),Ns=c?.path&&Ne?Tr?`data:${io(c.path)};utf8,${encodeURIComponent(z)}`:Pi:"",Cs=c?.path&&$e&&ir&&ys===ir?qs().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:xt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:xt.outsideFileGrant,directory:o||void 0}):"",Ss=s.useCallback(t=>r.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:r.jsx("iframe",{src:Cs,className:"h-full w-full border-0",title:t.name},js)}),[Cs,js]);s.useEffect(()=>{let t=!1,i="";return(async()=>{if(!c?.path||!Ne||Tr){Oe("");return}ge(null);const u=await Je(c.path);if(t)return;await(n.readFileBinary?n.readFileBinary(c.path,u).then(h=>h.dataUrl):(async()=>{const h=await Hs("/api/fs/raw",{query:{path:c.path,allowOutsideWorkspace:u.allowOutsideWorkspace?"true":void 0,outsideFileGrant:u.outsideFileGrant,directory:o||void 0}});if(!h.ok)throw new Error(e("filesView.error.readFileFailed"));const b=await h.blob();return i=URL.createObjectURL(b),t?(URL.revokeObjectURL(i),i="",""):i})()).then(h=>{t||(Oe(h),se(c.path))}).catch(h=>{t||(Oe(""),ge(h instanceof Error?h.message:e("filesView.error.readFileFailed")),se(null))}).finally(()=>{t||ct(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[pr,n,Ne,Tr,Je,o,c?.path,xt,e]);const ja=s.useCallback(()=>Qr(null),[]),Fa=s.useMemo(()=>Mo({drafts:Qn,editingDraftId:Nr,commentText:Fr,onTextChange:Yn,selection:U,isDragging:Gn,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:ss,onCancel:()=>{Ke(null),nr()},onEdit:t=>{rs(t),Ke({start:t.startLine,end:t.endLine})},onDelete:ns}),[nr,Fr,ns,Nr,Qn,ss,Gn,U,c?.path,Yn,rs]),ks=li(),Rs=li(),Ts=!Me&&!Qe&&ye===_e,Es=Ts&&Er&&B==="view"&&!(Lt&&ae==="tree"),Vs=Ts&&qe&&Le()==="preview",{setScroller:Ps,restore:Na}=Lr(Es?`${ut}:code`:null),{setScroller:Ms,restore:Ca}=Lr(Es?`${ut}:code:fullscreen`:null),{setScroller:Ds}=Lr(Vs?`${ut}:markdown`:null),{setScroller:zs}=Lr(Vs?`${ut}:markdown:fullscreen`:null),{setScroller:Ls}=ks,{setScroller:As}=Rs,Sa=s.useCallback(t=>{Ls(t),Ps(t)},[Ls,Ps]),ka=s.useCallback(t=>{As(t),Ms(t)},[As,Ms]),Ra=s.useCallback(t=>{Jn.current=t,wr.current=t,Ds(t)},[Ds]),Ta=s.useCallback(t=>{yr.current=t,zs(t)},[zs]),dn=uo("unified"),Ge=z.length>Wt,fn=s.useMemo(()=>Ge?pl(z):void 0,[z,Ge]),Is=s.useCallback((t,i,l,u)=>{const p={name:t.name,contents:i,lang:pn(t.path)||void 0},h=b=>r.jsx(jo,{file:Ge&&fn?{...p,cacheKey:`${t.path}:${fn}`}:p,options:{disableFileHeader:!0,overflow:X?"wrap":"scroll",theme:xs,themeType:x.metadata.variant==="dark"?"dark":"light",onPostRender:u},className:Ge?"block w-full":"block h-full w-full",style:Ge?void 0:{height:"100%"}},b);return Ge?r.jsx("div",{className:"h-full",children:r.jsx(No.Provider,{value:l.virtualizer,children:r.jsx(Co.Provider,{value:dn,children:h(`${t.path}:${dn?"pool":"pending"}`)})})}):r.jsx("div",{className:"h-full",children:h(t.path)})},[x.metadata.variant,Ge,fn,xs,dn,X]),Os=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!c)return null;const l=i==="docked",u=ao(oo("save_file")),p=l?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",h=(b,R)=>r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:R})}),r.jsx($t,{side:"bottom",sideOffset:6,children:b})]});return r.jsxs("div",{className:p,children:[He&&fa&&r.jsxs(r.Fragment,{children:[Gt?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[r.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):Fe&&Li==="saved"&&!ze?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[r.jsx(F,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):ze?h(e(Fe?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{Mt()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(Fe?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),"aria-label":e("filesView.editor.saveAria",{shortcut:u}),children:r.jsx(F,{name:"save-3",className:"size-4"})})):null,h(e(Fe?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Ii(!Fe),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Fe?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(Fe?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(Fe?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Fe?r.jsx(F,{name:"file-check-fill",className:"size-4"}):r.jsx(F,{name:"file-check",className:"size-4"})}))]}),r.jsxs(jn,{onOpenChange:Se,children:[r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:r.jsx(Fn,{asChild:!0,children:r.jsx(O,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:r.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),r.jsxs(Nn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Xi.map(b=>r.jsxs(Ir,{className:"flex items-center gap-2",onClick:()=>{Zi(b)},children:[r.jsx(al,{label:b.label,iconDataUrl:b.iconDataUrl}),r.jsx("span",{className:"typography-ui-label text-foreground",children:b.label})]},b.id)),Ji?r.jsxs(Ir,{className:"flex items-center gap-2",onClick:()=>{Qi(!0)},children:[r.jsx(F,{name:"refresh",className:"size-4"}),r.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!Ne&&!$e&&!st&&r.jsxs(r.Fragment,{children:[h(e(X?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Ce(!X),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",X?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(X?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:r.jsx(F,{name:"text-wrap",className:"size-4"})})),B==="edit"&&r.jsxs(r.Fragment,{children:[h(e("filesView.editor.findInFile"),r.jsx(O,{variant:"ghost",size:"sm",onClick:b=>{ce(!ee),b.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:r.jsx(F,{name:"search",className:"size-4"})})),h(e("filesView.editor.goToLine"),r.jsx(O,{variant:"ghost",size:"sm",onClick:b=>{Zr(R=>!R),b.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:r.jsx(F,{name:"menu-fold-2",className:"size-4"})})),r.jsx(Wo,{open:Gi,onOpenChange:Zr,view:Ue.current,variant:"inline"})]})]}),Er&&He&&!Lt&&!At&&r.jsx(wn,{currentMode:B==="view"?"preview":"edit",onToggle:()=>{ma(B==="view"?"edit":"view")}}),qe&&h(e(Le()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>ha(Le()==="preview"?"edit":"preview"),className:q("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Le()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(Le()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(Le()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:r.jsx(F,{name:Le()==="preview"?"eye":"eye-off",className:"size-4"})})),yn(c?.path??"")&&r.jsx(wn,{currentMode:gs(),onToggle:()=>{ga(gs()==="preview"?"edit":"preview")}}),qe&&Le()==="preview"&&h(e("filesView.editor.findInFile"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{xr(!0),$n(b=>b+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:r.jsx(F,{name:"search",className:"size-4"})})),qe&&Le()==="preview"&&ea&&r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(O,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(hr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{hr?Vi():z.trim()&&Ei(z)},children:hr?r.jsx(F,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"volume-up",className:"size-4"})})}),r.jsx($t,{sideOffset:8,children:e(hr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),sr&&r.jsxs(r.Fragment,{children:[r.jsx(wn,{currentMode:re,onToggle:()=>va(re==="preview"?"edit":"preview")}),re==="preview"&&r.jsx(O,{variant:"ghost",size:"sm",onClick:async()=>{const b=Dn.current?.getXml();if(De.current&&(clearTimeout(De.current),De.current=null),c?.path&&b){if(!await un(c.path,b))return;gr(!0),setTimeout(()=>gr(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:Ai?r.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"save-3",className:"size-4"})})]}),Lt&&h(e(ae==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>pa(ae==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(ae==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:ae==="tree"?r.jsx(F,{name:"code-sslash",className:"size-4"}):r.jsx(F,{name:"node-tree",className:"size-4"})})),ua&&h(e("filesView.editor.copyFileContents"),r.jsx(O,{variant:"ghost",size:"sm",onClick:async()=>{(await Br(z)).ok?(An(!0),er.current!==null&&window.clearTimeout(er.current),er.current=window.setTimeout(()=>{An(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:Hi?r.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"clipboard",className:"size-4"})})),da&&h(e("filesView.editor.copyFilePathTitle",{path:pt}),r.jsx(O,{variant:"ghost",size:"sm",onClick:async()=>{(await Br(pt)).ok?(In(!0),tr.current!==null&&window.clearTimeout(tr.current),tr.current=window.setTimeout(()=>{In(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:pt}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:pt}),children:qi?r.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"file-copy-2",className:"size-4"})})),n.downloadFile&&h(e("filesView.editor.saveFile"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{const b=n.downloadFile;b&&b(c.path).catch(R=>{console.error("Download failed:",R),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:r.jsx(F,{name:"download",className:"size-4"})})),t?h(e("filesView.editor.exitFullscreen"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Y(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:r.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!f&&a==="full"&&h(e(W?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Y(!W),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(W?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(W?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:W?r.jsx(F,{name:"fullscreen-exit",className:"size-4"}):r.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},mn=r.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[r.jsx(vi,{open:Xr,onOpenChange:t=>{t||Qt(!0)},children:r.jsxs(xi,{showCloseButton:!1,className:"max-w-md",children:[r.jsxs(wi,{children:[r.jsx(bi,{children:e("filesView.unsaved.title")}),r.jsx(yi,{children:e("filesView.unsaved.description")})]}),r.jsxs(ji,{children:[r.jsx(O,{variant:"outline",onClick:()=>{ia()},disabled:Gt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),r.jsx(O,{variant:"destructive",onClick:sa,children:e("filesView.unsaved.discard")})]})]})}),r.jsxs("div",{className:q("flex flex-col flex-shrink-0",E&&"border-b border-border/40"),children:[E?r.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[f&&_&&r.jsx("button",{type:"button",onClick:()=>L(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:r.jsx(F,{name:"arrow-left-s",className:"size-5"})}),f?c?r.jsxs(jn,{children:[r.jsx(Fn,{asChild:!0,children:r.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[r.jsx(Ar,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(di,{name:c.name}),r.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),r.jsx(Nn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:St.map(t=>{const i=c?.path===t.path;return r.jsxs(Ir,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}i||Te(t)},className:q("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx(Ar,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(di,{name:t.name})]}),r.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),ds(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:r.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):St.length>0?r.jsxs("div",{className:"relative min-w-0 flex-1",children:[kn.left&&r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),kn.right&&r.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),r.jsx("div",{ref:Ur,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:St.map(t=>{const i=c?.path===t.path;return r.jsxs("div",{title:Or(o,t.path),className:q("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[r.jsx(Ar,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),r.jsx("button",{type:"button",onClick:()=>{i||Te(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),r.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),ds(t.path)},className:q("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!N&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:r.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,c?r.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[pt&&!f?r.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:pt,children:pt}):null,r.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Os({layout:"docked"})})]}):null]}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:r.jsx(vn,{ref:Sa,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ge&&"[overflow-anchor:none]"),children:c?Me||Fs?D?r.jsx("div",{className:"p-3"}):r.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):Qe?r.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Qe}):Ne?r.jsx("div",{className:"flex h-full items-center justify-center p-3",children:r.jsx("img",{src:Ns,alt:c?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):$e?Ss(c):st?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[r.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),r.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?r.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(F,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):c&&sr&&re==="preview"?r.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:r.jsx(sl,{ref:Dn,xml:wa,onChange:xa},`${c.path}:${ke}`)}):c&&Lt&&ae==="tree"?r.jsx(xn,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:r.jsx("div",{className:"h-full overflow-auto",children:r.jsx(yo,{jsonString:z,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&qe&&Le()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:br,ref:Ra,children:[r.jsx(si,{containerRef:Jn,filePath:c.path,fileContent:z}),z.length>500*1024&&r.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(z.length/1024)})}),r.jsx(xn,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:r.jsx(ti,{content:z,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!W&&r.jsx(oi,{containerRef:wr,open:On,onOpenChange:xr,focusNonce:Bn})]}):c&&At&&$==="preview"?ya?r.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):r.jsx("div",{className:"h-full overflow-hidden",children:r.jsx("iframe",{src:!d.isVSCode&&bs===Mr?(()=>{const t=c.path.split("/").map(i=>encodeURIComponent(i)).join("/");return qs().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:d.isVSCode?(()=>{const t=c.path.substring(0,c.path.lastIndexOf("/")+1);return t?z.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):z})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},ba)}):c&&Er&&B==="view"?Is(c,Ge?z:ie,ks,Na):r.jsxs("div",{className:q("relative h-full",zt&&"overflow-hidden"),ref:vr,children:[r.jsx("div",{className:q("h-full",zt&&"invisible"),children:r.jsx(hi,{positionKey:ut,value:ie,onChange:je,readOnly:!He,vimMode:Xn==="vim",extensions:vs,className:"h-full",blockWidgets:Fa,onViewReady:t=>{Ue.current=t,Jr(i=>i+1),window.requestAnimationFrame(()=>{It(t)})},onViewDestroy:()=>{Ue.current&&(Ue.current=null),Jr(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:ce,highlightLines:U?{start:Math.min(U.start,U.end),end:Math.max(U.start,U.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const u=t.state.doc.lineAt(i.from).number;if(U&&!l.shiftKey&&Math.min(U.start,U.end)===u&&Math.max(U.start,U.end)===u)return Ke(null),nr(),Vt.current=!1,mt.current=null,Pt(!1),!0;if(f&&U&&!l.shiftKey){const p=Math.min(U.start,U.end,u),h=Math.max(U.start,U.end,u);return Ke({start:p,end:h}),Vt.current=!1,mt.current=null,Pt(!1),!0}if(Vt.current=!0,mt.current=u,Pt(!0),U&&l.shiftKey){const p=Math.min(U.start,u),h=Math.max(U.end,u);Ke({start:p,end:h})}else Ke({start:u,end:u});return!0},mouseover:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Vt.current||mt.current===null)return!1;const u=t.state.doc.lineAt(i.from).number,p=Math.min(mt.current,u),h=Math.max(mt.current,u);return Ke({start:p,end:h}),Pt(!0),!1},mouseup:()=>(Vt.current=!1,mt.current=null,Pt(!1),!1)}}},ut)}),zt&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):r.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})})]}),Ea=!!(o&&En[o]),Bs=o?dr[o]:null,$s=r.jsxs("section",{className:q("flex min-h-0 flex-col overflow-hidden",f?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[r.jsx("div",{className:q("flex flex-col gap-2 py-2",f?"px-3":"px-2"),children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1 min-w-0",children:[r.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),r.jsx(lr,{ref:I,value:P,onChange:t=>M(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),P.trim().length>0&&r.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{M(""),I.current?.focus()},children:r.jsx(F,{name:"close",className:"size-4"})})]}),r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>en("createFile",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:r.jsx(F,{name:"file-add",className:"size-4"})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>en("createFolder",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:r.jsx(F,{name:"folder-add",className:"size-4"})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{Cr()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:r.jsx(F,{name:"refresh",className:"size-4"})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),r.jsx(vn,{outerClassName:"flex-1 min-h-0",className:q("py-2",f?"px-3":"px-2"),children:r.jsx("ul",{className:"flex flex-col",children:Ti?r.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):Pn.length>0?Pn.map(t=>{const i=c?.path===t.path;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>{Te(t)},className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Si(t.path,t.extension),r.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Bs?r.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx("span",{className:"text-[var(--status-error)]",children:Bs}),r.jsxs(O,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Cr()},children:[r.jsx(F,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Ea?fs(o,0):r.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),Va=a==="full"&&W&&c&&r.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:r.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[r.jsx("div",{className:"absolute right-4 top-4 z-30",children:Os({exitFullscreenOnly:!0})}),r.jsx(vn,{ref:ka,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ge&&"[overflow-anchor:none]"),children:Me||Fs?D?r.jsx("div",{className:"p-4"}):r.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Qe?r.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Qe}):Ne?r.jsx("div",{className:"flex h-full items-center justify-center p-4",children:r.jsx("img",{src:Ns,alt:c.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):$e?Ss(c):st?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[r.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),r.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?r.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(F,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):qe&&Le()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:br,ref:Ta,children:[c?r.jsx(si,{containerRef:yr,filePath:c.path,fileContent:z}):null,z.length>500*1024&&r.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(z.length/1024)})}),r.jsx(xn,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:r.jsx(ti,{content:z,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),r.jsx(oi,{containerRef:yr,open:On,onOpenChange:xr,focusNonce:Bn,className:"right-4 top-16"})]}):Er&&B==="view"?Is(c,Ge?z:ie,Rs,Ca):r.jsxs("div",{className:q("relative h-full",zt&&"overflow-hidden"),children:[r.jsx("div",{className:q("h-full",zt&&"invisible"),children:r.jsx(hi,{positionKey:`${ut}:fullscreen`,value:ie,onChange:je,readOnly:!He,vimMode:Xn==="vim",extensions:vs,className:"h-full",onViewReady:t=>{Ue.current=t,window.requestAnimationFrame(()=>{It(t)})},onViewDestroy:()=>{Ue.current&&(Ue.current=null)}},`${ut}:fullscreen`)}),zt&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return r.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[r.jsx(bl,{activeDialog:yt,dialogData:jt,dialogInputValue:ft,onDialogInputChange:Ln,isDialogSubmitting:$i,onDialogSubmit:na,onClose:ja,inputRef:Di}),Va,f?_?mn:$s:a==="editor-only"?r.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:mn})}):r.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[m>=700&&r.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:$s}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:mn})]})]})};function jl(a){return a+1}export{Wu as FilesView};