@openchamber/web 1.18.4 → 1.19.0
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/README.md +1 -0
- package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-DAvopJvy.js} +1 -1
- package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-D9cV-qR9.js} +1 -1
- package/dist/assets/{DiagramEditor-jnG3Hbxg.js → DiagramEditor-B9NCadU7.js} +1 -1
- package/dist/assets/DiagramView-LKGBwf4G.js +1 -0
- package/dist/assets/{DiffView-DZIoOnV7.js → DiffView-BWNq-0ov.js} +2 -2
- package/dist/assets/FilesView-DB-Q0Gkz.js +14 -0
- package/dist/assets/{GitView-DBFrDDBv.js → GitView-DsWXqWx3.js} +3 -3
- package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-h4dHASlq.js} +1 -1
- package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +12 -0
- package/dist/assets/OnboardingScreen-CDjgzxEe.js +1 -0
- package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-jPKTJje5.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BHm4Yr0X.js → PierreDiffViewer-D_Gt4A_6.js} +1 -1
- package/dist/assets/PlanView-UvuxIl9-.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +1 -0
- package/dist/assets/SettingsView-3B9VN6Ys.js +28 -0
- package/dist/assets/SettingsWindow-CqQNDKNd.js +1 -0
- package/dist/assets/{ToolOutputDialog-Za6V4VMJ.js → ToolOutputDialog-PmjlAxVE.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-BL-9ixyC.js → ToolPartDiffPreview-B34Xw9wq.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-CwGocYQd.js → VirtualizedFileDiff-B37yB9jZ.js} +3 -3
- package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-Bxun3k66.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DYFv_yZS.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +1 -0
- package/dist/assets/de-DbV6CLxv.js +9 -0
- package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
- package/dist/assets/es-CVDlyzZ4.js +15 -0
- package/dist/assets/fr-Czc-p0g-.js +13 -0
- package/dist/assets/index-1OhiMDBz.css +1 -0
- package/dist/assets/index-BSvmTvZl.js +1 -0
- package/dist/assets/index-DzriVon2.js +7 -0
- package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-DwHKxDYc.js} +1 -1
- package/dist/assets/{isFilePlainText-gTibdNIe.js → isFilePlainText-Dwq6ILxo.js} +1 -1
- package/dist/assets/ja-dwc9NM_S.js +15 -0
- package/dist/assets/ko-Ds1DZ8FX.js +15 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-BF51IOVF.js +921 -0
- package/dist/assets/{main-D7UcL3VQ.js → main-D7UPARut.js} +2 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +2 -0
- package/dist/assets/{miniChat-O_GVoEbc.js → miniChat-BISXSGOo.js} +2 -2
- package/dist/assets/mobile-BnYxVuvw.js +2 -0
- package/dist/assets/{patchFileDiff-KNkxM1C1.js → patchFileDiff-BEDPDypx.js} +2 -2
- package/dist/assets/pl-CLiTO7i-.js +15 -0
- package/dist/assets/pt-BR-GIimJgpK.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +2 -0
- package/dist/assets/{renderMobileApp-toj9cXoh.js → renderMobileApp-BiMbzPq9.js} +7 -7
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +15 -0
- package/dist/assets/scheduledTasksApi-01zzfzqH.js +1 -0
- package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DXYW46vW.js} +1 -1
- package/dist/assets/uk-DLfgD1ki.js +15 -0
- package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-CbzHzFop.js} +139 -142
- package/dist/assets/{useInlineCommentController-CYPvYJDt.js → useInlineCommentController-CegKdDXi.js} +2 -2
- package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-BYlZTzrw.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
- package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
- package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-CiAYDJXN.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
- package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
- package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
- package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
- package/dist/assets/vendor-zod-adaMkgkm.js +39 -0
- package/dist/assets/{web-components-GMc3oR3i.js → web-components-DCLjCO9n.js} +1 -1
- package/dist/assets/zh-CN-DkeP5awK.js +15 -0
- package/dist/assets/zh-TW-BocaFm3d.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/index.js +116 -3
- package/server/lib/agent-memory/actions.js +243 -0
- package/server/lib/agent-memory/actions.test.js +343 -0
- package/server/lib/agent-memory/feature-flag.js +19 -0
- package/server/lib/agent-memory/feature-flag.test.js +38 -0
- package/server/lib/agent-memory/project-resolution.js +56 -0
- package/server/lib/agent-memory/project-resolution.test.js +85 -0
- package/server/lib/agent-memory/routes.http.test.js +270 -0
- package/server/lib/agent-memory/routes.js +169 -0
- package/server/lib/agent-memory/runtime.js +427 -0
- package/server/lib/agent-memory/runtime.test.js +344 -0
- package/server/lib/agent-memory/threat-patterns.js +61 -0
- package/server/lib/agent-memory/threat-patterns.test.js +61 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
- package/server/lib/agent-tool/runtime.js +63 -13
- package/server/lib/agent-tool/runtime.test.js +85 -2
- package/server/lib/context-obligatory/runtime.js +34 -3
- package/server/lib/context-obligatory/runtime.test.js +114 -0
- package/server/lib/fs/DOCUMENTATION.md +3 -0
- package/server/lib/fs/routes.js +149 -32
- package/server/lib/fs/routes.test.js +225 -0
- package/server/lib/git/DOCUMENTATION.md +8 -0
- package/server/lib/git/service.js +121 -67
- package/server/lib/git/service.test.js +129 -0
- package/server/lib/github/DOCUMENTATION.md +14 -3
- package/server/lib/github/pr-status.js +188 -83
- package/server/lib/github/pr-status.test.js +182 -0
- package/server/lib/github/routes.js +36 -30
- package/server/lib/notifications/template-runtime.js +2 -3
- package/server/lib/openchamber-control/action-resolution.test.js +65 -0
- package/server/lib/openchamber-control/actions.js +78 -0
- package/server/lib/openchamber-control/service.js +7 -0
- package/server/lib/openchamber-sessions/routes.js +14 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -4
- package/server/lib/opencode/claude-cli-auth.js +60 -0
- package/server/lib/opencode/claude-cli-auth.test.js +54 -0
- package/server/lib/opencode/feature-routes-runtime.js +11 -0
- package/server/lib/opencode/plugins.js +12 -3
- package/server/lib/opencode/plugins.test.js +18 -0
- package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
- package/server/lib/opencode/proxy.js +116 -6
- package/server/lib/opencode/proxy.test.js +158 -1
- package/server/lib/opencode/routes.js +4 -1
- package/server/lib/opencode/settings-helpers.js +11 -0
- package/server/lib/opencode/settings-helpers.test.js +35 -0
- package/server/lib/opencode/settings-runtime.js +51 -0
- package/server/lib/opencode/shared.js +120 -16
- package/server/lib/opencode/shared.test.js +185 -1
- package/server/lib/project-context/DOCUMENTATION.md +158 -0
- package/server/lib/project-context/routes.http.test.js +264 -0
- package/server/lib/project-context/routes.js +237 -0
- package/server/lib/project-context/runtime.js +667 -0
- package/server/lib/project-context/runtime.test.js +498 -0
- package/server/lib/quota/DOCUMENTATION.md +16 -1
- package/server/lib/quota/providers/claude/auth.js +113 -0
- package/server/lib/quota/providers/claude/auth.test.js +117 -0
- package/server/lib/quota/providers/claude/index.js +151 -0
- package/server/lib/quota/providers/claude/index.test.js +147 -0
- package/server/lib/quota/providers/claude/transforms.js +127 -0
- package/server/lib/quota/providers/claude/transforms.test.js +82 -0
- package/server/lib/quota/providers/command-code.js +90 -0
- package/server/lib/quota/providers/command-code.test.js +72 -0
- package/server/lib/quota/providers/index.js +22 -2
- package/server/lib/quota/providers/index.test.js +10 -1
- package/server/lib/quota/utils/formatters.js +2 -1
- package/server/lib/scheduled-tasks/runtime.js +21 -2
- package/server/lib/session-knowledge/DOCUMENTATION.md +87 -0
- package/server/lib/session-knowledge/routes.js +107 -0
- package/server/lib/session-knowledge/runtime.js +331 -0
- package/server/lib/session-knowledge/runtime.test.js +275 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +22 -22
- package/server/lib/skills-catalog/curated-sources.js +1 -1
- package/server/lib/skills-catalog/curated-sources.test.js +10 -0
- package/server/lib/small-model/index.js +8 -0
- package/server/lib/small-model/index.test.js +31 -1
- package/server/lib/small-model/routes.js +3 -1
- package/dist/assets/DiagramView-CFXxgg_a.js +0 -1
- package/dist/assets/FilesView-BKL6YlKG.js +0 -14
- package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
- package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
- package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
- package/dist/assets/SettingsView-5RmswFZe.js +0 -28
- package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
- package/dist/assets/de-u7gSnqWs.js +0 -9
- package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
- package/dist/assets/es-T9O7aAOr.js +0 -15
- package/dist/assets/fr-Oor7ewbE.js +0 -13
- package/dist/assets/index-BzIpNlNE.css +0 -1
- package/dist/assets/index-C0yNhuZw.js +0 -1
- package/dist/assets/index-DRpChWux.js +0 -7
- package/dist/assets/ja-DHpqbVmr.js +0 -15
- package/dist/assets/ko-CwLkS3nx.js +0 -15
- package/dist/assets/main-DPMd2iKS.js +0 -915
- package/dist/assets/markdownCore-DDrHVneM.js +0 -2
- package/dist/assets/mobile-Br4TtAqc.js +0 -2
- package/dist/assets/pl-CcZILN8q.js +0 -15
- package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
- package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
- package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
- package/dist/assets/uk-BA2kZR38.js +0 -15
- package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
- package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
- package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
- package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
- package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
- package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
- package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
- package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
- package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
- package/server/lib/quota/providers/claude.js +0 -107
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{R as l,r as Te,j as t,f as jt}from"./vendor-react-BUCujlKS.js";import{f as et,y as Ze,h4 as In,cR as Ht,c5 as Wt,t as b,I as D,aU as Vs,aR as Is,cP as wr,aT as Ps,cl as Fs,cm as Rs,cn as Ms,co as Bs,ch as Ut,ci as Kt,B as W,h5 as Pn,h6 as Fn,bs as ut,bt as mt,bu as ht,bv as gt,bw as wt,S as nr,aX as Jt,aY as qt,aZ as Yt,h7 as Rn,h as Re,h8 as Mn,h9 as Bn,ha as Tn,hb as Dn,aQ as En,aa as Ln,bH as An,hc as On,hd as zn,he as Gn,hf as _n,hg as $n,hh as Hn,hi as Wn,bU as yr,bK as Un,bL as Kn,bM as Jn,bN as qn,bO as Yn,hj as Qn,bR as Xn,bx as ks,ew as Zn,V as ea,a0 as ta,a2 as sa,a1 as ra,bk as na,hk as aa,bS as ia,hl as oa,hm as la,a3 as ca,hn as da,a4 as ua,bF as ma,ho as ha,l as ga,bT as fa,g as pa,cq as xa,a9 as wa,Z as ya,hp as ba,hq as Cs}from"./useAppFontEffects-BikB6enL.js";import{u as va,a as ja,d as Ca}from"./main-DPMd2iKS.js";import{s as Na,v as Sa,q as ka,J as Va,X as Ia}from"./runtimeEndpointReset-BVmispdD.js";import{u as ar}from"./vendor-zustand-BAGL70zf.js";import{r as Pa,u as xt}from"./index-DRpChWux.js";import{C as Fa,a as Ra}from"./CommitSection-MJmntVPJ.js";import{P as Ma}from"./PierreDiffViewer-BHm4Yr0X.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-B-bSg3P5.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./SessionSwitcherDropdown-rro-SsaO.js";import"./scheduledTasksApi-ByKya3Un.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-GMc3oR3i.js";import"./computeVirtualFileMetrics-Da00Jg7M.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-CwGocYQd.js";import"./isDiffPlainText-D9YpoLrV.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-CYPvYJDt.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";const br="gitmojiCache",Ba=1e3*60*60*24*7,vr="1",Ta="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",jr=i=>{if(!i||typeof i!="object")return!1;const e=i;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Ns=()=>{if(typeof window>"u")return null;try{const i=window.localStorage.getItem(br);if(!i)return null;const e=JSON.parse(i);return!e||e.version!==vr||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(jr),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Da=i=>{if(!(typeof window>"u"))try{const e={gitmojis:i,fetchedAt:Date.now(),version:vr};window.localStorage.setItem(br,JSON.stringify(e))}catch{return}},ir=i=>Date.now()-i.fetchedAt<Ba;let _t=null;const It=new Set,or=async()=>{if(_t)return _t;const i=(async()=>{try{const e=await fetch(Ta);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const n=await e.json(),r=Array.isArray(n.gitmojis)?n.gitmojis.filter(jr):[];return Da(r),It.forEach(v=>v(r)),r}catch(e){console.warn("Failed to load gitmoji list:",e);const n=[];return It.forEach(r=>r(n)),n}finally{_t=null}})();return _t=i,i},Ea=i=>{const[e,n]=l.useState(()=>i?Ns()?.gitmojis??[]:[]),[r,v]=l.useState(!1),f=l.useRef(i);f.current=i,l.useEffect(()=>{if(!i){It.delete(n),n([]),v(!1);return}const p=Ns();if(p&&(n(p.gitmojis),ir(p)))return;It.add(n),v(!0);let m=!1;return or().finally(()=>{!m&&f.current&&v(!1)}),()=>{m=!0,It.delete(n)}},[i]);const x=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const p=Ns();return p&&ir(p)?p.gitmojis:or()},[e]);return{gitmojis:e,isLoading:r,ensureLoaded:x}},Ct=async(i,e)=>{const n=await Pa(`/api/git/integrate/${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>null);throw new Error(r?.error||`Git integrate request failed: ${n.statusText}`)}return n.json()};async function Vt(i){return Ct("plan",i)}async function La(i){return Ct("conflict-details",{tempWorktreePath:i})}async function Aa(i){return(await Ct("cherry-pick-status",{tempWorktreePath:i})).inProgress}async function Oa(i){return Ct("run",{plan:i})}async function za(i){await Ct("abort",{state:i})}async function Ga(i){return Ct("continue",{state:i})}const _a=({repoRoot:i,sourceBranch:e,worktreeMetadata:n,localBranches:r,defaultTargetBranch:v,refreshKey:f,onRefresh:x,showHeader:p=!0})=>{const{t:m}=et(),w=Ze(h=>h.currentSessionId),B=xt(h=>h.setActiveMainTab),[y,C]=Te.useState(!1),k=Te.useRef(null),[V,A]=Te.useState(v);Te.useEffect(()=>{A(v)},[v]),Te.useEffect(()=>{if(y){const h=setTimeout(()=>{k.current?.focus()},0);return()=>clearTimeout(h)}},[y]);const I=!!(i&&e&&V&&V!=="HEAD"&&e!==V),[d,E]=Te.useState({kind:"idle"}),[R,O]=Te.useState(!1),[N,P]=Te.useState([]),g=Te.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);Te.useEffect(()=>{if(!g||typeof window>"u")return;const h=window.localStorage.getItem(g);if(!h)return;let L=!1;try{const T=JSON.parse(h);if(!T?.tempWorktreePath||T.repoRoot!==i){window.localStorage.removeItem(g);return}(async()=>{const u=await Aa(T.tempWorktreePath).catch(()=>!1);if(L)return;if(!u){window.localStorage.removeItem(g);return}const M=await La(T.tempWorktreePath).catch(()=>null);L||M&&E({kind:"conflict",state:T,details:M})})()}catch{window.localStorage.removeItem(g)}return()=>{L=!0}},[g,i]),Te.useEffect(()=>{if(!I){E({kind:"idle"});return}let h=!1;return E({kind:"loading"}),(async()=>{try{const L=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V});if(h)return;if(E({kind:"ready",plan:L}),L.commits.length>0){const u=L.commits.slice(-50).reverse(),M=await In(i,u);h||(P(M),O(!1))}else h||(P([]),O(!1))}catch{h||E({kind:"idle"})}})(),()=>{h=!0}},[I,i,e,V,f]);const U=Te.useCallback(h=>{w&&Ze.getState().setWorktreeMetadata(w,{...n,createdFromBranch:h})},[w,n]),Y=Ze(h=>h.openNewSessionDraft),S=Te.useCallback(async h=>{const L=await Ht("git.integrate.cherrypick.resolve.visible",{current_commit:h.state.currentCommit,target_branch:h.state.targetBranch}),T=await Ht("git.integrate.cherrypick.resolve.instructions",{repo_root:h.state.repoRoot,temp_worktree_path:h.state.tempWorktreePath,source_branch:h.state.sourceBranch,target_branch:h.state.targetBranch,current_commit:h.state.currentCommit}),u=`Cherry-pick conflict context (JSON)
|
|
1
|
+
import{R as l,r as Te,j as t,f as jt}from"./vendor-react-BUCujlKS.js";import{f as et,y as Ze,hd as In,cR as Ht,c5 as Wt,t as b,I as D,aU as Vs,aR as Is,cP as wr,aT as Ps,cl as Fs,cm as Rs,cn as Ms,co as Bs,ch as Ut,ci as Kt,B as W,he as Pn,hf as Fn,bs as ut,bt as mt,bu as ht,bv as gt,bw as wt,S as nr,aX as Jt,aY as qt,aZ as Yt,hg as Rn,h as Re,hh as Mn,hi as Bn,hj as Tn,hk as Dn,aQ as En,aa as Ln,bH as An,hl as On,hm as zn,hn as Gn,ho as _n,hp as $n,hq as Hn,hr as Wn,bU as yr,bK as Un,bL as Kn,bM as Jn,bN as qn,bO as Yn,hs as Qn,bR as Xn,bx as ks,ex as Zn,V as ea,a0 as ta,a2 as sa,a1 as ra,bk as na,ht as aa,bS as ia,hu as oa,hv as la,a3 as ca,hw as da,a4 as ua,bF as ma,hx as ha,l as ga,bT as fa,g as pa,cq as xa,a9 as wa,Z as ya,hy as ba,hz as Cs}from"./useAppFontEffects-CbzHzFop.js";import{u as va,a as ja,d as Ca}from"./main-BF51IOVF.js";import{s as Na,v as Sa,q as ka,J as Va,X as Ia}from"./runtimeEndpointReset-BMBRhIbf.js";import{u as ar}from"./vendor-zustand-BAGL70zf.js";import{r as Pa,u as xt}from"./index-DzriVon2.js";import{C as Fa,a as Ra}from"./CommitSection-D9cV-qR9.js";import{P as Ma}from"./PierreDiffViewer-D_Gt4A_6.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./SessionSwitcherDropdown-xKU4LRuQ.js";import"./scheduledTasksApi-01zzfzqH.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-DCLjCO9n.js";import"./computeVirtualFileMetrics-DYFv_yZS.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-B37yB9jZ.js";import"./isDiffPlainText-DwHKxDYc.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-CegKdDXi.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";const br="gitmojiCache",Ba=1e3*60*60*24*7,vr="1",Ta="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",jr=i=>{if(!i||typeof i!="object")return!1;const e=i;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Ns=()=>{if(typeof window>"u")return null;try{const i=window.localStorage.getItem(br);if(!i)return null;const e=JSON.parse(i);return!e||e.version!==vr||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(jr),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Da=i=>{if(!(typeof window>"u"))try{const e={gitmojis:i,fetchedAt:Date.now(),version:vr};window.localStorage.setItem(br,JSON.stringify(e))}catch{return}},ir=i=>Date.now()-i.fetchedAt<Ba;let _t=null;const It=new Set,or=async()=>{if(_t)return _t;const i=(async()=>{try{const e=await fetch(Ta);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const n=await e.json(),r=Array.isArray(n.gitmojis)?n.gitmojis.filter(jr):[];return Da(r),It.forEach(v=>v(r)),r}catch(e){console.warn("Failed to load gitmoji list:",e);const n=[];return It.forEach(r=>r(n)),n}finally{_t=null}})();return _t=i,i},Ea=i=>{const[e,n]=l.useState(()=>i?Ns()?.gitmojis??[]:[]),[r,v]=l.useState(!1),f=l.useRef(i);f.current=i,l.useEffect(()=>{if(!i){It.delete(n),n([]),v(!1);return}const p=Ns();if(p&&(n(p.gitmojis),ir(p)))return;It.add(n),v(!0);let m=!1;return or().finally(()=>{!m&&f.current&&v(!1)}),()=>{m=!0,It.delete(n)}},[i]);const x=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const p=Ns();return p&&ir(p)?p.gitmojis:or()},[e]);return{gitmojis:e,isLoading:r,ensureLoaded:x}},Ct=async(i,e)=>{const n=await Pa(`/api/git/integrate/${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>null);throw new Error(r?.error||`Git integrate request failed: ${n.statusText}`)}return n.json()};async function Vt(i){return Ct("plan",i)}async function La(i){return Ct("conflict-details",{tempWorktreePath:i})}async function Aa(i){return(await Ct("cherry-pick-status",{tempWorktreePath:i})).inProgress}async function Oa(i){return Ct("run",{plan:i})}async function za(i){await Ct("abort",{state:i})}async function Ga(i){return Ct("continue",{state:i})}const _a=({repoRoot:i,sourceBranch:e,worktreeMetadata:n,localBranches:r,defaultTargetBranch:v,refreshKey:f,onRefresh:x,showHeader:p=!0})=>{const{t:m}=et(),w=Ze(h=>h.currentSessionId),B=xt(h=>h.setActiveMainTab),[y,C]=Te.useState(!1),k=Te.useRef(null),[V,A]=Te.useState(v);Te.useEffect(()=>{A(v)},[v]),Te.useEffect(()=>{if(y){const h=setTimeout(()=>{k.current?.focus()},0);return()=>clearTimeout(h)}},[y]);const I=!!(i&&e&&V&&V!=="HEAD"&&e!==V),[d,E]=Te.useState({kind:"idle"}),[R,O]=Te.useState(!1),[N,P]=Te.useState([]),g=Te.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);Te.useEffect(()=>{if(!g||typeof window>"u")return;const h=window.localStorage.getItem(g);if(!h)return;let L=!1;try{const T=JSON.parse(h);if(!T?.tempWorktreePath||T.repoRoot!==i){window.localStorage.removeItem(g);return}(async()=>{const u=await Aa(T.tempWorktreePath).catch(()=>!1);if(L)return;if(!u){window.localStorage.removeItem(g);return}const M=await La(T.tempWorktreePath).catch(()=>null);L||M&&E({kind:"conflict",state:T,details:M})})()}catch{window.localStorage.removeItem(g)}return()=>{L=!0}},[g,i]),Te.useEffect(()=>{if(!I){E({kind:"idle"});return}let h=!1;return E({kind:"loading"}),(async()=>{try{const L=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V});if(h)return;if(E({kind:"ready",plan:L}),L.commits.length>0){const u=L.commits.slice(-50).reverse(),M=await In(i,u);h||(P(M),O(!1))}else h||(P([]),O(!1))}catch{h||E({kind:"idle"})}})(),()=>{h=!0}},[I,i,e,V,f]);const U=Te.useCallback(h=>{w&&Ze.getState().setWorktreeMetadata(w,{...n,createdFromBranch:h})},[w,n]),Y=Ze(h=>h.openNewSessionDraft),S=Te.useCallback(async h=>{const L=await Ht("git.integrate.cherrypick.resolve.visible",{current_commit:h.state.currentCommit,target_branch:h.state.targetBranch}),T=await Ht("git.integrate.cherrypick.resolve.instructions",{repo_root:h.state.repoRoot,temp_worktree_path:h.state.tempWorktreePath,source_branch:h.state.sourceBranch,target_branch:h.state.targetBranch,current_commit:h.state.currentCommit}),u=`Cherry-pick conflict context (JSON)
|
|
2
2
|
${JSON.stringify({repoRoot:h.state.repoRoot,tempWorktreePath:h.state.tempWorktreePath,sourceBranch:h.state.sourceBranch,targetBranch:h.state.targetBranch,currentCommit:h.state.currentCommit,remainingCommits:h.state.remainingCommits,statusPorcelain:h.details.statusPorcelain,unmergedFiles:h.details.unmergedFiles,currentPatchMeta:h.details.currentPatchMeta,currentPatch:h.details.currentPatch,diff:h.details.diff},null,2)}`;return{visibleText:L,instructionsText:T,payloadText:u}},[]),F=Wt(h=>h.setPendingInputText),J=Wt(h=>h.setPendingSyntheticParts),H=Te.useCallback(async(h,L)=>{const T=await S(h);if(L){Y({directoryOverride:h.state.tempWorktreePath,initialPrompt:T.visibleText,syntheticParts:[{text:T.instructionsText,synthetic:!0},{text:T.payloadText,synthetic:!0}]}),B("chat");return}if(!w){b.error(m("gitView.integrate.noActiveSession"),{description:m("gitView.integrate.noActiveSessionDescription")});return}F(T.visibleText,"replace"),J([{text:T.instructionsText,synthetic:!0},{text:T.payloadText,synthetic:!0}]),B("chat")},[w,B,S,Y,F,J,m]),G=Te.useCallback(async()=>{if(d.kind==="ready"){if(d.plan.commits.length===0){b.message(m("gitView.integrate.noCommitsToMoveToast"));return}E({kind:"running",plan:d.plan});try{const h=await Oa(d.plan);if(h.kind==="success"){b.success(m("gitView.integrate.commitsMovedToast"),{description:h.moved===1?m("gitView.integrate.commitsMovedDescriptionSingle",{count:h.moved,branch:d.plan.targetBranch}):m("gitView.integrate.commitsMovedDescriptionPlural",{count:h.moved,branch:d.plan.targetBranch})});const L=await Vt(d.plan);E({kind:"ready",plan:L}),x?.();return}h.kind==="conflict"&&(b.error(m("gitView.integrate.cherryPickConflictToast"),{description:m("gitView.integrate.cherryPickConflictDescription")}),E({kind:"conflict",state:h.state,details:h.details}),g&&typeof window<"u"&&window.localStorage.setItem(g,JSON.stringify(h.state)))}catch(h){const L=h instanceof Error?h.message:String(h);b.error(m("gitView.integrate.failedToMoveToast"),{description:L});const T=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V}).catch(()=>null);E(T?{kind:"ready",plan:T}:{kind:"idle"})}}},[d,x,i,e,V,g,m]),Z=Te.useCallback(async()=>{if(d.kind==="conflict")try{await za(d.state),b.message(m("gitView.integrate.cherryPickAbortedToast")),g&&typeof window<"u"&&window.localStorage.removeItem(g)}finally{const h=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V}).catch(()=>null);E(h?{kind:"ready",plan:h}:{kind:"idle"})}},[d,i,e,V,g,m]),Q=Te.useCallback(async()=>{if(d.kind==="conflict")try{const h=await Ga(d.state);if(h.kind==="success"){b.success(m("gitView.integrate.cherryPickFinishedToast"));const L=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V}).catch(()=>null);E(L?{kind:"ready",plan:L}:{kind:"idle"}),g&&typeof window<"u"&&window.localStorage.removeItem(g),x?.();return}h.kind==="conflict"&&(E({kind:"conflict",state:h.state,details:h.details}),g&&typeof window<"u"&&window.localStorage.setItem(g,JSON.stringify(h.state)))}catch(h){const L=h instanceof Error?h.message:String(h);b.error(m("gitView.integrate.cherryPickContinueFailedToast"),{description:L})}},[d,i,e,V,x,g,m]);return!i||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[p?t.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(D,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:m("gitView.integrate.title")}),d.kind==="ready"&&d.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:m("gitView.integrate.toMoveCount",{count:d.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:d.kind==="loading"||d.kind==="running"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null})]}):null,t.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:m("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",V]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Vs,{open:y,onOpenChange:C,children:[t.jsx(Is,{asChild:!0,children:t.jsxs("button",{type:"button",className:wr({size:"default"}),children:[m("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:V}),t.jsx(D,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Ps,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(Fs,{className:"h-full min-h-0",children:[t.jsx(Rs,{ref:k,placeholder:m("gitView.branch.searchPlaceholder"),onKeyDown:h=>h.stopPropagation()}),t.jsxs(Ms,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Bs,{children:m("gitView.branch.empty")}),t.jsx(Ut,{heading:m("gitView.branch.localBranches"),children:r.map(h=>t.jsx(Kt,{value:h,onSelect:()=>{A(h),U(h),C(!1)},children:h},h))})]})]})})]}),d.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{G()},disabled:!I||d.plan.commits.length===0,children:m("gitView.integrate.move")}):d.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:m("gitView.integrate.checking")}):d.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:m("gitView.integrate.moving")}):null]}),d.kind==="ready"&&d.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:m("gitView.integrate.noCommitsToMove")}),d.kind==="ready"&&d.plan.commits.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"typography-meta text-foreground",children:[m("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",d.plan.commits.length,")"]})]}),N.length>0&&d.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>O(h=>!h),className:"typography-micro text-muted-foreground hover:text-foreground",children:m(R?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(R?N:N.slice(0,5)).map(h=>t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"font-mono text-xs text-muted-foreground flex-shrink-0",children:h.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:h.subject||h.sha})]},h.sha)),N.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:m("gitView.integrate.previewUnavailable")}),d.plan.commits.length>N.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:m("gitView.integrate.showingFirstCommits",{count:N.length})})]})]}),d.kind==="conflict"&&t.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 p-3 space-y-2",children:[t.jsx("div",{className:"typography-meta text-foreground",children:m("gitView.integrate.conflictsInFiles",{count:d.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[m("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:d.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[d.details.unmergedFiles.slice(0,6).map(h=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:h},h)),d.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:m("gitView.integrate.moreFiles",{count:d.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{Z()},children:m("gitView.operation.abort")}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!w,onClick:()=>{H({state:d.state,details:d.details},!1)},children:[t.jsx(D,{name:"sparkling",className:"size-3.5"}),m("gitView.integrate.currentSession")]}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{H({state:d.state,details:d.details},!0)},children:[t.jsx(D,{name:"sparkling",className:"size-3.5"}),m("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{Q()},children:m("gitView.operation.continue")})]})]})]})]})},$a=({open:i,onOpenChange:e,directory:n,hasUncommittedChanges:r,hasStagedChanges:v=!1,uncommittedFileCount:f,onChanged:x})=>{const{t:p}=et(),[m,w]=l.useState([]),[B,y]=l.useState(!1),[C,k]=l.useState(""),[V,A]=l.useState(""),[I,d]=l.useState(null),[E,R]=l.useState({}),O=l.useCallback(async()=>{if(n){y(!0);try{const S=await Pn(n);w(S.stashes),R({})}catch(S){b.error(S instanceof Error?S.message:p("gitView.stashes.toast.loadFailed"))}finally{y(!1)}}},[n,p]);l.useEffect(()=>{i&&O()},[O,i]),l.useEffect(()=>{if(!i||!n||m.length===0)return;let S=!1;const F=m.map(J=>J.ref);return Fn(n,F).then(J=>{S||R(J.counts)}).catch(()=>{}),()=>{S=!0}},[n,i,m]);const N=l.useMemo(()=>{const S=C.trim().toLowerCase();return S?m.filter(F=>`${F.ref} ${F.message} ${F.relativeTime}`.toLowerCase().includes(S)):m},[C,m]),P=l.useCallback(async S=>{await O(),await x?.(S)},[O,x]),g=async()=>{if(!(!n||I)){d("create");try{const S=await Rn(n,{message:V.trim()||void 0});S.created?(b.success(p("gitView.stashes.toast.created")),A("")):b.info(p("gitView.stashes.toast.noChanges")),await P({affectsIndex:!!(S.created&&v)})}catch(S){b.error(S instanceof Error?S.message:p("gitView.stashes.toast.createFailed"))}finally{d(null)}}},U=async(S,F)=>{if(!(!n||I)&&!(F==="drop"&&!window.confirm(p("gitView.stashes.confirm.drop",{ref:S.ref})))){d(`${F}:${S.ref}`);try{F==="apply"&&await Mn(n,{ref:S.ref}),F==="pop"&&await Bn(n,{ref:S.ref}),F==="drop"&&await Tn(n,{ref:S.ref});const J=F==="apply"?"gitView.stashes.toast.applySuccess":F==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";b.success(p(J)),await P({affectsIndex:F!=="drop"})}catch(J){const H=F==="apply"?"gitView.stashes.toast.applyFailed":F==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";b.error(J instanceof Error?J.message:p(H)),await P({affectsIndex:F!=="drop"})}finally{d(null)}}},Y=I!==null;return t.jsx(ut,{open:i,onOpenChange:e,children:t.jsxs(mt,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(ht,{children:[t.jsxs(gt,{className:"flex items-center gap-2",children:[t.jsx(D,{name:"archive-stack",className:"h-5 w-5"}),p("gitView.stashes.title")]}),t.jsx(wt,{children:p("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(nr,{value:V,onChange:S=>A(S.target.value),placeholder:p("gitView.stashes.messagePlaceholder"),disabled:Y||!r,className:"flex-1"}),t.jsxs(W,{onClick:g,disabled:!r||Y||!n,children:[I==="create"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"inbox-archive",className:"size-4"}),p("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:p("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(D,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(nr,{value:C,onChange:S=>k(S.target.value),placeholder:p("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:B?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(D,{name:"loader-4",className:"size-5 animate-spin"})}):N.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:p(C?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):N.map((S,F)=>t.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[t.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[t.jsx("p",{className:"typography-small truncate text-foreground",children:S.message||p("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(Jt,{children:[t.jsx(qt,{asChild:!0,children:t.jsx("span",{children:F===0&&!C.trim()?p("gitView.stashes.latestLabel"):p("gitView.stashes.itemNumber",{number:F+1})})}),t.jsx(Yt,{sideOffset:6,children:S.ref})]})," · ",S.relativeTime," · ",typeof E[S.ref]=="number"?p("gitView.stashes.fileCount",{count:E[S.ref]}):p("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Ss,{label:p("gitView.stashes.actions.apply"),loading:I===`apply:${S.ref}`,onClick:()=>U(S,"apply"),disabled:Y,children:t.jsx(D,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Ss,{label:p("gitView.stashes.actions.pop"),loading:I===`pop:${S.ref}`,onClick:()=>U(S,"pop"),disabled:Y,children:t.jsx(D,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Ss,{label:p("gitView.stashes.actions.drop"),loading:I===`drop:${S.ref}`,onClick:()=>U(S,"drop"),disabled:Y,destructive:!0,children:t.jsx(D,{name:"delete-bin",className:"size-4"})})]})]},S.ref))})]})})},Ss=i=>{const e=jt.c(17),{label:n,loading:r,disabled:v,destructive:f,onClick:x,children:p}=i,m=r||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let B;e[0]!==w?(B=Re("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=B):B=e[1];let y;e[2]!==p||e[3]!==r?(y=r?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):p,e[2]=p,e[3]=r,e[4]=y):y=e[4];let C;e[5]!==v||e[6]!==n||e[7]!==x||e[8]!==m||e[9]!==B||e[10]!==y?(C=t.jsx(qt,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":n,"aria-busy":m,className:B,onClick:x,disabled:v,children:y})}),e[5]=v,e[6]=n,e[7]=x,e[8]=m,e[9]=B,e[10]=y,e[11]=C):C=e[11];let k;e[12]!==n?(k=t.jsx(Yt,{sideOffset:6,children:n}),e[12]=n,e[13]=k):k=e[13];let V;return e[14]!==C||e[15]!==k?(V=t.jsxs(Jt,{children:[C,k]}),e[14]=C,e[15]=k,e[16]=V):V=e[16],V},Ha=i=>{const e=jt.c(16),{onOpenStashes:n}=i,{t:r}=et();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(D,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=v):v=e[0];let f;e[1]!==r?(f=r("gitView.empty.cleanTitle"),e[1]=r,e[2]=f):f=e[2];let x;e[3]!==f?(x=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=x):x=e[4];let p;e[5]!==r?(p=r("gitView.empty.cleanDescription"),e[5]=r,e[6]=p):p=e[6];let m;e[7]!==p?(m=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:p}),e[7]=p,e[8]=m):m=e[8];let w;e[9]!==n||e[10]!==r?(w=n?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[t.jsx(D,{name:"archive-stack",className:"size-4"}),r("gitView.stashes.title")]}):null,e[9]=n,e[10]=r,e[11]=w):w=e[11];let B;return e[12]!==x||e[13]!==m||e[14]!==w?(B=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[v,x,m,w]}),e[12]=x,e[13]=m,e[14]=w,e[15]=B):B=e[15],B},dt=8,Wa=i=>{const e=jt.c(18),{laned:n,totalLanes:r,isExpanded:v}=i,{lane:f,color:x,connectors:p}=n,w=Math.max(r,f+1)*dt+dt/2,B=l.useRef(null),y=l.useRef(null);let C;e[0]!==x||e[1]!==p||e[2]!==f||e[3]!==w?(C=()=>{const d=B.current,E=y.current;if(!d||!E)return;const R=d.offsetHeight;if(R===0)return;const O=window.devicePixelRatio||1;E.width=w*O,E.height=R*O;const N=E.getContext("2d");if(!N)return;N.scale(O,O),N.clearRect(0,0,w,R);const P=R/2,g=f*dt+dt/2,U=getComputedStyle(E),Y=U.getPropertyValue("--surface-muted-foreground").trim()||U.color,S=H=>{if(!H.startsWith("var("))return H;const G=H.slice(4,-1).trim();return U.getPropertyValue(G).trim()||Y},F=[...p].sort(Ka);for(const H of F){const G=H.fromLane*dt+dt/2,Z=H.toLane*dt+dt/2,Q=H.type==="passing"?.72:H.type==="branch-out"||H.type==="merge-in"?.95:1;N.beginPath(),N.strokeStyle=S(H.color),N.globalAlpha=Q,N.lineWidth=1.25,N.lineCap="round";e:switch(H.type){case"passing":case"commit-lane":{N.moveTo(G,0),N.lineTo(G,R);break e}case"top-stub":{N.moveTo(G,0),N.lineTo(G,P);break e}case"bottom-stub":{N.moveTo(G,P),N.lineTo(G,R);break e}case"branch-out":{const se=(P+R)/2;N.moveTo(g,P),N.bezierCurveTo(g,se,Z,se,Z,R);break e}case"merge-in":{const se=P/2;N.moveTo(G,0),N.bezierCurveTo(G,se,g,se,g,P);break e}default:continue}N.stroke(),N.globalAlpha=1}const J=U.getPropertyValue("--background").trim()||U.getPropertyValue("--surface-background").trim();N.beginPath(),N.arc(g,P,4,0,Math.PI*2),N.fillStyle=S(x),N.fill(),N.beginPath(),N.arc(g,P,5,0,Math.PI*2),N.strokeStyle=J||Y,N.lineWidth=2,N.stroke()},e[0]=x,e[1]=p,e[2]=f,e[3]=w,e[4]=C):C=e[4];let k;e[5]!==x||e[6]!==p||e[7]!==v||e[8]!==f||e[9]!==n||e[10]!==r||e[11]!==w?(k=[n,f,x,p,r,v,w],e[5]=x,e[6]=p,e[7]=v,e[8]=f,e[9]=n,e[10]=r,e[11]=w,e[12]=k):k=e[12],l.useLayoutEffect(C,k);let V;e[13]!==w?(V={width:w,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=w,e[14]=V):V=e[14];let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("canvas",{ref:y,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=A):A=e[15];let I;return e[16]!==V?(I=t.jsx("div",{ref:B,style:V,children:A}),e[16]=V,e[17]=I):I=e[17],I};function Ua(i){return i==="branch-out"||i==="merge-in"}function Ka(i,e){const n=Ua;return(n(i.type)?1:0)-(n(e.type)?1:0)}const lr=15e3,cr=500,dr=12,ur=8*1024*1024,mr=i=>typeof i=="string"?0:(i.original?.length??0)+(i.modified?.length??0),hr=i=>{if(i.size<=dr){let v=0;for(const f of i.values())v+=mr(f);if(v<=ur)return i}const e=Array.from(i.entries()).reverse(),n=new Map;let r=0;for(const[v,f]of e){if(n.size>=dr)continue;const x=mr(f);r+x>ur&&n.size>0||(n.set(v,f),r+=x)}return new Map(Array.from(n.entries()).reverse())};function gr(i,e){const n=new Date(i);return Number.isNaN(n.getTime())?i:An(n,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Ja(i){switch(i){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 qa(i){return i?i.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.startsWith("HEAD ->");return{label:n?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:n,isTag:e.startsWith("tag: ")}}):[]}const Ya=l.memo(({entry:i,mode:e="history",laned:n,totalLanes:r,isExpanded:v,onToggle:f,files:x,isLoadingFiles:p,onCopyHash:m,directory:w,onConflict:B,onActionSuccess:y})=>{const{t:C}=et(),k=xt(u=>u.timeFormatPreference),V=e==="graph",[A,I]=l.useState(null),[d,E]=l.useState(!1),[R,O]=l.useState(""),[N,P]=l.useState(null),[g,U]=l.useState(new Set),[Y,S]=l.useState(new Map),[F,J]=l.useState(new Set),H=async()=>{if(w){I("checkout");try{await Wn(w,i.hash),b.success(C("gitView.history.actions.detachedHead")),y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},G=async()=>{if(!(!w||!R.trim())){I("createBranch");try{await On(w,R.trim(),i.hash),E(!1),O(""),y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},Z=async()=>{if(w){I("cherryPick");try{const u=await Hn(w,i.hash);u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"cherry-pick"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},Q=async()=>{if(w){I("revert");try{const u=await $n(w,i.hash);u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"revert"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},se=async(u,M=!1)=>{if(!(!w||A!==null)){I("reset");try{await zn(w,i.hash,u,M),y?.()}catch($){b.error(String($.message))}finally{I(null)}}},ce=async()=>{if(!N)return;const u=N;switch(P(null),u){case"checkout":return H();case"cherryPick":return Z();case"revert":return Q();case"merge":return oe();case"rebase":return h();case"resetSoft":return se("soft");case"resetMixed":return se("mixed");case"resetHard":return se("hard",!0)}},oe=async()=>{if(w){I("merge");try{const u=await _n(w,{branch:i.hash});u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"merge"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},h=async()=>{if(w){I("rebase");try{const u=await Gn(w,{onto:i.hash});u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"rebase"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},L=l.useCallback(async u=>{const M=u.path;if(!w){S($=>new Map($).set(M,"error"));return}S($=>hr(new Map($).set(M,"loading")));try{const $=Dn(w,i.hash,u.path,!1),ae=new Promise((ee,_)=>{setTimeout(()=>_(new Error(`Timed out after ${lr}ms`)),lr)}),ie=await Promise.race([$,ae]);S(ee=>hr(new Map(ee).set(M,ie)))}catch{S($=>new Map($).set(M,"error"))}},[w,i.hash]),T=l.useCallback(async u=>{const M=u.path;if(u.changeType==="R"||u.isBinary){U(ee=>{const _=new Set(ee);return _.has(M)?_.delete(M):_.add(M),_});return}const $=Y.get(M);if(g.has(M)&&$&&$!=="error"){U(ee=>{const _=new Set(ee);return _.delete(M),_});return}U(ee=>{const _=new Set(ee);return _.add(M),_}),!($&&$!=="error"||u.insertions+u.deletions>cr&&!F.has(M))&&await L(u)},[Y,F,L,g]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Re("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",V?"hover:bg-[var(--interactive-hover)]/40":v?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[V&&n&&r!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(Wa,{laned:n,totalLanes:r,isExpanded:v})}):t.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[V?(()=>{const u=qa(i.refs);return u.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:u.map(M=>t.jsx("span",{className:Re("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",M.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":M.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:M.label},M.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:i.message}),t.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t.jsx("span",{className:"truncate min-w-[3ch]",title:i.author_name,children:i.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:gr(i.date,k),children:gr(i.date,k)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:i.hash.slice(0,8)}),t.jsxs(Jt,{children:[t.jsx(qt,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:u=>{u.stopPropagation(),m(i.hash)},children:t.jsx(D,{name:"file-copy",className:"size-3"})})}),t.jsx(Yt,{sideOffset:8,children:C("gitView.history.copySha")})]})]})]})]}),v&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[V&&N?t.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:C(`gitView.history.actions.${N}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:A!==null,onClick:u=>{u.stopPropagation(),ce()},children:[A!==null?t.jsx(D,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,C("gitView.history.actions.confirmButton")]}),t.jsx(W,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:A!==null,onClick:u=>{u.stopPropagation(),P(null)},children:C("gitView.history.actions.cancelButton")})]}):V?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("checkout")},children:C("gitView.history.actions.checkout")}),d?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:R,onChange:u=>O(u.target.value),onKeyDown:u=>{u.key==="Enter"&&G(),u.key==="Escape"&&(E(!1),O(""))},placeholder:C("gitView.history.actions.createBranchPlaceholder"),className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:!R.trim()||A!==null,onClick:u=>{u.stopPropagation(),G()},children:[A==="createBranch"?t.jsx(D,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,C("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(W,{variant:"outline",size:"xs",className:"h-6",onClick:u=>{u.stopPropagation(),E(!0)},children:C("gitView.history.actions.createBranch")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("cherryPick")},children:C("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("revert")},children:C("gitView.history.actions.revert")}),t.jsxs(Vs,{children:[t.jsx(Is,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>u.stopPropagation(),children:[A==="reset"?t.jsx(D,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,C("gitView.history.actions.reset")]})}),t.jsx(Ps,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(u=>t.jsx(En,{disabled:A!==null,onSelect:M=>{M.stopPropagation(),P(`reset${u.charAt(0).toUpperCase()+u.slice(1)}`)},children:C(`gitView.history.actions.reset${u.charAt(0).toUpperCase()+u.slice(1)}`)},u))})]}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("merge")},children:C("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("rebase")},children:C("gitView.history.actions.rebase")})]}):null,p?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:C("gitView.history.loadingFiles")})]}):x.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:C("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:x.map(u=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>T(u),className:Re("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",g.has(u.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:Re("font-semibold w-3 text-center shrink-0",Ja(u.changeType)),children:u.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:u.path,children:u.path}),!u.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",u.deletions]})]}),u.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:C("gitView.history.binary")}),t.jsx(D,{name:g.has(u.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),g.has(u.path)&&t.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:u.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:C("gitView.history.renamedNoDiff")}):u.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:C("gitView.history.binaryNoDiff")}):(()=>{const M=u.insertions+u.deletions;if(!F.has(u.path)&&M>cr)return t.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:C("gitView.history.largeDiffTitle",{count:M})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:C("gitView.history.largeDiffDescription")}),t.jsx(W,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{J(ae=>new Set(ae).add(u.path)),L(u)},children:C("gitView.history.renderDiffAnyway")})]});const $=Y.get(u.path);return $==="loading"||$===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:C("gitView.history.loadingDiff")}):$==="error"?t.jsx("button",{type:"button",onClick:()=>T(u),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:C("gitView.history.diffError")}):t.jsx(Ma,{original:$.original,modified:$.modified,language:Ln(u.path)||"",fileName:u.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},u.path))})]})]})}),fr=["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 $t(i){return fr[i%fr.length]}function Qa(i){if(i.length===0)return[];const e=[],n=[];for(let r=0;r<i.length;r++){const v=i[r],f=[];for(let k=0;k<e.length;k++)e[k]===v.hash&&f.push(k);let x=f.length>0?f[0]:-1;if(x===-1){const k=e.indexOf(null);k!==-1?x=k:(x=e.length,e.push(null))}const p=f.slice(1),m=$t(x),w=e[x]===v.hash,B=v.parents.length>0;B?e[x]=v.parents[0]:e[x]=null;const y=[];for(let k=1;k<v.parents.length;k++){const V=v.parents[k],A=e.indexOf(V);if(A!==-1)y.push(A);else{const I=e.indexOf(null),d=I!==-1?I:e.length;e[d]=V,d===e.length&&e.push(V),y.push(d)}}const C=[];w&&B?C.push({fromLane:x,toLane:x,color:m,type:"commit-lane"}):w&&!B?C.push({fromLane:x,toLane:x,color:m,type:"top-stub"}):!w&&B&&C.push({fromLane:x,toLane:x,color:m,type:"bottom-stub"});for(const k of p)C.push({fromLane:k,toLane:x,color:$t(k),type:"merge-in"}),e[k]=null;for(const k of y)C.push({fromLane:x,toLane:k,color:$t(k),type:"branch-out"});for(let k=0;k<e.length;k++)e[k]!==null&&k!==x&&(y.includes(k)||C.push({fromLane:k,toLane:k,color:$t(k),type:"passing"}));n.push({commit:v,lane:x,color:m,connectors:C})}return n}const Xa=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],Za=i=>{const e=jt.c(84),{mode:n,log:r,isLogLoading:v,logMaxCount:f,onLogMaxCountChange:x,expandedCommitHashes:p,onToggleCommit:m,commitFilesMap:w,loadingCommitHashes:B,onCopyHash:y,directory:C,showHeader:k,contentMaxHeightClassName:V,branchDivider:A,onConflict:I,onActionSuccess:d}=i,E=n===void 0?"history":n,R=k===void 0?!0:k,O=V===void 0?"max-h-[50vh]":V,N=A===void 0?null:A,{t:P}=et(),[g,U]=l.useState(!0),Y=E==="graph";let S;e[0]!==Y||e[1]!==r?(S=Y&&r?Qa(r.all):[],e[0]=Y,e[1]=r,e[2]=S):S=e[2];const F=S;let J;e[3]!==F?(J=Math.max(1,...F.map(ei)),e[3]=F,e[4]=J):J=e[4];const H=J;let G;e[5]!==F?(G=new Map(F.map(ti)),e[5]=F,e[6]=G):G=e[6];const Z=G;if(!r)return null;const Q=N!==null&&N.insertBeforeIndex>0&&N.insertBeforeIndex<r.all.length,se=N!==null&&N.insertBeforeIndex===r.all.length,ce=Q||se;let oe;e[7]!==N||e[8]!==Q||e[9]!==se||e[10]!==r.all?(oe=Q?r.all.slice(0,N.insertBeforeIndex):se?r.all:[],e[7]=N,e[8]=Q,e[9]=se,e[10]=r.all,e[11]=oe):oe=e[11];const h=oe;let L;if(e[12]!==N||e[13]!==w||e[14]!==O||e[15]!==C||e[16]!==p||e[17]!==Q||e[18]!==ce||e[19]!==Y||e[20]!==v||e[21]!==Z||e[22]!==B||e[23]!==r.all||e[24]!==f||e[25]!==H||e[26]!==E||e[27]!==d||e[28]!==I||e[29]!==y||e[30]!==x||e[31]!==m||e[32]!==P||e[33]!==h){const te=Q?r.all.slice(N.insertBeforeIndex):[];let de;e[35]!==N?.direction?(de=N?.direction==="down"?t.jsx(D,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(D,{name:"arrow-up",className:"size-3.5"}),e[35]=N?.direction,e[36]=de):de=e[36];const ve=de;let ue;e[37]!==w||e[38]!==C||e[39]!==p||e[40]!==Y||e[41]!==Z||e[42]!==B||e[43]!==H||e[44]!==E||e[45]!==d||e[46]!==I||e[47]!==y||e[48]!==m?(ue=De=>t.jsx("ul",{className:"divide-y divide-border/60",children:De.map(je=>t.jsx(Ya,{entry:je,mode:E,laned:Y?Z.get(je.hash):void 0,totalLanes:Y?H:void 0,isExpanded:p.has(je.hash),onToggle:()=>m(je.hash),files:w.get(je.hash)??[],isLoadingFiles:B.has(je.hash),onCopyHash:y,directory:C,onConflict:I,onActionSuccess:d},je.hash))}),e[37]=w,e[38]=C,e[39]=p,e[40]=Y,e[41]=Z,e[42]=B,e[43]=H,e[44]=E,e[45]=d,e[46]=I,e[47]=y,e[48]=m,e[49]=ue):ue=e[49];const he=ue;let me;e[50]!==v||e[51]!==r.all.length||e[52]!==f||e[53]!==x||e[54]!==P?(me=r.all.length>=f?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(W,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(f+25),disabled:v,className:"px-3 text-muted-foreground hover:text-foreground",children:v?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(D,{name:"loader-4",className:"size-3 animate-spin"}),P("gitView.history.loadingMore")]}):P("gitView.history.loadMore")})}):null,e[50]=v,e[51]=r.all.length,e[52]=f,e[53]=x,e[54]=P,e[55]=me):me=e[55];const le=me;L=t.jsx(yr,{outerClassName:`min-h-0 ${O}`,className:"h-full w-full",children:r.all.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:P("gitView.history.noCommits")})}):ce&&N?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[h.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:he(h)}):null,t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-px flex-1 bg-border/60"}),t.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx("span",{className:"truncate",title:N.branchName,children:N.branchName}),ve]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),te.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:he(te)}):null]}),le]}):t.jsxs(t.Fragment,{children:[he(r.all),le]})}),e[12]=N,e[13]=w,e[14]=O,e[15]=C,e[16]=p,e[17]=Q,e[18]=ce,e[19]=Y,e[20]=v,e[21]=Z,e[22]=B,e[23]=r.all,e[24]=f,e[25]=H,e[26]=E,e[27]=d,e[28]=I,e[29]=y,e[30]=x,e[31]=m,e[32]=P,e[33]=h,e[34]=L}else L=e[34];const T=L;if(!R){if(ce){let de;return e[56]!==T?(de=t.jsx("section",{className:"h-full min-h-0",children:T}),e[56]=T,e[57]=de):de=e[57],de}let te;return e[58]!==T?(te=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:T}),e[58]=T,e[59]=te):te=e[59],te}let u;e[60]!==P?(u=P("gitView.history.title"),e[60]=P,e[61]=u):u=e[61];let M;e[62]!==u?(M=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:u}),e[62]=u,e[63]=M):M=e[63];let $;e[64]!==v||e[65]!==g||e[66]!==f||e[67]!==x||e[68]!==P?($=g&&t.jsx("div",{onClick:si,onPointerDown:ri,children:t.jsxs(Un,{value:String(f),onValueChange:te=>x(Number(te)),disabled:v,children:[t.jsx(Kn,{size:"sm",className:"w-auto",disabled:v,children:t.jsx(Jn,{placeholder:P("gitView.history.commitsPlaceholder")})}),t.jsx(qn,{children:Xa.map(te=>t.jsx(Yn,{value:String(te.value),children:P(te.labelKey)},te.value))})]})}),e[64]=v,e[65]=g,e[66]=f,e[67]=x,e[68]=P,e[69]=$):$=e[69];let ae;e[70]!==g?(ae=g?t.jsx(D,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(D,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=g,e[71]=ae):ae=e[71];let ie;e[72]!==$||e[73]!==ae?(ie=t.jsxs("div",{className:"flex items-center gap-2",children:[$,ae]}),e[72]=$,e[73]=ae,e[74]=ie):ie=e[74];let ee;e[75]!==M||e[76]!==ie?(ee=t.jsxs(Na,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[M,ie]}),e[75]=M,e[76]=ie,e[77]=ee):ee=e[77];let _;e[78]!==T?(_=t.jsx(Sa,{children:T}),e[78]=T,e[79]=_):_=e[79];let be;return e[80]!==g||e[81]!==ee||e[82]!==_?(be=t.jsxs(ka,{open:g,onOpenChange:U,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[ee,_]}),e[80]=g,e[81]=ee,e[82]=_,e[83]=be):be=e[83],be};function ei(i){return i.lane+1}function ti(i){return[i.commit.hash,i]}function si(i){return i.stopPropagation()}function ri(i){return i.stopPropagation()}const ni=i=>{const e=jt.c(150),{open:n,onOpenChange:r,conflictFiles:v,directory:f,operation:x,onAbort:p,onClearState:m}=i;let w;e[0]!==v?(w=v===void 0?[]:v,e[0]=v,e[1]=w):w=e[1];const B=w,{t:y}=et(),C=Ze(ai),k=Ze(ii),V=Wt(oi),A=Wt(li),I=xt(ci),[d,E]=l.useState(!1),[R,O]=l.useState(null),[N,P]=l.useState(null);let g,U;e[2]!==f||e[3]!==n||e[4]!==y?(g=()=>{!n||!f||(E(!0),P(null),O(null),Qn(f).then(X=>{O(X)}).catch(X=>{const Pe=X instanceof Error?X.message:y("gitView.conflict.loadFailed");P(Pe)}).finally(()=>{E(!1)}))},U=[n,f,y],e[2]=f,e[3]=n,e[4]=y,e[5]=g,e[6]=U):(g=e[5],U=e[6]),l.useEffect(g,U);let Y;e[7]!==R||e[8]!==f||e[9]!==x?(Y=async()=>{if(!R)return null;const X=x==="merge"?"merge":"rebase",Pe=R.headInfo||(x==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Oe=x==="merge"?"git commit --no-edit":"git rebase --continue",ze=await Ht("git.conflict.resolve.visible",{operation_label:X,head_ref:Pe}),Fe=await Ht("git.conflict.resolve.instructions",{operation_label:X,directory:f,operation:x,head_info:R.headInfo||"N/A",continue_cmd:Oe}),pe=`${X} conflict context (JSON)
|
|
3
|
-
${JSON.stringify({directory:f,operation:R.operation,headInfo:R.headInfo,statusPorcelain:R.statusPorcelain,unmergedFiles:R.unmergedFiles,diff:R.diff},null,2)}`;return{visibleText:ze,instructionsText:Fe,payloadText:pe}},e[7]=R,e[8]=f,e[9]=x,e[10]=Y):Y=e[10];const S=Y;let F;e[11]!==p||e[12]!==r?(F=()=>{p(),r(!1)},e[11]=p,e[12]=r,e[13]=F):F=e[13];const J=F;let H;e[14]!==m||e[15]!==r?(H=()=>{m?.(),r(!1)},e[14]=m,e[15]=r,e[16]=H):H=e[16];const G=H;let Z;e[17]!==S||e[18]!==k||e[19]!==m||e[20]!==r||e[21]!==I||e[22]!==V||e[23]!==A||e[24]!==y?(Z=async()=>{const X=await S();if(!X){b.error(y("gitView.conflict.noDetailsAvailable"));return}if(!k){b.error(y("gitView.conflict.noActiveSession"),{description:y("gitView.conflict.noActiveSessionDescription")});return}V(X.visibleText,"replace"),A([{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]),I("chat"),m?.(),r(!1)},e[17]=S,e[18]=k,e[19]=m,e[20]=r,e[21]=I,e[22]=V,e[23]=A,e[24]=y,e[25]=Z):Z=e[25];const Q=Z;let se;e[26]!==S||e[27]!==f||e[28]!==m||e[29]!==r||e[30]!==C||e[31]!==I||e[32]!==y?(se=async()=>{const X=await S();if(!X){b.error(y("gitView.conflict.noDetailsAvailable"));return}C({directoryOverride:f,initialPrompt:X.visibleText,syntheticParts:[{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]}),I("chat"),m?.(),r(!1)},e[26]=S,e[27]=f,e[28]=m,e[29]=r,e[30]=C,e[31]=I,e[32]=y,e[33]=se):se=e[33];const ce=se;let oe,h,L,T,u,M,$,ae,ie,ee,_,be,te,de,ve,ue,he,me,le,De,je,ge;if(e[34]!==R||e[35]!==B||e[36]!==k||e[37]!==J||e[38]!==G||e[39]!==Q||e[40]!==ce||e[41]!==d||e[42]!==N||e[43]!==r||e[44]!==n||e[45]!==x||e[46]!==y){const X=y(x==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),Pe=R?.unmergedFiles||B;L=ut,je=n,ge=r,h=mt,De="max-w-md w-[calc(100vw-2rem)]",de="flex flex-col gap-4 overflow-hidden";let Oe;e[69]===Symbol.for("react.memo_cache_sentinel")?(Oe=t.jsx(D,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[69]=Oe):Oe=e[69];const ze=t.jsxs("div",{className:"flex items-center gap-2",children:[Oe,t.jsx(gt,{children:y("gitView.conflict.detectedTitle",{operation:X})})]});let Fe;e[70]!==x||e[71]!==y?(Fe=y("gitView.conflict.detectedDescription",{operation:x}),e[70]=x,e[71]=y,e[72]=Fe):Fe=e[72];let pe;e[73]!==Fe?(pe=t.jsx(wt,{children:Fe}),e[73]=Fe,e[74]=pe):pe=e[74],e[75]!==ze||e[76]!==pe?(ve=t.jsxs(ht,{children:[ze,pe]}),e[75]=ze,e[76]=pe,e[77]=ve):ve=e[77],e[78]!==d||e[79]!==y?(ue=d&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:y("gitView.conflict.loading")})]}),e[78]=d,e[79]=y,e[80]=ue):ue=e[80],e[81]!==N||e[82]!==y?(he=N&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:y("gitView.conflict.errorLoadingDetails",{message:N})}),e[81]=N,e[82]=y,e[83]=he):he=e[83],e[84]!==Pe||e[85]!==y?(me=Pe.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:Pe.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:Pe.map(di)})})]}),e[84]=Pe,e[85]=y,e[86]=me):me=e[86],e[87]!==R||e[88]!==y?(le=R?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.conflict.headInfo")}),t.jsx("div",{className:"typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:R.headInfo})]}),e[87]=R,e[88]=y,e[89]=le):le=e[89],_="flex flex-col gap-2 pt-2";let Ce;e[90]!==ce?(Ce=()=>{ce()},e[90]=ce,e[91]=Ce):Ce=e[91];const Ge=d||!R;let Ne;e[92]!==d?(Ne=d?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"add",className:"size-4"}),e[92]=d,e[93]=Ne):Ne=e[93];let Be;e[94]!==y?(Be=y("gitView.conflict.resolveNewSession"),e[94]=y,e[95]=Be):Be=e[95],e[96]!==Ce||e[97]!==Ge||e[98]!==Ne||e[99]!==Be?(be=t.jsxs(W,{variant:"default",onClick:Ce,disabled:Ge,className:"w-full gap-2",children:[Ne,Be]}),e[96]=Ce,e[97]=Ge,e[98]=Ne,e[99]=Be,e[100]=be):be=e[100];let q;e[101]!==Q?(q=()=>{Q()},e[101]=Q,e[102]=q):q=e[102];const xe=d||!R||!k;let Se;e[103]!==d?(Se=d?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"chat-1",className:"size-4"}),e[103]=d,e[104]=Se):Se=e[104];let we;e[105]!==y?(we=y("gitView.conflict.resolveCurrentSession"),e[105]=y,e[106]=we):we=e[106],e[107]!==q||e[108]!==xe||e[109]!==Se||e[110]!==we?(te=t.jsxs(W,{variant:"outline",onClick:q,disabled:xe,className:"w-full gap-2",children:[Se,we]}),e[107]=q,e[108]=xe,e[109]=Se,e[110]=we,e[111]=te):te=e[111],ie="flex gap-2 pt-1";let ye;e[112]!==y?(ye=y("gitView.conflict.continueLater"),e[112]=y,e[113]=ye):ye=e[113],e[114]!==G||e[115]!==ye?(ee=t.jsx(W,{variant:"ghost",size:"sm",onClick:G,className:"flex-1",children:ye}),e[114]=G,e[115]=ye,e[116]=ee):ee=e[116],oe=W,T="destructive",u="sm",M=J,$="flex-1",ae=y("gitView.conflict.abortOperation",{operation:X}),e[34]=R,e[35]=B,e[36]=k,e[37]=J,e[38]=G,e[39]=Q,e[40]=ce,e[41]=d,e[42]=N,e[43]=r,e[44]=n,e[45]=x,e[46]=y,e[47]=oe,e[48]=h,e[49]=L,e[50]=T,e[51]=u,e[52]=M,e[53]=$,e[54]=ae,e[55]=ie,e[56]=ee,e[57]=_,e[58]=be,e[59]=te,e[60]=de,e[61]=ve,e[62]=ue,e[63]=he,e[64]=me,e[65]=le,e[66]=De,e[67]=je,e[68]=ge}else oe=e[47],h=e[48],L=e[49],T=e[50],u=e[51],M=e[52],$=e[53],ae=e[54],ie=e[55],ee=e[56],_=e[57],be=e[58],te=e[59],de=e[60],ve=e[61],ue=e[62],he=e[63],me=e[64],le=e[65],De=e[66],je=e[67],ge=e[68];let Ve;e[117]!==oe||e[118]!==T||e[119]!==u||e[120]!==M||e[121]!==$||e[122]!==ae?(Ve=t.jsx(oe,{variant:T,size:u,onClick:M,className:$,children:ae}),e[117]=oe,e[118]=T,e[119]=u,e[120]=M,e[121]=$,e[122]=ae,e[123]=Ve):Ve=e[123];let Me;e[124]!==ie||e[125]!==ee||e[126]!==Ve?(Me=t.jsxs("div",{className:ie,children:[ee,Ve]}),e[124]=ie,e[125]=ee,e[126]=Ve,e[127]=Me):Me=e[127];let Ee;e[128]!==_||e[129]!==be||e[130]!==te||e[131]!==Me?(Ee=t.jsxs("div",{className:_,children:[be,te,Me]}),e[128]=_,e[129]=be,e[130]=te,e[131]=Me,e[132]=Ee):Ee=e[132];let Ie;e[133]!==de||e[134]!==ve||e[135]!==ue||e[136]!==he||e[137]!==me||e[138]!==le||e[139]!==Ee?(Ie=t.jsxs("div",{className:de,children:[ve,ue,he,me,le,Ee]}),e[133]=de,e[134]=ve,e[135]=ue,e[136]=he,e[137]=me,e[138]=le,e[139]=Ee,e[140]=Ie):Ie=e[140];let Le;e[141]!==h||e[142]!==De||e[143]!==Ie?(Le=t.jsx(h,{className:De,children:Ie}),e[141]=h,e[142]=De,e[143]=Ie,e[144]=Le):Le=e[144];let fe;return e[145]!==L||e[146]!==je||e[147]!==ge||e[148]!==Le?(fe=t.jsx(L,{open:je,onOpenChange:ge,children:Le}),e[145]=L,e[146]=je,e[147]=ge,e[148]=Le,e[149]=fe):fe=e[149],fe};function ai(i){return i.openNewSessionDraft}function ii(i){return i.currentSessionId}function oi(i){return i.setPendingInputText}function li(i){return i.setPendingSyntheticParts}function ci(i){return i.setActiveMainTab}function di(i){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:i,children:i},i)}const ui=({open:i,onOpenChange:e,operation:n,targetBranch:r,onConfirm:v})=>{const{t:f}=et(),[x,p]=l.useState(!0),[m,w]=l.useState(!1),B=f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),y=async()=>{w(!0);try{await v(x),e(!1)}catch(k){const V=k instanceof Error?k.message:`Failed to ${n}`;b.error(V)}finally{w(!1)}},C=()=>{m||e(!1)};return t.jsx(ut,{open:i,onOpenChange:m?void 0:e,children:t.jsxs(mt,{className:"max-w-md",children:[t.jsxs(ht,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(gt,{children:f("gitView.stash.title")})]}),t.jsx(wt,{children:f("gitView.stash.description",{operation:n})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(n==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:r})]}),x&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(Xn,{checked:x,onChange:p,disabled:m,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!m&&p(!x),children:f("gitView.stash.restoreAfterOperation",{operation:n})})]}),t.jsxs(ks,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:C,disabled:m,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:y,disabled:m,className:"gap-1.5",children:m?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:B})})]})]})})},mi=({mergeInProgress:i,rebaseInProgress:e,onContinue:n,onAbort:r,onResolveWithAI:v,conflictCount:f=0,isLoading:x=!1})=>{const{t:p}=et(),[m,w]=l.useState(null),B=i&&i.head,y=e&&(e.headName||e.onto),C=B?"merge":y?"rebase":null;if(!C)return null;const k=async()=>{w("continue");try{await n()}finally{w(null)}},V=async()=>{w("abort");try{await r()}finally{w(null)}},A=m!==null,I=f>0,d=p(C==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let E="";i?E=i.message?p("gitView.operation.mergingMessage",{message:i.message}):p("gitView.operation.mergeInProgressWithHead",{head:i.head}):e&&(E=e.headName?p("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):p("gitView.operation.rebaseInProgress"));const R=I?f===1?p("gitView.operation.inProgressTitleOneConflict",{operation:d,count:f}):p("gitView.operation.inProgressTitleManyConflicts",{operation:d,count:f}):p("gitView.operation.inProgressTitle",{operation:d}),O=p(I?"gitView.operation.resolveConflictsHint":"gitView.operation.readyToContinueHint");return t.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:t.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:R}),E&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:E})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:O}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:V,disabled:A||x,className:"gap-1.5",children:[m==="abort"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"close",className:"size-4"}),p("gitView.operation.abort")]}),I?v&&t.jsx(W,{variant:"default",size:"sm",onClick:v,disabled:A||x,children:p("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:k,disabled:A||x,className:"gap-1.5",children:[m==="continue"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"check",className:"size-4"}),p("gitView.operation.continue")]})]})]})]})})},hi=i=>{const e=jt.c(104),{currentBranch:n,localBranches:r,remoteBranches:v,onMerge:f,onRebase:x,disabled:p,isOperating:m,operationLogs:w,onOperationComplete:B,mode:y,defaultTargetBranch:C}=i,k=p===void 0?!1:p,V=m===void 0?!1:m,A=w===void 0?[]:w,I=y===void 0?"dialog":y,{t:d}=et(),[E,R]=l.useState(!1),[O,N]=l.useState("merge"),[P,g]=l.useState(null),[U,Y]=l.useState(!1),[S,F]=l.useState(""),J=l.useRef(null),H=l.useRef(null),G=k||V,Z=n||d("gitView.branch.currentBranchFallback"),Q=A.length>0&&A.every(gi),se=A.some(fi);let ce;e[0]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{H.current&&(H.current.scrollTop=H.current.scrollHeight)},e[0]=ce):ce=e[0],l.useEffect(ce,[A]);let oe;if(e[1]!==S||e[2]!==n||e[3]!==r||e[4]!==v){e:{const q=S.toLowerCase();let xe;e[6]!==v?(xe=new Set(v.map(pi).filter(Boolean)),e[6]=v,e[7]=xe):xe=e[7];const Se=xe;let we;e[8]!==n||e[9]!==Se?(we=_e=>_e!==n&&!Se.has(_e),e[8]=n,e[9]=Se,e[10]=we):we=e[10];const ye=r.filter(we);if(!q){oe=ye;break e}oe=ye.filter(_e=>_e.toLowerCase().includes(q))}e[1]=S,e[2]=n,e[3]=r,e[4]=v,e[5]=oe}else oe=e[5];const h=oe;let L;if(e[11]!==S||e[12]!==v){e:{const q=S.toLowerCase();if(!q){L=v;break e}L=v.filter(xe=>xe.toLowerCase().includes(q))}e[11]=S,e[12]=v,e[13]=L}else L=e[13];const T=L;let u;e[14]!==C||e[15]!==r||e[16]!==v?(u=()=>C&&(v.includes(C)||r.includes(C))?C:null,e[14]=C,e[15]=r,e[16]=v,e[17]=u):u=e[17];const M=u;let $;e[18]!==M||e[19]!==R?($=()=>{R(!0),g(M()),N("merge"),F("")},e[18]=M,e[19]=R,e[20]=$):$=e[20];const ae=$;let ie;e[21]===Symbol.for("react.memo_cache_sentinel")?(ie=q=>{g(q),Y(!1),F("")},e[21]=ie):ie=e[21];const ee=ie;let _;e[22]!==f||e[23]!==x||e[24]!==O||e[25]!==P?(_=()=>{P&&(O==="merge"?f(P):x(P))},e[22]=f,e[23]=x,e[24]=O,e[25]=P,e[26]=_):_=e[26];const be=_;let te;e[27]!==V||e[28]!==R?(te=()=>{V||(g(null),N("merge"),F(""),R(!1))},e[27]=V,e[28]=R,e[29]=te):te=e[29];const de=te,ve=()=>{V&&!Q||(Q&&B?.(),g(null),N("merge"),F(""),R(!1))};let ue,he;e[30]!==U?(ue=()=>{U||F("")},he=[U],e[30]=U,e[31]=ue,e[32]=he):(ue=e[31],he=e[32]),l.useEffect(ue,he);let me,le;e[33]!==I||e[34]!==M||e[35]!==P?(me=()=>{I==="dialog"||P||g(M())},le=[I,M,P],e[33]=I,e[34]=M,e[35]=P,e[36]=me,e[37]=le):(me=e[36],le=e[37]),l.useEffect(me,le);const ge=V?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:H,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:t.jsx("div",{className:"space-y-2",children:A.map(xi)})}),Q?I==="dialog"?t.jsx(ks,{children:t.jsx(W,{variant:"default",size:"sm",onClick:ve,children:d(se?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:ve,children:d(se?"gitView.common.close":"gitView.common.done")})}):null]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:d("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>N("merge"),className:Re("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",O==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"git-merge",className:Re("size-4",O==="merge"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Re("typography-ui-label",O==="merge"?"text-foreground":"text-muted-foreground"),children:d("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:d("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>N("rebase"),className:Re("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",O==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"git-branch",className:Re("size-4",O==="rebase"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Re("typography-ui-label",O==="rebase"?"text-foreground":"text-muted-foreground"),children:d("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:d("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:O==="merge"?d("gitView.branch.branchToMergeInto",{branch:Z}):d("gitView.branch.branchToRebaseOnto")}),t.jsxs(Vs,{open:U,onOpenChange:Y,modal:!1,children:[t.jsx(Is,{asChild:!0,children:t.jsxs("button",{type:"button",className:Re(wr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Re("truncate",!P&&"text-muted-foreground"),children:P||d("gitView.branch.selectBranch")}),t.jsx(D,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Ps,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:t.jsxs(Fs,{className:"h-full min-h-0",children:[t.jsx(Rs,{ref:J,placeholder:d("gitView.branch.searchPlaceholder"),value:S,onValueChange:F,onKeyDown:wi}),t.jsxs(Ms,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Bs,{children:d("gitView.branch.empty")}),h.length>0&&t.jsx(Ut,{heading:d("gitView.branch.localBranches"),children:h.map(q=>t.jsx(Kt,{onSelect:()=>ee(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`local-${q}`))}),h.length>0&&T.length>0?t.jsx(Zn,{}):null,T.length>0&&t.jsx(Ut,{heading:d("gitView.branch.remoteBranches"),children:T.map(q=>t.jsx(Kt,{onSelect:()=>ee(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`remote-${q}`))})]})]})})]})]}),P?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:O==="merge"?t.jsxs(t.Fragment,{children:[d("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P})," ",d("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z})]}):t.jsxs(t.Fragment,{children:[d("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z})," ",d("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P})]})})}):null,I==="dialog"?t.jsxs(ks,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:de,children:d("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:be,disabled:!P,className:"gap-1.5",children:O==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"git-merge",className:"size-4"}),d("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"git-branch",className:"size-4"}),d("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:de,disabled:G,children:d("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:be,disabled:G||!P,children:d(O==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(I==="bare")return ge;if(I==="inline"){let q;e[38]!==d?(q=d("gitView.branch.updateTitle"),e[38]=d,e[39]=q):q=e[39];let xe;e[40]!==q?(xe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:q}),e[40]=q,e[41]=xe):xe=e[41];let Se;e[42]!==d?(Se=d("gitView.branch.updateDescriptionPrefix"),e[42]=d,e[43]=Se):Se=e[43];let we;e[44]!==Z?(we=t.jsx("span",{className:"font-mono text-foreground",children:Z}),e[44]=Z,e[45]=we):we=e[45];let ye;e[46]!==Se||e[47]!==we?(ye=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Se," ",we,"."]}),e[46]=Se,e[47]=we,e[48]=ye):ye=e[48];let _e;e[49]!==xe||e[50]!==ye?(_e=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[xe,ye]})}),e[49]=xe,e[50]=ye,e[51]=_e):_e=e[51];let tt;e[52]!==ge?(tt=t.jsx("div",{className:"pt-3",children:ge}),e[52]=ge,e[53]=tt):tt=e[53];let st;return e[54]!==_e||e[55]!==tt?(st=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[_e,tt]}),e[54]=_e,e[55]=tt,e[56]=st):st=e[56],st}let Ve;e[57]!==V?(Ve=V?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"git-merge",className:"size-4"}),e[57]=V,e[58]=Ve):Ve=e[58];let Me;e[59]!==d?(Me=d("gitView.branch.mergeRebase"),e[59]=d,e[60]=Me):Me=e[60];let Ee;e[61]!==Me?(Ee=t.jsx("span",{children:Me}),e[61]=Me,e[62]=Ee):Ee=e[62];let Ie;e[63]!==ae||e[64]!==G||e[65]!==Ve||e[66]!==Ee?(Ie=t.jsx(qt,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:ae,disabled:G,children:[Ve,Ee]})}),e[63]=ae,e[64]=G,e[65]=Ve,e[66]=Ee,e[67]=Ie):Ie=e[67];let Le;e[68]!==d?(Le=d("gitView.branch.mergeRebaseTooltip"),e[68]=d,e[69]=Le):Le=e[69];let fe;e[70]!==Le?(fe=t.jsx(Yt,{sideOffset:8,children:Le}),e[70]=Le,e[71]=fe):fe=e[71];let X;e[72]!==Ie||e[73]!==fe?(X=t.jsxs(Jt,{children:[Ie,fe]}),e[72]=Ie,e[73]=fe,e[74]=X):X=e[74];let Pe;e[75]!==ve||e[76]!==R?(Pe=q=>{q?R(!0):ve()},e[75]=ve,e[76]=R,e[77]=Pe):Pe=e[77];let Oe;e[78]!==d?(Oe=d("gitView.branch.updateTitle"),e[78]=d,e[79]=Oe):Oe=e[79];let ze;e[80]!==Oe?(ze=t.jsx(gt,{children:Oe}),e[80]=Oe,e[81]=ze):ze=e[81];let Fe;e[82]!==se||e[83]!==V||e[84]!==O||e[85]!==Q||e[86]!==d||e[87]!==Z?(Fe=V?d(Q?se?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":O==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[d("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z}),"."]}),e[82]=se,e[83]=V,e[84]=O,e[85]=Q,e[86]=d,e[87]=Z,e[88]=Fe):Fe=e[88];let pe;e[89]!==Fe?(pe=t.jsx(wt,{children:Fe}),e[89]=Fe,e[90]=pe):pe=e[90];let Ce;e[91]!==ze||e[92]!==pe?(Ce=t.jsxs(ht,{children:[ze,pe]}),e[91]=ze,e[92]=pe,e[93]=Ce):Ce=e[93];let Ge;e[94]!==ge||e[95]!==Ce?(Ge=t.jsxs(mt,{className:"max-w-md",children:[Ce,ge]}),e[94]=ge,e[95]=Ce,e[96]=Ge):Ge=e[96];let Ne;e[97]!==E||e[98]!==Pe||e[99]!==Ge?(Ne=t.jsx(ut,{open:E,onOpenChange:Pe,children:Ge}),e[97]=E,e[98]=Pe,e[99]=Ge,e[100]=Ne):Ne=e[100];let Be;return e[101]!==X||e[102]!==Ne?(Be=t.jsxs(t.Fragment,{children:[X,Ne]}),e[101]=X,e[102]=Ne,e[103]=Be):Be=e[103],Be};function gi(i){return i.status==="done"||i.status==="error"}function fi(i){return i.status==="error"}function pi(i){return i.slice(i.indexOf("/")+1)}function xi(i,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[i.status==="running"&&t.jsx(D,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),i.status==="done"&&t.jsx(D,{name:"check",className:"size-3.5 text-success"}),i.status==="error"&&t.jsx(D,{name:"close",className:"size-3.5 text-destructive"}),i.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Re("typography-micro",i.status==="error"&&"text-destructive",i.status==="done"&&"text-muted-foreground",i.status==="running"&&"text-foreground",i.status==="pending"&&"text-muted-foreground/60"),children:i.message})]},e)}function wi(i){return i.stopPropagation()}const yi=({runMutation:i,onMutationComplete:e,onMutationError:n,onPathsComplete:r,scheduleFlush:v})=>{const f=[];let x=!1;return{enqueue:m=>{const w=f[f.length-1];if(w?.directory===m.directory&&w.direction===m.direction){m.paths.forEach(B=>w.paths.add(B));return}f.push(m)},flush:()=>{if(x)return;const m=f.shift();if(!m)return;x=!0;const w={directory:m.directory,direction:m.direction,paths:Array.from(m.paths),rollback:m.rollback};(async()=>{try{await i(w),e(w)}catch(B){n(w,B)}finally{r(w.paths),x=!1,f.length>0&&v()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>x}},bi=15e3,vi=40,ji=20,pr={feat:":sparkles:",feature:":sparkles:",fix:":bug:",bug:":bug:",hotfix:":ambulance:",docs:":memo:",documentation:":memo:",style:":lipstick:",refactor:":recycle:",perf:":zap:",performance:":zap:",test:":white_check_mark:",tests:":white_check_mark:",build:":construction_worker:",ci:":green_heart:",chore:":wrench:",revert:":rewind:",wip:":construction:",security:":lock:",release:":bookmark:",merge:":twisted_rightwards_arrows:",mv:":truck:",move:":truck:",rename:":truck:",remove:":fire:",delete:":fire:",add:":sparkles:",create:":sparkles:",implement:":sparkles:",update:":recycle:",improve:":zap:",optimize:":zap:",upgrade:":arrow_up:",downgrade:":arrow_down:",deploy:":rocket:",init:":tada:",initial:":tada:"},Ci=(i,e)=>{const n=i.toLowerCase(),r=/^([a-z]+)(?:\(.*\))?!?:/,v=n.match(r);if(v){const p=v[1],m=pr[p];if(m)return e.find(w=>w.code===m)||null}const f=n.split(" ")[0],x=pr[f];return x&&e.find(p=>p.code===x)||null},Ni=20,vt=new Map,Si=(i,e)=>{if(vt.delete(i),vt.set(i,e),vt.size>Ni){const n=vt.keys().next().value;n!==void 0&&vt.delete(n)}},nt=i=>(i||"").replace(/\\/g,"/").replace(/\/+$/,""),xr=i=>{const e=i.index?.trim();return!!(e&&e!=="?")},ki=i=>{const e=i.working_dir?.trim(),n=i.index?.trim();return!!(e||n==="?")},zl=({isActive:i})=>{const{t:e}=et(),{git:n}=ea(),r=ta(),[v,f]=l.useState(null),[x,p]=l.useState(!1),m=Ze(s=>s.currentSessionId),w=Ze(s=>s.newSessionDraft),B=Ze(s=>s.setDraftBootstrapPendingDirectory),y=Ze(s=>s.worktreeMetadata),C=Ze(s=>s.availableWorktrees),k=nt(r),V=l.useMemo(()=>{if(!k)return;const s=C.find(a=>nt(a.path)===k);if(s)return s;for(const a of y.values())if(nt(a.path)===k)return a},[C,k,y]),A=l.useMemo(()=>{if(m)return y.get(m)??V;if(w?.open)return V},[m,V,w?.open,y]),{profiles:I,globalIdentity:d,defaultGitIdentityId:E,loadProfiles:R,loadGlobalIdentity:O,loadDefaultGitIdentityId:N}=Va(ar(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),P=sa(r??null),g=ra(r??null),U=na(s=>m?s.getAttachment(m):void 0),Y=U?aa(U):[],S=U&&!U.degraded&&!U.legacy?U.worktreeRoot??void 0:void 0,F=va(r,A,g?.current??void 0),J=ia(r??null),H=oa(r??null),G=la(r??null),Z=ca(r??null),Q=da(r??null),{setActiveDirectory:se,fetchAll:ce,ensureAll:oe,fetchStatus:h,fetchBranches:L,fetchLog:T,setLogMaxCount:u,fetchIdentity:M,prefetchDiffs:$,clearDiffCache:ae,moveStatusPathsOptimistically:ie,restoreStatus:ee,bumpIndexRevision:_}=ua(ar(s=>({setActiveDirectory:s.setActiveDirectory,fetchAll:s.fetchAll,ensureAll:s.ensureAll,fetchStatus:s.fetchStatus,fetchBranches:s.fetchBranches,fetchLog:s.fetchLog,setLogMaxCount:s.setLogMaxCount,fetchIdentity:s.fetchIdentity,prefetchDiffs:s.prefetchDiffs,clearDiffCache:s.clearDiffCache,moveStatusPathsOptimistically:s.moveStatusPathsOptimistically,restoreStatus:s.restoreStatus,bumpIndexRevision:s.bumpIndexRevision}))),be=xt(s=>s.isMobile),te=xt(s=>s.openContextDiff),de=xt(s=>s.openContextSurface),ve=g?.current??null,ue=ma(s=>!r||!ve?null:ha(s.entries,r,ve)),he=xt(s=>s.navigateToDiff),me=l.useRef(null),le=l.useRef(null),De=l.useRef(null),je=l.useRef(null),ge=l.useRef(!0);l.useEffect(()=>()=>{ge.current=!1},[]);const Ve=l.useCallback(()=>{le.current!==null&&(window.clearTimeout(le.current),le.current=null)},[]),Me=l.useCallback(s=>{Ve(),le.current=window.setTimeout(()=>{le.current=null,nt(s)===nt(r)&&h(s,n,{silent:!0})},bi)},[Ve,r,h,n]);l.useEffect(()=>Ve,[Ve]);const Ee=l.useCallback(()=>{De.current!==null&&(window.clearTimeout(De.current),De.current=null)},[]),Ie=l.useCallback(()=>{De.current===null&&(De.current=window.setTimeout(()=>{De.current=null,je.current?.()},0))},[]),Le=l.useCallback(async(s,a,o)=>{if(a==="stage"){if(n.stageGitFiles){await n.stageGitFiles(s,o);return}await Promise.all(o.map(c=>n.stageGitFile(s,c)));return}if(n.unstageGitFiles){await n.unstageGitFiles(s,o);return}await Promise.all(o.map(c=>n.unstageGitFile(s,c)))},[n]),fe=l.useMemo(()=>yi({runMutation:({directory:s,direction:a,paths:o})=>Le(s,a,o),onMutationComplete:({directory:s})=>{_(s),Me(s)},onMutationError:({directory:s,direction:a,rollback:o},c)=>{o?.(),_(s),Me(s);const j=e(a==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");b.error(c instanceof Error?c.message:j)},onPathsComplete:s=>{As(a=>{const o=new Set(a);return s.forEach(c=>o.delete(c)),o})},scheduleFlush:Ie}),[_,Le,Ie,Me,e]);l.useEffect(()=>(je.current=fe.flush,()=>{je.current=null}),[fe]),l.useEffect(()=>()=>fe.clear(),[fe]),l.useEffect(()=>Ee,[Ee]),l.useEffect(()=>{if(!i)return;if(!r){f(null),p(!1);return}let s=!1,a=null;const o=async()=>{try{const c=await ba(r);if(s)return;f(c.status),c.status==="pending"&&(a=window.setTimeout(()=>{o()},500))}catch{s||f(null)}};return o(),()=>{s=!0,a!==null&&window.clearTimeout(a)}},[i,r]),l.useEffect(()=>{const s=me.current;me.current=v,!(!r||!n)&&(s==="pending"&&v==="ready"&&(p(!0),ce(r,n).finally(()=>{window.setTimeout(()=>{p(!1)},1200)})),v==="failed"&&(B(null),p(!1)))},[r,ce,n,B,v]);const X=nt(w?.bootstrapPendingDirectory??null),Pe=!!(r&&X&&X===nt(r)),ze=!!(r&&(v==="pending"||Pe))||x,Fe=l.useMemo(()=>r?vt.get(r)??null:null,[r]),pe=ga(s=>s.settingsGitmojiEnabled),[Ce,Ge]=l.useState(null),{gitmojis:Ne}=Ea(pe);l.useEffect(()=>{const s=S||F?.projectDirectory;if(!s){Ge(null);return}let a=!1;return fa(s).then(o=>{if(a)return;const c=o.trim();Ge(c&&c!=="HEAD"?c:null)}).catch(()=>{a||Ge(null)}),()=>{a=!0}},[S,F?.projectDirectory]);const[Be,q]=l.useState(Fe?.commitMessage??""),[xe,Se]=l.useState([]),[we,ye]=l.useState(!1),_e=l.useRef(null),[tt,st]=l.useState(null),[Cr,Qt]=l.useState(!1),[Ts,Ds]=l.useState(null),[Je,Nr]=l.useState(25),[Sr,Es]=l.useState(!1),{triggerFireworks:kr}=ja(),Ls=l.useRef(new Map),Pt=l.useRef(0),Xt=l.useCallback(()=>{Pt.current+=1,ge.current&&Es(!0)},[]),Zt=l.useCallback(()=>{Pt.current=Math.max(0,Pt.current-1),ge.current&&Pt.current===0&&Es(!1)},[]),[es,Ft]=l.useState(new Set),[Vr,As]=l.useState(new Set),[ts,Os]=l.useState(!1),[Ir,Pr]=l.useState(0),[Fr,zs]=l.useState(!1),[ss,Gs]=l.useState(Fe?.generatedHighlights??[]),Rr=Vr.size>0||fe.size()>0||fe.isRunning(),_s=l.useCallback(()=>{const s=_e.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),rs=S||F?.projectDirectory||null,ns=g?.current||null,Mr=l.useMemo(()=>{const s=g?.tracking;return s?s.startsWith("origin/"):!0},[g?.tracking]),$s=l.useMemo(()=>{const s=F?.createdFromBranch,a=typeof s=="string"?s.trim():"",o=typeof g?.current=="string"?g.current.trim():"",c=typeof Ce=="string"?Ce.trim():"";return a?a===o&&a.startsWith("opencode/")&&c.length>0&&c!==a?c:a:c||o||"HEAD"},[F?.createdFromBranch,g,Ce]),Rt=l.useCallback(()=>{Gs([])},[]),[as,Br]=l.useState(new Set),[Mt,Tr]=l.useState(new Map),[Bt,is]=l.useState(new Set),os=l.useRef(Mt),Nt=l.useRef(Bt),[Dr,yt]=l.useState(null),[ft,ls]=l.useState(null),[Hs,Ws]=l.useState(""),[Ae,Tt]=l.useState(null),[Er,Us]=l.useState(!1),[Lr,Ks]=l.useState(!1),[cs,ds]=l.useState([]),[Ar,Js]=l.useState(null),[qs,us]=l.useState(null),[Or,Dt]=l.useState([]),[zr,qe]=l.useState(!1),[Gr,Qe]=l.useState([]),[Et,Xe]=l.useState("merge"),[_r,ms]=l.useState(null),[hs,Ys]=l.useState(!1),[gs,$r]=l.useState(100),[Hr,Wr]=l.useState(0),Ye=l.useMemo(()=>m?`openchamber.conflict:${m}`:null,[m]),rt=l.useCallback((s,a,o)=>{if(!Ye||typeof window>"u")return;const c={directory:s,conflictFiles:a,operation:o};window.localStorage.setItem(Ye,JSON.stringify(c))},[Ye]),We=l.useCallback(()=>{!Ye||typeof window>"u"||window.localStorage.removeItem(Ye)},[Ye]);l.useEffect(()=>{if(!Ye||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Ye);if(s)try{const a=JSON.parse(s);if(a.directory!==r){window.localStorage.removeItem(Ye);return}Qe(a.conflictFiles??[]),Xe(a.operation??"merge"),qe(!0)}catch{window.localStorage.removeItem(Ye)}},[Ye,r]);const[Ur,fs]=l.useState(!1),[ps,Qs]=l.useState("merge"),[xs,Xs]=l.useState(""),Kr=l.useCallback(s=>{pa(s).then(a=>{if(a.ok){b.success(e("gitView.toast.commitHashCopied"));return}b.error(e("gitView.toast.copyFailed"))})},[e]),Jr=l.useCallback(s=>{Br(a=>{const o=new Set(a);return o.has(s)?o.delete(s):o.add(s),o})},[]);l.useEffect(()=>{os.current=Mt},[Mt]),l.useEffect(()=>{Nt.current=Bt},[Bt]),l.useEffect(()=>{if(!r||!n)return;const s=Array.from(as).filter(o=>!os.current.has(o)&&!Nt.current.has(o));if(s.length===0)return;let a=!1;return is(o=>{const c=new Set(o);for(const j of s)c.add(j);return Nt.current=c,c}),Promise.all(s.map(o=>n.getCommitFiles(r,o).then(c=>({hash:o,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:o,files:[]})))).then(o=>{a||(Tr(c=>{const j=new Map(c);for(const{hash:z,files:ne}of o)j.set(z,ne);return os.current=j,j}),is(c=>{const j=new Set(c);for(const{hash:z}of o)j.delete(z);return Nt.current=j,j}))}),()=>{a=!0,is(o=>{let c=!1;const j=new Set(o);for(const z of s)j.delete(z)&&(c=!0);return c?(Nt.current=j,j):o})}},[as,r,n]),l.useEffect(()=>{r&&Si(r,{directory:r,commitMessage:Be,generatedHighlights:ss})},[Be,r,ss]),l.useEffect(()=>{i&&(R(),O(),N())},[i,R,O,N]),l.useEffect(()=>{if(!i)return;if(!r||!n?.getRemoteUrl){ls(null);return}let s=!1;return n.getRemoteUrl(r).then(a=>{s||ls(a)}).catch(()=>{s||ls(null)}),()=>{s=!0}},[i,r,n]);const Lt=l.useCallback(async()=>{if(!r||!n?.getRemotes){ds([]);return}try{const s=await n.getRemotes(r);ge.current&&ds(s)}catch{ge.current&&ds([])}},[r,n]);l.useEffect(()=>{i&&Lt()},[i,Lt]),l.useEffect(()=>{i&&r&&(se(r),oe(r,n))},[i,r,se,oe,n]),l.useEffect(()=>{if(i&&r)return xa.onGitRefreshHint(s=>{nt(s.directory)===nt(r)&&(s.paths?.length&&ae(r,s.paths),h(r,n,{silent:!0}))})},[i,ae,r,h,n]);const re=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([h(r,n),L(r,n)])}catch(a){if(s){const o=a instanceof Error?a.message:e("gitView.toast.refreshRepositoryFailed");b.error(o)}}},[r,n,h,L,e]),ke=l.useCallback(async()=>{r&&await T(r,n,Je)},[r,n,T,Je]),ws=l.useCallback(async()=>{r&&await M(r,n)},[r,n,M]);l.useEffect(()=>{if(!i||!r||!n?.hasLocalIdentity||P!==!0)return;const s=typeof E=="string"?E.trim():"";if(!s||s==="global"||Ls.current.get(r)===s)return;let o=!1;return(async()=>{try{const j=await n.hasLocalIdentity?.(r);if(o||j===!0)return;Xt(),await n.setGitIdentity(r,s),Ls.current.set(r,s),await ws()}catch(j){console.warn("Failed to auto-apply default git identity:",j)}finally{o||Zt()}})(),()=>{o=!0}},[i,Xt,r,E,Zt,n,P,ws]);const at=l.useMemo(()=>g?[...g.files??[]].sort((a,o)=>a.path.localeCompare(o.path)):[],[g]),Ue=l.useMemo(()=>at.filter(xr),[at]),ys=l.useMemo(()=>at.filter(ki),[at]);l.useEffect(()=>{if(!r||at.length===0)return;const s=[],a=new Set,o=j=>{!j||a.has(j)||(a.add(j),s.push(j))};if(Ue.forEach(j=>o(j.path)),xe.forEach(o),at.slice(0,ji).forEach(j=>o(j.path)),s.length===0)return;const c=window.setTimeout(()=>{$(r,n,s,{maxFiles:vi})},120);return()=>{window.clearTimeout(c)}},[at,r,n,$,Ue,xe]);const Zs=s=>s?.pushed[0]?.remote||g?.tracking?.split("/")[0]||Ke.find(a=>a.name==="origin")?.name||Ke[0]?.name||"origin",er=async(s,a)=>{if(r){st(s);try{const o=c=>{const j=`${c.name}/`,z=g?.tracking?.startsWith(j)?g.tracking.slice(j.length):void 0;return{remote:c.name,branch:z,rebase:!0}};if(s==="fetch"){if(!a)throw new Error("No remote available for fetch");await n.gitFetch(r,{remote:a.name}),b.success(e("gitView.toast.fetchedFromRemote",{name:a.name}))}else if(s==="pull"){if(!a)throw new Error("No remote available for pull");const c=await n.gitPull(r,o(a));b.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:a.name}))}else if(s==="push"){const c=await n.gitPush(r);b.success(e("gitView.toast.pushedToUpstream",{name:Zs(c)}))}else if(s==="sync"){if(!a)throw new Error("No remote available for sync");let c=0,j=!1;await n.gitFetch(r,{remote:a.name});const z=await n.getGitStatus(r);if((z.behind??0)>0){if((z.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync"));return}c=(await n.gitPull(r,o(a))).files.length}((await n.getGitStatus(r)).ahead??0)>0&&(await n.gitPush(r),j=!0),c>0&&j?b.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:a.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:a.name})):c>0?b.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:a.name})):j?b.success(e("gitView.toast.pushedToUpstream",{name:a.name})):b.success(e("gitView.toast.alreadyUpToDate"))}await re(!1),await ke()}catch(o){const c=o instanceof Error?o.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});b.error(c)}finally{st(null)}}},qr=l.useCallback(async s=>{if(!r)return;const a=s.name.trim();if(!a){b.error(e("gitView.toast.remoteNameRequired"));return}if(a==="origin"){b.error(e("gitView.toast.cannotRemoveOriginRemote"));return}Js(a);try{await n.removeRemote(r,{remote:a}),b.success(e("gitView.toast.removedRemote",{name:a})),await Promise.all([re(!1),Lt()])}catch(o){const c=o instanceof Error?o.message:`Failed to remove ${a}`;b.error(c)}finally{Js(null)}},[r,n,Lt,re,e]),tr=async(s={})=>{if(!r)return;if(!Be.trim()){b.error(e("gitView.toast.enterCommitMessage"));return}const a=Ue.map(c=>c.path).sort();if(a.length===0){b.error(e("gitView.toast.stageFileToCommit"));return}const o=s.pushAfter?"commitAndPush":"commit";Ds(o);try{if(await n.createGitCommit(r,Be.trim(),{files:a,stageFiles:[]}),_(r),b.success(e("gitView.toast.commitCreated")),q(""),Rt(),await re(),s.pushAfter){const c=g?.tracking?.split("/")[0],j=Ke.find(Vn=>Vn.name===c)??Ke[0];if(!j)throw new Error(e("mobile.changes.noRemote"));st("sync");const z=`${j.name}/`,ne=g?.tracking?.startsWith(z)?g.tracking.slice(z.length):void 0;await n.gitFetch(r,{remote:j.name});const K=await n.getGitStatus(r);if((K.behind??0)>0){if((K.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync")),await re(!1);return}await n.gitPull(r,{remote:j.name,branch:ne,rebase:!0})}const He=await n.getGitStatus(r);let bt;(He.ahead??0)>0&&(bt=await n.gitPush(r)),b.success(e("gitView.toast.pushedToUpstream",{name:Zs(bt)})),kr(),await re(!1)}else await re(!1);await ke(),Pr(c=>c+1)}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");b.error(j)}finally{Ds(null),s.pushAfter&&st(null)}},Yr=l.useCallback(async()=>{if(!r)return;const s=Ue.map(a=>a.path).sort();if(s.length===0){b.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),zs(!0);try{const{message:a}=await wa(r,s),o=a.subject?.trim()??"",c=Array.isArray(a.highlights)?a.highlights:[];if(o){let j=o;if(pe&&Ne.length>0){const z=Ci(o,Ne);if(z){const{code:ne,emoji:K}=z;!o.startsWith(ne)&&!o.startsWith(K)&&(j=`${ne} ${o}`)}}q(j)}Gs(c),_s()}catch(a){console.error("[git-generation][browser] GitView generate handler failed",{message:a instanceof Error?a.message:String(a),error:a});const o=a instanceof Error?a.message:e("gitView.toast.generateCommitMessageFailed");b.error(o)}finally{zs(!1)}},[r,Ue,pe,Ne,_s,e]),bs=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",Qr=async(s,a)=>{if(!r||!g)return;const o=Cs(U);if(o.length>0){b.error(e("gitView.toast.cannotCreateBranch",{reason:bs(o[0])}));return}const c=g.current??null,j=a?.name??"origin";try{await n.createBranch(r,s,c??"HEAD"),b.success(e("gitView.toast.createdBranch",{name:s})),await n.checkoutBranch(r,s);let z=!1;try{await n.gitPush(r,{remote:j,branch:s,options:["--set-upstream"]}),z=!0}catch(ne){const K=ne instanceof Error?ne.message:`Unable to push new branch to ${j}.`;b.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",K]})})}await re(),await ke(),z&&b.success(e("gitView.toast.upstreamSet",{branch:s,remote:j}))}catch(z){const ne=z instanceof Error?z.message:e("gitView.toast.createBranchFailed");throw b.error(ne),z}},Xr=async(s,a)=>{if(!r)return;const o=Cs(U);if(o.length>0){b.error(e("gitView.toast.cannotRenameBranch",{reason:bs(o[0])}));return}try{await n.renameBranch(r,s,a),b.success(e("gitView.toast.renamedBranch",{oldName:s,newName:a})),await re(),await ke()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:a});b.error(j)}},Zr=async s=>{if(!r)return;const a=Cs(U);if(a.length>0){b.error(e("gitView.toast.cannotCheckout",{reason:bs(a[0])}));return}const o=s.replace(/^remotes\//,"");if(g?.current!==o)try{await n.checkoutBranch(r,o),b.success(e("gitView.toast.checkedOut",{name:o})),await re(),await ke()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.checkoutFailed",{name:o});b.error(j)}},en=async s=>{if(r){Xt();try{await n.setGitIdentity(r,s.id),b.success(e("gitView.toast.appliedIdentity",{name:s.name})),await ws()}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.applyIdentityFailed");b.error(o)}finally{Zt()}}},St=l.useMemo(()=>J?.all?J.all.filter(s=>!s.startsWith("remotes/")).sort():[],[J]),it=l.useMemo(()=>J?.all?J.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[J]),Ke=l.useMemo(()=>{if(cs.length>0)return cs;const s=new Set,a=g?.tracking?.trim();a&&a.includes("/")&&s.add(a.split("/")[0]);for(const o of it){const c=o.indexOf("/");c>0&&s.add(o.slice(0,c))}return s.size===0&&ft&&s.add("origin"),Array.from(s).map(o=>({name:o,fetchUrl:ft??"",pushUrl:ft??""}))},[cs,it,ft,g?.tracking]),ot=g?.current??null,sr=l.useMemo(()=>{const s=g?.tracking?.trim().split("/")[0];return(s&&J?.defaultBranches?.[s])??J?.defaultBranches?.origin},[J,g?.tracking]),pt=l.useMemo(()=>Ca({remoteNames:new Set(Ke.map(s=>s.name)),localBranches:St,worktreeCreatedFromBranch:F?.createdFromBranch,rootBranchHint:Ce,defaultBranch:sr,headBranch:ot}),[ot,sr,Ke,St,Ce,F?.createdFromBranch]),tn=l.useMemo(()=>Ke.map(o=>o.name).map(o=>`${o}/${pt}`).find(o=>it.includes(o))??pt,[pt,Ke,it]),sn=l.useMemo(()=>{const s=new Map;d&&s.set(d.id,d);let a=null;if(ft)try{let o=ft.trim();o.startsWith("git@")&&(o=`https://${o.slice(4).replace(":","/")}`),o.endsWith(".git")&&(o=o.slice(0,-4));const c=new URL(o);a=c.hostname+c.pathname}catch{}for(const o of I){if(o.authType!=="token"){s.set(o.id,o);continue}const c=o.host;if(!c){s.set(o.id,o);continue}if(!c.includes("/")){s.set(o.id,o);continue}a&&a===c&&s.set(o.id,o)}return Array.from(s.values())},[I,d,ft]),rn=l.useMemo(()=>{if(G?.userName&&G?.userEmail){const s=I.find(a=>a.userName===G.userName&&a.userEmail===G.userEmail);return s||(d&&d.userName===G.userName&&d.userEmail===G.userEmail?d:{id:"local-config",name:G.userName,userName:G.userName,userEmail:G.userEmail,sshKey:G.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return d??null},[G,I,d]),nn=Ue.length,an=Z||tt!==null||Ts!==null,on=!!(F&&rs&&ns&&Mr),rr=!!ot,lt=on&&rs&&ns&&F?{repoRoot:rs,sourceBranch:ns,worktreeMetadata:F}:null;l.useEffect(()=>{if(!r||!n||!H?.all?.length||!ot||!pt||ot===pt){yt(null);return}let s=!1;return(async()=>{try{const o=await n.getGitLog(r,{from:pt,to:"HEAD",maxCount:Je});if(s)return;const c=new Set((o?.all??[]).map(z=>z.hash).filter(z=>typeof z=="string"&&z.length>0));if(c.size===0){yt(null);return}const j=H.all.findIndex(z=>!c.has(z.hash));if(j===0){yt(null);return}if(j===-1){yt({insertBeforeIndex:H.all.length,branchName:ot,direction:"up"});return}yt({insertBeforeIndex:j,branchName:ot,direction:"up"})}catch{s||yt(null)}})(),()=>{s=!0}},[pt,ot,r,n,H,Je]),l.useEffect(()=>{ms(null)},[r]),l.useEffect(()=>{if(Ae!=="graph"||!r){Ae!=="graph"&&ms(null);return}let s=!1;return Ys(!0),n.getGitLog(r,{maxCount:gs,all:!0}).then(a=>{s||ms(a)}).catch(a=>{console.error("Failed to fetch graph log:",a)}).finally(()=>{s||Ys(!1)}),()=>{s=!0}},[Ae,r,gs,Hr,n]);const kt=l.useCallback((s,a)=>{if(!r||s.length===0)return;const o=Array.from(new Set(s));As(j=>{const z=new Set(j);return o.forEach(ne=>z.add(ne)),z});const c=ie(r,o,a);fe.enqueue({directory:r,direction:a,paths:new Set(o),rollback:()=>ee(r,c)}),Ie()},[r,fe,ie,ee,Ie]),vs=l.useCallback(async s=>{if(r){Ft(a=>{const o=new Set(a);return o.add(s),o});try{await n.revertGitFile(r,s,{scope:"working"}),b.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.revertFailed");b.error(o)}finally{Ft(a=>{const o=new Set(a);return o.delete(s),o})}}},[r,re,n,e]),At=l.useCallback(async(s,a,o="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(ts||c.some(K=>es.has(K)))return;const j=new Set(Ue.map(K=>K.path)),z=o==="all"&&c.some(K=>j.has(K));a&&Os(!0),Ft(K=>{const He=new Set(K);return c.forEach(bt=>He.add(bt)),He});const ne=[];try{if(await Promise.all(c.map(async K=>{try{await n.revertGitFile(r,K,{scope:o})}catch(He){ne.push({path:K,message:He instanceof Error?He.message:e("gitView.toast.revertFailed")})}})),z&&ne.length<c.length&&_(r),await re(!1),ne.length===0)b.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(ne.length===c.length)b.error(ne[0]?.message||e("gitView.toast.revertFailed"));else{const K=c.length-ne.length;b.warning(K===1?e("gitView.toast.revertedSomeSingle",{success:K,failed:ne.length}):e("gitView.toast.revertedSomePlural",{success:K,failed:ne.length}))}}finally{Ft(K=>{const He=new Set(K);return c.forEach(bt=>He.delete(bt)),He}),a&&Os(!1)}},[_,r,n,ts,re,es,Ue,e]),ln=l.useCallback(async s=>{await At(s,!0)},[At]),cn=l.useCallback(async s=>{await At(s,!1,"working")},[At]),js=l.useCallback((s,a)=>{if(r&&!be){te(r,s,a);return}he(s,a)},[r,be,he,te]),dn=l.useCallback(()=>Qt(!0),[]),un=l.useMemo(()=>{const s=[];return Ue.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Ue,actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:a=>e("gitView.changes.unstageFileAria",{path:a}),onActionFile:a=>{kt([a],"unstage")},onActionAll:a=>{kt(a,"unstage")},onViewDiff:a=>js(a,!0),onRevertFile:vs,showRevertActions:!1,accent:!0}),ys.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:ys,actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:a=>e("gitView.changes.stageFileAria",{path:a}),onActionFile:a=>{kt([a],"stage")},onActionAll:a=>{kt(a,"stage")},onViewDiff:a=>js(a,!1),onRevertFile:vs}),s},[vs,js,kt,Ue,e,ys]),mn=l.useCallback(s=>{if(s.length===0)return;const a=s.map(o=>o.trim()).filter(Boolean);if(a.length===0){Rt();return}q(o=>{const c=o.trim(),j=c.length>0?`
|
|
3
|
+
${JSON.stringify({directory:f,operation:R.operation,headInfo:R.headInfo,statusPorcelain:R.statusPorcelain,unmergedFiles:R.unmergedFiles,diff:R.diff},null,2)}`;return{visibleText:ze,instructionsText:Fe,payloadText:pe}},e[7]=R,e[8]=f,e[9]=x,e[10]=Y):Y=e[10];const S=Y;let F;e[11]!==p||e[12]!==r?(F=()=>{p(),r(!1)},e[11]=p,e[12]=r,e[13]=F):F=e[13];const J=F;let H;e[14]!==m||e[15]!==r?(H=()=>{m?.(),r(!1)},e[14]=m,e[15]=r,e[16]=H):H=e[16];const G=H;let Z;e[17]!==S||e[18]!==k||e[19]!==m||e[20]!==r||e[21]!==I||e[22]!==V||e[23]!==A||e[24]!==y?(Z=async()=>{const X=await S();if(!X){b.error(y("gitView.conflict.noDetailsAvailable"));return}if(!k){b.error(y("gitView.conflict.noActiveSession"),{description:y("gitView.conflict.noActiveSessionDescription")});return}V(X.visibleText,"replace"),A([{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]),I("chat"),m?.(),r(!1)},e[17]=S,e[18]=k,e[19]=m,e[20]=r,e[21]=I,e[22]=V,e[23]=A,e[24]=y,e[25]=Z):Z=e[25];const Q=Z;let se;e[26]!==S||e[27]!==f||e[28]!==m||e[29]!==r||e[30]!==C||e[31]!==I||e[32]!==y?(se=async()=>{const X=await S();if(!X){b.error(y("gitView.conflict.noDetailsAvailable"));return}C({directoryOverride:f,initialPrompt:X.visibleText,syntheticParts:[{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]}),I("chat"),m?.(),r(!1)},e[26]=S,e[27]=f,e[28]=m,e[29]=r,e[30]=C,e[31]=I,e[32]=y,e[33]=se):se=e[33];const ce=se;let oe,h,L,T,u,M,$,ae,ie,ee,_,be,te,de,ve,ue,he,me,le,De,je,ge;if(e[34]!==R||e[35]!==B||e[36]!==k||e[37]!==J||e[38]!==G||e[39]!==Q||e[40]!==ce||e[41]!==d||e[42]!==N||e[43]!==r||e[44]!==n||e[45]!==x||e[46]!==y){const X=y(x==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),Pe=R?.unmergedFiles||B;L=ut,je=n,ge=r,h=mt,De="max-w-md w-[calc(100vw-2rem)]",de="flex flex-col gap-4 overflow-hidden";let Oe;e[69]===Symbol.for("react.memo_cache_sentinel")?(Oe=t.jsx(D,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[69]=Oe):Oe=e[69];const ze=t.jsxs("div",{className:"flex items-center gap-2",children:[Oe,t.jsx(gt,{children:y("gitView.conflict.detectedTitle",{operation:X})})]});let Fe;e[70]!==x||e[71]!==y?(Fe=y("gitView.conflict.detectedDescription",{operation:x}),e[70]=x,e[71]=y,e[72]=Fe):Fe=e[72];let pe;e[73]!==Fe?(pe=t.jsx(wt,{children:Fe}),e[73]=Fe,e[74]=pe):pe=e[74],e[75]!==ze||e[76]!==pe?(ve=t.jsxs(ht,{children:[ze,pe]}),e[75]=ze,e[76]=pe,e[77]=ve):ve=e[77],e[78]!==d||e[79]!==y?(ue=d&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:y("gitView.conflict.loading")})]}),e[78]=d,e[79]=y,e[80]=ue):ue=e[80],e[81]!==N||e[82]!==y?(he=N&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:y("gitView.conflict.errorLoadingDetails",{message:N})}),e[81]=N,e[82]=y,e[83]=he):he=e[83],e[84]!==Pe||e[85]!==y?(me=Pe.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:Pe.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:Pe.map(di)})})]}),e[84]=Pe,e[85]=y,e[86]=me):me=e[86],e[87]!==R||e[88]!==y?(le=R?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.conflict.headInfo")}),t.jsx("div",{className:"typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:R.headInfo})]}),e[87]=R,e[88]=y,e[89]=le):le=e[89],_="flex flex-col gap-2 pt-2";let Ce;e[90]!==ce?(Ce=()=>{ce()},e[90]=ce,e[91]=Ce):Ce=e[91];const Ge=d||!R;let Ne;e[92]!==d?(Ne=d?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"add",className:"size-4"}),e[92]=d,e[93]=Ne):Ne=e[93];let Be;e[94]!==y?(Be=y("gitView.conflict.resolveNewSession"),e[94]=y,e[95]=Be):Be=e[95],e[96]!==Ce||e[97]!==Ge||e[98]!==Ne||e[99]!==Be?(be=t.jsxs(W,{variant:"default",onClick:Ce,disabled:Ge,className:"w-full gap-2",children:[Ne,Be]}),e[96]=Ce,e[97]=Ge,e[98]=Ne,e[99]=Be,e[100]=be):be=e[100];let q;e[101]!==Q?(q=()=>{Q()},e[101]=Q,e[102]=q):q=e[102];const xe=d||!R||!k;let Se;e[103]!==d?(Se=d?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"chat-1",className:"size-4"}),e[103]=d,e[104]=Se):Se=e[104];let we;e[105]!==y?(we=y("gitView.conflict.resolveCurrentSession"),e[105]=y,e[106]=we):we=e[106],e[107]!==q||e[108]!==xe||e[109]!==Se||e[110]!==we?(te=t.jsxs(W,{variant:"outline",onClick:q,disabled:xe,className:"w-full gap-2",children:[Se,we]}),e[107]=q,e[108]=xe,e[109]=Se,e[110]=we,e[111]=te):te=e[111],ie="flex gap-2 pt-1";let ye;e[112]!==y?(ye=y("gitView.conflict.continueLater"),e[112]=y,e[113]=ye):ye=e[113],e[114]!==G||e[115]!==ye?(ee=t.jsx(W,{variant:"ghost",size:"sm",onClick:G,className:"flex-1",children:ye}),e[114]=G,e[115]=ye,e[116]=ee):ee=e[116],oe=W,T="destructive",u="sm",M=J,$="flex-1",ae=y("gitView.conflict.abortOperation",{operation:X}),e[34]=R,e[35]=B,e[36]=k,e[37]=J,e[38]=G,e[39]=Q,e[40]=ce,e[41]=d,e[42]=N,e[43]=r,e[44]=n,e[45]=x,e[46]=y,e[47]=oe,e[48]=h,e[49]=L,e[50]=T,e[51]=u,e[52]=M,e[53]=$,e[54]=ae,e[55]=ie,e[56]=ee,e[57]=_,e[58]=be,e[59]=te,e[60]=de,e[61]=ve,e[62]=ue,e[63]=he,e[64]=me,e[65]=le,e[66]=De,e[67]=je,e[68]=ge}else oe=e[47],h=e[48],L=e[49],T=e[50],u=e[51],M=e[52],$=e[53],ae=e[54],ie=e[55],ee=e[56],_=e[57],be=e[58],te=e[59],de=e[60],ve=e[61],ue=e[62],he=e[63],me=e[64],le=e[65],De=e[66],je=e[67],ge=e[68];let Ve;e[117]!==oe||e[118]!==T||e[119]!==u||e[120]!==M||e[121]!==$||e[122]!==ae?(Ve=t.jsx(oe,{variant:T,size:u,onClick:M,className:$,children:ae}),e[117]=oe,e[118]=T,e[119]=u,e[120]=M,e[121]=$,e[122]=ae,e[123]=Ve):Ve=e[123];let Me;e[124]!==ie||e[125]!==ee||e[126]!==Ve?(Me=t.jsxs("div",{className:ie,children:[ee,Ve]}),e[124]=ie,e[125]=ee,e[126]=Ve,e[127]=Me):Me=e[127];let Ee;e[128]!==_||e[129]!==be||e[130]!==te||e[131]!==Me?(Ee=t.jsxs("div",{className:_,children:[be,te,Me]}),e[128]=_,e[129]=be,e[130]=te,e[131]=Me,e[132]=Ee):Ee=e[132];let Ie;e[133]!==de||e[134]!==ve||e[135]!==ue||e[136]!==he||e[137]!==me||e[138]!==le||e[139]!==Ee?(Ie=t.jsxs("div",{className:de,children:[ve,ue,he,me,le,Ee]}),e[133]=de,e[134]=ve,e[135]=ue,e[136]=he,e[137]=me,e[138]=le,e[139]=Ee,e[140]=Ie):Ie=e[140];let Le;e[141]!==h||e[142]!==De||e[143]!==Ie?(Le=t.jsx(h,{className:De,children:Ie}),e[141]=h,e[142]=De,e[143]=Ie,e[144]=Le):Le=e[144];let fe;return e[145]!==L||e[146]!==je||e[147]!==ge||e[148]!==Le?(fe=t.jsx(L,{open:je,onOpenChange:ge,children:Le}),e[145]=L,e[146]=je,e[147]=ge,e[148]=Le,e[149]=fe):fe=e[149],fe};function ai(i){return i.openNewSessionDraft}function ii(i){return i.currentSessionId}function oi(i){return i.setPendingInputText}function li(i){return i.setPendingSyntheticParts}function ci(i){return i.setActiveMainTab}function di(i){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:i,children:i},i)}const ui=({open:i,onOpenChange:e,operation:n,targetBranch:r,onConfirm:v})=>{const{t:f}=et(),[x,p]=l.useState(!0),[m,w]=l.useState(!1),B=f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),y=async()=>{w(!0);try{await v(x),e(!1)}catch(k){const V=k instanceof Error?k.message:`Failed to ${n}`;b.error(V)}finally{w(!1)}},C=()=>{m||e(!1)};return t.jsx(ut,{open:i,onOpenChange:m?void 0:e,children:t.jsxs(mt,{className:"max-w-md",children:[t.jsxs(ht,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(gt,{children:f("gitView.stash.title")})]}),t.jsx(wt,{children:f("gitView.stash.description",{operation:n})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(n==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:r})]}),x&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(Xn,{checked:x,onChange:p,disabled:m,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!m&&p(!x),children:f("gitView.stash.restoreAfterOperation",{operation:n})})]}),t.jsxs(ks,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:C,disabled:m,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:y,disabled:m,className:"gap-1.5",children:m?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:B})})]})]})})},mi=({mergeInProgress:i,rebaseInProgress:e,onContinue:n,onAbort:r,onResolveWithAI:v,conflictCount:f=0,isLoading:x=!1})=>{const{t:p}=et(),[m,w]=l.useState(null),B=i&&i.head,y=e&&(e.headName||e.onto),C=B?"merge":y?"rebase":null;if(!C)return null;const k=async()=>{w("continue");try{await n()}finally{w(null)}},V=async()=>{w("abort");try{await r()}finally{w(null)}},A=m!==null,I=f>0,d=p(C==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let E="";i?E=i.message?p("gitView.operation.mergingMessage",{message:i.message}):p("gitView.operation.mergeInProgressWithHead",{head:i.head}):e&&(E=e.headName?p("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):p("gitView.operation.rebaseInProgress"));const R=I?f===1?p("gitView.operation.inProgressTitleOneConflict",{operation:d,count:f}):p("gitView.operation.inProgressTitleManyConflicts",{operation:d,count:f}):p("gitView.operation.inProgressTitle",{operation:d}),O=p(I?"gitView.operation.resolveConflictsHint":"gitView.operation.readyToContinueHint");return t.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:t.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:R}),E&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:E})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:O}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:V,disabled:A||x,className:"gap-1.5",children:[m==="abort"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"close",className:"size-4"}),p("gitView.operation.abort")]}),I?v&&t.jsx(W,{variant:"default",size:"sm",onClick:v,disabled:A||x,children:p("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:k,disabled:A||x,className:"gap-1.5",children:[m==="continue"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"check",className:"size-4"}),p("gitView.operation.continue")]})]})]})]})})},hi=i=>{const e=jt.c(104),{currentBranch:n,localBranches:r,remoteBranches:v,onMerge:f,onRebase:x,disabled:p,isOperating:m,operationLogs:w,onOperationComplete:B,mode:y,defaultTargetBranch:C}=i,k=p===void 0?!1:p,V=m===void 0?!1:m,A=w===void 0?[]:w,I=y===void 0?"dialog":y,{t:d}=et(),[E,R]=l.useState(!1),[O,N]=l.useState("merge"),[P,g]=l.useState(null),[U,Y]=l.useState(!1),[S,F]=l.useState(""),J=l.useRef(null),H=l.useRef(null),G=k||V,Z=n||d("gitView.branch.currentBranchFallback"),Q=A.length>0&&A.every(gi),se=A.some(fi);let ce;e[0]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{H.current&&(H.current.scrollTop=H.current.scrollHeight)},e[0]=ce):ce=e[0],l.useEffect(ce,[A]);let oe;if(e[1]!==S||e[2]!==n||e[3]!==r||e[4]!==v){e:{const q=S.toLowerCase();let xe;e[6]!==v?(xe=new Set(v.map(pi).filter(Boolean)),e[6]=v,e[7]=xe):xe=e[7];const Se=xe;let we;e[8]!==n||e[9]!==Se?(we=_e=>_e!==n&&!Se.has(_e),e[8]=n,e[9]=Se,e[10]=we):we=e[10];const ye=r.filter(we);if(!q){oe=ye;break e}oe=ye.filter(_e=>_e.toLowerCase().includes(q))}e[1]=S,e[2]=n,e[3]=r,e[4]=v,e[5]=oe}else oe=e[5];const h=oe;let L;if(e[11]!==S||e[12]!==v){e:{const q=S.toLowerCase();if(!q){L=v;break e}L=v.filter(xe=>xe.toLowerCase().includes(q))}e[11]=S,e[12]=v,e[13]=L}else L=e[13];const T=L;let u;e[14]!==C||e[15]!==r||e[16]!==v?(u=()=>C&&(v.includes(C)||r.includes(C))?C:null,e[14]=C,e[15]=r,e[16]=v,e[17]=u):u=e[17];const M=u;let $;e[18]!==M||e[19]!==R?($=()=>{R(!0),g(M()),N("merge"),F("")},e[18]=M,e[19]=R,e[20]=$):$=e[20];const ae=$;let ie;e[21]===Symbol.for("react.memo_cache_sentinel")?(ie=q=>{g(q),Y(!1),F("")},e[21]=ie):ie=e[21];const ee=ie;let _;e[22]!==f||e[23]!==x||e[24]!==O||e[25]!==P?(_=()=>{P&&(O==="merge"?f(P):x(P))},e[22]=f,e[23]=x,e[24]=O,e[25]=P,e[26]=_):_=e[26];const be=_;let te;e[27]!==V||e[28]!==R?(te=()=>{V||(g(null),N("merge"),F(""),R(!1))},e[27]=V,e[28]=R,e[29]=te):te=e[29];const de=te,ve=()=>{V&&!Q||(Q&&B?.(),g(null),N("merge"),F(""),R(!1))};let ue,he;e[30]!==U?(ue=()=>{U||F("")},he=[U],e[30]=U,e[31]=ue,e[32]=he):(ue=e[31],he=e[32]),l.useEffect(ue,he);let me,le;e[33]!==I||e[34]!==M||e[35]!==P?(me=()=>{I==="dialog"||P||g(M())},le=[I,M,P],e[33]=I,e[34]=M,e[35]=P,e[36]=me,e[37]=le):(me=e[36],le=e[37]),l.useEffect(me,le);const ge=V?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:H,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:t.jsx("div",{className:"space-y-2",children:A.map(xi)})}),Q?I==="dialog"?t.jsx(ks,{children:t.jsx(W,{variant:"default",size:"sm",onClick:ve,children:d(se?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:ve,children:d(se?"gitView.common.close":"gitView.common.done")})}):null]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:d("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>N("merge"),className:Re("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",O==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"git-merge",className:Re("size-4",O==="merge"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Re("typography-ui-label",O==="merge"?"text-foreground":"text-muted-foreground"),children:d("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:d("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>N("rebase"),className:Re("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",O==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"git-branch",className:Re("size-4",O==="rebase"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Re("typography-ui-label",O==="rebase"?"text-foreground":"text-muted-foreground"),children:d("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:d("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:O==="merge"?d("gitView.branch.branchToMergeInto",{branch:Z}):d("gitView.branch.branchToRebaseOnto")}),t.jsxs(Vs,{open:U,onOpenChange:Y,modal:!1,children:[t.jsx(Is,{asChild:!0,children:t.jsxs("button",{type:"button",className:Re(wr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Re("truncate",!P&&"text-muted-foreground"),children:P||d("gitView.branch.selectBranch")}),t.jsx(D,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Ps,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:t.jsxs(Fs,{className:"h-full min-h-0",children:[t.jsx(Rs,{ref:J,placeholder:d("gitView.branch.searchPlaceholder"),value:S,onValueChange:F,onKeyDown:wi}),t.jsxs(Ms,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Bs,{children:d("gitView.branch.empty")}),h.length>0&&t.jsx(Ut,{heading:d("gitView.branch.localBranches"),children:h.map(q=>t.jsx(Kt,{onSelect:()=>ee(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`local-${q}`))}),h.length>0&&T.length>0?t.jsx(Zn,{}):null,T.length>0&&t.jsx(Ut,{heading:d("gitView.branch.remoteBranches"),children:T.map(q=>t.jsx(Kt,{onSelect:()=>ee(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`remote-${q}`))})]})]})})]})]}),P?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:O==="merge"?t.jsxs(t.Fragment,{children:[d("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P})," ",d("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z})]}):t.jsxs(t.Fragment,{children:[d("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z})," ",d("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P})]})})}):null,I==="dialog"?t.jsxs(ks,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:de,children:d("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:be,disabled:!P,className:"gap-1.5",children:O==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"git-merge",className:"size-4"}),d("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"git-branch",className:"size-4"}),d("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:de,disabled:G,children:d("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:be,disabled:G||!P,children:d(O==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(I==="bare")return ge;if(I==="inline"){let q;e[38]!==d?(q=d("gitView.branch.updateTitle"),e[38]=d,e[39]=q):q=e[39];let xe;e[40]!==q?(xe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:q}),e[40]=q,e[41]=xe):xe=e[41];let Se;e[42]!==d?(Se=d("gitView.branch.updateDescriptionPrefix"),e[42]=d,e[43]=Se):Se=e[43];let we;e[44]!==Z?(we=t.jsx("span",{className:"font-mono text-foreground",children:Z}),e[44]=Z,e[45]=we):we=e[45];let ye;e[46]!==Se||e[47]!==we?(ye=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Se," ",we,"."]}),e[46]=Se,e[47]=we,e[48]=ye):ye=e[48];let _e;e[49]!==xe||e[50]!==ye?(_e=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[xe,ye]})}),e[49]=xe,e[50]=ye,e[51]=_e):_e=e[51];let tt;e[52]!==ge?(tt=t.jsx("div",{className:"pt-3",children:ge}),e[52]=ge,e[53]=tt):tt=e[53];let st;return e[54]!==_e||e[55]!==tt?(st=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[_e,tt]}),e[54]=_e,e[55]=tt,e[56]=st):st=e[56],st}let Ve;e[57]!==V?(Ve=V?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"git-merge",className:"size-4"}),e[57]=V,e[58]=Ve):Ve=e[58];let Me;e[59]!==d?(Me=d("gitView.branch.mergeRebase"),e[59]=d,e[60]=Me):Me=e[60];let Ee;e[61]!==Me?(Ee=t.jsx("span",{children:Me}),e[61]=Me,e[62]=Ee):Ee=e[62];let Ie;e[63]!==ae||e[64]!==G||e[65]!==Ve||e[66]!==Ee?(Ie=t.jsx(qt,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:ae,disabled:G,children:[Ve,Ee]})}),e[63]=ae,e[64]=G,e[65]=Ve,e[66]=Ee,e[67]=Ie):Ie=e[67];let Le;e[68]!==d?(Le=d("gitView.branch.mergeRebaseTooltip"),e[68]=d,e[69]=Le):Le=e[69];let fe;e[70]!==Le?(fe=t.jsx(Yt,{sideOffset:8,children:Le}),e[70]=Le,e[71]=fe):fe=e[71];let X;e[72]!==Ie||e[73]!==fe?(X=t.jsxs(Jt,{children:[Ie,fe]}),e[72]=Ie,e[73]=fe,e[74]=X):X=e[74];let Pe;e[75]!==ve||e[76]!==R?(Pe=q=>{q?R(!0):ve()},e[75]=ve,e[76]=R,e[77]=Pe):Pe=e[77];let Oe;e[78]!==d?(Oe=d("gitView.branch.updateTitle"),e[78]=d,e[79]=Oe):Oe=e[79];let ze;e[80]!==Oe?(ze=t.jsx(gt,{children:Oe}),e[80]=Oe,e[81]=ze):ze=e[81];let Fe;e[82]!==se||e[83]!==V||e[84]!==O||e[85]!==Q||e[86]!==d||e[87]!==Z?(Fe=V?d(Q?se?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":O==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[d("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z}),"."]}),e[82]=se,e[83]=V,e[84]=O,e[85]=Q,e[86]=d,e[87]=Z,e[88]=Fe):Fe=e[88];let pe;e[89]!==Fe?(pe=t.jsx(wt,{children:Fe}),e[89]=Fe,e[90]=pe):pe=e[90];let Ce;e[91]!==ze||e[92]!==pe?(Ce=t.jsxs(ht,{children:[ze,pe]}),e[91]=ze,e[92]=pe,e[93]=Ce):Ce=e[93];let Ge;e[94]!==ge||e[95]!==Ce?(Ge=t.jsxs(mt,{className:"max-w-md",children:[Ce,ge]}),e[94]=ge,e[95]=Ce,e[96]=Ge):Ge=e[96];let Ne;e[97]!==E||e[98]!==Pe||e[99]!==Ge?(Ne=t.jsx(ut,{open:E,onOpenChange:Pe,children:Ge}),e[97]=E,e[98]=Pe,e[99]=Ge,e[100]=Ne):Ne=e[100];let Be;return e[101]!==X||e[102]!==Ne?(Be=t.jsxs(t.Fragment,{children:[X,Ne]}),e[101]=X,e[102]=Ne,e[103]=Be):Be=e[103],Be};function gi(i){return i.status==="done"||i.status==="error"}function fi(i){return i.status==="error"}function pi(i){return i.slice(i.indexOf("/")+1)}function xi(i,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[i.status==="running"&&t.jsx(D,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),i.status==="done"&&t.jsx(D,{name:"check",className:"size-3.5 text-success"}),i.status==="error"&&t.jsx(D,{name:"close",className:"size-3.5 text-destructive"}),i.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Re("typography-micro",i.status==="error"&&"text-destructive",i.status==="done"&&"text-muted-foreground",i.status==="running"&&"text-foreground",i.status==="pending"&&"text-muted-foreground/60"),children:i.message})]},e)}function wi(i){return i.stopPropagation()}const yi=({runMutation:i,onMutationComplete:e,onMutationError:n,onPathsComplete:r,scheduleFlush:v})=>{const f=[];let x=!1;return{enqueue:m=>{const w=f[f.length-1];if(w?.directory===m.directory&&w.direction===m.direction){m.paths.forEach(B=>w.paths.add(B));return}f.push(m)},flush:()=>{if(x)return;const m=f.shift();if(!m)return;x=!0;const w={directory:m.directory,direction:m.direction,paths:Array.from(m.paths),rollback:m.rollback};(async()=>{try{await i(w),e(w)}catch(B){n(w,B)}finally{r(w.paths),x=!1,f.length>0&&v()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>x}},bi=15e3,vi=40,ji=20,pr={feat:":sparkles:",feature:":sparkles:",fix:":bug:",bug:":bug:",hotfix:":ambulance:",docs:":memo:",documentation:":memo:",style:":lipstick:",refactor:":recycle:",perf:":zap:",performance:":zap:",test:":white_check_mark:",tests:":white_check_mark:",build:":construction_worker:",ci:":green_heart:",chore:":wrench:",revert:":rewind:",wip:":construction:",security:":lock:",release:":bookmark:",merge:":twisted_rightwards_arrows:",mv:":truck:",move:":truck:",rename:":truck:",remove:":fire:",delete:":fire:",add:":sparkles:",create:":sparkles:",implement:":sparkles:",update:":recycle:",improve:":zap:",optimize:":zap:",upgrade:":arrow_up:",downgrade:":arrow_down:",deploy:":rocket:",init:":tada:",initial:":tada:"},Ci=(i,e)=>{const n=i.toLowerCase(),r=/^([a-z]+)(?:\(.*\))?!?:/,v=n.match(r);if(v){const p=v[1],m=pr[p];if(m)return e.find(w=>w.code===m)||null}const f=n.split(" ")[0],x=pr[f];return x&&e.find(p=>p.code===x)||null},Ni=20,vt=new Map,Si=(i,e)=>{if(vt.delete(i),vt.set(i,e),vt.size>Ni){const n=vt.keys().next().value;n!==void 0&&vt.delete(n)}},nt=i=>(i||"").replace(/\\/g,"/").replace(/\/+$/,""),xr=i=>{const e=i.index?.trim();return!!(e&&e!=="?")},ki=i=>{const e=i.working_dir?.trim(),n=i.index?.trim();return!!(e||n==="?")},Gl=({isActive:i})=>{const{t:e}=et(),{git:n}=ea(),r=ta(),[v,f]=l.useState(null),[x,p]=l.useState(!1),m=Ze(s=>s.currentSessionId),w=Ze(s=>s.newSessionDraft),B=Ze(s=>s.setDraftBootstrapPendingDirectory),y=Ze(s=>s.worktreeMetadata),C=Ze(s=>s.availableWorktrees),k=nt(r),V=l.useMemo(()=>{if(!k)return;const s=C.find(a=>nt(a.path)===k);if(s)return s;for(const a of y.values())if(nt(a.path)===k)return a},[C,k,y]),A=l.useMemo(()=>{if(m)return y.get(m)??V;if(w?.open)return V},[m,V,w?.open,y]),{profiles:I,globalIdentity:d,defaultGitIdentityId:E,loadProfiles:R,loadGlobalIdentity:O,loadDefaultGitIdentityId:N}=Va(ar(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),P=sa(r??null),g=ra(r??null),U=na(s=>m?s.getAttachment(m):void 0),Y=U?aa(U):[],S=U&&!U.degraded&&!U.legacy?U.worktreeRoot??void 0:void 0,F=va(r,A,g?.current??void 0),J=ia(r??null),H=oa(r??null),G=la(r??null),Z=ca(r??null),Q=da(r??null),{setActiveDirectory:se,fetchAll:ce,ensureAll:oe,fetchStatus:h,fetchBranches:L,fetchLog:T,setLogMaxCount:u,fetchIdentity:M,prefetchDiffs:$,clearDiffCache:ae,moveStatusPathsOptimistically:ie,restoreStatus:ee,bumpIndexRevision:_}=ua(ar(s=>({setActiveDirectory:s.setActiveDirectory,fetchAll:s.fetchAll,ensureAll:s.ensureAll,fetchStatus:s.fetchStatus,fetchBranches:s.fetchBranches,fetchLog:s.fetchLog,setLogMaxCount:s.setLogMaxCount,fetchIdentity:s.fetchIdentity,prefetchDiffs:s.prefetchDiffs,clearDiffCache:s.clearDiffCache,moveStatusPathsOptimistically:s.moveStatusPathsOptimistically,restoreStatus:s.restoreStatus,bumpIndexRevision:s.bumpIndexRevision}))),be=xt(s=>s.isMobile),te=xt(s=>s.openContextDiff),de=xt(s=>s.openContextSurface),ve=g?.current??null,ue=ma(s=>!r||!ve?null:ha(s.entries,r,ve)),he=xt(s=>s.navigateToDiff),me=l.useRef(null),le=l.useRef(null),De=l.useRef(null),je=l.useRef(null),ge=l.useRef(!0);l.useEffect(()=>()=>{ge.current=!1},[]);const Ve=l.useCallback(()=>{le.current!==null&&(window.clearTimeout(le.current),le.current=null)},[]),Me=l.useCallback(s=>{Ve(),le.current=window.setTimeout(()=>{le.current=null,nt(s)===nt(r)&&h(s,n,{silent:!0})},bi)},[Ve,r,h,n]);l.useEffect(()=>Ve,[Ve]);const Ee=l.useCallback(()=>{De.current!==null&&(window.clearTimeout(De.current),De.current=null)},[]),Ie=l.useCallback(()=>{De.current===null&&(De.current=window.setTimeout(()=>{De.current=null,je.current?.()},0))},[]),Le=l.useCallback(async(s,a,o)=>{if(a==="stage"){if(n.stageGitFiles){await n.stageGitFiles(s,o);return}await Promise.all(o.map(c=>n.stageGitFile(s,c)));return}if(n.unstageGitFiles){await n.unstageGitFiles(s,o);return}await Promise.all(o.map(c=>n.unstageGitFile(s,c)))},[n]),fe=l.useMemo(()=>yi({runMutation:({directory:s,direction:a,paths:o})=>Le(s,a,o),onMutationComplete:({directory:s})=>{_(s),Me(s)},onMutationError:({directory:s,direction:a,rollback:o},c)=>{o?.(),_(s),Me(s);const j=e(a==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");b.error(c instanceof Error?c.message:j)},onPathsComplete:s=>{As(a=>{const o=new Set(a);return s.forEach(c=>o.delete(c)),o})},scheduleFlush:Ie}),[_,Le,Ie,Me,e]);l.useEffect(()=>(je.current=fe.flush,()=>{je.current=null}),[fe]),l.useEffect(()=>()=>fe.clear(),[fe]),l.useEffect(()=>Ee,[Ee]),l.useEffect(()=>{if(!i)return;if(!r){f(null),p(!1);return}let s=!1,a=null;const o=async()=>{try{const c=await ba(r);if(s)return;f(c.status),c.status==="pending"&&(a=window.setTimeout(()=>{o()},500))}catch{s||f(null)}};return o(),()=>{s=!0,a!==null&&window.clearTimeout(a)}},[i,r]),l.useEffect(()=>{const s=me.current;me.current=v,!(!r||!n)&&(s==="pending"&&v==="ready"&&(p(!0),ce(r,n).finally(()=>{window.setTimeout(()=>{p(!1)},1200)})),v==="failed"&&(B(null),p(!1)))},[r,ce,n,B,v]);const X=nt(w?.bootstrapPendingDirectory??null),Pe=!!(r&&X&&X===nt(r)),ze=!!(r&&(v==="pending"||Pe))||x,Fe=l.useMemo(()=>r?vt.get(r)??null:null,[r]),pe=ga(s=>s.settingsGitmojiEnabled),[Ce,Ge]=l.useState(null),{gitmojis:Ne}=Ea(pe);l.useEffect(()=>{const s=S||F?.projectDirectory;if(!s){Ge(null);return}let a=!1;return fa(s).then(o=>{if(a)return;const c=o.trim();Ge(c&&c!=="HEAD"?c:null)}).catch(()=>{a||Ge(null)}),()=>{a=!0}},[S,F?.projectDirectory]);const[Be,q]=l.useState(Fe?.commitMessage??""),[xe,Se]=l.useState([]),[we,ye]=l.useState(!1),_e=l.useRef(null),[tt,st]=l.useState(null),[Cr,Qt]=l.useState(!1),[Ts,Ds]=l.useState(null),[Je,Nr]=l.useState(25),[Sr,Es]=l.useState(!1),{triggerFireworks:kr}=ja(),Ls=l.useRef(new Map),Pt=l.useRef(0),Xt=l.useCallback(()=>{Pt.current+=1,ge.current&&Es(!0)},[]),Zt=l.useCallback(()=>{Pt.current=Math.max(0,Pt.current-1),ge.current&&Pt.current===0&&Es(!1)},[]),[es,Ft]=l.useState(new Set),[Vr,As]=l.useState(new Set),[ts,Os]=l.useState(!1),[Ir,Pr]=l.useState(0),[Fr,zs]=l.useState(!1),[ss,Gs]=l.useState(Fe?.generatedHighlights??[]),Rr=Vr.size>0||fe.size()>0||fe.isRunning(),_s=l.useCallback(()=>{const s=_e.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),rs=S||F?.projectDirectory||null,ns=g?.current||null,Mr=l.useMemo(()=>{const s=g?.tracking;return s?s.startsWith("origin/"):!0},[g?.tracking]),$s=l.useMemo(()=>{const s=F?.createdFromBranch,a=typeof s=="string"?s.trim():"",o=typeof g?.current=="string"?g.current.trim():"",c=typeof Ce=="string"?Ce.trim():"";return a?a===o&&a.startsWith("opencode/")&&c.length>0&&c!==a?c:a:c||o||"HEAD"},[F?.createdFromBranch,g,Ce]),Rt=l.useCallback(()=>{Gs([])},[]),[as,Br]=l.useState(new Set),[Mt,Tr]=l.useState(new Map),[Bt,is]=l.useState(new Set),os=l.useRef(Mt),Nt=l.useRef(Bt),[Dr,yt]=l.useState(null),[ft,ls]=l.useState(null),[Hs,Ws]=l.useState(""),[Ae,Tt]=l.useState(null),[Er,Us]=l.useState(!1),[Lr,Ks]=l.useState(!1),[cs,ds]=l.useState([]),[Ar,Js]=l.useState(null),[qs,us]=l.useState(null),[Or,Dt]=l.useState([]),[zr,qe]=l.useState(!1),[Gr,Qe]=l.useState([]),[Et,Xe]=l.useState("merge"),[_r,ms]=l.useState(null),[hs,Ys]=l.useState(!1),[gs,$r]=l.useState(100),[Hr,Wr]=l.useState(0),Ye=l.useMemo(()=>m?`openchamber.conflict:${m}`:null,[m]),rt=l.useCallback((s,a,o)=>{if(!Ye||typeof window>"u")return;const c={directory:s,conflictFiles:a,operation:o};window.localStorage.setItem(Ye,JSON.stringify(c))},[Ye]),We=l.useCallback(()=>{!Ye||typeof window>"u"||window.localStorage.removeItem(Ye)},[Ye]);l.useEffect(()=>{if(!Ye||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Ye);if(s)try{const a=JSON.parse(s);if(a.directory!==r){window.localStorage.removeItem(Ye);return}Qe(a.conflictFiles??[]),Xe(a.operation??"merge"),qe(!0)}catch{window.localStorage.removeItem(Ye)}},[Ye,r]);const[Ur,fs]=l.useState(!1),[ps,Qs]=l.useState("merge"),[xs,Xs]=l.useState(""),Kr=l.useCallback(s=>{pa(s).then(a=>{if(a.ok){b.success(e("gitView.toast.commitHashCopied"));return}b.error(e("gitView.toast.copyFailed"))})},[e]),Jr=l.useCallback(s=>{Br(a=>{const o=new Set(a);return o.has(s)?o.delete(s):o.add(s),o})},[]);l.useEffect(()=>{os.current=Mt},[Mt]),l.useEffect(()=>{Nt.current=Bt},[Bt]),l.useEffect(()=>{if(!r||!n)return;const s=Array.from(as).filter(o=>!os.current.has(o)&&!Nt.current.has(o));if(s.length===0)return;let a=!1;return is(o=>{const c=new Set(o);for(const j of s)c.add(j);return Nt.current=c,c}),Promise.all(s.map(o=>n.getCommitFiles(r,o).then(c=>({hash:o,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:o,files:[]})))).then(o=>{a||(Tr(c=>{const j=new Map(c);for(const{hash:z,files:ne}of o)j.set(z,ne);return os.current=j,j}),is(c=>{const j=new Set(c);for(const{hash:z}of o)j.delete(z);return Nt.current=j,j}))}),()=>{a=!0,is(o=>{let c=!1;const j=new Set(o);for(const z of s)j.delete(z)&&(c=!0);return c?(Nt.current=j,j):o})}},[as,r,n]),l.useEffect(()=>{r&&Si(r,{directory:r,commitMessage:Be,generatedHighlights:ss})},[Be,r,ss]),l.useEffect(()=>{i&&(R(),O(),N())},[i,R,O,N]),l.useEffect(()=>{if(!i)return;if(!r||!n?.getRemoteUrl){ls(null);return}let s=!1;return n.getRemoteUrl(r).then(a=>{s||ls(a)}).catch(()=>{s||ls(null)}),()=>{s=!0}},[i,r,n]);const Lt=l.useCallback(async()=>{if(!r||!n?.getRemotes){ds([]);return}try{const s=await n.getRemotes(r);ge.current&&ds(s)}catch{ge.current&&ds([])}},[r,n]);l.useEffect(()=>{i&&Lt()},[i,Lt]),l.useEffect(()=>{i&&r&&(se(r),oe(r,n))},[i,r,se,oe,n]),l.useEffect(()=>{if(i&&r)return xa.onGitRefreshHint(s=>{nt(s.directory)===nt(r)&&(s.paths?.length&&ae(r,s.paths),h(r,n,{silent:!0}))})},[i,ae,r,h,n]);const re=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([h(r,n),L(r,n)])}catch(a){if(s){const o=a instanceof Error?a.message:e("gitView.toast.refreshRepositoryFailed");b.error(o)}}},[r,n,h,L,e]),ke=l.useCallback(async()=>{r&&await T(r,n,Je)},[r,n,T,Je]),ws=l.useCallback(async()=>{r&&await M(r,n)},[r,n,M]);l.useEffect(()=>{if(!i||!r||!n?.hasLocalIdentity||P!==!0)return;const s=typeof E=="string"?E.trim():"";if(!s||s==="global"||Ls.current.get(r)===s)return;let o=!1;return(async()=>{try{const j=await n.hasLocalIdentity?.(r);if(o||j===!0)return;Xt(),await n.setGitIdentity(r,s),Ls.current.set(r,s),await ws()}catch(j){console.warn("Failed to auto-apply default git identity:",j)}finally{o||Zt()}})(),()=>{o=!0}},[i,Xt,r,E,Zt,n,P,ws]);const at=l.useMemo(()=>g?[...g.files??[]].sort((a,o)=>a.path.localeCompare(o.path)):[],[g]),Ue=l.useMemo(()=>at.filter(xr),[at]),ys=l.useMemo(()=>at.filter(ki),[at]);l.useEffect(()=>{if(!r||at.length===0)return;const s=[],a=new Set,o=j=>{!j||a.has(j)||(a.add(j),s.push(j))};if(Ue.forEach(j=>o(j.path)),xe.forEach(o),at.slice(0,ji).forEach(j=>o(j.path)),s.length===0)return;const c=window.setTimeout(()=>{$(r,n,s,{maxFiles:vi})},120);return()=>{window.clearTimeout(c)}},[at,r,n,$,Ue,xe]);const Zs=s=>s?.pushed[0]?.remote||g?.tracking?.split("/")[0]||Ke.find(a=>a.name==="origin")?.name||Ke[0]?.name||"origin",er=async(s,a)=>{if(r){st(s);try{const o=c=>{const j=`${c.name}/`,z=g?.tracking?.startsWith(j)?g.tracking.slice(j.length):void 0;return{remote:c.name,branch:z,rebase:!0}};if(s==="fetch"){if(!a)throw new Error("No remote available for fetch");await n.gitFetch(r,{remote:a.name}),b.success(e("gitView.toast.fetchedFromRemote",{name:a.name}))}else if(s==="pull"){if(!a)throw new Error("No remote available for pull");const c=await n.gitPull(r,o(a));b.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:a.name}))}else if(s==="push"){const c=await n.gitPush(r);b.success(e("gitView.toast.pushedToUpstream",{name:Zs(c)}))}else if(s==="sync"){if(!a)throw new Error("No remote available for sync");let c=0,j=!1;await n.gitFetch(r,{remote:a.name});const z=await n.getGitStatus(r);if((z.behind??0)>0){if((z.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync"));return}c=(await n.gitPull(r,o(a))).files.length}((await n.getGitStatus(r)).ahead??0)>0&&(await n.gitPush(r),j=!0),c>0&&j?b.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:a.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:a.name})):c>0?b.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:a.name})):j?b.success(e("gitView.toast.pushedToUpstream",{name:a.name})):b.success(e("gitView.toast.alreadyUpToDate"))}await re(!1),await ke()}catch(o){const c=o instanceof Error?o.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});b.error(c)}finally{st(null)}}},qr=l.useCallback(async s=>{if(!r)return;const a=s.name.trim();if(!a){b.error(e("gitView.toast.remoteNameRequired"));return}if(a==="origin"){b.error(e("gitView.toast.cannotRemoveOriginRemote"));return}Js(a);try{await n.removeRemote(r,{remote:a}),b.success(e("gitView.toast.removedRemote",{name:a})),await Promise.all([re(!1),Lt()])}catch(o){const c=o instanceof Error?o.message:`Failed to remove ${a}`;b.error(c)}finally{Js(null)}},[r,n,Lt,re,e]),tr=async(s={})=>{if(!r)return;if(!Be.trim()){b.error(e("gitView.toast.enterCommitMessage"));return}const a=Ue.map(c=>c.path).sort();if(a.length===0){b.error(e("gitView.toast.stageFileToCommit"));return}const o=s.pushAfter?"commitAndPush":"commit";Ds(o);try{if(await n.createGitCommit(r,Be.trim(),{files:a,stageFiles:[]}),_(r),b.success(e("gitView.toast.commitCreated")),q(""),Rt(),await re(),s.pushAfter){const c=g?.tracking?.split("/")[0],j=Ke.find(Vn=>Vn.name===c)??Ke[0];if(!j)throw new Error(e("mobile.changes.noRemote"));st("sync");const z=`${j.name}/`,ne=g?.tracking?.startsWith(z)?g.tracking.slice(z.length):void 0;await n.gitFetch(r,{remote:j.name});const K=await n.getGitStatus(r);if((K.behind??0)>0){if((K.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync")),await re(!1);return}await n.gitPull(r,{remote:j.name,branch:ne,rebase:!0})}const He=await n.getGitStatus(r);let bt;(He.ahead??0)>0&&(bt=await n.gitPush(r)),b.success(e("gitView.toast.pushedToUpstream",{name:Zs(bt)})),kr(),await re(!1)}else await re(!1);await ke(),Pr(c=>c+1)}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");b.error(j)}finally{Ds(null),s.pushAfter&&st(null)}},Yr=l.useCallback(async()=>{if(!r)return;const s=Ue.map(a=>a.path).sort();if(s.length===0){b.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),zs(!0);try{const{message:a}=await wa(r,s),o=a.subject?.trim()??"",c=Array.isArray(a.highlights)?a.highlights:[];if(o){let j=o;if(pe&&Ne.length>0){const z=Ci(o,Ne);if(z){const{code:ne,emoji:K}=z;!o.startsWith(ne)&&!o.startsWith(K)&&(j=`${ne} ${o}`)}}q(j)}Gs(c),_s()}catch(a){console.error("[git-generation][browser] GitView generate handler failed",{message:a instanceof Error?a.message:String(a),error:a});const o=a instanceof Error?a.message:e("gitView.toast.generateCommitMessageFailed");b.error(o)}finally{zs(!1)}},[r,Ue,pe,Ne,_s,e]),bs=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",Qr=async(s,a)=>{if(!r||!g)return;const o=Cs(U);if(o.length>0){b.error(e("gitView.toast.cannotCreateBranch",{reason:bs(o[0])}));return}const c=g.current??null,j=a?.name??"origin";try{await n.createBranch(r,s,c??"HEAD"),b.success(e("gitView.toast.createdBranch",{name:s})),await n.checkoutBranch(r,s);let z=!1;try{await n.gitPush(r,{remote:j,branch:s,options:["--set-upstream"]}),z=!0}catch(ne){const K=ne instanceof Error?ne.message:`Unable to push new branch to ${j}.`;b.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",K]})})}await re(),await ke(),z&&b.success(e("gitView.toast.upstreamSet",{branch:s,remote:j}))}catch(z){const ne=z instanceof Error?z.message:e("gitView.toast.createBranchFailed");throw b.error(ne),z}},Xr=async(s,a)=>{if(!r)return;const o=Cs(U);if(o.length>0){b.error(e("gitView.toast.cannotRenameBranch",{reason:bs(o[0])}));return}try{await n.renameBranch(r,s,a),b.success(e("gitView.toast.renamedBranch",{oldName:s,newName:a})),await re(),await ke()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:a});b.error(j)}},Zr=async s=>{if(!r)return;const a=Cs(U);if(a.length>0){b.error(e("gitView.toast.cannotCheckout",{reason:bs(a[0])}));return}const o=s.replace(/^remotes\//,"");if(g?.current!==o)try{await n.checkoutBranch(r,o),b.success(e("gitView.toast.checkedOut",{name:o})),await re(),await ke()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.checkoutFailed",{name:o});b.error(j)}},en=async s=>{if(r){Xt();try{await n.setGitIdentity(r,s.id),b.success(e("gitView.toast.appliedIdentity",{name:s.name})),await ws()}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.applyIdentityFailed");b.error(o)}finally{Zt()}}},St=l.useMemo(()=>J?.all?J.all.filter(s=>!s.startsWith("remotes/")).sort():[],[J]),it=l.useMemo(()=>J?.all?J.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[J]),Ke=l.useMemo(()=>{if(cs.length>0)return cs;const s=new Set,a=g?.tracking?.trim();a&&a.includes("/")&&s.add(a.split("/")[0]);for(const o of it){const c=o.indexOf("/");c>0&&s.add(o.slice(0,c))}return s.size===0&&ft&&s.add("origin"),Array.from(s).map(o=>({name:o,fetchUrl:ft??"",pushUrl:ft??""}))},[cs,it,ft,g?.tracking]),ot=g?.current??null,sr=l.useMemo(()=>{const s=g?.tracking?.trim().split("/")[0];return(s&&J?.defaultBranches?.[s])??J?.defaultBranches?.origin},[J,g?.tracking]),pt=l.useMemo(()=>Ca({remoteNames:new Set(Ke.map(s=>s.name)),localBranches:St,worktreeCreatedFromBranch:F?.createdFromBranch,rootBranchHint:Ce,defaultBranch:sr,headBranch:ot}),[ot,sr,Ke,St,Ce,F?.createdFromBranch]),tn=l.useMemo(()=>Ke.map(o=>o.name).map(o=>`${o}/${pt}`).find(o=>it.includes(o))??pt,[pt,Ke,it]),sn=l.useMemo(()=>{const s=new Map;d&&s.set(d.id,d);let a=null;if(ft)try{let o=ft.trim();o.startsWith("git@")&&(o=`https://${o.slice(4).replace(":","/")}`),o.endsWith(".git")&&(o=o.slice(0,-4));const c=new URL(o);a=c.hostname+c.pathname}catch{}for(const o of I){if(o.authType!=="token"){s.set(o.id,o);continue}const c=o.host;if(!c){s.set(o.id,o);continue}if(!c.includes("/")){s.set(o.id,o);continue}a&&a===c&&s.set(o.id,o)}return Array.from(s.values())},[I,d,ft]),rn=l.useMemo(()=>{if(G?.userName&&G?.userEmail){const s=I.find(a=>a.userName===G.userName&&a.userEmail===G.userEmail);return s||(d&&d.userName===G.userName&&d.userEmail===G.userEmail?d:{id:"local-config",name:G.userName,userName:G.userName,userEmail:G.userEmail,sshKey:G.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return d??null},[G,I,d]),nn=Ue.length,an=Z||tt!==null||Ts!==null,on=!!(F&&rs&&ns&&Mr),rr=!!ot,lt=on&&rs&&ns&&F?{repoRoot:rs,sourceBranch:ns,worktreeMetadata:F}:null;l.useEffect(()=>{if(!r||!n||!H?.all?.length||!ot||!pt||ot===pt){yt(null);return}let s=!1;return(async()=>{try{const o=await n.getGitLog(r,{from:pt,to:"HEAD",maxCount:Je});if(s)return;const c=new Set((o?.all??[]).map(z=>z.hash).filter(z=>typeof z=="string"&&z.length>0));if(c.size===0){yt(null);return}const j=H.all.findIndex(z=>!c.has(z.hash));if(j===0){yt(null);return}if(j===-1){yt({insertBeforeIndex:H.all.length,branchName:ot,direction:"up"});return}yt({insertBeforeIndex:j,branchName:ot,direction:"up"})}catch{s||yt(null)}})(),()=>{s=!0}},[pt,ot,r,n,H,Je]),l.useEffect(()=>{ms(null)},[r]),l.useEffect(()=>{if(Ae!=="graph"||!r){Ae!=="graph"&&ms(null);return}let s=!1;return Ys(!0),n.getGitLog(r,{maxCount:gs,all:!0}).then(a=>{s||ms(a)}).catch(a=>{console.error("Failed to fetch graph log:",a)}).finally(()=>{s||Ys(!1)}),()=>{s=!0}},[Ae,r,gs,Hr,n]);const kt=l.useCallback((s,a)=>{if(!r||s.length===0)return;const o=Array.from(new Set(s));As(j=>{const z=new Set(j);return o.forEach(ne=>z.add(ne)),z});const c=ie(r,o,a);fe.enqueue({directory:r,direction:a,paths:new Set(o),rollback:()=>ee(r,c)}),Ie()},[r,fe,ie,ee,Ie]),vs=l.useCallback(async s=>{if(r){Ft(a=>{const o=new Set(a);return o.add(s),o});try{await n.revertGitFile(r,s,{scope:"working"}),b.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.revertFailed");b.error(o)}finally{Ft(a=>{const o=new Set(a);return o.delete(s),o})}}},[r,re,n,e]),At=l.useCallback(async(s,a,o="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(ts||c.some(K=>es.has(K)))return;const j=new Set(Ue.map(K=>K.path)),z=o==="all"&&c.some(K=>j.has(K));a&&Os(!0),Ft(K=>{const He=new Set(K);return c.forEach(bt=>He.add(bt)),He});const ne=[];try{if(await Promise.all(c.map(async K=>{try{await n.revertGitFile(r,K,{scope:o})}catch(He){ne.push({path:K,message:He instanceof Error?He.message:e("gitView.toast.revertFailed")})}})),z&&ne.length<c.length&&_(r),await re(!1),ne.length===0)b.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(ne.length===c.length)b.error(ne[0]?.message||e("gitView.toast.revertFailed"));else{const K=c.length-ne.length;b.warning(K===1?e("gitView.toast.revertedSomeSingle",{success:K,failed:ne.length}):e("gitView.toast.revertedSomePlural",{success:K,failed:ne.length}))}}finally{Ft(K=>{const He=new Set(K);return c.forEach(bt=>He.delete(bt)),He}),a&&Os(!1)}},[_,r,n,ts,re,es,Ue,e]),ln=l.useCallback(async s=>{await At(s,!0)},[At]),cn=l.useCallback(async s=>{await At(s,!1,"working")},[At]),js=l.useCallback((s,a)=>{if(r&&!be){te(r,s,a);return}he(s,a)},[r,be,he,te]),dn=l.useCallback(()=>Qt(!0),[]),un=l.useMemo(()=>{const s=[];return Ue.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Ue,actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:a=>e("gitView.changes.unstageFileAria",{path:a}),onActionFile:a=>{kt([a],"unstage")},onActionAll:a=>{kt(a,"unstage")},onViewDiff:a=>js(a,!0),onRevertFile:vs,showRevertActions:!1,accent:!0}),ys.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:ys,actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:a=>e("gitView.changes.stageFileAria",{path:a}),onActionFile:a=>{kt([a],"stage")},onActionAll:a=>{kt(a,"stage")},onViewDiff:a=>js(a,!1),onRevertFile:vs}),s},[vs,js,kt,Ue,e,ys]),mn=l.useCallback(s=>{if(s.length===0)return;const a=s.map(o=>o.trim()).filter(Boolean);if(a.length===0){Rt();return}q(o=>{const c=o.trim(),j=c.length>0?`
|
|
4
4
|
|
|
5
5
|
`:"";return`${c}${j}${a.join(`
|
|
6
|
-
`)}`.trim()}),Rt()},[Rt]),hn=l.useCallback((s,a)=>{const o=a||s;q(c=>{const j=c.trimStart();return j.startsWith(s)||a&&j.startsWith(a)?c:`${o.endsWith(" ")?o:`${o} `}${c}`.trimStart()}),Ws(""),ye(!1)},[]),Ot=l.useCallback(s=>{const a=s instanceof Error?s.message.toLowerCase():"";return a.includes("uncommitted changes")||a.includes("local changes")||a.includes("your local changes would be overwritten")||a.includes("please commit your changes or stash them")||a.includes("cannot rebase: you have unstaged changes")||a.includes("error: cannot pull with rebase")},[]),ct=l.useCallback((s,a)=>{Dt(o=>[...o,{message:s,status:a,timestamp:Date.now()}])},[]),$e=l.useCallback((s,a)=>{Dt(o=>{if(o.length===0)return o;const c=[...o];return c[c.length-1]={...c[c.length-1],status:s,...a?{message:a}:{}},c})},[]),zt=l.useCallback(()=>{Dt([])},[]),gn=l.useCallback(()=>{Dt([]),us(null)},[]),Gt=l.useCallback(s=>{const a=s.trim(),o=new Set(Ke.map(j=>j.name)),c=a.indexOf("/");if(c>0){const j=a.slice(0,c),z=a.slice(c+1);if(o.has(j)&&z)return{branch:a,remote:j,remoteBranch:z}}for(const j of Ke){const z=`${j.name}/${a}`;if(it.includes(z))return{branch:z,remote:j.name,remoteBranch:a}}return{branch:a,remote:null,remoteBranch:null}},[Ke,it]),fn=l.useCallback(async s=>{if(!r)return;us("merge"),zt();const a=g?.current,o=Gt(s);try{o.remote&&o.remoteBranch&&(ct(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),$e("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ct(`Merging ${o.branch} into ${a}...`,"running");const c=await n.merge(r,{branch:o.branch});c.conflict?($e("error","Merge conflicts detected"),Qe(c.conflictFiles??[]),Xe("merge"),qe(!0),rt(r,c.conflictFiles??[],"merge")):($e("done",`Merged ${o.branch} into ${a}`),We(),ct("Refreshing repository status...","running"),await re(),await ke(),$e("done","Repository status updated"))}catch(c){if(Ot(c))$e("error","Uncommitted changes detected"),Qs("merge"),Xs(o.branch),fs(!0);else{const j=c instanceof Error?c.message:`Failed to merge ${o.branch}`;$e("error",j)}}},[r,n,g,Gt,re,ke,Ot,rt,We,ct,$e,zt]),pn=l.useCallback(async s=>{if(!r)return;us("rebase"),zt();const a=g?.current,o=Gt(s);try{o.remote&&o.remoteBranch&&(ct(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),$e("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ct(`Rebasing ${a} onto ${o.branch}...`,"running");const c=await n.rebase(r,{onto:o.branch});c.conflict?($e("error","Rebase conflicts detected"),Qe(c.conflictFiles??[]),Xe("rebase"),qe(!0),rt(r,c.conflictFiles??[],"rebase")):($e("done",`Rebased ${a} onto ${o.branch}`),We(),ct("Refreshing repository status...","running"),await re(),await ke(),$e("done","Repository status updated"))}catch(c){if(Ot(c))$e("error","Uncommitted changes detected"),Qs("rebase"),Xs(o.branch),fs(!0);else{const j=c instanceof Error?c.message:`Failed to rebase onto ${o.branch}`;$e("error",j)}}},[r,n,g,Gt,re,ke,Ot,rt,We,ct,$e,zt]),xn=l.useCallback(async()=>{if(r)try{Et==="merge"?(await n.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),We(),await re(),await ke()}catch(s){const a=s instanceof Error?s.message:`Failed to abort ${Et}`;b.error(a)}},[r,n,Et,re,ke,We,e]),wn=l.useMemo(()=>g?.files?g.files.filter(s=>s.index==="U"||s.working_dir==="U"||s.index==="A"&&s.working_dir==="A"||s.index==="D"&&s.working_dir==="D").length:0,[g?.files]),yn=l.useCallback(async()=>{if(r)try{const s=!!g?.mergeInProgress?.head,a=!!(g?.rebaseInProgress?.headName||g?.rebaseInProgress?.onto);if(s){const o=await n.continueMerge(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("merge"),qe(!0),rt(r,o.conflictFiles??[],"merge"),b.error(e("gitView.toast.mergeConflictsDetected"))):(We(),b.success(e("gitView.toast.mergeCompleted")),await re(),await ke())}else if(a){const o=await n.continueRebase(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("rebase"),qe(!0),rt(r,o.conflictFiles??[],"rebase"),b.error(e("gitView.toast.rebaseConflictsDetected"))):(We(),b.success(e("gitView.toast.rebaseStepCompleted")),await re(),await ke())}}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");b.error(a)}},[r,n,g,re,ke,rt,We,e]),bn=l.useCallback(async()=>{if(r)try{!!g?.mergeInProgress?.head?(await n.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),We(),await re(),await ke()}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");b.error(a)}},[r,n,g,re,ke,We,e]),vn=l.useCallback(()=>{if(!r)return;const a=!!g?.mergeInProgress?.head?"merge":"rebase",o=g?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];o.length>0&&Qe(o),Xe(a),qe(!0)},[r,g]),jn=l.useCallback(async s=>{if(!r)return;const a=g?.current,o=ps,c=xs,j=(g?.files??[]).some(xr);try{await n.stash(r,{message:`Auto-stash before ${o} with ${c}`,includeUntracked:!0}),j&&_(r)}catch(K){const He=K instanceof Error?K.message:"Failed to stash changes";b.error(He);return}let z=!1,ne=!1;try{if(o==="merge"){const K=await n.merge(r,{branch:c});K.conflict?(ne=!0,Qe(K.conflictFiles??[]),Xe("merge"),qe(!0)):(z=!0,b.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:a||""})))}else{const K=await n.rebase(r,{onto:c});K.conflict?(ne=!0,Qe(K.conflictFiles??[]),Xe("rebase"),qe(!0)):(z=!0,b.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:a||"",branch:c})))}if(s&&z)try{await n.stashPop(r),_(r),b.success(e("gitView.toast.stashedRestored"))}catch(K){const He=K instanceof Error?K.message:e("gitView.toast.restoreStashFailed");b.error(He)}else s&&ne&&b.info(e("gitView.toast.restoreStashManually"));await re(),await ke()}catch(K){if(s)try{await n.stashPop(r),_(r)}catch{}throw K}},[_,r,n,g,ps,xs,re,ke,e]),Cn=l.useCallback(s=>{Nr(s),r&&(u(r,s),T(r,n,s))},[r,T,n,u]),Nn=l.useCallback(s=>{$r(s)},[]),Sn=l.useCallback(()=>{Tt(null),r&&(h(r,n),L(r,n),T(r,n,Je))},[r,h,L,T,Je,n]),kn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){b.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(h(r,n),L(r,n),T(r,n,Je));return}Qe(s.conflictFiles??[]),Xe(s.operation),qe(!0),r&&rt(r,s.conflictFiles??[],s.operation)}},[e,Qe,Xe,qe,rt,r,h,L,T,Je,n]);return r?P===null||P===!0&&!g?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):P===!1?ze?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(D,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e("gitView.empty.worktreeSetupInProgress")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(D,{name:"git-branch",className:"mb-3 size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e("gitView.empty.notGitRepository")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.notGitRepositoryDescription")}),Y.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):null]}):t.jsxs("div",{className:Re("flex h-full flex-col overflow-hidden"),children:[t.jsx(Ia,{status:g,localBranches:St,remoteBranches:it,branchInfo:J?.branches,syncAction:tt,remotes:Ke,onFetch:s=>er("fetch",s),onSync:s=>er("sync",s),onRemoveRemote:qr,removingRemoteName:Ar,onCheckoutBranch:Zr,onCreateBranch:Qr,onRenameBranch:Xr,activeIdentityProfile:rn,availableIdentities:sn,onSelectIdentity:en,isApplyingIdentity:Sr,isWorktreeMode:!!F,onOpenHistory:()=>Tt("history"),onOpenGraph:()=>Tt("graph"),onOpenStashes:dn,onOpenUpdateBranch:rr?()=>Us(!0):void 0,onOpenReintegrateCommits:lt?()=>Ks(!0):void 0,pullRequest:ue?.pr??null,prChecks:ue?.checks??null,onOpenPullRequest:r?()=>de(r,"pr"):void 0}),r&&(g?.mergeInProgress?.head||g?.rebaseInProgress?.headName||g?.rebaseInProgress?.onto)&&t.jsx(mi,{mergeInProgress:g?.mergeInProgress,rebaseInProgress:g?.rebaseInProgress,onContinue:yn,onAbort:bn,onResolveWithAI:vn,conflictCount:wn,isLoading:Z}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx("div",{className:"h-full min-h-0 flex flex-col",children:t.jsx("div",{className:Re("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(yr,{as:ya,ref:_e,outerClassName:"flex-1 min-h-0",className:Re("px-4","pt-1 pb-4"),disableHorizontal:!0,preventOverscroll:!0,children:t.jsx("div",{className:"flex h-full min-h-0 flex-col gap-3",children:(at?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Fa,{groups:un,diffStats:g?.diffStats,revertingPaths:es,isRevertingAll:ts,onVisiblePathsChange:Se,onRevertAll:ln,onRevertDirectory:cn,headerBackgroundClassName:"bg-background"})}),t.jsx(Ra,{stagedCount:nn,commitMessage:Be,onCommitMessageChange:q,generatedHighlights:ss,onInsertHighlights:mn,onGenerateMessage:Yr,isGeneratingMessage:Fr,onCommit:()=>tr({pushAfter:!1}),onCommitAndPush:()=>tr({pushAfter:!0}),commitAction:Ts,hasPendingIndexMutation:Rr,gitmojiEnabled:pe,onOpenGitmojiPicker:()=>ye(!0)})]}):t.jsx(Ha,{onOpenStashes:()=>Qt(!0)})})})})})}),t.jsx(ut,{open:Er,onOpenChange:s=>{!s&&qs!==null||Us(s)},children:t.jsxs(mt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ht,{children:[t.jsx(gt,{children:e("gitView.branch.updateTitle")}),t.jsxs(wt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:g?.current??""}),"."]})]}),rr?t.jsx(hi,{mode:"bare",currentBranch:g?.current,localBranches:St,remoteBranches:it,defaultTargetBranch:tn,onMerge:fn,onRebase:pn,disabled:an,isOperating:qs!==null,operationLogs:Or,onOperationComplete:gn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(ut,{open:Lr,onOpenChange:Ks,children:t.jsxs(mt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ht,{children:[t.jsx(gt,{children:e("gitView.integrate.title")}),t.jsx(wt,{children:lt?t.jsxs("span",{className:"font-mono text-foreground",children:[lt.sourceBranch," → ",$s]}):null})]}),lt?t.jsx(_a,{repoRoot:lt.repoRoot,sourceBranch:lt.sourceBranch,worktreeMetadata:lt.worktreeMetadata,localBranches:St,defaultTargetBranch:$s,refreshKey:Ir,showHeader:!1,onRefresh:()=>{r&&(h(r,n),L(r,n),T(r,n,Je))}},lt.worktreeMetadata.path):null]})}),t.jsx(ut,{open:Ae!==null,onOpenChange:s=>{s||Tt(null)},children:t.jsxs(mt,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(ht,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(gt,{children:e(Ae==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(Ae==="graph"){Wr(s=>s+1);return}r&&T(r,n,Je)},disabled:Ae==="graph"?hs:Q,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(D,{name:"refresh",className:Re("size-4",(Ae==="graph"?hs:Q)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(wt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Za,{mode:Ae==="graph"?"graph":"history",log:Ae==="graph"?_r??H:H,isLogLoading:Ae==="graph"&&hs||Q,logMaxCount:Ae==="graph"?gs:Je,onLogMaxCountChange:Ae==="graph"?Nn:Cn,expandedCommitHashes:as,onToggleCommit:Jr,commitFilesMap:Mt,loadingCommitHashes:Bt,onCopyHash:Kr,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Ae==="graph"?null:Dr,onConflict:Ae==="graph"?kn:void 0,onActionSuccess:Ae==="graph"?Sn:void 0})})]})}),t.jsx($a,{open:Cr,onOpenChange:Qt,directory:r,hasUncommittedChanges:(g?.files?.length??0)>0,hasStagedChanges:Ue.length>0,uncommittedFileCount:g?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&_(r),await re(!1),await ke()}}),t.jsx(ut,{open:we,onOpenChange:ye,children:t.jsxs(mt,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(ht,{className:"px-4 pt-4",children:t.jsx(gt,{children:e("gitView.gitmoji.title")})}),t.jsxs(Fs,{className:"h-[420px]",children:[t.jsx(Rs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:Hs,onValueChange:Ws}),t.jsxs(Ms,{children:[t.jsx(Bs,{children:e("gitView.gitmoji.empty")}),t.jsx(Ut,{children:(Ne.length===0?[]:Ne.filter(s=>{const a=Hs.trim().toLowerCase();return a?s.emoji.includes(a)||s.code.toLowerCase().includes(a)||s.description.toLowerCase().includes(a):!0})).map(s=>t.jsxs(Kt,{onSelect:()=>hn(s.emoji,s.code),children:[t.jsx("span",{className:"text-lg",children:s.emoji}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s.code}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s.description})]},s.code))})]})]})]})}),r&&t.jsx(ni,{open:zr,onOpenChange:qe,conflictFiles:Gr,directory:r,operation:Et,onAbort:xn,onClearState:We}),t.jsx(ui,{open:Ur,onOpenChange:fs,operation:ps,targetBranch:xs,onConfirm:jn})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:e("gitView.empty.selectSessionOrDirectory")})})};export{zl as GitView};
|
|
6
|
+
`)}`.trim()}),Rt()},[Rt]),hn=l.useCallback((s,a)=>{const o=a||s;q(c=>{const j=c.trimStart();return j.startsWith(s)||a&&j.startsWith(a)?c:`${o.endsWith(" ")?o:`${o} `}${c}`.trimStart()}),Ws(""),ye(!1)},[]),Ot=l.useCallback(s=>{const a=s instanceof Error?s.message.toLowerCase():"";return a.includes("uncommitted changes")||a.includes("local changes")||a.includes("your local changes would be overwritten")||a.includes("please commit your changes or stash them")||a.includes("cannot rebase: you have unstaged changes")||a.includes("error: cannot pull with rebase")},[]),ct=l.useCallback((s,a)=>{Dt(o=>[...o,{message:s,status:a,timestamp:Date.now()}])},[]),$e=l.useCallback((s,a)=>{Dt(o=>{if(o.length===0)return o;const c=[...o];return c[c.length-1]={...c[c.length-1],status:s,...a?{message:a}:{}},c})},[]),zt=l.useCallback(()=>{Dt([])},[]),gn=l.useCallback(()=>{Dt([]),us(null)},[]),Gt=l.useCallback(s=>{const a=s.trim(),o=new Set(Ke.map(j=>j.name)),c=a.indexOf("/");if(c>0){const j=a.slice(0,c),z=a.slice(c+1);if(o.has(j)&&z)return{branch:a,remote:j,remoteBranch:z}}for(const j of Ke){const z=`${j.name}/${a}`;if(it.includes(z))return{branch:z,remote:j.name,remoteBranch:a}}return{branch:a,remote:null,remoteBranch:null}},[Ke,it]),fn=l.useCallback(async s=>{if(!r)return;us("merge"),zt();const a=g?.current,o=Gt(s);try{o.remote&&o.remoteBranch&&(ct(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),$e("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ct(`Merging ${o.branch} into ${a}...`,"running");const c=await n.merge(r,{branch:o.branch});c.conflict?($e("error","Merge conflicts detected"),Qe(c.conflictFiles??[]),Xe("merge"),qe(!0),rt(r,c.conflictFiles??[],"merge")):($e("done",`Merged ${o.branch} into ${a}`),We(),ct("Refreshing repository status...","running"),await re(),await ke(),$e("done","Repository status updated"))}catch(c){if(Ot(c))$e("error","Uncommitted changes detected"),Qs("merge"),Xs(o.branch),fs(!0);else{const j=c instanceof Error?c.message:`Failed to merge ${o.branch}`;$e("error",j)}}},[r,n,g,Gt,re,ke,Ot,rt,We,ct,$e,zt]),pn=l.useCallback(async s=>{if(!r)return;us("rebase"),zt();const a=g?.current,o=Gt(s);try{o.remote&&o.remoteBranch&&(ct(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),$e("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ct(`Rebasing ${a} onto ${o.branch}...`,"running");const c=await n.rebase(r,{onto:o.branch});c.conflict?($e("error","Rebase conflicts detected"),Qe(c.conflictFiles??[]),Xe("rebase"),qe(!0),rt(r,c.conflictFiles??[],"rebase")):($e("done",`Rebased ${a} onto ${o.branch}`),We(),ct("Refreshing repository status...","running"),await re(),await ke(),$e("done","Repository status updated"))}catch(c){if(Ot(c))$e("error","Uncommitted changes detected"),Qs("rebase"),Xs(o.branch),fs(!0);else{const j=c instanceof Error?c.message:`Failed to rebase onto ${o.branch}`;$e("error",j)}}},[r,n,g,Gt,re,ke,Ot,rt,We,ct,$e,zt]),xn=l.useCallback(async()=>{if(r)try{Et==="merge"?(await n.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),We(),await re(),await ke()}catch(s){const a=s instanceof Error?s.message:`Failed to abort ${Et}`;b.error(a)}},[r,n,Et,re,ke,We,e]),wn=l.useMemo(()=>g?.files?g.files.filter(s=>s.index==="U"||s.working_dir==="U"||s.index==="A"&&s.working_dir==="A"||s.index==="D"&&s.working_dir==="D").length:0,[g?.files]),yn=l.useCallback(async()=>{if(r)try{const s=!!g?.mergeInProgress?.head,a=!!(g?.rebaseInProgress?.headName||g?.rebaseInProgress?.onto);if(s){const o=await n.continueMerge(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("merge"),qe(!0),rt(r,o.conflictFiles??[],"merge"),b.error(e("gitView.toast.mergeConflictsDetected"))):(We(),b.success(e("gitView.toast.mergeCompleted")),await re(),await ke())}else if(a){const o=await n.continueRebase(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("rebase"),qe(!0),rt(r,o.conflictFiles??[],"rebase"),b.error(e("gitView.toast.rebaseConflictsDetected"))):(We(),b.success(e("gitView.toast.rebaseStepCompleted")),await re(),await ke())}}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");b.error(a)}},[r,n,g,re,ke,rt,We,e]),bn=l.useCallback(async()=>{if(r)try{!!g?.mergeInProgress?.head?(await n.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),We(),await re(),await ke()}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");b.error(a)}},[r,n,g,re,ke,We,e]),vn=l.useCallback(()=>{if(!r)return;const a=!!g?.mergeInProgress?.head?"merge":"rebase",o=g?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];o.length>0&&Qe(o),Xe(a),qe(!0)},[r,g]),jn=l.useCallback(async s=>{if(!r)return;const a=g?.current,o=ps,c=xs,j=(g?.files??[]).some(xr);try{await n.stash(r,{message:`Auto-stash before ${o} with ${c}`,includeUntracked:!0}),j&&_(r)}catch(K){const He=K instanceof Error?K.message:"Failed to stash changes";b.error(He);return}let z=!1,ne=!1;try{if(o==="merge"){const K=await n.merge(r,{branch:c});K.conflict?(ne=!0,Qe(K.conflictFiles??[]),Xe("merge"),qe(!0)):(z=!0,b.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:a||""})))}else{const K=await n.rebase(r,{onto:c});K.conflict?(ne=!0,Qe(K.conflictFiles??[]),Xe("rebase"),qe(!0)):(z=!0,b.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:a||"",branch:c})))}if(s&&z)try{await n.stashPop(r),_(r),b.success(e("gitView.toast.stashedRestored"))}catch(K){const He=K instanceof Error?K.message:e("gitView.toast.restoreStashFailed");b.error(He)}else s&&ne&&b.info(e("gitView.toast.restoreStashManually"));await re(),await ke()}catch(K){if(s)try{await n.stashPop(r),_(r)}catch{}throw K}},[_,r,n,g,ps,xs,re,ke,e]),Cn=l.useCallback(s=>{Nr(s),r&&(u(r,s),T(r,n,s))},[r,T,n,u]),Nn=l.useCallback(s=>{$r(s)},[]),Sn=l.useCallback(()=>{Tt(null),r&&(h(r,n),L(r,n),T(r,n,Je))},[r,h,L,T,Je,n]),kn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){b.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(h(r,n),L(r,n),T(r,n,Je));return}Qe(s.conflictFiles??[]),Xe(s.operation),qe(!0),r&&rt(r,s.conflictFiles??[],s.operation)}},[e,Qe,Xe,qe,rt,r,h,L,T,Je,n]);return r?P===null||P===!0&&!g?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):P===!1?ze?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(D,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e("gitView.empty.worktreeSetupInProgress")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(D,{name:"git-branch",className:"mb-3 size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e("gitView.empty.notGitRepository")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.notGitRepositoryDescription")}),Y.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):null]}):t.jsxs("div",{className:Re("flex h-full flex-col overflow-hidden"),children:[t.jsx(Ia,{status:g,localBranches:St,remoteBranches:it,branchInfo:J?.branches,syncAction:tt,remotes:Ke,onFetch:s=>er("fetch",s),onSync:s=>er("sync",s),onRemoveRemote:qr,removingRemoteName:Ar,onCheckoutBranch:Zr,onCreateBranch:Qr,onRenameBranch:Xr,activeIdentityProfile:rn,availableIdentities:sn,onSelectIdentity:en,isApplyingIdentity:Sr,isWorktreeMode:!!F,onOpenHistory:()=>Tt("history"),onOpenGraph:()=>Tt("graph"),onOpenStashes:dn,onOpenUpdateBranch:rr?()=>Us(!0):void 0,onOpenReintegrateCommits:lt?()=>Ks(!0):void 0,pullRequest:ue?.pr??null,prChecks:ue?.checks??null,onOpenPullRequest:r?()=>de(r,"pr"):void 0}),r&&(g?.mergeInProgress?.head||g?.rebaseInProgress?.headName||g?.rebaseInProgress?.onto)&&t.jsx(mi,{mergeInProgress:g?.mergeInProgress,rebaseInProgress:g?.rebaseInProgress,onContinue:yn,onAbort:bn,onResolveWithAI:vn,conflictCount:wn,isLoading:Z}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx("div",{className:"h-full min-h-0 flex flex-col",children:t.jsx("div",{className:Re("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(yr,{as:ya,ref:_e,outerClassName:"flex-1 min-h-0",className:Re("px-4","pt-1 pb-4"),disableHorizontal:!0,preventOverscroll:!0,children:t.jsx("div",{className:"flex h-full min-h-0 flex-col gap-3",children:(at?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Fa,{groups:un,diffStats:g?.diffStats,revertingPaths:es,isRevertingAll:ts,onVisiblePathsChange:Se,onRevertAll:ln,onRevertDirectory:cn,headerBackgroundClassName:"bg-background"})}),t.jsx(Ra,{stagedCount:nn,commitMessage:Be,onCommitMessageChange:q,generatedHighlights:ss,onInsertHighlights:mn,onGenerateMessage:Yr,isGeneratingMessage:Fr,onCommit:()=>tr({pushAfter:!1}),onCommitAndPush:()=>tr({pushAfter:!0}),commitAction:Ts,hasPendingIndexMutation:Rr,gitmojiEnabled:pe,onOpenGitmojiPicker:()=>ye(!0)})]}):t.jsx(Ha,{onOpenStashes:()=>Qt(!0)})})})})})}),t.jsx(ut,{open:Er,onOpenChange:s=>{!s&&qs!==null||Us(s)},children:t.jsxs(mt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ht,{children:[t.jsx(gt,{children:e("gitView.branch.updateTitle")}),t.jsxs(wt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:g?.current??""}),"."]})]}),rr?t.jsx(hi,{mode:"bare",currentBranch:g?.current,localBranches:St,remoteBranches:it,defaultTargetBranch:tn,onMerge:fn,onRebase:pn,disabled:an,isOperating:qs!==null,operationLogs:Or,onOperationComplete:gn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(ut,{open:Lr,onOpenChange:Ks,children:t.jsxs(mt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ht,{children:[t.jsx(gt,{children:e("gitView.integrate.title")}),t.jsx(wt,{children:lt?t.jsxs("span",{className:"font-mono text-foreground",children:[lt.sourceBranch," → ",$s]}):null})]}),lt?t.jsx(_a,{repoRoot:lt.repoRoot,sourceBranch:lt.sourceBranch,worktreeMetadata:lt.worktreeMetadata,localBranches:St,defaultTargetBranch:$s,refreshKey:Ir,showHeader:!1,onRefresh:()=>{r&&(h(r,n),L(r,n),T(r,n,Je))}},lt.worktreeMetadata.path):null]})}),t.jsx(ut,{open:Ae!==null,onOpenChange:s=>{s||Tt(null)},children:t.jsxs(mt,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(ht,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(gt,{children:e(Ae==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(Ae==="graph"){Wr(s=>s+1);return}r&&T(r,n,Je)},disabled:Ae==="graph"?hs:Q,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(D,{name:"refresh",className:Re("size-4",(Ae==="graph"?hs:Q)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(wt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Za,{mode:Ae==="graph"?"graph":"history",log:Ae==="graph"?_r??H:H,isLogLoading:Ae==="graph"&&hs||Q,logMaxCount:Ae==="graph"?gs:Je,onLogMaxCountChange:Ae==="graph"?Nn:Cn,expandedCommitHashes:as,onToggleCommit:Jr,commitFilesMap:Mt,loadingCommitHashes:Bt,onCopyHash:Kr,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Ae==="graph"?null:Dr,onConflict:Ae==="graph"?kn:void 0,onActionSuccess:Ae==="graph"?Sn:void 0})})]})}),t.jsx($a,{open:Cr,onOpenChange:Qt,directory:r,hasUncommittedChanges:(g?.files?.length??0)>0,hasStagedChanges:Ue.length>0,uncommittedFileCount:g?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&_(r),await re(!1),await ke()}}),t.jsx(ut,{open:we,onOpenChange:ye,children:t.jsxs(mt,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(ht,{className:"px-4 pt-4",children:t.jsx(gt,{children:e("gitView.gitmoji.title")})}),t.jsxs(Fs,{className:"h-[420px]",children:[t.jsx(Rs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:Hs,onValueChange:Ws}),t.jsxs(Ms,{children:[t.jsx(Bs,{children:e("gitView.gitmoji.empty")}),t.jsx(Ut,{children:(Ne.length===0?[]:Ne.filter(s=>{const a=Hs.trim().toLowerCase();return a?s.emoji.includes(a)||s.code.toLowerCase().includes(a)||s.description.toLowerCase().includes(a):!0})).map(s=>t.jsxs(Kt,{onSelect:()=>hn(s.emoji,s.code),children:[t.jsx("span",{className:"text-lg",children:s.emoji}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s.code}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s.description})]},s.code))})]})]})]})}),r&&t.jsx(ni,{open:zr,onOpenChange:qe,conflictFiles:Gr,directory:r,operation:Et,onAbort:xn,onClearState:We}),t.jsx(ui,{open:Ur,onOpenChange:fs,operation:ps,targetBranch:xs,onConfirm:jn})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:e("gitView.empty.selectSessionOrDirectory")})})};export{Gl as GitView};
|