@vantran-se/openchamber-web 2.0.2 → 2.0.4

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 (93) hide show
  1. package/README.md +20 -28
  2. package/bin/cli.js +3 -1
  3. package/bin/cli.test.js +13 -4
  4. package/bin/lib/DOCUMENTATION.md +4 -1
  5. package/bin/lib/commands-serve.js +9 -0
  6. package/dist/assets/{CodeMirrorCommentWidgets-B82Oye3V.js → CodeMirrorCommentWidgets-DZF8ntaq.js} +1 -1
  7. package/dist/assets/{DiffView-DJLmWn6Z.js → DiffView-D2p4Ar0H.js} +1 -1
  8. package/dist/assets/{FilesView-DjksmZRo.js → FilesView-BeTtbsip.js} +1 -1
  9. package/dist/assets/{GitView-DiUsUIgr.js → GitView-DwQwqDvu.js} +1 -1
  10. package/dist/assets/{GuestAttachDialog-CYwWYLr3.js → GuestAttachDialog-CoXM0gh_.js} +1 -1
  11. package/dist/assets/{GuestSurfacePane-CmctyRI4.js → GuestSurfacePane-DIJvkkM-.js} +1 -1
  12. package/dist/assets/{JsonTreeView-DOHHcbgJ.js → JsonTreeView-Cq_27v0y.js} +1 -1
  13. package/dist/assets/{LinearIssuesView-DaqnylcV.js → LinearIssuesView-CsSSRMhn.js} +1 -1
  14. package/dist/assets/{MarkdownImageGallery-HJNvWt7L.js → MarkdownImageGallery-CY0dWTaE.js} +1 -1
  15. package/dist/assets/{MarkdownRendererImpl-nDZRGg2I.js → MarkdownRendererImpl-ILdXzLrt.js} +1 -1
  16. package/dist/assets/{OnboardingScreen-C2B5Bsof.js → OnboardingScreen-ClatMQAX.js} +1 -1
  17. package/dist/assets/{PatchDiff-C4FLBjpt.js → PatchDiff-DOwlrIK9.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-C_1S9c9n.js → PierreDiffViewer-CrcGqqD_.js} +1 -1
  19. package/dist/assets/{PlanView-_eZvb-G5.js → PlanView-BGLsMgQk.js} +1 -1
  20. package/dist/assets/{PluginPane-sM8fcZIV.js → PluginPane-B39JEUL8.js} +1 -1
  21. package/dist/assets/{SettingsView-BRfr46hb.js → SettingsView-13B2_G-A.js} +1 -1
  22. package/dist/assets/{SettingsWindow-CcUDwQHg.js → SettingsWindow-B0BAy-f9.js} +1 -1
  23. package/dist/assets/{SubmoduleDiffSummary-CrN1ZGwl.js → SubmoduleDiffSummary-fcdDzCSW.js} +1 -1
  24. package/dist/assets/{ToolOutputDialog-Cij4jI09.js → ToolOutputDialog-B7xaUz2H.js} +1 -1
  25. package/dist/assets/{ToolPartDiffPreview-BXzwQ-JY.js → ToolPartDiffPreview-CkWCaUmZ.js} +1 -1
  26. package/dist/assets/{VirtualizedFileDiff-DSWTLJNH.js → VirtualizedFileDiff-DONC4eI2.js} +1 -1
  27. package/dist/assets/{WalkthroughView-CpUUgY8H.js → WalkthroughView-CXDImOXW.js} +1 -1
  28. package/dist/assets/{appThemeRegistry-B5tHTkR8.js → appThemeRegistry-Br2TLSlb.js} +1 -1
  29. package/dist/assets/{commitAndPush-D7D8qV8p.js → commitAndPush-CcI4ol7c.js} +1 -1
  30. package/dist/assets/{computeVirtualFileMetrics-cq9uQ30i.js → computeVirtualFileMetrics-_-20umCs.js} +1 -1
  31. package/dist/assets/{de-CUO1-KqF.js → de-BtYnUgII.js} +1 -1
  32. package/dist/assets/{es-BlbC6sGJ.js → es-crP5qPye.js} +1 -1
  33. package/dist/assets/{fr-D2nwe_0W.js → fr-CLSRuALk.js} +1 -1
  34. package/dist/assets/{index-BQOoYIOu.js → index-OKDYjcMF.js} +1 -1
  35. package/dist/assets/{isDiffPlainText-D0obJ2p8.js → isDiffPlainText-D77M6q1f.js} +1 -1
  36. package/dist/assets/{isFilePlainText-DB3_rjyW.js → isFilePlainText-C54B4Mns.js} +1 -1
  37. package/dist/assets/{ja-CA7vnDsZ.js → ja-SZ1-ucLV.js} +1 -1
  38. package/dist/assets/{ko-Chy6a9l-.js → ko-HthbT_Ve.js} +1 -1
  39. package/dist/assets/{main-B9JFK3vF.js → main-BJklC7Cl.js} +4 -4
  40. package/dist/assets/{main-Bhiqnrhd.js → main-CGEvLMd2.js} +2 -2
  41. package/dist/assets/{markdownCore-tfqOFaBd.js → markdownCore-BzQuETm0.js} +1 -1
  42. package/dist/assets/{miniChat-B0UOL5zA.js → miniChat-BSxkRQLj.js} +2 -2
  43. package/dist/assets/{mobile-BJppFIEo.js → mobile-C5KRTNOB.js} +2 -2
  44. package/dist/assets/{patchFileDiff-Db6KuwCP.js → patchFileDiff-DGw2KryM.js} +1 -1
  45. package/dist/assets/{pl-CTR5A_1P.js → pl-C8eYfjL1.js} +1 -1
  46. package/dist/assets/{pt-BR-BE1O1KEx.js → pt-BR-cYOrZdxS.js} +1 -1
  47. package/dist/assets/{renderElectronMiniChatApp-Yz5sfoFh.js → renderElectronMiniChatApp-CnkAQV6o.js} +2 -2
  48. package/dist/assets/{renderMobileApp-QQ-yB8aY.js → renderMobileApp-CMxjwisj.js} +3 -3
  49. package/dist/assets/{runtimeEndpointReset-DKDdzRzm.js → runtimeEndpointReset-C45jrFq4.js} +3 -3
  50. package/dist/assets/{scheduledTasksApi-C5sCuNqf.js → scheduledTasksApi-CkK1F9s2.js} +1 -1
  51. package/dist/assets/{shikiHighlight-xURoo5t_.js → shikiHighlight-4O0ZM14D.js} +1 -1
  52. package/dist/assets/{textMateThemeFromAppTheme-BZLGuYTU.js → textMateThemeFromAppTheme-yNq7b0DZ.js} +1 -1
  53. package/dist/assets/{tr-Bh5vK6cW.js → tr-B4IQ5t-T.js} +1 -1
  54. package/dist/assets/{uk-CLDkZFy_.js → uk-DCoXG6ve.js} +1 -1
  55. package/dist/assets/{useAppFontEffects-BxrtCnfR.js → useAppFontEffects-Bzyszv2N.js} +48 -48
  56. package/dist/assets/{useInlineCommentController-CeXuR-SR.js → useInlineCommentController-zOf6ORAq.js} +1 -1
  57. package/dist/assets/{useRootScrollLock-DgWxezc1.js → useRootScrollLock-DCaZ4BWi.js} +2 -2
  58. package/dist/assets/{vendor-codemirror-language-data-DOuaQUZ0.js → vendor-codemirror-language-data-6cEFPNUR.js} +2 -2
  59. package/dist/assets/{web-components-63H1h21j.js → web-components-BEo4-ISu.js} +1 -1
  60. package/dist/assets/{zh-CN-DODgcmYj.js → zh-CN-BXBoxsFk.js} +1 -1
  61. package/dist/assets/{zh-TW-ByNfIwLA.js → zh-TW-C6oelpnL.js} +1 -1
  62. package/dist/index.html +1 -1
  63. package/dist/mini-chat.html +1 -1
  64. package/dist/mobile.html +1 -1
  65. package/package.json +1 -1
  66. package/server/index.d.ts +2 -0
  67. package/server/index.js +114 -52
  68. package/server/lib/agent-tool/DOCUMENTATION.md +47 -127
  69. package/server/lib/agent-tool/runtime.js +66 -47
  70. package/server/lib/agent-tool/runtime.test.js +2 -0
  71. package/server/lib/event-stream/DOCUMENTATION.md +2 -2
  72. package/server/lib/event-stream/global-hub.js +22 -6
  73. package/server/lib/event-stream/global-hub.test.js +93 -2
  74. package/server/lib/event-stream/rebind.test.js +1 -0
  75. package/server/lib/event-stream/runtime.js +1 -2
  76. package/server/lib/opencode/DOCUMENTATION.md +23 -23
  77. package/server/lib/opencode/lifecycle.js +126 -0
  78. package/server/lib/opencode/lifecycle.test.js +228 -1
  79. package/server/lib/opencode/network-runtime.js +16 -7
  80. package/server/lib/opencode/network-runtime.test.js +29 -1
  81. package/server/lib/opencode/proxy.js +15 -14
  82. package/server/lib/opencode/server-startup-runtime.js +25 -0
  83. package/server/lib/opencode/server-startup-runtime.test.js +67 -1
  84. package/server/lib/opencode/shared-service-runtime.js +155 -0
  85. package/server/lib/opencode/shared-service-runtime.test.js +180 -0
  86. package/server/lib/opencode/shutdown-runtime.js +11 -5
  87. package/server/lib/opencode/shutdown-runtime.test.js +77 -2
  88. package/server/lib/opencode/startup-pipeline-runtime.js +5 -4
  89. package/server/lib/opencode/startup-pipeline-runtime.test.js +18 -7
  90. package/server/lib/opencode/watcher.test.js +54 -0
  91. package/server/opencode-proxy.test.js +158 -0
  92. package/server/proxy-headers.js +8 -2
  93. package/server/proxy-headers.test.js +20 -0
package/README.md CHANGED
@@ -18,6 +18,17 @@ Or install manually: `bun add -g @openchamber/web` (or npm, pnpm, yarn).
18
18
 
