@vantran-se/openchamber-web 2.0.6 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/bin/lib/DOCUMENTATION.md +1 -0
  2. package/bin/lib/cli-args.js +3 -0
  3. package/bin/lib/cli-lifecycle.js +1 -0
  4. package/bin/lib/cli-process.js +1 -0
  5. package/bin/lib/cli-startup.js +53 -1
  6. package/bin/lib/cli-startup.test.js +37 -0
  7. package/bin/lib/commands-lifecycle.js +29 -13
  8. package/bin/lib/commands-startup.js +5 -2
  9. package/bin/lib/commands-startup.test.js +15 -0
  10. package/bin/lib/commands-update.js +40 -8
  11. package/bin/lib/commands-update.test.js +53 -6
  12. package/dist/assets/{CodeMirrorCommentWidgets-BlzB2e0C.js → CodeMirrorCommentWidgets--j227ElB.js} +1 -1
  13. package/dist/assets/{DiffView-D7JQzQVZ.js → DiffView-IFl6EaUT.js} +1 -1
  14. package/dist/assets/{FilesView-DC2gadXM.js → FilesView-2QJJIAmr.js} +1 -1
  15. package/dist/assets/{GitView-Gzl0wbdd.js → GitView-xpLPdSXl.js} +1 -1
  16. package/dist/assets/{GuestAttachDialog-CQdDIeco.js → GuestAttachDialog-CaRAB_pV.js} +1 -1
  17. package/dist/assets/{GuestSurfacePane-CrOhlIdt.js → GuestSurfacePane-CA1Pu0hE.js} +1 -1
  18. package/dist/assets/{JsonTreeView-C3QZifYe.js → JsonTreeView-RFvqdmCZ.js} +1 -1
  19. package/dist/assets/{LinearIssuesView-X27TCI3v.js → LinearIssuesView-CYI08VW3.js} +1 -1
  20. package/dist/assets/{MarkdownImageGallery-BlTWU9oH.js → MarkdownImageGallery-D_-yFGOt.js} +1 -1
  21. package/dist/assets/{MarkdownRendererImpl-Cno7QsJO.js → MarkdownRendererImpl-Dpb32U9p.js} +1 -1
  22. package/dist/assets/{OnboardingScreen-Wr_UzNtt.js → OnboardingScreen-B3B8bi91.js} +1 -1
  23. package/dist/assets/{PatchDiff-D6pWS7cD.js → PatchDiff-CdvF5h6a.js} +1 -1
  24. package/dist/assets/{PierreDiffViewer-DDljFbJJ.js → PierreDiffViewer-DLcUtI6Q.js} +1 -1
  25. package/dist/assets/{PlanView-LcfEbBPi.js → PlanView-Bvt1PdkO.js} +1 -1
  26. package/dist/assets/{PluginPane-DPWPLc2f.js → PluginPane-CaJz1LlW.js} +1 -1
  27. package/dist/assets/{SettingsView-CFe9O3EM.js → SettingsView-DL_ucsI6.js} +1 -1
  28. package/dist/assets/{SettingsWindow-DT1xhvgi.js → SettingsWindow-ilszvARl.js} +1 -1
  29. package/dist/assets/{SubmoduleDiffSummary-CBHXaIkB.js → SubmoduleDiffSummary-CeV_WX3U.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-B_ZX8ZbZ.js → ToolOutputDialog-vc1xXXMa.js} +1 -1
  31. package/dist/assets/{ToolPartDiffPreview-D_HQzkXU.js → ToolPartDiffPreview-B4EwqT8H.js} +1 -1
  32. package/dist/assets/{VirtualizedFileDiff-BUK1ujXg.js → VirtualizedFileDiff-DDgQH7-1.js} +1 -1
  33. package/dist/assets/{WalkthroughView-H-tYOvhO.js → WalkthroughView-Cf8EdtIU.js} +1 -1
  34. package/dist/assets/{appThemeRegistry-BoJGAwCP.js → appThemeRegistry-D2_fKsMa.js} +1 -1
  35. package/dist/assets/{commitAndPush-BzZrF8bK.js → commitAndPush-P6RxBC7G.js} +1 -1
  36. package/dist/assets/{computeVirtualFileMetrics-kYyVjXLu.js → computeVirtualFileMetrics-Bz7G81bS.js} +1 -1
  37. package/dist/assets/{de-ByfQDcPj.js → de-mIryiQXH.js} +1 -1
  38. package/dist/assets/{es-DzNbjsQS.js → es-CNRZG0Xh.js} +1 -1
  39. package/dist/assets/{fr-B8AVLrnX.js → fr-TQ28DG6e.js} +1 -1
  40. package/dist/assets/{index-0-ON1L7L.js → index-Dl3ruZe_.js} +1 -1
  41. package/dist/assets/{isDiffPlainText-Bgm_aLpu.js → isDiffPlainText-D2lANTsV.js} +1 -1
  42. package/dist/assets/{isFilePlainText-D5GMgURH.js → isFilePlainText-Cbv7v9Ro.js} +1 -1
  43. package/dist/assets/{ja-1g6S0G19.js → ja-eoTHPWE5.js} +1 -1
  44. package/dist/assets/{ko-CxplvYkJ.js → ko-B6kF-W3S.js} +1 -1
  45. package/dist/assets/{main-GjXmVNpD.js → main-BCP3yPm1.js} +4 -4
  46. package/dist/assets/{main--Y98ZLsD.js → main-yjCD5A_Y.js} +2 -2
  47. package/dist/assets/{markdownCore-CVdUcVCi.js → markdownCore-Bqfm6kwc.js} +1 -1
  48. package/dist/assets/{miniChat-tTx5mpbd.js → miniChat-fs-MMZEy.js} +2 -2
  49. package/dist/assets/{mobile-BmbiDWGb.js → mobile-DsTajahd.js} +2 -2
  50. package/dist/assets/{patchFileDiff-CV4iVQ8L.js → patchFileDiff-Cxi3zs93.js} +1 -1
  51. package/dist/assets/{pl-f3QyqvIB.js → pl-Cujf3IHL.js} +1 -1
  52. package/dist/assets/{pt-BR-BsaoaiCK.js → pt-BR-kre15SPf.js} +1 -1
  53. package/dist/assets/{renderElectronMiniChatApp-BnCdnDhv.js → renderElectronMiniChatApp-Dpfh7kye.js} +2 -2
  54. package/dist/assets/{renderMobileApp-CKn8nbSW.js → renderMobileApp-BSo1S4UB.js} +3 -3
  55. package/dist/assets/{runtimeEndpointReset-sCi88eed.js → runtimeEndpointReset-3DNMw1le.js} +3 -3
  56. package/dist/assets/{shikiHighlight-O5_xLmWt.js → shikiHighlight-mGfGdiiG.js} +1 -1
  57. package/dist/assets/{textMateThemeFromAppTheme-XM4VefqN.js → textMateThemeFromAppTheme-SNTAfu1S.js} +1 -1
  58. package/dist/assets/{tr-BNFsa6nz.js → tr-DMmJYX6x.js} +1 -1
  59. package/dist/assets/{uk-CJ9y5ULA.js → uk-SB3DoBhl.js} +1 -1
  60. package/dist/assets/{useAppFontEffects-BN06mgHB.js → useAppFontEffects-DJZbUd4z.js} +10 -10
  61. package/dist/assets/{useInlineCommentController-Bb9Gjz1Q.js → useInlineCommentController-dDUqIMI2.js} +1 -1
  62. package/dist/assets/{useRootScrollLock-Chk1cFUw.js → useRootScrollLock-DAPXfqs1.js} +2 -2
  63. package/dist/assets/{vendor-codemirror-language-data-C2qMZiA7.js → vendor-codemirror-language-data-DeBrOhi1.js} +2 -2
  64. package/dist/assets/{web-components-BQWjCn_U.js → web-components-5hxxRZKN.js} +1 -1
  65. package/dist/assets/{zh-CN-U0QjVlAA.js → zh-CN-B-YkU2-B.js} +1 -1
  66. package/dist/assets/{zh-TW-J9PTJQJi.js → zh-TW-0ddAsFNT.js} +1 -1
  67. package/dist/index.html +1 -1
  68. package/dist/mini-chat.html +1 -1
  69. package/dist/mobile.html +1 -1
  70. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-H-tYOvhO.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BN06mgHB.js","assets/index-Di6zUe5h.js","assets/vendor-zod-BSoePkpP.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-DUke1nme.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.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-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.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-C2qMZiA7.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-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-CV4iVQ8L.js","assets/runtimeEndpointReset-sCi88eed.js","assets/GuestAttachDialog-CQdDIeco.js","assets/PluginPane-DPWPLc2f.js","assets/VirtualizedFileDiff-BUK1ujXg.js","assets/web-components-BQWjCn_U.js","assets/computeVirtualFileMetrics-kYyVjXLu.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/isDiffPlainText-Bgm_aLpu.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DDljFbJJ.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-Bb9Gjz1Q.js","assets/appThemeRegistry-BoJGAwCP.js","assets/textMateThemeFromAppTheme-XM4VefqN.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-Chk1cFUw.js","assets/scheduledTasksApi-Dahv3ws0.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-D7JQzQVZ.js","assets/SubmoduleDiffSummary-CBHXaIkB.js","assets/changesTree-CePHbFcj.js","assets/FilesView-DC2gadXM.js","assets/shikiHighlight-O5_xLmWt.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-C3QZifYe.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-D5GMgURH.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-BlzB2e0C.js","assets/GitView-Gzl0wbdd.js","assets/commitAndPush-BzZrF8bK.js","assets/LinearIssuesView-X27TCI3v.js","assets/PlanView-LcfEbBPi.js","assets/GuestSurfacePane-CrOhlIdt.js","assets/SettingsWindow-DT1xhvgi.js","assets/SettingsView-CFe9O3EM.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-Wr_UzNtt.js"])))=>i.map(i=>d[i]);
2
- import{f as Ze,R as c,j as s,r as ct,c as Gm,h as qm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{F as en,H as Qo,I as Ym,J as Qm,h as ls,y as Fd,u as Ae,K as Rt,L as xl,a as Wt,z as vr,o as xt,N as js,O as Vr,P as kn,Q as Ld,R as Xm,S as Jm,T as Zm,U as eh,V as _d,n as Jt,W as jn,X as Ur,e as mn,Y as th,Z as sh,_ as nh,$ as rh,a0 as $d,x as Js,C as Vs,a1 as oh,a2 as bl,a3 as ih,a4 as zd,a5 as ah,a6 as Wd,f as lh,a7 as $n,a8 as Un,a9 as Ro,aa as Wi,ab as ch,ac as Ra,d as Mo,v as lr,q as as,ad as Kd,ae as dh,af as Ki,ag as Vd,ah as Ud,t as Hd,i as uh,ai as fh,aj as ko,ak as Co,al as mh,am as yl,an as hh,ao as ph,ap as gh,aq as xh,ar as wl,as as vl,at as Sl,au as jl,av as bh,B as kl,aw as yh,ax as wh,ay as vh,D as Sh,E as jh}from"./index-Di6zUe5h.js";import{_ as sn}from"./vendor-vite-runtime-DD1OZmLC.js";import{z as Cl,E as Si,F as Gs,G as Vi,H as Nl,I as kh,J as Ch,K as Nh,L as Ah,M as Ph,Q as Dh,R as Ih,V as Th,W as Ma,a as Eh,e as Gd,X as qd,h as Ui,m as Yd,Y as Rh,k as Mh,j as Oh,Z as Qd,_ as Hi,$ as zn,a0 as Xd,a1 as Jd,l as Bh,P as Fh,T as Lh,a2 as _h,a3 as $h,a4 as zh,a5 as Wh,b as Zd,a6 as Kh,a7 as eu,a8 as Oo,a9 as Vh,aa as Uh,ab as Hh,S as ji,ac as tu,ad as su,d as Gh,ae as qh,c as Yh,af as Qh,ag as ro,r as Al,ah as Xh,ai as Jh,u as _r,s as Zh,N as ep,D as tp,aj as sp,ak as Pl,al as np,am as ki,w as rp,q as op,x as nu,U as ip,y as ap,an as lp,ao as cp,ap as dp,O as up,o as fp,t as mp,v as ru,A as hp,C as pp}from"./runtimeEndpointReset-sCi88eed.js";import{f as St,h as Me,bh as _t,I as O,g as Jn,t as ze,at as Ps,bi as gs,av as Ds,as as Is,T as Cn,_ as nn,ai as Zn,bj as Nn,o as Qr,bk as Dl,bl as gp,bm as xp,ae as bt,af as yt,ag as wt,b as zt,z as nt,H as bp,bn as ou,bo as oo,u as us,r as xs,D as iu,C as au,bp as Gi,bq as yp,br as lu,bs as cu,S as Oa,bt as wp,bu as vp,bv as Il,bw as Tl,bx as du,by as Sp,bz as El,bA as jp,bB as kp,bC as Ba,bD as qi,bE as uu,bF as Cp,bG as Np,bH as Ap,Q as fu,bI as Pp,bJ as Dp,bK as Ip,n as ur,bL as mu,bM as Tp,bN as Ep,p as Rp,bO as hu,bP as Mp,bQ as Op,bR as Bp,bS as pu,bT as gu,bU as xu,bV as bu,bW as yu,bX as wu,bY as vu,bZ as Xr,b_ as Fa,aJ as La,b$ as Hn,c0 as Jr,c1 as Fp,c2 as bs,c3 as ys,c4 as Us,c5 as Bs,c6 as Fs,c7 as An,B as ut,c8 as gn,aB as ps,c9 as Lp,ca as _p,aH as hn,cb as cr,cc as Ms,cd as Xo,ce as Su,cf as Yi,cg as Qi,ch as Xi,ci as $p,cj as ks,ck as Cs,cl as hs,cm as Ns,cn as Yt,X as un,co as fr,cp as Rl,cq as hr,cr as ju,R as Jo,aj as zp,ak as _a,al as ku,J as Cu,K as pn,cs as $a,a9 as za,ct as Wp,cu as Kp,az as Vp,cv as Up,cw as Nu,cx as Hp,cy as Gp,aA as Wa,cz as qp,cA as Au,cB as pr,cC as Pu,cD as Yp,l as Lt,s as Qp,cE as Xp,cF as Jp,aO as Pn,cG as Zp,cH as dr,O as Du,cI as eg,cJ as tg,cK as Dn,cL as sg,cM as ng,aD as rg,cN as Ci,cO as og,cP as ig,cQ as ag,cR as Iu,cS as lg,cT as Ka,cU as cg,cV as Tu,cW as dg,aI as Ji,cX as Zi,cY as Ml,cZ as ug,c_ as Ol,c$ as Or,c as Hr,d as Va,a4 as fg,a1 as Eu,d0 as Pr,d1 as Br,d2 as mg,d3 as hg,d4 as pg,$ as Ua,aC as gg,d5 as xg,d6 as bg,d7 as yg,d8 as wg,d9 as Ru,da as Qs,db as vg,dc as Mu,dd as Sg,a8 as ea,de as jg,df as Ou,dg as ss,dh as kg,di as Cg,dj as Ng,dk as Bu,dl as Ag,dm as Ha,dn as Fu,a6 as Bo,dp as ta,dq as Zo,a as Ga,dr as qa,a5 as Pg,ds as Bl,P as Fo,U as ei,V as ti,W as si,dt as Dg,du as sa,dv as Lu,dw as Ig,dx as Tg,au as _u,dy as Eg,dz as Ya,L as Rg,dA as Fl,dB as Mg,dC as Og,dD as Ut,dE as Bg,dF as Yn,dG as $u,dH as zu,dI as Wu,dJ as Ku,dK as Fg,E as Lg,dL as _g,dM as $g,dN as zg,dO as Ll,dP as Vu,dQ as Wg,dR as Uu,F as Kg,dS as Vg,dT as Ug,dU as Hg,dV as $r,dW as Gg,dX as qg,dY as Yg,dZ as Qg,e as Qa,d_ as ni,d$ as Xg,e0 as Gr,a3 as Jg,G as ri,e1 as Zg,e2 as ex,e3 as _l,e4 as tx,e5 as sx,a0 as nx,e6 as rx,e7 as ox,a$ as $l,ab as zl,aa as Wl,e8 as ix,aW as na,e9 as ax,M as lx,N as Ni,ea as cx,eb as dx,ec as Hu,ed as Gu,ee as qu,ef as ux,eg as fx,a7 as mx,am as hx,eh as px,ei as Kl,ej as gx,ek as xx,el as bx,em as yx,en as Lo,eo as wx,ep as Vl,eq as vx,er as Sx,es as jx,et as kx,eu as ra,ev as Cx,ew as No,ex as Nx,i as Ax,ey as Px,ez as Dx,eA as Ix,eB as Tx,eC as Ex,eD as Rx,eE as Ul,eF as Mx,aP as Ox,aQ as Bx,aS as Fx,aR as Lx,aU as Hl,aV as Gl,aY as ql,aZ as Yl,aX as Yu,a_ as Qu,eG as _x,bc as $x,bd as zx,be as Wx,bf as Kx,bg as Vx,b6 as Ux,b8 as Hx,b9 as Gx,ba as qx,bb as Yx}from"./useAppFontEffects-BN06mgHB.js";import{u as Xu,S as Ql,C as Qx,t as Xx,W as Ju,f as Jx,G as Zx,a as eb}from"./useRootScrollLock-Chk1cFUw.js";import{u as On,O as Xl,D as tb,a as sb,b as nb,f as rb,c as Jl,s as ob,d as ib,e as ab,r as lb}from"./scheduledTasksApi-Dahv3ws0.js";import{f as oi,h as fn,T as ii,M as ai,D as li,j as ci,d as cb,b as db,k as ub,i as fb}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as di,S as Xa,h as mb,a as Zu,v as ef,s as hb}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ui}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as tf,M as sf,C as nf,a as oa,b as ia,c as aa,d as rf,e as pb,f as gb}from"./vendor-base-ui-CsXYnR5c.js";import{c as Zr,u as Qn,d as xb,p as bb}from"./vendor-zustand-BAGL70zf.js";import{g as yb,a as wb,E as of,b as vb,c as Sb,d as jb,e as kb,i as Cb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as Nb}from"./PluginPane-DPWPLc2f.js";import{a as Ja,s as Xn,r as af,o as Zl,b as ec}from"./vendor-zod-BSoePkpP.js";import{u as Ab}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as Pb}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as lf}from"./vendor-cron-parser-CjvYVigk.js";const Db="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",Ib="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",Ai=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Db:t.id==="terminal"?Ib:void 0}),tc=t=>{const e=Ze.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let x;return e[3]!==u?(x=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=x):x=e[4],x}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Me("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:h,children:d}),e[6]=d,e[7]=f):f=e[7],f},Tb=t=>{const e=Ze.c(75),{directory:n,className:r}=t,{t:i}=St(),o=On(Eb),l=On(Rb),a=On(Mb),d=On(Ob),u=On(Bb),h=On(Fb),f=On(Lb);let p,x;e[0]!==u?(p=()=>{u()},x=[u],e[0]=u,e[1]=p,e[2]=x):(p=e[1],x=e[2]),c.useEffect(p,x);const b=en()&&Qo();let k;e:{let ve;e[3]!==l||e[4]!==o?(ve=l.find(U=>U.id===o)??l.find(_b)??l[0]??Xl[0],e[3]=l,e[4]=o,e[5]=ve):ve=e[5];const pe=ve;if(pe){let U;e[6]!==pe?(U=Ai(pe),e[6]=pe,e[7]=U):U=e[7],k=U;break e}let Ne;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ne=Ai(Xl[0]),e[8]=Ne):Ne=e[8],k=Ne}const y=k;if(!b||!n||l.length===0)return null;let m;e[9]!==n?(m=async ve=>{await Ym(n,ve.id,ve.appName)||await Qm(n,ve.appName)},e[9]=n,e[10]=m):m=e[10];const g=m;let j;e[11]!==g||e[12]!==f?(j=async ve=>{await f(ve.id),await g(ve)},e[11]=g,e[12]=f,e[13]=j):j=e[13];const S=j;let w;e[14]!==n||e[15]!==i?(w=async()=>{(await Jn(n)).ok&&ze.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=w):w=e[16];const C=w;let v;e[17]!==r?(v=Me("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=v):v=e[18];let R;e[19]!==g||e[20]!==y?(R=()=>{g(y)},e[19]=g,e[20]=y,e[21]=R):R=e[21];const T=d&&"animate-pulse";let D;e[22]!==T?(D=Me("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",T),e[22]=T,e[23]=D):D=e[23];let F;e[24]!==y.label||e[25]!==i?(F=i("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=i,e[26]=F):F=e[26];let B;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(B=s.jsx(tc,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=B):B=e[30];let E;e[31]!==D||e[32]!==F||e[33]!==B||e[34]!==R?(E=s.jsx("button",{type:"button",onClick:R,className:D,"aria-label":F,children:B}),e[31]=D,e[32]=F,e[33]=B,e[34]=R,e[35]=E):E=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=Me("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=$):$=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let X;e[39]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=X):X=e[39];let Y;e[40]!==L?(Y=s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:$,"aria-label":L,children:X})}),e[40]=L,e[41]=Y):Y=e[41];let I;e[42]!==C?(I=()=>{C()},e[42]=C,e[43]=I):I=e[43];let P;e[44]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(O,{name:"file-copy",className:"h-4 w-4"}),e[44]=P):P=e[44];let A;e[45]!==i?(A=i("openInApp.actions.copyPath"),e[45]=i,e[46]=A):A=e[46];let q;e[47]!==A?(q=s.jsx("span",{className:"typography-ui-label text-foreground",children:A}),e[47]=A,e[48]=q):q=e[48];let K;e[49]!==I||e[50]!==q?(K=s.jsxs(_t,{className:"flex items-center gap-2",onClick:I,children:[P,q]}),e[49]=I,e[50]=q,e[51]=K):K=e[51];let te;e[52]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(gs,{}),e[52]=te):te=e[52];let ae;if(e[53]!==l||e[54]!==S||e[55]!==y.id){let ve;e[57]!==S||e[58]!==y.id?(ve=pe=>{const Ne=Ai(pe);return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{S(pe)},children:[s.jsx(tc,{label:pe.label,iconDataUrl:pe.iconDataUrl,fallbackIconDataUrl:Ne.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:pe.label}),y.id===pe.id?s.jsx(O,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},pe.id)},e[57]=S,e[58]=y.id,e[59]=ve):ve=e[59],ae=l.map(ve),e[53]=l,e[54]=S,e[55]=y.id,e[56]=ae}else ae=e[56];let re;e[60]!==a||e[61]!==h||e[62]!==i?(re=a?s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(O,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=re):re=e[63];let he;e[64]!==K||e[65]!==ae||e[66]!==re?(he=s.jsxs(Ds,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[K,te,ae,re]}),e[64]=K,e[65]=ae,e[66]=re,e[67]=he):he=e[67];let ce;e[68]!==Y||e[69]!==he?(ce=s.jsxs(Is,{children:[Y,he]}),e[68]=Y,e[69]=he,e[70]=ce):ce=e[70];let Te;return e[71]!==E||e[72]!==ce||e[73]!==v?(Te=s.jsxs("div",{className:v,children:[E,ce]}),e[71]=E,e[72]=ce,e[73]=v,e[74]=Te):Te=e[74],Te};function Eb(t){return t.selectedAppId}function Rb(t){return t.availableApps}function Mb(t){return t.isCacheStale}function Ob(t){return t.isScanning}function Bb(t){return t.initialize}function Fb(t){return t.loadInstalledApps}function Lb(t){return t.selectApp}function _b(t){return t.id===tb}const _o=new Map,la=new Set,cf=()=>{for(const t of la)t()},Pi=(t,e)=>{const n=t.trim();n&&(e.length===0?_o.delete(n):_o.set(n,[...e]),cf())},$b=t=>{_o.delete(t.trim())&&cf()},df=[],zb=t=>_o.get(t.trim())??df,Wb=t=>(la.add(t),()=>{la.delete(t)}),Kb=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=()=>zb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Wb,n,Vb)};function Vb(){return df}const Ub=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Hb=["dev","start","preview","serve"];async function Gb(t,e,n){if(!t)return null;const r=Qb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Xb(n);if(i){const o=await Jb(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await qb(t)){const i=await Yb(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function qb(t){const e=`${t}/index.html`,n=await $o(e,t);return typeof n=="string"&&n.trim().length>0}async function Yb(){try{const t=await ls("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Qb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Hb.some(i=>n.includes(i)))return e}return null}function Xb(t){for(const{pattern:e}of Ub)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Jb(t){const e=await $o(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await $o(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function $o(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Fd()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ls(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Zb(t){try{const e=await $o(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const Ys="__openchamber_auto_discover_preview__",ey=15e3,ty=3e3,Di=t=>t.id===Ys?"scan-2":Th.find(n=>n.key===t.icon)?.Icon??"play",sy=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},ny=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=St(),{currentTheme:l}=Cn(),{terminal:a,runtime:d}=nn(),u=Zn(),{isMobile:h}=Nn(),f=c.useMemo(()=>en(),[]),p=Cl(se=>se.instances),x=Cl(se=>se.load),b=Ae(se=>se.terminalShell),k=Ae(se=>se.terminalLoginShells.includes(se.terminalShell)),y=Ae(se=>se.setSettingsPage),m=Ae(se=>se.setSettingsDialogOpen),g=Ae(se=>se.setSettingsProjectsSelectedId),j=Ae(se=>se.openContextPreview),S=Rt(se=>se.ensureDirectory),w=Rt(se=>se.reconcileServerSessions),C=Rt(se=>se.setTabLabel),v=Rt(se=>se.setTabIconKey),R=Rt(se=>se.setActiveTab),T=Rt(se=>se.setConnecting),D=Rt(se=>se.setTabSessionId),F=Rt(se=>se.setTabPurpose),B=Rt(se=>se.allocateActionExecution),E=Rt(se=>se.setTabLifecycle),$=Rt(se=>se.setTabPreviewUrl),L=Rt(se=>se.matchesActionExecution),X=Rt(se=>se.captureStartedActionMutationRevisions),[Y,I]=c.useState([]),P=c.useRef(null),[A,q]=c.useState(null),[K,te]=c.useState(!1),ae=c.useRef({}),re=c.useRef({}),he=c.useRef({}),ce=c.useRef(new Set),Te=c.useRef(0),[ve,pe]=c.useState({}),Ne=t?.id??null,U=t?.path??"",Z=c.useMemo(()=>Ne?{id:Ne,path:U}:null,[Ne,U]);c.useEffect(()=>{f&&x().catch(()=>{})},[f,x]);const de=c.useCallback(async se=>{await Qr(se)},[]),ye=c.useCallback(async()=>{if(!Z)return;const se=Te.current+1;Te.current=se,te(!0);try{const me=await Dl(Z);if(Te.current!==se)return;P.current=me;const Ie=me.projectActions;I(Ie),q(We=>We===Ys||We&&Ie.some(V=>V.id===We)?We:null)}catch{if(Te.current!==se)return}finally{Te.current===se&&te(!1)}},[Z]),H=c.useMemo(()=>Si(e||Z?.path||""),[e,Z?.path]),je=c.useMemo(()=>Si(Z?.path||""),[Z?.path]),Ee=c.useMemo(()=>Si(u||"")||H,[u,H]),ge=c.useRef(Ee);c.useEffect(()=>{ge.current=Ee},[Ee]);const ne=Rt(se=>H?se.getDirectoryState(H):void 0),be=Rt(se=>je&&je!==H?se.getDirectoryState(je):void 0),G=c.useMemo(()=>{const se=H?[{directory:H,state:ne}]:[];return je&&je!==H&&se.push({directory:je,state:be}),se},[ne,H,je,be]),z=c.useMemo(()=>{const se=H?[H]:[];return je&&je!==H&&se.push(je),se},[H,je]),J=c.useCallback(se=>se.id!==Ys&&se.runIn==="parent"&&je||H,[H,je]),ue=c.useCallback((se,me,Ie)=>`${se}::${me}::${Ie}`,[]),le=c.useCallback((se,me,Ie=Rt.getState())=>se?Ie.getDirectoryState(se)?.tabs.find(We=>We.purpose.type==="project-action"&&We.purpose.actionId===me)??null:null,[]),W=c.useMemo(()=>{const se={};for(const{directory:me,state:Ie}of G)for(const We of Ie?.tabs??[]){if(We.purpose.type!=="project-action"||!We.purpose.executionId||!We.terminalSessionId||We.lifecycle==="idle"||We.lifecycle==="exited")continue;const V=Gs(me,We.purpose.actionId),Fe=ue(me,We.purpose.actionId,We.purpose.executionId);se[V]={directory:me,actionId:We.purpose.actionId,tabId:We.id,sessionId:We.terminalSessionId,executionId:We.purpose.executionId,status:We.lifecycle==="stopping"?"stopping":ve[Fe]?"waiting-for-preview":"running"}}return se},[ue,ve,G]),M=c.useCallback((se,me,Ie)=>{const We=Gs(se,me),V=ue(se,me,Ie),Ye=ae.current[We]?.executionId===Ie,Qe=globalThis.window,xe=st=>{Qe?.clearTimeout(he.current[st]),delete he.current[st]};Ye&&(delete ae.current[We],xe(We)),re.current[V]?.(),delete re.current[V],xe(V),pe(st=>{if(!st[V])return st;const Re={...st};return delete Re[V],Re})},[ue]),_=c.useCallback(se=>{re.current[se]?.(),delete re.current[se]},[]),ee=c.useCallback(se=>{window.clearTimeout(he.current[se]),delete he.current[se]},[]);c.useEffect(()=>{const se=re.current,me=he.current;return()=>{for(const Ie of Object.keys(se))_(Ie);for(const Ie of Object.keys(me))ee(Ie)}},[ee,_]),c.useEffect(()=>{const se=new Set(z);for(const me of Object.values(ae.current))se.has(me.directory)||M(me.directory,me.actionId,me.executionId);for(const me of Object.keys(re.current)){const Ie=me.split("::",1)[0]??"";se.has(Ie)||_(me)}},[M,_,z]);const oe=c.useCallback((se,me)=>{Ae.getState().openContextPanelTab(se,{mode:"terminal",targetDirectory:me===se?null:me})},[]),fe=c.useMemo(()=>A?Y.find(se=>se.id===A)??null:null,[Y,A]),ie=c.useMemo(()=>({id:Ys,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Le=!h,$e=c.useMemo(()=>Le?[ie,...Y]:Y,[Y,ie,Le]);c.useEffect(()=>{ye()},[ye]),c.useEffect(()=>{const se=z.map(me=>Vi(a,me,X,Ie=>w(me,Ie.sessions,{startedActionMutationRevisions:Ie.startedActionMutationRevisions})));return()=>{for(const me of se)me()}},[X,w,a,z]),c.useEffect(()=>{for(const{directory:se,state:me}of G)if(se)for(const Ie of me?.tabs??[]){if(Ie.purpose.type!=="project-action")continue;const We=Ie.purpose.actionId,V=$e.find(Qe=>Qe.id===We),Fe=V?.name??We,Ye=V?.icon||"play";Ie.label!==Fe&&C(se,Ie.id,Fe),Ie.iconKey!==Ye&&v(se,Ie.id,Ye)}},[$e,v,C,G]),c.useEffect(()=>{const se=globalThis.window;if(!se)return;const me=Ie=>{const We=Ie.detail;Ne&&(We?.projectId&&We.projectId!==Ne||ye())};return se.addEventListener(Nl,me),()=>{se.removeEventListener(Nl,me)}},[ye,Ne]),c.useEffect(()=>{A&&(A===Ys&&Le||Y.some(se=>se.id===A)||q(null))},[Y,Le,A]),c.useEffect(()=>{const se=Ie=>{delete he.current[Ie];const We=ae.current[Ie];if(!We||We.openedUrl)return;const V=ue(We.directory,We.actionId,We.executionId),Fe=We.announced;if(Fe.length!==0){if(window.clearTimeout(he.current[V]),delete he.current[V],We.openedUrl=!0,pe(Ye=>{if(!Ye[V])return Ye;const Qe={...Ye};return delete Qe[V],Qe}),Fe.length===1){Pi(We.directory,[]),$(We.directory,We.tabId,Fe[0],{locked:!1,autoOpened:!0}),j(We.directory,Fe[0]);return}We.offering=!0,Pi(We.directory,Fe),Ae.getState().openContextSurface(We.directory,"browser"),ze.info(o("projectActions.toast.multipleServers"))}},me=()=>{const Ie=Rt.getState(),We=Ie.sessions,V=W;for(const[Fe,Ye]of Object.entries(V)){const xe=We.get(Ye.directory)?.tabs.find(lt=>lt.id===Ye.tabId);if(!xe||xe.terminalSessionId!==Ye.sessionId){M(Ye.directory,Ye.actionId,Ye.executionId);continue}const st=ae.current[Fe],Re=st?.executionId===Ye.executionId?st:{hostDirectory:ge.current||Ye.directory,directory:Ye.directory,tabId:Ye.tabId,actionId:Ye.actionId,executionId:Ye.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ae.current[Fe]=Re;const ot=$e.find(lt=>lt.id===Ye.actionId),vt=Ie.getBuffer(Ye.directory,Ye.tabId).chunks;if(!ot||vt.length===0)continue;const De=vt.filter(lt=>Re.lastSeenChunkId===null||lt.id>Re.lastSeenChunkId);if(De.length===0)continue;const gt=De.map(lt=>lt.data).join(""),Ct=`${Re.tail}${gt}`;if(Re.openInPreview&&(!Re.openedUrl||Re.offering)){const lt=Dh(Ct),_e=Re.announced.length;for(const Je of lt)Re.announced.includes(Je)||Re.announced.push(Je);const Ge=Re.announced.length-_e;Re.offering&&Ge>0?Pi(Ye.directory,Re.announced):!Re.openedUrl&&_e===0&&Re.announced.length>0&&(window.clearTimeout(he.current[Fe]),he.current[Fe]=window.setTimeout(()=>se(Fe),ty))}const He=!Re.openedUrl&&ot.autoOpenUrl===!0&&!Re.openInPreview?Ih(Ct):null,Ue=De[De.length-1]?.id??Re.lastSeenChunkId;if(Re.lastSeenChunkId=Ue,Re.tail=Ct.slice(-512),He)if(Re.openedUrl=!0,Re.openInPreview){const lt=V[Fe];lt&&($(lt.directory,lt.tabId,He,{locked:!1,autoOpened:!1,expectedExecutionId:lt.executionId}),lt.status==="waiting-for-preview"&&pe(_e=>{const Ge=ue(lt.directory,lt.actionId,lt.executionId);if(!_e[Ge])return _e;const Je={..._e};return delete Je[Ge],Je}),window.clearTimeout(he.current[Fe]),delete he.current[Fe],j(lt.directory,He))}else de(He),ze.success(o("projectActions.toast.openedUrlFromOutput"));ae.current[Fe]=Re}for(const Fe of Object.keys(ae.current))if(!V[Fe]){const Ye=ae.current[Fe],Qe=Ye?We.get(Ye.directory)?.tabs.find(st=>st.id===Ye.tabId):void 0;if(Qe?.purpose.type==="project-action"&&Qe.purpose.executionId===Ye?.executionId&&!!Qe.terminalSessionId&&Qe.lifecycle!=="idle"&&Qe.lifecycle!=="exited")continue;delete ae.current[Fe],window.clearTimeout(he.current[Fe]),delete he.current[Fe]}};return me(),Rt.subscribe((Ie,We)=>{(Ie.sessions!==We.sessions||Ie.buffers!==We.buffers)&&me()})},[M,ge,$e,ue,j,de,W,$,o]),c.useEffect(()=>{for(const{directory:se,state:me}of G)for(const Ie of me?.tabs??[]){if(Ie.purpose.type!=="project-action"||!Ie.purpose.executionId||!Ie.terminalSessionId||Ie.lifecycle!=="running")continue;const We=Ie.purpose.actionId,V=Ie.purpose.executionId,Fe=ue(se,We,V);if(re.current[Fe])continue;const Ye=a.connect(Ie.terminalSessionId,{onEvent:Qe=>{if(!L(se,Ie.id,V))return;Qe.type==="snapshot"&&(Rt.getState().replaceBuffer(se,Ie.id,Qe.data??"",Qe.sequence??0,xl(Qe)),Qe.status==="running"&&Rt.getState().setTabLifecycle(se,Ie.id,"running",{expectedExecutionId:V}),Qe.status==="exited"&&(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V)));const xe=Qe.type==="data"?Qe.data??"":"";xe&&Rt.getState().appendToBuffer(se,Ie.id,xe,Qe.sequence,Qe.replayData),Qe.type==="exit"&&(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V))},onError:(Qe,xe)=>{!xe||!L(se,Ie.id,V)||(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabSessionId(se,Ie.id,null,{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V))}},se);re.current[Fe]=Ye.close}},[M,ue,L,a,G]);const Pe=c.useCallback(async se=>{const me=J(se);if(!me)throw new Error(o("projectActions.error.noActiveDirectory"));const Ie=Gs(me,se.id);S(me);const We=Rt.getState(),V=le(me,se.id,We),Fe=V?.id??We.createTab(me);C(me,Fe,se.name),v(me,Fe,se.icon||"play"),V||F(me,Fe,{type:"project-action",actionId:se.id,executionId:null}),R(me,Fe);const Qe=Rt.getState().getDirectoryState(me)?.tabs.find(xe=>xe.id===Fe);return{executionDirectory:me,key:Ie,tabId:Fe,sessionId:Qe?.terminalSessionId??null,executionId:Qe?.purpose.type==="project-action"?Qe.purpose.executionId:null}},[S,J,le,R,v,C,F,o]),Oe=c.useCallback(async se=>{if(d.isVSCode||!i&&h)return;if(!H){ze.error(o("projectActions.error.noActiveDirectoryForAction"));return}const me=Gs(J(se),se.id),Ie=W[me];if(Ie&&Ie.status==="running"||ce.current.has(me))return;ce.current.add(me);let We=null;try{const V=se.id===Ys?await(async()=>{const[Ge,Je]=await Promise.all([gp({id:Z?.id??"",path:H}),Zb(H)]),at=await Gb(H,Ge.actions,Je);if(!at)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Ys,name:o("projectActions.actions.autoDiscover"),command:at.command,icon:"scan-2",autoOpenUrl:!0,openUrl:at.previewUrlHint||""}})():se,Fe=V.autoOpenUrl===!0&&(V.openUrl||"").trim().length>0,Ye=!Fe&&se.id!==Ys,Qe=ge.current||H,{executionDirectory:xe,key:st,tabId:Re}=await Pe(V),ot=kh(V.command);if(!ot)throw new Error(o("projectActions.error.failedToRunAction"));const vt=V.autoOpenUrl===!0&&f&&(V.desktopOpenSshForward||"").trim().length>0,De=V.autoOpenUrl?sy(V.openUrl):null,gt=V.autoOpenUrl&&f?Ch(V.desktopOpenSshForward,p):null;if(a.listSessions){const Ge=le(xe,V.id);if(Ge?.purpose.type==="project-action"&&Ge.purpose.executionId===null){const Je=await Nh(a,xe,{captureStartedActionMutationRevisions:X});Je&&w(xe,Je.sessions,{startedActionMutationRevisions:Je.startedActionMutationRevisions})}}const Ct=le(xe,V.id);let He,Ue;if(Ct?.lifecycle==="running"&&Ct.terminalSessionId&&Ct.purpose.type==="project-action"&&Ct.purpose.executionId)He=Ct.terminalSessionId,Ue=Ct.purpose.executionId;else{const Ge=Ct?.purpose.type==="project-action"?Ct.purpose.executionId:null;Ge&&M(xe,V.id,Ge);const Je=B(xe,Re,V.id);if(!Je)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));We={directory:xe,tabId:Re,id:Je},T(xe,Re,!0,{expectedExecutionId:Je});const at=await Ah({terminal:a,createOptions:{cwd:xe,shell:b,loginShell:k,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:ot,isRunStillExpected:()=>L(xe,Re,Je),purpose:{type:"project-action",actionId:V.id,executionId:Je}});if(!L(xe,Re,Je)){at.sessionId===Je&&await a.close(at.sessionId).catch(()=>{});return}Ue=at.purpose?.type==="project-action"?at.purpose.executionId:Je,He=at.sessionId,F(xe,Re,{type:"project-action",actionId:V.id,executionId:Ue}),D(xe,Re,He,{expectedExecutionId:Ue}),T(xe,Re,!1,{expectedExecutionId:Ue})}Ye&&Qe&&oe(Qe,xe),ae.current[st]={hostDirectory:Qe,directory:xe,tabId:Re,actionId:V.id,executionId:Ue,lastSeenChunkId:null,openedUrl:!!gt||!!De||Fe,tail:"",openInPreview:V.id===Ys,announced:[],offering:!1};const lt=ue(xe,V.id,Ue);T(xe,Re,!0,{expectedExecutionId:Ue});const _e=a.connect(He,{onEvent:Ge=>{if(!L(xe,Re,Ue)||Ge.purpose?.type==="project-action"&&Ge.purpose.executionId!==Ue)return;Ge.type==="snapshot"&&(Rt.getState().replaceBuffer(xe,Re,Ge.data??"",Ge.sequence??0,xl(Ge)),Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Ge.purpose?.type==="project-action"&&Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:Ge.purpose.actionId,executionId:Ge.purpose.executionId}),Ge.status==="running"&&Rt.getState().setTabLifecycle(xe,Re,"running",{expectedExecutionId:Ue}),Ge.status==="exited"&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue)));const Je=Ge.type==="data"?Ge.data??"":"";Je&&Rt.getState().appendToBuffer(xe,Re,Je,Ge.sequence,Ge.replayData),Ge.type==="exit"&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue))},onError:(Ge,Je)=>{L(xe,Re,Ue)&&(Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Je&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setTabSessionId(xe,Re,null,{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue)))}},xe);if(!L(xe,Re,Ue)){_e.close();return}re.current[lt]?.(),re.current[lt]=_e.close,window.clearTimeout(he.current[lt]),delete he.current[lt],V.id===Ys&&!De&&(pe(Ge=>({...Ge,[lt]:!0})),he.current[lt]=window.setTimeout(()=>{delete he.current[lt];const Ge=ae.current[st];!Ge||Ge.executionId!==Ue||Ge.openedUrl||Ge.offering||L(xe,Re,Ue)&&(pe(Je=>{if(!Je[lt])return Je;const at={...Je};return delete at[lt],at}),Rt.getState().setActiveTab(xe,Re),oe(Ge.hostDirectory,xe))},ey)),gt?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),de(gt),ze.success(o("projectActions.toast.openedForwardedUrl"))):De?($(xe,Re,De,{locked:!0,autoOpened:!0,expectedExecutionId:Ue}),j(Qe,De),ze.success(o("projectActions.toast.openedActionUrl"))):Fe?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),ze.error(o("projectActions.error.invalidCustomUrlFormat"))):vt?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),ze.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(xe,Re,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ue})}catch(V){if(We&&L(We.directory,We.tabId,We.id)){const{directory:Fe,tabId:Ye,id:Qe}=We;M(Fe,se.id,Qe),E(Fe,Ye,"exited",{expectedExecutionId:Qe}),F(Fe,Ye,{type:"project-action",actionId:se.id,executionId:null})}if(V instanceof Error&&V.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(V instanceof Error&&(V.message==="COMMAND_MODE_UNSUPPORTED"||V.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){ze.error(o("projectActions.error.failedToCreateTerminalSession"));return}ze.error(V instanceof Error?V.message:o("projectActions.error.failedToRunAction"))}finally{ce.current.delete(me)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,ge,p,Pe,i,h,f,H,k,b,de,j,W,oe,d.isVSCode,J,L,M,ue,le,w,B,X,T,E,F,$,D,Z?.id,o,a]),Q=c.useCallback(async se=>{const me=Gs(J(se),se.id),Ie=W[me];Ie&&await Ph({terminal:a,sessionId:Ie.sessionId,isExecutionStillCurrent:()=>L(Ie.directory,Ie.tabId,Ie.executionId),markStopping:()=>{E(Ie.directory,Ie.tabId,"stopping",{expectedExecutionId:Ie.executionId})},restoreRunning:()=>{E(Ie.directory,Ie.tabId,"running",{expectedExecutionId:Ie.executionId})},clearSession:()=>{D(Ie.directory,Ie.tabId,null,{expectedExecutionId:Ie.executionId})},finalizeExit:()=>{E(Ie.directory,Ie.tabId,"exited",{expectedExecutionId:Ie.executionId}),F(Ie.directory,Ie.tabId,{type:"project-action",actionId:Ie.actionId,executionId:null}),M(Ie.directory,Ie.actionId,Ie.executionId)}})},[M,J,L,W,E,F,D,a]),Ce=c.useCallback(()=>{const se=fe??$e[0];if(!se)return;const me=Gs(J(se),se.id),Ie=W[me];if(Ie?.status!=="stopping"){if(Ie){Q(se);return}Oe(se)}},[$e,J,Oe,W,fe,Q]),Se=c.useCallback(async se=>{if(se.source==="shared"&&Z){const me=P.current?.trust.trusted?P.current:await Dl(Z);if(P.current=me,!await xp(Z,me))return;P.current={...me,trust:{...me.trust,trusted:!0}}}await Oe(se)},[Oe,Z]),Ke=c.useCallback((se,me=!1)=>{if(q(se.id),!me){Se(se);return}const Ie=Gs(J(se),se.id),We=W[Ie];if(We?.status!=="stopping"){if(We){Q(se);return}Se(se)}},[J,Se,W,Q]),et=c.useCallback(()=>{Z?.id&&(g(Z.id),y("projects"),m(!0))},[m,y,g,Z?.id]),it=fe??$e[0]??null,rt=it?W[Gs(J(it),it.id)]:null,pt=Rt(se=>rt?se.getDirectoryState(rt.directory)?.tabs.find(me=>me.id===rt.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&h||!Z||!H)return null;const ht=fe??$e[0]??null;if(!ht)return null;const tt=Di(ht),At=Gs(J(ht),ht.id),jt=W[At],we=jt?.status==="stopping",Xe=jt?.status==="waiting-for-preview",mt=!!(jt&&pt),qe=()=>{!jt||!pt||j(jt.directory,pt)},ft=ht.id===Ys;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:K||we,className:Me("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:Ce,"aria-label":jt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:we||Xe?s.jsx(O,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):jt?s.jsx(O,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(O,{name:tt,className:"h-5 w-5"})})}),ft?s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),mt?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:qe,children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ds,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:et,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(gs,{}),$e.map(se=>{const me=Di(se),Ie=Gs(J(se),se.id),We=W[Ie],V=!!We,Fe=We?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ke(se,!0)},children:[s.jsx(O,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:se.name}),se.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||We?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},se.id)})]})]})]}):s.jsxs("div",{className:Me("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ce,disabled:K||we,className:Me("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":jt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:we||Xe?s.jsx(O,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):jt?s.jsx(O,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(O,{name:tt,className:"h-4 w-4"})})})}),ft?s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),mt?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:qe,className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ds,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:et,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(gs,{}),$e.map(se=>{const me=Di(se),Ie=Gs(J(se),se.id),We=W[Ie],V=!!We,Fe=We?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ke(se,!0)},children:[s.jsx(O,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:se.name}),se.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||We?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},se.id)})]})]})]})},Fr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ry=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Fr(n??"");if(i){const o=ou(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function oy(){const t=zt(b=>b.projects),e=zt(b=>b.activeProjectId),n=nt(b=>b.availableWorktreesByProject),r=nt(b=>b.currentSessionId),i=bp(r??null),o=nt(b=>r?b.worktreeMetadata.get(r)?.path??"":""),l=nt(b=>b.newSessionDraft?.open?Fr(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Fr(o||""),[o]),d=c.useMemo(()=>{const b=typeof i?.directory=="string"?i.directory:"";return Fr(b||"")},[i?.directory]),u=a||d||l,h=c.useMemo(()=>ry({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>Fr(u||h?.path||""),[u,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),x=c.useRef(null);return c.useEffect(()=>{p&&f&&(x.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:x.current,[p,f])}const iy=({transform:t})=>({...t,y:0}),ay={Item:_t,Separator:gs},ly={Item:({className:t,...e})=>s.jsx(sf,{className:Me(cu,t),...e}),Separator:({className:t,...e})=>s.jsx(tf,{className:Me(lu,t),...e})},cy=t=>{const e=Ze.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:h}=t,{t:f}=St(),[p,x]=c.useState(!1),[b,k]=c.useState(!1),[y,m]=c.useState(!1);let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:j,listeners:S,setNodeRef:w,transform:C,transition:v,isDragging:R}=di(g);let T;e[2]!==f||e[3]!==n.session.title?(T=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=T):T=e[4];const D=T,F=!i&&(p||b),B=n.id;let E;e[5]!==n.session?(E=xs(n.session),e[5]=n.session,e[6]=E):E=e[6];const $=Ma(B,E),L=iu(n.id),Y=au(n.id)>0&&!r&&!L,I=L||Y;let P;e[7]!==L||e[8]!==f?(P=f(L?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=L,e[8]=f,e[9]=P):P=e[9];const A=P;let q;e[10]!==d||e[11]!==y||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(q=je=>({session:n.session,open:p||y,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:je}),e[10]=d,e[11]=y,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=q):q=e[16];const K=q;let te;e[17]!==C?(te=ui.Translate.toString(C),e[17]=C,e[18]=te):te=e[18];let ae;e[19]!==te||e[20]!==v?(ae={transform:te,transition:v},e[19]=te,e[20]=v,e[21]=ae):ae=e[21];const re=R&&"z-10 opacity-60";let he;e[22]!==re?(he=Me("session-tab-slot flex h-7 w-44 shrink-0 touch-none",re),e[22]=re,e[23]=he):he=e[23];const ce=r?"true":"false";let Te;e[24]!==r?(Te=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Te):Te=e[25];let ve;e[26]!==u?(ve=je=>u?.(je),e[26]=u,e[27]=ve):ve=e[27];let pe;e[28]!==h||e[29]!==A||e[30]!==r||e[31]!==$||e[32]!==L||e[33]!==K||e[34]!==p||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==F||e[39]!==a||e[40]!==I||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==D?(pe=s.jsx(nf,{render:je=>s.jsxs("div",{...je,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),o(n))},onAuxClick:Ee=>{Ee.button===1&&(Ee.preventDefault(),l(n.id))},"data-controls-open":F?"true":"false",className:Me("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Me("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",F&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Me("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",F&&"pr-10"),children:[s.jsx("div",{className:Me("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:D})})}),$?s.jsx(O,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):I?s.jsx(Oa,{state:L?"running":"unread",label:A,className:Me("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",F&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:uy,onPointerDown:fy,className:Me("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",F&&"flex opacity-100"),children:[s.jsxs(Is,{open:p,onOpenChange:Ee=>{x(Ee),Ee&&k(!0)},onOpenChangeComplete:Ee=>{Ee||k(!1),u?.(Ee)},children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsx(Ds,{align:"start",className:"min-w-[190px]",children:a(K(ay))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=A,e[30]=r,e[31]=$,e[32]=L,e[33]=K,e[34]=p,e[35]=l,e[36]=u,e[37]=o,e[38]=F,e[39]=a,e[40]=I,e[41]=i,e[42]=f,e[43]=n,e[44]=D,e[45]=pe):pe=e[45];let Ne,U;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ne={color:"var(--surface-elevated-foreground)"},U=Me(Gi,"min-w-[190px]"),e[46]=Ne,e[47]=U):(Ne=e[46],U=e[47]);let Z;e[48]!==K||e[49]!==a?(Z=a(K(ly)),e[48]=K,e[49]=a,e[50]=Z):Z=e[50];let de;e[51]!==Z?(de=s.jsx(oa,{children:s.jsx(ia,{className:"app-region-no-drag z-50",children:s.jsx(aa,{"data-slot":"dropdown-menu-content",style:Ne,className:U,children:Z})})}),e[51]=Z,e[52]=de):de=e[52];let ye;e[53]!==y||e[54]!==ve||e[55]!==pe||e[56]!==de?(ye=s.jsxs(rf,{open:y,onOpenChange:m,onOpenChangeComplete:ve,children:[pe,de]}),e[53]=y,e[54]=ve,e[55]=pe,e[56]=de,e[57]=ye):ye=e[57];let H;return e[58]!==j||e[59]!==S||e[60]!==w||e[61]!==he||e[62]!==ce||e[63]!==Te||e[64]!==ye||e[65]!==ae?(H=s.jsx("div",{ref:w,style:ae,className:he,"data-active":ce,...Te,...j,...S,children:ye}),e[58]=j,e[59]=S,e[60]=w,e[61]=he,e[62]=ce,e[63]=Te,e[64]=ye,e[65]=ae,e[66]=H):H=e[66],H},dy=t=>{const e=Ze.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=St(),d=oo(my),u=oo(hy),h=oo(py),f=oo(gy),p=nt(xy),x=nt(by),b=us(yy);let k,y;e[0]!==p||e[1]!==u?(k=()=>{p&&u(p)},y=[p,u],e[0]=p,e[1]=u,e[2]=k,e[3]=y):(k=e[2],y=e[3]),c.useEffect(k,y);let m;if(e[4]!==b){m=new Map;for(const ge of b)m.set(ge.id,ge);e[4]=b,e[5]=m}else m=e[5];const g=m;let j;if(e[6]!==g||e[7]!==d){j=[];for(const ge of d){const ne=g.get(ge);ne&&j.push({id:ge,session:ne})}e[6]=g,e[7]=d,e[8]=j}else j=e[8];const S=j;let w;e[9]!==x?(w=ge=>{x(ge.id,xs(ge.session))},e[9]=x,e[10]=w):w=e[10];const C=w,v=wy;let R;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==S?(R=ge=>{if(h(ge),p&&p!==ge){const ne=S.find(be=>be.id===ge);ne&&C(ne)}},e[11]=h,e[12]=p,e[13]=C,e[14]=S,e[15]=R):R=e[15];const T=R;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{distance:8}},e[16]=D):D=e[16];let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{delay:200,tolerance:6}},e[17]=F):F=e[17];const B=oi(fn(ai,D),fn(ii,F));let E;e[18]!==f?(E=ge=>{const{active:ne,over:be}=ge;be&&ne.id!==be.id&&f(String(ne.id),String(be.id))},e[18]=f,e[19]=E):E=e[19];const $=E,L=c.useRef(null);let X;e[20]===Symbol.for("react.memo_cache_sentinel")?(X={left:!1,right:!1},e[20]=X):X=e[20];const[Y,I]=c.useState(X);let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const ge=L.current;if(!ge)return;const ne=ge.scrollLeft>2,be=ge.scrollLeft+ge.clientWidth<ge.scrollWidth-2;I(G=>G.left===ne&&G.right===be?G:{left:ne,right:be})},e[21]=P):P=e[21];const A=P;let q;e[22]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{A();const ge=L.current;if(!ge||!globalThis.ResizeObserver)return;const ne=new ResizeObserver(A);return ne.observe(ge),()=>ne.disconnect()},e[22]=q):q=e[22];let K;e[23]!==S.length?(K=[A,S.length],e[23]=S.length,e[24]=K):K=e[24],c.useEffect(q,K);let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=te):te=e[25];let ae;e[26]!==p?(ae=[p],e[26]=p,e[27]=ae):ae=e[27],c.useEffect(te,ae);const re=Y.left&&Y.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":Y.left?"linear-gradient(to right, transparent, black 24px)":Y.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let he;e[28]!==S?(he=S.map(vy),e[28]=S,e[29]=he):he=e[29];const ce=he;let Te;e[30]!==p||e[31]!==S?(Te=!p||!S.some(ge=>ge.id===p),e[30]=p,e[31]=S,e[32]=Te):Te=e[32];const ve=Te;let pe;e[33]!==a?(pe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=pe):pe=e[34];let Ne;e[35]!==re?(Ne=re?{maskImage:re,WebkitMaskImage:re}:void 0,e[35]=re,e[36]=Ne):Ne=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=[iy],e[37]=U):U=e[37];let Z;e[38]!==o||e[39]!==p||e[40]!==T||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==S?(Z=S.map(ge=>s.jsx(cy,{tab:ge,isActive:ge.id===p,suppressControls:ge.id===p&&l,onSelect:C,onClose:v,renderMenu:n,closeOtherTabs:T,onMenuOpenChangeComplete:r,children:ge.id===p?o:null},ge.id)),e[38]=o,e[39]=p,e[40]=T,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=S,e[46]=Z):Z=e[46];let de;e[47]!==Z||e[48]!==ce?(de=s.jsx(Xa,{items:ce,strategy:mb,children:Z}),e[47]=Z,e[48]=ce,e[49]=de):de=e[49];let ye;e[50]!==$||e[51]!==B||e[52]!==de?(ye=s.jsx(li,{sensors:B,collisionDetection:ci,modifiers:U,onDragEnd:$,children:de}),e[50]=$,e[51]=B,e[52]=de,e[53]=ye):ye=e[53];let H;e[54]!==o||e[55]!==ve?(H=ve?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=ve,e[56]=H):H=e[56];let je;e[57]!==Ne||e[58]!==ye||e[59]!==H?(je=s.jsxs("div",{ref:L,onScroll:A,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ne,children:[ye,H]}),e[57]=Ne,e[58]=ye,e[59]=H,e[60]=je):je=e[60];let Ee;return e[61]!==pe||e[62]!==je?(Ee=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":pe,children:je}),e[61]=pe,e[62]=je,e[63]=Ee):Ee=e[63],Ee};function uy(t){return t.stopPropagation()}function fy(t){return t.stopPropagation()}function my(t){return t.tabIds}function hy(t){return t.ensureTab}function py(t){return t.closeOtherTabs}function gy(t){return t.reorderTabs}function xy(t){return t.currentSessionId}function by(t){return t.setCurrentSession}function yy(t){return t.activeSessions}function wy(t){yp(t)}function vy(t){return t.id}const uf=async t=>{const{entry:e,session:n}=t,r=Wt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(wp(e.action)&&vp(e.guest,"conversation"))){await Il(e,Tl(e.action.id,i),t.t,r);return}let l=!1;const a=vr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Il(e,Tl(e.action.id,i,d),t.t,r)}};function ca(t){const e=Ze.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=St(),{pending:a,disabled:d,hint:u,run:h}=Eh(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let x;e[0]!==f||e[1]!==p?(x=s.jsx(O,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=x):x=e[2];let b;e[3]!==l?(b=l("sessions.aiRename.action"),e[3]=l,e[4]=b):b=e[4];let k;e[5]!==o||e[6]!==d||e[7]!==h||e[8]!==x||e[9]!==b?(k=s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:h,className:"w-full",children:[x,b]})})}),e[5]=o,e[6]=d,e[7]=h,e[8]=x,e[9]=b,e[10]=k):k=e[10];let y;e[11]!==u?(y=s.jsx(wt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let m;return e[13]!==k||e[14]!==y?(m=s.jsxs(bt,{children:[k,y]}),e[13]=k,e[14]=y,e[15]=m):m=e[15],m}const da=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class ff extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const fi=Zr(()=>({pendingSessionIds:new Set})),mf=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],fi(n)},sc=(t,e)=>{fi.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},Sy=async(t,e)=>{try{const d=(await Ap(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=xt(t),r=xt(e)??e,i=nt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>xt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},nc=t=>{for(const e of t){const n=jp(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class jy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const ky=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new jy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},Cy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(kp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await du(o,n,e),nt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},rc=async(t,e,n)=>{try{await fu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},oc=async(t,e)=>{const n=e?[t,e]:[t];try{await Ba(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},hf=async(t,e)=>{if(fi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");sc(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,nt.getState().getWorktreeMetadata(a.id)]));nc(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){nc(n.slice(a));try{await du(d,t.sourceDirectory,i.directory)}catch(u){throw Sp(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&nt.getState().setWorktreeMetadata(d.id,El(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await Cy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await oc(t.sourceDirectory,i?.directory),u.length>0)throw ky(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new ff(d):d}return nt.getState().setWorktreeMetadata(t.root.id,El(i.metadata)),await oc(t.sourceDirectory,i.directory),i.directory}finally{sc(t.root.id,!1)}},Ny=async t=>{const e=xt(t.sourceDirectory)??t.sourceDirectory,n=xt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return hf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Ay=async t=>hf(t,async()=>{const e=qi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await uu(t.sourceDirectory)?await Sy(t.sourceDirectory,e.path):null,r=await Cp(e,n?{startRef:n}:{});try{await Np(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return rc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>rc(e,r,i)}}),Py=t=>{(t.kind==="existing"?Ny({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):Ay({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>ze.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));ze.error(t.messages.failure,{description:r instanceof ff?t.messages.outcomeUnknown:r.message})})},ua=t=>{fi.getState().pendingSessionIds.has(t.root.id)||Py(t)},zo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",Dy=c.memo(function(e){const n=Ze.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:h}=e,f=r===void 0?!0:r,p=h===void 0?!1:h;if(!f)return null;const x=a??zo,b=p&&"bg-interactive-selection text-interactive-selection-foreground";let k;n[0]!==x||n[1]!==b?(k=Me(x,b),n[0]=x,n[1]=b,n[2]=k):k=n[2];const y=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==y?(m=s.jsx(O,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=m):m=n[5];let g;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==k||n[10]!==m?(g=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:k,children:m})}),n[6]=o,n[7]=l,n[8]=p,n[9]=k,n[10]=m,n[11]=g):g=n[11];let j;n[12]!==i?(j=s.jsx(wt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=j):j=n[13];let S;return n[14]!==g||n[15]!==j?(S=s.jsxs(bt,{children:[g,j]}),n[14]=g,n[15]=j,n[16]=S):S=n[16],S}),Iy=c.memo(function(e){const n=Ze.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:x}=e,{t:b}=St();let k;n[0]!==d||n[1]!==a?(k=B=>{a(B),B&&d()},n[0]=d,n[1]=a,n[2]=k):k=n[2];let y;n[3]!==i||n[4]!==r||n[5]!==b?(y=r?b("header.services.openWithCurrent",{current:i}):b("header.services.open"),n[3]=i,n[4]=r,n[5]=b,n[6]=y):y=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let g;n[7]!==m?(g=Me(zo,m),n[7]=m,n[8]=g):g=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(O,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let w;n[13]!==y||n[14]!==g||n[15]!==S?(w=s.jsx(yt,{asChild:!0,children:s.jsx(Ps,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":y,className:g,children:[j,S]})})}),n[13]=y,n[14]=g,n[15]=S,n[16]=w):w=n[16];let C;n[17]!==i||n[18]!==u||n[19]!==b?(C=b("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=b,n[20]=C):C=n[20];let v;n[21]!==C?(v=s.jsx(wt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=v):v=n[22];let R;n[23]!==w||n[24]!==v?(R=s.jsxs(bt,{children:[w,v]}),n[23]=w,n[24]=v,n[25]=R):R=n[25];let T;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==x||n[30]!==f||n[31]!==p||n[32]!==h||n[33]!==a||n[34]!==b?(T=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:b("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?b("header.services.remoteUpdate.available",{version:h.version||""}):f?b("header.services.remoteUpdate.checking"):p||b("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:x,children:b("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Pp,{embedded:!0,open:l,onOpenChange:Ey,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=x,n[30]=f,n[31]=p,n[32]=h,n[33]=a,n[34]=b,n[35]=T):T=n[35];let D;n[36]!==T?(D=s.jsx(Ds,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:T}),n[36]=T,n[37]=D):D=n[37];let F;return n[38]!==l||n[39]!==k||n[40]!==R||n[41]!==D?(F=s.jsxs(Is,{open:l,onOpenChange:k,children:[R,D]}),n[38]=l,n[39]=k,n[40]=R,n[41]=D,n[42]=F):F=n[42],F}),an=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ic=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Ty=()=>{js("ui.header.render");const{t}=St(),e=Ae(N=>N.isSidebarOpen),n=Ae(N=>N.openContextOverview),r=Ae(N=>N.closeContextPanel),i=Ae(N=>N.shortcutOverrides),o=Ae(N=>N.sessionTabsEnabled),l=nt(N=>N.getContextUsage),a=nt(N=>!!N.newSessionDraft?.open),d=nt(N=>N.currentSessionId),u=Dp(d??""),h=Ip(d??""),f=mf(d??""),p=us(Qn(c.useCallback(N=>{if(!d)return null;const ke=[...N.activeSessions,...N.archivedSessions].find(dt=>dt.id===d);if(!ke)return null;const Ve=ke;return{title:ke.title??null,directory:Ve.directory??null,created:ke.time?.created??null,slug:Ve.slug??null,parentId:ke.parentID??null}},[d]))),x=zt(Qn(N=>{if(!N.activeProjectId)return null;const ke=N.projects.find(Ve=>Ve.id===N.activeProjectId);return ke?{id:ke.id,path:ke.path,label:ke.label}:null})),b=c.useMemo(()=>{if(!x)return null;const N=x.label?.trim();if(N)return N;const ke=x.path.split(/[\\/]/).filter(Boolean);return ke[ke.length-1]??null},[x]),k=ur(N=>N.loadSettings),{isMobile:y}=Nn(),m=c.useRef(null),[g,j]=c.useState(()=>typeof window>"u"?!1:en()),S=c.useMemo(()=>Vr(),[]),w=mu(),[C,v]=c.useState(!1),R=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:T,side:D}=Xu(),F=c.useMemo(()=>{if(typeof window>"u")return null;const N=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(typeof navigator>"u")return null;const ke=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ke)return null;const Ve=Number.parseInt(ke[1],10),dt=Number.parseInt(ke[2],10);return Number.isNaN(Ve)?null:Ve===10?dt:Ve},[]);ct.useEffect(()=>{typeof window>"u"||j(en())},[]);const{context:B,output:E}=Tp(d),$=l(B,E),[L,X]=c.useState(null),Y=!d||u;ct.useEffect(()=>{if(!d){X(N=>N===null?N:null);return}if($){X(N=>Ep(N,$)?N:$);return}Y&&X(N=>N===null?N:null)},[$,d,Y]);const[I,P]=c.useState(!1),[A,q]=c.useState("Local"),[K,te]=c.useState(!0),[ae,re]=c.useState(!1),[he,ce]=c.useState(null),[Te,ve]=c.useState(!1),[pe,Ne]=c.useState(null),U=c.useMemo(()=>kn(),[]),Z=Ae(N=>N.workStatusPanelVisible),de=Ae(N=>N.workStatusPanelEnabled),ye=Ae(N=>N.setWorkStatusPanelEnabled),H=Ae(N=>N.workStatusPanelFits),je=Ae(N=>N.workStatusOverlayOpen),Ee=Ae(N=>N.setWorkStatusOverlayOpen),ne=de&&H||je,be=c.useCallback(()=>{if(de&&!H){Ee(!je);return}ye(!de)},[Ee,ye,je,de,H]),G=!U&&!Z&&!!L,z=c.useCallback(async()=>{if(!(typeof window>"u"||!g))try{if(Qo()){q("Local"),te(!0);return}te(!1);const N=await Ld(),ke=Xm(),Ve=Jm([Zm(ke),...N.hosts]);if(Ve.id===eh){q("Local"),te(!0);return}q(_d(Ve.label.trim()||"Instance"))}catch{q("Local"),te(!0)}},[g]);ct.useEffect(()=>(z(),vr(()=>{z()})),[z]);const J=c.useCallback(async()=>{if(K){ce(null),Ne(null);return}ve(!0),Ne(null);try{const N=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ke=await ls(`/api/openchamber/update-check?${N.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ke.ok)throw new Error(`Server responded with ${ke.status}`);const Ve=await ke.json();ce({available:Ve.available??!1,version:Ve.version,currentVersion:Ve.currentVersion??"unknown",body:Ve.body,nextSuggestedCheckInSec:typeof Ve.nextSuggestedCheckInSec=="number"?Ve.nextSuggestedCheckInSec:void 0,packageManager:Ve.packageManager,updateCommand:Ve.updateCommand})}catch(N){ce(null),Ne(N instanceof Error?N.message:t("header.services.remoteUpdate.error"))}finally{ve(!1)}},[K,t]);c.useEffect(()=>{ce(null),Ne(null),re(!1)},[K,A]),c.useEffect(()=>{if(!g||K)return;const N=3e3,ke=3600*1e3;let Ve=!1,dt=null;const Tt=Et=>{dt=window.setTimeout(()=>{if(Ve||typeof document<"u"&&document.visibilityState!=="visible"){Tt(ke);return}J().finally(()=>{Ve||Tt(ke)})},Et)};return Tt(N),()=>{Ve=!0,dt!==null&&window.clearTimeout(dt)}},[J,K,A,g]);const ue=c.useCallback(()=>{if(he?.available){re(!0);return}J()},[J,he?.available]);Rp(),c.useEffect(()=>{k()},[k]);const le=d?p??null:null,W=c.useRef(null),[M,_]=c.useState(0);c.useEffect(()=>{if(!d){W.current&&(W.current=null,_(dt=>dt+1));return}if(le){W.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const N=W.current;if(!N||N.sessionId!==d)return;const ke=N.expiresAt-Date.now();if(ke<=0){W.current=null,_(dt=>dt+1);return}const Ve=window.setTimeout(()=>{W.current?.sessionId===d&&(W.current=null),_(dt=>dt+1)},ke);return()=>{window.clearTimeout(Ve)}},[d,le]);const ee=(()=>{if(le)return le;if(!d)return null;const N=W.current;return N&&N.sessionId===d&&N.expiresAt>Date.now()?N.session:null})(),oe=nt(N=>d?N.worktreeMetadata.get(d)?.path??"":""),fe=nt(N=>d?N.worktreeMetadata.get(d)?.branch?.trim()??null:null),ie=hu(N=>d?N.getAttachment(d):void 0),Le=c.useMemo(()=>ie?Mp(ie,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ie]),$e=c.useMemo(()=>ie?ie.legacy?"legacy":ie.degraded?"degraded":ie.worktreeStatus==="pending"?"pending":ie.worktreeStatus==="missing"?"missing":ie.worktreeStatus==="invalid"?"invalid":ie.attentionReason?"attention":null:null,[ie]),Pe=c.useMemo(()=>an(oe||""),[oe]),Oe=c.useMemo(()=>{const N=typeof ee?.directory=="string"?ee.directory:"";return an(N||"")},[ee?.directory]),Q=Ma(d??"",Oe),Ce=nt(N=>N.newSessionDraft?.open?an(N.newSessionDraft.bootstrapPendingDirectory??N.newSessionDraft.directoryOverride??""):""),Se=nt(N=>N.newSessionDraft.target),Ke=nt(N=>N.newSessionDraft.selectedProjectId),et=nt(N=>N.currentSessionDirectory),it=Jt(N=>N.homeDirectory),rt=c.useMemo(()=>Pe||Oe||Ce,[Ce,Oe,Pe]),pt=Ae(c.useCallback(N=>{const ke=an(rt||"");return ke?ic(N.contextPanelByDirectory[ke]):null},[rt])),ht=nt(N=>{const ke=an(Pe||Oe||"");if(!ke)return null;for(const Ve of N.availableWorktreesByProject.values()){const Tt=Ve.find(Et=>an(Et.path)===ke)?.branch?.trim();if(Tt)return Tt}return null}),At=Op(rt||null)||fe||ht,jt=a?Se==="chat":Bp(Oe||et,it),we=!jt&&!Z&&!!(b||At||!a&&$e),Xe=c.useMemo(()=>{if(!d)return b??"OpenChamber";const N=ee?.title?.trim();return N&&N.length>0?N:"Untitled Session"},[b,ee?.title,d]),mt=pu(),qe=nt(N=>N.updateSessionTitle),ft=nt(N=>N.archiveSessions),se=nt(N=>N.deleteSessions),[me,Ie]=c.useState(!1),[We,V]=c.useState(!1),Fe=c.useRef(null),[Ye,Qe]=c.useState(""),[xe,st]=c.useState(null),Re=c.useRef(null),ot=c.useCallback(()=>{d&&(Qe(ee?.title?.trim()||Xe),Ie(!0))},[ee?.title,d,Xe]),vt=c.useRef(ot);vt.current=ot;const De=c.useCallback(N=>{N&&(N.focus(),N.select())},[]);c.useEffect(()=>{if(V(!1),st(null),d&&Fe.current===d){Fe.current=null,vt.current();return}Ie(!1),Qe("")},[d]);const gt=c.useCallback(async()=>{if(!d)return;const N=Ye.trim();N&&N!==ee?.title?.trim()&&await qe(d,N),Ie(!1)},[ee?.title,d,Ye,qe]);c.useEffect(()=>{if(!me)return;const N=ke=>{const Ve=ke.target;(!Ve||!Re.current?.contains(Ve))&&gt()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[me,gt]);const Ct=c.useCallback(N=>{N&&Jn(N).then(ke=>{ze[ke.ok?"success":"error"](t(ke.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(t("sessions.sidebar.session.copyId.error")))},[t]),He=c.useCallback(async()=>{if(!d||!rt){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const N=await mt({sessionID:d,directory:rt}).catch(()=>null);if(!N){ze.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(N.length===0){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ke=gu(N,ee?.title??null),Ve=xu(ee?.title??null);await bu(ke,Ve)||yu(ke,Ve),ze.success(t("sessions.sidebar.session.export.success"))},[ee?.title,d,mt,rt,t]),Ue=wu(),lt=c.useMemo(()=>vu(Ue),[Ue]),_e=c.useCallback(N=>{d&&uf({entry:N,t,session:{id:d,title:ee?.title,directory:Oe??rt},loadRecords:async()=>{if(!rt)return null;try{return await mt({sessionID:d,directory:rt})}catch{return null}},onLoadFailed:()=>ze.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ee?.title,d,mt,rt,Oe,t]),Ge=c.useCallback(N=>lt.map(ke=>s.jsxs(N,{onClick:()=>_e(ke),children:[s.jsx(Xr,{icon:ke.icon,iconSrc:ke.iconSrc,className:"mr-1 size-4"}),ke.action.label]},`${ke.guest.id}:${ke.action.id}`)),[lt,_e]),Je=h?.type==="busy"||h?.type==="retry",at=c.useCallback(()=>{if(!d||!Oe||Je||f)return;const N=us.getState().activeSessions,ke=N.find(Tt=>Tt.id===d);if(!ke)return;const Ve=[],dt=[d];for(let Tt=0;Tt<dt.length;Tt+=1){const Et=dt[Tt];for(const kt of N)kt.parentID===Et&&(Ve.push(kt),dt.push(kt.id))}ua({kind:"quick",root:ke,descendants:Ve,sourceDirectory:Oe,messages:da(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Je,f,Oe,t]),Nt=c.useCallback(async()=>{if(!xe)return;const N=xe.action,ke=[xe.sessionId,...Gd(xe.sessionId,[],N==="delete")];if(st(null),(N==="archive"?await ft(ke):await se(ke)).failedIds.length>0){ze.error(t(N==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}ze.success(t(N==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ft,se,xe,t]),Bt=Ae(N=>N.openGuestPageId),Ft=Fa(N=>N.guests.find(ke=>ke.id===Bt)),Qt=Ae(N=>N.isScheduledTasksDialogOpen),Mt=Ae(N=>N.isArchivePageOpen),Gt=Ae(N=>N.isUsageStatsPageOpen),$t=Ae(N=>N.worktreesPageProjectId),Zt=Ae(N=>N.isMultiRunLauncherOpen),ts=zt(N=>{if(!$t)return null;const ke=N.projects.find(Ve=>Ve.id===$t);return ke?.label?.trim()||ke?.path?.split("/").pop()||null}),Ot=c.useMemo(()=>Ft?{title:Ft.pageTitle??Ft.name,subtitle:null}:Qt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Mt?{title:t("sessions.archivePage.title"),subtitle:null}:Gt?{title:t("usageStats.title"),subtitle:null}:$t?{title:t("sessions.worktreesPage.title",{project:ts??""}),subtitle:null}:Zt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Ft,Mt,Zt,Qt,Gt,t,$t,ts]),Dt=c.useMemo(()=>an(rt||x?.path||""),[x?.path,rt]),Pt=oy(),fs=La(N=>N.planModeEnabled),Ts=nt(N=>N.isSessionPlanAvailable),xn=fs&&d?Ts(d):!1,ns=c.useRef("");c.useEffect(()=>{if(!fs||!d)return;const N=`${d||"none"}:${Oe||"none"}:${ee?.created||0}:${ee?.slug||"none"}`;ns.current!==N&&(ns.current=N)},[fs,xn,ee?.slug,ee?.created,d,Oe]);const In=c.useCallback(()=>{jn("desktop_open_draft_mini_chat_window",{directory:jt?"":Ce,projectId:jt?null:Ke,apiBaseUrl:mn(),clientToken:Ur()}).catch(N=>{console.warn("[header] failed to open draft mini chat window",N)})},[Ce,Ke,jt]),to=c.useCallback(()=>{if(a){In();return}d&&jn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Oe||an(et||"")||Pe,apiBaseUrl:mn(),clientToken:Ur()}).catch(N=>{console.warn("[header] failed to open session mini chat window",N)})},[d,In,a,et,Oe,Pe]),Tn=c.useCallback(()=>{const N=an(rt||"");if(!N)return;const ke=Ae.getState().contextPanelByDirectory[N];if(ic(ke)==="context"){r(N);return}n(N)},[r,n,rt]),er=pt==="context",En=zo,Xs=c.useMemo(()=>g&&R&&!C?"88px":w?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||T)&&!U?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,C,R,w,U,T]);ct.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Xs)},[Xs]);const rn=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",on=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ct.useEffect(()=>{if(!g||!R){v(!1);return}let N=!1;const ke=async()=>{try{const dt=await jn("desktop_is_window_fullscreen");N||v(dt===!0)}catch{N||v(!1)}},Ve=()=>{ke()};return ke(),window.addEventListener("openchamber:window-resized",Ve),()=>{N=!0,window.removeEventListener("openchamber:window-resized",Ve)}},[g,R]);const tr=c.useMemo(()=>!g||!R||F===null?"":F>=26?"h-12":F<=15?"h-14":"",[g,R,F]),sr=c.useMemo(()=>{if(!(g&&!T||U)&&!(T&&D==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[g,U,T,D]),ws=c.useCallback(()=>{if(typeof document>"u")return;const N=m.current?.getBoundingClientRect().height;N&&document.documentElement.style.setProperty("--oc-header-height",`${N}px`)},[]);ct.useEffect(()=>{if(typeof window>"u")return;ws();const N=m.current;if(!N||typeof ResizeObserver>"u")return()=>{};let ke=0;const Ve=()=>{ke||(ke=requestAnimationFrame(()=>{ke=0,ws()}))},dt=new ResizeObserver(Ve);return dt.observe(N),window.addEventListener("resize",Ve),window.addEventListener("orientationchange",Ve),()=>{ke&&cancelAnimationFrame(ke),dt.disconnect(),window.removeEventListener("resize",Ve),window.removeEventListener("orientationchange",Ve)}},[ws]),ct.useEffect(()=>{ws()},[ws,y,tr]);const Rn=c.useCallback(async N=>{const ke=N.target;ke.closest(".app-region-no-drag")||ke.closest("button, a, input, select, textarea")||N.button===0&&g&&await th()},[g]),Es=c.useCallback(N=>Hn(Jr(N,i)),[i]);Fp({rename_current_session:()=>{if(!d||y)return!1;ot()},toggle_services_menu:()=>{if(I){P(!1);return}P(!0),z()}});const nr=s.jsxs(s.Fragment,{children:[Pt?s.jsx(ny,{projectRef:Pt.projectRef,directory:Pt.directory,className:"mr-2"}):null,s.jsx(Tb,{directory:Dt,className:"mr-1"}),g?s.jsx(Iy,{isDesktopApp:g,currentInstanceLabel:A,currentInstanceIsLocal:K,isDesktopServicesOpen:I,setIsDesktopServicesOpen:P,refreshCurrentInstanceLabel:z,shortcutLabel:Es,remoteUpdateInfo:he,remoteUpdateChecking:Te,remoteUpdateError:pe,onOpenRemoteUpdate:ue}):null]}),rr=S&&(a||!!d),kr=c.useCallback(({session:N,open:ke,isActive:Ve,select:dt,closeOtherTabs:Tt,components:Et})=>{const{Item:kt,Separator:Ht}=Et,os=Ve&&!U&&!jt&&ee&&!ee.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(kt,{onClick:()=>{Ve||dt(),Fe.current=N.id},children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ca,{sessionID:N.id,directory:N.directory,open:ke,Item:kt}),s.jsxs(kt,{onClick:()=>Ct(N.id),children:[s.jsx(O,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Ht,{}),Ve?s.jsxs(kt,{onClick:()=>{He()},children:[s.jsx(O,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,Ve?Ge(kt):null,os?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(kt,{disabled:!Oe||Je||f,onClick:at,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(wt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Je?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Ht,{}),s.jsxs(kt,{onClick:Tt,children:[s.jsx(O,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Ht,{}),s.jsxs(kt,{onClick:()=>st({action:"archive",sessionId:N.id}),children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(kt,{className:"text-destructive focus:text-destructive",onClick:()=>st({action:"delete",sessionId:N.id}),children:[s.jsx(O,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Ct,ee,He,jt,Je,f,U,at,Ge,Oe,t]),or=()=>s.jsxs("div",{onMouseDown:Rn,className:Me("app-region-drag relative flex h-12 select-none items-center",T&&D==="right"?"pr-0":"pr-3",tr),style:sr,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:rn}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:on}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Ot?s.jsxs(s.Fragment,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Ae.getState().closeMainSurfaces(),children:s.jsx(O,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(wt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ot.title}),Ot.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Ot.subtitle}):null]})]}):U||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[Q?s.jsx(O,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Ql,{align:"start",children:s.jsx("button",{type:"button",className:En,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[me?s.jsxs("form",{ref:Re,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),gt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>Qe(N.target.value),onKeyDown:N=>Ui(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xe}),we?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[b?s.jsx("span",{className:"truncate",children:b}):null,At?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:At})]}):null,!a&&$e?s.jsxs("span",{className:Me("inline-flex min-w-0 items-center gap-0.5",$e==="attention"||$e==="invalid"||$e==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(O,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Le})]}):null]}):null]}),s.jsx("div",{className:Me("flex h-[18px] shrink-0 items-center justify-center",we?"self-start":"self-center"),children:d&&!a&&!me?s.jsxs(Is,{open:We,onOpenChange:V,onOpenChangeComplete:N=>{!N&&Fe.current&&Fe.current===d&&(Fe.current=null,ot())},children:[s.jsx(Ps,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsxs(Ds,{align:"end",className:"min-w-[190px]",children:[s.jsxs(_t,{onClick:()=>{Fe.current=d},children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ca,{sessionID:d,directory:Oe,open:We,Item:_t}),s.jsxs(_t,{onClick:()=>d&&Ct(d),children:[s.jsx(O,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(gs,{}),s.jsxs(_t,{onClick:()=>{He()},children:[s.jsx(O,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Ge(_t),!U&&!jt&&ee&&!ee.parentId?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(_t,{disabled:!Oe||Je||f,onClick:at,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(wt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Je?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(gs,{}),s.jsxs(_t,{onClick:()=>{d&&st({action:"archive",sessionId:d})},children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(_t,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&st({action:"delete",sessionId:d})},children:[s.jsx(O,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Ql,{align:"start",children:s.jsx("button",{type:"button",className:En,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(dy,{renderMenu:kr,suppressActiveTabControls:me,onMenuOpenChangeComplete:N=>{!N&&Fe.current&&Fe.current===d&&(Fe.current=null,ot())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:me?s.jsxs("form",{ref:Re,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),gt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>Qe(N.target.value),onKeyDown:N=>Ui(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Xe})})})]}),Ot||U||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G&&L?s.jsx(Qx,{reading:Xx(L),contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Tn,pressed:er,className:rr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(Dy,{visible:rr,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:to,className:Me(En,"mr-1"),Icon:"picture-in-picture-2"}),U?null:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ne,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:be,className:Me(zo,"mr-1",ne?"text-foreground":"text-muted-foreground/50"),children:s.jsx(O,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{side:"bottom",children:t(de&&!H?je?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":de?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),nr,s.jsx(Ju,{visible:T&&D==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:or()}),s.jsx(bs,{open:xe!==null,onOpenChange:N=>{N||st(null)},children:s.jsxs(ys,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Us,{children:[s.jsx(Bs,{children:xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Fs,{children:xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Xe}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Xe})})]}),s.jsxs(An,{children:[s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>st(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{Nt()},children:xe?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(qd,{open:ae,onOpenChange:re,info:he,downloading:!1,downloaded:!1,progress:null,error:pe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function Ey(){}const ac=280,lc=264,cc=500,Ry=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=St(),l=Ae(v=>v.sidebarWidth),a=Ae(v=>v.setSidebarWidth),[d,u]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||ac),p=c.useRef(null),x=c.useRef(null),b=c.useRef(null),k=c.useCallback(v=>Math.min(cc,Math.max(lc,v)),[]),y=c.useCallback(v=>{const R=b.current;R&&(R.style.width=`${v}px`,R.style.minWidth=`${v}px`,R.style.maxWidth=`${v}px`,R.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(p.current=null,x.current=null)},[d]),e)return null;const m=Math.min(cc,Math.max(lc,l||ac)),g=t?m:0,j=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}x.current=v.pointerId,u(!0),h.current=v.clientX,f.current=g,p.current=g,y(g),v.preventDefault()}},S=v=>{if(e||!d||x.current!==v.pointerId)return;const R=v.clientX-h.current,T=k(f.current+R);p.current!==T&&(p.current=T,y(T))},w=v=>{if(x.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const R=k(p.current??g);x.current=null,p.current=null,u(!1),a(R)},C=d?p.current??g:g;return s.jsxs("aside",{ref:b,className:Me("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C:m}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||g===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Me("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:j,onPointerMove:S,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Me("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(gn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(ps,{children:n})})]})]})},My=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},io="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",Oy=()=>{const t=Ze.c(37),{t:e}=St(),n=Ae(By),r=Ae(Fy),i=Ae(Ly),o=c.useRef(null),l=Hn(Jr("toggle_sidebar",i)),a=_y,{usesFramelessChrome:d,side:u}=Xu(),h=zy;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const L=o.current;if(!L)return;const X=()=>{const I=Math.max(L.getBoundingClientRect().width,L.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(I)}px`)};if(X(),typeof ResizeObserver>"u")return;const Y=new ResizeObserver(X);return Y.observe(L),()=>{Y.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),c.useEffect(f,p);const x="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=b):b=t[2];const k="flex items-center gap-2";let y;t[3]!==d||t[4]!==u?(y=d&&u==="left"?s.jsx(Ju,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=y):y=t[5];let m;t[6]!==e||t[7]!==d?(m=d?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,"aria-label":e("header.actions.openAppMenuAria"),className:Me(io,"shrink-0"),children:s.jsx(O,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=m):m=t[8];const g=bt;let j;t[9]!==e?(j=e("header.actions.openSessionsAria"),t[9]=e,t[10]=j):j=t[10];let S,w;t[11]===Symbol.for("react.memo_cache_sentinel")?(S=Me(io,"shrink-0"),w=s.jsx(O,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=S,t[12]=w):(S=t[11],w=t[12]);let C;t[13]!==j||t[14]!==n?(C=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":j,className:S,children:w})}),t[13]=j,t[14]=n,t[15]=C):C=t[15];const v=wt,R=e("header.actions.openSessionsWithShortcut",{shortcut:l});let T;t[16]!==R?(T=s.jsx("p",{children:R}),t[16]=R,t[17]=T):T=t[17];let D;t[18]!==v||t[19]!==T?(D=s.jsx(v,{children:T}),t[18]=v,t[19]=T,t[20]=D):D=t[20];let F;t[21]!==g||t[22]!==C||t[23]!==D?(F=s.jsxs(g,{children:[C,D]}),t[21]=g,t[22]=C,t[23]=D,t[24]=F):F=t[24];let B;t[25]!==a||t[26]!==r||t[27]!==e?(B=r?s.jsxs("button",{type:"button",onClick:a,className:Me(io,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(O,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Me(io,"-ml-1 shrink-0"),children:s.jsx(O,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=B):B=t[28];let E;t[29]!==F||t[30]!==B||t[31]!==y||t[32]!==m?(E=s.jsxs("div",{ref:o,className:k,children:[y,m,F,B]}),t[29]=F,t[30]=B,t[31]=y,t[32]=m,t[33]=E):E=t[33];let $;return t[34]!==E||t[35]!==b?($=s.jsx("div",{className:x,style:b,children:E}),t[34]=E,t[35]=b,t[36]=$):$=t[36],$};function By(t){return t.toggleSidebar}function Fy(t){return t.isSidebarOpen}function Ly(t){return t.shortcutOverrides}function _y(){Ae.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function $y(t){console.warn("[titlebar] failed to open app menu",t)}function zy(t){const e=t.currentTarget.getBoundingClientRect();jn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch($y)}function pf(t){const e=Ze.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(O,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const dc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Wy(t,e,n){const r=Ze.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,h]=await Promise.all([Lp(t),_p(t)]).catch(Ky);if(d)return;const f=dc(u),p=dc(h);if(!f||!p||p===f)return;const x=n||"",b=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:x,label:x||b,name:b,worktreeRoot:p,worktreeStatus:"ready",headState:x?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Ky(){return["",""]}const uc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Vy=async(t,e)=>{if(t)return t.authActivate(e);const n=await ls("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},fc=({className:t})=>{const{t:e}=St(),{github:n}=nn(),r=hn(x=>x.status),i=hn(x=>x.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async x=>{if(!(!x||o)){l(!0);try{i(await Vy(n,x))}catch(b){console.error("Failed to switch GitHub account:",b)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,h=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),p=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(O,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Me(uc,t),title:f,children:p}):s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(uc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(Ds,{align:"end",className:"w-64",children:[s.jsx(cr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(gs,{}),h.map(x=>{const b=x.user,k=!!x.current,y=x.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(_t,{className:"gap-2",disabled:o,onSelect:()=>{k||a(x.id)},children:[b?.avatarUrl?s.jsx("img",{src:b.avatarUrl,alt:b.login?e("header.github.avatarWithLogin",{login:b.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(O,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:b?.name?.trim()||b?.login||"GitHub"}),b?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:b.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:y})]}):null]}),k?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},x.id)})]})]})};class mi extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const hi="/api/walkthrough",gf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),xf=()=>new mi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Uy=t=>!gf(t)&&(t.ok||t.status===404),Za=async(t,e)=>{if(Uy(t))throw xf();const n=await t.json().catch(()=>null);throw new mi(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},bf=async t=>{if(!gf(t))throw xf();try{return await t.json()}catch{throw new mi("The server returned a malformed walkthrough response")}};async function Hy(t,e,n={}){const r=await ls(hi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?bf(r):Za(r,"Failed to load walkthrough")}async function Gy(t,e,n={}){const r=await ls(`${hi}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?bf(r):Za(r,"Failed to generate walkthrough")}async function qy(t,e){const n=await ls(`${hi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Za(n,"Failed to cancel walkthrough generation")}async function Yy(t,e,n){const r=await ls(`${hi}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Dr={status:"idle",stage:null,result:null,readiness:null,error:null},Qy=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,bn=(t,e)=>`${Wt()}\0${t}\0${Qy(e)}`,mc=t=>t instanceof mi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},$s=new Map,Ir=new Map,Xy=1e3,Jy=Zr()(xb((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=bn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[bn(n,r)],selectModel:(n,r,i)=>{const o=bn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[bn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[bn(n,r)]??Dr,load:async(n,r,i={})=>{if(!n)return;const o=bn(n,r);if(e().entries[o]?.status==="generating")return;$s.get(o)?.abort();const a=new AbortController;$s.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"loading",error:null}}}));try{const d=await Hy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:mc(d)}}}))}finally{$s.get(o)===a&&$s.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=bn(n,r);$s.get(o)?.abort();const l=new AbortController;$s.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Ir.get(o);d!==void 0&&(clearInterval(d),Ir.delete(o))};a(),Ir.set(o,setInterval(()=>{Yy(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const h=u.entries[o];return!h||h.status!=="generating"||h.stage===d?u:{entries:{...u.entries,[o]:{...h,stage:d}}}})}).catch(()=>{})},Xy));try{const d=await Gy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:mc(d)}}}))}finally{a(),$s.get(o)===l&&$s.delete(o)}},cancel:(n,r)=>{const i=bn(n,r);qy(n,r).catch(()=>{}),$s.get(i)?.abort(),$s.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of $s.values())n.abort();$s.clear();for(const n of Ir.values())clearInterval(n);Ir.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Zy="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",e1=3e4,hc=20,yf=(t,e)=>JSON.stringify([Wt(),t,e]),t1=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},pc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ao=new Map,s1=t=>{const e=Object.entries(t);return e.length<=hc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,hc))},gc=Zr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=yf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<e1&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const h=`${l}::${a?"details":"plain"}`,p=ao.get(`${l}::details`)??(a?null:ao.get(h));if(p&&!o?.force)return p;const x=(async()=>{t(b=>({entries:{...b.entries,[l]:{...b.entries[l]??pc(),isLoading:!0,error:null}}}));try{const b=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(k=>({entries:s1({...k.entries,[l]:{result:b,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),b}catch(b){const k=b instanceof Error?b.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??pc(),isLoading:!1,error:k}}})),null}finally{ao.delete(h)}})();return ao.set(h,x),x},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=t1(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),n1=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},r1=35e3,Ii=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ti=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},xc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},o1=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},i1=[2e3,5e3],a1=600,bc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),wn=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},l1=(t,e)=>{const n=wn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},c1=(t,e)=>`${t}::${e}`,el=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Ei=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=el(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},d1=t=>t.startsWith("pr-"),u1=(t,e)=>{const n=el(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!d1(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Tr=new Map,lo=Qr;function f1(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const m1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=St(),d=Ae(N=>N.timeFormatPreference),{github:u}=nn(),h=hn(N=>N.status),f=hn(N=>N.hasChecked),p=Ae(N=>N.setSettingsDialogOpen),x=Ae(N=>N.setSettingsPage),b=nt(N=>N.currentSessionId),k=nt(N=>!!N.newSessionDraft?.open),{isMobile:y,hasTouchInput:m,screenWidth:g}=Nn(),j=Ae(N=>N.openContextSurface),S=Jy(N=>N.requestSource),w=!y&&g>=768&&!kn(),C=c.useCallback(()=>{x("integrations"),p(!0)},[p,x]),v=c.useMemo(()=>c1(t,e),[t,e]),R=c.useMemo(()=>Tr.get(v)??null,[v]),T=Ms(N=>N.ensureEntry),D=Ms(N=>N.setParams),F=Ms(N=>N.startWatching),B=Ms(N=>N.stopWatching),E=Ms(N=>N.refresh),$=Ms(N=>N.updateStatus),[L,X]=c.useState(()=>R?.title??bc(e)),[Y,I]=c.useState(()=>R?.body??""),[P,A]=c.useState(()=>R?.draft??!1),[q,K]=c.useState(()=>R?.additionalContext??""),[te,ae]=c.useState(()=>{const N=typeof R?.targetBaseBranch=="string"?wn(R.targetBaseBranch):"";return N||wn(n)}),[re,he]=c.useState("squash"),[ce,Te]=c.useState(!1),[ve,pe]=c.useState(!1),[Ne,U]=c.useState(!1),[Z,de]=c.useState(!1),[ye,H]=c.useState(!1),[je,Ee]=c.useState(!1),[ge,ne]=c.useState(null),[be,G]=c.useState(""),[z,J]=c.useState(""),[ue,le]=c.useState(!1),[W,M]=c.useState(!1),[_,ee]=c.useState(()=>Ei(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r})),[oe,fe]=c.useState(!1),{detectedUpstream:ie,upstreamBranches:Le}=f1(t,u);c.useEffect(()=>{fe(!1)},[t]);const $e=i.some(N=>N.name==="upstream"),Oe=!!(t&&e&&n&&(e!==n||($e||ie!==null))),Q=c.useMemo(()=>Xo(t,e,_?.name??null),[t,e,_?.name]),Ce=Ms(N=>N.entries[Q]),Se=Ce?.isLoading??!1,Ke=Ce?.status??null,et=Ce?.error??null,it=Ce?.isInitialStatusResolved??!1,rt=c.useMemo(()=>{const N=oe?null:_?.name?.trim()||null,ke=new Set;for(const Tt of o){const Et=l1(Tt,N);!Et||Et==="HEAD"||ke.add(Et)}if(oe)for(const Tt of Le)Tt&&Tt!=="HEAD"&&ke.add(Tt);const Ve=wn(n);Ve&&Ve!=="HEAD"&&ke.add(Ve);const dt=wn(te);return dt&&dt!=="HEAD"&&ke.add(dt),Array.from(ke).sort((Tt,Et)=>Tt.localeCompare(Et))},[n,o,_?.name,te,Le,oe]);c.useEffect(()=>{if(i.length===0){_&&ee(null);return}(!_||!i.some(N=>N.name===_.name))&&ee(Ei(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r}))},[R?.selectedRemoteName,i,_,r]),c.useEffect(()=>{const N=wn(n);if(!te&&N){ae(N);return}if(rt.length!==0&&!rt.includes(te)){const ke=rt.includes(N)?N:rt[0];ke&&ae(ke)}},[rt,n,te]);const[pt,ht]=c.useState(()=>R?.activeSegment??"overview"),[tt,At]=c.useState(new Set),[jt,we]=c.useState(new Set),Xe=c.useRef(new Set),mt=c.useRef(null),qe=c.useRef(!1),ft=c.useRef(new Set),se=c.useRef([]);c.useEffect(()=>{ie&&!$e&&fe(!0)},[ie,$e]),c.useEffect(()=>{oe&&ie?.defaultBranch&&ae(ie.defaultBranch)},[oe,ie?.defaultBranch]);const me=Ke?.pr??null,Ie=me?.state==="merged"||me?.state==="closed",We=Ie?null:me,V=We?yf(t,We.number):null,Fe=gc(N=>V?N.entries[V]:void 0),Ye=gc(N=>N.ensure),Qe=Fe?.result??null,xe=Fe?.isLoading??!1,st=c.useCallback(N=>{ht(N);const ke=Tr.get(v);ke&&Tr.set(v,{...ke,activeSegment:N})},[v]);c.useEffect(()=>{!We||!u?.prContext||pt==="overview"||Ye(u,t,We.number,{includeCheckDetails:pt==="checks",sourceRepo:Ke?.repo??null})},[pt,t,Ye,u,We,Ke?.repo]);const Re=Ke?.checks??null,ot=(Re?.pending??0)>0,vt=Qe?.checkRuns??null,De=Qe?.fetchedAt;c.useEffect(()=>{if(!vt||vt.length===0)return;const N=n1(vt);$(Q,ke=>{if(!ke?.pr||typeof De=="number"&&typeof ke.fetchedAt=="number"&&De<ke.fetchedAt)return ke;const Ve=ke.checks;return Ve&&Ve.state===N.state&&Ve.total===N.total&&Ve.success===N.success&&Ve.failure===N.failure&&Ve.pending===N.pending&&Ve.inProgress===N.inProgress&&Ve.queued===N.queued&&Ve.startedAt===N.startedAt?ke:{...ke,checks:N,...typeof De=="number"?{fetchedAt:De}:{}}})},[vt,De,Q,$]),c.useEffect(()=>{if(pt!=="checks"||!ot||!me||!u?.prContext)return;const N=window.setInterval(()=>{Ye(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Ke?.repo??null,force:!0})},r1);return()=>window.clearInterval(N)},[pt,ot,t,Ye,u,me,Ke?.repo]);const[gt,Ct]=c.useState(()=>Date.now());c.useEffect(()=>{if(!ot)return;Ct(Date.now());const N=window.setInterval(()=>Ct(Date.now()),3e4);return()=>window.clearInterval(N)},[ot]);const He=me?`${t}#${me.number}`:null,Ue=!!(He&&ge===He);c.useEffect(()=>{if(!u?.prContext||!me||typeof me.body=="string"&&me.body.length>0)return;const N=`${t}#${me.number}`;if(Xe.current.has(N))return;Xe.current.add(N),ne(N);let ke=!1;return Ye(u,t,me.number,{sourceRepo:Ke?.repo??null}).then(Ve=>{if(ke)return;const dt=Ve?.pr;dt&&$(Q,Tt=>!Tt?.pr||Tt.pr.number!==me.number?Tt:{...Tt,pr:{...Tt.pr,body:dt.body||""}})}).catch(()=>{}).finally(()=>{ke||ne(Ve=>Ve===N?null:Ve)}),()=>{ke=!0}},[t,Ye,u,me,Q,Ke?.repo,$]),c.useEffect(()=>{if(!me){Ee(!1),G(""),J(""),mt.current=null;return}const N=mt.current!==null&&mt.current!==me.number;N&&Ee(!1),(!je||N)&&(G(me.title||""),J(me.body||"")),mt.current=me.number},[je,me]);const lt=c.useCallback(N=>{if(!N)return"";const ke=Date.parse(N);return Number.isFinite(ke)?Su(ke,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):N},[d]),_e=c.useMemo(()=>{const N=h?.user?.login;return typeof N=="string"?N.trim():""},[h]),Ge=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Je=c.useCallback(N=>{const ke=_e.toLowerCase(),Ve=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return N.replace(Ve,(dt,Tt,Et)=>{const kt=`@${Et}`,Ht=Et.toLowerCase();return`${Tt}[${kt}](https://github.com/${Ht}${ke&&Ht===ke?"?oc-self-mention=1":""})`})},[_e]),at=c.useMemo(()=>{const N=(Qe?.issueComments??[]).map(dt=>({id:`issue-${dt.id}`,body:dt.body||"",authorName:dt.author?.name||dt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:dt.author?.login||null,avatarUrl:dt.author?.avatarUrl||null,createdAt:dt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),ke=(Qe?.reviewComments??[]).map(dt=>({id:`review-${dt.id}`,body:dt.body||"",authorName:dt.author?.name||dt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:dt.author?.login||null,avatarUrl:dt.author?.avatarUrl||null,createdAt:dt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:dt.path||null,line:dt.line??null})),Ve=[...N,...ke];return Ve.sort((dt,Tt)=>{const Et=dt.createdAt?Date.parse(dt.createdAt):0,kt=Tt.createdAt?Date.parse(Tt.createdAt):0,Ht=Number.isFinite(Et)?Et:0,os=Number.isFinite(kt)?kt:0;return Ht-os}),Ve},[Qe,a]),Nt=c.useCallback(()=>{const N=b??(k?"draft":null);return N?{directory:t,sessionKey:N}:(ze.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[b,t,k,a]),Bt=c.useCallback((N,ke)=>{const Ve=ke.authorLogin?`@${ke.authorLogin}`:ke.authorName,dt=ke.path?` · ${ke.path}${ke.line?`:${ke.line}`:""}`:"";Yi.getState().addDraft(N,{source:"pr-comment",fileLabel:`PR #${me?.number??""} ${Ve}${dt}`,startLine:ke.line??0,endLine:ke.line??0,code:ke.body,language:"markdown",text:""})},[me?.number]),Ft=c.useCallback((N,ke)=>{const Ve=N.status||"unknown",dt=N.conclusion??void 0,Tt=dt?`${Ve} / ${dt}`:Ve,Et=N.app?.name||N.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:ke?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[ke?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Et?`${Et} · ${Tt}`:Tt})]}),N.detailsUrl?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:N.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),N.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:N.output.title}):null,N.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:N.output.summary}):null,N.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:N.output.text}):null,Array.isArray(N.annotations)&&N.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",N.annotations.length>20?` (showing 20/${N.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:N.annotations.slice(0,20).map((kt,Ht)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[kt.title||kt.level||"Issue",kt.path?` · ${kt.path}`:"",typeof kt.startLine=="number"?`:${kt.startLine}`:"",typeof kt.endLine=="number"&&kt.endLine!==kt.startLine?`-${kt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:kt.message}),kt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:kt.rawDetails}):null]},`${kt.path||"file"}:${kt.startLine||Ht}:${Ht}`))})]}):null,N.job?.steps&&N.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:N.job.steps.map((kt,Ht)=>{const os=(kt.conclusion||"").toLowerCase(),Xt=os&&!["success","neutral","skipped"].includes(os),Hs=`${N.id??"run"}:${N.job?.jobId??"job"}:${kt.number??Ht}:${kt.name}`,vs=tt.has(Hs);return Xt?s.jsxs(Qi,{open:vs,children:[s.jsxs("button",{type:"button",onClick:()=>{At(gi=>{const Mn=new Set(gi);return Mn.has(Hs)?Mn.delete(Hs):Mn.add(Hs),Mn})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Xt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[vs?s.jsx(O,{name:"arrow-down-s",className:"size-4"}):s.jsx(O,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:kt.name}),kt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:kt.conclusion}):null]}),s.jsx(Xi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof kt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",kt.number]}):null,kt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",kt.status]}):null,kt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",kt.conclusion]}):null,kt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",lt(kt.startedAt)]}):null,kt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",lt(kt.completedAt)]}):null]})})]},Hs):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:kt.name}),kt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:kt.conclusion}):null]},Hs)})})]}):null]})},[tt,lt,a]),[Qt,Mt]=c.useState(!1),[Gt,$t]=c.useState(!1),Zt=c.useCallback(async()=>{if(!u?.prContext){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Nt();if(N){Mt(!0);try{const ke=await Ye(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Ke?.repo??null});if(!ke){ze.error(a("gitView.pr.toast.loadChecksFailed"));return}const dt=(ke.checkRuns??[]).filter(Et=>Ti(Et.conclusion));if(dt.length===0){ze.message(a("gitView.pr.toast.noFailedChecks"));return}const Tt=Yi.getState();for(const Et of dt){const kt=(Et.annotations??[]).map(Xt=>[[Xt.level,Xt.title].filter(Boolean).join(" "),Xt.path?`${Xt.path}${typeof Xt.startLine=="number"?`:${Xt.startLine}`:""}`:null,Xt.message,Xt.rawDetails].filter(Boolean).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-Cf8EdtIU.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DJZbUd4z.js","assets/index-Di6zUe5h.js","assets/vendor-zod-BSoePkpP.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-DUke1nme.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.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-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.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-DeBrOhi1.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-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-Cxi3zs93.js","assets/runtimeEndpointReset-3DNMw1le.js","assets/GuestAttachDialog-CaRAB_pV.js","assets/PluginPane-CaJz1LlW.js","assets/VirtualizedFileDiff-DDgQH7-1.js","assets/web-components-5hxxRZKN.js","assets/computeVirtualFileMetrics-Bz7G81bS.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/isDiffPlainText-D2lANTsV.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DLcUtI6Q.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-dDUqIMI2.js","assets/appThemeRegistry-D2_fKsMa.js","assets/textMateThemeFromAppTheme-SNTAfu1S.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-DAPXfqs1.js","assets/scheduledTasksApi-Dahv3ws0.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-IFl6EaUT.js","assets/SubmoduleDiffSummary-CeV_WX3U.js","assets/changesTree-CePHbFcj.js","assets/FilesView-2QJJIAmr.js","assets/shikiHighlight-mGfGdiiG.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-RFvqdmCZ.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-Cbv7v9Ro.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets--j227ElB.js","assets/GitView-xpLPdSXl.js","assets/commitAndPush-P6RxBC7G.js","assets/LinearIssuesView-CYI08VW3.js","assets/PlanView-Bvt1PdkO.js","assets/GuestSurfacePane-CA1Pu0hE.js","assets/SettingsWindow-ilszvARl.js","assets/SettingsView-DL_ucsI6.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-B3B8bi91.js"])))=>i.map(i=>d[i]);
2
+ import{f as Ze,R as c,j as s,r as ct,c as Gm,h as qm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{F as en,H as Qo,I as Ym,J as Qm,h as ls,y as Fd,u as Ae,K as Rt,L as xl,a as Wt,z as vr,o as xt,N as js,O as Vr,P as kn,Q as Ld,R as Xm,S as Jm,T as Zm,U as eh,V as _d,n as Jt,W as jn,X as Ur,e as mn,Y as th,Z as sh,_ as nh,$ as rh,a0 as $d,x as Js,C as Vs,a1 as oh,a2 as bl,a3 as ih,a4 as zd,a5 as ah,a6 as Wd,f as lh,a7 as $n,a8 as Un,a9 as Ro,aa as Wi,ab as ch,ac as Ra,d as Mo,v as lr,q as as,ad as Kd,ae as dh,af as Ki,ag as Vd,ah as Ud,t as Hd,i as uh,ai as fh,aj as ko,ak as Co,al as mh,am as yl,an as hh,ao as ph,ap as gh,aq as xh,ar as wl,as as vl,at as Sl,au as jl,av as bh,B as kl,aw as yh,ax as wh,ay as vh,D as Sh,E as jh}from"./index-Di6zUe5h.js";import{_ as sn}from"./vendor-vite-runtime-DD1OZmLC.js";import{z as Cl,E as Si,F as Gs,G as Vi,H as Nl,I as kh,J as Ch,K as Nh,L as Ah,M as Ph,Q as Dh,R as Ih,V as Th,W as Ma,a as Eh,e as Gd,X as qd,h as Ui,m as Yd,Y as Rh,k as Mh,j as Oh,Z as Qd,_ as Hi,$ as zn,a0 as Xd,a1 as Jd,l as Bh,P as Fh,T as Lh,a2 as _h,a3 as $h,a4 as zh,a5 as Wh,b as Zd,a6 as Kh,a7 as eu,a8 as Oo,a9 as Vh,aa as Uh,ab as Hh,S as ji,ac as tu,ad as su,d as Gh,ae as qh,c as Yh,af as Qh,ag as ro,r as Al,ah as Xh,ai as Jh,u as _r,s as Zh,N as ep,D as tp,aj as sp,ak as Pl,al as np,am as ki,w as rp,q as op,x as nu,U as ip,y as ap,an as lp,ao as cp,ap as dp,O as up,o as fp,t as mp,v as ru,A as hp,C as pp}from"./runtimeEndpointReset-3DNMw1le.js";import{f as St,h as Me,bh as _t,I as O,g as Jn,t as ze,at as Ps,bi as gs,av as Ds,as as Is,T as Cn,_ as nn,ai as Zn,bj as Nn,o as Qr,bk as Dl,bl as gp,bm as xp,ae as bt,af as yt,ag as wt,b as zt,z as nt,H as bp,bn as ou,bo as oo,u as us,r as xs,D as iu,C as au,bp as Gi,bq as yp,br as lu,bs as cu,S as Oa,bt as wp,bu as vp,bv as Il,bw as Tl,bx as du,by as Sp,bz as El,bA as jp,bB as kp,bC as Ba,bD as qi,bE as uu,bF as Cp,bG as Np,bH as Ap,Q as fu,bI as Pp,bJ as Dp,bK as Ip,n as ur,bL as mu,bM as Tp,bN as Ep,p as Rp,bO as hu,bP as Mp,bQ as Op,bR as Bp,bS as pu,bT as gu,bU as xu,bV as bu,bW as yu,bX as wu,bY as vu,bZ as Xr,b_ as Fa,aJ as La,b$ as Hn,c0 as Jr,c1 as Fp,c2 as bs,c3 as ys,c4 as Us,c5 as Bs,c6 as Fs,c7 as An,B as ut,c8 as gn,aB as ps,c9 as Lp,ca as _p,aH as hn,cb as cr,cc as Ms,cd as Xo,ce as Su,cf as Yi,cg as Qi,ch as Xi,ci as $p,cj as ks,ck as Cs,cl as hs,cm as Ns,cn as Yt,X as un,co as fr,cp as Rl,cq as hr,cr as ju,R as Jo,aj as zp,ak as _a,al as ku,J as Cu,K as pn,cs as $a,a9 as za,ct as Wp,cu as Kp,az as Vp,cv as Up,cw as Nu,cx as Hp,cy as Gp,aA as Wa,cz as qp,cA as Au,cB as pr,cC as Pu,cD as Yp,l as Lt,s as Qp,cE as Xp,cF as Jp,aO as Pn,cG as Zp,cH as dr,O as Du,cI as eg,cJ as tg,cK as Dn,cL as sg,cM as ng,aD as rg,cN as Ci,cO as og,cP as ig,cQ as ag,cR as Iu,cS as lg,cT as Ka,cU as cg,cV as Tu,cW as dg,aI as Ji,cX as Zi,cY as Ml,cZ as ug,c_ as Ol,c$ as Or,c as Hr,d as Va,a4 as fg,a1 as Eu,d0 as Pr,d1 as Br,d2 as mg,d3 as hg,d4 as pg,$ as Ua,aC as gg,d5 as xg,d6 as bg,d7 as yg,d8 as wg,d9 as Ru,da as Qs,db as vg,dc as Mu,dd as Sg,a8 as ea,de as jg,df as Ou,dg as ss,dh as kg,di as Cg,dj as Ng,dk as Bu,dl as Ag,dm as Ha,dn as Fu,a6 as Bo,dp as ta,dq as Zo,a as Ga,dr as qa,a5 as Pg,ds as Bl,P as Fo,U as ei,V as ti,W as si,dt as Dg,du as sa,dv as Lu,dw as Ig,dx as Tg,au as _u,dy as Eg,dz as Ya,L as Rg,dA as Fl,dB as Mg,dC as Og,dD as Ut,dE as Bg,dF as Yn,dG as $u,dH as zu,dI as Wu,dJ as Ku,dK as Fg,E as Lg,dL as _g,dM as $g,dN as zg,dO as Ll,dP as Vu,dQ as Wg,dR as Uu,F as Kg,dS as Vg,dT as Ug,dU as Hg,dV as $r,dW as Gg,dX as qg,dY as Yg,dZ as Qg,e as Qa,d_ as ni,d$ as Xg,e0 as Gr,a3 as Jg,G as ri,e1 as Zg,e2 as ex,e3 as _l,e4 as tx,e5 as sx,a0 as nx,e6 as rx,e7 as ox,a$ as $l,ab as zl,aa as Wl,e8 as ix,aW as na,e9 as ax,M as lx,N as Ni,ea as cx,eb as dx,ec as Hu,ed as Gu,ee as qu,ef as ux,eg as fx,a7 as mx,am as hx,eh as px,ei as Kl,ej as gx,ek as xx,el as bx,em as yx,en as Lo,eo as wx,ep as Vl,eq as vx,er as Sx,es as jx,et as kx,eu as ra,ev as Cx,ew as No,ex as Nx,i as Ax,ey as Px,ez as Dx,eA as Ix,eB as Tx,eC as Ex,eD as Rx,eE as Ul,eF as Mx,aP as Ox,aQ as Bx,aS as Fx,aR as Lx,aU as Hl,aV as Gl,aY as ql,aZ as Yl,aX as Yu,a_ as Qu,eG as _x,bc as $x,bd as zx,be as Wx,bf as Kx,bg as Vx,b6 as Ux,b8 as Hx,b9 as Gx,ba as qx,bb as Yx}from"./useAppFontEffects-DJZbUd4z.js";import{u as Xu,S as Ql,C as Qx,t as Xx,W as Ju,f as Jx,G as Zx,a as eb}from"./useRootScrollLock-DAPXfqs1.js";import{u as On,O as Xl,D as tb,a as sb,b as nb,f as rb,c as Jl,s as ob,d as ib,e as ab,r as lb}from"./scheduledTasksApi-Dahv3ws0.js";import{f as oi,h as fn,T as ii,M as ai,D as li,j as ci,d as cb,b as db,k as ub,i as fb}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as di,S as Xa,h as mb,a as Zu,v as ef,s as hb}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ui}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as tf,M as sf,C as nf,a as oa,b as ia,c as aa,d as rf,e as pb,f as gb}from"./vendor-base-ui-CsXYnR5c.js";import{c as Zr,u as Qn,d as xb,p as bb}from"./vendor-zustand-BAGL70zf.js";import{g as yb,a as wb,E as of,b as vb,c as Sb,d as jb,e as kb,i as Cb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as Nb}from"./PluginPane-CaJz1LlW.js";import{a as Ja,s as Xn,r as af,o as Zl,b as ec}from"./vendor-zod-BSoePkpP.js";import{u as Ab}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as Pb}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as lf}from"./vendor-cron-parser-CjvYVigk.js";const Db="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",Ib="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",Ai=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Db:t.id==="terminal"?Ib:void 0}),tc=t=>{const e=Ze.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let x;return e[3]!==u?(x=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=x):x=e[4],x}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Me("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:h,children:d}),e[6]=d,e[7]=f):f=e[7],f},Tb=t=>{const e=Ze.c(75),{directory:n,className:r}=t,{t:i}=St(),o=On(Eb),l=On(Rb),a=On(Mb),d=On(Ob),u=On(Bb),h=On(Fb),f=On(Lb);let p,x;e[0]!==u?(p=()=>{u()},x=[u],e[0]=u,e[1]=p,e[2]=x):(p=e[1],x=e[2]),c.useEffect(p,x);const b=en()&&Qo();let k;e:{let ve;e[3]!==l||e[4]!==o?(ve=l.find(U=>U.id===o)??l.find(_b)??l[0]??Xl[0],e[3]=l,e[4]=o,e[5]=ve):ve=e[5];const pe=ve;if(pe){let U;e[6]!==pe?(U=Ai(pe),e[6]=pe,e[7]=U):U=e[7],k=U;break e}let Ne;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ne=Ai(Xl[0]),e[8]=Ne):Ne=e[8],k=Ne}const y=k;if(!b||!n||l.length===0)return null;let m;e[9]!==n?(m=async ve=>{await Ym(n,ve.id,ve.appName)||await Qm(n,ve.appName)},e[9]=n,e[10]=m):m=e[10];const g=m;let j;e[11]!==g||e[12]!==f?(j=async ve=>{await f(ve.id),await g(ve)},e[11]=g,e[12]=f,e[13]=j):j=e[13];const S=j;let w;e[14]!==n||e[15]!==i?(w=async()=>{(await Jn(n)).ok&&ze.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=w):w=e[16];const C=w;let v;e[17]!==r?(v=Me("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=v):v=e[18];let R;e[19]!==g||e[20]!==y?(R=()=>{g(y)},e[19]=g,e[20]=y,e[21]=R):R=e[21];const T=d&&"animate-pulse";let D;e[22]!==T?(D=Me("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",T),e[22]=T,e[23]=D):D=e[23];let F;e[24]!==y.label||e[25]!==i?(F=i("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=i,e[26]=F):F=e[26];let B;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(B=s.jsx(tc,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=B):B=e[30];let E;e[31]!==D||e[32]!==F||e[33]!==B||e[34]!==R?(E=s.jsx("button",{type:"button",onClick:R,className:D,"aria-label":F,children:B}),e[31]=D,e[32]=F,e[33]=B,e[34]=R,e[35]=E):E=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=Me("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=$):$=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let X;e[39]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=X):X=e[39];let Y;e[40]!==L?(Y=s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:$,"aria-label":L,children:X})}),e[40]=L,e[41]=Y):Y=e[41];let I;e[42]!==C?(I=()=>{C()},e[42]=C,e[43]=I):I=e[43];let P;e[44]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(O,{name:"file-copy",className:"h-4 w-4"}),e[44]=P):P=e[44];let A;e[45]!==i?(A=i("openInApp.actions.copyPath"),e[45]=i,e[46]=A):A=e[46];let q;e[47]!==A?(q=s.jsx("span",{className:"typography-ui-label text-foreground",children:A}),e[47]=A,e[48]=q):q=e[48];let K;e[49]!==I||e[50]!==q?(K=s.jsxs(_t,{className:"flex items-center gap-2",onClick:I,children:[P,q]}),e[49]=I,e[50]=q,e[51]=K):K=e[51];let te;e[52]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(gs,{}),e[52]=te):te=e[52];let ae;if(e[53]!==l||e[54]!==S||e[55]!==y.id){let ve;e[57]!==S||e[58]!==y.id?(ve=pe=>{const Ne=Ai(pe);return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{S(pe)},children:[s.jsx(tc,{label:pe.label,iconDataUrl:pe.iconDataUrl,fallbackIconDataUrl:Ne.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:pe.label}),y.id===pe.id?s.jsx(O,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},pe.id)},e[57]=S,e[58]=y.id,e[59]=ve):ve=e[59],ae=l.map(ve),e[53]=l,e[54]=S,e[55]=y.id,e[56]=ae}else ae=e[56];let re;e[60]!==a||e[61]!==h||e[62]!==i?(re=a?s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(O,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=re):re=e[63];let he;e[64]!==K||e[65]!==ae||e[66]!==re?(he=s.jsxs(Ds,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[K,te,ae,re]}),e[64]=K,e[65]=ae,e[66]=re,e[67]=he):he=e[67];let ce;e[68]!==Y||e[69]!==he?(ce=s.jsxs(Is,{children:[Y,he]}),e[68]=Y,e[69]=he,e[70]=ce):ce=e[70];let Te;return e[71]!==E||e[72]!==ce||e[73]!==v?(Te=s.jsxs("div",{className:v,children:[E,ce]}),e[71]=E,e[72]=ce,e[73]=v,e[74]=Te):Te=e[74],Te};function Eb(t){return t.selectedAppId}function Rb(t){return t.availableApps}function Mb(t){return t.isCacheStale}function Ob(t){return t.isScanning}function Bb(t){return t.initialize}function Fb(t){return t.loadInstalledApps}function Lb(t){return t.selectApp}function _b(t){return t.id===tb}const _o=new Map,la=new Set,cf=()=>{for(const t of la)t()},Pi=(t,e)=>{const n=t.trim();n&&(e.length===0?_o.delete(n):_o.set(n,[...e]),cf())},$b=t=>{_o.delete(t.trim())&&cf()},df=[],zb=t=>_o.get(t.trim())??df,Wb=t=>(la.add(t),()=>{la.delete(t)}),Kb=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=()=>zb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Wb,n,Vb)};function Vb(){return df}const Ub=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Hb=["dev","start","preview","serve"];async function Gb(t,e,n){if(!t)return null;const r=Qb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Xb(n);if(i){const o=await Jb(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await qb(t)){const i=await Yb(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function qb(t){const e=`${t}/index.html`,n=await $o(e,t);return typeof n=="string"&&n.trim().length>0}async function Yb(){try{const t=await ls("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Qb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Hb.some(i=>n.includes(i)))return e}return null}function Xb(t){for(const{pattern:e}of Ub)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Jb(t){const e=await $o(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await $o(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function $o(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Fd()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ls(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Zb(t){try{const e=await $o(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const Ys="__openchamber_auto_discover_preview__",ey=15e3,ty=3e3,Di=t=>t.id===Ys?"scan-2":Th.find(n=>n.key===t.icon)?.Icon??"play",sy=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},ny=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=St(),{currentTheme:l}=Cn(),{terminal:a,runtime:d}=nn(),u=Zn(),{isMobile:h}=Nn(),f=c.useMemo(()=>en(),[]),p=Cl(se=>se.instances),x=Cl(se=>se.load),b=Ae(se=>se.terminalShell),k=Ae(se=>se.terminalLoginShells.includes(se.terminalShell)),y=Ae(se=>se.setSettingsPage),m=Ae(se=>se.setSettingsDialogOpen),g=Ae(se=>se.setSettingsProjectsSelectedId),j=Ae(se=>se.openContextPreview),S=Rt(se=>se.ensureDirectory),w=Rt(se=>se.reconcileServerSessions),C=Rt(se=>se.setTabLabel),v=Rt(se=>se.setTabIconKey),R=Rt(se=>se.setActiveTab),T=Rt(se=>se.setConnecting),D=Rt(se=>se.setTabSessionId),F=Rt(se=>se.setTabPurpose),B=Rt(se=>se.allocateActionExecution),E=Rt(se=>se.setTabLifecycle),$=Rt(se=>se.setTabPreviewUrl),L=Rt(se=>se.matchesActionExecution),X=Rt(se=>se.captureStartedActionMutationRevisions),[Y,I]=c.useState([]),P=c.useRef(null),[A,q]=c.useState(null),[K,te]=c.useState(!1),ae=c.useRef({}),re=c.useRef({}),he=c.useRef({}),ce=c.useRef(new Set),Te=c.useRef(0),[ve,pe]=c.useState({}),Ne=t?.id??null,U=t?.path??"",Z=c.useMemo(()=>Ne?{id:Ne,path:U}:null,[Ne,U]);c.useEffect(()=>{f&&x().catch(()=>{})},[f,x]);const de=c.useCallback(async se=>{await Qr(se)},[]),ye=c.useCallback(async()=>{if(!Z)return;const se=Te.current+1;Te.current=se,te(!0);try{const me=await Dl(Z);if(Te.current!==se)return;P.current=me;const Ie=me.projectActions;I(Ie),q(We=>We===Ys||We&&Ie.some(V=>V.id===We)?We:null)}catch{if(Te.current!==se)return}finally{Te.current===se&&te(!1)}},[Z]),H=c.useMemo(()=>Si(e||Z?.path||""),[e,Z?.path]),je=c.useMemo(()=>Si(Z?.path||""),[Z?.path]),Ee=c.useMemo(()=>Si(u||"")||H,[u,H]),ge=c.useRef(Ee);c.useEffect(()=>{ge.current=Ee},[Ee]);const ne=Rt(se=>H?se.getDirectoryState(H):void 0),be=Rt(se=>je&&je!==H?se.getDirectoryState(je):void 0),G=c.useMemo(()=>{const se=H?[{directory:H,state:ne}]:[];return je&&je!==H&&se.push({directory:je,state:be}),se},[ne,H,je,be]),z=c.useMemo(()=>{const se=H?[H]:[];return je&&je!==H&&se.push(je),se},[H,je]),J=c.useCallback(se=>se.id!==Ys&&se.runIn==="parent"&&je||H,[H,je]),ue=c.useCallback((se,me,Ie)=>`${se}::${me}::${Ie}`,[]),le=c.useCallback((se,me,Ie=Rt.getState())=>se?Ie.getDirectoryState(se)?.tabs.find(We=>We.purpose.type==="project-action"&&We.purpose.actionId===me)??null:null,[]),W=c.useMemo(()=>{const se={};for(const{directory:me,state:Ie}of G)for(const We of Ie?.tabs??[]){if(We.purpose.type!=="project-action"||!We.purpose.executionId||!We.terminalSessionId||We.lifecycle==="idle"||We.lifecycle==="exited")continue;const V=Gs(me,We.purpose.actionId),Fe=ue(me,We.purpose.actionId,We.purpose.executionId);se[V]={directory:me,actionId:We.purpose.actionId,tabId:We.id,sessionId:We.terminalSessionId,executionId:We.purpose.executionId,status:We.lifecycle==="stopping"?"stopping":ve[Fe]?"waiting-for-preview":"running"}}return se},[ue,ve,G]),M=c.useCallback((se,me,Ie)=>{const We=Gs(se,me),V=ue(se,me,Ie),Ye=ae.current[We]?.executionId===Ie,Qe=globalThis.window,xe=st=>{Qe?.clearTimeout(he.current[st]),delete he.current[st]};Ye&&(delete ae.current[We],xe(We)),re.current[V]?.(),delete re.current[V],xe(V),pe(st=>{if(!st[V])return st;const Re={...st};return delete Re[V],Re})},[ue]),_=c.useCallback(se=>{re.current[se]?.(),delete re.current[se]},[]),ee=c.useCallback(se=>{window.clearTimeout(he.current[se]),delete he.current[se]},[]);c.useEffect(()=>{const se=re.current,me=he.current;return()=>{for(const Ie of Object.keys(se))_(Ie);for(const Ie of Object.keys(me))ee(Ie)}},[ee,_]),c.useEffect(()=>{const se=new Set(z);for(const me of Object.values(ae.current))se.has(me.directory)||M(me.directory,me.actionId,me.executionId);for(const me of Object.keys(re.current)){const Ie=me.split("::",1)[0]??"";se.has(Ie)||_(me)}},[M,_,z]);const oe=c.useCallback((se,me)=>{Ae.getState().openContextPanelTab(se,{mode:"terminal",targetDirectory:me===se?null:me})},[]),fe=c.useMemo(()=>A?Y.find(se=>se.id===A)??null:null,[Y,A]),ie=c.useMemo(()=>({id:Ys,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Le=!h,$e=c.useMemo(()=>Le?[ie,...Y]:Y,[Y,ie,Le]);c.useEffect(()=>{ye()},[ye]),c.useEffect(()=>{const se=z.map(me=>Vi(a,me,X,Ie=>w(me,Ie.sessions,{startedActionMutationRevisions:Ie.startedActionMutationRevisions})));return()=>{for(const me of se)me()}},[X,w,a,z]),c.useEffect(()=>{for(const{directory:se,state:me}of G)if(se)for(const Ie of me?.tabs??[]){if(Ie.purpose.type!=="project-action")continue;const We=Ie.purpose.actionId,V=$e.find(Qe=>Qe.id===We),Fe=V?.name??We,Ye=V?.icon||"play";Ie.label!==Fe&&C(se,Ie.id,Fe),Ie.iconKey!==Ye&&v(se,Ie.id,Ye)}},[$e,v,C,G]),c.useEffect(()=>{const se=globalThis.window;if(!se)return;const me=Ie=>{const We=Ie.detail;Ne&&(We?.projectId&&We.projectId!==Ne||ye())};return se.addEventListener(Nl,me),()=>{se.removeEventListener(Nl,me)}},[ye,Ne]),c.useEffect(()=>{A&&(A===Ys&&Le||Y.some(se=>se.id===A)||q(null))},[Y,Le,A]),c.useEffect(()=>{const se=Ie=>{delete he.current[Ie];const We=ae.current[Ie];if(!We||We.openedUrl)return;const V=ue(We.directory,We.actionId,We.executionId),Fe=We.announced;if(Fe.length!==0){if(window.clearTimeout(he.current[V]),delete he.current[V],We.openedUrl=!0,pe(Ye=>{if(!Ye[V])return Ye;const Qe={...Ye};return delete Qe[V],Qe}),Fe.length===1){Pi(We.directory,[]),$(We.directory,We.tabId,Fe[0],{locked:!1,autoOpened:!0}),j(We.directory,Fe[0]);return}We.offering=!0,Pi(We.directory,Fe),Ae.getState().openContextSurface(We.directory,"browser"),ze.info(o("projectActions.toast.multipleServers"))}},me=()=>{const Ie=Rt.getState(),We=Ie.sessions,V=W;for(const[Fe,Ye]of Object.entries(V)){const xe=We.get(Ye.directory)?.tabs.find(lt=>lt.id===Ye.tabId);if(!xe||xe.terminalSessionId!==Ye.sessionId){M(Ye.directory,Ye.actionId,Ye.executionId);continue}const st=ae.current[Fe],Re=st?.executionId===Ye.executionId?st:{hostDirectory:ge.current||Ye.directory,directory:Ye.directory,tabId:Ye.tabId,actionId:Ye.actionId,executionId:Ye.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ae.current[Fe]=Re;const ot=$e.find(lt=>lt.id===Ye.actionId),vt=Ie.getBuffer(Ye.directory,Ye.tabId).chunks;if(!ot||vt.length===0)continue;const De=vt.filter(lt=>Re.lastSeenChunkId===null||lt.id>Re.lastSeenChunkId);if(De.length===0)continue;const gt=De.map(lt=>lt.data).join(""),Ct=`${Re.tail}${gt}`;if(Re.openInPreview&&(!Re.openedUrl||Re.offering)){const lt=Dh(Ct),_e=Re.announced.length;for(const Je of lt)Re.announced.includes(Je)||Re.announced.push(Je);const Ge=Re.announced.length-_e;Re.offering&&Ge>0?Pi(Ye.directory,Re.announced):!Re.openedUrl&&_e===0&&Re.announced.length>0&&(window.clearTimeout(he.current[Fe]),he.current[Fe]=window.setTimeout(()=>se(Fe),ty))}const He=!Re.openedUrl&&ot.autoOpenUrl===!0&&!Re.openInPreview?Ih(Ct):null,Ue=De[De.length-1]?.id??Re.lastSeenChunkId;if(Re.lastSeenChunkId=Ue,Re.tail=Ct.slice(-512),He)if(Re.openedUrl=!0,Re.openInPreview){const lt=V[Fe];lt&&($(lt.directory,lt.tabId,He,{locked:!1,autoOpened:!1,expectedExecutionId:lt.executionId}),lt.status==="waiting-for-preview"&&pe(_e=>{const Ge=ue(lt.directory,lt.actionId,lt.executionId);if(!_e[Ge])return _e;const Je={..._e};return delete Je[Ge],Je}),window.clearTimeout(he.current[Fe]),delete he.current[Fe],j(lt.directory,He))}else de(He),ze.success(o("projectActions.toast.openedUrlFromOutput"));ae.current[Fe]=Re}for(const Fe of Object.keys(ae.current))if(!V[Fe]){const Ye=ae.current[Fe],Qe=Ye?We.get(Ye.directory)?.tabs.find(st=>st.id===Ye.tabId):void 0;if(Qe?.purpose.type==="project-action"&&Qe.purpose.executionId===Ye?.executionId&&!!Qe.terminalSessionId&&Qe.lifecycle!=="idle"&&Qe.lifecycle!=="exited")continue;delete ae.current[Fe],window.clearTimeout(he.current[Fe]),delete he.current[Fe]}};return me(),Rt.subscribe((Ie,We)=>{(Ie.sessions!==We.sessions||Ie.buffers!==We.buffers)&&me()})},[M,ge,$e,ue,j,de,W,$,o]),c.useEffect(()=>{for(const{directory:se,state:me}of G)for(const Ie of me?.tabs??[]){if(Ie.purpose.type!=="project-action"||!Ie.purpose.executionId||!Ie.terminalSessionId||Ie.lifecycle!=="running")continue;const We=Ie.purpose.actionId,V=Ie.purpose.executionId,Fe=ue(se,We,V);if(re.current[Fe])continue;const Ye=a.connect(Ie.terminalSessionId,{onEvent:Qe=>{if(!L(se,Ie.id,V))return;Qe.type==="snapshot"&&(Rt.getState().replaceBuffer(se,Ie.id,Qe.data??"",Qe.sequence??0,xl(Qe)),Qe.status==="running"&&Rt.getState().setTabLifecycle(se,Ie.id,"running",{expectedExecutionId:V}),Qe.status==="exited"&&(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V)));const xe=Qe.type==="data"?Qe.data??"":"";xe&&Rt.getState().appendToBuffer(se,Ie.id,xe,Qe.sequence,Qe.replayData),Qe.type==="exit"&&(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V))},onError:(Qe,xe)=>{!xe||!L(se,Ie.id,V)||(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabSessionId(se,Ie.id,null,{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V))}},se);re.current[Fe]=Ye.close}},[M,ue,L,a,G]);const Pe=c.useCallback(async se=>{const me=J(se);if(!me)throw new Error(o("projectActions.error.noActiveDirectory"));const Ie=Gs(me,se.id);S(me);const We=Rt.getState(),V=le(me,se.id,We),Fe=V?.id??We.createTab(me);C(me,Fe,se.name),v(me,Fe,se.icon||"play"),V||F(me,Fe,{type:"project-action",actionId:se.id,executionId:null}),R(me,Fe);const Qe=Rt.getState().getDirectoryState(me)?.tabs.find(xe=>xe.id===Fe);return{executionDirectory:me,key:Ie,tabId:Fe,sessionId:Qe?.terminalSessionId??null,executionId:Qe?.purpose.type==="project-action"?Qe.purpose.executionId:null}},[S,J,le,R,v,C,F,o]),Oe=c.useCallback(async se=>{if(d.isVSCode||!i&&h)return;if(!H){ze.error(o("projectActions.error.noActiveDirectoryForAction"));return}const me=Gs(J(se),se.id),Ie=W[me];if(Ie&&Ie.status==="running"||ce.current.has(me))return;ce.current.add(me);let We=null;try{const V=se.id===Ys?await(async()=>{const[Ge,Je]=await Promise.all([gp({id:Z?.id??"",path:H}),Zb(H)]),at=await Gb(H,Ge.actions,Je);if(!at)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Ys,name:o("projectActions.actions.autoDiscover"),command:at.command,icon:"scan-2",autoOpenUrl:!0,openUrl:at.previewUrlHint||""}})():se,Fe=V.autoOpenUrl===!0&&(V.openUrl||"").trim().length>0,Ye=!Fe&&se.id!==Ys,Qe=ge.current||H,{executionDirectory:xe,key:st,tabId:Re}=await Pe(V),ot=kh(V.command);if(!ot)throw new Error(o("projectActions.error.failedToRunAction"));const vt=V.autoOpenUrl===!0&&f&&(V.desktopOpenSshForward||"").trim().length>0,De=V.autoOpenUrl?sy(V.openUrl):null,gt=V.autoOpenUrl&&f?Ch(V.desktopOpenSshForward,p):null;if(a.listSessions){const Ge=le(xe,V.id);if(Ge?.purpose.type==="project-action"&&Ge.purpose.executionId===null){const Je=await Nh(a,xe,{captureStartedActionMutationRevisions:X});Je&&w(xe,Je.sessions,{startedActionMutationRevisions:Je.startedActionMutationRevisions})}}const Ct=le(xe,V.id);let He,Ue;if(Ct?.lifecycle==="running"&&Ct.terminalSessionId&&Ct.purpose.type==="project-action"&&Ct.purpose.executionId)He=Ct.terminalSessionId,Ue=Ct.purpose.executionId;else{const Ge=Ct?.purpose.type==="project-action"?Ct.purpose.executionId:null;Ge&&M(xe,V.id,Ge);const Je=B(xe,Re,V.id);if(!Je)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));We={directory:xe,tabId:Re,id:Je},T(xe,Re,!0,{expectedExecutionId:Je});const at=await Ah({terminal:a,createOptions:{cwd:xe,shell:b,loginShell:k,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:ot,isRunStillExpected:()=>L(xe,Re,Je),purpose:{type:"project-action",actionId:V.id,executionId:Je}});if(!L(xe,Re,Je)){at.sessionId===Je&&await a.close(at.sessionId).catch(()=>{});return}Ue=at.purpose?.type==="project-action"?at.purpose.executionId:Je,He=at.sessionId,F(xe,Re,{type:"project-action",actionId:V.id,executionId:Ue}),D(xe,Re,He,{expectedExecutionId:Ue}),T(xe,Re,!1,{expectedExecutionId:Ue})}Ye&&Qe&&oe(Qe,xe),ae.current[st]={hostDirectory:Qe,directory:xe,tabId:Re,actionId:V.id,executionId:Ue,lastSeenChunkId:null,openedUrl:!!gt||!!De||Fe,tail:"",openInPreview:V.id===Ys,announced:[],offering:!1};const lt=ue(xe,V.id,Ue);T(xe,Re,!0,{expectedExecutionId:Ue});const _e=a.connect(He,{onEvent:Ge=>{if(!L(xe,Re,Ue)||Ge.purpose?.type==="project-action"&&Ge.purpose.executionId!==Ue)return;Ge.type==="snapshot"&&(Rt.getState().replaceBuffer(xe,Re,Ge.data??"",Ge.sequence??0,xl(Ge)),Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Ge.purpose?.type==="project-action"&&Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:Ge.purpose.actionId,executionId:Ge.purpose.executionId}),Ge.status==="running"&&Rt.getState().setTabLifecycle(xe,Re,"running",{expectedExecutionId:Ue}),Ge.status==="exited"&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue)));const Je=Ge.type==="data"?Ge.data??"":"";Je&&Rt.getState().appendToBuffer(xe,Re,Je,Ge.sequence,Ge.replayData),Ge.type==="exit"&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue))},onError:(Ge,Je)=>{L(xe,Re,Ue)&&(Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Je&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setTabSessionId(xe,Re,null,{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue)))}},xe);if(!L(xe,Re,Ue)){_e.close();return}re.current[lt]?.(),re.current[lt]=_e.close,window.clearTimeout(he.current[lt]),delete he.current[lt],V.id===Ys&&!De&&(pe(Ge=>({...Ge,[lt]:!0})),he.current[lt]=window.setTimeout(()=>{delete he.current[lt];const Ge=ae.current[st];!Ge||Ge.executionId!==Ue||Ge.openedUrl||Ge.offering||L(xe,Re,Ue)&&(pe(Je=>{if(!Je[lt])return Je;const at={...Je};return delete at[lt],at}),Rt.getState().setActiveTab(xe,Re),oe(Ge.hostDirectory,xe))},ey)),gt?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),de(gt),ze.success(o("projectActions.toast.openedForwardedUrl"))):De?($(xe,Re,De,{locked:!0,autoOpened:!0,expectedExecutionId:Ue}),j(Qe,De),ze.success(o("projectActions.toast.openedActionUrl"))):Fe?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),ze.error(o("projectActions.error.invalidCustomUrlFormat"))):vt?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),ze.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(xe,Re,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ue})}catch(V){if(We&&L(We.directory,We.tabId,We.id)){const{directory:Fe,tabId:Ye,id:Qe}=We;M(Fe,se.id,Qe),E(Fe,Ye,"exited",{expectedExecutionId:Qe}),F(Fe,Ye,{type:"project-action",actionId:se.id,executionId:null})}if(V instanceof Error&&V.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(V instanceof Error&&(V.message==="COMMAND_MODE_UNSUPPORTED"||V.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){ze.error(o("projectActions.error.failedToCreateTerminalSession"));return}ze.error(V instanceof Error?V.message:o("projectActions.error.failedToRunAction"))}finally{ce.current.delete(me)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,ge,p,Pe,i,h,f,H,k,b,de,j,W,oe,d.isVSCode,J,L,M,ue,le,w,B,X,T,E,F,$,D,Z?.id,o,a]),Q=c.useCallback(async se=>{const me=Gs(J(se),se.id),Ie=W[me];Ie&&await Ph({terminal:a,sessionId:Ie.sessionId,isExecutionStillCurrent:()=>L(Ie.directory,Ie.tabId,Ie.executionId),markStopping:()=>{E(Ie.directory,Ie.tabId,"stopping",{expectedExecutionId:Ie.executionId})},restoreRunning:()=>{E(Ie.directory,Ie.tabId,"running",{expectedExecutionId:Ie.executionId})},clearSession:()=>{D(Ie.directory,Ie.tabId,null,{expectedExecutionId:Ie.executionId})},finalizeExit:()=>{E(Ie.directory,Ie.tabId,"exited",{expectedExecutionId:Ie.executionId}),F(Ie.directory,Ie.tabId,{type:"project-action",actionId:Ie.actionId,executionId:null}),M(Ie.directory,Ie.actionId,Ie.executionId)}})},[M,J,L,W,E,F,D,a]),Ce=c.useCallback(()=>{const se=fe??$e[0];if(!se)return;const me=Gs(J(se),se.id),Ie=W[me];if(Ie?.status!=="stopping"){if(Ie){Q(se);return}Oe(se)}},[$e,J,Oe,W,fe,Q]),Se=c.useCallback(async se=>{if(se.source==="shared"&&Z){const me=P.current?.trust.trusted?P.current:await Dl(Z);if(P.current=me,!await xp(Z,me))return;P.current={...me,trust:{...me.trust,trusted:!0}}}await Oe(se)},[Oe,Z]),Ke=c.useCallback((se,me=!1)=>{if(q(se.id),!me){Se(se);return}const Ie=Gs(J(se),se.id),We=W[Ie];if(We?.status!=="stopping"){if(We){Q(se);return}Se(se)}},[J,Se,W,Q]),et=c.useCallback(()=>{Z?.id&&(g(Z.id),y("projects"),m(!0))},[m,y,g,Z?.id]),it=fe??$e[0]??null,rt=it?W[Gs(J(it),it.id)]:null,pt=Rt(se=>rt?se.getDirectoryState(rt.directory)?.tabs.find(me=>me.id===rt.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&h||!Z||!H)return null;const ht=fe??$e[0]??null;if(!ht)return null;const tt=Di(ht),At=Gs(J(ht),ht.id),jt=W[At],we=jt?.status==="stopping",Xe=jt?.status==="waiting-for-preview",mt=!!(jt&&pt),qe=()=>{!jt||!pt||j(jt.directory,pt)},ft=ht.id===Ys;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:K||we,className:Me("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:Ce,"aria-label":jt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:we||Xe?s.jsx(O,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):jt?s.jsx(O,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(O,{name:tt,className:"h-5 w-5"})})}),ft?s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),mt?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:qe,children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ds,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:et,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(gs,{}),$e.map(se=>{const me=Di(se),Ie=Gs(J(se),se.id),We=W[Ie],V=!!We,Fe=We?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ke(se,!0)},children:[s.jsx(O,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:se.name}),se.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||We?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},se.id)})]})]})]}):s.jsxs("div",{className:Me("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ce,disabled:K||we,className:Me("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":jt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:we||Xe?s.jsx(O,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):jt?s.jsx(O,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(O,{name:tt,className:"h-4 w-4"})})})}),ft?s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),mt?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:qe,className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ds,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:et,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(gs,{}),$e.map(se=>{const me=Di(se),Ie=Gs(J(se),se.id),We=W[Ie],V=!!We,Fe=We?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ke(se,!0)},children:[s.jsx(O,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:se.name}),se.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||We?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},se.id)})]})]})]})},Fr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ry=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Fr(n??"");if(i){const o=ou(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function oy(){const t=zt(b=>b.projects),e=zt(b=>b.activeProjectId),n=nt(b=>b.availableWorktreesByProject),r=nt(b=>b.currentSessionId),i=bp(r??null),o=nt(b=>r?b.worktreeMetadata.get(r)?.path??"":""),l=nt(b=>b.newSessionDraft?.open?Fr(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Fr(o||""),[o]),d=c.useMemo(()=>{const b=typeof i?.directory=="string"?i.directory:"";return Fr(b||"")},[i?.directory]),u=a||d||l,h=c.useMemo(()=>ry({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>Fr(u||h?.path||""),[u,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),x=c.useRef(null);return c.useEffect(()=>{p&&f&&(x.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:x.current,[p,f])}const iy=({transform:t})=>({...t,y:0}),ay={Item:_t,Separator:gs},ly={Item:({className:t,...e})=>s.jsx(sf,{className:Me(cu,t),...e}),Separator:({className:t,...e})=>s.jsx(tf,{className:Me(lu,t),...e})},cy=t=>{const e=Ze.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:h}=t,{t:f}=St(),[p,x]=c.useState(!1),[b,k]=c.useState(!1),[y,m]=c.useState(!1);let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:j,listeners:S,setNodeRef:w,transform:C,transition:v,isDragging:R}=di(g);let T;e[2]!==f||e[3]!==n.session.title?(T=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=T):T=e[4];const D=T,F=!i&&(p||b),B=n.id;let E;e[5]!==n.session?(E=xs(n.session),e[5]=n.session,e[6]=E):E=e[6];const $=Ma(B,E),L=iu(n.id),Y=au(n.id)>0&&!r&&!L,I=L||Y;let P;e[7]!==L||e[8]!==f?(P=f(L?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=L,e[8]=f,e[9]=P):P=e[9];const A=P;let q;e[10]!==d||e[11]!==y||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(q=je=>({session:n.session,open:p||y,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:je}),e[10]=d,e[11]=y,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=q):q=e[16];const K=q;let te;e[17]!==C?(te=ui.Translate.toString(C),e[17]=C,e[18]=te):te=e[18];let ae;e[19]!==te||e[20]!==v?(ae={transform:te,transition:v},e[19]=te,e[20]=v,e[21]=ae):ae=e[21];const re=R&&"z-10 opacity-60";let he;e[22]!==re?(he=Me("session-tab-slot flex h-7 w-44 shrink-0 touch-none",re),e[22]=re,e[23]=he):he=e[23];const ce=r?"true":"false";let Te;e[24]!==r?(Te=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Te):Te=e[25];let ve;e[26]!==u?(ve=je=>u?.(je),e[26]=u,e[27]=ve):ve=e[27];let pe;e[28]!==h||e[29]!==A||e[30]!==r||e[31]!==$||e[32]!==L||e[33]!==K||e[34]!==p||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==F||e[39]!==a||e[40]!==I||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==D?(pe=s.jsx(nf,{render:je=>s.jsxs("div",{...je,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),o(n))},onAuxClick:Ee=>{Ee.button===1&&(Ee.preventDefault(),l(n.id))},"data-controls-open":F?"true":"false",className:Me("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Me("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",F&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Me("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",F&&"pr-10"),children:[s.jsx("div",{className:Me("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:D})})}),$?s.jsx(O,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):I?s.jsx(Oa,{state:L?"running":"unread",label:A,className:Me("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",F&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:uy,onPointerDown:fy,className:Me("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",F&&"flex opacity-100"),children:[s.jsxs(Is,{open:p,onOpenChange:Ee=>{x(Ee),Ee&&k(!0)},onOpenChangeComplete:Ee=>{Ee||k(!1),u?.(Ee)},children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsx(Ds,{align:"start",className:"min-w-[190px]",children:a(K(ay))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=A,e[30]=r,e[31]=$,e[32]=L,e[33]=K,e[34]=p,e[35]=l,e[36]=u,e[37]=o,e[38]=F,e[39]=a,e[40]=I,e[41]=i,e[42]=f,e[43]=n,e[44]=D,e[45]=pe):pe=e[45];let Ne,U;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ne={color:"var(--surface-elevated-foreground)"},U=Me(Gi,"min-w-[190px]"),e[46]=Ne,e[47]=U):(Ne=e[46],U=e[47]);let Z;e[48]!==K||e[49]!==a?(Z=a(K(ly)),e[48]=K,e[49]=a,e[50]=Z):Z=e[50];let de;e[51]!==Z?(de=s.jsx(oa,{children:s.jsx(ia,{className:"app-region-no-drag z-50",children:s.jsx(aa,{"data-slot":"dropdown-menu-content",style:Ne,className:U,children:Z})})}),e[51]=Z,e[52]=de):de=e[52];let ye;e[53]!==y||e[54]!==ve||e[55]!==pe||e[56]!==de?(ye=s.jsxs(rf,{open:y,onOpenChange:m,onOpenChangeComplete:ve,children:[pe,de]}),e[53]=y,e[54]=ve,e[55]=pe,e[56]=de,e[57]=ye):ye=e[57];let H;return e[58]!==j||e[59]!==S||e[60]!==w||e[61]!==he||e[62]!==ce||e[63]!==Te||e[64]!==ye||e[65]!==ae?(H=s.jsx("div",{ref:w,style:ae,className:he,"data-active":ce,...Te,...j,...S,children:ye}),e[58]=j,e[59]=S,e[60]=w,e[61]=he,e[62]=ce,e[63]=Te,e[64]=ye,e[65]=ae,e[66]=H):H=e[66],H},dy=t=>{const e=Ze.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=St(),d=oo(my),u=oo(hy),h=oo(py),f=oo(gy),p=nt(xy),x=nt(by),b=us(yy);let k,y;e[0]!==p||e[1]!==u?(k=()=>{p&&u(p)},y=[p,u],e[0]=p,e[1]=u,e[2]=k,e[3]=y):(k=e[2],y=e[3]),c.useEffect(k,y);let m;if(e[4]!==b){m=new Map;for(const ge of b)m.set(ge.id,ge);e[4]=b,e[5]=m}else m=e[5];const g=m;let j;if(e[6]!==g||e[7]!==d){j=[];for(const ge of d){const ne=g.get(ge);ne&&j.push({id:ge,session:ne})}e[6]=g,e[7]=d,e[8]=j}else j=e[8];const S=j;let w;e[9]!==x?(w=ge=>{x(ge.id,xs(ge.session))},e[9]=x,e[10]=w):w=e[10];const C=w,v=wy;let R;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==S?(R=ge=>{if(h(ge),p&&p!==ge){const ne=S.find(be=>be.id===ge);ne&&C(ne)}},e[11]=h,e[12]=p,e[13]=C,e[14]=S,e[15]=R):R=e[15];const T=R;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{distance:8}},e[16]=D):D=e[16];let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{delay:200,tolerance:6}},e[17]=F):F=e[17];const B=oi(fn(ai,D),fn(ii,F));let E;e[18]!==f?(E=ge=>{const{active:ne,over:be}=ge;be&&ne.id!==be.id&&f(String(ne.id),String(be.id))},e[18]=f,e[19]=E):E=e[19];const $=E,L=c.useRef(null);let X;e[20]===Symbol.for("react.memo_cache_sentinel")?(X={left:!1,right:!1},e[20]=X):X=e[20];const[Y,I]=c.useState(X);let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const ge=L.current;if(!ge)return;const ne=ge.scrollLeft>2,be=ge.scrollLeft+ge.clientWidth<ge.scrollWidth-2;I(G=>G.left===ne&&G.right===be?G:{left:ne,right:be})},e[21]=P):P=e[21];const A=P;let q;e[22]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{A();const ge=L.current;if(!ge||!globalThis.ResizeObserver)return;const ne=new ResizeObserver(A);return ne.observe(ge),()=>ne.disconnect()},e[22]=q):q=e[22];let K;e[23]!==S.length?(K=[A,S.length],e[23]=S.length,e[24]=K):K=e[24],c.useEffect(q,K);let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=te):te=e[25];let ae;e[26]!==p?(ae=[p],e[26]=p,e[27]=ae):ae=e[27],c.useEffect(te,ae);const re=Y.left&&Y.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":Y.left?"linear-gradient(to right, transparent, black 24px)":Y.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let he;e[28]!==S?(he=S.map(vy),e[28]=S,e[29]=he):he=e[29];const ce=he;let Te;e[30]!==p||e[31]!==S?(Te=!p||!S.some(ge=>ge.id===p),e[30]=p,e[31]=S,e[32]=Te):Te=e[32];const ve=Te;let pe;e[33]!==a?(pe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=pe):pe=e[34];let Ne;e[35]!==re?(Ne=re?{maskImage:re,WebkitMaskImage:re}:void 0,e[35]=re,e[36]=Ne):Ne=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=[iy],e[37]=U):U=e[37];let Z;e[38]!==o||e[39]!==p||e[40]!==T||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==S?(Z=S.map(ge=>s.jsx(cy,{tab:ge,isActive:ge.id===p,suppressControls:ge.id===p&&l,onSelect:C,onClose:v,renderMenu:n,closeOtherTabs:T,onMenuOpenChangeComplete:r,children:ge.id===p?o:null},ge.id)),e[38]=o,e[39]=p,e[40]=T,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=S,e[46]=Z):Z=e[46];let de;e[47]!==Z||e[48]!==ce?(de=s.jsx(Xa,{items:ce,strategy:mb,children:Z}),e[47]=Z,e[48]=ce,e[49]=de):de=e[49];let ye;e[50]!==$||e[51]!==B||e[52]!==de?(ye=s.jsx(li,{sensors:B,collisionDetection:ci,modifiers:U,onDragEnd:$,children:de}),e[50]=$,e[51]=B,e[52]=de,e[53]=ye):ye=e[53];let H;e[54]!==o||e[55]!==ve?(H=ve?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=ve,e[56]=H):H=e[56];let je;e[57]!==Ne||e[58]!==ye||e[59]!==H?(je=s.jsxs("div",{ref:L,onScroll:A,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ne,children:[ye,H]}),e[57]=Ne,e[58]=ye,e[59]=H,e[60]=je):je=e[60];let Ee;return e[61]!==pe||e[62]!==je?(Ee=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":pe,children:je}),e[61]=pe,e[62]=je,e[63]=Ee):Ee=e[63],Ee};function uy(t){return t.stopPropagation()}function fy(t){return t.stopPropagation()}function my(t){return t.tabIds}function hy(t){return t.ensureTab}function py(t){return t.closeOtherTabs}function gy(t){return t.reorderTabs}function xy(t){return t.currentSessionId}function by(t){return t.setCurrentSession}function yy(t){return t.activeSessions}function wy(t){yp(t)}function vy(t){return t.id}const uf=async t=>{const{entry:e,session:n}=t,r=Wt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(wp(e.action)&&vp(e.guest,"conversation"))){await Il(e,Tl(e.action.id,i),t.t,r);return}let l=!1;const a=vr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Il(e,Tl(e.action.id,i,d),t.t,r)}};function ca(t){const e=Ze.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=St(),{pending:a,disabled:d,hint:u,run:h}=Eh(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let x;e[0]!==f||e[1]!==p?(x=s.jsx(O,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=x):x=e[2];let b;e[3]!==l?(b=l("sessions.aiRename.action"),e[3]=l,e[4]=b):b=e[4];let k;e[5]!==o||e[6]!==d||e[7]!==h||e[8]!==x||e[9]!==b?(k=s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:h,className:"w-full",children:[x,b]})})}),e[5]=o,e[6]=d,e[7]=h,e[8]=x,e[9]=b,e[10]=k):k=e[10];let y;e[11]!==u?(y=s.jsx(wt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let m;return e[13]!==k||e[14]!==y?(m=s.jsxs(bt,{children:[k,y]}),e[13]=k,e[14]=y,e[15]=m):m=e[15],m}const da=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class ff extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const fi=Zr(()=>({pendingSessionIds:new Set})),mf=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],fi(n)},sc=(t,e)=>{fi.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},Sy=async(t,e)=>{try{const d=(await Ap(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=xt(t),r=xt(e)??e,i=nt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>xt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},nc=t=>{for(const e of t){const n=jp(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class jy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const ky=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new jy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},Cy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(kp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await du(o,n,e),nt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},rc=async(t,e,n)=>{try{await fu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},oc=async(t,e)=>{const n=e?[t,e]:[t];try{await Ba(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},hf=async(t,e)=>{if(fi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");sc(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,nt.getState().getWorktreeMetadata(a.id)]));nc(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){nc(n.slice(a));try{await du(d,t.sourceDirectory,i.directory)}catch(u){throw Sp(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&nt.getState().setWorktreeMetadata(d.id,El(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await Cy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await oc(t.sourceDirectory,i?.directory),u.length>0)throw ky(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new ff(d):d}return nt.getState().setWorktreeMetadata(t.root.id,El(i.metadata)),await oc(t.sourceDirectory,i.directory),i.directory}finally{sc(t.root.id,!1)}},Ny=async t=>{const e=xt(t.sourceDirectory)??t.sourceDirectory,n=xt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return hf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Ay=async t=>hf(t,async()=>{const e=qi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await uu(t.sourceDirectory)?await Sy(t.sourceDirectory,e.path):null,r=await Cp(e,n?{startRef:n}:{});try{await Np(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return rc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>rc(e,r,i)}}),Py=t=>{(t.kind==="existing"?Ny({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):Ay({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>ze.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));ze.error(t.messages.failure,{description:r instanceof ff?t.messages.outcomeUnknown:r.message})})},ua=t=>{fi.getState().pendingSessionIds.has(t.root.id)||Py(t)},zo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",Dy=c.memo(function(e){const n=Ze.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:h}=e,f=r===void 0?!0:r,p=h===void 0?!1:h;if(!f)return null;const x=a??zo,b=p&&"bg-interactive-selection text-interactive-selection-foreground";let k;n[0]!==x||n[1]!==b?(k=Me(x,b),n[0]=x,n[1]=b,n[2]=k):k=n[2];const y=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==y?(m=s.jsx(O,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=m):m=n[5];let g;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==k||n[10]!==m?(g=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:k,children:m})}),n[6]=o,n[7]=l,n[8]=p,n[9]=k,n[10]=m,n[11]=g):g=n[11];let j;n[12]!==i?(j=s.jsx(wt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=j):j=n[13];let S;return n[14]!==g||n[15]!==j?(S=s.jsxs(bt,{children:[g,j]}),n[14]=g,n[15]=j,n[16]=S):S=n[16],S}),Iy=c.memo(function(e){const n=Ze.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:x}=e,{t:b}=St();let k;n[0]!==d||n[1]!==a?(k=B=>{a(B),B&&d()},n[0]=d,n[1]=a,n[2]=k):k=n[2];let y;n[3]!==i||n[4]!==r||n[5]!==b?(y=r?b("header.services.openWithCurrent",{current:i}):b("header.services.open"),n[3]=i,n[4]=r,n[5]=b,n[6]=y):y=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let g;n[7]!==m?(g=Me(zo,m),n[7]=m,n[8]=g):g=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(O,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let w;n[13]!==y||n[14]!==g||n[15]!==S?(w=s.jsx(yt,{asChild:!0,children:s.jsx(Ps,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":y,className:g,children:[j,S]})})}),n[13]=y,n[14]=g,n[15]=S,n[16]=w):w=n[16];let C;n[17]!==i||n[18]!==u||n[19]!==b?(C=b("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=b,n[20]=C):C=n[20];let v;n[21]!==C?(v=s.jsx(wt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=v):v=n[22];let R;n[23]!==w||n[24]!==v?(R=s.jsxs(bt,{children:[w,v]}),n[23]=w,n[24]=v,n[25]=R):R=n[25];let T;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==x||n[30]!==f||n[31]!==p||n[32]!==h||n[33]!==a||n[34]!==b?(T=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:b("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?b("header.services.remoteUpdate.available",{version:h.version||""}):f?b("header.services.remoteUpdate.checking"):p||b("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:x,children:b("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Pp,{embedded:!0,open:l,onOpenChange:Ey,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=x,n[30]=f,n[31]=p,n[32]=h,n[33]=a,n[34]=b,n[35]=T):T=n[35];let D;n[36]!==T?(D=s.jsx(Ds,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:T}),n[36]=T,n[37]=D):D=n[37];let F;return n[38]!==l||n[39]!==k||n[40]!==R||n[41]!==D?(F=s.jsxs(Is,{open:l,onOpenChange:k,children:[R,D]}),n[38]=l,n[39]=k,n[40]=R,n[41]=D,n[42]=F):F=n[42],F}),an=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ic=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Ty=()=>{js("ui.header.render");const{t}=St(),e=Ae(N=>N.isSidebarOpen),n=Ae(N=>N.openContextOverview),r=Ae(N=>N.closeContextPanel),i=Ae(N=>N.shortcutOverrides),o=Ae(N=>N.sessionTabsEnabled),l=nt(N=>N.getContextUsage),a=nt(N=>!!N.newSessionDraft?.open),d=nt(N=>N.currentSessionId),u=Dp(d??""),h=Ip(d??""),f=mf(d??""),p=us(Qn(c.useCallback(N=>{if(!d)return null;const ke=[...N.activeSessions,...N.archivedSessions].find(dt=>dt.id===d);if(!ke)return null;const Ve=ke;return{title:ke.title??null,directory:Ve.directory??null,created:ke.time?.created??null,slug:Ve.slug??null,parentId:ke.parentID??null}},[d]))),x=zt(Qn(N=>{if(!N.activeProjectId)return null;const ke=N.projects.find(Ve=>Ve.id===N.activeProjectId);return ke?{id:ke.id,path:ke.path,label:ke.label}:null})),b=c.useMemo(()=>{if(!x)return null;const N=x.label?.trim();if(N)return N;const ke=x.path.split(/[\\/]/).filter(Boolean);return ke[ke.length-1]??null},[x]),k=ur(N=>N.loadSettings),{isMobile:y}=Nn(),m=c.useRef(null),[g,j]=c.useState(()=>typeof window>"u"?!1:en()),S=c.useMemo(()=>Vr(),[]),w=mu(),[C,v]=c.useState(!1),R=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:T,side:D}=Xu(),F=c.useMemo(()=>{if(typeof window>"u")return null;const N=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(typeof navigator>"u")return null;const ke=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ke)return null;const Ve=Number.parseInt(ke[1],10),dt=Number.parseInt(ke[2],10);return Number.isNaN(Ve)?null:Ve===10?dt:Ve},[]);ct.useEffect(()=>{typeof window>"u"||j(en())},[]);const{context:B,output:E}=Tp(d),$=l(B,E),[L,X]=c.useState(null),Y=!d||u;ct.useEffect(()=>{if(!d){X(N=>N===null?N:null);return}if($){X(N=>Ep(N,$)?N:$);return}Y&&X(N=>N===null?N:null)},[$,d,Y]);const[I,P]=c.useState(!1),[A,q]=c.useState("Local"),[K,te]=c.useState(!0),[ae,re]=c.useState(!1),[he,ce]=c.useState(null),[Te,ve]=c.useState(!1),[pe,Ne]=c.useState(null),U=c.useMemo(()=>kn(),[]),Z=Ae(N=>N.workStatusPanelVisible),de=Ae(N=>N.workStatusPanelEnabled),ye=Ae(N=>N.setWorkStatusPanelEnabled),H=Ae(N=>N.workStatusPanelFits),je=Ae(N=>N.workStatusOverlayOpen),Ee=Ae(N=>N.setWorkStatusOverlayOpen),ne=de&&H||je,be=c.useCallback(()=>{if(de&&!H){Ee(!je);return}ye(!de)},[Ee,ye,je,de,H]),G=!U&&!Z&&!!L,z=c.useCallback(async()=>{if(!(typeof window>"u"||!g))try{if(Qo()){q("Local"),te(!0);return}te(!1);const N=await Ld(),ke=Xm(),Ve=Jm([Zm(ke),...N.hosts]);if(Ve.id===eh){q("Local"),te(!0);return}q(_d(Ve.label.trim()||"Instance"))}catch{q("Local"),te(!0)}},[g]);ct.useEffect(()=>(z(),vr(()=>{z()})),[z]);const J=c.useCallback(async()=>{if(K){ce(null),Ne(null);return}ve(!0),Ne(null);try{const N=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ke=await ls(`/api/openchamber/update-check?${N.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ke.ok)throw new Error(`Server responded with ${ke.status}`);const Ve=await ke.json();ce({available:Ve.available??!1,version:Ve.version,currentVersion:Ve.currentVersion??"unknown",body:Ve.body,nextSuggestedCheckInSec:typeof Ve.nextSuggestedCheckInSec=="number"?Ve.nextSuggestedCheckInSec:void 0,packageManager:Ve.packageManager,updateCommand:Ve.updateCommand})}catch(N){ce(null),Ne(N instanceof Error?N.message:t("header.services.remoteUpdate.error"))}finally{ve(!1)}},[K,t]);c.useEffect(()=>{ce(null),Ne(null),re(!1)},[K,A]),c.useEffect(()=>{if(!g||K)return;const N=3e3,ke=3600*1e3;let Ve=!1,dt=null;const Tt=Et=>{dt=window.setTimeout(()=>{if(Ve||typeof document<"u"&&document.visibilityState!=="visible"){Tt(ke);return}J().finally(()=>{Ve||Tt(ke)})},Et)};return Tt(N),()=>{Ve=!0,dt!==null&&window.clearTimeout(dt)}},[J,K,A,g]);const ue=c.useCallback(()=>{if(he?.available){re(!0);return}J()},[J,he?.available]);Rp(),c.useEffect(()=>{k()},[k]);const le=d?p??null:null,W=c.useRef(null),[M,_]=c.useState(0);c.useEffect(()=>{if(!d){W.current&&(W.current=null,_(dt=>dt+1));return}if(le){W.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const N=W.current;if(!N||N.sessionId!==d)return;const ke=N.expiresAt-Date.now();if(ke<=0){W.current=null,_(dt=>dt+1);return}const Ve=window.setTimeout(()=>{W.current?.sessionId===d&&(W.current=null),_(dt=>dt+1)},ke);return()=>{window.clearTimeout(Ve)}},[d,le]);const ee=(()=>{if(le)return le;if(!d)return null;const N=W.current;return N&&N.sessionId===d&&N.expiresAt>Date.now()?N.session:null})(),oe=nt(N=>d?N.worktreeMetadata.get(d)?.path??"":""),fe=nt(N=>d?N.worktreeMetadata.get(d)?.branch?.trim()??null:null),ie=hu(N=>d?N.getAttachment(d):void 0),Le=c.useMemo(()=>ie?Mp(ie,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ie]),$e=c.useMemo(()=>ie?ie.legacy?"legacy":ie.degraded?"degraded":ie.worktreeStatus==="pending"?"pending":ie.worktreeStatus==="missing"?"missing":ie.worktreeStatus==="invalid"?"invalid":ie.attentionReason?"attention":null:null,[ie]),Pe=c.useMemo(()=>an(oe||""),[oe]),Oe=c.useMemo(()=>{const N=typeof ee?.directory=="string"?ee.directory:"";return an(N||"")},[ee?.directory]),Q=Ma(d??"",Oe),Ce=nt(N=>N.newSessionDraft?.open?an(N.newSessionDraft.bootstrapPendingDirectory??N.newSessionDraft.directoryOverride??""):""),Se=nt(N=>N.newSessionDraft.target),Ke=nt(N=>N.newSessionDraft.selectedProjectId),et=nt(N=>N.currentSessionDirectory),it=Jt(N=>N.homeDirectory),rt=c.useMemo(()=>Pe||Oe||Ce,[Ce,Oe,Pe]),pt=Ae(c.useCallback(N=>{const ke=an(rt||"");return ke?ic(N.contextPanelByDirectory[ke]):null},[rt])),ht=nt(N=>{const ke=an(Pe||Oe||"");if(!ke)return null;for(const Ve of N.availableWorktreesByProject.values()){const Tt=Ve.find(Et=>an(Et.path)===ke)?.branch?.trim();if(Tt)return Tt}return null}),At=Op(rt||null)||fe||ht,jt=a?Se==="chat":Bp(Oe||et,it),we=!jt&&!Z&&!!(b||At||!a&&$e),Xe=c.useMemo(()=>{if(!d)return b??"OpenChamber";const N=ee?.title?.trim();return N&&N.length>0?N:"Untitled Session"},[b,ee?.title,d]),mt=pu(),qe=nt(N=>N.updateSessionTitle),ft=nt(N=>N.archiveSessions),se=nt(N=>N.deleteSessions),[me,Ie]=c.useState(!1),[We,V]=c.useState(!1),Fe=c.useRef(null),[Ye,Qe]=c.useState(""),[xe,st]=c.useState(null),Re=c.useRef(null),ot=c.useCallback(()=>{d&&(Qe(ee?.title?.trim()||Xe),Ie(!0))},[ee?.title,d,Xe]),vt=c.useRef(ot);vt.current=ot;const De=c.useCallback(N=>{N&&(N.focus(),N.select())},[]);c.useEffect(()=>{if(V(!1),st(null),d&&Fe.current===d){Fe.current=null,vt.current();return}Ie(!1),Qe("")},[d]);const gt=c.useCallback(async()=>{if(!d)return;const N=Ye.trim();N&&N!==ee?.title?.trim()&&await qe(d,N),Ie(!1)},[ee?.title,d,Ye,qe]);c.useEffect(()=>{if(!me)return;const N=ke=>{const Ve=ke.target;(!Ve||!Re.current?.contains(Ve))&&gt()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[me,gt]);const Ct=c.useCallback(N=>{N&&Jn(N).then(ke=>{ze[ke.ok?"success":"error"](t(ke.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(t("sessions.sidebar.session.copyId.error")))},[t]),He=c.useCallback(async()=>{if(!d||!rt){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const N=await mt({sessionID:d,directory:rt}).catch(()=>null);if(!N){ze.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(N.length===0){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ke=gu(N,ee?.title??null),Ve=xu(ee?.title??null);await bu(ke,Ve)||yu(ke,Ve),ze.success(t("sessions.sidebar.session.export.success"))},[ee?.title,d,mt,rt,t]),Ue=wu(),lt=c.useMemo(()=>vu(Ue),[Ue]),_e=c.useCallback(N=>{d&&uf({entry:N,t,session:{id:d,title:ee?.title,directory:Oe??rt},loadRecords:async()=>{if(!rt)return null;try{return await mt({sessionID:d,directory:rt})}catch{return null}},onLoadFailed:()=>ze.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ee?.title,d,mt,rt,Oe,t]),Ge=c.useCallback(N=>lt.map(ke=>s.jsxs(N,{onClick:()=>_e(ke),children:[s.jsx(Xr,{icon:ke.icon,iconSrc:ke.iconSrc,className:"mr-1 size-4"}),ke.action.label]},`${ke.guest.id}:${ke.action.id}`)),[lt,_e]),Je=h?.type==="busy"||h?.type==="retry",at=c.useCallback(()=>{if(!d||!Oe||Je||f)return;const N=us.getState().activeSessions,ke=N.find(Tt=>Tt.id===d);if(!ke)return;const Ve=[],dt=[d];for(let Tt=0;Tt<dt.length;Tt+=1){const Et=dt[Tt];for(const kt of N)kt.parentID===Et&&(Ve.push(kt),dt.push(kt.id))}ua({kind:"quick",root:ke,descendants:Ve,sourceDirectory:Oe,messages:da(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Je,f,Oe,t]),Nt=c.useCallback(async()=>{if(!xe)return;const N=xe.action,ke=[xe.sessionId,...Gd(xe.sessionId,[],N==="delete")];if(st(null),(N==="archive"?await ft(ke):await se(ke)).failedIds.length>0){ze.error(t(N==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}ze.success(t(N==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ft,se,xe,t]),Bt=Ae(N=>N.openGuestPageId),Ft=Fa(N=>N.guests.find(ke=>ke.id===Bt)),Qt=Ae(N=>N.isScheduledTasksDialogOpen),Mt=Ae(N=>N.isArchivePageOpen),Gt=Ae(N=>N.isUsageStatsPageOpen),$t=Ae(N=>N.worktreesPageProjectId),Zt=Ae(N=>N.isMultiRunLauncherOpen),ts=zt(N=>{if(!$t)return null;const ke=N.projects.find(Ve=>Ve.id===$t);return ke?.label?.trim()||ke?.path?.split("/").pop()||null}),Ot=c.useMemo(()=>Ft?{title:Ft.pageTitle??Ft.name,subtitle:null}:Qt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Mt?{title:t("sessions.archivePage.title"),subtitle:null}:Gt?{title:t("usageStats.title"),subtitle:null}:$t?{title:t("sessions.worktreesPage.title",{project:ts??""}),subtitle:null}:Zt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Ft,Mt,Zt,Qt,Gt,t,$t,ts]),Dt=c.useMemo(()=>an(rt||x?.path||""),[x?.path,rt]),Pt=oy(),fs=La(N=>N.planModeEnabled),Ts=nt(N=>N.isSessionPlanAvailable),xn=fs&&d?Ts(d):!1,ns=c.useRef("");c.useEffect(()=>{if(!fs||!d)return;const N=`${d||"none"}:${Oe||"none"}:${ee?.created||0}:${ee?.slug||"none"}`;ns.current!==N&&(ns.current=N)},[fs,xn,ee?.slug,ee?.created,d,Oe]);const In=c.useCallback(()=>{jn("desktop_open_draft_mini_chat_window",{directory:jt?"":Ce,projectId:jt?null:Ke,apiBaseUrl:mn(),clientToken:Ur()}).catch(N=>{console.warn("[header] failed to open draft mini chat window",N)})},[Ce,Ke,jt]),to=c.useCallback(()=>{if(a){In();return}d&&jn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Oe||an(et||"")||Pe,apiBaseUrl:mn(),clientToken:Ur()}).catch(N=>{console.warn("[header] failed to open session mini chat window",N)})},[d,In,a,et,Oe,Pe]),Tn=c.useCallback(()=>{const N=an(rt||"");if(!N)return;const ke=Ae.getState().contextPanelByDirectory[N];if(ic(ke)==="context"){r(N);return}n(N)},[r,n,rt]),er=pt==="context",En=zo,Xs=c.useMemo(()=>g&&R&&!C?"88px":w?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||T)&&!U?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,C,R,w,U,T]);ct.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Xs)},[Xs]);const rn=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",on=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ct.useEffect(()=>{if(!g||!R){v(!1);return}let N=!1;const ke=async()=>{try{const dt=await jn("desktop_is_window_fullscreen");N||v(dt===!0)}catch{N||v(!1)}},Ve=()=>{ke()};return ke(),window.addEventListener("openchamber:window-resized",Ve),()=>{N=!0,window.removeEventListener("openchamber:window-resized",Ve)}},[g,R]);const tr=c.useMemo(()=>!g||!R||F===null?"":F>=26?"h-12":F<=15?"h-14":"",[g,R,F]),sr=c.useMemo(()=>{if(!(g&&!T||U)&&!(T&&D==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[g,U,T,D]),ws=c.useCallback(()=>{if(typeof document>"u")return;const N=m.current?.getBoundingClientRect().height;N&&document.documentElement.style.setProperty("--oc-header-height",`${N}px`)},[]);ct.useEffect(()=>{if(typeof window>"u")return;ws();const N=m.current;if(!N||typeof ResizeObserver>"u")return()=>{};let ke=0;const Ve=()=>{ke||(ke=requestAnimationFrame(()=>{ke=0,ws()}))},dt=new ResizeObserver(Ve);return dt.observe(N),window.addEventListener("resize",Ve),window.addEventListener("orientationchange",Ve),()=>{ke&&cancelAnimationFrame(ke),dt.disconnect(),window.removeEventListener("resize",Ve),window.removeEventListener("orientationchange",Ve)}},[ws]),ct.useEffect(()=>{ws()},[ws,y,tr]);const Rn=c.useCallback(async N=>{const ke=N.target;ke.closest(".app-region-no-drag")||ke.closest("button, a, input, select, textarea")||N.button===0&&g&&await th()},[g]),Es=c.useCallback(N=>Hn(Jr(N,i)),[i]);Fp({rename_current_session:()=>{if(!d||y)return!1;ot()},toggle_services_menu:()=>{if(I){P(!1);return}P(!0),z()}});const nr=s.jsxs(s.Fragment,{children:[Pt?s.jsx(ny,{projectRef:Pt.projectRef,directory:Pt.directory,className:"mr-2"}):null,s.jsx(Tb,{directory:Dt,className:"mr-1"}),g?s.jsx(Iy,{isDesktopApp:g,currentInstanceLabel:A,currentInstanceIsLocal:K,isDesktopServicesOpen:I,setIsDesktopServicesOpen:P,refreshCurrentInstanceLabel:z,shortcutLabel:Es,remoteUpdateInfo:he,remoteUpdateChecking:Te,remoteUpdateError:pe,onOpenRemoteUpdate:ue}):null]}),rr=S&&(a||!!d),kr=c.useCallback(({session:N,open:ke,isActive:Ve,select:dt,closeOtherTabs:Tt,components:Et})=>{const{Item:kt,Separator:Ht}=Et,os=Ve&&!U&&!jt&&ee&&!ee.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(kt,{onClick:()=>{Ve||dt(),Fe.current=N.id},children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ca,{sessionID:N.id,directory:N.directory,open:ke,Item:kt}),s.jsxs(kt,{onClick:()=>Ct(N.id),children:[s.jsx(O,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Ht,{}),Ve?s.jsxs(kt,{onClick:()=>{He()},children:[s.jsx(O,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,Ve?Ge(kt):null,os?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(kt,{disabled:!Oe||Je||f,onClick:at,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(wt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Je?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Ht,{}),s.jsxs(kt,{onClick:Tt,children:[s.jsx(O,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Ht,{}),s.jsxs(kt,{onClick:()=>st({action:"archive",sessionId:N.id}),children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(kt,{className:"text-destructive focus:text-destructive",onClick:()=>st({action:"delete",sessionId:N.id}),children:[s.jsx(O,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Ct,ee,He,jt,Je,f,U,at,Ge,Oe,t]),or=()=>s.jsxs("div",{onMouseDown:Rn,className:Me("app-region-drag relative flex h-12 select-none items-center",T&&D==="right"?"pr-0":"pr-3",tr),style:sr,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:rn}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:on}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Ot?s.jsxs(s.Fragment,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Ae.getState().closeMainSurfaces(),children:s.jsx(O,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(wt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ot.title}),Ot.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Ot.subtitle}):null]})]}):U||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[Q?s.jsx(O,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Ql,{align:"start",children:s.jsx("button",{type:"button",className:En,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[me?s.jsxs("form",{ref:Re,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),gt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>Qe(N.target.value),onKeyDown:N=>Ui(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xe}),we?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[b?s.jsx("span",{className:"truncate",children:b}):null,At?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:At})]}):null,!a&&$e?s.jsxs("span",{className:Me("inline-flex min-w-0 items-center gap-0.5",$e==="attention"||$e==="invalid"||$e==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(O,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Le})]}):null]}):null]}),s.jsx("div",{className:Me("flex h-[18px] shrink-0 items-center justify-center",we?"self-start":"self-center"),children:d&&!a&&!me?s.jsxs(Is,{open:We,onOpenChange:V,onOpenChangeComplete:N=>{!N&&Fe.current&&Fe.current===d&&(Fe.current=null,ot())},children:[s.jsx(Ps,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsxs(Ds,{align:"end",className:"min-w-[190px]",children:[s.jsxs(_t,{onClick:()=>{Fe.current=d},children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ca,{sessionID:d,directory:Oe,open:We,Item:_t}),s.jsxs(_t,{onClick:()=>d&&Ct(d),children:[s.jsx(O,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(gs,{}),s.jsxs(_t,{onClick:()=>{He()},children:[s.jsx(O,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Ge(_t),!U&&!jt&&ee&&!ee.parentId?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(_t,{disabled:!Oe||Je||f,onClick:at,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(wt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Je?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(gs,{}),s.jsxs(_t,{onClick:()=>{d&&st({action:"archive",sessionId:d})},children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(_t,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&st({action:"delete",sessionId:d})},children:[s.jsx(O,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Ql,{align:"start",children:s.jsx("button",{type:"button",className:En,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(dy,{renderMenu:kr,suppressActiveTabControls:me,onMenuOpenChangeComplete:N=>{!N&&Fe.current&&Fe.current===d&&(Fe.current=null,ot())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:me?s.jsxs("form",{ref:Re,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),gt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>Qe(N.target.value),onKeyDown:N=>Ui(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Xe})})})]}),Ot||U||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G&&L?s.jsx(Qx,{reading:Xx(L),contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Tn,pressed:er,className:rr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(Dy,{visible:rr,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:to,className:Me(En,"mr-1"),Icon:"picture-in-picture-2"}),U?null:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ne,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:be,className:Me(zo,"mr-1",ne?"text-foreground":"text-muted-foreground/50"),children:s.jsx(O,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{side:"bottom",children:t(de&&!H?je?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":de?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),nr,s.jsx(Ju,{visible:T&&D==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:or()}),s.jsx(bs,{open:xe!==null,onOpenChange:N=>{N||st(null)},children:s.jsxs(ys,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Us,{children:[s.jsx(Bs,{children:xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Fs,{children:xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Xe}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Xe})})]}),s.jsxs(An,{children:[s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>st(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{Nt()},children:xe?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(qd,{open:ae,onOpenChange:re,info:he,downloading:!1,downloaded:!1,progress:null,error:pe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function Ey(){}const ac=280,lc=264,cc=500,Ry=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=St(),l=Ae(v=>v.sidebarWidth),a=Ae(v=>v.setSidebarWidth),[d,u]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||ac),p=c.useRef(null),x=c.useRef(null),b=c.useRef(null),k=c.useCallback(v=>Math.min(cc,Math.max(lc,v)),[]),y=c.useCallback(v=>{const R=b.current;R&&(R.style.width=`${v}px`,R.style.minWidth=`${v}px`,R.style.maxWidth=`${v}px`,R.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(p.current=null,x.current=null)},[d]),e)return null;const m=Math.min(cc,Math.max(lc,l||ac)),g=t?m:0,j=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}x.current=v.pointerId,u(!0),h.current=v.clientX,f.current=g,p.current=g,y(g),v.preventDefault()}},S=v=>{if(e||!d||x.current!==v.pointerId)return;const R=v.clientX-h.current,T=k(f.current+R);p.current!==T&&(p.current=T,y(T))},w=v=>{if(x.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const R=k(p.current??g);x.current=null,p.current=null,u(!1),a(R)},C=d?p.current??g:g;return s.jsxs("aside",{ref:b,className:Me("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C:m}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||g===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Me("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:j,onPointerMove:S,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Me("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(gn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(ps,{children:n})})]})]})},My=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},io="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",Oy=()=>{const t=Ze.c(37),{t:e}=St(),n=Ae(By),r=Ae(Fy),i=Ae(Ly),o=c.useRef(null),l=Hn(Jr("toggle_sidebar",i)),a=_y,{usesFramelessChrome:d,side:u}=Xu(),h=zy;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const L=o.current;if(!L)return;const X=()=>{const I=Math.max(L.getBoundingClientRect().width,L.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(I)}px`)};if(X(),typeof ResizeObserver>"u")return;const Y=new ResizeObserver(X);return Y.observe(L),()=>{Y.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),c.useEffect(f,p);const x="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=b):b=t[2];const k="flex items-center gap-2";let y;t[3]!==d||t[4]!==u?(y=d&&u==="left"?s.jsx(Ju,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=y):y=t[5];let m;t[6]!==e||t[7]!==d?(m=d?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,"aria-label":e("header.actions.openAppMenuAria"),className:Me(io,"shrink-0"),children:s.jsx(O,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=m):m=t[8];const g=bt;let j;t[9]!==e?(j=e("header.actions.openSessionsAria"),t[9]=e,t[10]=j):j=t[10];let S,w;t[11]===Symbol.for("react.memo_cache_sentinel")?(S=Me(io,"shrink-0"),w=s.jsx(O,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=S,t[12]=w):(S=t[11],w=t[12]);let C;t[13]!==j||t[14]!==n?(C=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":j,className:S,children:w})}),t[13]=j,t[14]=n,t[15]=C):C=t[15];const v=wt,R=e("header.actions.openSessionsWithShortcut",{shortcut:l});let T;t[16]!==R?(T=s.jsx("p",{children:R}),t[16]=R,t[17]=T):T=t[17];let D;t[18]!==v||t[19]!==T?(D=s.jsx(v,{children:T}),t[18]=v,t[19]=T,t[20]=D):D=t[20];let F;t[21]!==g||t[22]!==C||t[23]!==D?(F=s.jsxs(g,{children:[C,D]}),t[21]=g,t[22]=C,t[23]=D,t[24]=F):F=t[24];let B;t[25]!==a||t[26]!==r||t[27]!==e?(B=r?s.jsxs("button",{type:"button",onClick:a,className:Me(io,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(O,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Me(io,"-ml-1 shrink-0"),children:s.jsx(O,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=B):B=t[28];let E;t[29]!==F||t[30]!==B||t[31]!==y||t[32]!==m?(E=s.jsxs("div",{ref:o,className:k,children:[y,m,F,B]}),t[29]=F,t[30]=B,t[31]=y,t[32]=m,t[33]=E):E=t[33];let $;return t[34]!==E||t[35]!==b?($=s.jsx("div",{className:x,style:b,children:E}),t[34]=E,t[35]=b,t[36]=$):$=t[36],$};function By(t){return t.toggleSidebar}function Fy(t){return t.isSidebarOpen}function Ly(t){return t.shortcutOverrides}function _y(){Ae.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function $y(t){console.warn("[titlebar] failed to open app menu",t)}function zy(t){const e=t.currentTarget.getBoundingClientRect();jn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch($y)}function pf(t){const e=Ze.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(O,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const dc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Wy(t,e,n){const r=Ze.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,h]=await Promise.all([Lp(t),_p(t)]).catch(Ky);if(d)return;const f=dc(u),p=dc(h);if(!f||!p||p===f)return;const x=n||"",b=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:x,label:x||b,name:b,worktreeRoot:p,worktreeStatus:"ready",headState:x?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Ky(){return["",""]}const uc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Vy=async(t,e)=>{if(t)return t.authActivate(e);const n=await ls("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},fc=({className:t})=>{const{t:e}=St(),{github:n}=nn(),r=hn(x=>x.status),i=hn(x=>x.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async x=>{if(!(!x||o)){l(!0);try{i(await Vy(n,x))}catch(b){console.error("Failed to switch GitHub account:",b)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,h=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),p=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(O,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Me(uc,t),title:f,children:p}):s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(uc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(Ds,{align:"end",className:"w-64",children:[s.jsx(cr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(gs,{}),h.map(x=>{const b=x.user,k=!!x.current,y=x.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(_t,{className:"gap-2",disabled:o,onSelect:()=>{k||a(x.id)},children:[b?.avatarUrl?s.jsx("img",{src:b.avatarUrl,alt:b.login?e("header.github.avatarWithLogin",{login:b.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(O,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:b?.name?.trim()||b?.login||"GitHub"}),b?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:b.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:y})]}):null]}),k?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},x.id)})]})]})};class mi extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const hi="/api/walkthrough",gf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),xf=()=>new mi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Uy=t=>!gf(t)&&(t.ok||t.status===404),Za=async(t,e)=>{if(Uy(t))throw xf();const n=await t.json().catch(()=>null);throw new mi(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},bf=async t=>{if(!gf(t))throw xf();try{return await t.json()}catch{throw new mi("The server returned a malformed walkthrough response")}};async function Hy(t,e,n={}){const r=await ls(hi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?bf(r):Za(r,"Failed to load walkthrough")}async function Gy(t,e,n={}){const r=await ls(`${hi}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?bf(r):Za(r,"Failed to generate walkthrough")}async function qy(t,e){const n=await ls(`${hi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Za(n,"Failed to cancel walkthrough generation")}async function Yy(t,e,n){const r=await ls(`${hi}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Dr={status:"idle",stage:null,result:null,readiness:null,error:null},Qy=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,bn=(t,e)=>`${Wt()}\0${t}\0${Qy(e)}`,mc=t=>t instanceof mi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},$s=new Map,Ir=new Map,Xy=1e3,Jy=Zr()(xb((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=bn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[bn(n,r)],selectModel:(n,r,i)=>{const o=bn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[bn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[bn(n,r)]??Dr,load:async(n,r,i={})=>{if(!n)return;const o=bn(n,r);if(e().entries[o]?.status==="generating")return;$s.get(o)?.abort();const a=new AbortController;$s.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"loading",error:null}}}));try{const d=await Hy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:mc(d)}}}))}finally{$s.get(o)===a&&$s.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=bn(n,r);$s.get(o)?.abort();const l=new AbortController;$s.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Ir.get(o);d!==void 0&&(clearInterval(d),Ir.delete(o))};a(),Ir.set(o,setInterval(()=>{Yy(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const h=u.entries[o];return!h||h.status!=="generating"||h.stage===d?u:{entries:{...u.entries,[o]:{...h,stage:d}}}})}).catch(()=>{})},Xy));try{const d=await Gy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:mc(d)}}}))}finally{a(),$s.get(o)===l&&$s.delete(o)}},cancel:(n,r)=>{const i=bn(n,r);qy(n,r).catch(()=>{}),$s.get(i)?.abort(),$s.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of $s.values())n.abort();$s.clear();for(const n of Ir.values())clearInterval(n);Ir.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Zy="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",e1=3e4,hc=20,yf=(t,e)=>JSON.stringify([Wt(),t,e]),t1=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},pc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ao=new Map,s1=t=>{const e=Object.entries(t);return e.length<=hc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,hc))},gc=Zr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=yf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<e1&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const h=`${l}::${a?"details":"plain"}`,p=ao.get(`${l}::details`)??(a?null:ao.get(h));if(p&&!o?.force)return p;const x=(async()=>{t(b=>({entries:{...b.entries,[l]:{...b.entries[l]??pc(),isLoading:!0,error:null}}}));try{const b=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(k=>({entries:s1({...k.entries,[l]:{result:b,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),b}catch(b){const k=b instanceof Error?b.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??pc(),isLoading:!1,error:k}}})),null}finally{ao.delete(h)}})();return ao.set(h,x),x},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=t1(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),n1=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},r1=35e3,Ii=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ti=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},xc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},o1=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},i1=[2e3,5e3],a1=600,bc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),wn=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},l1=(t,e)=>{const n=wn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},c1=(t,e)=>`${t}::${e}`,el=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Ei=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=el(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},d1=t=>t.startsWith("pr-"),u1=(t,e)=>{const n=el(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!d1(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Tr=new Map,lo=Qr;function f1(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const m1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=St(),d=Ae(N=>N.timeFormatPreference),{github:u}=nn(),h=hn(N=>N.status),f=hn(N=>N.hasChecked),p=Ae(N=>N.setSettingsDialogOpen),x=Ae(N=>N.setSettingsPage),b=nt(N=>N.currentSessionId),k=nt(N=>!!N.newSessionDraft?.open),{isMobile:y,hasTouchInput:m,screenWidth:g}=Nn(),j=Ae(N=>N.openContextSurface),S=Jy(N=>N.requestSource),w=!y&&g>=768&&!kn(),C=c.useCallback(()=>{x("integrations"),p(!0)},[p,x]),v=c.useMemo(()=>c1(t,e),[t,e]),R=c.useMemo(()=>Tr.get(v)??null,[v]),T=Ms(N=>N.ensureEntry),D=Ms(N=>N.setParams),F=Ms(N=>N.startWatching),B=Ms(N=>N.stopWatching),E=Ms(N=>N.refresh),$=Ms(N=>N.updateStatus),[L,X]=c.useState(()=>R?.title??bc(e)),[Y,I]=c.useState(()=>R?.body??""),[P,A]=c.useState(()=>R?.draft??!1),[q,K]=c.useState(()=>R?.additionalContext??""),[te,ae]=c.useState(()=>{const N=typeof R?.targetBaseBranch=="string"?wn(R.targetBaseBranch):"";return N||wn(n)}),[re,he]=c.useState("squash"),[ce,Te]=c.useState(!1),[ve,pe]=c.useState(!1),[Ne,U]=c.useState(!1),[Z,de]=c.useState(!1),[ye,H]=c.useState(!1),[je,Ee]=c.useState(!1),[ge,ne]=c.useState(null),[be,G]=c.useState(""),[z,J]=c.useState(""),[ue,le]=c.useState(!1),[W,M]=c.useState(!1),[_,ee]=c.useState(()=>Ei(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r})),[oe,fe]=c.useState(!1),{detectedUpstream:ie,upstreamBranches:Le}=f1(t,u);c.useEffect(()=>{fe(!1)},[t]);const $e=i.some(N=>N.name==="upstream"),Oe=!!(t&&e&&n&&(e!==n||($e||ie!==null))),Q=c.useMemo(()=>Xo(t,e,_?.name??null),[t,e,_?.name]),Ce=Ms(N=>N.entries[Q]),Se=Ce?.isLoading??!1,Ke=Ce?.status??null,et=Ce?.error??null,it=Ce?.isInitialStatusResolved??!1,rt=c.useMemo(()=>{const N=oe?null:_?.name?.trim()||null,ke=new Set;for(const Tt of o){const Et=l1(Tt,N);!Et||Et==="HEAD"||ke.add(Et)}if(oe)for(const Tt of Le)Tt&&Tt!=="HEAD"&&ke.add(Tt);const Ve=wn(n);Ve&&Ve!=="HEAD"&&ke.add(Ve);const dt=wn(te);return dt&&dt!=="HEAD"&&ke.add(dt),Array.from(ke).sort((Tt,Et)=>Tt.localeCompare(Et))},[n,o,_?.name,te,Le,oe]);c.useEffect(()=>{if(i.length===0){_&&ee(null);return}(!_||!i.some(N=>N.name===_.name))&&ee(Ei(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r}))},[R?.selectedRemoteName,i,_,r]),c.useEffect(()=>{const N=wn(n);if(!te&&N){ae(N);return}if(rt.length!==0&&!rt.includes(te)){const ke=rt.includes(N)?N:rt[0];ke&&ae(ke)}},[rt,n,te]);const[pt,ht]=c.useState(()=>R?.activeSegment??"overview"),[tt,At]=c.useState(new Set),[jt,we]=c.useState(new Set),Xe=c.useRef(new Set),mt=c.useRef(null),qe=c.useRef(!1),ft=c.useRef(new Set),se=c.useRef([]);c.useEffect(()=>{ie&&!$e&&fe(!0)},[ie,$e]),c.useEffect(()=>{oe&&ie?.defaultBranch&&ae(ie.defaultBranch)},[oe,ie?.defaultBranch]);const me=Ke?.pr??null,Ie=me?.state==="merged"||me?.state==="closed",We=Ie?null:me,V=We?yf(t,We.number):null,Fe=gc(N=>V?N.entries[V]:void 0),Ye=gc(N=>N.ensure),Qe=Fe?.result??null,xe=Fe?.isLoading??!1,st=c.useCallback(N=>{ht(N);const ke=Tr.get(v);ke&&Tr.set(v,{...ke,activeSegment:N})},[v]);c.useEffect(()=>{!We||!u?.prContext||pt==="overview"||Ye(u,t,We.number,{includeCheckDetails:pt==="checks",sourceRepo:Ke?.repo??null})},[pt,t,Ye,u,We,Ke?.repo]);const Re=Ke?.checks??null,ot=(Re?.pending??0)>0,vt=Qe?.checkRuns??null,De=Qe?.fetchedAt;c.useEffect(()=>{if(!vt||vt.length===0)return;const N=n1(vt);$(Q,ke=>{if(!ke?.pr||typeof De=="number"&&typeof ke.fetchedAt=="number"&&De<ke.fetchedAt)return ke;const Ve=ke.checks;return Ve&&Ve.state===N.state&&Ve.total===N.total&&Ve.success===N.success&&Ve.failure===N.failure&&Ve.pending===N.pending&&Ve.inProgress===N.inProgress&&Ve.queued===N.queued&&Ve.startedAt===N.startedAt?ke:{...ke,checks:N,...typeof De=="number"?{fetchedAt:De}:{}}})},[vt,De,Q,$]),c.useEffect(()=>{if(pt!=="checks"||!ot||!me||!u?.prContext)return;const N=window.setInterval(()=>{Ye(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Ke?.repo??null,force:!0})},r1);return()=>window.clearInterval(N)},[pt,ot,t,Ye,u,me,Ke?.repo]);const[gt,Ct]=c.useState(()=>Date.now());c.useEffect(()=>{if(!ot)return;Ct(Date.now());const N=window.setInterval(()=>Ct(Date.now()),3e4);return()=>window.clearInterval(N)},[ot]);const He=me?`${t}#${me.number}`:null,Ue=!!(He&&ge===He);c.useEffect(()=>{if(!u?.prContext||!me||typeof me.body=="string"&&me.body.length>0)return;const N=`${t}#${me.number}`;if(Xe.current.has(N))return;Xe.current.add(N),ne(N);let ke=!1;return Ye(u,t,me.number,{sourceRepo:Ke?.repo??null}).then(Ve=>{if(ke)return;const dt=Ve?.pr;dt&&$(Q,Tt=>!Tt?.pr||Tt.pr.number!==me.number?Tt:{...Tt,pr:{...Tt.pr,body:dt.body||""}})}).catch(()=>{}).finally(()=>{ke||ne(Ve=>Ve===N?null:Ve)}),()=>{ke=!0}},[t,Ye,u,me,Q,Ke?.repo,$]),c.useEffect(()=>{if(!me){Ee(!1),G(""),J(""),mt.current=null;return}const N=mt.current!==null&&mt.current!==me.number;N&&Ee(!1),(!je||N)&&(G(me.title||""),J(me.body||"")),mt.current=me.number},[je,me]);const lt=c.useCallback(N=>{if(!N)return"";const ke=Date.parse(N);return Number.isFinite(ke)?Su(ke,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):N},[d]),_e=c.useMemo(()=>{const N=h?.user?.login;return typeof N=="string"?N.trim():""},[h]),Ge=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Je=c.useCallback(N=>{const ke=_e.toLowerCase(),Ve=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return N.replace(Ve,(dt,Tt,Et)=>{const kt=`@${Et}`,Ht=Et.toLowerCase();return`${Tt}[${kt}](https://github.com/${Ht}${ke&&Ht===ke?"?oc-self-mention=1":""})`})},[_e]),at=c.useMemo(()=>{const N=(Qe?.issueComments??[]).map(dt=>({id:`issue-${dt.id}`,body:dt.body||"",authorName:dt.author?.name||dt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:dt.author?.login||null,avatarUrl:dt.author?.avatarUrl||null,createdAt:dt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),ke=(Qe?.reviewComments??[]).map(dt=>({id:`review-${dt.id}`,body:dt.body||"",authorName:dt.author?.name||dt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:dt.author?.login||null,avatarUrl:dt.author?.avatarUrl||null,createdAt:dt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:dt.path||null,line:dt.line??null})),Ve=[...N,...ke];return Ve.sort((dt,Tt)=>{const Et=dt.createdAt?Date.parse(dt.createdAt):0,kt=Tt.createdAt?Date.parse(Tt.createdAt):0,Ht=Number.isFinite(Et)?Et:0,os=Number.isFinite(kt)?kt:0;return Ht-os}),Ve},[Qe,a]),Nt=c.useCallback(()=>{const N=b??(k?"draft":null);return N?{directory:t,sessionKey:N}:(ze.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[b,t,k,a]),Bt=c.useCallback((N,ke)=>{const Ve=ke.authorLogin?`@${ke.authorLogin}`:ke.authorName,dt=ke.path?` · ${ke.path}${ke.line?`:${ke.line}`:""}`:"";Yi.getState().addDraft(N,{source:"pr-comment",fileLabel:`PR #${me?.number??""} ${Ve}${dt}`,startLine:ke.line??0,endLine:ke.line??0,code:ke.body,language:"markdown",text:""})},[me?.number]),Ft=c.useCallback((N,ke)=>{const Ve=N.status||"unknown",dt=N.conclusion??void 0,Tt=dt?`${Ve} / ${dt}`:Ve,Et=N.app?.name||N.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:ke?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[ke?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Et?`${Et} · ${Tt}`:Tt})]}),N.detailsUrl?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:N.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),N.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:N.output.title}):null,N.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:N.output.summary}):null,N.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:N.output.text}):null,Array.isArray(N.annotations)&&N.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",N.annotations.length>20?` (showing 20/${N.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:N.annotations.slice(0,20).map((kt,Ht)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[kt.title||kt.level||"Issue",kt.path?` · ${kt.path}`:"",typeof kt.startLine=="number"?`:${kt.startLine}`:"",typeof kt.endLine=="number"&&kt.endLine!==kt.startLine?`-${kt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:kt.message}),kt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:kt.rawDetails}):null]},`${kt.path||"file"}:${kt.startLine||Ht}:${Ht}`))})]}):null,N.job?.steps&&N.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:N.job.steps.map((kt,Ht)=>{const os=(kt.conclusion||"").toLowerCase(),Xt=os&&!["success","neutral","skipped"].includes(os),Hs=`${N.id??"run"}:${N.job?.jobId??"job"}:${kt.number??Ht}:${kt.name}`,vs=tt.has(Hs);return Xt?s.jsxs(Qi,{open:vs,children:[s.jsxs("button",{type:"button",onClick:()=>{At(gi=>{const Mn=new Set(gi);return Mn.has(Hs)?Mn.delete(Hs):Mn.add(Hs),Mn})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Xt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[vs?s.jsx(O,{name:"arrow-down-s",className:"size-4"}):s.jsx(O,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:kt.name}),kt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:kt.conclusion}):null]}),s.jsx(Xi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof kt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",kt.number]}):null,kt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",kt.status]}):null,kt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",kt.conclusion]}):null,kt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",lt(kt.startedAt)]}):null,kt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",lt(kt.completedAt)]}):null]})})]},Hs):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:kt.name}),kt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:kt.conclusion}):null]},Hs)})})]}):null]})},[tt,lt,a]),[Qt,Mt]=c.useState(!1),[Gt,$t]=c.useState(!1),Zt=c.useCallback(async()=>{if(!u?.prContext){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Nt();if(N){Mt(!0);try{const ke=await Ye(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Ke?.repo??null});if(!ke){ze.error(a("gitView.pr.toast.loadChecksFailed"));return}const dt=(ke.checkRuns??[]).filter(Et=>Ti(Et.conclusion));if(dt.length===0){ze.message(a("gitView.pr.toast.noFailedChecks"));return}const Tt=Yi.getState();for(const Et of dt){const kt=(Et.annotations??[]).map(Xt=>[[Xt.level,Xt.title].filter(Boolean).join(" "),Xt.path?`${Xt.path}${typeof Xt.startLine=="number"?`:${Xt.startLine}`:""}`:null,Xt.message,Xt.rawDetails].filter(Boolean).join(`
3
3
  `)),Ht=(Et.job?.steps??[]).filter(Xt=>Ti(Xt.conclusion)).map(Xt=>`step ${Xt.number??"?"}: ${Xt.name} → ${Xt.conclusion}`),os=[`check: ${Et.job?.workflowName?`${Et.job.workflowName} / ${Et.name}`:Et.name}`,`status: ${Et.status??"unknown"} / ${Et.conclusion??"unknown"}`,Et.detailsUrl?`url: ${Et.detailsUrl}`:null,Et.output?.title?`title: ${Et.output.title}`:null,Et.output?.summary?`summary:
4
4
  ${Et.output.summary}`:null,Ht.length>0?`failed steps:
5
5
  ${Ht.join(`
@@ -875,7 +875,7 @@ ${t}
875
875
  styles: styles
876
876
  };
877
877
  `),wv=t=>{const e=Ze.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=St();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(p,x)=>s.jsxs("div",{role:"option","aria-selected":x===r,className:Me("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",x===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),i(p.url)},onPointerEnter:()=>l(x),children:[s.jsx(O,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||rl(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Me("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),o(p.url)},children:s.jsx(O,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let h;return e[15]!==d||e[16]!==u?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=h):h=e[17],h},Ws=t=>{const e=Ze.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Me("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let h;e[2]!==n?(h=s.jsx(O,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==h?(f=s.jsx(yt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=h,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(wt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let x;return e[14]!==f||e[15]!==p?(x=s.jsxs(bt,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=x):x=e[16],x},Lf=t=>{const e=Ze.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:h,canGoBack:f,canGoForward:p,isLoading:x,onAnnotate:b,onOpenDevTools:k,isAnnotating:y,onHardReload:m,onZoomIn:g,onZoomOut:j,onZoomReset:S,zoomPercent:w,onClearCookies:C,onClearCache:v,onToggleDeviceBar:R,isDeviceBarOpen:T}=t;let D;e[0]!==r?(D=r===void 0?[]:r,e[0]=r,e[1]=D):D=e[1];const F=D,B=w===void 0?100:w,{t:E}=St(),[$,L]=c.useState(!1),[X,Y]=c.useState(-1);let I;e[2]!==$||e[3]!==F?(I=$?F:[],e[2]=$,e[3]=F,e[4]=I):I=e[4];const P=I;let A;e[5]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{Y(-1)},e[5]=A):A=e[5];let q;e[6]!==n||e[7]!==$?(q=[n,$],e[6]=n,e[7]=$,e[8]=q):q=e[8],c.useEffect(A,q);let K;e[9]!==l?(K=$e=>{L(!1),Y(-1),l($e)},e[9]=l,e[10]=K):K=e[10];const te=K;let ae;e[11]!==X||e[12]!==te||e[13]!==P?(ae=$e=>{if(P.length!==0){if($e.key==="ArrowDown"||$e.key==="ArrowUp"){$e.preventDefault();const Pe=$e.key==="ArrowDown"?1:-1,Oe=P.length;Y(Q=>{const Ce=Q+Pe;return Ce<-1?Oe-1:Ce>=Oe?-1:Ce});return}if($e.key==="Escape"&&X>=0){$e.preventDefault(),Y(-1);return}if($e.key==="Enter"&&X>=0){$e.preventDefault();const Pe=P[X];Pe&&te(Pe.url)}}},e[11]=X,e[12]=te,e[13]=P,e[14]=ae):ae=e[14];const re=ae;let he;e[15]!==E?(he=E("contextPanel.browser.back"),e[15]=E,e[16]=he):he=e[16];const ce=!f;let Te;e[17]!==a||e[18]!==ce||e[19]!==he?(Te=s.jsx(Ws,{icon:"arrow-left",label:he,onClick:a,disabled:ce}),e[17]=a,e[18]=ce,e[19]=he,e[20]=Te):Te=e[20];let ve;e[21]!==E?(ve=E("contextPanel.browser.forward"),e[21]=E,e[22]=ve):ve=e[22];const pe=!p;let Ne;e[23]!==d||e[24]!==ve||e[25]!==pe?(Ne=s.jsx(Ws,{icon:"arrow-right",label:ve,onClick:d,disabled:pe}),e[23]=d,e[24]=ve,e[25]=pe,e[26]=Ne):Ne=e[26];let U;e[27]!==x||e[28]!==E?(U=E(x?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=x,e[28]=E,e[29]=U):U=e[29];let Z;e[30]!==u||e[31]!==U?(Z=s.jsx(Ws,{icon:"refresh",label:U,onClick:u}),e[30]=u,e[31]=U,e[32]=Z):Z=e[32];let de;e[33]!==m||e[34]!==E?(de=m?s.jsx(Ws,{icon:"restart",label:E("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=E,e[35]=de):de=e[35];let ye;e[36]!==n||e[37]!==te?(ye=$e=>{$e.preventDefault(),te(n)},e[36]=n,e[37]=te,e[38]=ye):ye=e[38];let H;e[39]!==o?(H=$e=>o($e.target.value),e[39]=o,e[40]=H):H=e[40];let je,Ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(je=()=>L(!0),Ee=()=>L(!1),e[41]=je,e[42]=Ee):(je=e[41],Ee=e[42]);const ge=P.length>0;let ne;e[43]===Symbol.for("react.memo_cache_sentinel")?(ne=Me("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=ne):ne=e[43];let be;e[44]!==E?(be=E("contextPanel.browser.addressAria"),e[44]=E,e[45]=be):be=e[45];let G;e[46]!==n||e[47]!==re||e[48]!==H||e[49]!==ge||e[50]!==be?(G=s.jsx("input",{value:n,onChange:H,onFocus:je,onBlur:Ee,onKeyDown:re,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":ge,"aria-controls":"openchamber-browser-address-suggestions",className:ne,"aria-label":be}),e[46]=n,e[47]=re,e[48]=H,e[49]=ge,e[50]=be,e[51]=G):G=e[51];let z;e[52]!==i?(z=$e=>i?.($e),e[52]=i,e[53]=z):z=e[53];let J;e[54]!==X||e[55]!==te||e[56]!==z||e[57]!==P?(J=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(wv,{entries:P,activeIndex:X,onSelect:te,onForget:z,onHighlight:Y})}),e[54]=X,e[55]=te,e[56]=z,e[57]=P,e[58]=J):J=e[58];let ue;e[59]!==ye||e[60]!==G||e[61]!==J?(ue=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:ye,children:[G,J]}),e[59]=ye,e[60]=G,e[61]=J,e[62]=ue):ue=e[62];let le;e[63]!==g||e[64]!==j||e[65]!==S||e[66]!==E||e[67]!==B?(le=j&&g?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(Ws,{icon:"subtract",label:E("contextPanel.browser.zoomOut"),onClick:j}),B!==100&&S?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:S,"aria-label":E("contextPanel.browser.zoomReset"),children:[B,"%"]})}),s.jsx(wt,{sideOffset:6,children:E("contextPanel.browser.zoomReset")})]}):null,s.jsx(Ws,{icon:"add",label:E("contextPanel.browser.zoomIn"),onClick:g})]}):null,e[63]=g,e[64]=j,e[65]=S,e[66]=E,e[67]=B,e[68]=le):le=e[68];let W;e[69]!==C||e[70]!==E?(W=C?s.jsx(Ws,{icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=E,e[71]=W):W=e[71];let M;e[72]!==v||e[73]!==E?(M=v?s.jsx(Ws,{icon:"database-2",label:E("contextPanel.browser.clearCache"),onClick:v}):null,e[72]=v,e[73]=E,e[74]=M):M=e[74];let _;e[75]!==T||e[76]!==R||e[77]!==E?(_=R?s.jsx(Ws,{icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onClick:R,pressed:T}):null,e[75]=T,e[76]=R,e[77]=E,e[78]=_):_=e[78];let ee;e[79]!==y||e[80]!==b||e[81]!==E?(ee=b?s.jsx(Ws,{icon:"markup",label:E("contextPanel.browser.annotate.toggle"),onClick:b,pressed:y}):null,e[79]=y,e[80]=b,e[81]=E,e[82]=ee):ee=e[82];let oe;e[83]!==k||e[84]!==E?(oe=k?s.jsx(Ws,{icon:"terminal-box",label:E("contextPanel.browser.devTools"),onClick:k}):null,e[83]=k,e[84]=E,e[85]=oe):oe=e[85];let fe;e[86]!==E?(fe=E("contextPanel.browser.openExternal"),e[86]=E,e[87]=fe):fe=e[87];let ie;e[88]!==h||e[89]!==fe?(ie=s.jsx(Ws,{icon:"external-link",label:fe,onClick:h}),e[88]=h,e[89]=fe,e[90]=ie):ie=e[90];let Le;return e[91]!==Te||e[92]!==Ne||e[93]!==Z||e[94]!==de||e[95]!==ue||e[96]!==le||e[97]!==W||e[98]!==M||e[99]!==_||e[100]!==ee||e[101]!==oe||e[102]!==ie?(Le=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Te,Ne,Z,de,ue,le,W,M,_,ee,oe,ie]}),e[91]=Te,e[92]=Ne,e[93]=Z,e[94]=de,e[95]=ue,e[96]=le,e[97]=W,e[98]=M,e[99]=_,e[100]=ee,e[101]=oe,e[102]=ie,e[103]=Le):Le=e[103],Le},Wo={kind:"fill"},Tc=240,vv=3840,_f=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],Ec=t=>Number.isFinite(t)?Math.round(Math.min(vv,Math.max(Tc,t))):Tc,Ko=t=>t.kind==="fill"?null:{width:t.width,height:t.height},$f=t=>{const e=_f.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Sv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},jv=(t,e)=>{const n=Ko(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},kv=["mobile","tablet","desktop","fill"],Cv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Rc=t=>typeof t=="string"&&kv.includes(t),wa=t=>t==="fill"?Wo:$f(Cv[t])??Wo,mo=t=>{const e=Ko(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=wa(n),i=Ko(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Nv=t=>{const e=Ze.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=St();let d;e[0]!==n?(d=Ko(n),e[0]=n,e[1]=d):d=e[1];const u=d,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(ce,Te)=>{const ve=Number.parseInt(Te,10);if(!Number.isFinite(ve))return;const pe=u??{width:1280,height:800};r({kind:"custom",width:Ec(ce==="width"?ve:pe.width),height:Ec(ce==="height"?ve:pe.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const p=f;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=Me("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=x):x=e[5];const b=x;let k;e[6]!==r?(k=ce=>{const Te=$f(ce.target.value);r(Te??Wo)},e[6]=r,e[7]=k):k=e[7];let y;e[8]!==a?(y=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=y):y=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Me("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=m):m=e[10];let g;e[11]!==a?(g=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=g):g=e[12];let j;e[13]!==g?(j=s.jsx("option",{value:"",children:g}),e[13]=g,e[14]=j):j=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=_f.map(Av),e[15]=S):S=e[15];let w;e[16]!==h||e[17]!==k||e[18]!==y||e[19]!==j?(w=s.jsxs("select",{value:h,onChange:k,"aria-label":y,className:m,children:[j,S]}),e[16]=h,e[17]=k,e[18]=y,e[19]=j,e[20]=w):w=e[20];const C=u?String(u.width):"";let v;e[21]!==p?(v=ce=>p("width",ce.target.value),e[21]=p,e[22]=v):v=e[22];let R;e[23]!==a?(R=a("contextPanel.browser.device.width"),e[23]=a,e[24]=R):R=e[24];let T;e[25]!==C||e[26]!==v||e[27]!==R?(T=s.jsx("input",{value:C,onChange:v,placeholder:"—",inputMode:"numeric","aria-label":R,className:b}),e[25]=C,e[26]=v,e[27]=R,e[28]=T):T=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=D):D=e[29];const F=u?String(u.height):"";let B;e[30]!==p?(B=ce=>p("height",ce.target.value),e[30]=p,e[31]=B):B=e[31];let E;e[32]!==a?(E=a("contextPanel.browser.device.height"),e[32]=a,e[33]=E):E=e[33];let $;e[34]!==F||e[35]!==B||e[36]!==E?($=s.jsx("input",{value:F,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":E,className:b}),e[34]=F,e[35]=B,e[36]=E,e[37]=$):$=e[37];let L;e[38]!==r||e[39]!==n?(L=()=>r(Sv(n)),e[38]=r,e[39]=n,e[40]=L):L=e[40];const X=!u;let Y;e[41]!==a?(Y=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=Y):Y=e[42];let I;e[43]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(O,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=I):I=e[43];let P;e[44]!==L||e[45]!==X||e[46]!==Y?(P=s.jsx(yt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:L,disabled:X,"aria-label":Y,children:I})}),e[44]=L,e[45]=X,e[46]=Y,e[47]=P):P=e[47];let A;e[48]!==a?(A=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=A):A=e[49];let q;e[50]!==A?(q=s.jsx(wt,{sideOffset:6,children:A}),e[50]=A,e[51]=q):q=e[51];let K;e[52]!==P||e[53]!==q?(K=s.jsxs(bt,{children:[P,q]}),e[52]=P,e[53]=q,e[54]=K):K=e[54];let te;e[55]!==l||e[56]!==u?(te=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=te):te=e[57];let ae;e[58]===Symbol.for("react.memo_cache_sentinel")?(ae=["system","light","dark"],e[58]=ae):ae=e[58];let re;e[59]!==i||e[60]!==o||e[61]!==a?(re=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ae.map(ce=>s.jsx(ut,{type:"button",variant:i===ce?"secondary":"ghost",size:"xs",className:Me("shrink-0 rounded-full px-2.5 typography-micro",i===ce?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ce),"aria-pressed":i===ce,children:a(ce==="system"?"contextPanel.browser.device.schemeSystem":ce==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ce))}),e[59]=i,e[60]=o,e[61]=a,e[62]=re):re=e[62];let he;return e[63]!==w||e[64]!==T||e[65]!==$||e[66]!==K||e[67]!==te||e[68]!==re?(he=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[w,T,D,$,K,te,re]}),e[63]=w,e[64]=T,e[65]=$,e[66]=K,e[67]=te,e[68]=re,e[69]=he):he=e[69],he};function Av(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Pv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Dv=2e3,Iv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=mn();if(!t)return!1;try{return!Sr(new URL(t,window.location.href).toString())}catch{return!1}},zf=t=>{const e=Ze.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=St();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=Kb(i),[h]=c.useState(Iv);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let T=!0,D=null;const F=new AbortController,B=()=>{jw(F.signal).then(E=>{T&&(d(E),D=setTimeout(B,Dv))})};return B(),()=>{T=!1,D&&clearTimeout(D),F.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const x=a.kind==="ready"?a.servers:null;let b;e[3]!==u||e[4]!==x?(b=Nw({announced:u,discovered:x}),e[3]=u,e[4]=x,e[5]=b):b=e[5];const k=b;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Du,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=y):y=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let g;e[9]!==m?(g=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=g):g=e[10];let j;e[11]!==o?(j=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=j):j=e[12];let S;e[13]!==j?(S=s.jsx("span",{className:"typography-micro text-muted-foreground",children:j}),e[13]=j,e[14]=S):S=e[14];let w;e[15]!==S||e[16]!==g?(w=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[g,S]}),e[15]=S,e[16]=g,e[17]=w):w=e[17];let C;e[18]!==u||e[19]!==k||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(C=k.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:k.map(T=>s.jsxs(ut,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{$b(i),n(T.url)},children:[s.jsx(O,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:rl(T.url)||T.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Pv(T.url)})]},T.port))})]}):null,e[18]=u,e[19]=k,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=C):C=e[24];let v;e[25]!==k.length||e[26]!==a.kind||e[27]!==o?(v=k.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=k.length,e[26]=a.kind,e[27]=o,e[28]=v):v=e[28];let R;return e[29]!==w||e[30]!==C||e[31]!==v?(R=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[y,w,C,v]}),e[29]=w,e[30]=C,e[31]=v,e[32]=R):R=e[32],R},As=t=>Math.round(t),Tv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${As(l.x)}, y=${As(l.y)}, width=${As(l.width)}, height=${As(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},Ev=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${As(n.x)}, y=${As(n.y)}, width=${As(n.width)}, height=${As(n.height)}`},Rv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${As(n.x)}, y=${As(n.y)}, width=${As(n.width)}, height=${As(n.height)}`},Mv=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${As(t.viewport.width)}x${As(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...Tv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(Ev(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(Rv(l,a)))),o.filter(l=>typeof l=="string").join(`
878
- `)},Ov=t=>{const e=Ze.c(7),{t:n}=St(),r=nt(Fv),i=nt(Lv),o=Yi(_v),l=eg($v);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){ze.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await l(d.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Mv({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),ze.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Bv=()=>{const t=Ze.c(16),{t:e}=St();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Fv(t){return t.currentSessionId}function Lv(t){return t.newSessionDraft?.open}function _v(t){return t.addDraft}function $v(t){return t.addAttachedFile}const zv=3e4,Wv=3,Kv=250,Vv={attempts:0,windowStartedAt:null},Uv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=zv,r=n?0:t.attempts;return r>=Wv?null:{delayMs:Kv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Hv=-3,ho=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",mr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Gv=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Dw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,h]=c.useState(!1),[f,p]=c.useState(!1),x=c.useRef(n);x.current=n;const b=c.useRef(Vv);return c.useEffect(()=>{if(!t)return;const k=()=>{try{const D=t.getURL();return ho(D)?D:""}catch{return""}},y=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},m=D=>{ho(D)&&(l(D),x.current(D))},g=()=>{const D=k();i({kind:"loading",url:D})},j=()=>{const D=k();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),m(D),y(),i(B=>B.kind==="failed"&&B.url===D?B:{kind:"ready",url:D,title:F})},S=D=>{const F=mr(D);ho(F.url)&&(m(F.url),y())},w=D=>{const F=mr(D),B=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",E=k();B&&E&&Cf.getState().resolve(E,B)},C=D=>{const F=mr(D);typeof F.title=="string"&&d(F.title)},v=D=>{const F=mr(D);if(F.isMainFrame===!1)return;const B=typeof F.errorCode=="number"?F.errorCode:0;B!==Hv&&i({kind:"failed",url:ho(F.validatedURL)?F.validatedURL:k(),code:B,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let R=null;const T=()=>{const D=k(),F=Uv(b.current,Date.now());if(!F){i({kind:"failed",url:D,code:0,description:"",crashed:!0});return}b.current=F.state,i({kind:"loading",url:D}),R=setTimeout(()=>{R=null;try{t.reload()}catch{i({kind:"failed",url:D,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",g),t.addEventListener("did-stop-loading",j),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",w),t.addEventListener("did-fail-load",v),t.addEventListener("render-process-gone",T),t.addEventListener("crashed",T);try{!t.isLoading()&&k()&&j()}catch{}return()=>{R!==null&&clearTimeout(R),t.removeEventListener("render-process-gone",T),t.removeEventListener("crashed",T),t.removeEventListener("did-start-loading",g),t.removeEventListener("did-stop-loading",j),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",w),t.removeEventListener("did-fail-load",v)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},qv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Yv=4e4,po=.5,Qv=-3,Xv=4,Jv="persist:openchamber-browser",Mc=20,Zv=600,eS=2e4,tS=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=St(),{currentTheme:i}=Cn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(W=>{o.current=W,a(W)},[]),u=Ae(W=>W.setContextPanelTabTargetPath),h=c.useRef(xr(t)),f=h.current!==Ks?h.current:"",[p,x]=c.useState(f?null:Ks),[b,k]=c.useState(f),[y,m]=c.useState(!1),[g,j]=c.useState(!1),[S,w]=c.useState(0),C=c.useRef(0),[v,R]=c.useState(!1),[T,D]=c.useState(Wo),F=c.useRef(T);F.current=T;const B=c.useRef([]),[E,$]=c.useState("system"),[L,X]=c.useState({width:0,height:0}),Y=c.useRef(null),I=c.useRef(null),P=c.useRef(!1),A=c.useRef(Date.now()),q=c.useCallback(W=>{!W||W===Ks||!e||!n||u(e,n,W)},[e,n,u]),K=Gv(l,{initialUrl:f,onUrlChange:c.useCallback(W=>{const M=ar(W);k(M),q(M)},[q])}),[te,ae]=c.useState(null),re=Ov(e),he=Bv(),ce=K.status.kind==="loading",Te=br(Mf(e)),ve=br(W=>W.recordVisit),pe=br(W=>W.forget);c.useEffect(()=>{K.status.kind==="ready"&&ve(e,{url:ar(K.status.url),title:K.status.title})},[e,K.status,ve]);const Ne=c.useMemo(()=>Rf(Te,b),[Te,b]),U=c.useCallback(W=>{const M=xr(W);M!==Ks&&(k(M),ae(null),Pc(M).then(_=>{const ee=o.current;if(!ee){x(_);return}try{ee.loadURL(_)}catch{x(_)}}).catch(_=>{_ instanceof Wr&&ae(M)}))},[]);c.useEffect(()=>{if(!f)return;let W=!0;return Pc(f).then(M=>{W&&x(M)}).catch(M=>{if(W){if(M instanceof Wr){ae(f),x(Ks);return}x(f)}}),()=>{W=!1}},[]);const Z=c.useMemo(()=>({executeJavaScript:async(W,M)=>{const _=o.current;if(!_)throw new Error("Browser view is not available");return _.executeJavaScript(W,M)},capturePage:async()=>{const W=o.current;if(!W)return null;const M=W.getWebContentsId();return Number.isFinite(M)?await pr("desktop_browser_capture_page",{webContentsId:M}):null}}),[]),de=c.useCallback(()=>{if(y){m(!1),Po(Z);return}if(!K.url){ze.error(r("contextPanel.browser.annotate.noPage"));return}const W=Kw(i.metadata.variant==="light"?"light":"dark");m(!0),zw({host:Z,theme:W,labels:he}).then(async M=>{m(!1),M&&await re(M)}).catch(()=>{m(!1),ze.error(r("contextPanel.browser.annotate.failed"))})},[Z,re,i,y,K.url,he,r]);c.useEffect(()=>{if(!y)return;const W=M=>{tg(M)||M.key!=="Escape"||(M.preventDefault(),M.stopImmediatePropagation(),m(!1),Po(Z))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[Z,y]);const ye=c.useCallback(async(W=8e3)=>{const M=Date.now();for(;;){const _=o.current;if(!_)return!1;let ee=!1;try{ee=_.isLoading()}catch{return!1}if(!ee)return!0;if(Date.now()-M>W)return!1;await new Promise(oe=>setTimeout(oe,120))}},[]),H=c.useCallback(async(W,M)=>{const _=o.current;if(!_)throw new Error("The browser panel is not ready");const ee=()=>{Rc(M.viewport)&&(D(wa(M.viewport)),R(!0))};if(W==="browser.back"||W==="browser.forward"){const Pe=W==="browser.back";if(!(Pe?_.canGoBack():_.canGoForward()))throw new Error(Pe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Pe?_.goBack():_.goForward(),await new Promise(Ce=>setTimeout(Ce,150)),await ye();let Q="";try{Q=_.getTitle()||""}catch{Q=""}return{url:ar(_.getURL()),title:Q}}if(W==="browser.capture"){const Pe=Ae.getState(),Oe=$n(e),Q=Pe.contextPanelByDirectory[Oe],Ce=!!(Q?.isOpen&&Q.activeTabId===n);Ce||Pe.setActiveContextPanelTab(e,n);const Se=()=>{if(Ce||!Q)return;const Ke=Ae.getState(),et=Ke.contextPanelByDirectory[Oe];!et?.isOpen||et.activeTabId!==n||(Q.activeTabId&&Q.activeTabId!==n&&Ke.setActiveContextPanelTab(e,Q.activeTabId),Q.isOpen||Ke.closeContextPanel(e))};try{const Ke=Date.now()+1200;let et=0,it=0;for(;it<2&&Date.now()<Ke;){const ht=_.getBoundingClientRect().width;it=ht>=2&&Math.abs(ht-et)<.5?it+1:0,et=ht,await new Promise(tt=>setTimeout(tt,50))}await new Promise(ht=>{requestAnimationFrame(()=>requestAnimationFrame(()=>ht()))}),await ye();const rt=await Z.capturePage();if(!rt)throw new Error("The page could not be captured");let pt="";try{pt=_.getTitle()||""}catch{pt=""}return{...rt,url:ar(_.getURL()),title:pt,viewport:mo(F.current)}}finally{Se()}}if(W==="browser.resize"){if(!Rc(M.viewport))throw new Error("viewport is required");return ee(),await new Promise(Pe=>setTimeout(Pe,200)),await ye(),{viewport:mo(wa(M.viewport))}}if(W==="browser.open"){const Pe=typeof M.url=="string"?M.url:"";if(!Pe)throw new Error("url is required");ee(),U(Pe),await new Promise(Ce=>setTimeout(Ce,150));const Oe=await ye(25e3);let Q="";try{Q=_.getTitle()||""}catch{Q=""}return{url:xr(Pe),title:Q,opened:!0,settled:Oe,viewport:mo(F.current)}}await ye();const oe=Pe=>typeof Pe=="string"&&Pe?Pe:void 0,ie=(()=>{switch(W){case"browser.snapshot":return hv({selector:oe(M.selector)});case"browser.click":return pv({selector:oe(M.selector),text:oe(M.text)});case"browser.type":return gv({selector:String(M.selector??""),value:String(M.value??""),submit:M.submit===!0});case"browser.inspect":return yv({selector:String(M.selector??"")});case"browser.scroll":return xv({selector:oe(M.selector),direction:oe(M.direction)});default:return null}})();if(!ie)throw new Error(`Unsupported browser action: ${W}`);const Le=await _.executeJavaScript(ie,!0);if(!Le||typeof Le!="object")throw new Error("The page returned no result");const $e=Le;if($e.ok!==!0)throw new Error(typeof $e.error=="string"&&$e.error?$e.error:"Browser action failed");if(W==="browser.snapshot"){const Pe=B.current;return{...$e,viewport:mo(F.current),...Pe.length>0?{consoleProblems:[...Pe]}:{}}}return(W==="browser.click"||W==="browser.type"&&M.submit===!0)&&(await new Promise(Pe=>setTimeout(Pe,150)),await ye()),Le},[Z,e,U,n,ye]),je=c.useCallback(()=>{const W=o.current;if(!W)return{title:"",url:""};let M="",_="";try{M=W.getTitle()||""}catch{M=""}try{_=ar(W.getURL())}catch{_=""}return{title:M,url:_}},[]);c.useEffect(()=>Xw({tabId:n,describe:je,run:H}),[je,H,n]),c.useEffect(()=>{const W=Z;return()=>{Po(W)}},[Z]),c.useEffect(()=>{if(!l)return;const W=_=>{const ee=_;if(typeof ee.level!="number"||ee.level<2)return;const oe=ee.sourceId?`${ee.sourceId}${ee.line?`:${ee.line}`:""}`:"";B.current.push({level:ee.level>=3?"error":"warning",message:String(ee.message??"").slice(0,400),source:oe}),B.current.length>Mc&&B.current.splice(0,B.current.length-Mc)},M=()=>{B.current=[]};return l.addEventListener("console-message",W),l.addEventListener("did-start-loading",M),()=>{l.removeEventListener("console-message",W),l.removeEventListener("did-start-loading",M)}},[l]);const Ee=c.useRef(new Set),ge=c.useCallback(W=>{Ee.current.clear(),U(W)},[U]);c.useEffect(()=>{if(!l)return;const W=_=>{const ee=mr(_),oe=typeof ee.url=="string"?ee.url:"";!oe||!Dc(oe)||(_.preventDefault(),U(oe))},M=_=>{const ee=mr(_);if(ee.isMainFrame===!1||ee.errorCode===-3)return;const oe=typeof ee.validatedURL=="string"?ee.validatedURL:"";!oe||!Dc(oe)||Ee.current.has(oe)||(Ee.current.add(oe),U(oe))};return l.addEventListener("will-navigate",W),l.addEventListener("did-fail-load",M),()=>{l.removeEventListener("will-navigate",W),l.removeEventListener("did-fail-load",M)}},[U,l]),c.useEffect(()=>{if(!l)return;const W=M=>{const _=M.detail;M.preventDefault(),_?.url&&U(_.url)};return l.addEventListener("new-window",W),()=>l.removeEventListener("new-window",W)},[U,l]);const ne=c.useCallback(W=>{const M=Math.min(Xv,Math.max(Qv,W));C.current=M,w(M);try{o.current?.setZoomLevel(M)}catch{}},[]);c.useEffect(()=>{const W=M=>{if(!(M instanceof CustomEvent))return;const _=M.detail,ee=o.current;!ee||document.activeElement!==ee||(_==="zoom-in"?ne(C.current+po):_==="zoom-out"?ne(C.current-po):_==="zoom-reset"&&ne(0))};return window.addEventListener("openchamber:zoom",W),()=>window.removeEventListener("openchamber:zoom",W)},[ne]);const be=c.useCallback(W=>{pr("desktop_browser_clear_data",{partition:Jv,cookies:W==="cookies",cache:W==="cache"}).then(()=>{ze.success(r(W==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>ze.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const W=Y.current;if(!W||typeof ResizeObserver>"u")return;const M=new ResizeObserver(_=>{const ee=_[0]?.contentRect;ee&&X({width:ee.width,height:ee.height})});return M.observe(W),()=>M.disconnect()},[]);const G=c.useCallback(W=>{$(W);const M=o.current;if(!M)return;let _=-1;try{_=M.getWebContentsId()}catch{return}pr("desktop_browser_set_color_scheme",{webContentsId:_,scheme:W}).catch(ee=>{$("system"),ze.error(ee instanceof Error?ee.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),z=c.useCallback(()=>{try{ce?o.current?.stop():o.current?.reload()}catch{}},[ce]),J=K.status;c.useEffect(()=>{const W=()=>{j(!0);const ee=setTimeout(()=>{try{o.current?.reload()}catch{}},Zv);return()=>clearTimeout(ee)};if(J.kind==="failed"){if(!vw(J.code,J.url)){j(!1);return}const ee=Date.now(),oe=I.current?.url===J.url?I.current:{url:J.url,startedAt:ee};if(I.current=oe,ee-oe.startedAt>Yv){j(!1);return}return W()}if(J.kind==="loading")return;if(I.current=null,J.kind!=="ready"||!J.url||!Sr(J.url)){P.current=!0,j(!1);return}if(P.current||Date.now()-A.current>eS){P.current=!0,j(!1);return}let M=!1,_=null;return kw(ar(J.url)).then(ee=>{if(!M){if(ee===null||ee<500){P.current=!0,j(!1);return}_=W()}}),()=>{M=!0,_?.()}},[J]);const ue=K.status.kind==="failed"&&!g?K.status:null,le=jv(T,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Lf,{address:b,onAddressChange:k,onSubmit:ge,suggestions:Ne,onForgetSuggestion:W=>pe(e,W),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:z,onOpenExternal:()=>{Qr(K.url||b)},canGoBack:K.canGoBack,canGoForward:K.canGoForward,isLoading:ce,onAnnotate:de,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ne(S+po),onZoomOut:()=>ne(S-po),onZoomReset:()=>ne(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>be("cookies"),onClearCache:()=>be("cache"),onToggleDeviceBar:()=>R(W=>!W),isDeviceBarOpen:v}),v?s.jsx(Nv,{viewport:T,onViewportChange:D,colorScheme:E,onColorSchemeChange:G,scale:le?.scale??1}):null,s.jsxs("div",{ref:Y,className:Me("relative min-h-0 flex-1 bg-background",le&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:d,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:le?{width:`${le.width}px`,height:`${le.height}px`,transform:`scale(${le.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!K.url&&!ce?s.jsx(zf,{onOpen:ge,directory:e}):null,g?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:te})})]}):null,ue&&!te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ue.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ue.crashed?r("contextPanel.browser.crashedHint"):ue.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ce?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},sS=t=>{const e=Ze.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=St(),l=Ae(rS);let a;e[0]!==n?(a=xr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==Ks?d:"",[h,f]=c.useState(u),[p,x]=c.useState(u);let b;e[2]!==u?(b=u?[u]:[],e[2]=u,e[3]=b):b=e[3];const[k,y]=c.useState(b),[m,g]=c.useState(u?0:-1),[j,S]=c.useReducer(oS,0);let w;e[4]!==r||e[5]!==l||e[6]!==i?(w=he=>{!he||he===Ks||!r||!i||l(r,i,he)},e[4]=r,e[5]=l,e[6]=i,e[7]=w):w=e[7];const C=w;let v;e[8]!==r?(v=Mf(r),e[8]=r,e[9]=v):v=e[9];const R=br(v),T=br(iS),D=br(aS);let F;e[10]!==h||e[11]!==R?(F=Rf(R,h),e[10]=h,e[11]=R,e[12]=F):F=e[12];const B=F;let E;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==T?(E=he=>{const ce=xr(he);ce!==Ks&&(f(ce),x(ce),C(ce),T(r,{url:ce}),y(Te=>{const ve=m>=0?Te.slice(0,m+1):[];return ve[ve.length-1]===ce?(g(ve.length-1),ve):(g(ve.length),[...ve,ce])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=T,e[17]=E):E=e[17];const $=E;let L;e[18]!==k||e[19]!==C?(L=he=>{const ce=k[he];ce&&(g(he),f(ce),x(ce),C(ce))},e[18]=k,e[19]=C,e[20]=L):L=e[20];const X=L;let Y;e[21]!==r||e[22]!==D?(Y=he=>D(r,he),e[21]=r,e[22]=D,e[23]=Y):Y=e[23];let I,P;e[24]!==X||e[25]!==m?(P=()=>X(m-1),I=()=>X(m+1),e[24]=X,e[25]=m,e[26]=I,e[27]=P):(I=e[26],P=e[27]);let A;e[28]!==h||e[29]!==p?(A=()=>{Qr(p||h)},e[28]=h,e[29]=p,e[30]=A):A=e[30];const q=m>0,K=m>=0&&m<k.length-1;let te;e[31]!==h||e[32]!==$||e[33]!==B||e[34]!==I||e[35]!==A||e[36]!==q||e[37]!==K||e[38]!==Y||e[39]!==P?(te=s.jsx(Lf,{address:h,onAddressChange:f,onSubmit:$,suggestions:B,onForgetSuggestion:Y,onBack:P,onForward:I,onReload:S,onOpenExternal:A,canGoBack:q,canGoForward:K,isLoading:!1}),e[31]=h,e[32]=$,e[33]=B,e[34]=I,e[35]=A,e[36]=q,e[37]=K,e[38]=Y,e[39]=P,e[40]=te):te=e[40];let ae;e[41]!==p||e[42]!==$||e[43]!==j||e[44]!==o?(ae=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${j}`):s.jsx(zf,{onOpen:$})}),e[41]=p,e[42]=$,e[43]=j,e[44]=o,e[45]=ae):ae=e[45];let re;return e[46]!==te||e[47]!==ae?(re=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[te,ae]}),e[46]=te,e[47]=ae,e[48]=re):re=e[48],re},nS=t=>{const e=Ze.c(3),[n]=c.useState(qv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(tS,{...t}):s.jsx(sS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function rS(t){return t.setContextPanelTabTargetPath}function oS(t){return t+1}function iS(t){return t.recordVisit}function aS(t){return t.forget}const lS=Dn(()=>sn(()=>import("./WalkthroughView-H-tYOvhO.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,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),cS=Dn(()=>sn(()=>import("./DiffView-D7JQzQVZ.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,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,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,113,114,115,116,129,117,118,119,120,121,130,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),dS=Dn(()=>sn(()=>import("./FilesView-DC2gadXM.js"),__vite__mapDeps([131,1,2,4,5,6,7,8,9,3,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,84,85,86,132,133,134,135,136,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,113,114,137,138,120,121,118,139,125,119,140])).then(t=>({default:t.FilesView}))),uS=Dn(()=>sn(()=>import("./GitView-Gzl0wbdd.js"),__vite__mapDeps([141,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,84,85,86,142,130,117,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,113,114,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),fS=Dn(()=>sn(()=>import("./LinearIssuesView-X27TCI3v.js"),__vite__mapDeps([143,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])).then(t=>({default:t.LinearIssuesView}))),mS=Dn(()=>sn(()=>import("./PlanView-LcfEbBPi.js"),__vite__mapDeps([144,1,2,4,5,6,7,8,9,132,57,58,59,60,61,62,79,55,56,63,133,134,135,3,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,119,140,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Wf=c.lazy(()=>sn(()=>import("./PluginPane-DPWPLc2f.js").then(t=>t.p),__vite__mapDeps([86,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])).then(t=>({default:t.PluginPane}))),Kf={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},hS=t=>{const e=Ze.c(12),{mode:n,docking:r}=t,[i,o]=c.useState(null),l=Kf[r.dock],a=Math.max(lg,i??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=Me("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let h;e[3]!==l.vertical||e[4]!==a?(h=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=h):h=e[5];let f;e[6]!==n?(f=s.jsx(Wf,{mode:n,onResize:o}),e[6]=n,e[7]=f):f=e[7];let p;return e[8]!==u||e[9]!==h||e[10]!==f?(p=s.jsx("div",{className:u,style:h,children:f}),e[8]=u,e[9]=h,e[10]=f,e[11]=p):p=e[11],p},Oc=c.lazy(()=>sn(()=>import("./GuestSurfacePane-CrOhlIdt.js"),__vite__mapDeps([145,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,86])).then(t=>({default:t.GuestSurfacePane}))),Vf=320,il=600,pS=400,gS=100,xS=24,Vo=new Map,bS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Bc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Vf,Math.round(t))):il,Fc=t=>{const e=t??(typeof window<"u"?window.innerWidth:il*2);return Math.max(Vf,e-pS)},yS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},wS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Uf=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Un(t)?Fa.getState().guests.find(r=>r.id===Ro(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),vS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},SS=(t,e,n)=>{if(t.mode==="chat"){const r=va(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?rl(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?vS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Uf(t.mode,n)},jS=t=>{const e=Ze.c(8),{mode:n}=t,r=Ka();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=h=>h.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??cg,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Xr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Lc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Wa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(pf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(O,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(O,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(O,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(O,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(O,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(O,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(O,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(O,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(O,{name:"chat-4",className:"h-3.5 w-3.5"});if(Un(t.mode))return s.jsx(jS,{mode:t.mode});if(t.mode==="browser"){const n=kS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(O,{name:"global",className:"h-3.5 w-3.5"})}},kS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},CS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=St(),i=Ae(g=>g.contextEditorTreeWidth),o=Ae(g=>g.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),h=c.useRef(null),f=c.useRef(null),p=c.useRef(null),x=c.useCallback(g=>{const j=p.current;j&&(j.style.width=`${g}px`,j.style.setProperty("--oc-editor-tree-width",`${g}px`))},[]),b=g=>{if(t){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{}f.current=g.pointerId,a(!0),d.current=g.clientX,u.current=i,h.current=i,g.preventDefault()}},k=g=>{if(!l||f.current!==g.pointerId)return;const j=d.current-g.clientX,S=Wi(u.current+j);h.current!==S&&(h.current=S,x(S))},y=g=>{if(f.current!==g.pointerId)return;try{g.currentTarget.releasePointerCapture(g.pointerId)}catch{}const j=Wi(h.current??i);f.current=null,h.current=null,a(!1),o(j)},m=t?i:0;return s.jsxs("div",{ref:p,className:Me("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?h.current??m:m}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?h.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Me("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:k,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Me("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(z1,{visible:t&&e})})]})},va=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,NS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},AS=(t,e)=>{if(e.length===0)return Vo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Vo:r},PS=(t,e)=>{const n=ag(t),r=c.useRef(Vo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=AS(n.getState().session,i.current);return NS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Vo)},DS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,IS=()=>{const{t}=St(),e=Zn()??"",n=c.useMemo(()=>bS(e),[e]),r=Ae(V=>n?V.contextPanelByDirectory[n]:void 0),i=Ae(V=>V.closeContextPanel),o=Ae(V=>V.closeContextPanelTab),l=Ae(V=>V.openContextPanelTab),a=Ae(V=>V.toggleContextPanelExpanded),d=Ae(V=>V.setContextPanelWidth),u=Ae(V=>V.setActiveContextPanelTab),h=Ae(V=>V.openAgentBrowserTab);c.useEffect(()=>{if(e)return Zw(V=>h(e,V))},[e,h]);const f=Ae(V=>V.openContextFile);c.useEffect(()=>Pn(V=>{if(V.type!=="file-open-request")return;const Fe=V.directory??e;Fe&&f(Fe,V.path)}),[e,f]);const p=Ae(V=>V.reorderContextPanelTabs),x=Js(V=>V.setSelectedPath),b=Ae(V=>V.contextEditorTreeVisible),k=Ae(V=>V.contextEditorTreeWidth),y=Ae(V=>V.setContextEditorTreeWidth),m=Ae(V=>V.toggleContextEditorTree),g=Ae(V=>V.contextEditorVisible),j=Ae(V=>V.toggleContextEditor),S=Ae(V=>V.openNewContextBrowserTab),w=Cf(V=>V.byOrigin),C=Ae(V=>V.allowPromptingSubagentSessions),{themeMode:v,setThemeMode:R,lightThemeId:T,darkThemeId:D,currentTheme:F}=Cn(),B=c.useMemo(()=>r?.tabs??[],[r?.tabs]),E=B.find(V=>V.id===r?.activeTabId)??B[B.length-1]??null,$=E?.mode==="browser"?E.id:null;c.useEffect(()=>{$&&Jw($)},[$]);const L=!!(r?.isOpen&&E),[X,Y]=c.useState(null),I=c.useMemo(()=>B.some(V=>V.mode==="file"&&V.targetPath),[B]),P=I&&(g||!b),A=E?.mode??null,q=A==="file"&&!P,K=!!(L&&r?.expanded&&!q),te=A?r?.widthByMode?.[A]:void 0,ae=A?r?.widthFractionByMode?.[A]:void 0,re=A?sg(A):.5,he=X??(typeof window<"u"?window.innerWidth:il*2),ce=ae!=null&&X!=null?Math.round(ae*X):te,Te=q?k:Bc(ce??Math.round(re*he),Fc(X??he));c.useEffect(()=>{!n||!A||q||ae!=null||te==null||X==null||d(n,A,te,X)},[A,X,n,q,te,ae,d]);const ve=c.useMemo(()=>{const V=[];for(const Fe of B){if(Fe.mode!=="chat")continue;const Ye=va(Fe.dedupeKey);Ye&&!V.includes(Ye)&&V.push(Ye)}return V},[B]),pe=PS(n||void 0,ve),[Ne,U]=c.useState(!1),Z=c.useRef(0),de=c.useRef(Te),ye=c.useRef(null),H=c.useRef(null),je=c.useRef(null),Ee=c.useRef(new Map),ge=c.useRef(new Map),ne=c.useRef(!1);c.useLayoutEffect(()=>{const V=je.current?.parentElement;if(!V||typeof ResizeObserver>"u")return;const Fe=new ResizeObserver(()=>{Y(V.clientWidth||null)});return Fe.observe(V),Y(V.clientWidth||null),()=>Fe.disconnect()},[]),c.useEffect(()=>{if(!L||ne.current){ne.current=L;return}const V=window.requestAnimationFrame(()=>{je.current?.focus({preventScroll:!0})});return ne.current=!0,()=>window.cancelAnimationFrame(V)},[L]);const be=c.useRef(null),G=c.useRef(null),z=c.useCallback(()=>{G.current=null;const V=je.current,Fe=ye.current;!V||Fe===null||V.style.setProperty("--oc-context-panel-width",`${Fe}px`)},[]);c.useEffect(()=>()=>{G.current!==null&&clearTimeout(G.current)},[]);const J=c.useCallback(V=>{const Fe=be.current,Ye=q?Wi(V):Bc(V,Fc(Fe));return Fe===null?Ye:Math.min(Ye,Math.max(1,Fe))},[q]),ue=c.useCallback(V=>{!L||K||!n||(H.current=V.pointerId,U(!0),Z.current=V.clientX,de.current=Te,ye.current=Te,be.current=yS(je.current),document.documentElement.style.cursor="col-resize",V.preventDefault())},[n,K,L,Te]),le=c.useCallback(()=>{const V=J(ye.current??Te),Fe=be.current;ye.current=null,be.current=null,G.current!==null&&(clearTimeout(G.current),G.current=null),document.documentElement.style.cursor="",q?y(V):n&&A&&d(n,A,V,Fe??void 0),U(!1),H.current=null},[A,J,n,q,y,d,Te]);c.useEffect(()=>{if(!Ne)return;const V=Qe=>{if(H.current!==Qe.pointerId)return;const xe=Z.current-Qe.clientX,st=J(de.current+xe);ye.current!==st&&(ye.current=st,G.current===null&&(G.current=setTimeout(z,gS)))},Fe=Qe=>{H.current===Qe.pointerId&&le()},Ye=()=>{le()};return window.addEventListener("pointermove",V),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",Ye),()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",Ye)}},[z,J,le,Ne]),c.useEffect(()=>{Ne||(ye.current=null,document.documentElement.style.cursor="")},[Ne]);const W=c.useCallback(()=>{n&&i(n)},[i,n]),M=c.useCallback(()=>{n&&a(n)},[n,a]),_=c.useCallback(V=>{V.key==="Escape"&&(V.target instanceof Node&&!V.currentTarget.contains(V.target)||ng(V.target)||rg(V.target)||(V.preventDefault(),V.stopPropagation(),W()))},[W]);c.useEffect(()=>{if(!(!n||!E)&&E.mode==="file"&&E.targetPath){x(n,E.targetPath,{allowOutsideRoot:!0});return}},[E,n,x]);const ee=c.useMemo(()=>B.filter(V=>V.mode==="chat"),[B]),oe=L&&E?.mode==="chat"?E.id:null,fe=L&&E?.mode==="chat"?va(E.dedupeKey):null,ie=yb(ee,oe);c.useEffect(()=>{if(!L||!n||!fe||typeof window>"u")return;const V=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Ci(n,fe,!1);return}Iu(fe),Ci(n,fe,!0)};V();const Fe=window.setInterval(V,1e4);return window.addEventListener("focus",V),window.addEventListener("blur",V),document.addEventListener("visibilitychange",V),()=>{window.clearInterval(Fe),window.removeEventListener("focus",V),window.removeEventListener("blur",V),document.removeEventListener("visibilitychange",V),Ci(n,fe,!1)}},[fe,n,L]);const Le=c.useCallback((V,Fe,Ye)=>wb(ge.current,V,Fe,n||null,Ye,{mode:v,lightThemeId:T,darkThemeId:D,currentTheme:F},{allowPromptingSubagentSessions:C}),[C,F,D,n,T,v]),$e=ie&&fe?Le(ie.id,fe,ie.readOnly):null;c.useEffect(()=>{const V=new Set(B.map(Fe=>Fe.id));for(const Fe of ge.current.keys())V.has(Fe)||ge.current.delete(Fe)},[B]);const Pe=c.useCallback(V=>{!n||E?.mode!=="diff"||l(n,{mode:"diff",targetPath:E.targetPath,stagedDiff:V==="staged",diffScope:V})},[E,n,l]),Oe=c.useCallback(()=>{if(typeof window>"u")return;const V={themeMode:v,lightThemeId:T,darkThemeId:D,currentTheme:F};for(const Fe of Ee.current.values()){const Ye=Fe.contentWindow;Ye&&Ye.postMessage({type:"openchamber:theme-sync",payload:V},window.location.origin)}},[F,D,T,v]),Q=c.useCallback(()=>{if(typeof window>"u")return;const V={allowPromptingSubagentSessions:C};for(const Fe of Ee.current.values()){const Ye=Fe.contentWindow;Ye&&Ye.postMessage({type:"openchamber:chat-settings-sync",payload:V},window.location.origin)}},[C]),Ce=c.useCallback((V,Fe,Ye)=>{const Qe=Fe.contentWindow;Qe&&Qe.postMessage({type:of,payload:{visible:oe===V}},Ye)},[oe]),Se=c.useCallback(()=>{if(!(typeof window>"u"))for(const[V,Fe]of Ee.current.entries())Ce(V,Fe,window.location.origin)},[Ce]);c.useEffect(()=>{if(typeof window>"u")return;const V=Fe=>{if(Fe.origin!==window.location.origin)return;const Ye=Array.from(Ee.current.entries()).find(([,ot])=>ot.contentWindow===Fe.source);if(!Ye)return;const Qe=Fe.data;if(Qe?.type===vb){const[ot,vt]=Ye;Ce(ot,vt,Fe.origin);return}if(Qe?.type===Sb){if(typeof Qe.requestId!="string"||!Qe.requestId)return;const ot=Wt(),vt={apiBaseUrl:mn(),clientToken:Ur(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Wd(),relayHostId:ot.startsWith("host:")?ot.slice(5):"",relay:ch()??void 0};Fe.source?.postMessage({type:jb,requestId:Qe.requestId,payload:vt},Fe.origin);return}if(Qe?.type==="openchamber:theme-sync-request"){Oe();return}if(Qe?.type==="openchamber:chat-settings-request"){Q();return}if(Qe?.type!=="openchamber:cycle-theme-request")return;const xe=["light","dark","system"],Re=(xe.indexOf(v)+1)%xe.length;R(xe[Re])};return window.addEventListener("message",V),()=>window.removeEventListener("message",V)},[Q,Ce,Oe,R,v]),c.useLayoutEffect(()=>{B.some(Fe=>Fe.mode==="chat")&&(Oe(),Q(),Se())},[D,T,Q,Se,Oe,B,v]);const Ke=E?.mode==="file"||E?.mode==="chat"||E?.mode==="browser",et=c.useMemo(()=>E?B.filter(V=>V.mode===E.mode):[],[E,B]),it=c.useMemo(()=>et.map(V=>{const Fe=SS(V,pe,t),Ye=DS(Fe,xS),Qe=wS(V.targetPath,e);return{id:V.id,label:Ye,icon:Lc(V,w),title:Qe?`${Fe}: ${Qe}`:Fe,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ye})}}),[et,e,w,pe,t]),rt=E?.mode==="context"?s.jsx(iw,{}):E?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(uS,{isActive:L})}):E?.mode==="pr"?s.jsx(h1,{}):E?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(fS,{})}):E?.mode==="notes"?s.jsx(Fh,{}):E?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(mS,{targetPath:E.targetPath,savedProjectPlan:E.projectPlanId&&E.projectPlanRef?{projectRef:E.projectPlanRef,planId:E.projectPlanId}:null})}):null,pt=c.useMemo(()=>B.filter(V=>V.mode==="browser"),[B]),ht=c.useMemo(()=>B.filter(V=>V.mode==="diff"),[B]),tt=c.useMemo(()=>B.find(V=>V.mode==="terminal")??null,[B]),At=c.useMemo(()=>B.some(V=>V.mode==="walkthrough"),[B]),jt=c.useMemo(()=>B.filter(V=>Un(V.mode)),[B]),we=Fa(V=>V.guests),Xe=c.useMemo(()=>new Set(we.filter(og).map(V=>V.id)),[we]),mt=c.useMemo(()=>{const V=new Map;for(const Fe of we){const Ye=ig(Fe);Ye&&V.set(Fe.id,Ye)}return V},[we]),qe=c.useMemo(()=>B.some(V=>V.mode==="file"),[B]),ft=E?.mode==="file",se=Ae(V=>V.closeContextPanelTabs),me=c.useCallback(V=>{if(!n)return null;const{id:Fe,index:Ye,allIds:Qe,close:xe}=V,st=()=>se(n,Qe.filter(He=>He!==Fe)),Re=()=>se(n,Qe.slice(0,Ye)),ot=()=>se(n,Qe.slice(Ye+1)),vt=()=>se(n,Qe),De=Qe.length>1,gt=Ye===0,Ct=Ye===Qe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(zn,{onClick:xe,children:[s.jsx(O,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Hi,{}),s.jsxs(zn,{onClick:st,disabled:!De,children:[s.jsx(O,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(zn,{onClick:Re,disabled:gt,children:[s.jsx(O,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(zn,{onClick:ot,disabled:Ct,children:[s.jsx(O,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Hi,{}),s.jsxs(zn,{onClick:vt,disabled:!De,children:[s.jsx(O,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[se,n,t]),Ie=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ke?s.jsx(Yd,{items:it,activeId:E?.id??null,onSelect:V=>{n&&u(n,V)},onClose:V=>{n&&o(n,V)},onReorder:(V,Fe)=>{n&&p(n,V,Fe)},layoutMode:"scrollable",variant:"default",tabContextMenu:me}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[E?Lc(E,w):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:E?Uf(E.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[E?.mode==="browser"?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(O,{name:"add",className:"h-3.5 w-3.5"})}):null,ft&&I?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":P,children:s.jsx(O,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,ft?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:m,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(O,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,q?null:s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:M,className:"h-7 w-7 p-0",title:t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:K?s.jsx(O,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:W,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})})]})]}),We=L?K?{"--oc-context-panel-width":X!==null?`${X}px`:"100%",width:X!==null?`${X}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Te}px`}:{"--oc-context-panel-width":`${Te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:je,"data-context-panel":"true",tabIndex:-1,inert:!L||void 0,className:Me("flex min-h-0 flex-col overflow-hidden bg-background",K?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!L&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:_,style:We,children:[L&&!K&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),L&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!K&&s.jsx("div",{className:Me("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Ne&&"bg-[var(--interactive-border)]"),onPointerDown:ue,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Me("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!L&&"pointer-events-none select-none opacity-0"),style:{width:K?X!==null?`${X}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!L,children:[Ie,s.jsxs("div",{className:Me("relative min-h-0 flex-1 overflow-hidden",Ne&&"pointer-events-none"),children:[qe?s.jsxs("div",{className:Me("absolute inset-0 flex",ft?"flex":"hidden"),children:[I||!b?s.jsx("div",{className:Me("h-full min-w-0 flex-1",I&&!P&&"hidden"),children:I?s.jsx(c.Suspense,{fallback:null,children:s.jsx(dS,{mode:"editor-only",visible:L&&ft&&P})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(O,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(CS,{visible:b,active:L&&ft,fill:!P})]}):null,ie&&fe&&$e?s.jsx("iframe",{ref:V=>{if(!V){Ee.current.delete(ie.id);return}Ee.current.set(ie.id,V)},src:$e,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:fe}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Oe(),Q(),Se()}},ie.id):null,pt.map(V=>s.jsx("div",{className:Me("absolute inset-0",E?.id!==V.id&&"invisible pointer-events-none"),"aria-hidden":E?.id!==V.id||void 0,children:s.jsx(nS,{initialUrl:V.targetPath??"",directory:n,tabID:V.id})},V.id)),ht.map(V=>s.jsx("div",{className:Me("absolute inset-0",E?.id!==V.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(cS,{visible:L&&E?.id===V.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:V.diffScope??(V.stagedDiff?"staged":"working"),onDiffScopeChange:Pe,targetFilePath:V.targetPath,flushContent:!0})})},V.id)),tt?s.jsx("div",{className:Me("absolute inset-0",E?.mode==="terminal"?"block":"hidden"),children:s.jsx(Lh,{visible:L&&E?.mode==="terminal",directory:tt.targetDirectory})}):null,At?s.jsx("div",{className:Me("absolute inset-0",E?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(lS,{directory:e,visible:L&&E?.mode==="walkthrough"})})}):null,jt.map(V=>{if(!Un(V.mode))return null;const Fe=Ro(V.mode),Ye=Xe.has(Fe),Qe=mt.get(Fe),xe=E?.id===V.id,st=xe&&L;return Ye&&!Qe&&!st?null:s.jsx("div",{className:Me("absolute inset-0",xe?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ye?Qe?s.jsxs("div",{className:Me("flex h-full",Kf[Qe.dock].container),children:[s.jsx(hS,{mode:V.mode,docking:Qe}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:st?s.jsx(Oc,{mode:V.mode}):null})]}):s.jsx(Oc,{mode:V.mode}):s.jsx(Wf,{mode:V.mode})})},V.id)}),E?.mode!=="chat"&&!ft&&E?.mode!=="browser"&&E?.mode!=="diff"&&E?.mode!=="terminal"&&E?.mode!=="walkthrough"&&!(E&&Un(E.mode))?rt:null]})]})]})},TS=t=>{const e=Ze.c(43),{open:n,onOpenChange:r}=t,{t:i}=St(),o=Ae(ES),l=Ae(RS),a=Ae(MS),d=Ae(OS),u=Ka();let h;e[0]!==o||e[1]!==u?(h=Tu(o,u),e[0]=o,e[1]=u,e[2]=h):h=e[2];const f=h,p=l.length===0;let x;if(e[3]!==l||e[4]!==f){let T;e[6]!==l?(T=D=>l.includes(D.id),e[6]=l,e[7]=T):T=e[7],x=f.every(T),e[3]=l,e[4]=f,e[5]=x}else x=e[5];const b=x;let k;e[8]!==i?(k=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=k):k=e[9];let y;e[10]!==k?(y=s.jsx(Bs,{children:k}),e[10]=k,e[11]=y):y=e[11];let m;e[12]!==i?(m=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=m):m=e[13];let g;e[14]!==m?(g=s.jsx(Fs,{children:m}),e[14]=m,e[15]=g):g=e[15];let j;e[16]!==y||e[17]!==g?(j=s.jsxs(Us,{children:[y,g]}),e[16]=y,e[17]=g,e[18]=j):j=e[18];let S;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let T;e[24]!==l||e[25]!==a||e[26]!==i?(T=D=>s.jsx(dg,{settingsItem:`layout.context-rail.surface.${D.id}`,checked:!l.includes(D.id),onChange:F=>a(D.id,F),label:D.label??i(D.labelKey),ariaLabel:D.label??i(D.labelKey)},D.id),e[24]=l,e[25]=a,e[26]=i,e[27]=T):T=e[27],S=f.map(T),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=S}else S=e[23];let w;e[28]!==S?(w=s.jsx("div",{className:"flex flex-col",children:S}),e[28]=S,e[29]=w):w=e[29];let C;e[30]!==p||e[31]!==b||e[32]!==d||e[33]!==i?(C=p?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ut,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=p,e[31]=b,e[32]=d,e[33]=i,e[34]=C):C=e[34];let v;e[35]!==C||e[36]!==j||e[37]!==w?(v=s.jsxs(ys,{className:"max-w-md",children:[j,w,C]}),e[35]=C,e[36]=j,e[37]=w,e[38]=v):v=e[38];let R;return e[39]!==r||e[40]!==n||e[41]!==v?(R=s.jsx(bs,{open:n,onOpenChange:r,children:v}),e[39]=r,e[40]=n,e[41]=v,e[42]=R):R=e[42],R};function ES(t){return t.contextRailOrder}function RS(t){return t.contextRailHiddenSurfaces}function MS(t){return t.setContextRailSurfaceVisible}function OS(t){return t.setContextRailHiddenSurfaces}const Hf=150,BS=500,FS=[],LS=t=>t>99?"99+":String(t),_S=t=>{const e=Ze.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:p}=t;let x;e[0]!==n.id?(x={id:n.id},e[0]=n.id,e[1]=x):x=e[1];const{attributes:b,listeners:k,setNodeRef:y,transform:m,transition:g,isDragging:j}=di(x);let S;e[2]!==a?(S=a!=null&&a>0?LS(a):null,e[2]=a,e[3]=S):S=e[3];const w=S;let C;e[4]!==m?(C=ui.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let v;e[6]!==C||e[7]!==g?(v={transform:C,transition:g},e[6]=C,e[7]=g,e[8]=v):v=e[8];const R=j&&"z-10 opacity-70";let T;e[9]!==R?(T=Me("relative",R),e[9]=R,e[10]=T):T=e[10];let D;e[11]!==p||e[12]!==n?(D=()=>p(n),e[11]=p,e[12]=n,e[13]=D):D=e[13];const F=d??o,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==B?(E=Me("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=E):E=e[15];let $;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?($=n.id==="diff"?s.jsx(pf,{className:"h-[18px] w-[18px]"}):s.jsx(Xr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=$):$=e[19];let L;e[20]!==w||e[21]!==h||e[22]!==i||e[23]!==f?(L=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):w?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:w}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=w,e[21]=h,e[22]=i,e[23]=f,e[24]=L):L=e[24];let X;e[25]!==b||e[26]!==r||e[27]!==k||e[28]!==E||e[29]!==$||e[30]!==L||e[31]!==D||e[32]!==F?(X=s.jsx(yt,{asChild:!0,children:s.jsxs("button",{type:"button",...b,...k,onClick:D,"aria-label":F,"aria-pressed":r,className:E,children:[$,L]})}),e[25]=b,e[26]=r,e[27]=k,e[28]=E,e[29]=$,e[30]=L,e[31]=D,e[32]=F,e[33]=X):X=e[33];let Y;e[34]!==o?(Y=s.jsx("span",{children:o}),e[34]=o,e[35]=Y):Y=e[35];let I;e[36]!==l?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=I):I=e[37];let P;e[38]!==u?(P=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=P):P=e[39];let A;e[40]!==Y||e[41]!==I||e[42]!==P?(A=s.jsx(wt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[Y,I,P]})}),e[40]=Y,e[41]=I,e[42]=P,e[43]=A):A=e[43];let q;e[44]!==X||e[45]!==A?(q=s.jsxs(bt,{delayDuration:Hf,children:[X,A]}),e[44]=X,e[45]=A,e[46]=q):q=e[46];let K;return e[47]!==y||e[48]!==q||e[49]!==v||e[50]!==T?(K=s.jsx("div",{ref:y,style:v,className:T,children:q}),e[47]=y,e[48]=q,e[49]=v,e[50]=T,e[51]=K):K=e[51],K},$S=()=>{const t=Ze.c(92),{t:e}=St(),n=Zn();let r;t[0]!==n?(r=n?$n(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Ae(o),a=Ae(zS),d=Ae(WS),u=Ae(KS),h=Ae(VS),f=Ae(US),p=Ae(HS),x=Ae(GS),b=La(qS),k=Ji(YS),y=Ji(QS),m=hn(XS),g=hn(JS),{screenWidth:j}=Nn(),S=_a(i||null);let w;t[4]!==x?(w=Zi("switch_context_surface",x),t[4]=x,t[5]=w):w=t[5];const C=w,[v,R]=c.useState(!1);let T,D;t[6]!==C?(T=()=>{const le=new Set;let W=null,M=!1;const _=ZS,ee=()=>{Ol(C,le)?!M&&W===null&&(W=setTimeout(()=>R(!0),BS)):(M=!1,W!==null&&(clearTimeout(W),W=null),R(!1))},oe=Le=>{if(le.add(Le.key.toLowerCase()),_(Le.key)&&Ol(C,le)){M=!0,W!==null&&(clearTimeout(W),W=null),R(!1);return}ee()},fe=Le=>{le.delete(Le.key.toLowerCase()),ee()},ie=()=>{le.clear(),M=!1,W!==null&&(clearTimeout(W),W=null),R(!1)};return window.addEventListener("keydown",oe,!0),window.addEventListener("keyup",fe,!0),window.addEventListener("blur",ie),()=>{window.removeEventListener("keydown",oe,!0),window.removeEventListener("keyup",fe,!0),window.removeEventListener("blur",ie),W!==null&&clearTimeout(W)}},D=[C],t[6]=C,t[7]=T,t[8]=D):(T=t[7],D=t[8]),c.useEffect(T,D);let F;t[9]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},t[9]=F):F=t[9];let B;t[10]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{delay:200,tolerance:6}},t[10]=B):B=t[10];const E=oi(fn(ai,F),fn(ii,B)),$=Ka(),L=Ml(ej),X=Ml(tj),Y=l?.tabs??FS;let I;t[11]!==l?.activeTabId||t[12]!==Y?(I=Y.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=Y,t[13]=I):I=t[13];const P=I,A=l?.isOpen?P?.mode??null:null,q=S?.files.length??0;let K;t[14]!==u||t[15]!==d||t[16]!==g||t[17]!==$||t[18]!==y||t[19]!==b||t[20]!==j||t[21]!==Y?(K=ug({railOrder:d,hiddenSurfaces:u,planModeEnabled:b,isVSCode:kn(),screenWidth:j,tabs:Y,linearConnected:y,githubConnected:g,extras:$}),t[14]=u,t[15]=d,t[16]=g,t[17]=$,t[18]=y,t[19]=b,t[20]=j,t[21]=Y,t[22]=K):K=t[22];const te=K;let ae,re;t[23]!==A||t[24]!==p||t[25]!==i||t[26]!==k||t[27]!==y?(re=()=>{!i||!k||y||A!=="linear"||p(i)},ae=[A,p,i,k,y],t[23]=A,t[24]=p,t[25]=i,t[26]=k,t[27]=y,t[28]=ae,t[29]=re):(ae=t[28],re=t[29]),c.useEffect(re,ae);let he,ce;t[30]!==A||t[31]!==p||t[32]!==i||t[33]!==m||t[34]!==g?(he=()=>{!i||!m||g||A!=="pr"||p(i)},ce=[A,p,i,m,g],t[30]=A,t[31]=p,t[32]=i,t[33]=m,t[34]=g,t[35]=he,t[36]=ce):(he=t[35],ce=t[36]),c.useEffect(he,ce);const[Te,ve]=c.useState(!1);let pe;t[37]!==$||t[38]!==h?(pe=le=>{const{active:W,over:M}=le;if(!M||W.id===M.id)return;const _=Tu(Ae.getState().contextRailOrder,$).map(sj),ee=_.indexOf(W.id),oe=_.indexOf(M.id);ee===-1||oe===-1||h(Zu(_,ee,oe))},t[37]=$,t[38]=h,t[39]=pe):pe=t[39];const Ne=pe;if(!i)return null;let U;t[40]!==e?(U=e("contextRail.aria.rail"),t[40]=e,t[41]=U):U=t[41];let Z;t[42]!==te?(Z=te.map(nj),t[42]=te,t[43]=Z):Z=t[43];let de;if(t[44]!==A||t[45]!==q||t[46]!==X||t[47]!==i||t[48]!==L||t[49]!==f||t[50]!==v||t[51]!==te||t[52]!==e||t[53]!==a){let le;t[55]!==A||t[56]!==q||t[57]!==X||t[58]!==i||t[59]!==L||t[60]!==f||t[61]!==v||t[62]!==e||t[63]!==a?(le=(W,M)=>{const _=W.label??e(W.labelKey),ee=W.id==="git"&&!a?q:0,oe=Un(W.mode)&&A!==W.mode?L[Ro(W.mode)]??0:0,fe=ee>0?ee:oe>0?oe:null,ie=fe!==null&&ee===0;return s.jsx(_S,{surface:W,isActive:A===W.mode,showActivityDot:!1,label:_,description:e(W.descriptionKey),badgeCount:fe,badgeAriaLabel:fe!==null?e(ie?fe===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":fe===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:_,count:fe}):null,badgeDescription:fe!==null?e(ie?fe===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":fe===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:fe}):null,orderNumber:M+1,showOrderNumber:v,onSelect:Le=>{Un(Le.mode)&&X(Ro(Le.mode)),f(i,Le.mode)}},W.id)},t[55]=A,t[56]=q,t[57]=X,t[58]=i,t[59]=L,t[60]=f,t[61]=v,t[62]=e,t[63]=a,t[64]=le):le=t[64],de=te.map(le),t[44]=A,t[45]=q,t[46]=X,t[47]=i,t[48]=L,t[49]=f,t[50]=v,t[51]=te,t[52]=e,t[53]=a,t[54]=de}else de=t[54];let ye;t[65]!==Z||t[66]!==de?(ye=s.jsx(Xa,{items:Z,strategy:ef,children:de}),t[65]=Z,t[66]=de,t[67]=ye):ye=t[67];let H;t[68]!==Ne||t[69]!==E||t[70]!==ye?(H=s.jsx(li,{sensors:E,collisionDetection:ci,onDragEnd:Ne,children:ye}),t[68]=Ne,t[69]=E,t[70]=ye,t[71]=H):H=t[71];let je;t[72]!==e?(je=e("contextRail.configure.open"),t[72]=e,t[73]=je):je=t[73];let Ee;t[74]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>ve(!0),t[74]=Ee):Ee=t[74];let ge;t[75]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(O,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=ge):ge=t[75];let ne;t[76]!==je?(ne=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":je,onClick:Ee,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ge})}),t[76]=je,t[77]=ne):ne=t[77];let be;t[78]!==e?(be=e("contextRail.configure.open"),t[78]=e,t[79]=be):be=t[79];let G;t[80]!==be?(G=s.jsx(wt,{side:"left",sideOffset:8,children:be}),t[80]=be,t[81]=G):G=t[81];let z;t[82]!==ne||t[83]!==G?(z=s.jsxs(bt,{delayDuration:Hf,children:[ne,G]}),t[82]=ne,t[83]=G,t[84]=z):z=t[84];let J;t[85]!==Te?(J=s.jsx(TS,{open:Te,onOpenChange:ve}),t[85]=Te,t[86]=J):J=t[86];let ue;return t[87]!==U||t[88]!==H||t[89]!==z||t[90]!==J?(ue=s.jsxs("nav",{"aria-label":U,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,z,J]}),t[87]=U,t[88]=H,t[89]=z,t[90]=J,t[91]=ue):ue=t[91],ue};function zS(t){return t.workStatusPanelVisible}function WS(t){return t.contextRailOrder}function KS(t){return t.contextRailHiddenSurfaces}function VS(t){return t.setContextRailOrder}function US(t){return t.openContextSurface}function HS(t){return t.closeContextPanel}function GS(t){return t.shortcutOverrides}function qS(t){return t.planModeEnabled}function YS(t){return t.hasChecked}function QS(t){return t.status?.connected===!0}function XS(t){return t.hasChecked}function JS(t){return t.status?.connected===!0}function ZS(t){return t.length===1&&t>="0"&&t<="9"}function ej(t){return t.countByGuest}function tj(t){return t.clearBadge}function sj(t){return t.id}function nj(t){return t.id}const rj=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),oj=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Or(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),ij=new Set,aj=[],Sa=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},lj=()=>{const t=Ze.c(183),{t:e}=St(),n=Ae(cj),r=Ae(dj),i=Ae(uj),o=Ae(fj),l=Ae(mj),a=Ae(hj),d=Ae(pj),u=Ae(gj),h=Ae(xj),f=Ae(bj),p=Ae(yj),x=Ae(wj),b=Ae(vj),k=nt(Sj),y=nt(jj),m=nt(kj),g=Hr(Cj);let j;t[0]!==n?(j=He=>n?He.activeSessions:aj,t[0]=n,t[1]=j):j=t[1];const S=us(j);let w;t[2]!==n?(w=He=>n?He.ids:ij,t[2]=n,t[3]=w):w=t[3];const C=Hr(w);let v;t[4]!==n?(v=He=>n?He.rankById:Ua,t[4]=n,t[5]=v):v=t[5];const R=Va(v),T=Jt(Nj),D=zt(Aj),F=zt(Pj),B=Zn(),E=$d(Dj),{files:$,git:L}=nn(),X=pn(Ij),{isMobile:Y}=Nn();let I;t[6]!==B?(I=B?Sa(B):null,t[6]=B,t[7]=I):I=t[7];const P=I,[A,q]=c.useState(""),te=Au(A,200).trim();let ae;t[8]!==A?(ae=A.trim(),t[8]=A,t[9]=ae):ae=t[9];const re=ae;let he,ce;t[10]!==n?(he=()=>{n&&q("")},ce=[n],t[10]=n,t[11]=he,t[12]=ce):(he=t[11],ce=t[12]),c.useEffect(he,ce);let Te,ve;t[13]!==S||t[14]!==X||t[15]!==L||t[16]!==n?(Te=()=>{if(!n||!L)return;const He=setTimeout(()=>{const Ue=new Set;for(const lt of S){const _e=xs(lt);!_e||Ue.has(_e)||(Ue.add(_e),X(_e,L))}},0);return()=>clearTimeout(He)},ve=[n,S,L,X],t[13]=S,t[14]=X,t[15]=L,t[16]=n,t[17]=Te,t[18]=ve):(Te=t[17],ve=t[18]),c.useEffect(Te,ve);let pe;t[19]!==r?(pe=()=>r(!1),t[19]=r,t[20]=pe):pe=t[20];const Ne=pe;let U;t[21]!==Ne?(U=He=>()=>{Ne(),He()},t[21]=Ne,t[22]=U):U=t[22];const Z=U;let de;t[23]!==D?.id||t[24]!==D?.path||t[25]!==T||t[26]!==m||t[27]!==Y||t[28]!==d||t[29]!==u||t[30]!==p||t[31]!==k||t[32]!==Z||t[33]!==x||t[34]!==b||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==g||t[39]!==a?(de=()=>{const He=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(O,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:Z(()=>{l(!1),k()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(O,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:Z(Tj)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(O,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:Z(Ej)},{id:"toggle-sidebar",title:e(Y?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(O,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(Y?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:Z(()=>{if(Y){const{isSessionSwitcherOpen:Ue}=Ae.getState();l(!Ue)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(O,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:Z(()=>{T&&u(T,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(O,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:Z(()=>{T&&d(T)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(O,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:Z(Rj)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(O,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:Z(Mj)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(O,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:Z(()=>i(!0))}];return He.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(O,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:Z(()=>{m&&T&&g({directory:T,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(O,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:Z(()=>{m&&Jn(m).then(Ue=>{if(Ue.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(O,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:Z(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(O,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:Z(()=>{l(!1),x(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(O,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:Z(()=>{T&&(b("notes"),u(T,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(O,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:Z(()=>{T&&(b("todos"),u(T,"notes"))})}),kn()||He.push({id:"restart-opencode",secondary:!0,title:e("commandPalette.item.restartOpenCode"),icon:s.jsx(O,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.restartOpenCode"),onSelect:Z(()=>{$h(e)})}),He.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(O,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:Z(Oj)}),Vr()&&He.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(O,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:Z(()=>{jn("desktop_open_draft_mini_chat_window",{directory:Sa(T||D?.path||""),projectId:D?.id??null}).catch(Bj)})}),He},t[23]=D?.id,t[24]=D?.path,t[25]=T,t[26]=m,t[27]=Y,t[28]=d,t[29]=u,t[30]=p,t[31]=k,t[32]=Z,t[33]=x,t[34]=b,t[35]=l,t[36]=i,t[37]=e,t[38]=g,t[39]=a,t[40]=de):de=t[40],D?.id,D?.path;let ye;t[41]!==de?(ye=de(),t[41]=de,t[42]=ye):ye=t[42];const H=ye,je=Ae(Fj);let Ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(Ee=en(),t[43]=Ee):Ee=t[43];const ge=Ee;let ne,be;t[44]===Symbol.for("react.memo_cache_sentinel")?(ne=kn(),be=!ge&&Ra(),t[44]=ne,t[45]=be):(ne=t[44],be=t[45]);let G;t[46]!==Y||t[47]!==je?(G={isVSCode:ne,isWeb:be,isDesktop:ge,isMobile:Y,routingAvailable:je},t[46]=Y,t[47]=je,t[48]=G):G=t[48];const z=G;let J;if(t[49]!==Z||t[50]!==i||t[51]!==o||t[52]!==z){let He;t[54]!==z?(He=lt=>lt.isAvailable?lt.isAvailable(z):!0,t[54]=z,t[55]=He):He=t[55];let Ue;t[56]!==Z||t[57]!==i||t[58]!==o?(Ue=lt=>{const _e=zh(lt.slug)??"settings-3",Ge=(lt.keywords??[]).join(" ");return{id:`settings:${lt.slug}`,title:lt.title,icon:lt.slug==="mcp"?s.jsx(gg,{className:"mr-2 h-4 w-4"}):s.jsx(O,{name:_e,className:"mr-2 h-4 w-4"}),searchText:`${lt.title} ${lt.group} ${Ge}`,onSelect:Z(()=>{o(lt.slug),i(!0)})}},t[56]=Z,t[57]=i,t[58]=o,t[59]=Ue):Ue=t[59],J=_h.filter(Lj).filter(He).map(Ue),t[49]=Z,t[50]=i,t[51]=o,t[52]=z,t[53]=J}else J=t[53];const ue=J;let le;if(t[60]!==S||t[61]!==C||t[62]!==R){const He=S.filter(_j);le=fg(He,C,R),t[60]=S,t[61]=C,t[62]=R,t[63]=le}else le=t[63];const W=le,M=Eu(),_=nt($j);let ee;t[64]!==M||t[65]!==_?(ee=(He,Ue)=>{const lt=_.get(He);return lt?.branch?lt.branch.trim()||null:Ue&&M.get(Ue)?.trim()||null},t[64]=M,t[65]=_,t[66]=ee):ee=t[66];const oe=ee;let fe;t[67]===Symbol.for("react.memo_cache_sentinel")?(fe=[],t[67]=fe):fe=t[67];const[ie,Le]=c.useState(fe),[$e,Pe]=c.useState(""),Oe=rj(P,te);let Q;t[68]!==P||t[69]!==Oe||t[70]!==n||t[71]!==E||t[72]!==Le||t[73]!==Pe||t[74]!==te?(Q=()=>{if(!n){Le([]),Pe("");return}if(!Oe){Le([]),Pe("");return}if(!P){Le([]),Pe("");return}let He=!1;return E(P,te,40,{type:"file"}).then(Ue=>{He||(Le(Ue.map(zj)),Pe(Oe))}).catch(()=>{He||(Le([]),Pe(Oe))}),()=>{He=!0}},t[68]=P,t[69]=Oe,t[70]=n,t[71]=E,t[72]=Le,t[73]=Pe,t[74]=te,t[75]=Q):Q=t[75];let Ce;t[76]!==P||t[77]!==Oe||t[78]!==n||t[79]!==E||t[80]!==te?(Ce=[n,P,te,Oe,E],t[76]=P,t[77]=Oe,t[78]=n,t[79]=E,t[80]=te,t[81]=Ce):Ce=t[81],c.useEffect(Q,Ce);const Se=re.length>0;let Ke;e:{if(!Se){let Ue;t[82]!==H?(Ue=H.filter(Wj).map(Kj),t[82]=H,t[83]=Ue):Ue=t[83],Ke=Ue;break e}let He;t[84]!==H||t[85]!==re?(He=Or(H,re,Vj,{limit:7,noFuzzy:!0}),t[84]=H,t[85]=re,t[86]=He):He=t[86],Ke=He}const et=Ke;let it;e:{if(!Se){let Ue;t[87]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[87]=Ue):Ue=t[87],it=Ue;break e}let He;t[88]!==re||t[89]!==ue?(He=Or(ue,re,Uj,{limit:7,noFuzzy:!0}),t[88]=re,t[89]=ue,t[90]=He):He=t[90],it=He}const rt=it;let pt;e:{if(!Se){let Ue;t[91]!==W?(Ue=W.slice(0,5).map(Hj),t[91]=W,t[92]=Ue):Ue=t[92],pt=Ue;break e}let He;t[93]!==re||t[94]!==W?(He=Or(W,re,Gj,{limit:7,threshold:.2}),t[93]=re,t[94]=W,t[95]=He):He=t[95],pt=He}const ht=pt;let tt;e:{if(!n){let Ue;t[96]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[96]=Ue):Ue=t[96],tt=Ue;break e}let He;t[97]!==ie||t[98]!==$e||t[99]!==Oe||t[100]!==te?(He=oj(ie,te,Oe,$e),t[97]=ie,t[98]=$e,t[99]=Oe,t[100]=te,t[101]=He):He=t[101],tt=He}const At=tt,jt=n&&Oe.length>0&&$e!==Oe;let we;e:{if(!Se){let Ue;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[102]=Ue):Ue=t[102],we=Ue;break e}let He;if(t[103]!==re||t[104]!==F){const Ue=F.map(qj);He=Or(Ue,re,Yj,{limit:7,threshold:.4}),t[103]=re,t[104]=F,t[105]=He}else He=t[105];we=He}const Xe=we;let mt,qe,ft,se,me,Ie,We,V,Fe,Ye,Qe,xe,st,Re;if(t[106]!==oe||t[107]!==Ne||t[108]!==P||t[109]!==$||t[110]!==Se||t[111]!==n||t[112]!==h||t[113]!==k||t[114]!==A||t[115]!==et||t[116]!==At||t[117]!==Xe||t[118]!==ht||t[119]!==rt||t[120]!==r||t[121]!==y||t[122]!==f||t[123]!==e){const He=et.map(Qj),Ue=rt.map(Xj),lt=ht.map(Jj),_e=Se?At.map(Zj):[],Ge=Se?Xe.map(e0):[];let Je;e:{if(!Se){Je=["commands","sessions"];break e}const Dt=t0,Pt=[{key:"commands",score:Dt(et)},{key:"settings",score:Dt(rt)},{key:"sessions",score:Dt(ht)},{key:"files",score:Dt(At)},{key:"projects",score:Dt(Xe)}];Pt.sort(s0),Je=Pt.map(n0)}const at=Je,Nt=Dt=>{Ne(),y(Dt.id,xs(Dt))},Bt=async Dt=>{if(!P)return;const Pt=await wf($,Dt,{directory:P});if(!Pt.ok){ze.error(vf(Pt.reason));return}h(P,Dt),Ne()},Ft=(Dt,Pt)=>{Ne(),k({selectedProjectId:Dt,directoryOverride:Pt})},Qt=Dt=>Hn(Jr(Dt,f));se=bs,xe=n,st=r;let Mt;t[138]!==e?(Mt=e("commandPalette.title"),t[138]=e,t[139]=Mt):Mt=t[139];let Gt;t[140]!==Mt?(Gt=s.jsx(Bs,{children:Mt}),t[140]=Mt,t[141]=Gt):Gt=t[141];let $t;t[142]!==e?($t=e("commandPalette.description"),t[142]=e,t[143]=$t):$t=t[143];let Zt;t[144]!==$t?(Zt=s.jsx(Fs,{children:$t}),t[144]=$t,t[145]=Zt):Zt=t[145],t[146]!==Gt||t[147]!==Zt?(Re=s.jsxs(Us,{className:"sr-only",children:[Gt,Zt]}),t[146]=Gt,t[147]=Zt,t[148]=Re):Re=t[148],ft=ys,Ye="overflow-hidden p-0",Qe=!0,qe=xg,We=!1,V="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let ts;t[149]!==e?(ts=e("commandPalette.input.placeholder"),t[149]=e,t[150]=ts):ts=t[150],t[151]!==A||t[152]!==ts?(Fe=s.jsx(bg,{value:A,onValueChange:q,placeholder:ts}),t[151]=A,t[152]=ts,t[153]=Fe):Fe=t[153],mt=yg;let Ot;t[154]!==e?(Ot=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Ot):Ot=t[155],t[156]!==Ot?(me=s.jsx(wg,{children:Ot}),t[156]=Ot,t[157]=me):me=t[157],Ie=at.map(Dt=>Dt==="commands"&&He.length>0?s.jsx(Pr,{children:He.map(Pt=>s.jsxs(Br,{value:Pt.id,onSelect:Pt.onSelect,children:[Pt.icon,s.jsx("span",{children:Pt.title}),Pt.shortcutId?s.jsx(mg,{children:Qt(Pt.shortcutId)}):null]},Pt.id))},"commands"):Dt==="settings"&&Ue.length>0?s.jsx(Pr,{children:Ue.map(r0)},"settings"):Dt==="sessions"&&lt.length>0?s.jsx(Pr,{children:lt.map(Pt=>{const fs=Pt.title||e("commandPalette.session.untitled"),Ts=xs(Pt),xn=oe(Pt.id,Ts);return s.jsxs(Br,{value:`session:${Pt.id}`,onSelect:()=>Nt(Pt),children:[s.jsx(O,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:fs}),xn?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:xn})]}):null]},Pt.id)})},"sessions"):Dt==="files"&&_e.length>0?s.jsx(Pr,{children:_e.map(Pt=>{const fs=hg(Pt.relativePath||Pt.name,{maxLength:80});return s.jsxs(Br,{value:`file:${Pt.path}`,onSelect:()=>{Bt(Pt.path)},children:[s.jsx(Wa,{filePath:Pt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Pt.relativePath,children:fs})]},`file:${Pt.path}`)})},"files"):Dt==="projects"&&Ge.length>0?s.jsx(Pr,{children:Ge.map(Pt=>{const fs=Pt.displayName;return s.jsxs(Br,{value:`project:${Pt.id}`,onSelect:()=>Ft(Pt.id,Pt.path),children:[s.jsx(O,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:fs}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Pt.path})]},`project:${Pt.id}`)})},"projects"):null),t[106]=oe,t[107]=Ne,t[108]=P,t[109]=$,t[110]=Se,t[111]=n,t[112]=h,t[113]=k,t[114]=A,t[115]=et,t[116]=At,t[117]=Xe,t[118]=ht,t[119]=rt,t[120]=r,t[121]=y,t[122]=f,t[123]=e,t[124]=mt,t[125]=qe,t[126]=ft,t[127]=se,t[128]=me,t[129]=Ie,t[130]=We,t[131]=V,t[132]=Fe,t[133]=Ye,t[134]=Qe,t[135]=xe,t[136]=st,t[137]=Re}else mt=t[124],qe=t[125],ft=t[126],se=t[127],me=t[128],Ie=t[129],We=t[130],V=t[131],Fe=t[132],Ye=t[133],Qe=t[134],xe=t[135],st=t[136],Re=t[137];let ot;t[158]!==jt||t[159]!==e?(ot=jt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=jt,t[159]=e,t[160]=ot):ot=t[160];let vt;t[161]!==mt||t[162]!==me||t[163]!==Ie||t[164]!==ot?(vt=s.jsxs(mt,{children:[me,Ie,ot]}),t[161]=mt,t[162]=me,t[163]=Ie,t[164]=ot,t[165]=vt):vt=t[165];let De;t[166]!==qe||t[167]!==We||t[168]!==V||t[169]!==Fe||t[170]!==vt?(De=s.jsxs(qe,{shouldFilter:We,className:V,children:[Fe,vt]}),t[166]=qe,t[167]=We,t[168]=V,t[169]=Fe,t[170]=vt,t[171]=De):De=t[171];let gt;t[172]!==ft||t[173]!==Ye||t[174]!==Qe||t[175]!==De?(gt=s.jsx(ft,{className:Ye,showCloseButton:Qe,children:De}),t[172]=ft,t[173]=Ye,t[174]=Qe,t[175]=De,t[176]=gt):gt=t[176];let Ct;return t[177]!==se||t[178]!==xe||t[179]!==st||t[180]!==Re||t[181]!==gt?(Ct=s.jsxs(se,{open:xe,onOpenChange:st,children:[Re,gt]}),t[177]=se,t[178]=xe,t[179]=st,t[180]=Re,t[181]=gt,t[182]=Ct):Ct=t[182],Ct};function cj(t){return t.isCommandPaletteOpen}function dj(t){return t.setCommandPaletteOpen}function uj(t){return t.setSettingsDialogOpen}function fj(t){return t.setSettingsPage}function mj(t){return t.setSessionSwitcherOpen}function hj(t){return t.toggleSidebar}function pj(t){return t.openContextOverview}function gj(t){return t.openContextSurface}function xj(t){return t.openContextFile}function bj(t){return t.shortcutOverrides}function yj(t){return t.openMultiRunLauncher}function wj(t){return t.setArchivePageOpen}function vj(t){return t.setProjectContextTab}function Sj(t){return t.openNewSessionDraft}function jj(t){return t.setCurrentSession}function kj(t){return t.currentSessionId}function Cj(t){return t.toggle}function Nj(t){return t.currentDirectory}function Aj(t){return t.getActiveProject()}function Pj(t){return t.projects}function Dj(t){return t.searchFiles}function Ij(t){return t.ensureStatus}function Tj(){Ru()}function Ej(){Qs.requestDirectoryDialog()}function Rj(){vg.invoke("cycle_theme")}function Mj(){Mu()}function Oj(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function Bj(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function Fj(t){return t.routingFeatureAvailable}function Lj(t){return t.slug!=="home"}function _j(t){return!pg(t)}function $j(t){return t.worktreeMetadata}function zj(t){return{path:Sa(t.path),name:t.name,relativePath:t.relativePath}}function Wj(t){return!t.secondary}function Kj(t){return{item:t,score:0}}function Vj(t){return t.searchText}function Uj(t){return t.searchText}function Hj(t){return{item:t,score:0}}function Gj(t){return t.title||""}function qj(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Yj(t){return t.searchText}function Qj(t){return t.item}function Xj(t){return t.item}function Jj(t){return t.item}function Zj(t){return t.item}function e0(t){return t.item}function t0(t){return t.length?t[0].score:1/0}function s0(t,e){return t.score-e.score}function n0(t){return t.key}function r0(t){return s.jsxs(Br,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const _c=(t,e,n)=>Hn(Jr(t,e),n),o0=()=>{const t=Ze.c(73),{t:e}=St(),n=Ae(i0),r=Ae(a0),i=Ae(l0);let o,l,a,d,u,h,f,p,x,b,k,y;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==e){const X=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[Hn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${Hn(Zi("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${Hn(Zi("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];a=bs,k=n,y=r,l=ys,x="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let Y;t[16]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(O,{name:"command",className:"h-5 w-5"}),t[16]=Y):Y=t[16];let I;t[17]!==e?(I=e("helpDialog.title"),t[17]=e,t[18]=I):I=t[18];let P;t[19]!==I?(P=s.jsxs(Bs,{className:"flex items-center gap-2",children:[Y,I]}),t[19]=I,t[20]=P):P=t[20];let A;t[21]!==e?(A=e("helpDialog.description"),t[21]=e,t[22]=A):A=t[22];let q;t[23]!==A?(q=s.jsx(Fs,{children:A}),t[23]=A,t[24]=q):q=t[24],t[25]!==P||t[26]!==q?(b=s.jsxs(Us,{children:[P,q]}),t[25]=P,t[26]=q,t[27]=b):b=t[27],o=gn,h="flex-1 min-h-0 mt-3",f="pr-1",p=!0,d="space-y-4",u=X.map(K=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(K.categoryKey)}),s.jsx("div",{className:"space-y-1",children:K.items.map(te=>{const ae=te.id?Sg(te.id):void 0,re=te.descriptionKey??(ae?.customizable?ae.settingsLabelKey:void 0);if(!re||te.id&&!Jr(te.id,i))return null;const he=te.id?_c(te.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(te.keys)?te.keys:te.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[te.icon&&s.jsx(O,{name:te.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(re)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(he)?he:[he]).map((ce,Te)=>s.jsxs(c.Fragment,{children:[Te>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:ce})]},`${ce}-${Te}`))})]},te.id||re)})})]},K.categoryKey)),t[0]=n,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=h,t[10]=f,t[11]=p,t[12]=x,t[13]=b,t[14]=k,t[15]=y}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],h=t[9],f=t[10],p=t[11],x=t[12],b=t[13],k=t[14],y=t[15];let m;t[28]!==d||t[29]!==u?(m=s.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=m):m=t[30];let g;t[31]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(O,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[31]=g):g=t[31];let j;t[32]!==e?(j=e("helpDialog.proTips.title"),t[32]=e,t[33]=j):j=t[33];let S;t[34]!==j?(S=s.jsx("p",{className:"font-medium mb-1",children:j}),t[34]=j,t[35]=S):S=t[35];let w;t[36]!==i||t[37]!==e?(w=e("helpDialog.proTips.commandPalette",{shortcut:_c("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[36]=i,t[37]=e,t[38]=w):w=t[38];let C;t[39]!==w?(C=s.jsxs("li",{children:["• ",w]}),t[39]=w,t[40]=C):C=t[40];let v;t[41]!==e?(v=e("helpDialog.proTips.recentSessions"),t[41]=e,t[42]=v):v=t[42];let R;t[43]!==v?(R=s.jsxs("li",{children:["• ",v]}),t[43]=v,t[44]=R):R=t[44];let T;t[45]!==e?(T=e("helpDialog.proTips.leaderSequences"),t[45]=e,t[46]=T):T=t[46];let D;t[47]!==T?(D=s.jsxs("li",{children:["• ",T]}),t[47]=T,t[48]=D):D=t[48];let F;t[49]!==C||t[50]!==R||t[51]!==D?(F=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[C,R,D]}),t[49]=C,t[50]=R,t[51]=D,t[52]=F):F=t[52];let B;t[53]!==S||t[54]!==F?(B=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[g,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[S,F]})]})}),t[53]=S,t[54]=F,t[55]=B):B=t[55];let E;t[56]!==o||t[57]!==h||t[58]!==B||t[59]!==f||t[60]!==p||t[61]!==m?(E=s.jsxs(o,{outerClassName:h,className:f,disableHorizontal:p,children:[m,B]}),t[56]=o,t[57]=h,t[58]=B,t[59]=f,t[60]=p,t[61]=m,t[62]=E):E=t[62];let $;t[63]!==l||t[64]!==E||t[65]!==x||t[66]!==b?($=s.jsxs(l,{className:x,children:[b,E]}),t[63]=l,t[64]=E,t[65]=x,t[66]=b,t[67]=$):$=t[67];let L;return t[68]!==a||t[69]!==$||t[70]!==k||t[71]!==y?(L=s.jsx(a,{open:k,onOpenChange:y,children:$}),t[68]=a,t[69]=$,t[70]=k,t[71]=y,t[72]=L):L=t[72],L};function i0(t){return t.isHelpDialogOpen}function a0(t){return t.setHelpDialogOpen}function l0(t){return t.shortcutOverrides}const c0=()=>{const t=Ze.c(32),{t:e}=St(),n=Ae(d0),r=Ae(u0),i=Ae(f0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await Jn(i)).ok){ze.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}ze.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Bs,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==u?(h=s.jsx(Fs,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Us,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let x;t[16]!==l||t[17]!==p?(x=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p})}),t[16]=l,t[17]=p,t[18]=x):x=t[18];let b;t[19]!==i||t[20]!==e?(b=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=b):b=t[21];let k;t[22]!==b?(k=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:b}),t[22]=b,t[23]=k):k=t[23];let y;t[24]!==f||t[25]!==x||t[26]!==k?(y=s.jsxs(ys,{className:"max-w-2xl",children:[f,x,k]}),t[24]=f,t[25]=x,t[26]=k,t[27]=y):y=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==y?(m=s.jsx(bs,{open:n,onOpenChange:r,children:y}),t[28]=n,t[29]=r,t[30]=y,t[31]=m):m=t[31],m};function d0(t){return t.isOpenCodeStatusDialogOpen}function u0(t){return t.setOpenCodeStatusDialogOpen}function f0(t){return t.openCodeStatusText}const m0=t=>{const e=Ze.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const b=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(b)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const b=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",b),()=>window.removeEventListener("openchamber:sidebar-session-search",b)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let p,x;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const b=k=>{l.current&&(l.current.contains(k.target)||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},x=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=x):(p=e[14],x=e[15]),c.useEffect(p,x)},h0=t=>{const e=Ze.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(p0)),u=[];a.forEach(p=>{const x=d.get(p);x&&(u.push(x),d.delete(p))});const h=[],f=[];return l.forEach(p=>{d.has(p.id)&&(p.isArchivedBucket?f.push(p):h.push(p))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function p0(t){return[t.id,t]}const go="oc.sessions.projectCollapse",$c="oc.sessions.groupOrder",zc="oc.sessions.groupCollapse",Wc=t=>{if(!t)return new Set;try{const e=Ja(Xn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},g0=t=>{if(!t)return new Map;try{const e=af(Xn(),Ja(Xn())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},x0=t=>{const e=Ze.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Mo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Wc(o.getItem(go)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Wc(o.getItem(zc)),e[2]=u):u=e[2];const[h,f]=c.useState(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>g0(o.getItem($c)),e[3]=p):p=e[3];const[x,b]=c.useState(p),k=c.useRef(0),y=c.useRef(!1),m=c.useRef(!1),g=c.useRef(null),j=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const pe=j.current;if(j.current=null,g.current=null,!pe)return;const{projects:Ne}=zt.getState(),U=Ne.map(Z=>({...Z,sidebarCollapsed:pe.has(Z.id)}));lr({projects:U}).catch(b0)},e[4]=n,e[5]=S):S=e[5];const w=S;let C;e[6]!==w||e[7]!==n?(C=pe=>{!globalThis.window||n||(j.current=pe,g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{w()},700))},e[6]=w,e[7]=n,e[8]=C):C=e[8];const v=C;let R,T;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=()=>()=>{globalThis.window&&g.current!==null&&window.clearTimeout(g.current),g.current=null,j.current=null},T=[],e[9]=R,e[10]=T):(R=e[9],T=e[10]),c.useEffect(R,T);let D,F;e[11]!==x?(F=()=>{if(m.current)try{o.setItem($c,JSON.stringify(Object.fromEntries(x.entries())))}catch{}},D=[x,o],e[11]=x,e[12]=D,e[13]=F):(D=e[12],F=e[13]),c.useEffect(F,D);let B,E;e[14]!==h?(B=()=>{if(y.current)try{o.setItem(zc,JSON.stringify(Array.from(h)))}catch{}},E=[h,o],e[14]=h,e[15]=B,e[16]=E):(B=e[15],E=e[16]),c.useEffect(B,E);let $;e[17]!==r||e[18]!==v?($=()=>{k.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const pe=new Set(r.map(y0));try{o.setItem(go,JSON.stringify(Array.from(pe)))}catch{}return v(pe),pe})},e[17]=r,e[18]=v,e[19]=$):$=e[19];const L=$;let X;e[20]!==v?(X=()=>{k.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const pe=new Set;try{o.setItem(go,JSON.stringify([]))}catch{}return v(pe),pe})},e[20]=v,e[21]=X):X=e[21];const Y=X;let I;e[22]!==v?(I=pe=>{k.current=Date.now()+150,d(Ne=>{const U=new Set(Ne);U.has(pe)?U.delete(pe):U.add(pe);try{o.setItem(go,JSON.stringify(Array.from(U)))}catch{}return v(U),U})},e[22]=v,e[23]=I):I=e[23];const P=I;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=pe=>{y.current=!0,f(Ne=>{const U=new Set(Ne);return U.has(pe)?U.delete(pe):U.add(pe),U})},e[24]=A):A=e[24];const q=A;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=pe=>{m.current=!0,b(pe)},e[25]=K):K=e[25];const te=K,{getOrderedGroups:ae}=h0(x);let re;e[26]!==h||e[27]!==a||e[28]!==x?(re={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:x},e[26]=h,e[27]=a,e[28]=x,e[29]=re):re=e[29];const he=re;let ce;e[30]!==L||e[31]!==Y||e[32]!==ae||e[33]!==v||e[34]!==P?(ce={setCollapsedProjects:d,toggleProject:P,collapseAllProjects:L,expandAllProjects:Y,scheduleCollapsedProjectsPersist:v,setCollapsedGroups:f,toggleGroup:q,setGroupOrderByProject:te,getOrderedGroups:ae},e[30]=L,e[31]=Y,e[32]=ae,e[33]=v,e[34]=P,e[35]=ce):ce=e[35];const Te=ce;let ve;return e[36]!==Te||e[37]!==he?(ve={state:he,actions:Te},e[36]=Te,e[37]=he,e[38]=ve):ve=e[38],ve};function b0(){}function y0(t){return t.id}const w0=5*6e4,v0=t=>{const e=Ze.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=nn(),u=pn(S0);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{ea(()=>u(C.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let p,x;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(v=>{C.set(v.id,i.get(v.normalizedPath)?.isGitRepo??null)}),o(C)},x=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=x):(p=e[11],x=e[12]),c.useEffect(p,x);let b;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=v=>{const R=i.get(v.normalizedPath)?.branch??"";return`${v.id}:${R}`},e[16]=i,e[17]=C):C=e[17],b=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=b}else b=e[15];const k=b;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const m=c.useRef(y);let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[19]=g):g=e[19];const j=c.useRef(g);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let C=!1;const v=setTimeout(()=>{(async()=>{const T=new Set(n.map(j0));for(const L of m.current.keys())T.has(L)||(m.current.delete(L),j.current.delete(L));const D=Date.now(),F=n.filter(L=>{const X=i.get(L.normalizedPath);if(X?.isGitRepo===!1)return m.current.delete(L.id),j.current.delete(L.id),!1;if(X?.isGitRepo!==!0||X.branch===null)return!1;const Y=X.branch.trim(),I=`${L.normalizedPath}\0${Y}`,P=m.current.get(L.id);if(P===I){const A=j.current.get(L.id);return A&&(A.at=D),!1}return!(P!==void 0&&D-(j.current.get(L.id)?.at??0)<w0)});if(F.length===0)return;const B=await jg(F,2,async L=>{const X=i.get(L.normalizedPath)?.branch?.trim()??"",Y=`${L.normalizedPath}\0${X}`,I=await ea(()=>$a(L.normalizedPath,X?{knownBranch:X}:void 0)).catch(k0);return{id:L.id,inputKey:Y,branch:I}});if(C)return;const E=B.filter(C0);if(E.length===0)return;const $=Date.now();l(L=>{const X=new Map(L);return E.forEach(Y=>{const{id:I,branch:P}=Y;P&&X.set(I,P)}),X}),E.forEach(L=>{const{id:X,inputKey:Y,branch:I}=L;m.current.set(X,Y),I&&j.current.set(X,{branch:I,at:$})})})()},150);return()=>{C=!0,clearTimeout(v)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let w;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==k||e[29]!==l?(w=[a,n,k,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=k,e[29]=l,e[30]=w):w=e[30],c.useEffect(S,w)};function S0(t){return t.ensureStatus}function j0(t){return t.id}function k0(){return null}function C0(t){return t.branch}const N0=t=>{const e=Ze.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Wh,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(ys,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(gn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(bs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function A0(t){const e=Ze.c(199),{t:n}=St(),r=Ou(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:h,onOpenArchive:f,headerActionIconClass:p,headerActionButtonClass:x,isSessionSearchOpen:b,setIsSessionSearchOpen:k,sessionSearchInputRef:y,sessionSearchQuery:m,setSessionSearchQuery:g,hasSessionSearchQuery:j,searchMatchCount:S,collapseAllProjects:w,expandAllProjects:C}=t,v=ss(z0),R=ss($0),T=as(_0),D=as(L0),F=as(F0),B=as(B0),E=as(O0),$=as(M0),L=as(R0),X=as(E0),Y=as(T0),I=as(I0),P=o&&Y==="single",A=o&&L==="timeline";if(i)return null;let q;e[0]!==x?(q=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=x,e[1]=q):q=e[1];let K;e[2]!==n?(K=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=K):K=e[3];let te;e[4]!==p?(te=s.jsx(O,{name:"folder-add",className:p}),e[4]=p,e[5]=te):te=e[5];let ae;e[6]!==a||e[7]!==q||e[8]!==K||e[9]!==te?(ae=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:q,"aria-label":K,children:te})}),e[6]=a,e[7]=q,e[8]=K,e[9]=te,e[10]=ae):ae=e[10];let re;e[11]!==n?(re=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=re):re=e[12];let he;e[13]!==re?(he=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:re})}),e[13]=re,e[14]=he):he=e[14];let ce;e[15]!==ae||e[16]!==he?(ce=s.jsxs(bt,{children:[ae,he]}),e[15]=ae,e[16]=he,e[17]=ce):ce=e[17];let Te;e[18]!==x?(Te=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=x,e[19]=Te):Te=e[19];let ve;e[20]!==n?(ve=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=ve):ve=e[21];let pe;e[22]!==p?(pe=s.jsx(O,{name:"calendar-schedule",className:p}),e[22]=p,e[23]=pe):pe=e[23];let Ne;e[24]!==d||e[25]!==Te||e[26]!==ve||e[27]!==pe?(Ne=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:Te,"aria-label":ve,children:pe})}),e[24]=d,e[25]=Te,e[26]=ve,e[27]=pe,e[28]=Ne):Ne=e[28];let U;e[29]!==n?(U=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=U):U=e[30];let Z;e[31]!==U?(Z=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:U})}),e[31]=U,e[32]=Z):Z=e[32];let de;e[33]!==Ne||e[34]!==Z?(de=s.jsxs(bt,{children:[Ne,Z]}),e[33]=Ne,e[34]=Z,e[35]=de):de=e[35];let ye;e[36]!==x?(ye=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=x,e[37]=ye):ye=e[37];let H;e[38]!==n?(H=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=H):H=e[39];const je=!h;let Ee;e[40]!==p?(Ee=s.jsx(Ng,{className:p}),e[40]=p,e[41]=Ee):Ee=e[41];let ge;e[42]!==u||e[43]!==ye||e[44]!==H||e[45]!==je||e[46]!==Ee?(ge=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:ye,"aria-label":H,disabled:je,children:Ee})}),e[42]=u,e[43]=ye,e[44]=H,e[45]=je,e[46]=Ee,e[47]=ge):ge=e[47];let ne;e[48]!==n?(ne=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=ne):ne=e[49];let be;e[50]!==ne?(be=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[50]=ne,e[51]=be):be=e[51];let G;e[52]!==ge||e[53]!==be?(G=s.jsxs(bt,{children:[ge,be]}),e[52]=ge,e[53]=be,e[54]=G):G=e[54];let z;e[55]!==x?(z=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=x,e[56]=z):z=e[56];let J;e[57]!==n?(J=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=J):J=e[58];let ue;e[59]!==p?(ue=s.jsx(O,{name:"archive",className:p}),e[59]=p,e[60]=ue):ue=e[60];let le;e[61]!==f||e[62]!==z||e[63]!==J||e[64]!==ue?(le=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:z,"aria-label":J,children:ue})}),e[61]=f,e[62]=z,e[63]=J,e[64]=ue,e[65]=le):le=e[65];let W;e[66]!==n?(W=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=W):W=e[67];let M;e[68]!==W?(M=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W})}),e[68]=W,e[69]=M):M=e[69];let _;e[70]!==le||e[71]!==M?(_=s.jsxs(bt,{children:[le,M]}),e[70]=le,e[71]=M,e[72]=_):_=e[72];let ee;e[73]!==r||e[74]!==p||e[75]!==n?(ee=r.length>0&&s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(O,{name:"apps",className:p})})}),s.jsxs(Ds,{align:"start",children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(D0)]})]}),e[73]=r,e[74]=p,e[75]=n,e[76]=ee):ee=e[76];let oe;e[77]!==de||e[78]!==G||e[79]!==_||e[80]!==ee||e[81]!==ce?(oe=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ce,de,G,_,ee]}),e[77]=de,e[78]=G,e[79]=_,e[80]=ee,e[81]=ce,e[82]=oe):oe=e[82];let fe;e[83]!==k?(fe=()=>k(P0),e[83]=k,e[84]=fe):fe=e[84];let ie;e[85]!==x?(ie=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=x,e[86]=ie):ie=e[86];let Le;e[87]!==n?(Le=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=Le):Le=e[88];let $e;e[89]!==p?($e=s.jsx(O,{name:"search",className:p}),e[89]=p,e[90]=$e):$e=e[90];let Pe;e[91]!==b||e[92]!==fe||e[93]!==ie||e[94]!==Le||e[95]!==$e?(Pe=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:fe,className:ie,"aria-label":Le,"aria-expanded":b,children:$e})}),e[91]=b,e[92]=fe,e[93]=ie,e[94]=Le,e[95]=$e,e[96]=Pe):Pe=e[96];let Oe;e[97]!==n?(Oe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=Oe):Oe=e[98];let Q;e[99]!==Oe?(Q=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[99]=Oe,e[100]=Q):Q=e[100];let Ce;e[101]!==Pe||e[102]!==Q?(Ce=s.jsxs(bt,{children:[Pe,Q]}),e[101]=Pe,e[102]=Q,e[103]=Ce):Ce=e[103];const Se=v&&"bg-interactive-hover text-primary";let Ke;e[104]!==x||e[105]!==Se?(Ke=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent",Se),e[104]=x,e[105]=Se,e[106]=Ke):Ke=e[106];let et;e[107]!==v||e[108]!==n?(et=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=v,e[108]=n,e[109]=et):et=e[109];let it;e[110]!==p?(it=s.jsx(O,{name:"checkbox-multiple",className:p}),e[110]=p,e[111]=it):it=e[111];let rt;e[112]!==v||e[113]!==Ke||e[114]!==et||e[115]!==it||e[116]!==R?(rt=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:R,className:Ke,"aria-label":et,"aria-pressed":v,children:it})}),e[112]=v,e[113]=Ke,e[114]=et,e[115]=it,e[116]=R,e[117]=rt):rt=e[117];let pt;e[118]!==v||e[119]!==n?(pt=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=v,e[119]=n,e[120]=pt):pt=e[120];let ht;e[121]!==pt?(ht=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:pt})}),e[121]=pt,e[122]=ht):ht=e[122];let tt;e[123]!==rt||e[124]!==ht?(tt=s.jsxs(bt,{children:[rt,ht]}),e[123]=rt,e[124]=ht,e[125]=tt):tt=e[125];let At;e[126]!==x?(At=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=x,e[127]=At):At=e[127];let jt;e[128]!==n?(jt=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=jt):jt=e[129];let we;e[130]!==p?(we=s.jsx(O,{name:"equalizer-2",className:p}),e[130]=p,e[131]=we):we=e[131];let Xe;e[132]!==At||e[133]!==jt||e[134]!==we?(Xe=s.jsx(yt,{asChild:!0,children:s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:At,"aria-label":jt,children:we})})}),e[132]=At,e[133]=jt,e[134]=we,e[135]=Xe):Xe=e[135];let mt;e[136]!==n?(mt=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=mt):mt=e[137];let qe;e[138]!==mt?(qe=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:mt})}),e[138]=mt,e[139]=qe):qe=e[139];let ft;e[140]!==Xe||e[141]!==qe?(ft=s.jsxs(bt,{children:[Xe,qe]}),e[140]=Xe,e[141]=qe,e[142]=ft):ft=e[142];let se;e[143]!==X||e[144]!==o||e[145]!==L||e[146]!==n||e[147]!==A?(se=o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{X(ot),lr({sidebarViewMode:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),L===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),A?null:s.jsx(gs,{})]}):null,e[143]=X,e[144]=o,e[145]=L,e[146]=n,e[147]=A,e[148]=se):se=e[148];let me;e[149]!==Y||e[150]!==F||e[151]!==I||e[152]!==B||e[153]!==$||e[154]!==o||e[155]!==n||e[156]!==A||e[157]!==E?(me=A?null:s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{B(ot),lr({sidebarProjectSortOrder:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),F===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{$(ot),lr({sidebarWorktreeSortOrder:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),E===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{})]}):null,o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{I(ot),lr({sidebarProjectDisplayMode:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),Y===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{})]}):null]}),e[149]=Y,e[150]=F,e[151]=I,e[152]=B,e[153]=$,e[154]=o,e[155]=n,e[156]=A,e[157]=E,e[158]=me):me=e[158];let Ie;e[159]!==P||e[160]!==l||e[161]!==T||e[162]!==n||e[163]!==A||e[164]!==D?(Ie=!A&&l&&!P?s.jsxs(_t,{onClick:()=>{D(),lr({sidebarShowRecentSection:!T})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),T?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[159]=P,e[160]=l,e[161]=T,e[162]=n,e[163]=A,e[164]=D,e[165]=Ie):Ie=e[165];let We;e[166]!==w||e[167]!==C||e[168]!==P||e[169]!==n||e[170]!==A?(We=!A&&!P?s.jsxs(s.Fragment,{children:[s.jsx(gs,{}),s.jsxs(_t,{onClick:w,className:"flex items-center gap-2",children:[s.jsx(O,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(_t,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(O,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[166]=w,e[167]=C,e[168]=P,e[169]=n,e[170]=A,e[171]=We):We=e[171];let V;e[172]!==se||e[173]!==me||e[174]!==Ie||e[175]!==We?(V=s.jsxs(Ds,{align:"end",className:"min-w-[180px]",children:[se,me,Ie,We]}),e[172]=se,e[173]=me,e[174]=Ie,e[175]=We,e[176]=V):V=e[176];let Fe;e[177]!==ft||e[178]!==V?(Fe=s.jsxs(Is,{children:[ft,V]}),e[177]=ft,e[178]=V,e[179]=Fe):Fe=e[179];let Ye;e[180]!==Ce||e[181]!==tt||e[182]!==Fe?(Ye=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ce,tt,Fe]}),e[180]=Ce,e[181]=tt,e[182]=Fe,e[183]=Ye):Ye=e[183];let Qe;e[184]!==oe||e[185]!==Ye?(Qe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[oe,Ye]}),e[184]=oe,e[185]=Ye,e[186]=Qe):Qe=e[186];let xe;e[187]!==j||e[188]!==b||e[189]!==S||e[190]!==y||e[191]!==m||e[192]!==k||e[193]!==g||e[194]!==n?(xe=b?s.jsx("div",{className:"pb-1",children:s.jsx(Zd,{inputRef:y,value:m,onSearch:g,onClose:()=>k(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:j?S===1?n("sessions.sidebar.header.search.matchCountSingle",{count:S}):n("sessions.sidebar.header.search.matchCountPlural",{count:S}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[187]=j,e[188]=b,e[189]=S,e[190]=y,e[191]=m,e[192]=k,e[193]=g,e[194]=n,e[195]=xe):xe=e[195];let st;return e[196]!==Qe||e[197]!==xe?(st=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Qe,xe]})}),e[196]=Qe,e[197]=xe,e[198]=st):st=e[198],st}function P0(t){return!t}function D0(t){return s.jsxs(_t,{onSelect:()=>Ae.getState().setOpenGuestPage(t.id),children:[s.jsx(Xr,{icon:Cg(t.icon),iconSrc:kg(t.id,t.icon,zd().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function I0(t){return t.setProjectDisplayMode}function T0(t){return t.projectDisplayMode}function E0(t){return t.setSidebarViewMode}function R0(t){return t.sidebarViewMode}function M0(t){return t.setWorktreeSortOrder}function O0(t){return t.worktreeSortOrder}function B0(t){return t.setProjectSortOrder}function F0(t){return t.projectSortOrder}function L0(t){return t.toggleRecentSection}function _0(t){return t.showRecentSection}function $0(t){return t.toggleMode}function z0(t){return t.enabled}const xo="inline-flex h-8 w-8 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-ring";function W0(t){const e=Ze.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,h=d===void 0?!0:d,{t:f}=St();if(!u&&!h)return null;let p;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(p=u?s.jsxs(s.Fragment,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:xo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(O,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:xo,"aria-label":f("usageStats.openAction"),children:s.jsx(O,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:xo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(O,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:xo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(O,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=p):p=e[6];let x;e[7]!==l||e[8]!==h||e[9]!==f?(x=h?s.jsx(ut,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=h,e[9]=f,e[10]=x):x=e[10];let b;return e[11]!==p||e[12]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[p,x]}),e[11]=p,e[12]=x,e[13]=b):b=e[13],b}const K0=t=>{for(const e of t.sessions.values())if(e.tabs.some(Kd))return!0;return!1},V0=()=>{const t=Ze.c(4),{terminal:e}=nn(),n=Rt(K0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=U0,l=H0;if(n)return Vi(e,"",l,o);let a=G0;return a=Vi(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function U0(t){const e=Rt.getState(),n=Kh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function H0(){return new Map(Rt.getState().actionMutationRevisions)}function G0(){}const q0=t=>{const e=Ze.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,p=r===void 0?!0:r;let x,b;e[0]!==f||e[1]!==h||e[2]!==p||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(x=()=>{!p||o||!l||a||n.forEach(k=>{if(d.has(k.normalizedPath))return;const y=Bu(k.normalizedPath),m=i.archivedSessionsByProject.get(k.id)??[],g=u[y]??[],j=new Map(g.map(Y0));m.forEach(S=>{const w=Ag(S,k.normalizedPath),C=w.toLowerCase();let v=j.get(C);v||(v=h(y,w),j.set(C,v)),v.sessionIds.includes(S.id)||f(y,v.id,S.id)})})},b=[n,p,i,o,l,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=p,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=x,e[11]=b):(x=e[10],b=e[11]),c.useEffect(x,b)};function Y0(t){return[t.name.toLowerCase(),t]}function Q0({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const X0=t=>{const e=Ze.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let x,b;if(e[0]!==n){b=new Map,x=new Map;const C=(v,R,T,D)=>{b.has(v)||b.set(v,new Map);const F=b.get(v);D.forEach(B=>{const E=xt(B.worktree?.path??B.session.directory??T??R);F.set(B.session.id,{directory:E}),x.has(v)||x.set(v,{id:B.session.id,directory:E}),B.children.length>0&&C(v,R,E,B.children)})};n.forEach(v=>{v.groups.forEach(R=>{C(v.project.id,v.project.normalizedPath,R.directory,R.sessions)})}),e[0]=n,e[1]=x,e[2]=b}else x=e[1],b=e[2];let k;e[3]!==x||e[4]!==b?(k={metaByProject:b,firstSessionByProject:x},e[3]=x,e[4]=b,e[5]=k):k=e[5];const y=k,m=c.useRef(null);let g,j;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==y||e[16]!==o||e[17]!==p?(g=()=>{if(!r||u||Ae.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(D=>D.project.id===r);if(!C)return;const v=y.metaByProject.get(r);if(l&&v&&v.has(l)){m.current=r,o(D=>{if(D.get(r)===l)return D;const F=new Map(D);return F.set(r,l),F});return}const R=Q0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:v,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(R.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,R.kind==="open-draft"){h&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(R.kind!=="select-session")return;const T=v?.get(R.sessionId)?.directory??null;d(R.sessionId,T)},j=[r,i,l,a,d,u,h,f,n,y,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=y,e[16]=o,e[17]=p,e[18]=g,e[19]=j):(g=e[18],j=e[19]),c.useLayoutEffect(g,j);let S,w;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(S=()=>{if(!r||!l)return;const C=y.metaByProject.get(r);!C||!C.has(l)||o(v=>{if(v.get(r)===l)return v;const R=new Map(v);return R.set(r,l),R})},w=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=S,e[25]=w):(S=e[24],w=e[25]),c.useEffect(S,w)},J0=t=>{const e=Ze.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=nt(Z0),a=nt(e2);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,p]=c.useState(h);let x;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(x={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=x):x=e[15],X0(x);let b,k;return e[16]!==f||e[17]!==i?(b=()=>{i(f)},k=[f,i],e[16]=f,e[17]=i,e[18]=b,e[19]=k):(b=e[18],k=e[19]),c.useEffect(b,k),null};function Z0(t){return t.currentSessionId}function e2(t){return!!t.newSessionDraft?.open}const t2=t=>{const e=Ze.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},_n=(t,e)=>`${t}\0${e}`,Kn=(t,e)=>t??Ha(e)??xt(e??null),qr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??xt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},al=t=>t.startsWith("__archived__:"),s2=(t,e)=>t.map(n=>{const r=xt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
878
+ `)},Ov=t=>{const e=Ze.c(7),{t:n}=St(),r=nt(Fv),i=nt(Lv),o=Yi(_v),l=eg($v);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){ze.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await l(d.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Mv({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),ze.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Bv=()=>{const t=Ze.c(16),{t:e}=St();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Fv(t){return t.currentSessionId}function Lv(t){return t.newSessionDraft?.open}function _v(t){return t.addDraft}function $v(t){return t.addAttachedFile}const zv=3e4,Wv=3,Kv=250,Vv={attempts:0,windowStartedAt:null},Uv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=zv,r=n?0:t.attempts;return r>=Wv?null:{delayMs:Kv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Hv=-3,ho=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",mr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Gv=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Dw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,h]=c.useState(!1),[f,p]=c.useState(!1),x=c.useRef(n);x.current=n;const b=c.useRef(Vv);return c.useEffect(()=>{if(!t)return;const k=()=>{try{const D=t.getURL();return ho(D)?D:""}catch{return""}},y=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},m=D=>{ho(D)&&(l(D),x.current(D))},g=()=>{const D=k();i({kind:"loading",url:D})},j=()=>{const D=k();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),m(D),y(),i(B=>B.kind==="failed"&&B.url===D?B:{kind:"ready",url:D,title:F})},S=D=>{const F=mr(D);ho(F.url)&&(m(F.url),y())},w=D=>{const F=mr(D),B=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",E=k();B&&E&&Cf.getState().resolve(E,B)},C=D=>{const F=mr(D);typeof F.title=="string"&&d(F.title)},v=D=>{const F=mr(D);if(F.isMainFrame===!1)return;const B=typeof F.errorCode=="number"?F.errorCode:0;B!==Hv&&i({kind:"failed",url:ho(F.validatedURL)?F.validatedURL:k(),code:B,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let R=null;const T=()=>{const D=k(),F=Uv(b.current,Date.now());if(!F){i({kind:"failed",url:D,code:0,description:"",crashed:!0});return}b.current=F.state,i({kind:"loading",url:D}),R=setTimeout(()=>{R=null;try{t.reload()}catch{i({kind:"failed",url:D,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",g),t.addEventListener("did-stop-loading",j),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",w),t.addEventListener("did-fail-load",v),t.addEventListener("render-process-gone",T),t.addEventListener("crashed",T);try{!t.isLoading()&&k()&&j()}catch{}return()=>{R!==null&&clearTimeout(R),t.removeEventListener("render-process-gone",T),t.removeEventListener("crashed",T),t.removeEventListener("did-start-loading",g),t.removeEventListener("did-stop-loading",j),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",w),t.removeEventListener("did-fail-load",v)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},qv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Yv=4e4,po=.5,Qv=-3,Xv=4,Jv="persist:openchamber-browser",Mc=20,Zv=600,eS=2e4,tS=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=St(),{currentTheme:i}=Cn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(W=>{o.current=W,a(W)},[]),u=Ae(W=>W.setContextPanelTabTargetPath),h=c.useRef(xr(t)),f=h.current!==Ks?h.current:"",[p,x]=c.useState(f?null:Ks),[b,k]=c.useState(f),[y,m]=c.useState(!1),[g,j]=c.useState(!1),[S,w]=c.useState(0),C=c.useRef(0),[v,R]=c.useState(!1),[T,D]=c.useState(Wo),F=c.useRef(T);F.current=T;const B=c.useRef([]),[E,$]=c.useState("system"),[L,X]=c.useState({width:0,height:0}),Y=c.useRef(null),I=c.useRef(null),P=c.useRef(!1),A=c.useRef(Date.now()),q=c.useCallback(W=>{!W||W===Ks||!e||!n||u(e,n,W)},[e,n,u]),K=Gv(l,{initialUrl:f,onUrlChange:c.useCallback(W=>{const M=ar(W);k(M),q(M)},[q])}),[te,ae]=c.useState(null),re=Ov(e),he=Bv(),ce=K.status.kind==="loading",Te=br(Mf(e)),ve=br(W=>W.recordVisit),pe=br(W=>W.forget);c.useEffect(()=>{K.status.kind==="ready"&&ve(e,{url:ar(K.status.url),title:K.status.title})},[e,K.status,ve]);const Ne=c.useMemo(()=>Rf(Te,b),[Te,b]),U=c.useCallback(W=>{const M=xr(W);M!==Ks&&(k(M),ae(null),Pc(M).then(_=>{const ee=o.current;if(!ee){x(_);return}try{ee.loadURL(_)}catch{x(_)}}).catch(_=>{_ instanceof Wr&&ae(M)}))},[]);c.useEffect(()=>{if(!f)return;let W=!0;return Pc(f).then(M=>{W&&x(M)}).catch(M=>{if(W){if(M instanceof Wr){ae(f),x(Ks);return}x(f)}}),()=>{W=!1}},[]);const Z=c.useMemo(()=>({executeJavaScript:async(W,M)=>{const _=o.current;if(!_)throw new Error("Browser view is not available");return _.executeJavaScript(W,M)},capturePage:async()=>{const W=o.current;if(!W)return null;const M=W.getWebContentsId();return Number.isFinite(M)?await pr("desktop_browser_capture_page",{webContentsId:M}):null}}),[]),de=c.useCallback(()=>{if(y){m(!1),Po(Z);return}if(!K.url){ze.error(r("contextPanel.browser.annotate.noPage"));return}const W=Kw(i.metadata.variant==="light"?"light":"dark");m(!0),zw({host:Z,theme:W,labels:he}).then(async M=>{m(!1),M&&await re(M)}).catch(()=>{m(!1),ze.error(r("contextPanel.browser.annotate.failed"))})},[Z,re,i,y,K.url,he,r]);c.useEffect(()=>{if(!y)return;const W=M=>{tg(M)||M.key!=="Escape"||(M.preventDefault(),M.stopImmediatePropagation(),m(!1),Po(Z))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[Z,y]);const ye=c.useCallback(async(W=8e3)=>{const M=Date.now();for(;;){const _=o.current;if(!_)return!1;let ee=!1;try{ee=_.isLoading()}catch{return!1}if(!ee)return!0;if(Date.now()-M>W)return!1;await new Promise(oe=>setTimeout(oe,120))}},[]),H=c.useCallback(async(W,M)=>{const _=o.current;if(!_)throw new Error("The browser panel is not ready");const ee=()=>{Rc(M.viewport)&&(D(wa(M.viewport)),R(!0))};if(W==="browser.back"||W==="browser.forward"){const Pe=W==="browser.back";if(!(Pe?_.canGoBack():_.canGoForward()))throw new Error(Pe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Pe?_.goBack():_.goForward(),await new Promise(Ce=>setTimeout(Ce,150)),await ye();let Q="";try{Q=_.getTitle()||""}catch{Q=""}return{url:ar(_.getURL()),title:Q}}if(W==="browser.capture"){const Pe=Ae.getState(),Oe=$n(e),Q=Pe.contextPanelByDirectory[Oe],Ce=!!(Q?.isOpen&&Q.activeTabId===n);Ce||Pe.setActiveContextPanelTab(e,n);const Se=()=>{if(Ce||!Q)return;const Ke=Ae.getState(),et=Ke.contextPanelByDirectory[Oe];!et?.isOpen||et.activeTabId!==n||(Q.activeTabId&&Q.activeTabId!==n&&Ke.setActiveContextPanelTab(e,Q.activeTabId),Q.isOpen||Ke.closeContextPanel(e))};try{const Ke=Date.now()+1200;let et=0,it=0;for(;it<2&&Date.now()<Ke;){const ht=_.getBoundingClientRect().width;it=ht>=2&&Math.abs(ht-et)<.5?it+1:0,et=ht,await new Promise(tt=>setTimeout(tt,50))}await new Promise(ht=>{requestAnimationFrame(()=>requestAnimationFrame(()=>ht()))}),await ye();const rt=await Z.capturePage();if(!rt)throw new Error("The page could not be captured");let pt="";try{pt=_.getTitle()||""}catch{pt=""}return{...rt,url:ar(_.getURL()),title:pt,viewport:mo(F.current)}}finally{Se()}}if(W==="browser.resize"){if(!Rc(M.viewport))throw new Error("viewport is required");return ee(),await new Promise(Pe=>setTimeout(Pe,200)),await ye(),{viewport:mo(wa(M.viewport))}}if(W==="browser.open"){const Pe=typeof M.url=="string"?M.url:"";if(!Pe)throw new Error("url is required");ee(),U(Pe),await new Promise(Ce=>setTimeout(Ce,150));const Oe=await ye(25e3);let Q="";try{Q=_.getTitle()||""}catch{Q=""}return{url:xr(Pe),title:Q,opened:!0,settled:Oe,viewport:mo(F.current)}}await ye();const oe=Pe=>typeof Pe=="string"&&Pe?Pe:void 0,ie=(()=>{switch(W){case"browser.snapshot":return hv({selector:oe(M.selector)});case"browser.click":return pv({selector:oe(M.selector),text:oe(M.text)});case"browser.type":return gv({selector:String(M.selector??""),value:String(M.value??""),submit:M.submit===!0});case"browser.inspect":return yv({selector:String(M.selector??"")});case"browser.scroll":return xv({selector:oe(M.selector),direction:oe(M.direction)});default:return null}})();if(!ie)throw new Error(`Unsupported browser action: ${W}`);const Le=await _.executeJavaScript(ie,!0);if(!Le||typeof Le!="object")throw new Error("The page returned no result");const $e=Le;if($e.ok!==!0)throw new Error(typeof $e.error=="string"&&$e.error?$e.error:"Browser action failed");if(W==="browser.snapshot"){const Pe=B.current;return{...$e,viewport:mo(F.current),...Pe.length>0?{consoleProblems:[...Pe]}:{}}}return(W==="browser.click"||W==="browser.type"&&M.submit===!0)&&(await new Promise(Pe=>setTimeout(Pe,150)),await ye()),Le},[Z,e,U,n,ye]),je=c.useCallback(()=>{const W=o.current;if(!W)return{title:"",url:""};let M="",_="";try{M=W.getTitle()||""}catch{M=""}try{_=ar(W.getURL())}catch{_=""}return{title:M,url:_}},[]);c.useEffect(()=>Xw({tabId:n,describe:je,run:H}),[je,H,n]),c.useEffect(()=>{const W=Z;return()=>{Po(W)}},[Z]),c.useEffect(()=>{if(!l)return;const W=_=>{const ee=_;if(typeof ee.level!="number"||ee.level<2)return;const oe=ee.sourceId?`${ee.sourceId}${ee.line?`:${ee.line}`:""}`:"";B.current.push({level:ee.level>=3?"error":"warning",message:String(ee.message??"").slice(0,400),source:oe}),B.current.length>Mc&&B.current.splice(0,B.current.length-Mc)},M=()=>{B.current=[]};return l.addEventListener("console-message",W),l.addEventListener("did-start-loading",M),()=>{l.removeEventListener("console-message",W),l.removeEventListener("did-start-loading",M)}},[l]);const Ee=c.useRef(new Set),ge=c.useCallback(W=>{Ee.current.clear(),U(W)},[U]);c.useEffect(()=>{if(!l)return;const W=_=>{const ee=mr(_),oe=typeof ee.url=="string"?ee.url:"";!oe||!Dc(oe)||(_.preventDefault(),U(oe))},M=_=>{const ee=mr(_);if(ee.isMainFrame===!1||ee.errorCode===-3)return;const oe=typeof ee.validatedURL=="string"?ee.validatedURL:"";!oe||!Dc(oe)||Ee.current.has(oe)||(Ee.current.add(oe),U(oe))};return l.addEventListener("will-navigate",W),l.addEventListener("did-fail-load",M),()=>{l.removeEventListener("will-navigate",W),l.removeEventListener("did-fail-load",M)}},[U,l]),c.useEffect(()=>{if(!l)return;const W=M=>{const _=M.detail;M.preventDefault(),_?.url&&U(_.url)};return l.addEventListener("new-window",W),()=>l.removeEventListener("new-window",W)},[U,l]);const ne=c.useCallback(W=>{const M=Math.min(Xv,Math.max(Qv,W));C.current=M,w(M);try{o.current?.setZoomLevel(M)}catch{}},[]);c.useEffect(()=>{const W=M=>{if(!(M instanceof CustomEvent))return;const _=M.detail,ee=o.current;!ee||document.activeElement!==ee||(_==="zoom-in"?ne(C.current+po):_==="zoom-out"?ne(C.current-po):_==="zoom-reset"&&ne(0))};return window.addEventListener("openchamber:zoom",W),()=>window.removeEventListener("openchamber:zoom",W)},[ne]);const be=c.useCallback(W=>{pr("desktop_browser_clear_data",{partition:Jv,cookies:W==="cookies",cache:W==="cache"}).then(()=>{ze.success(r(W==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>ze.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const W=Y.current;if(!W||typeof ResizeObserver>"u")return;const M=new ResizeObserver(_=>{const ee=_[0]?.contentRect;ee&&X({width:ee.width,height:ee.height})});return M.observe(W),()=>M.disconnect()},[]);const G=c.useCallback(W=>{$(W);const M=o.current;if(!M)return;let _=-1;try{_=M.getWebContentsId()}catch{return}pr("desktop_browser_set_color_scheme",{webContentsId:_,scheme:W}).catch(ee=>{$("system"),ze.error(ee instanceof Error?ee.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),z=c.useCallback(()=>{try{ce?o.current?.stop():o.current?.reload()}catch{}},[ce]),J=K.status;c.useEffect(()=>{const W=()=>{j(!0);const ee=setTimeout(()=>{try{o.current?.reload()}catch{}},Zv);return()=>clearTimeout(ee)};if(J.kind==="failed"){if(!vw(J.code,J.url)){j(!1);return}const ee=Date.now(),oe=I.current?.url===J.url?I.current:{url:J.url,startedAt:ee};if(I.current=oe,ee-oe.startedAt>Yv){j(!1);return}return W()}if(J.kind==="loading")return;if(I.current=null,J.kind!=="ready"||!J.url||!Sr(J.url)){P.current=!0,j(!1);return}if(P.current||Date.now()-A.current>eS){P.current=!0,j(!1);return}let M=!1,_=null;return kw(ar(J.url)).then(ee=>{if(!M){if(ee===null||ee<500){P.current=!0,j(!1);return}_=W()}}),()=>{M=!0,_?.()}},[J]);const ue=K.status.kind==="failed"&&!g?K.status:null,le=jv(T,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Lf,{address:b,onAddressChange:k,onSubmit:ge,suggestions:Ne,onForgetSuggestion:W=>pe(e,W),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:z,onOpenExternal:()=>{Qr(K.url||b)},canGoBack:K.canGoBack,canGoForward:K.canGoForward,isLoading:ce,onAnnotate:de,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ne(S+po),onZoomOut:()=>ne(S-po),onZoomReset:()=>ne(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>be("cookies"),onClearCache:()=>be("cache"),onToggleDeviceBar:()=>R(W=>!W),isDeviceBarOpen:v}),v?s.jsx(Nv,{viewport:T,onViewportChange:D,colorScheme:E,onColorSchemeChange:G,scale:le?.scale??1}):null,s.jsxs("div",{ref:Y,className:Me("relative min-h-0 flex-1 bg-background",le&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:d,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:le?{width:`${le.width}px`,height:`${le.height}px`,transform:`scale(${le.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!K.url&&!ce?s.jsx(zf,{onOpen:ge,directory:e}):null,g?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:te})})]}):null,ue&&!te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ue.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ue.crashed?r("contextPanel.browser.crashedHint"):ue.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ce?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},sS=t=>{const e=Ze.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=St(),l=Ae(rS);let a;e[0]!==n?(a=xr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==Ks?d:"",[h,f]=c.useState(u),[p,x]=c.useState(u);let b;e[2]!==u?(b=u?[u]:[],e[2]=u,e[3]=b):b=e[3];const[k,y]=c.useState(b),[m,g]=c.useState(u?0:-1),[j,S]=c.useReducer(oS,0);let w;e[4]!==r||e[5]!==l||e[6]!==i?(w=he=>{!he||he===Ks||!r||!i||l(r,i,he)},e[4]=r,e[5]=l,e[6]=i,e[7]=w):w=e[7];const C=w;let v;e[8]!==r?(v=Mf(r),e[8]=r,e[9]=v):v=e[9];const R=br(v),T=br(iS),D=br(aS);let F;e[10]!==h||e[11]!==R?(F=Rf(R,h),e[10]=h,e[11]=R,e[12]=F):F=e[12];const B=F;let E;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==T?(E=he=>{const ce=xr(he);ce!==Ks&&(f(ce),x(ce),C(ce),T(r,{url:ce}),y(Te=>{const ve=m>=0?Te.slice(0,m+1):[];return ve[ve.length-1]===ce?(g(ve.length-1),ve):(g(ve.length),[...ve,ce])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=T,e[17]=E):E=e[17];const $=E;let L;e[18]!==k||e[19]!==C?(L=he=>{const ce=k[he];ce&&(g(he),f(ce),x(ce),C(ce))},e[18]=k,e[19]=C,e[20]=L):L=e[20];const X=L;let Y;e[21]!==r||e[22]!==D?(Y=he=>D(r,he),e[21]=r,e[22]=D,e[23]=Y):Y=e[23];let I,P;e[24]!==X||e[25]!==m?(P=()=>X(m-1),I=()=>X(m+1),e[24]=X,e[25]=m,e[26]=I,e[27]=P):(I=e[26],P=e[27]);let A;e[28]!==h||e[29]!==p?(A=()=>{Qr(p||h)},e[28]=h,e[29]=p,e[30]=A):A=e[30];const q=m>0,K=m>=0&&m<k.length-1;let te;e[31]!==h||e[32]!==$||e[33]!==B||e[34]!==I||e[35]!==A||e[36]!==q||e[37]!==K||e[38]!==Y||e[39]!==P?(te=s.jsx(Lf,{address:h,onAddressChange:f,onSubmit:$,suggestions:B,onForgetSuggestion:Y,onBack:P,onForward:I,onReload:S,onOpenExternal:A,canGoBack:q,canGoForward:K,isLoading:!1}),e[31]=h,e[32]=$,e[33]=B,e[34]=I,e[35]=A,e[36]=q,e[37]=K,e[38]=Y,e[39]=P,e[40]=te):te=e[40];let ae;e[41]!==p||e[42]!==$||e[43]!==j||e[44]!==o?(ae=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${j}`):s.jsx(zf,{onOpen:$})}),e[41]=p,e[42]=$,e[43]=j,e[44]=o,e[45]=ae):ae=e[45];let re;return e[46]!==te||e[47]!==ae?(re=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[te,ae]}),e[46]=te,e[47]=ae,e[48]=re):re=e[48],re},nS=t=>{const e=Ze.c(3),[n]=c.useState(qv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(tS,{...t}):s.jsx(sS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function rS(t){return t.setContextPanelTabTargetPath}function oS(t){return t+1}function iS(t){return t.recordVisit}function aS(t){return t.forget}const lS=Dn(()=>sn(()=>import("./WalkthroughView-Cf8EdtIU.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,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),cS=Dn(()=>sn(()=>import("./DiffView-IFl6EaUT.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,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,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,113,114,115,116,129,117,118,119,120,121,130,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),dS=Dn(()=>sn(()=>import("./FilesView-2QJJIAmr.js"),__vite__mapDeps([131,1,2,4,5,6,7,8,9,3,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,84,85,86,132,133,134,135,136,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,113,114,137,138,120,121,118,139,125,119,140])).then(t=>({default:t.FilesView}))),uS=Dn(()=>sn(()=>import("./GitView-xpLPdSXl.js"),__vite__mapDeps([141,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,84,85,86,142,130,117,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,113,114,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),fS=Dn(()=>sn(()=>import("./LinearIssuesView-CYI08VW3.js"),__vite__mapDeps([143,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])).then(t=>({default:t.LinearIssuesView}))),mS=Dn(()=>sn(()=>import("./PlanView-Bvt1PdkO.js"),__vite__mapDeps([144,1,2,4,5,6,7,8,9,132,57,58,59,60,61,62,79,55,56,63,133,134,135,3,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,119,140,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Wf=c.lazy(()=>sn(()=>import("./PluginPane-CaJz1LlW.js").then(t=>t.p),__vite__mapDeps([86,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])).then(t=>({default:t.PluginPane}))),Kf={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},hS=t=>{const e=Ze.c(12),{mode:n,docking:r}=t,[i,o]=c.useState(null),l=Kf[r.dock],a=Math.max(lg,i??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=Me("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let h;e[3]!==l.vertical||e[4]!==a?(h=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=h):h=e[5];let f;e[6]!==n?(f=s.jsx(Wf,{mode:n,onResize:o}),e[6]=n,e[7]=f):f=e[7];let p;return e[8]!==u||e[9]!==h||e[10]!==f?(p=s.jsx("div",{className:u,style:h,children:f}),e[8]=u,e[9]=h,e[10]=f,e[11]=p):p=e[11],p},Oc=c.lazy(()=>sn(()=>import("./GuestSurfacePane-CA1Pu0hE.js"),__vite__mapDeps([145,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,86])).then(t=>({default:t.GuestSurfacePane}))),Vf=320,il=600,pS=400,gS=100,xS=24,Vo=new Map,bS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Bc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Vf,Math.round(t))):il,Fc=t=>{const e=t??(typeof window<"u"?window.innerWidth:il*2);return Math.max(Vf,e-pS)},yS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},wS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Uf=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Un(t)?Fa.getState().guests.find(r=>r.id===Ro(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),vS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},SS=(t,e,n)=>{if(t.mode==="chat"){const r=va(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?rl(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?vS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Uf(t.mode,n)},jS=t=>{const e=Ze.c(8),{mode:n}=t,r=Ka();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=h=>h.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??cg,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Xr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Lc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Wa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(pf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(O,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(O,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(O,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(O,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(O,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(O,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(O,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(O,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(O,{name:"chat-4",className:"h-3.5 w-3.5"});if(Un(t.mode))return s.jsx(jS,{mode:t.mode});if(t.mode==="browser"){const n=kS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(O,{name:"global",className:"h-3.5 w-3.5"})}},kS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},CS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=St(),i=Ae(g=>g.contextEditorTreeWidth),o=Ae(g=>g.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),h=c.useRef(null),f=c.useRef(null),p=c.useRef(null),x=c.useCallback(g=>{const j=p.current;j&&(j.style.width=`${g}px`,j.style.setProperty("--oc-editor-tree-width",`${g}px`))},[]),b=g=>{if(t){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{}f.current=g.pointerId,a(!0),d.current=g.clientX,u.current=i,h.current=i,g.preventDefault()}},k=g=>{if(!l||f.current!==g.pointerId)return;const j=d.current-g.clientX,S=Wi(u.current+j);h.current!==S&&(h.current=S,x(S))},y=g=>{if(f.current!==g.pointerId)return;try{g.currentTarget.releasePointerCapture(g.pointerId)}catch{}const j=Wi(h.current??i);f.current=null,h.current=null,a(!1),o(j)},m=t?i:0;return s.jsxs("div",{ref:p,className:Me("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?h.current??m:m}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?h.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Me("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:k,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Me("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(z1,{visible:t&&e})})]})},va=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,NS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},AS=(t,e)=>{if(e.length===0)return Vo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Vo:r},PS=(t,e)=>{const n=ag(t),r=c.useRef(Vo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=AS(n.getState().session,i.current);return NS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Vo)},DS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,IS=()=>{const{t}=St(),e=Zn()??"",n=c.useMemo(()=>bS(e),[e]),r=Ae(V=>n?V.contextPanelByDirectory[n]:void 0),i=Ae(V=>V.closeContextPanel),o=Ae(V=>V.closeContextPanelTab),l=Ae(V=>V.openContextPanelTab),a=Ae(V=>V.toggleContextPanelExpanded),d=Ae(V=>V.setContextPanelWidth),u=Ae(V=>V.setActiveContextPanelTab),h=Ae(V=>V.openAgentBrowserTab);c.useEffect(()=>{if(e)return Zw(V=>h(e,V))},[e,h]);const f=Ae(V=>V.openContextFile);c.useEffect(()=>Pn(V=>{if(V.type!=="file-open-request")return;const Fe=V.directory??e;Fe&&f(Fe,V.path)}),[e,f]);const p=Ae(V=>V.reorderContextPanelTabs),x=Js(V=>V.setSelectedPath),b=Ae(V=>V.contextEditorTreeVisible),k=Ae(V=>V.contextEditorTreeWidth),y=Ae(V=>V.setContextEditorTreeWidth),m=Ae(V=>V.toggleContextEditorTree),g=Ae(V=>V.contextEditorVisible),j=Ae(V=>V.toggleContextEditor),S=Ae(V=>V.openNewContextBrowserTab),w=Cf(V=>V.byOrigin),C=Ae(V=>V.allowPromptingSubagentSessions),{themeMode:v,setThemeMode:R,lightThemeId:T,darkThemeId:D,currentTheme:F}=Cn(),B=c.useMemo(()=>r?.tabs??[],[r?.tabs]),E=B.find(V=>V.id===r?.activeTabId)??B[B.length-1]??null,$=E?.mode==="browser"?E.id:null;c.useEffect(()=>{$&&Jw($)},[$]);const L=!!(r?.isOpen&&E),[X,Y]=c.useState(null),I=c.useMemo(()=>B.some(V=>V.mode==="file"&&V.targetPath),[B]),P=I&&(g||!b),A=E?.mode??null,q=A==="file"&&!P,K=!!(L&&r?.expanded&&!q),te=A?r?.widthByMode?.[A]:void 0,ae=A?r?.widthFractionByMode?.[A]:void 0,re=A?sg(A):.5,he=X??(typeof window<"u"?window.innerWidth:il*2),ce=ae!=null&&X!=null?Math.round(ae*X):te,Te=q?k:Bc(ce??Math.round(re*he),Fc(X??he));c.useEffect(()=>{!n||!A||q||ae!=null||te==null||X==null||d(n,A,te,X)},[A,X,n,q,te,ae,d]);const ve=c.useMemo(()=>{const V=[];for(const Fe of B){if(Fe.mode!=="chat")continue;const Ye=va(Fe.dedupeKey);Ye&&!V.includes(Ye)&&V.push(Ye)}return V},[B]),pe=PS(n||void 0,ve),[Ne,U]=c.useState(!1),Z=c.useRef(0),de=c.useRef(Te),ye=c.useRef(null),H=c.useRef(null),je=c.useRef(null),Ee=c.useRef(new Map),ge=c.useRef(new Map),ne=c.useRef(!1);c.useLayoutEffect(()=>{const V=je.current?.parentElement;if(!V||typeof ResizeObserver>"u")return;const Fe=new ResizeObserver(()=>{Y(V.clientWidth||null)});return Fe.observe(V),Y(V.clientWidth||null),()=>Fe.disconnect()},[]),c.useEffect(()=>{if(!L||ne.current){ne.current=L;return}const V=window.requestAnimationFrame(()=>{je.current?.focus({preventScroll:!0})});return ne.current=!0,()=>window.cancelAnimationFrame(V)},[L]);const be=c.useRef(null),G=c.useRef(null),z=c.useCallback(()=>{G.current=null;const V=je.current,Fe=ye.current;!V||Fe===null||V.style.setProperty("--oc-context-panel-width",`${Fe}px`)},[]);c.useEffect(()=>()=>{G.current!==null&&clearTimeout(G.current)},[]);const J=c.useCallback(V=>{const Fe=be.current,Ye=q?Wi(V):Bc(V,Fc(Fe));return Fe===null?Ye:Math.min(Ye,Math.max(1,Fe))},[q]),ue=c.useCallback(V=>{!L||K||!n||(H.current=V.pointerId,U(!0),Z.current=V.clientX,de.current=Te,ye.current=Te,be.current=yS(je.current),document.documentElement.style.cursor="col-resize",V.preventDefault())},[n,K,L,Te]),le=c.useCallback(()=>{const V=J(ye.current??Te),Fe=be.current;ye.current=null,be.current=null,G.current!==null&&(clearTimeout(G.current),G.current=null),document.documentElement.style.cursor="",q?y(V):n&&A&&d(n,A,V,Fe??void 0),U(!1),H.current=null},[A,J,n,q,y,d,Te]);c.useEffect(()=>{if(!Ne)return;const V=Qe=>{if(H.current!==Qe.pointerId)return;const xe=Z.current-Qe.clientX,st=J(de.current+xe);ye.current!==st&&(ye.current=st,G.current===null&&(G.current=setTimeout(z,gS)))},Fe=Qe=>{H.current===Qe.pointerId&&le()},Ye=()=>{le()};return window.addEventListener("pointermove",V),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",Ye),()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",Ye)}},[z,J,le,Ne]),c.useEffect(()=>{Ne||(ye.current=null,document.documentElement.style.cursor="")},[Ne]);const W=c.useCallback(()=>{n&&i(n)},[i,n]),M=c.useCallback(()=>{n&&a(n)},[n,a]),_=c.useCallback(V=>{V.key==="Escape"&&(V.target instanceof Node&&!V.currentTarget.contains(V.target)||ng(V.target)||rg(V.target)||(V.preventDefault(),V.stopPropagation(),W()))},[W]);c.useEffect(()=>{if(!(!n||!E)&&E.mode==="file"&&E.targetPath){x(n,E.targetPath,{allowOutsideRoot:!0});return}},[E,n,x]);const ee=c.useMemo(()=>B.filter(V=>V.mode==="chat"),[B]),oe=L&&E?.mode==="chat"?E.id:null,fe=L&&E?.mode==="chat"?va(E.dedupeKey):null,ie=yb(ee,oe);c.useEffect(()=>{if(!L||!n||!fe||typeof window>"u")return;const V=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Ci(n,fe,!1);return}Iu(fe),Ci(n,fe,!0)};V();const Fe=window.setInterval(V,1e4);return window.addEventListener("focus",V),window.addEventListener("blur",V),document.addEventListener("visibilitychange",V),()=>{window.clearInterval(Fe),window.removeEventListener("focus",V),window.removeEventListener("blur",V),document.removeEventListener("visibilitychange",V),Ci(n,fe,!1)}},[fe,n,L]);const Le=c.useCallback((V,Fe,Ye)=>wb(ge.current,V,Fe,n||null,Ye,{mode:v,lightThemeId:T,darkThemeId:D,currentTheme:F},{allowPromptingSubagentSessions:C}),[C,F,D,n,T,v]),$e=ie&&fe?Le(ie.id,fe,ie.readOnly):null;c.useEffect(()=>{const V=new Set(B.map(Fe=>Fe.id));for(const Fe of ge.current.keys())V.has(Fe)||ge.current.delete(Fe)},[B]);const Pe=c.useCallback(V=>{!n||E?.mode!=="diff"||l(n,{mode:"diff",targetPath:E.targetPath,stagedDiff:V==="staged",diffScope:V})},[E,n,l]),Oe=c.useCallback(()=>{if(typeof window>"u")return;const V={themeMode:v,lightThemeId:T,darkThemeId:D,currentTheme:F};for(const Fe of Ee.current.values()){const Ye=Fe.contentWindow;Ye&&Ye.postMessage({type:"openchamber:theme-sync",payload:V},window.location.origin)}},[F,D,T,v]),Q=c.useCallback(()=>{if(typeof window>"u")return;const V={allowPromptingSubagentSessions:C};for(const Fe of Ee.current.values()){const Ye=Fe.contentWindow;Ye&&Ye.postMessage({type:"openchamber:chat-settings-sync",payload:V},window.location.origin)}},[C]),Ce=c.useCallback((V,Fe,Ye)=>{const Qe=Fe.contentWindow;Qe&&Qe.postMessage({type:of,payload:{visible:oe===V}},Ye)},[oe]),Se=c.useCallback(()=>{if(!(typeof window>"u"))for(const[V,Fe]of Ee.current.entries())Ce(V,Fe,window.location.origin)},[Ce]);c.useEffect(()=>{if(typeof window>"u")return;const V=Fe=>{if(Fe.origin!==window.location.origin)return;const Ye=Array.from(Ee.current.entries()).find(([,ot])=>ot.contentWindow===Fe.source);if(!Ye)return;const Qe=Fe.data;if(Qe?.type===vb){const[ot,vt]=Ye;Ce(ot,vt,Fe.origin);return}if(Qe?.type===Sb){if(typeof Qe.requestId!="string"||!Qe.requestId)return;const ot=Wt(),vt={apiBaseUrl:mn(),clientToken:Ur(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Wd(),relayHostId:ot.startsWith("host:")?ot.slice(5):"",relay:ch()??void 0};Fe.source?.postMessage({type:jb,requestId:Qe.requestId,payload:vt},Fe.origin);return}if(Qe?.type==="openchamber:theme-sync-request"){Oe();return}if(Qe?.type==="openchamber:chat-settings-request"){Q();return}if(Qe?.type!=="openchamber:cycle-theme-request")return;const xe=["light","dark","system"],Re=(xe.indexOf(v)+1)%xe.length;R(xe[Re])};return window.addEventListener("message",V),()=>window.removeEventListener("message",V)},[Q,Ce,Oe,R,v]),c.useLayoutEffect(()=>{B.some(Fe=>Fe.mode==="chat")&&(Oe(),Q(),Se())},[D,T,Q,Se,Oe,B,v]);const Ke=E?.mode==="file"||E?.mode==="chat"||E?.mode==="browser",et=c.useMemo(()=>E?B.filter(V=>V.mode===E.mode):[],[E,B]),it=c.useMemo(()=>et.map(V=>{const Fe=SS(V,pe,t),Ye=DS(Fe,xS),Qe=wS(V.targetPath,e);return{id:V.id,label:Ye,icon:Lc(V,w),title:Qe?`${Fe}: ${Qe}`:Fe,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ye})}}),[et,e,w,pe,t]),rt=E?.mode==="context"?s.jsx(iw,{}):E?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(uS,{isActive:L})}):E?.mode==="pr"?s.jsx(h1,{}):E?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(fS,{})}):E?.mode==="notes"?s.jsx(Fh,{}):E?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(mS,{targetPath:E.targetPath,savedProjectPlan:E.projectPlanId&&E.projectPlanRef?{projectRef:E.projectPlanRef,planId:E.projectPlanId}:null})}):null,pt=c.useMemo(()=>B.filter(V=>V.mode==="browser"),[B]),ht=c.useMemo(()=>B.filter(V=>V.mode==="diff"),[B]),tt=c.useMemo(()=>B.find(V=>V.mode==="terminal")??null,[B]),At=c.useMemo(()=>B.some(V=>V.mode==="walkthrough"),[B]),jt=c.useMemo(()=>B.filter(V=>Un(V.mode)),[B]),we=Fa(V=>V.guests),Xe=c.useMemo(()=>new Set(we.filter(og).map(V=>V.id)),[we]),mt=c.useMemo(()=>{const V=new Map;for(const Fe of we){const Ye=ig(Fe);Ye&&V.set(Fe.id,Ye)}return V},[we]),qe=c.useMemo(()=>B.some(V=>V.mode==="file"),[B]),ft=E?.mode==="file",se=Ae(V=>V.closeContextPanelTabs),me=c.useCallback(V=>{if(!n)return null;const{id:Fe,index:Ye,allIds:Qe,close:xe}=V,st=()=>se(n,Qe.filter(He=>He!==Fe)),Re=()=>se(n,Qe.slice(0,Ye)),ot=()=>se(n,Qe.slice(Ye+1)),vt=()=>se(n,Qe),De=Qe.length>1,gt=Ye===0,Ct=Ye===Qe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(zn,{onClick:xe,children:[s.jsx(O,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Hi,{}),s.jsxs(zn,{onClick:st,disabled:!De,children:[s.jsx(O,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(zn,{onClick:Re,disabled:gt,children:[s.jsx(O,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(zn,{onClick:ot,disabled:Ct,children:[s.jsx(O,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Hi,{}),s.jsxs(zn,{onClick:vt,disabled:!De,children:[s.jsx(O,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[se,n,t]),Ie=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ke?s.jsx(Yd,{items:it,activeId:E?.id??null,onSelect:V=>{n&&u(n,V)},onClose:V=>{n&&o(n,V)},onReorder:(V,Fe)=>{n&&p(n,V,Fe)},layoutMode:"scrollable",variant:"default",tabContextMenu:me}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[E?Lc(E,w):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:E?Uf(E.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[E?.mode==="browser"?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(O,{name:"add",className:"h-3.5 w-3.5"})}):null,ft&&I?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":P,children:s.jsx(O,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,ft?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:m,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(O,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,q?null:s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:M,className:"h-7 w-7 p-0",title:t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:K?s.jsx(O,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:W,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})})]})]}),We=L?K?{"--oc-context-panel-width":X!==null?`${X}px`:"100%",width:X!==null?`${X}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Te}px`}:{"--oc-context-panel-width":`${Te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:je,"data-context-panel":"true",tabIndex:-1,inert:!L||void 0,className:Me("flex min-h-0 flex-col overflow-hidden bg-background",K?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!L&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:_,style:We,children:[L&&!K&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),L&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!K&&s.jsx("div",{className:Me("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Ne&&"bg-[var(--interactive-border)]"),onPointerDown:ue,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Me("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!L&&"pointer-events-none select-none opacity-0"),style:{width:K?X!==null?`${X}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!L,children:[Ie,s.jsxs("div",{className:Me("relative min-h-0 flex-1 overflow-hidden",Ne&&"pointer-events-none"),children:[qe?s.jsxs("div",{className:Me("absolute inset-0 flex",ft?"flex":"hidden"),children:[I||!b?s.jsx("div",{className:Me("h-full min-w-0 flex-1",I&&!P&&"hidden"),children:I?s.jsx(c.Suspense,{fallback:null,children:s.jsx(dS,{mode:"editor-only",visible:L&&ft&&P})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(O,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(CS,{visible:b,active:L&&ft,fill:!P})]}):null,ie&&fe&&$e?s.jsx("iframe",{ref:V=>{if(!V){Ee.current.delete(ie.id);return}Ee.current.set(ie.id,V)},src:$e,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:fe}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Oe(),Q(),Se()}},ie.id):null,pt.map(V=>s.jsx("div",{className:Me("absolute inset-0",E?.id!==V.id&&"invisible pointer-events-none"),"aria-hidden":E?.id!==V.id||void 0,children:s.jsx(nS,{initialUrl:V.targetPath??"",directory:n,tabID:V.id})},V.id)),ht.map(V=>s.jsx("div",{className:Me("absolute inset-0",E?.id!==V.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(cS,{visible:L&&E?.id===V.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:V.diffScope??(V.stagedDiff?"staged":"working"),onDiffScopeChange:Pe,targetFilePath:V.targetPath,flushContent:!0})})},V.id)),tt?s.jsx("div",{className:Me("absolute inset-0",E?.mode==="terminal"?"block":"hidden"),children:s.jsx(Lh,{visible:L&&E?.mode==="terminal",directory:tt.targetDirectory})}):null,At?s.jsx("div",{className:Me("absolute inset-0",E?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(lS,{directory:e,visible:L&&E?.mode==="walkthrough"})})}):null,jt.map(V=>{if(!Un(V.mode))return null;const Fe=Ro(V.mode),Ye=Xe.has(Fe),Qe=mt.get(Fe),xe=E?.id===V.id,st=xe&&L;return Ye&&!Qe&&!st?null:s.jsx("div",{className:Me("absolute inset-0",xe?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ye?Qe?s.jsxs("div",{className:Me("flex h-full",Kf[Qe.dock].container),children:[s.jsx(hS,{mode:V.mode,docking:Qe}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:st?s.jsx(Oc,{mode:V.mode}):null})]}):s.jsx(Oc,{mode:V.mode}):s.jsx(Wf,{mode:V.mode})})},V.id)}),E?.mode!=="chat"&&!ft&&E?.mode!=="browser"&&E?.mode!=="diff"&&E?.mode!=="terminal"&&E?.mode!=="walkthrough"&&!(E&&Un(E.mode))?rt:null]})]})]})},TS=t=>{const e=Ze.c(43),{open:n,onOpenChange:r}=t,{t:i}=St(),o=Ae(ES),l=Ae(RS),a=Ae(MS),d=Ae(OS),u=Ka();let h;e[0]!==o||e[1]!==u?(h=Tu(o,u),e[0]=o,e[1]=u,e[2]=h):h=e[2];const f=h,p=l.length===0;let x;if(e[3]!==l||e[4]!==f){let T;e[6]!==l?(T=D=>l.includes(D.id),e[6]=l,e[7]=T):T=e[7],x=f.every(T),e[3]=l,e[4]=f,e[5]=x}else x=e[5];const b=x;let k;e[8]!==i?(k=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=k):k=e[9];let y;e[10]!==k?(y=s.jsx(Bs,{children:k}),e[10]=k,e[11]=y):y=e[11];let m;e[12]!==i?(m=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=m):m=e[13];let g;e[14]!==m?(g=s.jsx(Fs,{children:m}),e[14]=m,e[15]=g):g=e[15];let j;e[16]!==y||e[17]!==g?(j=s.jsxs(Us,{children:[y,g]}),e[16]=y,e[17]=g,e[18]=j):j=e[18];let S;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let T;e[24]!==l||e[25]!==a||e[26]!==i?(T=D=>s.jsx(dg,{settingsItem:`layout.context-rail.surface.${D.id}`,checked:!l.includes(D.id),onChange:F=>a(D.id,F),label:D.label??i(D.labelKey),ariaLabel:D.label??i(D.labelKey)},D.id),e[24]=l,e[25]=a,e[26]=i,e[27]=T):T=e[27],S=f.map(T),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=S}else S=e[23];let w;e[28]!==S?(w=s.jsx("div",{className:"flex flex-col",children:S}),e[28]=S,e[29]=w):w=e[29];let C;e[30]!==p||e[31]!==b||e[32]!==d||e[33]!==i?(C=p?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ut,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=p,e[31]=b,e[32]=d,e[33]=i,e[34]=C):C=e[34];let v;e[35]!==C||e[36]!==j||e[37]!==w?(v=s.jsxs(ys,{className:"max-w-md",children:[j,w,C]}),e[35]=C,e[36]=j,e[37]=w,e[38]=v):v=e[38];let R;return e[39]!==r||e[40]!==n||e[41]!==v?(R=s.jsx(bs,{open:n,onOpenChange:r,children:v}),e[39]=r,e[40]=n,e[41]=v,e[42]=R):R=e[42],R};function ES(t){return t.contextRailOrder}function RS(t){return t.contextRailHiddenSurfaces}function MS(t){return t.setContextRailSurfaceVisible}function OS(t){return t.setContextRailHiddenSurfaces}const Hf=150,BS=500,FS=[],LS=t=>t>99?"99+":String(t),_S=t=>{const e=Ze.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:p}=t;let x;e[0]!==n.id?(x={id:n.id},e[0]=n.id,e[1]=x):x=e[1];const{attributes:b,listeners:k,setNodeRef:y,transform:m,transition:g,isDragging:j}=di(x);let S;e[2]!==a?(S=a!=null&&a>0?LS(a):null,e[2]=a,e[3]=S):S=e[3];const w=S;let C;e[4]!==m?(C=ui.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let v;e[6]!==C||e[7]!==g?(v={transform:C,transition:g},e[6]=C,e[7]=g,e[8]=v):v=e[8];const R=j&&"z-10 opacity-70";let T;e[9]!==R?(T=Me("relative",R),e[9]=R,e[10]=T):T=e[10];let D;e[11]!==p||e[12]!==n?(D=()=>p(n),e[11]=p,e[12]=n,e[13]=D):D=e[13];const F=d??o,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==B?(E=Me("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=E):E=e[15];let $;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?($=n.id==="diff"?s.jsx(pf,{className:"h-[18px] w-[18px]"}):s.jsx(Xr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=$):$=e[19];let L;e[20]!==w||e[21]!==h||e[22]!==i||e[23]!==f?(L=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):w?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:w}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=w,e[21]=h,e[22]=i,e[23]=f,e[24]=L):L=e[24];let X;e[25]!==b||e[26]!==r||e[27]!==k||e[28]!==E||e[29]!==$||e[30]!==L||e[31]!==D||e[32]!==F?(X=s.jsx(yt,{asChild:!0,children:s.jsxs("button",{type:"button",...b,...k,onClick:D,"aria-label":F,"aria-pressed":r,className:E,children:[$,L]})}),e[25]=b,e[26]=r,e[27]=k,e[28]=E,e[29]=$,e[30]=L,e[31]=D,e[32]=F,e[33]=X):X=e[33];let Y;e[34]!==o?(Y=s.jsx("span",{children:o}),e[34]=o,e[35]=Y):Y=e[35];let I;e[36]!==l?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=I):I=e[37];let P;e[38]!==u?(P=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=P):P=e[39];let A;e[40]!==Y||e[41]!==I||e[42]!==P?(A=s.jsx(wt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[Y,I,P]})}),e[40]=Y,e[41]=I,e[42]=P,e[43]=A):A=e[43];let q;e[44]!==X||e[45]!==A?(q=s.jsxs(bt,{delayDuration:Hf,children:[X,A]}),e[44]=X,e[45]=A,e[46]=q):q=e[46];let K;return e[47]!==y||e[48]!==q||e[49]!==v||e[50]!==T?(K=s.jsx("div",{ref:y,style:v,className:T,children:q}),e[47]=y,e[48]=q,e[49]=v,e[50]=T,e[51]=K):K=e[51],K},$S=()=>{const t=Ze.c(92),{t:e}=St(),n=Zn();let r;t[0]!==n?(r=n?$n(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Ae(o),a=Ae(zS),d=Ae(WS),u=Ae(KS),h=Ae(VS),f=Ae(US),p=Ae(HS),x=Ae(GS),b=La(qS),k=Ji(YS),y=Ji(QS),m=hn(XS),g=hn(JS),{screenWidth:j}=Nn(),S=_a(i||null);let w;t[4]!==x?(w=Zi("switch_context_surface",x),t[4]=x,t[5]=w):w=t[5];const C=w,[v,R]=c.useState(!1);let T,D;t[6]!==C?(T=()=>{const le=new Set;let W=null,M=!1;const _=ZS,ee=()=>{Ol(C,le)?!M&&W===null&&(W=setTimeout(()=>R(!0),BS)):(M=!1,W!==null&&(clearTimeout(W),W=null),R(!1))},oe=Le=>{if(le.add(Le.key.toLowerCase()),_(Le.key)&&Ol(C,le)){M=!0,W!==null&&(clearTimeout(W),W=null),R(!1);return}ee()},fe=Le=>{le.delete(Le.key.toLowerCase()),ee()},ie=()=>{le.clear(),M=!1,W!==null&&(clearTimeout(W),W=null),R(!1)};return window.addEventListener("keydown",oe,!0),window.addEventListener("keyup",fe,!0),window.addEventListener("blur",ie),()=>{window.removeEventListener("keydown",oe,!0),window.removeEventListener("keyup",fe,!0),window.removeEventListener("blur",ie),W!==null&&clearTimeout(W)}},D=[C],t[6]=C,t[7]=T,t[8]=D):(T=t[7],D=t[8]),c.useEffect(T,D);let F;t[9]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},t[9]=F):F=t[9];let B;t[10]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{delay:200,tolerance:6}},t[10]=B):B=t[10];const E=oi(fn(ai,F),fn(ii,B)),$=Ka(),L=Ml(ej),X=Ml(tj),Y=l?.tabs??FS;let I;t[11]!==l?.activeTabId||t[12]!==Y?(I=Y.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=Y,t[13]=I):I=t[13];const P=I,A=l?.isOpen?P?.mode??null:null,q=S?.files.length??0;let K;t[14]!==u||t[15]!==d||t[16]!==g||t[17]!==$||t[18]!==y||t[19]!==b||t[20]!==j||t[21]!==Y?(K=ug({railOrder:d,hiddenSurfaces:u,planModeEnabled:b,isVSCode:kn(),screenWidth:j,tabs:Y,linearConnected:y,githubConnected:g,extras:$}),t[14]=u,t[15]=d,t[16]=g,t[17]=$,t[18]=y,t[19]=b,t[20]=j,t[21]=Y,t[22]=K):K=t[22];const te=K;let ae,re;t[23]!==A||t[24]!==p||t[25]!==i||t[26]!==k||t[27]!==y?(re=()=>{!i||!k||y||A!=="linear"||p(i)},ae=[A,p,i,k,y],t[23]=A,t[24]=p,t[25]=i,t[26]=k,t[27]=y,t[28]=ae,t[29]=re):(ae=t[28],re=t[29]),c.useEffect(re,ae);let he,ce;t[30]!==A||t[31]!==p||t[32]!==i||t[33]!==m||t[34]!==g?(he=()=>{!i||!m||g||A!=="pr"||p(i)},ce=[A,p,i,m,g],t[30]=A,t[31]=p,t[32]=i,t[33]=m,t[34]=g,t[35]=he,t[36]=ce):(he=t[35],ce=t[36]),c.useEffect(he,ce);const[Te,ve]=c.useState(!1);let pe;t[37]!==$||t[38]!==h?(pe=le=>{const{active:W,over:M}=le;if(!M||W.id===M.id)return;const _=Tu(Ae.getState().contextRailOrder,$).map(sj),ee=_.indexOf(W.id),oe=_.indexOf(M.id);ee===-1||oe===-1||h(Zu(_,ee,oe))},t[37]=$,t[38]=h,t[39]=pe):pe=t[39];const Ne=pe;if(!i)return null;let U;t[40]!==e?(U=e("contextRail.aria.rail"),t[40]=e,t[41]=U):U=t[41];let Z;t[42]!==te?(Z=te.map(nj),t[42]=te,t[43]=Z):Z=t[43];let de;if(t[44]!==A||t[45]!==q||t[46]!==X||t[47]!==i||t[48]!==L||t[49]!==f||t[50]!==v||t[51]!==te||t[52]!==e||t[53]!==a){let le;t[55]!==A||t[56]!==q||t[57]!==X||t[58]!==i||t[59]!==L||t[60]!==f||t[61]!==v||t[62]!==e||t[63]!==a?(le=(W,M)=>{const _=W.label??e(W.labelKey),ee=W.id==="git"&&!a?q:0,oe=Un(W.mode)&&A!==W.mode?L[Ro(W.mode)]??0:0,fe=ee>0?ee:oe>0?oe:null,ie=fe!==null&&ee===0;return s.jsx(_S,{surface:W,isActive:A===W.mode,showActivityDot:!1,label:_,description:e(W.descriptionKey),badgeCount:fe,badgeAriaLabel:fe!==null?e(ie?fe===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":fe===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:_,count:fe}):null,badgeDescription:fe!==null?e(ie?fe===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":fe===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:fe}):null,orderNumber:M+1,showOrderNumber:v,onSelect:Le=>{Un(Le.mode)&&X(Ro(Le.mode)),f(i,Le.mode)}},W.id)},t[55]=A,t[56]=q,t[57]=X,t[58]=i,t[59]=L,t[60]=f,t[61]=v,t[62]=e,t[63]=a,t[64]=le):le=t[64],de=te.map(le),t[44]=A,t[45]=q,t[46]=X,t[47]=i,t[48]=L,t[49]=f,t[50]=v,t[51]=te,t[52]=e,t[53]=a,t[54]=de}else de=t[54];let ye;t[65]!==Z||t[66]!==de?(ye=s.jsx(Xa,{items:Z,strategy:ef,children:de}),t[65]=Z,t[66]=de,t[67]=ye):ye=t[67];let H;t[68]!==Ne||t[69]!==E||t[70]!==ye?(H=s.jsx(li,{sensors:E,collisionDetection:ci,onDragEnd:Ne,children:ye}),t[68]=Ne,t[69]=E,t[70]=ye,t[71]=H):H=t[71];let je;t[72]!==e?(je=e("contextRail.configure.open"),t[72]=e,t[73]=je):je=t[73];let Ee;t[74]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>ve(!0),t[74]=Ee):Ee=t[74];let ge;t[75]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(O,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=ge):ge=t[75];let ne;t[76]!==je?(ne=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":je,onClick:Ee,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ge})}),t[76]=je,t[77]=ne):ne=t[77];let be;t[78]!==e?(be=e("contextRail.configure.open"),t[78]=e,t[79]=be):be=t[79];let G;t[80]!==be?(G=s.jsx(wt,{side:"left",sideOffset:8,children:be}),t[80]=be,t[81]=G):G=t[81];let z;t[82]!==ne||t[83]!==G?(z=s.jsxs(bt,{delayDuration:Hf,children:[ne,G]}),t[82]=ne,t[83]=G,t[84]=z):z=t[84];let J;t[85]!==Te?(J=s.jsx(TS,{open:Te,onOpenChange:ve}),t[85]=Te,t[86]=J):J=t[86];let ue;return t[87]!==U||t[88]!==H||t[89]!==z||t[90]!==J?(ue=s.jsxs("nav",{"aria-label":U,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,z,J]}),t[87]=U,t[88]=H,t[89]=z,t[90]=J,t[91]=ue):ue=t[91],ue};function zS(t){return t.workStatusPanelVisible}function WS(t){return t.contextRailOrder}function KS(t){return t.contextRailHiddenSurfaces}function VS(t){return t.setContextRailOrder}function US(t){return t.openContextSurface}function HS(t){return t.closeContextPanel}function GS(t){return t.shortcutOverrides}function qS(t){return t.planModeEnabled}function YS(t){return t.hasChecked}function QS(t){return t.status?.connected===!0}function XS(t){return t.hasChecked}function JS(t){return t.status?.connected===!0}function ZS(t){return t.length===1&&t>="0"&&t<="9"}function ej(t){return t.countByGuest}function tj(t){return t.clearBadge}function sj(t){return t.id}function nj(t){return t.id}const rj=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),oj=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Or(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),ij=new Set,aj=[],Sa=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},lj=()=>{const t=Ze.c(183),{t:e}=St(),n=Ae(cj),r=Ae(dj),i=Ae(uj),o=Ae(fj),l=Ae(mj),a=Ae(hj),d=Ae(pj),u=Ae(gj),h=Ae(xj),f=Ae(bj),p=Ae(yj),x=Ae(wj),b=Ae(vj),k=nt(Sj),y=nt(jj),m=nt(kj),g=Hr(Cj);let j;t[0]!==n?(j=He=>n?He.activeSessions:aj,t[0]=n,t[1]=j):j=t[1];const S=us(j);let w;t[2]!==n?(w=He=>n?He.ids:ij,t[2]=n,t[3]=w):w=t[3];const C=Hr(w);let v;t[4]!==n?(v=He=>n?He.rankById:Ua,t[4]=n,t[5]=v):v=t[5];const R=Va(v),T=Jt(Nj),D=zt(Aj),F=zt(Pj),B=Zn(),E=$d(Dj),{files:$,git:L}=nn(),X=pn(Ij),{isMobile:Y}=Nn();let I;t[6]!==B?(I=B?Sa(B):null,t[6]=B,t[7]=I):I=t[7];const P=I,[A,q]=c.useState(""),te=Au(A,200).trim();let ae;t[8]!==A?(ae=A.trim(),t[8]=A,t[9]=ae):ae=t[9];const re=ae;let he,ce;t[10]!==n?(he=()=>{n&&q("")},ce=[n],t[10]=n,t[11]=he,t[12]=ce):(he=t[11],ce=t[12]),c.useEffect(he,ce);let Te,ve;t[13]!==S||t[14]!==X||t[15]!==L||t[16]!==n?(Te=()=>{if(!n||!L)return;const He=setTimeout(()=>{const Ue=new Set;for(const lt of S){const _e=xs(lt);!_e||Ue.has(_e)||(Ue.add(_e),X(_e,L))}},0);return()=>clearTimeout(He)},ve=[n,S,L,X],t[13]=S,t[14]=X,t[15]=L,t[16]=n,t[17]=Te,t[18]=ve):(Te=t[17],ve=t[18]),c.useEffect(Te,ve);let pe;t[19]!==r?(pe=()=>r(!1),t[19]=r,t[20]=pe):pe=t[20];const Ne=pe;let U;t[21]!==Ne?(U=He=>()=>{Ne(),He()},t[21]=Ne,t[22]=U):U=t[22];const Z=U;let de;t[23]!==D?.id||t[24]!==D?.path||t[25]!==T||t[26]!==m||t[27]!==Y||t[28]!==d||t[29]!==u||t[30]!==p||t[31]!==k||t[32]!==Z||t[33]!==x||t[34]!==b||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==g||t[39]!==a?(de=()=>{const He=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(O,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:Z(()=>{l(!1),k()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(O,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:Z(Tj)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(O,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:Z(Ej)},{id:"toggle-sidebar",title:e(Y?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(O,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(Y?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:Z(()=>{if(Y){const{isSessionSwitcherOpen:Ue}=Ae.getState();l(!Ue)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(O,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:Z(()=>{T&&u(T,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(O,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:Z(()=>{T&&d(T)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(O,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:Z(Rj)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(O,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:Z(Mj)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(O,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:Z(()=>i(!0))}];return He.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(O,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:Z(()=>{m&&T&&g({directory:T,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(O,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:Z(()=>{m&&Jn(m).then(Ue=>{if(Ue.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(O,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:Z(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(O,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:Z(()=>{l(!1),x(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(O,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:Z(()=>{T&&(b("notes"),u(T,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(O,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:Z(()=>{T&&(b("todos"),u(T,"notes"))})}),kn()||He.push({id:"restart-opencode",secondary:!0,title:e("commandPalette.item.restartOpenCode"),icon:s.jsx(O,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.restartOpenCode"),onSelect:Z(()=>{$h(e)})}),He.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(O,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:Z(Oj)}),Vr()&&He.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(O,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:Z(()=>{jn("desktop_open_draft_mini_chat_window",{directory:Sa(T||D?.path||""),projectId:D?.id??null}).catch(Bj)})}),He},t[23]=D?.id,t[24]=D?.path,t[25]=T,t[26]=m,t[27]=Y,t[28]=d,t[29]=u,t[30]=p,t[31]=k,t[32]=Z,t[33]=x,t[34]=b,t[35]=l,t[36]=i,t[37]=e,t[38]=g,t[39]=a,t[40]=de):de=t[40],D?.id,D?.path;let ye;t[41]!==de?(ye=de(),t[41]=de,t[42]=ye):ye=t[42];const H=ye,je=Ae(Fj);let Ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(Ee=en(),t[43]=Ee):Ee=t[43];const ge=Ee;let ne,be;t[44]===Symbol.for("react.memo_cache_sentinel")?(ne=kn(),be=!ge&&Ra(),t[44]=ne,t[45]=be):(ne=t[44],be=t[45]);let G;t[46]!==Y||t[47]!==je?(G={isVSCode:ne,isWeb:be,isDesktop:ge,isMobile:Y,routingAvailable:je},t[46]=Y,t[47]=je,t[48]=G):G=t[48];const z=G;let J;if(t[49]!==Z||t[50]!==i||t[51]!==o||t[52]!==z){let He;t[54]!==z?(He=lt=>lt.isAvailable?lt.isAvailable(z):!0,t[54]=z,t[55]=He):He=t[55];let Ue;t[56]!==Z||t[57]!==i||t[58]!==o?(Ue=lt=>{const _e=zh(lt.slug)??"settings-3",Ge=(lt.keywords??[]).join(" ");return{id:`settings:${lt.slug}`,title:lt.title,icon:lt.slug==="mcp"?s.jsx(gg,{className:"mr-2 h-4 w-4"}):s.jsx(O,{name:_e,className:"mr-2 h-4 w-4"}),searchText:`${lt.title} ${lt.group} ${Ge}`,onSelect:Z(()=>{o(lt.slug),i(!0)})}},t[56]=Z,t[57]=i,t[58]=o,t[59]=Ue):Ue=t[59],J=_h.filter(Lj).filter(He).map(Ue),t[49]=Z,t[50]=i,t[51]=o,t[52]=z,t[53]=J}else J=t[53];const ue=J;let le;if(t[60]!==S||t[61]!==C||t[62]!==R){const He=S.filter(_j);le=fg(He,C,R),t[60]=S,t[61]=C,t[62]=R,t[63]=le}else le=t[63];const W=le,M=Eu(),_=nt($j);let ee;t[64]!==M||t[65]!==_?(ee=(He,Ue)=>{const lt=_.get(He);return lt?.branch?lt.branch.trim()||null:Ue&&M.get(Ue)?.trim()||null},t[64]=M,t[65]=_,t[66]=ee):ee=t[66];const oe=ee;let fe;t[67]===Symbol.for("react.memo_cache_sentinel")?(fe=[],t[67]=fe):fe=t[67];const[ie,Le]=c.useState(fe),[$e,Pe]=c.useState(""),Oe=rj(P,te);let Q;t[68]!==P||t[69]!==Oe||t[70]!==n||t[71]!==E||t[72]!==Le||t[73]!==Pe||t[74]!==te?(Q=()=>{if(!n){Le([]),Pe("");return}if(!Oe){Le([]),Pe("");return}if(!P){Le([]),Pe("");return}let He=!1;return E(P,te,40,{type:"file"}).then(Ue=>{He||(Le(Ue.map(zj)),Pe(Oe))}).catch(()=>{He||(Le([]),Pe(Oe))}),()=>{He=!0}},t[68]=P,t[69]=Oe,t[70]=n,t[71]=E,t[72]=Le,t[73]=Pe,t[74]=te,t[75]=Q):Q=t[75];let Ce;t[76]!==P||t[77]!==Oe||t[78]!==n||t[79]!==E||t[80]!==te?(Ce=[n,P,te,Oe,E],t[76]=P,t[77]=Oe,t[78]=n,t[79]=E,t[80]=te,t[81]=Ce):Ce=t[81],c.useEffect(Q,Ce);const Se=re.length>0;let Ke;e:{if(!Se){let Ue;t[82]!==H?(Ue=H.filter(Wj).map(Kj),t[82]=H,t[83]=Ue):Ue=t[83],Ke=Ue;break e}let He;t[84]!==H||t[85]!==re?(He=Or(H,re,Vj,{limit:7,noFuzzy:!0}),t[84]=H,t[85]=re,t[86]=He):He=t[86],Ke=He}const et=Ke;let it;e:{if(!Se){let Ue;t[87]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[87]=Ue):Ue=t[87],it=Ue;break e}let He;t[88]!==re||t[89]!==ue?(He=Or(ue,re,Uj,{limit:7,noFuzzy:!0}),t[88]=re,t[89]=ue,t[90]=He):He=t[90],it=He}const rt=it;let pt;e:{if(!Se){let Ue;t[91]!==W?(Ue=W.slice(0,5).map(Hj),t[91]=W,t[92]=Ue):Ue=t[92],pt=Ue;break e}let He;t[93]!==re||t[94]!==W?(He=Or(W,re,Gj,{limit:7,threshold:.2}),t[93]=re,t[94]=W,t[95]=He):He=t[95],pt=He}const ht=pt;let tt;e:{if(!n){let Ue;t[96]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[96]=Ue):Ue=t[96],tt=Ue;break e}let He;t[97]!==ie||t[98]!==$e||t[99]!==Oe||t[100]!==te?(He=oj(ie,te,Oe,$e),t[97]=ie,t[98]=$e,t[99]=Oe,t[100]=te,t[101]=He):He=t[101],tt=He}const At=tt,jt=n&&Oe.length>0&&$e!==Oe;let we;e:{if(!Se){let Ue;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[102]=Ue):Ue=t[102],we=Ue;break e}let He;if(t[103]!==re||t[104]!==F){const Ue=F.map(qj);He=Or(Ue,re,Yj,{limit:7,threshold:.4}),t[103]=re,t[104]=F,t[105]=He}else He=t[105];we=He}const Xe=we;let mt,qe,ft,se,me,Ie,We,V,Fe,Ye,Qe,xe,st,Re;if(t[106]!==oe||t[107]!==Ne||t[108]!==P||t[109]!==$||t[110]!==Se||t[111]!==n||t[112]!==h||t[113]!==k||t[114]!==A||t[115]!==et||t[116]!==At||t[117]!==Xe||t[118]!==ht||t[119]!==rt||t[120]!==r||t[121]!==y||t[122]!==f||t[123]!==e){const He=et.map(Qj),Ue=rt.map(Xj),lt=ht.map(Jj),_e=Se?At.map(Zj):[],Ge=Se?Xe.map(e0):[];let Je;e:{if(!Se){Je=["commands","sessions"];break e}const Dt=t0,Pt=[{key:"commands",score:Dt(et)},{key:"settings",score:Dt(rt)},{key:"sessions",score:Dt(ht)},{key:"files",score:Dt(At)},{key:"projects",score:Dt(Xe)}];Pt.sort(s0),Je=Pt.map(n0)}const at=Je,Nt=Dt=>{Ne(),y(Dt.id,xs(Dt))},Bt=async Dt=>{if(!P)return;const Pt=await wf($,Dt,{directory:P});if(!Pt.ok){ze.error(vf(Pt.reason));return}h(P,Dt),Ne()},Ft=(Dt,Pt)=>{Ne(),k({selectedProjectId:Dt,directoryOverride:Pt})},Qt=Dt=>Hn(Jr(Dt,f));se=bs,xe=n,st=r;let Mt;t[138]!==e?(Mt=e("commandPalette.title"),t[138]=e,t[139]=Mt):Mt=t[139];let Gt;t[140]!==Mt?(Gt=s.jsx(Bs,{children:Mt}),t[140]=Mt,t[141]=Gt):Gt=t[141];let $t;t[142]!==e?($t=e("commandPalette.description"),t[142]=e,t[143]=$t):$t=t[143];let Zt;t[144]!==$t?(Zt=s.jsx(Fs,{children:$t}),t[144]=$t,t[145]=Zt):Zt=t[145],t[146]!==Gt||t[147]!==Zt?(Re=s.jsxs(Us,{className:"sr-only",children:[Gt,Zt]}),t[146]=Gt,t[147]=Zt,t[148]=Re):Re=t[148],ft=ys,Ye="overflow-hidden p-0",Qe=!0,qe=xg,We=!1,V="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let ts;t[149]!==e?(ts=e("commandPalette.input.placeholder"),t[149]=e,t[150]=ts):ts=t[150],t[151]!==A||t[152]!==ts?(Fe=s.jsx(bg,{value:A,onValueChange:q,placeholder:ts}),t[151]=A,t[152]=ts,t[153]=Fe):Fe=t[153],mt=yg;let Ot;t[154]!==e?(Ot=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Ot):Ot=t[155],t[156]!==Ot?(me=s.jsx(wg,{children:Ot}),t[156]=Ot,t[157]=me):me=t[157],Ie=at.map(Dt=>Dt==="commands"&&He.length>0?s.jsx(Pr,{children:He.map(Pt=>s.jsxs(Br,{value:Pt.id,onSelect:Pt.onSelect,children:[Pt.icon,s.jsx("span",{children:Pt.title}),Pt.shortcutId?s.jsx(mg,{children:Qt(Pt.shortcutId)}):null]},Pt.id))},"commands"):Dt==="settings"&&Ue.length>0?s.jsx(Pr,{children:Ue.map(r0)},"settings"):Dt==="sessions"&&lt.length>0?s.jsx(Pr,{children:lt.map(Pt=>{const fs=Pt.title||e("commandPalette.session.untitled"),Ts=xs(Pt),xn=oe(Pt.id,Ts);return s.jsxs(Br,{value:`session:${Pt.id}`,onSelect:()=>Nt(Pt),children:[s.jsx(O,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:fs}),xn?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:xn})]}):null]},Pt.id)})},"sessions"):Dt==="files"&&_e.length>0?s.jsx(Pr,{children:_e.map(Pt=>{const fs=hg(Pt.relativePath||Pt.name,{maxLength:80});return s.jsxs(Br,{value:`file:${Pt.path}`,onSelect:()=>{Bt(Pt.path)},children:[s.jsx(Wa,{filePath:Pt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Pt.relativePath,children:fs})]},`file:${Pt.path}`)})},"files"):Dt==="projects"&&Ge.length>0?s.jsx(Pr,{children:Ge.map(Pt=>{const fs=Pt.displayName;return s.jsxs(Br,{value:`project:${Pt.id}`,onSelect:()=>Ft(Pt.id,Pt.path),children:[s.jsx(O,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:fs}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Pt.path})]},`project:${Pt.id}`)})},"projects"):null),t[106]=oe,t[107]=Ne,t[108]=P,t[109]=$,t[110]=Se,t[111]=n,t[112]=h,t[113]=k,t[114]=A,t[115]=et,t[116]=At,t[117]=Xe,t[118]=ht,t[119]=rt,t[120]=r,t[121]=y,t[122]=f,t[123]=e,t[124]=mt,t[125]=qe,t[126]=ft,t[127]=se,t[128]=me,t[129]=Ie,t[130]=We,t[131]=V,t[132]=Fe,t[133]=Ye,t[134]=Qe,t[135]=xe,t[136]=st,t[137]=Re}else mt=t[124],qe=t[125],ft=t[126],se=t[127],me=t[128],Ie=t[129],We=t[130],V=t[131],Fe=t[132],Ye=t[133],Qe=t[134],xe=t[135],st=t[136],Re=t[137];let ot;t[158]!==jt||t[159]!==e?(ot=jt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=jt,t[159]=e,t[160]=ot):ot=t[160];let vt;t[161]!==mt||t[162]!==me||t[163]!==Ie||t[164]!==ot?(vt=s.jsxs(mt,{children:[me,Ie,ot]}),t[161]=mt,t[162]=me,t[163]=Ie,t[164]=ot,t[165]=vt):vt=t[165];let De;t[166]!==qe||t[167]!==We||t[168]!==V||t[169]!==Fe||t[170]!==vt?(De=s.jsxs(qe,{shouldFilter:We,className:V,children:[Fe,vt]}),t[166]=qe,t[167]=We,t[168]=V,t[169]=Fe,t[170]=vt,t[171]=De):De=t[171];let gt;t[172]!==ft||t[173]!==Ye||t[174]!==Qe||t[175]!==De?(gt=s.jsx(ft,{className:Ye,showCloseButton:Qe,children:De}),t[172]=ft,t[173]=Ye,t[174]=Qe,t[175]=De,t[176]=gt):gt=t[176];let Ct;return t[177]!==se||t[178]!==xe||t[179]!==st||t[180]!==Re||t[181]!==gt?(Ct=s.jsxs(se,{open:xe,onOpenChange:st,children:[Re,gt]}),t[177]=se,t[178]=xe,t[179]=st,t[180]=Re,t[181]=gt,t[182]=Ct):Ct=t[182],Ct};function cj(t){return t.isCommandPaletteOpen}function dj(t){return t.setCommandPaletteOpen}function uj(t){return t.setSettingsDialogOpen}function fj(t){return t.setSettingsPage}function mj(t){return t.setSessionSwitcherOpen}function hj(t){return t.toggleSidebar}function pj(t){return t.openContextOverview}function gj(t){return t.openContextSurface}function xj(t){return t.openContextFile}function bj(t){return t.shortcutOverrides}function yj(t){return t.openMultiRunLauncher}function wj(t){return t.setArchivePageOpen}function vj(t){return t.setProjectContextTab}function Sj(t){return t.openNewSessionDraft}function jj(t){return t.setCurrentSession}function kj(t){return t.currentSessionId}function Cj(t){return t.toggle}function Nj(t){return t.currentDirectory}function Aj(t){return t.getActiveProject()}function Pj(t){return t.projects}function Dj(t){return t.searchFiles}function Ij(t){return t.ensureStatus}function Tj(){Ru()}function Ej(){Qs.requestDirectoryDialog()}function Rj(){vg.invoke("cycle_theme")}function Mj(){Mu()}function Oj(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function Bj(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function Fj(t){return t.routingFeatureAvailable}function Lj(t){return t.slug!=="home"}function _j(t){return!pg(t)}function $j(t){return t.worktreeMetadata}function zj(t){return{path:Sa(t.path),name:t.name,relativePath:t.relativePath}}function Wj(t){return!t.secondary}function Kj(t){return{item:t,score:0}}function Vj(t){return t.searchText}function Uj(t){return t.searchText}function Hj(t){return{item:t,score:0}}function Gj(t){return t.title||""}function qj(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Yj(t){return t.searchText}function Qj(t){return t.item}function Xj(t){return t.item}function Jj(t){return t.item}function Zj(t){return t.item}function e0(t){return t.item}function t0(t){return t.length?t[0].score:1/0}function s0(t,e){return t.score-e.score}function n0(t){return t.key}function r0(t){return s.jsxs(Br,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const _c=(t,e,n)=>Hn(Jr(t,e),n),o0=()=>{const t=Ze.c(73),{t:e}=St(),n=Ae(i0),r=Ae(a0),i=Ae(l0);let o,l,a,d,u,h,f,p,x,b,k,y;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==e){const X=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[Hn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${Hn(Zi("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${Hn(Zi("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];a=bs,k=n,y=r,l=ys,x="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let Y;t[16]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(O,{name:"command",className:"h-5 w-5"}),t[16]=Y):Y=t[16];let I;t[17]!==e?(I=e("helpDialog.title"),t[17]=e,t[18]=I):I=t[18];let P;t[19]!==I?(P=s.jsxs(Bs,{className:"flex items-center gap-2",children:[Y,I]}),t[19]=I,t[20]=P):P=t[20];let A;t[21]!==e?(A=e("helpDialog.description"),t[21]=e,t[22]=A):A=t[22];let q;t[23]!==A?(q=s.jsx(Fs,{children:A}),t[23]=A,t[24]=q):q=t[24],t[25]!==P||t[26]!==q?(b=s.jsxs(Us,{children:[P,q]}),t[25]=P,t[26]=q,t[27]=b):b=t[27],o=gn,h="flex-1 min-h-0 mt-3",f="pr-1",p=!0,d="space-y-4",u=X.map(K=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(K.categoryKey)}),s.jsx("div",{className:"space-y-1",children:K.items.map(te=>{const ae=te.id?Sg(te.id):void 0,re=te.descriptionKey??(ae?.customizable?ae.settingsLabelKey:void 0);if(!re||te.id&&!Jr(te.id,i))return null;const he=te.id?_c(te.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(te.keys)?te.keys:te.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[te.icon&&s.jsx(O,{name:te.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(re)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(he)?he:[he]).map((ce,Te)=>s.jsxs(c.Fragment,{children:[Te>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:ce})]},`${ce}-${Te}`))})]},te.id||re)})})]},K.categoryKey)),t[0]=n,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=h,t[10]=f,t[11]=p,t[12]=x,t[13]=b,t[14]=k,t[15]=y}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],h=t[9],f=t[10],p=t[11],x=t[12],b=t[13],k=t[14],y=t[15];let m;t[28]!==d||t[29]!==u?(m=s.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=m):m=t[30];let g;t[31]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(O,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[31]=g):g=t[31];let j;t[32]!==e?(j=e("helpDialog.proTips.title"),t[32]=e,t[33]=j):j=t[33];let S;t[34]!==j?(S=s.jsx("p",{className:"font-medium mb-1",children:j}),t[34]=j,t[35]=S):S=t[35];let w;t[36]!==i||t[37]!==e?(w=e("helpDialog.proTips.commandPalette",{shortcut:_c("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[36]=i,t[37]=e,t[38]=w):w=t[38];let C;t[39]!==w?(C=s.jsxs("li",{children:["• ",w]}),t[39]=w,t[40]=C):C=t[40];let v;t[41]!==e?(v=e("helpDialog.proTips.recentSessions"),t[41]=e,t[42]=v):v=t[42];let R;t[43]!==v?(R=s.jsxs("li",{children:["• ",v]}),t[43]=v,t[44]=R):R=t[44];let T;t[45]!==e?(T=e("helpDialog.proTips.leaderSequences"),t[45]=e,t[46]=T):T=t[46];let D;t[47]!==T?(D=s.jsxs("li",{children:["• ",T]}),t[47]=T,t[48]=D):D=t[48];let F;t[49]!==C||t[50]!==R||t[51]!==D?(F=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[C,R,D]}),t[49]=C,t[50]=R,t[51]=D,t[52]=F):F=t[52];let B;t[53]!==S||t[54]!==F?(B=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[g,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[S,F]})]})}),t[53]=S,t[54]=F,t[55]=B):B=t[55];let E;t[56]!==o||t[57]!==h||t[58]!==B||t[59]!==f||t[60]!==p||t[61]!==m?(E=s.jsxs(o,{outerClassName:h,className:f,disableHorizontal:p,children:[m,B]}),t[56]=o,t[57]=h,t[58]=B,t[59]=f,t[60]=p,t[61]=m,t[62]=E):E=t[62];let $;t[63]!==l||t[64]!==E||t[65]!==x||t[66]!==b?($=s.jsxs(l,{className:x,children:[b,E]}),t[63]=l,t[64]=E,t[65]=x,t[66]=b,t[67]=$):$=t[67];let L;return t[68]!==a||t[69]!==$||t[70]!==k||t[71]!==y?(L=s.jsx(a,{open:k,onOpenChange:y,children:$}),t[68]=a,t[69]=$,t[70]=k,t[71]=y,t[72]=L):L=t[72],L};function i0(t){return t.isHelpDialogOpen}function a0(t){return t.setHelpDialogOpen}function l0(t){return t.shortcutOverrides}const c0=()=>{const t=Ze.c(32),{t:e}=St(),n=Ae(d0),r=Ae(u0),i=Ae(f0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await Jn(i)).ok){ze.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}ze.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Bs,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==u?(h=s.jsx(Fs,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Us,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let x;t[16]!==l||t[17]!==p?(x=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p})}),t[16]=l,t[17]=p,t[18]=x):x=t[18];let b;t[19]!==i||t[20]!==e?(b=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=b):b=t[21];let k;t[22]!==b?(k=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:b}),t[22]=b,t[23]=k):k=t[23];let y;t[24]!==f||t[25]!==x||t[26]!==k?(y=s.jsxs(ys,{className:"max-w-2xl",children:[f,x,k]}),t[24]=f,t[25]=x,t[26]=k,t[27]=y):y=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==y?(m=s.jsx(bs,{open:n,onOpenChange:r,children:y}),t[28]=n,t[29]=r,t[30]=y,t[31]=m):m=t[31],m};function d0(t){return t.isOpenCodeStatusDialogOpen}function u0(t){return t.setOpenCodeStatusDialogOpen}function f0(t){return t.openCodeStatusText}const m0=t=>{const e=Ze.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const b=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(b)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const b=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",b),()=>window.removeEventListener("openchamber:sidebar-session-search",b)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let p,x;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const b=k=>{l.current&&(l.current.contains(k.target)||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},x=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=x):(p=e[14],x=e[15]),c.useEffect(p,x)},h0=t=>{const e=Ze.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(p0)),u=[];a.forEach(p=>{const x=d.get(p);x&&(u.push(x),d.delete(p))});const h=[],f=[];return l.forEach(p=>{d.has(p.id)&&(p.isArchivedBucket?f.push(p):h.push(p))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function p0(t){return[t.id,t]}const go="oc.sessions.projectCollapse",$c="oc.sessions.groupOrder",zc="oc.sessions.groupCollapse",Wc=t=>{if(!t)return new Set;try{const e=Ja(Xn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},g0=t=>{if(!t)return new Map;try{const e=af(Xn(),Ja(Xn())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},x0=t=>{const e=Ze.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Mo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Wc(o.getItem(go)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Wc(o.getItem(zc)),e[2]=u):u=e[2];const[h,f]=c.useState(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>g0(o.getItem($c)),e[3]=p):p=e[3];const[x,b]=c.useState(p),k=c.useRef(0),y=c.useRef(!1),m=c.useRef(!1),g=c.useRef(null),j=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const pe=j.current;if(j.current=null,g.current=null,!pe)return;const{projects:Ne}=zt.getState(),U=Ne.map(Z=>({...Z,sidebarCollapsed:pe.has(Z.id)}));lr({projects:U}).catch(b0)},e[4]=n,e[5]=S):S=e[5];const w=S;let C;e[6]!==w||e[7]!==n?(C=pe=>{!globalThis.window||n||(j.current=pe,g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{w()},700))},e[6]=w,e[7]=n,e[8]=C):C=e[8];const v=C;let R,T;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=()=>()=>{globalThis.window&&g.current!==null&&window.clearTimeout(g.current),g.current=null,j.current=null},T=[],e[9]=R,e[10]=T):(R=e[9],T=e[10]),c.useEffect(R,T);let D,F;e[11]!==x?(F=()=>{if(m.current)try{o.setItem($c,JSON.stringify(Object.fromEntries(x.entries())))}catch{}},D=[x,o],e[11]=x,e[12]=D,e[13]=F):(D=e[12],F=e[13]),c.useEffect(F,D);let B,E;e[14]!==h?(B=()=>{if(y.current)try{o.setItem(zc,JSON.stringify(Array.from(h)))}catch{}},E=[h,o],e[14]=h,e[15]=B,e[16]=E):(B=e[15],E=e[16]),c.useEffect(B,E);let $;e[17]!==r||e[18]!==v?($=()=>{k.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const pe=new Set(r.map(y0));try{o.setItem(go,JSON.stringify(Array.from(pe)))}catch{}return v(pe),pe})},e[17]=r,e[18]=v,e[19]=$):$=e[19];const L=$;let X;e[20]!==v?(X=()=>{k.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const pe=new Set;try{o.setItem(go,JSON.stringify([]))}catch{}return v(pe),pe})},e[20]=v,e[21]=X):X=e[21];const Y=X;let I;e[22]!==v?(I=pe=>{k.current=Date.now()+150,d(Ne=>{const U=new Set(Ne);U.has(pe)?U.delete(pe):U.add(pe);try{o.setItem(go,JSON.stringify(Array.from(U)))}catch{}return v(U),U})},e[22]=v,e[23]=I):I=e[23];const P=I;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=pe=>{y.current=!0,f(Ne=>{const U=new Set(Ne);return U.has(pe)?U.delete(pe):U.add(pe),U})},e[24]=A):A=e[24];const q=A;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=pe=>{m.current=!0,b(pe)},e[25]=K):K=e[25];const te=K,{getOrderedGroups:ae}=h0(x);let re;e[26]!==h||e[27]!==a||e[28]!==x?(re={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:x},e[26]=h,e[27]=a,e[28]=x,e[29]=re):re=e[29];const he=re;let ce;e[30]!==L||e[31]!==Y||e[32]!==ae||e[33]!==v||e[34]!==P?(ce={setCollapsedProjects:d,toggleProject:P,collapseAllProjects:L,expandAllProjects:Y,scheduleCollapsedProjectsPersist:v,setCollapsedGroups:f,toggleGroup:q,setGroupOrderByProject:te,getOrderedGroups:ae},e[30]=L,e[31]=Y,e[32]=ae,e[33]=v,e[34]=P,e[35]=ce):ce=e[35];const Te=ce;let ve;return e[36]!==Te||e[37]!==he?(ve={state:he,actions:Te},e[36]=Te,e[37]=he,e[38]=ve):ve=e[38],ve};function b0(){}function y0(t){return t.id}const w0=5*6e4,v0=t=>{const e=Ze.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=nn(),u=pn(S0);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{ea(()=>u(C.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let p,x;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(v=>{C.set(v.id,i.get(v.normalizedPath)?.isGitRepo??null)}),o(C)},x=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=x):(p=e[11],x=e[12]),c.useEffect(p,x);let b;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=v=>{const R=i.get(v.normalizedPath)?.branch??"";return`${v.id}:${R}`},e[16]=i,e[17]=C):C=e[17],b=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=b}else b=e[15];const k=b;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const m=c.useRef(y);let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[19]=g):g=e[19];const j=c.useRef(g);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let C=!1;const v=setTimeout(()=>{(async()=>{const T=new Set(n.map(j0));for(const L of m.current.keys())T.has(L)||(m.current.delete(L),j.current.delete(L));const D=Date.now(),F=n.filter(L=>{const X=i.get(L.normalizedPath);if(X?.isGitRepo===!1)return m.current.delete(L.id),j.current.delete(L.id),!1;if(X?.isGitRepo!==!0||X.branch===null)return!1;const Y=X.branch.trim(),I=`${L.normalizedPath}\0${Y}`,P=m.current.get(L.id);if(P===I){const A=j.current.get(L.id);return A&&(A.at=D),!1}return!(P!==void 0&&D-(j.current.get(L.id)?.at??0)<w0)});if(F.length===0)return;const B=await jg(F,2,async L=>{const X=i.get(L.normalizedPath)?.branch?.trim()??"",Y=`${L.normalizedPath}\0${X}`,I=await ea(()=>$a(L.normalizedPath,X?{knownBranch:X}:void 0)).catch(k0);return{id:L.id,inputKey:Y,branch:I}});if(C)return;const E=B.filter(C0);if(E.length===0)return;const $=Date.now();l(L=>{const X=new Map(L);return E.forEach(Y=>{const{id:I,branch:P}=Y;P&&X.set(I,P)}),X}),E.forEach(L=>{const{id:X,inputKey:Y,branch:I}=L;m.current.set(X,Y),I&&j.current.set(X,{branch:I,at:$})})})()},150);return()=>{C=!0,clearTimeout(v)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let w;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==k||e[29]!==l?(w=[a,n,k,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=k,e[29]=l,e[30]=w):w=e[30],c.useEffect(S,w)};function S0(t){return t.ensureStatus}function j0(t){return t.id}function k0(){return null}function C0(t){return t.branch}const N0=t=>{const e=Ze.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Wh,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(ys,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(gn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(bs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function A0(t){const e=Ze.c(199),{t:n}=St(),r=Ou(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:h,onOpenArchive:f,headerActionIconClass:p,headerActionButtonClass:x,isSessionSearchOpen:b,setIsSessionSearchOpen:k,sessionSearchInputRef:y,sessionSearchQuery:m,setSessionSearchQuery:g,hasSessionSearchQuery:j,searchMatchCount:S,collapseAllProjects:w,expandAllProjects:C}=t,v=ss(z0),R=ss($0),T=as(_0),D=as(L0),F=as(F0),B=as(B0),E=as(O0),$=as(M0),L=as(R0),X=as(E0),Y=as(T0),I=as(I0),P=o&&Y==="single",A=o&&L==="timeline";if(i)return null;let q;e[0]!==x?(q=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=x,e[1]=q):q=e[1];let K;e[2]!==n?(K=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=K):K=e[3];let te;e[4]!==p?(te=s.jsx(O,{name:"folder-add",className:p}),e[4]=p,e[5]=te):te=e[5];let ae;e[6]!==a||e[7]!==q||e[8]!==K||e[9]!==te?(ae=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:q,"aria-label":K,children:te})}),e[6]=a,e[7]=q,e[8]=K,e[9]=te,e[10]=ae):ae=e[10];let re;e[11]!==n?(re=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=re):re=e[12];let he;e[13]!==re?(he=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:re})}),e[13]=re,e[14]=he):he=e[14];let ce;e[15]!==ae||e[16]!==he?(ce=s.jsxs(bt,{children:[ae,he]}),e[15]=ae,e[16]=he,e[17]=ce):ce=e[17];let Te;e[18]!==x?(Te=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=x,e[19]=Te):Te=e[19];let ve;e[20]!==n?(ve=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=ve):ve=e[21];let pe;e[22]!==p?(pe=s.jsx(O,{name:"calendar-schedule",className:p}),e[22]=p,e[23]=pe):pe=e[23];let Ne;e[24]!==d||e[25]!==Te||e[26]!==ve||e[27]!==pe?(Ne=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:Te,"aria-label":ve,children:pe})}),e[24]=d,e[25]=Te,e[26]=ve,e[27]=pe,e[28]=Ne):Ne=e[28];let U;e[29]!==n?(U=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=U):U=e[30];let Z;e[31]!==U?(Z=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:U})}),e[31]=U,e[32]=Z):Z=e[32];let de;e[33]!==Ne||e[34]!==Z?(de=s.jsxs(bt,{children:[Ne,Z]}),e[33]=Ne,e[34]=Z,e[35]=de):de=e[35];let ye;e[36]!==x?(ye=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=x,e[37]=ye):ye=e[37];let H;e[38]!==n?(H=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=H):H=e[39];const je=!h;let Ee;e[40]!==p?(Ee=s.jsx(Ng,{className:p}),e[40]=p,e[41]=Ee):Ee=e[41];let ge;e[42]!==u||e[43]!==ye||e[44]!==H||e[45]!==je||e[46]!==Ee?(ge=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:ye,"aria-label":H,disabled:je,children:Ee})}),e[42]=u,e[43]=ye,e[44]=H,e[45]=je,e[46]=Ee,e[47]=ge):ge=e[47];let ne;e[48]!==n?(ne=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=ne):ne=e[49];let be;e[50]!==ne?(be=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[50]=ne,e[51]=be):be=e[51];let G;e[52]!==ge||e[53]!==be?(G=s.jsxs(bt,{children:[ge,be]}),e[52]=ge,e[53]=be,e[54]=G):G=e[54];let z;e[55]!==x?(z=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=x,e[56]=z):z=e[56];let J;e[57]!==n?(J=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=J):J=e[58];let ue;e[59]!==p?(ue=s.jsx(O,{name:"archive",className:p}),e[59]=p,e[60]=ue):ue=e[60];let le;e[61]!==f||e[62]!==z||e[63]!==J||e[64]!==ue?(le=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:z,"aria-label":J,children:ue})}),e[61]=f,e[62]=z,e[63]=J,e[64]=ue,e[65]=le):le=e[65];let W;e[66]!==n?(W=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=W):W=e[67];let M;e[68]!==W?(M=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W})}),e[68]=W,e[69]=M):M=e[69];let _;e[70]!==le||e[71]!==M?(_=s.jsxs(bt,{children:[le,M]}),e[70]=le,e[71]=M,e[72]=_):_=e[72];let ee;e[73]!==r||e[74]!==p||e[75]!==n?(ee=r.length>0&&s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(O,{name:"apps",className:p})})}),s.jsxs(Ds,{align:"start",children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(D0)]})]}),e[73]=r,e[74]=p,e[75]=n,e[76]=ee):ee=e[76];let oe;e[77]!==de||e[78]!==G||e[79]!==_||e[80]!==ee||e[81]!==ce?(oe=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ce,de,G,_,ee]}),e[77]=de,e[78]=G,e[79]=_,e[80]=ee,e[81]=ce,e[82]=oe):oe=e[82];let fe;e[83]!==k?(fe=()=>k(P0),e[83]=k,e[84]=fe):fe=e[84];let ie;e[85]!==x?(ie=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=x,e[86]=ie):ie=e[86];let Le;e[87]!==n?(Le=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=Le):Le=e[88];let $e;e[89]!==p?($e=s.jsx(O,{name:"search",className:p}),e[89]=p,e[90]=$e):$e=e[90];let Pe;e[91]!==b||e[92]!==fe||e[93]!==ie||e[94]!==Le||e[95]!==$e?(Pe=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:fe,className:ie,"aria-label":Le,"aria-expanded":b,children:$e})}),e[91]=b,e[92]=fe,e[93]=ie,e[94]=Le,e[95]=$e,e[96]=Pe):Pe=e[96];let Oe;e[97]!==n?(Oe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=Oe):Oe=e[98];let Q;e[99]!==Oe?(Q=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[99]=Oe,e[100]=Q):Q=e[100];let Ce;e[101]!==Pe||e[102]!==Q?(Ce=s.jsxs(bt,{children:[Pe,Q]}),e[101]=Pe,e[102]=Q,e[103]=Ce):Ce=e[103];const Se=v&&"bg-interactive-hover text-primary";let Ke;e[104]!==x||e[105]!==Se?(Ke=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent",Se),e[104]=x,e[105]=Se,e[106]=Ke):Ke=e[106];let et;e[107]!==v||e[108]!==n?(et=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=v,e[108]=n,e[109]=et):et=e[109];let it;e[110]!==p?(it=s.jsx(O,{name:"checkbox-multiple",className:p}),e[110]=p,e[111]=it):it=e[111];let rt;e[112]!==v||e[113]!==Ke||e[114]!==et||e[115]!==it||e[116]!==R?(rt=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:R,className:Ke,"aria-label":et,"aria-pressed":v,children:it})}),e[112]=v,e[113]=Ke,e[114]=et,e[115]=it,e[116]=R,e[117]=rt):rt=e[117];let pt;e[118]!==v||e[119]!==n?(pt=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=v,e[119]=n,e[120]=pt):pt=e[120];let ht;e[121]!==pt?(ht=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:pt})}),e[121]=pt,e[122]=ht):ht=e[122];let tt;e[123]!==rt||e[124]!==ht?(tt=s.jsxs(bt,{children:[rt,ht]}),e[123]=rt,e[124]=ht,e[125]=tt):tt=e[125];let At;e[126]!==x?(At=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=x,e[127]=At):At=e[127];let jt;e[128]!==n?(jt=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=jt):jt=e[129];let we;e[130]!==p?(we=s.jsx(O,{name:"equalizer-2",className:p}),e[130]=p,e[131]=we):we=e[131];let Xe;e[132]!==At||e[133]!==jt||e[134]!==we?(Xe=s.jsx(yt,{asChild:!0,children:s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:At,"aria-label":jt,children:we})})}),e[132]=At,e[133]=jt,e[134]=we,e[135]=Xe):Xe=e[135];let mt;e[136]!==n?(mt=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=mt):mt=e[137];let qe;e[138]!==mt?(qe=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:mt})}),e[138]=mt,e[139]=qe):qe=e[139];let ft;e[140]!==Xe||e[141]!==qe?(ft=s.jsxs(bt,{children:[Xe,qe]}),e[140]=Xe,e[141]=qe,e[142]=ft):ft=e[142];let se;e[143]!==X||e[144]!==o||e[145]!==L||e[146]!==n||e[147]!==A?(se=o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{X(ot),lr({sidebarViewMode:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),L===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),A?null:s.jsx(gs,{})]}):null,e[143]=X,e[144]=o,e[145]=L,e[146]=n,e[147]=A,e[148]=se):se=e[148];let me;e[149]!==Y||e[150]!==F||e[151]!==I||e[152]!==B||e[153]!==$||e[154]!==o||e[155]!==n||e[156]!==A||e[157]!==E?(me=A?null:s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{B(ot),lr({sidebarProjectSortOrder:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),F===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{$(ot),lr({sidebarWorktreeSortOrder:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),E===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{})]}):null,o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{I(ot),lr({sidebarProjectDisplayMode:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),Y===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{})]}):null]}),e[149]=Y,e[150]=F,e[151]=I,e[152]=B,e[153]=$,e[154]=o,e[155]=n,e[156]=A,e[157]=E,e[158]=me):me=e[158];let Ie;e[159]!==P||e[160]!==l||e[161]!==T||e[162]!==n||e[163]!==A||e[164]!==D?(Ie=!A&&l&&!P?s.jsxs(_t,{onClick:()=>{D(),lr({sidebarShowRecentSection:!T})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),T?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[159]=P,e[160]=l,e[161]=T,e[162]=n,e[163]=A,e[164]=D,e[165]=Ie):Ie=e[165];let We;e[166]!==w||e[167]!==C||e[168]!==P||e[169]!==n||e[170]!==A?(We=!A&&!P?s.jsxs(s.Fragment,{children:[s.jsx(gs,{}),s.jsxs(_t,{onClick:w,className:"flex items-center gap-2",children:[s.jsx(O,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(_t,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(O,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[166]=w,e[167]=C,e[168]=P,e[169]=n,e[170]=A,e[171]=We):We=e[171];let V;e[172]!==se||e[173]!==me||e[174]!==Ie||e[175]!==We?(V=s.jsxs(Ds,{align:"end",className:"min-w-[180px]",children:[se,me,Ie,We]}),e[172]=se,e[173]=me,e[174]=Ie,e[175]=We,e[176]=V):V=e[176];let Fe;e[177]!==ft||e[178]!==V?(Fe=s.jsxs(Is,{children:[ft,V]}),e[177]=ft,e[178]=V,e[179]=Fe):Fe=e[179];let Ye;e[180]!==Ce||e[181]!==tt||e[182]!==Fe?(Ye=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ce,tt,Fe]}),e[180]=Ce,e[181]=tt,e[182]=Fe,e[183]=Ye):Ye=e[183];let Qe;e[184]!==oe||e[185]!==Ye?(Qe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[oe,Ye]}),e[184]=oe,e[185]=Ye,e[186]=Qe):Qe=e[186];let xe;e[187]!==j||e[188]!==b||e[189]!==S||e[190]!==y||e[191]!==m||e[192]!==k||e[193]!==g||e[194]!==n?(xe=b?s.jsx("div",{className:"pb-1",children:s.jsx(Zd,{inputRef:y,value:m,onSearch:g,onClose:()=>k(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:j?S===1?n("sessions.sidebar.header.search.matchCountSingle",{count:S}):n("sessions.sidebar.header.search.matchCountPlural",{count:S}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[187]=j,e[188]=b,e[189]=S,e[190]=y,e[191]=m,e[192]=k,e[193]=g,e[194]=n,e[195]=xe):xe=e[195];let st;return e[196]!==Qe||e[197]!==xe?(st=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Qe,xe]})}),e[196]=Qe,e[197]=xe,e[198]=st):st=e[198],st}function P0(t){return!t}function D0(t){return s.jsxs(_t,{onSelect:()=>Ae.getState().setOpenGuestPage(t.id),children:[s.jsx(Xr,{icon:Cg(t.icon),iconSrc:kg(t.id,t.icon,zd().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function I0(t){return t.setProjectDisplayMode}function T0(t){return t.projectDisplayMode}function E0(t){return t.setSidebarViewMode}function R0(t){return t.sidebarViewMode}function M0(t){return t.setWorktreeSortOrder}function O0(t){return t.worktreeSortOrder}function B0(t){return t.setProjectSortOrder}function F0(t){return t.projectSortOrder}function L0(t){return t.toggleRecentSection}function _0(t){return t.showRecentSection}function $0(t){return t.toggleMode}function z0(t){return t.enabled}const xo="inline-flex h-8 w-8 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-ring";function W0(t){const e=Ze.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,h=d===void 0?!0:d,{t:f}=St();if(!u&&!h)return null;let p;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(p=u?s.jsxs(s.Fragment,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:xo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(O,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:xo,"aria-label":f("usageStats.openAction"),children:s.jsx(O,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:xo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(O,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:xo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(O,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=p):p=e[6];let x;e[7]!==l||e[8]!==h||e[9]!==f?(x=h?s.jsx(ut,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=h,e[9]=f,e[10]=x):x=e[10];let b;return e[11]!==p||e[12]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[p,x]}),e[11]=p,e[12]=x,e[13]=b):b=e[13],b}const K0=t=>{for(const e of t.sessions.values())if(e.tabs.some(Kd))return!0;return!1},V0=()=>{const t=Ze.c(4),{terminal:e}=nn(),n=Rt(K0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=U0,l=H0;if(n)return Vi(e,"",l,o);let a=G0;return a=Vi(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function U0(t){const e=Rt.getState(),n=Kh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function H0(){return new Map(Rt.getState().actionMutationRevisions)}function G0(){}const q0=t=>{const e=Ze.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,p=r===void 0?!0:r;let x,b;e[0]!==f||e[1]!==h||e[2]!==p||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(x=()=>{!p||o||!l||a||n.forEach(k=>{if(d.has(k.normalizedPath))return;const y=Bu(k.normalizedPath),m=i.archivedSessionsByProject.get(k.id)??[],g=u[y]??[],j=new Map(g.map(Y0));m.forEach(S=>{const w=Ag(S,k.normalizedPath),C=w.toLowerCase();let v=j.get(C);v||(v=h(y,w),j.set(C,v)),v.sessionIds.includes(S.id)||f(y,v.id,S.id)})})},b=[n,p,i,o,l,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=p,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=x,e[11]=b):(x=e[10],b=e[11]),c.useEffect(x,b)};function Y0(t){return[t.name.toLowerCase(),t]}function Q0({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const X0=t=>{const e=Ze.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let x,b;if(e[0]!==n){b=new Map,x=new Map;const C=(v,R,T,D)=>{b.has(v)||b.set(v,new Map);const F=b.get(v);D.forEach(B=>{const E=xt(B.worktree?.path??B.session.directory??T??R);F.set(B.session.id,{directory:E}),x.has(v)||x.set(v,{id:B.session.id,directory:E}),B.children.length>0&&C(v,R,E,B.children)})};n.forEach(v=>{v.groups.forEach(R=>{C(v.project.id,v.project.normalizedPath,R.directory,R.sessions)})}),e[0]=n,e[1]=x,e[2]=b}else x=e[1],b=e[2];let k;e[3]!==x||e[4]!==b?(k={metaByProject:b,firstSessionByProject:x},e[3]=x,e[4]=b,e[5]=k):k=e[5];const y=k,m=c.useRef(null);let g,j;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==y||e[16]!==o||e[17]!==p?(g=()=>{if(!r||u||Ae.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(D=>D.project.id===r);if(!C)return;const v=y.metaByProject.get(r);if(l&&v&&v.has(l)){m.current=r,o(D=>{if(D.get(r)===l)return D;const F=new Map(D);return F.set(r,l),F});return}const R=Q0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:v,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(R.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,R.kind==="open-draft"){h&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(R.kind!=="select-session")return;const T=v?.get(R.sessionId)?.directory??null;d(R.sessionId,T)},j=[r,i,l,a,d,u,h,f,n,y,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=y,e[16]=o,e[17]=p,e[18]=g,e[19]=j):(g=e[18],j=e[19]),c.useLayoutEffect(g,j);let S,w;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(S=()=>{if(!r||!l)return;const C=y.metaByProject.get(r);!C||!C.has(l)||o(v=>{if(v.get(r)===l)return v;const R=new Map(v);return R.set(r,l),R})},w=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=S,e[25]=w):(S=e[24],w=e[25]),c.useEffect(S,w)},J0=t=>{const e=Ze.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=nt(Z0),a=nt(e2);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,p]=c.useState(h);let x;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(x={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=x):x=e[15],X0(x);let b,k;return e[16]!==f||e[17]!==i?(b=()=>{i(f)},k=[f,i],e[16]=f,e[17]=i,e[18]=b,e[19]=k):(b=e[18],k=e[19]),c.useEffect(b,k),null};function Z0(t){return t.currentSessionId}function e2(t){return!!t.newSessionDraft?.open}const t2=t=>{const e=Ze.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},_n=(t,e)=>`${t}\0${e}`,Kn=(t,e)=>t??Ha(e)??xt(e??null),qr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??xt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},al=t=>t.startsWith("__archived__:"),s2=(t,e)=>t.map(n=>{const r=xt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
879
879
  `),n2=[],r2=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:x,foldersMap:b,standaloneGroups:k}=t,y=c.useRef(new Map),m=c.useMemo(()=>{const T=y.current,D=new Map;let F=0,B=0;const E=(L,X)=>L.length===X.length&&L.every((Y,I)=>Y===X[I]),$=e.map(L=>{const X=n(L.id),Y=r(L.id),I=i.get(L.normalizedPath)??n2,P=o.has(L.id)?!!o.get(L.id):d,A=l.get(L.id)??null,q=s2(I,a),K=T.get(L.id);if(K&&K.project===L&&E(K.activeSessions,X)&&E(K.archivedSessions,Y)&&K.availableWorktrees===I&&K.rootBranch===A&&K.worktreeBranchesKey===q&&K.isRepo===P&&K.buildGroupedSessions===u)return F+=1,D.set(L.id,K),K.section;if(B+=1,K){const he=K.project!==L?"project":E(K.activeSessions,X)?E(K.archivedSessions,Y)?K.availableWorktrees!==I?"worktrees":K.rootBranch!==A?"branch":K.worktreeBranchesKey!==q?"worktreeBranches":K.isRepo!==P?"repo":"builder":"archived":"sessions";js(`ui.sidebar.project_section.rebuilt_reason.${he}`)}const te=Fu([...X,...Y]),ae=u(te,L.normalizedPath,I,A,P),re={project:L,groups:ae};return D.set(L.id,{project:L,activeSessions:X,archivedSessions:Y,availableWorktrees:I,rootBranch:A,worktreeBranchesKey:q,isRepo:P,buildGroupedSessions:u,section:re}),re});return y.current=D,F>0&&js("ui.sidebar.project_section.reused",F),B>0&&js("ui.sidebar.project_section.rebuilt",B),$},[e,n,r,i,o,d,u,l,a]),g=c.useMemo(()=>m,[m]),j=c.useMemo(()=>{const T=new WeakMap;if(!h)return T;const D=f.trim().toLowerCase(),F=D.startsWith("ses_"),B=$=>$.reduce((L,X)=>L+(!F||X.session.id.toLowerCase()===D?1:0)+B(X.children),0),E=$=>{const L=p($.sessions,f),X=B(L),Y=!F&&Bo([x($)],f),I=qr($).flatMap(({scopeKey:A})=>b[A]??[]),P=F?0:I.filter(A=>Bo([A.name],f)).length;T.set($,{filteredNodes:L,matchedSessionCount:X,folderNameMatchCount:P,groupMatches:Y,hasMatch:Y||X>0||P>0})};return g.forEach($=>{$.groups.forEach(E)}),k.forEach(E),T},[h,g,k,p,f,x,b]),S=c.useMemo(()=>h?g.map(T=>({...T,groups:T.groups.filter(D=>j.get(D)?.hasMatch===!0)})).filter(T=>T.groups.length>0):g,[h,g,j]),w=h?S:g,C=c.useRef(new WeakMap),v=c.useMemo(()=>{const T=C.current;return w.map(D=>{const F=T.get(D);if(F&&F.query===f)return F.section;const B=D.groups.filter(P=>!P.isArchivedBucket),E=D.groups.filter(P=>P.isArchivedBucket),$=B.flatMap(P=>h?j.get(P)?.filteredNodes??[]:P.sessions),L=B.map(P=>({scopeKey:P.folderScopeKey??xt(P.directory??null),directory:P.directory??null})).filter(P=>!!P.scopeKey),X=B.find(P=>P.isMain)??null,Y={id:"flat",label:X?.label??"",branch:X?.branch??null,description:X?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:X?.directory??D.project.normalizedPath,folderScopeKey:X?.folderScopeKey??D.project.normalizedPath,folderScopes:L,sessions:$};if(h){const P=B.map(A=>j.get(A)).filter(A=>!!A);j.set(Y,{filteredNodes:$,matchedSessionCount:P.reduce((A,q)=>A+q.matchedSessionCount,0),folderNameMatchCount:P.reduce((A,q)=>A+q.folderNameMatchCount,0),groupMatches:P.some(A=>A.groupMatches),hasMatch:P.some(A=>A.hasMatch)})}const I={project:D.project,groups:[Y,...E]};return T.set(D,{query:f,section:I}),I})},[j,h,f,w]),R=c.useMemo(()=>{if(!h)return 0;const T=(F,B)=>{const E=j.get(B);if(!E)return F;const $=E.folderNameMatchCount+(E.groupMatches?1:0);return F+E.matchedSessionCount+$},D=w.reduce((F,B)=>B.groups.reduce(T,F),0);return k.reduce(T,D)},[h,w,k,j]);return{projectSections:m,visibleProjectSections:g,groupSearchDataByGroup:j,searchableProjectSections:S,sectionsForRender:w,flatSectionsForRender:v,searchMatchCount:R}},o2=180,Kc=150,i2=2,a2=8,Vc=[-1,1],Bi=t=>`${t.directory}
880
880
  ${t.sessionId}`,l2=t=>t?.directory?.trim()||null,c2=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>kn(),[]),h=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(x=>window.clearTimeout(x)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<i2&&l.current.length>0;){const x=l.current.shift();if(!x)break;if(x.generation!==d.current||nt.getState().currentSessionId===x.sessionId||ta(x.sessionId,x.directory).renderable)continue;const k=Bi(x);a.current.add(k),i({directory:x.directory,sessionID:x.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(k),f()})}},[t,u,i]),p=c.useCallback(x=>{const b=x?.id,k=l2(x);if(!t||u||!b||!k||b===e)return;const y={sessionId:b,directory:k,generation:d.current},m=Bi(y);if(ta(b,k).renderable||a.current.has(m)||l.current.some(S=>Bi(S)===m))return;const g=o.current.get(m);g!==void 0&&window.clearTimeout(g);const j=window.setTimeout(()=>{if(o.current.delete(m),y.generation!==d.current)return;const S=l.current;S.length>=a2&&S.shift(),S.push(y),f()},o2);o.current.set(m,j)},[e,t,u,f]);c.useEffect(()=>{h()},[h,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const x=window.setTimeout(()=>{const b=n.findIndex(k=>k.id===e);if(!(b<0))for(const k of Vc)p(n[b+k])},Kc);return()=>window.clearTimeout(x)},[e,t,u,p,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const x=window.setTimeout(()=>{const b=r.findIndex(k=>k.id===e);if(!(b<0))for(const k of Vc)p(r[b+k])},Kc);return()=>window.clearTimeout(x)},[e,t,u,r,p]),c.useEffect(()=>h,[h])},d2=t=>{const e=Ze.c(3),n=nt(u2);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],c2(r),null};function u2(t){return t.currentSessionId}const f2=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},ll=t=>{const e=Ze.c(15),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=f2(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const d=a;let u;e[6]!==o||e[7]!==d.active?(u=k=>{if(!o)return null;for(const y of d.active){const m=k.statusById.get(y)?.status.type;if(m==="busy"||m==="retry")return"active"}return null},e[6]=o,e[7]=d.active,e[8]=u):u=e[8];const h=Zo(u);let f;e[9]!==o||e[10]!==d.unread?(f=k=>{if(!o)return null;for(const y of d.unread)if((k.index.session.unseenCount[y]??0)>0)return"unread";return null},e[9]=o,e[10]=d.unread,e[11]=f):f=e[11];const p=Ga(f);let x;return e[12]!==o||e[13]!==d.active?(x=k=>{if(!o)return null;let y=null;for(const m of d.active){const g=k.bySession.get(m);if(g){if(g.permissions.length>0)return"permission";g.forms.length>0&&(y="form")}}return y},e[12]=o,e[13]=d.active,e[14]=x):x=e[14],qa(x)??h??p};function Gf(t){const e=Ze.c(19),{state:n,className:r}=t,{t:i}=St();if(n==="permission"||n==="form"){let u;e[0]!==n||e[1]!==i?(u=i(n==="permission"?"sessions.sidebar.session.status.permissionRequired":"sessions.sidebar.session.status.questionPending"),e[0]=n,e[1]=i,e[2]=u):u=e[2];const h=u,f=n==="permission"?"text-destructive":"text-status-info";let p;e[3]!==r||e[4]!==f?(p=Me("inline-flex shrink-0 items-center",f,r),e[3]=r,e[4]=f,e[5]=p):p=e[5];const x=n==="permission"?"shield":"question";let b;e[6]!==x?(b=s.jsx(O,{name:x,className:"h-3 w-3"}),e[6]=x,e[7]=b):b=e[7];let k;return e[8]!==h||e[9]!==p||e[10]!==b?(k=s.jsx("span",{className:p,"aria-label":h,title:h,children:b}),e[8]=h,e[9]=p,e[10]=b,e[11]=k):k=e[11],k}let o;e[12]!==n||e[13]!==i?(o=i(n==="active"?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[12]=n,e[13]=i,e[14]=o):o=e[14];const l=o,a=n==="active"?"running":"unread";let d;return e[15]!==r||e[16]!==l||e[17]!==a?(d=s.jsx(Oa,{state:a,label:l,className:r}),e[15]=r,e[16]=l,e[17]=a,e[18]=d):d=e[18],d}const m2=t=>{const e=Ze.c(5),{nodes:n,includeUnreadSubtasks:r}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=ll(i);if(!o)return null;let l;return e[3]!==o?(l=s.jsx(Gf,{state:o}),e[3]=o,e[4]=l):l=e[4],l},h2=t=>{const e=Ze.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:h,children:f,renderBody:p,mobileVariant:x,alwaysShowActions:b,isRenaming:k,renameDraft:y,onRenameDraftChange:m,onRenameSave:g,onRenameCancel:j,droppableRef:S,isDropTarget:w,onNewSession:C,depth:v,hideActions:R,archivedBucket:T}=t,D=a===void 0?null:a,F=p===void 0?!0:p,E=b===void 0?x===void 0?!1:x:b,$=k===void 0?!1:k,L=y===void 0?"":y,X=w===void 0?!1:w,Y=R===void 0?!1:R,I=T===void 0?!1:T,{t:P}=St(),[A,q]=c.useState(!1),[K,te]=c.useState(""),ae=c.useRef(null),re=$||A,he=$?L:K;let ce;e[0]!==n.name?(ce=()=>{te(n.name),q(!0)},e[0]=n.name,e[1]=ce):ce=e[1];const Te=ce;let ve;e[2]!==he||e[3]!==n.name||e[4]!==$||e[5]!==u||e[6]!==g?(ve=()=>{const Pe=he.trim();Pe&&Pe!==n.name&&u(Pe),$&&g&&g(),q(!1),te("")},e[2]=he,e[3]=n.name,e[4]=$,e[5]=u,e[6]=g,e[7]=ve):ve=e[7];const pe=ve;let Ne;e[8]!==$||e[9]!==j?(Ne=()=>{$&&j&&j(),q(!1),te("")},e[8]=$,e[9]=j,e[10]=Ne):Ne=e[10];const U=Ne;let Z;e[11]!==$||e[12]!==m?(Z=Pe=>{$&&m?m(Pe):te(Pe)},e[11]=$,e[12]=m,e[13]=Z):Z=e[13];const de=Z;let ye,H;e[14]!==$?(ye=()=>{if(!$)return;const Pe=()=>{const Ce=ae.current;Ce&&(Ce.focus(),Ce.select())},Oe=requestAnimationFrame(Pe),Q=window.setTimeout(Pe,0);return()=>{cancelAnimationFrame(Oe),window.clearTimeout(Q)}},H=[$],e[14]=$,e[15]=ye,e[16]=H):(ye=e[15],H=e[16]),c.useEffect(ye,H);const je=l?"folder":"folder-open",Ee=X&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ge;e[17]!==Ee?(ge=Me("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Ee),e[17]=Ee,e[18]=ge):ge=e[18];let ne;e[19]!==d||e[20]!==re?(ne=re?void 0:Pe=>{Pe.currentTarget.blur(),d()},e[19]=d,e[20]=re,e[21]=ne):ne=e[21];const be=re?void 0:"button",G=re?void 0:0;let z;e[22]!==d||e[23]!==re?(z=re?void 0:Pe=>{(Pe.key==="Enter"||Pe.key===" ")&&(Pe.preventDefault(),d())},e[22]=d,e[23]=re,e[24]=z):z=e[24];let J;e[25]!==n.name||e[26]!==l||e[27]!==P?(J=l?P("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):P("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=P,e[28]=J):J=e[28];const ue=I?E?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":E?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let le;e[29]!==ue?(le=Me("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",ue),e[29]=ue,e[30]=le):le=e[30];const W=X?"text-primary":"text-muted-foreground";let M;e[31]!==W?(M=Me("h-3.5 w-3.5 flex-shrink-0",W),e[31]=W,e[32]=M):M=e[32];let _;e[33]!==je||e[34]!==M?(_=s.jsx(O,{name:je,className:M}),e[33]=je,e[34]=M,e[35]=_):_=e[35];let ee;e[36]!==D||e[37]!==r||e[38]!==he||e[39]!==n.name||e[40]!==U||e[41]!==de||e[42]!==pe||e[43]!==l||e[44]!==X||e[45]!==re||e[46]!==i||e[47]!==P?(ee=re?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:p2,onMouseDown:g2,onSubmit:Pe=>{Pe.preventDefault(),pe()},children:[s.jsx("input",{ref:ae,value:he,onChange:Pe=>de(Pe.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:P("sessions.sidebar.folderItem.namePlaceholder"),onClick:x2,onPointerDown:b2,onMouseDown:y2,onKeyDown:Pe=>{if(Pe.key==="Escape"){Pe.stopPropagation(),U();return}(Pe.key===" "||Pe.key==="Enter")&&Pe.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:w2,onPointerDown:v2,onMouseDown:S2,children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),U()},onPointerDown:j2,onMouseDown:k2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:Me("typography-ui-label font-semibold truncate",X?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(wt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),D?s.jsx(Gf,{state:D}):null,l?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=D,e[37]=r,e[38]=he,e[39]=n.name,e[40]=U,e[41]=de,e[42]=pe,e[43]=l,e[44]=X,e[45]=re,e[46]=i,e[47]=P,e[48]=ee):ee=e[48];let oe;e[49]!==le||e[50]!==_||e[51]!==ee?(oe=s.jsxs("div",{className:le,children:[_,ee]}),e[49]=le,e[50]=_,e[51]=ee,e[52]=oe):oe=e[52];let fe;e[53]!==E||e[54]!==I||e[55]!==n.name||e[56]!==Te||e[57]!==Y||e[58]!==h||e[59]!==C||e[60]!==re||e[61]!==P?(fe=!re&&(!Y||I)?s.jsx("div",{className:Me("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",E?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!I&&C?s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),C()},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-ring","aria-label":P("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:P("sessions.sidebar.project.actions.newSession"),children:s.jsx(O,{name:"add",className:"h-3.5 w-3.5"})}):null,I?null:s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),Te()},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-ring","aria-label":P("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(O,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":I?P("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):P("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=E,e[54]=I,e[55]=n.name,e[56]=Te,e[57]=Y,e[58]=h,e[59]=C,e[60]=re,e[61]=P,e[62]=fe):fe=e[62];let ie;e[63]!==S||e[64]!==ge||e[65]!==ne||e[66]!==be||e[67]!==G||e[68]!==z||e[69]!==J||e[70]!==oe||e[71]!==fe?(ie=s.jsxs("div",{ref:S,className:ge,onClick:ne,role:be,tabIndex:G,onKeyDown:z,"aria-label":J,children:[oe,fe]}),e[63]=S,e[64]=ge,e[65]=ne,e[66]=be,e[67]=G,e[68]=z,e[69]=J,e[70]=oe,e[71]=fe,e[72]=ie):ie=e[72];let Le;e[73]!==f||e[74]!==l||e[75]!==F||e[76]!==i||e[77]!==o||e[78]!==P?(Le=!l&&F?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:P("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=F,e[76]=i,e[77]=o,e[78]=P,e[79]=Le):Le=e[79];let $e;return e[80]!==ie||e[81]!==Le?($e=s.jsxs("div",{className:"oc-folder",children:[ie,Le]}),e[80]=ie,e[81]=Le,e[82]=$e):$e=e[82],$e},qf=c.memo(h2);function p2(t){return t.stopPropagation()}function g2(t){return t.stopPropagation()}function x2(t){return t.stopPropagation()}function b2(t){return t.stopPropagation()}function y2(t){return t.stopPropagation()}function w2(t){return t.stopPropagation()}function v2(t){return t.stopPropagation()}function S2(t){return t.stopPropagation()}function j2(t){return t.stopPropagation()}function k2(t){return t.stopPropagation()}function C2(t){const e=Ze.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=ll(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(qf,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const Yr=t=>{const e=Ze.c(13),{directory:n,className:r}=t,{t:i}=St();let o;e[0]!==n?(o=dh(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=k=>k.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Rt(a)?.tabs.some(Kd))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const f=h;let p;e[6]!==r?(p=Me("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(O,{name:"pulse",className:"size-3.5"}),e[8]=x):x=e[8];let b;return e[9]!==l||e[10]!==f||e[11]!==p?(b=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:x}),e[9]=l,e[10]=f,e[11]=p,e[12]=b):b=e[12],b},N2=t=>{const e=Ze.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,h=a===void 0?!1:a,f=`session-drag:${r??n}`;let p;e[0]!==h||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(p={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:h},e[0]=h,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=p):p=e[5];let x;e[6]!==h||e[7]!==f||e[8]!==p?(x={id:f,disabled:h,data:p},e[6]=h,e[7]=f,e[8]=p,e[9]=x):x=e[9];const{attributes:b,listeners:k,setNodeRef:y,isDragging:m}=cb(x);let g;e[10]!==k?(g=C=>{C.stopPropagation(),k?.onPointerDown&&k.onPointerDown(C)},e[10]=k,e[11]=g):g=e[11];const j=g,S=`touch-pan-y select-none${m?" opacity-30":""}`;let w;return e[12]!==b||e[13]!==d||e[14]!==j||e[15]!==k||e[16]!==y||e[17]!==S?(w=s.jsx("div",{ref:y,...b,...k,onPointerDown:j,className:S,children:d}),e[12]=b,e[13]=d,e[14]=j,e[15]=k,e[16]=y,e[17]=S,e[18]=w):w=e[18],w},Yf=t=>{const e=Ze.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=_n(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let h;e[3]!==a||e[4]!==r?(h=a||al(r),e[3]=a,e[4]=r,e[5]=h):h=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let p;e[10]!==u||e[11]!==h||e[12]!==f?(p={id:u,disabled:h,data:f},e[10]=u,e[11]=h,e[12]=f,e[13]=p):p=e[13];const{setNodeRef:x,isOver:b}=db(p);let k;e[14]!==l||e[15]!==b||e[16]!==x?(k=l(x,b),e[14]=l,e[15]=b,e[16]=x,e[17]=k):k=e[17];let y;return e[18]!==k?(y=s.jsx(s.Fragment,{children:k}),e[18]=k,e[19]=y):y=e[19],y},A2=t=>{const e=Ze.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const h=oi(fn(ai,d),fn(ii,u)),[f,p]=c.useState(null),[x,b]=c.useState("Session"),[k,y]=c.useState(null),[m,g]=c.useState(null);if(!n){let D;return e[2]!==l?(D=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=D):D=e[3],D}let j;e[4]!==o||e[5]!==a?(j=D=>{p(null),y(null),g(null);const{active:F,over:B}=D;if(!B)return;const E=F.data.current,$=B.data.current;E?.type!=="session"||!E.sessionId||!E.ownerKey||E.archivedBucket===!0||a&&E.ownerKey!==a||$?.type!=="folder"||!$.folderId||!$.scopeKey||!$.ownerKey||al($.scopeKey)||$.ownerKey!==E.ownerKey||o(E.sessionId,{folderId:$.folderId,scopeKey:$.scopeKey,ownerKey:$.ownerKey},E.ownerKey)},e[4]=o,e[5]=a,e[6]=j):j=e[6];const S=j;let w,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=D=>{const F=D.active.data.current;if(F?.type==="session"&&F.sessionId){p(F.sessionId),b(F.sessionTitle??"Session");const B=D.active.rect.current.initial?.width,E=D.active.rect.current.initial?.height;y(B??null),g(E??null)}},C=()=>{p(null),y(null),g(null)},e[7]=w,e[8]=C):(w=e[7],C=e[8]);let v;e[9]!==m||e[10]!==f||e[11]!==x||e[12]!==k||e[13]!==i?(v=f&&i?s.jsxs("div",{style:{width:k?`${k}px`:"auto",height:m?`${m}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(O,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:x})]}):null,e[9]=m,e[10]=f,e[11]=x,e[12]=k,e[13]=i,e[14]=v):v=e[14];let R;e[15]!==v?(R=s.jsx(ub,{children:v}),e[15]=v,e[16]=R):R=e[16];let T;return e[17]!==l||e[18]!==S||e[19]!==h||e[20]!==R?(T=s.jsxs(li,{sensors:h,collisionDetection:ci,onDragStart:w,onDragCancel:C,onDragEnd:S,children:[l,R]}),e[17]=l,e[18]=S,e[19]=h,e[20]=R,e[21]=T):T=e[21],T},Qf=c.createContext(null),P2=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Qf.Provider,{value:a.current,children:r})},Xf=()=>c.useContext(Qf),D2=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const h of u)l.has(h)||(l.add(h),o.push(h))}return o.length>0?{ids:o,scopeKey:i}:null},Jf=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},Uc=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},wr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(wr(n,e))return!0;return!1},I2=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!Pg(r),T2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,E2=(t,e,n)=>{const r=new Map,i=o=>{const l=xs(o.session)??xt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},ja=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Zf=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},em=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const p=i.get(u.parentId)??[];p.push(u.id),i.set(u.parentId,p)}const h=new Set;let f=u.id;for(;f;){if(h.has(f)){o.add(u.id);break}h.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const h=r.get(u);if(!h)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&h.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(h.nodeCount>0||!n&&Bo([h.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Hc=new WeakMap;let Gc=1;const R2=t=>{const e=Hc.get(t);if(e!==void 0)return e;const n=Gc;return Gc+=1,Hc.set(t,n),n},Uo=t=>t.children.length===0?"":t.children.map(n=>{const r=R2(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Uo(n)}`}).join("|"),tm=(t,e,n,r,i,o)=>{const l=Wt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const h=d.session.directory??i,f=u.session.directory??o,p=Bl(l,h??"",d.session.id),x=Bl(l,f??"",u.session.id);return(p?n.has(p):!1)!==(x?r.has(x):!1)?!0:d.children.some((b,k)=>a(b,u.children[k]))};return a(t,e)},M2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,O2=(t,e)=>t?t.branchLabel??null:e??null,B2=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=xt(t?.path??null);return n&&r?Xo(r,n):null},Ho=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},F2=t=>{const e=Ze.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[h,f]=c.useState(!1),p=i===n&&!h,x=r?i===r&&!h:d;let b;e[0]!==l||e[1]!==i||e[2]!==o?(b=T=>{if(i===T){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=b):b=e[3];const k=b;let y;e[4]!==n||e[5]!==k||e[6]!==o?(y=T=>{if(T){u(!1),f(!1),o(n);return}k(n)},e[4]=n,e[5]=k,e[6]=o,e[7]=y):y=e[7];const m=y;let g;e[8]!==r||e[9]!==k||e[10]!==o?(g=T=>{if(!r){u(T);return}if(T){f(!1),o(r);return}k(r)},e[8]=r,e[9]=k,e[10]=o,e[11]=g):g=e[11];const j=g;let S;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(S=T=>{T||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=S):S=e[17];const w=S;let C;e[18]!==p||e[19]!==n||e[20]!==o?(C=()=>{f(!1),o(p?null:n)},e[18]=p,e[19]=n,e[20]=o,e[21]=C):C=e[21];const v=C;let R;return e[22]!==j||e[23]!==m||e[24]!==w||e[25]!==x||e[26]!==p||e[27]!==v?(R={isMenuOpen:p,isContextMenuOpen:x,handleMenuOpenChange:m,handleContextMenuOpenChange:j,handleMenuOpenChangeComplete:w,toggleMenu:v},e[22]=j,e[23]=m,e[24]=w,e[25]=x,e[26]=p,e[27]=v,e[28]=R):R=e[28],R},L2=t=>{const e=Ze.c(10),{project:n,fallback:r}=t,{currentTheme:i}=Cn(),o=n.iconImage??null;let l;e[0]!==n.id||e[1]!==o?(l={id:n.id,iconImage:o},e[0]=n.id,e[1]=o,e[2]=l):l=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=s.jsx(si,{project:l,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},_2=t=>{const e=Ze.c(13),{project:n}=t,r=n?.icon?ei[n.icon]:null,i=n?.color?ti[n.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?s.jsx(O,{name:r,className:Me("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!n?.iconImage){let h;return e[3]!==l?(h=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=h):h=e[4],h}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==n?(d=s.jsx(L2,{project:n,fallback:l}),e[7]=l,e[8]=n,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},qc=t=>{const e=Ze.c(44),{compact:n,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,statusDot:d,pinnedMarker:u,timeSlot:h,directoryIndicator:f,prBadge:p,zombieIndicator:x,badges:b,providerId:k,metaPaddingClass:y,hideMetaOnHoverClass:m}=t,g=n===void 0?!1:n,j=!g&&(!!a||!!p||!!x||!!b||!!k);let S;e[0]!==m||e[1]!==y?(S=Me("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",y,m),e[0]=m,e[1]=y,e[2]=S):S=e[2];const w=g?b:null;let C;e[3]!==h?(C=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:h}),e[3]=h,e[4]=C):C=e[4];let v;e[5]!==f||e[6]!==u||e[7]!==d||e[8]!==S||e[9]!==w||e[10]!==C?(v=s.jsxs("span",{className:S,children:[w,f,u,d,C]}),e[5]=f,e[6]=u,e[7]=d,e[8]=S,e[9]=w,e[10]=C,e[11]=v):v=e[11];const R=v;if(g){let X;e[12]!==l?(X=Me("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[12]=l,e[13]=X):X=e[13];let Y;e[14]!==X||e[15]!==o?(Y=s.jsx("div",{className:X,children:o}),e[14]=X,e[15]=o,e[16]=Y):Y=e[16];let I;return e[17]!==R||e[18]!==Y?(I=s.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[Y,R]}),e[17]=R,e[18]=Y,e[19]=I):I=e[19],I}let T;e[20]!==r?(T=s.jsx(_2,{project:r}),e[20]=r,e[21]=T):T=e[21];let D;e[22]!==i?(D=i?s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[22]=i,e[23]=D):D=e[23];let F;e[24]!==R||e[25]!==T||e[26]!==D?(F=s.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[T,D,R]}),e[24]=R,e[25]=T,e[26]=D,e[27]=F):F=e[27];let B;e[28]!==l?(B=Me("w-full min-w-0 truncate typography-ui-label font-normal",l),e[28]=l,e[29]=B):B=e[29];let E;e[30]!==B||e[31]!==o?(E=s.jsx("div",{className:B,children:o}),e[30]=B,e[31]=o,e[32]=E):E=e[32];let $;e[33]!==b||e[34]!==a||e[35]!==j||e[36]!==p||e[37]!==k||e[38]!==x?($=j?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[a?s.jsxs(s.Fragment,{children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null,s.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[x??p,b,k?s.jsx(Fo,{providerId:k,className:"h-4 w-4 flex-shrink-0 opacity-45"}):null]})]}):null,e[33]=b,e[34]=a,e[35]=j,e[36]=p,e[37]=k,e[38]=x,e[39]=$):$=e[39];let L;return e[40]!==E||e[41]!==$||e[42]!==F?(L=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[F,E,$]}),e[40]=E,e[41]=$,e[42]=F,e[43]=L):L=e[43],L};let ka=!1;const Ca=new Set;let Yc=!1;function $2(){for(const t of Ca)t()}function cl(t){ka!==t&&(ka=t,$2())}function z2(t){t.key==="Shift"&&cl(!0)}function W2(t){t.key==="Shift"&&cl(!1)}function K2(){cl(!1)}function V2(){Yc||typeof window>"u"||(Yc=!0,window.addEventListener("keydown",z2),window.addEventListener("keyup",W2),window.addEventListener("blur",K2))}function U2(t){return V2(),Ca.add(t),()=>{Ca.delete(t)}}function H2(){return ka}function G2(){return!1}function q2(){return ct.useSyncExternalStore(U2,H2,G2)}async function Y2(t,e,n){const r=await Promise.all(t.map(async i=>{n();const o=i.directory??i.session.directory,l=await Vs.getSession(i.session.id,o);if(n(),!eu(e,Oo(l,i.projectDirectory??l.directory)))throw new Error("Fusion source membership changed");const a=await Vs.getSessionMessages(i.session.id,{limit:50},o);n();let d="";for(const u of a.items)if(u.info.role==="assistant"){d=Dg(u.parts).trim();break}return{source:{...i,session:l},text:d}}));return n(),r.filter(i=>i.text.length>0)}const sm=t=>{const e=Ze.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=St(),u=Lt(Q2),h=Lt(X2),f=Lt(J2);let p;e[0]!==u?(p=u(),e[0]=u,e[1]=p):p=e[1];const x=p;let b;e[2]!==x?(b=x.filter(Z2),e[2]=x,e[3]=b):b=e[3];const k=b;let y,m;e[4]!==x.length||e[5]!==h?(y=()=>{x.length===0&&h()},m=[x.length,h],e[4]=x.length,e[5]=h,e[6]=y,e[7]=m):(y=e[6],m=e[7]),c.useEffect(y,m);let g,j;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==k||e[12]!==n?(g=()=>{if(o)return;const B=n.trim();if(B.length>0&&k.some(L=>L.name===B))return;const E=typeof f=="string"&&f.trim().length>0?f.trim():null;if(E&&k.some(L=>L.name===E)){r(E);return}const $=k[0]?.name;$&&r($)},j=[f,o,r,k,n],e[8]=f,e[9]=o,e[10]=r,e[11]=k,e[12]=n,e[13]=g,e[14]=j):(g=e[13],j=e[14]),c.useEffect(g,j);const S=n.trim().length>0?n:void 0;let w;e[15]!==i?(w=Me("max-w-full",i),e[15]=i,e[16]=w):w=e[16];let C;e[17]!==d?(C=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=C):C=e[18];let v;e[19]!==C?(v=s.jsx(hs,{placeholder:C}),e[19]=C,e[20]=v):v=e[20];let R;e[21]!==l||e[22]!==w||e[23]!==v?(R=s.jsx(Cs,{id:l,size:"lg",className:w,children:v}),e[21]=l,e[22]=w,e[23]=v,e[24]=R):R=e[24];let T;e[25]!==k?(T=k.length>0&&s.jsx(sa,{children:k.map(ek)}),e[25]=k,e[26]=T):T=e[26];let D;e[27]!==a||e[28]!==T?(D=s.jsx(Ns,{fitContent:!0,portalToBody:a,children:T}),e[27]=a,e[28]=T,e[29]=D):D=e[29];let F;return e[30]!==o||e[31]!==r||e[32]!==S||e[33]!==R||e[34]!==D?(F=s.jsxs(ks,{value:S,onValueChange:r,disabled:o,children:[R,D]}),e[30]=o,e[31]=r,e[32]=S,e[33]=R,e[34]=D,e[35]=F):F=e[35],F};function Q2(t){return t.getVisibleAgents}function X2(t){return t.loadAgents}function J2(t){return t.currentAgentName}function Z2(t){return Lu(t.mode)}function ek(t){return s.jsx(Yt,{value:t.name,className:"w-auto whitespace-nowrap",children:Ig(t)},t.name)}const tk="h-7",Kr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,sk=t=>{const e=Ze.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Me("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",tk),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(Fo,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(O,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=p):p=e[7];let x;return e[8]!==u||e[9]!==h||e[10]!==p?(x=s.jsxs("div",{className:d,children:[u,h,p]}),e[8]=u,e[9]=h,e[10]=p,e[11]=x):x=e[11],x},nm=t=>{const e=Ze.c(119),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:h,dropdownSide:f,dropdownClassName:p,containerClassName:x,triggerIcon:b}=t,k=d===void 0?!0:d,y=f===void 0?"top":f,{t:m}=St(),g=Lt(nk),j=Ae(rk),S=Ae(ok),{favoriteModelsList:w,recentModelsList:C}=Tg(),v=Ae(ik),R=Ae(ak),[T,D]=c.useState(!1),[F,B]=c.useState(""),[E,$]=c.useState(null),L=c.useRef(null),X=c.useRef(null),Y=u===1,I=u===void 0||n.length<u||Y;let P;if(e[0]!==n){P=new Map;for(const Se of n){const Ke=`${Se.providerID}:${Se.modelID}`;P.set(Ke,(P.get(Ke)||0)+1)}e[0]=n,e[1]=P}else P=e[1];const A=P;let q;e[2]!==n?(q=Se=>n.filter(et=>et.providerID===Se.providerID&&et.modelID===Se.modelID).findIndex(et=>et.instanceId===Se.instanceId)+1,e[2]=n,e[3]=q):q=e[3];const K=q;let te,ae;e[4]!==y||e[5]!==T?(te=()=>{if(!T||!X.current)return;const Se=X.current.getBoundingClientRect();if(y==="bottom"){const ht=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Se.bottom-16-112;$(Math.max(160,Math.min(320,ht)));return}let Ke=X.current.parentElement;for(;Ke&&!Ke.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const rt=getComputedStyle(Ke);if(rt.overflow==="auto"||rt.overflow==="hidden"||rt.overflowY==="auto"||rt.overflowY==="hidden")break;Ke=Ke.parentElement}const et=Ke?Ke.getBoundingClientRect().top:0,it=Se.top-et-16;$(Math.max(150,Math.min(300,it)))},ae=[y,T],e[4]=y,e[5]=T,e[6]=te,e[7]=ae):(te=e[6],ae=e[7]),c.useEffect(te,ae);let re,he;e[8]!==I||e[9]!==T?(re=()=>{!I&&T&&(D(!1),B(""))},he=[I,T],e[8]=I,e[9]=T,e[10]=re,e[11]=he):(re=e[10],he=e[11]),c.useEffect(re,he);let ce,Te;e[12]!==T?(ce=()=>{if(!T)return;const Se=Ke=>{L.current&&!L.current.contains(Ke.target)&&(D(!1),B(""))};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},Te=[T],e[12]=T,e[13]=ce,e[14]=Te):(ce=e[13],Te=e[14]),c.useEffect(ce,Te);let ve;e[15]!==Y||e[16]!==r||e[17]!==o||e[18]!==n.length?(ve=Se=>{const Ke={providerID:Se.providerID,modelID:Se.modelID,displayName:Se.model.name||Se.modelID,instanceId:Kr()};Y&&n.length>0&&o?o(0,Ke):r(Ke),Y&&(D(!1),B(""))},e[15]=Y,e[16]=r,e[17]=o,e[18]=n.length,e[19]=ve):ve=e[19];const pe=ve;let Ne;e[20]!==m?(Ne=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=Ne):Ne=e[21];let U;e[22]!==m?(U=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=U):U=e[23];let Z;e[24]!==m?(Z=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=Z):Z=e[25];let de;e[26]!==m?(de=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=de):de=e[27];let ye;e[28]!==m?(ye=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=ye):ye=e[29];let H;e[30]!==m?(H=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=H):H=e[31];let je;e[32]!==m?(je=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=je):je=e[33];let Ee;e[34]!==m?(Ee=m("chat.modelControls.capabilities"),e[34]=m,e[35]=Ee):Ee=e[35];let ge;e[36]!==m?(ge=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=ge):ge=e[37];let ne;e[38]!==m?(ne=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=ne):ne=e[39];let be;e[40]!==m?(be=m("chat.modelControls.input"),e[40]=m,e[41]=be):be=e[41];let G;e[42]!==m?(G=m("chat.modelControls.output"),e[42]=m,e[43]=G):G=e[43];let z;e[44]!==m?(z=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=z):z=e[45];let J;e[46]!==Ne||e[47]!==U||e[48]!==Z||e[49]!==de||e[50]!==ye||e[51]!==H||e[52]!==je||e[53]!==Ee||e[54]!==ge||e[55]!==ne||e[56]!==be||e[57]!==G||e[58]!==z?(J={searchPlaceholder:Ne,noResults:U,favorites:Z,recent:de,keyboardHint:ye,favorite:H,unfavorite:je,capabilities:Ee,capabilityToolCalling:ge,capabilityReasoning:ne,input:be,output:G,costPerMillion:z},e[46]=Ne,e[47]=U,e[48]=Z,e[49]=de,e[50]=ye,e[51]=H,e[52]=je,e[53]=Ee,e[54]=ge,e[55]=ne,e[56]=be,e[57]=G,e[58]=z,e[59]=J):J=e[59];const ue=J;let le;e[60]!==x?(le=Me("relative",x),e[60]=x,e[61]=le):le=e[61];const W=T?"":void 0;let M;e[62]!==h?(M=Me(_u({size:"default"}),"w-fit",h),e[62]=h,e[63]=M):M=e[63];const _=!I;let ee;e[64]!==T?(ee=()=>{D(!T)},e[64]=T,e[65]=ee):ee=e[65];let oe;e[66]!==b?(oe=b??s.jsx(O,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=b,e[67]=oe):oe=e[67];let fe;e[68]!==a||e[69]!==m?(fe=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=fe):fe=e[70];let ie;e[71]!==W||e[72]!==M||e[73]!==_||e[74]!==ee||e[75]!==oe||e[76]!==fe?(ie=s.jsxs("button",{ref:X,type:"button","data-popup-open":W,className:M,disabled:_,onClick:ee,children:[oe,fe]}),e[71]=W,e[72]=M,e[73]=_,e[74]=ee,e[75]=oe,e[76]=fe,e[77]=ie):ie=e[77];let Le;e[78]!==E||e[79]!==I||e[80]!==p||e[81]!==y||e[82]!==w||e[83]!==pe||e[84]!==v||e[85]!==S||e[86]!==T||e[87]!==ue||e[88]!==A||e[89]!==R||e[90]!==g||e[91]!==C||e[92]!==F||e[93]!==j?(Le=T?s.jsx("div",{className:Me("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",y==="top"?"bottom-full mb-1":"top-full mt-1",p),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(Eg,{providers:g,providerOrder:R,favoriteModels:w,recentModels:C,hiddenModels:v,searchQuery:F,onSearchQueryChange:B,onSelect:pe,labels:ue,selectionCount:Se=>A.get(`${Se.providerID}:${Se.modelID}`)||0,disabled:!I,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:E?`${E}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:T,isFavorite:Se=>S(Se.providerID,Se.modelID),onToggleFavorite:Se=>j(Se.providerID,Se.modelID),onEscape:()=>{D(!1),B("")}})}):null,e[78]=E,e[79]=I,e[80]=p,e[81]=y,e[82]=w,e[83]=pe,e[84]=v,e[85]=S,e[86]=T,e[87]=ue,e[88]=A,e[89]=R,e[90]=g,e[91]=C,e[92]=F,e[93]=j,e[94]=Le):Le=e[94];let $e;e[95]!==le||e[96]!==ie||e[97]!==Le?($e=s.jsxs("div",{className:le,ref:L,children:[ie,Le]}),e[95]=le,e[96]=ie,e[97]=Le,e[98]=$e):$e=e[98];let Pe;e[99]!==K||e[100]!==A||e[101]!==i||e[102]!==o||e[103]!==g||e[104]!==n||e[105]!==k||e[106]!==m?(Pe=k&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Se,Ke)=>{const et=`${Se.providerID}:${Se.modelID}`,it=A.get(et)||1,rt=K(Se),ht=g.find(we=>we.id===Se.providerID)?.models?.find(we=>we.id===Se.modelID),tt=Ya(ht?.variants),At=tt.length>0,jt=Se.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(sk,{model:Se,instanceIndex:rt,totalSameModel:it,onRemove:()=>i(Ke)}),At&&s.jsxs(ks,{value:jt,onValueChange:we=>{if(!o)return;o(Ke,{...Se,variant:we==="__default__"?void 0:we})},children:[s.jsxs(Cs,{size:"sm",className:"gap-1.5",children:[s.jsx(O,{name:"brain-ai-3",className:Me("h-3.5 w-3.5 flex-shrink-0",jt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(hs,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:we=>we==="__default__"?m("multirun.modelMultiSelect.variant.default"):we})]}),s.jsxs(Ns,{fitContent:!0,children:[s.jsx(Yt,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),tt.map(lk)]})]})]},Se.instanceId)})}),e[99]=K,e[100]=A,e[101]=i,e[102]=o,e[103]=g,e[104]=n,e[105]=k,e[106]=m,e[107]=Pe):Pe=e[107];let Oe;e[108]!==$e||e[109]!==Pe?(Oe=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[$e,Pe]}),e[108]=$e,e[109]=Pe,e[110]=Oe):Oe=e[110];let Q;e[111]!==u||e[112]!==l||e[113]!==n.length||e[114]!==m?(Q=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[111]=u,e[112]=l,e[113]=n.length,e[114]=m,e[115]=Q):Q=e[115];let Ce;return e[116]!==Oe||e[117]!==Q?(Ce=s.jsxs("div",{className:"space-y-2",children:[Oe,Q]}),e[116]=Oe,e[117]=Q,e[118]=Ce):Ce=e[118],Ce};function nk(t){return t.providers}function rk(t){return t.toggleFavoriteModel}function ok(t){return t.isFavoriteModel}function ik(t){return t.hiddenModels}function ak(t){return t.providerOrder}function lk(t){return s.jsx(Yt,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const ck=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
881
881
 
@@ -892,5 +892,5 @@ Now write the final fused answer.`}],directory:ae})}catch(te){if(Wt()!==A||Vs.ge
892
892
  `)?(D(rt),R(!0)):R(!1);return}R(!1)},[]),ue=ct.useCallback(Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,prompt:Q}}))},[]),le=ct.useCallback(Q=>{const Ce=m.execution.prompt,Ke=K.current?.selectionStart??Ce.length,it=Ce.substring(0,Ke).lastIndexOf("@"),rt=Q.relativePath&&Q.relativePath.trim().length>0?Q.relativePath.trim():Q.path||Q.name,pt=it!==-1?it:Ke,ht=`${Ce.substring(0,pt)}@${rt} ${Ce.substring(Ke)}`,tt=pt+rt.length+2;ue(ht),R(!1),D(""),requestAnimationFrame(()=>{const At=K.current;At&&(At.selectionStart=tt,At.selectionEnd=tt,At.focus()),J(ht,tt)})},[m.execution.prompt,ue,J]),W=ct.useCallback(Q=>{const Ce=m.execution.prompt,Ke=K.current?.selectionStart??Ce.length,it=Ce.substring(0,Ke).lastIndexOf("@"),rt=it!==-1?it:Ke,pt=`${Ce.substring(0,rt)}@${Q} ${Ce.substring(Ke)}`,ht=rt+Q.length+2;ue(pt),R(!1),D(""),requestAnimationFrame(()=>{const tt=K.current;tt&&(tt.selectionStart=ht,tt.selectionEnd=ht,tt.focus()),J(pt,ht)})},[m.execution.prompt,ue,J]),M=ct.useCallback(Q=>{const Ce=`/${Q.name} `;ue(Ce),B(!1),$(""),X(!1),requestAnimationFrame(()=>{const Se=K.current;Se&&(Se.focus(),Se.selectionStart=Se.value.length,Se.selectionEnd=Se.value.length),J(Ce,Ce.length)})},[ue,J]),_=ct.useCallback((Q,Ce)=>{const Se=m.execution.prompt,et=K.current?.selectionStart??Se.length,rt=Se.substring(0,et).lastIndexOf("#"),pt=rt!==-1?rt:et,ht=`${Se.substring(0,pt)}#${Ce} ${Se.substring(et)}`,tt=pt+Ce.length+2;ue(ht),X(!1),I(""),requestAnimationFrame(()=>{const At=K.current;At&&(At.selectionStart=tt,At.selectionEnd=tt,At.focus()),J(ht,tt)})},[m.execution.prompt,ue,J]),ee=ct.useCallback(Q=>{if(F&&ae.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")){Q.preventDefault(),ae.current.handleKeyDown(Q.key);return}v&&te.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),te.current.handleKeyDown(Q.key)),L&&re.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),re.current.handleKeyDown(Q.key))},[F,v,L]),oe=ct.useCallback(async()=>{const Q=L4(m,o);if(Q){ze.error(Q);return}const Ce={...m.id?{id:m.id}:{},name:m.name.trim(),enabled:m.enabled,schedule:{kind:m.schedule.kind,timezone:m.schedule.timezone.trim(),...m.schedule.kind==="cron"?{cron:m.schedule.cronExpression.trim()}:m.schedule.kind==="once"?{date:m.schedule.onceDate,time:m.schedule.onceTime}:{times:_4(m.schedule.times),...m.schedule.kind==="weekly"?{weekdays:m.schedule.weekdays}:{}}},execution:{prompt:m.execution.prompt,providerID:m.execution.providerID,modelID:m.execution.modelID,...m.execution.variant.trim()?{variant:m.execution.variant.trim()}:{},...m.execution.agent.trim()?{agent:m.execution.agent.trim()}:{},...m.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...m.execution.goalEnabled?{goalEnabled:!0}:{},...m.execution.goalEnabled&&m.execution.goalTokenBudget?{goalTokenBudget:m.execution.goalTokenBudget}:{}},...m.state?{state:m.state}:{}};S(!0);try{await i(Ce),r(!1)}catch(Se){ze.error(Se instanceof Error?Se.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[m,r,i,o]),fe=ct.useId(),ie=ct.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Le=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),$e=o("sessions.scheduledTasks.editor.description"),Pe=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(un,{id:"sched-name",value:m.name,onChange:Q=>g(Ce=>({...Ce,name:Q.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(ks,{value:m.schedule.kind,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,kind:Q,...Q==="cron"&&!Ce.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{children:Q=>o(Q==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":Q==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":Q==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Ns,{children:[s.jsx(Yt,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(Yt,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(Yt,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(Yt,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx($4,{draft:m,setDraft:g,locale:l,t:o}):m.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:q,children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Me(_u({size:"default"}),"w-fit max-w-full"),onClick:()=>C(Q=>!Q),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(O,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:P4(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),w?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>A(Q=>gd(Q,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:be,children:s.jsx(O,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(P)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>A(Q=>gd(Q,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(O,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:G.map((Q,Ce)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:Q},`${Q}-${Ce}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:D4(P,ve).map(({date:Q,inCurrentMonth:Ce})=>{const Se=pd(Q),Ke=Se===m.schedule.onceDate,et=vd(Q,Ee),it=Q.getTime()<Ee.getTime(),rt=Ke?"bg-interactive-selection text-interactive-selection-foreground":it?"text-muted-foreground/40":Ce?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{it||(z(Se),C(!1))},disabled:it,className:["h-8 rounded-md typography-ui-label",rt,et&&!Ke?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",it?"cursor-not-allowed opacity-45":""].join(" "),children:Q.getDate()},Se)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:ne||""}),s.jsx(ut,{type:"button",size:"xs",variant:"ghost",onClick:()=>{z(pd(Ee)),A(new Date(Ee.getFullYear(),Ee.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(yd,{value:m.schedule.onceTime,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Q=>g(Ce=>({...Ce,schedule:{...Ce.schedule,onceTime:Q}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ks,{value:m.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{})}),s.jsx(Ns,{children:Pa.map(Q=>s.jsx(Yt,{value:Q,children:Q},Q))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[m.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:pe.map(Q=>{const Ce=m.schedule.weekdays.includes(Q.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",Ce?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(hr,{checked:Ce,onChange:Se=>de(Q.value,Se),ariaLabel:Q.label}),s.jsx("button",{type:"button",onClick:()=>de(Q.value,!Ce),className:"group-hover:text-foreground",children:Q.label})]},Q.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((Q,Ce)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yd,{value:Q,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Se=>ye(Ce,Se)}),m.schedule.times.length>1?s.jsx(ut,{type:"button",size:"icon",variant:"ghost",onClick:()=>H(Ce),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null]},Ce))}),s.jsx("div",{children:s.jsxs(ut,{type:"button",size:"sm",variant:"outline",onClick:je,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ks,{value:m.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{})}),s.jsx(Ns,{children:Pa.map(Q=>s.jsx(Yt,{value:Q,children:Q},Q))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(cx,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(Q,Ce)=>{g(Se=>({...Se,execution:{...Se.execution,providerID:Q,modelID:Ce,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(ks,{value:Z,disabled:!U,onValueChange:Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,variant:Q==="__default"?"":Q}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{children:Q=>Q==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):Q})}),s.jsxs(Ns,{children:[s.jsx(Yt,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Ne.map(Q=>s.jsx(Yt,{value:Q,children:Q},Q))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(dx,{agentName:m.execution.agent,filter:Q=>Lu(Q.mode),onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,agent:Q}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(fr,{id:"sched-prompt",ref:K,value:m.execution.prompt,onChange:Q=>{const Ce=Q.target.value;ue(Ce);const Se=Q.target.selectionStart??Ce.length;J(Ce,Se)},onKeyDown:ee,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),F?s.jsx(Hu,{ref:ae,searchQuery:E,onCommandSelect:M,onClose:()=>B(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,v?s.jsx(Gu,{ref:te,searchQuery:T,onFileSelect:le,onAgentSelect:W,onClose:()=>R(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,L?s.jsx(qu,{ref:re,searchQuery:Y,onSnippetSelect:_,onClose:()=>X(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),m.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(hr,{checked:m.execution.goalTokenBudget!==null,onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Q?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(ux,{value:m.execution.goalTokenBudget,onValueChange:Q=>{typeof Q=="number"&&Number.isFinite(Q)&&Q>0&&g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Math.floor(Q)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Oe=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(hr,{checked:m.enabled,onChange:Q=>g(Ce=>({...Ce,enabled:Q})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(md),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,permissionAutoAccept:!Q.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(O,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(O,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(wt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(md,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,goalEnabled:!Q.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(O,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(O,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(wt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:j,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(ut,{type:"button",size:"sm",onClick:oe,disabled:j,children:o(j?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return y?s.jsx(Jo,{open:e,title:Le,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:Q=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:Le}),Q]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:$e})]}),footer:Oe,children:Pe}):s.jsx(bs,{open:e,onOpenChange:Q=>{!Q&&ie()||r(Q)},children:s.jsxs(ys,{"aria-describedby":fe,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Fs,{id:fe,className:"sr-only",children:$e}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Bs,{className:"typography-ui-label font-medium text-foreground",children:Le}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:$e})]})}),s.jsx(za,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Pe})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:Oe})})]})})}function W4(t){return jr(t,{min:0,max:23})}function K4(t,e){return jr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function V4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function U4(t){return s.jsx(Yt,{value:t,children:t},t)}const H4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},G4=(t,e)=>{const n=H4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},q4=(t,e)=>!t||!Number.isFinite(t)?"":fx(t,e),jd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),p=Math.round(r%o/i),x=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:x}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:x})}const d=Math.floor(r/l),u=Math.round(r%l/o),h=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},Y4={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},Q4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function X4(){const{t}=St(),e=Ae(I=>I.isScheduledTasksDialogOpen),n=Ae(I=>I.setScheduledTasksDialogOpen),r=Ae(I=>I.isMobile),i=Ae(I=>I.timeFormatPreference),o=zt(I=>I.projects),l=zt(I=>I.getActiveProject()),a=Jt(I=>I.homeDirectory),{currentTheme:d}=Cn(),[u,h]=ct.useState(""),[f,p]=ct.useState([]),[x,b]=ct.useState(!0),[k,y]=ct.useState(!1),[m,g]=ct.useState(null),[j,S]=ct.useState(null),w=ct.useMemo(()=>o.find(I=>I.id===u)||null,[o,u]),C=ct.useCallback(I=>{const P=I.label?.trim()||Yn(I.path,a||void 0),A=I.icon?ei[I.icon]:null,q=I.color?ti[I.color]:void 0,K=A?s.jsx(O,{name:A,className:"h-3.5 w-3.5 shrink-0",style:q?{color:q}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:q?{color:q}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[I.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:I.iconBackground?{backgroundColor:I.iconBackground}:void 0,children:s.jsx(si,{project:{id:I.id,iconImage:I.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:K})}):K,s.jsx("span",{className:"truncate",children:P})]})},[a,d.metadata.variant,d.colors.surface.foreground]),v=ct.useCallback(async(I,P)=>{if(!I){p([]);return}P?.silent||b(!0);try{const A=await rb(I);A.sort((q,K)=>{if(q.enabled!==K.enabled)return q.enabled?-1:1;const te=q.name.localeCompare(K.name);return te!==0?te:(q.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(K.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(A)}catch(A){ze.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),P?.silent||p([])}finally{P?.silent||b(!1)}},[t]);ct.useEffect(()=>{if(!e)return;const I=l?.id||o[0]?.id||"";h(I),I?v(I):(p([]),b(!1))},[e,l,o,v]),ct.useEffect(()=>{if(!e)return;let I=null;const P=Pn(A=>{A.type==="scheduled-task-ran"&&A.projectId===u&&(I&&clearTimeout(I),I=setTimeout(()=>{v(u,{silent:!0})},400))});return()=>{I&&clearTimeout(I),P()}},[e,u,v]);const R=ct.useCallback(async I=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Jl(u,I),await v(u),ze.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,v,t]),T=ct.useCallback(async(I,P)=>{if(u){S(I.id),p(A=>A.map(q=>q.id===I.id?{...q,enabled:P}:q));try{I.loopFile?await ob(u,I.id,P):await Jl(u,{...I,enabled:P}),await v(u,{silent:!0})}catch(A){ze.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await v(u,{silent:!0})}finally{S(null)}}},[u,v,t]),D=ct.useCallback(async I=>{if(!(!u||!window.confirm(I.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:I.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:I.name})))){S(I.id);try{I.loopFile?await ib(u,I.id):await ab(u,I.id),await v(u,{silent:!0}),ze.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(A){ze.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[u,v,t]),F=ct.useCallback(I=>{if(!I.loopFile){g(I),y(!0);return}w?.path&&(n(!1),Js.getState().setSelectedPath(w.path,I.loopFile,{allowOutsideRoot:!0}),Ae.getState().openContextFile(w.path,I.loopFile))},[w?.path,n]),B=ct.useCallback(async I=>{if(u){S(I.id);try{const{sessionId:P,persistError:A}=await lb(u,I.id);if(await Promise.all([v(u,{silent:!0}),ri()]),A?ze.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):ze.success(t("sessions.scheduledTasks.dialog.toast.started")),P){const q=o.find(K=>K.id===u);nt.getState().setCurrentSession(P,q?.path??null)}}catch(P){ze.error(P instanceof Error?P.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[u,o,v,t]),E=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(ks,{value:u||"__none",onValueChange:I=>{const P=I==="__none"?"":I;h(P),P?v(P):p([])},children:[s.jsx(Cs,{size:"lg",className:r?"w-full":void 0,children:w?s.jsx(hs,{children:C(w)}):s.jsx(hs,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Ns,{children:[o.length===0?s.jsx(Yt,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(I=>s.jsx(Yt,{value:I.id,children:C(I)},I.id))]})]})]}),$=()=>{g(null),y(!0)},L=I=>{h(I),I?v(I):p([])},X=s.jsx("div",{className:"min-h-[280px]",children:x?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(O,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(I=>{const P=j===I.id,A=I.state?.lastStatus||"idle",q=Y4[A],K=t(A==="success"?"sessions.scheduledTasks.dialog.status.success":A==="error"?"sessions.scheduledTasks.dialog.status.error":A==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),te=I.state?.nextRunAt,ae=I.state?.lastRunAt;return s.jsxs("div",{className:Me("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Me("min-w-0",!I.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:I.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:G4(I,t)}),I.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:I.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:I.loopFile})}):null]}),s.jsxs("div",{className:Me("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!I.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(O,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),te?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:jd(te,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:q4(te,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(O,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),A==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(O,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ae?s.jsxs(s.Fragment,{children:[q.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${q.tone})`},children:[s.jsx(O,{name:q.Icon,className:"h-3.5 w-3.5"}),K]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:jd(ae,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),I.state?.lastError?s.jsxs("div",{className:Me("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!I.enabled&&"opacity-60"),style:Q4("error"),children:[s.jsx(O,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:I.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Me("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",I.enabled?"text-foreground":"text-muted-foreground",P&&"cursor-not-allowed opacity-50"),children:[s.jsx(hr,{checked:I.enabled,onChange:re=>{T(I,re)},ariaLabel:I.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:I.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:I.name}),disabled:P}),I.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(ut,{variant:"outline",size:"sm",onClick:()=>{B(I)},disabled:P,children:[s.jsx(O,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(ut,{variant:"outline",size:"sm",onClick:()=>F(I),disabled:P,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:I.name}),children:[s.jsx(O,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{D(I)},disabled:P,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:I.name}),children:s.jsx(O,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},I.id)})})}),Y=s.jsxs("div",{className:"space-y-4",children:[E,X]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Jo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:I=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),I]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(ut,{className:"w-full",onClick:$,disabled:!u,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:Y}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(I=>s.jsx("button",{type:"button",onClick:()=>L(I.id),className:Me("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===I.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(I)},I.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(ut,{size:"sm",onClick:$,disabled:!u,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:X})})]})]})}):null,s.jsx(z4,{open:k,task:m,onOpenChange:y,onSave:R})]})}const To=100;function J4(){const t=Ze.c(108),{t:e}=St(),n=Ae(aC),r=Ae(iC),i=nt(oC),o=nt(rC),l=Jt(nC);let a;t[0]!==n?(a=te=>n?te.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=us(Qn(a)),[u,h]=c.useState(""),[f,p]=c.useState(null),[x,b]=c.useState(To);let k;t[2]!==u?(k=u.trim().toLowerCase(),t[2]=u,t[3]=k):k=t[3];const y=k;let m;e:{if(!n){let ae;t[4]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[4]=ae):ae=t[4],m=ae;break e}let te;t[5]!==d?(te=[...d].sort(sC),t[5]=d,t[6]=te):te=t[6],m=te}const g=m;let j;if(t[7]!==l||t[8]!==g||t[9]!==e){const te=new Map;for(const ae of g){const re=xt(xs(ae))??"",he=te.get(re);if(he){he.sessions.push(ae);continue}te.set(re,{directory:re,label:re?Yn(re,l)||re:e("sessions.archivePage.otherProjects"),sessions:[ae]})}j=[...te.values()].sort(tC),t[7]=l,t[8]=g,t[9]=e,t[10]=j}else j=t[10];const S=j;let w;e:{if(y){if(y.startsWith("ses_")){let re;if(t[11]!==y||t[12]!==g){let he;t[14]!==y?(he=ce=>ce.id.toLowerCase()===y,t[14]=y,t[15]=he):he=t[15],re=g.filter(he),t[11]=y,t[12]=g,t[13]=re}else re=t[13];w=re;break e}let ae;t[16]!==y||t[17]!==g?(ae=mx(g,y,eC),t[16]=y,t[17]=g,t[18]=ae):ae=t[18],w=ae;break e}if(f===null){w=g;break e}let te;t[19]!==S||t[20]!==f?(te=S.find(ae=>ae.directory===f)?.sessions??[],t[19]=S,t[20]=f,t[21]=te):te=t[21],w=te}const C=w;let v,R,T,D,F,B,E,$,L,X;if(t[22]!==d.length||t[23]!==S||t[24]!==C||t[25]!==l||t[26]!==y||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==x){F=Symbol.for("react.early_return_sentinel");e:{const te=C.slice(0,x);v=C.length-te.length;const ae=d.length;let re;t[45]===Symbol.for("react.memo_cache_sentinel")?(re=be=>{p(be),b(To)},t[45]=re):re=t[45];const he=re;let ce;t[46]!==i||t[47]!==r?(ce=be=>{const G=xt(xs(be));i(be.id,G??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=ce):ce=t[48];const Te=ce;let ve;t[49]!==e||t[50]!==o?(ve=be=>{o(be.id).then(G=>{G?ze.success(e("sessions.sidebar.session.restore.success")):ze.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=ve):ve=t[51];const pe=ve;if(!n){F=null;break e}let Ne;t[52]!==e?(Ne=(be,G,z,J,ue,le,W)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:ue,title:le,className:Me("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",W?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",J?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:G}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:z})]}),W?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>Qs.requestDelete({sessions:W,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:G}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},be),t[52]=e,t[53]=Ne):Ne=t[53];const U=Ne;D="absolute inset-0 z-10 flex flex-col bg-background",R="flex min-h-0 flex-1";let Z;if(t[54]!==U||t[55]!==f||t[56]!==e||t[57]!==ae){let be;t[59]===Symbol.for("react.memo_cache_sentinel")?(be=()=>he(null),t[59]=be):be=t[59],Z=U("__all__",e("sessions.archivePage.allDirectories"),ae,f===null,be),t[54]=U,t[55]=f,t[56]=e,t[57]=ae,t[58]=Z}else Z=t[58];let de;if(t[60]!==S||t[61]!==U||t[62]!==f){let be;t[64]!==U||t[65]!==f?(be=G=>U(G.directory||"__none__",G.label,G.sessions.length,f===G.directory,()=>he(G.directory),G.directory||void 0,G.sessions),t[64]=U,t[65]=f,t[66]=be):be=t[66],de=S.map(be),t[60]=S,t[61]=U,t[62]=f,t[63]=de}else de=t[63];t[67]!==Z||t[68]!==de?(T=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[Z,de]})}),t[67]=Z,t[68]=de,t[69]=T):T=t[69],L="flex min-w-0 flex-1 flex-col";let ye;t[70]===Symbol.for("react.memo_cache_sentinel")?(ye=be=>{h(be),b(To)},t[70]=ye):ye=t[70];let H;t[71]!==e?(H=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=H):H=t[72];let je;t[73]!==e?(je=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=je):je=t[74];let Ee;t[75]!==u||t[76]!==H||t[77]!==je?(Ee=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Zd,{value:u,onSearch:ye,placeholder:H,clearLabel:je})}),t[75]=u,t[76]=H,t[77]=je,t[78]=Ee):Ee=t[78];let ge;t[79]!==C.length||t[80]!==e?(ge=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[79]=C.length,t[80]=e,t[81]=ge):ge=t[81];let ne;t[82]!==ge?(ne=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:ge}),t[82]=ge,t[83]=ne):ne=t[83],t[84]!==Ee||t[85]!==ne?(X=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Ee,ne]}),t[84]=Ee,t[85]=ne,t[86]=X):X=t[86],$="min-h-0 flex-1 overflow-y-auto px-6 py-3",B="mx-auto w-full max-w-3xl space-y-0.5",E=te.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(y?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):te.map(be=>{const G=xt(xs(be))??"",z=G?Yn(G,l)||G:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Te(be),role:"button",tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),Te(be))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:be.title||e("sessions.sidebar.session.untitled")}),y&&z?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:G,children:z}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Uu(be.time?.archived??be.time?.updated??be.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),pe(be)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(O,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),Qs.requestDelete({sessions:[be],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},be.id)})}t[22]=d.length,t[23]=S,t[24]=C,t[25]=l,t[26]=y,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=x,t[35]=v,t[36]=R,t[37]=T,t[38]=D,t[39]=F,t[40]=B,t[41]=E,t[42]=$,t[43]=L,t[44]=X}else v=t[35],R=t[36],T=t[37],D=t[38],F=t[39],B=t[40],E=t[41],$=t[42],L=t[43],X=t[44];if(F!==Symbol.for("react.early_return_sentinel"))return F;let Y;t[87]!==v||t[88]!==e?(Y=v>0?s.jsx("button",{type:"button",onClick:()=>b(Z4),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=v,t[88]=e,t[89]=Y):Y=t[89];let I;t[90]!==Y||t[91]!==B||t[92]!==E?(I=s.jsxs("div",{className:B,children:[E,Y]}),t[90]=Y,t[91]=B,t[92]=E,t[93]=I):I=t[93];let P;t[94]!==I||t[95]!==$?(P=s.jsx("div",{className:$,children:I}),t[94]=I,t[95]=$,t[96]=P):P=t[96];let A;t[97]!==P||t[98]!==L||t[99]!==X?(A=s.jsxs("div",{className:L,children:[X,P]}),t[97]=P,t[98]=L,t[99]=X,t[100]=A):A=t[100];let q;t[101]!==R||t[102]!==T||t[103]!==A?(q=s.jsxs("div",{className:R,children:[T,A]}),t[101]=R,t[102]=T,t[103]=A,t[104]=q):q=t[104];let K;return t[105]!==D||t[106]!==q?(K=s.jsx("div",{className:D,children:q}),t[105]=D,t[106]=q,t[107]=K):K=t[107],K}function Z4(t){return t+To}function eC(t){return[t.title]}function tC(t,e){return e.sessions.length-t.sessions.length}function sC(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function nC(t){return t.homeDirectory}function rC(t){return t.unarchiveSession}function oC(t){return t.setCurrentSession}function iC(t){return t.setArchivePageOpen}function aC(t){return t.isArchivePageOpen}function lC(){const t=Ze.c(18),{t:e}=St(),n=Ae(uC),r=Ae(dC),i=zt(cC);let o;t[0]!==n?(o=x=>x.projects.find(b=>b.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=zt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(O,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==a||t[10]!==u?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(ut,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(sp,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let p;return t[15]!==h||t[16]!==f?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,f]})})}),t[15]=h,t[16]=f,t[17]=p):p=t[17],p}function cC(t){return t.setActiveProjectIdOnly}function dC(t){return t.setNewWorktreeDialogOpen}function uC(t){return t.worktreesPageProjectId}function hm(t){const e=Ze.c(30),{git:n}=nn(),r=ku(t),i=Cu(t),o=hx(t),l=px(t),a=pn(gC),d=pn(pC);let u,h;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},h=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=h):(u=e[5],h=e[6]),c.useEffect(u,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const p=r?.all;let x;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(x=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=x):x=e[18],c.useEffect(f,x);const b=o||i===!0&&l;let k;e:{if(!r?.all){let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[19]=v):v=e[19],k=v;break e}let C;e[20]!==r.all?(C=r.all.filter(hC).sort(),e[20]=r.all,e[21]=C):C=e[21],k=C}const y=k;let m;e:{if(!r?.all){let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[22]=v):v=e[22],m=v;break e}let C;e[23]!==r.all?(C=r.all.filter(mC).map(fC).sort(),e[23]=r.all,e[24]=C):C=e[24],m=C}const g=m;let j;e:{if(!t){j=null;break e}if(i!==null){j=i;break e}if(b){j=null;break e}j=r?.all?!0:null}const S=j;let w;return e[25]!==S||e[26]!==b||e[27]!==y||e[28]!==g?(w={localBranches:y,remoteBranches:g,isLoading:b,isGitRepository:S},e[25]=S,e[26]=b,e[27]=y,e[28]=g,e[29]=w):w=e[29],w}function fC(t){return t.replace(/^remotes\//,"")}function mC(t){return t.startsWith("remotes/")}function hC(t){return!t.startsWith("remotes/")}function pC(t){return t.fetchStatus}function gC(t){return t.fetchBranches}const xC=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=St(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:h}=hm(t),f=c.useMemo(()=>[...a,...d.map(x=>`remotes/${x}`)],[a,d]);c.useEffect(()=>{if(i||u||f.length===0||e&&f.includes(e))return;const x=e;let b=!1;return(async()=>{try{const y=t?await $a(t).catch(()=>null):null;if(b)return;const m=localStorage.getItem(Pl),{sourceBranch:g,shouldClearSavedSourceBranch:j}=np({branches:f,savedSourceBranch:m,rootBranch:y});if(j&&localStorage.removeItem(Pl),b||x&&f.includes(x))return;g&&n(g)}catch{}})(),()=>{b=!0}},[f,t,i,u,n,e]);const p=i||!h||u;return s.jsxs("div",{children:[s.jsxs(ks,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Cs,{id:o,size:"lg",className:Me("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(hs,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Ns,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(sa,{children:[s.jsx(Kl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(x=>s.jsx(Yt,{value:x,className:"whitespace-normal break-all",children:x},x))]}),a.length>0&&d.length>0&&s.jsx(gx,{}),d.length>0&&s.jsxs(sa,{children:[s.jsx(Kl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(x=>s.jsx(Yt,{value:`remotes/${x}`,className:"whitespace-normal break-all",children:x},`remotes/${x}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},bC=10*1024*1024,Eo=t=>{const e=Ze.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(O,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(bt,{children:[r,s.jsx(wt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Wn=t=>{const e=Ze.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},yC=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=St(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Kr(),prompt:"",models:[]}]),[u,h]=c.useState(""),[f,p]=c.useState([]),[x,b]=c.useState(!1),[k,y]=c.useState([]),[m,g]=c.useState(!1),[j,S]=c.useState(!1),[w,C]=c.useState(!0),v=c.useRef(null),R=Jt(M=>M.currentDirectory??null),T=Jt(M=>M.homeDirectory??null),D=c.useMemo(()=>{if(typeof window>"u")return null;const M=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof M=="string"&&M.trim().length>0?M.trim():null},[]),F=zt(M=>M.activeProjectId),B=zt(M=>M.setActiveProjectIdOnly),E=zt(M=>M.projects),[$,L]=c.useState(()=>F??null);c.useEffect(()=>{if(F){L(F);return}!$&&E.length>0&&L(E[0].id)},[F,E,$]);const X=c.useMemo(()=>$?E.find(M=>M.id===$)??null:null,[E,$]),Y=X?.path??R,I=c.useCallback(M=>{L(M),M!==F&&B(M)},[F,B]),{currentTheme:P}=Cn(),A=c.useCallback(M=>{const _=M.label?.trim()||Yn(M.path,T),ee=M.icon?ei[M.icon]:null,oe=M.color?ti[M.color]:void 0,fe=ee?s.jsx(O,{name:ee,className:"h-3.5 w-3.5 shrink-0",style:oe?{color:oe}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:oe?{color:oe}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[M.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:M.iconBackground?{backgroundColor:M.iconBackground}:void 0,children:s.jsx(si,{project:{id:M.id,iconImage:M.iconImage??null},options:{themeVariant:P.metadata.variant,iconColor:P.colors.surface.foreground},className:"h-full w-full object-contain",fallback:fe})}):fe,s.jsx("span",{className:"truncate",children:_})]})},[T,P.metadata.variant,P.colors.surface.foreground]),q=c.useMemo(()=>{if(X?.path)return{id:X.id,path:X.path};const M=R??D;return M?{id:`path:${M}`,path:M}:null},[X,R,D]),[K]=c.useState(()=>typeof window<"u"?en():!1),te=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ae=mu(),re=c.useMemo(()=>{if(typeof window>"u")return null;const M=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof M=="number"&&Number.isFinite(M)&&M>0)return M;if(typeof navigator>"u")return null;const _=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!_)return null;const ee=Number.parseInt(_[1],10),oe=Number.parseInt(_[2],10);return Number.isNaN(ee)?null:ee===10?oe:ee},[]),he=c.useMemo(()=>K&&te||ae?"pl-[88px]":"pl-3",[K,te,ae]),ce=c.useMemo(()=>!K||!te||re===null?"":re>=26?"h-12":re<=15?"h-14":"",[K,te,re]),Te=c.useCallback(async M=>{M.target.closest("button, a, input, select, textarea")||M.button===0&&K&&await xx()},[K]);c.useEffect(()=>{if(!n)return;const M=_=>{_.key==="Escape"&&(_.preventDefault(),_.stopPropagation(),n())};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[n]);const[ve,pe]=c.useState(""),{isLoading:Ne,isGitRepository:U}=hm(Y),Z=c.useRef(!1),de=U===!0,ye=de&&w;c.useEffect(()=>{if(U===!1){Z.current=!0,C(!1);return}U===!0&&Z.current&&(Z.current=!1,C(!0))},[U]);const H=ki(M=>M.createMultiRun),je=ki(M=>M.error),Ee=ki(M=>M.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(M=>{const _=[...M];return _.length>0&&!_[0].prompt.trim()&&(_[0]={..._[0],prompt:t}),_})},[t]),c.useEffect(()=>{if(!q)return;let M=!1;return S(!0),(async()=>{try{const _=await bx(q);M||y(_)}catch{}finally{M||S(!1)}})(),()=>{M=!0}},[q]);const ge=c.useCallback((M,_)=>{d(ee=>ee.map(oe=>oe.id===M?{...oe,..._}:oe))},[]),ne=c.useCallback(M=>{d(_=>_.filter(ee=>ee.id!==M))},[]),be=c.useCallback(()=>{d(M=>[...M,{id:Kr(),prompt:"",models:[]}])},[]),G=async M=>{const _=M.target.files;if(!_)return;let ee=0;for(let oe=0;oe<_.length;oe++){const fe=_[oe];if(fe.size>bC){ze.error(i("multirun.launcher.toast.fileTooLarge",{fileName:fe.name}));continue}try{const ie=await new Promise((Le,$e)=>{const Pe=new FileReader;Pe.onload=()=>Le(Pe.result),Pe.onerror=$e,Pe.readAsDataURL(fe)});p(Le=>[...Le,{id:Kr(),filename:fe.name,mimeType:fe.type||"application/octet-stream",size:fe.size,dataUrl:ie}]),ee++}catch(ie){console.error("File attach failed",ie),ze.error(i("multirun.launcher.toast.attachFailed",{fileName:fe.name}))}}ee>0&&ze.success(ee===1?i("multirun.launcher.toast.attachedSingle",{count:ee}):i("multirun.launcher.toast.attachedPlural",{count:ee})),v.current&&(v.current.value="")},z=M=>{p(_=>_.filter(ee=>ee.id!==M))},J=c.useMemo(()=>a.reduce((M,_)=>M+_.models.length,0),[a]),ue=async M=>{M.preventDefault();const _=a.filter(ee=>ee.prompt.trim()&&ee.models.length>=1);if(_.length!==0&&!(J<1)){b(!0),Ee();try{$&&$!==F&&B($);const ee=f.map($e=>({mime:$e.mimeType,filename:$e.filename,url:$e.dataUrl})),oe=k.filter($e=>$e.trim().length>0),fe=_.map($e=>({prompt:$e.prompt.trim(),models:$e.models.map(Pe=>({providerID:Pe.providerID,modelID:Pe.modelID,displayName:Pe.displayName,variant:Pe.variant}))})),ie={name:o.trim(),groups:fe,agent:u||void 0,worktreeBaseBranch:ye?ve:void 0,isolateRuns:ye,files:ee.length>0?ee:void 0,setupCommands:oe.length>0?oe:void 0},Le=await H(ie);Le&&(Le.failedCount>0&&ze.error(i("multirun.launcher.toast.partialFailure",{failed:Le.failedCount})),Le.firstSessionId&&nt.getState().setCurrentSession(Le.firstSessionId),e?.())}finally{b(!1)}}},le=!!(o.trim()&&a.some(M=>M.prompt.trim()&&M.models.length>=1)&&J>=1&&Y&&!Ne&&(U===!1||!ye||ve)),W=k.filter(M=>M.trim()).length;return s.jsxs("form",{onSubmit:ue,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Te,className:Me("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",he,ce),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring app-region-no-drag",children:s.jsx(O,{name:"close",className:"h-5 w-5"})})}),s.jsx(wt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(za,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),E.length>0?s.jsxs(ks,{value:$??void 0,onValueChange:I,children:[s.jsx(Cs,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:X?s.jsx(hs,{children:A(X)}):s.jsx(hs,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Ns,{fitContent:!0,children:E.map(M=>s.jsx(Yt,{value:M.id,className:"max-w-[24rem]",children:A(M)},M.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"group-name",required:!0,info:s.jsx(Eo,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(un,{id:"group-name",value:o,onChange:M=>l(M.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Eo,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(xC,{directory:Y,value:ve,onChange:pe,disabled:!ye,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(hr,{checked:w,onChange:C,disabled:!de,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"multirun-agent",info:s.jsx(Eo,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(sm,{value:u,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(Qi,{open:m,onOpenChange:g,children:[s.jsxs(ju,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(O,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),W>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:W}),s.jsx(O,{name:"arrow-down-s",className:Me("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(Xi,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:j?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[k.map((M,_)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(un,{value:M,onChange:ee=>{const oe=[...k];oe[_]=ee.target.value,y(oe)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>y(k.filter((ee,oe)=>oe!==_)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})})]},`${M}-${_}`)),s.jsxs("button",{type:"button",onClick:()=>y([...k,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(O,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Wn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:G,accept:"*/*"}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>v.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(O,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(wt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(M=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[M.mimeType.startsWith("image/")?s.jsx(O,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(O,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:M.filename,children:M.filename}),s.jsx("button",{type:"button",onClick:()=>z(M.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(O,{name:"close",className:"h-3 w-3"})})]},M.id))]})]}),a.map((M,_)=>s.jsx(wC,{group:M,groupIndex:_,canRemove:a.length>1,onUpdate:ge,onRemove:ne},M.id)),s.jsxs("button",{type:"button",onClick:be,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(O,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),je&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:je})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!ye&&U!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(O,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(ut,{type:"submit",size:"sm",disabled:!le||x,children:x?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:J})})})]})})]})},wC=t=>{const e=Ze.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=St(),[d,u]=c.useState(!1),[h,f]=c.useState(""),[p,x]=c.useState(!1),[b,k]=c.useState(""),[y,m]=c.useState(!1),[g,j]=c.useState(""),S=c.useRef(null),w=c.useRef(null),C=c.useRef(null),v=c.useRef(null);let R;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(R=oe=>{o(n.id,{models:[...n.models,oe]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=R):R=e[3];const T=R;let D;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(D=oe=>{o(n.id,{models:n.models.filter((fe,ie)=>ie!==oe)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=D):D=e[7];const F=D;let B;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(B=(oe,fe)=>{o(n.id,{models:n.models.map((ie,Le)=>Le===oe?fe:ie)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=B):B=e[11];const E=B;let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(oe,fe)=>{if(oe.startsWith("/")){const Pe=oe.indexOf(" "),Oe=oe.indexOf(`
893
893
  `),Q=Math.min(Pe===-1?oe.length:Pe,Oe===-1?oe.length:Oe);if(fe<=Q&&Pe===-1){k(oe.substring(1,Q)),x(!0),u(!1),m(!1);return}}x(!1);const ie=oe.substring(0,fe),Le=ie.lastIndexOf("#");if(Le!==-1){const Pe=Le>0?ie[Le-1]:null,Oe=ie.substring(Le+1);if((!Pe||/\s/.test(Pe))&&!Oe.includes(" ")&&!Oe.includes(`
894
894
  `)){j(Oe),m(!0),u(!1);return}}m(!1);const $e=ie.lastIndexOf("@");if($e!==-1){const Pe=$e>0?ie[$e-1]:null,Oe=ie.substring($e+1);(!Pe||/\s/.test(Pe))&&!Oe.includes(" ")&&!Oe.includes(`
895
- `)?(f(Oe),u(!0)):u(!1);return}u(!1)},e[12]=$):$=e[12];const L=$;let X;e[13]!==n.id||e[14]!==o?(X=oe=>{o(n.id,{prompt:oe})},e[13]=n.id,e[14]=o,e[15]=X):X=e[15];const Y=X;let I;e[16]!==n.prompt||e[17]!==Y?(I=oe=>{const fe=n.prompt,Le=S.current?.selectionStart??fe.length,Pe=fe.substring(0,Le).lastIndexOf("@"),Oe=oe.relativePath&&oe.relativePath.trim().length>0?oe.relativePath.trim():oe.path||oe.name,Q=Pe!==-1?Pe:Le,Ce=`${fe.substring(0,Q)}@${Oe} ${fe.substring(Le)}`,Se=Q+Oe.length+2;Y(Ce),u(!1),f(""),requestAnimationFrame(()=>{const Ke=S.current;Ke&&(Ke.selectionStart=Se,Ke.selectionEnd=Se,Ke.focus()),L(Ce,Se)})},e[16]=n.prompt,e[17]=Y,e[18]=I):I=e[18];const P=I;let A;e[19]!==n.prompt||e[20]!==Y?(A=oe=>{const fe=n.prompt,Le=S.current?.selectionStart??fe.length,Pe=fe.substring(0,Le).lastIndexOf("@"),Oe=Pe!==-1?Pe:Le,Q=`${fe.substring(0,Oe)}@${oe} ${fe.substring(Le)}`,Ce=Oe+oe.length+2;Y(Q),u(!1),f(""),requestAnimationFrame(()=>{const Se=S.current;Se&&(Se.selectionStart=Ce,Se.selectionEnd=Ce,Se.focus()),L(Q,Ce)})},e[19]=n.prompt,e[20]=Y,e[21]=A):A=e[21];const q=A;let K;e[22]!==Y?(K=oe=>{const fe=`/${oe.name} `;Y(fe),x(!1),k(""),m(!1),requestAnimationFrame(()=>{const ie=S.current;ie&&(ie.focus(),ie.selectionStart=ie.value.length,ie.selectionEnd=ie.value.length),L(fe,fe.length)})},e[22]=Y,e[23]=K):K=e[23];const te=K;let ae;e[24]!==n.prompt||e[25]!==Y?(ae=(oe,fe)=>{const ie=n.prompt,$e=S.current?.selectionStart??ie.length,Oe=ie.substring(0,$e).lastIndexOf("#"),Q=Oe!==-1?Oe:$e,Ce=`${ie.substring(0,Q)}#${fe} ${ie.substring($e)}`,Se=Q+fe.length+2;Y(Ce),m(!1),j(""),requestAnimationFrame(()=>{const Ke=S.current;Ke&&(Ke.selectionStart=Se,Ke.selectionEnd=Se,Ke.focus()),L(Ce,Se)})},e[24]=n.prompt,e[25]=Y,e[26]=ae):ae=e[26];const re=ae;let he;e[27]!==p||e[28]!==d||e[29]!==y?(he=oe=>{if(p&&C.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")){oe.preventDefault(),C.current.handleKeyDown(oe.key);return}d&&w.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),w.current.handleKeyDown(oe.key)),y&&v.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),v.current.handleKeyDown(oe.key))},e[27]=p,e[28]=d,e[29]=y,e[30]=he):he=e[30];const ce=he,Te=r+1;let ve;e[31]!==a||e[32]!==Te?(ve=a("multirun.launcher.groups.groupLabel",{index:Te}),e[31]=a,e[32]=Te,e[33]=ve):ve=e[33];let pe;e[34]!==ve?(pe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ve}),e[34]=ve,e[35]=pe):pe=e[35];let Ne;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(Ne=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=Ne):Ne=e[40];let U;e[41]!==pe||e[42]!==Ne?(U=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[pe,Ne]}),e[41]=pe,e[42]=Ne,e[43]=U):U=e[43];let Z;e[44]!==a?(Z=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=Z):Z=e[45];let de;e[46]!==Z?(de=s.jsx(Wn,{required:!0,children:Z}),e[46]=Z,e[47]=de):de=e[47];const ye=n.prompt;let H;e[48]!==Y?(H=oe=>{const fe=oe.target.value;Y(fe);const ie=oe.target.selectionStart??fe.length;L(fe,ie)},e[48]=Y,e[49]=H):H=e[49];let je;e[50]!==a?(je=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=je):je=e[51];let Ee;e[52]!==n.prompt||e[53]!==ce||e[54]!==H||e[55]!==je?(Ee=s.jsx(fr,{ref:S,value:ye,onChange:H,onKeyDown:ce,placeholder:je,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ce,e[54]=H,e[55]=je,e[56]=Ee):Ee=e[56];let ge;e[57]!==b||e[58]!==te||e[59]!==p?(ge=p?s.jsx(Hu,{ref:C,searchQuery:b,onCommandSelect:te,onClose:()=>x(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=b,e[58]=te,e[59]=p,e[60]=ge):ge=e[60];let ne;e[61]!==q||e[62]!==P||e[63]!==h||e[64]!==d?(ne=d?s.jsx(Gu,{ref:w,searchQuery:h,onFileSelect:P,onAgentSelect:q,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=q,e[62]=P,e[63]=h,e[64]=d,e[65]=ne):ne=e[65];let be;e[66]!==re||e[67]!==y||e[68]!==g?(be=y?s.jsx(qu,{ref:v,searchQuery:g,onSnippetSelect:re,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=re,e[67]=y,e[68]=g,e[69]=be):be=e[69];let G;e[70]!==Ee||e[71]!==ge||e[72]!==ne||e[73]!==be?(G=s.jsxs("div",{className:"relative",children:[Ee,ge,ne,be]}),e[70]=Ee,e[71]=ge,e[72]=ne,e[73]=be,e[74]=G):G=e[74];let z;e[75]!==de||e[76]!==G?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[de,G]}),e[75]=de,e[76]=G,e[77]=z):z=e[77];let J;e[78]!==a?(J=a("multirun.launcher.models.info"),e[78]=a,e[79]=J):J=e[79];let ue;e[80]!==J?(ue=s.jsx(Eo,{children:J}),e[80]=J,e[81]=ue):ue=e[81];let le;e[82]!==a?(le=a("multirun.launcher.models.label"),e[82]=a,e[83]=le):le=e[83];let W;e[84]!==ue||e[85]!==le?(W=s.jsx(Wn,{required:!0,info:ue,children:le}),e[84]=ue,e[85]=le,e[86]=W):W=e[86];let M;e[87]!==n.models||e[88]!==T||e[89]!==F||e[90]!==E?(M=s.jsx(nm,{selectedModels:n.models,onAdd:T,onRemove:F,onUpdate:E,minModels:1}),e[87]=n.models,e[88]=T,e[89]=F,e[90]=E,e[91]=M):M=e[91];let _;e[92]!==W||e[93]!==M?(_=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[W,M]}),e[92]=W,e[93]=M,e[94]=_):_=e[94];let ee;return e[95]!==U||e[96]!==z||e[97]!==_?(ee=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[U,z,_]}),e[95]=U,e[96]=z,e[97]=_,e[98]=ee):ee=e[98],ee};function vC(t){const e=[],n=(r,i)=>{const o=xt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const SC=t=>{const e=new Map;for(const n of t){const r=xs(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},jC=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},kC=t=>{const e=Ze.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=Wt(),h=SC(i),f=l.current?.runtimeKey===u?l.current.identities:null,p=Hd.getState().spaces;for(const x of jC(f,h)){const b=fh(x.directory),k=b===null?null:p.get(b);k&&k.state!=="complete"||yx({runtimeKey:u,...x})}l.current={runtimeKey:u,identities:h}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},CC=new Map,NC=t=>{const e=Ze.c(23),{isVSCode:n}=t,r=ni(),i=zt(AC),o=Jt(PC),l=nt(DC);let a;e[0]!==n?(a=T=>n?CC:T.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=nt(a),u=!n;let h;e[2]!==d||e[3]!==i||e[4]!==u?(h=um(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=h):h=e[5];const f=h,p=us(IC),x=us(TC),b=us(EC),k=`session-list-sync:${c.useId()}`;let y,m;e[6]!==k||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(k,vC({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(k)),m=[k,r,o,l],e[6]=k,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=m):(y=e[10],m=e[11]),c.useEffect(y,m);const g=c.useRef(null);let j,S;e[12]!==n||e[13]!==f?(j=()=>{const T=new Set(f),D=g.current;g.current=T;const F=D?[...T].filter(B=>!D.has(B)):n?[...T]:[];F.length&&Ba(F,Lo())},S=[n,f],e[12]=n,e[13]=f,e[14]=j,e[15]=S):(j=e[14],S=e[15]),c.useEffect(j,S);let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=[],e[16]=w):w=e[16],c.useEffect(RC,w);let C;e[17]!==x||e[18]!==p?(C=[...p,...x],e[17]=x,e[18]=p,e[19]=C):C=e[19];const v=C;let R;e[20]!==v||e[21]!==b?(R={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:v},e[20]=v,e[21]=b,e[22]=R):R=e[22],kC(R)};function AC(t){return t.projects}function PC(t){return t.currentDirectory}function DC(t){return t.currentSessionDirectory}function IC(t){return t.activeSessions}function TC(t){return t.archivedSessions}function EC(t){return t.status==="ready"}function RC(){let t=null,e=!1;const n=new Set,r=Pn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),ri(Lo());return}const o=[...n];n.clear(),o.length&&Ba(o,Lo())},500)});return()=>{t&&clearTimeout(t),r()}}const MC=Dn(()=>sn(()=>import("./SettingsWindow-DT1xhvgi.js"),__vite__mapDeps([146,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,147,84,85,86,148,132,133,134,135,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,149,150,151])).then(t=>({default:t.SettingsWindow}))),OC=()=>{const t=Ze.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],NC(e),rp();const n=Ae(BC),r=Ae(FC),i=Ae(LC),o=Ae(_C),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const h=Ae($C),f=Ae(zC),p=Ae(WC),x=Ae(KC),b=Ae(VC),k=Ae(UC),y=Ae(HC),m=Ae(GC),g=Ou();let j;if(t[4]!==g||t[5]!==m){let G;t[7]!==m?(G=z=>z.id===m,t[7]=m,t[8]=G):G=t[8],j=g.find(G),t[4]=g,t[5]=m,t[6]=j}else j=t[6];const S=j;let w,C;t[9]!==S||t[10]!==m?(w=()=>{m&&!S&&Ae.getState().setOpenGuestPage(null)},C=[m,S],t[9]=S,t[10]=m,t[11]=w,t[12]=C):(w=t[11],C=t[12]),c.useEffect(w,C);let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=[],t[13]=v):v=t[13],c.useEffect(YC,v);const R=x||b||k||!!y||h||!!S;let T;t[14]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[14]=T):T=t[14],c.useEffect(XC,T);const{isMobile:D}=Nn();op();let F,B;t[15]!==D||t[16]!==r?(F=()=>{Ae.getState().isMobile!==D&&r(D)},B=[D,r],t[15]=D,t[16]=r,t[17]=F,t[18]=B):(F=t[17],B=t[18]),c.useEffect(F,B);let E,$,L,X,Y;t[19]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(lj,{}),$=s.jsx(o0,{}),L=s.jsx(c0,{}),X=s.jsx(k4,{}),Y=s.jsx(Oy,{}),t[19]=E,t[20]=$,t[21]=L,t[22]=X,t[23]=Y):(E=t[19],$=t[20],L=t[21],X=t[22],Y=t[23]);let I;t[24]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(My,{}),t[24]=I):I=t[24];let P;t[25]!==n?(P=s.jsx(j4,{isVisible:n}),t[25]=n,t[26]=P):P=t[26];let A;t[27]!==D||t[28]!==n||t[29]!==P?(A=s.jsx(Ry,{isOpen:n,isMobile:D,className:"border-border",topBar:I,children:P}),t[27]=D,t[28]=n,t[29]=P,t[30]=A):A=t[30];let q;t[31]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(Ty,{}),t[31]=q):q=t[31];const K=R&&"invisible";let te;t[32]!==K?(te=Me("absolute inset-0",K),t[32]=K,t[33]=te):te=t[33];const ae=!i&&!R;let re;t[34]!==ae?(re=s.jsx(ps,{children:s.jsx(nu,{active:ae})}),t[34]=ae,t[35]=re):re=t[35];let he;t[36]!==te||t[37]!==re?(he=s.jsx("div",{className:te,children:re}),t[36]=te,t[37]=re,t[38]=he):he=t[38];let ce;t[39]!==h||t[40]!==p||t[41]!==f?(ce=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(yC,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[39]=h,t[40]=p,t[41]=f,t[42]=ce):ce=t[42];let Te;t[43]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx(ps,{children:s.jsx(X4,{})}),t[43]=Te):Te=t[43];let ve;t[44]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx(ps,{children:s.jsx(J4,{})}),t[44]=ve):ve=t[44];let pe;t[45]!==k?(pe=k&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(ip,{})})}),t[45]=k,t[46]=pe):pe=t[46];let Ne;t[47]===Symbol.for("react.memo_cache_sentinel")?(Ne=s.jsx(ps,{children:s.jsx(lC,{})}),t[47]=Ne):Ne=t[47];let U;t[48]!==S?(U=S&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(Nb,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:JC})})}),t[48]=S,t[49]=U):U=t[49];let Z;t[50]!==he||t[51]!==ce||t[52]!==pe||t[53]!==U?(Z=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[he,ce,Te,ve,pe,Ne,U]}),t[50]=he,t[51]=ce,t[52]=pe,t[53]=U,t[54]=Z):Z=t[54];let de;t[55]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(IS,{}),t[55]=de):de=t[55];let ye;t[56]!==Z?(ye=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[Z,de]})})}),t[56]=Z,t[57]=ye):ye=t[57];let H;t[58]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(ps,{children:s.jsx($S,{})})}),t[58]=H):H=t[58];let je;t[59]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(ps,{children:s.jsx(Zx,{})}),t[59]=je):je=t[59];let Ee;t[60]!==ye?(Ee=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[q,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ye,H,je]})]}),t[60]=ye,t[61]=Ee):Ee=t[61];let ge;t[62]!==A||t[63]!==Ee?(ge=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[A,Ee]}),t[62]=A,t[63]=Ee,t[64]=ge):ge=t[64];let ne;t[65]!==i||t[66]!==o||t[67]!==l?(ne=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(MC,{open:i,onOpenChange:o})}):null,t[65]=i,t[66]=o,t[67]=l,t[68]=ne):ne=t[68];let be;return t[69]!==ge||t[70]!==ne?(be=s.jsx(ap,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[E,$,L,X,Y,ge,ne]})}),t[69]=ge,t[70]=ne,t[71]=be):be=t[71],be};function BC(t){return t.isSidebarOpen}function FC(t){return t.setIsMobile}function LC(t){return t.isSettingsDialogOpen}function _C(t){return t.setSettingsDialogOpen}function $C(t){return t.isMultiRunLauncherOpen}function zC(t){return t.setMultiRunLauncherOpen}function WC(t){return t.multiRunLauncherPrefillPrompt}function KC(t){return t.isScheduledTasksDialogOpen}function VC(t){return t.isArchivePageOpen}function UC(t){return t.isUsageStatsPageOpen}function HC(t){return t.worktreesPageProjectId}function GC(t){return t.openGuestPageId}function qC(){return Ae.getState().setOpenGuestPage(null)}function YC(){return vr(qC)}function QC(){return Ae.getState().closeMainSurfaces()}function XC(){const t=QC,e=nt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function JC(){return Ae.getState().setOpenGuestPage(null)}const pm=12,ZC=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],e5=t=>{const e=Ze.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,h=l===void 0?ZC:l,f=ct.useRef(!1);let p,x;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},x=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=x):(p=e[2],x=e[3]),ct.useEffect(p,x);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:pm},t5),e[4]=b):b=e[4];const k=b;if(!n)return null;let y;e[5]!==i?(y=Me("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let j;e[11]!==d||e[12]!==u?(j=S=>{const w={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:w,children:k.map((C,v)=>{const R=C.x*S.radius,T=C.y*S.radius,D={"--translate-x":`${R}px`,"--translate-y":`${T}px`,"--particle-delay":`${C.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:D},`${S.id}-${v}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=j):j=e[13],m=h.map(j),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let g;return e[14]!==d||e[15]!==y||e[16]!==m?(g=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=y,e[16]=m,e[17]=g):g=e[17],g};function t5(t,e){const n=Math.PI*2*e/pm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const s5=t=>{const e=Ze.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ct.useState(o),d=ct.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const h=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(n5)},e[4]=f):f=e[4];const p=f;let x;e[5]!==i?(x=()=>{h(),a(r5),d.current=window.setTimeout(()=>{a(o5),d.current=null},i)},e[5]=i,e[6]=x):x=e[6];const b=x;let k,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>h(),y=[h],e[7]=k,e[8]=y):(k=e[7],y=e[8]),ct.useEffect(k,y);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==b?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:b,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=b,e[12]=m):m=e[12],m};function n5(t){return t.isActive?{...t,isActive:!1}:t}function r5(t){return{isActive:!0,cycle:t.cycle+1}}function o5(t){return t.isActive?{...t,isActive:!1}:t}const gm=c.createContext(void 0),i5=t=>{const e=Ze.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=s5();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(e5,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(gm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},rA=()=>{const t=c.useContext(gm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Da="openchamber_requests_in_flight",xm=1e3,a5=300*1e3,Yo=Math.ceil(a5/xm),l5=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Da)==="1"}catch{return!1}},bm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let c5=1;const d5=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},u5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},ym=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},yr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},f5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=c5++;d5(o,Date.now());try{return await e(r,i)}finally{u5(o)}};window.fetch=n},kd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Rr=t=>{t.length>Yo&&t.splice(0,t.length-Yo)},m5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=ym(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(yr(e,50)),t.p90Samples.push(yr(e,90)),t.p99Samples.push(yr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Rr(t.samples),Rr(t.p50Samples),Rr(t.p90Samples),Rr(t.p99Samples),Rr(t.maxSamples),t.lastSampleAt=Date.now()},h5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(m5,xm))},Cd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Nd=t=>{if(!(typeof window>"u"))try{if(t){Cd(),kd(),window.localStorage.setItem(Da,"1"),window.__openchamberRequestsInFlight__=bm(),f5(),h5();return}window.localStorage.removeItem(Da),Cd(),kd(),delete window.__openchamberRequestsInFlight__}catch{}},p5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=bm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},Ia=()=>{if(typeof window>"u")return Ad();const t=window.__openchamberRequestsInFlight__;if(!l5()||!t)return Ad();const e=ym(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:yr(e,50),ageP90:yr(e,90),ageP99:yr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Yo}},Ad=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Yo});function g5(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const wm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Ta=t=>`${(t/1e3).toFixed(2)} s`,ds=t=>{const e=Ze.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Pd=t=>{const e=Ze.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=St();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(y5,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?wm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let x;e[18]!==h||e[19]!==p?(x=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=x):x=e[20];let b;e[21]!==o?(b=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=b):b=e[22];let k;e[23]!==r.entries.length||e[24]!==b?(k=s.jsx(ds,{label:b,value:r.entries.length}),e[23]=r.entries.length,e[24]=b,e[25]=k):k=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let m;e[28]!==y||e[29]!==u?(m=s.jsx(ds,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=m):m=e[30];let g;e[31]!==o?(g=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=g):g=e[32];let j;e[33]!==r.lastUpdatedAt||e[34]!==o?(j=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=j):j=e[35];let S;e[36]!==g||e[37]!==j?(S=s.jsx(ds,{label:g,value:j}),e[36]=g,e[37]=j,e[38]=S):S=e[38];let w;e[39]!==m||e[40]!==S||e[41]!==k?(w=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[k,m,S]}),e[39]=m,e[40]=S,e[41]=k,e[42]=w):w=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[x,w,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(gn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Dd=t=>{const e=Ze.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(w5,0),u=r>0?52/r:0;let h;e[0]!==d||e[1]!==a?(h=S=>a-d+S,e[0]=d,e[1]=a,e[2]=h):h=e[2];const f=h;let p;e[3]!==u?(p=S=>56-S*u,e[3]=u,e[4]=p):p=e[4];const x=p;let b;e[5]!==l?(b=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=b):b=e[6];const k=`0 0 ${a} 56`;let y;e[7]!==a?(y=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=y):y=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==x){let S;e[13]!==f||e[14]!==x?(S=(w,C)=>{const v=w.samples.length;if(v===0)return null;const R=w.samples.map((D,F)=>`${f(F)},${x(D).toFixed(2)}`),T=`M ${R.join(" L ")}`;return s.jsxs(c.Fragment,{children:[w.filled?s.jsx("path",{d:`M ${f(0)},56 L ${R.join(" L ")} L ${f(v-1)},56 Z`,fill:`color-mix(in srgb, ${w.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:T,fill:"none",stroke:w.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=x,e[15]=S):S=e[15],m=n.map(S),e[9]=n,e[10]=f,e[11]=x,e[12]=m}else m=e[12];let g;e[16]!==o||e[17]!==k||e[18]!==y||e[19]!==m?(g=s.jsxs("svg",{viewBox:k,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,m]}),e[16]=o,e[17]=k,e[18]=y,e[19]=m,e[20]=g):g=e[20];let j;return e[21]!==b||e[22]!==g?(j=s.jsxs("div",{className:"relative w-full",children:[b,g]}),e[21]=b,e[22]=g,e[23]=j):j=e[23],j},x5=t=>{const e=Ze.c(100),{onClose:n}=t,{t:r}=St(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=nt(v5),u=Ku(S5),h=Pu(),f=wx(j5),p=Ms(k5),[x,b]=c.useState(C5),[k,y]=c.useState(N5),[m,g]=c.useState(A5),j=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let S;e[0]!==m.samples?(S=m.samples.reduce(P5,0),e[0]=m.samples,e[1]=S):S=e[1];const w=S,C=j.reduce(I5,0);let v;e[2]!==x.entries?(v=new Map,x.entries.forEach(Se=>{v.set(Se.metric,Se.count)}),e[2]=x.entries,e[3]=v):v=e[3];let R;e[4]!==v?(R=v.get("ui.message_list.render")??0,e[4]=v,e[5]=R):R=e[5];let T;e[6]!==v?(T=v.get("ui.message_list.render.streaming")??0,e[6]=v,e[7]=T):T=e[7];let D;e[8]!==v?(D=v.get("ui.chat_message.render")??0,e[8]=v,e[9]=D):D=e[9];let F;e[10]!==v?(F=v.get("ui.chat_message.render.streaming")??0,e[10]=v,e[11]=F):F=e[11];let B;e[12]!==v?(B=v.get("ui.chat_message.render.static_during_stream")??0,e[12]=v,e[13]=B):B=e[13];let E;e[14]!==v?(E=v.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=v,e[15]=E):E=e[15];let $;e[16]!==R||e[17]!==T||e[18]!==D||e[19]!==F||e[20]!==B||e[21]!==E?($={messageListRender:R,messageListRenderStreaming:T,chatMessageRender:D,chatMessageRenderStreaming:F,chatMessageRenderStaticDuringStream:B,chatMessageRenderStaticOutsideActiveTurnDuringStream:E},e[16]=R,e[17]=T,e[18]=D,e[19]=F,e[20]=B,e[21]=E,e[22]=$):$=e[22];const L=$;let X,Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>{const Se=()=>{b(ko()),y(Co()),g(Ia())};Se();const Ke=window.setInterval(Se,500);return()=>window.clearInterval(Ke)},X=[],e[23]=X,e[24]=Y):(X=e[23],Y=e[24]),c.useEffect(Y,X);let I,P;e[25]!==l?(I=()=>{if(l==="idle")return;const Se=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Se)},P=[l],e[25]=l,e[26]=I,e[27]=P):(I=e[26],P=e[27]),c.useEffect(I,P);let A=0,q=0,K=0;for(const Se of Object.keys(f)){const Ke=f[Se]??[];q=q+Ke.length;for(const et of Ke)et.role==="user"?K=K+1:et.role==="assistant"&&(A=A+1)}let te;e[28]!==A||e[29]!==q||e[30]!==K?(te={assistant:A,total:q,user:K},e[28]=A,e[29]=q,e[30]=K,e[31]=te):te=e[31];const ae=te;let re;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==h||e[36]!==r){let Se;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Se=Ke=>{const et=f[Ke.id]??[];let it=0,rt=0;for(const ht of et)ht.role==="user"?rt=rt+1:ht.role==="assistant"&&(it=it+1);const pt=u.get(Ke.id);return{id:Ke.id,title:Ke.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:it,messageCount:et.length,userMessageCount:rt,isStreaming:pt?.isStreaming||!1,isZombie:pt?.isZombie||!1,backgroundCount:pt?.backgroundMessageCount||0,lastAccessed:pt?.lastAccessedAt||0,isCurrent:Ke.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Se):Se=e[42],re=h.map(Se).sort(T5),e[32]=d,e[33]=f,e[34]=u,e[35]=h,e[36]=r,e[37]=re}else re=e[37];const he=re;let ce;e[43]!==f?(ce=Object.keys(f),e[43]=f,e[44]=ce):ce=e[44];const Te=ce.length;let ve;e[45]===Symbol.for("react.memo_cache_sentinel")?(ve=async()=>{try{const Se={generatedAt:new Date().toISOString(),ui:ko(),vscode:Co()};await navigator.clipboard.writeText(JSON.stringify(Se,null,2)),a("copied")}catch{a("error")}},e[45]=ve):ve=e[45];const pe=ve,Ne=Sx,U="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let Z;e[46]===Symbol.for("react.memo_cache_sentinel")?(Z={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=Z):Z=e[46];let de;e[47]!==i?(de=g5(i),e[47]=i,e[48]=de):de=e[48];let ye;e[49]!==de?(ye=s.jsx(O,{name:de,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=de,e[50]=ye):ye=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let je;e[53]!==H?(je=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=je):je=e[54];let Ee;e[55]!==ye||e[56]!==je?(Ee=s.jsxs("div",{className:"flex items-center gap-2",children:[ye,je]}),e[55]=ye,e[56]=je,e[57]=Ee):Ee=e[57];let ge;e[58]!==i?(ge=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ut,{size:"xs",variant:"ghost",onClick:pe,children:s.jsx(O,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{mh(),b(ko()),y(Co())},children:s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=ge):ge=e[59];let ne;e[60]!==i?(ne=i==="requests"?s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{p5(),g(Ia())},children:s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=ne):ne=e[61];let be;e[62]!==n?(be=n?s.jsx(ut,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=be):be=e[63];let G;e[64]!==ge||e[65]!==ne||e[66]!==be?(G=s.jsxs("div",{className:"flex items-center gap-1",children:[ge,ne,be]}),e[64]=ge,e[65]=ne,e[66]=be,e[67]=G):G=e[67];let z;e[68]!==Ee||e[69]!==G?(z=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Ee,G]}),e[68]=Ee,e[69]=G,e[70]=z):z=e[70];let J;e[71]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=J):J=e[71];const ue=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let W;e[73]!==r?(W=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=W):W=e[74];let M;e[75]!==ue||e[76]!==W?(M=s.jsx(ut,{size:"sm",variant:ue,className:"flex-1",onClick:le,children:W}),e[75]=ue,e[76]=W,e[77]=M):M=e[77];const _=i==="streaming"?"secondary":"ghost";let ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>o("streaming"),e[78]=ee):ee=e[78];let oe;e[79]!==r?(oe=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=oe):oe=e[80];let fe;e[81]!==_||e[82]!==oe?(fe=s.jsx(ut,{size:"sm",variant:_,className:"flex-1",onClick:ee,children:oe}),e[81]=_,e[82]=oe,e[83]=fe):fe=e[83];const ie=i==="requests"?"secondary":"ghost";let Le;e[84]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>o("requests"),e[84]=Le):Le=e[84];let $e;e[85]!==r?($e=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=$e):$e=e[86];let Pe;e[87]!==ie||e[88]!==$e?(Pe=s.jsx(ut,{size:"sm",variant:ie,className:"flex-1",onClick:Le,children:$e}),e[87]=ie,e[88]=$e,e[89]=Pe):Pe=e[89];let Oe;e[90]!==M||e[91]!==fe||e[92]!==Pe?(Oe=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:J,children:[M,fe,Pe]}),e[90]=M,e[91]=fe,e[92]=Pe,e[93]=Oe):Oe=e[93];const Q=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ds,{label:r("memoryDebugPanel.metric.totalMessages"),value:ae.total}),s.jsx(ds,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Te} / ${Vl.MAX_SESSIONS}`}),s.jsx(ds,{label:r("memoryDebugPanel.metric.userMessages"),value:ae.user}),s.jsx(ds,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ae.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:vx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Vl.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(gn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:he.map(Se=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Se.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Se.title}),Se.isStreaming?s.jsx(O,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Se.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Se.assistantMessageCount,user:Se.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Se.messageCount})}),Se.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Se.backgroundCount]}):null]})]},Se.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(E5),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:ae,sessionMessageRoleCounts:he.map(R5),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(wt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(ut,{size:"xs",variant:"outline",onClick:pe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ds,{label:r("memoryDebugPanel.metric.uiMetrics"),value:x.entries.length}),s.jsx(ds,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:k.entries.length}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Pd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:x,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),k.entries.length>0?s.jsx(Pd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:k,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ds,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(ds,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?wm(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(Dd,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:w,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${w}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ta(m.peakAgeMs)})]}),s.jsx(Dd,{series:j.map(M5),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ta(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map(O5)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ce;return e[94]!==Ne||e[95]!==Z||e[96]!==z||e[97]!==Oe||e[98]!==Q?(Ce=s.jsxs(Ne,{className:U,style:Z,children:[z,Oe,Q]}),e[94]=Ne,e[95]=Z,e[96]=z,e[97]=Oe,e[98]=Q,e[99]=Ce):Ce=e[99],Ce},b5=x5;function y5(t,e){return t+e.count}function w5(t,e){return Math.max(t,e.samples.length)}function v5(t){return t.currentSessionId}function S5(t){return t.sessionMemoryState}function j5(t){return t.message}function k5(t){return t.totalRequestCount}function C5(){return ko()}function N5(){return Co()}function A5(){return Ia()}function P5(t,e){return Math.max(t,e)}function D5(t,e){return Math.max(t,e)}function I5(t,e){return e.samples.reduce(D5,t)}function T5(t,e){return e.lastAccessed-t.lastAccessed}function E5(t){return{id:t.id,title:t.title}}function R5(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function M5(t){return{samples:t.samples,color:t.color}}function O5(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ta(t.current)})]},t.label)}const B5=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},F5=async()=>{const t=B5()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Id="openchamber:menu-action",zi="openchamber:check-for-updates",L5=t=>{const e=nt(m=>m.openNewSessionDraft),n=Ae(m=>m.toggleCommandPalette),r=Ae(m=>m.setCommandPaletteOpen),i=Ae(m=>m.toggleHelpDialog),o=Ae(m=>m.toggleSidebar),l=Ae(m=>m.setSessionSwitcherOpen),a=Ae(m=>m.setSettingsDialogOpen),d=Ae(m=>m.setAboutDialogOpen),u=_r(m=>m.checkForUpdates),{setThemeMode:h}=Cn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:m,error:g}=_r.getState();if(g){ze.error("Failed to check for updates",{description:g});return}m||ze.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),x=c.useCallback(()=>{Qs.requestDirectoryDialog()},[]),b=c.useCallback(m=>{const g=jx();if(g.length===0)return;const j=nt.getState().currentSessionId,S=g.findIndex(v=>v.id===j);let w=m>0?0:g.length-1;S>=0&&(w=(S+m+g.length)%g.length);const C=g[w];C&&(l(!1),nt.getState().setCurrentSession(C.id))},[l]),k=c.useCallback(m=>{const{activeProjectId:g,projects:j,setActiveProject:S}=zt.getState();if(j.length===0)return;const w=j.findIndex(R=>R.id===g);let C=m>0?0:j.length-1;w>=0&&(C=(w+m+j.length)%j.length);const v=j[C];v&&S(v.id)},[]),y=c.useCallback(m=>{switch(m){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const g=nt.getState(),j=Jt.getState().currentDirectory;e(g.currentSessionId&&j?{directoryOverride:j}:void 0)}break;case"new-worktree-session":l(!1),Ru();break;case"change-workspace":x();break;case"toggle-right-sidebar":{const g=Jt.getState().currentDirectory;if(!g)break;const j=Ae.getState(),S=$n(g),w=j.contextPanelByDirectory[S];w?.isOpen?j.closeContextPanel(S):w?.activeTabId?j.setActiveContextPanelTab(S,w.activeTabId):j.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"git");break}case"open-right-sidebar-files":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"file");break}case"toggle-terminal":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"terminal");break}case"toggle-terminal-expanded":{const g=Jt.getState().currentDirectory;if(!g)break;const j=$n(g),S=Ae.getState(),w=S.contextPanelByDirectory[j];(w?.isOpen?w.tabs.find(v=>v.id===w.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(j,"terminal"),S.toggleContextPanelExpanded(j);break}case"copy":{const g=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(g)||F5();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":kx();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Jt.getState().goBack();break;case"go-forward":Jt.getState().goForward();break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":k(-1);break;case"next-project":k(1);break;case"help-dialog":i();break;case"download-logs":{Mu().catch(()=>{ze.error("Failed to collect OpenCode status")});break}}},[x,k,b,t,e,d,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=j=>{const S=j.detail;S&&y(S)},g=()=>{p()};return window.addEventListener(Id,m),window.addEventListener(zi,g),()=>{window.removeEventListener(Id,m),window.removeEventListener(zi,g)}},[y,p]),c.useEffect(()=>{if(typeof window>"u")return;const g=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof g!="function")return;let j=null,S=null;return g("openchamber:menu-action",w=>{const C=w?.payload;typeof C=="string"&&y(C)}).then(w=>{j=w}).catch(()=>{}),g("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(zi))}).then(w=>{S=w}).catch(()=>{}),()=>{(async()=>{try{const C=j?.();C instanceof Promise&&await C}catch{}try{const C=S?.();C instanceof Promise&&await C}catch{}})()}},[y])},_5="openchamber:tray-action",$5=5e3,z5=500,W5=20,Td=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ed=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,vm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Sm=t=>t.title.trim()||"Question",K5=(t,e)=>Qa(t,e,Hr.getState().ids,Va.getState().rankById),V5=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},U5=(t,e,n,r,i)=>{if(!t)return"";const o=ou(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||V5(t),d=No(t);let u=d&&i.get(d)||"";if(!u){for(const[h,f]of pn.getState().directories)if(No(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(p=>No(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},H5=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Nx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:Px(h),value:Ax(f.valueLabel,p)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},G5=async()=>{try{if(Qo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=mn();if(e&&yl(e,t))return"Local OpenChamber";const r=(await Ld()).hosts.find(i=>e?yl(e,hh(i)):!1);return r?.label?.trim()?_d(r.label.trim()):"Instance"}catch{return""}},q5=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=ra()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(No(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const h=u?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:vm(h),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"form",id:h.id,sessionId:f,sessionTitle:"",label:Sm(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Y5=(t,e)=>{const n=Ga.getState().index.session,r=us.getState().activeSessions,i=new Map;for(const g of r)if(g?.id&&g.parentID){const j=i.get(g.parentID)??[];j.push(g.id),i.set(g.parentID,j)}const o=g=>{const j=[],S=[...i.get(g)??[]],w=new Set;for(;S.length;){const C=S.pop();w.has(C)||(w.add(C),j.push(C),S.push(...i.get(C)??[]))}return j},l=Ae.getState();let a=0;if(l.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let j=n.unseenCount[g.id]??0;j===0&&l.notifyOnSubtasks&&(j=o(g.id).reduce((S,w)=>S+(n.unseenCount[w]??0),0)),j>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=q5(),u=new Map(d.titleById);for(const g of r)g?.id&&g.title&&u.set(g.id,g.title);const h=Zo.getState().statusById,f=g=>{const j=d.statusById.get(g);return j&&j!=="idle"?j:h.get(g)?.status.type??j??"idle"},p=g=>{const j=g.map(S=>f(S));return j.includes("busy")?"busy":j.includes("retry")?"retry":"idle"},x=zt.getState().projects,b=nt.getState().availableWorktreesByProject,k=r.filter(g=>g?.id&&!g.parentID).slice().sort(K5).slice(0,W5).map(g=>{const j=[g.id,...o(g.id)],S=xs(g)??"";return{id:g.id,title:g.title||"Untitled session",status:p(j),branch:S?d.branchByDirectory.get(S)??"":"",unseen:j.reduce((w,C)=>w+(n.unseenCount[C]??0),0),hasError:j.some(w=>n.unseenHasError[w]??!1),directory:S,subtitle:U5(S,g,x,b,d.branchByDirectory)}}),y=d.approvals.map(g=>({...g,sessionTitle:u.get(g.sessionId)||""})),m=new Set(y.map(g=>g.id));for(const[g,j]of qa.getState().bySession){const S=u.get(g)||"";for(const w of j.permissions)m.has(w.id)||(m.add(w.id),y.push({kind:"permission",id:w.id,sessionId:g,sessionTitle:S,label:vm(w),directory:j.directory}));for(const w of j.forms)m.has(w.id)||(m.add(w.id),y.push({kind:"form",id:w.id,sessionId:g,sessionTitle:S,label:Sm(w),directory:j.directory}))}return{sessions:k,approvals:y,instanceName:t,usage:H5(),dockBadgeCount:a}},Q5=()=>{c.useEffect(()=>{if(!Td()||!Vr())return;const t=Ed();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const v=Y5(i,t),R=JSON.stringify(v);R!==n&&(n=R,jn("desktop_tray_update",v))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},z5))},a=Ga.subscribe(()=>l()),d=us.subscribe(()=>l()),u=Ae.subscribe((v,R)=>{(v.dockBadgeEnabled!==R.dockBadgeEnabled||v.notifyOnSubtasks!==R.notifyOnSubtasks)&&l()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),h;G5().then(v=>{e||(i=v,o())});const f=new Map,p=()=>{if(e)return;let v;try{v=ra()}catch{return}const R=new Set;for(const[T,D]of v.children.entries())R.add(T),f.has(T)||f.set(T,D.subscribe(()=>l()));for(const[T,D]of f)R.has(T)||(D(),f.delete(T))};let x=null;try{x=ra().subscribeRegistry(()=>{p(),l()})}catch{}p();const b=zt.subscribe(()=>l()),k=nt.subscribe(()=>l()),y=pn.subscribe(()=>l()),m=Zo.subscribe(()=>l()),g=qa.subscribe(()=>l()),j=Va.subscribe(()=>l()),S=Hr.subscribe(()=>l()),w=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:v,results:R}=ur.getState();v.length>0&&v.some(D=>!R.some(F=>F.providerId===D))&&ur.getState().fetchQuotas(v)});const C=window.setInterval(()=>{p(),o()},$5);return o(),()=>{h(),window.clearInterval(C),b(),k(),y(),m(),g(),j(),S(),w(),x?.();for(const v of f.values())v();f.clear()}},[]),c.useEffect(()=>{if(!Td()||!Ed()||!Vr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Cx(i.sessionId,i.id,i.response).catch(()=>{ze.error("Failed to respond to permission request")})};let r=null;return e(_5,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},X5=30*6e4,J5=(t,e,n=X5)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Mr=null;const Z5=()=>{if(Mr)return Mr;const t=Wt();return Mr=(async()=>{const e=await Vs.getHostSessionStatusSnapshot();if(!e||Wt()!==t)return;const n=Zo.getState(),r=us.getState().entityById,i=J5(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?xs(a):null}});for(const[l,a]of i)Dx(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?xs(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Ix(o)})().finally(()=>{Mr=null}),Mr},eN=45e3,tN=[1e3,2e3,4e3],sN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const h=await u().catch(()=>!1);if(i)return;a||=h;const f=a?void 0:tN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??eN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},nN=t=>{const e=Ze.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=rN;let o=i();const l=vr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function rN(){const t=Wt();let e=!0;const n=async i=>(i?await Tx(Lo()):await ri(),!e||Wt()!==t?!1:(Z5(),us.getState().status==="ready")),r=sN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const oN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,iN=t=>{const e=Ze.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||en()||!Ra()||!globalThis.window))return Pn(aN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function aN(t){if(t.type!=="notification")return;const e=Ae.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&oN())return;Fd()?.notifications?.notifyAgentCompletion(t.payload)}const lN=6e4,cN=t=>{const e=Ze.c(10),n=Ae(dN),r=Ex(uN),o=lp(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:lN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Pn(h=>{h.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function dN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function uN(t){return t.load}const fN=()=>{const t=Ze.c(4),{t:e}=St(),n=Ae(mN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Pn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),ze.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function mN(t){return t.setBrowserProvider}const Rd="pwa-install-toast-shown",Md="pwa-install-toast-dismissed",hN=()=>{const t=Ze.c(6),{browserTab:e}=cp(),{t:n}=St(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!Ra()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(ze.dismiss(u),u=null)},f=async()=>{if(!d)return;const b=d;d=null,h(),await b.prompt();const{outcome:k}=await b.userChoice;k==="accepted"&&ze.success(r.current("pwa.installPrompt.started"))},p=b=>{const k=b;if(typeof k.prompt!="function")return;k.preventDefault(),d=k;const y=Mo(),m=ph();dp({dismissed:y.getItem(Md),sessionShown:m.getItem(Rd),hasActiveToast:u!==null})&&(m.setItem(Rd,"true"),u=ze.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Mo().setItem(Md,"true"),h()}}}))},x=()=>{d=null,h(),ze.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",x),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",x)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},pN=({open:t,onOpenChange:e})=>{const{t:n}=St(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[h,f]=c.useState(!1),[p,x]=c.useState(null),[b,k]=c.useState(!1);c.useCallback(async()=>{},[p,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const g=await ls("/api/system/info");if(g.ok){const j=await g.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){o(j.openchamberVersion);return}}}catch{}o(await Rx())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const j=await ls("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!j.ok)return;const S=await j.json().catch(()=>null),w=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!m&&w&&a(w)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{x(null),k(!1);return}},[t,r]);const y=i;return s.jsx(bs,{open:t,onOpenChange:e,children:s.jsx(ys,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Du,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ea="project-config-invalid",gN=()=>{const t=Ze.c(9),{t:e}=St(),n=Lt(xN);let r;t[0]!==n?(r=p=>p.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const i=Lt(r),[o,l]=ct.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const p=Lt.getState(),x=p.activeDirectoryKey;l(!0),Promise.all([p.loadProviders({directory:x,source:"projectConfigError:retry"}),p.loadAgents({directory:x,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,h;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){ze.dismiss(Ea);return}ze.error(e("projectConfigError.toast.title"),{id:Ea,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&s.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),o||d()}}})},h=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=h):(u=t[6],h=t[7]),ct.useEffect(u,h);let f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[8]=f):f=t[8],ct.useEffect(yN,f),null};function xN(t){return t.activeDirectoryKey}function bN(){ze.dismiss(Ea)}function yN(){return bN}const wN="\x1B",vN=new RegExp(`${wN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),jo=Xn().transform(t=>t.replace(vN,"").trim()).nullish(),SN=Zl({isOpenCodeReady:ec().optional(),openCodeRunning:ec().optional(),lastOpenCodeError:jo,opencodeBinaryResolved:jo,lastOpenCodeLaunchDiagnostics:Zl({sourceBinary:jo,binary:jo}).nullish()}),jN=async(t,e=ls)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=SN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},kN=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},Od=Dn(()=>sn(()=>import("./OnboardingScreen-Wr_UzNtt.js"),__vite__mapDeps([152,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])).then(t=>({default:t.OnboardingScreen}))),CN=()=>{const t=Ze.c(3),e=Ae(TN),n=Ae(EN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(pN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},NN=t=>{const e=Ze.c(33),{onRetry:n,isRetrying:r}=t,{t:i}=St(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const w=new AbortController,C=Wt(),v=setTimeout(()=>w.abort(),5e3);return jN(w.signal).then(R=>{!w.signal.aborted&&Wt()===C&&l(R)}).catch(RN).finally(()=>clearTimeout(v)),()=>{w.abort(),clearTimeout(v)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=Lt(MN),h=o?null:u?.message??null;let f;e[2]!==i?(f=i("startup.initRecovery.title"),e[2]=i,e[3]=f):f=e[3];let p;e[4]!==f?(p=s.jsx("h1",{className:"typography-title text-foreground",children:f}),e[4]=f,e[5]=p):p=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==i?(x=i(kN(o,u)),e[6]=o,e[7]=u,e[8]=i,e[9]=x):x=e[9];let b;e[10]!==x?(b=s.jsx("p",{className:"typography-body text-muted-foreground",children:x}),e[10]=x,e[11]=b):b=e[11];let k;e[12]!==p||e[13]!==b?(k=s.jsxs("div",{className:"flex flex-col gap-2",children:[p,b]}),e[12]=p,e[13]=b,e[14]=k):k=e[14];let y;e[15]!==h||e[16]!==i?(y=h&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:h})]}),e[15]=h,e[16]=i,e[17]=y):y=e[17];let m;e[18]!==o||e[19]!==i?(m=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=m):m=e[20];let g;e[21]!==r||e[22]!==i?(g=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=g):g=e[23];let j;e[24]!==r||e[25]!==n||e[26]!==g?(j=s.jsx(ut,{type:"button",onClick:n,disabled:r,children:g}),e[24]=r,e[25]=n,e[26]=g,e[27]=j):j=e[27];let S;return e[28]!==j||e[29]!==k||e[30]!==y||e[31]!==m?(S=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[k,y,m,j]})}),e[28]=j,e[29]=k,e[30]=y,e[31]=m,e[32]=S):S=e[32],S},Bd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",AN=()=>{if(typeof window>"u"||!Cb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},PN=t=>{const e=Ze.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=Jt(ON),l=nt(BN),a=nt(FN),d=_x(),u=c.useRef(null);let h;e[0]!==n.directory?(h=Bd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let p;e[2]!==o?(p=Bd(o),e[2]=o,e[3]=p):p=e[3];const x=p;let b,k;if(e[4]!==x||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(b=()=>{if(r||f&&x!==f)return;const w=`${f}
895
+ `)?(f(Oe),u(!0)):u(!1);return}u(!1)},e[12]=$):$=e[12];const L=$;let X;e[13]!==n.id||e[14]!==o?(X=oe=>{o(n.id,{prompt:oe})},e[13]=n.id,e[14]=o,e[15]=X):X=e[15];const Y=X;let I;e[16]!==n.prompt||e[17]!==Y?(I=oe=>{const fe=n.prompt,Le=S.current?.selectionStart??fe.length,Pe=fe.substring(0,Le).lastIndexOf("@"),Oe=oe.relativePath&&oe.relativePath.trim().length>0?oe.relativePath.trim():oe.path||oe.name,Q=Pe!==-1?Pe:Le,Ce=`${fe.substring(0,Q)}@${Oe} ${fe.substring(Le)}`,Se=Q+Oe.length+2;Y(Ce),u(!1),f(""),requestAnimationFrame(()=>{const Ke=S.current;Ke&&(Ke.selectionStart=Se,Ke.selectionEnd=Se,Ke.focus()),L(Ce,Se)})},e[16]=n.prompt,e[17]=Y,e[18]=I):I=e[18];const P=I;let A;e[19]!==n.prompt||e[20]!==Y?(A=oe=>{const fe=n.prompt,Le=S.current?.selectionStart??fe.length,Pe=fe.substring(0,Le).lastIndexOf("@"),Oe=Pe!==-1?Pe:Le,Q=`${fe.substring(0,Oe)}@${oe} ${fe.substring(Le)}`,Ce=Oe+oe.length+2;Y(Q),u(!1),f(""),requestAnimationFrame(()=>{const Se=S.current;Se&&(Se.selectionStart=Ce,Se.selectionEnd=Ce,Se.focus()),L(Q,Ce)})},e[19]=n.prompt,e[20]=Y,e[21]=A):A=e[21];const q=A;let K;e[22]!==Y?(K=oe=>{const fe=`/${oe.name} `;Y(fe),x(!1),k(""),m(!1),requestAnimationFrame(()=>{const ie=S.current;ie&&(ie.focus(),ie.selectionStart=ie.value.length,ie.selectionEnd=ie.value.length),L(fe,fe.length)})},e[22]=Y,e[23]=K):K=e[23];const te=K;let ae;e[24]!==n.prompt||e[25]!==Y?(ae=(oe,fe)=>{const ie=n.prompt,$e=S.current?.selectionStart??ie.length,Oe=ie.substring(0,$e).lastIndexOf("#"),Q=Oe!==-1?Oe:$e,Ce=`${ie.substring(0,Q)}#${fe} ${ie.substring($e)}`,Se=Q+fe.length+2;Y(Ce),m(!1),j(""),requestAnimationFrame(()=>{const Ke=S.current;Ke&&(Ke.selectionStart=Se,Ke.selectionEnd=Se,Ke.focus()),L(Ce,Se)})},e[24]=n.prompt,e[25]=Y,e[26]=ae):ae=e[26];const re=ae;let he;e[27]!==p||e[28]!==d||e[29]!==y?(he=oe=>{if(p&&C.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")){oe.preventDefault(),C.current.handleKeyDown(oe.key);return}d&&w.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),w.current.handleKeyDown(oe.key)),y&&v.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),v.current.handleKeyDown(oe.key))},e[27]=p,e[28]=d,e[29]=y,e[30]=he):he=e[30];const ce=he,Te=r+1;let ve;e[31]!==a||e[32]!==Te?(ve=a("multirun.launcher.groups.groupLabel",{index:Te}),e[31]=a,e[32]=Te,e[33]=ve):ve=e[33];let pe;e[34]!==ve?(pe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ve}),e[34]=ve,e[35]=pe):pe=e[35];let Ne;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(Ne=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=Ne):Ne=e[40];let U;e[41]!==pe||e[42]!==Ne?(U=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[pe,Ne]}),e[41]=pe,e[42]=Ne,e[43]=U):U=e[43];let Z;e[44]!==a?(Z=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=Z):Z=e[45];let de;e[46]!==Z?(de=s.jsx(Wn,{required:!0,children:Z}),e[46]=Z,e[47]=de):de=e[47];const ye=n.prompt;let H;e[48]!==Y?(H=oe=>{const fe=oe.target.value;Y(fe);const ie=oe.target.selectionStart??fe.length;L(fe,ie)},e[48]=Y,e[49]=H):H=e[49];let je;e[50]!==a?(je=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=je):je=e[51];let Ee;e[52]!==n.prompt||e[53]!==ce||e[54]!==H||e[55]!==je?(Ee=s.jsx(fr,{ref:S,value:ye,onChange:H,onKeyDown:ce,placeholder:je,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ce,e[54]=H,e[55]=je,e[56]=Ee):Ee=e[56];let ge;e[57]!==b||e[58]!==te||e[59]!==p?(ge=p?s.jsx(Hu,{ref:C,searchQuery:b,onCommandSelect:te,onClose:()=>x(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=b,e[58]=te,e[59]=p,e[60]=ge):ge=e[60];let ne;e[61]!==q||e[62]!==P||e[63]!==h||e[64]!==d?(ne=d?s.jsx(Gu,{ref:w,searchQuery:h,onFileSelect:P,onAgentSelect:q,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=q,e[62]=P,e[63]=h,e[64]=d,e[65]=ne):ne=e[65];let be;e[66]!==re||e[67]!==y||e[68]!==g?(be=y?s.jsx(qu,{ref:v,searchQuery:g,onSnippetSelect:re,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=re,e[67]=y,e[68]=g,e[69]=be):be=e[69];let G;e[70]!==Ee||e[71]!==ge||e[72]!==ne||e[73]!==be?(G=s.jsxs("div",{className:"relative",children:[Ee,ge,ne,be]}),e[70]=Ee,e[71]=ge,e[72]=ne,e[73]=be,e[74]=G):G=e[74];let z;e[75]!==de||e[76]!==G?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[de,G]}),e[75]=de,e[76]=G,e[77]=z):z=e[77];let J;e[78]!==a?(J=a("multirun.launcher.models.info"),e[78]=a,e[79]=J):J=e[79];let ue;e[80]!==J?(ue=s.jsx(Eo,{children:J}),e[80]=J,e[81]=ue):ue=e[81];let le;e[82]!==a?(le=a("multirun.launcher.models.label"),e[82]=a,e[83]=le):le=e[83];let W;e[84]!==ue||e[85]!==le?(W=s.jsx(Wn,{required:!0,info:ue,children:le}),e[84]=ue,e[85]=le,e[86]=W):W=e[86];let M;e[87]!==n.models||e[88]!==T||e[89]!==F||e[90]!==E?(M=s.jsx(nm,{selectedModels:n.models,onAdd:T,onRemove:F,onUpdate:E,minModels:1}),e[87]=n.models,e[88]=T,e[89]=F,e[90]=E,e[91]=M):M=e[91];let _;e[92]!==W||e[93]!==M?(_=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[W,M]}),e[92]=W,e[93]=M,e[94]=_):_=e[94];let ee;return e[95]!==U||e[96]!==z||e[97]!==_?(ee=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[U,z,_]}),e[95]=U,e[96]=z,e[97]=_,e[98]=ee):ee=e[98],ee};function vC(t){const e=[],n=(r,i)=>{const o=xt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const SC=t=>{const e=new Map;for(const n of t){const r=xs(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},jC=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},kC=t=>{const e=Ze.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=Wt(),h=SC(i),f=l.current?.runtimeKey===u?l.current.identities:null,p=Hd.getState().spaces;for(const x of jC(f,h)){const b=fh(x.directory),k=b===null?null:p.get(b);k&&k.state!=="complete"||yx({runtimeKey:u,...x})}l.current={runtimeKey:u,identities:h}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},CC=new Map,NC=t=>{const e=Ze.c(23),{isVSCode:n}=t,r=ni(),i=zt(AC),o=Jt(PC),l=nt(DC);let a;e[0]!==n?(a=T=>n?CC:T.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=nt(a),u=!n;let h;e[2]!==d||e[3]!==i||e[4]!==u?(h=um(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=h):h=e[5];const f=h,p=us(IC),x=us(TC),b=us(EC),k=`session-list-sync:${c.useId()}`;let y,m;e[6]!==k||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(k,vC({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(k)),m=[k,r,o,l],e[6]=k,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=m):(y=e[10],m=e[11]),c.useEffect(y,m);const g=c.useRef(null);let j,S;e[12]!==n||e[13]!==f?(j=()=>{const T=new Set(f),D=g.current;g.current=T;const F=D?[...T].filter(B=>!D.has(B)):n?[...T]:[];F.length&&Ba(F,Lo())},S=[n,f],e[12]=n,e[13]=f,e[14]=j,e[15]=S):(j=e[14],S=e[15]),c.useEffect(j,S);let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=[],e[16]=w):w=e[16],c.useEffect(RC,w);let C;e[17]!==x||e[18]!==p?(C=[...p,...x],e[17]=x,e[18]=p,e[19]=C):C=e[19];const v=C;let R;e[20]!==v||e[21]!==b?(R={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:v},e[20]=v,e[21]=b,e[22]=R):R=e[22],kC(R)};function AC(t){return t.projects}function PC(t){return t.currentDirectory}function DC(t){return t.currentSessionDirectory}function IC(t){return t.activeSessions}function TC(t){return t.archivedSessions}function EC(t){return t.status==="ready"}function RC(){let t=null,e=!1;const n=new Set,r=Pn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),ri(Lo());return}const o=[...n];n.clear(),o.length&&Ba(o,Lo())},500)});return()=>{t&&clearTimeout(t),r()}}const MC=Dn(()=>sn(()=>import("./SettingsWindow-ilszvARl.js"),__vite__mapDeps([146,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,147,84,85,86,148,132,133,134,135,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,149,150,151])).then(t=>({default:t.SettingsWindow}))),OC=()=>{const t=Ze.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],NC(e),rp();const n=Ae(BC),r=Ae(FC),i=Ae(LC),o=Ae(_C),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const h=Ae($C),f=Ae(zC),p=Ae(WC),x=Ae(KC),b=Ae(VC),k=Ae(UC),y=Ae(HC),m=Ae(GC),g=Ou();let j;if(t[4]!==g||t[5]!==m){let G;t[7]!==m?(G=z=>z.id===m,t[7]=m,t[8]=G):G=t[8],j=g.find(G),t[4]=g,t[5]=m,t[6]=j}else j=t[6];const S=j;let w,C;t[9]!==S||t[10]!==m?(w=()=>{m&&!S&&Ae.getState().setOpenGuestPage(null)},C=[m,S],t[9]=S,t[10]=m,t[11]=w,t[12]=C):(w=t[11],C=t[12]),c.useEffect(w,C);let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=[],t[13]=v):v=t[13],c.useEffect(YC,v);const R=x||b||k||!!y||h||!!S;let T;t[14]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[14]=T):T=t[14],c.useEffect(XC,T);const{isMobile:D}=Nn();op();let F,B;t[15]!==D||t[16]!==r?(F=()=>{Ae.getState().isMobile!==D&&r(D)},B=[D,r],t[15]=D,t[16]=r,t[17]=F,t[18]=B):(F=t[17],B=t[18]),c.useEffect(F,B);let E,$,L,X,Y;t[19]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(lj,{}),$=s.jsx(o0,{}),L=s.jsx(c0,{}),X=s.jsx(k4,{}),Y=s.jsx(Oy,{}),t[19]=E,t[20]=$,t[21]=L,t[22]=X,t[23]=Y):(E=t[19],$=t[20],L=t[21],X=t[22],Y=t[23]);let I;t[24]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(My,{}),t[24]=I):I=t[24];let P;t[25]!==n?(P=s.jsx(j4,{isVisible:n}),t[25]=n,t[26]=P):P=t[26];let A;t[27]!==D||t[28]!==n||t[29]!==P?(A=s.jsx(Ry,{isOpen:n,isMobile:D,className:"border-border",topBar:I,children:P}),t[27]=D,t[28]=n,t[29]=P,t[30]=A):A=t[30];let q;t[31]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(Ty,{}),t[31]=q):q=t[31];const K=R&&"invisible";let te;t[32]!==K?(te=Me("absolute inset-0",K),t[32]=K,t[33]=te):te=t[33];const ae=!i&&!R;let re;t[34]!==ae?(re=s.jsx(ps,{children:s.jsx(nu,{active:ae})}),t[34]=ae,t[35]=re):re=t[35];let he;t[36]!==te||t[37]!==re?(he=s.jsx("div",{className:te,children:re}),t[36]=te,t[37]=re,t[38]=he):he=t[38];let ce;t[39]!==h||t[40]!==p||t[41]!==f?(ce=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(yC,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[39]=h,t[40]=p,t[41]=f,t[42]=ce):ce=t[42];let Te;t[43]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx(ps,{children:s.jsx(X4,{})}),t[43]=Te):Te=t[43];let ve;t[44]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx(ps,{children:s.jsx(J4,{})}),t[44]=ve):ve=t[44];let pe;t[45]!==k?(pe=k&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(ip,{})})}),t[45]=k,t[46]=pe):pe=t[46];let Ne;t[47]===Symbol.for("react.memo_cache_sentinel")?(Ne=s.jsx(ps,{children:s.jsx(lC,{})}),t[47]=Ne):Ne=t[47];let U;t[48]!==S?(U=S&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(Nb,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:JC})})}),t[48]=S,t[49]=U):U=t[49];let Z;t[50]!==he||t[51]!==ce||t[52]!==pe||t[53]!==U?(Z=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[he,ce,Te,ve,pe,Ne,U]}),t[50]=he,t[51]=ce,t[52]=pe,t[53]=U,t[54]=Z):Z=t[54];let de;t[55]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(IS,{}),t[55]=de):de=t[55];let ye;t[56]!==Z?(ye=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[Z,de]})})}),t[56]=Z,t[57]=ye):ye=t[57];let H;t[58]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(ps,{children:s.jsx($S,{})})}),t[58]=H):H=t[58];let je;t[59]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(ps,{children:s.jsx(Zx,{})}),t[59]=je):je=t[59];let Ee;t[60]!==ye?(Ee=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[q,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ye,H,je]})]}),t[60]=ye,t[61]=Ee):Ee=t[61];let ge;t[62]!==A||t[63]!==Ee?(ge=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[A,Ee]}),t[62]=A,t[63]=Ee,t[64]=ge):ge=t[64];let ne;t[65]!==i||t[66]!==o||t[67]!==l?(ne=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(MC,{open:i,onOpenChange:o})}):null,t[65]=i,t[66]=o,t[67]=l,t[68]=ne):ne=t[68];let be;return t[69]!==ge||t[70]!==ne?(be=s.jsx(ap,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[E,$,L,X,Y,ge,ne]})}),t[69]=ge,t[70]=ne,t[71]=be):be=t[71],be};function BC(t){return t.isSidebarOpen}function FC(t){return t.setIsMobile}function LC(t){return t.isSettingsDialogOpen}function _C(t){return t.setSettingsDialogOpen}function $C(t){return t.isMultiRunLauncherOpen}function zC(t){return t.setMultiRunLauncherOpen}function WC(t){return t.multiRunLauncherPrefillPrompt}function KC(t){return t.isScheduledTasksDialogOpen}function VC(t){return t.isArchivePageOpen}function UC(t){return t.isUsageStatsPageOpen}function HC(t){return t.worktreesPageProjectId}function GC(t){return t.openGuestPageId}function qC(){return Ae.getState().setOpenGuestPage(null)}function YC(){return vr(qC)}function QC(){return Ae.getState().closeMainSurfaces()}function XC(){const t=QC,e=nt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function JC(){return Ae.getState().setOpenGuestPage(null)}const pm=12,ZC=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],e5=t=>{const e=Ze.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,h=l===void 0?ZC:l,f=ct.useRef(!1);let p,x;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},x=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=x):(p=e[2],x=e[3]),ct.useEffect(p,x);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:pm},t5),e[4]=b):b=e[4];const k=b;if(!n)return null;let y;e[5]!==i?(y=Me("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let j;e[11]!==d||e[12]!==u?(j=S=>{const w={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:w,children:k.map((C,v)=>{const R=C.x*S.radius,T=C.y*S.radius,D={"--translate-x":`${R}px`,"--translate-y":`${T}px`,"--particle-delay":`${C.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:D},`${S.id}-${v}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=j):j=e[13],m=h.map(j),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let g;return e[14]!==d||e[15]!==y||e[16]!==m?(g=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=y,e[16]=m,e[17]=g):g=e[17],g};function t5(t,e){const n=Math.PI*2*e/pm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const s5=t=>{const e=Ze.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ct.useState(o),d=ct.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const h=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(n5)},e[4]=f):f=e[4];const p=f;let x;e[5]!==i?(x=()=>{h(),a(r5),d.current=window.setTimeout(()=>{a(o5),d.current=null},i)},e[5]=i,e[6]=x):x=e[6];const b=x;let k,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>h(),y=[h],e[7]=k,e[8]=y):(k=e[7],y=e[8]),ct.useEffect(k,y);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==b?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:b,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=b,e[12]=m):m=e[12],m};function n5(t){return t.isActive?{...t,isActive:!1}:t}function r5(t){return{isActive:!0,cycle:t.cycle+1}}function o5(t){return t.isActive?{...t,isActive:!1}:t}const gm=c.createContext(void 0),i5=t=>{const e=Ze.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=s5();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(e5,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(gm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},rA=()=>{const t=c.useContext(gm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Da="openchamber_requests_in_flight",xm=1e3,a5=300*1e3,Yo=Math.ceil(a5/xm),l5=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Da)==="1"}catch{return!1}},bm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let c5=1;const d5=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},u5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},ym=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},yr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},f5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=c5++;d5(o,Date.now());try{return await e(r,i)}finally{u5(o)}};window.fetch=n},kd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Rr=t=>{t.length>Yo&&t.splice(0,t.length-Yo)},m5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=ym(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(yr(e,50)),t.p90Samples.push(yr(e,90)),t.p99Samples.push(yr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Rr(t.samples),Rr(t.p50Samples),Rr(t.p90Samples),Rr(t.p99Samples),Rr(t.maxSamples),t.lastSampleAt=Date.now()},h5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(m5,xm))},Cd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Nd=t=>{if(!(typeof window>"u"))try{if(t){Cd(),kd(),window.localStorage.setItem(Da,"1"),window.__openchamberRequestsInFlight__=bm(),f5(),h5();return}window.localStorage.removeItem(Da),Cd(),kd(),delete window.__openchamberRequestsInFlight__}catch{}},p5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=bm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},Ia=()=>{if(typeof window>"u")return Ad();const t=window.__openchamberRequestsInFlight__;if(!l5()||!t)return Ad();const e=ym(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:yr(e,50),ageP90:yr(e,90),ageP99:yr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Yo}},Ad=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Yo});function g5(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const wm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Ta=t=>`${(t/1e3).toFixed(2)} s`,ds=t=>{const e=Ze.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Pd=t=>{const e=Ze.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=St();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(y5,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?wm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let x;e[18]!==h||e[19]!==p?(x=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=x):x=e[20];let b;e[21]!==o?(b=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=b):b=e[22];let k;e[23]!==r.entries.length||e[24]!==b?(k=s.jsx(ds,{label:b,value:r.entries.length}),e[23]=r.entries.length,e[24]=b,e[25]=k):k=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let m;e[28]!==y||e[29]!==u?(m=s.jsx(ds,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=m):m=e[30];let g;e[31]!==o?(g=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=g):g=e[32];let j;e[33]!==r.lastUpdatedAt||e[34]!==o?(j=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=j):j=e[35];let S;e[36]!==g||e[37]!==j?(S=s.jsx(ds,{label:g,value:j}),e[36]=g,e[37]=j,e[38]=S):S=e[38];let w;e[39]!==m||e[40]!==S||e[41]!==k?(w=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[k,m,S]}),e[39]=m,e[40]=S,e[41]=k,e[42]=w):w=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[x,w,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(gn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Dd=t=>{const e=Ze.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(w5,0),u=r>0?52/r:0;let h;e[0]!==d||e[1]!==a?(h=S=>a-d+S,e[0]=d,e[1]=a,e[2]=h):h=e[2];const f=h;let p;e[3]!==u?(p=S=>56-S*u,e[3]=u,e[4]=p):p=e[4];const x=p;let b;e[5]!==l?(b=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=b):b=e[6];const k=`0 0 ${a} 56`;let y;e[7]!==a?(y=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=y):y=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==x){let S;e[13]!==f||e[14]!==x?(S=(w,C)=>{const v=w.samples.length;if(v===0)return null;const R=w.samples.map((D,F)=>`${f(F)},${x(D).toFixed(2)}`),T=`M ${R.join(" L ")}`;return s.jsxs(c.Fragment,{children:[w.filled?s.jsx("path",{d:`M ${f(0)},56 L ${R.join(" L ")} L ${f(v-1)},56 Z`,fill:`color-mix(in srgb, ${w.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:T,fill:"none",stroke:w.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=x,e[15]=S):S=e[15],m=n.map(S),e[9]=n,e[10]=f,e[11]=x,e[12]=m}else m=e[12];let g;e[16]!==o||e[17]!==k||e[18]!==y||e[19]!==m?(g=s.jsxs("svg",{viewBox:k,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,m]}),e[16]=o,e[17]=k,e[18]=y,e[19]=m,e[20]=g):g=e[20];let j;return e[21]!==b||e[22]!==g?(j=s.jsxs("div",{className:"relative w-full",children:[b,g]}),e[21]=b,e[22]=g,e[23]=j):j=e[23],j},x5=t=>{const e=Ze.c(100),{onClose:n}=t,{t:r}=St(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=nt(v5),u=Ku(S5),h=Pu(),f=wx(j5),p=Ms(k5),[x,b]=c.useState(C5),[k,y]=c.useState(N5),[m,g]=c.useState(A5),j=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let S;e[0]!==m.samples?(S=m.samples.reduce(P5,0),e[0]=m.samples,e[1]=S):S=e[1];const w=S,C=j.reduce(I5,0);let v;e[2]!==x.entries?(v=new Map,x.entries.forEach(Se=>{v.set(Se.metric,Se.count)}),e[2]=x.entries,e[3]=v):v=e[3];let R;e[4]!==v?(R=v.get("ui.message_list.render")??0,e[4]=v,e[5]=R):R=e[5];let T;e[6]!==v?(T=v.get("ui.message_list.render.streaming")??0,e[6]=v,e[7]=T):T=e[7];let D;e[8]!==v?(D=v.get("ui.chat_message.render")??0,e[8]=v,e[9]=D):D=e[9];let F;e[10]!==v?(F=v.get("ui.chat_message.render.streaming")??0,e[10]=v,e[11]=F):F=e[11];let B;e[12]!==v?(B=v.get("ui.chat_message.render.static_during_stream")??0,e[12]=v,e[13]=B):B=e[13];let E;e[14]!==v?(E=v.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=v,e[15]=E):E=e[15];let $;e[16]!==R||e[17]!==T||e[18]!==D||e[19]!==F||e[20]!==B||e[21]!==E?($={messageListRender:R,messageListRenderStreaming:T,chatMessageRender:D,chatMessageRenderStreaming:F,chatMessageRenderStaticDuringStream:B,chatMessageRenderStaticOutsideActiveTurnDuringStream:E},e[16]=R,e[17]=T,e[18]=D,e[19]=F,e[20]=B,e[21]=E,e[22]=$):$=e[22];const L=$;let X,Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>{const Se=()=>{b(ko()),y(Co()),g(Ia())};Se();const Ke=window.setInterval(Se,500);return()=>window.clearInterval(Ke)},X=[],e[23]=X,e[24]=Y):(X=e[23],Y=e[24]),c.useEffect(Y,X);let I,P;e[25]!==l?(I=()=>{if(l==="idle")return;const Se=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Se)},P=[l],e[25]=l,e[26]=I,e[27]=P):(I=e[26],P=e[27]),c.useEffect(I,P);let A=0,q=0,K=0;for(const Se of Object.keys(f)){const Ke=f[Se]??[];q=q+Ke.length;for(const et of Ke)et.role==="user"?K=K+1:et.role==="assistant"&&(A=A+1)}let te;e[28]!==A||e[29]!==q||e[30]!==K?(te={assistant:A,total:q,user:K},e[28]=A,e[29]=q,e[30]=K,e[31]=te):te=e[31];const ae=te;let re;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==h||e[36]!==r){let Se;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Se=Ke=>{const et=f[Ke.id]??[];let it=0,rt=0;for(const ht of et)ht.role==="user"?rt=rt+1:ht.role==="assistant"&&(it=it+1);const pt=u.get(Ke.id);return{id:Ke.id,title:Ke.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:it,messageCount:et.length,userMessageCount:rt,isStreaming:pt?.isStreaming||!1,isZombie:pt?.isZombie||!1,backgroundCount:pt?.backgroundMessageCount||0,lastAccessed:pt?.lastAccessedAt||0,isCurrent:Ke.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Se):Se=e[42],re=h.map(Se).sort(T5),e[32]=d,e[33]=f,e[34]=u,e[35]=h,e[36]=r,e[37]=re}else re=e[37];const he=re;let ce;e[43]!==f?(ce=Object.keys(f),e[43]=f,e[44]=ce):ce=e[44];const Te=ce.length;let ve;e[45]===Symbol.for("react.memo_cache_sentinel")?(ve=async()=>{try{const Se={generatedAt:new Date().toISOString(),ui:ko(),vscode:Co()};await navigator.clipboard.writeText(JSON.stringify(Se,null,2)),a("copied")}catch{a("error")}},e[45]=ve):ve=e[45];const pe=ve,Ne=Sx,U="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let Z;e[46]===Symbol.for("react.memo_cache_sentinel")?(Z={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=Z):Z=e[46];let de;e[47]!==i?(de=g5(i),e[47]=i,e[48]=de):de=e[48];let ye;e[49]!==de?(ye=s.jsx(O,{name:de,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=de,e[50]=ye):ye=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let je;e[53]!==H?(je=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=je):je=e[54];let Ee;e[55]!==ye||e[56]!==je?(Ee=s.jsxs("div",{className:"flex items-center gap-2",children:[ye,je]}),e[55]=ye,e[56]=je,e[57]=Ee):Ee=e[57];let ge;e[58]!==i?(ge=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ut,{size:"xs",variant:"ghost",onClick:pe,children:s.jsx(O,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{mh(),b(ko()),y(Co())},children:s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=ge):ge=e[59];let ne;e[60]!==i?(ne=i==="requests"?s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{p5(),g(Ia())},children:s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=ne):ne=e[61];let be;e[62]!==n?(be=n?s.jsx(ut,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=be):be=e[63];let G;e[64]!==ge||e[65]!==ne||e[66]!==be?(G=s.jsxs("div",{className:"flex items-center gap-1",children:[ge,ne,be]}),e[64]=ge,e[65]=ne,e[66]=be,e[67]=G):G=e[67];let z;e[68]!==Ee||e[69]!==G?(z=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Ee,G]}),e[68]=Ee,e[69]=G,e[70]=z):z=e[70];let J;e[71]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=J):J=e[71];const ue=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let W;e[73]!==r?(W=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=W):W=e[74];let M;e[75]!==ue||e[76]!==W?(M=s.jsx(ut,{size:"sm",variant:ue,className:"flex-1",onClick:le,children:W}),e[75]=ue,e[76]=W,e[77]=M):M=e[77];const _=i==="streaming"?"secondary":"ghost";let ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>o("streaming"),e[78]=ee):ee=e[78];let oe;e[79]!==r?(oe=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=oe):oe=e[80];let fe;e[81]!==_||e[82]!==oe?(fe=s.jsx(ut,{size:"sm",variant:_,className:"flex-1",onClick:ee,children:oe}),e[81]=_,e[82]=oe,e[83]=fe):fe=e[83];const ie=i==="requests"?"secondary":"ghost";let Le;e[84]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>o("requests"),e[84]=Le):Le=e[84];let $e;e[85]!==r?($e=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=$e):$e=e[86];let Pe;e[87]!==ie||e[88]!==$e?(Pe=s.jsx(ut,{size:"sm",variant:ie,className:"flex-1",onClick:Le,children:$e}),e[87]=ie,e[88]=$e,e[89]=Pe):Pe=e[89];let Oe;e[90]!==M||e[91]!==fe||e[92]!==Pe?(Oe=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:J,children:[M,fe,Pe]}),e[90]=M,e[91]=fe,e[92]=Pe,e[93]=Oe):Oe=e[93];const Q=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ds,{label:r("memoryDebugPanel.metric.totalMessages"),value:ae.total}),s.jsx(ds,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Te} / ${Vl.MAX_SESSIONS}`}),s.jsx(ds,{label:r("memoryDebugPanel.metric.userMessages"),value:ae.user}),s.jsx(ds,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ae.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:vx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Vl.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(gn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:he.map(Se=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Se.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Se.title}),Se.isStreaming?s.jsx(O,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Se.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Se.assistantMessageCount,user:Se.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Se.messageCount})}),Se.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Se.backgroundCount]}):null]})]},Se.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(E5),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:ae,sessionMessageRoleCounts:he.map(R5),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(wt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(ut,{size:"xs",variant:"outline",onClick:pe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ds,{label:r("memoryDebugPanel.metric.uiMetrics"),value:x.entries.length}),s.jsx(ds,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:k.entries.length}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Pd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:x,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),k.entries.length>0?s.jsx(Pd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:k,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ds,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(ds,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?wm(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(Dd,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:w,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${w}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ta(m.peakAgeMs)})]}),s.jsx(Dd,{series:j.map(M5),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ta(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map(O5)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ce;return e[94]!==Ne||e[95]!==Z||e[96]!==z||e[97]!==Oe||e[98]!==Q?(Ce=s.jsxs(Ne,{className:U,style:Z,children:[z,Oe,Q]}),e[94]=Ne,e[95]=Z,e[96]=z,e[97]=Oe,e[98]=Q,e[99]=Ce):Ce=e[99],Ce},b5=x5;function y5(t,e){return t+e.count}function w5(t,e){return Math.max(t,e.samples.length)}function v5(t){return t.currentSessionId}function S5(t){return t.sessionMemoryState}function j5(t){return t.message}function k5(t){return t.totalRequestCount}function C5(){return ko()}function N5(){return Co()}function A5(){return Ia()}function P5(t,e){return Math.max(t,e)}function D5(t,e){return Math.max(t,e)}function I5(t,e){return e.samples.reduce(D5,t)}function T5(t,e){return e.lastAccessed-t.lastAccessed}function E5(t){return{id:t.id,title:t.title}}function R5(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function M5(t){return{samples:t.samples,color:t.color}}function O5(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ta(t.current)})]},t.label)}const B5=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},F5=async()=>{const t=B5()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Id="openchamber:menu-action",zi="openchamber:check-for-updates",L5=t=>{const e=nt(m=>m.openNewSessionDraft),n=Ae(m=>m.toggleCommandPalette),r=Ae(m=>m.setCommandPaletteOpen),i=Ae(m=>m.toggleHelpDialog),o=Ae(m=>m.toggleSidebar),l=Ae(m=>m.setSessionSwitcherOpen),a=Ae(m=>m.setSettingsDialogOpen),d=Ae(m=>m.setAboutDialogOpen),u=_r(m=>m.checkForUpdates),{setThemeMode:h}=Cn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:m,error:g}=_r.getState();if(g){ze.error("Failed to check for updates",{description:g});return}m||ze.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),x=c.useCallback(()=>{Qs.requestDirectoryDialog()},[]),b=c.useCallback(m=>{const g=jx();if(g.length===0)return;const j=nt.getState().currentSessionId,S=g.findIndex(v=>v.id===j);let w=m>0?0:g.length-1;S>=0&&(w=(S+m+g.length)%g.length);const C=g[w];C&&(l(!1),nt.getState().setCurrentSession(C.id))},[l]),k=c.useCallback(m=>{const{activeProjectId:g,projects:j,setActiveProject:S}=zt.getState();if(j.length===0)return;const w=j.findIndex(R=>R.id===g);let C=m>0?0:j.length-1;w>=0&&(C=(w+m+j.length)%j.length);const v=j[C];v&&S(v.id)},[]),y=c.useCallback(m=>{switch(m){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const g=nt.getState(),j=Jt.getState().currentDirectory;e(g.currentSessionId&&j?{directoryOverride:j}:void 0)}break;case"new-worktree-session":l(!1),Ru();break;case"change-workspace":x();break;case"toggle-right-sidebar":{const g=Jt.getState().currentDirectory;if(!g)break;const j=Ae.getState(),S=$n(g),w=j.contextPanelByDirectory[S];w?.isOpen?j.closeContextPanel(S):w?.activeTabId?j.setActiveContextPanelTab(S,w.activeTabId):j.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"git");break}case"open-right-sidebar-files":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"file");break}case"toggle-terminal":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"terminal");break}case"toggle-terminal-expanded":{const g=Jt.getState().currentDirectory;if(!g)break;const j=$n(g),S=Ae.getState(),w=S.contextPanelByDirectory[j];(w?.isOpen?w.tabs.find(v=>v.id===w.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(j,"terminal"),S.toggleContextPanelExpanded(j);break}case"copy":{const g=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(g)||F5();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":kx();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Jt.getState().goBack();break;case"go-forward":Jt.getState().goForward();break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":k(-1);break;case"next-project":k(1);break;case"help-dialog":i();break;case"download-logs":{Mu().catch(()=>{ze.error("Failed to collect OpenCode status")});break}}},[x,k,b,t,e,d,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=j=>{const S=j.detail;S&&y(S)},g=()=>{p()};return window.addEventListener(Id,m),window.addEventListener(zi,g),()=>{window.removeEventListener(Id,m),window.removeEventListener(zi,g)}},[y,p]),c.useEffect(()=>{if(typeof window>"u")return;const g=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof g!="function")return;let j=null,S=null;return g("openchamber:menu-action",w=>{const C=w?.payload;typeof C=="string"&&y(C)}).then(w=>{j=w}).catch(()=>{}),g("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(zi))}).then(w=>{S=w}).catch(()=>{}),()=>{(async()=>{try{const C=j?.();C instanceof Promise&&await C}catch{}try{const C=S?.();C instanceof Promise&&await C}catch{}})()}},[y])},_5="openchamber:tray-action",$5=5e3,z5=500,W5=20,Td=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ed=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,vm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Sm=t=>t.title.trim()||"Question",K5=(t,e)=>Qa(t,e,Hr.getState().ids,Va.getState().rankById),V5=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},U5=(t,e,n,r,i)=>{if(!t)return"";const o=ou(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||V5(t),d=No(t);let u=d&&i.get(d)||"";if(!u){for(const[h,f]of pn.getState().directories)if(No(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(p=>No(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},H5=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Nx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:Px(h),value:Ax(f.valueLabel,p)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},G5=async()=>{try{if(Qo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=mn();if(e&&yl(e,t))return"Local OpenChamber";const r=(await Ld()).hosts.find(i=>e?yl(e,hh(i)):!1);return r?.label?.trim()?_d(r.label.trim()):"Instance"}catch{return""}},q5=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=ra()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(No(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const h=u?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:vm(h),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"form",id:h.id,sessionId:f,sessionTitle:"",label:Sm(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Y5=(t,e)=>{const n=Ga.getState().index.session,r=us.getState().activeSessions,i=new Map;for(const g of r)if(g?.id&&g.parentID){const j=i.get(g.parentID)??[];j.push(g.id),i.set(g.parentID,j)}const o=g=>{const j=[],S=[...i.get(g)??[]],w=new Set;for(;S.length;){const C=S.pop();w.has(C)||(w.add(C),j.push(C),S.push(...i.get(C)??[]))}return j},l=Ae.getState();let a=0;if(l.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let j=n.unseenCount[g.id]??0;j===0&&l.notifyOnSubtasks&&(j=o(g.id).reduce((S,w)=>S+(n.unseenCount[w]??0),0)),j>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=q5(),u=new Map(d.titleById);for(const g of r)g?.id&&g.title&&u.set(g.id,g.title);const h=Zo.getState().statusById,f=g=>{const j=d.statusById.get(g);return j&&j!=="idle"?j:h.get(g)?.status.type??j??"idle"},p=g=>{const j=g.map(S=>f(S));return j.includes("busy")?"busy":j.includes("retry")?"retry":"idle"},x=zt.getState().projects,b=nt.getState().availableWorktreesByProject,k=r.filter(g=>g?.id&&!g.parentID).slice().sort(K5).slice(0,W5).map(g=>{const j=[g.id,...o(g.id)],S=xs(g)??"";return{id:g.id,title:g.title||"Untitled session",status:p(j),branch:S?d.branchByDirectory.get(S)??"":"",unseen:j.reduce((w,C)=>w+(n.unseenCount[C]??0),0),hasError:j.some(w=>n.unseenHasError[w]??!1),directory:S,subtitle:U5(S,g,x,b,d.branchByDirectory)}}),y=d.approvals.map(g=>({...g,sessionTitle:u.get(g.sessionId)||""})),m=new Set(y.map(g=>g.id));for(const[g,j]of qa.getState().bySession){const S=u.get(g)||"";for(const w of j.permissions)m.has(w.id)||(m.add(w.id),y.push({kind:"permission",id:w.id,sessionId:g,sessionTitle:S,label:vm(w),directory:j.directory}));for(const w of j.forms)m.has(w.id)||(m.add(w.id),y.push({kind:"form",id:w.id,sessionId:g,sessionTitle:S,label:Sm(w),directory:j.directory}))}return{sessions:k,approvals:y,instanceName:t,usage:H5(),dockBadgeCount:a}},Q5=()=>{c.useEffect(()=>{if(!Td()||!Vr())return;const t=Ed();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const v=Y5(i,t),R=JSON.stringify(v);R!==n&&(n=R,jn("desktop_tray_update",v))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},z5))},a=Ga.subscribe(()=>l()),d=us.subscribe(()=>l()),u=Ae.subscribe((v,R)=>{(v.dockBadgeEnabled!==R.dockBadgeEnabled||v.notifyOnSubtasks!==R.notifyOnSubtasks)&&l()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),h;G5().then(v=>{e||(i=v,o())});const f=new Map,p=()=>{if(e)return;let v;try{v=ra()}catch{return}const R=new Set;for(const[T,D]of v.children.entries())R.add(T),f.has(T)||f.set(T,D.subscribe(()=>l()));for(const[T,D]of f)R.has(T)||(D(),f.delete(T))};let x=null;try{x=ra().subscribeRegistry(()=>{p(),l()})}catch{}p();const b=zt.subscribe(()=>l()),k=nt.subscribe(()=>l()),y=pn.subscribe(()=>l()),m=Zo.subscribe(()=>l()),g=qa.subscribe(()=>l()),j=Va.subscribe(()=>l()),S=Hr.subscribe(()=>l()),w=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:v,results:R}=ur.getState();v.length>0&&v.some(D=>!R.some(F=>F.providerId===D))&&ur.getState().fetchQuotas(v)});const C=window.setInterval(()=>{p(),o()},$5);return o(),()=>{h(),window.clearInterval(C),b(),k(),y(),m(),g(),j(),S(),w(),x?.();for(const v of f.values())v();f.clear()}},[]),c.useEffect(()=>{if(!Td()||!Ed()||!Vr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Cx(i.sessionId,i.id,i.response).catch(()=>{ze.error("Failed to respond to permission request")})};let r=null;return e(_5,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},X5=30*6e4,J5=(t,e,n=X5)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Mr=null;const Z5=()=>{if(Mr)return Mr;const t=Wt();return Mr=(async()=>{const e=await Vs.getHostSessionStatusSnapshot();if(!e||Wt()!==t)return;const n=Zo.getState(),r=us.getState().entityById,i=J5(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?xs(a):null}});for(const[l,a]of i)Dx(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?xs(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Ix(o)})().finally(()=>{Mr=null}),Mr},eN=45e3,tN=[1e3,2e3,4e3],sN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const h=await u().catch(()=>!1);if(i)return;a||=h;const f=a?void 0:tN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??eN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},nN=t=>{const e=Ze.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=rN;let o=i();const l=vr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function rN(){const t=Wt();let e=!0;const n=async i=>(i?await Tx(Lo()):await ri(),!e||Wt()!==t?!1:(Z5(),us.getState().status==="ready")),r=sN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const oN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,iN=t=>{const e=Ze.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||en()||!Ra()||!globalThis.window))return Pn(aN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function aN(t){if(t.type!=="notification")return;const e=Ae.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&oN())return;Fd()?.notifications?.notifyAgentCompletion(t.payload)}const lN=6e4,cN=t=>{const e=Ze.c(10),n=Ae(dN),r=Ex(uN),o=lp(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:lN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Pn(h=>{h.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function dN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function uN(t){return t.load}const fN=()=>{const t=Ze.c(4),{t:e}=St(),n=Ae(mN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Pn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),ze.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function mN(t){return t.setBrowserProvider}const Rd="pwa-install-toast-shown",Md="pwa-install-toast-dismissed",hN=()=>{const t=Ze.c(6),{browserTab:e}=cp(),{t:n}=St(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!Ra()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(ze.dismiss(u),u=null)},f=async()=>{if(!d)return;const b=d;d=null,h(),await b.prompt();const{outcome:k}=await b.userChoice;k==="accepted"&&ze.success(r.current("pwa.installPrompt.started"))},p=b=>{const k=b;if(typeof k.prompt!="function")return;k.preventDefault(),d=k;const y=Mo(),m=ph();dp({dismissed:y.getItem(Md),sessionShown:m.getItem(Rd),hasActiveToast:u!==null})&&(m.setItem(Rd,"true"),u=ze.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Mo().setItem(Md,"true"),h()}}}))},x=()=>{d=null,h(),ze.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",x),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",x)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},pN=({open:t,onOpenChange:e})=>{const{t:n}=St(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[h,f]=c.useState(!1),[p,x]=c.useState(null),[b,k]=c.useState(!1);c.useCallback(async()=>{},[p,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const g=await ls("/api/system/info");if(g.ok){const j=await g.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){o(j.openchamberVersion);return}}}catch{}o(await Rx())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const j=await ls("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!j.ok)return;const S=await j.json().catch(()=>null),w=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!m&&w&&a(w)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{x(null),k(!1);return}},[t,r]);const y=i;return s.jsx(bs,{open:t,onOpenChange:e,children:s.jsx(ys,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Du,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ea="project-config-invalid",gN=()=>{const t=Ze.c(9),{t:e}=St(),n=Lt(xN);let r;t[0]!==n?(r=p=>p.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const i=Lt(r),[o,l]=ct.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const p=Lt.getState(),x=p.activeDirectoryKey;l(!0),Promise.all([p.loadProviders({directory:x,source:"projectConfigError:retry"}),p.loadAgents({directory:x,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,h;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){ze.dismiss(Ea);return}ze.error(e("projectConfigError.toast.title"),{id:Ea,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&s.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),o||d()}}})},h=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=h):(u=t[6],h=t[7]),ct.useEffect(u,h);let f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[8]=f):f=t[8],ct.useEffect(yN,f),null};function xN(t){return t.activeDirectoryKey}function bN(){ze.dismiss(Ea)}function yN(){return bN}const wN="\x1B",vN=new RegExp(`${wN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),jo=Xn().transform(t=>t.replace(vN,"").trim()).nullish(),SN=Zl({isOpenCodeReady:ec().optional(),openCodeRunning:ec().optional(),lastOpenCodeError:jo,opencodeBinaryResolved:jo,lastOpenCodeLaunchDiagnostics:Zl({sourceBinary:jo,binary:jo}).nullish()}),jN=async(t,e=ls)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=SN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},kN=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},Od=Dn(()=>sn(()=>import("./OnboardingScreen-B3B8bi91.js"),__vite__mapDeps([152,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])).then(t=>({default:t.OnboardingScreen}))),CN=()=>{const t=Ze.c(3),e=Ae(TN),n=Ae(EN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(pN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},NN=t=>{const e=Ze.c(33),{onRetry:n,isRetrying:r}=t,{t:i}=St(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const w=new AbortController,C=Wt(),v=setTimeout(()=>w.abort(),5e3);return jN(w.signal).then(R=>{!w.signal.aborted&&Wt()===C&&l(R)}).catch(RN).finally(()=>clearTimeout(v)),()=>{w.abort(),clearTimeout(v)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=Lt(MN),h=o?null:u?.message??null;let f;e[2]!==i?(f=i("startup.initRecovery.title"),e[2]=i,e[3]=f):f=e[3];let p;e[4]!==f?(p=s.jsx("h1",{className:"typography-title text-foreground",children:f}),e[4]=f,e[5]=p):p=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==i?(x=i(kN(o,u)),e[6]=o,e[7]=u,e[8]=i,e[9]=x):x=e[9];let b;e[10]!==x?(b=s.jsx("p",{className:"typography-body text-muted-foreground",children:x}),e[10]=x,e[11]=b):b=e[11];let k;e[12]!==p||e[13]!==b?(k=s.jsxs("div",{className:"flex flex-col gap-2",children:[p,b]}),e[12]=p,e[13]=b,e[14]=k):k=e[14];let y;e[15]!==h||e[16]!==i?(y=h&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:h})]}),e[15]=h,e[16]=i,e[17]=y):y=e[17];let m;e[18]!==o||e[19]!==i?(m=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=m):m=e[20];let g;e[21]!==r||e[22]!==i?(g=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=g):g=e[23];let j;e[24]!==r||e[25]!==n||e[26]!==g?(j=s.jsx(ut,{type:"button",onClick:n,disabled:r,children:g}),e[24]=r,e[25]=n,e[26]=g,e[27]=j):j=e[27];let S;return e[28]!==j||e[29]!==k||e[30]!==y||e[31]!==m?(S=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[k,y,m,j]})}),e[28]=j,e[29]=k,e[30]=y,e[31]=m,e[32]=S):S=e[32],S},Bd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",AN=()=>{if(typeof window>"u"||!Cb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},PN=t=>{const e=Ze.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=Jt(ON),l=nt(BN),a=nt(FN),d=_x(),u=c.useRef(null);let h;e[0]!==n.directory?(h=Bd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let p;e[2]!==o?(p=Bd(o),e[2]=o,e[3]=p):p=e[3];const x=p;let b,k;if(e[4]!==x||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(b=()=>{if(r||f&&x!==f)return;const w=`${f}
896
896
  ${n.sessionId}`;u.current===w&&l||(u.current=w,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},k=[x,l,n.directory,n.sessionId,f,r,a,d],e[4]=x,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=b,e[13]=k):(b=e[12],k=e[13]),c.useEffect(b,k),f&&x!==f)return null;let y;e[14]!==i?(y=s.jsx(Yu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=y):y=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(ru,{}),e[16]=m):m=e[16];let g;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(g=s.jsx(nu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=g):g=e[20];let j;e[21]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Qu,{}),e[21]=j):j=e[21];let S;return e[22]!==y||e[23]!==g?(S=s.jsxs(s.Fragment,{children:[y,m,g,j]}),e[22]=y,e[23]=g,e[24]=S):S=e[24],S};function DN({apis:t}){c.useEffect(()=>{gh("App:mounted"),xh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Lt(U=>U.initializeApp),n=Lt(U=>U.isInitialized),r=Lt(U=>U.isConnected),i=Lt(U=>U.providers.length),o=Lt(U=>U.agents.length),l=Lt(U=>U.loadProviders),a=Lt(U=>U.loadAgents),d=nt(U=>U.error),u=nt(U=>U.clearError),h=Jt(U=>U.currentDirectory),f=Jt(U=>U.setDirectory),p=Jt(U=>U.isSwitchingDirectory),[x,b]=c.useState(!1),k=hn(U=>U.refreshStatus),y=Ji(U=>U.refreshStatus),[m,g]=c.useState(()=>t.runtime.isVSCode),[j,S]=c.useState(!1),[w,C]=c.useState(!1),[v,R]=c.useState(0),[T,D]=c.useState(0),[F,B]=c.useState(!1),E=Ae(U=>U.wideChatLayoutEnabled),$=Ae(U=>U.mobileKeyboardMode),L=c.useMemo(()=>en(),[]),X=La(U=>U.setPlanModeEnabled),[Y,I]=c.useState(()=>wl()),[P,A]=c.useState(()=>{const U=vl();return U!==null?Sl({isDesktopShell:!0,bootOutcome:U}):null}),q=c.useRef(!1),K=c.useMemo(()=>AN(),[]),te=!K||j;c.useEffect(()=>(jl(x),Nd(x),()=>{jl(!1),Nd(!1)}),[x]),c.useEffect(()=>{bh($)},[$]),c.useEffect(()=>{g(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>vr(U=>{fp(U),D(Z=>Z+1),C(!1),R(Z=>Z+1)}),[]);const ae=Ul(U=>{const Z=Wt();return Object.values(U.runsByOriginalSessionID).filter(de=>de.status==="running"&&de.runtimeKey===Z).map(de=>`${de.originalSessionID}:${de.phase}:${de.lastForwardedMessageID??""}:${de.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(K)return;const U=Wt(),Z=Object.values(Ul.getState().runsByOriginalSessionID).filter(de=>de.status==="running"&&de.runtimeKey===U);for(const de of Z)Mx(de.originalSessionID)},[ae,K,T]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",E),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[E]),c.useEffect(()=>(kl(t),()=>kl(null)),[t]),c.useEffect(()=>{K||(k(t.github,{force:!0}),y(t.linear,{force:!0}))},[t.github,t.linear,K,r,k,y,T]),Ox();const re=Y==="valid",he=P?.screen==="main";c.useEffect(()=>{if(!yh({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:re,bootViewIsMain:he}))return;const U=setTimeout(()=>{const Z=document.getElementById("initial-loading");Z&&(Z.classList.add("fade-out"),setTimeout(()=>{Z.remove()},300))},150);return()=>clearTimeout(U)},[L,n,re,he]),c.useEffect(()=>{if(!L||Y!=="malformed")return;const U=document.getElementById("initial-loading");U&&(U.textContent="Desktop startup failed — please restart the app.")},[L,Y]),c.useEffect(()=>{if(L)return;const U=setTimeout(()=>{const Z=document.getElementById("initial-loading");Z&&!n&&(Z.classList.add("fade-out"),setTimeout(()=>{Z.remove()},300))},5e3);return()=>clearTimeout(U)},[L,n]),c.useEffect(()=>{let U=!1;return(async()=>{const de=await ls("/health",{method:"GET"}).catch(()=>null);if(!de||!de.ok||U)return;const ye=await de.json().catch(()=>null);if(!ye||U)return;const H=ye.planModeExperimentalEnabled;X(H===!0||H===1||H==="1"||H==="true")})(),()=>{U=!0}},[X]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let U=!0,Z,de=0;const ye=10,H=1e3,je=async()=>{if(!U)return;if(de>=ye){C(!0);return}const Ee=Lt.getState();if(Ee.isInitialized){C(!1);return}de+=1,await Ee.initializeApp();const ge=Lt.getState();if(!U)return;if(ge.isInitialized){C(!1);return}if(de>=ye){C(!0);return}const ne=Math.min(H*Math.pow(2,de-1),16e3);Z=setTimeout(je,ne)};return Z=setTimeout(je,H),()=>{U=!1,Z&&clearTimeout(Z)}},[v,n,m]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!w)return;const U=document.getElementById("initial-loading");U&&(U.classList.add("fade-out"),setTimeout(()=>{U.remove()},300))},[w]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let U=!0,Z=0;const de=15,ye=async()=>{const je=Lt.getState();if(!(je.providers.length>0&&je.agents.length>0))try{je.providers.length===0&&await l({source:"startupRecovery"}),Lt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};ye();const H=setInterval(()=>{if(U){if(++Z>=de){clearInterval(H);return}ye()}},2e3);return()=>{U=!1,clearInterval(H)}},[r,m,a,l,i,o]),c.useEffect(()=>{p||m||r&&Vs.setDirectory(h)},[h,p,r,m]),c.useEffect(()=>{if(!K||typeof window>"u")return;const U=ye=>{S(ye?.visible===!0)},Z=ye=>{if(ye.origin!==window.location.origin||ye.source!==window.parent)return;const H=ye.data;H?.type===of&&U(H.payload)},de=window;return de.__openchamberSetEmbeddedVisibility=U,window.addEventListener("message",Z),kb(),()=>{window.removeEventListener("message",Z),de.__openchamberSetEmbeddedVisibility===U&&delete de.__openchamberSetEmbeddedVisibility}},[K]),c.useEffect(()=>{!K?.directory||m||h!==K.directory&&f(K.directory,{showOverlay:!1})},[h,K,m,f]),c.useEffect(()=>{if(!K||typeof window>"u")return;const U=Z=>{Z.storageArea===window.localStorage&&Z.key==="ui-store"&&Ae.persist.rehydrate()};return window.addEventListener("storage",U),()=>{window.removeEventListener("storage",U)}},[K]),c.useEffect(()=>{if(typeof window>"u")return;const U=Z=>{const de=Z.detail,ye=typeof de?.sessionId=="string"?de.sessionId.trim():"";if(!ye)return;const H=typeof de?.directory=="string"&&de.directory.trim().length>0?de.directory.trim():null;nt.getState().setCurrentSession(ye,H)};return window.addEventListener("openchamber:open-session",U),()=>window.removeEventListener("openchamber:open-session",U)},[]),c.useEffect(()=>{if(typeof window>"u")return;const U=()=>{jn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",U),()=>window.removeEventListener("openchamber:open-mini-chat",U)},[]),c.useEffect(()=>{if(typeof window>"u")return;const U=()=>{const Z=nt.getState().currentSessionId;Z&&Iu(Z)};return window.addEventListener("focus",U),()=>window.removeEventListener("focus",U)},[]),c.useEffect(()=>{if(typeof window>"u")return;const U=Z=>{const de=Z.detail,ye=typeof de?.directory=="string"&&de.directory.trim().length>0?de.directory.trim():null,H=typeof de?.projectId=="string"&&de.projectId.trim().length>0?de.projectId.trim():null,je=!!(ye||H);Ae.getState().setSessionSwitcherOpen(!1),nt.getState().openNewSessionDraft({target:je?"project":"chat",selectedProjectId:je?H:null,directoryOverride:je?ye:null,preserveDirectoryOverride:!!ye})};return window.addEventListener("openchamber:open-draft-session",U),()=>window.removeEventListener("openchamber:open-draft-session",U)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||q.current||(q.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),Bx({enabled:te}),iN({enabled:te}),cN(h||null),fN(),Fx(),hN(),Lx(),eb(),mp();const ce=c.useCallback(()=>{b(U=>!U)},[]);L5(ce),Q5(),nN(!K),c.useEffect(()=>{if(K)return;const U=()=>b(Z=>!Z);return window.addEventListener("openchamber:memory-debug-toggle",U),()=>window.removeEventListener("openchamber:memory-debug-toggle",U)},[K]),c.useEffect(()=>{K||d&&setTimeout(()=>u(),5e3)},[u,K,d]),c.useEffect(()=>{if(!L||Y!=="not-injected")return;let U=!1,Z=0;const de=200,ye=2e3,H=50,je=()=>{if(U)return;Z++;const Ee=wl();if(Ee!=="not-injected"){if(U=!0,I(Ee),Ee==="valid"){const ne=vl();ne&&A(Sl({isDesktopShell:!0,bootOutcome:ne}))}return}const ge=Math.min(de*Math.pow(1.1,Z),ye);if(Z>=H){const ne=document.getElementById("initial-loading");ne&&!ne.textContent?.includes("taking longer")&&(ne.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(je,ge)};return window.setTimeout(je,de),()=>{U=!0}},[L,Y]);const Te=c.useCallback(async()=>{if(wh({isDesktopShell:en(),isDesktopLocalOriginActive:Qo()})){await vh();return}window.location.reload()},[]),ve=c.useCallback(async()=>{if(!F){C(!1),B(!0);try{await Lt.getState().initializeApp()}finally{B(!1)}Lt.getState().isInitialized||R(U=>U+1)}},[F]),pe=U=>{if(U.screen==="recovery")return U.variant};if(L&&P&&P.screen!=="main"){if(P.screen==="chooser")return s.jsx(ps,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Od,{mode:"first-launch",localAvailable:P.localAvailable!==!1,onCliAvailable:Te,onChooseRemote:()=>{}})})})});const U=pe(P),Z=P.screen==="recovery"&&"url"in P?P.url:void 0;return s.jsx(ps,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Od,{mode:"recovery",recoveryVariant:U,recoveryHostUrl:Z,recoveryHostLabel:void 0,localAvailable:P.localAvailable!==!1,onCliAvailable:Te})})})})}if(K)return s.jsx(ps,{children:s.jsx(Hl,{sdk:Vs.getSdkClient(),directory:h||"",children:s.jsx(Gl,{apis:t,children:s.jsx(na,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(PN,{embeddedSessionChat:K,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:te}),s.jsx(ql,{}),s.jsx(Yl,{})]})})})},T)});if(w&&!n&&!m&&!K)return s.jsx(ps,{children:s.jsx(NN,{onRetry:()=>{ve()},isRetrying:F},T)});const Ne=!n&&!L;return s.jsx(ps,{children:s.jsx(Hl,{sdk:Vs.getSdkClient(),directory:h||"",children:s.jsx(Gl,{apis:t,children:s.jsx(i5,{children:s.jsx(na,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:L?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Yu,{embeddedBackgroundWorkEnabled:te}),s.jsx(ru,{}),s.jsx(gN,{}),s.jsx(OC,{}),s.jsx(hp,{ready:n&&(!L||re&&he)}),s.jsx(Qu,{}),s.jsx(ql,{}),s.jsx(Yl,{}),!Ne&&s.jsxs(s.Fragment,{children:[s.jsx(pp,{}),s.jsx(CN,{}),x&&s.jsx(b5,{onClose:()=>b(!1)})]})]})})})})},T)})}function IN(t){const e=Ze.c(2);let n;return e[0]!==t?(n=s.jsx(up,{children:s.jsx(DN,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function TN(t){return t.isAboutDialogOpen}function EN(t){return t.setAboutDialogOpen}function RN(){}function MN(t){return t.lastInitFailure}function ON(t){return t.currentDirectory}function BN(t){return t.currentSessionId}function FN(t){return t.setCurrentSession}const LN=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();$x();Sh().then(()=>{Promise.all([jh(),zx()]).catch(t=>{console.error("[main] settings init failed:",t)}),Wx(),Kx(),Vx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const jm=document.getElementById("root");if(!jm)throw new Error("Root element not found");Ux();qm.createRoot(jm).render(s.jsx(ct.StrictMode,{children:s.jsx(Hx,{children:s.jsx(Gx,{children:s.jsx(qx,{children:s.jsx(Yx,{children:s.jsx(IN,{apis:LN})})})})})}));const oA=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Zy as W,Wy as a,rA as b,vf as g,oA as m,Jy as u,wf as v};