@openchamber/web 1.24.0 → 1.24.2
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 +29 -6
- package/bin/lib/cli-http.js +5 -1
- package/bin/lib/commands-status.js +5 -0
- package/dist/assets/{CodeMirrorCommentWidgets-C9kV-n7r.js → CodeMirrorCommentWidgets-B_vBPQYm.js} +1 -1
- package/dist/assets/DiffView-Ce0oBXXQ.js +4 -0
- package/dist/assets/{FilesView-vjJx7VaM.js → FilesView-DtXueAWP.js} +6 -6
- package/dist/assets/GitView-k0hUF8KB.js +6 -0
- package/dist/assets/GuestAttachDialog-DIf2U85Z.js +1 -0
- package/dist/assets/{JsonTreeView-D_4G5X6-.js → JsonTreeView-4AnJ04Pw.js} +1 -1
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/{LinearIssuesView-1uKhePfH.js → LinearIssuesView-z_9p2GuO.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-Ix7N_2wp.js → MarkdownImageGallery-BC-BNN-s.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Deel_y5S.js → MarkdownRendererImpl-DyaBTUbH.js} +6 -6
- package/dist/assets/{OnboardingScreen-ToIakxb_.js → OnboardingScreen-DKU_yTb6.js} +1 -1
- package/dist/assets/{PatchDiff-BjMgezr1.js → PatchDiff-DpGmHRnV.js} +1 -1
- package/dist/assets/PierreDiffViewer-CgLl_tp7.js +210 -0
- package/dist/assets/{PlanView-BGAzxDwD.js → PlanView-CrfB4qqY.js} +4 -4
- package/dist/assets/PluginPane-B5cn-jPy.js +3 -0
- package/dist/assets/SettingsView-DMKKwezx.js +29 -0
- package/dist/assets/SettingsWindow-DwbnVzOC.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary--YFqK6Ih.js → SubmoduleDiffSummary-hkGcvs0E.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DRWBvdaJ.js → ToolOutputDialog-DuoIOc0j.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-BxZJCU28.js → ToolPartDiffPreview-t1Bvq_2Y.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-DCXjBGRf.js → VirtualizedFileDiff-BK4aU5qJ.js} +1 -1
- package/dist/assets/{WalkthroughView-CfIPvWWa.js → WalkthroughView-Bk6TPNFw.js} +2 -2
- package/dist/assets/{appThemeRegistry-DDROzcUO.js → appThemeRegistry-DnOVbJjF.js} +1 -1
- package/dist/assets/commitAndPush-DLWNZkkY.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-DHgQIkUq.js → computeVirtualFileMetrics-BVTujWSX.js} +1 -1
- package/dist/assets/{de-CX_f-T5U.js → de-zEHaAIi3.js} +4 -4
- package/dist/assets/{es-BERmWNn_.js → es-CBDgEzgk.js} +4 -4
- package/dist/assets/{fr-BjYYE_-z.js → fr-DjiTptT_.js} +4 -4
- package/dist/assets/index-AgOdanig.css +1 -0
- package/dist/assets/index-B-2_X4DD.js +40 -0
- package/dist/assets/{index-WjufPkIV.js → index-CkA4p2IK.js} +1 -1
- package/dist/assets/{isDiffPlainText-D9faP70y.js → isDiffPlainText-D3yX_vx4.js} +1 -1
- package/dist/assets/{isFilePlainText-6qOcz5Ky.js → isFilePlainText-CZR9TcHV.js} +1 -1
- package/dist/assets/ja-CerMgj3r.js +16 -0
- package/dist/assets/{ko-Dty1aUod.js → ko-DHYDAze5.js} +4 -4
- package/dist/assets/main-BDka4W43.js +896 -0
- package/dist/assets/main-Dl7Dyge_.js +2 -0
- package/dist/assets/markdownCore-DFmr0rUR.js +5 -0
- package/dist/assets/miniChat-CLKQPPpO.js +2 -0
- package/dist/assets/mobile--giD2Q1L.js +2 -0
- package/dist/assets/{patchFileDiff-BvU6KOQC.js → patchFileDiff-DRh-AQvd.js} +1 -1
- package/dist/assets/{pl-CX-_ROkr.js → pl-BTB_93bq.js} +6 -6
- package/dist/assets/{pt-BR-DhRR1arx.js → pt-BR-BwA3oyCK.js} +4 -4
- package/dist/assets/renderElectronMiniChatApp-DmB7zpVK.js +2 -0
- package/dist/assets/renderMobileApp-pMfOuQfl.js +25 -0
- package/dist/assets/runtimeEndpointReset-Gqhmkm3U.js +25 -0
- package/dist/assets/{scheduledTasksApi-DW3xqMQ8.js → scheduledTasksApi-CeRAIUmW.js} +1 -1
- package/dist/assets/{shikiHighlight-DsxD9QEa.js → shikiHighlight-BfjuB3CD.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-Da7ed8qM.js → textMateThemeFromAppTheme-BP60t9SX.js} +1 -1
- package/dist/assets/tr-CcPsJoNM.js +7 -0
- package/dist/assets/{uk-CD21CXFV.js → uk-B68WibXi.js} +4 -4
- package/dist/assets/{useAppFontEffects-hfv2s6mZ.js → useAppFontEffects-DcdrFv2Z.js} +147 -147
- package/dist/assets/{useInlineCommentController-BmtfVbo8.js → useInlineCommentController-Cq4SUjsA.js} +2 -2
- package/dist/assets/useRootScrollLock-CSdR6Wnm.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-BPMJpOpT.js → vendor-codemirror-language-data-BFm1Ju2w.js} +2 -2
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
- package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
- package/dist/assets/{vendor-zod-fZppILAM.js → vendor-zod-CgAdXWZO.js} +4 -4
- package/dist/assets/{web-components-U-hWbgJo.js → web-components-2vo9YsZc.js} +1 -1
- package/dist/assets/zh-CN-DbFHYXwP.js +16 -0
- package/dist/assets/{zh-TW-CRp5dJU2.js → zh-TW-DmXAwdty.js} +4 -4
- package/dist/index.html +6 -4
- package/dist/mini-chat.html +6 -4
- package/dist/mobile.html +6 -4
- package/package.json +6 -5
- package/server/index.js +29 -7
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -4
- package/server/lib/agent-tool/runtime.js +62 -15
- package/server/lib/agent-tool/runtime.test.js +88 -2
- package/server/lib/changelog/update-notes.js +2 -1
- package/server/lib/changelog/update-notes.test.js +19 -0
- package/server/lib/event-stream/DOCUMENTATION.md +23 -0
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +292 -0
- package/server/lib/event-stream/global-hub.js +53 -23
- package/server/lib/event-stream/global-hub.test.js +160 -0
- package/server/lib/event-stream/global-ws-bridge.js +1 -0
- package/server/lib/event-stream/index.js +4 -0
- package/server/lib/fs/DOCUMENTATION.md +2 -1
- package/server/lib/fs/routes.js +56 -4
- package/server/lib/fs/routes.test.js +116 -0
- package/server/lib/git/DOCUMENTATION.md +18 -5
- package/server/lib/git/routes.js +1 -1
- package/server/lib/git/serial-refresh.js +93 -0
- package/server/lib/git/serial-refresh.test.js +112 -0
- package/server/lib/git/service.js +325 -70
- package/server/lib/git/service.test.js +291 -0
- package/server/lib/github/pr-status.js +5 -5
- package/server/lib/github/pr-status.test.js +1 -1
- package/server/lib/github/routes.js +4 -4
- package/server/lib/guests/DOCUMENTATION.md +5 -3
- package/server/lib/guests/background.test.js +83 -0
- package/server/lib/guests/catalog.js +20 -9
- package/server/lib/guests/catalog.test.js +5 -5
- package/server/lib/guests/routes.js +2 -2
- package/server/lib/message-queue/DOCUMENTATION.md +10 -1
- package/server/lib/message-queue/runtime.js +21 -1
- package/server/lib/message-queue/runtime.test.js +52 -5
- package/server/lib/notifications/routes.js +5 -0
- package/server/lib/openchamber-sessions/routes.js +18 -18
- package/server/lib/openchamber-sessions/routes.test.js +49 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +5 -0
- package/server/lib/opencode/session-runtime.js +68 -0
- package/server/lib/opencode/session-runtime.test.js +43 -0
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-registry.json +8 -0
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
- package/server/lib/permission-auto-accept/runtime.js +13 -0
- package/server/lib/permission-auto-accept/runtime.test.js +37 -1
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/realtime-proxy-terminal.test.js +150 -0
- package/server/lib/realtime-proxy.js +2 -0
- package/server/lib/routing/DOCUMENTATION.md +83 -0
- package/server/lib/routing/defaults.js +98 -0
- package/server/lib/routing/feature-flag.js +11 -0
- package/server/lib/routing/history.js +34 -0
- package/server/lib/routing/jev.js +98 -0
- package/server/lib/routing/routes.http.test.js +100 -0
- package/server/lib/routing/routes.js +81 -0
- package/server/lib/routing/runtime.js +217 -0
- package/server/lib/routing/runtime.test.js +188 -0
- package/server/lib/routing/store.js +249 -0
- package/server/lib/routing/store.test.js +96 -0
- package/server/lib/scheduled-tasks/runtime.js +2 -2
- package/server/lib/scheduled-tasks/runtime.test.js +14 -0
- package/server/lib/security/request-security.js +9 -5
- package/server/lib/security/request-security.test.js +37 -0
- package/server/lib/small-model/DOCUMENTATION.md +14 -2
- package/server/lib/small-model/call.js +37 -6
- package/server/lib/small-model/call.test.js +182 -0
- package/server/lib/terminal/DOCUMENTATION.md +21 -2
- package/server/lib/terminal/runtime.js +10 -3
- package/server/lib/terminal/runtime.test.js +22 -0
- package/server/lib/terminal/shutdown.js +106 -0
- package/server/lib/terminal/shutdown.test.js +84 -0
- package/server/lib/tts/service.test.js +78 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
- package/server/lib/ui-auth/session-cookie.js +51 -0
- package/server/lib/ui-auth/session-cookie.test.js +46 -0
- package/server/lib/ui-auth/ui-auth.js +13 -9
- package/server/lib/ui-auth/ui-auth.test.js +56 -0
- package/dist/assets/DiffView-B7YkbY-u.js +0 -4
- package/dist/assets/DirtyBranchSwitchDialog-CU0A93Zx.js +0 -1
- package/dist/assets/GitView-BLhlMYEY.js +0 -6
- package/dist/assets/GuestAttachDialog-B-fwE8r3.js +0 -3
- package/dist/assets/PierreDiffViewer-53Ghfnlr.js +0 -161
- package/dist/assets/SettingsView-n2X-jfBB.js +0 -29
- package/dist/assets/SettingsWindow-Bi8LE9XI.js +0 -1
- package/dist/assets/index-DpzTz2UH.css +0 -1
- package/dist/assets/index-Dy8xgawx.js +0 -40
- package/dist/assets/ja-DxqeAk9N.js +0 -16
- package/dist/assets/main-BOYSXfYn.js +0 -896
- package/dist/assets/main-Bjcre_GE.js +0 -2
- package/dist/assets/markdownCore-DPrwM1rU.js +0 -5
- package/dist/assets/miniChat-Dz_bPgMc.js +0 -2
- package/dist/assets/mobile-BbZPBJrK.js +0 -2
- package/dist/assets/renderElectronMiniChatApp-uNEUkeAI.js +0 -2
- package/dist/assets/renderMobileApp-BK1kFlcJ.js +0 -25
- package/dist/assets/runtimeEndpointReset-BULHvOwb.js +0 -25
- package/dist/assets/tr-cIQtYBpg.js +0 -7
- package/dist/assets/useRootScrollLock-Cwc4kSl2.js +0 -1
- package/dist/assets/zh-CN-BWvlPHY-.js +0 -16
- /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session cookie naming that is stable per host:port.
|
|
3
|
+
*
|
|
4
|
+
* Browsers do not isolate cookies by port (RFC 6265). Instances on the same
|
|
5
|
+
* hostname overwrite one another's session cookies without distinct names.
|
|
6
|
+
* This applies to LAN addresses and same-host loopback instances alike.
|
|
7
|
+
*
|
|
8
|
+
* We fold the request port into the cookie name so each port owns its own
|
|
9
|
+
* cookie. Password/passkey session issuance and validation (`ui-auth.js`) and
|
|
10
|
+
* notification identity extraction (`request-security.js`) share this resolver.
|
|
11
|
+
* A host with no explicit port keeps the bare `oc_ui_session` name.
|
|
12
|
+
*/
|
|
13
|
+
export const SESSION_COOKIE_BASE = 'oc_ui_session';
|
|
14
|
+
|
|
15
|
+
const forwardedHost = (headers) => {
|
|
16
|
+
const forwarded = headers?.['x-forwarded-host'];
|
|
17
|
+
if (typeof forwarded === 'string' && forwarded.trim().length > 0) {
|
|
18
|
+
return forwarded.split(',')[0].trim();
|
|
19
|
+
}
|
|
20
|
+
const host = headers?.host;
|
|
21
|
+
return typeof host === 'string' ? host.trim() : '';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Extract the trailing port from a Host authority, or null when there is none.
|
|
26
|
+
* Handles bracketed IPv6 (`[::1]:3000`, `[::1]`) and plain host names.
|
|
27
|
+
*/
|
|
28
|
+
const hostPort = (host) => {
|
|
29
|
+
if (host.startsWith('[')) {
|
|
30
|
+
const end = host.indexOf(']');
|
|
31
|
+
if (end === -1) return null;
|
|
32
|
+
const rest = host.slice(end + 1);
|
|
33
|
+
if (!rest.startsWith(':')) return null;
|
|
34
|
+
return /^\d+$/.test(rest.slice(1)) ? rest.slice(1) : null;
|
|
35
|
+
}
|
|
36
|
+
const matches = host.match(/:(\d+)$/);
|
|
37
|
+
return matches ? matches[1] : null;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the session cookie name for a request. Returns the bare base name
|
|
42
|
+
* when the host carries no explicit port, otherwise `<base>_<port>`.
|
|
43
|
+
*/
|
|
44
|
+
export const sessionCookieNameForRequest = (req, base = SESSION_COOKIE_BASE) => {
|
|
45
|
+
const host = forwardedHost(req?.headers || {});
|
|
46
|
+
const port = host ? hostPort(host) : null;
|
|
47
|
+
if (!port) return base;
|
|
48
|
+
const portNumber = Number.parseInt(port, 10);
|
|
49
|
+
if (!Number.isFinite(portNumber) || portNumber <= 0) return base;
|
|
50
|
+
return `${base}_${port}`;
|
|
51
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
SESSION_COOKIE_BASE,
|
|
4
|
+
sessionCookieNameForRequest,
|
|
5
|
+
} from './session-cookie.js';
|
|
6
|
+
|
|
7
|
+
const req = (host, forwarded) => ({
|
|
8
|
+
headers: {
|
|
9
|
+
...(host ? { host } : {}),
|
|
10
|
+
...(forwarded ? { 'x-forwarded-host': forwarded } : {}),
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('sessionCookieNameForRequest', () => {
|
|
15
|
+
test('keeps the bare base name when the host has no explicit port', () => {
|
|
16
|
+
expect(sessionCookieNameForRequest(req('192.168.0.1'))).toBe(SESSION_COOKIE_BASE);
|
|
17
|
+
expect(sessionCookieNameForRequest(req('example.com'))).toBe(SESSION_COOKIE_BASE);
|
|
18
|
+
expect(sessionCookieNameForRequest(req(''))).toBe(SESSION_COOKIE_BASE);
|
|
19
|
+
expect(sessionCookieNameForRequest(undefined)).toBe(SESSION_COOKIE_BASE);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('folds the port into the name so LAN instances on one IP are isolated', () => {
|
|
23
|
+
expect(sessionCookieNameForRequest(req('192.168.0.1:3000'))).toBe('oc_ui_session_3000');
|
|
24
|
+
expect(sessionCookieNameForRequest(req('192.168.0.1:3001'))).toBe('oc_ui_session_3001');
|
|
25
|
+
expect(sessionCookieNameForRequest(req('192.168.0.1:8080'))).toBe('oc_ui_session_8080');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('handles IPv6 authorities', () => {
|
|
29
|
+
expect(sessionCookieNameForRequest(req('[::1]:3000'))).toBe('oc_ui_session_3000');
|
|
30
|
+
expect(sessionCookieNameForRequest(req('[::1]'))).toBe(SESSION_COOKIE_BASE);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('prefers the forwarded host port over the direct host', () => {
|
|
34
|
+
expect(sessionCookieNameForRequest(req('127.0.0.1:3902', '203.0.113.9:8443')))
|
|
35
|
+
.toBe('oc_ui_session_8443');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('ignores malformed or non-numeric ports', () => {
|
|
39
|
+
expect(sessionCookieNameForRequest(req('192.168.0.1:notaport'))).toBe(SESSION_COOKIE_BASE);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('honours a custom base name', () => {
|
|
43
|
+
expect(sessionCookieNameForRequest(req('127.0.0.1:3000'), 'my_app')).toBe('my_app_3000');
|
|
44
|
+
expect(sessionCookieNameForRequest(req('127.0.0.1'), 'my_app')).toBe('my_app');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -4,6 +4,7 @@ import fs from 'fs';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import os from 'os';
|
|
6
6
|
import { createUiPasskeys } from './ui-passkeys.js';
|
|
7
|
+
import { sessionCookieNameForRequest } from './session-cookie.js';
|
|
7
8
|
|
|
8
9
|
const SESSION_COOKIE_NAME = 'oc_ui_session';
|
|
9
10
|
const SESSION_TTL_MS = 12 * 60 * 60 * 1000;
|
|
@@ -516,7 +517,7 @@ export const createUiAuth = ({
|
|
|
516
517
|
const secure = isSecureRequest(req);
|
|
517
518
|
const maxAgeSeconds = Math.floor(ttlMs / 1000);
|
|
518
519
|
const header = buildCookie({
|
|
519
|
-
name: cookieName,
|
|
520
|
+
name: sessionCookieNameForRequest(req, cookieName),
|
|
520
521
|
value: encodeURIComponent(token),
|
|
521
522
|
maxAge: maxAgeSeconds,
|
|
522
523
|
secure,
|
|
@@ -526,8 +527,9 @@ export const createUiAuth = ({
|
|
|
526
527
|
|
|
527
528
|
const ensureSessionToken = async (req, res) => {
|
|
528
529
|
const cookies = parseCookies(req.headers.cookie);
|
|
529
|
-
|
|
530
|
-
|
|
530
|
+
const name = sessionCookieNameForRequest(req, cookieName);
|
|
531
|
+
if (cookies[name]) {
|
|
532
|
+
return cookies[name];
|
|
531
533
|
}
|
|
532
534
|
const token = crypto.randomBytes(32).toString('base64url');
|
|
533
535
|
setSessionCookie(req, res, token, sessionTtlMs);
|
|
@@ -560,8 +562,9 @@ export const createUiAuth = ({
|
|
|
560
562
|
|
|
561
563
|
const resolveAuthContext = async (req, res, { allowClientAuth = true, allowUrlToken = true } = {}) => {
|
|
562
564
|
const cookies = parseCookies(req.headers.cookie);
|
|
563
|
-
|
|
564
|
-
|
|
565
|
+
const name = sessionCookieNameForRequest(req, cookieName);
|
|
566
|
+
if (cookies[name]) {
|
|
567
|
+
return { type: 'session', token: cookies[name] };
|
|
565
568
|
}
|
|
566
569
|
if (allowClientAuth) {
|
|
567
570
|
const clientAuth = await authenticateClientRequest(req, { allowUrlToken });
|
|
@@ -672,8 +675,9 @@ export const createUiAuth = ({
|
|
|
672
675
|
|
|
673
676
|
const getTokenFromRequest = (req) => {
|
|
674
677
|
const cookies = parseCookies(req.headers.cookie);
|
|
675
|
-
|
|
676
|
-
|
|
678
|
+
const name = sessionCookieNameForRequest(req, cookieName);
|
|
679
|
+
if (cookies[name]) {
|
|
680
|
+
return cookies[name];
|
|
677
681
|
}
|
|
678
682
|
return null;
|
|
679
683
|
};
|
|
@@ -682,7 +686,7 @@ export const createUiAuth = ({
|
|
|
682
686
|
const secure = isSecureRequest(req);
|
|
683
687
|
const maxAgeSeconds = Math.floor(ttlMs / 1000);
|
|
684
688
|
const header = buildCookie({
|
|
685
|
-
name: cookieName,
|
|
689
|
+
name: sessionCookieNameForRequest(req, cookieName),
|
|
686
690
|
value: encodeURIComponent(token),
|
|
687
691
|
maxAge: maxAgeSeconds,
|
|
688
692
|
secure,
|
|
@@ -693,7 +697,7 @@ export const createUiAuth = ({
|
|
|
693
697
|
const clearSessionCookie = (req, res) => {
|
|
694
698
|
const secure = isSecureRequest(req);
|
|
695
699
|
const header = buildCookie({
|
|
696
|
-
name: cookieName,
|
|
700
|
+
name: sessionCookieNameForRequest(req, cookieName),
|
|
697
701
|
value: '',
|
|
698
702
|
maxAge: 0,
|
|
699
703
|
secure,
|
|
@@ -357,3 +357,59 @@ describe('ui auth client credential seam', () => {
|
|
|
357
357
|
expect(expiresAt).toBeLessThanOrEqual(Date.now() + 124_000);
|
|
358
358
|
});
|
|
359
359
|
});
|
|
360
|
+
|
|
361
|
+
// issue #2377: browsers key cookie jars on host only, so two instances on one
|
|
362
|
+
// LAN IP (different ports) collided on `oc_ui_session`. Cookies are now scoped
|
|
363
|
+
// by the request port so each instance owns its own slot.
|
|
364
|
+
describe('ui auth port-scoped session cookies (issue #2377)', () => {
|
|
365
|
+
const loginHost = async (auth, host) => {
|
|
366
|
+
const req = { method: 'POST', headers: { host }, body: { password: 'secret' } };
|
|
367
|
+
const res = createResponse();
|
|
368
|
+
await auth.handleSessionCreate(req, res);
|
|
369
|
+
return String(res.getHeader('set-cookie') || '').split(';', 1)[0];
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
it('names the issued cookie with the request port', async () => {
|
|
373
|
+
const createUiAuth = await loadCreateUiAuth();
|
|
374
|
+
const auth = createUiAuth({ password: 'secret' });
|
|
375
|
+
|
|
376
|
+
const issued = await loginHost(auth, '192.168.0.1:3000');
|
|
377
|
+
expect(issued).toMatch(/^oc_ui_session_3000=/);
|
|
378
|
+
expect(issued.length).toBeGreaterThan('oc_ui_session_3000='.length);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('keeps the bare cookie name when the host has no explicit port', async () => {
|
|
382
|
+
const createUiAuth = await loadCreateUiAuth();
|
|
383
|
+
const auth = createUiAuth({ password: 'secret' });
|
|
384
|
+
|
|
385
|
+
expect(await loginHost(auth, '192.168.0.1')).toMatch(/^oc_ui_session=/);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it('reads the slot for the request port and ignores another port cookie', async () => {
|
|
389
|
+
const createUiAuth = await loadCreateUiAuth();
|
|
390
|
+
const auth = createUiAuth({ password: 'secret' });
|
|
391
|
+
|
|
392
|
+
// Valid token issued against :3000.
|
|
393
|
+
const portCookie = await loginHost(auth, '192.168.0.1:3000');
|
|
394
|
+
const validToken = portCookie.slice('oc_ui_session_3000='.length);
|
|
395
|
+
|
|
396
|
+
// A request that lands on :3001 must read the :3001 slot, NOT the :3000 one,
|
|
397
|
+
// even though the browser ships both cookies to either port.
|
|
398
|
+
const wrongSlot = {
|
|
399
|
+
method: 'GET',
|
|
400
|
+
headers: { host: '192.168.0.1:3001', cookie: `oc_ui_session_3000=${validToken}; oc_ui_session_3001=stale` },
|
|
401
|
+
};
|
|
402
|
+
const wrongRes = createResponse();
|
|
403
|
+
await auth.handleSessionStatus(wrongSlot, wrongRes);
|
|
404
|
+
expect(wrongRes.body.authenticated).toBe(false);
|
|
405
|
+
|
|
406
|
+
// The same token read on its own port authenticates.
|
|
407
|
+
const rightSlot = {
|
|
408
|
+
method: 'GET',
|
|
409
|
+
headers: { host: '192.168.0.1:3000', cookie: `oc_ui_session_3000=${validToken}` },
|
|
410
|
+
};
|
|
411
|
+
const rightRes = createResponse();
|
|
412
|
+
await auth.handleSessionStatus(rightSlot, rightRes);
|
|
413
|
+
expect(rightRes.body.authenticated).toBe(true);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{R as i,f as Ye,j as t}from"./vendor-react-BUCujlKS.js";import{u as ae,O as Ce,a as Re,G as Fn}from"./index-Dy8xgawx.js";import{c as Dn,b as An,u as Vn,a as En,B as Ln,C as Tn,P as Tt,h as Mn,e as Bn,g as Pn,i as In,f as zn}from"./patchFileDiff-BvU6KOQC.js";import{c as On,b as _n,i as Kn,u as Gn,a as Hn,d as $n,S as qn}from"./SubmoduleDiffSummary--YFqK6Ih.js";import{f as ze,B as fe,I as L,h as je,Z as $t,af as Wn,K as ne,ag as Un,bf as Jn,J as Xn,ah as Yn,aj as Qn,z as Mt,k as Zn,d6 as qt,t as Je,kb as es,aw as Xe,aa as ts,ab as ns,ac as ss,k1 as Wt,kc as rs,ax as Ut,gy as is,au as Ue,av as os,c4 as Jt,aq as as,as as ls,at as cs,ap as us}from"./useAppFontEffects-hfv2s6mZ.js";import{f as ds,d as fs}from"./runtimeEndpointReset-BULHvOwb.js";import{P as ms}from"./PierreDiffViewer-53Ghfnlr.js";import{u as ps,v as hs,g as gs,W as xs}from"./main-BOYSXfYn.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-DCXjBGRf.js";import"./web-components-U-hWbgJo.js";import"./computeVirtualFileMetrics-DHgQIkUq.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"./isDiffPlainText-D9faP70y.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-B-fwE8r3.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-BmtfVbo8.js";import"./appThemeRegistry-DDROzcUO.js";import"./textMateThemeFromAppTheme-Da7ed8qM.js";import"./useRootScrollLock-Cwc4kSl2.js";import"./scheduledTasksApi-DW3xqMQ8.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const ys=i.memo(function(e){const s=Ye.c(13),{index:u,staged:g,busyHunk:m,disabled:x,onAction:j}=e,{t:C}=ze();let c;s[0]!==g?(c=g?["unstage"]:["discard","stage"],s[0]=g,s[1]=c):c=s[1];const w=c;let R;s[2]===Symbol.for("react.memo_cache_sentinel")?(R={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=R):R=s[2];let d;s[3]!==w||s[4]!==m||s[5]!==x||s[6]!==u||s[7]!==j||s[8]!==C?(d=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:w.map(y=>{const K=C(y==="stage"?"diffView.hunk.stageTitle":y==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),I=m?.index===u&&m.action===y;return t.jsx(fe,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",y==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",y==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:x||m!==null,title:K,"aria-label":K,onPointerDown:ws,onClick:f=>{f.stopPropagation(),j(u,y)},children:t.jsx(L,{name:I?"loader-4":y==="stage"?"add":"arrow-go-back",className:je(y==="stage"?"size-4":"size-3.5",I&&"animate-spin")})},y)})}),s[3]=w,s[4]=m,s[5]=x,s[6]=u,s[7]=j,s[8]=C,s[9]=d):d=s[9];let T;return s[10]!==u||s[11]!==d?(T=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:R,"data-hunk-actions":u,children:d}),s[10]=u,s[11]=d,s[12]=T):T=s[12],T});function ws(o){return o.stopPropagation()}const Bt=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const g=s??u;return g?{path:g.path,topOffset:g.top-o}:null},bs=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),Pt=o=>{if(!o)return null;const e=o.split(`
|
|
2
|
-
`);let s=null;for(const u of e){const g=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(g){const m=Number.parseInt(g[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},js=1100,vs=15e3,It=500,zt=300,Xt=1e6,yt=3,Ss=o=>o<=6?o:o<=12?6:o<=25?4:2,Ot={status:"loading"},Ns=3,ks=i.memo(()=>{const o=Ye.c(4),{t:e}=ze();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),Yt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Cs=Yt.M,Rs=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=o=>{const e=Rs(o);return Yt[e]??Cs},Fs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},_t=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Kt=o=>!!o.working_dir?.trim()||o.index==="?",Ds=(o,e)=>is(o,e),Gt=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Ht=(o,e)=>{const s=o.split(`
|
|
3
|
-
`),u=e.split(`
|
|
4
|
-
`),g=Math.min(s.length,u.length);for(let m=0;m<g;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},As=o=>Array.isArray(o)?o.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Vs=o=>o==="added"?"A":o==="deleted"?"D":"M",wt=(o,e,s)=>In(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:zn(o,e),contextMode:s},Zt=(o,e,s)=>{const u=o??0,g=e??0;return!u&&!g?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,g?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",g]}):null]})},Es=i.memo(o=>{const e=Ye.c(68),{scope:s,workingCount:u,stagedCount:g,turnCount:m,branchCount:x,commitCount:j,prCount:C,showCommitOption:c,showBranchOption:w,onScopeChange:R}=o,{t:d}=ze(),[T,y]=i.useState(!1),K=s==="pr"?C??0:s==="staged"?g:s==="turn"?m:s==="branch"?x??0:s==="commit"?j??0:u;let I;e[0]!==s||e[1]!==d?(I=d(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=d,e[2]=I):I=e[2];const f=I;let me;e[3]!==d?(me=d("diffView.scope.selectorAria"),e[3]=d,e[4]=me):me=e[4];let pe;e[5]!==K?(pe=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",K]}),e[5]=K,e[6]=pe):pe=e[6];let te;e[7]!==f||e[8]!==pe?(te=t.jsxs("span",{className:"whitespace-nowrap",children:[f,pe]}),e[7]=f,e[8]=pe,e[9]=te):te=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(L,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=k):k=e[10];let V;e[11]!==me||e[12]!==te?(V=t.jsx(as,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":me,children:[te,k]})}),e[11]=me,e[12]=te,e[13]=V):V=e[13];let v;e[14]!==R?(v=Q=>{(Q==="working"||Q==="staged"||Q==="turn"||Q==="branch"||Q==="commit"||Q==="pr")&&(R?.(Q),y(!1))},e[14]=R,e[15]=v):v=e[15];let se;e[16]!==d?(se=d("diffView.scope.changed"),e[16]=d,e[17]=se):se=e[17];let J;e[18]!==se?(J=t.jsx("span",{children:se}),e[18]=se,e[19]=J):J=e[19];let le;e[20]!==u?(le=t.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=le):le=e[21];let re;e[22]!==le||e[23]!==J?(re=t.jsx(Ue,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[J,le]})}),e[22]=le,e[23]=J,e[24]=re):re=e[24];let ce;e[25]!==d?(ce=d("diffView.scope.staged"),e[25]=d,e[26]=ce):ce=e[26];let X;e[27]!==ce?(X=t.jsx("span",{children:ce}),e[27]=ce,e[28]=X):X=e[28];let $;e[29]!==g?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:g}),e[29]=g,e[30]=$):$=e[30];let ue;e[31]!==X||e[32]!==$?(ue=t.jsx(Ue,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[X,$]})}),e[31]=X,e[32]=$,e[33]=ue):ue=e[33];let M;e[34]!==d?(M=d("diffView.scope.lastTurn"),e[34]=d,e[35]=M):M=e[35];let D;e[36]!==M?(D=t.jsx("span",{children:M}),e[36]=M,e[37]=D):D=e[37];let q;e[38]!==m?(q=t.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=q):q=e[39];let G;e[40]!==D||e[41]!==q?(G=t.jsx(Ue,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[D,q]})}),e[40]=D,e[41]=q,e[42]=G):G=e[42];let de;e[43]!==x||e[44]!==w||e[45]!==d?(de=w?t.jsx(Ue,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x??"…"})]})}):null,e[43]=x,e[44]=w,e[45]=d,e[46]=de):de=e[46];let Y;e[47]!==j||e[48]!==c||e[49]!==d?(Y=c&&t.jsx(Ue,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[47]=j,e[48]=c,e[49]=d,e[50]=Y):Y=e[50];let E;e[51]!==C||e[52]!==c||e[53]!==d?(E=c&&t.jsx(Ue,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}),e[51]=C,e[52]=c,e[53]=d,e[54]=E):E=e[54];let W;e[55]!==s||e[56]!==re||e[57]!==ue||e[58]!==G||e[59]!==de||e[60]!==Y||e[61]!==E||e[62]!==v?(W=t.jsx(ls,{align:"start",className:"w-40",children:t.jsxs(cs,{value:s,onValueChange:v,children:[re,ue,G,de,Y,E]})}),e[55]=s,e[56]=re,e[57]=ue,e[58]=G,e[59]=de,e[60]=Y,e[61]=E,e[62]=v,e[63]=W):W=e[63];let ve;return e[64]!==T||e[65]!==W||e[66]!==V?(ve=t.jsxs(us,{open:T,onOpenChange:y,children:[V,W]}),e[64]=T,e[65]=W,e[66]=V,e[67]=ve):ve=e[67],ve}),Ls=i.memo(o=>{const e=Ye.c(11),{changedFiles:s,selectedFile:u,onSelectFile:g}=o,{t:m}=ze();if(s.length===0)return null;let x;if(e[0]!==s||e[1]!==g||e[2]!==u||e[3]!==m){let C;e[5]!==g||e[6]!==u||e[7]!==m?(C=c=>{const w=Qt(c),R=u===c.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>g(c.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",R?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Ut,{filePath:c.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:m(w.descriptionKey),"aria-label":m(w.descriptionKey),children:w.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c.path,children:c.path}),Zt(c.insertions,c.deletions)]})},c.path)},e[5]=g,e[6]=u,e[7]=m,e[8]=C):C=e[8],x=s.map(C),e[0]=s,e[1]=g,e[2]=u,e[3]=m,e[4]=x}else x=e[4];let j;return e[9]!==x?(j=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:x})}),e[9]=x,e[10]=j):j=e[10],j}),Ts=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,renderSideBySide:g}=o,{t:m}=ze(),x=u.original.length>0,j=u.modified.length>0,C=g?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",c=g?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let R;e[1]!==u.original||e[2]!==s||e[3]!==x||e[4]!==c||e[5]!==g||e[6]!==m?(R=x&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),t.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=x,e[4]=c,e[5]=g,e[6]=m,e[7]=R):R=e[7];let d;e[8]!==u.modified||e[9]!==s||e[10]!==j||e[11]!==x||e[12]!==c||e[13]!==g||e[14]!==m?(d=j&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(x?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=j,e[11]=x,e[12]=c,e[13]=g,e[14]=m,e[15]=d):d=e[15];let T;return e[16]!==C||e[17]!==R||e[18]!==d?(T=t.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:t.jsxs("div",{className:C,children:[R,d]})}),e[16]=C,e[17]=R,e[18]=d,e[19]=T):T=e[19],T}),Ms=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,staged:g,renderSideBySide:m,wrapLines:x,hunkActions:j}=o;let C;e[0]!==s?(C=os(s)||"text",e[0]=s,e[1]=C):C=e[1];const c=C;if(u.submodule){let d;return e[2]!==u.submodule||e[3]!==g?(d=t.jsx(qn,{state:u.submodule,staged:g}),e[2]=u.submodule,e[3]=g,e[4]=d):d=e[4],d}if(u.isBinary){let d;return e[5]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(ks,{}),e[5]=d):d=e[5],d}if(Xe(s)){let d;return e[6]!==u||e[7]!==s||e[8]!==m?(d=t.jsx(Ts,{filePath:s,diff:u,renderSideBySide:m}),e[6]=u,e[7]=s,e[8]=m,e[9]=d):d=e[9],d}let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[10]=w):w=e[10];let R;return e[11]!==u.fileDiff||e[12]!==u.modified||e[13]!==u.original||e[14]!==s||e[15]!==j||e[16]!==c||e[17]!==m||e[18]!==x?(R=t.jsx("div",{className:"w-full",style:w,children:t.jsx(ms,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:c,fileName:s,renderSideBySide:m,wrapLines:x,layout:"inline",hunkActions:j})}),e[11]=u.fileDiff,e[12]=u.modified,e[13]=u.original,e[14]=s,e[15]=j,e[16]=c,e[17]=m,e[18]=x,e[19]=R):R=e[19],R}),Bs=i.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:g,isSelected:m,isExpanded:x,isMounted:j,onSelect:C,onExpandedChange:c,registerSectionRef:w,showOpenInEditorAction:R=!1,isOpeningInEditor:d=!1,onOpenInEditor:T,staged:y=!1,loadFullFiles:K=!1,initialDiffData:I=null,comparisonDiff:f,onRetryComparisonDiff:me,readOnlyActions:pe=!1,hunkActionsEnabled:te=!1})=>{const{t:k}=ze(),{git:V}=$t(),v=ne(i.useCallback(h=>h.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),se=ne(h=>h.setDiff),J=ne(h=>h.fetchStatus),le=ae(h=>h.setDiffFileLayout),[re,ce]=i.useState(0),[X,$]=i.useState(null),[ue,M]=i.useState(!1),D=i.useMemo(()=>f?f.status==="error"?{kind:"error",message:f.message}:null:X,[f,X]),q=f?f.status==="loading":ue,[G,de]=i.useState(null),Y=i.useRef(!1),[E,W]=i.useState(null),[ve,Q]=i.useState(!1),[ie,Qe]=i.useState(null),[lt,Fe]=i.useState(null),he=i.useRef(null),mt=i.useRef(null),Oe=i.useMemo(()=>Qt(s),[s]),_e=u==="side-by-side",De=K?"full":"patch",ge=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,a=te&&!pe&&!I&&!f&&!Xe(s.path),xe=JSON.stringify([Re(),e,s.path,y,ge,re]),z=E?.scope===xe?E.patch:null,Ze=E?.scope===xe?E.submodule:null,U=i.useMemo(()=>f?f.status==="ready"?f.data:null:I||(y?lt:ie||(v?{original:v.original,modified:v.modified,isBinary:v.isBinary,submodule:v.submodule,contextMode:"full"}:null)),[f,v,I,ie,y,lt]),et=U?.contextMode===De,tt=i.useCallback(h=>{mt.current=h,w(s.path,h)},[s.path,w]),nt=i.useCallback(h=>{c(s.path,h)},[s.path,c]),st=i.useCallback(()=>{C(s.path)},[s.path,C]),rt=i.useRef({fileStatusKey:ge,staged:y});i.useEffect(()=>{if(!o)return;const h=rt.current;h.fileStatusKey===ge&&h.staged===y||(rt.current={fileStatusKey:ge,staged:y},y?Fe(null):Qe(null),$(null),he.current=null)},[ge,y,o]),i.useEffect(()=>{if(!o||!x||!j||X)return;if(!e||f||I||U&&et&&(!a||z!==null)){he.current=null,M(!1);return}const h=`${e}::${s.path}::${y?"staged":"unstaged"}::${ge}::${De}::${re}`;if(he.current===h)return;he.current=h,$(null),M(!0);let O=!1;const ye=Re(),Ge=K?Xt:yt,Z=Xe(s.path)?V.getGitFileDiff(e,{path:s.path,staged:y}):!K&&z!==null?Promise.resolve({diff:z,submodule:Ze}):V.getGitDiff(e,{path:s.path,staged:y,contextLines:Ge}),Ve=a&&K&&z===null?V.getGitDiff(e,{path:s.path,staged:y,contextLines:yt}).then(S=>S.diff):Promise.resolve(z),Pe=Promise.all([Z,Ve]),we=vs;let _;const Ee=new Promise((S,He)=>{_=setTimeout(()=>He(new Error(`Timed out after ${we}ms`)),we)});return Promise.race([Pe,Ee]).then(([S,He])=>{if(O||ye!==Re())return;const be="diff"in S&&!K?S.diff:He;if(a&&K&&be!==null&&/^@@\s/m.test(be)&&"diff"in S&&S.diff!==be&&!Mn(S.diff,be))throw W(null),new Error(k("diffView.hunk.unavailable"));if(a&&be!==null&&W({scope:xe,patch:be,submodule:S.submodule}),"diff"in S){const Ne={...wt(s.path,S.diff,De),submodule:S.submodule};y?Fe(Ne):Qe(Ne)}else{const Ne={original:S.original??"",modified:S.modified??"",isBinary:S.isBinary,submodule:S.submodule,contextMode:"full"};y?Fe(Ne):se(e,s.path,Ne,ye)}M(!1)}).catch(S=>{if(!(O||ye!==Re())){if(M(!1),S instanceof Fn){$({kind:"unavailable",reason:S.reason}),S.reason==="path_not_found"&&J(e,V,{force:!0,silent:!0});return}$({kind:"error",message:S instanceof Error?S.message:String(S)})}}).finally(()=>clearTimeout(_)),()=>{O=!0,clearTimeout(_),he.current===h&&(he.current=null)}},[z,Ze,a,xe,f,De,U,et,re,e,J,s.path,ge,V,I,x,j,K,X,se,y,k,o]);const ct=i.useCallback(()=>{nt(!x),st()},[nt,st,x]),Ae=i.useCallback(()=>{$(null),W(null),Qe(null),Fe(null),he.current=null,ce(h=>h+1)},[]),Se=i.useCallback(async(h,O)=>{if(!e||!a||q||D||Y.current||G!==null)return;const ye=z?Bn(z,h):null;if(!ye){Je.error(k("diffView.hunk.unavailable"));return}if(y&&O!=="unstage"||!y&&O==="unstage")return;Y.current=!0;const Ge=Re();de({index:h,action:O});try{const Z=O==="stage"?V.stageGitHunk:O==="unstage"?V.unstageGitHunk:V.revertGitHunk;if(!Z){Je.error(k("diffView.hunk.unsupported"));return}if(await Z(e,s.path,ye),Ge!==Re())return;Ae(),qt.requestGitRefresh({directory:e,paths:[s.path]}),await J(e,V)}catch(Z){if(Ge!==Re())return;Ae(),Je.error(Z instanceof Error&&Z.message?Z.message:k("diffView.hunk.unavailable"))}finally{Y.current=!1,de(Z=>Z?.index===h&&Z.action===O?null:Z)}},[z,a,q,D,e,J,s.path,V,G,Ae,y,k]),Be=i.useMemo(()=>a&&z!==null?Pn(z):[],[z,a]),Ke=i.useCallback(h=>t.jsx(ys,{index:h,staged:y,busyHunk:G,disabled:q||!!D,onAction:Se}),[D,Se,G,q,y]),it=i.useMemo(()=>Be.length>0?{anchors:Be,render:Ke}:void 0,[Be,Ke]);return t.jsxs("div",{ref:tt,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:ct,onKeyDown:h=>{h.target===h.currentTarget&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),ct())},className:je("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:x?t.jsx(L,{name:"arrow-down-s",className:"size-4"}):t.jsx(L,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:k(Oe.descriptionKey),"aria-label":k(Oe.descriptionKey),children:Oe.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ut,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const h=s.path.lastIndexOf("/");if(h===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const O=s.path.slice(0,h),ye=s.path.slice(h+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:O}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ye})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Zt(s.insertions,s.deletions),R&&T?t.jsx(fe,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:k("diffView.actions.openFileInEditorAtChange"),onClick:h=>{h.stopPropagation(),T(s.path,U)},disabled:d,children:d?t.jsx(L,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(L,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:_e?"side-by-side":"unified",onModeChange:h=>{const O=h==="side-by-side"?"side-by-side":"inline";le(s.path,O)},className:"opacity-70"})]})]})}),x&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!j&&!D?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,D?.kind==="unavailable"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:D.reason==="nested_repository"?k("diffView.unavailable.nestedRepositoryTitle"):k("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.reason==="nested_repository"?k("diffView.unavailable.nestedRepositoryDescription"):k("diffView.unavailable.missingDescription")}),D.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:Ae,children:k("diffView.actions.retry")}):null]}):null,D?.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>f?me?.():Ae(),children:k("diffView.actions.retry")})]}):null,j&&q&&!U&&!D?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),k("diffView.state.loadingDiff")]}):null,j&&U&&!ve&&s.insertions+s.deletions>It?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:k("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Q(!0),children:k("diffView.actions.renderAnyway")})]}):null,j&&U&&(ve||s.insertions+s.deletions<=It)?t.jsx(t.Fragment,{children:t.jsx(Ms,{filePath:s.path,diff:U,staged:y,renderSideBySide:_e,wrapLines:g,hunkActions:it})}):null]})]})}),eo=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:g=!1,diffScope:m="all",onDiffScopeChange:x,targetFilePath:j=null,flushContent:C=!1})=>{const{t:c}=ze(),{git:w,files:R}=$t(),d=Wn(),T=ne(n=>n.runtimeKey),{rootIsGitRepo:y,gitDirectory:K,nestedRepos:I}=Un(d??null,{enabled:o}),f=K??d,me=ae(n=>n.openContextSurface),pe=ps(n=>n.requestSource),{screenWidth:te,isMobile:k}=Jn(),V=Xn(f??null),v=Yn(f??null),se=Qn(f??null),J=ne(n=>n.setActiveDirectory),le=ne(n=>n.ensureStatus),re=ne(n=>n.selectNestedRepo),ce=ne(n=>n.fetchStatus),X=ne(n=>n.fetchBranches),$=ne(n=>n.clearDiffCache),ue=ne(n=>n.setDiff),[M,D]=i.useState(null),[q,G]=i.useState(!1),[de,Y]=i.useState(null),[E,W]=i.useState(()=>new Set),[ve,Q]=i.useState(()=>new Set),[ie,Qe]=i.useState(!1),[lt,Fe]=i.useState(0),[he,mt]=i.useState(()=>new Map),[Oe,_e]=i.useState(!1),[De,ge]=i.useState(!1),[a,xe]=i.useState(m);i.useEffect(()=>{xe(m)},[m]);const z=ae(n=>n.pendingDiffFile),Ze=ae(n=>n.pendingDiffStaged),U=ae(n=>n.pendingDiffScope),et=ae(n=>n.setPendingDiffFile),tt=ae(n=>n.diffLayoutPreference),nt=ae(n=>n.diffFileLayout),st=ae(n=>n.setDiffFileLayout),rt=ae(n=>n.diffWrapLines),ct=ae(n=>n.setDiffWrapLines),Ae=ae(n=>n.openContextFileAtLine),Se=Mt(n=>n.currentSessionId),Be=Zn(a==="turn"?Se??"":"",d??void 0),Ke=rt,it=a==="staged"?!0:a==="working"?!1:null,h=it??q,O=k||te<=768,ye=!!Se&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!O&&!Ce(),Ge=a!=="turn"&&!O&&!Ce(),Z=!e&&!O&&te>=1024,Ve=i.useRef(null),Pe=i.useRef(new Map),we=i.useRef(null),_=i.useRef(null),Ee=i.useRef(!1),S=i.useRef(null),He=i.useRef(null),be=i.useRef(null),Ne=i.useRef(null),bt=i.useCallback(()=>{const n=Ve.current;if(!n)return null;const r=n.getBoundingClientRect().top,l=[];for(const[p,b]of Pe.current)b&&l.push({path:p,top:b.getBoundingClientRect().top});return Bt(r,l)},[]),$e=i.useCallback(()=>{we.current=null,Ee.current=!1,Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)},[]),qe=i.useCallback(n=>{W(r=>{if(r.has(n))return r;const l=new Set(r);return l.add(n),l})},[]),ot=i.useMemo(()=>{for(let n=Be.length-1;n>=0;n-=1){const r=Be[n];if(r.role==="user")return As(r.summary?.diffs)}return[]},[Be]),en=i.useMemo(()=>{const n=new Map;for(const r of ot)if(r.file){if(typeof r.patch=="string"){n.set(r.file,wt(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[ot]),tn=i.useMemo(()=>v?.files?v.files.filter(Kt).length:0,[v]),nn=i.useMemo(()=>v?.files?v.files.filter(_t).length:0,[v]),sn=ot.length,H=v?.current??null,Le=Dn(f??null,H,o&&a==="pr"&&!Ce()),Te=Le.selectedSource,Me=An(f??null,H,o&&a==="commit"&&!Ce()),Ie=Me.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Ce()&&(xe("working"),x?.("working"))},[a,x]);const We=ne(n=>f?n.directories.get(f)?.branches??null:null),rn=ne(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),on=i.useCallback(()=>{f&&X(f,w)},[f,X,w]),an=On(f??null,o&&V!==!1,rn,!!We,on,Ns),jt=i.useMemo(()=>{const n=v?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,v?.tracking]),vt=!Ce()&&_n(H,jt),ln=v!==null,St=Ce()||an||Kn(H,jt,ln,We!==null),cn=Vn(n=>n.setOverride),{base:ke,resolved:un,revision:Nt}=En(f??null,H,o&&vt&&a==="branch"),[dn,fn]=i.useState(0);i.useEffect(()=>{const n=$n(a,!St);n!==a&&(xe(n),n==="working"&&x?.("working"))},[a,St,x]);const mn=i.useMemo(()=>a==="pr"?Te:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&ke&&H?{kind:"branch",baseRef:ke,headRef:H}:null,[a,ke,H,Ie,Te]),A=Gn(f??null,mn,o&&!Ce(),a==="branch"?Nt:""),{fetchDiff:kt}=A,Ct=a==="commit"?A.files:null,Rt=a==="commit"?A.error:null,ut=a==="branch"?A.files:null,Ft=a==="branch"?A.error:null,Dt=A.files?a==="pr"?JSON.stringify([A.key,A.revision]):A.key:null,pn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(E).sort().join("\0"):"",[a,E]),hn=i.useCallback(async n=>{try{const r=ie&&a!=="pr",l=await kt(n,r?Xt:yt);return{status:"ready",data:wt(n,l.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:c("diffView.state.failedToLoadDiff")}}},[a,kt,ie,c]),gn=Hn(Dt,o?pn:"",Dt?hn:null,Ot,JSON.stringify([a==="branch"?Nt:"",a==="pr"?A.revision:0,dn,ie])),xn=ut?.length??null,N=i.useMemo(()=>{if(a==="commit"||a==="pr")return(A.files??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:l.insertions,deletions:l.deletions,isNew:l.status==="A"}));if(a==="branch")return(ut??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,p)=>l.path.localeCompare(p.path));if(a==="turn")return ot.map(l=>({path:l.file??"",index:"",working_dir:Vs(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,p)=>l.path.localeCompare(p.path));if(!v?.files)return[];const n=v.diffStats??{},r=a==="staged"?_t:a==="working"?Kt:()=>!0;return v.files.filter(r).map(l=>({...l,insertions:n[l.path]?.insertions??0,deletions:n[l.path]?.deletions??0,isNew:Fs(l)})).sort((l,p)=>l.path.localeCompare(p.path))},[a,ut,A.files,ot,v]),pt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=pt?pt.split("\0"):[],r=new Set(n),l=`${f??""}:${a}:${s?"collapsed":"default"}`,p=He.current!==l;He.current=l,W(b=>{if(p){const P=s?0:Ss(n.length);return new Set(n.slice(0,P))}let B=!1;const F=new Set;for(const P of b){if(!r.has(P)){B=!0;continue}F.add(P)}return B?F:b}),Q(b=>{if(p)return new Set;let B=!1;const F=new Set;for(const P of b){if(!r.has(P)){B=!0;continue}F.add(P)}return B?F:b})},[a,pt,f,s]);const At=i.useCallback(()=>{if(S.current=null,!o)return;const n=Ve.current;if(!n)return;const r=n.getBoundingClientRect(),l=r.top-zt,p=r.bottom+zt,b={},B=[];for(const[F,P]of Pe.current){if(!P)continue;const ee=P.getBoundingClientRect();B.push({path:F,top:ee.top}),E.has(F)&&(ee.bottom<l||ee.top>p||(b[F]=!0))}be.current=Bt(r.top,B),Q(F=>{let P=!1;const ee=new Set(F);for(const at of Object.keys(b))ee.has(at)||(ee.add(at),P=!0);return P?ee:F})},[E,o]),oe=i.useCallback(()=>{o&&(typeof window>"u"||S.current===null&&(S.current=window.requestAnimationFrame(At)))},[At,o]);i.useEffect(()=>{const n=Ve.current;if(!(!o||!n))return oe(),n.addEventListener("scroll",oe,{passive:!0}),window.addEventListener("resize",oe),()=>{n.removeEventListener("scroll",oe),window.removeEventListener("resize",oe),S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null)}},[N,E,oe,o]);const ht=i.useCallback(n=>{const r=nt[n.path];if(r)return r;if(tt==="inline")return"inline";if(tt==="side-by-side")return"side-by-side";const l=te<js;return n.isNew||l?"inline":"side-by-side"},[nt,tt,te]),Vt=i.useMemo(()=>N.length===0?null:N.every(n=>ht(n)==="side-by-side")?"side-by-side":"inline",[N,ht]);i.useEffect(()=>{o&&f&&(J(f),le(f,w))},[f,J,le,w,o]);const dt=JSON.stringify([T,f]),gt=i.useRef({scope:dt,paths:new Set,dirty:!1}),Et=i.useRef(o);i.useEffect(()=>{const n=o&&!Et.current;if(Et.current=o,gt.current.scope!==dt&&(gt.current={scope:dt,paths:new Set,dirty:!1}),!f)return;const r=p=>{p?.length&&(Ne.current=bt()??be.current,$(f,p),mt(b=>{const B=new Map(b);for(const F of p)B.set(F,(B.get(F)??0)+1);return B})),ce(f,w,{silent:!0})},l=gt.current;return o&&(n||l.dirty)&&(r([...l.paths]),l.paths.clear(),l.dirty=!1),qt.onGitRefreshHint(p=>{if(Gt(p.directory)===Gt(f)){if(!o){l.dirty=!0;for(const b of p.paths??[])l.paths.add(b);return}r(p.paths)}})},[bt,$,f,ce,w,dt,o]),i.useLayoutEffect(()=>{const n=Ne.current;if(!n)return;Ne.current=null;const r=Ve.current,l=Pe.current.get(n.path);if(!r||!l)return;const p=r.getBoundingClientRect().top,b=l.getBoundingClientRect().top-p;r.scrollTop=bs(r.scrollTop,n.topOffset,b,r.scrollHeight-r.clientHeight),be.current=n},[he]),i.useEffect(()=>{!o||a!=="all"&&!U||z&&(U&&xe(U),D(z),G(U==="staged"||!U&&Ze),et(null),Ee.current=!0,we.current=z,qe(z),Fe(n=>n+1))},[a,qe,z,U,Ze,et,o]),i.useEffect(()=>{if(a==="all")return;const n=j?.trim();n&&(D(n),G(a==="staged"),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1))},[a,qe,j]),i.useEffect(()=>{if(!M)return;N.some(r=>r.path===M)||(D(null),G(!1))},[N,M]);const yn=i.useCallback((n,r)=>{const l=Pe.current;r?l.set(n,r):l.delete(n),oe()},[oe]),wn=i.useCallback((n,r)=>{$e(),W(l=>{const p=l.has(n);if(r===p)return l;const b=new Set(l);return r?b.add(n):b.delete(n),b}),r||Q(l=>{if(!l.has(n))return l;const p=new Set(l);return p.delete(n),p}),oe()},[$e,oe]),bn=i.useCallback(()=>{$e(),W(n=>n.size>0?new Set:new Set(N.map(r=>r.path))),Q(new Set),oe()},[$e,N,oe]),jn=i.useCallback(async n=>{if(!Se)return;const r=Mt.getState().getDirectoryForSession(Se)||d||"";if(!r){Je.error(c("diffView.reviewDialog.toast.noSessionDirectory"));return}ge(!0);try{await es({originalSessionID:Se,directory:r,providerID:n.providerID,modelID:n.modelID,agent:n.agent||void 0,variant:n.variant||void 0,generateHandoff:n.generateHandoff,returnAfterHandoffRequest:n.generateHandoff,autoReview:n.autoReview}),_e(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Je.error(l instanceof Error?l.message:c("diffView.reviewDialog.toast.startFailed"))}finally{ge(!1)}},[Se,d,c]),ft=i.useCallback(n=>{const r=Pe.current.get(n),l=Ve.current;if(!r||!l)return!1;const p=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+p,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=we.current;if(!o||!n)return;let r=0;const l=20;let p=!1;const b=(F=!0)=>{p||(p=!0,we.current=null,Ee.current=!1,F&&Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null))},B=()=>{if(p){_.current=null;return}const F=we.current;if(!F){b(),_.current=null;return}if(!ft(F)){r+=1,r<l?_.current=window.requestAnimationFrame(B):(b(),_.current=null);return}if(u&&Ee.current){Y(F),b(!1);return}b()};return _.current=window.requestAnimationFrame(B),()=>{p=!0,_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)}},[u,lt,ft,o]);const vn=i.useCallback(n=>{},[]),xt=i.useCallback(n=>{$e(),D(n),G(!1),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1),ft(n)},[$e,qe,ft]);i.useEffect(()=>{const n=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const p=r.key==="ArrowDown"?1:-1,b=M?N.findIndex(P=>P.path===M):-1,B=b===-1?p>0?0:N.length-1:b+p,F=N[B];F&&(r.preventDefault(),xt(F.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,M,xt,o]);const Sn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{st(l.path,r)})},[N,st]),[Nn,Lt]=i.useState(null),kn=i.useCallback(async(n,r)=>{if(!f||!n)return;Lt(n);const l=Re();try{let p=null;if(r?.patch&&!r.isBinary&&!Xe(n)?p=Pt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(p=Ht(r.original,r.modified)),p===null)try{const ee=await w.getGitDiff(f,{path:n,staged:h,contextLines:3});p=Pt(ee.diff)}catch{p=null}let b=r;if(p===null||!b){const ee=await w.getGitFileDiff(f,{path:n,staged:h}),at={original:ee.original??"",modified:ee.modified??"",isBinary:ee.isBinary,submodule:ee.submodule};b=at,h||ue(f,n,at,l)}const B=p??(b.isBinary||Xe(n)?1:Ht(b.original,b.modified)),F=Ds(f,n),P=await hs(R,F,{directory:f});if(!P.ok){Je.error(gs(P.reason));return}Ae(f,F,B,1)}finally{Lt(p=>p===n?null:p)}},[h,f,R,w,Ae,ue]),Cn=()=>{if(!f)return null;const n=r=>it!==null?it:q&&r===M;return t.jsxs("div",{className:je("flex min-w-0 flex-1 min-h-0 h-full",C?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Z&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:c("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Ls,{changedFiles:N,selectedFile:null,onSelectFile:xt})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(Jt,{ref:Ve,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>t.jsx(Bs,{visible:o,directory:f,file:r,layout:ht(r),wrapLines:Ke,isSelected:!1,isExpanded:E.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:g&&a!=="turn",isOpeningInEditor:Nn===r.path,onOpenInEditor:(l,p)=>{kn(l,p)},staged:n(r.path),loadFullFiles:ie&&a!=="pr",readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",comparisonDiff:a==="branch"||a==="commit"||a==="pr"?gn.get(r.path)??Ot:void 0,onRetryComparisonDiff:()=>fn(l=>l+1),initialDiffData:a==="turn"?en.get(r.path)??null:null},`${Re()}:${f}:${r.path}:${he.get(r.path)??0}`))})})})]})},Rn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.selectSessionDirectory")});if(a!=="turn"&&se&&!v)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&V===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.notGitRepository")});if(a==="pr"){if(!Te||A.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:A.error??Le.error??(Le.loading?c("session.githubPrPicker.loading.pullRequests"):c("pullRequestComparison.select"))}),(A.error||Le.error)&&t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{Te?A.refresh():Le.refresh()},children:c("diffView.actions.retry")}),!Te&&!Le.loading&&t.jsx(Tt,{comparison:Le})]});if(!A.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="commit"){if(Rt)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Rt}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{A.refresh()},children:c("diffView.actions.retry")})]});if(!Ie&&!Me.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Me.error??c("commitComparison.noCommits")});if(!Ct)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="branch"){if(!un)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.resolvingBase")]});if(!ke)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(L,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:c("gitView.pr.toast.baseBranchRequired")})]});if(Ft)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ft}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{A.refresh()},children:c("diffView.actions.retry")})]});if(ut===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?c("diffView.state.noLastTurnChanges"):a==="pr"?c("walkthrough.blocked.emptyDiff.description"):a==="commit"?c("commitComparison.emptyDiff"):a==="branch"&&ke?c("diffView.branch.empty",{base:fs(ke)}):c("diffView.state.cleanWorkingTree")}):Cn()};return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[y===!1&&Array.isArray(I)&&I.length>0?t.jsx(ds,{repositories:I,selectedRepository:K??null,onSelectRepository:n=>{d&&re(d,n)},repositoryRoot:d??void 0}):null,!k&&(a!=="all"?t.jsx(Es,{scope:a,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:a==="commit"?Ct?.length??null:null,prCount:a==="pr"?A.files?.length??null:null,showCommitOption:!Ce(),showBranchOption:vt,onScopeChange:n=>{xe(n),x?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:se&&!v?c("diffView.state.loadingChanges"):N.length===1?c("diffView.summary.changedFilesSingle",{count:N.length}):c("diffView.summary.changedFilesPlural",{count:N.length})})})),a==="branch"&&t.jsx(Ln,{branches:We?.all??[],currentBranch:H,base:ke,onSelect:n=>{f&&H&&cn(f,H,n)}},JSON.stringify([f,H])),a==="commit"&&t.jsx(Tn,{commits:Me.commits,selectedHash:Ie,loading:Me.loading,error:Me.error,onSelect:Me.select,onRefresh:()=>{Me.refresh()}},JSON.stringify([f,H])),a==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Le},JSON.stringify([T,f,H])),Te&&t.jsx(fe,{variant:"ghost",size:"sm",disabled:A.loading,"aria-label":c("session.githubIssuePicker.actions.refresh"),title:c("session.githubIssuePicker.actions.refresh"),onClick:()=>{A.refresh()},children:t.jsx(L,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(fe,{variant:"ghost",size:"sm",onClick:bn,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll"),children:[t.jsx(L,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll")})]}),N.length>0&&ye&&t.jsxs(fe,{variant:"default",size:"sm",onClick:()=>_e(!0),disabled:De,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":c("diffView.actions.reviewAria"),children:[De?t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(L,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:c("diffView.actions.review")})]}),N.length>0&&Ge&&t.jsxs(fe,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";pe(n,a==="pr"&&Te?Te:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&ke&&H?{kind:"branch",baseRef:ke,headRef:H}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),me(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",xs),"aria-label":c("walkthrough.action.open"),children:[t.jsx(L,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}),N.length>0&&a!=="pr"&&t.jsxs(ts,{children:[t.jsx(ns,{asChild:!0,children:t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>Qe(n=>!n),"aria-pressed":ie,"aria-label":c(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:je("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",ie&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(L,{name:"file-download",className:"size-4"})})}),t.jsx(ss,{children:t.jsx("p",{children:c(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>ct(!rt),className:je("h-5 w-5 p-0 transition-opacity",Ke?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:c(Ke?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(L,{name:"text-wrap",className:"size-4"})}),Vt&&t.jsx(Wt,{mode:Vt==="side-by-side"?"side-by-side":"unified",onModeChange:Sn})]}),t.jsx(rs,{open:Oe,onOpenChange:_e,projectDirectory:f??null,submitting:De,onConfirm:jn}),Rn()]})};export{eo as DiffView,Bs as MultiFileDiffEntry};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ax as Ee,aa as be,ab as ye,I as E,ac as we,h as J,B as Y,a5 as Te,jk as Ie,b_ as fe,b$ as ue,c0 as pe,c1 as ge,c2 as xe,c3 as ve,bf as Me,cm as Re,t as ae}from"./useAppFontEffects-hfv2s6mZ.js";import{u as ke}from"./index-Dy8xgawx.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Fe=Se.M;function Pe(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=Pe(p);return Se[e]??Fe}const He=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=$e(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=Q(),$=u.description,F=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let H;t[7]!==a?(H=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=H):H=t[8];const W=H;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const P=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let R;t[13]!==v?(R=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=R):R=t[14];const q=o?P:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==$||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:$,"aria-label":$,children:u.code}),t[17]=u.code,t[18]=$,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Z;t[30]===Symbol.for("react.memo_cache_sentinel")?(Z={color:"var(--status-success)"},t[30]=Z):Z=t[30];let i;t[31]!==F?(i=s.jsxs("span",{style:Z,children:["+",F]}),t[31]=F,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:P;let ee;return t[46]!==T||t[47]!==d||t[48]!==R||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:R,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=R,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Ze=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=Q(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),$=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),F=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from($[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[$,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(F);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),F.forEach(m=>n.add(m)),n})},[f,F]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe($[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,$,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),H=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice(H,H+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,H]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),P=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=P.length,R=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||P.length===0||(await g(P),c(!1))},[P,r,g]),K=N.useCallback(async()=>{!d||!u||R||(await d(u.paths),I(null))},[R,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx(He,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Z=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(Z(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:J("relative",Z(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!R&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:R,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:R||!u,children:a(R?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=Q(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const H=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const P=y.scrollHeight,X=Math.min(Math.max(P,he),re);y.style.height=`${X}px`,y.style.overflowY=P>re?"auto":"hidden",P>re&&!H&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",$=S?"sentences":"off",F=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=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)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==$||e[15]!==F||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:$,spellCheck:F,className:z,style:T}),e[13]=h,e[14]=$,e[15]=F,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=Q();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Je=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=Q(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:$}=Me();let F;e[5]!==o?(F=o("gitView.commit.title"),e[5]=o,e[6]=F):F=e[6];let A;e[7]!==F?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:F}),e[7]=F,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let H;e[22]!==o?(H=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=H):H=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==$||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==H?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:H,disabled:W,hasTouchInput:$,isMobile:I}),e[24]=r,e[25]=$,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=H,e[31]=L):L=e[31];let P;e[32]!==V||e[33]!==k||e[34]!==o?(P=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=P):P=e[35];const X=a||f!==null||v||t===0;let R;e[36]!==o?(R=o("gitView.commit.generateAria"),e[36]=o,e[37]=R):R=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==R||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":R,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=R,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Z=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Z||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Z,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Z,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==P||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,P,D]}),e[72]=L,e[73]=P,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Qe=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=Q(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Re,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Ze as C,Qe as D,Je as a};
|