@openchamber/web 1.21.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/bin/cli.test.js +35 -0
  2. package/bin/lib/DOCUMENTATION.md +12 -0
  3. package/bin/lib/cli-settings-accessors.js +111 -0
  4. package/bin/lib/cli-settings-accessors.test.js +189 -0
  5. package/bin/lib/cli-startup.js +29 -9
  6. package/bin/lib/commands-connect-url.js +12 -14
  7. package/dist/assets/{CodeMirrorCommentWidgets-C2BopIs3.js → CodeMirrorCommentWidgets-CPvfxh0N.js} +1 -1
  8. package/dist/assets/CommitSection-CC5mFzO2.js +1 -0
  9. package/dist/assets/DiffView-6xGdyI0n.js +4 -0
  10. package/dist/assets/FilesView-Bm3vT63N.js +17 -0
  11. package/dist/assets/GitView-B6y1Y69c.js +6 -0
  12. package/dist/assets/{JsonTreeView-osju7J70.js → JsonTreeView-rwHz84MX.js} +1 -1
  13. package/dist/assets/LinearIssuesView-B0UM_Rkx.js +1 -0
  14. package/dist/assets/MarkdownImageGallery-sGilV9Hs.js +1 -0
  15. package/dist/assets/MarkdownRendererImpl--4sRsKBn.js +12 -0
  16. package/dist/assets/OnboardingScreen-CECL_Cms.js +1 -0
  17. package/dist/assets/{PatchDiff-Dan3mADn.js → PatchDiff-BGPl1s-U.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-CGoI2v0q.js → PierreDiffViewer-Cvz9Z-io.js} +2 -2
  19. package/dist/assets/PlanView-BFMsnHk3.js +5 -0
  20. package/dist/assets/SettingsView-_Gtn5SdT.js +28 -0
  21. package/dist/assets/{SettingsWindow-DXF-MTHG.js → SettingsWindow-C1Qa09YO.js} +1 -1
  22. package/dist/assets/{ToolOutputDialog-DrCa1JRk.js → ToolOutputDialog-DzQlzMF4.js} +6 -6
  23. package/dist/assets/{ToolPartDiffPreview-B_tfvlNF.js → ToolPartDiffPreview-DfVOfwHy.js} +2 -2
  24. package/dist/assets/{VirtualizedFileDiff-CN_BctrR.js → VirtualizedFileDiff-DT5MDv-u.js} +1 -1
  25. package/dist/assets/WalkthroughView-D8sLH_M8.js +4 -0
  26. package/dist/assets/{computeVirtualFileMetrics-Gi1d5eU1.js → computeVirtualFileMetrics-DmpLWhll.js} +1 -1
  27. package/dist/assets/{contextPanelEmbeddedChat-CpzVNWAv.js → contextPanelEmbeddedChat-BK78t3M_.js} +1 -1
  28. package/dist/assets/de-C3luvSd_.js +9 -0
  29. package/dist/assets/es-CmU4HLv9.js +15 -0
  30. package/dist/assets/fr-Bgyni40l.js +13 -0
  31. package/dist/assets/index-C57jT0Sa.css +1 -0
  32. package/dist/assets/{index-Brm3X9rs.js → index-CWYs7sMK.js} +1 -1
  33. package/dist/assets/index-b0zDkWyg.js +7 -0
  34. package/dist/assets/{isDiffPlainText-pH9kAJQH.js → isDiffPlainText-BO_q5ezD.js} +1 -1
  35. package/dist/assets/{isFilePlainText-CVKy_dgB.js → isFilePlainText-D8qPqUAf.js} +1 -1
  36. package/dist/assets/ja-C1ImKinT.js +15 -0
  37. package/dist/assets/ko-CP7OdxYH.js +15 -0
  38. package/dist/assets/main-D4rd8Hy5.js +928 -0
  39. package/dist/assets/{main-vUCh0VB0.js → main-D7fwjW2z.js} +2 -2
  40. package/dist/assets/{markdown-shiki.worker-CKGJ1J33.js → markdown-shiki.worker-D5fBU-lw.js} +5 -5
  41. package/dist/assets/markdownCore-BcmkWZPO.js +3 -0
  42. package/dist/assets/{miniChat-BlzGEYgE.js → miniChat-D5rraz-g.js} +2 -2
  43. package/dist/assets/{mobile-CkX6H-IT.js → mobile-Cg_DE3KL.js} +2 -2
  44. package/dist/assets/{patchFileDiff-BCTsE43U.js → patchFileDiff-Bpql0QGw.js} +3 -3
  45. package/dist/assets/pl-DQYSiGYX.js +15 -0
  46. package/dist/assets/pt-BR-DytpsW4M.js +15 -0
  47. package/dist/assets/{renderElectronMiniChatApp-CJYe_KOL.js → renderElectronMiniChatApp-B_Bn7BbN.js} +2 -2
  48. package/dist/assets/renderMobileApp-DLfxMzGJ.js +25 -0
  49. package/dist/assets/runtimeEndpointReset-HlRmXFGW.js +16 -0
  50. package/dist/assets/scheduledTasksApi-BPvxrynl.js +1 -0
  51. package/dist/assets/{shikiHighlight-BgTPSITe.js → shikiHighlight-CFAVs_lu.js} +1 -1
  52. package/dist/assets/tr-aizaUvft.js +6 -0
  53. package/dist/assets/uk-DwnRxJZd.js +15 -0
  54. package/dist/assets/useAppFontEffects-DWXGRUPZ.js +7310 -0
  55. package/dist/assets/{useInlineCommentController-DFFv0hae.js → useInlineCommentController-Cc0OCXr0.js} +2 -2
  56. package/dist/assets/useRootScrollLock-BFZtfciC.js +1 -0
  57. package/dist/assets/{vendor-base-ui-_6j2xOWl.js → vendor-base-ui-BeMD8X_w.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-language-data-DkQX2EBa.js → vendor-codemirror-language-data-BGFszm8n.js} +2 -2
  59. package/dist/assets/{vendor-floating-ui-core-CXmKXOXc.js → vendor-floating-ui-core-PuGzNPnN.js} +1 -1
  60. package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-BTvzWks8.js} +1 -1
  61. package/dist/assets/{vendor-floating-ui-react-dom-DKpLs02S.js → vendor-floating-ui-react-dom-DxYCWdHj.js} +1 -1
  62. package/dist/assets/{vendor-floating-ui-utils-BzXdqYpP.js → vendor-floating-ui-utils-D6FqdtJt.js} +1 -1
  63. package/dist/assets/vendor-linkify-it-DZCzzDkK.js +1 -0
  64. package/dist/assets/vendor-marked-linkify-it-CXI_LHIE.js +1 -0
  65. package/dist/assets/vendor-uc.micro-BAd0H0z4.js +1 -0
  66. package/dist/assets/{web-components-DLnGY4fs.js → web-components-CD-GFayc.js} +4 -4
  67. package/dist/assets/zh-CN-UDNMxm7r.js +15 -0
  68. package/dist/assets/zh-TW-BsswdYL-.js +15 -0
  69. package/dist/index.html +5 -5
  70. package/dist/mini-chat.html +3 -3
  71. package/dist/mobile.html +3 -3
  72. package/dist/site.webmanifest +1 -1
  73. package/dist/sw.js +1 -1
  74. package/package.json +2 -2
  75. package/public/site.webmanifest +1 -1
  76. package/server/index.js +6 -2
  77. package/server/lib/cloudflare-tunnel.js +1 -1
  78. package/server/lib/dictation/DOCUMENTATION.md +19 -6
  79. package/server/lib/dictation/local/model-catalog.js +220 -0
  80. package/server/lib/dictation/local/model-catalog.test.js +42 -0
  81. package/server/lib/dictation/local/sherpa-tts.js +41 -20
  82. package/server/lib/dictation/local/worker-process.js +2 -0
  83. package/server/lib/dictation/runtime.js +4 -0
  84. package/server/lib/dictation/service.js +27 -4
  85. package/server/lib/fs/DOCUMENTATION.md +5 -0
  86. package/server/lib/fs/routes.js +150 -0
  87. package/server/lib/fs/routes.test.js +308 -3
  88. package/server/lib/git/DOCUMENTATION.md +4 -3
  89. package/server/lib/git/service.js +128 -6
  90. package/server/lib/git/service.test.js +191 -1
  91. package/server/lib/linear/DOCUMENTATION.md +97 -0
  92. package/server/lib/linear/OAUTH-BROKER-HANDOFF.md +91 -0
  93. package/server/lib/linear/auth.js +436 -0
  94. package/server/lib/linear/auth.test.js +242 -0
  95. package/server/lib/linear/client.js +191 -0
  96. package/server/lib/linear/index.js +61 -0
  97. package/server/lib/linear/issues.js +499 -0
  98. package/server/lib/linear/issues.test.js +512 -0
  99. package/server/lib/linear/mapping.js +188 -0
  100. package/server/lib/linear/mapping.test.js +147 -0
  101. package/server/lib/linear/oauth.js +345 -0
  102. package/server/lib/linear/oauth.test.js +166 -0
  103. package/server/lib/linear/parse.js +23 -0
  104. package/server/lib/linear/routes.js +432 -0
  105. package/server/lib/linear/routes.test.js +661 -0
  106. package/server/lib/linear/status-runtime.js +64 -0
  107. package/server/lib/linear/status-runtime.test.js +167 -0
  108. package/server/lib/linear/status.js +280 -0
  109. package/server/lib/linear/status.test.js +271 -0
  110. package/server/lib/linear/teams.js +72 -0
  111. package/server/lib/linear/teams.test.js +94 -0
  112. package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
  113. package/server/lib/markdown-image-grants/routes.js +3 -1
  114. package/server/lib/markdown-image-grants/routes.test.js +14 -0
  115. package/server/lib/openchamber-sessions/routes.js +4 -1
  116. package/server/lib/openchamber-sessions/routes.test.js +23 -0
  117. package/server/lib/opencode/env-runtime.js +17 -1
  118. package/server/lib/opencode/env-runtime.test.js +56 -0
  119. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  120. package/server/lib/opencode/lifecycle.js +48 -9
  121. package/server/lib/opencode/lifecycle.test.js +125 -1
  122. package/server/lib/opencode/managed-process-registry.d.ts +13 -0
  123. package/server/lib/opencode/managed-process-registry.js +213 -163
  124. package/server/lib/opencode/managed-process-registry.test.mjs +285 -0
  125. package/server/lib/opencode/project-directory-runtime.js +16 -11
  126. package/server/lib/opencode/project-directory-runtime.test.js +32 -12
  127. package/server/lib/opencode/pwa-manifest-routes.js +1 -1
  128. package/server/lib/opencode/routes-upgrade.test.js +96 -12
  129. package/server/lib/opencode/routes.js +53 -5
  130. package/server/lib/opencode/settings-helpers.js +3 -0
  131. package/server/lib/opencode/settings-helpers.test.js +10 -0
  132. package/server/lib/opencode/static-routes-runtime.js +3 -3
  133. package/server/lib/opencode/theme-runtime.js +1 -1
  134. package/server/lib/opencode/theme-runtime.test.js +129 -0
  135. package/server/lib/projects/project-config.js +33 -5
  136. package/server/lib/projects/project-config.test.js +85 -0
  137. package/server/lib/quota/DOCUMENTATION.md +19 -0
  138. package/server/lib/quota/providers/copilot.js +26 -10
  139. package/server/lib/quota/providers/copilot.test.js +78 -0
  140. package/server/lib/scheduled-tasks/DOCUMENTATION.md +7 -0
  141. package/server/lib/small-model/DOCUMENTATION.md +11 -5
  142. package/server/lib/small-model/call.js +64 -20
  143. package/server/lib/small-model/call.test.js +184 -2
  144. package/server/lib/tts/DOCUMENTATION.md +1 -0
  145. package/server/lib/tts/language-detect.js +210 -0
  146. package/server/lib/tts/language-detect.test.js +76 -0
  147. package/server/lib/tts/routes.js +23 -1
  148. package/server/lib/tts/routes.test.js +26 -0
  149. package/server/lib/tunnels/install-help.js +2 -2
  150. package/server/lib/tunnels/install-help.test.js +9 -0
  151. package/server/lib/walkthrough/languages.js +1 -0
  152. package/dist/assets/CommitSection-HJeMUAWb.js +0 -1
  153. package/dist/assets/DiffView-D5cvbEPb.js +0 -4
  154. package/dist/assets/FilesView-DPU8aNPL.js +0 -17
  155. package/dist/assets/GitView-Ct6xWrVH.js +0 -6
  156. package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +0 -1
  157. package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +0 -12
  158. package/dist/assets/OnboardingScreen-w2VG4fWY.js +0 -1
  159. package/dist/assets/PlanView-Dgg-WTEc.js +0 -4
  160. package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +0 -1
  161. package/dist/assets/SettingsView-D9yRuFZw.js +0 -28
  162. package/dist/assets/WalkthroughView-D9Q4lr5x.js +0 -4
  163. package/dist/assets/de-B_LdJwEM.js +0 -9
  164. package/dist/assets/es-CubfsAYV.js +0 -15
  165. package/dist/assets/fr-5qJM0nFS.js +0 -13
  166. package/dist/assets/index-BW82eK5v.css +0 -1
  167. package/dist/assets/index-rlLjZUM5.js +0 -7
  168. package/dist/assets/ja-DJYIBUlH.js +0 -15
  169. package/dist/assets/ko-DcUBkB7y.js +0 -15
  170. package/dist/assets/main-DLBxKIoX.js +0 -926
  171. package/dist/assets/markdownCore-DG6GHLF4.js +0 -3
  172. package/dist/assets/pl-rB6BLcio.js +0 -15
  173. package/dist/assets/pt-BR-DcwtlO-o.js +0 -15
  174. package/dist/assets/renderMobileApp-hQJTnr8B.js +0 -25
  175. package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +0 -15
  176. package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +0 -1
  177. package/dist/assets/uk-INZlFD9A.js +0 -15
  178. package/dist/assets/useAppFontEffects-Cll4gnsh.js +0 -7268
  179. package/dist/assets/zh-CN-Dzda8xa1.js +0 -15
  180. package/dist/assets/zh-TW-Cwn3rNYZ.js +0 -15
