@openchamber/web 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-C36E738Y.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
- package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
- package/dist/assets/DiffView-D5cvbEPb.js +4 -0
- package/dist/assets/FilesView-DPU8aNPL.js +17 -0
- package/dist/assets/GitView-Ct6xWrVH.js +6 -0
- package/dist/assets/{JsonTreeView-KnXFN2A-.js → JsonTreeView-osju7J70.js} +1 -1
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
- package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
- package/dist/assets/{PatchDiff-BzVOVog8.js → PatchDiff-Dan3mADn.js} +1 -1
- package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
- package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
- package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
- package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
- package/dist/assets/{ToolOutputDialog-BB1c--Zr.js → ToolOutputDialog-DrCa1JRk.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DaOIDISD.js → ToolPartDiffPreview-B_tfvlNF.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-lESMT-2b.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
- package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
- package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
- package/dist/assets/{WalkthroughView-CaSYE0lw.js → WalkthroughView-D9Q4lr5x.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DkRR5b75.js → computeVirtualFileMetrics-Gi1d5eU1.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
- package/dist/assets/de-B_LdJwEM.js +9 -0
- package/dist/assets/es-CubfsAYV.js +15 -0
- package/dist/assets/fr-5qJM0nFS.js +13 -0
- package/dist/assets/index-BW82eK5v.css +1 -0
- package/dist/assets/index-Brm3X9rs.js +1 -0
- package/dist/assets/index-rlLjZUM5.js +7 -0
- package/dist/assets/{isDiffPlainText-BG53Ixxy.js → isDiffPlainText-pH9kAJQH.js} +1 -1
- package/dist/assets/{isFilePlainText-BbV-39jl.js → isFilePlainText-CVKy_dgB.js} +1 -1
- package/dist/assets/ja-DJYIBUlH.js +15 -0
- package/dist/assets/ko-DcUBkB7y.js +15 -0
- package/dist/assets/main-DLBxKIoX.js +926 -0
- package/dist/assets/main-vUCh0VB0.js +2 -0
- package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
- package/dist/assets/{miniChat-ldEghBLB.js → miniChat-BlzGEYgE.js} +2 -2
- package/dist/assets/mobile-CkX6H-IT.js +2 -0
- package/dist/assets/{patchFileDiff-BcFaMtMu.js → patchFileDiff-BCTsE43U.js} +3 -3
- package/dist/assets/pl-rB6BLcio.js +15 -0
- package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
- package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
- package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
- package/dist/assets/{shikiHighlight-DCT2Sq_z.js → shikiHighlight-BgTPSITe.js} +1 -1
- package/dist/assets/uk-INZlFD9A.js +15 -0
- package/dist/assets/{useAppFontEffects-B53Rb6m7.js → useAppFontEffects-Cll4gnsh.js} +170 -180
- package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
- package/dist/assets/{vendor-base-ui-DsHmyMwp.js → vendor-base-ui-_6j2xOWl.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-vch3tJ4c.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
- package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
- package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
- package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
- package/dist/assets/{web-components-pcwCTWjC.js → web-components-DLnGY4fs.js} +4 -4
- package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
- package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +4 -4
- package/server/index.js +8 -0
- package/server/lib/client-auth/pairing.js +8 -7
- package/server/lib/client-auth/pairing.test.js +5 -1
- package/server/lib/client-auth/remote-clients.js +9 -1
- package/server/lib/client-auth/remote-clients.test.js +17 -0
- package/server/lib/github/pr-status.js +10 -1
- package/server/lib/quota/providers/index.js +4 -18
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +34 -2
- package/server/lib/relay/service.test.js +69 -0
- package/server/lib/session-goal/runtime.js +2 -1
- package/server/lib/session-goal/runtime.test.js +4 -2
- package/server/lib/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +29 -1
- package/server/lib/terminal/runtime.test.js +26 -0
- package/server/lib/ui-auth/ui-auth.js +2 -2
- package/server/lib/ui-auth/ui-auth.test.js +2 -2
- package/dist/assets/CommitSection-C-F3AX6D.js +0 -1
- package/dist/assets/DiagramEditor-BPECg1jS.js +0 -1
- package/dist/assets/DiagramView-D0YNMix8.js +0 -1
- package/dist/assets/DiffView-BHWaMYCC.js +0 -4
- package/dist/assets/FilesView-NMBCW2Tm.js +0 -14
- package/dist/assets/GitView-Rp8P1KEI.js +0 -6
- package/dist/assets/MarkdownImageGallery-BMn3mtor.js +0 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +0 -12
- package/dist/assets/OnboardingScreen-CenIeD4v.js +0 -1
- package/dist/assets/PierreDiffViewer-Dlby4XqT.js +0 -136
- package/dist/assets/PlanView-Czu1KMJa.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +0 -1
- package/dist/assets/SettingsView-B6vmuf-c.js +0 -28
- package/dist/assets/SettingsWindow-CauZpdD3.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +0 -1
- package/dist/assets/de-DFdX3ABv.js +0 -9
- package/dist/assets/es-iC-FKvV9.js +0 -15
- package/dist/assets/fr-BBbi_1AL.js +0 -13
- package/dist/assets/index-BiEgzzkg.js +0 -1
- package/dist/assets/index-Cwmuwk3V.js +0 -7
- package/dist/assets/index-GNm1wgUH.css +0 -1
- package/dist/assets/ja-DQLQJL2J.js +0 -15
- package/dist/assets/ko-BeElEB4Y.js +0 -15
- package/dist/assets/main-Dpzo18z7.js +0 -2
- package/dist/assets/main-WMjtYzJs.js +0 -921
- package/dist/assets/markdownCore--tDmyI_v.js +0 -2
- package/dist/assets/mobile-Dk-VGreF.js +0 -2
- package/dist/assets/pl-CLHt2_vV.js +0 -15
- package/dist/assets/pt-BR-C_MPUq7e.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +0 -2
- package/dist/assets/renderMobileApp-CDfHS5rr.js +0 -25
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +0 -15
- package/dist/assets/scheduledTasksApi-BFSlqgnG.js +0 -1
- package/dist/assets/uk-PhsC-c4-.js +0 -15
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +0 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +0 -39
- package/dist/assets/zh-CN-wF-NOFHM.js +0 -15
- package/dist/assets/zh-TW-4m4-A7rT.js +0 -15
- package/server/lib/quota/providers/command-code.js +0 -90
- package/server/lib/quota/providers/command-code.test.js +0 -85
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Brm3X9rs.js","assets/useAppFontEffects-Cll4gnsh.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-rlLjZUM5.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BLfBSgBh.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-BW82eK5v.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-_6j2xOWl.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-CpzVNWAv.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DkQX2EBa.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/computeVirtualFileMetrics-Gi1d5eU1.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isFilePlainText-CVKy_dgB.js","assets/isDiffPlainText-pH9kAJQH.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-Dgg-WTEc.js","assets/shikiHighlight-BgTPSITe.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useInlineCommentController-DFFv0hae.js","assets/CodeMirrorCommentWidgets-C2BopIs3.js","assets/vendor-ghostty-web-CrxinGGH.js","assets/vendor-capacitor-keyboard-CYccoJjr.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Gt}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Ve,r as ae,j as t,R as m}from"./vendor-react-BUCujlKS.js";import{e6 as fo,aO as mo,f as et,o as ho,bz as js,bA as ks,bC as Ss,I as R,bX as po,bT as Dn,h as ie,B as Ne,b7 as pr,g as go,t as ke,e7 as xo,e8 as bo,e9 as yo,O as wo,dQ as vo,ea as jo,eb as ko,ec as So,y as ot,ed as No,l as vt,ee as Co,dq as gr,ef as Io,dr as To,bU as Ns,cL as Po,bB as Ws,b2 as Do,b5 as Eo,b4 as Ro,bj as Us,eg as Ao,eh as Bo,ei as Mo,ej as Lo,ek as Fo,el as Oo,em as $o,en as Wo,b as Ct,c3 as Uo,a0 as En,dm as _o,dK as xr,dz as br,dB as Vo,eo as zo,u as dn,cw as Go,ep as un,S as bt,de as Ho,eq as Rn,er as Ko,es as qo,et as An,eu as Yo,ev as Jo,ew as Qo,ex as Xo,bF as Zo,ey as ea,b0 as $t,aZ as Wt,a$ as Ut,bS as _s,bN as yr,bO as wr,ez as vr,bP as jr,bQ as kr,bR as Ls,L as Sr,N as ta,eA as sa,eB as Bn,eC as na,T as ra,U as oa,R as aa,eD as Nr,eE as ia,eF as la,eG as ca,eH as da,_ as fn,a4 as us,a5 as fs,a6 as ms,cr as mn,cs as hn,ct as pn,cu as gn,cm as Ft,cn as Dt,eI as is,aY as Rt,bw as xn,M as ys,bD as ua,bE as Sn,V as Nn,aq as Fs,c1 as fa,eJ as Cr,bV as ma,dG as ha,ad as Cn,eK as qs,m as Ir,cP as ls,eL as Mn,eM as Ln,cN as Fn,bW as pa,eN as ga,eO as xa,dA as ba,eP as ya,eQ as wa,dZ as Pt,eR as va,eS as ja,Z as Vs,eT as Et,eU as bn,eV as ka,eW as Ps,c8 as Sa,eX as Na,eY as Ca,eZ as Ia,e_ as Ta,e$ as Pa,f0 as Da,d7 as Ea,dj as Ra,cV as Aa,cG as Ba,dk as Ma,ao as La,a9 as Fa,bL as Oa,f1 as Tr,e3 as $a,f2 as Wa,f3 as Ua,f4 as _a,f5 as Va,bI as za,cT as Ga}from"./useAppFontEffects-Cll4gnsh.js";import{ak as On,al as Ha,am as $n,an as Ka,i as qa,ao as Ya,F as Pr,_ as Ja,r as Bt,u as Fe,A as Qa,b as Xa,v as Za,a as Ys,d as Wn,$ as Dr,W as ei,ap as Lt,o as ti,m as Cs,z as Er,a2 as si,a3 as ni,aq as ri,ar as oi,w as cs,U as ai,as as ii,a9 as li,at as ps,au as Js,av as Rr,T as ci,n as di,y as ui}from"./index-rlLjZUM5.js";import{g as fi,h as mi,i as hi,d as pi,C as gi,c as xi,M as bi,S as yi,a as wi,b as vi}from"./vendor-base-ui-_6j2xOWl.js";import{c as zs,d as Ar,p as Br,a as ji}from"./vendor-zustand-BAGL70zf.js";import{i as Mr}from"./contextPanelEmbeddedChat-CpzVNWAv.js";import{f as Lr,h as Fr,P as Or,k as ki,D as $r,j as Wr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Ur,S as _r,h as Si,v as Ni,a as Ci}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Vr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const Ii=["typescript","javascript","tsx","jsx","json","markdown"],zr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Un=null;const Gr=()=>(Un??=Promise.all([Gt(()=>import("./index-Brm3X9rs.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112])),Gt(()=>import("./workerFactory-tw7cIdmV.js"),[]),Gt(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([113,114,100,101,5,85,86,87,88,89,90,91,92,93,94,95,96,97,98]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),Un),ws={},_n=new Set,yn=new Set;let Bs={light:"pierre-light",dark:"pierre-dark"};const Ti=()=>{for(const s of yn)s()},Hr=(s,e)=>{e.setRenderOptions({theme:Bs,lineDiffType:zr[s].lineDiffType})},wn=s=>{typeof window>"u"||_n.has(s)||(_n.add(s),Gr().then(e=>{if(ws[s])return;const n=zr[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Ii,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),ws[s]=r,Hr(s,r),Ti()}))},Pi=s=>(yn.add(s),()=>yn.delete(s)),Di=s=>{if(!(Bs.light===s.light&&Bs.dark===s.dark)){Bs=s;for(const e of Object.keys(ws)){const n=ws[e];n&&Hr(e,n)}}},Pu=s=>{const e=Ve.c(15),{children:n}=s,r=fo();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=On(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=On(!0),e[1]=i):i=e[1];const u=i,c=r?.lightThemeId??a.metadata.id,l=r?.darkThemeId??u.metadata.id;let f;e[2]!==c||e[3]!==r?.availableThemes?(f=r?.availableThemes.find(C=>C.metadata.id===c)??a,e[2]=c,e[3]=r?.availableThemes,e[4]=f):f=e[4];const h=f;let g;e[5]!==l||e[6]!==r?.availableThemes?(g=r?.availableThemes.find(C=>C.metadata.id===l)??u,e[5]=l,e[6]=r?.availableThemes,e[7]=g):g=e[7];const p=g;let d,y;e[8]!==p||e[9]!==h?(d=()=>{let C=!1;return Gr().then(B=>{C||(B.ensurePierreThemeRegistered(h),B.ensurePierreThemeRegistered(p),Di({light:h.metadata.id,dark:p.metadata.id}))}),()=>{C=!0}},y=[p,h],e[8]=p,e[9]=h,e[10]=d,e[11]=y):(d=e[10],y=e[11]),ae.useEffect(d,y);let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[12]=j):j=e[12],ae.useEffect(Ri,j);let I;return e[13]!==n?(I=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=I):I=e[14],I},Du=s=>{const e=Ve.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>ws[n],e[0]=n,e[1]=r):r=e[1];const o=ae.useSyncExternalStore(Pi,r,Ai);let a,i;return e[2]!==n?(a=()=>{wn(n)},i=[n],e[2]=n,e[3]=a,e[4]=i):(a=e[3],i=e[4]),ae.useEffect(a,i),o};function Ei(){wn("unified"),wn("split")}function Ri(){if(typeof window>"u")return;const s=Ei;if(typeof window.requestIdleCallback=="function"){const n=window.requestIdleCallback(s,{timeout:5e3});return()=>window.cancelIdleCallback(n)}const e=window.setTimeout(s,2e3);return()=>window.clearTimeout(e)}function Ai(){}const Vn="openchamber.update-install-id";function Bi(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(Vn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(Vn,e),e}catch{return}}function Mi(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=mo();return s}catch{return"unknown"}}function Li(){const s=typeof window<"u"?window.__OPENCHAMBER_ELECTRON__?.arch?.toLowerCase?.():void 0;if(s==="arm64"||s==="aarch64")return"arm64";if(s==="x64"||s==="amd64"||s==="x86_64")return"x64";const e=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e==="arm64"||e==="aarch64")return"arm64";if(e==="x64"||e==="amd64"||e==="x86_64")return"x64";const r=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(r==="arm"||r==="arm64"||r==="aarch64")return"arm64";if(r==="x86"||r==="x64"||r==="amd64")return"x64";const o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function Fi(){const s=Xa();if(s==="android"||s==="ios")return s;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function Oi(s){const e=Fe.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",Mi()),n.set("arch",Li()),n.set("platform",Fi()),e&&(s==="desktop"||s==="mobile")){const r=Bi();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",Qa()?"local":"remote"),n):s==="vscode"?(n.set("appType","vscode"),n.set("instanceMode","local"),n):s==="mobile"?(n.set("appType","mobile-capacitor"),n.set("instanceMode","remote"),n):(n.set("appType","web"),n.set("instanceMode","unknown"),n)}async function Ds(s,e){try{const n=Oi(s),r=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?n.set("currentVersion",e):s==="vscode"&&r&&n.set("currentVersion",r);const o=await Bt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);const a=await o.json();return{available:a.available??!1,version:a.version,currentVersion:a.currentVersion??"unknown",body:a.body,releaseUrl:a.releaseUrl,downloadUrl:a.downloadUrl,nextSuggestedCheckInSec:typeof a.nextSuggestedCheckInSec=="number"&&Number.isFinite(a.nextSuggestedCheckInSec)?a.nextSuggestedCheckInSec:void 0,packageManager:a.packageManager,updateCommand:a.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function $i(){return qa()?"mobile":Ya()?"desktop":Pr()?"vscode":Ja()?"web":null}const zn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},Wi=zs()((s,e)=>({...zn,checkForUpdates:async()=>{const n=$i();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.21.0",[i,u]=await Promise.allSettled([$n(),Ds("desktop",a)]),c=i.status==="fulfilled"?i.value:null;return o=u.status==="fulfilled"?u.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:c?.available??!1,info:c,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Ds("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Ds("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Ds("mobile","1.21.0"),o=r?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:r?.available??!1,info:n==="vscode"?null:r,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(r){return s({checking:!1,error:r instanceof Error?r.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const o=await $n();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await Ka(i=>{s({progress:i})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(o){s({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:r}=e();if(!(r!=="desktop"||!n))try{if(!await Ha())throw new Error("Desktop restart only works on Local instance")}catch(o){s({error:o instanceof Error?o.message:"Failed to restart"})}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(zn)}})),Gn="https://github.com/openchamber/openchamber/releases";function Ui(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(pr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function _i(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Hn(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function Vi(s,e){const n=s.split(".").map(o=>Number.parseInt(o,10)),r=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(r[o])?r[o]:0;if(a!==i)return i-a}return 0}function zi(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let r;for(;(r=e.exec(s))!==null;)n.push({version:r[1]??"",date:r[2]??"",start:r.index});return n.length===0?[]:n.map((o,a)=>{const i=n[a+1]?.start??s.length,u=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:u}})}const Kn=2e3,Gi=600*1e3;async function Hi(){try{const s=await Bt("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}});return s.ok?{success:!0,autoRestart:(await s.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await s.json().catch(()=>({}))).error||`Server error: ${s.status}`}}catch(s){return{success:!1,error:s instanceof Error?s.message:void 0}}}async function Ki(){try{return(await Bt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function qi(s,e=Math.ceil(Gi/Kn),n=Kn){for(let r=0;r<e;r++){try{const o=await Bt("/api/openchamber/update-check?reportUsage=false",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);if(a&&a.available===!1||a&&typeof a.currentVersion=="string"&&typeof s=="string"&&a.currentVersion!==s)return!0}else if((o.status===401||o.status===403)&&await Ki())return!0}catch{}await new Promise(o=>setTimeout(o,n))}return!1}const Eu=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:u,onRestart:c,runtimeType:l="desktop"})=>{const{t:f}=et(),[h,g]=ae.useState(!1),[p,d]=ae.useState("idle"),[y,j]=ae.useState(null),I=n?.version?n.releaseUrl||`${Gn}/tag/v${n.version}`:Gn,C=n?.downloadUrl||I,B=a?.total?Math.round(a.downloaded/a.total*100):0,$=l==="web",S=l==="mobile",w=n?.updateCommand||"openchamber update";ae.useEffect(()=>{s||(d("idle"),j(null))},[s]);const x=async()=>{(await go(w)).ok&&(g(!0),setTimeout(()=>g(!1),2e3))},N=ae.useCallback(async H=>{await ho(H)},[]),W=ae.useCallback(async()=>{d("updating"),j(null);const H=await Hi();if(!H.success){d("error"),j(H.error||f("updateDialog.error.updateFailed"));return}H.autoRestart&&(d("restarting"),await new Promise(D=>setTimeout(D,2e3))),d("reconnecting"),await qi(n?.currentVersion)?window.location.reload():(d("error"),j(f("updateDialog.error.takingLonger")))},[n?.currentVersion,f]),V=ae.useCallback(()=>{N(C)},[N,C]),F=p!=="idle"&&p!=="error",_=ae.useMemo(()=>{if(!n?.body)return null;const H=n.body.trim();if(!H)return null;const J=zi(H);if(J.length===0)return{kind:"raw",title:f("updateDialog.changelog.title"),content:Hn(H)};const D=[...J].sort((oe,U)=>Vi(oe.version,U.version));return{kind:"sections",title:f("updateDialog.changelog.title"),sections:D.map(oe=>({version:oe.version,dateLabel:Ui(oe.date),content:Hn(_i(oe.raw)||H)}))}},[n?.body,f]);return t.jsx(js,{open:s,onOpenChange:F?void 0:e,children:t.jsxs(ks,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(Ss,{className:"flex items-center gap-2.5",children:[t.jsx(R,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:f(p==="restarting"||p==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(n?.currentVersion||n?.version)&&t.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ml-3",children:[n?.currentVersion&&t.jsx("span",{className:"text-muted-foreground",children:n.currentVersion}),n?.currentVersion&&n?.version&&t.jsx("span",{className:"text-muted-foreground/50",children:"→"}),n?.version&&t.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:n.version})]})]}),t.jsxs("div",{className:"space-y-2",children:[$&&F&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(R,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[p==="updating"&&f("updateDialog.status.installingUpdate"),p==="restarting"&&f("updateDialog.status.serverRestarting"),p==="reconnecting"&&f("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:f("updateDialog.status.autoReloadHint")})]}),_&&!F&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(po,{className:"max-h-[400px] p-0",fillContainer:!1,children:_.kind==="raw"?t.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:H=>{const D=H.target.closest("a");D&&D.href&&(H.preventDefault(),H.stopPropagation(),N(D.href))},children:t.jsx(Dn,{content:_.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:_.sections.map(H=>t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",H.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:H.dateLabel})]}),t.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:J=>{const oe=J.target.closest("a");oe&&oe.href&&(J.preventDefault(),J.stopPropagation(),N(oe.href))},children:t.jsx(Dn,{content:H.content,disableLinkSafety:!0,enableFileReferences:!1})})]},H.version))})})}),$&&p==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(R,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:f("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:w}),t.jsx("button",{onClick:x,className:ie("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",h&&"text-[var(--status-success)]"),title:f(h?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:h?t.jsx(R,{name:"check",className:"h-4 w-4"}):t.jsx(R,{name:"clipboard",className:"h-4 w-4"})})]})]}),!$&&!S&&r&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:f("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[B,"%"]})]}),t.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${B}%`}})})]}),(i||y)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:i||y})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[t.jsx(R,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!$&&!S&&!o&&!r&&t.jsxs("button",{onClick:u,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"download",className:"h-4 w-4"}),f("updateDialog.actions.downloadUpdate")]}),!$&&!S&&r&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(R,{name:"loader",className:"h-4 w-4 animate-spin"}),f("updateDialog.status.downloading")]}),!$&&!S&&o&&t.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"restart",className:"h-4 w-4"}),f("updateDialog.actions.restartToUpdate")]}),S&&t.jsxs(Ne,{onClick:V,size:"default",children:[t.jsx(R,{name:"external-link",className:"h-4 w-4"}),f("updateDialog.actions.openMobileUpdate")]}),$&&!F&&t.jsxs("button",{onClick:W,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"download",className:"h-4 w-4"}),f("updateDialog.actions.updateNow")]}),$&&F&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(R,{name:"loader",className:"h-4 w-4 animate-spin"}),f("updateDialog.status.updating")]})]})]})]})})},Ru=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),Yi=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),Ji=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Qi=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),as="opencode-update-available",Es="opencode-upgrade-progress",Xi=5e3,Zi=[1e4,6e4],qn="opencode-update-toast-dismissed-version",Au=()=>{const{t:s}=et(),e=Fe(i=>i.showOpenCodeUpdateNotifications),n=ae.useRef(new Set),r=ae.useRef(!1);ae.useEffect(()=>{e||ke.dismiss(as)},[e]);const o=ae.useCallback(()=>{ke.dismiss(Es),xo({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=ae.useCallback(async()=>{if(!r.current){r.current=!0,ke.dismiss(as),ke.message(s("opencodeUpdate.toast.upgrading.title"),{id:Es,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(R,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const i=await Bt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),u=await i.json().catch(()=>null);if(!i.ok||u?.success===!1)throw new Error(u?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));ke.success(s("opencodeUpdate.toast.updated.title"),{id:Es,description:u?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:u.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(R,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){ke.error(s("opencodeUpdate.toast.failed.title"),{id:Es,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return ae.useEffect(()=>{const i=g=>{if(!Fe.getState().showOpenCodeUpdateNotifications){ke.dismiss(as);return}Yi({version:g,dismissedVersion:Wn().getItem(qn),seenVersions:n.current})&&(n.current.add(g),ke.info(s("opencodeUpdate.toast.available.title"),{id:as,description:s("opencodeUpdate.toast.available.description",{version:g}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:a},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Wn().setItem(qn,g),Dr({openCodeUpdateToastDismissedVersion:g}),ke.dismiss(as)}}}))};let u=!1;const c=[],l=async(g,p=Ys())=>{try{const d=await Bt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!d.ok)throw new Error(d.statusText||"OpenCode upgrade status check failed");const y=await d.json().catch(()=>null),j=Qi(y);!u&&p===Ys()&&j&&i(j)}catch{const d=Zi[g];!u&&p===Ys()&&d!==void 0&&c.push(setTimeout(()=>{l(g+1,p)},d))}},f=g=>{Ji(g.detail)&&l(0)};e&&c.push(setTimeout(()=>{l(0)},Xi));const h=Za(({runtimeKey:g})=>{n.current.clear(),ke.dismiss(as),Fe.getState().showOpenCodeUpdateNotifications&&l(0,g)});return window.addEventListener("openchamber:opencode-update-available",f),()=>{u=!0;for(const g of c)clearTimeout(g);h(),window.removeEventListener("openchamber:opencode-update-available",f)}},[a,e,s]),null},Bu=()=>{const s=Ve.c(3),[e,n]=m.useState(el),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>yo(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),m.useEffect(o,a),!r)return null;let i;return s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(wo,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function el(){return bo()}class tl extends m.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){this.setState({error:e,errorInfo:n})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(vo,{className:"w-full max-w-md",children:[t.jsx(jo,{className:"text-center",children:t.jsxs(ko,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(R,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(So,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&t.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&t.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[t.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(Ne,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(R,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function sl(s){const e=Ve.c(22),{t:n}=et();let r;e[0]!==n?(r=n("chat.errorBoundary.title"),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==n?(o=n("chat.errorBoundary.description"),e[2]=n,e[3]=o):o=e[3];let a;e[4]!==n?(a=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=a):a=e[5];let i;e[6]!==n?(i=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=i):i=e[7];let u;e[8]!==n?(u=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=u):u=e[9];let c;e[10]!==n?(c=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=c):c=e[11];let l;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==u||e[17]!==c?(l={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:u,persistentHint:c},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=u,e[17]=c,e[18]=l):l=e[18];let f;return e[19]!==s||e[20]!==l?(f=t.jsx(tl,{...s,texts:l}),e[19]=s,e[20]=l,e[21]=f):f=e[21],f}const Mu=s=>{const e=Ve.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,u=o===void 0?!1:o,l=ot(nl)||void 0;let f;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==u?(f=t.jsx(No,{active:i,messagesEnabled:r,readOnly:u,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=u,e[4]=f):f=e[4];let h;return e[5]!==l||e[6]!==f?(h=t.jsx(sl,{sessionId:l,children:f}),e[5]=l,e[6]=f,e[7]=h):h=e[7],h};function nl(s){return s.currentSessionId}const rl=mi,ol=s=>{const e=Ve.c(14);let n,r,o,a;e[0]!==s?({className:o,asChild:n,children:r,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);let i;e[5]!==n||e[6]!==r?(i=n&&ae.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const u=i;let c;e[8]!==o?(c=ie("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",o),e[8]=o,e[9]=c):c=e[9];let l;return e[10]!==a||e[11]!==u||e[12]!==c?(l=t.jsx(fi,{className:c,...a,...u}),e[10]=a,e[11]=u,e[12]=c,e[13]=l):l=e[13],l},al=s=>{const e=Ve.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=ie("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(hi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},Yn=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function il(s){const e=Ve.c(131),{t:n}=et(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:u,allowRunAsGoal:c,onConfirm:l}=s,f=u===void 0?!1:u,h=c===void 0?!1:c;let g;e[0]!==h?(g=h&&!Pr(),e[0]=h,e[1]=g):g=e[1];const p=g,d=vt(bl),y=vt(xl),j=Co(gl),I=vt(pl),C=vt(hl),B=vt(ml),$=vt(fl),S=vt(ul);let w;e[2]!==S||e[3]!==B||e[4]!==C||e[5]!==$?(w=()=>Yn({providerID:C,modelID:B,variant:$,agent:S}),e[2]=S,e[3]=B,e[4]=C,e[5]=$,e[6]=w):w=e[6];const[x,N]=m.useState(w);let W,V;e[7]!==j||e[8]!==y||e[9]!==d||e[10]!==r||e[11]!==i?(W=()=>{r&&(d({directory:i,source:"todoSendDialog"}),y({directory:i}),j())},V=[r,d,y,j,i],e[7]=j,e[8]=y,e[9]=d,e[10]=r,e[11]=i,e[12]=W,e[13]=V):(W=e[12],V=e[13]),m.useEffect(W,V);let F,_;e[14]!==S||e[15]!==B||e[16]!==C||e[17]!==$||e[18]!==r?(F=()=>{r&&N(Yn({providerID:C,modelID:B,variant:$,agent:S}))},_=[r,C,B,$,S],e[14]=S,e[15]=B,e[16]=C,e[17]=$,e[18]=r,e[19]=F,e[20]=_):(F=e[19],_=e[20]),m.useEffect(F,_);let H,J;e[21]!==x.modelID||e[22]!==x.providerID||e[23]!==r||e[24]!==I?(H=()=>{if(!r||I.length===0)return;const b=I.find(Se=>Se.id===x.providerID)??I[0],A=Array.isArray(b?.models)?b.models:[],ge=A.some(Se=>Se.id===x.modelID),me=A[0]?.id??"";b?.id===x.providerID&&ge||N(Se=>({...Se,providerID:b?.id??"",modelID:ge?Se.modelID:me,variant:""}))},J=[r,I,x.providerID,x.modelID],e[21]=x.modelID,e[22]=x.providerID,e[23]=r,e[24]=I,e[25]=H,e[26]=J):(H=e[25],J=e[26]),m.useEffect(H,J);const D=dl;let oe;if(e[27]!==x.modelID||e[28]!==x.providerID||e[29]!==I){let b;e[31]!==x.providerID?(b=ge=>ge.id===x.providerID,e[31]=x.providerID,e[32]=b):b=e[32],oe=I.find(b)?.models?.find(ge=>ge.id===x.modelID),e[27]=x.modelID,e[28]=x.providerID,e[29]=I,e[30]=oe}else oe=e[30];const U=oe;let z;e[33]!==U?(z=U?.variants?Object.keys(U.variants):[],e[33]=U,e[34]=z):z=e[34];const P=z,O=P.length>0;let M,G;e[35]!==x.variant||e[36]!==O?(M=()=>{O||!x.variant||N(cl)},G=[O,x.variant],e[35]=x.variant,e[36]=O,e[37]=M,e[38]=G):(M=e[37],G=e[38]),m.useEffect(M,G);let E;e[39]!==x.modelID||e[40]!==x.providerID?(E=x.providerID.trim().length>0&&x.modelID.trim().length>0,e[39]=x.modelID,e[40]=x.providerID,e[41]=E):E=e[41];const K=E;let q;e[42]!==K||e[43]!==x||e[44]!==l||e[45]!==f?(q=()=>{!K||f||l(x)},e[42]=K,e[43]=x,e[44]=l,e[45]=f,e[46]=q):q=e[46];const Z=q;let Q,X;e[47]!==Z||e[48]!==r?(Q=()=>{if(!r)return;const b=A=>{(A.metaKey||A.ctrlKey)&&A.key==="Enter"&&(A.preventDefault(),Z())};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},X=[r,Z],e[47]=Z,e[48]=r,e[49]=Q,e[50]=X):(Q=e[49],X=e[50]),m.useEffect(Q,X);let ee;e[51]!==n||e[52]!==a?(ee=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=a,e[53]=ee):ee=e[53];const de=ee;let se;e[54]!==o||e[55]!==f?(se=b=>{f||o(b)},e[54]=o,e[55]=f,e[56]=se):se=e[56];let he;e[57]!==de?(he=t.jsx(Ws,{children:t.jsx(Ss,{children:de})}),e[57]=de,e[58]=he):he=e[58];let le;e[59]!==n?(le=n("chat.modelControls.model"),e[59]=n,e[60]=le):le=e[60];let Y;e[61]!==le?(Y=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:le}),e[61]=le,e[62]=Y):Y=e[62];let ne;e[63]===Symbol.for("react.memo_cache_sentinel")?(ne=(b,A)=>{N(ge=>({...ge,providerID:b,modelID:A,variant:""}))},e[63]=ne):ne=e[63];let ce;e[64]!==x.modelID||e[65]!==x.providerID?(ce=t.jsx(gr,{providerId:x.providerID,modelId:x.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:ne}),e[64]=x.modelID,e[65]=x.providerID,e[66]=ce):ce=e[66];let v;e[67]!==Y||e[68]!==ce?(v=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[Y,ce]}),e[67]=Y,e[68]=ce,e[69]=v):v=e[69];let L;e[70]!==n?(L=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=L):L=e[71];let te;e[72]!==L?(te=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:L}),e[72]=L,e[73]=te):te=e[73];const ue=!O;let fe;e[74]===Symbol.for("react.memo_cache_sentinel")?(fe=b=>N(A=>({...A,variant:b})),e[74]=fe):fe=e[74];let be;e[75]!==x.variant||e[76]!==ue||e[77]!==P?(be=t.jsx(Io,{value:x.variant,options:P,disabled:ue,onChange:fe}),e[75]=x.variant,e[76]=ue,e[77]=P,e[78]=be):be=e[78];let Ie;e[79]!==te||e[80]!==be?(Ie=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[te,be]}),e[79]=te,e[80]=be,e[81]=Ie):Ie=e[81];let Ee;e[82]!==n?(Ee=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=Ee):Ee=e[83];let ze;e[84]!==Ee?(ze=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Ee}),e[84]=Ee,e[85]=ze):ze=e[85];let Qe;e[86]===Symbol.for("react.memo_cache_sentinel")?(Qe=b=>N(A=>({...A,agent:b})),e[86]=Qe):Qe=e[86];let Ue;e[87]!==x.agent?(Ue=t.jsx(To,{agentName:x.agent,filter:D,dropdownPortalToBody:!0,onChange:Qe}),e[87]=x.agent,e[88]=Ue):Ue=e[88];let qe;e[89]!==ze||e[90]!==Ue?(qe=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[ze,Ue]}),e[89]=ze,e[90]=Ue,e[91]=qe):qe=e[91];let Ae;e[92]!==v||e[93]!==Ie||e[94]!==qe?(Ae=t.jsxs("div",{className:"flex flex-col gap-4",children:[v,Ie,qe]}),e[92]=v,e[93]=Ie,e[94]=qe,e[95]=Ae):Ae=e[95];const it=`flex items-center gap-3 ${p?"justify-between":"justify-end"}`;let Re;e[96]!==x.runAsGoal||e[97]!==p||e[98]!==f||e[99]!==n?(Re=p?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ns,{checked:x.runAsGoal===!0,onChange:b=>N(A=>({...A,runAsGoal:b})),disabled:f,ariaLabel:n("sessions.scheduledTasks.editor.goal.aria")}),t.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:f,onClick:()=>N(ll),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=x.runAsGoal,e[97]=p,e[98]=f,e[99]=n,e[100]=Re):Re=e[100];let $e;e[101]!==o?($e=()=>o(!1),e[101]=o,e[102]=$e):$e=e[102];let We;e[103]!==n?(We=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=We):We=e[104];let Ge;e[105]!==f||e[106]!==$e||e[107]!==We?(Ge=t.jsx(Ne,{variant:"ghost",size:"sm",onClick:$e,disabled:f,children:We}),e[105]=f,e[106]=$e,e[107]=We,e[108]=Ge):Ge=e[108];const at=!K||f;let Pe;e[109]!==f||e[110]!==n?(Pe=n(f?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=f,e[110]=n,e[111]=Pe):Pe=e[111];let Je;e[112]!==Z||e[113]!==at||e[114]!==Pe?(Je=t.jsx(Ne,{size:"sm",onClick:Z,disabled:at,children:Pe}),e[112]=Z,e[113]=at,e[114]=Pe,e[115]=Je):Je=e[115];let _e;e[116]!==Ge||e[117]!==Je?(_e=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Ge,Je]}),e[116]=Ge,e[117]=Je,e[118]=_e):_e=e[118];let Te;e[119]!==it||e[120]!==Re||e[121]!==_e?(Te=t.jsxs("div",{className:it,children:[Re,_e]}),e[119]=it,e[120]=Re,e[121]=_e,e[122]=Te):Te=e[122];let Xe;e[123]!==he||e[124]!==Ae||e[125]!==Te?(Xe=t.jsxs(ks,{className:"max-w-md overflow-visible",children:[he,Ae,Te]}),e[123]=he,e[124]=Ae,e[125]=Te,e[126]=Xe):Xe=e[126];let nt;return e[127]!==r||e[128]!==se||e[129]!==Xe?(nt=t.jsx(js,{open:r,onOpenChange:se,children:Xe}),e[127]=r,e[128]=se,e[129]=Xe,e[130]=nt):nt=e[130],nt}function ll(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function cl(s){return{...s,variant:""}}function dl(s){return Po(s.mode)}function ul(s){return s.currentAgentName||""}function fl(s){return s.currentVariant||""}function ml(s){return s.currentModelId}function hl(s){return s.currentProviderId}function pl(s){return s.providers}function gl(s){return s.loadAgents}function xl(s){return s.loadAgents}function bl(s){return s.loadProviders}function Lu(s){const e=Ve.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(pi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Fu(s){const e=Ve.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(gi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Ou(s){const e=Ve.c(20);let n,r,o,a,i;e[0]!==s?({className:r,positionerClassName:o,children:n,style:i,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a,e[5]=i):(n=e[1],r=e[2],o=e[3],a=e[4],i=e[5]);let u;e[6]!==o?(u=ie("app-region-no-drag z-50",o),e[6]=o,e[7]=u):u=e[7];let c;e[8]!==i?(c={color:"var(--surface-elevated-foreground)",...i},e[8]=i,e[9]=c):c=e[9];let l;e[10]!==r?(l=ie(Do,r),e[10]=r,e[11]=l):l=e[11];let f;e[12]!==n||e[13]!==a||e[14]!==c||e[15]!==l?(f=t.jsx(xi,{"data-slot":"dropdown-menu-content",style:c,className:l,...a,children:n}),e[12]=n,e[13]=a,e[14]=c,e[15]=l,e[16]=f):f=e[16];let h;return e[17]!==u||e[18]!==f?(h=t.jsx(wi,{children:t.jsx(vi,{className:u,children:f})}),e[17]=u,e[18]=f,e[19]=h):h=e[19],h}function $u(s){const e=Ve.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=ie(Eo,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(bi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function Wu(s){const e=Ve.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=ie(Ro,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(yi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const yl=280,Jn=4,wl=({transform:s})=>({...s,y:0}),vl=s=>{const e=Ve.c(18),{id:n,children:r,className:o}=s;let a;e[0]!==n?(a={id:n},e[0]=n,e[1]=a):a=e[1];const{attributes:i,listeners:u,setNodeRef:c,transform:l,transition:f,isDragging:h}=Ur(a);let g;e[2]!==l?(g=Vr.Transform.toString(l),e[2]=l,e[3]=g):g=e[3];let p;e[4]!==g||e[5]!==f?(p={transform:g,transition:f},e[4]=g,e[5]=f,e[6]=p):p=e[6];const d=h&&"opacity-50";let y;e[7]!==o||e[8]!==d?(y=ie("h-full rounded-md",o,d),e[7]=o,e[8]=d,e[9]=y):y=e[9];let j;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==u||e[14]!==c||e[15]!==p||e[16]!==y?(j=t.jsx("div",{ref:c,"data-sortable-tab-id":n,style:p,className:y,...i,...u,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=u,e[14]=c,e[15]=p,e[16]=y,e[17]=j):j=e[17],j},jl=s=>{const e=Ve.c(6),{id:n,children:r,className:o}=s;let a;e[0]!==o?(a=ie("h-full",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==r||e[3]!==n||e[4]!==a?(i=t.jsx("div",{className:a,"data-sortable-tab-id":n,children:r}),e[2]=r,e[3]=n,e[4]=a,e[5]=i):i=e[5],i},vs=s=>{const e=Ve.c(133),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:u,variant:c,activePillInsetClassName:l,activePillButtonClassName:f,inactiveTabsIconOnly:h,animateActivePill:g,activePillLowercase:p,nonCompositedIndicator:d,className:y}=s,j=u===void 0?"scrollable":u,I=c===void 0?"default":c,C=h===void 0?!1:h,B=p===void 0?!0:p,$=d===void 0?!1:d,{t:S}=et(),w=Fe(kl),{isTablet:x}=Us(),N=w||x,W=m.useRef(null);let V;e[0]===Symbol.for("react.memo_cache_sentinel")?(V={left:!1,right:!1},e[0]=V):V=e[0];const[F,_]=m.useState(V);let H;e[1]!==n?(H=n.map(Sl),e[1]=n,e[2]=H):H=e[2];const J=H,D=j==="scrollable",oe=I==="default",U=I==="active-pill",P=U||I==="animated",O=oe,M=P||O,G=U&&D,E=P,K=g??P,q=typeof i=="function",Z=q?vl:jl;let Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q=new Map,e[3]=Q):Q=e[3];const X=m.useRef(Q),[ee,de]=m.useState(null),[se,he]=m.useState(!1),[le,Y]=m.useState(null),ne=m.useRef(!1),ce=m.useRef(0),v=m.useRef(r),L=m.useRef(null);let te;e:{if(!M||!le||!r||le===r){te=0;break e}const je=n.findIndex(Ke=>Ke.id===le),pe=n.findIndex(Ke=>Ke.id===r);if(je<0||pe<0){te=0;break e}te=je>pe?Jn:-Jn}const ue=te;let fe;e[4]===Symbol.for("react.memo_cache_sentinel")?(fe={activationConstraint:{distance:8}},e[4]=fe):fe=e[4];const be=Lr(Fr(Or,fe)),Ie=Nl;let Ee;e[5]===Symbol.for("react.memo_cache_sentinel")?(Ee=(je,pe)=>{if(pe){X.current.set(je,pe);return}X.current.delete(je)},e[5]=Ee):Ee=e[5];const ze=Ee;let Qe;e[6]!==r||e[7]!==M?(Qe=()=>{if(!M||!r){de(Cl);return}const je=W.current,pe=X.current.get(r);if(!je||!pe){de(Il);return}let Ke=0,ct=0,mt=pe;for(;mt&&mt!==je;)Ke=Ke+mt.offsetLeft,ct=ct+mt.offsetTop,mt=mt.offsetParent;const jt={left:Ke,top:ct,width:pe.offsetWidth,height:pe.offsetHeight};de(yt=>Ie(yt,jt)?yt:jt)},e[6]=r,e[7]=M,e[8]=Qe):Qe=e[8];const Ue=Qe;let qe;e[9]!==D?(qe=()=>{if(!D){_({left:!1,right:!1});return}const je=W.current;if(!je){_({left:!1,right:!1});return}_({left:je.scrollLeft>2,right:je.scrollLeft+je.clientWidth<je.scrollWidth-2})},e[9]=D,e[10]=qe):qe=e[10];const Ae=qe;let it;e[11]!==D||e[12]!==Ae?(it=()=>{if(!D){_({left:!1,right:!1});return}const je=W.current;if(!je)return;Ae(),je.addEventListener("scroll",Ae,{passive:!0});const pe=new ResizeObserver(Ae);return pe.observe(je),()=>{je.removeEventListener("scroll",Ae),pe.disconnect()}},e[11]=D,e[12]=Ae,e[13]=it):it=e[13];let Re;e[14]!==D||e[15]!==n.length||e[16]!==Ae?(Re=[D,n.length,Ae],e[14]=D,e[15]=n.length,e[16]=Ae,e[17]=Re):Re=e[17],m.useEffect(it,Re);let $e;e[18]!==r||e[19]!==Ue||e[20]!==M?($e=()=>{if(!M){de(null);return}Ue();const je=W.current;if(!je)return;const pe=new ResizeObserver(()=>{performance.now()-ce.current>yl&&he(!1),Ue()});if(pe.observe(je),r){const Ke=X.current.get(r);Ke&&pe.observe(Ke)}return()=>{pe.disconnect()}},e[18]=r,e[19]=Ue,e[20]=M,e[21]=$e):$e=e[21];let We;e[22]!==r||e[23]!==n.length||e[24]!==Ue||e[25]!==M?(We=[r,n.length,Ue,M],e[22]=r,e[23]=n.length,e[24]=Ue,e[25]=M,e[26]=We):We=e[26],m.useEffect($e,We);let Ge;e[27]!==Ue?(Ge=()=>{Ue()},e[27]=Ue,e[28]=Ge):Ge=e[28],m.useLayoutEffect(Ge);let at;e[29]!==J?(at=J.join("\0"),e[29]=J,e[30]=at):at=e[30];const Pe=at;let Je,_e;e[31]!==r||e[32]!==Pe||e[33]!==M?(Je=()=>{if(!M){ne.current=!1,he(!1);return}const je=L.current!==Pe;if(L.current=Pe,!ne.current){ne.current=!0,v.current=r;return}const pe=v.current!==r;if(v.current=r,!pe||je){he(!1);return}ce.current=performance.now(),he(!0)},_e=[r,Pe,M],e[31]=r,e[32]=Pe,e[33]=M,e[34]=Je,e[35]=_e):(Je=e[34],_e=e[35]),m.useLayoutEffect(Je,_e);let Te;e[36]!==r||e[37]!==D||e[38]!==Ae?(Te=()=>{if(!D||!r)return;const je=W.current;if(!je)return;const pe=window.requestAnimationFrame(()=>{const Ke=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),ct=je.querySelector(`[data-sortable-tab-id="${Ke}"]`);ct&&(ct.scrollIntoView({block:"nearest",inline:"nearest"}),Ae())});return()=>{window.cancelAnimationFrame(pe)}},e[36]=r,e[37]=D,e[38]=Ae,e[39]=Te):Te=e[39];let Xe;e[40]!==r||e[41]!==D||e[42]!==n.length||e[43]!==Ae?(Xe=[r,D,n.length,Ae],e[40]=r,e[41]=D,e[42]=n.length,e[43]=Ae,e[44]=Xe):Xe=e[44],m.useEffect(Te,Xe);let nt;e[45]!==i?(nt=je=>{if(!i)return;const{active:pe,over:Ke}=je;!Ke||pe.id===Ke.id||i(String(pe.id),String(Ke.id))},e[45]=i,e[46]=nt):nt=e[46];const b=nt;let A;e[47]!==y?(A=ie("relative flex h-full min-w-0 flex-1",y),e[47]=y,e[48]=A):A=e[48];let ge;e[49]!==D||e[50]!==F||e[51]!==P?(ge=D&&F.left?t.jsx("div",{className:ie("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",P?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=D,e[50]=F,e[51]=P,e[52]=ge):ge=e[52];let me;e[53]!==D||e[54]!==F||e[55]!==P?(me=D&&F.right?t.jsx("div",{className:ie("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",P?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=D,e[54]=F,e[55]=P,e[56]=me):me=e[56];const Se=P?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",Me=P&&"@container/pill-tabs",Be=P&&"pill-tabs__track",He=P&&(l??"gap-0.5 py-0.5"),k=O&&"items-center overflow-y-hidden",ve=E&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",Ce=D?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let De;e[57]!==Se||e[58]!==Me||e[59]!==Be||e[60]!==He||e[61]!==k||e[62]!==ve||e[63]!==Ce?(De=ie("relative flex h-full min-w-0 flex-1",Se,Me,Be,He,k,ve,Ce),e[57]=Se,e[58]=Me,e[59]=Be,e[60]=He,e[61]=k,e[62]=ve,e[63]=Ce,e[64]=De):De=e[64];let tt;e[65]!==D?(tt=D?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=D,e[66]=tt):tt=e[66];let ft;e[67]!==S?(ft=S("sortableTabsStrip.aria.tabs"),e[67]=S,e[68]=ft):ft=e[68];let rt;e[69]!==$||e[70]!==ue||e[71]!==ee||e[72]!==se||e[73]!==K||e[74]!==P?(rt=P&&ee?t.jsx("div",{className:ie("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",K&&se&&($?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:$?{left:`${ee.left+ue}px`,top:`${ee.top}px`,width:`${ee.width}px`,height:`${ee.height}px`}:{transform:`translate3d(${ee.left+ue}px, ${ee.top}px, 0)`,width:`${ee.width}px`,height:`${ee.height}px`}}):null,e[69]=$,e[70]=ue,e[71]=ee,e[72]=se,e[73]=K,e[74]=P,e[75]=rt):rt=e[75];let dt;e[76]!==ue||e[77]!==ee||e[78]!==se||e[79]!==O?(dt=O&&ee?t.jsx("div",{className:ie("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",se&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${ee.left+ue}px, 0, 0)`,width:`${ee.width}px`},"aria-hidden":!0}):null,e[76]=ue,e[77]=ee,e[78]=se,e[79]=O,e[80]=dt):dt=e[80];let lt;if(e[81]!==Z||e[82]!==r||e[83]!==f||e[84]!==B||e[85]!==N||e[86]!==C||e[87]!==U||e[88]!==w||e[89]!==D||e[90]!==n||e[91]!==a||e[92]!==o||e[93]!==G||e[94]!==P||e[95]!==M){let je;e[97]!==Z||e[98]!==r||e[99]!==f||e[100]!==B||e[101]!==N||e[102]!==C||e[103]!==U||e[104]!==w||e[105]!==D||e[106]!==a||e[107]!==o||e[108]!==G||e[109]!==P||e[110]!==M?(je=pe=>{const Ke=pe.id===r,ct=C&&P&&!Ke&&!!pe.icon,mt=!ct,jt=!!pe.icon,yt=C&&P&&Ke&&!D&&!G,kt=pe.closable!==!1&&!!a,pt=kt&&!!pe.icon,St=D||G?void 0:P?yt?"flex-none basis-auto":w?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",It=kt?ht=>{ht.button===1&&(ht.preventDefault(),ht.stopPropagation(),a?.(pe.id))}:void 0,Nt=kt?Tl:void 0;return t.jsx(Z,{id:pe.id,className:St,children:t.jsxs("div",{ref:ht=>ze(pe.id,ht),onAuxClick:It,onMouseDown:Nt,className:ie("group flex h-full min-w-0 flex-nowrap items-center",D||G?"shrink-0":P?"w-full":"w-full min-w-0",P?"relative z-10 bg-transparent":Ke?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("button",{type:"button",role:"tab","aria-selected":Ke,"aria-label":ct?pe.title??pe.label:void 0,onClick:()=>o(pe.id),onPointerDown:M?()=>{he(!0),Y(pe.id)}:void 0,onPointerUp:M?()=>Y(null):void 0,onPointerLeave:M?()=>Y(null):void 0,onPointerCancel:M?()=>Y(null):void 0,className:ie(P?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",P&&B?"lowercase":null,P&&(ct?"gap-0":"gap-1.5"),P?G?"shrink-0 whitespace-nowrap px-3 text-center":D?"max-w-56 shrink-0 px-3 text-center":ct?"px-2 !min-w-0 text-center":yt?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":D?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",P?f??(U?w?"h-[38px]":"h-[31px]":"h-7"):null,P?Ke?"text-foreground":"text-muted-foreground hover:text-foreground":null,P?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:pe.title??pe.label,children:P?t.jsxs(t.Fragment,{children:[jt?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:ie("flex items-center justify-center transition-opacity",pt&&(N?"opacity-0":"group-hover:opacity-0")),children:pe.icon}),pt?t.jsx("span",{role:"button",tabIndex:-1,className:ie("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",N?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Pl,onClick:ht=>{ht.stopPropagation(),a?.(pe.id)},"aria-label":pe.closeLabel??`Close ${pe.label} tab`,title:pe.closeLabel??`Close ${pe.label} tab`,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,mt?t.jsx("span",{className:"animated-tabs__label truncate",children:pe.label}):null]}):t.jsxs("span",{className:ie("flex min-w-0 flex-nowrap items-center gap-1.5",!D&&"justify-center"),children:[jt?t.jsxs("span",{className:ie("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",Ke?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:ie("flex items-center justify-center transition-opacity",pt&&(N?"opacity-0":"group-hover:opacity-0")),children:pe.icon}),pt?t.jsx("span",{role:"button",tabIndex:-1,className:ie("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",N?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Dl,onClick:ht=>{ht.stopPropagation(),a?.(pe.id)},"aria-label":pe.closeLabel??`Close ${pe.label} tab`,title:pe.closeLabel??`Close ${pe.label} tab`,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:pe.label})]})}),kt&&!pt?t.jsx("button",{type:"button",onPointerDown:El,onClick:ht=>{ht.stopPropagation(),a?.(pe.id)},className:ie("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",P?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",P?Ke?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":Ke?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":pe.closeLabel??`Close ${pe.label} tab`,title:pe.closeLabel??`Close ${pe.label} tab`,children:t.jsx(R,{name:"close",className:"h-3 w-3"})}):null]})},pe.id)},e[97]=Z,e[98]=r,e[99]=f,e[100]=B,e[101]=N,e[102]=C,e[103]=U,e[104]=w,e[105]=D,e[106]=a,e[107]=o,e[108]=G,e[109]=P,e[110]=M,e[111]=je):je=e[111],lt=n.map(je),e[81]=Z,e[82]=r,e[83]=f,e[84]=B,e[85]=N,e[86]=C,e[87]=U,e[88]=w,e[89]=D,e[90]=n,e[91]=a,e[92]=o,e[93]=G,e[94]=P,e[95]=M,e[96]=lt}else lt=e[96];let st;e[112]!==De||e[113]!==tt||e[114]!==ft||e[115]!==rt||e[116]!==dt||e[117]!==lt?(st=t.jsxs("div",{ref:W,className:De,style:tt,role:"tablist","aria-label":ft,children:[rt,dt,lt]}),e[112]=De,e[113]=tt,e[114]=ft,e[115]=rt,e[116]=dt,e[117]=lt,e[118]=st):st=e[118];let T;e[119]!==A||e[120]!==ge||e[121]!==me||e[122]!==st?(T=t.jsxs("div",{className:A,children:[ge,me,st]}),e[119]=A,e[120]=ge,e[121]=me,e[122]=st,e[123]=T):T=e[123];const re=T;if(!q)return re;let xe;e[124]===Symbol.for("react.memo_cache_sentinel")?(xe=[wl],e[124]=xe):xe=e[124];let Le;e[125]!==J||e[126]!==re?(Le=t.jsx(_r,{items:J,strategy:Si,children:re}),e[125]=J,e[126]=re,e[127]=Le):Le=e[127];let ye;e[128]===Symbol.for("react.memo_cache_sentinel")?(ye=t.jsx(ki,{dropAnimation:null}),e[128]=ye):ye=e[128];let Oe;return e[129]!==b||e[130]!==be||e[131]!==Le?(Oe=t.jsxs($r,{sensors:be,collisionDetection:Wr,onDragEnd:b,modifiers:xe,children:[Le,ye]}),e[129]=b,e[130]=be,e[131]=Le,e[132]=Oe):Oe=e[132],Oe};function kl(s){return s.isMobile}function Sl(s){return s.id}function Nl(s,e){return!s||!e?s===e:Math.abs(s.left-e.left)<.5&&Math.abs(s.top-e.top)<.5&&Math.abs(s.width-e.width)<.5&&Math.abs(s.height-e.height)<.5}function Cl(s){return s===null?s:null}function Il(s){return s===null?s:null}function Tl(s){s.button===1&&s.preventDefault()}function Pl(s){s.stopPropagation()}function Dl(s){s.stopPropagation()}function El(s){s.stopPropagation()}const zt=zs()(Ar(Br((s,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:n=>{s({selectedProfileId:n})},loadProfiles:async()=>{s({isLoading:!0});const n=e().profiles;try{const r=await Oo();return s({profiles:r,isLoading:!1}),!0}catch(r){return console.error("Failed to load git identity profiles:",r),s({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{const n=await Fo();if(n&&n.userName&&n.userEmail){const r={id:"global",name:"Global Identity",userName:n.userName,userEmail:n.userEmail,authType:n.sshCommand?"ssh":void 0,sshKey:n.sshCommand?n.sshCommand.replace("ssh -i ",""):null,color:"info",icon:"fingerprint"};s({globalIdentity:r})}else s({globalIdentity:null});return!0}catch(n){return console.error("Failed to load global git identity:",n),s({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{const n=await Lo();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{const n=r=>{if(typeof r!="string")return null;const o=r.trim();return o.length>0?o:null};try{let r=null;if(r===null){const o=ti()?.settings;if(o)try{const i=(await o.load())?.settings||{};r=n(i.defaultGitIdentityId)}catch{}}if(r===null)try{const o=await Bt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);r=n(a?.defaultGitIdentityId)}}catch{}return s({defaultGitIdentityId:r}),!0}catch(r){return console.error("Failed to load default git identity setting:",r),!1}},setDefaultGitIdentityId:async n=>{try{const r=typeof n=="string"?n.trim():"",o=r.length>0?r:"";return await Dr({defaultGitIdentityId:o}),s({defaultGitIdentityId:o.length>0?o:null}),!0}catch(r){return console.error("Failed to save default git identity setting:",r),!1}},createProfile:async n=>{try{const r={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return Lt("saving"),await Mo(r),Lt("saved"),await e().loadProfiles(),!0}catch(r){return Lt("error"),console.error("Failed to create git identity profile:",r),!1}},updateProfile:async(n,r)=>{try{const o=e().profiles.find(i=>i.id===n);if(!o)throw new Error("Profile not found");const a={...o,...r};return Lt("saving"),await Bo(n,a),Lt("saved"),await e().loadProfiles(),!0}catch(o){return Lt("error"),console.error("Failed to update git identity profile:",o),!1}},deleteProfile:async n=>{try{return Lt("saving"),await Ao(n),Lt("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return Lt("error"),console.error("Failed to delete git identity profile:",r),!1}},getProfileById:n=>{const{profiles:r,globalIdentity:o}=e();return n==="global"?o||void 0:r.find(a=>a.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:r}=e();return r.filter(o=>!n.some(a=>a.authType==="token"&&a.host===o.host))}}),{name:"git-identities-store",storage:ei(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=zt);const Os=$o,Ot=s=>{const e=Ve.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:u,children:c,className:l,contentClassName:f,divider:h}=s,g=h===void 0?!0:h;let p;return e[0]!==c||e[1]!==l||e[2]!==f||e[3]!==r||e[4]!==g||e[5]!==u||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(p=t.jsx(Wo,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:u,divider:g,className:l,contentClassName:f,children:c}),e[0]=c,e[1]=l,e[2]=f,e[3]=r,e[4]=g,e[5]=u,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=p):p=e[10],p},Rl=450,Al=({projectRef:s=null,sections:e="all"})=>{const{t:n}=et(),{isMobile:r,isTablet:o}=Us(),a=r||o,i=Ct(E=>E.getActiveProject()),u=s?.path??i?.path??null,c=ot(E=>E.getWorktreeMetadata),l=Uo(),f=Cs(E=>E.homeDirectory),[h,g]=m.useState([]),[p,d]=m.useState(!1),[y,j]=m.useState(!1),[I,C]=m.useState(null),[B,$]=m.useState(null),[S,w]=m.useState([]),[x,N]=m.useState(!1),W=m.useRef(!1),V=m.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!u?null:{id:i.id,path:u},[i?.id,u,s?.id,s?.path]),F=m.useCallback(async()=>{if(!(!V||B===!1))try{const E=await En(V);w(E)}catch{}},[V,B]);m.useEffect(()=>{if(!u)return;let E=!1;return $(null),(async()=>{try{const K=await _o(u);if(E)return;$(K)}catch{}})(),()=>{E=!0}},[u]),m.useEffect(()=>{if(!V){w([]),N(!1);return}if(B===!1){w([]),N(!1);return}let E=!1;return N(!0),w([]),(async()=>{try{const K=await En(V);if(E)return;w(K)}catch{}finally{E||N(!1)}})(),()=>{E=!0}},[V,B]),m.useEffect(()=>{if(!V)return;let E=!1;return j(!0),(async()=>{try{const[K,q]=await Promise.all([xr(V),br(V)]);if(!E){const Z=K.length>0?K:[""];g(Z),C(JSON.stringify(Z)),d(q)}}catch{E||(g([""]),C(JSON.stringify([""])),d(!1))}finally{E||j(!1)}})(),()=>{E=!0}},[V]);const _=m.useCallback(async E=>{if(!V)return!1;const K=E.filter(q=>q.trim().length>0);try{return await Vo(V,K)?(C(JSON.stringify(E)),!0):(ke.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1)}catch{return ke.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1}},[V,n]),H=m.useMemo(()=>I===null?!1:I!==JSON.stringify(h),[I,h]);m.useEffect(()=>{if(!H||y||W.current)return;const E=window.setTimeout(()=>{W.current||(W.current=!0,(async()=>{try{await _(h)}finally{W.current=!1}})())},Rl);return()=>{window.clearTimeout(E)}},[H,y,_,h]);const J=m.useCallback((E,K)=>{g(q=>{const Z=[...q];return Z[E]=K,Z})},[]),D=m.useCallback(()=>{g(E=>[...E,""])},[]),oe=m.useCallback(E=>{g(K=>{const q=K.filter((Z,Q)=>Q!==E);return q.length>0?q:[""]})},[]),U=m.useCallback(()=>{!H||W.current||(W.current=!0,(async()=>{try{await _(h)}finally{W.current=!1}})())},[H,_,h]),z=m.useCallback(E=>{d(E),V&&zo(V,E)},[V]),P=m.useCallback(E=>{const K=le=>le.replace(/\\/g,"/").replace(/\/+$/,""),q=K(E.path),Z=l.filter(le=>{const Y=c(le.id);if(Y?.path&&K(Y.path)===q)return!0;const ne=le.directory;return!!(ne&&K(ne)===q)}),Q=new Set(Z.map(le=>le.id)),X=[...dn.getState().activeSessions,...dn.getState().archivedSessions],ee=le=>{const Y=X.filter(ce=>{const v=ce.parentID;return v&&le.has(v)});if(Y.length===0)return[];const ne=new Set(Y.map(ce=>ce.id));return[...Y,...ee(ne)]},de=ee(Q),se=new Set,he=[...Z,...de].filter(le=>se.has(le.id)?!1:(se.add(le.id),!0));Go.requestDelete({sessions:he,mode:"worktree",worktree:E})},[l,c]),O=m.useMemo(()=>l.map(E=>E.id).join(","),[l]);m.useEffect(()=>{B&&u&&F()},[O,B,u,F]);const M=t.jsxs(un,{children:[n("settings.openchamber.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",n("settings.openchamber.worktrees.setup.tooltipSuffix")]}),G=t.jsx(un,{children:n("settings.openchamber.worktrees.list.tooltip")});return u?B===!1?t.jsx(Ot,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.gitOnly")})}):t.jsxs(t.Fragment,{children:[e==="all"?t.jsx(Ot,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:M,children:y?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.setup.loading")}):t.jsxs("div",{className:ie("space-y-2",Os),children:[h.map((E,K)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(bt,{value:E,onChange:q=>J(K,q.target.value),onBlur:U,placeholder:n("settings.openchamber.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(Ne,{type:"button",variant:"ghost",size:"icon",onClick:()=>oe(K),className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":n("settings.openchamber.worktrees.setup.removeCommandAria"),children:t.jsx(R,{name:"close",className:"h-4 w-4"})})]},K)),t.jsxs(Ne,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:D,children:[t.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),n("settings.openchamber.worktrees.setup.addCommand")]}),t.jsxs("label",{"data-settings-item":"projects.worktree.setup.wait",className:"flex cursor-pointer items-center gap-2 py-1",children:[t.jsx(Ns,{checked:p,onChange:z,ariaLabel:n("settings.openchamber.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:ie("typography-ui-label font-normal",p?"text-foreground":"text-foreground/60"),children:n("settings.openchamber.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(Ot,{title:n("settings.openchamber.worktrees.list.title"),titleAccessory:G,children:x?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.list.loading")}):S.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.openchamber.worktrees.list.empty")}):t.jsx("div",{className:ie("space-y-1",e==="all"&&Os),children:S.map(E=>t.jsxs("div",{className:"group flex w-full items-center gap-2 py-1.5",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"flex min-w-0 items-center gap-2",children:t.jsx("p",{className:"typography-meta min-w-0 truncate text-foreground",children:E.label||E.branch||n("settings.openchamber.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:Ho(E.path,f)})]}),t.jsx("button",{type:"button",onClick:()=>P(E),className:ie("flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",a?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":n("settings.openchamber.worktrees.list.deleteWorktreeAria",{name:E.branch||E.label||E.path}),children:t.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})]},E.path))})})]}):t.jsx(Ot,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.selectProject")})})},Qn=(s,e)=>e.updatedAtMs-s.updatedAtMs,Xn=zs((s,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){s({isLoading:!0,error:null});try{const[n,r]=await Promise.all([Jo(),An()]),o={};for(const a of r.sort(Qn))o[a.id]=a;e().listenerReady||await Qo(a=>{s(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),s({instances:n.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await Yo();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await An(),r={};for(const o of n.sort(Qn))r[o.id]=o;s({statusesById:r})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await qo({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(r){throw s({isSaving:!1,error:r instanceof Error?r.message:String(r)}),r}},upsertInstance:async n=>{const r=e().instances,o=r.some(a=>a.id===n.id)?r.map(a=>a.id===n.id?n:a):[n,...r];await e().setInstances(o)},createFromCommand:async(n,r,o)=>{const a=Xo(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await Rn(n).catch(()=>{});const r=e().instances.filter(o=>o.id!==n);await e().setInstances(r),s(o=>{const a={...o.statusesById};return delete a[n],{statusesById:a}})},connect:async n=>{s({error:null});try{await Ko(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},disconnect:async n=>{s({error:null});try{await Rn(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},retry:async n=>{await e().connect(n)},getStatus:n=>e().statusesById[n]||null,clearError:()=>s({error:null})})),Kr=[{key:"play",label:"Play",Icon:"play"},{key:"build",label:"Build",Icon:"hammer"},{key:"lint",label:"Lint",Icon:"checkbox-circle"},{key:"terminal",label:"Terminal",Icon:"terminal-box"},{key:"tools",label:"Tools",Icon:"tools"},{key:"bug",label:"Bug",Icon:"bug"},{key:"flask",label:"Flask",Icon:"flask"},{key:"rocket",label:"Rocket",Icon:"rocket"},{key:"code",label:"Code",Icon:"code"},{key:"server",label:"Server",Icon:"server"},{key:"branch",label:"Branch",Icon:"git-branch"},{key:"search",label:"Search",Icon:"search"},{key:"settings",label:"Settings",Icon:"settings-3"},{key:"brain",label:"Brain",Icon:"brain-ai-3"},{key:"stack",label:"Stack",Icon:"stack"},{key:"robot",label:"Robot",Icon:"robot-2"},{key:"command",label:"Command",Icon:"command"},{key:"file",label:"File",Icon:"file-text"}],qr=Object.fromEntries(Kr.map(s=>[s.key,s.Icon])),Bl="openchamber:project-actions-updated",Ml=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},Uu=(s,e)=>`${Ml(s)}::${e}`,Ll=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},Zn=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},Fl=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=Zn(e.localPort),r=Zn(e.remotePort);if(!n||!r)return null;const o=Ll(e.localHost||s.localForward.bindHost||"127.0.0.1"),a=(e.remoteHost||"127.0.0.1").trim(),i=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${i} - ${o}:${n} -> ${a}:${r}`,url:`http://${o}:${n}`}},Yr=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=Fl(n,r);o&&e.push(o)}return e},_u=(s,e)=>{const n=(s||"").trim();return n&&Yr(e).find(a=>a.id===n)?.url||null},Ol=450,$l=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,Wl=()=>({id:$l(),name:"",command:"",icon:"play"}),Ul=({projectRef:s})=>{const{t:e}=et(),n=m.useMemo(()=>Er(),[]),r=Xn(w=>w.instances),o=Xn(w=>w.load),[a,i]=m.useState([]),[u,c]=m.useState(!1),[l,f]=m.useState(null),[h,g]=m.useState({}),p=m.useRef(!1),d=m.useRef(null);m.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),m.useEffect(()=>{let w=!1;return c(!0),(async()=>{try{const x=await Zo(s);if(w)return;i(x.actions),f(JSON.stringify({actions:x.actions}))}catch{if(w)return;i([]),f(JSON.stringify({actions:[]}))}finally{w||c(!1)}})(),()=>{w=!0}},[s]);const y=m.useMemo(()=>n?Yr(r):[],[r,n]),j=m.useMemo(()=>a.some(x=>x.name.trim().length===0||x.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),I=m.useMemo(()=>l===null?!1:l!==JSON.stringify({actions:a}),[a,l]),C=m.useCallback(async w=>await ea(s,{actions:w,primaryActionId:null})?(f(JSON.stringify({actions:w})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Bl,{detail:{projectId:s.id}})),!0):(ke.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);m.useEffect(()=>{if(!I||u||j||p.current)return;const w=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await C(a)}finally{p.current=!1}})())},Ol);return()=>{window.clearTimeout(w)}},[a,I,u,C,j]),m.useEffect(()=>{if(!I||!j||u){j||(d.current=null);return}const w=window.setTimeout(()=>{d.current!==j&&(d.current=j,ke.error(j))},1e3);return()=>{window.clearTimeout(w)}},[I,u,j]);const B=m.useCallback(()=>{const w=Wl();i(x=>[...x,w]),g(x=>({...x,[w.id]:!0}))},[]),$=m.useCallback(w=>{i(x=>x.filter(N=>N.id!==w)),g(x=>{const N={...x};return delete N[w],N})},[]),S=m.useCallback((w,x)=>{i(N=>N.map(W=>W.id===w?x(W):W))},[]);return t.jsxs(Ot,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(Ne,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:B,children:[t.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[u?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")}):t.jsx("div",{className:ie("space-y-0",Os),children:a.map(w=>{const x=w.icon||"play",N=qr[x]||"play",W=h[w.id]??!1,V=w.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(rl,{open:W,onOpenChange:F=>{g(_=>({..._,[w.id]:F}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(ol,{className:"group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[W?t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(R,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(R,{name:N,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:V})})]}),t.jsx(Ne,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>$(w.id),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(al,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-2 pb-4 pl-3 pr-1",children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsxs($t,{children:[t.jsx(Wt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(R,{name:N,className:"h-4 w-4"})})}),t.jsx(Ut,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:Kr.map(F=>{const _=F.Icon,H=(w.icon||"play")===F.key;return t.jsx("button",{type:"button",onClick:()=>S(w.id,J=>({...J,icon:F.key})),className:ie("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",H&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:F.label}),children:t.jsx(R,{name:_,className:"h-4 w-4"})},F.key)})})})]}),t.jsx(bt,{value:w.name,onChange:F=>S(w.id,_=>({..._,name:F.target.value})),placeholder:e("settings.projects.actions.field.actionNamePlaceholder"),className:"h-7 flex-1 min-w-0"})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.command")}),t.jsx(_s,{value:w.command,onChange:F=>S(w.id,_=>({..._,command:F.target.value})),placeholder:e("settings.projects.actions.field.commandPlaceholder"),className:"min-h-[88px] w-full font-mono text-xs"})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.projects.actions.field.autoOpenUrl")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2",role:"button",tabIndex:0,"aria-pressed":w.autoOpenUrl===!0,onClick:()=>S(w.id,F=>({...F,...F.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),S(w.id,_=>({..._,..._.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(Ns,{checked:w.autoOpenUrl===!0,onChange:F=>S(w.id,_=>({..._,...F?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:V})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),w.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(bt,{value:w.openUrl||"",onChange:F=>S(w.id,_=>({..._,openUrl:F.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(un,{contentClassName:"max-w-xs",children:e("settings.projects.actions.field.overrideUrlTooltip")})]}),n?t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.desktopSshForward")}),y.length>0?t.jsxs(yr,{value:w.desktopOpenSshForward&&y.some(F=>F.id===w.desktopOpenSshForward)?w.desktopOpenSshForward:"__none__",onValueChange:F=>{S(w.id,_=>({..._,...F==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:F}}))},children:[t.jsx(wr,{size:vr,className:"w-full",children:t.jsx(jr,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(kr,{children:[t.jsx(Ls,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),y.map(F=>t.jsx(Ls,{value:F.id,children:F.label},F.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},w.id)})}),j&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:j}):null]})},_l=s=>{if(!s)return[];const e=s.variants;return e?Object.keys(e):[]},Qs="__default__",Jr=s=>s.charAt(0).toUpperCase()+s.slice(1),Vl=s=>{const e=Ve.c(138),{form:n}=s,{t:r}=et(),{currentTheme:o}=Sr(),a=vt(zl),{name:i,setName:u,icon:c,setIcon:l,color:f,setColor:h,iconBackground:g,setIconBackground:p,parsedDefaultModel:d,defaultVariant:y,handleDefaultModelChange:j,handleDefaultVariantChange:I,isUploadingIcon:C,isRemovingCustomIcon:B,isDiscoveringIcon:$,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:w,pendingUploadIconPreviewUrl:x,setPreviewImageFailed:N,hasPendingUploadImageIcon:W,hasCustomIcon:V,effectiveHasImageIcon:F,hasRemovableImageIcon:_,showImagePreview:H,fileInputRef:J,handleUploadIcon:D,handleRemoveImageIcon:oe,handleDiscoverIcon:U,currentIconImage:z,project:P}=n;let O;e:{const{providerId:me,modelId:Se}=d;if(!me||!Se){let Be;e[0]===Symbol.for("react.memo_cache_sentinel")?(Be=[],e[0]=Be):Be=e[0],O=Be;break e}let Me;if(e[1]!==Se||e[2]!==me||e[3]!==a){const Be=a.find(He=>He.id===me)?.models.find(He=>He.id===Se);Me=_l(Be),e[1]=Se,e[2]=me,e[3]=a,e[4]=Me}else Me=e[4];O=Me}const M=O;if(!P)return null;const G=f?ta[f]??null:null;let E;e[5]!==r?(E=r("settings.projects.page.field.projectName"),e[5]=r,e[6]=E):E=e[6];let K;e[7]!==u?(K=me=>u(me.target.value),e[7]=u,e[8]=K):K=e[8];let q;e[9]!==r?(q=r("settings.projects.page.field.projectNamePlaceholder"),e[9]=r,e[10]=q):q=e[10];let Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=ie("h-8 rounded-md px-3",Os),e[11]=Z):Z=e[11];let Q;e[12]!==i||e[13]!==K||e[14]!==q?(Q=t.jsx(bt,{value:i,onChange:K,placeholder:q,className:Z}),e[12]=i,e[13]=K,e[14]=q,e[15]=Q):Q=e[15];let X;e[16]!==E||e[17]!==Q?(X=t.jsx(Ot,{title:E,settingsItem:"projects.name",divider:!1,children:Q}),e[16]=E,e[17]=Q,e[18]=X):X=e[18];let ee;e[19]!==r?(ee=r("settings.projects.page.section.chatDefaults"),e[19]=r,e[20]=ee):ee=e[20];let de;e[21]!==r?(de=r("settings.projects.page.section.chatDefaultsDescription"),e[21]=r,e[22]=de):de=e[22];let se;e[23]!==r?(se=r("settings.projects.page.field.projectModel"),e[23]=r,e[24]=se):se=e[24];let he;e[25]!==j||e[26]!==d.modelId||e[27]!==d.providerId?(he=t.jsx(gr,{providerId:d.providerId,modelId:d.modelId,onChange:j,className:sa}),e[25]=j,e[26]=d.modelId,e[27]=d.providerId,e[28]=he):he=e[28];let le;e[29]!==se||e[30]!==he?(le=t.jsx(Bn,{settingsItem:"projects.default-model",label:se,children:he}),e[29]=se,e[30]=he,e[31]=le):le=e[31];let Y;e[32]!==M||e[33]!==y||e[34]!==I||e[35]!==r?(Y=M.length>0?t.jsx(Bn,{settingsItem:"projects.default-thinking",label:r("settings.projects.page.field.projectThinking"),children:t.jsxs(yr,{value:y??Qs,onValueChange:me=>I(me===Qs?void 0:me),children:[t.jsx(wr,{size:vr,className:na,"aria-label":r("settings.projects.page.field.projectThinking"),children:t.jsx(jr,{children:y?Jr(y):r("settings.projects.page.option.thinkingDefault")})}),t.jsxs(kr,{children:[t.jsx(Ls,{value:Qs,children:r("settings.projects.page.option.thinkingDefault")}),M.map(Gl)]})]})}):null,e[32]=M,e[33]=y,e[34]=I,e[35]=r,e[36]=Y):Y=e[36];let ne;e[37]!==le||e[38]!==Y||e[39]!==ee||e[40]!==de?(ne=t.jsxs(Ot,{title:ee,info:de,contentClassName:"space-y-0",children:[le,Y]}),e[37]=le,e[38]=Y,e[39]=ee,e[40]=de,e[41]=ne):ne=e[41];let ce;e[42]!==r?(ce=r("settings.projects.page.field.accentColor"),e[42]=r,e[43]=ce):ce=e[43];let v;e[44]!==h?(v=()=>h(null),e[44]=h,e[45]=v):v=e[45];const L=f===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let te;e[46]!==L?(te=ie("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",L),e[46]=L,e[47]=te):te=e[47];let ue;e[48]!==r?(ue=r("settings.projects.page.field.none"),e[48]=r,e[49]=ue):ue=e[49];let fe;e[50]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx(R,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[50]=fe):fe=e[50];let be;e[51]!==v||e[52]!==te||e[53]!==ue?(be=t.jsx("button",{type:"button",onClick:v,className:te,title:ue,children:fe}),e[51]=v,e[52]=te,e[53]=ue,e[54]=be):be=e[54];let Ie;e[55]!==f||e[56]!==h?(Ie=ra.map(me=>t.jsx("button",{type:"button",onClick:()=>h(me.key),className:ie("h-7 w-7 rounded-md border transition-colors",f===me.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:me.cssVar},title:me.label},me.key)),e[55]=f,e[56]=h,e[57]=Ie):Ie=e[57];let Ee;e[58]!==be||e[59]!==Ie?(Ee=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[be,Ie]}),e[58]=be,e[59]=Ie,e[60]=Ee):Ee=e[60];let ze;e[61]!==ce||e[62]!==Ee?(ze=t.jsx(Ot,{title:ce,settingsItem:"projects.accent-color",children:Ee}),e[61]=ce,e[62]=Ee,e[63]=ze):ze=e[63];let Qe;e[64]!==r?(Qe=r("settings.projects.page.field.projectIcon"),e[64]=r,e[65]=Qe):Qe=e[65];let Ue;e[66]!==D?(Ue=me=>{const Se=me.target.files?.[0]??null;D(Se),me.currentTarget.value=""},e[66]=D,e[67]=Ue):Ue=e[67];let qe;e[68]!==J||e[69]!==Ue?(qe=t.jsx("input",{ref:J,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Ue}),e[68]=J,e[69]=Ue,e[70]=qe):qe=e[70];let Ae;e[71]!==l?(Ae=()=>l(null),e[71]=l,e[72]=Ae):Ae=e[72];const it=c===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let Re;e[73]!==it?(Re=ie("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",it),e[73]=it,e[74]=Re):Re=e[74];let $e;e[75]!==r?($e=r("settings.projects.page.field.none"),e[75]=r,e[76]=$e):$e=e[76];let We;e[77]===Symbol.for("react.memo_cache_sentinel")?(We=t.jsx(R,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[77]=We):We=e[77];let Ge;e[78]!==Ae||e[79]!==Re||e[80]!==$e?(Ge=t.jsx("button",{type:"button",onClick:Ae,className:Re,title:$e,children:We}),e[78]=Ae,e[79]=Re,e[80]=$e,e[81]=Ge):Ge=e[81];let at;e[82]!==G||e[83]!==c||e[84]!==l?(at=oa.map(me=>{const Se=me.Icon;return t.jsx("button",{type:"button",onClick:()=>l(me.key),className:ie("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",c===me.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:me.label,children:t.jsx(R,{name:Se,className:"w-4 h-4",style:G&&c===me.key?{color:G}:void 0})},me.key)}),e[82]=G,e[83]=c,e[84]=l,e[85]=at):at=e[85];let Pe;e[86]!==Ge||e[87]!==at?(Pe=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ge,at]}),e[86]=Ge,e[87]=at,e[88]=Pe):Pe=e[88];let Je;e[89]!==z||e[90]!==o||e[91]!==F||e[92]!==W||e[93]!==g||e[94]!==x||e[95]!==P||e[96]!==N||e[97]!==H||e[98]!==r?(Je=F&&H&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:g?{backgroundColor:g}:void 0,children:W&&x?t.jsx("img",{src:x,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>N(!0)}):t.jsx(aa,{project:{...P,iconImage:z??P.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>N(!0)})})})]}),e[89]=z,e[90]=o,e[91]=F,e[92]=W,e[93]=g,e[94]=x,e[95]=P,e[96]=N,e[97]=H,e[98]=r,e[99]=Je):Je=e[99];let _e;e[100]!==F||e[101]!==g||e[102]!==p||e[103]!==r?(_e=F&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:g??"#000000",onChange:me=>p(me.target.value),className:"h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1","aria-label":r("settings.projects.page.field.projectIconBackgroundAria")}),t.jsx(bt,{value:g??"",onChange:me=>p(me.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(Ne,{type:"button",size:"xs",variant:"outline",onClick:()=>p(null),className:"h-7 w-7 p-0","aria-label":r("settings.projects.page.field.clearIconBackgroundAria"),title:r("settings.projects.page.field.clearBackground"),disabled:!g,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),e[100]=F,e[101]=g,e[102]=p,e[103]=r,e[104]=_e):_e=e[104];let Te;e[105]!==J||e[106]!==U||e[107]!==V||e[108]!==$||e[109]!==C||e[110]!==r?(Te=!V&&t.jsxs(t.Fragment,{children:[t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",onClick:()=>J.current?.click(),disabled:C,children:r(C?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{U()},disabled:$,children:r($?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[105]=J,e[106]=U,e[107]=V,e[108]=$,e[109]=C,e[110]=r,e[111]=Te):Te=e[111];let Xe;e[112]!==oe||e[113]!==_||e[114]!==B||e[115]!==r?(Xe=_&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{oe()},disabled:B,children:r(B?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[112]=oe,e[113]=_,e[114]=B,e[115]=r,e[116]=Xe):Xe=e[116];let nt;e[117]!==B||e[118]!==S||e[119]!==w||e[120]!==r?(nt=S&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>w(!1),disabled:B,children:r("settings.projects.page.actions.undoRemove")}),e[117]=B,e[118]=S,e[119]=w,e[120]=r,e[121]=nt):nt=e[121];let b;e[122]!==Te||e[123]!==Xe||e[124]!==nt?(b=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Te,Xe,nt]}),e[122]=Te,e[123]=Xe,e[124]=nt,e[125]=b):b=e[125];let A;e[126]!==Qe||e[127]!==qe||e[128]!==Pe||e[129]!==Je||e[130]!==_e||e[131]!==b?(A=t.jsxs(Ot,{title:Qe,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[qe,Pe,Je,_e,b]}),e[126]=Qe,e[127]=qe,e[128]=Pe,e[129]=Je,e[130]=_e,e[131]=b,e[132]=A):A=e[132];let ge;return e[133]!==ne||e[134]!==ze||e[135]!==A||e[136]!==X?(ge=t.jsxs(t.Fragment,{children:[X,ne,ze,A]}),e[133]=ne,e[134]=ze,e[135]=A,e[136]=X,e[137]=ge):ge=e[137],ge};function zl(s){return s.providers}function Gl(s){return t.jsx(Ls,{value:s,children:Jr(s)},s)}const Hl=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Kl=s=>{if(!s)return null;const e=s.trim();return e&&Hl.test(e)?e.toLowerCase():null},ql=s=>{const{t:e}=et(),n=Ct(Y=>Y.uploadProjectIcon),r=Ct(Y=>Y.removeProjectIcon),o=Ct(Y=>Y.discoverProjectIcon),a=Ct(Y=>s?Y.projects.find(ne=>ne.id===s.id)?.iconImage??null:null),[i,u]=m.useState(""),[c,l]=m.useState(null),[f,h]=m.useState(null),[g,p]=m.useState(null),[d,y]=m.useState(void 0),[j,I]=m.useState(void 0),[C,B]=m.useState(!1),[$,S]=m.useState(!1),[w,x]=m.useState(!1),[N,W]=m.useState(!1),[V,F]=m.useState(null),[_,H]=m.useState(null),[J,D]=m.useState(!1),oe=m.useRef(null),U=m.useCallback(()=>{F(null),H(Y=>(Y&&URL.revokeObjectURL(Y),null))},[]),z=s?.id??null;m.useEffect(()=>{if(!s){u(""),l(null),h(null),p(null),y(void 0),I(void 0);return}u(s.label??""),l(s.icon??null),h(s.color??null),p(s.iconBackground??null),y(s.defaultModel),I(s.defaultVariant),W(!1),U(),D(!1)},[s,U]),m.useEffect(()=>()=>{U()},[U]);const P=m.useMemo(()=>Nr(d)??{providerId:"",modelId:""},[d]),O=!!s?.iconImage,M=!!(V&&_),G=s?.iconImage?.source==="custom",E=O&&!N||M,K=E,q=!!(s&&O&&!N),Z=!J&&(M||q),Q=!!s&&(i.trim()!==(s?.label??"").trim()||c!==(s?.icon??null)||f!==(s?.color??null)||g!==(s?.iconBackground??null)||(d??void 0)!==(s?.defaultModel??void 0)||(j??void 0)!==(s?.defaultVariant??void 0)||N||!!V),X=m.useCallback((Y,ne)=>{y(Y&&ne?`${Y}/${ne}`:void 0),I(void 0)},[]),ee=m.useCallback(Y=>{I(Y)},[]),de=m.useCallback(Y=>{!s||!Y||C||(W(!1),D(!1),F(Y),H(ne=>(ne&&URL.revokeObjectURL(ne),URL.createObjectURL(Y))))},[C,s]),se=m.useCallback(()=>{!s||!K||$||(M&&U(),W(!!O),D(!1))},[U,M,K,O,$,s]),he=m.useCallback(async()=>{if(!(!s||w)){U(),W(!1),D(!1),x(!0);try{const Y=await o(s.id);if(!Y.ok){ke.error(Y.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(Y.skipped){ke.success(e("settings.projects.page.toast.customIconAlreadySet"));return}ke.success(e("settings.projects.page.toast.iconDiscovered"))}finally{x(!1)}}},[U,o,w,s,e]),le=m.useCallback(async Y=>{const ne=Y?.silent===!0;if(!s)return null;const ce=i.trim();if(!ce)return null;if(V){B(!0);const L=await n(s.id,V);if(B(!1),!L.ok)return ke.error(L.error||e("settings.projects.page.toast.uploadIconFailed")),null;ne||ke.success(e("settings.projects.page.toast.iconUpdated")),U(),W(!1)}const v=N&&!!s.iconImage;if(v){S(!0);const L=await r(s.id);if(S(!1),!L.ok)return ke.error(L.error||e("settings.projects.page.toast.removeIconFailed")),null;ne||ke.success(e("settings.projects.page.toast.iconRemoved")),W(!1),p(null)}return{label:ce,icon:c,color:f,iconBackground:Kl(v?null:g),defaultModel:d??null,defaultVariant:d?j??null:null}},[U,f,d,j,c,g,i,N,V,s,r,e,n]);return m.useEffect(()=>{D(!1)},[z,a?.updatedAt]),{name:i,setName:u,icon:c,setIcon:l,color:f,setColor:h,iconBackground:g,setIconBackground:p,defaultModel:d,defaultVariant:j,parsedDefaultModel:P,handleDefaultModelChange:X,handleDefaultVariantChange:ee,isUploadingIcon:C,isRemovingCustomIcon:$,isDiscoveringIcon:w,pendingRemoveImageIcon:N,setPendingRemoveImageIcon:W,pendingUploadIconFile:V,pendingUploadIconPreviewUrl:_,previewImageFailed:J,setPreviewImageFailed:D,hasStoredImageIcon:O,hasPendingUploadImageIcon:M,hasCustomIcon:G,effectiveHasImageIcon:E,hasRemovableImageIcon:K,showStoredImagePreview:q,showImagePreview:Z,fileInputRef:oe,clearPendingUploadIcon:U,handleUploadIcon:de,handleRemoveImageIcon:se,handleDiscoverIcon:he,hasChanges:Q,prepareSaveData:le,currentIconImage:a,project:s}},Yl=450,Jl=(s,e)=>{const{t:n}=et(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:u,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:f,isUploadingIcon:h,isRemovingCustomIcon:g,prepareSaveData:p}=s,d=m.useRef(!1);m.useEffect(()=>{if(!r||!o.trim()||h||g||d.current)return;const y=window.setTimeout(()=>{d.current||(d.current=!0,(async()=>{try{const j=await p({silent:!0});if(j)try{await e(j)}catch{ke.error(n("settings.projects.page.toast.saveFailed"))}}finally{d.current=!1}})())},Yl);return()=>{window.clearTimeout(y)}},[i,c,r,a,u,g,h,o,e,l,f,p,n])},Vu=s=>{const e=Ve.c(16),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=ql(n);let u;e:{if(!n){u=null;break e}let y;e[0]!==n.id||e[1]!==n.path?(y={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=y):y=e[2],u=y}const c=u;let l;if(e[3]!==r?(l=async y=>{await r(y)},e[3]=r,e[4]=l):l=e[4],Jl(i,l),!n||!c)return null;let h;e[5]!==i?(h=t.jsx(Vl,{form:i}),e[5]=i,e[6]=h):h=e[6];let g;e[7]!==c?(g=t.jsx(Ul,{projectRef:c}),e[7]=c,e[8]=g):g=e[8];let p;e[9]!==c||e[10]!==a?(p=a?t.jsx(Al,{projectRef:c}):null,e[9]=c,e[10]=a,e[11]=p):p=e[11];let d;return e[12]!==h||e[13]!==g||e[14]!==p?(d=t.jsxs("div",{className:"space-y-0",children:[h,g,p]}),e[12]=h,e[13]=g,e[14]=p,e[15]=d):d=e[15],d},Qr=()=>{const s=ia();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},zu=()=>{const s=Ve.c(2),[e,n]=m.useState(Ql);let r,o;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{n(Qr())};i();for(const u of a)typeof u.addEventListener=="function"?u.addEventListener("change",i):typeof u.addListener=="function"&&u.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const u of a)typeof u.removeEventListener=="function"?u.removeEventListener("change",i):typeof u.removeListener=="function"&&u.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),m.useEffect(r,o),e};function Ql(){return Qr()}const Xl=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"general",title:"General",group:"general",kind:"single",keywords:["general","startup","launch at login","autostart","tray","password","passkey","security","privacy","telemetry","transport","network","lan","binary","cli"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:s=>!s.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"split",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"usage",title:"Usage",group:"general",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"split",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"split",keywords:["plugin","plugins","extensions","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"content",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"content",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"projects",kind:"single",keywords:["git","github","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji","oauth","prs","issues"],isAvailable:s=>!s.isVSCode},{slug:"appearance",title:"Appearance",group:"general",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:s=>!s.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"magic-prompts",title:"Magic Prompts",group:"content",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:s=>!s.isVSCode},{slug:"snippets",title:"Snippets",group:"content",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"general",kind:"single",keywords:["tts","speech","voice"],isAvailable:s=>!s.isVSCode},{slug:"tunnel",title:"External Tunnel",group:"projects",kind:"single",keywords:["tunnel","external","cloudflare","qr","remote","mobile","share"],isAvailable:s=>!s.isVSCode},{slug:"about",title:"About",group:"general",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:s=>s.isMobile&&!s.isVSCode},{slug:"integrations",title:"Integrations",group:"general",kind:"single",keywords:["integration","plugin","provider","oauth","claude","cursor","command code","connect","discord","telegram","messenger"]}],Zl={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function ec(s){const e=s.trim().toLowerCase();return Xl.find(n=>n.slug===e)??null}function tc(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=Zl[e];if(n)return n;const r=ec(e);return r?r.slug:"home"}function Gu(s){switch(s){case"general":return"settings-3";case"projects":return"folders";case"remote-instances":return"computer";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return"chat-thread";case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"plug-2";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"integrations":return"plug";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"home-office";case"about":return"information";case"home":return null;default:return"robot-2"}}const sc=["chat","git","diff","terminal","files"],nc=["settings","agents","commands","skills","providers","usage","git-identities"],At={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function er(s){const e=rc();return{sessionId:oc(e),tab:ac(e),settingsPath:ic(e),diffFile:lc(e)}}function rc(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function oc(s){const e=s.get(At.SESSION);return!e||e.trim().length===0?null:e.trim()}function ac(s){const e=s.get(At.TAB);if(!e)return null;const n=e.toLowerCase().trim();return sc.includes(n)?n:null}function ic(s){const e=s.get(At.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(nc.includes(n),n)}function lc(s){const e=s.get(At.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function tr(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(At.SESSION)||s.has(At.TAB)||s.has(At.SETTINGS)||s.has(At.FILE)}catch{return!1}}function Xr(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(At.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(At.SETTINGS,n),e}return e}function cc(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function dc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=Xr(s),r=[...e.entries()].sort((a,i)=>a[0].localeCompare(i[0])),o=[...n.entries()].sort((a,i)=>a[0].localeCompare(i[0]));if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(r[a][0]!==o[a][0]||r[a][1]!==o[a][1])return!1;return!0}catch{return!0}}function sr(s,e={}){if(!(typeof window>"u")&&!(uc()||Mr())&&!(!e.force&&dc(s)))try{const n=Xr(s),r=cc(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function uc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function fc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function Hu(){const s=m.useMemo(()=>fc(),[]),e=m.useMemo(()=>Mr(),[]),n=m.useRef(!1),r=m.useRef(!1),o=ot(h=>h.setCurrentSession),a=Fe(h=>h.setSettingsDialogOpen),i=Fe(h=>h.setSettingsPage),u=Fe(h=>h.navigateToDiff),c=m.useCallback(async h=>{if(!r.current){r.current=!0;try{if(h.sessionId){const g=ot.getState().currentSessionId;if(h.sessionId!==g){const p=ot.getState().getDirectoryForSession(h.sessionId);o(h.sessionId,p)}}if(h.settingsPath){i(tc(h.settingsPath)),a(!0);return}if(Fe.getState().isSettingsDialogOpen&&a(!1),h.tab&&h.tab!=="chat"){const g=Cs.getState().currentDirectory;if(g){const p=h.tab==="files"?"file":h.tab;Fe.getState().openContextSurface(g,p)}}h.diffFile&&(h.tab==="diff"||!h.tab)&&u(h.diffFile)}finally{r.current=!1}}},[o,a,i,u]),l=m.useCallback(()=>{const h=ot.getState(),g=Fe.getState();return{sessionId:h.currentSessionId,isSettingsOpen:g.isSettingsDialogOpen,settingsPath:g.settingsPage}},[]),f=m.useCallback((h={})=>{if(s||e||r.current)return;const g=l();sr(g,h)},[s,e,l]);m.useEffect(()=>{if(n.current||(n.current=!0,!tr()))return;const h=er();(async()=>(await c(h),!s&&!e&&sr({...l(),sessionId:h.sessionId??ot.getState().currentSessionId,settingsPath:h.settingsPath??Fe.getState().settingsPage},{replace:!0,force:!0})))()},[c,l,s,e]),m.useEffect(()=>{if(s||e)return;let h=ot.getState().currentSessionId;return ot.subscribe(p=>{const d=p.currentSessionId;d===h||r.current||(h=d,f())})},[s,e,f]),m.useEffect(()=>{if(s||e)return;let h=Fe.getState().isSettingsDialogOpen,g=Fe.getState().settingsPage;return Fe.subscribe(d=>{if(r.current)return;const y=d.isSettingsDialogOpen!==h,j=d.settingsPage!==g;h=d.isSettingsDialogOpen,g=d.settingsPage,(y||j)&&f()})},[s,e,f]),m.useEffect(()=>{if(typeof window>"u"||s||e)return;const h=()=>{const g=er();tr()?c(g):Fe.getState().isSettingsDialogOpen&&a(!1)};return window.addEventListener("popstate",h),()=>{window.removeEventListener("popstate",h)}},[c,s,e,a])}function Ku(){const s=Ve.c(5),e=Wi(hc),n=m.useRef(e);let r,o;s[0]!==e?(r=()=>{n.current=e},o=[e],s[0]=e,s[1]=r,s[2]=o):(r=s[1],o=s[2]),m.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let u=!1,c=null;const l=mc,f=h=>{u||(c=window.setTimeout(async()=>{const g=await n.current(),p=typeof g=="number"&&Number.isFinite(g)?l(g):36e5;f(p)},h))};return f(3e3),()=>{u=!0,c!==null&&window.clearTimeout(c)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),m.useEffect(a,i)}function mc(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function hc(s){return s.checkForUpdates}const vn=1e3,xs=60*vn,Xs=60*xs,pc=(s,e)=>{const n=Math.max(0,s);return n<xs?e("common.duration.secondsCompact",{seconds:Math.floor(n/vn)}):n<Xs?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/xs),seconds:Math.floor(n%xs/vn)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/Xs),minutes:Math.floor(n%Xs/xs)})},gc=1e3,qu=s=>{const e=Ve.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=et(),i=la(n),u=ca(n),c=da(r,gc),l=r?Math.max(0,c-(i??c)):u;if(l===void 0)return null;let f,h;e[0]!==l||e[1]!==r||e[2]!==a?(f=pc(l,a),h=r?a("sessions.sidebar.session.status.activeFor",{duration:f}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:f}),e[0]=l,e[1]=r,e[2]=a,e[3]=f,e[4]=h):(f=e[3],h=e[4]);const g=h,p=r?"text-primary":"text-[var(--status-info)]";let d;e[5]!==o||e[6]!==p?(d=ie("shrink-0 tabular-nums",p,o),e[5]=o,e[6]=p,e[7]=d):d=e[7];let y;return e[8]!==g||e[9]!==f||e[10]!==d?(y=t.jsx("span",{className:d,"aria-label":g,title:g,children:f}),e[8]=g,e[9]=f,e[10]=d,e[11]=y):y=e[11],y},xc=()=>{const s=Ve.c(14),[e,n]=ae.useState(!1),[r,o]=ae.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Er()),o(si())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),ae.useEffect(a,i);let u;s[2]!==e?(u=async d=>e?await ni(d):{success:!0,path:d},s[2]=e,s[3]=u):u=s[3];const c=u;let l;s[4]!==e?(l=async d=>e?await ri():{success:!0},s[4]=e,s[5]=l):l=s[5];const f=l;let h;s[6]!==e?(h=async d=>e?await oi():{success:!0},s[6]=e,s[7]=h):h=s[7];const g=h;let p;return s[8]!==r||s[9]!==e||s[10]!==c||s[11]!==f||s[12]!==g?(p={isDesktop:e,canRequestAccess:r,requestAccess:c,startAccessing:f,stopAccessing:g},s[8]=r,s[9]=e,s[10]=c,s[11]=f,s[12]=g,s[13]=p):p=s[13],p},bc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),yc=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,onCheckout:o,onCreate:a,remotes:i=[],disabled:u=!1})=>{const{t:c}=et(),[l,f]=m.useState(!1),[h,g]=m.useState(""),[p,d]=m.useState(!1),[y,j]=m.useState(!1),[I,C]=m.useState(""),[B,$]=m.useState(!1),S=m.useRef(null),w=m.useCallback(U=>{U.stopPropagation()},[]),x=i.length>1,N=m.useMemo(()=>bc(I),[I]),W=m.useMemo(()=>fn(e,h,U=>[U]),[h,e]),V=m.useMemo(()=>fn(n,h,U=>[U]),[h,n]),F=U=>{if(U===s){f(!1);return}o(U),f(!1),g("")},_=()=>{d(!0),setTimeout(()=>S.current?.focus(),50)},H=async()=>{if(!(!N||B)){if(x){j(!0);return}$(!0);try{await a(N,i[0]),C(""),d(!1),f(!1)}finally{$(!1)}}},J=async U=>{if(!(!N||B)){$(!0);try{await a(N,U),C(""),d(!1),j(!1),f(!1)}finally{$(!1)}}},D=()=>{j(!1)},oe=()=>{C(""),d(!1),j(!1)};return m.useEffect(()=>{l||(g(""),d(!1),j(!1),C(""))},[l]),t.jsxs($t,{open:l,onOpenChange:f,children:[t.jsxs(us,{children:[t.jsx(fs,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:u,children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||c("gitView.branch.detachedHead")}),t.jsx(R,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(ms,{sideOffset:8,children:c("gitView.branch.currentBranchTooltip")})]}),t.jsx(Ut,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(mn,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(hn,{placeholder:c("gitView.branch.searchPlaceholder"),value:h,onValueChange:g,onKeyDown:w}),t.jsxs(pn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(gn,{children:c("gitView.branch.empty")}),t.jsx(Ft,{children:y?t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("button",{type:"button",onClick:D,disabled:B,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[c("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:N})," ",c("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:i.map(U=>t.jsxs("button",{type:"button",onClick:()=>J(U),disabled:B,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[B?t.jsx(R,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,U.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:U.pushUrl})]},U.name))})]}):p?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:S,placeholder:c("gitView.branch.newBranchPlaceholder"),value:I,onChange:U=>C(U.target.value),onClick:U=>U.stopPropagation(),onKeyDown:U=>{w(U),U.key==="Enter"?(U.preventDefault(),H()):U.key==="Escape"&&(U.preventDefault(),oe())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:H,disabled:!N||B,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:B?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:oe,disabled:B,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"close",className:"size-4"})})]}):t.jsxs(Dt,{onSelect:_,children:[t.jsx(R,{name:"add",className:"size-4"}),t.jsx("span",{children:c("gitView.branch.create")})]})}),t.jsx(is,{}),t.jsxs(Ft,{heading:c("gitView.branch.localBranches"),children:[W.map(U=>t.jsxs(Dt,{onSelect:()=>F(U),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:U}),(r?.[U]?.ahead||r?.[U]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[U].ahead||0," ahead ·"," ",r[U].behind||0," behind"]})]}),s===U&&t.jsx("span",{className:"typography-micro text-primary",children:c("gitView.branch.currentBadge")})]},`local-${U}`)),W.length===0&&t.jsx(Dt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noLocalBranches")})})]}),t.jsx(is,{}),t.jsxs(Ft,{heading:c("gitView.branch.remoteBranches"),children:[V.map(U=>t.jsx(Dt,{onSelect:()=>F(U),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:U})},`remote-${U}`)),V.length===0&&t.jsx(Dt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noRemoteBranches")})})]})]})]})})]})},wc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),vc=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=et(),[o,a]=m.useState(!1),[i,u]=m.useState(s||""),[c,l]=m.useState(!1),f=m.useRef(null),h=()=>{!s||!e||(u(s),a(!0),setTimeout(()=>f.current?.focus(),0))},g=async()=>{if(!s||!e||!i.trim())return;const y=wc(i);if(y===s){a(!1);return}l(!0);try{await e(s,y),a(!1),u("")}finally{l(!1)}},p=()=>{a(!1),u("")},d=y=>{y.key==="Enter"?(y.preventDefault(),g()):y.key==="Escape"&&(y.preventDefault(),p())};return o?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:y=>{y.preventDefault(),g()},children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:f,value:i,onChange:y=>u(y.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:r("gitView.branch.namePlaceholder"),onKeyDown:d,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:c,"aria-label":r(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:c?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:p,disabled:c,"aria-label":r("gitView.branch.renameCancel"),title:r("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||r("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:h,title:r("gitView.branch.renameTitle"),children:t.jsx(R,{name:"edit",className:"size-4"})})]})]})},jc=s=>{const e=Ve.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:u,removingRemoteName:c,aheadCount:l,behindCount:f,trackingRemoteName:h,hasUncommittedChanges:g}=s,p=r===void 0?[]:r,d=c===void 0?null:c,y=l===void 0?0:l,j=f===void 0?0:f,I=g===void 0?!1:g,{t:C}=et(),B=m.useRef(!1),$=!!d,S=p.find(ue=>ue.name===h)??p[0],w=j>0&&I,x=u||n!==null||$||!S||w,N=u||n!==null||$||p.length===0,W=y>0||j>0;let V;e[0]!==C?(V=C("gitView.sync.sync"),e[0]=C,e[1]=V):V=e[1];const F=j>0?`↓${j}`:null,_=y>0?`↑${y}`:null;let H;e[2]!==V||e[3]!==F||e[4]!==_?(H=[V,F,_].filter(Boolean),e[2]=V,e[3]=F,e[4]=_,e[5]=H):H=e[5];const J=H.join(" "),D=w?C("gitView.sync.commitOrStashTooltip"):S?W?C("gitView.sync.syncChangesTooltip",{ahead:y,behind:j}):C("gitView.sync.syncChanges"):C("gitView.sync.noRemoteTooltip"),oe=()=>{S&&a(S)},U="inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",z=w?0:void 0;let P;e[6]===Symbol.for("react.memo_cache_sentinel")?(P=ie("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[6]=P):P=e[6];let O;e[7]!==C?(O=C("gitView.sync.syncChanges"),e[7]=C,e[8]=O):O=e[8];let M;e[9]!==n?(M=n==="sync"?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=M):M=e[10];let G;e[11]!==J?(G=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:J}),e[11]=J,e[12]=G):G=e[12];let E;e[13]!==oe||e[14]!==x||e[15]!==O||e[16]!==M||e[17]!==G?(E=t.jsxs("button",{type:"button",onClick:oe,disabled:x,className:P,"aria-label":O,children:[M,G]}),e[13]=oe,e[14]=x,e[15]=O,e[16]=M,e[17]=G,e[18]=E):E=e[18];let K;e[19]!==z||e[20]!==E?(K=t.jsx(fs,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:z,children:E})}),e[19]=z,e[20]=E,e[21]=K):K=e[21];let q;e[22]!==D?(q=t.jsx(ms,{sideOffset:8,children:D}),e[22]=D,e[23]=q):q=e[23];let Z;e[24]!==K||e[25]!==q?(Z=t.jsxs(us,{children:[K,q]}),e[24]=K,e[25]=q,e[26]=Z):Z=e[26];const Q=$t;let X;e[27]===Symbol.for("react.memo_cache_sentinel")?(X=ie("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[27]=X):X=e[27];let ee;e[28]!==C?(ee=C("gitView.sync.moreActionsAria"),e[28]=C,e[29]=ee):ee=e[29];let de;e[30]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsx(R,{name:"arrow-down-s",className:"size-4"}),e[30]=de):de=e[30];let se;e[31]!==N||e[32]!==ee?(se=t.jsx(Wt,{asChild:!0,children:t.jsx("button",{type:"button",className:X,disabled:N,"aria-label":ee,children:de})}),e[31]=N,e[32]=ee,e[33]=se):se=e[33];const he=Ut,le="start",Y=-40,ne="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",ce=p.map(ue=>t.jsx(Rt,{onSelect:fe=>{if(B.current){fe.preventDefault(),B.current=!1;return}o(ue)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(R,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:C("gitView.sync.fetchFromRemote",{name:ue.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ue.fetchUrl})]})}),i&&ue.name!==h?t.jsx(Ne,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||$,onPointerDown:fe=>{B.current=!0,fe.preventDefault(),fe.stopPropagation()},onClick:fe=>{B.current=!0,fe.preventDefault(),fe.stopPropagation(),i(ue)},"aria-label":C("gitView.header.removeRemoteAria",{name:ue.name}),title:C("gitView.header.removeRemoteTitle",{name:ue.name}),children:d===ue.name?t.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(R,{name:"close",className:"size-3.5"})}):null]})},ue.name));let v;e[34]!==he||e[35]!==ce?(v=t.jsx(he,{align:le,alignOffset:Y,className:ne,children:ce}),e[34]=he,e[35]=ce,e[36]=v):v=e[36];let L;e[37]!==Q||e[38]!==se||e[39]!==v?(L=t.jsxs(Q,{children:[se,v]}),e[37]=Q,e[38]=se,e[39]=v,e[40]=L):L=e[40];let te;return e[41]!==Z||e[42]!==L?(te=t.jsxs("div",{className:U,children:[Z,L]}),e[41]=Z,e[42]=L,e[43]=te):te=e[43],te},kc={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},Sc={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function Zr(s){return s&&Sc[s]||"var(--primary)"}const nr=s=>{const e=Ve.c(8),{icon:n,className:r,colorToken:o}=s,a=kc[n??"branch"]??"user-3";let i;e[0]!==o?(i=Zr(o),e[0]=o,e[1]=i):i=e[1];let u;e[2]!==i?(u={color:i},e[2]=i,e[3]=u):u=e[3];let c;return e[4]!==r||e[5]!==a||e[6]!==u?(c=t.jsx(R,{name:a,className:r,style:u}),e[4]=r,e[5]=a,e[6]=u,e[7]=c):c=e[7],c},eo=s=>{const e=Ve.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,u=i===void 0?!1:i,{t:c}=et(),l=a||r.length===0,f=n?.color;let h;e[0]!==f?(h=Zr(f),e[0]=f,e[1]=h):h=e[1];let g;e[2]!==h?(g={color:h},e[2]=h,e[3]=g):g=e[3];let p;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==a?(p=a?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(nr,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=a,e[7]=p):p=e[7];let d;e[8]!==n?.name||e[9]!==u||e[10]!==c?(d=!u&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||c("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=u,e[10]=c,e[11]=d):d=e[11];let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(R,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=y):y=e[12];let j;e[13]!==l||e[14]!==g||e[15]!==p||e[16]!==d?(j=t.jsx(fs,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",style:g,disabled:l,children:[p,d,y]})})}),e[13]=l,e[14]=g,e[15]=p,e[16]=d,e[17]=j):j=e[17];let I;e[18]!==c?(I=c("gitView.header.identityTooltip"),e[18]=c,e[19]=I):I=e[19];let C;e[20]!==I?(C=t.jsx(ms,{sideOffset:8,children:I}),e[20]=I,e[21]=C):C=e[21];let B;e[22]!==C||e[23]!==j?(B=t.jsxs(us,{children:[j,C]}),e[22]=C,e[23]=j,e[24]=B):B=e[24];let $;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==c?($=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:c("gitView.header.noProfiles")})}):r.map(x=>{const N=n?.id===x.id;return t.jsx(Rt,{onSelect:()=>o(x),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(nr,{icon:x.icon,colorToken:x.color,className:"size-4"}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:x.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x.userEmail})]}),N?t.jsx(R,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},x.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=c,e[29]=$):$=e[29];let S;e[30]!==$?(S=t.jsx(Ut,{align:"end",className:"w-64",children:$}),e[30]=$,e[31]=S):S=e[31];let w;return e[32]!==B||e[33]!==S?(w=t.jsxs($t,{children:[B,S]}),e[32]=B,e[33]=S,e[34]=w):w=e[34],w},Nc=s=>{const e=Ve.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=et(),u=`${n.remote}/${n.branch}`,c=n.ahead===0&&n.behind===0;let l;e[0]!==i||e[1]!==u||e[2]!==r?(l=r?i("gitView.header.upstreamTooltipTracking",{target:u,tracking:r}):i("gitView.header.upstreamTooltip",{target:u}),e[0]=i,e[1]=u,e[2]=r,e[3]=l):l=e[3];const f=l;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(R,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=h):h=e[4];let g;e[5]!==u?(g=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:u}),e[5]=u,e[6]=g):g=e[6];let p;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==c||e[10]!==i?(p=c?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=c,e[10]=i,e[11]=p):p=e[11];let d;e[12]!==g||e[13]!==p?(d=t.jsx(fs,{asChild:!0,children:t.jsxs("div",{className:"inline-flex h-8 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[h,g,p]})}),e[12]=g,e[13]=p,e[14]=d):d=e[14];let y;e[15]!==f?(y=t.jsx(ms,{sideOffset:8,children:f}),e[15]=f,e[16]=y):y=e[16];let j;return e[17]!==d||e[18]!==y||e[19]!==a?(j=t.jsxs(us,{delayDuration:a,children:[d,y]}),e[17]=d,e[18]=y,e[19]=a,e[20]=j):j=e[20],j},Yu=s=>{const e=Ve.c(67),{status:n,localBranches:r,remoteBranches:o,branchInfo:a,syncAction:i,remotes:u,onFetch:c,onSync:l,onRemoveRemote:f,removingRemoteName:h,onCheckoutBranch:g,onCreateBranch:p,onRenameBranch:d,activeIdentityProfile:y,availableIdentities:j,onSelectIdentity:I,isApplyingIdentity:C,isWorktreeMode:B,onOpenHistory:$,onOpenGraph:S,onOpenStashes:w,onOpenUpdateBranch:x,onOpenReintegrateCommits:N,pullRequest:W,prChecks:V,onOpenPullRequest:F}=s,{t:_}=et();if(!n)return null;let H;e[0]!==S||e[1]!==$||e[2]!==N||e[3]!==w||e[4]!==x||e[5]!==_?(H=$||S||w||x?t.jsxs($t,{children:[t.jsxs(us,{children:[t.jsx(fs,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":_("gitView.header.repositoryViews"),children:t.jsx(R,{name:"more-fill",className:"size-4"})})})}),t.jsx(ms,{sideOffset:8,children:_("gitView.header.repositoryViews")})]}),t.jsxs(Ut,{align:"end",children:[$?t.jsxs(Rt,{onSelect:$,children:[t.jsx(R,{name:"history",className:"size-4"}),_("gitView.history.title")]}):null,S?t.jsxs(Rt,{onSelect:S,children:[t.jsx(R,{name:"git-branch",className:"size-4"}),_("gitView.graph.title")]}):null,w?t.jsxs(Rt,{onSelect:w,children:[t.jsx(R,{name:"archive-stack",className:"size-4"}),_("gitView.stashes.title")]}):null,x?t.jsxs(Rt,{onSelect:x,children:[t.jsx(R,{name:"git-merge",className:"size-4"}),_("gitView.header.updateBranch")]}):null,N?t.jsxs(Rt,{onSelect:N,children:[t.jsx(R,{name:"split-cells-horizontal",className:"size-4"}),_("gitView.integrate.title")]}):null]})]}):null,e[0]=S,e[1]=$,e[2]=N,e[3]=w,e[4]=x,e[5]=_,e[6]=H):H=e[6];let J;e[7]!==H?(J=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:H}),e[7]=H,e[8]=J):J=e[8];const D=J,oe=V?V.state==="success"?"var(--status-success)":V.state==="failure"?"var(--status-error)":"var(--status-warning)":null,U=W?W.state==="merged"?"merged":W.state==="closed"?"closed":W.draft?"draft":V?.state==="failure"||W.mergeable===!1||W.mergeableState==="blocked"||W.mergeableState==="dirty"?"blocked":"open":null;let z;e[9]!==F||e[10]!==oe||e[11]!==U||e[12]!==W||e[13]!==_?(z=W&&F?t.jsxs(us,{children:[t.jsx(fs,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",onClick:F,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(R,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${U})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:_("gitView.pr.numberLabel",{number:W.number})}),oe?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:oe}}):null]})}),t.jsx(ms,{sideOffset:8,children:_("gitView.header.openPullRequest")})]}):null,e[9]=F,e[10]=oe,e[11]=U,e[12]=W,e[13]=_,e[14]=z):z=e[14];const P=z,O=!n;let M;e[15]!==n.tracking?(M=n.tracking?.split("/")[0],e[15]=n.tracking,e[16]=M):M=e[16];const G=(n.files?.length??0)>0;let E;e[17]!==c||e[18]!==f||e[19]!==l||e[20]!==u||e[21]!==h||e[22]!==n.ahead||e[23]!==n.behind||e[24]!==i||e[25]!==O||e[26]!==M||e[27]!==G?(E=t.jsx(jc,{syncAction:i,remotes:u,onFetch:c,onSync:l,onRemoveRemote:f,removingRemoteName:h,disabled:O,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:M,hasUncommittedChanges:G}),e[17]=c,e[18]=f,e[19]=l,e[20]=u,e[21]=h,e[22]=n.ahead,e[23]=n.behind,e[24]=i,e[25]=O,e[26]=M,e[27]=G,e[28]=E):E=e[28];const K=E;let q;e[29]!==n.tracking||e[30]!==n.upstreamComparison?(q=n.upstreamComparison?t.jsx(Nc,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[29]=n.tracking,e[30]=n.upstreamComparison,e[31]=q):q=e[31];const Z=q;let Q;e[32]!==y||e[33]!==j||e[34]!==C||e[35]!==I?(Q=t.jsx(eo,{activeProfile:y,identities:j,onSelect:I,isApplying:C,iconOnly:!0}),e[32]=y,e[33]=j,e[34]=C,e[35]=I,e[36]=Q):Q=e[36];const X=Q;let ee;e[37]!==a||e[38]!==B||e[39]!==r||e[40]!==g||e[41]!==p||e[42]!==d||e[43]!==o||e[44]!==u||e[45]!==n.current?(ee=t.jsx("div",{className:"min-w-0 flex-1",children:B?t.jsx(vc,{currentBranch:n.current,onRename:d}):t.jsx(yc,{currentBranch:n.current,localBranches:r,remoteBranches:o,branchInfo:a,onCheckout:g,onCreate:p,remotes:u})}),e[37]=a,e[38]=B,e[39]=r,e[40]=g,e[41]=p,e[42]=d,e[43]=o,e[44]=u,e[45]=n.current,e[46]=ee):ee=e[46];let de;e[47]!==X?(de=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:X}),e[47]=X,e[48]=de):de=e[48];let se;e[49]!==ee||e[50]!==de?(se=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[ee,de]}),e[49]=ee,e[50]=de,e[51]=se):se=e[51];let he;e[52]!==P?(he=P?t.jsx("div",{className:"shrink-0",children:P}):null,e[52]=P,e[53]=he):he=e[53];let le;e[54]===Symbol.for("react.memo_cache_sentinel")?(le=t.jsx("div",{className:"min-w-0 flex-1"}),e[54]=le):le=e[54];let Y;e[55]!==Z?(Y=Z?t.jsx("div",{className:"min-w-0 shrink",children:Z}):null,e[55]=Z,e[56]=Y):Y=e[56];let ne;e[57]!==K?(ne=t.jsx("div",{className:"shrink-0",children:K}),e[57]=K,e[58]=ne):ne=e[58];let ce;e[59]!==D||e[60]!==he||e[61]!==Y||e[62]!==ne?(ce=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[he,le,Y,D,ne]}),e[59]=D,e[60]=he,e[61]=Y,e[62]=ne,e[63]=ce):ce=e[63];let v;return e[64]!==se||e[65]!==ce?(v=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[se,ce]}),e[64]=se,e[65]=ce,e[66]=v):v=e[66],v},Cc=s=>s==="/",$s=s=>s.replace(/\\/g,"/"),In=s=>{if(!s||Cc(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},ds=s=>s.endsWith("/"),Ic=s=>{const e=s.trim();return!e||ds(e)?e:`${e}/`},Tn=s=>s.lastIndexOf("/"),to=s=>{if(ds(s))return s;const e=Tn(s);return e<0?s:s.slice(0,e+1)},Tc=s=>{const e=Tn(s);return s.slice(e+1)},so=s=>{const e=In(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Tn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},Pc=s=>ds(s)&&so(s)!==null,Dc=(s,e)=>`${to(s)}${e}/`,_t=s=>{if(!s)return null;const e=In($s(s.trim()));return e?e.toLowerCase():null},rr=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},Ec=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,Zs=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},Rc=async()=>{try{const s=await Bt("/api/fs/home",{method:"GET",headers:{Accept:"application/json"}});if(s.ok){const e=await s.json();if(typeof e.home=="string"&&e.home.trim().length>0)return $s(e.home.trim())}}catch{}return cs.getFilesystemHome().catch(()=>null)},Ju=({open:s,onOpenChange:e})=>{const{t:n}=et(),r=Cs(k=>k.homeDirectory),o=Ct(k=>k.projects),a=Ct(k=>k.addProject),i=Fe(k=>k.setSessionSwitcherOpen),u=ot(k=>k.openNewSessionDraft),c=zt(k=>k.profiles),l=zt(k=>k.globalIdentity),f=zt(k=>k.defaultGitIdentityId),h=zt(k=>k.loadProfiles),g=zt(k=>k.loadGlobalIdentity),p=zt(k=>k.loadDefaultGitIdentityId),{canRequestAccess:d,requestAccess:y,startAccessing:j}=xc(),{isMobile:I}=Us(),C=m.useRef(null),B=m.useRef(null),$=m.useRef(new Map),[S,w]=m.useState(""),[x,N]=m.useState("~/"),[W,V]=m.useState([]),[F,_]=m.useState(!1),[H,J]=m.useState(!1),[D,oe]=m.useState(null),[U,z]=m.useState(0),[P,O]=m.useState(0),[M,G]=m.useState(!1),[E,K]=m.useState(!1),[q,Z]=m.useState(0),[Q,X]=m.useState(!1),[ee,de]=m.useState(""),[se,he]=m.useState(null),[le,Y]=m.useState(!1),ne=S||r,ce=m.useMemo(()=>new Set(o.map(k=>_t(k.path)).filter(k=>!!k)),[o]);m.useEffect(()=>{if(!s)return;N("~/"),V([]),O(0),G(!1),K(!1),X(!1),de(""),he(null),Y(!1),requestAnimationFrame(()=>Zs(C.current));let k=!1;return(async()=>{const Ce=await Rc();k||(w(Ce||r||""),requestAnimationFrame(()=>Zs(C.current)))})(),()=>{k=!0}},[r,s]),m.useEffect(()=>{s&&(h(),g(),p())},[p,h,g,s]);const v=m.useMemo(()=>{const k=new Map;l&&k.set(l.id,l);for(const ve of c)k.set(ve.id,ve);return Array.from(k.values())},[c,l]);m.useEffect(()=>{if(!s||!Q||se!==null)return;const k=typeof f=="string"?f.trim():"";if(k&&v.some(Ce=>Ce.id===k)){he(k);return}const ve=v.find(Ce=>Ce.authType==="ssh"||Ce.sshKey);ve&&he(ve.id)},[v,f,Q,s,se]);const L=m.useMemo(()=>v.find(k=>k.id===se)??null,[v,se]),te=m.useMemo(()=>to(x),[x]),ue=m.useMemo(()=>ds(x)?"":Tc(x),[x]),fe=m.useMemo(()=>ne?rr(te,ne):"",[te,ne]);m.useEffect(()=>{if(!s||!fe){V([]),oe(null);return}let k=!1;return _(!0),J(!1),oe(null),cs.listLocalDirectory(fe).then(ve=>{if(k)return;J(!1),oe(null);const Ce=ve.filter(De=>De.isDirectory).map(De=>({name:De.name,path:$s(De.path)})).sort((De,tt)=>De.name.localeCompare(tt.name));V(Ce)}).catch(ve=>{if(!k){V([]);const Ce=ai(ve)?ve.reason:"unknown";oe(Ce),J(Ce==="not-found")}}).finally(()=>{k||_(!1)}),()=>{k=!0}},[fe,U,s]);const be=m.useMemo(()=>{const k=ue.toLowerCase(),ve=le||ue.startsWith(".");return W.filter(Ce=>Ce.name.toLowerCase().startsWith(k)&&(ve||!Ce.name.startsWith(".")))},[ue,W,le]),Ie=m.useMemo(()=>{const k=[];Pc(x)&&k.push({type:"up",value:"browse:up",name:"..",path:so(x)});for(const ve of be){const Ce=_t(ve.path);k.push({type:"directory",value:`browse:${ve.path}`,name:ve.name,path:ve.path,disabled:!!(Ce&&ce.has(Ce))})}return k},[ce,be,x]);m.useEffect(()=>{O(0)},[x,Ie.length]);const Ee=m.useMemo(()=>ne?In(rr(x,ne)):"",[ne,x]),ze=_t(Ee),Qe=!!(ze&&ce.has(ze)),Ue=m.useMemo(()=>ue?be.find(k=>k.name===ue)??null:null,[ue,be]),qe=!!(Ee&&!Qe&&(D===null||D==="not-found")&&(ds(x)&&H||!ds(x)&&ue.trim().length>0&&Ue===null)),Ae=!M&&!E&&!Qe&&D!=="os-permission"&&D!=="invalid-response"&&D!=="unknown"&&!!Ee,it=Ae&&ee.trim().length>0,Re=Ie[P]??null,$e=!!(Re&&(Re.type==="up"||Re.type==="directory"&&!Re.disabled)),We=xn("mod"),Ge=n(Qe?"directoryExplorerDialog.actions.alreadyAdded":Q?M?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":M?"directoryExplorerDialog.actions.adding":qe?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");m.useLayoutEffect(()=>{const k=B.current;if(!k)return;const ve=()=>Z(Math.ceil(k.getBoundingClientRect().width));if(ve(),typeof ResizeObserver>"u")return;const Ce=new ResizeObserver(ve);return Ce.observe(k),()=>Ce.disconnect()},[Ge]),m.useLayoutEffect(()=>{const k=C.current;k&&(k.scrollLeft=k.scrollWidth)},[q,x]),m.useLayoutEffect(()=>{s&&Zs(C.current)},[s]),m.useLayoutEffect(()=>{const k=Ie[P];k&&$.current.get(k.value)?.scrollIntoView({block:"nearest"})},[P,Ie]);const at=m.useCallback(()=>{e(!1)},[e]),Pe=m.useCallback((k,ve)=>{I&&i(!1),u({selectedProjectId:k,directoryOverride:ve}),at()},[at,I,u,i]),Je=m.useCallback((k,ve)=>{k.stopPropagation();const Ce=_t(ve);if(Ce&&ce.has(Ce))return;const De=a(ve);if(!De){ke.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Pe(De.id,De.path)},[a,ce,Pe,n]),_e=m.useCallback(async k=>{if(!k||M)return;const ve=_t(k);if(ve&&ce.has(ve))return;let Ce=k;G(!0);try{const De=!Q&&qe&&_t(k)===_t(Ee);if(Q){const ft=ee.trim();if(!ft){ke.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}Ce=(await cs.cloneRepository({remoteUrl:ft,destinationPath:k,gitIdentityId:L?.id??null})).path}else De&&await cs.createDirectory(k,{asProject:!0});const tt=a(Ce);if(!tt){ke.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Pe(tt.id,tt.path)}catch(De){ke.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:De instanceof Error?De.message:n("directoryExplorerDialog.toast.unknownError")})}finally{G(!1)}},[a,ce,ee,Q,M,Pe,L?.id,qe,Ee,n]),Te=m.useCallback(k=>{N(Ic(k))},[]),Xe=m.useCallback(k=>{N(Dc(x,k.name))},[x]),nt=m.useCallback(k=>{if(k){if(k.type==="up"){k.path&&Te(k.path);return}k.disabled||Xe(k)}},[Te,Xe]),b=m.useCallback(async()=>{if(!(!d||E)){K(!0);try{const k=await y(Ee);if(!k.success||!k.path){k.error&&k.error!=="Directory selection cancelled"&&ke.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:k.error});return}const ve=await j(k.path);if(!ve.success){ke.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:ve.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}await _e(k.path)}catch(k){ke.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:k instanceof Error?k.message:n("directoryExplorerDialog.toast.unknownError")})}finally{K(!1)}}},[d,_e,E,y,j,n,Ee]),A=m.useCallback(k=>{if(k.key==="ArrowDown"){k.preventDefault(),O(ve=>Math.min(Ie.length-1,ve+1));return}if(k.key==="ArrowUp"){k.preventDefault(),O(ve=>Math.max(0,ve-1));return}if(k.key==="Enter"){if(k.preventDefault(),Ec(k)){_e(Ee);return}$e&&nt(Re);return}k.key==="Backspace"&&x===""&&(k.preventDefault(),at())},[nt,_e,at,$e,Re,x,Ie.length,Ee]),ge=t.jsxs("button",{type:"button",onClick:()=>Y(k=>!k),className:"flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40",children:[le?t.jsx(R,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(R,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),me=t.jsxs("div",{className:"px-2.5 py-1.5",children:[Q?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(bt,{value:ee,onChange:k=>de(k.target.value),placeholder:n("directoryExplorerDialog.clone.remoteUrlPlaceholder"),className:"min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),t.jsx(eo,{activeProfile:L,identities:v,onSelect:k=>he(k.id),isApplying:M,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(R,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(bt,{ref:C,value:x,onChange:k=>N($s(k.target.value)),onKeyDown:A,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!I&&q>0?{paddingRight:`${q+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),I?null:t.jsx(Ne,{ref:B,variant:"outline",size:"xs",tabIndex:-1,className:"absolute right-1.5 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta",disabled:Q?!it:!Ae,onMouseDown:k=>k.preventDefault(),onClick:()=>{_e(Ee)},title:Ge,children:Ge})]})]}),Se=t.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm",children:t.jsxs("div",{className:"max-h-[min(28rem,58vh)] overflow-y-auto p-2",children:[t.jsx("div",{className:"px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80",children:n("directoryExplorerDialog.browse.directories")}),F?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):D&&D!=="not-found"?t.jsxs("div",{className:"flex flex-col items-center gap-3 px-4 py-10 text-center",children:[t.jsx("div",{className:"typography-ui-label text-status-error",children:n(D==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[D==="os-permission"&&d?t.jsx(Ne,{size:"xs",onClick:()=>{b()},disabled:E,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(Ne,{variant:"outline",size:"xs",onClick:()=>z(k=>k+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):Ie.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:Ie.map((k,ve)=>{const Ce=ve===P;return t.jsxs("button",{ref:De=>{De?$.current.set(k.value,De):$.current.delete(k.value)},type:"button",disabled:k.type==="directory"&&k.disabled,onMouseEnter:()=>O(ve),onMouseDown:De=>De.preventDefault(),onClick:()=>nt(k),className:ie("flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ce&&"bg-interactive-selection text-interactive-selection-foreground",!Ce&&"hover:bg-interactive-hover/50",k.type==="directory"&&k.disabled&&"cursor-not-allowed opacity-45 hover:bg-transparent"),children:[k.type==="up"?t.jsx(R,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(R,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:k.name})}),k.type==="directory"&&k.disabled?t.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground",children:n("directoryExplorerDialog.browse.addedBadge")}):k.type==="directory"?t.jsx("button",{type:"button",onMouseDown:De=>De.stopPropagation(),onClick:De=>Je(De,k.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null]},k.value)})})]})}),Me=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[me,Se]}),Be=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(R,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(R,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(R,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:We}),t.jsx(R,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),He=()=>t.jsxs(t.Fragment,{children:[I?null:Be,t.jsxs("div",{className:ie("flex w-full flex-row justify-end gap-2 sm:w-auto",I&&"justify-stretch"),children:[d?t.jsx(Ne,{variant:"ghost",size:"xs",onClick:b,disabled:M||E||Q,children:n(E?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>X(k=>!k),disabled:M||E,className:ie(I&&"flex-1"),children:n(Q?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),I?t.jsx(Ne,{size:"xs",onClick:()=>{_e(Ee)},disabled:Q?!it:!Ae,className:"flex-1",children:Ge}):null]})]});return I?t.jsx(ys,{open:s,onClose:at,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px]",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:He()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:ge}),Me]})}):t.jsx(js,{open:s,onOpenChange:e,children:t.jsxs(ks,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(Ws,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Ss,{children:n("directoryExplorerDialog.title")}),t.jsx(ua,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),ge]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:Me}),t.jsx(Sn,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:He()})]})})};function or(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=[...e.map(c=>({label:c,value:c,source:"local"})),...n.map(c=>({label:c,value:`remotes/${c}`,source:"remote"}))],i=fn(a,o,c=>[c.label]),u=new Set(i);return{matching:i,otherLocal:a.filter(c=>c.source==="local"&&!u.has(c)).map(c=>c.label),otherRemote:a.filter(c=>c.source==="remote"&&!u.has(c)).map(c=>c.label)}}const en="oc:lastWorktreeSourceBranch",Ac=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,Bc=({branches:s,savedSourceBranch:e,rootBranch:n})=>!!(e&&s.includes(e))&&e?{sourceBranch:e,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&s.includes(n)?n:s.includes("main")?"main":s.includes("master")?"master":s[0]??"",shouldClearSavedSourceBranch:!!e};function Mc({open:s,onOpenChange:e,onSelect:n}){const{t:r}=et(),o=Fe(v=>v.isMobile),{github:a}=Nn(),i=Fs(v=>v.status),u=Fs(v=>v.hasChecked),c=Fe(v=>v.setSettingsDialogOpen),l=Fe(v=>v.setSettingsPage),f=Ct(v=>v.getActiveProject()),h=f?.path??null,g=ae.useMemo(()=>h&&f?{id:f.id,path:h}:null,[f,h]),[p,d]=ae.useState("issues"),[y,j]=ae.useState(""),[I,C]=ae.useState([]),[B,$]=ae.useState([]),[S,w]=ae.useState(!1),[x,N]=ae.useState(!1),[W,V]=ae.useState(null),[F,_]=ae.useState(null),[H,J]=ae.useState(null),[D,oe]=ae.useState(!1),[U,z]=ae.useState(new Map),[P,O]=ae.useState(1),[M,G]=ae.useState(!1),E=fa(y,350),K=ae.useCallback(async v=>{if(!(!h||!a)&&!(u&&i?.connected===!1)){w(!0),V(null),O(1),G(!1);try{if(p==="issues"&&a.issuesList){const L=await a.issuesList(h,{page:1,query:v});L.connected===!1?(V(r("session.githubIntegration.error.notConnected")),C([])):(C(L.issues??[]),O(L.page??1),G(!!L.hasMore))}else if(p==="prs"&&a.prsList){const L=await a.prsList(h,{page:1,query:v});L.connected===!1?(V(r("session.githubIntegration.error.notConnected")),$([])):($(L.prs??[]),O(L.page??1),G(!!L.hasMore))}}catch(L){V(L instanceof Error?L.message:r("session.githubIntegration.error.loadDataFailed"))}finally{w(!1)}}},[h,a,u,i,p,r]);ae.useEffect(()=>{if(!s||!h||u&&i?.connected===!1||!a)return;if(!E.trim()){K();return}const v=new AbortController;w(!0),V(null),O(1),G(!1);const L=p==="issues"&&a.issuesList?a.issuesList(h,{page:1,query:E.trim()}):p==="prs"&&a.prsList?a.prsList(h,{page:1,query:E.trim()}):null;if(!L){w(!1);return}return L.then(te=>{v.signal.aborted||("issues"in te?te.connected===!1?(V(r("session.githubIntegration.error.notConnected")),C([])):(C(te.issues??[]),O(te.page??1),G(!!te.hasMore)):"prs"in te&&(te.connected===!1?(V(r("session.githubIntegration.error.notConnected")),$([])):($(te.prs??[]),O(te.page??1),G(!!te.hasMore))))}).catch(te=>{v.signal.aborted||V(te instanceof Error?te.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{v.signal.aborted||w(!1)}),()=>v.abort()},[s,h,a,u,i,p,E,K,r]);const q=ae.useCallback(async()=>{if(!(!h||!a)&&!(S||x)&&M){N(!0);try{const v=P+1;if(p==="issues"&&a.issuesList){const L=E.trim()?await a.issuesList(h,{page:v,query:E.trim()}):await a.issuesList(h,{page:v});L.connected!==!1&&(C(te=>[...te,...L.issues??[]]),O(L.page??v),G(!!L.hasMore))}else if(p==="prs"&&a.prsList){const L=E.trim()?await a.prsList(h,{page:v,query:E.trim()}):await a.prsList(h,{page:v});L.connected!==!1&&($(te=>[...te,...L.prs??[]]),O(L.page??v),G(!!L.hasMore))}}catch{}finally{N(!1)}}},[h,a,p,P,M,S,x,E]);ae.useEffect(()=>{if(!s){d("issues"),j(""),C([]),$([]),_(null),J(null),oe(!1),V(null),z(new Map),O(1),G(!1);return}K()},[s,K]);const Z=ae.useCallback(async v=>{if(!(!g||!v)&&!U.has(v))try{const te=(await Cr(g,{mode:"new",branchName:v,worktreeName:v})).errors.find(ue=>ue.code==="branch_in_use");z(ue=>new Map(ue).set(v,{isValid:!te,error:te?r(te.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{z(L=>new Map(L).set(v,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[g,U,r]);ae.useEffect(()=>{!s||p!=="prs"||B.forEach(v=>{v.head&&Z(v.head)})},[s,p,B,Z]);const Q=u&&i?.connected===!0,X=()=>{l("github"),c(!0)},ee=v=>{_(v),J(null)},de=v=>{J(v),_(null)},se=()=>{F?n({type:"issue",item:F}):H&&n({type:"pr",item:H,includeDiff:D}),e(!1)},he=()=>{_(null),J(null),oe(!1)},le=F||H&&U.get(H.head??"")?.isValid!==!1,Y=v=>v.head?U.get(v.head)?.isValid===!1:!0,ne=t.jsx(t.Fragment,{children:Q?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(R,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(bt,{value:y,onChange:v=>j(v.target.value),placeholder:r(p==="issues"?"session.githubIntegration.search.issuesPlaceholder":"session.githubIntegration.search.prsPlaceholder"),className:"h-8 pl-9"})]}),t.jsx("div",{className:"mt-2 h-[300px] overflow-hidden",children:t.jsxs("div",{className:"h-full overflow-y-auto",children:[S&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(R,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),W&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(R,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:W})]})}),!S&&!W&&p==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[I.length>0?I.map(v=>t.jsx("button",{onClick:()=>ee(v),className:ie("w-full text-left px-2 py-1.5 rounded transition-colors",F?.number===v.number?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",v.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:v.title}),v.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block",children:[v.sourceRepo.owner,"/",v.sourceRepo.repo]}):null]})]})},`${v.sourceRepo?.owner??""}-${v.sourceRepo?.repo??""}-${v.number}`)):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noIssuesFound")}),M&&!x&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{q()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),x&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!S&&!W&&p==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[B.length>0?B.map(v=>{const L=Y(v),te=v.head?U.get(v.head):void 0;return t.jsx("button",{onClick:()=>!L&&de(v),disabled:L,className:ie("w-full text-left px-2 py-1.5 rounded transition-colors",H?.number===v.number?"bg-interactive-selection text-interactive-selection-foreground":L?"opacity-50 cursor-not-allowed":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",v.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:v.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[v.head," → ",v.base]}),v.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[v.sourceRepo.owner,"/",v.sourceRepo.repo]}):null,L&&te?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:te.error})]})]})]})},`${v.sourceRepo?.owner??""}-${v.sourceRepo?.repo??""}-${v.number}`)}):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noPullRequestsFound")}),M&&!x&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{q()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),x&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(R,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:r("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:r("session.githubIntegration.connect.description")})]}),t.jsx(Ne,{onClick:X,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),ce=t.jsxs("div",{className:ie("w-full",o?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:ie("flex items-center gap-4",o?"w-full justify-center order-1":"flex-1"),children:[!o&&(F||H)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:F?r("session.githubIntegration.selected.issueNumber",{number:F.number}):r("session.githubIntegration.selected.prNumber",{number:H?.number??""})}),t.jsx("button",{onClick:he,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),p==="prs"&&H&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(Ns,{checked:D,onChange:v=>oe(v),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:ie("flex gap-2",o?"w-full order-2":"justify-end"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),className:ie(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(Ne,{size:"sm",onClick:se,disabled:!le,className:ie(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(ys,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:Q?ce:void 0,renderHeader:v=>t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border/40",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:r("session.githubIntegration.title")}),v]}),t.jsx("div",{className:"w-full",children:t.jsx(vs,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(R,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:L=>{d(L),j("")},variant:"active-pill",layoutMode:"fit"})}),(F||H)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:F?r("session.githubIntegration.selected.issueNumber",{number:F.number}):r("session.githubIntegration.selected.prNumber",{number:H?.number??""})}),t.jsx("button",{onClick:he,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:ne}):t.jsx(js,{open:s,onOpenChange:e,children:t.jsxs(ks,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(Ws,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ss,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(R,{name:"github",className:"h-5 w-5"}),r("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(vs,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(R,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:v=>{d(v),j("")},variant:"active-pill",layoutMode:"fit"})})]})}),ne,t.jsx(Sn,{className:"mt-1",children:ce})]})})})}const bs=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),Lc=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",ar=(s,e,n)=>{const r=bs(s.head||"");if(!r)throw new Error("PR head branch is missing");if(e.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};const o=n.find(l=>{const f=l.indexOf("/");return f<=0||f>=l.length-1?!1:l.slice(f+1)===r});if(o){const l=o.indexOf("/"),f=o.slice(0,l);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:f,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${f}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",u=`pr-${Lc(i)}`,c=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!c)throw new Error("PR head repository URL is unavailable. The fork may have been deleted; push the branch to a reachable repository and try again.");return{existingBranch:`remotes/${u}/${r}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:u,ensureRemoteUrl:c,sourceLabel:`${u}/${r}`}},xt=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,"").split("/").join("-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,80),Fc=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
|
|
3
|
+
${JSON.stringify(e,null,2)}`},Oc=s=>`GitHub pull request context (JSON)
|
|
4
|
+
${JSON.stringify(s,null,2)}`;function Qu({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=et(),{github:o,git:a}=Nn(),i=Fe(b=>b.isMobile),u=Fs(b=>b.status),c=Fs(b=>b.hasChecked),l=Ct(b=>b.getActiveProject()),f=l?.path??null,h=ae.useMemo(()=>f&&l?{id:l.id,path:f}:null,[l,f]),[g,p]=ae.useState("new-branch"),[d,y]=ae.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[j,I]=ae.useState({selectedBranch:"",worktreeName:""}),C=ma(f),B=ha(f),$=Cn(b=>b.fetchBranches),S=ae.useMemo(()=>C?.all?C.all.filter(b=>!b.startsWith("remotes/")).sort():[],[C]),w=ae.useMemo(()=>C?.all?C.all.filter(b=>b.startsWith("remotes/")).map(b=>b.replace(/^remotes\//,"")).sort():[],[C]),x=ot(b=>b.availableWorktreesByProject),N=ae.useMemo(()=>{if(!f)return new Set;const b=x.get(f)??[];return new Set(b.map(A=>A.name))},[x,f]),W=ae.useCallback((b=10)=>{for(let A=0;A<b;A++){const ge=qs();if(!N.has(ge))return ge}return`${qs()}-${Date.now().toString(36).slice(-4)}`},[N]),[V,F]=ae.useState(!1),[_,H]=ae.useState(!1),[J,D]=ae.useState(!1),[oe,U]=ae.useState(!1),[z,P]=ae.useState(!1),[O,M]=ae.useState(""),[G,E]=ae.useState(""),K=ae.useRef(null),q=ae.useRef(null),Z=ae.useRef(null),Q=ae.useRef(null),X=ae.useCallback(b=>{b.stopPropagation()},[]),ee=ae.useCallback(b=>{let A=b;for(;A&&A!==document.body;){const{overflowY:ge}=window.getComputedStyle(A);if((ge==="auto"||ge==="scroll")&&A.scrollHeight>A.clientHeight)return A;A=A.parentElement}return null},[]),de=ae.useCallback(b=>{b&&(b.scrollTop=0)},[]),se=ae.useCallback(b=>{const A=b.current?.querySelector('[data-slot="command-list"]')??null;de(A)},[de]),he=ae.useCallback(b=>{const A=ee(b.current);de(A)},[ee,de]),le=ae.useMemo(()=>or({localBranches:S,remoteBranches:w,query:O}),[S,w,O]),Y=ae.useMemo(()=>or({localBranches:S,remoteBranches:w,query:G}),[S,w,G]),ne=O.trim().length>0,ce=G.trim().length>0,v=le.matching.length>0,L=Y.matching.length>0,te=!!(f&&a),ue=ae.useCallback(()=>{!f||!a||$(f,a)},[f,a,$]);ae.useEffect(()=>{!s||!f||!a||C?.all||$(f,a)},[s,f,a,C?.all,$]),ae.useEffect(()=>{!_&&!oe&&M("")},[_,oe]),ae.useEffect(()=>{!J&&!z&&E("")},[J,z]),ae.useEffect(()=>{_&&se(K),oe&&he(Z)},[_,oe,O,se,he]),ae.useEffect(()=>{J&&se(q),z&&he(Q)},[J,z,G,se,he]);const[fe,be]=ae.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Ie,Ee]=ae.useState(!1),[ze,Qe]=ae.useState(null),Ue=ae.useCallback(()=>{const b=vt.getState(),A=b.getVisibleAgents();if(b.settingsDefaultAgent){const ge=A.find(me=>me.name===b.settingsDefaultAgent);if(ge)return ge.name}return A.find(ge=>ge.name==="build")?.name||A[0]?.name},[]),qe=ae.useCallback(()=>{const b=vt.getState(),A=b.settingsDefaultModel;if(!A)return null;const ge=Nr(A);if(!ge)return null;const{providerId:me,modelId:Se}=ge;return b.getModelMetadata(me,Se)?{providerID:me,modelID:Se}:null},[]),Ae=ae.useCallback((b,A)=>{const ge=vt.getState(),me=ge.settingsDefaultVariant,Se=ge.currentProviderId===b&&ge.currentModelId===A?ge.currentVariant:void 0,He=ge.providers.find(k=>k.id===b)?.models.find(k=>k.id===A)?.variants;if(!He)return me||Se||void 0;if(me&&Object.prototype.hasOwnProperty.call(He,me))return me;if(Se&&Object.prototype.hasOwnProperty.call(He,Se))return Se},[]),it=ae.useCallback(async b=>{if(!f||!o)return;const A=vt.getState(),ge=Ir.getState().lastUsedProvider,me=qe(),Se=me?.providerID||A.currentProviderId||ge?.providerID,Me=me?.modelID||A.currentModelId||ge?.modelID,Be=Ue()||A.currentAgentName||void 0;if(!Se||!Me){ke.error(r("session.newWorktree.error.noModelSelected"));return}const He=Ae(Se,Me);if(b.issue){if(!o.issueGet||!o.issueComments)return;const k=await o.issueGet(f,b.issue.number,{sourceRepo:b.issue.sourceRepo??null});if(k.connected===!1||!k.repo||!k.issue)throw new Error("Failed to load issue context");const ve=await o.issueComments(f,b.issue.number,{sourceRepo:b.issue.sourceRepo??null});if(ve.connected===!1)throw new Error("Failed to load issue comments");const Ce=await ls("github.issue.review.visible",{issue_number:String(b.issue.number)}),De=await ls("github.issue.review.instructions"),tt=Fc({repo:k.repo,issue:k.issue,comments:ve.comments??[]});await ot.getState().sendMessage(Ce,Se,Me,Be,void 0,void 0,[{text:De,synthetic:!0},{text:tt,synthetic:!0}],He,void 0,{sessionId:b.sessionId}),Mn(b.sessionId,b.directory,Ln({url:k.issue.url,number:k.issue.number,title:k.issue.title,kind:"issue",author:k.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),ke.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(b.pr){if(!o.prContext)return;const k=await o.prContext(f,b.pr.number,{sourceRepo:b.pr.sourceRepo??null,includeDiff:b.includeDiff,includeCheckDetails:!1});if(k.connected===!1||!k.repo||!k.pr)throw new Error("Failed to load PR context");const ve=await ls("github.pr.review.visible",{pr_number:String(b.pr.number)}),Ce=await ls("github.pr.review.instructions"),De=Oc(k);await ot.getState().sendMessage(ve,Se,Me,Be,void 0,void 0,[{text:Ce,synthetic:!0},{text:De,synthetic:!0}],He,void 0,{sessionId:b.sessionId}),Mn(b.sessionId,b.directory,Ln({url:k.pr.url,number:k.pr.number,title:k.pr.title,kind:"pull",author:k.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),ke.success(r("session.newWorktree.toast.sessionFromPr"))}},[o,f,Ue,qe,Ae,r]),Re=g==="new-branch"?d:j;ae.useEffect(()=>{if(!s||!C?.all||!f||d.sourceBranch)return;const b=d.sourceBranch;let A=!1;return(async()=>{try{const me=await pa(f).catch(()=>null);if(A)return;const Se=localStorage.getItem(en),{sourceBranch:Me,shouldClearSavedSourceBranch:Be}=Bc({branches:C.all,savedSourceBranch:Se,rootBranch:me});if(Be&&localStorage.removeItem(en),A||b)return;Me&&y(He=>({...He,sourceBranch:Me}))}catch{}})(),()=>{A=!0}},[s,C?.all,f,d.sourceBranch]),ae.useLayoutEffect(()=>{if(!s)return;p("new-branch"),I({selectedBranch:"",worktreeName:""}),H(!1),D(!1),U(!1),P(!1),M(""),E(""),be({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const b=W();y({branchName:b,worktreeName:b,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,W]),ae.useEffect(()=>{if(g!=="new-branch"||!d.isSyncingWorktreeName)return;const b=bs(d.branchName),A=xt(b);y(ge=>({...ge,worktreeName:A}))},[g,d.branchName,d.isSyncingWorktreeName]);const $e=ae.useCallback(async()=>{if(!h||!fe.touched||Ie)return;ze&&ze.abort();const b=new AbortController;Qe(b),be(A=>({...A,isValidating:!0}));try{const A=g==="new-branch"?d.branchName:j.selectedBranch,ge=Re.worktreeName,me=bs(A),Se=xt(ge);let Me=null,Be=null;if(me||(Me=r("session.newWorktree.error.branchNameRequired")),Se||(Be=r("session.newWorktree.error.worktreeDirectoryRequired")),me&&Se){const He=g==="new-branch"?d.linkedPr:null,k=He?ar(He,S,w):null,ve=await Cr(h,{mode:g==="existing-branch"||k?"existing":"new",branchName:me,worktreeName:Se,existingBranch:k?.existingBranch??(g==="existing-branch"?me:void 0),...k?.ensureRemoteName?{ensureRemoteName:k.ensureRemoteName}:{},...k?.ensureRemoteUrl?{ensureRemoteUrl:k.ensureRemoteUrl}:{}});if(b.signal.aborted)return;ve.ok||ve.errors.forEach(Ce=>{if(Ce.code==="worktree_exists"){Be=Be??Ce.message;return}Ce.code.startsWith("branch_")&&(Me=Me??Ce.message)})}b.signal.aborted||be(He=>({...He,isValidating:!1,branchError:Me,worktreeError:Be}))}catch{b.signal.aborted||be(A=>({...A,isValidating:!1}))}},[h,g,d.branchName,d.linkedPr,j.selectedBranch,Re.worktreeName,S,w,fe.touched,ze,Ie,r]),We=g==="new-branch"?d.branchName:j.selectedBranch;ae.useEffect(()=>{if(!s||!h||!fe.touched||Ie)return;const b=setTimeout(()=>{$e()},300);return()=>clearTimeout(b)},[Re.worktreeName,We,s,h,$e,fe.touched,Ie]);const Ge=async()=>{if(!h||!f){ke.error(r("session.newWorktree.error.noActiveProject"));return}be(Se=>({...Se,touched:!0}));const b=g==="new-branch"?d.branchName:j.selectedBranch,A=Re.worktreeName,ge=bs(b),me=xt(A);if(!ge){ke.error(r("session.newWorktree.error.branchNameRequired"));return}if(!me){ke.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}ze&&(ze.abort(),Qe(null)),be(Se=>({...Se,isValidating:!1,branchError:null,worktreeError:null})),Ee(!0);try{const Se=g==="new-branch"?d.linkedPr:null,Me=g==="new-branch"?d.linkedIssue:null,Be=g==="new-branch"?d.linkedPr:null,He=g==="new-branch"?d.includePrDiff:!1,k=!!(Me||Be),ve=await xr(h),Ce=d.sourceBranch;let De="";const tt=(()=>{if(Se){const st=ar(Se,S,w);return De=st.sourceLabel,{preferredName:ge||me,mode:"existing",branchName:ge,worktreeName:me,existingBranch:st.existingBranch,setupCommands:ve,setUpstream:st.setUpstream,upstreamRemote:st.upstreamRemote,upstreamBranch:st.upstreamBranch,returnAfterDirectoryCreated:!0,...st.ensureRemoteName?{ensureRemoteName:st.ensureRemoteName}:{},...st.ensureRemoteUrl?{ensureRemoteUrl:st.ensureRemoteUrl}:{}}}return De=g==="new-branch"?Ce:"",{preferredName:ge||me,mode:g==="existing-branch"?"existing":"new",branchName:g==="existing-branch"?void 0:ge,worktreeName:me,existingBranch:g==="existing-branch"?ge:void 0,setupCommands:ve,returnAfterDirectoryCreated:!0,...Ce&&g==="new-branch"?{startRef:Ce}:{}}})(),ft=await ga(f,tt),rt=await xa(h,ft);let dt=null;if(k){await br(h)&&await ba(rt.path);const st=Me?`#${Me.number} ${Me.title}`.trim():Be?`#${Be.number} ${Be.title}`.trim():r("session.newWorktree.newSessionTitle"),T=await ya(st,rt.path,null);if(!T?.id)throw new Error("Failed to create session");dt=T.id,n?.(rt.path,{sessionId:dt}),e(!1),Ee(!1),wa(T.id,st).catch(()=>{});try{ot.getState().initializeNewOpenChamberSession(T.id,vt.getState().agents)}catch{}}else e(!1),Ee(!1);const lt=Ac({mode:g,sourceBranch:d.sourceBranch,linkedPr:!!d.linkedPr,selectedBranch:j.selectedBranch});lt&&localStorage.setItem(en,lt),ke.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${rt.branch||rt.name}${De?` ${r("session.newWorktree.fromSource",{source:De})}`:""}`})}),dt?it({sessionId:dt,directory:rt.path,issue:Me,pr:Be,includeDiff:He}).catch(st=>{const T=st instanceof Error?st.message:r("session.newWorktree.error.sendGitHubContextFailed");ke.error(r("session.newWorktree.error.sendGitHubContextFailed"),{description:T})}):n?.(rt.path)}catch(Se){const Me=Se instanceof Error?Se.message:r("session.newWorktree.error.createWorktreeFailed");ke.error(r("session.newWorktree.error.createWorktreeFailed"),{description:Me})}finally{Ee(!1)}},at=b=>{p(b),be(A=>({...A,touched:!1,branchError:null,worktreeError:null}))},Pe=b=>{if(!b){y(A=>({...A,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(b.type==="issue"){const A=b.item,ge=`issue-${A.number}-${qs()}`;y(me=>({...me,linkedIssue:A,linkedPr:null,includePrDiff:!1,branchName:ge,worktreeName:xt(ge),isSyncingWorktreeName:!0}))}else if(b.type==="pr"){const A=b.item;y(ge=>({...ge,linkedPr:A,linkedIssue:null,includePrDiff:b.includeDiff??!1,branchName:A.head,worktreeName:xt(A.head),isSyncingWorktreeName:!0}))}},Je=c&&u?.connected===!0,Te=(g==="existing-branch"?!!j.selectedBranch&&!!j.worktreeName&&!fe.branchError&&!fe.worktreeError:!!bs(d.branchName)&&!!d.worktreeName&&!fe.branchError&&!fe.worktreeError)&&!Ie,Xe=()=>{y(b=>({...b,linkedIssue:null,linkedPr:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},nt=t.jsxs("div",{className:ie("flex gap-2",i?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:ie("flex items-center gap-1.5 text-destructive",i?"w-full justify-center order-first":"mr-auto"),children:fe.touched&&(fe.branchError||fe.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(R,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:fe.branchError||fe.worktreeError})]})}),t.jsxs("div",{className:ie("flex gap-2",i&&"w-full"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ie,className:ie(i&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:Ge,disabled:!Te||Ie,className:ie("gap-1.5",i&&"flex-1"),children:[Ie&&t.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ie?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[i?t.jsxs(ys,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:nt,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(vs,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(R,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:b=>at(b),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>U(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:j.selectedBranch?"text-foreground":"text-muted-foreground",children:j.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:ue,disabled:!te||B,title:r("session.newWorktree.fetchBranches"),children:B?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"})})]}),t.jsx(ys,{open:oe,title:r("session.newWorktree.selectBranch"),onClose:()=>U(!1),children:t.jsxs("div",{className:"space-y-4",ref:Z,children:[t.jsx(bt,{value:O,onChange:b=>M(b.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),B?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&w.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[ne&&v&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:le.matching.map(b=>t.jsx("button",{onClick:()=>{I(A=>({...A,selectedBranch:b.value,worktreeName:xt(b.label)})),be(A=>({...A,touched:!0})),U(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",j.selectedBranch===b.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:b.label})},`${b.source}-${b.value}`))})]}),ne&&!v&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),le.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(ne?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:le.otherLocal.map(b=>t.jsx("button",{onClick:()=>{I(A=>({...A,selectedBranch:b,worktreeName:xt(b)})),be(A=>({...A,touched:!0})),U(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",j.selectedBranch===b?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:b})},b))})]}),le.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(ne?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:le.otherRemote.map(b=>t.jsx("button",{onClick:()=>{I(A=>({...A,selectedBranch:`remotes/${b}`,worktreeName:xt(b)})),be(A=>({...A,touched:!0})),U(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",j.selectedBranch===`remotes/${b}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:b})},`remotes/${b}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.branchName")}),g==="new-branch"&&Je&&t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>F(!0),className:"gap-1.5 h-7",children:[t.jsx(R,{name:"github",className:"size-4 text-status-success"}),d.linkedIssue||d.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(bt,{value:d.branchName,onChange:b=>{y(A=>({...A,branchName:b.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>be(b=>({...b,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!d.linkedPr,className:ie("h-8",fe.touched&&fe.branchError&&"border-destructive",d.linkedPr&&"bg-muted text-muted-foreground")}),d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:d.linkedPr.head})})]}),d.linkedIssue&&!d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:d.linkedIssue.number,title:d.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const b=xt(g==="new-branch"?d.branchName:"");y(A=>({...A,worktreeName:b,isSyncingWorktreeName:!0}))},disabled:!d.branchName||d.worktreeName===xt(d.branchName),className:ie("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",d.worktreeName===xt(d.branchName)||!d.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(R,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(bt,{value:Re.worktreeName,onChange:b=>{g==="new-branch"?y(A=>({...A,worktreeName:b.target.value,isSyncingWorktreeName:!1})):I(A=>({...A,worktreeName:b.target.value}))},onBlur:()=>be(b=>({...b,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:ie("h-8",fe.touched&&fe.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!d.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>P(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:d.sourceBranch?"text-foreground":"text-muted-foreground",children:d.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),d.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:d.sourceBranch})}),t.jsx(ys,{open:z,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>P(!1),children:t.jsxs("div",{className:"space-y-4",ref:Q,children:[t.jsx(bt,{value:G,onChange:b=>E(b.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),B?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&w.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[ce&&L&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:Y.matching.map(b=>t.jsx("button",{onClick:()=>{y(A=>({...A,sourceBranch:b.value})),P(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",d.sourceBranch===b.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:b.label})},`${b.source}-${b.value}`))})]}),ce&&!L&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),Y.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(ce?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherLocal.map(b=>t.jsx("button",{onClick:()=>{y(A=>({...A,sourceBranch:b})),P(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",d.sourceBranch===b?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:b})},b))})]}),Y.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(ce?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherRemote.map(b=>t.jsx("button",{onClick:()=>{y(A=>({...A,sourceBranch:`remotes/${b}`})),P(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",d.sourceBranch===`remotes/${b}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:b})},`remotes/${b}`))})]})]})]})})]}),(d.linkedIssue||d.linkedPr)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),d.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:d.linkedIssue.number})}),d.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:d.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:d.linkedIssue?.title||d.linkedPr?.title}),t.jsx("a",{href:d.linkedIssue?.url||d.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:b=>b.stopPropagation(),children:t.jsx(R,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Xe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[d.linkedPr.head," → ",d.linkedPr.base]}),d.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx(js,{open:s,onOpenChange:e,children:t.jsxs(ks,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(Ws,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ss,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(R,{name:"git-branch",className:"h-5 w-5"}),r("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(vs,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(R,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:b=>at(b),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs($t,{open:_,onOpenChange:H,children:[t.jsx(Wt,{asChild:!0,children:t.jsxs("button",{type:"button",className:ie(Fn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:ie("truncate",j.selectedBranch?"text-foreground":"text-muted-foreground"),children:j.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Ut,{align:"start",sideOffset:6,portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:K,children:t.jsxs(mn,{shouldFilter:!1,children:[t.jsx(hn,{placeholder:r("session.newWorktree.searchBranches"),value:O,onValueChange:M,onKeyDown:X}),t.jsx(pn,{disableHorizontal:!0,children:B?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&w.length===0?t.jsx(gn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ne&&v&&t.jsx(Ft,{heading:r("session.newWorktree.matchingBranches"),children:le.matching.map(b=>t.jsx(Dt,{value:b.value,onSelect:()=>{I(A=>({...A,selectedBranch:b.value,worktreeName:xt(b.label)})),be(A=>({...A,touched:!0})),H(!1)},children:t.jsx("span",{className:"typography-small break-all",children:b.label})},`${b.source}-${b.value}`))}),ne&&!v&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),le.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[ne&&t.jsx(is,{}),t.jsx(Ft,{heading:r(ne?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:le.otherLocal.map(b=>t.jsx(Dt,{value:b,onSelect:()=>{I(A=>({...A,selectedBranch:b,worktreeName:xt(b)})),be(A=>({...A,touched:!0})),H(!1)},children:t.jsx("span",{className:"typography-small break-all",children:b})},`local-${b}`))})]}),le.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(le.otherLocal.length>0||ne)&&t.jsx(is,{}),t.jsx(Ft,{heading:r(ne?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:le.otherRemote.map(b=>t.jsx(Dt,{value:`remotes/${b}`,onSelect:()=>{I(A=>({...A,selectedBranch:`remotes/${b}`,worktreeName:xt(b)})),be(A=>({...A,touched:!0})),H(!1)},children:t.jsx("span",{className:"typography-small break-all",children:b})},`remote-${b}`))})]})]})})]})})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:ue,disabled:!te||B,title:r("session.newWorktree.fetchBranches"),children:B?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.branchName")}),g==="new-branch"&&Je&&t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>F(!0),className:"gap-1.5 h-7",children:[t.jsx(R,{name:"github",className:"size-4 text-status-success"}),d.linkedIssue||d.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(bt,{value:d.branchName,onChange:b=>{y(A=>({...A,branchName:b.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>be(b=>({...b,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!d.linkedPr,className:ie("h-8",fe.touched&&fe.branchError&&"border-destructive",d.linkedPr&&"bg-muted text-muted-foreground")}),d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:d.linkedPr.head})})]}),d.linkedIssue&&!d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:d.linkedIssue.number,title:d.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const b=xt(g==="new-branch"?d.branchName:"");y(A=>({...A,worktreeName:b,isSyncingWorktreeName:!0}))},disabled:!d.branchName||d.worktreeName===xt(d.branchName),className:ie("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",d.worktreeName===xt(d.branchName)||!d.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(R,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(bt,{value:Re.worktreeName,onChange:b=>{g==="new-branch"?y(A=>({...A,worktreeName:b.target.value,isSyncingWorktreeName:!1})):I(A=>({...A,worktreeName:b.target.value}))},onBlur:()=>be(b=>({...b,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:ie("h-8",fe.touched&&fe.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!d.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs($t,{open:J,onOpenChange:D,children:[t.jsx(Wt,{asChild:!0,children:t.jsxs("button",{type:"button",className:ie(Fn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:ie("truncate",d.sourceBranch?"text-foreground":"text-muted-foreground"),children:d.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Ut,{align:"start",portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:q,children:t.jsxs(mn,{shouldFilter:!1,children:[t.jsx(hn,{placeholder:r("session.newWorktree.searchBranches"),value:G,onValueChange:E,onKeyDown:X}),t.jsx(pn,{disableHorizontal:!0,children:B?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&w.length===0?t.jsx(gn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ce&&L&&t.jsx(Ft,{heading:r("session.newWorktree.matchingBranches"),children:Y.matching.map(b=>t.jsx(Dt,{value:b.value,onSelect:()=>{y(A=>({...A,sourceBranch:b.value})),D(!1)},children:t.jsx("span",{className:"typography-small break-all",children:b.label})},`${b.source}-${b.value}`))}),ce&&!L&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),Y.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[ce&&t.jsx(is,{}),t.jsx(Ft,{heading:r(ce?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:Y.otherLocal.map(b=>t.jsx(Dt,{value:b,onSelect:()=>{y(A=>({...A,sourceBranch:b})),D(!1)},children:t.jsx("span",{className:"typography-small break-all",children:b})},`local-${b}`))})]}),Y.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(Y.otherLocal.length>0||ce)&&t.jsx(is,{}),t.jsx(Ft,{heading:r(ce?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:Y.otherRemote.map(b=>t.jsx(Dt,{value:`remotes/${b}`,onSelect:()=>{y(A=>({...A,sourceBranch:`remotes/${b}`})),D(!1)},children:t.jsx("span",{className:"typography-small break-all",children:b})},`remote-${b}`))})]})]})})]})})]}),d.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:d.sourceBranch})})]}),(d.linkedIssue||d.linkedPr)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),d.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:d.linkedIssue.number})}),d.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:d.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:d.linkedIssue?.title||d.linkedPr?.title}),t.jsx("a",{href:d.linkedIssue?.url||d.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:b=>b.stopPropagation(),children:t.jsx(R,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Xe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),d.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[d.linkedPr.head," → ",d.linkedPr.base]}),d.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]}),t.jsxs(Sn,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:fe.touched&&(fe.branchError||fe.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(R,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:fe.branchError||fe.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ie,children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:Ge,disabled:!Te||Ie,className:"gap-1.5",children:[Ie&&t.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ie?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(Mc,{open:V,onOpenChange:F,onSelect:Pe})]})}const Pn=(s,e)=>s==="global"?"global":`project:${e??""}`,no=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,ir=(s,e)=>s.reduce((n,r)=>no(r,e)?n+1:n,0),ro=s=>{const e=Ve.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:u,expandLabel:c}=s,{t:l}=et(),f=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let h;e[0]!==f?(h=ie("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",f),e[0]=f,e[1]=h):h=e[1];const g=n?void 0:r;let p;e[2]!==n||e[3]!==r?(p=n?void 0:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),r())},e[2]=n,e[3]=r,e[4]=p):p=e[4];const d=n?void 0:"button",y=n?void 0:0,j=n?void 0:c;let I;e[5]!==a||e[6]!==o?(I=t.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[5]=a,e[6]=o,e[7]=I):I=e[7];let C;e[8]!==n||e[9]!==r||e[10]!==l?(C=n?t.jsx("button",{type:"button",onClick:r,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":l("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:l("rightSidebar.contextNotesTodo.notes.actions.collapse"),children:t.jsx(R,{name:"arrow-up-s",className:"h-3.5 w-3.5"})}):null,e[8]=n,e[9]=r,e[10]=l,e[11]=C):C=e[11];let B;e[12]!==i||e[13]!==C?(B=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:$c,onKeyDown:Wc,children:[C,i]}),e[12]=i,e[13]=C,e[14]=B):B=e[14];let $;e[15]!==B||e[16]!==I?($=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[I,B]}),e[15]=B,e[16]=I,e[17]=$):$=e[17];let S;e[18]!==u?(S=u?t.jsx("div",{className:"min-w-0",children:u}):null,e[18]=u,e[19]=S):S=e[19];let w;return e[20]!==$||e[21]!==S||e[22]!==h||e[23]!==g||e[24]!==p||e[25]!==d||e[26]!==y||e[27]!==j?(w=t.jsxs("li",{className:h,onClick:g,onKeyDown:p,role:d,tabIndex:y,"aria-label":j,children:[$,S]}),e[20]=$,e[21]=S,e[22]=h,e[23]=g,e[24]=p,e[25]=d,e[26]=y,e[27]=j,e[28]=w):w=e[28],w};function $c(s){return s.stopPropagation()}function Wc(s){return s.stopPropagation()}const Uc=s=>{const e=Ve.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:u}=s,{t:c}=et(),[l,f]=m.useState(n.title),[h,g]=m.useState(n.body);let p,d;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(p=()=>{o||(f(n.title),g(n.body))},d=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=p,e[4]=d):(p=e[3],d=e[4]),m.useEffect(p,d);let y;e[5]!==h||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==l?(y=()=>{const D=l.trim(),oe=h.trim();if(!D||!oe){f(n.title),g(n.body);return}D===n.title&&oe===n.body||i({title:D,body:oe})},e[5]=h,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=l,e[10]=y):y=e[10];const j=y,I=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let C;e[11]!==c||e[12]!==I?(C=c(I),e[11]=c,e[12]=I,e[13]=C):C=e[13];const B=C;let $;e[14]!==j||e[15]!==o||e[16]!==a?($=()=>{o&&j(),a()},e[14]=j,e[15]=o,e[16]=a,e[17]=$):$=e[17];const S=n.title;let w;e[18]!==n.flagged||e[19]!==c?(w=n.flagged?t.jsxs("span",{className:"flex items-center gap-1 text-[var(--status-error)]",children:[t.jsx(R,{name:"error-warning",className:"h-3 w-3 flex-shrink-0"}),c("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=c,e[20]=w):w=e[20];let x;e[21]!==w||e[22]!==B?(x=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[B,w]}),e[21]=w,e[22]=B,e[23]=x):x=e[23];let N;e[24]!==r||e[25]!==c?(N=r?t.jsx("span",{className:ie("mb-0.5 mr-1.5 inline-block rounded-full px-1.5 py-px typography-micro font-medium",r==="new"?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--status-warning)]/15 text-[var(--status-warning)]"),children:c(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=c,e[26]=N):N=e[26];let W;e[27]!==c?(W=c("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=c,e[28]=W):W=e[28];let V;e[29]!==c?(V=c("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=c,e[30]=V):V=e[30];let F;e[31]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=F):F=e[31];let _;e[32]!==u||e[33]!==W||e[34]!==V?(_=t.jsx("button",{type:"button",onClick:u,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":W,title:V,children:F}),e[32]=u,e[33]=W,e[34]=V,e[35]=_):_=e[35];let H;e[36]!==h||e[37]!==j||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==c||e[42]!==l?(H=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(bt,{value:l,onChange:D=>f(D.target.value.slice(0,va)),onBlur:j,"aria-label":c("rightSidebar.contextNotesTodo.memory.actions.editTitle"),className:"h-7 typography-ui-label"}),t.jsx(_s,{simple:!0,rows:Math.min(20,Math.max(3,h.split(`
|
|
5
|
+
`).length+1)),value:h,onChange:D=>g(D.target.value.slice(0,ja)),onBlur:j,"aria-label":c("rightSidebar.contextNotesTodo.memory.actions.editBody"),className:"min-h-0 w-full resize-none bg-transparent p-0 typography-meta leading-normal text-muted-foreground focus-visible:outline-none focus-visible:ring-0"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:n.title}),t.jsx("p",{className:"line-clamp-2 whitespace-pre-wrap break-words typography-meta text-muted-foreground",children:n.body})]}),e[36]=h,e[37]=j,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=c,e[42]=l,e[43]=H):H=e[43];let J;return e[44]!==n.title||e[45]!==o||e[46]!==N||e[47]!==_||e[48]!==H||e[49]!==$||e[50]!==x?(J=t.jsx(ro,{expanded:o,onToggleExpanded:$,expandLabel:S,footer:x,header:N,actions:_,children:H}),e[44]=n.title,e[45]=o,e[46]=N,e[47]=_,e[48]=H,e[49]=$,e[50]=x,e[51]=J):J=e[51],J},_c=s=>{const e=Ve.c(57),{projectPath:n,query:r}=s,{t:o}=et(),[a,i]=m.useState("project"),[u,c]=m.useState(null),l=Pt(Vc),f=Pt(zc),h=Pt(Gc),g=Pt(Hc),p=Pt(Kc),d=Pt(qc),y=Fe(Yc),j=a==="global"?l:f,I=a==="global"?h:g;let C;e[0]!==n||e[1]!==a?(C=Pn(a,n),e[0]=n,e[1]=a,e[2]=C):C=e[2];const B=C;let $;e[3]!==B?($=X=>X.agentMemoryViewedAt[B]??0,e[3]=B,e[4]=$):$=e[4];const S=Fe($),w=m.useRef(S),[x,N]=m.useState(S);let W,V;e[5]!==y||e[6]!==B?(W=()=>(w.current=Fe.getState().agentMemoryViewedAt[B]??0,N(w.current),()=>{y(B,Date.now())}),V=[y,B],e[5]=y,e[6]=B,e[7]=W,e[8]=V):(W=e[7],V=e[8]),m.useEffect(W,V);let F;if(e[9]!==j||e[10]!==r){let X;e[12]!==r?(X=ee=>Vs([ee.title,ee.body],r),e[12]=r,e[13]=X):X=e[13],F=j.filter(X),e[9]=j,e[10]=r,e[11]=F}else F=e[11];const _=F;let H;e[14]!==p||e[15]!==a||e[16]!==o?(H=async X=>{if(!await p(a,X)){const ee=Pt.getState().error;ke.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),ee?{description:ee}:void 0)}},e[14]=p,e[15]=a,e[16]=o,e[17]=H):H=e[17];const J=H;let D;e[18]!==d||e[19]!==a||e[20]!==o?(D=async(X,ee)=>{if(!await d(a,X,ee)){const de=Pt.getState().error;ke.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),de?{description:de}:void 0)}},e[18]=d,e[19]=a,e[20]=o,e[21]=D):D=e[21];const oe=D;let U;e[22]!==o?(U=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[22]=o,e[23]=U):U=e[23];let z;e[24]!==f.length||e[25]!==U?(z={id:"project",label:U,count:f.length},e[24]=f.length,e[25]=U,e[26]=z):z=e[26];let P;e[27]!==o?(P=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[27]=o,e[28]=P):P=e[28];let O;e[29]!==l.length||e[30]!==P?(O={id:"global",label:P,count:l.length},e[29]=l.length,e[30]=P,e[31]=O):O=e[31];let M;e[32]!==O||e[33]!==z?(M=[z,O],e[32]=O,e[33]=z,e[34]=M):M=e[34];const G=M;let E;e[35]!==o?(E=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[35]=o,e[36]=E):E=e[36];let K;e[37]!==a||e[38]!==G?(K=G.map(X=>t.jsx(Ne,{type:"button",variant:"chip",size:"xs","aria-pressed":a===X.id,className:"!font-normal",onClick:()=>i(X.id),children:`${X.label} ${X.count}`},X.id)),e[37]=a,e[38]=G,e[39]=K):K=e[39];let q;e[40]!==E||e[41]!==K?(q=t.jsx("div",{role:"group","aria-label":E,className:"flex items-center gap-1",children:K}),e[40]=E,e[41]=K,e[42]=q):q=e[42];let Z;e[43]!==x||e[44]!==u||e[45]!==J||e[46]!==oe||e[47]!==n||e[48]!==r||e[49]!==a||e[50]!==I||e[51]!==o||e[52]!==_?(Z=a==="project"&&!n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.noProject")}):I?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.unavailable")}):_.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r.trim()?o("rightSidebar.contextNotesTodo.memory.empty.noMatches"):o("rightSidebar.contextNotesTodo.memory.empty.nothing")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:_.map(X=>t.jsx(Uc,{entry:X,badge:no(X,x),expanded:u===X.id,onToggleExpanded:()=>c(u===X.id?null:X.id),onSave:ee=>{oe(X.id,ee)},onDelete:()=>{J(X.id)}},X.id))}),e[43]=x,e[44]=u,e[45]=J,e[46]=oe,e[47]=n,e[48]=r,e[49]=a,e[50]=I,e[51]=o,e[52]=_,e[53]=Z):Z=e[53];let Q;return e[54]!==q||e[55]!==Z?(Q=t.jsxs("div",{className:"flex flex-col gap-2",children:[q,Z]}),e[54]=q,e[55]=Z,e[56]=Q):Q=e[56],Q};function Vc(s){return s.global}function zc(s){return s.project}function Gc(s){return s.globalFailed}function Hc(s){return s.projectFailed}function Kc(s){return s.deleteEntry}function qc(s){return s.saveEntry}function Yc(s){return s.markAgentMemoryViewed}const Jc=400,Qc=s=>{const e=Ve.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:u,onDelete:c}=s,{t:l}=et(),[f,h]=m.useState(n.body),g=m.useRef(n.body),p=m.useRef(null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},e[0]=d):d=e[0];const y=d;let j,I;e[1]!==f||e[2]!==n.body?(j=()=>{n.body!==g.current&&f===g.current&&(g.current=n.body,h(n.body))},I=[f,n.body],e[1]=f,e[2]=n.body,e[3]=j,e[4]=I):(j=e[3],I=e[4]),m.useEffect(j,I);let C,B;e[5]!==f||e[6]!==i?(C=()=>{if(f!==g.current)return p.current=window.setTimeout(()=>{p.current=null,f.trim()&&(g.current=f,i(f))},Jc),y},B=[y,f,i],e[5]=f,e[6]=i,e[7]=C,e[8]=B):(C=e[7],B=e[8]),m.useEffect(C,B);let $,S;e[9]===Symbol.for("react.memo_cache_sentinel")?($=()=>y,S=[y],e[9]=$,e[10]=S):($=e[9],S=e[10]),m.useEffect($,S);let w;e[11]!==f||e[12]!==i?(w=()=>{if(y(),f!==g.current){if(!f.trim()){h(g.current);return}g.current=f,i(f)}},e[11]=f,e[12]=i,e[13]=w):w=e[13];const x=w;let N;e[14]!==n.source||e[15]!==l?(N=n.source==="selection"?l("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?l("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=l,e[16]=N):N=e[16];const W=N;let V;e[17]!==l?(V=l("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=l,e[18]=V):V=e[18];let F;e[19]!==W?(F=W?t.jsx("span",{className:"typography-micro text-muted-foreground",children:W}):null,e[19]=W,e[20]=F):F=e[20];const _=r?"text-primary":"text-muted-foreground hover:text-foreground";let H;e[21]!==_?(H=ie("inline-flex h-6 w-6 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",_),e[21]=_,e[22]=H):H=e[22];let J;e[23]!==r||e[24]!==l?(J=l(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=l,e[25]=J):J=e[25];let D;e[26]!==r||e[27]!==l?(D=l(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=l,e[28]=D):D=e[28];const oe=r?"pushpin-2-fill":"pushpin";let U;e[29]!==oe?(U=t.jsx(R,{name:oe,className:"h-3.5 w-3.5"}),e[29]=oe,e[30]=U):U=e[30];let z;e[31]!==u||e[32]!==r||e[33]!==H||e[34]!==J||e[35]!==D||e[36]!==U?(z=t.jsx("button",{type:"button",onClick:u,className:H,"aria-pressed":r,"aria-label":J,title:D,children:U}),e[31]=u,e[32]=r,e[33]=H,e[34]=J,e[35]=D,e[36]=U,e[37]=z):z=e[37];let P;e[38]!==l?(P=l("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=l,e[39]=P):P=e[39];let O;e[40]!==l?(O=l("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=l,e[41]=O):O=e[41];let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[42]=M):M=e[42];let G;e[43]!==c||e[44]!==P||e[45]!==O?(G=t.jsx("button",{type:"button",onClick:c,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":P,title:O,children:M}),e[43]=c,e[44]=P,e[45]=O,e[46]=G):G=e[46];let E;e[47]!==z||e[48]!==G?(E=t.jsxs(t.Fragment,{children:[z,G]}),e[47]=z,e[48]=G,e[49]=E):E=e[49];let K;e[50]!==f||e[51]!==o||e[52]!==x?(K=o?t.jsx(_s,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,f.split(`
|
|
6
|
+
`).length+1)),value:f,onChange:Z=>h(Z.target.value.slice(0,bn)),onBlur:x,className:"min-h-0 w-full resize-none bg-transparent p-0 typography-ui-label leading-normal text-foreground focus-visible:outline-none focus-visible:ring-0"}):t.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words typography-ui-label leading-normal text-foreground",title:f,children:f}),e[50]=f,e[51]=o,e[52]=x,e[53]=K):K=e[53];let q;return e[54]!==o||e[55]!==a||e[56]!==V||e[57]!==F||e[58]!==E||e[59]!==K?(q=t.jsx(ro,{expanded:o,onToggleExpanded:a,expandLabel:V,footer:F,actions:E,children:K}),e[54]=o,e[55]=a,e[56]=V,e[57]=F,e[58]=E,e[59]=K,e[60]=q):q=e[60],q},Xc=s=>{const e=Ve.c(69),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:u}=s,{t:c}=et(),[l,f]=m.useState(""),[h,g]=m.useState(null),p=Fe(Zc),d=Fe(ed),y=Et(td),j=Et(sd),I=Et(nd);let C;if(e[0]!==r||e[1]!==a){let Q;e[3]!==a?(Q=X=>Vs([X.body],a),e[3]=a,e[4]=Q):Q=e[4],C=r.filter(Q),e[0]=r,e[1]=a,e[2]=C}else C=e[2];const B=C;let $;e[5]!==n?($=Q=>{const X=Et.getState().getEntry(n).error;ke.error(Q,X?{description:X}:void 0)},e[5]=n,e[6]=$):$=e[6];const S=$;let w;e[7]!==l||e[8]!==y||e[9]!==n||e[10]!==S||e[11]!==c?(w=async()=>{const Q=l.trim();if(!Q)return;if(!await y(n,{body:Q})){S(c("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}f("")},e[7]=l,e[8]=y,e[9]=n,e[10]=S,e[11]=c,e[12]=w):w=e[12];const x=w;let N;e[13]!==I||e[14]!==n||e[15]!==S||e[16]!==c?(N=async Q=>{await I(n,Q)||S(c("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[13]=I,e[14]=n,e[15]=S,e[16]=c,e[17]=N):N=e[17];const W=N;let V;e[18]!==u||e[19]!==S||e[20]!==c?(V=async(Q,X)=>{await u(Q,X)||S(c("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[18]=u,e[19]=S,e[20]=c,e[21]=V):V=e[21];const F=V;let _;e[22]!==n||e[23]!==S||e[24]!==j||e[25]!==c?(_=(Q,X)=>{j(n,Q,X).then(ee=>{ee||S(c("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[22]=n,e[23]=S,e[24]=j,e[25]=c,e[26]=_):_=e[26];const H=_;let J;e[27]===Symbol.for("react.memo_cache_sentinel")?(J=Q=>f(Q.target.value.slice(0,bn)),e[27]=J):J=e[27];let D;e[28]!==c?(D=c("rightSidebar.contextNotesTodo.notes.placeholder"),e[28]=c,e[29]=D):D=e[29];let oe;e[30]!==l.length?(oe=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[l.length,"/",bn]}),e[30]=l.length,e[31]=oe):oe=e[31];let U;e[32]!==x?(U=()=>{x()},e[32]=x,e[33]=U):U=e[33];let z;e[34]!==l||e[35]!==o?(z=o||l.trim().length===0,e[34]=l,e[35]=o,e[36]=z):z=e[36];let P;e[37]!==c?(P=c("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=c,e[38]=P):P=e[38];let O;e[39]!==c?(O=c("rightSidebar.contextNotesTodo.notes.addAria"),e[39]=c,e[40]=O):O=e[40];let M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(R,{name:"add",className:"h-4 w-4"}),e[41]=M):M=e[41];let G;e[42]!==U||e[43]!==z||e[44]!==P||e[45]!==O?(G=t.jsx("button",{type:"button",onClick:U,disabled:z,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-40","aria-label":P,title:O,children:M}),e[42]=U,e[43]=z,e[44]=P,e[45]=O,e[46]=G):G=e[46];let E;e[47]!==G||e[48]!==oe?(E=t.jsxs(t.Fragment,{children:[oe,G]}),e[47]=G,e[48]=oe,e[49]=E):E=e[49];let K;e[50]!==l||e[51]!==o||e[52]!==p||e[53]!==d||e[54]!==E||e[55]!==D?(K=t.jsx(_s,{value:l,onChange:J,placeholder:D,resizedHeight:p,onResizeHeightChange:d,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:E}),e[50]=l,e[51]=o,e[52]=p,e[53]=d,e[54]=E,e[55]=D,e[56]=K):K=e[56];let q;e[57]!==h||e[58]!==W||e[59]!==H||e[60]!==F||e[61]!==i||e[62]!==a||e[63]!==c||e[64]!==B?(q=t.jsx("div",{children:B.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?c("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):c("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:B.map(Q=>t.jsx(Qc,{note:Q,pinned:i.has(Q.id),expanded:h===Q.id,onToggleExpanded:()=>g(X=>X===Q.id?null:Q.id),onSaveBody:X=>H(Q.id,X),onTogglePinned:()=>{F(Q.id,!i.has(Q.id))},onDelete:()=>{W(Q.id)}},Q.id))})}),e[57]=h,e[58]=W,e[59]=H,e[60]=F,e[61]=i,e[62]=a,e[63]=c,e[64]=B,e[65]=q):q=e[65];let Z;return e[66]!==K||e[67]!==q?(Z=t.jsxs("div",{className:"space-y-2",children:[K,q]}),e[66]=K,e[67]=q,e[68]=Z):Z=e[68],Z};function Zc(s){return s.notesPanelHeight}function ed(s){return s.setNotesPanelHeight}function td(s){return s.createNote}function sd(s){return s.saveNoteBody}function nd(s){return s.deleteNote}const rd=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=et(),u=m.useRef(null),[c,l]=m.useState(!1),[f,h]=m.useState(null),g=Et(x=>x.createPlan),p=Et(x=>x.deletePlan),d=Cs(x=>x.currentDirectory),y=Fe(x=>x.openContextPanelTab),j=m.useCallback(async x=>{if(!f){h(x);try{await p(s,x)||ke.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{h(null)}}},[f,s,p,i]),I=m.useCallback(async(x,N)=>{if(!x.trim()){ke.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const W=ka(x,N||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await g(s,{title:W.title,body:W.body})){ke.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}ke.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[g,s,i]),C=m.useCallback(async()=>{if(c)return;const x=await ii({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(x.success&&x.path){l(!0);try{const N=new URLSearchParams({path:x.path,allowOutsideWorkspace:"true"});x.outsideFileGrant&&N.set("outsideFileGrant",x.outsideFileGrant);const W=await Bt(`/api/fs/read?${N.toString()}`,{cache:"no-store"});if(!W.ok){ke.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const V=await W.text(),F=x.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await I(V,F)}catch(N){const W=N instanceof Error?N.message:void 0;ke.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),W?{description:W}:void 0)}finally{l(!1)}return}x.error==="Native file picker not available"&&u.current?.click()},[I,c,s.path,i]),B=m.useCallback(async x=>{if(x){l(!0);try{const N=await x.text(),W=x.name.replace(/\.(md|markdown|txt)$/i,"").trim();await I(N,W)}catch(N){const W=N instanceof Error?N.message:void 0;ke.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),W?{description:W}:void 0)}finally{l(!1)}}},[I,i]),$=m.useCallback(async(x,N)=>{if(!await a(x,N)){const V=Et.getState().getEntry(s).error;ke.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),V?{description:V}:void 0)}},[a,s,i]),S=m.useMemo(()=>e.filter(x=>Vs([x.title],n)),[e,n]),w=m.useCallback(x=>{if(r){r({id:x.id,title:x.title});return}const N=d?.trim()||s.path.trim();N&&y(N,{mode:"plan",projectPlanId:x.id,dedupeKey:`plan:${x.id}`,label:x.title})},[d,r,y,s.path]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx("input",{ref:u,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:x=>{const N=x.target.files?.[0]??null;B(N),x.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:C,disabled:c,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":i("rightSidebar.contextNotesTodo.plans.importFromFile"),title:i("rightSidebar.contextNotesTodo.plans.importFromFile"),children:t.jsx(R,{name:"add",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:S.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:n.trim()?i("rightSidebar.contextNotesTodo.search.noResults",{query:n.trim()}):i("rightSidebar.contextNotesTodo.plans.empty")}):t.jsx("ul",{className:"divide-y divide-border/50",children:S.map(x=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w(x),className:"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-md px-1.5 py-1 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:x.title}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(x.createdAt).toLocaleDateString(pr())})]}),t.jsx("button",{type:"button",onClick:()=>{$(x.id,!o.has(x.id))},className:ie("inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o.has(x.id)?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-pressed":o.has(x.id),"aria-label":o.has(x.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),title:o.has(x.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),children:t.jsx(R,{name:"pushpin",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{j(x.id)},disabled:f===x.id,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:i("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":i("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:x.title}),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},x.id))})})]})},od=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,ad=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],lr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},id=s=>{const e=Ve.c(20),{id:n,children:r}=s;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:i,setNodeRef:u,setActivatorNodeRef:c,transform:l,transition:f,isDragging:h}=Ur(o);let g;e[2]!==l?(g=Vr.Transform.toString(l),e[2]=l,e[3]=g):g=e[3];let p;e[4]!==g||e[5]!==f?(p={transform:g,transition:f},e[4]=g,e[5]=f,e[6]=p):p=e[6];const d=h&&"opacity-60";let y;e[7]!==d?(y=ie(d),e[7]=d,e[8]=y):y=e[8];let j;e[9]!==a||e[10]!==r||e[11]!==h||e[12]!==i||e[13]!==c?(j=r({attributes:a,listeners:i,setActivatorNodeRef:c,isDragging:h}),e[9]=a,e[10]=r,e[11]=h,e[12]=i,e[13]=c,e[14]=j):j=e[14];let I;return e[15]!==u||e[16]!==p||e[17]!==y||e[18]!==j?(I=t.jsx("li",{ref:u,style:p,className:y,children:j}),e[15]=u,e[16]=p,e[17]=y,e[18]=j,e[19]=I):I=e[19],I},ld=s=>{const e=Ve.c(82),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:u,onSendToCurrentSession:c,onSendToNewSession:l,onSendToNewWorktreeSession:f}=s,{t:h}=et(),[g,p]=m.useState(""),[d,y]=m.useState(cd);let j;e[0]!==g||e[1]!==u||e[2]!==n?(j=()=>{const v=g.trim();v&&(u(lr(n,{id:od(),text:v.slice(0,Ps),completed:!1,createdAt:Date.now()})),p(""))},e[0]=g,e[1]=u,e[2]=n,e[3]=j):j=e[3];const I=j;let C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C=v=>{y(L=>{const te=new Set(L);return te.has(v)?te.delete(v):te.add(v),te})},e[4]=C):C=e[4];const B=C;let $;e[5]!==u||e[6]!==n?($=(v,L)=>{const te=n.find(be=>be.id===v);if(!te||te.completed===L)return;const ue=n.filter(be=>be.id!==v),fe={...te,completed:L};u(L?[...ue,fe]:lr(ue,fe))},e[5]=u,e[6]=n,e[7]=$):$=e[7];const S=$;let w;e[8]!==u||e[9]!==n?(w=v=>{u(n.filter(L=>L.id!==v))},e[8]=u,e[9]=n,e[10]=w):w=e[10];const x=w;let N;e[11]!==u||e[12]!==n?(N=()=>{const v=n.filter(dd);v.length!==n.length&&u(v)},e[11]=u,e[12]=n,e[13]=N):N=e[13];const W=N;let V;e[14]!==u||e[15]!==n?(V=v=>{const{active:L,over:te}=v;if(!te||L.id===te.id)return;const ue=n.findIndex(be=>be.id===L.id),fe=n.findIndex(be=>be.id===te.id);ue===-1||fe===-1||u(ad(Ci(n,ue,fe)))},e[14]=u,e[15]=n,e[16]=V):V=e[16];const F=V;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_={activationConstraint:{distance:8}},e[17]=_):_=e[17];const H=Lr(Fr(Or,_));let J;e[18]!==g?(J=g.slice(0,Ps),e[18]=g,e[19]=J):J=e[19];const D=J;let oe;e[20]!==n?(oe=n.reduce(ud,0),e[20]=n,e[21]=oe):oe=e[21];const U=oe;let z;if(e[22]!==r||e[23]!==n){let v;e[25]!==r?(v=L=>Vs([L.text],r),e[25]=r,e[26]=v):v=e[26],z=n.filter(v),e[22]=r,e[23]=n,e[24]=z}else z=e[24];const P=z,O=o||U===0;let M;e[27]!==h?(M=h("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[27]=h,e[28]=M):M=e[28];let G;e[29]!==W||e[30]!==O||e[31]!==M?(G=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:W,disabled:O,className:"typography-meta rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",children:M})}),e[29]=W,e[30]=O,e[31]=M,e[32]=G):G=e[32];let E;e[33]!==D.length?(E=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[D.length,"/",Ps]}),e[33]=D.length,e[34]=E):E=e[34];let K;e[35]!==G||e[36]!==E?(K=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[G,E]}),e[35]=G,e[36]=E,e[37]=K):K=e[37];let q;e[38]===Symbol.for("react.memo_cache_sentinel")?(q=v=>p(v.target.value.slice(0,Ps)),e[38]=q):q=e[38];let Z;e[39]!==I?(Z=v=>{v.key==="Enter"&&(v.preventDefault(),I())},e[39]=I,e[40]=Z):Z=e[40];let Q;e[41]!==h?(Q=h("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[41]=h,e[42]=Q):Q=e[42];let X;e[43]!==o||e[44]!==Z||e[45]!==Q||e[46]!==D?(X=t.jsx(bt,{value:D,onChange:q,onKeyDown:Z,placeholder:Q,disabled:o,className:"h-8"}),e[43]=o,e[44]=Z,e[45]=Q,e[46]=D,e[47]=X):X=e[47];let ee;e[48]!==o||e[49]!==D?(ee=o||D.trim().length===0,e[48]=o,e[49]=D,e[50]=ee):ee=e[50];let de;e[51]!==h?(de=h("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=h,e[52]=de):de=e[52];let se;e[53]!==h?(se=h("rightSidebar.contextNotesTodo.todo.addAria"),e[53]=h,e[54]=se):se=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx(R,{name:"add",className:"h-4 w-4"}),e[55]=he):he=e[55];let le;e[56]!==I||e[57]!==ee||e[58]!==de||e[59]!==se?(le=t.jsx("button",{type:"button",onClick:I,disabled:ee,className:"inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":de,title:se,children:he}),e[56]=I,e[57]=ee,e[58]=de,e[59]=se,e[60]=le):le=e[60];let Y;e[61]!==X||e[62]!==le?(Y=t.jsxs("div",{className:"flex items-center gap-1.5",children:[X,le]}),e[61]=X,e[62]=le,e[63]=Y):Y=e[63];let ne;e[64]!==a||e[65]!==d||e[66]!==x||e[67]!==F||e[68]!==S||e[69]!==c||e[70]!==l||e[71]!==f||e[72]!==r||e[73]!==i||e[74]!==h||e[75]!==H||e[76]!==P?(ne=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:P.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:r.trim()?h("rightSidebar.contextNotesTodo.search.noResults",{query:r.trim()}):h("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx($r,{sensors:H,collisionDetection:Wr,onDragEnd:F,children:t.jsx(_r,{items:P.map(fd),strategy:Ni,children:t.jsx("ul",{className:"divide-y divide-border/50",children:P.map(v=>{const L=d.has(v.id);return t.jsx(id,{id:v.id,children:te=>t.jsxs("div",{className:ie("flex gap-1.5 px-2.5 py-1.5",L?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:te.setActivatorNodeRef,...te.attributes,...te.listeners,onClick:md,className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":h("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:v.text}),title:h("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:v.text}),children:t.jsx(R,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(Ns,{checked:v.completed,onChange:ue=>S(v.id,ue),ariaLabel:h("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:v.text})})}),t.jsx("button",{type:"button",onClick:()=>B(v.id),className:ie("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",L?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",v.completed&&"text-muted-foreground line-through"),title:L?void 0:v.text,"aria-label":L?h("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:v.text}):h("rightSidebar.contextNotesTodo.todo.actions.expand",{text:v.text}),children:v.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>x(v.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":h("rightSidebar.contextNotesTodo.todo.actions.delete",{text:v.text}),title:h("rightSidebar.contextNotesTodo.todo.actions.delete",{text:v.text}),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs($t,{children:[t.jsx(Wt,{asChild:!0,children:t.jsx("button",{type:"button",disabled:i===v.id,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":h("rightSidebar.contextNotesTodo.todo.actions.send",{text:v.text}),title:h("rightSidebar.contextNotesTodo.todo.actions.send",{text:v.text}),children:t.jsx(R,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(Ut,{align:"end",className:"w-56",children:[t.jsx(Rt,{onClick:()=>c(v.text),children:h("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(Rt,{onClick:()=>l(v.id,v.text),children:h("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(Rt,{onClick:()=>f(v.id,v.text),disabled:!a,children:h("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},v.id)})})})})}),e[64]=a,e[65]=d,e[66]=x,e[67]=F,e[68]=S,e[69]=c,e[70]=l,e[71]=f,e[72]=r,e[73]=i,e[74]=h,e[75]=H,e[76]=P,e[77]=ne):ne=e[77];let ce;return e[78]!==K||e[79]!==Y||e[80]!==ne?(ce=t.jsxs("div",{className:"space-y-2",children:[K,Y,ne]}),e[78]=K,e[79]=Y,e[80]=ne,e[81]=ce):ce=e[81],ce};function cd(){return new Set}function dd(s){return!s.completed}function ud(s,e){return s+(e.completed?1:0)}function fd(s){return s.id}function md(s){s.preventDefault(),s.stopPropagation()}const hd=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=et(),[a,i]=m.useState(null),[u,c]=m.useState(!1),[l,f]=m.useState(null),h=ot(N=>N.currentSessionId),g=ot(N=>N.createSession),p=ot(N=>N.initializeNewOpenChamberSession),d=ot(N=>N.sendMessage),y=ot(N=>N.setCurrentSession),j=Sa(N=>N.setPendingInputText),I=Fe(N=>N.setSessionSwitcherOpen),C=m.useCallback(()=>{I(!1)},[I]),B=m.useCallback(N=>{if(!h){ke.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}C();const W=`\`\`\`md
|
|
7
|
+
${N}
|
|
8
|
+
\`\`\``;j(W,"append"),ke.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[h,r,C,j,o]),$=m.useCallback((N,W)=>{!e||l||i({kind:"session",todoId:N,todoText:W})},[e,l]),S=m.useCallback((N,W)=>{if(!(!e||l)){if(!n){ke.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:N,todoText:W})}},[n,e,l,o]),w=m.useCallback(async N=>{if(!e||!a)return;const W=await ls("plan.todo.visible",{todo_text:a.todoText}),F=[{synthetic:!0,text:await ls("plan.todo.instructions",{todo_text:a.todoText})}];c(!0),f(a.todoId);try{C();let _=null,H=e.path;if(a.kind==="worktree"){if(!n){ke.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const D=await Na(e.path,Ca());if(!D?.id)return;_=D.id,H=D.path}else{const D=await g(void 0,e.path,null);if(!D?.id){ke.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}_=D.id,H=D.directory??e.path,p(D.id,vt.getState().agents??[])}if(!_)return;const J=Ir.getState();J.saveSessionModelSelection(_,N.providerID,N.modelID),N.agent.trim()&&(J.saveSessionAgentSelection(_,N.agent),J.saveAgentModelForSession(_,N.agent,N.providerID,N.modelID),J.saveAgentModelVariantForSession(_,N.agent,N.providerID,N.modelID,N.variant||void 0)),y(_,H),await d(W,N.providerID,N.modelID,N.agent.trim()||void 0,void 0,void 0,F,N.variant||void 0),ke.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch(_){const H=_ instanceof Error?_.message:void 0;ke.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),H?{description:H}:void 0)}finally{c(!1),f(null)}},[n,g,p,r,a,e,C,d,y,o]),x=m.useCallback(()=>{u||i(null)},[u]);return{pendingSendTarget:a,isSubmitting:u,sendingTodoId:l,sendToCurrentSession:B,sendToNewSession:$,sendToNewWorktreeSession:S,confirmSend:w,closeDialog:x}},pd=m.lazy(()=>Gt(()=>import("./PlanView-Dgg-WTEc.js"),__vite__mapDeps([115,2,3,4,5,6,7,8,9,116,57,58,59,60,61,62,79,55,56,63,117,118,119,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,120,121,113,114,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(s=>({default:s.PlanView}))),cr=["notes","todos","plans","memory"],gd=120,xd=320,tn=s=>Math.min(xd,Math.max(gd,Math.round(s))),bd=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],gs=(s,e)=>s.toLowerCase().includes(e),yd=s=>{const e=Ve.c(239),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:u}=s,c=o===void 0?!1:o,{t:l}=et();let f;e[0]!==n?(f=Ia(n),e[0]=n,e[1]=f):f=e[1];const h=f;let g;e[2]!==h?(g=we=>(h?we.entries[h]:void 0)??Ta,e[2]=h,e[3]=g):g=e[3];const p=Et(g),d=Et(wd),y=Et(vd),j=ot(jd),I=ot(kd),C=ot(Sd),B=ot(Nd);let $;e[4]===Symbol.for("react.memo_cache_sentinel")?($={notes:[],plans:[]},e[4]=$):$=e[4];const[S,w]=m.useState($);let x,N;e[5]!==I||e[6]!==j||e[7]!==C.open||e[8]!==C.projectContextPins?(x=()=>{if(C.open){w(C.projectContextPins??{notes:[],plans:[]});return}let we=!1;return Pa(I,j).then(Ye=>{we||w({notes:Ye.notes.map(Cd),plans:Ye.plans.map(Id)})}),()=>{we=!0}},N=[I,j,C.open,C.projectContextPins],e[5]=I,e[6]=j,e[7]=C.open,e[8]=C.projectContextPins,e[9]=x,e[10]=N):(x=e[9],N=e[10]),m.useEffect(x,N);let W;e[11]!==I||e[12]!==j||e[13]!==C.open||e[14]!==B?(W=async(we,Ye,wt)=>{if(C.open)return B(we,Ye,wt),!0;if(!j||!I)return!1;const Mt=await Da(I,j,we,Ye,wt);return Mt?(w(Mt),!0):!1},e[11]=I,e[12]=j,e[13]=C.open,e[14]=B,e[15]=W):W=e[15];const V=W;let F;e[16]!==S.notes?(F=new Set(S.notes),e[16]=S.notes,e[17]=F):F=e[17];const _=F;let H;e[18]!==S.plans?(H=new Set(S.plans),e[18]=S.plans,e[19]=H):H=e[19];const J=H,D=Fe(Td),oe=Pt(Pd),U=D&&!oe,z=Pt(Dd),P=Pt(Ed),O=Fe(Rd),M=Fe(Ad),G=Fe(Bd);let E;e[20]!==M?(E=cr.includes(M)?M:"notes",e[20]=M,e[21]=E):E=e[21];const K=E,q=K==="memory"&&!U?"notes":K,[Z,Q]=m.useState(""),[X,ee]=m.useState(null);let de;e[22]!==Z?(de=Z.trim().toLowerCase(),e[22]=Z,e[23]=de):de=e[23];const se=de;let he;e[24]!==p.todos?(he=bd(p.todos),e[24]=p.todos,e[25]=he):he=e[25];const le=he,Y=p.loading&&!p.loaded;let ne;e[26]!==z||e[27]!==P?(ne=[...z,...P],e[26]=z,e[27]=P,e[28]=ne):ne=e[28];const ce=ne;let v;e:{if(!se){let ut;e[29]!==p.notes.length||e[30]!==p.plans.length||e[31]!==ce.length||e[32]!==le.length?(ut={notes:p.notes.length,todos:le.length,plans:p.plans.length,memory:ce.length},e[29]=p.notes.length,e[30]=p.plans.length,e[31]=ce.length,e[32]=le.length,e[33]=ut):ut=e[33],v=ut;break e}let we;if(e[34]!==p.notes||e[35]!==se){let ut;e[37]!==se?(ut=hs=>gs(hs.body,se),e[37]=se,e[38]=ut):ut=e[38],we=p.notes.filter(ut),e[34]=p.notes,e[35]=se,e[36]=we}else we=e[36];const Ye=we.length;let wt;if(e[39]!==le||e[40]!==se){let ut;e[42]!==se?(ut=hs=>gs(hs.text,se),e[42]=se,e[43]=ut):ut=e[43],wt=le.filter(ut),e[39]=le,e[40]=se,e[41]=wt}else wt=e[41];const Mt=wt.length;let rs;if(e[44]!==p.plans||e[45]!==se){let ut;e[47]!==se?(ut=hs=>gs(hs.title,se),e[47]=se,e[48]=ut):ut=e[48],rs=p.plans.filter(ut),e[44]=p.plans,e[45]=se,e[46]=rs}else rs=e[46];const uo=rs.length;let os;e[49]!==ce||e[50]!==se?(os=ce.filter(ut=>gs(ut.title,se)||gs(ut.body,se)),e[49]=ce,e[50]=se,e[51]=os):os=e[51];let Ts;e[52]!==we.length||e[53]!==wt.length||e[54]!==rs.length||e[55]!==os.length?(Ts={notes:Ye,todos:Mt,plans:uo,memory:os.length},e[52]=we.length,e[53]=wt.length,e[54]=rs.length,e[55]=os.length,e[56]=Ts):Ts=e[56],v=Ts}const L=v,te=Fe(Md);let ue;e[57]!==n?.path?(ue=we=>we.agentMemoryViewedAt[Pn("project",n?.path??null)]??0,e[57]=n?.path,e[58]=ue):ue=e[58];const fe=Fe(ue),be=ir(z,te)+ir(P,fe),Ie=Fe(Ld),Ee=Fe(Fd),[ze,Qe]=m.useState(!1),[Ue,qe]=m.useState(null),Ae=Ue??Ie;let it;e[59]!==Ae?(it=tn(Ae),e[59]=Ae,e[60]=it):it=e[60];const Re=it;let $e;e[61]!==Re?($e=we=>{we.currentTarget.setPointerCapture(we.pointerId),Qe(!0),qe(Re)},e[61]=Re,e[62]=$e):$e=e[62];const We=$e;let Ge;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ge=we=>{if(!we.currentTarget.hasPointerCapture(we.pointerId))return;const Ye=we.currentTarget.closest("nav")?.getBoundingClientRect().right??0;qe(tn(Ye-we.clientX))},e[63]=Ge):Ge=e[63];const at=Ge;let Pe;e[64]!==Ee?(Pe=we=>{we.currentTarget.hasPointerCapture(we.pointerId)&&we.currentTarget.releasePointerCapture(we.pointerId),Qe(!1),qe(Ye=>(Ye!==null&&Ee(tn(Ye)),null))},e[64]=Ee,e[65]=Pe):Pe=e[65];const Je=Pe;let _e;e[66]!==c||e[67]!==a||e[68]!==n?(_e={projectRef:n,canCreateWorktree:c,onActionComplete:a},e[66]=c,e[67]=a,e[68]=n,e[69]=_e):_e=e[69];const Te=hd(_e);let Xe,nt;e[70]!==d||e[71]!==n?(Xe=()=>{n&&d(n)},nt=[d,n],e[70]=d,e[71]=n,e[72]=Xe,e[73]=nt):(Xe=e[72],nt=e[73]),m.useEffect(Xe,nt);const b=m.useRef(null);let A,ge;e[74]!==p.error||e[75]!==p.loaded||e[76]!==l?(A=()=>{if(!p.error){b.current=null;return}b.current!==p.error&&(b.current=p.error,p.loaded||ke.error(l("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},ge=[p.error,p.loaded,l],e[74]=p.error,e[75]=p.loaded,e[76]=l,e[77]=A,e[78]=ge):(A=e[77],ge=e[78]),m.useEffect(A,ge);let me;e[79]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{ee(null)},e[79]=me):me=e[79];let Se;e[80]!==h?(Se=[h],e[80]=h,e[81]=Se):Se=e[81],m.useEffect(me,Se);let Me,Be;e[82]!==q?(Me=()=>{q!=="plans"&&ee(null)},Be=[q],e[82]=q,e[83]=Me,e[84]=Be):(Me=e[83],Be=e[84]),m.useEffect(Me,Be);let He;e[85]===Symbol.for("react.memo_cache_sentinel")?(He=()=>{Q("")},e[85]=He):He=e[85];let k;e[86]!==h?(k=[h],e[86]=h,e[87]=k):k=e[87],m.useEffect(He,k);let ve,Ce;e[88]!==q||e[89]!==L||e[90]!==G||e[91]!==se?(ve=()=>{if(!se||L[q]>0)return;const we=cr.find(Ye=>L[Ye]>0);we&&G(we)},Ce=[q,L,G,se],e[88]=q,e[89]=L,e[90]=G,e[91]=se,e[92]=ve,e[93]=Ce):(ve=e[92],Ce=e[93]),m.useEffect(ve,Ce);let De;e[94]!==n||e[95]!==y||e[96]!==l?(De=we=>{n&&y(n,we).then(Ye=>{Ye||ke.error(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[94]=n,e[95]=y,e[96]=l,e[97]=De):De=e[97];const tt=De;let ft;e[98]!==l?(ft=l("rightSidebar.contextNotesTodo.tabs.notes"),e[98]=l,e[99]=ft):ft=e[99];const rt=String(L.notes);let dt;e[100]!==ft||e[101]!==rt?(dt={id:"notes",icon:"sticky-note",label:ft,count:rt},e[100]=ft,e[101]=rt,e[102]=dt):dt=e[102];let lt;e[103]!==l?(lt=l("rightSidebar.contextNotesTodo.tabs.todos"),e[103]=l,e[104]=lt):lt=e[104];const st=String(L.todos);let T;e[105]!==lt||e[106]!==st?(T={id:"todos",icon:"checkbox-circle",label:lt,count:st},e[105]=lt,e[106]=st,e[107]=T):T=e[107];let re;e[108]!==l?(re=l("rightSidebar.contextNotesTodo.tabs.plans"),e[108]=l,e[109]=re):re=e[109];const xe=String(L.plans);let Le;e[110]!==re||e[111]!==xe?(Le={id:"plans",icon:"file-text",label:re,count:xe},e[110]=re,e[111]=xe,e[112]=Le):Le=e[112];let ye;e[113]!==L.memory||e[114]!==be||e[115]!==U||e[116]!==l?(ye=U?[{id:"memory",icon:"brain-4",label:l("rightSidebar.contextNotesTodo.tabs.memory"),count:be>0?`${be}/${L.memory}`:String(L.memory)}]:[],e[113]=L.memory,e[114]=be,e[115]=U,e[116]=l,e[117]=ye):ye=e[117];let Oe;e[118]!==dt||e[119]!==T||e[120]!==Le||e[121]!==ye?(Oe=[dt,T,Le,...ye],e[118]=dt,e[119]=T,e[120]=Le,e[121]=ye,e[122]=Oe):Oe=e[122];const je=Oe;if(!n){let we;e[123]!==u?(we=ie("w-full min-w-0 p-3",u),e[123]=u,e[124]=we):we=e[124];let Ye;e[125]!==l?(Ye=l("rightSidebar.contextNotesTodo.empty.selectProject"),e[125]=l,e[126]=Ye):Ye=e[126];let wt;e[127]!==Ye?(wt=t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ye}),e[127]=Ye,e[128]=wt):wt=e[128];let Mt;return e[129]!==we||e[130]!==wt?(Mt=t.jsx("div",{className:we,children:wt}),e[129]=we,e[130]=wt,e[131]=Mt):Mt=e[131],Mt}let pe;e[132]!==r||e[133]!==n.path?(pe=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[132]=r,e[133]=n.path,e[134]=pe):pe=e[134];const Ke=pe;let ct;e[135]!==u?(ct=ie("flex h-full min-h-0 w-full min-w-0 flex-col",u),e[135]=u,e[136]=ct):ct=e[136];let mt;e[137]!==X||e[138]!==l?(mt=X?t.jsx("button",{type:"button",onClick:()=>ee(null),className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":l("rightSidebar.contextNotesTodo.plans.actions.back"),title:l("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(R,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[137]=X,e[138]=l,e[139]=mt):mt=e[139];let jt;e[140]!==n.path||e[141]!==Ke?(jt=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:Ke}),e[140]=n.path,e[141]=Ke,e[142]=jt):jt=e[142];let yt;e[143]===Symbol.for("react.memo_cache_sentinel")?(yt=t.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e[143]=yt):yt=e[143];let kt;e[144]===Symbol.for("react.memo_cache_sentinel")?(kt=we=>Q(we.target.value),e[144]=kt):kt=e[144];let pt;e[145]!==l?(pt=l("rightSidebar.contextNotesTodo.search.placeholder"),e[145]=l,e[146]=pt):pt=e[146];let St;e[147]!==Z||e[148]!==pt?(St=t.jsx(bt,{value:Z,onChange:kt,placeholder:pt,className:"h-8 pl-7 pr-7"}),e[147]=Z,e[148]=pt,e[149]=St):St=e[149];let It;e[150]!==Z||e[151]!==l?(It=Z?t.jsx("button",{type:"button",onClick:()=>Q(""),className:"absolute right-1.5 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":l("rightSidebar.contextNotesTodo.search.clear"),title:l("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null,e[150]=Z,e[151]=l,e[152]=It):It=e[152];let Nt;e[153]!==St||e[154]!==It?(Nt=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[yt,St,It]}),e[153]=St,e[154]=It,e[155]=Nt):Nt=e[155];let ht;e[156]!==mt||e[157]!==jt||e[158]!==Nt?(ht=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[mt,jt,Nt]}),e[156]=mt,e[157]=jt,e[158]=Nt,e[159]=ht):ht=e[159];let Ht;e[160]!==q||e[161]!==O||e[162]!==je||e[163]!==G||e[164]!==l?(Ht=O?t.jsx("nav",{className:"flex flex-shrink-0 items-center gap-1.5 overflow-x-auto px-3 pb-2","aria-label":l("rightSidebar.contextNotesTodo.sections.label"),children:je.map(we=>{const Ye=q===we.id;return t.jsxs("button",{type:"button",onClick:()=>G(we.id),"aria-current":Ye?"page":void 0,className:ie("flex flex-shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ye?"border-transparent bg-interactive-active text-foreground":"border-[var(--interactive-border)] text-muted-foreground"),children:[t.jsx(R,{name:we.icon,className:"h-4 w-4 flex-shrink-0"}),Ye?t.jsx("span",{className:"whitespace-nowrap typography-meta",children:we.label}):null,t.jsx("span",{className:"typography-micro text-muted-foreground",children:we.count})]},we.id)})}):null,e[160]=q,e[161]=O,e[162]=je,e[163]=G,e[164]=l,e[165]=Ht):Ht=e[165];const Gs=X?"overflow-hidden":"overflow-y-auto";let Kt;e[166]!==Gs?(Kt=ie("min-h-0 min-w-0 flex-1 p-3",Gs),e[166]=Gs,e[167]=Kt):Kt=e[167];let qt;e[168]!==q||e[169]!==p.notes||e[170]!==Y||e[171]!==_||e[172]!==n||e[173]!==Z||e[174]!==V?(qt=q==="notes"?t.jsx(Xc,{projectRef:n,notes:p.notes,disabled:Y,query:Z,pinnedNoteIds:_,onTogglePinned:(we,Ye)=>V("note",we,Ye)}):null,e[168]=q,e[169]=p.notes,e[170]=Y,e[171]=_,e[172]=n,e[173]=Z,e[174]=V,e[175]=qt):qt=e[175];let Yt;e[176]!==q||e[177]!==c||e[178]!==tt||e[179]!==Y||e[180]!==Z||e[181]!==Te.sendToCurrentSession||e[182]!==Te.sendToNewSession||e[183]!==Te.sendToNewWorktreeSession||e[184]!==Te.sendingTodoId||e[185]!==le?(Yt=q==="todos"?t.jsx(ld,{todos:le,query:Z,disabled:Y,canCreateWorktree:c,sendingTodoId:Te.sendingTodoId,onPersistTodos:tt,onSendToCurrentSession:Te.sendToCurrentSession,onSendToNewSession:Te.sendToNewSession,onSendToNewWorktreeSession:Te.sendToNewWorktreeSession}):null,e[176]=q,e[177]=c,e[178]=tt,e[179]=Y,e[180]=Z,e[181]=Te.sendToCurrentSession,e[182]=Te.sendToNewSession,e[183]=Te.sendToNewWorktreeSession,e[184]=Te.sendingTodoId,e[185]=le,e[186]=Yt):Yt=e[186];let Jt;e[187]!==q||e[188]!==U||e[189]!==n.path||e[190]!==Z?(Jt=q==="memory"&&U?t.jsx(_c,{projectPath:n.path,query:Z}):null,e[187]=q,e[188]=U,e[189]=n.path,e[190]=Z,e[191]=Jt):Jt=e[191];let Qt;e[192]!==q||e[193]!==p.plans||e[194]!==i||e[195]!==X||e[196]!==J||e[197]!==n||e[198]!==Z||e[199]!==V?(Qt=q==="plans"&&!X?t.jsx(rd,{projectRef:n,plans:p.plans,query:Z,pinnedPlanIds:J,onTogglePinned:(we,Ye)=>V("plan",we,Ye),onOpenPlan:i??ee}):null,e[192]=q,e[193]=p.plans,e[194]=i,e[195]=X,e[196]=J,e[197]=n,e[198]=Z,e[199]=V,e[200]=Qt):Qt=e[200];let Xt;e[201]!==q||e[202]!==X?(Xt=q==="plans"&&X?t.jsx(m.Suspense,{fallback:null,children:t.jsx(pd,{projectPlanId:X.id,onNavigatedToChat:()=>ee(null)})}):null,e[201]=q,e[202]=X,e[203]=Xt):Xt=e[203];let Zt;e[204]!==Kt||e[205]!==qt||e[206]!==Yt||e[207]!==Jt||e[208]!==Qt||e[209]!==Xt?(Zt=t.jsxs("div",{className:Kt,children:[qt,Yt,Jt,Qt,Xt]}),e[204]=Kt,e[205]=qt,e[206]=Yt,e[207]=Jt,e[208]=Qt,e[209]=Xt,e[210]=Zt):Zt=e[210];let es;e[211]!==q||e[212]!==Je||e[213]!==We||e[214]!==O||e[215]!==ze||e[216]!==je||e[217]!==G||e[218]!==Re||e[219]!==l?(es=O?null:t.jsxs("nav",{className:"relative flex flex-shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-[var(--interactive-border)] p-2",style:{width:`${Re}px`},"aria-label":l("rightSidebar.contextNotesTodo.sections.label"),children:[t.jsx("div",{className:ie("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",ze&&"bg-[var(--interactive-border)]"),onPointerDown:We,onPointerMove:at,onPointerUp:Je,onPointerCancel:Je,role:"separator","aria-orientation":"vertical","aria-label":l("rightSidebar.contextNotesTodo.sections.resize")}),je.map(we=>{const Ye=q===we.id;return t.jsxs("button",{type:"button",onClick:()=>G(we.id),"aria-current":Ye?"page":void 0,className:ie("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ye?"bg-interactive-active text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),style:{minHeight:0},children:[t.jsx(R,{name:we.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:we.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:we.count})]},we.id)})]}),e[211]=q,e[212]=Je,e[213]=We,e[214]=O,e[215]=ze,e[216]=je,e[217]=G,e[218]=Re,e[219]=l,e[220]=es):es=e[220];let ts;e[221]!==Zt||e[222]!==es?(ts=t.jsxs("div",{className:"flex min-h-0 flex-1",children:[Zt,es]}),e[221]=Zt,e[222]=es,e[223]=ts):ts=e[223];const Hs=Te.pendingSendTarget!==null;let ss;e[224]!==Te?(ss=we=>{we||Te.closeDialog()},e[224]=Te,e[225]=ss):ss=e[225];const Ks=Te.pendingSendTarget?.kind??"session";let ns;e[226]!==n.path||e[227]!==Te.confirmSend||e[228]!==Te.isSubmitting||e[229]!==Hs||e[230]!==ss||e[231]!==Ks?(ns=t.jsx(il,{open:Hs,onOpenChange:ss,target:Ks,projectDirectory:n.path,submitting:Te.isSubmitting,onConfirm:Te.confirmSend}),e[226]=n.path,e[227]=Te.confirmSend,e[228]=Te.isSubmitting,e[229]=Hs,e[230]=ss,e[231]=Ks,e[232]=ns):ns=e[232];let Is;return e[233]!==ct||e[234]!==ht||e[235]!==Ht||e[236]!==ts||e[237]!==ns?(Is=t.jsxs("div",{className:ct,children:[ht,Ht,ts,ns]}),e[233]=ct,e[234]=ht,e[235]=Ht,e[236]=ts,e[237]=ns,e[238]=Is):Is=e[238],Is};function wd(s){return s.load}function vd(s){return s.saveTodos}function jd(s){return s.currentSessionId}function kd(s){return s.currentSessionDirectory}function Sd(s){return s.newSessionDraft}function Nd(s){return s.setDraftProjectContextPin}function Cd(s){return s.id}function Id(s){return s.id}function Td(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function Pd(s){return s.disabled}function Dd(s){return s.global}function Ed(s){return s.project}function Rd(s){return s.isMobile}function Ad(s){return s.projectContextTab}function Bd(s){return s.setProjectContextTab}function Md(s){return s.agentMemoryViewedAt[Pn("global",null)]??0}function Ld(s){return s.projectContextSidebarWidth}function Fd(s){return s.setProjectContextSidebarWidth}const Xu=s=>{const e=Ve.c(26),{onActionComplete:n,onOpenPlan:r}=s,o=Ct(Od),a=Ct($d),i=Cs(Wd),{t:u}=et(),c=Cn(Ud),l=ot(_d),f=ot(Vd);let h;e[0]!==f||e[1]!==i?(h=Ea(f)??Ra(i),e[0]=f,e[1]=i,e[2]=h):h=e[2];const g=h;let p;e:{if(l){p=null;break e}if(o){let w;e[3]!==o||e[4]!==a?(w=a.find(x=>x.id===o)??a[0]??null,e[3]=o,e[4]=a,e[5]=w):w=e[5],p=w;break e}p=a[0]??null}const d=p;let y;e:{if(l&&g){let x;e[6]!==g?(x={id:Ma,path:g},e[6]=g,e[7]=x):x=e[7],y=x;break e}if(!d){y=null;break e}let w;e[8]!==d.id||e[9]!==d.path?(w={id:d.id,path:d.path},e[8]=d.id,e[9]=d.path,e[10]=w):w=e[10],y=w}const j=y;let I;e:{if(l){let x;e[11]!==u?(x=u("sessions.sidebar.activity.chatsTitle"),e[11]=u,e[12]=x):x=e[12],I=x;break e}if(!d){I=null;break e}let w;e[13]!==d.label||e[14]!==d.path||e[15]!==i?(w=d.label?.trim()||Aa(d.path,i)||d.path,e[13]=d.label,e[14]=d.path,e[15]=i,e[16]=w):w=e[16],I=w}const C=I;let B;e:{if(!d){B=!1;break e}let w;e[17]!==d.path||e[18]!==c?(w=c.get(d.path)?.isGitRepo,e[17]=d.path,e[18]=c,e[19]=w):w=e[19],B=w===!0}const $=B;let S;return e[20]!==$||e[21]!==n||e[22]!==r||e[23]!==C||e[24]!==j?(S=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(yd,{projectRef:j,projectLabel:C,canCreateWorktree:$,onActionComplete:n,onOpenPlan:r})}),e[20]=$,e[21]=n,e[22]=r,e[23]=C,e[24]=j,e[25]=S):S=e[25],S};function Od(s){return s.activeProjectId}function $d(s){return s.projects}function Wd(s){return s.homeDirectory}function Ud(s){return s.directories}function _d(s){return s.newSessionDraft.open?s.newSessionDraft.target==="chat":Ba(s.currentSessionDirectory)}function Vd(s){return s.currentSessionDirectory}const Ms=Object.freeze({chunks:Object.freeze([]),byteLength:0,lastSequence:-1}),jn=512*1024,zd=new TextEncoder,Gd=new TextDecoder,sn=s=>{const e=zd.encode(s);if(e.byteLength<=jn)return{text:s,byteLength:e.byteLength};let n=e.byteLength-jn;for(;n<e.byteLength&&(e[n]&192)===128;)n+=1;const r=e.subarray(n);return{text:Gd.decode(r),byteLength:r.byteLength}},Vt=(s,e)=>`${s}\0${e}`,nn=(s,e)=>{let n=null;for(const r of s.keys())e(r)&&(n??=new Map(s),n.delete(r));return n},Hd="terminal-store";let dr=!1,ur=0;const Rs=()=>typeof globalThis.crypto?.randomUUID=="function"?`tab-${globalThis.crypto.randomUUID()}`:(ur+=1,`tab-${Date.now().toString(36)}-${ur.toString(36)}`),rn=s=>typeof s=="object"&&s!==null,Kd=s=>{const e=/^tab-(\d+)$/.exec(s);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function gt(s){let e=s.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const qd=/^Terminal(?: (\d+))?$/,fr=s=>{let e=0;for(const n of s){const r=qd.exec(n.label);if(!r)continue;const o=r[1]?Number.parseInt(r[1],10):1;Number.isSafeInteger(o)&&(e=Math.max(e,o))}return e===0?"Terminal":`Terminal ${e+1}`},As=(s,e)=>({id:s,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),on=s=>({tabs:[s],activeTabId:s.id}),Tt=(s,e)=>s.tabs.findIndex(n=>n.id===e);let an=null,ln=null;const Yd=s=>{if(ln&&an?.sessions===s.sessions&&an.nextTabId===s.nextTabId)return ln;const e={sessions:Array.from(s.sessions.entries()).map(([n,r])=>[n,{activeTabId:r.activeTabId,tabs:r.tabs.map(o=>({id:o.id,label:o.label,iconKey:o.iconKey,createdAt:o.createdAt}))}]),nextTabId:s.nextTabId};return an={sessions:s.sessions,nextTabId:s.nextTabId},ln=e,e},Jd=()=>{const s=ji(()=>li());if(!s)return;let e=null;return{getItem:n=>s.getItem(n),setItem:(n,r)=>{if(r.state!==e)return e=r.state,s.setItem(n,r)},removeItem:n=>(e=null,s.removeItem(n))}},Ze=zs()(Ar(Br((s,e)=>({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=gt(n);r&&s(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),i=Rs(),u=As(i,"Terminal");return a.set(r,on(u)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=gt(n);return e().sessions.get(r)},getActiveTab:n=>{const r=gt(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(i=>i.id===a)??o.tabs[0]:o.tabs[0]},getBuffer:(n,r)=>e().buffers.get(Vt(gt(n),r))??Ms,createTab:n=>{const r=gt(n);if(!r)return"tab-invalid";const o=Rs();return s(a=>{const i=new Map(a.sessions),u=i.get(r),c=a.nextTabId+1,l=fr(u?.tabs??[]),f=As(o,l);return u?i.set(r,{...u,tabs:[...u.tabs,f]}):i.set(r,on(f)),{sessions:i,nextTabId:c}}),o},adoptServerSessions:(n,r)=>{const o=gt(n);!o||r.length===0||s(a=>{const i=a.sessions.get(o),u=new Set;for(const d of i?.tabs??[])u.add(d.id),d.terminalSessionId&&u.add(d.terminalSessionId);const c=r.filter(d=>!u.has(d.sessionId));if(c.length===0)return a;const l=[...i?.tabs??[]],f=l.length===1&&l[0].terminalSessionId===null&&l[0].lifecycle==="idle"&&!a.buffers.has(Vt(o,l[0].id))?l[0]:null;f&&(l.length=0);for(const d of c){const y={...As(d.sessionId,f&&l.length===0?f.label:fr(l)),terminalSessionId:d.sessionId,lifecycle:d.status,createdAt:d.createdAt??Date.now()};l.push(y)}const h=i?.activeTabId??null,g=h&&l.some(d=>d.id===h)?h:l[0]?.id??null,p=new Map(a.sessions);return p.set(o,{tabs:l,activeTabId:g}),{sessions:p}})},setActiveTab:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),u=i.get(o);return!u||u.activeTabId===r||Tt(u,r)<0?a:(i.set(o,{...u,activeTabId:r}),{sessions:i})})},setTabLabel:(n,r,o)=>{const a=gt(n),i=o.trim();i&&s(u=>{const c=new Map(u.sessions),l=c.get(a);if(!l)return u;const f=Tt(l,r);if(f<0||l.tabs[f]?.label===i)return u;const h=[...l.tabs];return h[f]={...h[f],label:i},c.set(a,{...l,tabs:h}),{sessions:c}})},setTabIconKey:(n,r,o)=>{const a=gt(n);s(i=>{const u=new Map(i.sessions),c=u.get(a);if(!c)return i;const l=Tt(c,r);if(l<0)return i;const f=o?.trim()||null;if(c.tabs[l]?.iconKey===f)return i;const h=[...c.tabs];return h[l]={...h[l],iconKey:f},u.set(a,{...c,tabs:h}),{sessions:u}})},closeTab:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),u=i.get(o);if(!u)return a;const c=Tt(u,r);if(c<0)return a;const l=u.tabs.filter(y=>y.id!==r),f=Object.fromEntries(Object.entries(a.projectActionRuns).filter(([,y])=>!(y.directory===o&&y.tabId===r))),h=Object.keys(f).length!==Object.keys(a.projectActionRuns).length,g=Vt(o,r),p=a.buffers.has(g)?nn(a.buffers,y=>y===g):null;if(l.length===0){const y=Rs(),j=As(y,"Terminal");return i.set(o,on(j)),{sessions:i,nextTabId:a.nextTabId+1,...p?{buffers:p}:{},...h?{projectActionRuns:f}:{}}}let d=u.activeTabId;return u.activeTabId===r&&(d=l[Math.min(c,l.length-1)]?.id??l[0]?.id??null),i.set(o,{...u,tabs:l,activeTabId:d}),{sessions:i,...p?{buffers:p}:{},...h?{projectActionRuns:f}:{}}})},setTabSessionId:(n,r,o)=>{const a=gt(n);s(i=>{const u=new Map(i.sessions),c=u.get(a);if(!c)return i;const l=Tt(c,r);if(l<0)return i;const f=c.tabs[l],h=o!==null&&f.terminalSessionId!==o,g=o?"running":f.terminalSessionId?"exited":f.lifecycle,p={...f,terminalSessionId:o,lifecycle:g,isConnecting:!1},d=Vt(a,r),y=h&&i.buffers.has(d)?nn(i.buffers,I=>I===d):null,j=[...c.tabs];return j[l]=p,u.set(a,{...c,tabs:j}),{sessions:u,...y?{buffers:y}:{}}})},setTabLifecycle:(n,r,o)=>{const a=gt(n);s(i=>{const u=new Map(i.sessions),c=u.get(a);if(!c)return i;const l=Tt(c,r);if(l<0)return i;const f=[...c.tabs];return f[l]={...f[l],lifecycle:o,isConnecting:!1},u.set(a,{...c,tabs:f}),{sessions:u}})},setConnecting:(n,r,o)=>{const a=gt(n);s(i=>{const u=new Map(i.sessions),c=u.get(a);if(!c)return i;const l=Tt(c,r);if(l<0)return i;const f=[...c.tabs];return f[l]={...f[l],isConnecting:o},u.set(a,{...c,tabs:f}),{sessions:u}})},replaceBuffer:(n,r,o,a)=>{const i=gt(n);s(u=>{const c=u.sessions.get(i);if(!c||Tt(c,r)<0)return u;const l=Vt(i,r),f=u.buffers.get(l)??Ms;if(f.lastSequence>a)return u;const h=sn(o);if(f.lastSequence===a&&f.byteLength===h.byteLength&&f.chunks.map(d=>d.data).join("")===h.text)return u;const g=u.nextChunkId,p=new Map(u.buffers);return p.set(l,{chunks:h.text?[{id:g,data:h.text,byteLength:h.byteLength}]:[],byteLength:h.byteLength,lastSequence:a}),{buffers:p,nextChunkId:h.text?g+1:g}})},appendToBuffer:(n,r,o,a,i)=>{if(!o)return;const u=gt(n);s(c=>{const l=c.sessions.get(u);if(!l||Tt(l,r)<0)return c;const f=Vt(u,r),h=c.buffers.get(f)??Ms;if(a!==void 0&&a<=h.lastSequence)return c;const g=c.nextChunkId,p=sn(o),d=i!==void 0&&i!==o?sn(i).text:void 0,y={id:g,data:p.text,...d!==void 0?{replayData:d}:{},byteLength:p.byteLength},j=[...h.chunks,y];let I=h.byteLength+y.byteLength;for(;I>jn&&j.length>1;){const B=j.shift();if(!B)break;I-=B.byteLength}const C=new Map(c.buffers);return C.set(f,{chunks:j,byteLength:I,lastSequence:a??h.lastSequence}),{buffers:C,nextChunkId:g+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const i=gt(n);s(u=>{const c=new Map(u.sessions),l=c.get(i);if(!l)return u;const f=Tt(l,r);if(f<0)return u;const h=l.tabs[f],g=a.autoOpened??h.previewAutoOpened,p=a.locked??h.previewUrlLocked;if(h.previewUrl===o&&h.previewAutoOpened===g&&h.previewUrlLocked===p)return u;const d=[...l.tabs];return d[f]={...h,previewUrl:o,previewAutoOpened:g,previewUrlLocked:p},c.set(i,{...l,tabs:d}),{sessions:c}})},markPreviewAutoOpened:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),u=i.get(o);if(!u)return a;const c=Tt(u,r);if(c<0)return a;const l=u.tabs[c];if(!l.previewUrl||l.previewAutoOpened)return a;const f=[...u.tabs];return f[c]={...l,previewAutoOpened:!0},i.set(o,{...u,tabs:f}),{sessions:i}})},setProjectActionRun:n=>{s(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{s(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{s(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},removeDirectory:n=>{const r=gt(n);s(o=>{const a=new Map(o.sessions);a.delete(r);const i=Vt(r,""),u=nn(o.buffers,l=>l.startsWith(i)),c=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,l])=>l.directory!==r));return{sessions:a,...u?{buffers:u}:{},projectActionRuns:c}})},clearAll:()=>{s({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:Hd,storage:Jd(),partialize:Yd,merge:(s,e)=>{if(!rn(s))return e;const n=Array.isArray(s.sessions)?s.sessions:[],r=new Map;let o=0;for(const u of n){if(!Array.isArray(u)||u.length!==2)continue;const[c,l]=u;if(typeof c!="string"||!rn(l))continue;const f=Array.isArray(l.tabs)?l.tabs:[],h=[],g=new Map;for(const j of f){if(!rn(j))continue;const I=typeof j.id=="string"?j.id:null;if(!I)continue;const C=Kd(I);C!==null&&(o=Math.max(o,C));const B=C===null?I:Rs();g.set(I,B),h.push({id:B,label:typeof j.label=="string"?j.label:"Terminal",iconKey:typeof j.iconKey=="string"?j.iconKey:null,terminalSessionId:null,lifecycle:"idle",createdAt:typeof j.createdAt=="number"?j.createdAt:Date.now(),isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(h.length===0)continue;const p=typeof l.activeTabId=="string"?l.activeTabId:null,d=p?g.get(p)??p:null,y=d?h.some(j=>j.id===d):!1;r.set(c,{tabs:h,activeTabId:y?d:h[0].id})}const a=typeof s.nextTabId=="number"&&Number.isFinite(s.nextTabId)?s.nextTabId:1,i=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,buffers:new Map,nextChunkId:1,nextTabId:i,hasHydrated:!0}}})));if(typeof window<"u"&&!dr){dr=!0;const s=Ze.persist,e=()=>{Ze.getState().hasHydrated||Ze.setState({hasHydrated:!0})};s?.hasHydrated?.()?e():s?.onFinishHydration?s.onFinishHydration(e):e()}function Qd(s){const{colors:e}=s,n=e.syntax.base;return{background:e.surface.background,foreground:n.foreground,cursor:e.interactive.cursor,cursorAccent:e.surface.background,selectionBackground:e.interactive.selection,selectionForeground:e.interactive.selectionForeground,selectionInactiveBackground:e.interactive.selection+"50",black:e.surface.muted,red:e.status.error,green:e.status.success,yellow:e.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:e.status.error,brightGreen:e.status.success,brightYellow:e.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:e.surface.elevatedForeground}}function Xd(s,e,n,r,o=!1){const i=`${s}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:e,fontFamily:i,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:o}}const cn=["\x1B[0m","\x1B[m"],Zd=s=>{const e=s.trim(),n=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(n){const a=n.length<=4?n.slice(0,3).split("").map(i=>i+i).join(""):n.slice(0,6);return[Number.parseInt(a.slice(0,2),16),Number.parseInt(a.slice(2,4),16),Number.parseInt(a.slice(4,6),16)]}const r=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!r)return null;const o=r.slice(1,4).map(Number);return o.some(a=>a<0||a>255)?null:o},mr=s=>{const e=Zd(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},eu=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let o=0;const a=Math.max(...cn.map(c=>c.length))-1;for(let c=1;c<=Math.min(a,r.length);c+=1){const l=r.slice(-c);cn.some(f=>f.length>l.length&&f.startsWith(l))&&(o=c)}const i=o>0?r.slice(-o):"";let u=o>0?r.slice(0,-o):r;for(const c of cn)u=u.replaceAll(c,n);return{data:u,carry:i}},tu=(s,e,n,r,o)=>{if(n.width<=0||n.height<=0||r<=0||o<=0)return null;const a=Math.floor((s-n.left)/n.width*r),i=Math.floor((e-n.top)/n.height*o);return{column:Math.max(0,Math.min(r-1,a)),row:Math.max(0,Math.min(o-1,i))}},su=(s,e)=>{const n=Math.max(0,Math.min(s.length-1,e)),r=i=>!!(i&&!/^\s+$/u.test(i));if(!r(s[n]))return{startColumn:n,endColumn:n};let o=n,a=n;for(;o>0&&r(s[o-1]);)o-=1;for(;a<s.length-1&&r(s[a+1]);)a+=1;return{startColumn:o,endColumn:a}};let nu=null;const ru=()=>nu??=Gt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([122,5])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),ou=2e3,au=()=>{if(typeof window>"u")return Promise.resolve();const s=window.__openchamberEnsureNerdFonts;return typeof s!="function"?Promise.resolve():Promise.race([Promise.resolve(s()).catch(()=>{}),new Promise(e=>setTimeout(e,ou))]).then(()=>{})},iu=(s,e,n)=>{if(typeof window>"u"||typeof document>"u")return null;const r=document.createElement("canvas").getContext("2d");if(!r||s.clientWidth<24||s.clientHeight<24)return null;r.font=`${n}px ${e}`;const o=r.measureText("M"),a=Math.ceil(o.width),i=Math.ceil((o.actualBoundingBoxAscent||n*.8)+(o.actualBoundingBoxDescent||n*.2))+2;if(a<1||i<1)return null;const u=window.getComputedStyle(s),c=(Number.parseInt(u.paddingLeft,10)||0)+(Number.parseInt(u.paddingRight,10)||0),l=(Number.parseInt(u.paddingTop,10)||0)+(Number.parseInt(u.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-c-15)/a)),rows:Math.max(1,Math.floor((s.clientHeight-l)/i))}},oo=m.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:o,fontFamily:a,fontSize:i,className:u,enableTouchScroll:c=!1,autoFocus:l=!0,isVisible:f=!0},h)=>{const g=m.useRef(null),p=m.useRef(null),d=m.useRef(null),y=m.useRef(n),j=m.useRef(r),I=m.useRef(null),C=m.useRef(null),B=m.useRef(null),$=m.useRef(""),S=m.useRef(""),w=m.useRef(mr(o.background)),x=m.useRef(!1),N=m.useRef(0),W=m.useRef(f),V=m.useRef(!1),[F,_]=m.useState(0),[H,J]=m.useState(0);y.current=n,j.current=r,W.current=f,w.current=mr(o.background),m.useLayoutEffect(()=>{const z=g.current;if(!z)return;const P=iu(z,a,i);C.current=P,P&&j.current(P.cols,P.rows)},[a,i]);const D=m.useCallback(()=>{const z=g.current,P=p.current;if(!z||!P||!d.current||!W.current)return;const O=z.getBoundingClientRect();if(!(O.width<24||O.height<24))try{d.current.fit();const M={cols:P.cols,rows:P.rows};(!I.current||I.current.cols!==M.cols||I.current.rows!==M.rows)&&(I.current=M,j.current(M.cols,M.rows)),V.current||(V.current=!0,_(G=>G+1))}catch{}},[]),oe=m.useCallback(()=>{if(x.current||!$.current||!p.current)return;const z=p.current,P=$.current;$.current="";const O=eu(P,S.current,w.current);if(S.current=O.carry,!O.data){$.current&&oe();return}x.current=!0;const M=N.current;z.write(O.data,()=>{p.current!==z||N.current!==M||(x.current=!1,$.current&&oe())})},[]),U=m.useCallback(()=>{B.current=null,$.current="",S.current="",x.current=!1,N.current+=1;const z=p.current;if(!z){J(P=>P+1);return}try{z.reset();const P=w.current;P&&z.write(`${P}\x1B[2J\x1B[H`)}catch{J(P=>P+1)}},[]);return m.useEffect(()=>{const z=g.current;if(!z)return;let P=!1,O=null,M=null,G=null,E=null,K=[];const q=()=>{O&&W.current&&(O.options.cursorBlink=!0)},Z=ee=>{ee.relatedTarget instanceof Node&&z.contains(ee.relatedTarget)||O&&(O.options.cursorBlink=!1)},Q=()=>{O&&W.current&&z.contains(document.activeElement)&&(O.options.cursorBlink=!0)},X=()=>{O&&(O.options.cursorBlink=!1)};return z.addEventListener("focusin",q),z.addEventListener("focusout",Z),window.addEventListener("focus",Q),window.addEventListener("blur",X),Promise.all([ru(),au()]).then(([{module:ee,ghostty:de}])=>{if(P)return;O=new ee.Terminal({...Xd(a,i,o,de,!1),...C.current??{}});const se=new ee.FitAddon;O.loadAddon(se),O.open(z),z.setAttribute("autocapitalize","off"),z.setAttribute("autocorrect","off"),z.setAttribute("spellcheck","false"),p.current=O,d.current=se,K=[O.onData(le=>y.current(le))],M=new ResizeObserver(()=>{G&&clearTimeout(G),G=setTimeout(D,80)}),M.observe(z),D();const he=w.current;he&&O.write(`${he}\x1B[2J\x1B[H`),E=requestAnimationFrame(D)}),()=>{P=!0;const ee=document.activeElement;ee instanceof HTMLElement&&z.contains(ee)&&(ee.blur(),window.Capacitor?.getPlatform?.()==="android"&&Gt(async()=>{const{Keyboard:se}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:se}},__vite__mapDeps([123,124])).then(({Keyboard:se})=>se.hide()).catch(()=>{})),M?.disconnect(),G&&clearTimeout(G),E!==null&&cancelAnimationFrame(E),z.removeEventListener("focusin",q),z.removeEventListener("focusout",Z),window.removeEventListener("focus",Q),window.removeEventListener("blur",X),K.forEach(de=>de.dispose()),O?.dispose(),p.current=null,d.current=null,I.current=null,B.current=null,$.current="",S.current="",x.current=!1,N.current+=1,V.current=!1}},[D,a,i,H,o]),m.useEffect(()=>{const z=p.current,P=g.current;!z||!P||(z.options.cursorBlink=f&&document.hasFocus()&&P.contains(document.activeElement))},[f,F]),m.useEffect(()=>{if(!p.current)return;if(e.length===0){B.current!==null&&U();return}const P=B.current;let O=-1;if(P!==null){for(let E=e.length-1;E>=0;E-=1){const K=e[E].id;if(K===P){O=E;break}if(K<P)break}if(O<0){U();return}}const M=O<0,G=O>=0?e.slice(O+1):e;$.current+=G.map(E=>M?E.replayData??E.data:E.data).join(""),B.current=e.at(-1)?.id??null,oe()},[e,oe,F,U]),m.useEffect(()=>{if(!l||!f)return;const z=requestAnimationFrame(()=>p.current?.focus());return()=>cancelAnimationFrame(z)},[l,f,F,s]),m.useEffect(()=>{const z=g.current;if(!c||!z)return;const P=O=>{const M=O;if(!M.isComposing)switch(M.inputType){case"insertText":M.data&&y.current(M.data);break;case"insertLineBreak":case"insertParagraph":y.current("\r");break;case"deleteContentBackward":y.current("");break}};return z.addEventListener("beforeinput",P),()=>z.removeEventListener("beforeinput",P)},[c,F]),m.useEffect(()=>{const z=g.current,P=p.current;if(!c||!z||!P)return;let O=null,M=null,G="idle",E=0,K=0,q=0,Z=0,Q=null;const X=Math.max(12,i+2),ee=()=>{window.Capacitor?.getPlatform?.()==="android"&&Gt(async()=>{const{Keyboard:te}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:te}},__vite__mapDeps([123,124])).then(({Keyboard:te})=>te.show()).catch(()=>{})},de=()=>{M&&(clearTimeout(M),M=null)},se=(L,te)=>{const ue=z.querySelector("canvas");return ue?tu(L,te,ue.getBoundingClientRect(),P.cols,P.rows):null},he=(L,te)=>{const ue=z.querySelector("canvas");if(!ue)return;const fe=ue.getBoundingClientRect(),be=fe.left+(te.column+.5)/P.cols*fe.width,Ie=fe.top+(te.row+.5)/P.rows*fe.height;ue.dispatchEvent(new MouseEvent(L,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:be,clientY:Ie}))},le=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},Y=L=>{L.pointerType!=="touch"||O!==null||(O=L.pointerId,G="pending",E=L.clientX,K=L.clientY,q=L.clientY,Z=0,Q=null,z.setPointerCapture(L.pointerId),M=setTimeout(()=>{if(M=null,O!==L.pointerId||G!=="pending")return;const te=se(E,K);if(!te)return;const ue=P.buffer.active,fe=Math.max(0,ue.length-P.rows-ue.viewportY+te.row),be=ue.getLine(fe),Ie=Array.from({length:P.cols},(Qe,Ue)=>be?.getCell(Ue)?.getChars()??""),Ee=su(Ie,te.column),ze={column:Ee.startColumn,row:te.row};Q={column:Ee.endColumn,row:te.row},G="selecting",he("mousedown",ze),he("mousemove",Q)},350))},ne=L=>{if(O!==L.pointerId)return;if(G==="selecting"){const fe=se(L.clientX,L.clientY);fe&&(!Q||fe.column!==Q.column||fe.row!==Q.row)&&(Q=fe,he("mousemove",fe)),L.cancelable&&L.preventDefault();return}if(G==="pending"){if(Math.hypot(L.clientX-E,L.clientY-K)<8)return;de(),G="scrolling"}if(G!=="scrolling")return;const te=q-L.clientY;q=L.clientY,Z+=te;const ue=Math.trunc(Z/X);ue&&(P.scrollLines(ue),Z-=ue*X),L.cancelable&&L.preventDefault()},ce=L=>{if(O!==L.pointerId)return;const te=G==="pending",ue=G==="selecting";de(),z.hasPointerCapture(L.pointerId)&&z.releasePointerCapture(L.pointerId),O=null,G="idle",ue&&le(),te&&(P.focus(),ee())},v=L=>{if(O!==L.pointerId)return;const te=G==="selecting";de(),z.hasPointerCapture(L.pointerId)&&z.releasePointerCapture(L.pointerId),O=null,G="idle",te&&le()};return z.addEventListener("pointerdown",Y),z.addEventListener("pointermove",ne,{passive:!1}),z.addEventListener("pointerup",ce),z.addEventListener("pointercancel",v),()=>{de(),z.removeEventListener("pointerdown",Y),z.removeEventListener("pointermove",ne),z.removeEventListener("pointerup",ce),z.removeEventListener("pointercancel",v)}},[c,i,F]),m.useImperativeHandle(h,()=>({focus:()=>p.current?.focus(),fit:D,getSelection:()=>{const z=p.current,P=z?.getSelectionPosition(),O=z?.getSelection()??"";return!P||!O.trim()?null:{text:O,startLine:P.start.y+1,endLine:P.end.y+1}}}),[D]),t.jsx("div",{ref:g,"data-terminal-owner":"main",className:ie("terminal-viewport-container h-full w-full overflow-hidden touch-none",u)})});oo.displayName="TerminalViewport";const lu="\x1B",ao=new RegExp(`${lu}\\[[0-9;?]*[ -/]*[@-~]`,"g"),cu=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,du=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,uu=/Serving HTTP on .*? port (\d{2,5})/i,fu=new Set([".",",",";",":","!","?"]),io=s=>{let e=s;for(;e.length>0;){const n=e[e.length-1];if(n===")"||n==="]"||n==="}"||n===">"){const r=n===")"?"(":n==="]"?"[":n==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${r}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${n}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(fu.has(n)){e=e.slice(0,-1);continue}break}return e},kn=s=>{let e=io(s);return e=e.replace("0.0.0.0","127.0.0.1"),e=e.replace("[::1]","127.0.0.1"),e=e.replace("[::]","127.0.0.1"),e},mu=s=>{if(!s)return[];const e=s.replace(ao,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(uu);if(a?.[1]){const i=Number.parseInt(a[1],10);Number.isFinite(i)&&i>0&&i<=65535&&o(`http://127.0.0.1:${i}/`)}for(const i of e.split(`
|
|
9
|
+
`)){if(!du.test(i))continue;const u=Array.from(i.matchAll(cu));if(u.length===0)continue;const c=u.find(l=>{try{return!!new URL(kn(l[1])).port}catch{return!1}});o(kn((c??u[0])[1]))}return n},lo=s=>mu(s)[0]??null,hu=async(s,e=1500)=>{if(!s||typeof window>"u")return!1;let n;try{n=new URL(s)}catch{return!1}if(n.protocol!=="http:"&&n.protocol!=="https:")return!1;const r=n.hostname.toLowerCase();if(r!=="localhost"&&r!=="127.0.0.1"&&r!=="0.0.0.0"&&r!=="::1"&&r!=="::")return!1;const o=new AbortController,a=window.setTimeout(()=>o.abort(),e);try{const i=await Bt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n.toString()}),cache:"no-store",signal:o.signal});return i.ok?(await i.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(a)}},pu=/https?:\/\/[^\s<>'"`]+/gi,Zu=(s,{requireAnnounced:e=!1}={})=>{const n=lo(s);if(n)return n;if(e)return null;const r=String(s||"").replace(ao,""),o=[];for(const u of r.match(pu)??[])try{const c=new URL(io(u));c.port&&o.push(c)}catch{}if(o.length===0)return null;const a=u=>{const c=u.hostname.toLowerCase();return(c==="localhost"||c==="127.0.0.1"||c==="0.0.0.0"||c==="::1"?50:0)-(u.search||u.hash?10:0)};let i=o[0];for(const u of o.slice(1))a(u)>a(i)&&(i=u);return kn(i.toString())},gu={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},xu=(s,e)=>{if(e&&s.startsWith("arrow-")){const n=e==="ctrl"?"5":"3",r={"arrow-up":"A","arrow-down":"B","arrow-right":"C","arrow-left":"D"}[s];return`\x1B[1;${n}${r}`}return gu[s]},co=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},bu=(s,e)=>s&&(e==="ctrl"?co(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),hr={cols:80,rows:24},ef=({visible:s})=>{const{t:e}=et(),{terminal:n,runtime:r}=Nn(),{currentTheme:o}=Sr(),a=m.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});a.current={themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground};const{monoFont:i}=La(),u=Fe(T=>T.terminalFontSize),c=Fe(T=>T.terminalShell),l=Fe(T=>T.terminalLoginShells.includes(T.terminalShell)),{isMobile:f,isTablet:h,hasTouchOnlyPointer:g}=Us(),p=f||h,d=(p||g)&&r.platform==="web",y=r.platform!=="vscode",j=Fe(T=>T.showTerminalQuickKeysOnDesktop),I=p||j,C=ot(T=>T.currentSessionId),B=ot(T=>T.newSessionDraft),$=C!==null||B?.open===!0,S=Fa()??null,w=Ze(T=>S?T.sessions.get(S):void 0),x=Ze(T=>T.hasHydrated),N=Ze(T=>T.ensureDirectory),W=Ze(T=>T.createTab),V=Ze(T=>T.setActiveTab),F=Ze(T=>T.closeTab),_=Ze(T=>T.setTabSessionId),H=Ze(T=>T.adoptServerSessions),J=Ze(T=>T.setTabLifecycle),D=Ze(T=>T.setConnecting),oe=Ze(T=>T.appendToBuffer),U=Ze(T=>T.replaceBuffer),z=Ze(T=>T.setTabPreviewUrl),P=Oa(T=>T.addDraft),O=Fe(T=>T.openContextPreview),M=m.useMemo(()=>w?y?w.activeTabId??w.tabs[0]?.id??null:w.tabs[0]?.id??null:null,[w,y]),G=m.useMemo(()=>{if(w)return M?w.tabs.find(T=>T.id===M)??w.tabs[0]:w.tabs[0]},[w,M]),E=m.useMemo(()=>(w?.tabs??[]).map(T=>({icon:(()=>{const re=T.iconKey?qr[T.iconKey]??"terminal":"terminal";return t.jsx(R,{name:re,className:"h-4 w-4"})})(),id:T.id,label:T.label,title:T.label,closeLabel:e("terminalView.tabs.closeTabTitle")})),[w?.tabs,e]),K=G?.terminalSessionId??null,q=G?.lifecycle??"idle",Z=Ze(T=>S&&M?T.getBuffer(S,M).chunks:Ms.chunks),Q=G?.isConnecting??!1,X=G?.previewUrl??null,[ee,de]=m.useState(null),[se,he]=m.useState(!1),[le,Y]=m.useState(!1),[ne,ce]=m.useState(null),[v,L]=m.useState(!1),te=m.useRef(null),ue=m.useRef(null),fe=m.useRef(M),be=m.useRef(K),Ie=m.useRef(S),Ee=m.useRef(null),ze=m.useRef(null),Qe=m.useRef(new Set),Ue=m.useRef(""),qe=m.useRef(new Set),Ae=m.useRef(0),it=m.useCallback(()=>{Ue.current="",qe.current.clear(),Ae.current+=1},[]),Re=m.useCallback(()=>{d||typeof document<"u"&&!document.hasFocus()||Ee.current?.focus()},[d]),$e=m.useCallback(()=>{d||Ee.current?.focus()},[d]),We=s??!1,[Ge,at]=m.useState(We);m.useEffect(()=>{We&&at(!0)},[We]),m.useEffect(()=>{be.current=K},[K]),m.useEffect(()=>{!K||!n.updateAppearance||n.updateAppearance(K,a.current).catch(()=>{})},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,n,K]),m.useEffect(()=>{fe.current=M,it()},[M,it]),m.useEffect(()=>{Ie.current=S},[S]),m.useEffect(()=>{if(!x||!S||!n.listSessions)return;let T=!1;const re=S;return n.listSessions(re).then(xe=>{T||Ie.current!==re||H(re,xe)}).catch(()=>{}),()=>{T=!0}},[x,S,n,H]),m.useEffect(()=>{if(!n.touchSessions)return;const T=()=>{if(typeof navigator<"u"&&!navigator.onLine)return;const xe=[];for(const Le of Ze.getState().sessions.values())for(const ye of Le.tabs)ye.terminalSessionId&&xe.push(ye.terminalSessionId);xe.length>0&&n.touchSessions?.(xe).catch(()=>{})};T();const re=setInterval(T,600*1e3);return()=>clearInterval(re)},[n]),m.useEffect(()=>{!I&&ne!==null&&ce(null)},[I,ne,ce]),m.useEffect(()=>{!K&&ne!==null&&ce(null)},[K,ne,ce]);const Pe=m.useCallback(()=>{te.current?.(),te.current=null,ue.current=null,Y(!1)},[]);m.useEffect(()=>()=>{Pe(),be.current=null},[Pe]);const Je=m.useCallback((T,re,xe)=>{if(!xe)return;const Le=`${Ue.current}${xe}`.replace(/\r\n|\r/g,`
|
|
10
|
+
`),ye=Le.split(`
|
|
11
|
+
`),Oe=Le.endsWith(`
|
|
12
|
+
`)?ye.join(`
|
|
13
|
+
`):ye.slice(0,-1).join(`
|
|
14
|
+
`);if(Ue.current=Le.endsWith(`
|
|
15
|
+
`)?"":(ye[ye.length-1]??"").slice(-1024),!Oe)return;const je=lo(Oe);if(!je||qe.current.has(je))return;const pe=Ae.current;qe.current.add(je),hu(je).then(Ke=>{if(qe.current.delete(je),!Ke||Ae.current!==pe)return;const ct=Ze.getState().getDirectoryState(T)?.tabs.find(mt=>mt.id===re);!ct||ct.previewUrlLocked||ct.previewUrl===je||z(T,re,je,{locked:!1,autoOpened:!1})})},[z]),_e=m.useCallback((T,re,xe)=>{if(ue.current===xe)return;Pe(),ue.current=xe;const Le=n.connect(xe,{onEvent:ye=>{if(ue.current===xe)switch(ye.type){case"snapshot":{D(T,re,!1),de(null),he(!1),Y(!1),Re(),U(T,re,ye.data??"",ye.sequence??0),Je(T,re,ye.data??""),ye.status==="exited"&&J(T,re,"exited");break}case"reconnecting":{de(null),he(!1),Y(!0);break}case"data":{ye.data&&(oe(T,re,ye.data,ye.sequence,ye.replayData),Je(T,re,ye.data));break}case"exit":{const Oe=typeof ye.exitCode=="number"?ye.exitCode:null,je=typeof ye.signal=="number"?ye.signal:null,Ke=!!Ze.getState().getDirectoryState(T)?.tabs.find(ct=>ct.id===re)?.label?.startsWith("Action:");oe(T,re,e("terminalView.stream.processExitedMessage",{exitCodeSegment:Oe!==null?e("terminalView.stream.processExitedWithCode",{exitCode:Oe}):"",signalSegment:je!==null?e("terminalView.stream.processExitedWithSignal",{signal:je}):""})),J(T,re,"exited"),D(T,re,!1),de(Ke?null:e("terminalView.error.sessionEnded")),he(!1),Y(!1),Pe();break}}},onError:(ye,Oe)=>{if(ue.current===xe){if(!Oe){de(null),he(!1);return}if(Y(!1),ye.code==="SESSION_NOT_FOUND"&&!Ze.getState().getDirectoryState(T)?.tabs.find(pe=>pe.id===re)?.label?.startsWith("Action:")){de(null),he(!1),D(T,re,!1),_(T,re,null),J(T,re,"idle"),Pe();return}de(e("terminalView.error.connectionFailed",{message:ye.message})),he(!0),D(T,re,!1),J(T,re,"exited"),_(T,re,null),Pe()}}});te.current=()=>{Le.close(),ue.current=null}},[oe,U,Pe,Re,Je,D,J,_,e,n]);m.useEffect(()=>{let T=!1;if(!x||!Ge)return;if(!S){de(e($?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),Pe();return}return(async()=>{const xe=S;if(!Ie.current||Ie.current!==xe)return;if(!Ze.getState().getDirectoryState(xe)){N(xe);return}const ye=Ze.getState().getDirectoryState(xe);if(!ye||ye.tabs.length===0)return;const Oe=y?ye.activeTabId??ye.tabs[0]?.id??null:ye.tabs[0]?.id??null;if(!Oe)return;const je=ye.tabs.find(yt=>yt.id===Oe)??ye.tabs[0],pe=je?.terminalSessionId??null,Ke=je?.lifecycle??"idle",ct=!!je?.label?.startsWith("Action:"),mt=Ze.getState().getBuffer(xe,Oe),jt=mt.byteLength>0||mt.chunks.length>0;if(!pe){if(Ke==="exited"){D(xe,Oe,!1);return}if(ct&&jt){D(xe,Oe,!1);return}const yt=`${xe}\0${Oe}`;if(Qe.current.has(yt))return;const kt=ze.current??hr;Qe.current.add(yt),de(null),he(!1),Y(!1),D(xe,Oe,!0);try{const pt=await n.createSession({cwd:xe,sessionId:Oe,cols:kt.cols,rows:kt.rows,shell:c,loginShell:l,...a.current}),St=!T&&Ie.current===xe&&fe.current===Oe;if(!Ze.getState().getDirectoryState(xe)?.tabs.find(ht=>ht.id===Oe)){try{await n.close(pt.sessionId)}catch{}return}if(_(xe,Oe,pt.sessionId),!St)return;const Nt=ze.current;Nt&&(Nt.cols!==kt.cols||Nt.rows!==kt.rows)&&n.resize({sessionId:pt.sessionId,...Nt}).catch(()=>{});return}catch(pt){const St=Ze.getState().getDirectoryState(xe)?.tabs.find(It=>It.id===Oe);if(!St||St.terminalSessionId||(D(xe,Oe,!1),Ie.current!==xe||fe.current!==Oe))return;de(pt instanceof Error?pt.message:e("terminalView.error.startSessionFailed")),he(!0),Y(!1);return}finally{Qe.current.delete(yt)}}!pe||T||(be.current=pe,_e(xe,Oe,pe))})(),()=>{T=!0,be.current=null,Pe()}},[$,S,K,q,M,Ge,y,x,N,D,J,_,_e,Pe,e,n,l,c]),m.useEffect(()=>{if(!We||d)return;if(typeof window>"u"){Re();return}const T=window.requestAnimationFrame(()=>{Re()});return()=>{window.cancelAnimationFrame(T)}},[M,Re,We,d]);const Te=m.useCallback(async()=>{if(!S||v)return;const T=Ze.getState().getDirectoryState(S),re=y?M??T?.activeTabId??T?.tabs[0]?.id??null:T?.tabs[0]?.id??null;if(!re)return;const xe=T?.tabs.find(Le=>Le.id===re)?.terminalSessionId??null;if(!(!xe||!n.restartSession)){L(!0),de(null),he(!1),Y(!1),Pe(),it();try{const Le=ze.current??hr,ye=await n.restartSession(xe,{cwd:S,shell:c,loginShell:l,...Le,...a.current});if(Ze.getState().getDirectoryState(S)?.tabs.find(je=>je.id===re)?.terminalSessionId!==xe||(_(S,re,ye.sessionId),J(S,re,"running"),Ie.current!==S||fe.current!==re))return;be.current=ye.sessionId,_e(S,re,ye.sessionId)}catch(Le){if(Ze.getState().getDirectoryState(S)?.tabs.find(Oe=>Oe.id===re)?.terminalSessionId!==xe||Ie.current!==S||fe.current!==re)return;de(Le instanceof Error?Le.message:e("terminalView.error.restartFailed")),he(!1),Y(!1),be.current=xe,_e(S,re,xe)}finally{L(!1)}}},[M,Pe,S,y,v,it,J,_,_e,e,n,l,c]),Xe=m.useCallback(async()=>{await Te()},[Te]),nt=m.useCallback(()=>{if(!S)return;const T=W(S);V(S,T),de(null),he(!1),Y(!1),Pe()},[W,Pe,S,V]),b=m.useCallback(()=>{const T=Ee.current?.getSelection(),re=C??(B?.open?"draft":null);!T||!re||!G||!S||P({directory:S,sessionKey:re},{source:"terminal",fileLabel:G.label,startLine:T.startLine,endLine:T.endLine,code:T.text,language:"",terminalId:G.terminalSessionId??G.id,text:""})},[G,P,C,S,B?.open]),A=m.useCallback(T=>{S&&(V(S,T),de(null),he(!1),Y(!1),Pe())},[Pe,S,V]),ge=m.useCallback(T=>{if(!S)return;T===M&&Pe(),de(null),he(!1),Y(!1);const re=Ze.getState().getDirectoryState(S)?.tabs.find(xe=>xe.id===T)?.terminalSessionId;(async()=>{re&&await n.close(re),F(S,T)})().catch(xe=>de(xe instanceof Error?xe.message:e("terminalView.error.sessionEnded")))},[M,F,Pe,S,e,n]),me=m.useCallback(T=>{if(!T||le)return;let re=T,xe=!1;ne&&T.length>0&&(re=bu(T,ne),xe=!0);const Le=be.current;Le&&(n.sendInput(Le,re).catch(ye=>{le||de(ye instanceof Error?ye.message:e("terminalView.error.sendInputFailed"))}),xe&&(ce(null),$e()))},[ne,$e,le,ce,e,n]),Se=m.useCallback((T,re)=>{const xe=ze.current;if((!xe||xe.cols!==T||xe.rows!==re)&&(ze.current={cols:T,rows:re}),!We)return;const Le=be.current;Le&&n.resize({sessionId:Le,cols:T,rows:re}).catch(()=>{})},[We,n]),Me=m.useCallback(T=>{ce(re=>re===T?null:T),$e()},[$e,ce]),Be=m.useCallback(T=>{const re=xu(T,ne);re&&(me(re),ce(null),$e())},[ne,$e,me,ce]),He=m.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),k=m.useCallback(T=>{if(T.repeat)return;const re=T.key;if(!re||re==="Control"||re==="Meta"||re==="Alt"||re==="Shift")return;const xe=re.length===1?re.toLowerCase():re;if(xe in He){T.preventDefault(),T.stopPropagation(),Be(He[xe]);return}if(ne!=="ctrl")return;const Le=T.code??"",ye=re.length===1&&/[a-zA-Z]/.test(re)?re.toUpperCase():Le.startsWith("Key")&&Le.length===4?Le.slice(3).toUpperCase():null;if(ye&&ye.length===1&&ye>="A"&&ye<="Z"){const Oe=co(ye);if(!Oe)return;T.preventDefault(),T.stopPropagation(),me(Oe),ce(null),$e()}},[ne,$e,Be,me,He,ce]);m.useEffect(()=>{if(!(!I||!ne||!K))return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[ne,k,I,K]);const ve=m.useMemo(()=>{const T=ps[Js].stack;if(typeof window>"u")return(ps[i]??ps[Js]).stack;const xe=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return xe&&xe.trim().length>0?xe.trim():(ps[i]??ps[Js]).stack??T},[i]),Ce=m.useMemo(()=>Qd(o),[o]),De=`${S??"no-dir"}::${M??"no-tab"}`;if(m.useEffect(()=>{if(!We||d)return;const T=Ee.current;if(!T)return;const re=()=>{T.fit()};if(typeof window<"u"){const xe=window.requestAnimationFrame(()=>{re(),Re()}),Le=[220,400].map(ye=>window.setTimeout(re,ye));return()=>{window.cancelAnimationFrame(xe),Le.forEach(ye=>window.clearTimeout(ye))}}re()},[Re,We,d,De,K]),m.useEffect(()=>{if(!We||!d)return;let T=null;const re=()=>{T!==null&&window.cancelAnimationFrame(T),T=window.requestAnimationFrame(()=>{T=null,Ee.current?.fit()})};return window.addEventListener("oc:keyboard-settled",re),()=>{window.removeEventListener("oc:keyboard-settled",re),T!==null&&window.cancelAnimationFrame(T)}},[We,De,d]),!$)return t.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:e("terminalView.empty.selectSession")});if(!S)return t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[t.jsx("p",{children:e("terminalView.empty.noWorkingDirectoryForSession")}),t.jsx("button",{onClick:Te,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("terminalView.actions.retry")})]});const tt=!K||Q||v||le,ft=Ge,rt=p?"lg":"xs",dt=p?"w-10 p-0":"w-9 p-0",lt=T=>{p&&T.preventDefault()},st=t.jsxs(t.Fragment,{children:[t.jsx(Ne,{type:"button",size:rt,variant:"outline",onPointerDown:lt,onClick:()=>Be("esc"),disabled:tt,children:e("terminalView.quickKeys.escape")}),t.jsxs(Ne,{type:"button",size:rt,variant:"outline",className:dt,onPointerDown:lt,onClick:()=>Be("tab"),disabled:tt,children:[t.jsx(R,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.tabAria")})]}),t.jsxs(Ne,{type:"button",size:rt,variant:"chip","aria-pressed":ne==="ctrl",className:p?"px-3":"px-2",onPointerDown:lt,onClick:()=>Me("ctrl"),disabled:tt,children:[t.jsx("span",{className:"text-xs font-medium",children:xn("ctrl")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(Ne,{type:"button",size:rt,variant:"chip","aria-pressed":ne==="alt",className:p?"px-3":"px-2",onPointerDown:lt,onClick:()=>Me("alt"),disabled:tt,children:[t.jsx("span",{className:"text-xs font-medium",children:xn("alt")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(Ne,{type:"button",size:rt,variant:"outline",className:dt,onPointerDown:lt,onClick:()=>Be("arrow-up"),disabled:tt,children:[t.jsx(R,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(Ne,{type:"button",size:rt,variant:"outline",className:dt,onPointerDown:lt,onClick:()=>Be("arrow-left"),disabled:tt,children:[t.jsx(R,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(Ne,{type:"button",size:rt,variant:"outline",className:dt,onPointerDown:lt,onClick:()=>Be("arrow-down"),disabled:tt,children:[t.jsx(R,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(Ne,{type:"button",size:rt,variant:"outline",className:dt,onPointerDown:lt,onClick:()=>Be("arrow-right"),disabled:tt,children:[t.jsx(R,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(Ne,{type:"button",size:rt,variant:"outline",className:dt,onPointerDown:lt,onClick:()=>Be("enter"),disabled:tt,children:[t.jsx(R,{name:"arrow-go-back"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.enterAria")})]})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[t.jsxs("div",{className:ie("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",p?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[y&&w?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:ie("min-w-0 flex-1",p?"h-8":"h-7"),children:t.jsx(vs,{items:E,activeId:M,onSelect:A,onClose:ge,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:ie("shrink-0",p?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:nt,title:e("terminalView.tabs.newTabTitle"),children:t.jsx(R,{name:"add",className:`${p?"h-[18px] w-[18px]":"h-4 w-4"}`})}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{Te()},disabled:v,title:e("terminalView.actions.restart"),"aria-label":e("terminalView.actions.restart"),children:t.jsx(R,{name:"restart",className:"h-4 w-4"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:b,title:e("terminalView.actions.attachSelection"),"aria-label":e("terminalView.actions.attachSelection"),children:t.jsx(R,{name:"attachment-2",className:"h-4 w-4"})}),X?t.jsxs(Ne,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{S&&O(S,X)},title:e("terminalView.preview.openTitle"),children:[t.jsx(R,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:e("terminalView.preview.open")})]}):null]})]}):null,!p&&I&&y&&w?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:st}):null,!p&&I&&(!y||!w)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:st}):null]}),t.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:Ce.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:ft?t.jsx(oo,{ref:T=>{Ee.current=T},sessionKey:De,chunks:Z,onInput:me,onResize:Se,theme:Ce,fontFamily:ve,fontSize:u,enableTouchScroll:d,autoFocus:We,isVisible:We},De):null}),!le&&ee&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[t.jsx("span",{children:ee}),se&&p&&t.jsx(Ne,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Xe,disabled:v,title:e("terminalView.actions.hardRestartTitle"),type:"button",children:e("terminalView.actions.hardRestart")})]})]}),p&&I?t.jsx("div",{className:"shrink-0 overflow-x-auto border-t border-border/40 bg-[var(--surface-background)] px-2 pt-1.5 pb-[max(0.375rem,calc(var(--oc-app-bottom-safe,0px)-var(--oc-keyboard-inset,0px)))] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:t.jsx("div",{className:"flex min-w-max items-center gap-1.5",children:st})}):null]})},tf=()=>{Rr(),cs.reconnectToRuntimeBaseUrl(),Tr()},sf=s=>{ot.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&$a.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),Rr(),Ze.getState().clearAll(),cs.reconnectToRuntimeBaseUrl(),vt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),Ct.getState().resetForRuntimeSwitch(),Et.getState().reset(),dn.getState().resetForRuntimeSwitch(),Wa(new Map),Ua(),_a(),Va.getState().reset(),ci.getState().resetForRuntimeSwitch(),Cn.getState().resetForRuntimeSwitch(s.runtimeKey),za.getState().resetForRuntimeSwitch(),Ga.getState().resetForRuntimeSwitch(s.runtimeKey),di.getState().resetForRuntimeSwitch(s.runtimeKey),ot.getState().restoreForRuntimeSwitch(s.runtimeKey),Tr(),queueMicrotask(()=>{ui()})};export{Xl as A,Gu as B,Bu as C,Ju as D,Vu as E,Bc as F,zu as G,Ru as H,zt as I,ec as J,tc as K,en as L,il as M,Qu as N,Au as O,Xu as P,Du as Q,Yu as R,qu as S,ef as T,Eu as U,Al as W,jc as a,vs as b,sf as c,Ku as d,Hu as e,Mu as f,Pu as g,Xn as h,Ze as i,Bl as j,_u as k,qr as l,mu as m,Ml as n,Zu as o,rl as p,al as q,tf as r,ol as s,Uu as t,Wi as u,Ou as v,Wu as w,$u as x,Fu as y,Lu as z};
|