19
19
  > **Prerequisites:** [OpenCode CLI](https://opencode.ai) installed, Node.js 22+.
20
20
 
21
+ Start OpenCode first, then OpenChamber in another terminal:
22
+
23
+ ```bash
24
+ opencode
25
+ openchamber
26
+ ```
27
+
28
+ Both clients use the same local OpenCode service, sessions, and live events. Normal local use does not require `opencode serve`, an OpenCode port, or skip-start configuration. Stopping OpenChamber Web leaves OpenCode, the TUI, and current work running.
29
+
30
+ Shared Web does not install OpenChamber managed tools. Those tools remain available in Electron Desktop's managed OpenCode child.
31
+
21
32
  ## Usage
22
33
 
23
34
  ```bash
@@ -41,20 +52,14 @@ openchamber connect-url --port 3000 # Add this server to OpenChamber Desktop
41
52
  openchamber connect-url --server http://host:3000 --qr
42
53
  openchamber connect-url --port 3000 --qr
43
54
  openchamber logs # Follow latest instance logs
44
- OPENCODE_PORT=4096 OPENCODE_SKIP_START=true openchamber # Connect to external OpenCode server
45
- OPENCODE_HOST=https://myhost:4096 OPENCODE_SKIP_START=true openchamber # Connect via custom host/HTTPS
46
- openchamber stop # Stop server
55
+ OPENCODE_HOST=https://myhost:4096 openchamber # Connect to an external OpenCode server
56
+ openchamber stop # Stop Web; OpenCode and the TUI keep running
47
57
  openchamber update # Update to latest version
48
58
  ```
49
59
 
50
60
  `startup enable` snapshots your current environment into the native service so startup behaves like you launched `openchamber` from the same shell. This preserves provider tokens, PATH, SSH agent settings, and other CLI auth/config env vars. Use `--no-env-snapshot` for a minimal service env.
51
61
 
52
- When OpenChamber launches the local OpenCode server, it also registers a native
53
- `openchamber` agent tool for project, session, and scheduled-task orchestration.
54
- The tool is not injected when connecting to an external OpenCode server.
55
- Behavior settings can optionally inject a managed system-prompt optimizer on
56
- the next OpenCode restart. It is disabled by default and is not available for
57
- external OpenCode servers.
62
+ Electron Desktop keeps its managed OpenCode child and environment-backed OpenChamber tools. Ordinary Web does not install or advertise those tools. An external endpoint selected with `OPENCODE_HOST` may have user-configured tools, but OpenChamber does not install or guarantee them.
58
63
 
59
64
  ### Tunnel behavior notes
60
65
 
@@ -101,35 +106,23 @@ Generating a client token does not automatically password-protect the hosted bro
101
106
  <summary>Connect to external OpenCode server</summary>
102
107
 
103
108
  ```bash
104
- OPENCODE_PORT=4096 OPENCODE_SKIP_START=true openchamber
105
- OPENCODE_HOST=https://myhost:4096 OPENCODE_SKIP_START=true openchamber
109
+ OPENCODE_HOST=https://myhost:4096 openchamber
106
110
  ```
107
111
 
112
+ `OPENCODE_HOST` overrides shared local discovery. Web treats that endpoint as externally owned: it connects API and event streams but never starts, stops, or restarts the endpoint. OpenChamber managed tools are not guaranteed there.
113
+
108
114
  | Variable | Description |
109
115
  |----------|-------------|
110
- | `OPENCODE_HOST` | Full base URL of external server (overrides `OPENCODE_PORT`) |
111
- | `OPENCODE_PORT` | Port of external server |
112
- | `OPENCODE_SKIP_START` | Skip starting embedded OpenCode server |
113
- | `OPENCHAMBER_OPENCODE_HOSTNAME` | Bind hostname for managed OpenCode server (default: `127.0.0.1`, use `0.0.0.0` for LAN/remote access — trusted networks only). Invalid values are rejected with an error and fall back to loopback |
114
- | `OPENCHAMBER_HOST` | Bind hostname for the OpenChamber web server (default: `127.0.0.1`; use `0.0.0.0` for LAN/remote access — trusted networks only) |
116
+ | `OPENCODE_HOST` | Full base URL of an externally owned OpenCode server |
117
+ | `OPENCHAMBER_HOST` | Bind hostname for the OpenChamber web server (default: `127.0.0.1`; use `0.0.0.0` for LAN/remote access on trusted networks) |
115
118
  | `OPENCHAMBER_VERBOSE_REQUEST_LOGS` | Set to `true` to log every HTTP request; disabled by default to keep user logs small |
116
119
  | `OPENCHAMBER_SKIP_API_COMPRESSION` | Set to `true` to disable gzip compression for `/api/*` responses |
117
- | `OPENCHAMBER_COMPRESS_API` | Set to `true` to force `/api/*` compression, or `false` to disable it. Desktop runtime disables API compression by default to reduce local sidecar CPU use |
120
+ | `OPENCHAMBER_COMPRESS_API` | Set to `true` to force `/api/*` compression, or `false` to disable it. Desktop disables API compression by default to reduce local sidecar CPU use |
118
121
  | `OPENCHAMBER_FS_UPLOAD_MAX_BYTES` | Maximum file upload size in bytes (default: 100 MiB) |
119
122
  | `OPENCHAMBER_TERMINAL_SHELL` | Preferred terminal shell executable used by the `Auto` setting before platform defaults |
120
123
 
121
124
  </details>
122
125
 
123
- <details>
124
- <summary>Bind managed OpenCode to LAN / Tailscale</summary>
125
-
126
- ```bash
127
- OPENCHAMBER_OPENCODE_HOSTNAME=0.0.0.0 openchamber --port 3000
128
- ```
129
-
130
- **Security note:** binding to `0.0.0.0` exposes the server on all network interfaces — use only on trusted networks and protect with firewall rules or `--ui-password`.
131
-
132
- </details>
133
126
 
134
127
  **Optional env vars:**
135
128
  ```yaml
@@ -214,7 +207,6 @@ After=opencode.service
214
207
  Type=simple
215
208
  ExecStart=openchamber serve --port 3000 --host 0.0.0.0 --ui-password your-password --foreground
216
209
  Environment="OPENCODE_HOST=http://localhost:4095"
217
- Environment="OPENCODE_SKIP_START=true"
218
210
  Restart=on-failure
219
211
  RestartSec=5
220
212
 
package/bin/cli.js CHANGED
@@ -414,7 +414,9 @@ if (isCliExecution) {
414
414
 
415
415
  main().catch((error) => {
416
416
  const message = error instanceof Error ? error.message : String(error);
417
- if (isJsonMode(activeCommandOptions)) {
417
+ if (error?.cliReported === true) {
418
+ process.exit(EXIT_CODE.GENERAL_ERROR);
419
+ } else if (isJsonMode(activeCommandOptions)) {
418
420
  printJson({
419
421
  status: 'error',
420
422
  error: {
package/bin/cli.test.js CHANGED
@@ -70,10 +70,10 @@ function createMockJsonResponse(body, ok = true) {
70
70
  };
71
71
  }
72
72
 
73
- async function captureStdout(fn) {
74
- const originalWrite = process.stdout.write;
73
+ async function captureStream(stream, fn) {
74
+ const originalWrite = stream.write;
75
75
  let output = '';
76
- process.stdout.write = (chunk, encoding, callback) => {
76
+ stream.write = (chunk, encoding, callback) => {
77
77
  output += Buffer.isBuffer(chunk) ? chunk.toString('utf8') : String(chunk);
78
78
  if (typeof encoding === 'function') encoding();
79
79
  if (typeof callback === 'function') callback();
@@ -83,10 +83,18 @@ async function captureStdout(fn) {
83
83
  await fn();
84
84
  return output;
85
85
  } finally {
86
- process.stdout.write = originalWrite;
86
+ stream.write = originalWrite;
87
87
  }
88
88
  }
89
89
 
90
+ async function captureStdout(fn) {
91
+ return captureStream(process.stdout, fn);
92
+ }
93
+
94
+ async function captureStderr(fn) {
95
+ return captureStream(process.stderr, fn);
96
+ }
97
+
90
98
  async function startMockOpenChamberServer(options = {}) {
91
99
  const runtime = options.runtime || 'web';
92
100
  const pid = Number.isFinite(options.pid) ? options.pid : null;
@@ -666,6 +674,7 @@ describe('cli API target resolution', () => {
666
674
  });
667
675
  });
668
676
 
677
+
669
678
  describe('network-exposed auth validation', () => {
670
679
  it('allows loopback without a UI password', () => {
671
680
  expect(() => assertAuthenticatedNetworkExposure({ host: '127.0.0.1' })).not.toThrow();
@@ -15,12 +15,15 @@ Command modules implement user-facing commands and preserve output contracts acr
15
15
 
16
16
  - `commands-serve.js`
17
17
  - Implements `openchamber serve`.
18
- - Owns OpenCode CLI checks, port resolution, log rotation, PID/instance registry writes, foreground/background server launch, startup summaries, and foreground shutdown behavior.
18
+ - Owns OpenCode CLI checks, port resolution, log rotation, PID and instance registry writes, foreground or background server launch, startup summaries, and foreground shutdown behavior.
19
+ - Ordinary Web connects to OpenCode's shared local service. Startup failures use the existing output adapter so JSON remains JSON-only, quiet output stays concise, and non-TTY mode never prompts.
19
20
 
20
21
  - `commands-lifecycle.js`
21
22
  - Implements `openchamber stop` and `openchamber restart`.
22
23
  - Owns lifecycle stop/restart semantics, desktop-managed port rejection, unmanaged instance shutdown attempts, PID/instance cleanup, and restart reuse of stored instance options.
23
24
 
25
+ Stopping Web shuts down the selected OpenChamber instance but leaves a `shared-local` or `explicit-external` OpenCode service running. OpenCode process teardown belongs only to the Desktop `managed-owned` runtime.
26
+
24
27
  - `commands-status.js`
25
28
  - Implements `openchamber status`.
26
29
  - Formats discovered instances and tunnel readiness/status for human, quiet, and JSON output.
@@ -311,6 +311,15 @@ async function serveCommand(options) {
311
311
  settled = true;
312
312
  clearTimeout(timeout);
313
313
  resolve(msg.port);
314
+ return;
315
+ }
316
+ if (msg && msg.type === 'openchamber:error') {
317
+ settled = true;
318
+ clearTimeout(timeout);
319
+ const error = new Error(msg.message || 'OpenChamber failed to start');
320
+ if (msg.code) error.code = msg.code;
321
+ if (msg.url) error.url = msg.url;
322
+ reject(error);
314
323
  }
315
324
  });
316
325
 
@@ -1 +1 @@
1
- import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-CeXuR-SR.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
1
+ import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-zOf6ORAq.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
@@ -1,4 +1,4 @@
1
- import{R as i,f as tt,j as n}from"./vendor-react-BUCujlKS.js";import{u as me,O as Fe,B as Ln,a as De,G as Mn}from"./index-CvLgnuNI.js";import{c as Tn,b as Bn,u as In,a as Pn,B as _n,C as On,P as Gt,h as zn,e as Kn,g as Gn,i as Hn,f as $n}from"./patchFileDiff-Db6KuwCP.js";import{c as qn,b as Wn,i as Un,u as Jn,a as Xn,d as Yn,S as Qn}from"./SubmoduleDiffSummary-CrN1ZGwl.js";import{f as qe,B as ke,I as z,h as Ae,_ as en,ai as Zn,K as ae,aj as es,bj as ts,J as ns,ak as ss,am as rs,z as Ht,k as is,d9 as tn,t as $e,kX as os,az as et,kM as nn,kY as as,aA as sn,gV as ls,ax as Ze,ay as cs,c8 as rn,at as us,av as ds,aw as fs,as as ms}from"./useAppFontEffects-BxrtCnfR.js";import{j as ps,f as hs}from"./runtimeEndpointReset-DKDdzRzm.js";import{P as gs}from"./PierreDiffViewer-C_1S9c9n.js";import{u as xs,v as ys,g as ws,W as bs}from"./main-B9JFK3vF.js";import{p as js}from"./VirtualizedFileDiff-DSWTLJNH.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.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-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.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-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-DOuaQUZ0.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"./GuestAttachDialog-CYwWYLr3.js";import"./PluginPane-sM8fcZIV.js";import"./web-components-63H1h21j.js";import"./computeVirtualFileMetrics-cq9uQ30i.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"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CeXuR-SR.js";import"./appThemeRegistry-B5tHTkR8.js";import"./textMateThemeFromAppTheme-BZLGuYTU.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-DgWxezc1.js";import"./scheduledTasksApi-C5sCuNqf.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./isDiffPlainText-D0obJ2p8.js";import"./vendor-diff-C3JhlQdm.js";const vs=i.memo(function(e){const s=tt.c(13),{index:c,staged:y,busyHunk:p,disabled:b,onAction:v}=e,{t:F}=qe();let l;s[0]!==y?(l=y?["unstage"]:["discard","stage"],s[0]=y,s[1]=l):l=s[1];const j=l;let N;s[2]===Symbol.for("react.memo_cache_sentinel")?(N={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=N):N=s[2];let f;s[3]!==j||s[4]!==p||s[5]!==b||s[6]!==c||s[7]!==v||s[8]!==F?(f=n.jsx("div",{className:"pointer-events-auto 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:j.map(w=>{const D=F(w==="stage"?"diffView.hunk.stageTitle":w==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:c+1}),_=p?.index===c&&p.action===w;return n.jsx(ke,{variant:"ghost",size:"xs",className:Ae("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",w==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",w==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:b||p!==null,title:D,"aria-label":D,onPointerDown:Ss,onClick:m=>{m.stopPropagation(),v(c,w)},children:n.jsx(z,{name:_?"loader-4":w==="stage"?"add":"arrow-go-back",className:Ae(w==="stage"?"size-4":"size-3.5",_&&"animate-spin")})},w)})}),s[3]=j,s[4]=p,s[5]=b,s[6]=c,s[7]=v,s[8]=F,s[9]=f):f=s[9];let V;return s[10]!==c||s[11]!==f?(V=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:N,"data-hunk-actions":c,children:f}),s[10]=c,s[11]=f,s[12]=V):V=s[12],V});function Ss(o){return o.stopPropagation()}const $t=(o,e)=>{if(e.length===0)return null;let s=null,c=null;for(const p of e)p.top<=o?(!s||p.top>s.top)&&(s=p):(!c||p.top<c.top)&&(c=p);const y=s??c;return y?{path:y.path,topOffset:y.top-o}:null},ks=(o,e,s,c)=>Math.min(Math.max(0,c),Math.max(0,o+s-e)),qt=o=>{if(!o)return null;const e=o.split(`
1
+ import{R as i,f as tt,j as n}from"./vendor-react-BUCujlKS.js";import{u as me,O as Fe,B as Ln,a as De,G as Mn}from"./index-CvLgnuNI.js";import{c as Tn,b as Bn,u as In,a as Pn,B as _n,C as On,P as Gt,h as zn,e as Kn,g as Gn,i as Hn,f as $n}from"./patchFileDiff-DGw2KryM.js";import{c as qn,b as Wn,i as Un,u as Jn,a as Xn,d as Yn,S as Qn}from"./SubmoduleDiffSummary-fcdDzCSW.js";import{f as qe,B as ke,I as z,h as Ae,_ as en,ai as Zn,K as ae,aj as es,bj as ts,J as ns,ak as ss,am as rs,z as Ht,k as is,d9 as tn,t as $e,kX as os,az as et,kM as nn,kY as as,aA as sn,gV as ls,ax as Ze,ay as cs,c8 as rn,at as us,av as ds,aw as fs,as as ms}from"./useAppFontEffects-Bzyszv2N.js";import{j as ps,f as hs}from"./runtimeEndpointReset-C45jrFq4.js";import{P as gs}from"./PierreDiffViewer-CrcGqqD_.js";import{u as xs,v as ys,g as ws,W as bs}from"./main-BJklC7Cl.js";import{p as js}from"./VirtualizedFileDiff-DONC4eI2.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.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-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.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-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-6cEFPNUR.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"./GuestAttachDialog-CoXM0gh_.js";import"./PluginPane-B39JEUL8.js";import"./web-components-BEo4-ISu.js";import"./computeVirtualFileMetrics-_-20umCs.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"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-zOf6ORAq.js";import"./appThemeRegistry-Br2TLSlb.js";import"./textMateThemeFromAppTheme-yNq7b0DZ.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-DCaZ4BWi.js";import"./scheduledTasksApi-CkK1F9s2.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./isDiffPlainText-D77M6q1f.js";import"./vendor-diff-C3JhlQdm.js";const vs=i.memo(function(e){const s=tt.c(13),{index:c,staged:y,busyHunk:p,disabled:b,onAction:v}=e,{t:F}=qe();let l;s[0]!==y?(l=y?["unstage"]:["discard","stage"],s[0]=y,s[1]=l):l=s[1];const j=l;let N;s[2]===Symbol.for("react.memo_cache_sentinel")?(N={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=N):N=s[2];let f;s[3]!==j||s[4]!==p||s[5]!==b||s[6]!==c||s[7]!==v||s[8]!==F?(f=n.jsx("div",{className:"pointer-events-auto 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:j.map(w=>{const D=F(w==="stage"?"diffView.hunk.stageTitle":w==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:c+1}),_=p?.index===c&&p.action===w;return n.jsx(ke,{variant:"ghost",size:"xs",className:Ae("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",w==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",w==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:b||p!==null,title:D,"aria-label":D,onPointerDown:Ss,onClick:m=>{m.stopPropagation(),v(c,w)},children:n.jsx(z,{name:_?"loader-4":w==="stage"?"add":"arrow-go-back",className:Ae(w==="stage"?"size-4":"size-3.5",_&&"animate-spin")})},w)})}),s[3]=j,s[4]=p,s[5]=b,s[6]=c,s[7]=v,s[8]=F,s[9]=f):f=s[9];let V;return s[10]!==c||s[11]!==f?(V=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:N,"data-hunk-actions":c,children:f}),s[10]=c,s[11]=f,s[12]=V):V=s[12],V});function Ss(o){return o.stopPropagation()}const $t=(o,e)=>{if(e.length===0)return null;let s=null,c=null;for(const p of e)p.top<=o?(!s||p.top>s.top)&&(s=p):(!c||p.top<c.top)&&(c=p);const y=s??c;return y?{path:y.path,topOffset:y.top-o}:null},ks=(o,e,s,c)=>Math.min(Math.max(0,c),Math.max(0,o+s-e)),qt=o=>{if(!o)return null;const e=o.split(`
2
2
  `);let s=null;for(const c of e){const y=c.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(y){const p=Number.parseInt(y[1]??"",10);s=Number.isFinite(p)&&p>=1?p:null;continue}if(s!==null){if(c.startsWith(" ")){s+=1;continue}if(c.startsWith("+"))return s;if(c.startsWith("-"))return Math.max(1,s)}}return null},Ns=1100,Cs=15e3,Wt=500,Ut=300,on=1e6,Ct=3,Rs=o=>o<=6?o:o<=12?6:o<=25?4:2,Jt={status:"loading"},Fs=3,Ds=i.memo(()=>{const o=tt.c(4),{t:e}=qe();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let c;return o[2]!==s?(c=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:s})}),o[2]=s,o[3]=c):c=o[3],c}),an={"?":{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"}},As=an.M,Es=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},ln=o=>{const e=Es(o);return an[e]??As},Vs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},Xt=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Yt=o=>!!o.working_dir?.trim()||o.index==="?",Ls=(o,e)=>ls(o,e),Qt=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Zt=(o,e)=>{const s=o.split(`
3
3
  `),c=e.split(`
4
4
  `),y=Math.min(s.length,c.length);for(let p=0;p<y;p+=1)if(s[p]!==c[p])return p+1;return c.length>s.length?s.length+1:s.length>c.length?Math.max(1,c.length):1},Ms=o=>o==="added"?"A":o==="deleted"?"D":"M",Rt=(o,e,s)=>Hn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:$n(o,e),contextMode:s},cn=(o,e,s)=>{const c=o??0,y=e??0;return!c&&!y?null:n.jsxs("span",{className:Ae("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[c?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",c]}):null,y?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",y]}):null]})},Ts=i.memo(o=>{const e=tt.c(68),{scope:s,workingCount:c,stagedCount:y,turnCount:p,branchCount:b,commitCount:v,prCount:F,showCommitOption:l,showBranchOption:j,onScopeChange:N}=o,{t:f}=qe(),[V,w]=i.useState(!1),D=s==="pr"?F??0:s==="staged"?y:s==="turn"?p:s==="branch"?b??0:s==="commit"?v??0:c;let _;e[0]!==s||e[1]!==f?(_=f(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=f,e[2]=_):_=e[2];const m=_;let be;e[3]!==f?(be=f("diffView.scope.selectorAria"),e[3]=f,e[4]=be):be=e[4];let Z;e[5]!==D?(Z=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",D]}),e[5]=D,e[6]=Z):Z=e[6];let ee;e[7]!==m||e[8]!==Z?(ee=n.jsxs("span",{className:"whitespace-nowrap",children:[m,Z]}),e[7]=m,e[8]=Z,e[9]=ee):ee=e[9];let Ne;e[10]===Symbol.for("react.memo_cache_sentinel")?(Ne=n.jsx(z,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=Ne):Ne=e[10];let q;e[11]!==be||e[12]!==ee?(q=n.jsx(us,{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":be,children:[ee,Ne]})}),e[11]=be,e[12]=ee,e[13]=q):q=e[13];let x;e[14]!==N?(x=H=>{(H==="working"||H==="staged"||H==="turn"||H==="branch"||H==="commit"||H==="pr")&&(N?.(H),w(!1))},e[14]=N,e[15]=x):x=e[15];let P;e[16]!==f?(P=f("diffView.scope.changed"),e[16]=f,e[17]=P):P=e[17];let W;e[18]!==P?(W=n.jsx("span",{children:P}),e[18]=P,e[19]=W):W=e[19];let le;e[20]!==c?(le=n.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[20]=c,e[21]=le):le=e[21];let te;e[22]!==le||e[23]!==W?(te=n.jsx(Ze,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[W,le]})}),e[22]=le,e[23]=W,e[24]=te):te=e[24];let pe;e[25]!==f?(pe=f("diffView.scope.staged"),e[25]=f,e[26]=pe):pe=e[26];let ne;e[27]!==pe?(ne=n.jsx("span",{children:pe}),e[27]=pe,e[28]=ne):ne=e[28];let he;e[29]!==y?(he=n.jsx("span",{className:"typography-meta text-muted-foreground",children:y}),e[29]=y,e[30]=he):he=e[30];let J;e[31]!==ne||e[32]!==he?(J=n.jsx(Ze,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[ne,he]})}),e[31]=ne,e[32]=he,e[33]=J):J=e[33];let I;e[34]!==f?(I=f("diffView.scope.lastTurn"),e[34]=f,e[35]=I):I=e[35];let se;e[36]!==I?(se=n.jsx("span",{children:I}),e[36]=I,e[37]=se):se=e[37];let X;e[38]!==p?(X=n.jsx("span",{className:"typography-meta text-muted-foreground",children:p}),e[38]=p,e[39]=X):X=e[39];let K;e[40]!==se||e[41]!==X?(K=n.jsx(Ze,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[se,X]})}),e[40]=se,e[41]=X,e[42]=K):K=e[42];let je;e[43]!==b||e[44]!==j||e[45]!==f?(je=j?n.jsx(Ze,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:f("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:b??"…"})]})}):null,e[43]=b,e[44]=j,e[45]=f,e[46]=je):je=e[46];let A;e[47]!==v||e[48]!==l||e[49]!==f?(A=l&&n.jsx(Ze,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:f("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:v??"…"})]})}),e[47]=v,e[48]=l,e[49]=f,e[50]=A):A=e[50];let G;e[51]!==F||e[52]!==l||e[53]!==f?(G=l&&n.jsx(Ze,{value:"pr",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:f("session.githubIntegration.tabs.pullRequests")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:F??"…"})]})}),e[51]=F,e[52]=l,e[53]=f,e[54]=G):G=e[54];let C;e[55]!==s||e[56]!==te||e[57]!==J||e[58]!==K||e[59]!==je||e[60]!==A||e[61]!==G||e[62]!==x?(C=n.jsx(ds,{align:"start",className:"w-40",children:n.jsxs(fs,{value:s,onValueChange:x,children:[te,J,K,je,A,G]})}),e[55]=s,e[56]=te,e[57]=J,e[58]=K,e[59]=je,e[60]=A,e[61]=G,e[62]=x,e[63]=C):C=e[63];let ce;return e[64]!==V||e[65]!==C||e[66]!==q?(ce=n.jsxs(ms,{open:V,onOpenChange:w,children:[q,C]}),e[64]=V,e[65]=C,e[66]=q,e[67]=ce):ce=e[67],ce}),Bs=i.memo(o=>{const e=tt.c(11),{changedFiles:s,selectedFile:c,onSelectFile:y}=o,{t:p}=qe();if(s.length===0)return null;let b;if(e[0]!==s||e[1]!==y||e[2]!==c||e[3]!==p){let F;e[5]!==y||e[6]!==c||e[7]!==p?(F=l=>{const j=ln(l),N=c===l.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>y(l.path),className:Ae("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",N?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(sn,{filePath:l.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:j.color},title:p(j.descriptionKey),"aria-label":p(j.descriptionKey),children:j.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:l.path,children:l.path}),cn(l.insertions,l.deletions)]})},l.path)},e[5]=y,e[6]=c,e[7]=p,e[8]=F):F=e[8],b=s.map(F),e[0]=s,e[1]=y,e[2]=c,e[3]=p,e[4]=b}else b=e[4];let v;return e[9]!==b?(v=n.jsx(rn,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:b})}),e[9]=b,e[10]=v):v=e[10],v}),Is=i.memo(o=>{const e=tt.c(20),{filePath:s,diff:c,renderSideBySide:y}=o,{t:p}=qe(),b=c.original.length>0,v=c.modified.length>0,F=y?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",l=y?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={contain:"layout"},e[0]=j):j=e[0];let N;e[1]!==c.original||e[2]!==s||e[3]!==b||e[4]!==l||e[5]!==y||e[6]!==p?(N=b&&n.jsxs("div",{className:l,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p("diffView.image.original")}),n.jsx("img",{src:c.original,alt:p("diffView.image.originalAlt",{path:s}),className:y?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=c.original,e[2]=s,e[3]=b,e[4]=l,e[5]=y,e[6]=p,e[7]=N):N=e[7];let f;e[8]!==c.modified||e[9]!==s||e[10]!==v||e[11]!==b||e[12]!==l||e[13]!==y||e[14]!==p?(f=v&&n.jsxs("div",{className:l,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p(b?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:c.modified,alt:p("diffView.image.modifiedAlt",{path:s}),className:y?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=c.modified,e[9]=s,e[10]=v,e[11]=b,e[12]=l,e[13]=y,e[14]=p,e[15]=f):f=e[15];let V;return e[16]!==F||e[17]!==N||e[18]!==f?(V=n.jsx("div",{className:"w-full overflow-auto p-4",style:j,children:n.jsxs("div",{className:F,children:[N,f]})}),e[16]=F,e[17]=N,e[18]=f,e[19]=V):V=e[19],V}),Ps=i.memo(o=>{const e=tt.c(23),{filePath:s,diff:c,staged:y,renderSideBySide:p,wrapLines:b,hunkActions:v,onExpandContextRequest:F,pendingContextExpansion:l,contextLoading:j}=o;let N;e[0]!==s?(N=cs(s)||"text",e[0]=s,e[1]=N):N=e[1];const f=N;if(c.submodule){let D;return e[2]!==c.submodule||e[3]!==y?(D=n.jsx(Qn,{state:c.submodule,staged:y}),e[2]=c.submodule,e[3]=y,e[4]=D):D=e[4],D}if(c.isBinary){let D;return e[5]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Ds,{}),e[5]=D):D=e[5],D}if(et(s)){let D;return e[6]!==c||e[7]!==s||e[8]!==p?(D=n.jsx(Is,{filePath:s,diff:c,renderSideBySide:p}),e[6]=c,e[7]=s,e[8]=p,e[9]=D):D=e[9],D}let V;e[10]===Symbol.for("react.memo_cache_sentinel")?(V={contain:"layout"},e[10]=V):V=e[10];let w;return e[11]!==j||e[12]!==c.fileDiff||e[13]!==c.modified||e[14]!==c.original||e[15]!==s||e[16]!==v||e[17]!==f||e[18]!==F||e[19]!==l||e[20]!==p||e[21]!==b?(w=n.jsx("div",{className:"w-full",style:V,children:n.jsx(gs,{original:c.original,modified:c.modified,fileDiff:c.fileDiff,language:f,fileName:s,renderSideBySide:p,wrapLines:b,layout:"inline",hunkActions:v,onExpandContextRequest:F,pendingContextExpansion:l,contextLoading:j})}),e[11]=j,e[12]=c.fileDiff,e[13]=c.modified,e[14]=c.original,e[15]=s,e[16]=v,e[17]=f,e[18]=F,e[19]=l,e[20]=p,e[21]=b,e[22]=w):w=e[22],w}),_s=i.memo(({visible:o=!0,directory:e,file:s,layout:c,wrapLines:y,isSelected:p,isExpanded:b,isMounted:v,onSelect:F,onExpandedChange:l,registerSectionRef:j,showOpenInEditorAction:N=!1,isOpeningInEditor:f=!1,onOpenInEditor:V,staged:w=!1,loadFullFiles:D=!1,initialDiffData:_=null,comparisonDiff:m,onRetryComparisonDiff:be,loadFullComparisonDiff:Z,readOnlyActions:ee=!1,hunkActionsEnabled:Ne=!1,contentRevision:q=0})=>{const{t:x}=qe(),{git:P}=en(),W=ae(i.useCallback(g=>g.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),le=ae(g=>g.setDiff),te=ae(g=>g.fetchStatus),pe=me(g=>g.setDiffFileLayout),[ne,he]=i.useState(0),[J,I]=i.useState(null),[se,X]=i.useState(!1),[K,je]=i.useState(null),A=K!==null&&K.source===m?K.result:m,G=!!e&&!_&&(!m||!!Z),C=i.useMemo(()=>A?A.status==="error"?{kind:"error",message:A.message}:null:J,[A,J]),ce=A?A.status==="loading":se,[H,lt]=i.useState(null),Be=i.useRef(!1),[Ie,nt]=i.useState(null),[ct,xt]=i.useState(!1),[st,Pe]=i.useState(null),[We,_e]=i.useState(null),[a,Ee]=i.useState(null),re=D||a!==null;i.useEffect(()=>{if(!a||!Z||!m||m.status!=="ready"||K?.source===m)return;let g=!1;return Z(s.path).then(M=>{if(!g){if(M.status==="error"){$e.error(M.message),Ee(null);return}je({source:m,result:M})}}),()=>{g=!0}},[a,s.path,K,Z,m]);const ge=i.useRef(null),Ve=i.useRef(null),Oe=i.useMemo(()=>ln(s),[s]),Ue=c==="side-by-side",ze=re?"full":"patch",ve=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,ue=Ne&&!ee&&!_&&!A&&!et(s.path),Je=JSON.stringify([De(),e,s.path,w,ve,ne,q]),U=Ie?.scope===Je?Ie.patch:null,de=Ie?.scope===Je?Ie.submodule:null,ie=i.useMemo(()=>A?A.status==="ready"?A.data:null:_||(w?We:st||(W?{original:W.original,modified:W.modified,isBinary:W.isBinary,submodule:W.submodule,contextMode:"full"}:null)),[A,W,_,st,w,We]),Xe=ie?.contextMode===ze,rt=i.useCallback(g=>{Ve.current=g,j(s.path,g)},[s.path,j]),Ke=i.useCallback(g=>{l(s.path,g)},[s.path,l]),Ye=i.useCallback(()=>{F(s.path)},[s.path,F]),ut=i.useRef({fileStatusKey:ve,staged:w});i.useEffect(()=>{if(!o)return;const g=ut.current;g.fileStatusKey===ve&&g.staged===w||(ut.current={fileStatusKey:ve,staged:w},w?_e(null):Pe(null),I(null),ge.current=null)},[ve,w,o]);const[yt,wt]=i.useState(q),xe=yt===q;i.useEffect(()=>{xe||(I(null),ge.current=null)},[xe]),i.useEffect(()=>{if(!o||!b||!v||J)return;if(!e||A||_||ie&&Xe&&xe&&(!ue||U!==null)){ge.current=null,X(!1);return}const g=`${e}::${s.path}::${w?"staged":"unstaged"}::${ve}::${ze}::${ne}::${q}`;if(ge.current===g)return;ge.current=g,I(null),X(!0);let M=!1;const ye=De(),we=re?on:Ct,O=et(s.path)?P.getGitFileDiff(e,{path:s.path,staged:w}):!re&&U!==null?Promise.resolve({diff:U,submodule:de}):P.getGitDiff(e,{path:s.path,staged:w,contextLines:we}),Ge=ue&&re&&U===null?P.getGitDiff(e,{path:s.path,staged:w,contextLines:Ct}).then(E=>E.diff):Promise.resolve(U),ft=Promise.all([O,Ge]),mt=Cs;let it;const bt=new Promise((E,ot)=>{it=setTimeout(()=>ot(new Error(`Timed out after ${mt}ms`)),mt)});return Promise.race([ft,bt]).then(([E,ot])=>{if(M||ye!==De())return;const L="diff"in E&&!re?E.diff:ot;if(ue&&re&&L!==null&&/^@@\s/m.test(L)&&"diff"in E&&E.diff!==L&&!zn(E.diff,L))throw nt(null),new Error(x("diffView.hunk.unavailable"));if(ue&&L!==null&&nt({scope:Je,patch:L,submodule:E.submodule}),"diff"in E){const Y={...Rt(s.path,E.diff,ze),submodule:E.submodule};w?_e(Y):Pe(Y)}else{const Y={original:E.original??"",modified:E.modified??"",isBinary:E.isBinary,submodule:E.submodule,contextMode:"full"};w?_e(Y):le(e,s.path,Y,ye)}wt(q),X(!1)}).catch(E=>{if(!(M||ye!==De())){if(X(!1),E instanceof Mn){I({kind:"unavailable",reason:E.reason}),E.reason==="path_not_found"&&te(e,P,{force:!0,silent:!0});return}I({kind:"error",message:E instanceof Error?E.message:String(E)})}}).finally(()=>clearTimeout(it)),()=>{M=!0,clearTimeout(it),ge.current===g&&(ge.current=null)}},[U,de,q,ue,xe,Je,A,ze,ie,Xe,ne,e,te,s.path,ve,P,_,b,v,re,J,le,w,x,o]);const Le=i.useCallback(()=>{Ke(!b),Ye()},[Ke,Ye,b]),oe=i.useCallback(()=>{I(null),nt(null),Pe(null),_e(null),ge.current=null,he(g=>g+1)},[]),$=i.useCallback(async(g,M)=>{if(!e||!ue||ce||C||Be.current||H!==null)return;const ye=U?Kn(U,g):null;if(!ye){$e.error(x("diffView.hunk.unavailable"));return}if(w&&M!=="unstage"||!w&&M==="unstage")return;Be.current=!0;const we=De();lt({index:g,action:M});try{const O=M==="stage"?P.stageGitHunk:M==="unstage"?P.unstageGitHunk:P.revertGitHunk;if(!O){$e.error(x("diffView.hunk.unsupported"));return}if(await O(e,s.path,ye),we!==De())return;oe(),tn.requestGitRefresh({directory:e,paths:[s.path]}),await te(e,P)}catch(O){if(we!==De())return;oe(),$e.error(O instanceof Error&&O.message?O.message:x("diffView.hunk.unavailable"))}finally{Be.current=!1,lt(O=>O?.index===g&&O.action===M?null:O)}},[U,ue,ce,C,e,te,s.path,P,H,oe,w,x]),Se=i.useMemo(()=>ue&&U!==null?Gn(U):[],[U,ue]),Ce=i.useCallback(g=>n.jsx(vs,{index:g,staged:w,busyHunk:H,disabled:ce||!!C,onAction:$}),[C,$,H,ce,w]),dt=i.useMemo(()=>Se.length>0?{anchors:Se,render:Ce}:void 0,[Se,Ce]);return n.jsxs("div",{ref:rt,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:Le,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),Le())},className:Ae("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",p?"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:b?n.jsx(z,{name:"arrow-down-s",className:"size-4"}):n.jsx(z,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:x(Oe.descriptionKey),"aria-label":x(Oe.descriptionKey),children:Oe.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(sn,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const g=s.path.lastIndexOf("/");if(g===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const M=s.path.slice(0,g),ye=s.path.slice(g+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:M}),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:ye})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[cn(s.insertions,s.deletions),N&&V?n.jsx(ke,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:x("diffView.actions.openFileInEditorAtChange"),onClick:g=>{g.stopPropagation(),V(s.path,ie)},disabled:f,children:f?n.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(z,{name:"edit",className:"size-3.5"})}):null,n.jsx(nn,{mode:Ue?"side-by-side":"unified",onModeChange:g=>{const M=g==="side-by-side"?"side-by-side":"inline";pe(s.path,M)},className:"opacity-70"})]})]})}),b&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!v&&!C?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,C?.kind==="unavailable"?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:C.reason==="nested_repository"?x("diffView.unavailable.nestedRepositoryTitle"):C.reason==="untracked_directory"?x("diffView.unavailable.untrackedDirectoryTitle"):x("diffView.unavailable.missingTitle")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C.reason==="nested_repository"?x("diffView.unavailable.nestedRepositoryDescription"):C.reason==="untracked_directory"?x("diffView.unavailable.untrackedDirectoryDescription"):x("diffView.unavailable.missingDescription")}),C.reason==="path_not_found"?n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:oe,children:x("diffView.actions.retry")}):null]}):null,C?.kind==="error"?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:x("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C.message}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>A?be?.():oe(),children:x("diffView.actions.retry")})]}):null,v&&ce&&!ie&&!C?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),x("diffView.state.loadingDiff")]}):null,v&&ie&&!ct&&s.insertions+s.deletions>Wt?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:x("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:x("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>xt(!0),children:x("diffView.actions.renderAnyway")})]}):null,v&&ie&&(ct||s.insertions+s.deletions<=Wt)?n.jsx(n.Fragment,{children:n.jsx(Ps,{filePath:s.path,diff:ie,staged:w,renderSideBySide:Ue,wrapLines:y,hunkActions:dt,onExpandContextRequest:G?Ee:void 0,pendingContextExpansion:a,contextLoading:a!==null&&ie.contextMode!=="full"&&!C})}):null]})]})}),io=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:c=!1,showOpenInEditorAction:y=!1,diffScope:p="all",onDiffScopeChange:b,targetFilePath:v=null,flushContent:F=!1})=>{const{t:l}=qe(),{git:j,files:N}=en(),f=Zn(),V=ae(t=>t.runtimeKey),{rootIsGitRepo:w,gitDirectory:D,nestedRepos:_}=es(f??null,{enabled:o}),m=D??f,be=me(t=>t.openContextSurface),Z=xs(t=>t.requestSource),{screenWidth:ee,isMobile:Ne}=ts(),q=ns(m??null),x=ss(m??null),P=rs(m??null),W=ae(t=>t.setActiveDirectory),le=ae(t=>t.ensureStatus),te=ae(t=>t.selectNestedRepo),pe=ae(t=>t.fetchStatus),ne=ae(t=>t.fetchBranches),he=ae(t=>t.clearDiffCache),J=ae(t=>t.setDiff),[I,se]=i.useState(null),[X,K]=i.useState(!1),[je,A]=i.useState(null),[G,C]=i.useState(()=>new Set),[ce,H]=i.useState(()=>new Set),[lt,Be]=i.useState(0),[Ie,nt]=i.useState(()=>new Map),[ct,xt]=i.useState(0),[st,Pe]=i.useState(!1),[We,_e]=i.useState(!1),[a,Ee]=i.useState(p);i.useEffect(()=>{Ee(p)},[p]);const re=me(t=>t.pendingDiffFile),ge=me(t=>t.pendingDiffStaged),Ve=me(t=>t.pendingDiffScope),Oe=me(t=>t.setPendingDiffFile),Ue=me(t=>t.diffLayoutPreference),ze=me(t=>t.diffFileLayout),ve=me(t=>t.setDiffFileLayout),ue=me(t=>t.diffWrapLines),Je=me(t=>t.setDiffWrapLines),U=me(t=>t.openContextFileAtLine),de=Ht(t=>t.currentSessionId),ie=is(a==="turn"?de??"":"",f??void 0),Xe=ue,rt=a==="staged"?!0:a==="working"?!1:null,Ke=rt??X,Ye=Ne||ee<=768,ut=!!de&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!Ye&&!Fe(),yt=a!=="turn"&&!Ye&&!Fe(),wt=!e&&!Ye&&ee>=1024,xe=i.useRef(null),Le=i.useRef(new Map),oe=i.useRef(null),$=i.useRef(null),Se=i.useRef(!1),Ce=i.useRef(null),dt=i.useRef(null),g=i.useRef(null),M=i.useRef(null),ye=i.useCallback(()=>{const t=xe.current;if(!t)return null;const r=t.getBoundingClientRect().top,u=[];for(const[d,h]of Le.current)h&&u.push({path:d,top:h.getBoundingClientRect().top});return $t(r,u)},[]),we=i.useCallback(()=>{oe.current=null,Se.current=!1,A(null),$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null)},[]),O=i.useCallback(t=>{C(r=>{if(r.has(t))return r;const u=new Set(r);return u.add(t),u})},[]),[Ge,ft]=i.useState([]),mt=ie.length>0?ie[ie.length-1].id:"";i.useEffect(()=>{if(a!=="turn"||!de||!o)return;let t=!1;return Ln.getSessionTurnDiff(de,{directory:f??void 0}).then(r=>{t||ft(r.map(u=>({file:u.file,patch:u.patch,status:u.status,additions:u.additions,deletions:u.deletions})))}).catch(r=>{t||(console.warn("[diff-view] turn diff unavailable:",r instanceof Error?r.message:r),ft([]))}),()=>{t=!0}},[a,de,mt,f,o]);const it=i.useMemo(()=>{const t=new Map;for(const r of Ge)if(r.file){if(typeof r.patch=="string"){t.set(r.file,Rt(r.file,r.patch,"patch"));continue}t.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return t},[Ge]),bt=i.useMemo(()=>x?.files?x.files.filter(Yt).length:0,[x]),E=i.useMemo(()=>x?.files?x.files.filter(Xt).length:0,[x]),ot=Ge.length,L=x?.current??null,Y=Tn(m??null,L,o&&a==="pr"&&!Fe()),Me=Y.selectedSource,Te=Bn(m??null,L,o&&a==="commit"&&!Fe()),He=Te.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Fe()&&(Ee("working"),b?.("working"))},[a,b]);const Qe=ae(t=>m?t.directories.get(m)?.branches??null:null),un=ae(t=>m?t.directories.get(m)?.isLoadingBranches??!1:!1),dn=i.useCallback(()=>{m&&ne(m,j)},[m,ne,j]),fn=qn(m??null,o&&q!==!1,un,!!Qe,dn,Fs),Ft=i.useMemo(()=>{const t=x?.tracking?.trim().split("/")[0];return(t&&Qe?.defaultBranches?.[t])??Qe?.defaultBranches?.origin??null},[Qe,x?.tracking]),Dt=!Fe()&&Wn(L,Ft),mn=x!==null,At=Fe()||fn||Un(L,Ft,mn,Qe!==null),pn=In(t=>t.setOverride),{base:Re,resolved:hn,revision:Et}=Pn(m??null,L,o&&Dt&&a==="branch"),[gn,xn]=i.useState(0);i.useEffect(()=>{const t=Yn(a,!At);t!==a&&(Ee(t),t==="working"&&b?.("working"))},[a,At,b]);const yn=i.useMemo(()=>a==="pr"?Me:a==="commit"&&He?{kind:"commit",hash:He}:a==="branch"&&Re&&L?{kind:"branch",baseRef:Re,headRef:L}:null,[a,Re,L,He,Me]),T=Jn(m??null,yn,o&&!Fe(),a==="branch"?Et:""),{fetchDiff:Vt,fetchFullFile:Lt}=T,Mt=a==="commit"?T.files:null,Tt=a==="commit"?T.error:null,pt=a==="branch"?T.files:null,Bt=a==="branch"?T.error:null,It=T.files?a==="pr"?JSON.stringify([T.key,T.revision]):T.key:null,wn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(G).sort().join("\0"):"",[a,G]),jt=i.useCallback(async(t,r=!1)=>{try{const u=await Vt(t,r?on:Ct);return{status:"ready",data:Rt(t,u.diff,r?"full":"patch")}}catch(u){return{status:"error",message:u instanceof Error?u.message:l("diffView.state.failedToLoadDiff")}}},[Vt,l]),Pt=i.useCallback(async t=>{try{const{original:r,modified:u}=await Lt(t),d=js({name:t,contents:r},{name:t,contents:u});return{status:"ready",data:{original:r,modified:u,fileDiff:d,contextMode:"full"}}}catch(r){return{status:"error",message:r instanceof Error?r.message:l("diffView.state.failedToLoadDiff")}}},[Lt,l]),bn=i.useMemo(()=>a==="branch"||a==="commit"?t=>jt(t,!0):a==="pr"?Pt:void 0,[a,jt,Pt]),jn=Xn(It,o?wn:"",It?jt:null,Jt,JSON.stringify([a==="branch"?Et:"",a==="pr"?T.revision:0,gn])),vn=pt?.length??null,k=i.useMemo(()=>{if(a==="commit"||a==="pr")return(T.files??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:d.insertions,deletions:d.deletions,isNew:d.status==="A"}));if(a==="branch")return(pt??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:0,deletions:0,isNew:d.status==="A"})).sort((d,h)=>d.path.localeCompare(h.path));if(a==="turn")return Ge.map(d=>({path:d.file??"",index:"",working_dir:Ms(d.status),insertions:d.additions??0,deletions:d.deletions??0,isNew:d.status==="added"})).filter(d=>d.path).sort((d,h)=>d.path.localeCompare(h.path));if(!x?.files)return[];const t=x.diffStats,r=a==="staged"?Xt:a==="working"?Yt:()=>!0,u=d=>{const h=t?.staged?.[d],R=t?.working?.[d];return a==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:a==="working"?{insertions:R?.insertions??0,deletions:R?.deletions??0}:{insertions:(h?.insertions??0)+(R?.insertions??0),deletions:(h?.deletions??0)+(R?.deletions??0)}};return x.files.filter(r).map(d=>{const h=u(d.path);return{...d,insertions:h.insertions,deletions:h.deletions,isNew:Vs(d)}}).sort((d,h)=>d.path.localeCompare(h.path))},[a,pt,T.files,Ge,x]),vt=i.useMemo(()=>k.map(t=>t.path).join("\0"),[k]);i.useEffect(()=>{const t=vt?vt.split("\0"):[],r=new Set(t),u=`${m??""}:${a}:${s?"collapsed":"default"}`,d=dt.current!==u;dt.current=u,C(h=>{if(d){const B=s?0:Rs(t.length);return new Set(t.slice(0,B))}let R=!1;const S=new Set;for(const B of h){if(!r.has(B)){R=!0;continue}S.add(B)}return R?S:h}),H(h=>{if(d)return new Set;let R=!1;const S=new Set;for(const B of h){if(!r.has(B)){R=!0;continue}S.add(B)}return R?S:h})},[a,vt,m,s]);const _t=i.useCallback(()=>{if(Ce.current=null,!o)return;const t=xe.current;if(!t)return;const r=t.getBoundingClientRect(),u=r.top-Ut,d=r.bottom+Ut,h={},R=[];for(const[S,B]of Le.current){if(!B)continue;const Q=B.getBoundingClientRect();R.push({path:S,top:Q.top}),G.has(S)&&(Q.bottom<u||Q.top>d||(h[S]=!0))}g.current=$t(r.top,R),H(S=>{let B=!1;const Q=new Set(S);for(const at of Object.keys(h))Q.has(at)||(Q.add(at),B=!0);return B?Q:S})},[G,o]),fe=i.useCallback(()=>{o&&(typeof window>"u"||Ce.current===null&&(Ce.current=window.requestAnimationFrame(_t)))},[_t,o]);i.useEffect(()=>{const t=xe.current;if(!(!o||!t))return fe(),t.addEventListener("scroll",fe,{passive:!0}),window.addEventListener("resize",fe),()=>{t.removeEventListener("scroll",fe),window.removeEventListener("resize",fe),Ce.current!==null&&(window.cancelAnimationFrame(Ce.current),Ce.current=null)}},[k,G,fe,o]);const St=i.useCallback(t=>{const r=ze[t.path];if(r)return r;if(Ue==="inline")return"inline";if(Ue==="side-by-side")return"side-by-side";const u=ee<Ns;return t.isNew||u?"inline":"side-by-side"},[ze,Ue,ee]),Ot=i.useMemo(()=>k.length===0?null:k.every(t=>St(t)==="side-by-side")?"side-by-side":"inline",[k,St]);i.useEffect(()=>{o&&m&&(W(m),le(m,j))},[m,W,le,j,o]);const ht=JSON.stringify([V,m]),kt=i.useRef({scope:ht,paths:new Set,dirty:!1,unscoped:!1}),zt=i.useRef(o);i.useEffect(()=>{const t=o&&!zt.current;if(zt.current=o,kt.current.scope!==ht&&(kt.current={scope:ht,paths:new Set,dirty:!1,unscoped:!1}),!m)return;const r=(d,h)=>{d.length&&(M.current=ye()??g.current,he(m,d),nt(R=>{const S=new Map(R);for(const B of d)S.set(B,(S.get(B)??0)+1);return S})),h&&xt(R=>R+1),pe(m,j,{silent:!0})},u=kt.current;return o&&(t||u.dirty)&&(r([...u.paths],u.unscoped),u.paths.clear(),u.dirty=!1,u.unscoped=!1),tn.onGitRefreshHint(d=>{if(Qt(d.directory)!==Qt(m))return;const h=d.paths??[],R=h.length===0;if(!o){u.dirty=!0,u.unscoped||=R;for(const S of h)u.paths.add(S);return}r(h,R)})},[ye,he,m,pe,j,ht,o]),i.useLayoutEffect(()=>{const t=M.current;if(!t)return;M.current=null;const r=xe.current,u=Le.current.get(t.path);if(!r||!u)return;const d=r.getBoundingClientRect().top,h=u.getBoundingClientRect().top-d;r.scrollTop=ks(r.scrollTop,t.topOffset,h,r.scrollHeight-r.clientHeight),g.current=t},[Ie]),i.useEffect(()=>{!o||a!=="all"&&!Ve||re&&(Ve&&Ee(Ve),se(re),K(Ve==="staged"||!Ve&&ge),Oe(null),Se.current=!0,oe.current=re,O(re),Be(t=>t+1))},[a,O,re,Ve,ge,Oe,o]),i.useEffect(()=>{if(a==="all")return;const t=v?.trim();t&&(se(t),K(a==="staged"),Se.current=!0,oe.current=t,O(t),Be(r=>r+1))},[a,O,v]),i.useEffect(()=>{if(!I)return;k.some(r=>r.path===I)||(se(null),K(!1))},[k,I]);const Sn=i.useCallback((t,r)=>{const u=Le.current;r?u.set(t,r):u.delete(t),fe()},[fe]),kn=i.useCallback((t,r)=>{we(),C(u=>{const d=u.has(t);if(r===d)return u;const h=new Set(u);return r?h.add(t):h.delete(t),h}),r||H(u=>{if(!u.has(t))return u;const d=new Set(u);return d.delete(t),d}),fe()},[we,fe]),Nn=i.useCallback(()=>{we(),C(t=>t.size>0?new Set:new Set(k.map(r=>r.path))),H(new Set),fe()},[we,k,fe]),Cn=i.useCallback(async t=>{if(!de)return;const r=Ht.getState().getDirectoryForSession(de)||f||"";if(!r){$e.error(l("diffView.reviewDialog.toast.noSessionDirectory"));return}_e(!0);try{await os({originalSessionID:de,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}),Pe(!1)}catch(u){console.error("[review-flow] failed to start review flow",u),$e.error(u instanceof Error?u.message:l("diffView.reviewDialog.toast.startFailed"))}finally{_e(!1)}},[de,f,l]),gt=i.useCallback(t=>{const r=Le.current.get(t),u=xe.current;if(!r||!u)return!1;const d=r.getBoundingClientRect().top-u.getBoundingClientRect().top;return u.scrollTo({top:u.scrollTop+d,behavior:"auto"}),!0},[]);i.useEffect(()=>{const t=oe.current;if(!o||!t)return;let r=0;const u=20;let d=!1;const h=(S=!0)=>{d||(d=!0,oe.current=null,Se.current=!1,S&&A(null),$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null))},R=()=>{if(d){$.current=null;return}const S=oe.current;if(!S){h(),$.current=null;return}if(!gt(S)){r+=1,r<u?$.current=window.requestAnimationFrame(R):(h(),$.current=null);return}if(c&&Se.current){A(S),h(!1);return}h()};return $.current=window.requestAnimationFrame(R),()=>{d=!0,$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null)}},[c,lt,gt,o]);const Rn=i.useCallback(t=>{},[]),Nt=i.useCallback(t=>{we(),se(t),K(!1),Se.current=!0,oe.current=t,O(t),Be(r=>r+1),gt(t)},[we,O,gt]);i.useEffect(()=>{const t=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const u=r.target;if(u instanceof HTMLElement&&(u.isContentEditable||u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.closest('[role="dialog"]'))||k.length===0)return;const d=r.key==="ArrowDown"?1:-1,h=I?k.findIndex(B=>B.path===I):-1,R=h===-1?d>0?0:k.length-1:h+d,S=k[R];S&&(r.preventDefault(),Nt(S.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[k,I,Nt,o]);const Fn=i.useCallback(t=>{const r=t==="side-by-side"?"side-by-side":"inline";k.forEach(u=>{ve(u.path,r)})},[k,ve]),[Dn,Kt]=i.useState(null),An=i.useCallback(async(t,r)=>{if(!m||!t)return;Kt(t);const u=De();try{let d=null;if(r?.patch&&!r.isBinary&&!et(t)?d=qt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!et(t)&&(d=Zt(r.original,r.modified)),d===null)try{const Q=await j.getGitDiff(m,{path:t,staged:Ke,contextLines:3});d=qt(Q.diff)}catch{d=null}let h=r;if(d===null||!h){const Q=await j.getGitFileDiff(m,{path:t,staged:Ke}),at={original:Q.original??"",modified:Q.modified??"",isBinary:Q.isBinary,submodule:Q.submodule};h=at,Ke||J(m,t,at,u)}const R=d??(h.isBinary||et(t)?1:Zt(h.original,h.modified)),S=Ls(m,t),B=await ys(N,S,{directory:m});if(!B.ok){$e.error(ws(B.reason));return}U(m,S,R,1)}finally{Kt(d=>d===t?null:d)}},[Ke,m,N,j,U,J]),En=()=>{if(!m)return null;const t=r=>rt!==null?rt:X&&r===I;return n.jsxs("div",{className:Ae("flex min-w-0 flex-1 min-h-0 h-full",F?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[wt&&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:l("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:k.length})]}),n.jsx(Bs,{changedFiles:k,selectedFile:null,onSelectFile:Nt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(rn,{ref:xe,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:k.map(r=>n.jsx(_s,{visible:o,directory:m,file:r,layout:St(r),wrapLines:Xe,isSelected:!1,isExpanded:G.has(r.path),isMounted:ce.has(r.path)||r.path===je,onSelect:Rn,onExpandedChange:kn,registerSectionRef:Sn,showOpenInEditorAction:y&&a!=="turn",isOpeningInEditor:Dn===r.path,onOpenInEditor:(u,d)=>{An(u,d)},staged:t(r.path),readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",contentRevision:ct,comparisonDiff:a==="branch"||a==="commit"||a==="pr"?jn.get(r.path)??Jt:void 0,onRetryComparisonDiff:()=>xn(u=>u+1),loadFullComparisonDiff:bn,initialDiffData:a==="turn"?it.get(r.path)??null:null},`${De()}:${m}:${r.path}:${Ie.get(r.path)??0}`))})})})]})},Vn=()=>{if(!m)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l("diffView.state.selectSessionDirectory")});if(a!=="turn"&&P&&!x)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&q===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l("diffView.state.notGitRepository")});if(a==="pr"){if(!Me||T.error)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:T.error??Y.error??(Y.loading?l("session.githubPrPicker.loading.pullRequests"):l("pullRequestComparison.select"))}),(T.error||Y.error)&&n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{Me?T.refresh():Y.refresh()},children:l("diffView.actions.retry")}),!Me&&!Y.loading&&n.jsx(Gt,{comparison:Y})]});if(!T.files)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(a==="commit"){if(Tt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:Tt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{T.refresh()},children:l("diffView.actions.retry")})]});if(!He&&!Te.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Te.error??l("commitComparison.noCommits")});if(!Mt)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(a==="branch"){if(!hn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.resolvingBase")]});if(!Re)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(z,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:l("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:l("gitView.pr.toast.baseBranchRequired")})]});if(Bt)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:l("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Bt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{T.refresh()},children:l("diffView.actions.retry")})]});if(pt===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.loadingFiles")]})}return k.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?l("diffView.state.noLastTurnChanges"):a==="pr"?l("walkthrough.blocked.emptyDiff.description"):a==="commit"?l("commitComparison.emptyDiff"):a==="branch"&&Re?l("diffView.branch.empty",{base:hs(Re)}):l("diffView.state.cleanWorkingTree")}):En()};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:[w===!1&&Array.isArray(_)&&_.length>0?n.jsx(ps,{repositories:_,selectedRepository:D??null,onSelectRepository:t=>{f&&te(f,t)},repositoryRoot:f??void 0}):null,!Ne&&(a!=="all"?n.jsx(Ts,{scope:a,workingCount:bt,stagedCount:E,turnCount:ot,branchCount:vn,commitCount:a==="commit"?Mt?.length??null:null,prCount:a==="pr"?T.files?.length??null:null,showCommitOption:!Fe(),showBranchOption:Dt,onScopeChange:t=>{Ee(t),b?.(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:P&&!x?l("diffView.state.loadingChanges"):k.length===1?l("diffView.summary.changedFilesSingle",{count:k.length}):l("diffView.summary.changedFilesPlural",{count:k.length})})})),a==="branch"&&n.jsx(_n,{branches:Qe?.all??[],currentBranch:L,base:Re,onSelect:t=>{m&&L&&pn(m,L,t)}},JSON.stringify([m,L])),a==="commit"&&n.jsx(On,{commits:Te.commits,selectedHash:He,loading:Te.loading,error:Te.error,onSelect:Te.select,onRefresh:()=>{Te.refresh()}},JSON.stringify([m,L])),a==="pr"&&n.jsxs(n.Fragment,{children:[n.jsx(Gt,{comparison:Y},JSON.stringify([V,m,L])),Me&&n.jsx(ke,{variant:"ghost",size:"sm",disabled:T.loading,"aria-label":l("session.githubIssuePicker.actions.refresh"),title:l("session.githubIssuePicker.actions.refresh"),onClick:()=>{T.refresh()},children:n.jsx(z,{name:"refresh",className:"size-4"})})]}),k.length>0&&n.jsxs(ke,{variant:"ghost",size:"sm",onClick:Nn,className:Ae("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:G.size>0?l("diffView.actions.collapseAll"):l("diffView.actions.expandAll"),children:[n.jsx(z,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:G.size>0?l("diffView.actions.collapseAll"):l("diffView.actions.expandAll")})]}),k.length>0&&ut&&n.jsxs(ke,{variant:"default",size:"sm",onClick:()=>Pe(!0),disabled:We,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":l("diffView.actions.reviewAria"),children:[We?n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(z,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:l("diffView.actions.review")})]}),k.length>0&&yt&&n.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>{const t=m??"";Z(t,a==="pr"&&Me?Me:a==="commit"&&He?{kind:"commit",hash:He}:a==="branch"&&Re&&L?{kind:"branch",baseRef:Re,headRef:L}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),be(f??t,"walkthrough")},className:Ae("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",bs),"aria-label":l("walkthrough.action.open"),children:[n.jsx(z,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:l("walkthrough.action.open")})]}),k.length>0&&n.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>Je(!ue),className:Ae("h-5 w-5 p-0 transition-opacity",Xe?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:l(Xe?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(z,{name:"text-wrap",className:"size-4"})}),Ot&&n.jsx(nn,{mode:Ot==="side-by-side"?"side-by-side":"unified",onModeChange:Fn})]}),n.jsx(as,{open:st,onOpenChange:Pe,projectDirectory:m??null,submitting:We,onConfirm:Cn}),Vn()]})};export{io as DiffView,_s as MultiFileDiffEntry};
@@ -1,4 +1,4 @@
1
- import{f as Re,R as i,c as Ei,j as r,r as ht}from"./vendor-react-BUCujlKS.js";import{a as tt,h as en,Y as Mo,Z as Do,_ as zo,$ as Lo,v as et,u as mt,e1 as Ao,I as Vi,B as Io,a3 as Pi,e as Oo,d$ as Bo,a2 as $o,e0 as _o}from"./index-CvLgnuNI.js";import{f as st,z as Mi,ai as sa,cf as Wo,h as W,kw as Uo,g5 as Ko,X as Fs,B as I,I as E,kx as Ho,aA as Ns,gV as qo,gT as Go,_ as Xo,T as Jo,bj as Yo,K as Zo,ak as Qo,cA as el,eF as Di,ix as tl,gr as sl,t as re,l as zi,ay as Kr,ct as bs,d9 as rl,b as nl,ky as ys,c1 as il,az as Hr,kz as qr,cu as Li,cv as Ai,kA as Ii,kB as Oi,kC as al,kD as ol,kE as ll,hy as cl,kF as ul,kG as dl,kH as fl,c2 as ra,c3 as na,c4 as ia,c5 as aa,c6 as oa,c7 as la,as as tn,at as sn,av as rn,bh as ur,c8 as Gr,aB as ar,cp as Xr,ae as Mt,af as Dt,ag as zt,b$ as ml,c0 as hl,g as fr,bi as pl,cz as gl}from"./useAppFontEffects-BxrtCnfR.js";import{at as xl,Y as vl,Z as wl,_ as bl,$ as yl,a0 as jl}from"./runtimeEndpointReset-DKDdzRzm.js";import{c as Bi,s as Nl,P as js,C as Sl}from"./shikiHighlight-xURoo5t_.js";import{a as Fl}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Lt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Cl,J as kl,F as Rl}from"./JsonTreeView-DOHHcbgJ.js";import{ensurePierreThemeRegistered as $i,getResolvedShikiTheme as Tl}from"./appThemeRegistry-B5tHTkR8.js";import{V as El,W as Vl}from"./Virtualizer-CZlLSacm.js";import{V as Pl}from"./Virtualizer-D_a8gKmg.js";import{a as Ml,u as or,b as Dl,c as zl,h as Ll,i as Al,j as Il}from"./scheduledTasksApi-C5sCuNqf.js";import{D as Ol}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Bl,u as $l,n as _l}from"./useInlineCommentController-CeXuR-SR.js";import{b as Wl}from"./CodeMirrorCommentWidgets-B82Oye3V.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.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-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.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-DOuaQUZ0.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"./GuestAttachDialog-CYwWYLr3.js";import"./PluginPane-sM8fcZIV.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-63H1h21j.js";import"./computeVirtualFileMetrics-cq9uQ30i.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-DB3_rjyW.js";import"./textMateThemeFromAppTheme-BZLGuYTU.js";function _i(n){const e=Re.c(41),{containerRef:t,filePath:a,fileContent:w}=n,{t:f}=st(),v=Mi(Yl),d=Mi(Jl),x=sa(),g=Wo(Xl),[m,b]=i.useState(null),[y,C]=i.useState(""),[N,F]=i.useState(!1),p=i.useRef(!1),l=i.useRef(null),T=i.useRef(null),[R,M]=i.useState(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{b(null),C(""),F(!1),p.current=!1,T.current=null,M(null)},e[0]=D):D=e[0];const L=D;let k,V;e[1]!==t?(k=()=>{const K=t.current;if(!K)return;const ie=()=>{if(p.current)return;const ae=window.getSelection(),fe=ae?.toString().trim()??"";if(!ae||!fe||ae.rangeCount===0){L();return}const me=ae.getRangeAt(0);if(!K.contains(me.commonAncestorContainer)){L();return}const ce=me.getBoundingClientRect();T.current=me.cloneRange(),C(fe),b({x:ce.left+ce.width/2,y:ce.top-10})},_=ae=>{l.current?.contains(ae.target)||p.current&&L()};return document.addEventListener("selectionchange",ie),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",ie),document.removeEventListener("pointerdown",_)}},V=[t,L],e[1]=t,e[2]=k,e[3]=V):(k=e[2],V=e[3]),i.useEffect(k,V);let z;e[4]!==w?(z=K=>{const ie=he=>w.slice(0,he).split(`
1
+ import{f as Re,R as i,c as Ei,j as r,r as ht}from"./vendor-react-BUCujlKS.js";import{a as tt,h as en,Y as Mo,Z as Do,_ as zo,$ as Lo,v as et,u as mt,e1 as Ao,I as Vi,B as Io,a3 as Pi,e as Oo,d$ as Bo,a2 as $o,e0 as _o}from"./index-CvLgnuNI.js";import{f as st,z as Mi,ai as sa,cf as Wo,h as W,kw as Uo,g5 as Ko,X as Fs,B as I,I as E,kx as Ho,aA as Ns,gV as qo,gT as Go,_ as Xo,T as Jo,bj as Yo,K as Zo,ak as Qo,cA as el,eF as Di,ix as tl,gr as sl,t as re,l as zi,ay as Kr,ct as bs,d9 as rl,b as nl,ky as ys,c1 as il,az as Hr,kz as qr,cu as Li,cv as Ai,kA as Ii,kB as Oi,kC as al,kD as ol,kE as ll,hy as cl,kF as ul,kG as dl,kH as fl,c2 as ra,c3 as na,c4 as ia,c5 as aa,c6 as oa,c7 as la,as as tn,at as sn,av as rn,bh as ur,c8 as Gr,aB as ar,cp as Xr,ae as Mt,af as Dt,ag as zt,b$ as ml,c0 as hl,g as fr,bi as pl,cz as gl}from"./useAppFontEffects-Bzyszv2N.js";import{at as xl,Y as vl,Z as wl,_ as bl,$ as yl,a0 as jl}from"./runtimeEndpointReset-C45jrFq4.js";import{c as Bi,s as Nl,P as js,C as Sl}from"./shikiHighlight-4O0ZM14D.js";import{a as Fl}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Lt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Cl,J as kl,F as Rl}from"./JsonTreeView-Cq_27v0y.js";import{ensurePierreThemeRegistered as $i,getResolvedShikiTheme as Tl}from"./appThemeRegistry-Br2TLSlb.js";import{V as El,W as Vl}from"./Virtualizer-CZlLSacm.js";import{V as Pl}from"./Virtualizer-D_a8gKmg.js";import{a as Ml,u as or,b as Dl,c as zl,h as Ll,i as Al,j as Il}from"./scheduledTasksApi-CkK1F9s2.js";import{D as Ol}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Bl,u as $l,n as _l}from"./useInlineCommentController-zOf6ORAq.js";import{b as Wl}from"./CodeMirrorCommentWidgets-DZF8ntaq.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.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-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.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-6cEFPNUR.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"./GuestAttachDialog-CoXM0gh_.js";import"./PluginPane-B39JEUL8.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-BEo4-ISu.js";import"./computeVirtualFileMetrics-_-20umCs.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-C54B4Mns.js";import"./textMateThemeFromAppTheme-yNq7b0DZ.js";function _i(n){const e=Re.c(41),{containerRef:t,filePath:a,fileContent:w}=n,{t:f}=st(),v=Mi(Yl),d=Mi(Jl),x=sa(),g=Wo(Xl),[m,b]=i.useState(null),[y,C]=i.useState(""),[N,F]=i.useState(!1),p=i.useRef(!1),l=i.useRef(null),T=i.useRef(null),[R,M]=i.useState(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{b(null),C(""),F(!1),p.current=!1,T.current=null,M(null)},e[0]=D):D=e[0];const L=D;let k,V;e[1]!==t?(k=()=>{const K=t.current;if(!K)return;const ie=()=>{if(p.current)return;const ae=window.getSelection(),fe=ae?.toString().trim()??"";if(!ae||!fe||ae.rangeCount===0){L();return}const me=ae.getRangeAt(0);if(!K.contains(me.commonAncestorContainer)){L();return}const ce=me.getBoundingClientRect();T.current=me.cloneRange(),C(fe),b({x:ce.left+ce.width/2,y:ce.top-10})},_=ae=>{l.current?.contains(ae.target)||p.current&&L()};return document.addEventListener("selectionchange",ie),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",ie),document.removeEventListener("pointerdown",_)}},V=[t,L],e[1]=t,e[2]=k,e[3]=V):(k=e[2],V=e[3]),i.useEffect(k,V);let z;e[4]!==w?(z=K=>{const ie=he=>w.slice(0,he).split(`
2
2
  `).length,_=ql,ae=(he,ve)=>{for(const Ee of _(he)){const ye=w.indexOf(Ee,ve);if(ye>=0)return ye}return-1},fe=K.length>=8?w.indexOf(K):-1;if(fe>=0){const he=ie(fe);return{start:he,end:he+K.split(`
3
3
  `).length-1}}const me=K.split(`
4
4
  `).map(Hl).filter(Boolean);if(me.length===0)return null;const ce=ae(me[0],0);if(ce<0)return null;const be=ie(ce);if(me.length===1)return{start:be,end:be};const xe=ae(me[me.length-1],ce);return xe<0?null:{start:be,end:Math.max(be,ie(xe))}},e[4]=w,e[5]=z):z=e[5];const B=z;let U;e[6]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{const K=T.current;if(!K){M(null);return}M(Uo(K))},e[6]=U):U=e[6];const Z=U;let te,ee;e[7]!==N?(te=()=>{if(!N)return;let K=null;const ie=()=>{K===null&&(K=window.requestAnimationFrame(()=>{K=null,Z()}))};return document.addEventListener("scroll",ie,{capture:!0,passive:!0}),window.addEventListener("resize",ie),()=>{K!==null&&window.cancelAnimationFrame(K),document.removeEventListener("scroll",ie,{capture:!0}),window.removeEventListener("resize",ie)}},ee=[N,Z],e[7]=N,e[8]=te,e[9]=ee):(te=e[8],ee=e[9]),i.useEffect(te,ee);let q;e[10]!==y?(q=()=>{y&&(F(!0),p.current=!0,Z(),window.getSelection()?.removeAllRanges())},e[10]=y,e[11]=q):q=e[11];const G=q;let X;e[12]!==g||e[13]!==v||e[14]!==x||e[15]!==a||e[16]!==d||e[17]!==B||e[18]!==y?(X=K=>{const ie=v??(d?"draft":null);if(!y||!ie||!x){L();return}const _=B(y);g({directory:x,sessionKey:ie},{source:"file-quote",fileLabel:a,startLine:_?.start??0,endLine:_?.end??0,code:y,language:"",text:K.trim()}),L(),queueMicrotask(Kl)},e[12]=g,e[13]=v,e[14]=x,e[15]=a,e[16]=d,e[17]=B,e[18]=y,e[19]=X):X=e[19];const H=X;if(!m)return null;let Q;e[20]!==N||e[21]!==B||e[22]!==y?(Q=N?B(y):null,e[20]=N,e[21]=B,e[22]=y,e[23]=Q):Q=e[23];const _e=Q;let ne;e[24]!==m.x||e[25]!==m.y?(ne={left:m.x,top:m.y,transform:"translate(-50%, -100%)"},e[24]=m.x,e[25]=m.y,e[26]=ne):ne=e[26];let Te;e[27]!==N||e[28]!==R?(Te=N&&R&&R.length>0?Ei.createPortal(r.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:R.map(Ul)}),document.body):null,e[27]=N,e[28]=R,e[29]=Te):Te=e[29];let De;e[30]!==N||e[31]!==a||e[32]!==_e||e[33]!==G||e[34]!==H||e[35]!==f?(De=N?r.jsx("div",{className:"w-[min(420px,80vw)]",children:r.jsx(Bl,{fileLabel:a,lineRange:_e?{start:_e.start,end:_e.end}:void 0,onSave:H,onCancel:L})}):r.jsx("div",{className:W("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:G,className:W("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:f("chat.textSelection.title.commentOnSelection"),children:f("chat.textSelection.actions.comment")})}),e[30]=N,e[31]=a,e[32]=_e,e[33]=G,e[34]=H,e[35]=f,e[36]=De):De=e[36];let ze;return e[37]!==ne||e[38]!==Te||e[39]!==De?(ze=Ei.createPortal(r.jsxs("div",{ref:l,className:"fixed z-50",style:ne,children:[Te,De]}),document.body),e[37]=ne,e[38]=Te,e[39]=De,e[40]=ze):ze=e[40],ze}function Ul(n,e){return r.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:n.left,top:n.top,width:n.width,height:n.height}},e)}function Kl(){Ko()}function Hl(n){return n.trim()}function ql(n){const e=n.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Gl)}function Gl(n){return n.length>=8}function Xl(n){return n.addDraft}function Jl(n){return n.newSessionDraft?.open}function Yl(n){return n.currentSessionId}const Zl=(n,e)=>{if(!e)return null;const t=Number.parseInt(n.trim(),10);return!Number.isFinite(t)||t<1?null:Math.min(t,e.state.doc.lines)},Wi=(n,e)=>{const t=n.state.doc.lineAt(e.main.head);return{lineNumber:t.number,character:e.main.head-t.from+1,selection:e}},Ui=(n,e,t)=>{const a=n.state.doc.line(e),w=Math.max(1,Math.min(t,a.length+1)),f=a.from+w-1;n.dispatch({selection:Fl.cursor(f),effects:Lt.scrollIntoView(f,{y:"center"})})};function Ql({open:n,onOpenChange:e,view:t,variant:a="overlay"}){const{t:w}=st(),[f,v]=i.useState(""),d=i.useRef(null),x=i.useRef(!1),g=i.useRef(null),m=i.useRef(null),b=i.useMemo(()=>Zl(f,t),[f,t]);i.useEffect(()=>{!n||!t||(x.current=!1,d.current=Wi(t,t.state.selection),v(""))},[n,t]),i.useEffect(()=>{n&&window.requestAnimationFrame(()=>{m.current?.focus(),m.current?.select()})},[n]),i.useEffect(()=>{if(!(!n||!t||!d.current)){if(b===null){const{selection:p}=d.current;t.dispatch({selection:p,effects:Lt.scrollIntoView(p.main.from,{y:"center"})});return}Ui(t,b,d.current.character)}},[b,n,t]);const y=i.useCallback(()=>{if(!t||x.current||!d.current)return;const{selection:p}=d.current;t.dispatch({selection:p,effects:Lt.scrollIntoView(p.main.from,{y:"center"})})},[t]),C=i.useCallback(p=>{p||y(),e(p)},[e,y]),N=i.useCallback(()=>{!t||b===null||!d.current||(x.current=!0,Ui(t,b,d.current.character),e(!1),t.focus())},[b,e,t]);i.useEffect(()=>{if(!n)return;const p=T=>{const R=g.current,M=T.target;!R||!(M instanceof Node)||R.contains(M)||C(!1)},l=T=>{T.key==="Escape"&&(T.preventDefault(),C(!1))};return document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("pointerdown",p,!0),document.removeEventListener("keydown",l,!0)}},[C,n,a]);const F=i.useMemo(()=>{if(!t)return w("goToLineDialog.helper.editorUnavailable");if(b===null){const p=d.current??Wi(t,t.state.selection);return w("goToLineDialog.helper.currentLineRange",{current:p.lineNumber,max:t.state.doc.lines})}return w("goToLineDialog.helper.goToLine",{line:b})},[b,w,t]);return a==="inline"?n?r.jsxs("div",{ref:g,className:"ml-1 flex h-6 items-center gap-1",children:[r.jsx(Fs,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:p=>v(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),N())},placeholder:w("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),r.jsx(I,{variant:"outline",size:"xs",onClick:N,disabled:!t||b===null,className:"h-6 px-2",children:w("goToLineDialog.actions.go")})]}):null:r.jsx("div",{ref:g,className:W("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",n?"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(Fs,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:p=>v(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),N())},placeholder:w("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/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:F})]})})}const ec=(n,e)=>{const t=e.trim().toLowerCase(),a=[];if(!t)return a;const w=n.toLowerCase();let f=0;for(;;){const v=w.indexOf(t,f);if(v===-1)break;a.push({start:v,end:v+t.length}),f=v+t.length}return a},mr="data-md-find",Jr="data-md-find-current",ca="rounded-[2px] bg-status-warning/30 text-foreground",tc="rounded-[2px] bg-status-warning/60 text-foreground",sc=120,rc=n=>n instanceof Element&&n.hasAttribute(mr),nc=n=>n.target instanceof Element&&n.target.hasAttribute(mr)?!0:[...n.addedNodes].some(e=>rc(e)),ua=n=>{const e=new Set;n.querySelectorAll(`mark[${mr}]`).forEach(t=>{const a=t.parentNode;a&&(a.replaceChild(document.createTextNode(t.textContent??""),t),e.add(a))}),e.forEach(t=>t.normalize())},ic=(n,e)=>{ua(n);const t=e.trim().toLowerCase();if(!t)return[];const a=[],w=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode(v){const d=v.parentElement;return!d||d.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),f=[];for(;w.nextNode();){const v=w.currentNode;v instanceof Text&&f.push(v)}for(const v of f){const d=v.nodeValue??"";if(!d)continue;const x=ec(d,t);if(x.length===0)continue;const g=v.parentNode;if(!g)continue;const m=document.createDocumentFragment();let b=0;for(const y of x){y.start>b&&m.appendChild(document.createTextNode(d.slice(b,y.start)));const C=document.createElement("mark");C.setAttribute(mr,""),C.className=ca,C.textContent=d.slice(y.start,y.end),m.appendChild(C),a.push(C),b=y.end}b<d.length&&m.appendChild(document.createTextNode(d.slice(b))),g.replaceChild(m,v)}return a},Ki=({containerRef:n,open:e,onOpenChange:t,focusNonce:a,className:w})=>{const{t:f}=st(),[v,d]=i.useState(""),[x,g]=i.useState(0),[m,b]=i.useState(0),y=i.useRef(null),C=i.useRef([]),N=i.useRef(v);N.current=v;const F=i.useRef(null),p=i.useRef(null),l=i.useCallback((k,V=!1)=>{const z=n.current;if(!z){C.current=[],g(0),b(0);return}C.current=ic(z,k);const B=C.current.length;g(B),b(U=>!V||B===0?0:Math.min(U,B-1))},[n]),T=i.useCallback((k,V=!1)=>{F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{F.current=null,l(k,V)},sc)},[l]);i.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]);const R=i.useCallback(()=>{t(!1);const k=p.current;p.current=null,k?.isConnected&&k.focus()},[t]);i.useEffect(()=>{const k=n.current;if(!e||!k)return;const V=new MutationObserver(z=>{!N.current.trim()||!z.some(U=>!nc(U))||T(N.current,!0)});return V.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{V.disconnect(),ua(k)}},[n,e,T]),i.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!p.current&&(p.current=k),y.current?.focus()},[e]),i.useEffect(()=>{e&&a>0&&(y.current?.focus(),y.current?.select())},[e,a]),i.useEffect(()=>{const k=n.current;if(!k||(k.querySelectorAll(`mark[${Jr}]`).forEach(z=>{z.removeAttribute(Jr),z.className=ca}),x===0))return;const V=C.current[Math.min(Math.max(m,0),x-1)];V&&(V.setAttribute(Jr,""),V.className=tc,V.scrollIntoView({block:"nearest"}))},[n,m,x]);const M=i.useCallback(()=>{b(k=>x===0?0:(k+1)%x)},[x]),D=i.useCallback(()=>{b(k=>x===0?0:(k-1+x)%x)},[x]),L=i.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?D():M()):k.key==="Escape"&&(k.preventDefault(),R())},[R,M,D]);return e?r.jsxs("div",{className:W("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",w),children:[r.jsx(E,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),r.jsx(Fs,{ref:y,value:v,onChange:k=>{d(k.target.value),T(k.target.value)},onKeyDown:L,placeholder:f("filesView.preview.find.placeholder"),"aria-label":f("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":x>0?f("filesView.preview.find.countAria",{current:m+1,total:x}):f("filesView.preview.find.noMatches"),children:v.trim()&&x===0?f("filesView.preview.find.noMatches"):x>0?`${m+1}/${x}`:""}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:f("filesView.preview.find.previousAria"),"aria-label":f("filesView.preview.find.previousAria"),disabled:x===0,children:r.jsx(E,{name:"arrow-up",className:"size-3.5"})}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:f("filesView.preview.find.nextAria"),"aria-label":f("filesView.preview.find.nextAria"),disabled:x===0,children:r.jsx(E,{name:"arrow-down",className:"size-3.5"})}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:R,title:f("filesView.preview.find.closeAria"),"aria-label":f("filesView.preview.find.closeAria"),children:r.jsx(E,{name:"close",className:"size-3.5"})})]}):null},ac=n=>{let e=!0;return{poll:async()=>{if(!e||n.isDirty())return!1;const t=n.getLoadedContent(),a=n.getLoadedRevision();try{const w=await n.readContent();if(!e||n.isDirty()||a!==n.getLoadedRevision())return!1;if(w===t)return!0;const f=await n.readContent();return!e||n.isDirty()||f!==w||a!==n.getLoadedRevision()?!1:(n.applyContent(w),!0)}catch{return!1}},dispose:()=>{e=!1}}},oc=1,lc=(n,e)=>e.size!==n.size||e.mtimeMs!==void 0&&n.mtimeMs!==void 0&&Math.abs(e.mtimeMs-n.mtimeMs)>=oc;function Hi(){const n=Re.c(8),[e]=ht.useState(cc),t=ht.useRef(!1);let a;n[0]!==e?(a=x=>{if(x==null){e.cleanUp(),t.current=!1;return}t.current||(t.current=!0,e.setup(x,x.firstElementChild??void 0))},n[0]=e,n[1]=a):a=n[1];const w=a;let f,v;n[2]!==e?(f=()=>()=>{t.current=!1,e.cleanUp()},v=[e],n[2]=e,n[3]=f,n[4]=v):(f=n[3],v=n[4]),ht.useLayoutEffect(f,v);let d;return n[5]!==w||n[6]!==e?(d={virtualizer:e,setScroller:w},n[5]=w,n[6]=e,n[7]=d):d=n[7],d}function cc(){return new Pl}const rs=new Map,uc=100;function lr(n){const[e,t]=ht.useState(null),a=ht.useRef(null),w=ht.useRef(null),f=ht.useRef(null),v=ht.useCallback((d,x)=>{d&&x instanceof Cl&&(f.current={key:n,file:x,node:d});const g=a.current,m=w.current,b=()=>{a.current===g&&(g?.(),m?.())};x?queueMicrotask(b):b()},[n]);return ht.useLayoutEffect(()=>{if(!e||!n)return;const d=rs.get(n)??{top:0,left:0};let x=!0;const g=()=>f.current?.key===n?f.current.file:null,m=l=>f.current?.key===n?f.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${l-1}"]`):null,b=()=>{C.disconnect(),N.disconnect()},y=()=>{if(!x)return;const l=g(),T=d.line&&l?.getLinePosition(d.line.number),R=d.line&&m(d.line.number);let M=d.top;d.line&&T&&(M=(l?.top??0)+T.top-d.line.offset),d.line&&R&&(M=e.scrollTop+R.getBoundingClientRect().top-e.getBoundingClientRect().top-d.line.offset),e.scrollTop=M,e.scrollLeft=d.left,(!d.line||R)&&Math.abs(e.scrollTop-M)<1&&Math.abs(e.scrollLeft-d.left)<1&&(x=!1,b())},C=new ResizeObserver(y),N=new MutationObserver(()=>{if(x){for(const l of e.children)C.observe(l);y()}});C.observe(e);for(const l of e.children)C.observe(l);N.observe(e,{childList:!0,subtree:!0});const F=()=>{if(x)return;const l=g(),T=l?.getNumericScrollAnchor(e.scrollTop-(l.top??0)),R=T&&m(T.lineNumber),M=R?R.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(rs.delete(n),rs.set(n,{top:e.scrollTop,left:e.scrollLeft,line:T&&M!==null&&M>=0&&M<e.clientHeight?{number:T.lineNumber,offset:M}:void 0}),rs.size>uc){const D=rs.keys().next().value;D!==void 0&&rs.delete(D)}},p=()=>{x=!1,b()};return a.current=y,w.current=F,y(),e.addEventListener("scroll",F,{passive:!0}),e.addEventListener("wheel",p,{passive:!0}),e.addEventListener("touchstart",p,{passive:!0}),e.addEventListener("pointerdown",p,{passive:!0}),e.addEventListener("keydown",p),()=>{a.current=null,w.current=null,f.current?.key===n&&(f.current=null),b(),e.removeEventListener("scroll",F),e.removeEventListener("wheel",p),e.removeEventListener("touchstart",p),e.removeEventListener("pointerdown",p),e.removeEventListener("keydown",p)}},[n,e]),{setScroller:t,restore:v}}function dc(n){return!(!n.autoSaveEnabled||!n.isDirty||!n.canWrite||n.isSaving||n.fileLoading||n.isNonEditableBinary||!n.selectedFilePath||n.loadedFilePath!==n.selectedFilePath)}function fc(n){return n.selectedFilePath?n.isDirty?!(n.fileLoading||n.loadedFilePath!==n.selectedFilePath||n.isNonEditableBinary||n.draftContent===""&&n.fileContent!==""&&n.loadedFilePath!==n.selectedFilePath):!0:!1}const da=2e5,mc=n=>{let e=0,t=0;for(let a=0;a<n.length;a++)n.charCodeAt(a)===10&&(a>0&&n.charCodeAt(a-1)===13?e++:t++);return e>t?`\r