@@ -0,0 +1,76 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { detectTextLanguage, languageOfLocale, pickVoiceForLanguage } from './language-detect.js';
3
+
4
+ describe('detectTextLanguage', () => {
5
+ it.each([
6
+ ['en', 'The build is green and the tests pass, so you can merge this now.'],
7
+ ['uk', 'Привіт! Це тестове повідомлення, і воно написане українською мовою.'],
8
+ ['ru', 'Привет! Это тестовое сообщение, и оно написано на русском языке.'],
9
+ ['de', 'Die Änderung ist fertig und die Tests laufen ohne Fehler durch.'],
10
+ ['fr', 'La modification est prête et les tests passent sans erreur.'],
11
+ ['es', 'El cambio está listo y las pruebas pasan sin errores.'],
12
+ ['it', 'La modifica è pronta e i test passano senza errori.'],
13
+ ['pt', 'A alteração está pronta e os testes passam sem erros, você pode continuar.'],
14
+ ['pl', 'Zmiana jest gotowa i testy przechodzą bez błędów.'],
15
+ ['nl', 'De wijziging is klaar en de tests slagen zonder fouten.'],
16
+ ['cs', 'Změna je hotová a testy procházejí bez chyb.'],
17
+ ['tr', 'Değişiklik hazır ve testler hatasız geçiyor.'],
18
+ ['sv', 'Ändringen är klar och testerna går igenom utan fel.'],
19
+ ['zh', '修改已经完成,所有测试都通过了。'],
20
+ ['ja', '変更が完了し、すべてのテストに合格しました。'],
21
+ ['ko', '변경이 완료되었고 모든 테스트를 통과했습니다.'],
22
+ ])('detects %s', (language, text) => {
23
+ expect(detectTextLanguage(text).language).toBe(language);
24
+ });
25
+
26
+ it.each([
27
+ ['uk', 'Готово. Запушено.'],
28
+ ['uk', 'Все ок'],
29
+ ['uk', 'Добре, давай так зробимо'],
30
+ ['ru', 'Хорошо, давай так и сделаем'],
31
+ ['ru', 'Готово, всё запушено.'],
32
+ ])('tells short %s phrases apart by letters', (language, text) => {
33
+ expect(detectTextLanguage(text).language).toBe(language);
34
+ });
35
+
36
+ it('falls back to English for text without letters', () => {
37
+ expect(detectTextLanguage('1234 ... !!!').language).toBe('en');
38
+ expect(detectTextLanguage('').language).toBe('en');
39
+ });
40
+
41
+ it('does not let a single quoted foreign word flip an English paragraph', () => {
42
+ const text = 'The façade of the building is the part that you see from the street, and it is not the same as the interior.';
43
+ expect(detectTextLanguage(text).language).toBe('en');
44
+ });
45
+ });
46
+
47
+ describe('pickVoiceForLanguage', () => {
48
+ const voices = [
49
+ { name: 'Samantha', locale: 'en_US' },
50
+ { name: 'Daniel', locale: 'en_GB' },
51
+ { name: 'Lesya', locale: 'uk_UA' },
52
+ { name: 'Lesya (Enhanced)', locale: 'uk_UA' },
53
+ { name: 'Milena', locale: 'ru_RU' },
54
+ { name: 'Anna', locale: 'de_DE' },
55
+ ];
56
+
57
+ it('prefers the enhanced variant of a matching voice', () => {
58
+ expect(pickVoiceForLanguage('uk', voices)).toBe('Lesya (Enhanced)');
59
+ });
60
+
61
+ it('prefers the primary locale of a language', () => {
62
+ expect(pickVoiceForLanguage('en', voices)).toBe('Samantha');
63
+ });
64
+
65
+ it('returns null when no voice speaks the language', () => {
66
+ expect(pickVoiceForLanguage('ja', voices)).toBeNull();
67
+ });
68
+ });
69
+
70
+ describe('languageOfLocale', () => {
71
+ it('reads the language subtag', () => {
72
+ expect(languageOfLocale('uk_UA')).toBe('uk');
73
+ expect(languageOfLocale('en-GB')).toBe('en');
74
+ expect(languageOfLocale(null)).toBeNull();
75
+ });
76
+ });
@@ -2,6 +2,8 @@ import express from 'express';
2
2
  import { normalizeCustomOpenAIBaseURL } from './base-url.js';
3
3
  import { summarizeText, sanitizeForTTS, sanitizeForNote } from '../text/summarization.js';
4
4
 
