@openchamber/web 1.21.0 → 1.21.1
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.
- package/bin/cli.test.js +35 -0
- package/bin/lib/DOCUMENTATION.md +12 -0
- package/bin/lib/cli-settings-accessors.js +111 -0
- package/bin/lib/cli-settings-accessors.test.js +189 -0
- package/bin/lib/cli-startup.js +29 -9
- package/bin/lib/commands-connect-url.js +12 -14
- package/dist/assets/{CodeMirrorCommentWidgets-C2BopIs3.js → CodeMirrorCommentWidgets-BGj8TJxW.js} +1 -1
- package/dist/assets/CommitSection-DwGiXyjf.js +1 -0
- package/dist/assets/{DiffView-D5cvbEPb.js → DiffView-Db6bjVv1.js} +3 -3
- package/dist/assets/FilesView-DQOa7Lgz.js +17 -0
- package/dist/assets/GitView-CHzJxTi0.js +6 -0
- package/dist/assets/{JsonTreeView-osju7J70.js → JsonTreeView-CggOsLot.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DoZpaHev.js +1 -0
- package/dist/assets/MarkdownRendererImpl-B5Y5xCOz.js +12 -0
- package/dist/assets/{OnboardingScreen-w2VG4fWY.js → OnboardingScreen-C98d69Fp.js} +1 -1
- package/dist/assets/{PatchDiff-Dan3mADn.js → PatchDiff-DJYMUiXA.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CGoI2v0q.js → PierreDiffViewer-CY2bx_SB.js} +3 -3
- package/dist/assets/PlanView-PkiOY_9H.js +5 -0
- package/dist/assets/SettingsView-D-K3ELCM.js +28 -0
- package/dist/assets/{SettingsWindow-DXF-MTHG.js → SettingsWindow-oyOm2fHR.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DrCa1JRk.js → ToolOutputDialog-lKyeQTPL.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-B_tfvlNF.js → ToolPartDiffPreview-C7kBQNAA.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-CN_BctrR.js → VirtualizedFileDiff-BP7ebDFF.js} +1 -1
- package/dist/assets/{WalkthroughView-D9Q4lr5x.js → WalkthroughView-MuJodAHD.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-Gi1d5eU1.js → computeVirtualFileMetrics-CZ0xPeaT.js} +1 -1
- package/dist/assets/{contextPanelEmbeddedChat-CpzVNWAv.js → contextPanelEmbeddedChat-C9abMBTb.js} +1 -1
- package/dist/assets/de-CEoCz3j6.js +9 -0
- package/dist/assets/es-DwyXCqaL.js +15 -0
- package/dist/assets/{fr-5qJM0nFS.js → fr-CS7Csln9.js} +5 -5
- package/dist/assets/index-CUKcHnUA.css +1 -0
- package/dist/assets/{index-Brm3X9rs.js → index-CaPAjwXQ.js} +1 -1
- package/dist/assets/index-DIvDEKE-.js +7 -0
- package/dist/assets/{isDiffPlainText-pH9kAJQH.js → isDiffPlainText-ZBvDxhVB.js} +1 -1
- package/dist/assets/{isFilePlainText-CVKy_dgB.js → isFilePlainText-DiLRrkJr.js} +1 -1
- package/dist/assets/ja-vnwqLcx6.js +15 -0
- package/dist/assets/ko-CXuSfZv5.js +15 -0
- package/dist/assets/{main-vUCh0VB0.js → main-D5RWr6sJ.js} +2 -2
- package/dist/assets/main-DLlfDjQ_.js +926 -0
- package/dist/assets/{markdown-shiki.worker-CKGJ1J33.js → markdown-shiki.worker-D5fBU-lw.js} +5 -5
- package/dist/assets/markdownCore-CcTcLsQF.js +3 -0
- package/dist/assets/{miniChat-BlzGEYgE.js → miniChat-CqR3icsk.js} +2 -2
- package/dist/assets/{mobile-CkX6H-IT.js → mobile-RN_UTTlB.js} +2 -2
- package/dist/assets/{patchFileDiff-BCTsE43U.js → patchFileDiff-CjRR5ESs.js} +3 -3
- package/dist/assets/pl-BJxry0Mi.js +15 -0
- package/dist/assets/pt-BR-DxLmkhdv.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-CJYe_KOL.js → renderElectronMiniChatApp-1wC94fQK.js} +2 -2
- package/dist/assets/renderMobileApp-ltva2Plg.js +25 -0
- package/dist/assets/runtimeEndpointReset-D6SmNZaP.js +15 -0
- package/dist/assets/{scheduledTasksApi-CAGPh_gZ.js → scheduledTasksApi-mjMDet_H.js} +1 -1
- package/dist/assets/{shikiHighlight-BgTPSITe.js → shikiHighlight-fGmFkxAM.js} +1 -1
- package/dist/assets/tr-5Mk_hQ2Q.js +6 -0
- package/dist/assets/uk-ClgQjmlw.js +15 -0
- package/dist/assets/{useAppFontEffects-Cll4gnsh.js → useAppFontEffects-KP8_yiGW.js} +143 -141
- package/dist/assets/{useInlineCommentController-DFFv0hae.js → useInlineCommentController-HIjtuhxD.js} +2 -2
- package/dist/assets/useRootScrollLock-BSiQ5F75.js +1 -0
- package/dist/assets/{vendor-base-ui-_6j2xOWl.js → vendor-base-ui-BeMD8X_w.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DkQX2EBa.js → vendor-codemirror-language-data-DrTPkHl4.js} +2 -2
- package/dist/assets/{vendor-floating-ui-core-CXmKXOXc.js → vendor-floating-ui-core-PuGzNPnN.js} +1 -1
- package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-BTvzWks8.js} +1 -1
- package/dist/assets/{vendor-floating-ui-react-dom-DKpLs02S.js → vendor-floating-ui-react-dom-DxYCWdHj.js} +1 -1
- package/dist/assets/{vendor-floating-ui-utils-BzXdqYpP.js → vendor-floating-ui-utils-D6FqdtJt.js} +1 -1
- package/dist/assets/vendor-linkify-it-DZCzzDkK.js +1 -0
- package/dist/assets/vendor-marked-linkify-it-CXI_LHIE.js +1 -0
- package/dist/assets/vendor-uc.micro-BAd0H0z4.js +1 -0
- package/dist/assets/{web-components-DLnGY4fs.js → web-components-DOXvU-tB.js} +1 -1
- package/dist/assets/zh-CN-Ba6y8H-i.js +15 -0
- package/dist/assets/zh-TW-Dv8yyhN1.js +15 -0
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/dist/site.webmanifest +1 -1
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/public/site.webmanifest +1 -1
- package/server/index.js +2 -2
- package/server/lib/cloudflare-tunnel.js +1 -1
- package/server/lib/fs/DOCUMENTATION.md +1 -0
- package/server/lib/fs/routes.js +21 -0
- package/server/lib/fs/routes.test.js +89 -3
- package/server/lib/git/DOCUMENTATION.md +4 -3
- package/server/lib/git/service.js +128 -6
- package/server/lib/git/service.test.js +191 -1
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +3 -1
- package/server/lib/markdown-image-grants/routes.test.js +14 -0
- package/server/lib/openchamber-sessions/routes.js +4 -1
- package/server/lib/openchamber-sessions/routes.test.js +23 -0
- package/server/lib/opencode/env-runtime.js +17 -1
- package/server/lib/opencode/env-runtime.test.js +56 -0
- package/server/lib/opencode/lifecycle.js +48 -9
- package/server/lib/opencode/lifecycle.test.js +125 -1
- package/server/lib/opencode/managed-process-registry.d.ts +13 -0
- package/server/lib/opencode/managed-process-registry.js +213 -163
- package/server/lib/opencode/managed-process-registry.test.mjs +285 -0
- package/server/lib/opencode/project-directory-runtime.js +16 -11
- package/server/lib/opencode/project-directory-runtime.test.js +32 -12
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +96 -12
- package/server/lib/opencode/routes.js +53 -5
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +10 -0
- package/server/lib/opencode/theme-runtime.js +1 -1
- package/server/lib/opencode/theme-runtime.test.js +129 -0
- package/server/lib/quota/DOCUMENTATION.md +19 -0
- package/server/lib/quota/providers/copilot.js +26 -10
- package/server/lib/quota/providers/copilot.test.js +78 -0
- package/server/lib/small-model/DOCUMENTATION.md +11 -5
- package/server/lib/small-model/call.js +64 -20
- package/server/lib/small-model/call.test.js +184 -2
- package/server/lib/tunnels/install-help.js +2 -2
- package/server/lib/tunnels/install-help.test.js +9 -0
- package/server/lib/walkthrough/languages.js +1 -0
- package/dist/assets/CommitSection-HJeMUAWb.js +0 -1
- package/dist/assets/FilesView-DPU8aNPL.js +0 -17
- package/dist/assets/GitView-Ct6xWrVH.js +0 -6
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +0 -12
- package/dist/assets/PlanView-Dgg-WTEc.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +0 -1
- package/dist/assets/SettingsView-D9yRuFZw.js +0 -28
- package/dist/assets/de-B_LdJwEM.js +0 -9
- package/dist/assets/es-CubfsAYV.js +0 -15
- package/dist/assets/index-BW82eK5v.css +0 -1
- package/dist/assets/index-rlLjZUM5.js +0 -7
- package/dist/assets/ja-DJYIBUlH.js +0 -15
- package/dist/assets/ko-DcUBkB7y.js +0 -15
- package/dist/assets/main-DLBxKIoX.js +0 -926
- package/dist/assets/markdownCore-DG6GHLF4.js +0 -3
- package/dist/assets/pl-rB6BLcio.js +0 -15
- package/dist/assets/pt-BR-DcwtlO-o.js +0 -15
- package/dist/assets/renderMobileApp-hQJTnr8B.js +0 -25
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +0 -15
- package/dist/assets/uk-INZlFD9A.js +0 -15
- package/dist/assets/zh-CN-Dzda8xa1.js +0 -15
- package/dist/assets/zh-TW-Cwn3rNYZ.js +0 -15
|
@@ -5,11 +5,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
5
5
|
|
|
6
6
|
// readConfig reads merged opencode config layers from disk; mock it so each
|
|
7
7
|
// test controls the provider config without touching the filesystem. call.js
|
|
8
|
-
// imports
|
|
9
|
-
// untouched for this file.
|
|
8
|
+
// imports the config readers and a plain-object predicate from shared.js, so
|
|
9
|
+
// the rest of that module is left untouched for this file.
|
|
10
10
|
vi.mock('../opencode/shared.js', () => ({
|
|
11
11
|
readConfig: vi.fn(),
|
|
12
12
|
readConfigLayers: vi.fn(),
|
|
13
|
+
// Pure predicate with no disk access — the real implementation, so header
|
|
14
|
+
// parsing is exercised rather than stubbed.
|
|
15
|
+
isPlainObject: (value) => value instanceof Object && !Array.isArray(value),
|
|
13
16
|
}));
|
|
14
17
|
|
|
15
18
|
vi.mock('./runtime-providers.js', () => ({ getRuntimeProvider: vi.fn(async () => null) }));
|
|
@@ -67,6 +70,7 @@ describe('callSmallModel — custom provider config', () => {
|
|
|
67
70
|
globalThis.fetch = originalFetch;
|
|
68
71
|
vi.restoreAllMocks();
|
|
69
72
|
delete process.env.OPENCHAMBER_TEST_PROVIDER_KEY;
|
|
73
|
+
delete process.env.OPENCHAMBER_TEST_GATEWAY_KEY;
|
|
70
74
|
});
|
|
71
75
|
|
|
72
76
|
describe('config-supplied credentials (no auth.json entry)', () => {
|
|
@@ -122,6 +126,105 @@ describe('callSmallModel — custom provider config', () => {
|
|
|
122
126
|
expect(lastCall(fetchMock).init.headers.Authorization).toBe('Bearer sk-env-key');
|
|
123
127
|
});
|
|
124
128
|
|
|
129
|
+
it('sends configured provider headers alongside the bearer token', async () => {
|
|
130
|
+
process.env.OPENCHAMBER_TEST_GATEWAY_KEY = 'sub-key';
|
|
131
|
+
readConfig.mockReturnValue({
|
|
132
|
+
provider: {
|
|
133
|
+
custom: {
|
|
134
|
+
options: {
|
|
135
|
+
apiKey: 'sk-config',
|
|
136
|
+
baseURL: 'https://proxy.example.test/v1',
|
|
137
|
+
headers: {
|
|
138
|
+
'Ocp-Apim-Subscription-Key': '{env:OPENCHAMBER_TEST_GATEWAY_KEY}',
|
|
139
|
+
'x-tenant': 'team',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
fetchMock.mockResolvedValue(ok('hello'));
|
|
146
|
+
|
|
147
|
+
await callSmallModel({
|
|
148
|
+
auth: {},
|
|
149
|
+
catalog: {},
|
|
150
|
+
workingDirectory: '/proj',
|
|
151
|
+
providerID: 'custom',
|
|
152
|
+
modelID: 'model',
|
|
153
|
+
prompt: 'hi',
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const { init } = lastCall(fetchMock);
|
|
157
|
+
expect(init.headers['Ocp-Apim-Subscription-Key']).toBe('sub-key');
|
|
158
|
+
expect(init.headers['x-tenant']).toBe('team');
|
|
159
|
+
expect(init.headers.Authorization).toBe('Bearer sk-config');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('resolves a relative header file from the config layer that defines it', async () => {
|
|
163
|
+
const configPath = '/config/opencode.json';
|
|
164
|
+
const secretPath = '/config/gateway-key';
|
|
165
|
+
vi.spyOn(fs, 'readFileSync').mockImplementation((filePath) => {
|
|
166
|
+
if (filePath === secretPath) return 'sub-key\n';
|
|
167
|
+
throw new Error(`Unexpected file read: ${filePath}`);
|
|
168
|
+
});
|
|
169
|
+
const provider = {
|
|
170
|
+
custom: {
|
|
171
|
+
options: {
|
|
172
|
+
apiKey: 'sk-config',
|
|
173
|
+
baseURL: 'https://proxy.example.test/v1',
|
|
174
|
+
headers: { 'x-gateway-key': '{file:./gateway-key}' },
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
readConfig.mockReturnValue({ provider });
|
|
179
|
+
readConfigLayers.mockReturnValue({
|
|
180
|
+
customConfig: {},
|
|
181
|
+
projectConfig: {},
|
|
182
|
+
userConfig: { provider },
|
|
183
|
+
paths: { customPath: null, projectPath: '/project/opencode.json', userPath: configPath },
|
|
184
|
+
});
|
|
185
|
+
fetchMock.mockResolvedValue(ok('hello'));
|
|
186
|
+
|
|
187
|
+
await callSmallModel({
|
|
188
|
+
auth: {},
|
|
189
|
+
catalog: {},
|
|
190
|
+
workingDirectory: '/project',
|
|
191
|
+
providerID: 'custom',
|
|
192
|
+
modelID: 'model',
|
|
193
|
+
prompt: 'hi',
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
expect(lastCall(fetchMock).init.headers['x-gateway-key']).toBe('sub-key');
|
|
197
|
+
expect(fs.readFileSync).toHaveBeenCalledWith(secretPath, 'utf8');
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('overrides Authorization without depending on header-name casing', async () => {
|
|
201
|
+
readConfig.mockReturnValue({
|
|
202
|
+
provider: {
|
|
203
|
+
custom: {
|
|
204
|
+
options: {
|
|
205
|
+
apiKey: 'sk-config',
|
|
206
|
+
baseURL: 'https://proxy.example.test/v1',
|
|
207
|
+
headers: { authorization: 'Basic gateway-token' },
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
fetchMock.mockResolvedValue(ok('hello'));
|
|
213
|
+
|
|
214
|
+
await callSmallModel({
|
|
215
|
+
auth: {},
|
|
216
|
+
catalog: {},
|
|
217
|
+
workingDirectory: '/project',
|
|
218
|
+
providerID: 'custom',
|
|
219
|
+
modelID: 'model',
|
|
220
|
+
prompt: 'hi',
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const headers = lastCall(fetchMock).init.headers;
|
|
224
|
+
expect(headers.authorization).toBe('Basic gateway-token');
|
|
225
|
+
expect(headers.Authorization).toBeUndefined();
|
|
226
|
+
});
|
|
227
|
+
|
|
125
228
|
it('uses apiKey and baseURL from provider config when no auth.json entry exists', async () => {
|
|
126
229
|
readConfig.mockReturnValue({
|
|
127
230
|
provider: {
|
|
@@ -316,6 +419,69 @@ describe('callSmallModel — custom provider config', () => {
|
|
|
316
419
|
});
|
|
317
420
|
});
|
|
318
421
|
|
|
422
|
+
describe('anthropic provider custom baseURL override', () => {
|
|
423
|
+
const anthropicOk = (text) => ({
|
|
424
|
+
ok: true,
|
|
425
|
+
status: 200,
|
|
426
|
+
json: async () => ({ content: [{ type: 'text', text }] }),
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it('respects provider.anthropic.options.baseURL over the hardcoded Anthropic endpoint', async () => {
|
|
430
|
+
readConfig.mockReturnValue({
|
|
431
|
+
provider: { anthropic: { options: { baseURL: 'http://127.0.0.1:3456/v1' } } },
|
|
432
|
+
});
|
|
433
|
+
fetchMock.mockResolvedValue(anthropicOk('ok'));
|
|
434
|
+
|
|
435
|
+
await callSmallModel({
|
|
436
|
+
auth: { anthropic: { type: 'api', key: 'dummy' } },
|
|
437
|
+
catalog: {},
|
|
438
|
+
workingDirectory: '/proj',
|
|
439
|
+
providerID: 'anthropic',
|
|
440
|
+
modelID: 'claude-haiku-4-5',
|
|
441
|
+
prompt: 'hi',
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const { url, init } = lastCall(fetchMock);
|
|
445
|
+
expect(url).toBe('http://127.0.0.1:3456/v1/messages');
|
|
446
|
+
expect(url).not.toContain('api.anthropic.com');
|
|
447
|
+
expect(init.headers['x-api-key']).toBe('dummy');
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it('uses a bare-host baseURL as-is without inserting /v1, matching @ai-sdk/anthropic', async () => {
|
|
451
|
+
readConfig.mockReturnValue({
|
|
452
|
+
provider: { anthropic: { options: { baseURL: 'http://127.0.0.1:3456' } } },
|
|
453
|
+
});
|
|
454
|
+
fetchMock.mockResolvedValue(anthropicOk('ok'));
|
|
455
|
+
|
|
456
|
+
await callSmallModel({
|
|
457
|
+
auth: { anthropic: { type: 'api', key: 'dummy' } },
|
|
458
|
+
catalog: {},
|
|
459
|
+
workingDirectory: '/proj',
|
|
460
|
+
providerID: 'anthropic',
|
|
461
|
+
modelID: 'claude-haiku-4-5',
|
|
462
|
+
prompt: 'hi',
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
expect(lastCall(fetchMock).url).toBe('http://127.0.0.1:3456/messages');
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('falls back to https://api.anthropic.com when no anthropic baseURL override is configured', async () => {
|
|
469
|
+
readConfig.mockReturnValue({});
|
|
470
|
+
fetchMock.mockResolvedValue(anthropicOk('ok'));
|
|
471
|
+
|
|
472
|
+
await callSmallModel({
|
|
473
|
+
auth: { anthropic: { type: 'api', key: 'sk-ant' } },
|
|
474
|
+
catalog: {},
|
|
475
|
+
workingDirectory: '/proj',
|
|
476
|
+
providerID: 'anthropic',
|
|
477
|
+
modelID: 'claude-haiku-4-5',
|
|
478
|
+
prompt: 'hi',
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
expect(lastCall(fetchMock).url).toBe('https://api.anthropic.com/v1/messages');
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
|
|
319
485
|
describe('catalog-based base URL (no config override)', () => {
|
|
320
486
|
it('uses the catalog api field when no config baseURL is set', async () => {
|
|
321
487
|
readConfig.mockReturnValue({});
|
|
@@ -536,6 +702,22 @@ describe('callSmallModel — Google thinking configuration', () => {
|
|
|
536
702
|
const body = JSON.parse(lastCall(fetchMock).init.body);
|
|
537
703
|
expect(body.generationConfig.thinkingConfig).toEqual({ thinkingBudget: 0 });
|
|
538
704
|
});
|
|
705
|
+
|
|
706
|
+
it('omits thinkingConfig for other Google/Gemini models', async () => {
|
|
707
|
+
fetchMock.mockResolvedValue(googleResponse('generated commit'));
|
|
708
|
+
|
|
709
|
+
await callSmallModel({
|
|
710
|
+
auth: { google: { type: 'api', key: 'google-key' } },
|
|
711
|
+
catalog: {},
|
|
712
|
+
workingDirectory: '/proj',
|
|
713
|
+
providerID: 'google',
|
|
714
|
+
modelID: 'gemini-1.5-flash',
|
|
715
|
+
prompt: 'generate',
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
const body = JSON.parse(lastCall(fetchMock).init.body);
|
|
719
|
+
expect(body.generationConfig.thinkingConfig).toBeUndefined();
|
|
720
|
+
});
|
|
539
721
|
});
|
|
540
722
|
|
|
541
723
|
describe('callSmallModel — GitHub Copilot endpoint routing', () => {
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
const PROVIDER_INSTALL_INFO = {
|
|
7
7
|
[TUNNEL_PROVIDER_CLOUDFLARE]: {
|
|
8
8
|
dependency: 'cloudflared',
|
|
9
|
-
installUrl: 'https://developers.cloudflare.com/cloudflare-one/networks/connectors/
|
|
9
|
+
installUrl: 'https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/',
|
|
10
10
|
commands: {
|
|
11
11
|
darwin: 'brew install cloudflared',
|
|
12
12
|
win32: 'winget install --id Cloudflare.cloudflared',
|
|
13
|
-
linux: 'Download cloudflared from https://developers.cloudflare.com/cloudflare-one/networks/connectors/
|
|
13
|
+
linux: 'Download cloudflared from https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
[TUNNEL_PROVIDER_NGROK]: {
|
|
@@ -28,4 +28,13 @@ describe('getTunnelDependencyInstallInfo', () => {
|
|
|
28
28
|
|
|
29
29
|
expect(info.installCommand).toBe('brew install cloudflared');
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it('returns the current Linux cloudflared download guidance', () => {
|
|
33
|
+
const info = getTunnelDependencyInstallInfo(TUNNEL_PROVIDER_CLOUDFLARE, 'linux');
|
|
34
|
+
const downloadUrl = 'https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/';
|
|
35
|
+
|
|
36
|
+
expect(info.installUrl).toBe(downloadUrl);
|
|
37
|
+
expect(info.installCommand).toBe(`Download cloudflared from ${downloadUrl}`);
|
|
38
|
+
expect(info.message).toContain(downloadUrl);
|
|
39
|
+
});
|
|
31
40
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as S,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ve}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,am as ze,a4 as fe,a5 as me,I as $,a6 as ue,h as J,B as Z,$ as Ee,gR as Te,bz as pe,bA as ge,bB as xe,bC as be,bD as ye,bE as ve,bj as Ie}from"./useAppFontEffects-Cll4gnsh.js";import{u as Ce}from"./index-rlLjZUM5.js";const ke={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Me=ke.M;function Re(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function $e(p){const e=Re(p);return ke[e]??Me}const He=S.memo(function(e){const t=oe.c(58),{file:o,actionLabel:x,actionSymbol:b,onAction:m,onViewDiff:f,onRevert:l,isReverting:d,stats:z,rowPaddingClassName:g,indentPx:y,actionAtStart:V,showRevert:H}=e,j=y===void 0?0:y,r=V===void 0?!1:V,w=H===void 0?!0:H;let N;t[0]!==o?(N=$e(o),t[0]=o,t[1]=N):N=t[1];const h=N,{t:E}=Q(),F=h.description,M=z?.insertions??0,C=z?.deletions??0;let D;t[2]!==m||t[3]!==f?(D=U=>{U.key===" "?(U.preventDefault(),m()):U.key==="Enter"&&(U.preventDefault(),f())},t[2]=m,t[3]=f,t[4]=D):D=t[4];const A=D;let T;t[5]!==m?(T=U=>{U.preventDefault(),U.stopPropagation(),m()},t[5]=m,t[6]=T):T=t[6];const u=T;let P;t[7]!==l?(P=U=>{U.preventDefault(),U.stopPropagation(),l()},t[7]=l,t[8]=P):P=t[8];const W=P;let L;t[9]!==x||t[10]!==b||t[11]!==u?(L=s.jsx("button",{type:"button",onClick:u,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":x,title:x,children:b}),t[9]=x,t[10]=b,t[11]=u,t[12]=L):L=t[12];const R=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${g??"px-3"}`;let I;t[13]!==j?(I=j>0?{paddingLeft:`${j}px`}:void 0,t[13]=j,t[14]=I):I=t[14];const Y=r?R:null;let K;t[15]!==h.color?(K={color:h.color},t[15]=h.color,t[16]=K):K=t[16];let G;t[17]!==h.code||t[18]!==F||t[19]!==K?(G=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:F,"aria-label":F,children:h.code}),t[17]=h.code,t[18]=F,t[19]=K,t[20]=G):G=t[20];let O;t[21]!==o.path?(O=s.jsx(ze,{filePath:o.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=o.path,t[22]=O):O=t[22];let B;if(t[23]!==o.path){e:{const U=o.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],B=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:o.path,children:o.path});break e}const De=o.path.slice(0,U),Ae=o.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const re=s.jsx("span",{className:"text-foreground",children:Ae.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],B=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:o.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:De}),ie]})}t[23]=o.path,t[24]=B}else B=t[24];let q;t[30]===Symbol.for("react.memo_cache_sentinel")?(q={color:"var(--status-success)"},t[30]=q):q=t[30];let i;t[31]!==M?(i=s.jsxs("span",{style:q,children:["+",M]}),t[31]=M,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==C?(c=s.jsxs("span",{style:a,children:["-",C]}),t[35]=C,t[36]=c):c=t[36];let k;t[37]!==i||t[38]!==c?(k=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=k):k=t[39];let v;t[40]!==o.path||t[41]!==W||t[42]!==d||t[43]!==w||t[44]!==E?(v=w?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:d,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:o.path}),children:d?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx($,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=o.path,t[41]=W,t[42]=d,t[43]=w,t[44]=E,t[45]=v):v=t[45];const _=r?null:R;let ee;return t[46]!==A||t[47]!==f||t[48]!==I||t[49]!==Y||t[50]!==G||t[51]!==O||t[52]!==B||t[53]!==k||t[54]!==v||t[55]!==_||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:f,onKeyDown:A,style:I,children:[Y,G,O,B,k,v,_]}),t[46]=A,t[47]=f,t[48]=I,t[49]=Y,t[50]=G,t[51]=O,t[52]=B,t[53]=k,t[54]=v,t[55]=_,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const o=Se(t.path);if(!o)continue;const b=o.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),b.length>0){let f="";for(const l of b){f=f?`${f}/${l}`:l;const d=m.children.get(l);if(d){d.files.push(t),m=d;continue}const z=we(f,l);z.files.push(t),m.children.set(l,z),m=z}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],o=(x,b)=>{const m=Array.from(x.children.values()).sort((l,d)=>l.path.localeCompare(d.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:b,directory:l}),e.has(l.path)&&o(l,b+1);const f=[...x.directFiles].sort((l,d)=>l.path.localeCompare(d.path));for(const l of f)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:b,file:l})};return o(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:o=!1,headerBackgroundClassName:x="bg-sidebar",onVisiblePathsChange:b,onRevertAll:m,onRevertDirectory:f})=>{const{t:l}=Q(),d=S.useRef(null),g=Ce(i=>i.gitChangesViewMode)==="tree",y=S.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,H]=S.useState(new Set),[j,r]=S.useState(new Set),[w,N]=S.useState(!1),[h,E]=S.useState(null),F=S.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),M=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(F[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[F,y]);S.useEffect(()=>{g&&r(i=>{const n=new Set,a=new Set(M);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),M.forEach(c=>n.add(c)),n})},[g,M]);const C=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!V.has(n.id)){if(g){const c=new Set;j.forEach(v=>{v.startsWith(`${n.id} `)&&c.add(v.slice(n.id.length+1))}),Pe(F[a],c).forEach(v=>{v.kind==="file"?i.push({type:"file",key:`${n.id}:${v.key}`,groupIndex:a,file:v.file,depth:v.depth}):i.push({type:"directory",key:`${n.id}:${v.key}`,groupIndex:a,directory:v.directory,depth:v.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,j,g,m,F,y]),D=C.length,A=D>=Le,T=Ve({count:D,enabled:A,getScrollElement:()=>d.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>C[i]?.key??i}),u=T.getVirtualItems(),P=S.useMemo(()=>{if(!A)return 0;const i=d.current?.scrollTop??0;return u.find(a=>a.end>i)?.index??0},[A,u,d]);S.useEffect(()=>{if(!b)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(D===0){b([]);return}if(!A){const n=[];for(const a of C)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;b(n);return}b(C.slice(P,P+Math.ceil((d.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[b,D,C,A,P]);const W=S.useCallback(i=>{H(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),L=S.useCallback((i,n)=>{r(a=>{const c=new Set(a),k=de(i,n);return c.has(k)?c.delete(k):c.add(k),c})},[]),R=S.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),X=R.length,I=h?o||h.paths.some(i=>t.has(i)):!1,Y=S.useCallback(async()=>{!m||o||R.length===0||(await m(R),N(!1))},[R,o,m]),K=S.useCallback(async()=>{!f||!h||I||(await f(h.paths),E(null))},[I,f,h]),G=S.useCallback((i,n)=>{const a=V.has(i.id),c=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",x,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(k=>k.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!a,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),s.jsx($,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[V,x,W]),O=S.useCallback((i,n,a)=>{const c=j.has(de(i.id,n.path)),k=n.files.map(_=>_.path),v=o||k.some(_=>t.has(_));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx($,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx($,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&f?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:k,count:k.length}),disabled:v,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:v?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx($,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(_=>_.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[j,o,f,t,l,L]),B=S.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>N(!0),disabled:o,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx($,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return G(a,n);if(i.type==="directory")return O(a,i.directory,i.depth);const c=i.file;return s.jsx(He,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||o,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!g,showRevert:a.showRevertActions!==!1})},[e,o,g,O,G,t,l,y]),q=S.useCallback(i=>{const n=C[i],a=C[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[C]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Ee,{ref:d,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:A?s.jsx("div",{style:{height:T.getTotalSize(),position:"relative"},children:u.map(i=>{const n=C[i.index];return n?s.jsx("div",{"data-index":i.index,ref:T.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:B(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:C.map((i,n)=>s.jsx("div",{className:J("relative",q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:B(i,n===0)},i.key))})}),s.jsx(Te,{containerRef:d,disableHorizontal:!0})]}),s.jsx(pe,{open:w,onOpenChange:i=>{!o&&!i&&N(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:X===1?l("gitView.changes.revertAllDescriptionSingle",{count:X}):l("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>N(!1),disabled:o,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{Y()},disabled:o,children:l(o?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!h,onOpenChange:i=>{!I&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:h?h.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:h.count,path:h.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:h.count,path:h.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:I,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:I||!h,children:l(I?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(23),{value:t,onChange:o,onSubmit:x,placeholder:b,disabled:m,hasTouchInput:f,isMobile:l}=p,d=m===void 0?!1:m,z=f===void 0?!1:f,g=l===void 0?!1:l,{t:y}=Q(),V=S.useRef(null),H=Ce(Oe);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const u=V.current;if(!u)return;const P=document.activeElement===u,W=()=>{u.style.height=`${he}px`;const R=u.scrollHeight,X=Math.min(Math.max(R,he),ae);u.style.height=`${X}px`,u.style.overflowY=R>ae?"auto":"hidden",R>ae&&!P&&(u.scrollTop=u.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=j):j=e[0];let r;e[1]!==t?(r=[t],e[1]=t,e[2]=r):r=e[2],S.useLayoutEffect(j,r);let w;e[3]!==o?(w=u=>o(u.target.value),e[3]=o,e[4]=w):w=e[4];let N;e[5]!==x?(N=u=>{u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&!u.shiftKey&&!u.altKey&&(u.preventDefault(),x?.())},e[5]=x,e[6]=N):N=e[6];let h;e[7]!==b||e[8]!==y?(h=b??y("gitView.commit.messagePlaceholder"),e[7]=b,e[8]=y,e[9]=h):h=e[9];const E=z?"on":"off",F=z?"sentences":"off",M=g||H,C=d&&"opacity-50";let D;e[10]!==C?(D=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",C),e[10]=C,e[11]=D):D=e[11];let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A={minHeight:he,maxHeight:ae},e[12]=A):A=e[12];let T;return e[13]!==d||e[14]!==F||e[15]!==M||e[16]!==D||e[17]!==w||e[18]!==N||e[19]!==h||e[20]!==E||e[21]!==t?(T=s.jsx("textarea",{ref:V,value:t,onChange:w,onKeyDown:N,placeholder:h,rows:1,disabled:d,autoCorrect:E,autoCapitalize:F,spellCheck:M,className:D,style:A}),e[13]=d,e[14]=F,e[15]=M,e[16]=D,e[17]=w,e[18]=N,e[19]=h,e[20]=E,e[21]=t,e[22]=T):T=e[22],T};function Oe(p){return p.inputSpellcheckEnabled}const Ke=p=>{const e=oe.c(30),{highlights:t,onInsert:o}=p,{t:x}=Q();if(t.length===0)return null;let b;e[0]!==t||e[1]!==o?(b=()=>{o(t)},e[0]=t,e[1]=o,e[2]=b):b=e[2];const m=b;let f;e[3]!==x?(f=x("gitView.commit.aiHighlights.title"),e[3]=x,e[4]=f):f=e[4];let l;e[5]!==f?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:f}),e[5]=f,e[6]=l):l=e[6];let d;e[7]!==x?(d=x("gitView.commit.aiHighlights.insertAria"),e[7]=x,e[8]=d):d=e[8];let z;e[9]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx($,{name:"arrow-down",className:"size-4"}),e[9]=z):z=e[9];let g;e[10]!==m||e[11]!==d?(g=s.jsx(me,{asChild:!0,children:s.jsx(Z,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":d,children:z})}),e[10]=m,e[11]=d,e[12]=g):g=e[12];let y;e[13]!==x?(y=x("gitView.commit.aiHighlights.insertTooltip"),e[13]=x,e[14]=y):y=e[14];let V;e[15]!==y?(V=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=V):V=e[16];let H;e[17]!==g||e[18]!==V?(H=s.jsxs(fe,{children:[g,V]}),e[17]=g,e[18]=V,e[19]=H):H=e[19];let j;e[20]!==l||e[21]!==H?(j=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,H]}),e[20]=l,e[21]=H,e[22]=j):j=e[22];let r;e[23]!==t?(r=t.map(Be),e[23]=t,e[24]=r):r=e[24];let w;e[25]!==r?(w=s.jsx("ul",{className:"space-y-1",children:r}),e[25]=r,e[26]=w):w=e[26];let N;return e[27]!==j||e[28]!==w?(N=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[j,w]}),e[27]=j,e[28]=w,e[29]=N):N=e[29],N};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const qe=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:o,onCommitMessageChange:x,generatedHighlights:b,onInsertHighlights:m,onGenerateMessage:f,isGeneratingMessage:l,onCommit:d,onCommitAndPush:z,commitAction:g,hasPendingIndexMutation:y,gitmojiEnabled:V,onOpenGitmojiPicker:H}=p,j=y===void 0?!1:y,{t:r}=Q(),w=t>0;let N;e[0]!==g||e[1]!==o||e[2]!==j||e[3]!==w?(N=o.trim()&&w&&g===null&&!j,e[0]=g,e[1]=o,e[2]=j,e[3]=w,e[4]=N):N=e[4];const h=N,{isMobile:E,hasTouchInput:F}=Ie();let M;e[5]!==r?(M=r("gitView.commit.title"),e[5]=r,e[6]=M):M=e[6];let C;e[7]!==M?(C=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:M}),e[7]=M,e[8]=C):C=e[8];let D;e[9]!==w||e[10]!==r?(D=w?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:r("gitView.commit.stageFilesHint")}),e[9]=w,e[10]=r,e[11]=D):D=e[11];let A;e[12]!==C||e[13]!==D?(A=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[C,D]}),e[12]=C,e[13]=D,e[14]=A):A=e[14];let T;e[15]!==b||e[16]!==m?(T=s.jsx(Ke,{highlights:b,onInsert:m}),e[15]=b,e[16]=m,e[17]=T):T=e[17];let u;e[18]!==h||e[19]!==l||e[20]!==d?(u=()=>{h&&!l&&d()},e[18]=h,e[19]=l,e[20]=d,e[21]=u):u=e[21];let P;e[22]!==r?(P=r("gitView.commit.messagePlaceholder"),e[22]=r,e[23]=P):P=e[23];const W=g!==null;let L;e[24]!==o||e[25]!==F||e[26]!==E||e[27]!==x||e[28]!==W||e[29]!==u||e[30]!==P?(L=s.jsx(Ge,{value:o,onChange:x,onSubmit:u,placeholder:P,disabled:W,hasTouchInput:F,isMobile:E}),e[24]=o,e[25]=F,e[26]=E,e[27]=x,e[28]=W,e[29]=u,e[30]=P,e[31]=L):L=e[31];let R;e[32]!==V||e[33]!==H||e[34]!==r?(R=V&&s.jsxs(Z,{variant:"outline",size:"sm",onClick:H,className:"w-fit",type:"button",children:[s.jsx($,{name:"emotion-happy",className:"size-4"}),r("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=H,e[34]=r,e[35]=R):R=e[35];const X=l||g!==null||j||t===0;let I;e[36]!==r?(I=r("gitView.commit.generateAria"),e[36]=r,e[37]=I):I=e[37];let Y;e[38]!==l?(Y=l?s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx($,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=l,e[39]=Y):Y=e[39];let K;e[40]!==r?(K=r("gitView.commit.generate"),e[40]=r,e[41]=K):K=e[41];let G;e[42]!==K?(G=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=G):G=e[43];let O;e[44]!==f||e[45]!==X||e[46]!==I||e[47]!==Y||e[48]!==G?(O=s.jsxs(Z,{variant:"outline",size:"sm",onClick:f,disabled:X,type:"button","aria-label":I,className:"commit-actions__btn",children:[Y,G]}),e[44]=f,e[45]=X,e[46]=I,e[47]=Y,e[48]=G,e[49]=O):O=e[49];let B;e[50]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[50]=B):B=e[50];const q=!h||l;let i;e[51]!==r?(i=r("gitView.commit.commitAria"),e[51]=r,e[52]=i):i=e[52];let n;e[53]!==g||e[54]!==r?(n=g==="commit"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.commit")})]}),e[53]=g,e[54]=r,e[55]=n):n=e[55];let a;e[56]!==d||e[57]!==q||e[58]!==i||e[59]!==n?(a=s.jsx(Z,{size:"sm",variant:"outline",onClick:d,disabled:q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=d,e[57]=q,e[58]=i,e[59]=n,e[60]=a):a=e[60];let c;e[61]!==h||e[62]!==g||e[63]!==l||e[64]!==E||e[65]!==z||e[66]!==r?(c=E?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx(Z,{variant:"default",size:"sm",onClick:()=>z(),disabled:!h||l,className:"h-7 w-7 p-0","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx($,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:r("gitView.commit.push")})})]}):s.jsx(Z,{size:"sm",variant:"default",onClick:()=>z(),disabled:!h||l,className:"commit-actions__btn","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.push")})]})}),e[61]=h,e[62]=g,e[63]=l,e[64]=E,e[65]=z,e[66]=r,e[67]=c):c=e[67];let k;e[68]!==O||e[69]!==a||e[70]!==c?(k=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[O,B,a,c]}),e[68]=O,e[69]=a,e[70]=c,e[71]=k):k=e[71];let v;e[72]!==L||e[73]!==R||e[74]!==k||e[75]!==T?(v=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[T,L,R,k]}),e[72]=L,e[73]=R,e[74]=k,e[75]=T,e[76]=v):v=e[76];let _;return e[77]!==v||e[78]!==A?(_=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[A,v]}),e[77]=v,e[78]=A,e[79]=_):_=e[79],_};export{Ye as C,qe as a};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{f as pt,R as r,c as gr,j as s,r as en}from"./vendor-react-BUCujlKS.js";import{Q as Xi,R as Ji,S as Yi,T as Zi,ak as xr,n as Ke,u as ht,cY as Qi,C as vr,w as ea,r as wr,V as br,e as ta,cW as sa,aK as na,cX as ra,a as ia}from"./index-rlLjZUM5.js";import{f as ts,y as yr,a9 as $r,bL as aa,h as U,he as oa,f9 as la,S as Ss,B as z,V as ca,L as ua,bj as da,aa as fa,c1 as ma,hf as jr,hg as ha,gL as pa,t as G,l as Fr,aj as tn,bY as ys,cw as ga,b as xa,hh as sn,by as va,ak as Nr,hi as Cr,bZ as Sr,b_ as wa,f_ as ba,hj as ya,hk as ja,hl as Fa,bz as Wr,bA as _r,bB as Ur,bC as Kr,bD as Gr,bE as Hr,I as w,b0 as ln,aZ as cn,am as Fs,a$ as un,aY as Ns,bX as nn,al as rn,bT as kr,a4 as zt,a5 as Lt,a6 as It,bw as Na,bx as Ca,g as ks,a_ as Sa,b6 as ka}from"./useAppFontEffects-Cll4gnsh.js";import{Q as Ra,v as Va,w as Ta,x as Da,y as Pa,z as Ea}from"./runtimeEndpointReset-BDh7r8BL.js";import{c as Rr,s as Ma,C as Vr,P as an}from"./shikiHighlight-BgTPSITe.js";import{a as za}from"./vendor-codemirror-state-C9awkmn-.js";import{E as jt}from"./vendor-codemirror-view-CiLROUVV.js";import{J as La,F as Ia}from"./JsonTreeView-osju7J70.js";import{ensurePierreThemeRegistered as Tr,getResolvedShikiTheme as Aa}from"./appThemeRegistry-BK0dHKa6.js";import{V as Oa,W as Ba}from"./Virtualizer-CZlLSacm.js";import{V as $a}from"./Virtualizer-D_a8gKmg.js";import{u as js,c as Wa,e as _a}from"./scheduledTasksApi-CAGPh_gZ.js";import{D as Ua}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Ka,u as Ga,n as Ha}from"./useInlineCommentController-DFFv0hae.js";import{b as qa}from"./CodeMirrorCommentWidgets-C2BopIs3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-_6j2xOWl.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-CpzVNWAv.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-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-DkQX2EBa.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-DLnGY4fs.js";import"./computeVirtualFileMetrics-Gi1d5eU1.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-CVKy_dgB.js";import"./registerCustomTheme-BBXUCRnG.js";function Dr(a){const e=pt.c(41),{containerRef:n,filePath:d,fileContent:g}=a,{t:x}=ts(),y=yr(so),b=yr(to),h=$r(),F=aa(eo),[p,C]=r.useState(null),[S,V]=r.useState(""),[j,D]=r.useState(!1),o=r.useRef(!1),L=r.useRef(null),$=r.useRef(null),[H,I]=r.useState(null);let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{C(null),V(""),D(!1),o.current=!1,$.current=null,I(null)},e[0]=T):T=e[0];const k=T;let Z,X;e[1]!==n?(Z=()=>{const M=n.current;if(!M)return;const W=()=>{if(o.current)return;const ne=window.getSelection(),Se=ne?.toString().trim()??"";if(!ne||!Se||ne.rangeCount===0){k();return}const ie=ne.getRangeAt(0);if(!M.contains(ie.commonAncestorContainer)){k();return}const ae=ie.getBoundingClientRect();$.current=ie.cloneRange(),V(Se),C({x:ae.left+ae.width/2,y:ae.top-10})},se=ne=>{L.current?.contains(ne.target)||o.current&&k()};return document.addEventListener("selectionchange",W),document.addEventListener("pointerdown",se),()=>{document.removeEventListener("selectionchange",W),document.removeEventListener("pointerdown",se)}},X=[n,k],e[1]=n,e[2]=Z,e[3]=X):(Z=e[2],X=e[3]),r.useEffect(Z,X);let J;e[4]!==g?(J=M=>{const W=de=>g.slice(0,de).split(`
|
|
2
|
-
`).length,se=Za,ne=(de,Te)=>{for(const De of se(de)){const ke=g.indexOf(De,Te);if(ke>=0)return ke}return-1},Se=M.length>=8?g.indexOf(M):-1;if(Se>=0){const de=W(Se);return{start:de,end:de+M.split(`
|
|
3
|
-
`).length-1}}const ie=M.split(`
|
|
4
|
-
`).map(Ya).filter(Boolean);if(ie.length===0)return null;const ae=ne(ie[0],0);if(ae<0)return null;const ye=W(ae);if(ie.length===1)return{start:ye,end:ye};const Ve=ne(ie[ie.length-1],ae);return Ve<0?null:{start:ye,end:Math.max(ye,W(Ve))}},e[4]=g,e[5]=J):J=e[5];const P=J;let Q;e[6]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{const M=$.current;if(!M){I(null);return}I(oa(M))},e[6]=Q):Q=e[6];const Ne=Q;let K,q;e[7]!==j?(K=()=>{if(!j)return;let M=null;const W=()=>{M===null&&(M=window.requestAnimationFrame(()=>{M=null,Ne()}))};return document.addEventListener("scroll",W,{capture:!0,passive:!0}),window.addEventListener("resize",W),()=>{M!==null&&window.cancelAnimationFrame(M),document.removeEventListener("scroll",W,{capture:!0}),window.removeEventListener("resize",W)}},q=[j,Ne],e[7]=j,e[8]=K,e[9]=q):(K=e[8],q=e[9]),r.useEffect(K,q);let ee;e[10]!==S?(ee=()=>{S&&(D(!0),o.current=!0,Ne(),window.getSelection()?.removeAllRanges())},e[10]=S,e[11]=ee):ee=e[11];const le=ee;let te;e[12]!==F||e[13]!==y||e[14]!==h||e[15]!==d||e[16]!==b||e[17]!==P||e[18]!==S?(te=M=>{const W=y??(b?"draft":null);if(!S||!W||!h){k();return}const se=P(S);F({directory:h,sessionKey:W},{source:"file-quote",fileLabel:d,startLine:se?.start??0,endLine:se?.end??0,code:S,language:"",text:M.trim()}),k(),queueMicrotask(Ja)},e[12]=F,e[13]=y,e[14]=h,e[15]=d,e[16]=b,e[17]=P,e[18]=S,e[19]=te):te=e[19];const Ce=te;if(!p)return null;let E;e[20]!==j||e[21]!==P||e[22]!==S?(E=j?P(S):null,e[20]=j,e[21]=P,e[22]=S,e[23]=E):E=e[23];const ve=E;let we;e[24]!==p.x||e[25]!==p.y?(we={left:p.x,top:p.y,transform:"translate(-50%, -100%)"},e[24]=p.x,e[25]=p.y,e[26]=we):we=e[26];let ce;e[27]!==j||e[28]!==H?(ce=j&&H&&H.length>0?gr.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:H.map(Xa)}),document.body):null,e[27]=j,e[28]=H,e[29]=ce):ce=e[29];let ue;e[30]!==j||e[31]!==d||e[32]!==ve||e[33]!==le||e[34]!==Ce||e[35]!==x?(ue=j?s.jsx("div",{className:"w-[min(420px,80vw)]",children:s.jsx(Ka,{fileLabel:d,lineRange:ve?{start:ve.start,end:ve.end}:void 0,onSave:Ce,onCancel:k})}):s.jsx("div",{className:U("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:s.jsx("button",{type:"button",onClick:le,className:U("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:x("chat.textSelection.title.commentOnSelection"),children:x("chat.textSelection.actions.comment")})}),e[30]=j,e[31]=d,e[32]=ve,e[33]=le,e[34]=Ce,e[35]=x,e[36]=ue):ue=e[36];let be;return e[37]!==we||e[38]!==ce||e[39]!==ue?(be=gr.createPortal(s.jsxs("div",{ref:L,className:"fixed z-50",style:we,children:[ce,ue]}),document.body),e[37]=we,e[38]=ce,e[39]=ue,e[40]=be):be=e[40],be}function Xa(a,e){return s.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:a.left,top:a.top,width:a.width,height:a.height}},e)}function Ja(){la()}function Ya(a){return a.trim()}function Za(a){const e=a.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Qa)}function Qa(a){return a.length>=8}function eo(a){return a.addDraft}function to(a){return a.newSessionDraft?.open}function so(a){return a.currentSessionId}const no=(a,e)=>{if(!e)return null;const n=Number.parseInt(a.trim(),10);return!Number.isFinite(n)||n<1?null:Math.min(n,e.state.doc.lines)},Pr=(a,e)=>{const n=a.state.doc.lineAt(e.main.head);return{lineNumber:n.number,character:e.main.head-n.from+1,selection:e}},Er=(a,e,n)=>{const d=a.state.doc.line(e),g=Math.max(1,Math.min(n,d.length+1)),x=d.from+g-1;a.dispatch({selection:za.cursor(x),effects:jt.scrollIntoView(x,{y:"center"})})};function ro({open:a,onOpenChange:e,view:n,variant:d="overlay"}){const{t:g}=ts(),[x,y]=r.useState(""),b=r.useRef(null),h=r.useRef(!1),F=r.useRef(null),p=r.useRef(null),C=r.useMemo(()=>no(x,n),[x,n]);r.useEffect(()=>{!a||!n||(h.current=!1,b.current=Pr(n,n.state.selection),y(""))},[a,n]),r.useEffect(()=>{a&&window.requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})},[a]),r.useEffect(()=>{if(!(!a||!n||!b.current)){if(C===null){const{selection:o}=b.current;n.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})});return}Er(n,C,b.current.character)}},[C,a,n]);const S=r.useCallback(()=>{if(!n||h.current||!b.current)return;const{selection:o}=b.current;n.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})})},[n]),V=r.useCallback(o=>{o||S(),e(o)},[e,S]),j=r.useCallback(()=>{!n||C===null||!b.current||(h.current=!0,Er(n,C,b.current.character),e(!1),n.focus())},[C,e,n]);r.useEffect(()=>{if(!a)return;const o=$=>{const H=F.current,I=$.target;!H||!(I instanceof Node)||H.contains(I)||V(!1)},L=$=>{$.key==="Escape"&&($.preventDefault(),V(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",L,!0)}},[V,a,d]);const D=r.useMemo(()=>{if(!n)return g("goToLineDialog.helper.editorUnavailable");if(C===null){const o=b.current??Pr(n,n.state.selection);return g("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:n.state.doc.lines})}return g("goToLineDialog.helper.goToLine",{line:C})},[C,g,n]);return d==="inline"?a?s.jsxs("div",{ref:F,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(Ss,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:g("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(z,{variant:"outline",size:"xs",onClick:j,disabled:!n||C===null,className:"h-6 px-2",children:g("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:F,className:U("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",a?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(Ss,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:g("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:D})]})})}function Mr(){const a=pt.c(8),[e]=en.useState(io),n=en.useRef(!1);let d;a[0]!==e?(d=h=>{if(h==null){e.cleanUp(),n.current=!1;return}n.current||(n.current=!0,e.setup(h,h.firstElementChild??void 0))},a[0]=e,a[1]=d):d=a[1];const g=d;let x,y;a[2]!==e?(x=()=>()=>{n.current=!1,e.cleanUp()},y=[e],a[2]=e,a[3]=x,a[4]=y):(x=a[3],y=a[4]),en.useLayoutEffect(x,y);let b;return a[5]!==g||a[6]!==e?(b={virtualizer:e,setScroller:g},a[5]=g,a[6]=e,a[7]=b):b=a[7],b}function io(){return new $a}function ao(a){return!(!a.autoSaveEnabled||!a.isDirty||!a.canWrite||a.isSaving||a.fileLoading||a.isNonEditableBinary||!a.selectedFilePath||a.loadedFilePath!==a.selectedFilePath)}function oo(a){return a.selectedFilePath?a.isDirty?!(a.fileLoading||a.loadedFilePath!==a.selectedFilePath||a.isNonEditableBinary||a.draftContent===""&&a.fileContent!==""&&a.loadedFilePath!==a.selectedFilePath):!0:!1}const lo='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function zr(){if(typeof document>"u")return!1;const a=document.documentElement.getAttribute("data-theme");return a==="dark"||!a&&window.matchMedia("(prefers-color-scheme: dark)").matches}const co=r.forwardRef(function({xml:e,readOnly:n,className:d,onChange:g},x){const y=r.useRef(e),b=r.useRef(null),h=r.useRef(!1),[F,p]=r.useState(zr),C=r.useRef(e),S=r.useRef(e);S.current!==e&&(S.current=e,C.current=e,y.current=e);const V=r.useRef(F);V.current!==F&&(V.current=F,C.current=y.current);const j=r.useRef(null);r.useEffect(()=>{const L=()=>p(zr());L();const $=new MutationObserver(L);return $.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>$.disconnect()},[]),r.useEffect(()=>{const L=setTimeout(()=>{j.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(L)},[]),r.useImperativeHandle(x,()=>({getXml:()=>y.current}));const D=r.useCallback(()=>{!e&&!h.current&&(h.current=!0,setTimeout(()=>{b.current?.template({})},500))},[e]),o=r.useCallback(L=>{y.current=L.xml,g?.(L.xml)},[g]);return s.jsx("div",{ref:j,className:U("h-full w-full",d),children:s.jsx(Ua,{ref:b,xml:C.current||lo,autosave:!0,urlParameters:{ui:n?"simple":F?"dark":"kennedy",spin:!0,libraries:!n,chrome:n,nav:n,layers:n,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:D,onAutoSave:o},F?"dark":"light")})}),uo=a=>{const e=B(a);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const n=e.lastIndexOf("/");if(n<0)return e;if(n===0)return"/";const d=e.slice(0,n);return/^[A-Za-z]:$/.test(d)?`${d}/`:d},fo=a=>{const e=pt.c(8),{label:n,iconDataUrl:d}=a,[g,x]=r.useState(!1);let y;e[0]!==n?(y=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=y):y=e[1];const b=y;if(d&&!g){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>x(!0),e[2]=p):p=e[2];let C;return e[3]!==d?(C=s.jsx("img",{src:d,alt:"",className:"size-4 rounded-sm",onError:p}),e[3]=d,e[4]=C):C=e[4],C}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=U("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let F;return e[6]!==b?(F=s.jsx("span",{className:h,children:b}),e[6]=b,e[7]=F):F=e[7],F},mo=a=>a.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),B=a=>{if(!a)return"";const e=a.replace(/\\/g,"/"),n=e.startsWith("//");let d=e.replace(/\/+/g,"/");n&&!d.startsWith("//")&&(d=`/${d}`);const g=d==="/",x=/^[A-Za-z]:\/$/.test(d);return!g&&!x&&(d=d.replace(/\/+$/,"")),d},ho=a=>a.startsWith("/")||a.startsWith("//")||/^[A-Za-z]:\//.test(a),Ot=a=>/^[A-Za-z]:\//.test(a)?a.toLowerCase():a,Rs=(a,e)=>{const n=B(e),d=B(a);if(!n||!d)return!1;const g=Ot(n),x=Ot(d);return x===g||x.startsWith(`${g}/`)},Lr=(a,e)=>{const n=B(e),d=B(a);if(!Rs(d,n))return[];const x=d.slice(n.length).replace(/^\//,"").split("/"),y=[];let b=n;for(let h=0;h<x.length-1;h++)b=b?`${b}/${x[h]}`:x[h],y.push(b);return y},Cs=(a,e)=>{if(!e)return"";const n=B(e);if(!a||!Rs(n,a))return n;const d=n.slice(a.length);return d.startsWith("/")?d.slice(1):d},po=new Set(["node_modules"]),go=a=>{const e=pt.c(3),{status:n}=a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=d):d=e[0];const g=d[n];let x;return e[1]!==g?(x=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:g}}),e[1]=g,e[2]=x):x=e[2],x},Ir=a=>{const e=pt.c(11),{name:n}=a,d=r.useRef(null),g=r.useRef(null),[x,y]=r.useState(!1);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const S=d.current,V=g.current;if(!S||!V)return;const j=()=>{y(V.scrollWidth>S.clientWidth+1)};j();const D=new ResizeObserver(j);return D.observe(S),D.observe(V),()=>{D.disconnect()}},e[0]=b):b=e[0];let h;e[1]!==n?(h=[n],e[1]=n,e[2]=h):h=e[2],r.useLayoutEffect(b,h);let F;e[3]!==n?(F=s.jsx("span",{ref:g,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:n}),e[3]=n,e[4]=F):F=e[4];let p;e[5]!==n||e[6]!==x?(p=x?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:n}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:n})]}):s.jsx("span",{className:"block min-w-0 truncate",children:n}),e[5]=n,e[6]=x,e[7]=p):p=e[7];let C;return e[8]!==F||e[9]!==p?(C=s.jsxs("span",{ref:d,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[F,p]}),e[8]=F,e[9]=p,e[10]=C):C=e[10],C},xo=a=>po.has(a),vo=a=>{const e=B(a);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},wo=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("is a directory")||n.includes("eisdir")},Ar=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("file not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")},At=2e5;function bo(a){const e=a.length>400?`${a.slice(0,200)}${a.slice(-200)}`:a;let n=2166136261;for(let d=0;d<e.length;d+=1)n^=e.charCodeAt(d),n=n+((n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24))>>>0;return`${a.length}:${n.toString(16)}`}const yo=a=>{let e=0,n=0;for(let d=0;d<a.length;d+=1)a.charCodeAt(d)===10&&(d>0&&a.charCodeAt(d-1)===13?e+=1:n+=1);return e>n?`\r
|
|
5
|
-
`:`
|
|
6
|
-
`},qr=a=>a.replace(/\r\n/g,`
|
|
7
|
-
`).replace(/\r/g,`
|
|
8
|
-
`),jo=(a,e)=>{const n=qr(a);return e===`\r
|
|
9
|
-
`?n.replace(/\n/g,`\r
|
|
10
|
-
`):n},Xr=(a,e)=>s.jsx(Fs,{filePath:a,extension:e}),Or=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Fo=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},on=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="html"||e==="htm"},No=a=>{const e=pt.c(76),{node:n,root:d,isExpanded:g,isActive:x,isMobile:y,isBrowserClient:b,alwaysShowActions:h,status:F,badge:p,permissions:C,downloadFile:S,contextMenuPath:V,setContextMenuPath:j,rightClickMenuPath:D,setRightClickMenuPath:o,onSelect:L,onToggle:$,onRevealPath:H,onOpenDialog:I}=a,{t:T}=ts(),k=n.type==="directory",{canRename:Z,canCreateFile:X,canCreateFolder:J,canDelete:P,canReveal:Q}=C,Ne=!k&&!!S,K=Q&&!b,q=Z||X||J||P||Ne||K;let ee;e[0]!==q||e[1]!==n.path||e[2]!==o?(ee=fe=>{q&&(fe?.preventDefault(),o(n.path))},e[0]=q,e[1]=n.path,e[2]=o,e[3]=ee):ee=e[3];const le=ee;let te;e[4]!==k||e[5]!==n||e[6]!==L||e[7]!==$?(te=()=>{k?$(n.path):L(n)},e[4]=k,e[5]=n,e[6]=L,e[7]=$,e[8]=te):te=e[8];const Ce=te;let E;e[9]!==n.path||e[10]!==j||e[11]!==o?(E=fe=>{fe.stopPropagation(),o(null),j(n.path)},e[9]=n.path,e[10]=j,e[11]=o,e[12]=E):E=e[12];const ve=E;let we;e[13]!==X||e[14]!==J||e[15]!==P||e[16]!==Z||e[17]!==K||e[18]!==S||e[19]!==b||e[20]!==k||e[21]!==n||e[22]!==I||e[23]!==H||e[24]!==d||e[25]!==T?(we=fe=>{const{Item:pe,Separator:Ze}=fe;return s.jsxs(s.Fragment,{children:[Z&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("rename",n)},children:[s.jsx(w,{name:"edit",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.rename")]}),s.jsxs(pe,{onClick:_=>{_.stopPropagation(),ks(n.path).then(it=>{if(it.ok){G.success(T("sidebarFilesTree.toast.pathCopied"));return}G.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(w,{name:"file-copy",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.copyPath")]}),s.jsxs(pe,{onClick:_=>{_.stopPropagation();const it=Cs(d,n.path)||n.path;ks(it).then(me=>{if(me.ok){G.success(T("filesView.toast.relativePathCopied"));return}G.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(w,{name:"file-copy-2",className:"mr-2 size-4"})," ",T("filesView.tree.menu.copyRelativePath")]}),!k&&S&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),S(n.path).catch(it=>{console.error("Download failed:",it),G.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(w,{name:"download",className:"mr-2 size-4"})," ",T(b?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),K&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),H(n.path)},children:[s.jsx(w,{name:"folder-received",className:"mr-2 size-4"})," ",T(ka())]}),k&&(X||J)&&s.jsxs(s.Fragment,{children:[s.jsx(Ze,{}),X&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("createFile",n)},children:[s.jsx(w,{name:"file-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFile")]}),J&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("createFolder",n)},children:[s.jsx(w,{name:"folder-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFolder")]})]}),P&&s.jsxs(s.Fragment,{children:[s.jsx(Ze,{}),s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(w,{name:"delete-bin",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.delete")]})]})]})},e[13]=X,e[14]=J,e[15]=P,e[16]=Z,e[17]=K,e[18]=S,e[19]=b,e[20]=k,e[21]=n,e[22]=I,e[23]=H,e[24]=d,e[25]=T,e[26]=we):we=e[26];const ce=we,ue=D===n.path;let be;e[27]!==n.path||e[28]!==o?(be=fe=>o(fe?n.path:null),e[27]=n.path,e[28]=o,e[29]=be):be=e[29];const M=y?void 0:le;let W;e[30]!==M?(W=s.jsx("div",{className:"group relative flex items-center",onContextMenu:M}),e[30]=M,e[31]=W):W=e[31];const se=y?void 0:le,ne=x?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let Se;e[32]!==ne?(Se=U("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",ne),e[32]=ne,e[33]=Se):Se=e[33];let ie;e[34]!==k||e[35]!==g||e[36]!==n.extension||e[37]!==n.path?(ie=k?g?s.jsx(w,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(w,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Xr(n.path,n.extension),e[34]=k,e[35]=g,e[36]=n.extension,e[37]=n.path,e[38]=ie):ie=e[38];let ae;e[39]!==n.name||e[40]!==n.path?(ae=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[39]=n.name,e[40]=n.path,e[41]=ae):ae=e[41];let ye;e[42]!==k||e[43]!==F?(ye=!k&&F&&s.jsx(go,{status:F}),e[42]=k,e[43]=F,e[44]=ye):ye=e[44];let Ve;e[45]!==p||e[46]!==k?(Ve=k&&p&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[p.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",p.modified]}),p.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",p.added]})]}),e[45]=p,e[46]=k,e[47]=Ve):Ve=e[47];let de;e[48]!==Ce||e[49]!==Se||e[50]!==ie||e[51]!==ae||e[52]!==ye||e[53]!==Ve||e[54]!==se?(de=s.jsxs("button",{type:"button",onClick:Ce,onContextMenu:se,className:Se,children:[ie,ae,ye,Ve]}),e[48]=Ce,e[49]=Se,e[50]=ie,e[51]=ae,e[52]=ye,e[53]=Ve,e[54]=se,e[55]=de):de=e[55];let Te;e[56]!==h||e[57]!==V||e[58]!==ve||e[59]!==q||e[60]!==y||e[61]!==n.path||e[62]!==ce||e[63]!==j?(Te=q&&s.jsx("div",{className:U("absolute right-1 top-1/2 -translate-y-1/2",h?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(ln,{open:V===n.path,onOpenChange:fe=>j(fe?n.path:null),children:[s.jsx(cn,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"icon",className:"size-6",onClick:ve,children:s.jsx(w,{name:"more-2-fill",className:"size-4"})})}),s.jsx(un,{align:"end",side:"bottom",onCloseAutoFocus:()=>j(null),children:ce({Item:Ns,Separator:Sa})})]})}),e[56]=h,e[57]=V,e[58]=ve,e[59]=q,e[60]=y,e[61]=n.path,e[62]=ce,e[63]=j,e[64]=Te):Te=e[64];let De;e[65]!==de||e[66]!==Te||e[67]!==W?(De=s.jsxs(Pa,{render:W,children:[de,Te]}),e[65]=de,e[66]=Te,e[67]=W,e[68]=De):De=e[68];let ke;e[69]!==ce?(ke=s.jsx(Va,{className:"min-w-[180px]",children:ce({Item:Da,Separator:Ta})}),e[69]=ce,e[70]=ke):ke=e[70];let Y;return e[71]!==De||e[72]!==ke||e[73]!==ue||e[74]!==be?(Y=s.jsxs(Ea,{open:ue,onOpenChange:be,children:[De,ke]}),e[71]=De,e[72]=ke,e[73]=ue,e[74]=be,e[75]=Y):Y=e[75],Y},Co=a=>{const e=pt.c(83),{activeDialog:n,dialogData:d,dialogInputValue:g,onDialogInputChange:x,isDialogSubmitting:y,onDialogSubmit:b,onClose:h,inputRef:F}=a,{t:p}=ts(),C=!!n;let S;e[0]!==h?(S=E=>!E&&h(),e[0]=h,e[1]=S):S=e[1];let V;e[2]!==n||e[3]!==p?(V=n==="createFile"&&p("filesView.dialog.createFile.title"),e[2]=n,e[3]=p,e[4]=V):V=e[4];let j;e[5]!==n||e[6]!==p?(j=n==="createFolder"&&p("filesView.dialog.createFolder.title"),e[5]=n,e[6]=p,e[7]=j):j=e[7];let D;e[8]!==n||e[9]!==p?(D=n==="rename"&&p("filesView.dialog.rename.title"),e[8]=n,e[9]=p,e[10]=D):D=e[10];let o;e[11]!==n||e[12]!==p?(o=n==="delete"&&p("filesView.dialog.delete.title"),e[11]=n,e[12]=p,e[13]=o):o=e[13];let L;e[14]!==V||e[15]!==j||e[16]!==D||e[17]!==o?(L=s.jsxs(Kr,{children:[V,j,D,o]}),e[14]=V,e[15]=j,e[16]=D,e[17]=o,e[18]=L):L=e[18];let $;e[19]!==n||e[20]!==d?.path||e[21]!==p?($=n==="createFile"&&p("filesView.dialog.createFile.description",{path:d?.path??p("filesView.dialog.rootFallback")}),e[19]=n,e[20]=d?.path,e[21]=p,e[22]=$):$=e[22];let H;e[23]!==n||e[24]!==d?.path||e[25]!==p?(H=n==="createFolder"&&p("filesView.dialog.createFolder.description",{path:d?.path??p("filesView.dialog.rootFallback")}),e[23]=n,e[24]=d?.path,e[25]=p,e[26]=H):H=e[26];let I;e[27]!==n||e[28]!==d?.name||e[29]!==p?(I=n==="rename"&&p("filesView.dialog.rename.description",{name:d?.name??""}),e[27]=n,e[28]=d?.name,e[29]=p,e[30]=I):I=e[30];let T;e[31]!==n||e[32]!==d?.name||e[33]!==p?(T=n==="delete"&&p("filesView.dialog.delete.description",{name:d?.name??""}),e[31]=n,e[32]=d?.name,e[33]=p,e[34]=T):T=e[34];let k;e[35]!==I||e[36]!==T||e[37]!==$||e[38]!==H?(k=s.jsxs(Gr,{children:[$,H,I,T]}),e[35]=I,e[36]=T,e[37]=$,e[38]=H,e[39]=k):k=e[39];let Z;e[40]!==k||e[41]!==L?(Z=s.jsxs(Ur,{children:[L,k]}),e[40]=k,e[41]=L,e[42]=Z):Z=e[42];let X;e[43]!==n||e[44]!==g||e[45]!==F||e[46]!==x||e[47]!==b||e[48]!==p?(X=n!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Ss,{value:g,onChange:E=>x(E.target.value),placeholder:p(n==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:E=>{E.key==="Enter"&&b()},ref:F})}),e[43]=n,e[44]=g,e[45]=F,e[46]=x,e[47]=b,e[48]=p,e[49]=X):X=e[49];let J;e[50]!==p?(J=p("filesView.dialog.cancel"),e[50]=p,e[51]=J):J=e[51];let P;e[52]!==y||e[53]!==h||e[54]!==J?(P=s.jsx(z,{variant:"outline",onClick:h,disabled:y,children:J}),e[52]=y,e[53]=h,e[54]=J,e[55]=P):P=e[55];const Q=n==="delete"?"destructive":"default";let Ne;e[56]!==b?(Ne=()=>{b()},e[56]=b,e[57]=Ne):Ne=e[57];let K;e[58]!==n||e[59]!==g||e[60]!==y?(K=y||n!=="delete"&&!g.trim(),e[58]=n,e[59]=g,e[60]=y,e[61]=K):K=e[61];let q;e[62]!==n||e[63]!==y||e[64]!==p?(q=y?s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):p(n==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=n,e[63]=y,e[64]=p,e[65]=q):q=e[65];let ee;e[66]!==Q||e[67]!==Ne||e[68]!==K||e[69]!==q?(ee=s.jsx(z,{variant:Q,onClick:Ne,disabled:K,children:q}),e[66]=Q,e[67]=Ne,e[68]=K,e[69]=q,e[70]=ee):ee=e[70];let le;e[71]!==P||e[72]!==ee?(le=s.jsxs(Hr,{children:[P,ee]}),e[71]=P,e[72]=ee,e[73]=le):le=e[73];let te;e[74]!==F||e[75]!==Z||e[76]!==X||e[77]!==le?(te=s.jsxs(_r,{initialFocus:F,children:[Z,X,le]}),e[74]=F,e[75]=Z,e[76]=X,e[77]=le,e[78]=te):te=e[78];let Ce;return e[79]!==C||e[80]!==S||e[81]!==te?(Ce=s.jsx(Wr,{open:C,onOpenChange:S,children:te}),e[79]=C,e[80]=S,e[81]=te,e[82]=Ce):Ce=e[82],Ce},Br=(a,e,n)=>{const d=pt.c(8),[g,x]=r.useState(""),[y,b]=r.useState(0);let h,F;d[0]!==a||d[1]!==n||d[2]!==e?(h=()=>{if(!a){x("");return}let C=!1;x("");const S=ta(),V=sa(S);na(S).then(D=>{C||!D||(x(a),e(null))}).catch(D=>{C||(e(D instanceof Error?D.message:n),x(a))});const j=ra(()=>{C||(x(a),b(So),e(null))});return()=>{C=!0,V(),j()}},F=[a,e,n],d[0]=a,d[1]=n,d[2]=e,d[3]=h,d[4]=F):(h=d[3],F=d[4]),r.useEffect(h,F);let p;return d[5]!==y||d[6]!==g?(p={readyKey:g,nonce:y},d[5]=y,d[6]=g,d[7]=p):p=d[7],p},Hc=({mode:a="full"})=>{const{t:e}=ts(),{files:n,runtime:d}=ca(),{currentTheme:g,availableThemes:x,lightThemeId:y,darkThemeId:b}=ua(),{isMobile:h,isTablet:F,screenWidth:p}=da(),C=Xi(d.platform),S=h||F,V=Ji(),j=Yi(),D=$r()??"",o=B(D.trim()),L=a!=="editor-only",$=a==="editor-only"&&!h,H=Zi(t=>t.searchFiles),I=fa(D),[T,k]=r.useState(""),Z=ma(T,200),X=r.useRef(null),[J,P]=r.useState(!1),[Q,Ne]=r.useState(!0),[K,q]=r.useState(!1),[ee,le]=r.useState(!1),te=r.useRef(0),Ce=r.useCallback(t=>{te.current=Math.max(0,te.current+(t?1:-1))},[]),[E,ve]=r.useState("edit"),[we,ce]=r.useState("edit"),[ue,be]=r.useState("tree"),[M,W]=r.useState("edit"),[se,ne]=r.useState("preview"),[Se,ie]=r.useState(0),ae=r.useRef({}),ye=r.useRef({}),Ve=r.useRef({}),de=r.useRef({}),Te=r.useMemo(()=>x.find(t=>t.metadata.id===y)??xr(!1),[x,y]),De=r.useMemo(()=>x.find(t=>t.metadata.id===b)??xr(!0),[x,b]);r.useEffect(()=>{Tr(Te),Tr(De)},[Te,De]);const ke=r.useMemo(()=>[],[]),Y=Ke(t=>o?t.byRoot[o]?.openPaths??ke:ke),fe=Ke(t=>o?t.byRoot[o]?.selectedPath??null:null),pe=Ke(t=>o?t.byRoot[o]?.expandedPaths??ke:ke),Ze=Ke(t=>t.removeOpenPath),_=Ke(t=>t.removeOpenPathsByPrefix),it=Ke(t=>t.removeExpandedPathsByPrefix),me=Ke(t=>t.setSelectedPath),dn=Ke(t=>t.toggleExpandedPath),ss=Ke(t=>t.expandPaths),Ft=r.useCallback(t=>{const i=B(t),l=i.split("/"),u=l[l.length-1]||i,m=u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;return{name:u,path:i,type:"file",extension:m}},[]),Nt=r.useMemo(()=>Y.map(Ft),[Y,Ft]),Vs=r.useMemo(()=>{if(fe){const t=Ot(fe);if(Y.some(i=>Ot(i)===t))return fe}return Y[0]??null},[Y,fe]),c=r.useMemo(()=>Vs?Ft(Vs):null,[Vs,Ft]),Ge=c?.path??"",[,Jr]=r.useState(0);r.useEffect(()=>{if(!o||!fe)return;const t=Ot(fe);Y.some(l=>Ot(l)===t)||me(o,Y[0]??null)},[Y,o,fe,me]);const ns=!!(o&&Ge&&!Rs(Ge,o)),fn=ns?jr(Ge):void 0,gt=r.useMemo(()=>({allowOutsideWorkspace:a==="editor-only"&&ns,outsideFileGrant:fn,directory:o||void 0}),[a,ns,fn,o]),He=r.useCallback(async t=>{const i=jr(t),l=await ha(t,o,a==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==i&&Jr(u=>u+1),l},[a,o]),Ts=r.useRef(null),[mn,Yr]=r.useState({left:!1,right:!1}),hn=r.useCallback(()=>{const t=Ts.current;t&&Yr({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),pn=r.useRef(hn);pn.current=hn,r.useEffect(()=>{const t=Ts.current;if(!t)return;const i=()=>pn.current();i(),t.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(t),()=>{t.removeEventListener("scroll",i),l.disconnect()}},[Nt.length]);const[gn,Ds]=r.useState({}),[rs,Bt]=r.useState({}),ze=r.useRef(new Set),Le=r.useRef(new Set),Qe=r.useRef(new Map),xn=r.useRef(0),[vn,is]=r.useState([]),[Zr,as]=r.useState(!1),[R,he]=r.useState(""),{isPlaying:os,play:Qr,stop:ei}=pa(),[Be,at]=r.useState(!1),[et,ge]=r.useState(null),[ti,Ie]=r.useState(""),[Pe,oe]=r.useState(null),[re,xe]=r.useState(""),[$t,Ps]=r.useState(!1),[wn,si]=r.useState(`
|
|
11
|
-
`),ni=r.useRef(null),qe=r.useRef(null),Ee=r.useRef(null),ot=r.useRef(""),Wt=r.useRef(""),tt=r.useRef(null),bn=r.useRef(null),Xe=r.useRef(null),_t=r.useRef(0),Ct=r.useRef(null),[ls,ri]=r.useState(0),[ii,St]=r.useState("idle"),[ai,cs]=r.useState(!1),[Ut,yn]=r.useState(!1),je=ht(t=>t.autoSaveEnabled),oi=ht(t=>t.setAutoSaveEnabled),[Es,Kt]=r.useState(!1),kt=r.useRef(null),Gt=r.useRef(null),Ht=r.useRef(!1),qt=r.useRef(null),Xt=r.useRef(null),$e=r.useRef(null),us=r.useRef(null),[li,Ms]=r.useState(0),Rt=r.useRef(null),xt=r.useRef({key:"",attempts:0});r.useEffect(()=>()=>{Rt.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Rt.current),Rt.current=null)},[]);const[vt,zs]=r.useState(null),[wt,ci]=r.useState(null),[lt,jn]=r.useState(""),[ui,Ls]=r.useState(!1),[di,fi]=r.useState(null),[mi,hi]=r.useState(null),[pi,Fn]=r.useState(!1),[gi,Nn]=r.useState(!1),[xi,Is]=r.useState(!1),Cn=!!n.writeFile,Sn=!!n.createDirectory,kn=!!n.rename,Rn=!!n.delete,Vn=!!n.revealPath,vi=js(t=>t.availableApps),wi=js(t=>t.isCacheStale),Tn=js(t=>t.initialize),bi=js(t=>t.loadInstalledApps);r.useEffect(()=>{Tn()},[Tn]);const yi=r.useCallback(t=>{n.revealPath&&n.revealPath(t).catch(()=>{G.error(e("sidebarFilesTree.toast.revealFailed"))})},[n,e]),ji=r.useCallback(async t=>{if(!c?.path||await Qi(c.path,t.id,t.appName)||await vr(c.path,t.appName))return;const u=uo(c.path)||o;u&&await vr(u,t.appName)||G.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,c?.path,e]),As=r.useCallback((t,i)=>{zs(t),ci(i),jn(t==="rename"&&i.name||""),Ls(!1)},[]),[A,We]=r.useState(null),Vt=r.useRef(!1),ct=r.useRef(null),[Dn,Tt]=r.useState(!1),Je=ht(t=>t.pendingFileNavigation),ds=ht(t=>t.setPendingFileNavigation),Os=ht(t=>t.pendingFileFocusPath),Bs=ht(t=>t.setPendingFileFocusPath),Pn=ht(t=>t.fileEditorKeymap),Jt=Fr(t=>t.settingsDefaultFileViewerPreview),Fi=Fr(t=>t.showMessageTTSButtons);r.useEffect(()=>{const t=()=>{Vt.current=!1,ct.current=null,Tt(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),r.useEffect(()=>()=>{qt.current!==null&&window.clearTimeout(qt.current),Xt.current!==null&&window.clearTimeout(Xt.current)},[]);const Ni=r.useCallback((t,i)=>{const l=t.split(`
|
|
12
|
-
`),u=Math.max(1,i.start),m=Math.min(l.length,i.end);return u>m?"":l.slice(u-1,m).join(`
|
|
13
|
-
`)},[]),fs=r.useRef(null),Ci=Ga({source:"file",fileLabel:c?.path??null,language:c?.path&&tn(c.path)||"text",getCodeForRange:t=>Ni(R,Ha(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:En,commentText:ms,setCommentText:Mn,editingDraftId:hs,setSelection:zn,saveComment:Ln,cancel:Yt,reset:In,startEdit:An,deleteDraft:On}=Ci;r.useEffect(()=>{We(null),In(),xe(""),Ps(!1)},[c?.path,In]),r.useEffect(()=>{zn(A)},[A,zn]),r.useEffect(()=>{if(!A&&!hs)return;const t=l=>{const u=l.target;u.closest('[data-comment-input="true"]')||u.closest('[data-comment-card="true"]')||u.closest(".cm-gutterElement")||u.closest("[data-sonner-toast]")||u.closest("[data-sonner-toaster]")||ms.trim()||(We(null),Yt())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[Yt,ms,hs,A]);const Bn=r.useCallback((t,i)=>{const l=i??A??void 0;i&&We(i),Ln(t,l),We(null)},[A,Ln]),$n=r.useCallback((t,i)=>{const l=[];for(const u of i){if(!(u&&typeof u.name=="string"&&u.name.length>0)||!V&&u.name.startsWith(".")||!j&&xo(u.name))continue;const m=u.name,f=B(u.path||""),v=f?ho(f)?f:B(`${t}/${f}`):B(`${t}/${m}`),N=u.isDirectory?"directory":"file",O=N==="file"&&m.includes(".")?m.split(".").pop()?.toLowerCase():void 0;l.push({name:m,path:v,type:N,extension:O})}return mo(l)},[j,V]),Ae=r.useCallback(async t=>{const i=B(t.trim());if(!i||ze.current.has(i)||Le.current.has(i))return;Le.current=new Set(Le.current),Le.current.add(i);const l=xn.current+1;xn.current=l,Qe.current=new Map(Qe.current),Qe.current.set(i,l);const u=()=>Qe.current.get(i)===l;await(n.listDirectory?n.listDirectory(i).then(f=>f.entries.map(v=>({name:v.name,path:v.path,isDirectory:v.isDirectory}))):ea.listLocalDirectory(i).then(f=>f.map(v=>({name:v.name,path:v.path,isDirectory:v.isDirectory})))).then(f=>{if(!u())return;const v=$n(i,f);ze.current=new Set(ze.current),ze.current.add(i),Bt(N=>{if(!N[i])return N;const O={...N};return delete O[i],O}),Ds(N=>({...N,[i]:v}))}).catch(f=>{if(!u())return;const v=f instanceof Error?f.message:String(f??"");if(v==="Directory not found"&&o&&i!==o){it(o,i),Bt(N=>{if(!N[i])return N;const O={...N};return delete O[i],O});return}console.error("Failed to load files directory:",f),Bt(N=>({...N,[i]:v}))}).finally(()=>{u()&&(Qe.current=new Map(Qe.current),Qe.current.delete(i),Le.current=new Set(Le.current),Le.current.delete(i))})},[n,$n,it,o]),ps=r.useCallback(async()=>{o&&(ze.current=new Set,Le.current=new Set,Qe.current=new Map,Bt({}),Ds(t=>Object.keys(t).length===0?t:{}),await Ae(o))},[Ae,o]),Ye=r.useCallback(async t=>{if(!t){await ps();return}const i=B(t);ze.current=new Set(ze.current),ze.current.delete(i),Le.current=new Set(Le.current),Le.current.delete(i),await Ae(i)},[Ae,ps]),Wn=r.useRef(""),_n=r.useRef("");r.useEffect(()=>{if(!o)return;const t=`${o}|h${V?"1":"0"}|g${j?"1":"0"}`,i=Wn.current!==o,l=_n.current!==t;!i&&!l||(i&&(Wn.current=o,he(""),ge(null),Ie(""),oe(null),P(!1)),l&&(_n.current=t,ze.current=new Set,Le.current=new Set,Qe.current=new Map,Bt({}),Ds(u=>Object.keys(u).length===0?u:{}),Ae(o)))},[Ae,o,j,V]),r.useEffect(()=>{if(!n.listDirectory)return;const t=()=>{if(!document.hidden&&pe.length>0)for(const i of pe)Ye(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[pe,n.listDirectory,Ye]),r.useEffect(()=>{if(!n.listDirectory||pe.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of pe)Ye(i)},8e3);return()=>clearInterval(t)},[pe,n.listDirectory,Ye]);const Si=r.useCallback(async t=>{if(t?.preventDefault(),!wt||!vt)return;Ls(!0);const i=()=>{zs(null)},l=m=>{G.error(m)},u=()=>{Ls(!1)};if(vt==="createFile"){if(!lt.trim()){l(e("sidebarFilesTree.toast.filenameRequired")),u();return}if(!n.writeFile){l(e("sidebarFilesTree.toast.writeNotSupported")),u();return}const m=wt.path,f=m?`${m}/`:"",v=B(`${f}${lt.trim()}`);await n.writeFile(v,"").then(async N=>{N.success&&(G.success(e("sidebarFilesTree.toast.fileCreated")),await Ye(m)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(vt==="createFolder"){if(!lt.trim()){l(e("sidebarFilesTree.toast.folderNameRequired")),u();return}const m=wt.path,f=m?`${m}/`:"",v=B(`${f}${lt.trim()}`);await n.createDirectory(v).then(async N=>{N.success&&(G.success(e("sidebarFilesTree.toast.folderCreated")),await Ye(m)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(vt==="rename"){if(!lt.trim()){l(e("sidebarFilesTree.toast.nameRequired")),u();return}if(!n.rename){l(e("sidebarFilesTree.toast.renameNotSupported")),u();return}const m=wt.path,f=m.split("/").slice(0,-1).join("/"),v=f?`${f}/`:"",N=B(`${v}${lt.trim()}`);await n.rename(m,N).then(async O=>{O.success&&(G.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await Ye(f),o&&_(o,m),(c?.path===m||c?.path.startsWith(`${m}/`))&&(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(vt==="delete"){if(!n.delete){l(e("sidebarFilesTree.toast.deleteNotSupported")),u();return}const m=wt.path,f=m.split("/").slice(0,-1).join("/");await n.delete(m).then(async v=>{v.success&&(G.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await Ye(f),o&&_(o,m),(c?.path===m||c?.path.startsWith(`${m}/`))&&(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}u()},[vt,wt,lt,n,Ye,h,_,o,c?.path,me,e]);r.useEffect(()=>{if(!D){is([]),as(!1);return}const t=Z.trim();if(!t){is([]),as(!1);return}let i=!1;return as(!0),H(D,t,150,{includeHidden:V,respectGitignore:!j,type:"file"}).then(l=>{if(i)return;const m=l.filter(f=>j||!vo(f.path)).map(f=>({name:f.name,path:B(f.path),type:"file",extension:f.extension,relativePath:f.relativePath}));is(m)}).catch(()=>{i||is([])}).finally(()=>{i||as(!1)}),()=>{i=!0}},[D,Z,H,V,j]);const Un=r.useCallback(async t=>{const i=await He(t);if(n.readFile)return(await n.readFile(t,{...i,directory:o||void 0})).content??"";const l=new URLSearchParams({path:t});i.allowOutsideWorkspace&&l.set("allowOutsideWorkspace","true"),i.outsideFileGrant&&l.set("outsideFileGrant",i.outsideFileGrant),o&&l.set("directory",o);const u=await wr(`/api/fs/read?${l.toString()}`);if(!u.ok){const m=await u.json().catch(()=>({error:u.statusText}));throw new Error(m.error||e("filesView.error.readFileFailed"))}return u.text()},[n,He,o,e]),ut=r.useCallback(async t=>{if(n.statFile){const i=await He(t),l=await n.statFile(t,{...i,directory:o||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[n,He,o]);r.useEffect(()=>{if(!o||!n.statFile||Y.length===0)return;let t=!1;const i=[...Y];return Promise.all(i.map(async l=>{try{const u=await He(l),m=await n.statFile?.(l,{...u,directory:o||void 0});!t&&m&&!m.isFile&&_(o,l)}catch(u){!t&&Ar(u)&&_(o,l)}})),()=>{t=!0}},[n,Y,_,He,o]);const $s=r.useMemo(()=>R.length>At?`${R.slice(0,At)}
|
|
14
|
-
|
|
15
|
-
… truncated …`:R,[R]),Me=re!==$s,Dt=r.useCallback(async()=>{if(!c||!n.writeFile)return G.error(e("filesView.toast.savingNotSupported")),!1;const t=ys(c.path)||Ut;if(!oo({selectedFilePath:c.path,loadedFilePath:Pe,fileLoading:Be,isDirty:Me,draftContent:re,fileContent:R,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):re===""&&R!==""&&Pe!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${R.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Me)return!0;Ps(!0);try{const i=jo(re,wn);if(!(await n.writeFile(c.path,i))?.success)return G.error(e("filesView.toast.writeFileFailed")),!1;if(he(re),o&&Rs(c.path,o)){const u=Cs(o,c.path);u&&ga.requestGitRefresh({directory:o,paths:[u]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(B(c.path))){const u=xa.getState().projects.find(m=>B(m.path)===B(o));if(u)try{await Wa(u.id)}catch{G.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&sn(c.path)&&(ot.current=re,Wt.current=re),ut(c.path).then(u=>{u&&(Xe.current=u)}).catch(()=>{}),!0}catch(i){return G.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Ps(!1)}},[Ut,re,R,Be,n,Me,wn,Pe,ut,o,c,e]);r.useEffect(()=>{je||(St("idle"),qe.current&&(clearTimeout(qe.current),qe.current=null))},[je]);const Kn=1500;r.useEffect(()=>{const t=!!(c&&n.writeFile),i=!!(c?.path&&(ys(c.path)||Ut));if(ao({autoSaveEnabled:je,isDirty:Me,canWrite:t,isSaving:$t,fileLoading:Be,selectedFilePath:c?.path,loadedFilePath:Pe,isNonEditableBinary:i}))return qe.current=setTimeout(()=>{Dt().then(l=>{l&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},Kn),()=>{qe.current&&(clearTimeout(qe.current),qe.current=null)}},[je,Ut,re,Be,Me,Pe,c,n.writeFile,$t,Dt]),r.useEffect(()=>{St("idle")},[c?.path]),va({save_file:t=>{if(!(t.target instanceof Node)||!us.current?.contains(t.target))return!1;qe.current&&(clearTimeout(qe.current),qe.current=null),$t||Dt().then(i=>{i&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node)||!us.current?.contains(t.target))return!1;le(!0)}});const Gn=r.useCallback(async t=>{const i=_t.current+1;_t.current=i;const l=()=>{if(!o)return!1;const N=Ke.getState().byRoot[o],O=N?.selectedPath??N?.openPaths[0]??null;return _t.current===i&&O===t.path};if(ge(null),Ie(""),oe(null),yn(!1),at(!0),await He(t.path),!l())return;const u=Nr(t.path),m=Cr(t.path),f=Sr(t.path),v=ys(t.path);if(h&&P(!0),d.isDesktop&&u&&!m){he(""),xe("");return}if(!d.isDesktop&&u&&!m){he(""),xe(""),oe(t.path),at(!1);return}if(f){he(""),xe(""),oe(t.path),at(!1);return}if(v){he(""),xe(""),oe(t.path),at(!1);return}await Un(t.path).then(N=>{if(!l())return;if(wa(N)){yn(!0),he(""),xe(""),oe(t.path);return}const O=qr(N);si(yo(N)),he(O),ot.current=O,Wt.current=O,xe(O.length>At?`${O.slice(0,At)}
|
|
16
|
-
|
|
17
|
-
… truncated …`:O),oe(t.path),ut(t.path).then(ft=>{ft&&l()&&(Xe.current=ft)}).catch(()=>{})}).catch(N=>{if(l()){if(wo(N)){if(at(!1),o&&me(o,null),ge(null),he(""),xe(""),oe(null),Xe.current=null,T.trim().length>0&&k(""),h&&P(!1),o){const ft=[...Lr(t.path,o),t.path];ft.length>0&&ss(o,ft);for(const mt of ft)ze.current.has(mt)||Ae(mt)}return}if(Ar(N)){o&&_(o,t.path),he(""),xe(""),ge(null),Xe.current=null,h&&P(!1);return}he(""),xe(""),ge(N instanceof Error?N.message:e("filesView.error.readFileFailed")),Xe.current=null}}).finally(()=>{l()&&at(!1)})},[ss,h,Ae,Un,ut,_,He,o,d.isDesktop,T,me,e]),gs=r.useCallback(async(t,i)=>{if(!o)return;const l=Lr(t,o),u=i?[...l,t]:l;u.length>0&&ss(o,u);const m=u.map(f=>{if(!ze.current.has(f))return Ae(f)}).filter(Boolean);await Promise.all(m)},[ss,Ae,o]),Hn=r.useCallback((t,i)=>{const l=i.findIndex(u=>u.path===t);return l===-1||i.length<=1?null:i[l+1]??i[l-1]??null},[]),Re=r.useCallback(async t=>{if(Ht.current)Ht.current=!1;else if(Me){Kt(!0),kt.current=t;return}o&&(me(o,t.path),gs(t.path,!1)),ge(null),Ie(""),he(""),ot.current="",Wt.current="",xe(""),oe(null),h&&P(!0)},[gs,Me,h,o,me]);r.useEffect(()=>{c?.path&&gs(c.path,!1)},[gs,c?.path]),r.useEffect(()=>{if(!c){_t.current+=1,Ct.current=null,at(!1);return}if(Pe===c.path||Ct.current===c.path)return;const t=c.path;Ct.current=t,Gn(c).finally(()=>{Ct.current===t&&(Ct.current=null)})},[ls,Gn,Pe,c]);const Ws=r.useRef(Me);Ws.current=Me,r.useEffect(()=>_a(({runtimeKey:t,paths:i})=>{const l=c?.path;t!==ia()||!l||Ws.current||!i.includes(B(l))||(_t.current+=1,Ct.current=null,Xe.current=null,Ie(""),ge(null),oe(null),ri(u=>u+1))}),[c?.path]),r.useEffect(()=>{if(!c?.path||Pe!==c.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||ut(c.path).then(l=>{if(t||!l)return;const u=Xe.current;if(!u||u.path!==c.path){Xe.current=l;return}const m=l.mtimeMs!==void 0&&u.mtimeMs!==void 0&&l.mtimeMs!==u.mtimeMs,f=l.size!==u.size;!m&&!f||Ws.current||(Xe.current=l,oe(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[Pe,ut,c?.path]);const ki=r.useCallback(()=>{const t=kt.current,i=Gt.current;if(kt.current=null,Gt.current=null,Ht.current=!0,Kt(!1),xe($s),i){o&&Ze(o,i),c?.path===i&&(t?Re(t):(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1)));return}if(t){Re(t);return}},[$s,Re,h,Ze,o,c?.path,me]),Ri=r.useCallback(async()=>{const t=kt.current,i=Gt.current;if(!await Dt()){Ht.current=!1;return}if(kt.current=null,Gt.current=null,Ht.current=!0,Kt(!1),i){o&&Ze(o,i),c?.path===i&&(t?await Re(t):(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1)));return}if(t){await Re(t);return}},[Re,h,Ze,o,Dt,c?.path,me]),qn=r.useCallback(t=>{const i=c?.path===t,l=Hn(t,Nt);if(i&&Me){Kt(!0),kt.current=l,Gt.current=t;return}if(o&&Ze(o,t),!!i){if(l){Re(l);return}o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1)}},[Hn,Re,Me,h,Nt,Ze,o,c?.path,me]),Vi=r.useCallback(t=>{if(Y.includes(t))return"open";if(I?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=I.files.find(u=>u.path===i);if(l){if(l.index==="A"||l.working_dir==="?")return"git-added";if(l.index==="D")return"git-deleted";if(l.index==="M"||l.working_dir==="M")return"git-modified"}}return null},[Y,I,o]),Ti=r.useCallback(t=>{if(!I?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=i?`${i}/`:"";let u=0,m=0;for(const f of I.files)f.path.startsWith(l)&&((f.index==="M"||f.working_dir==="M")&&u++,(f.index==="A"||f.working_dir==="?")&&m++);return u+m>0?{modified:u,added:m}:null},[I,o]),Di=r.useCallback(async t=>{const i=B(t);o&&(dn(o,i),ze.current.has(i)||await Ae(i))},[Ae,o,dn]),Pi=r.useMemo(()=>({canRename:kn,canCreateFile:Cn,canCreateFolder:Sn,canDelete:Rn,canReveal:Vn}),[kn,Cn,Sn,Rn,Vn]);function Xn(t,i){const l=gn[t]??[];return l.map((u,m)=>{const f=u.type==="directory",v=f&&pe.includes(u.path),N=c?.path===u.path,O=m===l.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),O&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(No,{node:u,root:o,isExpanded:v,isActive:N,isMobile:h,isBrowserClient:C,alwaysShowActions:S,status:f?void 0:Vi(u.path),badge:f?Ti(u.path):void 0,permissions:Pi,downloadFile:n.downloadFile,contextMenuPath:di,setContextMenuPath:fi,rightClickMenuPath:mi,setRightClickMenuPath:hi,onSelect:Re,onToggle:Di,onRevealPath:yi,onOpenDialog:As}),f&&v&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[rs[u.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:rs[u.path],children:rs[u.path]}),s.jsxs(z,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ye(u.path)},children:[s.jsx(w,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,Xn(u.path,i+1)]})]},u.path)})}const Fe=!!(c?.path&&Nr(c.path)),xs=!!(c?.path&&Cr(c.path)),Oe=!!(c?.path&&Sr(c.path)),_s=!!(c?.path&&(ys(c.path)||Ut)),st=_s&&!Fe&&!Oe,Jn=r.useMemo(()=>B(Je?.path??""),[Je?.path]),Pt=!!(Je&&Jn&&Ge&&Ge===Jn&&!Be&&!et&&!Fe&&!Oe&&!st),dt=r.useMemo(()=>Cs(o,Ge),[Ge,o]),Ei=!!(c&&(!Fe||xs)&&!Oe&&!st&&R.length>0),Mi=!!(c&&dt.length>0),_e=!!(c&&!ns&&!_s&&!Fe&&n.writeFile&&R.length<=At),bt=!!(c?.path&&Or(c.path)),Zt=!!(c?.path&&Fo(c.path)),Et=!!(c?.path&&on(c.path)),Qt=!!(c?.path&&sn(c.path)),Us=!!(c&&!_s&&!Fe)&&!bt&&!Qt&&!(Et&&M==="preview"),zi=bt&&we==="edit"||Et&&M==="edit"||Zt&&ue==="text"||!bt&&!Et&&!Zt&&E==="edit",vs=r.useMemo(()=>Ge?ba(Ge):null,[Ge]),[Yn,Ks]=r.useState(null);r.useEffect(()=>{let t=!1;const i=c?.path;if(!i||vs){Ks(null);return}return Ks(null),ya(i).then(l=>{t||Ks(l)}),()=>{t=!0}},[c?.path,vs]),r.useEffect(()=>{!_e&&E==="edit"&&ve("view")},[_e,E]);const Gs="openchamber:files:md-viewer-mode",Hs="openchamber:files:html-viewer-mode",qs="openchamber:files:json-viewer-mode";r.useEffect(()=>{const t=c?.path;if(!t)return;ve(ae.current[t]??"edit");let i=Jt?"preview":"edit";try{const m=localStorage.getItem(Gs);(m==="preview"||m==="edit")&&(i=m)}catch{}ce(ye.current[t]??i);let l=Jt?"preview":"edit";try{const m=localStorage.getItem(Hs);(m==="preview"||m==="edit")&&(l=m)}catch{}W(Ve.current[t]??l),ne(de.current[t]??(Jt?"preview":"edit"));let u=Jt?"tree":"text";try{const m=localStorage.getItem(qs);(m==="tree"||m==="text")&&(u=m)}catch{}be(u)},[c?.path,Jt]);const Li=r.useCallback(t=>{const i=c?.path;i&&(ae.current[i]=t),ve(t)},[c?.path]),Ii=r.useCallback(t=>{const i=c?.path;i&&(ye.current[i]=t),ce(t);try{localStorage.setItem(Gs,t)}catch{}},[c?.path]),nt=r.useCallback(()=>we,[we]),Ai=r.useCallback(t=>{be(t);try{localStorage.setItem(qs,t)}catch{}},[]),Oi=r.useCallback(t=>{const i=c?.path;i&&(Ve.current[i]=t),W(t);try{localStorage.setItem(Hs,t)}catch{}},[c?.path]),Bi=r.useCallback(t=>{const i=c?.path;if(i&&(de.current[i]=t),Ee.current&&(clearTimeout(Ee.current),Ee.current=null),tt.current!==null&&(cancelAnimationFrame(tt.current),tt.current=null),t==="edit")xe(ot.current||R),ne(t);else{ot.current=re;const l=i;ne("edit"),tt.current=requestAnimationFrame(()=>{tt.current=requestAnimationFrame(()=>{tt.current=null,!(o&&l&&Ke.getState().byRoot[o]?.selectedPath!==l)&&(ie(u=>u+1),ne("preview"))})});return}},[re,R,o,c?.path]),Xs=r.useCallback(async(t,i)=>{if(!n.writeFile||i===Wt.current)return!1;if(!(await n.writeFile(t,i))?.success)return G.error(e("filesView.toast.writeFileFailed")),!1;ot.current=i,Wt.current=i,xe(i);const u=await ut(t).catch(()=>null);return u&&(Xe.current=u),!0},[n,ut,e]);r.useEffect(()=>()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null),tt.current!==null&&(cancelAnimationFrame(tt.current),tt.current=null)},[se,c?.path]);const $i=r.useCallback(t=>{if(ot.current=t,!je||!c?.path||se!=="preview"||!n.writeFile)return;Ee.current&&clearTimeout(Ee.current);const i=c.path;Ee.current=setTimeout(()=>{Ee.current=null,Xs(i,t).then(l=>{l&&(cs(!0),setTimeout(()=>cs(!1),1500))}).catch(l=>{G.error(l instanceof Error?l.message:e("filesView.toast.saveFailed"))})},Kn)},[je,se,n.writeFile,Xs,c?.path,e]),Wi=r.useMemo(()=>Qt&&(ot.current||re)||R,[re,R,Qt]),Zn=r.useCallback(()=>M,[M]);r.useEffect(()=>{const t=l=>{const u=l?"preview":"edit",m=l?"tree":"text";for(const f of Y)ae.current[f]="edit",Or(f)&&(ye.current[f]=u),on(f)&&(Ve.current[f]=u),sn(f)&&(de.current[f]=u);ve("edit"),ce(u),W(u),ne(u),be(m);try{localStorage.setItem(Gs,u),localStorage.setItem(Hs,u),localStorage.setItem(qs,m)}catch{}},i=l=>{const u=!!l.detail?.enabled;t(u)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",i)}},[Y]),r.useEffect(()=>{if(!Je||!o)return;const t=()=>{typeof window>"u"||Rt.current===null&&(Rt.current=window.requestAnimationFrame(()=>{Rt.current=null,Ms(rt=>rt+1)}))},i=(rt,yt)=>{if(rt.state.doc.length!==yt.length)return!1;if(yt.length===0)return!0;const Qs=Math.min(128,yt.length);if(rt.state.sliceDoc(0,Qs)!==yt.slice(0,Qs))return!1;const pr=Math.max(0,yt.length-Qs);return rt.state.sliceDoc(pr,yt.length)===yt.slice(pr)},l=B(Je.path);if(!l){ds(null),xt.current={key:"",attempts:0};return}const u=`${l}:${Je.line}:${Je.column??1}`;if(xt.current.key!==u&&(xt.current={key:u,attempts:0}),c?.path!==l){if(Es)return;Re(Ft(l));return}if(Be||Pe!==l)return;if(et||Fe||Oe||st){ds(null),xt.current={key:"",attempts:0};return}if(!_e)return;if(E!=="edit"){ve("edit");return}const m=$e.current;if(!m){t();return}if(!i(m,re)){t();return}const f=Math.max(1,Math.min(Je.line,m.state.doc.lines)),v=m.state.doc.line(f),N=Math.max(1,Je.column||1),O=Math.max(0,v.to-v.from),ft=Math.min(O,N-1),mt=v.from+ft;if(!(m.state.selection.main.head===mt)||xt.current.attempts===0){xt.current.attempts+=1,m.dispatch({selection:{anchor:mt},effects:jt.scrollIntoView(mt,{y:"center"})}),m.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const rt=$e.current;rt&&(rt.dispatch({selection:{anchor:mt},effects:jt.scrollIntoView(mt,{y:"center"})}),rt.focus())}),ds(null),xt.current={key:"",attempts:0}},[_e,Es,re,li,et,Be,Fe,Oe,st,Pe,Re,Je,o,c?.path,ds,E,Ft]),r.useEffect(()=>{if(!Os||!o)return;const t=B(Os);if(!t){Bs(null);return}c?.path===t&&(Be||Pe!==t||(!et&&!Fe&&!Oe&&!st&&_e&&E==="edit"&&$e.current?.focus(),Bs(null)))},[_e,et,Be,Fe,Oe,st,Pe,Os,o,c?.path,Bs,E]);const Mt=r.useCallback(t=>{if(!h||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(i.offsetTop+i.height))<=0)return;const m=t.state.selection.main.head,f=t.coordsAtPos(m);if(!f)return;const v=Math.round(i.offsetTop+i.height),O=f.bottom+20-v;O<=0||(t.scrollDOM.scrollTop+=O)},[h]);r.useEffect(()=>{if(!h||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Mt($e.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[h,Mt]),ja("open_go_to_line",t=>{if(!_e||E!=="edit"||h)return!1;const i=t.target;if(i?.closest('[role="dialog"]')||!(i instanceof Node)||!us.current?.contains(i))return!1;const l=!!i?.closest(".cm-editor");if(!!i?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;Is(!0)});const ws=ht(t=>t.editorFontSize),Qn=r.useMemo(()=>{if(!c?.path)return[Rr(g,{fontSize:ws})];const t=tn(c.path),i=[Rr(g,t?{syntaxColors:!1,fontSize:ws}:{fontSize:ws})],l=vs??Yn;return l&&i.push(l),t&&i.push(Ma({language:t,themeName:g.metadata.id,theme:Aa(g)})),Q&&i.push(jt.lineWrapping),h&&i.push(jt.updateListener.of(u=>{u.view.hasFocus&&(u.selectionSet||u.focusChanged||u.viewportChanged||u.geometryChanged)&&window.requestAnimationFrame(()=>{Mt(u.view)})})),i},[g,c?.path,vs,Yn,Q,h,Mt,ws]),er=r.useMemo(()=>({light:Te.metadata.id,dark:De.metadata.id}),[Te.metadata.id,De.metadata.id]),es=c?.path&&Oe&&(!gt.allowOutsideWorkspace||gt.outsideFileGrant)?`${c.path}|${gt.allowOutsideWorkspace?"outside":"workspace"}|${gt.outsideFileGrant??""}|${ls}`:"",bs=c?.path&&Et&&M==="preview"&&!d.isVSCode?`${c.path}|${ls}`:"",tr=e("filesView.error.readFileFailed"),{readyKey:sr,nonce:_i}=Br(bs,ge,tr),{readyKey:nr,nonce:rr}=Br(es,ge,tr),Ui=!!(bs&&sr!==bs),ir=!!(es&&nr!==es),ar=c?.path&&Fe?xs?`data:${Fa(c.path)};utf8,${encodeURIComponent(R)}`:ti:"",or=c?.path&&Oe&&es&&nr===es?br().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:gt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:gt.outsideFileGrant,directory:o||void 0}):"",lr=r.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:or,className:"h-full w-full border-0",title:t.name},rr)}),[or,rr]);r.useEffect(()=>{let t=!1,i="";return(async()=>{if(!c?.path||!Fe||xs){Ie("");return}ge(null);const u=await He(c.path);if(t)return;await(n.readFileBinary?n.readFileBinary(c.path,u).then(f=>f.dataUrl):(async()=>{const f=await wr("/api/fs/raw",{query:{path:c.path,allowOutsideWorkspace:u.allowOutsideWorkspace?"true":void 0,outsideFileGrant:u.outsideFileGrant,directory:o||void 0}});if(!f.ok)throw new Error(e("filesView.error.readFileFailed"));const v=await f.blob();return i=URL.createObjectURL(v),t?(URL.revokeObjectURL(i),i="",""):i})()).then(f=>{t||(Ie(f),oe(c.path))}).catch(f=>{t||(Ie(""),ge(f instanceof Error?f.message:e("filesView.error.readFileFailed")),oe(null))}).finally(()=>{t||at(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[ls,n,Fe,xs,He,o,c?.path,gt,e]);const Ki=r.useCallback(()=>zs(null),[]),Gi=r.useMemo(()=>qa({drafts:En,editingDraftId:hs,commentText:ms,onTextChange:Mn,selection:A,isDragging:Dn,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:Bn,onCancel:()=>{We(null),Yt()},onEdit:t=>{An(t),We({start:t.startLine,end:t.endLine})},onDelete:On}),[Yt,ms,On,hs,En,Bn,Dn,A,c?.path,Mn,An]),cr=Mr(),ur=Mr(),Js=Ra("unified"),Ue=R.length>At,Ys=r.useMemo(()=>Ue?bo(R):void 0,[R,Ue]),dr=r.useCallback((t,i,l)=>{const u={name:t.name,contents:i,lang:tn(t.path)||void 0},m=f=>s.jsx(Ia,{file:Ue&&Ys?{...u,cacheKey:`${t.path}:${Ys}`}:u,options:{disableFileHeader:!0,overflow:Q?"wrap":"scroll",theme:er,themeType:g.metadata.variant==="dark"?"dark":"light"},className:Ue?"block w-full":"block h-full w-full",style:Ue?void 0:{height:"100%"}},f);return Ue?s.jsx("div",{className:"h-full",children:s.jsx(Oa.Provider,{value:l.virtualizer,children:s.jsx(Ba.Provider,{value:Js,children:m(`${t.path}:${Js?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:m(t.path)})},[g.metadata.variant,Ue,Ys,er,Js,Q]),fr=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!c)return null;const l=i==="docked",u=Na(Ca("save_file")),m=l?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",f=(v,N)=>s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:N})}),s.jsx(It,{side:"bottom",sideOffset:6,children:v})]});return s.jsxs("div",{className:m,children:[_e&&zi&&s.jsxs(s.Fragment,{children:[$t?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):je&&ii==="saved"&&!Me?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(w,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):Me?f(e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{Dt()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),"aria-label":e("filesView.editor.saveAria",{shortcut:u}),children:s.jsx(w,{name:"save-3",className:"size-4"})})):null,f(e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>oi(!je),className:U("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",je?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:je?s.jsx(w,{name:"file-check-fill",className:"size-4"}):s.jsx(w,{name:"file-check",className:"size-4"})}))]}),s.jsxs(ln,{onOpenChange:Ce,children:[s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(cn,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(w,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(un,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[vi.map(v=>s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{ji(v)},children:[s.jsx(fo,{label:v.label,iconDataUrl:v.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:v.label})]},v.id)),wi?s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{bi(!0)},children:[s.jsx(w,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!Fe&&!Oe&&!st&&s.jsxs(s.Fragment,{children:[f(e(Q?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ne(!Q),className:U("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Q?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(Q?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(w,{name:"text-wrap",className:"size-4"})})),E==="edit"&&s.jsxs(s.Fragment,{children:[f(e("filesView.editor.findInFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:v=>{le(!ee),v.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(w,{name:"search",className:"size-4"})})),f(e("filesView.editor.goToLine"),s.jsx(z,{variant:"ghost",size:"sm",onClick:v=>{Is(N=>!N),v.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(w,{name:"menu-fold-2",className:"size-4"})})),s.jsx(ro,{open:xi,onOpenChange:Is,view:$e.current,variant:"inline"})]})]}),Us&&_e&&!Zt&&!Et&&s.jsx(an,{currentMode:E==="view"?"preview":"edit",onToggle:()=>{Li(E==="view"?"edit":"view")}}),bt&&f(e(nt()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ii(nt()==="preview"?"edit":"preview"),className:U("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",nt()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(nt()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(nt()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(w,{name:nt()==="preview"?"eye":"eye-off",className:"size-4"})})),on(c?.path??"")&&s.jsx(an,{currentMode:Zn(),onToggle:()=>{Oi(Zn()==="preview"?"edit":"preview")}}),bt&&nt()==="preview"&&Fi&&s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(os?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{os?ei():R.trim()&&Qr(R)},children:os?s.jsx(w,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"volume-up",className:"size-4"})})}),s.jsx(It,{sideOffset:8,children:e(os?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),Qt&&s.jsxs(s.Fragment,{children:[s.jsx(an,{currentMode:se,onToggle:()=>Bi(se==="preview"?"edit":"preview")}),se==="preview"&&s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{const v=bn.current?.getXml();if(Ee.current&&(clearTimeout(Ee.current),Ee.current=null),c?.path&&v){if(!await Xs(c.path,v))return;cs(!0),setTimeout(()=>cs(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:ai?s.jsx(w,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"save-3",className:"size-4"})})]}),Zt&&f(e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ai(ue==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:ue==="tree"?s.jsx(w,{name:"code-sslash",className:"size-4"}):s.jsx(w,{name:"node-tree",className:"size-4"})})),Ei&&f(e("filesView.editor.copyFileContents"),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await ks(R)).ok?(Fn(!0),qt.current!==null&&window.clearTimeout(qt.current),qt.current=window.setTimeout(()=>{Fn(!1)},1200)):G.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:pi?s.jsx(w,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"clipboard",className:"size-4"})})),Mi&&f(e("filesView.editor.copyFilePathTitle",{path:dt}),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await ks(dt)).ok?(Nn(!0),Xt.current!==null&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>{Nn(!1)},1200)):G.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:dt}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:dt}),children:gi?s.jsx(w,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"file-copy-2",className:"size-4"})})),n.downloadFile&&f(e("filesView.editor.saveFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{const v=n.downloadFile;v&&v(c.path).catch(N=>{console.error("Download failed:",N),G.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(w,{name:"download",className:"size-4"})})),t?f(e("filesView.editor.exitFullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>q(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(w,{name:"fullscreen-exit",className:"size-4"})})):!h&&a==="full"&&f(e(K?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>q(!K),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(K?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(K?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:K?s.jsx(w,{name:"fullscreen-exit",className:"size-4"}):s.jsx(w,{name:"fullscreen",className:"size-4"})}))]})},Zs=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Wr,{open:Es,onOpenChange:t=>{t||Kt(!0)},children:s.jsxs(_r,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Ur,{children:[s.jsx(Kr,{children:e("filesView.unsaved.title")}),s.jsx(Gr,{children:e("filesView.unsaved.description")})]}),s.jsxs(Hr,{children:[s.jsx(z,{variant:"outline",onClick:()=>{Ri()},disabled:$t,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(z,{variant:"destructive",onClick:ki,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:U("flex flex-col flex-shrink-0",L&&"border-b border-border/40"),children:[L?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[h&&J&&s.jsx("button",{type:"button",onClick:()=>P(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(w,{name:"arrow-left-s",className:"size-5"})}),h?c?s.jsxs(ln,{children:[s.jsx(cn,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[s.jsx(Fs,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Ir,{name:c.name}),s.jsx(w,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(un,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs(Ns,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}i||Re(t)},className:U("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Fs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Ir,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),qn(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(w,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Nt.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[mn.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),mn.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:Ts,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs("div",{title:Cs(o,t.path),className:U("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx(Fs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||Re(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),qn(t.path)},className:U("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!S&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(w,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,c?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[dt&&!h?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:dt,children:dt}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:fr({layout:"docked"})})]}):null]}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(nn,{ref:cr.setScroller,outerClassName:"h-full min-w-0",className:U("h-full min-w-0",Ue&&"[overflow-anchor:none]"),children:c?Be||ir?$?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):et?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:et}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:ar,alt:c?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Oe?lr(c):st?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),G.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(w,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):c&&Qt&&se==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(co,{ref:bn,xml:Wi,onChange:$i},`${c.path}:${Se}`)}):c&&Zt&&ue==="tree"?s.jsx(rn,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(La,{jsonString:R,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&bt&&nt()==="preview"?s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3",ref:fs,children:[s.jsx(Dr,{containerRef:fs,filePath:c.path,fileContent:R}),R.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(R.length/1024)})}),s.jsx(rn,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(kr,{content:R,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):c&&Et&&M==="preview"?Ui?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!d.isVSCode&&sr===bs?(()=>{const t=c.path.split("/").map(i=>encodeURIComponent(i)).join("/");return br().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:d.isVSCode?(()=>{const t=c.path.substring(0,c.path.lastIndexOf("/")+1);return t?R.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):R})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},_i)}):c&&Us&&E==="view"?dr(c,Ue?R:re,cr):s.jsxs("div",{className:U("relative h-full",Pt&&"overflow-hidden"),ref:us,children:[s.jsx("div",{className:U("h-full",Pt&&"invisible"),children:s.jsx(Vr,{value:re,onChange:xe,readOnly:!_e,vimMode:Pn==="vim",extensions:Qn,className:"h-full",blockWidgets:Gi,onViewReady:t=>{$e.current=t,Ms(i=>i+1),window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{$e.current&&($e.current=null),Ms(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:le,highlightLines:A?{start:Math.min(A.start,A.end),end:Math.max(A.start,A.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const u=t.state.doc.lineAt(i.from).number;if(A&&!l.shiftKey&&Math.min(A.start,A.end)===u&&Math.max(A.start,A.end)===u)return We(null),Yt(),Vt.current=!1,ct.current=null,Tt(!1),!0;if(h&&A&&!l.shiftKey){const m=Math.min(A.start,A.end,u),f=Math.max(A.start,A.end,u);return We({start:m,end:f}),Vt.current=!1,ct.current=null,Tt(!1),!0}if(Vt.current=!0,ct.current=u,Tt(!0),A&&l.shiftKey){const m=Math.min(A.start,u),f=Math.max(A.end,u);We({start:m,end:f})}else We({start:u,end:u});return!0},mouseover:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Vt.current||ct.current===null)return!1;const u=t.state.doc.lineAt(i.from).number,m=Math.min(ct.current,u),f=Math.max(ct.current,u);return We({start:m,end:f}),Tt(!0),!1},mouseup:()=>(Vt.current=!1,ct.current=null,Tt(!1),!1)}}})}),Pt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})})]}),Hi=!!(o&&gn[o]),mr=o?rs[o]:null,hr=s.jsxs("section",{className:U("flex min-h-0 flex-col overflow-hidden",h?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:U("flex flex-col gap-2 py-2",h?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(w,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(Ss,{ref:X,value:T,onChange:t=>k(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),T.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{k(""),X.current?.focus()},children:s.jsx(w,{name:"close",className:"size-4"})})]}),s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>As("createFile",{path:D,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(w,{name:"file-add",className:"size-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>As("createFolder",{path:D,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(w,{name:"folder-add",className:"size-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{ps()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(w,{name:"refresh",className:"size-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(nn,{outerClassName:"flex-1 min-h-0",className:U("py-2",h?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:Zr?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):vn.length>0?vn.map(t=>{const i=c?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{Re(t)},className:U("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Xr(t.path,t.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):mr?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:mr}),s.jsxs(z,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ps()},children:[s.jsx(w,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Hi?Xn(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),qi=a==="full"&&K&&c&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:fr({exitFullscreenOnly:!0})}),s.jsx(nn,{ref:ur.setScroller,outerClassName:"h-full min-w-0",className:U("h-full min-w-0",Ue&&"[overflow-anchor:none]"),children:Be||ir?$?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):et?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:et}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:ar,alt:c.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Oe?lr(c):st?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),G.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(w,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):bt&&nt()==="preview"?s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4",ref:fs,children:[c?s.jsx(Dr,{containerRef:fs,filePath:c.path,fileContent:R}):null,R.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(R.length/1024)})}),s.jsx(rn,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(kr,{content:R,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):Us&&E==="view"?dr(c,Ue?R:re,ur):s.jsxs("div",{className:U("relative h-full",Pt&&"overflow-hidden"),children:[s.jsx("div",{className:U("h-full",Pt&&"invisible"),children:s.jsx(Vr,{value:re,onChange:xe,readOnly:!_e,vimMode:Pn==="vim",extensions:Qn,className:"h-full",onViewReady:t=>{$e.current=t,window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{$e.current&&($e.current=null)}})}),Pt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Co,{activeDialog:vt,dialogData:wt,dialogInputValue:lt,onDialogInputChange:jn,isDialogSubmitting:ui,onDialogSubmit:Si,onClose:Ki,inputRef:ni}),qi,h?J?Zs:hr:a==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Zs})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[p>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:hr}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Zs})]})]})};function So(a){return a+1}export{Hc as FilesView};
|