@openchamber/web 1.24.0 → 1.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/bin/cli.test.js +7 -6
  2. package/bin/lib/cli-http.js +5 -1
  3. package/dist/assets/{CodeMirrorCommentWidgets-C9kV-n7r.js → CodeMirrorCommentWidgets-DvUH815P.js} +1 -1
  4. package/dist/assets/DiffView-DkC3xlRJ.js +4 -0
  5. package/dist/assets/{FilesView-vjJx7VaM.js → FilesView-D0bM9FVB.js} +6 -6
  6. package/dist/assets/GitView-Bxuv3dfP.js +6 -0
  7. package/dist/assets/GuestAttachDialog-B0u3Q5uO.js +1 -0
  8. package/dist/assets/{JsonTreeView-D_4G5X6-.js → JsonTreeView-BBVPFM5K.js} +1 -1
  9. package/dist/assets/{LinearIssuesView-1uKhePfH.js → LinearIssuesView-UI1FcSC8.js} +1 -1
  10. package/dist/assets/{MarkdownImageGallery-Ix7N_2wp.js → MarkdownImageGallery-CUJxH8Le.js} +1 -1
  11. package/dist/assets/{MarkdownRendererImpl-Deel_y5S.js → MarkdownRendererImpl-D5BZOg8X.js} +1 -1
  12. package/dist/assets/{OnboardingScreen-ToIakxb_.js → OnboardingScreen-5Gou9cGD.js} +1 -1
  13. package/dist/assets/{PatchDiff-BjMgezr1.js → PatchDiff-C4rE5k6z.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-53Ghfnlr.js → PierreDiffViewer-ByRVu6ss.js} +1 -1
  15. package/dist/assets/{PlanView-BGAzxDwD.js → PlanView-u2yi5XGJ.js} +4 -4
  16. package/dist/assets/PluginPane-QxjsKYeO.js +3 -0
  17. package/dist/assets/SettingsView-Fo5ZqMaT.js +29 -0
  18. package/dist/assets/SettingsWindow-HVDVANjJ.js +1 -0
  19. package/dist/assets/{SubmoduleDiffSummary--YFqK6Ih.js → SubmoduleDiffSummary-D3hzkybB.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-DRWBvdaJ.js → ToolOutputDialog-3J6IRayW.js} +6 -6
  21. package/dist/assets/{ToolPartDiffPreview-BxZJCU28.js → ToolPartDiffPreview-DarxPjSd.js} +1 -1
  22. package/dist/assets/{VirtualizedFileDiff-DCXjBGRf.js → VirtualizedFileDiff-CZgXWHjU.js} +4 -4
  23. package/dist/assets/{WalkthroughView-CfIPvWWa.js → WalkthroughView-wSpED5L4.js} +2 -2
  24. package/dist/assets/{appThemeRegistry-DDROzcUO.js → appThemeRegistry-Cf8KitzT.js} +1 -1
  25. package/dist/assets/commitAndPush-DZnzlhvc.js +1 -0
  26. package/dist/assets/{computeVirtualFileMetrics-DHgQIkUq.js → computeVirtualFileMetrics-VYnT_A2h.js} +1 -1
  27. package/dist/assets/{de-CX_f-T5U.js → de-BM_8EDD3.js} +4 -4
  28. package/dist/assets/{es-BERmWNn_.js → es-CxZjlqpo.js} +3 -3
  29. package/dist/assets/{fr-BjYYE_-z.js → fr-VCixCnMW.js} +4 -4
  30. package/dist/assets/{index-WjufPkIV.js → index-3U4CtS9b.js} +1 -1
  31. package/dist/assets/index-B9Hvzjwl.css +1 -0
  32. package/dist/assets/index-DLHQogv8.js +40 -0
  33. package/dist/assets/{isDiffPlainText-D9faP70y.js → isDiffPlainText-ImDG3Uhg.js} +1 -1
  34. package/dist/assets/{isFilePlainText-6qOcz5Ky.js → isFilePlainText-D_YDVYDb.js} +1 -1
  35. package/dist/assets/{ja-DxqeAk9N.js → ja-CZ5k_GyD.js} +4 -4
  36. package/dist/assets/{ko-Dty1aUod.js → ko-7YM3A1Xh.js} +4 -4
  37. package/dist/assets/{main-Bjcre_GE.js → main-CycplCph.js} +2 -2
  38. package/dist/assets/main-DFYTCx5o.js +896 -0
  39. package/dist/assets/markdownCore-DHvqMxPn.js +5 -0
  40. package/dist/assets/{miniChat-Dz_bPgMc.js → miniChat-DIQKfY2V.js} +2 -2
  41. package/dist/assets/{mobile-BbZPBJrK.js → mobile-BMwz5q-m.js} +2 -2
  42. package/dist/assets/{patchFileDiff-BvU6KOQC.js → patchFileDiff-DDQ6Rq5e.js} +3 -3
  43. package/dist/assets/{pl-CX-_ROkr.js → pl-BcgDO_w5.js} +4 -4
  44. package/dist/assets/{pt-BR-DhRR1arx.js → pt-BR-CU2u_1q5.js} +3 -3
  45. package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +2 -0
  46. package/dist/assets/renderMobileApp-D0Y8DtkA.js +25 -0
  47. package/dist/assets/runtimeEndpointReset-DhC3REb2.js +25 -0
  48. package/dist/assets/{scheduledTasksApi-DW3xqMQ8.js → scheduledTasksApi-D8pq6gQz.js} +1 -1
  49. package/dist/assets/{shikiHighlight-DsxD9QEa.js → shikiHighlight-1imXsir9.js} +1 -1
  50. package/dist/assets/{textMateThemeFromAppTheme-Da7ed8qM.js → textMateThemeFromAppTheme-Dgqc63LZ.js} +1 -1
  51. package/dist/assets/tr-DuYhOzNe.js +7 -0
  52. package/dist/assets/{uk-CD21CXFV.js → uk-Cuk7-uvq.js} +3 -3
  53. package/dist/assets/{useAppFontEffects-hfv2s6mZ.js → useAppFontEffects-BItUWdo4.js} +147 -147
  54. package/dist/assets/{useInlineCommentController-BmtfVbo8.js → useInlineCommentController-CkbKsm7m.js} +2 -2
  55. package/dist/assets/useRootScrollLock-vmzxZjWA.js +2 -0
  56. package/dist/assets/{vendor-codemirror-language-data-BPMJpOpT.js → vendor-codemirror-language-data-BDyxuqK4.js} +2 -2
  57. package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
  58. package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
  59. package/dist/assets/{web-components-U-hWbgJo.js → web-components-D7FinaeH.js} +1 -1
  60. package/dist/assets/{zh-CN-BWvlPHY-.js → zh-CN-CUWoiRHd.js} +3 -3
  61. package/dist/assets/{zh-TW-CRp5dJU2.js → zh-TW-CQ8EBSBN.js} +3 -3
  62. package/dist/index.html +3 -3
  63. package/dist/mini-chat.html +3 -3
  64. package/dist/mobile.html +3 -3
  65. package/package.json +4 -3
  66. package/server/index.js +26 -7
  67. package/server/lib/changelog/update-notes.js +2 -1
  68. package/server/lib/changelog/update-notes.test.js +19 -0
  69. package/server/lib/event-stream/DOCUMENTATION.md +23 -0
  70. package/server/lib/event-stream/delta-coalescer.js +0 -0
  71. package/server/lib/event-stream/delta-coalescer.test.js +292 -0
  72. package/server/lib/event-stream/global-hub.js +53 -23
  73. package/server/lib/event-stream/global-hub.test.js +160 -0
  74. package/server/lib/event-stream/global-ws-bridge.js +1 -0
  75. package/server/lib/event-stream/index.js +4 -0
  76. package/server/lib/git/DOCUMENTATION.md +17 -4
  77. package/server/lib/git/routes.js +1 -1
  78. package/server/lib/git/serial-refresh.js +93 -0
  79. package/server/lib/git/serial-refresh.test.js +112 -0
  80. package/server/lib/git/service.js +232 -62
  81. package/server/lib/git/service.test.js +273 -0
  82. package/server/lib/github/pr-status.js +5 -5
  83. package/server/lib/github/pr-status.test.js +1 -1
  84. package/server/lib/github/routes.js +4 -4
  85. package/server/lib/guests/DOCUMENTATION.md +5 -3
  86. package/server/lib/guests/background.test.js +83 -0
  87. package/server/lib/guests/catalog.js +20 -9
  88. package/server/lib/guests/catalog.test.js +5 -5
  89. package/server/lib/guests/routes.js +2 -2
  90. package/server/lib/message-queue/DOCUMENTATION.md +6 -0
  91. package/server/lib/message-queue/runtime.js +5 -0
  92. package/server/lib/message-queue/runtime.test.js +32 -1
  93. package/server/lib/opencode/feature-routes-runtime.js +5 -0
  94. package/server/lib/opencode/settings-helpers.js +3 -0
  95. package/server/lib/opencode/settings-registry.json +8 -0
  96. package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
  97. package/server/lib/permission-auto-accept/runtime.js +13 -0
  98. package/server/lib/permission-auto-accept/runtime.test.js +37 -1
  99. package/server/lib/routing/DOCUMENTATION.md +81 -0
  100. package/server/lib/routing/defaults.js +98 -0
  101. package/server/lib/routing/feature-flag.js +11 -0
  102. package/server/lib/routing/history.js +34 -0
  103. package/server/lib/routing/jev.js +98 -0
  104. package/server/lib/routing/routes.http.test.js +100 -0
  105. package/server/lib/routing/routes.js +81 -0
  106. package/server/lib/routing/runtime.js +217 -0
  107. package/server/lib/routing/runtime.test.js +188 -0
  108. package/server/lib/routing/store.js +249 -0
  109. package/server/lib/routing/store.test.js +96 -0
  110. package/server/lib/security/request-security.js +9 -5
  111. package/server/lib/security/request-security.test.js +37 -0
  112. package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
  113. package/server/lib/ui-auth/session-cookie.js +51 -0
  114. package/server/lib/ui-auth/session-cookie.test.js +46 -0
  115. package/server/lib/ui-auth/ui-auth.js +13 -9
  116. package/server/lib/ui-auth/ui-auth.test.js +56 -0
  117. package/dist/assets/DiffView-B7YkbY-u.js +0 -4
  118. package/dist/assets/DirtyBranchSwitchDialog-CU0A93Zx.js +0 -1
  119. package/dist/assets/GitView-BLhlMYEY.js +0 -6
  120. package/dist/assets/GuestAttachDialog-B-fwE8r3.js +0 -3
  121. package/dist/assets/SettingsView-n2X-jfBB.js +0 -29
  122. package/dist/assets/SettingsWindow-Bi8LE9XI.js +0 -1
  123. package/dist/assets/index-DpzTz2UH.css +0 -1
  124. package/dist/assets/index-Dy8xgawx.js +0 -40
  125. package/dist/assets/main-BOYSXfYn.js +0 -896
  126. package/dist/assets/markdownCore-DPrwM1rU.js +0 -5
  127. package/dist/assets/renderElectronMiniChatApp-uNEUkeAI.js +0 -2
  128. package/dist/assets/renderMobileApp-BK1kFlcJ.js +0 -25
  129. package/dist/assets/runtimeEndpointReset-BULHvOwb.js +0 -25
  130. package/dist/assets/tr-cIQtYBpg.js +0 -7
  131. package/dist/assets/useRootScrollLock-Cwc4kSl2.js +0 -1