5
+ import { detectTextLanguage, languageOfLocale, pickVoiceForLanguage } from './language-detect.js';
6
+
5
7
  export function registerTtsRoutes(app, { sayTTSCapability }) {
6
8
  let ttsModulePromise = null;
7
9
  const getTtsModule = async () => {
@@ -154,7 +156,8 @@ export function registerTtsRoutes(app, { sayTTSCapability }) {
154
156
  // macOS 'say' command TTS speak endpoint
155
157
  app.post('/api/tts/say/speak', async (req, res) => {
156
158
  try {
157
- const { text, voice = 'Samantha', rate = 200 } = req.body || {};
159
+ const { text, rate = 200, language, languageSample } = req.body || {};
160
+ let voice = typeof req.body?.voice === 'string' && req.body.voice.trim() ? req.body.voice.trim() : 'Samantha';
158
161
 
159
162
  if (!text || typeof text !== 'string' || !text.trim()) {
160
163
  return res.status(400).json({ error: 'Text is required' });
@@ -164,6 +167,23 @@ export function registerTtsRoutes(app, { sayTTSCapability }) {
164
167
  if (process.platform !== 'darwin') {
165
168
  return res.status(503).json({ error: 'macOS say command not available on this platform' });
166
169
  }
170
+
171
+ // `language: 'auto'`: keep the chosen voice while it speaks the text's
172
+ // language, otherwise switch to an installed voice that does. A
173
+ // language with no installed voice keeps the chosen voice — say still
174
+ // reads the text, just with an accent — rather than failing.
175
+ let resolvedLanguage = null;
176
+ if (language === 'auto') {
177
+ const capability = await sayTTSCapability;
178
+ const voices = Array.isArray(capability?.voices) ? capability.voices : [];
179
+ const sample = typeof languageSample === 'string' && languageSample.trim() ? languageSample.slice(0, 4000) : text;
180
+ resolvedLanguage = detectTextLanguage(sample).language;
181
+ const chosen = voices.find((entry) => entry.name === voice);
182
+ if (languageOfLocale(chosen?.locale) !== resolvedLanguage) {
183
+ const match = pickVoiceForLanguage(resolvedLanguage, voices);
184
+ if (match) voice = match;
185
+ }
186
+ }
167
187
 
168
188
  const { exec } = await import('child_process');
169
189
  const { promisify } = await import('util');
@@ -195,6 +215,8 @@ export function registerTtsRoutes(app, { sayTTSCapability }) {
195
215
 
196
216
  // Send audio response
197
217
  res.setHeader('Content-Type', 'audio/mp4');
218
+ res.setHeader('X-Speech-Voice', voice);
219
+ if (resolvedLanguage) res.setHeader('X-Speech-Language', resolvedLanguage);
198
220
  res.setHeader('Content-Length', audioBuffer.length);
199
221
  res.send(audioBuffer);
200
222
 
@@ -33,6 +33,32 @@ describe('tts routes', () => {
33
33
  });
34
34
  });
35
35
 
36
+ it('switches the say voice to the language of the text when asked to', async () => {
37
+ const capability = Promise.resolve({
38
+ available: true,
39
+ voices: [
40
+ { name: 'Samantha', locale: 'en_US' },
41
+ { name: 'Lesya', locale: 'uk_UA' },
42
+ { name: 'Lesya (Enhanced)', locale: 'uk_UA' },
43
+ ],
44
+ });
45
+ const app = createApp(capability);
46
+ const response = await request(app)
47
+ .post('/api/tts/say/speak')
48
+ .send({ text: 'Привіт! Це відповідь українською мовою, і вона досить довга.', voice: 'Samantha', language: 'auto' });
49
+
50
+ // On macOS the route synthesizes; elsewhere it refuses before running say.
51
+ // Either way the chosen voice must be the Ukrainian one when the platform
52
+ // allows the request to proceed.
53
+ if (process.platform === 'darwin') {
54
+ expect(response.status).toBe(200);
55
+ expect(response.headers['x-speech-voice']).toBe('Lesya (Enhanced)');
56
+ expect(response.headers['x-speech-language']).toBe('uk');
57
+ } else {
58
+ expect(response.status).toBe(503);
59
+ }
60
+ });
61
+
36
62
  it('returns local note fallback while model summarization is retired', async () => {
37
63
  const response = await request(createApp())
38
64
  .post('/api/text/summarize')
@@ -6,11 +6,11 @@ import {
6
6
  const PROVIDER_INSTALL_INFO = {
7
7
  [TUNNEL_PROVIDER_CLOUDFLARE]: {
8
8
  dependency: 'cloudflared',
9
- installUrl: 'https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflared/downloads/',
9
+ installUrl: 'https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/',
10
10
  commands: {
11
11
  darwin: 'brew install cloudflared',
12
12
  win32: 'winget install --id Cloudflare.cloudflared',
13
- linux: 'Download cloudflared from https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflared/downloads/',
13
+ linux: 'Download cloudflared from https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/',
14
14
  },
15
15
  },
16
16
  [TUNNEL_PROVIDER_NGROK]: {
@@ -28,4 +28,13 @@ describe('getTunnelDependencyInstallInfo', () => {
28
28
 
29
29
  expect(info.installCommand).toBe('brew install cloudflared');
30
30
  });
31
+
32
+ it('returns the current Linux cloudflared download guidance', () => {
33
+ const info = getTunnelDependencyInstallInfo(TUNNEL_PROVIDER_CLOUDFLARE, 'linux');
34
+ const downloadUrl = 'https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/';
35
+
36
+ expect(info.installUrl).toBe(downloadUrl);
37
+ expect(info.installCommand).toBe(`Download cloudflared from ${downloadUrl}`);
38
+ expect(info.message).toContain(downloadUrl);
39
+ });
31
40
  });
@@ -27,6 +27,7 @@ const LANGUAGE_NAMES = {
27
27
  ko: 'Korean',
28
28
  pl: 'Polish',
29
29
  ja: 'Japanese',
30
+ tr: 'Turkish',
30
31
  };
31
32
 
32
33
  /**
@@ -1 +0,0 @@
1
- import{R as S,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ve}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,am as ze,a4 as fe,a5 as me,I as $,a6 as ue,h as J,B as Z,$ as Ee,gR as Te,bz as pe,bA as ge,bB as xe,bC as be,bD as ye,bE as ve,bj as Ie}from"./useAppFontEffects-Cll4gnsh.js";import{u as Ce}from"./index-rlLjZUM5.js";const ke={"?":{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"}},Me=ke.M;function Re(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 $e(p){const e=Re(p);return ke[e]??Me}const He=S.memo(function(e){const t=oe.c(58),{file:o,actionLabel:x,actionSymbol:b,onAction:m,onViewDiff:f,onRevert:l,isReverting:d,stats:z,rowPaddingClassName:g,indentPx:y,actionAtStart:V,showRevert:H}=e,j=y===void 0?0:y,r=V===void 0?!1:V,w=H===void 0?!0:H;let N;t[0]!==o?(N=$e(o),t[0]=o,t[1]=N):N=t[1];const h=N,{t:E}=Q(),F=h.description,M=z?.insertions??0,C=z?.deletions??0;let D;t[2]!==m||t[3]!==f?(D=U=>{U.key===" "?(U.preventDefault(),m()):U.key==="Enter"&&(U.preventDefault(),f())},t[2]=m,t[3]=f,t[4]=D):D=t[4];const A=D;let T;t[5]!==m?(T=U=>{U.preventDefault(),U.stopPropagation(),m()},t[5]=m,t[6]=T):T=t[6];const u=T;let P;t[7]!==l?(P=U=>{U.preventDefault(),U.stopPropagation(),l()},t[7]=l,t[8]=P):P=t[8];const W=P;let L;t[9]!==x||t[10]!==b||t[11]!==u?(L=s.jsx("button",{type:"button",onClick:u,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":x,title:x,children:b}),t[9]=x,t[10]=b,t[11]=u,t[12]=L):L=t[12];const R=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${g??"px-3"}`;let I;t[13]!==j?(I=j>0?{paddingLeft:`${j}px`}:void 0,t[13]=j,t[14]=I):I=t[14];const Y=r?R:null;let K;t[15]!==h.color?(K={color:h.color},t[15]=h.color,t[16]=K):K=t[16];let G;t[17]!==h.code||t[18]!==F||t[19]!==K?(G=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:F,"aria-label":F,children:h.code}),t[17]=h.code,t[18]=F,t[19]=K,t[20]=G):G=t[20];let O;t[21]!==o.path?(O=s.jsx(ze,{filePath:o.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=o.path,t[22]=O):O=t[22];let B;if(t[23]!==o.path){e:{const U=o.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],B=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:o.path,children:o.path});break e}const De=o.path.slice(0,U),Ae=o.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 re=s.jsx("span",{className:"text-foreground",children:Ae.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],B=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:o.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:De}),ie]})}t[23]=o.path,t[24]=B}else B=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]!==M?(i=s.jsxs("span",{style:q,children:["+",M]}),t[31]=M,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==C?(c=s.jsxs("span",{style:a,children:["-",C]}),t[35]=C,t[36]=c):c=t[36];let k;t[37]!==i||t[38]!==c?(k=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=k):k=t[39];let v;t[40]!==o.path||t[41]!==W||t[42]!==d||t[43]!==w||t[44]!==E?(v=w?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:d,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":E("gitView.changes.revertFileAria",{path:o.path}),children:d?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx($,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=o.path,t[41]=W,t[42]=d,t[43]=w,t[44]=E,t[45]=v):v=t[45];const _=r?null:R;let ee;return t[46]!==A||t[47]!==f||t[48]!==I||t[49]!==Y||t[50]!==G||t[51]!==O||t[52]!==B||t[53]!==k||t[54]!==v||t[55]!==_||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:f,onKeyDown:A,style:I,children:[Y,G,O,B,k,v,_]}),t[46]=A,t[47]=f,t[48]=I,t[49]=Y,t[50]=G,t[51]=O,t[52]=B,t[53]=k,t[54]=v,t[55]=_,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const o=Se(t.path);if(!o)continue;const b=o.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),b.length>0){let f="";for(const l of b){f=f?`${f}/${l}`:l;const d=m.children.get(l);if(d){d.files.push(t),m=d;continue}const z=we(f,l);z.files.push(t),m.children.set(l,z),m=z}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],o=(x,b)=>{const m=Array.from(x.children.values()).sort((l,d)=>l.path.localeCompare(d.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:b,directory:l}),e.has(l.path)&&o(l,b+1);const f=[...x.directFiles].sort((l,d)=>l.path.localeCompare(d.path));for(const l of f)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:b,file:l})};return o(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:o=!1,headerBackgroundClassName:x="bg-sidebar",onVisiblePathsChange:b,onRevertAll:m,onRevertDirectory:f})=>{const{t:l}=Q(),d=S.useRef(null),g=Ce(i=>i.gitChangesViewMode)==="tree",y=S.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,H]=S.useState(new Set),[j,r]=S.useState(new Set),[w,N]=S.useState(!1),[h,E]=S.useState(null),F=S.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),M=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(F[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[F,y]);S.useEffect(()=>{g&&r(i=>{const n=new Set,a=new Set(M);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),M.forEach(c=>n.add(c)),n})},[g,M]);const C=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!V.has(n.id)){if(g){const c=new Set;j.forEach(v=>{v.startsWith(`${n.id} `)&&c.add(v.slice(n.id.length+1))}),Pe(F[a],c).forEach(v=>{v.kind==="file"?i.push({type:"file",key:`${n.id}:${v.key}`,groupIndex:a,file:v.file,depth:v.depth}):i.push({type:"directory",key:`${n.id}:${v.key}`,groupIndex:a,directory:v.directory,depth:v.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,j,g,m,F,y]),D=C.length,A=D>=Le,T=Ve({count:D,enabled:A,getScrollElement:()=>d.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>C[i]?.key??i}),u=T.getVirtualItems(),P=S.useMemo(()=>{if(!A)return 0;const i=d.current?.scrollTop??0;return u.find(a=>a.end>i)?.index??0},[A,u,d]);S.useEffect(()=>{if(!b)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(D===0){b([]);return}if(!A){const n=[];for(const a of C)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;b(n);return}b(C.slice(P,P+Math.ceil((d.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[b,D,C,A,P]);const W=S.useCallback(i=>{H(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),L=S.useCallback((i,n)=>{r(a=>{const c=new Set(a),k=de(i,n);return c.has(k)?c.delete(k):c.add(k),c})},[]),R=S.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),X=R.length,I=h?o||h.paths.some(i=>t.has(i)):!1,Y=S.useCallback(async()=>{!m||o||R.length===0||(await m(R),N(!1))},[R,o,m]),K=S.useCallback(async()=>{!f||!h||I||(await f(h.paths),E(null))},[I,f,h]),G=S.useCallback((i,n)=>{const a=V.has(i.id),c=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",x,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(k=>k.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":!a,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:c}),s.jsx($,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[V,x,W]),O=S.useCallback((i,n,a)=>{const c=j.has(de(i.id,n.path)),k=n.files.map(_=>_.path),v=o||k.some(_=>t.has(_));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*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":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx($,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx($,{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&&f?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:k,count:k.length}),disabled:v,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":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:v?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx($,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(_=>_.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":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[j,o,f,t,l,L]),B=S.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>N(!0),disabled:o,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx($,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return G(a,n);if(i.type==="directory")return O(a,i.directory,i.depth);const c=i.file;return s.jsx(He,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||o,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!g,showRevert:a.showRevertActions!==!1})},[e,o,g,O,G,t,l,y]),q=S.useCallback(i=>{const n=C[i],a=C[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[C]);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(Ee,{ref:d,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:A?s.jsx("div",{style:{height:T.getTotalSize(),position:"relative"},children:u.map(i=>{const n=C[i.index];return n?s.jsx("div",{"data-index":i.index,ref:T.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(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:B(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:C.map((i,n)=>s.jsx("div",{className:J("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:B(i,n===0)},i.key))})}),s.jsx(Te,{containerRef:d,disableHorizontal:!0})]}),s.jsx(pe,{open:w,onOpenChange:i=>{!o&&!i&&N(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:X===1?l("gitView.changes.revertAllDescriptionSingle",{count:X}):l("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>N(!1),disabled:o,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{Y()},disabled:o,children:l(o?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!h,onOpenChange:i=>{!I&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:h?h.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:h.count,path:h.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:h.count,path:h.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:I,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:I||!h,children:l(I?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(23),{value:t,onChange:o,onSubmit:x,placeholder:b,disabled:m,hasTouchInput:f,isMobile:l}=p,d=m===void 0?!1:m,z=f===void 0?!1:f,g=l===void 0?!1:l,{t:y}=Q(),V=S.useRef(null),H=Ce(Oe);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const u=V.current;if(!u)return;const P=document.activeElement===u,W=()=>{u.style.height=`${he}px`;const R=u.scrollHeight,X=Math.min(Math.max(R,he),ae);u.style.height=`${X}px`,u.style.overflowY=R>ae?"auto":"hidden",R>ae&&!P&&(u.scrollTop=u.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=j):j=e[0];let r;e[1]!==t?(r=[t],e[1]=t,e[2]=r):r=e[2],S.useLayoutEffect(j,r);let w;e[3]!==o?(w=u=>o(u.target.value),e[3]=o,e[4]=w):w=e[4];let N;e[5]!==x?(N=u=>{u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&!u.shiftKey&&!u.altKey&&(u.preventDefault(),x?.())},e[5]=x,e[6]=N):N=e[6];let h;e[7]!==b||e[8]!==y?(h=b??y("gitView.commit.messagePlaceholder"),e[7]=b,e[8]=y,e[9]=h):h=e[9];const E=z?"on":"off",F=z?"sentences":"off",M=g||H,C=d&&"opacity-50";let D;e[10]!==C?(D=J("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)]",C),e[10]=C,e[11]=D):D=e[11];let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A={minHeight:he,maxHeight:ae},e[12]=A):A=e[12];let T;return e[13]!==d||e[14]!==F||e[15]!==M||e[16]!==D||e[17]!==w||e[18]!==N||e[19]!==h||e[20]!==E||e[21]!==t?(T=s.jsx("textarea",{ref:V,value:t,onChange:w,onKeyDown:N,placeholder:h,rows:1,disabled:d,autoCorrect:E,autoCapitalize:F,spellCheck:M,className:D,style:A}),e[13]=d,e[14]=F,e[15]=M,e[16]=D,e[17]=w,e[18]=N,e[19]=h,e[20]=E,e[21]=t,e[22]=T):T=e[22],T};function Oe(p){return p.inputSpellcheckEnabled}const Ke=p=>{const e=oe.c(30),{highlights:t,onInsert:o}=p,{t:x}=Q();if(t.length===0)return null;let b;e[0]!==t||e[1]!==o?(b=()=>{o(t)},e[0]=t,e[1]=o,e[2]=b):b=e[2];const m=b;let f;e[3]!==x?(f=x("gitView.commit.aiHighlights.title"),e[3]=x,e[4]=f):f=e[4];let l;e[5]!==f?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:f}),e[5]=f,e[6]=l):l=e[6];let d;e[7]!==x?(d=x("gitView.commit.aiHighlights.insertAria"),e[7]=x,e[8]=d):d=e[8];let z;e[9]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx($,{name:"arrow-down",className:"size-4"}),e[9]=z):z=e[9];let g;e[10]!==m||e[11]!==d?(g=s.jsx(me,{asChild:!0,children:s.jsx(Z,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":d,children:z})}),e[10]=m,e[11]=d,e[12]=g):g=e[12];let y;e[13]!==x?(y=x("gitView.commit.aiHighlights.insertTooltip"),e[13]=x,e[14]=y):y=e[14];let V;e[15]!==y?(V=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=V):V=e[16];let H;e[17]!==g||e[18]!==V?(H=s.jsxs(fe,{children:[g,V]}),e[17]=g,e[18]=V,e[19]=H):H=e[19];let j;e[20]!==l||e[21]!==H?(j=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,H]}),e[20]=l,e[21]=H,e[22]=j):j=e[22];let r;e[23]!==t?(r=t.map(Be),e[23]=t,e[24]=r):r=e[24];let w;e[25]!==r?(w=s.jsx("ul",{className:"space-y-1",children:r}),e[25]=r,e[26]=w):w=e[26];let N;return e[27]!==j||e[28]!==w?(N=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[j,w]}),e[27]=j,e[28]=w,e[29]=N):N=e[29],N};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const qe=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:o,onCommitMessageChange:x,generatedHighlights:b,onInsertHighlights:m,onGenerateMessage:f,isGeneratingMessage:l,onCommit:d,onCommitAndPush:z,commitAction:g,hasPendingIndexMutation:y,gitmojiEnabled:V,onOpenGitmojiPicker:H}=p,j=y===void 0?!1:y,{t:r}=Q(),w=t>0;let N;e[0]!==g||e[1]!==o||e[2]!==j||e[3]!==w?(N=o.trim()&&w&&g===null&&!j,e[0]=g,e[1]=o,e[2]=j,e[3]=w,e[4]=N):N=e[4];const h=N,{isMobile:E,hasTouchInput:F}=Ie();let M;e[5]!==r?(M=r("gitView.commit.title"),e[5]=r,e[6]=M):M=e[6];let C;e[7]!==M?(C=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:M}),e[7]=M,e[8]=C):C=e[8];let D;e[9]!==w||e[10]!==r?(D=w?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:r("gitView.commit.stageFilesHint")}),e[9]=w,e[10]=r,e[11]=D):D=e[11];let A;e[12]!==C||e[13]!==D?(A=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[C,D]}),e[12]=C,e[13]=D,e[14]=A):A=e[14];let T;e[15]!==b||e[16]!==m?(T=s.jsx(Ke,{highlights:b,onInsert:m}),e[15]=b,e[16]=m,e[17]=T):T=e[17];let u;e[18]!==h||e[19]!==l||e[20]!==d?(u=()=>{h&&!l&&d()},e[18]=h,e[19]=l,e[20]=d,e[21]=u):u=e[21];let P;e[22]!==r?(P=r("gitView.commit.messagePlaceholder"),e[22]=r,e[23]=P):P=e[23];const W=g!==null;let L;e[24]!==o||e[25]!==F||e[26]!==E||e[27]!==x||e[28]!==W||e[29]!==u||e[30]!==P?(L=s.jsx(Ge,{value:o,onChange:x,onSubmit:u,placeholder:P,disabled:W,hasTouchInput:F,isMobile:E}),e[24]=o,e[25]=F,e[26]=E,e[27]=x,e[28]=W,e[29]=u,e[30]=P,e[31]=L):L=e[31];let R;e[32]!==V||e[33]!==H||e[34]!==r?(R=V&&s.jsxs(Z,{variant:"outline",size:"sm",onClick:H,className:"w-fit",type:"button",children:[s.jsx($,{name:"emotion-happy",className:"size-4"}),r("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=H,e[34]=r,e[35]=R):R=e[35];const X=l||g!==null||j||t===0;let I;e[36]!==r?(I=r("gitView.commit.generateAria"),e[36]=r,e[37]=I):I=e[37];let Y;e[38]!==l?(Y=l?s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx($,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=l,e[39]=Y):Y=e[39];let K;e[40]!==r?(K=r("gitView.commit.generate"),e[40]=r,e[41]=K):K=e[41];let G;e[42]!==K?(G=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=G):G=e[43];let O;e[44]!==f||e[45]!==X||e[46]!==I||e[47]!==Y||e[48]!==G?(O=s.jsxs(Z,{variant:"outline",size:"sm",onClick:f,disabled:X,type:"button","aria-label":I,className:"commit-actions__btn",children:[Y,G]}),e[44]=f,e[45]=X,e[46]=I,e[47]=Y,e[48]=G,e[49]=O):O=e[49];let B;e[50]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[50]=B):B=e[50];const q=!h||l;let i;e[51]!==r?(i=r("gitView.commit.commitAria"),e[51]=r,e[52]=i):i=e[52];let n;e[53]!==g||e[54]!==r?(n=g==="commit"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.commit")})]}),e[53]=g,e[54]=r,e[55]=n):n=e[55];let a;e[56]!==d||e[57]!==q||e[58]!==i||e[59]!==n?(a=s.jsx(Z,{size:"sm",variant:"outline",onClick:d,disabled:q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=d,e[57]=q,e[58]=i,e[59]=n,e[60]=a):a=e[60];let c;e[61]!==h||e[62]!==g||e[63]!==l||e[64]!==E||e[65]!==z||e[66]!==r?(c=E?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx(Z,{variant:"default",size:"sm",onClick:()=>z(),disabled:!h||l,className:"h-7 w-7 p-0","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx($,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:r("gitView.commit.push")})})]}):s.jsx(Z,{size:"sm",variant:"default",onClick:()=>z(),disabled:!h||l,className:"commit-actions__btn","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.push")})]})}),e[61]=h,e[62]=g,e[63]=l,e[64]=E,e[65]=z,e[66]=r,e[67]=c):c=e[67];let k;e[68]!==O||e[69]!==a||e[70]!==c?(k=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[O,B,a,c]}),e[68]=O,e[69]=a,e[70]=c,e[71]=k):k=e[71];let v;e[72]!==L||e[73]!==R||e[74]!==k||e[75]!==T?(v=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[T,L,R,k]}),e[72]=L,e[73]=R,e[74]=k,e[75]=T,e[76]=v):v=e[76];let _;return e[77]!==v||e[78]!==A?(_=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[A,v]}),e[77]=v,e[78]=A,e[79]=_):_=e[79],_};export{Ye as C,qe as a};
@@ -1,4 +0,0 @@
1
- import{R as o,j as n,f as be}from"./vendor-react-BUCujlKS.js";import{W as pn,a as at,u as te,F as Ge}from"./index-rlLjZUM5.js";import{f as we,V as Et,a9 as hn,bj as gn,ab as xn,aa as bn,ac as wn,ad as ae,y as vt,k as yn,hB as vn,hC as jn,hD as Sn,cw as Nn,t as Ke,hE as Fn,ak as Be,B as me,I as A,h as le,a4 as kn,a5 as Cn,a6 as Dn,ho as Bt,hF as Rn,fp as An,fu as $e,_ as En,bX as it,am as Vt,aj as Bn,aZ as Vn,a$ as Ln,fv as Tn,b0 as Mn}from"./useAppFontEffects-Cll4gnsh.js";import{c as _n,p as In}from"./vendor-zustand-BAGL70zf.js";import{P as On}from"./PierreDiffViewer-CGoI2v0q.js";import{u as zn,v as Pn,g as Gn,W as $n}from"./main-DLBxKIoX.js";import{f as Kn}from"./patchFileDiff-BCTsE43U.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-_6j2xOWl.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-CpzVNWAv.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"./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-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.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-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-DkQX2EBa.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-DLnGY4fs.js";import"./computeVirtualFileMetrics-Gi1d5eU1.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"./VirtualizedFileDiff-CN_BctrR.js";import"./isDiffPlainText-pH9kAJQH.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-DFFv0hae.js";import"./runtimeEndpointReset-BDh7r8BL.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./SessionSwitcherDropdown-CJTrc8K7.js";import"./scheduledTasksApi-CAGPh_gZ.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const Wn="openchamber.git-base-branch",Hn=100,We=(s,e)=>JSON.stringify([at(),s,e]),jt=_n()(In((s,e)=>({overrides:{},getOverride:(i,a)=>!i||!a?null:e().overrides[We(i,a)]??null,setOverride:(i,a,d)=>{!i||!a||!d||s(f=>{const p=We(i,a),g=Object.entries({...f.overrides,[p]:d});for(;g.length>Hn;)g.shift();return{overrides:Object.fromEntries(g)}})},clearOverride:(i,a)=>{!i||!a||s(d=>{const f=We(i,a);if(!(f in d.overrides))return d;const p={...d.overrides};return delete p[f],{overrides:p}})}}),{name:Wn,storage:pn(),partialize:s=>({overrides:s.overrides})})),Un=(s,e)=>!!s&&e!==null&&s!==e,qn=(s,e,i,a)=>i?s===null||a&&e===null?!0:e!==null&&s===e:!1,Xn=(s,e)=>s==="branch"&&!e?"working":s,Jn=(s,e,i)=>JSON.stringify([s,e,i]),Yn=(s,e,i,a,d,f)=>{const p=o.useRef({directory:"",attempts:0}),[g,u]=o.useState(()=>({directory:"",exhausted:!1})),m=o.useRef(d);m.current=d;const x=!!s&&g.directory===s&&g.exhausted;return o.useEffect(()=>{if(!s||!e||a||i)return;const c=p.current.directory===s?p.current.attempts:0;if(c>=f){g.directory===s&&g.exhausted||u({directory:s,exhausted:!0});return}p.current={directory:s,attempts:c+1},m.current()},[s,g,a,e,i,f]),x},Qn=(s,e,i,a)=>{const[d,f]=o.useState(()=>new Map),p=o.useRef(d);p.current=d;const g=o.useRef(i);g.current=i;const u=o.useCallback((m,x)=>{const c=new Map(p.current);if(x===null){if(!c.delete(m))return}else c.set(m,x);p.current=c,f(c)},[]);return o.useEffect(()=>{s&&(p.current=new Map,f(p.current))},[s]),o.useEffect(()=>{const m=g.current;if(!s||!m||!e)return;let x=!1;const c=new Set;for(const v of e.split("\0"))p.current.has(v)||(c.add(v),u(v,a),m(v).then(S=>{x||(c.delete(v),u(v,S))}).catch(()=>{x||(c.delete(v),u(v,null))}));return()=>{x=!0;for(const v of c)u(v,null)}},[e,a,s,u]),d},St=(s,e)=>{if(e.length===0)return null;let i=null,a=null;for(const f of e)f.top<=s?(!i||f.top>i.top)&&(i=f):(!a||f.top<a.top)&&(a=f);const d=i??a;return d?{path:d.path,topOffset:d.top-s}:null},Zn=(s,e,i,a)=>Math.min(Math.max(0,a),Math.max(0,s+i-e)),Nt=s=>{if(!s)return null;const e=s.split(`
2
- `);let i=null;for(const a of e){const d=a.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(d){const f=Number.parseInt(d[1]??"",10);i=Number.isFinite(f)&&f>=1?f:null;continue}if(i!==null){if(a.startsWith(" ")){i+=1;continue}if(a.startsWith("+"))return i;if(a.startsWith("-"))return Math.max(1,i)}}return null},es=1100,ts=15e3,Ft=500,kt=300,ns=1e6,ss=3,rs=s=>s<=6?s:s<=12?6:s<=25?4:2,is={original:"",modified:"",isBinary:!1,contextMode:"patch"},os=3,as=o.memo(()=>{const s=be.c(4),{t:e}=we();let i;s[0]!==e?(i=e("diffView.binary.unavailable"),s[0]=e,s[1]=i):i=s[1];let a;return s[2]!==i?(a=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:i})}),s[2]=i,s[3]=a):a=s[3],a}),Lt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},ls=Lt.M,cs=s=>{const e=s.index?.trim(),i=s.working_dir?.trim();return e&&e!=="?"?e.charAt(0):i?i.charAt(0):e?.charAt(0)||i?.charAt(0)||"M"},Tt=s=>{const e=cs(s);return Lt[e]??ls},us=s=>{const{index:e,working_dir:i}=s;return e==="A"||i==="A"||e==="?"||i==="?"},Ct=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},Dt=s=>!!s.working_dir?.trim()||s.index==="?",fs=(s,e)=>An(s,e),Rt=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),At=(s,e)=>{const i=s.split(`
3
- `),a=e.split(`
4
- `),d=Math.min(i.length,a.length);for(let f=0;f<d;f+=1)if(i[f]!==a[f])return f+1;return a.length>i.length?i.length+1:i.length>a.length?Math.max(1,a.length):1},ds=s=>/^Binary files .+ differ$/m.test(s)||/^GIT binary patch$/m.test(s),ms=s=>Array.isArray(s)?s.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],ps=s=>s==="added"?"A":s==="deleted"?"D":"M",ot=(s,e,i)=>ds(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:i}:{original:"",modified:"",patch:e,fileDiff:Kn(s,e),contextMode:i},Mt=(s,e,i)=>{const a=s??0,d=e??0;return!a&&!d?null:n.jsxs("span",{className:le("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",i?.className),children:[a?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",a]}):null,d?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d]}):null]})},hs=o.memo(s=>{const e=be.c(58),{scope:i,workingCount:a,stagedCount:d,turnCount:f,branchCount:p,showBranchOption:g,onScopeChange:u}=s,{t:m}=we(),[x,c]=o.useState(!1),v=i==="staged"?d:i==="turn"?f:i==="branch"?p??0:a;let S;e[0]!==i||e[1]!==m?(S=m(i==="staged"?"diffView.scope.staged":i==="turn"?"diffView.scope.lastTurn":i==="branch"?"diffView.scope.branch":"diffView.scope.changed"),e[0]=i,e[1]=m,e[2]=S):S=e[2];const O=S;let T;e[3]!==m?(T=m("diffView.scope.selectorAria"),e[3]=m,e[4]=T):T=e[4];let ne;e[5]!==v?(ne=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",v]}),e[5]=v,e[6]=ne):ne=e[6];let y;e[7]!==O||e[8]!==ne?(y=n.jsxs("span",{className:"whitespace-nowrap",children:[O,ne]}),e[7]=O,e[8]=ne,e[9]=y):y=e[9];let V;e[10]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(A,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=V):V=e[10];let M;e[11]!==T||e[12]!==y?(M=n.jsx(Vn,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":T,children:[y,V]})}),e[11]=T,e[12]=y,e[13]=M):M=e[13];let q;e[14]!==u?(q=ie=>{(ie==="working"||ie==="staged"||ie==="turn"||ie==="branch")&&(u?.(ie),c(!1))},e[14]=u,e[15]=q):q=e[15];let X;e[16]!==m?(X=m("diffView.scope.changed"),e[16]=m,e[17]=X):X=e[17];let se;e[18]!==X?(se=n.jsx("span",{children:X}),e[18]=X,e[19]=se):se=e[19];let J;e[20]!==a?(J=n.jsx("span",{className:"typography-meta text-muted-foreground",children:a}),e[20]=a,e[21]=J):J=e[21];let Y;e[22]!==J||e[23]!==se?(Y=n.jsx($e,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[se,J]})}),e[22]=J,e[23]=se,e[24]=Y):Y=e[24];let C;e[25]!==m?(C=m("diffView.scope.staged"),e[25]=m,e[26]=C):C=e[26];let _;e[27]!==C?(_=n.jsx("span",{children:C}),e[27]=C,e[28]=_):_=e[28];let re;e[29]!==d?(re=n.jsx("span",{className:"typography-meta text-muted-foreground",children:d}),e[29]=d,e[30]=re):re=e[30];let L;e[31]!==_||e[32]!==re?(L=n.jsx($e,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[_,re]})}),e[31]=_,e[32]=re,e[33]=L):L=e[33];let G;e[34]!==m?(G=m("diffView.scope.lastTurn"),e[34]=m,e[35]=G):G=e[35];let $;e[36]!==G?($=n.jsx("span",{children:G}),e[36]=G,e[37]=$):$=e[37];let E;e[38]!==f?(E=n.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[38]=f,e[39]=E):E=e[39];let K;e[40]!==$||e[41]!==E?(K=n.jsx($e,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[$,E]})}),e[40]=$,e[41]=E,e[42]=K):K=e[42];let Q;e[43]!==p||e[44]!==g||e[45]!==m?(Q=g?n.jsx($e,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:m("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:p??"…"})]})}):null,e[43]=p,e[44]=g,e[45]=m,e[46]=Q):Q=e[46];let z;e[47]!==i||e[48]!==Y||e[49]!==L||e[50]!==K||e[51]!==Q||e[52]!==q?(z=n.jsx(Ln,{align:"start",className:"w-40",children:n.jsxs(Tn,{value:i,onValueChange:q,children:[Y,L,K,Q]})}),e[47]=i,e[48]=Y,e[49]=L,e[50]=K,e[51]=Q,e[52]=q,e[53]=z):z=e[53];let W;return e[54]!==x||e[55]!==z||e[56]!==M?(W=n.jsxs(Mn,{open:x,onOpenChange:c,children:[M,z]}),e[54]=x,e[55]=z,e[56]=M,e[57]=W):W=e[57],W}),gs=o.memo(s=>{const e=be.c(11),{changedFiles:i,selectedFile:a,onSelectFile:d}=s,{t:f}=we();if(i.length===0)return null;let p;if(e[0]!==i||e[1]!==d||e[2]!==a||e[3]!==f){let u;e[5]!==d||e[6]!==a||e[7]!==f?(u=m=>{const x=Tt(m),c=a===m.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>d(m.path),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",c?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(Vt,{filePath:m.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:x.color},title:f(x.descriptionKey),"aria-label":f(x.descriptionKey),children:x.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:m.path,children:m.path}),Mt(m.insertions,m.deletions)]})},m.path)},e[5]=d,e[6]=a,e[7]=f,e[8]=u):u=e[8],p=i.map(u),e[0]=i,e[1]=d,e[2]=a,e[3]=f,e[4]=p}else p=e[4];let g;return e[9]!==p?(g=n.jsx(it,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:p})}),e[9]=p,e[10]=g):g=e[10],g}),xs=o.memo(s=>{const e=be.c(20),{filePath:i,diff:a,renderSideBySide:d}=s,{t:f}=we(),p=a.original.length>0,g=a.modified.length>0,u=d?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",m=d?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={contain:"layout"},e[0]=x):x=e[0];let c;e[1]!==a.original||e[2]!==i||e[3]!==p||e[4]!==m||e[5]!==d||e[6]!==f?(c=p&&n.jsxs("div",{className:m,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),n.jsx("img",{src:a.original,alt:f("diffView.image.originalAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=a.original,e[2]=i,e[3]=p,e[4]=m,e[5]=d,e[6]=f,e[7]=c):c=e[7];let v;e[8]!==a.modified||e[9]!==i||e[10]!==g||e[11]!==p||e[12]!==m||e[13]!==d||e[14]!==f?(v=g&&n.jsxs("div",{className:m,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(p?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:a.modified,alt:f("diffView.image.modifiedAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=a.modified,e[9]=i,e[10]=g,e[11]=p,e[12]=m,e[13]=d,e[14]=f,e[15]=v):v=e[15];let S;return e[16]!==u||e[17]!==c||e[18]!==v?(S=n.jsx("div",{className:"w-full overflow-auto p-4",style:x,children:n.jsxs("div",{className:u,children:[c,v]})}),e[16]=u,e[17]=c,e[18]=v,e[19]=S):S=e[19],S}),bs=o.memo(s=>{const e=be.c(16),{filePath:i,diff:a,renderSideBySide:d,wrapLines:f}=s;let p;e[0]!==i?(p=Bn(i)||"text",e[0]=i,e[1]=p):p=e[1];const g=p;if(a.isBinary){let x;return e[2]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(as,{}),e[2]=x):x=e[2],x}if(Be(i)){let x;return e[3]!==a||e[4]!==i||e[5]!==d?(x=n.jsx(xs,{filePath:i,diff:a,renderSideBySide:d}),e[3]=a,e[4]=i,e[5]=d,e[6]=x):x=e[6],x}let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u={contain:"layout"},e[7]=u):u=e[7];let m;return e[8]!==a.fileDiff||e[9]!==a.modified||e[10]!==a.original||e[11]!==i||e[12]!==g||e[13]!==d||e[14]!==f?(m=n.jsx("div",{className:"w-full",style:u,children:n.jsx(On,{original:a.original,modified:a.modified,fileDiff:a.fileDiff,language:g,fileName:i,renderSideBySide:d,wrapLines:f,layout:"inline"})}),e[8]=a.fileDiff,e[9]=a.modified,e[10]=a.original,e[11]=i,e[12]=g,e[13]=d,e[14]=f,e[15]=m):m=e[15],m}),ws=o.memo(s=>{const e=be.c(7),{filePath:i,staged:a,busyAction:d,disabled:f,onAction:p}=s,{t:g}=we();let u;return e[0]!==d||e[1]!==f||e[2]!==i||e[3]!==p||e[4]!==a||e[5]!==g?(u=n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:a?n.jsx(rt,{label:g("gitView.changes.unstageFileAria",{path:i}),icon:"arrow-go-back",loading:d==="unstage",disabled:f,onClick:()=>p("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx(rt,{label:g("gitView.changes.revertFileAria",{path:i}),icon:"arrow-go-back",loading:d==="discard",disabled:f,tone:"failure",onClick:()=>p("discard")}),n.jsx(rt,{label:g("gitView.changes.stageFileAria",{path:i}),icon:"add",loading:d==="stage",disabled:f,tone:"success",onClick:()=>p("stage")})]})}),e[0]=d,e[1]=f,e[2]=i,e[3]=p,e[4]=a,e[5]=g,e[6]=u):u=e[6],u}),rt=s=>{const e=be.c(14),{label:i,icon:a,loading:d,disabled:f,tone:p,onClick:g}=s,u=p==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",m=p==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]";let x;e[0]!==u||e[1]!==m?(x=le("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",u,m),e[0]=u,e[1]=m,e[2]=x):x=e[2];let c;e[3]!==g?(c=O=>{O.stopPropagation(),g()},e[3]=g,e[4]=c):c=e[4];let v;e[5]!==a||e[6]!==d?(v=d?n.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(A,{name:a,className:a==="add"?"size-4":"size-3.5"}),e[5]=a,e[6]=d,e[7]=v):v=e[7];let S;return e[8]!==f||e[9]!==i||e[10]!==x||e[11]!==c||e[12]!==v?(S=n.jsx(me,{variant:"ghost",size:"sm",className:x,disabled:f,title:i,"aria-label":i,onClick:c,children:v}),e[8]=f,e[9]=i,e[10]=x,e[11]=c,e[12]=v,e[13]=S):S=e[13],S},ys=o.memo(({directory:s,file:e,layout:i,wrapLines:a,isSelected:d,isExpanded:f,isMounted:p,onSelect:g,onExpandedChange:u,registerSectionRef:m,showOpenInEditorAction:x=!1,isOpeningInEditor:c=!1,onOpenInEditor:v,staged:S=!1,loadFullFiles:O=!1,initialDiffData:T=null,readOnlyActions:ne=!1})=>{const{t:y}=we(),{git:V}=Et(),M=ae(o.useCallback(w=>w.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),q=ae(w=>w.setDiff),X=ae(w=>w.fetchStatus),se=te(w=>w.setDiffFileLayout),[J,Y]=o.useState(0),[C,_]=o.useState(null),[re,L]=o.useState(!1),[G,$]=o.useState(null),[E,K]=o.useState(!1),[Q,z]=o.useState(null),[W,ie]=o.useState(null),ce=o.useRef(null),Ce=o.useRef(null),pe=o.useMemo(()=>Tt(e),[e]),Ve=i==="side-by-side",ye=O?"full":"patch",he=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Z=o.useMemo(()=>T||(S?W:Q||(M?{original:M.original,modified:M.modified,isBinary:M.isBinary,contextMode:"full"}:null)),[M,T,Q,S,W]),De=Z?.contextMode===ye,b=o.useCallback(w=>{Ce.current=w,m(e.path,w)},[e.path,m]),ge=o.useCallback(w=>{u(e.path,w)},[e.path,u]),ue=o.useCallback(()=>{g(e.path)},[e.path,g]);o.useEffect(()=>{S?ie(null):z(null),_(null),ce.current=null},[he,S]),o.useEffect(()=>{if(!f||!p)return;if(!s||T||Z&&De){ce.current=null,L(!1);return}const w=`${s}::${e.path}::${S?"staged":"unstaged"}::${he}::${ye}::${J}`;if(ce.current===w)return;ce.current=w,_(null),L(!0);let D=!1;const de=at(),Le=O?ns:ss,Te=Be(e.path)?V.getGitFileDiff(s,{path:e.path,staged:S}):V.getGitDiff(s,{path:e.path,staged:S,contextLines:Le}),Me=ts,_e=new Promise((B,H)=>{setTimeout(()=>H(new Error(`Timed out after ${Me}ms`)),Me)});return Promise.race([Te,_e]).then(B=>{if(!D){if("diff"in B){const H=ot(e.path,B.diff,ye);S?ie(H):z(H)}else{const H={original:B.original??"",modified:B.modified??"",isBinary:B.isBinary,contextMode:"full"};S?ie(H):q(s,e.path,H,de)}L(!1)}}).catch(B=>{if(D)return;const H=B instanceof Error?B.message:String(B);_(H),L(!1)}),()=>{D=!0,ce.current===w&&(ce.current=null)}},[ye,Z,De,J,s,e.path,he,V,T,f,p,O,q,S]);const Re=o.useCallback(()=>{ge(!f),ue()},[ge,ue,f]),fe=o.useCallback(async w=>{if(!(!s||G!==null)){$(w);try{w==="stage"?await V.stageGitFile(s,e.path):w==="unstage"?await V.unstageGitFile(s,e.path):await V.revertGitFile(s,e.path,{scope:"working"}),Y(D=>D+1),await X(s,V)}catch(D){const de=w==="unstage"?"gitView.toast.unstageFileFailed":w==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.revertFailed";Ke.error(D instanceof Error?D.message:y(de))}finally{$(D=>D===w?null:D)}}},[s,X,e.path,G,V,y]);return n.jsxs("div",{ref:b,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:Re,onKeyDown:w=>{w.target===w.currentTarget&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),Re())},className:le("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",d?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?n.jsx(A,{name:"arrow-down-s",className:"size-4"}):n.jsx(A,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:pe.color},title:y(pe.descriptionKey),"aria-label":y(pe.descriptionKey),children:pe.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Vt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const w=e.path.lastIndexOf("/");if(w===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const D=e.path.slice(0,w),de=e.path.slice(w+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:D}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:de})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Mt(e.insertions,e.deletions),x&&v?n.jsx(me,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:y("diffView.actions.openFileInEditorAtChange"),onClick:w=>{w.stopPropagation(),v(e.path,Z)},disabled:c,children:c?n.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(A,{name:"edit",className:"size-3.5"})}):null,n.jsx(Bt,{mode:Ve?"side-by-side":"unified",onModeChange:w=>{const D=w==="side-by-side"?"side-by-side":"inline";se(e.path,D)},className:"opacity-70"})]})]})}),f&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!p&&!C?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,C?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Y(w=>w+1),children:y("diffView.actions.retry")})]}):null,p&&re&&!Z&&!C?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),y("diffView.state.loadingDiff")]}):null,p&&Z&&!E&&e.insertions+e.deletions>Ft?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:y("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>K(!0),children:y("diffView.actions.renderAnyway")})]}):null,p&&Z&&(E||e.insertions+e.deletions<=Ft)?n.jsxs(n.Fragment,{children:[n.jsx(bs,{filePath:e.path,diff:Z,renderSideBySide:Ve,wrapLines:a}),n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:ne?null:n.jsx(ws,{filePath:e.path,staged:S,busyAction:G,disabled:G!==null,onAction:fe})})})]}):null]})]})}),Mi=({hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,showOpenInEditorAction:a=!1,diffScope:d="all",onDiffScopeChange:f,targetFilePath:p=null,flushContent:g=!1})=>{const{t:u}=we(),{git:m,files:x}=Et(),c=hn(),v=te(t=>t.openContextSurface),S=zn(t=>t.requestSource),{screenWidth:O,isMobile:T}=gn(),ne=xn(c??null),y=bn(c??null),V=wn(c??null),M=ae(t=>t.setActiveDirectory),q=ae(t=>t.ensureStatus),X=ae(t=>t.fetchStatus),se=ae(t=>t.fetchBranches),J=ae(t=>t.clearDiffCache),Y=ae(t=>t.setDiff),[C,_]=o.useState(null),[re,L]=o.useState(!1),[G,$]=o.useState(null),[E,K]=o.useState(()=>new Set),[Q,z]=o.useState(()=>new Set),[W,ie]=o.useState(!1),[ce,Ce]=o.useState(0),[pe,Ve]=o.useState(()=>new Map),[ye,he]=o.useState(!1),[Z,De]=o.useState(!1),[b,ge]=o.useState(d);o.useEffect(()=>{ge(d)},[d]);const ue=te(t=>t.pendingDiffFile),Re=te(t=>t.pendingDiffStaged),fe=te(t=>t.pendingDiffScope),w=te(t=>t.setPendingDiffFile),D=te(t=>t.diffLayoutPreference),de=te(t=>t.diffFileLayout),Le=te(t=>t.setDiffFileLayout),Te=te(t=>t.diffWrapLines),Me=te(t=>t.setDiffWrapLines),_e=te(t=>t.openContextFileAtLine),B=vt(t=>t.currentSessionId),H=yn(B??"",c??void 0),He=Te,Ue=b==="staged"?!0:b==="working"?!1:null,Ie=Ue??re,qe=T||O<=768,_t=!!B&&b!=="turn"&&!qe&&!Ge(),It=b!=="turn"&&!qe&&!Ge(),Ot=!s&&!qe&&O>=1024,ve=o.useRef(null),Ae=o.useRef(new Map),xe=o.useRef(null),P=o.useRef(null),je=o.useRef(!1),Se=o.useRef(null),lt=o.useRef(null),Xe=o.useRef(null),Je=o.useRef(null),ct=o.useCallback(()=>{const t=ve.current;if(!t)return null;const r=t.getBoundingClientRect().top,l=[];for(const[h,j]of Ae.current)j&&l.push({path:h,top:j.getBoundingClientRect().top});return St(r,l)},[]),Ne=o.useCallback(()=>{xe.current=null,je.current=!1,$(null),P.current!==null&&(window.cancelAnimationFrame(P.current),P.current=null)},[]),Fe=o.useCallback(t=>{K(r=>{if(r.has(t))return r;const l=new Set(r);return l.add(t),l})},[]),Ee=o.useMemo(()=>{for(let t=H.length-1;t>=0;t-=1){const r=H[t];if(r.role==="user")return ms(r.summary?.diffs)}return[]},[H]),zt=o.useMemo(()=>{const t=new Map;for(const r of Ee)if(r.file){if(typeof r.patch=="string"){t.set(r.file,ot(r.file,r.patch,"patch"));continue}t.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return t},[Ee]),Pt=o.useMemo(()=>y?.files?y.files.filter(Dt).length:0,[y]),Gt=o.useMemo(()=>y?.files?y.files.filter(Ct).length:0,[y]),$t=Ee.length,k=y?.current??null,ke=ae(t=>c?t.directories.get(c)?.branches??null:null),Kt=ae(t=>c?t.directories.get(c)?.isLoadingBranches??!1:!1),Wt=o.useCallback(()=>{c&&se(c,m)},[c,se,m]),Ht=Yn(c??null,ne!==!1,Kt,!!ke,Wt,os),ut=o.useMemo(()=>{const t=y?.tracking?.trim().split("/")[0];return(t&&ke?.defaultBranches?.[t])??ke?.defaultBranches?.origin??null},[ke,y?.tracking]),Ye=!Ge()&&Un(k,ut),Ut=y!==null,ft=Ge()||Ht||qn(k,ut,Ut,ke!==null),qt=jt(t=>t.setOverride),Xt=jt(o.useCallback(t=>c&&k?t.overrides[We(c,k)]??null:null,[k,c])),[Jt,Qe]=o.useState(null),[Yt,Ze]=o.useState(!1),[dt,Qt]=o.useState("");o.useEffect(()=>{const t=Xn(b,!ft);t!==b&&(ge(t),t==="working"&&f?.("working"))},[b,ft,f]),o.useEffect(()=>{if(!Ye||!c||!k){Qe(null),Ze(!1);return}let t=!1;return Ze(!1),vn(c,k).then(r=>{t||Qe(r.base)}).catch(()=>{t||Qe(null)}).finally(()=>{t||Ze(!0)}),()=>{t=!0}},[k,c,Ye]);const oe=Xt??Jt,[Oe,mt]=o.useState(null),[pt,ht]=o.useState(null),ze=o.useRef(0),et=o.useCallback(()=>{if(!c||!k||!oe)return;const t=ze.current+1;ze.current=t,mt(null),ht(null),jn(c,{base:oe,head:k}).then(r=>{ze.current===t&&mt(r)}).catch(r=>{ze.current===t&&ht(r instanceof Error?r.message:u("diffView.branch.loadError"))})},[oe,k,c,u]);o.useEffect(()=>{b==="branch"&&et()},[b,et]);const gt=b==="branch"&&c&&k&&oe?Jn(c,oe,k):null,Zt=o.useMemo(()=>b==="branch"?Array.from(E).sort().join("\0"):"",[b,E]),en=o.useCallback(t=>!c||!oe||!k?Promise.reject(new Error("branch range is unavailable")):Sn(c,{base:oe,head:k,path:t}).then(r=>ot(t,r.diff,"patch")),[oe,k,c]),tn=Qn(gt,Zt,gt?en:null,is),nn=Oe?.length??null,N=o.useMemo(()=>{if(b==="branch")return(Oe??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,h)=>l.path.localeCompare(h.path));if(b==="turn")return Ee.map(l=>({path:l.file??"",index:"",working_dir:ps(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,h)=>l.path.localeCompare(h.path));if(!y?.files)return[];const t=y.diffStats??{},r=b==="staged"?Ct:b==="working"?Dt:()=>!0;return y.files.filter(r).map(l=>({...l,insertions:t[l.path]?.insertions??0,deletions:t[l.path]?.deletions??0,isNew:us(l)})).sort((l,h)=>l.path.localeCompare(h.path))},[b,Oe,Ee,y]),tt=o.useMemo(()=>N.map(t=>t.path).join("\0"),[N]);o.useEffect(()=>{const t=tt?tt.split("\0"):[],r=new Set(t),l=`${c??""}:${b}:${e?"collapsed":"default"}`,h=lt.current!==l;lt.current=l,K(j=>{if(h){const R=e?0:rs(t.length);return new Set(t.slice(0,R))}let I=!1;const F=new Set;for(const R of j){if(!r.has(R)){I=!0;continue}F.add(R)}return I?F:j}),z(j=>{if(h)return new Set;let I=!1;const F=new Set;for(const R of j){if(!r.has(R)){I=!0;continue}F.add(R)}return I?F:j})},[b,tt,c,e]);const xt=o.useCallback(()=>{Se.current=null;const t=ve.current;if(!t)return;const r=t.getBoundingClientRect(),l=r.top-kt,h=r.bottom+kt,j={},I=[];for(const[F,R]of Ae.current){if(!R)continue;const U=R.getBoundingClientRect();I.push({path:F,top:U.top}),E.has(F)&&(U.bottom<l||U.top>h||(j[F]=!0))}Xe.current=St(r.top,I),z(F=>{let R=!1;const U=new Set(F);for(const yt of Object.keys(j))U.has(yt)||(U.add(yt),R=!0);return R?U:F})},[E]),ee=o.useCallback(()=>{typeof window>"u"||Se.current===null&&(Se.current=window.requestAnimationFrame(xt))},[xt]);o.useEffect(()=>{const t=ve.current;if(t)return ee(),t.addEventListener("scroll",ee,{passive:!0}),window.addEventListener("resize",ee),()=>{t.removeEventListener("scroll",ee),window.removeEventListener("resize",ee),Se.current!==null&&(window.cancelAnimationFrame(Se.current),Se.current=null)}},[N,E,ee]);const nt=o.useCallback(t=>{const r=de[t.path];if(r)return r;if(D==="inline")return"inline";if(D==="side-by-side")return"side-by-side";const l=O<es;return t.isNew||l?"inline":"side-by-side"},[de,D,O]),bt=o.useMemo(()=>N.length===0?null:N.every(t=>nt(t)==="side-by-side")?"side-by-side":"inline",[N,nt]);o.useEffect(()=>{c&&(M(c),q(c,m))},[c,M,q,m]),o.useEffect(()=>{if(c)return Nn.onGitRefreshHint(t=>{Rt(t.directory)===Rt(c)&&(t.paths?.length&&(Je.current=ct()??Xe.current,J(c,t.paths),Ve(r=>{const l=new Map(r);for(const h of t.paths??[])l.set(h,(l.get(h)??0)+1);return l})),X(c,m,{silent:!0}))})},[ct,J,c,X,m]),o.useLayoutEffect(()=>{const t=Je.current;if(!t)return;Je.current=null;const r=ve.current,l=Ae.current.get(t.path);if(!r||!l)return;const h=r.getBoundingClientRect().top,j=l.getBoundingClientRect().top-h;r.scrollTop=Zn(r.scrollTop,t.topOffset,j,r.scrollHeight-r.clientHeight),Xe.current=t},[pe]),o.useEffect(()=>{b!=="all"&&!fe||ue&&(fe&&ge(fe),_(ue),L(fe==="staged"||!fe&&Re),w(null),je.current=!0,xe.current=ue,Fe(ue),Ce(t=>t+1))},[b,Fe,ue,fe,Re,w]),o.useEffect(()=>{if(b==="all")return;const t=p?.trim();t&&(_(t),L(b==="staged"),je.current=!0,xe.current=t,Fe(t),Ce(r=>r+1))},[b,Fe,p]),o.useEffect(()=>{if(!C)return;N.some(r=>r.path===C)||(_(null),L(!1))},[N,C]);const sn=o.useCallback((t,r)=>{const l=Ae.current;r?l.set(t,r):l.delete(t),ee()},[ee]),rn=o.useCallback((t,r)=>{Ne(),K(l=>{const h=l.has(t);if(r===h)return l;const j=new Set(l);return r?j.add(t):j.delete(t),j}),r||z(l=>{if(!l.has(t))return l;const h=new Set(l);return h.delete(t),h}),ee()},[Ne,ee]),on=o.useCallback(()=>{Ne(),K(t=>t.size>0?new Set:new Set(N.map(r=>r.path))),z(new Set),ee()},[Ne,N,ee]),an=o.useCallback(async t=>{if(!B)return;const r=vt.getState().getDirectoryForSession(B)||c||"";if(!r){Ke.error(u("diffView.reviewDialog.toast.noSessionDirectory"));return}De(!0);try{await Fn({originalSessionID:B,directory:r,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),he(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Ke.error(l instanceof Error?l.message:u("diffView.reviewDialog.toast.startFailed"))}finally{De(!1)}},[B,c,u]),Pe=o.useCallback(t=>{const r=Ae.current.get(t),l=ve.current;if(!r||!l)return!1;const h=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+h,behavior:"auto"}),!0},[]);o.useEffect(()=>{if(!xe.current)return;let r=0;const l=20;let h=!1;const j=(F=!0)=>{h||(h=!0,xe.current=null,je.current=!1,F&&$(null),P.current!==null&&(window.cancelAnimationFrame(P.current),P.current=null))},I=()=>{if(h){P.current=null;return}const F=xe.current;if(!F){j(),P.current=null;return}if(!Pe(F)){r+=1,r<l?P.current=window.requestAnimationFrame(I):(j(),P.current=null);return}if(i&&je.current){$(F),j(!1);return}j()};return P.current=window.requestAnimationFrame(I),()=>{h=!0,P.current!==null&&(window.cancelAnimationFrame(P.current),P.current=null)}},[i,ce,Pe]);const ln=o.useCallback(t=>{},[]),st=o.useCallback(t=>{Ne(),_(t),L(!1),je.current=!0,xe.current=t,Fe(t),Ce(r=>r+1),Pe(t)},[Ne,Fe,Pe]);o.useEffect(()=>{const t=r=>{if(!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const h=r.key==="ArrowDown"?1:-1,j=C?N.findIndex(R=>R.path===C):-1,I=j===-1?h>0?0:N.length-1:j+h,F=N[I];F&&(r.preventDefault(),st(F.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[N,C,st]);const cn=o.useCallback(t=>{const r=t==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{Le(l.path,r)})},[N,Le]),[un,wt]=o.useState(null),fn=o.useCallback(async(t,r)=>{if(!c||!t)return;wt(t);const l=at();try{let h=null;if(r?.patch&&!r.isBinary&&!Be(t)?h=Nt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Be(t)&&(h=At(r.original,r.modified)),h===null)try{const U=await m.getGitDiff(c,{path:t,staged:Ie,contextLines:3});h=Nt(U.diff)}catch{h=null}let j=r;if(h===null||!j){const U=await m.getGitFileDiff(c,{path:t,staged:Ie});j={original:U.original??"",modified:U.modified??"",isBinary:U.isBinary},Ie||Y(c,t,j,l)}const I=h??(j.isBinary||Be(t)?1:At(j.original,j.modified)),F=fs(c,t),R=await Pn(x,F,{directory:c});if(!R.ok){Ke.error(Gn(R.reason));return}_e(c,F,I,1)}finally{wt(h=>h===t?null:h)}},[Ie,c,x,m,_e,Y]),dn=()=>{if(!c)return null;const t=r=>Ue!==null?Ue:re&&r===C;return n.jsxs("div",{className:le("flex min-w-0 flex-1 min-h-0 h-full",g?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Ot&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:u("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),n.jsx(gs,{changedFiles:N,selectedFile:null,onSelectFile:st})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(it,{ref:ve,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>n.jsx(ys,{directory:c,file:r,layout:nt(r),wrapLines:He,isSelected:!1,isExpanded:E.has(r.path),isMounted:Q.has(r.path)||r.path===G,onSelect:ln,onExpandedChange:rn,registerSectionRef:sn,showOpenInEditorAction:a&&b!=="turn",isOpeningInEditor:un===r.path,onOpenInEditor:(l,h)=>{fn(l,h)},staged:t(r.path),loadFullFiles:W,readOnlyActions:b==="branch",initialDiffData:b==="turn"?zt.get(r.path)??null:b==="branch"?tn.get(r.path)??null:null},`${r.path}:${pe.get(r.path)??0}`))})})})]})},mn=()=>{if(!c)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.selectSessionDirectory")});if(b!=="turn"&&V&&!y)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingRepositoryStatus")]});if(b!=="turn"&&ne===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.notGitRepository")});if(b==="branch"){if(!Yt)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.resolvingBase")]});if(!oe){const t=(ke?.all??[]).map(l=>l.replace(/^remotes\//,"")).filter(l=>l!==k&&!l.endsWith(`/${k}`)).sort(),r=En(t,dt,l=>[l]);return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(A,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:u("diffView.branch.noBaseDescription")}),n.jsx("input",{type:"text",value:dt,onChange:l=>Qt(l.target.value),placeholder:u("gitView.branch.searchPlaceholder"),"aria-label":u("gitView.branch.searchPlaceholder"),className:"w-full max-w-sm rounded-md border border-border/60 bg-[var(--surface-elevated)] px-2.5 py-1.5 typography-meta text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"}),n.jsx(it,{outerClassName:"max-h-48 w-full max-w-sm min-h-0",className:"px-1 py-1",children:r.length===0?n.jsx("div",{className:"px-2 py-3 typography-meta text-muted-foreground",children:u("gitView.branch.empty")}):n.jsx("div",{className:"flex flex-col gap-0.5",children:r.map(l=>n.jsxs("button",{type:"button",onClick:()=>c&&k&&qt(c,k,l),className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[n.jsx(A,{name:"git-branch",className:"size-3.5 text-primary"}),n.jsx("span",{className:"truncate typography-ui-label text-foreground",title:l,children:l})]},l))})})]})}if(pt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:pt}),n.jsx(me,{variant:"outline",size:"sm",onClick:()=>et(),children:u("diffView.actions.retry")})]});if(Oe===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.loadingFiles")]})}return N.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:b==="turn"?u("diffView.state.noLastTurnChanges"):b==="branch"&&oe?u("diffView.branch.empty",{base:oe}):u("diffView.state.cleanWorkingTree")}):dn()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[!T&&(b==="working"||b==="staged"||b==="turn"||b==="branch"?n.jsx(hs,{scope:b,workingCount:Pt,stagedCount:Gt,turnCount:$t,branchCount:nn,showBranchOption:Ye,onScopeChange:t=>{ge(t),f?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:V&&!y?u("diffView.state.loadingChanges"):N.length===1?u("diffView.summary.changedFilesSingle",{count:N.length}):u("diffView.summary.changedFilesPlural",{count:N.length})})})),N.length>0&&n.jsxs(me,{variant:"ghost",size:"sm",onClick:on,className:le("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll"),children:[n.jsx(A,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll")})]}),N.length>0&&_t&&n.jsxs(me,{variant:"default",size:"sm",onClick:()=>he(!0),disabled:Z,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":u("diffView.actions.reviewAria"),children:[Z?n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(A,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:u("diffView.actions.review")})]}),N.length>0&&It&&n.jsxs(me,{variant:"outline",size:"sm",onClick:()=>{const t=c??"";S(t,{kind:"working-tree",scope:b==="staged"||b==="working"?b:"all"}),v(t,"walkthrough")},className:le("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",$n),"aria-label":u("walkthrough.action.open"),children:[n.jsx(A,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}),N.length>0&&n.jsxs(kn,{children:[n.jsx(Cn,{asChild:!0,children:n.jsx(me,{variant:"ghost",size:"sm",onClick:()=>ie(t=>!t),"aria-pressed":W,"aria-label":u(W?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:le("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",W&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(A,{name:"file-download",className:"size-4"})})}),n.jsx(Dn,{children:n.jsx("p",{children:u(W?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&n.jsx(me,{variant:"ghost",size:"sm",onClick:()=>Me(!Te),className:le("h-5 w-5 p-0 transition-opacity",He?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:u(He?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(A,{name:"text-wrap",className:"size-4"})}),bt&&n.jsx(Bt,{mode:bt==="side-by-side"?"side-by-side":"unified",onModeChange:cn})]}),n.jsx(Rn,{open:ye,onOpenChange:he,projectDirectory:c??null,submitting:Z,onConfirm:an}),mn()]})};export{Mi as DiffView};