@vantran-se/openchamber-web 1.22.1 → 1.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/bin/cli.js +4 -1
- package/bin/cli.test.js +92 -0
- package/bin/lib/cli-startup.js +49 -0
- package/bin/lib/commands-startup.js +41 -6
- package/dist/assets/{CodeMirrorCommentWidgets-C53Q7pbX.js → CodeMirrorCommentWidgets-CV1HNV5l.js} +1 -1
- package/dist/assets/{DiffView-Dh1ey2x9.js → DiffView-DkkSa30n.js} +3 -3
- package/dist/assets/DirtyBranchSwitchDialog-DW4WaXPc.js +1 -0
- package/dist/assets/FilesView-DDu8zDy5.js +17 -0
- package/dist/assets/GitView-1Ixo8z-M.js +6 -0
- package/dist/assets/{JsonTreeView-Bl0lp9Rs.js → JsonTreeView-DvCLL7dT.js} +1 -1
- package/dist/assets/LinearIssuesView-Bs1rZrF2.js +1 -0
- package/dist/assets/{MarkdownImageGallery-bA0PS-tn.js → MarkdownImageGallery-DyJUc6h9.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-Bdm8vMkS.js +12 -0
- package/dist/assets/{OnboardingScreen-D3kYJIb6.js → OnboardingScreen-Dg66B6oB.js} +1 -1
- package/dist/assets/{PatchDiff-D6NXAfJk.js → PatchDiff-CAduNjfZ.js} +1 -1
- package/dist/assets/{PierreDiffViewer-Ct2A13NO.js → PierreDiffViewer-CTIb1GYD.js} +2 -2
- package/dist/assets/PlanView-trDaszfq.js +5 -0
- package/dist/assets/SettingsView-DStMfBmy.js +28 -0
- package/dist/assets/{SettingsWindow-BiWDBRvb.js → SettingsWindow-DQQFnrSZ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BQexMQIm.js → ToolOutputDialog-SjY2XZlA.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-DJdzUQPE.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-Dpz2ra8h.js → VirtualizedFileDiff-Iehm4iMH.js} +1 -1
- package/dist/assets/{WalkthroughView-AX-u2pFg.js → WalkthroughView-BALp2d9O.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DtyozJdt.js → computeVirtualFileMetrics-BKZA43vN.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-C9EcRSDF.js → contextPanelEmbeddedChat-D2PM_pEv.js} +1 -1
- package/dist/assets/{de-DqVn5vme.js → de-DlSNLAcy.js} +6 -5
- package/dist/assets/{es-hj43Z53i.js → es-D1GbowZ3.js} +6 -5
- package/dist/assets/{fr-BmkZt2mF.js → fr-BPOLXIAY.js} +6 -5
- package/dist/assets/{index-DmhujXbT.js → index-Ce0LR32V.js} +1 -1
- package/dist/assets/index-D42fPvt4.css +1 -0
- package/dist/assets/index-DlFbCkEy.js +39 -0
- package/dist/assets/{isDiffPlainText-XyulMHxx.js → isDiffPlainText-DaB2u_Kv.js} +1 -1
- package/dist/assets/{isFilePlainText-B19Ddps1.js → isFilePlainText-yJZa2IAC.js} +1 -1
- package/dist/assets/{ja-DioMIEGF.js → ja-Dm2-m9io.js} +7 -6
- package/dist/assets/{ko-BqPgaQJb.js → ko-CIXlzQ5-.js} +7 -6
- package/dist/assets/main-B7qTsd_w.js +930 -0
- package/dist/assets/{main-B2a_JfKZ.js → main-CyQrD9dG.js} +2 -2
- package/dist/assets/{markdownCore-CWRCqSH2.js → markdownCore-CeEwGgEK.js} +2 -2
- package/dist/assets/{miniChat-B3CSU_Ps.js → miniChat-7cPEx4sV.js} +2 -2
- package/dist/assets/{mobile-QNcFIVCW.js → mobile-QtzkPTM8.js} +2 -2
- package/dist/assets/{patchFileDiff-BpMQZnYu.js → patchFileDiff-No55fDiD.js} +1 -1
- package/dist/assets/pl-B2zmkOpw.js +16 -0
- package/dist/assets/{pt-BR-BqH8fuCH.js → pt-BR-C-JE5H6y.js} +6 -5
- package/dist/assets/{renderElectronMiniChatApp-D77bmLqo.js → renderElectronMiniChatApp-ePTkBJNS.js} +2 -2
- package/dist/assets/renderMobileApp-D9RjB9DX.js +25 -0
- package/dist/assets/runtimeEndpointReset-DfJIWwwo.js +17 -0
- package/dist/assets/{scheduledTasksApi-BSRCtP6T.js → scheduledTasksApi-DuhdyYEa.js} +1 -1
- package/dist/assets/{shikiHighlight-DE-OwqGw.js → shikiHighlight-EHEg58-n.js} +1 -1
- package/dist/assets/tr-MJmRIzEY.js +7 -0
- package/dist/assets/{uk-BkkfxbOs.js → uk-BmD7eM8k.js} +6 -5
- package/dist/assets/{useAppFontEffects-COAeIX-D.js → useAppFontEffects-CuJPKtI1.js} +151 -180
- package/dist/assets/useInlineCommentController-DD7_7OP_.js +2 -0
- package/dist/assets/{useRootScrollLock-C0N9mCwz.js → useRootScrollLock-DRGAe8PN.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-BG3v1Ghq.js → vendor-codemirror-language-data-9ZzoH0o0.js} +2 -2
- package/dist/assets/vendor-zod-CK21ihK-.js +39 -0
- package/dist/assets/{web-components-BNMwa0qm.js → web-components-PttKBrhi.js} +1 -1
- package/dist/assets/{zh-CN-C6FMdVgv.js → zh-CN-JJHl4ehT.js} +6 -5
- package/dist/assets/{zh-TW-CdcMjDxv.js → zh-TW-DPc4DEEW.js} +6 -5
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +8 -4
- package/server/index.js +38 -5
- package/server/lib/agent-tool/runtime.js +2 -19
- package/server/lib/changelog/update-notes.js +82 -0
- package/server/lib/changelog/update-notes.test.js +59 -0
- package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
- package/server/lib/dev-tunnel/runtime.js +4 -4
- package/server/lib/dev-tunnel/tunnel.test.js +20 -0
- package/server/lib/fs/DOCUMENTATION.md +2 -0
- package/server/lib/fs/routes.js +32 -21
- package/server/lib/fs/routes.test.js +77 -0
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/routes.js +16 -0
- package/server/lib/git/service.js +107 -17
- package/server/lib/git/service.test.js +171 -0
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
- package/server/lib/mcp-reconnect/runtime.js +122 -0
- package/server/lib/mcp-reconnect/runtime.test.js +140 -0
- package/server/lib/message-queue/DOCUMENTATION.md +158 -0
- package/server/lib/message-queue/runtime.js +870 -0
- package/server/lib/message-queue/runtime.test.js +482 -0
- package/server/lib/openchamber-sessions/routes.js +102 -0
- package/server/lib/openchamber-sessions/routes.test.js +88 -0
- package/server/lib/opencode/DOCUMENTATION.md +13 -5
- package/server/lib/opencode/config-paths.test.js +116 -0
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +5 -0
- package/server/lib/opencode/input-history-scope.js +14 -0
- package/server/lib/opencode/managed-plugin-config.js +35 -0
- package/server/lib/opencode/openchamber-routes.test.js +2 -2
- package/server/lib/opencode/plugins.js +2 -2
- package/server/lib/opencode/providers.js +44 -2
- package/server/lib/opencode/providers.test.js +131 -4
- package/server/lib/opencode/routes.js +4 -4
- package/server/lib/opencode/server-startup-runtime.js +1 -1
- package/server/lib/opencode/settings-helpers.js +28 -0
- package/server/lib/opencode/settings-helpers.test.js +177 -0
- package/server/lib/opencode/settings-runtime.js +2 -2
- package/server/lib/opencode/settings-runtime.test.js +29 -0
- package/server/lib/opencode/shared.js +4 -1
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/skill-routes.js +2 -1
- package/server/lib/opencode/snippets.js +1 -2
- package/server/lib/package-manager.js +4 -29
- package/server/lib/package-manager.test.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +2 -1
- package/server/lib/quota/credentials/providers.js +4 -0
- package/server/lib/quota/credentials/store.js +1 -1
- package/server/lib/quota/credentials/store.test.js +4 -4
- package/server/lib/quota/providers/exe-dev.js +75 -0
- package/server/lib/quota/providers/exe-dev.test.js +47 -0
- package/server/lib/quota/providers/index.js +7 -0
- package/server/lib/quota/providers/opencode-go.js +1 -0
- package/server/lib/quota/providers/opencode-go.test.js +5 -1
- package/server/lib/quota/routes.js +2 -0
- package/server/lib/quota/utils/auth.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/host-client.test.js +9 -1
- package/server/lib/relay/tunnel-host.js +3 -1
- package/server/lib/relay/tunnel-host.test.js +9 -1
- package/server/lib/security/request-security.js +21 -6
- package/server/lib/security/request-security.test.js +42 -8
- package/server/lib/session-assist/runtime.js +1 -0
- package/server/lib/session-goal/DOCUMENTATION.md +20 -7
- package/server/lib/session-goal/create.js +3 -1
- package/server/lib/session-goal/runtime.js +77 -11
- package/server/lib/session-goal/runtime.test.js +426 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
- package/server/lib/skills-catalog/install.js +3 -2
- package/server/lib/small-model/DOCUMENTATION.md +4 -0
- package/server/lib/small-model/call.js +8 -2
- package/server/lib/small-model/call.test.js +23 -0
- package/server/lib/small-model/index.js +2 -1
- package/server/lib/small-model/routes.js +2 -1
- package/server/lib/system-prompt/runtime.js +2 -21
- package/server/lib/terminal/DOCUMENTATION.md +11 -7
- package/server/lib/terminal/runtime.js +180 -26
- package/server/lib/terminal/runtime.test.js +553 -26
- package/server/lib/terminal/shells.js +17 -0
- package/server/lib/terminal/shells.test.js +32 -1
- package/server/lib/ui-auth/ui-auth.js +4 -1
- package/server/lib/ui-auth/ui-auth.test.js +16 -0
- package/server/lib/walkthrough/index.js +1 -0
- package/server/lib/walkthrough/routes.test.js +26 -5
- package/dist/assets/CommitSection-X-f2RgYr.js +0 -1
- package/dist/assets/FilesView-3ZYP72ki.js +0 -17
- package/dist/assets/GitView-CMuN7z2Z.js +0 -6
- package/dist/assets/LinearIssuesView-CQiUDU8b.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BGQi2PLq.js +0 -12
- package/dist/assets/PlanView-6AUjzNQn.js +0 -5
- package/dist/assets/SettingsView-CHI8fFaK.js +0 -28
- package/dist/assets/ToolPartDiffPreview-DPAATNn6.js +0 -8
- package/dist/assets/index-L_ncV-6H.css +0 -1
- package/dist/assets/index-qES19dlJ.js +0 -7
- package/dist/assets/main-CYgSu6dx.js +0 -928
- package/dist/assets/pl-slULBF4R.js +0 -15
- package/dist/assets/renderMobileApp-BQ3Kdm-d.js +0 -25
- package/dist/assets/runtimeEndpointReset-CRGn1gVj.js +0 -16
- package/dist/assets/tr-CjEbw1Aw.js +0 -6
- package/dist/assets/useInlineCommentController-JsBboQwt.js +0 -2
- package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{R as l,r as be,j as t,f as Ct}from"./vendor-react-BUCujlKS.js";import{f as et,y as Ze,a0 as Rt,hV as Mn,cU as Jt,cf as qt,t as v,I as A,b4 as Bs,b1 as Ds,cS as Nr,b3 as Ms,cx as Es,cy as Ts,cz as As,cA as Ls,cs as Yt,ct as Qt,B as W,hW as En,hX as Tn,bG as ht,bH as gt,bI as ft,bJ as pt,bK as bt,S as dr,a6 as Xt,a7 as Zt,a8 as es,hY as An,h as Ce,hZ as Ln,h_ as On,h$ as zn,i0 as Gn,b0 as _n,am as Hn,bR as $n,i1 as Wn,i2 as Un,i3 as Kn,i4 as Jn,i5 as qn,i6 as Yn,i7 as Qn,c2 as Sr,bU as Xn,bV as Zn,bW as ea,bX as ta,bY as sa,i8 as ra,b$ as na,bL as Rs,eN as aa,V as ia,ab as oa,ac as la,ae as ca,ad as da,bw as ua,i9 as ma,c0 as ha,ia as ga,ib as fa,af as pa,ic as xa,ag as wa,bP as ya,hO as ba,l as va,c1 as ja,g as Ca,cC as Na,al as Sa,a1 as ka,id as Va,ie as Is}from"./useAppFontEffects-COAeIX-D.js";import{a as Ia,b as Pa,d as Fa}from"./main-CYgSu6dx.js";import{x as Ra,w as Ba,v as Da,X as Ma,c as Ea,a0 as Ta}from"./runtimeEndpointReset-CRGn1gVj.js";import{u as ur}from"./vendor-zustand-BAGL70zf.js";import{r as Aa,u as Pt}from"./index-qES19dlJ.js";import{C as La,a as Oa}from"./CommitSection-X-f2RgYr.js";import{P as za}from"./PierreDiffViewer-Ct2A13NO.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-BeMD8X_w.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"./contextPanelEmbeddedChat-C9EcRSDF.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-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-BG3v1Ghq.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-BLfBSgBh.js";import"./useRootScrollLock-C0N9mCwz.js";import"./scheduledTasksApi-BSRCtP6T.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-BNMwa0qm.js";import"./computeVirtualFileMetrics-DtyozJdt.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-Dpz2ra8h.js";import"./isDiffPlainText-XyulMHxx.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-JsBboQwt.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";const kr="gitmojiCache",Ga=1e3*60*60*24*7,Vr="1",_a="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Ir=i=>{if(!i||typeof i!="object")return!1;const e=i;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Ps=()=>{if(typeof window>"u")return null;try{const i=window.localStorage.getItem(kr);if(!i)return null;const e=JSON.parse(i);return!e||e.version!==Vr||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(Ir),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Ha=i=>{if(!(typeof window>"u"))try{const e={gitmojis:i,fetchedAt:Date.now(),version:Vr};window.localStorage.setItem(kr,JSON.stringify(e))}catch{return}},mr=i=>Date.now()-i.fetchedAt<Ga;let Ut=null;const Ft=new Set,hr=async()=>{if(Ut)return Ut;const i=(async()=>{try{const e=await fetch(_a);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const n=await e.json(),u=Array.isArray(n.gitmojis)?n.gitmojis.filter(Ir):[];return Ha(u),Ft.forEach(j=>j(u)),u}catch(e){console.warn("Failed to load gitmoji list:",e);const n=[];return Ft.forEach(u=>u(n)),n}finally{Ut=null}})();return Ut=i,i},$a=i=>{const[e,n]=l.useState(()=>i?Ps()?.gitmojis??[]:[]),[u,j]=l.useState(!1),f=l.useRef(i);f.current=i,l.useEffect(()=>{if(!i){Ft.delete(n),n([]),j(!1);return}const p=Ps();if(p&&(n(p.gitmojis),mr(p)))return;Ft.add(n),j(!0);let h=!1;return hr().finally(()=>{!h&&f.current&&j(!1)}),()=>{h=!0,Ft.delete(n)}},[i]);const x=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const p=Ps();return p&&mr(p)?p.gitmojis:hr()},[e]);return{gitmojis:e,isLoading:u,ensureLoaded:x}},Nt=async(i,e)=>{const n=await Aa(`/api/git/integrate/${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const u=await n.json().catch(()=>null);throw new Error(u?.error||`Git integrate request failed: ${n.statusText}`)}return n.json()};async function It(i){return Nt("plan",i)}async function Wa(i){return Nt("conflict-details",{tempWorktreePath:i})}async function Ua(i){return(await Nt("cherry-pick-status",{tempWorktreePath:i})).inProgress}async function Ka(i){return Nt("run",{plan:i})}async function Ja(i){await Nt("abort",{state:i})}async function qa(i){return Nt("continue",{state:i})}const Ya=({repoRoot:i,sourceBranch:e,worktreeMetadata:n,localBranches:u,defaultTargetBranch:j,refreshKey:f,onRefresh:x,showHeader:p=!0})=>{const{t:h}=et(),w=Ze(g=>g.currentSessionId),[E,b]=be.useState(!1),[V,L]=be.useState(""),S=be.useRef(null),O=be.useMemo(()=>Rt(u,V,g=>[g]),[u,V]),[C,y]=be.useState(j);be.useEffect(()=>{y(j)},[j]),be.useEffect(()=>{if(E){const g=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(g)}},[E]);const D=!!(i&&e&&C&&C!=="HEAD"&&e!==C),[k,R]=be.useState({kind:"idle"}),[I,F]=be.useState(!1),[r,Y]=be.useState([]),B=be.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);be.useEffect(()=>{if(!B||typeof window>"u")return;const g=window.localStorage.getItem(B);if(!g)return;let d=!1;try{const P=JSON.parse(g);if(!P?.tempWorktreePath||P.repoRoot!==i){window.localStorage.removeItem(B);return}(async()=>{const M=await Ua(P.tempWorktreePath).catch(()=>!1);if(d)return;if(!M){window.localStorage.removeItem(B);return}const J=await Wa(P.tempWorktreePath).catch(()=>null);d||J&&R({kind:"conflict",state:P,details:J})})()}catch{window.localStorage.removeItem(B)}return()=>{d=!0}},[B,i]),be.useEffect(()=>{if(!D){R({kind:"idle"});return}let g=!1;return R({kind:"loading"}),(async()=>{try{const d=await It({repoRoot:i,sourceBranch:e,targetBranch:C});if(g)return;if(R({kind:"ready",plan:d}),d.commits.length>0){const M=d.commits.slice(-50).reverse(),J=await Mn(i,M);g||(Y(J),F(!1))}else g||(Y([]),F(!1))}catch{g||R({kind:"idle"})}})(),()=>{g=!0}},[D,i,e,C,f]);const m=be.useCallback(g=>{w&&Ze.getState().setWorktreeMetadata(w,{...n,createdFromBranch:g})},[w,n]),T=Ze(g=>g.openNewSessionDraft),ee=be.useCallback(async g=>{const d=await Jt("git.integrate.cherrypick.resolve.visible",{current_commit:g.state.currentCommit,target_branch:g.state.targetBranch}),P=await Jt("git.integrate.cherrypick.resolve.instructions",{repo_root:g.state.repoRoot,temp_worktree_path:g.state.tempWorktreePath,source_branch:g.state.sourceBranch,target_branch:g.state.targetBranch,current_commit:g.state.currentCommit}),M=`Cherry-pick conflict context (JSON)
|
|
2
|
-
${JSON.stringify({repoRoot:g.state.repoRoot,tempWorktreePath:g.state.tempWorktreePath,sourceBranch:g.state.sourceBranch,targetBranch:g.state.targetBranch,currentCommit:g.state.currentCommit,remainingCommits:g.state.remainingCommits,statusPorcelain:g.details.statusPorcelain,unmergedFiles:g.details.unmergedFiles,currentPatchMeta:g.details.currentPatchMeta,currentPatch:g.details.currentPatch,diff:g.details.diff},null,2)}`;return{visibleText:d,instructionsText:P,payloadText:M}},[]),$=qt(g=>g.setPendingInputText),G=qt(g=>g.setPendingSyntheticParts),_=be.useCallback(async(g,d)=>{const P=await ee(g);if(d){T({directoryOverride:g.state.tempWorktreePath,initialPrompt:P.visibleText,syntheticParts:[{text:P.instructionsText,synthetic:!0},{text:P.payloadText,synthetic:!0}]});return}if(!w){v.error(h("gitView.integrate.noActiveSession"),{description:h("gitView.integrate.noActiveSessionDescription")});return}$(P.visibleText,"replace"),G([{text:P.instructionsText,synthetic:!0},{text:P.payloadText,synthetic:!0}])},[w,ee,T,$,G,h]),Z=be.useCallback(async()=>{if(k.kind==="ready"){if(k.plan.commits.length===0){v.message(h("gitView.integrate.noCommitsToMoveToast"));return}R({kind:"running",plan:k.plan});try{const g=await Ka(k.plan);if(g.kind==="success"){v.success(h("gitView.integrate.commitsMovedToast"),{description:g.moved===1?h("gitView.integrate.commitsMovedDescriptionSingle",{count:g.moved,branch:k.plan.targetBranch}):h("gitView.integrate.commitsMovedDescriptionPlural",{count:g.moved,branch:k.plan.targetBranch})});const d=await It(k.plan);R({kind:"ready",plan:d}),x?.();return}g.kind==="conflict"&&(v.error(h("gitView.integrate.cherryPickConflictToast"),{description:h("gitView.integrate.cherryPickConflictDescription")}),R({kind:"conflict",state:g.state,details:g.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(g.state)))}catch(g){const d=g instanceof Error?g.message:String(g);v.error(h("gitView.integrate.failedToMoveToast"),{description:d});const P=await It({repoRoot:i,sourceBranch:e,targetBranch:C}).catch(()=>null);R(P?{kind:"ready",plan:P}:{kind:"idle"})}}},[k,x,i,e,C,B,h]),H=be.useCallback(async()=>{if(k.kind==="conflict")try{await Ja(k.state),v.message(h("gitView.integrate.cherryPickAbortedToast")),B&&typeof window<"u"&&window.localStorage.removeItem(B)}finally{const g=await It({repoRoot:i,sourceBranch:e,targetBranch:C}).catch(()=>null);R(g?{kind:"ready",plan:g}:{kind:"idle"})}},[k,i,e,C,B,h]),ce=be.useCallback(async()=>{if(k.kind==="conflict")try{const g=await qa(k.state);if(g.kind==="success"){v.success(h("gitView.integrate.cherryPickFinishedToast"));const d=await It({repoRoot:i,sourceBranch:e,targetBranch:C}).catch(()=>null);R(d?{kind:"ready",plan:d}:{kind:"idle"}),B&&typeof window<"u"&&window.localStorage.removeItem(B),x?.();return}g.kind==="conflict"&&(R({kind:"conflict",state:g.state,details:g.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(g.state)))}catch(g){const d=g instanceof Error?g.message:String(g);v.error(h("gitView.integrate.cherryPickContinueFailedToast"),{description:d})}},[k,i,e,C,x,B,h]);return!i||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[p?t.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(A,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:h("gitView.integrate.title")}),k.kind==="ready"&&k.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:h("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(A,{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:h("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",C]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Bs,{open:E,onOpenChange:b,children:[t.jsx(Ds,{asChild:!0,children:t.jsxs("button",{type:"button",className:Nr({size:"default"}),children:[h("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:C}),t.jsx(A,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Ms,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(Es,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Ts,{ref:S,placeholder:h("gitView.branch.searchPlaceholder"),value:V,onValueChange:L,onKeyDown:g=>g.stopPropagation()}),t.jsxs(As,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Ls,{children:h("gitView.branch.empty")}),t.jsx(Yt,{heading:h("gitView.branch.localBranches"),children:O.map(g=>t.jsx(Qt,{value:g,onSelect:()=>{y(g),m(g),b(!1),L("")},children:g},g))})]})]})})]}),k.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{Z()},disabled:!D||k.plan.commits.length===0,children:h("gitView.integrate.move")}):k.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:h("gitView.integrate.checking")}):k.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:h("gitView.integrate.moving")}):null]}),k.kind==="ready"&&k.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:h("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:[h("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(g=>!g),className:"typography-micro text-muted-foreground hover:text-foreground",children:h(I?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(I?r:r.slice(0,5)).map(g=>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:g.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:g.subject||g.sha})]},g.sha)),r.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:h("gitView.integrate.previewUnavailable")}),k.plan.commits.length>r.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:h("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:h("gitView.integrate.conflictsInFiles",{count:k.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[h("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(g=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:g},g)),k.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:h("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:h("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(A,{name:"sparkling",className:"size-3.5"}),h("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(A,{name:"sparkling",className:"size-3.5"}),h("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{ce()},children:h("gitView.operation.continue")})]})]})]})]})},Qa=({open:i,onOpenChange:e,directory:n,hasUncommittedChanges:u,hasStagedChanges:j=!1,uncommittedFileCount:f,onChanged:x})=>{const{t:p}=et(),[h,w]=l.useState([]),[E,b]=l.useState(!1),[V,L]=l.useState(""),[S,O]=l.useState(""),[C,y]=l.useState(null),[D,k]=l.useState({}),R=l.useCallback(async()=>{if(n){b(!0);try{const m=await En(n);w(m.stashes),k({})}catch(m){v.error(m instanceof Error?m.message:p("gitView.stashes.toast.loadFailed"))}finally{b(!1)}}},[n,p]);l.useEffect(()=>{i&&R()},[R,i]),l.useEffect(()=>{if(!i||!n||h.length===0)return;let m=!1;const T=h.map(ee=>ee.ref);return Tn(n,T).then(ee=>{m||k(ee.counts)}).catch(()=>{}),()=>{m=!0}},[n,i,h]);const I=l.useMemo(()=>Rt(h,V,m=>[m.message,m.ref,m.relativeTime]),[V,h]),F=l.useCallback(async m=>{await R(),await x?.(m)},[R,x]),r=async()=>{if(!(!n||C)){y("create");try{const m=await An(n,{message:S.trim()||void 0});m.created?(v.success(p("gitView.stashes.toast.created")),O("")):v.info(p("gitView.stashes.toast.noChanges")),await F({affectsIndex:!!(m.created&&j)})}catch(m){v.error(m instanceof Error?m.message:p("gitView.stashes.toast.createFailed"))}finally{y(null)}}},Y=async(m,T)=>{if(!(!n||C)&&!(T==="drop"&&!window.confirm(p("gitView.stashes.confirm.drop",{ref:m.ref})))){y(`${T}:${m.ref}`);try{T==="apply"&&await Ln(n,{ref:m.ref}),T==="pop"&&await On(n,{ref:m.ref}),T==="drop"&&await zn(n,{ref:m.ref});const ee=T==="apply"?"gitView.stashes.toast.applySuccess":T==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";v.success(p(ee)),await F({affectsIndex:T!=="drop"})}catch(ee){const $=T==="apply"?"gitView.stashes.toast.applyFailed":T==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";v.error(ee instanceof Error?ee.message:p($)),await F({affectsIndex:T!=="drop"})}finally{y(null)}}},B=C!==null;return t.jsx(ht,{open:i,onOpenChange:e,children:t.jsxs(gt,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(ft,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(A,{name:"archive-stack",className:"h-5 w-5"}),p("gitView.stashes.title")]}),t.jsx(bt,{children:p("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(dr,{value:S,onChange:m=>O(m.target.value),placeholder:p("gitView.stashes.messagePlaceholder"),disabled:B||!u,className:"flex-1"}),t.jsxs(W,{onClick:r,disabled:!u||B||!n,children:[C==="create"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"inbox-archive",className:"size-4"}),p("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:p("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(A,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(dr,{value:V,onChange:m=>L(m.target.value),placeholder:p("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:E?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(A,{name:"loader-4",className:"size-5 animate-spin"})}):I.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:p(V?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):I.map((m,T)=>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:m.message||p("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(Xt,{children:[t.jsx(Zt,{asChild:!0,children:t.jsx("span",{children:T===0&&!V.trim()?p("gitView.stashes.latestLabel"):p("gitView.stashes.itemNumber",{number:T+1})})}),t.jsx(es,{sideOffset:6,children:m.ref})]})," · ",m.relativeTime," · ",typeof D[m.ref]=="number"?p("gitView.stashes.fileCount",{count:D[m.ref]}):p("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Fs,{label:p("gitView.stashes.actions.apply"),loading:C===`apply:${m.ref}`,onClick:()=>Y(m,"apply"),disabled:B,children:t.jsx(A,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Fs,{label:p("gitView.stashes.actions.pop"),loading:C===`pop:${m.ref}`,onClick:()=>Y(m,"pop"),disabled:B,children:t.jsx(A,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Fs,{label:p("gitView.stashes.actions.drop"),loading:C===`drop:${m.ref}`,onClick:()=>Y(m,"drop"),disabled:B,destructive:!0,children:t.jsx(A,{name:"delete-bin",className:"size-4"})})]})]},m.ref))})]})})},Fs=i=>{const e=Ct.c(17),{label:n,loading:u,disabled:j,destructive:f,onClick:x,children:p}=i,h=u||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let E;e[0]!==w?(E=Ce("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=E):E=e[1];let b;e[2]!==p||e[3]!==u?(b=u?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):p,e[2]=p,e[3]=u,e[4]=b):b=e[4];let V;e[5]!==j||e[6]!==n||e[7]!==x||e[8]!==h||e[9]!==E||e[10]!==b?(V=t.jsx(Zt,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":n,"aria-busy":h,className:E,onClick:x,disabled:j,children:b})}),e[5]=j,e[6]=n,e[7]=x,e[8]=h,e[9]=E,e[10]=b,e[11]=V):V=e[11];let L;e[12]!==n?(L=t.jsx(es,{sideOffset:6,children:n}),e[12]=n,e[13]=L):L=e[13];let S;return e[14]!==V||e[15]!==L?(S=t.jsxs(Xt,{children:[V,L]}),e[14]=V,e[15]=L,e[16]=S):S=e[16],S},Xa=i=>{const e=Ct.c(16),{onOpenStashes:n}=i,{t:u}=et();let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(A,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=j):j=e[0];let f;e[1]!==u?(f=u("gitView.empty.cleanTitle"),e[1]=u,e[2]=f):f=e[2];let x;e[3]!==f?(x=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=x):x=e[4];let p;e[5]!==u?(p=u("gitView.empty.cleanDescription"),e[5]=u,e[6]=p):p=e[6];let h;e[7]!==p?(h=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:p}),e[7]=p,e[8]=h):h=e[8];let w;e[9]!==n||e[10]!==u?(w=n?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[t.jsx(A,{name:"archive-stack",className:"size-4"}),u("gitView.stashes.title")]}):null,e[9]=n,e[10]=u,e[11]=w):w=e[11];let E;return e[12]!==x||e[13]!==h||e[14]!==w?(E=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[j,x,h,w]}),e[12]=x,e[13]=h,e[14]=w,e[15]=E):E=e[15],E},mt=8,Za=i=>{const e=Ct.c(18),{laned:n,totalLanes:u,isExpanded:j}=i,{lane:f,color:x,connectors:p}=n,w=Math.max(u,f+1)*mt+mt/2,E=l.useRef(null),b=l.useRef(null);let V;e[0]!==x||e[1]!==p||e[2]!==f||e[3]!==w?(V=()=>{const y=E.current,D=b.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 I=D.getContext("2d");if(!I)return;I.scale(R,R),I.clearRect(0,0,w,k);const F=k/2,r=f*mt+mt/2,Y=getComputedStyle(D),B=Y.getPropertyValue("--surface-muted-foreground").trim()||Y.color,m=$=>{if(!$.startsWith("var("))return $;const G=$.slice(4,-1).trim();return Y.getPropertyValue(G).trim()||B},T=[...p].sort(ti);for(const $ of T){const G=$.fromLane*mt+mt/2,_=$.toLane*mt+mt/2,Z=$.type==="passing"?.72:$.type==="branch-out"||$.type==="merge-in"?.95:1;I.beginPath(),I.strokeStyle=m($.color),I.globalAlpha=Z,I.lineWidth=1.25,I.lineCap="round";e:switch($.type){case"passing":case"commit-lane":{I.moveTo(G,0),I.lineTo(G,k);break e}case"top-stub":{I.moveTo(G,0),I.lineTo(G,F);break e}case"bottom-stub":{I.moveTo(G,F),I.lineTo(G,k);break e}case"branch-out":{const H=(F+k)/2;I.moveTo(r,F),I.bezierCurveTo(r,H,_,H,_,k);break e}case"merge-in":{const H=F/2;I.moveTo(G,0),I.bezierCurveTo(G,H,r,H,r,F);break e}default:continue}I.stroke(),I.globalAlpha=1}const ee=Y.getPropertyValue("--background").trim()||Y.getPropertyValue("--surface-background").trim();I.beginPath(),I.arc(r,F,4,0,Math.PI*2),I.fillStyle=m(x),I.fill(),I.beginPath(),I.arc(r,F,5,0,Math.PI*2),I.strokeStyle=ee||B,I.lineWidth=2,I.stroke()},e[0]=x,e[1]=p,e[2]=f,e[3]=w,e[4]=V):V=e[4];let L;e[5]!==x||e[6]!==p||e[7]!==j||e[8]!==f||e[9]!==n||e[10]!==u||e[11]!==w?(L=[n,f,x,p,u,j,w],e[5]=x,e[6]=p,e[7]=j,e[8]=f,e[9]=n,e[10]=u,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 O;e[15]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx("canvas",{ref:b,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=O):O=e[15];let C;return e[16]!==S?(C=t.jsx("div",{ref:E,style:S,children:O}),e[16]=S,e[17]=C):C=e[17],C};function ei(i){return i==="branch-out"||i==="merge-in"}function ti(i,e){const n=ei;return(n(i.type)?1:0)-(n(e.type)?1:0)}const gr=15e3,fr=500,pr=12,xr=8*1024*1024,wr=i=>typeof i=="string"?0:(i.original?.length??0)+(i.modified?.length??0),yr=i=>{if(i.size<=pr){let j=0;for(const f of i.values())j+=wr(f);if(j<=xr)return i}const e=Array.from(i.entries()).reverse(),n=new Map;let u=0;for(const[j,f]of e){if(n.size>=pr)continue;const x=wr(f);u+x>xr&&n.size>0||(n.set(j,f),u+=x)}return new Map(Array.from(n.entries()).reverse())};function br(i,e){const n=new Date(i);return Number.isNaN(n.getTime())?i:$n(n,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function si(i){switch(i){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}function ri(i){return i?i.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.startsWith("HEAD ->");return{label:n?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:n,isTag:e.startsWith("tag: ")}}):[]}const ni=l.memo(({entry:i,mode:e="history",laned:n,totalLanes:u,isExpanded:j,onToggle:f,files:x,isLoadingFiles:p,onCopyHash:h,directory:w,onConflict:E,onActionSuccess:b})=>{const{t:V}=et(),L=Pt(d=>d.timeFormatPreference),S=e==="graph",[O,C]=l.useState(null),[y,D]=l.useState(!1),[k,R]=l.useState(""),[I,F]=l.useState(null),[r,Y]=l.useState(new Set),[B,m]=l.useState(new Map),[T,ee]=l.useState(new Set),$=async()=>{if(w){C("checkout");try{await Qn(w,i.hash),v.success(V("gitView.history.actions.detachedHead")),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},G=async()=>{if(!(!w||!k.trim())){C("createBranch");try{await Wn(w,k.trim(),i.hash),D(!1),R(""),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},_=async()=>{if(w){C("cherryPick");try{const d=await Yn(w,i.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"cherry-pick"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},Z=async()=>{if(w){C("revert");try{const d=await qn(w,i.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"revert"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},H=async(d,P=!1)=>{if(!(!w||O!==null)){C("reset");try{await Un(w,i.hash,d,P),b?.()}catch(M){v.error(String(M.message))}finally{C(null)}}},ce=async()=>{if(!I)return;const d=I;switch(F(null),d){case"checkout":return $();case"cherryPick":return _();case"revert":return Z();case"merge":return ie();case"rebase":return de();case"resetSoft":return H("soft");case"resetMixed":return H("mixed");case"resetHard":return H("hard",!0)}},ie=async()=>{if(w){C("merge");try{const d=await Jn(w,{branch:i.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"merge"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},de=async()=>{if(w){C("rebase");try{const d=await Kn(w,{onto:i.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"rebase"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},oe=l.useCallback(async d=>{const P=d.path;if(!w){m(M=>new Map(M).set(P,"error"));return}m(M=>yr(new Map(M).set(P,"loading")));try{const M=Gn(w,i.hash,d.path,!1),J=new Promise((te,K)=>{setTimeout(()=>K(new Error(`Timed out after ${gr}ms`)),gr)}),ae=await Promise.race([M,J]);m(te=>yr(new Map(te).set(P,ae)))}catch{m(M=>new Map(M).set(P,"error"))}},[w,i.hash]),g=l.useCallback(async d=>{const P=d.path;if(d.changeType==="R"||d.isBinary){Y(te=>{const K=new Set(te);return K.has(P)?K.delete(P):K.add(P),K});return}const M=B.get(P);if(r.has(P)&&M&&M!=="error"){Y(te=>{const K=new Set(te);return K.delete(P),K});return}Y(te=>{const K=new Set(te);return K.add(P),K}),!(M&&M!=="error"||d.insertions+d.deletions>fr&&!T.has(P))&&await oe(d)},[B,T,oe,r]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Ce("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":j?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&n&&u!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(Za,{laned:n,totalLanes:u,isExpanded:j})}):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=ri(i.refs);return d.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:d.map(P=>t.jsx("span",{className:Ce("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",P.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":P.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:P.label},P.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:i.message}),t.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t.jsx("span",{className:"truncate min-w-[3ch]",title:i.author_name,children:i.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:br(i.date,L),children:br(i.date,L)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:i.hash.slice(0,8)}),t.jsxs(Xt,{children:[t.jsx(Zt,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:d=>{d.stopPropagation(),h(i.hash)},children:t.jsx(A,{name:"file-copy",className:"size-3"})})}),t.jsx(es,{sideOffset:8,children:V("gitView.history.copySha")})]})]})]})]}),j&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[S&&I?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.${I}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:O!==null,onClick:d=>{d.stopPropagation(),ce()},children:[O!==null?t.jsx(A,{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:O!==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:O!==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()||O!==null,onClick:d=>{d.stopPropagation(),G()},children:[O==="createBranch"?t.jsx(A,{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:O!==null,onClick:d=>{d.stopPropagation(),F("cherryPick")},children:V("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>{d.stopPropagation(),F("revert")},children:V("gitView.history.actions.revert")}),t.jsxs(Bs,{children:[t.jsx(Ds,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>d.stopPropagation(),children:[O==="reset"?t.jsx(A,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.reset")]})}),t.jsx(Ms,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(d=>t.jsx(_n,{disabled:O!==null,onSelect:P=>{P.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:O!==null,onClick:d=>{d.stopPropagation(),F("merge")},children:V("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>{d.stopPropagation(),F("rebase")},children:V("gitView.history.actions.rebase")})]}):null,p?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(A,{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")})]}):x.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:x.map(d=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>g(d),className:Ce("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:Ce("font-semibold w-3 text-center shrink-0",si(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(A,{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 P=d.insertions+d.deletions;if(!T.has(d.path)&&P>fr)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:P})}),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:()=>{ee(J=>new Set(J).add(d.path)),oe(d)},children:V("gitView.history.renderDiffAnyway")})]});const M=B.get(d.path);return M==="loading"||M===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.loadingDiff")}):M==="error"?t.jsx("button",{type:"button",onClick:()=>g(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(za,{original:M.original,modified:M.modified,language:Hn(d.path)||"",fileName:d.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},d.path))})]})]})}),vr=["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 Kt(i){return vr[i%vr.length]}function ai(i){if(i.length===0)return[];const e=[],n=[];for(let u=0;u<i.length;u++){const j=i[u],f=[];for(let S=0;S<e.length;S++)e[S]===j.hash&&f.push(S);let x=f.length>0?f[0]:-1;if(x===-1){const S=e.indexOf(null);S!==-1?x=S:(x=e.length,e.push(null))}const p=f.slice(1),h=Kt(x),w=e[x]===j.hash,E=j.parents.length>0;E?e[x]=j.parents[0]:e[x]=null;const b=[],V=new Set;for(let S=1;S<j.parents.length;S++){const O=j.parents[S],C=e.indexOf(O);if(C!==-1)b.push(C);else{const y=e.indexOf(null);if(y!==-1)e[y]=O,b.push(y),V.add(y);else{const D=e.length;e.push(O),b.push(D),V.add(D)}}}const L=[];w&&E?L.push({fromLane:x,toLane:x,color:h,type:"commit-lane"}):w&&!E?L.push({fromLane:x,toLane:x,color:h,type:"top-stub"}):!w&&E&&L.push({fromLane:x,toLane:x,color:h,type:"bottom-stub"});for(const S of p)L.push({fromLane:S,toLane:x,color:Kt(S),type:"merge-in"}),e[S]=null;for(const S of b)L.push({fromLane:x,toLane:S,color:Kt(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==x&&(V.has(S)||L.push({fromLane:S,toLane:S,color:Kt(S),type:"passing"}));n.push({commit:j,lane:x,color:h,connectors:L})}return n}const ii=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],oi=i=>{const e=Ct.c(84),{mode:n,log:u,isLogLoading:j,logMaxCount:f,onLogMaxCountChange:x,expandedCommitHashes:p,onToggleCommit:h,commitFilesMap:w,loadingCommitHashes:E,onCopyHash:b,directory:V,showHeader:L,contentMaxHeightClassName:S,branchDivider:O,onConflict:C,onActionSuccess:y}=i,D=n===void 0?"history":n,k=L===void 0?!0:L,R=S===void 0?"max-h-[50vh]":S,I=O===void 0?null:O,{t:F}=et(),[r,Y]=l.useState(!0),B=D==="graph";let m;e[0]!==B||e[1]!==u?(m=B&&u?ai(u.all):[],e[0]=B,e[1]=u,e[2]=m):m=e[2];const T=m;let ee;e[3]!==T?(ee=Math.max(1,...T.map(li)),e[3]=T,e[4]=ee):ee=e[4];const $=ee;let G;e[5]!==T?(G=new Map(T.map(ci)),e[5]=T,e[6]=G):G=e[6];const _=G;if(!u)return null;const Z=I!==null&&I.insertBeforeIndex>0&&I.insertBeforeIndex<u.all.length,H=I!==null&&I.insertBeforeIndex===u.all.length,ce=Z||H;let ie;e[7]!==I||e[8]!==Z||e[9]!==H||e[10]!==u.all?(ie=Z?u.all.slice(0,I.insertBeforeIndex):H?u.all:[],e[7]=I,e[8]=Z,e[9]=H,e[10]=u.all,e[11]=ie):ie=e[11];const de=ie;let oe;if(e[12]!==I||e[13]!==w||e[14]!==R||e[15]!==V||e[16]!==p||e[17]!==Z||e[18]!==ce||e[19]!==B||e[20]!==j||e[21]!==_||e[22]!==E||e[23]!==u.all||e[24]!==f||e[25]!==$||e[26]!==D||e[27]!==y||e[28]!==C||e[29]!==b||e[30]!==x||e[31]!==h||e[32]!==F||e[33]!==de){const se=Z?u.all.slice(I.insertBeforeIndex):[];let Q;e[35]!==I?.direction?(Q=I?.direction==="down"?t.jsx(A,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(A,{name:"arrow-up",className:"size-3.5"}),e[35]=I?.direction,e[36]=Q):Q=e[36];const Ne=Q;let ve;e[37]!==w||e[38]!==V||e[39]!==p||e[40]!==B||e[41]!==_||e[42]!==E||e[43]!==$||e[44]!==D||e[45]!==y||e[46]!==C||e[47]!==b||e[48]!==h?(ve=Fe=>t.jsx("ul",{className:"divide-y divide-border/60",children:Fe.map(ue=>t.jsx(ni,{entry:ue,mode:D,laned:B?_.get(ue.hash):void 0,totalLanes:B?$:void 0,isExpanded:p.has(ue.hash),onToggle:()=>h(ue.hash),files:w.get(ue.hash)??[],isLoadingFiles:E.has(ue.hash),onCopyHash:b,directory:V,onConflict:C,onActionSuccess:y},ue.hash))}),e[37]=w,e[38]=V,e[39]=p,e[40]=B,e[41]=_,e[42]=E,e[43]=$,e[44]=D,e[45]=y,e[46]=C,e[47]=b,e[48]=h,e[49]=ve):ve=e[49];const me=ve;let he;e[50]!==j||e[51]!==u.all.length||e[52]!==f||e[53]!==x||e[54]!==F?(he=u.all.length>=f?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(W,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(f+25),disabled:j,className:"px-3 text-muted-foreground hover:text-foreground",children:j?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(A,{name:"loader-4",className:"size-3 animate-spin"}),F("gitView.history.loadingMore")]}):F("gitView.history.loadMore")})}):null,e[50]=j,e[51]=u.all.length,e[52]=f,e[53]=x,e[54]=F,e[55]=he):he=e[55];const Pe=he;oe=t.jsx(Sr,{outerClassName:`min-h-0 ${R}`,className:"h-full w-full",children:u.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")})}):ce&&I?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[de.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(de)}):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:I.branchName,children:I.branchName}),Ne]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),se.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(se)}):null]}),Pe]}):t.jsxs(t.Fragment,{children:[me(u.all),Pe]})}),e[12]=I,e[13]=w,e[14]=R,e[15]=V,e[16]=p,e[17]=Z,e[18]=ce,e[19]=B,e[20]=j,e[21]=_,e[22]=E,e[23]=u.all,e[24]=f,e[25]=$,e[26]=D,e[27]=y,e[28]=C,e[29]=b,e[30]=x,e[31]=h,e[32]=F,e[33]=de,e[34]=oe}else oe=e[34];const g=oe;if(!k){if(ce){let Q;return e[56]!==g?(Q=t.jsx("section",{className:"h-full min-h-0",children:g}),e[56]=g,e[57]=Q):Q=e[57],Q}let se;return e[58]!==g?(se=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:g}),e[58]=g,e[59]=se):se=e[59],se}let d;e[60]!==F?(d=F("gitView.history.title"),e[60]=F,e[61]=d):d=e[61];let P;e[62]!==d?(P=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:d}),e[62]=d,e[63]=P):P=e[63];let M;e[64]!==j||e[65]!==r||e[66]!==f||e[67]!==x||e[68]!==F?(M=r&&t.jsx("div",{onClick:di,onPointerDown:ui,children:t.jsxs(Xn,{value:String(f),onValueChange:se=>x(Number(se)),disabled:j,children:[t.jsx(Zn,{size:"sm",className:"w-auto",disabled:j,children:t.jsx(ea,{placeholder:F("gitView.history.commitsPlaceholder")})}),t.jsx(ta,{children:ii.map(se=>t.jsx(sa,{value:String(se.value),children:F(se.labelKey)},se.value))})]})}),e[64]=j,e[65]=r,e[66]=f,e[67]=x,e[68]=F,e[69]=M):M=e[69];let J;e[70]!==r?(J=r?t.jsx(A,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(A,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=r,e[71]=J):J=e[71];let ae;e[72]!==M||e[73]!==J?(ae=t.jsxs("div",{className:"flex items-center gap-2",children:[M,J]}),e[72]=M,e[73]=J,e[74]=ae):ae=e[74];let te;e[75]!==P||e[76]!==ae?(te=t.jsxs(Ra,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[P,ae]}),e[75]=P,e[76]=ae,e[77]=te):te=e[77];let K;e[78]!==g?(K=t.jsx(Ba,{children:g}),e[78]=g,e[79]=K):K=e[79];let we;return e[80]!==r||e[81]!==te||e[82]!==K?(we=t.jsxs(Da,{open:r,onOpenChange:Y,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[te,K]}),e[80]=r,e[81]=te,e[82]=K,e[83]=we):we=e[83],we};function li(i){return i.lane+1}function ci(i){return[i.commit.hash,i]}function di(i){return i.stopPropagation()}function ui(i){return i.stopPropagation()}const mi=i=>{const e=Ct.c(148),{open:n,onOpenChange:u,conflictFiles:j,directory:f,operation:x,onAbort:p,onClearState:h}=i;let w;e[0]!==j?(w=j===void 0?[]:j,e[0]=j,e[1]=w):w=e[1];const E=w,{t:b}=et(),V=Ze(hi),L=Ze(gi),S=qt(fi),O=qt(pi),[C,y]=l.useState(!1),[D,k]=l.useState(null),[R,I]=l.useState(null);let F,r;e[2]!==f||e[3]!==n||e[4]!==b?(F=()=>{!n||!f||(y(!0),I(null),k(null),ra(f).then(X=>{k(X)}).catch(X=>{const pe=X instanceof Error?X.message:b("gitView.conflict.loadFailed");I(pe)}).finally(()=>{y(!1)}))},r=[n,f,b],e[2]=f,e[3]=n,e[4]=b,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]!==x?(Y=async()=>{if(!D)return null;const X=x==="merge"?"merge":"rebase",pe=D.headInfo||(x==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Re=x==="merge"?"git commit --no-edit":"git rebase --continue",Ve=await Jt("git.conflict.resolve.visible",{operation_label:X,head_ref:pe}),je=await Jt("git.conflict.resolve.instructions",{operation_label:X,directory:f,operation:x,head_info:D.headInfo||"N/A",continue_cmd:Re}),le=`${X} 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:Ve,instructionsText:je,payloadText:le}},e[7]=D,e[8]=f,e[9]=x,e[10]=Y):Y=e[10];const B=Y;let m;e[11]!==p||e[12]!==u?(m=()=>{p(),u(!1)},e[11]=p,e[12]=u,e[13]=m):m=e[13];const T=m;let ee;e[14]!==h||e[15]!==u?(ee=()=>{h?.(),u(!1)},e[14]=h,e[15]=u,e[16]=ee):ee=e[16];const $=ee;let G;e[17]!==B||e[18]!==L||e[19]!==h||e[20]!==u||e[21]!==S||e[22]!==O||e[23]!==b?(G=async()=>{const X=await B();if(!X){v.error(b("gitView.conflict.noDetailsAvailable"));return}if(!L){v.error(b("gitView.conflict.noActiveSession"),{description:b("gitView.conflict.noActiveSessionDescription")});return}S(X.visibleText,"replace"),O([{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]),h?.(),u(!1)},e[17]=B,e[18]=L,e[19]=h,e[20]=u,e[21]=S,e[22]=O,e[23]=b,e[24]=G):G=e[24];const _=G;let Z;e[25]!==B||e[26]!==f||e[27]!==h||e[28]!==u||e[29]!==V||e[30]!==b?(Z=async()=>{const X=await B();if(!X){v.error(b("gitView.conflict.noDetailsAvailable"));return}V({directoryOverride:f,initialPrompt:X.visibleText,syntheticParts:[{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]}),h?.(),u(!1)},e[25]=B,e[26]=f,e[27]=h,e[28]=u,e[29]=V,e[30]=b,e[31]=Z):Z=e[31];const H=Z;let ce,ie,de,oe,g,d,P,M,J,ae,te,K,we,se,Q,Ne,ve,me,he,Pe,Fe,ue;if(e[32]!==D||e[33]!==E||e[34]!==L||e[35]!==T||e[36]!==$||e[37]!==_||e[38]!==H||e[39]!==C||e[40]!==R||e[41]!==u||e[42]!==n||e[43]!==x||e[44]!==b){const X=b(x==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),pe=D?.unmergedFiles||E;de=ht,Fe=n,ue=u,ie=gt,Pe="max-w-md w-[calc(100vw-2rem)]",se="flex flex-col gap-4 overflow-hidden";let Re;e[67]===Symbol.for("react.memo_cache_sentinel")?(Re=t.jsx(A,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[67]=Re):Re=e[67];const Ve=t.jsxs("div",{className:"flex items-center gap-2",children:[Re,t.jsx(pt,{children:b("gitView.conflict.detectedTitle",{operation:X})})]});let je;e[68]!==x||e[69]!==b?(je=b("gitView.conflict.detectedDescription",{operation:x}),e[68]=x,e[69]=b,e[70]=je):je=e[70];let le;e[71]!==je?(le=t.jsx(bt,{children:je}),e[71]=je,e[72]=le):le=e[72],e[73]!==Ve||e[74]!==le?(Q=t.jsxs(ft,{children:[Ve,le]}),e[73]=Ve,e[74]=le,e[75]=Q):Q=e[75],e[76]!==C||e[77]!==b?(Ne=C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:b("gitView.conflict.loading")})]}),e[76]=C,e[77]=b,e[78]=Ne):Ne=e[78],e[79]!==R||e[80]!==b?(ve=R&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:b("gitView.conflict.errorLoadingDetails",{message:R})}),e[79]=R,e[80]=b,e[81]=ve):ve=e[81],e[82]!==pe||e[83]!==b?(me=pe.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:pe.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:pe.map(xi)})})]}),e[82]=pe,e[83]=b,e[84]=me):me=e[84],e[85]!==D||e[86]!==b?(he=D?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("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]=b,e[87]=he):he=e[87],te="flex flex-col gap-2 pt-2";let Be;e[88]!==H?(Be=()=>{H()},e[88]=H,e[89]=Be):Be=e[89];const _e=C||!D;let Le;e[90]!==C?(Le=C?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"add",className:"size-4"}),e[90]=C,e[91]=Le):Le=e[91];let Ee;e[92]!==b?(Ee=b("gitView.conflict.resolveNewSession"),e[92]=b,e[93]=Ee):Ee=e[93],e[94]!==Be||e[95]!==_e||e[96]!==Le||e[97]!==Ee?(K=t.jsxs(W,{variant:"default",onClick:Be,disabled:_e,className:"w-full gap-2",children:[Le,Ee]}),e[94]=Be,e[95]=_e,e[96]=Le,e[97]=Ee,e[98]=K):K=e[98];let De;e[99]!==_?(De=()=>{_()},e[99]=_,e[100]=De):De=e[100];const Te=C||!D||!L;let Ie;e[101]!==C?(Ie=C?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"chat-1",className:"size-4"}),e[101]=C,e[102]=Ie):Ie=e[102];let q;e[103]!==b?(q=b("gitView.conflict.resolveCurrentSession"),e[103]=b,e[104]=q):q=e[104],e[105]!==De||e[106]!==Te||e[107]!==Ie||e[108]!==q?(we=t.jsxs(W,{variant:"outline",onClick:De,disabled:Te,className:"w-full gap-2",children:[Ie,q]}),e[105]=De,e[106]=Te,e[107]=Ie,e[108]=q,e[109]=we):we=e[109],J="flex gap-2 pt-1";let xe;e[110]!==b?(xe=b("gitView.conflict.continueLater"),e[110]=b,e[111]=xe):xe=e[111],e[112]!==$||e[113]!==xe?(ae=t.jsx(W,{variant:"ghost",size:"sm",onClick:$,className:"flex-1",children:xe}),e[112]=$,e[113]=xe,e[114]=ae):ae=e[114],ce=W,oe="destructive",g="sm",d=T,P="flex-1",M=b("gitView.conflict.abortOperation",{operation:X}),e[32]=D,e[33]=E,e[34]=L,e[35]=T,e[36]=$,e[37]=_,e[38]=H,e[39]=C,e[40]=R,e[41]=u,e[42]=n,e[43]=x,e[44]=b,e[45]=ce,e[46]=ie,e[47]=de,e[48]=oe,e[49]=g,e[50]=d,e[51]=P,e[52]=M,e[53]=J,e[54]=ae,e[55]=te,e[56]=K,e[57]=we,e[58]=se,e[59]=Q,e[60]=Ne,e[61]=ve,e[62]=me,e[63]=he,e[64]=Pe,e[65]=Fe,e[66]=ue}else ce=e[45],ie=e[46],de=e[47],oe=e[48],g=e[49],d=e[50],P=e[51],M=e[52],J=e[53],ae=e[54],te=e[55],K=e[56],we=e[57],se=e[58],Q=e[59],Ne=e[60],ve=e[61],me=e[62],he=e[63],Pe=e[64],Fe=e[65],ue=e[66];let qe;e[115]!==ce||e[116]!==oe||e[117]!==g||e[118]!==d||e[119]!==P||e[120]!==M?(qe=t.jsx(ce,{variant:oe,size:g,onClick:d,className:P,children:M}),e[115]=ce,e[116]=oe,e[117]=g,e[118]=d,e[119]=P,e[120]=M,e[121]=qe):qe=e[121];let Ye;e[122]!==J||e[123]!==ae||e[124]!==qe?(Ye=t.jsxs("div",{className:J,children:[ae,qe]}),e[122]=J,e[123]=ae,e[124]=qe,e[125]=Ye):Ye=e[125];let ge;e[126]!==te||e[127]!==K||e[128]!==we||e[129]!==Ye?(ge=t.jsxs("div",{className:te,children:[K,we,Ye]}),e[126]=te,e[127]=K,e[128]=we,e[129]=Ye,e[130]=ge):ge=e[130];let fe;e[131]!==se||e[132]!==Q||e[133]!==Ne||e[134]!==ve||e[135]!==me||e[136]!==he||e[137]!==ge?(fe=t.jsxs("div",{className:se,children:[Q,Ne,ve,me,he,ge]}),e[131]=se,e[132]=Q,e[133]=Ne,e[134]=ve,e[135]=me,e[136]=he,e[137]=ge,e[138]=fe):fe=e[138];let Se;e[139]!==ie||e[140]!==Pe||e[141]!==fe?(Se=t.jsx(ie,{className:Pe,children:fe}),e[139]=ie,e[140]=Pe,e[141]=fe,e[142]=Se):Se=e[142];let ke;return e[143]!==de||e[144]!==Fe||e[145]!==ue||e[146]!==Se?(ke=t.jsx(de,{open:Fe,onOpenChange:ue,children:Se}),e[143]=de,e[144]=Fe,e[145]=ue,e[146]=Se,e[147]=ke):ke=e[147],ke};function hi(i){return i.openNewSessionDraft}function gi(i){return i.currentSessionId}function fi(i){return i.setPendingInputText}function pi(i){return i.setPendingSyntheticParts}function xi(i){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:i,children:i},i)}const wi=({open:i,onOpenChange:e,operation:n,targetBranch:u,onConfirm:j})=>{const{t:f}=et(),[x,p]=l.useState(!0),[h,w]=l.useState(!1),E=f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),b=async()=>{w(!0);try{await j(x),e(!1)}catch(L){const S=L instanceof Error?L.message:`Failed to ${n}`;v.error(S)}finally{w(!1)}},V=()=>{h||e(!1)};return t.jsx(ht,{open:i,onOpenChange:h?void 0:e,children:t.jsxs(gt,{className:"max-w-md",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(pt,{children:f("gitView.stash.title")})]}),t.jsx(bt,{children:f("gitView.stash.description",{operation:n})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(n==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:u})]}),x&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(na,{checked:x,onChange:p,disabled:h,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!h&&p(!x),children:f("gitView.stash.restoreAfterOperation",{operation:n})})]}),t.jsxs(Rs,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:V,disabled:h,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:b,disabled:h,className:"gap-1.5",children:h?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:E})})]})]})})},yi=({mergeInProgress:i,rebaseInProgress:e,onContinue:n,onAbort:u,onResolveWithAI:j,conflictCount:f=0,isLoading:x=!1})=>{const{t:p}=et(),[h,w]=l.useState(null),E=i&&i.head,b=e&&(e.headName||e.onto),V=E?"merge":b?"rebase":null;if(!V)return null;const L=async()=>{w("continue");try{await n()}finally{w(null)}},S=async()=>{w("abort");try{await u()}finally{w(null)}},O=h!==null,C=f>0,y=p(V==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let D="";i?D=i.message?p("gitView.operation.mergingMessage",{message:i.message}):p("gitView.operation.mergeInProgressWithHead",{head:i.head}):e&&(D=e.headName?p("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):p("gitView.operation.rebaseInProgress"));const k=C?f===1?p("gitView.operation.inProgressTitleOneConflict",{operation:y,count:f}):p("gitView.operation.inProgressTitleManyConflicts",{operation:y,count:f}):p("gitView.operation.inProgressTitle",{operation:y}),R=p(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:O||x,className:"gap-1.5",children:[h==="abort"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"close",className:"size-4"}),p("gitView.operation.abort")]}),C?j&&t.jsx(W,{variant:"default",size:"sm",onClick:j,disabled:O||x,children:p("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:L,disabled:O||x,className:"gap-1.5",children:[h==="continue"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"check",className:"size-4"}),p("gitView.operation.continue")]})]})]})]})})},bi=i=>{const e=Ct.c(104),{currentBranch:n,localBranches:u,remoteBranches:j,onMerge:f,onRebase:x,disabled:p,isOperating:h,operationLogs:w,onOperationComplete:E,mode:b,defaultTargetBranch:V}=i,L=p===void 0?!1:p,S=h===void 0?!1:h,O=w===void 0?[]:w,C=b===void 0?"dialog":b,{t:y}=et(),[D,k]=l.useState(!1),[R,I]=l.useState("merge"),[F,r]=l.useState(null),[Y,B]=l.useState(!1),[m,T]=l.useState(""),ee=l.useRef(null),$=l.useRef(null),G=L||S,_=n||y("gitView.branch.currentBranchFallback"),Z=O.length>0&&O.every(vi),H=O.some(ji);let ce;e[0]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{$.current&&($.current.scrollTop=$.current.scrollHeight)},e[0]=ce):ce=e[0],l.useEffect(ce,[O]);let ie;e[1]!==j?(ie=new Set(j.map(Ci).filter(Boolean)),e[1]=j,e[2]=ie):ie=e[2];const de=ie;let oe;if(e[3]!==m||e[4]!==n||e[5]!==u||e[6]!==de){let q;e[8]!==n||e[9]!==de?(q=Ae=>Ae!==n&&!de.has(Ae),e[8]=n,e[9]=de,e[10]=q):q=e[10];const xe=u.filter(q);oe=Rt(xe,m,Ni),e[3]=m,e[4]=n,e[5]=u,e[6]=de,e[7]=oe}else oe=e[7];const g=oe;let d;e[11]!==m||e[12]!==j?(d=Rt(j,m,Si),e[11]=m,e[12]=j,e[13]=d):d=e[13];const P=d;let M;e[14]!==V||e[15]!==u||e[16]!==j?(M=()=>V&&(j.includes(V)||u.includes(V))?V:null,e[14]=V,e[15]=u,e[16]=j,e[17]=M):M=e[17];const J=M;let ae;e[18]!==J||e[19]!==k?(ae=()=>{k(!0),r(J()),I("merge"),T("")},e[18]=J,e[19]=k,e[20]=ae):ae=e[20];const te=ae;let K;e[21]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{r(q),B(!1),T("")},e[21]=K):K=e[21];const we=K;let se;e[22]!==f||e[23]!==x||e[24]!==R||e[25]!==F?(se=()=>{F&&(R==="merge"?f(F):x(F))},e[22]=f,e[23]=x,e[24]=R,e[25]=F,e[26]=se):se=e[26];const Q=se;let Ne;e[27]!==S||e[28]!==k?(Ne=()=>{S||(r(null),I("merge"),T(""),k(!1))},e[27]=S,e[28]=k,e[29]=Ne):Ne=e[29];const ve=Ne,me=()=>{S&&!Z||(Z&&E?.(),r(null),I("merge"),T(""),k(!1))};let he,Pe;e[30]!==Y?(he=()=>{Y||T("")},Pe=[Y],e[30]=Y,e[31]=he,e[32]=Pe):(he=e[31],Pe=e[32]),l.useEffect(he,Pe);let Fe,ue;e[33]!==C||e[34]!==J||e[35]!==F?(Fe=()=>{C==="dialog"||F||r(J())},ue=[C,J,F],e[33]=C,e[34]=J,e[35]=F,e[36]=Fe,e[37]=ue):(Fe=e[36],ue=e[37]),l.useEffect(Fe,ue);const ge=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:$,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:O.map(ki)})}),Z?C==="dialog"?t.jsx(Rs,{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:()=>I("merge"),className:Ce("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"git-merge",className:Ce("size-4",R==="merge"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Ce("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:()=>I("rebase"),className:Ce("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"git-branch",className:Ce("size-4",R==="rebase"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Ce("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(Bs,{open:Y,onOpenChange:B,modal:!1,children:[t.jsx(Ds,{asChild:!0,children:t.jsxs("button",{type:"button",className:Ce(Nr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Ce("truncate",!F&&"text-muted-foreground"),children:F||y("gitView.branch.selectBranch")}),t.jsx(A,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Ms,{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(Es,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Ts,{ref:ee,placeholder:y("gitView.branch.searchPlaceholder"),value:m,onValueChange:T,onKeyDown:Vi}),t.jsxs(As,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Ls,{children:y("gitView.branch.empty")}),g.length>0&&t.jsx(Yt,{heading:y("gitView.branch.localBranches"),children:g.map(q=>t.jsx(Qt,{onSelect:()=>we(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`local-${q}`))}),g.length>0&&P.length>0?t.jsx(aa,{}):null,P.length>0&&t.jsx(Yt,{heading:y("gitView.branch.remoteBranches"),children:P.map(q=>t.jsx(Qt,{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(Rs,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:ve,children:y("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:Q,disabled:!F,className:"gap-1.5",children:R==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"git-merge",className:"size-4"}),y("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(A,{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:ve,disabled:G,children:y("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:Q,disabled:G||!F,children:y(R==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(C==="bare")return ge;if(C==="inline"){let q;e[38]!==y?(q=y("gitView.branch.updateTitle"),e[38]=y,e[39]=q):q=e[39];let xe;e[40]!==q?(xe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:q}),e[40]=q,e[41]=xe):xe=e[41];let Ae;e[42]!==y?(Ae=y("gitView.branch.updateDescriptionPrefix"),e[42]=y,e[43]=Ae):Ae=e[43];let Ge;e[44]!==_?(Ge=t.jsx("span",{className:"font-mono text-foreground",children:_}),e[44]=_,e[45]=Ge):Ge=e[45];let tt;e[46]!==Ae||e[47]!==Ge?(tt=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Ae," ",Ge,"."]}),e[46]=Ae,e[47]=Ge,e[48]=tt):tt=e[48];let nt;e[49]!==xe||e[50]!==tt?(nt=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[xe,tt]})}),e[49]=xe,e[50]=tt,e[51]=nt):nt=e[51];let at;e[52]!==ge?(at=t.jsx("div",{className:"pt-3",children:ge}),e[52]=ge,e[53]=at):at=e[53];let it;return e[54]!==nt||e[55]!==at?(it=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[nt,at]}),e[54]=nt,e[55]=at,e[56]=it):it=e[56],it}let fe;e[57]!==S?(fe=S?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"git-merge",className:"size-4"}),e[57]=S,e[58]=fe):fe=e[58];let Se;e[59]!==y?(Se=y("gitView.branch.mergeRebase"),e[59]=y,e[60]=Se):Se=e[60];let ke;e[61]!==Se?(ke=t.jsx("span",{children:Se}),e[61]=Se,e[62]=ke):ke=e[62];let X;e[63]!==te||e[64]!==G||e[65]!==fe||e[66]!==ke?(X=t.jsx(Zt,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:te,disabled:G,children:[fe,ke]})}),e[63]=te,e[64]=G,e[65]=fe,e[66]=ke,e[67]=X):X=e[67];let pe;e[68]!==y?(pe=y("gitView.branch.mergeRebaseTooltip"),e[68]=y,e[69]=pe):pe=e[69];let Re;e[70]!==pe?(Re=t.jsx(es,{sideOffset:8,children:pe}),e[70]=pe,e[71]=Re):Re=e[71];let Ve;e[72]!==X||e[73]!==Re?(Ve=t.jsxs(Xt,{children:[X,Re]}),e[72]=X,e[73]=Re,e[74]=Ve):Ve=e[74];let je;e[75]!==me||e[76]!==k?(je=q=>{q?k(!0):me()},e[75]=me,e[76]=k,e[77]=je):je=e[77];let le;e[78]!==y?(le=y("gitView.branch.updateTitle"),e[78]=y,e[79]=le):le=e[79];let Be;e[80]!==le?(Be=t.jsx(pt,{children:le}),e[80]=le,e[81]=Be):Be=e[81];let _e;e[82]!==H||e[83]!==S||e[84]!==R||e[85]!==Z||e[86]!==y||e[87]!==_?(_e=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]=_e):_e=e[88];let Le;e[89]!==_e?(Le=t.jsx(bt,{children:_e}),e[89]=_e,e[90]=Le):Le=e[90];let Ee;e[91]!==Be||e[92]!==Le?(Ee=t.jsxs(ft,{children:[Be,Le]}),e[91]=Be,e[92]=Le,e[93]=Ee):Ee=e[93];let De;e[94]!==ge||e[95]!==Ee?(De=t.jsxs(gt,{className:"max-w-md",children:[Ee,ge]}),e[94]=ge,e[95]=Ee,e[96]=De):De=e[96];let Te;e[97]!==D||e[98]!==je||e[99]!==De?(Te=t.jsx(ht,{open:D,onOpenChange:je,children:De}),e[97]=D,e[98]=je,e[99]=De,e[100]=Te):Te=e[100];let Ie;return e[101]!==Ve||e[102]!==Te?(Ie=t.jsxs(t.Fragment,{children:[Ve,Te]}),e[101]=Ve,e[102]=Te,e[103]=Ie):Ie=e[103],Ie};function vi(i){return i.status==="done"||i.status==="error"}function ji(i){return i.status==="error"}function Ci(i){return i.slice(i.indexOf("/")+1)}function Ni(i){return[i]}function Si(i){return[i]}function ki(i,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[i.status==="running"&&t.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),i.status==="done"&&t.jsx(A,{name:"check",className:"size-3.5 text-success"}),i.status==="error"&&t.jsx(A,{name:"close",className:"size-3.5 text-destructive"}),i.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Ce("typography-micro",i.status==="error"&&"text-destructive",i.status==="done"&&"text-muted-foreground",i.status==="running"&&"text-foreground",i.status==="pending"&&"text-muted-foreground/60"),children:i.message})]},e)}function Vi(i){return i.stopPropagation()}const Ii=({runMutation:i,onMutationComplete:e,onMutationError:n,onPathsComplete:u,scheduleFlush:j})=>{const f=[];let x=!1;return{enqueue:h=>{const w=f[f.length-1];if(w?.directory===h.directory&&w.direction===h.direction){h.paths.forEach(E=>w.paths.add(E));return}f.push(h)},flush:()=>{if(x)return;const h=f.shift();if(!h)return;x=!0;const w={directory:h.directory,direction:h.direction,paths:Array.from(h.paths),rollback:h.rollback};(async()=>{try{await i(w),e(w)}catch(E){n(w,E)}finally{u(w.paths),x=!1,f.length>0&&j()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>x}},Pi=15e3,Fi=40,Ri=20,jr={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:"},Bi=(i,e)=>{const n=i.toLowerCase(),u=/^([a-z]+)(?:\(.*\))?!?:/,j=n.match(u);if(j){const p=j[1],h=jr[p];if(h)return e.find(w=>w.code===h)||null}const f=n.split(" ")[0],x=jr[f];return x&&e.find(p=>p.code===x)||null},Di=20,yt=new Map,Mi=(i,e)=>{if(yt.delete(i),yt.set(i,e),yt.size>Di){const n=yt.keys().next().value;n!==void 0&&yt.delete(n)}},rt=i=>(i||"").replace(/\\/g,"/").replace(/\/+$/,""),Cr=i=>{const e=i.index?.trim();return!!(e&&e!=="?")},Ei=i=>{const e=i.working_dir?.trim(),n=i.index?.trim();return!!(e||n==="?")},Xl=({isActive:i})=>{const{t:e}=et(),{git:n}=ia(),u=oa(),[j,f]=l.useState(null),[x,p]=l.useState(!1),h=Ze(s=>s.currentSessionId),w=Ze(s=>s.newSessionDraft),E=Ze(s=>s.setDraftBootstrapPendingDirectory),b=Ze(s=>s.worktreeMetadata),V=Ze(s=>s.availableWorktrees),L=rt(u),S=l.useMemo(()=>{if(!L)return;const s=V.find(a=>rt(a.path)===L);if(s)return s;for(const a of b.values())if(rt(a.path)===L)return a},[V,L,b]),O=l.useMemo(()=>{if(h)return b.get(h)??S;if(w?.open)return S},[h,S,w?.open,b]),{profiles:C,globalIdentity:y,defaultGitIdentityId:D,loadProfiles:k,loadGlobalIdentity:R,loadDefaultGitIdentityId:I}=Ma(ur(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}=la(u??null,{enabled:i}),B=ca(r??null),m=da(r??null),T=ua(s=>h?s.getAttachment(h):void 0),ee=T?ma(T):[],$=T&&!T.degraded&&!T.legacy?T.worktreeRoot??void 0:void 0,G=Ia(u,O,m?.current??void 0),_=ha(r??null),Z=ga(r??null),H=fa(r??null),ce=pa(r??null),ie=xa(r??null),{setActiveDirectory:de,fetchAll:oe,ensureAll:g,fetchStatus:d,fetchBranches:P,fetchLog:M,setLogMaxCount:J,fetchIdentity:ae,prefetchDiffs:te,clearDiffCache:K,moveStatusPathsOptimistically:we,restoreStatus:se,bumpIndexRevision:Q,ensureNestedRepos:Ne,selectNestedRepo:ve}=wa(ur(s=>({setActiveDirectory:s.setActiveDirectory,fetchAll:s.fetchAll,ensureAll:s.ensureAll,fetchStatus:s.fetchStatus,fetchBranches:s.fetchBranches,fetchLog:s.fetchLog,setLogMaxCount:s.setLogMaxCount,fetchIdentity:s.fetchIdentity,prefetchDiffs:s.prefetchDiffs,clearDiffCache:s.clearDiffCache,moveStatusPathsOptimistically:s.moveStatusPathsOptimistically,restoreStatus:s.restoreStatus,bumpIndexRevision:s.bumpIndexRevision,ensureNestedRepos:s.ensureNestedRepos,selectNestedRepo:s.selectNestedRepo}))),me=Pt(s=>s.isMobile),he=Pt(s=>s.openContextDiff),Pe=Pt(s=>s.openContextSurface),Fe=m?.current??null,ue=ya(s=>!r||!Fe?null:ba(s.entries,r,Fe)),qe=Pt(s=>s.navigateToDiff),Ye=l.useRef(null),ge=l.useRef(null),fe=l.useRef(null),Se=l.useRef(null),ke=l.useRef(!0);l.useEffect(()=>()=>{ke.current=!1},[]);const X=l.useCallback(()=>{ge.current!==null&&(window.clearTimeout(ge.current),ge.current=null)},[]),pe=l.useCallback(s=>{X(),ge.current=window.setTimeout(()=>{ge.current=null,rt(s)===rt(r)&&d(s,n,{silent:!0})},Pi)},[X,r,d,n]);l.useEffect(()=>X,[X]);const Re=l.useCallback(()=>{fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null)},[]),Ve=l.useCallback(()=>{fe.current===null&&(fe.current=window.setTimeout(()=>{fe.current=null,Se.current?.()},0))},[]),je=l.useCallback(async(s,a,o)=>{if(a==="stage"){if(n.stageGitFiles){await n.stageGitFiles(s,o);return}await Promise.all(o.map(c=>n.stageGitFile(s,c)));return}if(n.unstageGitFiles){await n.unstageGitFiles(s,o);return}await Promise.all(o.map(c=>n.unstageGitFile(s,c)))},[n]),le=l.useMemo(()=>Ii({runMutation:({directory:s,direction:a,paths:o})=>je(s,a,o),onMutationComplete:({directory:s})=>{Q(s),pe(s)},onMutationError:({directory:s,direction:a,rollback:o},c)=>{o?.(),Q(s),pe(s);const N=e(a==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");v.error(c instanceof Error?c.message:N)},onPathsComplete:s=>{Ws(a=>{const o=new Set(a);return s.forEach(c=>o.delete(c)),o})},scheduleFlush:Ve}),[Q,je,Ve,pe,e]);l.useEffect(()=>(Se.current=le.flush,()=>{Se.current=null}),[le]),l.useEffect(()=>()=>le.clear(),[le]),l.useEffect(()=>Re,[Re]),l.useEffect(()=>{if(!i)return;if(!u){f(null),p(!1);return}let s=!1,a=null;const o=async()=>{try{const c=await Va(u);if(s)return;f(c.status),c.status==="pending"&&(a=window.setTimeout(()=>{o()},500))}catch{s||f(null)}};return o(),()=>{s=!0,a!==null&&window.clearTimeout(a)}},[i,u]),l.useEffect(()=>{const s=Ye.current;Ye.current=j,!(!u||!n)&&(s==="pending"&&j==="ready"&&(p(!0),oe(u,n).finally(()=>{window.setTimeout(()=>{p(!1)},1200)})),j==="failed"&&(E(null),p(!1)))},[u,oe,n,E,j]);const Be=rt(w?.bootstrapPendingDirectory??null),_e=!!(u&&Be&&Be===rt(u)),Ee=!!(u&&(j==="pending"||_e))||x,De=l.useMemo(()=>r?yt.get(r)??null:null,[r]),Te=va(s=>s.settingsGitmojiEnabled),[Ie,q]=l.useState(null),{gitmojis:xe}=$a(Te);l.useEffect(()=>{const s=$||G?.projectDirectory;if(!s){q(null);return}let a=!1;return ja(s).then(o=>{if(a)return;const c=o.trim();q(c&&c!=="HEAD"?c:null)}).catch(()=>{a||q(null)}),()=>{a=!0}},[$,G?.projectDirectory]);const[Ae,Ge]=l.useState(De?.commitMessage??""),[tt,nt]=l.useState([]),[at,it]=l.useState(!1),Os=l.useRef(null),[zs,Bt]=l.useState(null),[Pr,ts]=l.useState(!1),[Gs,_s]=l.useState(null),[Ue,Fr]=l.useState(25),[Rr,Hs]=l.useState(!1),{triggerFireworks:Br}=Pa(),$s=l.useRef(new Map),Dt=l.useRef(0),ss=l.useCallback(()=>{Dt.current+=1,ke.current&&Hs(!0)},[]),rs=l.useCallback(()=>{Dt.current=Math.max(0,Dt.current-1),ke.current&&Dt.current===0&&Hs(!1)},[]),[ns,Mt]=l.useState(new Set),[Dr,Ws]=l.useState(new Set),[as,Us]=l.useState(!1),[Mr,Er]=l.useState(0),[Tr,Ks]=l.useState(!1),[is,os]=l.useState(De?.generatedHighlights??[]),Ar=Dr.size>0||le.size()>0||le.isRunning(),Js=l.useCallback(()=>{const s=Os.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),ls=$||G?.projectDirectory||null,cs=m?.current||null,Lr=l.useMemo(()=>{const s=m?.tracking;return s?s.startsWith("origin/"):!0},[m?.tracking]),qs=l.useMemo(()=>{const s=G?.createdFromBranch,a=typeof s=="string"?s.trim():"",o=typeof m?.current=="string"?m.current.trim():"",c=typeof Ie=="string"?Ie.trim():"";return a?a===o&&a.startsWith("opencode/")&&c.length>0&&c!==a?c:a:c||o||"HEAD"},[G?.createdFromBranch,m,Ie]),Et=l.useCallback(()=>{os([])},[]),[ds,Or]=l.useState(new Set),[Tt,zr]=l.useState(new Map),[At,us]=l.useState(new Set),ms=l.useRef(Tt),St=l.useRef(At),[Gr,vt]=l.useState(null),[xt,hs]=l.useState(null),[Ys,Qs]=l.useState(""),[Me,Lt]=l.useState(null),[_r,Xs]=l.useState(!1),[Hr,Zs]=l.useState(!1),[gs,fs]=l.useState([]),[$r,er]=l.useState(null),[tr,ps]=l.useState(null),[Wr,Ot]=l.useState([]),[Ur,Ke]=l.useState(!1),[Kr,Qe]=l.useState([]),[zt,Xe]=l.useState("merge"),[Jr,xs]=l.useState(null),[ws,sr]=l.useState(!1),[ys,qr]=l.useState(100),[Yr,Qr]=l.useState(0),Je=l.useMemo(()=>h?`openchamber.conflict:${h}`:null,[h]),st=l.useCallback((s,a,o)=>{if(!Je||typeof window>"u")return;const c={directory:s,conflictFiles:a,operation:o};window.localStorage.setItem(Je,JSON.stringify(c))},[Je]),He=l.useCallback(()=>{!Je||typeof window>"u"||window.localStorage.removeItem(Je)},[Je]);l.useEffect(()=>{if(!Je||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Je);if(s)try{const a=JSON.parse(s);if(a.directory!==r){window.localStorage.removeItem(Je);return}Qe(a.conflictFiles??[]),Xe(a.operation??"merge"),Ke(!0)}catch{window.localStorage.removeItem(Je)}},[Je,r]);const[Xr,bs]=l.useState(!1),[vs,rr]=l.useState("merge"),[js,nr]=l.useState(""),Zr=l.useCallback(s=>{Ca(s).then(a=>{if(a.ok){v.success(e("gitView.toast.commitHashCopied"));return}v.error(e("gitView.toast.copyFailed"))})},[e]),en=l.useCallback(s=>{Or(a=>{const o=new Set(a);return o.has(s)?o.delete(s):o.add(s),o})},[]);l.useEffect(()=>{ms.current=Tt},[Tt]),l.useEffect(()=>{St.current=At},[At]),l.useEffect(()=>{if(!r||!n)return;const s=Array.from(ds).filter(o=>!ms.current.has(o)&&!St.current.has(o));if(s.length===0)return;let a=!1;return us(o=>{const c=new Set(o);for(const N of s)c.add(N);return St.current=c,c}),Promise.all(s.map(o=>n.getCommitFiles(r,o).then(c=>({hash:o,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:o,files:[]})))).then(o=>{a||(zr(c=>{const N=new Map(c);for(const{hash:z,files:ne}of o)N.set(z,ne);return ms.current=N,N}),us(c=>{const N=new Set(c);for(const{hash:z}of o)N.delete(z);return St.current=N,N}))}),()=>{a=!0,us(o=>{let c=!1;const N=new Set(o);for(const z of s)N.delete(z)&&(c=!0);return c?(St.current=N,N):o})}},[ds,r,n]),l.useEffect(()=>{if(!r)return;const s=yt.get(r)??null;Ge(s?.commitMessage??""),os(s?.generatedHighlights??[])},[r]),l.useEffect(()=>{r&&Mi(r,{directory:r,commitMessage:Ae,generatedHighlights:is})},[Ae,r,is]),l.useEffect(()=>{i&&(k(),R(),I())},[i,k,R,I]),l.useEffect(()=>{if(!i)return;if(!r||!n?.getRemoteUrl||B!==!0){hs(null);return}let s=!1;return n.getRemoteUrl(r).then(a=>{s||hs(a)}).catch(()=>{s||hs(null)}),()=>{s=!0}},[i,r,n,B]);const Gt=l.useCallback(async()=>{if(!r||!n?.getRemotes||B!==!0){fs([]);return}try{const s=await n.getRemotes(r);ke.current&&fs(s)}catch{ke.current&&fs([])}},[r,n,B]);l.useEffect(()=>{i&&Gt()},[i,Gt]),l.useEffect(()=>{i&&u&&r&&(de(u),g(r,n))},[i,u,r,de,g,n]),l.useEffect(()=>{if(i&&r)return Na.onGitRefreshHint(s=>{rt(s.directory)===rt(r)&&(s.paths?.length&&K(r,s.paths),d(r,n,{silent:!0}))})},[i,K,r,d,n]);const re=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([d(r,n),P(r,n)])}catch(a){if(s){const o=a instanceof Error?a.message:e("gitView.toast.refreshRepositoryFailed");v.error(o)}}},[r,n,d,P,e]),ye=l.useCallback(async()=>{r&&await M(r,n,Ue)},[r,n,M,Ue]),Cs=l.useCallback(async()=>{r&&await ae(r,n)},[r,n,ae]);l.useEffect(()=>{if(!i||!r||!n?.hasLocalIdentity||B!==!0)return;const s=typeof D=="string"?D.trim():"";if(!s||s==="global"||$s.current.get(r)===s)return;let o=!1;return(async()=>{try{const N=await n.hasLocalIdentity?.(r);if(o||N===!0)return;ss(),await n.setGitIdentity(r,s),$s.current.set(r,s),await Cs()}catch(N){console.warn("Failed to auto-apply default git identity:",N)}finally{o||rs()}})(),()=>{o=!0}},[i,ss,r,D,rs,n,B,Cs]);const ot=l.useMemo(()=>m?[...m.files??[]].sort((a,o)=>a.path.localeCompare(o.path)):[],[m]),$e=l.useMemo(()=>ot.filter(Cr),[ot]),Ns=l.useMemo(()=>ot.filter(Ei),[ot]);l.useEffect(()=>{if(!r||ot.length===0)return;const s=[],a=new Set,o=N=>{!N||a.has(N)||(a.add(N),s.push(N))};if($e.forEach(N=>o(N.path)),tt.forEach(o),ot.slice(0,Ri).forEach(N=>o(N.path)),s.length===0)return;const c=window.setTimeout(()=>{te(r,n,s,{maxFiles:Fi})},120);return()=>{window.clearTimeout(c)}},[ot,r,n,te,$e,tt]);const ar=s=>s?.pushed[0]?.remote||m?.tracking?.split("/")[0]||We.find(a=>a.name==="origin")?.name||We[0]?.name||"origin",ir=async(s,a)=>{if(r){Bt(s);try{const o=c=>{const N=`${c.name}/`,z=m?.tracking?.startsWith(N)?m.tracking.slice(N.length):void 0;return{remote:c.name,branch:z,rebase:!0}};if(s==="fetch"){if(!a)throw new Error("No remote available for fetch");await n.gitFetch(r,{remote:a.name}),v.success(e("gitView.toast.fetchedFromRemote",{name:a.name}))}else if(s==="pull"){if(!a)throw new Error("No remote available for pull");const c=await n.gitPull(r,o(a));v.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:a.name}))}else if(s==="push"){const c=await n.gitPush(r);v.success(e("gitView.toast.pushedToUpstream",{name:ar(c)}))}else if(s==="sync"){if(!a)throw new Error("No remote available for sync");let c=0,N=!1;await n.gitFetch(r,{remote:a.name});const z=await n.getGitStatus(r);if((z.behind??0)>0){if((z.files?.length??0)>0){v.error(e("gitView.toast.commitOrStashBeforeSync"));return}c=(await n.gitPull(r,o(a))).files.length}((await n.getGitStatus(r)).ahead??0)>0&&(await n.gitPush(r),N=!0),c>0&&N?v.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:a.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:a.name})):c>0?v.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:a.name})):N?v.success(e("gitView.toast.pushedToUpstream",{name:a.name})):v.success(e("gitView.toast.alreadyUpToDate"))}await re(!1),await ye()}catch(o){const c=o instanceof Error?o.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});v.error(c)}finally{Bt(null)}}},tn=l.useCallback(async s=>{if(!r)return;const a=s.name.trim();if(!a){v.error(e("gitView.toast.remoteNameRequired"));return}if(a==="origin"){v.error(e("gitView.toast.cannotRemoveOriginRemote"));return}er(a);try{await n.removeRemote(r,{remote:a}),v.success(e("gitView.toast.removedRemote",{name:a})),await Promise.all([re(!1),Gt()])}catch(o){const c=o instanceof Error?o.message:`Failed to remove ${a}`;v.error(c)}finally{er(null)}},[r,n,Gt,re,e]),or=async(s={})=>{if(!r)return;if(!Ae.trim()){v.error(e("gitView.toast.enterCommitMessage"));return}const a=$e.map(c=>c.path).sort();if(a.length===0){v.error(e("gitView.toast.stageFileToCommit"));return}const o=s.pushAfter?"commitAndPush":"commit";_s(o);try{if(await n.createGitCommit(r,Ae.trim(),{files:a,stageFiles:[]}),Q(r),v.success(e("gitView.toast.commitCreated")),Ge(""),Et(),await re(),s.pushAfter){const c=m?.tracking?.split("/")[0],N=We.find(Dn=>Dn.name===c)??We[0];if(!N)throw new Error(e("mobile.changes.noRemote"));Bt("sync");const z=`${N.name}/`,ne=m?.tracking?.startsWith(z)?m.tracking.slice(z.length):void 0;await n.gitFetch(r,{remote:N.name});const U=await n.getGitStatus(r);if((U.behind??0)>0){if((U.files?.length??0)>0){v.error(e("gitView.toast.commitOrStashBeforeSync")),await re(!1);return}await n.gitPull(r,{remote:N.name,branch:ne,rebase:!0})}const ze=await n.getGitStatus(r);let jt;(ze.ahead??0)>0&&(jt=await n.gitPush(r)),v.success(e("gitView.toast.pushedToUpstream",{name:ar(jt)})),Br(),await re(!1)}else await re(!1);await ye(),Er(c=>c+1)}catch(c){const N=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");v.error(N)}finally{_s(null),s.pushAfter&&Bt(null)}},sn=l.useCallback(async()=>{if(!r)return;const s=$e.map(a=>a.path).sort();if(s.length===0){v.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),Ks(!0);try{const{message:a}=await Sa(r,s),o=a.subject?.trim()??"",c=Array.isArray(a.highlights)?a.highlights:[];if(o){let N=o;if(Te&&xe.length>0){const z=Bi(o,xe);if(z){const{code:ne,emoji:U}=z;!o.startsWith(ne)&&!o.startsWith(U)&&(N=`${ne} ${o}`)}}Ge(N)}os(c),Js()}catch(a){console.error("[git-generation][browser] GitView generate handler failed",{message:a instanceof Error?a.message:String(a),error:a});const o=a instanceof Error?a.message:e("gitView.toast.generateCommitMessageFailed");v.error(o)}finally{Ks(!1)}},[r,$e,Te,xe,Js,e]),Ss=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",rn=async(s,a)=>{if(!r||!m)return;const o=Is(T);if(o.length>0){v.error(e("gitView.toast.cannotCreateBranch",{reason:Ss(o[0])}));return}const c=m.current??null,N=a?.name??"origin";try{await n.createBranch(r,s,c??"HEAD"),v.success(e("gitView.toast.createdBranch",{name:s})),await n.checkoutBranch(r,s);let z=!1;try{await n.gitPush(r,{remote:N,branch:s,options:["--set-upstream"]}),z=!0}catch(ne){const U=ne instanceof Error?ne.message:`Unable to push new branch to ${N}.`;v.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",U]})})}await re(),await ye(),z&&v.success(e("gitView.toast.upstreamSet",{branch:s,remote:N}))}catch(z){const ne=z instanceof Error?z.message:e("gitView.toast.createBranchFailed");throw v.error(ne),z}},nn=async(s,a)=>{if(!r)return;const o=Is(T);if(o.length>0){v.error(e("gitView.toast.cannotRenameBranch",{reason:Ss(o[0])}));return}try{await n.renameBranch(r,s,a),v.success(e("gitView.toast.renamedBranch",{oldName:s,newName:a})),await re(),await ye()}catch(c){const N=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:a});v.error(N)}},an=async s=>{if(!r)return;const a=Is(T);if(a.length>0){v.error(e("gitView.toast.cannotCheckout",{reason:Ss(a[0])}));return}const o=s.replace(/^remotes\//,"");if(m?.current!==o)try{const c=await n.checkoutBranch(r,o);v.success(e("gitView.toast.checkedOut",{name:c?.branch||o})),await re(),await ye()}catch(c){const N=c instanceof Error?c.message:e("gitView.toast.checkoutFailed",{name:o});v.error(N)}},on=async s=>{if(r){ss();try{await n.setGitIdentity(r,s.id),v.success(e("gitView.toast.appliedIdentity",{name:s.name})),await Cs()}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.applyIdentityFailed");v.error(o)}finally{rs()}}},kt=l.useMemo(()=>_?.all?_.all.filter(s=>!s.startsWith("remotes/")).sort():[],[_]),lt=l.useMemo(()=>_?.all?_.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[_]),We=l.useMemo(()=>{if(gs.length>0)return gs;const s=new Set,a=m?.tracking?.trim();a&&a.includes("/")&&s.add(a.split("/")[0]);for(const o of lt){const c=o.indexOf("/");c>0&&s.add(o.slice(0,c))}return s.size===0&&xt&&s.add("origin"),Array.from(s).map(o=>({name:o,fetchUrl:xt??"",pushUrl:xt??""}))},[gs,lt,xt,m?.tracking]),ct=m?.current??null,lr=l.useMemo(()=>{const s=m?.tracking?.trim().split("/")[0];return(s&&_?.defaultBranches?.[s])??_?.defaultBranches?.origin},[_,m?.tracking]),wt=l.useMemo(()=>Fa({remoteNames:new Set(We.map(s=>s.name)),localBranches:kt,worktreeCreatedFromBranch:G?.createdFromBranch,rootBranchHint:Ie,defaultBranch:lr,headBranch:ct}),[ct,lr,We,kt,Ie,G?.createdFromBranch]),ln=l.useMemo(()=>We.map(o=>o.name).map(o=>`${o}/${wt}`).find(o=>lt.includes(o))??wt,[wt,We,lt]),cn=l.useMemo(()=>{const s=new Map;y&&s.set(y.id,y);let a=null;if(xt)try{let o=xt.trim();o.startsWith("git@")&&(o=`https://${o.slice(4).replace(":","/")}`),o.endsWith(".git")&&(o=o.slice(0,-4));const c=new URL(o);a=c.hostname+c.pathname}catch{}for(const o of C){if(o.authType!=="token"){s.set(o.id,o);continue}const c=o.host;if(!c){s.set(o.id,o);continue}if(!c.includes("/")){s.set(o.id,o);continue}a&&a===c&&s.set(o.id,o)}return Array.from(s.values())},[C,y,xt]),dn=l.useMemo(()=>{if(H?.userName&&H?.userEmail){const s=C.find(a=>a.userName===H.userName&&a.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]),un=$e.length,mn=ce||zs!==null||Gs!==null,hn=!!(G&&ls&&cs&&Lr),cr=!!ct,dt=hn&&ls&&cs&&G?{repoRoot:ls,sourceBranch:cs,worktreeMetadata:G}:null;l.useEffect(()=>{if(!r||!n||!Z?.all?.length||!ct||!wt||ct===wt){vt(null);return}let s=!1;return(async()=>{try{const o=await n.getGitLog(r,{from:wt,to:"HEAD",maxCount:Ue});if(s)return;const c=new Set((o?.all??[]).map(z=>z.hash).filter(z=>typeof z=="string"&&z.length>0));if(c.size===0){vt(null);return}const N=Z.all.findIndex(z=>!c.has(z.hash));if(N===0){vt(null);return}if(N===-1){vt({insertBeforeIndex:Z.all.length,branchName:ct,direction:"up"});return}vt({insertBeforeIndex:N,branchName:ct,direction:"up"})}catch{s||vt(null)}})(),()=>{s=!0}},[wt,ct,r,n,Z,Ue]),l.useEffect(()=>{xs(null)},[r]),l.useEffect(()=>{if(Me!=="graph"||!r){Me!=="graph"&&xs(null);return}let s=!1;return sr(!0),n.getGitLog(r,{maxCount:ys,all:!0}).then(a=>{s||xs(a)}).catch(a=>{console.error("Failed to fetch graph log:",a)}).finally(()=>{s||sr(!1)}),()=>{s=!0}},[Me,r,ys,Yr,n]);const Vt=l.useCallback((s,a)=>{if(!r||s.length===0)return;const o=Array.from(new Set(s));Ws(N=>{const z=new Set(N);return o.forEach(ne=>z.add(ne)),z});const c=we(r,o,a);le.enqueue({directory:r,direction:a,paths:new Set(o),rollback:()=>se(r,c)}),Ve()},[r,le,we,se,Ve]),ks=l.useCallback(async s=>{if(r){Mt(a=>{const o=new Set(a);return o.add(s),o});try{await n.revertGitFile(r,s,{scope:"working"}),v.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.revertFailed");v.error(o)}finally{Mt(a=>{const o=new Set(a);return o.delete(s),o})}}},[r,re,n,e]),_t=l.useCallback(async(s,a,o="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(as||c.some(U=>ns.has(U)))return;const N=new Set($e.map(U=>U.path)),z=o==="all"&&c.some(U=>N.has(U));a&&Us(!0),Mt(U=>{const ze=new Set(U);return c.forEach(jt=>ze.add(jt)),ze});const ne=[];try{if(await Promise.all(c.map(async U=>{try{await n.revertGitFile(r,U,{scope:o})}catch(ze){ne.push({path:U,message:ze instanceof Error?ze.message:e("gitView.toast.revertFailed")})}})),z&&ne.length<c.length&&Q(r),await re(!1),ne.length===0)v.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(ne.length===c.length)v.error(ne[0]?.message||e("gitView.toast.revertFailed"));else{const U=c.length-ne.length;v.warning(U===1?e("gitView.toast.revertedSomeSingle",{success:U,failed:ne.length}):e("gitView.toast.revertedSomePlural",{success:U,failed:ne.length}))}}finally{Mt(U=>{const ze=new Set(U);return c.forEach(jt=>ze.delete(jt)),ze}),a&&Us(!1)}},[Q,r,n,as,re,ns,$e,e]),gn=l.useCallback(async s=>{await _t(s,!0)},[_t]),fn=l.useCallback(async s=>{await _t(s,!1,"working")},[_t]),Vs=l.useCallback((s,a)=>{if(u&&!me){he(u,s,a);return}qe(s,a)},[u,me,qe,he]),pn=l.useCallback(()=>ts(!0),[]),xn=l.useMemo(()=>{const s=[];return $e.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:$e,actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:a=>e("gitView.changes.unstageFileAria",{path:a}),onActionFile:a=>{Vt([a],"unstage")},onActionAll:a=>{Vt(a,"unstage")},onViewDiff:a=>Vs(a,!0),onRevertFile:ks,showRevertActions:!1,accent:!0}),Ns.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:Ns,actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:a=>e("gitView.changes.stageFileAria",{path:a}),onActionFile:a=>{Vt([a],"stage")},onActionAll:a=>{Vt(a,"stage")},onViewDiff:a=>Vs(a,!1),onRevertFile:ks}),s},[ks,Vs,Vt,$e,e,Ns]),wn=l.useCallback(s=>{if(s.length===0)return;const a=s.map(o=>o.trim()).filter(Boolean);if(a.length===0){Et();return}Ge(o=>{const c=o.trim(),N=c.length>0?`
|
|
4
|
-
|
|
5
|
-
`:"";return`${c}${N}${a.join(`
|
|
6
|
-
`)}`.trim()}),Et()},[Et]),yn=l.useCallback((s,a)=>{const o=a||s;Ge(c=>{const N=c.trimStart();return N.startsWith(s)||a&&N.startsWith(a)?c:`${o.endsWith(" ")?o:`${o} `}${c}`.trimStart()}),Qs(""),it(!1)},[]),Ht=l.useCallback(s=>{const a=s instanceof Error?s.message.toLowerCase():"";return a.includes("uncommitted changes")||a.includes("local changes")||a.includes("your local changes would be overwritten")||a.includes("please commit your changes or stash them")||a.includes("cannot rebase: you have unstaged changes")||a.includes("error: cannot pull with rebase")},[]),ut=l.useCallback((s,a)=>{Ot(o=>[...o,{message:s,status:a,timestamp:Date.now()}])},[]),Oe=l.useCallback((s,a)=>{Ot(o=>{if(o.length===0)return o;const c=[...o];return c[c.length-1]={...c[c.length-1],status:s,...a?{message:a}:{}},c})},[]),$t=l.useCallback(()=>{Ot([])},[]),bn=l.useCallback(()=>{Ot([]),ps(null)},[]),Wt=l.useCallback(s=>{const a=s.trim(),o=new Set(We.map(N=>N.name)),c=a.indexOf("/");if(c>0){const N=a.slice(0,c),z=a.slice(c+1);if(o.has(N)&&z)return{branch:a,remote:N,remoteBranch:z}}for(const N of We){const z=`${N.name}/${a}`;if(lt.includes(z))return{branch:z,remote:N.name,remoteBranch:a}}return{branch:a,remote:null,remoteBranch:null}},[We,lt]),vn=l.useCallback(async s=>{if(!r)return;ps("merge"),$t();const a=m?.current,o=Wt(s);try{o.remote&&o.remoteBranch&&(ut(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),Oe("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ut(`Merging ${o.branch} into ${a}...`,"running");const c=await n.merge(r,{branch:o.branch});c.conflict?(Oe("error","Merge conflicts detected"),Qe(c.conflictFiles??[]),Xe("merge"),Ke(!0),st(r,c.conflictFiles??[],"merge")):(Oe("done",`Merged ${o.branch} into ${a}`),He(),ut("Refreshing repository status...","running"),await re(),await ye(),Oe("done","Repository status updated"))}catch(c){if(Ht(c))Oe("error","Uncommitted changes detected"),rr("merge"),nr(o.branch),bs(!0);else{const N=c instanceof Error?c.message:`Failed to merge ${o.branch}`;Oe("error",N)}}},[r,n,m,Wt,re,ye,Ht,st,He,ut,Oe,$t]),jn=l.useCallback(async s=>{if(!r)return;ps("rebase"),$t();const a=m?.current,o=Wt(s);try{o.remote&&o.remoteBranch&&(ut(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),Oe("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ut(`Rebasing ${a} onto ${o.branch}...`,"running");const c=await n.rebase(r,{onto:o.branch});c.conflict?(Oe("error","Rebase conflicts detected"),Qe(c.conflictFiles??[]),Xe("rebase"),Ke(!0),st(r,c.conflictFiles??[],"rebase")):(Oe("done",`Rebased ${a} onto ${o.branch}`),He(),ut("Refreshing repository status...","running"),await re(),await ye(),Oe("done","Repository status updated"))}catch(c){if(Ht(c))Oe("error","Uncommitted changes detected"),rr("rebase"),nr(o.branch),bs(!0);else{const N=c instanceof Error?c.message:`Failed to rebase onto ${o.branch}`;Oe("error",N)}}},[r,n,m,Wt,re,ye,Ht,st,He,ut,Oe,$t]),Cn=l.useCallback(async()=>{if(r)try{zt==="merge"?(await n.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),He(),await re(),await ye()}catch(s){const a=s instanceof Error?s.message:`Failed to abort ${zt}`;v.error(a)}},[r,n,zt,re,ye,He,e]),Nn=l.useMemo(()=>m?.files?m.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,[m?.files]),Sn=l.useCallback(async()=>{if(r)try{const s=!!m?.mergeInProgress?.head,a=!!(m?.rebaseInProgress?.headName||m?.rebaseInProgress?.onto);if(s){const o=await n.continueMerge(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("merge"),Ke(!0),st(r,o.conflictFiles??[],"merge"),v.error(e("gitView.toast.mergeConflictsDetected"))):(He(),v.success(e("gitView.toast.mergeCompleted")),await re(),await ye())}else if(a){const o=await n.continueRebase(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("rebase"),Ke(!0),st(r,o.conflictFiles??[],"rebase"),v.error(e("gitView.toast.rebaseConflictsDetected"))):(He(),v.success(e("gitView.toast.rebaseStepCompleted")),await re(),await ye())}}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");v.error(a)}},[r,n,m,re,ye,st,He,e]),kn=l.useCallback(async()=>{if(r)try{!!m?.mergeInProgress?.head?(await n.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),He(),await re(),await ye()}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");v.error(a)}},[r,n,m,re,ye,He,e]),Vn=l.useCallback(()=>{if(!r)return;const a=!!m?.mergeInProgress?.head?"merge":"rebase",o=m?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];o.length>0&&Qe(o),Xe(a),Ke(!0)},[r,m]),In=l.useCallback(async s=>{if(!r)return;const a=m?.current,o=vs,c=js,N=(m?.files??[]).some(Cr);try{await n.stash(r,{message:`Auto-stash before ${o} with ${c}`,includeUntracked:!0}),N&&Q(r)}catch(U){const ze=U instanceof Error?U.message:"Failed to stash changes";v.error(ze);return}let z=!1,ne=!1;try{if(o==="merge"){const U=await n.merge(r,{branch:c});U.conflict?(ne=!0,Qe(U.conflictFiles??[]),Xe("merge"),Ke(!0)):(z=!0,v.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:a||""})))}else{const U=await n.rebase(r,{onto:c});U.conflict?(ne=!0,Qe(U.conflictFiles??[]),Xe("rebase"),Ke(!0)):(z=!0,v.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:a||"",branch:c})))}if(s&&z)try{await n.stashPop(r),Q(r),v.success(e("gitView.toast.stashedRestored"))}catch(U){const ze=U instanceof Error?U.message:e("gitView.toast.restoreStashFailed");v.error(ze)}else s&&ne&&v.info(e("gitView.toast.restoreStashManually"));await re(),await ye()}catch(U){if(s)try{await n.stashPop(r),Q(r)}catch{}throw U}},[Q,r,n,m,vs,js,re,ye,e]),Pn=l.useCallback(s=>{Fr(s),r&&(J(r,s),M(r,n,s))},[r,M,n,J]),Fn=l.useCallback(s=>{qr(s)},[]),Rn=l.useCallback(()=>{Lt(null),r&&(d(r,n),P(r,n),M(r,n,Ue))},[r,d,P,M,Ue,n]),Bn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){v.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(d(r,n),P(r,n),M(r,n,Ue));return}Qe(s.conflictFiles??[]),Xe(s.operation),Ke(!0),r&&st(r,s.conflictFiles??[],s.operation)}},[e,Qe,Xe,Ke,st,r,d,P,M,Ue,n]);return u?B===null||B===!0&&!m?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(A,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):B===!1?Ee?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(A,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e("gitView.empty.worktreeSetupInProgress")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):t.jsx(Ea,{rootIsGitRepo:F,resolvedIsGitRepo:B,nestedRepos:Y,onRetryDiscovery:()=>{u&&Ne(u,{force:!0})},emptyStateFooter:ee.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:Ce("flex h-full flex-col overflow-hidden"),children:[t.jsx(Ta,{status:m,localBranches:kt,remoteBranches:lt,branchInfo:_?.branches,syncAction:zs,remotes:We,onFetch:s=>ir("fetch",s),onSync:s=>ir("sync",s),onRemoveRemote:tn,removingRemoteName:$r,onCheckoutBranch:an,onCreateBranch:rn,onRenameBranch:nn,activeIdentityProfile:dn,availableIdentities:cn,onSelectIdentity:on,isApplyingIdentity:Rr,isWorktreeMode:!!G,onOpenHistory:()=>Lt("history"),onOpenGraph:()=>Lt("graph"),onOpenStashes:pn,onOpenUpdateBranch:cr?()=>Xs(!0):void 0,onOpenReintegrateCommits:dt?()=>Zs(!0):void 0,pullRequest:ue?.pr??null,prChecks:ue?.checks??null,onOpenPullRequest:r?()=>Pe(r,"pr"):void 0,repositoryOptions:r!==u&&Array.isArray(Y)?Y:void 0,selectedRepository:r!==u?r:null,onSelectRepository:r!==u&&u?s=>ve(u,s):void 0,repositoryRoot:r!==u?u:void 0}),u&&(m?.mergeInProgress?.head||m?.rebaseInProgress?.headName||m?.rebaseInProgress?.onto)&&t.jsx(yi,{mergeInProgress:m?.mergeInProgress,rebaseInProgress:m?.rebaseInProgress,onContinue:Sn,onAbort:kn,onResolveWithAI:Vn,conflictCount:Nn,isLoading:ce}),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:Ce("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(Sr,{as:ka,ref:Os,outerClassName:"flex-1 min-h-0",className:Ce("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:(ot?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(La,{groups:xn,diffStats:m?.diffStats,revertingPaths:ns,isRevertingAll:as,onVisiblePathsChange:nt,onRevertAll:gn,onRevertDirectory:fn,headerBackgroundClassName:"bg-background"})}),t.jsx(Oa,{stagedCount:un,commitMessage:Ae,onCommitMessageChange:Ge,generatedHighlights:is,onInsertHighlights:wn,onGenerateMessage:sn,isGeneratingMessage:Tr,onCommit:()=>or({pushAfter:!1}),onCommitAndPush:()=>or({pushAfter:!0}),commitAction:Gs,hasPendingIndexMutation:Ar,gitmojiEnabled:Te,onOpenGitmojiPicker:()=>it(!0)})]}):t.jsx(Xa,{onOpenStashes:()=>ts(!0)})})})})})}),t.jsx(ht,{open:_r,onOpenChange:s=>{!s&&tr!==null||Xs(s)},children:t.jsxs(gt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(pt,{children:e("gitView.branch.updateTitle")}),t.jsxs(bt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:m?.current??""}),"."]})]}),cr?t.jsx(bi,{mode:"bare",currentBranch:m?.current,localBranches:kt,remoteBranches:lt,defaultTargetBranch:ln,onMerge:vn,onRebase:jn,disabled:mn,isOperating:tr!==null,operationLogs:Wr,onOperationComplete:bn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(ht,{open:Hr,onOpenChange:Zs,children:t.jsxs(gt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(pt,{children:e("gitView.integrate.title")}),t.jsx(bt,{children:dt?t.jsxs("span",{className:"font-mono text-foreground",children:[dt.sourceBranch," → ",qs]}):null})]}),dt?t.jsx(Ya,{repoRoot:dt.repoRoot,sourceBranch:dt.sourceBranch,worktreeMetadata:dt.worktreeMetadata,localBranches:kt,defaultTargetBranch:qs,refreshKey:Mr,showHeader:!1,onRefresh:()=>{r&&(d(r,n),P(r,n),M(r,n,Ue))}},dt.worktreeMetadata.path):null]})}),t.jsx(ht,{open:Me!==null,onOpenChange:s=>{s||Lt(null)},children:t.jsxs(gt,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(pt,{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"){Qr(s=>s+1);return}r&&M(r,n,Ue)},disabled:Me==="graph"?ws:ie,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(A,{name:"refresh",className:Ce("size-4",(Me==="graph"?ws:ie)&&"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(oi,{mode:Me==="graph"?"graph":"history",log:Me==="graph"?Jr??Z:Z,isLogLoading:Me==="graph"&&ws||ie,logMaxCount:Me==="graph"?ys:Ue,onLogMaxCountChange:Me==="graph"?Fn:Pn,expandedCommitHashes:ds,onToggleCommit:en,commitFilesMap:Tt,loadingCommitHashes:At,onCopyHash:Zr,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Me==="graph"?null:Gr,onConflict:Me==="graph"?Bn:void 0,onActionSuccess:Me==="graph"?Rn:void 0})})]})}),t.jsx(Qa,{open:Pr,onOpenChange:ts,directory:r,hasUncommittedChanges:(m?.files?.length??0)>0,hasStagedChanges:$e.length>0,uncommittedFileCount:m?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&Q(r),await re(!1),await ye()}}),t.jsx(ht,{open:at,onOpenChange:it,children:t.jsxs(gt,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(ft,{className:"px-4 pt-4",children:t.jsx(pt,{children:e("gitView.gitmoji.title")})}),t.jsxs(Es,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(Ts,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:Ys,onValueChange:Qs}),t.jsxs(As,{children:[t.jsx(Ls,{children:e("gitView.gitmoji.empty")}),t.jsx(Yt,{children:Rt(xe,Ys,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(Qt,{onSelect:()=>yn(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(mi,{open:Ur,onOpenChange:Ke,conflictFiles:Kr,directory:r,operation:zt,onAbort:Cn,onClearState:He}),t.jsx(wi,{open:Xr,onOpenChange:bs,operation:vs,targetBranch:js,onConfirm:In})]}):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{Xl as GitView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as r,j as s,f as et}from"./vendor-react-BUCujlKS.js";import{f as bt,V as yt,au as fe,c8 as vt,bR as jt,t as v,ig as It,I as u,B as xe,o as Ye,c2 as He,a1 as Qe,bU as Nt,bV as Pt,bW as wt,bX as St,bY as kt,b_ as Ze,h as D,S as Lt,fI as Ct,b1 as Rt,b3 as At,fJ as Ft,b4 as Et}from"./useAppFontEffects-COAeIX-D.js";import{u as f,d7 as K}from"./index-qES19dlJ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-BeMD8X_w.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"./contextPanelEmbeddedChat-C9EcRSDF.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-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-BG3v1Ghq.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";const $e="[&_img]:max-w-full [&_img]:h-auto",tt="flex h-8 min-w-0 flex-1 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 disabled:cursor-not-allowed disabled:opacity-50",Re="flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Tt=520,Je=t=>t.name?.trim()||t.urlKey?.trim()||t.id,Mt={0:"contextPanel.linear.priority.none",1:"contextPanel.linear.priority.urgent",2:"contextPanel.linear.priority.high",3:"contextPanel.linear.priority.medium",4:"contextPanel.linear.priority.low"},Kt={triage:0,backlog:1,unstarted:2,started:3,completed:4,canceled:5},Xe=t=>t==="triage"||t==="backlog"||t==="unstarted"||t==="started"||t==="completed"||t==="canceled"?Kt[t]:99,Dt=(t,n)=>{const o=Xe(t.type)-Xe(n.type);return o!==0?o:t.position!==n.position?t.position-n.position:t.name.localeCompare(n.name)},Ot=t=>t!==0&&t!==1&&t!==2&&t!==3&&t!==4?null:Mt[t],he=[{value:"all",labelKey:"contextPanel.linear.filter.status.all"},{value:"backlog",labelKey:"contextPanel.linear.filter.status.backlog"},{value:"todo",labelKey:"contextPanel.linear.filter.status.todo"},{value:"started",labelKey:"contextPanel.linear.filter.status.started"},{value:"inReview",labelKey:"contextPanel.linear.filter.status.inReview"},{value:"completed",labelKey:"contextPanel.linear.filter.status.completed"},{value:"canceled",labelKey:"contextPanel.linear.filter.status.canceled"},{value:"duplicate",labelKey:"contextPanel.linear.filter.status.duplicate"}],Ut=t=>he.some(n=>n.value===t),ge=[{value:"all",labelKey:"contextPanel.linear.filter.priority.all"},{value:"urgent",labelKey:"contextPanel.linear.priority.urgent"},{value:"high",labelKey:"contextPanel.linear.priority.high"},{value:"medium",labelKey:"contextPanel.linear.priority.medium"},{value:"low",labelKey:"contextPanel.linear.priority.low"},{value:"none",labelKey:"contextPanel.linear.priority.none"}],_t=t=>ge.some(n=>n.value===t),zt=t=>t?{color:t,backgroundColor:`color-mix(in srgb, ${t} 18%, transparent)`}:{backgroundColor:"color-mix(in srgb, var(--surface-mutedForeground) 12%, transparent)"},Wt=t=>{const n=et.c(4),{labels:o}=t;if(o.length===0)return null;let c;n[0]!==o?(c=o.map(qt),n[0]=o,n[1]=c):c=n[1];let y;return n[2]!==c?(y=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:c}),n[2]=c,n[3]=y):y=n[3],y},te=t=>{const n=et.c(31),{icon:o,label:c,ariaLabel:y,value:W,items:V,disabled:j,compact:x,active:w,onValueChange:d}=t,[S,G]=r.useState(!1),B=j?!1:S;let A;n[0]!==j?(A=E=>{j||G(E)},n[0]=j,n[1]=A):A=n[1];const H=w===!0,k=x?Re:tt,Q=x?c:void 0,Z=w?"text-primary":"text-muted-foreground";let L;n[2]!==Z?(L=D("size-3.5 shrink-0",Z),n[2]=Z,n[3]=L):L=n[3];let h;n[4]!==o||n[5]!==L?(h=s.jsx(u,{name:o,className:L}),n[4]=o,n[5]=L,n[6]=h):h=n[6];let C;n[7]!==x||n[8]!==c?(C=x?null:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate",children:c}),s.jsx(u,{name:"arrow-down-s",className:"size-4 shrink-0 opacity-60"})]}),n[7]=x,n[8]=c,n[9]=C):C=n[9];let I;n[10]!==y||n[11]!==j||n[12]!==H||n[13]!==k||n[14]!==Q||n[15]!==h||n[16]!==C?(I=s.jsx(Rt,{asChild:!0,children:s.jsxs("button",{type:"button",disabled:j,"aria-pressed":H,className:k,"aria-label":y,title:Q,children:[h,C]})}),n[10]=y,n[11]=j,n[12]=H,n[13]=k,n[14]=Q,n[15]=h,n[16]=C,n[17]=I):I=n[17];let R;n[18]!==d?(R=E=>{d(E),G(!1)},n[18]=d,n[19]=R):R=n[19];let N;n[20]!==V?(N=V.map(Yt),n[20]=V,n[21]=N):N=n[21];let g;n[22]!==R||n[23]!==N||n[24]!==W?(g=s.jsx(At,{align:"start",className:"min-w-40",children:s.jsx(Ft,{value:W,onValueChange:R,children:N})}),n[22]=R,n[23]=N,n[24]=W,n[25]=g):g=n[25];let F;return n[26]!==B||n[27]!==I||n[28]!==g||n[29]!==A?(F=s.jsxs(Et,{open:B,onOpenChange:A,children:[I,g]}),n[26]=B,n[27]=I,n[28]=g,n[29]=A,n[30]=F):F=n[30],F},Vt=t=>{const n=t.trim();if(!n)return null;const o=n.match(/linear\.app\/(?:[^/]+\/)?issue\/([A-Za-z][A-Za-z0-9]*-\d+)/i);return o?o[1].toUpperCase():/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(n)?n.toUpperCase():null},Gt=t=>({id:t.id,identifier:t.identifier,title:t.title,url:t.url,state:t.state,assignee:t.assignee,team:t.team,priority:t.priority,labels:t.labels}),Bt=(t,n)=>{const o=Gt(n);return t.map(c=>c.id===n.id?o:c)},In=()=>{const{t}=bt(),{linear:n}=yt(),o=fe(e=>e.status),c=fe(e=>e.hasChecked),y=fe(e=>e.refreshStatus),W=fe(e=>e.setStatus),V=f(e=>e.setSettingsDialogOpen),j=f(e=>e.setSettingsPage),x=f(e=>e.linearIssueListStatus),w=f(e=>e.linearIssueListAssignee),d=f(e=>e.linearIssueListTeamId),S=f(e=>e.linearIssueListPriority),G=f(e=>e.linearIssueFocus),B=f(e=>e.timeFormatPreference),A=f(e=>e.setLinearIssueListStatus),H=f(e=>e.setLinearIssueListAssignee),k=f(e=>e.setLinearIssueListTeamId),Q=f(e=>e.setLinearIssueListPriority),Z=f(e=>e.resetLinearIssueListFilters),L=f(e=>e.setLinearIssueFocus),[h,C]=r.useState(""),[I,R]=r.useState(!1),[N,g]=r.useState([]),[F,E]=r.useState(null),[be,se]=r.useState(!1),[O,U]=r.useState(!0),[ne,Ae]=r.useState(!1),[$,Fe]=r.useState(!1),[Ee,ae]=r.useState(null),[J,T]=r.useState(null),[l,X]=r.useState(null),[_,re]=r.useState([]),[st,Te]=r.useState(!1),[q,Me]=r.useState(!1),[le,Ke]=r.useState(!1),[ie,ye]=r.useState(!1),[Y,oe]=r.useState([]),[ce,De]=r.useState(!1),P=r.useRef(0),ve=r.useRef(null),Oe=r.useRef(null),[Ue,nt]=r.useState(0),ue=r.useMemo(()=>Vt(h),[h]),je=vt(h,350),at=r.useCallback(e=>{if(!e)return"";const a=Date.parse(e);return Number.isFinite(a)?jt(a,B,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):""},[B]),rt=r.useCallback(()=>{j("integrations"),V(!0)},[V,j]),de=r.useMemo(()=>({query:je.trim()||void 0,status:x,assignee:w,teamId:d===K?void 0:d,priority:S==="all"?void 0:S}),[je,w,S,x,d]),me=o?.workspaces??[],z=me.find(e=>e.current)?.id||o?.organization?.id||"",_e=r.useCallback(async()=>{if(c&&o?.connected===!1){U(!1),g([]),se(!1),E(null),ae(null);return}if(!n?.issuesList){U(!0),ae(t("session.linearIssuePicker.error.runtimeUnavailable"));return}const e=P.current+1;P.current=e,Ae(!0),ae(null);try{const a=await n.issuesList(de);if(e!==P.current)return;if(U(a.connected!==!1),a.connected===!1){g([]),se(!1),E(null);return}g(a.issues??[]),E(a.cursor??null),se(!!a.hasMore)}catch(a){if(e!==P.current)return;ae(a instanceof Error?a.message:String(a))}finally{e===P.current&&Ae(!1)}},[n,c,o,de,t]);r.useEffect(()=>{n&&!c&&y(n)},[n,c,y]),r.useEffect(()=>{_e()},[_e]),r.useEffect(()=>{if(!n?.mappingGet||!O){oe([]);return}let e=!1;return n.mappingGet().then(a=>{if(!e){if(a.connected===!1){oe([]);return}oe(a.teams??[])}}).catch(()=>{e||oe([])}),()=>{e=!0}},[O,z,n]),r.useEffect(()=>{d===K||Y.length===0||Y.some(e=>e.id===d)||k(K)},[d,k,Y]);const lt=r.useCallback(async()=>{if(!n?.issuesList||$||ne||!be||!F)return;const e=P.current+1;P.current=e,Fe(!0);try{const a=await n.issuesList({...de,cursor:F});if(e!==P.current||(U(a.connected!==!1),a.connected===!1))return;g(i=>[...i,...a.issues??[]]),E(a.cursor??null),se(!!a.hasMore)}catch(a){if(e!==P.current)return;const i=a instanceof Error?a.message:String(a);v.error(t("session.linearIssuePicker.toast.loadMoreFailed"),{description:i})}finally{e===P.current&&Fe(!1)}},[F,be,ne,$,n,de,t]);r.useEffect(()=>{if(!J||!n?.issueGet)return;let e=!1;return Te(!0),X(null),re([]),(async()=>{try{const a=await n.issueGet(J);if(e)return;if(a.connected===!1){U(!1),T(null);return}const i=a.issue;if(!i){v.error(t("session.linearIssuePicker.error.issueNotFound")),T(null);return}X(i);const M=i.team?.id;if(!M||!n.issueStates)return;try{const b=await n.issueStates(M);if(e)return;if(b.connected===!1){U(!1);return}re(b.states??[])}catch(b){if(e)return;const pe=b instanceof Error?b.message:String(b);v.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:pe})}}catch(a){if(e)return;const i=a instanceof Error?a.message:String(a);v.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:i}),T(null)}finally{e||Te(!1)}})(),()=>{e=!0}},[n,J,t]),r.useEffect(()=>{G&&(T(G),L(null))},[G,L]);const ze=r.useCallback(e=>{X(e),g(a=>Bt(a,e))},[]),Ie=r.useCallback(async(e,a)=>{if(!(!n?.issueUpdate||!l||q)&&l.state?.id!==e){Me(!0);try{const i=await n.issueUpdate({id:l.id,stateId:e});if(i.connected===!1){U(!1),v.error(t(a));return}if(!i.issue){v.error(t(a));return}ze(i.issue),v.success(t("contextPanel.linear.toast.statusUpdated"))}catch(i){const M=i instanceof Error?i.message:String(i);v.error(t(a),{description:M})}finally{Me(!1)}}},[ze,q,n,l,t]),it=r.useCallback(()=>{const e=_.find(a=>a.type==="completed");if(!e){v.error(t("contextPanel.linear.error.noCompletedState"));return}Ie(e.id,"contextPanel.linear.toast.closeFailed")},[t,Ie,_]),ot=r.useCallback(async()=>{if(!(!l||le)){Ke(!0);try{await It({linear:n,issueKey:l.id,createInWorktree:ie,t})}finally{Ke(!1)}}},[ie,le,n,l,t]),ct=r.useCallback(async e=>{if(!(!n?.authActivate||!e||e===z||ce)){De(!0);try{const a=await n.authActivate(e);W(a),T(null),X(null),re([]),k(K),v.success(t("contextPanel.linear.toast.workspaceSwitched"))}catch(a){const i=a instanceof Error?a.message:String(a);v.error(t("contextPanel.linear.toast.workspaceSwitchFailed"),{description:i})}finally{De(!1)}}},[z,ce,n,W,k,t]),Ne=r.useMemo(()=>{const e=new Map(_.map(b=>[b.id,b])),a=l?.state?.id,i=l?.state?.name;return[...a&&i&&!e.has(a)?[{id:a,name:i,type:l.state?.type??null,position:0},..._]:_].sort(Dt)},[l,_]),ut=_.find(e=>e.type==="completed"),dt=l?.state?.type==="completed",We=c&&O===!1,mt=!n,Ve=!!J,Ge=x==="all"&&w==="any"&&d===K&&S==="all",Pe=!!n&&O&&!We,ee=!Pe||ce,m=Ue>0&&Ue<Tt,we=h.trim().length>0,pt=!Ge||we,Se=!m||I||we,ke=r.useCallback(()=>{C(""),R(!1)},[]);r.useEffect(()=>{const e=ve.current;if(!e||!globalThis.ResizeObserver)return;const a=new ResizeObserver(i=>{nt(i[0]?.contentRect.width??0)});return a.observe(e),()=>a.disconnect()},[Ve]),r.useEffect(()=>{m&&I&&Oe.current?.focus()},[m,I]);const ft=s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":ie,onClick:()=>ye(e=>!e),onKeyDown:e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),ye(a=>!a))},children:[s.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),ye(a=>!a)},"aria-label":t("session.linearIssuePicker.actions.toggleWorktreeAria"),className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:ie?s.jsx(u,{name:"checkbox",className:"h-4 w-4 text-primary"}):s.jsx(u,{name:"checkbox-blank",className:"h-4 w-4"})}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("session.linearIssuePicker.actions.createInWorktree")})]}),xt=e=>s.jsxs("div",{className:D("group flex items-center gap-2 py-1.5 px-1 rounded cursor-pointer hover:bg-interactive-hover/30 transition-colors",J===e.id&&"bg-interactive-selection/30"),onClick:()=>T(e.id),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:e.identifier}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:e.title}),s.jsx("div",{className:"flex-shrink-0 h-5 flex items-center mr-1",children:s.jsx("button",{type:"button",className:"hidden group-hover:flex h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),Ye(e.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})})})]},e.id);if(Ve){const e=l?.assignee?.displayName||l?.assignee?.name,a=l?.comments??[],i=l?.description?.trim()||"",M=l?.state?.id||"",b=Ot(l?.priority),pe=l?.labels??[];return s.jsxs("div",{ref:ve,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[s.jsxs(xe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>{T(null),X(null),re([])},"aria-label":t("contextPanel.linear.actions.backToList"),children:[s.jsx(u,{name:"arrow-left-s",className:"h-4 w-4"}),t("contextPanel.linear.actions.backToList")]}),l?s.jsx("button",{type:"button",className:"ml-auto flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Ye(l.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})}):null]}),s.jsxs(He,{as:Qe,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:[st&&!l?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}):null,l?s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:l.identifier}),s.jsx("h2",{className:"typography-ui-header text-foreground mt-0.5",children:l.title})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ne.length>0&&M?s.jsxs(Nt,{value:M,onValueChange:p=>{Ie(p,"contextPanel.linear.toast.statusUpdateFailed")},disabled:q,children:[s.jsx(Pt,{size:"sm",className:"h-7 w-auto min-w-0","aria-label":t("contextPanel.linear.label.statusAria"),children:s.jsx(wt,{placeholder:t("contextPanel.linear.label.status"),children:p=>Ne.find(Le=>Le.id===p)?.name??p})}),s.jsx(St,{children:Ne.map(p=>s.jsx(kt,{value:p.id,children:p.name},p.id))})]}):l.state?.name?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l.state.name}):null,ut&&!dt?s.jsxs(xe,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:it,disabled:q,children:[q?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.closeIssue")]}):null]}),s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 typography-meta",children:[l.team?.name?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.team")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:l.team.name})]}):null,s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.assignee")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:e||t("contextPanel.linear.label.unassigned")}),b?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.priority")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:t(b)})]}):null,pe.length>0?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.labels")}),s.jsx("dd",{className:"min-w-0",children:s.jsx(Wt,{labels:pe})})]}):null]}),s.jsx("div",{children:i?s.jsx(Ze,{content:i,className:$e,enableFileReferences:!1}):s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noDescription")})}),s.jsxs("div",{children:[s.jsx("h3",{className:"typography-ui-label text-foreground mb-2",children:t("contextPanel.linear.label.comments")}),a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noComments")}):s.jsx("div",{className:"relative pl-3",children:a.map((p,Le)=>{const Ce=p.user?.displayName||p.user?.name||t("contextPanel.linear.label.unassigned"),Be=p.user?.avatarUrl||null,ht=Ce.charAt(0).toUpperCase(),gt=Le===a.length-1,qe=at(p.createdAt);return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[gt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:Be?s.jsx("img",{src:Be,alt:Ce,className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("span",{children:ht})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{className:"text-foreground whitespace-nowrap",children:Ce}),qe?s.jsx("span",{className:"whitespace-nowrap",children:qe}):null]}),p.body.trim()?s.jsx(Ze,{content:p.body,className:D("typography-markdown-body text-foreground break-words",$e),enableFileReferences:!1}):null]})]},p.id)})})]})]})}):null]}),l?s.jsxs("div",{className:"shrink-0 border-t border-border px-4 py-3 flex flex-col gap-3",children:[ft,s.jsxs(xe,{type:"button",onClick:()=>{ot()},disabled:le||q,className:"w-full",children:[le?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.startSession")]})]}):null]})}return s.jsxs("div",{ref:ve,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"px-3 pt-3 space-y-2",children:[Se?s.jsxs("div",{className:"relative",children:[s.jsx(u,{name:"search",className:D("absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4",we?"text-primary":"text-muted-foreground")}),s.jsx(Lt,{ref:Oe,placeholder:t("session.linearIssuePicker.searchPlaceholder"),value:h,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key==="Escape"&&m&&(e.preventDefault(),ke())},className:D("pl-9 w-full",m&&"pr-9")}),m?s.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":t("contextPanel.linear.actions.closeSearch"),title:t("contextPanel.linear.actions.closeSearch"),onClick:ke,children:s.jsx(u,{name:"close",className:"size-3.5"})}):null]}):null,Pe||m&&!Se?s.jsxs("div",{className:D("flex min-w-0 items-center",m&&"gap-0.5"),children:[Pe?s.jsxs(s.Fragment,{children:[s.jsx(te,{icon:"task",label:t((he.find(e=>e.value===x)??he[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.statusAria"),value:x,active:x!=="all",disabled:ee,items:he.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{Ut(e)&&A(e)}}),s.jsx(te,{icon:"error-warning",compact:m,label:t((ge.find(e=>e.value===S)??ge[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.priorityAria"),value:S,active:S!=="all",disabled:ee,items:ge.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{_t(e)&&Q(e)}}),s.jsx(te,{icon:"user-3",compact:m,label:t(w==="me"?"contextPanel.linear.filter.assignee.me":"contextPanel.linear.filter.assignee.any"),ariaLabel:t("contextPanel.linear.filter.assigneeAria"),value:w,active:w!=="any",disabled:ee,items:[{value:"any",label:t("contextPanel.linear.filter.assignee.any")},{value:"me",label:t("contextPanel.linear.filter.assignee.me")}],onValueChange:e=>{(e==="any"||e==="me")&&H(e)}}),Y.length>0?s.jsx(te,{icon:"team",compact:m,label:d===K?t("contextPanel.linear.filter.team.all"):Y.find(e=>e.id===d)?.name??d,ariaLabel:t("contextPanel.linear.filter.teamAria"),value:d,active:d!==K,disabled:ee,items:[{value:K,label:t("contextPanel.linear.filter.team.all")},...Y.map(e=>({value:e.id,label:e.name}))],onValueChange:k}):null,me.length>1&&z?s.jsx(te,{icon:"briefcase",compact:m,label:Je(me.find(e=>e.id===z)??{id:z,name:null,urlKey:null}),ariaLabel:t("contextPanel.linear.label.workspaceAria"),value:z,disabled:ce,items:me.map(e=>({value:e.id,label:Je(e)})),onValueChange:e=>{ct(e)}}):null,pt?s.jsxs("button",{type:"button",className:D(m?Re:tt,!m&&"flex-none"),"aria-label":t("contextPanel.linear.filter.clearAria"),title:t("contextPanel.linear.filter.clearAria"),disabled:ee,onClick:()=>{Z(),ke()},children:[s.jsx(u,{name:"close",className:"size-3.5 shrink-0 text-muted-foreground"}),m?null:s.jsx("span",{className:"min-w-0 truncate",children:t("contextPanel.linear.filter.clear")})]}):null]}):null,m&&!Se?s.jsx("button",{type:"button",className:Re,"aria-label":t("contextPanel.linear.filter.searchAria"),title:t("contextPanel.linear.filter.searchAria"),onClick:()=>R(!0),children:s.jsx(u,{name:"search",className:"size-3.5 shrink-0 text-muted-foreground"})}):null]}):null]}),s.jsxs(He,{as:Qe,outerClassName:"h-full min-h-0 flex-1",className:"px-3 py-2",disableHorizontal:!0,preventOverscroll:!0,children:[mt?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:t("session.linearIssuePicker.empty.runtimeUnavailable")}):null,ne&&N.length===0?s.jsxs("div",{className:"text-center text-muted-foreground py-8 flex items-center justify-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.issues")]}):null,We?s.jsxs("div",{className:"text-center text-muted-foreground py-8 space-y-3",children:[s.jsx("div",{children:t("session.linearIssuePicker.empty.notConnected")}),s.jsx("div",{className:"flex justify-center",children:s.jsx(xe,{variant:"outline",size:"sm",onClick:rt,children:t("session.linearIssuePicker.actions.openSettings")})})]}):null,Ee?s.jsx("div",{className:"text-center text-muted-foreground py-8 break-words",children:Ee}):null,ue&&n&&O?s.jsxs("div",{className:"group flex items-center gap-2 py-1.5 px-1 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:()=>T(ue),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:ue}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:t("session.linearIssuePicker.actions.useIssue",{identifier:ue})})]}):null,N.length===0&&!ne&&O&&n?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:je.trim()?t("session.linearIssuePicker.empty.noIssuesFound"):t(Ge?"session.linearIssuePicker.empty.noOpenIssuesFound":"contextPanel.linear.empty.noMatchingIssues")}):null,N.map(xt),be&&O&&n?s.jsx("div",{className:"py-2 flex justify-center",children:s.jsx("button",{type:"button",onClick:()=>{lt()},disabled:$,className:D("typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4",$&&"opacity-50 cursor-not-allowed hover:text-muted-foreground"),children:$?s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.more")]}):t("session.linearIssuePicker.actions.loadMore")})}):null]})]})};function qt(t){return s.jsx("span",{className:"inline-flex h-5 max-w-[8rem] items-center truncate rounded-md px-1.5 typography-meta text-muted-foreground",style:zt(t.color),children:t.name},t.id)}function Yt(t){return s.jsx(Ct,{value:t.value,children:t.label},t.value)}export{In as LinearIssuesView};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{R as E,f as ie,j as ee}from"./vendor-react-BUCujlKS.js";import{m as zt}from"./vendor-morphdom-B7dS_VPB.js";import{r as Bt,a as $t}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{fs as it,ft as Ht,fu as Vt,fv as Kt,g as be,b8 as jt,bb as Ut,fw as Zt,fx as Xt,V as st,ab as at,fy as lt,f as ct,h as dt,ea as Gt,fz as Yt,fA as De,fB as Jt,fC as Qt,fD as en,fE as tn,fF as nn,o as rn}from"./useAppFontEffects-COAeIX-D.js";import{r as on,F as ut,I as te,ci as sn,u as X,a as an,al as Oe,z as ln,A as cn}from"./index-qES19dlJ.js";import{h as dn}from"./contextPanelEmbeddedChat-C9EcRSDF.js";import{getCachedMarkdownBlocks as We,renderMarkdownSync as un,renderMarkdownBlocks as mn}from"./markdownCore-CWRCqSH2.js";import{r as pn}from"./registerCustomTheme-BBXUCRnG.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-BeMD8X_w.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-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-BG3v1Ghq.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-k3Ppq1Ha.js";import"./vendor-dompurify-r8glNMJW.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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";const mt=t=>{const e=t.target;if(!(e instanceof Element))return null;const n=e.closest("a[href]");return!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true"?null:n},Le=(t,e)=>{if(t.defaultPrevented)return!1;const r=mt(t)?.getAttribute("href")??"";return Ht(r)?(t.preventDefault(),t.stopPropagation(),e?.(r),!0):!1},fn=t=>t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey,hn=(t,e)=>{const n=o=>{if(Le(o,e.openAppLink)||!e.allowExternalHttp||o.defaultPrevented||!fn(o))return;const s=mt(o)?.getAttribute("href")??"";it(s)&&(o.preventDefault(),o.stopPropagation(),e.openExternalHttp(s))},r=o=>{o.button===1&&Le(o,e.openAppLink)},i=o=>{Le(o)};return t.addEventListener("click",n),t.addEventListener("auxclick",r),t.addEventListener("dragstart",i),()=>{t.removeEventListener("click",n),t.removeEventListener("auxclick",r),t.removeEventListener("dragstart",i)}},pt="openchamber-md",gn={name:pt,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let qe=!1;const bn=()=>{qe||(qe=!0,pn(pt,()=>Promise.resolve(gn)))},R=t=>Number.isFinite(t)&&t>0,ze=t=>{if(t==null)return null;const e=String(t).trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return R(n)?n:null},Me=(t,e,n)=>Math.min(n,Math.max(e,t)),wn=6,Be=1.25,yn=1.0015,An=.5,vn=12,$e=3,kn=400,ne='[data-markdown="mermaid-block"]',I=t=>t.querySelector(ne)!==null,En=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(wn));return Object.is(n,-0)?"0":String(n)}).join(" "),Cn=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(i=>Number.parseFloat(i));if(e?.length===4){const[i,o,s,a]=e;if(Number.isFinite(i)&&Number.isFinite(o)&&R(s)&&R(a))return{x:i,y:o,width:s,height:a}}const n=ze(t.width),r=ze(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Sn=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Ln=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(i=>i!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,Sn(n)].join(":")},ft=(t,e)=>{if(!R(e.width)||!R(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const i=t.height*r;return{x:t.x-(i-t.width)/2,y:t.y,width:i,height:t.height}},Mn=({currentBox:t,viewport:e,delta:n})=>!R(e.width)||!R(e.height)||!R(t.width)||!R(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},Nn=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>$e*$e},Rn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:i,minScale:o,maxScale:s})=>{if(!R(n.width)||!R(n.height)||!R(i)||!R(t.width)||!R(t.height)||!R(e.width)||!R(e.height)||!R(o)||!R(s))return t;const a=Math.min(o,s),l=Math.max(o,s),c=ft(e,n),u=c.width/t.width,g=Me(u*i,a,l),p=c.width/g,h=p/(t.width/t.height),m=Me(r.x/n.width,0,1),f=Me(r.y/n.height,0,1),A=t.x+m*t.width,v=t.y+f*t.height;return{x:A-m*p,y:v-f*h,width:p,height:h}},we=new WeakMap,xe=new WeakMap,V=new Set,re=new Set;let H=null,Q=null,Y=null;const _n=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),ht=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return Ln({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},Z=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Tn=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},xn=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),gt=t=>{const e=t.map(n=>Z(n.viewport));t.forEach((n,r)=>{const i=e[r];i&&n.fitToViewport(i)})},bt=()=>{Y!==null||V.size===0||(Y=window.requestAnimationFrame(()=>{Y=null,gt(Array.from(V))}))},Pn=()=>{if(H)return H;const t=globalThis.ResizeObserver;return t?(H=new t(e=>{for(const n of e)n.target instanceof HTMLElement&&xe.get(n.target)?.fitToViewport({width:n.contentRect.width,height:n.contentRect.height})}),H):null},In=t=>{if(V.has(t))return;const e=V.size===0;V.add(t),xe.set(t.viewport,t),Pn()?.observe(t.viewport),e&&window.addEventListener("resize",bt)},Fn=t=>{V.delete(t)&&(H?.unobserve(t.viewport),xe.delete(t.viewport),!(V.size>0)&&(H?.disconnect(),H=null,window.removeEventListener("resize",bt),Y!==null&&(window.cancelAnimationFrame(Y),Y=null)))},Dn=t=>{const e=_n(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=Cn({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let i=r,o=null,s=null,a=null,l=null;const c=d=>{i=d,n.setAttribute("viewBox",En(d)),n.removeAttribute("width"),n.removeAttribute("height")},u=d=>{c(ft(r,d))},g=()=>{u(Z(e))},p=(d,y)=>{c(Rn({currentBox:i,contentBox:r,viewport:Z(e),pointer:d,zoomFactor:y,minScale:An,maxScale:vn}))},h=()=>{const d=Z(e);p({x:d.width/2,y:d.height/2},Be)},m=()=>{const d=Z(e);p({x:d.width/2,y:d.height/2},1/Be)},f=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),p(Tn(d,e),Math.pow(yn,-d.deltaY)))},A=d=>{d.button!==0||xn(d.target)||(o=d.pointerId,s={x:d.clientX,y:d.clientY},a=s,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(d.pointerId),t.setAttribute("data-mermaid-panning","true"),d.preventDefault())},v=d=>{if(o!==d.pointerId||!a)return;const y={x:d.clientX,y:d.clientY};c(Mn({currentBox:i,viewport:Z(e),delta:{x:y.x-a.x,y:y.y-a.y}})),a=y,s&&Nn(s,y)&&t.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault()},w=d=>{o===d.pointerId&&(e.releasePointerCapture?.(d.pointerId),o=null,s=null,a=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},kn)))};e.addEventListener("wheel",f,{passive:!1}),e.addEventListener("pointerdown",A),e.addEventListener("pointermove",v),e.addEventListener("pointerup",w),e.addEventListener("pointercancel",w);const k={viewport:e,zoomIn:h,zoomOut:m,fit:g,fitToViewport:u,cleanup:()=>{Fn(k),e.removeEventListener("wheel",f),e.removeEventListener("pointerdown",A),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",w),e.removeEventListener("pointercancel",w),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),we.delete(t)}};return k},wt=t=>{for(const[e,n]of t.controllers){const r=ht(e);(!t.container.contains(e)||r!==t.signatures.get(e))&&(n.cleanup(),t.controllers.delete(e),t.signatures.delete(e))}},On=t=>{if(t.disposed)return[];const e=[];for(const n of Array.from(t.container.querySelectorAll(ne))){if(t.controllers.has(n)||n.querySelector('[data-markdown="mermaid"] svg')===null)continue;const r=Dn(n);r&&(t.controllers.set(n,r),t.signatures.set(n,ht(n)),we.set(n,r),e.push(r))}return e},yt=()=>{const t=Array.from(re);re.clear();const e=[];for(const n of t)n.disposed||(wt(n),e.push(...On(n)));gt(e);for(const n of e)In(n)},Wn=()=>{Q===null&&(Q=window.requestAnimationFrame(()=>{Q=null,Q=window.requestAnimationFrame(()=>{Q=null,yt()})}))},qn=t=>{t.disposed||(wt(t),re.add(t),Wn())},zn=t=>{if(!(t instanceof HTMLElement))return null;const e=we.get(t);if(e)return e;for(const n of re)if(n.container.contains(t))return yt(),we.get(t)??null;return null},Bn=t=>{const e={container:t,controllers:new Map,signatures:new Map,disposed:!1},n=()=>qn(e),r=()=>{e.disposed=!0,re.delete(e);for(const i of e.controllers.values())i.cleanup();e.controllers.clear(),e.signatures.clear()};return n(),{refresh:n,cleanup:r}},$n={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image"},At="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",oe=(t,e)=>{const n=$n[e],r=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","remixicon size-3.5"),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true");const i=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");i.setAttribute("href",`#oc-${n}`),r.appendChild(i),t.replaceChildren(r)},Hn=t=>{for(const e of Array.from(t.querySelectorAll('[data-openchamber-markdown-image-label="true"]'))){if(e.querySelector("[data-openchamber-markdown-image-label-icon]"))continue;const n=document.createElement("span");n.className="inline-flex shrink-0",n.setAttribute("aria-hidden","true"),n.setAttribute("data-openchamber-markdown-image-label-icon","true"),oe(n,"image"),e.prepend(n)}},W=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=At,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),oe(r,t),r},vt=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),i=t.querySelector("pre"),o=t.querySelector("pre code"),s=t.querySelectorAll("[data-md-code-line-content]"),a=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),i?.classList.toggle("whitespace-pre-wrap",e),i?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),i&&(i.style.whiteSpace=e?"pre-wrap":"pre",i.style.overflowWrap=e?"anywhere":"normal"),o&&(o.style.whiteSpace=e?"pre-wrap":"pre",o.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(s))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(a){const l=e?n.disableCodeWrap:n.enableCodeWrap;a.setAttribute("title",l),a.setAttribute("aria-label",l),a.classList.toggle("text-foreground",e),a.classList.toggle("opacity-100",e),a.classList.toggle("text-muted-foreground",!e),a.classList.toggle("opacity-65",!e),a.setAttribute("aria-pressed",e?"true":"false")}},kt=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;t.removeAttribute("data-md-gutter-reserved");const n=e.textContent??"",r=n.endsWith(`
|
|
2
|
-
`),i=r?n.slice(0,-1).split(`
|
|
3
|
-
`):n.split(`
|
|
4
|
-
`),o=i.length>0?i:[""],s=Array.from(e.children).filter(c=>c.classList.contains("line"));r&&s.length===o.length+1&&s.at(-1)?.textContent===""&&s.pop();const a=s.length===o.length,l=document.createDocumentFragment();o.forEach((c,u)=>{const g=document.createElement("span");g.setAttribute("data-md-code-line","");const p=document.createElement("span");p.setAttribute("data-md-code-line-number",String(u+1)),p.setAttribute("aria-hidden","true");const h=document.createElement("span");if(h.setAttribute("data-md-code-line-content",""),a){const m=s[u];m&&h.append(...Array.from(m.childNodes))}else h.textContent=c;if(g.append(p,h),l.appendChild(g),u<o.length-1||r){const m=document.createElement("span");m.setAttribute("data-md-code-line-break",""),m.textContent=`
|
|
5
|
-
`,l.appendChild(m)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",r)},Et=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const n=e.map(r=>r.textContent??"").join(`
|
|
6
|
-
`);return t.hasAttribute("data-md-code-trailing-newline")?`${n}
|
|
7
|
-
`:n},He=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const i of Array.from(r)){const o=i.querySelector("pre");o&&kt(o),vt(i,e,n)}},Ve=(t,e,n,r)=>{oe(t,"check"),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{oe(t,n),t.setAttribute("title",r),t.setAttribute("aria-label",r)},2e3)},Vn=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Kn=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const i=r.parentElement;if(!i||i.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],s=r.getAttribute("data-md-lang")??o??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const c=document.createElement("span");c.className="font-mono text-[13px] text-muted-foreground",c.textContent=s;const u=W("copy",e.labels.copy,"copy-code"),g=W("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");l.appendChild(c);const p=document.createElement("div");p.className="flex items-center gap-1",p.setAttribute("data-md-code-actions",""),p.appendChild(g),p.appendChild(u),l.appendChild(p);const h=document.createElement("div");h.setAttribute("data-md-code-body",""),h.className="px-3 py-2.5 overflow-x-auto",i.replaceChild(a,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync?r.setAttribute("data-md-gutter-reserved",""):kt(r),h.appendChild(r),a.appendChild(l),a.appendChild(h),vt(a,e.codeBlockLineWrap,e.labels)}},Ke=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const i=t.querySelectorAll("tbody tr");for(const o of Array.from(i)){const s=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());s.length>0&&n.push(s)}return{headers:e,rows:n}},jn=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,je=({headers:t,rows:e})=>[t,...e].map(n=>n.map(jn).join(",")).join(`
|
|
8
|
-
`),Un=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
|
|
9
|
-
`),Ue=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,i=e.map(o=>`| ${o.join(" | ")} |`).join(`
|
|
10
|
-
`);return`${n}
|
|
11
|
-
${r}
|
|
12
|
-
${i}`},Ze=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${jt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const i=document.createElement("button");i.type="button",i.className=`w-full text-left ${Ut}`,i.setAttribute("data-md-action",`${t}-${r.key}`),i.textContent=r.label,n.appendChild(i)}return n},Zn=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const s=document.createElement("div");s.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(W("copy",e.copyTable,"table-copy-toggle")),a.appendChild(Ze("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(W("download",e.downloadTable,"table-download-toggle")),l.appendChild(Ze("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),s.appendChild(a),s.appendChild(l);const c=document.createElement("div");c.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const u=r.parentElement;if(!u)continue;u.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(r.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const g=r.querySelector("tbody tr:last-child");g?.classList.remove("border-b"),g?.classList.add("border-0");for(const p of Array.from(r.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(r.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");c.appendChild(r),o.appendChild(s),o.appendChild(c)}},Xn=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const i=r.parentElement;if(!i)continue;const o=(r.textContent??"").replace(/\s+$/,""),s=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.setAttribute("data-md-source",o),a.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const c=document.createElement("div");if(c.setAttribute("data-markdown","mermaid-toolbar"),c.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",s.svg){a.setAttribute("data-mermaid-render","svg");const g=document.createElement("div");g.setAttribute("data-markdown","mermaid-viewport");const p=document.createElement("div");if(p.setAttribute("data-markdown","mermaid"),p.setAttribute("data-md-original-svg",s.svg),p.innerHTML=s.svg,g.appendChild(p),l.appendChild(g),e.mermaidControls.showPanZoomControls&&(c.appendChild(W("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),c.appendChild(W("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),c.appendChild(W("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const h=W("copy",e.labels.copyDiagram,"mermaid-copy");h.setAttribute("data-md-source",o),c.appendChild(h)}if(e.mermaidControls.download){const h=W("download",e.labels.downloadDiagram,"mermaid-download");h.setAttribute("data-md-svg","1"),c.appendChild(h)}}else{a.setAttribute("data-mermaid-render","ascii");const g=document.createElement("pre");if(g.setAttribute("data-markdown","mermaid-ascii"),g.textContent=s.ascii||o,l.appendChild(g),e.mermaidControls.copy){const p=W("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",s.ascii||o),c.appendChild(p)}}a.appendChild(l),a.appendChild(c);const u=i.parentElement;u&&u.replaceChild(a,i)}},Gn=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const i=r.getAttribute("href")??"";if(!it(i))continue;r.setAttribute("data-md-link-decorated","true");const o=Vt(i);if(o){const s=document.createElement("span");s.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>s.remove(),{once:!0}),s.appendChild(a),r.parentNode?.insertBefore(s,r)}if(e.onPreviewLoopback&&Kt(i)){const s=document.createElement("button");s.type="button",s.className=`ml-1 align-middle ${At}`,s.setAttribute("data-md-action","preview-loopback"),s.setAttribute("data-md-url",i),s.setAttribute("title",e.labels.previewTitle),s.setAttribute("aria-label",e.labels.previewLabel),oe(s,"download"),r.parentNode?.insertBefore(s,r.nextSibling)}}},me=(t,e)=>{Hn(t),Vn(t),Xn(t,e),Kn(t,e),Zn(t,e.labels),Gn(t,e)},Xe=(t,e,n)=>{const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)},pe=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},Ge=t=>(t.nodeType===1?t:t.parentElement)?.closest("pre code[data-md-code-lines]")??null,Yn=t=>{const e=Ge(t.startContainer);return!e||e!==Ge(t.endContainer)?null:t.toString()},fe=new WeakMap,Jn=t=>{let e=fe.get(t);if(!e){const n=()=>{const o=t.getSelection();return!o||o.rangeCount!==1||o.isCollapsed?null:Yn(o.getRangeAt(0))},r=o=>{if(!o.clipboardData)return;const s=n();s!==null&&(o.preventDefault(),o.stopPropagation(),o.clipboardData.setData("text/plain",s))},i=o=>{const s=n();s!==null&&(o.preventDefault(),be(s))};e={registrations:0,handler:r,menuHandler:i},fe.set(t,e),t.addEventListener("copy",r,!0),t.defaultView?.addEventListener("openchamber:copy",i)}return e.registrations+=1,()=>{const n=fe.get(t);n&&(n.registrations-=1,!(n.registrations>0)&&(t.removeEventListener("copy",n.handler,!0),t.defaultView?.removeEventListener("openchamber:copy",n.menuHandler),fe.delete(t)))}},Qn=(t,e)=>{const n=Jn(t.ownerDocument),r=i=>{const o=i.target;if(!(o instanceof Element))return;const s=o.closest("[data-md-action]");if(!s){pe(t);return}const a=s.getAttribute("data-md-action")??"";if(a==="copy-code"){const l=s.closest('[data-component="markdown-code"]')?.querySelector("code"),c=l?Et(l):"";c&&(s.setAttribute("data-md-copy-pending",""),be(c).then(()=>Ve(s,e.labels.copied,"copy",e.labels.copy)).finally(()=>s.removeAttribute("data-md-copy-pending")));return}if(a==="toggle-code-wrap"){i.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(a==="table-copy-toggle"||a==="table-download-toggle"){i.preventDefault();const l=s.parentElement?.querySelector("[data-md-menu]")??null,c=l?.classList.contains("hidden")??!1;pe(t),l&&c&&l.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const l=a.replace("table-copy-",""),c=s.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=Ke(c),g=l==="csv"?je(u):l==="tsv"?Un(u):Ue(u);be(g)}pe(t);return}if(a.startsWith("table-download-")){const l=a.replace("table-download-",""),c=s.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=Ke(c),g=l==="csv"?je(u):Ue(u);Xe(l==="csv"?"table.csv":"table.md",g,l==="csv"?"text/csv":"text/markdown")}pe(t);return}if(a==="mermaid-copy"){const l=s.getAttribute("data-md-source")??"";l&&be(l).then(()=>Ve(s,e.labels.copied,"copy",e.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){i.preventDefault();const l=s.closest('[data-markdown="mermaid-block"]'),c=zn(l);a==="mermaid-zoom-in"?c?.zoomIn():a==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(a==="mermaid-download"){const l=s.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=l?.getAttribute("data-md-original-svg")??l?.innerHTML??"";c&&Xe("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){i.preventDefault();const l=s.getAttribute("data-md-url")??"";l&&e.onPreviewLoopback?.(l);return}};return t.addEventListener("click",r),()=>{n(),t.removeEventListener("click",r)}},Ye=(t,e,n)=>{let r=0;for(const o of t){const s=r+o.data.length;if(e<s||e===s&&n==="left")return{node:o,offset:Math.max(0,e-r)};r=s}const i=t.at(-1);return i?{node:i,offset:i.data.length}:null},er=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Je=Array.from(er).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ct=t=>Zt(t),tr=t=>Xt(t),nr=t=>{let e;try{e=new URL(t.trim())}catch{return null}if(e.protocol!=="file:"||e.hostname&&e.hostname!=="localhost")return null;try{const n=decodeURIComponent(e.pathname);return/^\/[A-Za-z]:\//.test(n)?n.slice(1):n.startsWith("/")?n:null}catch{return null}},ye=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},he=t=>{let e=ye(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const i=Je.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Je})):.*$`,"i")):null;return i&&(e=i[1]??e),ye(e)},St=t=>{const e=ye(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?ye(e.slice(0,n)):e;if(!r)return null;const i=r.match(/^(.*?):(\d+)-(\d+)$/);if(i){const l=he(i[1]??""),c=Number.parseInt(i[2]??"",10),u=Number.parseInt(i[3]??"",10);return!l||!Number.isFinite(c)||!Number.isFinite(u)||u<c?null:{path:l,line:c,endLine:u}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=he(o[1]??""),c=Number.parseInt(o[2]??"",10),u=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(u??Number.NaN)?u:void 0}}const s=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(s){const l=he(s[1]??""),c=Number.parseInt(s[2]??"",10),u=s[3]?Number.parseInt(s[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(u??Number.NaN)?u:void 0}}const a=he(r);return a?{path:a}:null},Ne=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,rr=4,or=1e3,ir=200,z=new Map;let ge=0;const Qe=[],sr=()=>ut()?ir:or,ar=(t,e)=>`${t}\0${e}`,lr=(t,e)=>{const n=Ct(t);if(!n)return Promise.resolve(!1);const r=ar(e,n),i=z.get(r);if(i)return z.delete(r),z.set(r,i),i;const o=new Promise(a=>{const l=()=>{ge+=1,on(`/api/fs/stat?path=${encodeURIComponent(n)}&optional=true`,{method:"GET",cache:"no-store",headers:e?{"x-opencode-directory":e}:void 0}).then(async c=>{if(!c.ok){a(!1);return}const u=await c.json().catch(()=>null);a(u?.exists!==!1)}).catch(()=>a(!1)).finally(()=>{ge=Math.max(0,ge-1),Qe.shift()?.()})};if(ge<rr){l();return}Qe.push(l)}),s=sr();for(;z.size>=s;){const a=z.keys().next().value;if(typeof a!="string")break;z.delete(a)}return z.set(r,o),o},cr={maxSessions:8,maxEntriesPerSession:4};class dr{maxSessions;maxEntriesPerSession;sessions=new Map;constructor(e=cr){this.maxSessions=Math.max(1,e.maxSessions),this.maxEntriesPerSession=Math.max(1,e.maxEntriesPerSession)}store(e){const n=e.scope,r=e.id;let i=this.sessions.get(n);for(i===void 0?(i=new Map,this.sessions.set(n,i)):this.refreshSession(n,i),i.delete(r),i.set(r,e);i.size>this.maxEntriesPerSession;)this.removeOldestEntry(i);for(;this.sessions.size>this.maxSessions;)this.removeOldestSession()}take(e){const n=e.scope,r=this.sessions.get(n);if(!r)return null;const i=e.id;this.refreshSession(n,r);const o=r.get(i);return o===void 0||o.locale!==e.locale||o.directory!==e.directory?null:(r.delete(i),r.size===0&&this.sessions.delete(n),o.fragment)}clear(){this.sessions.clear()}stats(){let e=0;for(const n of this.sessions.values())e+=n.size;return{sessions:this.sessions.size,entries:e}}refreshSession(e,n){this.sessions.delete(e),this.sessions.set(e,n)}removeOldestEntry(e){const n=e.keys().next().value;n!==void 0&&e.delete(n)}removeOldestSession(){const e=this.sessions.keys().next().value;e!==void 0&&this.sessions.delete(e)}}const et=new dr,Lt=()=>{const t=ie.c(4),e=Gt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Oe(!1),t[0]=n):n=t[0];const r=n;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=Oe(!0),t[1]=i):i=t[1];const o=i;let s;return t[2]!==e?.currentTheme?(s=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=s):s=t[3],s},Mt=t=>{const e=ie.c(4),{containerRef:n,enabled:r}=t;let i,o;e[0]!==n||e[1]!==r?(i=()=>{const s=n.current;if(s)return hn(s,{allowExternalHttp:r!==!1,openAppLink:_r,openExternalHttp:Tr})},o=[n,r],e[0]=n,e[1]=r,e[2]=i,e[3]=o):(i=e[2],o=e[3]),E.useEffect(i,o)},J={download:!0,copy:!0,showPanZoomControls:!0},Nt=!0,ur=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},tt='[data-openchamber-file-link="true"]',Rt="data-openchamber-block-path-token",_t=`[${Rt}]`,G="data-openchamber-block-paths-scanned",mr=2e5,pr=80,fr=40,nt=160,hr=()=>ut()?fr:pr,gr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Tt=t=>Ct(t),br=t=>tr(t),wr=(t,e)=>en(t,e),yr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},xt=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=Tt(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return gr.has(r)||r.startsWith(".")&&r.length>1?!0:yr(e)},Pt=t=>{const e=St(t);return e?xt(e.path):!1},Ar=t=>{const e=t.querySelectorAll(_t);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${G}]`);for(const r of Array.from(n))r.removeAttribute(G),r.normalize()},Re=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim(),n=e?nr(e):null;if(n)return n;if(e&&Pt(e))return e}return(t.textContent||"").trim()},vr=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(G)==="true")continue;if((r.textContent??"").length>mr){r.setAttribute(G,"true");continue}const i=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let s=i.nextNode();for(;s;){const u=s;u.parentElement?.closest("[data-md-code-line-number]")||o.push(u),s=i.nextNode()}const a=Et(r);if(!a.includes(".")){r.setAttribute(G,"true");continue}Ne.lastIndex=0;const l=[];let c=Ne.exec(a);for(;c;){const u=c[0];u&&Pt(u)&&l.push({start:c.index,end:c.index+u.length,raw:u}),c=Ne.exec(a)}for(const{start:u,end:g,raw:p}of l.reverse()){const h=Ye(o,u,"right"),m=Ye(o,g,"left");if(!h||!m)continue;const f=n.createRange();f.setStart(h.node,h.offset),f.setEnd(m.node,m.offset);const A=n.createElement("span");A.setAttribute(Rt,"true"),A.textContent=p,f.deleteContents(),f.insertNode(A)}r.setAttribute(G,"true")}},_e=(t,e)=>{const n=St(t);if(!n||!xt(n.path))return null;const r=br(n.path)?Tt(n.path):wr(e,n.path);return r?{...n,resolvedPath:r}:null},kr=(t,e)=>t||Qt(t,e),It=({containerRef:t,effectiveDirectory:e,editor:n,preferRuntimeEditor:r,enabled:i})=>{const o=E.useRef(null);E.useEffect(()=>{const s=t.current;if(!s||i&&!e)return;let a=!1;const l=hr(),c=i&&!dn(),u=d=>{d.removeAttribute("data-openchamber-file-link"),d.removeAttribute("data-openchamber-file-ref"),d.removeAttribute("data-openchamber-file-path"),d.getAttribute("title")==="Open file"&&d.removeAttribute("title"),d.tagName.toLowerCase()!=="a"&&(d.removeAttribute("role"),d.removeAttribute("tabindex"))},g=()=>{const d=s.querySelectorAll(tt);for(const y of Array.from(d))u(y);Ar(s)};if(!c){g();return}const p=(d=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){h();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{a||h()})},d)},h=()=>{w+=1;try{m()}finally{queueMicrotask(()=>{w-=1})}},m=()=>{c&&vr(s);const d=s.querySelectorAll(`[data-markdown="inline-code"], a, ${_t}`);let y=0;for(const b of Array.from(d)){const L=Re(b),C=_e(L,e);if(u(b),!C||y>=l)continue;y+=1,(ln()&&cn()&&!De(C.resolvedPath,e)?Promise.resolve(!0):lr(C.resolvedPath,e)).then(x=>{if(a||!x||!s.contains(b))return;const _=Re(b),P=_e(_,e);!P||P.resolvedPath!==C.resolvedPath||(b.setAttribute("data-openchamber-file-link","true"),b.setAttribute("data-openchamber-file-ref",_),b.setAttribute("data-openchamber-file-path",P.resolvedPath),b.setAttribute("title","Open file"),b.tagName.toLowerCase()!=="a"&&(b.setAttribute("role","button"),b.setAttribute("tabindex","0")))})}},f=async d=>{const y=d.getAttribute("data-openchamber-file-ref")||Re(d),b=_e(y,e);if(!b)return;const L=kr(e,b.resolvedPath);if(r&&n){n.openFile(b.resolvedPath,Number.isFinite(b.line??Number.NaN)?Math.max(1,Math.trunc(b.line)):void 0,Number.isFinite(b.column??Number.NaN)?Math.max(1,Math.trunc(b.column)):void 0);return}De(b.resolvedPath,e)||await Jt(b.resolvedPath,e);const C=X.getState();Number.isFinite(b.line??Number.NaN)?C.openContextFileAtLine(L,b.resolvedPath,Math.max(1,Math.trunc(b.line)),Number.isFinite(b.column??Number.NaN)?Math.max(1,Math.trunc(b.column)):1):C.openContextFile(L,b.resolvedPath)},A=d=>{const y=d.target;if(!(y instanceof Element))return;const b=y.closest(tt);b instanceof HTMLElement&&(d.preventDefault(),d.stopPropagation(),f(b))},v=d=>{if(d.key!=="Enter"&&d.key!==" ")return;const y=d.target;!(y instanceof HTMLElement)||y.getAttribute("data-openchamber-file-link")!=="true"||(d.preventDefault(),d.stopPropagation(),f(y))};p(nt);let w=0;const k=new MutationObserver(()=>{w>0||p(nt)});return k.observe(s,{childList:!0,subtree:!0}),s.addEventListener("click",A),s.addEventListener("keydown",v),()=>{a=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,k.disconnect(),s.removeEventListener("click",A),s.removeEventListener("keydown",v)}},[t,n,e,r,i])},Ft=t=>{const e=ie.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:i,enablePanZoom:o,allowMermaidWheelEvents:s}=t;let a,l;e[0]!==s||e[1]!==n||e[2]!==i||e[3]!==o||e[4]!==r?(a=()=>{const c=n.current;if(!c)return;const u=p=>{if(!i||!r)return;const h=p.target;if(!(h instanceof Element)||h.closest('button, a, [role="button"]'))return;const m=h.closest(ne);if(!m)return;if(m instanceof HTMLElement&&m.hasAttribute("data-mermaid-suppress-click")){m.removeAttribute("data-mermaid-suppress-click");return}const A=Array.from(c.querySelectorAll(ne)).indexOf(m);if(A<0)return;const v=m instanceof HTMLElement?m.getAttribute("data-md-source"):null;if(!v||v.trim().length===0)return;const w=`Diagram ${A+1}`;r({open:!0,title:w,content:"",metadata:{tool:"mermaid-preview",filename:w},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(v)}`,source:v,filename:w}})},g=p=>{if(s||(p.ctrlKey||p.metaKey)&&o)return;const h=p.target;!(h instanceof Element)||!h.closest(ne)||p.stopPropagation()};return c.addEventListener("click",u),c.addEventListener("wheel",g,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",u),c.removeEventListener("wheel",g,!0)}},l=[s,n,i,o,r],e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=r,e[5]=a,e[6]=l):(a=e[5],l=e[6]),E.useEffect(a,l)},B=new Map,Er=100,$="data-md-decoration-id",Cr=(t,e,n)=>{const r=t.children;if(r.length!==e.length)return!1;for(let i=0;i<e.length;i+=1){const o=r[i];if(!o||o.getAttribute("data-md-id")!==e[i]?.id||o.getAttribute($)!==n)return!1}return!0},rt=new WeakMap;let ot=0;const Sr=2e5,Te=t=>{const e=rt.get(t);if(e)return e;const n=`decoration-${ot}`;return ot+=1,rt.set(t,n),n},Lr=(t,e)=>{const n=B.get(t);if(n)return B.delete(t),B.set(t,n),n;const r=e();if(B.set(t,r),B.size>Er){const i=B.keys().next().value;i&&B.delete(i)}return r},Mr=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),Dt=(t,e,n,r=J)=>{const{t:i}=ct(),o=E.useMemo(()=>({copy:i("markdownRenderer.code.actions.copyTitle"),copied:i("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:i("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:i("markdownRenderer.code.actions.disableWrapTitle"),copyTable:i("markdownRenderer.table.actions.copyTitle"),downloadTable:i("markdownRenderer.table.actions.downloadTitle"),copyDiagram:i("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:i("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:i("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:i("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:i("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:i("terminalView.preview.open"),previewTitle:i("terminalView.preview.openTitle")}),[i]),s=X(c=>c.codeBlockLineWrap),a=X(c=>c.setCodeBlockLineWrap),l=E.useCallback(()=>{a(!X.getState().codeBlockLineWrap)},[a]);return E.useMemo(()=>{const c=Mr(t),u=X.getState().mermaidRenderingMode,g=t.metadata?.id??"theme";return{labels:o,mermaidControls:r,codeBlockLineWrap:s,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:h=>Lr(`${g}:${u}:${h}`,()=>{try{return u==="ascii"?{ascii:Bt(h)}:{svg:$t(h,c)}}catch{return{}}}),onPreviewLoopback:n}},[t,o,r,s,e,l,n])},Ot=({containerRef:t,text:e,streaming:n,imageMode:r="inline",syntaxVars:i,ctx:o,domCacheKey:s})=>{E.useEffect(()=>{bn()},[]);const a=E.useRef(null),l=E.useRef(0),c=E.useContext(Yt),u=E.useRef(null),g=E.useCallback(()=>{u.current?.(),u.current=null},[]);E.useEffect(()=>g,[g]);const p=E.useRef(null),h=E.useCallback(()=>{const m=t.current;if(m){if(!a.current){if(!I(m))return;a.current=Bn(m);return}a.current.refresh()}},[t]);E.useLayoutEffect(()=>{l.current+=1,p.current=null},[o,r,n,e]),E.useLayoutEffect(()=>{if(!s)return;const m=t.current,f=m?.querySelector("[data-markdown-content]")??m;if(!f||f.childNodes.length>0)return;const A=et.take(s);if(A){f.appendChild(A);const v=Te(o);for(const w of Array.from(f.children))w.setAttribute($,v);for(const[w,k]of Object.entries(i))f.style.setProperty(w,k);He(f,o.codeBlockLineWrap,o.labels),p.current={key:s,copiedLabel:o.labels.copied},te("ui.markdown_renderer.dom_cache.hit")}},[t,o,s,i,e.length]),E.useLayoutEffect(()=>{const m=t.current,f=m?.querySelector("[data-markdown-content]")??m;if(f)return()=>{const A=p.current;if(!A||f.childNodes.length===0||I(f)||Array.from(f.children).some(y=>!y.hasAttribute("data-md-id"))||f.querySelector("[data-md-copy-pending]"))return;const v=window.getSelection();if(v?.rangeCount&&!v.isCollapsed&&v.getRangeAt(0).intersectsNode(f))return;const w=f.querySelector("[data-md-menu]:not(.hidden)"),k=Array.from(f.querySelectorAll("[data-md-action]")).some(y=>y.getAttribute("title")===A.copiedLabel);if(w||k)return;const d=document.createDocumentFragment();d.append(...Array.from(f.childNodes)),et.store({...A.key,fragment:d}),te("ui.markdown_renderer.dom_cache.capture")}},[t]),E.useLayoutEffect(()=>{const m=t.current,f=m?.querySelector("[data-markdown-content]")??m;if(!f)return;const A=Te(o);if(e&&f.childNodes.length===0){const v=n?null:We(e,r);if(v){let w=!1;for(const k of v){const d=document.createElement("div");d.setAttribute("data-md-block",""),d.style.display="contents",d.innerHTML=k.html,me(d,o),d.setAttribute("data-md-id",k.id),d.setAttribute($,A),w||=I(d),f.appendChild(d)}w&&h()}else{!n&&!u.current&&(u.current=c?.hold()??null);const w=document.createElement("div");w.setAttribute("data-md-block",""),w.style.display="contents",w.innerHTML=un(e,r),me(w,o),w.setAttribute($,A),f.appendChild(w),I(w)&&h()}}else!a.current&&I(f)&&h()},[t,e,n,r,o,h,c]),E.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),E.useEffect(()=>{const m=t.current;if(!m)return;const f=m.querySelector("[data-markdown-content]")??m;let A=!0;const v=l.current,w=Te(o);if(!n){const k=We(e,r);if(k&&Cr(f,k,w)){p.current=s?{key:s,copiedLabel:o.labels.copied}:null,te("ui.markdown_renderer.settled_paint.reused"),g();return}}return mn(e,n,r).then(k=>{if(!A||l.current!==v)return;const d=Array.from(f.children);let y=0;k.forEach((C,T)=>{let M=d[T],x=!1;if(M||(M=document.createElement("div"),M.setAttribute("data-md-block",""),M.style.display="contents",f.appendChild(M),x=!0),M.getAttribute("data-md-id")===C.id){if(M.getAttribute($)!==w){const N=I(M);N&&(a.current?.cleanup(),a.current=null);const S=document.createElement("div");S.setAttribute("data-md-block",""),S.style.display="contents",S.innerHTML=C.html,me(S,o),S.setAttribute("data-md-id",C.id),S.setAttribute($,w),M.replaceWith(S),(N||I(S))&&h()}!a.current&&I(M)&&h();return}const _=document.createElement("div");if(_.innerHTML=C.html,me(_,o),x&&n&&T>0){const N=Math.min(y,4)*55;y+=1;for(const S of Array.from(_.children))S.classList.add("oc-md-block-enter"),N>0&&S instanceof HTMLElement&&S.style.setProperty("--oc-md-enter-delay",`${N}ms`)}const P=I(M),F=I(_);zt(M,_,{childrenOnly:!0,onBeforeElUpdated:(N,S)=>!N.isEqualNode(S)}),M.setAttribute("data-md-id",C.id),M.setAttribute($,w),(P||F||I(M))&&h()});const b=I(f);let L=!1;for(let C=d.length-1;C>=k.length;C-=1){const T=d[C];T&&I(T)&&(L=!0),T?.remove()}(L||d.length>k.length&&b)&&h(),p.current=s?{key:s,copiedLabel:o.labels.copied}:null,g()}),()=>{A=!1}},[t,o,s,r,h,g,n,e]),E.useEffect(()=>{const m=t.current;if(m)return Qn(m,o)},[t,o]),E.useEffect(()=>{const m=t.current,f=m?.querySelector("[data-markdown-content]")??m;if(f)for(const[A,v]of Object.entries(i))f.style.setProperty(A,v)},[t,i]),E.useEffect(()=>{const m=t.current,f=m?.querySelector("[data-markdown-content]")??m;f&&(o.deferCodeLineNumberSync||He(f,o.codeBlockLineWrap,o.labels))},[t,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels])},Wt=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Nr=t=>{const e=ie.c(39),{content:n,part:r,messageId:i,isAnimated:o,skipFadeIn:s,className:a,isStreaming:l,disableStreamAnimation:c,variant:u,onShowPopup:g,enableFileReferences:p}=t,h=o===void 0?!0:o,m=s===void 0?!1:s,f=l===void 0?!1:l,A=c===void 0?!1:c,v=u===void 0?"assistant":u,w=p===void 0?!0:p;te("ui.markdown_renderer.render"),f&&te("ui.markdown_renderer.render.streaming"),sn("ui.markdown_renderer.content_len",n.length);const k=Lt(),{editor:d,runtime:y}=st(),b=E.useRef(null),L=at()??"",C=X(xr);let T;e[0]!==L||e[1]!==C?(T=O=>{L&&C(L,O)},e[0]=L,e[1]=C,e[2]=T):T=e[2];const M=T,x=f&&!A;let _;e[3]!==g?(_={containerRef:b,onShowPopup:g,enableFullscreen:Nt,enablePanZoom:J.showPanZoomControls},e[3]=g,e[4]=_):_=e[4],Ft(_);const P=w&&!f;let F;e[5]!==d||e[6]!==L||e[7]!==y.isVSCode||e[8]!==P?(F={containerRef:b,effectiveDirectory:L,editor:d,preferRuntimeEditor:y.isVSCode,enabled:P},e[5]=d,e[6]=L,e[7]=y.isVSCode,e[8]=P,e[9]=F):F=e[9],It(F);let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N={containerRef:b},e[10]=N):N=e[10],Mt(N);let S;e[11]!==k?(S=lt(k),e[11]=k,e[12]=S):S=e[12];const D=S,q=Dt(k,x,L?M:void 0,J),{locale:Ae}=ct(),se=v==="assistant"?"label":"inline",ve=r&&(r.type==="text"||r.type==="reasoning")&&r.time?.end!==void 0?r:null;let ae;e[13]===Symbol.for("react.memo_cache_sentinel")?(ae=an(),e[13]=ae):ae=e[13];const qt=ae,Pe=ve?.sessionID,Ie=ve?.messageID,Fe=ve?.id;let ke;e:{if(f||!Pe||!Ie||!Fe||n.length===0||n.length>Sr){ke=null;break e}const O=`${qt}\0${Pe}`,Se=`${Ie}\0${Fe}\0${se}\0${n.length}`;let ue;e[14]!==L||e[15]!==Ae||e[16]!==O||e[17]!==Se?(ue={scope:O,id:Se,locale:Ae,directory:L},e[14]=L,e[15]=Ae,e[16]=O,e[17]=Se,e[18]=ue):ue=e[18],ke=ue}const Ee=ke,Ce=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`;let le;e[19]!==n||e[20]!==q||e[21]!==Ee||e[22]!==se||e[23]!==x||e[24]!==D?(le={containerRef:b,text:n,streaming:x,imageMode:se,syntaxVars:D,ctx:q,domCacheKey:Ee},e[19]=n,e[20]=q,e[21]=Ee,e[22]=se,e[23]=x,e[24]=D,e[25]=le):le=e[25],Ot(le);let K;e[26]!==a?(K=dt("break-words w-full min-w-0",a),e[26]=a,e[27]=K):K=e[27];let j;e[28]!==v?(j=Wt(v),e[28]=v,e[29]=j):j=e[29];let U;e[30]!==j?(U=ee.jsx("div",{className:j,"data-markdown-content":!0}),e[30]=j,e[31]=U):U=e[31];let ce;e[32]!==K||e[33]!==U?(ce=ee.jsx("div",{className:K,ref:b,children:U}),e[32]=K,e[33]=U,e[34]=ce):ce=e[34];const de=ce;if(h){let O;return e[35]!==Ce||e[36]!==de||e[37]!==m?(O=ee.jsx(tn,{skipAnimation:m,children:de},Ce),e[35]=Ce,e[36]=de,e[37]=m,e[38]=O):O=e[38],O}return de},Di=E.memo(Nr,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Rr=t=>{const e=ie.c(29),{content:n,className:r,variant:i,disableLinkSafety:o,stripFrontmatter:s,onShowPopup:a,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:u}=t,g=i===void 0?"assistant":i,p=s===void 0?!1:s,h=l===void 0?J:l,m=c===void 0?!1:c,f=u===void 0?!0:u,{editor:A,runtime:v}=st(),w=Lt(),k=E.useRef(null),d=at()??"";let y;e[0]!==n||e[1]!==p?(y=p?ur(n):n,e[0]=n,e[1]=p,e[2]=y):y=e[2];const b=y;let L;e[3]!==m||e[4]!==h.showPanZoomControls||e[5]!==a?(L={containerRef:k,onShowPopup:a,enableFullscreen:Nt,enablePanZoom:h.showPanZoomControls,allowMermaidWheelEvents:m},e[3]=m,e[4]=h.showPanZoomControls,e[5]=a,e[6]=L):L=e[6],Ft(L);let C;e[7]!==A||e[8]!==d||e[9]!==f||e[10]!==v.isVSCode?(C={containerRef:k,effectiveDirectory:d,editor:A,preferRuntimeEditor:v.isVSCode,enabled:f},e[7]=A,e[8]=d,e[9]=f,e[10]=v.isVSCode,e[11]=C):C=e[11],It(C);const T=!o;let M;e[12]!==T?(M={containerRef:k,enabled:T},e[12]=T,e[13]=M):M=e[13],Mt(M);let x;e[14]!==w?(x=lt(w),e[14]=w,e[15]=x):x=e[15];const _=x,P=Dt(w,!1,void 0,h);let F;e[16]!==P||e[17]!==b||e[18]!==_?(F={containerRef:k,text:b,streaming:!1,syntaxVars:_,ctx:P},e[16]=P,e[17]=b,e[18]=_,e[19]=F):F=e[19],Ot(F);let N;e[20]!==r?(N=dt("break-words w-full min-w-0",r),e[20]=r,e[21]=N):N=e[21];let S;e[22]!==g?(S=Wt(g),e[22]=g,e[23]=S):S=e[23];let D;e[24]!==S?(D=ee.jsx("div",{className:S,"data-markdown-content":!0}),e[24]=S,e[25]=D):D=e[25];let q;return e[26]!==N||e[27]!==D?(q=ee.jsx("div",{className:N,ref:k,children:D}),e[26]=N,e[27]=D,e[28]=q):q=e[28],q},Oi=E.memo(Rr,(t,e)=>{const n=t.mermaidControls??J,r=e.mermaidControls??J;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});function _r(t){nn(t)}function Tr(t){rn(t)}function xr(t){return t.openContextPreview}export{Di as MarkdownRenderer,Oi as SimpleMarkdownRenderer};
|