@aiworker/web 1.23.1 → 1.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-teB3HmBT.js → CodeMirrorCommentWidgets-COGJG0Iv.js} +1 -1
  2. package/dist/assets/{DiffView-DC9RX3MF.js → DiffView-BviYY3zL.js} +1 -1
  3. package/dist/assets/{DirtyBranchSwitchDialog-DwPkzXsS.js → DirtyBranchSwitchDialog-C26DvfVJ.js} +1 -1
  4. package/dist/assets/{FilesView-BFZkuu4O.js → FilesView-D0ZU_nCt.js} +1 -1
  5. package/dist/assets/{GitView-B_x52MHY.js → GitView-CYgiDRH-.js} +1 -1
  6. package/dist/assets/{JsonTreeView-cmAzUTiw.js → JsonTreeView-GsV9UScz.js} +1 -1
  7. package/dist/assets/{LinearIssuesView-Dehh5afm.js → LinearIssuesView-shqUS8nl.js} +1 -1
  8. package/dist/assets/{MarkdownImageGallery-DgNOqqhE.js → MarkdownImageGallery-CQSTFp6m.js} +1 -1
  9. package/dist/assets/{MarkdownRendererImpl-DusmMZ_p.js → MarkdownRendererImpl-DJWP3A8X.js} +1 -1
  10. package/dist/assets/{OnboardingScreen-B8fm1H4m.js → OnboardingScreen-CTuu4lgo.js} +1 -1
  11. package/dist/assets/{PatchDiff-BVr7gJU0.js → PatchDiff-Dp53v2pl.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-DzLt-nel.js → PierreDiffViewer-B5l0djPS.js} +1 -1
  13. package/dist/assets/{PlanView-BmQUYT_z.js → PlanView-CLUWkGiG.js} +1 -1
  14. package/dist/assets/{SettingsView-ChWmAcZT.js → SettingsView-CojPQVHx.js} +1 -1
  15. package/dist/assets/{SettingsWindow-Dy3M6ZB9.js → SettingsWindow-DbgEnZ6T.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-cTl_eLIH.js → ToolOutputDialog-Du-RZj-a.js} +1 -1
  17. package/dist/assets/{ToolPartDiffPreview-C_3iYNJQ.js → ToolPartDiffPreview-HBLSokoe.js} +1 -1
  18. package/dist/assets/{VirtualizedFileDiff-CAWthkoy.js → VirtualizedFileDiff-Bzp3hClU.js} +1 -1
  19. package/dist/assets/{WalkthroughView-C7AHOpCA.js → WalkthroughView-CpgA4s9w.js} +1 -1
  20. package/dist/assets/{computeVirtualFileMetrics-BkiDSlTW.js → computeVirtualFileMetrics-CI1PC_z2.js} +1 -1
  21. package/dist/assets/{de-DJsQr-p7.js → de-BX8b4hDD.js} +1 -1
  22. package/dist/assets/{es-BuYMlA9g.js → es-e98cS-yM.js} +1 -1
  23. package/dist/assets/{fr-ePDay33C.js → fr-BOiqxJAs.js} +1 -1
  24. package/dist/assets/{index-n6O3hklM.js → index-Cmn74sw-.js} +1 -1
  25. package/dist/assets/{isDiffPlainText-GMdPz-71.js → isDiffPlainText-DVralkU-.js} +1 -1
  26. package/dist/assets/{isFilePlainText-BVuH1zH9.js → isFilePlainText-CgTREsRX.js} +1 -1
  27. package/dist/assets/{ja-BzR9xOY_.js → ja-aoO55hGu.js} +1 -1
  28. package/dist/assets/{ko-BEjHAm14.js → ko-BGzFLogk.js} +1 -1
  29. package/dist/assets/{main-D3ZDQglc.js → main-BgfXQ-4g.js} +2 -2
  30. package/dist/assets/{main-BydQ1tr_.js → main-DGYUWmIt.js} +4 -4
  31. package/dist/assets/{markdownCore-Cb2MdZnV.js → markdownCore-BesaNs_G.js} +1 -1
  32. package/dist/assets/{miniChat-d01k801U.js → miniChat-DHKXp-_I.js} +2 -2
  33. package/dist/assets/{mobile-D7VV-Ufz.js → mobile-lXQ08VnX.js} +2 -2
  34. package/dist/assets/{patchFileDiff-CdztVMz0.js → patchFileDiff-i1lTtNbn.js} +1 -1
  35. package/dist/assets/{pl-rQmpxNIF.js → pl-B5x19laq.js} +1 -1
  36. package/dist/assets/{pt-BR-CorbsSW-.js → pt-BR-C3oU51Il.js} +1 -1
  37. package/dist/assets/{renderElectronMiniChatApp-BGG9UIlh.js → renderElectronMiniChatApp-CuO4ue6B.js} +2 -2
  38. package/dist/assets/{renderMobileApp-BRP3J1iv.js → renderMobileApp-B3zFlHy4.js} +3 -3
  39. package/dist/assets/{runtimeEndpointReset-BhT_-c52.js → runtimeEndpointReset-BLzrtrmj.js} +3 -3
  40. package/dist/assets/{shikiHighlight-BzXUjlby.js → shikiHighlight-ctlcPvvx.js} +1 -1
  41. package/dist/assets/{tr-CoAMXPtI.js → tr-C0QQa7et.js} +1 -1
  42. package/dist/assets/{uk-YlAX0rRU.js → uk-CqLSe9wT.js} +1 -1
  43. package/dist/assets/{useAppFontEffects-Cwyhjfl5.js → useAppFontEffects-B6OfEypo.js} +8 -8
  44. package/dist/assets/{useGitComparison-BCZVefdE.js → useGitComparison-BXZXEAW6.js} +1 -1
  45. package/dist/assets/{useInlineCommentController-DDkpBEU8.js → useInlineCommentController-CgbrpEWu.js} +1 -1
  46. package/dist/assets/{useRootScrollLock-CwjoWuC4.js → useRootScrollLock-Me41OjBT.js} +1 -1
  47. package/dist/assets/{vendor-codemirror-language-data-Cb1YnICj.js → vendor-codemirror-language-data-SJuFp0a0.js} +2 -2
  48. package/dist/assets/{web-components-LV3vjTxy.js → web-components-D8GS8Ork.js} +1 -1
  49. package/dist/assets/{zh-CN-DDYg0Jl7.js → zh-CN-iJEie4d6.js} +6 -6
  50. package/dist/assets/{zh-TW-CQKaCayr.js → zh-TW-CyslEwlK.js} +1 -1
  51. package/dist/index.html +1 -1
  52. package/dist/mini-chat.html +1 -1
  53. package/dist/mobile.html +1 -1
  54. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-C7AHOpCA.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Cwyhjfl5.js","assets/index-BD8ILbxF.js","assets/vendor-zod-B6551dwG.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-zhgg-SDz.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BY_5qla_.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-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/contextPanelEmbeddedChat-BdA6bdky.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-Cb1YnICj.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-CdztVMz0.js","assets/runtimeEndpointReset-BhT_-c52.js","assets/VirtualizedFileDiff-CAWthkoy.js","assets/web-components-LV3vjTxy.js","assets/computeVirtualFileMetrics-BkiDSlTW.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-GMdPz-71.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DzLt-nel.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-DDkpBEU8.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/useRootScrollLock-CwjoWuC4.js","assets/scheduledTasksApi-BEuUF_cj.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-DC9RX3MF.js","assets/useGitComparison-BCZVefdE.js","assets/FilesView-BFZkuu4O.js","assets/shikiHighlight-BzXUjlby.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-cmAzUTiw.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-BVuH1zH9.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-teB3HmBT.js","assets/GitView-B_x52MHY.js","assets/DirtyBranchSwitchDialog-DwPkzXsS.js","assets/LinearIssuesView-Dehh5afm.js","assets/PlanView-BmQUYT_z.js","assets/SettingsWindow-Dy3M6ZB9.js","assets/SettingsView-ChWmAcZT.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-B8fm1H4m.js"])))=>i.map(i=>d[i]);
2
- import{f as st,R as c,j as s,r as gt,h as Uf}from"./vendor-react-BUCujlKS.js";import{D as bn,E as Wo,F as Kf,G as ad,h as ds,v as zo,u as Te,H as Mt,I as Ga,J as Hf,K as Pn,L as Gf,N as vt,O as qs,P as Vo,Q as ld,R as qf,S as Qf,T as Yf,U as Xf,V as cd,z as ma,n as ts,W as Mn,X as $r,e as Nn,Y as Jf,a as us,Z as Zf,_ as em,$ as tm,a0 as dd,t as hn,A as Qs,a1 as sm,a2 as nm,a3 as qa,a4 as rm,a5 as ud,a6 as om,a7 as fd,f as im,a8 as am,a9 as or,aa as ha,d as No,q as Rr,o as ls,ab as md,ac as lm,ad as wi,ae as cm,af as dm,i as um,ag as fo,ah as mo,ai as fm,aj as Qa,ak as mm,al as hm,am as pm,an as gm,ao as Ya,ap as Xa,aq as Ja,ar as Za,as as xm,y as el,at as bm,au as ym,av as wm,B as Sm,C as vm}from"./index-BD8ILbxF.js";import{_ as Bn}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Nt,h as Ie,bb as Kt,I as E,g as gn,t as Le,ap as Ys,bc as Os,ar as Xs,ao as Js,R as Zn,Y as Sn,ae as er,bd as _n,o as Uo,be as tl,bf as jm,bg as km,a9 as At,aa as Dt,ab as Pt,b as Ht,y as Je,G as Cm,bh as hd,bi as Jr,u as Is,A as pa,r as Ts,C as pd,bj as Si,bk as Nm,bl as gd,bm as xd,bn as bd,bo as ga,bp as Ko,bq as yd,br as wd,bs as Am,bt as sl,bu as Dm,bv as Pm,bw as xa,bx as vi,by as Im,bz as Tm,N as Sd,bA as Rm,l as qt,bB as Em,n as ar,bC as vd,p as Mm,bD as jd,bE as Om,bF as Fm,bG as Bm,bH as kd,bI as Cd,bJ as _m,aD as ba,bK as qn,bL as qr,bM as Lm,bN as vs,bO as js,bP as $s,bQ as Rs,bR as Es,bS as yn,B as xt,bT as cn,ax as Gs,bU as $m,bV as Wm,aB as An,bW as ho,bX as Hs,bY as Ho,bZ as Nd,b_ as ji,b$ as ki,c0 as Ci,c1 as zm,c2 as Fs,c3 as Bs,c4 as As,c5 as _s,c6 as ss,V as Cn,c7 as lr,c8 as nl,c9 as ur,ca as Ad,Q as Go,af as Vm,ag as ya,ah as Dd,H as Pd,J as Dn,cb as qo,a4 as wa,cc as Um,cd as Km,av as Hm,ce as Gm,cf as qm,cg as Qm,aw as Sa,ch as va,ci as fr,cj as Id,ck as Ym,cl as Xm,cm as Qr,cn as Jm,aJ as Yr,co as Zm,cp as ir,O as Td,cq as eh,cr as th,cs as Ln,ct as sh,cu as nh,cv as ei,cw as Rd,cx as Ed,cy as rh,aC as Ni,cz as Ai,cA as oh,cB as rl,cC as Er,c as Wr,d as ja,a0 as ih,cD as Md,cE as jr,cF as Mr,cG as ah,cH as lh,cI as ch,Z as Od,ay as dh,cJ as uh,cK as fh,cL as mh,cM as hh,cN as Fd,cO as xn,cP as ph,cQ as Bd,cR as gh,cS as Di,cT as xh,cU as bh,cV as _d,cW as yh,cX as Ld,a2 as Ao,cY as Pi,T as ka,S as Ca,U as Na,cZ as Aa,a as Da,a1 as wh,c_ as ol,c$ as Ii,d0 as $d,d1 as Sh,aq as Wd,d2 as vh,P as Ti,K as jh,d3 as il,d4 as kh,d5 as al,d6 as Ch,d7 as Nh,d8 as Ah,d9 as cs,da as Dh,db as Fn,dc as Pa,dd as zd,de as Ph,df as Vd,dg as Ud,dh as Ih,D as Th,di as Rh,dj as Eh,dk as Mh,dl as ll,dm as Oh,dn as Fh,dp as Kd,E as Bh,dq as po,dr as Hd,ds as _h,dt as Lh,du as $h,dv as Wh,e as Gd,dw as Ia,dx as zh,dy as zr,dz as Vh,dA as cl,dB as Uh,dC as Kh,$ as Hh,dD as Gh,aV as dl,a6 as ul,a5 as fl,dE as qh,aQ as Ri,dF as Qh,L as Yh,M as ti,dG as Xh,dH as Jh,dI as qd,dJ as Qd,dK as Yd,dL as Zh,F as Ta,dM as ep,a3 as tp,dN as sp,dO as np,dP as rp,dQ as op,dR as ip,dS as ap,dT as lp,dU as cp,dV as Do,ai as dp,dW as up,dX as ml,dY as fp,dZ as mp,d_ as hp,d$ as pp,e0 as Po,e1 as gp,e2 as hl,e3 as xp,e4 as bp,e5 as yp,e6 as wp,e7 as Sp,e8 as vp,e9 as go,ea as jp,i as kp,eb as Cp,ec as Np,ed as Ap,ee as Dp,a7 as Pp,ef as Ip,eg as Tp,eh as Rp,ei as Ep,ej as pl,ek as Mp,aK as Op,aL as Fp,aM as Bp,aO as gl,aP as xl,aS as bl,aT as yl,aR as Xd,aU as Jd,el as _p,b6 as Lp,b7 as $p,b8 as Wp,b9 as zp,ba as Vp,b0 as Up,b2 as Kp,b3 as Hp,b4 as Gp,b5 as qp}from"./useAppFontEffects-Cwyhjfl5.js";import{u as Zd,S as wl,C as Qp,W as eu,f as Yp,a as Xp}from"./useRootScrollLock-CwjoWuC4.js";import{n as Sl,o as si,t as un,q as Ei,v as vl,w as Jp,x as Zp,y as eg,z as tg,A as sg,E as ng,F as rg,G as og,H as Ra,I as ig,a as ag,U as tu,h as Mi,f as su,J as lg,e as cg,d as dg,K as nu,L as Oi,M as Un,Q as ru,R as ou,P as ug,T as fg,V as mg,W as hg,X as pg,Y as gg,S as jl,Z as xg,_ as bg,$ as yg,u as Fr,s as wg,N as Sg,D as vg,a0 as jg,a1 as kl,a2 as kg,k as Cg,i as Ng,l as iu,m as Ag,a3 as Dg,a4 as Pg,a5 as Ig,g as Tg,j as Rg,O as au,C as Eg}from"./runtimeEndpointReset-BhT_-c52.js";import{u as Wn,O as Cl,D as Mg,a as Og,b as Fg,n as Bg,f as _g,c as Nl,s as Lg,d as $g,e as Wg,r as zg}from"./scheduledTasksApi-BEuUF_cj.js";import{f as Vr,h as On,T as lu,M as cu,D as Ur,j as Kr,d as Vg,P as Fi,b as Ug,k as Bi,i as Kg}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Qo,S as Io,h as Hg,a as du,v as _i,s as Gg}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as uu,M as fu,C as mu,a as Li,b as $i,c as Wi,d as hu,e as qg,f as Qg}from"./vendor-base-ui-BY_5qla_.js";import{c as tr,u as Jn,d as pu,p as Yg}from"./vendor-zustand-BAGL70zf.js";import{g as Xg,a as Jg,E as gu,b as Zg,c as ex,d as tx,e as sx,i as nx}from"./contextPanelEmbeddedChat-BdA6bdky.js";import{c as Ea,s as br,r as xu}from"./vendor-zod-B6551dwG.js";import{u as rx}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as bu}from"./vendor-cron-parser-CUcP7OfX.js";const ox="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",ix="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",ni=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__AIWORKER_PLATFORM__==="darwin"?ox:t.id==="terminal"?ix:void 0}),Al=t=>{const e=st.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 u=a,d=r||i;if(d&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let g;return e[3]!==d?(g=s.jsx("img",{src:d,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=d,e[4]=g):g=e[4],g}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Ie("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]!==u?(f=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=f):f=e[7],f},ax=t=>{const e=st.c(75),{directory:n,className:r}=t,{t:i}=Nt(),o=Wn(lx),l=Wn(cx),a=Wn(dx),u=Wn(ux),d=Wn(fx),h=Wn(mx),f=Wn(hx);let p,g;e[0]!==d?(p=()=>{d()},g=[d],e[0]=d,e[1]=p,e[2]=g):(p=e[1],g=e[2]),c.useEffect(p,g);const w=bn()&&Wo();let S;e:{let K;e[3]!==l||e[4]!==o?(K=l.find(ne=>ne.id===o)??l.find(px)??l[0]??Cl[0],e[3]=l,e[4]=o,e[5]=K):K=e[5];const pe=K;if(pe){let ne;e[6]!==pe?(ne=ni(pe),e[6]=pe,e[7]=ne):ne=e[7],S=ne;break e}let je;e[8]===Symbol.for("react.memo_cache_sentinel")?(je=ni(Cl[0]),e[8]=je):je=e[8],S=je}const x=S;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async K=>{await Kf(n,K.id,K.appName)||await ad(n,K.appName)},e[9]=n,e[10]=m):m=e[10];const b=m;let y;e[11]!==b||e[12]!==f?(y=async K=>{await f(K.id),await b(K)},e[11]=b,e[12]=f,e[13]=y):y=e[13];const v=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await gn(n)).ok&&Le.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const C=N;let k;e[17]!==r?(k=Ie("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]=k):k=e[18];let D;e[19]!==b||e[20]!==x?(D=()=>{b(x)},e[19]=b,e[20]=x,e[21]=D):D=e[21];const P=u&&"animate-pulse";let I;e[22]!==P?(I=Ie("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=I):I=e[23];let M;e[24]!==x.label||e[25]!==i?(M=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=M):M=e[26];let _;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(_=s.jsx(Al,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=_):_=e[30];let O;e[31]!==I||e[32]!==M||e[33]!==_||e[34]!==D?(O=s.jsx("button",{type:"button",onClick:D,className:I,"aria-label":M,children:_}),e[31]=I,e[32]=M,e[33]=_,e[34]=D,e[35]=O):O=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=Ie("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]=U):U=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=F):F=e[39];let R;e[40]!==L?(R=s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:U,"aria-label":L,children:F})}),e[40]=L,e[41]=R):R=e[41];let j;e[42]!==C?(j=()=>{C()},e[42]=C,e[43]=j):j=e[43];let A;e[44]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(E,{name:"file-copy",className:"h-4 w-4"}),e[44]=A):A=e[44];let B;e[45]!==i?(B=i("openInApp.actions.copyPath"),e[45]=i,e[46]=B):B=e[46];let X;e[47]!==B?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:B}),e[47]=B,e[48]=X):X=e[48];let H;e[49]!==j||e[50]!==X?(H=s.jsxs(Kt,{className:"flex items-center gap-2",onClick:j,children:[A,X]}),e[49]=j,e[50]=X,e[51]=H):H=e[51];let Z;e[52]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Os,{}),e[52]=Z):Z=e[52];let ce;if(e[53]!==l||e[54]!==v||e[55]!==x.id){let K;e[57]!==v||e[58]!==x.id?(K=pe=>{const je=ni(pe);return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{v(pe)},children:[s.jsx(Al,{label:pe.label,iconDataUrl:pe.iconDataUrl,fallbackIconDataUrl:je.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:pe.label}),x.id===pe.id?s.jsx(E,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},pe.id)},e[57]=v,e[58]=x.id,e[59]=K):K=e[59],ce=l.map(K),e[53]=l,e[54]=v,e[55]=x.id,e[56]=ce}else ce=e[56];let Y;e[60]!==a||e[61]!==h||e[62]!==i?(Y=a?s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(E,{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]=Y):Y=e[63];let se;e[64]!==H||e[65]!==ce||e[66]!==Y?(se=s.jsxs(Xs,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[H,Z,ce,Y]}),e[64]=H,e[65]=ce,e[66]=Y,e[67]=se):se=e[67];let oe;e[68]!==R||e[69]!==se?(oe=s.jsxs(Js,{children:[R,se]}),e[68]=R,e[69]=se,e[70]=oe):oe=e[70];let Se;return e[71]!==O||e[72]!==oe||e[73]!==k?(Se=s.jsxs("div",{className:k,children:[O,oe]}),e[71]=O,e[72]=oe,e[73]=k,e[74]=Se):Se=e[74],Se};function lx(t){return t.selectedAppId}function cx(t){return t.availableApps}function dx(t){return t.isCacheStale}function ux(t){return t.isScanning}function fx(t){return t.initialize}function mx(t){return t.loadInstalledApps}function hx(t){return t.selectApp}function px(t){return t.id===Mg}const To=new Map,zi=new Set,yu=()=>{for(const t of zi)t()},ri=(t,e)=>{const n=t.trim();n&&(e.length===0?To.delete(n):To.set(n,[...e]),yu())},gx=t=>{To.delete(t.trim())&&yu()},wu=[],xx=t=>To.get(t.trim())??wu,bx=t=>(zi.add(t),()=>{zi.delete(t)}),yx=t=>{const e=st.c(2);let n;return e[0]!==t?(n=()=>xx(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(bx,n,wx)};function wx(){return wu}const Sx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],vx=["dev","start","preview","serve"];async function jx(t,e,n){if(!t)return null;const r=Nx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Ax(n);if(i){const o=await Dx(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 kx(t)){const i=await Cx(),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 kx(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function Cx(){try{const t=await ds("/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 Nx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(vx.some(i=>n.includes(i)))return e}return null}function Ax(t){for(const{pattern:e}of Sx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Dx(t){const e=await Ro(`${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 Ro(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ro(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=zo()?.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 ds(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Px(t){try{const e=await Ro(`${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 mn="__aiworker_auto_discover_preview__",Ix=15e3,Tx=3e3,oi=t=>t.id===mn?"scan-2":og.find(n=>n.key===t.icon)?.Icon??"play",Rx=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}},Ex=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=Nt(),{currentTheme:l}=Zn(),{terminal:a,runtime:u}=Sn(),d=er(),{isMobile:h}=_n(),f=c.useMemo(()=>bn(),[]),p=Sl(J=>J.instances),g=Sl(J=>J.load),w=Te(J=>J.terminalShell),S=Te(J=>J.terminalLoginShells.includes(J.terminalShell)),x=Te(J=>J.setSettingsPage),m=Te(J=>J.setSettingsDialogOpen),b=Te(J=>J.setSettingsProjectsSelectedId),y=Te(J=>J.openContextPreview),v=Mt(J=>J.ensureDirectory),N=Mt(J=>J.reconcileServerSessions),C=Mt(J=>J.setTabLabel),k=Mt(J=>J.setTabIconKey),D=Mt(J=>J.setActiveTab),P=Mt(J=>J.setConnecting),I=Mt(J=>J.setTabSessionId),M=Mt(J=>J.setTabPurpose),_=Mt(J=>J.allocateActionExecution),O=Mt(J=>J.setTabLifecycle),U=Mt(J=>J.setTabPreviewUrl),L=Mt(J=>J.matchesActionExecution),F=Mt(J=>J.captureStartedActionMutationRevisions),[R,j]=c.useState([]),A=c.useRef(null),[B,X]=c.useState(null),[H,Z]=c.useState(!1),ce=c.useRef({}),Y=c.useRef({}),se=c.useRef({}),oe=c.useRef(new Set),Se=c.useRef(0),[K,pe]=c.useState({}),je=t?.id??null,ne=t?.path??"",T=c.useMemo(()=>je?{id:je,path:ne}:null,[je,ne]);c.useEffect(()=>{f&&g().catch(()=>{})},[f,g]);const G=c.useCallback(async J=>{await Uo(J)},[]),le=c.useCallback(async()=>{if(!T)return;const J=Se.current+1;Se.current=J,Z(!0);try{const re=await tl(T);if(Se.current!==J)return;A.current=re;const Pe=re.projectActions;j(Pe),X(_e=>_e===mn||_e&&Pe.some(Ve=>Ve.id===_e)?_e:null)}catch{if(Se.current!==J)return}finally{Se.current===J&&Z(!1)}},[T]),de=c.useMemo(()=>si(e||T?.path||""),[e,T?.path]),ue=c.useMemo(()=>si(T?.path||""),[T?.path]),Oe=c.useMemo(()=>si(d||"")||de,[d,de]),me=c.useRef(Oe);c.useEffect(()=>{me.current=Oe},[Oe]);const Re=Mt(J=>de?J.getDirectoryState(de):void 0),ye=Mt(J=>ue&&ue!==de?J.getDirectoryState(ue):void 0),q=c.useMemo(()=>{const J=de?[{directory:de,state:Re}]:[];return ue&&ue!==de&&J.push({directory:ue,state:ye}),J},[Re,de,ue,ye]),we=c.useMemo(()=>{const J=de?[de]:[];return ue&&ue!==de&&J.push(ue),J},[de,ue]),be=c.useCallback(J=>J.id!==mn&&J.runIn==="parent"&&ue||de,[de,ue]),Ne=c.useCallback((J,re,Pe)=>`${J}::${re}::${Pe}`,[]),ie=c.useCallback((J,re,Pe=Mt.getState())=>J?Pe.getDirectoryState(J)?.tabs.find(_e=>_e.purpose.type==="project-action"&&_e.purpose.actionId===re)??null:null,[]),ee=c.useMemo(()=>{const J={};for(const{directory:re,state:Pe}of q)for(const _e of Pe?.tabs??[]){if(_e.purpose.type!=="project-action"||!_e.purpose.executionId||!_e.terminalSessionId||_e.lifecycle==="idle"||_e.lifecycle==="exited")continue;const Ve=un(re,_e.purpose.actionId),Ze=Ne(re,_e.purpose.actionId,_e.purpose.executionId);J[Ve]={directory:re,actionId:_e.purpose.actionId,tabId:_e.id,sessionId:_e.terminalSessionId,executionId:_e.purpose.executionId,status:_e.lifecycle==="stopping"?"stopping":K[Ze]?"waiting-for-preview":"running"}}return J},[Ne,K,q]),V=c.useCallback((J,re,Pe)=>{const _e=un(J,re),Ve=Ne(J,re,Pe),lt=ce.current[_e]?.executionId===Pe,rt=globalThis.window,Ge=ot=>{rt?.clearTimeout(se.current[ot]),delete se.current[ot]};lt&&(delete ce.current[_e],Ge(_e)),Y.current[Ve]?.(),delete Y.current[Ve],Ge(Ve),pe(ot=>{if(!ot[Ve])return ot;const Ee={...ot};return delete Ee[Ve],Ee})},[Ne]),$=c.useCallback(J=>{Y.current[J]?.(),delete Y.current[J]},[]),ae=c.useCallback(J=>{window.clearTimeout(se.current[J]),delete se.current[J]},[]);c.useEffect(()=>{const J=Y.current,re=se.current;return()=>{for(const Pe of Object.keys(J))$(Pe);for(const Pe of Object.keys(re))ae(Pe)}},[ae,$]),c.useEffect(()=>{const J=new Set(we);for(const re of Object.values(ce.current))J.has(re.directory)||V(re.directory,re.actionId,re.executionId);for(const re of Object.keys(Y.current)){const Pe=re.split("::",1)[0]??"";J.has(Pe)||$(re)}},[V,$,we]);const W=c.useCallback((J,re)=>{Te.getState().openContextPanelTab(J,{mode:"terminal",targetDirectory:re===J?null:re})},[]),ve=c.useMemo(()=>B?R.find(J=>J.id===B)??null:null,[R,B]),Fe=c.useMemo(()=>({id:mn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Ce=!h,ke=c.useMemo(()=>Ce?[Fe,...R]:R,[R,Fe,Ce]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{const J=we.map(re=>Ei(a,re,F,Pe=>N(re,Pe.sessions,{startedActionMutationRevisions:Pe.startedActionMutationRevisions})));return()=>{for(const re of J)re()}},[F,N,a,we]),c.useEffect(()=>{for(const{directory:J,state:re}of q)if(J)for(const Pe of re?.tabs??[]){if(Pe.purpose.type!=="project-action")continue;const _e=Pe.purpose.actionId,Ve=ke.find(rt=>rt.id===_e),Ze=Ve?.name??_e,lt=Ve?.icon||"play";Pe.label!==Ze&&C(J,Pe.id,Ze),Pe.iconKey!==lt&&k(J,Pe.id,lt)}},[ke,k,C,q]),c.useEffect(()=>{const J=globalThis.window;if(!J)return;const re=Pe=>{const _e=Pe.detail;je&&(_e?.projectId&&_e.projectId!==je||le())};return J.addEventListener(vl,re),()=>{J.removeEventListener(vl,re)}},[le,je]),c.useEffect(()=>{B&&(B===mn&&Ce||R.some(J=>J.id===B)||X(null))},[R,Ce,B]),c.useEffect(()=>{const J=Pe=>{delete se.current[Pe];const _e=ce.current[Pe];if(!_e||_e.openedUrl)return;const Ve=Ne(_e.directory,_e.actionId,_e.executionId),Ze=_e.announced;if(Ze.length!==0){if(window.clearTimeout(se.current[Ve]),delete se.current[Ve],_e.openedUrl=!0,pe(lt=>{if(!lt[Ve])return lt;const rt={...lt};return delete rt[Ve],rt}),Ze.length===1){ri(_e.directory,[]),U(_e.directory,_e.tabId,Ze[0],{locked:!1,autoOpened:!0}),y(_e.directory,Ze[0]);return}_e.offering=!0,ri(_e.directory,Ze),Te.getState().openContextSurface(_e.directory,"browser"),Le.info(o("projectActions.toast.multipleServers"))}},re=()=>{const Pe=Mt.getState(),_e=Pe.sessions,Ve=ee;for(const[Ze,lt]of Object.entries(Ve)){const Ge=_e.get(lt.directory)?.tabs.find(yt=>yt.id===lt.tabId);if(!Ge||Ge.terminalSessionId!==lt.sessionId){V(lt.directory,lt.actionId,lt.executionId);continue}const ot=ce.current[Ze],Ee=ot?.executionId===lt.executionId?ot:{hostDirectory:me.current||lt.directory,directory:lt.directory,tabId:lt.tabId,actionId:lt.actionId,executionId:lt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ce.current[Ze]=Ee;const Rt=ke.find(yt=>yt.id===lt.actionId),xe=Pe.getBuffer(lt.directory,lt.tabId).chunks;if(!Rt||xe.length===0)continue;const mt=xe.filter(yt=>Ee.lastSeenChunkId===null||yt.id>Ee.lastSeenChunkId);if(mt.length===0)continue;const Tt=mt.map(yt=>yt.data).join(""),Xe=`${Ee.tail}${Tt}`;if(Ee.openInPreview&&(!Ee.openedUrl||Ee.offering)){const yt=ng(Xe),It=Ee.announced.length;for(const Et of yt)Ee.announced.includes(Et)||Ee.announced.push(Et);const kt=Ee.announced.length-It;Ee.offering&&kt>0?ri(lt.directory,Ee.announced):!Ee.openedUrl&&It===0&&Ee.announced.length>0&&(window.clearTimeout(se.current[Ze]),se.current[Ze]=window.setTimeout(()=>J(Ze),Tx))}const nt=!Ee.openedUrl&&Rt.autoOpenUrl===!0&&!Ee.openInPreview?rg(Xe):null,St=mt[mt.length-1]?.id??Ee.lastSeenChunkId;if(Ee.lastSeenChunkId=St,Ee.tail=Xe.slice(-512),nt)if(Ee.openedUrl=!0,Ee.openInPreview){const yt=Ve[Ze];yt&&(U(yt.directory,yt.tabId,nt,{locked:!1,autoOpened:!1,expectedExecutionId:yt.executionId}),yt.status==="waiting-for-preview"&&pe(It=>{const kt=Ne(yt.directory,yt.actionId,yt.executionId);if(!It[kt])return It;const Et={...It};return delete Et[kt],Et}),window.clearTimeout(se.current[Ze]),delete se.current[Ze],y(yt.directory,nt))}else G(nt),Le.success(o("projectActions.toast.openedUrlFromOutput"));ce.current[Ze]=Ee}for(const Ze of Object.keys(ce.current))if(!Ve[Ze]){const lt=ce.current[Ze],rt=lt?_e.get(lt.directory)?.tabs.find(ot=>ot.id===lt.tabId):void 0;if(rt?.purpose.type==="project-action"&&rt.purpose.executionId===lt?.executionId&&!!rt.terminalSessionId&&rt.lifecycle!=="idle"&&rt.lifecycle!=="exited")continue;delete ce.current[Ze],window.clearTimeout(se.current[Ze]),delete se.current[Ze]}};return re(),Mt.subscribe((Pe,_e)=>{(Pe.sessions!==_e.sessions||Pe.buffers!==_e.buffers)&&re()})},[V,me,ke,Ne,y,G,ee,U,o]),c.useEffect(()=>{for(const{directory:J,state:re}of q)for(const Pe of re?.tabs??[]){if(Pe.purpose.type!=="project-action"||!Pe.purpose.executionId||!Pe.terminalSessionId||Pe.lifecycle!=="running")continue;const _e=Pe.purpose.actionId,Ve=Pe.purpose.executionId,Ze=Ne(J,_e,Ve);if(Y.current[Ze])continue;const lt=a.connect(Pe.terminalSessionId,{onEvent:rt=>{if(!L(J,Pe.id,Ve))return;rt.type==="snapshot"&&(Mt.getState().replaceBuffer(J,Pe.id,rt.data??"",rt.sequence??0,Ga(rt)),rt.status==="running"&&Mt.getState().setTabLifecycle(J,Pe.id,"running",{expectedExecutionId:Ve}),rt.status==="exited"&&(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve)));const Ge=rt.type==="data"?rt.data??"":"";Ge&&Mt.getState().appendToBuffer(J,Pe.id,Ge,rt.sequence,rt.replayData),rt.type==="exit"&&(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve))},onError:(rt,Ge)=>{!Ge||!L(J,Pe.id,Ve)||(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabSessionId(J,Pe.id,null,{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve))}});Y.current[Ze]=lt.close}},[V,Ne,L,a,q]);const Qe=c.useCallback(async J=>{const re=be(J);if(!re)throw new Error(o("projectActions.error.noActiveDirectory"));const Pe=un(re,J.id);v(re);const _e=Mt.getState(),Ve=ie(re,J.id,_e),Ze=Ve?.id??_e.createTab(re);C(re,Ze,J.name),k(re,Ze,J.icon||"play"),Ve||M(re,Ze,{type:"project-action",actionId:J.id,executionId:null}),D(re,Ze);const rt=Mt.getState().getDirectoryState(re)?.tabs.find(Ge=>Ge.id===Ze);return{executionDirectory:re,key:Pe,tabId:Ze,sessionId:rt?.terminalSessionId??null,executionId:rt?.purpose.type==="project-action"?rt.purpose.executionId:null}},[v,be,ie,D,k,C,M,o]),We=c.useCallback(async J=>{if(u.isVSCode||!i&&h)return;if(!de){Le.error(o("projectActions.error.noActiveDirectoryForAction"));return}const re=un(be(J),J.id),Pe=ee[re];if(Pe&&Pe.status==="running"||oe.current.has(re))return;oe.current.add(re);let _e=null;try{const Ve=J.id===mn?await(async()=>{const[kt,Et]=await Promise.all([jm({id:T?.id??"",path:de}),Px(de)]),Bt=await jx(de,kt.actions,Et);if(!Bt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:mn,name:o("projectActions.actions.autoDiscover"),command:Bt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Bt.previewUrlHint||""}})():J,Ze=Ve.autoOpenUrl===!0&&(Ve.openUrl||"").trim().length>0,lt=!Ze&&J.id!==mn,rt=me.current||de,{executionDirectory:Ge,key:ot,tabId:Ee}=await Qe(Ve),Rt=Jp(Ve.command);if(!Rt)throw new Error(o("projectActions.error.failedToRunAction"));const xe=Ve.autoOpenUrl===!0&&f&&(Ve.desktopOpenSshForward||"").trim().length>0,mt=Ve.autoOpenUrl?Rx(Ve.openUrl):null,Tt=Ve.autoOpenUrl&&f?Zp(Ve.desktopOpenSshForward,p):null;if(a.listSessions){const kt=ie(Ge,Ve.id);if(kt?.purpose.type==="project-action"&&kt.purpose.executionId===null){const Et=await eg(a,Ge,{captureStartedActionMutationRevisions:F});Et&&N(Ge,Et.sessions,{startedActionMutationRevisions:Et.startedActionMutationRevisions})}}const Xe=ie(Ge,Ve.id);let nt,St;if(Xe?.lifecycle==="running"&&Xe.terminalSessionId&&Xe.purpose.type==="project-action"&&Xe.purpose.executionId)nt=Xe.terminalSessionId,St=Xe.purpose.executionId;else{const kt=Xe?.purpose.type==="project-action"?Xe.purpose.executionId:null;kt&&V(Ge,Ve.id,kt);const Et=_(Ge,Ee,Ve.id);if(!Et)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));_e={directory:Ge,tabId:Ee,id:Et},P(Ge,Ee,!0,{expectedExecutionId:Et});const Bt=await tg({terminal:a,createOptions:{cwd:Ge,shell:w,loginShell:S,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Rt,isRunStillExpected:()=>L(Ge,Ee,Et),purpose:{type:"project-action",actionId:Ve.id,executionId:Et}});if(!L(Ge,Ee,Et)){Bt.sessionId===Et&&await a.close(Bt.sessionId).catch(()=>{});return}St=Bt.purpose?.type==="project-action"?Bt.purpose.executionId:Et,nt=Bt.sessionId,M(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:St}),I(Ge,Ee,nt,{expectedExecutionId:St}),P(Ge,Ee,!1,{expectedExecutionId:St})}lt&&rt&&W(rt,Ge),ce.current[ot]={hostDirectory:rt,directory:Ge,tabId:Ee,actionId:Ve.id,executionId:St,lastSeenChunkId:null,openedUrl:!!Tt||!!mt||Ze,tail:"",openInPreview:Ve.id===mn,announced:[],offering:!1};const yt=Ne(Ge,Ve.id,St);P(Ge,Ee,!0,{expectedExecutionId:St});const It=a.connect(nt,{onEvent:kt=>{if(!L(Ge,Ee,St)||kt.purpose?.type==="project-action"&&kt.purpose.executionId!==St)return;kt.type==="snapshot"&&(Mt.getState().replaceBuffer(Ge,Ee,kt.data??"",kt.sequence??0,Ga(kt)),Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),kt.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:kt.purpose.actionId,executionId:kt.purpose.executionId}),kt.status==="running"&&Mt.getState().setTabLifecycle(Ge,Ee,"running",{expectedExecutionId:St}),kt.status==="exited"&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St)));const Et=kt.type==="data"?kt.data??"":"";Et&&Mt.getState().appendToBuffer(Ge,Ee,Et,kt.sequence,kt.replayData),kt.type==="exit"&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St))},onError:(kt,Et)=>{L(Ge,Ee,St)&&(Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),Et&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setTabSessionId(Ge,Ee,null,{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St)))}});if(!L(Ge,Ee,St)){It.close();return}Y.current[yt]?.(),Y.current[yt]=It.close,window.clearTimeout(se.current[yt]),delete se.current[yt],Ve.id===mn&&!mt&&(pe(kt=>({...kt,[yt]:!0})),se.current[yt]=window.setTimeout(()=>{delete se.current[yt];const kt=ce.current[ot];!kt||kt.executionId!==St||kt.openedUrl||kt.offering||L(Ge,Ee,St)&&(pe(Et=>{if(!Et[yt])return Et;const Bt={...Et};return delete Bt[yt],Bt}),Mt.getState().setActiveTab(Ge,Ee),W(kt.hostDirectory,Ge))},Ix)),Tt?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),G(Tt),Le.success(o("projectActions.toast.openedForwardedUrl"))):mt?(U(Ge,Ee,mt,{locked:!0,autoOpened:!0,expectedExecutionId:St}),y(rt,mt),Le.success(o("projectActions.toast.openedActionUrl"))):Ze?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),Le.error(o("projectActions.error.invalidCustomUrlFormat"))):xe?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),Le.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):U(Ge,Ee,null,{locked:!1,autoOpened:!1,expectedExecutionId:St})}catch(Ve){if(_e&&L(_e.directory,_e.tabId,_e.id)){const{directory:Ze,tabId:lt,id:rt}=_e;V(Ze,J.id,rt),O(Ze,lt,"exited",{expectedExecutionId:rt}),M(Ze,lt,{type:"project-action",actionId:J.id,executionId:null})}if(Ve instanceof Error&&Ve.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ve instanceof Error&&(Ve.message==="COMMAND_MODE_UNSUPPORTED"||Ve.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Le.error(o("projectActions.error.failedToCreateTerminalSession"));return}Le.error(Ve instanceof Error?Ve.message:o("projectActions.error.failedToRunAction"))}finally{oe.current.delete(re)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,me,p,Qe,i,h,f,de,S,w,G,y,ee,W,u.isVSCode,be,L,V,Ne,ie,N,_,F,P,O,M,U,I,T?.id,o,a]),z=c.useCallback(async J=>{const re=un(be(J),J.id),Pe=ee[re];Pe&&await sg({terminal:a,sessionId:Pe.sessionId,isExecutionStillCurrent:()=>L(Pe.directory,Pe.tabId,Pe.executionId),markStopping:()=>{O(Pe.directory,Pe.tabId,"stopping",{expectedExecutionId:Pe.executionId})},restoreRunning:()=>{O(Pe.directory,Pe.tabId,"running",{expectedExecutionId:Pe.executionId})},clearSession:()=>{I(Pe.directory,Pe.tabId,null,{expectedExecutionId:Pe.executionId})},finalizeExit:()=>{O(Pe.directory,Pe.tabId,"exited",{expectedExecutionId:Pe.executionId}),M(Pe.directory,Pe.tabId,{type:"project-action",actionId:Pe.actionId,executionId:null}),V(Pe.directory,Pe.actionId,Pe.executionId)}})},[V,be,L,ee,O,M,I,a]),he=c.useCallback(()=>{const J=ve??ke[0];if(!J)return;const re=un(be(J),J.id),Pe=ee[re];if(Pe?.status!=="stopping"){if(Pe){z(J);return}We(J)}},[ke,be,We,ee,ve,z]),Be=c.useCallback(async J=>{if(J.source==="shared"&&T){const re=A.current?.trust.trusted?A.current:await tl(T);if(A.current=re,!await km(T,re))return;A.current={...re,trust:{...re.trust,trusted:!0}}}await We(J)},[We,T]),Ae=c.useCallback((J,re=!1)=>{if(X(J.id),!re){Be(J);return}const Pe=un(be(J),J.id),_e=ee[Pe];if(_e?.status!=="stopping"){if(_e){z(J);return}Be(J)}},[be,Be,ee,z]),at=c.useCallback(()=>{T?.id&&(b(T.id),x("projects"),m(!0))},[m,x,b,T?.id]),Ue=ve??ke[0]??null,ht=Ue?ee[un(be(Ue),Ue.id)]:null,ut=Mt(J=>ht?J.getDirectoryState(ht.directory)?.tabs.find(re=>re.id===ht.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&h||!T||!de)return null;const Ct=ve??ke[0]??null;if(!Ct)return null;const ge=oi(Ct),Ye=un(be(Ct),Ct.id),bt=ee[Ye],jt=bt?.status==="stopping",fe=bt?.status==="waiting-for-preview",ze=!!(bt&&ut),it=()=>{!bt||!ut||y(bt.directory,ut)},$e=Ct.id===mn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:H||jt,className:Ie("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-primary","disabled:cursor-not-allowed",n),onClick:he,"aria-label":bt?o("projectActions.actions.stopNamedAria",{name:Ct.name}):o("projectActions.actions.runNamedAria",{name:Ct.name}),children:jt||fe?s.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):bt?s.jsx(E,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(E,{name:ge,className:"h-5 w-5"})})}),$e?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),ze?s.jsxs(At,{children:[s.jsx(Dt,{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-primary","aria-label":o("projectActions.actions.openPreview"),onClick:it,children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Js,{children:[s.jsx(Ys,{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-primary","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Xs,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:at,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),ke.map(J=>{const re=oi(J),Pe=un(be(J),J.id),_e=ee[Pe],Ve=!!_e,Ze=_e?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Ae(J,!0)},children:[s.jsx(E,{name:re,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:J.name}),J.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,Ze||_e?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},J.id)})]})]})]}):s.jsxs("div",{className:Ie("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(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,disabled:H||jt,className:Ie("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-primary disabled:cursor-not-allowed"),"aria-label":bt?o("projectActions.actions.stopNamedAria",{name:Ct.name}):o("projectActions.actions.runNamedAria",{name:Ct.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:jt||fe?s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):bt?s.jsx(E,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(E,{name:ge,className:"h-4 w-4"})})})}),$e?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),ze?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:it,className:Ie(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-primary"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Js,{children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(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-primary"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Xs,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:at,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),ke.map(J=>{const re=oi(J),Pe=un(be(J),J.id),_e=ee[Pe],Ve=!!_e,Ze=_e?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Ae(J,!0)},children:[s.jsx(E,{name:re,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:J.name}),J.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,Ze||_e?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},J.id)})]})]})]})},Or=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Mx=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Or(n??"");if(i){const o=hd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Ox(){const t=Ht(w=>w.projects),e=Ht(w=>w.activeProjectId),n=Je(w=>w.availableWorktreesByProject),r=Je(w=>w.currentSessionId),i=Cm(r??null),o=Je(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=Je(w=>w.newSessionDraft?.open?Or(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Or(o||""),[o]),u=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return Or(w||"")},[i?.directory]),d=a||u||l,h=c.useMemo(()=>Mx({projects:t,worktreesByProject:n,directory:d,activeProjectId:e}),[e,d,t,n]),f=c.useMemo(()=>Or(d||h?.path||""),[d,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),g=c.useRef(null);return c.useEffect(()=>{p&&f&&(g.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:g.current,[p,f])}const Fx=({transform:t})=>({...t,y:0}),Bx={Item:Kt,Separator:Os},_x={Item:({className:t,...e})=>s.jsx(fu,{className:Ie(xd,t),...e}),Separator:({className:t,...e})=>s.jsx(uu,{className:Ie(gd,t),...e})},Lx=t=>{const e=st.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:f}=Nt(),[p,g]=c.useState(!1),[w,S]=c.useState(!1),[x,m]=c.useState(!1);let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:y,listeners:v,setNodeRef:N,transform:C,transition:k,isDragging:D}=Qo(b);let P;e[2]!==f||e[3]!==n.session.title?(P=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=P):P=e[4];const I=P,M=!i&&(p||w),_=pa(n.id),O=n.id;let U;e[5]!==n.session?(U=Ts(n.session),e[5]=n.session,e[6]=U):U=e[6];const L=Ra(O,U),F=_?.type==="busy"||_?.type==="retry",j=pd(n.id)>0&&!r&&!F,A=F||j;let B;e[7]!==F||e[8]!==f?(B=f(F?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=F,e[8]=f,e[9]=B):B=e[9];const X=B;let H;e[10]!==u||e[11]!==x||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(H=Oe=>({session:n.session,open:p||x,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:Oe}),e[10]=u,e[11]=x,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=H):H=e[16];const Z=H;let ce;e[17]!==C?(ce=Yo.Translate.toString(C),e[17]=C,e[18]=ce):ce=e[18];let Y;e[19]!==ce||e[20]!==k?(Y={transform:ce,transition:k},e[19]=ce,e[20]=k,e[21]=Y):Y=e[21];const se=D&&"z-10 opacity-60";let oe;e[22]!==se?(oe=Ie("session-tab-slot flex h-7 w-44 shrink-0 touch-none",se),e[22]=se,e[23]=oe):oe=e[23];const Se=r?"true":"false";let K;e[24]!==r?(K=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=K):K=e[25];let pe;e[26]!==d?(pe=Oe=>d?.(Oe),e[26]=d,e[27]=pe):pe=e[27];let je;e[28]!==h||e[29]!==X||e[30]!==r||e[31]!==L||e[32]!==F||e[33]!==Z||e[34]!==p||e[35]!==l||e[36]!==d||e[37]!==o||e[38]!==M||e[39]!==a||e[40]!==A||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==I?(je=s.jsx(mu,{render:Oe=>s.jsxs("div",{...Oe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),o(n))},onAuxClick:me=>{me.button===1&&(me.preventDefault(),l(n.id))},"data-controls-open":M?"true":"false",className:Ie("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":Ie("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",M&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Ie("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",M&&"pr-10"),children:[s.jsx("div",{className:Ie("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:I})})}),L?s.jsx(E,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):A?s.jsx("span",{className:Ie("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",F?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",M&&"opacity-0"),"aria-label":X}):null]}),i?null:s.jsxs("div",{onClick:Wx,onPointerDown:zx,className:Ie("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",M&&"flex opacity-100"),children:[s.jsxs(Js,{open:p,onOpenChange:me=>{g(me),me&&S(!0)},onOpenChangeComplete:me=>{me||S(!1),d?.(me)},children:[s.jsx(Ys,{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(E,{name:"more",className:"size-4"})})}),s.jsx(Xs,{align:"start",className:"min-w-[190px]",children:a(Z(Bx))})]}),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(E,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=X,e[30]=r,e[31]=L,e[32]=F,e[33]=Z,e[34]=p,e[35]=l,e[36]=d,e[37]=o,e[38]=M,e[39]=a,e[40]=A,e[41]=i,e[42]=f,e[43]=n,e[44]=I,e[45]=je):je=e[45];let ne,T;e[46]===Symbol.for("react.memo_cache_sentinel")?(ne={color:"var(--surface-elevated-foreground)"},T=Ie(Si,"min-w-[190px]"),e[46]=ne,e[47]=T):(ne=e[46],T=e[47]);let G;e[48]!==Z||e[49]!==a?(G=a(Z(_x)),e[48]=Z,e[49]=a,e[50]=G):G=e[50];let le;e[51]!==G?(le=s.jsx(Li,{children:s.jsx($i,{className:"app-region-no-drag z-50",children:s.jsx(Wi,{"data-slot":"dropdown-menu-content",style:ne,className:T,children:G})})}),e[51]=G,e[52]=le):le=e[52];let de;e[53]!==x||e[54]!==pe||e[55]!==je||e[56]!==le?(de=s.jsxs(hu,{open:x,onOpenChange:m,onOpenChangeComplete:pe,children:[je,le]}),e[53]=x,e[54]=pe,e[55]=je,e[56]=le,e[57]=de):de=e[57];let ue;return e[58]!==y||e[59]!==v||e[60]!==N||e[61]!==oe||e[62]!==Se||e[63]!==K||e[64]!==de||e[65]!==Y?(ue=s.jsx("div",{ref:N,style:Y,className:oe,"data-active":Se,...K,...y,...v,children:de}),e[58]=y,e[59]=v,e[60]=N,e[61]=oe,e[62]=Se,e[63]=K,e[64]=de,e[65]=Y,e[66]=ue):ue=e[66],ue},$x=t=>{const e=st.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=Nt(),u=Jr(Vx),d=Jr(Ux),h=Jr(Kx),f=Jr(Hx),p=Je(Gx),g=Je(qx),w=Is(Qx);let S,x;e[0]!==p||e[1]!==d?(S=()=>{p&&d(p)},x=[p,d],e[0]=p,e[1]=d,e[2]=S,e[3]=x):(S=e[2],x=e[3]),c.useEffect(S,x);let m;if(e[4]!==w){m=new Map;for(const me of w)m.set(me.id,me);e[4]=w,e[5]=m}else m=e[5];const b=m;let y;if(e[6]!==b||e[7]!==u){y=[];for(const me of u){const Re=b.get(me);Re&&y.push({id:me,session:Re})}e[6]=b,e[7]=u,e[8]=y}else y=e[8];const v=y;let N;e[9]!==g?(N=me=>{g(me.id,Ts(me.session))},e[9]=g,e[10]=N):N=e[10];const C=N,k=Yx;let D;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==v?(D=me=>{if(h(me),p&&p!==me){const Re=v.find(ye=>ye.id===me);Re&&C(Re)}},e[11]=h,e[12]=p,e[13]=C,e[14]=v,e[15]=D):D=e[15];const P=D;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{distance:8}},e[16]=I):I=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[17]=M):M=e[17];const _=Vr(On(cu,I),On(lu,M));let O;e[18]!==f?(O=me=>{const{active:Re,over:ye}=me;ye&&Re.id!==ye.id&&f(String(Re.id),String(ye.id))},e[18]=f,e[19]=O):O=e[19];const U=O,L=c.useRef(null);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F={left:!1,right:!1},e[20]=F):F=e[20];const[R,j]=c.useState(F);let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const me=L.current;if(!me)return;const Re=me.scrollLeft>2,ye=me.scrollLeft+me.clientWidth<me.scrollWidth-2;j(q=>q.left===Re&&q.right===ye?q:{left:Re,right:ye})},e[21]=A):A=e[21];const B=A;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{B();const me=L.current;if(!me||!globalThis.ResizeObserver)return;const Re=new ResizeObserver(B);return Re.observe(me),()=>Re.disconnect()},e[22]=X):X=e[22];let H;e[23]!==v.length?(H=[B,v.length],e[23]=v.length,e[24]=H):H=e[24],c.useEffect(X,H);let Z;e[25]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=Z):Z=e[25];let ce;e[26]!==p?(ce=[p],e[26]=p,e[27]=ce):ce=e[27],c.useEffect(Z,ce);const Y=R.left&&R.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":R.left?"linear-gradient(to right, transparent, black 24px)":R.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let se;e[28]!==v?(se=v.map(Xx),e[28]=v,e[29]=se):se=e[29];const oe=se;let Se;e[30]!==p||e[31]!==v?(Se=!p||!v.some(me=>me.id===p),e[30]=p,e[31]=v,e[32]=Se):Se=e[32];const K=Se;let pe;e[33]!==a?(pe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=pe):pe=e[34];let je;e[35]!==Y?(je=Y?{maskImage:Y,WebkitMaskImage:Y}:void 0,e[35]=Y,e[36]=je):je=e[36];let ne;e[37]===Symbol.for("react.memo_cache_sentinel")?(ne=[Fx],e[37]=ne):ne=e[37];let T;e[38]!==o||e[39]!==p||e[40]!==P||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==v?(T=v.map(me=>s.jsx(Lx,{tab:me,isActive:me.id===p,suppressControls:me.id===p&&l,onSelect:C,onClose:k,renderMenu:n,closeOtherTabs:P,onMenuOpenChangeComplete:r,children:me.id===p?o:null},me.id)),e[38]=o,e[39]=p,e[40]=P,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=v,e[46]=T):T=e[46];let G;e[47]!==T||e[48]!==oe?(G=s.jsx(Io,{items:oe,strategy:Hg,children:T}),e[47]=T,e[48]=oe,e[49]=G):G=e[49];let le;e[50]!==U||e[51]!==_||e[52]!==G?(le=s.jsx(Ur,{sensors:_,collisionDetection:Kr,modifiers:ne,onDragEnd:U,children:G}),e[50]=U,e[51]=_,e[52]=G,e[53]=le):le=e[53];let de;e[54]!==o||e[55]!==K?(de=K?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]=K,e[56]=de):de=e[56];let ue;e[57]!==je||e[58]!==le||e[59]!==de?(ue=s.jsxs("div",{ref:L,onScroll:B,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:je,children:[le,de]}),e[57]=je,e[58]=le,e[59]=de,e[60]=ue):ue=e[60];let Oe;return e[61]!==pe||e[62]!==ue?(Oe=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":pe,children:ue}),e[61]=pe,e[62]=ue,e[63]=Oe):Oe=e[63],Oe};function Wx(t){return t.stopPropagation()}function zx(t){return t.stopPropagation()}function Vx(t){return t.tabIds}function Ux(t){return t.ensureTab}function Kx(t){return t.closeOtherTabs}function Hx(t){return t.reorderTabs}function Gx(t){return t.currentSessionId}function qx(t){return t.setCurrentSession}function Qx(t){return t.activeSessions}function Yx(t){Nm(t)}function Xx(t){return t.id}function Jx(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(ga(),{month:"short"}),r=e.getDate(),i=e.getFullYear(),o=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${i}, ${o}:${l}`}function Zx(t){if(t.info.role==="user")return"";const e=typeof t.info.providerID=="string"?t.info.providerID.trim():"",n=typeof t.info.modelID=="string"?t.info.modelID.trim():"";return e&&n?`${e}/${n}`:n||e}function eb(t){const e=t.info.role==="user"?"User":"Assistant",n=Jx(t.info.time?.created),r=Zx(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-CpgA4s9w.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-B6OfEypo.js","assets/index-BD8ILbxF.js","assets/vendor-zod-B6551dwG.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-zhgg-SDz.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BY_5qla_.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-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/contextPanelEmbeddedChat-BdA6bdky.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-SJuFp0a0.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-i1lTtNbn.js","assets/runtimeEndpointReset-BLzrtrmj.js","assets/VirtualizedFileDiff-Bzp3hClU.js","assets/web-components-D8GS8Ork.js","assets/computeVirtualFileMetrics-CI1PC_z2.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-DVralkU-.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-B5l0djPS.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CgbrpEWu.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/useRootScrollLock-Me41OjBT.js","assets/scheduledTasksApi-BEuUF_cj.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-BviYY3zL.js","assets/useGitComparison-BXZXEAW6.js","assets/FilesView-D0ZU_nCt.js","assets/shikiHighlight-ctlcPvvx.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-GsV9UScz.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-CgTREsRX.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-COGJG0Iv.js","assets/GitView-CYgiDRH-.js","assets/DirtyBranchSwitchDialog-C26DvfVJ.js","assets/LinearIssuesView-shqUS8nl.js","assets/PlanView-CLUWkGiG.js","assets/SettingsWindow-DbgEnZ6T.js","assets/SettingsView-CojPQVHx.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-CTuu4lgo.js"])))=>i.map(i=>d[i]);
2
+ import{f as st,R as c,j as s,r as gt,h as Uf}from"./vendor-react-BUCujlKS.js";import{D as bn,E as Wo,F as Kf,G as ad,h as ds,v as zo,u as Te,H as Mt,I as Ga,J as Hf,K as Pn,L as Gf,N as vt,O as qs,P as Vo,Q as ld,R as qf,S as Qf,T as Yf,U as Xf,V as cd,z as ma,n as ts,W as Mn,X as $r,e as Nn,Y as Jf,a as us,Z as Zf,_ as em,$ as tm,a0 as dd,t as hn,A as Qs,a1 as sm,a2 as nm,a3 as qa,a4 as rm,a5 as ud,a6 as om,a7 as fd,f as im,a8 as am,a9 as or,aa as ha,d as No,q as Rr,o as ls,ab as md,ac as lm,ad as wi,ae as cm,af as dm,i as um,ag as fo,ah as mo,ai as fm,aj as Qa,ak as mm,al as hm,am as pm,an as gm,ao as Ya,ap as Xa,aq as Ja,ar as Za,as as xm,y as el,at as bm,au as ym,av as wm,B as Sm,C as vm}from"./index-BD8ILbxF.js";import{_ as Bn}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Nt,h as Ie,bb as Kt,I as E,g as gn,t as Le,ap as Ys,bc as Os,ar as Xs,ao as Js,R as Zn,Y as Sn,ae as er,bd as _n,o as Uo,be as tl,bf as jm,bg as km,a9 as At,aa as Dt,ab as Pt,b as Ht,y as Je,G as Cm,bh as hd,bi as Jr,u as Is,A as pa,r as Ts,C as pd,bj as Si,bk as Nm,bl as gd,bm as xd,bn as bd,bo as ga,bp as Ko,bq as yd,br as wd,bs as Am,bt as sl,bu as Dm,bv as Pm,bw as xa,bx as vi,by as Im,bz as Tm,N as Sd,bA as Rm,l as qt,bB as Em,n as ar,bC as vd,p as Mm,bD as jd,bE as Om,bF as Fm,bG as Bm,bH as kd,bI as Cd,bJ as _m,aD as ba,bK as qn,bL as qr,bM as Lm,bN as vs,bO as js,bP as $s,bQ as Rs,bR as Es,bS as yn,B as xt,bT as cn,ax as Gs,bU as $m,bV as Wm,aB as An,bW as ho,bX as Hs,bY as Ho,bZ as Nd,b_ as ji,b$ as ki,c0 as Ci,c1 as zm,c2 as Fs,c3 as Bs,c4 as As,c5 as _s,c6 as ss,V as Cn,c7 as lr,c8 as nl,c9 as ur,ca as Ad,Q as Go,af as Vm,ag as ya,ah as Dd,H as Pd,J as Dn,cb as qo,a4 as wa,cc as Um,cd as Km,av as Hm,ce as Gm,cf as qm,cg as Qm,aw as Sa,ch as va,ci as fr,cj as Id,ck as Ym,cl as Xm,cm as Qr,cn as Jm,aJ as Yr,co as Zm,cp as ir,O as Td,cq as eh,cr as th,cs as Ln,ct as sh,cu as nh,cv as ei,cw as Rd,cx as Ed,cy as rh,aC as Ni,cz as Ai,cA as oh,cB as rl,cC as Er,c as Wr,d as ja,a0 as ih,cD as Md,cE as jr,cF as Mr,cG as ah,cH as lh,cI as ch,Z as Od,ay as dh,cJ as uh,cK as fh,cL as mh,cM as hh,cN as Fd,cO as xn,cP as ph,cQ as Bd,cR as gh,cS as Di,cT as xh,cU as bh,cV as _d,cW as yh,cX as Ld,a2 as Ao,cY as Pi,T as ka,S as Ca,U as Na,cZ as Aa,a as Da,a1 as wh,c_ as ol,c$ as Ii,d0 as $d,d1 as Sh,aq as Wd,d2 as vh,P as Ti,K as jh,d3 as il,d4 as kh,d5 as al,d6 as Ch,d7 as Nh,d8 as Ah,d9 as cs,da as Dh,db as Fn,dc as Pa,dd as zd,de as Ph,df as Vd,dg as Ud,dh as Ih,D as Th,di as Rh,dj as Eh,dk as Mh,dl as ll,dm as Oh,dn as Fh,dp as Kd,E as Bh,dq as po,dr as Hd,ds as _h,dt as Lh,du as $h,dv as Wh,e as Gd,dw as Ia,dx as zh,dy as zr,dz as Vh,dA as cl,dB as Uh,dC as Kh,$ as Hh,dD as Gh,aV as dl,a6 as ul,a5 as fl,dE as qh,aQ as Ri,dF as Qh,L as Yh,M as ti,dG as Xh,dH as Jh,dI as qd,dJ as Qd,dK as Yd,dL as Zh,F as Ta,dM as ep,a3 as tp,dN as sp,dO as np,dP as rp,dQ as op,dR as ip,dS as ap,dT as lp,dU as cp,dV as Do,ai as dp,dW as up,dX as ml,dY as fp,dZ as mp,d_ as hp,d$ as pp,e0 as Po,e1 as gp,e2 as hl,e3 as xp,e4 as bp,e5 as yp,e6 as wp,e7 as Sp,e8 as vp,e9 as go,ea as jp,i as kp,eb as Cp,ec as Np,ed as Ap,ee as Dp,a7 as Pp,ef as Ip,eg as Tp,eh as Rp,ei as Ep,ej as pl,ek as Mp,aK as Op,aL as Fp,aM as Bp,aO as gl,aP as xl,aS as bl,aT as yl,aR as Xd,aU as Jd,el as _p,b6 as Lp,b7 as $p,b8 as Wp,b9 as zp,ba as Vp,b0 as Up,b2 as Kp,b3 as Hp,b4 as Gp,b5 as qp}from"./useAppFontEffects-B6OfEypo.js";import{u as Zd,S as wl,C as Qp,W as eu,f as Yp,a as Xp}from"./useRootScrollLock-Me41OjBT.js";import{n as Sl,o as si,t as un,q as Ei,v as vl,w as Jp,x as Zp,y as eg,z as tg,A as sg,E as ng,F as rg,G as og,H as Ra,I as ig,a as ag,U as tu,h as Mi,f as su,J as lg,e as cg,d as dg,K as nu,L as Oi,M as Un,Q as ru,R as ou,P as ug,T as fg,V as mg,W as hg,X as pg,Y as gg,S as jl,Z as xg,_ as bg,$ as yg,u as Fr,s as wg,N as Sg,D as vg,a0 as jg,a1 as kl,a2 as kg,k as Cg,i as Ng,l as iu,m as Ag,a3 as Dg,a4 as Pg,a5 as Ig,g as Tg,j as Rg,O as au,C as Eg}from"./runtimeEndpointReset-BLzrtrmj.js";import{u as Wn,O as Cl,D as Mg,a as Og,b as Fg,n as Bg,f as _g,c as Nl,s as Lg,d as $g,e as Wg,r as zg}from"./scheduledTasksApi-BEuUF_cj.js";import{f as Vr,h as On,T as lu,M as cu,D as Ur,j as Kr,d as Vg,P as Fi,b as Ug,k as Bi,i as Kg}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Qo,S as Io,h as Hg,a as du,v as _i,s as Gg}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as uu,M as fu,C as mu,a as Li,b as $i,c as Wi,d as hu,e as qg,f as Qg}from"./vendor-base-ui-BY_5qla_.js";import{c as tr,u as Jn,d as pu,p as Yg}from"./vendor-zustand-BAGL70zf.js";import{g as Xg,a as Jg,E as gu,b as Zg,c as ex,d as tx,e as sx,i as nx}from"./contextPanelEmbeddedChat-BdA6bdky.js";import{c as Ea,s as br,r as xu}from"./vendor-zod-B6551dwG.js";import{u as rx}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as bu}from"./vendor-cron-parser-CUcP7OfX.js";const ox="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",ix="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",ni=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__AIWORKER_PLATFORM__==="darwin"?ox:t.id==="terminal"?ix:void 0}),Al=t=>{const e=st.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 u=a,d=r||i;if(d&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let g;return e[3]!==d?(g=s.jsx("img",{src:d,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=d,e[4]=g):g=e[4],g}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Ie("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]!==u?(f=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=f):f=e[7],f},ax=t=>{const e=st.c(75),{directory:n,className:r}=t,{t:i}=Nt(),o=Wn(lx),l=Wn(cx),a=Wn(dx),u=Wn(ux),d=Wn(fx),h=Wn(mx),f=Wn(hx);let p,g;e[0]!==d?(p=()=>{d()},g=[d],e[0]=d,e[1]=p,e[2]=g):(p=e[1],g=e[2]),c.useEffect(p,g);const w=bn()&&Wo();let S;e:{let K;e[3]!==l||e[4]!==o?(K=l.find(ne=>ne.id===o)??l.find(px)??l[0]??Cl[0],e[3]=l,e[4]=o,e[5]=K):K=e[5];const pe=K;if(pe){let ne;e[6]!==pe?(ne=ni(pe),e[6]=pe,e[7]=ne):ne=e[7],S=ne;break e}let je;e[8]===Symbol.for("react.memo_cache_sentinel")?(je=ni(Cl[0]),e[8]=je):je=e[8],S=je}const x=S;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async K=>{await Kf(n,K.id,K.appName)||await ad(n,K.appName)},e[9]=n,e[10]=m):m=e[10];const b=m;let y;e[11]!==b||e[12]!==f?(y=async K=>{await f(K.id),await b(K)},e[11]=b,e[12]=f,e[13]=y):y=e[13];const v=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await gn(n)).ok&&Le.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const C=N;let k;e[17]!==r?(k=Ie("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]=k):k=e[18];let D;e[19]!==b||e[20]!==x?(D=()=>{b(x)},e[19]=b,e[20]=x,e[21]=D):D=e[21];const P=u&&"animate-pulse";let I;e[22]!==P?(I=Ie("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=I):I=e[23];let M;e[24]!==x.label||e[25]!==i?(M=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=M):M=e[26];let _;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(_=s.jsx(Al,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=_):_=e[30];let O;e[31]!==I||e[32]!==M||e[33]!==_||e[34]!==D?(O=s.jsx("button",{type:"button",onClick:D,className:I,"aria-label":M,children:_}),e[31]=I,e[32]=M,e[33]=_,e[34]=D,e[35]=O):O=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=Ie("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]=U):U=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=F):F=e[39];let R;e[40]!==L?(R=s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:U,"aria-label":L,children:F})}),e[40]=L,e[41]=R):R=e[41];let j;e[42]!==C?(j=()=>{C()},e[42]=C,e[43]=j):j=e[43];let A;e[44]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(E,{name:"file-copy",className:"h-4 w-4"}),e[44]=A):A=e[44];let B;e[45]!==i?(B=i("openInApp.actions.copyPath"),e[45]=i,e[46]=B):B=e[46];let X;e[47]!==B?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:B}),e[47]=B,e[48]=X):X=e[48];let H;e[49]!==j||e[50]!==X?(H=s.jsxs(Kt,{className:"flex items-center gap-2",onClick:j,children:[A,X]}),e[49]=j,e[50]=X,e[51]=H):H=e[51];let Z;e[52]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Os,{}),e[52]=Z):Z=e[52];let ce;if(e[53]!==l||e[54]!==v||e[55]!==x.id){let K;e[57]!==v||e[58]!==x.id?(K=pe=>{const je=ni(pe);return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{v(pe)},children:[s.jsx(Al,{label:pe.label,iconDataUrl:pe.iconDataUrl,fallbackIconDataUrl:je.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:pe.label}),x.id===pe.id?s.jsx(E,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},pe.id)},e[57]=v,e[58]=x.id,e[59]=K):K=e[59],ce=l.map(K),e[53]=l,e[54]=v,e[55]=x.id,e[56]=ce}else ce=e[56];let Y;e[60]!==a||e[61]!==h||e[62]!==i?(Y=a?s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(E,{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]=Y):Y=e[63];let se;e[64]!==H||e[65]!==ce||e[66]!==Y?(se=s.jsxs(Xs,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[H,Z,ce,Y]}),e[64]=H,e[65]=ce,e[66]=Y,e[67]=se):se=e[67];let oe;e[68]!==R||e[69]!==se?(oe=s.jsxs(Js,{children:[R,se]}),e[68]=R,e[69]=se,e[70]=oe):oe=e[70];let Se;return e[71]!==O||e[72]!==oe||e[73]!==k?(Se=s.jsxs("div",{className:k,children:[O,oe]}),e[71]=O,e[72]=oe,e[73]=k,e[74]=Se):Se=e[74],Se};function lx(t){return t.selectedAppId}function cx(t){return t.availableApps}function dx(t){return t.isCacheStale}function ux(t){return t.isScanning}function fx(t){return t.initialize}function mx(t){return t.loadInstalledApps}function hx(t){return t.selectApp}function px(t){return t.id===Mg}const To=new Map,zi=new Set,yu=()=>{for(const t of zi)t()},ri=(t,e)=>{const n=t.trim();n&&(e.length===0?To.delete(n):To.set(n,[...e]),yu())},gx=t=>{To.delete(t.trim())&&yu()},wu=[],xx=t=>To.get(t.trim())??wu,bx=t=>(zi.add(t),()=>{zi.delete(t)}),yx=t=>{const e=st.c(2);let n;return e[0]!==t?(n=()=>xx(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(bx,n,wx)};function wx(){return wu}const Sx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],vx=["dev","start","preview","serve"];async function jx(t,e,n){if(!t)return null;const r=Nx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Ax(n);if(i){const o=await Dx(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 kx(t)){const i=await Cx(),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 kx(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function Cx(){try{const t=await ds("/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 Nx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(vx.some(i=>n.includes(i)))return e}return null}function Ax(t){for(const{pattern:e}of Sx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Dx(t){const e=await Ro(`${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 Ro(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ro(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=zo()?.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 ds(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Px(t){try{const e=await Ro(`${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 mn="__aiworker_auto_discover_preview__",Ix=15e3,Tx=3e3,oi=t=>t.id===mn?"scan-2":og.find(n=>n.key===t.icon)?.Icon??"play",Rx=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}},Ex=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=Nt(),{currentTheme:l}=Zn(),{terminal:a,runtime:u}=Sn(),d=er(),{isMobile:h}=_n(),f=c.useMemo(()=>bn(),[]),p=Sl(J=>J.instances),g=Sl(J=>J.load),w=Te(J=>J.terminalShell),S=Te(J=>J.terminalLoginShells.includes(J.terminalShell)),x=Te(J=>J.setSettingsPage),m=Te(J=>J.setSettingsDialogOpen),b=Te(J=>J.setSettingsProjectsSelectedId),y=Te(J=>J.openContextPreview),v=Mt(J=>J.ensureDirectory),N=Mt(J=>J.reconcileServerSessions),C=Mt(J=>J.setTabLabel),k=Mt(J=>J.setTabIconKey),D=Mt(J=>J.setActiveTab),P=Mt(J=>J.setConnecting),I=Mt(J=>J.setTabSessionId),M=Mt(J=>J.setTabPurpose),_=Mt(J=>J.allocateActionExecution),O=Mt(J=>J.setTabLifecycle),U=Mt(J=>J.setTabPreviewUrl),L=Mt(J=>J.matchesActionExecution),F=Mt(J=>J.captureStartedActionMutationRevisions),[R,j]=c.useState([]),A=c.useRef(null),[B,X]=c.useState(null),[H,Z]=c.useState(!1),ce=c.useRef({}),Y=c.useRef({}),se=c.useRef({}),oe=c.useRef(new Set),Se=c.useRef(0),[K,pe]=c.useState({}),je=t?.id??null,ne=t?.path??"",T=c.useMemo(()=>je?{id:je,path:ne}:null,[je,ne]);c.useEffect(()=>{f&&g().catch(()=>{})},[f,g]);const G=c.useCallback(async J=>{await Uo(J)},[]),le=c.useCallback(async()=>{if(!T)return;const J=Se.current+1;Se.current=J,Z(!0);try{const re=await tl(T);if(Se.current!==J)return;A.current=re;const Pe=re.projectActions;j(Pe),X(_e=>_e===mn||_e&&Pe.some(Ve=>Ve.id===_e)?_e:null)}catch{if(Se.current!==J)return}finally{Se.current===J&&Z(!1)}},[T]),de=c.useMemo(()=>si(e||T?.path||""),[e,T?.path]),ue=c.useMemo(()=>si(T?.path||""),[T?.path]),Oe=c.useMemo(()=>si(d||"")||de,[d,de]),me=c.useRef(Oe);c.useEffect(()=>{me.current=Oe},[Oe]);const Re=Mt(J=>de?J.getDirectoryState(de):void 0),ye=Mt(J=>ue&&ue!==de?J.getDirectoryState(ue):void 0),q=c.useMemo(()=>{const J=de?[{directory:de,state:Re}]:[];return ue&&ue!==de&&J.push({directory:ue,state:ye}),J},[Re,de,ue,ye]),we=c.useMemo(()=>{const J=de?[de]:[];return ue&&ue!==de&&J.push(ue),J},[de,ue]),be=c.useCallback(J=>J.id!==mn&&J.runIn==="parent"&&ue||de,[de,ue]),Ne=c.useCallback((J,re,Pe)=>`${J}::${re}::${Pe}`,[]),ie=c.useCallback((J,re,Pe=Mt.getState())=>J?Pe.getDirectoryState(J)?.tabs.find(_e=>_e.purpose.type==="project-action"&&_e.purpose.actionId===re)??null:null,[]),ee=c.useMemo(()=>{const J={};for(const{directory:re,state:Pe}of q)for(const _e of Pe?.tabs??[]){if(_e.purpose.type!=="project-action"||!_e.purpose.executionId||!_e.terminalSessionId||_e.lifecycle==="idle"||_e.lifecycle==="exited")continue;const Ve=un(re,_e.purpose.actionId),Ze=Ne(re,_e.purpose.actionId,_e.purpose.executionId);J[Ve]={directory:re,actionId:_e.purpose.actionId,tabId:_e.id,sessionId:_e.terminalSessionId,executionId:_e.purpose.executionId,status:_e.lifecycle==="stopping"?"stopping":K[Ze]?"waiting-for-preview":"running"}}return J},[Ne,K,q]),V=c.useCallback((J,re,Pe)=>{const _e=un(J,re),Ve=Ne(J,re,Pe),lt=ce.current[_e]?.executionId===Pe,rt=globalThis.window,Ge=ot=>{rt?.clearTimeout(se.current[ot]),delete se.current[ot]};lt&&(delete ce.current[_e],Ge(_e)),Y.current[Ve]?.(),delete Y.current[Ve],Ge(Ve),pe(ot=>{if(!ot[Ve])return ot;const Ee={...ot};return delete Ee[Ve],Ee})},[Ne]),$=c.useCallback(J=>{Y.current[J]?.(),delete Y.current[J]},[]),ae=c.useCallback(J=>{window.clearTimeout(se.current[J]),delete se.current[J]},[]);c.useEffect(()=>{const J=Y.current,re=se.current;return()=>{for(const Pe of Object.keys(J))$(Pe);for(const Pe of Object.keys(re))ae(Pe)}},[ae,$]),c.useEffect(()=>{const J=new Set(we);for(const re of Object.values(ce.current))J.has(re.directory)||V(re.directory,re.actionId,re.executionId);for(const re of Object.keys(Y.current)){const Pe=re.split("::",1)[0]??"";J.has(Pe)||$(re)}},[V,$,we]);const W=c.useCallback((J,re)=>{Te.getState().openContextPanelTab(J,{mode:"terminal",targetDirectory:re===J?null:re})},[]),ve=c.useMemo(()=>B?R.find(J=>J.id===B)??null:null,[R,B]),Fe=c.useMemo(()=>({id:mn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Ce=!h,ke=c.useMemo(()=>Ce?[Fe,...R]:R,[R,Fe,Ce]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{const J=we.map(re=>Ei(a,re,F,Pe=>N(re,Pe.sessions,{startedActionMutationRevisions:Pe.startedActionMutationRevisions})));return()=>{for(const re of J)re()}},[F,N,a,we]),c.useEffect(()=>{for(const{directory:J,state:re}of q)if(J)for(const Pe of re?.tabs??[]){if(Pe.purpose.type!=="project-action")continue;const _e=Pe.purpose.actionId,Ve=ke.find(rt=>rt.id===_e),Ze=Ve?.name??_e,lt=Ve?.icon||"play";Pe.label!==Ze&&C(J,Pe.id,Ze),Pe.iconKey!==lt&&k(J,Pe.id,lt)}},[ke,k,C,q]),c.useEffect(()=>{const J=globalThis.window;if(!J)return;const re=Pe=>{const _e=Pe.detail;je&&(_e?.projectId&&_e.projectId!==je||le())};return J.addEventListener(vl,re),()=>{J.removeEventListener(vl,re)}},[le,je]),c.useEffect(()=>{B&&(B===mn&&Ce||R.some(J=>J.id===B)||X(null))},[R,Ce,B]),c.useEffect(()=>{const J=Pe=>{delete se.current[Pe];const _e=ce.current[Pe];if(!_e||_e.openedUrl)return;const Ve=Ne(_e.directory,_e.actionId,_e.executionId),Ze=_e.announced;if(Ze.length!==0){if(window.clearTimeout(se.current[Ve]),delete se.current[Ve],_e.openedUrl=!0,pe(lt=>{if(!lt[Ve])return lt;const rt={...lt};return delete rt[Ve],rt}),Ze.length===1){ri(_e.directory,[]),U(_e.directory,_e.tabId,Ze[0],{locked:!1,autoOpened:!0}),y(_e.directory,Ze[0]);return}_e.offering=!0,ri(_e.directory,Ze),Te.getState().openContextSurface(_e.directory,"browser"),Le.info(o("projectActions.toast.multipleServers"))}},re=()=>{const Pe=Mt.getState(),_e=Pe.sessions,Ve=ee;for(const[Ze,lt]of Object.entries(Ve)){const Ge=_e.get(lt.directory)?.tabs.find(yt=>yt.id===lt.tabId);if(!Ge||Ge.terminalSessionId!==lt.sessionId){V(lt.directory,lt.actionId,lt.executionId);continue}const ot=ce.current[Ze],Ee=ot?.executionId===lt.executionId?ot:{hostDirectory:me.current||lt.directory,directory:lt.directory,tabId:lt.tabId,actionId:lt.actionId,executionId:lt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ce.current[Ze]=Ee;const Rt=ke.find(yt=>yt.id===lt.actionId),xe=Pe.getBuffer(lt.directory,lt.tabId).chunks;if(!Rt||xe.length===0)continue;const mt=xe.filter(yt=>Ee.lastSeenChunkId===null||yt.id>Ee.lastSeenChunkId);if(mt.length===0)continue;const Tt=mt.map(yt=>yt.data).join(""),Xe=`${Ee.tail}${Tt}`;if(Ee.openInPreview&&(!Ee.openedUrl||Ee.offering)){const yt=ng(Xe),It=Ee.announced.length;for(const Et of yt)Ee.announced.includes(Et)||Ee.announced.push(Et);const kt=Ee.announced.length-It;Ee.offering&&kt>0?ri(lt.directory,Ee.announced):!Ee.openedUrl&&It===0&&Ee.announced.length>0&&(window.clearTimeout(se.current[Ze]),se.current[Ze]=window.setTimeout(()=>J(Ze),Tx))}const nt=!Ee.openedUrl&&Rt.autoOpenUrl===!0&&!Ee.openInPreview?rg(Xe):null,St=mt[mt.length-1]?.id??Ee.lastSeenChunkId;if(Ee.lastSeenChunkId=St,Ee.tail=Xe.slice(-512),nt)if(Ee.openedUrl=!0,Ee.openInPreview){const yt=Ve[Ze];yt&&(U(yt.directory,yt.tabId,nt,{locked:!1,autoOpened:!1,expectedExecutionId:yt.executionId}),yt.status==="waiting-for-preview"&&pe(It=>{const kt=Ne(yt.directory,yt.actionId,yt.executionId);if(!It[kt])return It;const Et={...It};return delete Et[kt],Et}),window.clearTimeout(se.current[Ze]),delete se.current[Ze],y(yt.directory,nt))}else G(nt),Le.success(o("projectActions.toast.openedUrlFromOutput"));ce.current[Ze]=Ee}for(const Ze of Object.keys(ce.current))if(!Ve[Ze]){const lt=ce.current[Ze],rt=lt?_e.get(lt.directory)?.tabs.find(ot=>ot.id===lt.tabId):void 0;if(rt?.purpose.type==="project-action"&&rt.purpose.executionId===lt?.executionId&&!!rt.terminalSessionId&&rt.lifecycle!=="idle"&&rt.lifecycle!=="exited")continue;delete ce.current[Ze],window.clearTimeout(se.current[Ze]),delete se.current[Ze]}};return re(),Mt.subscribe((Pe,_e)=>{(Pe.sessions!==_e.sessions||Pe.buffers!==_e.buffers)&&re()})},[V,me,ke,Ne,y,G,ee,U,o]),c.useEffect(()=>{for(const{directory:J,state:re}of q)for(const Pe of re?.tabs??[]){if(Pe.purpose.type!=="project-action"||!Pe.purpose.executionId||!Pe.terminalSessionId||Pe.lifecycle!=="running")continue;const _e=Pe.purpose.actionId,Ve=Pe.purpose.executionId,Ze=Ne(J,_e,Ve);if(Y.current[Ze])continue;const lt=a.connect(Pe.terminalSessionId,{onEvent:rt=>{if(!L(J,Pe.id,Ve))return;rt.type==="snapshot"&&(Mt.getState().replaceBuffer(J,Pe.id,rt.data??"",rt.sequence??0,Ga(rt)),rt.status==="running"&&Mt.getState().setTabLifecycle(J,Pe.id,"running",{expectedExecutionId:Ve}),rt.status==="exited"&&(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve)));const Ge=rt.type==="data"?rt.data??"":"";Ge&&Mt.getState().appendToBuffer(J,Pe.id,Ge,rt.sequence,rt.replayData),rt.type==="exit"&&(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve))},onError:(rt,Ge)=>{!Ge||!L(J,Pe.id,Ve)||(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabSessionId(J,Pe.id,null,{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve))}});Y.current[Ze]=lt.close}},[V,Ne,L,a,q]);const Qe=c.useCallback(async J=>{const re=be(J);if(!re)throw new Error(o("projectActions.error.noActiveDirectory"));const Pe=un(re,J.id);v(re);const _e=Mt.getState(),Ve=ie(re,J.id,_e),Ze=Ve?.id??_e.createTab(re);C(re,Ze,J.name),k(re,Ze,J.icon||"play"),Ve||M(re,Ze,{type:"project-action",actionId:J.id,executionId:null}),D(re,Ze);const rt=Mt.getState().getDirectoryState(re)?.tabs.find(Ge=>Ge.id===Ze);return{executionDirectory:re,key:Pe,tabId:Ze,sessionId:rt?.terminalSessionId??null,executionId:rt?.purpose.type==="project-action"?rt.purpose.executionId:null}},[v,be,ie,D,k,C,M,o]),We=c.useCallback(async J=>{if(u.isVSCode||!i&&h)return;if(!de){Le.error(o("projectActions.error.noActiveDirectoryForAction"));return}const re=un(be(J),J.id),Pe=ee[re];if(Pe&&Pe.status==="running"||oe.current.has(re))return;oe.current.add(re);let _e=null;try{const Ve=J.id===mn?await(async()=>{const[kt,Et]=await Promise.all([jm({id:T?.id??"",path:de}),Px(de)]),Bt=await jx(de,kt.actions,Et);if(!Bt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:mn,name:o("projectActions.actions.autoDiscover"),command:Bt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Bt.previewUrlHint||""}})():J,Ze=Ve.autoOpenUrl===!0&&(Ve.openUrl||"").trim().length>0,lt=!Ze&&J.id!==mn,rt=me.current||de,{executionDirectory:Ge,key:ot,tabId:Ee}=await Qe(Ve),Rt=Jp(Ve.command);if(!Rt)throw new Error(o("projectActions.error.failedToRunAction"));const xe=Ve.autoOpenUrl===!0&&f&&(Ve.desktopOpenSshForward||"").trim().length>0,mt=Ve.autoOpenUrl?Rx(Ve.openUrl):null,Tt=Ve.autoOpenUrl&&f?Zp(Ve.desktopOpenSshForward,p):null;if(a.listSessions){const kt=ie(Ge,Ve.id);if(kt?.purpose.type==="project-action"&&kt.purpose.executionId===null){const Et=await eg(a,Ge,{captureStartedActionMutationRevisions:F});Et&&N(Ge,Et.sessions,{startedActionMutationRevisions:Et.startedActionMutationRevisions})}}const Xe=ie(Ge,Ve.id);let nt,St;if(Xe?.lifecycle==="running"&&Xe.terminalSessionId&&Xe.purpose.type==="project-action"&&Xe.purpose.executionId)nt=Xe.terminalSessionId,St=Xe.purpose.executionId;else{const kt=Xe?.purpose.type==="project-action"?Xe.purpose.executionId:null;kt&&V(Ge,Ve.id,kt);const Et=_(Ge,Ee,Ve.id);if(!Et)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));_e={directory:Ge,tabId:Ee,id:Et},P(Ge,Ee,!0,{expectedExecutionId:Et});const Bt=await tg({terminal:a,createOptions:{cwd:Ge,shell:w,loginShell:S,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Rt,isRunStillExpected:()=>L(Ge,Ee,Et),purpose:{type:"project-action",actionId:Ve.id,executionId:Et}});if(!L(Ge,Ee,Et)){Bt.sessionId===Et&&await a.close(Bt.sessionId).catch(()=>{});return}St=Bt.purpose?.type==="project-action"?Bt.purpose.executionId:Et,nt=Bt.sessionId,M(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:St}),I(Ge,Ee,nt,{expectedExecutionId:St}),P(Ge,Ee,!1,{expectedExecutionId:St})}lt&&rt&&W(rt,Ge),ce.current[ot]={hostDirectory:rt,directory:Ge,tabId:Ee,actionId:Ve.id,executionId:St,lastSeenChunkId:null,openedUrl:!!Tt||!!mt||Ze,tail:"",openInPreview:Ve.id===mn,announced:[],offering:!1};const yt=Ne(Ge,Ve.id,St);P(Ge,Ee,!0,{expectedExecutionId:St});const It=a.connect(nt,{onEvent:kt=>{if(!L(Ge,Ee,St)||kt.purpose?.type==="project-action"&&kt.purpose.executionId!==St)return;kt.type==="snapshot"&&(Mt.getState().replaceBuffer(Ge,Ee,kt.data??"",kt.sequence??0,Ga(kt)),Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),kt.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:kt.purpose.actionId,executionId:kt.purpose.executionId}),kt.status==="running"&&Mt.getState().setTabLifecycle(Ge,Ee,"running",{expectedExecutionId:St}),kt.status==="exited"&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St)));const Et=kt.type==="data"?kt.data??"":"";Et&&Mt.getState().appendToBuffer(Ge,Ee,Et,kt.sequence,kt.replayData),kt.type==="exit"&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St))},onError:(kt,Et)=>{L(Ge,Ee,St)&&(Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),Et&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setTabSessionId(Ge,Ee,null,{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St)))}});if(!L(Ge,Ee,St)){It.close();return}Y.current[yt]?.(),Y.current[yt]=It.close,window.clearTimeout(se.current[yt]),delete se.current[yt],Ve.id===mn&&!mt&&(pe(kt=>({...kt,[yt]:!0})),se.current[yt]=window.setTimeout(()=>{delete se.current[yt];const kt=ce.current[ot];!kt||kt.executionId!==St||kt.openedUrl||kt.offering||L(Ge,Ee,St)&&(pe(Et=>{if(!Et[yt])return Et;const Bt={...Et};return delete Bt[yt],Bt}),Mt.getState().setActiveTab(Ge,Ee),W(kt.hostDirectory,Ge))},Ix)),Tt?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),G(Tt),Le.success(o("projectActions.toast.openedForwardedUrl"))):mt?(U(Ge,Ee,mt,{locked:!0,autoOpened:!0,expectedExecutionId:St}),y(rt,mt),Le.success(o("projectActions.toast.openedActionUrl"))):Ze?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),Le.error(o("projectActions.error.invalidCustomUrlFormat"))):xe?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),Le.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):U(Ge,Ee,null,{locked:!1,autoOpened:!1,expectedExecutionId:St})}catch(Ve){if(_e&&L(_e.directory,_e.tabId,_e.id)){const{directory:Ze,tabId:lt,id:rt}=_e;V(Ze,J.id,rt),O(Ze,lt,"exited",{expectedExecutionId:rt}),M(Ze,lt,{type:"project-action",actionId:J.id,executionId:null})}if(Ve instanceof Error&&Ve.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ve instanceof Error&&(Ve.message==="COMMAND_MODE_UNSUPPORTED"||Ve.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Le.error(o("projectActions.error.failedToCreateTerminalSession"));return}Le.error(Ve instanceof Error?Ve.message:o("projectActions.error.failedToRunAction"))}finally{oe.current.delete(re)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,me,p,Qe,i,h,f,de,S,w,G,y,ee,W,u.isVSCode,be,L,V,Ne,ie,N,_,F,P,O,M,U,I,T?.id,o,a]),z=c.useCallback(async J=>{const re=un(be(J),J.id),Pe=ee[re];Pe&&await sg({terminal:a,sessionId:Pe.sessionId,isExecutionStillCurrent:()=>L(Pe.directory,Pe.tabId,Pe.executionId),markStopping:()=>{O(Pe.directory,Pe.tabId,"stopping",{expectedExecutionId:Pe.executionId})},restoreRunning:()=>{O(Pe.directory,Pe.tabId,"running",{expectedExecutionId:Pe.executionId})},clearSession:()=>{I(Pe.directory,Pe.tabId,null,{expectedExecutionId:Pe.executionId})},finalizeExit:()=>{O(Pe.directory,Pe.tabId,"exited",{expectedExecutionId:Pe.executionId}),M(Pe.directory,Pe.tabId,{type:"project-action",actionId:Pe.actionId,executionId:null}),V(Pe.directory,Pe.actionId,Pe.executionId)}})},[V,be,L,ee,O,M,I,a]),he=c.useCallback(()=>{const J=ve??ke[0];if(!J)return;const re=un(be(J),J.id),Pe=ee[re];if(Pe?.status!=="stopping"){if(Pe){z(J);return}We(J)}},[ke,be,We,ee,ve,z]),Be=c.useCallback(async J=>{if(J.source==="shared"&&T){const re=A.current?.trust.trusted?A.current:await tl(T);if(A.current=re,!await km(T,re))return;A.current={...re,trust:{...re.trust,trusted:!0}}}await We(J)},[We,T]),Ae=c.useCallback((J,re=!1)=>{if(X(J.id),!re){Be(J);return}const Pe=un(be(J),J.id),_e=ee[Pe];if(_e?.status!=="stopping"){if(_e){z(J);return}Be(J)}},[be,Be,ee,z]),at=c.useCallback(()=>{T?.id&&(b(T.id),x("projects"),m(!0))},[m,x,b,T?.id]),Ue=ve??ke[0]??null,ht=Ue?ee[un(be(Ue),Ue.id)]:null,ut=Mt(J=>ht?J.getDirectoryState(ht.directory)?.tabs.find(re=>re.id===ht.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&h||!T||!de)return null;const Ct=ve??ke[0]??null;if(!Ct)return null;const ge=oi(Ct),Ye=un(be(Ct),Ct.id),bt=ee[Ye],jt=bt?.status==="stopping",fe=bt?.status==="waiting-for-preview",ze=!!(bt&&ut),it=()=>{!bt||!ut||y(bt.directory,ut)},$e=Ct.id===mn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:H||jt,className:Ie("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-primary","disabled:cursor-not-allowed",n),onClick:he,"aria-label":bt?o("projectActions.actions.stopNamedAria",{name:Ct.name}):o("projectActions.actions.runNamedAria",{name:Ct.name}),children:jt||fe?s.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):bt?s.jsx(E,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(E,{name:ge,className:"h-5 w-5"})})}),$e?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),ze?s.jsxs(At,{children:[s.jsx(Dt,{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-primary","aria-label":o("projectActions.actions.openPreview"),onClick:it,children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Js,{children:[s.jsx(Ys,{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-primary","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Xs,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:at,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),ke.map(J=>{const re=oi(J),Pe=un(be(J),J.id),_e=ee[Pe],Ve=!!_e,Ze=_e?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Ae(J,!0)},children:[s.jsx(E,{name:re,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:J.name}),J.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,Ze||_e?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},J.id)})]})]})]}):s.jsxs("div",{className:Ie("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(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,disabled:H||jt,className:Ie("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-primary disabled:cursor-not-allowed"),"aria-label":bt?o("projectActions.actions.stopNamedAria",{name:Ct.name}):o("projectActions.actions.runNamedAria",{name:Ct.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:jt||fe?s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):bt?s.jsx(E,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(E,{name:ge,className:"h-4 w-4"})})})}),$e?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),ze?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:it,className:Ie(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-primary"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Js,{children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(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-primary"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Xs,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:at,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),ke.map(J=>{const re=oi(J),Pe=un(be(J),J.id),_e=ee[Pe],Ve=!!_e,Ze=_e?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Ae(J,!0)},children:[s.jsx(E,{name:re,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:J.name}),J.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,Ze||_e?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},J.id)})]})]})]})},Or=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Mx=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Or(n??"");if(i){const o=hd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Ox(){const t=Ht(w=>w.projects),e=Ht(w=>w.activeProjectId),n=Je(w=>w.availableWorktreesByProject),r=Je(w=>w.currentSessionId),i=Cm(r??null),o=Je(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=Je(w=>w.newSessionDraft?.open?Or(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Or(o||""),[o]),u=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return Or(w||"")},[i?.directory]),d=a||u||l,h=c.useMemo(()=>Mx({projects:t,worktreesByProject:n,directory:d,activeProjectId:e}),[e,d,t,n]),f=c.useMemo(()=>Or(d||h?.path||""),[d,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),g=c.useRef(null);return c.useEffect(()=>{p&&f&&(g.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:g.current,[p,f])}const Fx=({transform:t})=>({...t,y:0}),Bx={Item:Kt,Separator:Os},_x={Item:({className:t,...e})=>s.jsx(fu,{className:Ie(xd,t),...e}),Separator:({className:t,...e})=>s.jsx(uu,{className:Ie(gd,t),...e})},Lx=t=>{const e=st.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:f}=Nt(),[p,g]=c.useState(!1),[w,S]=c.useState(!1),[x,m]=c.useState(!1);let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:y,listeners:v,setNodeRef:N,transform:C,transition:k,isDragging:D}=Qo(b);let P;e[2]!==f||e[3]!==n.session.title?(P=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=P):P=e[4];const I=P,M=!i&&(p||w),_=pa(n.id),O=n.id;let U;e[5]!==n.session?(U=Ts(n.session),e[5]=n.session,e[6]=U):U=e[6];const L=Ra(O,U),F=_?.type==="busy"||_?.type==="retry",j=pd(n.id)>0&&!r&&!F,A=F||j;let B;e[7]!==F||e[8]!==f?(B=f(F?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=F,e[8]=f,e[9]=B):B=e[9];const X=B;let H;e[10]!==u||e[11]!==x||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(H=Oe=>({session:n.session,open:p||x,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:Oe}),e[10]=u,e[11]=x,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=H):H=e[16];const Z=H;let ce;e[17]!==C?(ce=Yo.Translate.toString(C),e[17]=C,e[18]=ce):ce=e[18];let Y;e[19]!==ce||e[20]!==k?(Y={transform:ce,transition:k},e[19]=ce,e[20]=k,e[21]=Y):Y=e[21];const se=D&&"z-10 opacity-60";let oe;e[22]!==se?(oe=Ie("session-tab-slot flex h-7 w-44 shrink-0 touch-none",se),e[22]=se,e[23]=oe):oe=e[23];const Se=r?"true":"false";let K;e[24]!==r?(K=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=K):K=e[25];let pe;e[26]!==d?(pe=Oe=>d?.(Oe),e[26]=d,e[27]=pe):pe=e[27];let je;e[28]!==h||e[29]!==X||e[30]!==r||e[31]!==L||e[32]!==F||e[33]!==Z||e[34]!==p||e[35]!==l||e[36]!==d||e[37]!==o||e[38]!==M||e[39]!==a||e[40]!==A||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==I?(je=s.jsx(mu,{render:Oe=>s.jsxs("div",{...Oe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),o(n))},onAuxClick:me=>{me.button===1&&(me.preventDefault(),l(n.id))},"data-controls-open":M?"true":"false",className:Ie("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":Ie("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",M&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Ie("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",M&&"pr-10"),children:[s.jsx("div",{className:Ie("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:I})})}),L?s.jsx(E,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):A?s.jsx("span",{className:Ie("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",F?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",M&&"opacity-0"),"aria-label":X}):null]}),i?null:s.jsxs("div",{onClick:Wx,onPointerDown:zx,className:Ie("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",M&&"flex opacity-100"),children:[s.jsxs(Js,{open:p,onOpenChange:me=>{g(me),me&&S(!0)},onOpenChangeComplete:me=>{me||S(!1),d?.(me)},children:[s.jsx(Ys,{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(E,{name:"more",className:"size-4"})})}),s.jsx(Xs,{align:"start",className:"min-w-[190px]",children:a(Z(Bx))})]}),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(E,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=X,e[30]=r,e[31]=L,e[32]=F,e[33]=Z,e[34]=p,e[35]=l,e[36]=d,e[37]=o,e[38]=M,e[39]=a,e[40]=A,e[41]=i,e[42]=f,e[43]=n,e[44]=I,e[45]=je):je=e[45];let ne,T;e[46]===Symbol.for("react.memo_cache_sentinel")?(ne={color:"var(--surface-elevated-foreground)"},T=Ie(Si,"min-w-[190px]"),e[46]=ne,e[47]=T):(ne=e[46],T=e[47]);let G;e[48]!==Z||e[49]!==a?(G=a(Z(_x)),e[48]=Z,e[49]=a,e[50]=G):G=e[50];let le;e[51]!==G?(le=s.jsx(Li,{children:s.jsx($i,{className:"app-region-no-drag z-50",children:s.jsx(Wi,{"data-slot":"dropdown-menu-content",style:ne,className:T,children:G})})}),e[51]=G,e[52]=le):le=e[52];let de;e[53]!==x||e[54]!==pe||e[55]!==je||e[56]!==le?(de=s.jsxs(hu,{open:x,onOpenChange:m,onOpenChangeComplete:pe,children:[je,le]}),e[53]=x,e[54]=pe,e[55]=je,e[56]=le,e[57]=de):de=e[57];let ue;return e[58]!==y||e[59]!==v||e[60]!==N||e[61]!==oe||e[62]!==Se||e[63]!==K||e[64]!==de||e[65]!==Y?(ue=s.jsx("div",{ref:N,style:Y,className:oe,"data-active":Se,...K,...y,...v,children:de}),e[58]=y,e[59]=v,e[60]=N,e[61]=oe,e[62]=Se,e[63]=K,e[64]=de,e[65]=Y,e[66]=ue):ue=e[66],ue},$x=t=>{const e=st.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=Nt(),u=Jr(Vx),d=Jr(Ux),h=Jr(Kx),f=Jr(Hx),p=Je(Gx),g=Je(qx),w=Is(Qx);let S,x;e[0]!==p||e[1]!==d?(S=()=>{p&&d(p)},x=[p,d],e[0]=p,e[1]=d,e[2]=S,e[3]=x):(S=e[2],x=e[3]),c.useEffect(S,x);let m;if(e[4]!==w){m=new Map;for(const me of w)m.set(me.id,me);e[4]=w,e[5]=m}else m=e[5];const b=m;let y;if(e[6]!==b||e[7]!==u){y=[];for(const me of u){const Re=b.get(me);Re&&y.push({id:me,session:Re})}e[6]=b,e[7]=u,e[8]=y}else y=e[8];const v=y;let N;e[9]!==g?(N=me=>{g(me.id,Ts(me.session))},e[9]=g,e[10]=N):N=e[10];const C=N,k=Yx;let D;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==v?(D=me=>{if(h(me),p&&p!==me){const Re=v.find(ye=>ye.id===me);Re&&C(Re)}},e[11]=h,e[12]=p,e[13]=C,e[14]=v,e[15]=D):D=e[15];const P=D;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{distance:8}},e[16]=I):I=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[17]=M):M=e[17];const _=Vr(On(cu,I),On(lu,M));let O;e[18]!==f?(O=me=>{const{active:Re,over:ye}=me;ye&&Re.id!==ye.id&&f(String(Re.id),String(ye.id))},e[18]=f,e[19]=O):O=e[19];const U=O,L=c.useRef(null);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F={left:!1,right:!1},e[20]=F):F=e[20];const[R,j]=c.useState(F);let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const me=L.current;if(!me)return;const Re=me.scrollLeft>2,ye=me.scrollLeft+me.clientWidth<me.scrollWidth-2;j(q=>q.left===Re&&q.right===ye?q:{left:Re,right:ye})},e[21]=A):A=e[21];const B=A;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{B();const me=L.current;if(!me||!globalThis.ResizeObserver)return;const Re=new ResizeObserver(B);return Re.observe(me),()=>Re.disconnect()},e[22]=X):X=e[22];let H;e[23]!==v.length?(H=[B,v.length],e[23]=v.length,e[24]=H):H=e[24],c.useEffect(X,H);let Z;e[25]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=Z):Z=e[25];let ce;e[26]!==p?(ce=[p],e[26]=p,e[27]=ce):ce=e[27],c.useEffect(Z,ce);const Y=R.left&&R.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":R.left?"linear-gradient(to right, transparent, black 24px)":R.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let se;e[28]!==v?(se=v.map(Xx),e[28]=v,e[29]=se):se=e[29];const oe=se;let Se;e[30]!==p||e[31]!==v?(Se=!p||!v.some(me=>me.id===p),e[30]=p,e[31]=v,e[32]=Se):Se=e[32];const K=Se;let pe;e[33]!==a?(pe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=pe):pe=e[34];let je;e[35]!==Y?(je=Y?{maskImage:Y,WebkitMaskImage:Y}:void 0,e[35]=Y,e[36]=je):je=e[36];let ne;e[37]===Symbol.for("react.memo_cache_sentinel")?(ne=[Fx],e[37]=ne):ne=e[37];let T;e[38]!==o||e[39]!==p||e[40]!==P||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==v?(T=v.map(me=>s.jsx(Lx,{tab:me,isActive:me.id===p,suppressControls:me.id===p&&l,onSelect:C,onClose:k,renderMenu:n,closeOtherTabs:P,onMenuOpenChangeComplete:r,children:me.id===p?o:null},me.id)),e[38]=o,e[39]=p,e[40]=P,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=v,e[46]=T):T=e[46];let G;e[47]!==T||e[48]!==oe?(G=s.jsx(Io,{items:oe,strategy:Hg,children:T}),e[47]=T,e[48]=oe,e[49]=G):G=e[49];let le;e[50]!==U||e[51]!==_||e[52]!==G?(le=s.jsx(Ur,{sensors:_,collisionDetection:Kr,modifiers:ne,onDragEnd:U,children:G}),e[50]=U,e[51]=_,e[52]=G,e[53]=le):le=e[53];let de;e[54]!==o||e[55]!==K?(de=K?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]=K,e[56]=de):de=e[56];let ue;e[57]!==je||e[58]!==le||e[59]!==de?(ue=s.jsxs("div",{ref:L,onScroll:B,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:je,children:[le,de]}),e[57]=je,e[58]=le,e[59]=de,e[60]=ue):ue=e[60];let Oe;return e[61]!==pe||e[62]!==ue?(Oe=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":pe,children:ue}),e[61]=pe,e[62]=ue,e[63]=Oe):Oe=e[63],Oe};function Wx(t){return t.stopPropagation()}function zx(t){return t.stopPropagation()}function Vx(t){return t.tabIds}function Ux(t){return t.ensureTab}function Kx(t){return t.closeOtherTabs}function Hx(t){return t.reorderTabs}function Gx(t){return t.currentSessionId}function qx(t){return t.setCurrentSession}function Qx(t){return t.activeSessions}function Yx(t){Nm(t)}function Xx(t){return t.id}function Jx(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(ga(),{month:"short"}),r=e.getDate(),i=e.getFullYear(),o=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${i}, ${o}:${l}`}function Zx(t){if(t.info.role==="user")return"";const e=typeof t.info.providerID=="string"?t.info.providerID.trim():"",n=typeof t.info.modelID=="string"?t.info.modelID.trim():"";return e&&n?`${e}/${n}`:n||e}function eb(t){const e=t.info.role==="user"?"User":"Assistant",n=Jx(t.info.time?.created),r=Zx(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
3
3
 
4
4
  *${i}*`:`**${e}**`}function Su(t){const e=eb(t),n=ig(t.parts,{user:t.info.role==="user"});return n?`${e}
5
5
 
@@ -909,7 +909,7 @@ ${t}
909
909
  styles: styles
910
910
  };
911
911
  `),ew=t=>{const e=st.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=Nt();if(n.length===0)return null;let u;e[0]!==a?(u=a("contextPanel.browser.history.label"),e[0]=a,e[1]=u):u=e[1];let d;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,g)=>s.jsxs("div",{role:"option","aria-selected":g===r,className:Ie("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(p.url)},onPointerEnter:()=>l(g),children:[s.jsx(E,{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||$a(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Ie("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:w=>{w.preventDefault(),w.stopPropagation(),o(p.url)},children:s.jsx(E,{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],d=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=d}else d=e[8];let h;return e[15]!==u||e[16]!==d?(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":u,children:d}),e[15]=u,e[16]=d,e[17]=h):h=e[17],h},an=t=>{const e=st.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",u=l&&"text-foreground";let d;e[0]!==u?(d=Ie("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=d):d=e[1];let h;e[2]!==n?(h=s.jsx(E,{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]!==d||e[10]!==h?(f=s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{type:"button",variant:a,size:"xs",className:d,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]=d,e[10]=h,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(Pt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let g;return e[14]!==f||e[15]!==p?(g=s.jsxs(At,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=g):g=e[16],g},ef=t=>{const e=st.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:u,onReload:d,onOpenExternal:h,canGoBack:f,canGoForward:p,isLoading:g,onAnnotate:w,onOpenDevTools:S,isAnnotating:x,onHardReload:m,onZoomIn:b,onZoomOut:y,onZoomReset:v,zoomPercent:N,onClearCookies:C,onClearCache:k,onToggleDeviceBar:D,isDeviceBarOpen:P}=t;let I;e[0]!==r?(I=r===void 0?[]:r,e[0]=r,e[1]=I):I=e[1];const M=I,_=N===void 0?100:N,{t:O}=Nt(),[U,L]=c.useState(!1),[F,R]=c.useState(-1);let j;e[2]!==U||e[3]!==M?(j=U?M:[],e[2]=U,e[3]=M,e[4]=j):j=e[4];const A=j;let B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{R(-1)},e[5]=B):B=e[5];let X;e[6]!==n||e[7]!==U?(X=[n,U],e[6]=n,e[7]=U,e[8]=X):X=e[8],c.useEffect(B,X);let H;e[9]!==l?(H=ke=>{L(!1),R(-1),l(ke)},e[9]=l,e[10]=H):H=e[10];const Z=H;let ce;e[11]!==F||e[12]!==Z||e[13]!==A?(ce=ke=>{if(A.length!==0){if(ke.key==="ArrowDown"||ke.key==="ArrowUp"){ke.preventDefault();const Qe=ke.key==="ArrowDown"?1:-1,We=A.length;R(z=>{const he=z+Qe;return he<-1?We-1:he>=We?-1:he});return}if(ke.key==="Escape"&&F>=0){ke.preventDefault(),R(-1);return}if(ke.key==="Enter"&&F>=0){ke.preventDefault();const Qe=A[F];Qe&&Z(Qe.url)}}},e[11]=F,e[12]=Z,e[13]=A,e[14]=ce):ce=e[14];const Y=ce;let se;e[15]!==O?(se=O("contextPanel.browser.back"),e[15]=O,e[16]=se):se=e[16];const oe=!f;let Se;e[17]!==a||e[18]!==oe||e[19]!==se?(Se=s.jsx(an,{icon:"arrow-left",label:se,onClick:a,disabled:oe}),e[17]=a,e[18]=oe,e[19]=se,e[20]=Se):Se=e[20];let K;e[21]!==O?(K=O("contextPanel.browser.forward"),e[21]=O,e[22]=K):K=e[22];const pe=!p;let je;e[23]!==u||e[24]!==K||e[25]!==pe?(je=s.jsx(an,{icon:"arrow-right",label:K,onClick:u,disabled:pe}),e[23]=u,e[24]=K,e[25]=pe,e[26]=je):je=e[26];let ne;e[27]!==g||e[28]!==O?(ne=O(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=O,e[29]=ne):ne=e[29];let T;e[30]!==d||e[31]!==ne?(T=s.jsx(an,{icon:"refresh",label:ne,onClick:d}),e[30]=d,e[31]=ne,e[32]=T):T=e[32];let G;e[33]!==m||e[34]!==O?(G=m?s.jsx(an,{icon:"restart",label:O("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=O,e[35]=G):G=e[35];let le;e[36]!==n||e[37]!==Z?(le=ke=>{ke.preventDefault(),Z(n)},e[36]=n,e[37]=Z,e[38]=le):le=e[38];let de;e[39]!==o?(de=ke=>o(ke.target.value),e[39]=o,e[40]=de):de=e[40];let ue,Oe;e[41]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>L(!0),Oe=()=>L(!1),e[41]=ue,e[42]=Oe):(ue=e[41],Oe=e[42]);const me=A.length>0;let Re;e[43]===Symbol.for("react.memo_cache_sentinel")?(Re=Ie("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]=Re):Re=e[43];let ye;e[44]!==O?(ye=O("contextPanel.browser.addressAria"),e[44]=O,e[45]=ye):ye=e[45];let q;e[46]!==n||e[47]!==Y||e[48]!==de||e[49]!==me||e[50]!==ye?(q=s.jsx("input",{value:n,onChange:de,onFocus:ue,onBlur:Oe,onKeyDown:Y,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":me,"aria-controls":"openchamber-browser-address-suggestions",className:Re,"aria-label":ye}),e[46]=n,e[47]=Y,e[48]=de,e[49]=me,e[50]=ye,e[51]=q):q=e[51];let we;e[52]!==i?(we=ke=>i?.(ke),e[52]=i,e[53]=we):we=e[53];let be;e[54]!==F||e[55]!==Z||e[56]!==we||e[57]!==A?(be=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(ew,{entries:A,activeIndex:F,onSelect:Z,onForget:we,onHighlight:R})}),e[54]=F,e[55]=Z,e[56]=we,e[57]=A,e[58]=be):be=e[58];let Ne;e[59]!==le||e[60]!==q||e[61]!==be?(Ne=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:le,children:[q,be]}),e[59]=le,e[60]=q,e[61]=be,e[62]=Ne):Ne=e[62];let ie;e[63]!==b||e[64]!==y||e[65]!==v||e[66]!==O||e[67]!==_?(ie=y&&b?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(an,{icon:"subtract",label:O("contextPanel.browser.zoomOut"),onClick:y}),_!==100&&v?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(xt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:v,"aria-label":O("contextPanel.browser.zoomReset"),children:[_,"%"]})}),s.jsx(Pt,{sideOffset:6,children:O("contextPanel.browser.zoomReset")})]}):null,s.jsx(an,{icon:"add",label:O("contextPanel.browser.zoomIn"),onClick:b})]}):null,e[63]=b,e[64]=y,e[65]=v,e[66]=O,e[67]=_,e[68]=ie):ie=e[68];let ee;e[69]!==C||e[70]!==O?(ee=C?s.jsx(an,{icon:"delete-bin",label:O("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=O,e[71]=ee):ee=e[71];let V;e[72]!==k||e[73]!==O?(V=k?s.jsx(an,{icon:"database-2",label:O("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=O,e[74]=V):V=e[74];let $;e[75]!==P||e[76]!==D||e[77]!==O?($=D?s.jsx(an,{icon:"smartphone",label:O("contextPanel.browser.deviceToolbar"),onClick:D,pressed:P}):null,e[75]=P,e[76]=D,e[77]=O,e[78]=$):$=e[78];let ae;e[79]!==x||e[80]!==w||e[81]!==O?(ae=w?s.jsx(an,{icon:"markup",label:O("contextPanel.browser.annotate.toggle"),onClick:w,pressed:x}):null,e[79]=x,e[80]=w,e[81]=O,e[82]=ae):ae=e[82];let W;e[83]!==S||e[84]!==O?(W=S?s.jsx(an,{icon:"terminal-box",label:O("contextPanel.browser.devTools"),onClick:S}):null,e[83]=S,e[84]=O,e[85]=W):W=e[85];let ve;e[86]!==O?(ve=O("contextPanel.browser.openExternal"),e[86]=O,e[87]=ve):ve=e[87];let Fe;e[88]!==h||e[89]!==ve?(Fe=s.jsx(an,{icon:"external-link",label:ve,onClick:h}),e[88]=h,e[89]=ve,e[90]=Fe):Fe=e[90];let Ce;return e[91]!==Se||e[92]!==je||e[93]!==T||e[94]!==G||e[95]!==Ne||e[96]!==ie||e[97]!==ee||e[98]!==V||e[99]!==$||e[100]!==ae||e[101]!==W||e[102]!==Fe?(Ce=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Se,je,T,G,Ne,ie,ee,V,$,ae,W,Fe]}),e[91]=Se,e[92]=je,e[93]=T,e[94]=G,e[95]=Ne,e[96]=ie,e[97]=ee,e[98]=V,e[99]=$,e[100]=ae,e[101]=W,e[102]=Fe,e[103]=Ce):Ce=e[103],Ce},Mo={kind:"fill"},rc=240,tw=3840,tf=[{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}],oc=t=>Number.isFinite(t)?Math.round(Math.min(tw,Math.max(rc,t))):rc,Oo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},sf=t=>{const e=tf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},sw=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},nw=(t,e)=>{const n=Oo(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}},rw=["mobile","tablet","desktop","fill"],ow={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},ic=t=>typeof t=="string"&&rw.includes(t),Zi=t=>t==="fill"?Mo:sf(ow[t])??Mo,ro=t=>{const e=Oo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Zi(n),i=Oo(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}},iw=t=>{const e=st.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=Nt();let u;e[0]!==n?(u=Oo(n),e[0]=n,e[1]=u):u=e[1];const d=u,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==d?(f=(oe,Se)=>{const K=Number.parseInt(Se,10);if(!Number.isFinite(K))return;const pe=d??{width:1280,height:800};r({kind:"custom",width:oc(oe==="width"?K:pe.width),height:oc(oe==="height"?K:pe.height)})},e[2]=r,e[3]=d,e[4]=f):f=e[4];const p=f;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=Ie("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]=g):g=e[5];const w=g;let S;e[6]!==r?(S=oe=>{const Se=sf(oe.target.value);r(Se??Mo)},e[6]=r,e[7]=S):S=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Ie("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 b;e[11]!==a?(b=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=b):b=e[12];let y;e[13]!==b?(y=s.jsx("option",{value:"",children:b}),e[13]=b,e[14]=y):y=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=tf.map(aw),e[15]=v):v=e[15];let N;e[16]!==h||e[17]!==S||e[18]!==x||e[19]!==y?(N=s.jsxs("select",{value:h,onChange:S,"aria-label":x,className:m,children:[y,v]}),e[16]=h,e[17]=S,e[18]=x,e[19]=y,e[20]=N):N=e[20];const C=d?String(d.width):"";let k;e[21]!==p?(k=oe=>p("width",oe.target.value),e[21]=p,e[22]=k):k=e[22];let D;e[23]!==a?(D=a("contextPanel.browser.device.width"),e[23]=a,e[24]=D):D=e[24];let P;e[25]!==C||e[26]!==k||e[27]!==D?(P=s.jsx("input",{value:C,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":D,className:w}),e[25]=C,e[26]=k,e[27]=D,e[28]=P):P=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=I):I=e[29];const M=d?String(d.height):"";let _;e[30]!==p?(_=oe=>p("height",oe.target.value),e[30]=p,e[31]=_):_=e[31];let O;e[32]!==a?(O=a("contextPanel.browser.device.height"),e[32]=a,e[33]=O):O=e[33];let U;e[34]!==M||e[35]!==_||e[36]!==O?(U=s.jsx("input",{value:M,onChange:_,placeholder:"—",inputMode:"numeric","aria-label":O,className:w}),e[34]=M,e[35]=_,e[36]=O,e[37]=U):U=e[37];let L;e[38]!==r||e[39]!==n?(L=()=>r(sw(n)),e[38]=r,e[39]=n,e[40]=L):L=e[40];const F=!d;let R;e[41]!==a?(R=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=R):R=e[42];let j;e[43]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(E,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=j):j=e[43];let A;e[44]!==L||e[45]!==F||e[46]!==R?(A=s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:L,disabled:F,"aria-label":R,children:j})}),e[44]=L,e[45]=F,e[46]=R,e[47]=A):A=e[47];let B;e[48]!==a?(B=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=B):B=e[49];let X;e[50]!==B?(X=s.jsx(Pt,{sideOffset:6,children:B}),e[50]=B,e[51]=X):X=e[51];let H;e[52]!==A||e[53]!==X?(H=s.jsxs(At,{children:[A,X]}),e[52]=A,e[53]=X,e[54]=H):H=e[54];let Z;e[55]!==l||e[56]!==d?(Z=d&&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]=d,e[57]=Z):Z=e[57];let ce;e[58]===Symbol.for("react.memo_cache_sentinel")?(ce=["system","light","dark"],e[58]=ce):ce=e[58];let Y;e[59]!==i||e[60]!==o||e[61]!==a?(Y=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ce.map(oe=>s.jsx(xt,{type:"button",variant:i===oe?"secondary":"ghost",size:"xs",className:Ie("shrink-0 rounded-full px-2.5 typography-micro",i===oe?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(oe),"aria-pressed":i===oe,children:a(oe==="system"?"contextPanel.browser.device.schemeSystem":oe==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},oe))}),e[59]=i,e[60]=o,e[61]=a,e[62]=Y):Y=e[62];let se;return e[63]!==N||e[64]!==P||e[65]!==U||e[66]!==H||e[67]!==Z||e[68]!==Y?(se=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,P,I,U,H,Z,Y]}),e[63]=N,e[64]=P,e[65]=U,e[66]=H,e[67]=Z,e[68]=Y,e[69]=se):se=e[69],se};function aw(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const lw=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},cw=2e3,dw=()=>{if(typeof window>"u"||window.__AIWORKER_ELECTRON__)return!1;const t=Nn();if(!t)return!1;try{return!yr(new URL(t,window.location.href).toString())}catch{return!1}},nf=t=>{const e=st.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=Nt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,u]=c.useState(l),d=yx(i),[h]=c.useState(dw);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let P=!0,I=null;const M=new AbortController,_=()=>{i1(M.signal).then(O=>{P&&(u(O),I=setTimeout(_,cw))})};return _(),()=>{P=!1,I&&clearTimeout(I),M.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const g=a.kind==="ready"?a.servers:null;let w;e[3]!==d||e[4]!==g?(w=c1({announced:d,discovered:g}),e[3]=d,e[4]=g,e[5]=w):w=e[5];const S=w;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Td,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=x):x=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==m?(b=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=b):b=e[10];let y;e[11]!==o?(y=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=y):y=e[12];let v;e[13]!==y?(v=s.jsx("span",{className:"typography-micro text-muted-foreground",children:y}),e[13]=y,e[14]=v):v=e[14];let N;e[15]!==v||e[16]!==b?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[b,v]}),e[15]=v,e[16]=b,e[17]=N):N=e[17];let C;e[18]!==d||e[19]!==S||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(C=S.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:d.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:S.map(P=>s.jsxs(xt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{gx(i),n(P.url)},children:[s.jsx(E,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:$a(P.url)||P.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:lw(P.url)})]},P.port))})]}):null,e[18]=d,e[19]=S,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=C):C=e[24];let k;e[25]!==S.length||e[26]!==a.kind||e[27]!==o?(k=S.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=S.length,e[26]=a.kind,e[27]=o,e[28]=k):k=e[28];let D;return e[29]!==N||e[30]!==C||e[31]!==k?(D=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:[x,N,C,k]}),e[29]=N,e[30]=C,e[31]=k,e[32]=D):D=e[32],D},Ls=t=>Math.round(t),uw=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,u])=>`${a}="${u}"`).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=${Ls(l.x)}, y=${Ls(l.y)}, width=${Ls(l.width)}, height=${Ls(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")},fw=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},mw=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},hw=({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: ${Ls(t.viewport.width)}x${Ls(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("",...uw(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(fw(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(mw(l,a)))),o.filter(l=>typeof l=="string").join(`
912
- `)},pw=t=>{const e=st.c(7),{t:n}=Nt(),r=Je(xw),i=Je(bw),o=ji(yw),l=eh(ww);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async u=>{const d=r??(i?"draft":null);if(!d){Le.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(u.screenshot)try{await l(u.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:d},{source:"preview-annotation",fileLabel:u.payload.pageUrl||"browser",startLine:1,endLine:1,code:hw({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Le.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},gw=()=>{const t=st.c(16),{t:e}=Nt();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 xw(t){return t.currentSessionId}function bw(t){return t.newSessionDraft?.open}function yw(t){return t.addDraft}function ww(t){return t.addAttachedFile}const Sw=3e4,vw=3,jw=250,kw={attempts:0,windowStartedAt:null},Cw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Sw,r=n?0:t.attempts;return r>=vw?null:{delayMs:jw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Nw=-3,oo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",dr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Aw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:f1),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[f,p]=c.useState(!1),g=c.useRef(n);g.current=n;const w=c.useRef(kw);return c.useEffect(()=>{if(!t)return;const S=()=>{try{const I=t.getURL();return oo(I)?I:""}catch{return""}},x=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},m=I=>{oo(I)&&(l(I),g.current(I))},b=()=>{const I=S();i({kind:"loading",url:I})},y=()=>{const I=S();let M="";try{M=t.getTitle()||""}catch{M=""}u(M),m(I),x(),i(_=>_.kind==="failed"&&_.url===I?_:{kind:"ready",url:I,title:M})},v=I=>{const M=dr(I);oo(M.url)&&(m(M.url),x())},N=I=>{const M=dr(I),_=Array.isArray(M.favicons)?M.favicons.find(Boolean):"",O=S();_&&O&&Vu.getState().resolve(O,_)},C=I=>{const M=dr(I);typeof M.title=="string"&&u(M.title)},k=I=>{const M=dr(I);if(M.isMainFrame===!1)return;const _=typeof M.errorCode=="number"?M.errorCode:0;_!==Nw&&i({kind:"failed",url:oo(M.validatedURL)?M.validatedURL:S(),code:_,description:typeof M.errorDescription=="string"?M.errorDescription:""})};let D=null;const P=()=>{const I=S(),M=Cw(w.current,Date.now());if(!M){i({kind:"failed",url:I,code:0,description:"",crashed:!0});return}w.current=M.state,i({kind:"loading",url:I}),D=setTimeout(()=>{D=null;try{t.reload()}catch{i({kind:"failed",url:I,code:0,description:"",crashed:!0})}},M.delayMs)};t.addEventListener("did-start-loading",b),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",v),t.addEventListener("did-navigate-in-page",v),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",P),t.addEventListener("crashed",P);try{!t.isLoading()&&S()&&y()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",b),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",v),t.removeEventListener("did-navigate-in-page",v),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:o,title:a,canGoBack:d,canGoForward:f}},Dw=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,Pw=4e4,io=.5,Iw=-3,Tw=4,Rw="persist:openchamber-browser",ac=20,Ew=600,Mw=2e4,Ow=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=Nt(),{currentTheme:i}=Zn(),o=c.useRef(null),[l,a]=c.useState(null),u=c.useCallback(ie=>{o.current=ie,a(ie)},[]),d=Te(ie=>ie.setContextPanelTabTargetPath),h=c.useRef(hr(t)),f=h.current!==ln?h.current:"",[p,g]=c.useState(f?null:ln),[w,S]=c.useState(f),[x,m]=c.useState(!1),[b,y]=c.useState(!1),[v,N]=c.useState(0),C=c.useRef(0),[k,D]=c.useState(!1),[P,I]=c.useState(Mo),M=c.useRef(P);M.current=P;const _=c.useRef([]),[O,U]=c.useState("system"),[L,F]=c.useState({width:0,height:0}),R=c.useRef(null),j=c.useRef(null),A=c.useRef(!1),B=c.useRef(Date.now()),X=c.useCallback(ie=>{!ie||ie===ln||!e||!n||d(e,n,ie)},[e,n,d]),H=Aw(l,{initialUrl:f,onUrlChange:c.useCallback(ie=>{const ee=Ar(ie);S(ee),X(ee)},[X])}),[Z,ce]=c.useState(null),Y=pw(e),se=gw(),oe=H.status.kind==="loading",Se=gr(Yu(e)),K=gr(ie=>ie.recordVisit),pe=gr(ie=>ie.forget);c.useEffect(()=>{H.status.kind==="ready"&&K(e,{url:Ar(H.status.url),title:H.status.title})},[e,H.status,K]);const je=c.useMemo(()=>Qu(Se,w),[Se,w]),ne=c.useCallback(ie=>{const ee=hr(ie);ee!==ln&&(S(ee),ce(null),tc(ee).then(V=>{const $=o.current;if(!$){g(V);return}try{$.loadURL(V)}catch{g(V)}}).catch(V=>{V instanceof _r&&ce(ee)}))},[]);c.useEffect(()=>{if(!f)return;let ie=!0;return tc(f).then(ee=>{ie&&g(ee)}).catch(ee=>{if(ie){if(ee instanceof _r){ce(f),g(ln);return}g(f)}}),()=>{ie=!1}},[]);const T=c.useMemo(()=>({executeJavaScript:async(ie,ee)=>{const V=o.current;if(!V)throw new Error("Browser view is not available");return V.executeJavaScript(ie,ee)},capturePage:async()=>{const ie=o.current;if(!ie)return null;const ee=ie.getWebContentsId();return Number.isFinite(ee)?await fr("desktop_browser_capture_page",{webContentsId:ee}):null}}),[]),G=c.useCallback(()=>{if(x){m(!1),bo(T);return}if(!H.url){Le.error(r("contextPanel.browser.annotate.noPage"));return}const ie=N1(i.metadata.variant==="light"?"light":"dark");m(!0),k1({host:T,theme:ie,labels:se}).then(async ee=>{m(!1),ee&&await Y(ee)}).catch(()=>{m(!1),Le.error(r("contextPanel.browser.annotate.failed"))})},[T,Y,i,x,H.url,se,r]);c.useEffect(()=>{if(!x)return;const ie=ee=>{th(ee)||ee.key!=="Escape"||(ee.preventDefault(),ee.stopImmediatePropagation(),m(!1),bo(T))};return window.addEventListener("keydown",ie,!0),()=>window.removeEventListener("keydown",ie,!0)},[T,x]);const le=c.useCallback(async(ie=8e3)=>{const ee=Date.now();for(;;){const V=o.current;if(!V)return!1;let $=!1;try{$=V.isLoading()}catch{return!1}if(!$)return!0;if(Date.now()-ee>ie)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),de=c.useCallback(async(ie,ee)=>{const V=o.current;if(!V)throw new Error("The browser panel is not ready");const $=()=>{ic(ee.viewport)&&(I(Zi(ee.viewport)),D(!0))};if(ie==="browser.back"||ie==="browser.forward"){const ke=ie==="browser.back";if(!(ke?V.canGoBack():V.canGoForward()))throw new Error(ke?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");ke?V.goBack():V.goForward(),await new Promise(z=>setTimeout(z,150)),await le();let We="";try{We=V.getTitle()||""}catch{We=""}return{url:Ar(V.getURL()),title:We}}if(ie==="browser.capture"){Te.getState().openContextBrowser(e,V.getURL());const ke=Date.now()+1200;let Qe=0,We=0;for(;We<2&&Date.now()<ke;){const Be=V.getBoundingClientRect().width;We=Be>=2&&Math.abs(Be-Qe)<.5?We+1:0,Qe=Be,await new Promise(Ae=>setTimeout(Ae,50))}await new Promise(Be=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Be()))}),await le();const z=await T.capturePage();if(!z)throw new Error("The page could not be captured");let he="";try{he=V.getTitle()||""}catch{he=""}return{...z,url:Ar(V.getURL()),title:he,viewport:ro(M.current)}}if(ie==="browser.resize"){if(!ic(ee.viewport))throw new Error("viewport is required");return $(),await new Promise(ke=>setTimeout(ke,200)),await le(),{viewport:ro(Zi(ee.viewport))}}if(ie==="browser.open"){const ke=typeof ee.url=="string"?ee.url:"";if(!ke)throw new Error("url is required");$(),ne(ke),await new Promise(z=>setTimeout(z,150));const Qe=await le(25e3);let We="";try{We=V.getTitle()||""}catch{We=""}return{url:hr(ke),title:We,opened:!0,settled:Qe,viewport:ro(M.current)}}await le();const ae=ke=>typeof ke=="string"&&ke?ke:void 0,ve=(()=>{switch(ie){case"browser.snapshot":return q1({selector:ae(ee.selector)});case"browser.click":return Q1({selector:ae(ee.selector),text:ae(ee.text)});case"browser.type":return Y1({selector:String(ee.selector??""),value:String(ee.value??""),submit:ee.submit===!0});case"browser.inspect":return Z1({selector:String(ee.selector??"")});case"browser.scroll":return X1({selector:ae(ee.selector),direction:ae(ee.direction)});default:return null}})();if(!ve)throw new Error(`Unsupported browser action: ${ie}`);const Fe=await V.executeJavaScript(ve,!0);if(!Fe||typeof Fe!="object")throw new Error("The page returned no result");const Ce=Fe;if(Ce.ok!==!0)throw new Error(typeof Ce.error=="string"&&Ce.error?Ce.error:"Browser action failed");if(ie==="browser.snapshot"){const ke=_.current;return{...Ce,viewport:ro(M.current),...ke.length>0?{consoleProblems:[...ke]}:{}}}return(ie==="browser.click"||ie==="browser.type"&&ee.submit===!0)&&(await new Promise(ke=>setTimeout(ke,150)),await le()),Fe},[T,e,ne,le]);c.useEffect(()=>R1({run:de}),[de]),c.useEffect(()=>{const ie=T;return()=>{bo(ie)}},[T]),c.useEffect(()=>{if(!l)return;const ie=V=>{const $=V;if(typeof $.level!="number"||$.level<2)return;const ae=$.sourceId?`${$.sourceId}${$.line?`:${$.line}`:""}`:"";_.current.push({level:$.level>=3?"error":"warning",message:String($.message??"").slice(0,400),source:ae}),_.current.length>ac&&_.current.splice(0,_.current.length-ac)},ee=()=>{_.current=[]};return l.addEventListener("console-message",ie),l.addEventListener("did-start-loading",ee),()=>{l.removeEventListener("console-message",ie),l.removeEventListener("did-start-loading",ee)}},[l]);const ue=c.useRef(new Set),Oe=c.useCallback(ie=>{ue.current.clear(),ne(ie)},[ne]);c.useEffect(()=>{if(!l)return;const ie=V=>{const $=dr(V),ae=typeof $.url=="string"?$.url:"";!ae||!sc(ae)||(V.preventDefault(),ne(ae))},ee=V=>{const $=dr(V);if($.isMainFrame===!1||$.errorCode===-3)return;const ae=typeof $.validatedURL=="string"?$.validatedURL:"";!ae||!sc(ae)||ue.current.has(ae)||(ue.current.add(ae),ne(ae))};return l.addEventListener("will-navigate",ie),l.addEventListener("did-fail-load",ee),()=>{l.removeEventListener("will-navigate",ie),l.removeEventListener("did-fail-load",ee)}},[ne,l]),c.useEffect(()=>{if(!l)return;const ie=ee=>{const V=ee.detail;ee.preventDefault(),V?.url&&ne(V.url)};return l.addEventListener("new-window",ie),()=>l.removeEventListener("new-window",ie)},[ne,l]);const me=c.useCallback(ie=>{const ee=Math.min(Tw,Math.max(Iw,ie));C.current=ee,N(ee);try{o.current?.setZoomLevel(ee)}catch{}},[]);c.useEffect(()=>{const ie=ee=>{if(!(ee instanceof CustomEvent))return;const V=ee.detail,$=o.current;!$||document.activeElement!==$||(V==="zoom-in"?me(C.current+io):V==="zoom-out"?me(C.current-io):V==="zoom-reset"&&me(0))};return window.addEventListener("aiworker:zoom",ie),()=>window.removeEventListener("aiworker:zoom",ie)},[me]);const Re=c.useCallback(ie=>{fr("desktop_browser_clear_data",{partition:Rw,cookies:ie==="cookies",cache:ie==="cache"}).then(()=>{Le.success(r(ie==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Le.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const ie=R.current;if(!ie||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(V=>{const $=V[0]?.contentRect;$&&F({width:$.width,height:$.height})});return ee.observe(ie),()=>ee.disconnect()},[]);const ye=c.useCallback(ie=>{U(ie);const ee=o.current;if(!ee)return;let V=-1;try{V=ee.getWebContentsId()}catch{return}fr("desktop_browser_set_color_scheme",{webContentsId:V,scheme:ie}).catch($=>{U("system"),Le.error($ instanceof Error?$.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),q=c.useCallback(()=>{try{oe?o.current?.stop():o.current?.reload()}catch{}},[oe]),we=H.status;c.useEffect(()=>{const ie=()=>{y(!0);const $=setTimeout(()=>{try{o.current?.reload()}catch{}},Ew);return()=>clearTimeout($)};if(we.kind==="failed"){if(!r1(we.code,we.url)){y(!1);return}const $=Date.now(),ae=j.current?.url===we.url?j.current:{url:we.url,startedAt:$};if(j.current=ae,$-ae.startedAt>Pw){y(!1);return}return ie()}if(we.kind==="loading")return;if(j.current=null,we.kind!=="ready"||!we.url||!yr(we.url)){A.current=!0,y(!1);return}if(A.current||Date.now()-B.current>Mw){A.current=!0,y(!1);return}let ee=!1,V=null;return a1(Ar(we.url)).then($=>{if(!ee){if($===null||$<500){A.current=!0,y(!1);return}V=ie()}}),()=>{ee=!0,V?.()}},[we]);const be=H.status.kind==="failed"&&!b?H.status:null,Ne=nw(P,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(ef,{address:w,onAddressChange:S,onSubmit:Oe,suggestions:je,onForgetSuggestion:ie=>pe(e,ie),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:q,onOpenExternal:()=>{Uo(H.url||w)},canGoBack:H.canGoBack,canGoForward:H.canGoForward,isLoading:oe,onAnnotate:G,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>me(v+io),onZoomOut:()=>me(v-io),onZoomReset:()=>me(0),zoomPercent:Math.round(Math.pow(1.2,v)*100),onClearCookies:()=>Re("cookies"),onClearCache:()=>Re("cache"),onToggleDeviceBar:()=>D(ie=>!ie),isDeviceBarOpen:k}),k?s.jsx(iw,{viewport:P,onViewportChange:I,colorScheme:O,onColorSchemeChange:ye,scale:Ne?.scale??1}):null,s.jsxs("div",{ref:R,className:Ie("relative min-h-0 flex-1 bg-background",Ne&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:u,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:Ne?{width:`${Ne.width}px`,height:`${Ne.height}px`,transform:`scale(${Ne.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!H.url&&!oe?s.jsx(nf,{onOpen:Oe,directory:e}):null,b?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,Z?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:Z})})]}):null,be&&!Z?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:be.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:be.crashed?r("contextPanel.browser.crashedHint"):be.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,oe?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]})]})},Fw=t=>{const e=st.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=Nt(),l=Te(_w);let a;e[0]!==n?(a=hr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==ln?u:"",[h,f]=c.useState(d),[p,g]=c.useState(d);let w;e[2]!==d?(w=d?[d]:[],e[2]=d,e[3]=w):w=e[3];const[S,x]=c.useState(w),[m,b]=c.useState(d?0:-1),[y,v]=c.useReducer(Lw,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=se=>{!se||se===ln||!r||!i||l(r,i,se)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let k;e[8]!==r?(k=Yu(r),e[8]=r,e[9]=k):k=e[9];const D=gr(k),P=gr($w),I=gr(Ww);let M;e[10]!==h||e[11]!==D?(M=Qu(D,h),e[10]=h,e[11]=D,e[12]=M):M=e[12];const _=M;let O;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==P?(O=se=>{const oe=hr(se);oe!==ln&&(f(oe),g(oe),C(oe),P(r,{url:oe}),x(Se=>{const K=m>=0?Se.slice(0,m+1):[];return K[K.length-1]===oe?(b(K.length-1),K):(b(K.length),[...K,oe])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=P,e[17]=O):O=e[17];const U=O;let L;e[18]!==S||e[19]!==C?(L=se=>{const oe=S[se];oe&&(b(se),f(oe),g(oe),C(oe))},e[18]=S,e[19]=C,e[20]=L):L=e[20];const F=L;let R;e[21]!==r||e[22]!==I?(R=se=>I(r,se),e[21]=r,e[22]=I,e[23]=R):R=e[23];let j,A;e[24]!==F||e[25]!==m?(A=()=>F(m-1),j=()=>F(m+1),e[24]=F,e[25]=m,e[26]=j,e[27]=A):(j=e[26],A=e[27]);let B;e[28]!==h||e[29]!==p?(B=()=>{Uo(p||h)},e[28]=h,e[29]=p,e[30]=B):B=e[30];const X=m>0,H=m>=0&&m<S.length-1;let Z;e[31]!==h||e[32]!==U||e[33]!==_||e[34]!==j||e[35]!==B||e[36]!==X||e[37]!==H||e[38]!==R||e[39]!==A?(Z=s.jsx(ef,{address:h,onAddressChange:f,onSubmit:U,suggestions:_,onForgetSuggestion:R,onBack:A,onForward:j,onReload:v,onOpenExternal:B,canGoBack:X,canGoForward:H,isLoading:!1}),e[31]=h,e[32]=U,e[33]=_,e[34]=j,e[35]=B,e[36]=X,e[37]=H,e[38]=R,e[39]=A,e[40]=Z):Z=e[40];let ce;e[41]!==p||e[42]!==U||e[43]!==y||e[44]!==o?(ce=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}|${y}`):s.jsx(nf,{onOpen:U})}),e[41]=p,e[42]=U,e[43]=y,e[44]=o,e[45]=ce):ce=e[45];let Y;return e[46]!==Z||e[47]!==ce?(Y=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Z,ce]}),e[46]=Z,e[47]=ce,e[48]=Y):Y=e[48],Y},Bw=t=>{const e=st.c(3),[n]=c.useState(Dw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Ow,{...t}):s.jsx(Fw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function _w(t){return t.setContextPanelTabTargetPath}function Lw(t){return t+1}function $w(t){return t.recordVisit}function Ww(t){return t.forget}const zw=Ln(()=>Bn(()=>import("./WalkthroughView-C7AHOpCA.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])).then(t=>({default:t.WalkthroughView}))),Vw=Ln(()=>Bn(()=>import("./DiffView-DC9RX3MF.js"),__vite__mapDeps([124,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,125,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.DiffView}))),Uw=Ln(()=>Bn(()=>import("./FilesView-BFZkuu4O.js"),__vite__mapDeps([126,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,127,128,129,130,131,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,132,133,118,119,116,121,134,117,135])).then(t=>({default:t.FilesView}))),Kw=Ln(()=>Bn(()=>import("./GitView-B_x52MHY.js"),__vite__mapDeps([136,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,137,115,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,85,113,114,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),Hw=Ln(()=>Bn(()=>import("./LinearIssuesView-Dehh5afm.js"),__vite__mapDeps([138,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}))),Gw=Ln(()=>Bn(()=>import("./PlanView-BmQUYT_z.js"),__vite__mapDeps([139,1,2,4,5,6,7,8,9,127,57,58,59,60,61,62,79,55,56,63,128,129,130,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,117,135,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,84])).then(t=>({default:t.PlanView}))),qw=320,Qw=1400,rf=600,Yw=100,Xw=24,Fo=new Map,Jw=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},lc=t=>Number.isFinite(t)?Math.min(Qw,Math.max(qw,Math.round(t))):rf,Zw=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},eS=(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},of=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="linear"?"contextPanel.mode.linear":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),tS=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=ea(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"?$a(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?tS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):of(t.mode,n)},cc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Sa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Eu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(E,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(E,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(E,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(E,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(E,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(E,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(E,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(E,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=nS(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(E,{name:"global",className:"h-3.5 w-3.5"})}},nS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},rS=200,oS=480,iS=({visible:t,active:e})=>{const{t:n}=Nt(),r=Te(b=>b.contextEditorTreeWidth),i=Te(b=>b.setContextEditorTreeWidth),[o,l]=c.useState(!1),a=c.useRef(0),u=c.useRef(r),d=c.useRef(null),h=c.useRef(null),f=c.useRef(null),p=c.useCallback(b=>Math.min(oS,Math.max(rS,Math.round(b))),[]),g=c.useCallback(b=>{const y=f.current;y&&(y.style.width=`${b}px`,y.style.setProperty("--oc-editor-tree-width",`${b}px`))},[]),w=b=>{if(t){try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}h.current=b.pointerId,l(!0),a.current=b.clientX,u.current=r,d.current=r,b.preventDefault()}},S=b=>{if(!o||h.current!==b.pointerId)return;const y=a.current-b.clientX,v=p(u.current+y);d.current!==v&&(d.current=v,g(v))},x=b=>{if(h.current!==b.pointerId)return;try{b.currentTarget.releasePointerCapture(b.pointerId)}catch{}const y=p(d.current??r);h.current=null,d.current=null,l(!1),i(y)},m=t?r:0;return s.jsxs("div",{ref:f,className:Ie("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?d.current??m:m}px`,"--oc-editor-tree-width":`${o?d.current??r:r}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:Ie("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:S,onPointerUp:x,onPointerCancel:x,role:"separator","aria-orientation":"vertical","aria-label":n("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Ie("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(Cy,{visible:t&&e})})]})},ea=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,aS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},lS=(t,e)=>{if(e.length===0)return Fo;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?Fo:r},cS=(t,e)=>{const n=kd(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=lS(n.getState().session,i.current);return aS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},dS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,uS=()=>{const{t}=Nt(),e=er()??"",n=c.useMemo(()=>Jw(e),[e]),r=Te(ge=>n?ge.contextPanelByDirectory[n]:void 0),i=Te(ge=>ge.closeContextPanel),o=Te(ge=>ge.closeContextPanelTab),l=Te(ge=>ge.openContextPanelTab),a=Te(ge=>ge.toggleContextPanelExpanded),u=Te(ge=>ge.setContextPanelWidth),d=Te(ge=>ge.setActiveContextPanelTab),h=Te(ge=>ge.openContextBrowser);c.useEffect(()=>{if(e)return E1(ge=>h(e,ge))},[e,h]);const f=Te(ge=>ge.reorderContextPanelTabs),p=hn(ge=>ge.setSelectedPath),g=Te(ge=>ge.contextEditorTreeVisible),w=Te(ge=>ge.toggleContextEditorTree),S=Te(ge=>ge.openNewContextBrowserTab),x=Vu(ge=>ge.byOrigin),m=Te(ge=>ge.allowPromptingSubagentSessions),{themeMode:b,setThemeMode:y,lightThemeId:v,darkThemeId:N,currentTheme:C}=Zn(),k=c.useMemo(()=>r?.tabs??[],[r?.tabs]),D=k.find(ge=>ge.id===r?.activeTabId)??k[k.length-1]??null,P=!!(r?.isOpen&&D),I=!!(P&&r?.expanded),[M,_]=c.useState(null),O=D?.mode??null,U=O?r?.widthByMode?.[O]:void 0,L=O?r?.widthFractionByMode?.[O]:void 0,F=O?sh(O):.5,R=M??(typeof window<"u"?window.innerWidth:rf*2),j=L!=null&&M!=null?Math.round(L*M):U,A=lc(j??Math.round(F*R));c.useEffect(()=>{!n||!O||L!=null||U==null||M==null||u(n,O,U,M)},[O,M,n,U,L,u]);const B=c.useMemo(()=>{const ge=[];for(const Ye of k){if(Ye.mode!=="chat")continue;const bt=ea(Ye.dedupeKey);bt&&!ge.includes(bt)&&ge.push(bt)}return ge},[k]),X=cS(n||void 0,B),[H,Z]=c.useState(!1),ce=c.useRef(0),Y=c.useRef(A),se=c.useRef(null),oe=c.useRef(null),Se=c.useRef(null),K=c.useRef(new Map),pe=c.useRef(new Map),je=c.useRef(!1);c.useLayoutEffect(()=>{const ge=Se.current?.parentElement;if(!ge||typeof ResizeObserver>"u")return;const Ye=new ResizeObserver(()=>{_(ge.clientWidth||null)});return Ye.observe(ge),_(ge.clientWidth||null),()=>Ye.disconnect()},[]),c.useEffect(()=>{if(!P||je.current){je.current=P;return}const ge=window.requestAnimationFrame(()=>{Se.current?.focus({preventScroll:!0})});return je.current=!0,()=>window.cancelAnimationFrame(ge)},[P]);const ne=c.useRef(null),T=c.useRef(null),G=c.useCallback(()=>{T.current=null;const ge=Se.current,Ye=se.current;!ge||Ye===null||ge.style.setProperty("--oc-context-panel-width",`${Ye}px`)},[]);c.useEffect(()=>()=>{T.current!==null&&clearTimeout(T.current)},[]);const le=c.useCallback(ge=>{const Ye=lc(ge),bt=ne.current;return bt===null?Ye:Math.min(Ye,Math.max(1,bt))},[]),de=c.useCallback(ge=>{!P||I||!n||(oe.current=ge.pointerId,Z(!0),ce.current=ge.clientX,Y.current=A,se.current=A,ne.current=Zw(Se.current),document.documentElement.style.cursor="col-resize",ge.preventDefault())},[n,I,P,A]),ue=c.useCallback(()=>{const ge=le(se.current??A),Ye=ne.current;se.current=null,ne.current=null,T.current!==null&&(clearTimeout(T.current),T.current=null),document.documentElement.style.cursor="",n&&O&&u(n,O,ge,Ye??void 0),Z(!1),oe.current=null},[O,le,n,u,A]);c.useEffect(()=>{if(!H)return;const ge=jt=>{if(oe.current!==jt.pointerId)return;const fe=ce.current-jt.clientX,ze=le(Y.current+fe);se.current!==ze&&(se.current=ze,T.current===null&&(T.current=setTimeout(G,Yw)))},Ye=jt=>{oe.current===jt.pointerId&&ue()},bt=()=>{ue()};return window.addEventListener("pointermove",ge),window.addEventListener("pointerup",Ye),window.addEventListener("pointercancel",Ye),window.addEventListener("blur",bt),()=>{window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",Ye),window.removeEventListener("pointercancel",Ye),window.removeEventListener("blur",bt)}},[G,le,ue,H]),c.useEffect(()=>{H||(se.current=null,document.documentElement.style.cursor="")},[H]);const Oe=c.useCallback(()=>{n&&i(n)},[i,n]),me=c.useCallback(()=>{n&&a(n)},[n,a]),Re=c.useCallback(ge=>{ge.key==="Escape"&&(nh(ge.target)||(ge.preventDefault(),ge.stopPropagation(),Oe()))},[Oe]);c.useEffect(()=>{if(!(!n||!D)&&D.mode==="file"&&D.targetPath){p(n,D.targetPath,{allowOutsideRoot:!0});return}},[D,n,p]);const ye=c.useMemo(()=>k.filter(ge=>ge.mode==="chat"),[k]),q=P&&D?.mode==="chat"?D.id:null,we=P&&D?.mode==="chat"?ea(D.dedupeKey):null,be=Xg(ye,q);c.useEffect(()=>{if(!P||!n||!we||typeof window>"u")return;const ge=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ei(n,we,!1);return}Rd(we),ei(n,we,!0)};ge();const Ye=window.setInterval(ge,1e4);return window.addEventListener("focus",ge),window.addEventListener("blur",ge),document.addEventListener("visibilitychange",ge),()=>{window.clearInterval(Ye),window.removeEventListener("focus",ge),window.removeEventListener("blur",ge),document.removeEventListener("visibilitychange",ge),ei(n,we,!1)}},[we,n,P]);const Ne=c.useCallback((ge,Ye,bt)=>Jg(pe.current,ge,Ye,n||null,bt,{mode:b,lightThemeId:v,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:m}),[m,C,N,n,v,b]),ie=be&&we?Ne(be.id,we,be.readOnly):null;c.useEffect(()=>{const ge=new Set(k.map(Ye=>Ye.id));for(const Ye of pe.current.keys())ge.has(Ye)||pe.current.delete(Ye)},[k]);const ee=c.useCallback(ge=>{!n||D?.mode!=="diff"||l(n,{mode:"diff",targetPath:D.targetPath,stagedDiff:ge==="staged",diffScope:ge})},[D,n,l]),V=c.useCallback(()=>{if(typeof window>"u")return;const ge={themeMode:b,lightThemeId:v,darkThemeId:N,currentTheme:C};for(const Ye of K.current.values()){const bt=Ye.contentWindow;bt&&bt.postMessage({type:"aiworker:theme-sync",payload:ge},window.location.origin)}},[C,N,v,b]),$=c.useCallback(()=>{if(typeof window>"u")return;const ge={allowPromptingSubagentSessions:m};for(const Ye of K.current.values()){const bt=Ye.contentWindow;bt&&bt.postMessage({type:"aiworker:chat-settings-sync",payload:ge},window.location.origin)}},[m]),ae=c.useCallback((ge,Ye,bt)=>{const jt=Ye.contentWindow;jt&&jt.postMessage({type:gu,payload:{visible:q===ge}},bt)},[q]),W=c.useCallback(()=>{if(!(typeof window>"u"))for(const[ge,Ye]of K.current.entries())ae(ge,Ye,window.location.origin)},[ae]);c.useEffect(()=>{if(typeof window>"u")return;const ge=Ye=>{if(Ye.origin!==window.location.origin)return;const bt=Array.from(K.current.entries()).find(([,$e])=>$e.contentWindow===Ye.source);if(!bt)return;const jt=Ye.data;if(jt?.type===Zg){const[$e,J]=bt;ae($e,J,Ye.origin);return}if(jt?.type===ex){if(typeof jt.requestId!="string"||!jt.requestId)return;const $e=us(),J={apiBaseUrl:Nn(),clientToken:$r(),localOrigin:typeof window.__AIWORKER_LOCAL_ORIGIN__=="string"?window.__AIWORKER_LOCAL_ORIGIN__:"",runtimeHeaders:fd(),relayHostId:$e.startsWith("host:")?$e.slice(5):"",relay:am()??void 0};Ye.source?.postMessage({type:tx,requestId:jt.requestId,payload:J},Ye.origin);return}if(jt?.type==="aiworker:theme-sync-request"){V();return}if(jt?.type==="aiworker:chat-settings-request"){$();return}if(jt?.type!=="aiworker:cycle-theme-request")return;const fe=["light","dark","system"],it=(fe.indexOf(b)+1)%fe.length;y(fe[it])};return window.addEventListener("message",ge),()=>window.removeEventListener("message",ge)},[$,ae,V,y,b]),c.useLayoutEffect(()=>{k.some(Ye=>Ye.mode==="chat")&&(V(),$(),W())},[N,v,$,W,V,k,b]);const ve=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",Fe=c.useMemo(()=>D?k.filter(ge=>ge.mode===D.mode):[],[D,k]),Ce=c.useMemo(()=>Fe.map(ge=>{const Ye=sS(ge,X,t),bt=dS(Ye,Xw),jt=eS(ge.targetPath,e);return{id:ge.id,label:bt,icon:cc(ge,x),title:jt?`${Ye}: ${jt}`:Ye,closeLabel:t("contextPanel.tab.closeTabAria",{label:bt})}}),[Fe,e,x,X,t]),ke=D?.mode==="context"?s.jsx(Uy,{}):D?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kw,{isActive:P})}):D?.mode==="pr"?s.jsx(Jb,{}):D?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hw,{})}):D?.mode==="notes"?s.jsx(ug,{}):D?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Gw,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,Qe=c.useMemo(()=>k.filter(ge=>ge.mode==="browser"),[k]),We=c.useMemo(()=>k.filter(ge=>ge.mode==="diff"),[k]),z=c.useMemo(()=>k.find(ge=>ge.mode==="terminal")??null,[k]),he=c.useMemo(()=>k.some(ge=>ge.mode==="walkthrough"),[k]),Be=c.useMemo(()=>k.some(ge=>ge.mode==="file"),[k]),Ae=c.useMemo(()=>k.some(ge=>ge.mode==="file"&&ge.targetPath),[k]),at=D?.mode==="file",Ue=Te(ge=>ge.closeContextPanelTabs),ht=c.useCallback(ge=>{if(!n)return null;const{id:Ye,index:bt,allIds:jt,close:fe}=ge,ze=()=>Ue(n,jt.filter(Ve=>Ve!==Ye)),it=()=>Ue(n,jt.slice(0,bt)),$e=()=>Ue(n,jt.slice(bt+1)),J=()=>Ue(n,jt),re=jt.length>1,Pe=bt===0,_e=bt===jt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Un,{onClick:fe,children:[s.jsx(E,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Oi,{}),s.jsxs(Un,{onClick:ze,disabled:!re,children:[s.jsx(E,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Un,{onClick:it,disabled:Pe,children:[s.jsx(E,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Un,{onClick:$e,disabled:_e,children:[s.jsx(E,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Oi,{}),s.jsxs(Un,{onClick:J,disabled:!re,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Ue,n,t]),ut=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ve?s.jsx(su,{items:Ce,activeId:D?.id??null,onSelect:ge=>{n&&d(n,ge)},onClose:ge=>{n&&o(n,ge)},onReorder:(ge,Ye)=>{n&&f(n,ge,Ye)},layoutMode:"scrollable",variant:"default",tabContextMenu:ht}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[D?cc(D,x):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?of(D.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?.mode==="browser"?s.jsx(xt,{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(E,{name:"add",className:"h-3.5 w-3.5"})}):null,at?s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":g,children:s.jsx(E,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:me,className:"h-7 w-7 p-0",title:t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:I?s.jsx(E,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:Oe,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ct=P?I?{"--oc-context-panel-width":M!==null?`${M}px`:"100%",width:M!==null?`${M}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${A}px`}:{"--oc-context-panel-width":`${A}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:Se,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:Ie("flex min-h-0 flex-col overflow-hidden bg-background",I?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Re,style:Ct,children:[P&&!I&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!I&&s.jsx("div",{className:Ie("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",H&&"bg-[var(--interactive-border)]"),onPointerDown:de,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Ie("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]",!P&&"pointer-events-none select-none opacity-0"),style:{width:I?M!==null?`${M}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[ut,s.jsxs("div",{className:Ie("relative min-h-0 flex-1 overflow-hidden",H&&"pointer-events-none"),children:[Be?s.jsxs("div",{className:Ie("absolute inset-0 flex",at?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:Ae?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uw,{mode:"editor-only",visible:P&&at})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(E,{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")})]})}),s.jsx(iS,{visible:g,active:P&&at})]}):null,be&&we&&ie?s.jsx("iframe",{ref:ge=>{if(!ge){K.current.delete(be.id);return}K.current.set(be.id,ge)},src:ie,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:we}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{V(),$(),W()}},be.id):null,Qe.map(ge=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==ge.id&&"hidden"),children:s.jsx(Bw,{initialUrl:ge.targetPath??"",directory:n,tabID:ge.id})},ge.id)),We.map(ge=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==ge.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vw,{visible:P&&D?.id===ge.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:ge.diffScope??(ge.stagedDiff?"staged":"working"),onDiffScopeChange:ee,targetFilePath:ge.targetPath,flushContent:!0})})},ge.id)),z?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:s.jsx(fg,{visible:P&&D?.mode==="terminal",directory:z.targetDirectory})}):null,he?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(zw,{directory:e,visible:P&&D?.mode==="walkthrough"})})}):null,D?.mode!=="chat"&&!at&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"?ke:null]})]})]})},fS=t=>{const e=st.c(42),{open:n,onOpenChange:r}=t,{t:i}=Nt(),o=Te(mS),l=Te(hS),a=Te(pS),u=Te(gS);let d;e[0]!==o?(d=Ed(o),e[0]=o,e[1]=d):d=e[1];const h=d,f=l.length===0;let p;if(e[2]!==l||e[3]!==h){let D;e[5]!==l?(D=P=>l.includes(P.id),e[5]=l,e[6]=D):D=e[6],p=h.every(D),e[2]=l,e[3]=h,e[4]=p}else p=e[4];const g=p;let w;e[7]!==i?(w=i("contextRail.configure.dialogTitle"),e[7]=i,e[8]=w):w=e[8];let S;e[9]!==w?(S=s.jsx(Rs,{children:w}),e[9]=w,e[10]=S):S=e[10];let x;e[11]!==i?(x=i("contextRail.configure.dialogDescription"),e[11]=i,e[12]=x):x=e[12];let m;e[13]!==x?(m=s.jsx(Es,{children:x}),e[13]=x,e[14]=m):m=e[14];let b;e[15]!==S||e[16]!==m?(b=s.jsxs($s,{children:[S,m]}),e[15]=S,e[16]=m,e[17]=b):b=e[17];let y;if(e[18]!==l||e[19]!==a||e[20]!==h||e[21]!==i){let D;e[23]!==l||e[24]!==a||e[25]!==i?(D=P=>s.jsx(rh,{settingsItem:`layout.context-rail.surface.${P.id}`,checked:!l.includes(P.id),onChange:I=>a(P.id,I),label:i(P.labelKey),ariaLabel:i(P.labelKey)},P.id),e[23]=l,e[24]=a,e[25]=i,e[26]=D):D=e[26],y=h.map(D),e[18]=l,e[19]=a,e[20]=h,e[21]=i,e[22]=y}else y=e[22];let v;e[27]!==y?(v=s.jsx("div",{className:"flex flex-col",children:y}),e[27]=y,e[28]=v):v=e[28];let N;e[29]!==f||e[30]!==g||e[31]!==u||e[32]!==i?(N=f?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[g?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(xt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[29]=f,e[30]=g,e[31]=u,e[32]=i,e[33]=N):N=e[33];let C;e[34]!==N||e[35]!==b||e[36]!==v?(C=s.jsxs(js,{className:"max-w-md",children:[b,v,N]}),e[34]=N,e[35]=b,e[36]=v,e[37]=C):C=e[37];let k;return e[38]!==r||e[39]!==n||e[40]!==C?(k=s.jsx(vs,{open:n,onOpenChange:r,children:C}),e[38]=r,e[39]=n,e[40]=C,e[41]=k):k=e[41],k};function mS(t){return t.contextRailOrder}function hS(t){return t.contextRailHiddenSurfaces}function pS(t){return t.setContextRailSurfaceVisible}function gS(t){return t.setContextRailHiddenSurfaces}const af=150,xS=500,bS=[],yS=t=>t>99?"99+":String(t),wS=t=>{const e=st.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:f,onSelect:p}=t;let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:w,listeners:S,setNodeRef:x,transform:m,transition:b,isDragging:y}=Qo(g);let v;e[2]!==a?(v=a!=null&&a>0?yS(a):null,e[2]=a,e[3]=v):v=e[3];const N=v;let C;e[4]!==m?(C=Yo.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let k;e[6]!==C||e[7]!==b?(k={transform:C,transition:b},e[6]=C,e[7]=b,e[8]=k):k=e[8];const D=y&&"z-10 opacity-70";let P;e[9]!==D?(P=Ie("relative",D),e[9]=D,e[10]=P):P=e[10];let I;e[11]!==p||e[12]!==n?(I=()=>p(n),e[11]=p,e[12]=n,e[13]=I):I=e[13];const M=u??o,_=r?"text-primary":"text-muted-foreground hover:text-foreground";let O;e[14]!==_?(O=Ie("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",_),e[14]=_,e[15]=O):O=e[15];let U;e[16]!==n.icon||e[17]!==n.id?(U=n.id==="diff"?s.jsx(Eu,{}):s.jsx(E,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=U):U=e[18];let L;e[19]!==N||e[20]!==h||e[21]!==i||e[22]!==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}):N?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:N}):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[19]=N,e[20]=h,e[21]=i,e[22]=f,e[23]=L):L=e[23];let F;e[24]!==w||e[25]!==r||e[26]!==S||e[27]!==O||e[28]!==U||e[29]!==L||e[30]!==I||e[31]!==M?(F=s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...S,onClick:I,"aria-label":M,"aria-pressed":r,className:O,children:[U,L]})}),e[24]=w,e[25]=r,e[26]=S,e[27]=O,e[28]=U,e[29]=L,e[30]=I,e[31]=M,e[32]=F):F=e[32];let R;e[33]!==o?(R=s.jsx("span",{children:o}),e[33]=o,e[34]=R):R=e[34];let j;e[35]!==l?(j=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[35]=l,e[36]=j):j=e[36];let A;e[37]!==d?(A=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[37]=d,e[38]=A):A=e[38];let B;e[39]!==R||e[40]!==j||e[41]!==A?(B=s.jsx(Pt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[R,j,A]})}),e[39]=R,e[40]=j,e[41]=A,e[42]=B):B=e[42];let X;e[43]!==F||e[44]!==B?(X=s.jsxs(At,{delayDuration:af,children:[F,B]}),e[43]=F,e[44]=B,e[45]=X):X=e[45];let H;return e[46]!==x||e[47]!==X||e[48]!==k||e[49]!==P?(H=s.jsx("div",{ref:x,style:k,className:P,children:X}),e[46]=x,e[47]=X,e[48]=k,e[49]=P,e[50]=H):H=e[50],H},SS=()=>{const t=st.c(86),{t:e}=Nt(),n=er();let r;t[0]!==n?(r=n?or(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=we=>i?we.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Te(o),a=Te(vS),u=Te(jS),d=Te(kS),h=Te(CS),f=Te(NS),p=Te(AS),g=Te(DS),w=ba(PS),S=Ni(IS),x=Ni(TS),m=An(RS),b=An(ES),{screenWidth:y}=_n(),v=ya(i||null);let N;t[4]!==g?(N=Ai("switch_context_surface",g),t[4]=g,t[5]=N):N=t[5];const C=N,[k,D]=c.useState(!1);let P,I;t[6]!==C?(P=()=>{const we=new Set;let be=null,Ne=!1;const ie=MS,ee=()=>{rl(C,we)?!Ne&&be===null&&(be=setTimeout(()=>D(!0),xS)):(Ne=!1,be!==null&&(clearTimeout(be),be=null),D(!1))},V=W=>{if(we.add(W.key.toLowerCase()),ie(W.key)&&rl(C,we)){Ne=!0,be!==null&&(clearTimeout(be),be=null),D(!1);return}ee()},$=W=>{we.delete(W.key.toLowerCase()),ee()},ae=()=>{we.clear(),Ne=!1,be!==null&&(clearTimeout(be),be=null),D(!1)};return window.addEventListener("keydown",V,!0),window.addEventListener("keyup",$,!0),window.addEventListener("blur",ae),()=>{window.removeEventListener("keydown",V,!0),window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",ae),be!==null&&clearTimeout(be)}},I=[C],t[6]=C,t[7]=P,t[8]=I):(P=t[7],I=t[8]),c.useEffect(P,I);let M;t[9]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{distance:8}},t[9]=M):M=t[9];let _;t[10]===Symbol.for("react.memo_cache_sentinel")?(_={activationConstraint:{delay:200,tolerance:6}},t[10]=_):_=t[10];const O=Vr(On(cu,M),On(lu,_)),U=l?.tabs??bS;let L;t[11]!==l?.activeTabId||t[12]!==U?(L=U.find(we=>we.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=U,t[13]=L):L=t[13];const F=L,R=l?.isOpen?F?.mode??null:null,j=v?.files.length??0;let A;t[14]!==d||t[15]!==u||t[16]!==b||t[17]!==x||t[18]!==w||t[19]!==y||t[20]!==U?(A=oh({railOrder:u,hiddenSurfaces:d,planModeEnabled:w,isVSCode:Pn(),screenWidth:y,tabs:U,linearConnected:x,githubConnected:b}),t[14]=d,t[15]=u,t[16]=b,t[17]=x,t[18]=w,t[19]=y,t[20]=U,t[21]=A):A=t[21];const B=A;let X,H;t[22]!==R||t[23]!==p||t[24]!==i||t[25]!==S||t[26]!==x?(H=()=>{!i||!S||x||R!=="linear"||p(i)},X=[R,p,i,S,x],t[22]=R,t[23]=p,t[24]=i,t[25]=S,t[26]=x,t[27]=X,t[28]=H):(X=t[27],H=t[28]),c.useEffect(H,X);let Z,ce;t[29]!==R||t[30]!==p||t[31]!==i||t[32]!==m||t[33]!==b?(Z=()=>{!i||!m||b||R!=="pr"||p(i)},ce=[R,p,i,m,b],t[29]=R,t[30]=p,t[31]=i,t[32]=m,t[33]=b,t[34]=Z,t[35]=ce):(Z=t[34],ce=t[35]),c.useEffect(Z,ce);const[Y,se]=c.useState(!1);let oe;t[36]!==h?(oe=we=>{const{active:be,over:Ne}=we;if(!Ne||be.id===Ne.id)return;const ie=Ed(Te.getState().contextRailOrder).map(OS),ee=ie.indexOf(be.id),V=ie.indexOf(Ne.id);ee===-1||V===-1||h(du(ie,ee,V))},t[36]=h,t[37]=oe):oe=t[37];const Se=oe;if(!i)return null;let K;t[38]!==e?(K=e("contextRail.aria.rail"),t[38]=e,t[39]=K):K=t[39];let pe;t[40]!==B?(pe=B.map(FS),t[40]=B,t[41]=pe):pe=t[41];let je;if(t[42]!==R||t[43]!==j||t[44]!==i||t[45]!==f||t[46]!==k||t[47]!==B||t[48]!==e||t[49]!==a){let we;t[51]!==R||t[52]!==j||t[53]!==i||t[54]!==f||t[55]!==k||t[56]!==e||t[57]!==a?(we=(be,Ne)=>{const ie=e(be.labelKey),ee=be.id==="git"&&!a?j:0,V=ee>0?ee:null;return s.jsx(wS,{surface:be,isActive:R===be.mode,showActivityDot:!1,label:ie,description:e(be.descriptionKey),badgeCount:V,badgeAriaLabel:V!==null?e(V===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ie,count:V}):null,badgeDescription:V!==null?e(V===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:V}):null,orderNumber:Ne+1,showOrderNumber:k,onSelect:$=>f(i,$.mode)},be.id)},t[51]=R,t[52]=j,t[53]=i,t[54]=f,t[55]=k,t[56]=e,t[57]=a,t[58]=we):we=t[58],je=B.map(we),t[42]=R,t[43]=j,t[44]=i,t[45]=f,t[46]=k,t[47]=B,t[48]=e,t[49]=a,t[50]=je}else je=t[50];let ne;t[59]!==pe||t[60]!==je?(ne=s.jsx(Io,{items:pe,strategy:_i,children:je}),t[59]=pe,t[60]=je,t[61]=ne):ne=t[61];let T;t[62]!==Se||t[63]!==O||t[64]!==ne?(T=s.jsx(Ur,{sensors:O,collisionDetection:Kr,onDragEnd:Se,children:ne}),t[62]=Se,t[63]=O,t[64]=ne,t[65]=T):T=t[65];let G;t[66]!==e?(G=e("contextRail.configure.open"),t[66]=e,t[67]=G):G=t[67];let le;t[68]===Symbol.for("react.memo_cache_sentinel")?(le=()=>se(!0),t[68]=le):le=t[68];let de;t[69]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(E,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[69]=de):de=t[69];let ue;t[70]!==G?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":G,onClick:le,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:de})}),t[70]=G,t[71]=ue):ue=t[71];let Oe;t[72]!==e?(Oe=e("contextRail.configure.open"),t[72]=e,t[73]=Oe):Oe=t[73];let me;t[74]!==Oe?(me=s.jsx(Pt,{side:"left",sideOffset:8,children:Oe}),t[74]=Oe,t[75]=me):me=t[75];let Re;t[76]!==ue||t[77]!==me?(Re=s.jsxs(At,{delayDuration:af,children:[ue,me]}),t[76]=ue,t[77]=me,t[78]=Re):Re=t[78];let ye;t[79]!==Y?(ye=s.jsx(fS,{open:Y,onOpenChange:se}),t[79]=Y,t[80]=ye):ye=t[80];let q;return t[81]!==K||t[82]!==T||t[83]!==Re||t[84]!==ye?(q=s.jsxs("nav",{"aria-label":K,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[T,Re,ye]}),t[81]=K,t[82]=T,t[83]=Re,t[84]=ye,t[85]=q):q=t[85],q};function vS(t){return t.workStatusPanelVisible}function jS(t){return t.contextRailOrder}function kS(t){return t.contextRailHiddenSurfaces}function CS(t){return t.setContextRailOrder}function NS(t){return t.openContextSurface}function AS(t){return t.closeContextPanel}function DS(t){return t.shortcutOverrides}function PS(t){return t.planModeEnabled}function IS(t){return t.hasChecked}function TS(t){return t.status?.connected===!0}function RS(t){return t.hasChecked}function ES(t){return t.status?.connected===!0}function MS(t){return t.length===1&&t>="0"&&t<="9"}function OS(t){return t.id}function FS(t){return t.id}const BS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),_S=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Er(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),LS=new Set,$S=[],ta=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},WS=()=>{const t=st.c(182),{t:e}=Nt(),n=Te(zS),r=Te(VS),i=Te(US),o=Te(KS),l=Te(HS),a=Te(GS),u=Te(qS),d=Te(QS),h=Te(YS),f=Te(XS),p=Te(JS),g=Te(ZS),w=Te(ev),S=Je(tv),x=Je(sv),m=Je(nv),b=Wr(rv);let y;t[0]!==n?(y=Xe=>n?Xe.activeSessions:$S,t[0]=n,t[1]=y):y=t[1];const v=Is(y);let N;t[2]!==n?(N=Xe=>n?Xe.ids:LS,t[2]=n,t[3]=N):N=t[3];const C=Wr(N);let k;t[4]!==n?(k=Xe=>n?Xe.rankById:Od,t[4]=n,t[5]=k):k=t[5];const D=ja(k),P=ts(ov),I=Ht(iv),M=Ht(av),_=er(),O=dd(lv),{files:U,git:L}=Sn(),F=Dn(cv),{isMobile:R}=_n();let j;t[6]!==_?(j=_?ta(_):null,t[6]=_,t[7]=j):j=t[7];const A=j,[B,X]=c.useState(""),Z=va(B,200).trim();let ce;t[8]!==B?(ce=B.trim(),t[8]=B,t[9]=ce):ce=t[9];const Y=ce;let se,oe;t[10]!==n?(se=()=>{n&&X("")},oe=[n],t[10]=n,t[11]=se,t[12]=oe):(se=t[11],oe=t[12]),c.useEffect(se,oe);let Se,K;t[13]!==v||t[14]!==F||t[15]!==L||t[16]!==n?(Se=()=>{if(!n||!L)return;const Xe=setTimeout(()=>{const nt=new Set;for(const St of v){const yt=Ts(St);!yt||nt.has(yt)||(nt.add(yt),F(yt,L))}},0);return()=>clearTimeout(Xe)},K=[n,v,L,F],t[13]=v,t[14]=F,t[15]=L,t[16]=n,t[17]=Se,t[18]=K):(Se=t[17],K=t[18]),c.useEffect(Se,K);let pe;t[19]!==r?(pe=()=>r(!1),t[19]=r,t[20]=pe):pe=t[20];const je=pe;let ne;t[21]!==je?(ne=Xe=>()=>{je(),Xe()},t[21]=je,t[22]=ne):ne=t[22];const T=ne;let G;t[23]!==I?.id||t[24]!==I?.path||t[25]!==P||t[26]!==m||t[27]!==R||t[28]!==u||t[29]!==d||t[30]!==p||t[31]!==S||t[32]!==T||t[33]!==g||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==b||t[39]!==a?(G=()=>{const Xe=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(E,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:T(()=>{l(!1),S()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(E,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:T(dv)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:T(uv)},{id:"toggle-sidebar",title:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(E,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:T(()=>{if(R){const{isSessionSwitcherOpen:nt}=Te.getState();l(!nt)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(E,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:T(()=>{P&&d(P,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(E,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:T(()=>{P&&u(P)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(E,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:T(fv)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(E,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:T(mv)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(E,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:T(()=>i(!0))}];return Xe.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(E,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:T(()=>{m&&P&&b({directory:P,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:T(()=>{m&&gn(m).then(nt=>{if(nt.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(E,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:T(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(E,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:T(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(E,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:T(()=>{P&&(w("notes"),d(P,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(E,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:T(()=>{P&&(w("todos"),d(P,"notes"))})}),Xe.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(E,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:T(hv)}),Vo()&&Xe.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(E,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:T(()=>{Mn("desktop_open_draft_mini_chat_window",{directory:ta(P||I?.path||""),projectId:I?.id??null}).catch(pv)})}),Xe},t[23]=I?.id,t[24]=I?.path,t[25]=P,t[26]=m,t[27]=R,t[28]=u,t[29]=d,t[30]=p,t[31]=S,t[32]=T,t[33]=g,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=b,t[39]=a,t[40]=G):G=t[40],I?.id,I?.path;let le;t[41]!==G?(le=G(),t[41]=G,t[42]=le):le=t[42];const de=le;let ue;t[43]===Symbol.for("react.memo_cache_sentinel")?(ue=bn(),t[43]=ue):ue=t[43];const Oe=ue;let me,Re;t[44]===Symbol.for("react.memo_cache_sentinel")?(me=Pn(),Re=!Oe&&ha(),t[44]=me,t[45]=Re):(me=t[44],Re=t[45]);let ye;t[46]!==R?(ye={isVSCode:me,isWeb:Re,isDesktop:Oe,isMobile:R},t[46]=R,t[47]=ye):ye=t[47];const q=ye;let we;if(t[48]!==T||t[49]!==i||t[50]!==o||t[51]!==q){let Xe;t[53]!==q?(Xe=St=>St.isAvailable?St.isAvailable(q):!0,t[53]=q,t[54]=Xe):Xe=t[54];let nt;t[55]!==T||t[56]!==i||t[57]!==o?(nt=St=>{const yt=hg(St.slug)??"settings-3",It=(St.keywords??[]).join(" ");return{id:`settings:${St.slug}`,title:St.title,icon:St.slug==="mcp"?s.jsx(dh,{className:"mr-2 h-4 w-4"}):s.jsx(E,{name:yt,className:"mr-2 h-4 w-4"}),searchText:`${St.title} ${St.group} ${It}`,onSelect:T(()=>{o(St.slug),i(!0)})}},t[55]=T,t[56]=i,t[57]=o,t[58]=nt):nt=t[58],we=mg.filter(gv).filter(Xe).map(nt),t[48]=T,t[49]=i,t[50]=o,t[51]=q,t[52]=we}else we=t[52];const be=we;let Ne;if(t[59]!==v||t[60]!==C||t[61]!==D){const Xe=v.filter(xv);Ne=ih(Xe,C,D),t[59]=v,t[60]=C,t[61]=D,t[62]=Ne}else Ne=t[62];const ie=Ne,ee=Md(),V=Je(bv);let $;t[63]!==ee||t[64]!==V?($=(Xe,nt)=>{const St=V.get(Xe);return St?.branch?St.branch.trim()||null:nt&&ee.get(nt)?.trim()||null},t[63]=ee,t[64]=V,t[65]=$):$=t[65];const ae=$;let W;t[66]===Symbol.for("react.memo_cache_sentinel")?(W=[],t[66]=W):W=t[66];const[ve,Fe]=c.useState(W),[Ce,ke]=c.useState(""),Qe=BS(A,Z);let We;t[67]!==A||t[68]!==Qe||t[69]!==n||t[70]!==O||t[71]!==Fe||t[72]!==ke||t[73]!==Z?(We=()=>{if(!n){Fe([]),ke("");return}if(!Qe){Fe([]),ke("");return}if(!A){Fe([]),ke("");return}let Xe=!1;return O(A,Z,40,{type:"file"}).then(nt=>{Xe||(Fe(nt.map(yv)),ke(Qe))}).catch(()=>{Xe||(Fe([]),ke(Qe))}),()=>{Xe=!0}},t[67]=A,t[68]=Qe,t[69]=n,t[70]=O,t[71]=Fe,t[72]=ke,t[73]=Z,t[74]=We):We=t[74];let z;t[75]!==A||t[76]!==Qe||t[77]!==n||t[78]!==O||t[79]!==Z?(z=[n,A,Z,Qe,O],t[75]=A,t[76]=Qe,t[77]=n,t[78]=O,t[79]=Z,t[80]=z):z=t[80],c.useEffect(We,z);const he=Y.length>0;let Be;e:{if(!he){let nt;t[81]!==de?(nt=de.filter(wv).map(Sv),t[81]=de,t[82]=nt):nt=t[82],Be=nt;break e}let Xe;t[83]!==de||t[84]!==Y?(Xe=Er(de,Y,vv,{limit:7,noFuzzy:!0}),t[83]=de,t[84]=Y,t[85]=Xe):Xe=t[85],Be=Xe}const Ae=Be;let at;e:{if(!he){let nt;t[86]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[86]=nt):nt=t[86],at=nt;break e}let Xe;t[87]!==Y||t[88]!==be?(Xe=Er(be,Y,jv,{limit:7,noFuzzy:!0}),t[87]=Y,t[88]=be,t[89]=Xe):Xe=t[89],at=Xe}const Ue=at;let ht;e:{if(!he){let nt;t[90]!==ie?(nt=ie.slice(0,5).map(kv),t[90]=ie,t[91]=nt):nt=t[91],ht=nt;break e}let Xe;t[92]!==Y||t[93]!==ie?(Xe=Er(ie,Y,Cv,{limit:7,threshold:.2}),t[92]=Y,t[93]=ie,t[94]=Xe):Xe=t[94],ht=Xe}const ut=ht;let Ct;e:{if(!n){let nt;t[95]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[95]=nt):nt=t[95],Ct=nt;break e}let Xe;t[96]!==ve||t[97]!==Ce||t[98]!==Qe||t[99]!==Z?(Xe=_S(ve,Z,Qe,Ce),t[96]=ve,t[97]=Ce,t[98]=Qe,t[99]=Z,t[100]=Xe):Xe=t[100],Ct=Xe}const ge=Ct,Ye=n&&Qe.length>0&&Ce!==Qe;let bt;e:{if(!he){let nt;t[101]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[101]=nt):nt=t[101],bt=nt;break e}let Xe;if(t[102]!==Y||t[103]!==M){const nt=M.map(Nv);Xe=Er(nt,Y,Av,{limit:7,threshold:.4}),t[102]=Y,t[103]=M,t[104]=Xe}else Xe=t[104];bt=Xe}const jt=bt;let fe,ze,it,$e,J,re,Pe,_e,Ve,Ze,lt,rt,Ge,ot;if(t[105]!==ae||t[106]!==je||t[107]!==A||t[108]!==U||t[109]!==he||t[110]!==n||t[111]!==h||t[112]!==S||t[113]!==B||t[114]!==Ae||t[115]!==ge||t[116]!==jt||t[117]!==ut||t[118]!==Ue||t[119]!==r||t[120]!==x||t[121]!==f||t[122]!==e){const Xe=Ae.map(Dv),nt=Ue.map(Pv),St=ut.map(Iv),yt=he?ge.map(Tv):[],It=he?jt.map(Rv):[];let kt;e:{if(!he){kt=["commands","sessions"];break e}const ft=Ev,ct=[{key:"commands",score:ft(Ae)},{key:"settings",score:ft(Ue)},{key:"sessions",score:ft(ut)},{key:"files",score:ft(ge)},{key:"projects",score:ft(jt)}];ct.sort(Mv),kt=ct.map(Ov)}const Et=kt,Bt=ft=>{je(),x(ft.id,Ts(ft))},zt=async ft=>{if(!A)return;const ct=await _u(U,ft,{directory:A});if(!ct.ok){Le.error(Lu(ct.reason));return}h(A,ft),je()},Gt=(ft,ct)=>{je(),S({selectedProjectId:ft,directoryOverride:ct})},rs=ft=>qn(qr(ft,f));$e=vs,rt=n,Ge=r;let _t;t[137]!==e?(_t=e("commandPalette.title"),t[137]=e,t[138]=_t):_t=t[138];let Wt;t[139]!==_t?(Wt=s.jsx(Rs,{children:_t}),t[139]=_t,t[140]=Wt):Wt=t[140];let Me;t[141]!==e?(Me=e("commandPalette.description"),t[141]=e,t[142]=Me):Me=t[142];let qe;t[143]!==Me?(qe=s.jsx(Es,{children:Me}),t[143]=Me,t[144]=qe):qe=t[144],t[145]!==Wt||t[146]!==qe?(ot=s.jsxs($s,{className:"sr-only",children:[Wt,qe]}),t[145]=Wt,t[146]=qe,t[147]=ot):ot=t[147],it=js,Ze="overflow-hidden p-0",lt=!0,ze=uh,Pe=!1,_e="[&_[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 dt;t[148]!==e?(dt=e("commandPalette.input.placeholder"),t[148]=e,t[149]=dt):dt=t[149],t[150]!==B||t[151]!==dt?(Ve=s.jsx(fh,{value:B,onValueChange:X,placeholder:dt}),t[150]=B,t[151]=dt,t[152]=Ve):Ve=t[152],fe=mh;let wt;t[153]!==e?(wt=e("commandPalette.empty.noResults"),t[153]=e,t[154]=wt):wt=t[154],t[155]!==wt?(J=s.jsx(hh,{children:wt}),t[155]=wt,t[156]=J):J=t[156],re=Et.map(ft=>ft==="commands"&&Xe.length>0?s.jsx(jr,{children:Xe.map(ct=>s.jsxs(Mr,{value:ct.id,onSelect:ct.onSelect,children:[ct.icon,s.jsx("span",{children:ct.title}),ct.shortcutId?s.jsx(ah,{children:rs(ct.shortcutId)}):null]},ct.id))},"commands"):ft==="settings"&&nt.length>0?s.jsx(jr,{children:nt.map(Fv)},"settings"):ft==="sessions"&&St.length>0?s.jsx(jr,{children:St.map(ct=>{const Vt=ct.title||e("commandPalette.session.untitled"),Xt=Ts(ct),Jt=ae(ct.id,Xt);return s.jsxs(Mr,{value:`session:${ct.id}`,onSelect:()=>Bt(ct),children:[s.jsx(E,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Vt}),Jt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:Jt})]}):null]},ct.id)})},"sessions"):ft==="files"&&yt.length>0?s.jsx(jr,{children:yt.map(ct=>{const Vt=lh(ct.relativePath||ct.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${ct.path}`,onSelect:()=>{zt(ct.path)},children:[s.jsx(Sa,{filePath:ct.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":ct.relativePath,children:Vt})]},`file:${ct.path}`)})},"files"):ft==="projects"&&It.length>0?s.jsx(jr,{children:It.map(ct=>{const Vt=ct.displayName;return s.jsxs(Mr,{value:`project:${ct.id}`,onSelect:()=>Gt(ct.id,ct.path),children:[s.jsx(E,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Vt}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:ct.path})]},`project:${ct.id}`)})},"projects"):null),t[105]=ae,t[106]=je,t[107]=A,t[108]=U,t[109]=he,t[110]=n,t[111]=h,t[112]=S,t[113]=B,t[114]=Ae,t[115]=ge,t[116]=jt,t[117]=ut,t[118]=Ue,t[119]=r,t[120]=x,t[121]=f,t[122]=e,t[123]=fe,t[124]=ze,t[125]=it,t[126]=$e,t[127]=J,t[128]=re,t[129]=Pe,t[130]=_e,t[131]=Ve,t[132]=Ze,t[133]=lt,t[134]=rt,t[135]=Ge,t[136]=ot}else fe=t[123],ze=t[124],it=t[125],$e=t[126],J=t[127],re=t[128],Pe=t[129],_e=t[130],Ve=t[131],Ze=t[132],lt=t[133],rt=t[134],Ge=t[135],ot=t[136];let Ee;t[157]!==Ye||t[158]!==e?(Ee=Ye?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=Ye,t[158]=e,t[159]=Ee):Ee=t[159];let Rt;t[160]!==fe||t[161]!==J||t[162]!==re||t[163]!==Ee?(Rt=s.jsxs(fe,{children:[J,re,Ee]}),t[160]=fe,t[161]=J,t[162]=re,t[163]=Ee,t[164]=Rt):Rt=t[164];let xe;t[165]!==ze||t[166]!==Pe||t[167]!==_e||t[168]!==Ve||t[169]!==Rt?(xe=s.jsxs(ze,{shouldFilter:Pe,className:_e,children:[Ve,Rt]}),t[165]=ze,t[166]=Pe,t[167]=_e,t[168]=Ve,t[169]=Rt,t[170]=xe):xe=t[170];let mt;t[171]!==it||t[172]!==Ze||t[173]!==lt||t[174]!==xe?(mt=s.jsx(it,{className:Ze,showCloseButton:lt,children:xe}),t[171]=it,t[172]=Ze,t[173]=lt,t[174]=xe,t[175]=mt):mt=t[175];let Tt;return t[176]!==$e||t[177]!==rt||t[178]!==Ge||t[179]!==ot||t[180]!==mt?(Tt=s.jsxs($e,{open:rt,onOpenChange:Ge,children:[ot,mt]}),t[176]=$e,t[177]=rt,t[178]=Ge,t[179]=ot,t[180]=mt,t[181]=Tt):Tt=t[181],Tt};function zS(t){return t.isCommandPaletteOpen}function VS(t){return t.setCommandPaletteOpen}function US(t){return t.setSettingsDialogOpen}function KS(t){return t.setSettingsPage}function HS(t){return t.setSessionSwitcherOpen}function GS(t){return t.toggleSidebar}function qS(t){return t.openContextOverview}function QS(t){return t.openContextSurface}function YS(t){return t.openContextFile}function XS(t){return t.shortcutOverrides}function JS(t){return t.openMultiRunLauncher}function ZS(t){return t.setArchivePageOpen}function ev(t){return t.setProjectContextTab}function tv(t){return t.openNewSessionDraft}function sv(t){return t.setCurrentSession}function nv(t){return t.currentSessionId}function rv(t){return t.toggle}function ov(t){return t.currentDirectory}function iv(t){return t.getActiveProject()}function av(t){return t.projects}function lv(t){return t.searchFiles}function cv(t){return t.ensureStatus}function dv(){Fd()}function uv(){xn.requestDirectoryDialog()}function fv(){ph.invoke("cycle_theme")}function mv(){Bd()}function hv(){window.dispatchEvent(new CustomEvent("aiworker:memory-debug-toggle"))}function pv(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function gv(t){return t.slug!=="home"}function xv(t){return!ch(t)}function bv(t){return t.worktreeMetadata}function yv(t){return{path:ta(t.path),name:t.name,relativePath:t.relativePath}}function wv(t){return!t.secondary}function Sv(t){return{item:t,score:0}}function vv(t){return t.searchText}function jv(t){return t.searchText}function kv(t){return{item:t,score:0}}function Cv(t){return t.title||""}function Nv(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Av(t){return t.searchText}function Dv(t){return t.item}function Pv(t){return t.item}function Iv(t){return t.item}function Tv(t){return t.item}function Rv(t){return t.item}function Ev(t){return t.length?t[0].score:1/0}function Mv(t,e){return t.score-e.score}function Ov(t){return t.key}function Fv(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const dc=(t,e,n)=>qn(qr(t,e),n),Bv=()=>{const t=st.c(74),{t:e}=Nt(),n=Te(_v),r=Te(Lv),i=Te($v);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Pn(),t[0]=o):o=t[0];const l=o;let a,u,d,h,f,p,g,w,S,x,m,b;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const j=[{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:[qn("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:[`${qn(Ai("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${qn(Ai("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:""}]}];d=vs,m=n,b=r,u=js,S="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let A;t[17]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(E,{name:"command",className:"h-5 w-5"}),t[17]=A):A=t[17];let B;t[18]!==e?(B=e("helpDialog.title"),t[18]=e,t[19]=B):B=t[19];let X;t[20]!==B?(X=s.jsxs(Rs,{className:"flex items-center gap-2",children:[A,B]}),t[20]=B,t[21]=X):X=t[21];let H;t[22]!==e?(H=e("helpDialog.description"),t[22]=e,t[23]=H):H=t[23];let Z;t[24]!==H?(Z=s.jsx(Es,{children:H}),t[24]=H,t[25]=Z):Z=t[25],t[26]!==X||t[27]!==Z?(x=s.jsxs($s,{children:[X,Z]}),t[26]=X,t[27]=Z,t[28]=x):x=t[28],a=cn,p="flex-1 min-h-0 mt-3",g="pr-1",w=!0,h="space-y-4",f=j.map(ce=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ce.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ce.items.filter(Y=>!(l&&Y.id==="toggle_prompt_navigator")).map(Y=>{const se=Y.id?gh(Y.id):void 0,oe=Y.descriptionKey??(se?.customizable?se.settingsLabelKey:void 0);if(!oe||Y.id&&!qr(Y.id,i))return null;const Se=Y.id?dc(Y.id,i,e("settings.aiworker.keyboardShortcuts.unassigned")):Array.isArray(Y.keys)?Y.keys:Y.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:[Y.icon&&s.jsx(E,{name:Y.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(oe)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Se)?Se:[Se]).map((K,pe)=>s.jsxs(c.Fragment,{children:[pe>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:K})]},`${K}-${pe}`))})]},Y.id||oe)})})]},ce.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=u,t[7]=d,t[8]=h,t[9]=f,t[10]=p,t[11]=g,t[12]=w,t[13]=S,t[14]=x,t[15]=m,t[16]=b}else a=t[5],u=t[6],d=t[7],h=t[8],f=t[9],p=t[10],g=t[11],w=t[12],S=t[13],x=t[14],m=t[15],b=t[16];let y;t[29]!==h||t[30]!==f?(y=s.jsx("div",{className:h,children:f}),t[29]=h,t[30]=f,t[31]=y):y=t[31];let v;t[32]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(E,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=v):v=t[32];let N;t[33]!==e?(N=e("helpDialog.proTips.title"),t[33]=e,t[34]=N):N=t[34];let C;t[35]!==N?(C=s.jsx("p",{className:"font-medium mb-1",children:N}),t[35]=N,t[36]=C):C=t[36];let k;t[37]!==i||t[38]!==e?(k=e("helpDialog.proTips.commandPalette",{shortcut:dc("open_command_palette",i,e("settings.aiworker.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=k):k=t[39];let D;t[40]!==k?(D=s.jsxs("li",{children:["• ",k]}),t[40]=k,t[41]=D):D=t[41];let P;t[42]!==e?(P=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=P):P=t[43];let I;t[44]!==P?(I=s.jsxs("li",{children:["• ",P]}),t[44]=P,t[45]=I):I=t[45];let M;t[46]!==e?(M=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=M):M=t[47];let _;t[48]!==M?(_=s.jsxs("li",{children:["• ",M]}),t[48]=M,t[49]=_):_=t[49];let O;t[50]!==D||t[51]!==I||t[52]!==_?(O=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[D,I,_]}),t[50]=D,t[51]=I,t[52]=_,t[53]=O):O=t[53];let U;t[54]!==C||t[55]!==O?(U=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[v,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,O]})]})}),t[54]=C,t[55]=O,t[56]=U):U=t[56];let L;t[57]!==a||t[58]!==y||t[59]!==U||t[60]!==p||t[61]!==g||t[62]!==w?(L=s.jsxs(a,{outerClassName:p,className:g,disableHorizontal:w,children:[y,U]}),t[57]=a,t[58]=y,t[59]=U,t[60]=p,t[61]=g,t[62]=w,t[63]=L):L=t[63];let F;t[64]!==u||t[65]!==L||t[66]!==S||t[67]!==x?(F=s.jsxs(u,{className:S,children:[x,L]}),t[64]=u,t[65]=L,t[66]=S,t[67]=x,t[68]=F):F=t[68];let R;return t[69]!==d||t[70]!==F||t[71]!==m||t[72]!==b?(R=s.jsx(d,{open:m,onOpenChange:b,children:F}),t[69]=d,t[70]=F,t[71]=m,t[72]=b,t[73]=R):R=t[73],R};function _v(t){return t.isHelpDialogOpen}function Lv(t){return t.setHelpDialogOpen}function $v(t){return t.shortcutOverrides}const Wv=()=>{const t=st.c(32),{t:e}=Nt(),n=Te(zv),r=Te(Vv),i=Te(Uv);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await gn(i)).ok){Le.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Le.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 u;t[5]!==a?(u=s.jsx(Rs,{children:a}),t[5]=a,t[6]=u):u=t[6];let d;t[7]!==e?(d=e("openCodeStatusDialog.description"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==d?(h=s.jsx(Es,{children:d}),t[9]=d,t[10]=h):h=t[10];let f;t[11]!==u||t[12]!==h?(f=s.jsxs($s,{children:[u,h]}),t[11]=u,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 g;t[16]!==l||t[17]!==p?(g=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-primary",children:p})}),t[16]=l,t[17]=p,t[18]=g):g=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let S;t[22]!==w?(S=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=S):S=t[23];let x;t[24]!==f||t[25]!==g||t[26]!==S?(x=s.jsxs(js,{className:"max-w-2xl",children:[f,g,S]}),t[24]=f,t[25]=g,t[26]=S,t[27]=x):x=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==x?(m=s.jsx(vs,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=m):m=t[31],m};function zv(t){return t.isOpenCodeStatusDialogOpen}function Vv(t){return t.setOpenCodeStatusDialogOpen}function Uv(t){return t.openCodeStatusText}const Kv=t=>{const e=st.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let u,d;e[0]!==a||e[1]!==r||e[2]!==o?(u=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},d=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=u,e[4]=d):(u=e[3],d=e[4]),c.useEffect(u,d);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("aiworker:sidebar-session-search",w),()=>window.removeEventListener("aiworker:sidebar-session-search",w)},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,g;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const w=S=>{l.current&&(l.current.contains(S.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},g=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=g):(p=e[14],g=e[15]),c.useEffect(p,g)},Hv=t=>{const e=st.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const u=new Map(l.map(Gv)),d=[];a.forEach(p=>{const g=u.get(p);g&&(d.push(g),u.delete(p))});const h=[],f=[];return l.forEach(p=>{u.has(p.id)&&(p.isArchivedBucket?f.push(p):h.push(p))}),[...h,...d,...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 Gv(t){return[t.id,t]}const ao="oc.sessions.projectCollapse",uc="oc.sessions.groupOrder",fc="oc.sessions.groupCollapse",mc=t=>{if(!t)return new Set;try{const e=Ea(br()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},qv=t=>{if(!t)return new Map;try{const e=xu(br(),Ea(br())).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}},Qv=t=>{const e=st.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=No(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>mc(o.getItem(ao)),e[1]=l):l=e[1];const[a,u]=c.useState(l);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>mc(o.getItem(fc)),e[2]=d):d=e[2];const[h,f]=c.useState(d);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>qv(o.getItem(uc)),e[3]=p):p=e[3];const[g,w]=c.useState(p),S=c.useRef(0),x=c.useRef(!1),m=c.useRef(!1),b=c.useRef(null),y=c.useRef(null);let v;e[4]!==n?(v=()=>{if(n)return;const pe=y.current;if(y.current=null,b.current=null,!pe)return;const{projects:je}=Ht.getState(),ne=je.map(T=>({...T,sidebarCollapsed:pe.has(T.id)}));Rr({projects:ne}).catch(Yv)},e[4]=n,e[5]=v):v=e[5];const N=v;let C;e[6]!==N||e[7]!==n?(C=pe=>{!globalThis.window||n||(y.current=pe,b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const k=C;let D,P;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&b.current!==null&&window.clearTimeout(b.current),b.current=null,y.current=null},P=[],e[9]=D,e[10]=P):(D=e[9],P=e[10]),c.useEffect(D,P);let I,M;e[11]!==g?(M=()=>{if(m.current)try{o.setItem(uc,JSON.stringify(Object.fromEntries(g.entries())))}catch{}},I=[g,o],e[11]=g,e[12]=I,e[13]=M):(I=e[12],M=e[13]),c.useEffect(M,I);let _,O;e[14]!==h?(_=()=>{if(x.current)try{o.setItem(fc,JSON.stringify(Array.from(h)))}catch{}},O=[h,o],e[14]=h,e[15]=_,e[16]=O):(_=e[15],O=e[16]),c.useEffect(_,O);let U;e[17]!==r||e[18]!==k?(U=()=>{S.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const pe=new Set(r.map(Xv));try{o.setItem(ao,JSON.stringify(Array.from(pe)))}catch{}return k(pe),pe})},e[17]=r,e[18]=k,e[19]=U):U=e[19];const L=U;let F;e[20]!==k?(F=()=>{S.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const pe=new Set;try{o.setItem(ao,JSON.stringify([]))}catch{}return k(pe),pe})},e[20]=k,e[21]=F):F=e[21];const R=F;let j;e[22]!==k?(j=pe=>{S.current=Date.now()+150,u(je=>{const ne=new Set(je);ne.has(pe)?ne.delete(pe):ne.add(pe);try{o.setItem(ao,JSON.stringify(Array.from(ne)))}catch{}return k(ne),ne})},e[22]=k,e[23]=j):j=e[23];const A=j;let B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=pe=>{x.current=!0,f(je=>{const ne=new Set(je);return ne.has(pe)?ne.delete(pe):ne.add(pe),ne})},e[24]=B):B=e[24];const X=B;let H;e[25]===Symbol.for("react.memo_cache_sentinel")?(H=pe=>{m.current=!0,w(pe)},e[25]=H):H=e[25];const Z=H,{getOrderedGroups:ce}=Hv(g);let Y;e[26]!==h||e[27]!==a||e[28]!==g?(Y={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:g},e[26]=h,e[27]=a,e[28]=g,e[29]=Y):Y=e[29];const se=Y;let oe;e[30]!==L||e[31]!==R||e[32]!==ce||e[33]!==k||e[34]!==A?(oe={setCollapsedProjects:u,toggleProject:A,collapseAllProjects:L,expandAllProjects:R,scheduleCollapsedProjectsPersist:k,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:Z,getOrderedGroups:ce},e[30]=L,e[31]=R,e[32]=ce,e[33]=k,e[34]=A,e[35]=oe):oe=e[35];const Se=oe;let K;return e[36]!==Se||e[37]!==se?(K={state:se,actions:Se},e[36]=Se,e[37]=se,e[38]=K):K=e[38],K};function Yv(){}function Xv(t){return t.id}const Jv=5*6e4,Zv=t=>{const e=st.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=Sn(),d=Dn(e0);let h,f;e[0]!==a||e[1]!==d||e[2]!==u||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!u||n.length===0){o(new Map);return}n.forEach(C=>{Di(()=>d(C.normalizedPath,u))})},f=[a,n,u,d,o],e[0]=a,e[1]=d,e[2]=u,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let p,g;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(k=>{C.set(k.id,i.get(k.normalizedPath)?.isGitRepo??null)}),o(C)},g=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=g):(p=e[11],g=e[12]),c.useEffect(p,g);let w;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=k=>{const D=i.get(k.normalizedPath)?.branch??"";return`${k.id}:${D}`},e[16]=i,e[17]=C):C=e[17],w=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const S=w;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const m=c.useRef(x);let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=new Map,e[19]=b):b=e[19];const y=c.useRef(b);let v;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(v=()=>{if(!a)return;let C=!1;const k=setTimeout(()=>{(async()=>{const P=new Set(n.map(t0));for(const L of m.current.keys())P.has(L)||(m.current.delete(L),y.current.delete(L));const I=Date.now(),M=n.filter(L=>{const F=i.get(L.normalizedPath);if(F?.isGitRepo===!1)return m.current.delete(L.id),y.current.delete(L.id),!1;if(F?.isGitRepo!==!0||F.branch===null)return!1;const R=F.branch.trim(),j=`${L.normalizedPath}\0${R}`,A=m.current.get(L.id);if(A===j){const B=y.current.get(L.id);return B&&(B.at=I),!1}return!(A!==void 0&&I-(y.current.get(L.id)?.at??0)<Jv)});if(M.length===0)return;const _=await xh(M,2,async L=>{const F=i.get(L.normalizedPath)?.branch?.trim()??"",R=`${L.normalizedPath}\0${F}`,j=await Di(()=>qo(L.normalizedPath,F?{knownBranch:F}:void 0)).catch(s0);return{id:L.id,inputKey:R,branch:j}});if(C)return;const O=_.filter(n0);if(O.length===0)return;const U=Date.now();l(L=>{const F=new Map(L);return O.forEach(R=>{const{id:j,branch:A}=R;A&&F.set(j,A)}),F}),O.forEach(L=>{const{id:F,inputKey:R,branch:j}=L;m.current.set(F,R),j&&y.current.set(F,{branch:j,at:U})})})()},150);return()=>{C=!0,clearTimeout(k)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=v):v=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==S||e[29]!==l?(N=[a,n,S,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=S,e[29]=l,e[30]=N):N=e[30],c.useEffect(v,N)};function e0(t){return t.ensureStatus}function t0(t){return t.id}function s0(){return null}function n0(t){return t.branch}const r0=t=>{const e=st.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(pg,{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(js,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(cn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-background",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 u;return e[6]!==r||e[7]!==n||e[8]!==a?(u=s.jsx(vs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=u):u=e[9],u},o0=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const i of t){r.has(i)||(r.add(i),n.push(i));const o=e.get(i);if(o)for(const l of o)r.has(l)||(r.add(l),n.push(l))}return n},xs=tr()((t,e)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{e().enabled||t({enabled:!0})},disable:()=>{t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{e().enabled?t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):t({enabled:!0})},toggleSelected:(n,r,i)=>{const o=e(),l=new Set(o.selectedIds);let a=o.scopeKey,u=o.anchorId;r!==null&&o.scopeKey!==null&&r!==o.scopeKey?(l.clear(),a=r,u=null):a===null&&r!==null&&(a=r);const h=i&&i.length>0?[n,...i]:[n];if(l.has(n)){for(const p of h)l.delete(p);u===n&&(u=null)}else{for(const p of h)l.add(p);u=n}l.size===0?t({selectedIds:l,scopeKey:null,anchorId:null}):t({selectedIds:l,scopeKey:a,anchorId:u})},setRange:(n,r,i,o,l)=>{const a=e();if(i.length===0)return;const u=n&&i.includes(n)?n:i[0],d=i.indexOf(u),h=i.indexOf(r);if(d<0||h<0)return;const[f,p]=d<=h?[d,h]:[h,d],g=i.slice(f,p+1),w=o0(g,l),x=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of w)x.add(m);t({selectedIds:x,scopeKey:o??a.scopeKey,anchorId:u})},replaceAll:(n,r)=>{if(n.length===0){t({selectedIds:new Set,scopeKey:null,anchorId:null});return}t({selectedIds:new Set(n),scopeKey:r,anchorId:n[0]??null})},clear:()=>{t({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{const r=e();if(r.selectedIds.size===0||n.length===0)return;const i=new Set(r.selectedIds);for(const o of n)i.delete(o);i.size!==r.selectedIds.size&&(i.size===0?t({selectedIds:i,scopeKey:null,anchorId:null}):t({selectedIds:i}))}}));function i0(t){const e=st.c(213),{t:n}=Nt(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:u,canOpenMultiRun:d,onOpenArchive:h,headerActionIconClass:f,headerActionButtonClass:p,isSessionSearchOpen:g,setIsSessionSearchOpen:w,sessionSearchInputRef:S,sessionSearchQuery:x,setSessionSearchQuery:m,hasSessionSearchQuery:b,searchMatchCount:y,collapseAllProjects:v,expandAllProjects:N}=t,C=xs(y0),k=xs(b0),D=ls(x0),P=ls(g0),I=ls(p0),M=ls(h0),_=ls(m0),O=ls(f0),U=ls(u0),L=ls(d0),F=ls(c0),R=ls(l0),j=i&&F==="single";if(r)return null;let A;e[0]!==p?(A=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=p,e[1]=A):A=e[1];let B;e[2]!==n?(B=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=B):B=e[3];let X;e[4]!==f?(X=s.jsx(E,{name:"folder-add",className:f}),e[4]=f,e[5]=X):X=e[5];let H;e[6]!==l||e[7]!==A||e[8]!==B||e[9]!==X?(H=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,className:A,"aria-label":B,children:X})}),e[6]=l,e[7]=A,e[8]=B,e[9]=X,e[10]=H):H=e[10];let Z;e[11]!==n?(Z=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=Z):Z=e[12];let ce;e[13]!==Z?(ce=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Z})}),e[13]=Z,e[14]=ce):ce=e[14];let Y;e[15]!==H||e[16]!==ce?(Y=s.jsxs(At,{children:[H,ce]}),e[15]=H,e[16]=ce,e[17]=Y):Y=e[17];let se;e[18]!==p?(se=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=p,e[19]=se):se=e[19];let oe;e[20]!==n?(oe=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=oe):oe=e[21];let Se;e[22]!==f?(Se=s.jsx(E,{name:"calendar-schedule",className:f}),e[22]=f,e[23]=Se):Se=e[23];let K;e[24]!==a||e[25]!==se||e[26]!==oe||e[27]!==Se?(K=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:se,"aria-label":oe,children:Se})}),e[24]=a,e[25]=se,e[26]=oe,e[27]=Se,e[28]=K):K=e[28];let pe;e[29]!==n?(pe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=pe):pe=e[30];let je;e[31]!==pe?(je=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:pe})}),e[31]=pe,e[32]=je):je=e[32];let ne;e[33]!==K||e[34]!==je?(ne=s.jsxs(At,{children:[K,je]}),e[33]=K,e[34]=je,e[35]=ne):ne=e[35];let T;e[36]!==p?(T=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=p,e[37]=T):T=e[37];let G;e[38]!==n?(G=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=G):G=e[39];const le=!d;let de;e[40]!==f?(de=s.jsx(bh,{className:f}),e[40]=f,e[41]=de):de=e[41];let ue;e[42]!==u||e[43]!==T||e[44]!==G||e[45]!==le||e[46]!==de?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:T,"aria-label":G,disabled:le,children:de})}),e[42]=u,e[43]=T,e[44]=G,e[45]=le,e[46]=de,e[47]=ue):ue=e[47];let Oe;e[48]!==n?(Oe=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Oe):Oe=e[49];let me;e[50]!==Oe?(me=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[50]=Oe,e[51]=me):me=e[51];let Re;e[52]!==ue||e[53]!==me?(Re=s.jsxs(At,{children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=Re):Re=e[54];let ye;e[55]!==p?(ye=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=p,e[56]=ye):ye=e[56];let q;e[57]!==n?(q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=q):q=e[58];let we;e[59]!==f?(we=s.jsx(E,{name:"archive",className:f}),e[59]=f,e[60]=we):we=e[60];let be;e[61]!==h||e[62]!==ye||e[63]!==q||e[64]!==we?(be=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:ye,"aria-label":q,children:we})}),e[61]=h,e[62]=ye,e[63]=q,e[64]=we,e[65]=be):be=e[65];let Ne;e[66]!==n?(Ne=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=Ne):Ne=e[67];let ie;e[68]!==Ne?(ie=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ne})}),e[68]=Ne,e[69]=ie):ie=e[69];let ee;e[70]!==be||e[71]!==ie?(ee=s.jsxs(At,{children:[be,ie]}),e[70]=be,e[71]=ie,e[72]=ee):ee=e[72];let V;e[73]!==ne||e[74]!==Re||e[75]!==ee||e[76]!==Y?(V=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[Y,ne,Re,ee]}),e[73]=ne,e[74]=Re,e[75]=ee,e[76]=Y,e[77]=V):V=e[77];let $;e[78]!==w?($=()=>w(a0),e[78]=w,e[79]=$):$=e[79];let ae;e[80]!==p?(ae=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=p,e[81]=ae):ae=e[81];let W;e[82]!==n?(W=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=W):W=e[83];let ve;e[84]!==f?(ve=s.jsx(E,{name:"search",className:f}),e[84]=f,e[85]=ve):ve=e[85];let Fe;e[86]!==g||e[87]!==$||e[88]!==ae||e[89]!==W||e[90]!==ve?(Fe=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,className:ae,"aria-label":W,"aria-expanded":g,children:ve})}),e[86]=g,e[87]=$,e[88]=ae,e[89]=W,e[90]=ve,e[91]=Fe):Fe=e[91];let Ce;e[92]!==n?(Ce=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=Ce):Ce=e[93];let ke;e[94]!==Ce?(ke=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ce})}),e[94]=Ce,e[95]=ke):ke=e[95];let Qe;e[96]!==Fe||e[97]!==ke?(Qe=s.jsxs(At,{children:[Fe,ke]}),e[96]=Fe,e[97]=ke,e[98]=Qe):Qe=e[98];const We=C&&"bg-interactive-hover text-primary";let z;e[99]!==p||e[100]!==We?(z=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",We),e[99]=p,e[100]=We,e[101]=z):z=e[101];let he;e[102]!==C||e[103]!==n?(he=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=he):he=e[104];let Be;e[105]!==f?(Be=s.jsx(E,{name:"checkbox-multiple",className:f}),e[105]=f,e[106]=Be):Be=e[106];let Ae;e[107]!==C||e[108]!==z||e[109]!==he||e[110]!==Be||e[111]!==k?(Ae=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:z,"aria-label":he,"aria-pressed":C,children:Be})}),e[107]=C,e[108]=z,e[109]=he,e[110]=Be,e[111]=k,e[112]=Ae):Ae=e[112];let at;e[113]!==C||e[114]!==n?(at=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=at):at=e[115];let Ue;e[116]!==at?(Ue=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:at})}),e[116]=at,e[117]=Ue):Ue=e[117];let ht;e[118]!==Ae||e[119]!==Ue?(ht=s.jsxs(At,{children:[Ae,Ue]}),e[118]=Ae,e[119]=Ue,e[120]=ht):ht=e[120];let ut;e[121]!==p?(ut=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=p,e[122]=ut):ut=e[122];let Ct;e[123]!==n?(Ct=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=Ct):Ct=e[124];let ge;e[125]!==f?(ge=s.jsx(E,{name:"equalizer-2",className:f}),e[125]=f,e[126]=ge):ge=e[126];let Ye;e[127]!==ut||e[128]!==Ct||e[129]!==ge?(Ye=s.jsx(Dt,{asChild:!0,children:s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:ut,"aria-label":Ct,children:ge})})}),e[127]=ut,e[128]=Ct,e[129]=ge,e[130]=Ye):Ye=e[130];let bt;e[131]!==n?(bt=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=bt):bt=e[132];let jt;e[133]!==bt?(jt=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:bt})}),e[133]=bt,e[134]=jt):jt=e[134];let fe;e[135]!==Ye||e[136]!==jt?(fe=s.jsxs(At,{children:[Ye,jt]}),e[135]=Ye,e[136]=jt,e[137]=fe):fe=e[137];let ze;e[138]!==n?(ze=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=ze):ze=e[139];let it;e[140]!==ze?(it=s.jsx(ho,{children:ze}),e[140]=ze,e[141]=it):it=e[141];let $e;e[142]!==I||e[143]!==M||e[144]!==n?($e=[["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(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{M(It),Rr({sidebarProjectSortOrder:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),I===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),e[142]=I,e[143]=M,e[144]=n,e[145]=$e):$e=e[145];let J;e[146]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(Os,{}),e[146]=J):J=e[146];let re;e[147]!==F||e[148]!==R||e[149]!==i||e[150]!==n?(re=i?s.jsxs(s.Fragment,{children:[s.jsx(ho,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{R(It),Rr({sidebarProjectDisplayMode:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),F===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),s.jsx(Os,{})]}):null,e[147]=F,e[148]=R,e[149]=i,e[150]=n,e[151]=re):re=e[151];let Pe;e[152]!==n?(Pe=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=Pe):Pe=e[153];let _e;e[154]!==Pe?(_e=s.jsx(ho,{children:Pe}),e[154]=Pe,e[155]=_e):_e=e[155];let Ve;e[156]!==_||e[157]!==O||e[158]!==n?(Ve=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{O(It),Rr({sidebarSessionGroupingMode:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),_===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),e[156]=_,e[157]=O,e[158]=n,e[159]=Ve):Ve=e[159];let Ze;e[160]===Symbol.for("react.memo_cache_sentinel")?(Ze=s.jsx(Os,{}),e[160]=Ze):Ze=e[160];let lt;e[161]!==j||e[162]!==o||e[163]!==D||e[164]!==n||e[165]!==P?(lt=o&&!j?s.jsxs(Kt,{onClick:()=>{P(),Rr({sidebarShowRecentSection:!D})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),D?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[161]=j,e[162]=o,e[163]=D,e[164]=n,e[165]=P,e[166]=lt):lt=e[166];let rt;e[167]!==n?(rt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=rt):rt=e[168];let Ge;e[169]!==rt?(Ge=s.jsx("span",{children:rt}),e[169]=rt,e[170]=Ge):Ge=e[170];let ot;e[171]!==U?(ot=U?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=U,e[172]=ot):ot=e[172];let Ee;e[173]!==Ge||e[174]!==ot||e[175]!==L?(Ee=s.jsxs(Kt,{onClick:L,className:"flex items-center justify-between",children:[Ge,ot]}),e[173]=Ge,e[174]=ot,e[175]=L,e[176]=Ee):Ee=e[176];let Rt;e[177]!==v||e[178]!==N||e[179]!==j||e[180]!==n?(Rt=j?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Kt,{onClick:v,className:"flex items-center gap-2",children:[s.jsx(E,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Kt,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(E,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[177]=v,e[178]=N,e[179]=j,e[180]=n,e[181]=Rt):Rt=e[181];let xe;e[182]!==it||e[183]!==$e||e[184]!==re||e[185]!==_e||e[186]!==Ve||e[187]!==lt||e[188]!==Ee||e[189]!==Rt?(xe=s.jsxs(Xs,{align:"end",className:"min-w-[180px]",children:[it,$e,J,re,_e,Ve,Ze,lt,Ee,Rt]}),e[182]=it,e[183]=$e,e[184]=re,e[185]=_e,e[186]=Ve,e[187]=lt,e[188]=Ee,e[189]=Rt,e[190]=xe):xe=e[190];let mt;e[191]!==fe||e[192]!==xe?(mt=s.jsxs(Js,{children:[fe,xe]}),e[191]=fe,e[192]=xe,e[193]=mt):mt=e[193];let Tt;e[194]!==Qe||e[195]!==ht||e[196]!==mt?(Tt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Qe,ht,mt]}),e[194]=Qe,e[195]=ht,e[196]=mt,e[197]=Tt):Tt=e[197];let Xe;e[198]!==V||e[199]!==Tt?(Xe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[V,Tt]}),e[198]=V,e[199]=Tt,e[200]=Xe):Xe=e[200];let nt;e[201]!==b||e[202]!==g||e[203]!==y||e[204]!==S||e[205]!==x||e[206]!==w||e[207]!==m||e[208]!==n?(nt=g?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[b?s.jsx("span",{children:y===1?n("sessions.sidebar.header.search.matchCountSingle",{count:y}):n("sessions.sidebar.header.search.matchCountPlural",{count:y})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:S,value:x,onChange:yt=>m(yt.target.value),placeholder:n("sessions.sidebar.header.search.placeholder"),className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50",onKeyDown:yt=>{yt.key==="Escape"&&(yt.stopPropagation(),b?m(""):w(!1))}}),x.length>0?s.jsx("button",{type:"button",onClick:()=>m(""),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 hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":n("sessions.sidebar.header.search.clear"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[201]=b,e[202]=g,e[203]=y,e[204]=S,e[205]=x,e[206]=w,e[207]=m,e[208]=n,e[209]=nt):nt=e[209];let St;return e[210]!==Xe||e[211]!==nt?(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:[Xe,nt]})}),e[210]=Xe,e[211]=nt,e[212]=St):St=e[212],St}function a0(t){return!t}function l0(t){return t.setProjectDisplayMode}function c0(t){return t.projectDisplayMode}function d0(t){return t.toggleStickyZoneHeaders}function u0(t){return t.stickyZoneHeaders}function f0(t){return t.setSessionGroupingMode}function m0(t){return t.sessionGroupingMode}function h0(t){return t.setProjectSortOrder}function p0(t){return t.projectSortOrder}function g0(t){return t.toggleRecentSection}function x0(t){return t.showRecentSection}function b0(t){return t.toggleMode}function y0(t){return t.enabled}function w0(t){const e=st.c(8),{t:n}=Nt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(E,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const mi="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-primary/50";function S0(t){const e=st.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,u=l===void 0?!0:l,d=a===void 0?!0:a,{t:h}=Nt();if(!u&&!d)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(f=u?s.jsxs(s.Fragment,{children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:mi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(E,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:mi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(E,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:mi,"aria-label":h("sessions.sidebar.footer.actions.aboutAiWorker"),children:s.jsx(E,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutAiWorker")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=h,e[5]=f):f=e[5];let p;e[6]!==o||e[7]!==d||e[8]!==h?(p=d?s.jsx(xt,{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:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=d,e[8]=h,e[9]=p):p=e[9];let g;return e[10]!==f||e[11]!==p?(g=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,p]}),e[10]=f,e[11]=p,e[12]=g):g=e[12],g}const v0=t=>{for(const e of t.sessions.values())if(e.tabs.some(md))return!0;return!1},j0=()=>{const t=st.c(4),{terminal:e}=Sn(),n=Mt(v0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=k0,l=C0;if(n)return Ei(e,"",l,o);let a=N0;return a=Ei(e,"",l,u=>{o(u),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 k0(t){const e=Mt.getState(),n=gg(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 C0(){return new Map(Mt.getState().actionMutationRevisions)}function N0(){}const A0=t=>{const e=st.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:f}=t,p=r===void 0?!0:r;let g,w;e[0]!==f||e[1]!==h||e[2]!==p||e[3]!==d||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==u?(g=()=>{!p||o||!l||a||n.forEach(S=>{if(u.has(S.normalizedPath))return;const x=_d(S.normalizedPath),m=i.archivedSessionsByProject.get(S.id)??[],b=d[x]??[],y=new Map(b.map(D0));m.forEach(v=>{const N=yh(v,S.normalizedPath),C=N.toLowerCase();let k=y.get(C);k||(k=h(x,N),y.set(C,k)),k.sessionIds.includes(v.id)||f(x,k.id,v.id)})})},w=[n,p,i,o,l,a,u,d,h,f],e[0]=f,e[1]=h,e[2]=p,e[3]=d,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=u,e[10]=g,e[11]=w):(g=e[10],w=e[11]),c.useEffect(g,w)};function D0(t){return[t.name.toLowerCase(),t]}function P0({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 d=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!d)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const u=(o&&r.has(o)?o:null)??l;return!u||u===e?{kind:"none"}:{kind:"select-session",sessionId:u}}const I0=t=>{const e=st.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let g,w;if(e[0]!==n){w=new Map,g=new Map;const C=(k,D,P,I)=>{w.has(k)||w.set(k,new Map);const M=w.get(k);I.forEach(_=>{const O=vt(_.worktree?.path??_.session.directory??P??D);M.set(_.session.id,{directory:O}),g.has(k)||g.set(k,{id:_.session.id,directory:O}),_.children.length>0&&C(k,D,O,_.children)})};n.forEach(k=>{k.groups.forEach(D=>{C(k.project.id,k.project.normalizedPath,D.directory,D.sessions)})}),e[0]=n,e[1]=g,e[2]=w}else g=e[1],w=e[2];let S;e[3]!==g||e[4]!==w?(S={metaByProject:w,firstSessionByProject:g},e[3]=g,e[4]=w,e[5]=S):S=e[5];const x=S,m=c.useRef(null);let b,y;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==u||e[11]!==h||e[12]!==d||e[13]!==f||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==p?(b=()=>{if(!r||d||Te.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(I=>I.project.id===r);if(!C)return;const k=x.metaByProject.get(r);if(l&&k&&k.has(l)){m.current=r,o(I=>{if(I.get(r)===l)return I;const M=new Map(I);return M.set(r,l),M});return}const D=P0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:k,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(D.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,D.kind==="open-draft"){h&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(D.kind!=="select-session")return;const P=k?.get(D.sessionId)?.directory??null;u(D.sessionId,P)},y=[r,i,l,a,u,d,h,f,n,x,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=u,e[11]=h,e[12]=d,e[13]=f,e[14]=n,e[15]=x,e[16]=o,e[17]=p,e[18]=b,e[19]=y):(b=e[18],y=e[19]),c.useLayoutEffect(b,y);let v,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(v=()=>{if(!r||!l)return;const C=x.metaByProject.get(r);!C||!C.has(l)||o(k=>{if(k.get(r)===l)return k;const D=new Map(k);return D.set(r,l),D})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=v,e[25]=N):(v=e[24],N=e[25]),c.useEffect(v,N)},T0=t=>{const e=st.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=Je(R0),a=Je(E0);let u;e[5]!==l||e[6]!==o?(u=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=u):u=e[7];const d=u;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 g;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(g={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=g):g=e[15],I0(g);let w,S;return e[16]!==f||e[17]!==i?(w=()=>{i(f)},S=[f,i],e[16]=f,e[17]=i,e[18]=w,e[19]=S):(w=e[18],S=e[19]),c.useEffect(w,S),null};function R0(t){return t.currentSessionId}function E0(t){return!!t.newSessionDraft?.open}const hc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function lf(t){const e=new Map,n=(r,i,o)=>{const l=vt(r??null);if(!l)return;const a=e.get(l);a&&hc[a.priority]<=hc[i]||e.set(l,{directory:l,priority:i,reason:o})};for(const r of t.knownDirectories??[])n(r,"background","known-project");n(t.activeProjectDirectory,"active-project","project-expanded");for(const r of t.projectSections??[]){const i=!t.collapsedProjects.has(r.project.id);let o="background";r.project.id===t.activeProjectId?o="active-project":i&&(o="expanded"),n(r.project.normalizedPath,o,i?"project-expanded":"known-project");for(const l of r.groups){if(!l.directory||l.isArchivedBucket||l.isMain)continue;const a=i&&!t.collapsedGroups.has(`${r.project.id}:${l.id}`);let u="background";a?u="expanded":i&&(u="visible"),n(l.directory,u,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const M0=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,pc=(t,e,n)=>{M0(t.get(e),n)&&t.set(e,n)},O0=t=>{const e=t;return vt(e.directory)??vt(e.project?.worktree)},F0=t=>{if(t==="/"||/^[A-Z]:$/.test(t))return null;const e=t.lastIndexOf("/");return e<0?null:e===0?"/":e===2&&/^[A-Z]:\//.test(t)?t.slice(0,2):t.slice(0,e)},B0=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const S=vt(w.normalizedPath);if(!S)continue;const x=l.get(S);(!x||w.id.localeCompare(x.id)<0)&&l.set(S,w),pc(o,S,{projectId:w.id,projectRoot:S,scopeDirectory:S,kind:"project"})}if(!r)for(const[w,S]of n){const x=vt(w),m=x?l.get(x):void 0;if(!(!m||!x))for(const b of S){const y=vt(b.path);y&&pc(o,y,{projectId:m.id,projectRoot:x,scopeDirectory:y,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,f=new Map,p=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const b=o.get(w)??null;return a.set(w,b),b}const S=[];let x=w,m=null;for(;x;){if(a.has(x)){m=a.get(x)??null;break}if(S.push(x),m=o.get(x)??null,m)break;x=F0(x)}for(const b of S)a.set(b,m);return m},g=(w,S,x)=>{for(const m of w){const b=p(O0(m));if(!b)continue;u.set(m.id,b);const y=S.get(b.projectId);if(y?y.push(m):S.set(b.projectId,[m]),!x)continue;const v=x.get(b.scopeDirectory);v?v.add(m.id):x.set(b.scopeDirectory,new Set([m.id]))}};return g(t,d,f),g(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},_0=t=>{const e=st.c(7),{ownership:n}=t;let r;e[0]!==n?(r=u=>n.sessionsByProject.get(u)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=u=>n.archivedSessionsByProject.get(u)??[],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},L0=(t,e)=>t.map(n=>{const r=vt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
912
+ `)},pw=t=>{const e=st.c(7),{t:n}=Nt(),r=Je(xw),i=Je(bw),o=ji(yw),l=eh(ww);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async u=>{const d=r??(i?"draft":null);if(!d){Le.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(u.screenshot)try{await l(u.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:d},{source:"preview-annotation",fileLabel:u.payload.pageUrl||"browser",startLine:1,endLine:1,code:hw({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Le.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},gw=()=>{const t=st.c(16),{t:e}=Nt();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 xw(t){return t.currentSessionId}function bw(t){return t.newSessionDraft?.open}function yw(t){return t.addDraft}function ww(t){return t.addAttachedFile}const Sw=3e4,vw=3,jw=250,kw={attempts:0,windowStartedAt:null},Cw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Sw,r=n?0:t.attempts;return r>=vw?null:{delayMs:jw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Nw=-3,oo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",dr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Aw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:f1),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[f,p]=c.useState(!1),g=c.useRef(n);g.current=n;const w=c.useRef(kw);return c.useEffect(()=>{if(!t)return;const S=()=>{try{const I=t.getURL();return oo(I)?I:""}catch{return""}},x=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},m=I=>{oo(I)&&(l(I),g.current(I))},b=()=>{const I=S();i({kind:"loading",url:I})},y=()=>{const I=S();let M="";try{M=t.getTitle()||""}catch{M=""}u(M),m(I),x(),i(_=>_.kind==="failed"&&_.url===I?_:{kind:"ready",url:I,title:M})},v=I=>{const M=dr(I);oo(M.url)&&(m(M.url),x())},N=I=>{const M=dr(I),_=Array.isArray(M.favicons)?M.favicons.find(Boolean):"",O=S();_&&O&&Vu.getState().resolve(O,_)},C=I=>{const M=dr(I);typeof M.title=="string"&&u(M.title)},k=I=>{const M=dr(I);if(M.isMainFrame===!1)return;const _=typeof M.errorCode=="number"?M.errorCode:0;_!==Nw&&i({kind:"failed",url:oo(M.validatedURL)?M.validatedURL:S(),code:_,description:typeof M.errorDescription=="string"?M.errorDescription:""})};let D=null;const P=()=>{const I=S(),M=Cw(w.current,Date.now());if(!M){i({kind:"failed",url:I,code:0,description:"",crashed:!0});return}w.current=M.state,i({kind:"loading",url:I}),D=setTimeout(()=>{D=null;try{t.reload()}catch{i({kind:"failed",url:I,code:0,description:"",crashed:!0})}},M.delayMs)};t.addEventListener("did-start-loading",b),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",v),t.addEventListener("did-navigate-in-page",v),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",P),t.addEventListener("crashed",P);try{!t.isLoading()&&S()&&y()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",b),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",v),t.removeEventListener("did-navigate-in-page",v),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:o,title:a,canGoBack:d,canGoForward:f}},Dw=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,Pw=4e4,io=.5,Iw=-3,Tw=4,Rw="persist:openchamber-browser",ac=20,Ew=600,Mw=2e4,Ow=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=Nt(),{currentTheme:i}=Zn(),o=c.useRef(null),[l,a]=c.useState(null),u=c.useCallback(ie=>{o.current=ie,a(ie)},[]),d=Te(ie=>ie.setContextPanelTabTargetPath),h=c.useRef(hr(t)),f=h.current!==ln?h.current:"",[p,g]=c.useState(f?null:ln),[w,S]=c.useState(f),[x,m]=c.useState(!1),[b,y]=c.useState(!1),[v,N]=c.useState(0),C=c.useRef(0),[k,D]=c.useState(!1),[P,I]=c.useState(Mo),M=c.useRef(P);M.current=P;const _=c.useRef([]),[O,U]=c.useState("system"),[L,F]=c.useState({width:0,height:0}),R=c.useRef(null),j=c.useRef(null),A=c.useRef(!1),B=c.useRef(Date.now()),X=c.useCallback(ie=>{!ie||ie===ln||!e||!n||d(e,n,ie)},[e,n,d]),H=Aw(l,{initialUrl:f,onUrlChange:c.useCallback(ie=>{const ee=Ar(ie);S(ee),X(ee)},[X])}),[Z,ce]=c.useState(null),Y=pw(e),se=gw(),oe=H.status.kind==="loading",Se=gr(Yu(e)),K=gr(ie=>ie.recordVisit),pe=gr(ie=>ie.forget);c.useEffect(()=>{H.status.kind==="ready"&&K(e,{url:Ar(H.status.url),title:H.status.title})},[e,H.status,K]);const je=c.useMemo(()=>Qu(Se,w),[Se,w]),ne=c.useCallback(ie=>{const ee=hr(ie);ee!==ln&&(S(ee),ce(null),tc(ee).then(V=>{const $=o.current;if(!$){g(V);return}try{$.loadURL(V)}catch{g(V)}}).catch(V=>{V instanceof _r&&ce(ee)}))},[]);c.useEffect(()=>{if(!f)return;let ie=!0;return tc(f).then(ee=>{ie&&g(ee)}).catch(ee=>{if(ie){if(ee instanceof _r){ce(f),g(ln);return}g(f)}}),()=>{ie=!1}},[]);const T=c.useMemo(()=>({executeJavaScript:async(ie,ee)=>{const V=o.current;if(!V)throw new Error("Browser view is not available");return V.executeJavaScript(ie,ee)},capturePage:async()=>{const ie=o.current;if(!ie)return null;const ee=ie.getWebContentsId();return Number.isFinite(ee)?await fr("desktop_browser_capture_page",{webContentsId:ee}):null}}),[]),G=c.useCallback(()=>{if(x){m(!1),bo(T);return}if(!H.url){Le.error(r("contextPanel.browser.annotate.noPage"));return}const ie=N1(i.metadata.variant==="light"?"light":"dark");m(!0),k1({host:T,theme:ie,labels:se}).then(async ee=>{m(!1),ee&&await Y(ee)}).catch(()=>{m(!1),Le.error(r("contextPanel.browser.annotate.failed"))})},[T,Y,i,x,H.url,se,r]);c.useEffect(()=>{if(!x)return;const ie=ee=>{th(ee)||ee.key!=="Escape"||(ee.preventDefault(),ee.stopImmediatePropagation(),m(!1),bo(T))};return window.addEventListener("keydown",ie,!0),()=>window.removeEventListener("keydown",ie,!0)},[T,x]);const le=c.useCallback(async(ie=8e3)=>{const ee=Date.now();for(;;){const V=o.current;if(!V)return!1;let $=!1;try{$=V.isLoading()}catch{return!1}if(!$)return!0;if(Date.now()-ee>ie)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),de=c.useCallback(async(ie,ee)=>{const V=o.current;if(!V)throw new Error("The browser panel is not ready");const $=()=>{ic(ee.viewport)&&(I(Zi(ee.viewport)),D(!0))};if(ie==="browser.back"||ie==="browser.forward"){const ke=ie==="browser.back";if(!(ke?V.canGoBack():V.canGoForward()))throw new Error(ke?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");ke?V.goBack():V.goForward(),await new Promise(z=>setTimeout(z,150)),await le();let We="";try{We=V.getTitle()||""}catch{We=""}return{url:Ar(V.getURL()),title:We}}if(ie==="browser.capture"){Te.getState().openContextBrowser(e,V.getURL());const ke=Date.now()+1200;let Qe=0,We=0;for(;We<2&&Date.now()<ke;){const Be=V.getBoundingClientRect().width;We=Be>=2&&Math.abs(Be-Qe)<.5?We+1:0,Qe=Be,await new Promise(Ae=>setTimeout(Ae,50))}await new Promise(Be=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Be()))}),await le();const z=await T.capturePage();if(!z)throw new Error("The page could not be captured");let he="";try{he=V.getTitle()||""}catch{he=""}return{...z,url:Ar(V.getURL()),title:he,viewport:ro(M.current)}}if(ie==="browser.resize"){if(!ic(ee.viewport))throw new Error("viewport is required");return $(),await new Promise(ke=>setTimeout(ke,200)),await le(),{viewport:ro(Zi(ee.viewport))}}if(ie==="browser.open"){const ke=typeof ee.url=="string"?ee.url:"";if(!ke)throw new Error("url is required");$(),ne(ke),await new Promise(z=>setTimeout(z,150));const Qe=await le(25e3);let We="";try{We=V.getTitle()||""}catch{We=""}return{url:hr(ke),title:We,opened:!0,settled:Qe,viewport:ro(M.current)}}await le();const ae=ke=>typeof ke=="string"&&ke?ke:void 0,ve=(()=>{switch(ie){case"browser.snapshot":return q1({selector:ae(ee.selector)});case"browser.click":return Q1({selector:ae(ee.selector),text:ae(ee.text)});case"browser.type":return Y1({selector:String(ee.selector??""),value:String(ee.value??""),submit:ee.submit===!0});case"browser.inspect":return Z1({selector:String(ee.selector??"")});case"browser.scroll":return X1({selector:ae(ee.selector),direction:ae(ee.direction)});default:return null}})();if(!ve)throw new Error(`Unsupported browser action: ${ie}`);const Fe=await V.executeJavaScript(ve,!0);if(!Fe||typeof Fe!="object")throw new Error("The page returned no result");const Ce=Fe;if(Ce.ok!==!0)throw new Error(typeof Ce.error=="string"&&Ce.error?Ce.error:"Browser action failed");if(ie==="browser.snapshot"){const ke=_.current;return{...Ce,viewport:ro(M.current),...ke.length>0?{consoleProblems:[...ke]}:{}}}return(ie==="browser.click"||ie==="browser.type"&&ee.submit===!0)&&(await new Promise(ke=>setTimeout(ke,150)),await le()),Fe},[T,e,ne,le]);c.useEffect(()=>R1({run:de}),[de]),c.useEffect(()=>{const ie=T;return()=>{bo(ie)}},[T]),c.useEffect(()=>{if(!l)return;const ie=V=>{const $=V;if(typeof $.level!="number"||$.level<2)return;const ae=$.sourceId?`${$.sourceId}${$.line?`:${$.line}`:""}`:"";_.current.push({level:$.level>=3?"error":"warning",message:String($.message??"").slice(0,400),source:ae}),_.current.length>ac&&_.current.splice(0,_.current.length-ac)},ee=()=>{_.current=[]};return l.addEventListener("console-message",ie),l.addEventListener("did-start-loading",ee),()=>{l.removeEventListener("console-message",ie),l.removeEventListener("did-start-loading",ee)}},[l]);const ue=c.useRef(new Set),Oe=c.useCallback(ie=>{ue.current.clear(),ne(ie)},[ne]);c.useEffect(()=>{if(!l)return;const ie=V=>{const $=dr(V),ae=typeof $.url=="string"?$.url:"";!ae||!sc(ae)||(V.preventDefault(),ne(ae))},ee=V=>{const $=dr(V);if($.isMainFrame===!1||$.errorCode===-3)return;const ae=typeof $.validatedURL=="string"?$.validatedURL:"";!ae||!sc(ae)||ue.current.has(ae)||(ue.current.add(ae),ne(ae))};return l.addEventListener("will-navigate",ie),l.addEventListener("did-fail-load",ee),()=>{l.removeEventListener("will-navigate",ie),l.removeEventListener("did-fail-load",ee)}},[ne,l]),c.useEffect(()=>{if(!l)return;const ie=ee=>{const V=ee.detail;ee.preventDefault(),V?.url&&ne(V.url)};return l.addEventListener("new-window",ie),()=>l.removeEventListener("new-window",ie)},[ne,l]);const me=c.useCallback(ie=>{const ee=Math.min(Tw,Math.max(Iw,ie));C.current=ee,N(ee);try{o.current?.setZoomLevel(ee)}catch{}},[]);c.useEffect(()=>{const ie=ee=>{if(!(ee instanceof CustomEvent))return;const V=ee.detail,$=o.current;!$||document.activeElement!==$||(V==="zoom-in"?me(C.current+io):V==="zoom-out"?me(C.current-io):V==="zoom-reset"&&me(0))};return window.addEventListener("aiworker:zoom",ie),()=>window.removeEventListener("aiworker:zoom",ie)},[me]);const Re=c.useCallback(ie=>{fr("desktop_browser_clear_data",{partition:Rw,cookies:ie==="cookies",cache:ie==="cache"}).then(()=>{Le.success(r(ie==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Le.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const ie=R.current;if(!ie||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(V=>{const $=V[0]?.contentRect;$&&F({width:$.width,height:$.height})});return ee.observe(ie),()=>ee.disconnect()},[]);const ye=c.useCallback(ie=>{U(ie);const ee=o.current;if(!ee)return;let V=-1;try{V=ee.getWebContentsId()}catch{return}fr("desktop_browser_set_color_scheme",{webContentsId:V,scheme:ie}).catch($=>{U("system"),Le.error($ instanceof Error?$.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),q=c.useCallback(()=>{try{oe?o.current?.stop():o.current?.reload()}catch{}},[oe]),we=H.status;c.useEffect(()=>{const ie=()=>{y(!0);const $=setTimeout(()=>{try{o.current?.reload()}catch{}},Ew);return()=>clearTimeout($)};if(we.kind==="failed"){if(!r1(we.code,we.url)){y(!1);return}const $=Date.now(),ae=j.current?.url===we.url?j.current:{url:we.url,startedAt:$};if(j.current=ae,$-ae.startedAt>Pw){y(!1);return}return ie()}if(we.kind==="loading")return;if(j.current=null,we.kind!=="ready"||!we.url||!yr(we.url)){A.current=!0,y(!1);return}if(A.current||Date.now()-B.current>Mw){A.current=!0,y(!1);return}let ee=!1,V=null;return a1(Ar(we.url)).then($=>{if(!ee){if($===null||$<500){A.current=!0,y(!1);return}V=ie()}}),()=>{ee=!0,V?.()}},[we]);const be=H.status.kind==="failed"&&!b?H.status:null,Ne=nw(P,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(ef,{address:w,onAddressChange:S,onSubmit:Oe,suggestions:je,onForgetSuggestion:ie=>pe(e,ie),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:q,onOpenExternal:()=>{Uo(H.url||w)},canGoBack:H.canGoBack,canGoForward:H.canGoForward,isLoading:oe,onAnnotate:G,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>me(v+io),onZoomOut:()=>me(v-io),onZoomReset:()=>me(0),zoomPercent:Math.round(Math.pow(1.2,v)*100),onClearCookies:()=>Re("cookies"),onClearCache:()=>Re("cache"),onToggleDeviceBar:()=>D(ie=>!ie),isDeviceBarOpen:k}),k?s.jsx(iw,{viewport:P,onViewportChange:I,colorScheme:O,onColorSchemeChange:ye,scale:Ne?.scale??1}):null,s.jsxs("div",{ref:R,className:Ie("relative min-h-0 flex-1 bg-background",Ne&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:u,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:Ne?{width:`${Ne.width}px`,height:`${Ne.height}px`,transform:`scale(${Ne.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!H.url&&!oe?s.jsx(nf,{onOpen:Oe,directory:e}):null,b?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,Z?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:Z})})]}):null,be&&!Z?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:be.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:be.crashed?r("contextPanel.browser.crashedHint"):be.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,oe?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]})]})},Fw=t=>{const e=st.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=Nt(),l=Te(_w);let a;e[0]!==n?(a=hr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==ln?u:"",[h,f]=c.useState(d),[p,g]=c.useState(d);let w;e[2]!==d?(w=d?[d]:[],e[2]=d,e[3]=w):w=e[3];const[S,x]=c.useState(w),[m,b]=c.useState(d?0:-1),[y,v]=c.useReducer(Lw,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=se=>{!se||se===ln||!r||!i||l(r,i,se)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let k;e[8]!==r?(k=Yu(r),e[8]=r,e[9]=k):k=e[9];const D=gr(k),P=gr($w),I=gr(Ww);let M;e[10]!==h||e[11]!==D?(M=Qu(D,h),e[10]=h,e[11]=D,e[12]=M):M=e[12];const _=M;let O;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==P?(O=se=>{const oe=hr(se);oe!==ln&&(f(oe),g(oe),C(oe),P(r,{url:oe}),x(Se=>{const K=m>=0?Se.slice(0,m+1):[];return K[K.length-1]===oe?(b(K.length-1),K):(b(K.length),[...K,oe])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=P,e[17]=O):O=e[17];const U=O;let L;e[18]!==S||e[19]!==C?(L=se=>{const oe=S[se];oe&&(b(se),f(oe),g(oe),C(oe))},e[18]=S,e[19]=C,e[20]=L):L=e[20];const F=L;let R;e[21]!==r||e[22]!==I?(R=se=>I(r,se),e[21]=r,e[22]=I,e[23]=R):R=e[23];let j,A;e[24]!==F||e[25]!==m?(A=()=>F(m-1),j=()=>F(m+1),e[24]=F,e[25]=m,e[26]=j,e[27]=A):(j=e[26],A=e[27]);let B;e[28]!==h||e[29]!==p?(B=()=>{Uo(p||h)},e[28]=h,e[29]=p,e[30]=B):B=e[30];const X=m>0,H=m>=0&&m<S.length-1;let Z;e[31]!==h||e[32]!==U||e[33]!==_||e[34]!==j||e[35]!==B||e[36]!==X||e[37]!==H||e[38]!==R||e[39]!==A?(Z=s.jsx(ef,{address:h,onAddressChange:f,onSubmit:U,suggestions:_,onForgetSuggestion:R,onBack:A,onForward:j,onReload:v,onOpenExternal:B,canGoBack:X,canGoForward:H,isLoading:!1}),e[31]=h,e[32]=U,e[33]=_,e[34]=j,e[35]=B,e[36]=X,e[37]=H,e[38]=R,e[39]=A,e[40]=Z):Z=e[40];let ce;e[41]!==p||e[42]!==U||e[43]!==y||e[44]!==o?(ce=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}|${y}`):s.jsx(nf,{onOpen:U})}),e[41]=p,e[42]=U,e[43]=y,e[44]=o,e[45]=ce):ce=e[45];let Y;return e[46]!==Z||e[47]!==ce?(Y=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Z,ce]}),e[46]=Z,e[47]=ce,e[48]=Y):Y=e[48],Y},Bw=t=>{const e=st.c(3),[n]=c.useState(Dw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Ow,{...t}):s.jsx(Fw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function _w(t){return t.setContextPanelTabTargetPath}function Lw(t){return t+1}function $w(t){return t.recordVisit}function Ww(t){return t.forget}const zw=Ln(()=>Bn(()=>import("./WalkthroughView-CpgA4s9w.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])).then(t=>({default:t.WalkthroughView}))),Vw=Ln(()=>Bn(()=>import("./DiffView-BviYY3zL.js"),__vite__mapDeps([124,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,125,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.DiffView}))),Uw=Ln(()=>Bn(()=>import("./FilesView-D0ZU_nCt.js"),__vite__mapDeps([126,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,127,128,129,130,131,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,132,133,118,119,116,121,134,117,135])).then(t=>({default:t.FilesView}))),Kw=Ln(()=>Bn(()=>import("./GitView-CYgiDRH-.js"),__vite__mapDeps([136,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,137,115,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,85,113,114,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),Hw=Ln(()=>Bn(()=>import("./LinearIssuesView-shqUS8nl.js"),__vite__mapDeps([138,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}))),Gw=Ln(()=>Bn(()=>import("./PlanView-CLUWkGiG.js"),__vite__mapDeps([139,1,2,4,5,6,7,8,9,127,57,58,59,60,61,62,79,55,56,63,128,129,130,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,117,135,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,84])).then(t=>({default:t.PlanView}))),qw=320,Qw=1400,rf=600,Yw=100,Xw=24,Fo=new Map,Jw=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},lc=t=>Number.isFinite(t)?Math.min(Qw,Math.max(qw,Math.round(t))):rf,Zw=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},eS=(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},of=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="linear"?"contextPanel.mode.linear":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),tS=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=ea(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"?$a(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?tS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):of(t.mode,n)},cc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Sa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Eu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(E,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(E,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(E,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(E,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(E,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(E,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(E,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(E,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=nS(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(E,{name:"global",className:"h-3.5 w-3.5"})}},nS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},rS=200,oS=480,iS=({visible:t,active:e})=>{const{t:n}=Nt(),r=Te(b=>b.contextEditorTreeWidth),i=Te(b=>b.setContextEditorTreeWidth),[o,l]=c.useState(!1),a=c.useRef(0),u=c.useRef(r),d=c.useRef(null),h=c.useRef(null),f=c.useRef(null),p=c.useCallback(b=>Math.min(oS,Math.max(rS,Math.round(b))),[]),g=c.useCallback(b=>{const y=f.current;y&&(y.style.width=`${b}px`,y.style.setProperty("--oc-editor-tree-width",`${b}px`))},[]),w=b=>{if(t){try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}h.current=b.pointerId,l(!0),a.current=b.clientX,u.current=r,d.current=r,b.preventDefault()}},S=b=>{if(!o||h.current!==b.pointerId)return;const y=a.current-b.clientX,v=p(u.current+y);d.current!==v&&(d.current=v,g(v))},x=b=>{if(h.current!==b.pointerId)return;try{b.currentTarget.releasePointerCapture(b.pointerId)}catch{}const y=p(d.current??r);h.current=null,d.current=null,l(!1),i(y)},m=t?r:0;return s.jsxs("div",{ref:f,className:Ie("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?d.current??m:m}px`,"--oc-editor-tree-width":`${o?d.current??r:r}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:Ie("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:S,onPointerUp:x,onPointerCancel:x,role:"separator","aria-orientation":"vertical","aria-label":n("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Ie("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(Cy,{visible:t&&e})})]})},ea=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,aS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},lS=(t,e)=>{if(e.length===0)return Fo;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?Fo:r},cS=(t,e)=>{const n=kd(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=lS(n.getState().session,i.current);return aS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},dS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,uS=()=>{const{t}=Nt(),e=er()??"",n=c.useMemo(()=>Jw(e),[e]),r=Te(ge=>n?ge.contextPanelByDirectory[n]:void 0),i=Te(ge=>ge.closeContextPanel),o=Te(ge=>ge.closeContextPanelTab),l=Te(ge=>ge.openContextPanelTab),a=Te(ge=>ge.toggleContextPanelExpanded),u=Te(ge=>ge.setContextPanelWidth),d=Te(ge=>ge.setActiveContextPanelTab),h=Te(ge=>ge.openContextBrowser);c.useEffect(()=>{if(e)return E1(ge=>h(e,ge))},[e,h]);const f=Te(ge=>ge.reorderContextPanelTabs),p=hn(ge=>ge.setSelectedPath),g=Te(ge=>ge.contextEditorTreeVisible),w=Te(ge=>ge.toggleContextEditorTree),S=Te(ge=>ge.openNewContextBrowserTab),x=Vu(ge=>ge.byOrigin),m=Te(ge=>ge.allowPromptingSubagentSessions),{themeMode:b,setThemeMode:y,lightThemeId:v,darkThemeId:N,currentTheme:C}=Zn(),k=c.useMemo(()=>r?.tabs??[],[r?.tabs]),D=k.find(ge=>ge.id===r?.activeTabId)??k[k.length-1]??null,P=!!(r?.isOpen&&D),I=!!(P&&r?.expanded),[M,_]=c.useState(null),O=D?.mode??null,U=O?r?.widthByMode?.[O]:void 0,L=O?r?.widthFractionByMode?.[O]:void 0,F=O?sh(O):.5,R=M??(typeof window<"u"?window.innerWidth:rf*2),j=L!=null&&M!=null?Math.round(L*M):U,A=lc(j??Math.round(F*R));c.useEffect(()=>{!n||!O||L!=null||U==null||M==null||u(n,O,U,M)},[O,M,n,U,L,u]);const B=c.useMemo(()=>{const ge=[];for(const Ye of k){if(Ye.mode!=="chat")continue;const bt=ea(Ye.dedupeKey);bt&&!ge.includes(bt)&&ge.push(bt)}return ge},[k]),X=cS(n||void 0,B),[H,Z]=c.useState(!1),ce=c.useRef(0),Y=c.useRef(A),se=c.useRef(null),oe=c.useRef(null),Se=c.useRef(null),K=c.useRef(new Map),pe=c.useRef(new Map),je=c.useRef(!1);c.useLayoutEffect(()=>{const ge=Se.current?.parentElement;if(!ge||typeof ResizeObserver>"u")return;const Ye=new ResizeObserver(()=>{_(ge.clientWidth||null)});return Ye.observe(ge),_(ge.clientWidth||null),()=>Ye.disconnect()},[]),c.useEffect(()=>{if(!P||je.current){je.current=P;return}const ge=window.requestAnimationFrame(()=>{Se.current?.focus({preventScroll:!0})});return je.current=!0,()=>window.cancelAnimationFrame(ge)},[P]);const ne=c.useRef(null),T=c.useRef(null),G=c.useCallback(()=>{T.current=null;const ge=Se.current,Ye=se.current;!ge||Ye===null||ge.style.setProperty("--oc-context-panel-width",`${Ye}px`)},[]);c.useEffect(()=>()=>{T.current!==null&&clearTimeout(T.current)},[]);const le=c.useCallback(ge=>{const Ye=lc(ge),bt=ne.current;return bt===null?Ye:Math.min(Ye,Math.max(1,bt))},[]),de=c.useCallback(ge=>{!P||I||!n||(oe.current=ge.pointerId,Z(!0),ce.current=ge.clientX,Y.current=A,se.current=A,ne.current=Zw(Se.current),document.documentElement.style.cursor="col-resize",ge.preventDefault())},[n,I,P,A]),ue=c.useCallback(()=>{const ge=le(se.current??A),Ye=ne.current;se.current=null,ne.current=null,T.current!==null&&(clearTimeout(T.current),T.current=null),document.documentElement.style.cursor="",n&&O&&u(n,O,ge,Ye??void 0),Z(!1),oe.current=null},[O,le,n,u,A]);c.useEffect(()=>{if(!H)return;const ge=jt=>{if(oe.current!==jt.pointerId)return;const fe=ce.current-jt.clientX,ze=le(Y.current+fe);se.current!==ze&&(se.current=ze,T.current===null&&(T.current=setTimeout(G,Yw)))},Ye=jt=>{oe.current===jt.pointerId&&ue()},bt=()=>{ue()};return window.addEventListener("pointermove",ge),window.addEventListener("pointerup",Ye),window.addEventListener("pointercancel",Ye),window.addEventListener("blur",bt),()=>{window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",Ye),window.removeEventListener("pointercancel",Ye),window.removeEventListener("blur",bt)}},[G,le,ue,H]),c.useEffect(()=>{H||(se.current=null,document.documentElement.style.cursor="")},[H]);const Oe=c.useCallback(()=>{n&&i(n)},[i,n]),me=c.useCallback(()=>{n&&a(n)},[n,a]),Re=c.useCallback(ge=>{ge.key==="Escape"&&(nh(ge.target)||(ge.preventDefault(),ge.stopPropagation(),Oe()))},[Oe]);c.useEffect(()=>{if(!(!n||!D)&&D.mode==="file"&&D.targetPath){p(n,D.targetPath,{allowOutsideRoot:!0});return}},[D,n,p]);const ye=c.useMemo(()=>k.filter(ge=>ge.mode==="chat"),[k]),q=P&&D?.mode==="chat"?D.id:null,we=P&&D?.mode==="chat"?ea(D.dedupeKey):null,be=Xg(ye,q);c.useEffect(()=>{if(!P||!n||!we||typeof window>"u")return;const ge=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ei(n,we,!1);return}Rd(we),ei(n,we,!0)};ge();const Ye=window.setInterval(ge,1e4);return window.addEventListener("focus",ge),window.addEventListener("blur",ge),document.addEventListener("visibilitychange",ge),()=>{window.clearInterval(Ye),window.removeEventListener("focus",ge),window.removeEventListener("blur",ge),document.removeEventListener("visibilitychange",ge),ei(n,we,!1)}},[we,n,P]);const Ne=c.useCallback((ge,Ye,bt)=>Jg(pe.current,ge,Ye,n||null,bt,{mode:b,lightThemeId:v,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:m}),[m,C,N,n,v,b]),ie=be&&we?Ne(be.id,we,be.readOnly):null;c.useEffect(()=>{const ge=new Set(k.map(Ye=>Ye.id));for(const Ye of pe.current.keys())ge.has(Ye)||pe.current.delete(Ye)},[k]);const ee=c.useCallback(ge=>{!n||D?.mode!=="diff"||l(n,{mode:"diff",targetPath:D.targetPath,stagedDiff:ge==="staged",diffScope:ge})},[D,n,l]),V=c.useCallback(()=>{if(typeof window>"u")return;const ge={themeMode:b,lightThemeId:v,darkThemeId:N,currentTheme:C};for(const Ye of K.current.values()){const bt=Ye.contentWindow;bt&&bt.postMessage({type:"aiworker:theme-sync",payload:ge},window.location.origin)}},[C,N,v,b]),$=c.useCallback(()=>{if(typeof window>"u")return;const ge={allowPromptingSubagentSessions:m};for(const Ye of K.current.values()){const bt=Ye.contentWindow;bt&&bt.postMessage({type:"aiworker:chat-settings-sync",payload:ge},window.location.origin)}},[m]),ae=c.useCallback((ge,Ye,bt)=>{const jt=Ye.contentWindow;jt&&jt.postMessage({type:gu,payload:{visible:q===ge}},bt)},[q]),W=c.useCallback(()=>{if(!(typeof window>"u"))for(const[ge,Ye]of K.current.entries())ae(ge,Ye,window.location.origin)},[ae]);c.useEffect(()=>{if(typeof window>"u")return;const ge=Ye=>{if(Ye.origin!==window.location.origin)return;const bt=Array.from(K.current.entries()).find(([,$e])=>$e.contentWindow===Ye.source);if(!bt)return;const jt=Ye.data;if(jt?.type===Zg){const[$e,J]=bt;ae($e,J,Ye.origin);return}if(jt?.type===ex){if(typeof jt.requestId!="string"||!jt.requestId)return;const $e=us(),J={apiBaseUrl:Nn(),clientToken:$r(),localOrigin:typeof window.__AIWORKER_LOCAL_ORIGIN__=="string"?window.__AIWORKER_LOCAL_ORIGIN__:"",runtimeHeaders:fd(),relayHostId:$e.startsWith("host:")?$e.slice(5):"",relay:am()??void 0};Ye.source?.postMessage({type:tx,requestId:jt.requestId,payload:J},Ye.origin);return}if(jt?.type==="aiworker:theme-sync-request"){V();return}if(jt?.type==="aiworker:chat-settings-request"){$();return}if(jt?.type!=="aiworker:cycle-theme-request")return;const fe=["light","dark","system"],it=(fe.indexOf(b)+1)%fe.length;y(fe[it])};return window.addEventListener("message",ge),()=>window.removeEventListener("message",ge)},[$,ae,V,y,b]),c.useLayoutEffect(()=>{k.some(Ye=>Ye.mode==="chat")&&(V(),$(),W())},[N,v,$,W,V,k,b]);const ve=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",Fe=c.useMemo(()=>D?k.filter(ge=>ge.mode===D.mode):[],[D,k]),Ce=c.useMemo(()=>Fe.map(ge=>{const Ye=sS(ge,X,t),bt=dS(Ye,Xw),jt=eS(ge.targetPath,e);return{id:ge.id,label:bt,icon:cc(ge,x),title:jt?`${Ye}: ${jt}`:Ye,closeLabel:t("contextPanel.tab.closeTabAria",{label:bt})}}),[Fe,e,x,X,t]),ke=D?.mode==="context"?s.jsx(Uy,{}):D?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kw,{isActive:P})}):D?.mode==="pr"?s.jsx(Jb,{}):D?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hw,{})}):D?.mode==="notes"?s.jsx(ug,{}):D?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Gw,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,Qe=c.useMemo(()=>k.filter(ge=>ge.mode==="browser"),[k]),We=c.useMemo(()=>k.filter(ge=>ge.mode==="diff"),[k]),z=c.useMemo(()=>k.find(ge=>ge.mode==="terminal")??null,[k]),he=c.useMemo(()=>k.some(ge=>ge.mode==="walkthrough"),[k]),Be=c.useMemo(()=>k.some(ge=>ge.mode==="file"),[k]),Ae=c.useMemo(()=>k.some(ge=>ge.mode==="file"&&ge.targetPath),[k]),at=D?.mode==="file",Ue=Te(ge=>ge.closeContextPanelTabs),ht=c.useCallback(ge=>{if(!n)return null;const{id:Ye,index:bt,allIds:jt,close:fe}=ge,ze=()=>Ue(n,jt.filter(Ve=>Ve!==Ye)),it=()=>Ue(n,jt.slice(0,bt)),$e=()=>Ue(n,jt.slice(bt+1)),J=()=>Ue(n,jt),re=jt.length>1,Pe=bt===0,_e=bt===jt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Un,{onClick:fe,children:[s.jsx(E,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Oi,{}),s.jsxs(Un,{onClick:ze,disabled:!re,children:[s.jsx(E,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Un,{onClick:it,disabled:Pe,children:[s.jsx(E,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Un,{onClick:$e,disabled:_e,children:[s.jsx(E,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Oi,{}),s.jsxs(Un,{onClick:J,disabled:!re,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Ue,n,t]),ut=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ve?s.jsx(su,{items:Ce,activeId:D?.id??null,onSelect:ge=>{n&&d(n,ge)},onClose:ge=>{n&&o(n,ge)},onReorder:(ge,Ye)=>{n&&f(n,ge,Ye)},layoutMode:"scrollable",variant:"default",tabContextMenu:ht}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[D?cc(D,x):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?of(D.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?.mode==="browser"?s.jsx(xt,{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(E,{name:"add",className:"h-3.5 w-3.5"})}):null,at?s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":g,children:s.jsx(E,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:me,className:"h-7 w-7 p-0",title:t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:I?s.jsx(E,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:Oe,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ct=P?I?{"--oc-context-panel-width":M!==null?`${M}px`:"100%",width:M!==null?`${M}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${A}px`}:{"--oc-context-panel-width":`${A}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:Se,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:Ie("flex min-h-0 flex-col overflow-hidden bg-background",I?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Re,style:Ct,children:[P&&!I&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!I&&s.jsx("div",{className:Ie("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",H&&"bg-[var(--interactive-border)]"),onPointerDown:de,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Ie("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]",!P&&"pointer-events-none select-none opacity-0"),style:{width:I?M!==null?`${M}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[ut,s.jsxs("div",{className:Ie("relative min-h-0 flex-1 overflow-hidden",H&&"pointer-events-none"),children:[Be?s.jsxs("div",{className:Ie("absolute inset-0 flex",at?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:Ae?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uw,{mode:"editor-only",visible:P&&at})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(E,{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")})]})}),s.jsx(iS,{visible:g,active:P&&at})]}):null,be&&we&&ie?s.jsx("iframe",{ref:ge=>{if(!ge){K.current.delete(be.id);return}K.current.set(be.id,ge)},src:ie,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:we}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{V(),$(),W()}},be.id):null,Qe.map(ge=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==ge.id&&"hidden"),children:s.jsx(Bw,{initialUrl:ge.targetPath??"",directory:n,tabID:ge.id})},ge.id)),We.map(ge=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==ge.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vw,{visible:P&&D?.id===ge.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:ge.diffScope??(ge.stagedDiff?"staged":"working"),onDiffScopeChange:ee,targetFilePath:ge.targetPath,flushContent:!0})})},ge.id)),z?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:s.jsx(fg,{visible:P&&D?.mode==="terminal",directory:z.targetDirectory})}):null,he?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(zw,{directory:e,visible:P&&D?.mode==="walkthrough"})})}):null,D?.mode!=="chat"&&!at&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"?ke:null]})]})]})},fS=t=>{const e=st.c(42),{open:n,onOpenChange:r}=t,{t:i}=Nt(),o=Te(mS),l=Te(hS),a=Te(pS),u=Te(gS);let d;e[0]!==o?(d=Ed(o),e[0]=o,e[1]=d):d=e[1];const h=d,f=l.length===0;let p;if(e[2]!==l||e[3]!==h){let D;e[5]!==l?(D=P=>l.includes(P.id),e[5]=l,e[6]=D):D=e[6],p=h.every(D),e[2]=l,e[3]=h,e[4]=p}else p=e[4];const g=p;let w;e[7]!==i?(w=i("contextRail.configure.dialogTitle"),e[7]=i,e[8]=w):w=e[8];let S;e[9]!==w?(S=s.jsx(Rs,{children:w}),e[9]=w,e[10]=S):S=e[10];let x;e[11]!==i?(x=i("contextRail.configure.dialogDescription"),e[11]=i,e[12]=x):x=e[12];let m;e[13]!==x?(m=s.jsx(Es,{children:x}),e[13]=x,e[14]=m):m=e[14];let b;e[15]!==S||e[16]!==m?(b=s.jsxs($s,{children:[S,m]}),e[15]=S,e[16]=m,e[17]=b):b=e[17];let y;if(e[18]!==l||e[19]!==a||e[20]!==h||e[21]!==i){let D;e[23]!==l||e[24]!==a||e[25]!==i?(D=P=>s.jsx(rh,{settingsItem:`layout.context-rail.surface.${P.id}`,checked:!l.includes(P.id),onChange:I=>a(P.id,I),label:i(P.labelKey),ariaLabel:i(P.labelKey)},P.id),e[23]=l,e[24]=a,e[25]=i,e[26]=D):D=e[26],y=h.map(D),e[18]=l,e[19]=a,e[20]=h,e[21]=i,e[22]=y}else y=e[22];let v;e[27]!==y?(v=s.jsx("div",{className:"flex flex-col",children:y}),e[27]=y,e[28]=v):v=e[28];let N;e[29]!==f||e[30]!==g||e[31]!==u||e[32]!==i?(N=f?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[g?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(xt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[29]=f,e[30]=g,e[31]=u,e[32]=i,e[33]=N):N=e[33];let C;e[34]!==N||e[35]!==b||e[36]!==v?(C=s.jsxs(js,{className:"max-w-md",children:[b,v,N]}),e[34]=N,e[35]=b,e[36]=v,e[37]=C):C=e[37];let k;return e[38]!==r||e[39]!==n||e[40]!==C?(k=s.jsx(vs,{open:n,onOpenChange:r,children:C}),e[38]=r,e[39]=n,e[40]=C,e[41]=k):k=e[41],k};function mS(t){return t.contextRailOrder}function hS(t){return t.contextRailHiddenSurfaces}function pS(t){return t.setContextRailSurfaceVisible}function gS(t){return t.setContextRailHiddenSurfaces}const af=150,xS=500,bS=[],yS=t=>t>99?"99+":String(t),wS=t=>{const e=st.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:f,onSelect:p}=t;let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:w,listeners:S,setNodeRef:x,transform:m,transition:b,isDragging:y}=Qo(g);let v;e[2]!==a?(v=a!=null&&a>0?yS(a):null,e[2]=a,e[3]=v):v=e[3];const N=v;let C;e[4]!==m?(C=Yo.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let k;e[6]!==C||e[7]!==b?(k={transform:C,transition:b},e[6]=C,e[7]=b,e[8]=k):k=e[8];const D=y&&"z-10 opacity-70";let P;e[9]!==D?(P=Ie("relative",D),e[9]=D,e[10]=P):P=e[10];let I;e[11]!==p||e[12]!==n?(I=()=>p(n),e[11]=p,e[12]=n,e[13]=I):I=e[13];const M=u??o,_=r?"text-primary":"text-muted-foreground hover:text-foreground";let O;e[14]!==_?(O=Ie("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",_),e[14]=_,e[15]=O):O=e[15];let U;e[16]!==n.icon||e[17]!==n.id?(U=n.id==="diff"?s.jsx(Eu,{}):s.jsx(E,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=U):U=e[18];let L;e[19]!==N||e[20]!==h||e[21]!==i||e[22]!==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}):N?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:N}):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[19]=N,e[20]=h,e[21]=i,e[22]=f,e[23]=L):L=e[23];let F;e[24]!==w||e[25]!==r||e[26]!==S||e[27]!==O||e[28]!==U||e[29]!==L||e[30]!==I||e[31]!==M?(F=s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...S,onClick:I,"aria-label":M,"aria-pressed":r,className:O,children:[U,L]})}),e[24]=w,e[25]=r,e[26]=S,e[27]=O,e[28]=U,e[29]=L,e[30]=I,e[31]=M,e[32]=F):F=e[32];let R;e[33]!==o?(R=s.jsx("span",{children:o}),e[33]=o,e[34]=R):R=e[34];let j;e[35]!==l?(j=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[35]=l,e[36]=j):j=e[36];let A;e[37]!==d?(A=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[37]=d,e[38]=A):A=e[38];let B;e[39]!==R||e[40]!==j||e[41]!==A?(B=s.jsx(Pt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[R,j,A]})}),e[39]=R,e[40]=j,e[41]=A,e[42]=B):B=e[42];let X;e[43]!==F||e[44]!==B?(X=s.jsxs(At,{delayDuration:af,children:[F,B]}),e[43]=F,e[44]=B,e[45]=X):X=e[45];let H;return e[46]!==x||e[47]!==X||e[48]!==k||e[49]!==P?(H=s.jsx("div",{ref:x,style:k,className:P,children:X}),e[46]=x,e[47]=X,e[48]=k,e[49]=P,e[50]=H):H=e[50],H},SS=()=>{const t=st.c(86),{t:e}=Nt(),n=er();let r;t[0]!==n?(r=n?or(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=we=>i?we.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Te(o),a=Te(vS),u=Te(jS),d=Te(kS),h=Te(CS),f=Te(NS),p=Te(AS),g=Te(DS),w=ba(PS),S=Ni(IS),x=Ni(TS),m=An(RS),b=An(ES),{screenWidth:y}=_n(),v=ya(i||null);let N;t[4]!==g?(N=Ai("switch_context_surface",g),t[4]=g,t[5]=N):N=t[5];const C=N,[k,D]=c.useState(!1);let P,I;t[6]!==C?(P=()=>{const we=new Set;let be=null,Ne=!1;const ie=MS,ee=()=>{rl(C,we)?!Ne&&be===null&&(be=setTimeout(()=>D(!0),xS)):(Ne=!1,be!==null&&(clearTimeout(be),be=null),D(!1))},V=W=>{if(we.add(W.key.toLowerCase()),ie(W.key)&&rl(C,we)){Ne=!0,be!==null&&(clearTimeout(be),be=null),D(!1);return}ee()},$=W=>{we.delete(W.key.toLowerCase()),ee()},ae=()=>{we.clear(),Ne=!1,be!==null&&(clearTimeout(be),be=null),D(!1)};return window.addEventListener("keydown",V,!0),window.addEventListener("keyup",$,!0),window.addEventListener("blur",ae),()=>{window.removeEventListener("keydown",V,!0),window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",ae),be!==null&&clearTimeout(be)}},I=[C],t[6]=C,t[7]=P,t[8]=I):(P=t[7],I=t[8]),c.useEffect(P,I);let M;t[9]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{distance:8}},t[9]=M):M=t[9];let _;t[10]===Symbol.for("react.memo_cache_sentinel")?(_={activationConstraint:{delay:200,tolerance:6}},t[10]=_):_=t[10];const O=Vr(On(cu,M),On(lu,_)),U=l?.tabs??bS;let L;t[11]!==l?.activeTabId||t[12]!==U?(L=U.find(we=>we.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=U,t[13]=L):L=t[13];const F=L,R=l?.isOpen?F?.mode??null:null,j=v?.files.length??0;let A;t[14]!==d||t[15]!==u||t[16]!==b||t[17]!==x||t[18]!==w||t[19]!==y||t[20]!==U?(A=oh({railOrder:u,hiddenSurfaces:d,planModeEnabled:w,isVSCode:Pn(),screenWidth:y,tabs:U,linearConnected:x,githubConnected:b}),t[14]=d,t[15]=u,t[16]=b,t[17]=x,t[18]=w,t[19]=y,t[20]=U,t[21]=A):A=t[21];const B=A;let X,H;t[22]!==R||t[23]!==p||t[24]!==i||t[25]!==S||t[26]!==x?(H=()=>{!i||!S||x||R!=="linear"||p(i)},X=[R,p,i,S,x],t[22]=R,t[23]=p,t[24]=i,t[25]=S,t[26]=x,t[27]=X,t[28]=H):(X=t[27],H=t[28]),c.useEffect(H,X);let Z,ce;t[29]!==R||t[30]!==p||t[31]!==i||t[32]!==m||t[33]!==b?(Z=()=>{!i||!m||b||R!=="pr"||p(i)},ce=[R,p,i,m,b],t[29]=R,t[30]=p,t[31]=i,t[32]=m,t[33]=b,t[34]=Z,t[35]=ce):(Z=t[34],ce=t[35]),c.useEffect(Z,ce);const[Y,se]=c.useState(!1);let oe;t[36]!==h?(oe=we=>{const{active:be,over:Ne}=we;if(!Ne||be.id===Ne.id)return;const ie=Ed(Te.getState().contextRailOrder).map(OS),ee=ie.indexOf(be.id),V=ie.indexOf(Ne.id);ee===-1||V===-1||h(du(ie,ee,V))},t[36]=h,t[37]=oe):oe=t[37];const Se=oe;if(!i)return null;let K;t[38]!==e?(K=e("contextRail.aria.rail"),t[38]=e,t[39]=K):K=t[39];let pe;t[40]!==B?(pe=B.map(FS),t[40]=B,t[41]=pe):pe=t[41];let je;if(t[42]!==R||t[43]!==j||t[44]!==i||t[45]!==f||t[46]!==k||t[47]!==B||t[48]!==e||t[49]!==a){let we;t[51]!==R||t[52]!==j||t[53]!==i||t[54]!==f||t[55]!==k||t[56]!==e||t[57]!==a?(we=(be,Ne)=>{const ie=e(be.labelKey),ee=be.id==="git"&&!a?j:0,V=ee>0?ee:null;return s.jsx(wS,{surface:be,isActive:R===be.mode,showActivityDot:!1,label:ie,description:e(be.descriptionKey),badgeCount:V,badgeAriaLabel:V!==null?e(V===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ie,count:V}):null,badgeDescription:V!==null?e(V===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:V}):null,orderNumber:Ne+1,showOrderNumber:k,onSelect:$=>f(i,$.mode)},be.id)},t[51]=R,t[52]=j,t[53]=i,t[54]=f,t[55]=k,t[56]=e,t[57]=a,t[58]=we):we=t[58],je=B.map(we),t[42]=R,t[43]=j,t[44]=i,t[45]=f,t[46]=k,t[47]=B,t[48]=e,t[49]=a,t[50]=je}else je=t[50];let ne;t[59]!==pe||t[60]!==je?(ne=s.jsx(Io,{items:pe,strategy:_i,children:je}),t[59]=pe,t[60]=je,t[61]=ne):ne=t[61];let T;t[62]!==Se||t[63]!==O||t[64]!==ne?(T=s.jsx(Ur,{sensors:O,collisionDetection:Kr,onDragEnd:Se,children:ne}),t[62]=Se,t[63]=O,t[64]=ne,t[65]=T):T=t[65];let G;t[66]!==e?(G=e("contextRail.configure.open"),t[66]=e,t[67]=G):G=t[67];let le;t[68]===Symbol.for("react.memo_cache_sentinel")?(le=()=>se(!0),t[68]=le):le=t[68];let de;t[69]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(E,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[69]=de):de=t[69];let ue;t[70]!==G?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":G,onClick:le,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:de})}),t[70]=G,t[71]=ue):ue=t[71];let Oe;t[72]!==e?(Oe=e("contextRail.configure.open"),t[72]=e,t[73]=Oe):Oe=t[73];let me;t[74]!==Oe?(me=s.jsx(Pt,{side:"left",sideOffset:8,children:Oe}),t[74]=Oe,t[75]=me):me=t[75];let Re;t[76]!==ue||t[77]!==me?(Re=s.jsxs(At,{delayDuration:af,children:[ue,me]}),t[76]=ue,t[77]=me,t[78]=Re):Re=t[78];let ye;t[79]!==Y?(ye=s.jsx(fS,{open:Y,onOpenChange:se}),t[79]=Y,t[80]=ye):ye=t[80];let q;return t[81]!==K||t[82]!==T||t[83]!==Re||t[84]!==ye?(q=s.jsxs("nav",{"aria-label":K,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[T,Re,ye]}),t[81]=K,t[82]=T,t[83]=Re,t[84]=ye,t[85]=q):q=t[85],q};function vS(t){return t.workStatusPanelVisible}function jS(t){return t.contextRailOrder}function kS(t){return t.contextRailHiddenSurfaces}function CS(t){return t.setContextRailOrder}function NS(t){return t.openContextSurface}function AS(t){return t.closeContextPanel}function DS(t){return t.shortcutOverrides}function PS(t){return t.planModeEnabled}function IS(t){return t.hasChecked}function TS(t){return t.status?.connected===!0}function RS(t){return t.hasChecked}function ES(t){return t.status?.connected===!0}function MS(t){return t.length===1&&t>="0"&&t<="9"}function OS(t){return t.id}function FS(t){return t.id}const BS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),_S=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Er(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),LS=new Set,$S=[],ta=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},WS=()=>{const t=st.c(182),{t:e}=Nt(),n=Te(zS),r=Te(VS),i=Te(US),o=Te(KS),l=Te(HS),a=Te(GS),u=Te(qS),d=Te(QS),h=Te(YS),f=Te(XS),p=Te(JS),g=Te(ZS),w=Te(ev),S=Je(tv),x=Je(sv),m=Je(nv),b=Wr(rv);let y;t[0]!==n?(y=Xe=>n?Xe.activeSessions:$S,t[0]=n,t[1]=y):y=t[1];const v=Is(y);let N;t[2]!==n?(N=Xe=>n?Xe.ids:LS,t[2]=n,t[3]=N):N=t[3];const C=Wr(N);let k;t[4]!==n?(k=Xe=>n?Xe.rankById:Od,t[4]=n,t[5]=k):k=t[5];const D=ja(k),P=ts(ov),I=Ht(iv),M=Ht(av),_=er(),O=dd(lv),{files:U,git:L}=Sn(),F=Dn(cv),{isMobile:R}=_n();let j;t[6]!==_?(j=_?ta(_):null,t[6]=_,t[7]=j):j=t[7];const A=j,[B,X]=c.useState(""),Z=va(B,200).trim();let ce;t[8]!==B?(ce=B.trim(),t[8]=B,t[9]=ce):ce=t[9];const Y=ce;let se,oe;t[10]!==n?(se=()=>{n&&X("")},oe=[n],t[10]=n,t[11]=se,t[12]=oe):(se=t[11],oe=t[12]),c.useEffect(se,oe);let Se,K;t[13]!==v||t[14]!==F||t[15]!==L||t[16]!==n?(Se=()=>{if(!n||!L)return;const Xe=setTimeout(()=>{const nt=new Set;for(const St of v){const yt=Ts(St);!yt||nt.has(yt)||(nt.add(yt),F(yt,L))}},0);return()=>clearTimeout(Xe)},K=[n,v,L,F],t[13]=v,t[14]=F,t[15]=L,t[16]=n,t[17]=Se,t[18]=K):(Se=t[17],K=t[18]),c.useEffect(Se,K);let pe;t[19]!==r?(pe=()=>r(!1),t[19]=r,t[20]=pe):pe=t[20];const je=pe;let ne;t[21]!==je?(ne=Xe=>()=>{je(),Xe()},t[21]=je,t[22]=ne):ne=t[22];const T=ne;let G;t[23]!==I?.id||t[24]!==I?.path||t[25]!==P||t[26]!==m||t[27]!==R||t[28]!==u||t[29]!==d||t[30]!==p||t[31]!==S||t[32]!==T||t[33]!==g||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==b||t[39]!==a?(G=()=>{const Xe=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(E,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:T(()=>{l(!1),S()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(E,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:T(dv)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:T(uv)},{id:"toggle-sidebar",title:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(E,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:T(()=>{if(R){const{isSessionSwitcherOpen:nt}=Te.getState();l(!nt)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(E,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:T(()=>{P&&d(P,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(E,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:T(()=>{P&&u(P)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(E,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:T(fv)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(E,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:T(mv)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(E,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:T(()=>i(!0))}];return Xe.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(E,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:T(()=>{m&&P&&b({directory:P,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:T(()=>{m&&gn(m).then(nt=>{if(nt.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(E,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:T(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(E,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:T(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(E,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:T(()=>{P&&(w("notes"),d(P,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(E,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:T(()=>{P&&(w("todos"),d(P,"notes"))})}),Xe.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(E,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:T(hv)}),Vo()&&Xe.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(E,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:T(()=>{Mn("desktop_open_draft_mini_chat_window",{directory:ta(P||I?.path||""),projectId:I?.id??null}).catch(pv)})}),Xe},t[23]=I?.id,t[24]=I?.path,t[25]=P,t[26]=m,t[27]=R,t[28]=u,t[29]=d,t[30]=p,t[31]=S,t[32]=T,t[33]=g,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=b,t[39]=a,t[40]=G):G=t[40],I?.id,I?.path;let le;t[41]!==G?(le=G(),t[41]=G,t[42]=le):le=t[42];const de=le;let ue;t[43]===Symbol.for("react.memo_cache_sentinel")?(ue=bn(),t[43]=ue):ue=t[43];const Oe=ue;let me,Re;t[44]===Symbol.for("react.memo_cache_sentinel")?(me=Pn(),Re=!Oe&&ha(),t[44]=me,t[45]=Re):(me=t[44],Re=t[45]);let ye;t[46]!==R?(ye={isVSCode:me,isWeb:Re,isDesktop:Oe,isMobile:R},t[46]=R,t[47]=ye):ye=t[47];const q=ye;let we;if(t[48]!==T||t[49]!==i||t[50]!==o||t[51]!==q){let Xe;t[53]!==q?(Xe=St=>St.isAvailable?St.isAvailable(q):!0,t[53]=q,t[54]=Xe):Xe=t[54];let nt;t[55]!==T||t[56]!==i||t[57]!==o?(nt=St=>{const yt=hg(St.slug)??"settings-3",It=(St.keywords??[]).join(" ");return{id:`settings:${St.slug}`,title:St.title,icon:St.slug==="mcp"?s.jsx(dh,{className:"mr-2 h-4 w-4"}):s.jsx(E,{name:yt,className:"mr-2 h-4 w-4"}),searchText:`${St.title} ${St.group} ${It}`,onSelect:T(()=>{o(St.slug),i(!0)})}},t[55]=T,t[56]=i,t[57]=o,t[58]=nt):nt=t[58],we=mg.filter(gv).filter(Xe).map(nt),t[48]=T,t[49]=i,t[50]=o,t[51]=q,t[52]=we}else we=t[52];const be=we;let Ne;if(t[59]!==v||t[60]!==C||t[61]!==D){const Xe=v.filter(xv);Ne=ih(Xe,C,D),t[59]=v,t[60]=C,t[61]=D,t[62]=Ne}else Ne=t[62];const ie=Ne,ee=Md(),V=Je(bv);let $;t[63]!==ee||t[64]!==V?($=(Xe,nt)=>{const St=V.get(Xe);return St?.branch?St.branch.trim()||null:nt&&ee.get(nt)?.trim()||null},t[63]=ee,t[64]=V,t[65]=$):$=t[65];const ae=$;let W;t[66]===Symbol.for("react.memo_cache_sentinel")?(W=[],t[66]=W):W=t[66];const[ve,Fe]=c.useState(W),[Ce,ke]=c.useState(""),Qe=BS(A,Z);let We;t[67]!==A||t[68]!==Qe||t[69]!==n||t[70]!==O||t[71]!==Fe||t[72]!==ke||t[73]!==Z?(We=()=>{if(!n){Fe([]),ke("");return}if(!Qe){Fe([]),ke("");return}if(!A){Fe([]),ke("");return}let Xe=!1;return O(A,Z,40,{type:"file"}).then(nt=>{Xe||(Fe(nt.map(yv)),ke(Qe))}).catch(()=>{Xe||(Fe([]),ke(Qe))}),()=>{Xe=!0}},t[67]=A,t[68]=Qe,t[69]=n,t[70]=O,t[71]=Fe,t[72]=ke,t[73]=Z,t[74]=We):We=t[74];let z;t[75]!==A||t[76]!==Qe||t[77]!==n||t[78]!==O||t[79]!==Z?(z=[n,A,Z,Qe,O],t[75]=A,t[76]=Qe,t[77]=n,t[78]=O,t[79]=Z,t[80]=z):z=t[80],c.useEffect(We,z);const he=Y.length>0;let Be;e:{if(!he){let nt;t[81]!==de?(nt=de.filter(wv).map(Sv),t[81]=de,t[82]=nt):nt=t[82],Be=nt;break e}let Xe;t[83]!==de||t[84]!==Y?(Xe=Er(de,Y,vv,{limit:7,noFuzzy:!0}),t[83]=de,t[84]=Y,t[85]=Xe):Xe=t[85],Be=Xe}const Ae=Be;let at;e:{if(!he){let nt;t[86]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[86]=nt):nt=t[86],at=nt;break e}let Xe;t[87]!==Y||t[88]!==be?(Xe=Er(be,Y,jv,{limit:7,noFuzzy:!0}),t[87]=Y,t[88]=be,t[89]=Xe):Xe=t[89],at=Xe}const Ue=at;let ht;e:{if(!he){let nt;t[90]!==ie?(nt=ie.slice(0,5).map(kv),t[90]=ie,t[91]=nt):nt=t[91],ht=nt;break e}let Xe;t[92]!==Y||t[93]!==ie?(Xe=Er(ie,Y,Cv,{limit:7,threshold:.2}),t[92]=Y,t[93]=ie,t[94]=Xe):Xe=t[94],ht=Xe}const ut=ht;let Ct;e:{if(!n){let nt;t[95]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[95]=nt):nt=t[95],Ct=nt;break e}let Xe;t[96]!==ve||t[97]!==Ce||t[98]!==Qe||t[99]!==Z?(Xe=_S(ve,Z,Qe,Ce),t[96]=ve,t[97]=Ce,t[98]=Qe,t[99]=Z,t[100]=Xe):Xe=t[100],Ct=Xe}const ge=Ct,Ye=n&&Qe.length>0&&Ce!==Qe;let bt;e:{if(!he){let nt;t[101]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[101]=nt):nt=t[101],bt=nt;break e}let Xe;if(t[102]!==Y||t[103]!==M){const nt=M.map(Nv);Xe=Er(nt,Y,Av,{limit:7,threshold:.4}),t[102]=Y,t[103]=M,t[104]=Xe}else Xe=t[104];bt=Xe}const jt=bt;let fe,ze,it,$e,J,re,Pe,_e,Ve,Ze,lt,rt,Ge,ot;if(t[105]!==ae||t[106]!==je||t[107]!==A||t[108]!==U||t[109]!==he||t[110]!==n||t[111]!==h||t[112]!==S||t[113]!==B||t[114]!==Ae||t[115]!==ge||t[116]!==jt||t[117]!==ut||t[118]!==Ue||t[119]!==r||t[120]!==x||t[121]!==f||t[122]!==e){const Xe=Ae.map(Dv),nt=Ue.map(Pv),St=ut.map(Iv),yt=he?ge.map(Tv):[],It=he?jt.map(Rv):[];let kt;e:{if(!he){kt=["commands","sessions"];break e}const ft=Ev,ct=[{key:"commands",score:ft(Ae)},{key:"settings",score:ft(Ue)},{key:"sessions",score:ft(ut)},{key:"files",score:ft(ge)},{key:"projects",score:ft(jt)}];ct.sort(Mv),kt=ct.map(Ov)}const Et=kt,Bt=ft=>{je(),x(ft.id,Ts(ft))},zt=async ft=>{if(!A)return;const ct=await _u(U,ft,{directory:A});if(!ct.ok){Le.error(Lu(ct.reason));return}h(A,ft),je()},Gt=(ft,ct)=>{je(),S({selectedProjectId:ft,directoryOverride:ct})},rs=ft=>qn(qr(ft,f));$e=vs,rt=n,Ge=r;let _t;t[137]!==e?(_t=e("commandPalette.title"),t[137]=e,t[138]=_t):_t=t[138];let Wt;t[139]!==_t?(Wt=s.jsx(Rs,{children:_t}),t[139]=_t,t[140]=Wt):Wt=t[140];let Me;t[141]!==e?(Me=e("commandPalette.description"),t[141]=e,t[142]=Me):Me=t[142];let qe;t[143]!==Me?(qe=s.jsx(Es,{children:Me}),t[143]=Me,t[144]=qe):qe=t[144],t[145]!==Wt||t[146]!==qe?(ot=s.jsxs($s,{className:"sr-only",children:[Wt,qe]}),t[145]=Wt,t[146]=qe,t[147]=ot):ot=t[147],it=js,Ze="overflow-hidden p-0",lt=!0,ze=uh,Pe=!1,_e="[&_[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 dt;t[148]!==e?(dt=e("commandPalette.input.placeholder"),t[148]=e,t[149]=dt):dt=t[149],t[150]!==B||t[151]!==dt?(Ve=s.jsx(fh,{value:B,onValueChange:X,placeholder:dt}),t[150]=B,t[151]=dt,t[152]=Ve):Ve=t[152],fe=mh;let wt;t[153]!==e?(wt=e("commandPalette.empty.noResults"),t[153]=e,t[154]=wt):wt=t[154],t[155]!==wt?(J=s.jsx(hh,{children:wt}),t[155]=wt,t[156]=J):J=t[156],re=Et.map(ft=>ft==="commands"&&Xe.length>0?s.jsx(jr,{children:Xe.map(ct=>s.jsxs(Mr,{value:ct.id,onSelect:ct.onSelect,children:[ct.icon,s.jsx("span",{children:ct.title}),ct.shortcutId?s.jsx(ah,{children:rs(ct.shortcutId)}):null]},ct.id))},"commands"):ft==="settings"&&nt.length>0?s.jsx(jr,{children:nt.map(Fv)},"settings"):ft==="sessions"&&St.length>0?s.jsx(jr,{children:St.map(ct=>{const Vt=ct.title||e("commandPalette.session.untitled"),Xt=Ts(ct),Jt=ae(ct.id,Xt);return s.jsxs(Mr,{value:`session:${ct.id}`,onSelect:()=>Bt(ct),children:[s.jsx(E,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Vt}),Jt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:Jt})]}):null]},ct.id)})},"sessions"):ft==="files"&&yt.length>0?s.jsx(jr,{children:yt.map(ct=>{const Vt=lh(ct.relativePath||ct.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${ct.path}`,onSelect:()=>{zt(ct.path)},children:[s.jsx(Sa,{filePath:ct.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":ct.relativePath,children:Vt})]},`file:${ct.path}`)})},"files"):ft==="projects"&&It.length>0?s.jsx(jr,{children:It.map(ct=>{const Vt=ct.displayName;return s.jsxs(Mr,{value:`project:${ct.id}`,onSelect:()=>Gt(ct.id,ct.path),children:[s.jsx(E,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Vt}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:ct.path})]},`project:${ct.id}`)})},"projects"):null),t[105]=ae,t[106]=je,t[107]=A,t[108]=U,t[109]=he,t[110]=n,t[111]=h,t[112]=S,t[113]=B,t[114]=Ae,t[115]=ge,t[116]=jt,t[117]=ut,t[118]=Ue,t[119]=r,t[120]=x,t[121]=f,t[122]=e,t[123]=fe,t[124]=ze,t[125]=it,t[126]=$e,t[127]=J,t[128]=re,t[129]=Pe,t[130]=_e,t[131]=Ve,t[132]=Ze,t[133]=lt,t[134]=rt,t[135]=Ge,t[136]=ot}else fe=t[123],ze=t[124],it=t[125],$e=t[126],J=t[127],re=t[128],Pe=t[129],_e=t[130],Ve=t[131],Ze=t[132],lt=t[133],rt=t[134],Ge=t[135],ot=t[136];let Ee;t[157]!==Ye||t[158]!==e?(Ee=Ye?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=Ye,t[158]=e,t[159]=Ee):Ee=t[159];let Rt;t[160]!==fe||t[161]!==J||t[162]!==re||t[163]!==Ee?(Rt=s.jsxs(fe,{children:[J,re,Ee]}),t[160]=fe,t[161]=J,t[162]=re,t[163]=Ee,t[164]=Rt):Rt=t[164];let xe;t[165]!==ze||t[166]!==Pe||t[167]!==_e||t[168]!==Ve||t[169]!==Rt?(xe=s.jsxs(ze,{shouldFilter:Pe,className:_e,children:[Ve,Rt]}),t[165]=ze,t[166]=Pe,t[167]=_e,t[168]=Ve,t[169]=Rt,t[170]=xe):xe=t[170];let mt;t[171]!==it||t[172]!==Ze||t[173]!==lt||t[174]!==xe?(mt=s.jsx(it,{className:Ze,showCloseButton:lt,children:xe}),t[171]=it,t[172]=Ze,t[173]=lt,t[174]=xe,t[175]=mt):mt=t[175];let Tt;return t[176]!==$e||t[177]!==rt||t[178]!==Ge||t[179]!==ot||t[180]!==mt?(Tt=s.jsxs($e,{open:rt,onOpenChange:Ge,children:[ot,mt]}),t[176]=$e,t[177]=rt,t[178]=Ge,t[179]=ot,t[180]=mt,t[181]=Tt):Tt=t[181],Tt};function zS(t){return t.isCommandPaletteOpen}function VS(t){return t.setCommandPaletteOpen}function US(t){return t.setSettingsDialogOpen}function KS(t){return t.setSettingsPage}function HS(t){return t.setSessionSwitcherOpen}function GS(t){return t.toggleSidebar}function qS(t){return t.openContextOverview}function QS(t){return t.openContextSurface}function YS(t){return t.openContextFile}function XS(t){return t.shortcutOverrides}function JS(t){return t.openMultiRunLauncher}function ZS(t){return t.setArchivePageOpen}function ev(t){return t.setProjectContextTab}function tv(t){return t.openNewSessionDraft}function sv(t){return t.setCurrentSession}function nv(t){return t.currentSessionId}function rv(t){return t.toggle}function ov(t){return t.currentDirectory}function iv(t){return t.getActiveProject()}function av(t){return t.projects}function lv(t){return t.searchFiles}function cv(t){return t.ensureStatus}function dv(){Fd()}function uv(){xn.requestDirectoryDialog()}function fv(){ph.invoke("cycle_theme")}function mv(){Bd()}function hv(){window.dispatchEvent(new CustomEvent("aiworker:memory-debug-toggle"))}function pv(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function gv(t){return t.slug!=="home"}function xv(t){return!ch(t)}function bv(t){return t.worktreeMetadata}function yv(t){return{path:ta(t.path),name:t.name,relativePath:t.relativePath}}function wv(t){return!t.secondary}function Sv(t){return{item:t,score:0}}function vv(t){return t.searchText}function jv(t){return t.searchText}function kv(t){return{item:t,score:0}}function Cv(t){return t.title||""}function Nv(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Av(t){return t.searchText}function Dv(t){return t.item}function Pv(t){return t.item}function Iv(t){return t.item}function Tv(t){return t.item}function Rv(t){return t.item}function Ev(t){return t.length?t[0].score:1/0}function Mv(t,e){return t.score-e.score}function Ov(t){return t.key}function Fv(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const dc=(t,e,n)=>qn(qr(t,e),n),Bv=()=>{const t=st.c(74),{t:e}=Nt(),n=Te(_v),r=Te(Lv),i=Te($v);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Pn(),t[0]=o):o=t[0];const l=o;let a,u,d,h,f,p,g,w,S,x,m,b;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const j=[{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:[qn("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:[`${qn(Ai("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${qn(Ai("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:""}]}];d=vs,m=n,b=r,u=js,S="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let A;t[17]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(E,{name:"command",className:"h-5 w-5"}),t[17]=A):A=t[17];let B;t[18]!==e?(B=e("helpDialog.title"),t[18]=e,t[19]=B):B=t[19];let X;t[20]!==B?(X=s.jsxs(Rs,{className:"flex items-center gap-2",children:[A,B]}),t[20]=B,t[21]=X):X=t[21];let H;t[22]!==e?(H=e("helpDialog.description"),t[22]=e,t[23]=H):H=t[23];let Z;t[24]!==H?(Z=s.jsx(Es,{children:H}),t[24]=H,t[25]=Z):Z=t[25],t[26]!==X||t[27]!==Z?(x=s.jsxs($s,{children:[X,Z]}),t[26]=X,t[27]=Z,t[28]=x):x=t[28],a=cn,p="flex-1 min-h-0 mt-3",g="pr-1",w=!0,h="space-y-4",f=j.map(ce=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ce.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ce.items.filter(Y=>!(l&&Y.id==="toggle_prompt_navigator")).map(Y=>{const se=Y.id?gh(Y.id):void 0,oe=Y.descriptionKey??(se?.customizable?se.settingsLabelKey:void 0);if(!oe||Y.id&&!qr(Y.id,i))return null;const Se=Y.id?dc(Y.id,i,e("settings.aiworker.keyboardShortcuts.unassigned")):Array.isArray(Y.keys)?Y.keys:Y.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:[Y.icon&&s.jsx(E,{name:Y.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(oe)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Se)?Se:[Se]).map((K,pe)=>s.jsxs(c.Fragment,{children:[pe>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:K})]},`${K}-${pe}`))})]},Y.id||oe)})})]},ce.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=u,t[7]=d,t[8]=h,t[9]=f,t[10]=p,t[11]=g,t[12]=w,t[13]=S,t[14]=x,t[15]=m,t[16]=b}else a=t[5],u=t[6],d=t[7],h=t[8],f=t[9],p=t[10],g=t[11],w=t[12],S=t[13],x=t[14],m=t[15],b=t[16];let y;t[29]!==h||t[30]!==f?(y=s.jsx("div",{className:h,children:f}),t[29]=h,t[30]=f,t[31]=y):y=t[31];let v;t[32]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(E,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=v):v=t[32];let N;t[33]!==e?(N=e("helpDialog.proTips.title"),t[33]=e,t[34]=N):N=t[34];let C;t[35]!==N?(C=s.jsx("p",{className:"font-medium mb-1",children:N}),t[35]=N,t[36]=C):C=t[36];let k;t[37]!==i||t[38]!==e?(k=e("helpDialog.proTips.commandPalette",{shortcut:dc("open_command_palette",i,e("settings.aiworker.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=k):k=t[39];let D;t[40]!==k?(D=s.jsxs("li",{children:["• ",k]}),t[40]=k,t[41]=D):D=t[41];let P;t[42]!==e?(P=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=P):P=t[43];let I;t[44]!==P?(I=s.jsxs("li",{children:["• ",P]}),t[44]=P,t[45]=I):I=t[45];let M;t[46]!==e?(M=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=M):M=t[47];let _;t[48]!==M?(_=s.jsxs("li",{children:["• ",M]}),t[48]=M,t[49]=_):_=t[49];let O;t[50]!==D||t[51]!==I||t[52]!==_?(O=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[D,I,_]}),t[50]=D,t[51]=I,t[52]=_,t[53]=O):O=t[53];let U;t[54]!==C||t[55]!==O?(U=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[v,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,O]})]})}),t[54]=C,t[55]=O,t[56]=U):U=t[56];let L;t[57]!==a||t[58]!==y||t[59]!==U||t[60]!==p||t[61]!==g||t[62]!==w?(L=s.jsxs(a,{outerClassName:p,className:g,disableHorizontal:w,children:[y,U]}),t[57]=a,t[58]=y,t[59]=U,t[60]=p,t[61]=g,t[62]=w,t[63]=L):L=t[63];let F;t[64]!==u||t[65]!==L||t[66]!==S||t[67]!==x?(F=s.jsxs(u,{className:S,children:[x,L]}),t[64]=u,t[65]=L,t[66]=S,t[67]=x,t[68]=F):F=t[68];let R;return t[69]!==d||t[70]!==F||t[71]!==m||t[72]!==b?(R=s.jsx(d,{open:m,onOpenChange:b,children:F}),t[69]=d,t[70]=F,t[71]=m,t[72]=b,t[73]=R):R=t[73],R};function _v(t){return t.isHelpDialogOpen}function Lv(t){return t.setHelpDialogOpen}function $v(t){return t.shortcutOverrides}const Wv=()=>{const t=st.c(32),{t:e}=Nt(),n=Te(zv),r=Te(Vv),i=Te(Uv);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await gn(i)).ok){Le.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Le.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 u;t[5]!==a?(u=s.jsx(Rs,{children:a}),t[5]=a,t[6]=u):u=t[6];let d;t[7]!==e?(d=e("openCodeStatusDialog.description"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==d?(h=s.jsx(Es,{children:d}),t[9]=d,t[10]=h):h=t[10];let f;t[11]!==u||t[12]!==h?(f=s.jsxs($s,{children:[u,h]}),t[11]=u,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 g;t[16]!==l||t[17]!==p?(g=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-primary",children:p})}),t[16]=l,t[17]=p,t[18]=g):g=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let S;t[22]!==w?(S=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=S):S=t[23];let x;t[24]!==f||t[25]!==g||t[26]!==S?(x=s.jsxs(js,{className:"max-w-2xl",children:[f,g,S]}),t[24]=f,t[25]=g,t[26]=S,t[27]=x):x=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==x?(m=s.jsx(vs,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=m):m=t[31],m};function zv(t){return t.isOpenCodeStatusDialogOpen}function Vv(t){return t.setOpenCodeStatusDialogOpen}function Uv(t){return t.openCodeStatusText}const Kv=t=>{const e=st.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let u,d;e[0]!==a||e[1]!==r||e[2]!==o?(u=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},d=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=u,e[4]=d):(u=e[3],d=e[4]),c.useEffect(u,d);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("aiworker:sidebar-session-search",w),()=>window.removeEventListener("aiworker:sidebar-session-search",w)},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,g;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const w=S=>{l.current&&(l.current.contains(S.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},g=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=g):(p=e[14],g=e[15]),c.useEffect(p,g)},Hv=t=>{const e=st.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const u=new Map(l.map(Gv)),d=[];a.forEach(p=>{const g=u.get(p);g&&(d.push(g),u.delete(p))});const h=[],f=[];return l.forEach(p=>{u.has(p.id)&&(p.isArchivedBucket?f.push(p):h.push(p))}),[...h,...d,...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 Gv(t){return[t.id,t]}const ao="oc.sessions.projectCollapse",uc="oc.sessions.groupOrder",fc="oc.sessions.groupCollapse",mc=t=>{if(!t)return new Set;try{const e=Ea(br()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},qv=t=>{if(!t)return new Map;try{const e=xu(br(),Ea(br())).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}},Qv=t=>{const e=st.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=No(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>mc(o.getItem(ao)),e[1]=l):l=e[1];const[a,u]=c.useState(l);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>mc(o.getItem(fc)),e[2]=d):d=e[2];const[h,f]=c.useState(d);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>qv(o.getItem(uc)),e[3]=p):p=e[3];const[g,w]=c.useState(p),S=c.useRef(0),x=c.useRef(!1),m=c.useRef(!1),b=c.useRef(null),y=c.useRef(null);let v;e[4]!==n?(v=()=>{if(n)return;const pe=y.current;if(y.current=null,b.current=null,!pe)return;const{projects:je}=Ht.getState(),ne=je.map(T=>({...T,sidebarCollapsed:pe.has(T.id)}));Rr({projects:ne}).catch(Yv)},e[4]=n,e[5]=v):v=e[5];const N=v;let C;e[6]!==N||e[7]!==n?(C=pe=>{!globalThis.window||n||(y.current=pe,b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const k=C;let D,P;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&b.current!==null&&window.clearTimeout(b.current),b.current=null,y.current=null},P=[],e[9]=D,e[10]=P):(D=e[9],P=e[10]),c.useEffect(D,P);let I,M;e[11]!==g?(M=()=>{if(m.current)try{o.setItem(uc,JSON.stringify(Object.fromEntries(g.entries())))}catch{}},I=[g,o],e[11]=g,e[12]=I,e[13]=M):(I=e[12],M=e[13]),c.useEffect(M,I);let _,O;e[14]!==h?(_=()=>{if(x.current)try{o.setItem(fc,JSON.stringify(Array.from(h)))}catch{}},O=[h,o],e[14]=h,e[15]=_,e[16]=O):(_=e[15],O=e[16]),c.useEffect(_,O);let U;e[17]!==r||e[18]!==k?(U=()=>{S.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const pe=new Set(r.map(Xv));try{o.setItem(ao,JSON.stringify(Array.from(pe)))}catch{}return k(pe),pe})},e[17]=r,e[18]=k,e[19]=U):U=e[19];const L=U;let F;e[20]!==k?(F=()=>{S.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const pe=new Set;try{o.setItem(ao,JSON.stringify([]))}catch{}return k(pe),pe})},e[20]=k,e[21]=F):F=e[21];const R=F;let j;e[22]!==k?(j=pe=>{S.current=Date.now()+150,u(je=>{const ne=new Set(je);ne.has(pe)?ne.delete(pe):ne.add(pe);try{o.setItem(ao,JSON.stringify(Array.from(ne)))}catch{}return k(ne),ne})},e[22]=k,e[23]=j):j=e[23];const A=j;let B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=pe=>{x.current=!0,f(je=>{const ne=new Set(je);return ne.has(pe)?ne.delete(pe):ne.add(pe),ne})},e[24]=B):B=e[24];const X=B;let H;e[25]===Symbol.for("react.memo_cache_sentinel")?(H=pe=>{m.current=!0,w(pe)},e[25]=H):H=e[25];const Z=H,{getOrderedGroups:ce}=Hv(g);let Y;e[26]!==h||e[27]!==a||e[28]!==g?(Y={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:g},e[26]=h,e[27]=a,e[28]=g,e[29]=Y):Y=e[29];const se=Y;let oe;e[30]!==L||e[31]!==R||e[32]!==ce||e[33]!==k||e[34]!==A?(oe={setCollapsedProjects:u,toggleProject:A,collapseAllProjects:L,expandAllProjects:R,scheduleCollapsedProjectsPersist:k,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:Z,getOrderedGroups:ce},e[30]=L,e[31]=R,e[32]=ce,e[33]=k,e[34]=A,e[35]=oe):oe=e[35];const Se=oe;let K;return e[36]!==Se||e[37]!==se?(K={state:se,actions:Se},e[36]=Se,e[37]=se,e[38]=K):K=e[38],K};function Yv(){}function Xv(t){return t.id}const Jv=5*6e4,Zv=t=>{const e=st.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=Sn(),d=Dn(e0);let h,f;e[0]!==a||e[1]!==d||e[2]!==u||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!u||n.length===0){o(new Map);return}n.forEach(C=>{Di(()=>d(C.normalizedPath,u))})},f=[a,n,u,d,o],e[0]=a,e[1]=d,e[2]=u,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let p,g;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(k=>{C.set(k.id,i.get(k.normalizedPath)?.isGitRepo??null)}),o(C)},g=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=g):(p=e[11],g=e[12]),c.useEffect(p,g);let w;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=k=>{const D=i.get(k.normalizedPath)?.branch??"";return`${k.id}:${D}`},e[16]=i,e[17]=C):C=e[17],w=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const S=w;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const m=c.useRef(x);let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=new Map,e[19]=b):b=e[19];const y=c.useRef(b);let v;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(v=()=>{if(!a)return;let C=!1;const k=setTimeout(()=>{(async()=>{const P=new Set(n.map(t0));for(const L of m.current.keys())P.has(L)||(m.current.delete(L),y.current.delete(L));const I=Date.now(),M=n.filter(L=>{const F=i.get(L.normalizedPath);if(F?.isGitRepo===!1)return m.current.delete(L.id),y.current.delete(L.id),!1;if(F?.isGitRepo!==!0||F.branch===null)return!1;const R=F.branch.trim(),j=`${L.normalizedPath}\0${R}`,A=m.current.get(L.id);if(A===j){const B=y.current.get(L.id);return B&&(B.at=I),!1}return!(A!==void 0&&I-(y.current.get(L.id)?.at??0)<Jv)});if(M.length===0)return;const _=await xh(M,2,async L=>{const F=i.get(L.normalizedPath)?.branch?.trim()??"",R=`${L.normalizedPath}\0${F}`,j=await Di(()=>qo(L.normalizedPath,F?{knownBranch:F}:void 0)).catch(s0);return{id:L.id,inputKey:R,branch:j}});if(C)return;const O=_.filter(n0);if(O.length===0)return;const U=Date.now();l(L=>{const F=new Map(L);return O.forEach(R=>{const{id:j,branch:A}=R;A&&F.set(j,A)}),F}),O.forEach(L=>{const{id:F,inputKey:R,branch:j}=L;m.current.set(F,R),j&&y.current.set(F,{branch:j,at:U})})})()},150);return()=>{C=!0,clearTimeout(k)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=v):v=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==S||e[29]!==l?(N=[a,n,S,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=S,e[29]=l,e[30]=N):N=e[30],c.useEffect(v,N)};function e0(t){return t.ensureStatus}function t0(t){return t.id}function s0(){return null}function n0(t){return t.branch}const r0=t=>{const e=st.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(pg,{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(js,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(cn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-background",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 u;return e[6]!==r||e[7]!==n||e[8]!==a?(u=s.jsx(vs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=u):u=e[9],u},o0=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const i of t){r.has(i)||(r.add(i),n.push(i));const o=e.get(i);if(o)for(const l of o)r.has(l)||(r.add(l),n.push(l))}return n},xs=tr()((t,e)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{e().enabled||t({enabled:!0})},disable:()=>{t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{e().enabled?t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):t({enabled:!0})},toggleSelected:(n,r,i)=>{const o=e(),l=new Set(o.selectedIds);let a=o.scopeKey,u=o.anchorId;r!==null&&o.scopeKey!==null&&r!==o.scopeKey?(l.clear(),a=r,u=null):a===null&&r!==null&&(a=r);const h=i&&i.length>0?[n,...i]:[n];if(l.has(n)){for(const p of h)l.delete(p);u===n&&(u=null)}else{for(const p of h)l.add(p);u=n}l.size===0?t({selectedIds:l,scopeKey:null,anchorId:null}):t({selectedIds:l,scopeKey:a,anchorId:u})},setRange:(n,r,i,o,l)=>{const a=e();if(i.length===0)return;const u=n&&i.includes(n)?n:i[0],d=i.indexOf(u),h=i.indexOf(r);if(d<0||h<0)return;const[f,p]=d<=h?[d,h]:[h,d],g=i.slice(f,p+1),w=o0(g,l),x=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of w)x.add(m);t({selectedIds:x,scopeKey:o??a.scopeKey,anchorId:u})},replaceAll:(n,r)=>{if(n.length===0){t({selectedIds:new Set,scopeKey:null,anchorId:null});return}t({selectedIds:new Set(n),scopeKey:r,anchorId:n[0]??null})},clear:()=>{t({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{const r=e();if(r.selectedIds.size===0||n.length===0)return;const i=new Set(r.selectedIds);for(const o of n)i.delete(o);i.size!==r.selectedIds.size&&(i.size===0?t({selectedIds:i,scopeKey:null,anchorId:null}):t({selectedIds:i}))}}));function i0(t){const e=st.c(213),{t:n}=Nt(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:u,canOpenMultiRun:d,onOpenArchive:h,headerActionIconClass:f,headerActionButtonClass:p,isSessionSearchOpen:g,setIsSessionSearchOpen:w,sessionSearchInputRef:S,sessionSearchQuery:x,setSessionSearchQuery:m,hasSessionSearchQuery:b,searchMatchCount:y,collapseAllProjects:v,expandAllProjects:N}=t,C=xs(y0),k=xs(b0),D=ls(x0),P=ls(g0),I=ls(p0),M=ls(h0),_=ls(m0),O=ls(f0),U=ls(u0),L=ls(d0),F=ls(c0),R=ls(l0),j=i&&F==="single";if(r)return null;let A;e[0]!==p?(A=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=p,e[1]=A):A=e[1];let B;e[2]!==n?(B=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=B):B=e[3];let X;e[4]!==f?(X=s.jsx(E,{name:"folder-add",className:f}),e[4]=f,e[5]=X):X=e[5];let H;e[6]!==l||e[7]!==A||e[8]!==B||e[9]!==X?(H=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,className:A,"aria-label":B,children:X})}),e[6]=l,e[7]=A,e[8]=B,e[9]=X,e[10]=H):H=e[10];let Z;e[11]!==n?(Z=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=Z):Z=e[12];let ce;e[13]!==Z?(ce=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Z})}),e[13]=Z,e[14]=ce):ce=e[14];let Y;e[15]!==H||e[16]!==ce?(Y=s.jsxs(At,{children:[H,ce]}),e[15]=H,e[16]=ce,e[17]=Y):Y=e[17];let se;e[18]!==p?(se=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=p,e[19]=se):se=e[19];let oe;e[20]!==n?(oe=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=oe):oe=e[21];let Se;e[22]!==f?(Se=s.jsx(E,{name:"calendar-schedule",className:f}),e[22]=f,e[23]=Se):Se=e[23];let K;e[24]!==a||e[25]!==se||e[26]!==oe||e[27]!==Se?(K=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:se,"aria-label":oe,children:Se})}),e[24]=a,e[25]=se,e[26]=oe,e[27]=Se,e[28]=K):K=e[28];let pe;e[29]!==n?(pe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=pe):pe=e[30];let je;e[31]!==pe?(je=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:pe})}),e[31]=pe,e[32]=je):je=e[32];let ne;e[33]!==K||e[34]!==je?(ne=s.jsxs(At,{children:[K,je]}),e[33]=K,e[34]=je,e[35]=ne):ne=e[35];let T;e[36]!==p?(T=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=p,e[37]=T):T=e[37];let G;e[38]!==n?(G=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=G):G=e[39];const le=!d;let de;e[40]!==f?(de=s.jsx(bh,{className:f}),e[40]=f,e[41]=de):de=e[41];let ue;e[42]!==u||e[43]!==T||e[44]!==G||e[45]!==le||e[46]!==de?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:T,"aria-label":G,disabled:le,children:de})}),e[42]=u,e[43]=T,e[44]=G,e[45]=le,e[46]=de,e[47]=ue):ue=e[47];let Oe;e[48]!==n?(Oe=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Oe):Oe=e[49];let me;e[50]!==Oe?(me=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[50]=Oe,e[51]=me):me=e[51];let Re;e[52]!==ue||e[53]!==me?(Re=s.jsxs(At,{children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=Re):Re=e[54];let ye;e[55]!==p?(ye=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=p,e[56]=ye):ye=e[56];let q;e[57]!==n?(q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=q):q=e[58];let we;e[59]!==f?(we=s.jsx(E,{name:"archive",className:f}),e[59]=f,e[60]=we):we=e[60];let be;e[61]!==h||e[62]!==ye||e[63]!==q||e[64]!==we?(be=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:ye,"aria-label":q,children:we})}),e[61]=h,e[62]=ye,e[63]=q,e[64]=we,e[65]=be):be=e[65];let Ne;e[66]!==n?(Ne=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=Ne):Ne=e[67];let ie;e[68]!==Ne?(ie=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ne})}),e[68]=Ne,e[69]=ie):ie=e[69];let ee;e[70]!==be||e[71]!==ie?(ee=s.jsxs(At,{children:[be,ie]}),e[70]=be,e[71]=ie,e[72]=ee):ee=e[72];let V;e[73]!==ne||e[74]!==Re||e[75]!==ee||e[76]!==Y?(V=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[Y,ne,Re,ee]}),e[73]=ne,e[74]=Re,e[75]=ee,e[76]=Y,e[77]=V):V=e[77];let $;e[78]!==w?($=()=>w(a0),e[78]=w,e[79]=$):$=e[79];let ae;e[80]!==p?(ae=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=p,e[81]=ae):ae=e[81];let W;e[82]!==n?(W=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=W):W=e[83];let ve;e[84]!==f?(ve=s.jsx(E,{name:"search",className:f}),e[84]=f,e[85]=ve):ve=e[85];let Fe;e[86]!==g||e[87]!==$||e[88]!==ae||e[89]!==W||e[90]!==ve?(Fe=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,className:ae,"aria-label":W,"aria-expanded":g,children:ve})}),e[86]=g,e[87]=$,e[88]=ae,e[89]=W,e[90]=ve,e[91]=Fe):Fe=e[91];let Ce;e[92]!==n?(Ce=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=Ce):Ce=e[93];let ke;e[94]!==Ce?(ke=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ce})}),e[94]=Ce,e[95]=ke):ke=e[95];let Qe;e[96]!==Fe||e[97]!==ke?(Qe=s.jsxs(At,{children:[Fe,ke]}),e[96]=Fe,e[97]=ke,e[98]=Qe):Qe=e[98];const We=C&&"bg-interactive-hover text-primary";let z;e[99]!==p||e[100]!==We?(z=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",We),e[99]=p,e[100]=We,e[101]=z):z=e[101];let he;e[102]!==C||e[103]!==n?(he=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=he):he=e[104];let Be;e[105]!==f?(Be=s.jsx(E,{name:"checkbox-multiple",className:f}),e[105]=f,e[106]=Be):Be=e[106];let Ae;e[107]!==C||e[108]!==z||e[109]!==he||e[110]!==Be||e[111]!==k?(Ae=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:z,"aria-label":he,"aria-pressed":C,children:Be})}),e[107]=C,e[108]=z,e[109]=he,e[110]=Be,e[111]=k,e[112]=Ae):Ae=e[112];let at;e[113]!==C||e[114]!==n?(at=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=at):at=e[115];let Ue;e[116]!==at?(Ue=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:at})}),e[116]=at,e[117]=Ue):Ue=e[117];let ht;e[118]!==Ae||e[119]!==Ue?(ht=s.jsxs(At,{children:[Ae,Ue]}),e[118]=Ae,e[119]=Ue,e[120]=ht):ht=e[120];let ut;e[121]!==p?(ut=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=p,e[122]=ut):ut=e[122];let Ct;e[123]!==n?(Ct=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=Ct):Ct=e[124];let ge;e[125]!==f?(ge=s.jsx(E,{name:"equalizer-2",className:f}),e[125]=f,e[126]=ge):ge=e[126];let Ye;e[127]!==ut||e[128]!==Ct||e[129]!==ge?(Ye=s.jsx(Dt,{asChild:!0,children:s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:ut,"aria-label":Ct,children:ge})})}),e[127]=ut,e[128]=Ct,e[129]=ge,e[130]=Ye):Ye=e[130];let bt;e[131]!==n?(bt=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=bt):bt=e[132];let jt;e[133]!==bt?(jt=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:bt})}),e[133]=bt,e[134]=jt):jt=e[134];let fe;e[135]!==Ye||e[136]!==jt?(fe=s.jsxs(At,{children:[Ye,jt]}),e[135]=Ye,e[136]=jt,e[137]=fe):fe=e[137];let ze;e[138]!==n?(ze=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=ze):ze=e[139];let it;e[140]!==ze?(it=s.jsx(ho,{children:ze}),e[140]=ze,e[141]=it):it=e[141];let $e;e[142]!==I||e[143]!==M||e[144]!==n?($e=[["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(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{M(It),Rr({sidebarProjectSortOrder:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),I===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),e[142]=I,e[143]=M,e[144]=n,e[145]=$e):$e=e[145];let J;e[146]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(Os,{}),e[146]=J):J=e[146];let re;e[147]!==F||e[148]!==R||e[149]!==i||e[150]!==n?(re=i?s.jsxs(s.Fragment,{children:[s.jsx(ho,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{R(It),Rr({sidebarProjectDisplayMode:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),F===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),s.jsx(Os,{})]}):null,e[147]=F,e[148]=R,e[149]=i,e[150]=n,e[151]=re):re=e[151];let Pe;e[152]!==n?(Pe=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=Pe):Pe=e[153];let _e;e[154]!==Pe?(_e=s.jsx(ho,{children:Pe}),e[154]=Pe,e[155]=_e):_e=e[155];let Ve;e[156]!==_||e[157]!==O||e[158]!==n?(Ve=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{O(It),Rr({sidebarSessionGroupingMode:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),_===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),e[156]=_,e[157]=O,e[158]=n,e[159]=Ve):Ve=e[159];let Ze;e[160]===Symbol.for("react.memo_cache_sentinel")?(Ze=s.jsx(Os,{}),e[160]=Ze):Ze=e[160];let lt;e[161]!==j||e[162]!==o||e[163]!==D||e[164]!==n||e[165]!==P?(lt=o&&!j?s.jsxs(Kt,{onClick:()=>{P(),Rr({sidebarShowRecentSection:!D})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),D?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[161]=j,e[162]=o,e[163]=D,e[164]=n,e[165]=P,e[166]=lt):lt=e[166];let rt;e[167]!==n?(rt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=rt):rt=e[168];let Ge;e[169]!==rt?(Ge=s.jsx("span",{children:rt}),e[169]=rt,e[170]=Ge):Ge=e[170];let ot;e[171]!==U?(ot=U?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=U,e[172]=ot):ot=e[172];let Ee;e[173]!==Ge||e[174]!==ot||e[175]!==L?(Ee=s.jsxs(Kt,{onClick:L,className:"flex items-center justify-between",children:[Ge,ot]}),e[173]=Ge,e[174]=ot,e[175]=L,e[176]=Ee):Ee=e[176];let Rt;e[177]!==v||e[178]!==N||e[179]!==j||e[180]!==n?(Rt=j?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Kt,{onClick:v,className:"flex items-center gap-2",children:[s.jsx(E,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Kt,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(E,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[177]=v,e[178]=N,e[179]=j,e[180]=n,e[181]=Rt):Rt=e[181];let xe;e[182]!==it||e[183]!==$e||e[184]!==re||e[185]!==_e||e[186]!==Ve||e[187]!==lt||e[188]!==Ee||e[189]!==Rt?(xe=s.jsxs(Xs,{align:"end",className:"min-w-[180px]",children:[it,$e,J,re,_e,Ve,Ze,lt,Ee,Rt]}),e[182]=it,e[183]=$e,e[184]=re,e[185]=_e,e[186]=Ve,e[187]=lt,e[188]=Ee,e[189]=Rt,e[190]=xe):xe=e[190];let mt;e[191]!==fe||e[192]!==xe?(mt=s.jsxs(Js,{children:[fe,xe]}),e[191]=fe,e[192]=xe,e[193]=mt):mt=e[193];let Tt;e[194]!==Qe||e[195]!==ht||e[196]!==mt?(Tt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Qe,ht,mt]}),e[194]=Qe,e[195]=ht,e[196]=mt,e[197]=Tt):Tt=e[197];let Xe;e[198]!==V||e[199]!==Tt?(Xe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[V,Tt]}),e[198]=V,e[199]=Tt,e[200]=Xe):Xe=e[200];let nt;e[201]!==b||e[202]!==g||e[203]!==y||e[204]!==S||e[205]!==x||e[206]!==w||e[207]!==m||e[208]!==n?(nt=g?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[b?s.jsx("span",{children:y===1?n("sessions.sidebar.header.search.matchCountSingle",{count:y}):n("sessions.sidebar.header.search.matchCountPlural",{count:y})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:S,value:x,onChange:yt=>m(yt.target.value),placeholder:n("sessions.sidebar.header.search.placeholder"),className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50",onKeyDown:yt=>{yt.key==="Escape"&&(yt.stopPropagation(),b?m(""):w(!1))}}),x.length>0?s.jsx("button",{type:"button",onClick:()=>m(""),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 hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":n("sessions.sidebar.header.search.clear"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[201]=b,e[202]=g,e[203]=y,e[204]=S,e[205]=x,e[206]=w,e[207]=m,e[208]=n,e[209]=nt):nt=e[209];let St;return e[210]!==Xe||e[211]!==nt?(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:[Xe,nt]})}),e[210]=Xe,e[211]=nt,e[212]=St):St=e[212],St}function a0(t){return!t}function l0(t){return t.setProjectDisplayMode}function c0(t){return t.projectDisplayMode}function d0(t){return t.toggleStickyZoneHeaders}function u0(t){return t.stickyZoneHeaders}function f0(t){return t.setSessionGroupingMode}function m0(t){return t.sessionGroupingMode}function h0(t){return t.setProjectSortOrder}function p0(t){return t.projectSortOrder}function g0(t){return t.toggleRecentSection}function x0(t){return t.showRecentSection}function b0(t){return t.toggleMode}function y0(t){return t.enabled}function w0(t){const e=st.c(8),{t:n}=Nt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(E,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const mi="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-primary/50";function S0(t){const e=st.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,u=l===void 0?!0:l,d=a===void 0?!0:a,{t:h}=Nt();if(!u&&!d)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(f=u?s.jsxs(s.Fragment,{children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:mi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(E,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:mi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(E,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:mi,"aria-label":h("sessions.sidebar.footer.actions.aboutAiWorker"),children:s.jsx(E,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutAiWorker")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=h,e[5]=f):f=e[5];let p;e[6]!==o||e[7]!==d||e[8]!==h?(p=d?s.jsx(xt,{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:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=d,e[8]=h,e[9]=p):p=e[9];let g;return e[10]!==f||e[11]!==p?(g=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,p]}),e[10]=f,e[11]=p,e[12]=g):g=e[12],g}const v0=t=>{for(const e of t.sessions.values())if(e.tabs.some(md))return!0;return!1},j0=()=>{const t=st.c(4),{terminal:e}=Sn(),n=Mt(v0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=k0,l=C0;if(n)return Ei(e,"",l,o);let a=N0;return a=Ei(e,"",l,u=>{o(u),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 k0(t){const e=Mt.getState(),n=gg(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 C0(){return new Map(Mt.getState().actionMutationRevisions)}function N0(){}const A0=t=>{const e=st.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:f}=t,p=r===void 0?!0:r;let g,w;e[0]!==f||e[1]!==h||e[2]!==p||e[3]!==d||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==u?(g=()=>{!p||o||!l||a||n.forEach(S=>{if(u.has(S.normalizedPath))return;const x=_d(S.normalizedPath),m=i.archivedSessionsByProject.get(S.id)??[],b=d[x]??[],y=new Map(b.map(D0));m.forEach(v=>{const N=yh(v,S.normalizedPath),C=N.toLowerCase();let k=y.get(C);k||(k=h(x,N),y.set(C,k)),k.sessionIds.includes(v.id)||f(x,k.id,v.id)})})},w=[n,p,i,o,l,a,u,d,h,f],e[0]=f,e[1]=h,e[2]=p,e[3]=d,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=u,e[10]=g,e[11]=w):(g=e[10],w=e[11]),c.useEffect(g,w)};function D0(t){return[t.name.toLowerCase(),t]}function P0({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 d=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!d)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const u=(o&&r.has(o)?o:null)??l;return!u||u===e?{kind:"none"}:{kind:"select-session",sessionId:u}}const I0=t=>{const e=st.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let g,w;if(e[0]!==n){w=new Map,g=new Map;const C=(k,D,P,I)=>{w.has(k)||w.set(k,new Map);const M=w.get(k);I.forEach(_=>{const O=vt(_.worktree?.path??_.session.directory??P??D);M.set(_.session.id,{directory:O}),g.has(k)||g.set(k,{id:_.session.id,directory:O}),_.children.length>0&&C(k,D,O,_.children)})};n.forEach(k=>{k.groups.forEach(D=>{C(k.project.id,k.project.normalizedPath,D.directory,D.sessions)})}),e[0]=n,e[1]=g,e[2]=w}else g=e[1],w=e[2];let S;e[3]!==g||e[4]!==w?(S={metaByProject:w,firstSessionByProject:g},e[3]=g,e[4]=w,e[5]=S):S=e[5];const x=S,m=c.useRef(null);let b,y;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==u||e[11]!==h||e[12]!==d||e[13]!==f||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==p?(b=()=>{if(!r||d||Te.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(I=>I.project.id===r);if(!C)return;const k=x.metaByProject.get(r);if(l&&k&&k.has(l)){m.current=r,o(I=>{if(I.get(r)===l)return I;const M=new Map(I);return M.set(r,l),M});return}const D=P0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:k,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(D.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,D.kind==="open-draft"){h&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(D.kind!=="select-session")return;const P=k?.get(D.sessionId)?.directory??null;u(D.sessionId,P)},y=[r,i,l,a,u,d,h,f,n,x,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=u,e[11]=h,e[12]=d,e[13]=f,e[14]=n,e[15]=x,e[16]=o,e[17]=p,e[18]=b,e[19]=y):(b=e[18],y=e[19]),c.useLayoutEffect(b,y);let v,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(v=()=>{if(!r||!l)return;const C=x.metaByProject.get(r);!C||!C.has(l)||o(k=>{if(k.get(r)===l)return k;const D=new Map(k);return D.set(r,l),D})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=v,e[25]=N):(v=e[24],N=e[25]),c.useEffect(v,N)},T0=t=>{const e=st.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=Je(R0),a=Je(E0);let u;e[5]!==l||e[6]!==o?(u=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=u):u=e[7];const d=u;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 g;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(g={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=g):g=e[15],I0(g);let w,S;return e[16]!==f||e[17]!==i?(w=()=>{i(f)},S=[f,i],e[16]=f,e[17]=i,e[18]=w,e[19]=S):(w=e[18],S=e[19]),c.useEffect(w,S),null};function R0(t){return t.currentSessionId}function E0(t){return!!t.newSessionDraft?.open}const hc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function lf(t){const e=new Map,n=(r,i,o)=>{const l=vt(r??null);if(!l)return;const a=e.get(l);a&&hc[a.priority]<=hc[i]||e.set(l,{directory:l,priority:i,reason:o})};for(const r of t.knownDirectories??[])n(r,"background","known-project");n(t.activeProjectDirectory,"active-project","project-expanded");for(const r of t.projectSections??[]){const i=!t.collapsedProjects.has(r.project.id);let o="background";r.project.id===t.activeProjectId?o="active-project":i&&(o="expanded"),n(r.project.normalizedPath,o,i?"project-expanded":"known-project");for(const l of r.groups){if(!l.directory||l.isArchivedBucket||l.isMain)continue;const a=i&&!t.collapsedGroups.has(`${r.project.id}:${l.id}`);let u="background";a?u="expanded":i&&(u="visible"),n(l.directory,u,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const M0=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,pc=(t,e,n)=>{M0(t.get(e),n)&&t.set(e,n)},O0=t=>{const e=t;return vt(e.directory)??vt(e.project?.worktree)},F0=t=>{if(t==="/"||/^[A-Z]:$/.test(t))return null;const e=t.lastIndexOf("/");return e<0?null:e===0?"/":e===2&&/^[A-Z]:\//.test(t)?t.slice(0,2):t.slice(0,e)},B0=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const S=vt(w.normalizedPath);if(!S)continue;const x=l.get(S);(!x||w.id.localeCompare(x.id)<0)&&l.set(S,w),pc(o,S,{projectId:w.id,projectRoot:S,scopeDirectory:S,kind:"project"})}if(!r)for(const[w,S]of n){const x=vt(w),m=x?l.get(x):void 0;if(!(!m||!x))for(const b of S){const y=vt(b.path);y&&pc(o,y,{projectId:m.id,projectRoot:x,scopeDirectory:y,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,f=new Map,p=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const b=o.get(w)??null;return a.set(w,b),b}const S=[];let x=w,m=null;for(;x;){if(a.has(x)){m=a.get(x)??null;break}if(S.push(x),m=o.get(x)??null,m)break;x=F0(x)}for(const b of S)a.set(b,m);return m},g=(w,S,x)=>{for(const m of w){const b=p(O0(m));if(!b)continue;u.set(m.id,b);const y=S.get(b.projectId);if(y?y.push(m):S.set(b.projectId,[m]),!x)continue;const v=x.get(b.scopeDirectory);v?v.add(m.id):x.set(b.scopeDirectory,new Set([m.id]))}};return g(t,d,f),g(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},_0=t=>{const e=st.c(7),{ownership:n}=t;let r;e[0]!==n?(r=u=>n.sessionsByProject.get(u)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=u=>n.archivedSessionsByProject.get(u)??[],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},L0=(t,e)=>t.map(n=>{const r=vt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
913
913
  `),$0=[],W0=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:u,buildGroupedSessions:d,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:g,foldersMap:w,standaloneGroups:S}=t,x=c.useRef(new Map),m=c.useMemo(()=>{const P=x.current,I=new Map;let M=0,_=0;const O=(L,F)=>L.length===F.length&&L.every((R,j)=>R===F[j]),U=e.map(L=>{const F=n(L.id),R=r(L.id),j=i.get(L.normalizedPath)??$0,A=o.has(L.id)?!!o.get(L.id):u,B=l.get(L.id)??null,X=L0(j,a),H=P.get(L.id);if(H&&H.project===L&&O(H.activeSessions,F)&&O(H.archivedSessions,R)&&H.availableWorktrees===j&&H.rootBranch===B&&H.worktreeBranchesKey===X&&H.isRepo===A&&H.buildGroupedSessions===d)return M+=1,I.set(L.id,H),H.section;if(_+=1,H){const se=H.project!==L?"project":O(H.activeSessions,F)?O(H.archivedSessions,R)?H.availableWorktrees!==j?"worktrees":H.rootBranch!==B?"branch":H.worktreeBranchesKey!==X?"worktreeBranches":H.isRepo!==A?"repo":"builder":"archived":"sessions";qs(`ui.sidebar.project_section.rebuilt_reason.${se}`)}const Z=Ld([...F,...R]),ce=d(Z,L.normalizedPath,j,B,A),Y={project:L,groups:ce};return I.set(L.id,{project:L,activeSessions:F,archivedSessions:R,availableWorktrees:j,rootBranch:B,worktreeBranchesKey:X,isRepo:A,buildGroupedSessions:d,section:Y}),Y});return x.current=I,M>0&&qs("ui.sidebar.project_section.reused",M),_>0&&qs("ui.sidebar.project_section.rebuilt",_),U},[e,n,r,i,o,u,d,l,a]),b=c.useMemo(()=>m,[m]),y=c.useMemo(()=>{const P=new WeakMap;if(!h)return P;const I=f.trim().toLowerCase(),M=I.startsWith("ses_"),_=U=>U.reduce((L,F)=>L+(!M||F.session.id.toLowerCase()===I?1:0)+_(F.children),0),O=U=>{const L=p(U.sessions,f),F=_(L),R=!M&&Ao([g(U)],f),j=vt(U.directory??null),A=j?w[j]??[]:[],B=M?0:A.filter(X=>Ao([X.name],f)).length;P.set(U,{filteredNodes:L,matchedSessionCount:F,folderNameMatchCount:B,groupMatches:R,hasMatch:R||F>0||B>0})};return b.forEach(U=>{U.groups.forEach(O)}),S.forEach(O),P},[h,b,S,p,f,g,w]),v=c.useMemo(()=>h?b.map(P=>({...P,groups:P.groups.filter(I=>y.get(I)?.hasMatch===!0)})).filter(P=>P.groups.length>0):b,[h,b,y]),N=h?v:b,C=c.useRef(new WeakMap),k=c.useMemo(()=>{const P=C.current;return N.map(I=>{const M=P.get(I);if(M&&M.query===f)return M.section;const _=I.groups.filter(A=>!A.isArchivedBucket),O=I.groups.filter(A=>A.isArchivedBucket),U=_.flatMap(A=>h?y.get(A)?.filteredNodes??[]:A.sessions),L=_.map(A=>({scopeKey:A.folderScopeKey??vt(A.directory??null),directory:A.directory??null})).filter(A=>!!A.scopeKey),F=_.find(A=>A.isMain)??null,R={id:"flat",label:F?.label??"",branch:F?.branch??null,description:F?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:F?.directory??I.project.normalizedPath,folderScopeKey:F?.folderScopeKey??I.project.normalizedPath,folderScopes:L,sessions:U};if(h){const A=_.map(B=>y.get(B)).filter(B=>!!B);y.set(R,{filteredNodes:U,matchedSessionCount:A.reduce((B,X)=>B+X.matchedSessionCount,0),folderNameMatchCount:A.reduce((B,X)=>B+X.folderNameMatchCount,0),groupMatches:A.some(B=>B.groupMatches),hasMatch:A.some(B=>B.hasMatch)})}const j={project:I.project,groups:[R,...O]};return P.set(I,{query:f,section:j}),j})},[y,h,f,N]),D=c.useMemo(()=>{if(!h)return 0;const P=(M,_)=>{const O=y.get(_);if(!O)return M;const U=O.folderNameMatchCount+(O.groupMatches?1:0);return M+O.matchedSessionCount+U},I=N.reduce((M,_)=>_.groups.reduce(P,M),0);return S.reduce(P,I)},[h,N,S,y]);return{projectSections:m,visibleProjectSections:b,groupSearchDataByGroup:y,searchableProjectSections:v,sectionsForRender:N,flatSectionsForRender:k,searchMatchCount:D}},z0=180,gc=150,V0=2,U0=8,xc=[-1,1,-2,2],hi=t=>`${t.directory}
914
914
  ${t.sessionId}`,K0=t=>t?.directory?.trim()||null,H0=({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),u=c.useRef(0),d=c.useMemo(()=>Pn(),[]),h=c.useCallback(()=>{u.current+=1,l.current=[],o.current.forEach(g=>window.clearTimeout(g)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||d))for(;a.current.size<V0&&l.current.length>0;){const g=l.current.shift();if(!g)break;if(g.generation!==u.current||Je.getState().currentSessionId===g.sessionId||Pi(g.sessionId,g.directory).renderable)continue;const S=hi(g);a.current.add(S),i({directory:g.directory,sessionID:g.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(S),f()})}},[t,d,i]),p=c.useCallback(g=>{const w=g?.id,S=K0(g);if(!t||d||!w||!S||w===e)return;const x={sessionId:w,directory:S,generation:u.current},m=hi(x);if(Pi(w,S).renderable||a.current.has(m)||l.current.some(v=>hi(v)===m))return;const b=o.current.get(m);b!==void 0&&window.clearTimeout(b);const y=window.setTimeout(()=>{if(o.current.delete(m),x.generation!==u.current)return;const v=l.current;v.length>=U0&&v.shift(),v.push(x),f()},z0);o.current.set(m,y)},[e,t,d,f]);c.useEffect(()=>{h()},[h,e,t,d]),c.useEffect(()=>{if(!t||d||!e||n.length===0)return;const g=window.setTimeout(()=>{const w=n.findIndex(S=>S.id===e);if(!(w<0))for(const S of xc)p(n[w+S])},gc);return()=>window.clearTimeout(g)},[e,t,d,p,n]),c.useEffect(()=>{if(!t||d||!e||r.length===0)return;const g=window.setTimeout(()=>{const w=r.findIndex(S=>S.id===e);if(!(w<0))for(const S of xc)p(r[w+S])},gc);return()=>window.clearTimeout(g)},[e,t,d,r,p]),c.useEffect(()=>h,[h])},G0=t=>{const e=st.c(3),n=Je(q0);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],H0(r),null};function q0(t){return t.currentSessionId}const Hr=t=>{const e=st.c(13),{directory:n,className:r}=t,{t:i}=Nt();let o;e[0]!==n?(o=lm(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=S=>S.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Mt(a)?.tabs.some(md))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=Ie("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(E,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let w;return e[9]!==l||e[10]!==f||e[11]!==p?(w=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:g}),e[9]=l,e[10]=f,e[11]=p,e[12]=w):w=e[12],w},wo=t=>{const e=st.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:u,alwaysShowActions:d}=t,h=d===void 0?!1:d,{currentTheme:f}=Zn(),p=i?ka[i]:null,g=o?Ca[o]??null:null,w=u!==void 0,S=w?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let x;e[0]!==h||e[1]!==w||e[2]!==u?(x=w?s.jsx("span",{className:Ie("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(E,{name:u?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=w,e[2]=u,e[3]=x):x=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==w||e[7]!==g||e[8]!==S||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(m=l?s.jsx("span",{className:Ie("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&h?"hidden":"inline-flex",S),style:a?{backgroundColor:a}:void 0,children:s.jsx(Na,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:p?s.jsx(E,{name:p,className:"h-3.5 w-3.5",style:g?{color:g}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:g?{color:g}:void 0})})}):p?s.jsx(E,{name:p,className:Ie("h-3.5 w-3.5",S),style:g?{color:g}:void 0}):s.jsx(E,{name:"folder",className:Ie("h-3.5 w-3.5 text-muted-foreground/80",S),style:g?{color:g}:void 0}),e[4]=h,e[5]=f,e[6]=w,e[7]=g,e[8]=S,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=m):m=e[13];let b;e[14]!==x||e[15]!==m?(b=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,m]}),e[14]=x,e[15]=m,e[16]=b):b=e[16];let y;e[17]!==r?(y=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=y):y=e[18];let v;return e[19]!==b||e[20]!==y?(v=s.jsxs(s.Fragment,{children:[b,y]}),e[19]=b,e[20]=y,e[21]=v):v=e[21],v},Q0=t=>{const e=st.c(63),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:f,isRepo:p,isDesktopShell:g,hideDirectoryControls:w,alwaysShowActions:S,onToggle:x,onNewSession:m,onNewWorktreeSession:b,onManageWorktrees:y,onRenameStart:v,onClose:N,sentinelRef:C,children:k,showCreateButtons:D,hideHeader:P,statusIndicator:I,openSidebarMenuKey:M,setOpenSidebarMenuKey:_,projectPickerOptions:O,onProjectSelect:U}=t,L=r===void 0?!1:r,F=D===void 0?!0:D,R=P===void 0?!1:P,j=I===void 0?null:I,{t:A}=Nt(),B=ls(J0);let X;e[0]!==L||e[1]!==n?(X={id:n,disabled:L},e[0]=L,e[1]=n,e[2]=X):X=e[2];const{attributes:H,listeners:Z,setNodeRef:ce,transform:Y,transition:se,isDragging:oe}=Qo(X),Se=c.useRef(!1),K=`project:${n}`,pe=M===K,[je,ne]=c.useState(!1),T=!!(O&&U);let G;e[3]!==K||e[4]!==_?(G=W=>{W&&ne(!1),_(W?K:null)},e[3]=K,e[4]=_,e[5]=G):G=e[5];const le=G;let de;e[6]!==w||e[7]!==p||e[8]!==N||e[9]!==y||e[10]!==m||e[11]!==v||e[12]!==F||e[13]!==A?(de=W=>s.jsxs(s.Fragment,{children:[F&&!p&&!w&&m&&s.jsxs(W,{onClick:m,children:[s.jsx(E,{name:"add",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.newSession")]}),p&&!w&&y&&s.jsxs(W,{onClick:y,children:[s.jsx(E,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(W,{onClick:v,children:[s.jsx(E,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.edit")]}),s.jsxs(W,{onClick:N,className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=w,e[7]=p,e[8]=N,e[9]=y,e[10]=m,e[11]=v,e[12]=F,e[13]=A,e[14]=de):de=e[14];const ue=de,Oe=Z0,me=ej,Re=tj;let ye;e[15]===Symbol.for("react.memo_cache_sentinel")?(ye=W=>{(W.button===2||W.button===0&&W.ctrlKey)&&(Se.current=!0)},e[15]=ye):ye=e[15];const q=ye;let we;e[16]!==x?(we=W=>{if(W.currentTarget.blur(),Se.current){Se.current=!1;return}x()},e[16]=x,e[17]=we):we=e[17];const be=we;let Ne;e[18]!==Y?(Ne=Yo.Transform.toString(Y),e[18]=Y,e[19]=Ne):Ne=e[19];let ie;e[20]!==Ne||e[21]!==se?(ie={transform:Ne,transition:se},e[20]=Ne,e[21]=se,e[22]=ie):ie=e[22];const ee=oe&&"opacity-30";let V;e[23]!==ee?(V=Ie("relative",ee),e[23]=ee,e[24]=V):V=e[24];let $;e[25]!==S||e[26]!==H||e[27]!==le||e[28]!==be||e[29]!==w||e[30]!==R||e[31]!==n||e[32]!==f||e[33]!==je||e[34]!==g||e[35]!==pe||e[36]!==T||e[37]!==p||e[38]!==Z||e[39]!==m||e[40]!==b||e[41]!==U||e[42]!==u||e[43]!==o||e[44]!==l||e[45]!==a||e[46]!==h||e[47]!==d||e[48]!==i||e[49]!==O||e[50]!==ue||e[51]!==C||e[52]!==F||e[53]!==j||e[54]!==B||e[55]!==A?($=R?null:s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{ref:C,"data-project-id":n,className:"absolute top-0 h-px w-full pointer-events-none","aria-hidden":"true"}),s.jsxs(ou,{open:je,onOpenChange:ne,children:[s.jsx(ru,{render:s.jsx("div",{className:Ie("-ml-2.5 -mr-2 text-left group/project select-none",B&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":B?"true":void 0,onContextMenu:W=>{w||(W.preventDefault(),ne(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...H,children:[T?s.jsxs(Js,{children:[s.jsx(Ys,{asChild:!0,children:s.jsxs("button",{type:"button",className:Ie("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-[padding]",p&&!w?S||pe?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":S||pe?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":A("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h}),s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(Hr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Xs,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:O?.map(W=>s.jsxs(Kt,{onClick:()=>U?.(W.id),className:"flex items-center justify-between gap-3",title:W.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(wo,{...W})}),W.id===n?s.jsx(E,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},W.id))})]}):s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:q,onClick:be,...Z,className:Ie("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 rounded-md cursor-grab active:cursor-grabbing transition-[padding]",p&&!w?S||pe?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":S||pe?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:f,alwaysShowActions:S}),j?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:j}):null,l?s.jsx(Hr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Pt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Ie("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",F?"right-7":"right-0.5"),children:[F&&p&&!w&&b?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W=>{W.stopPropagation(),b()},className:Ie("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":A("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(E,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:A("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,w?null:s.jsxs(Js,{open:pe,onOpenChange:le,children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground",pe?"opacity-100 pointer-events-auto":S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":A("sessions.sidebar.project.actions.projectMenu"),onPointerDown:me,onMouseDown:Re,onClick:Oe,children:s.jsx(E,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Xs,{align:"end",className:"min-w-[180px]",children:ue(Kt)})]})]}),F&&m?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W=>{W.stopPropagation(),m()},className:Ie("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":A(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-4 w-4"})})}),s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:A(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(nu,{className:"min-w-[180px]",children:ue(Un)})]})]}),e[25]=S,e[26]=H,e[27]=le,e[28]=be,e[29]=w,e[30]=R,e[31]=n,e[32]=f,e[33]=je,e[34]=g,e[35]=pe,e[36]=T,e[37]=p,e[38]=Z,e[39]=m,e[40]=b,e[41]=U,e[42]=u,e[43]=o,e[44]=l,e[45]=a,e[46]=h,e[47]=d,e[48]=i,e[49]=O,e[50]=ue,e[51]=C,e[52]=F,e[53]=j,e[54]=B,e[55]=A,e[56]=$):$=e[56];let ae;return e[57]!==k||e[58]!==ce||e[59]!==ie||e[60]!==V||e[61]!==$?(ae=s.jsxs("div",{ref:ce,style:ie,className:V,children:[$,k]}),e[57]=k,e[58]=ce,e[59]=ie,e[60]=V,e[61]=$,e[62]=ae):ae=e[62],ae},Y0=t=>{const e=st.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:u,setActivatorNodeRef:d,transform:h,transition:f,isDragging:p}=Qo(l);let g;e[3]!==a||e[4]!==d?(g={listeners:a,setActivatorNodeRef:d},e[3]=a,e[4]=d,e[5]=g):g=e[5];const w=g;let S;e[6]!==h?(S=Yo.Transform.toString(h),e[6]=h,e[7]=S):S=e[7];let x;e[8]!==S||e[9]!==f?(x={transform:S,transition:f},e[8]=S,e[9]=f,e[10]=x):x=e[10];const m=p&&"opacity-50";let b;e[11]!==m?(b=Ie("space-y-0.5 rounded-md",m),e[11]=m,e[12]=b):b=e[12];let y;e[13]!==i||e[14]!==w?(y=i(w),e[13]=i,e[14]=w,e[15]=y):y=e[15];let v;return e[16]!==u||e[17]!==x||e[18]!==b||e[19]!==y?(v=s.jsx("div",{ref:u,style:x,className:b,children:y}),e[16]=u,e[17]=x,e[18]=b,e[19]=y,e[20]=v):v=e[20],v},X0=c.memo(Y0);function J0(t){return t.stickyZoneHeaders}function Z0(t){t.stopPropagation()}function ej(t){t.stopPropagation()}function tj(t){t.stopPropagation()}const sj=(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}},cf=t=>{const e=st.c(9),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==r||e[1]!==n?(l=sj(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];const a=l;let u;e[3]!==o||e[4]!==a.active?(u=p=>{if(!o)return null;for(const g of a.active){const w=p.statusById.get(g)?.status.type;if(w==="busy"||w==="retry")return"active"}return null},e[3]=o,e[4]=a.active,e[5]=u):u=e[5];const d=Aa(u);let h;e[6]!==o||e[7]!==a.unread?(h=p=>{if(!o)return null;for(const g of a.unread)if((p.index.session.unseenCount[g]??0)>0)return"unread";return null},e[6]=o,e[7]=a.unread,e[8]=h):h=e[8];const f=Da(h);return d??f};function df(t){const e=st.c(6),{state:n,activeLabel:r,unreadLabel:i,className:o}=t,l=n==="active"?r:i,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let u;e[0]!==o||e[1]!==a?(u=Ie("h-1.5 w-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=u):u=e[2];let d;return e[3]!==l||e[4]!==u?(d=s.jsx("span",{className:u,"aria-label":l,title:l}),e[3]=l,e[4]=u,e[5]=d):d=e[5],d}const nj=t=>{const e=st.c(11),{nodes:n,includeUnreadSubtasks:r}=t,{t:i}=Nt();let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=cf(o);if(!l)return null;let a;e[3]!==i?(a=i("sessions.sidebar.session.status.active"),e[3]=i,e[4]=a):a=e[4];let u;e[5]!==i?(u=i("sessions.sidebar.session.status.unread"),e[5]=i,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==u?(d=s.jsx(df,{state:l,activeLabel:a,unreadLabel:u}),e[7]=l,e[8]=a,e[9]=u,e[10]=d):d=e[10],d},rj=t=>{const e=st.c(82),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:u,onRename:d,onDelete:h,children:f,mobileVariant:p,alwaysShowActions:g,isRenaming:w,renameDraft:S,onRenameDraftChange:x,onRenameSave:m,onRenameCancel:b,droppableRef:y,isDropTarget:v,onNewSession:N,depth:C,hideActions:k,archivedBucket:D}=t,P=a===void 0?null:a,M=g===void 0?p===void 0?!1:p:g,_=w===void 0?!1:w,O=S===void 0?"":S,U=v===void 0?!1:v,L=k===void 0?!1:k,F=D===void 0?!1:D,{t:R}=Nt(),[j,A]=c.useState(!1),[B,X]=c.useState(""),H=c.useRef(null),Z=_||j,ce=_?O:B;let Y;e[0]!==n.name?(Y=()=>{X(n.name),A(!0)},e[0]=n.name,e[1]=Y):Y=e[1];const se=Y;let oe;e[2]!==ce||e[3]!==n.name||e[4]!==_||e[5]!==d||e[6]!==m?(oe=()=>{const Ce=ce.trim();Ce&&Ce!==n.name&&d(Ce),_&&m&&m(),A(!1),X("")},e[2]=ce,e[3]=n.name,e[4]=_,e[5]=d,e[6]=m,e[7]=oe):oe=e[7];const Se=oe;let K;e[8]!==_||e[9]!==b?(K=()=>{_&&b&&b(),A(!1),X("")},e[8]=_,e[9]=b,e[10]=K):K=e[10];const pe=K;let je;e[11]!==_||e[12]!==x?(je=Ce=>{_&&x?x(Ce):X(Ce)},e[11]=_,e[12]=x,e[13]=je):je=e[13];const ne=je;let T,G;e[14]!==_?(T=()=>{if(!_)return;const Ce=()=>{const We=H.current;We&&(We.focus(),We.select())},ke=requestAnimationFrame(Ce),Qe=window.setTimeout(Ce,0);return()=>{cancelAnimationFrame(ke),window.clearTimeout(Qe)}},G=[_],e[14]=_,e[15]=T,e[16]=G):(T=e[15],G=e[16]),c.useEffect(T,G);const le=l?"folder":"folder-open",de=U&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ue;e[17]!==de?(ue=Ie("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",de),e[17]=de,e[18]=ue):ue=e[18];let Oe;e[19]!==u||e[20]!==Z?(Oe=Z?void 0:Ce=>{Ce.currentTarget.blur(),u()},e[19]=u,e[20]=Z,e[21]=Oe):Oe=e[21];const me=Z?void 0:"button",Re=Z?void 0:0;let ye;e[22]!==u||e[23]!==Z?(ye=Z?void 0:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),u())},e[22]=u,e[23]=Z,e[24]=ye):ye=e[24];let q;e[25]!==n.name||e[26]!==l||e[27]!==R?(q=l?R("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):R("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=R,e[28]=q):q=e[28];const we=F?M?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":M?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let be;e[29]!==we?(be=Ie("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",we),e[29]=we,e[30]=be):be=e[30];const Ne=U?"text-primary":"text-muted-foreground";let ie;e[31]!==Ne?(ie=Ie("h-3.5 w-3.5 flex-shrink-0",Ne),e[31]=Ne,e[32]=ie):ie=e[32];let ee;e[33]!==le||e[34]!==ie?(ee=s.jsx(E,{name:le,className:ie}),e[33]=le,e[34]=ie,e[35]=ee):ee=e[35];let V;e[36]!==P||e[37]!==r||e[38]!==ce||e[39]!==n.name||e[40]!==pe||e[41]!==ne||e[42]!==Se||e[43]!==l||e[44]!==U||e[45]!==Z||e[46]!==i||e[47]!==R?(V=Z?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:ij,onMouseDown:aj,onSubmit:Ce=>{Ce.preventDefault(),Se()},children:[s.jsx("input",{ref:H,value:ce,onChange:Ce=>ne(Ce.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:R("sessions.sidebar.folderItem.namePlaceholder"),onClick:lj,onPointerDown:cj,onMouseDown:dj,onKeyDown:Ce=>{if(Ce.key==="Escape"){Ce.stopPropagation(),pe();return}(Ce.key===" "||Ce.key==="Enter")&&Ce.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:uj,onPointerDown:fj,onMouseDown:mj,children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),pe()},onPointerDown:hj,onMouseDown:pj,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:Ie("typography-ui-label font-semibold truncate",U?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(Pt,{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]}),P?s.jsx(df,{state:P,activeLabel:R("sessions.sidebar.session.status.active"),unreadLabel:R("sessions.sidebar.session.status.unread")}):null,l?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=P,e[37]=r,e[38]=ce,e[39]=n.name,e[40]=pe,e[41]=ne,e[42]=Se,e[43]=l,e[44]=U,e[45]=Z,e[46]=i,e[47]=R,e[48]=V):V=e[48];let $;e[49]!==be||e[50]!==ee||e[51]!==V?($=s.jsxs("div",{className:be,children:[ee,V]}),e[49]=be,e[50]=ee,e[51]=V,e[52]=$):$=e[52];let ae;e[53]!==M||e[54]!==F||e[55]!==n.name||e[56]!==se||e[57]!==L||e[58]!==h||e[59]!==N||e[60]!==Z||e[61]!==R?(ae=!Z&&(!L||F)?s.jsx("div",{className:Ie("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",M?"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:[!F&&N?s.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),N()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":R("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:R("sessions.sidebar.project.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-3.5 w-3.5"})}):null,F?null:s.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),se()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":R("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(E,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Ce=>{Ce.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-primary/50","aria-label":F?R("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):R("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=M,e[54]=F,e[55]=n.name,e[56]=se,e[57]=L,e[58]=h,e[59]=N,e[60]=Z,e[61]=R,e[62]=ae):ae=e[62];let W;e[63]!==y||e[64]!==ue||e[65]!==Oe||e[66]!==me||e[67]!==Re||e[68]!==ye||e[69]!==q||e[70]!==$||e[71]!==ae?(W=s.jsxs("div",{ref:y,className:ue,onClick:Oe,role:me,tabIndex:Re,onKeyDown:ye,"aria-label":q,children:[$,ae]}),e[63]=y,e[64]=ue,e[65]=Oe,e[66]=me,e[67]=Re,e[68]=ye,e[69]=q,e[70]=$,e[71]=ae,e[72]=W):W=e[72];let ve;e[73]!==f||e[74]!==l||e[75]!==i||e[76]!==o||e[77]!==R?(ve=l?null: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:R("sessions.sidebar.folderItem.emptyFolder")})]}),e[73]=f,e[74]=l,e[75]=i,e[76]=o,e[77]=R,e[78]=ve):ve=e[78];let Fe;return e[79]!==W||e[80]!==ve?(Fe=s.jsxs("div",{className:"oc-folder",children:[W,ve]}),e[79]=W,e[80]=ve,e[81]=Fe):Fe=e[81],Fe},oj=c.memo(rj);function ij(t){return t.stopPropagation()}function aj(t){return t.stopPropagation()}function lj(t){return t.stopPropagation()}function cj(t){return t.stopPropagation()}function dj(t){return t.stopPropagation()}function uj(t){return t.stopPropagation()}function fj(t){return t.stopPropagation()}function mj(t){return t.stopPropagation()}function hj(t){return t.stopPropagation()}function pj(t){return t.stopPropagation()}const gj=t=>{const e=st.c(15),{sessionId:n,sessionDirectory:r,sessionTitle:i,children:o}=t,l=`session-drag:${n}`;let a;e[0]!==r||e[1]!==n||e[2]!==i?(a={type:"session",sessionId:n,sessionDirectory:r,sessionTitle:i},e[0]=r,e[1]=n,e[2]=i,e[3]=a):a=e[3];let u;e[4]!==l||e[5]!==a?(u={id:l,data:a},e[4]=l,e[5]=a,e[6]=u):u=e[6];const{attributes:d,listeners:h,setNodeRef:f,isDragging:p}=Vg(u);let g;e[7]!==h?(g=m=>{m.stopPropagation(),h?.onPointerDown&&h.onPointerDown(m)},e[7]=h,e[8]=g):g=e[8];const w=g,S=p?"opacity-30":void 0;let x;return e[9]!==d||e[10]!==o||e[11]!==w||e[12]!==f||e[13]!==S?(x=s.jsx("div",{ref:f,...d,onPointerDown:w,className:S,children:o}),e[9]=d,e[10]=o,e[11]=w,e[12]=f,e[13]=S,e[14]=x):x=e[14],x},xj=t=>{const e=st.c(11),{folderId:n,children:r}=t,i=`folder-drop:${n}`;let o;e[0]!==n?(o={type:"folder",folderId:n},e[0]=n,e[1]=o):o=e[1];let l;e[2]!==i||e[3]!==o?(l={id:i,data:o},e[2]=i,e[3]=o,e[4]=l):l=e[4];const{setNodeRef:a,isOver:u}=Ug(l);let d;e[5]!==r||e[6]!==u||e[7]!==a?(d=r(a,u),e[5]=r,e[6]=u,e[7]=a,e[8]=d):d=e[8];let h;return e[9]!==d?(h=s.jsx(s.Fragment,{children:d}),e[9]=d,e[10]=h):h=e[10],h},bj=t=>{const e=st.c(20),{scopeKey:n,hasFolders:r,onSessionDroppedOnFolder:i,children:o}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={activationConstraint:{distance:8}},e[0]=l):l=e[0];const a=Vr(On(Fi,l)),[u,d]=c.useState(null),[h,f]=c.useState("Session"),[p,g]=c.useState(null),[w,S]=c.useState(null);if(!n){let k;return e[1]!==o?(k=s.jsx(s.Fragment,{children:o}),e[1]=o,e[2]=k):k=e[2],k}let x;e[3]!==i?(x=k=>{d(null),g(null),S(null);const{active:D,over:P}=k;if(!P)return;const I=D.data.current,M=P.data.current;I?.type==="session"&&I.sessionId&&M?.type==="folder"&&M.folderId&&i(I.sessionId,M.folderId)},e[3]=i,e[4]=x):x=e[4];const m=x;let b,y;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=k=>{const D=k.active.data.current;if(D?.type==="session"&&D.sessionId){d(D.sessionId),f(D.sessionTitle??"Session");const P=k.active.rect.current.initial?.width,I=k.active.rect.current.initial?.height;g(typeof P=="number"?P:null),S(typeof I=="number"?I:null)}},y=()=>{d(null),g(null),S(null)},e[5]=b,e[6]=y):(b=e[5],y=e[6]);let v;e[7]!==w||e[8]!==u||e[9]!==h||e[10]!==p||e[11]!==r?(v=u&&r?s.jsxs("div",{style:{width:p?`${p}px`:"auto",height:w?`${w}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(E,{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:h})]}):null,e[7]=w,e[8]=u,e[9]=h,e[10]=p,e[11]=r,e[12]=v):v=e[12];let N;e[13]!==v?(N=s.jsx(Bi,{children:v}),e[13]=v,e[14]=N):N=e[14];let C;return e[15]!==o||e[16]!==m||e[17]!==a||e[18]!==N?(C=s.jsxs(Ur,{sensors:a,collisionDetection:Kr,onDragStart:b,onDragCancel:y,onDragEnd:m,children:[o,N]}),e[15]=o,e[16]=m,e[17]=a,e[18]=N,e[19]=C):C=e[19],C},sa=(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)},Hn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Hn(n,e))return!0;return!1},yj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!wh(r),wj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,Sj=(t,e,n)=>{const r=new Map,i=o=>{const l=Ts(o.session)??vt(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}))},vj=(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})},jj=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 u=a.pop();if(!(!u||r.has(u))){r.add(u);for(const d of n.get(u)??[])a.push(d.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},kj=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(d=>[d.id,d])),i=new Map,o=new Set;for(const d of t){if(d.parentId&&!r.has(d.parentId)){o.add(d.id);continue}if(d.parentId){const p=i.get(d.parentId)??[];p.push(d.id),i.set(d.parentId,p)}const h=new Set;let f=d.id;for(;f;){if(h.has(f)){o.add(d.id);break}h.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,u=d=>{if(l.has(d))return!0;if(a.has(d))return!1;const h=r.get(d);if(!h)return!1;a.add(d);let f=o.has(d);return!f&&e.archivedBucket&&h.nodeCount===0?f=(i.get(d)??[]).some(u):(!f&&!e.searchQuery&&(f=!0),!f&&(h.nodeCount>0||!n&&Ao([h.name],e.searchQuery))&&(f=!0),f||(f=(i.get(d)??[]).some(u))),a.delete(d),f&&l.add(d),f};return t.forEach(d=>u(d.id)),new Set(t.filter(d=>l.has(d.id)).map(d=>d.id))},bc=new WeakMap;let yc=1;const Cj=t=>{const e=bc.get(t);if(e!==void 0)return e;const n=yc;return yc+=1,bc.set(t,n),n},Bo=t=>t.children.length===0?"":t.children.map(n=>{const r=Cj(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Bo(n)}`}).join("|"),uf=(t,e,n,r,i,o)=>{const l=us(),a=(u,d)=>{if(u.session.id!==d.session.id||u.children.length!==d.children.length)return!0;const h=u.session.directory??i,f=d.session.directory??o,p=ol(l,h??"",u.session.id),g=ol(l,f??"",d.session.id);return(p?n.has(p):!1)!==(g?r.has(g):!1)?!0:u.children.some((w,S)=>a(w,d.children[S]))};return a(t,e)},Nj=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,Gr=(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 d of a.children)if(l(d))return!0;return!1};return t.forEach(a=>l(a)),o};let na=!1;const ra=new Set;let wc=!1;function Aj(){for(const t of ra)t()}function za(t){na!==t&&(na=t,Aj())}function Dj(t){t.key==="Shift"&&za(!0)}function Pj(t){t.key==="Shift"&&za(!1)}function Ij(){za(!1)}function Tj(){wc||typeof window>"u"||(wc=!0,window.addEventListener("keydown",Dj),window.addEventListener("keyup",Pj),window.addEventListener("blur",Ij))}function Rj(t){return Tj(),ra.add(t),()=>{ra.delete(t)}}function Ej(){return na}function Mj(){return!1}function Oj(){return gt.useSyncExternalStore(Rj,Ej,Mj)}const Fj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,ff=/^g[1-9]\d*$/,Dr=(t,e,n,r,i)=>{if(!Fj.test(t)||e!==void 0&&!ff.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(i==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;const o=Number.parseInt(i,10);return!Number.isSafeInteger(o)||o<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:o,fusion:!1}},So=t=>{if(!t)return null;const e=t.split("/");if(e.length<3||e.length>5)return null;const[n]=e;if(e.length===3)return Dr(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,u,d]=e;return ff.test(a)?Dr(n,a,u,d,void 0):Dr(n,void 0,a,u,d)}const[,r,i,o,l]=e;return r===""?Dr(n,void 0,i,o,l):Dr(n,r,i,o,l)},Bj=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},_j=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},mf=t=>{const e=st.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:u}=Nt(),d=qt(Lj),h=qt($j),f=qt(Wj);let p;e[0]!==d?(p=d(),e[0]=d,e[1]=p):p=e[1];const g=p;let w;e[2]!==g?(w=g.filter(zj),e[2]=g,e[3]=w):w=e[3];const S=w;let x,m;e[4]!==g.length||e[5]!==h?(x=()=>{g.length===0&&h()},m=[g.length,h],e[4]=g.length,e[5]=h,e[6]=x,e[7]=m):(x=e[6],m=e[7]),c.useEffect(x,m);let b,y;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==S||e[12]!==n?(b=()=>{if(o)return;const _=n.trim();if(_.length>0&&S.some(L=>L.name===_))return;const O=typeof f=="string"&&f.trim().length>0?f.trim():null;if(O&&S.some(L=>L.name===O)){r(O);return}const U=S[0]?.name;U&&r(U)},y=[f,o,r,S,n],e[8]=f,e[9]=o,e[10]=r,e[11]=S,e[12]=n,e[13]=b,e[14]=y):(b=e[13],y=e[14]),c.useEffect(b,y);const v=n.trim().length>0?n:void 0;let N;e[15]!==i?(N=Ie("max-w-full",i),e[15]=i,e[16]=N):N=e[16];let C;e[17]!==u?(C=u("multirun.agentSelector.placeholder"),e[17]=u,e[18]=C):C=e[18];let k;e[19]!==C?(k=s.jsx(As,{placeholder:C}),e[19]=C,e[20]=k):k=e[20];let D;e[21]!==l||e[22]!==N||e[23]!==k?(D=s.jsx(Bs,{id:l,size:"lg",className:N,children:k}),e[21]=l,e[22]=N,e[23]=k,e[24]=D):D=e[24];let P;e[25]!==S?(P=S.length>0&&s.jsx(Ii,{children:S.map(Vj)}),e[25]=S,e[26]=P):P=e[26];let I;e[27]!==a||e[28]!==P?(I=s.jsx(_s,{fitContent:!0,portalToBody:a,children:P}),e[27]=a,e[28]=P,e[29]=I):I=e[29];let M;return e[30]!==o||e[31]!==r||e[32]!==v||e[33]!==D||e[34]!==I?(M=s.jsxs(Fs,{value:v,onValueChange:r,disabled:o,children:[D,I]}),e[30]=o,e[31]=r,e[32]=v,e[33]=D,e[34]=I,e[35]=M):M=e[35],M};function Lj(t){return t.getVisibleAgents}function $j(t){return t.loadAgents}function Wj(t){return t.currentAgentName}function zj(t){return $d(t.mode)}function Vj(t){return s.jsx(ss,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Uj="h-7",Lr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Kj=t=>{const e=st.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 u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Ie("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Uj),e[0]=u):u=e[0];let d;e[1]!==n.providerID?(d=s.jsx(Ti,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=d):d=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(E,{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 g;return e[8]!==d||e[9]!==h||e[10]!==p?(g=s.jsxs("div",{className:u,children:[d,h,p]}),e[8]=d,e[9]=h,e[10]=p,e[11]=g):g=e[11],g},hf=t=>{const e=st.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:u,maxModels:d,addButtonClassName:h,dropdownSide:f,dropdownClassName:p,containerClassName:g,triggerIcon:w}=t,S=u===void 0?!0:u,x=f===void 0?"top":f,{t:m}=Nt(),b=qt(Hj),y=qt(Gj),v=Te(qj),N=Te(Qj),{favoriteModelsList:C,recentModelsList:k}=Sh(),D=Te(Yj),P=Te(Xj),[I,M]=c.useState(!1),[_,O]=c.useState(""),[U,L]=c.useState(null),F=c.useRef(null),R=c.useRef(null),j=d===1,A=d===void 0||n.length<d||j;let B;if(e[0]!==n){B=new Map;for(const Ae of n){const at=`${Ae.providerID}:${Ae.modelID}`;B.set(at,(B.get(at)||0)+1)}e[0]=n,e[1]=B}else B=e[1];const X=B;let H;e[2]!==n?(H=Ae=>n.filter(Ue=>Ue.providerID===Ae.providerID&&Ue.modelID===Ae.modelID).findIndex(Ue=>Ue.instanceId===Ae.instanceId)+1,e[2]=n,e[3]=H):H=e[3];const Z=H;let ce,Y;e[4]!==x||e[5]!==I?(ce=()=>{if(!I||!R.current)return;const Ae=R.current.getBoundingClientRect();if(x==="bottom"){const ge=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Ae.bottom-16-112;L(Math.max(160,Math.min(320,ge)));return}let at=R.current.parentElement;for(;at&&!at.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const ut=getComputedStyle(at);if(ut.overflow==="auto"||ut.overflow==="hidden"||ut.overflowY==="auto"||ut.overflowY==="hidden")break;at=at.parentElement}const Ue=at?at.getBoundingClientRect().top:0,ht=Ae.top-Ue-16;L(Math.max(150,Math.min(300,ht)))},Y=[x,I],e[4]=x,e[5]=I,e[6]=ce,e[7]=Y):(ce=e[6],Y=e[7]),c.useEffect(ce,Y);let se,oe;e[8]!==A||e[9]!==I?(se=()=>{!A&&I&&(M(!1),O(""))},oe=[A,I],e[8]=A,e[9]=I,e[10]=se,e[11]=oe):(se=e[10],oe=e[11]),c.useEffect(se,oe);let Se,K;e[12]!==I?(Se=()=>{if(!I)return;const Ae=at=>{F.current&&!F.current.contains(at.target)&&(M(!1),O(""))};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},K=[I],e[12]=I,e[13]=Se,e[14]=K):(Se=e[13],K=e[14]),c.useEffect(Se,K);let pe;e[15]!==j||e[16]!==r||e[17]!==o||e[18]!==n.length?(pe=Ae=>{const at={providerID:Ae.providerID,modelID:Ae.modelID,displayName:Ae.model.name||Ae.modelID,instanceId:Lr()};j&&n.length>0&&o?o(0,at):r(at),j&&(M(!1),O(""))},e[15]=j,e[16]=r,e[17]=o,e[18]=n.length,e[19]=pe):pe=e[19];const je=pe;let ne;e[20]!==m?(ne=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=ne):ne=e[21];let T;e[22]!==m?(T=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=T):T=e[23];let G;e[24]!==m?(G=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=G):G=e[25];let le;e[26]!==m?(le=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=le):le=e[27];let de;e[28]!==m?(de=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=de):de=e[29];let ue;e[30]!==m?(ue=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=ue):ue=e[31];let Oe;e[32]!==m?(Oe=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=Oe):Oe=e[33];let me;e[34]!==m?(me=m("chat.modelControls.capabilities"),e[34]=m,e[35]=me):me=e[35];let Re;e[36]!==m?(Re=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=Re):Re=e[37];let ye;e[38]!==m?(ye=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=ye):ye=e[39];let q;e[40]!==m?(q=m("chat.modelControls.input"),e[40]=m,e[41]=q):q=e[41];let we;e[42]!==m?(we=m("chat.modelControls.output"),e[42]=m,e[43]=we):we=e[43];let be;e[44]!==m?(be=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=be):be=e[45];let Ne;e[46]!==ne||e[47]!==T||e[48]!==G||e[49]!==le||e[50]!==de||e[51]!==ue||e[52]!==Oe||e[53]!==me||e[54]!==Re||e[55]!==ye||e[56]!==q||e[57]!==we||e[58]!==be?(Ne={searchPlaceholder:ne,noResults:T,favorites:G,recent:le,keyboardHint:de,favorite:ue,unfavorite:Oe,capabilities:me,capabilityToolCalling:Re,capabilityReasoning:ye,input:q,output:we,costPerMillion:be},e[46]=ne,e[47]=T,e[48]=G,e[49]=le,e[50]=de,e[51]=ue,e[52]=Oe,e[53]=me,e[54]=Re,e[55]=ye,e[56]=q,e[57]=we,e[58]=be,e[59]=Ne):Ne=e[59];const ie=Ne;let ee;e[60]!==g?(ee=Ie("relative",g),e[60]=g,e[61]=ee):ee=e[61];const V=I?"":void 0;let $;e[62]!==h?($=Ie(Wd({size:"default"}),"w-fit",h),e[62]=h,e[63]=$):$=e[63];const ae=!A;let W;e[64]!==I?(W=()=>{M(!I)},e[64]=I,e[65]=W):W=e[65];let ve;e[66]!==w?(ve=w??s.jsx(E,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=ve):ve=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 Ce;e[71]!==V||e[72]!==$||e[73]!==ae||e[74]!==W||e[75]!==ve||e[76]!==Fe?(Ce=s.jsxs("button",{ref:R,type:"button","data-popup-open":V,className:$,disabled:ae,onClick:W,children:[ve,Fe]}),e[71]=V,e[72]=$,e[73]=ae,e[74]=W,e[75]=ve,e[76]=Fe,e[77]=Ce):Ce=e[77];let ke;e[78]!==U||e[79]!==A||e[80]!==p||e[81]!==x||e[82]!==C||e[83]!==je||e[84]!==D||e[85]!==N||e[86]!==I||e[87]!==ie||e[88]!==X||e[89]!==y||e[90]!==P||e[91]!==b||e[92]!==k||e[93]!==_||e[94]!==v?(ke=I?s.jsx("div",{className:Ie("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",x==="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(vh,{providers:b,providerOrder:P,favoriteModels:C,recentModels:k,modelsMetadata:y,hiddenModels:D,searchQuery:_,onSearchQueryChange:O,onSelect:je,labels:ie,selectionCount:Ae=>X.get(`${Ae.providerID}:${Ae.modelID}`)||0,disabled:!A,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:U?`${U}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:I,isFavorite:Ae=>N(Ae.providerID,Ae.modelID),onToggleFavorite:Ae=>v(Ae.providerID,Ae.modelID),onEscape:()=>{M(!1),O("")}})}):null,e[78]=U,e[79]=A,e[80]=p,e[81]=x,e[82]=C,e[83]=je,e[84]=D,e[85]=N,e[86]=I,e[87]=ie,e[88]=X,e[89]=y,e[90]=P,e[91]=b,e[92]=k,e[93]=_,e[94]=v,e[95]=ke):ke=e[95];let Qe;e[96]!==ee||e[97]!==Ce||e[98]!==ke?(Qe=s.jsxs("div",{className:ee,ref:F,children:[Ce,ke]}),e[96]=ee,e[97]=Ce,e[98]=ke,e[99]=Qe):Qe=e[99];let We;e[100]!==Z||e[101]!==X||e[102]!==i||e[103]!==o||e[104]!==b||e[105]!==n||e[106]!==S||e[107]!==m?(We=S&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Ae,at)=>{const Ue=`${Ae.providerID}:${Ae.modelID}`,ht=X.get(Ue)||1,ut=Z(Ae),ge=b.find(fe=>fe.id===Ae.providerID)?.models?.find(fe=>fe.id===Ae.modelID),Ye=ge?.variants?Object.keys(ge.variants):[],bt=Ye.length>0,jt=Ae.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Kj,{model:Ae,instanceIndex:ut,totalSameModel:ht,onRemove:()=>i(at)}),bt&&s.jsxs(Fs,{value:jt,onValueChange:fe=>{if(!o)return;o(at,{...Ae,variant:fe==="__default__"?void 0:fe})},children:[s.jsxs(Bs,{size:"sm",className:"gap-1.5",children:[s.jsx(E,{name:"brain-ai-3",className:Ie("h-3.5 w-3.5 flex-shrink-0",jt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(As,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:fe=>fe==="__default__"?m("multirun.modelMultiSelect.variant.default"):fe})]}),s.jsxs(_s,{fitContent:!0,children:[s.jsx(ss,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),Ye.map(Jj)]})]})]},Ae.instanceId)})}),e[100]=Z,e[101]=X,e[102]=i,e[103]=o,e[104]=b,e[105]=n,e[106]=S,e[107]=m,e[108]=We):We=e[108];let z;e[109]!==Qe||e[110]!==We?(z=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Qe,We]}),e[109]=Qe,e[110]=We,e[111]=z):z=e[111];let he;e[112]!==d||e[113]!==l||e[114]!==n.length||e[115]!==m?(he=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:d!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:d}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=d,e[113]=l,e[114]=n.length,e[115]=m,e[116]=he):he=e[116];let Be;return e[117]!==z||e[118]!==he?(Be=s.jsxs("div",{className:"space-y-2",children:[z,he]}),e[117]=z,e[118]=he,e[119]=Be):Be=e[119],Be};function Hj(t){return t.providers}function Gj(t){return t.modelsMetadata}function qj(t){return t.toggleFavoriteModel}function Qj(t){return t.isFavoriteModel}function Yj(t){return t.hiddenModels}function Xj(t){return t.providerOrder}function Jj(t){return s.jsx(ss,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Zj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
915
915
 
@@ -926,5 +926,5 @@ Now write the final fused answer.`,synthetic:!0}],directory:B??Qs.getDirectory()
926
926
  `)?(I(ht),D(!0)):D(!1);return}D(!1)},[]),Ne=gt.useCallback(z=>{b(he=>({...he,execution:{...he.execution,prompt:z}}))},[]),ie=gt.useCallback(z=>{const he=m.execution.prompt,Ae=H.current?.selectionStart??he.length,Ue=he.substring(0,Ae).lastIndexOf("@"),ht=z.relativePath&&z.relativePath.trim().length>0?z.relativePath.trim():z.path||z.name,ut=Ue!==-1?Ue:Ae,Ct=`${he.substring(0,ut)}@${ht} ${he.substring(Ae)}`,ge=ut+ht.length+2;Ne(Ct),D(!1),I(""),requestAnimationFrame(()=>{const Ye=H.current;Ye&&(Ye.selectionStart=ge,Ye.selectionEnd=ge,Ye.focus()),be(Ct,ge)})},[m.execution.prompt,Ne,be]),ee=gt.useCallback(z=>{const he=m.execution.prompt,Ae=H.current?.selectionStart??he.length,Ue=he.substring(0,Ae).lastIndexOf("@"),ht=Ue!==-1?Ue:Ae,ut=`${he.substring(0,ht)}@${z} ${he.substring(Ae)}`,Ct=ht+z.length+2;Ne(ut),D(!1),I(""),requestAnimationFrame(()=>{const ge=H.current;ge&&(ge.selectionStart=Ct,ge.selectionEnd=Ct,ge.focus()),be(ut,Ct)})},[m.execution.prompt,Ne,be]),V=gt.useCallback(z=>{const he=`/${z.name} `;Ne(he),_(!1),U(""),F(!1),requestAnimationFrame(()=>{const Be=H.current;Be&&(Be.focus(),Be.selectionStart=Be.value.length,Be.selectionEnd=Be.value.length),be(he,he.length)})},[Ne,be]),$=gt.useCallback((z,he)=>{const Be=m.execution.prompt,at=H.current?.selectionStart??Be.length,ht=Be.substring(0,at).lastIndexOf("#"),ut=ht!==-1?ht:at,Ct=`${Be.substring(0,ut)}#${he} ${Be.substring(at)}`,ge=ut+he.length+2;Ne(Ct),F(!1),j(""),requestAnimationFrame(()=>{const Ye=H.current;Ye&&(Ye.selectionStart=ge,Ye.selectionEnd=ge,Ye.focus()),be(Ct,ge)})},[m.execution.prompt,Ne,be]),ae=gt.useCallback(z=>{if(M&&ce.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")){z.preventDefault(),ce.current.handleKeyDown(z.key);return}k&&Z.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),Z.current.handleKeyDown(z.key)),L&&Y.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),Y.current.handleKeyDown(z.key))},[M,k,L]),W=gt.useCallback(async()=>{const z=x4(m,o);if(z){Le.error(z);return}const he={...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:b4(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}:{}};v(!0);try{await i(he),r(!1)}catch(Be){Le.error(Be instanceof Error?Be.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{v(!1)}},[m,r,i,o]),ve=gt.useId(),Fe=gt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Ce=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),ke=o("sessions.scheduledTasks.editor.description"),Qe=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(Ms,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Cn,{id:"sched-name",value:m.name,onChange:z=>b(he=>({...he,name:z.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(Ms,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Fs,{value:m.schedule.kind,onValueChange:z=>{b(he=>({...he,schedule:{...he.schedule,kind:z,...z==="cron"&&!he.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{children:z=>o(z==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":z==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":z==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ss,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ss,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ss,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(y4,{draft:m,setDraft:b,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:X,children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Ie(Wd({size:"default"}),"w-fit max-w-full"),onClick:()=>C(z=>!z),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(E,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:a4(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-background 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:()=>B(z=>Fc(z,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:ye,children:s.jsx(E,{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(A)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>B(z=>Fc(z,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(E,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:q.map((z,he)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:z},`${z}-${he}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:l4(A,K).map(({date:z,inCurrentMonth:he})=>{const Be=Oc(z),Ae=Be===m.schedule.onceDate,at=Wc(z,Oe),Ue=z.getTime()<Oe.getTime(),ht=Ae?"bg-interactive-selection text-interactive-selection-foreground":Ue?"text-muted-foreground/40":he?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{Ue||(we(Be),C(!1))},disabled:Ue,className:["h-8 rounded-md typography-ui-label",ht,at&&!Ae?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",Ue?"cursor-not-allowed opacity-45":""].join(" "),children:z.getDate()},Be)})}),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:Re||""}),s.jsx(xt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{we(Oc(Oe)),B(new Date(Oe.getFullYear(),Oe.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(Ms,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(Lc,{value:m.schedule.onceTime,use24Hour:Se,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:z=>b(he=>({...he,schedule:{...he.schedule,onceTime:z}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Fs,{value:m.schedule.timezone,onValueChange:z=>{b(he=>({...he,schedule:{...he.schedule,timezone:z}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{})}),s.jsx(_s,{children:la.map(z=>s.jsx(ss,{value:z,children:z},z))})]})]})]})]}):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(Ms,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:pe.map(z=>{const he=m.schedule.weekdays.includes(z.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",he?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(ur,{checked:he,onChange:Be=>G(z.value,Be),ariaLabel:z.label}),s.jsx("button",{type:"button",onClick:()=>G(z.value,!he),className:"group-hover:text-foreground",children:z.label})]},z.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((z,he)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Lc,{value:z,use24Hour:Se,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:Be=>le(he,Be)}),m.schedule.times.length>1?s.jsx(xt,{type:"button",size:"icon",variant:"ghost",onClick:()=>de(he),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]},he))}),s.jsx("div",{children:s.jsxs(xt,{type:"button",size:"sm",variant:"outline",onClick:ue,children:[s.jsx(E,{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(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Fs,{value:m.schedule.timezone,onValueChange:z=>{b(he=>({...he,schedule:{...he.schedule,timezone:z}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{})}),s.jsx(_s,{children:la.map(z=>s.jsx(ss,{value:z,children:z},z))})]})]})]}),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(Ms,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Xh,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(z,he)=>{b(Be=>({...Be,execution:{...Be.execution,providerID:z,modelID:he,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Fs,{value:T,disabled:!ne,onValueChange:z=>{b(he=>({...he,execution:{...he.execution,variant:z==="__default"?"":z}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{children:z=>z==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):z})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),je.map(z=>s.jsx(ss,{value:z,children:z},z))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Jh,{agentName:m.execution.agent,filter:z=>$d(z.mode),onChange:z=>b(he=>({...he,execution:{...he.execution,agent:z}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(lr,{id:"sched-prompt",ref:H,value:m.execution.prompt,onChange:z=>{const he=z.target.value;Ne(he);const Be=z.target.selectionStart??he.length;be(he,Be)},onKeyDown:ae,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),M?s.jsx(qd,{ref:ce,searchQuery:O,onCommandSelect:V,onClose:()=>_(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,k?s.jsx(Qd,{ref:Z,searchQuery:P,onFileSelect:ie,onAgentSelect:ee,onClose:()=>D(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,L?s.jsx(Yd,{ref:Y,searchQuery:R,onSnippetSelect:$,onClose:()=>F(!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(ur,{checked:m.execution.goalTokenBudget!==null,onChange:z=>b(he=>({...he,execution:{...he.execution,goalTokenBudget:z?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(Zh,{value:m.execution.goalTokenBudget,onValueChange:z=>{typeof z=="number"&&Number.isFinite(z)&&z>0&&b(he=>({...he,execution:{...he.execution,goalTokenBudget:Math.floor(z)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),We=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(ur,{checked:m.enabled,onChange:z=>b(he=>({...he,enabled:z})),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(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(Ec),onClick:()=>b(z=>({...z,execution:{...z.execution,permissionAutoAccept:!z.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(E,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(E,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(Pt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(Ec,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>b(z=>({...z,execution:{...z.execution,goalEnabled:!z.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(E,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(E,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(Pt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(xt,{type:"button",size:"sm",onClick:W,disabled:y,children:o(y?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return x?s.jsx(Go,{open:e,title:Ce,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:z=>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:Ce}),z]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:ke})]}),footer:We,children:Qe}):s.jsx(vs,{open:e,onOpenChange:z=>{!z&&Fe()||r(z)},children:s.jsxs(js,{"aria-describedby":ve,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Es,{id:ve,className:"sr-only",children:ke}),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(Rs,{className:"typography-ui-label font-medium text-foreground",children:Ce}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:ke})]})}),s.jsx(wa,{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:Qe})}),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:We})})]})})}function S4(t){return wr(t,{min:0,max:23})}function v4(t,e){return wr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function j4(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 k4(t){return s.jsx(ss,{value:t,children:t},t)}const C4=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))},N4=(t,e)=>{const n=C4(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:Gn(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:Gn(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:Gn(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:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},A4=(t,e)=>!t||!Number.isFinite(t)?"":ep(t,e),Vc=(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),g=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:g}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:g})}const u=Math.floor(r/l),d=Math.round(r%l/o),h=d>0?`${u}d ${d}h`:`${u}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},D4={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"}},P4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function I4(){const{t}=Nt(),e=Te(j=>j.isScheduledTasksDialogOpen),n=Te(j=>j.setScheduledTasksDialogOpen),r=Te(j=>j.isMobile),i=Te(j=>j.timeFormatPreference),o=Ht(j=>j.projects),l=Ht(j=>j.getActiveProject()),a=ts(j=>j.homeDirectory),{currentTheme:u}=Zn(),[d,h]=gt.useState(""),[f,p]=gt.useState([]),[g,w]=gt.useState(!0),[S,x]=gt.useState(!1),[m,b]=gt.useState(null),[y,v]=gt.useState(null),N=gt.useMemo(()=>o.find(j=>j.id===d)||null,[o,d]),C=gt.useCallback(j=>{const A=j.label?.trim()||Fn(j.path,a||void 0),B=j.icon?ka[j.icon]:null,X=j.color?Ca[j.color]:void 0,H=B?s.jsx(E,{name:B,className:"h-3.5 w-3.5 shrink-0",style:X?{color:X}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:X?{color:X}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[j.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:j.iconBackground?{backgroundColor:j.iconBackground}:void 0,children:s.jsx(Na,{project:{id:j.id,iconImage:j.iconImage??null},options:{themeVariant:u.metadata.variant,iconColor:u.colors.surface.foreground},className:"h-full w-full object-contain",fallback:H})}):H,s.jsx("span",{className:"truncate",children:A})]})},[a,u.metadata.variant,u.colors.surface.foreground]),k=gt.useCallback(async(j,A)=>{if(!j){p([]);return}A?.silent||w(!0);try{const B=await _g(j);B.sort((X,H)=>{if(X.enabled!==H.enabled)return X.enabled?-1:1;const Z=X.name.localeCompare(H.name);return Z!==0?Z:(X.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(H.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(B)}catch(B){Le.error(B instanceof Error?B.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),A?.silent||p([])}finally{A?.silent||w(!1)}},[t]);gt.useEffect(()=>{if(!e)return;const j=l?.id||o[0]?.id||"";h(j),j?k(j):(p([]),w(!1))},[e,l,o,k]),gt.useEffect(()=>{if(!e)return;let j=null;const A=Yr(B=>{B.type==="scheduled-task-ran"&&B.projectId===d&&(j&&clearTimeout(j),j=setTimeout(()=>{k(d,{silent:!0})},400))});return()=>{j&&clearTimeout(j),A()}},[e,d,k]);const D=gt.useCallback(async j=>{if(!d)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Nl(d,j),await k(d),Le.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[d,k,t]),P=gt.useCallback(async(j,A)=>{if(d){v(j.id),p(B=>B.map(X=>X.id===j.id?{...X,enabled:A}:X));try{j.loopFile?await Lg(d,j.id,A):await Nl(d,{...j,enabled:A}),await k(d,{silent:!0})}catch(B){Le.error(B instanceof Error?B.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await k(d,{silent:!0})}finally{v(null)}}},[d,k,t]),I=gt.useCallback(async j=>{if(!(!d||!window.confirm(j.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:j.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:j.name})))){v(j.id);try{j.loopFile?await $g(d,j.id):await Wg(d,j.id),await k(d,{silent:!0}),Le.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(B){Le.error(B instanceof Error?B.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{v(null)}}},[d,k,t]),M=gt.useCallback(j=>{if(!j.loopFile){b(j),x(!0);return}N?.path&&(n(!1),hn.getState().setSelectedPath(N.path,j.loopFile,{allowOutsideRoot:!0}),Te.getState().openContextFile(N.path,j.loopFile))},[N?.path,n]),_=gt.useCallback(async j=>{if(d){v(j.id);try{const{sessionId:A,persistError:B}=await zg(d,j.id);if(await Promise.all([k(d,{silent:!0}),Ta()]),B?Le.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Le.success(t("sessions.scheduledTasks.dialog.toast.started")),A){const X=o.find(H=>H.id===d);Je.getState().setCurrentSession(A,X?.path??null)}}catch(A){Le.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{v(null)}}},[d,o,k,t]),O=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(Fs,{value:d||"__none",onValueChange:j=>{const A=j==="__none"?"":j;h(A),A?k(A):p([])},children:[s.jsx(Bs,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(As,{children:C(N)}):s.jsx(As,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(_s,{children:[o.length===0?s.jsx(ss,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(j=>s.jsx(ss,{value:j.id,children:C(j)},j.id))]})]})]}),U=()=>{b(null),x(!0)},L=j=>{h(j),j?k(j):p([])},F=s.jsx("div",{className:"min-h-[280px]",children:g?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(E,{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(d?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(j=>{const A=y===j.id,B=j.state?.lastStatus||"idle",X=D4[B],H=t(B==="success"?"sessions.scheduledTasks.dialog.status.success":B==="error"?"sessions.scheduledTasks.dialog.status.error":B==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),Z=j.state?.nextRunAt,ce=j.state?.lastRunAt;return s.jsxs("div",{className:Ie("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Ie("min-w-0",!j.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:j.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:N4(j,t)}),j.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:j.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:j.loopFile})}):null]}),s.jsxs("div",{className:Ie("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!j.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),Z?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:Vc(Z,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:A4(Z,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),B==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ce?s.jsxs(s.Fragment,{children:[X.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${X.tone})`},children:[s.jsx(E,{name:X.Icon,className:"h-3.5 w-3.5"}),H]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Vc(ce,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),j.state?.lastError?s.jsxs("div",{className:Ie("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!j.enabled&&"opacity-60"),style:P4("error"),children:[s.jsx(E,{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:j.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Ie("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",j.enabled?"text-foreground":"text-muted-foreground",A&&"cursor-not-allowed opacity-50"),children:[s.jsx(ur,{checked:j.enabled,onChange:Y=>{P(j,Y)},ariaLabel:j.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:j.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:j.name}),disabled:A}),j.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(xt,{variant:"outline",size:"sm",onClick:()=>{_(j)},disabled:A,children:[s.jsx(E,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(xt,{variant:"outline",size:"sm",onClick:()=>M(j),disabled:A,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:j.name}),children:[s.jsx(E,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(xt,{variant:"destructive",size:"sm",onClick:()=>{I(j)},disabled:A,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:j.name}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},j.id)})})}),R=s.jsxs("div",{className:"space-y-4",children:[O,F]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Go,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:j=>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")}),j]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(xt,{className:"w-full",onClick:U,disabled:!d,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:R}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",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(j=>s.jsx("button",{type:"button",onClick:()=>L(j.id),className:Ie("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-primary/50",d===j.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(j)},j.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(xt,{size:"sm",onClick:U,disabled:!d,children:[s.jsx(E,{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:F})})]})]})}):null,s.jsx(w4,{open:S,task:m,onOpenChange:x,onSave:D})]})}const ko=100;function T4(){const t=st.c(106),{t:e}=Nt(),n=Te($4),r=Te(L4),i=Je(_4),o=Je(B4),l=ts(F4);let a;t[0]!==n?(a=Z=>n?Z.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const u=Is(Jn(a)),[d,h]=c.useState(""),[f,p]=c.useState(null),[g,w]=c.useState(ko);let S;t[2]!==d?(S=d.trim().toLowerCase(),t[2]=d,t[3]=S):S=t[3];const x=S;let m;e:{if(!n){let ce;t[4]===Symbol.for("react.memo_cache_sentinel")?(ce=[],t[4]=ce):ce=t[4],m=ce;break e}let Z;t[5]!==u?(Z=[...u].sort(O4),t[5]=u,t[6]=Z):Z=t[6],m=Z}const b=m;let y;if(t[7]!==l||t[8]!==b||t[9]!==e){const Z=new Map;for(const ce of b){const Y=vt(Ts(ce))??"",se=Z.get(Y);if(se){se.sessions.push(ce);continue}Z.set(Y,{directory:Y,label:Y?Fn(Y,l)||Y:e("sessions.archivePage.otherProjects"),sessions:[ce]})}y=[...Z.values()].sort(M4),t[7]=l,t[8]=b,t[9]=e,t[10]=y}else y=t[10];const v=y;let N;e:{if(x){if(x.startsWith("ses_")){let Y;if(t[11]!==x||t[12]!==b){let se;t[14]!==x?(se=oe=>oe.id.toLowerCase()===x,t[14]=x,t[15]=se):se=t[15],Y=b.filter(se),t[11]=x,t[12]=b,t[13]=Y}else Y=t[13];N=Y;break e}let ce;t[16]!==x||t[17]!==b?(ce=tp(b,x,E4),t[16]=x,t[17]=b,t[18]=ce):ce=t[18],N=ce;break e}if(f===null){N=b;break e}let Z;t[19]!==v||t[20]!==f?(Z=v.find(ce=>ce.directory===f)?.sessions??[],t[19]=v,t[20]=f,t[21]=Z):Z=t[21],N=Z}const C=N;let k,D,P,I,M,_,O,U,L,F;if(t[22]!==u.length||t[23]!==v||t[24]!==C||t[25]!==l||t[26]!==x||t[27]!==n||t[28]!==d||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==g){M=Symbol.for("react.early_return_sentinel");e:{const Z=C.slice(0,g);k=C.length-Z.length;const ce=u.length;let Y;t[45]===Symbol.for("react.memo_cache_sentinel")?(Y=ye=>{p(ye),w(ko)},t[45]=Y):Y=t[45];const se=Y;let oe;t[46]!==i||t[47]!==r?(oe=ye=>{const q=vt(Ts(ye));i(ye.id,q??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=oe):oe=t[48];const Se=oe;let K;t[49]!==e||t[50]!==o?(K=ye=>{o(ye.id).then(q=>{q?Le.success(e("sessions.sidebar.session.restore.success")):Le.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=K):K=t[51];const pe=K;if(!n){M=null;break e}let je;t[52]!==e?(je=(ye,q,we,be,Ne,ie,ee)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:Ne,title:ie,className:Ie("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-primary/50",ee?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",be?"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:q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:we})]}),ee?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>xn.requestDelete({sessions:ee,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-primary/50","aria-label":e("sessions.archivePage.deleteProjectAria",{label:q}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(Pt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ye),t[52]=e,t[53]=je):je=t[53];const ne=je;I="absolute inset-0 z-10 flex flex-col bg-background",D="flex min-h-0 flex-1";let T;if(t[54]!==ne||t[55]!==f||t[56]!==e||t[57]!==ce){let ye;t[59]===Symbol.for("react.memo_cache_sentinel")?(ye=()=>se(null),t[59]=ye):ye=t[59],T=ne("__all__",e("sessions.archivePage.allDirectories"),ce,f===null,ye),t[54]=ne,t[55]=f,t[56]=e,t[57]=ce,t[58]=T}else T=t[58];let G;if(t[60]!==v||t[61]!==ne||t[62]!==f){let ye;t[64]!==ne||t[65]!==f?(ye=q=>ne(q.directory||"__none__",q.label,q.sessions.length,f===q.directory,()=>se(q.directory),q.directory||void 0,q.sessions),t[64]=ne,t[65]=f,t[66]=ye):ye=t[66],G=v.map(ye),t[60]=v,t[61]=ne,t[62]=f,t[63]=G}else G=t[63];t[67]!==T||t[68]!==G?(P=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:[T,G]})}),t[67]=T,t[68]=G,t[69]=P):P=t[69],L="flex min-w-0 flex-1 flex-col";let le;t[70]===Symbol.for("react.memo_cache_sentinel")?(le=s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[70]=le):le=t[70];let de;t[71]===Symbol.for("react.memo_cache_sentinel")?(de=ye=>{h(ye.target.value),w(ko)},t[71]=de):de=t[71];let ue;t[72]!==e?(ue=e("sessions.archivePage.searchPlaceholder"),t[72]=e,t[73]=ue):ue=t[73];let Oe;t[74]!==d||t[75]!==ue?(Oe=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[le,s.jsx("input",{value:d,onChange:de,placeholder:ue,className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-3 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50"})]}),t[74]=d,t[75]=ue,t[76]=Oe):Oe=t[76];let me;t[77]!==C.length||t[78]!==e?(me=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[77]=C.length,t[78]=e,t[79]=me):me=t[79];let Re;t[80]!==me?(Re=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:me}),t[80]=me,t[81]=Re):Re=t[81],t[82]!==Oe||t[83]!==Re?(F=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Oe,Re]}),t[82]=Oe,t[83]=Re,t[84]=F):F=t[84],U="min-h-0 flex-1 overflow-y-auto px-6 py-3",_="mx-auto w-full max-w-3xl space-y-0.5",O=Z.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(x?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):Z.map(ye=>{const q=vt(Ts(ye))??"",we=q?Fn(q,l)||q: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:()=>Se(ye),role:"button",tabIndex:0,onKeyDown:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),Se(ye))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ye.title||e("sessions.sidebar.session.untitled")}),x&&we?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:q,children:we}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Kd(ye.time?.archived??ye.time?.updated??ye.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:be=>{be.stopPropagation(),pe(ye)},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-primary/50","aria-label":e("sessions.archivePage.restoreSessionAria",{title:ye.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:be=>{be.stopPropagation(),xn.requestDelete({sessions:[ye],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-primary/50","aria-label":e("sessions.archivePage.deleteSessionAria",{title:ye.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ye.id)})}t[22]=u.length,t[23]=v,t[24]=C,t[25]=l,t[26]=x,t[27]=n,t[28]=d,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=g,t[35]=k,t[36]=D,t[37]=P,t[38]=I,t[39]=M,t[40]=_,t[41]=O,t[42]=U,t[43]=L,t[44]=F}else k=t[35],D=t[36],P=t[37],I=t[38],M=t[39],_=t[40],O=t[41],U=t[42],L=t[43],F=t[44];if(M!==Symbol.for("react.early_return_sentinel"))return M;let R;t[85]!==k||t[86]!==e?(R=k>0?s.jsx("button",{type:"button",onClick:()=>w(R4),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[85]=k,t[86]=e,t[87]=R):R=t[87];let j;t[88]!==R||t[89]!==_||t[90]!==O?(j=s.jsxs("div",{className:_,children:[O,R]}),t[88]=R,t[89]=_,t[90]=O,t[91]=j):j=t[91];let A;t[92]!==j||t[93]!==U?(A=s.jsx("div",{className:U,children:j}),t[92]=j,t[93]=U,t[94]=A):A=t[94];let B;t[95]!==A||t[96]!==L||t[97]!==F?(B=s.jsxs("div",{className:L,children:[F,A]}),t[95]=A,t[96]=L,t[97]=F,t[98]=B):B=t[98];let X;t[99]!==D||t[100]!==P||t[101]!==B?(X=s.jsxs("div",{className:D,children:[P,B]}),t[99]=D,t[100]=P,t[101]=B,t[102]=X):X=t[102];let H;return t[103]!==I||t[104]!==X?(H=s.jsx("div",{className:I,children:X}),t[103]=I,t[104]=X,t[105]=H):H=t[105],H}function R4(t){return t+ko}function E4(t){return[t.title]}function M4(t,e){return e.sessions.length-t.sessions.length}function O4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function F4(t){return t.homeDirectory}function B4(t){return t.unarchiveSession}function _4(t){return t.setCurrentSession}function L4(t){return t.setArchivePageOpen}function $4(t){return t.isArchivePageOpen}function W4(){const t=st.c(18),{t:e}=Nt(),n=Te(U4),r=Te(V4),i=Ht(z4);let o;t[0]!==n?(o=g=>g.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Ht(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 u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(E,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=u):u=t[6];let d;t[7]!==e?(d=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==a||t[10]!==d?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(xt,{size:"sm",onClick:a,children:[u,d]})}),t[9]=a,t[10]=d,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(jg,{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 z4(t){return t.setActiveProjectIdOnly}function V4(t){return t.setNewWorktreeDialogOpen}function U4(t){return t.worktreesPageProjectId}const ca=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),K4=(t,e)=>{const n=ca(t),r=ca(e);return`${n}-${r}`.substring(0,60)},Uc=(t,e)=>`${t}/${e}`,H4=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},Kc=(t,e)=>{const n=H4(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};cp(t.id,n),Je.getState().markSessionAsAiWorkerCreated(t.id),Is.getState().upsertSession(i);try{Do().ensureChild(n,{bootstrap:!1}).setState(l=>{const a=l.session.findIndex(d=>d.id===t.id);if(a>=0&&l.session[a]===i)return l;const u=a>=0?l.session.map((d,h)=>h===a?i:d):[...l.session,i].sort((d,h)=>d.id.localeCompare(h.id));return{session:u,sessionTotal:Math.max(l.sessionTotal,u.length),limit:Math.max(l.limit,u.length)}})}catch{}return i},G4=()=>{const t=Ht.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(i=>i.id===e);if(n?.path)return{id:n.id,path:n.path};const r=ts.getState().currentDirectory??null;if(r&&r.trim().length>0){const i=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${i}`,path:i}}return null},xi=tr()(pu(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:i,files:o,setupCommands:l}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let a=0;a<r.length;a++){if(!r[a].prompt.trim())return t({error:`Group ${a+1}: prompt is required`}),null;if(r[a].models.length<1)return t({error:`Group ${a+1}: select at least 1 model`}),null}t({isLoading:!0,error:null});try{const a=G4();if(!a)return t({error:"Select a project",isLoading:!1}),null;const u=a.path,h=await Ko(u)&&e.isolateRuns!==!1,f=ca(n),p=h?await qo(u):void 0,g=h?await sp(u):null,w=[],S=l?.filter(v=>v.trim().length>0)??[];for(let v=0;v<r.length;v++){const N=r[v],C=N.prompt,k=new Map;for(const P of N.models){const I=`${P.providerID}:${P.modelID}`;k.set(I,(k.get(I)||0)+1)}const D=new Map;for(const P of N.models){const I=`${P.providerID}:${P.modelID}`,M=k.get(I)||1,_=(D.get(I)||0)+1;D.set(I,_);const O=K4(P.providerID,P.modelID),U=r.length>1?`g${v+1}`:void 0,L=M>1?Uc(f,`${O}/${_}`):Uc(f,O),F=U?`${U}/${L}`:L,R=Bj({groupSlug:f,runGroup:U,providerID:P.providerID,modelID:P.modelID,index:M>1?_:void 0});try{if(!h){const X=await Qs.withDirectory(u,()=>Qs.createSession({title:R}));Kc(X,u),w.push({sessionId:X.id,worktreePath:u,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C});continue}const j=await np(a,{preferredName:F,mode:"new",branchName:F,worktreeName:F,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:S,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:g}),A={...j,createdFromBranch:p,kind:"standard"};await rp(a)&&await op(j.path);const B=await Qs.withDirectory(j.path,()=>Qs.createSession({title:R}));Kc(B,j.path),Je.getState().setWorktreeMetadata(B.id,A),w.push({sessionId:B.id,worktreePath:j.path,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C})}catch(j){console.warn("[MultiRun] Failed to create session:",j)}}}const x=l?.filter(v=>v.trim().length>0)??[];x.length>0&&ip(a,x).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const m=w.map(v=>v.sessionId),b=w[0]?.sessionId??null;if(m.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const y=o?.map(v=>({type:"file",mime:v.mime,filename:v.filename,url:v.url}));return(async()=>{try{const v=ap.getState().expandText;await Promise.allSettled(w.map(async N=>{try{const C=await v(N.prompt).catch(()=>N.prompt);await lp({sessionId:N.sessionId,directory:N.worktreePath,content:C,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:i,files:y})}catch(C){console.warn("[MultiRun] Failed to start run:",C)}}))}catch(v){console.warn("[MultiRun] Failed to start runs:",v)}})(),t({isLoading:!1}),{groupSlug:f,sessionIds:m,firstSessionId:b}}catch(a){return t({error:a instanceof Error?a.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"}));function Sf(t){const e=st.c(30),{git:n}=Sn(),r=Dd(t),i=Pd(t),o=dp(t),l=up(t),a=Dn(J4),u=Dn(X4);let d,h;e[0]!==t||e[1]!==u||e[2]!==n||e[3]!==i||e[4]!==o?(d=()=>{!t||!n||i!==null||o||u(t,n,{silent:!0})},h=[t,n,u,i,o],e[0]=t,e[1]=u,e[2]=n,e[3]=i,e[4]=o,e[5]=d,e[6]=h):(d=e[5],h=e[6]),c.useEffect(d,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 g;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(g=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=g):g=e[18],c.useEffect(f,g);const w=o||i===!0&&l;let S;e:{if(!r?.all){let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[19]=k):k=e[19],S=k;break e}let C;e[20]!==r.all?(C=r.all.filter(Y4).sort(),e[20]=r.all,e[21]=C):C=e[21],S=C}const x=S;let m;e:{if(!r?.all){let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[22]=k):k=e[22],m=k;break e}let C;e[23]!==r.all?(C=r.all.filter(Q4).map(q4).sort(),e[23]=r.all,e[24]=C):C=e[24],m=C}const b=m;let y;e:{if(!t){y=null;break e}if(i!==null){y=i;break e}if(w){y=null;break e}y=r?.all?!0:null}const v=y;let N;return e[25]!==v||e[26]!==w||e[27]!==x||e[28]!==b?(N={localBranches:x,remoteBranches:b,isLoading:w,isGitRepository:v},e[25]=v,e[26]=w,e[27]=x,e[28]=b,e[29]=N):N=e[29],N}function q4(t){return t.replace(/^remotes\//,"")}function Q4(t){return t.startsWith("remotes/")}function Y4(t){return!t.startsWith("remotes/")}function X4(t){return t.fetchStatus}function J4(t){return t.fetchBranches}const Z4=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=Nt(),{localBranches:a,remoteBranches:u,isLoading:d,isGitRepository:h}=Sf(t),f=c.useMemo(()=>[...a,...u.map(g=>`remotes/${g}`)],[a,u]);c.useEffect(()=>{if(i||d||f.length===0||e&&f.includes(e))return;const g=e;let w=!1;return(async()=>{try{const x=t?await qo(t).catch(()=>null):null;if(w)return;const m=localStorage.getItem(kl),{sourceBranch:b,shouldClearSavedSourceBranch:y}=kg({branches:f,savedSourceBranch:m,rootBranch:x});if(y&&localStorage.removeItem(kl),w||g&&f.includes(g))return;b&&n(b)}catch{}})(),()=>{w=!0}},[f,t,i,d,n,e]);const p=i||!h||d;return s.jsxs("div",{children:[s.jsxs(Fs,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Bs,{id:o,size:"lg",className:Ie("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(As,{placeholder:l(d?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(_s,{className:"max-h-[280px] max-w-[320px]",children:d?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&u.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(Ii,{children:[s.jsx(ml,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(g=>s.jsx(ss,{value:g,className:"whitespace-normal break-all",children:g},g))]}),a.length>0&&u.length>0&&s.jsx(fp,{}),u.length>0&&s.jsxs(Ii,{children:[s.jsx(ml,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),u.map(g=>s.jsx(ss,{value:`remotes/${g}`,className:"whitespace-normal break-all",children:g},`remotes/${g}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},e3=10*1024*1024,Co=t=>{const e=st.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Dt,{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(E,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(At,{children:[r,s.jsx(Pt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Kn=t=>{const e=st.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 u=o&&o;let d;return e[6]!==a||e[7]!==u?(d=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,u]}),e[6]=a,e[7]=u,e[8]=d):d=e[8],d},t3=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=Nt(),[o,l]=c.useState(""),[a,u]=c.useState(()=>[{id:Lr(),prompt:"",models:[]}]),[d,h]=c.useState(""),[f,p]=c.useState([]),[g,w]=c.useState(!1),[S,x]=c.useState([]),[m,b]=c.useState(!1),[y,v]=c.useState(!1),[N,C]=c.useState(!0),k=c.useRef(null),D=ts(V=>V.currentDirectory??null),P=ts(V=>V.homeDirectory??null),I=c.useMemo(()=>{if(typeof window>"u")return null;const V=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof V=="string"&&V.trim().length>0?V.trim():null},[]),M=Ht(V=>V.activeProjectId),_=Ht(V=>V.setActiveProjectIdOnly),O=Ht(V=>V.projects),[U,L]=c.useState(()=>M??null);c.useEffect(()=>{if(M){L(M);return}!U&&O.length>0&&L(O[0].id)},[M,O,U]);const F=c.useMemo(()=>U?O.find(V=>V.id===U)??null:null,[O,U]),R=F?.path??D,j=c.useCallback(V=>{L(V),V!==M&&_(V)},[M,_]),{currentTheme:A}=Zn(),B=c.useCallback(V=>{const $=V.label?.trim()||Fn(V.path,P),ae=V.icon?ka[V.icon]:null,W=V.color?Ca[V.color]:void 0,ve=ae?s.jsx(E,{name:ae,className:"h-3.5 w-3.5 shrink-0",style:W?{color:W}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:W?{color:W}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[V.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:V.iconBackground?{backgroundColor:V.iconBackground}:void 0,children:s.jsx(Na,{project:{id:V.id,iconImage:V.iconImage??null},options:{themeVariant:A.metadata.variant,iconColor:A.colors.surface.foreground},className:"h-full w-full object-contain",fallback:ve})}):ve,s.jsx("span",{className:"truncate",children:$})]})},[P,A.metadata.variant,A.colors.surface.foreground]),X=c.useMemo(()=>{if(F?.path)return{id:F.id,path:F.path};const V=D??I;return V?{id:`path:${V}`,path:V}:null},[F,D,I]),[H]=c.useState(()=>typeof window<"u"?bn():!1),Z=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ce=vd(),Y=c.useMemo(()=>{if(typeof window>"u")return null;const V=window.__AIWORKER_MACOS_MAJOR__;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(typeof navigator>"u")return null;const $=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!$)return null;const ae=Number.parseInt($[1],10),W=Number.parseInt($[2],10);return Number.isNaN(ae)?null:ae===10?W:ae},[]),se=c.useMemo(()=>H&&Z||ce?"pl-[88px]":"pl-3",[H,Z,ce]),oe=c.useMemo(()=>!H||!Z||Y===null?"":Y>=26?"h-12":Y<=15?"h-14":"",[H,Z,Y]),Se=c.useCallback(async V=>{V.target.closest("button, a, input, select, textarea")||V.button===0&&H&&await mp()},[H]);c.useEffect(()=>{if(!n)return;const V=$=>{$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),n())};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[n]);const[K,pe]=c.useState(""),{isLoading:je,isGitRepository:ne}=Sf(R),T=c.useRef(!1),G=ne===!0,le=G&&N;c.useEffect(()=>{if(ne===!1){T.current=!0,C(!1);return}ne===!0&&T.current&&(T.current=!1,C(!0))},[ne]);const de=xi(V=>V.createMultiRun),ue=xi(V=>V.error),Oe=xi(V=>V.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&u(V=>{const $=[...V];return $.length>0&&!$[0].prompt.trim()&&($[0]={...$[0],prompt:t}),$})},[t]),c.useEffect(()=>{if(!X)return;let V=!1;return v(!0),(async()=>{try{const $=await hp(X);V||x($)}catch{}finally{V||v(!1)}})(),()=>{V=!0}},[X]);const me=c.useCallback((V,$)=>{u(ae=>ae.map(W=>W.id===V?{...W,...$}:W))},[]),Re=c.useCallback(V=>{u($=>$.filter(ae=>ae.id!==V))},[]),ye=c.useCallback(()=>{u(V=>[...V,{id:Lr(),prompt:"",models:[]}])},[]),q=async V=>{const $=V.target.files;if(!$)return;let ae=0;for(let W=0;W<$.length;W++){const ve=$[W];if(ve.size>e3){Le.error(i("multirun.launcher.toast.fileTooLarge",{fileName:ve.name}));continue}try{const Fe=await new Promise((Ce,ke)=>{const Qe=new FileReader;Qe.onload=()=>Ce(Qe.result),Qe.onerror=ke,Qe.readAsDataURL(ve)});p(Ce=>[...Ce,{id:Lr(),filename:ve.name,mimeType:ve.type||"application/octet-stream",size:ve.size,dataUrl:Fe}]),ae++}catch(Fe){console.error("File attach failed",Fe),Le.error(i("multirun.launcher.toast.attachFailed",{fileName:ve.name}))}}ae>0&&Le.success(ae===1?i("multirun.launcher.toast.attachedSingle",{count:ae}):i("multirun.launcher.toast.attachedPlural",{count:ae})),k.current&&(k.current.value="")},we=V=>{p($=>$.filter(ae=>ae.id!==V))},be=c.useMemo(()=>a.reduce((V,$)=>V+$.models.length,0),[a]),Ne=async V=>{V.preventDefault();const $=a.filter(ae=>ae.prompt.trim()&&ae.models.length>=1);if($.length!==0&&!(be<1)){w(!0),Oe();try{U&&U!==M&&_(U);const ae=f.map(ke=>({mime:ke.mimeType,filename:ke.filename,url:ke.dataUrl})),W=S.filter(ke=>ke.trim().length>0),ve=$.map(ke=>({prompt:ke.prompt.trim(),models:ke.models.map(Qe=>({providerID:Qe.providerID,modelID:Qe.modelID,displayName:Qe.displayName,variant:Qe.variant}))})),Fe={name:o.trim(),groups:ve,agent:d||void 0,worktreeBaseBranch:le?K:void 0,isolateRuns:le,files:ae.length>0?ae:void 0,setupCommands:W.length>0?W:void 0},Ce=await de(Fe);Ce&&(Ce.firstSessionId&&Je.getState().setCurrentSession(Ce.firstSessionId),e?.())}finally{w(!1)}}},ie=!!(o.trim()&&a.some(V=>V.prompt.trim()&&V.models.length>=1)&&be>=1&&R&&!je&&(ne===!1||!le||K)),ee=S.filter(V=>V.trim()).length;return s.jsxs("form",{onSubmit:Ne,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Se,className:Ie("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",se,oe),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(At,{children:[s.jsx(Dt,{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-primary app-region-no-drag",children:s.jsx(E,{name:"close",className:"h-5 w-5"})})}),s.jsx(Pt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(wa,{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(Kn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),O.length>0?s.jsxs(Fs,{value:U??void 0,onValueChange:j,children:[s.jsx(Bs,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:F?s.jsx(As,{children:B(F)}):s.jsx(As,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(_s,{fitContent:!0,children:O.map(V=>s.jsx(ss,{value:V.id,className:"max-w-[24rem]",children:B(V)},V.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(Kn,{htmlFor:"group-name",required:!0,info:s.jsx(Co,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(Cn,{id:"group-name",value:o,onChange:V=>l(V.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(Kn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Co,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(Z4,{directory:R,value:K,onChange:pe,disabled:!le,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(ur,{checked:N,onChange:C,disabled:!G,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(Kn,{htmlFor:"multirun-agent",info:s.jsx(Co,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(mf,{value:d,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(ki,{open:m,onOpenChange:b,children:[s.jsxs(Ad,{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(E,{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")}),ee>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:ee}),s.jsx(E,{name:"arrow-down-s",className:Ie("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(Ci,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:y?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[S.map((V,$)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(Cn,{value:V,onChange:ae=>{const W=[...S];W[$]=ae.target.value,x(W)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>x(S.filter((ae,W)=>W!==$)),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-primary/50","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]},`${V}-${$}`)),s.jsxs("button",{type:"button",onClick:()=>x([...S,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(E,{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(Kn,{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:k,type:"file",multiple:!0,className:"hidden",onChange:q,accept:"*/*"}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>k.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(E,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(Pt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(V=>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:[V.mimeType.startsWith("image/")?s.jsx(E,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(E,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:V.filename,children:V.filename}),s.jsx("button",{type:"button",onClick:()=>we(V.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(E,{name:"close",className:"h-3 w-3"})})]},V.id))]})]}),a.map((V,$)=>s.jsx(s3,{group:V,groupIndex:$,canRemove:a.length>1,onUpdate:me,onRemove:Re},V.id)),s.jsxs("button",{type:"button",onClick:ye,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(E,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),ue&&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:ue})]})})}),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:[!le&&ne!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(E,{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(xt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(xt,{type:"submit",size:"sm",disabled:!ie||g,children:g?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:be})})})]})})]})},s3=t=>{const e=st.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=Nt(),[u,d]=c.useState(!1),[h,f]=c.useState(""),[p,g]=c.useState(!1),[w,S]=c.useState(""),[x,m]=c.useState(!1),[b,y]=c.useState(""),v=c.useRef(null),N=c.useRef(null),C=c.useRef(null),k=c.useRef(null);let D;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(D=W=>{o(n.id,{models:[...n.models,W]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=D):D=e[3];const P=D;let I;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(I=W=>{o(n.id,{models:n.models.filter((ve,Fe)=>Fe!==W)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=I):I=e[7];const M=I;let _;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(_=(W,ve)=>{o(n.id,{models:n.models.map((Fe,Ce)=>Ce===W?ve:Fe)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=_):_=e[11];const O=_;let U;e[12]===Symbol.for("react.memo_cache_sentinel")?(U=(W,ve)=>{if(W.startsWith("/")){const Qe=W.indexOf(" "),We=W.indexOf(`
927
927
  `),z=Math.min(Qe===-1?W.length:Qe,We===-1?W.length:We);if(ve<=z&&Qe===-1){S(W.substring(1,z)),g(!0),d(!1),m(!1);return}}g(!1);const Fe=W.substring(0,ve),Ce=Fe.lastIndexOf("#");if(Ce!==-1){const Qe=Ce>0?Fe[Ce-1]:null,We=Fe.substring(Ce+1);if((!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
928
928
  `)){y(We),m(!0),d(!1);return}}m(!1);const ke=Fe.lastIndexOf("@");if(ke!==-1){const Qe=ke>0?Fe[ke-1]:null,We=Fe.substring(ke+1);(!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
929
- `)?(f(We),d(!0)):d(!1);return}d(!1)},e[12]=U):U=e[12];const L=U;let F;e[13]!==n.id||e[14]!==o?(F=W=>{o(n.id,{prompt:W})},e[13]=n.id,e[14]=o,e[15]=F):F=e[15];const R=F;let j;e[16]!==n.prompt||e[17]!==R?(j=W=>{const ve=n.prompt,Ce=v.current?.selectionStart??ve.length,Qe=ve.substring(0,Ce).lastIndexOf("@"),We=W.relativePath&&W.relativePath.trim().length>0?W.relativePath.trim():W.path||W.name,z=Qe!==-1?Qe:Ce,he=`${ve.substring(0,z)}@${We} ${ve.substring(Ce)}`,Be=z+We.length+2;R(he),d(!1),f(""),requestAnimationFrame(()=>{const Ae=v.current;Ae&&(Ae.selectionStart=Be,Ae.selectionEnd=Be,Ae.focus()),L(he,Be)})},e[16]=n.prompt,e[17]=R,e[18]=j):j=e[18];const A=j;let B;e[19]!==n.prompt||e[20]!==R?(B=W=>{const ve=n.prompt,Ce=v.current?.selectionStart??ve.length,Qe=ve.substring(0,Ce).lastIndexOf("@"),We=Qe!==-1?Qe:Ce,z=`${ve.substring(0,We)}@${W} ${ve.substring(Ce)}`,he=We+W.length+2;R(z),d(!1),f(""),requestAnimationFrame(()=>{const Be=v.current;Be&&(Be.selectionStart=he,Be.selectionEnd=he,Be.focus()),L(z,he)})},e[19]=n.prompt,e[20]=R,e[21]=B):B=e[21];const X=B;let H;e[22]!==R?(H=W=>{const ve=`/${W.name} `;R(ve),g(!1),S(""),m(!1),requestAnimationFrame(()=>{const Fe=v.current;Fe&&(Fe.focus(),Fe.selectionStart=Fe.value.length,Fe.selectionEnd=Fe.value.length),L(ve,ve.length)})},e[22]=R,e[23]=H):H=e[23];const Z=H;let ce;e[24]!==n.prompt||e[25]!==R?(ce=(W,ve)=>{const Fe=n.prompt,ke=v.current?.selectionStart??Fe.length,We=Fe.substring(0,ke).lastIndexOf("#"),z=We!==-1?We:ke,he=`${Fe.substring(0,z)}#${ve} ${Fe.substring(ke)}`,Be=z+ve.length+2;R(he),m(!1),y(""),requestAnimationFrame(()=>{const Ae=v.current;Ae&&(Ae.selectionStart=Be,Ae.selectionEnd=Be,Ae.focus()),L(he,Be)})},e[24]=n.prompt,e[25]=R,e[26]=ce):ce=e[26];const Y=ce;let se;e[27]!==p||e[28]!==u||e[29]!==x?(se=W=>{if(p&&C.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")){W.preventDefault(),C.current.handleKeyDown(W.key);return}u&&N.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")&&(W.preventDefault(),N.current.handleKeyDown(W.key)),x&&k.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")&&(W.preventDefault(),k.current.handleKeyDown(W.key))},e[27]=p,e[28]=u,e[29]=x,e[30]=se):se=e[30];const oe=se,Se=r+1;let K;e[31]!==a||e[32]!==Se?(K=a("multirun.launcher.groups.groupLabel",{index:Se}),e[31]=a,e[32]=Se,e[33]=K):K=e[33];let pe;e[34]!==K?(pe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:K}),e[34]=K,e[35]=pe):pe=e[35];let je;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(je=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(E,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=je):je=e[40];let ne;e[41]!==pe||e[42]!==je?(ne=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[pe,je]}),e[41]=pe,e[42]=je,e[43]=ne):ne=e[43];let T;e[44]!==a?(T=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=T):T=e[45];let G;e[46]!==T?(G=s.jsx(Kn,{required:!0,children:T}),e[46]=T,e[47]=G):G=e[47];const le=n.prompt;let de;e[48]!==R?(de=W=>{const ve=W.target.value;R(ve);const Fe=W.target.selectionStart??ve.length;L(ve,Fe)},e[48]=R,e[49]=de):de=e[49];let ue;e[50]!==a?(ue=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=ue):ue=e[51];let Oe;e[52]!==n.prompt||e[53]!==oe||e[54]!==de||e[55]!==ue?(Oe=s.jsx(lr,{ref:v,value:le,onChange:de,onKeyDown:oe,placeholder:ue,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]=oe,e[54]=de,e[55]=ue,e[56]=Oe):Oe=e[56];let me;e[57]!==w||e[58]!==Z||e[59]!==p?(me=p?s.jsx(qd,{ref:C,searchQuery:w,onCommandSelect:Z,onClose:()=>g(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=Z,e[59]=p,e[60]=me):me=e[60];let Re;e[61]!==X||e[62]!==A||e[63]!==h||e[64]!==u?(Re=u?s.jsx(Qd,{ref:N,searchQuery:h,onFileSelect:A,onAgentSelect:X,onClose:()=>d(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=A,e[63]=h,e[64]=u,e[65]=Re):Re=e[65];let ye;e[66]!==Y||e[67]!==x||e[68]!==b?(ye=x?s.jsx(Yd,{ref:k,searchQuery:b,onSnippetSelect:Y,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=Y,e[67]=x,e[68]=b,e[69]=ye):ye=e[69];let q;e[70]!==Oe||e[71]!==me||e[72]!==Re||e[73]!==ye?(q=s.jsxs("div",{className:"relative",children:[Oe,me,Re,ye]}),e[70]=Oe,e[71]=me,e[72]=Re,e[73]=ye,e[74]=q):q=e[74];let we;e[75]!==G||e[76]!==q?(we=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[G,q]}),e[75]=G,e[76]=q,e[77]=we):we=e[77];let be;e[78]!==a?(be=a("multirun.launcher.models.info"),e[78]=a,e[79]=be):be=e[79];let Ne;e[80]!==be?(Ne=s.jsx(Co,{children:be}),e[80]=be,e[81]=Ne):Ne=e[81];let ie;e[82]!==a?(ie=a("multirun.launcher.models.label"),e[82]=a,e[83]=ie):ie=e[83];let ee;e[84]!==Ne||e[85]!==ie?(ee=s.jsx(Kn,{required:!0,info:Ne,children:ie}),e[84]=Ne,e[85]=ie,e[86]=ee):ee=e[86];let V;e[87]!==n.models||e[88]!==P||e[89]!==M||e[90]!==O?(V=s.jsx(hf,{selectedModels:n.models,onAdd:P,onRemove:M,onUpdate:O,minModels:1}),e[87]=n.models,e[88]=P,e[89]=M,e[90]=O,e[91]=V):V=e[91];let $;e[92]!==ee||e[93]!==V?($=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ee,V]}),e[92]=ee,e[93]=V,e[94]=$):$=e[94];let ae;return e[95]!==ne||e[96]!==we||e[97]!==$?(ae=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[ne,we,$]}),e[95]=ne,e[96]=we,e[97]=$,e[98]=ae):ae=e[98],ae},n3=t=>{const e=new Map;for(const n of t){const r=Ts(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},r3=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},o3=t=>{const e=st.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,u;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const d=us(),h=n3(i),f=l.current?.runtimeKey===d?l.current.identities:null;for(const p of r3(f,h))pp({runtimeKey:d,...p});l.current={runtimeKey:d,identities:h}},u=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=u):(a=e[3],u=e[4]),c.useEffect(a,u)},i3=new Map,a3=t=>{const e=st.c(26),{isVSCode:n}=t,r=Ia(),i=Ht(l3),o=Ht(c3),l=ts(d3),a=Je(u3);let u;e[0]!==n?(u=I=>n?i3:I.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Je(u),h=!n;let f;e[2]!==d||e[3]!==i||e[4]!==h?(f=bf(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=f):f=e[5];const p=f,g=Is(f3),w=Is(m3),S=Is(h3),x=`session-list-sync:${c.useId()}`;let m,b;e[6]!==o||e[7]!==x||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==p||e[12]!==i?(m=()=>(r.setBootstrapDemand(x,lf({knownDirectories:p,activeProjectDirectory:vt(i.find(I=>I.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),b=[o,x,r,l,a,p,i],e[6]=o,e[7]=x,e[8]=r,e[9]=l,e[10]=a,e[11]=p,e[12]=i,e[13]=m,e[14]=b):(m=e[13],b=e[14]),c.useEffect(m,b);const y=c.useRef(null);let v,N;e[15]!==n||e[16]!==p?(v=()=>{const I=new Set(p),M=y.current;y.current=I;const _=M?[...I].filter(O=>!M.has(O)):n?[...I]:[];_.length&&xa(_,Po())},N=[n,p],e[15]=n,e[16]=p,e[17]=v,e[18]=N):(v=e[17],N=e[18]),c.useEffect(v,N);let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[19]=C):C=e[19],c.useEffect(p3,C);let k;e[20]!==w||e[21]!==g?(k=[...g,...w],e[20]=w,e[21]=g,e[22]=k):k=e[22];const D=k;let P;e[23]!==D||e[24]!==S?(P={enabled:!0,hasAuthoritativeGlobalSessions:S,sessions:D},e[23]=D,e[24]=S,e[25]=P):P=e[25],o3(P)};function l3(t){return t.projects}function c3(t){return t.activeProjectId}function d3(t){return t.currentDirectory}function u3(t){return t.currentSessionDirectory}function f3(t){return t.activeSessions}function m3(t){return t.archivedSessions}function h3(t){return t.status==="ready"}function p3(){let t=null,e=!1;const n=new Set,r=Yr(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(),Ta(Po());return}const o=[...n];n.clear(),o.length&&xa(o,Po())},500)});return()=>{t&&clearTimeout(t),r()}}const g3=Ln(()=>Bn(()=>import("./SettingsWindow-Dy3M6ZB9.js"),__vite__mapDeps([140,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,141,84,142,127,128,129,130,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,143,144])).then(t=>({default:t.SettingsWindow}))),x3=()=>{const t=st.c(58);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],a3(e),Cg();const n=Te(b3),r=Te(y3),i=Te(w3),o=Te(S3),[l,a]=c.useState(!1);let u,d;t[1]!==i?(u=()=>{i&&a(!0)},d=[i],t[1]=i,t[2]=u,t[3]=d):(u=t[2],d=t[3]),c.useEffect(u,d);const h=Te(v3),f=Te(j3),p=Te(k3),g=Te(C3),w=Te(N3),S=Te(A3),x=g||w||!!S||h;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[4]=m):m=t[4],c.useEffect(P3,m);const{isMobile:b}=_n();Ng();const y=nb();let v,N;t[5]!==b||t[6]!==r?(v=()=>{Te.getState().isMobile!==b&&r(b)},N=[b,r],t[5]=b,t[6]=r,t[7]=v,t[8]=N):(v=t[7],N=t[8]),c.useEffect(v,N);let C,k,D,P;t[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(WS,{}),k=s.jsx(Bv,{}),D=s.jsx(Wv,{}),P=s.jsx(s4,{}),t[9]=C,t[10]=k,t[11]=D,t[12]=P):(C=t[9],k=t[10],D=t[11],P=t[12]);let I;t[13]!==y?(I=s.jsx(n4,{value:y,onMoveSessionOnly:I3,onMoveAllChanges:T3,onCancel:fb}),t[13]=y,t[14]=I):I=t[14];let M;t[15]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Sb,{}),t[15]=M):M=t[15];let _;t[16]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(wb,{}),t[16]=_):_=t[16];let O;t[17]!==n?(O=s.jsx(t4,{isVisible:n}),t[17]=n,t[18]=O):O=t[18];let U;t[19]!==b||t[20]!==n||t[21]!==O?(U=s.jsx(yb,{isOpen:n,isMobile:b,className:"border-border",topBar:_,children:O}),t[19]=b,t[20]=n,t[21]=O,t[22]=U):U=t[22];let L;t[23]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(xb,{}),t[23]=L):L=t[23];const F=x&&"invisible";let R;t[24]!==F?(R=Ie("absolute inset-0",F),t[24]=F,t[25]=R):R=t[25];const j=!i&&!x;let A;t[26]!==j?(A=s.jsx(Gs,{children:s.jsx(iu,{active:j})}),t[26]=j,t[27]=A):A=t[27];let B;t[28]!==R||t[29]!==A?(B=s.jsx("div",{className:R,children:A}),t[28]=R,t[29]=A,t[30]=B):B=t[30];let X;t[31]!==h||t[32]!==p||t[33]!==f?(X=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Gs,{children:s.jsx(t3,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[31]=h,t[32]=p,t[33]=f,t[34]=X):X=t[34];let H;t[35]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Gs,{children:s.jsx(I4,{})}),t[35]=H):H=t[35];let Z;t[36]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Gs,{children:s.jsx(T4,{})}),t[36]=Z):Z=t[36];let ce;t[37]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(Gs,{children:s.jsx(W4,{})}),t[37]=ce):ce=t[37];let Y;t[38]!==B||t[39]!==X?(Y=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[B,X,H,Z,ce]}),t[38]=B,t[39]=X,t[40]=Y):Y=t[40];let se;t[41]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(uS,{}),t[41]=se):se=t[41];let oe;t[42]!==Y?(oe=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:[Y,se]})})}),t[42]=Y,t[43]=oe):oe=t[43];let Se;t[44]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Gs,{children:s.jsx(SS,{})})}),t[44]=Se):Se=t[44];let K;t[45]!==oe?(K=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[L,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[oe,Se]})]}),t[45]=oe,t[46]=K):K=t[46];let pe;t[47]!==U||t[48]!==K?(pe=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[U,K]}),t[47]=U,t[48]=K,t[49]=pe):pe=t[49];let je;t[50]!==i||t[51]!==o||t[52]!==l?(je=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(g3,{open:i,onOpenChange:o})}):null,t[50]=i,t[51]=o,t[52]=l,t[53]=je):je=t[53];let ne;return t[54]!==I||t[55]!==pe||t[56]!==je?(ne=s.jsx(Ag,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[C,k,D,P,I,M,pe,je]})}),t[54]=I,t[55]=pe,t[56]=je,t[57]=ne):ne=t[57],ne};function b3(t){return t.isSidebarOpen}function y3(t){return t.setIsMobile}function w3(t){return t.isSettingsDialogOpen}function S3(t){return t.setSettingsDialogOpen}function v3(t){return t.isMultiRunLauncherOpen}function j3(t){return t.setMultiRunLauncherOpen}function k3(t){return t.multiRunLauncherPrefillPrompt}function C3(t){return t.isScheduledTasksDialogOpen}function N3(t){return t.isArchivePageOpen}function A3(t){return t.worktreesPageProjectId}function D3(){return Te.getState().closeMainSurfaces()}function P3(){const t=D3,e=Je.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 I3(){return Ru(!1)}function T3(){return Ru(!0)}const vf=12,R3=[{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"}],E3=t=>{const e=st.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,u=r===void 0?0:r,d=o===void 0?900:o,h=l===void 0?R3:l,f=gt.useRef(!1);let p,g;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},g=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=g):(p=e[2],g=e[3]),gt.useEffect(p,g);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:vf},M3),e[4]=w):w=e[4];const S=w;if(!n)return null;let x;e[5]!==i?(x=Ie("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let m;if(e[7]!==u||e[8]!==h||e[9]!==d){let y;e[11]!==u||e[12]!==d?(y=v=>{const N={"--burst-delay":`${v.delay}ms`,"--burst-x":`${v.x}%`,"--burst-y":`${v.y}%`,"--firework-color":`var(${v.colorVar})`,"--firework-duration":`${d}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:S.map((C,k)=>{const D=C.x*v.radius,P=C.y*v.radius,I={"--translate-x":`${D}px`,"--translate-y":`${P}px`,"--particle-delay":`${C.delay}ms`,color:`var(${v.colorVar})`};return s.jsx("span",{className:"firework-particle",style:I},`${v.id}-${k}-${u}`)})},`${v.id}-${u}`)},e[11]=u,e[12]=d,e[13]=y):y=e[13],m=h.map(y),e[7]=u,e[8]=h,e[9]=d,e[10]=m}else m=e[10];let b;return e[14]!==u||e[15]!==x||e[16]!==m?(b=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":u,children:m}),e[14]=u,e[15]=x,e[16]=m,e[17]=b):b=e[17],b};function M3(t,e){const n=Math.PI*2*e/vf;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const O3=t=>{const e=st.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]=gt.useState(o),u=gt.useRef(null);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},e[3]=d):d=e[3];const h=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(F3)},e[4]=f):f=e[4];const p=f;let g;e[5]!==i?(g=()=>{h(),a(B3),u.current=window.setTimeout(()=>{a(_3),u.current=null},i)},e[5]=i,e[6]=g):g=e[6];const w=g;let S,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>h(),x=[h],e[7]=S,e[8]=x):(S=e[7],x=e[8]),gt.useEffect(S,x);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function F3(t){return t.isActive?{...t,isActive:!1}:t}function B3(t){return{isActive:!0,cycle:t.cycle+1}}function _3(t){return t.isActive?{...t,isActive:!1}:t}const jf=c.createContext(void 0),L3=t=>{const e=st.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=O3();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 u=a;let d;e[3]!==i||e[4]!==r?(d=s.jsx(E3,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let h;return e[6]!==n||e[7]!==d||e[8]!==u?(h=s.jsxs(jf.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},v5=()=>{const t=c.useContext(jf);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},da="aiworker_requests_in_flight",kf=1e3,$3=300*1e3,$o=Math.ceil($3/kf),W3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(da)==="1"}catch{return!1}},Cf=()=>({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 z3=1;const V3=(t,e)=>{const n=window.__aiworkerRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},U3=t=>{const e=window.__aiworkerRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Nf=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},xr=(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)},K3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=z3++;V3(o,Date.now());try{return await e(r,i)}finally{U3(o)}};window.fetch=n},Hc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Tr=t=>{t.length>$o&&t.splice(0,t.length-$o)},H3=()=>{const t=window.__aiworkerRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Nf(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(xr(e,50)),t.p90Samples.push(xr(e,90)),t.p99Samples.push(xr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Tr(t.samples),Tr(t.p50Samples),Tr(t.p90Samples),Tr(t.p99Samples),Tr(t.maxSamples),t.lastSampleAt=Date.now()},G3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(H3,kf))},Gc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},qc=t=>{if(!(typeof window>"u"))try{if(t){Gc(),Hc(),window.localStorage.setItem(da,"1"),window.__aiworkerRequestsInFlight__=Cf(),K3(),G3();return}window.localStorage.removeItem(da),Gc(),Hc(),delete window.__aiworkerRequestsInFlight__}catch{}},q3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t)return;const e=Cf();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},ua=()=>{if(typeof window>"u")return Qc();const t=window.__aiworkerRequestsInFlight__;if(!W3()||!t)return Qc();const e=Nf(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:xr(e,50),ageP90:xr(e,90),ageP99:xr(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:$o}},Qc=()=>({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:$o});function Q3(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Af=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`},fa=t=>`${(t/1e3).toFixed(2)} s`,Ss=t=>{const e=st.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},Yc=t=>{const e=st.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=Nt();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 u;e[8]!==r.entries?(u=r.entries.reduce(J3,0),e[8]=r.entries,e[9]=u):u=e[9];const d=u;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?Af(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 g;e[18]!==h||e[19]!==p?(g=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=g):g=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let S;e[23]!==r.entries.length||e[24]!==w?(S=s.jsx(Ss,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=S):S=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let m;e[28]!==x||e[29]!==d?(m=s.jsx(Ss,{label:x,value:d}),e[28]=x,e[29]=d,e[30]=m):m=e[30];let b;e[31]!==o?(b=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=b):b=e[32];let y;e[33]!==r.lastUpdatedAt||e[34]!==o?(y=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=y):y=e[35];let v;e[36]!==b||e[37]!==y?(v=s.jsx(Ss,{label:b,value:y}),e[36]=b,e[37]=y,e[38]=v):v=e[38];let N;e[39]!==m||e[40]!==v||e[41]!==S?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[S,m,v]}),e[39]=m,e[40]=v,e[41]=S,e[42]=N):N=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:[g,N,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(cn,{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},Xc=t=>{const e=st.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce(Z3,0),d=r>0?52/r:0;let h;e[0]!==u||e[1]!==a?(h=v=>a-u+v,e[0]=u,e[1]=a,e[2]=h):h=e[2];const f=h;let p;e[3]!==d?(p=v=>56-v*d,e[3]=d,e[4]=p):p=e[4];const g=p;let w;e[5]!==l?(w=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]=w):w=e[6];const S=`0 0 ${a} 56`;let x;e[7]!==a?(x=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]=x):x=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==g){let v;e[13]!==f||e[14]!==g?(v=(N,C)=>{const k=N.samples.length;if(k===0)return null;const D=N.samples.map((I,M)=>`${f(M)},${g(I).toFixed(2)}`),P=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${D.join(" L ")} L ${f(k-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:P,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=g,e[15]=v):v=e[15],m=n.map(v),e[9]=n,e[10]=f,e[11]=g,e[12]=m}else m=e[12];let b;e[16]!==o||e[17]!==S||e[18]!==x||e[19]!==m?(b=s.jsxs("svg",{viewBox:S,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,m]}),e[16]=o,e[17]=S,e[18]=x,e[19]=m,e[20]=b):b=e[20];let y;return e[21]!==w||e[22]!==b?(y=s.jsxs("div",{className:"relative w-full",children:[w,b]}),e[21]=w,e[22]=b,e[23]=y):y=e[23],y},Y3=t=>{const e=st.c(100),{onClose:n}=t,{t:r}=Nt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Je(eC),d=Ud(tC),h=Id(),f=gp(sC),p=Hs(nC),[g,w]=c.useState(rC),[S,x]=c.useState(oC),[m,b]=c.useState(iC),y=[{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 v;e[0]!==m.samples?(v=m.samples.reduce(aC,0),e[0]=m.samples,e[1]=v):v=e[1];const N=v,C=y.reduce(cC,0);let k;e[2]!==g.entries?(k=new Map,g.entries.forEach(Be=>{k.set(Be.metric,Be.count)}),e[2]=g.entries,e[3]=k):k=e[3];let D;e[4]!==k?(D=k.get("ui.message_list.render")??0,e[4]=k,e[5]=D):D=e[5];let P;e[6]!==k?(P=k.get("ui.message_list.render.streaming")??0,e[6]=k,e[7]=P):P=e[7];let I;e[8]!==k?(I=k.get("ui.chat_message.render")??0,e[8]=k,e[9]=I):I=e[9];let M;e[10]!==k?(M=k.get("ui.chat_message.render.streaming")??0,e[10]=k,e[11]=M):M=e[11];let _;e[12]!==k?(_=k.get("ui.chat_message.render.static_during_stream")??0,e[12]=k,e[13]=_):_=e[13];let O;e[14]!==k?(O=k.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=k,e[15]=O):O=e[15];let U;e[16]!==D||e[17]!==P||e[18]!==I||e[19]!==M||e[20]!==_||e[21]!==O?(U={messageListRender:D,messageListRenderStreaming:P,chatMessageRender:I,chatMessageRenderStreaming:M,chatMessageRenderStaticDuringStream:_,chatMessageRenderStaticOutsideActiveTurnDuringStream:O},e[16]=D,e[17]=P,e[18]=I,e[19]=M,e[20]=_,e[21]=O,e[22]=U):U=e[22];const L=U;let F,R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const Be=()=>{w(fo()),x(mo()),b(ua())};Be();const Ae=window.setInterval(Be,500);return()=>window.clearInterval(Ae)},F=[],e[23]=F,e[24]=R):(F=e[23],R=e[24]),c.useEffect(R,F);let j,A;e[25]!==l?(j=()=>{if(l==="idle")return;const Be=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Be)},A=[l],e[25]=l,e[26]=j,e[27]=A):(j=e[26],A=e[27]),c.useEffect(j,A);let B=0,X=0,H=0;for(const Be of Object.keys(f)){const Ae=f[Be]??[];X=X+Ae.length;for(const at of Ae)at.role==="user"?H=H+1:at.role==="assistant"&&(B=B+1)}let Z;e[28]!==B||e[29]!==X||e[30]!==H?(Z={assistant:B,total:X,user:H},e[28]=B,e[29]=X,e[30]=H,e[31]=Z):Z=e[31];const ce=Z;let Y;if(e[32]!==u||e[33]!==f||e[34]!==d||e[35]!==h||e[36]!==r){let Be;e[38]!==u||e[39]!==f||e[40]!==d||e[41]!==r?(Be=Ae=>{const at=f[Ae.id]??[];let Ue=0,ht=0;for(const Ct of at)Ct.role==="user"?ht=ht+1:Ct.role==="assistant"&&(Ue=Ue+1);const ut=d.get(Ae.id);return{id:Ae.id,title:Ae.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:Ue,messageCount:at.length,userMessageCount:ht,isStreaming:ut?.isStreaming||!1,isZombie:ut?.isZombie||!1,backgroundCount:ut?.backgroundMessageCount||0,lastAccessed:ut?.lastAccessedAt||0,isCurrent:Ae.id===u}},e[38]=u,e[39]=f,e[40]=d,e[41]=r,e[42]=Be):Be=e[42],Y=h.map(Be).sort(dC),e[32]=u,e[33]=f,e[34]=d,e[35]=h,e[36]=r,e[37]=Y}else Y=e[37];const se=Y;let oe;e[43]!==f?(oe=Object.keys(f),e[43]=f,e[44]=oe):oe=e[44];const Se=oe.length;let K;e[45]===Symbol.for("react.memo_cache_sentinel")?(K=async()=>{try{const Be={generatedAt:new Date().toISOString(),ui:fo(),vscode:mo()};await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),a("copied")}catch{a("error")}},e[45]=K):K=e[45];const pe=K,je=bp,ne="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let T;e[46]===Symbol.for("react.memo_cache_sentinel")?(T={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=T):T=e[46];let G;e[47]!==i?(G=Q3(i),e[47]=i,e[48]=G):G=e[48];let le;e[49]!==G?(le=s.jsx(E,{name:G,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=G,e[50]=le):le=e[50];let de;e[51]!==r?(de=r("memoryDebugPanel.title"),e[51]=r,e[52]=de):de=e[52];let ue;e[53]!==de?(ue=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:de}),e[53]=de,e[54]=ue):ue=e[54];let Oe;e[55]!==le||e[56]!==ue?(Oe=s.jsxs("div",{className:"flex items-center gap-2",children:[le,ue]}),e[55]=le,e[56]=ue,e[57]=Oe):Oe=e[57];let me;e[58]!==i?(me=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(xt,{size:"xs",variant:"ghost",onClick:pe,children:s.jsx(E,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(xt,{size:"xs",variant:"ghost",onClick:()=>{fm(),w(fo()),x(mo())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=me):me=e[59];let Re;e[60]!==i?(Re=i==="requests"?s.jsx(xt,{size:"xs",variant:"ghost",onClick:()=>{q3(),b(ua())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=Re):Re=e[61];let ye;e[62]!==n?(ye=n?s.jsx(xt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ye):ye=e[63];let q;e[64]!==me||e[65]!==Re||e[66]!==ye?(q=s.jsxs("div",{className:"flex items-center gap-1",children:[me,Re,ye]}),e[64]=me,e[65]=Re,e[66]=ye,e[67]=q):q=e[67];let we;e[68]!==Oe||e[69]!==q?(we=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Oe,q]}),e[68]=Oe,e[69]=q,e[70]=we):we=e[70];let be;e[71]===Symbol.for("react.memo_cache_sentinel")?(be={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=be):be=e[71];const Ne=i==="memory"?"secondary":"ghost";let ie;e[72]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>o("memory"),e[72]=ie):ie=e[72];let ee;e[73]!==r?(ee=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=ee):ee=e[74];let V;e[75]!==Ne||e[76]!==ee?(V=s.jsx(xt,{size:"sm",variant:Ne,className:"flex-1",onClick:ie,children:ee}),e[75]=Ne,e[76]=ee,e[77]=V):V=e[77];const $=i==="streaming"?"secondary":"ghost";let ae;e[78]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>o("streaming"),e[78]=ae):ae=e[78];let W;e[79]!==r?(W=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=W):W=e[80];let ve;e[81]!==$||e[82]!==W?(ve=s.jsx(xt,{size:"sm",variant:$,className:"flex-1",onClick:ae,children:W}),e[81]=$,e[82]=W,e[83]=ve):ve=e[83];const Fe=i==="requests"?"secondary":"ghost";let Ce;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>o("requests"),e[84]=Ce):Ce=e[84];let ke;e[85]!==r?(ke=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=ke):ke=e[86];let Qe;e[87]!==Fe||e[88]!==ke?(Qe=s.jsx(xt,{size:"sm",variant:Fe,className:"flex-1",onClick:Ce,children:ke}),e[87]=Fe,e[88]=ke,e[89]=Qe):Qe=e[89];let We;e[90]!==V||e[91]!==ve||e[92]!==Qe?(We=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:be,children:[V,ve,Qe]}),e[90]=V,e[91]=ve,e[92]=Qe,e[93]=We):We=e[93];const z=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(Ss,{label:r("memoryDebugPanel.metric.totalMessages"),value:ce.total}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Se} / ${hl.MAX_SESSIONS}`}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.userMessages"),value:ce.user}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ce.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:xp()})})]}),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:hl.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(cn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:se.map(Be=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Be.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:Be.title}),Be.isStreaming?s.jsx(E,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Be.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:Be.assistantMessageCount,user:Be.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Be.messageCount})}),Be.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Be.backgroundCount]}):null]})]},Be.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(uC),currentSessionId:u,cachedSessions:Object.keys(f),messageRoleCounts:ce,sessionMessageRoleCounts:se.map(fC),memoryStates:Object.fromEntries(d)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Pt,{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(xt,{size:"xs",variant:"outline",onClick:pe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Ss,{label:r("memoryDebugPanel.metric.uiMetrics"),value:g.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:S.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Yc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:g,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),S.entries.length>0?s.jsx(Yc,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:S,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(Ss,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(Ss,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?Af(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(Xc,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${N}`}),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:fa(m.peakAgeMs)})]}),s.jsx(Xc,{series:y.map(mC),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:fa(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(hC)}),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 he;return e[94]!==je||e[95]!==T||e[96]!==we||e[97]!==We||e[98]!==z?(he=s.jsxs(je,{className:ne,style:T,children:[we,We,z]}),e[94]=je,e[95]=T,e[96]=we,e[97]=We,e[98]=z,e[99]=he):he=e[99],he},X3=Y3;function J3(t,e){return t+e.count}function Z3(t,e){return Math.max(t,e.samples.length)}function eC(t){return t.currentSessionId}function tC(t){return t.sessionMemoryState}function sC(t){return t.message}function nC(t){return t.totalRequestCount}function rC(){return fo()}function oC(){return mo()}function iC(){return ua()}function aC(t,e){return Math.max(t,e)}function lC(t,e){return Math.max(t,e)}function cC(t,e){return e.samples.reduce(lC,t)}function dC(t,e){return e.lastAccessed-t.lastAccessed}function uC(t){return{id:t.id,title:t.title}}function fC(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function mC(t){return{samples:t.samples,color:t.color}}function hC(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:fa(t.current)})]},t.label)}const pC=()=>{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()??"":""},gC=async()=>{const t=pC()||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")},Jc="aiworker:menu-action",bi="aiworker:check-for-updates",xC=t=>{const e=Je(m=>m.openNewSessionDraft),n=Te(m=>m.toggleCommandPalette),r=Te(m=>m.setCommandPaletteOpen),i=Te(m=>m.toggleHelpDialog),o=Te(m=>m.toggleSidebar),l=Te(m=>m.setSessionSwitcherOpen),a=Te(m=>m.setSettingsDialogOpen),u=Te(m=>m.setAboutDialogOpen),d=Fr(m=>m.checkForUpdates),{setThemeMode:h}=Zn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,d().then(()=>{const{available:m,error:b}=Fr.getState();if(b){Le.error("Failed to check for updates",{description:b});return}m||Le.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[d]),g=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const b=yp();if(b.length===0)return;const y=Je.getState().currentSessionId,v=b.findIndex(k=>k.id===y);let N=m>0?0:b.length-1;v>=0&&(N=(v+m+b.length)%b.length);const C=b[N];C&&(l(!1),Je.getState().setCurrentSession(C.id))},[l]),S=c.useCallback(m=>{const{activeProjectId:b,projects:y,setActiveProject:v}=Ht.getState();if(y.length===0)return;const N=y.findIndex(D=>D.id===b);let C=m>0?0:y.length-1;N>=0&&(C=(N+m+y.length)%y.length);const k=y[C];k&&v(k.id)},[]),x=c.useCallback(m=>{switch(m){case"about":u(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const b=Je.getState(),y=ts.getState().currentDirectory;e(b.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Fd();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const b=ts.getState().currentDirectory;if(!b)break;const y=Te.getState(),v=or(b),N=y.contextPanelByDirectory[v];N?.isOpen?y.closeContextPanel(v):N?.activeTabId?y.setActiveContextPanelTab(v,N.activeTabId):y.openContextSurface(v,"git");break}case"open-right-sidebar-git":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"git");break}case"open-right-sidebar-files":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"file");break}case"toggle-terminal":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"terminal");break}case"toggle-terminal-expanded":{const b=ts.getState().currentDirectory;if(!b)break;const y=or(b),v=Te.getState(),N=v.contextPanelByDirectory[y];(N?.isOpen?N.tabs.find(k=>k.id===N.activeTabId)?.mode:null)!=="terminal"&&v.openContextSurface(y,"terminal"),v.toggleContextPanelExpanded(y);break}case"copy":{const b=new Event("aiworker:copy",{cancelable:!0});!window.dispatchEvent(b)||gC();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":wp();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ts.getState().goBack();break;case"go-forward":ts.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":S(-1);break;case"next-project":S(1);break;case"help-dialog":i();break;case"download-logs":{Bd().catch(()=>{Le.error("Failed to collect OpenCode status")});break}}},[g,S,w,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=y=>{const v=y.detail;v&&x(v)},b=()=>{p()};return window.addEventListener(Jc,m),window.addEventListener(bi,b),()=>{window.removeEventListener(Jc,m),window.removeEventListener(bi,b)}},[x,p]),c.useEffect(()=>{if(typeof window>"u")return;const b=window.__AIWORKER_DESKTOP__?.listen;if(typeof b!="function")return;let y=null,v=null;return b("aiworker:menu-action",N=>{const C=N?.payload;typeof C=="string"&&x(C)}).then(N=>{y=N}).catch(()=>{}),b("aiworker:check-for-updates",()=>{window.dispatchEvent(new Event(bi))}).then(N=>{v=N}).catch(()=>{}),()=>{(async()=>{try{const C=y?.();C instanceof Promise&&await C}catch{}try{const C=v?.();C instanceof Promise&&await C}catch{}})()}},[x])},bC="aiworker:tray-action",Zc=5e3,yC=500,Df=20,ed=()=>{if(typeof window>"u")return!1;const t=window.__AIWORKER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},td=()=>typeof window<"u"&&window.__AIWORKER_ELECTRON__?.trayEnabled!==!1,wC=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},SC=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Pf=(t,e)=>Gd(t,e,Wr.getState().ids,ja.getState().rankById),vC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},jC=(t,e,n,r,i)=>{if(!t)return"";const o=hd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||vC(t),u=go(t);let d=u&&i.get(u)||"";if(!d){for(const[h,f]of Dn.getState().directories)if(go(h)===u){d=f.status?.current??"";break}}if(!d)for(const h of r.values()){const f=h.find(p=>go(p.path)===u);if(f?.branch){d=f.branch;break}}return d?`${a} · ${d}`:a},kC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ar.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 jp){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;u.push({label:Cp(h),value:kp(f.valueLabel,p)})}const d=!a.ok&&a.error?a.error:u.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:u,status:d})}return{mode:r,groups:o}},CC=async()=>{try{if(Wo())return"Local AiWorker";const t=window.__AIWORKER_LOCAL_ORIGIN__||window.location.origin,e=Nn();if(e&&Qa(e,t))return"Local AiWorker";const r=(await ld()).hosts.find(i=>e?Qa(e,mm(i)):!1);return r?.label?.trim()?cd(r.label.trim()):"Instance"}catch{return""}},NC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Do()}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(go(o)??o,a.vcs.branch);for(const u of a.session)u?.id&&r.set(u.id,u.title);for(const[u,d]of Object.entries(a.session_status??{})){const h=d?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,f)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:wC(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:SC(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},AC=()=>{const t=Is.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Pf).slice(0,Df).forEach(r=>{const i=Ts(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=Ts(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},DC=t=>{const e=NC(),n=Da.getState().index.session,r=Is.getState().activeSessions,i=new Map(e.titleById),o=new Map;for(const x of r)if(x?.id&&(x.title&&i.set(x.id,x.title),x.parentID)){const m=o.get(x.parentID)??[];m.push(x.id),o.set(x.parentID,m)}const l=x=>{const m=[],b=[...o.get(x)??[]],y=new Set;for(;b.length;){const v=b.pop();y.has(v)||(y.add(v),m.push(v),b.push(...o.get(v)??[]))}return m},a=Aa.getState().statusById,u=x=>{const m=e.statusById.get(x);return m&&m!=="idle"?m:a.get(x)?.status.type??m??"idle"},d=x=>{const m=x.map(b=>u(b));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=Ht.getState().projects,f=Je.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort(Pf).slice(0,Df).map(x=>{const m=[x.id,...l(x.id)],b=Ts(x)??"";return{id:x.id,title:x.title||"Untitled session",status:d(m),branch:b?e.branchByDirectory.get(b)??"":"",unseen:m.reduce((y,v)=>y+(n.unseenCount[v]??0),0),hasError:m.some(y=>n.unseenHasError[y]??!1),directory:b,subtitle:jC(b,x,h,f,e.branchByDirectory)}}),g=e.approvals.map(x=>({...x,sessionTitle:i.get(x.sessionId)||""})),w=Te.getState();let S=0;if(w.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let m=n.unseenCount[x.id]??0;m===0&&w.notifyOnSubtasks&&(m=l(x.id).reduce((b,y)=>b+(n.unseenCount[y]??0),0)),m>0&&(S+=1)}return{sessions:p,approvals:g,instanceName:t,usage:kC(),dockBadgeCount:S}},PC=()=>{c.useEffect(()=>{if(!ed()||!td()||!Vo())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=DC(r),k=JSON.stringify(C);k!==e&&(e=k,Mn("desktop_tray_update",C))};CC().then(C=>{t||(r=C,i())});const o=async()=>{const C=AC();await Promise.all([...C.entries()].map(async([k,D])=>{const P=await Qs.getSessionStatusForDirectory(k).catch(()=>null);t||P===null||Sp(k,P,D)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},yC))},a=new Map,u=()=>{if(t)return;let C;try{C=Do()}catch{return}const k=new Set;for(const[D,P]of C.children.entries())k.add(D),a.has(D)||a.set(D,P.subscribe(()=>l()));for(const[D,P]of a)k.has(D)||(P(),a.delete(D))};let d=null;try{d=Do().subscribeRegistry(()=>{u(),l()})}catch{}u();const h=Da.subscribe(()=>l()),f=Is.subscribe(()=>l()),p=Ht.subscribe(()=>l()),g=Je.subscribe(()=>l()),w=Dn.subscribe(()=>l()),S=Te.subscribe(()=>l()),x=Aa.subscribe(()=>l()),m=ja.subscribe(()=>l()),b=Wr.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},Zc),v=ar.subscribe(()=>l());ar.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:C,results:k}=ar.getState();C.length>0&&C.some(P=>!k.some(I=>I.providerId===P))&&ar.getState().fetchQuotas(C)});const N=window.setInterval(()=>{u(),i()},Zc);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),h(),f(),p(),g(),w(),S(),x(),m(),b(),v(),d?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!ed()||!td()||typeof window>"u")return;const e=window.__AIWORKER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&vp(i.sessionId,i.id,i.response).catch(()=>{Le.error("Failed to respond to permission request")})};let r=null;return e(bC,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{}}},[])},IC=45e3,TC=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,IC);return()=>r(i)},RC=t=>{const e=st.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return TC(EC,MC)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function EC(){Np(Po())}function MC(){Ta()}const OC="/api/notifications/stream",FC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),BC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="aiworker:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},_C=t=>{const e=st.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||bn()||!ha()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ud().sse(OC));return o.onmessage=LC,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function LC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Te.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&FC())return;const r=BC(e);if(!r)return;zo()?.notifications?.notifyAgentCompletion(r)}const $C=6e4,WC=t=>{const e=st.c(10),n=Te(zC),r=Ap(VC),o=Dg(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:$C})},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 u,d;e[5]!==n||e[6]!==r||e[7]!==o?(u=()=>{if(n)return Yr(h=>{h.type==="agent-memory-changed"&&r(o)})},d=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=u,e[9]=d):(u=e[8],d=e[9]),c.useEffect(u,d)};function zC(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function VC(t){return t.load}const sd="pwa-install-toast-shown",nd="pwa-install-toast-dismissed",UC=()=>{const t=st.c(6),{browserTab:e}=Pg(),{t:n}=Nt(),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"||!ha()||!e)return;let u=null,d=null;const h=()=>{d!==null&&(Le.dismiss(d),d=null)},f=async()=>{if(!u)return;const w=u;u=null,h(),await w.prompt();const{outcome:S}=await w.userChoice;S==="accepted"&&Le.success(r.current("pwa.installPrompt.started"))},p=w=>{const S=w;if(typeof S.prompt!="function")return;S.preventDefault(),u=S;const x=No(),m=hm();Ig({dismissed:x.getItem(nd),sessionShown:m.getItem(sd),hasActiveToast:d!==null})&&(m.setItem(sd,"true"),d=Le.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:()=>{No().setItem(nd,"true"),h()}}}))},g=()=>{u=null,h(),Le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",g),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",g)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},KC=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[u,d]=c.useState(!1),[h,f]=c.useState(!1),[p,g]=c.useState(null),[w,S]=c.useState(!1);c.useCallback(async()=>{},[p,u,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const b=await ds("/api/system/info");if(b.ok){const y=await b.json();if(typeof y.aiworkerVersion=="string"&&y.aiworkerVersion.trim()){o(y.aiworkerVersion);return}}}catch{}o(await Dp())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const y=await ds("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!y.ok)return;const v=await y.json().catch(()=>null),N=typeof v?.currentVersion=="string"?v.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{g(null),S(!1);return}},[t,r]);const x=i;return s.jsx(vs,{open:t,onOpenChange:e,children:s.jsx(js,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Td,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"AiWorker"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),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://roweb.cn/roweb/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(E,{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(E,{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(E,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@aiworker_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},rd=t=>{if(!(typeof window>"u")){if(t){window.location.href="aiworker://focus/mcp-auth";return}window.location.replace("/")}},yi=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},HC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to AiWorker and click Authorize again.":n},GC=()=>{const t=Pp(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),u=yi(a,"code"),d=Ip(a),h=Tp(a),f=yi(a,"error"),p=yi(a,"error_description");if(f){h&&ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(p??f);return}(async()=>{try{if(!u)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");let g=d,w=!1;if(h){const S=await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(S.ok){const x=await S.json().catch(()=>null);w=x?.origin===Rp,i(w),!g&&x?.name?.trim()&&(g={name:x.name.trim(),directory:typeof x.directory=="string"&&x.directory.trim()?x.directory.trim():null})}}if(!g?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");await t(g.name,u,g.directory),h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&rd(!0),l("Authorization completed. You can close this tab and return to AiWorker.")}catch(g){h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(HC(g,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:Ep,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Ie("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(xt,{type:"button",onClick:()=>rd(r),children:"Return to AiWorker"})})]})})},od=Ln(()=>Bn(()=>import("./OnboardingScreen-B8fm1H4m.js"),__vite__mapDeps([145,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])).then(t=>({default:t.OnboardingScreen}))),qC=()=>{const t=st.c(3),e=Te(e5),n=Te(t5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(KC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},QC=t=>{const e=st.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=Nt();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let u;e[6]!==a?(u=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,u]}),e[8]=l,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(xt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let p;return e[18]!==d||e[19]!==f?(p=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[d,f]})}),e[18]=d,e[19]=f,e[20]=p):p=e[20],p},id=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",YC=()=>{if(typeof window>"u"||!nx())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}},XC=()=>typeof window>"u"?!1:window.location.pathname===_p,JC=t=>{const e=st.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ts(s5),l=Je(n5),a=Je(r5),u=Cd(),d=c.useRef(null);let h;e[0]!==n.directory?(h=id(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let p;e[2]!==o?(p=id(o),e[2]=o,e[3]=p):p=e[3];const g=p;let w,S;if(e[4]!==g||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==u?(w=()=>{if(r||f&&g!==f)return;const N=`${f}
929
+ `)?(f(We),d(!0)):d(!1);return}d(!1)},e[12]=U):U=e[12];const L=U;let F;e[13]!==n.id||e[14]!==o?(F=W=>{o(n.id,{prompt:W})},e[13]=n.id,e[14]=o,e[15]=F):F=e[15];const R=F;let j;e[16]!==n.prompt||e[17]!==R?(j=W=>{const ve=n.prompt,Ce=v.current?.selectionStart??ve.length,Qe=ve.substring(0,Ce).lastIndexOf("@"),We=W.relativePath&&W.relativePath.trim().length>0?W.relativePath.trim():W.path||W.name,z=Qe!==-1?Qe:Ce,he=`${ve.substring(0,z)}@${We} ${ve.substring(Ce)}`,Be=z+We.length+2;R(he),d(!1),f(""),requestAnimationFrame(()=>{const Ae=v.current;Ae&&(Ae.selectionStart=Be,Ae.selectionEnd=Be,Ae.focus()),L(he,Be)})},e[16]=n.prompt,e[17]=R,e[18]=j):j=e[18];const A=j;let B;e[19]!==n.prompt||e[20]!==R?(B=W=>{const ve=n.prompt,Ce=v.current?.selectionStart??ve.length,Qe=ve.substring(0,Ce).lastIndexOf("@"),We=Qe!==-1?Qe:Ce,z=`${ve.substring(0,We)}@${W} ${ve.substring(Ce)}`,he=We+W.length+2;R(z),d(!1),f(""),requestAnimationFrame(()=>{const Be=v.current;Be&&(Be.selectionStart=he,Be.selectionEnd=he,Be.focus()),L(z,he)})},e[19]=n.prompt,e[20]=R,e[21]=B):B=e[21];const X=B;let H;e[22]!==R?(H=W=>{const ve=`/${W.name} `;R(ve),g(!1),S(""),m(!1),requestAnimationFrame(()=>{const Fe=v.current;Fe&&(Fe.focus(),Fe.selectionStart=Fe.value.length,Fe.selectionEnd=Fe.value.length),L(ve,ve.length)})},e[22]=R,e[23]=H):H=e[23];const Z=H;let ce;e[24]!==n.prompt||e[25]!==R?(ce=(W,ve)=>{const Fe=n.prompt,ke=v.current?.selectionStart??Fe.length,We=Fe.substring(0,ke).lastIndexOf("#"),z=We!==-1?We:ke,he=`${Fe.substring(0,z)}#${ve} ${Fe.substring(ke)}`,Be=z+ve.length+2;R(he),m(!1),y(""),requestAnimationFrame(()=>{const Ae=v.current;Ae&&(Ae.selectionStart=Be,Ae.selectionEnd=Be,Ae.focus()),L(he,Be)})},e[24]=n.prompt,e[25]=R,e[26]=ce):ce=e[26];const Y=ce;let se;e[27]!==p||e[28]!==u||e[29]!==x?(se=W=>{if(p&&C.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")){W.preventDefault(),C.current.handleKeyDown(W.key);return}u&&N.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")&&(W.preventDefault(),N.current.handleKeyDown(W.key)),x&&k.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")&&(W.preventDefault(),k.current.handleKeyDown(W.key))},e[27]=p,e[28]=u,e[29]=x,e[30]=se):se=e[30];const oe=se,Se=r+1;let K;e[31]!==a||e[32]!==Se?(K=a("multirun.launcher.groups.groupLabel",{index:Se}),e[31]=a,e[32]=Se,e[33]=K):K=e[33];let pe;e[34]!==K?(pe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:K}),e[34]=K,e[35]=pe):pe=e[35];let je;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(je=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(E,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=je):je=e[40];let ne;e[41]!==pe||e[42]!==je?(ne=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[pe,je]}),e[41]=pe,e[42]=je,e[43]=ne):ne=e[43];let T;e[44]!==a?(T=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=T):T=e[45];let G;e[46]!==T?(G=s.jsx(Kn,{required:!0,children:T}),e[46]=T,e[47]=G):G=e[47];const le=n.prompt;let de;e[48]!==R?(de=W=>{const ve=W.target.value;R(ve);const Fe=W.target.selectionStart??ve.length;L(ve,Fe)},e[48]=R,e[49]=de):de=e[49];let ue;e[50]!==a?(ue=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=ue):ue=e[51];let Oe;e[52]!==n.prompt||e[53]!==oe||e[54]!==de||e[55]!==ue?(Oe=s.jsx(lr,{ref:v,value:le,onChange:de,onKeyDown:oe,placeholder:ue,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]=oe,e[54]=de,e[55]=ue,e[56]=Oe):Oe=e[56];let me;e[57]!==w||e[58]!==Z||e[59]!==p?(me=p?s.jsx(qd,{ref:C,searchQuery:w,onCommandSelect:Z,onClose:()=>g(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=Z,e[59]=p,e[60]=me):me=e[60];let Re;e[61]!==X||e[62]!==A||e[63]!==h||e[64]!==u?(Re=u?s.jsx(Qd,{ref:N,searchQuery:h,onFileSelect:A,onAgentSelect:X,onClose:()=>d(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=A,e[63]=h,e[64]=u,e[65]=Re):Re=e[65];let ye;e[66]!==Y||e[67]!==x||e[68]!==b?(ye=x?s.jsx(Yd,{ref:k,searchQuery:b,onSnippetSelect:Y,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=Y,e[67]=x,e[68]=b,e[69]=ye):ye=e[69];let q;e[70]!==Oe||e[71]!==me||e[72]!==Re||e[73]!==ye?(q=s.jsxs("div",{className:"relative",children:[Oe,me,Re,ye]}),e[70]=Oe,e[71]=me,e[72]=Re,e[73]=ye,e[74]=q):q=e[74];let we;e[75]!==G||e[76]!==q?(we=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[G,q]}),e[75]=G,e[76]=q,e[77]=we):we=e[77];let be;e[78]!==a?(be=a("multirun.launcher.models.info"),e[78]=a,e[79]=be):be=e[79];let Ne;e[80]!==be?(Ne=s.jsx(Co,{children:be}),e[80]=be,e[81]=Ne):Ne=e[81];let ie;e[82]!==a?(ie=a("multirun.launcher.models.label"),e[82]=a,e[83]=ie):ie=e[83];let ee;e[84]!==Ne||e[85]!==ie?(ee=s.jsx(Kn,{required:!0,info:Ne,children:ie}),e[84]=Ne,e[85]=ie,e[86]=ee):ee=e[86];let V;e[87]!==n.models||e[88]!==P||e[89]!==M||e[90]!==O?(V=s.jsx(hf,{selectedModels:n.models,onAdd:P,onRemove:M,onUpdate:O,minModels:1}),e[87]=n.models,e[88]=P,e[89]=M,e[90]=O,e[91]=V):V=e[91];let $;e[92]!==ee||e[93]!==V?($=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ee,V]}),e[92]=ee,e[93]=V,e[94]=$):$=e[94];let ae;return e[95]!==ne||e[96]!==we||e[97]!==$?(ae=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[ne,we,$]}),e[95]=ne,e[96]=we,e[97]=$,e[98]=ae):ae=e[98],ae},n3=t=>{const e=new Map;for(const n of t){const r=Ts(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},r3=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},o3=t=>{const e=st.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,u;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const d=us(),h=n3(i),f=l.current?.runtimeKey===d?l.current.identities:null;for(const p of r3(f,h))pp({runtimeKey:d,...p});l.current={runtimeKey:d,identities:h}},u=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=u):(a=e[3],u=e[4]),c.useEffect(a,u)},i3=new Map,a3=t=>{const e=st.c(26),{isVSCode:n}=t,r=Ia(),i=Ht(l3),o=Ht(c3),l=ts(d3),a=Je(u3);let u;e[0]!==n?(u=I=>n?i3:I.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Je(u),h=!n;let f;e[2]!==d||e[3]!==i||e[4]!==h?(f=bf(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=f):f=e[5];const p=f,g=Is(f3),w=Is(m3),S=Is(h3),x=`session-list-sync:${c.useId()}`;let m,b;e[6]!==o||e[7]!==x||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==p||e[12]!==i?(m=()=>(r.setBootstrapDemand(x,lf({knownDirectories:p,activeProjectDirectory:vt(i.find(I=>I.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),b=[o,x,r,l,a,p,i],e[6]=o,e[7]=x,e[8]=r,e[9]=l,e[10]=a,e[11]=p,e[12]=i,e[13]=m,e[14]=b):(m=e[13],b=e[14]),c.useEffect(m,b);const y=c.useRef(null);let v,N;e[15]!==n||e[16]!==p?(v=()=>{const I=new Set(p),M=y.current;y.current=I;const _=M?[...I].filter(O=>!M.has(O)):n?[...I]:[];_.length&&xa(_,Po())},N=[n,p],e[15]=n,e[16]=p,e[17]=v,e[18]=N):(v=e[17],N=e[18]),c.useEffect(v,N);let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[19]=C):C=e[19],c.useEffect(p3,C);let k;e[20]!==w||e[21]!==g?(k=[...g,...w],e[20]=w,e[21]=g,e[22]=k):k=e[22];const D=k;let P;e[23]!==D||e[24]!==S?(P={enabled:!0,hasAuthoritativeGlobalSessions:S,sessions:D},e[23]=D,e[24]=S,e[25]=P):P=e[25],o3(P)};function l3(t){return t.projects}function c3(t){return t.activeProjectId}function d3(t){return t.currentDirectory}function u3(t){return t.currentSessionDirectory}function f3(t){return t.activeSessions}function m3(t){return t.archivedSessions}function h3(t){return t.status==="ready"}function p3(){let t=null,e=!1;const n=new Set,r=Yr(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(),Ta(Po());return}const o=[...n];n.clear(),o.length&&xa(o,Po())},500)});return()=>{t&&clearTimeout(t),r()}}const g3=Ln(()=>Bn(()=>import("./SettingsWindow-DbgEnZ6T.js"),__vite__mapDeps([140,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,141,84,142,127,128,129,130,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,143,144])).then(t=>({default:t.SettingsWindow}))),x3=()=>{const t=st.c(58);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],a3(e),Cg();const n=Te(b3),r=Te(y3),i=Te(w3),o=Te(S3),[l,a]=c.useState(!1);let u,d;t[1]!==i?(u=()=>{i&&a(!0)},d=[i],t[1]=i,t[2]=u,t[3]=d):(u=t[2],d=t[3]),c.useEffect(u,d);const h=Te(v3),f=Te(j3),p=Te(k3),g=Te(C3),w=Te(N3),S=Te(A3),x=g||w||!!S||h;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[4]=m):m=t[4],c.useEffect(P3,m);const{isMobile:b}=_n();Ng();const y=nb();let v,N;t[5]!==b||t[6]!==r?(v=()=>{Te.getState().isMobile!==b&&r(b)},N=[b,r],t[5]=b,t[6]=r,t[7]=v,t[8]=N):(v=t[7],N=t[8]),c.useEffect(v,N);let C,k,D,P;t[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(WS,{}),k=s.jsx(Bv,{}),D=s.jsx(Wv,{}),P=s.jsx(s4,{}),t[9]=C,t[10]=k,t[11]=D,t[12]=P):(C=t[9],k=t[10],D=t[11],P=t[12]);let I;t[13]!==y?(I=s.jsx(n4,{value:y,onMoveSessionOnly:I3,onMoveAllChanges:T3,onCancel:fb}),t[13]=y,t[14]=I):I=t[14];let M;t[15]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Sb,{}),t[15]=M):M=t[15];let _;t[16]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(wb,{}),t[16]=_):_=t[16];let O;t[17]!==n?(O=s.jsx(t4,{isVisible:n}),t[17]=n,t[18]=O):O=t[18];let U;t[19]!==b||t[20]!==n||t[21]!==O?(U=s.jsx(yb,{isOpen:n,isMobile:b,className:"border-border",topBar:_,children:O}),t[19]=b,t[20]=n,t[21]=O,t[22]=U):U=t[22];let L;t[23]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(xb,{}),t[23]=L):L=t[23];const F=x&&"invisible";let R;t[24]!==F?(R=Ie("absolute inset-0",F),t[24]=F,t[25]=R):R=t[25];const j=!i&&!x;let A;t[26]!==j?(A=s.jsx(Gs,{children:s.jsx(iu,{active:j})}),t[26]=j,t[27]=A):A=t[27];let B;t[28]!==R||t[29]!==A?(B=s.jsx("div",{className:R,children:A}),t[28]=R,t[29]=A,t[30]=B):B=t[30];let X;t[31]!==h||t[32]!==p||t[33]!==f?(X=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Gs,{children:s.jsx(t3,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[31]=h,t[32]=p,t[33]=f,t[34]=X):X=t[34];let H;t[35]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Gs,{children:s.jsx(I4,{})}),t[35]=H):H=t[35];let Z;t[36]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Gs,{children:s.jsx(T4,{})}),t[36]=Z):Z=t[36];let ce;t[37]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(Gs,{children:s.jsx(W4,{})}),t[37]=ce):ce=t[37];let Y;t[38]!==B||t[39]!==X?(Y=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[B,X,H,Z,ce]}),t[38]=B,t[39]=X,t[40]=Y):Y=t[40];let se;t[41]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(uS,{}),t[41]=se):se=t[41];let oe;t[42]!==Y?(oe=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:[Y,se]})})}),t[42]=Y,t[43]=oe):oe=t[43];let Se;t[44]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Gs,{children:s.jsx(SS,{})})}),t[44]=Se):Se=t[44];let K;t[45]!==oe?(K=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[L,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[oe,Se]})]}),t[45]=oe,t[46]=K):K=t[46];let pe;t[47]!==U||t[48]!==K?(pe=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[U,K]}),t[47]=U,t[48]=K,t[49]=pe):pe=t[49];let je;t[50]!==i||t[51]!==o||t[52]!==l?(je=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(g3,{open:i,onOpenChange:o})}):null,t[50]=i,t[51]=o,t[52]=l,t[53]=je):je=t[53];let ne;return t[54]!==I||t[55]!==pe||t[56]!==je?(ne=s.jsx(Ag,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[C,k,D,P,I,M,pe,je]})}),t[54]=I,t[55]=pe,t[56]=je,t[57]=ne):ne=t[57],ne};function b3(t){return t.isSidebarOpen}function y3(t){return t.setIsMobile}function w3(t){return t.isSettingsDialogOpen}function S3(t){return t.setSettingsDialogOpen}function v3(t){return t.isMultiRunLauncherOpen}function j3(t){return t.setMultiRunLauncherOpen}function k3(t){return t.multiRunLauncherPrefillPrompt}function C3(t){return t.isScheduledTasksDialogOpen}function N3(t){return t.isArchivePageOpen}function A3(t){return t.worktreesPageProjectId}function D3(){return Te.getState().closeMainSurfaces()}function P3(){const t=D3,e=Je.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 I3(){return Ru(!1)}function T3(){return Ru(!0)}const vf=12,R3=[{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"}],E3=t=>{const e=st.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,u=r===void 0?0:r,d=o===void 0?900:o,h=l===void 0?R3:l,f=gt.useRef(!1);let p,g;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},g=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=g):(p=e[2],g=e[3]),gt.useEffect(p,g);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:vf},M3),e[4]=w):w=e[4];const S=w;if(!n)return null;let x;e[5]!==i?(x=Ie("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let m;if(e[7]!==u||e[8]!==h||e[9]!==d){let y;e[11]!==u||e[12]!==d?(y=v=>{const N={"--burst-delay":`${v.delay}ms`,"--burst-x":`${v.x}%`,"--burst-y":`${v.y}%`,"--firework-color":`var(${v.colorVar})`,"--firework-duration":`${d}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:S.map((C,k)=>{const D=C.x*v.radius,P=C.y*v.radius,I={"--translate-x":`${D}px`,"--translate-y":`${P}px`,"--particle-delay":`${C.delay}ms`,color:`var(${v.colorVar})`};return s.jsx("span",{className:"firework-particle",style:I},`${v.id}-${k}-${u}`)})},`${v.id}-${u}`)},e[11]=u,e[12]=d,e[13]=y):y=e[13],m=h.map(y),e[7]=u,e[8]=h,e[9]=d,e[10]=m}else m=e[10];let b;return e[14]!==u||e[15]!==x||e[16]!==m?(b=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":u,children:m}),e[14]=u,e[15]=x,e[16]=m,e[17]=b):b=e[17],b};function M3(t,e){const n=Math.PI*2*e/vf;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const O3=t=>{const e=st.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]=gt.useState(o),u=gt.useRef(null);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},e[3]=d):d=e[3];const h=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(F3)},e[4]=f):f=e[4];const p=f;let g;e[5]!==i?(g=()=>{h(),a(B3),u.current=window.setTimeout(()=>{a(_3),u.current=null},i)},e[5]=i,e[6]=g):g=e[6];const w=g;let S,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>h(),x=[h],e[7]=S,e[8]=x):(S=e[7],x=e[8]),gt.useEffect(S,x);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function F3(t){return t.isActive?{...t,isActive:!1}:t}function B3(t){return{isActive:!0,cycle:t.cycle+1}}function _3(t){return t.isActive?{...t,isActive:!1}:t}const jf=c.createContext(void 0),L3=t=>{const e=st.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=O3();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 u=a;let d;e[3]!==i||e[4]!==r?(d=s.jsx(E3,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let h;return e[6]!==n||e[7]!==d||e[8]!==u?(h=s.jsxs(jf.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},v5=()=>{const t=c.useContext(jf);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},da="aiworker_requests_in_flight",kf=1e3,$3=300*1e3,$o=Math.ceil($3/kf),W3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(da)==="1"}catch{return!1}},Cf=()=>({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 z3=1;const V3=(t,e)=>{const n=window.__aiworkerRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},U3=t=>{const e=window.__aiworkerRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Nf=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},xr=(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)},K3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=z3++;V3(o,Date.now());try{return await e(r,i)}finally{U3(o)}};window.fetch=n},Hc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Tr=t=>{t.length>$o&&t.splice(0,t.length-$o)},H3=()=>{const t=window.__aiworkerRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Nf(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(xr(e,50)),t.p90Samples.push(xr(e,90)),t.p99Samples.push(xr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Tr(t.samples),Tr(t.p50Samples),Tr(t.p90Samples),Tr(t.p99Samples),Tr(t.maxSamples),t.lastSampleAt=Date.now()},G3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(H3,kf))},Gc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},qc=t=>{if(!(typeof window>"u"))try{if(t){Gc(),Hc(),window.localStorage.setItem(da,"1"),window.__aiworkerRequestsInFlight__=Cf(),K3(),G3();return}window.localStorage.removeItem(da),Gc(),Hc(),delete window.__aiworkerRequestsInFlight__}catch{}},q3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t)return;const e=Cf();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},ua=()=>{if(typeof window>"u")return Qc();const t=window.__aiworkerRequestsInFlight__;if(!W3()||!t)return Qc();const e=Nf(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:xr(e,50),ageP90:xr(e,90),ageP99:xr(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:$o}},Qc=()=>({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:$o});function Q3(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Af=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`},fa=t=>`${(t/1e3).toFixed(2)} s`,Ss=t=>{const e=st.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},Yc=t=>{const e=st.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=Nt();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 u;e[8]!==r.entries?(u=r.entries.reduce(J3,0),e[8]=r.entries,e[9]=u):u=e[9];const d=u;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?Af(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 g;e[18]!==h||e[19]!==p?(g=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=g):g=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let S;e[23]!==r.entries.length||e[24]!==w?(S=s.jsx(Ss,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=S):S=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let m;e[28]!==x||e[29]!==d?(m=s.jsx(Ss,{label:x,value:d}),e[28]=x,e[29]=d,e[30]=m):m=e[30];let b;e[31]!==o?(b=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=b):b=e[32];let y;e[33]!==r.lastUpdatedAt||e[34]!==o?(y=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=y):y=e[35];let v;e[36]!==b||e[37]!==y?(v=s.jsx(Ss,{label:b,value:y}),e[36]=b,e[37]=y,e[38]=v):v=e[38];let N;e[39]!==m||e[40]!==v||e[41]!==S?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[S,m,v]}),e[39]=m,e[40]=v,e[41]=S,e[42]=N):N=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:[g,N,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(cn,{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},Xc=t=>{const e=st.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce(Z3,0),d=r>0?52/r:0;let h;e[0]!==u||e[1]!==a?(h=v=>a-u+v,e[0]=u,e[1]=a,e[2]=h):h=e[2];const f=h;let p;e[3]!==d?(p=v=>56-v*d,e[3]=d,e[4]=p):p=e[4];const g=p;let w;e[5]!==l?(w=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]=w):w=e[6];const S=`0 0 ${a} 56`;let x;e[7]!==a?(x=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]=x):x=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==g){let v;e[13]!==f||e[14]!==g?(v=(N,C)=>{const k=N.samples.length;if(k===0)return null;const D=N.samples.map((I,M)=>`${f(M)},${g(I).toFixed(2)}`),P=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${D.join(" L ")} L ${f(k-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:P,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=g,e[15]=v):v=e[15],m=n.map(v),e[9]=n,e[10]=f,e[11]=g,e[12]=m}else m=e[12];let b;e[16]!==o||e[17]!==S||e[18]!==x||e[19]!==m?(b=s.jsxs("svg",{viewBox:S,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,m]}),e[16]=o,e[17]=S,e[18]=x,e[19]=m,e[20]=b):b=e[20];let y;return e[21]!==w||e[22]!==b?(y=s.jsxs("div",{className:"relative w-full",children:[w,b]}),e[21]=w,e[22]=b,e[23]=y):y=e[23],y},Y3=t=>{const e=st.c(100),{onClose:n}=t,{t:r}=Nt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Je(eC),d=Ud(tC),h=Id(),f=gp(sC),p=Hs(nC),[g,w]=c.useState(rC),[S,x]=c.useState(oC),[m,b]=c.useState(iC),y=[{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 v;e[0]!==m.samples?(v=m.samples.reduce(aC,0),e[0]=m.samples,e[1]=v):v=e[1];const N=v,C=y.reduce(cC,0);let k;e[2]!==g.entries?(k=new Map,g.entries.forEach(Be=>{k.set(Be.metric,Be.count)}),e[2]=g.entries,e[3]=k):k=e[3];let D;e[4]!==k?(D=k.get("ui.message_list.render")??0,e[4]=k,e[5]=D):D=e[5];let P;e[6]!==k?(P=k.get("ui.message_list.render.streaming")??0,e[6]=k,e[7]=P):P=e[7];let I;e[8]!==k?(I=k.get("ui.chat_message.render")??0,e[8]=k,e[9]=I):I=e[9];let M;e[10]!==k?(M=k.get("ui.chat_message.render.streaming")??0,e[10]=k,e[11]=M):M=e[11];let _;e[12]!==k?(_=k.get("ui.chat_message.render.static_during_stream")??0,e[12]=k,e[13]=_):_=e[13];let O;e[14]!==k?(O=k.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=k,e[15]=O):O=e[15];let U;e[16]!==D||e[17]!==P||e[18]!==I||e[19]!==M||e[20]!==_||e[21]!==O?(U={messageListRender:D,messageListRenderStreaming:P,chatMessageRender:I,chatMessageRenderStreaming:M,chatMessageRenderStaticDuringStream:_,chatMessageRenderStaticOutsideActiveTurnDuringStream:O},e[16]=D,e[17]=P,e[18]=I,e[19]=M,e[20]=_,e[21]=O,e[22]=U):U=e[22];const L=U;let F,R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const Be=()=>{w(fo()),x(mo()),b(ua())};Be();const Ae=window.setInterval(Be,500);return()=>window.clearInterval(Ae)},F=[],e[23]=F,e[24]=R):(F=e[23],R=e[24]),c.useEffect(R,F);let j,A;e[25]!==l?(j=()=>{if(l==="idle")return;const Be=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Be)},A=[l],e[25]=l,e[26]=j,e[27]=A):(j=e[26],A=e[27]),c.useEffect(j,A);let B=0,X=0,H=0;for(const Be of Object.keys(f)){const Ae=f[Be]??[];X=X+Ae.length;for(const at of Ae)at.role==="user"?H=H+1:at.role==="assistant"&&(B=B+1)}let Z;e[28]!==B||e[29]!==X||e[30]!==H?(Z={assistant:B,total:X,user:H},e[28]=B,e[29]=X,e[30]=H,e[31]=Z):Z=e[31];const ce=Z;let Y;if(e[32]!==u||e[33]!==f||e[34]!==d||e[35]!==h||e[36]!==r){let Be;e[38]!==u||e[39]!==f||e[40]!==d||e[41]!==r?(Be=Ae=>{const at=f[Ae.id]??[];let Ue=0,ht=0;for(const Ct of at)Ct.role==="user"?ht=ht+1:Ct.role==="assistant"&&(Ue=Ue+1);const ut=d.get(Ae.id);return{id:Ae.id,title:Ae.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:Ue,messageCount:at.length,userMessageCount:ht,isStreaming:ut?.isStreaming||!1,isZombie:ut?.isZombie||!1,backgroundCount:ut?.backgroundMessageCount||0,lastAccessed:ut?.lastAccessedAt||0,isCurrent:Ae.id===u}},e[38]=u,e[39]=f,e[40]=d,e[41]=r,e[42]=Be):Be=e[42],Y=h.map(Be).sort(dC),e[32]=u,e[33]=f,e[34]=d,e[35]=h,e[36]=r,e[37]=Y}else Y=e[37];const se=Y;let oe;e[43]!==f?(oe=Object.keys(f),e[43]=f,e[44]=oe):oe=e[44];const Se=oe.length;let K;e[45]===Symbol.for("react.memo_cache_sentinel")?(K=async()=>{try{const Be={generatedAt:new Date().toISOString(),ui:fo(),vscode:mo()};await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),a("copied")}catch{a("error")}},e[45]=K):K=e[45];const pe=K,je=bp,ne="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let T;e[46]===Symbol.for("react.memo_cache_sentinel")?(T={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=T):T=e[46];let G;e[47]!==i?(G=Q3(i),e[47]=i,e[48]=G):G=e[48];let le;e[49]!==G?(le=s.jsx(E,{name:G,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=G,e[50]=le):le=e[50];let de;e[51]!==r?(de=r("memoryDebugPanel.title"),e[51]=r,e[52]=de):de=e[52];let ue;e[53]!==de?(ue=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:de}),e[53]=de,e[54]=ue):ue=e[54];let Oe;e[55]!==le||e[56]!==ue?(Oe=s.jsxs("div",{className:"flex items-center gap-2",children:[le,ue]}),e[55]=le,e[56]=ue,e[57]=Oe):Oe=e[57];let me;e[58]!==i?(me=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(xt,{size:"xs",variant:"ghost",onClick:pe,children:s.jsx(E,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(xt,{size:"xs",variant:"ghost",onClick:()=>{fm(),w(fo()),x(mo())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=me):me=e[59];let Re;e[60]!==i?(Re=i==="requests"?s.jsx(xt,{size:"xs",variant:"ghost",onClick:()=>{q3(),b(ua())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=Re):Re=e[61];let ye;e[62]!==n?(ye=n?s.jsx(xt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ye):ye=e[63];let q;e[64]!==me||e[65]!==Re||e[66]!==ye?(q=s.jsxs("div",{className:"flex items-center gap-1",children:[me,Re,ye]}),e[64]=me,e[65]=Re,e[66]=ye,e[67]=q):q=e[67];let we;e[68]!==Oe||e[69]!==q?(we=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Oe,q]}),e[68]=Oe,e[69]=q,e[70]=we):we=e[70];let be;e[71]===Symbol.for("react.memo_cache_sentinel")?(be={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=be):be=e[71];const Ne=i==="memory"?"secondary":"ghost";let ie;e[72]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>o("memory"),e[72]=ie):ie=e[72];let ee;e[73]!==r?(ee=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=ee):ee=e[74];let V;e[75]!==Ne||e[76]!==ee?(V=s.jsx(xt,{size:"sm",variant:Ne,className:"flex-1",onClick:ie,children:ee}),e[75]=Ne,e[76]=ee,e[77]=V):V=e[77];const $=i==="streaming"?"secondary":"ghost";let ae;e[78]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>o("streaming"),e[78]=ae):ae=e[78];let W;e[79]!==r?(W=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=W):W=e[80];let ve;e[81]!==$||e[82]!==W?(ve=s.jsx(xt,{size:"sm",variant:$,className:"flex-1",onClick:ae,children:W}),e[81]=$,e[82]=W,e[83]=ve):ve=e[83];const Fe=i==="requests"?"secondary":"ghost";let Ce;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>o("requests"),e[84]=Ce):Ce=e[84];let ke;e[85]!==r?(ke=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=ke):ke=e[86];let Qe;e[87]!==Fe||e[88]!==ke?(Qe=s.jsx(xt,{size:"sm",variant:Fe,className:"flex-1",onClick:Ce,children:ke}),e[87]=Fe,e[88]=ke,e[89]=Qe):Qe=e[89];let We;e[90]!==V||e[91]!==ve||e[92]!==Qe?(We=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:be,children:[V,ve,Qe]}),e[90]=V,e[91]=ve,e[92]=Qe,e[93]=We):We=e[93];const z=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(Ss,{label:r("memoryDebugPanel.metric.totalMessages"),value:ce.total}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Se} / ${hl.MAX_SESSIONS}`}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.userMessages"),value:ce.user}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ce.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:xp()})})]}),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:hl.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(cn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:se.map(Be=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Be.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:Be.title}),Be.isStreaming?s.jsx(E,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Be.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:Be.assistantMessageCount,user:Be.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Be.messageCount})}),Be.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Be.backgroundCount]}):null]})]},Be.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(uC),currentSessionId:u,cachedSessions:Object.keys(f),messageRoleCounts:ce,sessionMessageRoleCounts:se.map(fC),memoryStates:Object.fromEntries(d)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Pt,{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(xt,{size:"xs",variant:"outline",onClick:pe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Ss,{label:r("memoryDebugPanel.metric.uiMetrics"),value:g.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:S.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Yc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:g,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),S.entries.length>0?s.jsx(Yc,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:S,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(Ss,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(Ss,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?Af(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(Xc,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${N}`}),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:fa(m.peakAgeMs)})]}),s.jsx(Xc,{series:y.map(mC),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:fa(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(hC)}),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 he;return e[94]!==je||e[95]!==T||e[96]!==we||e[97]!==We||e[98]!==z?(he=s.jsxs(je,{className:ne,style:T,children:[we,We,z]}),e[94]=je,e[95]=T,e[96]=we,e[97]=We,e[98]=z,e[99]=he):he=e[99],he},X3=Y3;function J3(t,e){return t+e.count}function Z3(t,e){return Math.max(t,e.samples.length)}function eC(t){return t.currentSessionId}function tC(t){return t.sessionMemoryState}function sC(t){return t.message}function nC(t){return t.totalRequestCount}function rC(){return fo()}function oC(){return mo()}function iC(){return ua()}function aC(t,e){return Math.max(t,e)}function lC(t,e){return Math.max(t,e)}function cC(t,e){return e.samples.reduce(lC,t)}function dC(t,e){return e.lastAccessed-t.lastAccessed}function uC(t){return{id:t.id,title:t.title}}function fC(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function mC(t){return{samples:t.samples,color:t.color}}function hC(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:fa(t.current)})]},t.label)}const pC=()=>{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()??"":""},gC=async()=>{const t=pC()||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")},Jc="aiworker:menu-action",bi="aiworker:check-for-updates",xC=t=>{const e=Je(m=>m.openNewSessionDraft),n=Te(m=>m.toggleCommandPalette),r=Te(m=>m.setCommandPaletteOpen),i=Te(m=>m.toggleHelpDialog),o=Te(m=>m.toggleSidebar),l=Te(m=>m.setSessionSwitcherOpen),a=Te(m=>m.setSettingsDialogOpen),u=Te(m=>m.setAboutDialogOpen),d=Fr(m=>m.checkForUpdates),{setThemeMode:h}=Zn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,d().then(()=>{const{available:m,error:b}=Fr.getState();if(b){Le.error("Failed to check for updates",{description:b});return}m||Le.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[d]),g=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const b=yp();if(b.length===0)return;const y=Je.getState().currentSessionId,v=b.findIndex(k=>k.id===y);let N=m>0?0:b.length-1;v>=0&&(N=(v+m+b.length)%b.length);const C=b[N];C&&(l(!1),Je.getState().setCurrentSession(C.id))},[l]),S=c.useCallback(m=>{const{activeProjectId:b,projects:y,setActiveProject:v}=Ht.getState();if(y.length===0)return;const N=y.findIndex(D=>D.id===b);let C=m>0?0:y.length-1;N>=0&&(C=(N+m+y.length)%y.length);const k=y[C];k&&v(k.id)},[]),x=c.useCallback(m=>{switch(m){case"about":u(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const b=Je.getState(),y=ts.getState().currentDirectory;e(b.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Fd();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const b=ts.getState().currentDirectory;if(!b)break;const y=Te.getState(),v=or(b),N=y.contextPanelByDirectory[v];N?.isOpen?y.closeContextPanel(v):N?.activeTabId?y.setActiveContextPanelTab(v,N.activeTabId):y.openContextSurface(v,"git");break}case"open-right-sidebar-git":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"git");break}case"open-right-sidebar-files":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"file");break}case"toggle-terminal":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"terminal");break}case"toggle-terminal-expanded":{const b=ts.getState().currentDirectory;if(!b)break;const y=or(b),v=Te.getState(),N=v.contextPanelByDirectory[y];(N?.isOpen?N.tabs.find(k=>k.id===N.activeTabId)?.mode:null)!=="terminal"&&v.openContextSurface(y,"terminal"),v.toggleContextPanelExpanded(y);break}case"copy":{const b=new Event("aiworker:copy",{cancelable:!0});!window.dispatchEvent(b)||gC();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":wp();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ts.getState().goBack();break;case"go-forward":ts.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":S(-1);break;case"next-project":S(1);break;case"help-dialog":i();break;case"download-logs":{Bd().catch(()=>{Le.error("Failed to collect OpenCode status")});break}}},[g,S,w,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=y=>{const v=y.detail;v&&x(v)},b=()=>{p()};return window.addEventListener(Jc,m),window.addEventListener(bi,b),()=>{window.removeEventListener(Jc,m),window.removeEventListener(bi,b)}},[x,p]),c.useEffect(()=>{if(typeof window>"u")return;const b=window.__AIWORKER_DESKTOP__?.listen;if(typeof b!="function")return;let y=null,v=null;return b("aiworker:menu-action",N=>{const C=N?.payload;typeof C=="string"&&x(C)}).then(N=>{y=N}).catch(()=>{}),b("aiworker:check-for-updates",()=>{window.dispatchEvent(new Event(bi))}).then(N=>{v=N}).catch(()=>{}),()=>{(async()=>{try{const C=y?.();C instanceof Promise&&await C}catch{}try{const C=v?.();C instanceof Promise&&await C}catch{}})()}},[x])},bC="aiworker:tray-action",Zc=5e3,yC=500,Df=20,ed=()=>{if(typeof window>"u")return!1;const t=window.__AIWORKER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},td=()=>typeof window<"u"&&window.__AIWORKER_ELECTRON__?.trayEnabled!==!1,wC=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},SC=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Pf=(t,e)=>Gd(t,e,Wr.getState().ids,ja.getState().rankById),vC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},jC=(t,e,n,r,i)=>{if(!t)return"";const o=hd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||vC(t),u=go(t);let d=u&&i.get(u)||"";if(!d){for(const[h,f]of Dn.getState().directories)if(go(h)===u){d=f.status?.current??"";break}}if(!d)for(const h of r.values()){const f=h.find(p=>go(p.path)===u);if(f?.branch){d=f.branch;break}}return d?`${a} · ${d}`:a},kC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ar.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 jp){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;u.push({label:Cp(h),value:kp(f.valueLabel,p)})}const d=!a.ok&&a.error?a.error:u.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:u,status:d})}return{mode:r,groups:o}},CC=async()=>{try{if(Wo())return"Local AiWorker";const t=window.__AIWORKER_LOCAL_ORIGIN__||window.location.origin,e=Nn();if(e&&Qa(e,t))return"Local AiWorker";const r=(await ld()).hosts.find(i=>e?Qa(e,mm(i)):!1);return r?.label?.trim()?cd(r.label.trim()):"Instance"}catch{return""}},NC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Do()}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(go(o)??o,a.vcs.branch);for(const u of a.session)u?.id&&r.set(u.id,u.title);for(const[u,d]of Object.entries(a.session_status??{})){const h=d?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,f)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:wC(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:SC(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},AC=()=>{const t=Is.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Pf).slice(0,Df).forEach(r=>{const i=Ts(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=Ts(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},DC=t=>{const e=NC(),n=Da.getState().index.session,r=Is.getState().activeSessions,i=new Map(e.titleById),o=new Map;for(const x of r)if(x?.id&&(x.title&&i.set(x.id,x.title),x.parentID)){const m=o.get(x.parentID)??[];m.push(x.id),o.set(x.parentID,m)}const l=x=>{const m=[],b=[...o.get(x)??[]],y=new Set;for(;b.length;){const v=b.pop();y.has(v)||(y.add(v),m.push(v),b.push(...o.get(v)??[]))}return m},a=Aa.getState().statusById,u=x=>{const m=e.statusById.get(x);return m&&m!=="idle"?m:a.get(x)?.status.type??m??"idle"},d=x=>{const m=x.map(b=>u(b));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=Ht.getState().projects,f=Je.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort(Pf).slice(0,Df).map(x=>{const m=[x.id,...l(x.id)],b=Ts(x)??"";return{id:x.id,title:x.title||"Untitled session",status:d(m),branch:b?e.branchByDirectory.get(b)??"":"",unseen:m.reduce((y,v)=>y+(n.unseenCount[v]??0),0),hasError:m.some(y=>n.unseenHasError[y]??!1),directory:b,subtitle:jC(b,x,h,f,e.branchByDirectory)}}),g=e.approvals.map(x=>({...x,sessionTitle:i.get(x.sessionId)||""})),w=Te.getState();let S=0;if(w.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let m=n.unseenCount[x.id]??0;m===0&&w.notifyOnSubtasks&&(m=l(x.id).reduce((b,y)=>b+(n.unseenCount[y]??0),0)),m>0&&(S+=1)}return{sessions:p,approvals:g,instanceName:t,usage:kC(),dockBadgeCount:S}},PC=()=>{c.useEffect(()=>{if(!ed()||!td()||!Vo())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=DC(r),k=JSON.stringify(C);k!==e&&(e=k,Mn("desktop_tray_update",C))};CC().then(C=>{t||(r=C,i())});const o=async()=>{const C=AC();await Promise.all([...C.entries()].map(async([k,D])=>{const P=await Qs.getSessionStatusForDirectory(k).catch(()=>null);t||P===null||Sp(k,P,D)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},yC))},a=new Map,u=()=>{if(t)return;let C;try{C=Do()}catch{return}const k=new Set;for(const[D,P]of C.children.entries())k.add(D),a.has(D)||a.set(D,P.subscribe(()=>l()));for(const[D,P]of a)k.has(D)||(P(),a.delete(D))};let d=null;try{d=Do().subscribeRegistry(()=>{u(),l()})}catch{}u();const h=Da.subscribe(()=>l()),f=Is.subscribe(()=>l()),p=Ht.subscribe(()=>l()),g=Je.subscribe(()=>l()),w=Dn.subscribe(()=>l()),S=Te.subscribe(()=>l()),x=Aa.subscribe(()=>l()),m=ja.subscribe(()=>l()),b=Wr.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},Zc),v=ar.subscribe(()=>l());ar.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:C,results:k}=ar.getState();C.length>0&&C.some(P=>!k.some(I=>I.providerId===P))&&ar.getState().fetchQuotas(C)});const N=window.setInterval(()=>{u(),i()},Zc);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),h(),f(),p(),g(),w(),S(),x(),m(),b(),v(),d?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!ed()||!td()||typeof window>"u")return;const e=window.__AIWORKER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&vp(i.sessionId,i.id,i.response).catch(()=>{Le.error("Failed to respond to permission request")})};let r=null;return e(bC,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{}}},[])},IC=45e3,TC=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,IC);return()=>r(i)},RC=t=>{const e=st.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return TC(EC,MC)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function EC(){Np(Po())}function MC(){Ta()}const OC="/api/notifications/stream",FC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),BC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="aiworker:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},_C=t=>{const e=st.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||bn()||!ha()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ud().sse(OC));return o.onmessage=LC,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function LC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Te.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&FC())return;const r=BC(e);if(!r)return;zo()?.notifications?.notifyAgentCompletion(r)}const $C=6e4,WC=t=>{const e=st.c(10),n=Te(zC),r=Ap(VC),o=Dg(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:$C})},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 u,d;e[5]!==n||e[6]!==r||e[7]!==o?(u=()=>{if(n)return Yr(h=>{h.type==="agent-memory-changed"&&r(o)})},d=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=u,e[9]=d):(u=e[8],d=e[9]),c.useEffect(u,d)};function zC(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function VC(t){return t.load}const sd="pwa-install-toast-shown",nd="pwa-install-toast-dismissed",UC=()=>{const t=st.c(6),{browserTab:e}=Pg(),{t:n}=Nt(),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"||!ha()||!e)return;let u=null,d=null;const h=()=>{d!==null&&(Le.dismiss(d),d=null)},f=async()=>{if(!u)return;const w=u;u=null,h(),await w.prompt();const{outcome:S}=await w.userChoice;S==="accepted"&&Le.success(r.current("pwa.installPrompt.started"))},p=w=>{const S=w;if(typeof S.prompt!="function")return;S.preventDefault(),u=S;const x=No(),m=hm();Ig({dismissed:x.getItem(nd),sessionShown:m.getItem(sd),hasActiveToast:d!==null})&&(m.setItem(sd,"true"),d=Le.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:()=>{No().setItem(nd,"true"),h()}}}))},g=()=>{u=null,h(),Le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",g),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",g)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},KC=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[u,d]=c.useState(!1),[h,f]=c.useState(!1),[p,g]=c.useState(null),[w,S]=c.useState(!1);c.useCallback(async()=>{},[p,u,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const b=await ds("/api/system/info");if(b.ok){const y=await b.json();if(typeof y.aiworkerVersion=="string"&&y.aiworkerVersion.trim()){o(y.aiworkerVersion);return}}}catch{}o(await Dp())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const y=await ds("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!y.ok)return;const v=await y.json().catch(()=>null),N=typeof v?.currentVersion=="string"?v.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{g(null),S(!1);return}},[t,r]);const x=i;return s.jsx(vs,{open:t,onOpenChange:e,children:s.jsx(js,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Td,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"AiWorker"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),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://roweb.cn/roweb/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(E,{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(E,{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(E,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@aiworker_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},rd=t=>{if(!(typeof window>"u")){if(t){window.location.href="aiworker://focus/mcp-auth";return}window.location.replace("/")}},yi=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},HC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to AiWorker and click Authorize again.":n},GC=()=>{const t=Pp(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),u=yi(a,"code"),d=Ip(a),h=Tp(a),f=yi(a,"error"),p=yi(a,"error_description");if(f){h&&ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(p??f);return}(async()=>{try{if(!u)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");let g=d,w=!1;if(h){const S=await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(S.ok){const x=await S.json().catch(()=>null);w=x?.origin===Rp,i(w),!g&&x?.name?.trim()&&(g={name:x.name.trim(),directory:typeof x.directory=="string"&&x.directory.trim()?x.directory.trim():null})}}if(!g?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");await t(g.name,u,g.directory),h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&rd(!0),l("Authorization completed. You can close this tab and return to AiWorker.")}catch(g){h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(HC(g,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:Ep,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Ie("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(xt,{type:"button",onClick:()=>rd(r),children:"Return to AiWorker"})})]})})},od=Ln(()=>Bn(()=>import("./OnboardingScreen-CTuu4lgo.js"),__vite__mapDeps([145,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])).then(t=>({default:t.OnboardingScreen}))),qC=()=>{const t=st.c(3),e=Te(e5),n=Te(t5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(KC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},QC=t=>{const e=st.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=Nt();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let u;e[6]!==a?(u=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,u]}),e[8]=l,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(xt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let p;return e[18]!==d||e[19]!==f?(p=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[d,f]})}),e[18]=d,e[19]=f,e[20]=p):p=e[20],p},id=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",YC=()=>{if(typeof window>"u"||!nx())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}},XC=()=>typeof window>"u"?!1:window.location.pathname===_p,JC=t=>{const e=st.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ts(s5),l=Je(n5),a=Je(r5),u=Cd(),d=c.useRef(null);let h;e[0]!==n.directory?(h=id(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let p;e[2]!==o?(p=id(o),e[2]=o,e[3]=p):p=e[3];const g=p;let w,S;if(e[4]!==g||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==u?(w=()=>{if(r||f&&g!==f)return;const N=`${f}
930
930
  ${n.sessionId}`;d.current===N&&l||(d.current=N,a(n.sessionId,n.directory),u.ensureSessionRenderable(n.sessionId,!0))},S=[g,l,n.directory,n.sessionId,f,r,a,u],e[4]=g,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=u,e[12]=w,e[13]=S):(w=e[12],S=e[13]),c.useEffect(w,S),f&&g!==f)return null;let x;e[14]!==i?(x=s.jsx(Xd,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=x):x=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(au,{}),e[16]=m):m=e[16];let b;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(b=s.jsx(iu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=b):b=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Jd,{}),e[21]=y):y=e[21];let v;return e[22]!==x||e[23]!==b?(v=s.jsxs(s.Fragment,{children:[x,m,b,y]}),e[22]=x,e[23]=b,e[24]=v):v=e[24],v};function ZC({apis:t}){c.useEffect(()=>{pm("App:mounted"),gm()&&console.info("[startup-trace] enabled. Run console.table(window.__AIWORKER_STARTUP_TRACE__) after startup.")},[]);const e=qt(T=>T.initializeApp),n=qt(T=>T.isInitialized),r=qt(T=>T.isConnected),i=qt(T=>T.providers.length),o=qt(T=>T.agents.length),l=qt(T=>T.loadProviders),a=qt(T=>T.loadAgents),u=Je(T=>T.error),d=Je(T=>T.clearError),h=ts(T=>T.currentDirectory),f=ts(T=>T.setDirectory),p=ts(T=>T.isSwitchingDirectory),[g,w]=c.useState(!1),S=An(T=>T.refreshStatus),x=Ni(T=>T.refreshStatus),[m,b]=c.useState(()=>t.runtime.isVSCode),[y,v]=c.useState(!1),[N,C]=c.useState(!1),[k,D]=c.useState(0),[P,I]=c.useState(0),[M,_]=c.useState(!1),O=Te(T=>T.wideChatLayoutEnabled),U=Te(T=>T.mobileKeyboardMode),L=c.useMemo(()=>bn(),[]),F=ba(T=>T.setPlanModeEnabled),[R,j]=c.useState(()=>Ya()),[A,B]=c.useState(()=>{const T=Xa();return T!==null?Ja({isDesktopShell:!0,bootOutcome:T}):null}),X=c.useRef(!1),H=c.useMemo(()=>YC(),[]),Z=!H||y,ce=c.useMemo(()=>XC(),[]);c.useEffect(()=>(Za(g),()=>{Za(!1)}),[g]),c.useEffect(()=>(qc(g),()=>{qc(!1)}),[g]),c.useEffect(()=>{xm(U)},[U]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>ma(T=>{Tg(T),I(G=>G+1),C(!1),D(G=>G+1)}),[]);const Y=pl(T=>{const G=us();return Object.values(T.runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===G).map(le=>`${le.originalSessionID}:${le.phase}:${le.lastForwardedMessageID??""}:${le.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(H)return;const T=us(),G=Object.values(pl.getState().runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===T);for(const le of G)Mp(le.originalSessionID)},[Y,H,P]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",O),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[O]),c.useEffect(()=>(el(t),()=>el(null)),[t]),c.useEffect(()=>{H||(S(t.github,{force:!0}),x(t.linear,{force:!0}))},[t.github,t.linear,H,r,S,x,P]),Op();const se=R==="valid",oe=A?.screen==="main";c.useEffect(()=>{if(!bm({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:se,bootViewIsMain:oe}))return;const T=setTimeout(()=>{const G=document.getElementById("initial-loading");G&&(G.classList.add("fade-out"),setTimeout(()=>{G.remove()},300))},150);return()=>clearTimeout(T)},[L,n,se,oe]),c.useEffect(()=>{if(!L||R!=="malformed")return;const T=document.getElementById("initial-loading");T&&(T.textContent="Desktop startup failed — please restart the app.")},[L,R]),c.useEffect(()=>{if(L)return;const T=setTimeout(()=>{const G=document.getElementById("initial-loading");G&&!n&&(G.classList.add("fade-out"),setTimeout(()=>{G.remove()},300))},5e3);return()=>clearTimeout(T)},[L,n]),c.useEffect(()=>{let T=!1;return(async()=>{const le=await ds("/health",{method:"GET"}).catch(()=>null);if(!le||!le.ok||T)return;const de=await le.json().catch(()=>null);if(!de||T)return;const ue=de.planModeExperimentalEnabled;F(ue===!0||ue===1||ue==="1"||ue==="true")})(),()=>{T=!0}},[F]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let T=!0,G,le=0;const de=10,ue=1e3,Oe=async()=>{if(!T)return;if(le>=de){C(!0);return}const me=qt.getState();if(me.isInitialized){C(!1);return}le+=1,await me.initializeApp();const Re=qt.getState();if(!T)return;if(Re.isInitialized){C(!1);return}if(le>=de){C(!0);return}const ye=Math.min(ue*Math.pow(2,le-1),16e3);G=setTimeout(Oe,ye)};return G=setTimeout(Oe,ue),()=>{T=!1,G&&clearTimeout(G)}},[k,n,m]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!N)return;const T=document.getElementById("initial-loading");T&&(T.classList.add("fade-out"),setTimeout(()=>{T.remove()},300))},[N]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let T=!0,G=0;const le=15,de=async()=>{const Oe=qt.getState();if(!(Oe.providers.length>0&&Oe.agents.length>0))try{Oe.providers.length===0&&await l({source:"startupRecovery"}),qt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};de();const ue=setInterval(()=>{if(T){if(++G>=le){clearInterval(ue);return}de()}},2e3);return()=>{T=!1,clearInterval(ue)}},[r,m,a,l,i,o]),c.useEffect(()=>{p||m||r&&Qs.setDirectory(h)},[h,p,r,m]),c.useEffect(()=>{if(!H||typeof window>"u")return;const T=de=>{v(de?.visible===!0)},G=de=>{if(de.origin!==window.location.origin||de.source!==window.parent)return;const ue=de.data;ue?.type===gu&&T(ue.payload)},le=window;return le.__aiworkerSetEmbeddedVisibility=T,window.addEventListener("message",G),sx(),()=>{window.removeEventListener("message",G),le.__aiworkerSetEmbeddedVisibility===T&&delete le.__aiworkerSetEmbeddedVisibility}},[H]),c.useEffect(()=>{!H?.directory||m||h!==H.directory&&f(H.directory,{showOverlay:!1})},[h,H,m,f]),c.useEffect(()=>{if(!H||typeof window>"u")return;const T=G=>{G.storageArea===window.localStorage&&G.key==="ui-store"&&Te.persist.rehydrate()};return window.addEventListener("storage",T),()=>{window.removeEventListener("storage",T)}},[H]),c.useEffect(()=>{if(typeof window>"u")return;const T=G=>{const le=G.detail,de=typeof le?.sessionId=="string"?le.sessionId.trim():"";if(!de)return;const ue=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null;Je.getState().setCurrentSession(de,ue)};return window.addEventListener("aiworker:open-session",T),()=>window.removeEventListener("aiworker:open-session",T)},[]),c.useEffect(()=>{if(typeof window>"u")return;const T=()=>{Mn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("aiworker:open-mini-chat",T),()=>window.removeEventListener("aiworker:open-mini-chat",T)},[]),c.useEffect(()=>{if(typeof window>"u")return;const T=()=>{const G=Je.getState().currentSessionId;G&&Rd(G)};return window.addEventListener("focus",T),()=>window.removeEventListener("focus",T)},[]),c.useEffect(()=>{if(typeof window>"u")return;const T=G=>{const le=G.detail,de=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null,ue=typeof le?.projectId=="string"&&le.projectId.trim().length>0?le.projectId.trim():null,Oe=!!(de||ue);Te.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({target:Oe?"project":"chat",selectedProjectId:Oe?ue:null,directoryOverride:Oe?de:null,preserveDirectoryOverride:!!de})};return window.addEventListener("aiworker:open-draft-session",T),()=>window.removeEventListener("aiworker:open-draft-session",T)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||X.current||(X.current=!0,window.__aiworkerAppReady=!0,window.dispatchEvent(new Event("aiworker:app-ready")))},[n,p]),Fp({enabled:Z}),_C({enabled:Z}),WC(h||null),UC(),Bp(),Xp(),Rg();const Se=c.useCallback(()=>{w(T=>!T)},[]);xC(Se),PC(),RC(!H),c.useEffect(()=>{if(H)return;const T=()=>w(G=>!G);return window.addEventListener("aiworker:memory-debug-toggle",T),()=>window.removeEventListener("aiworker:memory-debug-toggle",T)},[H]),c.useEffect(()=>{H||u&&setTimeout(()=>d(),5e3)},[d,H,u]),c.useEffect(()=>{if(!L||R!=="not-injected")return;let T=!1,G=0;const le=200,de=2e3,ue=50,Oe=()=>{if(T)return;G++;const me=Ya();if(me!=="not-injected"){if(T=!0,j(me),me==="valid"){const ye=Xa();ye&&B(Ja({isDesktopShell:!0,bootOutcome:ye}))}return}const Re=Math.min(le*Math.pow(1.1,G),de);if(G>=ue){const ye=document.getElementById("initial-loading");ye&&!ye.textContent?.includes("taking longer")&&(ye.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Oe,Re)};return window.setTimeout(Oe,le),()=>{T=!0}},[L,R]);const K=c.useCallback(async()=>{if(ym({isDesktopShell:bn(),isDesktopLocalOriginActive:Wo()})){await wm();return}window.location.reload()},[]),pe=c.useCallback(async()=>{if(!M){C(!1),_(!0);try{await qt.getState().initializeApp()}finally{_(!1)}qt.getState().isInitialized||D(T=>T+1)}},[M]),je=T=>{if(T.screen==="recovery")return T.variant};if(L&&A&&A.screen!=="main"){if(A.screen==="chooser")return s.jsx(Gs,{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:A.localAvailable!==!1,onCliAvailable:K,onChooseRemote:()=>{}})})})});const T=je(A),G=A.screen==="recovery"&&"url"in A?A.url:void 0;return s.jsx(Gs,{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:T,recoveryHostUrl:G,recoveryHostLabel:void 0,localAvailable:A.localAvailable!==!1,onCliAvailable:K})})})})}if(H)return s.jsx(Gs,{children:s.jsx(gl,{sdk:Qs.getSdkClient(),directory:h||"",children:s.jsx(xl,{apis:t,children:s.jsx(Ri,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(JC,{embeddedSessionChat:H,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:Z}),s.jsx(bl,{}),s.jsx(yl,{})]})})})},P)});if(ce)return s.jsx(Gs,{children:s.jsx(GC,{})});if(N&&!n&&!m&&!H)return s.jsx(Gs,{children:s.jsx(QC,{onRetry:()=>{pe()},isRetrying:M})});const ne=!n&&!L;return s.jsx(Gs,{children:s.jsx(gl,{sdk:Qs.getSdkClient(),directory:h||"",children:s.jsx(xl,{apis:t,children:s.jsx(L3,{children:s.jsx(Ri,{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(Xd,{embeddedBackgroundWorkEnabled:Z}),s.jsx(au,{}),s.jsx(x3,{}),s.jsx(Jd,{}),s.jsx(bl,{}),s.jsx(yl,{}),!ne&&s.jsxs(s.Fragment,{children:[s.jsx(Eg,{}),s.jsx(qC,{}),g&&s.jsx(X3,{onClose:()=>w(!1)})]})]})})})})},P)})}function e5(t){return t.isAboutDialogOpen}function t5(t){return t.setAboutDialogOpen}function s5(t){return t.currentDirectory}function n5(t){return t.currentSessionId}function r5(t){return t.setCurrentSession}const o5=typeof window<"u"&&window.__AIWORKER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Lp();Sm().then(()=>{Promise.all([vm(),$p()]).catch(t=>{console.error("[main] settings init failed:",t)}),Wp(),zp(),Vp()}).catch(t=>{console.error("[main] appearance init failed:",t)});const If=document.getElementById("root");if(!If)throw new Error("Root element not found");Up();Uf.createRoot(If).render(s.jsx(gt.StrictMode,{children:s.jsx(Kp,{children:s.jsx(Hp,{children:s.jsx(Gp,{children:s.jsx(qp,{children:s.jsx(ZC,{apis:o5})})})})})}));const j5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Bb as W,Nb as a,v5 as b,Lu as g,j5 as m,Fb as u,_u as v};