@openchamber/web 2.3.2 → 2.3.3

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.
Files changed (213) hide show
  1. package/dist/assets/{AboutDialog-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
  2. package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
  3. package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
  4. package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
  5. package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
  6. package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
  7. package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
  8. package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
  9. package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
  10. package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
  11. package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
  12. package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
  13. package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
  14. package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
  15. package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
  17. package/dist/assets/PlanView-BxRCMuGe.js +5 -0
  18. package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
  19. package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
  20. package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
  21. package/dist/assets/SettingsView-CVpfbdob.js +30 -0
  22. package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
  23. package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
  24. package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
  25. package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
  26. package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
  27. package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
  28. package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
  29. package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
  31. package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
  32. package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
  33. package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
  34. package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
  35. package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
  36. package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
  37. package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
  38. package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
  39. package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
  40. package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
  41. package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
  42. package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
  43. package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
  44. package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
  45. package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
  46. package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
  47. package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
  48. package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
  49. package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
  50. package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
  51. package/dist/assets/katex-BZNCT55U.css +1 -0
  52. package/dist/assets/katex.min-EZjpSwGK.js +65 -0
  53. package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
  54. package/dist/assets/main-BUetg9hg.js +1048 -0
  55. package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
  56. package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
  57. package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
  58. package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
  59. package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
  60. package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
  61. package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
  62. package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
  63. package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
  64. package/dist/assets/pl-4LdEMgWI.js +20 -0
  65. package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
  66. package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
  67. package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
  68. package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
  69. package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
  70. package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
  71. package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
  72. package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
  73. package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
  74. package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
  75. package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
  76. package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
  77. package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
  78. package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
  79. package/dist/assets/tr-Bg0Qt-mG.js +11 -0
  80. package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
  81. package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
  82. package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
  83. package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
  84. package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
  85. package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
  86. package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
  87. package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
  88. package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
  89. package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
  90. package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
  91. package/dist/index.html +3 -3
  92. package/dist/mini-chat.html +3 -3
  93. package/dist/mobile.html +3 -3
  94. package/package.json +5 -5
  95. package/server/index.js +13 -1
  96. package/server/lib/agent-memory/actions.js +22 -9
  97. package/server/lib/agent-memory/actions.test.js +57 -0
  98. package/server/lib/agent-memory/runtime.js +8 -5
  99. package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
  100. package/server/lib/agent-tool/runtime.js +41 -7
  101. package/server/lib/agent-tool/runtime.test.js +11 -0
  102. package/server/lib/git/DOCUMENTATION.md +17 -5
  103. package/server/lib/git/lfs-discovery.js +7 -4
  104. package/server/lib/git/lfs-discovery.test.js +60 -0
  105. package/server/lib/git/network-operations.js +9 -3
  106. package/server/lib/git/network-operations.test.js +31 -2
  107. package/server/lib/git/service.js +72 -12
  108. package/server/lib/git/service.test.js +65 -0
  109. package/server/lib/github/DOCUMENTATION.md +1 -0
  110. package/server/lib/github/reference-search.js +49 -18
  111. package/server/lib/github/reference-search.test.js +28 -6
  112. package/server/lib/github/routes.js +87 -1
  113. package/server/lib/github/routes.mutations.test.js +38 -0
  114. package/server/lib/github/routes.test.js +1 -0
  115. package/server/lib/gitlab/DOCUMENTATION.md +4 -0
  116. package/server/lib/gitlab/client.js +23 -0
  117. package/server/lib/gitlab/client.test.js +28 -1
  118. package/server/lib/gitlab/mappers.js +9 -0
  119. package/server/lib/gitlab/resources.js +153 -4
  120. package/server/lib/gitlab/resources.test.js +107 -0
  121. package/server/lib/gitlab/routes.js +120 -1
  122. package/server/lib/gitlab/routes.test.js +59 -0
  123. package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
  124. package/server/lib/markdown-image-grants/routes.js +14 -2
  125. package/server/lib/markdown-image-grants/routes.test.js +23 -0
  126. package/server/lib/notifications/APNS.md +24 -23
  127. package/server/lib/notifications/DOCUMENTATION.md +2 -2
  128. package/server/lib/notifications/apns-runtime.js +8 -5
  129. package/server/lib/notifications/apns-runtime.test.js +26 -0
  130. package/server/lib/notifications/message.js +5 -3
  131. package/server/lib/notifications/message.test.js +9 -0
  132. package/server/lib/notifications/runtime.js +44 -9
  133. package/server/lib/notifications/trigger-runtime.test.js +84 -0
  134. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
  135. package/server/lib/openchamber-control/actions.js +18 -2
  136. package/server/lib/openchamber-control/project-knowledge.js +17 -3
  137. package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
  138. package/server/lib/openchamber-control/render-page.js +58 -0
  139. package/server/lib/openchamber-control/service.js +9 -0
  140. package/server/lib/openchamber-control/service.test.js +43 -0
  141. package/server/lib/openchamber-sessions/routes.js +1 -0
  142. package/server/lib/openchamber-sessions/worktree-move.js +26 -10
  143. package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
  144. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  145. package/server/lib/opencode/managed-config-file.js +3 -2
  146. package/server/lib/opencode/managed-config-file.test.js +20 -6
  147. package/server/lib/opencode/settings-helpers.js +3 -0
  148. package/server/lib/opencode/settings-helpers.test.js +1 -1
  149. package/server/lib/opencode/settings-registry.json +3 -0
  150. package/server/lib/opencode/settings-runtime.js +1 -0
  151. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  152. package/server/lib/project-context/plan-progress.js +69 -0
  153. package/server/lib/project-context/plan-progress.test.js +58 -0
  154. package/server/lib/project-context/routes.http.test.js +22 -0
  155. package/server/lib/project-context/routes.js +20 -0
  156. package/server/lib/project-context/runtime.js +132 -18
  157. package/server/lib/project-context/runtime.test.js +58 -0
  158. package/server/lib/provider-read-cache/index.js +7 -1
  159. package/server/lib/provider-read-cache/index.test.js +12 -0
  160. package/server/lib/relay/DOCUMENTATION.md +17 -1
  161. package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
  162. package/server/lib/session-knowledge/runtime.js +29 -6
  163. package/server/lib/session-knowledge/runtime.test.js +26 -1
  164. package/server/lib/source-control/audit-storage.js +1 -0
  165. package/server/lib/source-control/mutation-storage.js +3 -0
  166. package/server/lib/spaces/DOCUMENTATION.md +14 -9
  167. package/server/lib/spaces/code-out.js +13 -4
  168. package/server/lib/spaces/code-out.test.js +5 -3
  169. package/server/lib/spaces/dispatcher.js +12 -5
  170. package/server/lib/spaces/dispatcher.test.js +19 -1
  171. package/server/lib/spaces/gatekeeper-channel.js +8 -7
  172. package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
  173. package/server/lib/spaces/gatekeeper-program.cjs +38 -3
  174. package/server/lib/spaces/gatekeeper-program.test.js +20 -0
  175. package/server/lib/spaces/hardening.js +14 -1
  176. package/server/lib/spaces/hardening.test.js +5 -0
  177. package/server/lib/spaces/host-providers.js +165 -0
  178. package/server/lib/spaces/host-providers.test.js +100 -0
  179. package/server/lib/spaces/host.js +16 -4
  180. package/server/lib/spaces/journey.js +87 -17
  181. package/server/lib/spaces/journey.test.js +90 -2
  182. package/server/lib/spaces/layout.js +15 -5
  183. package/server/lib/spaces/places/docker-live-support.js +2 -0
  184. package/server/lib/spaces/places/docker.test.js +2 -0
  185. package/server/lib/spaces/places/fake-docker.js +3 -0
  186. package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
  187. package/server/lib/spaces/routes.js +9 -0
  188. package/server/lib/spaces/routes.test.js +4 -2
  189. package/server/lib/spaces/space-opencode.js +31 -14
  190. package/server/lib/spaces/space-opencode.test.js +15 -2
  191. package/server/lib/spaces/space-records.js +8 -0
  192. package/server/lib/spaces/space-records.test.js +7 -3
  193. package/server/lib/spaces/websocket.test.js +13 -1
  194. package/server/lib/ui-auth/ui-auth.js +28 -3
  195. package/server/lib/ui-auth/ui-auth.test.js +31 -0
  196. package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
  197. package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
  198. package/dist/assets/SettingsView-BolP_tuu.js +0 -30
  199. package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
  200. package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
  201. package/dist/assets/katex-rNcbfUj4.css +0 -1
  202. package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
  203. package/dist/assets/main-CVHM3_8W.js +0 -1048
  204. package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
  205. package/dist/assets/pl-Bj-Hy0X5.js +0 -20
  206. package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
  207. package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
  208. package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
  209. package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
  210. package/dist/assets/tr-qMRMBQ8r.js +0 -11
  211. package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
  212. package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
  213. package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
@@ -1,5 +1,5 @@
1
- import{R as i,r as de,j as t,f as zt}from"./vendor-react-BUCujlKS.js";import{u as ot,F as it,K as Lt,fe as wa,aG as Fr,eP as Dr,z as g,I as E,aL as $s,aM as Ws,ce as en,aN as Us,au as Ks,at as qs,an as Js,ao as Ys,ap as ns,aq as as,B as K,ff as ba,fg as va,t as mt,q as ht,D as ft,l as gt,E as vt,y as Br,T as is,U as os,V as ls,fh as ja,L as me,fi as Ca,fj as Sa,fk as Na,fl as ka,aO as Va,bz as Ra,bL as Ia,fm as Pa,fn as Fa,fo as Da,fp as Ba,fq as Ma,fr as Aa,fs as Oa,n as tn,bR as Ea,bP as Ta,bO as La,bQ as za,bJ as Ga,C as Ha,o as _s,ft as _a,fu as we,eS as $a,eX as Wa,fv as Ua,bS as Ka,az as qa,d$ as Ja,e2 as Ya,e3 as Qa,d5 as Xa,fw as Za,eN as ei,fx as ti,eW as si,e4 as ri,fy as ni,ay as ai,e0 as ii,fz as oi,eU as li,eA as Mr,ad as ts,eC as Ar,eB as Or,ev as ci,fA as ui,$ as di,fB as mi,av as hi,O as fi,fC as Er,eR as gi,fD as pi,fE as Tr,cy as xi,fF as yi,fG as wi,fH as bi,fI as Ls,fJ as vi,f1 as At,fK as Lr}from"./useAppFontEffects-Bih1DxXi.js";import{u as ji,b as Ci}from"./main-CVHM3_8W.js";import{c as Si,d as Ni,e as ki,Q as Vi,I as Ri,R as Ii,L as Pi,K as Fi,U as Di,V as zs,H as Bi,W as Mi,M as Ai,X as Oi,Y as Ei,Z as Ti}from"./runtimeEndpointReset-CIpvn8QG.js";import{u as zr}from"./vendor-zustand-BAGL70zf.js";import{l as Li,u as Et,aT as zi,n as De,_ as ut}from"./katex.min-DQ8qF6NR.js";import{R as Gi,I as Hi,C as _i,a as $i,b as Wi,D as Ui}from"./InProgressOperationBanner-DzGIwGH2.js";import{P as Ki}from"./PierreDiffViewer-DPa08AmN.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-CVhJ1Zpv.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.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-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BYGweLoh.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./useRootScrollLock-Cpk7NmBa.js";import"./moveWorkspacePath-CyZJ-2aD.js";import"./sessionOwnership-BZoGed9N.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./changesTree-CePHbFcj.js";import"./parseDiffFromFile-OHXXXyzL.js";import"./computeVirtualFileMetrics-CUof18z3.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-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.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"./vendor-diff-C3JhlQdm.js";import"./isDiffPlainText-DSCjvV0m.js";import"./pierreDiffTint-DHf2xvyt.js";import"./Virtualizer-CnU8pYMb.js";import"./useInlineCommentController-AuUrVz9U.js";import"./appThemeRegistry-BUY7Ge9i.js";import"./textMateThemeFromAppTheme-DcAZmUlv.js";const sn="gitmojiCache",qi=1e3*60*60*24*7,rn="1",Ji="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",nn=o=>{if(!o||typeof o!="object")return!1;const e=o;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Gs=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(sn);if(!o)return null;const e=JSON.parse(o);return!e||e.version!==rn||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(nn),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Yi=o=>{if(!(typeof window>"u"))try{const e={gitmojis:o,fetchedAt:Date.now(),version:rn};window.localStorage.setItem(sn,JSON.stringify(e))}catch{return}},Gr=o=>Date.now()-o.fetchedAt<qi;let ss=null;const Tt=new Set,Hr=async()=>{if(ss)return ss;const o=(async()=>{try{const e=await fetch(Ji);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const a=await e.json(),h=Array.isArray(a.gitmojis)?a.gitmojis.filter(nn):[];return Yi(h),Tt.forEach(x=>x(h)),h}catch(e){console.warn("Failed to load gitmoji list:",e);const a=[];return Tt.forEach(h=>h(a)),a}finally{ss=null}})();return ss=o,o},Qi=o=>{const[e,a]=i.useState(()=>o?Gs()?.gitmojis??[]:[]),[h,x]=i.useState(!1),d=i.useRef(o);d.current=o,i.useEffect(()=>{if(!o){Tt.delete(a),a([]),x(!1);return}const v=Gs();if(v&&(a(v.gitmojis),Gr(v)))return;Tt.add(a),x(!0);let f=!1;return Hr().finally(()=>{!f&&d.current&&x(!1)}),()=>{f=!0,Tt.delete(a)}},[o]);const p=i.useCallback(async()=>{if(!d.current)return[];if(e.length>0)return e;const v=Gs();return v&&Gr(v)?v.gitmojis:Hr()},[e]);return{gitmojis:e,isLoading:h,ensureLoaded:p}},jt=async(o,e)=>{const a=await Li(`/api/git/integrate/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){const h=await a.json().catch(()=>null);throw new Error(h?.error||`Git integrate request failed: ${a.statusText}`)}return a.json()};async function Ot(o){return jt("plan",o)}async function Xi(o){return jt("conflict-details",{tempWorktreePath:o})}async function Zi(o){return(await jt("cherry-pick-status",{tempWorktreePath:o})).inProgress}async function eo(o){return jt("run",{plan:o})}async function to(o){await jt("abort",{state:o})}async function so(o){return jt("continue",{state:o})}const ro=({repoRoot:o,sourceBranch:e,worktreeMetadata:a,localBranches:h,defaultTargetBranch:x,refreshKey:d,onRefresh:p,showHeader:v=!0})=>{const{t:f}=ot(),y=it(m=>m.currentSessionId),[B,M]=de.useState(!1),[k,G]=de.useState(""),S=de.useRef(null),L=de.useMemo(()=>Lt(h,k,m=>[m]),[h,k]),[R,b]=de.useState(x);de.useEffect(()=>{b(x)},[x]),de.useEffect(()=>{if(B){const m=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(m)}},[B]);const q=!!(o&&e&&R&&R!=="HEAD"&&e!==R),[j,F]=de.useState({kind:"idle"}),[V,P]=de.useState(!1),[z,ee]=de.useState([]),A=de.useMemo(()=>y?`openchamber.integrate.conflict:${y}`:null,[y]);de.useEffect(()=>{if(!A||typeof window>"u")return;const m=window.localStorage.getItem(A);if(!m)return;let c=!1;try{const I=JSON.parse(m);if(!I?.tempWorktreePath||I.repoRoot!==o){window.localStorage.removeItem(A);return}(async()=>{const T=await Zi(I.tempWorktreePath).catch(()=>!1);if(c)return;if(!T){window.localStorage.removeItem(A);return}const ne=await Xi(I.tempWorktreePath).catch(()=>null);c||ne&&F({kind:"conflict",state:I,details:ne})})()}catch{window.localStorage.removeItem(A)}return()=>{c=!0}},[A,o]),de.useEffect(()=>{if(!q){F({kind:"idle"});return}let m=!1;return F({kind:"loading"}),(async()=>{try{const c=await Ot({repoRoot:o,sourceBranch:e,targetBranch:R});if(m)return;if(F({kind:"ready",plan:c}),c.commits.length>0){const T=c.commits.slice(-50).reverse(),ne=await wa(o,T);m||(ee(ne),P(!1))}else m||(ee([]),P(!1))}catch{m||F({kind:"idle"})}})(),()=>{m=!0}},[q,o,e,R,d]);const r=de.useCallback(m=>{y&&it.getState().setWorktreeMetadata(y,{...a,createdFromBranch:m})},[y,a]),O=it(m=>m.openNewSessionDraft),J=de.useCallback(async m=>{const c=await Fr("git.integrate.cherrypick.resolve.visible",{current_commit:m.state.currentCommit,target_branch:m.state.targetBranch}),I=await Fr("git.integrate.cherrypick.resolve.instructions",{repo_root:m.state.repoRoot,temp_worktree_path:m.state.tempWorktreePath,source_branch:m.state.sourceBranch,target_branch:m.state.targetBranch,current_commit:m.state.currentCommit}),T=`Cherry-pick conflict context (JSON)
2
- ${JSON.stringify({repoRoot:m.state.repoRoot,tempWorktreePath:m.state.tempWorktreePath,sourceBranch:m.state.sourceBranch,targetBranch:m.state.targetBranch,currentCommit:m.state.currentCommit,remainingCommits:m.state.remainingCommits,statusPorcelain:m.details.statusPorcelain,unmergedFiles:m.details.unmergedFiles,currentPatchMeta:m.details.currentPatchMeta,currentPatch:m.details.currentPatch,diff:m.details.diff},null,2)}`;return{visibleText:c,instructionsText:I,payloadText:T}},[]),w=Dr(m=>m.setPendingInputText),H=Dr(m=>m.setPendingSyntheticParts),_=de.useCallback(async(m,c)=>{const I=await J(m);if(c){O({directoryOverride:m.state.tempWorktreePath,initialPrompt:I.visibleText,syntheticParts:[{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}]});return}if(!y){g.error(f("gitView.integrate.noActiveSession"),{description:f("gitView.integrate.noActiveSessionDescription")});return}w(I.visibleText,"replace"),H([{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}])},[y,J,O,w,H,f]),Y=de.useCallback(async()=>{if(j.kind==="ready"){if(j.plan.commits.length===0){g.message(f("gitView.integrate.noCommitsToMoveToast"));return}F({kind:"running",plan:j.plan});try{const m=await eo(j.plan);if(m.kind==="success"){g.success(f("gitView.integrate.commitsMovedToast"),{description:m.moved===1?f("gitView.integrate.commitsMovedDescriptionSingle",{count:m.moved,branch:j.plan.targetBranch}):f("gitView.integrate.commitsMovedDescriptionPlural",{count:m.moved,branch:j.plan.targetBranch})});const c=await Ot(j.plan);F({kind:"ready",plan:c}),p?.();return}m.kind==="conflict"&&(g.error(f("gitView.integrate.cherryPickConflictToast"),{description:f("gitView.integrate.cherryPickConflictDescription")}),F({kind:"conflict",state:m.state,details:m.details}),A&&typeof window<"u"&&window.localStorage.setItem(A,JSON.stringify(m.state)))}catch(m){const c=m instanceof Error?m.message:String(m);g.error(f("gitView.integrate.failedToMoveToast"),{description:c});const I=await Ot({repoRoot:o,sourceBranch:e,targetBranch:R}).catch(()=>null);F(I?{kind:"ready",plan:I}:{kind:"idle"})}}},[j,p,o,e,R,A,f]),te=de.useCallback(async()=>{if(j.kind==="conflict")try{await to(j.state),g.message(f("gitView.integrate.cherryPickAbortedToast")),A&&typeof window<"u"&&window.localStorage.removeItem(A)}finally{const m=await Ot({repoRoot:o,sourceBranch:e,targetBranch:R}).catch(()=>null);F(m?{kind:"ready",plan:m}:{kind:"idle"})}},[j,o,e,R,A,f]),he=de.useCallback(async()=>{if(j.kind==="conflict")try{const m=await so(j.state);if(m.kind==="success"){g.success(f("gitView.integrate.cherryPickFinishedToast"));const c=await Ot({repoRoot:o,sourceBranch:e,targetBranch:R}).catch(()=>null);F(c?{kind:"ready",plan:c}:{kind:"idle"}),A&&typeof window<"u"&&window.localStorage.removeItem(A),p?.();return}m.kind==="conflict"&&(F({kind:"conflict",state:m.state,details:m.details}),A&&typeof window<"u"&&window.localStorage.setItem(A,JSON.stringify(m.state)))}catch(m){const c=m instanceof Error?m.message:String(m);g.error(f("gitView.integrate.cherryPickContinueFailedToast"),{description:c})}},[j,o,e,R,p,A,f]);return!o||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[v?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(E,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:f("gitView.integrate.title")}),j.kind==="ready"&&j.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:f("gitView.integrate.toMoveCount",{count:j.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:j.kind==="loading"||j.kind==="running"?t.jsx(E,{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:f("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",R]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs($s,{open:B,onOpenChange:M,children:[t.jsx(Ws,{asChild:!0,children:t.jsxs("button",{type:"button",className:en({size:"default"}),children:[f("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:R}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Us,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(Ks,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(qs,{ref:S,placeholder:f("gitView.branch.searchPlaceholder"),value:k,onValueChange:G,onKeyDown:m=>m.stopPropagation()}),t.jsxs(Js,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Ys,{children:f("gitView.branch.empty")}),t.jsx(ns,{heading:f("gitView.branch.localBranches"),children:L.map(m=>t.jsx(as,{value:m,onSelect:()=>{b(m),r(m),M(!1),G("")},children:m},m))})]})]})})]}),j.kind==="ready"?t.jsx(K,{size:"sm",onClick:()=>{Y()},disabled:!q||j.plan.commits.length===0,children:f("gitView.integrate.move")}):j.kind==="loading"?t.jsx(K,{size:"sm",variant:"outline",disabled:!0,children:f("gitView.integrate.checking")}):j.kind==="running"?t.jsx(K,{size:"sm",variant:"outline",disabled:!0,children:f("gitView.integrate.moving")}):null]}),j.kind==="ready"&&j.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:f("gitView.integrate.noCommitsToMove")}),j.kind==="ready"&&j.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:[f("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",j.plan.commits.length,")"]})]}),z.length>0&&j.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>P(m=>!m),className:"typography-micro text-muted-foreground hover:text-foreground",children:f(V?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(V?z:z.slice(0,5)).map(m=>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:m.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:m.subject||m.sha})]},m.sha)),z.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:f("gitView.integrate.previewUnavailable")}),j.plan.commits.length>z.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f("gitView.integrate.showingFirstCommits",{count:z.length})})]})]}),j.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:f("gitView.integrate.conflictsInFiles",{count:j.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[f("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:j.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[j.details.unmergedFiles.slice(0,6).map(m=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:m},m)),j.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:f("gitView.integrate.moreFiles",{count:j.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(K,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{te()},children:f("gitView.operation.abort")}),t.jsxs(K,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!y,onClick:()=>{_({state:j.state,details:j.details},!1)},children:[t.jsx(E,{name:"sparkling",className:"size-3.5"}),f("gitView.integrate.currentSession")]}),t.jsxs(K,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{_({state:j.state,details:j.details},!0)},children:[t.jsx(E,{name:"sparkling",className:"size-3.5"}),f("gitView.integrate.newSession")]}),t.jsx(K,{size:"sm",className:"typography-meta",onClick:()=>{he()},children:f("gitView.operation.continue")})]})]})]})]})},no=({open:o,onOpenChange:e,directory:a,hasUncommittedChanges:h,hasStagedChanges:x=!1,uncommittedFileCount:d,onChanged:p})=>{const{t:v}=ot(),[f,y]=i.useState([]),[B,M]=i.useState(!1),[k,G]=i.useState(""),[S,L]=i.useState(""),[R,b]=i.useState(null),[q,j]=i.useState({}),F=i.useCallback(async()=>{if(a){M(!0);try{const r=await ba(a);y(r.stashes),j({})}catch(r){g.error(r instanceof Error?r.message:v("gitView.stashes.toast.loadFailed"))}finally{M(!1)}}},[a,v]);i.useEffect(()=>{o&&F()},[F,o]),i.useEffect(()=>{if(!o||!a||f.length===0)return;let r=!1;const O=f.map(J=>J.ref);return va(a,O).then(J=>{r||j(J.counts)}).catch(()=>{}),()=>{r=!0}},[a,o,f]);const V=i.useMemo(()=>Lt(f,k,r=>[r.message,r.ref,r.relativeTime]),[k,f]),P=i.useCallback(async r=>{await F(),await p?.(r)},[F,p]),z=async()=>{if(!(!a||R)){b("create");try{const r=await ja(a,{message:S.trim()||void 0});r.created?(g.success(v("gitView.stashes.toast.created")),L("")):g.info(v("gitView.stashes.toast.noChanges")),await P({affectsIndex:!!(r.created&&x)})}catch(r){g.error(r instanceof Error?r.message:v("gitView.stashes.toast.createFailed"))}finally{b(null)}}},ee=async(r,O)=>{if(!(!a||R)&&!(O==="drop"&&!window.confirm(v("gitView.stashes.confirm.drop",{ref:r.ref})))){b(`${O}:${r.ref}`);try{O==="apply"&&await Ca(a,{ref:r.ref}),O==="pop"&&await Sa(a,{ref:r.ref}),O==="drop"&&await Na(a,{ref:r.ref});const J=O==="apply"?"gitView.stashes.toast.applySuccess":O==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";g.success(v(J)),await P({affectsIndex:O!=="drop"})}catch(J){const w=O==="apply"?"gitView.stashes.toast.applyFailed":O==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";g.error(J instanceof Error?J.message:v(w)),await P({affectsIndex:O!=="drop"})}finally{b(null)}}},A=R!==null;return t.jsx(mt,{open:o,onOpenChange:e,children:t.jsxs(ht,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(ft,{children:[t.jsxs(gt,{className:"flex items-center gap-2",children:[t.jsx(E,{name:"archive-stack",className:"size-4 text-muted-foreground"}),v("gitView.stashes.title")]}),t.jsx(vt,{children:v("gitView.stashes.description")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(Br,{value:S,onChange:r=>L(r.target.value),placeholder:v("gitView.stashes.messagePlaceholder"),disabled:A||!h,className:"flex-1"}),t.jsxs(K,{onClick:z,disabled:!h||A||!a,children:[R==="create"?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"inbox-archive",className:"size-4"}),v("gitView.stashes.actions.stashCurrentWithCount",{count:d})]})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:v("gitView.stashes.includeUntrackedHint")})]}),t.jsx("div",{className:"-mx-5 border-t border-border/60"}),t.jsxs("div",{className:"relative",children:[t.jsx(E,{name:"search",className:"absolute inset-s-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(Br,{value:k,onChange:r=>G(r.target.value),placeholder:v("gitView.stashes.searchPlaceholder"),className:"ps-8"})]}),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(E,{name:"loader-4",className:"size-5 animate-spin"})}):V.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:v(k?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):V.map((r,O)=>t.jsxs("div",{className:"group -mx-2 flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-interactive-hover",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"typography-ui-label truncate text-foreground",children:r.message||v("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-micro truncate text-muted-foreground",children:[t.jsxs(is,{children:[t.jsx(os,{asChild:!0,children:t.jsx("span",{children:O===0&&!k.trim()?v("gitView.stashes.latestLabel"):v("gitView.stashes.itemNumber",{number:O+1})})}),t.jsx(ls,{sideOffset:6,children:r.ref})]})," · ",r.relativeTime," · ",typeof q[r.ref]=="number"?v("gitView.stashes.fileCount",{count:q[r.ref]}):v("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Hs,{label:v("gitView.stashes.actions.apply"),loading:R===`apply:${r.ref}`,onClick:()=>ee(r,"apply"),disabled:A,children:t.jsx(E,{name:"inbox-unarchive",className:"size-3.5"})}),t.jsx(Hs,{label:v("gitView.stashes.actions.pop"),loading:R===`pop:${r.ref}`,onClick:()=>ee(r,"pop"),disabled:A,children:t.jsx(E,{name:"inbox-unarchive-fill",className:"size-3.5"})}),t.jsx(Hs,{label:v("gitView.stashes.actions.drop"),loading:R===`drop:${r.ref}`,onClick:()=>ee(r,"drop"),disabled:A,destructive:!0,children:t.jsx(E,{name:"delete-bin",className:"size-3.5"})})]})]},r.ref))})]})})},Hs=o=>{const e=zt.c(17),{label:a,loading:h,disabled:x,destructive:d,onClick:p,children:v}=o,f=h||void 0,y=d?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let B;e[0]!==y?(B=me("flex size-6 items-center justify-center rounded-md transition-colors hover:bg-interactive-hover disabled:opacity-50",y),e[0]=y,e[1]=B):B=e[1];let M;e[2]!==v||e[3]!==h?(M=h?t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):v,e[2]=v,e[3]=h,e[4]=M):M=e[4];let k;e[5]!==x||e[6]!==a||e[7]!==p||e[8]!==f||e[9]!==B||e[10]!==M?(k=t.jsx(os,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":a,"aria-busy":f,className:B,onClick:p,disabled:x,children:M})}),e[5]=x,e[6]=a,e[7]=p,e[8]=f,e[9]=B,e[10]=M,e[11]=k):k=e[11];let G;e[12]!==a?(G=t.jsx(ls,{sideOffset:6,children:a}),e[12]=a,e[13]=G):G=e[13];let S;return e[14]!==k||e[15]!==G?(S=t.jsxs(is,{children:[k,G]}),e[14]=k,e[15]=G,e[16]=S):S=e[16],S},ao=o=>{const e=zt.c(16),{onOpenStashes:a}=o,{t:h}=ot();let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(E,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=x):x=e[0];let d;e[1]!==h?(d=h("gitView.empty.cleanTitle"),e[1]=h,e[2]=d):d=e[2];let p;e[3]!==d?(p=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:d}),e[3]=d,e[4]=p):p=e[4];let v;e[5]!==h?(v=h("gitView.empty.cleanDescription"),e[5]=h,e[6]=v):v=e[6];let f;e[7]!==v?(f=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:v}),e[7]=v,e[8]=f):f=e[8];let y;e[9]!==a||e[10]!==h?(y=a?t.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[t.jsx(E,{name:"archive-stack",className:"size-4"}),h("gitView.stashes.title")]}):null,e[9]=a,e[10]=h,e[11]=y):y=e[11];let B;return e[12]!==p||e[13]!==f||e[14]!==y?(B=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[x,p,f,y]}),e[12]=p,e[13]=f,e[14]=y,e[15]=B):B=e[15],B},at=8,io=o=>{const e=zt.c(18),{laned:a,totalLanes:h,isExpanded:x}=o,{lane:d,color:p,connectors:v}=a,y=Math.max(h,d+1)*at+at/2,B=i.useRef(null),M=i.useRef(null);let k;e[0]!==p||e[1]!==v||e[2]!==d||e[3]!==y?(k=()=>{const b=B.current,q=M.current;if(!b||!q)return;const j=b.offsetHeight;if(j===0)return;const F=window.devicePixelRatio||1;q.width=y*F,q.height=j*F;const V=q.getContext("2d");if(!V)return;V.scale(F,F),V.clearRect(0,0,y,j);const P=j/2,z=d*at+at/2,ee=getComputedStyle(q),A=ee.getPropertyValue("--surface-muted-foreground").trim()||ee.color,r=w=>{if(!w.startsWith("var("))return w;const H=w.slice(4,-1).trim();return ee.getPropertyValue(H).trim()||A},O=[...v].sort(lo);for(const w of O){const H=w.fromLane*at+at/2,_=w.toLane*at+at/2,Y=w.type==="passing"?.72:w.type==="branch-out"||w.type==="merge-in"?.95:1;V.beginPath(),V.strokeStyle=r(w.color),V.globalAlpha=Y,V.lineWidth=1.25,V.lineCap="round";e:switch(w.type){case"passing":case"commit-lane":{V.moveTo(H,0),V.lineTo(H,j);break e}case"top-stub":{V.moveTo(H,0),V.lineTo(H,P);break e}case"bottom-stub":{V.moveTo(H,P),V.lineTo(H,j);break e}case"branch-out":{const te=(P+j)/2;V.moveTo(z,P),V.bezierCurveTo(z,te,_,te,_,j);break e}case"merge-in":{const te=P/2;V.moveTo(H,0),V.bezierCurveTo(H,te,z,te,z,P);break e}default:continue}V.stroke(),V.globalAlpha=1}const J=ee.getPropertyValue("--background").trim()||ee.getPropertyValue("--surface-background").trim();V.beginPath(),V.arc(z,P,4,0,Math.PI*2),V.fillStyle=r(p),V.fill(),V.beginPath(),V.arc(z,P,5,0,Math.PI*2),V.strokeStyle=J||A,V.lineWidth=2,V.stroke()},e[0]=p,e[1]=v,e[2]=d,e[3]=y,e[4]=k):k=e[4];let G;e[5]!==p||e[6]!==v||e[7]!==x||e[8]!==d||e[9]!==a||e[10]!==h||e[11]!==y?(G=[a,d,p,v,h,x,y],e[5]=p,e[6]=v,e[7]=x,e[8]=d,e[9]=a,e[10]=h,e[11]=y,e[12]=G):G=e[12],i.useLayoutEffect(k,G);let S;e[13]!==y?(S={width:y,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=y,e[14]=S):S=e[14];let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx("canvas",{ref:M,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=L):L=e[15];let R;return e[16]!==S?(R=t.jsx("div",{ref:B,style:S,children:L}),e[16]=S,e[17]=R):R=e[17],R};function oo(o){return o==="branch-out"||o==="merge-in"}function lo(o,e){const a=oo;return(a(o.type)?1:0)-(a(e.type)?1:0)}const _r=15e3,$r=500,Wr=12,Ur=8*1024*1024,Kr=o=>typeof o=="string"?0:(o.original?.length??0)+(o.modified?.length??0),qr=o=>{if(o.size<=Wr){let x=0;for(const d of o.values())x+=Kr(d);if(x<=Ur)return o}const e=Array.from(o.entries()).reverse(),a=new Map;let h=0;for(const[x,d]of e){if(a.size>=Wr)continue;const p=Kr(d);h+p>Ur&&a.size>0||(a.set(x,d),h+=p)}return new Map(Array.from(a.entries()).reverse())};function Jr(o,e){const a=new Date(o);return Number.isNaN(a.getTime())?o:Ia(a,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function co(o){switch(o){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 uo(o){return o?o.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const a=e.startsWith("HEAD ->");return{label:a?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:a,isTag:e.startsWith("tag: ")}}):[]}const mo=i.memo(({entry:o,mode:e="history",laned:a,totalLanes:h,isExpanded:x,onToggle:d,files:p,isLoadingFiles:v,onCopyHash:f,directory:y,onConflict:B,onActionSuccess:M})=>{const{t:k}=ot(),G=Et(c=>c.timeFormatPreference),S=e==="graph",[L,R]=i.useState(null),[b,q]=i.useState(!1),[j,F]=i.useState(""),[V,P]=i.useState(null),[z,ee]=i.useState(new Set),[A,r]=i.useState(new Map),[O,J]=i.useState(new Set),w=async()=>{if(y){R("checkout");try{await Oa(y,o.hash),g.success(k("gitView.history.actions.detachedHead")),M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},H=async()=>{if(!(!y||!j.trim())){R("createBranch");try{await Pa(y,j.trim(),o.hash),q(!1),F(""),M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},_=async()=>{if(y){R("cherryPick");try{const c=await Aa(y,o.hash);c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"cherry-pick"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},Y=async()=>{if(y){R("revert");try{const c=await Ma(y,o.hash);c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"revert"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},te=async(c,I=!1)=>{if(!(!y||L!==null)){R("reset");try{await Fa(y,o.hash,c,I),M?.()}catch(T){g.error(String(T.message))}finally{R(null)}}},he=async()=>{if(!V)return;const c=V;switch(P(null),c){case"checkout":return w();case"cherryPick":return _();case"revert":return Y();case"merge":return se();case"rebase":return oe();case"resetSoft":return te("soft");case"resetMixed":return te("mixed");case"resetHard":return te("hard",!0)}},se=async()=>{if(y){R("merge");try{const c=await Ba(y,{branch:o.hash});c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"merge"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},oe=async()=>{if(y){R("rebase");try{const c=await Da(y,{onto:o.hash});c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"rebase"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},le=i.useCallback(async c=>{const I=c.path;if(!y){r(T=>new Map(T).set(I,"error"));return}r(T=>qr(new Map(T).set(I,"loading")));try{const T=ka(y,o.hash,c.path,!1),ne=new Promise((Z,$)=>{setTimeout(()=>$(new Error(`Timed out after ${_r}ms`)),_r)}),Q=await Promise.race([T,ne]);r(Z=>qr(new Map(Z).set(I,Q)))}catch{r(T=>new Map(T).set(I,"error"))}},[y,o.hash]),m=i.useCallback(async c=>{const I=c.path;if(c.changeType==="R"||c.isBinary){ee(Z=>{const $=new Set(Z);return $.has(I)?$.delete(I):$.add(I),$});return}const T=A.get(I);if(z.has(I)&&T&&T!=="error"){ee(Z=>{const $=new Set(Z);return $.delete(I),$});return}ee(Z=>{const $=new Set(Z);return $.add(I),$}),!(T&&T!=="error"||c.insertions+c.deletions>$r&&!O.has(I))&&await le(c)},[A,O,le,z]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:d,className:me("w-full flex items-start gap-3 px-3 py-2 text-start transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":x?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&a&&h!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(io,{laned:a,totalLanes:h,isExpanded:x})}):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:[S?(()=>{const c=uo(o.refs);return c.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:c.map(I=>t.jsx("span",{className:me("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",I.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":I.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:I.label},I.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:o.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:o.author_name,children:o.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:Jr(o.date,G),children:Jr(o.date,G)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:o.hash.slice(0,8)}),t.jsxs(is,{children:[t.jsx(os,{asChild:!0,children:t.jsx(K,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:c=>{c.stopPropagation(),f(o.hash)},children:t.jsx(E,{name:"file-copy",className:"size-3"})})}),t.jsx(ls,{sideOffset:8,children:k("gitView.history.copySha")})]})]})]})]}),x&&t.jsxs("div",{className:"px-3 pb-2 ps-8 border-t border-border/40",children:[S&&V?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:k(`gitView.history.actions.${V}Confirm`)}),t.jsxs(K,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:L!==null,onClick:c=>{c.stopPropagation(),he()},children:[L!==null?t.jsx(E,{name:"loader-4",className:"size-3 animate-spin me-1"}):null,k("gitView.history.actions.confirmButton")]}),t.jsx(K,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:L!==null,onClick:c=>{c.stopPropagation(),P(null)},children:k("gitView.history.actions.cancelButton")})]}):S?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("checkout")},children:k("gitView.history.actions.checkout")}),b?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:j,onChange:c=>F(c.target.value),onKeyDown:c=>{c.key==="Enter"&&H(),c.key==="Escape"&&(q(!1),F(""))},placeholder:k("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(K,{variant:"outline",size:"xs",className:"h-6",disabled:!j.trim()||L!==null,onClick:c=>{c.stopPropagation(),H()},children:[L==="createBranch"?t.jsx(E,{name:"loader-4",className:"size-3 animate-spin me-1"}):null,k("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(K,{variant:"outline",size:"xs",className:"h-6",onClick:c=>{c.stopPropagation(),q(!0)},children:k("gitView.history.actions.createBranch")}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("cherryPick")},children:k("gitView.history.actions.cherryPick")}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("revert")},children:k("gitView.history.actions.revert")}),t.jsxs($s,{children:[t.jsx(Ws,{asChild:!0,children:t.jsxs(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>c.stopPropagation(),children:[L==="reset"?t.jsx(E,{name:"loader-4",className:"size-3 animate-spin me-1"}):null,k("gitView.history.actions.reset")]})}),t.jsx(Us,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(c=>t.jsx(Va,{disabled:L!==null,onSelect:I=>{I.stopPropagation(),P(`reset${c.charAt(0).toUpperCase()+c.slice(1)}`)},children:k(`gitView.history.actions.reset${c.charAt(0).toUpperCase()+c.slice(1)}`)},c))})]}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("merge")},children:k("gitView.history.actions.merge")}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("rebase")},children:k("gitView.history.actions.rebase")})]}):null,v?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(E,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:k("gitView.history.loadingFiles")})]}):p.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:k("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:p.map(c=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>m(c),className:me("w-full flex items-center gap-2 typography-micro text-start cursor-pointer transition-colors rounded px-1",z.has(c.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:me("font-semibold w-3 text-center shrink-0",co(c.changeType)),children:c.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:c.path,children:c.path}),!c.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",c.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",c.deletions]})]}),c.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:k("gitView.history.binary")}),t.jsx(E,{name:z.has(c.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),z.has(c.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:c.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:k("gitView.history.renamedNoDiff")}):c.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:k("gitView.history.binaryNoDiff")}):(()=>{const I=c.insertions+c.deletions;if(!O.has(c.path)&&I>$r)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:k("gitView.history.largeDiffTitle",{count:I})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:k("gitView.history.largeDiffDescription")}),t.jsx(K,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{J(ne=>new Set(ne).add(c.path)),le(c)},children:k("gitView.history.renderDiffAnyway")})]});const T=A.get(c.path);return T==="loading"||T===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:k("gitView.history.loadingDiff")}):T==="error"?t.jsx("button",{type:"button",onClick:()=>m(c),className:"w-full text-start px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:k("gitView.history.diffError")}):t.jsx(Ki,{original:T.original,modified:T.modified,language:Ra(c.path)||"",fileName:c.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},c.path))})]})]})}),Yr=["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 rs(o){return Yr[o%Yr.length]}function ho(o){if(o.length===0)return[];const e=[],a=[];for(let h=0;h<o.length;h++){const x=o[h],d=[];for(let S=0;S<e.length;S++)e[S]===x.hash&&d.push(S);let p=d.length>0?d[0]:-1;if(p===-1){const S=e.indexOf(null);S!==-1?p=S:(p=e.length,e.push(null))}const v=d.slice(1),f=rs(p),y=e[p]===x.hash,B=x.parents.length>0;B?e[p]=x.parents[0]:e[p]=null;const M=[],k=new Set;for(let S=1;S<x.parents.length;S++){const L=x.parents[S],R=e.indexOf(L);if(R!==-1)M.push(R);else{const b=e.indexOf(null);if(b!==-1)e[b]=L,M.push(b),k.add(b);else{const q=e.length;e.push(L),M.push(q),k.add(q)}}}const G=[];y&&B?G.push({fromLane:p,toLane:p,color:f,type:"commit-lane"}):y&&!B?G.push({fromLane:p,toLane:p,color:f,type:"top-stub"}):!y&&B&&G.push({fromLane:p,toLane:p,color:f,type:"bottom-stub"});for(const S of v)G.push({fromLane:S,toLane:p,color:rs(S),type:"merge-in"}),e[S]=null;for(const S of M)G.push({fromLane:p,toLane:S,color:rs(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==p&&(k.has(S)||G.push({fromLane:S,toLane:S,color:rs(S),type:"passing"}));a.push({commit:x,lane:p,color:f,connectors:G})}return a}const fo=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],go=o=>{const e=zt.c(84),{mode:a,log:h,isLogLoading:x,logMaxCount:d,onLogMaxCountChange:p,expandedCommitHashes:v,onToggleCommit:f,commitFilesMap:y,loadingCommitHashes:B,onCopyHash:M,directory:k,showHeader:G,contentMaxHeightClassName:S,branchDivider:L,onConflict:R,onActionSuccess:b}=o,q=a===void 0?"history":a,j=G===void 0?!0:G,F=S===void 0?"max-h-[50vh]":S,V=L===void 0?null:L,{t:P}=ot(),[z,ee]=i.useState(!0),A=q==="graph";let r;e[0]!==A||e[1]!==h?(r=A&&h?ho(h.all):[],e[0]=A,e[1]=h,e[2]=r):r=e[2];const O=r;let J;e[3]!==O?(J=Math.max(1,...O.map(po)),e[3]=O,e[4]=J):J=e[4];const w=J;let H;e[5]!==O?(H=new Map(O.map(xo)),e[5]=O,e[6]=H):H=e[6];const _=H;if(!h)return null;const Y=V!==null&&V.insertBeforeIndex>0&&V.insertBeforeIndex<h.all.length,te=V!==null&&V.insertBeforeIndex===h.all.length,he=Y||te;let se;e[7]!==V||e[8]!==Y||e[9]!==te||e[10]!==h.all?(se=Y?h.all.slice(0,V.insertBeforeIndex):te?h.all:[],e[7]=V,e[8]=Y,e[9]=te,e[10]=h.all,e[11]=se):se=e[11];const oe=se;let le;if(e[12]!==V||e[13]!==y||e[14]!==F||e[15]!==k||e[16]!==v||e[17]!==Y||e[18]!==he||e[19]!==A||e[20]!==x||e[21]!==_||e[22]!==B||e[23]!==h.all||e[24]!==d||e[25]!==w||e[26]!==q||e[27]!==b||e[28]!==R||e[29]!==M||e[30]!==p||e[31]!==f||e[32]!==P||e[33]!==oe){const ce=Y?h.all.slice(V.insertBeforeIndex):[];let pe;e[35]!==V?.direction?(pe=V?.direction==="down"?t.jsx(E,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(E,{name:"arrow-up",className:"size-3.5"}),e[35]=V?.direction,e[36]=pe):pe=e[36];const Me=pe;let be;e[37]!==y||e[38]!==k||e[39]!==v||e[40]!==A||e[41]!==_||e[42]!==B||e[43]!==w||e[44]!==q||e[45]!==b||e[46]!==R||e[47]!==M||e[48]!==f?(be=Gt=>t.jsx("ul",{className:"divide-y divide-border/60",children:Gt.map(Ne=>t.jsx(mo,{entry:Ne,mode:q,laned:A?_.get(Ne.hash):void 0,totalLanes:A?w:void 0,isExpanded:v.has(Ne.hash),onToggle:()=>f(Ne.hash),files:y.get(Ne.hash)??[],isLoadingFiles:B.has(Ne.hash),onCopyHash:M,directory:k,onConflict:R,onActionSuccess:b},Ne.hash))}),e[37]=y,e[38]=k,e[39]=v,e[40]=A,e[41]=_,e[42]=B,e[43]=w,e[44]=q,e[45]=b,e[46]=R,e[47]=M,e[48]=f,e[49]=be):be=e[49];const Se=be;let ae;e[50]!==x||e[51]!==h.all.length||e[52]!==d||e[53]!==p||e[54]!==P?(ae=h.all.length>=d?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(K,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(d+25),disabled:x,className:"px-3 text-muted-foreground hover:text-foreground",children:x?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(E,{name:"loader-4",className:"size-3 animate-spin"}),P("gitView.history.loadingMore")]}):P("gitView.history.loadMore")})}):null,e[50]=x,e[51]=h.all.length,e[52]=d,e[53]=p,e[54]=P,e[55]=ae):ae=e[55];const He=ae;le=t.jsx(tn,{outerClassName:`min-h-0 ${F}`,className:"h-full w-full",children:h.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")})}):he&&V?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[oe.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:Se(oe)}):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:V.branchName,children:V.branchName}),Me]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),ce.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:Se(ce)}):null]}),He]}):t.jsxs(t.Fragment,{children:[Se(h.all),He]})}),e[12]=V,e[13]=y,e[14]=F,e[15]=k,e[16]=v,e[17]=Y,e[18]=he,e[19]=A,e[20]=x,e[21]=_,e[22]=B,e[23]=h.all,e[24]=d,e[25]=w,e[26]=q,e[27]=b,e[28]=R,e[29]=M,e[30]=p,e[31]=f,e[32]=P,e[33]=oe,e[34]=le}else le=e[34];const m=le;if(!j){if(he){let pe;return e[56]!==m?(pe=t.jsx("section",{className:"h-full min-h-0",children:m}),e[56]=m,e[57]=pe):pe=e[57],pe}let ce;return e[58]!==m?(ce=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:m}),e[58]=m,e[59]=ce):ce=e[59],ce}let c;e[60]!==P?(c=P("gitView.history.title"),e[60]=P,e[61]=c):c=e[61];let I;e[62]!==c?(I=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:c}),e[62]=c,e[63]=I):I=e[63];let T;e[64]!==x||e[65]!==z||e[66]!==d||e[67]!==p||e[68]!==P?(T=z&&t.jsx("div",{onClick:yo,onPointerDown:wo,children:t.jsxs(Ea,{value:String(d),onValueChange:ce=>p(Number(ce)),disabled:x,children:[t.jsx(Ta,{className:"w-auto",disabled:x,children:t.jsx(La,{placeholder:P("gitView.history.commitsPlaceholder")})}),t.jsx(za,{children:fo.map(ce=>t.jsx(Ga,{value:String(ce.value),children:P(ce.labelKey)},ce.value))})]})}),e[64]=x,e[65]=z,e[66]=d,e[67]=p,e[68]=P,e[69]=T):T=e[69];let ne;e[70]!==z?(ne=z?t.jsx(E,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(E,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=z,e[71]=ne):ne=e[71];let Q;e[72]!==T||e[73]!==ne?(Q=t.jsxs("div",{className:"flex items-center gap-2",children:[T,ne]}),e[72]=T,e[73]=ne,e[74]=Q):Q=e[74];let Z;e[75]!==I||e[76]!==Q?(Z=t.jsxs(Si,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[I,Q]}),e[75]=I,e[76]=Q,e[77]=Z):Z=e[77];let $;e[78]!==m?($=t.jsx(Ni,{children:m}),e[78]=m,e[79]=$):$=e[79];let Be;return e[80]!==z||e[81]!==Z||e[82]!==$?(Be=t.jsxs(ki,{open:z,onOpenChange:ee,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[Z,$]}),e[80]=z,e[81]=Z,e[82]=$,e[83]=Be):Be=e[83],Be};function po(o){return o.lane+1}function xo(o){return[o.commit.hash,o]}function yo(o){return o.stopPropagation()}function wo(o){return o.stopPropagation()}const bo=({open:o,onOpenChange:e,operation:a,targetBranch:h,onConfirm:x})=>{const{t:d}=ot(),[p,v]=i.useState(!0),[f,y]=i.useState(!1),B=d(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),M=async()=>{y(!0);try{await x(p),e(!1)}catch(G){const S=G instanceof Error?G.message:`Failed to ${a}`;g.error(S)}finally{y(!1)}},k=()=>{f||e(!1)};return t.jsx(mt,{open:o,onOpenChange:f?void 0:e,children:t.jsxs(ht,{className:"max-w-md",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(gt,{children:d("gitView.stash.title")})]}),t.jsx(vt,{children:d("gitView.stash.description",{operation:a})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:d("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:d("gitView.stash.stepStash")}),t.jsxs("li",{children:[d(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",d(a==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:h})]}),p&&t.jsx("li",{children:d("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(Ha,{checked:p,onChange:v,disabled:f,ariaLabel:d("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!f&&v(!p),children:d("gitView.stash.restoreAfterOperation",{operation:a})})]}),t.jsxs(_s,{className:"gap-2",children:[t.jsx(K,{variant:"ghost",size:"sm",onClick:k,disabled:f,children:d("gitView.common.cancel")}),t.jsx(K,{variant:"default",size:"sm",onClick:M,disabled:f,className:"gap-1.5",children:f?t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),d("gitView.common.processing")]}):d("gitView.stash.confirmButton",{operation:B})})]})]})})},vo=o=>{const e=zt.c(100),{currentBranch:a,localBranches:h,remoteBranches:x,onMerge:d,onRebase:p,disabled:v,isOperating:f,operationLogs:y,onOperationComplete:B,mode:M,defaultTargetBranch:k}=o,G=v===void 0?!1:v,S=f===void 0?!1:f,L=y===void 0?[]:y,R=M===void 0?"dialog":M,{t:b}=ot(),[q,j]=i.useState(!1),[F,V]=i.useState("merge"),[P,z]=i.useState(null),[ee,A]=i.useState(!1),[r,O]=i.useState(""),J=i.useRef(null),w=i.useRef(null),H=G||S,_=a||b("gitView.branch.currentBranchFallback"),Y=L.length>0&&L.every(jo),te=L.some(Co);let he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},e[0]=he):he=e[0],i.useEffect(he,[L]);let se;if(e[1]!==r||e[2]!==a||e[3]!==h){let X;e[5]!==a?(X=Re=>Re!==a,e[5]=a,e[6]=X):X=e[6];const fe=h.filter(X);se=Lt(fe,r,So),e[1]=r,e[2]=a,e[3]=h,e[4]=se}else se=e[4];const oe=se;let le;e[7]!==r||e[8]!==x?(le=Lt(x,r,No),e[7]=r,e[8]=x,e[9]=le):le=e[9];const m=le;let c;e[10]!==k||e[11]!==h||e[12]!==x?(c=()=>{if(!k)return null;const X=x.find(fe=>fe.label===k);return X||(h.includes(k)?{kind:"local",branch:k,label:k}:null)},e[10]=k,e[11]=h,e[12]=x,e[13]=c):c=e[13];const I=c;let T;e[14]!==I||e[15]!==j?(T=()=>{j(!0),z(I()),V("merge"),O("")},e[14]=I,e[15]=j,e[16]=T):T=e[16];const ne=T;let Q;e[17]===Symbol.for("react.memo_cache_sentinel")?(Q=X=>{z(X),A(!1),O("")},e[17]=Q):Q=e[17];const Z=Q;let $;e[18]!==d||e[19]!==p||e[20]!==F||e[21]!==P?($=()=>{P&&(F==="merge"?d(P):p(P))},e[18]=d,e[19]=p,e[20]=F,e[21]=P,e[22]=$):$=e[22];const Be=$;let ce;e[23]!==S||e[24]!==j?(ce=()=>{S||(z(null),V("merge"),O(""),j(!1))},e[23]=S,e[24]=j,e[25]=ce):ce=e[25];const pe=ce,Me=()=>{S&&!Y||(Y&&B?.(),z(null),V("merge"),O(""),j(!1))};let be,Se;e[26]!==ee?(be=()=>{ee||O("")},Se=[ee],e[26]=ee,e[27]=be,e[28]=Se):(be=e[27],Se=e[28]),i.useEffect(be,Se);let ae,He;e[29]!==R||e[30]!==I||e[31]!==P?(ae=()=>{R==="dialog"||P||z(I())},He=[R,I,P],e[29]=R,e[30]=I,e[31]=P,e[32]=ae,e[33]=He):(ae=e[32],He=e[33]),i.useEffect(ae,He);const Ae=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:w,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:L.map(ko)})}),Y?R==="dialog"?t.jsx(_s,{children:t.jsx(K,{variant:"default",size:"sm",onClick:Me,children:b(te?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(K,{variant:"default",size:"sm",onClick:Me,children:b(te?"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:b("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>V("merge"),className:me("flex flex-col items-start gap-1 rounded-lg border p-3 text-start transition-colors",F==="merge"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"git-merge",className:me("size-4",F==="merge"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:me("typography-ui-label",F==="merge"?"text-foreground":"text-muted-foreground"),children:b("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:b("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>V("rebase"),className:me("flex flex-col items-start gap-1 rounded-lg border p-3 text-start transition-colors",F==="rebase"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"git-branch",className:me("size-4",F==="rebase"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:me("typography-ui-label",F==="rebase"?"text-foreground":"text-muted-foreground"),children:b("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:b("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:F==="merge"?b("gitView.branch.branchToMergeInto",{branch:_}):b("gitView.branch.branchToRebaseOnto")}),t.jsxs($s,{open:ee,onOpenChange:A,modal:!1,children:[t.jsx(Ws,{asChild:!0,children:t.jsxs("button",{type:"button",className:me(en({size:"default"}),"w-full"),children:[t.jsx("span",{className:me("truncate",!P&&"text-muted-foreground"),children:P?.label||b("gitView.branch.selectBranch")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Us,{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(Ks,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(qs,{ref:J,placeholder:b("gitView.branch.searchPlaceholder"),value:r,onValueChange:O,onKeyDown:Vo}),t.jsxs(Js,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Ys,{children:b("gitView.branch.empty")}),oe.length>0&&t.jsx(ns,{heading:b("gitView.branch.localBranches"),children:oe.map(X=>t.jsx(as,{onSelect:()=>Z({kind:"local",branch:X,label:X}),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X})},`local-${X}`))}),oe.length>0&&m.length>0?t.jsx(_a,{}):null,m.length>0&&t.jsx(ns,{heading:b("gitView.branch.remoteBranches"),children:m.map(X=>t.jsx(as,{onSelect:()=>Z(X),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.label})},`remote-${X.label}`))})]})]})})]})]}),P?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:F==="merge"?t.jsxs(t.Fragment,{children:[b("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P.label})," ",b("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})]}):t.jsxs(t.Fragment,{children:[b("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})," ",b("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P.label})]})})}):null,R==="dialog"?t.jsxs(_s,{className:"gap-2 pt-1",children:[t.jsx(K,{variant:"ghost",size:"sm",onClick:pe,children:b("gitView.common.cancel")}),t.jsx(K,{variant:"default",size:"sm",onClick:Be,disabled:!P,className:"gap-1.5",children:F==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"git-merge",className:"size-4"}),b("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"git-branch",className:"size-4"}),b("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(K,{variant:"destructive",size:"sm",onClick:pe,disabled:H,children:b("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(K,{variant:"default",size:"sm",onClick:Be,disabled:H||!P,children:b(F==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(R==="bare")return Ae;if(R==="inline"){let X;e[34]!==b?(X=b("gitView.branch.updateTitle"),e[34]=b,e[35]=X):X=e[35];let fe;e[36]!==X?(fe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:X}),e[36]=X,e[37]=fe):fe=e[37];let Re;e[38]!==b?(Re=b("gitView.branch.updateDescriptionPrefix"),e[38]=b,e[39]=Re):Re=e[39];let ve;e[40]!==_?(ve=t.jsx("span",{className:"font-mono text-foreground",children:_}),e[40]=_,e[41]=ve):ve=e[41];let xe;e[42]!==Re||e[43]!==ve?(xe=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Re," ",ve,"."]}),e[42]=Re,e[43]=ve,e[44]=xe):xe=e[44];let Le;e[45]!==fe||e[46]!==xe?(Le=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[fe,xe]})}),e[45]=fe,e[46]=xe,e[47]=Le):Le=e[47];let je;e[48]!==Ae?(je=t.jsx("div",{className:"pt-3",children:Ae}),e[48]=Ae,e[49]=je):je=e[49];let qe;return e[50]!==Le||e[51]!==je?(qe=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[Le,je]}),e[50]=Le,e[51]=je,e[52]=qe):qe=e[52],qe}let Ye;e[53]!==S?(Ye=S?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"git-merge",className:"size-4"}),e[53]=S,e[54]=Ye):Ye=e[54];let ke;e[55]!==b?(ke=b("gitView.branch.mergeRebase"),e[55]=b,e[56]=ke):ke=e[56];let Oe;e[57]!==ke?(Oe=t.jsx("span",{children:ke}),e[57]=ke,e[58]=Oe):Oe=e[58];let W;e[59]!==ne||e[60]!==H||e[61]!==Ye||e[62]!==Oe?(W=t.jsx(os,{asChild:!0,children:t.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",onClick:ne,disabled:H,children:[Ye,Oe]})}),e[59]=ne,e[60]=H,e[61]=Ye,e[62]=Oe,e[63]=W):W=e[63];let Qe;e[64]!==b?(Qe=b("gitView.branch.mergeRebaseTooltip"),e[64]=b,e[65]=Qe):Qe=e[65];let _e;e[66]!==Qe?(_e=t.jsx(ls,{sideOffset:8,children:Qe}),e[66]=Qe,e[67]=_e):_e=e[67];let Xe;e[68]!==W||e[69]!==_e?(Xe=t.jsxs(is,{children:[W,_e]}),e[68]=W,e[69]=_e,e[70]=Xe):Xe=e[70];let Ee;e[71]!==Me||e[72]!==j?(Ee=X=>{X?j(!0):Me()},e[71]=Me,e[72]=j,e[73]=Ee):Ee=e[73];let Ze;e[74]!==b?(Ze=b("gitView.branch.updateTitle"),e[74]=b,e[75]=Ze):Ze=e[75];let Te;e[76]!==Ze?(Te=t.jsx(gt,{children:Ze}),e[76]=Ze,e[77]=Te):Te=e[77];let et;e[78]!==te||e[79]!==S||e[80]!==F||e[81]!==Y||e[82]!==b||e[83]!==_?(et=S?b(Y?te?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":F==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[b("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_}),"."]}),e[78]=te,e[79]=S,e[80]=F,e[81]=Y,e[82]=b,e[83]=_,e[84]=et):et=e[84];let $e;e[85]!==et?($e=t.jsx(vt,{children:et}),e[85]=et,e[86]=$e):$e=e[86];let We;e[87]!==Te||e[88]!==$e?(We=t.jsxs(ft,{children:[Te,$e]}),e[87]=Te,e[88]=$e,e[89]=We):We=e[89];let Ue;e[90]!==Ae||e[91]!==We?(Ue=t.jsxs(ht,{className:"max-w-md",children:[We,Ae]}),e[90]=Ae,e[91]=We,e[92]=Ue):Ue=e[92];let Ve;e[93]!==q||e[94]!==Ee||e[95]!==Ue?(Ve=t.jsx(mt,{open:q,onOpenChange:Ee,children:Ue}),e[93]=q,e[94]=Ee,e[95]=Ue,e[96]=Ve):Ve=e[96];let Ke;return e[97]!==Xe||e[98]!==Ve?(Ke=t.jsxs(t.Fragment,{children:[Xe,Ve]}),e[97]=Xe,e[98]=Ve,e[99]=Ke):Ke=e[99],Ke};function jo(o){return o.status==="done"||o.status==="error"}function Co(o){return o.status==="error"}function So(o){return[o]}function No(o){return[o.label,o.branch,o.remote]}function ko(o,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[o.status==="running"&&t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),o.status==="done"&&t.jsx(E,{name:"check",className:"size-3.5 text-success"}),o.status==="error"&&t.jsx(E,{name:"close",className:"size-3.5 text-destructive"}),o.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:me("typography-micro",o.status==="error"&&"text-destructive",o.status==="done"&&"text-muted-foreground",o.status==="running"&&"text-foreground",o.status==="pending"&&"text-muted-foreground/60"),children:o.message})]},e)}function Vo(o){return o.stopPropagation()}const Ro=/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/i,Io=(o,e)=>{const a=[...o].sort((h,x)=>x.length-h.length);return e.flatMap(h=>{const x=a.find(p=>h.startsWith(`${p}/`));if(!x)return[];const d=h.slice(x.length+1);return d?[{kind:"remote",branch:d,destinationRef:`refs/remotes/${x}/${d}`,label:h,remote:x,sourceRef:`refs/heads/${d}`}]:[]})},Po=async({directory:o,git:e,runPlannedFetch:a,target:h})=>{if(h.kind==="local")return h.branch;await a(h);const d=(await e.getGitLog(o,{to:h.destinationRef,maxCount:1})).latest?.hash.trim();if(!d||!Ro.test(d))throw new we("invalid-terminal-state");return d},Fo=({runMutation:o,onMutationComplete:e,onMutationError:a,onPathsComplete:h,scheduleFlush:x})=>{const d=[];let p=!1;return{enqueue:f=>{const y=d[d.length-1];if(y?.directory===f.directory&&y.direction===f.direction){f.paths.forEach(B=>y.paths.add(B));return}d.push(f)},flush:()=>{if(p)return;const f=d.shift();if(!f)return;p=!0;const y={directory:f.directory,direction:f.direction,paths:Array.from(f.paths),rollback:f.rollback};(async()=>{try{await o(y),e(y)}catch(B){a(y,B)}finally{h(y.paths),p=!1,d.length>0&&x()}})()},clear:()=>{d.length=0},size:()=>d.length,isRunning:()=>p}},Do=(o,e,a)=>$a(o,e,h=>zi(h)&&Wa(h,a)),Bo=(o,e,a,h)=>Ua(o,e,a,x=>({id:"local-config",name:x.userName,...x,color:"info",icon:"user"}),h),Mo=(o,e,a,h)=>{if(e){const x=a.filter(d=>e.startsWith(`${d}/`)&&e.length>d.length+1).sort((d,p)=>p.length-d.length)[0];if(x)return{remoteName:x,destinationRef:`refs/heads/${e.slice(x.length+1)}`}}return h?{remoteName:h,destinationRef:`refs/heads/${o}`}:null},Ao=15e3,Oo=40,Eo=20,To=2,Qr={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:"},Xr=(o,e)=>{const a=o.toLowerCase(),h=/^([a-z]+)(?:\(.*\))?!?:/,x=a.match(h);if(x){const v=x[1],f=Qr[v];if(f)return e.find(y=>y.code===f)||null}const d=a.split(" ")[0],p=Qr[d];return p&&e.find(v=>v.code===p)||null},Lo=20,dt=new Map,zo=(o,e)=>{if(dt.delete(o),dt.set(o,e),dt.size>Lo){const a=dt.keys().next().value;a!==void 0&&dt.delete(a)}},Zr=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Go=o=>{const e=o.working_dir?.trim(),a=o.index?.trim();return!!(e||a==="?")},nu=({isActive:o})=>{const{t:e}=ot(),{git:a,sourceControl:h,runtime:x}=Ka(),d=qa(),p=Vi(),[v,f]=i.useState(null),[y,B]=i.useState(null),M=it(s=>s.currentSessionId),k=it(s=>s.newSessionDraft),G=it(s=>s.setDraftBootstrapPendingDirectory),S=it(s=>s.worktreeMetadata),L=it(s=>s.availableWorktrees),R=De(d),b=i.useMemo(()=>{if(!R)return;const s=L.find(n=>De(n.path)===R);if(s)return s;for(const n of S.values())if(De(n.path)===R)return n},[L,R,S]),q=i.useMemo(()=>{if(M)return S.get(M)??b;if(k?.open)return b},[M,b,k?.open,S]),{profiles:j,globalIdentity:F,defaultGitIdentityId:V,loadProfiles:P,loadGlobalIdentity:z,loadDefaultGitIdentityId:ee}=Ri(zr(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),{rootIsGitRepo:A,gitDirectory:r,nestedRepos:O}=Ja(d??null,{enabled:o,recheckOnOpen:!0}),J=Ya(r??null),w=Qa(r??null),H=Ii({directory:r,branch:w?.current,chooseContributor:p.choose}),_=Pi(r,a,h),Y=Xa(s=>M?s.getAttachment(M):void 0),te=Y?Za(Y):[],he=Y&&!Y.degraded&&!Y.legacy?Y.worktreeRoot??void 0:void 0,se=ji(d,q,w?.current??void 0),oe=ei(r??null),le=ti(r??null),m=si(r??null),c=ri(r??null),I=ni(r??null),{setActiveDirectory:T,ensureAll:ne,fetchStatus:Q,fetchBranches:Z,fetchLog:$,setLogMaxCount:Be,fetchIdentity:ce,prefetchDiffs:pe,clearDiffCache:Me,moveStatusPathsOptimistically:be,restoreStatus:Se,bumpIndexRevision:ae,ensureNestedRepos:He,selectNestedRepo:Gt}=ai(zr(s=>({setActiveDirectory:s.setActiveDirectory,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,ensureNestedRepos:s.ensureNestedRepos,selectNestedRepo:s.selectNestedRepo}))),Ne=Et(s=>s.isMobile),Ae=Et(s=>s.openContextDiff),Ye=Et(s=>s.openContextSurface),[ke,Oe]=i.useState([]),W=ii(r,h,o),[Qe,_e]=i.useState(!1),Xe=i.useMemo(()=>{const s=W.read;return!s?.binding||W.status!=="ready"||s.binding.state==="bound"?null:oi(s.binding)?e("gitView.identity.configChanged"):e("gitView.context.needsAttention")},[W.read,W.status,e]),Ee=W.read?.binding?.remotes[0]?.name??W.read?.repository.remotes.find(s=>s.name==="origin")?.name??W.read?.repository.remotes[0]?.name??"",Ze=i.useCallback(s=>{const n=W.read?.repository.remotes.find(l=>l.name===Ee);return n?Fi(s,li(n.fetch.displayUrl)):{applicable:!0}},[W.read,Ee]),Te=Mr(s=>s.entries),et=Mr(s=>s.refreshIdentityAccounts),$e=ts(s=>s.beginActiveContextsLoad),We=ts(s=>s.commitActiveContexts),Ue=ts(s=>s.releaseActiveContexts),Ve=i.useId();i.useEffect(()=>{if(!o||!d)return;const s=W.scope.runtimeKey,n=$e(s,d,Ve);return We(s,d,Ve,n,W.contexts.filter(l=>Ar(Te[Or(l)],l).connected)),()=>{Ue(s,d,Ve)}},[$e,W.contexts,W.scope.runtimeKey,We,d,o,Ue,Te,Ve]);const Ke=W.contexts[0]??null,X=w?.current??null,fe=ts(s=>!X||!Ke||!Ar(Te[Or(Ke)],Ke).connected?null:ci(s.entries,Ke,X)),Re=Et(s=>s.navigateToDiff),ve=i.useRef(null),xe=i.useRef(null),Le=i.useRef(null),je=i.useRef(!0);i.useEffect(()=>()=>{je.current=!1},[]);const qe=i.useCallback(()=>{ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null)},[]),cs=i.useCallback(s=>{qe(),ve.current=window.setTimeout(()=>{ve.current=null,De(s)===De(r)&&Q(s,a,{silent:!0})},Ao)},[qe,r,Q,a]);i.useEffect(()=>qe,[qe]);const Qs=i.useCallback(()=>{xe.current!==null&&(window.clearTimeout(xe.current),xe.current=null)},[]),Ht=i.useCallback(()=>{xe.current===null&&(xe.current=window.setTimeout(()=>{xe.current=null,Le.current?.()},0))},[]),Xs=i.useCallback(async(s,n,l)=>{if(n==="stage"){if(a.stageGitFiles){await a.stageGitFiles(s,l);return}await Promise.all(l.map(u=>a.stageGitFile(s,u)));return}if(a.unstageGitFiles){await a.unstageGitFiles(s,l);return}await Promise.all(l.map(u=>a.unstageGitFile(s,u)))},[a]),tt=i.useMemo(()=>Fo({runMutation:({directory:s,direction:n,paths:l})=>Xs(s,n,l),onMutationComplete:({directory:s})=>{ae(s),cs(s)},onMutationError:({directory:s,direction:n,rollback:l},u)=>{l?.(),ae(s),cs(s);const N=e(n==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");g.error(u instanceof Error?u.message:N)},onPathsComplete:s=>{cr(n=>{const l=new Set(n);return s.forEach(u=>l.delete(u)),l})},scheduleFlush:Ht}),[ae,Xs,Ht,cs,e]);i.useEffect(()=>(Le.current=tt.flush,()=>{Le.current=null}),[tt]),i.useEffect(()=>()=>tt.clear(),[tt]),i.useEffect(()=>Qs,[Qs]),i.useEffect(()=>{if(!o)return;if(!d){f(null);return}const s=De(d)??d;f({directory:s,status:null});let n=!1,l=null;const u=async()=>{try{const N=await wi(d);if(n)return;f({directory:s,status:N.status}),N.status==="pending"&&(l=window.setTimeout(()=>{u()},500))}catch{n||f({directory:s,status:null})}};return u(),()=>{n=!0,l!==null&&window.clearTimeout(l)}},[o,d]);const Zs=De(k?.bootstrapPendingDirectory??null),an=!!(d&&Zs&&Zs===De(d)),on=ui(d??null),ye=De(d),us=v?.directory===ye?v.status:null,ds=!!(d&&(on||us==="pending"||an&&k?.pendingWorktreeRequestId)),er=!!(ye&&y?.directory===ye);i.useEffect(()=>{if(!ye)return;if(us==="failed"){G(null),B(n=>n?.directory===ye?null:n);return}if(ds){B(n=>n?.directory===ye&&n.status==="refreshing"?n:{directory:ye,status:"refreshing"});return}if(y?.directory!==ye||y.status!=="refreshing"||!r||!a)return;let s=!1;return Q(r,a,{force:!0,silent:!0,throwOnError:!0}).then(()=>{s||B(n=>n?.directory===ye?null:n)}).catch(()=>{s||B(n=>n?.directory===ye?{...n,status:"failed"}:n)}),()=>{s=!0}},[Q,a,r,ds,ye,us,y,G]);const ln=ds||er,ms=er&&y?.status==="failed",tr=i.useMemo(()=>r?dt.get(r)??null:null,[r]),Ct=di(s=>s.settingsGitmojiEnabled),[St,hs]=i.useState(null),{gitmojis:pt}=Qi(Ct);i.useEffect(()=>{const s=he||se?.projectDirectory;if(!s){hs(null);return}let n=!1;return mi(s).then(l=>{if(n)return;const u=l.trim();hs(u&&u!=="HEAD"?u:null)}).catch(()=>{n||hs(null)}),()=>{n=!0}},[he,se?.projectDirectory]);const[Nt,xt]=i.useState(tr?.commitMessage??""),[sr,cn]=i.useState([]),[un,fs]=i.useState(!1),rr=i.useRef(null),[nr,_t]=i.useState(null),[dn,gs]=i.useState(!1),[ar,ir]=i.useState(null),[Ie,mn]=i.useState(25),[hn,or]=i.useState(!1),{triggerFireworks:fn}=Ci(),lr=i.useRef(new Map),$t=i.useRef(0),ps=i.useCallback(()=>{$t.current+=1,je.current&&or(!0)},[]),xs=i.useCallback(()=>{$t.current=Math.max(0,$t.current-1),je.current&&$t.current===0&&or(!1)},[]),[ys,Wt]=i.useState(new Set),[gn,cr]=i.useState(new Set),[ws,ur]=i.useState(!1),[pn,xn]=i.useState(0),[yn,dr]=i.useState(!1),[bs,vs]=i.useState(tr?.generatedHighlights??[]),wn=gn.size>0||tt.size()>0||tt.isRunning(),mr=i.useCallback(()=>{const s=rr.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),js=he||se?.projectDirectory||null,Cs=w?.current||null,bn=i.useMemo(()=>{const s=w?.tracking;return s?s.startsWith("origin/"):!0},[w?.tracking]),hr=i.useMemo(()=>{const s=se?.createdFromBranch,n=typeof s=="string"?s.trim():"",l=typeof w?.current=="string"?w.current.trim():"",u=typeof St=="string"?St.trim():"";return n?n===l&&n.startsWith("opencode/")&&u.length>0&&u!==n?u:n:u||l||"HEAD"},[se?.createdFromBranch,w,St]),Ut=i.useCallback(()=>{vs([])},[]),[Ss,vn]=i.useState(new Set),[Kt,jn]=i.useState(new Map),[qt,Ns]=i.useState(new Set),ks=i.useRef(Kt),kt=i.useRef(qt),[Cn,yt]=i.useState(null),[fr,gr]=i.useState(""),[ge,Jt]=i.useState(null),[Sn,pr]=i.useState(!1),[Nn,xr]=i.useState(!1),[kn,yr]=i.useState(null),[wr,br]=i.useState(null),[Vn,Yt]=i.useState([]),[Rn,wt]=i.useState(!1),[In,Vt]=i.useState([]),[Qt,Rt]=i.useState("merge"),[Pn,Vs]=i.useState(null),[Rs,vr]=i.useState(!1),[Is,Fn]=i.useState(100),[Dn,Bn]=i.useState(0),Pe=i.useMemo(()=>M?`openchamber.conflict:${M}`:null,[M]),jr=i.useCallback((s,n,l)=>{if(!Pe||typeof window>"u")return;const u={directory:s,conflictFiles:n,operation:l};window.localStorage.setItem(Pe,JSON.stringify(u))},[Pe]),Fe=i.useCallback(()=>{!Pe||typeof window>"u"||window.localStorage.removeItem(Pe)},[Pe]),Je=i.useCallback((s,n)=>{Vt(s),Rt(n),wt(!0),r&&jr(r,s,n)},[r,jr]);i.useEffect(()=>{if(!Pe||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Pe);if(s)try{const n=JSON.parse(s);if(n.directory!==r){window.localStorage.removeItem(Pe);return}Vt(n.conflictFiles??[]),Rt(n.operation??"merge"),wt(!0)}catch{window.localStorage.removeItem(Pe)}},[Pe,r]);const[Mn,Cr]=i.useState(!1),[Xt,It]=i.useState(null),[Ps,An]=i.useState("merge"),[Fs,On]=i.useState(""),[Ds,En]=i.useState(""),Tn=i.useCallback(s=>{hi(s).then(n=>{if(n.ok){g.success(e("gitView.toast.commitHashCopied"));return}g.error(e("gitView.toast.copyFailed"))})},[e]),Ln=i.useCallback(s=>{vn(n=>{const l=new Set(n);return l.has(s)?l.delete(s):l.add(s),l})},[]);i.useEffect(()=>{ks.current=Kt},[Kt]),i.useEffect(()=>{kt.current=qt},[qt]),i.useEffect(()=>{if(!r||!a)return;const s=Array.from(Ss).filter(l=>!ks.current.has(l)&&!kt.current.has(l));if(s.length===0)return;let n=!1;return Ns(l=>{const u=new Set(l);for(const N of s)u.add(N);return kt.current=u,u}),Promise.all(s.map(l=>a.getCommitFiles(r,l).then(u=>({hash:l,files:u.files})).catch(u=>(console.error("Failed to fetch commit files:",u),{hash:l,files:[]})))).then(l=>{n||(jn(u=>{const N=new Map(u);for(const{hash:C,files:D}of l)N.set(C,D);return ks.current=N,N}),Ns(u=>{const N=new Set(u);for(const{hash:C}of l)N.delete(C);return kt.current=N,N}))}),()=>{n=!0,Ns(l=>{let u=!1;const N=new Set(l);for(const C of s)N.delete(C)&&(u=!0);return u?(kt.current=N,N):l})}},[Ss,r,a]),i.useEffect(()=>{if(!r)return;const s=dt.get(r)??null;xt(s?.commitMessage??""),vs(s?.generatedHighlights??[])},[r]),i.useEffect(()=>{r&&zo(r,{directory:r,commitMessage:Nt,generatedHighlights:bs})},[Nt,r,bs]),i.useEffect(()=>{o&&(P(),z(),ee())},[o,P,z,ee]);const Zt=i.useCallback(async()=>{if(!r||!a?.getRemotes||J!==!0){Oe([]);return}try{const s=await a.getRemotes(r);je.current&&Oe(s)}catch{je.current&&Oe([])}},[r,a,J]);i.useEffect(()=>{o&&Zt()},[o,Zt]),i.useEffect(()=>{o&&d&&r&&(T(d),ne(r,a))},[o,d,r,T,ne,a]),i.useEffect(()=>{if(o&&r)return fi.onGitRefreshHint(s=>{De(s.directory)===De(r)&&(s.paths?.length&&Me(r,s.paths),Q(r,a,{silent:!0}))})},[o,Me,r,Q,a]);const re=i.useCallback(async(s=!0)=>{if(r)try{await Promise.all([Q(r,a),Z(r,a)])}catch(n){if(s){const l=n instanceof Error?n.message:e("gitView.toast.refreshRepositoryFailed");g.error(l)}}},[r,a,Q,Z,e]),ue=i.useCallback(async()=>{r&&await $(r,a,Ie)},[r,a,$,Ie]),lt=i.useCallback(async s=>{if(!r)return;const n=Promise.allSettled([Z(r,a),ue()]);s&&n.then(s),await Q(r,a).catch(()=>{})},[r,a,Z,Q,ue]),Bs=i.useCallback(async()=>{r&&await ce(r,a)},[r,a,ce]);i.useEffect(()=>{if(!o||!r||!a?.hasLocalIdentity||J!==!0)return;const s=typeof V=="string"?V.trim():"";if(!s||s==="global")return;const n=ut(),l=JSON.stringify([n,r]);if(lr.current.get(l)===s)return;let N=!1,C=!1;return(async()=>{try{const U=await a.hasLocalIdentity?.(r);if(N||ut()!==n||U===!0||(ps(),C=!0,await a.setGitIdentity(r,s),N||ut()!==n))return;lr.current.set(l,s),await Bs()}catch(U){!N&&ut()===n&&console.warn("Failed to auto-apply default git identity:",U)}finally{C&&xs()}})(),()=>{N=!0}},[o,ps,r,V,xs,a,J,Bs]);const st=i.useMemo(()=>w?[...w.files??[]].sort((n,l)=>n.path.localeCompare(l.path)):[],[w]),Ce=i.useMemo(()=>st.filter(Zr),[st]),Ms=i.useMemo(()=>st.filter(Go),[st]);i.useEffect(()=>{if(!o||!r||st.length===0)return;const s=[],n=new Set,l=N=>{!N||n.has(N)||(n.add(N),s.push(N))};if(Ce.forEach(N=>l(N.path)),sr.forEach(l),st.slice(0,Eo).forEach(N=>l(N.path)),s.length===0)return;const u=window.setTimeout(()=>{pe(r,a,s,{maxFiles:Oo})},120);return()=>{window.clearTimeout(u)}},[o,st,r,a,pe,Ce,sr]);const Pt=async(s,n,l=!1)=>{if(!r)return;const u=_.start();if(!u)return;_t(s);const N=e(s==="fetch"?"gitView.sync.fetch":s==="pull"?"gitView.sync.pull":s==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let C=null;try{if(s==="sync"||s==="publish"){const D=await H.prepare(s==="publish"?"push":"sync",{forceChoose:l,onOperation:u.onOperation});C=vi(await D())}else if(n&&w)await Tr({action:s,directory:r,remoteName:n.name,status:w,sourceControl:h,git:a,onOperation:u.onOperation});else throw new we("tracking-required");if(!u.isCurrent())return;s==="fetch"&&n?g.success(e("gitView.toast.fetchedFromRemote",{name:n.name})):s==="pull"&&n?g.success(e("gitView.toast.pulledFromRemote",{name:n.name})):s==="sync"?g.success(C?.kind==="up-to-date"?e("gitView.toast.alreadyUpToDate"):C?.kind==="pulled"?e("gitView.toast.pulledFromRemote",{name:C.remoteName}):C?.kind==="pushed"?e("gitView.toast.pushedToUpstream",{name:C.remoteName}):e("gitView.toast.syncedChanges")):s==="publish"&&g.success(e("gitView.publish.succeeded")),await lt()}catch(D){if(D instanceof At||D instanceof Lr){if(D instanceof At&&D.read.availability==="available"&&g.error(e("gitView.toast.syncActionFailed",{action:N}),{description:D.message||void 0}),u.isCurrent()&&await lt(),u.isCurrent()&&D instanceof At&&D.read.availability==="available"&&D.read.operation.state==="conflicted"&&D.read.operation.error.code==="CONFLICT"){const Ge=((await a.getGitStatus(r).catch(()=>null))?.files??[]).filter(zs).map(ya=>ya.path);Ge.length>0&&Je(Ge,"merge")}return}if(D instanceof we&&D.code==="stale-runtime")return;if(D instanceof we&&H.errorMessage(D)){g.info(H.errorMessage(D));return}await lt();const U=D instanceof we?D.code==="contributor-publish-cancelled-after-update"?e("gitView.toast.contributorPublishCancelledAfterUpdate"):D.code==="contributor-publish-cancelled"?e("gitView.toast.contributorPublishCancelled"):e("gitView.toast.syncActionFailed",{action:N}):D instanceof Error?D.message:e("gitView.toast.syncActionFailed",{action:N});g.error(U)}finally{u.finish(),u.isCurrent()&&_t(null)}},zn=i.useCallback(async s=>{if(!r)return;const n=s.name.trim();if(!n){g.error(e("gitView.toast.remoteNameRequired"));return}if(n==="origin"){g.error(e("gitView.toast.cannotRemoveOriginRemote"));return}yr(n);try{await a.removeRemote(r,{remote:n}),g.success(e("gitView.toast.removedRemote",{name:n})),await Promise.all([re(!1),Zt()])}catch(l){const u=l instanceof Error?l.message:`Failed to remove ${n}`;g.error(u)}finally{yr(null)}},[r,a,Zt,re,e]),Sr=async(s={})=>{if(!r)return;if(!Nt.trim()){g.error(e("gitView.toast.enterCommitMessage"));return}const n=Ce.map(C=>C.path).sort();if(n.length===0){g.error(e("gitView.toast.stageFileToCommit"));return}const l=s.pushAfter?"commitAndPush":"commit";ir(l);let u=null,N="pending";try{if(await a.createGitCommit(r,Nt.trim(),{files:n,stageFiles:[]}),N="local",ae(r),ae(r),g.success(e("gitView.toast.commitCreated")),xt(""),Ut(),s.pushAfter){if(u=_.start(),!u){g.warning(e("gitView.publish.commitKept")),await lt();return}const C=await H.prepare("push",{onOperation:u.onOperation});_t("publish"),await C(),N="published",g.success(e("gitView.publish.succeeded")),fn()}await lt(()=>xn(C=>C+1))}catch(C){if(s.pushAfter&&N==="local"&&g.warning(e("gitView.publish.commitKept")),C instanceof At||C instanceof Lr){C instanceof At&&C.read.availability==="available"&&g.error(e("gitView.toast.pushFailed"),{description:C.message||void 0}),await lt();return}if(C instanceof we&&C.code==="stale-runtime")return;if(C instanceof we&&H.errorMessage(C)){g.info(H.errorMessage(C));return}s.pushAfter&&await lt();const D=C instanceof we?C.code==="contributor-publish-cancelled-after-update"?e("gitView.toast.contributorPublishCancelledAfterUpdate"):C.code==="contributor-publish-cancelled"?e("gitView.toast.contributorPublishCancelled"):e("gitView.toast.syncActionFailed",{action:e("gitView.sync.syncChanges")}):C instanceof Error?C.message:e("gitView.toast.createCommitFailed");g.error(D)}finally{u?.finish(),ir(null),s.pushAfter&&_t(null)}},Gn=i.useCallback(async()=>{if(!r)return;const s=Ce.map(n=>n.path).sort();if(s.length===0){g.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),dr(!0);try{const{message:n}=await Er(r,s),l=n.subject?.trim()??"",u=Array.isArray(n.highlights)?n.highlights:[];if(l){let N=l;if(Ct&&pt.length>0){const C=Xr(l,pt);if(C){const{code:D,emoji:U}=C;!l.startsWith(D)&&!l.startsWith(U)&&(N=`${D} ${l}`)}}xt(N)}vs(u),mr()}catch(n){console.error("[git-generation][browser] GitView generate handler failed",{message:n instanceof Error?n.message:String(n),error:n});const l=n instanceof Error?n.message:e("gitView.toast.generateCommitMessageFailed");g.error(l)}finally{dr(!1)}},[r,Ce,Ct,pt,mr,e]),As=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",Hn=async s=>{if(!r||!w)return;const n=Ls(Y);if(n.length>0){g.error(e("gitView.toast.cannotCreateBranch",{reason:As(n[0])}));return}const l=w.current??null;try{await a.createBranch(r,s,l??"HEAD"),g.success(e("gitView.toast.createdBranch",{name:s})),await a.checkoutBranch(r,s),await re(),await ue()}catch(u){if(u instanceof we&&u.code==="stale-runtime")return;const N=u instanceof Error?u.message:e("gitView.toast.createBranchFailed");throw g.error(N),u}},_n=async(s,n)=>{if(!r)return;const l=Ls(Y);if(l.length>0){g.error(e("gitView.toast.cannotRenameBranch",{reason:As(l[0])}));return}try{await a.renameBranch(r,s,n),g.success(e("gitView.toast.renamedBranch",{oldName:s,newName:n})),await re(),await ue()}catch(u){const N=u instanceof Error?u.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:n});g.error(N)}},$n=async s=>{if(!r)return;const n=Ls(Y);if(n.length>0){g.error(e("gitView.toast.cannotCheckout",{reason:As(n[0])}));return}const l=s.replace(/^remotes\//,"");if(w?.current!==l){if((w?.files?.length??0)>0){It(l);return}await Os(l)}},Os=async s=>{if(!r)return;const n=s;try{const l=await a.checkoutBranch(r,n);g.success(e("gitView.toast.checkedOut",{name:l?.branch||n})),await re(),await ue()}catch(l){const u=l instanceof Error?l.message:e("gitView.toast.checkoutFailed",{name:n});g.error(u)}},Wn=async s=>{if(!r)return;const n=ut();ps();try{const l=await Ti({directory:r,identity:s,remoteName:Ee||null},{git:a,sourceControl:h});if(ut()!==n)return;l.status==="failed"?g.error(e("gitView.toast.applyIdentityFailed")):g.success(e("gitView.toast.appliedIdentity",{name:bi(s,e)})),await Bs()}catch(l){if(ut()!==n)return;const u=l instanceof Error?l.message:e("gitView.toast.applyIdentityFailed");g.error(u)}finally{xs()}},Ft=i.useMemo(()=>oe?.all?oe.all.filter(s=>!s.startsWith("remotes/")).sort():[],[oe]),Dt=i.useMemo(()=>oe?.all?oe.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[oe]),Un=i.useMemo(()=>Io(ke.map(s=>s.name),Dt),[ke,Dt]),rt=w?.current??null,Nr=i.useMemo(()=>{const s=W.contexts[0]?.primaryRemote;return s?oe?.defaultBranches?.[s]:void 0},[W.contexts,oe]),ct=i.useMemo(()=>Di({remoteNames:new Set(W.contexts[0]?.primaryRemote?[W.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(W.read?.repository.remotes.map(s=>s.name)??[]),localBranches:Ft,worktreeCreatedFromBranch:se?.createdFromBranch,rootBranchHint:St,defaultBranch:Nr,headBranch:rt,fallbackToConventional:!1}),[rt,Nr,W.contexts,Ft,W.read,St,se?.createdFromBranch]),Kn=i.useMemo(()=>{const s=W.contexts[0]?.primaryRemote,n=s?`${s}/${ct}`:null;return n&&Dt.includes(n)?n:ct},[ct,W.contexts,Dt]),kr=gi(),qn=i.useMemo(()=>Do(j,F,kr),[j,F,kr]),Vr=W.read?W.read.binding?.providers.find(s=>s.readiness==="ready")?.accountId??null:void 0,Jn=i.useMemo(()=>Bo(j,F,m,Vr),[Vr,m,j,F]),Yn=Ce.length,Qn=c||nr!==null||ar!==null,Xn=!!(se&&js&&Cs&&bn),Rr=!!rt,nt=Xn&&js&&Cs&&se?{repoRoot:js,sourceBranch:Cs,worktreeMetadata:se}:null;i.useEffect(()=>{if(!r||!a||!le?.all?.length||!rt||!ct||rt===ct){yt(null);return}let s=!1;return(async()=>{try{const l=await a.getGitLog(r,{from:ct,to:"HEAD",maxCount:Ie});if(s)return;const u=new Set((l?.all??[]).map(C=>C.hash).filter(C=>typeof C=="string"&&C.length>0));if(u.size===0){yt(null);return}const N=le.all.findIndex(C=>!u.has(C.hash));if(N===0){yt(null);return}if(N===-1){yt({insertBeforeIndex:le.all.length,branchName:rt,direction:"up"});return}yt({insertBeforeIndex:N,branchName:rt,direction:"up"})}catch{s||yt(null)}})(),()=>{s=!0}},[ct,rt,r,a,le,Ie]),i.useEffect(()=>{Vs(null)},[r]),i.useEffect(()=>{if(ge!=="graph"||!r){ge!=="graph"&&Vs(null);return}let s=!1;return vr(!0),a.getGitLog(r,{maxCount:Is,all:!0}).then(n=>{s||Vs(n)}).catch(n=>{console.error("Failed to fetch graph log:",n)}).finally(()=>{s||vr(!1)}),()=>{s=!0}},[ge,r,Is,Dn,a]);const Bt=i.useCallback((s,n)=>{if(!r||s.length===0)return;const l=Array.from(new Set(s));cr(N=>{const C=new Set(N);return l.forEach(D=>C.add(D)),C});const u=be(r,l,n);tt.enqueue({directory:r,direction:n,paths:new Set(l),rollback:()=>Se(r,u)}),Ht()},[r,tt,be,Se,Ht]),Es=i.useCallback(async s=>{if(r){Wt(n=>{const l=new Set(n);return l.add(s),l});try{await a.revertGitFile(r,s,{scope:"working"}),g.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(n){const l=n instanceof Error?n.message:e("gitView.toast.revertFailed");g.error(l)}finally{Wt(n=>{const l=new Set(n);return l.delete(s),l})}}},[r,re,a,e]),Mt=i.useCallback(async(s,n,l="all")=>{if(!r||s.length===0)return;const u=Array.from(new Set(s));if(ws||u.some(U=>ys.has(U)))return;const N=new Set(Ce.map(U=>U.path)),C=l==="all"&&u.some(U=>N.has(U));n&&ur(!0),Wt(U=>{const ie=new Set(U);return u.forEach(Ge=>ie.add(Ge)),ie});const D=[];try{if(await pi(u,To,async U=>{try{await a.revertGitFile(r,U,{scope:l})}catch(ie){D.push({path:U,message:ie instanceof Error?ie.message:e("gitView.toast.revertFailed")})}}),C&&D.length<u.length&&ae(r),await re(!1),D.length===0)g.success(u.length===1?e("gitView.toast.revertedFilesSingle",{count:u.length}):e("gitView.toast.revertedFilesPlural",{count:u.length}));else if(D.length===u.length)g.error(D[0]?.message||e("gitView.toast.revertFailed"));else{const U=u.length-D.length;g.warning(U===1?e("gitView.toast.revertedSomeSingle",{success:U,failed:D.length}):e("gitView.toast.revertedSomePlural",{success:U,failed:D.length}))}}finally{Wt(U=>{const ie=new Set(U);return u.forEach(Ge=>ie.delete(Ge)),ie}),n&&ur(!1)}},[ae,r,a,ws,re,ys,Ce,e]),Zn=i.useCallback(async s=>{await Mt(s,!0)},[Mt]),ea=i.useCallback(async s=>{await Mt(s,!1,"working")},[Mt]),Ts=i.useCallback((s,n)=>{if(d&&!Ne){Ae(d,s,n);return}Re(s,n)},[d,Ne,Re,Ae]),ta=i.useCallback(()=>gs(!0),[]),sa=i.useMemo(()=>{const s=[];return Ce.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Ce,statsScope:"staged",actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:n=>e("gitView.changes.unstageFileAria",{path:n}),onActionFile:n=>{Bt([n],"unstage")},onActionAll:n=>{Bt(n,"unstage")},onViewDiff:n=>Ts(n,!0),onRevertFile:Es,showRevertActions:!1,accent:!0}),Ms.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:Ms,statsScope:"working",actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:n=>e("gitView.changes.stageFileAria",{path:n}),onActionFile:n=>{Bt([n],"stage")},onActionAll:n=>{Bt(n,"stage")},onViewDiff:n=>Ts(n,!1),onRevertFile:Es}),s},[Es,Ts,Bt,Ce,e,Ms]),ra=i.useCallback(s=>{if(s.length===0)return;const n=s.map(l=>l.trim()).filter(Boolean);if(n.length===0){Ut();return}xt(l=>{const u=l.trim(),N=u.length>0?`
1
+ import{R as i,r as de,j as t,f as zt}from"./vendor-react-BUCujlKS.js";import{u as ot,F as it,K as Lt,fh as wa,aG as Fr,eS as Dr,z as g,I as E,aM as $s,aN as Ws,bW as en,aO as Us,au as Ks,at as qs,an as Js,ao as Ys,ap as ns,aq as as,B as K,fi as ba,fj as va,t as mt,q as ht,D as ft,l as gt,E as vt,y as Br,T as is,U as os,V as ls,fk as ja,L as me,fl as Ca,fm as Sa,fn as Na,fo as ka,aP as Va,bz as Ra,bL as Ia,fp as Pa,fq as Fa,fr as Da,fs as Ba,ft as Ma,fu as Oa,fv as Aa,n as tn,bR as Ea,bP as Ta,bO as La,bQ as za,bJ as Ga,C as _a,o as Hs,fw as Ha,fx as we,eV as $a,e_ as Wa,fy as Ua,ci as Ka,az as qa,e2 as Ja,e5 as Ya,e6 as Qa,d8 as Xa,fz as Za,eQ as ei,fA as ti,eZ as si,e7 as ri,fB as ni,ay as ai,e3 as ii,fC as oi,eX as li,eD as Mr,ad as ts,eF as Or,eE as Ar,ey as ci,fD as ui,$ as di,fE as mi,av as hi,O as fi,fF as Er,eU as gi,fG as pi,fH as Tr,c3 as xi,fI as yi,fJ as wi,fK as bi,fL as Ls,fM as vi,f4 as Ot,fN as Lr}from"./useAppFontEffects-Cs6k0JKv.js";import{u as ji,b as Ci}from"./main-BUetg9hg.js";import{c as Si,d as Ni,e as ki,R as Vi,J as Ri,U as Ii,M as Pi,L as Fi,V as Di,W as zs,I as Bi,X as Mi,O as Oi,Y as Ai,Z as Ei,_ as Ti}from"./runtimeEndpointReset-6CNNzem4.js";import{u as zr}from"./vendor-zustand-BAGL70zf.js";import{l as Li,u as Et,aU as zi,n as De,$ as ut}from"./katex.min-EZjpSwGK.js";import{R as Gi,I as _i,C as Hi,a as $i,b as Wi,D as Ui}from"./InProgressOperationBanner-JFV70YFh.js";import{P as Ki}from"./PierreDiffViewer-D0zX2Msu.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-CVhJ1Zpv.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.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-tanstack-react-virtual-Dozz-7fb.js";import"./vendor-tanstack-virtual-core-DKBj55Em.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DBekkZIx.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./useRootScrollLock-Dov-44ov.js";import"./moveWorkspacePath-CnYc96Xo.js";import"./sessionOwnership-BBuf0UCB.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./changesTree-CePHbFcj.js";import"./parseDiffFromFile-DEjkjYod.js";import"./computeVirtualFileMetrics-Cx05cmWI.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-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.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"./vendor-diff-C3JhlQdm.js";import"./isDiffPlainText-DW43IghW.js";import"./pierreDiffTint-3oatL635.js";import"./Virtualizer-Bl4Cf-H-.js";import"./useInlineCommentController-CVYaPzfO.js";import"./appThemeRegistry-xm_W0svA.js";import"./textMateThemeFromAppTheme-DLJBL6al.js";const sn="gitmojiCache",qi=1e3*60*60*24*7,rn="1",Ji="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",nn=o=>{if(!o||typeof o!="object")return!1;const e=o;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Gs=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(sn);if(!o)return null;const e=JSON.parse(o);return!e||e.version!==rn||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(nn),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Yi=o=>{if(!(typeof window>"u"))try{const e={gitmojis:o,fetchedAt:Date.now(),version:rn};window.localStorage.setItem(sn,JSON.stringify(e))}catch{return}},Gr=o=>Date.now()-o.fetchedAt<qi;let ss=null;const Tt=new Set,_r=async()=>{if(ss)return ss;const o=(async()=>{try{const e=await fetch(Ji);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const a=await e.json(),h=Array.isArray(a.gitmojis)?a.gitmojis.filter(nn):[];return Yi(h),Tt.forEach(x=>x(h)),h}catch(e){console.warn("Failed to load gitmoji list:",e);const a=[];return Tt.forEach(h=>h(a)),a}finally{ss=null}})();return ss=o,o},Qi=o=>{const[e,a]=i.useState(()=>o?Gs()?.gitmojis??[]:[]),[h,x]=i.useState(!1),d=i.useRef(o);d.current=o,i.useEffect(()=>{if(!o){Tt.delete(a),a([]),x(!1);return}const v=Gs();if(v&&(a(v.gitmojis),Gr(v)))return;Tt.add(a),x(!0);let f=!1;return _r().finally(()=>{!f&&d.current&&x(!1)}),()=>{f=!0,Tt.delete(a)}},[o]);const p=i.useCallback(async()=>{if(!d.current)return[];if(e.length>0)return e;const v=Gs();return v&&Gr(v)?v.gitmojis:_r()},[e]);return{gitmojis:e,isLoading:h,ensureLoaded:p}},jt=async(o,e)=>{const a=await Li(`/api/git/integrate/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){const h=await a.json().catch(()=>null);throw new Error(h?.error||`Git integrate request failed: ${a.statusText}`)}return a.json()};async function At(o){return jt("plan",o)}async function Xi(o){return jt("conflict-details",{tempWorktreePath:o})}async function Zi(o){return(await jt("cherry-pick-status",{tempWorktreePath:o})).inProgress}async function eo(o){return jt("run",{plan:o})}async function to(o){await jt("abort",{state:o})}async function so(o){return jt("continue",{state:o})}const ro=({repoRoot:o,sourceBranch:e,worktreeMetadata:a,localBranches:h,defaultTargetBranch:x,refreshKey:d,onRefresh:p,showHeader:v=!0})=>{const{t:f}=ot(),y=it(m=>m.currentSessionId),[B,M]=de.useState(!1),[k,G]=de.useState(""),S=de.useRef(null),L=de.useMemo(()=>Lt(h,k,m=>[m]),[h,k]),[R,b]=de.useState(x);de.useEffect(()=>{b(x)},[x]),de.useEffect(()=>{if(B){const m=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(m)}},[B]);const q=!!(o&&e&&R&&R!=="HEAD"&&e!==R),[j,F]=de.useState({kind:"idle"}),[V,P]=de.useState(!1),[z,ee]=de.useState([]),O=de.useMemo(()=>y?`openchamber.integrate.conflict:${y}`:null,[y]);de.useEffect(()=>{if(!O||typeof window>"u")return;const m=window.localStorage.getItem(O);if(!m)return;let c=!1;try{const I=JSON.parse(m);if(!I?.tempWorktreePath||I.repoRoot!==o){window.localStorage.removeItem(O);return}(async()=>{const T=await Zi(I.tempWorktreePath).catch(()=>!1);if(c)return;if(!T){window.localStorage.removeItem(O);return}const ne=await Xi(I.tempWorktreePath).catch(()=>null);c||ne&&F({kind:"conflict",state:I,details:ne})})()}catch{window.localStorage.removeItem(O)}return()=>{c=!0}},[O,o]),de.useEffect(()=>{if(!q){F({kind:"idle"});return}let m=!1;return F({kind:"loading"}),(async()=>{try{const c=await At({repoRoot:o,sourceBranch:e,targetBranch:R});if(m)return;if(F({kind:"ready",plan:c}),c.commits.length>0){const T=c.commits.slice(-50).reverse(),ne=await wa(o,T);m||(ee(ne),P(!1))}else m||(ee([]),P(!1))}catch{m||F({kind:"idle"})}})(),()=>{m=!0}},[q,o,e,R,d]);const r=de.useCallback(m=>{y&&it.getState().setWorktreeMetadata(y,{...a,createdFromBranch:m})},[y,a]),A=it(m=>m.openNewSessionDraft),J=de.useCallback(async m=>{const c=await Fr("git.integrate.cherrypick.resolve.visible",{current_commit:m.state.currentCommit,target_branch:m.state.targetBranch}),I=await Fr("git.integrate.cherrypick.resolve.instructions",{repo_root:m.state.repoRoot,temp_worktree_path:m.state.tempWorktreePath,source_branch:m.state.sourceBranch,target_branch:m.state.targetBranch,current_commit:m.state.currentCommit}),T=`Cherry-pick conflict context (JSON)
2
+ ${JSON.stringify({repoRoot:m.state.repoRoot,tempWorktreePath:m.state.tempWorktreePath,sourceBranch:m.state.sourceBranch,targetBranch:m.state.targetBranch,currentCommit:m.state.currentCommit,remainingCommits:m.state.remainingCommits,statusPorcelain:m.details.statusPorcelain,unmergedFiles:m.details.unmergedFiles,currentPatchMeta:m.details.currentPatchMeta,currentPatch:m.details.currentPatch,diff:m.details.diff},null,2)}`;return{visibleText:c,instructionsText:I,payloadText:T}},[]),w=Dr(m=>m.setPendingInputText),_=Dr(m=>m.setPendingSyntheticParts),H=de.useCallback(async(m,c)=>{const I=await J(m);if(c){A({directoryOverride:m.state.tempWorktreePath,initialPrompt:I.visibleText,syntheticParts:[{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}]});return}if(!y){g.error(f("gitView.integrate.noActiveSession"),{description:f("gitView.integrate.noActiveSessionDescription")});return}w(I.visibleText,"replace"),_([{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}])},[y,J,A,w,_,f]),Y=de.useCallback(async()=>{if(j.kind==="ready"){if(j.plan.commits.length===0){g.message(f("gitView.integrate.noCommitsToMoveToast"));return}F({kind:"running",plan:j.plan});try{const m=await eo(j.plan);if(m.kind==="success"){g.success(f("gitView.integrate.commitsMovedToast"),{description:m.moved===1?f("gitView.integrate.commitsMovedDescriptionSingle",{count:m.moved,branch:j.plan.targetBranch}):f("gitView.integrate.commitsMovedDescriptionPlural",{count:m.moved,branch:j.plan.targetBranch})});const c=await At(j.plan);F({kind:"ready",plan:c}),p?.();return}m.kind==="conflict"&&(g.error(f("gitView.integrate.cherryPickConflictToast"),{description:f("gitView.integrate.cherryPickConflictDescription")}),F({kind:"conflict",state:m.state,details:m.details}),O&&typeof window<"u"&&window.localStorage.setItem(O,JSON.stringify(m.state)))}catch(m){const c=m instanceof Error?m.message:String(m);g.error(f("gitView.integrate.failedToMoveToast"),{description:c});const I=await At({repoRoot:o,sourceBranch:e,targetBranch:R}).catch(()=>null);F(I?{kind:"ready",plan:I}:{kind:"idle"})}}},[j,p,o,e,R,O,f]),te=de.useCallback(async()=>{if(j.kind==="conflict")try{await to(j.state),g.message(f("gitView.integrate.cherryPickAbortedToast")),O&&typeof window<"u"&&window.localStorage.removeItem(O)}finally{const m=await At({repoRoot:o,sourceBranch:e,targetBranch:R}).catch(()=>null);F(m?{kind:"ready",plan:m}:{kind:"idle"})}},[j,o,e,R,O,f]),he=de.useCallback(async()=>{if(j.kind==="conflict")try{const m=await so(j.state);if(m.kind==="success"){g.success(f("gitView.integrate.cherryPickFinishedToast"));const c=await At({repoRoot:o,sourceBranch:e,targetBranch:R}).catch(()=>null);F(c?{kind:"ready",plan:c}:{kind:"idle"}),O&&typeof window<"u"&&window.localStorage.removeItem(O),p?.();return}m.kind==="conflict"&&(F({kind:"conflict",state:m.state,details:m.details}),O&&typeof window<"u"&&window.localStorage.setItem(O,JSON.stringify(m.state)))}catch(m){const c=m instanceof Error?m.message:String(m);g.error(f("gitView.integrate.cherryPickContinueFailedToast"),{description:c})}},[j,o,e,R,p,O,f]);return!o||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[v?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(E,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:f("gitView.integrate.title")}),j.kind==="ready"&&j.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:f("gitView.integrate.toMoveCount",{count:j.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:j.kind==="loading"||j.kind==="running"?t.jsx(E,{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:f("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",R]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs($s,{open:B,onOpenChange:M,children:[t.jsx(Ws,{asChild:!0,children:t.jsxs("button",{type:"button",className:en({size:"default"}),children:[f("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:R}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Us,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(Ks,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(qs,{ref:S,placeholder:f("gitView.branch.searchPlaceholder"),value:k,onValueChange:G,onKeyDown:m=>m.stopPropagation()}),t.jsxs(Js,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Ys,{children:f("gitView.branch.empty")}),t.jsx(ns,{heading:f("gitView.branch.localBranches"),children:L.map(m=>t.jsx(as,{value:m,onSelect:()=>{b(m),r(m),M(!1),G("")},children:m},m))})]})]})})]}),j.kind==="ready"?t.jsx(K,{size:"sm",onClick:()=>{Y()},disabled:!q||j.plan.commits.length===0,children:f("gitView.integrate.move")}):j.kind==="loading"?t.jsx(K,{size:"sm",variant:"outline",disabled:!0,children:f("gitView.integrate.checking")}):j.kind==="running"?t.jsx(K,{size:"sm",variant:"outline",disabled:!0,children:f("gitView.integrate.moving")}):null]}),j.kind==="ready"&&j.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:f("gitView.integrate.noCommitsToMove")}),j.kind==="ready"&&j.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:[f("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",j.plan.commits.length,")"]})]}),z.length>0&&j.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>P(m=>!m),className:"typography-micro text-muted-foreground hover:text-foreground",children:f(V?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(V?z:z.slice(0,5)).map(m=>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:m.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:m.subject||m.sha})]},m.sha)),z.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:f("gitView.integrate.previewUnavailable")}),j.plan.commits.length>z.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f("gitView.integrate.showingFirstCommits",{count:z.length})})]})]}),j.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:f("gitView.integrate.conflictsInFiles",{count:j.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[f("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:j.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[j.details.unmergedFiles.slice(0,6).map(m=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:m},m)),j.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:f("gitView.integrate.moreFiles",{count:j.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(K,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{te()},children:f("gitView.operation.abort")}),t.jsxs(K,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!y,onClick:()=>{H({state:j.state,details:j.details},!1)},children:[t.jsx(E,{name:"sparkling",className:"size-3.5"}),f("gitView.integrate.currentSession")]}),t.jsxs(K,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{H({state:j.state,details:j.details},!0)},children:[t.jsx(E,{name:"sparkling",className:"size-3.5"}),f("gitView.integrate.newSession")]}),t.jsx(K,{size:"sm",className:"typography-meta",onClick:()=>{he()},children:f("gitView.operation.continue")})]})]})]})]})},no=({open:o,onOpenChange:e,directory:a,hasUncommittedChanges:h,hasStagedChanges:x=!1,uncommittedFileCount:d,onChanged:p})=>{const{t:v}=ot(),[f,y]=i.useState([]),[B,M]=i.useState(!1),[k,G]=i.useState(""),[S,L]=i.useState(""),[R,b]=i.useState(null),[q,j]=i.useState({}),F=i.useCallback(async()=>{if(a){M(!0);try{const r=await ba(a);y(r.stashes),j({})}catch(r){g.error(r instanceof Error?r.message:v("gitView.stashes.toast.loadFailed"))}finally{M(!1)}}},[a,v]);i.useEffect(()=>{o&&F()},[F,o]),i.useEffect(()=>{if(!o||!a||f.length===0)return;let r=!1;const A=f.map(J=>J.ref);return va(a,A).then(J=>{r||j(J.counts)}).catch(()=>{}),()=>{r=!0}},[a,o,f]);const V=i.useMemo(()=>Lt(f,k,r=>[r.message,r.ref,r.relativeTime]),[k,f]),P=i.useCallback(async r=>{await F(),await p?.(r)},[F,p]),z=async()=>{if(!(!a||R)){b("create");try{const r=await ja(a,{message:S.trim()||void 0});r.created?(g.success(v("gitView.stashes.toast.created")),L("")):g.info(v("gitView.stashes.toast.noChanges")),await P({affectsIndex:!!(r.created&&x)})}catch(r){g.error(r instanceof Error?r.message:v("gitView.stashes.toast.createFailed"))}finally{b(null)}}},ee=async(r,A)=>{if(!(!a||R)&&!(A==="drop"&&!window.confirm(v("gitView.stashes.confirm.drop",{ref:r.ref})))){b(`${A}:${r.ref}`);try{A==="apply"&&await Ca(a,{ref:r.ref}),A==="pop"&&await Sa(a,{ref:r.ref}),A==="drop"&&await Na(a,{ref:r.ref});const J=A==="apply"?"gitView.stashes.toast.applySuccess":A==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";g.success(v(J)),await P({affectsIndex:A!=="drop"})}catch(J){const w=A==="apply"?"gitView.stashes.toast.applyFailed":A==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";g.error(J instanceof Error?J.message:v(w)),await P({affectsIndex:A!=="drop"})}finally{b(null)}}},O=R!==null;return t.jsx(mt,{open:o,onOpenChange:e,children:t.jsxs(ht,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(ft,{children:[t.jsxs(gt,{className:"flex items-center gap-2",children:[t.jsx(E,{name:"archive-stack",className:"size-4 text-muted-foreground"}),v("gitView.stashes.title")]}),t.jsx(vt,{children:v("gitView.stashes.description")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(Br,{value:S,onChange:r=>L(r.target.value),placeholder:v("gitView.stashes.messagePlaceholder"),disabled:O||!h,className:"flex-1"}),t.jsxs(K,{onClick:z,disabled:!h||O||!a,children:[R==="create"?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"inbox-archive",className:"size-4"}),v("gitView.stashes.actions.stashCurrentWithCount",{count:d})]})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:v("gitView.stashes.includeUntrackedHint")})]}),t.jsx("div",{className:"-mx-5 border-t border-border/60"}),t.jsxs("div",{className:"relative",children:[t.jsx(E,{name:"search",className:"absolute inset-s-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(Br,{value:k,onChange:r=>G(r.target.value),placeholder:v("gitView.stashes.searchPlaceholder"),className:"ps-8"})]}),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(E,{name:"loader-4",className:"size-5 animate-spin"})}):V.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:v(k?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):V.map((r,A)=>t.jsxs("div",{className:"group -mx-2 flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-interactive-hover",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"typography-ui-label truncate text-foreground",children:r.message||v("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-micro truncate text-muted-foreground",children:[t.jsxs(is,{children:[t.jsx(os,{asChild:!0,children:t.jsx("span",{children:A===0&&!k.trim()?v("gitView.stashes.latestLabel"):v("gitView.stashes.itemNumber",{number:A+1})})}),t.jsx(ls,{sideOffset:6,children:r.ref})]})," · ",r.relativeTime," · ",typeof q[r.ref]=="number"?v("gitView.stashes.fileCount",{count:q[r.ref]}):v("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(_s,{label:v("gitView.stashes.actions.apply"),loading:R===`apply:${r.ref}`,onClick:()=>ee(r,"apply"),disabled:O,children:t.jsx(E,{name:"inbox-unarchive",className:"size-3.5"})}),t.jsx(_s,{label:v("gitView.stashes.actions.pop"),loading:R===`pop:${r.ref}`,onClick:()=>ee(r,"pop"),disabled:O,children:t.jsx(E,{name:"inbox-unarchive-fill",className:"size-3.5"})}),t.jsx(_s,{label:v("gitView.stashes.actions.drop"),loading:R===`drop:${r.ref}`,onClick:()=>ee(r,"drop"),disabled:O,destructive:!0,children:t.jsx(E,{name:"delete-bin",className:"size-3.5"})})]})]},r.ref))})]})})},_s=o=>{const e=zt.c(17),{label:a,loading:h,disabled:x,destructive:d,onClick:p,children:v}=o,f=h||void 0,y=d?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let B;e[0]!==y?(B=me("flex size-6 items-center justify-center rounded-md transition-colors hover:bg-interactive-hover disabled:opacity-50",y),e[0]=y,e[1]=B):B=e[1];let M;e[2]!==v||e[3]!==h?(M=h?t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):v,e[2]=v,e[3]=h,e[4]=M):M=e[4];let k;e[5]!==x||e[6]!==a||e[7]!==p||e[8]!==f||e[9]!==B||e[10]!==M?(k=t.jsx(os,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":a,"aria-busy":f,className:B,onClick:p,disabled:x,children:M})}),e[5]=x,e[6]=a,e[7]=p,e[8]=f,e[9]=B,e[10]=M,e[11]=k):k=e[11];let G;e[12]!==a?(G=t.jsx(ls,{sideOffset:6,children:a}),e[12]=a,e[13]=G):G=e[13];let S;return e[14]!==k||e[15]!==G?(S=t.jsxs(is,{children:[k,G]}),e[14]=k,e[15]=G,e[16]=S):S=e[16],S},ao=o=>{const e=zt.c(16),{onOpenStashes:a}=o,{t:h}=ot();let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(E,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=x):x=e[0];let d;e[1]!==h?(d=h("gitView.empty.cleanTitle"),e[1]=h,e[2]=d):d=e[2];let p;e[3]!==d?(p=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:d}),e[3]=d,e[4]=p):p=e[4];let v;e[5]!==h?(v=h("gitView.empty.cleanDescription"),e[5]=h,e[6]=v):v=e[6];let f;e[7]!==v?(f=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:v}),e[7]=v,e[8]=f):f=e[8];let y;e[9]!==a||e[10]!==h?(y=a?t.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[t.jsx(E,{name:"archive-stack",className:"size-4"}),h("gitView.stashes.title")]}):null,e[9]=a,e[10]=h,e[11]=y):y=e[11];let B;return e[12]!==p||e[13]!==f||e[14]!==y?(B=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[x,p,f,y]}),e[12]=p,e[13]=f,e[14]=y,e[15]=B):B=e[15],B},at=8,io=o=>{const e=zt.c(18),{laned:a,totalLanes:h,isExpanded:x}=o,{lane:d,color:p,connectors:v}=a,y=Math.max(h,d+1)*at+at/2,B=i.useRef(null),M=i.useRef(null);let k;e[0]!==p||e[1]!==v||e[2]!==d||e[3]!==y?(k=()=>{const b=B.current,q=M.current;if(!b||!q)return;const j=b.offsetHeight;if(j===0)return;const F=window.devicePixelRatio||1;q.width=y*F,q.height=j*F;const V=q.getContext("2d");if(!V)return;V.scale(F,F),V.clearRect(0,0,y,j);const P=j/2,z=d*at+at/2,ee=getComputedStyle(q),O=ee.getPropertyValue("--surface-muted-foreground").trim()||ee.color,r=w=>{if(!w.startsWith("var("))return w;const _=w.slice(4,-1).trim();return ee.getPropertyValue(_).trim()||O},A=[...v].sort(lo);for(const w of A){const _=w.fromLane*at+at/2,H=w.toLane*at+at/2,Y=w.type==="passing"?.72:w.type==="branch-out"||w.type==="merge-in"?.95:1;V.beginPath(),V.strokeStyle=r(w.color),V.globalAlpha=Y,V.lineWidth=1.25,V.lineCap="round";e:switch(w.type){case"passing":case"commit-lane":{V.moveTo(_,0),V.lineTo(_,j);break e}case"top-stub":{V.moveTo(_,0),V.lineTo(_,P);break e}case"bottom-stub":{V.moveTo(_,P),V.lineTo(_,j);break e}case"branch-out":{const te=(P+j)/2;V.moveTo(z,P),V.bezierCurveTo(z,te,H,te,H,j);break e}case"merge-in":{const te=P/2;V.moveTo(_,0),V.bezierCurveTo(_,te,z,te,z,P);break e}default:continue}V.stroke(),V.globalAlpha=1}const J=ee.getPropertyValue("--background").trim()||ee.getPropertyValue("--surface-background").trim();V.beginPath(),V.arc(z,P,4,0,Math.PI*2),V.fillStyle=r(p),V.fill(),V.beginPath(),V.arc(z,P,5,0,Math.PI*2),V.strokeStyle=J||O,V.lineWidth=2,V.stroke()},e[0]=p,e[1]=v,e[2]=d,e[3]=y,e[4]=k):k=e[4];let G;e[5]!==p||e[6]!==v||e[7]!==x||e[8]!==d||e[9]!==a||e[10]!==h||e[11]!==y?(G=[a,d,p,v,h,x,y],e[5]=p,e[6]=v,e[7]=x,e[8]=d,e[9]=a,e[10]=h,e[11]=y,e[12]=G):G=e[12],i.useLayoutEffect(k,G);let S;e[13]!==y?(S={width:y,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=y,e[14]=S):S=e[14];let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx("canvas",{ref:M,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=L):L=e[15];let R;return e[16]!==S?(R=t.jsx("div",{ref:B,style:S,children:L}),e[16]=S,e[17]=R):R=e[17],R};function oo(o){return o==="branch-out"||o==="merge-in"}function lo(o,e){const a=oo;return(a(o.type)?1:0)-(a(e.type)?1:0)}const Hr=15e3,$r=500,Wr=12,Ur=8*1024*1024,Kr=o=>typeof o=="string"?0:(o.original?.length??0)+(o.modified?.length??0),qr=o=>{if(o.size<=Wr){let x=0;for(const d of o.values())x+=Kr(d);if(x<=Ur)return o}const e=Array.from(o.entries()).reverse(),a=new Map;let h=0;for(const[x,d]of e){if(a.size>=Wr)continue;const p=Kr(d);h+p>Ur&&a.size>0||(a.set(x,d),h+=p)}return new Map(Array.from(a.entries()).reverse())};function Jr(o,e){const a=new Date(o);return Number.isNaN(a.getTime())?o:Ia(a,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function co(o){switch(o){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 uo(o){return o?o.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const a=e.startsWith("HEAD ->");return{label:a?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:a,isTag:e.startsWith("tag: ")}}):[]}const mo=i.memo(({entry:o,mode:e="history",laned:a,totalLanes:h,isExpanded:x,onToggle:d,files:p,isLoadingFiles:v,onCopyHash:f,directory:y,onConflict:B,onActionSuccess:M})=>{const{t:k}=ot(),G=Et(c=>c.timeFormatPreference),S=e==="graph",[L,R]=i.useState(null),[b,q]=i.useState(!1),[j,F]=i.useState(""),[V,P]=i.useState(null),[z,ee]=i.useState(new Set),[O,r]=i.useState(new Map),[A,J]=i.useState(new Set),w=async()=>{if(y){R("checkout");try{await Aa(y,o.hash),g.success(k("gitView.history.actions.detachedHead")),M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},_=async()=>{if(!(!y||!j.trim())){R("createBranch");try{await Pa(y,j.trim(),o.hash),q(!1),F(""),M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},H=async()=>{if(y){R("cherryPick");try{const c=await Oa(y,o.hash);c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"cherry-pick"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},Y=async()=>{if(y){R("revert");try{const c=await Ma(y,o.hash);c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"revert"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},te=async(c,I=!1)=>{if(!(!y||L!==null)){R("reset");try{await Fa(y,o.hash,c,I),M?.()}catch(T){g.error(String(T.message))}finally{R(null)}}},he=async()=>{if(!V)return;const c=V;switch(P(null),c){case"checkout":return w();case"cherryPick":return H();case"revert":return Y();case"merge":return se();case"rebase":return oe();case"resetSoft":return te("soft");case"resetMixed":return te("mixed");case"resetHard":return te("hard",!0)}},se=async()=>{if(y){R("merge");try{const c=await Ba(y,{branch:o.hash});c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"merge"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},oe=async()=>{if(y){R("rebase");try{const c=await Da(y,{onto:o.hash});c.conflict?B?.({conflict:!0,conflictFiles:c.conflictFiles,operation:"rebase"}):M?.()}catch(c){g.error(String(c.message))}finally{R(null)}}},le=i.useCallback(async c=>{const I=c.path;if(!y){r(T=>new Map(T).set(I,"error"));return}r(T=>qr(new Map(T).set(I,"loading")));try{const T=ka(y,o.hash,c.path,!1),ne=new Promise((Z,$)=>{setTimeout(()=>$(new Error(`Timed out after ${Hr}ms`)),Hr)}),Q=await Promise.race([T,ne]);r(Z=>qr(new Map(Z).set(I,Q)))}catch{r(T=>new Map(T).set(I,"error"))}},[y,o.hash]),m=i.useCallback(async c=>{const I=c.path;if(c.changeType==="R"||c.isBinary){ee(Z=>{const $=new Set(Z);return $.has(I)?$.delete(I):$.add(I),$});return}const T=O.get(I);if(z.has(I)&&T&&T!=="error"){ee(Z=>{const $=new Set(Z);return $.delete(I),$});return}ee(Z=>{const $=new Set(Z);return $.add(I),$}),!(T&&T!=="error"||c.insertions+c.deletions>$r&&!A.has(I))&&await le(c)},[O,A,le,z]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:d,className:me("w-full flex items-start gap-3 px-3 py-2 text-start transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":x?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&a&&h!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(io,{laned:a,totalLanes:h,isExpanded:x})}):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:[S?(()=>{const c=uo(o.refs);return c.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:c.map(I=>t.jsx("span",{className:me("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",I.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":I.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:I.label},I.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:o.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:o.author_name,children:o.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:Jr(o.date,G),children:Jr(o.date,G)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:o.hash.slice(0,8)}),t.jsxs(is,{children:[t.jsx(os,{asChild:!0,children:t.jsx(K,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:c=>{c.stopPropagation(),f(o.hash)},children:t.jsx(E,{name:"file-copy",className:"size-3"})})}),t.jsx(ls,{sideOffset:8,children:k("gitView.history.copySha")})]})]})]})]}),x&&t.jsxs("div",{className:"px-3 pb-2 ps-8 border-t border-border/40",children:[S&&V?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:k(`gitView.history.actions.${V}Confirm`)}),t.jsxs(K,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:L!==null,onClick:c=>{c.stopPropagation(),he()},children:[L!==null?t.jsx(E,{name:"loader-4",className:"size-3 animate-spin me-1"}):null,k("gitView.history.actions.confirmButton")]}),t.jsx(K,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:L!==null,onClick:c=>{c.stopPropagation(),P(null)},children:k("gitView.history.actions.cancelButton")})]}):S?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("checkout")},children:k("gitView.history.actions.checkout")}),b?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:j,onChange:c=>F(c.target.value),onKeyDown:c=>{c.key==="Enter"&&_(),c.key==="Escape"&&(q(!1),F(""))},placeholder:k("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(K,{variant:"outline",size:"xs",className:"h-6",disabled:!j.trim()||L!==null,onClick:c=>{c.stopPropagation(),_()},children:[L==="createBranch"?t.jsx(E,{name:"loader-4",className:"size-3 animate-spin me-1"}):null,k("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(K,{variant:"outline",size:"xs",className:"h-6",onClick:c=>{c.stopPropagation(),q(!0)},children:k("gitView.history.actions.createBranch")}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("cherryPick")},children:k("gitView.history.actions.cherryPick")}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("revert")},children:k("gitView.history.actions.revert")}),t.jsxs($s,{children:[t.jsx(Ws,{asChild:!0,children:t.jsxs(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>c.stopPropagation(),children:[L==="reset"?t.jsx(E,{name:"loader-4",className:"size-3 animate-spin me-1"}):null,k("gitView.history.actions.reset")]})}),t.jsx(Us,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(c=>t.jsx(Va,{disabled:L!==null,onSelect:I=>{I.stopPropagation(),P(`reset${c.charAt(0).toUpperCase()+c.slice(1)}`)},children:k(`gitView.history.actions.reset${c.charAt(0).toUpperCase()+c.slice(1)}`)},c))})]}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("merge")},children:k("gitView.history.actions.merge")}),t.jsx(K,{variant:"outline",size:"xs",className:"h-6",disabled:L!==null,onClick:c=>{c.stopPropagation(),P("rebase")},children:k("gitView.history.actions.rebase")})]}):null,v?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(E,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:k("gitView.history.loadingFiles")})]}):p.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:k("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:p.map(c=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>m(c),className:me("w-full flex items-center gap-2 typography-micro text-start cursor-pointer transition-colors rounded px-1",z.has(c.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:me("font-semibold w-3 text-center shrink-0",co(c.changeType)),children:c.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:c.path,children:c.path}),!c.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",c.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",c.deletions]})]}),c.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:k("gitView.history.binary")}),t.jsx(E,{name:z.has(c.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),z.has(c.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:c.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:k("gitView.history.renamedNoDiff")}):c.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:k("gitView.history.binaryNoDiff")}):(()=>{const I=c.insertions+c.deletions;if(!A.has(c.path)&&I>$r)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:k("gitView.history.largeDiffTitle",{count:I})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:k("gitView.history.largeDiffDescription")}),t.jsx(K,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{J(ne=>new Set(ne).add(c.path)),le(c)},children:k("gitView.history.renderDiffAnyway")})]});const T=O.get(c.path);return T==="loading"||T===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:k("gitView.history.loadingDiff")}):T==="error"?t.jsx("button",{type:"button",onClick:()=>m(c),className:"w-full text-start px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:k("gitView.history.diffError")}):t.jsx(Ki,{original:T.original,modified:T.modified,language:Ra(c.path)||"",fileName:c.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},c.path))})]})]})}),Yr=["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 rs(o){return Yr[o%Yr.length]}function ho(o){if(o.length===0)return[];const e=[],a=[];for(let h=0;h<o.length;h++){const x=o[h],d=[];for(let S=0;S<e.length;S++)e[S]===x.hash&&d.push(S);let p=d.length>0?d[0]:-1;if(p===-1){const S=e.indexOf(null);S!==-1?p=S:(p=e.length,e.push(null))}const v=d.slice(1),f=rs(p),y=e[p]===x.hash,B=x.parents.length>0;B?e[p]=x.parents[0]:e[p]=null;const M=[],k=new Set;for(let S=1;S<x.parents.length;S++){const L=x.parents[S],R=e.indexOf(L);if(R!==-1)M.push(R);else{const b=e.indexOf(null);if(b!==-1)e[b]=L,M.push(b),k.add(b);else{const q=e.length;e.push(L),M.push(q),k.add(q)}}}const G=[];y&&B?G.push({fromLane:p,toLane:p,color:f,type:"commit-lane"}):y&&!B?G.push({fromLane:p,toLane:p,color:f,type:"top-stub"}):!y&&B&&G.push({fromLane:p,toLane:p,color:f,type:"bottom-stub"});for(const S of v)G.push({fromLane:S,toLane:p,color:rs(S),type:"merge-in"}),e[S]=null;for(const S of M)G.push({fromLane:p,toLane:S,color:rs(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==p&&(k.has(S)||G.push({fromLane:S,toLane:S,color:rs(S),type:"passing"}));a.push({commit:x,lane:p,color:f,connectors:G})}return a}const fo=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],go=o=>{const e=zt.c(84),{mode:a,log:h,isLogLoading:x,logMaxCount:d,onLogMaxCountChange:p,expandedCommitHashes:v,onToggleCommit:f,commitFilesMap:y,loadingCommitHashes:B,onCopyHash:M,directory:k,showHeader:G,contentMaxHeightClassName:S,branchDivider:L,onConflict:R,onActionSuccess:b}=o,q=a===void 0?"history":a,j=G===void 0?!0:G,F=S===void 0?"max-h-[50vh]":S,V=L===void 0?null:L,{t:P}=ot(),[z,ee]=i.useState(!0),O=q==="graph";let r;e[0]!==O||e[1]!==h?(r=O&&h?ho(h.all):[],e[0]=O,e[1]=h,e[2]=r):r=e[2];const A=r;let J;e[3]!==A?(J=Math.max(1,...A.map(po)),e[3]=A,e[4]=J):J=e[4];const w=J;let _;e[5]!==A?(_=new Map(A.map(xo)),e[5]=A,e[6]=_):_=e[6];const H=_;if(!h)return null;const Y=V!==null&&V.insertBeforeIndex>0&&V.insertBeforeIndex<h.all.length,te=V!==null&&V.insertBeforeIndex===h.all.length,he=Y||te;let se;e[7]!==V||e[8]!==Y||e[9]!==te||e[10]!==h.all?(se=Y?h.all.slice(0,V.insertBeforeIndex):te?h.all:[],e[7]=V,e[8]=Y,e[9]=te,e[10]=h.all,e[11]=se):se=e[11];const oe=se;let le;if(e[12]!==V||e[13]!==y||e[14]!==F||e[15]!==k||e[16]!==v||e[17]!==Y||e[18]!==he||e[19]!==O||e[20]!==x||e[21]!==H||e[22]!==B||e[23]!==h.all||e[24]!==d||e[25]!==w||e[26]!==q||e[27]!==b||e[28]!==R||e[29]!==M||e[30]!==p||e[31]!==f||e[32]!==P||e[33]!==oe){const ce=Y?h.all.slice(V.insertBeforeIndex):[];let pe;e[35]!==V?.direction?(pe=V?.direction==="down"?t.jsx(E,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(E,{name:"arrow-up",className:"size-3.5"}),e[35]=V?.direction,e[36]=pe):pe=e[36];const Me=pe;let be;e[37]!==y||e[38]!==k||e[39]!==v||e[40]!==O||e[41]!==H||e[42]!==B||e[43]!==w||e[44]!==q||e[45]!==b||e[46]!==R||e[47]!==M||e[48]!==f?(be=Gt=>t.jsx("ul",{className:"divide-y divide-border/60",children:Gt.map(Ne=>t.jsx(mo,{entry:Ne,mode:q,laned:O?H.get(Ne.hash):void 0,totalLanes:O?w:void 0,isExpanded:v.has(Ne.hash),onToggle:()=>f(Ne.hash),files:y.get(Ne.hash)??[],isLoadingFiles:B.has(Ne.hash),onCopyHash:M,directory:k,onConflict:R,onActionSuccess:b},Ne.hash))}),e[37]=y,e[38]=k,e[39]=v,e[40]=O,e[41]=H,e[42]=B,e[43]=w,e[44]=q,e[45]=b,e[46]=R,e[47]=M,e[48]=f,e[49]=be):be=e[49];const Se=be;let ae;e[50]!==x||e[51]!==h.all.length||e[52]!==d||e[53]!==p||e[54]!==P?(ae=h.all.length>=d?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(K,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(d+25),disabled:x,className:"px-3 text-muted-foreground hover:text-foreground",children:x?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(E,{name:"loader-4",className:"size-3 animate-spin"}),P("gitView.history.loadingMore")]}):P("gitView.history.loadMore")})}):null,e[50]=x,e[51]=h.all.length,e[52]=d,e[53]=p,e[54]=P,e[55]=ae):ae=e[55];const _e=ae;le=t.jsx(tn,{outerClassName:`min-h-0 ${F}`,className:"h-full w-full",children:h.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")})}):he&&V?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[oe.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:Se(oe)}):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:V.branchName,children:V.branchName}),Me]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),ce.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:Se(ce)}):null]}),_e]}):t.jsxs(t.Fragment,{children:[Se(h.all),_e]})}),e[12]=V,e[13]=y,e[14]=F,e[15]=k,e[16]=v,e[17]=Y,e[18]=he,e[19]=O,e[20]=x,e[21]=H,e[22]=B,e[23]=h.all,e[24]=d,e[25]=w,e[26]=q,e[27]=b,e[28]=R,e[29]=M,e[30]=p,e[31]=f,e[32]=P,e[33]=oe,e[34]=le}else le=e[34];const m=le;if(!j){if(he){let pe;return e[56]!==m?(pe=t.jsx("section",{className:"h-full min-h-0",children:m}),e[56]=m,e[57]=pe):pe=e[57],pe}let ce;return e[58]!==m?(ce=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:m}),e[58]=m,e[59]=ce):ce=e[59],ce}let c;e[60]!==P?(c=P("gitView.history.title"),e[60]=P,e[61]=c):c=e[61];let I;e[62]!==c?(I=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:c}),e[62]=c,e[63]=I):I=e[63];let T;e[64]!==x||e[65]!==z||e[66]!==d||e[67]!==p||e[68]!==P?(T=z&&t.jsx("div",{onClick:yo,onPointerDown:wo,children:t.jsxs(Ea,{value:String(d),onValueChange:ce=>p(Number(ce)),disabled:x,children:[t.jsx(Ta,{className:"w-auto",disabled:x,children:t.jsx(La,{placeholder:P("gitView.history.commitsPlaceholder")})}),t.jsx(za,{children:fo.map(ce=>t.jsx(Ga,{value:String(ce.value),children:P(ce.labelKey)},ce.value))})]})}),e[64]=x,e[65]=z,e[66]=d,e[67]=p,e[68]=P,e[69]=T):T=e[69];let ne;e[70]!==z?(ne=z?t.jsx(E,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(E,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=z,e[71]=ne):ne=e[71];let Q;e[72]!==T||e[73]!==ne?(Q=t.jsxs("div",{className:"flex items-center gap-2",children:[T,ne]}),e[72]=T,e[73]=ne,e[74]=Q):Q=e[74];let Z;e[75]!==I||e[76]!==Q?(Z=t.jsxs(Si,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[I,Q]}),e[75]=I,e[76]=Q,e[77]=Z):Z=e[77];let $;e[78]!==m?($=t.jsx(Ni,{children:m}),e[78]=m,e[79]=$):$=e[79];let Be;return e[80]!==z||e[81]!==Z||e[82]!==$?(Be=t.jsxs(ki,{open:z,onOpenChange:ee,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[Z,$]}),e[80]=z,e[81]=Z,e[82]=$,e[83]=Be):Be=e[83],Be};function po(o){return o.lane+1}function xo(o){return[o.commit.hash,o]}function yo(o){return o.stopPropagation()}function wo(o){return o.stopPropagation()}const bo=({open:o,onOpenChange:e,operation:a,targetBranch:h,onConfirm:x})=>{const{t:d}=ot(),[p,v]=i.useState(!0),[f,y]=i.useState(!1),B=d(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),M=async()=>{y(!0);try{await x(p),e(!1)}catch(G){const S=G instanceof Error?G.message:`Failed to ${a}`;g.error(S)}finally{y(!1)}},k=()=>{f||e(!1)};return t.jsx(mt,{open:o,onOpenChange:f?void 0:e,children:t.jsxs(ht,{className:"max-w-md",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(gt,{children:d("gitView.stash.title")})]}),t.jsx(vt,{children:d("gitView.stash.description",{operation:a})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:d("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:d("gitView.stash.stepStash")}),t.jsxs("li",{children:[d(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",d(a==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:h})]}),p&&t.jsx("li",{children:d("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(_a,{checked:p,onChange:v,disabled:f,ariaLabel:d("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!f&&v(!p),children:d("gitView.stash.restoreAfterOperation",{operation:a})})]}),t.jsxs(Hs,{className:"gap-2",children:[t.jsx(K,{variant:"ghost",size:"sm",onClick:k,disabled:f,children:d("gitView.common.cancel")}),t.jsx(K,{variant:"default",size:"sm",onClick:M,disabled:f,className:"gap-1.5",children:f?t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),d("gitView.common.processing")]}):d("gitView.stash.confirmButton",{operation:B})})]})]})})},vo=o=>{const e=zt.c(100),{currentBranch:a,localBranches:h,remoteBranches:x,onMerge:d,onRebase:p,disabled:v,isOperating:f,operationLogs:y,onOperationComplete:B,mode:M,defaultTargetBranch:k}=o,G=v===void 0?!1:v,S=f===void 0?!1:f,L=y===void 0?[]:y,R=M===void 0?"dialog":M,{t:b}=ot(),[q,j]=i.useState(!1),[F,V]=i.useState("merge"),[P,z]=i.useState(null),[ee,O]=i.useState(!1),[r,A]=i.useState(""),J=i.useRef(null),w=i.useRef(null),_=G||S,H=a||b("gitView.branch.currentBranchFallback"),Y=L.length>0&&L.every(jo),te=L.some(Co);let he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},e[0]=he):he=e[0],i.useEffect(he,[L]);let se;if(e[1]!==r||e[2]!==a||e[3]!==h){let X;e[5]!==a?(X=Re=>Re!==a,e[5]=a,e[6]=X):X=e[6];const fe=h.filter(X);se=Lt(fe,r,So),e[1]=r,e[2]=a,e[3]=h,e[4]=se}else se=e[4];const oe=se;let le;e[7]!==r||e[8]!==x?(le=Lt(x,r,No),e[7]=r,e[8]=x,e[9]=le):le=e[9];const m=le;let c;e[10]!==k||e[11]!==h||e[12]!==x?(c=()=>{if(!k)return null;const X=x.find(fe=>fe.label===k);return X||(h.includes(k)?{kind:"local",branch:k,label:k}:null)},e[10]=k,e[11]=h,e[12]=x,e[13]=c):c=e[13];const I=c;let T;e[14]!==I||e[15]!==j?(T=()=>{j(!0),z(I()),V("merge"),A("")},e[14]=I,e[15]=j,e[16]=T):T=e[16];const ne=T;let Q;e[17]===Symbol.for("react.memo_cache_sentinel")?(Q=X=>{z(X),O(!1),A("")},e[17]=Q):Q=e[17];const Z=Q;let $;e[18]!==d||e[19]!==p||e[20]!==F||e[21]!==P?($=()=>{P&&(F==="merge"?d(P):p(P))},e[18]=d,e[19]=p,e[20]=F,e[21]=P,e[22]=$):$=e[22];const Be=$;let ce;e[23]!==S||e[24]!==j?(ce=()=>{S||(z(null),V("merge"),A(""),j(!1))},e[23]=S,e[24]=j,e[25]=ce):ce=e[25];const pe=ce,Me=()=>{S&&!Y||(Y&&B?.(),z(null),V("merge"),A(""),j(!1))};let be,Se;e[26]!==ee?(be=()=>{ee||A("")},Se=[ee],e[26]=ee,e[27]=be,e[28]=Se):(be=e[27],Se=e[28]),i.useEffect(be,Se);let ae,_e;e[29]!==R||e[30]!==I||e[31]!==P?(ae=()=>{R==="dialog"||P||z(I())},_e=[R,I,P],e[29]=R,e[30]=I,e[31]=P,e[32]=ae,e[33]=_e):(ae=e[32],_e=e[33]),i.useEffect(ae,_e);const Oe=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:w,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:L.map(ko)})}),Y?R==="dialog"?t.jsx(Hs,{children:t.jsx(K,{variant:"default",size:"sm",onClick:Me,children:b(te?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(K,{variant:"default",size:"sm",onClick:Me,children:b(te?"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:b("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>V("merge"),className:me("flex flex-col items-start gap-1 rounded-lg border p-3 text-start transition-colors",F==="merge"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"git-merge",className:me("size-4",F==="merge"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:me("typography-ui-label",F==="merge"?"text-foreground":"text-muted-foreground"),children:b("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:b("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>V("rebase"),className:me("flex flex-col items-start gap-1 rounded-lg border p-3 text-start transition-colors",F==="rebase"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:"git-branch",className:me("size-4",F==="rebase"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:me("typography-ui-label",F==="rebase"?"text-foreground":"text-muted-foreground"),children:b("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:b("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:F==="merge"?b("gitView.branch.branchToMergeInto",{branch:H}):b("gitView.branch.branchToRebaseOnto")}),t.jsxs($s,{open:ee,onOpenChange:O,modal:!1,children:[t.jsx(Ws,{asChild:!0,children:t.jsxs("button",{type:"button",className:me(en({size:"default"}),"w-full"),children:[t.jsx("span",{className:me("truncate",!P&&"text-muted-foreground"),children:P?.label||b("gitView.branch.selectBranch")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Us,{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(Ks,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(qs,{ref:J,placeholder:b("gitView.branch.searchPlaceholder"),value:r,onValueChange:A,onKeyDown:Vo}),t.jsxs(Js,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Ys,{children:b("gitView.branch.empty")}),oe.length>0&&t.jsx(ns,{heading:b("gitView.branch.localBranches"),children:oe.map(X=>t.jsx(as,{onSelect:()=>Z({kind:"local",branch:X,label:X}),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X})},`local-${X}`))}),oe.length>0&&m.length>0?t.jsx(Ha,{}):null,m.length>0&&t.jsx(ns,{heading:b("gitView.branch.remoteBranches"),children:m.map(X=>t.jsx(as,{onSelect:()=>Z(X),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.label})},`remote-${X.label}`))})]})]})})]})]}),P?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:F==="merge"?t.jsxs(t.Fragment,{children:[b("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P.label})," ",b("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:H})]}):t.jsxs(t.Fragment,{children:[b("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:H})," ",b("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P.label})]})})}):null,R==="dialog"?t.jsxs(Hs,{className:"gap-2 pt-1",children:[t.jsx(K,{variant:"ghost",size:"sm",onClick:pe,children:b("gitView.common.cancel")}),t.jsx(K,{variant:"default",size:"sm",onClick:Be,disabled:!P,className:"gap-1.5",children:F==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"git-merge",className:"size-4"}),b("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"git-branch",className:"size-4"}),b("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(K,{variant:"destructive",size:"sm",onClick:pe,disabled:_,children:b("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(K,{variant:"default",size:"sm",onClick:Be,disabled:_||!P,children:b(F==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(R==="bare")return Oe;if(R==="inline"){let X;e[34]!==b?(X=b("gitView.branch.updateTitle"),e[34]=b,e[35]=X):X=e[35];let fe;e[36]!==X?(fe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:X}),e[36]=X,e[37]=fe):fe=e[37];let Re;e[38]!==b?(Re=b("gitView.branch.updateDescriptionPrefix"),e[38]=b,e[39]=Re):Re=e[39];let ve;e[40]!==H?(ve=t.jsx("span",{className:"font-mono text-foreground",children:H}),e[40]=H,e[41]=ve):ve=e[41];let xe;e[42]!==Re||e[43]!==ve?(xe=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Re," ",ve,"."]}),e[42]=Re,e[43]=ve,e[44]=xe):xe=e[44];let Le;e[45]!==fe||e[46]!==xe?(Le=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[fe,xe]})}),e[45]=fe,e[46]=xe,e[47]=Le):Le=e[47];let je;e[48]!==Oe?(je=t.jsx("div",{className:"pt-3",children:Oe}),e[48]=Oe,e[49]=je):je=e[49];let qe;return e[50]!==Le||e[51]!==je?(qe=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[Le,je]}),e[50]=Le,e[51]=je,e[52]=qe):qe=e[52],qe}let Ye;e[53]!==S?(Ye=S?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"git-merge",className:"size-4"}),e[53]=S,e[54]=Ye):Ye=e[54];let ke;e[55]!==b?(ke=b("gitView.branch.mergeRebase"),e[55]=b,e[56]=ke):ke=e[56];let Ae;e[57]!==ke?(Ae=t.jsx("span",{children:ke}),e[57]=ke,e[58]=Ae):Ae=e[58];let W;e[59]!==ne||e[60]!==_||e[61]!==Ye||e[62]!==Ae?(W=t.jsx(os,{asChild:!0,children:t.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",onClick:ne,disabled:_,children:[Ye,Ae]})}),e[59]=ne,e[60]=_,e[61]=Ye,e[62]=Ae,e[63]=W):W=e[63];let Qe;e[64]!==b?(Qe=b("gitView.branch.mergeRebaseTooltip"),e[64]=b,e[65]=Qe):Qe=e[65];let He;e[66]!==Qe?(He=t.jsx(ls,{sideOffset:8,children:Qe}),e[66]=Qe,e[67]=He):He=e[67];let Xe;e[68]!==W||e[69]!==He?(Xe=t.jsxs(is,{children:[W,He]}),e[68]=W,e[69]=He,e[70]=Xe):Xe=e[70];let Ee;e[71]!==Me||e[72]!==j?(Ee=X=>{X?j(!0):Me()},e[71]=Me,e[72]=j,e[73]=Ee):Ee=e[73];let Ze;e[74]!==b?(Ze=b("gitView.branch.updateTitle"),e[74]=b,e[75]=Ze):Ze=e[75];let Te;e[76]!==Ze?(Te=t.jsx(gt,{children:Ze}),e[76]=Ze,e[77]=Te):Te=e[77];let et;e[78]!==te||e[79]!==S||e[80]!==F||e[81]!==Y||e[82]!==b||e[83]!==H?(et=S?b(Y?te?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":F==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[b("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:H}),"."]}),e[78]=te,e[79]=S,e[80]=F,e[81]=Y,e[82]=b,e[83]=H,e[84]=et):et=e[84];let $e;e[85]!==et?($e=t.jsx(vt,{children:et}),e[85]=et,e[86]=$e):$e=e[86];let We;e[87]!==Te||e[88]!==$e?(We=t.jsxs(ft,{children:[Te,$e]}),e[87]=Te,e[88]=$e,e[89]=We):We=e[89];let Ue;e[90]!==Oe||e[91]!==We?(Ue=t.jsxs(ht,{className:"max-w-md",children:[We,Oe]}),e[90]=Oe,e[91]=We,e[92]=Ue):Ue=e[92];let Ve;e[93]!==q||e[94]!==Ee||e[95]!==Ue?(Ve=t.jsx(mt,{open:q,onOpenChange:Ee,children:Ue}),e[93]=q,e[94]=Ee,e[95]=Ue,e[96]=Ve):Ve=e[96];let Ke;return e[97]!==Xe||e[98]!==Ve?(Ke=t.jsxs(t.Fragment,{children:[Xe,Ve]}),e[97]=Xe,e[98]=Ve,e[99]=Ke):Ke=e[99],Ke};function jo(o){return o.status==="done"||o.status==="error"}function Co(o){return o.status==="error"}function So(o){return[o]}function No(o){return[o.label,o.branch,o.remote]}function ko(o,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[o.status==="running"&&t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),o.status==="done"&&t.jsx(E,{name:"check",className:"size-3.5 text-success"}),o.status==="error"&&t.jsx(E,{name:"close",className:"size-3.5 text-destructive"}),o.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:me("typography-micro",o.status==="error"&&"text-destructive",o.status==="done"&&"text-muted-foreground",o.status==="running"&&"text-foreground",o.status==="pending"&&"text-muted-foreground/60"),children:o.message})]},e)}function Vo(o){return o.stopPropagation()}const Ro=/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/i,Io=(o,e)=>{const a=[...o].sort((h,x)=>x.length-h.length);return e.flatMap(h=>{const x=a.find(p=>h.startsWith(`${p}/`));if(!x)return[];const d=h.slice(x.length+1);return d?[{kind:"remote",branch:d,destinationRef:`refs/remotes/${x}/${d}`,label:h,remote:x,sourceRef:`refs/heads/${d}`}]:[]})},Po=async({directory:o,git:e,runPlannedFetch:a,target:h})=>{if(h.kind==="local")return h.branch;await a(h);const d=(await e.getGitLog(o,{to:h.destinationRef,maxCount:1})).latest?.hash.trim();if(!d||!Ro.test(d))throw new we("invalid-terminal-state");return d},Fo=({runMutation:o,onMutationComplete:e,onMutationError:a,onPathsComplete:h,scheduleFlush:x})=>{const d=[];let p=!1;return{enqueue:f=>{const y=d[d.length-1];if(y?.directory===f.directory&&y.direction===f.direction){f.paths.forEach(B=>y.paths.add(B));return}d.push(f)},flush:()=>{if(p)return;const f=d.shift();if(!f)return;p=!0;const y={directory:f.directory,direction:f.direction,paths:Array.from(f.paths),rollback:f.rollback};(async()=>{try{await o(y),e(y)}catch(B){a(y,B)}finally{h(y.paths),p=!1,d.length>0&&x()}})()},clear:()=>{d.length=0},size:()=>d.length,isRunning:()=>p}},Do=(o,e,a)=>$a(o,e,h=>zi(h)&&Wa(h,a)),Bo=(o,e,a,h)=>Ua(o,e,a,x=>({id:"local-config",name:x.userName,...x,color:"info",icon:"user"}),h),Mo=(o,e,a,h)=>{if(e){const x=a.filter(d=>e.startsWith(`${d}/`)&&e.length>d.length+1).sort((d,p)=>p.length-d.length)[0];if(x)return{remoteName:x,destinationRef:`refs/heads/${e.slice(x.length+1)}`}}return h?{remoteName:h,destinationRef:`refs/heads/${o}`}:null},Oo=15e3,Ao=40,Eo=20,To=2,Qr={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:"},Xr=(o,e)=>{const a=o.toLowerCase(),h=/^([a-z]+)(?:\(.*\))?!?:/,x=a.match(h);if(x){const v=x[1],f=Qr[v];if(f)return e.find(y=>y.code===f)||null}const d=a.split(" ")[0],p=Qr[d];return p&&e.find(v=>v.code===p)||null},Lo=20,dt=new Map,zo=(o,e)=>{if(dt.delete(o),dt.set(o,e),dt.size>Lo){const a=dt.keys().next().value;a!==void 0&&dt.delete(a)}},Zr=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Go=o=>{const e=o.working_dir?.trim(),a=o.index?.trim();return!!(e||a==="?")},nu=({isActive:o})=>{const{t:e}=ot(),{git:a,sourceControl:h,runtime:x}=Ka(),d=qa(),p=Vi(),[v,f]=i.useState(null),[y,B]=i.useState(null),M=it(s=>s.currentSessionId),k=it(s=>s.newSessionDraft),G=it(s=>s.setDraftBootstrapPendingDirectory),S=it(s=>s.worktreeMetadata),L=it(s=>s.availableWorktrees),R=De(d),b=i.useMemo(()=>{if(!R)return;const s=L.find(n=>De(n.path)===R);if(s)return s;for(const n of S.values())if(De(n.path)===R)return n},[L,R,S]),q=i.useMemo(()=>{if(M)return S.get(M)??b;if(k?.open)return b},[M,b,k?.open,S]),{profiles:j,globalIdentity:F,defaultGitIdentityId:V,loadProfiles:P,loadGlobalIdentity:z,loadDefaultGitIdentityId:ee}=Ri(zr(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),{rootIsGitRepo:O,gitDirectory:r,nestedRepos:A}=Ja(d??null,{enabled:o,recheckOnOpen:!0}),J=Ya(r??null),w=Qa(r??null),_=Ii({directory:r,branch:w?.current,chooseContributor:p.choose}),H=Pi(r,a,h),Y=Xa(s=>M?s.getAttachment(M):void 0),te=Y?Za(Y):[],he=Y&&!Y.degraded&&!Y.legacy?Y.worktreeRoot??void 0:void 0,se=ji(d,q,w?.current??void 0),oe=ei(r??null),le=ti(r??null),m=si(r??null),c=ri(r??null),I=ni(r??null),{setActiveDirectory:T,ensureAll:ne,fetchStatus:Q,fetchBranches:Z,fetchLog:$,setLogMaxCount:Be,fetchIdentity:ce,prefetchDiffs:pe,clearDiffCache:Me,moveStatusPathsOptimistically:be,restoreStatus:Se,bumpIndexRevision:ae,ensureNestedRepos:_e,selectNestedRepo:Gt}=ai(zr(s=>({setActiveDirectory:s.setActiveDirectory,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,ensureNestedRepos:s.ensureNestedRepos,selectNestedRepo:s.selectNestedRepo}))),Ne=Et(s=>s.isMobile),Oe=Et(s=>s.openContextDiff),Ye=Et(s=>s.openContextSurface),[ke,Ae]=i.useState([]),W=ii(r,h,o),[Qe,He]=i.useState(!1),Xe=i.useMemo(()=>{const s=W.read;return!s?.binding||W.status!=="ready"||s.binding.state==="bound"?null:oi(s.binding)?e("gitView.identity.configChanged"):e("gitView.context.needsAttention")},[W.read,W.status,e]),Ee=W.read?.binding?.remotes[0]?.name??W.read?.repository.remotes.find(s=>s.name==="origin")?.name??W.read?.repository.remotes[0]?.name??"",Ze=i.useCallback(s=>{const n=W.read?.repository.remotes.find(l=>l.name===Ee);return n?Fi(s,li(n.fetch.displayUrl)):{applicable:!0}},[W.read,Ee]),Te=Mr(s=>s.entries),et=Mr(s=>s.refreshIdentityAccounts),$e=ts(s=>s.beginActiveContextsLoad),We=ts(s=>s.commitActiveContexts),Ue=ts(s=>s.releaseActiveContexts),Ve=i.useId();i.useEffect(()=>{if(!o||!d)return;const s=W.scope.runtimeKey,n=$e(s,d,Ve);return We(s,d,Ve,n,W.contexts.filter(l=>Or(Te[Ar(l)],l).connected)),()=>{Ue(s,d,Ve)}},[$e,W.contexts,W.scope.runtimeKey,We,d,o,Ue,Te,Ve]);const Ke=W.contexts[0]??null,X=w?.current??null,fe=ts(s=>!X||!Ke||!Or(Te[Ar(Ke)],Ke).connected?null:ci(s.entries,Ke,X)),Re=Et(s=>s.navigateToDiff),ve=i.useRef(null),xe=i.useRef(null),Le=i.useRef(null),je=i.useRef(!0);i.useEffect(()=>()=>{je.current=!1},[]);const qe=i.useCallback(()=>{ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null)},[]),cs=i.useCallback(s=>{qe(),ve.current=window.setTimeout(()=>{ve.current=null,De(s)===De(r)&&Q(s,a,{silent:!0})},Oo)},[qe,r,Q,a]);i.useEffect(()=>qe,[qe]);const Qs=i.useCallback(()=>{xe.current!==null&&(window.clearTimeout(xe.current),xe.current=null)},[]),_t=i.useCallback(()=>{xe.current===null&&(xe.current=window.setTimeout(()=>{xe.current=null,Le.current?.()},0))},[]),Xs=i.useCallback(async(s,n,l)=>{if(n==="stage"){if(a.stageGitFiles){await a.stageGitFiles(s,l);return}await Promise.all(l.map(u=>a.stageGitFile(s,u)));return}if(a.unstageGitFiles){await a.unstageGitFiles(s,l);return}await Promise.all(l.map(u=>a.unstageGitFile(s,u)))},[a]),tt=i.useMemo(()=>Fo({runMutation:({directory:s,direction:n,paths:l})=>Xs(s,n,l),onMutationComplete:({directory:s})=>{ae(s),cs(s)},onMutationError:({directory:s,direction:n,rollback:l},u)=>{l?.(),ae(s),cs(s);const N=e(n==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");g.error(u instanceof Error?u.message:N)},onPathsComplete:s=>{cr(n=>{const l=new Set(n);return s.forEach(u=>l.delete(u)),l})},scheduleFlush:_t}),[ae,Xs,_t,cs,e]);i.useEffect(()=>(Le.current=tt.flush,()=>{Le.current=null}),[tt]),i.useEffect(()=>()=>tt.clear(),[tt]),i.useEffect(()=>Qs,[Qs]),i.useEffect(()=>{if(!o)return;if(!d){f(null);return}const s=De(d)??d;f({directory:s,status:null});let n=!1,l=null;const u=async()=>{try{const N=await wi(d);if(n)return;f({directory:s,status:N.status}),N.status==="pending"&&(l=window.setTimeout(()=>{u()},500))}catch{n||f({directory:s,status:null})}};return u(),()=>{n=!0,l!==null&&window.clearTimeout(l)}},[o,d]);const Zs=De(k?.bootstrapPendingDirectory??null),an=!!(d&&Zs&&Zs===De(d)),on=ui(d??null),ye=De(d),us=v?.directory===ye?v.status:null,ds=!!(d&&(on||us==="pending"||an&&k?.pendingWorktreeRequestId)),er=!!(ye&&y?.directory===ye);i.useEffect(()=>{if(!ye)return;if(us==="failed"){G(null),B(n=>n?.directory===ye?null:n);return}if(ds){B(n=>n?.directory===ye&&n.status==="refreshing"?n:{directory:ye,status:"refreshing"});return}if(y?.directory!==ye||y.status!=="refreshing"||!r||!a)return;let s=!1;return Q(r,a,{force:!0,silent:!0,throwOnError:!0}).then(()=>{s||B(n=>n?.directory===ye?null:n)}).catch(()=>{s||B(n=>n?.directory===ye?{...n,status:"failed"}:n)}),()=>{s=!0}},[Q,a,r,ds,ye,us,y,G]);const ln=ds||er,ms=er&&y?.status==="failed",tr=i.useMemo(()=>r?dt.get(r)??null:null,[r]),Ct=di(s=>s.settingsGitmojiEnabled),[St,hs]=i.useState(null),{gitmojis:pt}=Qi(Ct);i.useEffect(()=>{const s=he||se?.projectDirectory;if(!s){hs(null);return}let n=!1;return mi(s).then(l=>{if(n)return;const u=l.trim();hs(u&&u!=="HEAD"?u:null)}).catch(()=>{n||hs(null)}),()=>{n=!0}},[he,se?.projectDirectory]);const[Nt,xt]=i.useState(tr?.commitMessage??""),[sr,cn]=i.useState([]),[un,fs]=i.useState(!1),rr=i.useRef(null),[nr,Ht]=i.useState(null),[dn,gs]=i.useState(!1),[ar,ir]=i.useState(null),[Ie,mn]=i.useState(25),[hn,or]=i.useState(!1),{triggerFireworks:fn}=Ci(),lr=i.useRef(new Map),$t=i.useRef(0),ps=i.useCallback(()=>{$t.current+=1,je.current&&or(!0)},[]),xs=i.useCallback(()=>{$t.current=Math.max(0,$t.current-1),je.current&&$t.current===0&&or(!1)},[]),[ys,Wt]=i.useState(new Set),[gn,cr]=i.useState(new Set),[ws,ur]=i.useState(!1),[pn,xn]=i.useState(0),[yn,dr]=i.useState(!1),[bs,vs]=i.useState(tr?.generatedHighlights??[]),wn=gn.size>0||tt.size()>0||tt.isRunning(),mr=i.useCallback(()=>{const s=rr.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),js=he||se?.projectDirectory||null,Cs=w?.current||null,bn=i.useMemo(()=>{const s=w?.tracking;return s?s.startsWith("origin/"):!0},[w?.tracking]),hr=i.useMemo(()=>{const s=se?.createdFromBranch,n=typeof s=="string"?s.trim():"",l=typeof w?.current=="string"?w.current.trim():"",u=typeof St=="string"?St.trim():"";return n?n===l&&n.startsWith("opencode/")&&u.length>0&&u!==n?u:n:u||l||"HEAD"},[se?.createdFromBranch,w,St]),Ut=i.useCallback(()=>{vs([])},[]),[Ss,vn]=i.useState(new Set),[Kt,jn]=i.useState(new Map),[qt,Ns]=i.useState(new Set),ks=i.useRef(Kt),kt=i.useRef(qt),[Cn,yt]=i.useState(null),[fr,gr]=i.useState(""),[ge,Jt]=i.useState(null),[Sn,pr]=i.useState(!1),[Nn,xr]=i.useState(!1),[kn,yr]=i.useState(null),[wr,br]=i.useState(null),[Vn,Yt]=i.useState([]),[Rn,wt]=i.useState(!1),[In,Vt]=i.useState([]),[Qt,Rt]=i.useState("merge"),[Pn,Vs]=i.useState(null),[Rs,vr]=i.useState(!1),[Is,Fn]=i.useState(100),[Dn,Bn]=i.useState(0),Pe=i.useMemo(()=>M?`openchamber.conflict:${M}`:null,[M]),jr=i.useCallback((s,n,l)=>{if(!Pe||typeof window>"u")return;const u={directory:s,conflictFiles:n,operation:l};window.localStorage.setItem(Pe,JSON.stringify(u))},[Pe]),Fe=i.useCallback(()=>{!Pe||typeof window>"u"||window.localStorage.removeItem(Pe)},[Pe]),Je=i.useCallback((s,n)=>{Vt(s),Rt(n),wt(!0),r&&jr(r,s,n)},[r,jr]);i.useEffect(()=>{if(!Pe||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Pe);if(s)try{const n=JSON.parse(s);if(n.directory!==r){window.localStorage.removeItem(Pe);return}Vt(n.conflictFiles??[]),Rt(n.operation??"merge"),wt(!0)}catch{window.localStorage.removeItem(Pe)}},[Pe,r]);const[Mn,Cr]=i.useState(!1),[Xt,It]=i.useState(null),[Ps,On]=i.useState("merge"),[Fs,An]=i.useState(""),[Ds,En]=i.useState(""),Tn=i.useCallback(s=>{hi(s).then(n=>{if(n.ok){g.success(e("gitView.toast.commitHashCopied"));return}g.error(e("gitView.toast.copyFailed"))})},[e]),Ln=i.useCallback(s=>{vn(n=>{const l=new Set(n);return l.has(s)?l.delete(s):l.add(s),l})},[]);i.useEffect(()=>{ks.current=Kt},[Kt]),i.useEffect(()=>{kt.current=qt},[qt]),i.useEffect(()=>{if(!r||!a)return;const s=Array.from(Ss).filter(l=>!ks.current.has(l)&&!kt.current.has(l));if(s.length===0)return;let n=!1;return Ns(l=>{const u=new Set(l);for(const N of s)u.add(N);return kt.current=u,u}),Promise.all(s.map(l=>a.getCommitFiles(r,l).then(u=>({hash:l,files:u.files})).catch(u=>(console.error("Failed to fetch commit files:",u),{hash:l,files:[]})))).then(l=>{n||(jn(u=>{const N=new Map(u);for(const{hash:C,files:D}of l)N.set(C,D);return ks.current=N,N}),Ns(u=>{const N=new Set(u);for(const{hash:C}of l)N.delete(C);return kt.current=N,N}))}),()=>{n=!0,Ns(l=>{let u=!1;const N=new Set(l);for(const C of s)N.delete(C)&&(u=!0);return u?(kt.current=N,N):l})}},[Ss,r,a]),i.useEffect(()=>{if(!r)return;const s=dt.get(r)??null;xt(s?.commitMessage??""),vs(s?.generatedHighlights??[])},[r]),i.useEffect(()=>{r&&zo(r,{directory:r,commitMessage:Nt,generatedHighlights:bs})},[Nt,r,bs]),i.useEffect(()=>{o&&(P(),z(),ee())},[o,P,z,ee]);const Zt=i.useCallback(async()=>{if(!r||!a?.getRemotes||J!==!0){Ae([]);return}try{const s=await a.getRemotes(r);je.current&&Ae(s)}catch{je.current&&Ae([])}},[r,a,J]);i.useEffect(()=>{o&&Zt()},[o,Zt]),i.useEffect(()=>{o&&d&&r&&(T(d),ne(r,a))},[o,d,r,T,ne,a]),i.useEffect(()=>{if(o&&r)return fi.onGitRefreshHint(s=>{De(s.directory)===De(r)&&(s.paths?.length&&Me(r,s.paths),Q(r,a,{silent:!0}))})},[o,Me,r,Q,a]);const re=i.useCallback(async(s=!0)=>{if(r)try{await Promise.all([Q(r,a),Z(r,a)])}catch(n){if(s){const l=n instanceof Error?n.message:e("gitView.toast.refreshRepositoryFailed");g.error(l)}}},[r,a,Q,Z,e]),ue=i.useCallback(async()=>{r&&await $(r,a,Ie)},[r,a,$,Ie]),lt=i.useCallback(async s=>{if(!r)return;const n=Promise.allSettled([Z(r,a),ue()]);s&&n.then(s),await Q(r,a).catch(()=>{})},[r,a,Z,Q,ue]),Bs=i.useCallback(async()=>{r&&await ce(r,a)},[r,a,ce]);i.useEffect(()=>{if(!o||!r||!a?.hasLocalIdentity||J!==!0)return;const s=typeof V=="string"?V.trim():"";if(!s||s==="global")return;const n=ut(),l=JSON.stringify([n,r]);if(lr.current.get(l)===s)return;let N=!1,C=!1;return(async()=>{try{const U=await a.hasLocalIdentity?.(r);if(N||ut()!==n||U===!0||(ps(),C=!0,await a.setGitIdentity(r,s),N||ut()!==n))return;lr.current.set(l,s),await Bs()}catch(U){!N&&ut()===n&&console.warn("Failed to auto-apply default git identity:",U)}finally{C&&xs()}})(),()=>{N=!0}},[o,ps,r,V,xs,a,J,Bs]);const st=i.useMemo(()=>w?[...w.files??[]].sort((n,l)=>n.path.localeCompare(l.path)):[],[w]),Ce=i.useMemo(()=>st.filter(Zr),[st]),Ms=i.useMemo(()=>st.filter(Go),[st]);i.useEffect(()=>{if(!o||!r||st.length===0)return;const s=[],n=new Set,l=N=>{!N||n.has(N)||(n.add(N),s.push(N))};if(Ce.forEach(N=>l(N.path)),sr.forEach(l),st.slice(0,Eo).forEach(N=>l(N.path)),s.length===0)return;const u=window.setTimeout(()=>{pe(r,a,s,{maxFiles:Ao})},120);return()=>{window.clearTimeout(u)}},[o,st,r,a,pe,Ce,sr]);const Pt=async(s,n,l=!1)=>{if(!r)return;const u=H.start();if(!u)return;Ht(s);const N=e(s==="fetch"?"gitView.sync.fetch":s==="pull"?"gitView.sync.pull":s==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let C=null;try{if(s==="sync"||s==="publish"){const D=await _.prepare(s==="publish"?"push":"sync",{forceChoose:l,onOperation:u.onOperation});C=vi(await D())}else if(n&&w)await Tr({action:s,directory:r,remoteName:n.name,status:w,sourceControl:h,git:a,onOperation:u.onOperation});else throw new we("tracking-required");if(!u.isCurrent())return;s==="fetch"&&n?g.success(e("gitView.toast.fetchedFromRemote",{name:n.name})):s==="pull"&&n?g.success(e("gitView.toast.pulledFromRemote",{name:n.name})):s==="sync"?g.success(C?.kind==="up-to-date"?e("gitView.toast.alreadyUpToDate"):C?.kind==="pulled"?e("gitView.toast.pulledFromRemote",{name:C.remoteName}):C?.kind==="pushed"?e("gitView.toast.pushedToUpstream",{name:C.remoteName}):e("gitView.toast.syncedChanges")):s==="publish"&&g.success(e("gitView.publish.succeeded")),await lt()}catch(D){if(D instanceof Ot||D instanceof Lr){if(D instanceof Ot&&D.read.availability==="available"&&g.error(e("gitView.toast.syncActionFailed",{action:N}),{description:D.message||void 0}),u.isCurrent()&&await lt(),u.isCurrent()&&D instanceof Ot&&D.read.availability==="available"&&D.read.operation.state==="conflicted"&&D.read.operation.error.code==="CONFLICT"){const Ge=((await a.getGitStatus(r).catch(()=>null))?.files??[]).filter(zs).map(ya=>ya.path);Ge.length>0&&Je(Ge,"merge")}return}if(D instanceof we&&D.code==="stale-runtime")return;if(D instanceof we&&_.errorMessage(D)){g.info(_.errorMessage(D));return}await lt();const U=D instanceof we?D.code==="contributor-publish-cancelled-after-update"?e("gitView.toast.contributorPublishCancelledAfterUpdate"):D.code==="contributor-publish-cancelled"?e("gitView.toast.contributorPublishCancelled"):e("gitView.toast.syncActionFailed",{action:N}):D instanceof Error?D.message:e("gitView.toast.syncActionFailed",{action:N});g.error(U)}finally{u.finish(),u.isCurrent()&&Ht(null)}},zn=i.useCallback(async s=>{if(!r)return;const n=s.name.trim();if(!n){g.error(e("gitView.toast.remoteNameRequired"));return}if(n==="origin"){g.error(e("gitView.toast.cannotRemoveOriginRemote"));return}yr(n);try{await a.removeRemote(r,{remote:n}),g.success(e("gitView.toast.removedRemote",{name:n})),await Promise.all([re(!1),Zt()])}catch(l){const u=l instanceof Error?l.message:`Failed to remove ${n}`;g.error(u)}finally{yr(null)}},[r,a,Zt,re,e]),Sr=async(s={})=>{if(!r)return;if(!Nt.trim()){g.error(e("gitView.toast.enterCommitMessage"));return}const n=Ce.map(C=>C.path).sort();if(n.length===0){g.error(e("gitView.toast.stageFileToCommit"));return}const l=s.pushAfter?"commitAndPush":"commit";ir(l);let u=null,N="pending";try{if(await a.createGitCommit(r,Nt.trim(),{files:n,stageFiles:[]}),N="local",ae(r),ae(r),g.success(e("gitView.toast.commitCreated")),xt(""),Ut(),s.pushAfter){if(u=H.start(),!u){g.warning(e("gitView.publish.commitKept")),await lt();return}const C=await _.prepare("push",{onOperation:u.onOperation});Ht("publish"),await C(),N="published",g.success(e("gitView.publish.succeeded")),fn()}await lt(()=>xn(C=>C+1))}catch(C){if(s.pushAfter&&N==="local"&&g.warning(e("gitView.publish.commitKept")),C instanceof Ot||C instanceof Lr){C instanceof Ot&&C.read.availability==="available"&&g.error(e("gitView.toast.pushFailed"),{description:C.message||void 0}),await lt();return}if(C instanceof we&&C.code==="stale-runtime")return;if(C instanceof we&&_.errorMessage(C)){g.info(_.errorMessage(C));return}s.pushAfter&&await lt();const D=C instanceof we?C.code==="contributor-publish-cancelled-after-update"?e("gitView.toast.contributorPublishCancelledAfterUpdate"):C.code==="contributor-publish-cancelled"?e("gitView.toast.contributorPublishCancelled"):e("gitView.toast.syncActionFailed",{action:e("gitView.sync.syncChanges")}):C instanceof Error?C.message:e("gitView.toast.createCommitFailed");g.error(D)}finally{u?.finish(),ir(null),s.pushAfter&&Ht(null)}},Gn=i.useCallback(async()=>{if(!r)return;const s=Ce.map(n=>n.path).sort();if(s.length===0){g.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),dr(!0);try{const{message:n}=await Er(r,s),l=n.subject?.trim()??"",u=Array.isArray(n.highlights)?n.highlights:[];if(l){let N=l;if(Ct&&pt.length>0){const C=Xr(l,pt);if(C){const{code:D,emoji:U}=C;!l.startsWith(D)&&!l.startsWith(U)&&(N=`${D} ${l}`)}}xt(N)}vs(u),mr()}catch(n){console.error("[git-generation][browser] GitView generate handler failed",{message:n instanceof Error?n.message:String(n),error:n});const l=n instanceof Error?n.message:e("gitView.toast.generateCommitMessageFailed");g.error(l)}finally{dr(!1)}},[r,Ce,Ct,pt,mr,e]),Os=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",_n=async s=>{if(!r||!w)return;const n=Ls(Y);if(n.length>0){g.error(e("gitView.toast.cannotCreateBranch",{reason:Os(n[0])}));return}const l=w.current??null;try{await a.createBranch(r,s,l??"HEAD"),g.success(e("gitView.toast.createdBranch",{name:s})),await a.checkoutBranch(r,s),await re(),await ue()}catch(u){if(u instanceof we&&u.code==="stale-runtime")return;const N=u instanceof Error?u.message:e("gitView.toast.createBranchFailed");throw g.error(N),u}},Hn=async(s,n)=>{if(!r)return;const l=Ls(Y);if(l.length>0){g.error(e("gitView.toast.cannotRenameBranch",{reason:Os(l[0])}));return}try{await a.renameBranch(r,s,n),g.success(e("gitView.toast.renamedBranch",{oldName:s,newName:n})),await re(),await ue()}catch(u){const N=u instanceof Error?u.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:n});g.error(N)}},$n=async s=>{if(!r)return;const n=Ls(Y);if(n.length>0){g.error(e("gitView.toast.cannotCheckout",{reason:Os(n[0])}));return}const l=s.replace(/^remotes\//,"");if(w?.current!==l){if((w?.files?.length??0)>0){It(l);return}await As(l)}},As=async s=>{if(!r)return;const n=s;try{const l=await a.checkoutBranch(r,n);g.success(e("gitView.toast.checkedOut",{name:l?.branch||n})),await re(),await ue()}catch(l){const u=l instanceof Error?l.message:e("gitView.toast.checkoutFailed",{name:n});g.error(u)}},Wn=async s=>{if(!r)return;const n=ut();ps();try{const l=await Ti({directory:r,identity:s,remoteName:Ee||null},{git:a,sourceControl:h});if(ut()!==n)return;l.status==="failed"?g.error(e("gitView.toast.applyIdentityFailed")):g.success(e("gitView.toast.appliedIdentity",{name:bi(s,e)})),await Bs()}catch(l){if(ut()!==n)return;const u=l instanceof Error?l.message:e("gitView.toast.applyIdentityFailed");g.error(u)}finally{xs()}},Ft=i.useMemo(()=>oe?.all?oe.all.filter(s=>!s.startsWith("remotes/")).sort():[],[oe]),Dt=i.useMemo(()=>oe?.all?oe.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[oe]),Un=i.useMemo(()=>Io(ke.map(s=>s.name),Dt),[ke,Dt]),rt=w?.current??null,Nr=i.useMemo(()=>{const s=W.contexts[0]?.primaryRemote;return s?oe?.defaultBranches?.[s]:void 0},[W.contexts,oe]),ct=i.useMemo(()=>Di({remoteNames:new Set(W.contexts[0]?.primaryRemote?[W.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(W.read?.repository.remotes.map(s=>s.name)??[]),localBranches:Ft,worktreeCreatedFromBranch:se?.createdFromBranch,rootBranchHint:St,defaultBranch:Nr,headBranch:rt,fallbackToConventional:!1}),[rt,Nr,W.contexts,Ft,W.read,St,se?.createdFromBranch]),Kn=i.useMemo(()=>{const s=W.contexts[0]?.primaryRemote,n=s?`${s}/${ct}`:null;return n&&Dt.includes(n)?n:ct},[ct,W.contexts,Dt]),kr=gi(),qn=i.useMemo(()=>Do(j,F,kr),[j,F,kr]),Vr=W.read?W.read.binding?.providers.find(s=>s.readiness==="ready")?.accountId??null:void 0,Jn=i.useMemo(()=>Bo(j,F,m,Vr),[Vr,m,j,F]),Yn=Ce.length,Qn=c||nr!==null||ar!==null,Xn=!!(se&&js&&Cs&&bn),Rr=!!rt,nt=Xn&&js&&Cs&&se?{repoRoot:js,sourceBranch:Cs,worktreeMetadata:se}:null;i.useEffect(()=>{if(!r||!a||!le?.all?.length||!rt||!ct||rt===ct){yt(null);return}let s=!1;return(async()=>{try{const l=await a.getGitLog(r,{from:ct,to:"HEAD",maxCount:Ie});if(s)return;const u=new Set((l?.all??[]).map(C=>C.hash).filter(C=>typeof C=="string"&&C.length>0));if(u.size===0){yt(null);return}const N=le.all.findIndex(C=>!u.has(C.hash));if(N===0){yt(null);return}if(N===-1){yt({insertBeforeIndex:le.all.length,branchName:rt,direction:"up"});return}yt({insertBeforeIndex:N,branchName:rt,direction:"up"})}catch{s||yt(null)}})(),()=>{s=!0}},[ct,rt,r,a,le,Ie]),i.useEffect(()=>{Vs(null)},[r]),i.useEffect(()=>{if(ge!=="graph"||!r){ge!=="graph"&&Vs(null);return}let s=!1;return vr(!0),a.getGitLog(r,{maxCount:Is,all:!0}).then(n=>{s||Vs(n)}).catch(n=>{console.error("Failed to fetch graph log:",n)}).finally(()=>{s||vr(!1)}),()=>{s=!0}},[ge,r,Is,Dn,a]);const Bt=i.useCallback((s,n)=>{if(!r||s.length===0)return;const l=Array.from(new Set(s));cr(N=>{const C=new Set(N);return l.forEach(D=>C.add(D)),C});const u=be(r,l,n);tt.enqueue({directory:r,direction:n,paths:new Set(l),rollback:()=>Se(r,u)}),_t()},[r,tt,be,Se,_t]),Es=i.useCallback(async s=>{if(r){Wt(n=>{const l=new Set(n);return l.add(s),l});try{await a.revertGitFile(r,s,{scope:"working"}),g.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(n){const l=n instanceof Error?n.message:e("gitView.toast.revertFailed");g.error(l)}finally{Wt(n=>{const l=new Set(n);return l.delete(s),l})}}},[r,re,a,e]),Mt=i.useCallback(async(s,n,l="all")=>{if(!r||s.length===0)return;const u=Array.from(new Set(s));if(ws||u.some(U=>ys.has(U)))return;const N=new Set(Ce.map(U=>U.path)),C=l==="all"&&u.some(U=>N.has(U));n&&ur(!0),Wt(U=>{const ie=new Set(U);return u.forEach(Ge=>ie.add(Ge)),ie});const D=[];try{if(await pi(u,To,async U=>{try{await a.revertGitFile(r,U,{scope:l})}catch(ie){D.push({path:U,message:ie instanceof Error?ie.message:e("gitView.toast.revertFailed")})}}),C&&D.length<u.length&&ae(r),await re(!1),D.length===0)g.success(u.length===1?e("gitView.toast.revertedFilesSingle",{count:u.length}):e("gitView.toast.revertedFilesPlural",{count:u.length}));else if(D.length===u.length)g.error(D[0]?.message||e("gitView.toast.revertFailed"));else{const U=u.length-D.length;g.warning(U===1?e("gitView.toast.revertedSomeSingle",{success:U,failed:D.length}):e("gitView.toast.revertedSomePlural",{success:U,failed:D.length}))}}finally{Wt(U=>{const ie=new Set(U);return u.forEach(Ge=>ie.delete(Ge)),ie}),n&&ur(!1)}},[ae,r,a,ws,re,ys,Ce,e]),Zn=i.useCallback(async s=>{await Mt(s,!0)},[Mt]),ea=i.useCallback(async s=>{await Mt(s,!1,"working")},[Mt]),Ts=i.useCallback((s,n)=>{if(d&&!Ne){Oe(d,s,n);return}Re(s,n)},[d,Ne,Re,Oe]),ta=i.useCallback(()=>gs(!0),[]),sa=i.useMemo(()=>{const s=[];return Ce.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Ce,statsScope:"staged",actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:n=>e("gitView.changes.unstageFileAria",{path:n}),onActionFile:n=>{Bt([n],"unstage")},onActionAll:n=>{Bt(n,"unstage")},onViewDiff:n=>Ts(n,!0),onRevertFile:Es,showRevertActions:!1,accent:!0}),Ms.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:Ms,statsScope:"working",actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:n=>e("gitView.changes.stageFileAria",{path:n}),onActionFile:n=>{Bt([n],"stage")},onActionAll:n=>{Bt(n,"stage")},onViewDiff:n=>Ts(n,!1),onRevertFile:Es}),s},[Es,Ts,Bt,Ce,e,Ms]),ra=i.useCallback(s=>{if(s.length===0)return;const n=s.map(l=>l.trim()).filter(Boolean);if(n.length===0){Ut();return}xt(l=>{const u=l.trim(),N=u.length>0?`
3
3
 
4
4
  `:"";return`${u}${N}${n.join(`
5
- `)}`.trim()}),Ut()},[Ut]),na=i.useCallback((s,n)=>{const l=n||s;xt(u=>{const N=u.trimStart();return N.startsWith(s)||n&&N.startsWith(n)?u:`${l.endsWith(" ")?l:`${l} `}${u}`.trimStart()}),gr(""),fs(!1)},[]),Ir=i.useCallback(s=>{const n=s instanceof Error?s.message.toLowerCase():"";return n.includes("uncommitted changes")||n.includes("local changes")||n.includes("your local changes would be overwritten")||n.includes("please commit your changes or stash them")||n.includes("cannot rebase: you have unstaged changes")||n.includes("error: cannot pull with rebase")},[]),bt=i.useCallback((s,n)=>{Yt(l=>[...l,{message:s,status:n,timestamp:Date.now()}])},[]),ze=i.useCallback((s,n)=>{Yt(l=>{if(l.length===0)return l;const u=[...l];return u[u.length-1]={...u[u.length-1],status:s,...n?{message:n}:{}},u})},[]),Pr=i.useCallback(()=>{Yt([])},[]),aa=i.useCallback(()=>{Yt([]),br(null)},[]),es=i.useCallback(async(s,n)=>{if(!r)return;const l=n.kind==="remote"?_.start():null;if(n.kind==="remote"&&!l)return;br(s),Pr();const u=w?.current;let N=n.branch;try{if(N=await Po({directory:r,git:a,target:n,runPlannedFetch:async C=>{if(bt(`Fetching ${C.label}...`,"running"),!w||!l)throw new we("branch-required");if(await Tr({action:"fetch",directory:r,fetchTarget:{remoteName:C.remote,sourceRef:C.sourceRef,destinationRef:C.destinationRef},remoteName:C.remote,status:w,sourceControl:h,git:a,onOperation:l.onOperation}),!l.isCurrent())throw new we("stale-runtime");ze("done",`Fetched ${C.label}`)}}),l&&!l.isCurrent())throw new we("stale-runtime");if(s==="merge"){bt(`Merging ${n.label} into ${u}...`,"running");const C=await a.merge(r,{branch:N});C.conflict?(ze("error","Merge conflicts detected"),Je(C.conflictFiles??[],"merge")):(ze("done",`Merged ${n.label} into ${u}`),Fe(),bt("Refreshing repository status...","running"),await re(),await ue(),ze("done","Repository status updated"))}else{bt(`Rebasing ${u} onto ${n.label}...`,"running");const C=await a.rebase(r,{onto:N});C.conflict?(ze("error","Rebase conflicts detected"),Je(C.conflictFiles??[],"rebase")):(ze("done",`Rebased ${u} onto ${n.label}`),Fe(),bt("Refreshing repository status...","running"),await re(),await ue(),ze("done","Repository status updated"))}}catch(C){if(Ir(C))ze("error","Uncommitted changes detected"),An(s),On(N),En(n.label),Cr(!0);else{const D=C instanceof we?e("gitView.toast.syncActionFailed",{action:e("gitView.sync.fetch")}):C instanceof Error?C.message:s==="merge"?`Failed to merge ${n.label}`:`Failed to rebase onto ${n.label}`;ze("error",D)}}finally{l?.finish()}},[r,a,h,w,_,re,ue,Ir,Je,Fe,bt,ze,Pr,e]),ia=i.useCallback(s=>{es("merge",s)},[es]),oa=i.useCallback(s=>{es("rebase",s)},[es]),la=i.useCallback(async()=>{if(r)try{Qt==="merge"?(await a.abortMerge(r),g.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),g.success(e("gitView.toast.rebaseAborted"))),Fe(),await re(),await ue()}catch(s){const n=s instanceof Error?s.message:`Failed to abort ${Qt}`;g.error(n)}},[r,a,Qt,re,ue,Fe,e]),ca=i.useMemo(()=>(w?.files??[]).filter(zs).length,[w?.files]),ua=i.useCallback(async()=>{if(r)try{const s=!!w?.mergeInProgress?.head,n=!!(w?.rebaseInProgress?.headName||w?.rebaseInProgress?.onto);if(s){const l=await a.continueMerge(r);l.conflict?(Je(l.conflictFiles??[],"merge"),g.error(e("gitView.toast.mergeConflictsDetected"))):(Fe(),g.success(e("gitView.toast.mergeCompleted")),await re(),await ue())}else if(n){const l=await a.continueRebase(r);l.conflict?(Je(l.conflictFiles??[],"rebase"),g.error(e("gitView.toast.rebaseConflictsDetected"))):(Fe(),g.success(e("gitView.toast.rebaseStepCompleted")),await re(),await ue())}}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");g.error(n)}},[r,a,w,re,ue,Je,Fe,e]),da=i.useCallback(async()=>{if(r)try{!!w?.mergeInProgress?.head?(await a.abortMerge(r),g.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),g.success(e("gitView.toast.rebaseAborted"))),Fe(),await re(),await ue()}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");g.error(n)}},[r,a,w,re,ue,Fe,e]),ma=i.useCallback(()=>{if(!r)return;const n=!!w?.mergeInProgress?.head?"merge":"rebase",l=(w?.files??[]).filter(zs).map(u=>u.path);l.length>0&&Vt(l),Rt(n),wt(!0)},[r,w]),ha=i.useCallback(async s=>{if(!r)return;const n=w?.current,l=Ps,u=Fs,N=Ds||u,C=(w?.files??[]).some(Zr);try{await a.stash(r,{message:`Auto-stash before ${l} with ${N}`,includeUntracked:!0}),C&&ae(r)}catch(ie){const Ge=ie instanceof Error?ie.message:"Failed to stash changes";g.error(Ge);return}let D=!1,U=!1;try{if(l==="merge"){const ie=await a.merge(r,{branch:u});ie.conflict?(U=!0,Vt(ie.conflictFiles??[]),Rt("merge"),wt(!0)):(D=!0,g.success(e("gitView.toast.mergedIntoBranch",{branch:N,currentBranch:n||""})))}else{const ie=await a.rebase(r,{onto:u});ie.conflict?(U=!0,Vt(ie.conflictFiles??[]),Rt("rebase"),wt(!0)):(D=!0,g.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:n||"",branch:N})))}if(s&&D)try{await a.stashPop(r),ae(r),g.success(e("gitView.toast.stashedRestored"))}catch(ie){const Ge=ie instanceof Error?ie.message:e("gitView.toast.restoreStashFailed");g.error(Ge)}else s&&U&&g.info(e("gitView.toast.restoreStashManually"));await re(),await ue()}catch(ie){if(s)try{await a.stashPop(r),ae(r)}catch{}throw ie}},[ae,r,a,w,Ps,Fs,Ds,re,ue,e]),fa=i.useCallback(s=>{mn(s),r&&(Be(r,s),$(r,a,s))},[r,$,a,Be]),ga=i.useCallback(s=>{Fn(s)},[]),pa=i.useCallback(()=>{Jt(null),r&&(Q(r,a),Z(r,a),$(r,a,Ie))},[r,Q,Z,$,Ie,a]),xa=i.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){g.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(Q(r,a),Z(r,a),$(r,a,Ie));return}Je(s.conflictFiles??[],s.operation)}},[e,Je,r,Q,Z,$,Ie,a]);return d?ln?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[ms?null:t.jsx(E,{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(ms?"gitView.toast.refreshRepositoryFailed":"gitView.empty.worktreeSetupInProgress")}),ms?t.jsx(K,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:()=>{ye&&B({directory:ye,status:"refreshing"})},children:e("gitView.empty.retryDiscovery")}):t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):J===null||J===!0&&!w?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(E,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):J===!1?t.jsx(Bi,{root:d,rootIsGitRepo:A,resolvedIsGitRepo:J,nestedRepos:O,onRetryDiscovery:()=>{d&&He(d,{force:!0})},emptyStateFooter:te.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):void 0}):t.jsxs("div",{className:me("flex h-full flex-col overflow-hidden"),children:[t.jsx(Mi,{directory:r??"",status:w,localBranches:Ft,remoteBranches:Dt,branchInfo:oe?.branches,syncAction:_.entry?.executing?nr:null,operationBlocked:_.blocked,remotes:ke,onFetch:s=>Pt("fetch",s),onPull:s=>Pt("pull",s),onSync:s=>Pt("sync",s),onPublish:()=>{Pt("publish")},onChooseSyncTargets:()=>{Pt("sync",void 0,!0)},onRemoveRemote:zn,removingRemoteName:kn,onCheckoutBranch:$n,onCreateBranch:Hn,onRenameBranch:_n,activeIdentityProfile:Jn,availableIdentities:qn,onSelectIdentity:Wn,isApplyingIdentity:hn,identityAttention:Xe,identityApplicability:Ze,onConfigureRepository:x.isVSCode?void 0:()=>_e(!0),onIdentityMenuOpen:()=>{et(h,j.map(s=>s.account))},isWorktreeMode:!!se,onOpenHistory:()=>Jt("history"),onOpenGraph:()=>Jt("graph"),onOpenStashes:ta,onOpenUpdateBranch:Rr?()=>pr(!0):void 0,onOpenReintegrateCommits:nt?()=>xr(!0):void 0,pullRequest:fe?.changeRequest??fe?.pr??null,pullRequestProvider:fe?.changeRequest?.provider??null,prChecks:fe?.ci?.summary??fe?.checks??null,onOpenPullRequest:r?()=>Ye(r,"pr"):void 0,repositoryOptions:r!==d&&Array.isArray(O)?O:void 0,selectedRepository:r!==d?r:null,onSelectRepository:r!==d&&d?s=>Gt(d,s):void 0,repositoryRoot:r!==d?d:void 0}),x.isVSCode?null:t.jsx(Gi,{open:Qe,onOpenChange:_e,directory:o?r??"":""}),t.jsx(Ai,{className:"mx-4 mt-3",entry:_.entry,onRefresh:()=>{_.refresh()},onCancel:()=>{_.cancel()}}),d&&(w?.mergeInProgress?.head||w?.rebaseInProgress?.headName||w?.rebaseInProgress?.onto)&&t.jsx(Hi,{mergeInProgress:w?.mergeInProgress,rebaseInProgress:w?.rebaseInProgress,onContinue:ua,onAbort:da,onResolveWithAI:ma,conflictCount:ca,isLoading:c}),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:me("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(tn,{as:xi,ref:rr,outerClassName:"flex-1 min-h-0",className:me("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:(st?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(_i,{groups:sa,diffStats:w?.diffStats,revertingPaths:ys,isRevertingAll:ws,onVisiblePathsChange:cn,onRevertAll:Zn,onRevertDirectory:ea,headerBackgroundClassName:"bg-background"})}),t.jsx($i,{stagedCount:Yn,commitMessage:Nt,onCommitMessageChange:xt,generatedHighlights:bs,onInsertHighlights:ra,onGenerateMessage:Gn,isGeneratingMessage:yn,onCommit:()=>Sr({pushAfter:!1}),onCommitAndPush:()=>Sr({pushAfter:!0}),commitAction:ar,networkOperationBlocked:_.blocked,hasPendingIndexMutation:wn,gitmojiEnabled:Ct,onOpenGitmojiPicker:()=>fs(!0)})]}):t.jsx(ao,{onOpenStashes:()=>gs(!0)})})})})})}),t.jsx(mt,{open:Sn,onOpenChange:s=>{!s&&wr!==null||pr(s)},children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(gt,{children:e("gitView.branch.updateTitle")}),t.jsxs(vt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:w?.current??""}),"."]})]}),Rr?t.jsx(vo,{mode:"bare",currentBranch:w?.current,localBranches:Ft,remoteBranches:Un,defaultTargetBranch:Kn,onMerge:ia,onRebase:oa,disabled:Qn||_.blocked,isOperating:wr!==null,operationLogs:Vn,onOperationComplete:aa}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(mt,{open:Nn,onOpenChange:xr,children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(gt,{children:e("gitView.integrate.title")}),t.jsx(vt,{children:nt?t.jsxs("span",{className:"font-mono text-foreground",children:[nt.sourceBranch," → ",hr]}):null})]}),nt?t.jsx(ro,{repoRoot:nt.repoRoot,sourceBranch:nt.sourceBranch,worktreeMetadata:nt.worktreeMetadata,localBranches:Ft,defaultTargetBranch:hr,refreshKey:pn,showHeader:!1,onRefresh:()=>{r&&(Q(r,a),Z(r,a),$(r,a,Ie))}},nt.worktreeMetadata.path):null]})}),t.jsx(mt,{open:ge!==null,onOpenChange:s=>{s||Jt(null)},children:t.jsxs(ht,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(gt,{children:e(ge==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(K,{type:"button",variant:"ghost",size:"sm",className:"me-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(ge==="graph"){Bn(s=>s+1);return}r&&$(r,a,Ie)},disabled:ge==="graph"?Rs:I,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(E,{name:"refresh",className:me("size-4",(ge==="graph"?Rs:I)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(vt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(go,{mode:ge==="graph"?"graph":"history",log:ge==="graph"?Pn??le:le,isLogLoading:ge==="graph"&&Rs||I,logMaxCount:ge==="graph"?Is:Ie,onLogMaxCountChange:ge==="graph"?ga:fa,expandedCommitHashes:Ss,onToggleCommit:Ln,commitFilesMap:Kt,loadingCommitHashes:qt,onCopyHash:Tn,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:ge==="graph"?null:Cn,onConflict:ge==="graph"?xa:void 0,onActionSuccess:ge==="graph"?pa:void 0})})]})}),t.jsx(no,{open:dn,onOpenChange:gs,directory:r,hasUncommittedChanges:(w?.files?.length??0)>0,hasStagedChanges:Ce.length>0,uncommittedFileCount:w?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&ae(r),await re(!1),await ue()}}),t.jsx(mt,{open:un,onOpenChange:fs,children:t.jsxs(ht,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(ft,{className:"px-4 pt-4",children:t.jsx(gt,{children:e("gitView.gitmoji.title")})}),t.jsxs(Ks,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(qs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:fr,onValueChange:gr}),t.jsxs(Js,{children:[t.jsx(Ys,{children:e("gitView.gitmoji.empty")}),t.jsx(ns,{children:Lt(pt,fr,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(as,{onSelect:()=>na(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))})]})]})]})}),H.context?t.jsx(Oi,{context:H.context,onSelect:H.settle}):null,H.confirmDialog,t.jsx(Ei,{candidates:p.candidates,onSelect:p.settle}),r&&t.jsx(Wi,{open:Rn,onOpenChange:wt,conflictFiles:In,directory:r,operation:Qt,onAbort:la,onClearState:Fe}),t.jsx(Ui,{open:Xt!==null,onOpenChange:s=>{s||It(null)},targetBranch:Xt??"",changedFileCount:w?.files?.length??0,onCommitAndSwitch:async(s,n)=>{const l=Xt;if(!l||!r)return;const u=w?.current??null;await a.createGitCommit(r,s,{addAll:!0}),ae(r);let N=null;if(n){const C=W.read?.repository.remotes.map(U=>U.name)??ke.map(U=>U.name),D=u?Mo(u,w?.tracking,C,W.contexts[0]?.primaryRemote??C[0]??null):null;try{if(!D||!u)throw new Error(e("mobile.changes.noRemote"));await yi({directory:r,branch:u,remoteName:D.remoteName,sourceControl:h,git:a,choose:p.choose,destinationRef:D.destinationRef}),N=D.remoteName}catch(U){console.error("Push after commit failed:",U),g.error(e("gitView.dirtySwitch.pushFailed")),await re(),await ue(),It(null);return}}g.success(N?e("gitView.toast.pushedToUpstream",{name:N}):u?e("gitView.dirtySwitch.committedNotPushed",{branch:u}):e("gitView.toast.commitCreated")),await re(),await ue(),It(null),await Os(l)},onGenerateMessage:async()=>{if(!r)return"";const s=(w?.files??[]).map(u=>u.path).sort(),{message:n}=await Er(r,s),l=n.subject?.trim()??"";if(l&&Ct&&pt.length>0){const u=Xr(l,pt);if(u&&!l.startsWith(u.code)&&!l.startsWith(u.emoji))return`${u.code} ${l}`}return l},onRevertAndSwitch:async()=>{const s=Xt;if(!s||!r)return;const n=(w?.files??[]).map(u=>u.path);await Mt(n,!0,"all");const l=await a.getGitStatus(r);if(!l.isClean&&(l.files?.length??0)>0){g.error(e("gitView.dirtySwitch.revertIncomplete"));return}It(null),await Os(s)}}),t.jsx(bo,{open:Mn,onOpenChange:Cr,operation:Ps,targetBranch:Ds||Fs,onConfirm:ha})]}):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{nu as GitView};
5
+ `)}`.trim()}),Ut()},[Ut]),na=i.useCallback((s,n)=>{const l=n||s;xt(u=>{const N=u.trimStart();return N.startsWith(s)||n&&N.startsWith(n)?u:`${l.endsWith(" ")?l:`${l} `}${u}`.trimStart()}),gr(""),fs(!1)},[]),Ir=i.useCallback(s=>{const n=s instanceof Error?s.message.toLowerCase():"";return n.includes("uncommitted changes")||n.includes("local changes")||n.includes("your local changes would be overwritten")||n.includes("please commit your changes or stash them")||n.includes("cannot rebase: you have unstaged changes")||n.includes("error: cannot pull with rebase")},[]),bt=i.useCallback((s,n)=>{Yt(l=>[...l,{message:s,status:n,timestamp:Date.now()}])},[]),ze=i.useCallback((s,n)=>{Yt(l=>{if(l.length===0)return l;const u=[...l];return u[u.length-1]={...u[u.length-1],status:s,...n?{message:n}:{}},u})},[]),Pr=i.useCallback(()=>{Yt([])},[]),aa=i.useCallback(()=>{Yt([]),br(null)},[]),es=i.useCallback(async(s,n)=>{if(!r)return;const l=n.kind==="remote"?H.start():null;if(n.kind==="remote"&&!l)return;br(s),Pr();const u=w?.current;let N=n.branch;try{if(N=await Po({directory:r,git:a,target:n,runPlannedFetch:async C=>{if(bt(`Fetching ${C.label}...`,"running"),!w||!l)throw new we("branch-required");if(await Tr({action:"fetch",directory:r,fetchTarget:{remoteName:C.remote,sourceRef:C.sourceRef,destinationRef:C.destinationRef},remoteName:C.remote,status:w,sourceControl:h,git:a,onOperation:l.onOperation}),!l.isCurrent())throw new we("stale-runtime");ze("done",`Fetched ${C.label}`)}}),l&&!l.isCurrent())throw new we("stale-runtime");if(s==="merge"){bt(`Merging ${n.label} into ${u}...`,"running");const C=await a.merge(r,{branch:N});C.conflict?(ze("error","Merge conflicts detected"),Je(C.conflictFiles??[],"merge")):(ze("done",`Merged ${n.label} into ${u}`),Fe(),bt("Refreshing repository status...","running"),await re(),await ue(),ze("done","Repository status updated"))}else{bt(`Rebasing ${u} onto ${n.label}...`,"running");const C=await a.rebase(r,{onto:N});C.conflict?(ze("error","Rebase conflicts detected"),Je(C.conflictFiles??[],"rebase")):(ze("done",`Rebased ${u} onto ${n.label}`),Fe(),bt("Refreshing repository status...","running"),await re(),await ue(),ze("done","Repository status updated"))}}catch(C){if(Ir(C))ze("error","Uncommitted changes detected"),On(s),An(N),En(n.label),Cr(!0);else{const D=C instanceof we?e("gitView.toast.syncActionFailed",{action:e("gitView.sync.fetch")}):C instanceof Error?C.message:s==="merge"?`Failed to merge ${n.label}`:`Failed to rebase onto ${n.label}`;ze("error",D)}}finally{l?.finish()}},[r,a,h,w,H,re,ue,Ir,Je,Fe,bt,ze,Pr,e]),ia=i.useCallback(s=>{es("merge",s)},[es]),oa=i.useCallback(s=>{es("rebase",s)},[es]),la=i.useCallback(async()=>{if(r)try{Qt==="merge"?(await a.abortMerge(r),g.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),g.success(e("gitView.toast.rebaseAborted"))),Fe(),await re(),await ue()}catch(s){const n=s instanceof Error?s.message:`Failed to abort ${Qt}`;g.error(n)}},[r,a,Qt,re,ue,Fe,e]),ca=i.useMemo(()=>(w?.files??[]).filter(zs).length,[w?.files]),ua=i.useCallback(async()=>{if(r)try{const s=!!w?.mergeInProgress?.head,n=!!(w?.rebaseInProgress?.headName||w?.rebaseInProgress?.onto);if(s){const l=await a.continueMerge(r);l.conflict?(Je(l.conflictFiles??[],"merge"),g.error(e("gitView.toast.mergeConflictsDetected"))):(Fe(),g.success(e("gitView.toast.mergeCompleted")),await re(),await ue())}else if(n){const l=await a.continueRebase(r);l.conflict?(Je(l.conflictFiles??[],"rebase"),g.error(e("gitView.toast.rebaseConflictsDetected"))):(Fe(),g.success(e("gitView.toast.rebaseStepCompleted")),await re(),await ue())}}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");g.error(n)}},[r,a,w,re,ue,Je,Fe,e]),da=i.useCallback(async()=>{if(r)try{!!w?.mergeInProgress?.head?(await a.abortMerge(r),g.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),g.success(e("gitView.toast.rebaseAborted"))),Fe(),await re(),await ue()}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");g.error(n)}},[r,a,w,re,ue,Fe,e]),ma=i.useCallback(()=>{if(!r)return;const n=!!w?.mergeInProgress?.head?"merge":"rebase",l=(w?.files??[]).filter(zs).map(u=>u.path);l.length>0&&Vt(l),Rt(n),wt(!0)},[r,w]),ha=i.useCallback(async s=>{if(!r)return;const n=w?.current,l=Ps,u=Fs,N=Ds||u,C=(w?.files??[]).some(Zr);try{await a.stash(r,{message:`Auto-stash before ${l} with ${N}`,includeUntracked:!0}),C&&ae(r)}catch(ie){const Ge=ie instanceof Error?ie.message:"Failed to stash changes";g.error(Ge);return}let D=!1,U=!1;try{if(l==="merge"){const ie=await a.merge(r,{branch:u});ie.conflict?(U=!0,Vt(ie.conflictFiles??[]),Rt("merge"),wt(!0)):(D=!0,g.success(e("gitView.toast.mergedIntoBranch",{branch:N,currentBranch:n||""})))}else{const ie=await a.rebase(r,{onto:u});ie.conflict?(U=!0,Vt(ie.conflictFiles??[]),Rt("rebase"),wt(!0)):(D=!0,g.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:n||"",branch:N})))}if(s&&D)try{await a.stashPop(r),ae(r),g.success(e("gitView.toast.stashedRestored"))}catch(ie){const Ge=ie instanceof Error?ie.message:e("gitView.toast.restoreStashFailed");g.error(Ge)}else s&&U&&g.info(e("gitView.toast.restoreStashManually"));await re(),await ue()}catch(ie){if(s)try{await a.stashPop(r),ae(r)}catch{}throw ie}},[ae,r,a,w,Ps,Fs,Ds,re,ue,e]),fa=i.useCallback(s=>{mn(s),r&&(Be(r,s),$(r,a,s))},[r,$,a,Be]),ga=i.useCallback(s=>{Fn(s)},[]),pa=i.useCallback(()=>{Jt(null),r&&(Q(r,a),Z(r,a),$(r,a,Ie))},[r,Q,Z,$,Ie,a]),xa=i.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){g.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(Q(r,a),Z(r,a),$(r,a,Ie));return}Je(s.conflictFiles??[],s.operation)}},[e,Je,r,Q,Z,$,Ie,a]);return d?ln?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[ms?null:t.jsx(E,{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(ms?"gitView.toast.refreshRepositoryFailed":"gitView.empty.worktreeSetupInProgress")}),ms?t.jsx(K,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:()=>{ye&&B({directory:ye,status:"refreshing"})},children:e("gitView.empty.retryDiscovery")}):t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):J===null||J===!0&&!w?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(E,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):J===!1?t.jsx(Bi,{root:d,rootIsGitRepo:O,resolvedIsGitRepo:J,nestedRepos:A,onRetryDiscovery:()=>{d&&_e(d,{force:!0})},emptyStateFooter:te.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):void 0}):t.jsxs("div",{className:me("flex h-full flex-col overflow-hidden"),children:[t.jsx(Mi,{directory:r??"",status:w,localBranches:Ft,remoteBranches:Dt,branchInfo:oe?.branches,syncAction:H.entry?.executing?nr:null,operationBlocked:H.blocked,remotes:ke,onFetch:s=>Pt("fetch",s),onPull:s=>Pt("pull",s),onSync:s=>Pt("sync",s),onPublish:()=>{Pt("publish")},onChooseSyncTargets:()=>{Pt("sync",void 0,!0)},onRemoveRemote:zn,removingRemoteName:kn,onCheckoutBranch:$n,onCreateBranch:_n,onRenameBranch:Hn,activeIdentityProfile:Jn,availableIdentities:qn,onSelectIdentity:Wn,isApplyingIdentity:hn,identityAttention:Xe,identityApplicability:Ze,onConfigureRepository:x.isVSCode?void 0:()=>He(!0),onIdentityMenuOpen:()=>{et(h,j.map(s=>s.account))},isWorktreeMode:!!se,onOpenHistory:()=>Jt("history"),onOpenGraph:()=>Jt("graph"),onOpenStashes:ta,onOpenUpdateBranch:Rr?()=>pr(!0):void 0,onOpenReintegrateCommits:nt?()=>xr(!0):void 0,pullRequest:fe?.changeRequest??fe?.pr??null,pullRequestProvider:fe?.changeRequest?.provider??null,prChecks:fe?.ci?.summary??fe?.checks??null,onOpenPullRequest:r?()=>Ye(r,"pr"):void 0,repositoryOptions:r!==d&&Array.isArray(A)?A:void 0,selectedRepository:r!==d?r:null,onSelectRepository:r!==d&&d?s=>Gt(d,s):void 0,repositoryRoot:r!==d?d:void 0}),x.isVSCode?null:t.jsx(Gi,{open:Qe,onOpenChange:He,directory:o?r??"":""}),t.jsx(Oi,{className:"mx-4 mt-3",entry:H.entry,onRefresh:()=>{H.refresh()},onCancel:()=>{H.cancel()}}),d&&(w?.mergeInProgress?.head||w?.rebaseInProgress?.headName||w?.rebaseInProgress?.onto)&&t.jsx(_i,{mergeInProgress:w?.mergeInProgress,rebaseInProgress:w?.rebaseInProgress,onContinue:ua,onAbort:da,onResolveWithAI:ma,conflictCount:ca,isLoading:c}),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:me("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(tn,{as:xi,ref:rr,outerClassName:"flex-1 min-h-0",className:me("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:(st?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Hi,{groups:sa,diffStats:w?.diffStats,revertingPaths:ys,isRevertingAll:ws,onVisiblePathsChange:cn,onRevertAll:Zn,onRevertDirectory:ea,headerBackgroundClassName:"bg-background"})}),t.jsx($i,{stagedCount:Yn,commitMessage:Nt,onCommitMessageChange:xt,generatedHighlights:bs,onInsertHighlights:ra,onGenerateMessage:Gn,isGeneratingMessage:yn,onCommit:()=>Sr({pushAfter:!1}),onCommitAndPush:()=>Sr({pushAfter:!0}),commitAction:ar,networkOperationBlocked:H.blocked,hasPendingIndexMutation:wn,gitmojiEnabled:Ct,onOpenGitmojiPicker:()=>fs(!0)})]}):t.jsx(ao,{onOpenStashes:()=>gs(!0)})})})})})}),t.jsx(mt,{open:Sn,onOpenChange:s=>{!s&&wr!==null||pr(s)},children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(gt,{children:e("gitView.branch.updateTitle")}),t.jsxs(vt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:w?.current??""}),"."]})]}),Rr?t.jsx(vo,{mode:"bare",currentBranch:w?.current,localBranches:Ft,remoteBranches:Un,defaultTargetBranch:Kn,onMerge:ia,onRebase:oa,disabled:Qn||H.blocked,isOperating:wr!==null,operationLogs:Vn,onOperationComplete:aa}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(mt,{open:Nn,onOpenChange:xr,children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(gt,{children:e("gitView.integrate.title")}),t.jsx(vt,{children:nt?t.jsxs("span",{className:"font-mono text-foreground",children:[nt.sourceBranch," → ",hr]}):null})]}),nt?t.jsx(ro,{repoRoot:nt.repoRoot,sourceBranch:nt.sourceBranch,worktreeMetadata:nt.worktreeMetadata,localBranches:Ft,defaultTargetBranch:hr,refreshKey:pn,showHeader:!1,onRefresh:()=>{r&&(Q(r,a),Z(r,a),$(r,a,Ie))}},nt.worktreeMetadata.path):null]})}),t.jsx(mt,{open:ge!==null,onOpenChange:s=>{s||Jt(null)},children:t.jsxs(ht,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(gt,{children:e(ge==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(K,{type:"button",variant:"ghost",size:"sm",className:"me-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(ge==="graph"){Bn(s=>s+1);return}r&&$(r,a,Ie)},disabled:ge==="graph"?Rs:I,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(E,{name:"refresh",className:me("size-4",(ge==="graph"?Rs:I)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(vt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(go,{mode:ge==="graph"?"graph":"history",log:ge==="graph"?Pn??le:le,isLogLoading:ge==="graph"&&Rs||I,logMaxCount:ge==="graph"?Is:Ie,onLogMaxCountChange:ge==="graph"?ga:fa,expandedCommitHashes:Ss,onToggleCommit:Ln,commitFilesMap:Kt,loadingCommitHashes:qt,onCopyHash:Tn,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:ge==="graph"?null:Cn,onConflict:ge==="graph"?xa:void 0,onActionSuccess:ge==="graph"?pa:void 0})})]})}),t.jsx(no,{open:dn,onOpenChange:gs,directory:r,hasUncommittedChanges:(w?.files?.length??0)>0,hasStagedChanges:Ce.length>0,uncommittedFileCount:w?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&ae(r),await re(!1),await ue()}}),t.jsx(mt,{open:un,onOpenChange:fs,children:t.jsxs(ht,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(ft,{className:"px-4 pt-4",children:t.jsx(gt,{children:e("gitView.gitmoji.title")})}),t.jsxs(Ks,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(qs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:fr,onValueChange:gr}),t.jsxs(Js,{children:[t.jsx(Ys,{children:e("gitView.gitmoji.empty")}),t.jsx(ns,{children:Lt(pt,fr,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(as,{onSelect:()=>na(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))})]})]})]})}),_.context?t.jsx(Ai,{context:_.context,onSelect:_.settle}):null,_.confirmDialog,t.jsx(Ei,{candidates:p.candidates,onSelect:p.settle}),r&&t.jsx(Wi,{open:Rn,onOpenChange:wt,conflictFiles:In,directory:r,operation:Qt,onAbort:la,onClearState:Fe}),t.jsx(Ui,{open:Xt!==null,onOpenChange:s=>{s||It(null)},targetBranch:Xt??"",changedFileCount:w?.files?.length??0,onCommitAndSwitch:async(s,n)=>{const l=Xt;if(!l||!r)return;const u=w?.current??null;await a.createGitCommit(r,s,{addAll:!0}),ae(r);let N=null;if(n){const C=W.read?.repository.remotes.map(U=>U.name)??ke.map(U=>U.name),D=u?Mo(u,w?.tracking,C,W.contexts[0]?.primaryRemote??C[0]??null):null;try{if(!D||!u)throw new Error(e("mobile.changes.noRemote"));await yi({directory:r,branch:u,remoteName:D.remoteName,sourceControl:h,git:a,choose:p.choose,destinationRef:D.destinationRef}),N=D.remoteName}catch(U){console.error("Push after commit failed:",U),g.error(e("gitView.dirtySwitch.pushFailed")),await re(),await ue(),It(null);return}}g.success(N?e("gitView.toast.pushedToUpstream",{name:N}):u?e("gitView.dirtySwitch.committedNotPushed",{branch:u}):e("gitView.toast.commitCreated")),await re(),await ue(),It(null),await As(l)},onGenerateMessage:async()=>{if(!r)return"";const s=(w?.files??[]).map(u=>u.path).sort(),{message:n}=await Er(r,s),l=n.subject?.trim()??"";if(l&&Ct&&pt.length>0){const u=Xr(l,pt);if(u&&!l.startsWith(u.code)&&!l.startsWith(u.emoji))return`${u.code} ${l}`}return l},onRevertAndSwitch:async()=>{const s=Xt;if(!s||!r)return;const n=(w?.files??[]).map(u=>u.path);await Mt(n,!0,"all");const l=await a.getGitStatus(r);if(!l.isClean&&(l.files?.length??0)>0){g.error(e("gitView.dirtySwitch.revertIncomplete"));return}It(null),await As(s)}}),t.jsx(bo,{open:Mn,onOpenChange:Cr,operation:Ps,targetBranch:Ds||Fs,onConfirm:ha})]}):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{nu as GitView};