@@ -1,4 +0,0 @@
1
- import{R as i,f as Ye,j as t}from"./vendor-react-BUCujlKS.js";import{u as ae,O as Ce,a as Re,G as Fn}from"./index-Dy8xgawx.js";import{c as Dn,b as An,u as Vn,a as En,B as Ln,C as Tn,P as Tt,h as Mn,e as Bn,g as Pn,i as In,f as zn}from"./patchFileDiff-BvU6KOQC.js";import{c as On,b as _n,i as Kn,u as Gn,a as Hn,d as $n,S as qn}from"./SubmoduleDiffSummary--YFqK6Ih.js";import{f as ze,B as fe,I as L,h as je,Z as $t,af as Wn,K as ne,ag as Un,bf as Jn,J as Xn,ah as Yn,aj as Qn,z as Mt,k as Zn,d6 as qt,t as Je,kb as es,aw as Xe,aa as ts,ab as ns,ac as ss,k1 as Wt,kc as rs,ax as Ut,gy as is,au as Ue,av as os,c4 as Jt,aq as as,as as ls,at as cs,ap as us}from"./useAppFontEffects-hfv2s6mZ.js";import{f as ds,d as fs}from"./runtimeEndpointReset-BULHvOwb.js";import{P as ms}from"./PierreDiffViewer-53Ghfnlr.js";import{u as ps,v as hs,g as gs,W as xs}from"./main-BOYSXfYn.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-DCXjBGRf.js";import"./web-components-U-hWbgJo.js";import"./computeVirtualFileMetrics-DHgQIkUq.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-D9faP70y.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-B-fwE8r3.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-BmtfVbo8.js";import"./appThemeRegistry-DDROzcUO.js";import"./textMateThemeFromAppTheme-Da7ed8qM.js";import"./useRootScrollLock-Cwc4kSl2.js";import"./scheduledTasksApi-DW3xqMQ8.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const ys=i.memo(function(e){const s=Ye.c(13),{index:u,staged:g,busyHunk:m,disabled:x,onAction:j}=e,{t:C}=ze();let c;s[0]!==g?(c=g?["unstage"]:["discard","stage"],s[0]=g,s[1]=c):c=s[1];const w=c;let R;s[2]===Symbol.for("react.memo_cache_sentinel")?(R={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=R):R=s[2];let d;s[3]!==w||s[4]!==m||s[5]!==x||s[6]!==u||s[7]!==j||s[8]!==C?(d=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:w.map(y=>{const K=C(y==="stage"?"diffView.hunk.stageTitle":y==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),I=m?.index===u&&m.action===y;return t.jsx(fe,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",y==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",y==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:x||m!==null,title:K,"aria-label":K,onPointerDown:ws,onClick:f=>{f.stopPropagation(),j(u,y)},children:t.jsx(L,{name:I?"loader-4":y==="stage"?"add":"arrow-go-back",className:je(y==="stage"?"size-4":"size-3.5",I&&"animate-spin")})},y)})}),s[3]=w,s[4]=m,s[5]=x,s[6]=u,s[7]=j,s[8]=C,s[9]=d):d=s[9];let T;return s[10]!==u||s[11]!==d?(T=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:R,"data-hunk-actions":u,children:d}),s[10]=u,s[11]=d,s[12]=T):T=s[12],T});function ws(o){return o.stopPropagation()}const Bt=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const g=s??u;return g?{path:g.path,topOffset:g.top-o}:null},bs=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),Pt=o=>{if(!o)return null;const e=o.split(`
2
- `);let s=null;for(const u of e){const g=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(g){const m=Number.parseInt(g[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},js=1100,vs=15e3,It=500,zt=300,Xt=1e6,yt=3,Ss=o=>o<=6?o:o<=12?6:o<=25?4:2,Ot={status:"loading"},Ns=3,ks=i.memo(()=>{const o=Ye.c(4),{t:e}=ze();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),Yt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Cs=Yt.M,Rs=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=o=>{const e=Rs(o);return Yt[e]??Cs},Fs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},_t=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Kt=o=>!!o.working_dir?.trim()||o.index==="?",Ds=(o,e)=>is(o,e),Gt=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Ht=(o,e)=>{const s=o.split(`
3
- `),u=e.split(`
4
- `),g=Math.min(s.length,u.length);for(let m=0;m<g;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},As=o=>Array.isArray(o)?o.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Vs=o=>o==="added"?"A":o==="deleted"?"D":"M",wt=(o,e,s)=>In(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:zn(o,e),contextMode:s},Zt=(o,e,s)=>{const u=o??0,g=e??0;return!u&&!g?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,g?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",g]}):null]})},Es=i.memo(o=>{const e=Ye.c(68),{scope:s,workingCount:u,stagedCount:g,turnCount:m,branchCount:x,commitCount:j,prCount:C,showCommitOption:c,showBranchOption:w,onScopeChange:R}=o,{t:d}=ze(),[T,y]=i.useState(!1),K=s==="pr"?C??0:s==="staged"?g:s==="turn"?m:s==="branch"?x??0:s==="commit"?j??0:u;let I;e[0]!==s||e[1]!==d?(I=d(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=d,e[2]=I):I=e[2];const f=I;let me;e[3]!==d?(me=d("diffView.scope.selectorAria"),e[3]=d,e[4]=me):me=e[4];let pe;e[5]!==K?(pe=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",K]}),e[5]=K,e[6]=pe):pe=e[6];let te;e[7]!==f||e[8]!==pe?(te=t.jsxs("span",{className:"whitespace-nowrap",children:[f,pe]}),e[7]=f,e[8]=pe,e[9]=te):te=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(L,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=k):k=e[10];let V;e[11]!==me||e[12]!==te?(V=t.jsx(as,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":me,children:[te,k]})}),e[11]=me,e[12]=te,e[13]=V):V=e[13];let v;e[14]!==R?(v=Q=>{(Q==="working"||Q==="staged"||Q==="turn"||Q==="branch"||Q==="commit"||Q==="pr")&&(R?.(Q),y(!1))},e[14]=R,e[15]=v):v=e[15];let se;e[16]!==d?(se=d("diffView.scope.changed"),e[16]=d,e[17]=se):se=e[17];let J;e[18]!==se?(J=t.jsx("span",{children:se}),e[18]=se,e[19]=J):J=e[19];let le;e[20]!==u?(le=t.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=le):le=e[21];let re;e[22]!==le||e[23]!==J?(re=t.jsx(Ue,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[J,le]})}),e[22]=le,e[23]=J,e[24]=re):re=e[24];let ce;e[25]!==d?(ce=d("diffView.scope.staged"),e[25]=d,e[26]=ce):ce=e[26];let X;e[27]!==ce?(X=t.jsx("span",{children:ce}),e[27]=ce,e[28]=X):X=e[28];let $;e[29]!==g?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:g}),e[29]=g,e[30]=$):$=e[30];let ue;e[31]!==X||e[32]!==$?(ue=t.jsx(Ue,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[X,$]})}),e[31]=X,e[32]=$,e[33]=ue):ue=e[33];let M;e[34]!==d?(M=d("diffView.scope.lastTurn"),e[34]=d,e[35]=M):M=e[35];let D;e[36]!==M?(D=t.jsx("span",{children:M}),e[36]=M,e[37]=D):D=e[37];let q;e[38]!==m?(q=t.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=q):q=e[39];let G;e[40]!==D||e[41]!==q?(G=t.jsx(Ue,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[D,q]})}),e[40]=D,e[41]=q,e[42]=G):G=e[42];let de;e[43]!==x||e[44]!==w||e[45]!==d?(de=w?t.jsx(Ue,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x??"…"})]})}):null,e[43]=x,e[44]=w,e[45]=d,e[46]=de):de=e[46];let Y;e[47]!==j||e[48]!==c||e[49]!==d?(Y=c&&t.jsx(Ue,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[47]=j,e[48]=c,e[49]=d,e[50]=Y):Y=e[50];let E;e[51]!==C||e[52]!==c||e[53]!==d?(E=c&&t.jsx(Ue,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}),e[51]=C,e[52]=c,e[53]=d,e[54]=E):E=e[54];let W;e[55]!==s||e[56]!==re||e[57]!==ue||e[58]!==G||e[59]!==de||e[60]!==Y||e[61]!==E||e[62]!==v?(W=t.jsx(ls,{align:"start",className:"w-40",children:t.jsxs(cs,{value:s,onValueChange:v,children:[re,ue,G,de,Y,E]})}),e[55]=s,e[56]=re,e[57]=ue,e[58]=G,e[59]=de,e[60]=Y,e[61]=E,e[62]=v,e[63]=W):W=e[63];let ve;return e[64]!==T||e[65]!==W||e[66]!==V?(ve=t.jsxs(us,{open:T,onOpenChange:y,children:[V,W]}),e[64]=T,e[65]=W,e[66]=V,e[67]=ve):ve=e[67],ve}),Ls=i.memo(o=>{const e=Ye.c(11),{changedFiles:s,selectedFile:u,onSelectFile:g}=o,{t:m}=ze();if(s.length===0)return null;let x;if(e[0]!==s||e[1]!==g||e[2]!==u||e[3]!==m){let C;e[5]!==g||e[6]!==u||e[7]!==m?(C=c=>{const w=Qt(c),R=u===c.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>g(c.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",R?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Ut,{filePath:c.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:m(w.descriptionKey),"aria-label":m(w.descriptionKey),children:w.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c.path,children:c.path}),Zt(c.insertions,c.deletions)]})},c.path)},e[5]=g,e[6]=u,e[7]=m,e[8]=C):C=e[8],x=s.map(C),e[0]=s,e[1]=g,e[2]=u,e[3]=m,e[4]=x}else x=e[4];let j;return e[9]!==x?(j=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:x})}),e[9]=x,e[10]=j):j=e[10],j}),Ts=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,renderSideBySide:g}=o,{t:m}=ze(),x=u.original.length>0,j=u.modified.length>0,C=g?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",c=g?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let R;e[1]!==u.original||e[2]!==s||e[3]!==x||e[4]!==c||e[5]!==g||e[6]!==m?(R=x&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),t.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=x,e[4]=c,e[5]=g,e[6]=m,e[7]=R):R=e[7];let d;e[8]!==u.modified||e[9]!==s||e[10]!==j||e[11]!==x||e[12]!==c||e[13]!==g||e[14]!==m?(d=j&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(x?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=j,e[11]=x,e[12]=c,e[13]=g,e[14]=m,e[15]=d):d=e[15];let T;return e[16]!==C||e[17]!==R||e[18]!==d?(T=t.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:t.jsxs("div",{className:C,children:[R,d]})}),e[16]=C,e[17]=R,e[18]=d,e[19]=T):T=e[19],T}),Ms=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,staged:g,renderSideBySide:m,wrapLines:x,hunkActions:j}=o;let C;e[0]!==s?(C=os(s)||"text",e[0]=s,e[1]=C):C=e[1];const c=C;if(u.submodule){let d;return e[2]!==u.submodule||e[3]!==g?(d=t.jsx(qn,{state:u.submodule,staged:g}),e[2]=u.submodule,e[3]=g,e[4]=d):d=e[4],d}if(u.isBinary){let d;return e[5]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(ks,{}),e[5]=d):d=e[5],d}if(Xe(s)){let d;return e[6]!==u||e[7]!==s||e[8]!==m?(d=t.jsx(Ts,{filePath:s,diff:u,renderSideBySide:m}),e[6]=u,e[7]=s,e[8]=m,e[9]=d):d=e[9],d}let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[10]=w):w=e[10];let R;return e[11]!==u.fileDiff||e[12]!==u.modified||e[13]!==u.original||e[14]!==s||e[15]!==j||e[16]!==c||e[17]!==m||e[18]!==x?(R=t.jsx("div",{className:"w-full",style:w,children:t.jsx(ms,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:c,fileName:s,renderSideBySide:m,wrapLines:x,layout:"inline",hunkActions:j})}),e[11]=u.fileDiff,e[12]=u.modified,e[13]=u.original,e[14]=s,e[15]=j,e[16]=c,e[17]=m,e[18]=x,e[19]=R):R=e[19],R}),Bs=i.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:g,isSelected:m,isExpanded:x,isMounted:j,onSelect:C,onExpandedChange:c,registerSectionRef:w,showOpenInEditorAction:R=!1,isOpeningInEditor:d=!1,onOpenInEditor:T,staged:y=!1,loadFullFiles:K=!1,initialDiffData:I=null,comparisonDiff:f,onRetryComparisonDiff:me,readOnlyActions:pe=!1,hunkActionsEnabled:te=!1})=>{const{t:k}=ze(),{git:V}=$t(),v=ne(i.useCallback(h=>h.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),se=ne(h=>h.setDiff),J=ne(h=>h.fetchStatus),le=ae(h=>h.setDiffFileLayout),[re,ce]=i.useState(0),[X,$]=i.useState(null),[ue,M]=i.useState(!1),D=i.useMemo(()=>f?f.status==="error"?{kind:"error",message:f.message}:null:X,[f,X]),q=f?f.status==="loading":ue,[G,de]=i.useState(null),Y=i.useRef(!1),[E,W]=i.useState(null),[ve,Q]=i.useState(!1),[ie,Qe]=i.useState(null),[lt,Fe]=i.useState(null),he=i.useRef(null),mt=i.useRef(null),Oe=i.useMemo(()=>Qt(s),[s]),_e=u==="side-by-side",De=K?"full":"patch",ge=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,a=te&&!pe&&!I&&!f&&!Xe(s.path),xe=JSON.stringify([Re(),e,s.path,y,ge,re]),z=E?.scope===xe?E.patch:null,Ze=E?.scope===xe?E.submodule:null,U=i.useMemo(()=>f?f.status==="ready"?f.data:null:I||(y?lt:ie||(v?{original:v.original,modified:v.modified,isBinary:v.isBinary,submodule:v.submodule,contextMode:"full"}:null)),[f,v,I,ie,y,lt]),et=U?.contextMode===De,tt=i.useCallback(h=>{mt.current=h,w(s.path,h)},[s.path,w]),nt=i.useCallback(h=>{c(s.path,h)},[s.path,c]),st=i.useCallback(()=>{C(s.path)},[s.path,C]),rt=i.useRef({fileStatusKey:ge,staged:y});i.useEffect(()=>{if(!o)return;const h=rt.current;h.fileStatusKey===ge&&h.staged===y||(rt.current={fileStatusKey:ge,staged:y},y?Fe(null):Qe(null),$(null),he.current=null)},[ge,y,o]),i.useEffect(()=>{if(!o||!x||!j||X)return;if(!e||f||I||U&&et&&(!a||z!==null)){he.current=null,M(!1);return}const h=`${e}::${s.path}::${y?"staged":"unstaged"}::${ge}::${De}::${re}`;if(he.current===h)return;he.current=h,$(null),M(!0);let O=!1;const ye=Re(),Ge=K?Xt:yt,Z=Xe(s.path)?V.getGitFileDiff(e,{path:s.path,staged:y}):!K&&z!==null?Promise.resolve({diff:z,submodule:Ze}):V.getGitDiff(e,{path:s.path,staged:y,contextLines:Ge}),Ve=a&&K&&z===null?V.getGitDiff(e,{path:s.path,staged:y,contextLines:yt}).then(S=>S.diff):Promise.resolve(z),Pe=Promise.all([Z,Ve]),we=vs;let _;const Ee=new Promise((S,He)=>{_=setTimeout(()=>He(new Error(`Timed out after ${we}ms`)),we)});return Promise.race([Pe,Ee]).then(([S,He])=>{if(O||ye!==Re())return;const be="diff"in S&&!K?S.diff:He;if(a&&K&&be!==null&&/^@@\s/m.test(be)&&"diff"in S&&S.diff!==be&&!Mn(S.diff,be))throw W(null),new Error(k("diffView.hunk.unavailable"));if(a&&be!==null&&W({scope:xe,patch:be,submodule:S.submodule}),"diff"in S){const Ne={...wt(s.path,S.diff,De),submodule:S.submodule};y?Fe(Ne):Qe(Ne)}else{const Ne={original:S.original??"",modified:S.modified??"",isBinary:S.isBinary,submodule:S.submodule,contextMode:"full"};y?Fe(Ne):se(e,s.path,Ne,ye)}M(!1)}).catch(S=>{if(!(O||ye!==Re())){if(M(!1),S instanceof Fn){$({kind:"unavailable",reason:S.reason}),S.reason==="path_not_found"&&J(e,V,{force:!0,silent:!0});return}$({kind:"error",message:S instanceof Error?S.message:String(S)})}}).finally(()=>clearTimeout(_)),()=>{O=!0,clearTimeout(_),he.current===h&&(he.current=null)}},[z,Ze,a,xe,f,De,U,et,re,e,J,s.path,ge,V,I,x,j,K,X,se,y,k,o]);const ct=i.useCallback(()=>{nt(!x),st()},[nt,st,x]),Ae=i.useCallback(()=>{$(null),W(null),Qe(null),Fe(null),he.current=null,ce(h=>h+1)},[]),Se=i.useCallback(async(h,O)=>{if(!e||!a||q||D||Y.current||G!==null)return;const ye=z?Bn(z,h):null;if(!ye){Je.error(k("diffView.hunk.unavailable"));return}if(y&&O!=="unstage"||!y&&O==="unstage")return;Y.current=!0;const Ge=Re();de({index:h,action:O});try{const Z=O==="stage"?V.stageGitHunk:O==="unstage"?V.unstageGitHunk:V.revertGitHunk;if(!Z){Je.error(k("diffView.hunk.unsupported"));return}if(await Z(e,s.path,ye),Ge!==Re())return;Ae(),qt.requestGitRefresh({directory:e,paths:[s.path]}),await J(e,V)}catch(Z){if(Ge!==Re())return;Ae(),Je.error(Z instanceof Error&&Z.message?Z.message:k("diffView.hunk.unavailable"))}finally{Y.current=!1,de(Z=>Z?.index===h&&Z.action===O?null:Z)}},[z,a,q,D,e,J,s.path,V,G,Ae,y,k]),Be=i.useMemo(()=>a&&z!==null?Pn(z):[],[z,a]),Ke=i.useCallback(h=>t.jsx(ys,{index:h,staged:y,busyHunk:G,disabled:q||!!D,onAction:Se}),[D,Se,G,q,y]),it=i.useMemo(()=>Be.length>0?{anchors:Be,render:Ke}:void 0,[Be,Ke]);return t.jsxs("div",{ref:tt,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:ct,onKeyDown:h=>{h.target===h.currentTarget&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),ct())},className:je("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:x?t.jsx(L,{name:"arrow-down-s",className:"size-4"}):t.jsx(L,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:k(Oe.descriptionKey),"aria-label":k(Oe.descriptionKey),children:Oe.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ut,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const h=s.path.lastIndexOf("/");if(h===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const O=s.path.slice(0,h),ye=s.path.slice(h+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:O}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ye})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Zt(s.insertions,s.deletions),R&&T?t.jsx(fe,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:k("diffView.actions.openFileInEditorAtChange"),onClick:h=>{h.stopPropagation(),T(s.path,U)},disabled:d,children:d?t.jsx(L,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(L,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:_e?"side-by-side":"unified",onModeChange:h=>{const O=h==="side-by-side"?"side-by-side":"inline";le(s.path,O)},className:"opacity-70"})]})]})}),x&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!j&&!D?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,D?.kind==="unavailable"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:D.reason==="nested_repository"?k("diffView.unavailable.nestedRepositoryTitle"):k("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.reason==="nested_repository"?k("diffView.unavailable.nestedRepositoryDescription"):k("diffView.unavailable.missingDescription")}),D.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:Ae,children:k("diffView.actions.retry")}):null]}):null,D?.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>f?me?.():Ae(),children:k("diffView.actions.retry")})]}):null,j&&q&&!U&&!D?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),k("diffView.state.loadingDiff")]}):null,j&&U&&!ve&&s.insertions+s.deletions>It?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:k("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Q(!0),children:k("diffView.actions.renderAnyway")})]}):null,j&&U&&(ve||s.insertions+s.deletions<=It)?t.jsx(t.Fragment,{children:t.jsx(Ms,{filePath:s.path,diff:U,staged:y,renderSideBySide:_e,wrapLines:g,hunkActions:it})}):null]})]})}),eo=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:g=!1,diffScope:m="all",onDiffScopeChange:x,targetFilePath:j=null,flushContent:C=!1})=>{const{t:c}=ze(),{git:w,files:R}=$t(),d=Wn(),T=ne(n=>n.runtimeKey),{rootIsGitRepo:y,gitDirectory:K,nestedRepos:I}=Un(d??null,{enabled:o}),f=K??d,me=ae(n=>n.openContextSurface),pe=ps(n=>n.requestSource),{screenWidth:te,isMobile:k}=Jn(),V=Xn(f??null),v=Yn(f??null),se=Qn(f??null),J=ne(n=>n.setActiveDirectory),le=ne(n=>n.ensureStatus),re=ne(n=>n.selectNestedRepo),ce=ne(n=>n.fetchStatus),X=ne(n=>n.fetchBranches),$=ne(n=>n.clearDiffCache),ue=ne(n=>n.setDiff),[M,D]=i.useState(null),[q,G]=i.useState(!1),[de,Y]=i.useState(null),[E,W]=i.useState(()=>new Set),[ve,Q]=i.useState(()=>new Set),[ie,Qe]=i.useState(!1),[lt,Fe]=i.useState(0),[he,mt]=i.useState(()=>new Map),[Oe,_e]=i.useState(!1),[De,ge]=i.useState(!1),[a,xe]=i.useState(m);i.useEffect(()=>{xe(m)},[m]);const z=ae(n=>n.pendingDiffFile),Ze=ae(n=>n.pendingDiffStaged),U=ae(n=>n.pendingDiffScope),et=ae(n=>n.setPendingDiffFile),tt=ae(n=>n.diffLayoutPreference),nt=ae(n=>n.diffFileLayout),st=ae(n=>n.setDiffFileLayout),rt=ae(n=>n.diffWrapLines),ct=ae(n=>n.setDiffWrapLines),Ae=ae(n=>n.openContextFileAtLine),Se=Mt(n=>n.currentSessionId),Be=Zn(a==="turn"?Se??"":"",d??void 0),Ke=rt,it=a==="staged"?!0:a==="working"?!1:null,h=it??q,O=k||te<=768,ye=!!Se&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!O&&!Ce(),Ge=a!=="turn"&&!O&&!Ce(),Z=!e&&!O&&te>=1024,Ve=i.useRef(null),Pe=i.useRef(new Map),we=i.useRef(null),_=i.useRef(null),Ee=i.useRef(!1),S=i.useRef(null),He=i.useRef(null),be=i.useRef(null),Ne=i.useRef(null),bt=i.useCallback(()=>{const n=Ve.current;if(!n)return null;const r=n.getBoundingClientRect().top,l=[];for(const[p,b]of Pe.current)b&&l.push({path:p,top:b.getBoundingClientRect().top});return Bt(r,l)},[]),$e=i.useCallback(()=>{we.current=null,Ee.current=!1,Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)},[]),qe=i.useCallback(n=>{W(r=>{if(r.has(n))return r;const l=new Set(r);return l.add(n),l})},[]),ot=i.useMemo(()=>{for(let n=Be.length-1;n>=0;n-=1){const r=Be[n];if(r.role==="user")return As(r.summary?.diffs)}return[]},[Be]),en=i.useMemo(()=>{const n=new Map;for(const r of ot)if(r.file){if(typeof r.patch=="string"){n.set(r.file,wt(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[ot]),tn=i.useMemo(()=>v?.files?v.files.filter(Kt).length:0,[v]),nn=i.useMemo(()=>v?.files?v.files.filter(_t).length:0,[v]),sn=ot.length,H=v?.current??null,Le=Dn(f??null,H,o&&a==="pr"&&!Ce()),Te=Le.selectedSource,Me=An(f??null,H,o&&a==="commit"&&!Ce()),Ie=Me.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Ce()&&(xe("working"),x?.("working"))},[a,x]);const We=ne(n=>f?n.directories.get(f)?.branches??null:null),rn=ne(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),on=i.useCallback(()=>{f&&X(f,w)},[f,X,w]),an=On(f??null,o&&V!==!1,rn,!!We,on,Ns),jt=i.useMemo(()=>{const n=v?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,v?.tracking]),vt=!Ce()&&_n(H,jt),ln=v!==null,St=Ce()||an||Kn(H,jt,ln,We!==null),cn=Vn(n=>n.setOverride),{base:ke,resolved:un,revision:Nt}=En(f??null,H,o&&vt&&a==="branch"),[dn,fn]=i.useState(0);i.useEffect(()=>{const n=$n(a,!St);n!==a&&(xe(n),n==="working"&&x?.("working"))},[a,St,x]);const mn=i.useMemo(()=>a==="pr"?Te:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&ke&&H?{kind:"branch",baseRef:ke,headRef:H}:null,[a,ke,H,Ie,Te]),A=Gn(f??null,mn,o&&!Ce(),a==="branch"?Nt:""),{fetchDiff:kt}=A,Ct=a==="commit"?A.files:null,Rt=a==="commit"?A.error:null,ut=a==="branch"?A.files:null,Ft=a==="branch"?A.error:null,Dt=A.files?a==="pr"?JSON.stringify([A.key,A.revision]):A.key:null,pn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(E).sort().join("\0"):"",[a,E]),hn=i.useCallback(async n=>{try{const r=ie&&a!=="pr",l=await kt(n,r?Xt:yt);return{status:"ready",data:wt(n,l.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:c("diffView.state.failedToLoadDiff")}}},[a,kt,ie,c]),gn=Hn(Dt,o?pn:"",Dt?hn:null,Ot,JSON.stringify([a==="branch"?Nt:"",a==="pr"?A.revision:0,dn,ie])),xn=ut?.length??null,N=i.useMemo(()=>{if(a==="commit"||a==="pr")return(A.files??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:l.insertions,deletions:l.deletions,isNew:l.status==="A"}));if(a==="branch")return(ut??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,p)=>l.path.localeCompare(p.path));if(a==="turn")return ot.map(l=>({path:l.file??"",index:"",working_dir:Vs(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,p)=>l.path.localeCompare(p.path));if(!v?.files)return[];const n=v.diffStats??{},r=a==="staged"?_t:a==="working"?Kt:()=>!0;return v.files.filter(r).map(l=>({...l,insertions:n[l.path]?.insertions??0,deletions:n[l.path]?.deletions??0,isNew:Fs(l)})).sort((l,p)=>l.path.localeCompare(p.path))},[a,ut,A.files,ot,v]),pt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=pt?pt.split("\0"):[],r=new Set(n),l=`${f??""}:${a}:${s?"collapsed":"default"}`,p=He.current!==l;He.current=l,W(b=>{if(p){const P=s?0:Ss(n.length);return new Set(n.slice(0,P))}let B=!1;const F=new Set;for(const P of b){if(!r.has(P)){B=!0;continue}F.add(P)}return B?F:b}),Q(b=>{if(p)return new Set;let B=!1;const F=new Set;for(const P of b){if(!r.has(P)){B=!0;continue}F.add(P)}return B?F:b})},[a,pt,f,s]);const At=i.useCallback(()=>{if(S.current=null,!o)return;const n=Ve.current;if(!n)return;const r=n.getBoundingClientRect(),l=r.top-zt,p=r.bottom+zt,b={},B=[];for(const[F,P]of Pe.current){if(!P)continue;const ee=P.getBoundingClientRect();B.push({path:F,top:ee.top}),E.has(F)&&(ee.bottom<l||ee.top>p||(b[F]=!0))}be.current=Bt(r.top,B),Q(F=>{let P=!1;const ee=new Set(F);for(const at of Object.keys(b))ee.has(at)||(ee.add(at),P=!0);return P?ee:F})},[E,o]),oe=i.useCallback(()=>{o&&(typeof window>"u"||S.current===null&&(S.current=window.requestAnimationFrame(At)))},[At,o]);i.useEffect(()=>{const n=Ve.current;if(!(!o||!n))return oe(),n.addEventListener("scroll",oe,{passive:!0}),window.addEventListener("resize",oe),()=>{n.removeEventListener("scroll",oe),window.removeEventListener("resize",oe),S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null)}},[N,E,oe,o]);const ht=i.useCallback(n=>{const r=nt[n.path];if(r)return r;if(tt==="inline")return"inline";if(tt==="side-by-side")return"side-by-side";const l=te<js;return n.isNew||l?"inline":"side-by-side"},[nt,tt,te]),Vt=i.useMemo(()=>N.length===0?null:N.every(n=>ht(n)==="side-by-side")?"side-by-side":"inline",[N,ht]);i.useEffect(()=>{o&&f&&(J(f),le(f,w))},[f,J,le,w,o]);const dt=JSON.stringify([T,f]),gt=i.useRef({scope:dt,paths:new Set,dirty:!1}),Et=i.useRef(o);i.useEffect(()=>{const n=o&&!Et.current;if(Et.current=o,gt.current.scope!==dt&&(gt.current={scope:dt,paths:new Set,dirty:!1}),!f)return;const r=p=>{p?.length&&(Ne.current=bt()??be.current,$(f,p),mt(b=>{const B=new Map(b);for(const F of p)B.set(F,(B.get(F)??0)+1);return B})),ce(f,w,{silent:!0})},l=gt.current;return o&&(n||l.dirty)&&(r([...l.paths]),l.paths.clear(),l.dirty=!1),qt.onGitRefreshHint(p=>{if(Gt(p.directory)===Gt(f)){if(!o){l.dirty=!0;for(const b of p.paths??[])l.paths.add(b);return}r(p.paths)}})},[bt,$,f,ce,w,dt,o]),i.useLayoutEffect(()=>{const n=Ne.current;if(!n)return;Ne.current=null;const r=Ve.current,l=Pe.current.get(n.path);if(!r||!l)return;const p=r.getBoundingClientRect().top,b=l.getBoundingClientRect().top-p;r.scrollTop=bs(r.scrollTop,n.topOffset,b,r.scrollHeight-r.clientHeight),be.current=n},[he]),i.useEffect(()=>{!o||a!=="all"&&!U||z&&(U&&xe(U),D(z),G(U==="staged"||!U&&Ze),et(null),Ee.current=!0,we.current=z,qe(z),Fe(n=>n+1))},[a,qe,z,U,Ze,et,o]),i.useEffect(()=>{if(a==="all")return;const n=j?.trim();n&&(D(n),G(a==="staged"),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1))},[a,qe,j]),i.useEffect(()=>{if(!M)return;N.some(r=>r.path===M)||(D(null),G(!1))},[N,M]);const yn=i.useCallback((n,r)=>{const l=Pe.current;r?l.set(n,r):l.delete(n),oe()},[oe]),wn=i.useCallback((n,r)=>{$e(),W(l=>{const p=l.has(n);if(r===p)return l;const b=new Set(l);return r?b.add(n):b.delete(n),b}),r||Q(l=>{if(!l.has(n))return l;const p=new Set(l);return p.delete(n),p}),oe()},[$e,oe]),bn=i.useCallback(()=>{$e(),W(n=>n.size>0?new Set:new Set(N.map(r=>r.path))),Q(new Set),oe()},[$e,N,oe]),jn=i.useCallback(async n=>{if(!Se)return;const r=Mt.getState().getDirectoryForSession(Se)||d||"";if(!r){Je.error(c("diffView.reviewDialog.toast.noSessionDirectory"));return}ge(!0);try{await es({originalSessionID:Se,directory:r,providerID:n.providerID,modelID:n.modelID,agent:n.agent||void 0,variant:n.variant||void 0,generateHandoff:n.generateHandoff,returnAfterHandoffRequest:n.generateHandoff,autoReview:n.autoReview}),_e(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Je.error(l instanceof Error?l.message:c("diffView.reviewDialog.toast.startFailed"))}finally{ge(!1)}},[Se,d,c]),ft=i.useCallback(n=>{const r=Pe.current.get(n),l=Ve.current;if(!r||!l)return!1;const p=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+p,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=we.current;if(!o||!n)return;let r=0;const l=20;let p=!1;const b=(F=!0)=>{p||(p=!0,we.current=null,Ee.current=!1,F&&Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null))},B=()=>{if(p){_.current=null;return}const F=we.current;if(!F){b(),_.current=null;return}if(!ft(F)){r+=1,r<l?_.current=window.requestAnimationFrame(B):(b(),_.current=null);return}if(u&&Ee.current){Y(F),b(!1);return}b()};return _.current=window.requestAnimationFrame(B),()=>{p=!0,_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)}},[u,lt,ft,o]);const vn=i.useCallback(n=>{},[]),xt=i.useCallback(n=>{$e(),D(n),G(!1),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1),ft(n)},[$e,qe,ft]);i.useEffect(()=>{const n=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const p=r.key==="ArrowDown"?1:-1,b=M?N.findIndex(P=>P.path===M):-1,B=b===-1?p>0?0:N.length-1:b+p,F=N[B];F&&(r.preventDefault(),xt(F.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,M,xt,o]);const Sn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{st(l.path,r)})},[N,st]),[Nn,Lt]=i.useState(null),kn=i.useCallback(async(n,r)=>{if(!f||!n)return;Lt(n);const l=Re();try{let p=null;if(r?.patch&&!r.isBinary&&!Xe(n)?p=Pt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(p=Ht(r.original,r.modified)),p===null)try{const ee=await w.getGitDiff(f,{path:n,staged:h,contextLines:3});p=Pt(ee.diff)}catch{p=null}let b=r;if(p===null||!b){const ee=await w.getGitFileDiff(f,{path:n,staged:h}),at={original:ee.original??"",modified:ee.modified??"",isBinary:ee.isBinary,submodule:ee.submodule};b=at,h||ue(f,n,at,l)}const B=p??(b.isBinary||Xe(n)?1:Ht(b.original,b.modified)),F=Ds(f,n),P=await hs(R,F,{directory:f});if(!P.ok){Je.error(gs(P.reason));return}Ae(f,F,B,1)}finally{Lt(p=>p===n?null:p)}},[h,f,R,w,Ae,ue]),Cn=()=>{if(!f)return null;const n=r=>it!==null?it:q&&r===M;return t.jsxs("div",{className:je("flex min-w-0 flex-1 min-h-0 h-full",C?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Z&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:c("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Ls,{changedFiles:N,selectedFile:null,onSelectFile:xt})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(Jt,{ref:Ve,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>t.jsx(Bs,{visible:o,directory:f,file:r,layout:ht(r),wrapLines:Ke,isSelected:!1,isExpanded:E.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:g&&a!=="turn",isOpeningInEditor:Nn===r.path,onOpenInEditor:(l,p)=>{kn(l,p)},staged:n(r.path),loadFullFiles:ie&&a!=="pr",readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",comparisonDiff:a==="branch"||a==="commit"||a==="pr"?gn.get(r.path)??Ot:void 0,onRetryComparisonDiff:()=>fn(l=>l+1),initialDiffData:a==="turn"?en.get(r.path)??null:null},`${Re()}:${f}:${r.path}:${he.get(r.path)??0}`))})})})]})},Rn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.selectSessionDirectory")});if(a!=="turn"&&se&&!v)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&V===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.notGitRepository")});if(a==="pr"){if(!Te||A.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:A.error??Le.error??(Le.loading?c("session.githubPrPicker.loading.pullRequests"):c("pullRequestComparison.select"))}),(A.error||Le.error)&&t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{Te?A.refresh():Le.refresh()},children:c("diffView.actions.retry")}),!Te&&!Le.loading&&t.jsx(Tt,{comparison:Le})]});if(!A.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="commit"){if(Rt)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Rt}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{A.refresh()},children:c("diffView.actions.retry")})]});if(!Ie&&!Me.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Me.error??c("commitComparison.noCommits")});if(!Ct)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="branch"){if(!un)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.resolvingBase")]});if(!ke)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(L,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:c("gitView.pr.toast.baseBranchRequired")})]});if(Ft)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ft}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{A.refresh()},children:c("diffView.actions.retry")})]});if(ut===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?c("diffView.state.noLastTurnChanges"):a==="pr"?c("walkthrough.blocked.emptyDiff.description"):a==="commit"?c("commitComparison.emptyDiff"):a==="branch"&&ke?c("diffView.branch.empty",{base:fs(ke)}):c("diffView.state.cleanWorkingTree")}):Cn()};return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[y===!1&&Array.isArray(I)&&I.length>0?t.jsx(ds,{repositories:I,selectedRepository:K??null,onSelectRepository:n=>{d&&re(d,n)},repositoryRoot:d??void 0}):null,!k&&(a!=="all"?t.jsx(Es,{scope:a,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:a==="commit"?Ct?.length??null:null,prCount:a==="pr"?A.files?.length??null:null,showCommitOption:!Ce(),showBranchOption:vt,onScopeChange:n=>{xe(n),x?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:se&&!v?c("diffView.state.loadingChanges"):N.length===1?c("diffView.summary.changedFilesSingle",{count:N.length}):c("diffView.summary.changedFilesPlural",{count:N.length})})})),a==="branch"&&t.jsx(Ln,{branches:We?.all??[],currentBranch:H,base:ke,onSelect:n=>{f&&H&&cn(f,H,n)}},JSON.stringify([f,H])),a==="commit"&&t.jsx(Tn,{commits:Me.commits,selectedHash:Ie,loading:Me.loading,error:Me.error,onSelect:Me.select,onRefresh:()=>{Me.refresh()}},JSON.stringify([f,H])),a==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Le},JSON.stringify([T,f,H])),Te&&t.jsx(fe,{variant:"ghost",size:"sm",disabled:A.loading,"aria-label":c("session.githubIssuePicker.actions.refresh"),title:c("session.githubIssuePicker.actions.refresh"),onClick:()=>{A.refresh()},children:t.jsx(L,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(fe,{variant:"ghost",size:"sm",onClick:bn,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll"),children:[t.jsx(L,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll")})]}),N.length>0&&ye&&t.jsxs(fe,{variant:"default",size:"sm",onClick:()=>_e(!0),disabled:De,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":c("diffView.actions.reviewAria"),children:[De?t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(L,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:c("diffView.actions.review")})]}),N.length>0&&Ge&&t.jsxs(fe,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";pe(n,a==="pr"&&Te?Te:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&ke&&H?{kind:"branch",baseRef:ke,headRef:H}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),me(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",xs),"aria-label":c("walkthrough.action.open"),children:[t.jsx(L,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}),N.length>0&&a!=="pr"&&t.jsxs(ts,{children:[t.jsx(ns,{asChild:!0,children:t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>Qe(n=>!n),"aria-pressed":ie,"aria-label":c(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:je("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",ie&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(L,{name:"file-download",className:"size-4"})})}),t.jsx(ss,{children:t.jsx("p",{children:c(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>ct(!rt),className:je("h-5 w-5 p-0 transition-opacity",Ke?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:c(Ke?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(L,{name:"text-wrap",className:"size-4"})}),Vt&&t.jsx(Wt,{mode:Vt==="side-by-side"?"side-by-side":"unified",onModeChange:Sn})]}),t.jsx(rs,{open:Oe,onOpenChange:_e,projectDirectory:f??null,submitting:De,onConfirm:jn}),Rn()]})};export{eo as DiffView,Bs as MultiFileDiffEntry};
@@ -1 +0,0 @@
1
- import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ax as Ee,aa as be,ab as ye,I as E,ac as we,h as J,B as Y,a5 as Te,jk as Ie,b_ as fe,b$ as ue,c0 as pe,c1 as ge,c2 as xe,c3 as ve,bf as Me,cm as Re,t as ae}from"./useAppFontEffects-hfv2s6mZ.js";import{u as ke}from"./index-Dy8xgawx.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Fe=Se.M;function Pe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function $e(p){const e=Pe(p);return Se[e]??Fe}const He=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=$e(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=Q(),$=u.description,F=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let H;t[7]!==a?(H=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=H):H=t[8];const W=H;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const P=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let R;t[13]!==v?(R=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=R):R=t[14];const q=o?P:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==$||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:$,"aria-label":$,children:u.code}),t[17]=u.code,t[18]=$,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Z;t[30]===Symbol.for("react.memo_cache_sentinel")?(Z={color:"var(--status-success)"},t[30]=Z):Z=t[30];let i;t[31]!==F?(i=s.jsxs("span",{style:Z,children:["+",F]}),t[31]=F,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:P;let ee;return t[46]!==T||t[47]!==d||t[48]!==R||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:R,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=R,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Ze=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=Q(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),$=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),F=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from($[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[$,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(F);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),F.forEach(m=>n.add(m)),n})},[f,F]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe($[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,$,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),H=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice(H,H+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,H]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),P=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=P.length,R=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||P.length===0||(await g(P),c(!1))},[P,r,g]),K=N.useCallback(async()=>{!d||!u||R||(await d(u.paths),I(null))},[R,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx(He,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Z=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(Z(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:J("relative",Z(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!R&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:R,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:R||!u,children:a(R?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=Q(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const H=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const P=y.scrollHeight,X=Math.min(Math.max(P,he),re);y.style.height=`${X}px`,y.style.overflowY=P>re?"auto":"hidden",P>re&&!H&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",$=S?"sentences":"off",F=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==$||e[15]!==F||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:$,spellCheck:F,className:z,style:T}),e[13]=h,e[14]=$,e[15]=F,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=Q();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Je=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=Q(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:$}=Me();let F;e[5]!==o?(F=o("gitView.commit.title"),e[5]=o,e[6]=F):F=e[6];let A;e[7]!==F?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:F}),e[7]=F,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let H;e[22]!==o?(H=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=H):H=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==$||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==H?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:H,disabled:W,hasTouchInput:$,isMobile:I}),e[24]=r,e[25]=$,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=H,e[31]=L):L=e[31];let P;e[32]!==V||e[33]!==k||e[34]!==o?(P=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=P):P=e[35];const X=a||f!==null||v||t===0;let R;e[36]!==o?(R=o("gitView.commit.generateAria"),e[36]=o,e[37]=R):R=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==R||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":R,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=R,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Z=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Z||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Z,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Z,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==P||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,P,D]}),e[72]=L,e[73]=P,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Qe=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=Q(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Re,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Ze as C,Qe as D,Je as a};
@@ -1,6 +0,0 @@
1
- import{R as l,r as ve,j as t,f as Ct}from"./vendor-react-BUCujlKS.js";import{f as nt,z as rt,a4 as Dt,kd as _n,dr as Yt,cF as Qt,t as b,I as T,ap as Ts,aq as Ls,ar as Fr,as as Os,d1 as As,d2 as zs,d3 as Gs,d4 as _s,cY as Zt,cZ as Xt,B as W,ke as $n,kf as Hn,b_ as mt,b$ as ht,c0 as gt,c1 as ft,c2 as bt,W as gr,aa as es,ab as ts,ac as ss,kg as Wn,h as Se,kh as Un,ki as Kn,kj as qn,kk as Jn,bd as Yn,av as Qn,ca as Zn,kl as Xn,km as ea,kn as ta,ko as sa,kp as ra,kq as na,kr as aa,c4 as Rr,cf as ia,cg as oa,ch as la,ci as ca,cj as da,cn as ua,cd as ma,cc as ha,ks as ga,cm as fa,c3 as Es,fq as pa,Z as xa,af as wa,ag as ya,J as ba,ah as va,bI as ja,kt as Ca,ai as Na,ku as Sa,kv as ka,aj as Va,kw as Ia,K as Pa,c8 as Fa,jn as Ra,kx as Ba,l as Da,co as Ma,g as Ea,d6 as Ta,ao as fr,a5 as La,ky as Oa,kz as Bs}from"./useAppFontEffects-hfv2s6mZ.js";import{a as Aa,b as za}from"./main-BOYSXfYn.js";import{ab as Ga,Q as _a,i as $a,ah as Ha}from"./runtimeEndpointReset-BULHvOwb.js";import{u as pr}from"./vendor-zustand-BAGL70zf.js";import{h as Wa,u as Rt}from"./index-Dy8xgawx.js";import{C as Ua,a as Ka,D as qa}from"./DirtyBranchSwitchDialog-CU0A93Zx.js";import{P as Ja}from"./PierreDiffViewer-53Ghfnlr.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./useRootScrollLock-Cwc4kSl2.js";import"./scheduledTasksApi-DW3xqMQ8.js";import"./GuestAttachDialog-B-fwE8r3.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-U-hWbgJo.js";import"./computeVirtualFileMetrics-DHgQIkUq.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-DCXjBGRf.js";import"./isDiffPlainText-D9faP70y.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-BmtfVbo8.js";import"./appThemeRegistry-DDROzcUO.js";import"./textMateThemeFromAppTheme-Da7ed8qM.js";const Br="gitmojiCache",Ya=1e3*60*60*24*7,Dr="1",Qa="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Mr=o=>{if(!o||typeof o!="object")return!1;const e=o;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Ds=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(Br);if(!o)return null;const e=JSON.parse(o);return!e||e.version!==Dr||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(Mr),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Za=o=>{if(!(typeof window>"u"))try{const e={gitmojis:o,fetchedAt:Date.now(),version:Dr};window.localStorage.setItem(Br,JSON.stringify(e))}catch{return}},xr=o=>Date.now()-o.fetchedAt<Ya;let qt=null;const Bt=new Set,wr=async()=>{if(qt)return qt;const o=(async()=>{try{const e=await fetch(Qa);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const a=await e.json(),m=Array.isArray(a.gitmojis)?a.gitmojis.filter(Mr):[];return Za(m),Bt.forEach(N=>N(m)),m}catch(e){console.warn("Failed to load gitmoji list:",e);const a=[];return Bt.forEach(m=>m(a)),a}finally{qt=null}})();return qt=o,o},Xa=o=>{const[e,a]=l.useState(()=>o?Ds()?.gitmojis??[]:[]),[m,N]=l.useState(!1),f=l.useRef(o);f.current=o,l.useEffect(()=>{if(!o){Bt.delete(a),a([]),N(!1);return}const x=Ds();if(x&&(a(x.gitmojis),xr(x)))return;Bt.add(a),N(!0);let g=!1;return wr().finally(()=>{!g&&f.current&&N(!1)}),()=>{g=!0,Bt.delete(a)}},[o]);const p=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const x=Ds();return x&&xr(x)?x.gitmojis:wr()},[e]);return{gitmojis:e,isLoading:m,ensureLoaded:p}},Nt=async(o,e)=>{const a=await Wa(`/api/git/integrate/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){const m=await a.json().catch(()=>null);throw new Error(m?.error||`Git integrate request failed: ${a.statusText}`)}return a.json()};async function Ft(o){return Nt("plan",o)}async function ei(o){return Nt("conflict-details",{tempWorktreePath:o})}async function ti(o){return(await Nt("cherry-pick-status",{tempWorktreePath:o})).inProgress}async function si(o){return Nt("run",{plan:o})}async function ri(o){await Nt("abort",{state:o})}async function ni(o){return Nt("continue",{state:o})}const ai=({repoRoot:o,sourceBranch:e,worktreeMetadata:a,localBranches:m,defaultTargetBranch:N,refreshKey:f,onRefresh:p,showHeader:x=!0})=>{const{t:g}=nt(),w=rt(h=>h.currentSessionId),[M,v]=ve.useState(!1),[V,L]=ve.useState(""),S=ve.useRef(null),z=ve.useMemo(()=>Dt(m,V,h=>[h]),[m,V]),[C,y]=ve.useState(N);ve.useEffect(()=>{y(N)},[N]),ve.useEffect(()=>{if(M){const h=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(h)}},[M]);const D=!!(o&&e&&C&&C!=="HEAD"&&e!==C),[k,R]=ve.useState({kind:"idle"}),[P,F]=ve.useState(!1),[r,Y]=ve.useState([]),B=ve.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);ve.useEffect(()=>{if(!B||typeof window>"u")return;const h=window.localStorage.getItem(B);if(!h)return;let d=!1;try{const I=JSON.parse(h);if(!I?.tempWorktreePath||I.repoRoot!==o){window.localStorage.removeItem(B);return}(async()=>{const O=await ti(I.tempWorktreePath).catch(()=>!1);if(d)return;if(!O){window.localStorage.removeItem(B);return}const J=await ei(I.tempWorktreePath).catch(()=>null);d||J&&R({kind:"conflict",state:I,details:J})})()}catch{window.localStorage.removeItem(B)}return()=>{d=!0}},[B,o]),ve.useEffect(()=>{if(!D){R({kind:"idle"});return}let h=!1;return R({kind:"loading"}),(async()=>{try{const d=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C});if(h)return;if(R({kind:"ready",plan:d}),d.commits.length>0){const O=d.commits.slice(-50).reverse(),J=await _n(o,O);h||(Y(J),F(!1))}else h||(Y([]),F(!1))}catch{h||R({kind:"idle"})}})(),()=>{h=!0}},[D,o,e,C,f]);const u=ve.useCallback(h=>{w&&rt.getState().setWorktreeMetadata(w,{...a,createdFromBranch:h})},[w,a]),E=rt(h=>h.openNewSessionDraft),se=ve.useCallback(async h=>{const d=await Yt("git.integrate.cherrypick.resolve.visible",{current_commit:h.state.currentCommit,target_branch:h.state.targetBranch}),I=await Yt("git.integrate.cherrypick.resolve.instructions",{repo_root:h.state.repoRoot,temp_worktree_path:h.state.tempWorktreePath,source_branch:h.state.sourceBranch,target_branch:h.state.targetBranch,current_commit:h.state.currentCommit}),O=`Cherry-pick conflict context (JSON)
2
- ${JSON.stringify({repoRoot:h.state.repoRoot,tempWorktreePath:h.state.tempWorktreePath,sourceBranch:h.state.sourceBranch,targetBranch:h.state.targetBranch,currentCommit:h.state.currentCommit,remainingCommits:h.state.remainingCommits,statusPorcelain:h.details.statusPorcelain,unmergedFiles:h.details.unmergedFiles,currentPatchMeta:h.details.currentPatchMeta,currentPatch:h.details.currentPatch,diff:h.details.diff},null,2)}`;return{visibleText:d,instructionsText:I,payloadText:O}},[]),U=Qt(h=>h.setPendingInputText),G=Qt(h=>h.setPendingSyntheticParts),$=ve.useCallback(async(h,d)=>{const I=await se(h);if(d){E({directoryOverride:h.state.tempWorktreePath,initialPrompt:I.visibleText,syntheticParts:[{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}]});return}if(!w){b.error(g("gitView.integrate.noActiveSession"),{description:g("gitView.integrate.noActiveSessionDescription")});return}U(I.visibleText,"replace"),G([{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}])},[w,se,E,U,G,g]),Z=ve.useCallback(async()=>{if(k.kind==="ready"){if(k.plan.commits.length===0){b.message(g("gitView.integrate.noCommitsToMoveToast"));return}R({kind:"running",plan:k.plan});try{const h=await si(k.plan);if(h.kind==="success"){b.success(g("gitView.integrate.commitsMovedToast"),{description:h.moved===1?g("gitView.integrate.commitsMovedDescriptionSingle",{count:h.moved,branch:k.plan.targetBranch}):g("gitView.integrate.commitsMovedDescriptionPlural",{count:h.moved,branch:k.plan.targetBranch})});const d=await Ft(k.plan);R({kind:"ready",plan:d}),p?.();return}h.kind==="conflict"&&(b.error(g("gitView.integrate.cherryPickConflictToast"),{description:g("gitView.integrate.cherryPickConflictDescription")}),R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);b.error(g("gitView.integrate.failedToMoveToast"),{description:d});const I=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(I?{kind:"ready",plan:I}:{kind:"idle"})}}},[k,p,o,e,C,B,g]),H=ve.useCallback(async()=>{if(k.kind==="conflict")try{await ri(k.state),b.message(g("gitView.integrate.cherryPickAbortedToast")),B&&typeof window<"u"&&window.localStorage.removeItem(B)}finally{const h=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(h?{kind:"ready",plan:h}:{kind:"idle"})}},[k,o,e,C,B,g]),le=ve.useCallback(async()=>{if(k.kind==="conflict")try{const h=await ni(k.state);if(h.kind==="success"){b.success(g("gitView.integrate.cherryPickFinishedToast"));const d=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(d?{kind:"ready",plan:d}:{kind:"idle"}),B&&typeof window<"u"&&window.localStorage.removeItem(B),p?.();return}h.kind==="conflict"&&(R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);b.error(g("gitView.integrate.cherryPickContinueFailedToast"),{description:d})}},[k,o,e,C,p,B,g]);return!o||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[x?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(T,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.integrate.title")}),k.kind==="ready"&&k.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:g("gitView.integrate.toMoveCount",{count:k.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:k.kind==="loading"||k.kind==="running"?t.jsx(T,{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:g("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",C]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Ts,{open:M,onOpenChange:v,children:[t.jsx(Ls,{asChild:!0,children:t.jsxs("button",{type:"button",className:Fr({size:"default"}),children:[g("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:C}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Os,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(As,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(zs,{ref:S,placeholder:g("gitView.branch.searchPlaceholder"),value:V,onValueChange:L,onKeyDown:h=>h.stopPropagation()}),t.jsxs(Gs,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(_s,{children:g("gitView.branch.empty")}),t.jsx(Zt,{heading:g("gitView.branch.localBranches"),children:z.map(h=>t.jsx(Xt,{value:h,onSelect:()=>{y(h),u(h),v(!1),L("")},children:h},h))})]})]})})]}),k.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{Z()},disabled:!D||k.plan.commits.length===0,children:g("gitView.integrate.move")}):k.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.checking")}):k.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.moving")}):null]}),k.kind==="ready"&&k.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.noCommitsToMove")}),k.kind==="ready"&&k.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:[g("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",k.plan.commits.length,")"]})]}),r.length>0&&k.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>F(h=>!h),className:"typography-micro text-muted-foreground hover:text-foreground",children:g(P?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(P?r:r.slice(0,5)).map(h=>t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"font-mono text-xs text-muted-foreground flex-shrink-0",children:h.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:h.subject||h.sha})]},h.sha)),r.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.previewUnavailable")}),k.plan.commits.length>r.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:g("gitView.integrate.showingFirstCommits",{count:r.length})})]})]}),k.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:g("gitView.integrate.conflictsInFiles",{count:k.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[g("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:k.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[k.details.unmergedFiles.slice(0,6).map(h=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:h},h)),k.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:g("gitView.integrate.moreFiles",{count:k.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{H()},children:g("gitView.operation.abort")}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!w,onClick:()=>{$({state:k.state,details:k.details},!1)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.currentSession")]}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{$({state:k.state,details:k.details},!0)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{le()},children:g("gitView.operation.continue")})]})]})]})]})},ii=({open:o,onOpenChange:e,directory:a,hasUncommittedChanges:m,hasStagedChanges:N=!1,uncommittedFileCount:f,onChanged:p})=>{const{t:x}=nt(),[g,w]=l.useState([]),[M,v]=l.useState(!1),[V,L]=l.useState(""),[S,z]=l.useState(""),[C,y]=l.useState(null),[D,k]=l.useState({}),R=l.useCallback(async()=>{if(a){v(!0);try{const u=await $n(a);w(u.stashes),k({})}catch(u){b.error(u instanceof Error?u.message:x("gitView.stashes.toast.loadFailed"))}finally{v(!1)}}},[a,x]);l.useEffect(()=>{o&&R()},[R,o]),l.useEffect(()=>{if(!o||!a||g.length===0)return;let u=!1;const E=g.map(se=>se.ref);return Hn(a,E).then(se=>{u||k(se.counts)}).catch(()=>{}),()=>{u=!0}},[a,o,g]);const P=l.useMemo(()=>Dt(g,V,u=>[u.message,u.ref,u.relativeTime]),[V,g]),F=l.useCallback(async u=>{await R(),await p?.(u)},[R,p]),r=async()=>{if(!(!a||C)){y("create");try{const u=await Wn(a,{message:S.trim()||void 0});u.created?(b.success(x("gitView.stashes.toast.created")),z("")):b.info(x("gitView.stashes.toast.noChanges")),await F({affectsIndex:!!(u.created&&N)})}catch(u){b.error(u instanceof Error?u.message:x("gitView.stashes.toast.createFailed"))}finally{y(null)}}},Y=async(u,E)=>{if(!(!a||C)&&!(E==="drop"&&!window.confirm(x("gitView.stashes.confirm.drop",{ref:u.ref})))){y(`${E}:${u.ref}`);try{E==="apply"&&await Un(a,{ref:u.ref}),E==="pop"&&await Kn(a,{ref:u.ref}),E==="drop"&&await qn(a,{ref:u.ref});const se=E==="apply"?"gitView.stashes.toast.applySuccess":E==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";b.success(x(se)),await F({affectsIndex:E!=="drop"})}catch(se){const U=E==="apply"?"gitView.stashes.toast.applyFailed":E==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";b.error(se instanceof Error?se.message:x(U)),await F({affectsIndex:E!=="drop"})}finally{y(null)}}},B=C!==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(gt,{children:[t.jsxs(ft,{className:"flex items-center gap-2",children:[t.jsx(T,{name:"archive-stack",className:"h-5 w-5"}),x("gitView.stashes.title")]}),t.jsx(bt,{children:x("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(gr,{value:S,onChange:u=>z(u.target.value),placeholder:x("gitView.stashes.messagePlaceholder"),disabled:B||!m,className:"flex-1"}),t.jsxs(W,{onClick:r,disabled:!m||B||!a,children:[C==="create"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"inbox-archive",className:"size-4"}),x("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:x("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(T,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(gr,{value:V,onChange:u=>L(u.target.value),placeholder:x("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:M?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(T,{name:"loader-4",className:"size-5 animate-spin"})}):P.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:x(V?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):P.map((u,E)=>t.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[t.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[t.jsx("p",{className:"typography-small truncate text-foreground",children:u.message||x("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(es,{children:[t.jsx(ts,{asChild:!0,children:t.jsx("span",{children:E===0&&!V.trim()?x("gitView.stashes.latestLabel"):x("gitView.stashes.itemNumber",{number:E+1})})}),t.jsx(ss,{sideOffset:6,children:u.ref})]})," · ",u.relativeTime," · ",typeof D[u.ref]=="number"?x("gitView.stashes.fileCount",{count:D[u.ref]}):x("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Ms,{label:x("gitView.stashes.actions.apply"),loading:C===`apply:${u.ref}`,onClick:()=>Y(u,"apply"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.pop"),loading:C===`pop:${u.ref}`,onClick:()=>Y(u,"pop"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.drop"),loading:C===`drop:${u.ref}`,onClick:()=>Y(u,"drop"),disabled:B,destructive:!0,children:t.jsx(T,{name:"delete-bin",className:"size-4"})})]})]},u.ref))})]})})},Ms=o=>{const e=Ct.c(17),{label:a,loading:m,disabled:N,destructive:f,onClick:p,children:x}=o,g=m||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let M;e[0]!==w?(M=Se("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=M):M=e[1];let v;e[2]!==x||e[3]!==m?(v=m?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):x,e[2]=x,e[3]=m,e[4]=v):v=e[4];let V;e[5]!==N||e[6]!==a||e[7]!==p||e[8]!==g||e[9]!==M||e[10]!==v?(V=t.jsx(ts,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":a,"aria-busy":g,className:M,onClick:p,disabled:N,children:v})}),e[5]=N,e[6]=a,e[7]=p,e[8]=g,e[9]=M,e[10]=v,e[11]=V):V=e[11];let L;e[12]!==a?(L=t.jsx(ss,{sideOffset:6,children:a}),e[12]=a,e[13]=L):L=e[13];let S;return e[14]!==V||e[15]!==L?(S=t.jsxs(es,{children:[V,L]}),e[14]=V,e[15]=L,e[16]=S):S=e[16],S},oi=o=>{const e=Ct.c(16),{onOpenStashes:a}=o,{t:m}=nt();let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(T,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=N):N=e[0];let f;e[1]!==m?(f=m("gitView.empty.cleanTitle"),e[1]=m,e[2]=f):f=e[2];let p;e[3]!==f?(p=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=p):p=e[4];let x;e[5]!==m?(x=m("gitView.empty.cleanDescription"),e[5]=m,e[6]=x):x=e[6];let g;e[7]!==x?(g=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:x}),e[7]=x,e[8]=g):g=e[8];let w;e[9]!==a||e[10]!==m?(w=a?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[t.jsx(T,{name:"archive-stack",className:"size-4"}),m("gitView.stashes.title")]}):null,e[9]=a,e[10]=m,e[11]=w):w=e[11];let M;return e[12]!==p||e[13]!==g||e[14]!==w?(M=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[N,p,g,w]}),e[12]=p,e[13]=g,e[14]=w,e[15]=M):M=e[15],M},ut=8,li=o=>{const e=Ct.c(18),{laned:a,totalLanes:m,isExpanded:N}=o,{lane:f,color:p,connectors:x}=a,w=Math.max(m,f+1)*ut+ut/2,M=l.useRef(null),v=l.useRef(null);let V;e[0]!==p||e[1]!==x||e[2]!==f||e[3]!==w?(V=()=>{const y=M.current,D=v.current;if(!y||!D)return;const k=y.offsetHeight;if(k===0)return;const R=window.devicePixelRatio||1;D.width=w*R,D.height=k*R;const P=D.getContext("2d");if(!P)return;P.scale(R,R),P.clearRect(0,0,w,k);const F=k/2,r=f*ut+ut/2,Y=getComputedStyle(D),B=Y.getPropertyValue("--surface-muted-foreground").trim()||Y.color,u=U=>{if(!U.startsWith("var("))return U;const G=U.slice(4,-1).trim();return Y.getPropertyValue(G).trim()||B},E=[...x].sort(di);for(const U of E){const G=U.fromLane*ut+ut/2,$=U.toLane*ut+ut/2,Z=U.type==="passing"?.72:U.type==="branch-out"||U.type==="merge-in"?.95:1;P.beginPath(),P.strokeStyle=u(U.color),P.globalAlpha=Z,P.lineWidth=1.25,P.lineCap="round";e:switch(U.type){case"passing":case"commit-lane":{P.moveTo(G,0),P.lineTo(G,k);break e}case"top-stub":{P.moveTo(G,0),P.lineTo(G,F);break e}case"bottom-stub":{P.moveTo(G,F),P.lineTo(G,k);break e}case"branch-out":{const H=(F+k)/2;P.moveTo(r,F),P.bezierCurveTo(r,H,$,H,$,k);break e}case"merge-in":{const H=F/2;P.moveTo(G,0),P.bezierCurveTo(G,H,r,H,r,F);break e}default:continue}P.stroke(),P.globalAlpha=1}const se=Y.getPropertyValue("--background").trim()||Y.getPropertyValue("--surface-background").trim();P.beginPath(),P.arc(r,F,4,0,Math.PI*2),P.fillStyle=u(p),P.fill(),P.beginPath(),P.arc(r,F,5,0,Math.PI*2),P.strokeStyle=se||B,P.lineWidth=2,P.stroke()},e[0]=p,e[1]=x,e[2]=f,e[3]=w,e[4]=V):V=e[4];let L;e[5]!==p||e[6]!==x||e[7]!==N||e[8]!==f||e[9]!==a||e[10]!==m||e[11]!==w?(L=[a,f,p,x,m,N,w],e[5]=p,e[6]=x,e[7]=N,e[8]=f,e[9]=a,e[10]=m,e[11]=w,e[12]=L):L=e[12],l.useLayoutEffect(V,L);let S;e[13]!==w?(S={width:w,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=w,e[14]=S):S=e[14];let z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("canvas",{ref:v,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=z):z=e[15];let C;return e[16]!==S?(C=t.jsx("div",{ref:M,style:S,children:z}),e[16]=S,e[17]=C):C=e[17],C};function ci(o){return o==="branch-out"||o==="merge-in"}function di(o,e){const a=ci;return(a(o.type)?1:0)-(a(e.type)?1:0)}const yr=15e3,br=500,vr=12,jr=8*1024*1024,Cr=o=>typeof o=="string"?0:(o.original?.length??0)+(o.modified?.length??0),Nr=o=>{if(o.size<=vr){let N=0;for(const f of o.values())N+=Cr(f);if(N<=jr)return o}const e=Array.from(o.entries()).reverse(),a=new Map;let m=0;for(const[N,f]of e){if(a.size>=vr)continue;const p=Cr(f);m+p>jr&&a.size>0||(a.set(N,f),m+=p)}return new Map(Array.from(a.entries()).reverse())};function Sr(o,e){const a=new Date(o);return Number.isNaN(a.getTime())?o:Zn(a,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ui(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 mi(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 hi=l.memo(({entry:o,mode:e="history",laned:a,totalLanes:m,isExpanded:N,onToggle:f,files:p,isLoadingFiles:x,onCopyHash:g,directory:w,onConflict:M,onActionSuccess:v})=>{const{t:V}=nt(),L=Rt(d=>d.timeFormatPreference),S=e==="graph",[z,C]=l.useState(null),[y,D]=l.useState(!1),[k,R]=l.useState(""),[P,F]=l.useState(null),[r,Y]=l.useState(new Set),[B,u]=l.useState(new Map),[E,se]=l.useState(new Set),U=async()=>{if(w){C("checkout");try{await aa(w,o.hash),b.success(V("gitView.history.actions.detachedHead")),v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},G=async()=>{if(!(!w||!k.trim())){C("createBranch");try{await Xn(w,k.trim(),o.hash),D(!1),R(""),v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},$=async()=>{if(w){C("cherryPick");try{const d=await na(w,o.hash);d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"cherry-pick"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},Z=async()=>{if(w){C("revert");try{const d=await ra(w,o.hash);d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"revert"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},H=async(d,I=!1)=>{if(!(!w||z!==null)){C("reset");try{await ea(w,o.hash,d,I),v?.()}catch(O){b.error(String(O.message))}finally{C(null)}}},le=async()=>{if(!P)return;const d=P;switch(F(null),d){case"checkout":return U();case"cherryPick":return $();case"revert":return Z();case"merge":return ae();case"rebase":return ce();case"resetSoft":return H("soft");case"resetMixed":return H("mixed");case"resetHard":return H("hard",!0)}},ae=async()=>{if(w){C("merge");try{const d=await sa(w,{branch:o.hash});d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"merge"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},ce=async()=>{if(w){C("rebase");try{const d=await ta(w,{onto:o.hash});d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"rebase"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},ie=l.useCallback(async d=>{const I=d.path;if(!w){u(O=>new Map(O).set(I,"error"));return}u(O=>Nr(new Map(O).set(I,"loading")));try{const O=Jn(w,o.hash,d.path,!1),J=new Promise((re,q)=>{setTimeout(()=>q(new Error(`Timed out after ${yr}ms`)),yr)}),ne=await Promise.race([O,J]);u(re=>Nr(new Map(re).set(I,ne)))}catch{u(O=>new Map(O).set(I,"error"))}},[w,o.hash]),h=l.useCallback(async d=>{const I=d.path;if(d.changeType==="R"||d.isBinary){Y(re=>{const q=new Set(re);return q.has(I)?q.delete(I):q.add(I),q});return}const O=B.get(I);if(r.has(I)&&O&&O!=="error"){Y(re=>{const q=new Set(re);return q.delete(I),q});return}Y(re=>{const q=new Set(re);return q.add(I),q}),!(O&&O!=="error"||d.insertions+d.deletions>br&&!E.has(I))&&await ie(d)},[B,E,ie,r]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Se("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":N?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&a&&m!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(li,{laned:a,totalLanes:m,isExpanded:N})}):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 d=mi(o.refs);return d.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:d.map(I=>t.jsx("span",{className:Se("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:Sr(o.date,L),children:Sr(o.date,L)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:o.hash.slice(0,8)}),t.jsxs(es,{children:[t.jsx(ts,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:d=>{d.stopPropagation(),g(o.hash)},children:t.jsx(T,{name:"file-copy",className:"size-3"})})}),t.jsx(ss,{sideOffset:8,children:V("gitView.history.copySha")})]})]})]})]}),N&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[S&&P?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:V(`gitView.history.actions.${P}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),le()},children:[z!==null?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.confirmButton")]}),t.jsx(W,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),F(null)},children:V("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(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("checkout")},children:V("gitView.history.actions.checkout")}),y?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:k,onChange:d=>R(d.target.value),onKeyDown:d=>{d.key==="Enter"&&G(),d.key==="Escape"&&(D(!1),R(""))},placeholder:V("gitView.history.actions.createBranchPlaceholder"),className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:!k.trim()||z!==null,onClick:d=>{d.stopPropagation(),G()},children:[z==="createBranch"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(W,{variant:"outline",size:"xs",className:"h-6",onClick:d=>{d.stopPropagation(),D(!0)},children:V("gitView.history.actions.createBranch")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("cherryPick")},children:V("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("revert")},children:V("gitView.history.actions.revert")}),t.jsxs(Ts,{children:[t.jsx(Ls,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>d.stopPropagation(),children:[z==="reset"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.reset")]})}),t.jsx(Os,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(d=>t.jsx(Yn,{disabled:z!==null,onSelect:I=>{I.stopPropagation(),F(`reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},children:V(`gitView.history.actions.reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},d))})]}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("merge")},children:V("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("rebase")},children:V("gitView.history.actions.rebase")})]}):null,x?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:V("gitView.history.loadingFiles")})]}):p.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:V("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:p.map(d=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>h(d),className:Se("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",r.has(d.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:Se("font-semibold w-3 text-center shrink-0",ui(d.changeType)),children:d.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:d.path,children:d.path}),!d.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",d.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d.deletions]})]}),d.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:V("gitView.history.binary")}),t.jsx(T,{name:r.has(d.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),r.has(d.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:d.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.renamedNoDiff")}):d.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.binaryNoDiff")}):(()=>{const I=d.insertions+d.deletions;if(!E.has(d.path)&&I>br)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:V("gitView.history.largeDiffTitle",{count:I})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:V("gitView.history.largeDiffDescription")}),t.jsx(W,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{se(J=>new Set(J).add(d.path)),ie(d)},children:V("gitView.history.renderDiffAnyway")})]});const O=B.get(d.path);return O==="loading"||O===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.loadingDiff")}):O==="error"?t.jsx("button",{type:"button",onClick:()=>h(d),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:V("gitView.history.diffError")}):t.jsx(Ja,{original:O.original,modified:O.modified,language:Qn(d.path)||"",fileName:d.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},d.path))})]})]})}),kr=["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 Jt(o){return kr[o%kr.length]}function gi(o){if(o.length===0)return[];const e=[],a=[];for(let m=0;m<o.length;m++){const N=o[m],f=[];for(let S=0;S<e.length;S++)e[S]===N.hash&&f.push(S);let p=f.length>0?f[0]:-1;if(p===-1){const S=e.indexOf(null);S!==-1?p=S:(p=e.length,e.push(null))}const x=f.slice(1),g=Jt(p),w=e[p]===N.hash,M=N.parents.length>0;M?e[p]=N.parents[0]:e[p]=null;const v=[],V=new Set;for(let S=1;S<N.parents.length;S++){const z=N.parents[S],C=e.indexOf(z);if(C!==-1)v.push(C);else{const y=e.indexOf(null);if(y!==-1)e[y]=z,v.push(y),V.add(y);else{const D=e.length;e.push(z),v.push(D),V.add(D)}}}const L=[];w&&M?L.push({fromLane:p,toLane:p,color:g,type:"commit-lane"}):w&&!M?L.push({fromLane:p,toLane:p,color:g,type:"top-stub"}):!w&&M&&L.push({fromLane:p,toLane:p,color:g,type:"bottom-stub"});for(const S of x)L.push({fromLane:S,toLane:p,color:Jt(S),type:"merge-in"}),e[S]=null;for(const S of v)L.push({fromLane:p,toLane:S,color:Jt(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==p&&(V.has(S)||L.push({fromLane:S,toLane:S,color:Jt(S),type:"passing"}));a.push({commit:N,lane:p,color:g,connectors:L})}return a}const fi=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],pi=o=>{const e=Ct.c(84),{mode:a,log:m,isLogLoading:N,logMaxCount:f,onLogMaxCountChange:p,expandedCommitHashes:x,onToggleCommit:g,commitFilesMap:w,loadingCommitHashes:M,onCopyHash:v,directory:V,showHeader:L,contentMaxHeightClassName:S,branchDivider:z,onConflict:C,onActionSuccess:y}=o,D=a===void 0?"history":a,k=L===void 0?!0:L,R=S===void 0?"max-h-[50vh]":S,P=z===void 0?null:z,{t:F}=nt(),[r,Y]=l.useState(!0),B=D==="graph";let u;e[0]!==B||e[1]!==m?(u=B&&m?gi(m.all):[],e[0]=B,e[1]=m,e[2]=u):u=e[2];const E=u;let se;e[3]!==E?(se=Math.max(1,...E.map(xi)),e[3]=E,e[4]=se):se=e[4];const U=se;let G;e[5]!==E?(G=new Map(E.map(wi)),e[5]=E,e[6]=G):G=e[6];const $=G;if(!m)return null;const Z=P!==null&&P.insertBeforeIndex>0&&P.insertBeforeIndex<m.all.length,H=P!==null&&P.insertBeforeIndex===m.all.length,le=Z||H;let ae;e[7]!==P||e[8]!==Z||e[9]!==H||e[10]!==m.all?(ae=Z?m.all.slice(0,P.insertBeforeIndex):H?m.all:[],e[7]=P,e[8]=Z,e[9]=H,e[10]=m.all,e[11]=ae):ae=e[11];const ce=ae;let ie;if(e[12]!==P||e[13]!==w||e[14]!==R||e[15]!==V||e[16]!==x||e[17]!==Z||e[18]!==le||e[19]!==B||e[20]!==N||e[21]!==$||e[22]!==M||e[23]!==m.all||e[24]!==f||e[25]!==U||e[26]!==D||e[27]!==y||e[28]!==C||e[29]!==v||e[30]!==p||e[31]!==g||e[32]!==F||e[33]!==ce){const K=Z?m.all.slice(P.insertBeforeIndex):[];let de;e[35]!==P?.direction?(de=P?.direction==="down"?t.jsx(T,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(T,{name:"arrow-up",className:"size-3.5"}),e[35]=P?.direction,e[36]=de):de=e[36];const ke=de;let ye;e[37]!==w||e[38]!==V||e[39]!==x||e[40]!==B||e[41]!==$||e[42]!==M||e[43]!==U||e[44]!==D||e[45]!==y||e[46]!==C||e[47]!==v||e[48]!==g?(ye=Re=>t.jsx("ul",{className:"divide-y divide-border/60",children:Re.map(ue=>t.jsx(hi,{entry:ue,mode:D,laned:B?$.get(ue.hash):void 0,totalLanes:B?U:void 0,isExpanded:x.has(ue.hash),onToggle:()=>g(ue.hash),files:w.get(ue.hash)??[],isLoadingFiles:M.has(ue.hash),onCopyHash:v,directory:V,onConflict:C,onActionSuccess:y},ue.hash))}),e[37]=w,e[38]=V,e[39]=x,e[40]=B,e[41]=$,e[42]=M,e[43]=U,e[44]=D,e[45]=y,e[46]=C,e[47]=v,e[48]=g,e[49]=ye):ye=e[49];const me=ye;let xe;e[50]!==N||e[51]!==m.all.length||e[52]!==f||e[53]!==p||e[54]!==F?(xe=m.all.length>=f?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(W,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(f+25),disabled:N,className:"px-3 text-muted-foreground hover:text-foreground",children:N?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(T,{name:"loader-4",className:"size-3 animate-spin"}),F("gitView.history.loadingMore")]}):F("gitView.history.loadMore")})}):null,e[50]=N,e[51]=m.all.length,e[52]=f,e[53]=p,e[54]=F,e[55]=xe):xe=e[55];const Ve=xe;ie=t.jsx(Rr,{outerClassName:`min-h-0 ${R}`,className:"h-full w-full",children:m.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:F("gitView.history.noCommits")})}):le&&P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[ce.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(ce)}):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:P.branchName,children:P.branchName}),ke]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),K.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(K)}):null]}),Ve]}):t.jsxs(t.Fragment,{children:[me(m.all),Ve]})}),e[12]=P,e[13]=w,e[14]=R,e[15]=V,e[16]=x,e[17]=Z,e[18]=le,e[19]=B,e[20]=N,e[21]=$,e[22]=M,e[23]=m.all,e[24]=f,e[25]=U,e[26]=D,e[27]=y,e[28]=C,e[29]=v,e[30]=p,e[31]=g,e[32]=F,e[33]=ce,e[34]=ie}else ie=e[34];const h=ie;if(!k){if(le){let de;return e[56]!==h?(de=t.jsx("section",{className:"h-full min-h-0",children:h}),e[56]=h,e[57]=de):de=e[57],de}let K;return e[58]!==h?(K=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:h}),e[58]=h,e[59]=K):K=e[59],K}let d;e[60]!==F?(d=F("gitView.history.title"),e[60]=F,e[61]=d):d=e[61];let I;e[62]!==d?(I=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:d}),e[62]=d,e[63]=I):I=e[63];let O;e[64]!==N||e[65]!==r||e[66]!==f||e[67]!==p||e[68]!==F?(O=r&&t.jsx("div",{onClick:yi,onPointerDown:bi,children:t.jsxs(ia,{value:String(f),onValueChange:K=>p(Number(K)),disabled:N,children:[t.jsx(oa,{size:"sm",className:"w-auto",disabled:N,children:t.jsx(la,{placeholder:F("gitView.history.commitsPlaceholder")})}),t.jsx(ca,{children:fi.map(K=>t.jsx(da,{value:String(K.value),children:F(K.labelKey)},K.value))})]})}),e[64]=N,e[65]=r,e[66]=f,e[67]=p,e[68]=F,e[69]=O):O=e[69];let J;e[70]!==r?(J=r?t.jsx(T,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(T,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=r,e[71]=J):J=e[71];let ne;e[72]!==O||e[73]!==J?(ne=t.jsxs("div",{className:"flex items-center gap-2",children:[O,J]}),e[72]=O,e[73]=J,e[74]=ne):ne=e[74];let re;e[75]!==I||e[76]!==ne?(re=t.jsxs(ua,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[I,ne]}),e[75]=I,e[76]=ne,e[77]=re):re=e[77];let q;e[78]!==h?(q=t.jsx(ma,{children:h}),e[78]=h,e[79]=q):q=e[79];let we;return e[80]!==r||e[81]!==re||e[82]!==q?(we=t.jsxs(ha,{open:r,onOpenChange:Y,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[re,q]}),e[80]=r,e[81]=re,e[82]=q,e[83]=we):we=e[83],we};function xi(o){return o.lane+1}function wi(o){return[o.commit.hash,o]}function yi(o){return o.stopPropagation()}function bi(o){return o.stopPropagation()}const vi=o=>{const e=Ct.c(148),{open:a,onOpenChange:m,conflictFiles:N,directory:f,operation:p,onAbort:x,onClearState:g}=o;let w;e[0]!==N?(w=N===void 0?[]:N,e[0]=N,e[1]=w):w=e[1];const M=w,{t:v}=nt(),V=rt(ji),L=rt(Ci),S=Qt(Ni),z=Qt(Si),[C,y]=l.useState(!1),[D,k]=l.useState(null),[R,P]=l.useState(null);let F,r;e[2]!==f||e[3]!==a||e[4]!==v?(F=()=>{!a||!f||(y(!0),P(null),k(null),ga(f).then(ee=>{k(ee)}).catch(ee=>{const he=ee instanceof Error?ee.message:v("gitView.conflict.loadFailed");P(he)}).finally(()=>{y(!1)}))},r=[a,f,v],e[2]=f,e[3]=a,e[4]=v,e[5]=F,e[6]=r):(F=e[5],r=e[6]),l.useEffect(F,r);let Y;e[7]!==D||e[8]!==f||e[9]!==p?(Y=async()=>{if(!D)return null;const ee=p==="merge"?"merge":"rebase",he=D.headInfo||(p==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Be=p==="merge"?"git commit --no-edit":"git rebase --continue",ge=await Yt("git.conflict.resolve.visible",{operation_label:ee,head_ref:he}),Ne=await Yt("git.conflict.resolve.instructions",{operation_label:ee,directory:f,operation:p,head_info:D.headInfo||"N/A",continue_cmd:Be}),Ie=`${ee} conflict context (JSON)
3
- ${JSON.stringify({directory:f,operation:D.operation,headInfo:D.headInfo,statusPorcelain:D.statusPorcelain,unmergedFiles:D.unmergedFiles,diff:D.diff},null,2)}`;return{visibleText:ge,instructionsText:Ne,payloadText:Ie}},e[7]=D,e[8]=f,e[9]=p,e[10]=Y):Y=e[10];const B=Y;let u;e[11]!==x||e[12]!==m?(u=()=>{x(),m(!1)},e[11]=x,e[12]=m,e[13]=u):u=e[13];const E=u;let se;e[14]!==g||e[15]!==m?(se=()=>{g?.(),m(!1)},e[14]=g,e[15]=m,e[16]=se):se=e[16];const U=se;let G;e[17]!==B||e[18]!==L||e[19]!==g||e[20]!==m||e[21]!==S||e[22]!==z||e[23]!==v?(G=async()=>{const ee=await B();if(!ee){b.error(v("gitView.conflict.noDetailsAvailable"));return}if(!L){b.error(v("gitView.conflict.noActiveSession"),{description:v("gitView.conflict.noActiveSessionDescription")});return}S(ee.visibleText,"replace"),z([{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]),g?.(),m(!1)},e[17]=B,e[18]=L,e[19]=g,e[20]=m,e[21]=S,e[22]=z,e[23]=v,e[24]=G):G=e[24];const $=G;let Z;e[25]!==B||e[26]!==f||e[27]!==g||e[28]!==m||e[29]!==V||e[30]!==v?(Z=async()=>{const ee=await B();if(!ee){b.error(v("gitView.conflict.noDetailsAvailable"));return}V({directoryOverride:f,initialPrompt:ee.visibleText,syntheticParts:[{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]}),g?.(),m(!1)},e[25]=B,e[26]=f,e[27]=g,e[28]=m,e[29]=V,e[30]=v,e[31]=Z):Z=e[31];const H=Z;let le,ae,ce,ie,h,d,I,O,J,ne,re,q,we,K,de,ke,ye,me,xe,Ve,Re,ue;if(e[32]!==D||e[33]!==M||e[34]!==L||e[35]!==E||e[36]!==U||e[37]!==$||e[38]!==H||e[39]!==C||e[40]!==R||e[41]!==m||e[42]!==a||e[43]!==p||e[44]!==v){const ee=v(p==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),he=D?.unmergedFiles||M;ce=mt,Re=a,ue=m,ae=ht,Ve="max-w-md w-[calc(100vw-2rem)]",K="flex flex-col gap-4 overflow-hidden";let Be;e[67]===Symbol.for("react.memo_cache_sentinel")?(Be=t.jsx(T,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[67]=Be):Be=e[67];const ge=t.jsxs("div",{className:"flex items-center gap-2",children:[Be,t.jsx(ft,{children:v("gitView.conflict.detectedTitle",{operation:ee})})]});let Ne;e[68]!==p||e[69]!==v?(Ne=v("gitView.conflict.detectedDescription",{operation:p}),e[68]=p,e[69]=v,e[70]=Ne):Ne=e[70];let Ie;e[71]!==Ne?(Ie=t.jsx(bt,{children:Ne}),e[71]=Ne,e[72]=Ie):Ie=e[72],e[73]!==ge||e[74]!==Ie?(de=t.jsxs(gt,{children:[ge,Ie]}),e[73]=ge,e[74]=Ie,e[75]=de):de=e[75],e[76]!==C||e[77]!==v?(ke=C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:v("gitView.conflict.loading")})]}),e[76]=C,e[77]=v,e[78]=ke):ke=e[78],e[79]!==R||e[80]!==v?(ye=R&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:v("gitView.conflict.errorLoadingDetails",{message:R})}),e[79]=R,e[80]=v,e[81]=ye):ye=e[81],e[82]!==he||e[83]!==v?(me=he.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:v("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:he.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:he.map(ki)})})]}),e[82]=he,e[83]=v,e[84]=me):me=e[84],e[85]!==D||e[86]!==v?(xe=D?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:v("gitView.conflict.headInfo")}),t.jsx("div",{className:"typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:D.headInfo})]}),e[85]=D,e[86]=v,e[87]=xe):xe=e[87],re="flex flex-col gap-2 pt-2";let Te;e[88]!==H?(Te=()=>{H()},e[88]=H,e[89]=Te):Te=e[89];const oe=C||!D;let Pe;e[90]!==C?(Pe=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"add",className:"size-4"}),e[90]=C,e[91]=Pe):Pe=e[91];let Fe;e[92]!==v?(Fe=v("gitView.conflict.resolveNewSession"),e[92]=v,e[93]=Fe):Fe=e[93],e[94]!==Te||e[95]!==oe||e[96]!==Pe||e[97]!==Fe?(q=t.jsxs(W,{variant:"default",onClick:Te,disabled:oe,className:"w-full gap-2",children:[Pe,Fe]}),e[94]=Te,e[95]=oe,e[96]=Pe,e[97]=Fe,e[98]=q):q=e[98];let De;e[99]!==$?(De=()=>{$()},e[99]=$,e[100]=De):De=e[100];const Ue=C||!D||!L;let Le;e[101]!==C?(Le=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"chat-1",className:"size-4"}),e[101]=C,e[102]=Le):Le=e[102];let Q;e[103]!==v?(Q=v("gitView.conflict.resolveCurrentSession"),e[103]=v,e[104]=Q):Q=e[104],e[105]!==De||e[106]!==Ue||e[107]!==Le||e[108]!==Q?(we=t.jsxs(W,{variant:"outline",onClick:De,disabled:Ue,className:"w-full gap-2",children:[Le,Q]}),e[105]=De,e[106]=Ue,e[107]=Le,e[108]=Q,e[109]=we):we=e[109],J="flex gap-2 pt-1";let fe;e[110]!==v?(fe=v("gitView.conflict.continueLater"),e[110]=v,e[111]=fe):fe=e[111],e[112]!==U||e[113]!==fe?(ne=t.jsx(W,{variant:"ghost",size:"sm",onClick:U,className:"flex-1",children:fe}),e[112]=U,e[113]=fe,e[114]=ne):ne=e[114],le=W,ie="destructive",h="sm",d=E,I="flex-1",O=v("gitView.conflict.abortOperation",{operation:ee}),e[32]=D,e[33]=M,e[34]=L,e[35]=E,e[36]=U,e[37]=$,e[38]=H,e[39]=C,e[40]=R,e[41]=m,e[42]=a,e[43]=p,e[44]=v,e[45]=le,e[46]=ae,e[47]=ce,e[48]=ie,e[49]=h,e[50]=d,e[51]=I,e[52]=O,e[53]=J,e[54]=ne,e[55]=re,e[56]=q,e[57]=we,e[58]=K,e[59]=de,e[60]=ke,e[61]=ye,e[62]=me,e[63]=xe,e[64]=Ve,e[65]=Re,e[66]=ue}else le=e[45],ae=e[46],ce=e[47],ie=e[48],h=e[49],d=e[50],I=e[51],O=e[52],J=e[53],ne=e[54],re=e[55],q=e[56],we=e[57],K=e[58],de=e[59],ke=e[60],ye=e[61],me=e[62],xe=e[63],Ve=e[64],Re=e[65],ue=e[66];let $e;e[115]!==le||e[116]!==ie||e[117]!==h||e[118]!==d||e[119]!==I||e[120]!==O?($e=t.jsx(le,{variant:ie,size:h,onClick:d,className:I,children:O}),e[115]=le,e[116]=ie,e[117]=h,e[118]=d,e[119]=I,e[120]=O,e[121]=$e):$e=e[121];let Ae;e[122]!==J||e[123]!==ne||e[124]!==$e?(Ae=t.jsxs("div",{className:J,children:[ne,$e]}),e[122]=J,e[123]=ne,e[124]=$e,e[125]=Ae):Ae=e[125];let je;e[126]!==re||e[127]!==q||e[128]!==we||e[129]!==Ae?(je=t.jsxs("div",{className:re,children:[q,we,Ae]}),e[126]=re,e[127]=q,e[128]=we,e[129]=Ae,e[130]=je):je=e[130];let be;e[131]!==K||e[132]!==de||e[133]!==ke||e[134]!==ye||e[135]!==me||e[136]!==xe||e[137]!==je?(be=t.jsxs("div",{className:K,children:[de,ke,ye,me,xe,je]}),e[131]=K,e[132]=de,e[133]=ke,e[134]=ye,e[135]=me,e[136]=xe,e[137]=je,e[138]=be):be=e[138];let Ce;e[139]!==ae||e[140]!==Ve||e[141]!==be?(Ce=t.jsx(ae,{className:Ve,children:be}),e[139]=ae,e[140]=Ve,e[141]=be,e[142]=Ce):Ce=e[142];let Ee;return e[143]!==ce||e[144]!==Re||e[145]!==ue||e[146]!==Ce?(Ee=t.jsx(ce,{open:Re,onOpenChange:ue,children:Ce}),e[143]=ce,e[144]=Re,e[145]=ue,e[146]=Ce,e[147]=Ee):Ee=e[147],Ee};function ji(o){return o.openNewSessionDraft}function Ci(o){return o.currentSessionId}function Ni(o){return o.setPendingInputText}function Si(o){return o.setPendingSyntheticParts}function ki(o){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:o,children:o},o)}const Vi=({open:o,onOpenChange:e,operation:a,targetBranch:m,onConfirm:N})=>{const{t:f}=nt(),[p,x]=l.useState(!0),[g,w]=l.useState(!1),M=f(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),v=async()=>{w(!0);try{await N(p),e(!1)}catch(L){const S=L instanceof Error?L.message:`Failed to ${a}`;b.error(S)}finally{w(!1)}},V=()=>{g||e(!1)};return t.jsx(mt,{open:o,onOpenChange:g?void 0:e,children:t.jsxs(ht,{className:"max-w-md",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(ft,{children:f("gitView.stash.title")})]}),t.jsx(bt,{children:f("gitView.stash.description",{operation:a})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(a==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:m})]}),p&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(fa,{checked:p,onChange:x,disabled:g,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!g&&x(!p),children:f("gitView.stash.restoreAfterOperation",{operation:a})})]}),t.jsxs(Es,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:V,disabled:g,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:v,disabled:g,className:"gap-1.5",children:g?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:M})})]})]})})},Ii=({mergeInProgress:o,rebaseInProgress:e,onContinue:a,onAbort:m,onResolveWithAI:N,conflictCount:f=0,isLoading:p=!1})=>{const{t:x}=nt(),[g,w]=l.useState(null),M=o&&o.head,v=e&&(e.headName||e.onto),V=M?"merge":v?"rebase":null;if(!V)return null;const L=async()=>{w("continue");try{await a()}finally{w(null)}},S=async()=>{w("abort");try{await m()}finally{w(null)}},z=g!==null,C=f>0,y=x(V==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let D="";o?D=o.message?x("gitView.operation.mergingMessage",{message:o.message}):x("gitView.operation.mergeInProgressWithHead",{head:o.head}):e&&(D=e.headName?x("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):x("gitView.operation.rebaseInProgress"));const k=C?f===1?x("gitView.operation.inProgressTitleOneConflict",{operation:y,count:f}):x("gitView.operation.inProgressTitleManyConflicts",{operation:y,count:f}):x("gitView.operation.inProgressTitle",{operation:y}),R=x(C?"gitView.operation.resolveConflictsHint":"gitView.operation.readyToContinueHint");return t.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:t.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:k}),D&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:D})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:R}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:S,disabled:z||p,className:"gap-1.5",children:[g==="abort"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"close",className:"size-4"}),x("gitView.operation.abort")]}),C?N&&t.jsx(W,{variant:"default",size:"sm",onClick:N,disabled:z||p,children:x("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:L,disabled:z||p,className:"gap-1.5",children:[g==="continue"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"check",className:"size-4"}),x("gitView.operation.continue")]})]})]})]})})},Pi=o=>{const e=Ct.c(104),{currentBranch:a,localBranches:m,remoteBranches:N,onMerge:f,onRebase:p,disabled:x,isOperating:g,operationLogs:w,onOperationComplete:M,mode:v,defaultTargetBranch:V}=o,L=x===void 0?!1:x,S=g===void 0?!1:g,z=w===void 0?[]:w,C=v===void 0?"dialog":v,{t:y}=nt(),[D,k]=l.useState(!1),[R,P]=l.useState("merge"),[F,r]=l.useState(null),[Y,B]=l.useState(!1),[u,E]=l.useState(""),se=l.useRef(null),U=l.useRef(null),G=L||S,$=a||y("gitView.branch.currentBranchFallback"),Z=z.length>0&&z.every(Fi),H=z.some(Ri);let le;e[0]===Symbol.for("react.memo_cache_sentinel")?(le=()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight)},e[0]=le):le=e[0],l.useEffect(le,[z]);let ae;e[1]!==N?(ae=new Set(N.map(Bi).filter(Boolean)),e[1]=N,e[2]=ae):ae=e[2];const ce=ae;let ie;if(e[3]!==u||e[4]!==a||e[5]!==m||e[6]!==ce){let Q;e[8]!==a||e[9]!==ce?(Q=Oe=>Oe!==a&&!ce.has(Oe),e[8]=a,e[9]=ce,e[10]=Q):Q=e[10];const fe=m.filter(Q);ie=Dt(fe,u,Di),e[3]=u,e[4]=a,e[5]=m,e[6]=ce,e[7]=ie}else ie=e[7];const h=ie;let d;e[11]!==u||e[12]!==N?(d=Dt(N,u,Mi),e[11]=u,e[12]=N,e[13]=d):d=e[13];const I=d;let O;e[14]!==V||e[15]!==m||e[16]!==N?(O=()=>V&&(N.includes(V)||m.includes(V))?V:null,e[14]=V,e[15]=m,e[16]=N,e[17]=O):O=e[17];const J=O;let ne;e[18]!==J||e[19]!==k?(ne=()=>{k(!0),r(J()),P("merge"),E("")},e[18]=J,e[19]=k,e[20]=ne):ne=e[20];const re=ne;let q;e[21]===Symbol.for("react.memo_cache_sentinel")?(q=Q=>{r(Q),B(!1),E("")},e[21]=q):q=e[21];const we=q;let K;e[22]!==f||e[23]!==p||e[24]!==R||e[25]!==F?(K=()=>{F&&(R==="merge"?f(F):p(F))},e[22]=f,e[23]=p,e[24]=R,e[25]=F,e[26]=K):K=e[26];const de=K;let ke;e[27]!==S||e[28]!==k?(ke=()=>{S||(r(null),P("merge"),E(""),k(!1))},e[27]=S,e[28]=k,e[29]=ke):ke=e[29];const ye=ke,me=()=>{S&&!Z||(Z&&M?.(),r(null),P("merge"),E(""),k(!1))};let xe,Ve;e[30]!==Y?(xe=()=>{Y||E("")},Ve=[Y],e[30]=Y,e[31]=xe,e[32]=Ve):(xe=e[31],Ve=e[32]),l.useEffect(xe,Ve);let Re,ue;e[33]!==C||e[34]!==J||e[35]!==F?(Re=()=>{C==="dialog"||F||r(J())},ue=[C,J,F],e[33]=C,e[34]=J,e[35]=F,e[36]=Re,e[37]=ue):(Re=e[36],ue=e[37]),l.useEffect(Re,ue);const je=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:U,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:z.map(Ei)})}),Z?C==="dialog"?t.jsx(Es,{children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y(H?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y(H?"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:y("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>P("merge"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="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(T,{name:"git-merge",className:Se("size-4",R==="merge"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="merge"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>P("rebase"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="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(T,{name:"git-branch",className:Se("size-4",R==="rebase"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="rebase"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?y("gitView.branch.branchToMergeInto",{branch:$}):y("gitView.branch.branchToRebaseOnto")}),t.jsxs(Ts,{open:Y,onOpenChange:B,modal:!1,children:[t.jsx(Ls,{asChild:!0,children:t.jsxs("button",{type:"button",className:Se(Fr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Se("truncate",!F&&"text-muted-foreground"),children:F||y("gitView.branch.selectBranch")}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Os,{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(As,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(zs,{ref:se,placeholder:y("gitView.branch.searchPlaceholder"),value:u,onValueChange:E,onKeyDown:Ti}),t.jsxs(Gs,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(_s,{children:y("gitView.branch.empty")}),h.length>0&&t.jsx(Zt,{heading:y("gitView.branch.localBranches"),children:h.map(Q=>t.jsx(Xt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`local-${Q}`))}),h.length>0&&I.length>0?t.jsx(pa,{}):null,I.length>0&&t.jsx(Zt,{heading:y("gitView.branch.remoteBranches"),children:I.map(Q=>t.jsx(Xt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`remote-${Q}`))})]})]})})]})]}),F?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})," ",y("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:$})]}):t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:$})," ",y("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})]})})}):null,C==="dialog"?t.jsxs(Es,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:ye,children:y("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:!F,className:"gap-1.5",children:R==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-merge",className:"size-4"}),y("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-branch",className:"size-4"}),y("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:ye,disabled:G,children:y("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:G||!F,children:y(R==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(C==="bare")return je;if(C==="inline"){let Q;e[38]!==y?(Q=y("gitView.branch.updateTitle"),e[38]=y,e[39]=Q):Q=e[39];let fe;e[40]!==Q?(fe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:Q}),e[40]=Q,e[41]=fe):fe=e[41];let Oe;e[42]!==y?(Oe=y("gitView.branch.updateDescriptionPrefix"),e[42]=y,e[43]=Oe):Oe=e[43];let et;e[44]!==$?(et=t.jsx("span",{className:"font-mono text-foreground",children:$}),e[44]=$,e[45]=et):et=e[45];let He;e[46]!==Oe||e[47]!==et?(He=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Oe," ",et,"."]}),e[46]=Oe,e[47]=et,e[48]=He):He=e[48];let Ke;e[49]!==fe||e[50]!==He?(Ke=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[fe,He]})}),e[49]=fe,e[50]=He,e[51]=Ke):Ke=e[51];let We;e[52]!==je?(We=t.jsx("div",{className:"pt-3",children:je}),e[52]=je,e[53]=We):We=e[53];let pt;return e[54]!==Ke||e[55]!==We?(pt=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[Ke,We]}),e[54]=Ke,e[55]=We,e[56]=pt):pt=e[56],pt}let be;e[57]!==S?(be=S?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"git-merge",className:"size-4"}),e[57]=S,e[58]=be):be=e[58];let Ce;e[59]!==y?(Ce=y("gitView.branch.mergeRebase"),e[59]=y,e[60]=Ce):Ce=e[60];let Ee;e[61]!==Ce?(Ee=t.jsx("span",{children:Ce}),e[61]=Ce,e[62]=Ee):Ee=e[62];let ee;e[63]!==re||e[64]!==G||e[65]!==be||e[66]!==Ee?(ee=t.jsx(ts,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:re,disabled:G,children:[be,Ee]})}),e[63]=re,e[64]=G,e[65]=be,e[66]=Ee,e[67]=ee):ee=e[67];let he;e[68]!==y?(he=y("gitView.branch.mergeRebaseTooltip"),e[68]=y,e[69]=he):he=e[69];let Be;e[70]!==he?(Be=t.jsx(ss,{sideOffset:8,children:he}),e[70]=he,e[71]=Be):Be=e[71];let ge;e[72]!==ee||e[73]!==Be?(ge=t.jsxs(es,{children:[ee,Be]}),e[72]=ee,e[73]=Be,e[74]=ge):ge=e[74];let Ne;e[75]!==me||e[76]!==k?(Ne=Q=>{Q?k(!0):me()},e[75]=me,e[76]=k,e[77]=Ne):Ne=e[77];let Ie;e[78]!==y?(Ie=y("gitView.branch.updateTitle"),e[78]=y,e[79]=Ie):Ie=e[79];let Te;e[80]!==Ie?(Te=t.jsx(ft,{children:Ie}),e[80]=Ie,e[81]=Te):Te=e[81];let oe;e[82]!==H||e[83]!==S||e[84]!==R||e[85]!==Z||e[86]!==y||e[87]!==$?(oe=S?y(Z?H?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":R==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[y("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:$}),"."]}),e[82]=H,e[83]=S,e[84]=R,e[85]=Z,e[86]=y,e[87]=$,e[88]=oe):oe=e[88];let Pe;e[89]!==oe?(Pe=t.jsx(bt,{children:oe}),e[89]=oe,e[90]=Pe):Pe=e[90];let Fe;e[91]!==Te||e[92]!==Pe?(Fe=t.jsxs(gt,{children:[Te,Pe]}),e[91]=Te,e[92]=Pe,e[93]=Fe):Fe=e[93];let De;e[94]!==je||e[95]!==Fe?(De=t.jsxs(ht,{className:"max-w-md",children:[Fe,je]}),e[94]=je,e[95]=Fe,e[96]=De):De=e[96];let Ue;e[97]!==D||e[98]!==Ne||e[99]!==De?(Ue=t.jsx(mt,{open:D,onOpenChange:Ne,children:De}),e[97]=D,e[98]=Ne,e[99]=De,e[100]=Ue):Ue=e[100];let Le;return e[101]!==ge||e[102]!==Ue?(Le=t.jsxs(t.Fragment,{children:[ge,Ue]}),e[101]=ge,e[102]=Ue,e[103]=Le):Le=e[103],Le};function Fi(o){return o.status==="done"||o.status==="error"}function Ri(o){return o.status==="error"}function Bi(o){return o.slice(o.indexOf("/")+1)}function Di(o){return[o]}function Mi(o){return[o]}function Ei(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(T,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),o.status==="done"&&t.jsx(T,{name:"check",className:"size-3.5 text-success"}),o.status==="error"&&t.jsx(T,{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:Se("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 Ti(o){return o.stopPropagation()}const Li=({runMutation:o,onMutationComplete:e,onMutationError:a,onPathsComplete:m,scheduleFlush:N})=>{const f=[];let p=!1;return{enqueue:g=>{const w=f[f.length-1];if(w?.directory===g.directory&&w.direction===g.direction){g.paths.forEach(M=>w.paths.add(M));return}f.push(g)},flush:()=>{if(p)return;const g=f.shift();if(!g)return;p=!0;const w={directory:g.directory,direction:g.direction,paths:Array.from(g.paths),rollback:g.rollback};(async()=>{try{await o(w),e(w)}catch(M){a(w,M)}finally{m(w.paths),p=!1,f.length>0&&N()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>p}},Oi=15e3,Ai=40,zi=20,Vr={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:"},Ir=(o,e)=>{const a=o.toLowerCase(),m=/^([a-z]+)(?:\(.*\))?!?:/,N=a.match(m);if(N){const x=N[1],g=Vr[x];if(g)return e.find(w=>w.code===g)||null}const f=a.split(" ")[0],p=Vr[f];return p&&e.find(x=>x.code===p)||null},Gi=20,yt=new Map,_i=(o,e)=>{if(yt.delete(o),yt.set(o,e),yt.size>Gi){const a=yt.keys().next().value;a!==void 0&&yt.delete(a)}},Xe=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Pr=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},$i=o=>{const e=o.working_dir?.trim(),a=o.index?.trim();return!!(e||a==="?")},oc=({isActive:o})=>{const{t:e}=nt(),{git:a}=xa(),m=wa(),[N,f]=l.useState(null),[p,x]=l.useState(null),g=rt(s=>s.currentSessionId),w=rt(s=>s.newSessionDraft),M=rt(s=>s.setDraftBootstrapPendingDirectory),v=rt(s=>s.worktreeMetadata),V=rt(s=>s.availableWorktrees),L=Xe(m),S=l.useMemo(()=>{if(!L)return;const s=V.find(n=>Xe(n.path)===L);if(s)return s;for(const n of v.values())if(Xe(n.path)===L)return n},[V,L,v]),z=l.useMemo(()=>{if(g)return v.get(g)??S;if(w?.open)return S},[g,S,w?.open,v]),{profiles:C,globalIdentity:y,defaultGitIdentityId:D,loadProfiles:k,loadGlobalIdentity:R,loadDefaultGitIdentityId:P}=Ga(pr(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),{rootIsGitRepo:F,gitDirectory:r,nestedRepos:Y}=ya(m??null,{enabled:o}),B=ba(r??null),u=va(r??null),E=ja(s=>g?s.getAttachment(g):void 0),se=E?Ca(E):[],U=E&&!E.degraded&&!E.legacy?E.worktreeRoot??void 0:void 0,G=Aa(m,z,u?.current??void 0),$=Na(r??null),Z=Sa(r??null),H=ka(r??null),le=Va(r??null),ae=Ia(r??null),{setActiveDirectory:ce,ensureAll:ie,fetchStatus:h,fetchBranches:d,fetchLog:I,setLogMaxCount:O,fetchIdentity:J,prefetchDiffs:ne,clearDiffCache:re,moveStatusPathsOptimistically:q,restoreStatus:we,bumpIndexRevision:K,ensureNestedRepos:de,selectNestedRepo:ke}=Pa(pr(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}))),ye=Rt(s=>s.isMobile),me=Rt(s=>s.openContextDiff),xe=Rt(s=>s.openContextSurface),Ve=u?.current??null,Re=Fa(s=>!r||!Ve?null:Ra(s.entries,r,Ve)),ue=Rt(s=>s.navigateToDiff),$e=l.useRef(null),Ae=l.useRef(null),je=l.useRef(null),be=l.useRef(!0);l.useEffect(()=>()=>{be.current=!1},[]);const Ce=l.useCallback(()=>{$e.current!==null&&(window.clearTimeout($e.current),$e.current=null)},[]),Ee=l.useCallback(s=>{Ce(),$e.current=window.setTimeout(()=>{$e.current=null,Xe(s)===Xe(r)&&h(s,a,{silent:!0})},Oi)},[Ce,r,h,a]);l.useEffect(()=>Ce,[Ce]);const ee=l.useCallback(()=>{Ae.current!==null&&(window.clearTimeout(Ae.current),Ae.current=null)},[]),he=l.useCallback(()=>{Ae.current===null&&(Ae.current=window.setTimeout(()=>{Ae.current=null,je.current?.()},0))},[]),Be=l.useCallback(async(s,n,i)=>{if(n==="stage"){if(a.stageGitFiles){await a.stageGitFiles(s,i);return}await Promise.all(i.map(c=>a.stageGitFile(s,c)));return}if(a.unstageGitFiles){await a.unstageGitFiles(s,i);return}await Promise.all(i.map(c=>a.unstageGitFile(s,c)))},[a]),ge=l.useMemo(()=>Li({runMutation:({directory:s,direction:n,paths:i})=>Be(s,n,i),onMutationComplete:({directory:s})=>{K(s),Ee(s)},onMutationError:({directory:s,direction:n,rollback:i},c)=>{i?.(),K(s),Ee(s);const j=e(n==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");b.error(c instanceof Error?c.message:j)},onPathsComplete:s=>{Js(n=>{const i=new Set(n);return s.forEach(c=>i.delete(c)),i})},scheduleFlush:he}),[K,Be,he,Ee,e]);l.useEffect(()=>(je.current=ge.flush,()=>{je.current=null}),[ge]),l.useEffect(()=>()=>ge.clear(),[ge]),l.useEffect(()=>ee,[ee]),l.useEffect(()=>{if(!o)return;if(!m){f(null);return}const s=Xe(m)??m;f({directory:s,status:null});let n=!1,i=null;const c=async()=>{try{const j=await Oa(m);if(n)return;f({directory:s,status:j.status}),j.status==="pending"&&(i=window.setTimeout(()=>{c()},500))}catch{n||f({directory:s,status:null})}};return c(),()=>{n=!0,i!==null&&window.clearTimeout(i)}},[o,m]);const Ne=Xe(w?.bootstrapPendingDirectory??null),Ie=!!(m&&Ne&&Ne===Xe(m)),Te=Ba(m??null),oe=Xe(m),Pe=N?.directory===oe?N.status:null,Fe=!!(m&&(Te||Pe==="pending"||Ie&&w?.pendingWorktreeRequestId)),De=!!(oe&&p?.directory===oe);l.useEffect(()=>{if(!oe)return;if(Pe==="failed"){M(null),x(n=>n?.directory===oe?null:n);return}if(Fe){x(n=>n?.directory===oe&&n.status==="refreshing"?n:{directory:oe,status:"refreshing"});return}if(p?.directory!==oe||p.status!=="refreshing"||!r||!a)return;let s=!1;return h(r,a,{force:!0,silent:!0,throwOnError:!0}).then(()=>{s||x(n=>n?.directory===oe?null:n)}).catch(()=>{s||x(n=>n?.directory===oe?{...n,status:"failed"}:n)}),()=>{s=!0}},[h,a,r,Fe,oe,Pe,p,M]);const Ue=Fe||De,Le=De&&p?.status==="failed",Q=l.useMemo(()=>r?yt.get(r)??null:null,[r]),fe=Da(s=>s.settingsGitmojiEnabled),[Oe,et]=l.useState(null),{gitmojis:He}=Xa(fe);l.useEffect(()=>{const s=U||G?.projectDirectory;if(!s){et(null);return}let n=!1;return Ma(s).then(i=>{if(n)return;const c=i.trim();et(c&&c!=="HEAD"?c:null)}).catch(()=>{n||et(null)}),()=>{n=!0}},[U,G?.projectDirectory]);const[Ke,We]=l.useState(Q?.commitMessage??""),[pt,Er]=l.useState([]),[Tr,rs]=l.useState(!1),$s=l.useRef(null),[Hs,Mt]=l.useState(null),[Lr,ns]=l.useState(!1),[Ws,Us]=l.useState(null),[Ye,Or]=l.useState(25),[Ar,Ks]=l.useState(!1),{triggerFireworks:zr}=za(),qs=l.useRef(new Map),Et=l.useRef(0),as=l.useCallback(()=>{Et.current+=1,be.current&&Ks(!0)},[]),is=l.useCallback(()=>{Et.current=Math.max(0,Et.current-1),be.current&&Et.current===0&&Ks(!1)},[]),[os,Tt]=l.useState(new Set),[Gr,Js]=l.useState(new Set),[ls,Ys]=l.useState(!1),[_r,$r]=l.useState(0),[Hr,Qs]=l.useState(!1),[cs,ds]=l.useState(Q?.generatedHighlights??[]),Wr=Gr.size>0||ge.size()>0||ge.isRunning(),Zs=l.useCallback(()=>{const s=$s.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),us=U||G?.projectDirectory||null,ms=u?.current||null,Ur=l.useMemo(()=>{const s=u?.tracking;return s?s.startsWith("origin/"):!0},[u?.tracking]),Xs=l.useMemo(()=>{const s=G?.createdFromBranch,n=typeof s=="string"?s.trim():"",i=typeof u?.current=="string"?u.current.trim():"",c=typeof Oe=="string"?Oe.trim():"";return n?n===i&&n.startsWith("opencode/")&&c.length>0&&c!==n?c:n:c||i||"HEAD"},[G?.createdFromBranch,u,Oe]),Lt=l.useCallback(()=>{ds([])},[]),[hs,Kr]=l.useState(new Set),[Ot,qr]=l.useState(new Map),[At,gs]=l.useState(new Set),fs=l.useRef(Ot),St=l.useRef(At),[Jr,vt]=l.useState(null),[xt,ps]=l.useState(null),[er,tr]=l.useState(""),[Me,zt]=l.useState(null),[Yr,sr]=l.useState(!1),[Qr,rr]=l.useState(!1),[xs,ws]=l.useState([]),[Zr,nr]=l.useState(null),[ar,ys]=l.useState(null),[Xr,Gt]=l.useState([]),[en,Qe]=l.useState(!1),[tn,tt]=l.useState([]),[_t,st]=l.useState("merge"),[sn,bs]=l.useState(null),[vs,ir]=l.useState(!1),[js,rn]=l.useState(100),[nn,an]=l.useState(0),Ze=l.useMemo(()=>g?`openchamber.conflict:${g}`:null,[g]),at=l.useCallback((s,n,i)=>{if(!Ze||typeof window>"u")return;const c={directory:s,conflictFiles:n,operation:i};window.localStorage.setItem(Ze,JSON.stringify(c))},[Ze]),qe=l.useCallback(()=>{!Ze||typeof window>"u"||window.localStorage.removeItem(Ze)},[Ze]);l.useEffect(()=>{if(!Ze||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Ze);if(s)try{const n=JSON.parse(s);if(n.directory!==r){window.localStorage.removeItem(Ze);return}tt(n.conflictFiles??[]),st(n.operation??"merge"),Qe(!0)}catch{window.localStorage.removeItem(Ze)}},[Ze,r]);const[on,Cs]=l.useState(!1),[$t,kt]=l.useState(null),[Ns,or]=l.useState("merge"),[Ss,lr]=l.useState(""),ln=l.useCallback(s=>{Ea(s).then(n=>{if(n.ok){b.success(e("gitView.toast.commitHashCopied"));return}b.error(e("gitView.toast.copyFailed"))})},[e]),cn=l.useCallback(s=>{Kr(n=>{const i=new Set(n);return i.has(s)?i.delete(s):i.add(s),i})},[]);l.useEffect(()=>{fs.current=Ot},[Ot]),l.useEffect(()=>{St.current=At},[At]),l.useEffect(()=>{if(!r||!a)return;const s=Array.from(hs).filter(i=>!fs.current.has(i)&&!St.current.has(i));if(s.length===0)return;let n=!1;return gs(i=>{const c=new Set(i);for(const j of s)c.add(j);return St.current=c,c}),Promise.all(s.map(i=>a.getCommitFiles(r,i).then(c=>({hash:i,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:i,files:[]})))).then(i=>{n||(qr(c=>{const j=new Map(c);for(const{hash:A,files:X}of i)j.set(A,X);return fs.current=j,j}),gs(c=>{const j=new Set(c);for(const{hash:A}of i)j.delete(A);return St.current=j,j}))}),()=>{n=!0,gs(i=>{let c=!1;const j=new Set(i);for(const A of s)j.delete(A)&&(c=!0);return c?(St.current=j,j):i})}},[hs,r,a]),l.useEffect(()=>{if(!r)return;const s=yt.get(r)??null;We(s?.commitMessage??""),ds(s?.generatedHighlights??[])},[r]),l.useEffect(()=>{r&&_i(r,{directory:r,commitMessage:Ke,generatedHighlights:cs})},[Ke,r,cs]),l.useEffect(()=>{o&&(k(),R(),P())},[o,k,R,P]),l.useEffect(()=>{if(!o)return;if(!r||!a?.getRemoteUrl||B!==!0){ps(null);return}let s=!1;return a.getRemoteUrl(r).then(n=>{s||ps(n)}).catch(()=>{s||ps(null)}),()=>{s=!0}},[o,r,a,B]);const Ht=l.useCallback(async()=>{if(!r||!a?.getRemotes||B!==!0){ws([]);return}try{const s=await a.getRemotes(r);be.current&&ws(s)}catch{be.current&&ws([])}},[r,a,B]);l.useEffect(()=>{o&&Ht()},[o,Ht]),l.useEffect(()=>{o&&m&&r&&(ce(m),ie(r,a))},[o,m,r,ce,ie,a]),l.useEffect(()=>{if(o&&r)return Ta.onGitRefreshHint(s=>{Xe(s.directory)===Xe(r)&&(s.paths?.length&&re(r,s.paths),h(r,a,{silent:!0}))})},[o,re,r,h,a]);const te=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([h(r,a),d(r,a)])}catch(n){if(s){const i=n instanceof Error?n.message:e("gitView.toast.refreshRepositoryFailed");b.error(i)}}},[r,a,h,d,e]),pe=l.useCallback(async()=>{r&&await I(r,a,Ye)},[r,a,I,Ye]),ks=l.useCallback(async()=>{r&&await J(r,a)},[r,a,J]);l.useEffect(()=>{if(!o||!r||!a?.hasLocalIdentity||B!==!0)return;const s=typeof D=="string"?D.trim():"";if(!s||s==="global"||qs.current.get(r)===s)return;let i=!1;return(async()=>{try{const j=await a.hasLocalIdentity?.(r);if(i||j===!0)return;as(),await a.setGitIdentity(r,s),qs.current.set(r,s),await ks()}catch(j){console.warn("Failed to auto-apply default git identity:",j)}finally{i||is()}})(),()=>{i=!0}},[o,as,r,D,is,a,B,ks]);const it=l.useMemo(()=>u?[...u.files??[]].sort((n,i)=>n.path.localeCompare(i.path)):[],[u]),Je=l.useMemo(()=>it.filter(Pr),[it]),Vs=l.useMemo(()=>it.filter($i),[it]);l.useEffect(()=>{if(!o||!r||it.length===0)return;const s=[],n=new Set,i=j=>{!j||n.has(j)||(n.add(j),s.push(j))};if(Je.forEach(j=>i(j.path)),pt.forEach(i),it.slice(0,zi).forEach(j=>i(j.path)),s.length===0)return;const c=window.setTimeout(()=>{ne(r,a,s,{maxFiles:Ai})},120);return()=>{window.clearTimeout(c)}},[o,it,r,a,ne,Je,pt]);const cr=s=>s?.pushed[0]?.remote||u?.tracking?.split("/")[0]||ze.find(n=>n.name==="origin")?.name||ze[0]?.name||"origin",dr=async(s,n)=>{if(r){Mt(s);try{const i=c=>{const j=`${c.name}/`,A=u?.tracking?.startsWith(j)?u.tracking.slice(j.length):void 0;return{remote:c.name,branch:A,rebase:!0}};if(s==="fetch"){if(!n)throw new Error("No remote available for fetch");await a.gitFetch(r,{remote:n.name}),b.success(e("gitView.toast.fetchedFromRemote",{name:n.name}))}else if(s==="pull"){if(!n)throw new Error("No remote available for pull");const c=await a.gitPull(r,i(n));b.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:n.name}))}else if(s==="push"){const c=await a.gitPush(r);b.success(e("gitView.toast.pushedToUpstream",{name:cr(c)}))}else if(s==="sync"){if(!n)throw new Error("No remote available for sync");let c=0,j=!1;await a.gitFetch(r,{remote:n.name});const A=await a.getGitStatus(r);if((A.behind??0)>0){if((A.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync"));return}c=(await a.gitPull(r,i(n))).files.length}((await a.getGitStatus(r)).ahead??0)>0&&(await a.gitPush(r),j=!0),c>0&&j?b.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:n.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:n.name})):c>0?b.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:n.name})):j?b.success(e("gitView.toast.pushedToUpstream",{name:n.name})):b.success(e("gitView.toast.alreadyUpToDate"))}await te(!1),await pe()}catch(i){const c=i instanceof Error?i.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});b.error(c)}finally{Mt(null)}}},dn=l.useCallback(async s=>{if(!r)return;const n=s.name.trim();if(!n){b.error(e("gitView.toast.remoteNameRequired"));return}if(n==="origin"){b.error(e("gitView.toast.cannotRemoveOriginRemote"));return}nr(n);try{await a.removeRemote(r,{remote:n}),b.success(e("gitView.toast.removedRemote",{name:n})),await Promise.all([te(!1),Ht()])}catch(i){const c=i instanceof Error?i.message:`Failed to remove ${n}`;b.error(c)}finally{nr(null)}},[r,a,Ht,te,e]),ur=async(s={})=>{if(!r)return;if(!Ke.trim()){b.error(e("gitView.toast.enterCommitMessage"));return}const n=Je.map(c=>c.path).sort();if(n.length===0){b.error(e("gitView.toast.stageFileToCommit"));return}const i=s.pushAfter?"commitAndPush":"commit";Us(i);try{if(await a.createGitCommit(r,Ke.trim(),{files:n,stageFiles:[]}),K(r),b.success(e("gitView.toast.commitCreated")),We(""),Lt(),await te(),s.pushAfter){const c=u?.tracking?.split("/")[0],j=ze.find(Gn=>Gn.name===c)??ze[0];if(!j)throw new Error(e("mobile.changes.noRemote"));Mt("sync");const A=`${j.name}/`,X=u?.tracking?.startsWith(A)?u.tracking.slice(A.length):void 0;await a.gitFetch(r,{remote:j.name});const _=await a.getGitStatus(r);if((_.behind??0)>0){if((_.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync")),await te(!1);return}await a.gitPull(r,{remote:j.name,branch:X,rebase:!0})}const _e=await a.getGitStatus(r);let jt;(_e.ahead??0)>0&&(jt=await a.gitPush(r)),b.success(e("gitView.toast.pushedToUpstream",{name:cr(jt)})),zr(),await te(!1)}else await te(!1);await pe(),$r(c=>c+1)}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");b.error(j)}finally{Us(null),s.pushAfter&&Mt(null)}},un=l.useCallback(async()=>{if(!r)return;const s=Je.map(n=>n.path).sort();if(s.length===0){b.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),Qs(!0);try{const{message:n}=await fr(r,s),i=n.subject?.trim()??"",c=Array.isArray(n.highlights)?n.highlights:[];if(i){let j=i;if(fe&&He.length>0){const A=Ir(i,He);if(A){const{code:X,emoji:_}=A;!i.startsWith(X)&&!i.startsWith(_)&&(j=`${X} ${i}`)}}We(j)}ds(c),Zs()}catch(n){console.error("[git-generation][browser] GitView generate handler failed",{message:n instanceof Error?n.message:String(n),error:n});const i=n instanceof Error?n.message:e("gitView.toast.generateCommitMessageFailed");b.error(i)}finally{Qs(!1)}},[r,Je,fe,He,Zs,e]),Is=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",mn=async(s,n)=>{if(!r||!u)return;const i=Bs(E);if(i.length>0){b.error(e("gitView.toast.cannotCreateBranch",{reason:Is(i[0])}));return}const c=u.current??null,j=n?.name??"origin";try{await a.createBranch(r,s,c??"HEAD"),b.success(e("gitView.toast.createdBranch",{name:s})),await a.checkoutBranch(r,s);let A=!1;try{await a.gitPush(r,{remote:j,branch:s,options:["--set-upstream"]}),A=!0}catch(X){const _=X instanceof Error?X.message:`Unable to push new branch to ${j}.`;b.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",_]})})}await te(),await pe(),A&&b.success(e("gitView.toast.upstreamSet",{branch:s,remote:j}))}catch(A){const X=A instanceof Error?A.message:e("gitView.toast.createBranchFailed");throw b.error(X),A}},hn=async(s,n)=>{if(!r)return;const i=Bs(E);if(i.length>0){b.error(e("gitView.toast.cannotRenameBranch",{reason:Is(i[0])}));return}try{await a.renameBranch(r,s,n),b.success(e("gitView.toast.renamedBranch",{oldName:s,newName:n})),await te(),await pe()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:n});b.error(j)}},gn=async s=>{if(!r)return;const n=Bs(E);if(n.length>0){b.error(e("gitView.toast.cannotCheckout",{reason:Is(n[0])}));return}const i=s.replace(/^remotes\//,"");if(u?.current!==i){if((u?.files?.length??0)>0){kt(i);return}await Ps(i)}},Ps=async s=>{if(!r)return;const n=s;try{const i=await a.checkoutBranch(r,n);b.success(e("gitView.toast.checkedOut",{name:i?.branch||n})),await te(),await pe()}catch(i){const c=i instanceof Error?i.message:e("gitView.toast.checkoutFailed",{name:n});b.error(c)}},fn=async s=>{if(r){as();try{await a.setGitIdentity(r,s.id),b.success(e("gitView.toast.appliedIdentity",{name:s.name})),await ks()}catch(n){const i=n instanceof Error?n.message:e("gitView.toast.applyIdentityFailed");b.error(i)}finally{is()}}},Vt=l.useMemo(()=>$?.all?$.all.filter(s=>!s.startsWith("remotes/")).sort():[],[$]),ot=l.useMemo(()=>$?.all?$.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[$]),ze=l.useMemo(()=>{if(xs.length>0)return xs;const s=new Set,n=u?.tracking?.trim();n&&n.includes("/")&&s.add(n.split("/")[0]);for(const i of ot){const c=i.indexOf("/");c>0&&s.add(i.slice(0,c))}return s.size===0&&xt&&s.add("origin"),Array.from(s).map(i=>({name:i,fetchUrl:xt??"",pushUrl:xt??""}))},[xs,ot,xt,u?.tracking]),lt=u?.current??null,mr=l.useMemo(()=>{const s=u?.tracking?.trim().split("/")[0];return(s&&$?.defaultBranches?.[s])??$?.defaultBranches?.origin},[$,u?.tracking]),wt=l.useMemo(()=>_a({remoteNames:new Set(ze.map(s=>s.name)),localBranches:Vt,worktreeCreatedFromBranch:G?.createdFromBranch,rootBranchHint:Oe,defaultBranch:mr,headBranch:lt}),[lt,mr,ze,Vt,Oe,G?.createdFromBranch]),pn=l.useMemo(()=>ze.map(i=>i.name).map(i=>`${i}/${wt}`).find(i=>ot.includes(i))??wt,[wt,ze,ot]),xn=l.useMemo(()=>{const s=new Map;y&&s.set(y.id,y);let n=null;if(xt)try{let i=xt.trim();i.startsWith("git@")&&(i=`https://${i.slice(4).replace(":","/")}`),i.endsWith(".git")&&(i=i.slice(0,-4));const c=new URL(i);n=c.hostname+c.pathname}catch{}for(const i of C){if(i.authType!=="token"){s.set(i.id,i);continue}const c=i.host;if(!c){s.set(i.id,i);continue}if(!c.includes("/")){s.set(i.id,i);continue}n&&n===c&&s.set(i.id,i)}return Array.from(s.values())},[C,y,xt]),wn=l.useMemo(()=>{if(H?.userName&&H?.userEmail){const s=C.find(n=>n.userName===H.userName&&n.userEmail===H.userEmail);return s||(y&&y.userName===H.userName&&y.userEmail===H.userEmail?y:{id:"local-config",name:H.userName,userName:H.userName,userEmail:H.userEmail,sshKey:H.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return y??null},[H,C,y]),yn=Je.length,bn=le||Hs!==null||Ws!==null,vn=!!(G&&us&&ms&&Ur),hr=!!lt,ct=vn&&us&&ms&&G?{repoRoot:us,sourceBranch:ms,worktreeMetadata:G}:null;l.useEffect(()=>{if(!r||!a||!Z?.all?.length||!lt||!wt||lt===wt){vt(null);return}let s=!1;return(async()=>{try{const i=await a.getGitLog(r,{from:wt,to:"HEAD",maxCount:Ye});if(s)return;const c=new Set((i?.all??[]).map(A=>A.hash).filter(A=>typeof A=="string"&&A.length>0));if(c.size===0){vt(null);return}const j=Z.all.findIndex(A=>!c.has(A.hash));if(j===0){vt(null);return}if(j===-1){vt({insertBeforeIndex:Z.all.length,branchName:lt,direction:"up"});return}vt({insertBeforeIndex:j,branchName:lt,direction:"up"})}catch{s||vt(null)}})(),()=>{s=!0}},[wt,lt,r,a,Z,Ye]),l.useEffect(()=>{bs(null)},[r]),l.useEffect(()=>{if(Me!=="graph"||!r){Me!=="graph"&&bs(null);return}let s=!1;return ir(!0),a.getGitLog(r,{maxCount:js,all:!0}).then(n=>{s||bs(n)}).catch(n=>{console.error("Failed to fetch graph log:",n)}).finally(()=>{s||ir(!1)}),()=>{s=!0}},[Me,r,js,nn,a]);const It=l.useCallback((s,n)=>{if(!r||s.length===0)return;const i=Array.from(new Set(s));Js(j=>{const A=new Set(j);return i.forEach(X=>A.add(X)),A});const c=q(r,i,n);ge.enqueue({directory:r,direction:n,paths:new Set(i),rollback:()=>we(r,c)}),he()},[r,ge,q,we,he]),Fs=l.useCallback(async s=>{if(r){Tt(n=>{const i=new Set(n);return i.add(s),i});try{await a.revertGitFile(r,s,{scope:"working"}),b.success(e("gitView.toast.revertedFile",{path:s})),await te(!1)}catch(n){const i=n instanceof Error?n.message:e("gitView.toast.revertFailed");b.error(i)}finally{Tt(n=>{const i=new Set(n);return i.delete(s),i})}}},[r,te,a,e]),Pt=l.useCallback(async(s,n,i="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(ls||c.some(_=>os.has(_)))return;const j=new Set(Je.map(_=>_.path)),A=i==="all"&&c.some(_=>j.has(_));n&&Ys(!0),Tt(_=>{const _e=new Set(_);return c.forEach(jt=>_e.add(jt)),_e});const X=[];try{if(await Promise.all(c.map(async _=>{try{await a.revertGitFile(r,_,{scope:i})}catch(_e){X.push({path:_,message:_e instanceof Error?_e.message:e("gitView.toast.revertFailed")})}})),A&&X.length<c.length&&K(r),await te(!1),X.length===0)b.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(X.length===c.length)b.error(X[0]?.message||e("gitView.toast.revertFailed"));else{const _=c.length-X.length;b.warning(_===1?e("gitView.toast.revertedSomeSingle",{success:_,failed:X.length}):e("gitView.toast.revertedSomePlural",{success:_,failed:X.length}))}}finally{Tt(_=>{const _e=new Set(_);return c.forEach(jt=>_e.delete(jt)),_e}),n&&Ys(!1)}},[K,r,a,ls,te,os,Je,e]),jn=l.useCallback(async s=>{await Pt(s,!0)},[Pt]),Cn=l.useCallback(async s=>{await Pt(s,!1,"working")},[Pt]),Rs=l.useCallback((s,n)=>{if(m&&!ye){me(m,s,n);return}ue(s,n)},[m,ye,ue,me]),Nn=l.useCallback(()=>ns(!0),[]),Sn=l.useMemo(()=>{const s=[];return Je.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Je,actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:n=>e("gitView.changes.unstageFileAria",{path:n}),onActionFile:n=>{It([n],"unstage")},onActionAll:n=>{It(n,"unstage")},onViewDiff:n=>Rs(n,!0),onRevertFile:Fs,showRevertActions:!1,accent:!0}),Vs.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:Vs,actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:n=>e("gitView.changes.stageFileAria",{path:n}),onActionFile:n=>{It([n],"stage")},onActionAll:n=>{It(n,"stage")},onViewDiff:n=>Rs(n,!1),onRevertFile:Fs}),s},[Fs,Rs,It,Je,e,Vs]),kn=l.useCallback(s=>{if(s.length===0)return;const n=s.map(i=>i.trim()).filter(Boolean);if(n.length===0){Lt();return}We(i=>{const c=i.trim(),j=c.length>0?`
4
-
5
- `:"";return`${c}${j}${n.join(`
6
- `)}`.trim()}),Lt()},[Lt]),Vn=l.useCallback((s,n)=>{const i=n||s;We(c=>{const j=c.trimStart();return j.startsWith(s)||n&&j.startsWith(n)?c:`${i.endsWith(" ")?i:`${i} `}${c}`.trimStart()}),tr(""),rs(!1)},[]),Wt=l.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")},[]),dt=l.useCallback((s,n)=>{Gt(i=>[...i,{message:s,status:n,timestamp:Date.now()}])},[]),Ge=l.useCallback((s,n)=>{Gt(i=>{if(i.length===0)return i;const c=[...i];return c[c.length-1]={...c[c.length-1],status:s,...n?{message:n}:{}},c})},[]),Ut=l.useCallback(()=>{Gt([])},[]),In=l.useCallback(()=>{Gt([]),ys(null)},[]),Kt=l.useCallback(s=>{const n=s.trim(),i=new Set(ze.map(j=>j.name)),c=n.indexOf("/");if(c>0){const j=n.slice(0,c),A=n.slice(c+1);if(i.has(j)&&A)return{branch:n,remote:j,remoteBranch:A}}for(const j of ze){const A=`${j.name}/${n}`;if(ot.includes(A))return{branch:A,remote:j.name,remoteBranch:n}}return{branch:n,remote:null,remoteBranch:null}},[ze,ot]),Pn=l.useCallback(async s=>{if(!r)return;ys("merge"),Ut();const n=u?.current,i=Kt(s);try{i.remote&&i.remoteBranch&&(dt(`Fetching ${i.remote}/${i.remoteBranch}...`,"running"),await a.gitFetch(r,{remote:i.remote,branch:i.remoteBranch}),Ge("done",`Fetched ${i.remote}/${i.remoteBranch}`)),dt(`Merging ${i.branch} into ${n}...`,"running");const c=await a.merge(r,{branch:i.branch});c.conflict?(Ge("error","Merge conflicts detected"),tt(c.conflictFiles??[]),st("merge"),Qe(!0),at(r,c.conflictFiles??[],"merge")):(Ge("done",`Merged ${i.branch} into ${n}`),qe(),dt("Refreshing repository status...","running"),await te(),await pe(),Ge("done","Repository status updated"))}catch(c){if(Wt(c))Ge("error","Uncommitted changes detected"),or("merge"),lr(i.branch),Cs(!0);else{const j=c instanceof Error?c.message:`Failed to merge ${i.branch}`;Ge("error",j)}}},[r,a,u,Kt,te,pe,Wt,at,qe,dt,Ge,Ut]),Fn=l.useCallback(async s=>{if(!r)return;ys("rebase"),Ut();const n=u?.current,i=Kt(s);try{i.remote&&i.remoteBranch&&(dt(`Fetching ${i.remote}/${i.remoteBranch}...`,"running"),await a.gitFetch(r,{remote:i.remote,branch:i.remoteBranch}),Ge("done",`Fetched ${i.remote}/${i.remoteBranch}`)),dt(`Rebasing ${n} onto ${i.branch}...`,"running");const c=await a.rebase(r,{onto:i.branch});c.conflict?(Ge("error","Rebase conflicts detected"),tt(c.conflictFiles??[]),st("rebase"),Qe(!0),at(r,c.conflictFiles??[],"rebase")):(Ge("done",`Rebased ${n} onto ${i.branch}`),qe(),dt("Refreshing repository status...","running"),await te(),await pe(),Ge("done","Repository status updated"))}catch(c){if(Wt(c))Ge("error","Uncommitted changes detected"),or("rebase"),lr(i.branch),Cs(!0);else{const j=c instanceof Error?c.message:`Failed to rebase onto ${i.branch}`;Ge("error",j)}}},[r,a,u,Kt,te,pe,Wt,at,qe,dt,Ge,Ut]),Rn=l.useCallback(async()=>{if(r)try{_t==="merge"?(await a.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),qe(),await te(),await pe()}catch(s){const n=s instanceof Error?s.message:`Failed to abort ${_t}`;b.error(n)}},[r,a,_t,te,pe,qe,e]),Bn=l.useMemo(()=>u?.files?u.files.filter(s=>s.index==="U"||s.working_dir==="U"||s.index==="A"&&s.working_dir==="A"||s.index==="D"&&s.working_dir==="D").length:0,[u?.files]),Dn=l.useCallback(async()=>{if(r)try{const s=!!u?.mergeInProgress?.head,n=!!(u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto);if(s){const i=await a.continueMerge(r);i.conflict?(tt(i.conflictFiles??[]),st("merge"),Qe(!0),at(r,i.conflictFiles??[],"merge"),b.error(e("gitView.toast.mergeConflictsDetected"))):(qe(),b.success(e("gitView.toast.mergeCompleted")),await te(),await pe())}else if(n){const i=await a.continueRebase(r);i.conflict?(tt(i.conflictFiles??[]),st("rebase"),Qe(!0),at(r,i.conflictFiles??[],"rebase"),b.error(e("gitView.toast.rebaseConflictsDetected"))):(qe(),b.success(e("gitView.toast.rebaseStepCompleted")),await te(),await pe())}}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");b.error(n)}},[r,a,u,te,pe,at,qe,e]),Mn=l.useCallback(async()=>{if(r)try{!!u?.mergeInProgress?.head?(await a.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),qe(),await te(),await pe()}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");b.error(n)}},[r,a,u,te,pe,qe,e]),En=l.useCallback(()=>{if(!r)return;const n=!!u?.mergeInProgress?.head?"merge":"rebase",i=u?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];i.length>0&&tt(i),st(n),Qe(!0)},[r,u]),Tn=l.useCallback(async s=>{if(!r)return;const n=u?.current,i=Ns,c=Ss,j=(u?.files??[]).some(Pr);try{await a.stash(r,{message:`Auto-stash before ${i} with ${c}`,includeUntracked:!0}),j&&K(r)}catch(_){const _e=_ instanceof Error?_.message:"Failed to stash changes";b.error(_e);return}let A=!1,X=!1;try{if(i==="merge"){const _=await a.merge(r,{branch:c});_.conflict?(X=!0,tt(_.conflictFiles??[]),st("merge"),Qe(!0)):(A=!0,b.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:n||""})))}else{const _=await a.rebase(r,{onto:c});_.conflict?(X=!0,tt(_.conflictFiles??[]),st("rebase"),Qe(!0)):(A=!0,b.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:n||"",branch:c})))}if(s&&A)try{await a.stashPop(r),K(r),b.success(e("gitView.toast.stashedRestored"))}catch(_){const _e=_ instanceof Error?_.message:e("gitView.toast.restoreStashFailed");b.error(_e)}else s&&X&&b.info(e("gitView.toast.restoreStashManually"));await te(),await pe()}catch(_){if(s)try{await a.stashPop(r),K(r)}catch{}throw _}},[K,r,a,u,Ns,Ss,te,pe,e]),Ln=l.useCallback(s=>{Or(s),r&&(O(r,s),I(r,a,s))},[r,I,a,O]),On=l.useCallback(s=>{rn(s)},[]),An=l.useCallback(()=>{zt(null),r&&(h(r,a),d(r,a),I(r,a,Ye))},[r,h,d,I,Ye,a]),zn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){b.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(h(r,a),d(r,a),I(r,a,Ye));return}tt(s.conflictFiles??[]),st(s.operation),Qe(!0),r&&at(r,s.conflictFiles??[],s.operation)}},[e,tt,st,Qe,at,r,h,d,I,Ye,a]);return m?Ue?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[Le?null:t.jsx(T,{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(Le?"gitView.toast.refreshRepositoryFailed":"gitView.empty.worktreeSetupInProgress")}),Le?t.jsx(W,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:()=>{oe&&x({directory:oe,status:"refreshing"})},children:e("gitView.empty.retryDiscovery")}):t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):B===null||B===!0&&!u?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(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):B===!1?t.jsx($a,{rootIsGitRepo:F,resolvedIsGitRepo:B,nestedRepos:Y,onRetryDiscovery:()=>{m&&de(m,{force:!0})},emptyStateFooter:se.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:Se("flex h-full flex-col overflow-hidden"),children:[t.jsx(Ha,{directory:r??"",status:u,localBranches:Vt,remoteBranches:ot,branchInfo:$?.branches,syncAction:Hs,remotes:ze,onFetch:s=>dr("fetch",s),onSync:s=>dr("sync",s),onRemoveRemote:dn,removingRemoteName:Zr,onCheckoutBranch:gn,onCreateBranch:mn,onRenameBranch:hn,activeIdentityProfile:wn,availableIdentities:xn,onSelectIdentity:fn,isApplyingIdentity:Ar,isWorktreeMode:!!G,onOpenHistory:()=>zt("history"),onOpenGraph:()=>zt("graph"),onOpenStashes:Nn,onOpenUpdateBranch:hr?()=>sr(!0):void 0,onOpenReintegrateCommits:ct?()=>rr(!0):void 0,pullRequest:Re?.pr??null,prChecks:Re?.checks??null,onOpenPullRequest:r?()=>xe(r,"pr"):void 0,repositoryOptions:r!==m&&Array.isArray(Y)?Y:void 0,selectedRepository:r!==m?r:null,onSelectRepository:r!==m&&m?s=>ke(m,s):void 0,repositoryRoot:r!==m?m:void 0}),m&&(u?.mergeInProgress?.head||u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto)&&t.jsx(Ii,{mergeInProgress:u?.mergeInProgress,rebaseInProgress:u?.rebaseInProgress,onContinue:Dn,onAbort:Mn,onResolveWithAI:En,conflictCount:Bn,isLoading:le}),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:Se("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(Rr,{as:La,ref:$s,outerClassName:"flex-1 min-h-0",className:Se("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:(it?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ua,{groups:Sn,diffStats:u?.diffStats,revertingPaths:os,isRevertingAll:ls,onVisiblePathsChange:Er,onRevertAll:jn,onRevertDirectory:Cn,headerBackgroundClassName:"bg-background"})}),t.jsx(Ka,{stagedCount:yn,commitMessage:Ke,onCommitMessageChange:We,generatedHighlights:cs,onInsertHighlights:kn,onGenerateMessage:un,isGeneratingMessage:Hr,onCommit:()=>ur({pushAfter:!1}),onCommitAndPush:()=>ur({pushAfter:!0}),commitAction:Ws,hasPendingIndexMutation:Wr,gitmojiEnabled:fe,onOpenGitmojiPicker:()=>rs(!0)})]}):t.jsx(oi,{onOpenStashes:()=>ns(!0)})})})})})}),t.jsx(mt,{open:Yr,onOpenChange:s=>{!s&&ar!==null||sr(s)},children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.branch.updateTitle")}),t.jsxs(bt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:u?.current??""}),"."]})]}),hr?t.jsx(Pi,{mode:"bare",currentBranch:u?.current,localBranches:Vt,remoteBranches:ot,defaultTargetBranch:pn,onMerge:Pn,onRebase:Fn,disabled:bn,isOperating:ar!==null,operationLogs:Xr,onOperationComplete:In}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(mt,{open:Qr,onOpenChange:rr,children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.integrate.title")}),t.jsx(bt,{children:ct?t.jsxs("span",{className:"font-mono text-foreground",children:[ct.sourceBranch," → ",Xs]}):null})]}),ct?t.jsx(ai,{repoRoot:ct.repoRoot,sourceBranch:ct.sourceBranch,worktreeMetadata:ct.worktreeMetadata,localBranches:Vt,defaultTargetBranch:Xs,refreshKey:_r,showHeader:!1,onRefresh:()=>{r&&(h(r,a),d(r,a),I(r,a,Ye))}},ct.worktreeMetadata.path):null]})}),t.jsx(mt,{open:Me!==null,onOpenChange:s=>{s||zt(null)},children:t.jsxs(ht,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(ft,{children:e(Me==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(Me==="graph"){an(s=>s+1);return}r&&I(r,a,Ye)},disabled:Me==="graph"?vs:ae,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(T,{name:"refresh",className:Se("size-4",(Me==="graph"?vs:ae)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(bt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(pi,{mode:Me==="graph"?"graph":"history",log:Me==="graph"?sn??Z:Z,isLogLoading:Me==="graph"&&vs||ae,logMaxCount:Me==="graph"?js:Ye,onLogMaxCountChange:Me==="graph"?On:Ln,expandedCommitHashes:hs,onToggleCommit:cn,commitFilesMap:Ot,loadingCommitHashes:At,onCopyHash:ln,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Me==="graph"?null:Jr,onConflict:Me==="graph"?zn:void 0,onActionSuccess:Me==="graph"?An:void 0})})]})}),t.jsx(ii,{open:Lr,onOpenChange:ns,directory:r,hasUncommittedChanges:(u?.files?.length??0)>0,hasStagedChanges:Je.length>0,uncommittedFileCount:u?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&K(r),await te(!1),await pe()}}),t.jsx(mt,{open:Tr,onOpenChange:rs,children:t.jsxs(ht,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(gt,{className:"px-4 pt-4",children:t.jsx(ft,{children:e("gitView.gitmoji.title")})}),t.jsxs(As,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(zs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:er,onValueChange:tr}),t.jsxs(Gs,{children:[t.jsx(_s,{children:e("gitView.gitmoji.empty")}),t.jsx(Zt,{children:Dt(He,er,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(Xt,{onSelect:()=>Vn(s.emoji,s.code),children:[t.jsx("span",{className:"text-lg",children:s.emoji}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s.code}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s.description})]},s.code))})]})]})]})}),r&&t.jsx(vi,{open:en,onOpenChange:Qe,conflictFiles:tn,directory:r,operation:_t,onAbort:Rn,onClearState:qe}),t.jsx(qa,{open:$t!==null,onOpenChange:s=>{s||kt(null)},targetBranch:$t??"",changedFileCount:u?.files?.length??0,onCommitAndSwitch:async(s,n)=>{const i=$t;if(!i||!r)return;const c=u?.current??null;await a.createGitCommit(r,s,{addAll:!0}),K(r);let j=null;if(n){const A=u?.tracking?.split("/")[0],X=ze.find(_=>_.name===A)??ze[0];try{if(!X)throw new Error(e("mobile.changes.noRemote"));await a.gitPush(r,u?.tracking?{remote:X.name}:{remote:X.name,branch:c??void 0,options:["--set-upstream"]}),j=X.name}catch(_){console.error("Push after commit failed:",_),b.error(e("gitView.dirtySwitch.pushFailed")),await te(),await pe(),kt(null);return}}b.success(j?e("gitView.toast.pushedToUpstream",{name:j}):c?e("gitView.dirtySwitch.committedNotPushed",{branch:c}):e("gitView.toast.commitCreated")),await te(),await pe(),kt(null),await Ps(i)},onGenerateMessage:async()=>{if(!r)return"";const s=(u?.files??[]).map(c=>c.path).sort(),{message:n}=await fr(r,s),i=n.subject?.trim()??"";if(i&&fe&&He.length>0){const c=Ir(i,He);if(c&&!i.startsWith(c.code)&&!i.startsWith(c.emoji))return`${c.code} ${i}`}return i},onRevertAndSwitch:async()=>{const s=$t;if(!s||!r)return;const n=(u?.files??[]).map(c=>c.path);await Pt(n,!0,"all");const i=await a.getGitStatus(r);if(!i.isClean&&(i.files?.length??0)>0){b.error(e("gitView.dirtySwitch.revertIncomplete"));return}kt(null),await Ps(s)}}),t.jsx(Vi,{open:on,onOpenChange:Cs,operation:Ns,targetBranch:Ss,onConfirm:Tn})]}):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{oc as GitView};