@openchamber/web 1.24.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.test.js +7 -6
- package/bin/lib/cli-http.js +5 -1
- package/dist/assets/{CodeMirrorCommentWidgets-C9kV-n7r.js → CodeMirrorCommentWidgets-DvUH815P.js} +1 -1
- package/dist/assets/DiffView-DkC3xlRJ.js +4 -0
- package/dist/assets/{FilesView-vjJx7VaM.js → FilesView-D0bM9FVB.js} +6 -6
- package/dist/assets/GitView-Bxuv3dfP.js +6 -0
- package/dist/assets/GuestAttachDialog-B0u3Q5uO.js +1 -0
- package/dist/assets/{JsonTreeView-D_4G5X6-.js → JsonTreeView-BBVPFM5K.js} +1 -1
- package/dist/assets/{LinearIssuesView-1uKhePfH.js → LinearIssuesView-UI1FcSC8.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-Ix7N_2wp.js → MarkdownImageGallery-CUJxH8Le.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Deel_y5S.js → MarkdownRendererImpl-D5BZOg8X.js} +1 -1
- package/dist/assets/{OnboardingScreen-ToIakxb_.js → OnboardingScreen-5Gou9cGD.js} +1 -1
- package/dist/assets/{PatchDiff-BjMgezr1.js → PatchDiff-C4rE5k6z.js} +1 -1
- package/dist/assets/{PierreDiffViewer-53Ghfnlr.js → PierreDiffViewer-ByRVu6ss.js} +1 -1
- package/dist/assets/{PlanView-BGAzxDwD.js → PlanView-u2yi5XGJ.js} +4 -4
- package/dist/assets/PluginPane-QxjsKYeO.js +3 -0
- package/dist/assets/SettingsView-Fo5ZqMaT.js +29 -0
- package/dist/assets/SettingsWindow-HVDVANjJ.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary--YFqK6Ih.js → SubmoduleDiffSummary-D3hzkybB.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DRWBvdaJ.js → ToolOutputDialog-3J6IRayW.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-BxZJCU28.js → ToolPartDiffPreview-DarxPjSd.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-DCXjBGRf.js → VirtualizedFileDiff-CZgXWHjU.js} +4 -4
- package/dist/assets/{WalkthroughView-CfIPvWWa.js → WalkthroughView-wSpED5L4.js} +2 -2
- package/dist/assets/{appThemeRegistry-DDROzcUO.js → appThemeRegistry-Cf8KitzT.js} +1 -1
- package/dist/assets/commitAndPush-DZnzlhvc.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-DHgQIkUq.js → computeVirtualFileMetrics-VYnT_A2h.js} +1 -1
- package/dist/assets/{de-CX_f-T5U.js → de-BM_8EDD3.js} +4 -4
- package/dist/assets/{es-BERmWNn_.js → es-CxZjlqpo.js} +3 -3
- package/dist/assets/{fr-BjYYE_-z.js → fr-VCixCnMW.js} +4 -4
- package/dist/assets/{index-WjufPkIV.js → index-3U4CtS9b.js} +1 -1
- package/dist/assets/index-B9Hvzjwl.css +1 -0
- package/dist/assets/index-DLHQogv8.js +40 -0
- package/dist/assets/{isDiffPlainText-D9faP70y.js → isDiffPlainText-ImDG3Uhg.js} +1 -1
- package/dist/assets/{isFilePlainText-6qOcz5Ky.js → isFilePlainText-D_YDVYDb.js} +1 -1
- package/dist/assets/{ja-DxqeAk9N.js → ja-CZ5k_GyD.js} +4 -4
- package/dist/assets/{ko-Dty1aUod.js → ko-7YM3A1Xh.js} +4 -4
- package/dist/assets/{main-Bjcre_GE.js → main-CycplCph.js} +2 -2
- package/dist/assets/main-DFYTCx5o.js +896 -0
- package/dist/assets/markdownCore-DHvqMxPn.js +5 -0
- package/dist/assets/{miniChat-Dz_bPgMc.js → miniChat-DIQKfY2V.js} +2 -2
- package/dist/assets/{mobile-BbZPBJrK.js → mobile-BMwz5q-m.js} +2 -2
- package/dist/assets/{patchFileDiff-BvU6KOQC.js → patchFileDiff-DDQ6Rq5e.js} +3 -3
- package/dist/assets/{pl-CX-_ROkr.js → pl-BcgDO_w5.js} +4 -4
- package/dist/assets/{pt-BR-DhRR1arx.js → pt-BR-CU2u_1q5.js} +3 -3
- package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +2 -0
- package/dist/assets/renderMobileApp-D0Y8DtkA.js +25 -0
- package/dist/assets/runtimeEndpointReset-DhC3REb2.js +25 -0
- package/dist/assets/{scheduledTasksApi-DW3xqMQ8.js → scheduledTasksApi-D8pq6gQz.js} +1 -1
- package/dist/assets/{shikiHighlight-DsxD9QEa.js → shikiHighlight-1imXsir9.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-Da7ed8qM.js → textMateThemeFromAppTheme-Dgqc63LZ.js} +1 -1
- package/dist/assets/tr-DuYhOzNe.js +7 -0
- package/dist/assets/{uk-CD21CXFV.js → uk-Cuk7-uvq.js} +3 -3
- package/dist/assets/{useAppFontEffects-hfv2s6mZ.js → useAppFontEffects-BItUWdo4.js} +147 -147
- package/dist/assets/{useInlineCommentController-BmtfVbo8.js → useInlineCommentController-CkbKsm7m.js} +2 -2
- package/dist/assets/useRootScrollLock-vmzxZjWA.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-BPMJpOpT.js → vendor-codemirror-language-data-BDyxuqK4.js} +2 -2
- 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/{web-components-U-hWbgJo.js → web-components-D7FinaeH.js} +1 -1
- package/dist/assets/{zh-CN-BWvlPHY-.js → zh-CN-CUWoiRHd.js} +3 -3
- package/dist/assets/{zh-TW-CRp5dJU2.js → zh-TW-CQ8EBSBN.js} +3 -3
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +4 -3
- package/server/index.js +26 -7
- 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/git/DOCUMENTATION.md +17 -4
- 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 +232 -62
- package/server/lib/git/service.test.js +273 -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 +6 -0
- package/server/lib/message-queue/runtime.js +5 -0
- package/server/lib/message-queue/runtime.test.js +32 -1
- package/server/lib/opencode/feature-routes-runtime.js +5 -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/routing/DOCUMENTATION.md +81 -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/security/request-security.js +9 -5
- package/server/lib/security/request-security.test.js +37 -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/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/main-BOYSXfYn.js +0 -896
- package/dist/assets/markdownCore-DPrwM1rU.js +0 -5
- 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/bin/cli.test.js
CHANGED
|
@@ -832,7 +832,7 @@ describe('CLI HTTP helpers', () => {
|
|
|
832
832
|
}
|
|
833
833
|
});
|
|
834
834
|
|
|
835
|
-
it('retries UI-authenticated API requests with the
|
|
835
|
+
it.each(['oc_ui_session', 'oc_ui_session_3000'])('retries UI-authenticated API requests with the %s cookie', async (cookieName) => {
|
|
836
836
|
await withTempOpenChamberDataDir(async () => {
|
|
837
837
|
const port = 45678;
|
|
838
838
|
fs.writeFileSync(await getInstanceFilePath(port), JSON.stringify({ port, uiPassword: 'secret' }, null, 2));
|
|
@@ -844,11 +844,11 @@ describe('CLI HTTP helpers', () => {
|
|
|
844
844
|
expect(JSON.parse(options.body)).toEqual({ password: 'secret' });
|
|
845
845
|
return {
|
|
846
846
|
ok: true,
|
|
847
|
-
headers: { get: (name) => name.toLowerCase() === 'set-cookie' ?
|
|
847
|
+
headers: { get: (name) => name.toLowerCase() === 'set-cookie' ? `${cookieName}=session-token; Path=/; HttpOnly` : null },
|
|
848
848
|
json: async () => ({ authenticated: true }),
|
|
849
849
|
};
|
|
850
850
|
}
|
|
851
|
-
if (options.headers?.Cookie ===
|
|
851
|
+
if (options.headers?.Cookie === `${cookieName}=session-token`) {
|
|
852
852
|
return createMockJsonResponse({ ok: true });
|
|
853
853
|
}
|
|
854
854
|
return {
|
|
@@ -866,6 +866,7 @@ describe('CLI HTTP helpers', () => {
|
|
|
866
866
|
|
|
867
867
|
expect(response.ok).toBe(true);
|
|
868
868
|
expect(body).toEqual({ ok: true });
|
|
869
|
+
expect(calls.at(-1).options.headers.Cookie).toBe(`${cookieName}=session-token`);
|
|
869
870
|
expect(calls.map((call) => new URL(call.url).pathname)).toEqual([
|
|
870
871
|
'/api/openchamber/tunnel/start',
|
|
871
872
|
'/auth/session',
|
|
@@ -877,7 +878,7 @@ describe('CLI HTTP helpers', () => {
|
|
|
877
878
|
});
|
|
878
879
|
});
|
|
879
880
|
|
|
880
|
-
it('
|
|
881
|
+
it.each(['oc_ui_session', 'oc_ui_session_3000'])('uses the stored password and getSetCookie for %s', async (cookieName) => {
|
|
881
882
|
await withTempOpenChamberDataDir(async () => {
|
|
882
883
|
const port = 45679;
|
|
883
884
|
fs.writeFileSync(await getInstanceFilePath(port), JSON.stringify({ port, uiPassword: 'stored-secret' }, null, 2));
|
|
@@ -887,11 +888,11 @@ describe('CLI HTTP helpers', () => {
|
|
|
887
888
|
expect(JSON.parse(options.body)).toEqual({ password: 'stored-secret' });
|
|
888
889
|
return {
|
|
889
890
|
ok: true,
|
|
890
|
-
headers: { getSetCookie: () => [
|
|
891
|
+
headers: { getSetCookie: () => [`${cookieName}=session-token; Path=/; HttpOnly`] },
|
|
891
892
|
json: async () => ({ authenticated: true }),
|
|
892
893
|
};
|
|
893
894
|
}
|
|
894
|
-
if (options.headers?.Cookie ===
|
|
895
|
+
if (options.headers?.Cookie === `${cookieName}=session-token`) {
|
|
895
896
|
return createMockJsonResponse({ ok: true });
|
|
896
897
|
}
|
|
897
898
|
return {
|
package/bin/lib/cli-http.js
CHANGED
|
@@ -3,6 +3,10 @@ import { readDesktopLocalClientTokenFromSettings, readDesktopLocalPortFromSettin
|
|
|
3
3
|
import { getInstanceFilePath, readInstanceOptions } from './cli-process.js';
|
|
4
4
|
|
|
5
5
|
const UI_SESSION_COOKIE_NAME = 'oc_ui_session';
|
|
6
|
+
// The server folds the request port into the cookie name (oc_ui_session_<port>)
|
|
7
|
+
// so LAN instances on different ports don't share one jar (issue #2377). Accept
|
|
8
|
+
// both the bare name and any per-port variant when extracting.
|
|
9
|
+
const UI_SESSION_COOKIE_PATTERN = new RegExp(`(?:^|,\\s*)(${UI_SESSION_COOKIE_NAME}(?:_\\d+)?=[^;]+)`);
|
|
6
10
|
|
|
7
11
|
function extractUiSessionCookie(response) {
|
|
8
12
|
const values = [];
|
|
@@ -23,7 +27,7 @@ function extractUiSessionCookie(response) {
|
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
for (const setCookie of values) {
|
|
26
|
-
const match = setCookie.match(
|
|
30
|
+
const match = setCookie.match(UI_SESSION_COOKIE_PATTERN);
|
|
27
31
|
if (match?.[1]) return match[1];
|
|
28
32
|
}
|
|
29
33
|
return null;
|
package/dist/assets/{CodeMirrorCommentWidgets-C9kV-n7r.js → CodeMirrorCommentWidgets-DvUH815P.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-
|
|
1
|
+
import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-CkbKsm7m.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
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-DLHQogv8.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 In,i as Pn,f as zn}from"./patchFileDiff-DDQ6Rq5e.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-D3hzkybB.js";import{f as ze,B as fe,I as T,h as je,Z as $t,af as Wn,K as ne,ag as Un,bg as Jn,J as Xn,ah as Yn,aj as Qn,z as Mt,k as Zn,d5 as qt,t as Je,kj as es,aw as Xe,aa as ts,ab as ns,ac as ss,k9 as Wt,kk as rs,ax as Ut,gC as is,au as Ue,av as os,c5 as Jt,aq as as,as as ls,at as cs,ap as us}from"./useAppFontEffects-BItUWdo4.js";import{f as ds,d as fs}from"./runtimeEndpointReset-DhC3REb2.js";import{P as ms}from"./PierreDiffViewer-ByRVu6ss.js";import{u as ps,v as hs,g as gs,W as xs}from"./main-DFYTCx5o.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-CZgXWHjU.js";import"./web-components-D7FinaeH.js";import"./computeVirtualFileMetrics-VYnT_A2h.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-ImDG3Uhg.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-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BDyxuqK4.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-B0u3Q5uO.js";import"./PluginPane-QxjsKYeO.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CkbKsm7m.js";import"./appThemeRegistry-Cf8KitzT.js";import"./textMateThemeFromAppTheme-Dgqc63LZ.js";import"./useRootScrollLock-vmzxZjWA.js";import"./scheduledTasksApi-D8pq6gQz.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const ys=i.memo(function(e){const s=Ye.c(13),{index:c,staged:x,busyHunk:p,disabled:y,onAction:j}=e,{t:C}=ze();let l;s[0]!==x?(l=x?["unstage"]:["discard","stage"],s[0]=x,s[1]=l):l=s[1];const b=l;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]!==b||s[4]!==p||s[5]!==y||s[6]!==c||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:b.map(w=>{const K=C(w==="stage"?"diffView.hunk.stageTitle":w==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:c+1}),P=p?.index===c&&p.action===w;return t.jsx(fe,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",w==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",w==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:y||p!==null,title:K,"aria-label":K,onPointerDown:ws,onClick:f=>{f.stopPropagation(),j(c,w)},children:t.jsx(T,{name:P?"loader-4":w==="stage"?"add":"arrow-go-back",className:je(w==="stage"?"size-4":"size-3.5",P&&"animate-spin")})},w)})}),s[3]=b,s[4]=p,s[5]=y,s[6]=c,s[7]=j,s[8]=C,s[9]=d):d=s[9];let M;return s[10]!==c||s[11]!==d?(M=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:R,"data-hunk-actions":c,children:d}),s[10]=c,s[11]=d,s[12]=M):M=s[12],M});function ws(a){return a.stopPropagation()}const Bt=(a,e)=>{if(e.length===0)return null;let s=null,c=null;for(const p of e)p.top<=a?(!s||p.top>s.top)&&(s=p):(!c||p.top<c.top)&&(c=p);const x=s??c;return x?{path:x.path,topOffset:x.top-a}:null},bs=(a,e,s,c)=>Math.min(Math.max(0,c),Math.max(0,a+s-e)),It=a=>{if(!a)return null;const e=a.split(`
|
|
2
|
+
`);let s=null;for(const c of e){const x=c.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(x){const p=Number.parseInt(x[1]??"",10);s=Number.isFinite(p)&&p>=1?p:null;continue}if(s!==null){if(c.startsWith(" ")){s+=1;continue}if(c.startsWith("+"))return s;if(c.startsWith("-"))return Math.max(1,s)}}return null},js=1100,vs=15e3,Pt=500,zt=300,Xt=1e6,yt=3,ks=a=>a<=6?a:a<=12?6:a<=25?4:2,Ot={status:"loading"},Ss=3,Ns=i.memo(()=>{const a=Ye.c(4),{t:e}=ze();let s;a[0]!==e?(s=e("diffView.binary.unavailable"),a[0]=e,a[1]=s):s=a[1];let c;return a[2]!==s?(c=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})}),a[2]=s,a[3]=c):c=a[3],c}),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=a=>{const e=a.index?.trim(),s=a.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=a=>{const e=Rs(a);return Yt[e]??Cs},Fs=a=>{const{index:e,working_dir:s}=a;return e==="A"||s==="A"||e==="?"||s==="?"},_t=a=>{const e=a.index?.trim();return!!(e&&e!=="?")},Kt=a=>!!a.working_dir?.trim()||a.index==="?",Ds=(a,e)=>is(a,e),Gt=a=>(a||"").replace(/\\/g,"/").replace(/\/+$/,""),Ht=(a,e)=>{const s=a.split(`
|
|
3
|
+
`),c=e.split(`
|
|
4
|
+
`),x=Math.min(s.length,c.length);for(let p=0;p<x;p+=1)if(s[p]!==c[p])return p+1;return c.length>s.length?s.length+1:s.length>c.length?Math.max(1,c.length):1},As=a=>Array.isArray(a)?a.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Vs=a=>a==="added"?"A":a==="deleted"?"D":"M",wt=(a,e,s)=>Pn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:zn(a,e),contextMode:s},Zt=(a,e,s)=>{const c=a??0,x=e??0;return!c&&!x?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[c?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",c]}):null,x?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",x]}):null]})},Es=i.memo(a=>{const e=Ye.c(68),{scope:s,workingCount:c,stagedCount:x,turnCount:p,branchCount:y,commitCount:j,prCount:C,showCommitOption:l,showBranchOption:b,onScopeChange:R}=a,{t:d}=ze(),[M,w]=i.useState(!1),K=s==="pr"?C??0:s==="staged"?x:s==="turn"?p:s==="branch"?y??0:s==="commit"?j??0:c;let P;e[0]!==s||e[1]!==d?(P=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]=P):P=e[2];const f=P;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 v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(T,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=v):v=e[10];let E;e[11]!==me||e[12]!==te?(E=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,v]})}),e[11]=me,e[12]=te,e[13]=E):E=e[13];let k;e[14]!==R?(k=Q=>{(Q==="working"||Q==="staged"||Q==="turn"||Q==="branch"||Q==="commit"||Q==="pr")&&(R?.(Q),w(!1))},e[14]=R,e[15]=k):k=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]!==c?(le=t.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[20]=c,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]!==x?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:x}),e[29]=x,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 B;e[34]!==d?(B=d("diffView.scope.lastTurn"),e[34]=d,e[35]=B):B=e[35];let D;e[36]!==B?(D=t.jsx("span",{children:B}),e[36]=B,e[37]=D):D=e[37];let q;e[38]!==p?(q=t.jsx("span",{className:"typography-meta text-muted-foreground",children:p}),e[38]=p,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]!==y||e[44]!==b||e[45]!==d?(de=b?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:y??"…"})]})}):null,e[43]=y,e[44]=b,e[45]=d,e[46]=de):de=e[46];let Y;e[47]!==j||e[48]!==l||e[49]!==d?(Y=l&&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]=l,e[49]=d,e[50]=Y):Y=e[50];let L;e[51]!==C||e[52]!==l||e[53]!==d?(L=l&&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]=l,e[53]=d,e[54]=L):L=e[54];let W;e[55]!==s||e[56]!==re||e[57]!==ue||e[58]!==G||e[59]!==de||e[60]!==Y||e[61]!==L||e[62]!==k?(W=t.jsx(ls,{align:"start",className:"w-40",children:t.jsxs(cs,{value:s,onValueChange:k,children:[re,ue,G,de,Y,L]})}),e[55]=s,e[56]=re,e[57]=ue,e[58]=G,e[59]=de,e[60]=Y,e[61]=L,e[62]=k,e[63]=W):W=e[63];let ve;return e[64]!==M||e[65]!==W||e[66]!==E?(ve=t.jsxs(us,{open:M,onOpenChange:w,children:[E,W]}),e[64]=M,e[65]=W,e[66]=E,e[67]=ve):ve=e[67],ve}),Ls=i.memo(a=>{const e=Ye.c(11),{changedFiles:s,selectedFile:c,onSelectFile:x}=a,{t:p}=ze();if(s.length===0)return null;let y;if(e[0]!==s||e[1]!==x||e[2]!==c||e[3]!==p){let C;e[5]!==x||e[6]!==c||e[7]!==p?(C=l=>{const b=Qt(l),R=c===l.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>x(l.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:l.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:b.color},title:p(b.descriptionKey),"aria-label":p(b.descriptionKey),children:b.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:l.path,children:l.path}),Zt(l.insertions,l.deletions)]})},l.path)},e[5]=x,e[6]=c,e[7]=p,e[8]=C):C=e[8],y=s.map(C),e[0]=s,e[1]=x,e[2]=c,e[3]=p,e[4]=y}else y=e[4];let j;return e[9]!==y?(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:y})}),e[9]=y,e[10]=j):j=e[10],j}),Ts=i.memo(a=>{const e=Ye.c(20),{filePath:s,diff:c,renderSideBySide:x}=a,{t:p}=ze(),y=c.original.length>0,j=c.modified.length>0,C=x?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",l=x?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={contain:"layout"},e[0]=b):b=e[0];let R;e[1]!==c.original||e[2]!==s||e[3]!==y||e[4]!==l||e[5]!==x||e[6]!==p?(R=y&&t.jsxs("div",{className:l,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p("diffView.image.original")}),t.jsx("img",{src:c.original,alt:p("diffView.image.originalAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=c.original,e[2]=s,e[3]=y,e[4]=l,e[5]=x,e[6]=p,e[7]=R):R=e[7];let d;e[8]!==c.modified||e[9]!==s||e[10]!==j||e[11]!==y||e[12]!==l||e[13]!==x||e[14]!==p?(d=j&&t.jsxs("div",{className:l,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p(y?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:c.modified,alt:p("diffView.image.modifiedAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=c.modified,e[9]=s,e[10]=j,e[11]=y,e[12]=l,e[13]=x,e[14]=p,e[15]=d):d=e[15];let M;return e[16]!==C||e[17]!==R||e[18]!==d?(M=t.jsx("div",{className:"w-full overflow-auto p-4",style:b,children:t.jsxs("div",{className:C,children:[R,d]})}),e[16]=C,e[17]=R,e[18]=d,e[19]=M):M=e[19],M}),Ms=i.memo(a=>{const e=Ye.c(20),{filePath:s,diff:c,staged:x,renderSideBySide:p,wrapLines:y,hunkActions:j}=a;let C;e[0]!==s?(C=os(s)||"text",e[0]=s,e[1]=C):C=e[1];const l=C;if(c.submodule){let d;return e[2]!==c.submodule||e[3]!==x?(d=t.jsx(qn,{state:c.submodule,staged:x}),e[2]=c.submodule,e[3]=x,e[4]=d):d=e[4],d}if(c.isBinary){let d;return e[5]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(Ns,{}),e[5]=d):d=e[5],d}if(Xe(s)){let d;return e[6]!==c||e[7]!==s||e[8]!==p?(d=t.jsx(Ts,{filePath:s,diff:c,renderSideBySide:p}),e[6]=c,e[7]=s,e[8]=p,e[9]=d):d=e[9],d}let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b={contain:"layout"},e[10]=b):b=e[10];let R;return e[11]!==c.fileDiff||e[12]!==c.modified||e[13]!==c.original||e[14]!==s||e[15]!==j||e[16]!==l||e[17]!==p||e[18]!==y?(R=t.jsx("div",{className:"w-full",style:b,children:t.jsx(ms,{original:c.original,modified:c.modified,fileDiff:c.fileDiff,language:l,fileName:s,renderSideBySide:p,wrapLines:y,layout:"inline",hunkActions:j})}),e[11]=c.fileDiff,e[12]=c.modified,e[13]=c.original,e[14]=s,e[15]=j,e[16]=l,e[17]=p,e[18]=y,e[19]=R):R=e[19],R}),Bs=i.memo(({visible:a=!0,directory:e,file:s,layout:c,wrapLines:x,isSelected:p,isExpanded:y,isMounted:j,onSelect:C,onExpandedChange:l,registerSectionRef:b,showOpenInEditorAction:R=!1,isOpeningInEditor:d=!1,onOpenInEditor:M,staged:w=!1,loadFullFiles:K=!1,initialDiffData:P=null,comparisonDiff:f,onRetryComparisonDiff:me,readOnlyActions:pe=!1,hunkActionsEnabled:te=!1})=>{const{t:v}=ze(),{git:E}=$t(),k=ne(i.useCallback(g=>g.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),se=ne(g=>g.setDiff),J=ne(g=>g.fetchStatus),le=ae(g=>g.setDiffFileLayout),[re,ce]=i.useState(0),[X,$]=i.useState(null),[ue,B]=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),[L,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=c==="side-by-side",De=K?"full":"patch",ge=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,o=te&&!pe&&!P&&!f&&!Xe(s.path),xe=JSON.stringify([Re(),e,s.path,w,ge,re]),z=L?.scope===xe?L.patch:null,Ze=L?.scope===xe?L.submodule:null,U=i.useMemo(()=>f?f.status==="ready"?f.data:null:P||(w?lt:ie||(k?{original:k.original,modified:k.modified,isBinary:k.isBinary,submodule:k.submodule,contextMode:"full"}:null)),[f,k,P,ie,w,lt]),et=U?.contextMode===De,tt=i.useCallback(g=>{mt.current=g,b(s.path,g)},[s.path,b]),nt=i.useCallback(g=>{l(s.path,g)},[s.path,l]),st=i.useCallback(()=>{C(s.path)},[s.path,C]),rt=i.useRef({fileStatusKey:ge,staged:w});i.useEffect(()=>{if(!a)return;const g=rt.current;g.fileStatusKey===ge&&g.staged===w||(rt.current={fileStatusKey:ge,staged:w},w?Fe(null):Qe(null),$(null),he.current=null)},[ge,w,a]),i.useEffect(()=>{if(!a||!y||!j||X)return;if(!e||f||P||U&&et&&(!o||z!==null)){he.current=null,B(!1);return}const g=`${e}::${s.path}::${w?"staged":"unstaged"}::${ge}::${De}::${re}`;if(he.current===g)return;he.current=g,$(null),B(!0);let O=!1;const ye=Re(),Ge=K?Xt:yt,Z=Xe(s.path)?E.getGitFileDiff(e,{path:s.path,staged:w}):!K&&z!==null?Promise.resolve({diff:z,submodule:Ze}):E.getGitDiff(e,{path:s.path,staged:w,contextLines:Ge}),Ve=o&&K&&z===null?E.getGitDiff(e,{path:s.path,staged:w,contextLines:yt}).then(S=>S.diff):Promise.resolve(z),Ie=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([Ie,Ee]).then(([S,He])=>{if(O||ye!==Re())return;const be="diff"in S&&!K?S.diff:He;if(o&&K&&be!==null&&/^@@\s/m.test(be)&&"diff"in S&&S.diff!==be&&!Mn(S.diff,be))throw W(null),new Error(v("diffView.hunk.unavailable"));if(o&&be!==null&&W({scope:xe,patch:be,submodule:S.submodule}),"diff"in S){const Se={...wt(s.path,S.diff,De),submodule:S.submodule};w?Fe(Se):Qe(Se)}else{const Se={original:S.original??"",modified:S.modified??"",isBinary:S.isBinary,submodule:S.submodule,contextMode:"full"};w?Fe(Se):se(e,s.path,Se,ye)}B(!1)}).catch(S=>{if(!(O||ye!==Re())){if(B(!1),S instanceof Fn){$({kind:"unavailable",reason:S.reason}),S.reason==="path_not_found"&&J(e,E,{force:!0,silent:!0});return}$({kind:"error",message:S instanceof Error?S.message:String(S)})}}).finally(()=>clearTimeout(_)),()=>{O=!0,clearTimeout(_),he.current===g&&(he.current=null)}},[z,Ze,o,xe,f,De,U,et,re,e,J,s.path,ge,E,P,y,j,K,X,se,w,v,a]);const ct=i.useCallback(()=>{nt(!y),st()},[nt,st,y]),Ae=i.useCallback(()=>{$(null),W(null),Qe(null),Fe(null),he.current=null,ce(g=>g+1)},[]),ke=i.useCallback(async(g,O)=>{if(!e||!o||q||D||Y.current||G!==null)return;const ye=z?Bn(z,g):null;if(!ye){Je.error(v("diffView.hunk.unavailable"));return}if(w&&O!=="unstage"||!w&&O==="unstage")return;Y.current=!0;const Ge=Re();de({index:g,action:O});try{const Z=O==="stage"?E.stageGitHunk:O==="unstage"?E.unstageGitHunk:E.revertGitHunk;if(!Z){Je.error(v("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,E)}catch(Z){if(Ge!==Re())return;Ae(),Je.error(Z instanceof Error&&Z.message?Z.message:v("diffView.hunk.unavailable"))}finally{Y.current=!1,de(Z=>Z?.index===g&&Z.action===O?null:Z)}},[z,o,q,D,e,J,s.path,E,G,Ae,w,v]),Be=i.useMemo(()=>o&&z!==null?In(z):[],[z,o]),Ke=i.useCallback(g=>t.jsx(ys,{index:g,staged:w,busyHunk:G,disabled:q||!!D,onAction:ke}),[D,ke,G,q,w]),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:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.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",p?"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:y?t.jsx(T,{name:"arrow-down-s",className:"size-4"}):t.jsx(T,{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:v(Oe.descriptionKey),"aria-label":v(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 g=s.path.lastIndexOf("/");if(g===-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,g),ye=s.path.slice(g+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&&M?t.jsx(fe,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:v("diffView.actions.openFileInEditorAtChange"),onClick:g=>{g.stopPropagation(),M(s.path,U)},disabled:d,children:d?t.jsx(T,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(T,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:_e?"side-by-side":"unified",onModeChange:g=>{const O=g==="side-by-side"?"side-by-side":"inline";le(s.path,O)},className:"opacity-70"})]})]})}),y&&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"?v("diffView.unavailable.nestedRepositoryTitle"):D.reason==="untracked_directory"?v("diffView.unavailable.untrackedDirectoryTitle"):v("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.reason==="nested_repository"?v("diffView.unavailable.nestedRepositoryDescription"):D.reason==="untracked_directory"?v("diffView.unavailable.untrackedDirectoryDescription"):v("diffView.unavailable.missingDescription")}),D.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:Ae,children:v("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:v("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:v("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(T,{name:"loader-4",className:"size-4 animate-spin"}),v("diffView.state.loadingDiff")]}):null,j&&U&&!ve&&s.insertions+s.deletions>Pt?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:v("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:v("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Q(!0),children:v("diffView.actions.renderAnyway")})]}):null,j&&U&&(ve||s.insertions+s.deletions<=Pt)?t.jsx(t.Fragment,{children:t.jsx(Ms,{filePath:s.path,diff:U,staged:w,renderSideBySide:_e,wrapLines:x,hunkActions:it})}):null]})]})}),to=({visible:a=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:c=!1,showOpenInEditorAction:x=!1,diffScope:p="all",onDiffScopeChange:y,targetFilePath:j=null,flushContent:C=!1})=>{const{t:l}=ze(),{git:b,files:R}=$t(),d=Wn(),M=ne(n=>n.runtimeKey),{rootIsGitRepo:w,gitDirectory:K,nestedRepos:P}=Un(d??null,{enabled:a}),f=K??d,me=ae(n=>n.openContextSurface),pe=ps(n=>n.requestSource),{screenWidth:te,isMobile:v}=Jn(),E=Xn(f??null),k=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),[B,D]=i.useState(null),[q,G]=i.useState(!1),[de,Y]=i.useState(null),[L,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),[o,xe]=i.useState(p);i.useEffect(()=>{xe(p)},[p]);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),ke=Mt(n=>n.currentSessionId),Be=Zn(o==="turn"?ke??"":"",d??void 0),Ke=rt,it=o==="staged"?!0:o==="working"?!1:null,g=it??q,O=v||te<=768,ye=!!ke&&o!=="turn"&&o!=="commit"&&o!=="pr"&&!O&&!Ce(),Ge=o!=="turn"&&!O&&!Ce(),Z=!e&&!O&&te>=1024,Ve=i.useRef(null),Ie=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),Se=i.useRef(null),bt=i.useCallback(()=>{const n=Ve.current;if(!n)return null;const r=n.getBoundingClientRect().top,m=[];for(const[u,h]of Ie.current)h&&m.push({path:u,top:h.getBoundingClientRect().top});return Bt(r,m)},[]),$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 m=new Set(r);return m.add(n),m})},[]),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(()=>k?.files?k.files.filter(Kt).length:0,[k]),nn=i.useMemo(()=>k?.files?k.files.filter(_t).length:0,[k]),sn=ot.length,H=k?.current??null,Le=Dn(f??null,H,a&&o==="pr"&&!Ce()),Te=Le.selectedSource,Me=An(f??null,H,a&&o==="commit"&&!Ce()),Pe=Me.selectedCommit?.hash??null;i.useEffect(()=>{(o==="commit"||o==="pr")&&Ce()&&(xe("working"),y?.("working"))},[o,y]);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,b)},[f,X,b]),an=On(f??null,a&&E!==!1,rn,!!We,on,Ss),jt=i.useMemo(()=>{const n=k?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,k?.tracking]),vt=!Ce()&&_n(H,jt),ln=k!==null,kt=Ce()||an||Kn(H,jt,ln,We!==null),cn=Vn(n=>n.setOverride),{base:Ne,resolved:un,revision:St}=En(f??null,H,a&&vt&&o==="branch"),[dn,fn]=i.useState(0);i.useEffect(()=>{const n=$n(o,!kt);n!==o&&(xe(n),n==="working"&&y?.("working"))},[o,kt,y]);const mn=i.useMemo(()=>o==="pr"?Te:o==="commit"&&Pe?{kind:"commit",hash:Pe}:o==="branch"&&Ne&&H?{kind:"branch",baseRef:Ne,headRef:H}:null,[o,Ne,H,Pe,Te]),V=Gn(f??null,mn,a&&!Ce(),o==="branch"?St:""),{fetchDiff:Nt}=V,Ct=o==="commit"?V.files:null,Rt=o==="commit"?V.error:null,ut=o==="branch"?V.files:null,Ft=o==="branch"?V.error:null,Dt=V.files?o==="pr"?JSON.stringify([V.key,V.revision]):V.key:null,pn=i.useMemo(()=>o==="branch"||o==="commit"||o==="pr"?Array.from(L).sort().join("\0"):"",[o,L]),hn=i.useCallback(async n=>{try{const r=ie&&o!=="pr",m=await Nt(n,r?Xt:yt);return{status:"ready",data:wt(n,m.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:l("diffView.state.failedToLoadDiff")}}},[o,Nt,ie,l]),gn=Hn(Dt,a?pn:"",Dt?hn:null,Ot,JSON.stringify([o==="branch"?St:"",o==="pr"?V.revision:0,dn,ie])),xn=ut?.length??null,N=i.useMemo(()=>{if(o==="commit"||o==="pr")return(V.files??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:u.insertions,deletions:u.deletions,isNew:u.status==="A"}));if(o==="branch")return(ut??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:0,deletions:0,isNew:u.status==="A"})).sort((u,h)=>u.path.localeCompare(h.path));if(o==="turn")return ot.map(u=>({path:u.file??"",index:"",working_dir:Vs(u.status),insertions:u.additions??0,deletions:u.deletions??0,isNew:u.status==="added"})).filter(u=>u.path).sort((u,h)=>u.path.localeCompare(h.path));if(!k?.files)return[];const n=k.diffStats,r=o==="staged"?_t:o==="working"?Kt:()=>!0,m=u=>{const h=n?.staged?.[u],A=n?.working?.[u];return o==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:o==="working"?{insertions:A?.insertions??0,deletions:A?.deletions??0}:{insertions:(h?.insertions??0)+(A?.insertions??0),deletions:(h?.deletions??0)+(A?.deletions??0)}};return k.files.filter(r).map(u=>{const h=m(u.path);return{...u,insertions:h.insertions,deletions:h.deletions,isNew:Fs(u)}}).sort((u,h)=>u.path.localeCompare(h.path))},[o,ut,V.files,ot,k]),pt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=pt?pt.split("\0"):[],r=new Set(n),m=`${f??""}:${o}:${s?"collapsed":"default"}`,u=He.current!==m;He.current=m,W(h=>{if(u){const I=s?0:ks(n.length);return new Set(n.slice(0,I))}let A=!1;const F=new Set;for(const I of h){if(!r.has(I)){A=!0;continue}F.add(I)}return A?F:h}),Q(h=>{if(u)return new Set;let A=!1;const F=new Set;for(const I of h){if(!r.has(I)){A=!0;continue}F.add(I)}return A?F:h})},[o,pt,f,s]);const At=i.useCallback(()=>{if(S.current=null,!a)return;const n=Ve.current;if(!n)return;const r=n.getBoundingClientRect(),m=r.top-zt,u=r.bottom+zt,h={},A=[];for(const[F,I]of Ie.current){if(!I)continue;const ee=I.getBoundingClientRect();A.push({path:F,top:ee.top}),L.has(F)&&(ee.bottom<m||ee.top>u||(h[F]=!0))}be.current=Bt(r.top,A),Q(F=>{let I=!1;const ee=new Set(F);for(const at of Object.keys(h))ee.has(at)||(ee.add(at),I=!0);return I?ee:F})},[L,a]),oe=i.useCallback(()=>{a&&(typeof window>"u"||S.current===null&&(S.current=window.requestAnimationFrame(At)))},[At,a]);i.useEffect(()=>{const n=Ve.current;if(!(!a||!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,L,oe,a]);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 m=te<js;return n.isNew||m?"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(()=>{a&&f&&(J(f),le(f,b))},[f,J,le,b,a]);const dt=JSON.stringify([M,f]),gt=i.useRef({scope:dt,paths:new Set,dirty:!1}),Et=i.useRef(a);i.useEffect(()=>{const n=a&&!Et.current;if(Et.current=a,gt.current.scope!==dt&&(gt.current={scope:dt,paths:new Set,dirty:!1}),!f)return;const r=u=>{u?.length&&(Se.current=bt()??be.current,$(f,u),mt(h=>{const A=new Map(h);for(const F of u)A.set(F,(A.get(F)??0)+1);return A})),ce(f,b,{silent:!0})},m=gt.current;return a&&(n||m.dirty)&&(r([...m.paths]),m.paths.clear(),m.dirty=!1),qt.onGitRefreshHint(u=>{if(Gt(u.directory)===Gt(f)){if(!a){m.dirty=!0;for(const h of u.paths??[])m.paths.add(h);return}r(u.paths)}})},[bt,$,f,ce,b,dt,a]),i.useLayoutEffect(()=>{const n=Se.current;if(!n)return;Se.current=null;const r=Ve.current,m=Ie.current.get(n.path);if(!r||!m)return;const u=r.getBoundingClientRect().top,h=m.getBoundingClientRect().top-u;r.scrollTop=bs(r.scrollTop,n.topOffset,h,r.scrollHeight-r.clientHeight),be.current=n},[he]),i.useEffect(()=>{!a||o!=="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))},[o,qe,z,U,Ze,et,a]),i.useEffect(()=>{if(o==="all")return;const n=j?.trim();n&&(D(n),G(o==="staged"),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1))},[o,qe,j]),i.useEffect(()=>{if(!B)return;N.some(r=>r.path===B)||(D(null),G(!1))},[N,B]);const yn=i.useCallback((n,r)=>{const m=Ie.current;r?m.set(n,r):m.delete(n),oe()},[oe]),wn=i.useCallback((n,r)=>{$e(),W(m=>{const u=m.has(n);if(r===u)return m;const h=new Set(m);return r?h.add(n):h.delete(n),h}),r||Q(m=>{if(!m.has(n))return m;const u=new Set(m);return u.delete(n),u}),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(!ke)return;const r=Mt.getState().getDirectoryForSession(ke)||d||"";if(!r){Je.error(l("diffView.reviewDialog.toast.noSessionDirectory"));return}ge(!0);try{await es({originalSessionID:ke,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(m){console.error("[review-flow] failed to start review flow",m),Je.error(m instanceof Error?m.message:l("diffView.reviewDialog.toast.startFailed"))}finally{ge(!1)}},[ke,d,l]),ft=i.useCallback(n=>{const r=Ie.current.get(n),m=Ve.current;if(!r||!m)return!1;const u=r.getBoundingClientRect().top-m.getBoundingClientRect().top;return m.scrollTo({top:m.scrollTop+u,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=we.current;if(!a||!n)return;let r=0;const m=20;let u=!1;const h=(F=!0)=>{u||(u=!0,we.current=null,Ee.current=!1,F&&Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null))},A=()=>{if(u){_.current=null;return}const F=we.current;if(!F){h(),_.current=null;return}if(!ft(F)){r+=1,r<m?_.current=window.requestAnimationFrame(A):(h(),_.current=null);return}if(c&&Ee.current){Y(F),h(!1);return}h()};return _.current=window.requestAnimationFrame(A),()=>{u=!0,_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)}},[c,lt,ft,a]);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(!a||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const m=r.target;if(m instanceof HTMLElement&&(m.isContentEditable||m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.closest('[role="dialog"]'))||N.length===0)return;const u=r.key==="ArrowDown"?1:-1,h=B?N.findIndex(I=>I.path===B):-1,A=h===-1?u>0?0:N.length-1:h+u,F=N[A];F&&(r.preventDefault(),xt(F.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,B,xt,a]);const kn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(m=>{st(m.path,r)})},[N,st]),[Sn,Lt]=i.useState(null),Nn=i.useCallback(async(n,r)=>{if(!f||!n)return;Lt(n);const m=Re();try{let u=null;if(r?.patch&&!r.isBinary&&!Xe(n)?u=It(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(u=Ht(r.original,r.modified)),u===null)try{const ee=await b.getGitDiff(f,{path:n,staged:g,contextLines:3});u=It(ee.diff)}catch{u=null}let h=r;if(u===null||!h){const ee=await b.getGitFileDiff(f,{path:n,staged:g}),at={original:ee.original??"",modified:ee.modified??"",isBinary:ee.isBinary,submodule:ee.submodule};h=at,g||ue(f,n,at,m)}const A=u??(h.isBinary||Xe(n)?1:Ht(h.original,h.modified)),F=Ds(f,n),I=await hs(R,F,{directory:f});if(!I.ok){Je.error(gs(I.reason));return}Ae(f,F,A,1)}finally{Lt(u=>u===n?null:u)}},[g,f,R,b,Ae,ue]),Cn=()=>{if(!f)return null;const n=r=>it!==null?it:q&&r===B;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:l("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:a,directory:f,file:r,layout:ht(r),wrapLines:Ke,isSelected:!1,isExpanded:L.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:x&&o!=="turn",isOpeningInEditor:Sn===r.path,onOpenInEditor:(m,u)=>{Nn(m,u)},staged:n(r.path),loadFullFiles:ie&&o!=="pr",readOnlyActions:o==="branch"||o==="commit"||o==="pr",hunkActionsEnabled:o==="all"||o==="working"||o==="staged",comparisonDiff:o==="branch"||o==="commit"||o==="pr"?gn.get(r.path)??Ot:void 0,onRetryComparisonDiff:()=>fn(m=>m+1),initialDiffData:o==="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:l("diffView.state.selectSessionDirectory")});if(o!=="turn"&&se&&!k)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingRepositoryStatus")]});if(o!=="turn"&&E===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l("diffView.state.notGitRepository")});if(o==="pr"){if(!Te||V.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:V.error??Le.error??(Le.loading?l("session.githubPrPicker.loading.pullRequests"):l("pullRequestComparison.select"))}),(V.error||Le.error)&&t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{Te?V.refresh():Le.refresh()},children:l("diffView.actions.retry")}),!Te&&!Le.loading&&t.jsx(Tt,{comparison:Le})]});if(!V.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(o==="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:()=>{V.refresh()},children:l("diffView.actions.retry")})]});if(!Pe&&!Me.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Me.error??l("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(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(o==="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(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.resolvingBase")]});if(!Ne)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(T,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:l("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:l("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:l("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:()=>{V.refresh()},children:l("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(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:o==="turn"?l("diffView.state.noLastTurnChanges"):o==="pr"?l("walkthrough.blocked.emptyDiff.description"):o==="commit"?l("commitComparison.emptyDiff"):o==="branch"&&Ne?l("diffView.branch.empty",{base:fs(Ne)}):l("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:[w===!1&&Array.isArray(P)&&P.length>0?t.jsx(ds,{repositories:P,selectedRepository:K??null,onSelectRepository:n=>{d&&re(d,n)},repositoryRoot:d??void 0}):null,!v&&(o!=="all"?t.jsx(Es,{scope:o,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:o==="commit"?Ct?.length??null:null,prCount:o==="pr"?V.files?.length??null:null,showCommitOption:!Ce(),showBranchOption:vt,onScopeChange:n=>{xe(n),y?.(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&&!k?l("diffView.state.loadingChanges"):N.length===1?l("diffView.summary.changedFilesSingle",{count:N.length}):l("diffView.summary.changedFilesPlural",{count:N.length})})})),o==="branch"&&t.jsx(Ln,{branches:We?.all??[],currentBranch:H,base:Ne,onSelect:n=>{f&&H&&cn(f,H,n)}},JSON.stringify([f,H])),o==="commit"&&t.jsx(Tn,{commits:Me.commits,selectedHash:Pe,loading:Me.loading,error:Me.error,onSelect:Me.select,onRefresh:()=>{Me.refresh()}},JSON.stringify([f,H])),o==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Le},JSON.stringify([M,f,H])),Te&&t.jsx(fe,{variant:"ghost",size:"sm",disabled:V.loading,"aria-label":l("session.githubIssuePicker.actions.refresh"),title:l("session.githubIssuePicker.actions.refresh"),onClick:()=>{V.refresh()},children:t.jsx(T,{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:L.size>0?l("diffView.actions.collapseAll"):l("diffView.actions.expandAll"),children:[t.jsx(T,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:L.size>0?l("diffView.actions.collapseAll"):l("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":l("diffView.actions.reviewAria"),children:[De?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:l("diffView.actions.review")})]}),N.length>0&&Ge&&t.jsxs(fe,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";pe(n,o==="pr"&&Te?Te:o==="commit"&&Pe?{kind:"commit",hash:Pe}:o==="branch"&&Ne&&H?{kind:"branch",baseRef:Ne,headRef:H}:{kind:"working-tree",scope:o==="staged"||o==="working"?o:"all"}),me(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",xs),"aria-label":l("walkthrough.action.open"),children:[t.jsx(T,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:l("walkthrough.action.open")})]}),N.length>0&&o!=="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":l(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(T,{name:"file-download",className:"size-4"})})}),t.jsx(ss,{children:t.jsx("p",{children:l(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:l(Ke?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(T,{name:"text-wrap",className:"size-4"})}),Vt&&t.jsx(Wt,{mode:Vt==="side-by-side"?"side-by-side":"unified",onModeChange:kn})]}),t.jsx(rs,{open:Oe,onOpenChange:_e,projectDirectory:f??null,submitting:De,onConfirm:jn}),Rn()]})};export{to as DiffView,Bs as MultiFileDiffEntry};
|