@pi-chamber/web 1.0.7 → 1.0.8-rc.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/dist/assets/AgentsSurface-CcWBqAWV.js +1 -0
- package/dist/assets/ChoicesArtifact-Kk-qvrSB.js +1 -0
- package/dist/assets/DiagramView-DZUBo1uP.js +1 -0
- package/dist/assets/{DiffView-BxW6BuOC.js → DiffView-CiZy4jFA.js} +6 -6
- package/dist/assets/FileSaveConflictDialog-DZ9NDwOO.js +3 -0
- package/dist/assets/FilesView-DqiZ9kw9.js +6 -0
- package/dist/assets/GitHubDetailScaffold-DM2DH7o8.js +11 -0
- package/dist/assets/GitHubLinkPicker-ChB8NZ1h.js +1 -0
- package/dist/assets/GitHubListPrimitives-CibDiJGq.js +1 -0
- package/dist/assets/{GitView-DD33ngnM.js → GitView--EaZQrBr.js} +5 -5
- package/dist/assets/{IssuesSurface-BAY_eyX5.js → IssuesSurface-CySTpaD1.js} +3 -3
- package/dist/assets/{JsonTreeView-DpXbUrAl.js → JsonTreeView-_yMHKKQZ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cn63lAmn.js → MarkdownRendererImpl-D_-2fQw0.js} +3 -3
- package/dist/assets/PatchDiff-bHObDlhD.js +1 -0
- package/dist/assets/PierreDiffViewer-UY7Cse-s.js +147 -0
- package/dist/assets/PullRequestsSurface-iXy6chwc.js +2 -0
- package/dist/assets/{SessionSwitcherContent-CscYekC1.js → SessionSwitcherContent-DJGCa_wN.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-CDOX-5Y2.js +2 -0
- package/dist/assets/SessionUnreadDot-Dwc3MdvA.js +1 -0
- package/dist/assets/SettingsView-DA-U9lsj.js +11 -0
- package/dist/assets/{SettingsWindow-gxjULdm1.js → SettingsWindow-CUg49Mfh.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-DNsbTLS7.js → StickyHorizontalScrollbar-CMbTn5WQ.js} +1 -1
- package/dist/assets/SubagentsArtifact-DUZX9tDe.js +1 -0
- package/dist/assets/ToolOutputDialog-BuZZaRw4.js +8 -0
- package/dist/assets/ToolPartDiffPreview-CKncG6i2.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-BrbPymTL.js → VirtualizedFileDiff-BGZiLPe_.js} +4 -4
- package/dist/assets/{Virtualizer-okhy9Aq3.js → Virtualizer-PxblpQn6.js} +1 -1
- package/dist/assets/VisualFrame-DBZkHFnG.js +22 -0
- package/dist/assets/VisualsArtifact-Bq0vMO-i.js +1 -0
- package/dist/assets/{collapsible-D6qdoq7-.js → collapsible-Bro9KrfM.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-G4csGiKs.js → computeVirtualFileMetrics-DJQqK49u.js} +2 -2
- package/dist/assets/contextFileOpenGuard-ByWK3Sru.js +1 -0
- package/dist/assets/{fileTreeStatus-Bskhj4qT.js → fileTreeStatus-CyJ3TOYD.js} +2 -2
- package/dist/assets/gitStatusPredicates-BsXrwngT.js +1 -0
- package/dist/assets/githubLink-g2bmC0qi.js +10 -0
- package/dist/assets/index-B_L9GVYw.css +1 -0
- package/dist/assets/{index-ComwtfT4.js → index-C9rUUQ_Y.js} +1 -1
- package/dist/assets/index-CKKWVoND.js +11 -0
- package/dist/assets/{main-DoiadX0a.js → main-DT-4_fhe.js} +2 -2
- package/dist/assets/main-DsLMU9CT.js +137 -0
- package/dist/assets/{markdownCore-DczkEluO.js → markdownCore-QmM_aOnZ.js} +2 -2
- package/dist/assets/{miniChat-Ck6MEZ9Q.js → miniChat-BqGslD2z.js} +2 -2
- package/dist/assets/{mobile-BucKVm1P.js → mobile-C5JOcDIC.js} +2 -2
- package/dist/assets/{nativeFileSave-Cp9i5QGd.js → nativeFileSave-DSMsJqXM.js} +1 -1
- package/dist/assets/pi-session-focus-preference-Cc_S4zi1.js +9 -0
- package/dist/assets/{renderDiffWithHighlighter-PL82AR81.js → renderDiffWithHighlighter-BXhnIAHg.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-CiSkecEE.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-CYgfbA4F.js → renderFileWithHighlighter-CK29YZtC.js} +1 -1
- package/dist/assets/renderMobileApp-C4JuoxsZ.js +11 -0
- package/dist/assets/runtimeEndpointReset-Dwj-jCDS.js +66 -0
- package/dist/assets/runtimeSurface-0K7vuUpd.js +1 -0
- package/dist/assets/selection-CnYkEsu_.js +1 -0
- package/dist/assets/useAppFontEffects-CV5UyTRw.js +226 -0
- package/dist/assets/useGitHubRemoteSearch-CgP-zEBj.js +1 -0
- package/dist/assets/useSwitcherItems-C8G5F0hs.js +1 -0
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-DVZvgYu4.js → vendor-aparajita-capacitor-secure-storage-DUoR8t1G.js} +1 -1
- package/dist/assets/{vendor-base-ui-BCqPBzDj.js → vendor-base-ui-DE6jnTiC.js} +1 -1
- package/dist/assets/{vendor-boot-3SaHYVb1.js → vendor-boot-D-KEJjsM.js} +29 -29
- package/dist/assets/{vendor-capacitor-app-NbQ-WiPS.js → vendor-capacitor-app-CO5jS31X.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-CgrHt8iN.js → vendor-capacitor-keyboard-335osRpd.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-CWt0OF5t.js → vendor-capacitor-status-bar-lB9y4H9d.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-WThuuUAz.js → vendor-codemirror-autocomplete-BKvJ8PfM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-BbLGCxF6.js → vendor-codemirror-lang-angular-wjCUD0bM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-Cceks-9O.js → vendor-codemirror-lang-cpp-LJzlG8sJ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-D1wpUg3Z.js → vendor-codemirror-lang-css-DoEEdEpW.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-Cv0zXHHM.js → vendor-codemirror-lang-go-DexsLPb8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DbL8oT9H.js → vendor-codemirror-lang-html-h25V-Hp5.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CNugenuC.js → vendor-codemirror-lang-java-D8xoT8cv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Bx_FIyZF.js → vendor-codemirror-lang-javascript-DF3GDYje.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-DDGjB3Zq.js → vendor-codemirror-lang-jinja-BboTHFdn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-DIvqf9Pb.js → vendor-codemirror-lang-json-DCqvG1nE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-D8r9dGG1.js → vendor-codemirror-lang-less-B8ZrSKJM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-B24mguYi.js → vendor-codemirror-lang-liquid-DF9S5m5F.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-v3yG2sbf.js → vendor-codemirror-lang-markdown-6BNbCEPe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BcZGalqy.js → vendor-codemirror-lang-php-CQwAz1Hd.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-b-JqEwQy.js → vendor-codemirror-lang-python-DQym-8Tx.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-B1uZxDW-.js → vendor-codemirror-lang-rust-DknzOTkO.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-DqPrngKp.js → vendor-codemirror-lang-sass-dB0Rm5HI.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-UyCnpt-k.js → vendor-codemirror-lang-sql-CCQUnnD-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-xDwYkovV.js → vendor-codemirror-lang-vue-h1M5bF00.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-CF3169p_.js → vendor-codemirror-lang-wast-DWgtlGfu.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-FCtVhuOb.js → vendor-codemirror-lang-xml-DncwoCUY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-g0sPmAnv.js → vendor-codemirror-lang-yaml-C7QkS5ER.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-B03xgzP2.js → vendor-codemirror-language-data-BUZIlm3G.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-Dw3Wpu15.js → vendor-codemirror-search-BlDCaCMK.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-Cu3E-KUI.js → vendor-lezer-cpp-B4JK1BC1.js} +1 -1
- package/dist/assets/{vendor-lezer-css-Cb8vp67u.js → vendor-lezer-css-DRxDmhcy.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BTsIaOm7.js → vendor-lezer-go-DsUgfmxi.js} +1 -1
- package/dist/assets/{vendor-lezer-html-UQMsUwj-.js → vendor-lezer-html-qr9pUPmM.js} +1 -1
- package/dist/assets/{vendor-lezer-java-BIWrFrAx.js → vendor-lezer-java-6UyNiQiB.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-BH2Etgoy.js → vendor-lezer-javascript-CUdJ0VGA.js} +1 -1
- package/dist/assets/{vendor-lezer-json-CE-QUCwM.js → vendor-lezer-json-BKYAA8Hu.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-HY6Yc0Vr.js → vendor-lezer-lr-DluApmOX.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-xFL3Evwf.js → vendor-lezer-markdown-B-uzYzYT.js} +1 -1
- package/dist/assets/{vendor-lezer-php-Cr_mQGrG.js → vendor-lezer-php-DI6PNjlz.js} +1 -1
- package/dist/assets/{vendor-lezer-python-BNRFWCb0.js → vendor-lezer-python-Bj232yb5.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-BvfOK5cU.js → vendor-lezer-rust-DlPG_Yau.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-qoxiLisk.js → vendor-lezer-sass-CBsyWB2A.js} +1 -1
- package/dist/assets/{vendor-lezer-xml--x8SSpqU.js → vendor-lezer-xml-C1FmgtmE.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-BDo1JaEr.js → vendor-lezer-yaml-DpHmjriG.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-D1Fe7FiY.js → vendor-replit-codemirror-vim-Cvk64got.js} +1 -1
- package/dist/assets/{web-components-CGDpzixf.js → web-components-BpncHjnV.js} +4 -4
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -1
- package/plugins/featured.json +12 -0
- package/plugins/registry.json +7 -0
- package/plugins/subagents/LICENSE +25 -0
- package/plugins/subagents/agents/planner.md +36 -0
- package/plugins/subagents/agents/reviewer.md +34 -0
- package/plugins/subagents/agents/scout.md +49 -0
- package/plugins/subagents/agents/worker.md +23 -0
- package/plugins/subagents/extension.js +631 -0
- package/plugins/subagents/extension.test.js +295 -0
- package/plugins/subagents/package.json +41 -0
- package/plugins/visuals/choices.js +168 -0
- package/plugins/visuals/extension.js +90 -0
- package/plugins/visuals/files.js +74 -0
- package/plugins/visuals/package.json +32 -0
- package/server/index.js +103 -24
- package/server/lib/git/DOCUMENTATION.md +4 -0
- package/server/lib/git/service.js +70 -5
- package/server/lib/git/service.test.js +179 -0
- package/server/lib/github/DOCUMENTATION.md +6 -2
- package/server/lib/github/gh-cli.js +35 -9
- package/server/lib/github/gh-cli.test.js +122 -0
- package/server/lib/marketplace/DOCUMENTATION.md +95 -0
- package/server/lib/marketplace/featured.js +176 -0
- package/server/lib/marketplace/featured.test.js +207 -0
- package/server/lib/marketplace/npm-registry.js +255 -0
- package/server/lib/marketplace/npm-registry.test.js +227 -0
- package/server/lib/marketplace/routes.js +64 -0
- package/server/lib/marketplace/routes.test.js +119 -0
- package/server/lib/marketplace/service.js +225 -0
- package/server/lib/marketplace/service.test.js +174 -0
- package/server/lib/notifications/DOCUMENTATION.md +10 -4
- package/server/lib/notifications/pi-notification-watcher.js +95 -33
- package/server/lib/notifications/pi-notification-watcher.test.js +89 -0
- package/server/lib/open-url/DOCUMENTATION.md +2 -1
- package/server/lib/pi/extension-protocol.js +54 -0
- package/server/lib/pi/fixtures/pichamber-gui-demo.ts +12 -13
- package/server/lib/pi/merged-event-stream.js +316 -0
- package/server/lib/pi/merged-event-stream.test.js +95 -0
- package/server/lib/pi/routes-daemon-pool.test.js +348 -0
- package/server/lib/pi/routes-extension-events.test.js +115 -0
- package/server/lib/pi/routes-merged-events.test.js +327 -0
- package/server/lib/pi/routes-sandbox.test.js +1684 -0
- package/server/lib/pi/routes.js +790 -87
- package/server/lib/pi/routes.test.js +381 -1
- package/server/lib/pi/sandbox/DOCUMENTATION.md +68 -0
- package/server/lib/pi/sandbox/launcher.js +122 -0
- package/server/lib/pi/sandbox/launcher.test.js +91 -0
- package/server/lib/pi/sandbox/nono-launcher.js +455 -0
- package/server/lib/pi/sandbox/nono-launcher.test.js +371 -0
- package/server/lib/pi/sandbox/nono-profile-macos.json +20 -0
- package/server/lib/pi/sandbox/nono-profile-wsl2.json +21 -0
- package/server/lib/pi/sandbox/nono-profile.json +22 -0
- package/server/lib/pi/sandbox/project-sandbox-manager.js +1461 -0
- package/server/lib/pi/sandbox/project-sandbox-setting.js +166 -0
- package/server/lib/pi/sandbox/project-sandbox.js +207 -0
- package/server/lib/pi/sandbox/sandbox-routes.js +110 -0
- package/server/lib/pi/sandbox/sandboxed-folders.js +100 -0
- package/server/lib/pi/sandbox/sandboxed-folders.test.js +65 -0
- package/server/lib/pi/sandbox/trust-ask.js +135 -0
- package/server/lib/pi/sandbox/trust-ask.test.js +54 -0
- package/server/lib/pi/sandbox/worktree-ids.js +96 -0
- package/server/lib/pi/sandbox/worktree-ids.test.js +73 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +47 -10
- package/server/lib/pi/session-daemon/daemon-pool.js +157 -0
- package/server/lib/pi/session-daemon/daemon-process.js +10 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +89 -29
- package/server/lib/pi/session-daemon/extension-config.js +902 -0
- package/server/lib/pi/session-daemon/extension-config.test.js +798 -0
- package/server/lib/pi/session-daemon/extension-controls.js +177 -0
- package/server/lib/pi/session-daemon/extension-controls.test.js +181 -0
- package/server/lib/pi/session-daemon/extension-name.js +6 -0
- package/server/lib/pi/session-daemon/extension-name.test.js +5 -0
- package/server/lib/pi/session-daemon/extension-palette.js +146 -0
- package/server/lib/pi/session-daemon/extension-palette.test.js +107 -0
- package/server/lib/pi/session-daemon/extension-replacements.js +138 -0
- package/server/lib/pi/session-daemon/extension-replacements.test.js +116 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.js +30 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.test.js +34 -0
- package/server/lib/pi/session-daemon/pichamber-ui.js +44 -0
- package/server/lib/pi/session-daemon/plugin-host.js +245 -0
- package/server/lib/pi/session-daemon/plugin-host.test.js +192 -0
- package/server/lib/pi/session-daemon/session-daemon-controls.e2e.test.js +205 -0
- package/server/lib/pi/session-daemon/session-daemon-drafts.e2e.test.js +409 -0
- package/server/lib/pi/session-daemon/session-daemon-extension-config.e2e.test.js +196 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +137 -6
- package/server/lib/pi/session-daemon/session-daemon-plugins.e2e.test.js +272 -0
- package/server/lib/pi/session-daemon/session-daemon-providers.e2e.test.js +153 -0
- package/server/lib/pi/session-daemon/session-daemon-read-persisted.test.js +167 -0
- package/server/lib/pi/session-daemon/session-daemon.js +927 -108
- package/server/lib/pi/session-daemon/session-daemon.test.js +391 -4
- package/server/lib/pi/session-daemon/session-engine-router.js +7 -0
- package/server/lib/pi/session-daemon/session-engine-router.test.js +20 -0
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +98 -1
- package/server/lib/pi/session-daemon/session-jsonl.js +49 -10
- package/server/lib/pi/session-daemon/session-jsonl.test.js +11 -0
- package/server/lib/pi/session-daemon/session-lease.js +93 -15
- package/server/lib/pi/session-daemon/session-lease.test.js +107 -1
- package/server/lib/pi/session-daemon/supervisor-launcher-stop.test.js +295 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox-nono.e2e.test.js +301 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox.test.js +444 -0
- package/server/lib/pi/session-daemon/supervisor.js +408 -38
- package/server/lib/pi/session-daemon/supervisor.test.js +28 -0
- package/server/lib/pi/settings-store.js +14 -0
- package/server/lib/pi/settings-store.test.js +11 -0
- package/server/lib/pi/ui-settings-store.js +88 -2
- package/server/lib/pi/ui-settings-store.test.js +118 -0
- package/server/lib/plugins/DOCUMENTATION.md +198 -0
- package/server/lib/plugins/daemon-sync.js +88 -0
- package/server/lib/plugins/daemon-sync.supervisor.test.js +83 -0
- package/server/lib/plugins/daemon-sync.test.js +108 -0
- package/server/lib/plugins/impact.js +139 -0
- package/server/lib/plugins/impact.test.js +83 -0
- package/server/lib/plugins/manifest.js +220 -0
- package/server/lib/plugins/manifest.test.js +127 -0
- package/server/lib/plugins/registry.js +59 -0
- package/server/lib/plugins/routes.js +92 -0
- package/server/lib/plugins/routes.test.js +247 -0
- package/server/lib/plugins/service.js +183 -0
- package/server/lib/plugins/store.js +261 -0
- package/server/lib/plugins/store.test.js +188 -0
- package/server/lib/plugins/visuals-extension.test.js +237 -0
- package/server/lib/server/cross-process-lock.js +28 -3
- package/server/lib/server-browser/DOCUMENTATION.md +32 -7
- package/server/lib/server-browser/browser-tab.js +4 -1
- package/server/lib/server-browser/downloads.js +261 -34
- package/server/lib/server-browser/downloads.test.js +171 -0
- package/server/lib/server-browser/runtime.integration.test.js +47 -0
- package/server/lib/server-browser/runtime.js +16 -0
- package/server/lib/server-browser/server-browser.js +25 -6
- package/server/lib/tunnels/executable-search.js +5 -1
- package/server/lib/tunnels/executable-search.test.js +26 -0
- package/dist/assets/DiagramView-BB-aZobi.js +0 -1
- package/dist/assets/FileSaveConflictDialog-Bzz8FNMq.js +0 -3
- package/dist/assets/FilesView-DECxN8Z0.js +0 -6
- package/dist/assets/GitHubDetailScaffold-CWsWycRd.js +0 -11
- package/dist/assets/GitHubLinkPicker-BVYdg_e8.js +0 -1
- package/dist/assets/GitHubListPrimitives-Dlv3tC4d.js +0 -1
- package/dist/assets/PatchDiff-BklyOEHs.js +0 -1
- package/dist/assets/PierreDiffViewer-wc6cB6qw.js +0 -147
- package/dist/assets/PullRequestsSurface-BZvJkT1I.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-DShvvGwC.js +0 -2
- package/dist/assets/SessionUnreadDot-CbqRq6h_.js +0 -1
- package/dist/assets/SettingsView-DcF-At5E.js +0 -6
- package/dist/assets/ToolOutputDialog-DdMIfrnK.js +0 -8
- package/dist/assets/ToolPartDiffPreview-C6Sm4eVf.js +0 -1
- package/dist/assets/contextFileOpenGuard-UU86YHgI.js +0 -1
- package/dist/assets/gitStatusPredicates-DQEO4Psc.js +0 -1
- package/dist/assets/githubLink-ByPAyFjh.js +0 -10
- package/dist/assets/index-BaLCg7tL.css +0 -1
- package/dist/assets/index-I2QYqABE.js +0 -11
- package/dist/assets/main-DyFfbllq.js +0 -137
- package/dist/assets/pi-session-focus-preference-Dx0UXPoO.js +0 -9
- package/dist/assets/renderElectronMiniChatApp-Cb7s7dWl.js +0 -2
- package/dist/assets/renderMobileApp-Bp74b_Lo.js +0 -11
- package/dist/assets/runtimeEndpointReset-7nWYnKd4.js +0 -62
- package/dist/assets/runtimeSurface-CFwnvks_.js +0 -1
- package/dist/assets/useAppFontEffects-ZTyNwFk6.js +0 -213
- package/dist/assets/useGitHubRemoteSearch-BF3ohpsh.js +0 -1
- package/dist/assets/useSwitcherItems-BJzwyDGX.js +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-
|
|
2
|
-
import{_ as vt}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,cc as Ma,bl as $a,aP as Pa}from"./vendor-boot-3SaHYVb1.js";import{R as a,a as is}from"./vendor-react-Bz1tRBxM.js";import{a$ as Be,aR as we,aS as Ne,b0 as Le,B as H,I as S,au as wt,aT as Ce,b1 as Ie,d4 as $s,d5 as Ps,d6 as Bs,d7 as Ls,d8 as He,d9 as Ee,d$ as Es,as as Nt,bv as fe,bT as rt,z as qe,bm as Ct,e0 as St,bj as kt,t as P,b6 as Rt,b2 as hs,e1 as Ba,e2 as La,A as Ia,h as zs,c6 as lt,av as Fe,aw as De,aB as Me,ax as $e,ay as Pe,dI as Et,cw as Ta,aP as Aa,cb as Oa,cc as Ga,cd as _a,cf as Ha,cg as qa,at as Va,aC as We,ah as Ua,cT as zt,dG as Ft,e3 as Wa,d0 as Ka,cZ as Dt,dd as Ya,y as Qa,bF as Xa,cU as Za,e4 as Ja,e5 as en,e6 as sn,e7 as tn,e8 as an,az as nn}from"./useAppFontEffects-ZTyNwFk6.js";import{aQ as rn,aR as Is,aS as Mt,aT as ln,aU as $t,aV as on,h as Fs,aW as cn}from"./runtimeEndpointReset-7nWYnKd4.js";import{f as se,h as Ts,cI as dn,n as os}from"./index-I2QYqABE.js";import{C as un,d as hn,i as it,a as mn}from"./gitStatusPredicates-DQEO4Psc.js";import{v as fn,G as pn,a as gn,b as xn}from"./GitHubDetailScaffold-CWsWycRd.js";import{C as bn,a as yn,b as jn}from"./collapsible-D6qdoq7-.js";import{P as Pt}from"./PierreDiffViewer-wc6cB6qw.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./runtimeSurface-CFwnvks_.js";import"./nativeFileSave-Cp9i5QGd.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-CbqRq6h_.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";import"./vendor-base-ui-BCqPBzDj.js";import"./web-components-CGDpzixf.js";import"./computeVirtualFileMetrics-G4csGiKs.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-BrbPymTL.js";import"./renderDiffWithHighlighter-PL82AR81.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-DNsbTLS7.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";const vn=t=>t.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Bt=({currentBranch:t,localBranches:r,remoteBranches:c,branchInfo:p,onCheckout:m,onCreate:o,remotes:n=[],disabled:s=!1})=>{const[h,g]=a.useState(!1),[d,j]=a.useState(""),[b,f]=a.useState(!1),[u,w]=a.useState(!1),[z,R]=a.useState(""),[M,_]=a.useState(!1),U=a.useRef(null),I=a.useCallback(D=>{D.stopPropagation()},[]),L=n.length>1,B=a.useMemo(()=>vn(z),[z]),F=a.useMemo(()=>{const D=d.toLowerCase();return D?r.filter(ae=>ae.toLowerCase().includes(D)):r},[d,r]),T=a.useMemo(()=>{const D=d.toLowerCase();return D?c.filter(ae=>ae.toLowerCase().includes(D)):c},[d,c]),x=D=>{if(D===t){g(!1);return}m(D),g(!1),j("")},q=()=>{f(!0),setTimeout(()=>U.current?.focus(),50)},W=async()=>{if(!(!B||M)){if(L){w(!0);return}_(!0);try{await o(B,n[0]),R(""),f(!1),g(!1)}finally{_(!1)}}},J=async D=>{if(!(!B||M)){_(!0);try{await o(B,D),R(""),f(!1),w(!1),g(!1)}finally{_(!1)}}},Y=()=>{w(!1)},A=()=>{R(""),f(!1),w(!1)};return a.useEffect(()=>{h||(j(""),f(!1),w(!1),R(""))},[h]),e.jsxs(Be,{open:h,onOpenChange:g,children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Le,{asChild:!0,children:e.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:s,children:[e.jsx(S,{name:"git-branch",className:"size-4 text-primary"}),e.jsx(wt,{value:t||"Detached HEAD",className:"min-w-0 font-medium text-left"}),e.jsx(S,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),e.jsx(Ce,{sideOffset:8,children:"Current branch"})]}),e.jsx(Ie,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:e.jsxs($s,{className:"h-full min-h-0",children:[e.jsx(Ps,{placeholder:"Search branches...",value:d,onValueChange:j,onKeyDown:I}),e.jsxs(Bs,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[e.jsx(Ls,{children:"No branches found."}),e.jsx(He,{children:u?e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{type:"button",onClick:Y,disabled:M,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(S,{name:"arrow-left",className:"size-4"})}),e.jsxs("span",{className:"typography-meta text-muted-foreground",children:["Push"," ",e.jsx("span",{className:"text-foreground font-medium",children:B})," ","to"]})]}),e.jsx("div",{className:"flex flex-col gap-1",children:n.map(D=>e.jsxs("button",{type:"button",onClick:()=>J(D),disabled:M,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[e.jsxs("span",{className:"typography-ui-label text-foreground",children:[M?e.jsx(S,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,D.name]}),e.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:D.pushUrl})]},D.name))})]}):b?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[e.jsx("input",{ref:U,placeholder:"New branch name",value:z,onChange:D=>R(D.target.value),onClick:D=>D.stopPropagation(),onKeyDown:D=>{I(D),D.key==="Enter"?(D.preventDefault(),W()):D.key==="Escape"&&(D.preventDefault(),A())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),e.jsx("button",{type:"button",onClick:W,disabled:!B||M,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:M?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"add",className:"size-4"})}),e.jsx("button",{type:"button",onClick:A,disabled:M,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(S,{name:"close",className:"size-4"})})]}):e.jsxs(Ee,{onSelect:q,children:[e.jsx(S,{name:"add",className:"size-4"}),e.jsx("span",{children:"Create new branch..."})]})}),e.jsx(Es,{}),e.jsxs(He,{heading:"Local branches",children:[F.map(D=>e.jsxs(Ee,{onSelect:()=>x(D),children:[e.jsxs("span",{className:"flex flex-1 flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:D}),(p?.[D]?.ahead||p?.[D]?.behind)&&e.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p[D].ahead||0," ahead ·"," ",p[D].behind||0," behind"]})]}),t===D&&e.jsx("span",{className:"typography-micro text-primary",children:"Current"})]},`local-${D}`)),F.length===0&&e.jsx(Ee,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No local branches"})})]}),e.jsx(Es,{}),e.jsxs(He,{heading:"Remote branches",children:[T.map(D=>e.jsx(Ee,{onSelect:()=>x(D),children:e.jsx("span",{className:"typography-ui-label text-foreground",children:D})},`remote-${D}`)),T.length===0&&e.jsx(Ee,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No remote branches"})})]})]})]})})]})},wn=t=>t.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Lt=({currentBranch:t,onRename:r,showEditButton:c=!0})=>{const[p,m]=a.useState(!1),[o,n]=a.useState(t||""),[s,h]=a.useState(!1),g=a.useRef(null),d=()=>{!t||!r||(n(t),m(!0),setTimeout(()=>g.current?.focus(),0))},j=async()=>{if(!t||!r||!o.trim())return;const u=wn(o);if(u===t){m(!1);return}h(!0);try{await r(t,u),m(!1),n("")}finally{h(!1)}},b=()=>{m(!1),n("")},f=u=>{u.key==="Enter"?(u.preventDefault(),j()):u.key==="Escape"&&(u.preventDefault(),b())};return p?e.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:e.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:u=>{u.preventDefault(),j()},children:[e.jsx(S,{name:"git-branch",className:"size-4 text-primary"}),e.jsx("input",{ref:g,value:o,onChange:u=>n(u.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:"Branch name",onKeyDown:f,autoFocus:!0}),e.jsx("button",{type:"submit",disabled:s,"aria-label":s?"Saving branch name":"Save branch name",title:s?"Saving branch name":"Save branch name",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:s?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"check",className:"size-4"})}),e.jsx("button",{type:"button",onClick:b,disabled:s,"aria-label":"Cancel branch rename",title:"Cancel branch rename",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(S,{name:"close",className:"size-4"})})]})}):e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[e.jsx(S,{name:"git-branch",className:"size-4 text-primary shrink-0"}),e.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[e.jsx(wt,{value:t||"Detached HEAD",className:"min-w-0 typography-ui-label font-normal text-foreground"}),c&&r&&t&&e.jsx(H,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:d,title:"Rename branch",children:e.jsx(S,{name:"edit",className:"size-4"})})]})]})},It=({syncAction:t,remotes:r=[],onFetch:c,onSync:p,disabled:m,showFetchMenu:o=!0,aheadCount:n=0,behindCount:s=0,trackingRemoteName:h,hasUncommittedChanges:g=!1,iconOnly:d=!1,upstreamTarget:j=null})=>{const{isMobile:b,isTablet:f}=Nt(),u=b||f,w=r.find(x=>x.name===h)??r[0],z=s>0&&g,R=m||t!==null||!w||z,M=m||t!==null||r.length===0,_=n>0||s>0,U=["sync",s>0?`↓${s}`:null,n>0?`↑${n}`:null].filter(Boolean).join(" "),I=z?"Commit or stash your changes before syncing":w?[_?`Sync Changes (${s} down, ${n} up)`:"Sync changes",j?`Compared with ${j}`:null].filter(Boolean).join(". "):"No remotes configured",L=()=>{w&&p(w)},B=u?"h-9":"h-8",F=[s>0?`↓${s}`:null,n>0?`↑${n}`:null].filter(Boolean).join(" "),T=d?F:U;return e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"inline-flex",tabIndex:z?0:void 0,children:e.jsxs(H,{type:"button",variant:"ghost",size:"sm",onClick:L,disabled:R,className:se(B,"flex-shrink-0 gap-1.5 tabular-nums",T?"px-2":u?"w-9 p-0":"w-8 p-0"),"aria-label":"Sync changes",children:[t==="sync"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"refresh",className:"size-4"}),T?e.jsx("span",{className:"whitespace-nowrap",children:T}):null]})})}),e.jsx(Ce,{sideOffset:8,children:I})]}),o?e.jsxs(Be,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(H,{type:"button",variant:"ghost",size:"sm",className:se(B,u?"w-9":"w-8","flex-shrink-0 p-0"),disabled:M,"aria-label":"More sync actions",children:e.jsx(S,{name:"more",className:"size-4"})})}),e.jsx(Ie,{align:"end",className:"w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",children:r.map(x=>e.jsx(Tt,{remote:x,onFetch:c},x.name))})]}):null]})},Tt=({remote:t,onFetch:r,disabled:c=!1})=>e.jsx(fe,{disabled:c,onSelect:()=>r(t),children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsx(S,{name:"refresh",className:"size-4 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:`Fetch from ${t.name}`}),e.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:t.fetchUrl})]})]})}),Nn=420,Cn=({status:t,localBranches:r,remoteBranches:c,branchInfo:p,syncAction:m,remotes:o,onFetch:n,onSync:s,onCheckoutBranch:h,onCreateBranch:g,onRenameBranch:d,isWorktreeMode:j,upstreamTarget:b,onOpenHistory:f,onOpenGraph:u,onOpenStashes:w,onOpenUpdateBranch:z,onOpenReintegrateCommits:R,diffScope:M,onDiffScopeChange:_,allCount:U,workingCount:I,stagedCount:L,branchAvailable:B,diffHeaderState:F})=>{const T=f||u||w||z||R,x=(F?.totalCount??0)>0,q=M!=="turn"&&M!=="branch",W=o.length>0,J=!t||m!==null,Y=a.useRef(null),[A,D]=a.useState(!1);a.useLayoutEffect(()=>{const ee=Y.current;if(!ee||typeof ResizeObserver>"u")return;const O=()=>D(ee.clientWidth<Nn);O();const N=new ResizeObserver(O);return N.observe(ee),()=>N.disconnect()},[]);const ae=o.find(ee=>ee.name===t.tracking?.split("/")[0])??o[0],ne=(t.ahead??0)>0||(t.behind??0)>0,re=A&&!ne,le=re&&!!ae||W||T||F!==null;return e.jsxs("div",{ref:Y,className:"flex min-w-0 flex-1 items-center gap-1",children:[e.jsx("div",{className:"min-w-0 flex-shrink",children:j?e.jsx(Lt,{currentBranch:t.current,onRename:d}):e.jsx(Bt,{currentBranch:t.current,localBranches:r,remoteBranches:c,branchInfo:p,onCheckout:h,onCreate:g,remotes:o})}),e.jsx("div",{className:"min-w-0 shrink-0",children:e.jsx(un,{scope:M,isGitRepo:!0,branchAvailable:B,allCount:U,workingCount:I,stagedCount:L,turnCount:F?.turnCount??0,branchCount:F?.branchCount??0,focusedFilePath:F?.focusedFilePath??null,onScopeChange:_})}),e.jsx("div",{className:"min-w-0 flex-1"}),e.jsx("div",{className:re?"hidden":"shrink-0",children:e.jsx(It,{syncAction:m,remotes:o,onFetch:n,onSync:s,disabled:!t,showFetchMenu:!1,iconOnly:!0,aheadCount:t.ahead,behindCount:t.behind,trackingRemoteName:t.tracking?.split("/")[0],hasUncommittedChanges:(t.files?.length??0)>0,upstreamTarget:b})}),le?e.jsx("div",{className:"shrink-0",children:e.jsxs(Be,{children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Le,{asChild:!0,children:e.jsx(H,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":"Repository views",children:e.jsx(S,{name:"more-fill",className:"size-4"})})})}),e.jsx(Ce,{sideOffset:8,children:"Repository views"})]}),e.jsxs(Ie,{align:"end",className:"max-w-[min(360px,calc(100vw-2rem))]",children:[re&&ae?e.jsxs(fe,{disabled:J,onSelect:()=>s(ae),children:[e.jsx(S,{name:"refresh",className:"size-4"}),"Sync changes"]}):null,o.map(ee=>e.jsx(Tt,{remote:ee,onFetch:n,disabled:J},ee.name)),W&&(T||F!==null)?e.jsx(rt,{}):null,f?e.jsxs(fe,{onSelect:f,children:[e.jsx(S,{name:"history",className:"size-4"}),"History"]}):null,u?e.jsxs(fe,{onSelect:u,children:[e.jsx(S,{name:"git-branch",className:"size-4"}),"Graph"]}):null,w?e.jsxs(fe,{onSelect:w,children:[e.jsx(S,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null,z?e.jsxs(fe,{onSelect:z,children:[e.jsx(S,{name:"git-merge",className:"size-4"}),"Update branch"]}):null,R?e.jsxs(fe,{onSelect:R,children:[e.jsx(S,{name:"split-cells-horizontal",className:"size-4"}),"Re-integrate commits"]}):null,T&&F!==null?e.jsx(rt,{}):null,F!==null?e.jsxs(fe,{disabled:!x,onSelect:F.onExpandOrCollapseAll,children:[e.jsx(S,{name:"expand-up-down",className:"size-4"}),F.expandedCount>0?"Collapse all":"Expand all"]}):null,F!==null?e.jsxs(fe,{disabled:!x||!q,onSelect:F.onToggleLoadFullFiles,children:[e.jsx(S,{name:"file-download",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Load full files"}),F.loadFullFiles?e.jsx(S,{name:"check",className:"size-4"}):null]}):null,F!==null?e.jsxs(fe,{disabled:!x,onSelect:F.onToggleWrapLines,children:[e.jsx(S,{name:"text-wrap",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Wrap lines"}),F.wrapLines?e.jsx(S,{name:"check",className:"size-4"}):null]}):null,F!==null?e.jsxs(fe,{disabled:F.layoutMode===null,onSelect:F.onToggleLayout,children:[e.jsx(S,{name:F.layoutMode==="side-by-side"?"layout-column":"align-justify",className:"size-4"}),F.layoutMode==="side-by-side"?"Switch to unified view":"Switch to side-by-side view"]}):null]})]})}):null]})},Sn=t=>t.isFork&&t.upstreamDefaultBranch?.trim()?t.upstreamDefaultBranch.trim():t.defaultBranch?.trim()?t.defaultBranch.trim():"main",Ds=(t,r)=>`${t}
|
|
3
|
-
${r}`,kn=t=>{const r=t.headBranch.trim();if(t.allBranches==null)return[];const c=new Set,p=[];for(const o of t.allBranches){if(!o.startsWith("remotes/"))continue;const n=o.slice(8),s=n.indexOf("/");if(s<=0)continue;const h=n.slice(s+1).trim();!h||h===r||c.has(h)||(c.add(h),p.push(h))}if(p.sort((o,n)=>o.localeCompare(n)),p.length===0)return[];const m=t.defaultBranch?.trim()??"";return m&&m!==r?[m,...p.filter(o=>o!==m)]:p},Rn=[{id:"ready",label:"Create pull request",description:"Open the pull request for review"},{id:"draft",label:"Create draft pull request",description:"Mark the pull request as not ready for review"}],En=t=>t==="draft"?"Create draft pull request":"Create pull request",As=new Map,ot=t=>As.get(t)??null,zn=(t,r)=>{As.set(t,r)},Ms=t=>{As.delete(t)},Fn=320,Dn=({directory:t,headBranch:r,defaultBranch:c,isFork:p,upstreamDefaultBranch:m,hasUpstream:o,onCollapse:n,onCreated:s})=>{const h=qe(),g=Ct(t),d=Sn({isFork:p,upstreamDefaultBranch:m,defaultBranch:c}),j=Ds(t,r),b=ot(j),[f,u]=a.useState(b?.base??d),[w,z]=a.useState(b?.title??""),[R,M]=a.useState(b?.body??""),[_,U]=a.useState(b?.mode??"ready"),[I,L]=a.useState("write"),[B,F]=a.useState(!1),[T,x]=a.useState(!1),[q,W]=a.useState(!1),[J,Y]=a.useState(""),[A,D]=a.useState({}),[ae,ne]=a.useState(null),re=a.useRef(!1),le=a.useRef(null);a.useEffect(()=>{re.current||u(d)},[d]),a.useEffect(()=>{if(!w.trim()&&!R.trim()&&_==="ready"&&f===d){ot(j)&&Ms(j);return}zn(j,{title:w,body:R,base:f===d?null:f,mode:_})},[j,w,R,f,_,d]);const ee=St(t),O=h.git;a.useEffect(()=>{ee!==null||!O||kt.getState().fetchBranches(t,O).catch(()=>{})},[ee,t,O]);const N=a.useMemo(()=>kn({allBranches:ee?.all,headBranch:r,defaultBranch:d}),[ee,r,d]);a.useLayoutEffect(()=>{const k=le.current;k&&(k.style.height="0px",k.style.height=`${Math.min(k.scrollHeight,Fn)}px`)},[R,I]);const E=a.useCallback(k=>{re.current=!0,u(k),W(!1),Y(""),D(Q=>Q.base?{...Q,base:void 0}:Q)},[]),i=a.useCallback(async()=>{if(B||T)return;if(!g){ne("Select a repository first");return}const k=fn({title:w,head:r,base:f});if(D(k.errors),!k.ok)return;const Q=h.github;if(!Q){ne("GitHub is not available in this runtime");return}ne(null),F(!0);try{if(!o){x(!0);try{await h.git.gitPush(t)}catch(K){ne(K instanceof Error?K.message:"Push failed. Create the pull request after pushing.");return}finally{x(!1)}}const V=await rn.getState().createPullRequest({directory:t,repo:g,title:w.trim(),head:r,base:f,body:R.trim()||void 0,draft:_==="draft"},Q);if(!V.ok||V.number==null){ne(V.error?.kind==="failed"?V.error.message:"Failed to create pull request");return}P.success(`Pull request #${V.number} created`),Ms(j),await Is.getState().refresh(t,r,Q,{force:!0}).catch(()=>{}),Mt(t,g,V.number),s?.(V.number)}finally{F(!1)}},[B,T,g,w,R,r,f,_,o,h,t,j,s]),$=a.useCallback(k=>{k.nativeEvent.isComposing||k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&!k.shiftKey&&!k.altKey&&!k.repeat&&(k.preventDefault(),k.stopPropagation(),i())},[i]);return e.jsxs("section",{"aria-label":"Create pull request",className:"flex min-w-0 flex-col gap-2 py-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(S,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("h3",{className:"typography-ui-label text-foreground",children:"New pull request"}),e.jsx("span",{className:"flex-1"}),e.jsx(H,{type:"button",variant:"ghost",size:"icon",onClick:n,"aria-label":"Cancel",title:"Cancel",className:"size-6 shrink-0",children:e.jsx(S,{name:"close",className:"size-4"})})]}),e.jsxs("p",{className:"flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"shrink-0",children:"into"}),N.length>0?e.jsxs(Be,{open:q,onOpenChange:k=>{W(k),k||Y("")},modal:!1,children:[e.jsx(Le,{asChild:!0,children:e.jsxs("button",{type:"button","aria-label":"Base branch",className:se(Rt({size:"default"}),"min-w-28 max-w-56"),children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:f||"Select base"}),e.jsx(S,{name:"arrow-down-s",className:"size-3.5 shrink-0 opacity-60"})]})}),e.jsx(Ie,{align:"start",sideOffset:6,className:"max-h-[min(var(--available-height),24rem)] w-72 max-w-[min(18rem,var(--available-width))] overflow-hidden p-0",children:e.jsxs($s,{className:"h-full min-h-0",children:[e.jsx(Ps,{placeholder:"Search branches...",value:J,onValueChange:Y,onKeyDown:k=>k.stopPropagation()}),e.jsxs(Bs,{disableHorizontal:!0,children:[e.jsx(Ls,{children:"No branches found."}),e.jsx(He,{heading:"Branches",children:N.map(k=>e.jsxs(Ee,{value:k,onSelect:()=>E(k),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono typography-ui-label text-foreground",children:k}),k===d?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:"default"}):null]},k))})]})]})})]}):e.jsx(hs,{value:f,onChange:k=>{re.current=!0,u(k.target.value)},"aria-label":"Base branch",className:"h-8 w-40"}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",title:"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono",title:r,children:r})]}),A.base?e.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:A.base}):null,o?null:e.jsxs("p",{className:"flex items-start gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(S,{name:"information",className:"size-3.5 shrink-0 text-[var(--status-info)]","aria-hidden":"true"}),e.jsx("span",{children:"This branch isn't on the remote yet. It will be pushed first."})]}),e.jsx(hs,{value:w,onChange:k=>z(k.target.value),placeholder:"Title","aria-label":"Pull request title",onKeyDown:$,className:"h-8"}),A.title?e.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:A.title}):null,e.jsx("div",{role:"tablist","aria-label":"Description format",className:"flex items-center gap-4",children:["write","preview"].map(k=>{const Q=I===k;return e.jsxs("button",{type:"button",role:"tab","aria-selected":Q,onClick:()=>L(k),className:se("relative flex h-7 shrink-0 items-center text-xs leading-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Q?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:[k==="write"?"Write":"Preview",Q?e.jsx("span",{"aria-hidden":"true",className:"absolute inset-x-0 bottom-0 h-0.5 bg-interactive-selection"}):null]},k)})}),I==="write"?e.jsx("textarea",{ref:le,value:R,onChange:k=>M(k.target.value),rows:4,placeholder:"Add a description (markdown supported)","aria-label":"Pull request description",onKeyDown:$,className:"min-h-20 w-full resize-none overflow-y-auto rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground placeholder:text-muted-foreground"}):e.jsx("div",{className:"min-h-20 w-full min-w-0",children:R.trim()?e.jsx(pn,{markdown:R}):e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Nothing to preview"})}),ae?e.jsxs("div",{role:"alert",className:"flex items-start gap-1.5 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-2 py-1.5 text-foreground",children:[e.jsx(S,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 typography-micro",children:ae})]}):null,e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"flex-1"}),e.jsxs("span",{role:"group","aria-label":"Create pull request options",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(H,{type:"button",variant:"default",size:"sm",onClick:()=>{i()},disabled:B,children:T?"Pushing…":B?"Creating…":En(_)}),e.jsxs(Be,{modal:!1,children:[e.jsx(Le,{asChild:!0,children:e.jsx(H,{type:"button",variant:"default",size:"sm",className:"shrink-0 px-1.5",title:"Create options","aria-label":"Create options",disabled:B,children:e.jsx(S,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ie,{align:"end",className:"w-72",children:e.jsx(Ba,{value:_,onValueChange:k=>U(k),children:Rn.map(k=>e.jsx(La,{value:k.id,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:k.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:k.description})]})},k.id))})})]})]})]})]})},Mn=({directory:t,branch:r,repo:c})=>{const p=a.useMemo(()=>$t(t,r),[t,r]),m=Is(g=>p?g.results[p]??null:null),o=on(p),n=m?.pr;if(!n)return null;const s=o?o.visualState==="merged"?`Pull request #${o.number}, merged`:o.visualState==="draft"?`Draft pull request #${o.number}`:o.visualState==="blocked"?`Pull request #${o.number}, checks failing`:o.visualState==="closed"?`Pull request #${o.number}, closed`:`Pull request #${o.number}, open`:`Pull request #${n.number}, open`,h=()=>Mt(t,c,n.number);return e.jsxs("div",{className:"relative flex min-w-0 items-center gap-2 rounded-md px-2 py-1",children:[e.jsx("button",{type:"button",onClick:h,"aria-label":`Open ${s} in Pull requests`,title:s,className:"absolute inset-0 rounded-md hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50"}),e.jsxs("span",{className:"pointer-events-none flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx(gn,{kind:"pr",state:n.state,draft:n.draft}),e.jsxs("span",{className:"shrink-0 font-mono typography-micro tabular-nums text-muted-foreground",children:["#",n.number]}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.title||`Pull request #${n.number}`,children:n.title||`Pull request #${n.number}`}),e.jsx(xn,{state:m?.checks?.state??null})]}),e.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:h,className:"relative shrink-0",children:"Open"})]})},$n=({headBranch:t,onExpand:r})=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2 py-1",children:[e.jsx(S,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"flex min-w-0 flex-1 items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"shrink-0",children:"No pull request for"}),e.jsx("code",{className:"min-w-0 max-w-44 truncate rounded bg-[var(--surface-muted)] px-1 py-px font-mono text-foreground",title:t,children:t})]}),e.jsx(H,{type:"button",variant:"default",size:"xs",onClick:r,className:"shrink-0",children:"Create pull request"})]}),Pn=({directory:t,branch:r,hasUpstream:c})=>{const p=qe(),m=Ct(t||null),o=Ia(j=>t?j.entriesByDirectory[t]?.scope??null:null);ln(t,r,p.github??null);const n=a.useMemo(()=>$t(t,r),[t,r]),s=Is(j=>n?j.results[n]??null:null),[h,g]=a.useState(!1);a.useEffect(()=>{g(!1)},[t,r]);const d=a.useMemo(()=>!o||!m?null:o.repositories.find(j=>j.host&&j.owner&&j.repo&&`${j.host}/${j.owner}/${j.repo}`===m)??null,[o,m]);return!t||!r||!m||s?.skippedDefaultBranch?null:s?.pr?e.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-1 py-1.5",children:e.jsx(Mn,{directory:t,branch:r,repo:m})}):!s||!s.fetchedAt?null:e.jsx("div",{className:"shrink-0 border-b border-border px-3 py-1.5",children:h?e.jsx(Dn,{directory:t,headBranch:r,defaultBranch:s.defaultBranch??d?.defaultBranch??null,isFork:(d?.fork??!1)===!0,upstreamDefaultBranch:null,hasUpstream:c,onCollapse:()=>g(!1),onCreated:()=>{Ms(Ds(t,r)),g(!1)}},Ds(t,r)):e.jsx($n,{headBranch:r,onExpand:()=>g(!0)})})},Bn=({open:t,onOpenChange:r,conflictFiles:c=[],directory:p,operation:m,onAbort:o,onClearState:n})=>{const{git:s}=qe(),h=zs(x=>x.openNewSessionDraft),g=zs(x=>x.currentSessionId),d=lt(x=>x.setPendingInputText),j=lt(x=>x.setPendingSyntheticParts),b=Ts(x=>x.setActiveMainTab),[f,u]=a.useState(!1),[w,z]=a.useState(null),[R,M]=a.useState(null);a.useEffect(()=>{!t||!p||(u(!0),M(null),z(null),s.getConflictDetails(p).then(x=>{z(x)}).catch(x=>{const q=x instanceof Error?x.message:"Failed to load conflict details";M(q)}).finally(()=>{u(!1)}))},[p,s,t]);const _=a.useCallback(async()=>{if(!w)return null;const x=m==="merge"?"merge":"rebase",q=w.headInfo||(m==="merge"?"MERGE_HEAD":"REBASE_HEAD"),W=m==="merge"?"git commit --no-edit":"git rebase --continue",J=`Investigate the ${x} conflicts and concisely report the intended resolution strategy without making modifications. Wait for confirmation before resolving, staging, or continuing the ${x}. Preserve the intent of changes from ${q}.`,Y=`Git ${x} operation is in progress with conflicts.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-CiZy4jFA.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/index-CKKWVoND.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-B_L9GVYw.css","assets/useAppFontEffects-CV5UyTRw.js","assets/runtimeSurface-0K7vuUpd.js","assets/nativeFileSave-DSMsJqXM.js","assets/gitStatusPredicates-BsXrwngT.js","assets/VirtualizedFileDiff-BGZiLPe_.js","assets/web-components-BpncHjnV.js","assets/computeVirtualFileMetrics-DJQqK49u.js","assets/vendor-shiki-BEwTOAFg.js","assets/vendor-shikijs-core-Ck_OPM_T.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-DPFxvYtK.js","assets/vendor-hast-util-to-html-O3stl53j.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-C40bX6nM.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-DrfmQi8i.js","assets/vendor-pierre-theming-BO6EPniU.js","assets/vendor-shikijs-engine-javascript-DL394yyj.js","assets/vendor-oniguruma-to-es-DgwFOwdE.js","assets/vendor-oniguruma-parser-BrbMHgHx.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/renderDiffWithHighlighter-BXhnIAHg.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-UY7Cse-s.js","assets/StickyHorizontalScrollbar-CMbTn5WQ.js","assets/runtimeEndpointReset-Dwj-jCDS.js","assets/SessionUnreadDot-Dwc3MdvA.js","assets/permissionStore-zIpxq9Pq.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/appThemeRegistry-Ca8eGRB9.js","assets/registerCustomTheme-C-h6lsYW.js","assets/contextFileOpenGuard-ByWK3Sru.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as vt}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,b2 as Ma,bh as $a,b1 as Pa}from"./vendor-boot-D-KEJjsM.js";import{R as a,a as is}from"./vendor-react-Bz1tRBxM.js";import{D as Be,ap as we,aq as Ne,h as Le,B as H,I as S,cA as wt,ar as Ce,i as Ie,cB as $s,cC as Ps,cD as Bs,cE as Ls,cF as He,cG as Ee,cH as Es,ai as Nt,a0 as fe,aY as rt,j as qe,l as Ct,cI as St,ax as kt,t as P,cJ as Rt,f as hs,V as Ba,W as La,k as Ia,x as zs,N as lt,m as Fe,n as De,o as Me,p as $e,q as Pe,bl as Et,cK as Aa,aj as Ta,bv as Oa,bw as Ga,bx as _a,by as Ha,bz as qa,bi as Va,U as We,a2 as Ua,aW as zt,cq as Ft,cL as Wa,cM as Ka,cN as Dt,K as Ya,aZ as Qa,bO as Xa,bP as Za,cO as Ja,cP as en,cQ as sn,bQ as tn,cR as an,bS as nn}from"./useAppFontEffects-CV5UyTRw.js";import{i as rn,j as Is,o as Mt,ah as ln,ai as $t,aj as on,U as Fs,ak as cn}from"./runtimeEndpointReset-Dwj-jCDS.js";import{c as se,u as As,$ as dn,n as os}from"./index-CKKWVoND.js";import{C as un,d as hn,a as it,b as mn}from"./gitStatusPredicates-BsXrwngT.js";import{X as fn,q as pn,G as gn,O as xn}from"./GitHubDetailScaffold-DM2DH7o8.js";import{C as bn,a as yn,b as jn}from"./collapsible-Bro9KrfM.js";import{P as Pt}from"./PierreDiffViewer-UY7Cse-s.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./runtimeSurface-0K7vuUpd.js";import"./nativeFileSave-DSMsJqXM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-Dwc3MdvA.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";import"./vendor-base-ui-DE6jnTiC.js";import"./web-components-BpncHjnV.js";import"./computeVirtualFileMetrics-DJQqK49u.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-BGZiLPe_.js";import"./renderDiffWithHighlighter-BXhnIAHg.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";const vn=t=>t.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Bt=({currentBranch:t,localBranches:r,remoteBranches:c,branchInfo:p,onCheckout:m,onCreate:o,remotes:n=[],disabled:s=!1})=>{const[h,g]=a.useState(!1),[d,j]=a.useState(""),[b,f]=a.useState(!1),[u,w]=a.useState(!1),[z,R]=a.useState(""),[M,_]=a.useState(!1),U=a.useRef(null),I=a.useCallback(D=>{D.stopPropagation()},[]),L=n.length>1,B=a.useMemo(()=>vn(z),[z]),F=a.useMemo(()=>{const D=d.toLowerCase();return D?r.filter(ae=>ae.toLowerCase().includes(D)):r},[d,r]),A=a.useMemo(()=>{const D=d.toLowerCase();return D?c.filter(ae=>ae.toLowerCase().includes(D)):c},[d,c]),x=D=>{if(D===t){g(!1);return}m(D),g(!1),j("")},q=()=>{f(!0),setTimeout(()=>U.current?.focus(),50)},W=async()=>{if(!(!B||M)){if(L){w(!0);return}_(!0);try{await o(B,n[0]),R(""),f(!1),g(!1)}finally{_(!1)}}},J=async D=>{if(!(!B||M)){_(!0);try{await o(B,D),R(""),f(!1),w(!1),g(!1)}finally{_(!1)}}},Y=()=>{w(!1)},T=()=>{R(""),f(!1),w(!1)};return a.useEffect(()=>{h||(j(""),f(!1),w(!1),R(""))},[h]),e.jsxs(Be,{open:h,onOpenChange:g,children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Le,{asChild:!0,children:e.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:s,children:[e.jsx(S,{name:"git-branch",className:"size-4 text-primary"}),e.jsx(wt,{value:t||"Detached HEAD",className:"min-w-0 font-medium text-left"}),e.jsx(S,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),e.jsx(Ce,{sideOffset:8,children:"Current branch"})]}),e.jsx(Ie,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:e.jsxs($s,{className:"h-full min-h-0",children:[e.jsx(Ps,{placeholder:"Search branches...",value:d,onValueChange:j,onKeyDown:I}),e.jsxs(Bs,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[e.jsx(Ls,{children:"No branches found."}),e.jsx(He,{children:u?e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{type:"button",onClick:Y,disabled:M,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(S,{name:"arrow-left",className:"size-4"})}),e.jsxs("span",{className:"typography-meta text-muted-foreground",children:["Push"," ",e.jsx("span",{className:"text-foreground font-medium",children:B})," ","to"]})]}),e.jsx("div",{className:"flex flex-col gap-1",children:n.map(D=>e.jsxs("button",{type:"button",onClick:()=>J(D),disabled:M,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[e.jsxs("span",{className:"typography-ui-label text-foreground",children:[M?e.jsx(S,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,D.name]}),e.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:D.pushUrl})]},D.name))})]}):b?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[e.jsx("input",{ref:U,placeholder:"New branch name",value:z,onChange:D=>R(D.target.value),onClick:D=>D.stopPropagation(),onKeyDown:D=>{I(D),D.key==="Enter"?(D.preventDefault(),W()):D.key==="Escape"&&(D.preventDefault(),T())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),e.jsx("button",{type:"button",onClick:W,disabled:!B||M,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:M?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"add",className:"size-4"})}),e.jsx("button",{type:"button",onClick:T,disabled:M,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(S,{name:"close",className:"size-4"})})]}):e.jsxs(Ee,{onSelect:q,children:[e.jsx(S,{name:"add",className:"size-4"}),e.jsx("span",{children:"Create new branch..."})]})}),e.jsx(Es,{}),e.jsxs(He,{heading:"Local branches",children:[F.map(D=>e.jsxs(Ee,{onSelect:()=>x(D),children:[e.jsxs("span",{className:"flex flex-1 flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:D}),(p?.[D]?.ahead||p?.[D]?.behind)&&e.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p[D].ahead||0," ahead ·"," ",p[D].behind||0," behind"]})]}),t===D&&e.jsx("span",{className:"typography-micro text-primary",children:"Current"})]},`local-${D}`)),F.length===0&&e.jsx(Ee,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No local branches"})})]}),e.jsx(Es,{}),e.jsxs(He,{heading:"Remote branches",children:[A.map(D=>e.jsx(Ee,{onSelect:()=>x(D),children:e.jsx("span",{className:"typography-ui-label text-foreground",children:D})},`remote-${D}`)),A.length===0&&e.jsx(Ee,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No remote branches"})})]})]})]})})]})},wn=t=>t.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Lt=({currentBranch:t,onRename:r,showEditButton:c=!0})=>{const[p,m]=a.useState(!1),[o,n]=a.useState(t||""),[s,h]=a.useState(!1),g=a.useRef(null),d=()=>{!t||!r||(n(t),m(!0),setTimeout(()=>g.current?.focus(),0))},j=async()=>{if(!t||!r||!o.trim())return;const u=wn(o);if(u===t){m(!1);return}h(!0);try{await r(t,u),m(!1),n("")}finally{h(!1)}},b=()=>{m(!1),n("")},f=u=>{u.key==="Enter"?(u.preventDefault(),j()):u.key==="Escape"&&(u.preventDefault(),b())};return p?e.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:e.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:u=>{u.preventDefault(),j()},children:[e.jsx(S,{name:"git-branch",className:"size-4 text-primary"}),e.jsx("input",{ref:g,value:o,onChange:u=>n(u.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:"Branch name",onKeyDown:f,autoFocus:!0}),e.jsx("button",{type:"submit",disabled:s,"aria-label":s?"Saving branch name":"Save branch name",title:s?"Saving branch name":"Save branch name",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:s?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"check",className:"size-4"})}),e.jsx("button",{type:"button",onClick:b,disabled:s,"aria-label":"Cancel branch rename",title:"Cancel branch rename",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(S,{name:"close",className:"size-4"})})]})}):e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[e.jsx(S,{name:"git-branch",className:"size-4 text-primary shrink-0"}),e.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[e.jsx(wt,{value:t||"Detached HEAD",className:"min-w-0 typography-ui-label font-normal text-foreground"}),c&&r&&t&&e.jsx(H,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:d,title:"Rename branch",children:e.jsx(S,{name:"edit",className:"size-4"})})]})]})},It=({syncAction:t,remotes:r=[],onFetch:c,onSync:p,disabled:m,showFetchMenu:o=!0,aheadCount:n=0,behindCount:s=0,trackingRemoteName:h,hasUncommittedChanges:g=!1,iconOnly:d=!1,upstreamTarget:j=null})=>{const{isMobile:b,isTablet:f}=Nt(),u=b||f,w=r.find(x=>x.name===h)??r[0],z=s>0&&g,R=m||t!==null||!w||z,M=m||t!==null||r.length===0,_=n>0||s>0,U=["sync",s>0?`↓${s}`:null,n>0?`↑${n}`:null].filter(Boolean).join(" "),I=z?"Commit or stash your changes before syncing":w?[_?`Sync Changes (${s} down, ${n} up)`:"Sync changes",j?`Compared with ${j}`:null].filter(Boolean).join(". "):"No remotes configured",L=()=>{w&&p(w)},B=u?"h-9":"h-8",F=[s>0?`↓${s}`:null,n>0?`↑${n}`:null].filter(Boolean).join(" "),A=d?F:U;return e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"inline-flex",tabIndex:z?0:void 0,children:e.jsxs(H,{type:"button",variant:"ghost",size:"sm",onClick:L,disabled:R,className:se(B,"flex-shrink-0 gap-1.5 tabular-nums",A?"px-2":u?"w-9 p-0":"w-8 p-0"),"aria-label":"Sync changes",children:[t==="sync"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"refresh",className:"size-4"}),A?e.jsx("span",{className:"whitespace-nowrap",children:A}):null]})})}),e.jsx(Ce,{sideOffset:8,children:I})]}),o?e.jsxs(Be,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(H,{type:"button",variant:"ghost",size:"sm",className:se(B,u?"w-9":"w-8","flex-shrink-0 p-0"),disabled:M,"aria-label":"More sync actions",children:e.jsx(S,{name:"more",className:"size-4"})})}),e.jsx(Ie,{align:"end",className:"w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",children:r.map(x=>e.jsx(At,{remote:x,onFetch:c},x.name))})]}):null]})},At=({remote:t,onFetch:r,disabled:c=!1})=>e.jsx(fe,{disabled:c,onSelect:()=>r(t),children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsx(S,{name:"refresh",className:"size-4 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:`Fetch from ${t.name}`}),e.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:t.fetchUrl})]})]})}),Nn=420,Cn=({status:t,localBranches:r,remoteBranches:c,branchInfo:p,syncAction:m,remotes:o,onFetch:n,onSync:s,onCheckoutBranch:h,onCreateBranch:g,onRenameBranch:d,isWorktreeMode:j,upstreamTarget:b,onOpenHistory:f,onOpenGraph:u,onOpenStashes:w,onOpenUpdateBranch:z,onOpenReintegrateCommits:R,diffScope:M,onDiffScopeChange:_,allCount:U,workingCount:I,stagedCount:L,branchAvailable:B,diffHeaderState:F})=>{const A=f||u||w||z||R,x=(F?.totalCount??0)>0,q=M!=="turn"&&M!=="branch",W=o.length>0,J=!t||m!==null,Y=a.useRef(null),[T,D]=a.useState(!1);a.useLayoutEffect(()=>{const ee=Y.current;if(!ee||typeof ResizeObserver>"u")return;const O=()=>D(ee.clientWidth<Nn);O();const N=new ResizeObserver(O);return N.observe(ee),()=>N.disconnect()},[]);const ae=o.find(ee=>ee.name===t.tracking?.split("/")[0])??o[0],ne=(t.ahead??0)>0||(t.behind??0)>0,re=T&&!ne,le=re&&!!ae||W||A||F!==null;return e.jsxs("div",{ref:Y,className:"flex min-w-0 flex-1 items-center gap-1",children:[e.jsx("div",{className:"min-w-0 flex-shrink",children:j?e.jsx(Lt,{currentBranch:t.current,onRename:d}):e.jsx(Bt,{currentBranch:t.current,localBranches:r,remoteBranches:c,branchInfo:p,onCheckout:h,onCreate:g,remotes:o})}),e.jsx("div",{className:"min-w-0 shrink-0",children:e.jsx(un,{scope:M,isGitRepo:!0,branchAvailable:B,allCount:U,workingCount:I,stagedCount:L,turnCount:F?.turnCount??0,branchCount:F?.branchCount??0,focusedFilePath:F?.focusedFilePath??null,onScopeChange:_})}),e.jsx("div",{className:"min-w-0 flex-1"}),e.jsx("div",{className:re?"hidden":"shrink-0",children:e.jsx(It,{syncAction:m,remotes:o,onFetch:n,onSync:s,disabled:!t,showFetchMenu:!1,iconOnly:!0,aheadCount:t.ahead,behindCount:t.behind,trackingRemoteName:t.tracking?.split("/")[0],hasUncommittedChanges:(t.files?.length??0)>0,upstreamTarget:b})}),le?e.jsx("div",{className:"shrink-0",children:e.jsxs(Be,{children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Le,{asChild:!0,children:e.jsx(H,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":"Repository views",children:e.jsx(S,{name:"more-fill",className:"size-4"})})})}),e.jsx(Ce,{sideOffset:8,children:"Repository views"})]}),e.jsxs(Ie,{align:"end",className:"max-w-[min(360px,calc(100vw-2rem))]",children:[re&&ae?e.jsxs(fe,{disabled:J,onSelect:()=>s(ae),children:[e.jsx(S,{name:"refresh",className:"size-4"}),"Sync changes"]}):null,o.map(ee=>e.jsx(At,{remote:ee,onFetch:n,disabled:J},ee.name)),W&&(A||F!==null)?e.jsx(rt,{}):null,f?e.jsxs(fe,{onSelect:f,children:[e.jsx(S,{name:"history",className:"size-4"}),"History"]}):null,u?e.jsxs(fe,{onSelect:u,children:[e.jsx(S,{name:"git-branch",className:"size-4"}),"Graph"]}):null,w?e.jsxs(fe,{onSelect:w,children:[e.jsx(S,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null,z?e.jsxs(fe,{onSelect:z,children:[e.jsx(S,{name:"git-merge",className:"size-4"}),"Update branch"]}):null,R?e.jsxs(fe,{onSelect:R,children:[e.jsx(S,{name:"split-cells-horizontal",className:"size-4"}),"Re-integrate commits"]}):null,A&&F!==null?e.jsx(rt,{}):null,F!==null?e.jsxs(fe,{disabled:!x,onSelect:F.onExpandOrCollapseAll,children:[e.jsx(S,{name:"expand-up-down",className:"size-4"}),F.expandedCount>0?"Collapse all":"Expand all"]}):null,F!==null?e.jsxs(fe,{disabled:!x||!q,onSelect:F.onToggleLoadFullFiles,children:[e.jsx(S,{name:"file-download",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Load full files"}),F.loadFullFiles?e.jsx(S,{name:"check",className:"size-4"}):null]}):null,F!==null?e.jsxs(fe,{disabled:!x,onSelect:F.onToggleWrapLines,children:[e.jsx(S,{name:"text-wrap",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Wrap lines"}),F.wrapLines?e.jsx(S,{name:"check",className:"size-4"}):null]}):null,F!==null?e.jsxs(fe,{disabled:F.layoutMode===null,onSelect:F.onToggleLayout,children:[e.jsx(S,{name:F.layoutMode==="side-by-side"?"layout-column":"align-justify",className:"size-4"}),F.layoutMode==="side-by-side"?"Switch to unified view":"Switch to side-by-side view"]}):null]})]})}):null]})},Sn=t=>t.isFork&&t.upstreamDefaultBranch?.trim()?t.upstreamDefaultBranch.trim():t.defaultBranch?.trim()?t.defaultBranch.trim():"main",Ds=(t,r)=>`${t}
|
|
3
|
+
${r}`,kn=t=>{const r=t.headBranch.trim();if(t.allBranches==null)return[];const c=new Set,p=[];for(const o of t.allBranches){if(!o.startsWith("remotes/"))continue;const n=o.slice(8),s=n.indexOf("/");if(s<=0)continue;const h=n.slice(s+1).trim();!h||h===r||c.has(h)||(c.add(h),p.push(h))}if(p.sort((o,n)=>o.localeCompare(n)),p.length===0)return[];const m=t.defaultBranch?.trim()??"";return m&&m!==r?[m,...p.filter(o=>o!==m)]:p},Rn=[{id:"ready",label:"Create pull request",description:"Open the pull request for review"},{id:"draft",label:"Create draft pull request",description:"Mark the pull request as not ready for review"}],En=t=>t==="draft"?"Create draft pull request":"Create pull request",Ts=new Map,ot=t=>Ts.get(t)??null,zn=(t,r)=>{Ts.set(t,r)},Ms=t=>{Ts.delete(t)},Fn=320,Dn=({directory:t,headBranch:r,defaultBranch:c,isFork:p,upstreamDefaultBranch:m,hasUpstream:o,onCollapse:n,onCreated:s})=>{const h=qe(),g=Ct(t),d=Sn({isFork:p,upstreamDefaultBranch:m,defaultBranch:c}),j=Ds(t,r),b=ot(j),[f,u]=a.useState(b?.base??d),[w,z]=a.useState(b?.title??""),[R,M]=a.useState(b?.body??""),[_,U]=a.useState(b?.mode??"ready"),[I,L]=a.useState("write"),[B,F]=a.useState(!1),[A,x]=a.useState(!1),[q,W]=a.useState(!1),[J,Y]=a.useState(""),[T,D]=a.useState({}),[ae,ne]=a.useState(null),re=a.useRef(!1),le=a.useRef(null);a.useEffect(()=>{re.current||u(d)},[d]),a.useEffect(()=>{if(!w.trim()&&!R.trim()&&_==="ready"&&f===d){ot(j)&&Ms(j);return}zn(j,{title:w,body:R,base:f===d?null:f,mode:_})},[j,w,R,f,_,d]);const ee=St(t),O=h.git;a.useEffect(()=>{ee!==null||!O||kt.getState().fetchBranches(t,O).catch(()=>{})},[ee,t,O]);const N=a.useMemo(()=>kn({allBranches:ee?.all,headBranch:r,defaultBranch:d}),[ee,r,d]);a.useLayoutEffect(()=>{const k=le.current;k&&(k.style.height="0px",k.style.height=`${Math.min(k.scrollHeight,Fn)}px`)},[R,I]);const E=a.useCallback(k=>{re.current=!0,u(k),W(!1),Y(""),D(Q=>Q.base?{...Q,base:void 0}:Q)},[]),i=a.useCallback(async()=>{if(B||A)return;if(!g){ne("Select a repository first");return}const k=fn({title:w,head:r,base:f});if(D(k.errors),!k.ok)return;const Q=h.github;if(!Q){ne("GitHub is not available in this runtime");return}ne(null),F(!0);try{if(!o){x(!0);try{await h.git.gitPush(t)}catch(K){ne(K instanceof Error?K.message:"Push failed. Create the pull request after pushing.");return}finally{x(!1)}}const V=await rn.getState().createPullRequest({directory:t,repo:g,title:w.trim(),head:r,base:f,body:R.trim()||void 0,draft:_==="draft"},Q);if(!V.ok||V.number==null){ne(V.error?.kind==="failed"?V.error.message:"Failed to create pull request");return}P.success(`Pull request #${V.number} created`),Ms(j),await Is.getState().refresh(t,r,Q,{force:!0}).catch(()=>{}),Mt(t,g,V.number),s?.(V.number)}finally{F(!1)}},[B,A,g,w,R,r,f,_,o,h,t,j,s]),$=a.useCallback(k=>{k.nativeEvent.isComposing||k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&!k.shiftKey&&!k.altKey&&!k.repeat&&(k.preventDefault(),k.stopPropagation(),i())},[i]);return e.jsxs("section",{"aria-label":"Create pull request",className:"flex min-w-0 flex-col gap-2 py-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(S,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("h3",{className:"typography-ui-label text-foreground",children:"New pull request"}),e.jsx("span",{className:"flex-1"}),e.jsx(H,{type:"button",variant:"ghost",size:"icon",onClick:n,"aria-label":"Cancel",title:"Cancel",className:"size-6 shrink-0",children:e.jsx(S,{name:"close",className:"size-4"})})]}),e.jsxs("p",{className:"flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"shrink-0",children:"into"}),N.length>0?e.jsxs(Be,{open:q,onOpenChange:k=>{W(k),k||Y("")},modal:!1,children:[e.jsx(Le,{asChild:!0,children:e.jsxs("button",{type:"button","aria-label":"Base branch",className:se(Rt({size:"default"}),"min-w-28 max-w-56"),children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:f||"Select base"}),e.jsx(S,{name:"arrow-down-s",className:"size-3.5 shrink-0 opacity-60"})]})}),e.jsx(Ie,{align:"start",sideOffset:6,className:"max-h-[min(var(--available-height),24rem)] w-72 max-w-[min(18rem,var(--available-width))] overflow-hidden p-0",children:e.jsxs($s,{className:"h-full min-h-0",children:[e.jsx(Ps,{placeholder:"Search branches...",value:J,onValueChange:Y,onKeyDown:k=>k.stopPropagation()}),e.jsxs(Bs,{disableHorizontal:!0,children:[e.jsx(Ls,{children:"No branches found."}),e.jsx(He,{heading:"Branches",children:N.map(k=>e.jsxs(Ee,{value:k,onSelect:()=>E(k),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono typography-ui-label text-foreground",children:k}),k===d?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:"default"}):null]},k))})]})]})})]}):e.jsx(hs,{value:f,onChange:k=>{re.current=!0,u(k.target.value)},"aria-label":"Base branch",className:"h-8 w-40"}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",title:"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono",title:r,children:r})]}),T.base?e.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:T.base}):null,o?null:e.jsxs("p",{className:"flex items-start gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(S,{name:"information",className:"size-3.5 shrink-0 text-[var(--status-info)]","aria-hidden":"true"}),e.jsx("span",{children:"This branch isn't on the remote yet. It will be pushed first."})]}),e.jsx(hs,{value:w,onChange:k=>z(k.target.value),placeholder:"Title","aria-label":"Pull request title",onKeyDown:$,className:"h-8"}),T.title?e.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:T.title}):null,e.jsx("div",{role:"tablist","aria-label":"Description format",className:"flex items-center gap-4",children:["write","preview"].map(k=>{const Q=I===k;return e.jsxs("button",{type:"button",role:"tab","aria-selected":Q,onClick:()=>L(k),className:se("relative flex h-7 shrink-0 items-center text-xs leading-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Q?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:[k==="write"?"Write":"Preview",Q?e.jsx("span",{"aria-hidden":"true",className:"absolute inset-x-0 bottom-0 h-0.5 bg-interactive-selection"}):null]},k)})}),I==="write"?e.jsx("textarea",{ref:le,value:R,onChange:k=>M(k.target.value),rows:4,placeholder:"Add a description (markdown supported)","aria-label":"Pull request description",onKeyDown:$,className:"min-h-20 w-full resize-none overflow-y-auto rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground placeholder:text-muted-foreground"}):e.jsx("div",{className:"min-h-20 w-full min-w-0",children:R.trim()?e.jsx(pn,{markdown:R}):e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Nothing to preview"})}),ae?e.jsxs("div",{role:"alert",className:"flex items-start gap-1.5 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-2 py-1.5 text-foreground",children:[e.jsx(S,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 typography-micro",children:ae})]}):null,e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"flex-1"}),e.jsxs("span",{role:"group","aria-label":"Create pull request options",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(H,{type:"button",variant:"default",size:"sm",onClick:()=>{i()},disabled:B,children:A?"Pushing…":B?"Creating…":En(_)}),e.jsxs(Be,{modal:!1,children:[e.jsx(Le,{asChild:!0,children:e.jsx(H,{type:"button",variant:"default",size:"sm",className:"shrink-0 px-1.5",title:"Create options","aria-label":"Create options",disabled:B,children:e.jsx(S,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ie,{align:"end",className:"w-72",children:e.jsx(Ba,{value:_,onValueChange:k=>U(k),children:Rn.map(k=>e.jsx(La,{value:k.id,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:k.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:k.description})]})},k.id))})})]})]})]})]})},Mn=({directory:t,branch:r,repo:c})=>{const p=a.useMemo(()=>$t(t,r),[t,r]),m=Is(g=>p?g.results[p]??null:null),o=on(p),n=m?.pr;if(!n)return null;const s=o?o.visualState==="merged"?`Pull request #${o.number}, merged`:o.visualState==="draft"?`Draft pull request #${o.number}`:o.visualState==="blocked"?`Pull request #${o.number}, checks failing`:o.visualState==="closed"?`Pull request #${o.number}, closed`:`Pull request #${o.number}, open`:`Pull request #${n.number}, open`,h=()=>Mt(t,c,n.number);return e.jsxs("div",{className:"relative flex min-w-0 items-center gap-2 rounded-md px-2 py-1",children:[e.jsx("button",{type:"button",onClick:h,"aria-label":`Open ${s} in Pull requests`,title:s,className:"absolute inset-0 rounded-md hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50"}),e.jsxs("span",{className:"pointer-events-none flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx(gn,{kind:"pr",state:n.state,draft:n.draft}),e.jsxs("span",{className:"shrink-0 font-mono typography-micro tabular-nums text-muted-foreground",children:["#",n.number]}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.title||`Pull request #${n.number}`,children:n.title||`Pull request #${n.number}`}),e.jsx(xn,{state:m?.checks?.state??null})]}),e.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:h,className:"relative shrink-0",children:"Open"})]})},$n=({headBranch:t,onExpand:r})=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2 py-1",children:[e.jsx(S,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"flex min-w-0 flex-1 items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"shrink-0",children:"No pull request for"}),e.jsx("code",{className:"min-w-0 max-w-44 truncate rounded bg-[var(--surface-muted)] px-1 py-px font-mono text-foreground",title:t,children:t})]}),e.jsx(H,{type:"button",variant:"default",size:"xs",onClick:r,className:"shrink-0",children:"Create pull request"})]}),Pn=({directory:t,branch:r,hasUpstream:c})=>{const p=qe(),m=Ct(t||null),o=Ia(j=>t?j.entriesByDirectory[t]?.scope??null:null);ln(t,r,p.github??null);const n=a.useMemo(()=>$t(t,r),[t,r]),s=Is(j=>n?j.results[n]??null:null),[h,g]=a.useState(!1);a.useEffect(()=>{g(!1)},[t,r]);const d=a.useMemo(()=>!o||!m?null:o.repositories.find(j=>j.host&&j.owner&&j.repo&&`${j.host}/${j.owner}/${j.repo}`===m)??null,[o,m]);return!t||!r||!m||s?.skippedDefaultBranch?null:s?.pr?e.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-1 py-1.5",children:e.jsx(Mn,{directory:t,branch:r,repo:m})}):!s||!s.fetchedAt?null:e.jsx("div",{className:"shrink-0 border-b border-border px-3 py-1.5",children:h?e.jsx(Dn,{directory:t,headBranch:r,defaultBranch:s.defaultBranch??d?.defaultBranch??null,isFork:(d?.fork??!1)===!0,upstreamDefaultBranch:null,hasUpstream:c,onCollapse:()=>g(!1),onCreated:()=>{Ms(Ds(t,r)),g(!1)}},Ds(t,r)):e.jsx($n,{headBranch:r,onExpand:()=>g(!0)})})},Bn=({open:t,onOpenChange:r,conflictFiles:c=[],directory:p,operation:m,onAbort:o,onClearState:n})=>{const{git:s}=qe(),h=zs(x=>x.openNewSessionDraft),g=zs(x=>x.currentSessionId),d=lt(x=>x.setPendingInputText),j=lt(x=>x.setPendingSyntheticParts),b=As(x=>x.setActiveMainTab),[f,u]=a.useState(!1),[w,z]=a.useState(null),[R,M]=a.useState(null);a.useEffect(()=>{!t||!p||(u(!0),M(null),z(null),s.getConflictDetails(p).then(x=>{z(x)}).catch(x=>{const q=x instanceof Error?x.message:"Failed to load conflict details";M(q)}).finally(()=>{u(!1)}))},[p,s,t]);const _=a.useCallback(async()=>{if(!w)return null;const x=m==="merge"?"merge":"rebase",q=w.headInfo||(m==="merge"?"MERGE_HEAD":"REBASE_HEAD"),W=m==="merge"?"git commit --no-edit":"git rebase --continue",J=`Investigate the ${x} conflicts and concisely report the intended resolution strategy without making modifications. Wait for confirmation before resolving, staging, or continuing the ${x}. Preserve the intent of changes from ${q}.`,Y=`Git ${x} operation is in progress with conflicts.
|
|
4
4
|
- Directory: ${p}
|
|
5
5
|
- Operation: ${m}
|
|
6
6
|
- Head Info: ${w.headInfo||"N/A"}
|
|
7
7
|
|
|
8
|
-
Inspect each conflicted file and both sides of every conflict. Report a concise per-file resolution strategy and any assumptions or tradeoffs. Wait for explicit user confirmation before editing, staging, or running ${W}. After confirmation, remove all conflict markers, preserve intent from both sides, verify syntax, and complete the ${x}.`,
|
|
9
|
-
${JSON.stringify({directory:p,operation:w.operation,headInfo:w.headInfo,statusPorcelain:w.statusPorcelain,unmergedFiles:w.unmergedFiles,diff:w.diff},null,2)}`;return{visibleText:J,instructionsText:Y,payloadText:A}},[w,p,m]),U=()=>{o(),r(!1)},I=()=>{n?.(),r(!1)},L=async()=>{const x=await _();if(!x){P.error("No conflict details available");return}if(!g){P.error("No active session",{description:"Open or create a session to resolve conflicts."});return}d(x.visibleText,"replace"),j([{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]),b("chat"),n?.(),r(!1)},B=async()=>{const x=await _();if(!x){P.error("No conflict details available");return}h({directoryOverride:p,initialPrompt:x.visibleText,syntheticParts:[{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]}),b("chat"),n?.(),r(!1)},F=m==="merge"?"Merge":"Rebase",T=w?.unmergedFiles||c;return e.jsx(Fe,{open:t,onOpenChange:r,children:e.jsx(De,{className:"max-w-md w-[calc(100vw-2rem)]",children:e.jsxs("div",{className:"flex flex-col gap-4 overflow-hidden",children:[e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e.jsx($e,{children:`${F} conflicts detected`})]}),e.jsx(Pe,{children:`Resolve the ${m} conflicts to continue.`})]}),f&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-meta",children:"Loading conflict details..."})]}),R&&e.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:`Failed to load conflict details: ${R}`}),T.length>0&&e.jsxs("div",{className:"space-y-2 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Conflicted files:"}),e.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:T.length})]}),e.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:e.jsx("ul",{className:"space-y-1",children:T.map(x=>e.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:x,children:x},x))})})]}),w?.headInfo&&e.jsxs("div",{className:"space-y-1 overflow-hidden",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"HEAD information:"}),e.jsx("div",{className:"typography-code text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:w.headInfo})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[e.jsxs(H,{variant:"default",onClick:()=>{B()},disabled:f||!w,className:"w-full gap-2",children:[f?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"add",className:"size-4"}),"Resolve in new session"]}),e.jsxs(H,{variant:"outline",onClick:()=>{L()},disabled:f||!w||!g,className:"w-full gap-2",children:[f?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"chat-1",className:"size-4"}),"Resolve in current session"]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(H,{variant:"ghost",size:"sm",onClick:I,className:"flex-1",children:"Continue later"}),e.jsx(H,{variant:"destructive",size:"sm",onClick:U,className:"flex-1",children:`Abort ${F}`})]})]})]})})})},Re=8,Ln=({laned:t,totalLanes:r,isExpanded:c})=>{const{lane:p,color:m,connectors:o}=t,s=Math.max(r,p+1)*Re+Re/2,h=a.useRef(null),g=a.useRef(null);return a.useLayoutEffect(()=>{const d=h.current,j=g.current;if(!d||!j)return;const b=d.offsetHeight;if(b===0)return;const f=window.devicePixelRatio||1;j.width=s*f,j.height=b*f;const u=j.getContext("2d");if(!u)return;u.scale(f,f),u.clearRect(0,0,s,b);const w=b/2,z=p*Re+Re/2,R=getComputedStyle(j),M=R.getPropertyValue("--surface-muted-foreground").trim()||R.color,_=L=>{if(!L.startsWith("var("))return L;const B=L.slice(4,-1).trim();return R.getPropertyValue(B).trim()||M},U=[...o].sort((L,B)=>{const F=T=>T==="branch-out"||T==="merge-in";return(F(L.type)?1:0)-(F(B.type)?1:0)});for(const L of U){const B=L.fromLane*Re+Re/2,F=L.toLane*Re+Re/2,T=L.type==="passing"?.72:L.type==="branch-out"||L.type==="merge-in"?.95:1;switch(u.beginPath(),u.strokeStyle=_(L.color),u.globalAlpha=T,u.lineWidth=1.25,u.lineCap="round",L.type){case"passing":case"commit-lane":u.moveTo(B,0),u.lineTo(B,b);break;case"top-stub":u.moveTo(B,0),u.lineTo(B,w);break;case"bottom-stub":u.moveTo(B,w),u.lineTo(B,b);break;case"branch-out":{const x=(w+b)/2;u.moveTo(z,w),u.bezierCurveTo(z,x,F,x,F,b);break}case"merge-in":{const x=w/2;u.moveTo(B,0),u.bezierCurveTo(B,x,z,x,z,w);break}default:continue}u.stroke(),u.globalAlpha=1}const I=R.getPropertyValue("--background").trim()||R.getPropertyValue("--surface-background").trim();u.beginPath(),u.arc(z,w,4,0,Math.PI*2),u.fillStyle=_(m),u.fill(),u.beginPath(),u.arc(z,w,5,0,Math.PI*2),u.strokeStyle=I||M,u.lineWidth=2,u.stroke()},[t,p,m,o,r,c,s]),e.jsx("div",{ref:h,style:{width:s,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},children:e.jsx("canvas",{ref:g,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}})})},ct=15e3,dt=500,ut=12,ht=8*1024*1024,mt=t=>typeof t=="string"?0:(t.original?.length??0)+(t.modified?.length??0),ft=t=>{if(t.size<=ut){let m=0;for(const o of t.values())m+=mt(o);if(m<=ht)return t}const r=Array.from(t.entries()).reverse(),c=new Map;let p=0;for(const[m,o]of r){if(c.size>=ut)continue;const n=mt(o);p+n>ht&&c.size>0||(c.set(m,o),p+=n)}return new Map(Array.from(c.entries()).reverse())};function pt(t,r){const c=new Date(t);return Number.isNaN(c.getTime())?t:Ta(c,r,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function In(t){switch(t){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}function Tn(t){return t?t.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{const c=r.startsWith("HEAD ->");return{label:c?r.replace("HEAD -> ",""):r.replace("tag: ",""),isHead:c,isTag:r.startsWith("tag: ")}}):[]}const An=a.memo(({entry:t,mode:r="history",laned:c,totalLanes:p,isExpanded:m,onToggle:o,files:n,isLoadingFiles:s,onCopyHash:h,directory:g,onConflict:d,onActionSuccess:j})=>{const{git:b}=qe(),f=Ts(i=>i.timeFormatPreference),u=r==="graph",w={checkout:"Check out this commit as detached HEAD?",cherryPick:"Cherry-pick this commit onto the current branch?",revert:"Stage a revert of this commit?",merge:"Merge this commit into the current branch?",rebase:"Rebase current branch onto this commit?",resetSoft:"Soft reset — HEAD moves, staged changes preserved.",resetMixed:"Mixed reset — HEAD moves, changes unstaged.",resetHard:"Hard reset — HEAD moves, all uncommitted changes permanently discarded."},z={soft:"Soft — keep staged",mixed:"Mixed — unstage changes",hard:"Hard — discard all changes"},[R,M]=a.useState(null),[_,U]=a.useState(!1),[I,L]=a.useState(""),[B,F]=a.useState(null),[T,x]=a.useState(new Set),[q,W]=a.useState(new Map),[J,Y]=a.useState(new Set),A=async()=>{if(g){M("checkout");try{await b.checkoutCommit(g,t.hash),P.success("Checked out (detached HEAD)"),j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},D=async()=>{if(!(!g||!I.trim())){M("createBranch");try{await b.createBranch(g,I.trim(),t.hash),U(!1),L(""),j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},ae=async()=>{if(g){M("cherryPick");try{const i=await b.cherryPick(g,t.hash);i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"cherry-pick"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},ne=async()=>{if(g){M("revert");try{const i=await b.revertCommit(g,t.hash);i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"revert"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},re=async(i,$=!1)=>{if(!(!g||R!==null)){M("reset");try{await b.resetToCommit(g,t.hash,i,$),j?.()}catch(k){P.error(String(k.message))}finally{M(null)}}},le=async()=>{if(!B)return;const i=B;switch(F(null),i){case"checkout":return A();case"cherryPick":return ae();case"revert":return ne();case"merge":return ee();case"rebase":return O();case"resetSoft":return re("soft");case"resetMixed":return re("mixed");case"resetHard":return re("hard",!0)}},ee=async()=>{if(g){M("merge");try{const i=await b.merge(g,{branch:t.hash});i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"merge"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},O=async()=>{if(g){M("rebase");try{const i=await b.rebase(g,{onto:t.hash});i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"rebase"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},N=a.useCallback(async i=>{const $=i.path;if(!g){W(k=>new Map(k).set($,"error"));return}W(k=>ft(new Map(k).set($,"loading")));try{const Q=(b.getCommitFileDiff??dn)(g,t.hash,i.path,!1),V=new Promise((ce,Ve)=>{setTimeout(()=>Ve(new Error(`Timed out after ${ct}ms`)),ct)}),K=await Promise.race([Q,V]);W(ce=>ft(new Map(ce).set($,K)))}catch{W(k=>new Map(k).set($,"error"))}},[g,t.hash,b.getCommitFileDiff]),E=a.useCallback(async i=>{const $=i.path;if(i.changeType==="R"||i.isBinary){x(K=>{const ce=new Set(K);return ce.has($)?ce.delete($):ce.add($),ce});return}const k=q.get($);if(T.has($)&&k&&k!=="error"){x(K=>{const ce=new Set(K);return ce.delete($),ce});return}x(K=>{const ce=new Set(K);return ce.add($),ce}),!(k&&k!=="error"||i.insertions+i.deletions>dt&&!J.has($))&&await N(i)},[q,J,N,T]);return e.jsxs("li",{children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":m,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),o())},className:se("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",u?"hover:bg-[var(--interactive-hover)]/40":m?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[u&&c&&p!==void 0?e.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:e.jsx(Ln,{laned:c,totalLanes:p,isExpanded:m})}):e.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[u?(()=>{const i=Tn(t.refs);return i.length>0?e.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:i.map($=>e.jsx("span",{className:se("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",$.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":$.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:$.label},$.label))}):null})():null,e.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:t.message}),e.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[e.jsx("span",{className:"truncate min-w-[3ch]",title:t.author_name,children:t.author_name}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("span",{className:"truncate min-w-0",title:pt(t.date,f),children:pt(t.date,f)})]}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("code",{className:"shrink-0 font-mono",children:t.hash.slice(0,8)}),e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(H,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:i=>{i.stopPropagation(),h(t.hash)},children:e.jsx(S,{name:"file-copy",className:"size-3"})})}),e.jsx(Ce,{sideOffset:8,children:"Copy SHA"})]})]})]})]}),m&&e.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[u&&B?e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[e.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:w[B]}),e.jsxs(H,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:R!==null,onClick:i=>{i.stopPropagation(),le()},children:[R!==null?e.jsx(S,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Confirm"]}),e.jsx(H,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:R!==null,onClick:i=>{i.stopPropagation(),F(null)},children:"Cancel"})]}):u?e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("checkout")},children:"Checkout"}),_?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:I,onChange:i=>L(i.target.value),onKeyDown:i=>{i.key==="Enter"&&D(),i.key==="Escape"&&(U(!1),L(""))},placeholder:"Branch name",className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),e.jsxs(H,{variant:"outline",size:"xs",className:"h-6",disabled:!I.trim()||R!==null,onClick:i=>{i.stopPropagation(),D()},children:[R==="createBranch"?e.jsx(S,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Create"]})]}):e.jsx(H,{variant:"outline",size:"xs",className:"h-6",onClick:i=>{i.stopPropagation(),U(!0)},children:"Create branch here"}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("cherryPick")},children:"Cherry-pick"}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("revert")},children:"Revert"}),e.jsxs(Be,{children:[e.jsx(Le,{asChild:!0,children:e.jsxs(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>i.stopPropagation(),children:[R==="reset"?e.jsx(S,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Reset..."]})}),e.jsx(Ie,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(i=>e.jsx(fe,{disabled:R!==null,onSelect:$=>{$.stopPropagation(),F(`reset${i.charAt(0).toUpperCase()+i.slice(1)}`)},children:z[i]},i))})]}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("merge")},children:"Merge into current"}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("rebase")},children:"Rebase onto this"})]}):null,s?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading files..."})]}):n.length===0?e.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:"No files"}):e.jsx("ul",{className:"space-y-0.5 py-2",children:n.map(i=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>E(i),className:se("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",T.has(i.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[e.jsx("span",{className:se("font-semibold w-3 text-center shrink-0",In(i.changeType)),children:i.changeType}),e.jsx("span",{className:"truncate text-foreground min-w-0",title:i.path,children:i.path}),!i.isBinary&&e.jsxs("span",{className:"shrink-0",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i.insertions]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",i.deletions]})]}),i.isBinary&&e.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:"Binary"}),e.jsx(S,{name:T.has(i.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),T.has(i.path)&&e.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:i.changeType==="R"?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Renamed file — diff not supported"}):i.isBinary?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Binary file — no diff available"}):(()=>{const $=i.insertions+i.deletions;if(!J.has(i.path)&&$>dt)return e.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${$} changed lines)`}),e.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),e.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{Y(Q=>new Set(Q).add(i.path)),N(i)},children:"Render anyway"})]});const k=q.get(i.path);return k==="loading"||k===void 0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Loading diff..."}):k==="error"?e.jsx("button",{type:"button",onClick:()=>E(i),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:"Failed to load diff. Click to retry."}):e.jsx(Pt,{original:k.original,modified:k.modified,language:Et(i.path)||"",fileName:i.path,renderSideBySide:!1,layout:"inline"})})()})]},i.path))})]})]})}),gt=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)","var(--syntax-keyword)","var(--syntax-string)","var(--status-info)"];function cs(t){return gt[t%gt.length]}function On(t){if(t.length===0)return[];const r=[],c=[];for(let p=0;p<t.length;p++){const m=t[p],o=[];for(let f=0;f<r.length;f++)r[f]===m.hash&&o.push(f);let n=o.length>0?o[0]:-1;if(n===-1){const f=r.indexOf(null);f!==-1?n=f:(n=r.length,r.push(null))}const s=o.slice(1),h=cs(n),g=r[n]===m.hash,d=m.parents.length>0;d?r[n]=m.parents[0]:r[n]=null;const j=[];for(let f=1;f<m.parents.length;f++){const u=m.parents[f],w=r.indexOf(u);if(w!==-1)j.push(w);else{const z=r.indexOf(null),R=z!==-1?z:r.length;r[R]=u,R===r.length&&r.push(u),j.push(R)}}const b=[];g&&d?b.push({fromLane:n,toLane:n,color:h,type:"commit-lane"}):g&&!d?b.push({fromLane:n,toLane:n,color:h,type:"top-stub"}):!g&&d&&b.push({fromLane:n,toLane:n,color:h,type:"bottom-stub"});for(const f of s)b.push({fromLane:f,toLane:n,color:cs(f),type:"merge-in"}),r[f]=null;for(const f of j)b.push({fromLane:n,toLane:f,color:cs(f),type:"branch-out"});for(let f=0;f<r.length;f++)r[f]!==null&&f!==n&&(j.includes(f)||b.push({fromLane:f,toLane:f,color:cs(f),type:"passing"}));c.push({commit:m,lane:n,color:h,connectors:b})}return c}const Gn=[{label:"25 commits",value:25},{label:"50 commits",value:50},{label:"100 commits",value:100}],_n=({mode:t="history",log:r,isLogLoading:c,logMaxCount:p,onLogMaxCountChange:m,expandedCommitHashes:o,onToggleCommit:n,commitFilesMap:s,loadingCommitHashes:h,onCopyHash:g,directory:d,showHeader:j=!0,contentMaxHeightClassName:b="max-h-[50vh]",branchDivider:f=null,onConflict:u,onActionSuccess:w})=>{const[z,R]=a.useState(!0),M=t==="graph",_=a.useMemo(()=>M&&r?On(r.all):[],[M,r]),U=a.useMemo(()=>Math.max(1,..._.map(A=>A.lane+1)),[_]),I=a.useMemo(()=>new Map(_.map(A=>[A.commit.hash,A])),[_]);if(!r)return null;const L=f!==null&&f.insertBeforeIndex>0&&f.insertBeforeIndex<r.all.length,B=f!==null&&f.insertBeforeIndex===r.all.length,F=L||B,T=L?r.all.slice(0,f.insertBeforeIndex):B?r.all:[],x=L?r.all.slice(f.insertBeforeIndex):[],q=f?.direction==="down"?e.jsx(S,{name:"arrow-down-s",className:"size-3.5"}):e.jsx(S,{name:"arrow-up",className:"size-3.5"}),W=A=>e.jsx("ul",{className:"divide-y divide-border/60",children:A.map(D=>e.jsx(An,{entry:D,mode:t,laned:M?I.get(D.hash):void 0,totalLanes:M?U:void 0,isExpanded:o.has(D.hash),onToggle:()=>n(D.hash),files:s.get(D.hash)??[],isLoadingFiles:h.has(D.hash),onCopyHash:g,directory:d,onConflict:u,onActionSuccess:w},D.hash))}),J=r.all.length>=p?e.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:e.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(p+25),disabled:c,className:"px-3 text-muted-foreground hover:text-foreground",children:c?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{name:"loader-4",className:"size-3 animate-spin"}),"Loading..."]}):"Load more"})}):null,Y=e.jsx(Aa,{outerClassName:`min-h-0 ${b}`,className:"h-full w-full",children:r.all.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"No commits found"})}):F&&f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-0",children:[T.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:W(T)}):null,e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60"}),e.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"truncate",title:f.branchName,children:f.branchName}),q]}),e.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),x.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:W(x)}):null]}),J]}):e.jsxs(e.Fragment,{children:[W(r.all),J]})});return j?e.jsxs(bn,{open:z,onOpenChange:R,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[e.jsxs(yn,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"History"}),e.jsxs("div",{className:"flex items-center gap-2",children:[z&&e.jsx("div",{onClick:A=>A.stopPropagation(),onPointerDown:A=>A.stopPropagation(),children:e.jsxs(Oa,{value:String(p),onValueChange:A=>m(Number(A)),disabled:c,children:[e.jsx(Ga,{size:"sm",className:"w-auto",disabled:c,children:e.jsx(_a,{placeholder:"Commits"})}),e.jsx(Ha,{children:Gn.map(A=>e.jsx(qa,{value:String(A.value),children:A.label},A.value))})]})}),z?e.jsx(S,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):e.jsx(S,{name:"arrow-down-s",className:"size-4 text-muted-foreground"})]})]}),e.jsx(jn,{children:Y})]}):F?e.jsx("section",{className:"h-full min-h-0",children:Y}):e.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:Y})},Hn=a.memo(function({mode:r,onOpenChange:c,onRefresh:p,isRefreshing:m,log:o,maxCount:n,onMaxCountChange:s,expandedCommitHashes:h,onToggleCommit:g,commitFilesMap:d,loadingCommitHashes:j,onCopyHash:b,directory:f,branchDivider:u,onConflict:w,onActionSuccess:z}){return r?e.jsx(Fe,{open:r!==null,onOpenChange:c,children:e.jsxs(De,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx($e,{children:r==="graph"?"Graph":"History"}),e.jsxs(H,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:p,disabled:m,title:"Refresh","aria-label":"Refresh",children:[e.jsx(S,{name:"refresh",className:se("size-4",m&&"animate-spin")}),"Refresh"]})]}),e.jsx(Pe,{children:"Browse recent commits and inspect changed files."})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(_n,{mode:r==="graph"?"graph":"history",log:o,isLogLoading:m,logMaxCount:n,onLogMaxCountChange:s,expandedCommitHashes:h,onToggleCommit:g,commitFilesMap:d,loadingCommitHashes:j,onCopyHash:b,directory:f,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:r==="graph"?null:u,onConflict:r==="graph"?w:void 0,onActionSuccess:r==="graph"?z:void 0})})]})}):null}),qn=({open:t,onOpenChange:r,operation:c,targetBranch:p,onConfirm:m})=>{const[o,n]=a.useState(!0),[s,h]=a.useState(!1),g=c==="merge"?"Merge":"Rebase",d=async()=>{h(!0);try{await m(o),r(!1)}catch(b){const f=b instanceof Error?b.message:`Failed to ${c}`;P.error(f)}finally{h(!1)}},j=()=>{s||r(!1)};return e.jsx(Fe,{open:t,onOpenChange:s?void 0:r,children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),e.jsx($e,{children:"Uncommitted changes"})]}),e.jsx(Pe,{children:`Stash your local changes before starting the ${c}.`})]}),e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:"This will:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[e.jsx("li",{children:"Stash your uncommitted changes"}),e.jsxs("li",{children:[c==="merge"?"Merge":"Rebase"," ",c==="merge"?"with":"onto"," ",e.jsx("span",{className:"font-mono text-primary",children:p})]}),o&&e.jsx("li",{children:"Restore your stashed changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(Va,{checked:o,onChange:n,disabled:s,ariaLabel:"Restore stashed changes after operation"}),e.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!s&&n(!o),children:`Restore stashed changes after ${c}`})]}),e.jsxs(We,{className:"gap-2",children:[e.jsx(H,{variant:"ghost",size:"sm",onClick:j,disabled:s,children:"Cancel"}),e.jsx(H,{variant:"default",size:"sm",onClick:d,disabled:s,className:"gap-1.5",children:s?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),"Processing..."]}):`${g}`})]})]})})},Vn=({open:t,onOpenChange:r,directory:c,hasUncommittedChanges:p,hasStagedChanges:m=!1,uncommittedFileCount:o,onChanged:n})=>{const{git:s}=qe(),[h,g]=a.useState([]),[d,j]=a.useState(!1),[b,f]=a.useState(""),[u,w]=a.useState(""),[z,R]=a.useState(null),[M,_]=a.useState({}),U=a.useCallback(async()=>{if(c){j(!0);try{const x=await s.listGitStashes(c);g(x.stashes),_({})}catch(x){P.error(x instanceof Error?x.message:"Failed to load stashes")}finally{j(!1)}}},[c,s]);a.useEffect(()=>{t&&U()},[U,t]),a.useEffect(()=>{if(!t||!c||h.length===0)return;let x=!1;const q=h.map(W=>W.ref);return s.countGitStashFiles(c,q).then(W=>{x||_(W.counts)}).catch(()=>{}),()=>{x=!0}},[c,s,t,h]);const I=a.useMemo(()=>{const x=b.trim().toLowerCase();return x?h.filter(q=>`${q.ref} ${q.message} ${q.relativeTime}`.toLowerCase().includes(x)):h},[b,h]),L=a.useCallback(async x=>{await U(),await n?.(x)},[U,n]),B=async()=>{if(!(!c||z)){R("create");try{const x=await s.stashGitChanges(c,{message:u.trim()||void 0});x.created?(P.success("Changes stashed"),w("")):P.info("No local changes to stash"),await L({affectsIndex:!!(x.created&&m)})}catch(x){P.error(x instanceof Error?x.message:"Failed to stash changes")}finally{R(null)}}},F=async(x,q)=>{if(!(!c||z)&&!(q==="drop"&&!window.confirm(`Drop ${x.ref}?`))){R(`${q}:${x.ref}`);try{q==="apply"&&await s.applyGitStash(c,{ref:x.ref}),q==="pop"&&await s.popGitStash(c,{ref:x.ref}),q==="drop"&&await s.dropGitStash(c,{ref:x.ref});const W=q==="apply"?"Stash applied":q==="pop"?"Stash popped":"Stash dropped";P.success(W),await L({affectsIndex:q!=="drop"})}catch(W){const J=q==="apply"?"Failed to apply stash":q==="pop"?"Failed to pop stash":"Failed to drop stash";P.error(W instanceof Error?W.message:J),await L({affectsIndex:q!=="drop"})}finally{R(null)}}},T=z!==null;return e.jsx(Fe,{open:t,onOpenChange:r,children:e.jsxs(De,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs(Me,{children:[e.jsxs($e,{className:"flex items-center gap-2",children:[e.jsx(S,{name:"archive-stack",className:"h-5 w-5"}),"Stashes"]}),e.jsx(Pe,{children:"Save, restore, and clean up Git stashes for this repository."})]}),e.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(hs,{value:u,onChange:x=>w(x.target.value),placeholder:"Stash name",disabled:T||!p,className:"flex-1"}),e.jsxs(H,{onClick:B,disabled:!p||T||!c,children:[z==="create"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"inbox-archive",className:"size-4"}),`Stash ${o} files`]})]}),e.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:"Untracked files are included automatically."})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(S,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(hs,{value:b,onChange:x=>f(x.target.value),placeholder:"Search stashes",className:"pl-9"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:d?e.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:e.jsx(S,{name:"loader-4",className:"size-5 animate-spin"})}):I.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:b?"No matching stashes.":"No stashes yet."}):I.map((x,q)=>e.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[e.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[e.jsx("p",{className:"typography-small truncate text-foreground",children:x.message||"Untitled stash"}),e.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{children:q===0&&!b.trim()?"Latest":`#${q+1}`})}),e.jsx(Ce,{sideOffset:6,children:x.ref})]})," · ",x.relativeTime," · ",typeof M[x.ref]=="number"?`${M[x.ref]} files`:"counting files..."]})]}),e.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[e.jsx(Cs,{label:"Apply",loading:z===`apply:${x.ref}`,onClick:()=>F(x,"apply"),disabled:T,children:e.jsx(S,{name:"inbox-unarchive",className:"size-4"})}),e.jsx(Cs,{label:"Pop",loading:z===`pop:${x.ref}`,onClick:()=>F(x,"pop"),disabled:T,children:e.jsx(S,{name:"inbox-unarchive-fill",className:"size-4"})}),e.jsx(Cs,{label:"Drop",loading:z===`drop:${x.ref}`,onClick:()=>F(x,"drop"),disabled:T,destructive:!0,children:e.jsx(S,{name:"delete-bin",className:"size-4"})})]})]},x.ref))})]})})},Cs=({label:t,loading:r,disabled:c,destructive:p,onClick:m,children:o})=>e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,"aria-busy":r||void 0,className:se("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",p?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground"),onClick:m,disabled:c,children:r?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):o})}),e.jsx(Ce,{sideOffset:6,children:t})]}),Un=({currentBranch:t,localBranches:r,remoteBranches:c,onMerge:p,onRebase:m,disabled:o=!1,isOperating:n=!1,operationLogs:s=[],onOperationComplete:h,mode:g="dialog",defaultTargetBranch:d})=>{const[j,b]=a.useState(!1),[f,u]=a.useState("merge"),[w,z]=a.useState(null),[R,M]=a.useState(!1),[_,U]=a.useState(""),I=a.useRef(null),L=a.useRef(null),B=o||n,F=t||"current branch",T=s.length>0&&s.every(O=>O.status==="done"||O.status==="error"),x=s.some(O=>O.status==="error");a.useEffect(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[s]);const q=a.useMemo(()=>{const O=_.toLowerCase(),N=new Set(c.map(i=>i.slice(i.indexOf("/")+1)).filter(Boolean)),E=r.filter(i=>i!==t&&!N.has(i));return O?E.filter(i=>i.toLowerCase().includes(O)):E},[_,r,t,c]),W=a.useMemo(()=>{const O=_.toLowerCase();return O?c.filter(N=>N.toLowerCase().includes(O)):c},[_,c]),J=a.useCallback(()=>d&&(c.includes(d)||r.includes(d))?d:null,[d,r,c]),Y=()=>{b(!0),z(J()),u("merge"),U("")},A=O=>{z(O),M(!1),U("")},D=()=>{w&&(f==="merge"?p(w):m(w))},ae=()=>{n||(z(null),u("merge"),U(""),b(!1))},ne=()=>{n&&!T||(T&&h?.(),z(null),u("merge"),U(""),b(!1))};a.useEffect(()=>{R||U("")},[R]),a.useEffect(()=>{g==="dialog"||w||z(J())},[g,J,w]);const ee=n?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{ref:L,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:e.jsx("div",{className:"space-y-2",children:s.map((O,N)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"mt-0.5 shrink-0",children:[O.status==="running"&&e.jsx(S,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),O.status==="done"&&e.jsx(S,{name:"check",className:"size-3.5 text-success"}),O.status==="error"&&e.jsx(S,{name:"close",className:"size-3.5 text-destructive"}),O.status==="pending"&&e.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),e.jsx("span",{className:se("typography-micro",O.status==="error"&&"text-destructive",O.status==="done"&&"text-muted-foreground",O.status==="running"&&"text-foreground",O.status==="pending"&&"text-subtle-foreground"),children:O.message})]},N))})}),T?g==="dialog"?e.jsx(We,{children:e.jsx(H,{variant:"default",size:"sm",onClick:ne,children:x?"Close":"Done"})}):e.jsx("div",{className:"flex justify-end",children:e.jsx(H,{variant:"default",size:"sm",onClick:ne,children:x?"Close":"Done"})}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Operation"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>u("merge"),className:se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",f==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"git-merge",className:se("size-4",f==="merge"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:se("typography-ui-label",f==="merge"?"text-foreground":"text-muted-foreground"),children:"Merge"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Create a merge commit and preserve branch history."})]}),e.jsxs("button",{type:"button",onClick:()=>u("rebase"),className:se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",f==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"git-branch",className:se("size-4",f==="rebase"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:se("typography-ui-label",f==="rebase"?"text-foreground":"text-muted-foreground"),children:"Rebase"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Replay your commits on top of the selected branch."})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:f==="merge"?`Branch to merge into ${F}`:"Branch to rebase onto"}),e.jsxs(Be,{open:R,onOpenChange:M,modal:!1,children:[e.jsx(Le,{asChild:!0,children:e.jsxs("button",{type:"button",className:se(Rt({size:"default"}),"w-full"),children:[e.jsx("span",{className:se("truncate",!w&&"text-muted-foreground"),children:w||"Select branch"}),e.jsx(S,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),e.jsx(Ie,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:e.jsxs($s,{className:"h-full min-h-0",children:[e.jsx(Ps,{ref:I,placeholder:"Search branches...",value:_,onValueChange:U,onKeyDown:O=>O.stopPropagation()}),e.jsxs(Bs,{className:"h-full min-h-0",disableHorizontal:!0,children:[e.jsx(Ls,{children:"No branches found."}),q.length>0&&e.jsx(He,{heading:"Local branches",children:q.map(O=>e.jsx(Ee,{onSelect:()=>A(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`local-${O}`))}),q.length>0&&W.length>0?e.jsx(Es,{}):null,W.length>0&&e.jsx(He,{heading:"Remote branches",children:W.map(O=>e.jsx(Ee,{onSelect:()=>A(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`remote-${O}`))})]})]})})]})]}),w?e.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:e.jsx("p",{className:"typography-meta text-muted-foreground",children:f==="merge"?e.jsxs(e.Fragment,{children:["This will merge"," ",e.jsx("span",{className:"font-mono text-foreground",children:w})," ","into"," ",e.jsx("span",{className:"font-mono text-foreground",children:F})]}):e.jsxs(e.Fragment,{children:["This will rebase"," ",e.jsx("span",{className:"font-mono text-foreground",children:F})," ","onto"," ",e.jsx("span",{className:"font-mono text-foreground",children:w})]})})}):null,g==="dialog"?e.jsxs(We,{className:"gap-2 pt-1",children:[e.jsx(H,{variant:"ghost",size:"sm",onClick:ae,children:"Cancel"}),e.jsx(H,{variant:"default",size:"sm",onClick:D,disabled:!w,className:"gap-1.5",children:f==="merge"?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"git-merge",className:"size-4"}),"Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"git-branch",className:"size-4"}),"Rebase"]})})]}):e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(H,{variant:"destructive",size:"sm",onClick:ae,disabled:B,children:"Reset"}),e.jsx("div",{className:"flex-1"}),e.jsx(H,{variant:"default",size:"sm",onClick:D,disabled:B||!w,children:f==="merge"?"Merge":"Rebase"})]})]});return g==="bare"?ee:g==="inline"?e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:"Update branch"}),e.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:F}),"."]})]})}),e.jsx("div",{className:"pt-3",children:ee})]}):e.jsxs(e.Fragment,{children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs(H,{variant:"outline",size:"sm",className:"gap-1.5",onClick:Y,disabled:B,children:[n?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"git-merge",className:"size-4"}),e.jsx("span",{children:"Merge/Rebase"})]})}),e.jsx(Ce,{sideOffset:8,children:"Update this branch from another branch."})]}),e.jsx(Fe,{open:j,onOpenChange:O=>{O?b(!0):ne()},children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Update branch"}),e.jsx(Pe,{children:n?T?x?"Operation failed":"Operation completed":f==="merge"?"Merging in progress":"Rebasing in progress":e.jsxs(e.Fragment,{children:["Choose how to bring another branch into"," ",e.jsx("span",{className:"font-mono text-foreground",children:F}),"."]})})]}),ee]})})]})},Wn=a.memo(function({open:r,onOpenChange:c,branchOperation:p,currentBranch:m,localBranches:o,remoteBranches:n,defaultTargetBranch:s,onMerge:h,onRebase:g,disabled:d,operationLogs:j,onOperationComplete:b,canShowBranchWorkflows:f}){return e.jsx(Fe,{open:r,onOpenChange:u=>{!u&&p!==null||c(u)},children:e.jsxs(De,{className:"max-w-2xl min-h-[26rem]",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Update branch"}),e.jsxs(Pe,{children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:m??""}),"."]})]}),f?e.jsx(Un,{mode:"bare",currentBranch:m,localBranches:o,remoteBranches:n,defaultTargetBranch:s??void 0,onMerge:h,onRebase:g,disabled:d,isOperating:p!==null,operationLogs:j,onOperationComplete:b}):e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Branch actions unavailable in this repository state"})]})})}),Kn=({currentDirectory:t,isUpdateBranchDialogOpen:r,setIsUpdateBranchDialogOpen:c,branchOperation:p,currentBranch:m,localBranches:o,remoteBranches:n,updateTargetBranch:s,onMerge:h,onRebase:g,isBusy:d,operationLogs:j,onOperationComplete:b,canShowBranchWorkflows:f,gitLogDialogMode:u,setGitLogDialogMode:w,onRefreshHistory:z,isLogRefreshing:R,log:M,maxCount:_,onMaxCountChange:U,expandedCommitHashes:I,onToggleCommit:L,commitFilesMap:B,loadingCommitHashes:F,onCopyHash:T,historyBranchDivider:x,onConflict:q,onActionSuccess:W,isStashesDialogOpen:J,setIsStashesDialogOpen:Y,hasUncommittedChanges:A,hasStagedChanges:D,uncommittedFileCount:ae,onStashesChanged:ne,conflictDialogOpen:re,setConflictDialogOpen:le,conflictFiles:ee,conflictOperation:O,onAbortConflict:N,onClearConflictState:E,stashDialogOpen:i,setStashDialogOpen:$,stashDialogOperation:k,stashDialogBranch:Q,onConfirmStashAndRetry:V})=>e.jsxs(e.Fragment,{children:[e.jsx(Wn,{open:r,onOpenChange:c,branchOperation:p,currentBranch:m,localBranches:o,remoteBranches:n,defaultTargetBranch:s,onMerge:h,onRebase:g,disabled:d,operationLogs:j,onOperationComplete:b,canShowBranchWorkflows:f}),e.jsx(Hn,{mode:u,onOpenChange:K=>{K||w(null)},onRefresh:z,isRefreshing:R,log:M,maxCount:_,onMaxCountChange:U,expandedCommitHashes:I,onToggleCommit:L,commitFilesMap:B,loadingCommitHashes:F,onCopyHash:T,directory:t??void 0,branchDivider:x,onConflict:q,onActionSuccess:W}),e.jsx(Vn,{open:J,onOpenChange:Y,directory:t,hasUncommittedChanges:A,hasStagedChanges:D,uncommittedFileCount:ae,onChanged:ne}),t&&e.jsx(Bn,{open:re,onOpenChange:le,conflictFiles:ee,directory:t,operation:O,onAbort:N,onClearState:E}),e.jsx(qn,{open:i,onOpenChange:$,operation:k,targetBranch:Q,onConfirm:V})]}),Yn=20,_e=new Map;function Qn(t){return _e.get(t)??null}function Xn(t,r){if(_e.delete(t),_e.set(t,r),_e.size>Yn){const c=_e.keys().next().value;c!==void 0&&_e.delete(c)}}const Ss=38,ds=200,Zn=({value:t,onChange:r,placeholder:c,disabled:p=!1,hasTouchInput:m=!1,isMobile:o=!1})=>{const n=a.useRef(null);return a.useLayoutEffect(()=>{const s=n.current;if(!s)return;const h=document.activeElement===s,g=()=>{s.style.height=`${Ss}px`;const j=s.scrollHeight,b=Math.min(Math.max(j,Ss),ds);s.style.height=`${b}px`,s.style.overflowY=j>ds?"auto":"hidden",j>ds&&!h&&(s.scrollTop=s.scrollHeight)};g();const d=window.requestAnimationFrame(g);return()=>{window.cancelAnimationFrame(d)}},[t]),e.jsx("textarea",{ref:n,value:t,onChange:s=>r(s.target.value),placeholder:c??"Commit message",rows:1,disabled:p,autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:o,className:se("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)]",p&&"opacity-50"),style:{minHeight:Ss,maxHeight:ds}})},At=({stagedCount:t,commitMessage:r,onCommitMessageChange:c,onCommit:p,onCommitAndPush:m,commitAction:o,hasPendingIndexMutation:n=!1})=>{const s=t>0,h=r.trim()&&s&&o===null&&!n,{isMobile:g,hasTouchInput:d}=Nt();return e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"Commit"}),s?null:e.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:"Stage files to enable commit."})]}),e.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[e.jsx(Zn,{value:r,onChange:c,placeholder:"Commit message",disabled:o!==null,hasTouchInput:d,isMobile:g}),e.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"flex-1"}),e.jsx(H,{size:"sm",variant:"outline",onClick:p,disabled:!h,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit",children:o==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),g?e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(H,{variant:"solid",size:"sm",onClick:()=>m(),disabled:!h,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:o==="commitAndPush"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(Ce,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(H,{size:"sm",variant:"solid",onClick:()=>m(),disabled:!h,className:"commit-actions__btn","aria-label":"Commit and sync",children:o==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Syncing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})},Jn=({onOpenStashes:t})=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[e.jsx(S,{name:"git-commit",className:"size-10 text-subtle-foreground mb-4"}),e.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:"Working tree clean"}),e.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:"All changes have been committed"}),t?e.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:t,className:"gap-1.5",children:[e.jsx(S,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null]}),er=({mergeInProgress:t,rebaseInProgress:r,onContinue:c,onAbort:p,onResolveWithAI:m,conflictCount:o=0,isLoading:n=!1})=>{const[s,h]=a.useState(null),g=t&&t.head,d=r&&(r.headName||r.onto),j=g?"merge":d?"rebase":null;if(!j)return null;const b=async()=>{h("continue");try{await c()}finally{h(null)}},f=async()=>{h("abort");try{await p()}finally{h(null)}},u=s!==null,w=o>0,z=j==="merge"?"Merge":"Rebase";let R="";t?R=t.message?`Merging: ${t.message}`:`Merging ${t.head}`:r&&(R=r.headName?`Rebasing ${r.headName} onto ${r.onto||""}`:"Rebase in progress");const M=w?o===1?`${z} in progress: ${o} conflict`:`${z} in progress: ${o} conflicts`:`${z} in progress`,_=w?"Resolve conflicts, then continue the operation.":"All conflicts resolved. Continue to finish the operation.";return e.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:M}),R&&e.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:R})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:_}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(H,{variant:"ghost",size:"sm",onClick:f,disabled:u||n,className:"gap-1.5",children:[s==="abort"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"close",className:"size-4"}),"Abort"]}),w?m&&e.jsx(H,{variant:"default",size:"sm",onClick:m,disabled:u||n,children:"Resolve with AI"}):e.jsxs(H,{variant:"default",size:"sm",onClick:b,disabled:u||n,className:"gap-1.5",children:[s==="continue"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"check",className:"size-4"}),"Continue"]})]})]})]})})};function sr(t,r){const[c,p]=a.useState(new Set),[m,o]=a.useState(new Map),[n,s]=a.useState(new Set),h=a.useRef(m),g=a.useRef(n),d=a.useCallback(b=>{Ua(b).then(f=>{if(f.ok){P.success("Commit hash copied");return}P.error("Failed to copy")})},[]),j=a.useCallback(b=>{p(f=>{const u=new Set(f);return u.has(b)?u.delete(b):u.add(b),u})},[]);return a.useEffect(()=>{h.current=m},[m]),a.useEffect(()=>{g.current=n},[n]),a.useEffect(()=>{if(!t||!r)return;const b=Array.from(c).filter(u=>!h.current.has(u)&&!g.current.has(u));if(b.length===0)return;let f=!1;return s(u=>{const w=new Set(u);for(const z of b)w.add(z);return g.current=w,w}),Promise.all(b.map(u=>r.getCommitFiles(t,u).then(w=>({hash:u,files:w.files})).catch(w=>(console.error("Failed to fetch commit files:",w),{hash:u,files:[]})))).then(u=>{f||(o(w=>{const z=new Map(w);for(const{hash:R,files:M}of u)z.set(R,M);return h.current=z,z}),s(w=>{const z=new Set(w);for(const{hash:R}of u)z.delete(R);return g.current=z,z}))}),()=>{f=!0,s(u=>{let w=!1;const z=new Set(u);for(const R of b)z.delete(R)&&(w=!0);return w?(g.current=z,z):u})}},[c,t,r]),{expandedCommitHashes:c,commitFilesMap:m,loadingCommitHashes:n,handleCopyCommitHash:d,handleToggleCommit:j}}const tr=t=>{const{remoteNames:r,localBranches:c,worktreeCreatedFromBranch:p,rootBranchHint:m,defaultBranch:o,headBranch:n}=t,s=typeof n=="string"?n.trim():"",h=f=>{if(!f)return"";let u=f.trim();if(!u||u==="HEAD")return"";if(c.includes(u))return u;u.startsWith("refs/heads/")&&(u=u.slice(11)),u.startsWith("heads/")&&(u=u.slice(6)),u.startsWith("remotes/")&&(u=u.slice(8));const w=u.indexOf("/");if(w>0){const z=u.slice(0,w);if(r.has(z)){const R=u.slice(w+1).trim();R&&(u=R)}}return u},g=f=>{const u=h(typeof f=="string"?f:"");return u&&u!==s?u:""},d=g(p);if(d)return d;const j=g(m);if(j)return j;const b=g(o);return b||(c.includes("main")?"main":c.includes("master")?"master":c.includes("develop")?"develop":"main")},ar=t=>{const{baseBranch:r,localBranches:c,remoteBranches:p}=t;return c.includes(r)?!0:p.some(m=>{const o=m.indexOf("/");return o>0&&m.slice(o+1)===r})},nr=t=>t?t.filter(r=>!r.startsWith("remotes/")).sort():[],rr=t=>t?t.filter(r=>r.startsWith("remotes/")).map(r=>r.replace(/^remotes\//,"")).sort():[],lr=(t,r,c,p)=>{if(t.length>0)return t;const m=new Set,o=c?.trim();o&&o.includes("/")&&m.add(o.split("/")[0]);for(const n of r){const s=n.indexOf("/");s>0&&m.add(n.slice(0,s))}return m.size===0&&p&&m.add("origin"),Array.from(m).map(n=>({name:n,fetchUrl:p??"",pushUrl:p??""}))},ir=(t,r)=>{const c=r?.trim().split("/")[0];return(c&&t?.[c])??t?.origin},or=(t,r,c)=>c?t.map(o=>o.name).map(o=>`${o}/${c}`).find(o=>r.includes(o))??c:null;function cr({branches:t,status:r,remotes:c,remoteUrl:p,git:m}){const o=a.useMemo(()=>nr(t?.all),[t?.all]),n=a.useMemo(()=>rr(t?.all),[t?.all]),s=a.useMemo(()=>lr(c,n,r?.tracking,p),[c,n,p,r?.tracking]),h=r?.current??null,g=a.useMemo(()=>ir(t?.defaultBranches,r?.tracking),[t?.defaultBranches,r?.tracking]),d=a.useMemo(()=>tr({remoteNames:new Set(s.map(f=>f.name)),localBranches:o,defaultBranch:g,headBranch:h}),[h,g,s,o]),j=!!(h&&d&&h!==d&&(r?.tracking||s.length>0)&&typeof m?.getGitRangeDiff=="function"&&ar({baseBranch:d,localBranches:o,remoteBranches:n})),b=a.useMemo(()=>or(s,n,d),[d,s,n]);return{localBranches:o,remoteBranches:n,effectiveRemotes:s,currentBranch:h,defaultBranch:g,baseBranch:d,branchScopeAvailable:j,updateTargetBranch:b}}function dr({currentSessionId:t,currentDirectory:r}){const[c,p]=a.useState(!1),[m,o]=a.useState([]),[n,s]=a.useState("merge"),h=a.useMemo(()=>t?`pichamber.conflict:${t}`:null,[t]),g=a.useCallback((j,b,f)=>{if(!h||typeof window>"u")return;const u={directory:j,conflictFiles:b,operation:f};window.localStorage.setItem(h,JSON.stringify(u))},[h]),d=a.useCallback(()=>{!h||typeof window>"u"||window.localStorage.removeItem(h)},[h]);return a.useEffect(()=>{if(!h||typeof window>"u"||!r)return;const j=window.localStorage.getItem(h);if(j)try{const b=JSON.parse(j);if(b.directory!==r){window.localStorage.removeItem(h);return}o(b.conflictFiles??[]),s(b.operation??"merge"),p(!0)}catch{window.localStorage.removeItem(h)}},[h,r]),{conflictDialogOpen:c,setConflictDialogOpen:p,conflictFiles:m,setConflictFiles:o,conflictOperation:n,setConflictOperation:s,persistConflictState:g,clearConflictState:d}}const ur=({runMutation:t,onMutationComplete:r,onMutationError:c,onPathsComplete:p,scheduleFlush:m})=>{const o=[];let n=!1;return{enqueue:h=>{const g=o[o.length-1];if(g?.directory===h.directory&&g.direction===h.direction){h.paths.forEach(d=>g.paths.add(d));return}o.push(h)},flush:()=>{if(n)return;const h=o.shift();if(!h)return;n=!0;const g={directory:h.directory,direction:h.direction,paths:Array.from(h.paths),rollback:h.rollback};(async()=>{try{await t(g),r(g)}catch(d){c(g,d)}finally{p(g.paths),n=!1,o.length>0&&m()}})()},clear:()=>{o.length=0},size:()=>o.length,isRunning:()=>n}},hr=a.memo(function({file:r,actionLabel:c,actionSymbol:p,onAction:m,onViewDiff:o,onRevert:n,isReverting:s,stats:h,rowPaddingClassName:g,indentPx:d=0,actionAtStart:j=!1,showRevert:b=!0}){const f=is.useMemo(()=>hn(r),[r]),u=f.description,w=h?.insertions??0,z=h?.deletions??0,R=is.useCallback(I=>{I.key===" "?(I.preventDefault(),m()):I.key==="Enter"&&(I.preventDefault(),o())},[m,o]),M=is.useCallback(I=>{I.preventDefault(),I.stopPropagation(),m()},[m]),_=is.useCallback(I=>{I.preventDefault(),I.stopPropagation(),n()},[n]),U=e.jsx("button",{type:"button",onClick:M,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":c,title:c,children:p});return e.jsxs("div",{className:`group flex items-center gap-2 py-1.5 cursor-pointer ${g??"px-3"}`,role:"button",tabIndex:0,onClick:o,onKeyDown:R,style:d>0?{paddingLeft:`${d}px`}:void 0,children:[j?U:null,e.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:f.color},title:u,"aria-label":u,children:f.code}),e.jsx(zt,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),(()=>{const I=r.path.lastIndexOf("/");if(I===-1)return e.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:r.path,children:r.path});const L=r.path.slice(0,I),B=r.path.slice(I);return e.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[e.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:L}),e.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("span",{className:"text-foreground",children:B.slice(1)})]})]})})(),e.jsxs("span",{className:"shrink-0 typography-micro",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",w]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",z]})]}),b?e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button",onClick:_,disabled:s,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Revert changes in ${r.path}`,children:s?e.jsx(S,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(S,{name:"arrow-go-back",className:"size-3.5"})})}),e.jsx(Ce,{sideOffset:8,children:"Revert changes"})]}):null,j?null:U]})}),xt=14,Ot=t=>t.replace(/\\/g,"/").replace(/^\/+/,"").trim(),bt=(t,r)=>({id:`dir:${t}`,path:t,name:r,children:new Map,directFiles:[],files:[]}),mr=t=>{const r=bt("","");for(const c of t){const p=Ot(c.path);if(!p)continue;const o=p.split("/").filter(Boolean).slice(0,-1);let n=r;if(n.files.push(c),o.length>0){let s="";for(const h of o){s=s?`${s}/${h}`:h;const g=n.children.get(h);if(g){g.files.push(c),n=g;continue}const d=bt(s,h);d.files.push(c),n.children.set(h,d),n=d}}n.directFiles.push(c)}return r},fr=(t,r)=>{const c=[],p=(m,o)=>{const n=Array.from(m.children.values()).sort((h,g)=>h.path.localeCompare(g.path));for(const h of n)c.push({key:h.id,kind:"directory",depth:o,directory:h}),r.has(h.path)&&p(h,o+1);const s=[...m.directFiles].sort((h,g)=>h.path.localeCompare(g.path));for(const h of s)c.push({key:`file:${Ot(h.path)}`,kind:"file",depth:o,file:h})};return p(t,0),c},pr=1e3,yt=34,ks=30,us="pl-0 pr-2",Rs=(t,r)=>`${t} ${r}`,gr=({groups:t,diffStats:r,revertingPaths:c,isRevertingAll:p=!1,headerBackgroundClassName:m="bg-sidebar",onVisiblePathsChange:o,onRevertAll:n,onRevertDirectory:s})=>{const h=a.useRef(null),d=Ts(N=>N.gitChangesViewMode)==="tree",j=a.useMemo(()=>t.filter(N=>N.entries.length>0),[t]),[b,f]=a.useState(new Set),[u,w]=a.useState(new Set),[z,R]=a.useState(!1),[M,_]=a.useState(null),U=a.useMemo(()=>j.map(N=>mr(N.entries)),[j]),I=a.useMemo(()=>{const N=[];return j.forEach((E,i)=>{Array.from(U[i]?.children.values()??[]).forEach($=>{N.push(Rs(E.id,$.path))})}),N},[U,j]);a.useEffect(()=>{d&&w(N=>{const E=new Set,i=new Set(I);return N.forEach($=>{($.slice($.indexOf(" ")+1).includes("/")||i.has($))&&E.add($)}),I.forEach($=>E.add($)),E})},[d,I]);const L=a.useMemo(()=>{const N=[];return j.forEach((E,i)=>{if(N.push({type:"header",key:`header:${E.id}`,groupIndex:i}),!b.has(E.id)){if(d){const $=new Set;u.forEach(Q=>{Q.startsWith(`${E.id} `)&&$.add(Q.slice(E.id.length+1))}),fr(U[i],$).forEach(Q=>{Q.kind==="file"?N.push({type:"file",key:`${E.id}:${Q.key}`,groupIndex:i,file:Q.file,depth:Q.depth}):N.push({type:"directory",key:`${E.id}:${Q.key}`,groupIndex:i,directory:Q.directory,depth:Q.depth})});return}E.entries.forEach($=>{N.push({type:"file",key:`${E.id}:file:${$.path}`,groupIndex:i,file:$,depth:0})})}}),n&&j.length>0&&N.push({type:"revert-all",key:"revert-all"}),N},[b,u,d,n,U,j]),B=L.length,F=B>=pr,T=Ma({count:B,enabled:F,getScrollElement:()=>h.current,estimateSize:()=>yt,overscan:12,getItemKey:N=>L[N]?.key??N}),x=T.getVirtualItems(),q=a.useMemo(()=>{if(!F)return 0;const N=h.current?.scrollTop??0;return x.find(i=>i.end>N)?.index??0},[F,x,h]);a.useEffect(()=>{if(!o)return;const N=E=>E&&E.type==="file"?E.file.path:null;if(B===0){o([]);return}if(!F){const E=[];for(const i of L)if(i.type==="file"&&(E.push(i.file.path),E.length>=ks))break;o(E);return}o(L.slice(q,q+Math.ceil((h.current?.clientHeight??0)/yt)+ks).map(E=>N(E)).filter(E=>!!E).slice(0,ks))},[o,B,L,F,q]);const W=a.useCallback(N=>{f(E=>{const i=new Set(E);return i.has(N)?i.delete(N):i.add(N),i})},[]),J=a.useCallback((N,E)=>{w(i=>{const $=new Set(i),k=Rs(N,E);return $.has(k)?$.delete(k):$.add(k),$})},[]),Y=a.useMemo(()=>{const N=new Set;return j.forEach(E=>E.entries.forEach(i=>N.add(i.path))),Array.from(N)},[j]),A=Y.length,D=M?p||M.paths.some(N=>c.has(N)):!1,ae=a.useCallback(async()=>{!n||p||Y.length===0||(await n(Y),R(!1))},[Y,p,n]),ne=a.useCallback(async()=>{!s||!M||D||(await s(M.paths),_(null))},[D,s,M]),re=a.useCallback((N,E)=>{const i=b.has(N.id),$=N.entries.length;return e.jsxs("div",{className:se("sticky top-0 z-10 flex items-center gap-2 py-2",m,us,!E&&"mt-1 border-t border-border/40"),children:[e.jsx("button",{type:"button",onClick:()=>N.onActionAll(N.entries.map(k=>k.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":N.actionAllLabel,title:N.actionAllLabel,children:N.actionSymbol}),e.jsxs("button",{type:"button",onClick:()=>W(N.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":!i,children:[e.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:N.title}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:$}),e.jsx(S,{name:"arrow-down-s",className:se("size-3.5 shrink-0 text-muted-foreground transition-transform",i&&"-rotate-90")})]})]})},[b,m,W]),le=a.useCallback((N,E,i)=>{const $=u.has(Rs(N.id,E.path)),k=E.files.map(V=>V.path),Q=p||k.some(V=>c.has(V));return e.jsxs("div",{className:se("group flex items-center gap-2 py-1.5",us),style:{paddingLeft:`${i*xt}px`},children:[e.jsxs("button",{type:"button",onClick:()=>J(N.id,E.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":$?`Collapse directory ${E.path}`:`Expand directory ${E.path}`,children:[$?e.jsx(S,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):e.jsx(S,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:E.path,children:E.name}),e.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:E.files.length})]}),N.showRevertActions!==!1&&s?e.jsx("button",{type:"button",onClick:()=>_({path:E.path,paths:k,count:k.length}),disabled:Q,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":`Revert changes in ${E.path}`,title:"Revert folder changes",children:Q?e.jsx(S,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(S,{name:"arrow-go-back",className:"size-3.5"})}):null,e.jsx("button",{type:"button",onClick:()=>N.onActionAll(E.files.map(V=>V.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":N.actionSymbol==="+"?`Stage all changes in ${E.path}`:`Unstage all changes in ${E.path}`,title:N.actionSymbol==="+"?`Stage all changes in ${E.path}`:`Unstage all changes in ${E.path}`,children:N.actionSymbol})]})},[u,p,s,c,J]),ee=a.useCallback((N,E)=>{if(N.type==="revert-all")return e.jsx("div",{className:se("flex justify-end py-2",us),children:e.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>R(!0),disabled:p,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[e.jsx(S,{name:"arrow-go-back",className:"size-3.5"}),"Revert all"]})});const i=j[N.groupIndex];if(!i)return null;if(N.type==="header")return re(i,E);if(N.type==="directory")return le(i,N.directory,N.depth);const $=N.file;return e.jsx(hr,{file:$,actionLabel:i.getActionLabel($.path),actionSymbol:i.actionSymbol,onAction:()=>i.onActionFile($.path),stats:r?.[$.path],onViewDiff:()=>i.onViewDiff($.path),onRevert:()=>i.onRevertFile($.path),isReverting:c.has($.path)||p,rowPaddingClassName:us,indentPx:N.depth*xt,actionAtStart:!d,showRevert:i.showRevertActions!==!1})},[r,p,d,le,re,c,j]),O=a.useCallback(N=>{const E=L[N],i=L[N-1];return!E||!i||E.type!=="file"&&E.type!=="directory"||i.type!=="file"&&i.type!=="directory"?!1:i.groupIndex===E.groupIndex},[L]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[e.jsx(Ft,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:F?e.jsx("div",{style:{height:T.getTotalSize(),position:"relative"},children:x.map(N=>{const E=L[N.index];return E?e.jsx("div",{"data-index":N.index,ref:T.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${N.start}px)`},className:se(O(N.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:ee(E,N.index===0)},E.key):null})}):e.jsx("div",{role:"list","aria-label":"Changed files",children:L.map((N,E)=>e.jsx("div",{className:se("relative",O(E)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:ee(N,E===0)},N.key))})}),e.jsx(Wa,{containerRef:h,disableHorizontal:!0})]}),e.jsx(Fe,{open:z,onOpenChange:N=>{!p&&!N&&R(!1)},children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Revert all changes?"}),e.jsx(Pe,{children:A===1?`Revert ${A} changed file? This cannot be undone.`:`Revert ${A} changed files? This cannot be undone.`})]}),e.jsxs(We,{children:[e.jsx(H,{variant:"outline",size:"sm",onClick:()=>R(!1),disabled:p,children:"Cancel"}),e.jsx(H,{variant:"destructive",size:"sm",onClick:()=>{ae()},disabled:p,children:p?"Reverting...":"Revert all"})]})]})}),e.jsx(Fe,{open:!!M,onOpenChange:N=>{!D&&!N&&_(null)},children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Revert folder changes?"}),e.jsx(Pe,{children:M?M.count===1?`This will discard local changes in ${M.count} file under ${M.path}.`:`This will discard local changes in ${M.count} files under ${M.path}.`:null})]}),e.jsxs(We,{children:[e.jsx(H,{variant:"outline",size:"sm",onClick:()=>_(null),disabled:D,children:"Cancel"}),e.jsx(H,{variant:"destructive",size:"sm",onClick:()=>{ne()},disabled:D||!M,children:D?"Reverting...":"Revert folder"})]})]})})]})},xr=Dt(()=>vt(()=>import("./DiffView-BxW6BuOC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53])).then(t=>({default:t.DiffView}))),br=({currentDirectory:t,status:r,isGitRepo:c,isLoadingStatus:p,changeEntries:m,stagedChangeEntries:o,unstagedChangeEntries:n,effectiveRemotes:s,syncAction:h,localBranches:g,remoteBranches:d,branchInfo:j,isWorktreeMode:b,onCheckoutBranch:f,onCreateBranch:u,onRenameBranch:w,commitAction:z,commitMessage:R,hasPendingIndexMutation:M,revertingPaths:_,isRevertingAll:U,initialDiffPath:I,initialDiffStaged:L=!1,onSyncAction:B,onMoveChangePaths:F,onRevertFile:T,onRevertAll:x,onCommitMessageChange:q,onCommit:W,onVisiblePathsChange:J,loadDiff:Y})=>{const[A,D]=a.useState(()=>I?{type:"diff",path:I,staged:L}:{type:"list"}),[ae,ne]=a.useState(null),[re,le]=a.useState(null),[ee,O]=a.useState(0);a.useEffect(()=>{I&&D(V=>V.type==="diff"&&V.path===I&&V.staged===L?V:{type:"diff",path:I,staged:L})},[I,L]);const N=a.useMemo(()=>A.type==="diff"&&m.some(V=>V.path===A.path),[m,A]);a.useEffect(()=>{if(A.type!=="diff"||!N){ne(null),le(null);return}let V=!1;return ne(null),le(null),Y(A.path,A.staged).then(K=>{V||ne(K)}).catch(K=>{V||le(K instanceof Error?K.message:String(K))}),()=>{V=!0}},[ee,Y,A,N]);const E=a.useCallback((V,K=!1)=>{D({type:"diff",path:V,staged:K})},[]),i=a.useMemo(()=>{const V=[];return o.length>0&&V.push({id:"staged",title:"Staged",entries:o,actionSymbol:"-",actionAllLabel:"Unstage all changes",getActionLabel:K=>`Unstage ${K}`,onActionFile:K=>F([K],"unstage"),onActionAll:K=>F(K,"unstage"),onViewDiff:K=>E(K,!0),onRevertFile:T,showRevertActions:!1,accent:!0}),n.length>0&&V.push({id:"unstaged",title:"Changes",entries:n,actionSymbol:"+",actionAllLabel:"Stage all changes",getActionLabel:K=>`Stage ${K}`,onActionFile:K=>F([K],"stage"),onActionAll:K=>F(K,"stage"),onViewDiff:K=>E(K,!1),onRevertFile:T}),V},[E,F,T,o,n]),{label:$,icon:k}=Ka(c),Q=a.useCallback(V=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Fs,{icon:k,title:$}),e.jsx("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:e.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:r?.current||t||""})}),e.jsx("div",{className:"min-h-0 flex-1",children:V})]}),[t,r,k,$]);return t?c===null||c===!0&&!r?Q(e.jsx(ze,{loading:!0,message:"Checking repository..."})):c===!1?Q(e.jsx(a.Suspense,{fallback:e.jsx(ze,{loading:!0,message:"Loading last turn changes..."}),children:e.jsx(xr,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})):A.type==="diff"?e.jsx(yr,{path:A.path,diff:ae,fileExists:N,error:re,onBack:()=>D({type:"list"}),onRetry:()=>O(V=>V+1)}):e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Fs,{leading:e.jsx("div",{className:"min-w-0 flex-1 -ml-2",children:b?e.jsx(Lt,{currentBranch:r?.current,onRename:w}):e.jsx(Bt,{currentBranch:r?.current,localBranches:g,remoteBranches:d,branchInfo:j,onCheckout:f,onCreate:u,remotes:s})}),actions:e.jsx(It,{syncAction:h,remotes:s,onFetch:V=>B("fetch",V),onSync:V=>B("sync",V),disabled:z!==null||p,aheadCount:r?.ahead??0,behindCount:r?.behind??0,trackingRemoteName:r?.tracking?.split("/")[0],hasUncommittedChanges:m.length>0})}),m.length>0?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-3 pt-2",children:e.jsx(gr,{groups:i,diffStats:r?.diffStats,revertingPaths:_,onRevertAll:x,isRevertingAll:U,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:J})}),e.jsx("div",{className:"shrink-0 border-t border-border/40 px-3 pb-3 pt-3",children:e.jsx(At,{stagedCount:o.length,commitMessage:R,onCommitMessageChange:q,onCommit:()=>{if(!R.trim()){P.error("Enter a commit message");return}if(o.length===0){P.error("Select at least one file to commit");return}W({pushAfter:!1})},onCommitAndPush:()=>{if(!R.trim()){P.error("Enter a commit message");return}if(o.length===0){P.error("Select at least one file to commit");return}W({pushAfter:!0})},commitAction:z,hasPendingIndexMutation:M})})]}):e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(ze,{icon:!0,message:"Working tree clean",description:"There are no changed files in this workspace."})})]}):Q(e.jsx(ze,{message:"Select a session or directory to view Git status"}))},ze=({message:t,description:r,loading:c=!1,icon:p=!1})=>e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[c?e.jsx(S,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,p?e.jsx(S,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:t}),r?e.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null]})}),yr=({path:t,diff:r,fileExists:c,error:p,onBack:m,onRetry:o})=>{const n=a.useMemo(()=>Et(t)||"text",[t]);return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Fs,{leading:e.jsx(H,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:m,children:e.jsx(S,{name:"arrow-left",className:"size-4"})}),icon:e.jsx(zt,{filePath:t,className:"size-4 shrink-0"}),title:t}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:c?p?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),e.jsx("p",{className:"typography-meta text-muted-foreground",children:p}),e.jsx(H,{type:"button",size:"sm",variant:"outline",onClick:o,children:"Retry"})]})}):r?r.isBinary?e.jsx(ze,{icon:!0,message:"Content of this file cannot be viewed."}):Ya(t)?e.jsx(ze,{icon:!0,message:"Image diffs are not available in mobile Changes yet."}):e.jsx(Ft,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:e.jsx(Pt,{original:r.original,modified:r.modified,language:n,fileName:t,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):e.jsx(ze,{loading:!0,message:"Loading diff..."}):e.jsx(ze,{icon:!0,message:"File is no longer changed",description:"Go back to Changes and refresh the list."})})]})},jt=Dt(()=>vt(()=>import("./DiffView-BxW6BuOC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53])).then(t=>({default:t.DiffView}))),jr=15e3,vr=40,wr=20,Cl=({isActive:t,chrome:r="desktop",initialDiffPath:c=null,initialDiffStaged:p=!1,gitHeaderSlot:m=null,onlyFilePath:o=null})=>{const{git:n}=qe(),s=Qa(),h=zs(l=>l.currentSessionId),g=Xa(s??null),d=Za(s??null),j=St(s??null),b=Ja(s??null),u=en(s??null)??[],w=sn(s??null),z=tn(s??null),R=an(s??null),{setActiveDirectory:M,fetchAll:_,ensureAll:U,fetchStatus:I,fetchBranches:L,fetchLog:B,fetchLogQuery:F,setLogMaxCount:T,prefetchDiffs:x,clearDiffCache:q,moveStatusPathsOptimistically:W,restoreStatus:J,bumpIndexRevision:Y}=kt($a(l=>({setActiveDirectory:l.setActiveDirectory,fetchAll:l.fetchAll,ensureAll:l.ensureAll,fetchStatus:l.fetchStatus,fetchBranches:l.fetchBranches,fetchLog:l.fetchLog,fetchLogQuery:l.fetchLogQuery,setLogMaxCount:l.setLogMaxCount,prefetchDiffs:l.prefetchDiffs,clearDiffCache:l.clearDiffCache,moveStatusPathsOptimistically:l.moveStatusPathsOptimistically,restoreStatus:l.restoreStatus,bumpIndexRevision:l.bumpIndexRevision})));a.useRef(null);const A=a.useRef(null),D=a.useRef(null),ae=a.useRef(null),ne=a.useRef(!0);a.useEffect(()=>()=>{ne.current=!1},[]);const re=a.useCallback(()=>{A.current!==null&&(window.clearTimeout(A.current),A.current=null)},[]),le=a.useCallback(l=>{re(),A.current=window.setTimeout(()=>{A.current=null,os(l)===os(s)&&I(l,n,{silent:!0})},jr)},[re,s,I,n]);a.useEffect(()=>re,[re]);const ee=a.useCallback(()=>{D.current!==null&&(window.clearTimeout(D.current),D.current=null)},[]),O=a.useCallback(()=>{D.current===null&&(D.current=window.setTimeout(()=>{D.current=null,ae.current?.()},0))},[]),N=a.useCallback(async(l,y,v)=>{if(y==="stage"){if(n.stageGitFiles){await n.stageGitFiles(l,v);return}await Promise.all(v.map(C=>n.stageGitFile(l,C)));return}if(n.unstageGitFiles){await n.unstageGitFiles(l,v);return}await Promise.all(v.map(C=>n.unstageGitFile(l,C)))},[n]),E=a.useMemo(()=>ur({runMutation:({directory:l,direction:y,paths:v})=>N(l,y,v),onMutationComplete:({directory:l})=>{Y(l),le(l)},onMutationError:({directory:l,direction:y,rollback:v},C)=>{v?.(),Y(l),le(l);const G=y==="stage"?"Failed to stage changes":"Failed to unstage changes";P.error(C instanceof Error?C.message:G)},onPathsComplete:l=>{Gs(y=>{const v=new Set(y);return l.forEach(C=>v.delete(C)),v})},scheduleFlush:O}),[Y,N,O,le]);a.useEffect(()=>(ae.current=E.flush,()=>{ae.current=null}),[E]),a.useEffect(()=>()=>E.clear(),[E]),a.useEffect(()=>ee,[ee]);const i=a.useMemo(()=>s?Qn(s):null,[s]),[$,k]=a.useState(i?.commitMessage??""),Q=a.useRef(null),[V,K]=a.useState(null),[ce,Ve]=a.useState(!1),[ms,Os]=a.useState(null),[ge,Gt]=a.useState(25),{triggerFireworks:_t}=cn(),[fs,Ke]=a.useState(new Set),[Ht,Gs]=a.useState(new Set),[ps,_s]=a.useState(!1),[Hs,qt]=a.useState([]),[Nr,Vt]=a.useState(0),[Ut,qs]=a.useState(!1),Vs=Ht.size>0||E.size()>0||E.isRunning();a.useCallback(()=>{const l=Q.current;l&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{l.scrollTo({top:l.scrollHeight,behavior:"smooth"})})})},[]);const{expandedCommitHashes:Wt,commitFilesMap:Kt,loadingCommitHashes:Yt,handleCopyCommitHash:Qt,handleToggleCommit:Xt}=sr(s,n),{conflictDialogOpen:Zt,setConflictDialogOpen:xe,conflictFiles:Jt,setConflictFiles:be,conflictOperation:Ye,setConflictOperation:ye,persistConflictState:je,clearConflictState:me}=dr({currentSessionId:h,currentDirectory:s}),[ea,gs]=a.useState(null),[sa,Qe]=a.useState([]),[ta,Xe]=a.useState(null),[aa,Ze]=a.useState(!1),[Je,na]=a.useState(100),[pe,es]=a.useState(null),[ra,Te]=a.useState(null),[la,xs]=a.useState(!1),[bs,Us]=a.useState("merge"),[ys,Ws]=a.useState("");a.useEffect(()=>{s&&Xn(s,{directory:s,commitMessage:$})},[$,s]),a.useEffect(()=>{t&&s&&(M(s),U(s,n))},[t,s,M,U,n]),a.useEffect(()=>{if(t&&s)return nn.onGitRefreshHint(l=>{os(l.directory)===os(s)&&(l.paths?.length&&q(s,l.paths),I(s,n,{silent:!0}))})},[t,q,s,I,n]);const te=a.useCallback(async(l=!0)=>{if(s)try{await Promise.all([I(s,n),L(s,n)])}catch(y){if(l){const v=y instanceof Error?y.message:"Failed to refresh repository";P.error(v)}}},[s,n,I,L]),ie=a.useCallback(async()=>{s&&await B(s,n,ge)},[s,n,B,ge]),de=a.useMemo(()=>d?[...d.files??[]].sort((y,v)=>y.path.localeCompare(v.path)):[],[d]),Se=a.useMemo(()=>de.filter(it),[de]),Ks=a.useMemo(()=>de.filter(mn),[de]);a.useEffect(()=>{if(!s||de.length===0)return;const l=[],y=new Set,v=G=>{!G||y.has(G)||(y.add(G),l.push(G))};if(Se.forEach(G=>v(G.path)),r==="mobile"&&Hs.forEach(v),de.slice(0,wr).forEach(G=>v(G.path)),l.length===0)return;const C=window.setTimeout(()=>{x(s,n,l,{maxFiles:vr})},120);return()=>{window.clearTimeout(C)}},[de,r,s,n,Hs,x,Se]);const Ys=l=>l?.pushed[0]?.remote||d?.tracking?.split("/")[0]||ve.find(y=>y.name==="origin")?.name||ve[0]?.name||"origin",js=async(l,y)=>{if(s){K(l);try{const v=C=>{const G=`${C.name}/`,X=d?.tracking?.startsWith(G)?d.tracking.slice(G.length):void 0;return{remote:C.name,branch:X,rebase:!0}};if(l==="fetch"){if(!y)throw new Error("No remote available for fetch");await n.gitFetch(s,{remote:y.name}),P.success(`Fetched from ${y.name}`)}else if(l==="pull"){if(!y)throw new Error("No remote available for pull");const C=await n.gitPull(s,v(y));P.success(C.files.length===1?`Pulled ${C.files.length} file from ${y.name}`:`Pulled ${C.files.length} files from ${y.name}`)}else if(l==="push"){const C=await n.gitPush(s);P.success(`Pushed to ${Ys(C)}`)}else if(l==="sync"){if(!y)throw new Error("No remote available for sync");let C=0,G=!1;await n.gitFetch(s,{remote:y.name});const X=await n.getGitStatus(s);if((X.behind??0)>0){if((X.files?.length??0)>0){P.error("Commit or stash your changes before syncing");return}C=(await n.gitPull(s,v(y))).files.length}((await n.getGitStatus(s)).ahead??0)>0&&(await n.gitPush(s),G=!0),C>0&&G?P.success(C===1?`Pulled ${C} file from ${y.name} and pushed to upstream`:`Pulled ${C} files from ${y.name} and pushed to upstream`):C>0?P.success(C===1?`Pulled ${C} file from ${y.name}`:`Pulled ${C} files from ${y.name}`):G?P.success(`Pushed to ${y.name}`):P.success("Already up to date")}await te(!1),await ie()}catch(v){const C=v instanceof Error?v.message:`${l==="sync"?"Sync changes":l==="pull"?"Pull":l} failed`;P.error(C)}finally{K(null)}}},ia=a.useCallback(async(l,y)=>{if(!s)throw new Error("No active directory");const v=await n.getGitFileDiff(s,{path:l,staged:y||void 0});return{original:v.original??"",modified:v.modified??"",isBinary:v.isBinary}},[s,n]),vs=async(l={})=>{if(!s)return;if(!$.trim()){P.error("Enter a commit message");return}const y=Se.map(C=>C.path).sort();if(y.length===0){P.error("Stage at least one file to commit");return}const v=l.pushAfter?"commitAndPush":"commit";Os(v);try{if(await n.createGitCommit(s,$.trim(),{files:y,stageFiles:[]}),Y(s),P.success("Commit created"),k(""),await te(),l.pushAfter){const C=d?.tracking?.split("/")[0],G=ve.find(Da=>Da.name===C)??ve[0];if(!G)throw new Error("No remote available");K("sync");const X=`${G.name}/`,oe=d?.tracking?.startsWith(X)?d.tracking.slice(X.length):void 0;await n.gitFetch(s,{remote:G.name});const Z=await n.getGitStatus(s);if((Z.behind??0)>0){if((Z.files?.length??0)>0){P.error("Commit or stash your changes before syncing"),await te(!1);return}await n.gitPull(s,{remote:G.name,branch:oe,rebase:!0})}const he=await n.getGitStatus(s);let Ge;(he.ahead??0)>0&&(Ge=await n.gitPush(s)),P.success(`Pushed to ${Ys(Ge)}`),r!=="mobile"&&_t(),await te(!1)}else await te(!1);await ie(),Vt(C=>C+1)}catch(C){const G=C instanceof Error?C.message:"Failed to create commit";P.error(G)}finally{Os(null),l.pushAfter&&K(null)}},Qs=async(l,y)=>{if(!s||!d)return;const v=d.current??null,C=y?.name??"origin";try{await n.createBranch(s,l,v??"HEAD"),P.success(`Created branch ${l}`),await n.checkoutBranch(s,l);let G=!1;try{await n.gitPush(s,{remote:C,branch:l,options:["--set-upstream"]}),G=!0}catch(X){const oe=X instanceof Error?X.message:`Unable to push new branch to ${C}.`;P.warning("Branch created locally, but failed to set upstream.",{description:e.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",oe]})})}await te(),await ie(),G&&P.success(`Set upstream for ${l} to ${C}`)}catch(G){const X=G instanceof Error?G.message:"Failed to create branch";throw P.error(X),G}},Xs=async(l,y)=>{if(s)try{await n.renameBranch(s,l,y),P.success(`Renamed ${l} to ${y}`),await te(),await ie()}catch(v){const C=v instanceof Error?v.message:`Failed to rename ${l} to ${y}`;P.error(C)}},Zs=async l=>{if(!s)return;const y=l.replace(/^remotes\//,"");if(d?.current!==y)try{await n.checkoutBranch(s,y),P.success(`Checked out ${y}`),await te(),await ie()}catch(v){const C=v instanceof Error?v.message:`Failed to checkout ${y}`;P.error(C)}},{localBranches:ws,remoteBranches:Ue,effectiveRemotes:ve,currentBranch:Ae,baseBranch:ss,branchScopeAvailable:Oe,updateTargetBranch:oa}=cr({branches:j,status:d,remotes:u,remoteUrl:w,git:n}),Js=Se.length,ca=z||V!==null||ms!==null,et=!!Ae;a.useEffect(()=>{if(!s||!n||!b?.all?.length||!Ae||!ss||!Oe){Te(null);return}let l=!1;return(async()=>{try{const v=await F(s,n,{from:ss,to:"HEAD",maxCount:ge});if(l)return;const C=new Set((v?.all??[]).map(X=>X.hash).filter(X=>typeof X=="string"&&X.length>0));if(C.size===0){Te(null);return}const G=b.all.findIndex(X=>!C.has(X.hash));if(G===0){Te(null);return}if(G===-1){Te({insertBeforeIndex:b.all.length,branchName:Ae,direction:"up"});return}Te({insertBeforeIndex:G,branchName:Ae,direction:"up"})}catch{l||Te(null)}})(),()=>{l=!0}},[ss,Oe,Ae,s,F,n,b,ge]),a.useEffect(()=>{Xe(null)},[s]),a.useEffect(()=>{if(pe!=="graph"||!s){pe!=="graph"&&Xe(null);return}let l=!1;return Ze(!0),F(s,n,{maxCount:Je,all:!0}).then(y=>{l||Xe(y)}).catch(y=>{console.error("Failed to fetch graph log:",y)}).finally(()=>{l||Ze(!1)}),()=>{l=!0}},[pe,s,Je,n,F]);const da=a.useCallback((l,y)=>{if(!s||l.length===0)return;const v=Array.from(new Set(l));Gs(G=>{const X=new Set(G);return v.forEach(oe=>X.add(oe)),X});const C=W(s,v,y);E.enqueue({directory:s,direction:y,paths:new Set(v),rollback:()=>J(s,C)}),O()},[s,E,W,J,O]),ua=a.useCallback(async l=>{if(s){Ke(y=>{const v=new Set(y);return v.add(l),v});try{await n.revertGitFile(s,l,{scope:"working"}),P.success(`Reverted ${l}`),await te(!1)}catch(y){const v=y instanceof Error?y.message:"Failed to revert changes";P.error(v)}finally{Ke(y=>{const v=new Set(y);return v.delete(l),v})}}},[s,te,n]),ts=a.useCallback(async(l,y,v="all")=>{if(!s||l.length===0)return;const C=Array.from(new Set(l));if(ps||C.some(Z=>fs.has(Z)))return;const G=new Set(Se.map(Z=>Z.path)),X=v==="all"&&C.some(Z=>G.has(Z));y&&_s(!0),Ke(Z=>{const he=new Set(Z);return C.forEach(Ge=>he.add(Ge)),he});const oe=[];try{if(await Promise.all(C.map(async Z=>{try{await n.revertGitFile(s,Z,{scope:v})}catch(he){oe.push({path:Z,message:he instanceof Error?he.message:"Failed to revert changes"})}})),X&&oe.length<C.length&&Y(s),await te(!1),oe.length===0)P.success(C.length===1?`Reverted ${C.length} file`:`Reverted ${C.length} files`);else if(oe.length===C.length)P.error(oe[0]?.message||"Failed to revert changes");else{const Z=C.length-oe.length;P.warning(Z===1?`Reverted ${Z} file, ${oe.length} failed`:`Reverted ${Z} files, ${oe.length} failed`)}}finally{Ke(Z=>{const he=new Set(Z);return C.forEach(Ge=>he.delete(Ge)),he}),y&&_s(!1)}},[Y,s,n,ps,te,fs,Se]),ha=a.useCallback(async l=>{await ts(l,!0)},[ts]);a.useCallback(async l=>{await ts(l,!1,"working")},[ts]);const ma=a.useCallback(()=>Ve(!0),[]),as=a.useCallback(l=>{const y=l instanceof Error?l.message.toLowerCase():"";return y.includes("uncommitted changes")||y.includes("local changes")||y.includes("your local changes would be overwritten")||y.includes("please commit your changes or stash them")||y.includes("cannot rebase: you have unstaged changes")||y.includes("error: cannot pull with rebase")},[]),ke=a.useCallback((l,y)=>{Qe(v=>[...v,{message:l,status:y,timestamp:Date.now()}])},[]),ue=a.useCallback((l,y)=>{Qe(v=>{if(v.length===0)return v;const C=[...v];return C[C.length-1]={...C[C.length-1],status:l,...y?{message:y}:{}},C})},[]),ns=a.useCallback(()=>{Qe([])},[]),fa=a.useCallback(()=>{Qe([]),gs(null)},[]),rs=a.useCallback(l=>{const y=l.trim(),v=new Set(ve.map(G=>G.name)),C=y.indexOf("/");if(C>0){const G=y.slice(0,C),X=y.slice(C+1);if(v.has(G)&&X)return{branch:y,remote:G,remoteBranch:X}}for(const G of ve){const X=`${G.name}/${y}`;if(Ue.includes(X))return{branch:X,remote:G.name,remoteBranch:y}}return{branch:y,remote:null,remoteBranch:null}},[ve,Ue]),pa=a.useCallback(async l=>{if(!s)return;gs("merge"),ns();const y=d?.current,v=rs(l);try{v.remote&&v.remoteBranch&&(ke(`Fetching ${v.remote}/${v.remoteBranch}...`,"running"),await n.gitFetch(s,{remote:v.remote,branch:v.remoteBranch}),ue("done",`Fetched ${v.remote}/${v.remoteBranch}`)),ke(`Merging ${v.branch} into ${y}...`,"running");const C=await n.merge(s,{branch:v.branch});C.conflict?(ue("error","Merge conflicts detected"),be(C.conflictFiles??[]),ye("merge"),xe(!0),je(s,C.conflictFiles??[],"merge")):(ue("done",`Merged ${v.branch} into ${y}`),me(),ke("Refreshing repository status...","running"),await te(),await ie(),ue("done","Repository status updated"))}catch(C){if(as(C))ue("error","Uncommitted changes detected"),Us("merge"),Ws(v.branch),xs(!0);else{const G=C instanceof Error?C.message:`Failed to merge ${v.branch}`;ue("error",G)}}},[s,n,d,rs,te,ie,as,je,me,ke,ue,ns]),ga=a.useCallback(async l=>{if(!s)return;gs("rebase"),ns();const y=d?.current,v=rs(l);try{v.remote&&v.remoteBranch&&(ke(`Fetching ${v.remote}/${v.remoteBranch}...`,"running"),await n.gitFetch(s,{remote:v.remote,branch:v.remoteBranch}),ue("done",`Fetched ${v.remote}/${v.remoteBranch}`)),ke(`Rebasing ${y} onto ${v.branch}...`,"running");const C=await n.rebase(s,{onto:v.branch});C.conflict?(ue("error","Rebase conflicts detected"),be(C.conflictFiles??[]),ye("rebase"),xe(!0),je(s,C.conflictFiles??[],"rebase")):(ue("done",`Rebased ${y} onto ${v.branch}`),me(),ke("Refreshing repository status...","running"),await te(),await ie(),ue("done","Repository status updated"))}catch(C){if(as(C))ue("error","Uncommitted changes detected"),Us("rebase"),Ws(v.branch),xs(!0);else{const G=C instanceof Error?C.message:`Failed to rebase onto ${v.branch}`;ue("error",G)}}},[s,n,d,rs,te,ie,as,je,me,ke,ue,ns]),xa=a.useCallback(async()=>{if(s)try{Ye==="merge"?(await n.abortMerge(s),P.success("Merge aborted")):(await n.abortRebase(s),P.success("Rebase aborted")),me(),await te(),await ie()}catch(l){const y=l instanceof Error?l.message:`Failed to abort ${Ye}`;P.error(y)}},[s,n,Ye,te,ie,me]),ba=a.useMemo(()=>d?.files?d.files.filter(l=>l.index==="U"||l.working_dir==="U"||l.index==="A"&&l.working_dir==="A"||l.index==="D"&&l.working_dir==="D").length:0,[d?.files]),ya=a.useCallback(async()=>{if(s)try{const l=!!d?.mergeInProgress?.head,y=!!(d?.rebaseInProgress?.headName||d?.rebaseInProgress?.onto);if(l){const v=await n.continueMerge(s);v.conflict?(be(v.conflictFiles??[]),ye("merge"),xe(!0),je(s,v.conflictFiles??[],"merge"),P.error("Merge conflicts detected")):(me(),P.success("Merge completed"),await te(),await ie())}else if(y){const v=await n.continueRebase(s);v.conflict?(be(v.conflictFiles??[]),ye("rebase"),xe(!0),je(s,v.conflictFiles??[],"rebase"),P.error("Rebase conflicts detected")):(me(),P.success("Rebase step completed"),await te(),await ie())}}catch(l){const y=l instanceof Error?l.message:"Failed to continue operation";P.error(y)}},[s,n,d,te,ie,je,me]),ja=a.useCallback(async()=>{if(s)try{!!d?.mergeInProgress?.head?(await n.abortMerge(s),P.success("Merge aborted")):(await n.abortRebase(s),P.success("Rebase aborted")),me(),await te(),await ie()}catch(l){const y=l instanceof Error?l.message:"Failed to abort operation";P.error(y)}},[s,n,d,te,ie,me]),va=a.useCallback(()=>{if(!s)return;const y=!!d?.mergeInProgress?.head?"merge":"rebase",v=d?.files?.filter(C=>C.index==="U"||C.working_dir==="U").map(C=>C.path)??[];v.length>0&&be(v),ye(y),xe(!0)},[s,d]),wa=a.useCallback(async l=>{if(!s)return;const y=d?.current,v=bs,C=ys,G=(d?.files??[]).some(it);try{await n.stash(s,{message:`Auto-stash before ${v} with ${C}`,includeUntracked:!0}),G&&Y(s)}catch(Z){const he=Z instanceof Error?Z.message:"Failed to stash changes";P.error(he);return}let X=!1,oe=!1;try{if(v==="merge"){const Z=await n.merge(s,{branch:C});Z.conflict?(oe=!0,be(Z.conflictFiles??[]),ye("merge"),xe(!0)):(X=!0,P.success(`Merged ${C} into ${y||""}`))}else{const Z=await n.rebase(s,{onto:C});Z.conflict?(oe=!0,be(Z.conflictFiles??[]),ye("rebase"),xe(!0)):(X=!0,P.success(`Rebased ${y||""} onto ${C}`))}if(l&&X)try{await n.stashPop(s),Y(s),P.success("Stashed changes restored")}catch(Z){const he=Z instanceof Error?Z.message:"Failed to restore stash";P.error(he)}else l&&oe&&P.info("Stash restored manually required");await te(),await ie()}catch(Z){if(l)try{await n.stashPop(s),Y(s)}catch{}throw Z}},[Y,s,n,d,bs,ys,te,ie]),Na=a.useCallback(l=>{Gt(l),s&&(T(s,l),B(s,n,l))},[s,B,n,T]),Ca=a.useCallback(l=>{na(l)},[]),Sa=a.useCallback(()=>{es(null),s&&(I(s,n),L(s,n),B(s,n,ge))},[s,I,L,B,ge,n]),ka=a.useCallback(l=>{if(l.conflict){if(l.operation==="cherry-pick"||l.operation==="revert"){P.error("Conflict",{description:`Conflicts in: ${l.conflictFiles?.join(", ")??"unknown files"}. Resolve manually and commit, or abort with git cherry-pick/revert --abort.`}),s&&(I(s,n),L(s,n),B(s,n,ge));return}be(l.conflictFiles??[]),ye(l.operation),xe(!0),s&&je(s,l.conflictFiles??[],l.operation)}},[be,ye,xe,je,s,I,L,B,ge,n]),[st,tt]=a.useState(()=>de.length>0?"all":"branch"),[Ra,Ea]=a.useState(null),ls=`${s??""}:${de.length>0?"nonempty":"empty"}`,at=a.useRef(ls);a.useEffect(()=>{at.current!==ls&&(at.current=ls,tt(de.length>0?"all":"branch"))},[de.length,ls]);const nt=a.useCallback(l=>{tt(l)},[]),za=a.useCallback(l=>{Ea(l)},[]),Ns=g===!0&&d?e.jsx(Cn,{status:d,localBranches:ws,remoteBranches:Ue,branchInfo:j?.branches,syncAction:V,remotes:ve,onFetch:l=>js("fetch",l),onSync:l=>js("sync",l),onCheckoutBranch:Zs,onCreateBranch:Qs,onRenameBranch:Xs,isWorktreeMode:!1,upstreamTarget:d.upstreamComparison?`${d.upstreamComparison.remote}/${d.upstreamComparison.branch}`:null,onOpenHistory:()=>es("history"),onOpenGraph:()=>es("graph"),onOpenStashes:ma,onOpenUpdateBranch:et?()=>qs(!0):void 0,diffScope:st,onDiffScopeChange:nt,allCount:de.length,workingCount:Ks.length,stagedCount:Js,branchAvailable:Oe,diffHeaderState:Ra}):null,Fa=Ns?m?Pa.createPortal(e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:Ns}),m):e.jsx("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border px-2",children:Ns}):null;return r==="mobile"?e.jsx(br,{currentDirectory:s??null,status:d,isGitRepo:g,isLoadingStatus:z,changeEntries:de,stagedChangeEntries:Se,unstagedChangeEntries:Ks,effectiveRemotes:ve,syncAction:V,localBranches:ws,remoteBranches:Ue,branchInfo:j?.branches,isWorktreeMode:!1,onCheckoutBranch:Zs,onCreateBranch:Qs,onRenameBranch:Xs,commitAction:ms,commitMessage:$,hasPendingIndexMutation:Vs,revertingPaths:fs,isRevertingAll:ps,initialDiffPath:c,initialDiffStaged:p,onSyncAction:(l,y)=>{js(l,y)},onMoveChangePaths:da,onRevertFile:l=>{ua(l)},onRevertAll:ha,onCommitMessageChange:k,onCommit:l=>{vs(l)},onVisiblePathsChange:qt,loadDiff:ia}):s?g===null||g===!0&&!d?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-ui-label",children:"Checking repository..."})]})}):g===!1?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(jt,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,toolbarSlot:m})})}):e.jsxs("div",{className:se("flex h-full flex-col overflow-hidden"),children:[Fa,s&&d?e.jsx(Pn,{directory:s,branch:d.current??null,hasUpstream:d.tracking!=null}):null,s&&(d?.mergeInProgress?.head||d?.rebaseInProgress?.headName||d?.rebaseInProgress?.onto)&&e.jsx(er,{mergeInProgress:d?.mergeInProgress,rebaseInProgress:d?.rebaseInProgress,onContinue:ya,onAbort:ja,onResolveWithAI:va,conflictCount:ba,isLoading:z}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:(de?.length??0)>0||Oe?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(jt,{diffScope:st,onDiffScopeChange:nt,branchBase:Oe?ss:null,branchHead:Oe?Ae:null,showOpenInEditorAction:!0,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,hideToolbar:!0,onlyFilePath:o,onHeaderControlsStateChange:za})})}),de.length>0?e.jsx("div",{ref:Q,className:"shrink-0 px-4 pb-4 pt-2",children:e.jsx(At,{stagedCount:Js,commitMessage:$,onCommitMessageChange:k,onCommit:()=>vs({pushAfter:!1}),onCommitAndPush:()=>vs({pushAfter:!0}),commitAction:ms,hasPendingIndexMutation:Vs})}):null]}):e.jsx(Jn,{onOpenStashes:()=>Ve(!0)})})}),e.jsx(Kn,{currentDirectory:s,isUpdateBranchDialogOpen:Ut,setIsUpdateBranchDialogOpen:qs,branchOperation:ea,currentBranch:d?.current,localBranches:ws,remoteBranches:Ue,updateTargetBranch:oa,onMerge:pa,onRebase:ga,isBusy:ca,operationLogs:sa,onOperationComplete:fa,canShowBranchWorkflows:et,gitLogDialogMode:pe,setGitLogDialogMode:es,onRefreshHistory:()=>{if(pe==="graph"){if(!s)return;Ze(!0),F(s,n,{maxCount:Je,all:!0},{force:!0}).then(l=>{ne.current&&l&&Xe(l)}).catch(l=>{console.error("Failed to refresh graph log:",l)}).finally(()=>{ne.current&&Ze(!1)});return}s&&B(s,n,ge)},isLogRefreshing:pe==="graph"?aa:R,log:pe==="graph"?ta??b:b,maxCount:pe==="graph"?Je:ge,onMaxCountChange:pe==="graph"?Ca:Na,expandedCommitHashes:Wt,onToggleCommit:Xt,commitFilesMap:Kt,loadingCommitHashes:Yt,onCopyHash:Qt,historyBranchDivider:ra,onConflict:pe==="graph"?ka:void 0,onActionSuccess:pe==="graph"?Sa:void 0,isStashesDialogOpen:ce,setIsStashesDialogOpen:Ve,hasUncommittedChanges:(d?.files?.length??0)>0,hasStagedChanges:Se.length>0,uncommittedFileCount:d?.files?.length??0,onStashesChanged:async l=>{s&&l?.affectsIndex&&Y(s),await te(!1),await ie()},conflictDialogOpen:Zt,setConflictDialogOpen:xe,conflictFiles:Jt,conflictOperation:Ye,onAbortConflict:xa,onClearConflictState:me,stashDialogOpen:la,setStashDialogOpen:xs,stashDialogOperation:bs,stashDialogBranch:ys,onConfirmStashAndRetry:wa})]}):e.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"Select a session or directory to view Git status"})})};export{Cl as GitView};
|
|
8
|
+
Inspect each conflicted file and both sides of every conflict. Report a concise per-file resolution strategy and any assumptions or tradeoffs. Wait for explicit user confirmation before editing, staging, or running ${W}. After confirmation, remove all conflict markers, preserve intent from both sides, verify syntax, and complete the ${x}.`,T=`${x} conflict context (JSON)
|
|
9
|
+
${JSON.stringify({directory:p,operation:w.operation,headInfo:w.headInfo,statusPorcelain:w.statusPorcelain,unmergedFiles:w.unmergedFiles,diff:w.diff},null,2)}`;return{visibleText:J,instructionsText:Y,payloadText:T}},[w,p,m]),U=()=>{o(),r(!1)},I=()=>{n?.(),r(!1)},L=async()=>{const x=await _();if(!x){P.error("No conflict details available");return}if(!g){P.error("No active session",{description:"Open or create a session to resolve conflicts."});return}d(x.visibleText,"replace"),j([{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]),b("chat"),n?.(),r(!1)},B=async()=>{const x=await _();if(!x){P.error("No conflict details available");return}h({directoryOverride:p,initialPrompt:x.visibleText,syntheticParts:[{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]}),b("chat"),n?.(),r(!1)},F=m==="merge"?"Merge":"Rebase",A=w?.unmergedFiles||c;return e.jsx(Fe,{open:t,onOpenChange:r,children:e.jsx(De,{className:"max-w-md w-[calc(100vw-2rem)]",children:e.jsxs("div",{className:"flex flex-col gap-4 overflow-hidden",children:[e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e.jsx($e,{children:`${F} conflicts detected`})]}),e.jsx(Pe,{children:`Resolve the ${m} conflicts to continue.`})]}),f&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-meta",children:"Loading conflict details..."})]}),R&&e.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:`Failed to load conflict details: ${R}`}),A.length>0&&e.jsxs("div",{className:"space-y-2 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Conflicted files:"}),e.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:A.length})]}),e.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:e.jsx("ul",{className:"space-y-1",children:A.map(x=>e.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:x,children:x},x))})})]}),w?.headInfo&&e.jsxs("div",{className:"space-y-1 overflow-hidden",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"HEAD information:"}),e.jsx("div",{className:"typography-code text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:w.headInfo})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[e.jsxs(H,{variant:"default",onClick:()=>{B()},disabled:f||!w,className:"w-full gap-2",children:[f?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"add",className:"size-4"}),"Resolve in new session"]}),e.jsxs(H,{variant:"outline",onClick:()=>{L()},disabled:f||!w||!g,className:"w-full gap-2",children:[f?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"chat-1",className:"size-4"}),"Resolve in current session"]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(H,{variant:"ghost",size:"sm",onClick:I,className:"flex-1",children:"Continue later"}),e.jsx(H,{variant:"destructive",size:"sm",onClick:U,className:"flex-1",children:`Abort ${F}`})]})]})]})})})},Re=8,Ln=({laned:t,totalLanes:r,isExpanded:c})=>{const{lane:p,color:m,connectors:o}=t,s=Math.max(r,p+1)*Re+Re/2,h=a.useRef(null),g=a.useRef(null);return a.useLayoutEffect(()=>{const d=h.current,j=g.current;if(!d||!j)return;const b=d.offsetHeight;if(b===0)return;const f=window.devicePixelRatio||1;j.width=s*f,j.height=b*f;const u=j.getContext("2d");if(!u)return;u.scale(f,f),u.clearRect(0,0,s,b);const w=b/2,z=p*Re+Re/2,R=getComputedStyle(j),M=R.getPropertyValue("--surface-muted-foreground").trim()||R.color,_=L=>{if(!L.startsWith("var("))return L;const B=L.slice(4,-1).trim();return R.getPropertyValue(B).trim()||M},U=[...o].sort((L,B)=>{const F=A=>A==="branch-out"||A==="merge-in";return(F(L.type)?1:0)-(F(B.type)?1:0)});for(const L of U){const B=L.fromLane*Re+Re/2,F=L.toLane*Re+Re/2,A=L.type==="passing"?.72:L.type==="branch-out"||L.type==="merge-in"?.95:1;switch(u.beginPath(),u.strokeStyle=_(L.color),u.globalAlpha=A,u.lineWidth=1.25,u.lineCap="round",L.type){case"passing":case"commit-lane":u.moveTo(B,0),u.lineTo(B,b);break;case"top-stub":u.moveTo(B,0),u.lineTo(B,w);break;case"bottom-stub":u.moveTo(B,w),u.lineTo(B,b);break;case"branch-out":{const x=(w+b)/2;u.moveTo(z,w),u.bezierCurveTo(z,x,F,x,F,b);break}case"merge-in":{const x=w/2;u.moveTo(B,0),u.bezierCurveTo(B,x,z,x,z,w);break}default:continue}u.stroke(),u.globalAlpha=1}const I=R.getPropertyValue("--background").trim()||R.getPropertyValue("--surface-background").trim();u.beginPath(),u.arc(z,w,4,0,Math.PI*2),u.fillStyle=_(m),u.fill(),u.beginPath(),u.arc(z,w,5,0,Math.PI*2),u.strokeStyle=I||M,u.lineWidth=2,u.stroke()},[t,p,m,o,r,c,s]),e.jsx("div",{ref:h,style:{width:s,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},children:e.jsx("canvas",{ref:g,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}})})},ct=15e3,dt=500,ut=12,ht=8*1024*1024,mt=t=>typeof t=="string"?0:(t.original?.length??0)+(t.modified?.length??0),ft=t=>{if(t.size<=ut){let m=0;for(const o of t.values())m+=mt(o);if(m<=ht)return t}const r=Array.from(t.entries()).reverse(),c=new Map;let p=0;for(const[m,o]of r){if(c.size>=ut)continue;const n=mt(o);p+n>ht&&c.size>0||(c.set(m,o),p+=n)}return new Map(Array.from(c.entries()).reverse())};function pt(t,r){const c=new Date(t);return Number.isNaN(c.getTime())?t:Aa(c,r,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function In(t){switch(t){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}function An(t){return t?t.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{const c=r.startsWith("HEAD ->");return{label:c?r.replace("HEAD -> ",""):r.replace("tag: ",""),isHead:c,isTag:r.startsWith("tag: ")}}):[]}const Tn=a.memo(({entry:t,mode:r="history",laned:c,totalLanes:p,isExpanded:m,onToggle:o,files:n,isLoadingFiles:s,onCopyHash:h,directory:g,onConflict:d,onActionSuccess:j})=>{const{git:b}=qe(),f=As(i=>i.timeFormatPreference),u=r==="graph",w={checkout:"Check out this commit as detached HEAD?",cherryPick:"Cherry-pick this commit onto the current branch?",revert:"Stage a revert of this commit?",merge:"Merge this commit into the current branch?",rebase:"Rebase current branch onto this commit?",resetSoft:"Soft reset — HEAD moves, staged changes preserved.",resetMixed:"Mixed reset — HEAD moves, changes unstaged.",resetHard:"Hard reset — HEAD moves, all uncommitted changes permanently discarded."},z={soft:"Soft — keep staged",mixed:"Mixed — unstage changes",hard:"Hard — discard all changes"},[R,M]=a.useState(null),[_,U]=a.useState(!1),[I,L]=a.useState(""),[B,F]=a.useState(null),[A,x]=a.useState(new Set),[q,W]=a.useState(new Map),[J,Y]=a.useState(new Set),T=async()=>{if(g){M("checkout");try{await b.checkoutCommit(g,t.hash),P.success("Checked out (detached HEAD)"),j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},D=async()=>{if(!(!g||!I.trim())){M("createBranch");try{await b.createBranch(g,I.trim(),t.hash),U(!1),L(""),j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},ae=async()=>{if(g){M("cherryPick");try{const i=await b.cherryPick(g,t.hash);i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"cherry-pick"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},ne=async()=>{if(g){M("revert");try{const i=await b.revertCommit(g,t.hash);i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"revert"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},re=async(i,$=!1)=>{if(!(!g||R!==null)){M("reset");try{await b.resetToCommit(g,t.hash,i,$),j?.()}catch(k){P.error(String(k.message))}finally{M(null)}}},le=async()=>{if(!B)return;const i=B;switch(F(null),i){case"checkout":return T();case"cherryPick":return ae();case"revert":return ne();case"merge":return ee();case"rebase":return O();case"resetSoft":return re("soft");case"resetMixed":return re("mixed");case"resetHard":return re("hard",!0)}},ee=async()=>{if(g){M("merge");try{const i=await b.merge(g,{branch:t.hash});i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"merge"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},O=async()=>{if(g){M("rebase");try{const i=await b.rebase(g,{onto:t.hash});i.conflict?d?.({conflict:!0,conflictFiles:i.conflictFiles,operation:"rebase"}):j?.()}catch(i){P.error(String(i.message))}finally{M(null)}}},N=a.useCallback(async i=>{const $=i.path;if(!g){W(k=>new Map(k).set($,"error"));return}W(k=>ft(new Map(k).set($,"loading")));try{const Q=(b.getCommitFileDiff??dn)(g,t.hash,i.path,!1),V=new Promise((ce,Ve)=>{setTimeout(()=>Ve(new Error(`Timed out after ${ct}ms`)),ct)}),K=await Promise.race([Q,V]);W(ce=>ft(new Map(ce).set($,K)))}catch{W(k=>new Map(k).set($,"error"))}},[g,t.hash,b.getCommitFileDiff]),E=a.useCallback(async i=>{const $=i.path;if(i.changeType==="R"||i.isBinary){x(K=>{const ce=new Set(K);return ce.has($)?ce.delete($):ce.add($),ce});return}const k=q.get($);if(A.has($)&&k&&k!=="error"){x(K=>{const ce=new Set(K);return ce.delete($),ce});return}x(K=>{const ce=new Set(K);return ce.add($),ce}),!(k&&k!=="error"||i.insertions+i.deletions>dt&&!J.has($))&&await N(i)},[q,J,N,A]);return e.jsxs("li",{children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":m,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),o())},className:se("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",u?"hover:bg-[var(--interactive-hover)]/40":m?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[u&&c&&p!==void 0?e.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:e.jsx(Ln,{laned:c,totalLanes:p,isExpanded:m})}):e.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[u?(()=>{const i=An(t.refs);return i.length>0?e.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:i.map($=>e.jsx("span",{className:se("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",$.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":$.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:$.label},$.label))}):null})():null,e.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:t.message}),e.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[e.jsx("span",{className:"truncate min-w-[3ch]",title:t.author_name,children:t.author_name}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("span",{className:"truncate min-w-0",title:pt(t.date,f),children:pt(t.date,f)})]}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("code",{className:"shrink-0 font-mono",children:t.hash.slice(0,8)}),e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(H,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:i=>{i.stopPropagation(),h(t.hash)},children:e.jsx(S,{name:"file-copy",className:"size-3"})})}),e.jsx(Ce,{sideOffset:8,children:"Copy SHA"})]})]})]})]}),m&&e.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[u&&B?e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[e.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:w[B]}),e.jsxs(H,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:R!==null,onClick:i=>{i.stopPropagation(),le()},children:[R!==null?e.jsx(S,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Confirm"]}),e.jsx(H,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:R!==null,onClick:i=>{i.stopPropagation(),F(null)},children:"Cancel"})]}):u?e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("checkout")},children:"Checkout"}),_?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:I,onChange:i=>L(i.target.value),onKeyDown:i=>{i.key==="Enter"&&D(),i.key==="Escape"&&(U(!1),L(""))},placeholder:"Branch name",className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),e.jsxs(H,{variant:"outline",size:"xs",className:"h-6",disabled:!I.trim()||R!==null,onClick:i=>{i.stopPropagation(),D()},children:[R==="createBranch"?e.jsx(S,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Create"]})]}):e.jsx(H,{variant:"outline",size:"xs",className:"h-6",onClick:i=>{i.stopPropagation(),U(!0)},children:"Create branch here"}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("cherryPick")},children:"Cherry-pick"}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("revert")},children:"Revert"}),e.jsxs(Be,{children:[e.jsx(Le,{asChild:!0,children:e.jsxs(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>i.stopPropagation(),children:[R==="reset"?e.jsx(S,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Reset..."]})}),e.jsx(Ie,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(i=>e.jsx(fe,{disabled:R!==null,onSelect:$=>{$.stopPropagation(),F(`reset${i.charAt(0).toUpperCase()+i.slice(1)}`)},children:z[i]},i))})]}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("merge")},children:"Merge into current"}),e.jsx(H,{variant:"outline",size:"xs",className:"h-6",disabled:R!==null,onClick:i=>{i.stopPropagation(),F("rebase")},children:"Rebase onto this"})]}):null,s?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading files..."})]}):n.length===0?e.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:"No files"}):e.jsx("ul",{className:"space-y-0.5 py-2",children:n.map(i=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>E(i),className:se("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",A.has(i.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[e.jsx("span",{className:se("font-semibold w-3 text-center shrink-0",In(i.changeType)),children:i.changeType}),e.jsx("span",{className:"truncate text-foreground min-w-0",title:i.path,children:i.path}),!i.isBinary&&e.jsxs("span",{className:"shrink-0",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i.insertions]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",i.deletions]})]}),i.isBinary&&e.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:"Binary"}),e.jsx(S,{name:A.has(i.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),A.has(i.path)&&e.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:i.changeType==="R"?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Renamed file — diff not supported"}):i.isBinary?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Binary file — no diff available"}):(()=>{const $=i.insertions+i.deletions;if(!J.has(i.path)&&$>dt)return e.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${$} changed lines)`}),e.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),e.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{Y(Q=>new Set(Q).add(i.path)),N(i)},children:"Render anyway"})]});const k=q.get(i.path);return k==="loading"||k===void 0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Loading diff..."}):k==="error"?e.jsx("button",{type:"button",onClick:()=>E(i),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:"Failed to load diff. Click to retry."}):e.jsx(Pt,{original:k.original,modified:k.modified,language:Et(i.path)||"",fileName:i.path,renderSideBySide:!1,layout:"inline"})})()})]},i.path))})]})]})}),gt=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)","var(--syntax-keyword)","var(--syntax-string)","var(--status-info)"];function cs(t){return gt[t%gt.length]}function On(t){if(t.length===0)return[];const r=[],c=[];for(let p=0;p<t.length;p++){const m=t[p],o=[];for(let f=0;f<r.length;f++)r[f]===m.hash&&o.push(f);let n=o.length>0?o[0]:-1;if(n===-1){const f=r.indexOf(null);f!==-1?n=f:(n=r.length,r.push(null))}const s=o.slice(1),h=cs(n),g=r[n]===m.hash,d=m.parents.length>0;d?r[n]=m.parents[0]:r[n]=null;const j=[];for(let f=1;f<m.parents.length;f++){const u=m.parents[f],w=r.indexOf(u);if(w!==-1)j.push(w);else{const z=r.indexOf(null),R=z!==-1?z:r.length;r[R]=u,R===r.length&&r.push(u),j.push(R)}}const b=[];g&&d?b.push({fromLane:n,toLane:n,color:h,type:"commit-lane"}):g&&!d?b.push({fromLane:n,toLane:n,color:h,type:"top-stub"}):!g&&d&&b.push({fromLane:n,toLane:n,color:h,type:"bottom-stub"});for(const f of s)b.push({fromLane:f,toLane:n,color:cs(f),type:"merge-in"}),r[f]=null;for(const f of j)b.push({fromLane:n,toLane:f,color:cs(f),type:"branch-out"});for(let f=0;f<r.length;f++)r[f]!==null&&f!==n&&(j.includes(f)||b.push({fromLane:f,toLane:f,color:cs(f),type:"passing"}));c.push({commit:m,lane:n,color:h,connectors:b})}return c}const Gn=[{label:"25 commits",value:25},{label:"50 commits",value:50},{label:"100 commits",value:100}],_n=({mode:t="history",log:r,isLogLoading:c,logMaxCount:p,onLogMaxCountChange:m,expandedCommitHashes:o,onToggleCommit:n,commitFilesMap:s,loadingCommitHashes:h,onCopyHash:g,directory:d,showHeader:j=!0,contentMaxHeightClassName:b="max-h-[50vh]",branchDivider:f=null,onConflict:u,onActionSuccess:w})=>{const[z,R]=a.useState(!0),M=t==="graph",_=a.useMemo(()=>M&&r?On(r.all):[],[M,r]),U=a.useMemo(()=>Math.max(1,..._.map(T=>T.lane+1)),[_]),I=a.useMemo(()=>new Map(_.map(T=>[T.commit.hash,T])),[_]);if(!r)return null;const L=f!==null&&f.insertBeforeIndex>0&&f.insertBeforeIndex<r.all.length,B=f!==null&&f.insertBeforeIndex===r.all.length,F=L||B,A=L?r.all.slice(0,f.insertBeforeIndex):B?r.all:[],x=L?r.all.slice(f.insertBeforeIndex):[],q=f?.direction==="down"?e.jsx(S,{name:"arrow-down-s",className:"size-3.5"}):e.jsx(S,{name:"arrow-up",className:"size-3.5"}),W=T=>e.jsx("ul",{className:"divide-y divide-border/60",children:T.map(D=>e.jsx(Tn,{entry:D,mode:t,laned:M?I.get(D.hash):void 0,totalLanes:M?U:void 0,isExpanded:o.has(D.hash),onToggle:()=>n(D.hash),files:s.get(D.hash)??[],isLoadingFiles:h.has(D.hash),onCopyHash:g,directory:d,onConflict:u,onActionSuccess:w},D.hash))}),J=r.all.length>=p?e.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:e.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(p+25),disabled:c,className:"px-3 text-muted-foreground hover:text-foreground",children:c?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{name:"loader-4",className:"size-3 animate-spin"}),"Loading..."]}):"Load more"})}):null,Y=e.jsx(Ta,{outerClassName:`min-h-0 ${b}`,className:"h-full w-full",children:r.all.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"No commits found"})}):F&&f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-0",children:[A.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:W(A)}):null,e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60"}),e.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"truncate",title:f.branchName,children:f.branchName}),q]}),e.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),x.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:W(x)}):null]}),J]}):e.jsxs(e.Fragment,{children:[W(r.all),J]})});return j?e.jsxs(bn,{open:z,onOpenChange:R,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[e.jsxs(yn,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"History"}),e.jsxs("div",{className:"flex items-center gap-2",children:[z&&e.jsx("div",{onClick:T=>T.stopPropagation(),onPointerDown:T=>T.stopPropagation(),children:e.jsxs(Oa,{value:String(p),onValueChange:T=>m(Number(T)),disabled:c,children:[e.jsx(Ga,{size:"sm",className:"w-auto",disabled:c,children:e.jsx(_a,{placeholder:"Commits"})}),e.jsx(Ha,{children:Gn.map(T=>e.jsx(qa,{value:String(T.value),children:T.label},T.value))})]})}),z?e.jsx(S,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):e.jsx(S,{name:"arrow-down-s",className:"size-4 text-muted-foreground"})]})]}),e.jsx(jn,{children:Y})]}):F?e.jsx("section",{className:"h-full min-h-0",children:Y}):e.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:Y})},Hn=a.memo(function({mode:r,onOpenChange:c,onRefresh:p,isRefreshing:m,log:o,maxCount:n,onMaxCountChange:s,expandedCommitHashes:h,onToggleCommit:g,commitFilesMap:d,loadingCommitHashes:j,onCopyHash:b,directory:f,branchDivider:u,onConflict:w,onActionSuccess:z}){return r?e.jsx(Fe,{open:r!==null,onOpenChange:c,children:e.jsxs(De,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx($e,{children:r==="graph"?"Graph":"History"}),e.jsxs(H,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:p,disabled:m,title:"Refresh","aria-label":"Refresh",children:[e.jsx(S,{name:"refresh",className:se("size-4",m&&"animate-spin")}),"Refresh"]})]}),e.jsx(Pe,{children:"Browse recent commits and inspect changed files."})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(_n,{mode:r==="graph"?"graph":"history",log:o,isLogLoading:m,logMaxCount:n,onLogMaxCountChange:s,expandedCommitHashes:h,onToggleCommit:g,commitFilesMap:d,loadingCommitHashes:j,onCopyHash:b,directory:f,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:r==="graph"?null:u,onConflict:r==="graph"?w:void 0,onActionSuccess:r==="graph"?z:void 0})})]})}):null}),qn=({open:t,onOpenChange:r,operation:c,targetBranch:p,onConfirm:m})=>{const[o,n]=a.useState(!0),[s,h]=a.useState(!1),g=c==="merge"?"Merge":"Rebase",d=async()=>{h(!0);try{await m(o),r(!1)}catch(b){const f=b instanceof Error?b.message:`Failed to ${c}`;P.error(f)}finally{h(!1)}},j=()=>{s||r(!1)};return e.jsx(Fe,{open:t,onOpenChange:s?void 0:r,children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),e.jsx($e,{children:"Uncommitted changes"})]}),e.jsx(Pe,{children:`Stash your local changes before starting the ${c}.`})]}),e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:"This will:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[e.jsx("li",{children:"Stash your uncommitted changes"}),e.jsxs("li",{children:[c==="merge"?"Merge":"Rebase"," ",c==="merge"?"with":"onto"," ",e.jsx("span",{className:"font-mono text-primary",children:p})]}),o&&e.jsx("li",{children:"Restore your stashed changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(Va,{checked:o,onChange:n,disabled:s,ariaLabel:"Restore stashed changes after operation"}),e.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!s&&n(!o),children:`Restore stashed changes after ${c}`})]}),e.jsxs(We,{className:"gap-2",children:[e.jsx(H,{variant:"ghost",size:"sm",onClick:j,disabled:s,children:"Cancel"}),e.jsx(H,{variant:"default",size:"sm",onClick:d,disabled:s,className:"gap-1.5",children:s?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),"Processing..."]}):`${g}`})]})]})})},Vn=({open:t,onOpenChange:r,directory:c,hasUncommittedChanges:p,hasStagedChanges:m=!1,uncommittedFileCount:o,onChanged:n})=>{const{git:s}=qe(),[h,g]=a.useState([]),[d,j]=a.useState(!1),[b,f]=a.useState(""),[u,w]=a.useState(""),[z,R]=a.useState(null),[M,_]=a.useState({}),U=a.useCallback(async()=>{if(c){j(!0);try{const x=await s.listGitStashes(c);g(x.stashes),_({})}catch(x){P.error(x instanceof Error?x.message:"Failed to load stashes")}finally{j(!1)}}},[c,s]);a.useEffect(()=>{t&&U()},[U,t]),a.useEffect(()=>{if(!t||!c||h.length===0)return;let x=!1;const q=h.map(W=>W.ref);return s.countGitStashFiles(c,q).then(W=>{x||_(W.counts)}).catch(()=>{}),()=>{x=!0}},[c,s,t,h]);const I=a.useMemo(()=>{const x=b.trim().toLowerCase();return x?h.filter(q=>`${q.ref} ${q.message} ${q.relativeTime}`.toLowerCase().includes(x)):h},[b,h]),L=a.useCallback(async x=>{await U(),await n?.(x)},[U,n]),B=async()=>{if(!(!c||z)){R("create");try{const x=await s.stashGitChanges(c,{message:u.trim()||void 0});x.created?(P.success("Changes stashed"),w("")):P.info("No local changes to stash"),await L({affectsIndex:!!(x.created&&m)})}catch(x){P.error(x instanceof Error?x.message:"Failed to stash changes")}finally{R(null)}}},F=async(x,q)=>{if(!(!c||z)&&!(q==="drop"&&!window.confirm(`Drop ${x.ref}?`))){R(`${q}:${x.ref}`);try{q==="apply"&&await s.applyGitStash(c,{ref:x.ref}),q==="pop"&&await s.popGitStash(c,{ref:x.ref}),q==="drop"&&await s.dropGitStash(c,{ref:x.ref});const W=q==="apply"?"Stash applied":q==="pop"?"Stash popped":"Stash dropped";P.success(W),await L({affectsIndex:q!=="drop"})}catch(W){const J=q==="apply"?"Failed to apply stash":q==="pop"?"Failed to pop stash":"Failed to drop stash";P.error(W instanceof Error?W.message:J),await L({affectsIndex:q!=="drop"})}finally{R(null)}}},A=z!==null;return e.jsx(Fe,{open:t,onOpenChange:r,children:e.jsxs(De,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs(Me,{children:[e.jsxs($e,{className:"flex items-center gap-2",children:[e.jsx(S,{name:"archive-stack",className:"h-5 w-5"}),"Stashes"]}),e.jsx(Pe,{children:"Save, restore, and clean up Git stashes for this repository."})]}),e.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(hs,{value:u,onChange:x=>w(x.target.value),placeholder:"Stash name",disabled:A||!p,className:"flex-1"}),e.jsxs(H,{onClick:B,disabled:!p||A||!c,children:[z==="create"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"inbox-archive",className:"size-4"}),`Stash ${o} files`]})]}),e.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:"Untracked files are included automatically."})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(S,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(hs,{value:b,onChange:x=>f(x.target.value),placeholder:"Search stashes",className:"pl-9"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:d?e.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:e.jsx(S,{name:"loader-4",className:"size-5 animate-spin"})}):I.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:b?"No matching stashes.":"No stashes yet."}):I.map((x,q)=>e.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[e.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[e.jsx("p",{className:"typography-small truncate text-foreground",children:x.message||"Untitled stash"}),e.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{children:q===0&&!b.trim()?"Latest":`#${q+1}`})}),e.jsx(Ce,{sideOffset:6,children:x.ref})]})," · ",x.relativeTime," · ",typeof M[x.ref]=="number"?`${M[x.ref]} files`:"counting files..."]})]}),e.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[e.jsx(Cs,{label:"Apply",loading:z===`apply:${x.ref}`,onClick:()=>F(x,"apply"),disabled:A,children:e.jsx(S,{name:"inbox-unarchive",className:"size-4"})}),e.jsx(Cs,{label:"Pop",loading:z===`pop:${x.ref}`,onClick:()=>F(x,"pop"),disabled:A,children:e.jsx(S,{name:"inbox-unarchive-fill",className:"size-4"})}),e.jsx(Cs,{label:"Drop",loading:z===`drop:${x.ref}`,onClick:()=>F(x,"drop"),disabled:A,destructive:!0,children:e.jsx(S,{name:"delete-bin",className:"size-4"})})]})]},x.ref))})]})})},Cs=({label:t,loading:r,disabled:c,destructive:p,onClick:m,children:o})=>e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,"aria-busy":r||void 0,className:se("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",p?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground"),onClick:m,disabled:c,children:r?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):o})}),e.jsx(Ce,{sideOffset:6,children:t})]}),Un=({currentBranch:t,localBranches:r,remoteBranches:c,onMerge:p,onRebase:m,disabled:o=!1,isOperating:n=!1,operationLogs:s=[],onOperationComplete:h,mode:g="dialog",defaultTargetBranch:d})=>{const[j,b]=a.useState(!1),[f,u]=a.useState("merge"),[w,z]=a.useState(null),[R,M]=a.useState(!1),[_,U]=a.useState(""),I=a.useRef(null),L=a.useRef(null),B=o||n,F=t||"current branch",A=s.length>0&&s.every(O=>O.status==="done"||O.status==="error"),x=s.some(O=>O.status==="error");a.useEffect(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[s]);const q=a.useMemo(()=>{const O=_.toLowerCase(),N=new Set(c.map(i=>i.slice(i.indexOf("/")+1)).filter(Boolean)),E=r.filter(i=>i!==t&&!N.has(i));return O?E.filter(i=>i.toLowerCase().includes(O)):E},[_,r,t,c]),W=a.useMemo(()=>{const O=_.toLowerCase();return O?c.filter(N=>N.toLowerCase().includes(O)):c},[_,c]),J=a.useCallback(()=>d&&(c.includes(d)||r.includes(d))?d:null,[d,r,c]),Y=()=>{b(!0),z(J()),u("merge"),U("")},T=O=>{z(O),M(!1),U("")},D=()=>{w&&(f==="merge"?p(w):m(w))},ae=()=>{n||(z(null),u("merge"),U(""),b(!1))},ne=()=>{n&&!A||(A&&h?.(),z(null),u("merge"),U(""),b(!1))};a.useEffect(()=>{R||U("")},[R]),a.useEffect(()=>{g==="dialog"||w||z(J())},[g,J,w]);const ee=n?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{ref:L,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:e.jsx("div",{className:"space-y-2",children:s.map((O,N)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"mt-0.5 shrink-0",children:[O.status==="running"&&e.jsx(S,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),O.status==="done"&&e.jsx(S,{name:"check",className:"size-3.5 text-success"}),O.status==="error"&&e.jsx(S,{name:"close",className:"size-3.5 text-destructive"}),O.status==="pending"&&e.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),e.jsx("span",{className:se("typography-micro",O.status==="error"&&"text-destructive",O.status==="done"&&"text-muted-foreground",O.status==="running"&&"text-foreground",O.status==="pending"&&"text-subtle-foreground"),children:O.message})]},N))})}),A?g==="dialog"?e.jsx(We,{children:e.jsx(H,{variant:"default",size:"sm",onClick:ne,children:x?"Close":"Done"})}):e.jsx("div",{className:"flex justify-end",children:e.jsx(H,{variant:"default",size:"sm",onClick:ne,children:x?"Close":"Done"})}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Operation"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>u("merge"),className:se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",f==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"git-merge",className:se("size-4",f==="merge"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:se("typography-ui-label",f==="merge"?"text-foreground":"text-muted-foreground"),children:"Merge"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Create a merge commit and preserve branch history."})]}),e.jsxs("button",{type:"button",onClick:()=>u("rebase"),className:se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",f==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{name:"git-branch",className:se("size-4",f==="rebase"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:se("typography-ui-label",f==="rebase"?"text-foreground":"text-muted-foreground"),children:"Rebase"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Replay your commits on top of the selected branch."})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:f==="merge"?`Branch to merge into ${F}`:"Branch to rebase onto"}),e.jsxs(Be,{open:R,onOpenChange:M,modal:!1,children:[e.jsx(Le,{asChild:!0,children:e.jsxs("button",{type:"button",className:se(Rt({size:"default"}),"w-full"),children:[e.jsx("span",{className:se("truncate",!w&&"text-muted-foreground"),children:w||"Select branch"}),e.jsx(S,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),e.jsx(Ie,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:e.jsxs($s,{className:"h-full min-h-0",children:[e.jsx(Ps,{ref:I,placeholder:"Search branches...",value:_,onValueChange:U,onKeyDown:O=>O.stopPropagation()}),e.jsxs(Bs,{className:"h-full min-h-0",disableHorizontal:!0,children:[e.jsx(Ls,{children:"No branches found."}),q.length>0&&e.jsx(He,{heading:"Local branches",children:q.map(O=>e.jsx(Ee,{onSelect:()=>T(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`local-${O}`))}),q.length>0&&W.length>0?e.jsx(Es,{}):null,W.length>0&&e.jsx(He,{heading:"Remote branches",children:W.map(O=>e.jsx(Ee,{onSelect:()=>T(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`remote-${O}`))})]})]})})]})]}),w?e.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:e.jsx("p",{className:"typography-meta text-muted-foreground",children:f==="merge"?e.jsxs(e.Fragment,{children:["This will merge"," ",e.jsx("span",{className:"font-mono text-foreground",children:w})," ","into"," ",e.jsx("span",{className:"font-mono text-foreground",children:F})]}):e.jsxs(e.Fragment,{children:["This will rebase"," ",e.jsx("span",{className:"font-mono text-foreground",children:F})," ","onto"," ",e.jsx("span",{className:"font-mono text-foreground",children:w})]})})}):null,g==="dialog"?e.jsxs(We,{className:"gap-2 pt-1",children:[e.jsx(H,{variant:"ghost",size:"sm",onClick:ae,children:"Cancel"}),e.jsx(H,{variant:"default",size:"sm",onClick:D,disabled:!w,className:"gap-1.5",children:f==="merge"?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"git-merge",className:"size-4"}),"Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"git-branch",className:"size-4"}),"Rebase"]})})]}):e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(H,{variant:"destructive",size:"sm",onClick:ae,disabled:B,children:"Reset"}),e.jsx("div",{className:"flex-1"}),e.jsx(H,{variant:"default",size:"sm",onClick:D,disabled:B||!w,children:f==="merge"?"Merge":"Rebase"})]})]});return g==="bare"?ee:g==="inline"?e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:"Update branch"}),e.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:F}),"."]})]})}),e.jsx("div",{className:"pt-3",children:ee})]}):e.jsxs(e.Fragment,{children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs(H,{variant:"outline",size:"sm",className:"gap-1.5",onClick:Y,disabled:B,children:[n?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"git-merge",className:"size-4"}),e.jsx("span",{children:"Merge/Rebase"})]})}),e.jsx(Ce,{sideOffset:8,children:"Update this branch from another branch."})]}),e.jsx(Fe,{open:j,onOpenChange:O=>{O?b(!0):ne()},children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Update branch"}),e.jsx(Pe,{children:n?A?x?"Operation failed":"Operation completed":f==="merge"?"Merging in progress":"Rebasing in progress":e.jsxs(e.Fragment,{children:["Choose how to bring another branch into"," ",e.jsx("span",{className:"font-mono text-foreground",children:F}),"."]})})]}),ee]})})]})},Wn=a.memo(function({open:r,onOpenChange:c,branchOperation:p,currentBranch:m,localBranches:o,remoteBranches:n,defaultTargetBranch:s,onMerge:h,onRebase:g,disabled:d,operationLogs:j,onOperationComplete:b,canShowBranchWorkflows:f}){return e.jsx(Fe,{open:r,onOpenChange:u=>{!u&&p!==null||c(u)},children:e.jsxs(De,{className:"max-w-2xl min-h-[26rem]",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Update branch"}),e.jsxs(Pe,{children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:m??""}),"."]})]}),f?e.jsx(Un,{mode:"bare",currentBranch:m,localBranches:o,remoteBranches:n,defaultTargetBranch:s??void 0,onMerge:h,onRebase:g,disabled:d,isOperating:p!==null,operationLogs:j,onOperationComplete:b}):e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Branch actions unavailable in this repository state"})]})})}),Kn=({currentDirectory:t,isUpdateBranchDialogOpen:r,setIsUpdateBranchDialogOpen:c,branchOperation:p,currentBranch:m,localBranches:o,remoteBranches:n,updateTargetBranch:s,onMerge:h,onRebase:g,isBusy:d,operationLogs:j,onOperationComplete:b,canShowBranchWorkflows:f,gitLogDialogMode:u,setGitLogDialogMode:w,onRefreshHistory:z,isLogRefreshing:R,log:M,maxCount:_,onMaxCountChange:U,expandedCommitHashes:I,onToggleCommit:L,commitFilesMap:B,loadingCommitHashes:F,onCopyHash:A,historyBranchDivider:x,onConflict:q,onActionSuccess:W,isStashesDialogOpen:J,setIsStashesDialogOpen:Y,hasUncommittedChanges:T,hasStagedChanges:D,uncommittedFileCount:ae,onStashesChanged:ne,conflictDialogOpen:re,setConflictDialogOpen:le,conflictFiles:ee,conflictOperation:O,onAbortConflict:N,onClearConflictState:E,stashDialogOpen:i,setStashDialogOpen:$,stashDialogOperation:k,stashDialogBranch:Q,onConfirmStashAndRetry:V})=>e.jsxs(e.Fragment,{children:[e.jsx(Wn,{open:r,onOpenChange:c,branchOperation:p,currentBranch:m,localBranches:o,remoteBranches:n,defaultTargetBranch:s,onMerge:h,onRebase:g,disabled:d,operationLogs:j,onOperationComplete:b,canShowBranchWorkflows:f}),e.jsx(Hn,{mode:u,onOpenChange:K=>{K||w(null)},onRefresh:z,isRefreshing:R,log:M,maxCount:_,onMaxCountChange:U,expandedCommitHashes:I,onToggleCommit:L,commitFilesMap:B,loadingCommitHashes:F,onCopyHash:A,directory:t??void 0,branchDivider:x,onConflict:q,onActionSuccess:W}),e.jsx(Vn,{open:J,onOpenChange:Y,directory:t,hasUncommittedChanges:T,hasStagedChanges:D,uncommittedFileCount:ae,onChanged:ne}),t&&e.jsx(Bn,{open:re,onOpenChange:le,conflictFiles:ee,directory:t,operation:O,onAbort:N,onClearState:E}),e.jsx(qn,{open:i,onOpenChange:$,operation:k,targetBranch:Q,onConfirm:V})]}),Yn=20,_e=new Map;function Qn(t){return _e.get(t)??null}function Xn(t,r){if(_e.delete(t),_e.set(t,r),_e.size>Yn){const c=_e.keys().next().value;c!==void 0&&_e.delete(c)}}const Ss=38,ds=200,Zn=({value:t,onChange:r,placeholder:c,disabled:p=!1,hasTouchInput:m=!1,isMobile:o=!1})=>{const n=a.useRef(null);return a.useLayoutEffect(()=>{const s=n.current;if(!s)return;const h=document.activeElement===s,g=()=>{s.style.height=`${Ss}px`;const j=s.scrollHeight,b=Math.min(Math.max(j,Ss),ds);s.style.height=`${b}px`,s.style.overflowY=j>ds?"auto":"hidden",j>ds&&!h&&(s.scrollTop=s.scrollHeight)};g();const d=window.requestAnimationFrame(g);return()=>{window.cancelAnimationFrame(d)}},[t]),e.jsx("textarea",{ref:n,value:t,onChange:s=>r(s.target.value),placeholder:c??"Commit message",rows:1,disabled:p,autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:o,className:se("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)]",p&&"opacity-50"),style:{minHeight:Ss,maxHeight:ds}})},Tt=({stagedCount:t,commitMessage:r,onCommitMessageChange:c,onCommit:p,onCommitAndPush:m,commitAction:o,hasPendingIndexMutation:n=!1})=>{const s=t>0,h=r.trim()&&s&&o===null&&!n,{isMobile:g,hasTouchInput:d}=Nt();return e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"Commit"}),s?null:e.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:"Stage files to enable commit."})]}),e.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[e.jsx(Zn,{value:r,onChange:c,placeholder:"Commit message",disabled:o!==null,hasTouchInput:d,isMobile:g}),e.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"flex-1"}),e.jsx(H,{size:"sm",variant:"outline",onClick:p,disabled:!h,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit",children:o==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),g?e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(H,{variant:"solid",size:"sm",onClick:()=>m(),disabled:!h,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:o==="commitAndPush"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(Ce,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(H,{size:"sm",variant:"solid",onClick:()=>m(),disabled:!h,className:"commit-actions__btn","aria-label":"Commit and sync",children:o==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Syncing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})},Jn=({onOpenStashes:t})=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[e.jsx(S,{name:"git-commit",className:"size-10 text-subtle-foreground mb-4"}),e.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:"Working tree clean"}),e.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:"All changes have been committed"}),t?e.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:t,className:"gap-1.5",children:[e.jsx(S,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null]}),er=({mergeInProgress:t,rebaseInProgress:r,onContinue:c,onAbort:p,onResolveWithAI:m,conflictCount:o=0,isLoading:n=!1})=>{const[s,h]=a.useState(null),g=t&&t.head,d=r&&(r.headName||r.onto),j=g?"merge":d?"rebase":null;if(!j)return null;const b=async()=>{h("continue");try{await c()}finally{h(null)}},f=async()=>{h("abort");try{await p()}finally{h(null)}},u=s!==null,w=o>0,z=j==="merge"?"Merge":"Rebase";let R="";t?R=t.message?`Merging: ${t.message}`:`Merging ${t.head}`:r&&(R=r.headName?`Rebasing ${r.headName} onto ${r.onto||""}`:"Rebase in progress");const M=w?o===1?`${z} in progress: ${o} conflict`:`${z} in progress: ${o} conflicts`:`${z} in progress`,_=w?"Resolve conflicts, then continue the operation.":"All conflicts resolved. Continue to finish the operation.";return e.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:M}),R&&e.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:R})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:_}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(H,{variant:"ghost",size:"sm",onClick:f,disabled:u||n,className:"gap-1.5",children:[s==="abort"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"close",className:"size-4"}),"Abort"]}),w?m&&e.jsx(H,{variant:"default",size:"sm",onClick:m,disabled:u||n,children:"Resolve with AI"}):e.jsxs(H,{variant:"default",size:"sm",onClick:b,disabled:u||n,className:"gap-1.5",children:[s==="continue"?e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(S,{name:"check",className:"size-4"}),"Continue"]})]})]})]})})};function sr(t,r){const[c,p]=a.useState(new Set),[m,o]=a.useState(new Map),[n,s]=a.useState(new Set),h=a.useRef(m),g=a.useRef(n),d=a.useCallback(b=>{Ua(b).then(f=>{if(f.ok){P.success("Commit hash copied");return}P.error("Failed to copy")})},[]),j=a.useCallback(b=>{p(f=>{const u=new Set(f);return u.has(b)?u.delete(b):u.add(b),u})},[]);return a.useEffect(()=>{h.current=m},[m]),a.useEffect(()=>{g.current=n},[n]),a.useEffect(()=>{if(!t||!r)return;const b=Array.from(c).filter(u=>!h.current.has(u)&&!g.current.has(u));if(b.length===0)return;let f=!1;return s(u=>{const w=new Set(u);for(const z of b)w.add(z);return g.current=w,w}),Promise.all(b.map(u=>r.getCommitFiles(t,u).then(w=>({hash:u,files:w.files})).catch(w=>(console.error("Failed to fetch commit files:",w),{hash:u,files:[]})))).then(u=>{f||(o(w=>{const z=new Map(w);for(const{hash:R,files:M}of u)z.set(R,M);return h.current=z,z}),s(w=>{const z=new Set(w);for(const{hash:R}of u)z.delete(R);return g.current=z,z}))}),()=>{f=!0,s(u=>{let w=!1;const z=new Set(u);for(const R of b)z.delete(R)&&(w=!0);return w?(g.current=z,z):u})}},[c,t,r]),{expandedCommitHashes:c,commitFilesMap:m,loadingCommitHashes:n,handleCopyCommitHash:d,handleToggleCommit:j}}const tr=t=>{const{remoteNames:r,localBranches:c,worktreeCreatedFromBranch:p,rootBranchHint:m,defaultBranch:o,headBranch:n}=t,s=typeof n=="string"?n.trim():"",h=f=>{if(!f)return"";let u=f.trim();if(!u||u==="HEAD")return"";if(c.includes(u))return u;u.startsWith("refs/heads/")&&(u=u.slice(11)),u.startsWith("heads/")&&(u=u.slice(6)),u.startsWith("remotes/")&&(u=u.slice(8));const w=u.indexOf("/");if(w>0){const z=u.slice(0,w);if(r.has(z)){const R=u.slice(w+1).trim();R&&(u=R)}}return u},g=f=>{const u=h(typeof f=="string"?f:"");return u&&u!==s?u:""},d=g(p);if(d)return d;const j=g(m);if(j)return j;const b=g(o);return b||(c.includes("main")?"main":c.includes("master")?"master":c.includes("develop")?"develop":"main")},ar=t=>{const{baseBranch:r,localBranches:c,remoteBranches:p}=t;return c.includes(r)?!0:p.some(m=>{const o=m.indexOf("/");return o>0&&m.slice(o+1)===r})},nr=t=>t?t.filter(r=>!r.startsWith("remotes/")).sort():[],rr=t=>t?t.filter(r=>r.startsWith("remotes/")).map(r=>r.replace(/^remotes\//,"")).sort():[],lr=(t,r,c,p)=>{if(t.length>0)return t;const m=new Set,o=c?.trim();o&&o.includes("/")&&m.add(o.split("/")[0]);for(const n of r){const s=n.indexOf("/");s>0&&m.add(n.slice(0,s))}return m.size===0&&p&&m.add("origin"),Array.from(m).map(n=>({name:n,fetchUrl:p??"",pushUrl:p??""}))},ir=(t,r)=>{const c=r?.trim().split("/")[0];return(c&&t?.[c])??t?.origin},or=(t,r,c)=>c?t.map(o=>o.name).map(o=>`${o}/${c}`).find(o=>r.includes(o))??c:null;function cr({branches:t,status:r,remotes:c,remoteUrl:p,git:m}){const o=a.useMemo(()=>nr(t?.all),[t?.all]),n=a.useMemo(()=>rr(t?.all),[t?.all]),s=a.useMemo(()=>lr(c,n,r?.tracking,p),[c,n,p,r?.tracking]),h=r?.current??null,g=a.useMemo(()=>ir(t?.defaultBranches,r?.tracking),[t?.defaultBranches,r?.tracking]),d=a.useMemo(()=>tr({remoteNames:new Set(s.map(f=>f.name)),localBranches:o,defaultBranch:g,headBranch:h}),[h,g,s,o]),j=!!(h&&d&&h!==d&&(r?.tracking||s.length>0)&&typeof m?.getGitRangeDiff=="function"&&ar({baseBranch:d,localBranches:o,remoteBranches:n})),b=a.useMemo(()=>or(s,n,d),[d,s,n]);return{localBranches:o,remoteBranches:n,effectiveRemotes:s,currentBranch:h,defaultBranch:g,baseBranch:d,branchScopeAvailable:j,updateTargetBranch:b}}function dr({currentSessionId:t,currentDirectory:r}){const[c,p]=a.useState(!1),[m,o]=a.useState([]),[n,s]=a.useState("merge"),h=a.useMemo(()=>t?`pichamber.conflict:${t}`:null,[t]),g=a.useCallback((j,b,f)=>{if(!h||typeof window>"u")return;const u={directory:j,conflictFiles:b,operation:f};window.localStorage.setItem(h,JSON.stringify(u))},[h]),d=a.useCallback(()=>{!h||typeof window>"u"||window.localStorage.removeItem(h)},[h]);return a.useEffect(()=>{if(!h||typeof window>"u"||!r)return;const j=window.localStorage.getItem(h);if(j)try{const b=JSON.parse(j);if(b.directory!==r){window.localStorage.removeItem(h);return}o(b.conflictFiles??[]),s(b.operation??"merge"),p(!0)}catch{window.localStorage.removeItem(h)}},[h,r]),{conflictDialogOpen:c,setConflictDialogOpen:p,conflictFiles:m,setConflictFiles:o,conflictOperation:n,setConflictOperation:s,persistConflictState:g,clearConflictState:d}}const ur=({runMutation:t,onMutationComplete:r,onMutationError:c,onPathsComplete:p,scheduleFlush:m})=>{const o=[];let n=!1;return{enqueue:h=>{const g=o[o.length-1];if(g?.directory===h.directory&&g.direction===h.direction){h.paths.forEach(d=>g.paths.add(d));return}o.push(h)},flush:()=>{if(n)return;const h=o.shift();if(!h)return;n=!0;const g={directory:h.directory,direction:h.direction,paths:Array.from(h.paths),rollback:h.rollback};(async()=>{try{await t(g),r(g)}catch(d){c(g,d)}finally{p(g.paths),n=!1,o.length>0&&m()}})()},clear:()=>{o.length=0},size:()=>o.length,isRunning:()=>n}},hr=a.memo(function({file:r,actionLabel:c,actionSymbol:p,onAction:m,onViewDiff:o,onRevert:n,isReverting:s,stats:h,rowPaddingClassName:g,indentPx:d=0,actionAtStart:j=!1,showRevert:b=!0}){const f=is.useMemo(()=>hn(r),[r]),u=f.description,w=h?.insertions??0,z=h?.deletions??0,R=is.useCallback(I=>{I.key===" "?(I.preventDefault(),m()):I.key==="Enter"&&(I.preventDefault(),o())},[m,o]),M=is.useCallback(I=>{I.preventDefault(),I.stopPropagation(),m()},[m]),_=is.useCallback(I=>{I.preventDefault(),I.stopPropagation(),n()},[n]),U=e.jsx("button",{type:"button",onClick:M,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":c,title:c,children:p});return e.jsxs("div",{className:`group flex items-center gap-2 py-1.5 cursor-pointer ${g??"px-3"}`,role:"button",tabIndex:0,onClick:o,onKeyDown:R,style:d>0?{paddingLeft:`${d}px`}:void 0,children:[j?U:null,e.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:f.color},title:u,"aria-label":u,children:f.code}),e.jsx(zt,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),(()=>{const I=r.path.lastIndexOf("/");if(I===-1)return e.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:r.path,children:r.path});const L=r.path.slice(0,I),B=r.path.slice(I);return e.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[e.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:L}),e.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("span",{className:"text-foreground",children:B.slice(1)})]})]})})(),e.jsxs("span",{className:"shrink-0 typography-micro",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",w]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",z]})]}),b?e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button",onClick:_,disabled:s,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Revert changes in ${r.path}`,children:s?e.jsx(S,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(S,{name:"arrow-go-back",className:"size-3.5"})})}),e.jsx(Ce,{sideOffset:8,children:"Revert changes"})]}):null,j?null:U]})}),xt=14,Ot=t=>t.replace(/\\/g,"/").replace(/^\/+/,"").trim(),bt=(t,r)=>({id:`dir:${t}`,path:t,name:r,children:new Map,directFiles:[],files:[]}),mr=t=>{const r=bt("","");for(const c of t){const p=Ot(c.path);if(!p)continue;const o=p.split("/").filter(Boolean).slice(0,-1);let n=r;if(n.files.push(c),o.length>0){let s="";for(const h of o){s=s?`${s}/${h}`:h;const g=n.children.get(h);if(g){g.files.push(c),n=g;continue}const d=bt(s,h);d.files.push(c),n.children.set(h,d),n=d}}n.directFiles.push(c)}return r},fr=(t,r)=>{const c=[],p=(m,o)=>{const n=Array.from(m.children.values()).sort((h,g)=>h.path.localeCompare(g.path));for(const h of n)c.push({key:h.id,kind:"directory",depth:o,directory:h}),r.has(h.path)&&p(h,o+1);const s=[...m.directFiles].sort((h,g)=>h.path.localeCompare(g.path));for(const h of s)c.push({key:`file:${Ot(h.path)}`,kind:"file",depth:o,file:h})};return p(t,0),c},pr=1e3,yt=34,ks=30,us="pl-0 pr-2",Rs=(t,r)=>`${t} ${r}`,gr=({groups:t,diffStats:r,revertingPaths:c,isRevertingAll:p=!1,headerBackgroundClassName:m="bg-sidebar",onVisiblePathsChange:o,onRevertAll:n,onRevertDirectory:s})=>{const h=a.useRef(null),d=As(N=>N.gitChangesViewMode)==="tree",j=a.useMemo(()=>t.filter(N=>N.entries.length>0),[t]),[b,f]=a.useState(new Set),[u,w]=a.useState(new Set),[z,R]=a.useState(!1),[M,_]=a.useState(null),U=a.useMemo(()=>j.map(N=>mr(N.entries)),[j]),I=a.useMemo(()=>{const N=[];return j.forEach((E,i)=>{Array.from(U[i]?.children.values()??[]).forEach($=>{N.push(Rs(E.id,$.path))})}),N},[U,j]);a.useEffect(()=>{d&&w(N=>{const E=new Set,i=new Set(I);return N.forEach($=>{($.slice($.indexOf(" ")+1).includes("/")||i.has($))&&E.add($)}),I.forEach($=>E.add($)),E})},[d,I]);const L=a.useMemo(()=>{const N=[];return j.forEach((E,i)=>{if(N.push({type:"header",key:`header:${E.id}`,groupIndex:i}),!b.has(E.id)){if(d){const $=new Set;u.forEach(Q=>{Q.startsWith(`${E.id} `)&&$.add(Q.slice(E.id.length+1))}),fr(U[i],$).forEach(Q=>{Q.kind==="file"?N.push({type:"file",key:`${E.id}:${Q.key}`,groupIndex:i,file:Q.file,depth:Q.depth}):N.push({type:"directory",key:`${E.id}:${Q.key}`,groupIndex:i,directory:Q.directory,depth:Q.depth})});return}E.entries.forEach($=>{N.push({type:"file",key:`${E.id}:file:${$.path}`,groupIndex:i,file:$,depth:0})})}}),n&&j.length>0&&N.push({type:"revert-all",key:"revert-all"}),N},[b,u,d,n,U,j]),B=L.length,F=B>=pr,A=Ma({count:B,enabled:F,getScrollElement:()=>h.current,estimateSize:()=>yt,overscan:12,getItemKey:N=>L[N]?.key??N}),x=A.getVirtualItems(),q=a.useMemo(()=>{if(!F)return 0;const N=h.current?.scrollTop??0;return x.find(i=>i.end>N)?.index??0},[F,x,h]);a.useEffect(()=>{if(!o)return;const N=E=>E&&E.type==="file"?E.file.path:null;if(B===0){o([]);return}if(!F){const E=[];for(const i of L)if(i.type==="file"&&(E.push(i.file.path),E.length>=ks))break;o(E);return}o(L.slice(q,q+Math.ceil((h.current?.clientHeight??0)/yt)+ks).map(E=>N(E)).filter(E=>!!E).slice(0,ks))},[o,B,L,F,q]);const W=a.useCallback(N=>{f(E=>{const i=new Set(E);return i.has(N)?i.delete(N):i.add(N),i})},[]),J=a.useCallback((N,E)=>{w(i=>{const $=new Set(i),k=Rs(N,E);return $.has(k)?$.delete(k):$.add(k),$})},[]),Y=a.useMemo(()=>{const N=new Set;return j.forEach(E=>E.entries.forEach(i=>N.add(i.path))),Array.from(N)},[j]),T=Y.length,D=M?p||M.paths.some(N=>c.has(N)):!1,ae=a.useCallback(async()=>{!n||p||Y.length===0||(await n(Y),R(!1))},[Y,p,n]),ne=a.useCallback(async()=>{!s||!M||D||(await s(M.paths),_(null))},[D,s,M]),re=a.useCallback((N,E)=>{const i=b.has(N.id),$=N.entries.length;return e.jsxs("div",{className:se("sticky top-0 z-10 flex items-center gap-2 py-2",m,us,!E&&"mt-1 border-t border-border/40"),children:[e.jsx("button",{type:"button",onClick:()=>N.onActionAll(N.entries.map(k=>k.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":N.actionAllLabel,title:N.actionAllLabel,children:N.actionSymbol}),e.jsxs("button",{type:"button",onClick:()=>W(N.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":!i,children:[e.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:N.title}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:$}),e.jsx(S,{name:"arrow-down-s",className:se("size-3.5 shrink-0 text-muted-foreground transition-transform",i&&"-rotate-90")})]})]})},[b,m,W]),le=a.useCallback((N,E,i)=>{const $=u.has(Rs(N.id,E.path)),k=E.files.map(V=>V.path),Q=p||k.some(V=>c.has(V));return e.jsxs("div",{className:se("group flex items-center gap-2 py-1.5",us),style:{paddingLeft:`${i*xt}px`},children:[e.jsxs("button",{type:"button",onClick:()=>J(N.id,E.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":$?`Collapse directory ${E.path}`:`Expand directory ${E.path}`,children:[$?e.jsx(S,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):e.jsx(S,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:E.path,children:E.name}),e.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:E.files.length})]}),N.showRevertActions!==!1&&s?e.jsx("button",{type:"button",onClick:()=>_({path:E.path,paths:k,count:k.length}),disabled:Q,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":`Revert changes in ${E.path}`,title:"Revert folder changes",children:Q?e.jsx(S,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(S,{name:"arrow-go-back",className:"size-3.5"})}):null,e.jsx("button",{type:"button",onClick:()=>N.onActionAll(E.files.map(V=>V.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":N.actionSymbol==="+"?`Stage all changes in ${E.path}`:`Unstage all changes in ${E.path}`,title:N.actionSymbol==="+"?`Stage all changes in ${E.path}`:`Unstage all changes in ${E.path}`,children:N.actionSymbol})]})},[u,p,s,c,J]),ee=a.useCallback((N,E)=>{if(N.type==="revert-all")return e.jsx("div",{className:se("flex justify-end py-2",us),children:e.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>R(!0),disabled:p,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[e.jsx(S,{name:"arrow-go-back",className:"size-3.5"}),"Revert all"]})});const i=j[N.groupIndex];if(!i)return null;if(N.type==="header")return re(i,E);if(N.type==="directory")return le(i,N.directory,N.depth);const $=N.file;return e.jsx(hr,{file:$,actionLabel:i.getActionLabel($.path),actionSymbol:i.actionSymbol,onAction:()=>i.onActionFile($.path),stats:r?.[$.path],onViewDiff:()=>i.onViewDiff($.path),onRevert:()=>i.onRevertFile($.path),isReverting:c.has($.path)||p,rowPaddingClassName:us,indentPx:N.depth*xt,actionAtStart:!d,showRevert:i.showRevertActions!==!1})},[r,p,d,le,re,c,j]),O=a.useCallback(N=>{const E=L[N],i=L[N-1];return!E||!i||E.type!=="file"&&E.type!=="directory"||i.type!=="file"&&i.type!=="directory"?!1:i.groupIndex===E.groupIndex},[L]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[e.jsx(Ft,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:F?e.jsx("div",{style:{height:A.getTotalSize(),position:"relative"},children:x.map(N=>{const E=L[N.index];return E?e.jsx("div",{"data-index":N.index,ref:A.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${N.start}px)`},className:se(O(N.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:ee(E,N.index===0)},E.key):null})}):e.jsx("div",{role:"list","aria-label":"Changed files",children:L.map((N,E)=>e.jsx("div",{className:se("relative",O(E)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:ee(N,E===0)},N.key))})}),e.jsx(Wa,{containerRef:h,disableHorizontal:!0})]}),e.jsx(Fe,{open:z,onOpenChange:N=>{!p&&!N&&R(!1)},children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Revert all changes?"}),e.jsx(Pe,{children:T===1?`Revert ${T} changed file? This cannot be undone.`:`Revert ${T} changed files? This cannot be undone.`})]}),e.jsxs(We,{children:[e.jsx(H,{variant:"outline",size:"sm",onClick:()=>R(!1),disabled:p,children:"Cancel"}),e.jsx(H,{variant:"destructive",size:"sm",onClick:()=>{ae()},disabled:p,children:p?"Reverting...":"Revert all"})]})]})}),e.jsx(Fe,{open:!!M,onOpenChange:N=>{!D&&!N&&_(null)},children:e.jsxs(De,{className:"max-w-md",children:[e.jsxs(Me,{children:[e.jsx($e,{children:"Revert folder changes?"}),e.jsx(Pe,{children:M?M.count===1?`This will discard local changes in ${M.count} file under ${M.path}.`:`This will discard local changes in ${M.count} files under ${M.path}.`:null})]}),e.jsxs(We,{children:[e.jsx(H,{variant:"outline",size:"sm",onClick:()=>_(null),disabled:D,children:"Cancel"}),e.jsx(H,{variant:"destructive",size:"sm",onClick:()=>{ne()},disabled:D||!M,children:D?"Reverting...":"Revert folder"})]})]})})]})},xr=Dt(()=>vt(()=>import("./DiffView-CiZy4jFA.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53])).then(t=>({default:t.DiffView}))),br=({currentDirectory:t,status:r,isGitRepo:c,isLoadingStatus:p,changeEntries:m,stagedChangeEntries:o,unstagedChangeEntries:n,effectiveRemotes:s,syncAction:h,localBranches:g,remoteBranches:d,branchInfo:j,isWorktreeMode:b,onCheckoutBranch:f,onCreateBranch:u,onRenameBranch:w,commitAction:z,commitMessage:R,hasPendingIndexMutation:M,revertingPaths:_,isRevertingAll:U,initialDiffPath:I,initialDiffStaged:L=!1,onSyncAction:B,onMoveChangePaths:F,onRevertFile:A,onRevertAll:x,onCommitMessageChange:q,onCommit:W,onVisiblePathsChange:J,loadDiff:Y})=>{const[T,D]=a.useState(()=>I?{type:"diff",path:I,staged:L}:{type:"list"}),[ae,ne]=a.useState(null),[re,le]=a.useState(null),[ee,O]=a.useState(0);a.useEffect(()=>{I&&D(V=>V.type==="diff"&&V.path===I&&V.staged===L?V:{type:"diff",path:I,staged:L})},[I,L]);const N=a.useMemo(()=>T.type==="diff"&&m.some(V=>V.path===T.path),[m,T]);a.useEffect(()=>{if(T.type!=="diff"||!N){ne(null),le(null);return}let V=!1;return ne(null),le(null),Y(T.path,T.staged).then(K=>{V||ne(K)}).catch(K=>{V||le(K instanceof Error?K.message:String(K))}),()=>{V=!0}},[ee,Y,T,N]);const E=a.useCallback((V,K=!1)=>{D({type:"diff",path:V,staged:K})},[]),i=a.useMemo(()=>{const V=[];return o.length>0&&V.push({id:"staged",title:"Staged",entries:o,actionSymbol:"-",actionAllLabel:"Unstage all changes",getActionLabel:K=>`Unstage ${K}`,onActionFile:K=>F([K],"unstage"),onActionAll:K=>F(K,"unstage"),onViewDiff:K=>E(K,!0),onRevertFile:A,showRevertActions:!1,accent:!0}),n.length>0&&V.push({id:"unstaged",title:"Changes",entries:n,actionSymbol:"+",actionAllLabel:"Stage all changes",getActionLabel:K=>`Stage ${K}`,onActionFile:K=>F([K],"stage"),onActionAll:K=>F(K,"stage"),onViewDiff:K=>E(K,!1),onRevertFile:A}),V},[E,F,A,o,n]),{label:$,icon:k}=Ka(c),Q=a.useCallback(V=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Fs,{icon:k,title:$}),e.jsx("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:e.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:r?.current||t||""})}),e.jsx("div",{className:"min-h-0 flex-1",children:V})]}),[t,r,k,$]);return t?c===null||c===!0&&!r?Q(e.jsx(ze,{loading:!0,message:"Checking repository..."})):c===!1?Q(e.jsx(a.Suspense,{fallback:e.jsx(ze,{loading:!0,message:"Loading last turn changes..."}),children:e.jsx(xr,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})):T.type==="diff"?e.jsx(yr,{path:T.path,diff:ae,fileExists:N,error:re,onBack:()=>D({type:"list"}),onRetry:()=>O(V=>V+1)}):e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Fs,{leading:e.jsx("div",{className:"min-w-0 flex-1 -ml-2",children:b?e.jsx(Lt,{currentBranch:r?.current,onRename:w}):e.jsx(Bt,{currentBranch:r?.current,localBranches:g,remoteBranches:d,branchInfo:j,onCheckout:f,onCreate:u,remotes:s})}),actions:e.jsx(It,{syncAction:h,remotes:s,onFetch:V=>B("fetch",V),onSync:V=>B("sync",V),disabled:z!==null||p,aheadCount:r?.ahead??0,behindCount:r?.behind??0,trackingRemoteName:r?.tracking?.split("/")[0],hasUncommittedChanges:m.length>0})}),m.length>0?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-3 pt-2",children:e.jsx(gr,{groups:i,diffStats:r?.diffStats,revertingPaths:_,onRevertAll:x,isRevertingAll:U,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:J})}),e.jsx("div",{className:"shrink-0 border-t border-border/40 px-3 pb-3 pt-3",children:e.jsx(Tt,{stagedCount:o.length,commitMessage:R,onCommitMessageChange:q,onCommit:()=>{if(!R.trim()){P.error("Enter a commit message");return}if(o.length===0){P.error("Select at least one file to commit");return}W({pushAfter:!1})},onCommitAndPush:()=>{if(!R.trim()){P.error("Enter a commit message");return}if(o.length===0){P.error("Select at least one file to commit");return}W({pushAfter:!0})},commitAction:z,hasPendingIndexMutation:M})})]}):e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(ze,{icon:!0,message:"Working tree clean",description:"There are no changed files in this workspace."})})]}):Q(e.jsx(ze,{message:"Select a session or directory to view Git status"}))},ze=({message:t,description:r,loading:c=!1,icon:p=!1})=>e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[c?e.jsx(S,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,p?e.jsx(S,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:t}),r?e.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null]})}),yr=({path:t,diff:r,fileExists:c,error:p,onBack:m,onRetry:o})=>{const n=a.useMemo(()=>Et(t)||"text",[t]);return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Fs,{leading:e.jsx(H,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:m,children:e.jsx(S,{name:"arrow-left",className:"size-4"})}),icon:e.jsx(zt,{filePath:t,className:"size-4 shrink-0"}),title:t}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:c?p?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),e.jsx("p",{className:"typography-meta text-muted-foreground",children:p}),e.jsx(H,{type:"button",size:"sm",variant:"outline",onClick:o,children:"Retry"})]})}):r?r.isBinary?e.jsx(ze,{icon:!0,message:"Content of this file cannot be viewed."}):Ya(t)?e.jsx(ze,{icon:!0,message:"Image diffs are not available in mobile Changes yet."}):e.jsx(Ft,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:e.jsx(Pt,{original:r.original,modified:r.modified,language:n,fileName:t,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):e.jsx(ze,{loading:!0,message:"Loading diff..."}):e.jsx(ze,{icon:!0,message:"File is no longer changed",description:"Go back to Changes and refresh the list."})})]})},jt=Dt(()=>vt(()=>import("./DiffView-CiZy4jFA.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53])).then(t=>({default:t.DiffView}))),jr=15e3,vr=40,wr=20,Cl=({isActive:t,chrome:r="desktop",initialDiffPath:c=null,initialDiffStaged:p=!1,gitHeaderSlot:m=null,onlyFilePath:o=null})=>{const{git:n}=qe(),s=Qa(),h=zs(l=>l.currentSessionId),g=Xa(s??null),d=Za(s??null),j=St(s??null),b=Ja(s??null),u=en(s??null)??[],w=sn(s??null),z=tn(s??null),R=an(s??null),{setActiveDirectory:M,fetchAll:_,ensureAll:U,fetchStatus:I,fetchBranches:L,fetchLog:B,fetchLogQuery:F,setLogMaxCount:A,prefetchDiffs:x,clearDiffCache:q,moveStatusPathsOptimistically:W,restoreStatus:J,bumpIndexRevision:Y}=kt($a(l=>({setActiveDirectory:l.setActiveDirectory,fetchAll:l.fetchAll,ensureAll:l.ensureAll,fetchStatus:l.fetchStatus,fetchBranches:l.fetchBranches,fetchLog:l.fetchLog,fetchLogQuery:l.fetchLogQuery,setLogMaxCount:l.setLogMaxCount,prefetchDiffs:l.prefetchDiffs,clearDiffCache:l.clearDiffCache,moveStatusPathsOptimistically:l.moveStatusPathsOptimistically,restoreStatus:l.restoreStatus,bumpIndexRevision:l.bumpIndexRevision})));a.useRef(null);const T=a.useRef(null),D=a.useRef(null),ae=a.useRef(null),ne=a.useRef(!0);a.useEffect(()=>()=>{ne.current=!1},[]);const re=a.useCallback(()=>{T.current!==null&&(window.clearTimeout(T.current),T.current=null)},[]),le=a.useCallback(l=>{re(),T.current=window.setTimeout(()=>{T.current=null,os(l)===os(s)&&I(l,n,{silent:!0})},jr)},[re,s,I,n]);a.useEffect(()=>re,[re]);const ee=a.useCallback(()=>{D.current!==null&&(window.clearTimeout(D.current),D.current=null)},[]),O=a.useCallback(()=>{D.current===null&&(D.current=window.setTimeout(()=>{D.current=null,ae.current?.()},0))},[]),N=a.useCallback(async(l,y,v)=>{if(y==="stage"){if(n.stageGitFiles){await n.stageGitFiles(l,v);return}await Promise.all(v.map(C=>n.stageGitFile(l,C)));return}if(n.unstageGitFiles){await n.unstageGitFiles(l,v);return}await Promise.all(v.map(C=>n.unstageGitFile(l,C)))},[n]),E=a.useMemo(()=>ur({runMutation:({directory:l,direction:y,paths:v})=>N(l,y,v),onMutationComplete:({directory:l})=>{Y(l),le(l)},onMutationError:({directory:l,direction:y,rollback:v},C)=>{v?.(),Y(l),le(l);const G=y==="stage"?"Failed to stage changes":"Failed to unstage changes";P.error(C instanceof Error?C.message:G)},onPathsComplete:l=>{Gs(y=>{const v=new Set(y);return l.forEach(C=>v.delete(C)),v})},scheduleFlush:O}),[Y,N,O,le]);a.useEffect(()=>(ae.current=E.flush,()=>{ae.current=null}),[E]),a.useEffect(()=>()=>E.clear(),[E]),a.useEffect(()=>ee,[ee]);const i=a.useMemo(()=>s?Qn(s):null,[s]),[$,k]=a.useState(i?.commitMessage??""),Q=a.useRef(null),[V,K]=a.useState(null),[ce,Ve]=a.useState(!1),[ms,Os]=a.useState(null),[ge,Gt]=a.useState(25),{triggerFireworks:_t}=cn(),[fs,Ke]=a.useState(new Set),[Ht,Gs]=a.useState(new Set),[ps,_s]=a.useState(!1),[Hs,qt]=a.useState([]),[Nr,Vt]=a.useState(0),[Ut,qs]=a.useState(!1),Vs=Ht.size>0||E.size()>0||E.isRunning();a.useCallback(()=>{const l=Q.current;l&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{l.scrollTo({top:l.scrollHeight,behavior:"smooth"})})})},[]);const{expandedCommitHashes:Wt,commitFilesMap:Kt,loadingCommitHashes:Yt,handleCopyCommitHash:Qt,handleToggleCommit:Xt}=sr(s,n),{conflictDialogOpen:Zt,setConflictDialogOpen:xe,conflictFiles:Jt,setConflictFiles:be,conflictOperation:Ye,setConflictOperation:ye,persistConflictState:je,clearConflictState:me}=dr({currentSessionId:h,currentDirectory:s}),[ea,gs]=a.useState(null),[sa,Qe]=a.useState([]),[ta,Xe]=a.useState(null),[aa,Ze]=a.useState(!1),[Je,na]=a.useState(100),[pe,es]=a.useState(null),[ra,Ae]=a.useState(null),[la,xs]=a.useState(!1),[bs,Us]=a.useState("merge"),[ys,Ws]=a.useState("");a.useEffect(()=>{s&&Xn(s,{directory:s,commitMessage:$})},[$,s]),a.useEffect(()=>{t&&s&&(M(s),U(s,n))},[t,s,M,U,n]),a.useEffect(()=>{if(t&&s)return nn.onGitRefreshHint(l=>{os(l.directory)===os(s)&&(l.paths?.length&&q(s,l.paths),I(s,n,{silent:!0}))})},[t,q,s,I,n]);const te=a.useCallback(async(l=!0)=>{if(s)try{await Promise.all([I(s,n),L(s,n)])}catch(y){if(l){const v=y instanceof Error?y.message:"Failed to refresh repository";P.error(v)}}},[s,n,I,L]),ie=a.useCallback(async()=>{s&&await B(s,n,ge)},[s,n,B,ge]),de=a.useMemo(()=>d?[...d.files??[]].sort((y,v)=>y.path.localeCompare(v.path)):[],[d]),Se=a.useMemo(()=>de.filter(it),[de]),Ks=a.useMemo(()=>de.filter(mn),[de]);a.useEffect(()=>{if(!s||de.length===0)return;const l=[],y=new Set,v=G=>{!G||y.has(G)||(y.add(G),l.push(G))};if(Se.forEach(G=>v(G.path)),r==="mobile"&&Hs.forEach(v),de.slice(0,wr).forEach(G=>v(G.path)),l.length===0)return;const C=window.setTimeout(()=>{x(s,n,l,{maxFiles:vr})},120);return()=>{window.clearTimeout(C)}},[de,r,s,n,Hs,x,Se]);const Ys=l=>l?.pushed[0]?.remote||d?.tracking?.split("/")[0]||ve.find(y=>y.name==="origin")?.name||ve[0]?.name||"origin",js=async(l,y)=>{if(s){K(l);try{const v=C=>{const G=`${C.name}/`,X=d?.tracking?.startsWith(G)?d.tracking.slice(G.length):void 0;return{remote:C.name,branch:X,rebase:!0}};if(l==="fetch"){if(!y)throw new Error("No remote available for fetch");await n.gitFetch(s,{remote:y.name}),P.success(`Fetched from ${y.name}`)}else if(l==="pull"){if(!y)throw new Error("No remote available for pull");const C=await n.gitPull(s,v(y));P.success(C.files.length===1?`Pulled ${C.files.length} file from ${y.name}`:`Pulled ${C.files.length} files from ${y.name}`)}else if(l==="push"){const C=await n.gitPush(s);P.success(`Pushed to ${Ys(C)}`)}else if(l==="sync"){if(!y)throw new Error("No remote available for sync");let C=0,G=!1;await n.gitFetch(s,{remote:y.name});const X=await n.getGitStatus(s);if((X.behind??0)>0){if((X.files?.length??0)>0){P.error("Commit or stash your changes before syncing");return}C=(await n.gitPull(s,v(y))).files.length}((await n.getGitStatus(s)).ahead??0)>0&&(await n.gitPush(s),G=!0),C>0&&G?P.success(C===1?`Pulled ${C} file from ${y.name} and pushed to upstream`:`Pulled ${C} files from ${y.name} and pushed to upstream`):C>0?P.success(C===1?`Pulled ${C} file from ${y.name}`:`Pulled ${C} files from ${y.name}`):G?P.success(`Pushed to ${y.name}`):P.success("Already up to date")}await te(!1),await ie()}catch(v){const C=v instanceof Error?v.message:`${l==="sync"?"Sync changes":l==="pull"?"Pull":l} failed`;P.error(C)}finally{K(null)}}},ia=a.useCallback(async(l,y)=>{if(!s)throw new Error("No active directory");const v=await n.getGitFileDiff(s,{path:l,staged:y||void 0});return{original:v.original??"",modified:v.modified??"",isBinary:v.isBinary}},[s,n]),vs=async(l={})=>{if(!s)return;if(!$.trim()){P.error("Enter a commit message");return}const y=Se.map(C=>C.path).sort();if(y.length===0){P.error("Stage at least one file to commit");return}const v=l.pushAfter?"commitAndPush":"commit";Os(v);try{if(await n.createGitCommit(s,$.trim(),{files:y,stageFiles:[]}),Y(s),P.success("Commit created"),k(""),await te(),l.pushAfter){const C=d?.tracking?.split("/")[0],G=ve.find(Da=>Da.name===C)??ve[0];if(!G)throw new Error("No remote available");K("sync");const X=`${G.name}/`,oe=d?.tracking?.startsWith(X)?d.tracking.slice(X.length):void 0;await n.gitFetch(s,{remote:G.name});const Z=await n.getGitStatus(s);if((Z.behind??0)>0){if((Z.files?.length??0)>0){P.error("Commit or stash your changes before syncing"),await te(!1);return}await n.gitPull(s,{remote:G.name,branch:oe,rebase:!0})}const he=await n.getGitStatus(s);let Ge;(he.ahead??0)>0&&(Ge=await n.gitPush(s)),P.success(`Pushed to ${Ys(Ge)}`),r!=="mobile"&&_t(),await te(!1)}else await te(!1);await ie(),Vt(C=>C+1)}catch(C){const G=C instanceof Error?C.message:"Failed to create commit";P.error(G)}finally{Os(null),l.pushAfter&&K(null)}},Qs=async(l,y)=>{if(!s||!d)return;const v=d.current??null,C=y?.name??"origin";try{await n.createBranch(s,l,v??"HEAD"),P.success(`Created branch ${l}`),await n.checkoutBranch(s,l);let G=!1;try{await n.gitPush(s,{remote:C,branch:l,options:["--set-upstream"]}),G=!0}catch(X){const oe=X instanceof Error?X.message:`Unable to push new branch to ${C}.`;P.warning("Branch created locally, but failed to set upstream.",{description:e.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",oe]})})}await te(),await ie(),G&&P.success(`Set upstream for ${l} to ${C}`)}catch(G){const X=G instanceof Error?G.message:"Failed to create branch";throw P.error(X),G}},Xs=async(l,y)=>{if(s)try{await n.renameBranch(s,l,y),P.success(`Renamed ${l} to ${y}`),await te(),await ie()}catch(v){const C=v instanceof Error?v.message:`Failed to rename ${l} to ${y}`;P.error(C)}},Zs=async l=>{if(!s)return;const y=l.replace(/^remotes\//,"");if(d?.current!==y)try{await n.checkoutBranch(s,y),P.success(`Checked out ${y}`),await te(),await ie()}catch(v){const C=v instanceof Error?v.message:`Failed to checkout ${y}`;P.error(C)}},{localBranches:ws,remoteBranches:Ue,effectiveRemotes:ve,currentBranch:Te,baseBranch:ss,branchScopeAvailable:Oe,updateTargetBranch:oa}=cr({branches:j,status:d,remotes:u,remoteUrl:w,git:n}),Js=Se.length,ca=z||V!==null||ms!==null,et=!!Te;a.useEffect(()=>{if(!s||!n||!b?.all?.length||!Te||!ss||!Oe){Ae(null);return}let l=!1;return(async()=>{try{const v=await F(s,n,{from:ss,to:"HEAD",maxCount:ge});if(l)return;const C=new Set((v?.all??[]).map(X=>X.hash).filter(X=>typeof X=="string"&&X.length>0));if(C.size===0){Ae(null);return}const G=b.all.findIndex(X=>!C.has(X.hash));if(G===0){Ae(null);return}if(G===-1){Ae({insertBeforeIndex:b.all.length,branchName:Te,direction:"up"});return}Ae({insertBeforeIndex:G,branchName:Te,direction:"up"})}catch{l||Ae(null)}})(),()=>{l=!0}},[ss,Oe,Te,s,F,n,b,ge]),a.useEffect(()=>{Xe(null)},[s]),a.useEffect(()=>{if(pe!=="graph"||!s){pe!=="graph"&&Xe(null);return}let l=!1;return Ze(!0),F(s,n,{maxCount:Je,all:!0}).then(y=>{l||Xe(y)}).catch(y=>{console.error("Failed to fetch graph log:",y)}).finally(()=>{l||Ze(!1)}),()=>{l=!0}},[pe,s,Je,n,F]);const da=a.useCallback((l,y)=>{if(!s||l.length===0)return;const v=Array.from(new Set(l));Gs(G=>{const X=new Set(G);return v.forEach(oe=>X.add(oe)),X});const C=W(s,v,y);E.enqueue({directory:s,direction:y,paths:new Set(v),rollback:()=>J(s,C)}),O()},[s,E,W,J,O]),ua=a.useCallback(async l=>{if(s){Ke(y=>{const v=new Set(y);return v.add(l),v});try{await n.revertGitFile(s,l,{scope:"working"}),P.success(`Reverted ${l}`),await te(!1)}catch(y){const v=y instanceof Error?y.message:"Failed to revert changes";P.error(v)}finally{Ke(y=>{const v=new Set(y);return v.delete(l),v})}}},[s,te,n]),ts=a.useCallback(async(l,y,v="all")=>{if(!s||l.length===0)return;const C=Array.from(new Set(l));if(ps||C.some(Z=>fs.has(Z)))return;const G=new Set(Se.map(Z=>Z.path)),X=v==="all"&&C.some(Z=>G.has(Z));y&&_s(!0),Ke(Z=>{const he=new Set(Z);return C.forEach(Ge=>he.add(Ge)),he});const oe=[];try{if(await Promise.all(C.map(async Z=>{try{await n.revertGitFile(s,Z,{scope:v})}catch(he){oe.push({path:Z,message:he instanceof Error?he.message:"Failed to revert changes"})}})),X&&oe.length<C.length&&Y(s),await te(!1),oe.length===0)P.success(C.length===1?`Reverted ${C.length} file`:`Reverted ${C.length} files`);else if(oe.length===C.length)P.error(oe[0]?.message||"Failed to revert changes");else{const Z=C.length-oe.length;P.warning(Z===1?`Reverted ${Z} file, ${oe.length} failed`:`Reverted ${Z} files, ${oe.length} failed`)}}finally{Ke(Z=>{const he=new Set(Z);return C.forEach(Ge=>he.delete(Ge)),he}),y&&_s(!1)}},[Y,s,n,ps,te,fs,Se]),ha=a.useCallback(async l=>{await ts(l,!0)},[ts]);a.useCallback(async l=>{await ts(l,!1,"working")},[ts]);const ma=a.useCallback(()=>Ve(!0),[]),as=a.useCallback(l=>{const y=l instanceof Error?l.message.toLowerCase():"";return y.includes("uncommitted changes")||y.includes("local changes")||y.includes("your local changes would be overwritten")||y.includes("please commit your changes or stash them")||y.includes("cannot rebase: you have unstaged changes")||y.includes("error: cannot pull with rebase")},[]),ke=a.useCallback((l,y)=>{Qe(v=>[...v,{message:l,status:y,timestamp:Date.now()}])},[]),ue=a.useCallback((l,y)=>{Qe(v=>{if(v.length===0)return v;const C=[...v];return C[C.length-1]={...C[C.length-1],status:l,...y?{message:y}:{}},C})},[]),ns=a.useCallback(()=>{Qe([])},[]),fa=a.useCallback(()=>{Qe([]),gs(null)},[]),rs=a.useCallback(l=>{const y=l.trim(),v=new Set(ve.map(G=>G.name)),C=y.indexOf("/");if(C>0){const G=y.slice(0,C),X=y.slice(C+1);if(v.has(G)&&X)return{branch:y,remote:G,remoteBranch:X}}for(const G of ve){const X=`${G.name}/${y}`;if(Ue.includes(X))return{branch:X,remote:G.name,remoteBranch:y}}return{branch:y,remote:null,remoteBranch:null}},[ve,Ue]),pa=a.useCallback(async l=>{if(!s)return;gs("merge"),ns();const y=d?.current,v=rs(l);try{v.remote&&v.remoteBranch&&(ke(`Fetching ${v.remote}/${v.remoteBranch}...`,"running"),await n.gitFetch(s,{remote:v.remote,branch:v.remoteBranch}),ue("done",`Fetched ${v.remote}/${v.remoteBranch}`)),ke(`Merging ${v.branch} into ${y}...`,"running");const C=await n.merge(s,{branch:v.branch});C.conflict?(ue("error","Merge conflicts detected"),be(C.conflictFiles??[]),ye("merge"),xe(!0),je(s,C.conflictFiles??[],"merge")):(ue("done",`Merged ${v.branch} into ${y}`),me(),ke("Refreshing repository status...","running"),await te(),await ie(),ue("done","Repository status updated"))}catch(C){if(as(C))ue("error","Uncommitted changes detected"),Us("merge"),Ws(v.branch),xs(!0);else{const G=C instanceof Error?C.message:`Failed to merge ${v.branch}`;ue("error",G)}}},[s,n,d,rs,te,ie,as,je,me,ke,ue,ns]),ga=a.useCallback(async l=>{if(!s)return;gs("rebase"),ns();const y=d?.current,v=rs(l);try{v.remote&&v.remoteBranch&&(ke(`Fetching ${v.remote}/${v.remoteBranch}...`,"running"),await n.gitFetch(s,{remote:v.remote,branch:v.remoteBranch}),ue("done",`Fetched ${v.remote}/${v.remoteBranch}`)),ke(`Rebasing ${y} onto ${v.branch}...`,"running");const C=await n.rebase(s,{onto:v.branch});C.conflict?(ue("error","Rebase conflicts detected"),be(C.conflictFiles??[]),ye("rebase"),xe(!0),je(s,C.conflictFiles??[],"rebase")):(ue("done",`Rebased ${y} onto ${v.branch}`),me(),ke("Refreshing repository status...","running"),await te(),await ie(),ue("done","Repository status updated"))}catch(C){if(as(C))ue("error","Uncommitted changes detected"),Us("rebase"),Ws(v.branch),xs(!0);else{const G=C instanceof Error?C.message:`Failed to rebase onto ${v.branch}`;ue("error",G)}}},[s,n,d,rs,te,ie,as,je,me,ke,ue,ns]),xa=a.useCallback(async()=>{if(s)try{Ye==="merge"?(await n.abortMerge(s),P.success("Merge aborted")):(await n.abortRebase(s),P.success("Rebase aborted")),me(),await te(),await ie()}catch(l){const y=l instanceof Error?l.message:`Failed to abort ${Ye}`;P.error(y)}},[s,n,Ye,te,ie,me]),ba=a.useMemo(()=>d?.files?d.files.filter(l=>l.index==="U"||l.working_dir==="U"||l.index==="A"&&l.working_dir==="A"||l.index==="D"&&l.working_dir==="D").length:0,[d?.files]),ya=a.useCallback(async()=>{if(s)try{const l=!!d?.mergeInProgress?.head,y=!!(d?.rebaseInProgress?.headName||d?.rebaseInProgress?.onto);if(l){const v=await n.continueMerge(s);v.conflict?(be(v.conflictFiles??[]),ye("merge"),xe(!0),je(s,v.conflictFiles??[],"merge"),P.error("Merge conflicts detected")):(me(),P.success("Merge completed"),await te(),await ie())}else if(y){const v=await n.continueRebase(s);v.conflict?(be(v.conflictFiles??[]),ye("rebase"),xe(!0),je(s,v.conflictFiles??[],"rebase"),P.error("Rebase conflicts detected")):(me(),P.success("Rebase step completed"),await te(),await ie())}}catch(l){const y=l instanceof Error?l.message:"Failed to continue operation";P.error(y)}},[s,n,d,te,ie,je,me]),ja=a.useCallback(async()=>{if(s)try{!!d?.mergeInProgress?.head?(await n.abortMerge(s),P.success("Merge aborted")):(await n.abortRebase(s),P.success("Rebase aborted")),me(),await te(),await ie()}catch(l){const y=l instanceof Error?l.message:"Failed to abort operation";P.error(y)}},[s,n,d,te,ie,me]),va=a.useCallback(()=>{if(!s)return;const y=!!d?.mergeInProgress?.head?"merge":"rebase",v=d?.files?.filter(C=>C.index==="U"||C.working_dir==="U").map(C=>C.path)??[];v.length>0&&be(v),ye(y),xe(!0)},[s,d]),wa=a.useCallback(async l=>{if(!s)return;const y=d?.current,v=bs,C=ys,G=(d?.files??[]).some(it);try{await n.stash(s,{message:`Auto-stash before ${v} with ${C}`,includeUntracked:!0}),G&&Y(s)}catch(Z){const he=Z instanceof Error?Z.message:"Failed to stash changes";P.error(he);return}let X=!1,oe=!1;try{if(v==="merge"){const Z=await n.merge(s,{branch:C});Z.conflict?(oe=!0,be(Z.conflictFiles??[]),ye("merge"),xe(!0)):(X=!0,P.success(`Merged ${C} into ${y||""}`))}else{const Z=await n.rebase(s,{onto:C});Z.conflict?(oe=!0,be(Z.conflictFiles??[]),ye("rebase"),xe(!0)):(X=!0,P.success(`Rebased ${y||""} onto ${C}`))}if(l&&X)try{await n.stashPop(s),Y(s),P.success("Stashed changes restored")}catch(Z){const he=Z instanceof Error?Z.message:"Failed to restore stash";P.error(he)}else l&&oe&&P.info("Stash restored manually required");await te(),await ie()}catch(Z){if(l)try{await n.stashPop(s),Y(s)}catch{}throw Z}},[Y,s,n,d,bs,ys,te,ie]),Na=a.useCallback(l=>{Gt(l),s&&(A(s,l),B(s,n,l))},[s,B,n,A]),Ca=a.useCallback(l=>{na(l)},[]),Sa=a.useCallback(()=>{es(null),s&&(I(s,n),L(s,n),B(s,n,ge))},[s,I,L,B,ge,n]),ka=a.useCallback(l=>{if(l.conflict){if(l.operation==="cherry-pick"||l.operation==="revert"){P.error("Conflict",{description:`Conflicts in: ${l.conflictFiles?.join(", ")??"unknown files"}. Resolve manually and commit, or abort with git cherry-pick/revert --abort.`}),s&&(I(s,n),L(s,n),B(s,n,ge));return}be(l.conflictFiles??[]),ye(l.operation),xe(!0),s&&je(s,l.conflictFiles??[],l.operation)}},[be,ye,xe,je,s,I,L,B,ge,n]),[st,tt]=a.useState(()=>de.length>0?"all":"branch"),[Ra,Ea]=a.useState(null),ls=`${s??""}:${de.length>0?"nonempty":"empty"}`,at=a.useRef(ls);a.useEffect(()=>{at.current!==ls&&(at.current=ls,tt(de.length>0?"all":"branch"))},[de.length,ls]);const nt=a.useCallback(l=>{tt(l)},[]),za=a.useCallback(l=>{Ea(l)},[]),Ns=g===!0&&d?e.jsx(Cn,{status:d,localBranches:ws,remoteBranches:Ue,branchInfo:j?.branches,syncAction:V,remotes:ve,onFetch:l=>js("fetch",l),onSync:l=>js("sync",l),onCheckoutBranch:Zs,onCreateBranch:Qs,onRenameBranch:Xs,isWorktreeMode:!1,upstreamTarget:d.upstreamComparison?`${d.upstreamComparison.remote}/${d.upstreamComparison.branch}`:null,onOpenHistory:()=>es("history"),onOpenGraph:()=>es("graph"),onOpenStashes:ma,onOpenUpdateBranch:et?()=>qs(!0):void 0,diffScope:st,onDiffScopeChange:nt,allCount:de.length,workingCount:Ks.length,stagedCount:Js,branchAvailable:Oe,diffHeaderState:Ra}):null,Fa=Ns?m?Pa.createPortal(e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:Ns}),m):e.jsx("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border px-2",children:Ns}):null;return r==="mobile"?e.jsx(br,{currentDirectory:s??null,status:d,isGitRepo:g,isLoadingStatus:z,changeEntries:de,stagedChangeEntries:Se,unstagedChangeEntries:Ks,effectiveRemotes:ve,syncAction:V,localBranches:ws,remoteBranches:Ue,branchInfo:j?.branches,isWorktreeMode:!1,onCheckoutBranch:Zs,onCreateBranch:Qs,onRenameBranch:Xs,commitAction:ms,commitMessage:$,hasPendingIndexMutation:Vs,revertingPaths:fs,isRevertingAll:ps,initialDiffPath:c,initialDiffStaged:p,onSyncAction:(l,y)=>{js(l,y)},onMoveChangePaths:da,onRevertFile:l=>{ua(l)},onRevertAll:ha,onCommitMessageChange:k,onCommit:l=>{vs(l)},onVisiblePathsChange:qt,loadDiff:ia}):s?g===null||g===!0&&!d?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(S,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-ui-label",children:"Checking repository..."})]})}):g===!1?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(jt,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,toolbarSlot:m})})}):e.jsxs("div",{className:se("flex h-full flex-col overflow-hidden"),children:[Fa,s&&d?e.jsx(Pn,{directory:s,branch:d.current??null,hasUpstream:d.tracking!=null}):null,s&&(d?.mergeInProgress?.head||d?.rebaseInProgress?.headName||d?.rebaseInProgress?.onto)&&e.jsx(er,{mergeInProgress:d?.mergeInProgress,rebaseInProgress:d?.rebaseInProgress,onContinue:ya,onAbort:ja,onResolveWithAI:va,conflictCount:ba,isLoading:z}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:(de?.length??0)>0||Oe?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(jt,{diffScope:st,onDiffScopeChange:nt,branchBase:Oe?ss:null,branchHead:Oe?Te:null,showOpenInEditorAction:!0,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,hideToolbar:!0,onlyFilePath:o,onHeaderControlsStateChange:za})})}),de.length>0?e.jsx("div",{ref:Q,className:"shrink-0 px-4 pb-4 pt-2",children:e.jsx(Tt,{stagedCount:Js,commitMessage:$,onCommitMessageChange:k,onCommit:()=>vs({pushAfter:!1}),onCommitAndPush:()=>vs({pushAfter:!0}),commitAction:ms,hasPendingIndexMutation:Vs})}):null]}):e.jsx(Jn,{onOpenStashes:()=>Ve(!0)})})}),e.jsx(Kn,{currentDirectory:s,isUpdateBranchDialogOpen:Ut,setIsUpdateBranchDialogOpen:qs,branchOperation:ea,currentBranch:d?.current,localBranches:ws,remoteBranches:Ue,updateTargetBranch:oa,onMerge:pa,onRebase:ga,isBusy:ca,operationLogs:sa,onOperationComplete:fa,canShowBranchWorkflows:et,gitLogDialogMode:pe,setGitLogDialogMode:es,onRefreshHistory:()=>{if(pe==="graph"){if(!s)return;Ze(!0),F(s,n,{maxCount:Je,all:!0},{force:!0}).then(l=>{ne.current&&l&&Xe(l)}).catch(l=>{console.error("Failed to refresh graph log:",l)}).finally(()=>{ne.current&&Ze(!1)});return}s&&B(s,n,ge)},isLogRefreshing:pe==="graph"?aa:R,log:pe==="graph"?ta??b:b,maxCount:pe==="graph"?Je:ge,onMaxCountChange:pe==="graph"?Ca:Na,expandedCommitHashes:Wt,onToggleCommit:Xt,commitFilesMap:Kt,loadingCommitHashes:Yt,onCopyHash:Qt,historyBranchDivider:ra,onConflict:pe==="graph"?ka:void 0,onActionSuccess:pe==="graph"?Sa:void 0,isStashesDialogOpen:ce,setIsStashesDialogOpen:Ve,hasUncommittedChanges:(d?.files?.length??0)>0,hasStagedChanges:Se.length>0,uncommittedFileCount:d?.files?.length??0,onStashesChanged:async l=>{s&&l?.affectsIndex&&Y(s),await te(!1),await ie()},conflictDialogOpen:Zt,setConflictDialogOpen:xe,conflictFiles:Jt,conflictOperation:Ye,onAbortConflict:xa,onClearConflictState:me,stashDialogOpen:la,setStashDialogOpen:xs,stashDialogOperation:bs,stashDialogBranch:ys,onConfirmStashAndRetry:wa})]}):e.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"Select a session or directory to view Git status"})})};export{Cl as GitView};
|